@pikku/cli 0.12.89 → 0.12.91

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.
Files changed (162) hide show
  1. package/README.md +25 -2
  2. package/console-app/assets/{index-BaOGIr2O.js → index-CpkvmAGb.js} +148 -148
  3. package/console-app/assets/{index-CSzCJzBb.css → index-D0HG8q0B.css} +1 -1
  4. package/console-app/index.html +2 -2
  5. package/dist/.pikku/agent/pikku-agent-types.gen.d.ts +1 -1
  6. package/dist/.pikku/channel/pikku-channel-types.gen.d.ts +1 -1
  7. package/dist/.pikku/channel/pikku-channel-types.gen.js +1 -1
  8. package/dist/.pikku/cli/pikku-cli-channel.js +21 -1
  9. package/dist/.pikku/cli/pikku-cli-client.gen.d.ts +1 -1
  10. package/dist/.pikku/cli/pikku-cli-client.gen.js +1 -1
  11. package/dist/.pikku/cli/pikku-cli-contracts-meta.gen.d.ts +1 -1
  12. package/dist/.pikku/cli/pikku-cli-contracts-meta.gen.js +1 -1
  13. package/dist/.pikku/cli/pikku-cli-contracts-meta.gen.json +6 -1
  14. package/dist/.pikku/cli/pikku-cli-types.gen.d.ts +1 -1
  15. package/dist/.pikku/cli/pikku-cli-types.gen.js +1 -1
  16. package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.js +1 -1
  17. package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.json +52 -1
  18. package/dist/.pikku/cli/pikku-cli-wirings.gen.d.ts +1 -1
  19. package/dist/.pikku/cli/pikku-cli-wirings.gen.js +1 -1
  20. package/dist/.pikku/cli/pikku-cli.gen.d.ts +1 -1
  21. package/dist/.pikku/cli/pikku-cli.gen.js +1 -1
  22. package/dist/.pikku/console/pikku-node-types.gen.d.ts +1 -1
  23. package/dist/.pikku/function/pikku-function-types.gen.d.ts +4 -4
  24. package/dist/.pikku/function/pikku-function-types.gen.js +1 -1
  25. package/dist/.pikku/function/pikku-functions-meta.gen.js +1 -1
  26. package/dist/.pikku/function/pikku-functions-meta.gen.json +73 -13
  27. package/dist/.pikku/function/pikku-functions.gen.js +9 -1
  28. package/dist/.pikku/http/pikku-http-types.gen.d.ts +1 -1
  29. package/dist/.pikku/http/pikku-http-types.gen.js +1 -1
  30. package/dist/.pikku/mcp/pikku-mcp-types.gen.d.ts +1 -1
  31. package/dist/.pikku/mcp/pikku-mcp-types.gen.js +1 -1
  32. package/dist/.pikku/pikku-bootstrap-scenarios.gen.d.ts +8 -0
  33. package/dist/.pikku/pikku-bootstrap-scenarios.gen.js +8 -0
  34. package/dist/.pikku/pikku-bootstrap.gen.d.ts +1 -1
  35. package/dist/.pikku/pikku-bootstrap.gen.js +1 -1
  36. package/dist/.pikku/pikku-meta-service.gen.d.ts +1 -1
  37. package/dist/.pikku/pikku-meta-service.gen.js +1 -1
  38. package/dist/.pikku/pikku-services.gen.d.ts +1 -1
  39. package/dist/.pikku/pikku-types.gen.d.ts +1 -1
  40. package/dist/.pikku/pikku-types.gen.js +1 -1
  41. package/dist/.pikku/queue/pikku-queue-types.gen.d.ts +1 -1
  42. package/dist/.pikku/queue/pikku-queue-types.gen.js +1 -1
  43. package/dist/.pikku/queue/pikku-queue-workers-wirings-meta.gen.js +1 -1
  44. package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.d.ts +1 -1
  45. package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.js +1 -1
  46. package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.js +1 -1
  47. package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.json +4 -0
  48. package/dist/.pikku/scenarios/pikku-scenario-functions-meta.gen.d.ts +1 -0
  49. package/dist/.pikku/scenarios/pikku-scenario-functions-meta.gen.js +10 -0
  50. package/dist/.pikku/scenarios/pikku-scenario-functions-meta.gen.json +1 -0
  51. package/dist/.pikku/scenarios/pikku-scenario-functions.gen.d.ts +4 -0
  52. package/dist/.pikku/scenarios/pikku-scenario-functions.gen.js +1 -0
  53. package/dist/.pikku/scenarios/pikku-scenario-wirings-meta.gen.d.ts +1 -0
  54. package/dist/.pikku/scenarios/pikku-scenario-wirings-meta.gen.js +10 -0
  55. package/dist/.pikku/scenarios/pikku-scenario-wirings.gen.d.ts +4 -0
  56. package/dist/.pikku/scenarios/pikku-scenario-wirings.gen.js +1 -0
  57. package/dist/.pikku/scheduler/pikku-scheduler-types.gen.d.ts +1 -1
  58. package/dist/.pikku/scheduler/pikku-scheduler-types.gen.js +1 -1
  59. package/dist/.pikku/schemas/register.gen.js +9 -1
  60. package/dist/.pikku/schemas/schemas/DbBaselineInput.schema.json +1 -0
  61. package/dist/.pikku/schemas/schemas/DbCheckInput.schema.json +1 -0
  62. package/dist/.pikku/schemas/schemas/DbCodegenInput.schema.json +1 -0
  63. package/dist/.pikku/schemas/schemas/DbExportInput.schema.json +1 -0
  64. package/dist/.pikku/schemas/schemas/FabricValidateInput.schema.json +1 -1
  65. package/dist/.pikku/schemas/schemas/PikkuCLIConfig.schema.json +1 -1
  66. package/dist/.pikku/schemas/schemas/ScenarioRunInput.schema.json +1 -1
  67. package/dist/.pikku/scopes/pikku-scope-types.gen.d.ts +1 -1
  68. package/dist/.pikku/scopes/pikku-scope-types.gen.js +1 -1
  69. package/dist/.pikku/scopes/pikku-scopes.gen.d.ts +1 -1
  70. package/dist/.pikku/secrets/pikku-secret-types.gen.d.ts +1 -1
  71. package/dist/.pikku/secrets/pikku-secret-types.gen.js +1 -1
  72. package/dist/.pikku/secrets/pikku-secrets.gen.d.ts +1 -1
  73. package/dist/.pikku/secrets/pikku-secrets.gen.js +1 -1
  74. package/dist/.pikku/trigger/pikku-trigger-types.gen.d.ts +1 -1
  75. package/dist/.pikku/trigger/pikku-trigger-types.gen.js +1 -1
  76. package/dist/.pikku/variables/pikku-variable-types.gen.d.ts +1 -1
  77. package/dist/.pikku/variables/pikku-variable-types.gen.js +1 -1
  78. package/dist/.pikku/variables/pikku-variables.gen.d.ts +1 -1
  79. package/dist/.pikku/variables/pikku-variables.gen.js +1 -1
  80. package/dist/.pikku/workflow/pikku-scenario-actors.gen.d.ts +19 -0
  81. package/dist/.pikku/workflow/pikku-scenario-actors.gen.js +17 -0
  82. package/dist/.pikku/workflow/pikku-workflow-types.gen.d.ts +152 -3
  83. package/dist/.pikku/workflow/pikku-workflow-types.gen.js +39 -1
  84. package/dist/.pikku/workflow/pikku-workflow-wirings-meta.gen.js +1 -1
  85. package/dist/.pikku/workflow/pikku-workflow-wirings.gen.js +1 -1
  86. package/dist/bin/pikku-bin.mjs +2 -2
  87. package/dist/src/cli.wiring.js +42 -0
  88. package/dist/src/fabric/fabric-commands.d.ts +9 -3
  89. package/dist/src/fabric/fabric-commands.js +6 -0
  90. package/dist/src/fabric/functions/validate.function.d.ts +15 -5
  91. package/dist/src/fabric/functions/validate.function.js +69 -16
  92. package/dist/src/fabric/lib/config.d.ts +11 -1
  93. package/dist/src/fabric/lib/config.js +39 -1
  94. package/dist/src/fabric/lib/frontend-typecheck.d.ts +46 -0
  95. package/dist/src/fabric/lib/frontend-typecheck.js +139 -0
  96. package/dist/src/functions/commands/db-baseline.d.ts +13 -0
  97. package/dist/src/functions/commands/db-baseline.js +48 -0
  98. package/dist/src/functions/commands/db-check.d.ts +12 -0
  99. package/dist/src/functions/commands/db-check.js +64 -0
  100. package/dist/src/functions/commands/db-codegen.d.ts +11 -0
  101. package/dist/src/functions/commands/db-codegen.js +39 -0
  102. package/dist/src/functions/commands/db-export.d.ts +12 -0
  103. package/dist/src/functions/commands/db-export.js +31 -0
  104. package/dist/src/functions/commands/db-generate.js +19 -26
  105. package/dist/src/functions/commands/dev.js +2 -0
  106. package/dist/src/functions/commands/load-user-project.d.ts +7 -0
  107. package/dist/src/functions/commands/load-user-project.js +21 -0
  108. package/dist/src/functions/commands/pikku-command-bootstrap.js +12 -0
  109. package/dist/src/functions/commands/scenario-browser.d.ts +69 -0
  110. package/dist/src/functions/commands/scenario-browser.js +60 -0
  111. package/dist/src/functions/commands/scenario-formatter.d.ts +81 -0
  112. package/dist/src/functions/commands/scenario-formatter.js +120 -0
  113. package/dist/src/functions/commands/scenario-ladder.d.ts +66 -0
  114. package/dist/src/functions/commands/scenario-ladder.js +132 -0
  115. package/dist/src/functions/commands/scenario-plan.d.ts +61 -0
  116. package/dist/src/functions/commands/scenario-plan.js +106 -0
  117. package/dist/src/functions/commands/scenario.d.ts +18 -0
  118. package/dist/src/functions/commands/scenario.js +305 -38
  119. package/dist/src/functions/commands/serve.js +2 -0
  120. package/dist/src/functions/db/db-migrator.d.ts +35 -4
  121. package/dist/src/functions/db/db-migrator.js +67 -10
  122. package/dist/src/functions/db/local-db.d.ts +235 -13
  123. package/dist/src/functions/db/local-db.js +430 -45
  124. package/dist/src/functions/db/postgres/postgres-introspector.js +19 -1
  125. package/dist/src/functions/db/postgres/postgres-migrator.d.ts +1 -0
  126. package/dist/src/functions/db/postgres/postgres-migrator.js +4 -1
  127. package/dist/src/functions/db/sqlite/sqlite-introspector.js +2 -1
  128. package/dist/src/functions/db/sqlite/sqlite-migrator.d.ts +1 -0
  129. package/dist/src/functions/db/sqlite/sqlite-migrator.js +6 -1
  130. package/dist/src/functions/wirings/functions/pikku-command-functions.js +26 -8
  131. package/dist/src/functions/wirings/functions/serialize-function-types.js +3 -3
  132. package/dist/src/functions/wirings/scenarios/scenario-partition.d.ts +29 -0
  133. package/dist/src/functions/wirings/scenarios/scenario-partition.js +58 -0
  134. package/dist/src/functions/wirings/scenarios/serialize-feature-meta.d.ts +14 -0
  135. package/dist/src/functions/wirings/scenarios/serialize-feature-meta.js +29 -0
  136. package/dist/src/functions/wirings/scenarios/serialize-scenario-meta.d.ts +12 -0
  137. package/dist/src/functions/wirings/scenarios/serialize-scenario-meta.js +56 -0
  138. package/dist/src/functions/wirings/scenarios/serialize-scenario-registration.d.ts +7 -0
  139. package/dist/src/functions/wirings/scenarios/serialize-scenario-registration.js +40 -0
  140. package/dist/src/functions/wirings/workflow/pikku-command-workflow.js +43 -8
  141. package/dist/src/functions/wirings/workflow/serialize-scenario-actors.d.ts +1 -1
  142. package/dist/src/functions/wirings/workflow/serialize-scenario-actors.js +13 -2
  143. package/dist/src/functions/wirings/workflow/serialize-scenario-step-map.d.ts +4 -0
  144. package/dist/src/functions/wirings/workflow/serialize-scenario-step-map.js +62 -0
  145. package/dist/src/functions/wirings/workflow/serialize-workflow-bootstrap-map.js +10 -3
  146. package/dist/src/functions/wirings/workflow/serialize-workflow-map.js +10 -3
  147. package/dist/src/functions/wirings/workflow/serialize-workflow-meta.js +4 -4
  148. package/dist/src/functions/wirings/workflow/serialize-workflow-types.d.ts +1 -1
  149. package/dist/src/functions/wirings/workflow/serialize-workflow-types.js +232 -3
  150. package/dist/src/server/server-ready.d.ts +12 -0
  151. package/dist/src/server/server-ready.js +12 -0
  152. package/dist/src/server/spawn-dev-server.d.ts +50 -0
  153. package/dist/src/server/spawn-dev-server.js +112 -0
  154. package/dist/src/services.js +12 -1
  155. package/dist/src/utils/meta-diff.js +5 -2
  156. package/dist/src/utils/pikku-cli-config.js +26 -0
  157. package/dist/src/utils/resolve-scenario-actors.d.ts +23 -0
  158. package/dist/src/utils/resolve-scenario-actors.js +74 -0
  159. package/dist/tsconfig.tsbuildinfo +1 -1
  160. package/package.json +16 -6
  161. package/skills/pikku-i18n/SKILL.md +53 -6
  162. package/skills/pikku-scenario/SKILL.md +196 -29
