@pikku/cli 0.12.0 → 0.12.2
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/cli.schema.json +1 -1
- package/console-app/assets/index-DRJQtv3c.js +676 -0
- package/console-app/index.html +6 -1
- package/dist/.pikku/agent/pikku-agent-types.gen.d.ts +30 -3
- package/dist/.pikku/agent/pikku-agent-types.gen.js +13 -0
- package/dist/.pikku/agent/pikku-agent-wirings-meta.gen.js +2 -2
- package/dist/.pikku/agent/pikku-agent-wirings.gen.d.ts +1 -1
- package/dist/.pikku/agent/pikku-agent-wirings.gen.js +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/channel/pikku-channels-meta.gen.js +2 -2
- package/dist/.pikku/channel/pikku-channels.gen.d.ts +1 -1
- package/dist/.pikku/channel/pikku-channels.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli-channel.js +77 -3
- 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-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 +2 -2
- package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.json +280 -10
- 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 +14 -11
- package/dist/.pikku/function/pikku-function-types.gen.js +25 -13
- package/dist/.pikku/function/pikku-functions-meta.gen.js +2 -2
- package/dist/.pikku/function/pikku-functions-meta.gen.json +426 -93
- package/dist/.pikku/function/pikku-functions.gen.js +5 -3
- 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 +2 -2
- 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/mcp/pikku-mcp-wirings-meta.gen.js +2 -2
- package/dist/.pikku/mcp/pikku-mcp-wirings.gen.d.ts +1 -1
- package/dist/.pikku/mcp/pikku-mcp-wirings.gen.js +1 -1
- package/dist/.pikku/pikku-bootstrap.gen.js +2 -2
- 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/pikku-websocket.gen.d.ts +1 -1
- package/dist/.pikku/pikku-websocket.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 +2 -2
- 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-remote-rpc-workers.gen.js +1 -1
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.js +2 -2
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.json +16 -2
- 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/scheduler/pikku-schedulers-wirings-meta.gen.js +2 -2
- package/dist/.pikku/scheduler/pikku-schedulers-wirings.gen.d.ts +1 -1
- package/dist/.pikku/scheduler/pikku-schedulers-wirings.gen.js +1 -1
- package/dist/.pikku/schemas/register.gen.js +15 -3
- package/dist/.pikku/schemas/schemas/PikkuCLIConfig.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuGatewayOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuNewAddonInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuNewFunctionInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuNewMiddlewareInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuNewPermissionInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuNewWiringInput.schema.json +1 -0
- 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 +2 -2
- package/dist/.pikku/workflow/pikku-workflow-wirings.gen.d.ts +1 -1
- package/dist/.pikku/workflow/pikku-workflow-wirings.gen.js +1 -1
- package/dist/src/cli.wiring.js +236 -9
- package/dist/src/functions/commands/all.js +13 -8
- package/dist/src/functions/commands/enable.d.ts +4 -0
- package/dist/src/functions/commands/enable.js +39 -0
- package/dist/src/functions/commands/info.d.ts +9 -0
- package/dist/src/functions/commands/info.js +283 -0
- package/dist/src/functions/commands/new-addon.d.ts +34 -0
- package/dist/src/functions/commands/new-addon.js +636 -0
- package/dist/src/functions/commands/new-function.d.ts +10 -0
- package/dist/src/functions/commands/new-function.js +79 -0
- package/dist/src/functions/commands/new-middleware.d.ts +10 -0
- package/dist/src/functions/commands/new-middleware.js +48 -0
- package/dist/src/functions/commands/new-permission.d.ts +10 -0
- package/dist/src/functions/commands/new-permission.js +45 -0
- package/dist/src/functions/commands/new-wiring.d.ts +10 -0
- package/dist/src/functions/commands/new-wiring.js +102 -0
- package/dist/src/functions/commands/pikku-command-bootstrap.js +11 -40
- package/dist/src/functions/commands/versions-check.js +85 -3
- package/dist/src/functions/commands/versions-update.js +1 -1
- package/dist/src/functions/runtimes/fetch/index.js +2 -1
- package/dist/src/functions/runtimes/nextjs/pikku-command-nextjs.js +4 -1
- package/dist/src/functions/runtimes/nextjs/serialize-nextjs-backend-wrapper.js +0 -4
- package/dist/src/functions/runtimes/websocket/pikku-command-websocket-typed.js +2 -1
- package/dist/src/functions/wirings/ai-agent/pikku-command-ai-agent-types.js +3 -2
- package/dist/src/functions/wirings/ai-agent/pikku-command-ai-agent.js +5 -5
- package/dist/src/functions/wirings/ai-agent/pikku-command-public-agent.js +3 -5
- package/dist/src/functions/wirings/ai-agent/serialize-agent-map.d.ts +1 -1
- package/dist/src/functions/wirings/ai-agent/serialize-ai-agent-types.d.ts +1 -1
- package/dist/src/functions/wirings/ai-agent/serialize-ai-agent-types.js +48 -3
- package/dist/src/functions/wirings/ai-agent/serialize-public-agent.js +30 -52
- package/dist/src/functions/wirings/channels/pikku-channels.js +1 -1
- package/dist/src/functions/wirings/channels/pikku-command-channel-types.js +2 -2
- package/dist/src/functions/wirings/channels/pikku-command-channels.js +1 -1
- package/dist/src/functions/wirings/channels/serialize-typed-channel-map.d.ts +4 -4
- package/dist/src/functions/wirings/cli/pikku-command-cli.js +1 -1
- package/dist/src/functions/wirings/cli/serialize-channel-cli-client.d.ts +2 -2
- package/dist/src/functions/wirings/cli/serialize-channel-cli.d.ts +1 -1
- package/dist/src/functions/wirings/cli/serialize-local-cli-bootstrap.d.ts +1 -1
- package/dist/src/functions/wirings/console/pikku-command-console-functions.js +4 -5
- package/dist/src/functions/wirings/console/pikku-command-nodes-meta.js +2 -2
- package/dist/src/functions/wirings/console/serialize-console-functions.d.ts +1 -1
- package/dist/src/functions/wirings/console/serialize-console-functions.js +18 -157
- package/dist/src/functions/wirings/functions/pikku-command-addon-types.d.ts +1 -0
- package/dist/src/functions/wirings/functions/pikku-command-addon-types.js +33 -0
- package/dist/src/functions/wirings/functions/pikku-command-function-types-split.js +1 -1
- package/dist/src/functions/wirings/functions/pikku-command-function-types.js +4 -4
- package/dist/src/functions/wirings/functions/pikku-command-functions.js +8 -14
- package/dist/src/functions/wirings/functions/schemas.js +1 -1
- package/dist/src/functions/wirings/functions/serialize-addon-types.d.ts +1 -0
- package/dist/src/functions/wirings/functions/{serialize-external-types.js → serialize-addon-types.js} +16 -15
- package/dist/src/functions/wirings/functions/serialize-function-imports.d.ts +3 -3
- package/dist/src/functions/wirings/functions/serialize-function-imports.js +3 -3
- package/dist/src/functions/wirings/functions/serialize-function-types.js +28 -14
- package/dist/src/functions/wirings/functions/serialize-pikku-types-hub.d.ts +1 -1
- package/dist/src/functions/wirings/functions/serialize-pikku-types-hub.js +2 -2
- package/dist/src/functions/wirings/gateway/pikku-command-gateway.d.ts +1 -0
- package/dist/src/functions/wirings/gateway/pikku-command-gateway.js +22 -0
- package/dist/src/functions/wirings/http/pikku-command-http-routes.js +1 -1
- package/dist/src/functions/wirings/http/pikku-http-routes.js +1 -1
- package/dist/src/functions/wirings/http/serialize-typed-http-map.d.ts +3 -3
- package/dist/src/functions/wirings/mcp/pikku-command-mcp-json.js +1 -1
- package/dist/src/functions/wirings/mcp/pikku-command-mcp.js +1 -1
- package/dist/src/functions/wirings/package/pikku-command-package.js +5 -5
- package/dist/src/functions/wirings/package/serialize-package.js +2 -2
- package/dist/src/functions/wirings/permissions/pikku-command-permissions.js +0 -5
- package/dist/src/functions/wirings/queue/pikku-command-queue-service.js +2 -1
- package/dist/src/functions/wirings/queue/serialize-queue-map.d.ts +2 -2
- package/dist/src/functions/wirings/queue/serialize-queue-meta.d.ts +1 -1
- package/dist/src/functions/wirings/rpc/pikku-command-public-rpc.js +3 -5
- package/dist/src/functions/wirings/rpc/pikku-command-remote-rpc.js +3 -5
- package/dist/src/functions/wirings/rpc/pikku-command-rpc-client.js +2 -1
- package/dist/src/functions/wirings/rpc/pikku-command-rpc-map.js +6 -6
- package/dist/src/functions/wirings/rpc/pikku-command-rpc.js +2 -4
- package/dist/src/functions/wirings/rpc/serialize-public-rpc.js +25 -16
- package/dist/src/functions/wirings/rpc/serialize-rpc-wrapper.js +43 -7
- package/dist/src/functions/wirings/rpc/serialize-typed-rpc-map.d.ts +8 -3
- package/dist/src/functions/wirings/rpc/serialize-typed-rpc-map.js +41 -31
- package/dist/src/functions/wirings/scheduler/serialize-scheduler-meta.d.ts +1 -1
- package/dist/src/functions/wirings/secrets/serialize-secrets-types.d.ts +2 -2
- package/dist/src/functions/wirings/triggers/serialize-trigger-meta.d.ts +1 -1
- package/dist/src/functions/wirings/triggers/serialize-trigger-meta.js +2 -2
- package/dist/src/functions/wirings/variables/serialize-variables-types.d.ts +2 -2
- package/dist/src/functions/wirings/workflow/pikku-command-workflow.js +5 -12
- package/dist/src/functions/wirings/workflow/serialize-workflow-map.d.ts +2 -2
- package/dist/src/functions/wirings/workflow/serialize-workflow-meta.js +2 -2
- package/dist/src/services/cli-logger-forwarder.service.d.ts +4 -3
- package/dist/src/services/cli-logger.service.d.ts +3 -2
- package/dist/src/services.d.ts +4 -3
- package/dist/src/services.js +14 -3
- package/dist/src/utils/check-required-types.d.ts +1 -1
- package/dist/src/utils/contract-versions.d.ts +1 -1
- package/dist/src/utils/file-writer.d.ts +6 -1
- package/dist/src/utils/file-writer.js +14 -1
- package/dist/src/utils/generate-bootstrap-file.d.ts +2 -2
- package/dist/src/utils/openapi/codegen.d.ts +19 -0
- package/dist/src/utils/openapi/codegen.js +288 -0
- package/dist/src/utils/openapi/naming.d.ts +30 -0
- package/dist/src/utils/openapi/naming.js +167 -0
- package/dist/src/utils/openapi/parse-openapi.d.ts +36 -0
- package/dist/src/utils/openapi/parse-openapi.js +196 -0
- package/dist/src/utils/openapi/zod-codegen.d.ts +53 -0
- package/dist/src/utils/openapi/zod-codegen.js +251 -0
- package/dist/src/utils/pikku-cli-config.d.ts +2 -2
- package/dist/src/utils/pikku-cli-config.js +51 -30
- package/dist/src/utils/pikku-files-and-methods.d.ts +1 -1
- package/dist/src/utils/pikku-files-and-methods.js +1 -1
- package/dist/src/utils/serialize-import-map.d.ts +2 -2
- package/dist/src/utils/serialize-import-map.js +1 -1
- package/dist/src/utils/serialize-meta-ts.js +1 -1
- package/dist/src/utils/serialize-schemas.d.ts +2 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/console-app/assets/index-C19L3UJu.js +0 -637
- package/dist/src/functions/wirings/functions/pikku-command-external-types.d.ts +0 -1
- package/dist/src/functions/wirings/functions/pikku-command-external-types.js +0 -33
- package/dist/src/functions/wirings/functions/serialize-external-types.d.ts +0 -1
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { pikkuSessionlessFunc } from '#pikku';
|
|
3
|
+
const printTable = (headers, rows, limit) => {
|
|
4
|
+
const all = [headers, ...rows.slice(0, limit)];
|
|
5
|
+
const widths = headers.map((_, col) => Math.max(...all.map((row) => (row[col] ?? '').length)));
|
|
6
|
+
const line = (row) => row.map((cell, i) => cell.padEnd(widths[i])).join(' ');
|
|
7
|
+
console.log(line(headers));
|
|
8
|
+
console.log(widths.map((w) => '-'.repeat(w)).join(' '));
|
|
9
|
+
for (const row of rows.slice(0, limit)) {
|
|
10
|
+
console.log(line(row));
|
|
11
|
+
}
|
|
12
|
+
if (rows.length > limit) {
|
|
13
|
+
console.log(`... and ${rows.length - limit} more (use --limit to show more)`);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
const getFunctionTypes = (funcId, state) => {
|
|
17
|
+
const types = [];
|
|
18
|
+
if (state.http?.meta) {
|
|
19
|
+
for (const routes of Object.values(state.http.meta)) {
|
|
20
|
+
for (const meta of Object.values(routes)) {
|
|
21
|
+
if (meta.pikkuFuncId === funcId)
|
|
22
|
+
types.push('http');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (state.channels?.meta) {
|
|
27
|
+
for (const channel of Object.values(state.channels.meta)) {
|
|
28
|
+
const messages = [channel.connect, channel.disconnect, channel.message];
|
|
29
|
+
for (const msg of messages) {
|
|
30
|
+
if (msg && msg.pikkuFuncId === funcId)
|
|
31
|
+
types.push('channel');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (state.scheduledTasks?.meta) {
|
|
36
|
+
if (funcId in state.scheduledTasks.meta)
|
|
37
|
+
types.push('scheduler');
|
|
38
|
+
}
|
|
39
|
+
if (state.queueWorkers?.meta) {
|
|
40
|
+
if (funcId in state.queueWorkers.meta)
|
|
41
|
+
types.push('queue');
|
|
42
|
+
}
|
|
43
|
+
if (state.workflows?.meta) {
|
|
44
|
+
if (funcId in state.workflows.meta)
|
|
45
|
+
types.push('workflow');
|
|
46
|
+
}
|
|
47
|
+
if (state.mcpEndpoints?.toolsMeta) {
|
|
48
|
+
if (funcId in state.mcpEndpoints.toolsMeta)
|
|
49
|
+
types.push('mcp');
|
|
50
|
+
}
|
|
51
|
+
if (state.cli?.meta) {
|
|
52
|
+
for (const program of Object.values(state.cli.meta)) {
|
|
53
|
+
if (program.commands) {
|
|
54
|
+
for (const cmd of program.commands) {
|
|
55
|
+
if (cmd.pikkuFuncId === funcId)
|
|
56
|
+
types.push('cli');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (state.triggers?.meta) {
|
|
62
|
+
if (funcId in state.triggers.meta)
|
|
63
|
+
types.push('trigger');
|
|
64
|
+
}
|
|
65
|
+
return [...new Set(types)];
|
|
66
|
+
};
|
|
67
|
+
const getFilePath = (funcId, state) => {
|
|
68
|
+
const entry = state.functions.files.get(funcId);
|
|
69
|
+
if (entry) {
|
|
70
|
+
return path.relative(state.rootDir, entry.path);
|
|
71
|
+
}
|
|
72
|
+
return '';
|
|
73
|
+
};
|
|
74
|
+
const formatMetadata = (meta) => {
|
|
75
|
+
if (!meta || meta.length === 0)
|
|
76
|
+
return '';
|
|
77
|
+
return meta
|
|
78
|
+
.map((m) => {
|
|
79
|
+
if ('name' in m)
|
|
80
|
+
return m.name;
|
|
81
|
+
if ('type' in m)
|
|
82
|
+
return m.type;
|
|
83
|
+
return '?';
|
|
84
|
+
})
|
|
85
|
+
.join(', ');
|
|
86
|
+
};
|
|
87
|
+
export const pikkuInfoFunctions = pikkuSessionlessFunc({
|
|
88
|
+
func: async ({ getInspectorState }, data) => {
|
|
89
|
+
const limit = parseInt(data?.limit ?? '50', 10);
|
|
90
|
+
const verbose = !!data?.verbose;
|
|
91
|
+
const state = await getInspectorState();
|
|
92
|
+
const meta = state.functions.meta;
|
|
93
|
+
const entries = Object.entries(meta);
|
|
94
|
+
if (entries.length === 0) {
|
|
95
|
+
console.log('No functions found.');
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (!verbose) {
|
|
99
|
+
const headers = ['pikkuFuncId', 'name', 'tags'];
|
|
100
|
+
const rows = entries.map(([id, m]) => [
|
|
101
|
+
id,
|
|
102
|
+
m.name ?? '',
|
|
103
|
+
(m.tags ?? []).join(', '),
|
|
104
|
+
]);
|
|
105
|
+
printTable(headers, rows, limit);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
const headers = [
|
|
109
|
+
'pikkuFuncId',
|
|
110
|
+
'name',
|
|
111
|
+
'tags',
|
|
112
|
+
'type',
|
|
113
|
+
'middleware',
|
|
114
|
+
'permissions',
|
|
115
|
+
'file',
|
|
116
|
+
];
|
|
117
|
+
const rows = entries.map(([id, m]) => [
|
|
118
|
+
id,
|
|
119
|
+
m.name ?? '',
|
|
120
|
+
(m.tags ?? []).join(', '),
|
|
121
|
+
getFunctionTypes(id, state).join(', '),
|
|
122
|
+
formatMetadata(m.middleware),
|
|
123
|
+
formatMetadata(m.permissions),
|
|
124
|
+
getFilePath(id, state),
|
|
125
|
+
]);
|
|
126
|
+
printTable(headers, rows, limit);
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
export const pikkuInfoTags = pikkuSessionlessFunc({
|
|
131
|
+
func: async ({ getInspectorState }, data) => {
|
|
132
|
+
const limit = parseInt(data?.limit ?? '50', 10);
|
|
133
|
+
const verbose = !!data?.verbose;
|
|
134
|
+
const state = await getInspectorState();
|
|
135
|
+
const meta = state.functions.meta;
|
|
136
|
+
const tagMap = new Map();
|
|
137
|
+
for (const [id, m] of Object.entries(meta)) {
|
|
138
|
+
for (const tag of m.tags ?? []) {
|
|
139
|
+
if (!tagMap.has(tag)) {
|
|
140
|
+
tagMap.set(tag, {
|
|
141
|
+
funcIds: [],
|
|
142
|
+
middlewareNames: [],
|
|
143
|
+
permissionNames: [],
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
tagMap.get(tag).funcIds.push(m.name ?? id);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
const tagMiddleware = state.middleware?.tagMiddleware;
|
|
150
|
+
if (tagMiddleware) {
|
|
151
|
+
for (const [tag, group] of tagMiddleware) {
|
|
152
|
+
if (!tagMap.has(tag)) {
|
|
153
|
+
tagMap.set(tag, {
|
|
154
|
+
funcIds: [],
|
|
155
|
+
middlewareNames: [],
|
|
156
|
+
permissionNames: [],
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
tagMap.get(tag).middlewareNames.push(...(group.instanceIds ?? []));
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
const tagPermissions = state.permissions?.tagPermissions;
|
|
163
|
+
if (tagPermissions) {
|
|
164
|
+
for (const [tag, group] of tagPermissions) {
|
|
165
|
+
if (!tagMap.has(tag)) {
|
|
166
|
+
tagMap.set(tag, {
|
|
167
|
+
funcIds: [],
|
|
168
|
+
middlewareNames: [],
|
|
169
|
+
permissionNames: [],
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
tagMap.get(tag).permissionNames.push(...(group.instanceIds ?? []));
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
const tags = [...tagMap.entries()].sort((a, b) => a[0].localeCompare(b[0]));
|
|
176
|
+
if (tags.length === 0) {
|
|
177
|
+
console.log('No tags found.');
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
if (!verbose) {
|
|
181
|
+
const headers = ['tag', 'functions', 'middleware', 'permissions'];
|
|
182
|
+
const rows = tags.map(([tag, info]) => [
|
|
183
|
+
tag,
|
|
184
|
+
String(info.funcIds.length),
|
|
185
|
+
String(info.middlewareNames.length),
|
|
186
|
+
String(info.permissionNames.length),
|
|
187
|
+
]);
|
|
188
|
+
printTable(headers, rows, limit);
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
const headers = ['tag', 'functions', 'middleware', 'permissions'];
|
|
192
|
+
const rows = tags.map(([tag, info]) => [
|
|
193
|
+
tag,
|
|
194
|
+
info.funcIds.join(', ') || '(none)',
|
|
195
|
+
info.middlewareNames.join(', ') || '(none)',
|
|
196
|
+
info.permissionNames.join(', ') || '(none)',
|
|
197
|
+
]);
|
|
198
|
+
printTable(headers, rows, limit);
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
});
|
|
202
|
+
export const pikkuInfoMiddleware = pikkuSessionlessFunc({
|
|
203
|
+
func: async ({ getInspectorState }, data) => {
|
|
204
|
+
const limit = parseInt(data?.limit ?? '50', 10);
|
|
205
|
+
const verbose = !!data?.verbose;
|
|
206
|
+
const state = await getInspectorState();
|
|
207
|
+
const definitions = state.middleware?.definitions ?? {};
|
|
208
|
+
const entries = Object.entries(definitions);
|
|
209
|
+
if (entries.length === 0) {
|
|
210
|
+
console.log('No middleware found.');
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
if (!verbose) {
|
|
214
|
+
const headers = ['id', 'name', 'exportedName'];
|
|
215
|
+
const rows = entries.map(([id, def]) => [
|
|
216
|
+
id,
|
|
217
|
+
def.name ?? '',
|
|
218
|
+
def.exportedName ?? '',
|
|
219
|
+
]);
|
|
220
|
+
printTable(headers, rows, limit);
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
const headers = [
|
|
224
|
+
'id',
|
|
225
|
+
'name',
|
|
226
|
+
'exportedName',
|
|
227
|
+
'sourceFile',
|
|
228
|
+
'services',
|
|
229
|
+
'description',
|
|
230
|
+
];
|
|
231
|
+
const rows = entries.map(([id, def]) => [
|
|
232
|
+
id,
|
|
233
|
+
def.name ?? '',
|
|
234
|
+
def.exportedName ?? '',
|
|
235
|
+
def.sourceFile?.replace(state.rootDir + '/', '') ?? '',
|
|
236
|
+
def.services?.services?.join(', ') ?? '',
|
|
237
|
+
def.description ?? '',
|
|
238
|
+
]);
|
|
239
|
+
printTable(headers, rows, limit);
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
});
|
|
243
|
+
export const pikkuInfoPermissions = pikkuSessionlessFunc({
|
|
244
|
+
func: async ({ getInspectorState }, data) => {
|
|
245
|
+
const limit = parseInt(data?.limit ?? '50', 10);
|
|
246
|
+
const verbose = !!data?.verbose;
|
|
247
|
+
const state = await getInspectorState();
|
|
248
|
+
const definitions = state.permissions?.definitions ?? {};
|
|
249
|
+
const entries = Object.entries(definitions);
|
|
250
|
+
if (entries.length === 0) {
|
|
251
|
+
console.log('No permissions found.');
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
if (!verbose) {
|
|
255
|
+
const headers = ['id', 'name', 'exportedName'];
|
|
256
|
+
const rows = entries.map(([id, def]) => [
|
|
257
|
+
id,
|
|
258
|
+
def.name ?? '',
|
|
259
|
+
def.exportedName ?? '',
|
|
260
|
+
]);
|
|
261
|
+
printTable(headers, rows, limit);
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
const headers = [
|
|
265
|
+
'id',
|
|
266
|
+
'name',
|
|
267
|
+
'exportedName',
|
|
268
|
+
'sourceFile',
|
|
269
|
+
'services',
|
|
270
|
+
'description',
|
|
271
|
+
];
|
|
272
|
+
const rows = entries.map(([id, def]) => [
|
|
273
|
+
id,
|
|
274
|
+
def.name ?? '',
|
|
275
|
+
def.exportedName ?? '',
|
|
276
|
+
def.sourceFile?.replace(state.rootDir + '/', '') ?? '',
|
|
277
|
+
def.services?.services?.join(', ') ?? '',
|
|
278
|
+
def.description ?? '',
|
|
279
|
+
]);
|
|
280
|
+
printTable(headers, rows, limit);
|
|
281
|
+
}
|
|
282
|
+
},
|
|
283
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare const pikkuNewAddon: import("#pikku").PikkuFunctionConfig<{
|
|
2
|
+
name: string;
|
|
3
|
+
displayName?: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
category?: string;
|
|
6
|
+
dir?: string;
|
|
7
|
+
secret?: boolean;
|
|
8
|
+
variable?: boolean;
|
|
9
|
+
oauth?: boolean;
|
|
10
|
+
test?: boolean;
|
|
11
|
+
openapi?: string;
|
|
12
|
+
}, void, "session" | "rpc", import("#pikku").PikkuFunctionSessionless<{
|
|
13
|
+
name: string;
|
|
14
|
+
displayName?: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
category?: string;
|
|
17
|
+
dir?: string;
|
|
18
|
+
secret?: boolean;
|
|
19
|
+
variable?: boolean;
|
|
20
|
+
oauth?: boolean;
|
|
21
|
+
test?: boolean;
|
|
22
|
+
openapi?: string;
|
|
23
|
+
}, void, "session" | "rpc", import("#pikku").Services> | import("#pikku").PikkuFunction<{
|
|
24
|
+
name: string;
|
|
25
|
+
displayName?: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
category?: string;
|
|
28
|
+
dir?: string;
|
|
29
|
+
secret?: boolean;
|
|
30
|
+
variable?: boolean;
|
|
31
|
+
oauth?: boolean;
|
|
32
|
+
test?: boolean;
|
|
33
|
+
openapi?: string;
|
|
34
|
+
}, void, "session" | "rpc", import("#pikku").Services>, undefined, undefined>;
|