@jigx/sdk-tools 1.2.0-next.3 → 1.2.0-next.4
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/README.md +27 -1
- package/dist/cli.js +83 -0
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/migrator/converters/app-index.d.ts +53 -0
- package/dist/migrator/converters/app-index.d.ts.map +1 -0
- package/dist/migrator/converters/app-index.js +206 -0
- package/dist/migrator/converters/app-index.js.map +1 -0
- package/dist/migrator/converters/assets.d.ts +7 -0
- package/dist/migrator/converters/assets.d.ts.map +1 -0
- package/dist/migrator/converters/assets.js +58 -0
- package/dist/migrator/converters/assets.js.map +1 -0
- package/dist/migrator/converters/components.d.ts +4 -0
- package/dist/migrator/converters/components.d.ts.map +1 -0
- package/dist/migrator/converters/components.js +7 -0
- package/dist/migrator/converters/components.js.map +1 -0
- package/dist/migrator/converters/databases.d.ts +9 -0
- package/dist/migrator/converters/databases.d.ts.map +1 -0
- package/dist/migrator/converters/databases.js +45 -0
- package/dist/migrator/converters/databases.js.map +1 -0
- package/dist/migrator/converters/datasources.d.ts +46 -0
- package/dist/migrator/converters/datasources.d.ts.map +1 -0
- package/dist/migrator/converters/datasources.js +445 -0
- package/dist/migrator/converters/datasources.js.map +1 -0
- package/dist/migrator/converters/functions.d.ts +13 -0
- package/dist/migrator/converters/functions.d.ts.map +1 -0
- package/dist/migrator/converters/functions.js +444 -0
- package/dist/migrator/converters/functions.js.map +1 -0
- package/dist/migrator/converters/index.d.ts +11 -0
- package/dist/migrator/converters/index.d.ts.map +1 -0
- package/dist/migrator/converters/index.js +9 -0
- package/dist/migrator/converters/index.js.map +1 -0
- package/dist/migrator/converters/scripts.d.ts +10 -0
- package/dist/migrator/converters/scripts.d.ts.map +1 -0
- package/dist/migrator/converters/scripts.js +28 -0
- package/dist/migrator/converters/scripts.js.map +1 -0
- package/dist/migrator/converters/translations.d.ts +5 -0
- package/dist/migrator/converters/translations.d.ts.map +1 -0
- package/dist/migrator/converters/translations.js +25 -0
- package/dist/migrator/converters/translations.js.map +1 -0
- package/dist/migrator/converters/types.d.ts +35 -0
- package/dist/migrator/converters/types.d.ts.map +1 -0
- package/dist/migrator/converters/types.js +2 -0
- package/dist/migrator/converters/types.js.map +1 -0
- package/dist/migrator/errors.d.ts +5 -0
- package/dist/migrator/errors.d.ts.map +1 -0
- package/dist/migrator/errors.js +8 -0
- package/dist/migrator/errors.js.map +1 -0
- package/dist/migrator/index.d.ts +6 -0
- package/dist/migrator/index.d.ts.map +1 -0
- package/dist/migrator/index.js +4 -0
- package/dist/migrator/index.js.map +1 -0
- package/dist/migrator/migrate.d.ts +75 -0
- package/dist/migrator/migrate.d.ts.map +1 -0
- package/dist/migrator/migrate.js +439 -0
- package/dist/migrator/migrate.js.map +1 -0
- package/dist/migrator/module-writer.d.ts +26 -0
- package/dist/migrator/module-writer.d.ts.map +1 -0
- package/dist/migrator/module-writer.js +26 -0
- package/dist/migrator/module-writer.js.map +1 -0
- package/dist/migrator/nodes/action-definition.d.ts +11 -0
- package/dist/migrator/nodes/action-definition.d.ts.map +1 -0
- package/dist/migrator/nodes/action-definition.js +75 -0
- package/dist/migrator/nodes/action-definition.js.map +1 -0
- package/dist/migrator/nodes/app-events.d.ts +29 -0
- package/dist/migrator/nodes/app-events.d.ts.map +1 -0
- package/dist/migrator/nodes/app-events.js +40 -0
- package/dist/migrator/nodes/app-events.js.map +1 -0
- package/dist/migrator/nodes/attach.d.ts +61 -0
- package/dist/migrator/nodes/attach.d.ts.map +1 -0
- package/dist/migrator/nodes/attach.js +174 -0
- package/dist/migrator/nodes/attach.js.map +1 -0
- package/dist/migrator/nodes/builder-access.d.ts +16 -0
- package/dist/migrator/nodes/builder-access.d.ts.map +1 -0
- package/dist/migrator/nodes/builder-access.js +81 -0
- package/dist/migrator/nodes/builder-access.js.map +1 -0
- package/dist/migrator/nodes/codegen.d.ts +33 -0
- package/dist/migrator/nodes/codegen.d.ts.map +1 -0
- package/dist/migrator/nodes/codegen.js +77 -0
- package/dist/migrator/nodes/codegen.js.map +1 -0
- package/dist/migrator/nodes/index.d.ts +6 -0
- package/dist/migrator/nodes/index.d.ts.map +1 -0
- package/dist/migrator/nodes/index.js +6 -0
- package/dist/migrator/nodes/index.js.map +1 -0
- package/dist/migrator/nodes/node-shape.d.ts +39 -0
- package/dist/migrator/nodes/node-shape.d.ts.map +1 -0
- package/dist/migrator/nodes/node-shape.js +65 -0
- package/dist/migrator/nodes/node-shape.js.map +1 -0
- package/dist/migrator/nodes/probe.d.ts +66 -0
- package/dist/migrator/nodes/probe.d.ts.map +1 -0
- package/dist/migrator/nodes/probe.js +46 -0
- package/dist/migrator/nodes/probe.js.map +1 -0
- package/dist/migrator/nodes/rules/action-list.d.ts +4 -0
- package/dist/migrator/nodes/rules/action-list.d.ts.map +1 -0
- package/dist/migrator/nodes/rules/action-list.js +14 -0
- package/dist/migrator/nodes/rules/action-list.js.map +1 -0
- package/dist/migrator/nodes/rules/action-slots.d.ts +13 -0
- package/dist/migrator/nodes/rules/action-slots.d.ts.map +1 -0
- package/dist/migrator/nodes/rules/action-slots.js +34 -0
- package/dist/migrator/nodes/rules/action-slots.js.map +1 -0
- package/dist/migrator/nodes/rules/custom-component.d.ts +7 -0
- package/dist/migrator/nodes/rules/custom-component.d.ts.map +1 -0
- package/dist/migrator/nodes/rules/custom-component.js +8 -0
- package/dist/migrator/nodes/rules/custom-component.js.map +1 -0
- package/dist/migrator/nodes/rules/dropdown.d.ts +4 -0
- package/dist/migrator/nodes/rules/dropdown.d.ts.map +1 -0
- package/dist/migrator/nodes/rules/dropdown.js +3 -0
- package/dist/migrator/nodes/rules/dropdown.js.map +1 -0
- package/dist/migrator/nodes/rules/execute-entity.d.ts +7 -0
- package/dist/migrator/nodes/rules/execute-entity.d.ts.map +1 -0
- package/dist/migrator/nodes/rules/execute-entity.js +40 -0
- package/dist/migrator/nodes/rules/execute-entity.js.map +1 -0
- package/dist/migrator/nodes/rules/field-row.d.ts +4 -0
- package/dist/migrator/nodes/rules/field-row.d.ts.map +1 -0
- package/dist/migrator/nodes/rules/field-row.js +3 -0
- package/dist/migrator/nodes/rules/field-row.js.map +1 -0
- package/dist/migrator/nodes/rules/index.d.ts +16 -0
- package/dist/migrator/nodes/rules/index.d.ts.map +1 -0
- package/dist/migrator/nodes/rules/index.js +42 -0
- package/dist/migrator/nodes/rules/index.js.map +1 -0
- package/dist/migrator/nodes/rules/list-item.d.ts +7 -0
- package/dist/migrator/nodes/rules/list-item.d.ts.map +1 -0
- package/dist/migrator/nodes/rules/list-item.js +40 -0
- package/dist/migrator/nodes/rules/list-item.js.map +1 -0
- package/dist/migrator/nodes/rules/list.d.ts +4 -0
- package/dist/migrator/nodes/rules/list.d.ts.map +1 -0
- package/dist/migrator/nodes/rules/list.js +7 -0
- package/dist/migrator/nodes/rules/list.js.map +1 -0
- package/dist/migrator/nodes/rules/method-names.d.ts +10 -0
- package/dist/migrator/nodes/rules/method-names.d.ts.map +1 -0
- package/dist/migrator/nodes/rules/method-names.js +33 -0
- package/dist/migrator/nodes/rules/method-names.js.map +1 -0
- package/dist/migrator/nodes/rules/screen-slots.d.ts +10 -0
- package/dist/migrator/nodes/rules/screen-slots.d.ts.map +1 -0
- package/dist/migrator/nodes/rules/screen-slots.js +9 -0
- package/dist/migrator/nodes/rules/screen-slots.js.map +1 -0
- package/dist/migrator/nodes/rules/set-jig-state.d.ts +4 -0
- package/dist/migrator/nodes/rules/set-jig-state.d.ts.map +1 -0
- package/dist/migrator/nodes/rules/set-jig-state.js +9 -0
- package/dist/migrator/nodes/rules/set-jig-state.js.map +1 -0
- package/dist/migrator/nodes/rules/state-key.d.ts +7 -0
- package/dist/migrator/nodes/rules/state-key.d.ts.map +1 -0
- package/dist/migrator/nodes/rules/state-key.js +16 -0
- package/dist/migrator/nodes/rules/state-key.js.map +1 -0
- package/dist/migrator/nodes/rules/summary.d.ts +7 -0
- package/dist/migrator/nodes/rules/summary.d.ts.map +1 -0
- package/dist/migrator/nodes/rules/summary.js +16 -0
- package/dist/migrator/nodes/rules/summary.js.map +1 -0
- package/dist/migrator/nodes/rules/sync-entities.d.ts +7 -0
- package/dist/migrator/nodes/rules/sync-entities.d.ts.map +1 -0
- package/dist/migrator/nodes/rules/sync-entities.js +17 -0
- package/dist/migrator/nodes/rules/sync-entities.js.map +1 -0
- package/dist/migrator/nodes/rules/types.d.ts +35 -0
- package/dist/migrator/nodes/rules/types.d.ts.map +1 -0
- package/dist/migrator/nodes/rules/types.js +7 -0
- package/dist/migrator/nodes/rules/types.js.map +1 -0
- package/dist/migrator/nodes/screen.d.ts +13 -0
- package/dist/migrator/nodes/screen.d.ts.map +1 -0
- package/dist/migrator/nodes/screen.js +403 -0
- package/dist/migrator/nodes/screen.js.map +1 -0
- package/dist/migrator/normalize.d.ts +42 -0
- package/dist/migrator/normalize.d.ts.map +1 -0
- package/dist/migrator/normalize.js +167 -0
- package/dist/migrator/normalize.js.map +1 -0
- package/dist/migrator/project-writer.d.ts +34 -0
- package/dist/migrator/project-writer.d.ts.map +1 -0
- package/dist/migrator/project-writer.js +65 -0
- package/dist/migrator/project-writer.js.map +1 -0
- package/dist/migrator/prune.d.ts +58 -0
- package/dist/migrator/prune.d.ts.map +1 -0
- package/dist/migrator/prune.js +171 -0
- package/dist/migrator/prune.js.map +1 -0
- package/dist/migrator/read-solution.d.ts +38 -0
- package/dist/migrator/read-solution.d.ts.map +1 -0
- package/dist/migrator/read-solution.js +144 -0
- package/dist/migrator/read-solution.js.map +1 -0
- package/dist/migrator/report.d.ts +76 -0
- package/dist/migrator/report.d.ts.map +1 -0
- package/dist/migrator/report.js +53 -0
- package/dist/migrator/report.js.map +1 -0
- package/dist/migrator/ts-printer.d.ts +19 -0
- package/dist/migrator/ts-printer.d.ts.map +1 -0
- package/dist/migrator/ts-printer.js +70 -0
- package/dist/migrator/ts-printer.js.map +1 -0
- package/dist/migrator/verify-entity.d.ts +21 -0
- package/dist/migrator/verify-entity.d.ts.map +1 -0
- package/dist/migrator/verify-entity.js +22 -0
- package/dist/migrator/verify-entity.js.map +1 -0
- package/dist/scaffolder/index.d.ts +1 -0
- package/dist/scaffolder/index.d.ts.map +1 -1
- package/dist/scaffolder/index.js +1 -0
- package/dist/scaffolder/index.js.map +1 -1
- package/dist/scaffolder/templates.d.ts +11 -2
- package/dist/scaffolder/templates.d.ts.map +1 -1
- package/dist/scaffolder/templates.js +7 -3
- package/dist/scaffolder/templates.js.map +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type EntityConversion } from '../converters/index.js';
|
|
2
|
+
import { type LegacyEntry } from '../read-solution.js';
|
|
3
|
+
/**
|
|
4
|
+
* `actions/<id>.jigx` → `app.addAction({ actionId })`, `definition.addParameter(…)` per
|
|
5
|
+
* parameter and the root action through the node engine.
|
|
6
|
+
*
|
|
7
|
+
* A root action that does not verify skips the whole entity with the root's gap: an
|
|
8
|
+
* action definition cannot build without its action.
|
|
9
|
+
*/
|
|
10
|
+
export declare function convertAction(entry: LegacyEntry): EntityConversion;
|
|
11
|
+
//# sourceMappingURL=action-definition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-definition.d.ts","sourceRoot":"","sources":["../../../src/migrator/nodes/action-definition.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAE9D,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAetD;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,gBAAgB,CAwDlE"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { ApplicationBuilder, toJaActionParameterDefinition } from '@jigx/core-sdk';
|
|
2
|
+
import { isPlainObject } from '../normalize.js';
|
|
3
|
+
import { lit, str } from '../ts-printer.js';
|
|
4
|
+
import { attachNode } from './attach.js';
|
|
5
|
+
import { emitPlan, Gen } from './codegen.js';
|
|
6
|
+
import { isNode } from './node-shape.js';
|
|
7
|
+
import { PROBE_APP_NAME, replay } from './probe.js';
|
|
8
|
+
const DEFINITION_KEYS = ['actionId', 'action', 'parameters'];
|
|
9
|
+
const UNSUPPORTED = {
|
|
10
|
+
type: 'skip',
|
|
11
|
+
gapId: 'actions:unsupported-shape',
|
|
12
|
+
reason: 'a global action needs an action node, optional parameters and nothing else',
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* `actions/<id>.jigx` → `app.addAction({ actionId })`, `definition.addParameter(…)` per
|
|
16
|
+
* parameter and the root action through the node engine.
|
|
17
|
+
*
|
|
18
|
+
* A root action that does not verify skips the whole entity with the root's gap: an
|
|
19
|
+
* action definition cannot build without its action.
|
|
20
|
+
*/
|
|
21
|
+
export function convertAction(entry) {
|
|
22
|
+
const { id, entity } = entry;
|
|
23
|
+
if (!isPlainObject(entity))
|
|
24
|
+
return UNSUPPORTED;
|
|
25
|
+
const { actionId, action, parameters } = entity;
|
|
26
|
+
const shapeOk = Object.keys(entity).every((key) => DEFINITION_KEYS.includes(key)) &&
|
|
27
|
+
(actionId === undefined || actionId === id) &&
|
|
28
|
+
isNode(action) &&
|
|
29
|
+
(parameters === undefined ||
|
|
30
|
+
(isPlainObject(parameters) && Object.values(parameters).every((p) => isPlainObject(p))));
|
|
31
|
+
if (!shapeOk || !isNode(action))
|
|
32
|
+
return UNSUPPORTED;
|
|
33
|
+
const result = attachNode({
|
|
34
|
+
parentFactory: () => new ApplicationBuilder({ name: PROBE_APP_NAME }).addAction({ actionId: id }),
|
|
35
|
+
parentType: 'action-definition',
|
|
36
|
+
parentChildRoot: 'root',
|
|
37
|
+
slot: 'action',
|
|
38
|
+
list: false,
|
|
39
|
+
path: ['action'],
|
|
40
|
+
node: action,
|
|
41
|
+
});
|
|
42
|
+
if (result.type === 'skip') {
|
|
43
|
+
return {
|
|
44
|
+
type: 'skip',
|
|
45
|
+
gapId: result.gap.gapId,
|
|
46
|
+
nodeType: result.gap.nodeType,
|
|
47
|
+
reason: result.gap.reason,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
const definitions = Object.entries(isPlainObject(parameters) ? parameters : {});
|
|
51
|
+
const gen = new Gen();
|
|
52
|
+
gen.push(`const definition = app.addAction({ actionId: ${str(id)} })`);
|
|
53
|
+
for (const [name, parameter] of definitions) {
|
|
54
|
+
gen.push(`definition.addParameter(${str(name)}, ${lit(parameter, gen.indent)})`);
|
|
55
|
+
}
|
|
56
|
+
const { plan } = result;
|
|
57
|
+
emitPlan({ plan, parentExpr: 'definition', gen });
|
|
58
|
+
return {
|
|
59
|
+
type: 'statements',
|
|
60
|
+
gaps: result.gaps,
|
|
61
|
+
statements: [
|
|
62
|
+
{
|
|
63
|
+
code: gen.code(),
|
|
64
|
+
run: (app) => {
|
|
65
|
+
const definition = app.addAction({ actionId: id });
|
|
66
|
+
for (const [name, value] of definitions) {
|
|
67
|
+
definition.addParameter(name, toJaActionParameterDefinition(structuredClone(value)));
|
|
68
|
+
}
|
|
69
|
+
replay({ parent: definition, plan });
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=action-definition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-definition.js","sourceRoot":"","sources":["../../../src/migrator/nodes/action-definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAA;AAElF,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/C,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,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GAAG,CAAC,IAAI,EAAE;gBAChB,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE;oBACX,MAAM,UAAU,GAAG,GAAG,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAA;oBAClD,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,WAAW,EAAE,CAAC;wBACxC,UAAU,CAAC,YAAY,CAAC,IAAI,EAAE,6BAA6B,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;oBACtF,CAAC;oBACD,MAAM,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAA;gBACtC,CAAC;aACF;SACF;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ApplicationBuilder } from '@jigx/core-sdk';
|
|
2
|
+
import { type NodeGap } from '../report.js';
|
|
3
|
+
import { type Gen } from './codegen.js';
|
|
4
|
+
/** Index keys whose action tree has a typed `ApplicationBuilder` event factory. */
|
|
5
|
+
export declare const APP_EVENTS: readonly string[];
|
|
6
|
+
export type AppEventConversion = {
|
|
7
|
+
readonly type: 'typed';
|
|
8
|
+
readonly code: string;
|
|
9
|
+
readonly run: (app: ApplicationBuilder) => void;
|
|
10
|
+
readonly gaps: readonly NodeGap[];
|
|
11
|
+
} | {
|
|
12
|
+
readonly type: 'skip';
|
|
13
|
+
readonly gap: NodeGap;
|
|
14
|
+
} | {
|
|
15
|
+
readonly type: 'not-node';
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Index `onLoad`/`onFocus`/`onRefresh` → `app.<event>.<action>(…)` through the node engine,
|
|
19
|
+
* verified on a scratch ApplicationBuilder. `onAppActivated` and `onTableChanged` have no
|
|
20
|
+
* typed event and stay index-level gaps.
|
|
21
|
+
*/
|
|
22
|
+
export declare function convertAppEvent(options: {
|
|
23
|
+
readonly name: string;
|
|
24
|
+
readonly key: string;
|
|
25
|
+
readonly value: unknown;
|
|
26
|
+
/** Shares the variable counter of the index module. */
|
|
27
|
+
readonly gen: Gen;
|
|
28
|
+
}): AppEventConversion;
|
|
29
|
+
//# sourceMappingURL=app-events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-events.d.ts","sourceRoot":"","sources":["../../../src/migrator/nodes/app-events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,cAAc,CAAA;AAE3C,OAAO,EAAY,KAAK,GAAG,EAAE,MAAM,cAAc,CAAA;AAIjD,mFAAmF;AACnF,eAAO,MAAM,UAAU,EAAE,SAAS,MAAM,EAAuC,CAAA;AAE/E,MAAM,MAAM,kBAAkB,GAC1B;IACE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,kBAAkB,KAAK,IAAI,CAAA;IAC/C,QAAQ,CAAC,IAAI,EAAE,SAAS,OAAO,EAAE,CAAA;CAClC,GACD;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAA;CAAE,GAChD;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;CAAE,CAAA;AAEjC;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE;IACvC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;IACvB,uDAAuD;IACvD,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAA;CAClB,GAAG,kBAAkB,CAwBrB"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ApplicationBuilder } from '@jigx/core-sdk';
|
|
2
|
+
import { attachNode } from './attach.js';
|
|
3
|
+
import { emitPlan } from './codegen.js';
|
|
4
|
+
import { isNode } from './node-shape.js';
|
|
5
|
+
import { replay } from './probe.js';
|
|
6
|
+
/** Index keys whose action tree has a typed `ApplicationBuilder` event factory. */
|
|
7
|
+
export const APP_EVENTS = ['onLoad', 'onFocus', 'onRefresh'];
|
|
8
|
+
/**
|
|
9
|
+
* Index `onLoad`/`onFocus`/`onRefresh` → `app.<event>.<action>(…)` through the node engine,
|
|
10
|
+
* verified on a scratch ApplicationBuilder. `onAppActivated` and `onTableChanged` have no
|
|
11
|
+
* typed event and stay index-level gaps.
|
|
12
|
+
*/
|
|
13
|
+
export function convertAppEvent(options) {
|
|
14
|
+
const { name, key, value } = options;
|
|
15
|
+
if (!isNode(value))
|
|
16
|
+
return { type: 'not-node' };
|
|
17
|
+
const result = attachNode({
|
|
18
|
+
parentFactory: () => new ApplicationBuilder({ name }),
|
|
19
|
+
parentType: 'application',
|
|
20
|
+
parentChildRoot: 'root',
|
|
21
|
+
slot: key,
|
|
22
|
+
list: false,
|
|
23
|
+
path: [key],
|
|
24
|
+
node: value,
|
|
25
|
+
});
|
|
26
|
+
if (result.type === 'skip')
|
|
27
|
+
return result;
|
|
28
|
+
const gen = options.gen.fork();
|
|
29
|
+
const { plan } = result;
|
|
30
|
+
emitPlan({ plan, parentExpr: 'app', gen });
|
|
31
|
+
return {
|
|
32
|
+
type: 'typed',
|
|
33
|
+
code: gen.code(),
|
|
34
|
+
run: (app) => {
|
|
35
|
+
replay({ parent: app, plan });
|
|
36
|
+
},
|
|
37
|
+
gaps: result.gaps,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=app-events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-events.js","sourceRoot":"","sources":["../../../src/migrator/nodes/app-events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB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AG,EAAE,IAAI,EAAE,CAAC,CAAA;QAC/B,CAAC;QACD,IAAI,EAAE,MAAM,CAAC,IAAI;KAClB,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { type NodeGap, type NodePathSegment } from '../report.js';
|
|
2
|
+
import { type LegacyNode, type NodeSlot } from './node-shape.js';
|
|
3
|
+
import { type Accessor, type ChildRoot, type NodePlan, type ParentFactory } from './probe.js';
|
|
4
|
+
import { type Call, type Obj } from './rules/index.js';
|
|
5
|
+
/** Where a node attaches: a scratch parent factory, the parent type and the slot. */
|
|
6
|
+
export interface AttachTarget {
|
|
7
|
+
readonly parentFactory: ParentFactory;
|
|
8
|
+
/** Node type of the parent (`component.entity`, `jig.list`, `jig-actions`, `application`, …). */
|
|
9
|
+
readonly parentType: string;
|
|
10
|
+
readonly parentChildRoot: ChildRoot;
|
|
11
|
+
readonly slot: string;
|
|
12
|
+
readonly list: boolean;
|
|
13
|
+
/** Path of the node inside its entity. */
|
|
14
|
+
readonly path: readonly NodePathSegment[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A node to attach: the node itself, or a pseudo node such as a bottom panel or a
|
|
18
|
+
* screen summary, already split into input, calls and child slots.
|
|
19
|
+
*/
|
|
20
|
+
export interface NodeSpec {
|
|
21
|
+
readonly nodeType: string;
|
|
22
|
+
/** Factory input; `undefined` calls the factory without parameters. */
|
|
23
|
+
readonly input: Obj | undefined;
|
|
24
|
+
readonly calls: readonly Call[];
|
|
25
|
+
readonly slots: readonly NodeSlot[];
|
|
26
|
+
/** Where this node's built output keeps its child slots. */
|
|
27
|
+
readonly childRoot: ChildRoot;
|
|
28
|
+
/** The legacy value the built node must equal (after pruning skipped children). */
|
|
29
|
+
readonly legacy: unknown;
|
|
30
|
+
/** Fixed accessor (pseudo nodes); looked up on the parent from the node type otherwise. */
|
|
31
|
+
readonly accessor?: Accessor;
|
|
32
|
+
}
|
|
33
|
+
export type AttachResult = {
|
|
34
|
+
readonly type: 'typed';
|
|
35
|
+
readonly plan: NodePlan;
|
|
36
|
+
readonly gaps: readonly NodeGap[];
|
|
37
|
+
} | {
|
|
38
|
+
readonly type: 'skip';
|
|
39
|
+
readonly gap: NodeGap;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Attaches a split node (or pseudo node): converts its children first, against a scratch
|
|
43
|
+
* chain of its ancestors, then verifies the node with its typed children by probe and
|
|
44
|
+
* compares it with the legacy value pruned of exactly the skipped children. A list slot
|
|
45
|
+
* emptied by those skips counts as absent on both sides (see `pruneAt`).
|
|
46
|
+
*
|
|
47
|
+
* A node that does not verify is skipped with its whole subtree as one gap:
|
|
48
|
+
* `no-factory-<slot>`, `throws-<message>`, `option-<key>` (one differing option) or
|
|
49
|
+
* `output-differs`.
|
|
50
|
+
*/
|
|
51
|
+
export declare function attachSpec(options: AttachTarget & {
|
|
52
|
+
readonly spec: NodeSpec;
|
|
53
|
+
}): AttachResult;
|
|
54
|
+
/**
|
|
55
|
+
* Attaches one legacy component or action node to a parent slot (see `attachSpec`).
|
|
56
|
+
* A shape with no typed form is skipped as `shape`; a rule-rejected one as `type-rejects`.
|
|
57
|
+
*/
|
|
58
|
+
export declare function attachNode(options: AttachTarget & {
|
|
59
|
+
readonly node: LegacyNode;
|
|
60
|
+
}): AttachResult;
|
|
61
|
+
//# sourceMappingURL=attach.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attach.d.ts","sourceRoot":"","sources":["../../../src/migrator/nodes/attach.ts"],"names":[],"mappings":"AAGA,OAAO,EAAc,KAAK,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAA;AAE7E,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,QAAQ,EAAS,MAAM,iBAAiB,CAAA;AACvE,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,aAAa,EAKnB,MAAM,YAAY,CAAA;AACnB,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G;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,GAAG,YAAY,CA8E5F;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,YAAY,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;CAAE,GAAG,YAAY,CAsB9F"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
2
|
+
import { isPlainObject } from '../normalize.js';
|
|
3
|
+
import { pruneAt, pruneBuiltAt } from '../prune.js';
|
|
4
|
+
import { countNodes } from '../report.js';
|
|
5
|
+
import { firstLine, hasMethod, member, messageSlug, toJsonValue } from './builder-access.js';
|
|
6
|
+
import { split } from './node-shape.js';
|
|
7
|
+
import { probe, replay, } from './probe.js';
|
|
8
|
+
import { methodCandidates, rejects, RULES } from './rules/index.js';
|
|
9
|
+
function nodeGap(options) {
|
|
10
|
+
const { nodeType, reasonSlug, reason, legacy, path } = options;
|
|
11
|
+
return {
|
|
12
|
+
gapId: `${nodeType}:${reasonSlug}`,
|
|
13
|
+
nodeType,
|
|
14
|
+
reason,
|
|
15
|
+
skippedNodes: countNodes({ value: legacy, asRoot: true }),
|
|
16
|
+
path,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/** Finds the parent member that creates a child of `nodeType` in `slot`. */
|
|
20
|
+
function findAccessor(options) {
|
|
21
|
+
const { parent, parentType, slot, nodeType, layout } = options;
|
|
22
|
+
const ruleHolder = RULES[parentType]?.holders?.[slot];
|
|
23
|
+
const holder = ruleHolder !== undefined && member(parent, ruleHolder) !== undefined
|
|
24
|
+
? ruleHolder
|
|
25
|
+
: nodeType.startsWith('component.') && slot === 'children'
|
|
26
|
+
? 'addControl'
|
|
27
|
+
: slot;
|
|
28
|
+
const factory = member(parent, holder);
|
|
29
|
+
if (typeof factory === 'function')
|
|
30
|
+
return { holder };
|
|
31
|
+
if (!isPlainObject(factory))
|
|
32
|
+
return undefined;
|
|
33
|
+
const method = methodCandidates({ type: nodeType, layout }).find((name) => hasMethod(factory, name));
|
|
34
|
+
return method === undefined ? undefined : { holder, method };
|
|
35
|
+
}
|
|
36
|
+
/** Keys (top-level, and under `options`) whose values differ between two built nodes. */
|
|
37
|
+
function differingKeys(built, legacy) {
|
|
38
|
+
if (!isPlainObject(built) || !isPlainObject(legacy))
|
|
39
|
+
return [];
|
|
40
|
+
const differing = [];
|
|
41
|
+
const names = new Set([...Object.keys(built), ...Object.keys(legacy)]);
|
|
42
|
+
for (const name of names) {
|
|
43
|
+
if (name === 'options' && isPlainObject(built.options) && isPlainObject(legacy.options)) {
|
|
44
|
+
const builtOptions = built.options;
|
|
45
|
+
const legacyOptions = legacy.options;
|
|
46
|
+
const optionNames = new Set([...Object.keys(builtOptions), ...Object.keys(legacyOptions)]);
|
|
47
|
+
for (const option of optionNames) {
|
|
48
|
+
if (!isDeepStrictEqual(builtOptions[option], legacyOptions[option]))
|
|
49
|
+
differing.push(option);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else if (!isDeepStrictEqual(built[name], legacy[name])) {
|
|
53
|
+
differing.push(name);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return differing;
|
|
57
|
+
}
|
|
58
|
+
function childPath(options) {
|
|
59
|
+
const { path, childRoot, slot, index } = options;
|
|
60
|
+
const base = childRoot === 'options' ? [...path, 'options', slot.key] : [...path, slot.key];
|
|
61
|
+
return slot.list ? [...base, index] : base;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Attaches a split node (or pseudo node): converts its children first, against a scratch
|
|
65
|
+
* chain of its ancestors, then verifies the node with its typed children by probe and
|
|
66
|
+
* compares it with the legacy value pruned of exactly the skipped children. A list slot
|
|
67
|
+
* emptied by those skips counts as absent on both sides (see `pruneAt`).
|
|
68
|
+
*
|
|
69
|
+
* A node that does not verify is skipped with its whole subtree as one gap:
|
|
70
|
+
* `no-factory-<slot>`, `throws-<message>`, `option-<key>` (one differing option) or
|
|
71
|
+
* `output-differs`.
|
|
72
|
+
*/
|
|
73
|
+
export function attachSpec(options) {
|
|
74
|
+
const { parentFactory, parentType, parentChildRoot, slot, list, path, spec } = options;
|
|
75
|
+
const { nodeType, legacy } = spec;
|
|
76
|
+
const skip = (reasonSlug, reason) => ({
|
|
77
|
+
type: 'skip',
|
|
78
|
+
gap: nodeGap({ nodeType, reasonSlug, reason, legacy, path }),
|
|
79
|
+
});
|
|
80
|
+
let accessor = spec.accessor;
|
|
81
|
+
if (accessor === undefined) {
|
|
82
|
+
let parent;
|
|
83
|
+
try {
|
|
84
|
+
parent = parentFactory();
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return skip('parent-throws', 'the scratch parent cannot be created');
|
|
88
|
+
}
|
|
89
|
+
accessor = findAccessor({
|
|
90
|
+
parent,
|
|
91
|
+
parentType,
|
|
92
|
+
slot,
|
|
93
|
+
nodeType,
|
|
94
|
+
layout: isPlainObject(legacy) && isPlainObject(legacy.options) ? legacy.options.layout : undefined,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
if (accessor === undefined) {
|
|
98
|
+
return skip(`no-factory-${slot}`, `${parentType} has no typed factory for ${nodeType} in "${slot}"`);
|
|
99
|
+
}
|
|
100
|
+
const shallow = { nodeType, accessor, input: spec.input, calls: spec.calls, slots: [] };
|
|
101
|
+
try {
|
|
102
|
+
replay({ parent: parentFactory(), plan: shallow });
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
const line = firstLine(error);
|
|
106
|
+
return skip(`throws-${messageSlug(line)}`, `the typed call throws: ${line}`);
|
|
107
|
+
}
|
|
108
|
+
const selfFactory = () => replay({ parent: parentFactory(), plan: shallow, withChildren: false });
|
|
109
|
+
const gaps = [];
|
|
110
|
+
const slots = spec.slots.map((nodeSlot) => {
|
|
111
|
+
const items = nodeSlot.nodes.map((node, index) => {
|
|
112
|
+
const result = attachNode({
|
|
113
|
+
parentFactory: selfFactory,
|
|
114
|
+
parentType: nodeType,
|
|
115
|
+
parentChildRoot: spec.childRoot,
|
|
116
|
+
slot: nodeSlot.key,
|
|
117
|
+
list: nodeSlot.list,
|
|
118
|
+
path: childPath({ path, childRoot: spec.childRoot, slot: nodeSlot, index }),
|
|
119
|
+
node,
|
|
120
|
+
});
|
|
121
|
+
if (result.type === 'skip') {
|
|
122
|
+
gaps.push(result.gap);
|
|
123
|
+
return { type: 'skip', gap: result.gap };
|
|
124
|
+
}
|
|
125
|
+
gaps.push(...result.gaps);
|
|
126
|
+
return { type: 'typed', plan: result.plan };
|
|
127
|
+
});
|
|
128
|
+
return { key: nodeSlot.key, items };
|
|
129
|
+
});
|
|
130
|
+
const plan = { ...shallow, slots };
|
|
131
|
+
const probed = probe({ parentFactory, childRoot: parentChildRoot, slot, list, candidate: plan });
|
|
132
|
+
if (probed.type === 'error') {
|
|
133
|
+
return skip(`throws-${messageSlug(probed.message)}`, `the typed call throws: ${probed.message}`);
|
|
134
|
+
}
|
|
135
|
+
const built = pruneBuiltAt({ built: toJsonValue(probed.value), legacy, path, gaps });
|
|
136
|
+
const expected = toJsonValue(pruneAt({ value: legacy, path, gaps }));
|
|
137
|
+
if (isDeepStrictEqual(built, expected))
|
|
138
|
+
return { type: 'typed', plan, gaps };
|
|
139
|
+
const differing = differingKeys(built, expected);
|
|
140
|
+
const only = differing.length === 1 ? differing.at(0) : undefined;
|
|
141
|
+
if (only !== undefined) {
|
|
142
|
+
return skip(`option-${only}`, `the typed call builds a different "${only}"`);
|
|
143
|
+
}
|
|
144
|
+
return skip('output-differs', 'the typed call builds a different node');
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Attaches one legacy component or action node to a parent slot (see `attachSpec`).
|
|
148
|
+
* A shape with no typed form is skipped as `shape`; a rule-rejected one as `type-rejects`.
|
|
149
|
+
*/
|
|
150
|
+
export function attachNode(options) {
|
|
151
|
+
const { node, path, parentType, slot } = options;
|
|
152
|
+
const parts = split(node);
|
|
153
|
+
const skipped = (reasonSlug, reason) => ({
|
|
154
|
+
type: 'skip',
|
|
155
|
+
gap: nodeGap({ nodeType: node.type, reasonSlug, reason, legacy: node, path }),
|
|
156
|
+
});
|
|
157
|
+
if (parts.type === 'shape')
|
|
158
|
+
return skipped('shape', 'the node shape has no typed form');
|
|
159
|
+
if (rejects({ type: node.type, input: parts.input, parentType, slot })) {
|
|
160
|
+
return skipped('type-rejects', `the SDK builds this shape but its types refuse it in "${slot}"`);
|
|
161
|
+
}
|
|
162
|
+
return attachSpec({
|
|
163
|
+
...options,
|
|
164
|
+
spec: {
|
|
165
|
+
nodeType: node.type,
|
|
166
|
+
input: parts.input,
|
|
167
|
+
calls: parts.calls,
|
|
168
|
+
slots: parts.slots,
|
|
169
|
+
childRoot: 'options',
|
|
170
|
+
legacy: node,
|
|
171
|
+
},
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=attach.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attach.js","sourceRoot":"","sources":["../../../src/migrator/nodes/attach.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AACnD,OAAO,EAAE,UAAU,EAAsC,MAAM,cAAc,CAAA;AAC7E,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAC5F,OAAO,EAAkC,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACvE,OAAO,EAKL,KAAK,EACL,MAAM,GAGP,MAAM,YAAY,CAAA;AACnB,OAAO,EAAa,gBAAgB,EAAY,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAoCxF,SAAS,OAAO,CAAC,OAMhB;IACC,MAAM,EAAE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CAAC;KAC9E,CAAC,CAAA;IACF,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO;QAAE,OAAO,OAAO,CAAC,OAAO,EAAE,kCAAkC,CAAC,CAAA;IACvF,IAAI,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;QACvE,OAAO,OAAO,CAAC,cAAc,EAAE,yDAAyD,IAAI,GAAG,CAAC,CAAA;IAClG,CAAC;IACD,OAAO,UAAU,CAAC;QAChB,GAAG,OAAO;QACV,IAAI,EAAE;YACJ,QAAQ,EAAE,IAAI,CAAC,IAAI;YACnB,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,SAAS,EAAE,SAAS;YACpB,MAAM,EAAE,IAAI;SACb;KACF,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Reads a public member of a builder or factory object; `undefined` when absent. */
|
|
2
|
+
export declare function member(target: unknown, name: string): unknown;
|
|
3
|
+
/**
|
|
4
|
+
* Calls a public method by dotted path (`leftElement.icon`) with `this` bound to its owner.
|
|
5
|
+
* @throws Error when the path does not end in a function
|
|
6
|
+
*/
|
|
7
|
+
export declare function invoke(target: unknown, path: string, args: readonly unknown[]): unknown;
|
|
8
|
+
/** Whether `target` has a callable member at a dotted path. */
|
|
9
|
+
export declare function hasMethod(target: unknown, path: string): boolean;
|
|
10
|
+
/** JSON round trip: the form a built Application takes in `build/output.json`. */
|
|
11
|
+
export declare function toJsonValue(value: unknown): unknown;
|
|
12
|
+
/** One-line summary of an error: the first Zod issue, or the first line of its message. */
|
|
13
|
+
export declare function firstLine(error: unknown): string;
|
|
14
|
+
/** Short, stable gap-id slug of an error message: lower-case words joined by `-`, at most 40 chars. */
|
|
15
|
+
export declare function messageSlug(message: string): string;
|
|
16
|
+
//# sourceMappingURL=builder-access.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builder-access.d.ts","sourceRoot":"","sources":["../../../src/migrator/nodes/builder-access.ts"],"names":[],"mappings":"AAUA,qFAAqF;AACrF,wBAAgB,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAI7D;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,OAAO,EAAE,GAAG,OAAO,CASvF;AAED,+DAA+D;AAC/D,wBAAgB,SAAS,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAIhE;AAED,kFAAkF;AAClF,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAInD;AAeD,2FAA2F;AAC3F,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAGhD;AAED,uGAAuG;AACvG,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAcnD"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// Reflective access to core-sdk builders by member name.
|
|
2
|
+
//
|
|
3
|
+
// The engine probes builders whose concrete type is only known at run time (the
|
|
4
|
+
// legacy node type picks the factory), so it reads and calls their public members
|
|
5
|
+
// by name. Results stay `unknown`; nothing here reaches into protected state.
|
|
6
|
+
function isObjectLike(value) {
|
|
7
|
+
return (typeof value === 'object' && value !== null) || typeof value === 'function';
|
|
8
|
+
}
|
|
9
|
+
/** Reads a public member of a builder or factory object; `undefined` when absent. */
|
|
10
|
+
export function member(target, name) {
|
|
11
|
+
if (!isObjectLike(target))
|
|
12
|
+
return undefined;
|
|
13
|
+
const value = Reflect.get(target, name);
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Calls a public method by dotted path (`leftElement.icon`) with `this` bound to its owner.
|
|
18
|
+
* @throws Error when the path does not end in a function
|
|
19
|
+
*/
|
|
20
|
+
export function invoke(target, path, args) {
|
|
21
|
+
const segments = path.split('.');
|
|
22
|
+
const name = segments.pop() ?? '';
|
|
23
|
+
let owner = target;
|
|
24
|
+
for (const segment of segments)
|
|
25
|
+
owner = member(owner, segment);
|
|
26
|
+
const fn = member(owner, name);
|
|
27
|
+
if (typeof fn !== 'function')
|
|
28
|
+
throw new Error(`No method "${path}"`);
|
|
29
|
+
const result = Reflect.apply(fn, owner, args);
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
/** Whether `target` has a callable member at a dotted path. */
|
|
33
|
+
export function hasMethod(target, path) {
|
|
34
|
+
let owner = target;
|
|
35
|
+
for (const segment of path.split('.'))
|
|
36
|
+
owner = member(owner, segment);
|
|
37
|
+
return typeof owner === 'function';
|
|
38
|
+
}
|
|
39
|
+
/** JSON round trip: the form a built Application takes in `build/output.json`. */
|
|
40
|
+
export function toJsonValue(value) {
|
|
41
|
+
const text = JSON.stringify(value ?? null);
|
|
42
|
+
const parsed = JSON.parse(text);
|
|
43
|
+
return parsed;
|
|
44
|
+
}
|
|
45
|
+
/** Message of the first issue of a Zod error (its `message` is the JSON issue list). */
|
|
46
|
+
function zodIssueMessage(message) {
|
|
47
|
+
if (!message.startsWith('['))
|
|
48
|
+
return undefined;
|
|
49
|
+
try {
|
|
50
|
+
const issues = JSON.parse(message);
|
|
51
|
+
const list = Array.isArray(issues) ? issues : [];
|
|
52
|
+
const text = member(list.at(0), 'message');
|
|
53
|
+
return typeof text === 'string' ? text : undefined;
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/** One-line summary of an error: the first Zod issue, or the first line of its message. */
|
|
60
|
+
export function firstLine(error) {
|
|
61
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
62
|
+
return zodIssueMessage(message) ?? message.split('\n').at(0) ?? message;
|
|
63
|
+
}
|
|
64
|
+
/** Short, stable gap-id slug of an error message: lower-case words joined by `-`, at most 40 chars. */
|
|
65
|
+
export function messageSlug(message) {
|
|
66
|
+
const words = message
|
|
67
|
+
.toLowerCase()
|
|
68
|
+
.replace(/[^a-z0-9]+/g, ' ')
|
|
69
|
+
.trim()
|
|
70
|
+
.split(' ')
|
|
71
|
+
.filter((word) => word.length > 0);
|
|
72
|
+
let out = '';
|
|
73
|
+
for (const word of words) {
|
|
74
|
+
const next = out ? `${out}-${word}` : word;
|
|
75
|
+
if (next.length > 40)
|
|
76
|
+
break;
|
|
77
|
+
out = next;
|
|
78
|
+
}
|
|
79
|
+
return out || 'error';
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=builder-access.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builder-access.js","sourceRoot":"","sources":["../../../src/migrator/nodes/builder-access.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,EAAE;AACF,gFAAgF;AAChF,kFAAkF;AAClF,8EAA8E;AAE9E,SAAS,YAAY,CAAC,KAAc;IAClC,OAAO,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC,IAAI,OAAO,KAAK,KAAK,UAAU,CAAA;AACrF,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,MAAM,CAAC,MAAe,EAAE,IAAY;IAClD,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC;QAAE,OAAO,SAAS,CAAA;IAC3C,MAAM,KAAK,GAAY,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IAChD,OAAO,KAAK,CAAA;AACd,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,MAAM,CAAC,MAAe,EAAE,IAAY,EAAE,IAAwB;IAC5E,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA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CAAC;IACD,OAAO,GAAG,IAAI,OAAO,CAAA;AACvB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type NodePlan } from './probe.js';
|
|
2
|
+
/**
|
|
3
|
+
* Generated-code buffer for one module: statement chunks plus variable naming
|
|
4
|
+
* (`c1`, `a2`, `panel3`, `summary4`). Forks share the variable counter, so chunks
|
|
5
|
+
* generated separately for one module never reuse a name.
|
|
6
|
+
*/
|
|
7
|
+
export declare class Gen {
|
|
8
|
+
readonly lines: string[];
|
|
9
|
+
readonly indent = " ";
|
|
10
|
+
private readonly counter;
|
|
11
|
+
constructor(counter?: {
|
|
12
|
+
value: number;
|
|
13
|
+
});
|
|
14
|
+
/** Returns the next free variable name with the given prefix. */
|
|
15
|
+
nextVar(prefix: string): string;
|
|
16
|
+
/** Appends one statement chunk (continuation lines carry their own indent). */
|
|
17
|
+
push(chunk: string): void;
|
|
18
|
+
/** An empty buffer that shares this buffer's variable counter. */
|
|
19
|
+
fork(): Gen;
|
|
20
|
+
/** The chunks as one `register`-body statement: every chunk after the first gets the body indent. */
|
|
21
|
+
code(): string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Prints a verified plan under `parentExpr`: the factory call with chained calls, then
|
|
25
|
+
* unchained calls and children on its variable. Skipped children become
|
|
26
|
+
* `// TODO(migrate)` comments in their legacy position.
|
|
27
|
+
*/
|
|
28
|
+
export declare function emitPlan(options: {
|
|
29
|
+
readonly plan: NodePlan;
|
|
30
|
+
readonly parentExpr: string;
|
|
31
|
+
readonly gen: Gen;
|
|
32
|
+
}): void;
|
|
33
|
+
//# sourceMappingURL=codegen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codegen.d.ts","sourceRoot":"","sources":["../../../src/migrator/nodes/codegen.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAA;AAK1C;;;;GAIG;AACH,qBAAa,GAAG;IACd,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,CAAK;IAC7B,QAAQ,CAAC,MAAM,QAAc;IAC7B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmB;IAE3C,YAAY,OAAO,GAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAiB,EAEpD;IAED,iEAAiE;IACjE,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAG9B;IAED,+EAA+E;IAC/E,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAExB;IAED,kEAAkE;IAClE,IAAI,IAAI,GAAG,CAEV;IAED,qGAAqG;IACrG,IAAI,IAAI,MAAM,CAEb;CACF;AAUD;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE;IAChC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;IACvB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAA;CAClB,GAAG,IAAI,CA2BP"}
|