@@ -1,5 +1,6 @@
1
1
  import { Kysely } from 'kysely';
2
2
  import { type MigrateResult } from './db-migrator.js';
3
+ import type { ColumnInfo } from './db-introspector.js';
3
4
  import { type CodegenResult } from './db-codegen.js';
4
5
  import { type ZodCodegenResult } from './zod-codegen.js';
5
6
  import { type SeedResult } from './sqlite/seed.js';
@@ -54,19 +55,150 @@ export interface MigrateAndCodegenOutcome {
54
55
  classificationsScaffolded: boolean;
55
56
  classificationsJsonWritten: boolean;
56
57
  }
57
- export declare function migrateAndCodegen(resolved: ResolvedDb): Promise<MigrateAndCodegenOutcome>;
58
+ export interface MigrateAndCodegenOptions {
59
+ /**
60
+ * Apply the migrations to a throwaway database and introspect that, instead
61
+ * of touching the configured one.
62
+ *
63
+ * The generated types describe the schema the migrations define, which is the
64
+ * contract — a live database additionally carries whatever has drifted into
65
+ * it (tables a runtime bootstrapped, leftovers from a reverted branch), and
66
+ * introspecting one makes codegen depend on a reachable, already-migrated
67
+ * server. That ordering is the problem this solves: codegen can now run
68
+ * before deploy-time migrations, on a machine with no database at all.
69
+ *
70
+ * SQLite uses `:memory:`; Postgres uses an embedded PGlite (real Postgres,
71
+ * and it needs no `CREATEDB` privilege anywhere).
72
+ */
73
+ scratch?: boolean;
74
+ }
75
+ export declare function migrateAndCodegen(resolved: ResolvedDb, options?: MigrateAndCodegenOptions): Promise<MigrateAndCodegenOutcome>;
58
76
  export declare function seed(resolved: ResolvedDb): Promise<SeedResult>;
