@pikku/cli 0.12.34 → 0.12.36

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 (109) hide show
  1. package/cli.schema.json +1 -1
  2. package/console-app/assets/index-Dxl3JsMK.js +233 -0
  3. package/console-app/index.html +1 -1
  4. package/dist/.pikku/agent/pikku-agent-types.gen.d.ts +1 -1
  5. package/dist/.pikku/channel/pikku-channel-types.gen.d.ts +1 -1
  6. package/dist/.pikku/channel/pikku-channel-types.gen.js +1 -1
  7. package/dist/.pikku/cli/pikku-cli-channel.js +6 -1
  8. package/dist/.pikku/cli/pikku-cli-types.gen.d.ts +1 -1
  9. package/dist/.pikku/cli/pikku-cli-types.gen.js +1 -1
  10. package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.js +1 -1
  11. package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.json +6 -0
  12. package/dist/.pikku/cli/pikku-cli-wirings.gen.d.ts +1 -1
  13. package/dist/.pikku/cli/pikku-cli-wirings.gen.js +1 -1
  14. package/dist/.pikku/cli/pikku-cli.gen.d.ts +1 -1
  15. package/dist/.pikku/cli/pikku-cli.gen.js +1 -1
  16. package/dist/.pikku/console/pikku-node-types.gen.d.ts +1 -1
  17. package/dist/.pikku/function/pikku-function-types.gen.d.ts +2 -2
  18. package/dist/.pikku/function/pikku-function-types.gen.js +17 -3
  19. package/dist/.pikku/function/pikku-functions-meta.gen.js +1 -1
  20. package/dist/.pikku/function/pikku-functions-meta.gen.json +238 -221
  21. package/dist/.pikku/function/pikku-functions.gen.js +3 -1
  22. package/dist/.pikku/http/pikku-http-types.gen.d.ts +1 -1
  23. package/dist/.pikku/http/pikku-http-types.gen.js +1 -1
  24. package/dist/.pikku/http/pikku-http-wirings-meta.gen.js +1 -1
  25. package/dist/.pikku/http/pikku-http-wirings.gen.d.ts +1 -1
  26. package/dist/.pikku/http/pikku-http-wirings.gen.js +1 -1
  27. package/dist/.pikku/mcp/pikku-mcp-types.gen.d.ts +1 -1
  28. package/dist/.pikku/mcp/pikku-mcp-types.gen.js +1 -1
  29. package/dist/.pikku/pikku-bootstrap.gen.d.ts +1 -1
  30. package/dist/.pikku/pikku-bootstrap.gen.js +1 -1
  31. package/dist/.pikku/pikku-meta-service.gen.d.ts +1 -1
  32. package/dist/.pikku/pikku-meta-service.gen.js +1 -1
  33. package/dist/.pikku/pikku-services.gen.d.ts +1 -1
  34. package/dist/.pikku/pikku-types.gen.d.ts +1 -1
  35. package/dist/.pikku/pikku-types.gen.js +1 -1
  36. package/dist/.pikku/queue/pikku-queue-types.gen.d.ts +1 -1
  37. package/dist/.pikku/queue/pikku-queue-types.gen.js +1 -1
  38. package/dist/.pikku/queue/pikku-queue-workers-wirings-meta.gen.js +1 -1
  39. package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.d.ts +1 -1
  40. package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.js +1 -1
  41. package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.js +1 -1
  42. package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.json +5 -4
  43. package/dist/.pikku/scheduler/pikku-scheduler-types.gen.d.ts +1 -1
  44. package/dist/.pikku/scheduler/pikku-scheduler-types.gen.js +1 -1
  45. package/dist/.pikku/schemas/register.gen.js +17 -13
  46. package/dist/.pikku/schemas/schemas/DbGenerateInput.schema.json +1 -0
  47. package/dist/.pikku/schemas/schemas/PikkuCLIConfig.schema.json +1 -1
  48. package/dist/.pikku/schemas/schemas/PikkuFunctionTypesInput.schema.json +1 -0
  49. package/dist/.pikku/secrets/pikku-secret-types.gen.d.ts +1 -1
  50. package/dist/.pikku/secrets/pikku-secret-types.gen.js +1 -1
  51. package/dist/.pikku/secrets/pikku-secrets.gen.d.ts +1 -1
  52. package/dist/.pikku/secrets/pikku-secrets.gen.js +1 -1
  53. package/dist/.pikku/trigger/pikku-trigger-types.gen.d.ts +1 -1
  54. package/dist/.pikku/trigger/pikku-trigger-types.gen.js +1 -1
  55. package/dist/.pikku/variables/pikku-variable-types.gen.d.ts +1 -1
  56. package/dist/.pikku/variables/pikku-variable-types.gen.js +1 -1
  57. package/dist/.pikku/variables/pikku-variables.gen.d.ts +1 -1
  58. package/dist/.pikku/variables/pikku-variables.gen.js +1 -1
  59. package/dist/.pikku/workflow/meta/allWorkflow.gen.json +22 -4
  60. package/dist/.pikku/workflow/pikku-workflow-types.gen.d.ts +1 -1
  61. package/dist/.pikku/workflow/pikku-workflow-types.gen.js +1 -1
  62. package/dist/.pikku/workflow/pikku-workflow-wirings-meta.gen.js +1 -1
  63. package/dist/.pikku/workflow/pikku-workflow-wirings.gen.js +1 -1
  64. package/dist/bin/pikku-bin.mjs +2 -2
  65. package/dist/src/cli.wiring.js +5 -0
  66. package/dist/src/fabric/functions/login.function.d.ts +1 -1
  67. package/dist/src/fabric/functions/login.function.js +1 -1
  68. package/dist/src/functions/commands/bootstrap.js +1 -1
  69. package/dist/src/functions/commands/db-generate.d.ts +1 -0
  70. package/dist/src/functions/commands/db-generate.js +45 -0
  71. package/dist/src/functions/commands/db-migrate.js +13 -1
  72. package/dist/src/functions/db/annotation-parser.d.ts +27 -16
  73. package/dist/src/functions/db/annotation-parser.js +50 -110
  74. package/dist/src/functions/db/better-auth-schema.d.ts +23 -0
  75. package/dist/src/functions/db/better-auth-schema.js +122 -0
  76. package/dist/src/functions/db/coercion-plugin.d.ts +1 -1
  77. package/dist/src/functions/db/coercion-plugin.js +4 -0
  78. package/dist/src/functions/db/db-codegen.d.ts +13 -1
  79. package/dist/src/functions/db/db-codegen.js +142 -31
  80. package/dist/src/functions/db/db-introspector.d.ts +6 -0
  81. package/dist/src/functions/db/local-db.d.ts +33 -0
  82. package/dist/src/functions/db/local-db.js +221 -79
  83. package/dist/src/functions/db/postgres/postgres-introspector.js +2 -0
  84. package/dist/src/functions/db/zod-codegen.d.ts +38 -0
  85. package/dist/src/functions/db/zod-codegen.js +153 -38
  86. package/dist/src/functions/validate/workspace-validate.js +1 -1
  87. package/dist/src/functions/wirings/auth/pikku-command-auth.js +30 -4
  88. package/dist/src/functions/wirings/auth/serialize-auth-gen.d.ts +33 -1
  89. package/dist/src/functions/wirings/auth/serialize-auth-gen.js +122 -88
  90. package/dist/src/functions/wirings/auth/serialize-auth-meta.d.ts +32 -0
  91. package/dist/src/functions/wirings/auth/serialize-auth-meta.js +23 -0
  92. package/dist/src/functions/wirings/auth/serialize-auth-types.d.ts +27 -0
  93. package/dist/src/functions/wirings/auth/serialize-auth-types.js +58 -0
  94. package/dist/src/functions/wirings/functions/pikku-command-function-types.d.ts +7 -1
  95. package/dist/src/functions/wirings/functions/pikku-command-function-types.js +16 -3
  96. package/dist/src/functions/wirings/functions/pikku-command-services.d.ts +1 -1
  97. package/dist/src/functions/wirings/functions/pikku-command-services.js +9 -2
  98. package/dist/src/functions/wirings/functions/serialize-function-types.js +17 -3
  99. package/dist/src/functions/wirings/functions/serialize-pikku-types-hub.d.ts +1 -1
  100. package/dist/src/functions/wirings/functions/serialize-pikku-types-hub.js +2 -1
  101. package/dist/src/functions/workflows/all.workflow.js +16 -2
  102. package/dist/src/scaffold/rpc-remote.gen.js +1 -1
  103. package/dist/src/services.js +8 -0
  104. package/dist/src/utils/pikku-cli-config.js +12 -0
  105. package/dist/tsconfig.tsbuildinfo +1 -1
  106. package/package.json +4 -3
  107. package/skills/pikku-better-auth/SKILL.md +211 -0
  108. package/console-app/assets/index-DsW0T00Z.js +0 -233
  109. package/skills/pikku-auth-js/SKILL.md +0 -339
