@elementumai/edk 0.9.7 → 0.9.9
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 +3 -2
- package/dist-sdk/src/catalog/factories.d.ts +14 -3
- package/dist-sdk/src/catalog/factories.js +32 -0
- package/dist-sdk/src/catalog/from-authoring.js +27 -33
- package/dist-sdk/src/catalog/index.d.ts +2 -2
- package/dist-sdk/src/catalog/index.js +2 -2
- package/dist-sdk/src/catalog/org.js +67 -29
- package/dist-sdk/src/catalog/token.js +10 -0
- package/dist-sdk/src/catalog/types.d.ts +20 -2
- package/dist-sdk/src/catalog/types.js +5 -0
- package/dist-sdk/src/core/index.d.ts +1 -1
- package/dist-sdk/src/core/index.js +1 -1
- package/dist-sdk/src/core/platform-id.d.ts +2 -0
- package/dist-sdk/src/core/platform-id.js +4 -0
- package/dist-sdk/src/core/system-fields.d.ts +14 -0
- package/dist-sdk/src/core/system-fields.js +6 -0
- package/dist-sdk/src/core/triggers/on-demand.d.ts +27 -24
- package/dist-sdk/src/core/triggers/on-demand.js +33 -12
- package/dist-sdk/src/core/types/aspect-category.d.ts +1 -0
- package/dist-sdk/src/core/types/aspect-category.js +1 -0
- package/dist-sdk/src/engine/build/context.d.ts +20 -8
- package/dist-sdk/src/engine/build/source-context.d.ts +14 -17
- package/dist-sdk/src/engine/build/source-context.js +1 -1
- package/dist-sdk/src/engine/pull/context.d.ts +9 -0
- package/dist-sdk/src/engine/pull/org.d.ts +4 -0
- package/dist-sdk/src/engine/pull/org.js +17 -2
- package/dist-sdk/src/engine/pull/procedure-refs.d.ts +16 -0
- package/dist-sdk/src/engine/pull/procedure-refs.js +69 -0
- package/dist-sdk/src/engine/tf/expr.js +1 -1
- package/dist-sdk/src/engine/workspace/authoring-layout.d.ts +15 -0
- package/dist-sdk/src/engine/workspace/authoring-layout.js +33 -1
- package/dist-sdk/src/engine/workspace/loader.d.ts +40 -0
- package/dist-sdk/src/engine/workspace/loader.js +328 -0
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +4 -0
- package/dist-sdk/src/entities/access-policy/from-tf.js +10 -2
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/access-policy/to-tf.js +7 -2
- package/dist-sdk/src/entities/agent/build.d.ts +54 -8
- package/dist-sdk/src/entities/agent/build.js +36 -1
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +126 -2
- package/dist-sdk/src/entities/agent/from-tf.d.ts +7 -6
- package/dist-sdk/src/entities/agent/from-tf.js +176 -5
- package/dist-sdk/src/entities/agent/index.d.ts +2 -2
- package/dist-sdk/src/entities/agent/index.js +1 -1
- package/dist-sdk/src/entities/agent/to-tf.d.ts +4 -4
- package/dist-sdk/src/entities/agent/to-tf.js +185 -11
- package/dist-sdk/src/entities/agent/tools.d.ts +16 -5
- package/dist-sdk/src/entities/agent/tools.js +13 -1
- package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +7 -0
- package/dist-sdk/src/entities/agent-tool/from-tf.js +29 -4
- package/dist-sdk/src/entities/agent-tool/to-tf.js +10 -9
- package/dist-sdk/src/entities/agent-tool/types.js +1 -0
- package/dist-sdk/src/entities/app/build.d.ts +2 -2
- package/dist-sdk/src/entities/app/build.js +6 -3
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +5 -0
- package/dist-sdk/src/entities/app/display-blocks-to-layout.d.ts +45 -0
- package/dist-sdk/src/entities/app/display-blocks-to-layout.js +98 -0
- package/dist-sdk/src/entities/app/display-blocks-to-record-create-form.d.ts +55 -0
- package/dist-sdk/src/entities/app/display-blocks-to-record-create-form.js +99 -0
- package/dist-sdk/src/entities/app/from-tf.js +9 -7
- package/dist-sdk/src/entities/app/to-tf.js +15 -7
- package/dist-sdk/src/entities/automation/build.d.ts +8 -1
- package/dist-sdk/src/entities/automation/build.js +36 -5
- package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +3 -7
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +2 -0
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +77 -8
- package/dist-sdk/src/entities/automation/from-tf.d.ts +10 -1
- package/dist-sdk/src/entities/automation/from-tf.js +803 -62
- package/dist-sdk/src/entities/automation/index.d.ts +1 -1
- package/dist-sdk/src/entities/automation/module.js +13 -3
- package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +12 -4
- package/dist-sdk/src/entities/automation/output-key-wire-name.js +17 -6
- package/dist-sdk/src/entities/automation/script-code.d.ts +1 -1
- package/dist-sdk/src/entities/automation/script-code.js +15 -11
- package/dist-sdk/src/entities/automation/task-label.d.ts +2 -0
- package/dist-sdk/src/entities/automation/task-label.js +18 -0
- package/dist-sdk/src/entities/automation/tasks.d.ts +60 -9
- package/dist-sdk/src/entities/automation/tasks.js +16 -4
- package/dist-sdk/src/entities/automation/to-tf.d.ts +4 -0
- package/dist-sdk/src/entities/automation/to-tf.js +385 -52
- package/dist-sdk/src/entities/automation/triggers.d.ts +14 -5
- package/dist-sdk/src/entities/automation/triggers.js +1 -1
- package/dist-sdk/src/entities/dashboard/from-tf.js +1 -1
- package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +1 -1
- package/dist-sdk/src/entities/element/build.d.ts +30 -7
- package/dist-sdk/src/entities/element/build.js +6 -3
- package/dist-sdk/src/entities/element/from-tf.js +7 -3
- package/dist-sdk/src/entities/element/index.d.ts +1 -1
- package/dist-sdk/src/entities/element/index.js +1 -1
- package/dist-sdk/src/entities/element/to-tf.js +49 -8
- package/dist-sdk/src/entities/field/from-tf.d.ts +6 -0
- package/dist-sdk/src/entities/field/from-tf.js +12 -0
- package/dist-sdk/src/entities/field/module.js +1 -0
- package/dist-sdk/src/entities/field/to-tf.d.ts +1 -1
- package/dist-sdk/src/entities/field/to-tf.js +19 -5
- package/dist-sdk/src/entities/org/category-ref.d.ts +5 -0
- package/dist-sdk/src/entities/org/category-ref.js +12 -0
- package/dist-sdk/src/entities/record-create-form/from-tf.js +3 -3
- package/dist-sdk/src/entities/record-create-form/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/record-create-form/to-tf.js +13 -5
- package/dist-sdk/src/entities/relationship/from-tf.js +15 -4
- package/dist-sdk/src/entities/role/from-tf.js +10 -4
- package/dist-sdk/src/entities/search-table/build.d.ts +1 -1
- package/dist-sdk/src/entities/search-table/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/search-table/from-tf.js +6 -0
- package/dist-sdk/src/entities/search-table/printer.js +3 -1
- package/dist-sdk/src/entities/search-table/to-tf.js +3 -3
- package/dist-sdk/src/entities/search-table/types.js +1 -0
- package/dist-sdk/src/entities/service-account/from-tf.js +10 -4
- package/dist-sdk/src/entities/service-account/to-tf.d.ts +2 -1
- package/dist-sdk/src/entities/service-account/to-tf.js +7 -0
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +7 -1
- package/dist-sdk/src/entities/shared/filters/ast.js +3 -0
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +7 -1
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +8 -4
- package/dist-sdk/src/entities/shared/handle-description.d.ts +12 -0
- package/dist-sdk/src/entities/shared/handle-description.js +20 -0
- package/dist-sdk/src/entities/shared/types/field-types.d.ts +6 -1
- package/dist-sdk/src/entities/shared/types/field-types.js +5 -8
- package/dist-sdk/src/entities/skill/build.d.ts +51 -2
- package/dist-sdk/src/entities/skill/build.js +65 -8
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +35 -3
- package/dist-sdk/src/entities/skill/from-tf.d.ts +11 -0
- package/dist-sdk/src/entities/skill/from-tf.js +39 -7
- package/dist-sdk/src/entities/skill/index.d.ts +1 -1
- package/dist-sdk/src/entities/skill/index.js +1 -1
- package/dist-sdk/src/entities/skill/input-coverage.d.ts +21 -0
- package/dist-sdk/src/entities/skill/input-coverage.js +148 -5
- package/dist-sdk/src/entities/skill/to-tf.d.ts +6 -25
- package/dist-sdk/src/entities/skill/to-tf.js +22 -38
- package/dist-sdk/src/entities/skill/tools.d.ts +2 -1
- package/dist-sdk/src/entities/skill/tools.js +3 -1
- package/dist-sdk/src/entities/skill-tool/from-tf.js +10 -3
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +5 -5
- package/dist-sdk/src/entities/skill-tool/to-tf.js +5 -7
- package/dist-sdk/src/entities/table/to-tf.js +3 -4
- package/dist-sdk/src/entities/task/to-tf.js +3 -2
- package/dist-sdk/src/entities/view/from-tf.js +36 -10
- package/dist-sdk/src/entities/view/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/view/to-tf.js +44 -30
- package/dist-sdk/src/entities/widget/from-tf.js +2 -2
- package/dist-sdk/src/entities/widget/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/widget/to-tf.js +52 -23
- package/dist-sdk/src/graph/index.d.ts +19 -1
- package/dist-sdk/src/graph/index.js +20 -0
- package/dist-sdk/src/graph/types.d.ts +19 -0
- package/package.json +10 -5
|
@@ -5,21 +5,33 @@
|
|
|
5
5
|
* Each input becomes a ServiceTaskParam that downstream tasks can
|
|
6
6
|
* reference via ctx.trigger.<paramName>.
|
|
7
7
|
*/
|
|
8
|
+
import type { AppOrElementRef } from "../../catalog/types.js";
|
|
9
|
+
import type { RecordShape } from "../../entities/field/record-shape.js";
|
|
8
10
|
import type { FieldTypeToTS, TriggerFieldTypeAlias } from "../../entities/shared/types/field-types.js";
|
|
9
11
|
import type { User } from "../types/platform.js";
|
|
10
12
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* Mobius lifts the restriction.
|
|
13
|
+
* Scalar `type` values are constrained to the aliases Mobius accepts.
|
|
14
|
+
* A `record` input additionally requires the app/element whose record is
|
|
15
|
+
* expected; that target supplies both its typed RecordShape and HCL default.
|
|
15
16
|
*/
|
|
16
|
-
|
|
17
|
-
type: TriggerFieldTypeAlias;
|
|
17
|
+
interface TriggerInputFieldDefBase {
|
|
18
18
|
required?: boolean;
|
|
19
|
+
description?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface ScalarTriggerInputFieldDef extends TriggerInputFieldDefBase {
|
|
22
|
+
type: Exclude<TriggerFieldTypeAlias, "record">;
|
|
19
23
|
multiple?: boolean;
|
|
20
24
|
defaultValue?: unknown;
|
|
21
|
-
|
|
25
|
+
app?: never;
|
|
22
26
|
}
|
|
27
|
+
export interface RecordTriggerInputFieldDef<A extends AppOrElementRef = AppOrElementRef> extends TriggerInputFieldDefBase {
|
|
28
|
+
type: "record";
|
|
29
|
+
/** App or element whose record this input accepts; supplies the HCL default and typed record shape. */
|
|
30
|
+
app: A;
|
|
31
|
+
multiple?: false;
|
|
32
|
+
defaultValue?: never;
|
|
33
|
+
}
|
|
34
|
+
export type TriggerInputFieldDef = ScalarTriggerInputFieldDef | RecordTriggerInputFieldDef;
|
|
23
35
|
/**
|
|
24
36
|
* Schema object mapping field names to their definitions.
|
|
25
37
|
* Example:
|
|
@@ -31,16 +43,11 @@ export type TriggerInputSchema = Record<string, TriggerInputFieldDef>;
|
|
|
31
43
|
* `false`; when true, the built-in `triggeredBy` parameter is
|
|
32
44
|
* referenceable from tasks via `ctx.trigger.triggeredBy` and the
|
|
33
45
|
* conditional in {@link InferTriggerType} adds it to the typed context.
|
|
46
|
+
*
|
|
47
|
+
* Record-detail context is a schema entry (`type: "record"`), not an option.
|
|
34
48
|
*/
|
|
35
49
|
export interface OnDemandTriggerOptions {
|
|
36
50
|
showTriggeredBy?: boolean;
|
|
37
|
-
/**
|
|
38
|
-
* When true, this on-demand automation is invoked against a specific
|
|
39
|
-
* record, and the invoking record is exposed as `ctx.trigger.record` —
|
|
40
|
-
* the same loosely-typed shape record-event triggers expose. Purely a
|
|
41
|
-
* typing declaration; the platform doesn't require a matching wire flag.
|
|
42
|
-
*/
|
|
43
|
-
record?: boolean;
|
|
44
51
|
}
|
|
45
52
|
/**
|
|
46
53
|
* Given a TriggerInputSchema, derive the TypeScript object type
|
|
@@ -52,21 +59,16 @@ export interface OnDemandTriggerOptions {
|
|
|
52
59
|
* with full type safety. When omitted or `false`, the key is absent
|
|
53
60
|
* and the reference is a `tsc` error.
|
|
54
61
|
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* `ctx.trigger.record` — used for on-demand automations invoked against a
|
|
58
|
-
* specific record.
|
|
62
|
+
* Record entries preserve both their authored parameter key and target
|
|
63
|
+
* app/element, so `ctx.trigger.<name>` has that target's RecordShape.
|
|
59
64
|
*/
|
|
65
|
+
type TriggerInputFieldToTS<D extends TriggerInputFieldDef> = D extends RecordTriggerInputFieldDef<infer A> ? RecordShape<A> : FieldTypeToTS<D["type"]>;
|
|
60
66
|
export type InferTriggerType<S extends TriggerInputSchema, Options extends OnDemandTriggerOptions = {}> = {
|
|
61
|
-
[K in keyof S]:
|
|
67
|
+
[K in keyof S]: TriggerInputFieldToTS<S[K]>;
|
|
62
68
|
} & (Options extends {
|
|
63
69
|
showTriggeredBy: true;
|
|
64
70
|
} ? {
|
|
65
71
|
triggeredBy: User;
|
|
66
|
-
} : {}) & (Options extends {
|
|
67
|
-
record: true;
|
|
68
|
-
} ? {
|
|
69
|
-
record: Record<string, unknown>;
|
|
70
72
|
} : {});
|
|
71
73
|
export interface OnDemandTriggerDef<T, S extends TriggerInputSchema = TriggerInputSchema> {
|
|
72
74
|
readonly kind: "onDemand";
|
|
@@ -90,7 +92,7 @@ export interface OnDemandTriggerDef<T, S extends TriggerInputSchema = TriggerInp
|
|
|
90
92
|
* })
|
|
91
93
|
* ```
|
|
92
94
|
*/
|
|
93
|
-
export declare function onDemand<S extends TriggerInputSchema, Options extends OnDemandTriggerOptions = {}>(schema: S, options?: Options): OnDemandTriggerDef<InferTriggerType<S, Options>, S>;
|
|
95
|
+
export declare function onDemand<S extends TriggerInputSchema, Options extends OnDemandTriggerOptions = {}>(schema: S, options?: Options & Record<Exclude<keyof Options, keyof OnDemandTriggerOptions>, never>): OnDemandTriggerDef<InferTriggerType<S, Options>, S>;
|
|
94
96
|
/**
|
|
95
97
|
* Wire shape for an onDemand `defaultValue`. Mirrors mobius's
|
|
96
98
|
* `WorkflowTriggerParameterDefaultValueInput` Java record — a
|
|
@@ -136,6 +138,7 @@ export interface SerializedOnDemandTrigger {
|
|
|
136
138
|
required: boolean;
|
|
137
139
|
multiple: boolean;
|
|
138
140
|
defaultValue?: WireDefaultValue;
|
|
141
|
+
app?: AppOrElementRef;
|
|
139
142
|
}>;
|
|
140
143
|
showTriggeredBy?: boolean;
|
|
141
144
|
};
|
|
@@ -82,6 +82,9 @@ function wrapDefaultValueForWire(alias, value) {
|
|
|
82
82
|
return { userId: value };
|
|
83
83
|
case "attachmentId":
|
|
84
84
|
return { attachmentId: value };
|
|
85
|
+
case "record":
|
|
86
|
+
throw new Error(`onDemand input default values are not supported for type "record". ` +
|
|
87
|
+
`Build supplies the explicitly targeted app/element id as the parameter default.`);
|
|
85
88
|
case "json":
|
|
86
89
|
case "object":
|
|
87
90
|
throw new Error(`onDemand input default values are not supported for type "${alias}". ` +
|
|
@@ -91,18 +94,36 @@ function wrapDefaultValueForWire(alias, value) {
|
|
|
91
94
|
}
|
|
92
95
|
}
|
|
93
96
|
export function serializeOnDemandTrigger(schema, options) {
|
|
94
|
-
const inputs = Object.entries(schema).map(([name, def]) =>
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
97
|
+
const inputs = Object.entries(schema).map(([name, def]) => {
|
|
98
|
+
if (def.type === "record") {
|
|
99
|
+
const runtimeDef = def;
|
|
100
|
+
if (runtimeDef.multiple === true) {
|
|
101
|
+
throw new Error(`On-demand record input "${name}" cannot be multiple`);
|
|
102
|
+
}
|
|
103
|
+
if (runtimeDef.defaultValue !== undefined) {
|
|
104
|
+
throw new Error(`On-demand record input "${name}" cannot declare a defaultValue`);
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
name,
|
|
108
|
+
type: FIELD_TYPE_MAP[def.type],
|
|
109
|
+
required: def.required ?? false,
|
|
110
|
+
multiple: false,
|
|
111
|
+
app: def.app,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
name,
|
|
116
|
+
type: FIELD_TYPE_MAP[def.type],
|
|
117
|
+
required: def.required ?? false,
|
|
118
|
+
multiple: def.multiple ?? false,
|
|
119
|
+
// Skip when the user didn't set a default. The wire's omission
|
|
120
|
+
// and `null` aren't the same — `null` would still try to
|
|
121
|
+
// construct the wrapper record and fail.
|
|
122
|
+
...(def.defaultValue === undefined
|
|
123
|
+
? {}
|
|
124
|
+
: { defaultValue: wrapDefaultValueForWire(def.type, def.defaultValue) }),
|
|
125
|
+
};
|
|
126
|
+
});
|
|
106
127
|
return {
|
|
107
128
|
onDemand: {
|
|
108
129
|
inputs,
|
|
@@ -22,25 +22,31 @@ export interface ResolvedForeignRoot {
|
|
|
22
22
|
* `"categories"`, …) — the engine never names a specific org identity kind.
|
|
23
23
|
* Entity to-tf passes the bag it authors against.
|
|
24
24
|
*/
|
|
25
|
+
/**
|
|
26
|
+
* A resolved org-identity address. `managed` means the identity is created in
|
|
27
|
+
* this build from `organization.ts` — callers must emit a resource attribute,
|
|
28
|
+
* not a data lookup (a data source can only see something already live).
|
|
29
|
+
*/
|
|
30
|
+
export interface OrgRefResolution {
|
|
31
|
+
readonly tfLabel: string;
|
|
32
|
+
readonly managed?: true;
|
|
33
|
+
}
|
|
25
34
|
export interface OrgRefLookup {
|
|
26
35
|
/** Resolve a root reference according to its graph-declared referenceLookups strategy. */
|
|
27
36
|
resolveForeignRoot(kind: KindId, identity: ForeignRootIdentity, options?: {
|
|
28
37
|
readonly record?: boolean;
|
|
29
38
|
}): ResolvedForeignRoot;
|
|
30
39
|
/**
|
|
31
|
-
* Resolve by org.ts bag key (tsLabel). Records a data block when found
|
|
40
|
+
* Resolve by org.ts bag key (tsLabel). Records a data block when found
|
|
41
|
+
* unless the hit is `managed` (authored in organization.ts this build).
|
|
32
42
|
* Used by token-bearing refs (cloud links, connectors, …).
|
|
33
43
|
*/
|
|
34
|
-
byTsLabel(bag: string, tsLabel: string):
|
|
35
|
-
readonly tfLabel: string;
|
|
36
|
-
} | undefined;
|
|
44
|
+
byTsLabel(bag: string, tsLabel: string): OrgRefResolution | undefined;
|
|
37
45
|
/**
|
|
38
46
|
* Resolve by display name within a bag. Used when authoring carries a plain
|
|
39
47
|
* name (categories today) rather than a catalog token.
|
|
40
48
|
*/
|
|
41
|
-
byName(bag: string, name: string):
|
|
42
|
-
readonly tfLabel: string;
|
|
43
|
-
} | undefined;
|
|
49
|
+
byName(bag: string, name: string): OrgRefResolution | undefined;
|
|
44
50
|
/** Legacy typed convenience routed through app's graph-declared root strategy. */
|
|
45
51
|
foreignApp(tfLabel: string, name: string, namespace?: string): void;
|
|
46
52
|
/**
|
|
@@ -76,10 +82,16 @@ export interface OrgRefLookup {
|
|
|
76
82
|
*/
|
|
77
83
|
foreignField(type: string, tfLabel: string, objectId: TfValue, name: string): void;
|
|
78
84
|
}
|
|
79
|
-
/** A stream root discovered elsewhere in THIS workspace build
|
|
85
|
+
/** A stream root discovered elsewhere in THIS workspace build, keyed by {@link workspaceAspectKey}. */
|
|
80
86
|
export interface WorkspaceAspect {
|
|
81
87
|
readonly kind: ChildResourceScope | "table";
|
|
82
88
|
readonly tfLabel: string;
|
|
89
|
+
/** ACTIVE authored automations owned by this root, keyed by source refName with their display name. */
|
|
90
|
+
readonly activeAutomationNamesByRefName?: ReadonlyMap<string, string>;
|
|
91
|
+
/** Sole on-demand record parameter targeting this same owner, keyed by automation refName, for CURRENT_RECORD widget binding. */
|
|
92
|
+
readonly onDemandRecordParamByAutomationRefName?: ReadonlyMap<string, string>;
|
|
93
|
+
/** Terraform labels of datamines managed by a table in this workspace. */
|
|
94
|
+
readonly managedDatamineLabels?: ReadonlySet<string>;
|
|
83
95
|
}
|
|
84
96
|
/**
|
|
85
97
|
* Key for the `workspaceAspects` map: an app and an element MAY share a
|
|
@@ -1,29 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Generic "what file is
|
|
3
|
-
*
|
|
2
|
+
* Generic "what file is the workspace loader currently importing, and what is
|
|
3
|
+
* its own on-disk text" context for `elementum build`'s own-file-child loader.
|
|
4
4
|
*
|
|
5
5
|
* Entity-agnostic on purpose: `engine/` may not import from `entities/`
|
|
6
6
|
* (`__tests__/engine/no-entity-types-in-engine.test.ts`), so this exists
|
|
7
7
|
* purely as plumbing — it knows nothing about automations or any other
|
|
8
8
|
* entity kind. An entity module (e.g. `entities/automation/script-code.ts`)
|
|
9
|
-
* that needs
|
|
10
|
-
*
|
|
11
|
-
* imports {@link currentSourceText} from here (entities/
|
|
12
|
-
* the normal direction; only the reverse is forbidden).
|
|
9
|
+
* that needs the file's real text — a `toString()` on a loaded function
|
|
10
|
+
* returns source with every type annotation blanked out by Node's type
|
|
11
|
+
* stripping — imports {@link currentSourceText} from here (entities/
|
|
12
|
+
* importing engine/ is the normal direction; only the reverse is forbidden).
|
|
13
13
|
*
|
|
14
14
|
* State lives on `globalThis` (via a `Symbol.for` registry key), not a plain
|
|
15
15
|
* module-scoped variable, for two independent reasons:
|
|
16
|
-
* - `AsyncLocalStorage` was tried first and rejected:
|
|
17
|
-
*
|
|
18
|
-
* scheduling, which does not reliably propagate ALS continuation context
|
|
19
|
-
* through to where the imported module's top-level code actually runs
|
|
16
|
+
* - `AsyncLocalStorage` was tried first and rejected: the continuation
|
|
17
|
+
* context did not reliably reach the imported module's top-level code
|
|
20
18
|
* (confirmed empirically — that version silently lost context there).
|
|
21
|
-
* - A plain module-scoped variable has a SEPARATE failure mode:
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* (natively-loaded) code holds, so writes through one are invisible to
|
|
19
|
+
* - A plain module-scoped variable has a SEPARATE failure mode: the same
|
|
20
|
+
* module can be instantiated twice in one process whenever something
|
|
21
|
+
* other than plain Node also loads it — Vitest's module runner is the
|
|
22
|
+
* live example, since the workspace loader is externalized and the test
|
|
23
|
+
* file's own imports are not. Writes through one copy are invisible to
|
|
27
24
|
* reads through the other. `globalThis` is the one thing guaranteed
|
|
28
25
|
* shared across however many separate module instances end up loaded in
|
|
29
26
|
* the same process.
|
|
@@ -37,7 +34,7 @@ export interface SourceTextContext {
|
|
|
37
34
|
readonly text: string;
|
|
38
35
|
}
|
|
39
36
|
/**
|
|
40
|
-
* Run `fn` (a
|
|
37
|
+
* Run `fn` (a workspace module import) with `filePath`'s own text available via
|
|
41
38
|
* {@link currentSourceText} for the duration of the returned promise.
|
|
42
39
|
*/
|
|
43
40
|
export declare function withSourceText<T>(filePath: string, text: string, fn: () => Promise<T>): Promise<T>;
|
|
@@ -3,7 +3,7 @@ function slot() {
|
|
|
3
3
|
return globalThis;
|
|
4
4
|
}
|
|
5
5
|
/**
|
|
6
|
-
* Run `fn` (a
|
|
6
|
+
* Run `fn` (a workspace module import) with `filePath`'s own text available via
|
|
7
7
|
* {@link currentSourceText} for the duration of the returned promise.
|
|
8
8
|
*/
|
|
9
9
|
export async function withSourceText(filePath, text, fn) {
|
|
@@ -65,6 +65,15 @@ export interface FromTfContext {
|
|
|
65
65
|
}>;
|
|
66
66
|
/** Lower-cased field display name -> typed field key for each on-disk app/element catalog. */
|
|
67
67
|
readonly fieldNamesByOwnerRefName?: ReadonlyMap<string, ReadonlyMap<string, string>>;
|
|
68
|
+
/**
|
|
69
|
+
* Procedure discriminator (CloudLink + name + database + schema + ordered
|
|
70
|
+
* parameter types, via `procedureDiscriminator` in `pull/procedure-refs.ts`)
|
|
71
|
+
* → the already-pulled org catalog's disambiguated procedure bag key. Lets
|
|
72
|
+
* an automation's Run Function task reconstruct the exact overload
|
|
73
|
+
* `src/catalog/org.ts` assigned instead of the base sanitized name, which
|
|
74
|
+
* only the FIRST same-name procedure under a CloudLink actually owns.
|
|
75
|
+
*/
|
|
76
|
+
readonly procedureKeysByDiscriminator?: ReadonlyMap<string, string>;
|
|
68
77
|
/**
|
|
69
78
|
* Foreign app/element display names this stream saw referenced (currently:
|
|
70
79
|
* a RELATION field's `related_object_id` as a `data.elementum_app`/
|
|
@@ -42,6 +42,8 @@ export interface OrgIdentity {
|
|
|
42
42
|
export interface OrgStoredFunction {
|
|
43
43
|
readonly cloudLinkName: string;
|
|
44
44
|
readonly name: string;
|
|
45
|
+
readonly databaseName: string;
|
|
46
|
+
readonly schemaName: string;
|
|
45
47
|
readonly functionType: string;
|
|
46
48
|
readonly configured: boolean;
|
|
47
49
|
readonly parameterTypes: readonly string[];
|
|
@@ -55,6 +57,8 @@ export interface OrgExtract {
|
|
|
55
57
|
readonly groups: readonly OrgIdentity[];
|
|
56
58
|
readonly phoneProviders: readonly OrgIdentity[];
|
|
57
59
|
readonly storedFunctions?: readonly OrgStoredFunction[];
|
|
60
|
+
/** Non-fatal export anomalies; callers report these and continue the pull. */
|
|
61
|
+
readonly diagnostics?: readonly string[];
|
|
58
62
|
/** The org app directory (namespace → platform id) from locals.org_apps. */
|
|
59
63
|
readonly apps: Readonly<Record<string, string>>;
|
|
60
64
|
}
|
|
@@ -81,14 +81,27 @@ export function extractOrg(doc) {
|
|
|
81
81
|
if (apps === undefined) {
|
|
82
82
|
throw new OrgExtractError("org export stream has no locals.org_apps — is this really an org export?");
|
|
83
83
|
}
|
|
84
|
+
const connectors = withTsLabels(raw.connectors);
|
|
85
|
+
const aiProviders = withTsLabels(raw.aiProviders);
|
|
86
|
+
const providerRefs = new Set(aiProviders.map((provider) => `${provider.resourceType}.${provider.tfLabel}`));
|
|
87
|
+
const diagnostics = connectors.flatMap((connector) => {
|
|
88
|
+
if (connector.providerRef === undefined) {
|
|
89
|
+
return [`connector "${connector.name}" (${connector.tfLabel}) has no resolved provider reference; skipped`];
|
|
90
|
+
}
|
|
91
|
+
const providerRefKey = `${connector.providerRef.resourceType}.${connector.providerRef.tfLabel}`;
|
|
92
|
+
return providerRefs.has(providerRefKey)
|
|
93
|
+
? []
|
|
94
|
+
: [`connector "${connector.name}" (${connector.tfLabel}) references provider "${providerRefKey}" which was not exported; skipped`];
|
|
95
|
+
});
|
|
84
96
|
return {
|
|
85
97
|
cloudLinks: withTsLabels(raw.cloudLinks),
|
|
86
98
|
categories: withTsLabels(raw.categories),
|
|
87
|
-
connectors
|
|
88
|
-
aiProviders
|
|
99
|
+
connectors,
|
|
100
|
+
aiProviders,
|
|
89
101
|
groups: withTsLabels(raw.groups),
|
|
90
102
|
phoneProviders: withTsLabels(raw.phoneProviders),
|
|
91
103
|
storedFunctions,
|
|
104
|
+
diagnostics,
|
|
92
105
|
apps,
|
|
93
106
|
};
|
|
94
107
|
}
|
|
@@ -113,6 +126,8 @@ function requireStoredFunctions(value) {
|
|
|
113
126
|
return {
|
|
114
127
|
cloudLinkName: stringValue("cloud_link_name"),
|
|
115
128
|
name: stringValue("name"),
|
|
129
|
+
databaseName: stringValue("database_name"),
|
|
130
|
+
schemaName: stringValue("schema_name"),
|
|
116
131
|
functionType: stringValue("function_type"),
|
|
117
132
|
configured: row.configured,
|
|
118
133
|
parameterTypes: row.parameter_types,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CloudLink display name + exact Snowflake signature → one discriminator
|
|
3
|
+
* string. Shared by the org.ts reader below and
|
|
4
|
+
* `entities/automation/from-tf.ts`'s `elementum_stored_function` decode
|
|
5
|
+
* branch — both MUST derive it the same way, or a pulled reference silently
|
|
6
|
+
* resolves to the wrong overload's key.
|
|
7
|
+
*/
|
|
8
|
+
export declare function procedureDiscriminator(cloudLinkName: string, name: string, database: string, schema: string, parameterTypes: readonly string[]): string;
|
|
9
|
+
/**
|
|
10
|
+
* Discriminator → the org catalog's disambiguated procedure bag key, read
|
|
11
|
+
* back from the already-pulled `<orgRoot>/org.ts`. Empty when org.ts is
|
|
12
|
+
* missing or carries no procedures — callers degrade to the base
|
|
13
|
+
* `sanitizeName` key, which is already correct whenever there's no
|
|
14
|
+
* same-name overload to disambiguate.
|
|
15
|
+
*/
|
|
16
|
+
export declare function loadProcedureCatalogKeys(orgRoot: string): Promise<ReadonlyMap<string, string>>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve a pulled automation's Run Function `procedure` task to the exact
|
|
3
|
+
* catalog bag key `src/catalog/org.ts` assigned it — `uniqueCatalogKey`
|
|
4
|
+
* there disambiguates same-name overloaded Snowflake procedures with a
|
|
5
|
+
* numeric suffix (`shippingRate`, `shippingRate2`, …) across the WHOLE
|
|
6
|
+
* CloudLink's procedure list, a decision `entities/automation/from-tf.ts`
|
|
7
|
+
* cannot reconstruct from one `data.elementum_stored_function` block alone.
|
|
8
|
+
*
|
|
9
|
+
* `elementum pull app`/`pull element` both require a prior `pull org
|
|
10
|
+
* --data-only` (org.ts is a hard prerequisite), so the already-pulled
|
|
11
|
+
* org.ts always carries the current, authoritative key assignment. Loading
|
|
12
|
+
* it through the same native workspace loader `elementum build` uses for
|
|
13
|
+
* the same file (`engine/build/build.ts`'s `loadOrgRefs`) gives back real
|
|
14
|
+
* `ProcedureRef` objects — no text parsing, no drift from the renderer's
|
|
15
|
+
* exact output format.
|
|
16
|
+
*/
|
|
17
|
+
import { existsSync } from "node:fs";
|
|
18
|
+
import { join } from "node:path";
|
|
19
|
+
import { createWorkspaceLoader } from "../workspace/loader.js";
|
|
20
|
+
/**
|
|
21
|
+
* CloudLink display name + exact Snowflake signature → one discriminator
|
|
22
|
+
* string. Shared by the org.ts reader below and
|
|
23
|
+
* `entities/automation/from-tf.ts`'s `elementum_stored_function` decode
|
|
24
|
+
* branch — both MUST derive it the same way, or a pulled reference silently
|
|
25
|
+
* resolves to the wrong overload's key.
|
|
26
|
+
*/
|
|
27
|
+
export function procedureDiscriminator(cloudLinkName, name, database, schema, parameterTypes) {
|
|
28
|
+
return [cloudLinkName, name, database, schema, parameterTypes.join(",")].join("\0");
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Discriminator → the org catalog's disambiguated procedure bag key, read
|
|
32
|
+
* back from the already-pulled `<orgRoot>/org.ts`. Empty when org.ts is
|
|
33
|
+
* missing or carries no procedures — callers degrade to the base
|
|
34
|
+
* `sanitizeName` key, which is already correct whenever there's no
|
|
35
|
+
* same-name overload to disambiguate.
|
|
36
|
+
*/
|
|
37
|
+
export async function loadProcedureCatalogKeys(orgRoot) {
|
|
38
|
+
const map = new Map();
|
|
39
|
+
const orgPath = join(orgRoot, "org.ts");
|
|
40
|
+
if (!existsSync(orgPath))
|
|
41
|
+
return map;
|
|
42
|
+
let mod;
|
|
43
|
+
try {
|
|
44
|
+
mod = (await createWorkspaceLoader(orgRoot).import(orgPath));
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
// A broken/unparseable org.ts is reported loudly by pull app's own
|
|
48
|
+
// earlier sentinel checks elsewhere; degrade quietly here rather than
|
|
49
|
+
// pile a second failure onto an unrelated resolution step.
|
|
50
|
+
return map;
|
|
51
|
+
}
|
|
52
|
+
for (const cloudLink of Object.values(mod.org?.cloudLinks ?? {})) {
|
|
53
|
+
const cloudLinkName = cloudLink.name;
|
|
54
|
+
if (typeof cloudLinkName !== "string")
|
|
55
|
+
continue;
|
|
56
|
+
for (const [key, procedure] of Object.entries(cloudLink.procedures ?? {})) {
|
|
57
|
+
const { name, databaseName, schemaName, parameterTypes } = procedure;
|
|
58
|
+
if (typeof name !== "string" ||
|
|
59
|
+
typeof databaseName !== "string" ||
|
|
60
|
+
typeof schemaName !== "string" ||
|
|
61
|
+
!Array.isArray(parameterTypes) ||
|
|
62
|
+
!parameterTypes.every((p) => typeof p === "string")) {
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
map.set(procedureDiscriminator(cloudLinkName, name, databaseName, schemaName, parameterTypes), key);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return map;
|
|
69
|
+
}
|
|
@@ -110,9 +110,9 @@ export function parseExpression(src, options = {}) {
|
|
|
110
110
|
}
|
|
111
111
|
const IDENT_RE = /^[A-Za-z_][A-Za-z0-9_-]*/;
|
|
112
112
|
class Parser {
|
|
113
|
+
pos = 0;
|
|
113
114
|
src;
|
|
114
115
|
options;
|
|
115
|
-
pos = 0;
|
|
116
116
|
constructor(src, options) {
|
|
117
117
|
this.src = src;
|
|
118
118
|
this.options = options;
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Driver/helper convention: underscore-prefixed source files are helpers, except
|
|
3
|
+
* digit-leading entity refs where ei's SanitizeName leading `_` survives into the
|
|
4
|
+
* tsLabel (`_1GenerateJson` from `1. Generate JSON`). Those remain discoverable
|
|
5
|
+
* own-file children — see issue #751.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isAuthoringHelperFile(fileName: string): boolean;
|
|
1
8
|
export interface AuthoringTenantContext {
|
|
2
9
|
/** Organization slug from `ei auth` (folder basename). */
|
|
3
10
|
readonly organization: string;
|
|
@@ -11,6 +18,14 @@ export declare function findOrgWorkspaceByTsconfig(startDir: string): string | u
|
|
|
11
18
|
* Example: `elements/tag/tag.ts`, `apps/incident/automations/triage.ts`.
|
|
12
19
|
*/
|
|
13
20
|
export declare function assertRelativeAuthoringPath(relPath: string): void;
|
|
21
|
+
/**
|
|
22
|
+
* True for stream-root authoring files only — `apps/<ref>/<ref>.ts`,
|
|
23
|
+
* `elements/<ref>/<ref>.ts`, or `tables/<ref>/<ref>.ts`. Own-file children
|
|
24
|
+
* under a bag (`automations/`, `agents/`, …) are excluded so catalog
|
|
25
|
+
* regeneration does not treat them as stream roots when passed an app/element
|
|
26
|
+
* directory (issue #751).
|
|
27
|
+
*/
|
|
28
|
+
export declare function isStreamRootAuthoringFile(file: string): boolean;
|
|
14
29
|
/**
|
|
15
30
|
* Org root directory must be `<org>` or `<instance>/<org>` for this tenant.
|
|
16
31
|
*/
|
|
@@ -39,6 +39,20 @@ const CHILD_BAGS = new Set([
|
|
|
39
39
|
]);
|
|
40
40
|
/** Instance folder names used in multi-instance parent workspaces. */
|
|
41
41
|
const INSTANCE_FOLDER_NAMES = new Set(["us", "eu", "stage", "dev", "local"]);
|
|
42
|
+
/**
|
|
43
|
+
* Driver/helper convention: underscore-prefixed source files are helpers, except
|
|
44
|
+
* digit-leading entity refs where ei's SanitizeName leading `_` survives into the
|
|
45
|
+
* tsLabel (`_1GenerateJson` from `1. Generate JSON`). Those remain discoverable
|
|
46
|
+
* own-file children — see issue #751.
|
|
47
|
+
*/
|
|
48
|
+
export function isAuthoringHelperFile(fileName) {
|
|
49
|
+
const base = basename(fileName);
|
|
50
|
+
if (!base.startsWith("_"))
|
|
51
|
+
return false;
|
|
52
|
+
const stem = base.replace(/\.(ts|js|mjs)$/, "");
|
|
53
|
+
// `_1Foo`, `_3_1Bar` — managed entity refs, not helpers.
|
|
54
|
+
return !/^\d/.test(stem.slice(1));
|
|
55
|
+
}
|
|
42
56
|
/** Walk up from `startDir` to the nearest directory that contains `tsconfig.json`. */
|
|
43
57
|
export function findOrgWorkspaceByTsconfig(startDir) {
|
|
44
58
|
let cur = resolve(startDir);
|
|
@@ -65,7 +79,7 @@ export function assertRelativeAuthoringPath(relPath) {
|
|
|
65
79
|
if (!/\.(ts|js|mjs)$/.test(file) || file.endsWith(".d.ts") || file.endsWith(".test.ts")) {
|
|
66
80
|
throw new Error(`Not an entity source file: ${relPath}`);
|
|
67
81
|
}
|
|
68
|
-
if (file
|
|
82
|
+
if (isAuthoringHelperFile(file)) {
|
|
69
83
|
throw new Error(`Not an entity source file: ${relPath}`);
|
|
70
84
|
}
|
|
71
85
|
const stem = file.replace(/\.(ts|js|mjs)$/, "");
|
|
@@ -112,6 +126,24 @@ export function assertRelativeAuthoringPath(relPath) {
|
|
|
112
126
|
}
|
|
113
127
|
throw new Error(`Authoring path is too deep or malformed: ${rel}`);
|
|
114
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* True for stream-root authoring files only — `apps/<ref>/<ref>.ts`,
|
|
131
|
+
* `elements/<ref>/<ref>.ts`, or `tables/<ref>/<ref>.ts`. Own-file children
|
|
132
|
+
* under a bag (`automations/`, `agents/`, …) are excluded so catalog
|
|
133
|
+
* regeneration does not treat them as stream roots when passed an app/element
|
|
134
|
+
* directory (issue #751).
|
|
135
|
+
*/
|
|
136
|
+
export function isStreamRootAuthoringFile(file) {
|
|
137
|
+
const normalized = resolve(file).replace(/\.(ts|js|mjs)$/, "");
|
|
138
|
+
const parts = normalized.split(sep);
|
|
139
|
+
const rootIdx = Math.max(parts.lastIndexOf("apps"), parts.lastIndexOf("elements"), parts.lastIndexOf("tables"));
|
|
140
|
+
if (rootIdx === -1)
|
|
141
|
+
return false;
|
|
142
|
+
const after = parts.slice(rootIdx);
|
|
143
|
+
if (after.length !== 3)
|
|
144
|
+
return false;
|
|
145
|
+
return after[1] === after[2];
|
|
146
|
+
}
|
|
115
147
|
/**
|
|
116
148
|
* Org root directory must be `<org>` or `<instance>/<org>` for this tenant.
|
|
117
149
|
*/
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve an installed SDK subpath from the package's ESM export map.
|
|
3
|
+
*
|
|
4
|
+
* The Bun fallback transforms authored ESM to CommonJS. Most imports enter
|
|
5
|
+
* through `jiti.import` and use ESM conditions, but the generated org barrel
|
|
6
|
+
* deliberately uses `createRequire` to break catalog cycles. A per-entity
|
|
7
|
+
* catalog reached through that getter is therefore evaluated on jiti's
|
|
8
|
+
* require path, which cannot resolve this ESM-only package (`exports` has an
|
|
9
|
+
* `import` condition, not `require`). Pointing that one public subpath at its
|
|
10
|
+
* exported file preserves the package boundary without adding a misleading
|
|
11
|
+
* CommonJS export to the SDK.
|
|
12
|
+
*/
|
|
13
|
+
export declare function findInstalledSdkSubpath(root: string, subpath: string): string | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Upgrade the short-lived #730 barrel shape before Bun/jiti evaluates it.
|
|
16
|
+
* Generated catalogs are CLI-owned, and this writes exactly the lazy-require
|
|
17
|
+
* form emitted by the current generator. Without the migration an existing
|
|
18
|
+
* workspace remains unloadable even after installing the fixed binary.
|
|
19
|
+
*/
|
|
20
|
+
export declare function upgradeGeneratedCatalogForJiti(root: string): void;
|
|
21
|
+
export interface WorkspaceLoader {
|
|
22
|
+
/**
|
|
23
|
+
* Import an authored workspace file. Repeated imports of the same file
|
|
24
|
+
* through the SAME loader return the same module; a new loader re-evaluates.
|
|
25
|
+
*
|
|
26
|
+
* Native imports are serialized process-wide. The generation stamp lives on
|
|
27
|
+
* a process global the resolve hook reads, the same constraint
|
|
28
|
+
* `withSourceText` documents. The generation id is assigned on first
|
|
29
|
+
* `import()`, not on construction, so creating a loader (canvas debounce)
|
|
30
|
+
* cannot change an in-flight graph's stamp.
|
|
31
|
+
*/
|
|
32
|
+
import(file: string): Promise<{
|
|
33
|
+
default?: unknown;
|
|
34
|
+
}>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* A loader scoped to one org root and one generation. Create one per build —
|
|
38
|
+
* that is what makes a rebuild see edited files.
|
|
39
|
+
*/
|
|
40
|
+
export declare function createWorkspaceLoader(orgRoot: string): WorkspaceLoader;
|