@quickback-dev/cli 0.58.2 → 0.58.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/commands/compile.d.ts +5 -0
- package/dist/commands/compile.d.ts.map +1 -1
- package/dist/commands/compile.js +34 -0
- package/dist/commands/compile.js.map +1 -1
- package/dist/commands/schema.d.ts +16 -0
- package/dist/commands/schema.d.ts.map +1 -0
- package/dist/commands/schema.js +122 -0
- package/dist/commands/schema.js.map +1 -0
- package/dist/commands/schema.test.d.ts +2 -0
- package/dist/commands/schema.test.d.ts.map +1 -0
- package/dist/commands/schema.test.js +57 -0
- package/dist/commands/schema.test.js.map +1 -0
- package/dist/docs/content.d.ts.map +1 -1
- package/dist/docs/content.js +7 -2
- package/dist/docs/content.js.map +1 -1
- package/dist/index.js +10 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/action-harvest.d.ts +9 -6
- package/dist/lib/action-harvest.d.ts.map +1 -1
- package/dist/lib/action-harvest.js +28 -15
- package/dist/lib/action-harvest.js.map +1 -1
- package/dist/lib/action-harvest.test.js +21 -0
- package/dist/lib/action-harvest.test.js.map +1 -1
- package/dist/lib/api-client.d.ts +53 -0
- package/dist/lib/api-client.d.ts.map +1 -1
- package/dist/lib/api-client.js +2 -0
- package/dist/lib/api-client.js.map +1 -1
- package/dist/lib/api-client.test.js +18 -0
- package/dist/lib/api-client.test.js.map +1 -1
- package/dist/lib/migrations/command-runner.d.ts +10 -0
- package/dist/lib/migrations/command-runner.d.ts.map +1 -0
- package/dist/lib/migrations/command-runner.js +66 -0
- package/dist/lib/migrations/command-runner.js.map +1 -0
- package/dist/lib/migrations/drizzle.d.ts +12 -0
- package/dist/lib/migrations/drizzle.d.ts.map +1 -0
- package/dist/lib/migrations/drizzle.js +60 -0
- package/dist/lib/migrations/drizzle.js.map +1 -0
- package/dist/lib/migrations/drizzle.test.d.ts +2 -0
- package/dist/lib/migrations/drizzle.test.d.ts.map +1 -0
- package/dist/lib/migrations/drizzle.test.js +61 -0
- package/dist/lib/migrations/drizzle.test.js.map +1 -0
- package/dist/lib/migrations/errors.d.ts +6 -0
- package/dist/lib/migrations/errors.d.ts.map +1 -0
- package/dist/lib/migrations/errors.js +9 -0
- package/dist/lib/migrations/errors.js.map +1 -0
- package/dist/lib/migrations/executor.d.ts +52 -0
- package/dist/lib/migrations/executor.d.ts.map +1 -0
- package/dist/lib/migrations/executor.js +190 -0
- package/dist/lib/migrations/executor.js.map +1 -0
- package/dist/lib/migrations/executor.test.d.ts +2 -0
- package/dist/lib/migrations/executor.test.d.ts.map +1 -0
- package/dist/lib/migrations/executor.test.js +241 -0
- package/dist/lib/migrations/executor.test.js.map +1 -0
- package/dist/lib/migrations/index.d.ts +11 -0
- package/dist/lib/migrations/index.d.ts.map +1 -0
- package/dist/lib/migrations/index.js +11 -0
- package/dist/lib/migrations/index.js.map +1 -0
- package/dist/lib/migrations/inventory.d.ts +19 -0
- package/dist/lib/migrations/inventory.d.ts.map +1 -0
- package/dist/lib/migrations/inventory.js +135 -0
- package/dist/lib/migrations/inventory.js.map +1 -0
- package/dist/lib/migrations/inventory.test.d.ts +2 -0
- package/dist/lib/migrations/inventory.test.d.ts.map +1 -0
- package/dist/lib/migrations/inventory.test.js +81 -0
- package/dist/lib/migrations/inventory.test.js.map +1 -0
- package/dist/lib/migrations/lock.d.ts +6 -0
- package/dist/lib/migrations/lock.d.ts.map +1 -0
- package/dist/lib/migrations/lock.js +101 -0
- package/dist/lib/migrations/lock.js.map +1 -0
- package/dist/lib/migrations/lock.test.d.ts +2 -0
- package/dist/lib/migrations/lock.test.d.ts.map +1 -0
- package/dist/lib/migrations/lock.test.js +35 -0
- package/dist/lib/migrations/lock.test.js.map +1 -0
- package/dist/lib/migrations/paths.d.ts +12 -0
- package/dist/lib/migrations/paths.d.ts.map +1 -0
- package/dist/lib/migrations/paths.js +82 -0
- package/dist/lib/migrations/paths.js.map +1 -0
- package/dist/lib/migrations/paths.test.d.ts +2 -0
- package/dist/lib/migrations/paths.test.d.ts.map +1 -0
- package/dist/lib/migrations/paths.test.js +32 -0
- package/dist/lib/migrations/paths.test.js.map +1 -0
- package/dist/lib/migrations/plan.d.ts +7 -0
- package/dist/lib/migrations/plan.d.ts.map +1 -0
- package/dist/lib/migrations/plan.js +189 -0
- package/dist/lib/migrations/plan.js.map +1 -0
- package/dist/lib/migrations/plan.test.d.ts +2 -0
- package/dist/lib/migrations/plan.test.d.ts.map +1 -0
- package/dist/lib/migrations/plan.test.js +104 -0
- package/dist/lib/migrations/plan.test.js.map +1 -0
- package/dist/lib/migrations/staging.d.ts +18 -0
- package/dist/lib/migrations/staging.d.ts.map +1 -0
- package/dist/lib/migrations/staging.js +150 -0
- package/dist/lib/migrations/staging.js.map +1 -0
- package/dist/lib/migrations/staging.test.d.ts +2 -0
- package/dist/lib/migrations/staging.test.d.ts.map +1 -0
- package/dist/lib/migrations/staging.test.js +73 -0
- package/dist/lib/migrations/staging.test.js.map +1 -0
- package/dist/lib/migrations/types.d.ts +49 -0
- package/dist/lib/migrations/types.d.ts.map +1 -0
- package/dist/lib/migrations/types.js +18 -0
- package/dist/lib/migrations/types.js.map +1 -0
- package/dist/lib/schema-engine-loader.d.ts +8 -0
- package/dist/lib/schema-engine-loader.d.ts.map +1 -0
- package/dist/lib/schema-engine-loader.js +26 -0
- package/dist/lib/schema-engine-loader.js.map +1 -0
- package/dist/lib/schema-sync/index.d.ts +41 -0
- package/dist/lib/schema-sync/index.d.ts.map +1 -0
- package/dist/lib/schema-sync/index.js +246 -0
- package/dist/lib/schema-sync/index.js.map +1 -0
- package/dist/lib/schema-sync/index.test.d.ts +2 -0
- package/dist/lib/schema-sync/index.test.d.ts.map +1 -0
- package/dist/lib/schema-sync/index.test.js +128 -0
- package/dist/lib/schema-sync/index.test.js.map +1 -0
- package/dist/schema-engine/index.d.ts +3 -0
- package/dist/schema-engine/index.d.ts.map +1 -0
- package/dist/schema-engine/index.js +854 -0
- package/dist/schema-engine/index.js.map +7 -0
- package/dist/schema-engine/managed-columns.d.ts +82 -0
- package/dist/schema-engine/managed-columns.d.ts.map +1 -0
- package/dist/schema-engine/source-sync.d.ts +64 -0
- package/dist/schema-engine/source-sync.d.ts.map +1 -0
- package/dist/skill/docs/compiler/definitions/actions.md +14 -6
- package/dist/skill/docs/compiler/targets/hono-api/using-the-api/openapi.md +7 -4
- package/dist/skill/docs/compiler/targets/hono-api/using-the-api/typescript.md +141 -0
- package/package.json +4 -2
- package/src/skill/docs/compiler/definitions/actions.md +14 -6
- package/src/skill/docs/compiler/targets/hono-api/using-the-api/openapi.md +7 -4
- package/src/skill/docs/compiler/targets/hono-api/using-the-api/typescript.md +141 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../schema-engine/src/managed-columns.ts", "../../../schema-engine/src/source-sync.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Canonical feature-owned managed-column requirements.\n *\n * This module deliberately contains no filesystem, process, network, or\n * user-module access. Callers supply the project facts that determine which\n * requirements apply to each discovered table.\n */\n\nexport const SCHEMA_ENGINE_VERSION = '2026-07-28.1';\n\nexport const SQLITE_EPOCH_SENTINEL = `'1970-01-01T00:00:00.000Z'`;\nexport const SQLITE_ISO_NOW_FN = `() => new Date().toISOString()`;\n\nexport type SchemaDialect = 'postgres' | 'sqlite';\nexport type ManagedColumnDialect = SchemaDialect;\nexport type NamingConvention = 'snake_case' | 'camelCase';\nexport type ManagedRequirementKind = 'audit' | 'soft-delete' | 'id' | 'scope';\n\nexport const AUDIT_JS_NAMES = ['createdAt', 'modifiedAt', 'createdBy', 'modifiedBy'] as const;\nexport const SOFT_DELETE_JS_NAMES = ['deletedAt', 'deletedBy'] as const;\n\nexport type AuditJsName = (typeof AUDIT_JS_NAMES)[number];\nexport type SoftDeleteJsName = (typeof SOFT_DELETE_JS_NAMES)[number];\nexport type AuditManagedJsName = AuditJsName | SoftDeleteJsName;\n\nexport interface ManagedColumnSpec {\n jsName: string;\n snakeName: string;\n kind: 'timestamp' | 'text';\n notNull: boolean;\n /** Compatibility discriminator used by existing compiler consumers. */\n audit: boolean;\n requirement: ManagedRequirementKind;\n}\n\nexport const AUDIT_COLUMN_SPECS: ReadonlyArray<ManagedColumnSpec> = [\n {\n jsName: 'createdAt',\n snakeName: 'created_at',\n kind: 'timestamp',\n notNull: true,\n audit: true,\n requirement: 'audit',\n },\n {\n jsName: 'modifiedAt',\n snakeName: 'modified_at',\n kind: 'timestamp',\n notNull: true,\n audit: true,\n requirement: 'audit',\n },\n {\n jsName: 'createdBy',\n snakeName: 'created_by',\n kind: 'text',\n notNull: false,\n audit: true,\n requirement: 'audit',\n },\n {\n jsName: 'modifiedBy',\n snakeName: 'modified_by',\n kind: 'text',\n notNull: false,\n audit: true,\n requirement: 'audit',\n },\n];\n\nexport const SOFT_DELETE_COLUMN_SPECS: ReadonlyArray<ManagedColumnSpec> = [\n {\n jsName: 'deletedAt',\n snakeName: 'deleted_at',\n kind: 'timestamp',\n notNull: false,\n audit: false,\n requirement: 'soft-delete',\n },\n {\n jsName: 'deletedBy',\n snakeName: 'deleted_by',\n kind: 'text',\n notNull: false,\n audit: false,\n requirement: 'soft-delete',\n },\n];\n\nexport const MANAGED_AUDIT_COLUMN_SPECS: ReadonlyArray<ManagedColumnSpec> = [\n ...AUDIT_COLUMN_SPECS,\n ...SOFT_DELETE_COLUMN_SPECS,\n];\nexport const MANAGED_COLUMN_SPECS = MANAGED_AUDIT_COLUMN_SPECS;\nexport const MANAGED_AUDIT_JS_NAMES: ReadonlySet<string> = new Set([\n ...AUDIT_JS_NAMES,\n ...SOFT_DELETE_JS_NAMES,\n]);\n\nexport interface ManagedGroupRequirement {\n kind: 'audit' | 'soft-delete';\n columns: ReadonlyArray<ManagedColumnSpec>;\n /** Canonical q-DSL spread helper, without the leading `...` or call. */\n qHelper: 'audit' | 'softDelete';\n}\n\nexport interface ManagedPhysicalColumnRequirement {\n kind: 'id' | 'scope';\n jsName: string;\n sqlName: string;\n /** Canonical q initializer, without `<jsName>:`. */\n qExpression: string;\n /** Canonical raw-Drizzle initializer, without `<jsName>:`. */\n rawExpression: string;\n /**\n * Additional exact expressions accepted as canonical. This is useful while\n * source-visible ID strategies are migrated without weakening validation.\n */\n acceptedQExpressions?: ReadonlyArray<string>;\n acceptedRawExpressions?: ReadonlyArray<string>;\n}\n\nexport type ManagedColumnRequirement =\n | ManagedGroupRequirement\n | ManagedPhysicalColumnRequirement;\n\nexport interface IdRequirementOptions {\n dialect: SchemaDialect;\n namingConvention?: NamingConvention;\n qExpression?: string;\n rawExpression?: string;\n acceptedQExpressions?: ReadonlyArray<string>;\n acceptedRawExpressions?: ReadonlyArray<string>;\n}\n\nexport interface ScopeRequirementOptions {\n dialect: SchemaDialect;\n kind: string;\n jsName?: string;\n sqlName?: string;\n namingConvention?: NamingConvention;\n qExpression?: string;\n rawExpression?: string;\n acceptedQExpressions?: ReadonlyArray<string>;\n acceptedRawExpressions?: ReadonlyArray<string>;\n}\n\nexport function managedSqlName(\n spec: Pick<ManagedColumnSpec, 'jsName' | 'snakeName'>,\n convention: NamingConvention,\n): string {\n return convention === 'snake_case' ? spec.snakeName : spec.jsName;\n}\n\nexport function managedColumnExpr(\n spec: ManagedColumnSpec,\n dialect: SchemaDialect,\n sqlName: string,\n): string {\n if (spec.kind === 'text' || (spec.jsName === 'deletedAt' && dialect === 'sqlite')) {\n return dialect === 'postgres' && spec.kind === 'timestamp'\n ? `timestamp(\"${sqlName}\", { withTimezone: true })`\n : `text(\"${sqlName}\")`;\n }\n if (spec.jsName === 'deletedAt') {\n return `timestamp(\"${sqlName}\", { withTimezone: true })`;\n }\n const pgUpdate = spec.jsName === 'modifiedAt' ? `.$onUpdate(() => new Date())` : '';\n const sqliteUpdate =\n spec.jsName === 'modifiedAt' ? `.$onUpdate(${SQLITE_ISO_NOW_FN})` : '';\n return dialect === 'postgres'\n ? `timestamp(\"${sqlName}\", { withTimezone: true }).notNull().defaultNow()${pgUpdate}`\n : `text(\"${sqlName}\").notNull().default(${SQLITE_EPOCH_SENTINEL}).$defaultFn(${SQLITE_ISO_NOW_FN})${sqliteUpdate}`;\n}\n\nexport function managedColumnLine(\n spec: ManagedColumnSpec,\n dialect: SchemaDialect,\n convention: NamingConvention,\n): string {\n return `${spec.jsName}: ${managedColumnExpr(\n spec,\n dialect,\n managedSqlName(spec, convention),\n )},`;\n}\n\nexport function auditRequirement(): ManagedGroupRequirement {\n return {\n kind: 'audit',\n columns: AUDIT_COLUMN_SPECS,\n qHelper: 'audit',\n };\n}\n\nexport function softDeleteRequirement(): ManagedGroupRequirement {\n return {\n kind: 'soft-delete',\n columns: SOFT_DELETE_COLUMN_SPECS,\n qHelper: 'softDelete',\n };\n}\n\nexport function idRequirement(options: IdRequirementOptions): ManagedPhysicalColumnRequirement {\n const sqlName = options.namingConvention === 'camelCase' ? 'id' : 'id';\n return {\n kind: 'id',\n jsName: 'id',\n sqlName,\n qExpression: options.qExpression ?? 'q.id()',\n rawExpression: options.rawExpression ?? `text(\"${sqlName}\").primaryKey()`,\n acceptedQExpressions: options.acceptedQExpressions,\n acceptedRawExpressions: options.acceptedRawExpressions,\n };\n}\n\nexport function scopeRequirement(\n options: ScopeRequirementOptions,\n): ManagedPhysicalColumnRequirement {\n const jsName = options.jsName ?? `${options.kind}Id`;\n const convention = options.namingConvention ?? 'snake_case';\n const snakeName = jsName.replace(/[A-Z]/g, (character) => `_${character.toLowerCase()}`);\n const sqlName = options.sqlName ?? (convention === 'snake_case' ? snakeName : jsName);\n return {\n kind: 'scope',\n jsName,\n sqlName,\n qExpression: options.qExpression ?? `q.scope(\"${options.kind}\")`,\n rawExpression: options.rawExpression ?? `text(\"${sqlName}\").notNull()`,\n acceptedQExpressions: options.acceptedQExpressions,\n acceptedRawExpressions: options.acceptedRawExpressions,\n };\n}\n", "import type * as TypeScript from 'typescript';\nimport {\n managedColumnExpr,\n managedColumnLine,\n managedSqlName,\n type ManagedColumnRequirement,\n type ManagedGroupRequirement,\n type ManagedPhysicalColumnRequirement,\n type NamingConvention,\n type SchemaDialect,\n} from './managed-columns.js';\n\nexport type TypeScriptApi = Omit<typeof TypeScript, 'default'>;\nexport type SchemaTableStyle = 'q-feature' | 'q-table' | 'raw-drizzle';\nexport type StaticDeleteMode = 'hard' | 'soft' | 'default' | 'dynamic';\n\nexport interface SchemaTableContext {\n /** Stable within one source file, even when SQL table names repeat. */\n id: string;\n fileName: string;\n tableName: string;\n variableName?: string;\n style: SchemaTableStyle;\n dialect: SchemaDialect;\n namingConvention: NamingConvention;\n hasResourceConfig: boolean;\n deleteMode: StaticDeleteMode;\n sourceStart: number;\n sourceEnd: number;\n}\n\nexport type ManagedRequirementResolver = (\n table: SchemaTableContext,\n) => ReadonlyArray<ManagedColumnRequirement>;\n\nexport interface SchemaSourceEdit {\n start: number;\n end: number;\n text: string;\n tableId?: string;\n reason: string;\n}\n\nexport type SchemaSyncDiagnosticCode =\n | 'DIVERGENT_MANAGED_COLUMN'\n | 'DUPLICATE_MANAGED_REPRESENTATION'\n | 'DUPLICATE_TABLE_COLUMN'\n | 'MISSING_VALUE_IMPORT'\n | 'SOURCE_PARSE_ERROR'\n | 'UNSUPPORTED_DYNAMIC_DELETE_MODE'\n | 'REQUIREMENT_RESOLUTION_FAILED'\n | 'INVALID_REQUIREMENT'\n | 'OVERLAPPING_SOURCE_EDITS';\n\nexport interface SchemaSyncDiagnostic {\n code: SchemaSyncDiagnosticCode;\n message: string;\n fileName: string;\n tableId?: string;\n tableName?: string;\n start?: number;\n end?: number;\n expected?: string;\n actual?: string;\n}\n\nexport interface PlanSchemaSourceOptions {\n fileName: string;\n source: string;\n typescript: TypeScriptApi;\n dialect: SchemaDialect;\n namingConvention?: NamingConvention;\n resolveRequirements: ManagedRequirementResolver;\n}\n\nexport interface SchemaSourcePlan {\n fileName: string;\n source: string;\n tables: ReadonlyArray<SchemaTableContext>;\n edits: ReadonlyArray<SchemaSourceEdit>;\n diagnostics: ReadonlyArray<SchemaSyncDiagnostic>;\n updatedSource: string;\n changed: boolean;\n canApply: boolean;\n}\n\ninterface DiscoveredTable {\n context: SchemaTableContext;\n columns: TypeScript.ObjectLiteralExpression;\n}\n\ninterface PlannedEntry {\n source: string;\n order: number;\n}\n\ninterface ImportRequirement {\n identifiers: Set<string>;\n tableIds: Set<string>;\n}\n\nconst MANAGED_MARKER =\n '// \u2500\u2500 quickback:audit (compiler-managed \u2014 edits are validated, not merged) \u2500\u2500';\n\n/**\n * Inspect every table in one source file and calculate formatting-preserving,\n * additive-only source edits. No edit is applied here.\n */\nexport function planSchemaSource(options: PlanSchemaSourceOptions): SchemaSourcePlan {\n const ts = options.typescript;\n const namingConvention = options.namingConvention ?? 'snake_case';\n const sourceFile = ts.createSourceFile(\n options.fileName,\n options.source,\n ts.ScriptTarget.Latest,\n true,\n options.fileName.endsWith('.tsx') ? ts.ScriptKind.TSX : ts.ScriptKind.TS,\n );\n const diagnostics: SchemaSyncDiagnostic[] = [];\n const parseDiagnostics = (\n sourceFile as TypeScript.SourceFile & {\n parseDiagnostics?: ReadonlyArray<TypeScript.Diagnostic>;\n }\n ).parseDiagnostics;\n if (parseDiagnostics && parseDiagnostics.length > 0) {\n for (const diagnostic of parseDiagnostics) {\n diagnostics.push({\n code: 'SOURCE_PARSE_ERROR',\n fileName: options.fileName,\n start: diagnostic.start,\n end:\n diagnostic.start !== undefined && diagnostic.length !== undefined\n ? diagnostic.start + diagnostic.length\n : undefined,\n message:\n `TypeScript could not parse this schema source: ` +\n ts.flattenDiagnosticMessageText(diagnostic.messageText, '\\n'),\n });\n }\n return {\n fileName: options.fileName,\n source: options.source,\n tables: [],\n edits: [],\n diagnostics,\n updatedSource: options.source,\n changed: false,\n canApply: false,\n };\n }\n const discovered = discoverTables(ts, sourceFile, options.dialect, namingConvention);\n const edits: SchemaSourceEdit[] = [];\n const imports = new Map<string, ImportRequirement>();\n\n for (const table of discovered) {\n let requirements: ReadonlyArray<ManagedColumnRequirement>;\n try {\n requirements = options.resolveRequirements(table.context);\n } catch (error) {\n diagnostics.push({\n code: 'REQUIREMENT_RESOLUTION_FAILED',\n fileName: options.fileName,\n tableId: table.context.id,\n tableName: table.context.tableName,\n start: table.context.sourceStart,\n end: table.context.sourceEnd,\n message:\n `Could not determine managed-column requirements for table ` +\n `\"${table.context.tableName}\": ${error instanceof Error ? error.message : String(error)}`,\n });\n continue;\n }\n if (!Array.isArray(requirements)) {\n diagnostics.push({\n code: 'INVALID_REQUIREMENT',\n fileName: options.fileName,\n tableId: table.context.id,\n tableName: table.context.tableName,\n message:\n `The managed-column resolver for table \"${table.context.tableName}\" did not return an array.`,\n });\n continue;\n }\n\n const entries: PlannedEntry[] = [];\n const seenKinds = new Set<string>();\n let needsManagedMarker = false;\n\n for (const requirement of requirements) {\n const key =\n requirement.kind === 'scope'\n ? `${requirement.kind}:${requirement.jsName}`\n : requirement.kind;\n if (seenKinds.has(key)) {\n diagnostics.push({\n code: 'INVALID_REQUIREMENT',\n fileName: options.fileName,\n tableId: table.context.id,\n tableName: table.context.tableName,\n message: `Requirement \"${key}\" was supplied more than once for table \"${table.context.tableName}\".`,\n });\n continue;\n }\n seenKinds.add(key);\n\n if (isManagedGroupRequirement(requirement)) {\n const result = planManagedGroup(\n ts,\n sourceFile,\n table,\n requirement,\n options.fileName,\n diagnostics,\n );\n entries.push(...result.entries);\n needsManagedMarker ||= result.needsMarker;\n for (const identifier of result.requiredImports) {\n addImportRequirement(\n imports,\n drizzleCoreModule(table.context.dialect),\n identifier,\n table.context.id,\n );\n }\n if (result.needsQImport) {\n addImportRequirement(imports, '@quickback/compiler', 'q', table.context.id);\n }\n continue;\n }\n\n const result = planPhysicalColumn(\n ts,\n sourceFile,\n table,\n requirement,\n options.fileName,\n diagnostics,\n );\n entries.push(...result.entries);\n for (const identifier of result.requiredImports) {\n addImportRequirement(\n imports,\n drizzleCoreModule(table.context.dialect),\n identifier,\n table.context.id,\n );\n }\n if (result.needsQImport) {\n addImportRequirement(imports, '@quickback/compiler', 'q', table.context.id);\n }\n }\n\n if (entries.length === 0) continue;\n entries.sort((a, b) => a.order - b.order);\n if (\n table.context.style === 'raw-drizzle' &&\n needsManagedMarker &&\n !options.source\n .slice(table.columns.getStart(sourceFile), table.columns.getEnd())\n .includes('quickback:audit')\n ) {\n const firstManagedIndex = entries.findIndex((entry) => entry.order >= 20);\n entries.splice(firstManagedIndex < 0 ? entries.length : firstManagedIndex, 0, {\n source: MANAGED_MARKER,\n order: 19,\n });\n }\n edits.push(\n ...planObjectInsertion(\n sourceFile,\n table.columns,\n entries.map((entry) => entry.source),\n table.context.id,\n ),\n );\n }\n\n for (const [moduleName, requirement] of imports) {\n planNamedImport(\n ts,\n sourceFile,\n moduleName,\n requirement,\n options.fileName,\n edits,\n diagnostics,\n );\n }\n\n let updatedSource = options.source;\n try {\n updatedSource = applySchemaSourceEdits(options.source, edits);\n } catch (error) {\n diagnostics.push({\n code: 'OVERLAPPING_SOURCE_EDITS',\n fileName: options.fileName,\n message: error instanceof Error ? error.message : String(error),\n });\n }\n\n return {\n fileName: options.fileName,\n source: options.source,\n tables: discovered.map((table) => table.context),\n edits,\n diagnostics,\n updatedSource,\n changed: updatedSource !== options.source,\n canApply: diagnostics.length === 0,\n };\n}\n\nfunction isManagedGroupRequirement(\n requirement: ManagedColumnRequirement,\n): requirement is ManagedGroupRequirement {\n return requirement.kind === 'audit' || requirement.kind === 'soft-delete';\n}\n\nexport function applySchemaSourceEdits(\n source: string,\n edits: ReadonlyArray<SchemaSourceEdit>,\n): string {\n const ordered = [...edits].sort((left, right) => {\n if (left.start !== right.start) return right.start - left.start;\n return right.end - left.end;\n });\n let previousStart = source.length + 1;\n let output = source;\n for (const edit of ordered) {\n if (\n edit.start < 0 ||\n edit.end < edit.start ||\n edit.end > source.length ||\n edit.end > previousStart\n ) {\n throw new Error(\n `Schema source edits overlap or address an invalid span: ${edit.start}..${edit.end} (${edit.reason}).`,\n );\n }\n output = output.slice(0, edit.start) + edit.text + output.slice(edit.end);\n previousStart = edit.start;\n }\n return output;\n}\n\nfunction discoverTables(\n ts: TypeScriptApi,\n sourceFile: TypeScript.SourceFile,\n defaultDialect: SchemaDialect,\n namingConvention: NamingConvention,\n): DiscoveredTable[] {\n const resourceByVariable = new Map<string, TypeScript.Expression>();\n\n const collectResources = (node: TypeScript.Node): void => {\n if (ts.isCallExpression(node) && isNamedCall(ts, node.expression, 'defineTable')) {\n const tableArg = node.arguments[0];\n const configArg = node.arguments[1];\n if (tableArg && ts.isIdentifier(tableArg) && configArg) {\n resourceByVariable.set(tableArg.text, configArg);\n }\n }\n ts.forEachChild(node, collectResources);\n };\n collectResources(sourceFile);\n\n const tables: DiscoveredTable[] = [];\n const occurrenceByName = new Map<string, number>();\n const visit = (node: TypeScript.Node): void => {\n if (!ts.isCallExpression(node)) {\n ts.forEachChild(node, visit);\n return;\n }\n\n const callKind = tableCallKind(ts, node.expression);\n if (!callKind) {\n ts.forEachChild(node, visit);\n return;\n }\n const nameArg = node.arguments[0];\n const bodyArg = node.arguments[1];\n if (!nameArg || !ts.isStringLiteralLike(nameArg) || !bodyArg) {\n ts.forEachChild(node, visit);\n return;\n }\n\n const variableName = enclosingVariableName(ts, node);\n let columns: TypeScript.ObjectLiteralExpression | undefined;\n let resource: TypeScript.Expression | undefined;\n let style: SchemaTableStyle;\n let dialect = defaultDialect;\n\n if (callKind === 'feature') {\n if (!ts.isObjectLiteralExpression(bodyArg)) {\n ts.forEachChild(node, visit);\n return;\n }\n columns = objectPropertyObject(ts, bodyArg, 'columns');\n resource = bodyArg;\n style = 'q-feature';\n } else if (callKind === 'q-table') {\n if (!ts.isObjectLiteralExpression(bodyArg)) {\n ts.forEachChild(node, visit);\n return;\n }\n columns = bodyArg;\n resource = variableName ? resourceByVariable.get(variableName) : undefined;\n style = 'q-table';\n } else {\n if (!ts.isObjectLiteralExpression(bodyArg)) {\n ts.forEachChild(node, visit);\n return;\n }\n columns = bodyArg;\n resource = variableName ? resourceByVariable.get(variableName) : undefined;\n style = 'raw-drizzle';\n dialect = callKind === 'pg-table' ? 'postgres' : 'sqlite';\n }\n\n if (!columns) {\n ts.forEachChild(node, visit);\n return;\n }\n const tableName = nameArg.text;\n const occurrence = (occurrenceByName.get(tableName) ?? 0) + 1;\n occurrenceByName.set(tableName, occurrence);\n tables.push({\n context: {\n id: `${tableName}@${occurrence}`,\n fileName: sourceFile.fileName,\n tableName,\n variableName,\n style,\n dialect,\n namingConvention,\n hasResourceConfig: resource !== undefined,\n deleteMode: resource ? readDeleteMode(ts, resource) : 'default',\n sourceStart: node.getStart(sourceFile),\n sourceEnd: node.getEnd(),\n },\n columns,\n });\n // Table calls cannot contain another table definition in their columns.\n };\n visit(sourceFile);\n return tables.sort((left, right) => left.context.sourceStart - right.context.sourceStart);\n}\n\ntype TableCallKind = 'feature' | 'q-table' | 'pg-table' | 'sqlite-table';\n\nfunction tableCallKind(\n ts: TypeScriptApi,\n expression: TypeScript.LeftHandSideExpression,\n): TableCallKind | undefined {\n if (ts.isIdentifier(expression)) {\n if (expression.text === 'feature') return 'feature';\n if (expression.text === 'pgTable') return 'pg-table';\n if (expression.text === 'sqliteTable') return 'sqlite-table';\n return undefined;\n }\n if (!ts.isPropertyAccessExpression(expression)) return undefined;\n if (expression.name.text === 'pgTable') return 'pg-table';\n if (expression.name.text === 'sqliteTable') return 'sqlite-table';\n if (\n ts.isIdentifier(expression.expression) &&\n (expression.expression.text === 'q' || expression.expression.text === 'qb')\n ) {\n if (expression.name.text === 'table') return 'q-table';\n if (expression.name.text === 'feature') return 'feature';\n }\n return undefined;\n}\n\nfunction enclosingVariableName(\n ts: TypeScriptApi,\n call: TypeScript.CallExpression,\n): string | undefined {\n const parent = call.parent;\n return ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name)\n ? parent.name.text\n : undefined;\n}\n\nfunction isNamedCall(\n ts: TypeScriptApi,\n expression: TypeScript.LeftHandSideExpression,\n name: string,\n): boolean {\n return (\n (ts.isIdentifier(expression) && expression.text === name) ||\n (ts.isPropertyAccessExpression(expression) && expression.name.text === name)\n );\n}\n\nfunction objectPropertyObject(\n ts: TypeScriptApi,\n object: TypeScript.ObjectLiteralExpression,\n name: string,\n): TypeScript.ObjectLiteralExpression | undefined {\n const property = object.properties.find(\n (candidate): candidate is TypeScript.PropertyAssignment =>\n ts.isPropertyAssignment(candidate) && propertyName(ts, candidate.name) === name,\n );\n return property && ts.isObjectLiteralExpression(property.initializer)\n ? property.initializer\n : undefined;\n}\n\nfunction readDeleteMode(\n ts: TypeScriptApi,\n expression: TypeScript.Expression,\n): StaticDeleteMode {\n if (!ts.isObjectLiteralExpression(expression)) return 'dynamic';\n let deleteExpression = propertyInitializer(ts, expression, 'delete');\n if (!deleteExpression) {\n const crud = propertyInitializer(ts, expression, 'crud');\n if (crud && !ts.isObjectLiteralExpression(crud)) return 'dynamic';\n if (crud && ts.isObjectLiteralExpression(crud)) {\n deleteExpression = propertyInitializer(ts, crud, 'delete');\n }\n }\n if (!deleteExpression) return 'default';\n if (!ts.isObjectLiteralExpression(deleteExpression)) return 'dynamic';\n const mode = propertyInitializer(ts, deleteExpression, 'mode');\n if (!mode) return 'default';\n if (!ts.isStringLiteralLike(mode)) return 'dynamic';\n if (mode.text === 'hard') return 'hard';\n if (mode.text === 'soft') return 'soft';\n return 'dynamic';\n}\n\nfunction propertyInitializer(\n ts: TypeScriptApi,\n object: TypeScript.ObjectLiteralExpression,\n name: string,\n): TypeScript.Expression | undefined {\n for (const property of object.properties) {\n if (ts.isPropertyAssignment(property) && propertyName(ts, property.name) === name) {\n return property.initializer;\n }\n if (ts.isShorthandPropertyAssignment(property) && property.name.text === name) {\n return property.name;\n }\n }\n return undefined;\n}\n\nfunction propertyName(\n ts: TypeScriptApi,\n name: TypeScript.PropertyName,\n): string | undefined {\n if (ts.isIdentifier(name) || ts.isPrivateIdentifier(name)) return name.text;\n if (ts.isStringLiteralLike(name) || ts.isNumericLiteral(name)) return name.text;\n return undefined;\n}\n\nfunction planManagedGroup(\n ts: TypeScriptApi,\n sourceFile: TypeScript.SourceFile,\n table: DiscoveredTable,\n requirement: ManagedGroupRequirement,\n fileName: string,\n diagnostics: SchemaSyncDiagnostic[],\n): {\n entries: PlannedEntry[];\n requiredImports: Set<string>;\n needsQImport: boolean;\n needsMarker: boolean;\n} {\n if (table.context.style !== 'raw-drizzle') {\n const helperSpread = findQHelperSpread(ts, table.columns, requirement.qHelper);\n const explicit = table.columns.properties.filter((property) => {\n if (!ts.isPropertyAssignment(property)) return false;\n const name = propertyName(ts, property.name);\n return requirement.columns.some((column) => column.jsName === name);\n });\n if (helperSpread && explicit.length > 0) {\n diagnostics.push({\n code: 'DUPLICATE_MANAGED_REPRESENTATION',\n fileName,\n tableId: table.context.id,\n tableName: table.context.tableName,\n start: explicit[0]!.getStart(sourceFile),\n end: explicit[explicit.length - 1]!.getEnd(),\n expected: `...q.${requirement.qHelper}(),`,\n actual: explicit.map((property) => property.getText(sourceFile)).join('\\n'),\n message:\n `Table \"${table.context.tableName}\" declares both ...q.${requirement.qHelper}() ` +\n `and explicit ${requirement.kind} columns. Remove the explicit duplicates manually.`,\n });\n return {\n entries: [],\n requiredImports: new Set(),\n needsQImport: false,\n needsMarker: false,\n };\n }\n if (helperSpread) {\n return {\n entries: [],\n requiredImports: new Set(),\n needsQImport: false,\n needsMarker: false,\n };\n }\n if (explicit.length > 0) {\n diagnostics.push({\n code: 'DIVERGENT_MANAGED_COLUMN',\n fileName,\n tableId: table.context.id,\n tableName: table.context.tableName,\n start: explicit[0]!.getStart(sourceFile),\n end: explicit[explicit.length - 1]!.getEnd(),\n expected: `...q.${requirement.qHelper}(),`,\n actual: explicit.map((property) => property.getText(sourceFile)).join('\\n'),\n message:\n `Table \"${table.context.tableName}\" uses explicit q-DSL ${requirement.kind} ` +\n `columns. Quickback cannot prove that hand-written q chains match the managed ` +\n `contract; replace them manually with ...q.${requirement.qHelper}().`,\n });\n return {\n entries: [],\n requiredImports: new Set(),\n needsQImport: false,\n needsMarker: false,\n };\n }\n return {\n entries: [{ source: `...q.${requirement.qHelper}(),`, order: groupOrder(requirement.kind) }],\n requiredImports: new Set(),\n needsQImport: true,\n needsMarker: false,\n };\n }\n\n const entries: PlannedEntry[] = [];\n const requiredImports = new Set<string>();\n for (const column of requirement.columns) {\n const sqlName = managedSqlName(column, table.context.namingConvention);\n const expectedExpression = managedColumnExpr(column, table.context.dialect, sqlName);\n const expectedLine = managedColumnLine(\n column,\n table.context.dialect,\n table.context.namingConvention,\n );\n const matches = matchingRawProperties(ts, table.columns, column.jsName, sqlName);\n if (matches.length > 1) {\n diagnostics.push(duplicateColumnDiagnostic(fileName, sourceFile, table, column.jsName, matches));\n continue;\n }\n const existing = matches[0];\n if (!existing) {\n entries.push({ source: expectedLine, order: groupOrder(requirement.kind) });\n for (const identifier of calledBuilderIdentifiers(expectedExpression)) {\n requiredImports.add(identifier);\n }\n continue;\n }\n if (\n propertyName(ts, existing.name) !== column.jsName ||\n !expressionMatches(sourceFile, existing.initializer, [expectedExpression])\n ) {\n diagnostics.push(\n divergentColumnDiagnostic(\n fileName,\n sourceFile,\n table,\n existing,\n expectedLine,\n column.jsName,\n ),\n );\n }\n }\n return {\n entries,\n requiredImports,\n needsQImport: false,\n needsMarker: entries.length > 0,\n };\n}\n\nfunction planPhysicalColumn(\n ts: TypeScriptApi,\n sourceFile: TypeScript.SourceFile,\n table: DiscoveredTable,\n requirement: ManagedPhysicalColumnRequirement,\n fileName: string,\n diagnostics: SchemaSyncDiagnostic[],\n): {\n entries: PlannedEntry[];\n requiredImports: Set<string>;\n needsQImport: boolean;\n} {\n const raw = table.context.style === 'raw-drizzle';\n const matches = raw\n ? matchingRawProperties(ts, table.columns, requirement.jsName, requirement.sqlName)\n : matchingQProperties(ts, table.columns, requirement.jsName);\n if (matches.length > 1) {\n diagnostics.push(\n duplicateColumnDiagnostic(fileName, sourceFile, table, requirement.jsName, matches),\n );\n return { entries: [], requiredImports: new Set(), needsQImport: false };\n }\n\n const expression = raw ? requirement.rawExpression : requirement.qExpression;\n const accepted = raw\n ? [requirement.rawExpression, ...(requirement.acceptedRawExpressions ?? [])]\n : [requirement.qExpression, ...(requirement.acceptedQExpressions ?? [])];\n const expected = `${requirement.jsName}: ${expression},`;\n const existing = matches[0];\n if (existing) {\n if (\n propertyName(ts, existing.name) !== requirement.jsName ||\n !expressionMatches(sourceFile, existing.initializer, accepted)\n ) {\n diagnostics.push(\n divergentColumnDiagnostic(\n fileName,\n sourceFile,\n table,\n existing,\n expected,\n requirement.jsName,\n ),\n );\n }\n return { entries: [], requiredImports: new Set(), needsQImport: false };\n }\n\n return {\n entries: [{ source: expected, order: requirement.kind === 'id' ? 0 : 10 }],\n requiredImports: raw\n ? new Set(calledBuilderIdentifiers(requirement.rawExpression))\n : new Set(),\n needsQImport: !raw,\n };\n}\n\nfunction groupOrder(kind: 'audit' | 'soft-delete'): number {\n return kind === 'audit' ? 20 : 30;\n}\n\nfunction findQHelperSpread(\n ts: TypeScriptApi,\n object: TypeScript.ObjectLiteralExpression,\n helper: string,\n): TypeScript.SpreadAssignment | undefined {\n return object.properties.find((property): property is TypeScript.SpreadAssignment => {\n if (!ts.isSpreadAssignment(property) || !ts.isCallExpression(property.expression)) {\n return false;\n }\n const callee = property.expression.expression;\n return (\n ts.isPropertyAccessExpression(callee) &&\n ts.isIdentifier(callee.expression) &&\n callee.expression.text === 'q' &&\n callee.name.text === helper &&\n property.expression.arguments.length === 0\n );\n });\n}\n\nfunction matchingQProperties(\n ts: TypeScriptApi,\n object: TypeScript.ObjectLiteralExpression,\n jsName: string,\n): TypeScript.PropertyAssignment[] {\n return object.properties.filter(\n (property): property is TypeScript.PropertyAssignment =>\n ts.isPropertyAssignment(property) && propertyName(ts, property.name) === jsName,\n );\n}\n\nfunction matchingRawProperties(\n ts: TypeScriptApi,\n object: TypeScript.ObjectLiteralExpression,\n jsName: string,\n sqlName: string,\n): TypeScript.PropertyAssignment[] {\n return object.properties.filter((property): property is TypeScript.PropertyAssignment => {\n if (!ts.isPropertyAssignment(property)) return false;\n if (propertyName(ts, property.name) === jsName) return true;\n return firstStringArgument(ts, property.initializer) === sqlName;\n });\n}\n\nfunction firstStringArgument(\n ts: TypeScriptApi,\n expression: TypeScript.Expression,\n): string | undefined {\n let current = expression;\n while (ts.isCallExpression(current)) {\n const first = current.arguments[0];\n if (first && ts.isStringLiteralLike(first)) return first.text;\n const callee = current.expression;\n if (!ts.isPropertyAccessExpression(callee)) break;\n current = callee.expression;\n }\n return undefined;\n}\n\nfunction expressionMatches(\n sourceFile: TypeScript.SourceFile,\n expression: TypeScript.Expression,\n accepted: ReadonlyArray<string>,\n): boolean {\n const actual = normalizeExpression(expression.getText(sourceFile));\n return accepted.some((candidate) => normalizeExpression(candidate) === actual);\n}\n\nfunction normalizeExpression(source: string): string {\n return source\n .replace(/\\/\\*[\\s\\S]*?\\*\\//g, '')\n .replace(/\\/\\/[^\\r\\n]*/g, '')\n .replace(/'([^'\\\\]*(?:\\\\.[^'\\\\]*)*)'/g, (_match, value: string) => `\"${value}\"`)\n .replace(/\\s+/g, '');\n}\n\nfunction calledBuilderIdentifiers(expression: string): string[] {\n const identifiers = new Set<string>();\n for (const match of expression.matchAll(/(?:^|[\\s:,{(])([A-Za-z_$][\\w$]*)\\s*\\(/g)) {\n const identifier = match[1]!;\n if (identifier !== 'Date') identifiers.add(identifier);\n }\n return [...identifiers].sort();\n}\n\nfunction duplicateColumnDiagnostic(\n fileName: string,\n sourceFile: TypeScript.SourceFile,\n table: DiscoveredTable,\n jsName: string,\n properties: TypeScript.PropertyAssignment[],\n): SchemaSyncDiagnostic {\n return {\n code: 'DUPLICATE_TABLE_COLUMN',\n fileName,\n tableId: table.context.id,\n tableName: table.context.tableName,\n start: properties[0]!.getStart(sourceFile),\n end: properties[properties.length - 1]!.getEnd(),\n actual: properties.map((property) => property.getText(sourceFile)).join('\\n'),\n message:\n `Table \"${table.context.tableName}\" declares managed column \"${jsName}\" more than once. ` +\n `Resolve the duplicate manually before syncing.`,\n };\n}\n\nfunction divergentColumnDiagnostic(\n fileName: string,\n sourceFile: TypeScript.SourceFile,\n table: DiscoveredTable,\n property: TypeScript.PropertyAssignment,\n expected: string,\n jsName: string,\n): SchemaSyncDiagnostic {\n return {\n code: 'DIVERGENT_MANAGED_COLUMN',\n fileName,\n tableId: table.context.id,\n tableName: table.context.tableName,\n start: property.getStart(sourceFile),\n end: property.getEnd(),\n expected,\n actual: property.getText(sourceFile),\n message:\n `Table \"${table.context.tableName}\" has a divergent managed column \"${jsName}\". ` +\n `Quickback will not rewrite it automatically; replace it with the canonical form.`,\n };\n}\n\nfunction planObjectInsertion(\n sourceFile: TypeScript.SourceFile,\n object: TypeScript.ObjectLiteralExpression,\n entries: string[],\n tableId: string,\n): SchemaSourceEdit[] {\n if (entries.length === 0) return [];\n const source = sourceFile.text;\n const lineEnding = source.includes('\\r\\n') ? '\\r\\n' : '\\n';\n const open = object.getStart(sourceFile);\n const close = object.getEnd() - 1;\n const multiline = source.slice(open, close).includes('\\n');\n const edits: SchemaSourceEdit[] = [];\n const last = object.properties[object.properties.length - 1];\n const hasTrailingComma = last\n ? source.slice(last.getEnd(), close).includes(',')\n : false;\n\n if (!multiline) {\n if (last) {\n const tail = source.slice(last.getEnd(), close);\n const preservesComment = tail.includes('//') || tail.includes('/*');\n edits.push({\n start: last.getEnd(),\n end: close,\n text: preservesComment\n ? `${hasTrailingComma ? '' : ','}${tail}${/\\s$/.test(tail) ? '' : ' '}${entries.join(' ')} `\n : `, ${entries.join(' ')} `,\n tableId,\n reason: 'insert managed columns into single-line table object',\n });\n } else {\n edits.push({\n start: open + 1,\n end: close,\n text: ` ${entries.join(' ')} `,\n tableId,\n reason: 'insert managed columns into empty single-line table object',\n });\n }\n return edits;\n }\n\n if (last && !hasTrailingComma) {\n edits.push({\n start: last.getEnd(),\n end: last.getEnd(),\n text: ',',\n tableId,\n reason: 'terminate the previous table column before managed-column insertion',\n });\n }\n\n const closeLineStart = source.lastIndexOf('\\n', close - 1) + 1;\n const closeIndent = source.slice(closeLineStart, close).match(/^[ \\t]*/)?.[0] ?? '';\n const first = object.properties[0];\n let entryIndent: string;\n if (first) {\n const firstStart = first.getStart(sourceFile);\n const firstLineStart = source.lastIndexOf('\\n', firstStart - 1) + 1;\n entryIndent = source.slice(firstLineStart, firstStart);\n } else {\n entryIndent = closeIndent.includes('\\t') ? `${closeIndent}\\t` : `${closeIndent} `;\n }\n const text = entries.map((entry) => `${entryIndent}${entry}`).join(lineEnding) + lineEnding;\n edits.push({\n start: closeLineStart,\n end: closeLineStart,\n text,\n tableId,\n reason: 'insert canonical managed-column declarations',\n });\n return edits;\n}\n\nfunction addImportRequirement(\n imports: Map<string, ImportRequirement>,\n moduleName: string,\n identifier: string,\n tableId: string,\n): void {\n let requirement = imports.get(moduleName);\n if (!requirement) {\n requirement = { identifiers: new Set(), tableIds: new Set() };\n imports.set(moduleName, requirement);\n }\n requirement.identifiers.add(identifier);\n requirement.tableIds.add(tableId);\n}\n\nfunction drizzleCoreModule(dialect: SchemaDialect): string {\n return dialect === 'postgres' ? 'drizzle-orm/pg-core' : 'drizzle-orm/sqlite-core';\n}\n\nfunction planNamedImport(\n ts: TypeScriptApi,\n sourceFile: TypeScript.SourceFile,\n moduleName: string,\n requirement: ImportRequirement,\n fileName: string,\n edits: SchemaSourceEdit[],\n diagnostics: SchemaSyncDiagnostic[],\n): void {\n const candidates = sourceFile.statements.filter(\n (statement): statement is TypeScript.ImportDeclaration =>\n ts.isImportDeclaration(statement) &&\n ts.isStringLiteralLike(statement.moduleSpecifier) &&\n statement.moduleSpecifier.text === moduleName &&\n !!statement.importClause &&\n !statement.importClause.isTypeOnly &&\n !!statement.importClause.namedBindings &&\n ts.isNamedImports(statement.importClause.namedBindings),\n );\n const present = new Set<string>();\n for (const candidate of candidates) {\n const bindings = candidate.importClause!.namedBindings as TypeScript.NamedImports;\n for (const element of bindings.elements) present.add(element.name.text);\n }\n const missing = [...requirement.identifiers].filter((name) => !present.has(name)).sort();\n if (missing.length === 0) return;\n const target = candidates[0];\n if (!target) {\n diagnostics.push({\n code: 'MISSING_VALUE_IMPORT',\n fileName,\n tableId: requirement.tableIds.size === 1 ? [...requirement.tableIds][0] : undefined,\n expected: `import { ${missing.join(', ')} } from \"${moduleName}\";`,\n message:\n `Managed-column synchronization needs { ${missing.join(', ')} } from ` +\n `\"${moduleName}\", but no plain named value import can be widened. ` +\n `Add the import manually; namespace and type-only imports are not rewritten.`,\n });\n return;\n }\n\n const bindings = target.importClause!.namedBindings as TypeScript.NamedImports;\n const source = sourceFile.text;\n const close = bindings.getEnd() - 1;\n const multiline = source.slice(bindings.getStart(sourceFile), close).includes('\\n');\n const last = bindings.elements[bindings.elements.length - 1];\n if (!multiline) {\n if (last) {\n const tail = source.slice(last.getEnd(), close);\n const preservesComment = tail.includes('//') || tail.includes('/*');\n edits.push({\n start: last.getEnd(),\n end: close,\n text: preservesComment\n ? `${tail.includes(',') ? '' : ','}${tail}${/\\s$/.test(tail) ? '' : ' '}${missing.join(', ')} `\n : `, ${missing.join(', ')} `,\n reason: `add required value imports from ${moduleName}`,\n });\n } else {\n edits.push({\n start: bindings.getStart(sourceFile) + 1,\n end: close,\n text: ` ${missing.join(', ')} `,\n reason: `add required value imports from ${moduleName}`,\n });\n }\n return;\n }\n if (last && !source.slice(last.getEnd(), close).includes(',')) {\n edits.push({\n start: last.getEnd(),\n end: last.getEnd(),\n text: ',',\n reason: `terminate the existing ${moduleName} import before widening it`,\n });\n }\n const lineEnding = source.includes('\\r\\n') ? '\\r\\n' : '\\n';\n const closeLineStart = source.lastIndexOf('\\n', close - 1) + 1;\n const first = bindings.elements[0];\n const indent = first\n ? source.slice(source.lastIndexOf('\\n', first.getStart(sourceFile) - 1) + 1, first.getStart(sourceFile))\n : ' ';\n edits.push({\n start: closeLineStart,\n end: closeLineStart,\n text: missing.map((name) => `${indent}${name},`).join(lineEnding) + lineEnding,\n reason: `add required value imports from ${moduleName}`,\n });\n}\n"],
|
|
5
|
+
"mappings": ";AAQO,IAAM,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;AAAA,IACP,KAAK;AAAA,IACL,MAAM,QAAQ,IAAI,CAAC,SAAS,GAAG,MAAM,GAAG,IAAI,GAAG,EAAE,KAAK,UAAU,IAAI;AAAA,IACpE,QAAQ,mCAAmC,UAAU;AAAA,EACvD,CAAC;AACH;",
|
|
6
|
+
"names": ["result", "bindings"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical feature-owned managed-column requirements.
|
|
3
|
+
*
|
|
4
|
+
* This module deliberately contains no filesystem, process, network, or
|
|
5
|
+
* user-module access. Callers supply the project facts that determine which
|
|
6
|
+
* requirements apply to each discovered table.
|
|
7
|
+
*/
|
|
8
|
+
export declare const SCHEMA_ENGINE_VERSION = "2026-07-28.1";
|
|
9
|
+
export declare const SQLITE_EPOCH_SENTINEL = "'1970-01-01T00:00:00.000Z'";
|
|
10
|
+
export declare const SQLITE_ISO_NOW_FN = "() => new Date().toISOString()";
|
|
11
|
+
export type SchemaDialect = 'postgres' | 'sqlite';
|
|
12
|
+
export type ManagedColumnDialect = SchemaDialect;
|
|
13
|
+
export type NamingConvention = 'snake_case' | 'camelCase';
|
|
14
|
+
export type ManagedRequirementKind = 'audit' | 'soft-delete' | 'id' | 'scope';
|
|
15
|
+
export declare const AUDIT_JS_NAMES: readonly ["createdAt", "modifiedAt", "createdBy", "modifiedBy"];
|
|
16
|
+
export declare const SOFT_DELETE_JS_NAMES: readonly ["deletedAt", "deletedBy"];
|
|
17
|
+
export type AuditJsName = (typeof AUDIT_JS_NAMES)[number];
|
|
18
|
+
export type SoftDeleteJsName = (typeof SOFT_DELETE_JS_NAMES)[number];
|
|
19
|
+
export type AuditManagedJsName = AuditJsName | SoftDeleteJsName;
|
|
20
|
+
export interface ManagedColumnSpec {
|
|
21
|
+
jsName: string;
|
|
22
|
+
snakeName: string;
|
|
23
|
+
kind: 'timestamp' | 'text';
|
|
24
|
+
notNull: boolean;
|
|
25
|
+
/** Compatibility discriminator used by existing compiler consumers. */
|
|
26
|
+
audit: boolean;
|
|
27
|
+
requirement: ManagedRequirementKind;
|
|
28
|
+
}
|
|
29
|
+
export declare const AUDIT_COLUMN_SPECS: ReadonlyArray<ManagedColumnSpec>;
|
|
30
|
+
export declare const SOFT_DELETE_COLUMN_SPECS: ReadonlyArray<ManagedColumnSpec>;
|
|
31
|
+
export declare const MANAGED_AUDIT_COLUMN_SPECS: ReadonlyArray<ManagedColumnSpec>;
|
|
32
|
+
export declare const MANAGED_COLUMN_SPECS: readonly ManagedColumnSpec[];
|
|
33
|
+
export declare const MANAGED_AUDIT_JS_NAMES: ReadonlySet<string>;
|
|
34
|
+
export interface ManagedGroupRequirement {
|
|
35
|
+
kind: 'audit' | 'soft-delete';
|
|
36
|
+
columns: ReadonlyArray<ManagedColumnSpec>;
|
|
37
|
+
/** Canonical q-DSL spread helper, without the leading `...` or call. */
|
|
38
|
+
qHelper: 'audit' | 'softDelete';
|
|
39
|
+
}
|
|
40
|
+
export interface ManagedPhysicalColumnRequirement {
|
|
41
|
+
kind: 'id' | 'scope';
|
|
42
|
+
jsName: string;
|
|
43
|
+
sqlName: string;
|
|
44
|
+
/** Canonical q initializer, without `<jsName>:`. */
|
|
45
|
+
qExpression: string;
|
|
46
|
+
/** Canonical raw-Drizzle initializer, without `<jsName>:`. */
|
|
47
|
+
rawExpression: string;
|
|
48
|
+
/**
|
|
49
|
+
* Additional exact expressions accepted as canonical. This is useful while
|
|
50
|
+
* source-visible ID strategies are migrated without weakening validation.
|
|
51
|
+
*/
|
|
52
|
+
acceptedQExpressions?: ReadonlyArray<string>;
|
|
53
|
+
acceptedRawExpressions?: ReadonlyArray<string>;
|
|
54
|
+
}
|
|
55
|
+
export type ManagedColumnRequirement = ManagedGroupRequirement | ManagedPhysicalColumnRequirement;
|
|
56
|
+
export interface IdRequirementOptions {
|
|
57
|
+
dialect: SchemaDialect;
|
|
58
|
+
namingConvention?: NamingConvention;
|
|
59
|
+
qExpression?: string;
|
|
60
|
+
rawExpression?: string;
|
|
61
|
+
acceptedQExpressions?: ReadonlyArray<string>;
|
|
62
|
+
acceptedRawExpressions?: ReadonlyArray<string>;
|
|
63
|
+
}
|
|
64
|
+
export interface ScopeRequirementOptions {
|
|
65
|
+
dialect: SchemaDialect;
|
|
66
|
+
kind: string;
|
|
67
|
+
jsName?: string;
|
|
68
|
+
sqlName?: string;
|
|
69
|
+
namingConvention?: NamingConvention;
|
|
70
|
+
qExpression?: string;
|
|
71
|
+
rawExpression?: string;
|
|
72
|
+
acceptedQExpressions?: ReadonlyArray<string>;
|
|
73
|
+
acceptedRawExpressions?: ReadonlyArray<string>;
|
|
74
|
+
}
|
|
75
|
+
export declare function managedSqlName(spec: Pick<ManagedColumnSpec, 'jsName' | 'snakeName'>, convention: NamingConvention): string;
|
|
76
|
+
export declare function managedColumnExpr(spec: ManagedColumnSpec, dialect: SchemaDialect, sqlName: string): string;
|
|
77
|
+
export declare function managedColumnLine(spec: ManagedColumnSpec, dialect: SchemaDialect, convention: NamingConvention): string;
|
|
78
|
+
export declare function auditRequirement(): ManagedGroupRequirement;
|
|
79
|
+
export declare function softDeleteRequirement(): ManagedGroupRequirement;
|
|
80
|
+
export declare function idRequirement(options: IdRequirementOptions): ManagedPhysicalColumnRequirement;
|
|
81
|
+
export declare function scopeRequirement(options: ScopeRequirementOptions): ManagedPhysicalColumnRequirement;
|
|
82
|
+
//# sourceMappingURL=managed-columns.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"managed-columns.d.ts","sourceRoot":"","sources":["../src/managed-columns.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,eAAO,MAAM,qBAAqB,iBAAiB,CAAC;AAEpD,eAAO,MAAM,qBAAqB,+BAA+B,CAAC;AAClE,eAAO,MAAM,iBAAiB,mCAAmC,CAAC;AAElE,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG,QAAQ,CAAC;AAClD,MAAM,MAAM,oBAAoB,GAAG,aAAa,CAAC;AAC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AAa,EACtB,OAAO,EAAE,MAAM,GACd,MAAM,CAeR;AAED,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,iBAAiB,EACvB,OAAO,EAAE,aAAa,EACtB,UAAU,EAAE,gBAAgB,GAC3B,MAAM,CAMR;AAED,wBAAgB,gBAAgB,IAAI,uBAAuB,CAM1D;AAED,wBAAgB,qBAAqB,IAAI,uBAAuB,CAM/D;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,gCAAgC,CAW7F;AAED,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,uBAAuB,GAC/B,gCAAgC,CAclC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type * as TypeScript from 'typescript';
|
|
2
|
+
import { type ManagedColumnRequirement, type NamingConvention, type SchemaDialect } from './managed-columns.js';
|
|
3
|
+
export type TypeScriptApi = Omit<typeof TypeScript, 'default'>;
|
|
4
|
+
export type SchemaTableStyle = 'q-feature' | 'q-table' | 'raw-drizzle';
|
|
5
|
+
export type StaticDeleteMode = 'hard' | 'soft' | 'default' | 'dynamic';
|
|
6
|
+
export interface SchemaTableContext {
|
|
7
|
+
/** Stable within one source file, even when SQL table names repeat. */
|
|
8
|
+
id: string;
|
|
9
|
+
fileName: string;
|
|
10
|
+
tableName: string;
|
|
11
|
+
variableName?: string;
|
|
12
|
+
style: SchemaTableStyle;
|
|
13
|
+
dialect: SchemaDialect;
|
|
14
|
+
namingConvention: NamingConvention;
|
|
15
|
+
hasResourceConfig: boolean;
|
|
16
|
+
deleteMode: StaticDeleteMode;
|
|
17
|
+
sourceStart: number;
|
|
18
|
+
sourceEnd: number;
|
|
19
|
+
}
|
|
20
|
+
export type ManagedRequirementResolver = (table: SchemaTableContext) => ReadonlyArray<ManagedColumnRequirement>;
|
|
21
|
+
export interface SchemaSourceEdit {
|
|
22
|
+
start: number;
|
|
23
|
+
end: number;
|
|
24
|
+
text: string;
|
|
25
|
+
tableId?: string;
|
|
26
|
+
reason: string;
|
|
27
|
+
}
|
|
28
|
+
export type SchemaSyncDiagnosticCode = 'DIVERGENT_MANAGED_COLUMN' | 'DUPLICATE_MANAGED_REPRESENTATION' | 'DUPLICATE_TABLE_COLUMN' | 'MISSING_VALUE_IMPORT' | 'SOURCE_PARSE_ERROR' | 'UNSUPPORTED_DYNAMIC_DELETE_MODE' | 'REQUIREMENT_RESOLUTION_FAILED' | 'INVALID_REQUIREMENT' | 'OVERLAPPING_SOURCE_EDITS';
|
|
29
|
+
export interface SchemaSyncDiagnostic {
|
|
30
|
+
code: SchemaSyncDiagnosticCode;
|
|
31
|
+
message: string;
|
|
32
|
+
fileName: string;
|
|
33
|
+
tableId?: string;
|
|
34
|
+
tableName?: string;
|
|
35
|
+
start?: number;
|
|
36
|
+
end?: number;
|
|
37
|
+
expected?: string;
|
|
38
|
+
actual?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface PlanSchemaSourceOptions {
|
|
41
|
+
fileName: string;
|
|
42
|
+
source: string;
|
|
43
|
+
typescript: TypeScriptApi;
|
|
44
|
+
dialect: SchemaDialect;
|
|
45
|
+
namingConvention?: NamingConvention;
|
|
46
|
+
resolveRequirements: ManagedRequirementResolver;
|
|
47
|
+
}
|
|
48
|
+
export interface SchemaSourcePlan {
|
|
49
|
+
fileName: string;
|
|
50
|
+
source: string;
|
|
51
|
+
tables: ReadonlyArray<SchemaTableContext>;
|
|
52
|
+
edits: ReadonlyArray<SchemaSourceEdit>;
|
|
53
|
+
diagnostics: ReadonlyArray<SchemaSyncDiagnostic>;
|
|
54
|
+
updatedSource: string;
|
|
55
|
+
changed: boolean;
|
|
56
|
+
canApply: boolean;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Inspect every table in one source file and calculate formatting-preserving,
|
|
60
|
+
* additive-only source edits. No edit is applied here.
|
|
61
|
+
*/
|
|
62
|
+
export declare function planSchemaSource(options: PlanSchemaSourceOptions): SchemaSourcePlan;
|
|
63
|
+
export declare function applySchemaSourceEdits(source: string, edits: ReadonlyArray<SchemaSourceEdit>): string;
|
|
64
|
+
//# sourceMappingURL=source-sync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-sync.d.ts","sourceRoot":"","sources":["../src/source-sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,UAAU,MAAM,YAAY,CAAC;AAC9C,OAAO,EAIL,KAAK,wBAAwB,EAG7B,KAAK,gBAAgB,EACrB,KAAK,aAAa,EACnB,MAAM,sBAAsB,CAAC;AAE9B,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,UAAU,EAAE,SAAS,CAAC,CAAC;AAC/D,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG,SAAS,GAAG,aAAa,CAAC;AACvE,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;AAEvE,MAAM,WAAW,kBAAkB;IACjC,uEAAuE;IACvE,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,gBAAgB,CAAC;IACxB,OAAO,EAAE,aAAa,CAAC;IACvB,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,iBAAiB,EAAE,OAAO,CAAC;IAC3B,UAAU,EAAE,gBAAgB,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,0BAA0B,GAAG,CACvC,KAAK,EAAE,kBAAkB,KACtB,aAAa,CAAC,wBAAwB,CAAC,CAAC;AAE7C,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;C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a,CAAC,gBAAgB,CAAC,GACrC,MAAM,CAsBR"}
|
|
@@ -88,6 +88,10 @@ export default defineAction({
|
|
|
88
88
|
nextStatus: z.enum(["screening", "interview", "offer"]),
|
|
89
89
|
notes: z.string().max(2000).optional(),
|
|
90
90
|
}),
|
|
91
|
+
output: z.object({
|
|
92
|
+
id: z.string(),
|
|
93
|
+
status: z.enum(["screening", "interview", "offer"]),
|
|
94
|
+
}),
|
|
91
95
|
access: { roles: ["owner", "admin"] },
|
|
92
96
|
transition: {
|
|
93
97
|
field: "status",
|
|
@@ -116,8 +120,8 @@ export default defineAction({
|
|
|
116
120
|
> the `.quickback/` directory is generated alongside your feature with a
|
|
117
121
|
> typed helper. It infers `record` and Zod `input`, exposes the generated
|
|
118
122
|
> `Services`, types `c` as a Hono request context, binds `whereRecord` and
|
|
119
|
-
> `whereTransition` to the feature table, and
|
|
120
|
-
>
|
|
123
|
+
> `whereTransition` to the feature table, and checks the value returned by
|
|
124
|
+
> `execute` against `output` when you declare one. Scoped
|
|
121
125
|
> `db` and interactive `tx` are schema-aware on D1 and Neon Hyperdrive;
|
|
122
126
|
> HTTP/WebSocket Neon keeps its dynamic database escape hatch. `AppContext`
|
|
123
127
|
> also retains its open index for namespace-hydrated fields. Audit fields
|
|
@@ -145,12 +149,15 @@ export default defineAction({
|
|
|
145
149
|
> `quickback/features/*/.quickback/` in `.gitignore` (new projects get this
|
|
146
150
|
> automatically).
|
|
147
151
|
|
|
148
|
-
### Local
|
|
152
|
+
### Local action-schema harvest
|
|
149
153
|
|
|
150
154
|
Before sending a compile request, the CLI loads each action in an isolated
|
|
151
|
-
local bundle and converts `action.input`
|
|
152
|
-
not call `execute`; the hosted compiler never
|
|
153
|
-
|
|
155
|
+
local bundle and converts `action.input` plus an optional `action.output` with
|
|
156
|
+
Zod 4's `z.toJSONSchema`. It does not call `execute`; the hosted compiler never
|
|
157
|
+
evaluates project code. The output contract feeds OpenAPI and
|
|
158
|
+
`Api.<feature>.actions.<action>.Output` in `quickback.gen.ts`. Under
|
|
159
|
+
contract v2, every action input must produce a schema; output remains optional.
|
|
160
|
+
A failure names the exact
|
|
154
161
|
action, whether bundling or evaluation failed, and the underlying local error.
|
|
155
162
|
V1 can still fall back to the lower-fidelity static schema parser.
|
|
156
163
|
|
|
@@ -176,6 +183,7 @@ namespace parameters.
|
|
|
176
183
|
|--------|----------|-------------|
|
|
177
184
|
| `description` | Yes | Human-readable description of the action |
|
|
178
185
|
| `input` | Yes | Zod schema for request validation |
|
|
186
|
+
| `output` | No | Portable Zod schema for the JSON success response. Generates action output types and constrains `execute`'s result. |
|
|
179
187
|
| `access` | Yes | Access control (roles, record conditions, or function) |
|
|
180
188
|
| `execute` | Yes | Inline async arrow function (`async (ctx) => { … }`) |
|
|
181
189
|
| `path` | Standalone only | Custom route path. Presence of `path` makes the action standalone. |
|
|
@@ -31,14 +31,17 @@ Each endpoint includes request/response schemas derived from your Drizzle column
|
|
|
31
31
|
|
|
32
32
|
The generated component schemas carry enough type information that strict validators (zod, openapi-typescript, openapi-fetch) produce non-optional, narrowed types out of the box:
|
|
33
33
|
|
|
34
|
-
- **`required[]` on response components** — every
|
|
34
|
+
- **`required[]` on response components** — every selected column is listed; nullable columns are present as `T | null`, not optional.
|
|
35
|
+
- **Logical q types survive database lowering** — `q.bool()` remains `boolean`, `q.timestamp()` remains an ISO date-time string, and `q.url()` retains its URI format even when D1 stores the value as text or integer.
|
|
35
36
|
- **Closed enums on `text(_, { enum: [...] })` columns** — emitted as `{ type: "string", enum: [...] }`, narrowing to a literal union in TS.
|
|
36
37
|
- **`Error.code` is a closed enum** — every `code` value the API can emit (`AUTH_MISSING`, `DB_UNIQUE_VIOLATION`, `BATCH_SIZE_EXCEEDED`, …) is enumerated so consumers can `switch` exhaustively.
|
|
37
38
|
- **ID `format`** — only emitted as `format: "uuid"` when your project's `generateId` actually produces UUIDs. cuid2 / prefixed / nanoid / serial generators get plain `{ type: "string" }`, keeping strict OpenAPI validators happy.
|
|
38
39
|
|
|
39
|
-
### Action input schemas
|
|
40
|
+
### Action input and output schemas
|
|
40
41
|
|
|
41
|
-
Actions defined with [`defineAction({ input
|
|
42
|
+
Actions defined with [`defineAction({ input, output })`](/compiler/definitions/actions) get both Zod schemas lifted into the operation. `GET` inputs become typed query parameters; other methods use a JSON request body. A declared `output` becomes the success response schema and the generated helper requires `execute` to return a compatible value.
|
|
43
|
+
|
|
44
|
+
The CLI evaluates only the schema declarations in an isolated local bundle and converts them with Zod 4's `z.toJSONSchema()`. It never invokes `execute`, and the hosted compiler only receives plain JSON Schema data. Discriminated unions, refinements, recursive schemas, and shared schema references therefore flow to OpenAPI and generated TypeScript without relying on the compiler's static fallback parser.
|
|
42
45
|
|
|
43
46
|
## Configuration
|
|
44
47
|
|
|
@@ -154,7 +157,7 @@ export default defineConfig({
|
|
|
154
157
|
|
|
155
158
|
The file is generated by piping the in-memory spec through [openapi-typescript](https://github.com/openapi-ts/openapi-typescript) — you can keep running it manually if you want a different output path or version, but for the typical case there's nothing to wire up. If your API project and SPA live in the same repo, prefer multiple `openapi.types` outputs over a second manual `codegen:api` step so one `quickback compile` keeps both copies in sync. Skipped automatically when `openapi.generate` is `false`.
|
|
156
159
|
|
|
157
|
-
|
|
160
|
+
For application code, prefer the compact first-party [`quickback.gen.ts` type tree](/compiler/targets/hono-api/using-the-api/typescript). Keep `api-types.gen.ts` for `openapi-fetch` and third-party OpenAPI tooling.
|
|
158
161
|
|
|
159
162
|
### External viewer
|
|
160
163
|
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# TypeScript Type Tree
|
|
2
|
+
|
|
3
|
+
Every compile emits `quickback.gen.ts`: a compact, type-only tree designed for application code. It is generated directly from the same compiler model that drives routes and OpenAPI, so there is no runtime package and no code to initialize.
|
|
4
|
+
|
|
5
|
+
```typescript
|
|
6
|
+
import type { Api, Qb } from "../quickback.gen";
|
|
7
|
+
|
|
8
|
+
type Application = Api.applications.Row;
|
|
9
|
+
type NewApplication = Api.applications.Insert;
|
|
10
|
+
type ApplicationPatch = Api.applications.Update;
|
|
11
|
+
type ApplicationId = Api.applications.Id;
|
|
12
|
+
|
|
13
|
+
type AdvanceInput = Api.applications.actions.advance.Input;
|
|
14
|
+
type AdvanceOutput = Api.applications.actions.advance.Output;
|
|
15
|
+
type PipelineItem = Api.applications.views.pipeline.Item;
|
|
16
|
+
type PipelineResponse = Api.applications.views.pipeline.Response;
|
|
17
|
+
|
|
18
|
+
type Page = Qb.Page<Application>;
|
|
19
|
+
type ApiProblem = Qb.Problem;
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Feature areas preserve their authored hierarchy:
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
type Booking = Api.events.travel.bookings.Row;
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Table types
|
|
29
|
+
|
|
30
|
+
Each resource table exposes:
|
|
31
|
+
|
|
32
|
+
| Member | Meaning |
|
|
33
|
+
|---|---|
|
|
34
|
+
| `Id` | Nominal table-specific primary-key type |
|
|
35
|
+
| `Row` | Complete selected wire shape |
|
|
36
|
+
| `Insert` | Createable fields, with defaults and nullable fields optional |
|
|
37
|
+
| `Update` | Updatable fields, all optional |
|
|
38
|
+
| `ListResponse` | `Qb.Page<Row>` |
|
|
39
|
+
| `columns.<name>` | Type of one row column |
|
|
40
|
+
| `views.<name>.Item` | A view's projected row |
|
|
41
|
+
| `views.<name>.Response` | Page plus typed aggregations where declared |
|
|
42
|
+
| `actions.<name>.Input` | The action's Zod input contract |
|
|
43
|
+
| `actions.<name>.Output` | The declared Zod output contract, or `unknown` |
|
|
44
|
+
|
|
45
|
+
Primary and foreign keys are branded by default. That makes accidentally passing a candidate ID where a job ID is required a TypeScript error, while both values remain ordinary strings or numbers at runtime.
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
function loadJob(id: Api.jobs.Id) {}
|
|
49
|
+
|
|
50
|
+
declare const candidateId: Api.candidates.Id;
|
|
51
|
+
loadJob(candidateId); // TypeScript error
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
At an untyped boundary, validate the value and cast it once:
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
const jobId = routeParams.id as Api.jobs.Id;
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Reading collections
|
|
61
|
+
|
|
62
|
+
List and view responses share one envelope: rows under `data`, pagination
|
|
63
|
+
metadata under `pagination`, and `view` naming the projection behind the
|
|
64
|
+
response (`null` for the default collection read).
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
declare const res: Api.applications.ListResponse; // Qb.Page<Api.applications.Row>
|
|
68
|
+
|
|
69
|
+
res.data; // Api.applications.Row[]
|
|
70
|
+
res.view; // string | null
|
|
71
|
+
res.pagination.count; // rows in this page
|
|
72
|
+
res.pagination.hasMore;
|
|
73
|
+
res.pagination.nextCursor; // pass back as ?starting_after=
|
|
74
|
+
res.pagination.total; // number | undefined — only when ?total=true
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
`total` and `totalPages` are counted only when the request passes
|
|
78
|
+
`?total=true`, so both are optional; every other member is always present. A
|
|
79
|
+
view that declares aggregations intersects this shape with a typed
|
|
80
|
+
`aggregations` object, and an aggregate-only view returns `{ view,
|
|
81
|
+
aggregations }` with no rows or pagination.
|
|
82
|
+
|
|
83
|
+
## Declaring action outputs
|
|
84
|
+
|
|
85
|
+
Add an optional `output` Zod schema to make an action end-to-end typed:
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
export default defineAction({
|
|
89
|
+
description: "Advance an application",
|
|
90
|
+
input: z.object({
|
|
91
|
+
nextStatus: z.enum(["screening", "interview", "offer"]),
|
|
92
|
+
}),
|
|
93
|
+
output: z.object({
|
|
94
|
+
id: z.string(),
|
|
95
|
+
status: z.enum(["screening", "interview", "offer"]),
|
|
96
|
+
}),
|
|
97
|
+
access: { roles: ["recruiter+"] },
|
|
98
|
+
async execute({ record, input }) {
|
|
99
|
+
return { id: record.id, status: input.nextStatus };
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
The generated feature helper checks `execute` against the declared output. The CLI harvests both schemas locally without invoking `execute`; the resulting contract feeds `quickback.gen.ts`, OpenAPI, and `api-types.gen.ts`.
|
|
105
|
+
|
|
106
|
+
## Configuration
|
|
107
|
+
|
|
108
|
+
The artifact is on by default:
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
export default defineConfig({
|
|
112
|
+
// Default: quickback.gen.ts
|
|
113
|
+
types: true,
|
|
114
|
+
});
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Use a custom path, fan out identical copies to colocated apps, disable branding, or turn the artifact off:
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
export default defineConfig({
|
|
121
|
+
types: {
|
|
122
|
+
output: [
|
|
123
|
+
"quickback.gen.ts",
|
|
124
|
+
"apps/web/src/lib/quickback.gen.ts",
|
|
125
|
+
],
|
|
126
|
+
brandIds: true,
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
| `types` value | Behavior |
|
|
132
|
+
|---|---|
|
|
133
|
+
| `true` or omitted | Write `quickback.gen.ts` |
|
|
134
|
+
| `false` | Do not emit the first-party type tree |
|
|
135
|
+
| `"src/lib/quickback.gen.ts"` | Write to one custom path |
|
|
136
|
+
| `["quickback.gen.ts", "apps/web/src/quickback.gen.ts"]` | Fan out identical copies |
|
|
137
|
+
| `{ output, brandIds: false }` | Configure paths and use structural IDs |
|
|
138
|
+
|
|
139
|
+
`api-types.gen.ts` remains available through `openapi.types` for `openapi-fetch` and third-party OpenAPI tools. The two artifacts are independent: disabling OpenAPI types does not disable the first-party tree.
|
|
140
|
+
|
|
141
|
+
The compiler also emits `reports/types.parity.gen.ts` when both artifacts exist. Quickback's output-matrix CI compiles that proof separately to require mutual assignability between direct table/action types and the OpenAPI wire types; it is outside the generated application's `src/**/*` build.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quickback-dev/cli",
|
|
3
|
-
"version": "0.58.
|
|
3
|
+
"version": "0.58.3",
|
|
4
4
|
"description": "CLI for Quickback — define your backend in TypeScript, compile to a fully wired Cloudflare Worker (or Bun / Node) with auth, database, migrations, security, CMS, and Account UI.",
|
|
5
5
|
"author": "Kardoe Incorporated <paul@kardoe.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,12 +43,13 @@
|
|
|
43
43
|
],
|
|
44
44
|
"scripts": {
|
|
45
45
|
"prebuild": "npx tsx scripts/inject-version.ts && npm run bundle:docs && npm run bundle:skill && npm run bundle:examples",
|
|
46
|
-
"build": "tsc",
|
|
46
|
+
"build": "tsc && npm run bundle:schema-engine",
|
|
47
47
|
"postbuild": "npx tsx scripts/bundle-cursor.ts && rm -rf dist/skill dist/examples && cp -r src/skill dist/skill && cp -r src/examples dist/examples",
|
|
48
48
|
"dev": "tsc --watch",
|
|
49
49
|
"test": "bun test",
|
|
50
50
|
"typecheck": "tsc --noEmit",
|
|
51
51
|
"bundle:docs": "npx tsx scripts/bundle-docs.ts",
|
|
52
|
+
"bundle:schema-engine": "node --import tsx scripts/bundle-schema-engine.ts",
|
|
52
53
|
"bundle:skill": "npx tsx scripts/bundle-skill.ts",
|
|
53
54
|
"bundle:cursor": "npx tsx scripts/bundle-cursor.ts",
|
|
54
55
|
"bundle:examples": "npx tsx scripts/bundle-examples.ts"
|
|
@@ -61,6 +62,7 @@
|
|
|
61
62
|
"prompts": "^2.4.2"
|
|
62
63
|
},
|
|
63
64
|
"devDependencies": {
|
|
65
|
+
"@quickback-dev/schema-engine": "workspace:*",
|
|
64
66
|
"@types/node": "^22.7.5",
|
|
65
67
|
"@types/prompts": "^2.4.9",
|
|
66
68
|
"bun-types": "^1.3.5",
|
|
@@ -88,6 +88,10 @@ export default defineAction({
|
|
|
88
88
|
nextStatus: z.enum(["screening", "interview", "offer"]),
|
|
89
89
|
notes: z.string().max(2000).optional(),
|
|
90
90
|
}),
|
|
91
|
+
output: z.object({
|
|
92
|
+
id: z.string(),
|
|
93
|
+
status: z.enum(["screening", "interview", "offer"]),
|
|
94
|
+
}),
|
|
91
95
|
access: { roles: ["owner", "admin"] },
|
|
92
96
|
transition: {
|
|
93
97
|
field: "status",
|
|
@@ -116,8 +120,8 @@ export default defineAction({
|
|
|
116
120
|
> the `.quickback/` directory is generated alongside your feature with a
|
|
117
121
|
> typed helper. It infers `record` and Zod `input`, exposes the generated
|
|
118
122
|
> `Services`, types `c` as a Hono request context, binds `whereRecord` and
|
|
119
|
-
> `whereTransition` to the feature table, and
|
|
120
|
-
>
|
|
123
|
+
> `whereTransition` to the feature table, and checks the value returned by
|
|
124
|
+
> `execute` against `output` when you declare one. Scoped
|
|
121
125
|
> `db` and interactive `tx` are schema-aware on D1 and Neon Hyperdrive;
|
|
122
126
|
> HTTP/WebSocket Neon keeps its dynamic database escape hatch. `AppContext`
|
|
123
127
|
> also retains its open index for namespace-hydrated fields. Audit fields
|
|
@@ -145,12 +149,15 @@ export default defineAction({
|
|
|
145
149
|
> `quickback/features/*/.quickback/` in `.gitignore` (new projects get this
|
|
146
150
|
> automatically).
|
|
147
151
|
|
|
148
|
-
### Local
|
|
152
|
+
### Local action-schema harvest
|
|
149
153
|
|
|
150
154
|
Before sending a compile request, the CLI loads each action in an isolated
|
|
151
|
-
local bundle and converts `action.input`
|
|
152
|
-
not call `execute`; the hosted compiler never
|
|
153
|
-
|
|
155
|
+
local bundle and converts `action.input` plus an optional `action.output` with
|
|
156
|
+
Zod 4's `z.toJSONSchema`. It does not call `execute`; the hosted compiler never
|
|
157
|
+
evaluates project code. The output contract feeds OpenAPI and
|
|
158
|
+
`Api.<feature>.actions.<action>.Output` in `quickback.gen.ts`. Under
|
|
159
|
+
contract v2, every action input must produce a schema; output remains optional.
|
|
160
|
+
A failure names the exact
|
|
154
161
|
action, whether bundling or evaluation failed, and the underlying local error.
|
|
155
162
|
V1 can still fall back to the lower-fidelity static schema parser.
|
|
156
163
|
|
|
@@ -176,6 +183,7 @@ namespace parameters.
|
|
|
176
183
|
|--------|----------|-------------|
|
|
177
184
|
| `description` | Yes | Human-readable description of the action |
|
|
178
185
|
| `input` | Yes | Zod schema for request validation |
|
|
186
|
+
| `output` | No | Portable Zod schema for the JSON success response. Generates action output types and constrains `execute`'s result. |
|
|
179
187
|
| `access` | Yes | Access control (roles, record conditions, or function) |
|
|
180
188
|
| `execute` | Yes | Inline async arrow function (`async (ctx) => { … }`) |
|
|
181
189
|
| `path` | Standalone only | Custom route path. Presence of `path` makes the action standalone. |
|