@@ -1,6 +1,26 @@
1
1
  import { readFileSync, writeFileSync, mkdirSync } from 'node:fs';
2
2
  import { dirname } from 'node:path';
3
- import { loadAnnotations, parseAnnotations, annotationFromName, } from './annotation-parser.js';
3
+ import { loadAnnotations, nameSuggestsKind, } from './annotation-parser.js';
4
+ import { ZOD_FORMATS } from './zod-codegen.js';
5
+ /**
6
+ * The column kind implied by the *real* DB type, dialect-aware. Postgres has
7
+ * native temporal/boolean types so we can trust them; SQLite stores dates as
8
+ * TEXT and booleans as INTEGER, so its declared types are indeterminate and we
9
+ * derive nothing (return null). Used both to auto-type Postgres dates and to
10
+ * detect name↔type contradictions for warnings.
11
+ */
12
+ function realKind(dialect, sqlType) {
13
+ if (dialect !== 'postgres')
14
+ return null;
15
+ const u = sqlType.toUpperCase();
16
+ if (u.includes('TIMESTAMP') || u === 'DATE')
17
+ return 'date';
18
+ if (u === 'BOOLEAN' || u === 'BOOL')
19
+ return 'bool';
20
+ if (u === 'UUID')
21
+ return 'uuid';
22
+ return null;
23
+ }
4
24
  // ─── Name helpers ─────────────────────────────────────────────────────────────