59
77
  export declare function reset(resolved: ResolvedDb, rootDir: string): Promise<void>;
60
78
  export declare function createKysely<DB>(resolved: ResolvedDb): Promise<Kysely<DB>>;
61
- type SchemaMap = Map<string, Set<string>>;
62
- export interface DesiredAuthSchema {
79
+ /**
80
+ * Every table and its columns, keyed by the name the introspector reports.
81
+ *
82
+ * Carries the whole {@link ColumnInfo}, not just the names, because the same
83
+ * map has to answer both "does this column exist" and "what would the statement
84
+ * that adds it look like" — and a map of names can only answer the first.
85
+ */
86
+ type SchemaMap = Map<string, Map<string, ColumnInfo>>;
87
+ /**
88
+ * A schema somebody other than the project's own migrations defines — Better
89
+ * Auth, the pikku runtime, an addon.
90
+ *
91
+ * Every such source answers the same two questions, which is what lets one
92
+ * mechanism serve all of them: `tables` is what must exist, and `sql` is what
93
+ * creates it.
94
+ */
95
+ export interface DesiredSchema {
63
96
  tables: SchemaMap;
64
97
  sql: string;
65
98
  }
99
+ export type DesiredAuthSchema = DesiredSchema;
66
100
  export declare function desiredAuthSchema(resolved: ResolvedDb, rootDir: string, srcDirectories: string[], logger: {
67
101
  error: (msg: string) => void;
68
102
  }): Promise<DesiredAuthSchema | null>;
103
+ /** A runtime schema left out because nothing in the project creates what it needs. */
104
+ export interface SkippedRuntimeSchema {
105
+ schema: string;
106
+ /** The prerequisite that was not there, as `table.column`. */
107
+ requires: string;
108
+ owner: string;
109
+ }
110
+ export interface DesiredRuntimeSchema extends DesiredSchema {
111
+ skipped: SkippedRuntimeSchema[];
112
+ }
113
+ /**
114
+ * The tables `@pikku/kysely`'s runtime services need, as declared.
115
+ *
116
+ * Materialized the same way the auth schema is: applied to a throwaway database
117
+ * and introspected, so one declaration answers both "what should exist" and
118
+ * "what SQL creates it" without a hand-written per-dialect copy.
119
+ *
120
+ * Auth goes into the same database first, because it is a prerequisite — the
121
+ * scope tables grant to a user, so they reference the table Better Auth owns.
122
+ * Its tables are subtracted from the result: they are covered by auth's own
123
+ * source, and counting them twice would have `db generate` write them twice.
124
+ *
125
+ * A project with no auth configured is not an error here. It genuinely has no
126
+ * scope tables, so the schemas that wanted them are left out and returned in
127
+ * `skipped` — reported rather than dropped, because the tables they would have
128
+ * recognised now have nothing to explain them.
129
+ */
130
+ export declare function desiredRuntimeSchema(resolved: ResolvedDb, rootDir: string, srcDirectories: string[], logger: {
131
+ error: (msg: string) => void;
132
+ }): Promise<DesiredRuntimeSchema>;
69
133
  export declare function introspectSchema(resolved: ResolvedDb): Promise<SchemaMap>;
134
+ export interface SchemaDriftResult {
135
+ /** In the migrations, absent from the database — it is behind. */
136
+ missingTables: string[];
137
+ missingColumns: {
138
+ table: string;
139
+ columns: string[];
140
+ }[];
141
+ /**
142
+ * In the database and absent from the migrations, but declared by the pikku
143
+ * runtime — created by a service at boot rather than written down.
144
+ */
145
+ runtimeTables: string[];
146
+ /** In the database, absent from the migrations — nobody wrote it down. */
147
+ extraTables: string[];
148
+ /**
149
+ * Runtime schemas that could not be materialized, so their tables were not
150
+ * recognisable — the reason an `extraTables` entry may be a runtime table in
151
+ * disguise.
152
+ */
153
+ skippedRuntimeSchemas: SkippedRuntimeSchema[];
154
+ inSync: boolean;
155
+ }
156
+ /**
157
+ * Compare the schema the migration files define against the one the configured
158
+ * database actually has.
159
+ *
160
+ * The two halves are asymmetric and must stay that way. Something missing from
161
+ * the database is a database that is behind — the fix only ever adds, so it is
162
+ * safe to automate. Something present in the database but absent from the
163
+ * migrations is a table nobody wrote down: a runtime that created its own at
164
+ * boot, or the remains of a reverted branch. Dropping those is how data gets
165
+ * lost, so they are reported and never acted on.
166
+ *
167
+ * The pikku runtime declares tables of its own, and they are used here to
168
+ * recognise rather than to require. A project that never constructs the
169
+ * workflow or AI services should not be told it is missing their tables, so
170
+ * absence is not a finding. Presence is: a runtime table in the database that
171
+ * no migration creates gets reported as such, separately from the genuinely
172
+ * unexplained ones, because for those the remedy is known — `db generate`
173
+ * writes them down.
174
+ */
175
+ export declare function computeSchemaDrift(resolved: ResolvedDb, rootDir: string, srcDirectories: string[], logger: {
176
+ error: (msg: string) => void;
177
+ }): Promise<SchemaDriftResult>;
178
+ export type BaselineResult = {
179
+ status: 'behind';
180
+ drift: SchemaDriftResult;
181
+ } | {
182
+ status: 'recorded';
183
+ recorded: string[];
184
+ };
185
+ /**
186
+ * Record the pending migrations as applied, for a database that already has
187
+ * what they describe.
188
+ *
189
+ * The situation this exists for: a runtime created its tables at boot, and the
190
+ * migration writing them down was authored afterwards. Every existing
191
+ * deployment already has those tables, so running that migration fails; not
192
+ * running it leaves the history claiming the schema is something else.
193
+ *
194
+ * Guarded by the same question `db check` answers. If the database is behind
195
+ * its migrations in any way then the premise is false — the tables are not all
196
+ * there — and recording them would hide a real gap behind a history that says
197
+ * everything is applied. So it refuses and hands back the drift.
198
+ */
199
+ export declare function baseline(resolved: ResolvedDb, rootDir: string, srcDirectories: string[], logger: {
200
+ error: (msg: string) => void;
201
+ }): Promise<BaselineResult>;
70
202
  export interface AuthDriftResult {
71
203
  hasAuth: boolean;
72
204
  inSync: boolean;
@@ -79,16 +211,106 @@ export interface AuthDriftResult {
79
211
  export declare function computeAuthDrift(resolved: ResolvedDb, rootDir: string, srcDirectories: string[], logger: {
80
212
  error: (msg: string) => void;
81
213
  }): Promise<AuthDriftResult>;
82
- export interface GenerateAuthResult {
83
- status: 'no-auth' | 'up-to-date' | 'written' | 'incremental-unsupported';
84
- file?: string;
85
- missingTables?: string[];
86
- missingColumns?: {
87
- table: string;
88
- columns: string[];
89
- }[];
214
+ /**
215
+ * Something other than the project's own migrations that declares tables.
216
+ *
217
+ * Better Auth, the pikku runtime, an addon. They differ only in where the
218
+ * declaration comes from; once materialized they answer the same two questions,
219
+ * which is what lets one generator serve all of them.
220
+ */
221
+ export interface SchemaSource {
222
+ /**
223
+ * Labels the generated migration and every report line about it.
224
+ *
225
+ * Part of the contract: change it and the migration written under the old
226
+ * name is orphaned, so `db generate` writes the tables a second time.
227
+ */
228
+ name: string;
229
+ desired: DesiredSchema;
230
+ /** Prose for the migration header, saying where the SQL came from. */
231
+ origin: string;
232
+ }
233
+ /** One dialect's worth of a published schema. */
234
+ export interface ExportedSchema {
235
+ sql: string;
236
+ tables: Record<string, ColumnInfo[]>;
237
+ }
238
+ /**
239
+ * What an addon publishes: its schema, per dialect it supports.
240
+ *
241
+ * Per-dialect rather than one portable form because there is no portable form —
242
+ * the SQL an addon ships is the SQL it wrote for that engine, and a consumer
243
+ * on a dialect the addon never wrote for is a real incompatibility rather than
244
+ * something to paper over at generate time.
245
+ */
246
+ export type SchemaArtifact = Partial<Record<ResolvedDb['dialect'], ExportedSchema>>;
247
+ /** An addon as the consumer wired it. */
248
+ export interface AddonDeclaration {
249
+ package: string;
250
+ /**
251
+ * A `wireRemoteAddon` addon runs on another host, against that host's
252
+ * database. Its tables are not this project's to create.
253
+ */
254
+ remote?: boolean;
255
+ }
256
+ /**
257
+ * Materialize this package's own migrations into something a consumer can use.
258
+ *
259
+ * The producer half of the addon channel, and the same trick the auth and
260
+ * runtime sources use: run the SQL into a throwaway database and introspect it,
261
+ * so the artifact answers both "what must exist" and "what creates it" without
262
+ * a second, hand-written description that drifts.
263
+ *
264
+ * Every dialect the package has migrations for is exported, not just the one it
265
+ * happens to be configured against — an addon is published once and consumed by
266
+ * projects on either engine.
267
+ */
268
+ export declare function exportSchema(rootDir: string): Promise<SchemaArtifact>;
269
+ /**
270
+ * The schema every wired addon publishes, as sources.
271
+ *
272
+ * An addon never creates its own tables. It has no database of its own — it
273
+ * runs inside the consumer, against the consumer's — so the only honest place
274
+ * for its DDL is the consumer's own migration history, which is what turning it
275
+ * into a `SchemaSource` achieves.
276
+ */
277
+ export declare function addonSchemaSources(rootDir: string, dialect: ResolvedDb['dialect'], addons: AddonDeclaration[], logger: {
278
+ error: (msg: string) => void;
279
+ }): Promise<SchemaSource[]>;
280
+ /**
281
+ * Every schema source the project has, in the order they must be applied.
282
+ *
283
+ * Auth comes first because the runtime's scope tables reference its `user`
284
+ * table; addons come last because they may reference either.
285
+ */
286
+ export declare function schemaSources(resolved: ResolvedDb, rootDir: string, srcDirectories: string[], logger: {
287
+ error: (msg: string) => void;
288
+ }, addons?: AddonDeclaration[]): Promise<SchemaSource[]>;
289
+ export interface GeneratedMigration {
290
+ source: string;
291
+ file: string;
292
+ /** Columns the migration adds that need a backfill decision before it is applied. */
293
+ needsBackfill: string[];
294
+ }
295
+ export interface GenerateResult {
296
+ /** Sources whose tables the migrations already cover. */
297
+ upToDate: string[];
298
+ written: GeneratedMigration[];
90
299
  }
91
- export declare function generateAuthMigration(resolved: ResolvedDb, rootDir: string, srcDirectories: string[], logger: {
300
+ /**
301
+ * Write a migration for every schema source the migrations do not yet cover.
302
+ *
303
+ * Three cases per source, and the distinction matters. Fully covered is
304
+ * nothing to do. Nothing covered writes the source's own SQL verbatim, which is
305
+ * the one case where the source knows better than any diff — it carries the
306
+ * indexes, constraints and ordering a table-and-column comparison cannot see.
307
+ * Partially covered writes the delta, because re-emitting the whole schema
308
+ * would fail on the tables that already exist.
309
+ *
310
+ * Migrations are written one file per source, numbered in dependency order, so
311
+ * a project can review and apply them independently.
312
+ */
313
+ export declare function generateMigrations(resolved: ResolvedDb, rootDir: string, srcDirectories: string[], logger: {
92
314
  error: (msg: string) => void;
93
- }): Promise<GenerateAuthResult>;
315
+ }, addons?: AddonDeclaration[]): Promise<GenerateResult>;
94
316
  export {};