diff --git a/.github/workflows/ci-account-pack.yaml b/.github/workflows/ci-account-pack.yaml new file mode 100644 index 00000000000..6f35bf74ee3 --- /dev/null +++ b/.github/workflows/ci-account-pack.yaml @@ -0,0 +1,140 @@ +name: 'CI: Account Pack Check' + +on: + pull_request: + branches-ignore: [wip/*, draft/*, temp/*] + paths: + - 'packages/account/**' + - 'packages/ingest-types/**' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + verify-pack-contents: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + package: [account, ingest-types] + steps: + - uses: actions/checkout@v7 + + - name: Setup frontend + uses: ./.github/actions/setup-frontend + + - name: Typecheck + run: pnpm -C packages/${{ matrix.package }} typecheck + + - name: Build package + run: pnpm -C packages/${{ matrix.package }} build + + - name: Verify packed tarball only contains compiled dist output + shell: bash + run: | + set -euo pipefail + UNEXPECTED=$( + pnpm -C packages/${{ matrix.package }} pack --dry-run --json | + jq -r ' + .files[].path + | select( + . != "package.json" + and . != "LICENSE" + and . != "README.md" + and (startswith("dist/") | not) + ) + ' + ) + if [ -n "$UNEXPECTED" ]; then + echo "::error title=Unexpected files in tarball::Packed tarball contains files outside dist:" >&2 + echo "$UNEXPECTED" >&2 + exit 1 + fi + echo 'Packed tarball contains only expected files.' + + - name: Verify published manifest resolves to dist and pins real versions + shell: bash + run: | + set -euo pipefail + PACK_DIR="$RUNNER_TEMP/${{ matrix.package }}-pack" + rm -rf "$PACK_DIR" + mkdir -p "$PACK_DIR" + pnpm -C packages/${{ matrix.package }} pack --pack-destination "$PACK_DIR" + TARBALL=$(find "$PACK_DIR" -maxdepth 1 -name '*.tgz' | head -n 1) + if [ -z "$TARBALL" ]; then + echo "::error title=Pack failed::No tarball produced in $PACK_DIR" >&2 + exit 1 + fi + MANIFEST=$(tar -xzOf "$TARBALL" package/package.json) + NON_DIST_EXPORTS=$( + printf '%s' "$MANIFEST" | + jq -r ' + [ + .exports + | .. + | strings + | select(. != "./package.json" and (startswith("./dist/") | not)) + ] + | join(", ") + ' + ) + if [ -n "$NON_DIST_EXPORTS" ]; then + echo "::error title=Exports escape dist::Published exports must resolve to compiled dist output, got: $NON_DIST_EXPORTS" >&2 + exit 1 + fi + PACKED_FILES=$(tar -tzf "$TARBALL" | sed -n 's#^package/##p') + MISSING_TARGETS='' + while IFS= read -r TARGET; do + [ -n "$TARGET" ] || continue + PATTERN=${TARGET#./} + FOUND='' + while IFS= read -r PACKED; do + # Unquoted: pattern exports like ./dist/* must glob-match. + case "$PACKED" in + $PATTERN) + FOUND=yes + break + ;; + esac + done <<< "$PACKED_FILES" + if [ -z "$FOUND" ]; then + MISSING_TARGETS="${MISSING_TARGETS}${TARGET}"$'\n' + fi + done <<< "$(printf '%s' "$MANIFEST" | jq -r '[.exports | .. | strings] | unique[]')" + if [ -n "$MISSING_TARGETS" ]; then + echo "::error title=Exports missing from tarball::Published exports point at files the tarball does not contain:" >&2 + printf '%s' "$MISSING_TARGETS" >&2 + echo "Packed files:" >&2 + printf '%s\n' "$PACKED_FILES" >&2 + exit 1 + fi + UNRESOLVED=$( + printf '%s' "$MANIFEST" | + jq -r ' + (.dependencies // {}) + (.peerDependencies // {}) + | to_entries[] + | select(.value | test("^(catalog:|workspace:)")) + | "\(.key)@\(.value)" + ' + ) + if [ -n "$UNRESOLVED" ]; then + echo "::error title=Unresolved workspace specifiers::Published manifest must not contain catalog:/workspace: ranges:" >&2 + echo "$UNRESOLVED" >&2 + exit 1 + fi + echo 'Published manifest resolves to dist with real dependency ranges.' + + smoke-consumer: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + + - name: Setup frontend + uses: ./.github/actions/setup-frontend + + - name: Install the packed tarballs into a clean consumer and import every entry + run: pnpm --filter @comfyorg/account smoke:pack diff --git a/eslint.config.ts b/eslint.config.ts index 2d887dfeeb0..76c104ccba2 100644 --- a/eslint.config.ts +++ b/eslint.config.ts @@ -206,6 +206,7 @@ export default defineConfig([ 'packages/account-ui/vitest.config.ts', 'packages/billing-contract/vitest.config.ts', 'packages/design-system/vitest.config.ts', + 'packages/ingest-types/openapi-ts.config.ts', 'packages/object-info-parser/vitest.config.ts', 'packages/shared-frontend-utils/vitest.config.ts', 'vite.electron.config.mts', diff --git a/packages/account/LICENSE b/packages/account/LICENSE new file mode 100644 index 00000000000..7ceb934bd26 --- /dev/null +++ b/packages/account/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 Comfy Org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/account/package.json b/packages/account/package.json index d4d82c1d195..2b4e2d5ee32 100644 --- a/packages/account/package.json +++ b/packages/account/package.json @@ -6,9 +6,7 @@ "keywords": [], "license": "MIT", "files": [ - "src", - "!src/**/*.test.ts", - "!src/**/__fixtures__" + "dist" ], "type": "module", "exports": { @@ -39,9 +37,111 @@ "./package.json": "./package.json" }, "publishConfig": { + "exports": { + "./boundedOperation": { + "types": "./dist/core/boundedOperation.d.ts", + "import": "./dist/core/boundedOperation.js" + }, + "./lazyIdentity": { + "types": "./dist/core/lazyIdentity.d.ts", + "import": "./dist/core/lazyIdentity.js" + }, + "./session": { + "types": "./dist/core/session.d.ts", + "import": "./dist/core/session.js" + }, + "./billing": { + "types": "./dist/core/billing/index.d.ts", + "import": "./dist/core/billing/index.js" + }, + "./firebase": { + "types": "./dist/firebase/index.d.ts", + "import": "./dist/firebase/index.js" + }, + "./web": { + "types": "./dist/web/crossTabRefresh.d.ts", + "import": "./dist/web/crossTabRefresh.js" + }, + "./vue/PasswordRules": { + "types": "./dist/vue/PasswordRules.vue.d.ts", + "import": "./dist/vue/PasswordRules.vue" + }, + "./vue/SocialAuthButtons": { + "types": "./dist/vue/SocialAuthButtons.vue.d.ts", + "import": "./dist/vue/SocialAuthButtons.vue" + }, + "./vue/TurnstileWidget": { + "types": "./dist/vue/TurnstileWidget.vue.d.ts", + "import": "./dist/vue/TurnstileWidget.vue" + }, + "./vue/regionGate": { + "types": "./dist/vue/regionGate.d.ts", + "import": "./dist/vue/regionGate.js" + }, + "./vue/turnstileGate": { + "types": "./dist/vue/turnstileGate.d.ts", + "import": "./dist/vue/turnstileGate.js" + }, + "./vue/lifecycleScope": { + "types": "./dist/vue/lifecycleScope.d.ts", + "import": "./dist/vue/lifecycleScope.js" + }, + "./vue/useGenerationGuard": { + "types": "./dist/vue/useGenerationGuard.d.ts", + "import": "./dist/vue/useGenerationGuard.js" + }, + "./testing": { + "types": "./dist/testing.d.ts", + "import": "./dist/testing.js" + }, + "./customerRecovery": { + "types": "./dist/core/customerRecovery.d.ts", + "import": "./dist/core/customerRecovery.js" + }, + "./signInSchemas": { + "types": "./dist/signInSchemas.d.ts", + "import": "./dist/signInSchemas.js" + }, + "./turnstile": { + "types": "./dist/turnstile.d.ts", + "import": "./dist/turnstile.js" + }, + "./turnstileScript": { + "types": "./dist/turnstileScript.d.ts", + "import": "./dist/turnstileScript.js" + }, + "./firebaseAuthError": { + "types": "./dist/firebaseAuthError.d.ts", + "import": "./dist/firebaseAuthError.js" + }, + "./provisioning": { + "types": "./dist/provisioning.d.ts", + "import": "./dist/provisioning.js" + }, + "./redirect": { + "types": "./dist/redirect.d.ts", + "import": "./dist/redirect.js" + }, + "./region": { + "types": "./dist/region.d.ts", + "import": "./dist/region.js" + }, + "./telemetry": { + "types": "./dist/telemetry.d.ts", + "import": "./dist/telemetry.js" + }, + "./webviewDetection": { + "types": "./dist/webviewDetection.d.ts", + "import": "./dist/webviewDetection.js" + }, + "./package.json": "./package.json" + }, "access": "public" }, "scripts": { + "build": "pnpm run clean && vue-tsc -p tsconfig.build.json && tsx scripts/copyVueSources.ts", + "clean": "node --input-type=module -e \"import { rmSync } from 'node:fs'; rmSync('dist', { recursive: true, force: true })\"", + "prepack": "pnpm run build", "lint": "oxlint src --type-aware && eslint src", "smoke:pack": "tsx scripts/smokePack.ts", "test": "vitest run", diff --git a/packages/account/scripts/copyVueSources.ts b/packages/account/scripts/copyVueSources.ts new file mode 100644 index 00000000000..98138c06666 --- /dev/null +++ b/packages/account/scripts/copyVueSources.ts @@ -0,0 +1,18 @@ +/** + * The Vue SFCs ship as source for the consumer's bundler: vue-tsc emits their + * declarations, this copies the `.vue` files next to them and drops the + * script-only `.vue.js` vue-tsc also writes. + */ +import { copyFileSync, readdirSync, rmSync } from 'node:fs' +import { join } from 'node:path' +import { fileURLToPath } from 'node:url' + +const packageDir = fileURLToPath(new URL('..', import.meta.url)) +const sourceDir = join(packageDir, 'src', 'vue') +const distDir = join(packageDir, 'dist', 'vue') + +for (const name of readdirSync(sourceDir)) { + if (!name.endsWith('.vue')) continue + rmSync(join(distDir, `${name}.js`), { force: true }) + copyFileSync(join(sourceDir, name), join(distDir, name)) +} diff --git a/packages/account/scripts/smokePack.ts b/packages/account/scripts/smokePack.ts index aec0274b24e..e85c23fa112 100644 --- a/packages/account/scripts/smokePack.ts +++ b/packages/account/scripts/smokePack.ts @@ -1,8 +1,12 @@ /** * Packs @comfyorg/account with `pnpm pack`, installs the tarball into a - * throwaway npm project alongside the declared peers, and imports every - * export entry from there: the consumer path where an unrewritten - * `catalog:` specifier or an export target missing from `files` first fails. + * throwaway npm project alongside the declared peers, and proves the published + * shape from there: plain node imports every built entry, tsc under nodenext + * resolves a type and a value from each through the published `types` + * conditions, and the Vue SFC entries resolve their declaration and ship their + * source for a bundler. This is the consumer path where an unrewritten + * `catalog:` specifier or an export target missing from the tarball first + * fails. * * ingest-types is not on npm yet, so it is packed too and pinned through npm * `overrides`; drop that once it is published. @@ -22,12 +26,16 @@ import { join, resolve } from 'node:path' import { fileURLToPath } from 'node:url' import { z } from 'zod' +const zExportTarget = z.union([ + z.string(), + z.object({ types: z.string(), import: z.string() }) +]) const zSpecifiers = z.record(z.string(), z.string()) const zManifest = z.object({ name: z.string(), version: z.string(), - exports: zSpecifiers, + exports: z.record(z.string(), zExportTarget), dependencies: zSpecifiers.optional(), peerDependencies: zSpecifiers.optional() }) @@ -37,6 +45,7 @@ const zPackResult = z.object({ files: z.array(z.object({ path: z.string() })) }) +type ExportTarget = z.infer type Manifest = z.infer type PackResult = z.infer @@ -46,7 +55,7 @@ const packagesDir = resolve(packageDir, '..') const keep = process.argv.includes('--keep') const WORKSPACE_ONLY_SPECIFIER = /^(catalog|workspace):/ -const NON_PUBLIC_FILE = /(\.test\.ts$|(^|\/)__fixtures__\/)/ +const NON_PUBLIC_FILE = /(\.test\.ts$|(^|\/)__fixtures__\/|^src\/)/ function run(command: string, args: string[], cwd: string): string { return execFileSync(command, args, { @@ -119,6 +128,10 @@ function packedManifest(tarball: string): Manifest { ) } +function targetFiles(target: ExportTarget): string[] { + return typeof target === 'string' ? [target] : [target.types, target.import] +} + function log(line: string): void { process.stdout.write(`${line}\n`) } @@ -127,9 +140,11 @@ function fail(message: string): never { throw new Error(message) } -function assertPublishable(source: Manifest, packed: PackResult): void { +function assertPublishable(packed: PackResult): Manifest { + const manifest = packedManifest(packed.filename) const shipped = new Set(packed.files.map((file) => file.path)) - const missingTargets = Object.values(source.exports) + const missingTargets = Object.values(manifest.exports) + .flatMap(targetFiles) .map((target) => target.replace(/^\.\//, '')) .filter((target) => !shipped.has(target)) if (missingTargets.length > 0) { @@ -139,9 +154,8 @@ function assertPublishable(source: Manifest, packed: PackResult): void { } const nonPublic = [...shipped].filter((path) => NON_PUBLIC_FILE.test(path)) if (nonPublic.length > 0) { - fail(`test-only files in the tarball:\n${nonPublic.join('\n')}`) + fail(`source or test-only files in the tarball:\n${nonPublic.join('\n')}`) } - const manifest = packedManifest(packed.filename) const unrewritten = Object.entries({ ...manifest.dependencies, ...manifest.peerDependencies @@ -153,25 +167,26 @@ function assertPublishable(source: Manifest, packed: PackResult): void { .join('\n')}` ) } - log(`packed ${source.name}: ${shipped.size} files, specifiers rewritten`) + log(`packed ${manifest.name}: ${shipped.size} files, specifiers rewritten`) + return manifest } -const CONSUMER_SOURCE = ` +const NODE_CONSUMER_SOURCE = ` import { existsSync } from 'node:fs' import { fileURLToPath } from 'node:url' import { createLazyIdentity } from '@comfyorg/account/lazyIdentity' -import type { AccountUser } from '@comfyorg/account/session' import { createSessionClient } from '@comfyorg/account/session' import { createTestIdentity } from '@comfyorg/account/testing' +import { zExchangeTokenResponse } from '@comfyorg/ingest-types/zod' -const identity = createTestIdentity({ +const identity = createTestIdentity({ onUserChanged: (callback) => { callback(null) return () => {} } }) const lazyIdentity = createLazyIdentity(async () => identity) -const memory = new Map() +const memory = new Map() const client = createSessionClient( { exchangeUrl: 'https://example.invalid/api/auth/token', @@ -193,6 +208,10 @@ if (beforeActivation !== 'pending' || afterActivation !== 'signed-out') { ) } console.log(\`session client: \${beforeActivation} -> \${afterActivation}\`) +if (typeof zExchangeTokenResponse.parse !== 'function') { + throw new Error('@comfyorg/ingest-types/zod did not load a zod schema') +} +console.log('@comfyorg/ingest-types/zod: imported under node') const { default: manifest } = await import('@comfyorg/account/package.json', { with: { type: 'json' } @@ -202,23 +221,145 @@ for (const subpath of Object.keys(manifest.exports)) { const target = fileURLToPath(import.meta.resolve(specifier)) if (!existsSync(target)) throw new Error(\`\${specifier} resolves to a missing file\`) if (target.endsWith('.vue')) { - console.log(\`\${specifier}: resolved (Vue SFC, needs a bundler to load)\`) + console.log(\`\${specifier}: source shipped for a bundler (\${target.slice(target.lastIndexOf('/dist/') + 1)})\`) continue } if (target.endsWith('.json')) await import(specifier, { with: { type: 'json' } }) else await import(specifier) - console.log(\`\${specifier}: imported\`) + console.log(\`\${specifier}: imported under node\`) } ` +const TYPED_CONSUMER_SOURCE = ` +import type { OperationHandle } from '@comfyorg/account/boundedOperation' +import { createBoundedOperation } from '@comfyorg/account/boundedOperation' +import type { LazyIdentity } from '@comfyorg/account/lazyIdentity' +import { createLazyIdentity } from '@comfyorg/account/lazyIdentity' +import type { AccountUser, SessionSnapshot } from '@comfyorg/account/session' +import { SESSION_ERROR_CODES, createSessionClient } from '@comfyorg/account/session' +import type { BillingErrorCode } from '@comfyorg/account/billing' +import { createSessionBillingTransport } from '@comfyorg/account/billing' +import type { FirebaseIdentityAppConfig } from '@comfyorg/account/firebase' +import { createFirebaseIdentity } from '@comfyorg/account/firebase' +import { createWebCrossTabRefreshPort } from '@comfyorg/account/web' +import type { IdentityPort } from '@comfyorg/account/testing' +import { createTestIdentity } from '@comfyorg/account/testing' +import type { CustomerRecoveryDeps } from '@comfyorg/account/customerRecovery' +import { MISSING_CUSTOMER_MESSAGE } from '@comfyorg/account/customerRecovery' +import type { AuthSchemaMessageKey } from '@comfyorg/account/signInSchemas' +import { PASSWORD_RULES } from '@comfyorg/account/signInSchemas' +import type { TurnstileMode } from '@comfyorg/account/turnstile' +import { normalizeTurnstileMode } from '@comfyorg/account/turnstile' +import type { TurnstileRenderOptions } from '@comfyorg/account/turnstileScript' +import { loadTurnstile } from '@comfyorg/account/turnstileScript' +import type { FirebaseAuthErrorLike } from '@comfyorg/account/firebaseAuthError' +import { isFirebaseAuthErrorLike } from '@comfyorg/account/firebaseAuthError' +import { signUpWithProvisioning } from '@comfyorg/account/provisioning' +import { safeInternalPath } from '@comfyorg/account/redirect' +import { getClientCountry } from '@comfyorg/account/region' +import type { AuthMethod } from '@comfyorg/account/telemetry' +import { SESSION_TELEMETRY_EVENT } from '@comfyorg/account/telemetry' +import { isEmbeddedWebView } from '@comfyorg/account/webviewDetection' +import type { RegionGateStatus } from '@comfyorg/account/vue/regionGate' +import { useRegionGate } from '@comfyorg/account/vue/regionGate' +import { useTurnstileGate } from '@comfyorg/account/vue/turnstileGate' +import type { LifecycleScope } from '@comfyorg/account/vue/lifecycleScope' +import { createLifecycleScope } from '@comfyorg/account/vue/lifecycleScope' +import { useGenerationGuard } from '@comfyorg/account/vue/useGenerationGuard' +import type PasswordRules from '@comfyorg/account/vue/PasswordRules' +import type SocialAuthButtons from '@comfyorg/account/vue/SocialAuthButtons' +import type TurnstileWidget from '@comfyorg/account/vue/TurnstileWidget' +import type { ExchangeTokenResponse } from '@comfyorg/ingest-types' +import { zExchangeTokenResponse } from '@comfyorg/ingest-types/zod' + +export const values = { + createBoundedOperation, + createLazyIdentity, + SESSION_ERROR_CODES, + createSessionClient, + createSessionBillingTransport, + createFirebaseIdentity, + createWebCrossTabRefreshPort, + createTestIdentity, + MISSING_CUSTOMER_MESSAGE, + PASSWORD_RULES, + normalizeTurnstileMode, + loadTurnstile, + isFirebaseAuthErrorLike, + signUpWithProvisioning, + safeInternalPath, + getClientCountry, + SESSION_TELEMETRY_EVENT, + isEmbeddedWebView, + useRegionGate, + useTurnstileGate, + createLifecycleScope, + useGenerationGuard, + zExchangeTokenResponse +} + +export interface Types { + boundedOperation: OperationHandle + lazyIdentity: LazyIdentity + session: SessionSnapshot + billing: BillingErrorCode + firebase: FirebaseIdentityAppConfig + web: ReturnType + testing: IdentityPort + customerRecovery: CustomerRecoveryDeps + signInSchemas: AuthSchemaMessageKey + turnstile: TurnstileMode + turnstileScript: TurnstileRenderOptions + firebaseAuthError: FirebaseAuthErrorLike + provisioning: Parameters[0] + redirect: ReturnType + region: Awaited> + telemetry: AuthMethod + webviewDetection: ReturnType + regionGate: RegionGateStatus + turnstileGate: ReturnType + lifecycleScope: LifecycleScope + useGenerationGuard: ReturnType + passwordRules: InstanceType['$props']['password'] + socialAuthButtons: InstanceType['$props']['googleLabel'] + turnstileWidget: InstanceType['$props']['siteKey'] + ingestTypes: ExchangeTokenResponse +} + +export const exchange: Types['ingestTypes'] = zExchangeTokenResponse.parse({}) + +export interface RejectedByRealDeclarations { + // @ts-expect-error an any-typed declaration would accept this + session: SessionSnapshot['noSuchProperty'] + // @ts-expect-error an any-typed declaration would accept this + passwordRules: InstanceType['$props']['noSuchProp'] + // @ts-expect-error an any-typed declaration would accept this + socialAuthButtons: InstanceType['$props']['noSuchProp'] + // @ts-expect-error an any-typed declaration would accept this + turnstileWidget: InstanceType['$props']['noSuchProp'] +} +` + +function assertTypedConsumerCoversEveryExport(manifest: Manifest): void { + const uncovered = Object.keys(manifest.exports) + .filter((subpath) => subpath !== './package.json') + .map((subpath) => subpath.replace(/^\./, manifest.name)) + .filter((specifier) => !TYPED_CONSUMER_SOURCE.includes(`'${specifier}'`)) + if (uncovered.length > 0) { + fail( + `TYPED_CONSUMER_SOURCE does not import these exports:\n${uncovered.join('\n')}` + ) + } +} + function main(): void { - const source = readManifest(packageDir) const consumerDir = mkdtempSync(join(tmpdir(), 'comfyorg-account-smoke-')) const tarballDir = join(consumerDir, 'tarballs') mkdirSync(tarballDir) try { const packed = pack(packageDir, tarballDir) - assertPublishable(source, packed) + const manifest = assertPublishable(packed) + assertTypedConsumerCoversEveryExport(manifest) const siblings = workspaceDependencyClosure( packageDir, @@ -227,11 +368,10 @@ function main(): void { const overrides = Object.fromEntries( [...siblings].map(([name, dir]) => { const packedSibling = pack(dir, tarballDir) - assertPublishable(readManifest(dir), packedSibling) + assertPublishable(packedSibling) return [name, `file:${packedSibling.filename}`] }) ) - const peers = packedManifest(packed.filename).peerDependencies ?? {} writeFileSync( join(consumerDir, 'package.json'), JSON.stringify( @@ -240,8 +380,8 @@ function main(): void { private: true, type: 'module', dependencies: { - [source.name]: `file:${packed.filename}`, - ...peers + [manifest.name]: `file:${packed.filename}`, + ...manifest.peerDependencies }, overrides }, @@ -256,9 +396,25 @@ function main(): void { consumerDir ) - writeFileSync(join(consumerDir, 'consumer.ts'), CONSUMER_SOURCE) - const tsx = join(workspaceRoot, 'node_modules', '.bin', 'tsx') - process.stdout.write(run(tsx, ['consumer.ts'], consumerDir)) + writeFileSync(join(consumerDir, 'consumer.mjs'), NODE_CONSUMER_SOURCE) + process.stdout.write(run('node', ['consumer.mjs'], consumerDir)) + + writeFileSync(join(consumerDir, 'consumer.ts'), TYPED_CONSUMER_SOURCE) + const tsc = join(workspaceRoot, 'node_modules', '.bin', 'tsc') + execFileSync( + tsc, + [ + '--noEmit', + '--module', + 'nodenext', + '--moduleResolution', + 'nodenext', + '--strict', + 'consumer.ts' + ], + { cwd: consumerDir, stdio: 'inherit' } + ) + log('tsc (nodenext, strict): a type and a value resolved from every entry') log('packed tarball smoke test passed') } finally { if (keep) log(`kept ${consumerDir}`) diff --git a/packages/account/src/turnstileScript.ts b/packages/account/src/turnstileScript.ts index e80dfa54537..17fad9f1a13 100644 --- a/packages/account/src/turnstileScript.ts +++ b/packages/account/src/turnstileScript.ts @@ -1,4 +1,4 @@ -import { createScriptLoader } from './loadExternalScript' +import { createScriptLoader } from './loadExternalScript.js' const TURNSTILE_SRC = 'https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit' diff --git a/packages/account/src/vue/PasswordRules.vue b/packages/account/src/vue/PasswordRules.vue index 85c3030f85c..054b80dc8c1 100644 --- a/packages/account/src/vue/PasswordRules.vue +++ b/packages/account/src/vue/PasswordRules.vue @@ -30,9 +30,9 @@ */ import { computed } from 'vue' -import type { PasswordRule } from '../signInSchemas' -import { passwordRuleChecks } from '../signInSchemas' -import { cn } from './cn' +import type { PasswordRule } from '../signInSchemas.js' +import { passwordRuleChecks } from '../signInSchemas.js' +import { cn } from './cn.js' export type PasswordRulesCopy = Readonly< Record diff --git a/packages/account/src/vue/TurnstileWidget.vue b/packages/account/src/vue/TurnstileWidget.vue index 8f55b7c3ac9..05cee0deb30 100644 --- a/packages/account/src/vue/TurnstileWidget.vue +++ b/packages/account/src/vue/TurnstileWidget.vue @@ -15,8 +15,8 @@ import { useTimeoutFn } from '@vueuse/core' import { onBeforeUnmount, onMounted, ref } from 'vue' -import type { TurnstileApi } from '../turnstileScript' -import { loadTurnstile } from '../turnstileScript' +import type { TurnstileApi } from '../turnstileScript.js' +import { loadTurnstile } from '../turnstileScript.js' const { siteKey, diff --git a/packages/account/src/vue/regionGate.ts b/packages/account/src/vue/regionGate.ts index 184decb3858..d2364e0ba6f 100644 --- a/packages/account/src/vue/regionGate.ts +++ b/packages/account/src/vue/regionGate.ts @@ -1,7 +1,7 @@ import { onMounted, readonly, ref, watch } from 'vue' import type { Ref } from 'vue' -import { isInChina } from '../region' +import { isInChina } from '../region.js' export type RegionGateStatus = 'pending' | 'blocked' | 'allowed' diff --git a/packages/account/tsconfig.build.json b/packages/account/tsconfig.build.json new file mode 100644 index 00000000000..37126ac77ca --- /dev/null +++ b/packages/account/tsconfig.build.json @@ -0,0 +1,32 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "noEmit": false, + "allowImportingTsExtensions": false, + "declaration": true, + "declarationMap": false, + "sourceMap": false, + "incremental": false, + "noEmitOnError": true, + "types": [] + }, + "include": [ + "src/core/**/*.ts", + "src/firebase/index.ts", + "src/web/crossTabRefresh.ts", + "src/vue/*.ts", + "src/vue/*.vue", + "src/testing.ts", + "src/signInSchemas.ts", + "src/turnstile.ts", + "src/turnstileScript.ts", + "src/loadExternalScript.ts", + "src/region.ts", + "src/firebaseAuthError.ts", + "src/provisioning.ts", + "src/redirect.ts", + "src/telemetry.ts", + "src/webviewDetection.ts" + ], + "exclude": ["src/**/*.test.ts", "src/**/__fixtures__/**"] +} diff --git a/packages/ingest-types/LICENSE b/packages/ingest-types/LICENSE new file mode 100644 index 00000000000..7ceb934bd26 --- /dev/null +++ b/packages/ingest-types/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 Comfy Org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/ingest-types/openapi-ts.config.ts b/packages/ingest-types/openapi-ts.config.ts index 0403ac810f6..8efdd03134c 100644 --- a/packages/ingest-types/openapi-ts.config.ts +++ b/packages/ingest-types/openapi-ts.config.ts @@ -4,7 +4,8 @@ export default defineConfig({ input: './openapi.yaml', output: { path: './src', - clean: true + clean: true, + importFileExtension: '.js' }, parser: { filters: { diff --git a/packages/ingest-types/package.json b/packages/ingest-types/package.json index c6bc7869af9..d64d62b30bb 100644 --- a/packages/ingest-types/package.json +++ b/packages/ingest-types/package.json @@ -1,24 +1,42 @@ { "name": "@comfyorg/ingest-types", "version": "1.0.0", + "private": true, "description": "Comfy Cloud Ingest API TypeScript types and Zod schemas", "license": "MIT", "files": [ - "src" + "dist" ], "type": "module", "exports": { ".": "./src/index.ts", - "./zod": "./src/zod.gen.ts" + "./zod": "./src/zod.gen.ts", + "./package.json": "./package.json" }, "publishConfig": { + "exports": { + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/index.js" + }, + "./zod": { + "types": "./dist/zod.gen.d.ts", + "import": "./dist/zod.gen.js" + }, + "./package.json": "./package.json" + }, "access": "public" }, "scripts": { - "generate": "openapi-ts && node -e \"const fs=require('fs'); ['src/zod.gen.ts'].forEach(f => fs.writeFileSync(f, fs.readFileSync(f,'utf8').replaceAll(\\\"from 'zod/v3'\\\", \\\"from 'zod'\\\")));\"" + "build": "pnpm run clean && tsc -p tsconfig.build.json", + "clean": "node --input-type=module -e \"import { rmSync } from 'node:fs'; rmSync('dist', { recursive: true, force: true })\"", + "prepack": "pnpm run build", + "generate": "openapi-ts && node -e \"const fs=require('fs'); ['src/zod.gen.ts'].forEach(f => fs.writeFileSync(f, fs.readFileSync(f,'utf8').replaceAll(\\\"from 'zod/v3'\\\", \\\"from 'zod'\\\")));\"", + "typecheck": "tsc --noEmit" }, "devDependencies": { "@hey-api/openapi-ts": "0.97.3", + "typescript": "catalog:", "zod": "catalog:" }, "peerDependencies": { diff --git a/packages/ingest-types/src/index.ts b/packages/ingest-types/src/index.ts index 638bfd5523d..377e03d1b22 100644 --- a/packages/ingest-types/src/index.ts +++ b/packages/ingest-types/src/index.ts @@ -1131,4 +1131,4 @@ export type { WorkspaceApiKeyInfo, WorkspaceSummary, WorkspaceWithRole -} from './types.gen' +} from './types.gen.js' diff --git a/packages/ingest-types/tsconfig.build.json b/packages/ingest-types/tsconfig.build.json new file mode 100644 index 00000000000..722be8bbf98 --- /dev/null +++ b/packages/ingest-types/tsconfig.build.json @@ -0,0 +1,15 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "noEmit": false, + "allowImportingTsExtensions": false, + "declaration": true, + "declarationMap": false, + "sourceMap": false, + "incremental": false, + "noEmitOnError": true, + "types": [] + }, + "include": ["src/index.ts", "src/zod.gen.ts", "src/types.gen.ts"], + "exclude": ["src/**/*.test.ts"] +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7edf87db58e..83166dc2915 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1309,6 +1309,9 @@ importers: '@hey-api/openapi-ts': specifier: 0.97.3 version: 0.97.3(magicast@0.5.4)(typescript@6.0.3) + typescript: + specifier: 'catalog:' + version: 6.0.3 zod: specifier: 'catalog:' version: 3.25.76