5
25
  function snakeToPascal(name) {
6
26
  return name
@@ -11,6 +31,10 @@ function snakeToPascal(name) {
11
31
  function snakeToCamel(name) {
12
32
  return name.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
13
33
  }
34
+ /** Escape a value for embedding inside a single-quoted TS string literal. */
35
+ function escapeTsString(value) {
36
+ return value.replace(/\\/g, '\\\\').replace(/'/g, "\\'");
37
+ }
14
38
  // ─── Type mapping ─────────────────────────────────────────────────────────────
15
39
  function mapType(sqlType) {
16
40
  const upper = sqlType.toUpperCase();
@@ -40,21 +64,30 @@ function mapType(sqlType) {
40
64
  }
41
65
  // ─── Type expression ─────────────────────────────────────────────────────────
42
66
  function selectBase(annotation, col) {
67
+ // An explicit `tsType` is a general type override and wins over everything.
68
+ if (annotation?.tsType)
69
+ return annotation.tsType;
43
70
  if (annotation?.kind === 'bool')
44
71
  return 'boolean';
45
72
  if (annotation?.kind === 'date')
46
73
  return 'Date';
74
+ if (annotation?.kind === 'uuid')
75
+ return 'Uuid';
47
76
  if (annotation?.kind === 'json')
48
- return annotation.tsType ?? 'unknown';
77
+ return 'unknown';
49
78
  return mapType(col.type);
50
79
  }
51
80
  function insertBase(annotation, col) {
81
+ if (annotation?.tsType)
82
+ return annotation.tsType;
52
83
  if (annotation?.kind === 'bool')
53
84
  return 'boolean | number';
54
85
  if (annotation?.kind === 'date')
55
86
  return 'Date | string';
87
+ if (annotation?.kind === 'uuid')
88
+ return 'Uuid';
56
89
  if (annotation?.kind === 'json')
57
- return annotation.tsType ?? 'unknown';
90
+ return 'unknown';
58
91
  return mapType(col.type);
59
92
  }
60
93
  function columnTypeExpression(col, annotation, classification) {
@@ -73,14 +106,17 @@ function columnTypeExpression(col, annotation, classification) {
73
106
  const rw = nullable ? 'Date | string | null' : 'Date | string';
74
107
  return wrap(`ColumnType<${base}, ${rw}, ${rw}>`);
75
108
  }
109
+ if (annotation?.kind === 'uuid') {
110
+ return wrap(nullable ? 'Uuid | null' : 'Uuid');
111
+ }
112
+ if (annotation?.tsType) {
113
+ const base = nullable
114
+ ? `${annotation.tsType} | null`
115
+ : annotation.tsType;
116
+ return wrap(base);
117
+ }
76
118
  if (annotation?.kind === 'json') {
77
- const base = annotation.tsType
78
- ? nullable
79
- ? `${annotation.tsType} | null`
80
- : annotation.tsType
81
- : nullable
82
- ? 'unknown | null'
83
- : 'unknown';
119
+ const base = nullable ? 'unknown | null' : 'unknown';
84
120
  return wrap(base);
85
121
  }
86
122
  const base = mapType(col.type);
@@ -109,18 +145,63 @@ function bareTableName(name) {
109
145
  const dot = name.indexOf('.');
110
146
  return dot >= 0 ? name.slice(dot + 1) : name;
111
147
  }
112
- function emitInterface(table, camelCase, explicitAnnotations) {
148
+ function emitInterface(table, camelCase, explicitAnnotations, dialect, enumByName, formatHints, warnings) {
113
149
  const ifaceName = snakeToPascal(table.name);
114
- const tableCols = explicitAnnotations[bareTableName(table.name)] ?? {};
150
+ const bare = bareTableName(table.name);
151
+ const tableCols = explicitAnnotations[bare] ?? {};
115
152
  const fields = table.columns
116
153
  .map((col) => {
117
154
  const fieldName = camelCase ? snakeToCamel(col.name) : col.name;
118
- const sqlAnn = tableCols[col.name] ?? null;
119
- const kindAnn = sqlAnn?.kind
120
- ? { kind: sqlAnn.kind, tsType: sqlAnn.tsType }
121
- : annotationFromName(col.name);
122
- const classification = sqlAnn?.classification ?? 'private';
123
- const type = columnTypeExpression(col, kindAnn, classification);
155
+ const ann = tableCols[col.name] ?? null;
156
+ // Effective typing kind: explicit annotation wins; otherwise, on Postgres
157
+ // the *real* column type tells us (a timestamp genuinely is a Date). On
158
+ // SQLite there is no native date storage (dates are TEXT), so nothing is
159
+ // derived `string` unless explicitly `kind: 'date'`.
160
+ // On Postgres, real `timestamp`/`uuid` types carry through automatically
161
+ // (no annotation needed); SQLite has neither native type so derives nothing.
162
+ const real = realKind(dialect, col.type);
163
+ const derived = !ann?.tsType && (real === 'date' || real === 'uuid') ? real : undefined;
164
+ const typingKind = ann?.kind ?? derived;
165
+ // Warn (don't force) only on a genuine contradiction the real type can
166
+ // prove: a column NAMED like a date/bool whose actual type disagrees
167
+ // (e.g. `created_at` that is really a boolean in Postgres). On SQLite the
168
+ // type is indeterminate, so there is nothing to contradict — no warning.
169
+ if (!ann?.kind && !ann?.tsType) {
170
+ const suggested = nameSuggestsKind(col.name);
171
+ if (suggested && real && suggested !== real) {
172
+ warnings.push(`Column "${bare}.${col.name}" is named like a ${suggested} but its DB type ` +
173
+ `is ${col.type} (${real}). If intentional, set its kind in db/annotations.ts.`);
174
+ }
175
+ }
176
+ // A Postgres enum column reports `type` as 'USER-DEFINED'; its real values
177
+ // come from `udtName`. Type it as a union of string literals — only when
178
+ // no explicit `tsType`/`kind` overrides it. This reuses the `tsType`
179
+ // plumbing, so it flows through both the public and classified branches.
180
+ const enumValues = col.udtName ? enumByName.get(col.udtName) : undefined;
181
+ const enumUnion = enumValues && enumValues.length > 0
182
+ ? enumValues.map((v) => `'${escapeTsString(v)}'`).join(' | ')
183
+ : null;
184
+ const effectiveTsType = ann?.tsType ?? (typingKind ? undefined : (enumUnion ?? undefined));
185
+ const typeAnn = typingKind || effectiveTsType
186
+ ? { kind: typingKind, tsType: effectiveTsType }
187
+ : null;
188
+ // A `format` validator refines the zod schema only and keeps the TS type
189
+ // as `string`. It therefore applies only when the resolved select base is
190
+ // plain `string`; on anything else (Date/Uuid/boolean/enum/unknown via
191
+ // kind/tsType) it would contradict the type, so warn and skip.
192
+ if (ann?.format) {
193
+ const base = selectBase(typeAnn, col);
194
+ if (base === 'string') {
195
+ ;
196
+ (formatHints[ifaceName] ??= {})[fieldName] = ann.format;
197
+ }
198
+ else {
199
+ warnings.push(`Column "${bare}.${col.name}": format '${ann.format}' ignored — its ` +
200
+ `resolved type is ${base}, not string. Remove the conflicting kind/tsType.`);
201
+ }
202
+ }
203
+ const classification = ann?.classification ?? 'private';
204
+ const type = columnTypeExpression(col, typeAnn, classification);
124
205
  const safeName = /^[a-zA-Z_][a-zA-Z0-9_]*$/.test(fieldName)
125
206
  ? fieldName
126
207
  : JSON.stringify(fieldName);
@@ -168,7 +249,21 @@ function emitManifest(tables, explicitAnnotations) {
168
249
  * flag added or removed columns.
169
250
  */
170
251
  function emitClassificationMap(tables) {
171
- const colEntry = ` security: 'public' | 'private' | 'pii' | 'secret' | 'encrypted'\n classification?: 'fake:email' | 'fake:name' | 'hash' | 'keep'\n description?: string`;
252
+ const colEntry = [
253
+ ` /** Privacy level. Defaults to 'private' when omitted. */`,
254
+ ` security?: 'public' | 'private' | 'pii' | 'secret' | 'encrypted'`,
255
+ ` /** Anonymize strategy used by \`pikku db anonymize\`. */`,
256
+ ` classification?: 'fake:email' | 'fake:name' | 'hash' | 'keep'`,
257
+ ` /** Column kind override for codegen coercion + typing. */`,
258
+ ` kind?: 'date' | 'bool' | 'json' | 'uuid'`,
259
+ ` /** TypeScript type override, e.g. \`string[]\` or \`MyJson\`. Wins over \`kind\`. */`,
260
+ ` tsType?: string`,
261
+ ` /** Zod string-format validator (keeps the TS type as \`string\`). */`,
262
+ ` format?: ${Object.keys(ZOD_FORMATS)
263
+ .map((f) => `'${f}'`)
264
+ .join(' | ')}`,
265
+ ` description?: string`,
266
+ ].join('\n');
172
267
  // Group tables by schema (for postgres schema.table names)
173
268
  const schemaMap = new Map();
174
269
  for (const table of tables) {
@@ -225,20 +320,32 @@ function emitClassificationMap(tables) {
225
320
  */
226
321
  export async function generateSchemaTypes(introspector, options) {
227
322
  const camelCase = options.camelCase ?? true;
323
+ const dialect = options.dialect ?? 'sqlite';
228
324
  const tableNames = await introspector.listTables();
229
325
  const tables = await Promise.all(tableNames.map(async (name) => ({
230
326
  name,
231
327
  columns: await introspector.getColumns(name),
232
328
  })));
233
329
  const explicitAnnotations = options.rootDir
234
- ? loadAnnotations(options.rootDir, options.migrationsDir)
235
- : options.migrationsDir
236
- ? parseAnnotations(options.migrationsDir)
237
- : {};
330
+ ? loadAnnotations(options.rootDir)
331
+ : {};
332
+ // Enum types — used to auto-type enum columns as string-literal unions. Keyed
333
+ // by both bare and schema-qualified name; `udtName` is bare so the bare key
334
+ // resolves it (a one-line changeset note flags the cross-schema-name caveat).
335
+ const enums = await introspector.listEnums();
336
+ const enumByName = new Map();
337
+ for (const e of enums) {
338
+ enumByName.set(e.name, e.values);
339
+ enumByName.set(`${e.schema}.${e.name}`, e.values);
340
+ }
238
341
  // ── schema.d.ts ─────────────────────────────────────────────────────────────
342
+ const warnings = [];
343
+ const zodFormats = {};
239
344
  const interfaces = tables
240
- .map((t) => emitInterface(t, camelCase, explicitAnnotations))
345
+ .map((t) => emitInterface(t, camelCase, explicitAnnotations, dialect, enumByName, zodFormats, warnings))
241
346
  .join('\n\n');
347
+ for (const w of warnings)
348
+ console.warn(`[pikku db] ${w}`);
242
349
  const dbEntries = tables
243
350
  .map((t) => {
244
351
  const tableKey = camelCase ? snakeToCamel(t.name) : t.name;
@@ -265,6 +372,9 @@ export async function generateSchemaTypes(introspector, options) {
265
372
  `export type Private<T> = T & { readonly __classification__?: 'private' }`,
266
373
  `export type Pii<T> = T & { readonly __classification__?: 'pii' }`,
267
374
  `export type Secret<T> = T & { readonly __classification__?: 'secret' }`,
375
+ // Transparent alias (structurally a string, so plain strings stay
376
+ // interchangeable) — its name lets the zod codegen emit `z.uuid()`.
377
+ `export type Uuid = string`,
268
378
  ``,
269
379
  interfaces,
270
380
  ``,
@@ -278,9 +388,11 @@ export async function generateSchemaTypes(introspector, options) {
278
388
  for (const table of tables) {
279
389
  const tableCols = explicitAnnotations[bareTableName(table.name)] ?? {};
280
390
  for (const col of table.columns) {
281
- const sqlAnn = tableCols[col.name];
282
- const kind = sqlAnn?.kind ?? annotationFromName(col.name)?.kind;
283
- if (kind) {
391
+ // Coercion is driven only by an explicit `kind` in db/annotations.ts —
392
+ // no name inference. An unannotated `*_at` column is not coerced. `uuid`
393
+ // is a string in both dialects, so it needs no runtime coercion.
394
+ const kind = tableCols[col.name]?.kind;
395
+ if (kind && kind !== 'uuid') {
284
396
  if (!coercionMap[table.name])
285
397
  coercionMap[table.name] = {};
286
398
  coercionMap[table.name][col.name] = kind;
@@ -315,10 +427,7 @@ export async function generateSchemaTypes(introspector, options) {
315
427
  // ── pikku-db-schema.gen.json ─────────────────────────────────────────────────
316
428
  let schemaJsonBody = null;
317
429
  if (options.schemaJsonFile) {
318
- const [fkResults, enums] = await Promise.all([
319
- Promise.all(tableNames.map((name) => introspector.getForeignKeys(name))),
320
- introspector.listEnums(),
321
- ]);
430
+ const fkResults = await Promise.all(tableNames.map((name) => introspector.getForeignKeys(name)));
322
431
  const fkMap = new Map(tableNames.map((name, i) => [name, fkResults[i]]));
323
432
  const jsonTables = tables.map((t) => ({
324
433
  name: t.name,
@@ -423,5 +532,7 @@ export async function generateSchemaTypes(introspector, options) {
423
532
  manifestWritten: manifestChanged,
424
533
  classificationMapWritten: classificationMapChanged,
425
534
  tables: tables.map((t) => t.name),
535
+ warnings,
536
+ zodFormats,
426
537
  };
427
538
  }
@@ -7,6 +7,12 @@ export interface ColumnInfo {
7
7
  defaultValue: string | null;
8
8
  /** True for virtual or stored generated columns — these are read-only and never inserted. */
9
9
  generated?: boolean;
10
+ /**
11
+ * Underlying DB type name (Postgres `udt_name`). For an enum column `type` is
12
+ * the generic `'USER-DEFINED'`, while `udtName` holds the actual enum type
13
+ * name used to resolve its values. Undefined on SQLite (no native enums).
14
+ */
15
+ udtName?: string;
10
16
  }
11
17
  export interface ForeignKeyInfo {
12
18
  column: string;
@@ -53,4 +53,37 @@ export declare function migrateAndCodegen(resolved: ResolvedDb): Promise<Migrate
53
53
  export declare function seed(resolved: ResolvedSqliteDb): Promise<SeedResult>;
54
54
  export declare function reset(resolved: ResolvedSqliteDb, rootDir: string): void;
55
55
  export declare function createKysely<DB>(resolved: ResolvedSqliteDb): Promise<Kysely<DB>>;
56
+ type SchemaMap = Map<string, Set<string>>;
57
+ export interface DesiredAuthSchema {
58
+ tables: SchemaMap;
59
+ sql: string;
60
+ }
61
+ export declare function desiredAuthSchema(rootDir: string, srcDirectories: string[], logger: {
62
+ error: (msg: string) => void;
63
+ }): Promise<DesiredAuthSchema | null>;
64
+ export declare function introspectSchema(resolved: ResolvedDb): Promise<SchemaMap>;
65
+ export interface AuthDriftResult {
66
+ hasAuth: boolean;
67
+ inSync: boolean;
68
+ missingTables: string[];
69
+ missingColumns: {
70
+ table: string;
71
+ columns: string[];
72
+ }[];
73
+ }
74
+ export declare function computeAuthDrift(resolved: ResolvedDb, rootDir: string, srcDirectories: string[], logger: {
75
+ error: (msg: string) => void;
76
+ }): Promise<AuthDriftResult>;
77
+ export interface GenerateAuthResult {
78
+ status: 'no-auth' | 'up-to-date' | 'written' | 'incremental-unsupported' | 'unsupported-dialect';
79
+ file?: string;
80
+ missingTables?: string[];
81
+ missingColumns?: {
82
+ table: string;
83
+ columns: string[];
84
+ }[];
85
+ }
86
+ export declare function generateAuthMigration(resolved: ResolvedDb, rootDir: string, srcDirectories: string[], logger: {
87
+ error: (msg: string) => void;
88
+ }): Promise<GenerateAuthResult>;
56
89
  export {};