@pikku/cli 0.12.85 → 0.12.88
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-CEv-kj3J.js → index-C3FPwdl7.js} +161 -147
- 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-client.gen.d.ts +1 -1
- package/dist/.pikku/cli/pikku-cli-client.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli-contracts-meta.gen.d.ts +1 -1
- package/dist/.pikku/cli/pikku-cli-contracts-meta.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli-contracts-meta.gen.json +4 -0
- 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-meta.gen.json +4 -0
- 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 +41 -17
- package/dist/.pikku/function/pikku-functions.gen.js +3 -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/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 +3 -1
- package/dist/.pikku/pikku-bootstrap.gen.js +3 -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 +2 -1
- package/dist/.pikku/pikku-services.gen.js +1 -0
- 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.d.ts +1 -0
- package/dist/.pikku/queue/pikku-queue-workers-wirings-meta.gen.js +6 -0
- package/dist/.pikku/queue/pikku-queue-workers-wirings-meta.gen.json +6 -0
- package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.d.ts +4 -0
- package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.js +5 -0
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.js +1 -1
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.json +1 -0
- 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 +3 -1
- package/dist/.pikku/schemas/schemas/FabricLoginInput.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuCLIConfig.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuUserAdminFunctionsOutput.schema.json +1 -0
- package/dist/.pikku/scopes/pikku-scope-types.gen.d.ts +1 -1
- package/dist/.pikku/scopes/pikku-scope-types.gen.js +1 -1
- package/dist/.pikku/scopes/pikku-scopes.gen.d.ts +1 -1
- 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/meta/allWorkflow.gen.json +8 -2
- 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/bin/pikku.js +22 -0
- package/dist/src/fabric/fabric-commands.d.ts +6 -3
- package/dist/src/fabric/fabric-commands.js +4 -0
- package/dist/src/fabric/functions/deploy.function.js +6 -0
- package/dist/src/fabric/functions/init.function.js +2 -2
- package/dist/src/fabric/functions/llm-key.function.d.ts +4 -4
- package/dist/src/fabric/functions/login.function.d.ts +4 -0
- package/dist/src/fabric/functions/login.function.js +45 -4
- package/dist/src/fabric/functions/validate.function.js +12 -2
- package/dist/src/fabric/lib/config.d.ts +8 -0
- package/dist/src/fabric/lib/config.js +15 -1
- package/dist/src/fabric/lib/git.js +2 -2
- package/dist/src/functions/wirings/ai-agent/pikku-command-public-agent.js +6 -2
- package/dist/src/functions/wirings/ai-agent/serialize-public-agent.d.ts +5 -1
- package/dist/src/functions/wirings/ai-agent/serialize-public-agent.js +81 -48
- package/dist/src/functions/wirings/auth/pikku-command-auth.js +4 -0
- package/dist/src/functions/wirings/console/pikku-command-console-functions.js +6 -2
- package/dist/src/functions/wirings/console/serialize-console-functions.d.ts +5 -1
- package/dist/src/functions/wirings/console/serialize-console-functions.js +55 -23
- package/dist/src/functions/wirings/functions/schemas.js +10 -1
- package/dist/src/functions/wirings/graph/pikku-command-graph-wirings.js +2 -0
- package/dist/src/functions/wirings/queue/pikku-command-queue.js +10 -2
- package/dist/src/functions/wirings/realtime/pikku-command-events-scaffold.js +8 -2
- package/dist/src/functions/wirings/realtime/serialize-events-scaffold.d.ts +5 -4
- package/dist/src/functions/wirings/realtime/serialize-events-scaffold.js +17 -7
- package/dist/src/functions/wirings/rpc/pikku-command-public-rpc.js +6 -2
- package/dist/src/functions/wirings/rpc/pikku-command-remote-rpc.js +6 -2
- package/dist/src/functions/wirings/rpc/serialize-public-rpc.d.ts +5 -1
- package/dist/src/functions/wirings/rpc/serialize-public-rpc.js +16 -5
- package/dist/src/functions/wirings/rpc/serialize-remote-rpc.d.ts +5 -1
- package/dist/src/functions/wirings/rpc/serialize-remote-rpc.js +16 -5
- package/dist/src/functions/wirings/scenarios/pikku-command-scenario-functions.js +8 -2
- package/dist/src/functions/wirings/scenarios/serialize-scenario-functions.d.ts +5 -1
- package/dist/src/functions/wirings/scenarios/serialize-scenario-functions.js +22 -16
- package/dist/src/functions/wirings/user-admin/pikku-command-user-admin-functions.d.ts +1 -0
- package/dist/src/functions/wirings/user-admin/pikku-command-user-admin-functions.js +49 -0
- package/dist/src/functions/wirings/user-admin/serialize-user-admin-functions.d.ts +24 -0
- package/dist/src/functions/wirings/user-admin/serialize-user-admin-functions.js +283 -0
- package/dist/src/functions/wirings/webhook/pikku-command-webhook.js +6 -2
- package/dist/src/functions/wirings/webhook/serialize-webhook.d.ts +5 -8
- package/dist/src/functions/wirings/webhook/serialize-webhook.js +19 -12
- package/dist/src/functions/wirings/workflow/pikku-command-workflow-routes.js +8 -2
- package/dist/src/functions/wirings/workflow/serialize-workflow-routes.d.ts +5 -1
- package/dist/src/functions/wirings/workflow/serialize-workflow-routes.js +61 -31
- package/dist/src/functions/workflows/all.workflow.js +8 -0
- package/dist/src/utils/pikku-cli-config.js +40 -10
- package/dist/src/utils/remove-legacy-scaffold-file.d.ts +3 -0
- package/dist/src/utils/remove-legacy-scaffold-file.js +43 -0
- package/dist/src/utils/serialize-schemas.js +57 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/skills/pikku-addon/SKILL.md +1 -0
- package/skills/pikku-ai-agent/SKILL.md +2 -1
- package/skills/pikku-ai-vercel/SKILL.md +1 -0
- package/skills/pikku-better-auth/SKILL.md +57 -0
- package/skills/pikku-concepts/SKILL.md +17 -1
- package/skills/pikku-concepts/references/concept-mapping.md +11 -9
- package/skills/pikku-emails/SKILL.md +1 -0
- package/skills/pikku-fabric/SKILL.md +92 -19
- package/skills/pikku-fabric-debug/SKILL.md +112 -0
- package/skills/pikku-permissions/SKILL.md +28 -12
- package/skills/pikku-react/SKILL.md +32 -3
- package/skills/pikku-react-query/SKILL.md +38 -1
- package/skills/pikku-realtime/SKILL.md +1 -1
- package/skills/pikku-security/SKILL.md +3 -3
- package/skills/pikku-template-clone/SKILL.md +1 -0
- package/cli.schema.json +0 -1
|
@@ -210,31 +210,58 @@ const _getPikkuCLIConfig = async (logger, configFile = undefined, requiredFields
|
|
|
210
210
|
? scaffoldDir
|
|
211
211
|
: join(result.rootDir, scaffoldDir);
|
|
212
212
|
if (result.scaffold?.remoteRpc && !result.remoteRpcWorkersFile) {
|
|
213
|
-
result.remoteRpcWorkersFile = join(resolvedScaffoldDir, 'rpc-remote.gen.ts');
|
|
213
|
+
result.remoteRpcWorkersFile = join(resolvedScaffoldDir, 'rpc', 'rpc-remote.gen.ts');
|
|
214
|
+
}
|
|
215
|
+
if (result.scaffold?.remoteRpc && !result.remoteRpcSchemasFile) {
|
|
216
|
+
result.remoteRpcSchemasFile = join(resolvedScaffoldDir, 'rpc', 'rpc-remote.schemas.gen.ts');
|
|
214
217
|
}
|
|
215
218
|
if (result.scaffold?.graph && !result.graphWiringsFile) {
|
|
216
|
-
result.graphWiringsFile = join(resolvedScaffoldDir, 'graph.wirings.gen.ts');
|
|
219
|
+
result.graphWiringsFile = join(resolvedScaffoldDir, 'graph', 'graph.wirings.gen.ts');
|
|
217
220
|
}
|
|
218
221
|
if (result.scaffold?.webhook && !result.webhookWorkersFile) {
|
|
219
|
-
result.webhookWorkersFile = join(resolvedScaffoldDir, 'webhook.gen.ts');
|
|
222
|
+
result.webhookWorkersFile = join(resolvedScaffoldDir, 'webhook', 'webhook.gen.ts');
|
|
223
|
+
}
|
|
224
|
+
if (result.scaffold?.webhook && !result.webhookSchemasFile) {
|
|
225
|
+
result.webhookSchemasFile = join(resolvedScaffoldDir, 'webhook', 'webhook.schemas.gen.ts');
|
|
220
226
|
}
|
|
221
227
|
if (result.scaffold?.workflow && !result.workflowRoutesFile) {
|
|
222
|
-
result.workflowRoutesFile = join(resolvedScaffoldDir, 'workflow-routes.gen.ts');
|
|
228
|
+
result.workflowRoutesFile = join(resolvedScaffoldDir, 'workflow', 'workflow-routes.gen.ts');
|
|
229
|
+
}
|
|
230
|
+
if (result.scaffold?.workflow && !result.workflowRoutesSchemasFile) {
|
|
231
|
+
result.workflowRoutesSchemasFile = join(resolvedScaffoldDir, 'workflow', 'workflow-routes.schemas.gen.ts');
|
|
223
232
|
}
|
|
224
233
|
if (result.scaffold?.rpc && !result.publicRpcFile) {
|
|
225
|
-
result.publicRpcFile = join(resolvedScaffoldDir, 'rpc-public.gen.ts');
|
|
234
|
+
result.publicRpcFile = join(resolvedScaffoldDir, 'rpc', 'rpc-public.gen.ts');
|
|
235
|
+
}
|
|
236
|
+
if (result.scaffold?.rpc && !result.publicRpcSchemasFile) {
|
|
237
|
+
result.publicRpcSchemasFile = join(resolvedScaffoldDir, 'rpc', 'rpc-public.schemas.gen.ts');
|
|
226
238
|
}
|
|
227
239
|
if (result.scaffold?.agent && !result.publicAgentFile) {
|
|
228
|
-
result.publicAgentFile = join(resolvedScaffoldDir, 'agent.gen.ts');
|
|
240
|
+
result.publicAgentFile = join(resolvedScaffoldDir, 'agent', 'agent.gen.ts');
|
|
241
|
+
}
|
|
242
|
+
if (result.scaffold?.agent && !result.publicAgentSchemasFile) {
|
|
243
|
+
result.publicAgentSchemasFile = join(resolvedScaffoldDir, 'agent', 'agent.schemas.gen.ts');
|
|
229
244
|
}
|
|
230
245
|
if (result.scaffold?.console && !result.consoleFunctionsFile) {
|
|
231
|
-
result.consoleFunctionsFile = join(resolvedScaffoldDir, 'console.gen.ts');
|
|
246
|
+
result.consoleFunctionsFile = join(resolvedScaffoldDir, 'console', 'console.gen.ts');
|
|
247
|
+
}
|
|
248
|
+
if (result.scaffold?.console && !result.consoleSchemasFile) {
|
|
249
|
+
result.consoleSchemasFile = join(resolvedScaffoldDir, 'console', 'console.schemas.gen.ts');
|
|
250
|
+
}
|
|
251
|
+
if (result.scaffold?.userAdmin && !result.userAdminFunctionsFile) {
|
|
252
|
+
result.userAdminFunctionsFile = join(resolvedScaffoldDir, 'admin', 'user-admin.gen.ts');
|
|
253
|
+
}
|
|
254
|
+
if (result.scaffold?.userAdmin && !result.userAdminSchemasFile) {
|
|
255
|
+
result.userAdminSchemasFile = join(resolvedScaffoldDir, 'admin', 'user-admin.schemas.gen.ts');
|
|
232
256
|
}
|
|
233
257
|
if (result.scaffold?.scenarios && !result.scenariosFunctionsFile) {
|
|
234
|
-
result.scenariosFunctionsFile = join(resolvedScaffoldDir, 'scenarios.gen.ts');
|
|
258
|
+
result.scenariosFunctionsFile = join(resolvedScaffoldDir, 'scenarios', 'scenarios.gen.ts');
|
|
259
|
+
}
|
|
260
|
+
if (result.scaffold?.scenarios && !result.scenariosSchemasFile) {
|
|
261
|
+
result.scenariosSchemasFile = join(resolvedScaffoldDir, 'scenarios', 'scenarios.schemas.gen.ts');
|
|
235
262
|
}
|
|
236
263
|
if (!result.authFile) {
|
|
237
|
-
result.authFile = join(resolvedScaffoldDir, 'auth.gen.ts');
|
|
264
|
+
result.authFile = join(resolvedScaffoldDir, 'auth', 'auth.gen.ts');
|
|
238
265
|
}
|
|
239
266
|
if (!result.authTypesFile) {
|
|
240
267
|
result.authTypesFile = join(result.outDir, 'auth', 'auth.types.ts');
|
|
@@ -243,7 +270,10 @@ const _getPikkuCLIConfig = async (logger, configFile = undefined, requiredFields
|
|
|
243
270
|
result.authMetaJsonFile = join(result.outDir, 'auth', 'pikku-auth-meta.gen.json');
|
|
244
271
|
}
|
|
245
272
|
if (result.scaffold?.events && !result.eventsChannelFile) {
|
|
246
|
-
result.eventsChannelFile = join(resolvedScaffoldDir, 'events.gen.ts');
|
|
273
|
+
result.eventsChannelFile = join(resolvedScaffoldDir, 'realtime', 'events.gen.ts');
|
|
274
|
+
}
|
|
275
|
+
if (result.scaffold?.events && !result.eventsSchemasFile) {
|
|
276
|
+
result.eventsSchemasFile = join(resolvedScaffoldDir, 'realtime', 'events.schemas.gen.ts');
|
|
247
277
|
}
|
|
248
278
|
if (result.scaffold?.events &&
|
|
249
279
|
result.clientFiles?.fetchFile &&
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { rm } from 'node:fs/promises';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { basename, dirname, join } from 'node:path';
|
|
4
|
+
const scaffoldFiles = (config) => {
|
|
5
|
+
const authDir = config.authFile ? dirname(config.authFile) : undefined;
|
|
6
|
+
return [
|
|
7
|
+
config.graphWiringsFile,
|
|
8
|
+
config.webhookWorkersFile,
|
|
9
|
+
config.webhookSchemasFile,
|
|
10
|
+
config.workflowRoutesFile,
|
|
11
|
+
config.workflowRoutesSchemasFile,
|
|
12
|
+
config.publicRpcFile,
|
|
13
|
+
config.publicRpcSchemasFile,
|
|
14
|
+
config.remoteRpcWorkersFile,
|
|
15
|
+
config.remoteRpcSchemasFile,
|
|
16
|
+
config.publicAgentFile,
|
|
17
|
+
config.publicAgentSchemasFile,
|
|
18
|
+
config.consoleFunctionsFile,
|
|
19
|
+
config.consoleSchemasFile,
|
|
20
|
+
config.scenariosFunctionsFile,
|
|
21
|
+
config.scenariosSchemasFile,
|
|
22
|
+
config.userAdminFunctionsFile,
|
|
23
|
+
config.userAdminSchemasFile,
|
|
24
|
+
config.eventsChannelFile,
|
|
25
|
+
config.eventsSchemasFile,
|
|
26
|
+
config.authFile,
|
|
27
|
+
authDir ? join(authDir, 'auth-secrets.gen.ts') : undefined,
|
|
28
|
+
authDir ? join(authDir, 'auth-middleware.gen.ts') : undefined,
|
|
29
|
+
];
|
|
30
|
+
};
|
|
31
|
+
export const removeLegacyScaffoldFile = async (file) => {
|
|
32
|
+
const legacy = join(dirname(dirname(file)), basename(file));
|
|
33
|
+
if (legacy !== file && existsSync(legacy)) {
|
|
34
|
+
await rm(legacy, { force: true });
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
export const pruneLegacyScaffoldFiles = async (config) => {
|
|
38
|
+
for (const file of scaffoldFiles(config)) {
|
|
39
|
+
if (file) {
|
|
40
|
+
await removeLegacyScaffoldFile(file);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { writeFileInDir } from './file-writer.js';
|
|
2
|
-
import { mkdir, writeFile } from 'fs/promises';
|
|
2
|
+
import { mkdir, readdir, unlink, writeFile } from 'fs/promises';
|
|
3
|
+
const SCHEMA_FILE_SUFFIX = '.schema.json';
|
|
3
4
|
function toValidIdentifier(name) {
|
|
4
5
|
let result = name.replace(/[-./: ]/g, '_');
|
|
5
6
|
if (/^\d/.test(result)) {
|
|
@@ -7,9 +8,59 @@ function toValidIdentifier(name) {
|
|
|
7
8
|
}
|
|
8
9
|
return result;
|
|
9
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Delete `<schemaParentDir>/schemas/*.schema.json` for schemas this run did not
|
|
13
|
+
* generate.
|
|
14
|
+
*
|
|
15
|
+
* Codegen rewrites `register.gen.ts` from scratch every run, so a schema that is no
|
|
16
|
+
* longer required stops being registered — but its JSON file used to stay on disk
|
|
17
|
+
* forever. That orphan is not inert: it is the artifact everything reaches for when
|
|
18
|
+
* asking "what does the server validate against?", and it answers with the shape the
|
|
19
|
+
* function had at some earlier point. Tooling reading it concludes the schema is fine
|
|
20
|
+
* while the running server disagrees, which is a dead end that reads as "the server is
|
|
21
|
+
* stale" and cannot be resolved by regenerating or restarting.
|
|
22
|
+
*
|
|
23
|
+
* Keeping the directory in step with `register.gen.ts` is the whole fix: if it is not
|
|
24
|
+
* imported there, it must not be on disk to be misread.
|
|
25
|
+
*/
|
|
26
|
+
async function pruneOrphanedSchemaFiles(logger, schemaParentDir, keep) {
|
|
27
|
+
const dir = `${schemaParentDir}/schemas`;
|
|
28
|
+
let entries;
|
|
29
|
+
try {
|
|
30
|
+
entries = await readdir(dir);
|
|
31
|
+
}
|
|
32
|
+
catch (e) {
|
|
33
|
+
// No schemas dir yet (first run, or none were ever generated) — nothing to prune.
|
|
34
|
+
// Anything else (permissions, IO) means we do NOT know what is on disk, and
|
|
35
|
+
// reporting a clean generation over an unread directory is the exact false
|
|
36
|
+
// "everything is registered" claim this prune exists to stop.
|
|
37
|
+
if (e?.code === 'ENOENT') {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
throw e;
|
|
41
|
+
}
|
|
42
|
+
const orphans = entries.filter((entry) => entry.endsWith(SCHEMA_FILE_SUFFIX) &&
|
|
43
|
+
!keep.has(entry.slice(0, -SCHEMA_FILE_SUFFIX.length)));
|
|
44
|
+
await Promise.all(orphans.map(async (orphan) => {
|
|
45
|
+
try {
|
|
46
|
+
await unlink(`${dir}/${orphan}`);
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
// A file we cannot remove is stale output, not a reason to fail the build —
|
|
50
|
+
// but say so, because it will keep being read as if it were current.
|
|
51
|
+
logger.error(`• Could not remove stale schema ${orphan}: ${e}`);
|
|
52
|
+
}
|
|
53
|
+
}));
|
|
54
|
+
if (orphans.length > 0) {
|
|
55
|
+
logger.info(`• Removed ${orphans.length} stale schema file(s).\x1b[0m`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
10
58
|
export async function saveSchemas(logger, schemaParentDir, schemas, requiredSchemas, supportsImportAttributes, packageName) {
|
|
11
59
|
if (requiredSchemas.size === 0) {
|
|
12
60
|
await writeFileInDir(logger, `${schemaParentDir}/register.gen.ts`, 'export const empty = null;');
|
|
61
|
+
// Every file in schemas/ is now an orphan: register.gen.ts registers nothing, so
|
|
62
|
+
// leaving them would be exactly the misleading state this prune exists to prevent.
|
|
63
|
+
await pruneOrphanedSchemaFiles(logger, schemaParentDir, new Set());
|
|
13
64
|
logger.info(`• Skipping schemas since none found.\x1b[0m`);
|
|
14
65
|
return;
|
|
15
66
|
}
|
|
@@ -22,8 +73,12 @@ export async function saveSchemas(logger, schemaParentDir, schemas, requiredSche
|
|
|
22
73
|
// Sort so register.gen.ts is byte-identical across runs — requiredSchemas is
|
|
23
74
|
// a Set in (nondeterministic) traversal-insertion order.
|
|
24
75
|
const availableSchemas = Array.from(requiredSchemas)
|
|
25
|
-
|
|
76
|
+
// Presence, not truthiness: `false` is a legal JSON Schema (it rejects everything),
|
|
77
|
+
// and dropping it here would unregister the schema AND prune its file.
|
|
78
|
+
.filter((schema) => schemas[schema] !== undefined)
|
|
26
79
|
.sort();
|
|
80
|
+
// Keep exactly what register.gen.ts is about to import — the two must not disagree.
|
|
81
|
+
await pruneOrphanedSchemaFiles(logger, schemaParentDir, new Set(availableSchemas));
|
|
27
82
|
const packageNameArg = packageName ? `, '${packageName}'` : '';
|
|
28
83
|
const schemaImports = availableSchemas
|
|
29
84
|
.map((schema) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../bin/pikku.ts","../src/cli.wiring.ts","../src/services.ts","../src/deploy/build-pipeline.ts","../src/deploy/provider-adapter.ts","../src/deploy/server-entry.ts","../src/deploy/analyzer/analyzer.ts","../src/deploy/analyzer/index.ts","../src/deploy/analyzer/manifest.ts","../src/deploy/bundler/bun-bundler.ts","../src/deploy/bundler/bundler.interface.ts","../src/deploy/bundler/bundler.ts","../src/deploy/bundler/dep-extractor.ts","../src/deploy/bundler/index.ts","../src/deploy/bundler/node-bundler.ts","../src/deploy/bundler/types.ts","../src/deploy/codegen/index.ts","../src/deploy/codegen/per-unit-codegen.ts","../src/deploy/plan/executor.ts","../src/deploy/plan/formatter.ts","../src/deploy/plan/index.ts","../src/deploy/plan/planner.ts","../src/deploy/plan/provider.ts","../src/deploy/plan/types.ts","../src/fabric/fabric-commands.ts","../src/fabric/functions/add.function.ts","../src/fabric/functions/addon-verify.function.ts","../src/fabric/functions/db-schema.function.ts","../src/fabric/functions/deploy-list.function.ts","../src/fabric/functions/deploy-units.function.ts","../src/fabric/functions/deploy.function.ts","../src/fabric/functions/domains-add.function.ts","../src/fabric/functions/domains-list.function.ts","../src/fabric/functions/domains-remove.function.ts","../src/fabric/functions/errors.function.ts","../src/fabric/functions/init.function.ts","../src/fabric/functions/link.function.ts","../src/fabric/functions/llm-key.function.ts","../src/fabric/functions/login.function.ts","../src/fabric/functions/logs.function.ts","../src/fabric/functions/metrics.function.ts","../src/fabric/functions/publish.function.ts","../src/fabric/functions/rollback.function.ts","../src/fabric/functions/secrets-list.function.ts","../src/fabric/functions/secrets-set.function.ts","../src/fabric/functions/smoke.function.ts","../src/fabric/functions/status.function.ts","../src/fabric/functions/trace.function.ts","../src/fabric/functions/validate.function.ts","../src/fabric/lib/config.ts","../src/fabric/lib/console-url.ts","../src/fabric/lib/git.ts","../src/fabric/lib/http.ts","../src/fabric/lib/not-implemented.ts","../src/fabric/lib/output.ts","../src/fabric/lib/prompt.ts","../src/fabric/lib/stage.ts","../src/fabric/sdk/http-map.gen.d.ts","../src/fabric/sdk/pikku-fetch.gen.ts","../src/fabric/sdk/pikku-rpc.gen.ts","../src/fabric/sdk/rpc-map.gen.d.ts","../src/functions/commands/all.ts","../src/functions/commands/audit.ts","../src/functions/commands/binary.ts","../src/functions/commands/bootstrap.ts","../src/functions/commands/bun-coverage-loader.ts","../src/functions/commands/db-audit.ts","../src/functions/commands/db-generate.ts","../src/functions/commands/db-migrate.ts","../src/functions/commands/db-reset.ts","../src/functions/commands/db-seed.ts","../src/functions/commands/db-shared.ts","../src/functions/commands/deploy-apply.ts","../src/functions/commands/deploy-info.ts","../src/functions/commands/deploy-plan.ts","../src/functions/commands/dev-ai-runner.ts","../src/functions/commands/dev.ts","../src/functions/commands/emails-init.ts","../src/functions/commands/enable.ts","../src/functions/commands/import-n8n.ts","../src/functions/commands/info.ts","../src/functions/commands/load-user-project.ts","../src/functions/commands/login.ts","../src/functions/commands/meta.ts","../src/functions/commands/new-addon.ts","../src/functions/commands/new-function.ts","../src/functions/commands/new-middleware.ts","../src/functions/commands/new-permission.ts","../src/functions/commands/new-wiring.ts","../src/functions/commands/pikku-command-bootstrap.ts","../src/functions/commands/pikku-command-summary.ts","../src/functions/commands/scenario.ts","../src/functions/commands/scopes-audit.ts","../src/functions/commands/scopes-prune.ts","../src/functions/commands/scopes-shared.ts","../src/functions/commands/serve-console.ts","../src/functions/commands/serve.ts","../src/functions/commands/skills.ts","../src/functions/commands/start-coverage.ts","../src/functions/commands/versions-check.ts","../src/functions/commands/versions-init.ts","../src/functions/commands/versions-update.ts","../src/functions/commands/watch.ts","../src/functions/commands/workspace-validate.ts","../src/functions/db/annotation-parser.ts","../src/functions/db/better-auth-schema.ts","../src/functions/db/coercion-plugin.ts","../src/functions/db/db-codegen.ts","../src/functions/db/db-introspector.ts","../src/functions/db/db-migrator.ts","../src/functions/db/local-db.ts","../src/functions/db/zod-codegen.ts","../src/functions/db/postgres/pglite-kysely.ts","../src/functions/db/postgres/postgres-introspector.ts","../src/functions/db/postgres/postgres-migrator.ts","../src/functions/db/sqlite/seed.ts","../src/functions/db/sqlite/sqlite-introspector.ts","../src/functions/db/sqlite/sqlite-kysely.ts","../src/functions/db/sqlite/sqlite-migrator.ts","../src/functions/db/sqlite/sqlite-runtime-bun.ts","../src/functions/db/sqlite/sqlite-runtime-node.ts","../src/functions/db/sqlite/sqlite-runtime.ts","../src/functions/runtimes/fetch/index.ts","../src/functions/runtimes/nextjs/pikku-command-nextjs.ts","../src/functions/runtimes/nextjs/serialize-nextjs-backend-worker-rpc-wrapper.ts","../src/functions/runtimes/nextjs/serialize-nextjs-backend-wrapper.ts","../src/functions/runtimes/nextjs/serialize-nextjs-http-wrapper.ts","../src/functions/runtimes/tanstack-start/pikku-command-tanstack-start.ts","../src/functions/runtimes/tanstack-start/serialize-tanstack-start-shim.ts","../src/functions/runtimes/websocket/pikku-command-websocket-typed.ts","../src/functions/runtimes/websocket/serialize-websocket-wrapper.ts","../src/functions/validate/workspace-validate.ts","../src/functions/wirings/ai-agent/pikku-command-ai-agent-types.ts","../src/functions/wirings/ai-agent/pikku-command-ai-agent.ts","../src/functions/wirings/ai-agent/pikku-command-public-agent.ts","../src/functions/wirings/ai-agent/serialize-agent-map.ts","../src/functions/wirings/ai-agent/serialize-ai-agent-types.ts","../src/functions/wirings/ai-agent/serialize-public-agent.ts","../src/functions/wirings/auth/pikku-command-auth.ts","../src/functions/wirings/auth/serialize-auth-gen.ts","../src/functions/wirings/auth/serialize-auth-meta.ts","../src/functions/wirings/auth/serialize-auth-types.ts","../src/functions/wirings/channels/pikku-channels.ts","../src/functions/wirings/channels/pikku-command-channel-types.ts","../src/functions/wirings/channels/pikku-command-channels-map.ts","../src/functions/wirings/channels/pikku-command-channels.ts","../src/functions/wirings/channels/serialize-channel-types.ts","../src/functions/wirings/channels/serialize-typed-channel-map.ts","../src/functions/wirings/cli/pikku-command-cli-entry.ts","../src/functions/wirings/cli/pikku-command-cli-types.ts","../src/functions/wirings/cli/pikku-command-cli.ts","../src/functions/wirings/cli/serialize-channel-cli-client.ts","../src/functions/wirings/cli/serialize-channel-cli.ts","../src/functions/wirings/cli/serialize-cli-types.ts","../src/functions/wirings/cli/serialize-local-cli-bootstrap.ts","../src/functions/wirings/console/pikku-command-console-functions.ts","../src/functions/wirings/console/pikku-command-node-types.ts","../src/functions/wirings/console/pikku-command-nodes-meta.ts","../src/functions/wirings/console/serialize-console-functions.ts","../src/functions/wirings/console/serialize-node-types.ts","../src/functions/wirings/credentials/pikku-command-credentials.ts","../src/functions/wirings/credentials/serialize-credentials-types.ts","../src/functions/wirings/emails/pikku-command-emails.ts","../src/functions/wirings/emails/serialize-emails.ts","../src/functions/wirings/functions/pikku-command-addon-types.ts","../src/functions/wirings/functions/pikku-command-function-types-split.ts","../src/functions/wirings/functions/pikku-command-function-types.ts","../src/functions/wirings/functions/pikku-command-functions.ts","../src/functions/wirings/functions/pikku-command-services.ts","../src/functions/wirings/functions/schemas.ts","../src/functions/wirings/functions/serialize-addon-refs.ts","../src/functions/wirings/functions/serialize-addon-types.ts","../src/functions/wirings/functions/serialize-function-imports.ts","../src/functions/wirings/functions/serialize-function-types.ts","../src/functions/wirings/functions/serialize-pikku-types-hub.ts","../src/functions/wirings/gateway/pikku-command-gateway.ts","../src/functions/wirings/gateway/serialize-gateway-meta.ts","../src/functions/wirings/graph/pikku-command-graph-wirings.ts","../src/functions/wirings/graph/serialize-graph-wirings.ts","../src/functions/wirings/http/pikku-command-http-map.ts","../src/functions/wirings/http/pikku-command-http-routes.ts","../src/functions/wirings/http/pikku-command-http-types.ts","../src/functions/wirings/http/pikku-command-openapi.ts","../src/functions/wirings/http/pikku-http-routes.ts","../src/functions/wirings/http/serialize-fetch-wrapper.ts","../src/functions/wirings/http/serialize-http-types.ts","../src/functions/wirings/http/serialize-typed-http-map.ts","../src/functions/wirings/mcp/pikku-command-mcp-json.ts","../src/functions/wirings/mcp/pikku-command-mcp-types.ts","../src/functions/wirings/mcp/pikku-command-mcp.ts","../src/functions/wirings/mcp/serialize-mcp-types.ts","../src/functions/wirings/middleware/pikku-command-middleware.ts","../src/functions/wirings/middleware/serialize-middleware-imports.ts","../src/functions/wirings/package/pikku-command-package-types.ts","../src/functions/wirings/package/pikku-command-package.ts","../src/functions/wirings/package/serialize-package-types.ts","../src/functions/wirings/package/serialize-package.ts","../src/functions/wirings/permissions/pikku-command-permissions.ts","../src/functions/wirings/permissions/serialize-permissions-imports.ts","../src/functions/wirings/queue/pikku-command-queue-map.ts","../src/functions/wirings/queue/pikku-command-queue-service.ts","../src/functions/wirings/queue/pikku-command-queue-types.ts","../src/functions/wirings/queue/pikku-command-queue.ts","../src/functions/wirings/queue/pikku-queue-map.ts","../src/functions/wirings/queue/pikku-queue.ts","../src/functions/wirings/queue/serialize-queue-map.ts","../src/functions/wirings/queue/serialize-queue-meta.ts","../src/functions/wirings/queue/serialize-queue-types.ts","../src/functions/wirings/queue/serialize-queue-wrapper.ts","../src/functions/wirings/realtime/pikku-command-events-scaffold.ts","../src/functions/wirings/realtime/pikku-command-realtime.ts","../src/functions/wirings/realtime/serialize-events-scaffold.ts","../src/functions/wirings/realtime/serialize-realtime-client.ts","../src/functions/wirings/rpc/pikku-command-public-rpc.ts","../src/functions/wirings/rpc/pikku-command-react-query.ts","../src/functions/wirings/rpc/pikku-command-remote-rpc.ts","../src/functions/wirings/rpc/pikku-command-rpc-client.ts","../src/functions/wirings/rpc/pikku-command-rpc-map.ts","../src/functions/wirings/rpc/pikku-command-rpc.ts","../src/functions/wirings/rpc/serialize-public-rpc.ts","../src/functions/wirings/rpc/serialize-react-query-hooks.ts","../src/functions/wirings/rpc/serialize-remote-rpc.ts","../src/functions/wirings/rpc/serialize-rpc-wrapper.ts","../src/functions/wirings/rpc/serialize-typed-rpc-map.ts","../src/functions/wirings/scenarios/pikku-command-scenario-functions.ts","../src/functions/wirings/scenarios/serialize-scenario-functions.ts","../src/functions/wirings/scheduler/pikku-command-scheduler-types.ts","../src/functions/wirings/scheduler/pikku-command-scheduler.ts","../src/functions/wirings/scheduler/serialize-scheduler-meta.ts","../src/functions/wirings/scheduler/serialize-scheduler-types.ts","../src/functions/wirings/scopes/pikku-command-scopes.ts","../src/functions/wirings/scopes/serialize-scopes-types.ts","../src/functions/wirings/secrets/pikku-command-secrets.ts","../src/functions/wirings/secrets/serialize-secrets-types.ts","../src/functions/wirings/triggers/pikku-command-trigger-types.ts","../src/functions/wirings/triggers/pikku-command-trigger.ts","../src/functions/wirings/triggers/serialize-trigger-meta.ts","../src/functions/wirings/triggers/serialize-trigger-types.ts","../src/functions/wirings/variables/pikku-command-variables.ts","../src/functions/wirings/variables/serialize-variables-types.ts","../src/functions/wirings/webhook/pikku-command-webhook.ts","../src/functions/wirings/webhook/serialize-webhook.ts","../src/functions/wirings/workflow/pikku-command-workflow-routes.ts","../src/functions/wirings/workflow/pikku-command-workflow.ts","../src/functions/wirings/workflow/serialize-scenario-actors.ts","../src/functions/wirings/workflow/serialize-workflow-bootstrap-map.ts","../src/functions/wirings/workflow/serialize-workflow-map.ts","../src/functions/wirings/workflow/serialize-workflow-meta.ts","../src/functions/wirings/workflow/serialize-workflow-registration.ts","../src/functions/wirings/workflow/serialize-workflow-routes.ts","../src/functions/wirings/workflow/serialize-workflow-types.ts","../src/functions/workflows/all.workflow.ts","../src/middleware/log-command-info-and-time.ts","../src/server/bun-server-runner.ts","../src/server/dev-server-runner.interface.ts","../src/server/node-server-runner.ts","../src/services/cli-logger-forwarder.service.ts","../src/services/cli-logger.service.ts","../src/utils/assert-single-core-version.ts","../src/utils/check-required-types.ts","../src/utils/cli-session.ts","../src/utils/command-summary.ts","../src/utils/contract-versions.ts","../src/utils/detect-better-auth.ts","../src/utils/device-auth.ts","../src/utils/file-import-path.ts","../src/utils/file-imports-serializer.ts","../src/utils/file-writer.ts","../src/utils/generate-bootstrap-file.ts","../src/utils/get-cli-version.ts","../src/utils/meta-diff.ts","../src/utils/parse-cli-filters.ts","../src/utils/pikku-cli-config.ts","../src/utils/pikku-files-and-methods.ts","../src/utils/precise-coverage-map.ts","../src/utils/serialize-import-map.ts","../src/utils/serialize-meta-ts.ts","../src/utils/serialize-schemas.ts","../src/utils/strip-verbose-meta.ts","../src/utils/tsc-check.ts","../.pikku/pikku-bootstrap.gen.ts","../.pikku/pikku-meta-service.gen.ts","../.pikku/pikku-services.gen.ts","../.pikku/pikku-types.gen.ts","../.pikku/agent/pikku-agent-map.gen.d.ts","../.pikku/agent/pikku-agent-types.gen.ts","../.pikku/auth/auth.types.ts","../.pikku/channel/pikku-channel-types.gen.ts","../.pikku/cli/pikku-cli-channel.ts","../.pikku/cli/pikku-cli-client.gen.ts","../.pikku/cli/pikku-cli-contracts-meta.gen.ts","../.pikku/cli/pikku-cli-types.gen.ts","../.pikku/cli/pikku-cli-wirings-meta.gen.ts","../.pikku/cli/pikku-cli-wirings.gen.ts","../.pikku/cli/pikku-cli.gen.ts","../.pikku/console/pikku-node-types.gen.ts","../.pikku/function/pikku-function-types.gen.ts","../.pikku/function/pikku-functions-meta.gen.ts","../.pikku/function/pikku-functions.gen.ts","../.pikku/http/pikku-http-types.gen.ts","../.pikku/mcp/pikku-mcp-types.gen.ts","../.pikku/node/pikku-node-types.gen.ts","../.pikku/queue/pikku-queue-types.gen.ts","../.pikku/rpc/pikku-rpc-wirings-map.gen.d.ts","../.pikku/rpc/pikku-rpc-wirings-map.internal.gen.d.ts","../.pikku/rpc/pikku-rpc-wirings-map.remote.gen.d.ts","../.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.ts","../.pikku/scheduler/pikku-scheduler-types.gen.ts","../.pikku/schemas/register.gen.ts","../.pikku/scopes/pikku-scope-types.gen.ts","../.pikku/scopes/pikku-scopes.gen.ts","../.pikku/secrets/pikku-secret-types.gen.ts","../.pikku/secrets/pikku-secrets.gen.ts","../.pikku/trigger/pikku-trigger-types.gen.ts","../.pikku/variables/pikku-variable-types.gen.ts","../.pikku/variables/pikku-variables.gen.ts","../.pikku/workflow/pikku-workflow-map.gen.d.ts","../.pikku/workflow/pikku-workflow-types.gen.ts","../.pikku/workflow/pikku-workflow-wirings-meta.gen.ts","../.pikku/workflow/pikku-workflow-wirings.gen.ts","../types/application-types.d.ts","../types/bun-sqlite.d.ts","../types/config.d.ts"],"version":"6.0.3"}
|
|
1
|
+
{"root":["../bin/pikku.ts","../src/cli.wiring.ts","../src/services.ts","../src/deploy/build-pipeline.ts","../src/deploy/provider-adapter.ts","../src/deploy/server-entry.ts","../src/deploy/analyzer/analyzer.ts","../src/deploy/analyzer/index.ts","../src/deploy/analyzer/manifest.ts","../src/deploy/bundler/bun-bundler.ts","../src/deploy/bundler/bundler.interface.ts","../src/deploy/bundler/bundler.ts","../src/deploy/bundler/dep-extractor.ts","../src/deploy/bundler/index.ts","../src/deploy/bundler/node-bundler.ts","../src/deploy/bundler/types.ts","../src/deploy/codegen/index.ts","../src/deploy/codegen/per-unit-codegen.ts","../src/deploy/plan/executor.ts","../src/deploy/plan/formatter.ts","../src/deploy/plan/index.ts","../src/deploy/plan/planner.ts","../src/deploy/plan/provider.ts","../src/deploy/plan/types.ts","../src/fabric/fabric-commands.ts","../src/fabric/functions/add.function.ts","../src/fabric/functions/addon-verify.function.ts","../src/fabric/functions/db-schema.function.ts","../src/fabric/functions/deploy-list.function.ts","../src/fabric/functions/deploy-units.function.ts","../src/fabric/functions/deploy.function.ts","../src/fabric/functions/domains-add.function.ts","../src/fabric/functions/domains-list.function.ts","../src/fabric/functions/domains-remove.function.ts","../src/fabric/functions/errors.function.ts","../src/fabric/functions/init.function.ts","../src/fabric/functions/link.function.ts","../src/fabric/functions/llm-key.function.ts","../src/fabric/functions/login.function.ts","../src/fabric/functions/logs.function.ts","../src/fabric/functions/metrics.function.ts","../src/fabric/functions/publish.function.ts","../src/fabric/functions/rollback.function.ts","../src/fabric/functions/secrets-list.function.ts","../src/fabric/functions/secrets-set.function.ts","../src/fabric/functions/smoke.function.ts","../src/fabric/functions/status.function.ts","../src/fabric/functions/trace.function.ts","../src/fabric/functions/validate.function.ts","../src/fabric/lib/config.ts","../src/fabric/lib/console-url.ts","../src/fabric/lib/git.ts","../src/fabric/lib/http.ts","../src/fabric/lib/not-implemented.ts","../src/fabric/lib/output.ts","../src/fabric/lib/prompt.ts","../src/fabric/lib/stage.ts","../src/fabric/sdk/http-map.gen.d.ts","../src/fabric/sdk/pikku-fetch.gen.ts","../src/fabric/sdk/pikku-rpc.gen.ts","../src/fabric/sdk/rpc-map.gen.d.ts","../src/functions/commands/all.ts","../src/functions/commands/audit.ts","../src/functions/commands/binary.ts","../src/functions/commands/bootstrap.ts","../src/functions/commands/bun-coverage-loader.ts","../src/functions/commands/db-audit.ts","../src/functions/commands/db-generate.ts","../src/functions/commands/db-migrate.ts","../src/functions/commands/db-reset.ts","../src/functions/commands/db-seed.ts","../src/functions/commands/db-shared.ts","../src/functions/commands/deploy-apply.ts","../src/functions/commands/deploy-info.ts","../src/functions/commands/deploy-plan.ts","../src/functions/commands/dev-ai-runner.ts","../src/functions/commands/dev.ts","../src/functions/commands/emails-init.ts","../src/functions/commands/enable.ts","../src/functions/commands/import-n8n.ts","../src/functions/commands/info.ts","../src/functions/commands/load-user-project.ts","../src/functions/commands/login.ts","../src/functions/commands/meta.ts","../src/functions/commands/new-addon.ts","../src/functions/commands/new-function.ts","../src/functions/commands/new-middleware.ts","../src/functions/commands/new-permission.ts","../src/functions/commands/new-wiring.ts","../src/functions/commands/pikku-command-bootstrap.ts","../src/functions/commands/pikku-command-summary.ts","../src/functions/commands/scenario.ts","../src/functions/commands/scopes-audit.ts","../src/functions/commands/scopes-prune.ts","../src/functions/commands/scopes-shared.ts","../src/functions/commands/serve-console.ts","../src/functions/commands/serve.ts","../src/functions/commands/skills.ts","../src/functions/commands/start-coverage.ts","../src/functions/commands/versions-check.ts","../src/functions/commands/versions-init.ts","../src/functions/commands/versions-update.ts","../src/functions/commands/watch.ts","../src/functions/commands/workspace-validate.ts","../src/functions/db/annotation-parser.ts","../src/functions/db/better-auth-schema.ts","../src/functions/db/coercion-plugin.ts","../src/functions/db/db-codegen.ts","../src/functions/db/db-introspector.ts","../src/functions/db/db-migrator.ts","../src/functions/db/local-db.ts","../src/functions/db/zod-codegen.ts","../src/functions/db/postgres/pglite-kysely.ts","../src/functions/db/postgres/postgres-introspector.ts","../src/functions/db/postgres/postgres-migrator.ts","../src/functions/db/sqlite/seed.ts","../src/functions/db/sqlite/sqlite-introspector.ts","../src/functions/db/sqlite/sqlite-kysely.ts","../src/functions/db/sqlite/sqlite-migrator.ts","../src/functions/db/sqlite/sqlite-runtime-bun.ts","../src/functions/db/sqlite/sqlite-runtime-node.ts","../src/functions/db/sqlite/sqlite-runtime.ts","../src/functions/runtimes/fetch/index.ts","../src/functions/runtimes/nextjs/pikku-command-nextjs.ts","../src/functions/runtimes/nextjs/serialize-nextjs-backend-worker-rpc-wrapper.ts","../src/functions/runtimes/nextjs/serialize-nextjs-backend-wrapper.ts","../src/functions/runtimes/nextjs/serialize-nextjs-http-wrapper.ts","../src/functions/runtimes/tanstack-start/pikku-command-tanstack-start.ts","../src/functions/runtimes/tanstack-start/serialize-tanstack-start-shim.ts","../src/functions/runtimes/websocket/pikku-command-websocket-typed.ts","../src/functions/runtimes/websocket/serialize-websocket-wrapper.ts","../src/functions/validate/workspace-validate.ts","../src/functions/wirings/ai-agent/pikku-command-ai-agent-types.ts","../src/functions/wirings/ai-agent/pikku-command-ai-agent.ts","../src/functions/wirings/ai-agent/pikku-command-public-agent.ts","../src/functions/wirings/ai-agent/serialize-agent-map.ts","../src/functions/wirings/ai-agent/serialize-ai-agent-types.ts","../src/functions/wirings/ai-agent/serialize-public-agent.ts","../src/functions/wirings/auth/pikku-command-auth.ts","../src/functions/wirings/auth/serialize-auth-gen.ts","../src/functions/wirings/auth/serialize-auth-meta.ts","../src/functions/wirings/auth/serialize-auth-types.ts","../src/functions/wirings/channels/pikku-channels.ts","../src/functions/wirings/channels/pikku-command-channel-types.ts","../src/functions/wirings/channels/pikku-command-channels-map.ts","../src/functions/wirings/channels/pikku-command-channels.ts","../src/functions/wirings/channels/serialize-channel-types.ts","../src/functions/wirings/channels/serialize-typed-channel-map.ts","../src/functions/wirings/cli/pikku-command-cli-entry.ts","../src/functions/wirings/cli/pikku-command-cli-types.ts","../src/functions/wirings/cli/pikku-command-cli.ts","../src/functions/wirings/cli/serialize-channel-cli-client.ts","../src/functions/wirings/cli/serialize-channel-cli.ts","../src/functions/wirings/cli/serialize-cli-types.ts","../src/functions/wirings/cli/serialize-local-cli-bootstrap.ts","../src/functions/wirings/console/pikku-command-console-functions.ts","../src/functions/wirings/console/pikku-command-node-types.ts","../src/functions/wirings/console/pikku-command-nodes-meta.ts","../src/functions/wirings/console/serialize-console-functions.ts","../src/functions/wirings/console/serialize-node-types.ts","../src/functions/wirings/credentials/pikku-command-credentials.ts","../src/functions/wirings/credentials/serialize-credentials-types.ts","../src/functions/wirings/emails/pikku-command-emails.ts","../src/functions/wirings/emails/serialize-emails.ts","../src/functions/wirings/functions/pikku-command-addon-types.ts","../src/functions/wirings/functions/pikku-command-function-types-split.ts","../src/functions/wirings/functions/pikku-command-function-types.ts","../src/functions/wirings/functions/pikku-command-functions.ts","../src/functions/wirings/functions/pikku-command-services.ts","../src/functions/wirings/functions/schemas.ts","../src/functions/wirings/functions/serialize-addon-refs.ts","../src/functions/wirings/functions/serialize-addon-types.ts","../src/functions/wirings/functions/serialize-function-imports.ts","../src/functions/wirings/functions/serialize-function-types.ts","../src/functions/wirings/functions/serialize-pikku-types-hub.ts","../src/functions/wirings/gateway/pikku-command-gateway.ts","../src/functions/wirings/gateway/serialize-gateway-meta.ts","../src/functions/wirings/graph/pikku-command-graph-wirings.ts","../src/functions/wirings/graph/serialize-graph-wirings.ts","../src/functions/wirings/http/pikku-command-http-map.ts","../src/functions/wirings/http/pikku-command-http-routes.ts","../src/functions/wirings/http/pikku-command-http-types.ts","../src/functions/wirings/http/pikku-command-openapi.ts","../src/functions/wirings/http/pikku-http-routes.ts","../src/functions/wirings/http/serialize-fetch-wrapper.ts","../src/functions/wirings/http/serialize-http-types.ts","../src/functions/wirings/http/serialize-typed-http-map.ts","../src/functions/wirings/mcp/pikku-command-mcp-json.ts","../src/functions/wirings/mcp/pikku-command-mcp-types.ts","../src/functions/wirings/mcp/pikku-command-mcp.ts","../src/functions/wirings/mcp/serialize-mcp-types.ts","../src/functions/wirings/middleware/pikku-command-middleware.ts","../src/functions/wirings/middleware/serialize-middleware-imports.ts","../src/functions/wirings/package/pikku-command-package-types.ts","../src/functions/wirings/package/pikku-command-package.ts","../src/functions/wirings/package/serialize-package-types.ts","../src/functions/wirings/package/serialize-package.ts","../src/functions/wirings/permissions/pikku-command-permissions.ts","../src/functions/wirings/permissions/serialize-permissions-imports.ts","../src/functions/wirings/queue/pikku-command-queue-map.ts","../src/functions/wirings/queue/pikku-command-queue-service.ts","../src/functions/wirings/queue/pikku-command-queue-types.ts","../src/functions/wirings/queue/pikku-command-queue.ts","../src/functions/wirings/queue/pikku-queue-map.ts","../src/functions/wirings/queue/pikku-queue.ts","../src/functions/wirings/queue/serialize-queue-map.ts","../src/functions/wirings/queue/serialize-queue-meta.ts","../src/functions/wirings/queue/serialize-queue-types.ts","../src/functions/wirings/queue/serialize-queue-wrapper.ts","../src/functions/wirings/realtime/pikku-command-events-scaffold.ts","../src/functions/wirings/realtime/pikku-command-realtime.ts","../src/functions/wirings/realtime/serialize-events-scaffold.ts","../src/functions/wirings/realtime/serialize-realtime-client.ts","../src/functions/wirings/rpc/pikku-command-public-rpc.ts","../src/functions/wirings/rpc/pikku-command-react-query.ts","../src/functions/wirings/rpc/pikku-command-remote-rpc.ts","../src/functions/wirings/rpc/pikku-command-rpc-client.ts","../src/functions/wirings/rpc/pikku-command-rpc-map.ts","../src/functions/wirings/rpc/pikku-command-rpc.ts","../src/functions/wirings/rpc/serialize-public-rpc.ts","../src/functions/wirings/rpc/serialize-react-query-hooks.ts","../src/functions/wirings/rpc/serialize-remote-rpc.ts","../src/functions/wirings/rpc/serialize-rpc-wrapper.ts","../src/functions/wirings/rpc/serialize-typed-rpc-map.ts","../src/functions/wirings/scenarios/pikku-command-scenario-functions.ts","../src/functions/wirings/scenarios/serialize-scenario-functions.ts","../src/functions/wirings/scheduler/pikku-command-scheduler-types.ts","../src/functions/wirings/scheduler/pikku-command-scheduler.ts","../src/functions/wirings/scheduler/serialize-scheduler-meta.ts","../src/functions/wirings/scheduler/serialize-scheduler-types.ts","../src/functions/wirings/scopes/pikku-command-scopes.ts","../src/functions/wirings/scopes/serialize-scopes-types.ts","../src/functions/wirings/secrets/pikku-command-secrets.ts","../src/functions/wirings/secrets/serialize-secrets-types.ts","../src/functions/wirings/triggers/pikku-command-trigger-types.ts","../src/functions/wirings/triggers/pikku-command-trigger.ts","../src/functions/wirings/triggers/serialize-trigger-meta.ts","../src/functions/wirings/triggers/serialize-trigger-types.ts","../src/functions/wirings/user-admin/pikku-command-user-admin-functions.ts","../src/functions/wirings/user-admin/serialize-user-admin-functions.ts","../src/functions/wirings/variables/pikku-command-variables.ts","../src/functions/wirings/variables/serialize-variables-types.ts","../src/functions/wirings/webhook/pikku-command-webhook.ts","../src/functions/wirings/webhook/serialize-webhook.ts","../src/functions/wirings/workflow/pikku-command-workflow-routes.ts","../src/functions/wirings/workflow/pikku-command-workflow.ts","../src/functions/wirings/workflow/serialize-scenario-actors.ts","../src/functions/wirings/workflow/serialize-workflow-bootstrap-map.ts","../src/functions/wirings/workflow/serialize-workflow-map.ts","../src/functions/wirings/workflow/serialize-workflow-meta.ts","../src/functions/wirings/workflow/serialize-workflow-registration.ts","../src/functions/wirings/workflow/serialize-workflow-routes.ts","../src/functions/wirings/workflow/serialize-workflow-types.ts","../src/functions/workflows/all.workflow.ts","../src/middleware/log-command-info-and-time.ts","../src/server/bun-server-runner.ts","../src/server/dev-server-runner.interface.ts","../src/server/node-server-runner.ts","../src/services/cli-logger-forwarder.service.ts","../src/services/cli-logger.service.ts","../src/utils/assert-single-core-version.ts","../src/utils/check-required-types.ts","../src/utils/cli-session.ts","../src/utils/command-summary.ts","../src/utils/contract-versions.ts","../src/utils/detect-better-auth.ts","../src/utils/device-auth.ts","../src/utils/file-import-path.ts","../src/utils/file-imports-serializer.ts","../src/utils/file-writer.ts","../src/utils/generate-bootstrap-file.ts","../src/utils/get-cli-version.ts","../src/utils/meta-diff.ts","../src/utils/parse-cli-filters.ts","../src/utils/pikku-cli-config.ts","../src/utils/pikku-files-and-methods.ts","../src/utils/precise-coverage-map.ts","../src/utils/remove-legacy-scaffold-file.ts","../src/utils/serialize-import-map.ts","../src/utils/serialize-meta-ts.ts","../src/utils/serialize-schemas.ts","../src/utils/strip-verbose-meta.ts","../src/utils/tsc-check.ts","../.pikku/pikku-bootstrap.gen.ts","../.pikku/pikku-meta-service.gen.ts","../.pikku/pikku-services.gen.ts","../.pikku/pikku-types.gen.ts","../.pikku/agent/pikku-agent-map.gen.d.ts","../.pikku/agent/pikku-agent-types.gen.ts","../.pikku/auth/auth.types.ts","../.pikku/channel/pikku-channel-types.gen.ts","../.pikku/cli/pikku-cli-channel.ts","../.pikku/cli/pikku-cli-client.gen.ts","../.pikku/cli/pikku-cli-contracts-meta.gen.ts","../.pikku/cli/pikku-cli-types.gen.ts","../.pikku/cli/pikku-cli-wirings-meta.gen.ts","../.pikku/cli/pikku-cli-wirings.gen.ts","../.pikku/cli/pikku-cli.gen.ts","../.pikku/console/pikku-node-types.gen.ts","../.pikku/function/pikku-function-types.gen.ts","../.pikku/function/pikku-functions-meta.gen.ts","../.pikku/function/pikku-functions.gen.ts","../.pikku/http/pikku-http-types.gen.ts","../.pikku/mcp/pikku-mcp-types.gen.ts","../.pikku/node/pikku-node-types.gen.ts","../.pikku/queue/pikku-queue-types.gen.ts","../.pikku/queue/pikku-queue-workers-wirings-map.gen.d.ts","../.pikku/queue/pikku-queue-workers-wirings-meta.gen.ts","../.pikku/queue/pikku-queue-workers-wirings.gen.ts","../.pikku/rpc/pikku-rpc-wirings-map.gen.d.ts","../.pikku/rpc/pikku-rpc-wirings-map.internal.gen.d.ts","../.pikku/rpc/pikku-rpc-wirings-map.remote.gen.d.ts","../.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.ts","../.pikku/scheduler/pikku-scheduler-types.gen.ts","../.pikku/schemas/register.gen.ts","../.pikku/scopes/pikku-scope-types.gen.ts","../.pikku/scopes/pikku-scopes.gen.ts","../.pikku/secrets/pikku-secret-types.gen.ts","../.pikku/secrets/pikku-secrets.gen.ts","../.pikku/trigger/pikku-trigger-types.gen.ts","../.pikku/variables/pikku-variable-types.gen.ts","../.pikku/variables/pikku-variables.gen.ts","../.pikku/workflow/pikku-workflow-map.gen.d.ts","../.pikku/workflow/pikku-workflow-types.gen.ts","../.pikku/workflow/pikku-workflow-wirings-meta.gen.ts","../.pikku/workflow/pikku-workflow-wirings.gen.ts","../types/application-types.d.ts","../types/bun-sqlite.d.ts","../types/config.d.ts"],"version":"6.0.3"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pikku/cli",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.88",
|
|
4
4
|
"author": "yasser.fadl@gmail.com",
|
|
5
5
|
"license": "BUSL-1.1",
|
|
6
6
|
"imports": {
|
|
@@ -28,14 +28,14 @@
|
|
|
28
28
|
"@electric-sql/pglite": "^0.5.1",
|
|
29
29
|
"@jridgewell/trace-mapping": "^0.3.25",
|
|
30
30
|
"@openapi-contrib/json-schema-to-openapi-schema": "^4.3.1",
|
|
31
|
-
"@pikku/better-auth": "^0.12.
|
|
31
|
+
"@pikku/better-auth": "^0.12.19",
|
|
32
32
|
"@pikku/bun-server": "^0.12.4",
|
|
33
33
|
"@pikku/deploy-cloudflare": "^0.12.8",
|
|
34
34
|
"@pikku/fetch": "^0.12.8",
|
|
35
|
-
"@pikku/inspector": "^0.12.
|
|
36
|
-
"@pikku/kysely": "^0.13.
|
|
35
|
+
"@pikku/inspector": "^0.12.46",
|
|
36
|
+
"@pikku/kysely": "^0.13.3",
|
|
37
37
|
"@pikku/kysely-node-sqlite": "^0.12.3",
|
|
38
|
-
"@pikku/n8n-import": "^0.0.
|
|
38
|
+
"@pikku/n8n-import": "^0.0.3",
|
|
39
39
|
"@pikku/node-http-server": "^0.12.6",
|
|
40
40
|
"@pikku/openapi-parser": "^0.12.16",
|
|
41
41
|
"@pikku/schedule": "^0.12.4",
|
|
@@ -60,10 +60,10 @@
|
|
|
60
60
|
"zod-to-ts": "^2.1.0"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
|
-
"@pikku/core": "^0.12.
|
|
63
|
+
"@pikku/core": "^0.12.69"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@pikku/core": "^0.12.
|
|
66
|
+
"@pikku/core": "^0.12.69",
|
|
67
67
|
"@types/istanbul-lib-instrument": "^1.7.7",
|
|
68
68
|
"@types/node": "^24.11.0",
|
|
69
69
|
"@types/pg": "^8.11.0",
|
|
@@ -7,6 +7,7 @@ description: >-
|
|
|
7
7
|
addons, reusable function packages, cross-project sharing, or addon package structure. DO NOT
|
|
8
8
|
TRIGGER when: user asks about internal function composition (use pikku-rpc) or general function
|
|
9
9
|
definitions (use pikku-concepts).
|
|
10
|
+
installGroups: [core]
|
|
10
11
|
---
|
|
11
12
|
|
|
12
13
|
# Pikku Addons
|
|
@@ -6,6 +6,7 @@ description: >-
|
|
|
6
6
|
uses pikkuAIAgent/runAIAgent/streamAIAgent, user asks about AI agents, chatbots, LLM assistants,
|
|
7
7
|
tool-calling agents, or agent memory/streaming. DO NOT TRIGGER when: user asks about MCP tool
|
|
8
8
|
exposure (use pikku-mcp) or general function definitions (use pikku-concepts).
|
|
9
|
+
installGroups: [core]
|
|
9
10
|
---
|
|
10
11
|
|
|
11
12
|
# Pikku AI Agent Wiring
|
|
@@ -214,7 +215,7 @@ wireHTTP({
|
|
|
214
215
|
func: pikkuFunc({
|
|
215
216
|
title: 'Chat',
|
|
216
217
|
func: async (services, { message, threadId }, wire) => {
|
|
217
|
-
const session =
|
|
218
|
+
const { session } = wire
|
|
218
219
|
return await runAIAgent(
|
|
219
220
|
'todo-assistant',
|
|
220
221
|
{
|
|
@@ -6,6 +6,7 @@ description: >-
|
|
|
6
6
|
VercelAIAgentRunner, user asks about Vercel AI SDK integration, AI agent runners, or
|
|
7
7
|
@pikku/ai-vercel. DO NOT TRIGGER when: user asks about AI agent wiring (use pikku-ai-agent) or
|
|
8
8
|
voice I/O (use pikku-ai-voice).
|
|
9
|
+
installGroups: [core]
|
|
9
10
|
---
|
|
10
11
|
|
|
11
12
|
# Pikku AI Vercel (Agent Runner)
|
|
@@ -9,6 +9,7 @@ description: >-
|
|
|
9
9
|
user asks about ANY form of authentication, login, logout, sessions, or user identity — always
|
|
10
10
|
answer with this skill. DO NOT TRIGGER when: user asks about JWT middleware (use pikku-security)
|
|
11
11
|
or custom session services (use pikku-services).
|
|
12
|
+
installGroups: [core]
|
|
12
13
|
---
|
|
13
14
|
|
|
14
15
|
# Pikku Better Auth Integration
|
|
@@ -119,6 +120,62 @@ Enabling `session: { cookieCache: { enabled: true } }` makes the CLI split out a
|
|
|
119
120
|
|
|
120
121
|
In both cases a **route-scoped** registration (`addHTTPMiddleware('/some/path', [...])`) does NOT count — only a global one suppresses the generated default. The generated middleware in a `.gen.ts` file is also ignored by the detector, so regeneration never self-suppresses.
|
|
121
122
|
|
|
123
|
+
### Admin capabilities are scopes, not a role
|
|
124
|
+
|
|
125
|
+
Pikku does **not** use better-auth's `admin()` plugin, and nothing in this
|
|
126
|
+
package reads a `role` column. A role is not a permission: "who may impersonate"
|
|
127
|
+
and "who may rebind a shared credential" are different capabilities one user can
|
|
128
|
+
hold independently, which a single `role` string cannot express. Every gate the
|
|
129
|
+
package owns therefore resolves the caller's scopes through the registered
|
|
130
|
+
`ScopeService` and checks the `admin:*` tree:
|
|
131
|
+
|
|
132
|
+
| Gate | Scope required |
|
|
133
|
+
| --- | --- |
|
|
134
|
+
| `impersonation` (`betterAuthSession` / `betterAuthStatelessSession`) | `admin:impersonate` |
|
|
135
|
+
| `credentialOAuth`'s `canLinkSingleton` | `admin:credentials:link` |
|
|
136
|
+
| the console's user directory | `admin:users:list` |
|
|
137
|
+
|
|
138
|
+
Holding the bare `admin` scope satisfies all of them — a parent grant covers
|
|
139
|
+
everything nested beneath it — so `admin` is the direct replacement for the old
|
|
140
|
+
`role === 'admin'`.
|
|
141
|
+
|
|
142
|
+
Declare the tree in your own `wireScope` (the CLI extracts it by AST, so it must
|
|
143
|
+
be an inline literal; `ADMIN_SCOPE_TREE` is exported from `@pikku/better-auth`
|
|
144
|
+
as the reference shape). Apps wiring `@pikku/addon-console` inherit it already.
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
wireScope({
|
|
148
|
+
admin: {
|
|
149
|
+
displayName: 'Administration',
|
|
150
|
+
description: 'Capabilities that act on the application as a whole',
|
|
151
|
+
scopes: {
|
|
152
|
+
impersonate: { description: 'Act as another user' },
|
|
153
|
+
credentials: {
|
|
154
|
+
description: 'Application-wide credentials',
|
|
155
|
+
scopes: {
|
|
156
|
+
link: { description: 'Bind a shared credential for every user' },
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
users: {
|
|
160
|
+
description: 'The user directory',
|
|
161
|
+
scopes: { list: { description: 'List and search users' } },
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
})
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Then grant it — via a role (`scopeService.createRole({ name: 'admin', scopes: ['admin'] })` plus `addUserToRole`) or directly with `addScopeToUser`.
|
|
169
|
+
|
|
170
|
+
Every gate **fails closed**: with no `ScopeService` registered nothing can hold
|
|
171
|
+
a scope, so nothing is authorized, and the denial is logged at `warn` because
|
|
172
|
+
that is a configuration bug rather than a permissions decision. Pass your own
|
|
173
|
+
`canImpersonate` / `canLinkSingleton` to override the default entirely.
|
|
174
|
+
|
|
175
|
+
Sibling concerns — banning a user, listing users from your own screens — are
|
|
176
|
+
actions your app *invokes*, not things pikku gates. Put them on your own
|
|
177
|
+
functions with `scopes: ['admin:users:ban']` and friends.
|
|
178
|
+
|
|
122
179
|
### 2. Production database adapter
|
|
123
180
|
|
|
124
181
|
For real deployments swap `memoryAdapter` for the Kysely adapter backed by an injected DB. Better Auth owns its own tables (`user`, `session`, `account`, `verification`, plus plugin tables) — generate its schema with `npx @better-auth/cli generate` and apply it as a migration.
|
|
@@ -71,7 +71,7 @@ const updateTodo = pikkuFunc({
|
|
|
71
71
|
input: UpdateTodoInput,
|
|
72
72
|
output: TodoOutput,
|
|
73
73
|
func: async (services, data, wire) => {
|
|
74
|
-
const session =
|
|
74
|
+
const { session } = wire
|
|
75
75
|
return services.todoStore.update(data.id, data)
|
|
76
76
|
},
|
|
77
77
|
})
|
|
@@ -111,6 +111,22 @@ pikkuFunc({
|
|
|
111
111
|
})
|
|
112
112
|
```
|
|
113
113
|
|
|
114
|
+
**Generics XOR `input`/`output` — never both.** A function's data and return
|
|
115
|
+
types come from *one* source: either the `input`/`output` schemas (preferred —
|
|
116
|
+
they double as runtime validation and OpenAPI) or type generics
|
|
117
|
+
(`pikkuFunc<In, Out>({ ... })`). Passing both makes the two disagree and forces
|
|
118
|
+
`as any` casts. Do not annotate the `func` return type inline either — let the
|
|
119
|
+
`output` schema (or the generic) be the single source of truth for the type.
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
// Correct — schema-based (no generics, no inline return type)
|
|
123
|
+
pikkuFunc({ input: MyInput, output: MyOutput, func: async (s, d) => { ... } })
|
|
124
|
+
// Correct — generic-based (no input/output)
|
|
125
|
+
pikkuFunc<MyIn, MyOut>({ func: async (s, d) => { ... } })
|
|
126
|
+
// WRONG — mixing the two
|
|
127
|
+
pikkuFunc<MyIn, MyOut>({ input: MyInput as any, func: async (s, d) => { ... } })
|
|
128
|
+
```
|
|
129
|
+
|
|
114
130
|
## Schemas (Validation)
|
|
115
131
|
|
|
116
132
|
Pikku uses Standard Schema — works with Zod, Valibot, ArkType:
|
|
@@ -192,17 +192,19 @@ router.delete('/users/:id', requireRole('admin'), deleteUser)
|
|
|
192
192
|
**Pikku:**
|
|
193
193
|
|
|
194
194
|
```typescript
|
|
195
|
-
const
|
|
196
|
-
const session =
|
|
197
|
-
return session?.
|
|
195
|
+
const isOwner = pikkuPermission(async ({ db }, { userId }, wire) => {
|
|
196
|
+
const { session } = wire
|
|
197
|
+
return session?.userId === userId
|
|
198
198
|
})
|
|
199
199
|
|
|
200
|
-
// Declare on the function definition (the only place permissions live)
|
|
200
|
+
// Declare on the function definition (the only place permissions live).
|
|
201
|
+
// A capability like "may delete users" is a scope, not a permission.
|
|
201
202
|
export const deleteUser = pikkuFunc({
|
|
202
203
|
func: async (services, data) => {
|
|
203
204
|
/* ... */
|
|
204
205
|
},
|
|
205
|
-
|
|
206
|
+
scopes: ['admin:users:delete'],
|
|
207
|
+
permissions: { owner: [isOwner] },
|
|
206
208
|
})
|
|
207
209
|
|
|
208
210
|
// App-wide baseline every function must also pass (AND gate, narrow-only)
|
|
@@ -476,7 +478,7 @@ const updateTodo = pikkuFunc(async (services, { id, title }, wire) => {
|
|
|
476
478
|
const todo = services.todoStore.getTodo(id)
|
|
477
479
|
if (!todo) throw new NotFoundError('Todo not found')
|
|
478
480
|
|
|
479
|
-
const session =
|
|
481
|
+
const { session } = wire
|
|
480
482
|
if (todo.userId !== session.userId) throw new ForbiddenError()
|
|
481
483
|
|
|
482
484
|
return { todo: services.todoStore.update(id, { title }) }
|
|
@@ -509,18 +511,18 @@ const login = pikkuSessionlessFunc(
|
|
|
509
511
|
async ({ jwt }, { username, password }, wire) => {
|
|
510
512
|
const user = authenticate(username, password)
|
|
511
513
|
const token = await jwt.sign({ userId: user.id })
|
|
512
|
-
await wire.
|
|
514
|
+
await wire.setSession({ userId: user.id, user }) // Set
|
|
513
515
|
return { token, user }
|
|
514
516
|
}
|
|
515
517
|
)
|
|
516
518
|
|
|
517
519
|
const getMe = pikkuFunc(async (services, data, wire) => {
|
|
518
|
-
const session =
|
|
520
|
+
const { session } = wire // Get
|
|
519
521
|
return { user: session.user }
|
|
520
522
|
})
|
|
521
523
|
|
|
522
524
|
const logout = pikkuFunc(async (services, data, wire) => {
|
|
523
|
-
await wire.
|
|
525
|
+
await wire.clearSession() // Clear
|
|
524
526
|
return { success: true }
|
|
525
527
|
})
|
|
526
528
|
```
|
|
@@ -10,6 +10,7 @@ description: >-
|
|
|
10
10
|
email (verification, password reset, invitation, receipt), wire email sending, or translate an
|
|
11
11
|
email. DO NOT TRIGGER when: user asks about i18n for the app UI (use pikku-i18n) or auth flows
|
|
12
12
|
in general (use pikku-better-auth).
|
|
13
|
+
installGroups: [core]
|
|
13
14
|
---
|
|
14
15
|
|
|
15
16
|
# Pikku Emails
|