@elementumai/edk 0.9.6 → 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 +34 -3
- package/dist-sdk/src/catalog/factories.d.ts +26 -6
- package/dist-sdk/src/catalog/factories.js +41 -6
- 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 +93 -42
- package/dist-sdk/src/catalog/token.js +10 -0
- package/dist-sdk/src/catalog/types.d.ts +42 -3
- package/dist-sdk/src/catalog/types.js +5 -0
- package/dist-sdk/src/core/index.d.ts +2 -2
- 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 +18 -0
- package/dist-sdk/src/core/system-fields.js +21 -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/app.d.ts +14 -9
- 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/core/types/platform.d.ts +1 -1
- package/dist-sdk/src/engine/build/context.d.ts +24 -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 +18 -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/pull/ref-only.d.ts +14 -0
- package/dist-sdk/src/engine/pull/ref-only.js +35 -2
- 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 +24 -4
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +7 -0
- package/dist-sdk/src/entities/access-policy/to-tf.js +11 -3
- 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 +144 -3
- 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/module.js +1 -0
- package/dist-sdk/src/entities/agent/to-tf.d.ts +5 -4
- package/dist-sdk/src/entities/agent/to-tf.js +186 -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 +16 -0
- package/dist-sdk/src/entities/agent-tool/from-tf.js +39 -6
- package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/agent-tool/to-tf.js +12 -12
- package/dist-sdk/src/entities/agent-tool/types.js +1 -0
- package/dist-sdk/src/entities/app/build.d.ts +44 -24
- package/dist-sdk/src/entities/app/build.js +18 -8
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +15 -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 +79 -14
- package/dist-sdk/src/entities/app/index.d.ts +3 -2
- package/dist-sdk/src/entities/app/index.js +2 -1
- package/dist-sdk/src/entities/app/to-tf.js +30 -6
- package/dist-sdk/src/entities/automation/build.d.ts +37 -18
- package/dist-sdk/src/entities/automation/build.js +121 -12
- package/dist-sdk/src/entities/automation/catalog-render.js +5 -2
- package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +8 -10
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +2 -0
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +103 -20
- package/dist-sdk/src/entities/automation/from-tf.d.ts +10 -1
- package/dist-sdk/src/entities/automation/from-tf.js +1165 -91
- package/dist-sdk/src/entities/automation/index.d.ts +1 -1
- package/dist-sdk/src/entities/automation/module.js +15 -5
- package/dist-sdk/src/entities/automation/operators.d.ts +2 -2
- package/dist-sdk/src/entities/automation/operators.js +1 -0
- package/dist-sdk/src/entities/automation/output-field-types.d.ts +17 -0
- package/dist-sdk/src/entities/automation/output-field-types.js +45 -0
- package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +20 -4
- package/dist-sdk/src/entities/automation/output-key-wire-name.js +33 -6
- package/dist-sdk/src/entities/automation/script-code.d.ts +1 -1
- package/dist-sdk/src/entities/automation/script-code.js +168 -36
- 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 +159 -45
- package/dist-sdk/src/entities/automation/tasks.js +60 -47
- package/dist-sdk/src/entities/automation/to-tf.d.ts +7 -1
- package/dist-sdk/src/entities/automation/to-tf.js +816 -87
- 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/automation/value-ref-tf.d.ts +78 -0
- package/dist-sdk/src/entities/automation/value-ref-tf.js +193 -0
- 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 +7 -3
- package/dist-sdk/src/entities/element/from-tf.js +7 -3
- package/dist-sdk/src/entities/element/index.d.ts +3 -2
- package/dist-sdk/src/entities/element/index.js +3 -2
- package/dist-sdk/src/entities/element/to-tf.js +49 -8
- package/dist-sdk/src/entities/field/build.d.ts +94 -3
- package/dist-sdk/src/entities/field/build.js +82 -3
- package/dist-sdk/src/entities/field/from-tf.d.ts +6 -0
- package/dist-sdk/src/entities/field/from-tf.js +104 -1
- package/dist-sdk/src/entities/field/locals.js +6 -7
- package/dist-sdk/src/entities/field/module.js +1 -0
- package/dist-sdk/src/entities/field/options.d.ts +2 -0
- package/dist-sdk/src/entities/field/options.js +12 -2
- package/dist-sdk/src/entities/field/record-shape.d.ts +12 -15
- package/dist-sdk/src/entities/field/to-tf.d.ts +13 -3
- package/dist-sdk/src/entities/field/to-tf.js +191 -56
- package/dist-sdk/src/entities/field/types.js +2 -0
- 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 +18 -13
- package/dist-sdk/src/entities/relationship/from-tf.js +100 -7
- 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/aspect-target-from-tf.d.ts +9 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +39 -0
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +24 -1
- package/dist-sdk/src/entities/shared/filters/ast.js +4 -0
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +13 -2
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +14 -8
- 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/tool-field-ref.d.ts +5 -3
- package/dist-sdk/src/entities/shared/tool-field-ref.js +11 -16
- package/dist-sdk/src/entities/shared/types/common.d.ts +7 -5
- 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/shared/types/platform.d.ts +15 -2
- 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.d.ts +1 -1
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +79 -18
- package/dist-sdk/src/entities/skill/from-tf.d.ts +11 -0
- package/dist-sdk/src/entities/skill/from-tf.js +47 -5
- 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 +89 -0
- package/dist-sdk/src/entities/skill/input-coverage.js +327 -0
- package/dist-sdk/src/entities/skill/module.js +2 -0
- package/dist-sdk/src/entities/skill/to-tf.d.ts +9 -25
- package/dist-sdk/src/entities/skill/to-tf.js +29 -40
- package/dist-sdk/src/entities/skill/tools.d.ts +12 -2
- package/dist-sdk/src/entities/skill/tools.js +3 -6
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +19 -0
- package/dist-sdk/src/entities/skill-tool/from-tf.js +50 -14
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +9 -7
- package/dist-sdk/src/entities/skill-tool/to-tf.js +29 -23
- package/dist-sdk/src/entities/table/to-tf.js +21 -5
- 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 +49 -30
- package/dist-sdk/src/entities/visual-flow/from-tf.js +6 -2
- 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 +22 -0
- package/package.json +11 -5
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* Regenerate the shared org catalog barrel (`generated/catalog.ts`): imports
|
|
3
3
|
* every app's, element's, and table's own per-entity `generated/catalog.ts`
|
|
4
4
|
* (written by `writeAppCatalog`/`writeAppCatalogFromAuthoring`) and exposes
|
|
5
|
-
* apps/elements flat plus tables under `catalog.tables
|
|
6
|
-
*
|
|
5
|
+
* apps/elements flat plus tables under both `catalog.tables` and `org.tables`
|
|
6
|
+
* (printers emit `org.tables.*`; automations historically use `catalog.tables.*`),
|
|
7
|
+
* alongside org AI providers/cloud links. `import catalog from "@catalog"` gives
|
|
7
8
|
* `catalog.testingAles`, `catalog.tables.orders`,
|
|
8
9
|
* `catalog.aiProviders.anthropic.models.claudeOpus_4_6`, etc.
|
|
9
10
|
*
|
|
@@ -66,13 +67,17 @@ function renderOrgTs(extract) {
|
|
|
66
67
|
// (`aiProviders.<provider>.models.<model>`), rendered specially here.
|
|
67
68
|
const aiProvidersLines = renderAiProvidersBag(extract);
|
|
68
69
|
const supportedFunctionsByCloudLink = new Map();
|
|
70
|
+
const supportedProceduresByCloudLink = new Map();
|
|
69
71
|
for (const fn of extract.storedFunctions ?? []) {
|
|
70
72
|
const mapped = supportedStoredFunction(fn);
|
|
71
73
|
if (mapped === undefined)
|
|
72
74
|
continue;
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
const target = fn.functionType === "PROCEDURE"
|
|
76
|
+
? supportedProceduresByCloudLink
|
|
77
|
+
: supportedFunctionsByCloudLink;
|
|
78
|
+
const entries = target.get(fn.cloudLinkName) ?? [];
|
|
79
|
+
entries.push({ fn, mapped });
|
|
80
|
+
target.set(fn.cloudLinkName, entries);
|
|
76
81
|
}
|
|
77
82
|
const factories = new Set(["orgCatalog", ...bags.map((b) => b.factory)]);
|
|
78
83
|
if (aiProvidersLines.length > 0) {
|
|
@@ -81,6 +86,8 @@ function renderOrgTs(extract) {
|
|
|
81
86
|
}
|
|
82
87
|
if (supportedFunctionsByCloudLink.size > 0)
|
|
83
88
|
factories.add("storedFunctionRef");
|
|
89
|
+
if (supportedProceduresByCloudLink.size > 0)
|
|
90
|
+
factories.add("procedureRef");
|
|
84
91
|
const lines = [
|
|
85
92
|
"// Org reference identities from `elementum pull org --data-only` — refresh by re-running it.",
|
|
86
93
|
"// Each key IS the identity's terraform label in camelCase: tfLabel = tsLabelToTfLabel(key)",
|
|
@@ -98,20 +105,31 @@ function renderOrgTs(extract) {
|
|
|
98
105
|
continue;
|
|
99
106
|
}
|
|
100
107
|
const functions = supportedFunctionsByCloudLink.get(e.name) ?? [];
|
|
101
|
-
|
|
108
|
+
const procedures = supportedProceduresByCloudLink.get(e.name) ?? [];
|
|
109
|
+
if (functions.length === 0 && procedures.length === 0) {
|
|
102
110
|
lines.push(` ${e.tsLabel}: ${factory}({ name: ${q(e.name)} }),`);
|
|
103
111
|
continue;
|
|
104
112
|
}
|
|
105
|
-
lines.push(` ${e.tsLabel}: ${factory}({ name: ${q(e.name)}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
+
lines.push(` ${e.tsLabel}: ${factory}({ name: ${q(e.name)},`);
|
|
114
|
+
if (functions.length > 0) {
|
|
115
|
+
lines.push(" storedFunctions: {");
|
|
116
|
+
const used = new Set();
|
|
117
|
+
for (const { fn, mapped } of functions) {
|
|
118
|
+
const key = uniqueCatalogKey(tfLabelToTsLabel(sanitizeName(fn.name)), used);
|
|
119
|
+
lines.push(` ${key}: storedFunctionRef({ name: ${q(fn.name)}, parameters: ${JSON.stringify(mapped.parameters)}, result: ${q(mapped.result)} }),`);
|
|
120
|
+
}
|
|
121
|
+
lines.push(" },");
|
|
113
122
|
}
|
|
114
|
-
|
|
123
|
+
if (procedures.length > 0) {
|
|
124
|
+
lines.push(" procedures: {");
|
|
125
|
+
const used = new Set();
|
|
126
|
+
for (const { fn, mapped } of procedures) {
|
|
127
|
+
const key = uniqueCatalogKey(tfLabelToTsLabel(sanitizeName(fn.name)), used);
|
|
128
|
+
lines.push(` ${key}: procedureRef({ name: ${q(fn.name)}, database: ${q(fn.databaseName)}, schema: ${q(fn.schemaName)}, parameters: ${JSON.stringify(fn.parameterTypes)}, result: ${q(mapped.result)} }),`);
|
|
129
|
+
}
|
|
130
|
+
lines.push(" },");
|
|
131
|
+
}
|
|
132
|
+
lines.push(" }),");
|
|
115
133
|
}
|
|
116
134
|
lines.push(" },");
|
|
117
135
|
}
|
|
@@ -132,12 +150,14 @@ const STORED_FUNCTION_TYPE = {
|
|
|
132
150
|
BINARY: undefined,
|
|
133
151
|
};
|
|
134
152
|
function supportedStoredFunction(fn) {
|
|
135
|
-
const
|
|
153
|
+
const knownKind = fn.functionType === "USER_DEFINED_FUNCTION" || fn.functionType === "PROCEDURE";
|
|
154
|
+
const problem = !knownKind ? `type ${fn.functionType}`
|
|
136
155
|
: !fn.configured ? "not configured"
|
|
137
156
|
: fn.returnType === "TABLE" ? "table result"
|
|
138
|
-
:
|
|
139
|
-
: fn.
|
|
140
|
-
: undefined
|
|
157
|
+
: fn.functionType === "PROCEDURE" && fn.parameterTypes.includes("AUTO_INCREMENT") ? "unsupported procedure argument AUTO_INCREMENT"
|
|
158
|
+
: STORED_FUNCTION_TYPE[fn.returnType] === undefined ? `unsupported result ${fn.returnType}`
|
|
159
|
+
: fn.parameterTypes.some((type) => STORED_FUNCTION_TYPE[type] === undefined) ? `unsupported argument in ${fn.parameterTypes.join(", ")}`
|
|
160
|
+
: undefined;
|
|
141
161
|
if (problem !== undefined) {
|
|
142
162
|
console.error(`[elementum] skipping stored function ${fn.name}: ${problem}`);
|
|
143
163
|
return undefined;
|
|
@@ -154,9 +174,9 @@ function supportedStoredFunction(fn) {
|
|
|
154
174
|
* independently derived from `name`/`model_name` (never split out of the
|
|
155
175
|
* connector's combined tfLabel) and cross-checked against the recorded
|
|
156
176
|
* tfLabel — a mismatch means ei's label construction drifted from this
|
|
157
|
-
* derivation.
|
|
158
|
-
*
|
|
159
|
-
*
|
|
177
|
+
* derivation. Connectors without a resolved provider are reported by
|
|
178
|
+
* `extractOrg` and skipped here because they cannot be represented safely in
|
|
179
|
+
* the nested public catalog.
|
|
160
180
|
*/
|
|
161
181
|
function renderAiProvidersBag(extract) {
|
|
162
182
|
if (extract.aiProviders.length === 0)
|
|
@@ -168,12 +188,12 @@ function renderAiProvidersBag(extract) {
|
|
|
168
188
|
const modelsByProviderKey = new Map();
|
|
169
189
|
for (const connector of extract.connectors) {
|
|
170
190
|
if (connector.providerRef === undefined) {
|
|
171
|
-
|
|
191
|
+
continue;
|
|
172
192
|
}
|
|
173
193
|
const providerRefKey = `${connector.providerRef.resourceType}.${connector.providerRef.tfLabel}`;
|
|
174
194
|
const provider = providerByRef.get(providerRefKey);
|
|
175
195
|
if (provider === undefined) {
|
|
176
|
-
|
|
196
|
+
continue;
|
|
177
197
|
}
|
|
178
198
|
const providerKey = tfLabelToTsLabel(sanitizeName(provider.name));
|
|
179
199
|
const modelKey = tfLabelToTsLabel(sanitizeName(connector.name));
|
|
@@ -226,7 +246,7 @@ function renderAiProvidersBag(extract) {
|
|
|
226
246
|
* importing file's own entry, so a static import here would statically
|
|
227
247
|
* import that file's own per-entity catalog, which itself statically
|
|
228
248
|
* imports the file currently mid-evaluation — a genuine circular require
|
|
229
|
-
* (confirmed live:
|
|
249
|
+
* (confirmed live: CJS semantics hand back a partial, `export
|
|
230
250
|
* default`-less module, and `.ref()` on it throws). A lazy getter defers
|
|
231
251
|
* that whole chain until the property is actually READ, by which point
|
|
232
252
|
* the importing file's own module evaluation has moved past the point of
|
|
@@ -239,16 +259,27 @@ function renderBarrel(appHandles, elementHandles, tableHandles) {
|
|
|
239
259
|
const elementKeys = computeElementKeys(appHandles, elementHandles);
|
|
240
260
|
const hasLazyEntries = appHandles.length > 0 || elementHandles.length > 0 || tableHandles.length > 0;
|
|
241
261
|
const lines = [
|
|
242
|
-
|
|
262
|
+
// Alias so we can re-export `org` with the pulled `tables` bag attached —
|
|
263
|
+
// table printers emit `org.tables.*` while automations historically use
|
|
264
|
+
// `catalog.tables.*`. Both must resolve the same lazy getters.
|
|
265
|
+
'import { org as orgIdentities } from "../org.js";',
|
|
243
266
|
'import { usersCatalog } from "@elementumai/edk/catalog";',
|
|
244
267
|
"",
|
|
245
268
|
];
|
|
246
269
|
if (hasLazyEntries) {
|
|
247
|
-
// A
|
|
248
|
-
//
|
|
249
|
-
//
|
|
250
|
-
//
|
|
251
|
-
|
|
270
|
+
// A synchronous require for the lazy getters below. Native ESM uses
|
|
271
|
+
// createRequire; the Bun binary's jiti fallback supplies its own require,
|
|
272
|
+
// which must win there so nested generated catalogs stay inside jiti's
|
|
273
|
+
// resolver. An import would eagerly pull every per-entity catalog into
|
|
274
|
+
// this module's evaluation and reintroduce the self-reference cycle.
|
|
275
|
+
lines.push('import { createRequire } from "node:module";', "");
|
|
276
|
+
lines.push('const catalogRequire = (globalThis as { Bun?: unknown }).Bun !== undefined && typeof require === "function"', " ? require", " : createRequire(import.meta.url);", "");
|
|
277
|
+
}
|
|
278
|
+
if (tableHandles.length > 0) {
|
|
279
|
+
lines.push("const tables = {");
|
|
280
|
+
for (const h of tableHandles)
|
|
281
|
+
lines.push(...lazyAspectGetter(safeKey(h), `../tables/${h}/generated/catalog.js`, "default", " "));
|
|
282
|
+
lines.push("};", "");
|
|
252
283
|
}
|
|
253
284
|
lines.push("const catalog = {");
|
|
254
285
|
for (const h of appHandles)
|
|
@@ -257,18 +288,21 @@ function renderBarrel(appHandles, elementHandles, tableHandles) {
|
|
|
257
288
|
lines.push(...lazyAspectGetter(elementKeys.get(h), `../elements/${h}/generated/catalog.js`, h));
|
|
258
289
|
}
|
|
259
290
|
lines.push(" users: usersCatalog,");
|
|
260
|
-
lines.push(" aiProviders:
|
|
261
|
-
lines.push(" cloudLinks:
|
|
262
|
-
lines.push(" categories:
|
|
263
|
-
lines.push(" groups:
|
|
264
|
-
lines.push(" phoneProviders:
|
|
291
|
+
lines.push(" aiProviders: orgIdentities.aiProviders,");
|
|
292
|
+
lines.push(" cloudLinks: orgIdentities.cloudLinks,");
|
|
293
|
+
lines.push(" categories: orgIdentities.categories,");
|
|
294
|
+
lines.push(" groups: orgIdentities.groups,");
|
|
295
|
+
lines.push(" phoneProviders: orgIdentities.phoneProviders,");
|
|
296
|
+
if (tableHandles.length > 0)
|
|
297
|
+
lines.push(" tables,");
|
|
298
|
+
lines.push("};");
|
|
265
299
|
if (tableHandles.length > 0) {
|
|
266
|
-
lines.push("
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
lines.push("
|
|
300
|
+
lines.push("", "const org = { ...orgIdentities, tables };", "export { org };");
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
lines.push("", "export { orgIdentities as org };");
|
|
270
304
|
}
|
|
271
|
-
lines.push("
|
|
305
|
+
lines.push("export type Ref = typeof catalog;", "export default catalog;", "");
|
|
272
306
|
return lines.join("\n");
|
|
273
307
|
}
|
|
274
308
|
/**
|
|
@@ -279,7 +313,7 @@ function renderBarrel(appHandles, elementHandles, tableHandles) {
|
|
|
279
313
|
function lazyAspectGetter(key, importPath, exportName, indent = " ") {
|
|
280
314
|
const quoted = JSON.stringify(importPath);
|
|
281
315
|
return [
|
|
282
|
-
`${indent}get ${key}() { return (
|
|
316
|
+
`${indent}get ${key}() { return (catalogRequire(${quoted}) as typeof import(${quoted})).${exportName}; },`,
|
|
283
317
|
];
|
|
284
318
|
}
|
|
285
319
|
/** An app and an element MAY share a handle — expose the element under a disambiguated key, warning once. */
|
|
@@ -340,6 +374,23 @@ async function discoverOrgRootHandles(root) {
|
|
|
340
374
|
function q(s) {
|
|
341
375
|
return JSON.stringify(s);
|
|
342
376
|
}
|
|
377
|
+
/**
|
|
378
|
+
* Disambiguate a catalog bag key against sibling keys already used in the
|
|
379
|
+
* same bag, appending numeric suffixes (`base`, `base2`, `base3`, …) — the
|
|
380
|
+
* same dedupe rule `withUniqueKeys` (`pull/util.ts`) applies elsewhere in the
|
|
381
|
+
* codebase. Needed because overloaded Snowflake stored functions/procedures
|
|
382
|
+
* (same name, distinct parameter signature) derive the same `sanitizeName`
|
|
383
|
+
* base; each still carries its own exact `name`/`database`/`schema`/
|
|
384
|
+
* `parameters` in the emitted ref, so only the bag KEY needs disambiguating.
|
|
385
|
+
*/
|
|
386
|
+
function uniqueCatalogKey(base, used) {
|
|
387
|
+
let key = base;
|
|
388
|
+
let i = 2;
|
|
389
|
+
while (used.has(key))
|
|
390
|
+
key = `${base}${i++}`;
|
|
391
|
+
used.add(key);
|
|
392
|
+
return key;
|
|
393
|
+
}
|
|
343
394
|
const RESERVED_IDENT = new Set([
|
|
344
395
|
"break", "case", "catch", "class", "const", "continue", "debugger", "default",
|
|
345
396
|
"delete", "do", "else", "export", "extends", "false", "finally", "for",
|
|
@@ -56,6 +56,16 @@ export function slimToken(token) {
|
|
|
56
56
|
// task build.
|
|
57
57
|
if (token.__kind === "documentModel" && typeof token.readerType === "string")
|
|
58
58
|
out.readerType = token.readerType;
|
|
59
|
+
// Procedure lookup must carry the exact ordered Snowflake signature so the
|
|
60
|
+
// provider can distinguish a procedure from a same-name UDF and select one
|
|
61
|
+
// exact overload. This is identity metadata, not a barrel bag.
|
|
62
|
+
if (token.__kind === "procedure" && Array.isArray(token.parameterTypes)) {
|
|
63
|
+
out.parameterTypes = token.parameterTypes.filter((type) => typeof type === "string");
|
|
64
|
+
}
|
|
65
|
+
if (token.__kind === "procedure" && typeof token.databaseName === "string")
|
|
66
|
+
out.databaseName = token.databaseName;
|
|
67
|
+
if (token.__kind === "procedure" && typeof token.schemaName === "string")
|
|
68
|
+
out.schemaName = token.schemaName;
|
|
59
69
|
// Search-table resource selection is generated by catalog factories, not
|
|
60
70
|
// authored as public API. Preserve the private discriminator so tool HCL
|
|
61
71
|
// can reference the correct resource family.
|
|
@@ -36,7 +36,7 @@ import type { AiProviderLlmModel, AiProviderType } from "./ai-provider-models.js
|
|
|
36
36
|
* resolved to the current-version param/output id via the parent
|
|
37
37
|
* automation's state binding.
|
|
38
38
|
*/
|
|
39
|
-
export type CatalogRefKind = "automation" | "agent" | "agent-evaluation" | "chart" | "dashboard" | "skill" | "visual-flow" | "approvalChain" | "table" | "tableColumn" | "cloudLink" | "storedFunction" | "field" | "searchTable" | "documentModel" | "documentModelField" | "connector" | "aiProvider" | "category" | "group" | "phoneProvider" | "phone-service" | "datamine" | "app" | "element" | "task" | "triggerParameter" | "outputProperty";
|
|
39
|
+
export type CatalogRefKind = "automation" | "agent" | "agent-evaluation" | "chart" | "dashboard" | "skill" | "visual-flow" | "approvalChain" | "table" | "tableColumn" | "cloudLink" | "storedFunction" | "procedure" | "field" | "searchTable" | "documentModel" | "documentModelField" | "connector" | "aiProvider" | "category" | "group" | "phoneProvider" | "phone-service" | "datamine" | "app" | "element" | "task" | "triggerParameter" | "outputProperty";
|
|
40
40
|
/**
|
|
41
41
|
* The reference surface for a catalog entity. `handle` is the stable join key
|
|
42
42
|
* (no id); `name` is for readability/diagnostics, never a match key.
|
|
@@ -96,6 +96,13 @@ export type ApprovalProcessRef<Parent extends string = string, RefName extends s
|
|
|
96
96
|
export interface TableColumnRef<Parent extends string = string, RefName extends string = string> extends CatalogRef<"tableColumn", RefName, Parent> {
|
|
97
97
|
/** Owning table handle. */
|
|
98
98
|
readonly parent: Parent;
|
|
99
|
+
/**
|
|
100
|
+
* The owning table's display NAME, stamped alongside `parent` for the same
|
|
101
|
+
* reason `FieldRef.parentName` is — a column outside this workspace builds to
|
|
102
|
+
* `data.elementum_table.<t>.field_ids["Column"]`, and that lookup keys by the
|
|
103
|
+
* table's display name, which `parent` (a refName) doesn't carry.
|
|
104
|
+
*/
|
|
105
|
+
readonly parentName?: string;
|
|
99
106
|
readonly fieldType?: string;
|
|
100
107
|
readonly tags?: readonly string[];
|
|
101
108
|
}
|
|
@@ -134,13 +141,31 @@ export interface AiProviderRef<T extends AiProviderType = AiProviderType> extend
|
|
|
134
141
|
}
|
|
135
142
|
/** Scalar calculation families supported by configured stored functions. */
|
|
136
143
|
export type StoredFunctionScalarType = "number" | "decimal" | "bool" | "date" | "datetime" | "handle" | "json" | "text";
|
|
144
|
+
/** Exact Snowflake signature types used to disambiguate overloaded procedures. */
|
|
145
|
+
export declare const PROCEDURE_PARAMETER_TYPES: readonly ["BOOLEAN", "DATE", "DATETIME", "DECIMAL", "HANDLE", "JSON", "LONG", "TEXT", "UUID"];
|
|
146
|
+
export type ProcedureParameterType = typeof PROCEDURE_PARAMETER_TYPES[number];
|
|
137
147
|
export interface StoredFunctionRef<Parameters extends readonly StoredFunctionScalarType[] = readonly StoredFunctionScalarType[], Result extends StoredFunctionScalarType = StoredFunctionScalarType> extends CatalogRef<"storedFunction"> {
|
|
138
148
|
readonly parent: string;
|
|
139
149
|
readonly parameterTypes: Parameters;
|
|
140
150
|
readonly resultType: Result;
|
|
141
151
|
}
|
|
142
|
-
|
|
152
|
+
/** A configured Snowflake procedure callable by an automation's Run Function task. */
|
|
153
|
+
export interface ProcedureRef<Parameters extends readonly ProcedureParameterType[] = readonly ProcedureParameterType[], Result extends StoredFunctionScalarType = StoredFunctionScalarType> extends CatalogRef<"procedure"> {
|
|
154
|
+
/** Owning CloudLink catalog key, stamped by {@link orgCatalog}. */
|
|
155
|
+
readonly parent: string;
|
|
156
|
+
/** Owning CloudLink display name, needed for the Terraform data lookup. */
|
|
157
|
+
readonly parentName?: string;
|
|
158
|
+
/** Snowflake database containing this configured procedure. */
|
|
159
|
+
readonly databaseName: string;
|
|
160
|
+
/** Snowflake schema containing this configured procedure. */
|
|
161
|
+
readonly schemaName: string;
|
|
162
|
+
/** Exact ordered Snowflake argument signature used by the provider lookup. */
|
|
163
|
+
readonly parameterTypes: Parameters;
|
|
164
|
+
readonly resultType: Result;
|
|
165
|
+
}
|
|
166
|
+
export interface CloudLinkRef<Functions extends Readonly<Record<string, StoredFunctionRef>> = Readonly<Record<string, StoredFunctionRef>>, Procedures extends Readonly<Record<string, ProcedureRef>> = Readonly<Record<string, ProcedureRef>>> extends CatalogRef<"cloudLink"> {
|
|
143
167
|
readonly storedFunctions?: Functions;
|
|
168
|
+
readonly procedures?: Procedures;
|
|
144
169
|
}
|
|
145
170
|
/** Org-owned reference identities from `elementum pull org --data-only` (pristine-refactor). */
|
|
146
171
|
export type CategoryRef = CatalogRef<"category">;
|
|
@@ -168,6 +193,8 @@ export interface FieldRef<Parent extends string = string, RefName extends string
|
|
|
168
193
|
readonly fieldType: FieldType;
|
|
169
194
|
readonly tags?: readonly string[];
|
|
170
195
|
readonly options?: readonly string[];
|
|
196
|
+
/** Authoring metadata: this Dropdown/Multi-Select sources values from records. */
|
|
197
|
+
readonly dynamicSource?: true;
|
|
171
198
|
/**
|
|
172
199
|
* Whether `parent` names an app or an element — stamped alongside `parent`
|
|
173
200
|
* by `appCatalog`/`elementCatalog` (the field's own token doesn't otherwise
|
|
@@ -210,7 +237,19 @@ export interface TriggerParameterRef extends CatalogRef<"triggerParameter"> {
|
|
|
210
237
|
*/
|
|
211
238
|
readonly required?: boolean;
|
|
212
239
|
}
|
|
213
|
-
|
|
240
|
+
/**
|
|
241
|
+
* An automation output property reference. `valueType` (when known) is the
|
|
242
|
+
* platform's workflow field-type tag for this output — `"TEXT"`,
|
|
243
|
+
* `"BOOLEAN"`, `"NUMBER"`, `"DECIMAL"` — the same domain
|
|
244
|
+
* `entities/automation`'s `outputFieldTypesFromScriptSchema` already
|
|
245
|
+
* computes for the wire; not populated when the output's source can't be
|
|
246
|
+
* resolved to a typed schema (a literal, a trigger ref, a variable ref, or
|
|
247
|
+
* a non-executeScript task). Kept a bare generic `string` here (no import
|
|
248
|
+
* from `entities/`) — same decoupling as {@link FieldRef}'s `fieldType`.
|
|
249
|
+
*/
|
|
250
|
+
export interface OutputPropertyRef<ValueType extends string = string> extends CatalogRef<"outputProperty"> {
|
|
251
|
+
readonly valueType?: ValueType;
|
|
252
|
+
}
|
|
214
253
|
export type DocumentModelFieldRef = CatalogRef<"documentModelField">;
|
|
215
254
|
/**
|
|
216
255
|
* A document model reference that also exposes its fields as a nested ref
|
|
@@ -23,6 +23,10 @@
|
|
|
23
23
|
* schema is authoring-only — at the wire boundary `resolvePayload` replaces the
|
|
24
24
|
* whole token with the resolved id, discarding it.
|
|
25
25
|
*/
|
|
26
|
+
/** Exact Snowflake signature types used to disambiguate overloaded procedures. */
|
|
27
|
+
export const PROCEDURE_PARAMETER_TYPES = [
|
|
28
|
+
"BOOLEAN", "DATE", "DATETIME", "DECIMAL", "HANDLE", "JSON", "LONG", "TEXT", "UUID",
|
|
29
|
+
];
|
|
26
30
|
/** Platform-owned user attributes accepted by user-search task filters. */
|
|
27
31
|
export const USER_FIELD_KEYS = ["firstName", "email", "jobTitle", "lastName"];
|
|
28
32
|
/**
|
|
@@ -45,6 +49,7 @@ export const REF_SCOPE = {
|
|
|
45
49
|
tableColumn: "org",
|
|
46
50
|
cloudLink: "org",
|
|
47
51
|
storedFunction: "org",
|
|
52
|
+
procedure: "org",
|
|
48
53
|
field: "app",
|
|
49
54
|
searchTable: "app",
|
|
50
55
|
datamine: "app",
|
|
@@ -2,10 +2,10 @@ export { UNRESOLVED_FIELD_MARKER, createRef, isRef, secret, template, toRefData,
|
|
|
2
2
|
export { buildContext, createActionOutputProxy, createActionsProxy, createForEachItemProxy, createTriggerProxy, type Context, type ForEachItem } from "../entities/shared/context.js";
|
|
3
3
|
export { asRowProxy, app, picklistOption, picklistStaticValueToApiId, resolveFieldValues, type App, type AppAgent, type AppAutomation, type AppCategory, type AppField, type AppFieldInputForAction, type AppFieldOf, type AppFieldValues, type AppPhoneService, type AppSearchTable, type AspectRecord, type AspectType, type FieldScope, type FieldValueForAppField, type FieldValueType, type PicklistOption, type PicklistOptionsResolver, type RowProxy, type RowScopedFields, type SearchTableRecord } from "./types/app.js";
|
|
4
4
|
export { asc, desc, sortBy, type SortDirection, type SortOrder } from "../entities/shared/types/common.js";
|
|
5
|
-
export { type Attachment, type Employee, type Group, type Manager, type
|
|
5
|
+
export { type Attachment, type Employee, type Group, type Manager, type DropdownValue, type DynamicDropdownValue, type RecordId, type RichText, type User, } from "../entities/shared/types/platform.js";
|
|
6
6
|
export { aiProviderConnector, type AiProviderConnector } from "./types/ai-provider.js";
|
|
7
7
|
export { user, type UserRef } from "./types/user.js";
|
|
8
8
|
export { group, type GroupRef } from "./types/group.js";
|
|
9
9
|
export { cloudLink, type CloudLink } from "./types/cloud-link.js";
|
|
10
10
|
export { category, type AspectCategoryRef } from "./types/aspect-category.js";
|
|
11
|
-
export { unsafePlatformId, type UnsafePlatformId } from "./platform-id.js";
|
|
11
|
+
export { isUnsafePlatformId, unsafePlatformId, type UnsafePlatformId } from "./platform-id.js";
|
|
@@ -7,4 +7,4 @@ export { user } from "./types/user.js";
|
|
|
7
7
|
export { group } from "./types/group.js";
|
|
8
8
|
export { cloudLink } from "./types/cloud-link.js";
|
|
9
9
|
export { category } from "./types/aspect-category.js";
|
|
10
|
-
export { unsafePlatformId } from "./platform-id.js";
|
|
10
|
+
export { isUnsafePlatformId, unsafePlatformId } from "./platform-id.js";
|
|
@@ -9,3 +9,5 @@ export interface UnsafePlatformId {
|
|
|
9
9
|
}
|
|
10
10
|
/** Mark a non-portable platform id intentionally. Prefer catalog refs whenever possible. */
|
|
11
11
|
export declare function unsafePlatformId(value: string): UnsafePlatformId;
|
|
12
|
+
/** Check whether `value` is an `UnsafePlatformId` wrapper. */
|
|
13
|
+
export declare function isUnsafePlatformId(value: unknown): value is UnsafePlatformId;
|
|
@@ -6,3 +6,7 @@ export function unsafePlatformId(value) {
|
|
|
6
6
|
}
|
|
7
7
|
return { __unsafe: "platformId", value };
|
|
8
8
|
}
|
|
9
|
+
/** Check whether `value` is an `UnsafePlatformId` wrapper. */
|
|
10
|
+
export function isUnsafePlatformId(value) {
|
|
11
|
+
return typeof value === "object" && value !== null && value.__unsafe === "platformId";
|
|
12
|
+
}
|
|
@@ -68,6 +68,10 @@ export declare const SYSTEM_FIELD_KEYS: readonly SystemFieldKey[];
|
|
|
68
68
|
/** `SYSTEM_FIELD_KEYS` as a set — for O(1) "is this key a system field?" checks (e.g. distinguishing a system field from a custom field by bag key alone). */
|
|
69
69
|
export declare const SYSTEM_FIELD_KEY_SET: ReadonlySet<SystemFieldKey>;
|
|
70
70
|
export declare const SYSTEM_FIELD_KEY_BY_TAG: Readonly<Record<string, SystemFieldKey>>;
|
|
71
|
+
/** Internal Terraform map key for each public `systemFields` key. */
|
|
72
|
+
export declare const SYSTEM_FIELD_HCL_KEY_BY_KEY: Readonly<Record<SystemFieldKey, string>>;
|
|
73
|
+
/** Internal inverse used only at the HCL extraction boundary. */
|
|
74
|
+
export declare const SYSTEM_FIELD_KEY_BY_HCL_KEY: Readonly<Record<string, SystemFieldKey>>;
|
|
71
75
|
/**
|
|
72
76
|
* What a NO-OVERRIDE deploy produces — the terraform provider's auto-create
|
|
73
77
|
* display names. This is the baseline the pull printer compares against when
|
|
@@ -88,6 +92,20 @@ export declare const DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES: Readonly<Record<SystemFi
|
|
|
88
92
|
* platform cosmetics EDK doesn't model (the HCL fold emits labels only).
|
|
89
93
|
*/
|
|
90
94
|
export declare const DEPLOY_DEFAULT_STATUS_OPTIONS: readonly string[];
|
|
95
|
+
/** Provider HCL values for the status options created by the platform baseline. */
|
|
96
|
+
export declare const DEPLOY_DEFAULT_STATUS_OPTION_VALUES: readonly [{
|
|
97
|
+
readonly label: "Open";
|
|
98
|
+
readonly color: "#3B82F6";
|
|
99
|
+
readonly tags: readonly [];
|
|
100
|
+
}, {
|
|
101
|
+
readonly label: "In Progress";
|
|
102
|
+
readonly color: "#F59E0B";
|
|
103
|
+
readonly tags: readonly [];
|
|
104
|
+
}, {
|
|
105
|
+
readonly label: "Closed";
|
|
106
|
+
readonly color: "#10B981";
|
|
107
|
+
readonly tags: readonly ["CLOSED"];
|
|
108
|
+
}];
|
|
91
109
|
/**
|
|
92
110
|
* Whether the provider marks the auto-created field `required` — synthesized
|
|
93
111
|
* into the compose payload so the wire shape matches what terraform creates.
|
|
@@ -104,6 +104,21 @@ export const SYSTEM_FIELD_KEYS = Object.keys(SYSTEM_FIELD_TAG_BY_KEY);
|
|
|
104
104
|
/** `SYSTEM_FIELD_KEYS` as a set — for O(1) "is this key a system field?" checks (e.g. distinguishing a system field from a custom field by bag key alone). */
|
|
105
105
|
export const SYSTEM_FIELD_KEY_SET = new Set(SYSTEM_FIELD_KEYS);
|
|
106
106
|
export const SYSTEM_FIELD_KEY_BY_TAG = Object.fromEntries(Object.entries(SYSTEM_FIELD_TAG_BY_KEY).map(([k, tag]) => [tag, k]));
|
|
107
|
+
/** Internal Terraform map key for each public `systemFields` key. */
|
|
108
|
+
export const SYSTEM_FIELD_HCL_KEY_BY_KEY = {
|
|
109
|
+
id: "id",
|
|
110
|
+
title: "title",
|
|
111
|
+
status: "status",
|
|
112
|
+
stage: "stage",
|
|
113
|
+
createdAt: "created_at",
|
|
114
|
+
createdBy: "created_by",
|
|
115
|
+
updatedAt: "updated_at",
|
|
116
|
+
updatedBy: "updated_by",
|
|
117
|
+
closedAt: "closed_at",
|
|
118
|
+
closedBy: "closed_by",
|
|
119
|
+
};
|
|
120
|
+
/** Internal inverse used only at the HCL extraction boundary. */
|
|
121
|
+
export const SYSTEM_FIELD_KEY_BY_HCL_KEY = Object.fromEntries(Object.entries(SYSTEM_FIELD_HCL_KEY_BY_KEY).map(([key, hclKey]) => [hclKey, key]));
|
|
107
122
|
/**
|
|
108
123
|
* What a NO-OVERRIDE deploy produces — the terraform provider's auto-create
|
|
109
124
|
* display names. This is the baseline the pull printer compares against when
|
|
@@ -135,6 +150,12 @@ export const DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES = {
|
|
|
135
150
|
* platform cosmetics EDK doesn't model (the HCL fold emits labels only).
|
|
136
151
|
*/
|
|
137
152
|
export const DEPLOY_DEFAULT_STATUS_OPTIONS = ["Open", "In Progress", "Closed"];
|
|
153
|
+
/** Provider HCL values for the status options created by the platform baseline. */
|
|
154
|
+
export const DEPLOY_DEFAULT_STATUS_OPTION_VALUES = [
|
|
155
|
+
{ label: "Open", color: "#3B82F6", tags: [] },
|
|
156
|
+
{ label: "In Progress", color: "#F59E0B", tags: [] },
|
|
157
|
+
{ label: "Closed", color: "#10B981", tags: ["CLOSED"] },
|
|
158
|
+
];
|
|
138
159
|
/**
|
|
139
160
|
* Whether the provider marks the auto-created field `required` — synthesized
|
|
140
161
|
* into the compose payload so the wire shape matches what terraform creates.
|
|
@@ -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,
|