@pikku/inspector 0.12.61 → 0.12.63
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/CHANGELOG.md +75 -0
- package/dist/add/add-variable.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/utils/post-process.js +6 -0
- package/dist/utils/workflow/graph/index.d.ts +2 -1
- package/dist/utils/workflow/graph/index.js +1 -1
- package/package.json +3 -3
- package/src/add/add-variable.ts +1 -1
- package/src/add/config-value-metadata.test.ts +8 -8
- package/src/index.ts +16 -1
- package/src/utils/post-process.test.ts +20 -0
- package/src/utils/post-process.ts +7 -0
- package/src/utils/workflow/graph/index.ts +18 -1
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,78 @@
|
|
|
1
|
+
## 0.12.63
|
|
2
|
+
|
|
3
|
+
### Patch Changes
|
|
4
|
+
|
|
5
|
+
- 274cab3: The singleton intersection moves to the leaves that name it, the runtime stops
|
|
6
|
+
creating schema, and `db generate` writes only the runtime tables a project's
|
|
7
|
+
services own
|
|
8
|
+
|
|
9
|
+
`WiredSingletonServices` was exported from the generated function leaf so the
|
|
10
|
+
auth leaf could import it. Nothing outside a generated leaf ever names it —
|
|
11
|
+
emit declarations for a project of any size and it appears in none of them —
|
|
12
|
+
so the auth and middleware leaves derive the intersection themselves and the
|
|
13
|
+
function leaf keeps it private. `WiredServices` stays exported: 147 `.d.ts`
|
|
14
|
+
files name it, and unexporting it asks every wired module to name each member
|
|
15
|
+
service through a specifier it does not have.
|
|
16
|
+
|
|
17
|
+
`ensurePikkuSchema` is gone. `requirePikkuSchema` replaces it: a service calls
|
|
18
|
+
it at boot, it looks, and it issues no DDL at all. `pikku db generate` writes
|
|
19
|
+
the declaration down as a migration and `pikku db migrate` applies it, and
|
|
20
|
+
those two are now the only way pikku's runtime tables come into existence. A
|
|
21
|
+
service that finds them missing says so and stops, naming both commands.
|
|
22
|
+
Half-present is no longer a distinct case — the remedy is the same migration
|
|
23
|
+
either way. `audit` and `virtual-user` join `pikkuSchemas` as a consequence:
|
|
24
|
+
boot was the only thing that had ever created them.
|
|
25
|
+
|
|
26
|
+
`pikku db generate` applied all of `pikkuSchemas`, so a project with no agents,
|
|
27
|
+
no channels and no workflows still had `agent_threads`, `channels` and
|
|
28
|
+
`workflow_runs` written into its migrations, and then carried them forever. A
|
|
29
|
+
schema now names the services that own it, and generation gates on
|
|
30
|
+
`requiredServices` — the set the inspector already builds for service
|
|
31
|
+
tree-shaking. The gate is one-sided: a schema that names no owner is always
|
|
32
|
+
written, because the session and secret stores and the deployment record are
|
|
33
|
+
reached by the runtime itself and nothing in a project's source implies them.
|
|
34
|
+
Declared scopes now imply `scopeService`, which nothing destructures because
|
|
35
|
+
the generated auth layer is what reaches it.
|
|
36
|
+
|
|
37
|
+
Drift keeps asking the unscoped question. A table already in a database has to
|
|
38
|
+
stay recognisable as a runtime table after the service that needed it is
|
|
39
|
+
dropped — scoping it there would report those tables as unexplained.
|
|
40
|
+
|
|
41
|
+
Every project in this repo that had been relying on boot-time creation now says
|
|
42
|
+
where its tables come from. `createConfig` moves into its own `config.ts` in the
|
|
43
|
+
templates — `pikku db` looks for it there — and the three postgres templates plus
|
|
44
|
+
the workflow verifier declare `postgresUrl` and run `pikku db generate && pikku
|
|
45
|
+
db migrate` before the server starts, from the single connection string their
|
|
46
|
+
runtime opens. The e2e harness cannot: its databases are in-memory sqlite built
|
|
47
|
+
inside the services factory, so nothing outside the process can migrate them. It
|
|
48
|
+
applies the schemas it owns with `applyPikkuSchemas` instead — the same DDL, run
|
|
49
|
+
by the one process that has the database.
|
|
50
|
+
|
|
51
|
+
- Updated dependencies [32616af]
|
|
52
|
+
- Updated dependencies [6848cd9]
|
|
53
|
+
- @pikku/core@0.12.89
|
|
54
|
+
|
|
55
|
+
## 0.12.62
|
|
56
|
+
|
|
57
|
+
### Patch Changes
|
|
58
|
+
|
|
59
|
+
- 985b87b: Follow through on the variable `required` → `optional` rename: regenerate the
|
|
60
|
+
core API report and update the inspector's `defineVariable` gating-flag test,
|
|
61
|
+
both of which #1369 left describing the deleted `required` flag.
|
|
62
|
+
- 3a83f85: Stop re-exporting package internals through entry points
|
|
63
|
+
|
|
64
|
+
66 names reached consumers only because an `export *` in an entry point swept
|
|
65
|
+
them up. Each one is referenced solely inside its own package, so the star is
|
|
66
|
+
now an explicit named re-export listing what is genuinely public. The
|
|
67
|
+
declarations themselves are untouched — this narrows the entry point, not the
|
|
68
|
+
module.
|
|
69
|
+
|
|
70
|
+
- Updated dependencies [9687ad1]
|
|
71
|
+
- Updated dependencies [2d21628]
|
|
72
|
+
- Updated dependencies [985b87b]
|
|
73
|
+
- Updated dependencies [3a83f85]
|
|
74
|
+
- @pikku/core@0.12.87
|
|
75
|
+
|
|
1
76
|
## 0.12.61
|
|
2
77
|
|
|
3
78
|
### Patch Changes
|
package/dist/add/add-variable.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { inspect, getInitialInspectorState } from './inspector.js';
|
|
2
2
|
export type { TypesMap } from './types-map.js';
|
|
3
|
-
export type
|
|
3
|
+
export type { AddonConfig, AuthDefinition, InspectorDiagnostic, InspectorFilters, InspectorHTTPState, InspectorLogger, InspectorMiddlewareState, InspectorOptions, InspectorPermissionState, InspectorState, MetaInputTypes, MiddlewareGroupMeta, MiddlewareRegistration, SchemaRef, } from './types.js';
|
|
4
4
|
export type { FilesAndMethodsErrors } from './utils/get-files-and-methods.js';
|
|
5
5
|
export { ErrorCode } from './error-codes.js';
|
|
6
6
|
export type { DiagnosticSeverity, CodedDiagnostic } from './error-codes.js';
|
|
@@ -266,6 +266,12 @@ export function aggregateRequiredServices(state) {
|
|
|
266
266
|
if (Object.keys(state.channels.meta).length > 0) {
|
|
267
267
|
requiredServices.add('eventHub');
|
|
268
268
|
}
|
|
269
|
+
// Declared scopes need scopeService to resolve a grant. Nothing in a project
|
|
270
|
+
// destructures it — the generated auth layer reaches it — so the declaration
|
|
271
|
+
// is the only signal there is.
|
|
272
|
+
if ((state.scopes?.definitions?.length ?? 0) > 0) {
|
|
273
|
+
requiredServices.add('scopeService');
|
|
274
|
+
}
|
|
269
275
|
// 7. Services that consumed addons need from the parent project.
|
|
270
276
|
const addonFnServices = new Map();
|
|
271
277
|
for (const [namespace, fns] of Object.entries(state.addonFunctions ?? {})) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Workflow graph serialization exports
|
|
3
3
|
*/
|
|
4
|
-
export
|
|
4
|
+
export { isDataRef, isFunctionNode, ref, state, } from './workflow-graph.types.js';
|
|
5
|
+
export type { BranchCondition, ContextVariable, DataRef, FlowNode, ForEachMode, FunctionNode, NodeOptions, SerializedWorkflowGraph, SerializedWorkflowGraphs, WorkflowContext, } from './workflow-graph.types.js';
|
|
5
6
|
export { serializeWorkflowGraph } from './serialize-workflow-graph.js';
|
|
6
7
|
export { convertDslToGraph } from './convert-dsl-to-graph.js';
|
|
7
8
|
export { finalizeWorkflows } from './finalize-workflows.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Workflow graph serialization exports
|
|
3
3
|
*/
|
|
4
|
-
export
|
|
4
|
+
export { isDataRef, isFunctionNode, ref, state, } from './workflow-graph.types.js';
|
|
5
5
|
export { serializeWorkflowGraph } from './serialize-workflow-graph.js';
|
|
6
6
|
export { convertDslToGraph } from './convert-dsl-to-graph.js';
|
|
7
7
|
export { finalizeWorkflows } from './finalize-workflows.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pikku/inspector",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.63",
|
|
4
4
|
"description": "TypeScript inspector for Pikku — discovers functions and wirings to drive code generation",
|
|
5
5
|
"author": "yasser.fadl@gmail.com",
|
|
6
6
|
"license": "BUSL-1.1",
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
"zod-to-ts": "^2.1.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@pikku/core": "^0.12.
|
|
48
|
+
"@pikku/core": "^0.12.89"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@pikku/core": "^0.12.
|
|
51
|
+
"@pikku/core": "^0.12.89",
|
|
52
52
|
"@types/node": "^24.13.3"
|
|
53
53
|
},
|
|
54
54
|
"engines": {
|
package/src/add/add-variable.ts
CHANGED
|
@@ -169,7 +169,7 @@ describe('config value metadata (docsUrl)', () => {
|
|
|
169
169
|
})
|
|
170
170
|
|
|
171
171
|
/**
|
|
172
|
-
* `optional`
|
|
172
|
+
* `optional` is the deploy gate's whole input. A flag the
|
|
173
173
|
* inspector drops leaves the gate seeing a bare declaration, which is how an
|
|
174
174
|
* optional secret suspends a deploy over a value production is meant NOT to
|
|
175
175
|
* have.
|
|
@@ -218,8 +218,8 @@ describe('config value gating flags', () => {
|
|
|
218
218
|
}
|
|
219
219
|
})
|
|
220
220
|
|
|
221
|
-
test('carries
|
|
222
|
-
const rootDir = await mkdtemp(`${fixtureRoot}-variable-
|
|
221
|
+
test('carries optional from defineVariable into the definition', async () => {
|
|
222
|
+
const rootDir = await mkdtemp(`${fixtureRoot}-variable-optional-`)
|
|
223
223
|
const file = join(rootDir, 'variable.ts')
|
|
224
224
|
|
|
225
225
|
await writeFile(
|
|
@@ -233,7 +233,7 @@ describe('config value gating flags', () => {
|
|
|
233
233
|
" name: 'consoleUrl',",
|
|
234
234
|
" displayName: 'Console URL',",
|
|
235
235
|
" variableId: 'CONSOLE_URL',",
|
|
236
|
-
'
|
|
236
|
+
' optional: true,',
|
|
237
237
|
' schema: ConsoleUrlSchema,',
|
|
238
238
|
'})',
|
|
239
239
|
'defineVariable({',
|
|
@@ -248,14 +248,14 @@ describe('config value gating flags', () => {
|
|
|
248
248
|
const criticals: Array<{ code: ErrorCode; message: string }> = []
|
|
249
249
|
try {
|
|
250
250
|
const state = await inspect(makeLogger(criticals), [file], { rootDir })
|
|
251
|
-
const
|
|
251
|
+
const optional = state.variables.definitions.find(
|
|
252
252
|
(d) => d.variableId === 'CONSOLE_URL'
|
|
253
253
|
)
|
|
254
|
-
const
|
|
254
|
+
const required = state.variables.definitions.find(
|
|
255
255
|
(d) => d.variableId === 'CORS_ORIGINS'
|
|
256
256
|
)
|
|
257
|
-
assert.equal(
|
|
258
|
-
assert.equal(optional
|
|
257
|
+
assert.equal(optional!.optional, true)
|
|
258
|
+
assert.equal(required!.optional, undefined)
|
|
259
259
|
} finally {
|
|
260
260
|
await rm(rootDir, { recursive: true, force: true })
|
|
261
261
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
export { inspect, getInitialInspectorState } from './inspector.js'
|
|
2
2
|
export type { TypesMap } from './types-map.js'
|
|
3
|
-
export type
|
|
3
|
+
export type {
|
|
4
|
+
AddonConfig,
|
|
5
|
+
AuthDefinition,
|
|
6
|
+
InspectorDiagnostic,
|
|
7
|
+
InspectorFilters,
|
|
8
|
+
InspectorHTTPState,
|
|
9
|
+
InspectorLogger,
|
|
10
|
+
InspectorMiddlewareState,
|
|
11
|
+
InspectorOptions,
|
|
12
|
+
InspectorPermissionState,
|
|
13
|
+
InspectorState,
|
|
14
|
+
MetaInputTypes,
|
|
15
|
+
MiddlewareGroupMeta,
|
|
16
|
+
MiddlewareRegistration,
|
|
17
|
+
SchemaRef,
|
|
18
|
+
} from './types.js'
|
|
4
19
|
export type { FilesAndMethodsErrors } from './utils/get-files-and-methods.js'
|
|
5
20
|
export { ErrorCode } from './error-codes.js'
|
|
6
21
|
export type { DiagnosticSeverity, CodedDiagnostic } from './error-codes.js'
|
|
@@ -94,6 +94,7 @@ function makeState(
|
|
|
94
94
|
addonRequiredParentServices?: string[]
|
|
95
95
|
authServices?: string[]
|
|
96
96
|
graphMeta?: Record<string, any>
|
|
97
|
+
scopeDefinitions?: any[]
|
|
97
98
|
} = {}
|
|
98
99
|
): Omit<InspectorState, 'typesLookup'> {
|
|
99
100
|
return {
|
|
@@ -128,6 +129,7 @@ function makeState(
|
|
|
128
129
|
workflows: { meta: {}, graphMeta: overrides.graphMeta ?? {} },
|
|
129
130
|
wireServicesMeta: new Map(),
|
|
130
131
|
rpc: { internalMeta: {}, exposedMeta: {} },
|
|
132
|
+
scopes: { definitions: overrides.scopeDefinitions ?? [] },
|
|
131
133
|
addonFunctions: overrides.addonFunctions ?? {},
|
|
132
134
|
addonRequiredParentServices: overrides.addonRequiredParentServices ?? [],
|
|
133
135
|
auth: overrides.authServices
|
|
@@ -392,6 +394,24 @@ describe('aggregateRequiredServices — the auth factory’s own services', () =
|
|
|
392
394
|
})
|
|
393
395
|
})
|
|
394
396
|
|
|
397
|
+
describe('aggregateRequiredServices — scopes imply the service that resolves them', () => {
|
|
398
|
+
// Nothing in a project destructures `scopeService` — the generated auth layer
|
|
399
|
+
// reaches it — so the declaration is the only signal there is. Without this,
|
|
400
|
+
// `pikku db generate` would leave a project that declares scopes with no
|
|
401
|
+
// tables to grant them in.
|
|
402
|
+
test('a declared scope requires scopeService', () => {
|
|
403
|
+
const state = makeState({ scopeDefinitions: [{ id: 'admin' }] })
|
|
404
|
+
aggregateRequiredServices(state)
|
|
405
|
+
assert.ok(state.serviceAggregation.requiredServices.has('scopeService'))
|
|
406
|
+
})
|
|
407
|
+
|
|
408
|
+
test('a project that declares none does not', () => {
|
|
409
|
+
const state = makeState()
|
|
410
|
+
aggregateRequiredServices(state)
|
|
411
|
+
assert.ok(!state.serviceAggregation.requiredServices.has('scopeService'))
|
|
412
|
+
})
|
|
413
|
+
})
|
|
414
|
+
|
|
395
415
|
describe('override validation resolves the override target (value), not the logical key', () => {
|
|
396
416
|
test('validateSecretOverrides accepts an override whose value is a declared secret', () => {
|
|
397
417
|
const { logger, criticals } = makeCriticalLogger()
|
|
@@ -322,6 +322,13 @@ export function aggregateRequiredServices(
|
|
|
322
322
|
requiredServices.add('eventHub')
|
|
323
323
|
}
|
|
324
324
|
|
|
325
|
+
// Declared scopes need scopeService to resolve a grant. Nothing in a project
|
|
326
|
+
// destructures it — the generated auth layer reaches it — so the declaration
|
|
327
|
+
// is the only signal there is.
|
|
328
|
+
if ((state.scopes?.definitions?.length ?? 0) > 0) {
|
|
329
|
+
requiredServices.add('scopeService')
|
|
330
|
+
}
|
|
331
|
+
|
|
325
332
|
// 7. Services that consumed addons need from the parent project.
|
|
326
333
|
const addonFnServices = new Map<string, string[] | undefined>()
|
|
327
334
|
for (const [namespace, fns] of Object.entries(state.addonFunctions ?? {})) {
|
|
@@ -1,7 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Workflow graph serialization exports
|
|
3
3
|
*/
|
|
4
|
-
export
|
|
4
|
+
export {
|
|
5
|
+
isDataRef,
|
|
6
|
+
isFunctionNode,
|
|
7
|
+
ref,
|
|
8
|
+
state,
|
|
9
|
+
} from './workflow-graph.types.js'
|
|
10
|
+
export type {
|
|
11
|
+
BranchCondition,
|
|
12
|
+
ContextVariable,
|
|
13
|
+
DataRef,
|
|
14
|
+
FlowNode,
|
|
15
|
+
ForEachMode,
|
|
16
|
+
FunctionNode,
|
|
17
|
+
NodeOptions,
|
|
18
|
+
SerializedWorkflowGraph,
|
|
19
|
+
SerializedWorkflowGraphs,
|
|
20
|
+
WorkflowContext,
|
|
21
|
+
} from './workflow-graph.types.js'
|
|
5
22
|
export { serializeWorkflowGraph } from './serialize-workflow-graph.js'
|
|
6
23
|
export { convertDslToGraph } from './convert-dsl-to-graph.js'
|
|
7
24
|
export { finalizeWorkflows } from './finalize-workflows.js'
|