@pikku/cli 0.12.29 → 0.12.31
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/console-app/assets/{index-ClGe-ul_.js → index-BkiCv5R3.js} +1 -1
- package/console-app/index.html +1 -1
- package/dist/.pikku/agent/pikku-agent-types.gen.d.ts +1 -1
- package/dist/.pikku/channel/pikku-channel-types.gen.d.ts +1 -1
- package/dist/.pikku/channel/pikku-channel-types.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli-channel.js +1 -1
- package/dist/.pikku/cli/pikku-cli-types.gen.d.ts +1 -1
- package/dist/.pikku/cli/pikku-cli-types.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli-wirings.gen.d.ts +1 -1
- package/dist/.pikku/cli/pikku-cli-wirings.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli.gen.d.ts +1 -1
- package/dist/.pikku/cli/pikku-cli.gen.js +1 -1
- package/dist/.pikku/console/pikku-node-types.gen.d.ts +1 -1
- package/dist/.pikku/function/pikku-function-types.gen.d.ts +1 -1
- package/dist/.pikku/function/pikku-function-types.gen.js +1 -1
- package/dist/.pikku/function/pikku-functions-meta.gen.js +1 -1
- package/dist/.pikku/function/pikku-functions-meta.gen.json +257 -257
- package/dist/.pikku/function/pikku-functions.gen.js +1 -1
- package/dist/.pikku/http/pikku-http-types.gen.d.ts +1 -1
- package/dist/.pikku/http/pikku-http-types.gen.js +1 -1
- package/dist/.pikku/http/pikku-http-wirings-meta.gen.js +1 -1
- package/dist/.pikku/http/pikku-http-wirings.gen.d.ts +1 -1
- package/dist/.pikku/http/pikku-http-wirings.gen.js +1 -1
- package/dist/.pikku/mcp/pikku-mcp-types.gen.d.ts +1 -1
- package/dist/.pikku/mcp/pikku-mcp-types.gen.js +1 -1
- package/dist/.pikku/pikku-bootstrap.gen.d.ts +1 -1
- package/dist/.pikku/pikku-bootstrap.gen.js +1 -1
- package/dist/.pikku/pikku-meta-service.gen.d.ts +1 -1
- package/dist/.pikku/pikku-meta-service.gen.js +1 -1
- package/dist/.pikku/pikku-services.gen.d.ts +1 -1
- package/dist/.pikku/pikku-types.gen.d.ts +1 -1
- package/dist/.pikku/pikku-types.gen.js +1 -1
- package/dist/.pikku/queue/pikku-queue-types.gen.d.ts +1 -1
- package/dist/.pikku/queue/pikku-queue-types.gen.js +1 -1
- package/dist/.pikku/queue/pikku-queue-workers-wirings-meta.gen.js +1 -1
- package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.d.ts +1 -1
- package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.js +1 -1
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.js +1 -1
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.json +5 -5
- package/dist/.pikku/scheduler/pikku-scheduler-types.gen.d.ts +1 -1
- package/dist/.pikku/scheduler/pikku-scheduler-types.gen.js +1 -1
- package/dist/.pikku/schemas/register.gen.js +15 -15
- package/dist/.pikku/secrets/pikku-secret-types.gen.d.ts +1 -1
- package/dist/.pikku/secrets/pikku-secret-types.gen.js +1 -1
- package/dist/.pikku/secrets/pikku-secrets.gen.d.ts +1 -1
- package/dist/.pikku/secrets/pikku-secrets.gen.js +1 -1
- package/dist/.pikku/trigger/pikku-trigger-types.gen.d.ts +1 -1
- package/dist/.pikku/trigger/pikku-trigger-types.gen.js +1 -1
- package/dist/.pikku/variables/pikku-variable-types.gen.d.ts +1 -1
- package/dist/.pikku/variables/pikku-variable-types.gen.js +1 -1
- package/dist/.pikku/variables/pikku-variables.gen.d.ts +1 -1
- package/dist/.pikku/variables/pikku-variables.gen.js +1 -1
- package/dist/.pikku/workflow/pikku-workflow-types.gen.d.ts +1 -1
- package/dist/.pikku/workflow/pikku-workflow-types.gen.js +1 -1
- package/dist/.pikku/workflow/pikku-workflow-wirings-meta.gen.js +1 -1
- package/dist/.pikku/workflow/pikku-workflow-wirings.gen.js +1 -1
- package/dist/bin/pikku-bin.mjs +2 -2
- package/dist/src/functions/commands/dev.js +1 -9
- package/dist/src/functions/db/db-codegen.d.ts +1 -0
- package/dist/src/functions/db/db-codegen.js +45 -0
- package/dist/src/functions/db/db-introspector.d.ts +12 -0
- package/dist/src/functions/db/local-db.d.ts +1 -0
- package/dist/src/functions/db/local-db.js +9 -2
- package/dist/src/functions/db/postgres/postgres-introspector.d.ts +3 -1
- package/dist/src/functions/db/postgres/postgres-introspector.js +43 -0
- package/dist/src/functions/db/sqlite/sqlite-introspector.d.ts +3 -1
- package/dist/src/functions/db/sqlite/sqlite-introspector.js +14 -0
- package/dist/src/functions/db/sqlite/sqlite-runtime-node.js +16 -3
- package/dist/src/functions/wirings/auth/serialize-auth-gen.js +4 -2
- package/dist/src/scaffold/rpc-remote.gen.js +1 -1
- package/package.json +1 -1
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"pikkuInfoMiddleware": "pikkuInfoMiddleware",
|
|
16
16
|
"pikkuInfoPermissions": "pikkuInfoPermissions",
|
|
17
17
|
"pikkuBootstrap": "pikkuBootstrap",
|
|
18
|
+
"pikkuCLITypes": "pikkuCLITypes",
|
|
18
19
|
"pikkuAddonTypes": "pikkuAddonTypes",
|
|
19
20
|
"pikkuWorkflow": "pikkuWorkflow",
|
|
20
|
-
"pikkuCLITypes": "pikkuCLITypes",
|
|
21
21
|
"FabricLogin": "FabricLogin",
|
|
22
22
|
"FabricInit": "FabricInit",
|
|
23
23
|
"FabricLink": "FabricLink",
|
|
@@ -92,7 +92,9 @@
|
|
|
92
92
|
"pikkuMetaClients": "pikkuMetaClients",
|
|
93
93
|
"remoteRPCHandler": "remoteRPCHandler",
|
|
94
94
|
"pikkuSummary": "pikkuSummary",
|
|
95
|
-
"
|
|
95
|
+
"pikkuAIAgentTypes": "pikkuAIAgentTypes",
|
|
96
|
+
"pikkuAIAgent": "pikkuAIAgent",
|
|
97
|
+
"pikkuPublicAgent": "pikkuPublicAgent",
|
|
96
98
|
"pikkuChannels": "pikkuChannels",
|
|
97
99
|
"pikkuChannelTypes": "pikkuChannelTypes",
|
|
98
100
|
"pikkuChannelsMap": "pikkuChannelsMap",
|
|
@@ -138,7 +140,5 @@
|
|
|
138
140
|
"pikkuTrigger": "pikkuTrigger",
|
|
139
141
|
"pikkuVariables": "pikkuVariables",
|
|
140
142
|
"pikkuWorkflowRoutes": "pikkuWorkflowRoutes",
|
|
141
|
-
"
|
|
142
|
-
"pikkuAIAgent": "pikkuAIAgent",
|
|
143
|
-
"pikkuPublicAgent": "pikkuPublicAgent"
|
|
143
|
+
"pikkuAuth": "pikkuAuth"
|
|
144
144
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This file was generated by @pikku/cli@0.12.
|
|
2
|
+
* This file was generated by @pikku/cli@0.12.31
|
|
3
3
|
*/
|
|
4
4
|
import { addSchema } from '@pikku/core/schema';
|
|
5
5
|
import * as PikkuSchemasOutput from './schemas/PikkuSchemasOutput.schema.json' with { type: 'json' };
|
|
@@ -178,20 +178,20 @@ import * as PikkuMetaClientsInput from './schemas/PikkuMetaClientsInput.schema.j
|
|
|
178
178
|
addSchema('PikkuMetaClientsInput', PikkuMetaClientsInput);
|
|
179
179
|
import * as RemoteRPCHandlerInput from './schemas/RemoteRPCHandlerInput.schema.json' with { type: 'json' };
|
|
180
180
|
addSchema('RemoteRPCHandlerInput', RemoteRPCHandlerInput);
|
|
181
|
+
import * as PikkuCommandChannelsOutput from './schemas/PikkuCommandChannelsOutput.schema.json' with { type: 'json' };
|
|
182
|
+
addSchema('PikkuCommandChannelsOutput', PikkuCommandChannelsOutput);
|
|
183
|
+
import * as PikkuCLIEntryOutput from './schemas/PikkuCLIEntryOutput.schema.json' with { type: 'json' };
|
|
184
|
+
addSchema('PikkuCLIEntryOutput', PikkuCLIEntryOutput);
|
|
185
|
+
import * as PikkuCLIOutput from './schemas/PikkuCLIOutput.schema.json' with { type: 'json' };
|
|
186
|
+
addSchema('PikkuCLIOutput', PikkuCLIOutput);
|
|
181
187
|
import * as PikkuAIAgentOutput from './schemas/PikkuAIAgentOutput.schema.json' with { type: 'json' };
|
|
182
188
|
addSchema('PikkuAIAgentOutput', PikkuAIAgentOutput);
|
|
183
189
|
import * as PikkuPublicAgentOutput from './schemas/PikkuPublicAgentOutput.schema.json' with { type: 'json' };
|
|
184
190
|
addSchema('PikkuPublicAgentOutput', PikkuPublicAgentOutput);
|
|
185
|
-
import * as PikkuCommandChannelsOutput from './schemas/PikkuCommandChannelsOutput.schema.json' with { type: 'json' };
|
|
186
|
-
addSchema('PikkuCommandChannelsOutput', PikkuCommandChannelsOutput);
|
|
187
191
|
import * as PikkuConsoleFunctionsOutput from './schemas/PikkuConsoleFunctionsOutput.schema.json' with { type: 'json' };
|
|
188
192
|
addSchema('PikkuConsoleFunctionsOutput', PikkuConsoleFunctionsOutput);
|
|
189
193
|
import * as PikkuNodesMetaOutput from './schemas/PikkuNodesMetaOutput.schema.json' with { type: 'json' };
|
|
190
194
|
addSchema('PikkuNodesMetaOutput', PikkuNodesMetaOutput);
|
|
191
|
-
import * as PikkuCLIEntryOutput from './schemas/PikkuCLIEntryOutput.schema.json' with { type: 'json' };
|
|
192
|
-
addSchema('PikkuCLIEntryOutput', PikkuCLIEntryOutput);
|
|
193
|
-
import * as PikkuCLIOutput from './schemas/PikkuCLIOutput.schema.json' with { type: 'json' };
|
|
194
|
-
addSchema('PikkuCLIOutput', PikkuCLIOutput);
|
|
195
195
|
import * as PikkuFunctionTypesSplitInput from './schemas/PikkuFunctionTypesSplitInput.schema.json' with { type: 'json' };
|
|
196
196
|
addSchema('PikkuFunctionTypesSplitInput', PikkuFunctionTypesSplitInput);
|
|
197
197
|
import * as PikkuFunctionsOutput from './schemas/PikkuFunctionsOutput.schema.json' with { type: 'json' };
|
|
@@ -210,24 +210,24 @@ import * as PikkuPackageOutput from './schemas/PikkuPackageOutput.schema.json' w
|
|
|
210
210
|
addSchema('PikkuPackageOutput', PikkuPackageOutput);
|
|
211
211
|
import * as PikkuPermissionsOutput from './schemas/PikkuPermissionsOutput.schema.json' with { type: 'json' };
|
|
212
212
|
addSchema('PikkuPermissionsOutput', PikkuPermissionsOutput);
|
|
213
|
+
import * as PikkuEventsScaffoldOutput from './schemas/PikkuEventsScaffoldOutput.schema.json' with { type: 'json' };
|
|
214
|
+
addSchema('PikkuEventsScaffoldOutput', PikkuEventsScaffoldOutput);
|
|
213
215
|
import * as PikkuCommandQueueOutput from './schemas/PikkuCommandQueueOutput.schema.json' with { type: 'json' };
|
|
214
216
|
addSchema('PikkuCommandQueueOutput', PikkuCommandQueueOutput);
|
|
215
217
|
import * as PikkuQueueOutput from './schemas/PikkuQueueOutput.schema.json' with { type: 'json' };
|
|
216
218
|
addSchema('PikkuQueueOutput', PikkuQueueOutput);
|
|
217
|
-
import * as PikkuEventsScaffoldOutput from './schemas/PikkuEventsScaffoldOutput.schema.json' with { type: 'json' };
|
|
218
|
-
addSchema('PikkuEventsScaffoldOutput', PikkuEventsScaffoldOutput);
|
|
219
|
-
import * as PikkuSchedulerOutput from './schemas/PikkuSchedulerOutput.schema.json' with { type: 'json' };
|
|
220
|
-
addSchema('PikkuSchedulerOutput', PikkuSchedulerOutput);
|
|
221
|
-
import * as PikkuTriggerTypesInput from './schemas/PikkuTriggerTypesInput.schema.json' with { type: 'json' };
|
|
222
|
-
addSchema('PikkuTriggerTypesInput', PikkuTriggerTypesInput);
|
|
223
|
-
import * as PikkuTriggerOutput from './schemas/PikkuTriggerOutput.schema.json' with { type: 'json' };
|
|
224
|
-
addSchema('PikkuTriggerOutput', PikkuTriggerOutput);
|
|
225
219
|
import * as PikkuPublicRPCOutput from './schemas/PikkuPublicRPCOutput.schema.json' with { type: 'json' };
|
|
226
220
|
addSchema('PikkuPublicRPCOutput', PikkuPublicRPCOutput);
|
|
227
221
|
import * as PikkuRemoteRPCOutput from './schemas/PikkuRemoteRPCOutput.schema.json' with { type: 'json' };
|
|
228
222
|
addSchema('PikkuRemoteRPCOutput', PikkuRemoteRPCOutput);
|
|
229
223
|
import * as PikkuRPCOutput from './schemas/PikkuRPCOutput.schema.json' with { type: 'json' };
|
|
230
224
|
addSchema('PikkuRPCOutput', PikkuRPCOutput);
|
|
225
|
+
import * as PikkuSchedulerOutput from './schemas/PikkuSchedulerOutput.schema.json' with { type: 'json' };
|
|
226
|
+
addSchema('PikkuSchedulerOutput', PikkuSchedulerOutput);
|
|
227
|
+
import * as PikkuTriggerTypesInput from './schemas/PikkuTriggerTypesInput.schema.json' with { type: 'json' };
|
|
228
|
+
addSchema('PikkuTriggerTypesInput', PikkuTriggerTypesInput);
|
|
229
|
+
import * as PikkuTriggerOutput from './schemas/PikkuTriggerOutput.schema.json' with { type: 'json' };
|
|
230
|
+
addSchema('PikkuTriggerOutput', PikkuTriggerOutput);
|
|
231
231
|
import * as PikkuWorkflowRoutesOutput from './schemas/PikkuWorkflowRoutesOutput.schema.json' with { type: 'json' };
|
|
232
232
|
addSchema('PikkuWorkflowRoutesOutput', PikkuWorkflowRoutesOutput);
|
|
233
233
|
import * as PikkuCLIConfig from './schemas/PikkuCLIConfig.schema.json' with { type: 'json' };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This file was generated by @pikku/cli@0.12.
|
|
2
|
+
* This file was generated by @pikku/cli@0.12.31
|
|
3
3
|
*/
|
|
4
4
|
export { wireVariable } from '@pikku/core/variable';
|
|
5
5
|
export type { CoreVariable, VariableDefinitionMeta, VariableDefinitionsMeta } from '@pikku/core/variable';
|
package/dist/bin/pikku-bin.mjs
CHANGED
|
@@ -11,8 +11,8 @@ async function checkForUpdate() {
|
|
|
11
11
|
})
|
|
12
12
|
if (!res.ok) return
|
|
13
13
|
const { version: latest } = await res.json()
|
|
14
|
-
if (latest !== '0.12.
|
|
15
|
-
process.stderr.write(`\n Update available 0.12.
|
|
14
|
+
if (latest !== '0.12.31') {
|
|
15
|
+
process.stderr.write(`\n Update available 0.12.31 → ${latest}\n brew upgrade pikku or npm install -g @pikku/cli\n\n`)
|
|
16
16
|
}
|
|
17
17
|
} catch {}
|
|
18
18
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { existsSync } from 'fs';
|
|
2
1
|
import { join, resolve } from 'path';
|
|
3
2
|
import { pikkuSessionlessFunc } from '#pikku';
|
|
4
3
|
import chokidar from 'chokidar';
|
|
@@ -40,8 +39,6 @@ export const dev = pikkuSessionlessFunc({
|
|
|
40
39
|
const commandWorkflowRegistrations = new Map(pikkuState(null, 'workflows', 'registrations'));
|
|
41
40
|
const workflowService = new InMemoryWorkflowService();
|
|
42
41
|
const pikkuDir = resolve(config.rootDir, config.outDir);
|
|
43
|
-
const bootstrapExists = existsSync(resolve(pikkuDir, 'pikku-bootstrap.gen.ts')) ||
|
|
44
|
-
existsSync(resolve(pikkuDir, 'pikku-bootstrap.gen.js'));
|
|
45
42
|
const runAll = async () => {
|
|
46
43
|
await workflowService.runToCompletion('allWorkflow', {}, rpc);
|
|
47
44
|
};
|
|
@@ -97,9 +94,6 @@ export const dev = pikkuSessionlessFunc({
|
|
|
97
94
|
pikkuState(null, 'workflows', 'registrations', previousWorkflowRegistrations);
|
|
98
95
|
}
|
|
99
96
|
};
|
|
100
|
-
if (bootstrapExists) {
|
|
101
|
-
await loadUserBootstrap(pikkuDir);
|
|
102
|
-
}
|
|
103
97
|
await runAllWithCommandState();
|
|
104
98
|
const inspectorState = await getInspectorState(true);
|
|
105
99
|
const { pikkuConfigFactory, singletonServicesFactory } = inspectorState.filesAndMethods;
|
|
@@ -107,9 +101,7 @@ export const dev = pikkuSessionlessFunc({
|
|
|
107
101
|
logger.error('createConfig and createSingletonServices must be defined in your project');
|
|
108
102
|
return;
|
|
109
103
|
}
|
|
110
|
-
|
|
111
|
-
await loadUserBootstrap(pikkuDir);
|
|
112
|
-
}
|
|
104
|
+
await loadUserBootstrap(pikkuDir);
|
|
113
105
|
workflowService.rewireQueueWorkers();
|
|
114
106
|
const configModule = await loadUserModule(pikkuConfigFactory.file);
|
|
115
107
|
const servicesModule = await loadUserModule(singletonServicesFactory.file);
|
|
@@ -308,11 +308,43 @@ export async function generateSchemaTypes(introspector, options) {
|
|
|
308
308
|
const classificationMapBody = options.classificationMapFile
|
|
309
309
|
? emitClassificationMap(tables)
|
|
310
310
|
: null;
|
|
311
|
+
// ── pikku-db-schema.gen.json ─────────────────────────────────────────────────
|
|
312
|
+
let schemaJsonBody = null;
|
|
313
|
+
if (options.schemaJsonFile) {
|
|
314
|
+
const [fkResults, enums] = await Promise.all([
|
|
315
|
+
Promise.all(tableNames.map((name) => introspector.getForeignKeys(name))),
|
|
316
|
+
introspector.listEnums(),
|
|
317
|
+
]);
|
|
318
|
+
const fkMap = new Map(tableNames.map((name, i) => [name, fkResults[i]]));
|
|
319
|
+
const jsonTables = tables.map((t) => ({
|
|
320
|
+
name: t.name,
|
|
321
|
+
columns: t.columns.map((c) => {
|
|
322
|
+
const fk = fkMap.get(t.name)?.find((f) => f.column === c.name);
|
|
323
|
+
return {
|
|
324
|
+
name: c.name,
|
|
325
|
+
type: c.type,
|
|
326
|
+
nullable: !c.notNull && !c.pk,
|
|
327
|
+
isPrimaryKey: c.pk,
|
|
328
|
+
...(fk
|
|
329
|
+
? {
|
|
330
|
+
foreignKey: {
|
|
331
|
+
table: fk.foreignTable,
|
|
332
|
+
column: fk.foreignColumn,
|
|
333
|
+
},
|
|
334
|
+
}
|
|
335
|
+
: {}),
|
|
336
|
+
};
|
|
337
|
+
}),
|
|
338
|
+
}));
|
|
339
|
+
schemaJsonBody =
|
|
340
|
+
JSON.stringify({ tables: jsonTables, enums }, null, 2) + '\n';
|
|
341
|
+
}
|
|
311
342
|
// ── write files ───────────────────────────────────────────────────────────────
|
|
312
343
|
let existingSchema = null;
|
|
313
344
|
let existingCoercion = null;
|
|
314
345
|
let existingManifest = null;
|
|
315
346
|
let existingClassificationMap = null;
|
|
347
|
+
let existingSchemaJson = null;
|
|
316
348
|
try {
|
|
317
349
|
existingSchema = readFileSync(options.outFile, 'utf8');
|
|
318
350
|
}
|
|
@@ -341,11 +373,20 @@ export async function generateSchemaTypes(introspector, options) {
|
|
|
341
373
|
/* ok */
|
|
342
374
|
}
|
|
343
375
|
}
|
|
376
|
+
if (options.schemaJsonFile) {
|
|
377
|
+
try {
|
|
378
|
+
existingSchemaJson = readFileSync(options.schemaJsonFile, 'utf8');
|
|
379
|
+
}
|
|
380
|
+
catch {
|
|
381
|
+
/* ok */
|
|
382
|
+
}
|
|
383
|
+
}
|
|
344
384
|
const schemaChanged = existingSchema !== schemaBody;
|
|
345
385
|
const coercionChanged = existingCoercion !== coercionBody;
|
|
346
386
|
const manifestChanged = manifestBody !== null && existingManifest !== manifestBody;
|
|
347
387
|
const classificationMapChanged = classificationMapBody !== null &&
|
|
348
388
|
existingClassificationMap !== classificationMapBody;
|
|
389
|
+
const schemaJsonChanged = schemaJsonBody !== null && existingSchemaJson !== schemaJsonBody;
|
|
349
390
|
if (schemaChanged) {
|
|
350
391
|
mkdirSync(dirname(options.outFile), { recursive: true });
|
|
351
392
|
writeFileSync(options.outFile, schemaBody, 'utf8');
|
|
@@ -364,6 +405,10 @@ export async function generateSchemaTypes(introspector, options) {
|
|
|
364
405
|
mkdirSync(dirname(options.classificationMapFile), { recursive: true });
|
|
365
406
|
writeFileSync(options.classificationMapFile, classificationMapBody, 'utf8');
|
|
366
407
|
}
|
|
408
|
+
if (schemaJsonChanged && options.schemaJsonFile && schemaJsonBody) {
|
|
409
|
+
mkdirSync(dirname(options.schemaJsonFile), { recursive: true });
|
|
410
|
+
writeFileSync(options.schemaJsonFile, schemaJsonBody, 'utf8');
|
|
411
|
+
}
|
|
367
412
|
return {
|
|
368
413
|
outFile: options.outFile,
|
|
369
414
|
coercionFile: options.coercionFile,
|
|
@@ -8,8 +8,20 @@ export interface ColumnInfo {
|
|
|
8
8
|
/** True for virtual or stored generated columns — these are read-only and never inserted. */
|
|
9
9
|
generated?: boolean;
|
|
10
10
|
}
|
|
11
|
+
export interface ForeignKeyInfo {
|
|
12
|
+
column: string;
|
|
13
|
+
foreignTable: string;
|
|
14
|
+
foreignColumn: string;
|
|
15
|
+
}
|
|
16
|
+
export interface EnumInfo {
|
|
17
|
+
name: string;
|
|
18
|
+
schema: string;
|
|
19
|
+
values: string[];
|
|
20
|
+
}
|
|
11
21
|
export interface DbIntrospector {
|
|
12
22
|
listTables(): Promise<string[]>;
|
|
13
23
|
getColumns(table: string): Promise<ColumnInfo[]>;
|
|
24
|
+
getForeignKeys(table: string): Promise<ForeignKeyInfo[]>;
|
|
25
|
+
listEnums(): Promise<EnumInfo[]>;
|
|
14
26
|
close(): Promise<void>;
|
|
15
27
|
}
|
|
@@ -40,6 +40,7 @@ export function resolveDb(userConfig, rootDir, outDir, runtimeDir) {
|
|
|
40
40
|
coercionFile: join(outDir, 'db', 'coercion.gen.ts'),
|
|
41
41
|
manifestFile: join(outDir, 'db', 'classification.gen.ts'),
|
|
42
42
|
classificationMapFile: join(outDir, 'db', 'classification-map.gen.d.ts'),
|
|
43
|
+
schemaJsonFile: join(outDir, 'db', 'pikku-db-schema.gen.json'),
|
|
43
44
|
classificationsFile: join(rootDir, 'db', 'annotations.ts'),
|
|
44
45
|
classificationsGenJsonFile: join(outDir, 'db', 'annotations.gen.json'),
|
|
45
46
|
zodFile: join(outDir, 'db', 'zod.gen.ts'),
|
|
@@ -55,13 +56,17 @@ export function resolveDb(userConfig, rootDir, outDir, runtimeDir) {
|
|
|
55
56
|
...base('db/postgres'),
|
|
56
57
|
};
|
|
57
58
|
}
|
|
58
|
-
|
|
59
|
+
const sqliteDb = userConfig.sqliteDb ??
|
|
60
|
+
(existsSync(join(rootDir, 'db/sqlite'))
|
|
61
|
+
? '.pikku-runtime/dev.db'
|
|
62
|
+
: undefined);
|
|
63
|
+
if (sqliteDb) {
|
|
59
64
|
const resolvedRuntimeDir = runtimeDir
|
|
60
65
|
? resolveAgainst(rootDir, runtimeDir)
|
|
61
66
|
: join(rootDir, '.pikku-runtime');
|
|
62
67
|
return {
|
|
63
68
|
dialect: 'sqlite',
|
|
64
|
-
dbFile: resolveAgainst(rootDir,
|
|
69
|
+
dbFile: resolveAgainst(rootDir, sqliteDb),
|
|
65
70
|
runtimeDir: resolvedRuntimeDir,
|
|
66
71
|
seedFile: resolveAgainst(rootDir, 'db/sqlite-seed.sql'),
|
|
67
72
|
...base('db/sqlite'),
|
|
@@ -95,6 +100,7 @@ export async function migrateAndCodegen(resolved) {
|
|
|
95
100
|
coercionFile: resolved.coercionFile,
|
|
96
101
|
manifestFile: resolved.manifestFile,
|
|
97
102
|
classificationMapFile: resolved.classificationMapFile,
|
|
103
|
+
schemaJsonFile: resolved.schemaJsonFile,
|
|
98
104
|
camelCase: resolved.camelCase,
|
|
99
105
|
rootDir: resolved.rootDir,
|
|
100
106
|
migrationsDir: resolved.migrationsDir,
|
|
@@ -120,6 +126,7 @@ export async function migrateAndCodegen(resolved) {
|
|
|
120
126
|
coercionFile: resolved.coercionFile,
|
|
121
127
|
manifestFile: resolved.manifestFile,
|
|
122
128
|
classificationMapFile: resolved.classificationMapFile,
|
|
129
|
+
schemaJsonFile: resolved.schemaJsonFile,
|
|
123
130
|
camelCase: resolved.camelCase,
|
|
124
131
|
rootDir: resolved.rootDir,
|
|
125
132
|
migrationsDir: resolved.migrationsDir,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DbIntrospector, ColumnInfo } from '../db-introspector.js';
|
|
1
|
+
import type { DbIntrospector, ColumnInfo, ForeignKeyInfo, EnumInfo } from '../db-introspector.js';
|
|
2
2
|
interface QueryClient {
|
|
3
3
|
query<T = unknown>(sql: string, params?: unknown[]): Promise<{
|
|
4
4
|
rows: T[];
|
|
@@ -11,6 +11,8 @@ export declare class PostgresIntrospector implements DbIntrospector {
|
|
|
11
11
|
connect(): Promise<void>;
|
|
12
12
|
listTables(): Promise<string[]>;
|
|
13
13
|
getColumns(table: string): Promise<ColumnInfo[]>;
|
|
14
|
+
getForeignKeys(table: string): Promise<ForeignKeyInfo[]>;
|
|
15
|
+
listEnums(): Promise<EnumInfo[]>;
|
|
14
16
|
close(): Promise<void>;
|
|
15
17
|
}
|
|
16
18
|
export {};
|