@elementumai/edk 0.12.0 → 0.13.0
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 +2 -0
- package/dist-sdk/src/catalog/factories.d.ts +7 -1
- package/dist-sdk/src/catalog/factories.js +2 -0
- package/dist-sdk/src/catalog/index.d.ts +2 -2
- package/dist-sdk/src/catalog/index.js +1 -1
- package/dist-sdk/src/catalog/org.js +79 -34
- package/dist-sdk/src/catalog/token.js +5 -0
- package/dist-sdk/src/catalog/types.d.ts +7 -1
- package/dist-sdk/src/catalog/types.js +3 -0
- package/dist-sdk/src/core/system-fields.d.ts +1 -1
- package/dist-sdk/src/core/system-fields.js +1 -1
- package/dist-sdk/src/core/types/app.d.ts +6 -0
- package/dist-sdk/src/engine/build/context.d.ts +3 -0
- package/dist-sdk/src/engine/pull/authored-address.js +42 -6
- package/dist-sdk/src/engine/pull/authored-root.d.ts +88 -0
- package/dist-sdk/src/engine/pull/authored-root.js +306 -0
- package/dist-sdk/src/engine/pull/context.d.ts +10 -0
- package/dist-sdk/src/engine/pull/field-refs-registry.d.ts +114 -0
- package/dist-sdk/src/engine/pull/field-refs-registry.js +501 -0
- package/dist-sdk/src/engine/pull/org.d.ts +1 -0
- package/dist-sdk/src/engine/pull/org.js +2 -0
- package/dist-sdk/src/engine/pull/partition.d.ts +8 -0
- package/dist-sdk/src/engine/pull/partition.js +43 -0
- package/dist-sdk/src/engine/pull/pulled-roots.d.ts +89 -0
- package/dist-sdk/src/engine/pull/pulled-roots.js +203 -0
- package/dist-sdk/src/engine/pull/ref-only.d.ts +4 -0
- package/dist-sdk/src/engine/pull/ref-only.js +7 -1
- package/dist-sdk/src/engine/pull/source-resources.d.ts +39 -0
- package/dist-sdk/src/engine/pull/source-resources.js +110 -0
- package/dist-sdk/src/engine/pull/stream-root.d.ts +148 -0
- package/dist-sdk/src/engine/pull/stream-root.js +563 -0
- package/dist-sdk/src/engine/workspace/reserved-catalog-keys.d.ts +47 -0
- package/dist-sdk/src/engine/workspace/reserved-catalog-keys.js +115 -0
- package/dist-sdk/src/entities/access-policy/build.d.ts +2 -1
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +7 -0
- package/dist-sdk/src/entities/access-policy/from-tf.js +18 -3
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +19 -0
- package/dist-sdk/src/entities/access-policy/to-tf.js +65 -8
- package/dist-sdk/src/entities/agent/build.d.ts +52 -1
- package/dist-sdk/src/entities/agent/build.js +34 -0
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +68 -0
- package/dist-sdk/src/entities/agent/from-tf.d.ts +34 -1
- package/dist-sdk/src/entities/agent/from-tf.js +262 -2
- package/dist-sdk/src/entities/agent/index.d.ts +1 -1
- package/dist-sdk/src/entities/agent/to-tf.d.ts +8 -10
- package/dist-sdk/src/entities/agent/to-tf.js +158 -14
- package/dist-sdk/src/entities/agent-tool/from-tf.js +6 -0
- package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +2 -2
- package/dist-sdk/src/entities/agent-tool/to-tf.js +2 -2
- package/dist-sdk/src/entities/app/build.d.ts +33 -13
- package/dist-sdk/src/entities/app/build.js +14 -12
- package/dist-sdk/src/entities/app/from-tf.js +24 -9
- package/dist-sdk/src/entities/app/index.d.ts +1 -0
- package/dist-sdk/src/entities/app/index.js +1 -0
- package/dist-sdk/src/entities/app/module.js +1 -0
- package/dist-sdk/src/entities/app/stage-keys.d.ts +2 -2
- package/dist-sdk/src/entities/app/stage-keys.js +3 -3
- package/dist-sdk/src/entities/app/to-tf.js +1 -0
- package/dist-sdk/src/entities/approval-chain/build.d.ts +46 -11
- package/dist-sdk/src/entities/approval-chain/build.js +120 -8
- package/dist-sdk/src/entities/approval-chain/from-tf.d.ts +24 -2
- package/dist-sdk/src/entities/approval-chain/from-tf.js +148 -6
- package/dist-sdk/src/entities/approval-chain/index.d.ts +4 -1
- package/dist-sdk/src/entities/approval-chain/index.js +4 -1
- package/dist-sdk/src/entities/approval-chain/module.js +23 -5
- package/dist-sdk/src/entities/approval-chain/printer.d.ts +1 -1
- package/dist-sdk/src/entities/approval-chain/printer.js +91 -5
- package/dist-sdk/src/entities/approval-chain/steps-tf.d.ts +77 -0
- package/dist-sdk/src/entities/approval-chain/steps-tf.js +255 -0
- package/dist-sdk/src/entities/approval-chain/steps.d.ts +71 -0
- package/dist-sdk/src/entities/approval-chain/steps.js +83 -0
- package/dist-sdk/src/entities/approval-chain/to-tf.d.ts +16 -6
- package/dist-sdk/src/entities/approval-chain/to-tf.js +37 -4
- package/dist-sdk/src/entities/automation/build.js +70 -27
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +20 -5
- package/dist-sdk/src/entities/automation/from-tf.d.ts +26 -5
- package/dist-sdk/src/entities/automation/from-tf.js +593 -101
- package/dist-sdk/src/entities/automation/index.d.ts +1 -0
- package/dist-sdk/src/entities/automation/index.js +1 -0
- package/dist-sdk/src/entities/automation/module.d.ts +4 -3
- package/dist-sdk/src/entities/automation/module.js +33 -12
- package/dist-sdk/src/entities/automation/refs-read.d.ts +19 -0
- package/dist-sdk/src/entities/automation/refs-read.js +48 -0
- package/dist-sdk/src/entities/automation/slack-message-refs.d.ts +9 -0
- package/dist-sdk/src/entities/automation/slack-message-refs.js +75 -0
- package/dist-sdk/src/entities/automation/task-output-labels.d.ts +11 -0
- package/dist-sdk/src/entities/automation/task-output-labels.js +23 -0
- package/dist-sdk/src/entities/automation/tasks.d.ts +29 -4
- package/dist-sdk/src/entities/automation/tasks.js +34 -11
- package/dist-sdk/src/entities/automation/to-tf.d.ts +3 -0
- package/dist-sdk/src/entities/automation/to-tf.js +337 -77
- package/dist-sdk/src/entities/automation/triggers.d.ts +0 -8
- package/dist-sdk/src/entities/automation/triggers.js +26 -11
- package/dist-sdk/src/entities/automation/unsafe-script-output.d.ts +50 -0
- package/dist-sdk/src/entities/automation/unsafe-script-output.js +92 -0
- package/dist-sdk/src/entities/chart/build.d.ts +9 -1
- package/dist-sdk/src/entities/chart/from-tf.js +3 -0
- package/dist-sdk/src/entities/chart/to-tf.js +19 -2
- package/dist-sdk/src/entities/dynamic-layout/build.d.ts +2 -0
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +44 -5
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +46 -12
- package/dist-sdk/src/entities/element/audit-field-guard.d.ts +9 -0
- package/dist-sdk/src/entities/element/audit-field-guard.js +88 -0
- package/dist-sdk/src/entities/element/build.js +2 -1
- package/dist-sdk/src/entities/element/from-tf.js +15 -2
- package/dist-sdk/src/entities/element/module.js +3 -0
- package/dist-sdk/src/entities/element/system-fields.d.ts +13 -0
- package/dist-sdk/src/entities/element/system-fields.js +23 -0
- package/dist-sdk/src/entities/element/to-tf.js +1 -0
- package/dist-sdk/src/entities/field/build.d.ts +9 -0
- package/dist-sdk/src/entities/field/from-tf.d.ts +29 -1
- package/dist-sdk/src/entities/field/from-tf.js +99 -6
- package/dist-sdk/src/entities/field/module.js +4 -0
- package/dist-sdk/src/entities/field/to-tf.d.ts +5 -1
- package/dist-sdk/src/entities/field/to-tf.js +33 -12
- package/dist-sdk/src/entities/org/category.js +1 -0
- package/dist-sdk/src/entities/org/index.d.ts +1 -0
- package/dist-sdk/src/entities/org/index.js +1 -0
- package/dist-sdk/src/entities/org/voice-auth.d.ts +5 -0
- package/dist-sdk/src/entities/org/voice-auth.js +33 -0
- package/dist-sdk/src/entities/organization/build.d.ts +3 -0
- package/dist-sdk/src/entities/organization/build.js +2 -0
- package/dist-sdk/src/entities/organization/index.d.ts +1 -0
- package/dist-sdk/src/entities/organization/index.js +1 -0
- package/dist-sdk/src/entities/organization/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/organization/to-tf.js +59 -1
- package/dist-sdk/src/entities/organization/voice-auth.d.ts +60 -0
- package/dist-sdk/src/entities/organization/voice-auth.js +60 -0
- package/dist-sdk/src/entities/phone-service/build.d.ts +9 -1
- package/dist-sdk/src/entities/phone-service/build.js +1 -0
- package/dist-sdk/src/entities/phone-service/deserializer/print-phone-service.js +3 -0
- package/dist-sdk/src/entities/phone-service/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/phone-service/from-tf.js +8 -1
- package/dist-sdk/src/entities/phone-service/to-tf.js +16 -0
- package/dist-sdk/src/entities/record-create-form/from-tf.js +2 -2
- package/dist-sdk/src/entities/relationship/from-tf.js +7 -2
- package/dist-sdk/src/entities/relationship/module.js +2 -2
- package/dist-sdk/src/entities/relationship/pair-check.d.ts +6 -2
- package/dist-sdk/src/entities/relationship/pair-check.js +105 -18
- package/dist-sdk/src/entities/relationship/to-tf.js +5 -2
- package/dist-sdk/src/entities/role/permission-levels.d.ts +7 -0
- package/dist-sdk/src/entities/role/permission-levels.js +78 -0
- package/dist-sdk/src/entities/role/to-tf.js +32 -2
- package/dist-sdk/src/entities/service-account/module.d.ts +2 -1
- package/dist-sdk/src/entities/service-account/module.js +4 -1
- package/dist-sdk/src/entities/service-account/resource-type.d.ts +2 -0
- package/dist-sdk/src/entities/service-account/resource-type.js +2 -0
- package/dist-sdk/src/entities/service-account/role-membership-check.d.ts +20 -0
- package/dist-sdk/src/entities/service-account/role-membership-check.js +80 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +15 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +36 -0
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +2 -0
- package/dist-sdk/src/entities/shared/filters/index.d.ts +85 -14
- package/dist-sdk/src/entities/shared/filters/index.js +18 -6
- package/dist-sdk/src/entities/shared/filters/option-lookups.d.ts +57 -0
- package/dist-sdk/src/entities/shared/filters/option-lookups.js +108 -0
- package/dist-sdk/src/entities/shared/filters/print.js +9 -5
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +12 -7
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +9 -5
- package/dist-sdk/src/entities/shared/raw-option-id.d.ts +30 -0
- package/dist-sdk/src/entities/shared/raw-option-id.js +41 -0
- package/dist-sdk/src/entities/shared/tool-field-ref.js +6 -2
- package/dist-sdk/src/entities/skill/input-coverage.js +5 -2
- package/dist-sdk/src/entities/sla/build.d.ts +96 -0
- package/dist-sdk/src/entities/sla/build.js +124 -0
- package/dist-sdk/src/entities/sla/from-tf.d.ts +40 -0
- package/dist-sdk/src/entities/sla/from-tf.js +164 -0
- package/dist-sdk/src/entities/sla/index.d.ts +1 -0
- package/dist-sdk/src/entities/sla/index.js +1 -0
- package/dist-sdk/src/entities/sla/module.d.ts +4 -0
- package/dist-sdk/src/entities/sla/module.js +73 -0
- package/dist-sdk/src/entities/sla/printer.d.ts +2 -0
- package/dist-sdk/src/entities/sla/printer.js +84 -0
- package/dist-sdk/src/entities/sla/to-tf.d.ts +12 -0
- package/dist-sdk/src/entities/sla/to-tf.js +81 -0
- package/dist-sdk/src/entities/table/build.d.ts +7 -2
- package/dist-sdk/src/entities/table/build.js +22 -1
- package/dist-sdk/src/entities/table/deserializer/normalize.d.ts +4 -1
- package/dist-sdk/src/entities/table/from-tf.js +89 -14
- package/dist-sdk/src/entities/table/index.d.ts +1 -1
- package/dist-sdk/src/entities/table/to-tf.js +41 -2
- package/dist-sdk/src/entities/task/from-tf.js +2 -1
- package/dist-sdk/src/entities/view/from-tf.js +7 -4
- package/dist-sdk/src/entities/widget/from-tf.js +13 -2
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +49 -4
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
- package/dist-sdk/src/graph/index.d.ts +5 -0
- package/dist-sdk/src/graph/index.js +7 -0
- package/dist-sdk/src/graph/modules.js +11 -1
- package/dist-sdk/src/graph/resource-types.d.ts +47 -0
- package/dist-sdk/src/graph/resource-types.js +62 -0
- package/dist-sdk/src/graph/types.d.ts +78 -6
- package/package.json +6 -3
|
@@ -260,14 +260,6 @@ export interface SlackMessageTriggerOutput {
|
|
|
260
260
|
readonly content: string;
|
|
261
261
|
readonly messageId: string;
|
|
262
262
|
readonly meta: Record<string, unknown>;
|
|
263
|
-
/** Compatibility aliases retained for existing automations. */
|
|
264
|
-
readonly slackThreadId: string;
|
|
265
|
-
readonly slackChannelId: string;
|
|
266
|
-
readonly messageAuthorEmail: string;
|
|
267
|
-
readonly messageAuthorId: string;
|
|
268
|
-
readonly messageAuthorName: string;
|
|
269
|
-
readonly messageContent: string;
|
|
270
|
-
readonly messageMetadata: Record<string, unknown>;
|
|
271
263
|
}
|
|
272
264
|
/** Fires when a Slack message is received. */
|
|
273
265
|
export declare function slackMessage(): TriggerChain<SlackMessageTriggerOutput>;
|
|
@@ -1,21 +1,36 @@
|
|
|
1
1
|
import { EdkValidationError } from "../../../elementum-entity-client/errors.js";
|
|
2
2
|
import { serializeOnDemandTrigger, } from "../../core/triggers/on-demand.js";
|
|
3
3
|
import { chainableTrigger } from "./build.js";
|
|
4
|
-
function recordTriggerFields(opts) {
|
|
4
|
+
function recordTriggerFields(trigger, opts) {
|
|
5
5
|
return {
|
|
6
6
|
aspectId: opts.app, // token → aspect id at deploy
|
|
7
7
|
...(opts.changedFields !== undefined ? { changedFieldIds: opts.changedFields } : {}),
|
|
8
8
|
...(opts.thinkUi !== undefined ? { thinkUi: opts.thinkUi } : {}),
|
|
9
|
-
...(
|
|
9
|
+
...triggerFilterField(trigger, opts.filter),
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* The `filter` key of a trigger's wire input. A top-level `filter.whereTrue()`
|
|
14
|
+
* is rejected here, at build: the platform stores a trigger filter that matches
|
|
15
|
+
* every record as no filter (and sends no `not` for TRUE), so the next read comes
|
|
16
|
+
* back with no filter and every plan adds it again (#2514).
|
|
17
|
+
*/
|
|
18
|
+
function triggerFilterField(trigger, filter) {
|
|
19
|
+
if (filter === undefined || filter === null)
|
|
20
|
+
return {};
|
|
21
|
+
if (String(filter.type).toUpperCase() === "TRUE") {
|
|
22
|
+
throw new EdkValidationError(`${trigger} filter: filter.whereTrue() matches every record, and the platform stores it as no filter, ` +
|
|
23
|
+
"so every plan would add it again. Leave filter out to fire on every record.");
|
|
24
|
+
}
|
|
25
|
+
return { filter };
|
|
26
|
+
}
|
|
12
27
|
/** Fires when a record is created on the given aspect. */
|
|
13
28
|
export function recordCreated(opts) {
|
|
14
|
-
return chainableTrigger({ wire: { createRecord: recordTriggerFields(opts) }, __recordApp: opts.app.refName });
|
|
29
|
+
return chainableTrigger({ wire: { createRecord: recordTriggerFields("recordCreated", opts) }, __recordApp: opts.app.refName });
|
|
15
30
|
}
|
|
16
31
|
/** Fires when a record is updated on the given aspect. */
|
|
17
32
|
export function recordUpdated(opts) {
|
|
18
|
-
return chainableTrigger({ wire: { updateRecord: recordTriggerFields(opts) }, __recordApp: opts.app.refName });
|
|
33
|
+
return chainableTrigger({ wire: { updateRecord: recordTriggerFields("recordUpdated", opts) }, __recordApp: opts.app.refName });
|
|
19
34
|
}
|
|
20
35
|
function buildRrule(opts) {
|
|
21
36
|
const parts = [`FREQ=${opts.frequency}`];
|
|
@@ -105,7 +120,7 @@ export function temporal(opts) {
|
|
|
105
120
|
aspectFieldId: opts.field,
|
|
106
121
|
temporalUnit: opts.temporalUnit,
|
|
107
122
|
value: opts.value,
|
|
108
|
-
...(
|
|
123
|
+
...triggerFilterField("temporal", opts.filter),
|
|
109
124
|
type: "TEMPORAL",
|
|
110
125
|
},
|
|
111
126
|
},
|
|
@@ -120,7 +135,7 @@ export function approvalProcessStatusUpdated(opts) {
|
|
|
120
135
|
aspectId: opts.app,
|
|
121
136
|
...(opts.approvalChain !== undefined ? { approvalChainTemplateId: opts.approvalChain } : {}),
|
|
122
137
|
status: opts.status,
|
|
123
|
-
...(
|
|
138
|
+
...triggerFilterField("approvalProcessStatusUpdated", opts.filter),
|
|
124
139
|
type: "APPROVAL_CHAIN_UPDATE",
|
|
125
140
|
},
|
|
126
141
|
},
|
|
@@ -134,7 +149,7 @@ export function attachment(opts) {
|
|
|
134
149
|
attachment: {
|
|
135
150
|
aspectId: opts.app,
|
|
136
151
|
type: "ATTACHMENT_UPDATE",
|
|
137
|
-
...(
|
|
152
|
+
...triggerFilterField("attachment", opts.filter),
|
|
138
153
|
...(opts.thinkUi !== undefined ? { thinkUi: opts.thinkUi } : {}),
|
|
139
154
|
},
|
|
140
155
|
},
|
|
@@ -186,7 +201,7 @@ export function dataMine(opts) {
|
|
|
186
201
|
type: "DATAMINE",
|
|
187
202
|
...(opts.fireOnAlert !== undefined ? { fireOnAlert: opts.fireOnAlert } : {}),
|
|
188
203
|
...(opts.fireOnRecovery !== undefined ? { fireOnRecovery: opts.fireOnRecovery } : {}),
|
|
189
|
-
...(
|
|
204
|
+
...triggerFilterField("dataMine", opts.filter),
|
|
190
205
|
},
|
|
191
206
|
},
|
|
192
207
|
});
|
|
@@ -209,7 +224,7 @@ export function commentAdded(opts) {
|
|
|
209
224
|
commentAdded: {
|
|
210
225
|
aspectId: opts.app,
|
|
211
226
|
conversationType: opts.conversationType,
|
|
212
|
-
...(
|
|
227
|
+
...triggerFilterField("commentAdded", opts.filter),
|
|
213
228
|
},
|
|
214
229
|
},
|
|
215
230
|
__recordApp: opts.app.refName,
|
|
@@ -223,7 +238,7 @@ export function conversationEnd(opts) {
|
|
|
223
238
|
aspectId: opts.app,
|
|
224
239
|
conversationType: opts.conversationType,
|
|
225
240
|
type: "CONVERSATION_END",
|
|
226
|
-
...(
|
|
241
|
+
...triggerFilterField("conversationEnd", opts.filter),
|
|
227
242
|
},
|
|
228
243
|
},
|
|
229
244
|
__recordApp: opts.app.refName,
|
|
@@ -246,7 +261,7 @@ export function surveyResponseCreate(opts) {
|
|
|
246
261
|
survey: {
|
|
247
262
|
aspectId: opts.app,
|
|
248
263
|
surveyTemplateId: opts.survey,
|
|
249
|
-
...(
|
|
264
|
+
...triggerFilterField("surveyResponseCreate", opts.filter),
|
|
250
265
|
type: "SURVEY_RESPONSE_CREATE",
|
|
251
266
|
},
|
|
252
267
|
},
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type Ref } from "../shared/ref.js";
|
|
2
|
+
/**
|
|
3
|
+
* Read an executeScript output that the script's `outputs` schema doesn't
|
|
4
|
+
* declare. Pull prints this for a live automation that still references such
|
|
5
|
+
* an output, so the reference round-trips unchanged (#1725).
|
|
6
|
+
*
|
|
7
|
+
* The platform resolves only declared outputs, so at runtime this reads
|
|
8
|
+
* nothing. Prefer adding the output to the script's `outputs` and reading
|
|
9
|
+
* `ctx.actions.<script>.result.<output>`. Build rejects a plain undeclared
|
|
10
|
+
* `result.<output>` in a filter, rejects this marker on an undeclared output in a task input, and
|
|
11
|
+
* accepts it in filters, workflow outputs and field assignments. On an output
|
|
12
|
+
* the script does declare, it builds the same reference as the plain read.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* condition: filter.eq(filter.text(unsafeScriptOutput(ctx.actions.RESOLVE_IDS, "legacyFlag")), "yes"),
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function unsafeScriptOutput(script: {
|
|
20
|
+
readonly result: unknown;
|
|
21
|
+
readonly textResult: unknown;
|
|
22
|
+
readonly stringArrayResult: unknown;
|
|
23
|
+
readonly numberArrayResult: unknown;
|
|
24
|
+
}, output: string): Ref<unknown>;
|
|
25
|
+
/** Member access for each `.`-separated segment of an output path. */
|
|
26
|
+
export declare function memberPath(path: string): string;
|
|
27
|
+
/** `ctx.actions.<script>` as valid TypeScript for any action name. */
|
|
28
|
+
export declare function scriptActionAccess(taskRefKey: string | undefined): string;
|
|
29
|
+
/**
|
|
30
|
+
* How a reference position treats a `result.<prop>` that the script's
|
|
31
|
+
* output schema doesn't declare (#1725):
|
|
32
|
+
* - `reject`: task inputs read the refs map, which holds only declared outputs.
|
|
33
|
+
* - `unsafeOnly`: filters reject it unless it is wrapped in
|
|
34
|
+
* {@link unsafeScriptOutput}, the form pull prints for a live dangling
|
|
35
|
+
* reference (#1151). to-tf keeps that envelope and emits a diagnostic.
|
|
36
|
+
* - `allow`: workflow outputs and field assignments rebuild it as a value envelope.
|
|
37
|
+
*/
|
|
38
|
+
export type UndeclaredScriptResult = "reject" | "unsafeOnly" | "allow";
|
|
39
|
+
/**
|
|
40
|
+
* Unwrap an {@link unsafeScriptOutput} reference name to its
|
|
41
|
+
* `result.<output>`, checking that it names an undeclared output of an
|
|
42
|
+
* executeScript task at a position that can carry one. Build finalize calls
|
|
43
|
+
* this on every task reference; any other name comes back unchanged.
|
|
44
|
+
* `declared` is the script's top-level output names, `undefined` when it has
|
|
45
|
+
* no schema.
|
|
46
|
+
*/
|
|
47
|
+
export declare function unwrapUnsafeScriptOutput(rawName: string, taskKey: string | undefined, taskRefKey: string, declared: ReadonlySet<string> | undefined, undeclared: UndeclaredScriptResult): {
|
|
48
|
+
readonly name: string;
|
|
49
|
+
readonly unsafe: boolean;
|
|
50
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { EdkValidationError } from "../../../elementum-entity-client/errors.js";
|
|
2
|
+
import { EntityTfError } from "../../engine/entity.js";
|
|
3
|
+
import { createRef, isRef } from "../shared/ref.js";
|
|
4
|
+
/**
|
|
5
|
+
* Prefix on the task-reference name of an {@link unsafeScriptOutput} ref.
|
|
6
|
+
* Build finalize (`rewriteTaskOutputRefs` in `build.ts`) strips it before
|
|
7
|
+
* anything reads the name, so it never reaches HCL or the wire.
|
|
8
|
+
*/
|
|
9
|
+
const UNSAFE_SCRIPT_OUTPUT_MARKER = "__edkUnsafeScriptOutput::";
|
|
10
|
+
/**
|
|
11
|
+
* Read an executeScript output that the script's `outputs` schema doesn't
|
|
12
|
+
* declare. Pull prints this for a live automation that still references such
|
|
13
|
+
* an output, so the reference round-trips unchanged (#1725).
|
|
14
|
+
*
|
|
15
|
+
* The platform resolves only declared outputs, so at runtime this reads
|
|
16
|
+
* nothing. Prefer adding the output to the script's `outputs` and reading
|
|
17
|
+
* `ctx.actions.<script>.result.<output>`. Build rejects a plain undeclared
|
|
18
|
+
* `result.<output>` in a filter, rejects this marker on an undeclared output in a task input, and
|
|
19
|
+
* accepts it in filters, workflow outputs and field assignments. On an output
|
|
20
|
+
* the script does declare, it builds the same reference as the plain read.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* condition: filter.eq(filter.text(unsafeScriptOutput(ctx.actions.RESOLVE_IDS, "legacyFlag")), "yes"),
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export function unsafeScriptOutput(script, output) {
|
|
28
|
+
const result = script?.result;
|
|
29
|
+
if (!isRef(result) || result.__data.kind !== "task" || result.__data.name !== "result") {
|
|
30
|
+
throw new EdkValidationError("unsafeScriptOutput() takes an executeScript action, such as ctx.actions.<script>.");
|
|
31
|
+
}
|
|
32
|
+
if (typeof output !== "string" || output === "" || output.split(".").some((segment) => segment === "")) {
|
|
33
|
+
throw new EdkValidationError(`unsafeScriptOutput() needs an output name such as "flag" or "obj.child"; got ${JSON.stringify(output)}.`);
|
|
34
|
+
}
|
|
35
|
+
return createRef({
|
|
36
|
+
kind: "task",
|
|
37
|
+
actionRefKey: result.__data.actionRefKey,
|
|
38
|
+
name: `${UNSAFE_SCRIPT_OUTPUT_MARKER}result.${output}`,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
const RESERVED_IDENT = new Set([
|
|
42
|
+
"break", "case", "catch", "class", "const", "continue", "debugger", "default",
|
|
43
|
+
"delete", "do", "else", "export", "extends", "false", "finally", "for",
|
|
44
|
+
"function", "if", "import", "in", "instanceof", "new", "null", "return",
|
|
45
|
+
"super", "switch", "this", "throw", "true", "try", "typeof", "var", "void",
|
|
46
|
+
"while", "with", "yield",
|
|
47
|
+
]);
|
|
48
|
+
/**
|
|
49
|
+
* `.name` when `name` is a plain identifier, else `["name"]`: the same rule
|
|
50
|
+
* the pull printer's `safeMember` uses, so a suggested fix in an error
|
|
51
|
+
* message is valid TypeScript for names such as `"Resolve IDs"`.
|
|
52
|
+
*/
|
|
53
|
+
function member(name) {
|
|
54
|
+
return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name) && !RESERVED_IDENT.has(name) ? `.${name}` : `[${JSON.stringify(name)}]`;
|
|
55
|
+
}
|
|
56
|
+
/** Member access for each `.`-separated segment of an output path. */
|
|
57
|
+
export function memberPath(path) {
|
|
58
|
+
return path.split(".").map(member).join("");
|
|
59
|
+
}
|
|
60
|
+
/** `ctx.actions.<script>` as valid TypeScript for any action name. */
|
|
61
|
+
export function scriptActionAccess(taskRefKey) {
|
|
62
|
+
return taskRefKey === undefined ? "ctx.actions.<script>" : `ctx.actions${member(taskRefKey)}`;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Unwrap an {@link unsafeScriptOutput} reference name to its
|
|
66
|
+
* `result.<output>`, checking that it names an undeclared output of an
|
|
67
|
+
* executeScript task at a position that can carry one. Build finalize calls
|
|
68
|
+
* this on every task reference; any other name comes back unchanged.
|
|
69
|
+
* `declared` is the script's top-level output names, `undefined` when it has
|
|
70
|
+
* no schema.
|
|
71
|
+
*/
|
|
72
|
+
export function unwrapUnsafeScriptOutput(rawName, taskKey, taskRefKey, declared, undeclared) {
|
|
73
|
+
if (!rawName.startsWith(UNSAFE_SCRIPT_OUTPUT_MARKER))
|
|
74
|
+
return { name: rawName, unsafe: false };
|
|
75
|
+
const name = rawName.slice(UNSAFE_SCRIPT_OUTPUT_MARKER.length);
|
|
76
|
+
const output = name.slice("result.".length);
|
|
77
|
+
const at = scriptActionAccess(taskRefKey);
|
|
78
|
+
const read = `${at}.result${memberPath(output)}`;
|
|
79
|
+
const call = `unsafeScriptOutput(${at}, ${JSON.stringify(output)})`;
|
|
80
|
+
if (taskKey !== "executeScript") {
|
|
81
|
+
throw new EntityTfError(`${call} only reads executeScript outputs; "${taskRefKey}" is ${taskKey === undefined ? "not a task in this automation" : `a ${taskKey} task`}.`);
|
|
82
|
+
}
|
|
83
|
+
// A marker on a declared output is allowed (Dax, #2221 Q1) and builds the
|
|
84
|
+
// same reference as the plain read, so it is checked like one.
|
|
85
|
+
if (declared?.has(output.split(".")[0] ?? "") === true)
|
|
86
|
+
return { name, unsafe: false };
|
|
87
|
+
if (undeclared === "reject") {
|
|
88
|
+
throw new EntityTfError(`${call} can't be used in a task input: inputs read the script's refs map, which holds only declared outputs. ` +
|
|
89
|
+
`Add ${JSON.stringify(output)} to the script's outputs and read ${read}.`);
|
|
90
|
+
}
|
|
91
|
+
return { name, unsafe: true };
|
|
92
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type AppCatalogRef, type AppOrElementOrTaskRef, type ChartRef, type FieldRef, type TableColumnRef, type TableRef } from "../../catalog/index.js";
|
|
2
2
|
import type { DeployableEntity, EntityDeployOptions } from "../../engine/entity.js";
|
|
3
3
|
import type { Filter } from "../shared/filters/types.js";
|
|
4
|
+
import type { FilterFieldToken } from "../shared/filters/index.js";
|
|
4
5
|
import type { UnsafePlatformId } from "../../core/platform-id.js";
|
|
5
6
|
import type { ChartAggregation, ChartColumnValueType, ChartJoinType, ChartType } from "./types.js";
|
|
6
7
|
export { chartAggregation, chartColumnValueType, chartJoinType, chartType, type ChartAggregation, type ChartColumnValueType, type ChartJoinType, type ChartType, } from "./types.js";
|
|
@@ -79,7 +80,14 @@ export interface ChartSubscription<Datasource extends ChartDatasourceRef = Chart
|
|
|
79
80
|
readonly columns: readonly ChartColumn<Datasource>[];
|
|
80
81
|
readonly groupBy?: readonly ChartGroupBy<Datasource>[];
|
|
81
82
|
readonly joins?: readonly ChartJoin<Datasource, ChartDatasourceRef>[];
|
|
82
|
-
|
|
83
|
+
/**
|
|
84
|
+
* Built with this module's `filter` helpers, typed as view and
|
|
85
|
+
* access-policy filters are (`Filter<FilterFieldToken, unknown>`, #2561):
|
|
86
|
+
* a narrower type here rejected every chart filter, pulled ones included
|
|
87
|
+
* (#2797). Build refuses a field outside the datasource, an aspect
|
|
88
|
+
* override and any runtime reference.
|
|
89
|
+
*/
|
|
90
|
+
readonly filter?: Filter<FilterFieldToken, unknown>;
|
|
83
91
|
readonly limit?: ChartSubscriptionLimit;
|
|
84
92
|
readonly tags?: readonly string[];
|
|
85
93
|
}
|
|
@@ -3,6 +3,7 @@ import { isTfExpr, scopedLabelToBagKey, tfLabelToTsLabel } from "../../engine/tf
|
|
|
3
3
|
import { FIELD_RESOURCE_TYPES } from "../field/types.js";
|
|
4
4
|
import { fieldKeyFromTfValue } from "../field/from-tf.js";
|
|
5
5
|
import { filterFromTf } from "../shared/filters/tf-codec.js";
|
|
6
|
+
import { optionLookupDecode } from "../shared/filters/option-lookups.js";
|
|
6
7
|
import { CHART_RESOURCE_TYPE } from "./types.js";
|
|
7
8
|
import { dataAspectDisplayName } from "../shared/aspect-target-from-tf.js";
|
|
8
9
|
const APP_RESOURCE_TYPE = "elementum_app";
|
|
@@ -329,6 +330,8 @@ function parseSubscription(value, appLabel, appRefName, ctx, where) {
|
|
|
329
330
|
},
|
|
330
331
|
aspect: () => { throw new Error("chart filter aspect overrides are unsupported"); },
|
|
331
332
|
reference: () => { throw new Error("chart filter references are unsupported"); },
|
|
333
|
+
// #2582: a stored option lookup prints as filter.textOption(label).
|
|
334
|
+
...optionLookupDecode,
|
|
332
335
|
});
|
|
333
336
|
}
|
|
334
337
|
catch (error) {
|
|
@@ -3,6 +3,7 @@ import { EntityTfError } from "../../engine/entity.js";
|
|
|
3
3
|
import { expr, sanitizeName, scopedResourceLabel, tsLabelToTfLabel, } from "../../engine/tf/index.js";
|
|
4
4
|
import { authoredFieldKeysFromPayload, fieldRefToTfValue, } from "../field/to-tf.js";
|
|
5
5
|
import { filterToTf as serializeFilterToTf } from "../shared/filters/tf-codec.js";
|
|
6
|
+
import { optionSelectionLiteral, optionsLocalName } from "../shared/filters/option-lookups.js";
|
|
6
7
|
import { isUnsafePlatformId } from "../../core/platform-id.js";
|
|
7
8
|
import { CHART_RESOURCE_TYPE } from "./types.js";
|
|
8
9
|
import { foreignFieldDataLabel, resolveForeignRef } from "../shared/foreign-ref.js";
|
|
@@ -84,8 +85,24 @@ function columnToTf(column, datasource, opts, where) {
|
|
|
84
85
|
function filterToTf(value, datasource, opts, where) {
|
|
85
86
|
return serializeFilterToTf(value, {
|
|
86
87
|
field: (field) => fieldId(field, datasource, opts, `${where}.field`),
|
|
87
|
-
|
|
88
|
+
// A chart filter always runs on the subscription's datasource. An
|
|
89
|
+
// authored aspect override (filter.withOptions({ aspect })) has nowhere
|
|
90
|
+
// to go, and pull never prints one (printer.ts), so refuse it rather
|
|
91
|
+
// than silently writing the datasource in its place (#2797).
|
|
92
|
+
aspect: () => {
|
|
93
|
+
throw new EntityTfError(`${where}: a chart filter runs on its subscription's datasource; remove the filter.withOptions aspect override`);
|
|
94
|
+
},
|
|
88
95
|
reference: () => { throw new EntityTfError(`${where}: runtime reference values are not supported in chart filters`); },
|
|
96
|
+
// #2582: a Dropdown option is selected with filter.textOption(label).
|
|
97
|
+
literal: optionSelectionLiteral({
|
|
98
|
+
where,
|
|
99
|
+
address: opts.chartAddress,
|
|
100
|
+
name: opts.chartName,
|
|
101
|
+
ownerKind: "chart",
|
|
102
|
+
optionsLocal: (field) => datasource.local && (datasource.kind === "app" || datasource.kind === "element")
|
|
103
|
+
? optionsLocalName(datasource.tfLabel, datasource.kind, field)
|
|
104
|
+
: undefined,
|
|
105
|
+
}),
|
|
89
106
|
});
|
|
90
107
|
}
|
|
91
108
|
function opaqueSubscriptionToTf(subscription, where) {
|
|
@@ -214,7 +231,7 @@ export function chartToTf(entity, opts) {
|
|
|
214
231
|
const attrs = {
|
|
215
232
|
name: chart.name ?? "",
|
|
216
233
|
type: chart.type ?? "",
|
|
217
|
-
subscriptions: (chart.subscriptions ?? []).map((subscription, index) => subscriptionToTf(subscription, opts, `chart ${entity.refName}.subscriptions[${index}]`)),
|
|
234
|
+
subscriptions: (chart.subscriptions ?? []).map((subscription, index) => subscriptionToTf(subscription, { ...opts, chartAddress: `${CHART_RESOURCE_TYPE}.${label}`, chartName: chart.name ?? entity.refName }, `chart ${entity.refName}.subscriptions[${index}]`)),
|
|
218
235
|
};
|
|
219
236
|
if (chart.target !== undefined)
|
|
220
237
|
attrs["target"] = chart.target;
|
|
@@ -215,6 +215,8 @@ export interface DynamicLayoutComponentVariantMap {
|
|
|
215
215
|
readonly fullWidth?: boolean;
|
|
216
216
|
/** App or element whose related records the block lists. */
|
|
217
217
|
readonly related?: AppOrElementRef;
|
|
218
|
+
/** Related-records widget on the layout's owner that holds the block's columns, rows, sort and filter. */
|
|
219
|
+
readonly widget?: WidgetRef;
|
|
218
220
|
/** Record filter over the related app's or element's fields. */
|
|
219
221
|
readonly filter?: Filter<FieldRef, never>;
|
|
220
222
|
};
|
|
@@ -2,7 +2,7 @@ import { unsafePlatformId } from "../../core/platform-id.js";
|
|
|
2
2
|
import { dataRefLabel, optionalString, plainObject, reportAuthoringBlocker, resourceRefLabel } from "../../engine/pull/context.js";
|
|
3
3
|
import { isTfExpr, isUuid, scopedLabelToBagKey, tfLabelToTsLabel, } from "../../engine/tf/index.js";
|
|
4
4
|
import { filterFromTf } from "../access-policy/from-tf.js";
|
|
5
|
-
import { fieldKeyFromTfValue } from "../field/from-tf.js";
|
|
5
|
+
import { elementAuditFieldReference, fieldKeyFromTfValue } from "../field/from-tf.js";
|
|
6
6
|
import { filterOwnerForAspect } from "../relationship/from-tf.js";
|
|
7
7
|
import { filterWireToTf } from "../shared/filters/tf-codec.js";
|
|
8
8
|
import { resolveDataAspectTarget } from "../shared/aspect-target-from-tf.js";
|
|
@@ -207,7 +207,9 @@ function componentMap(values, layoutKey, owner, ctx, where) {
|
|
|
207
207
|
if (automation["automationId"] !== undefined) {
|
|
208
208
|
const label = resourceRefLabel(automation["automationId"], "elementum_automation");
|
|
209
209
|
if (label !== undefined) {
|
|
210
|
-
|
|
210
|
+
// The display name lets build look the automation up when pull
|
|
211
|
+
// leaves it platform-managed, so it is not in source (edk#2693).
|
|
212
|
+
automation["automation"] = pulledRef("automation", scopedLabelToBagKey(owner.ownerTfLabel, label, "app"), owner.ownerRefName, exportedAutomationName(label, ctx));
|
|
211
213
|
}
|
|
212
214
|
else
|
|
213
215
|
ctx.diagnostics.push(`${where}.components.${id}.automationButton: automation_id is not a managed automation ref; dropped`);
|
|
@@ -235,8 +237,11 @@ function componentMap(values, layoutKey, owner, ctx, where) {
|
|
|
235
237
|
return [];
|
|
236
238
|
}
|
|
237
239
|
input["parameterName"] = managed.name;
|
|
240
|
+
// The same automation, reached through its on-demand trigger,
|
|
241
|
+
// stays on the button. A different one needs its own display
|
|
242
|
+
// name so build can look it up when it is not in source.
|
|
238
243
|
if (managed.automationLabel !== automationLabel) {
|
|
239
|
-
input["automation"] = pulledRef("automation", scopedLabelToBagKey(owner.ownerTfLabel, managed.automationLabel, "app"), owner.ownerRefName);
|
|
244
|
+
input["automation"] = pulledRef("automation", scopedLabelToBagKey(owner.ownerTfLabel, managed.automationLabel, "app"), owner.ownerRefName, exportedAutomationName(managed.automationLabel, ctx));
|
|
240
245
|
}
|
|
241
246
|
delete input["parameterId"];
|
|
242
247
|
}
|
|
@@ -284,7 +289,13 @@ function managedParameter(parameter, ctx) {
|
|
|
284
289
|
if (parameter.path.length !== 2 || parameter.path[0] !== "parameter_ids" || typeof name !== "string")
|
|
285
290
|
return undefined;
|
|
286
291
|
if (parameter.$expr === "resource-attr") {
|
|
287
|
-
|
|
292
|
+
if (parameter.type !== "elementum_on_demand_trigger")
|
|
293
|
+
return undefined;
|
|
294
|
+
// A single trigger shares the automation's label. A later trigger is
|
|
295
|
+
// `<auto>_<type>_<index>`, so the trigger label is not the automation.
|
|
296
|
+
// Follow the trigger's own `automation` attribute back to the owner.
|
|
297
|
+
const owning = owningAutomationLabel(parameter.label, ctx);
|
|
298
|
+
return { automationLabel: owning ?? parameter.label, name };
|
|
288
299
|
}
|
|
289
300
|
if (parameter.type !== "elementum_automation")
|
|
290
301
|
return undefined;
|
|
@@ -292,6 +303,24 @@ function managedParameter(parameter, ctx) {
|
|
|
292
303
|
const automationLabel = automationId === undefined ? undefined : resourceRefLabel(automationId, "elementum_automation");
|
|
293
304
|
return automationLabel === undefined ? undefined : { automationLabel, name };
|
|
294
305
|
}
|
|
306
|
+
/** Display name of an exported `elementum_automation`, when the stream has one. */
|
|
307
|
+
function exportedAutomationName(label, ctx) {
|
|
308
|
+
const exportedName = ctx.resourceByAddress?.(`elementum_automation.${label}`)?.attrs["name"];
|
|
309
|
+
return typeof exportedName === "string" && exportedName !== "" ? exportedName : undefined;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* The automation an on-demand trigger belongs to. Export writes
|
|
313
|
+
* `automation = elementum_automation.<label>` with no `.id`.
|
|
314
|
+
*/
|
|
315
|
+
function owningAutomationLabel(triggerLabel, ctx) {
|
|
316
|
+
const automation = ctx.resourceByAddress?.(`elementum_on_demand_trigger.${triggerLabel}`)?.attrs["automation"];
|
|
317
|
+
if (automation === undefined || !isTfExpr(automation) || automation.$expr !== "resource-attr" || automation.type !== "elementum_automation") {
|
|
318
|
+
return undefined;
|
|
319
|
+
}
|
|
320
|
+
if (automation.path.length === 0 || (automation.path.length === 1 && automation.path[0] === "id"))
|
|
321
|
+
return automation.label;
|
|
322
|
+
return undefined;
|
|
323
|
+
}
|
|
295
324
|
function relatedItemsBlock(block, owner, ctx, where) {
|
|
296
325
|
const aspectId = block["relatedAspectId"];
|
|
297
326
|
delete block["relatedAspectId"];
|
|
@@ -302,6 +331,15 @@ function relatedItemsBlock(block, owner, ctx, where) {
|
|
|
302
331
|
else
|
|
303
332
|
ctx.diagnostics.push(`${where}: related_aspect_id is not resolvable; dropped`);
|
|
304
333
|
}
|
|
334
|
+
const widgetId = block["widgetId"];
|
|
335
|
+
delete block["widgetId"];
|
|
336
|
+
if (widgetId !== undefined) {
|
|
337
|
+
const label = resourceRefLabel(widgetId, WIDGET_RESOURCE_TYPE);
|
|
338
|
+
if (label !== undefined)
|
|
339
|
+
block["widget"] = pulledRef("widget", scopedLabelToBagKey(owner.label, label, scopeOf(owner)), owner.ownerRefName);
|
|
340
|
+
else
|
|
341
|
+
ctx.diagnostics.push(`${where}: widget_id is not a managed widget ref; dropped`);
|
|
342
|
+
}
|
|
305
343
|
const raw = block["filter"];
|
|
306
344
|
delete block["filter"];
|
|
307
345
|
if (raw === undefined)
|
|
@@ -438,7 +476,8 @@ function fieldKey(value, owner, ctx, where, site = where) {
|
|
|
438
476
|
// A field pull did not extract keeps its platform id: its key would print
|
|
439
477
|
// as nothing and build would drop the entry (#1966). With no id the pull
|
|
440
478
|
// fails, naming the entry (#1978).
|
|
441
|
-
const
|
|
479
|
+
const kept = owner.unextracted === undefined ? resolved : unextractedFieldRefId(value, resolved, owner.unextracted, ctx, site);
|
|
480
|
+
const key = kept === undefined || kept !== resolved ? kept : elementAuditFieldReference(value, kept, { ...owner, scope: scopeOf(owner) }, ctx);
|
|
442
481
|
if (key === undefined) {
|
|
443
482
|
ctx.diagnostics.push(`${where}: field reference ${JSON.stringify(value)} is not resolvable; dropped`);
|
|
444
483
|
}
|
|
@@ -569,17 +569,22 @@ function automationButtonInput(rec, inputs, where, opts) {
|
|
|
569
569
|
token: rec["automation"],
|
|
570
570
|
value: resolveAutomation(rec["automation"], `${where}.automation`, opts),
|
|
571
571
|
};
|
|
572
|
-
const
|
|
573
|
-
? target.value.label
|
|
574
|
-
: undefined;
|
|
572
|
+
const value = target?.value;
|
|
575
573
|
const name = rec["parameterName"];
|
|
576
|
-
|
|
574
|
+
const ref = value !== undefined && isTfExpr(value) && (value.$expr === "resource-attr" || value.$expr === "data-attr") && value.type === AUTOMATION_RESOURCE_TYPE
|
|
575
|
+
? value
|
|
576
|
+
: undefined;
|
|
577
|
+
if (ref === undefined || typeof name !== "string") {
|
|
577
578
|
opts.diagnostics.push(`${where}: parameterName needs a managed button automation to bind to; dropped`);
|
|
578
579
|
return [];
|
|
579
580
|
}
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
581
|
+
const label = ref.label;
|
|
582
|
+
// A platform-managed automation is already a lookup of its published workflow.
|
|
583
|
+
out["parameter_id"] = ref.$expr === "data-attr"
|
|
584
|
+
? expr.dataAttr(AUTOMATION_RESOURCE_TYPE, label, ["parameter_ids", { index: name }])
|
|
585
|
+
: isActiveAutomation(target?.token.refName ?? "", opts)
|
|
586
|
+
? expr.dataAttr(AUTOMATION_RESOURCE_TYPE, publishedAutomationLookup(label, inputs), ["parameter_ids", { index: name }])
|
|
587
|
+
: expr.resourceAttr("elementum_on_demand_trigger", label, ["parameter_ids", { index: name }]);
|
|
583
588
|
}
|
|
584
589
|
if (Array.isArray(rec["fieldRefParams"])) {
|
|
585
590
|
out["field_ref_params"] = rec["fieldRefParams"].flatMap((param, index) => {
|
|
@@ -593,6 +598,7 @@ function automationButtonInput(rec, inputs, where, opts) {
|
|
|
593
598
|
function relatedItemsBlock(rec, where, opts) {
|
|
594
599
|
const out = snakeObject(rec, where, opts);
|
|
595
600
|
delete out["related"];
|
|
601
|
+
delete out["widget"];
|
|
596
602
|
delete out["filter"];
|
|
597
603
|
const related = rec["related"];
|
|
598
604
|
if (related !== undefined) {
|
|
@@ -600,6 +606,11 @@ function relatedItemsBlock(rec, where, opts) {
|
|
|
600
606
|
if (aspect !== undefined)
|
|
601
607
|
out["related_aspect_id"] = aspect;
|
|
602
608
|
}
|
|
609
|
+
if (rec["widget"] !== undefined) {
|
|
610
|
+
const widget = resolveWidget(rec["widget"], `${where}.widget`, opts);
|
|
611
|
+
if (widget !== undefined)
|
|
612
|
+
out["widget_id"] = widget;
|
|
613
|
+
}
|
|
603
614
|
if (rec["filter"] !== undefined) {
|
|
604
615
|
const foreignField = related === undefined
|
|
605
616
|
? undefined
|
|
@@ -722,7 +733,7 @@ function resolveField(value, where, opts) {
|
|
|
722
733
|
opts.diagnostics.push(`${where}: field "${refName}" targets a different ${scopeOf(opts)}; dropped`);
|
|
723
734
|
return undefined;
|
|
724
735
|
}
|
|
725
|
-
const resolved = fieldRefToTfValue(token?.fieldType ?? "", refName, opts.ownerTfLabel, scopeOf(opts), opts.fieldAddresses);
|
|
736
|
+
const resolved = fieldRefToTfValue(token?.fieldType ?? "", refName, opts.ownerTfLabel, scopeOf(opts), opts.fieldAddresses, token?.resourceKey);
|
|
726
737
|
if (resolved === undefined)
|
|
727
738
|
opts.diagnostics.push(`${where}: field "${refName}" has no Terraform mapping; dropped`);
|
|
728
739
|
return resolved;
|
|
@@ -731,11 +742,12 @@ function typedValue(value, fieldValue, opts) {
|
|
|
731
742
|
const rec = object(value);
|
|
732
743
|
const token = fieldValue;
|
|
733
744
|
if (typeof rec["string"] === "string" && token?.options?.includes(rec["string"])) {
|
|
745
|
+
const childPart = tsLabelToTfLabel(token.resourceKey ?? token.refName ?? "");
|
|
734
746
|
const localName = token.tags?.includes("STATUS")
|
|
735
747
|
? `${opts.ownerTfLabel}_status_options_by_label`
|
|
736
748
|
: token.tags?.includes("STAGE")
|
|
737
749
|
? `${opts.ownerTfLabel}_stage_options_by_label`
|
|
738
|
-
: `${scopedResourceLabel(opts.ownerTfLabel,
|
|
750
|
+
: `${scopedResourceLabel(opts.ownerTfLabel, childPart, scopeOf(opts))}_options_by_label`;
|
|
739
751
|
return { string: expr.local(localName, [{ index: rec["string"] }]) };
|
|
740
752
|
}
|
|
741
753
|
return snakeObject(rec, "dynamic layout typed value", opts);
|
|
@@ -748,13 +760,29 @@ function buttonAutomationProblem(token, opts) {
|
|
|
748
760
|
}
|
|
749
761
|
if (!isCanonicalTsLabel(refName))
|
|
750
762
|
return `its automation key ${JSON.stringify(refName)} is not a canonical tsLabel`;
|
|
751
|
-
const authored = opts.workspaceAspects?.get(workspaceAspectKey(scopeOf(opts), opts.ownerRefName))?.automationRefNames;
|
|
752
763
|
// A reference to an automation build never declares would fail plan with
|
|
753
764
|
// `Reference to undeclared resource` (#1877).
|
|
754
|
-
if (
|
|
755
|
-
return `its automation ${JSON.stringify(refName)} is not in source`;
|
|
765
|
+
if (!automationInSource(refName, opts) && platformAutomationName(token, opts) === undefined) {
|
|
766
|
+
return `its automation ${JSON.stringify(refName)} is not in source, and the reference has no display name to look the live automation up by`;
|
|
767
|
+
}
|
|
756
768
|
return undefined;
|
|
757
769
|
}
|
|
770
|
+
function automationInSource(refName, opts) {
|
|
771
|
+
const authored = opts.workspaceAspects?.get(workspaceAspectKey(scopeOf(opts), opts.ownerRefName))?.automationRefNames;
|
|
772
|
+
return authored === undefined || authored.has(refName);
|
|
773
|
+
}
|
|
774
|
+
/**
|
|
775
|
+
* The display name of an automation pull left platform-managed, so build can
|
|
776
|
+
* look the live one up as a run-automation widget does (edk#2693). A pull
|
|
777
|
+
* that could not read the display name prints the key as the name.
|
|
778
|
+
*/
|
|
779
|
+
function platformAutomationName(token, opts) {
|
|
780
|
+
const refName = token?.refName ?? "";
|
|
781
|
+
if (automationInSource(refName, opts))
|
|
782
|
+
return undefined;
|
|
783
|
+
const name = token?.name;
|
|
784
|
+
return typeof name === "string" && name !== "" && name !== refName ? name : undefined;
|
|
785
|
+
}
|
|
758
786
|
function resolveAutomation(token, where, opts) {
|
|
759
787
|
const problem = buttonAutomationProblem(token, opts);
|
|
760
788
|
if (problem !== undefined) {
|
|
@@ -762,6 +790,12 @@ function resolveAutomation(token, where, opts) {
|
|
|
762
790
|
return undefined;
|
|
763
791
|
}
|
|
764
792
|
const refName = token?.refName ?? "";
|
|
793
|
+
const platformName = platformAutomationName(token, opts);
|
|
794
|
+
if (platformName !== undefined) {
|
|
795
|
+
const label = `${opts.ownerTfLabel}_${tsLabelToTfLabel(refName)}`;
|
|
796
|
+
opts.orgRefs.rawLookup(AUTOMATION_RESOURCE_TYPE, label, platformName, { app_id: opts.objectId });
|
|
797
|
+
return expr.dataAttr(AUTOMATION_RESOURCE_TYPE, label, ["id"]);
|
|
798
|
+
}
|
|
765
799
|
return expr.resourceAttr(AUTOMATION_RESOURCE_TYPE, automationResourceLabel(opts.ownerTfLabel, refName, scopeOf(opts), scopeOf(opts) === "element" ? opts.ownerHandle : undefined), ["id"]);
|
|
766
800
|
}
|
|
767
801
|
function isActiveAutomation(refName, opts) {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BuiltRoot } from "../../graph/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* The build error for audit-field references, across the rendered files, on
|
|
4
|
+
* elements built without audit fields; empty when there are none. Each
|
|
5
|
+
* problem names the file, the resource and attribute that hold the
|
|
6
|
+
* reference, and, when the element authors its own field under that key,
|
|
7
|
+
* that field's ref.
|
|
8
|
+
*/
|
|
9
|
+
export declare function missingElementAuditFieldErrors(files: ReadonlyMap<string, string>, roots: readonly BuiltRoot[]): readonly string[];
|