@elementumai/edk 0.12.0 → 0.13.1
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 +8 -2
- package/dist-sdk/src/catalog/factories.d.ts +7 -1
- package/dist-sdk/src/catalog/factories.js +10 -2
- 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 +12 -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/coverage-gaps.d.ts +2 -0
- package/dist-sdk/src/engine/coverage-gaps.js +4 -0
- package/dist-sdk/src/engine/ei/run.d.ts +8 -0
- package/dist-sdk/src/engine/ei/run.js +46 -7
- 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 +34 -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 +159 -0
- package/dist-sdk/src/engine/pull/stream-root.js +579 -0
- package/dist-sdk/src/engine/workspace/authoring-layout.js +16 -2
- 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 +17 -5
- 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 +70 -1
- package/dist-sdk/src/entities/agent/from-tf.d.ts +36 -1
- package/dist-sdk/src/entities/agent/from-tf.js +289 -2
- package/dist-sdk/src/entities/agent/index.d.ts +1 -1
- package/dist-sdk/src/entities/agent/module.js +1 -0
- package/dist-sdk/src/entities/agent/to-tf.d.ts +11 -11
- package/dist-sdk/src/entities/agent/to-tf.js +179 -17
- 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.d.ts +1 -0
- package/dist-sdk/src/entities/app/from-tf.js +7 -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 +3 -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.d.ts +10 -1
- package/dist-sdk/src/entities/automation/build.js +70 -27
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +21 -5
- package/dist-sdk/src/entities/automation/from-tf.d.ts +26 -5
- package/dist-sdk/src/entities/automation/from-tf.js +665 -112
- package/dist-sdk/src/entities/automation/index.d.ts +2 -1
- 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 +45 -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/system-ref-name.d.ts +23 -3
- package/dist-sdk/src/entities/automation/system-ref-name.js +86 -4
- 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 +8 -1
- package/dist-sdk/src/entities/automation/to-tf.js +563 -103
- 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/dashboard/from-tf.d.ts +3 -1
- package/dist-sdk/src/entities/dashboard/from-tf.js +42 -2
- package/dist-sdk/src/entities/dashboard/to-tf.js +9 -1
- package/dist-sdk/src/entities/dashboard-widget-order/module.d.ts +10 -0
- package/dist-sdk/src/entities/dashboard-widget-order/module.js +25 -0
- package/dist-sdk/src/entities/dashboard-widget-order/order.d.ts +31 -0
- package/dist-sdk/src/entities/dashboard-widget-order/order.js +102 -0
- 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.d.ts +1 -0
- package/dist-sdk/src/entities/element/from-tf.js +4 -7
- package/dist-sdk/src/entities/element/module.js +5 -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 +52 -1
- package/dist-sdk/src/entities/field/from-tf.js +212 -14
- 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 +9 -4
- 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/build.d.ts +3 -4
- 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/search-table/build.d.ts +9 -3
- package/dist-sdk/src/entities/search-table/build.js +4 -4
- package/dist-sdk/src/entities/search-table/printer.js +3 -1
- package/dist-sdk/src/entities/search-table/to-tf.js +20 -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/context.d.ts +14 -1
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +2 -0
- package/dist-sdk/src/entities/shared/filters/index.d.ts +97 -15
- package/dist-sdk/src/entities/shared/filters/index.js +30 -7
- 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.d.ts +2 -0
- package/dist-sdk/src/entities/shared/filters/print.js +19 -6
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +16 -7
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +25 -5
- package/dist-sdk/src/entities/shared/filters/types.d.ts +4 -0
- 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.d.ts +1 -1
- package/dist-sdk/src/entities/shared/tool-field-ref.js +3 -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 +3 -2
- package/dist-sdk/src/entities/view/custom-view-validate.d.ts +6 -4
- package/dist-sdk/src/entities/view/custom-view-validate.js +36 -18
- package/dist-sdk/src/entities/view/from-tf.js +16 -4
- package/dist-sdk/src/entities/view/to-tf.js +66 -47
- package/dist-sdk/src/entities/visual-flow/module.js +52 -1
- package/dist-sdk/src/entities/widget/from-tf.js +19 -8
- 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 +9 -0
- package/dist-sdk/src/graph/index.js +8 -0
- package/dist-sdk/src/graph/modules.js +13 -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 +113 -6
- package/package.json +7 -4
|
@@ -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;
|
|
@@ -19,4 +19,6 @@ export interface DashboardOwner {
|
|
|
19
19
|
readonly fieldKeysByName?: ReadonlyMap<string, string | null>;
|
|
20
20
|
readonly unextractedFieldIds?: Set<string>;
|
|
21
21
|
}
|
|
22
|
-
export declare function dashboardsFromTf(blocks: readonly TfBlock[], widgetBlocks: readonly TfBlock[], owner: DashboardOwner, ctx: FromTfContext
|
|
22
|
+
export declare function dashboardsFromTf(blocks: readonly TfBlock[], widgetBlocks: readonly TfBlock[], owner: DashboardOwner, ctx: FromTfContext,
|
|
23
|
+
/** `elementum_dashboard_widget_order` blocks; each orders its dashboard's widgets. */
|
|
24
|
+
orderBlocks?: readonly TfBlock[]): NormalizedDashboard[];
|
|
@@ -5,6 +5,7 @@ import { filterFromTf } from "../access-policy/from-tf.js";
|
|
|
5
5
|
import { filterOwnerForAspect } from "../relationship/from-tf.js";
|
|
6
6
|
import { filterWireToTf } from "../shared/filters/tf-codec.js";
|
|
7
7
|
import { DASHBOARD_WIDGET_RESOURCE_TYPE } from "../dashboard-widget/module.js";
|
|
8
|
+
import { DASHBOARD_WIDGET_ORDER_RESOURCE_TYPE, KNOWN_DASHBOARD_WIDGET_ORDER_ATTRS, dashboardWidgetOrderFor, inDashboardWidgetOrder } from "../dashboard-widget-order/order.js";
|
|
8
9
|
import { DASHBOARD_RESOURCE_TYPE } from "./module.js";
|
|
9
10
|
import { CHART_RESOURCE_TYPE } from "../chart/types.js";
|
|
10
11
|
import { chartRefNameFromTfLabel } from "../chart/from-tf.js";
|
|
@@ -12,7 +13,9 @@ import { dashboardWidgetSize } from "./build.js";
|
|
|
12
13
|
import { resolveDataAspectTarget } from "../shared/aspect-target-from-tf.js";
|
|
13
14
|
import { managedViewSortFromTf } from "../view/from-tf.js";
|
|
14
15
|
const KNOWN_DASHBOARD_ATTRS = new Set(["name", "owner_id", "owner_type", "favorite", "tags"]);
|
|
15
|
-
export function dashboardsFromTf(blocks, widgetBlocks, owner, ctx
|
|
16
|
+
export function dashboardsFromTf(blocks, widgetBlocks, owner, ctx,
|
|
17
|
+
/** `elementum_dashboard_widget_order` blocks; each orders its dashboard's widgets. */
|
|
18
|
+
orderBlocks = []) {
|
|
16
19
|
const dashboards = [];
|
|
17
20
|
for (const block of blocks) {
|
|
18
21
|
const label = block.label;
|
|
@@ -32,7 +35,21 @@ export function dashboardsFromTf(blocks, widgetBlocks, owner, ctx) {
|
|
|
32
35
|
}
|
|
33
36
|
const tags = stringList(block.attrs, "tags", where, ctx);
|
|
34
37
|
const key = scopedLabelToBagKey(owner.ownerTfLabel, label, owner.scope);
|
|
35
|
-
const
|
|
38
|
+
const order = dashboardWidgetOrderFor(orderBlocks, DASHBOARD_RESOURCE_TYPE, label);
|
|
39
|
+
if (order !== undefined) {
|
|
40
|
+
const orderWhere = `${DASHBOARD_WIDGET_ORDER_RESOURCE_TYPE}.${order.label ?? "?"}`;
|
|
41
|
+
reportUnknownAttrs(order.attrs, KNOWN_DASHBOARD_WIDGET_ORDER_ATTRS, orderWhere, "dashboardsFromTf", ctx);
|
|
42
|
+
if (resourceRefLabel(order.attrs["owner_id"], owner.type) !== owner.label) {
|
|
43
|
+
ctx.diagnostics.push(`${orderWhere}: owner_id does not reference ${owner.type}.${owner.label}; widgets keep the export's order`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const ownedWidgets = widgetBlocks.filter((widget) => resourceRefLabel(widget.attrs["dashboard_id"], DASHBOARD_RESOURCE_TYPE) === label);
|
|
47
|
+
const orderedWidgets = order !== undefined && resourceRefLabel(order.attrs["owner_id"], owner.type) === owner.label
|
|
48
|
+
? inDashboardWidgetOrder(ownedWidgets, order)
|
|
49
|
+
: ownedWidgets;
|
|
50
|
+
const widgets = dashboardWidgetsFromTf(orderedWidgets, label, key, owner, ctx);
|
|
51
|
+
if (order !== undefined)
|
|
52
|
+
requireEveryWidget(order, ownedWidgets, widgets, label, ctx);
|
|
36
53
|
dashboards.push({
|
|
37
54
|
key,
|
|
38
55
|
name: optionalString(block.attrs, "name", where, ctx) ?? "",
|
|
@@ -122,6 +139,29 @@ function dashboardWidgetsFromTf(blocks, dashboardLabel, dashboardKey, owner, ctx
|
|
|
122
139
|
}];
|
|
123
140
|
});
|
|
124
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* The order's import lists every chart and records widget of the dashboard,
|
|
144
|
+
* but build lists only the widgets source holds. A widget this pull leaves out
|
|
145
|
+
* would therefore plan a reorder no source edit asked for, so the order is
|
|
146
|
+
* skipped and released with it. It runs after the widgets' own requirements,
|
|
147
|
+
* so a chart widget skipped for its chart takes the order along. The next
|
|
148
|
+
* plan imports the order for the widgets source holds (the kind's
|
|
149
|
+
* stateAdoption), so it plans no change.
|
|
150
|
+
*/
|
|
151
|
+
function requireEveryWidget(order, widgetBlocks, written, dashboardLabel, ctx) {
|
|
152
|
+
if (ctx.requiresExtracted === undefined)
|
|
153
|
+
return;
|
|
154
|
+
const address = `${DASHBOARD_WIDGET_ORDER_RESOURCE_TYPE}.${order.label ?? ""}`;
|
|
155
|
+
const writtenKeys = new Set(written.map((widget) => widget.key));
|
|
156
|
+
for (const block of widgetBlocks) {
|
|
157
|
+
const label = block.label ?? "";
|
|
158
|
+
const key = tfLabelToTsLabel(label.startsWith(`${dashboardLabel}_`) ? label.slice(dashboardLabel.length + 1) : label);
|
|
159
|
+
const requires = `${DASHBOARD_WIDGET_RESOURCE_TYPE}.${label}`;
|
|
160
|
+
ctx.requiresExtracted.push(writtenKeys.has(key)
|
|
161
|
+
? { address, requires, prune: (root) => root }
|
|
162
|
+
: { address, requires, unresolved: true, prune: (root) => root });
|
|
163
|
+
}
|
|
164
|
+
}
|
|
125
165
|
/**
|
|
126
166
|
* The filter ranges over the target's records, so its fields may belong to
|
|
127
167
|
* the target rather than to the dashboard's owner. A raw field id decodes
|
|
@@ -3,6 +3,7 @@ import { workspaceAspectKey } from "../../engine/build/context.js";
|
|
|
3
3
|
import { filterToTf } from "../access-policy/to-tf.js";
|
|
4
4
|
import { filterTfToWire } from "../shared/filters/tf-codec.js";
|
|
5
5
|
import { DASHBOARD_WIDGET_RESOURCE_TYPE } from "../dashboard-widget/module.js";
|
|
6
|
+
import { dashboardWidgetOrderToTf } from "../dashboard-widget-order/order.js";
|
|
6
7
|
import { targetFilterFieldResolver } from "../relationship/to-tf.js";
|
|
7
8
|
import { resolveForeignRef } from "../shared/foreign-ref.js";
|
|
8
9
|
import { DASHBOARD_RESOURCE_TYPE } from "./module.js";
|
|
@@ -30,6 +31,8 @@ export function dashboardsToTf(dashboards, opts) {
|
|
|
30
31
|
label: dashboardLabel,
|
|
31
32
|
attrs,
|
|
32
33
|
});
|
|
34
|
+
// The widgets bag's key order is the dashboard's widget order.
|
|
35
|
+
const widgetLabels = [];
|
|
33
36
|
for (const [widgetKey, widget] of Object.entries(dashboard.widgets ?? {})) {
|
|
34
37
|
const where = `dashboards.${key}.widgets.${widgetKey}`;
|
|
35
38
|
if (!isCanonicalTsLabel(widgetKey)) {
|
|
@@ -92,8 +95,13 @@ export function dashboardsToTf(dashboards, opts) {
|
|
|
92
95
|
opts.diagnostics.push(`${where}: unsupported widget type; dropped`);
|
|
93
96
|
continue;
|
|
94
97
|
}
|
|
95
|
-
|
|
98
|
+
const widgetLabel = scopedResourceLabel(opts.ownerTfLabel, tsLabelToTfLabel(`${key}_${widgetKey}`), opts.scope);
|
|
99
|
+
widgetLabels.push(widgetLabel);
|
|
100
|
+
blocks.push({ kind: "resource", type: DASHBOARD_WIDGET_RESOURCE_TYPE, label: widgetLabel, attrs: widgetAttrs });
|
|
96
101
|
}
|
|
102
|
+
const order = dashboardWidgetOrderToTf(dashboardLabel, opts.ownerId, expr.resourceAttr(DASHBOARD_RESOURCE_TYPE, dashboardLabel, ["id"]), widgetLabels);
|
|
103
|
+
if (order !== undefined)
|
|
104
|
+
blocks.push(order);
|
|
97
105
|
}
|
|
98
106
|
return blocks;
|
|
99
107
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type EntityKindModule } from "../../graph/types.js";
|
|
2
|
+
import { DASHBOARD_WIDGET_ORDER_RESOURCE_TYPE } from "./order.js";
|
|
3
|
+
export { DASHBOARD_WIDGET_ORDER_RESOURCE_TYPE };
|
|
4
|
+
/**
|
|
5
|
+
* `elementum_dashboard_widget_order` orders one dashboard's widgets. Build
|
|
6
|
+
* emits it from the authored `widgets` key order; pull prints widgets in its
|
|
7
|
+
* order. It has no authoring of its own: the bag order is the order. Its
|
|
8
|
+
* import id is `<owner id>:<dashboard id>`.
|
|
9
|
+
*/
|
|
10
|
+
export declare const dashboardWidgetOrderModule: EntityKindModule;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { NO_CANVAS, NO_CATALOG, NO_DATA, NO_LIFECYCLE } from "../../graph/types.js";
|
|
2
|
+
import { DASHBOARD_WIDGET_ORDER_RESOURCE_TYPE, dashboardWidgetOrderStateAdoption } from "./order.js";
|
|
3
|
+
export { DASHBOARD_WIDGET_ORDER_RESOURCE_TYPE };
|
|
4
|
+
/**
|
|
5
|
+
* `elementum_dashboard_widget_order` orders one dashboard's widgets. Build
|
|
6
|
+
* emits it from the authored `widgets` key order; pull prints widgets in its
|
|
7
|
+
* order. It has no authoring of its own: the bag order is the order. Its
|
|
8
|
+
* import id is `<owner id>:<dashboard id>`.
|
|
9
|
+
*/
|
|
10
|
+
export const dashboardWidgetOrderModule = {
|
|
11
|
+
kind: "dashboard-widget-order",
|
|
12
|
+
stream: { role: "streamMember" },
|
|
13
|
+
authoring: { unit: "inline", bag: "widgets" },
|
|
14
|
+
parents: [{ parent: "dashboard", child: "dashboard-widget-order" }],
|
|
15
|
+
resource: { shape: "single", resourceType: DASHBOARD_WIDGET_ORDER_RESOURCE_TYPE, adoptable: true },
|
|
16
|
+
data: NO_DATA,
|
|
17
|
+
lifecycle: NO_LIFECYCLE,
|
|
18
|
+
canvas: NO_CANVAS,
|
|
19
|
+
catalog: NO_CATALOG,
|
|
20
|
+
stateAdoption: dashboardWidgetOrderStateAdoption,
|
|
21
|
+
// Build writes no order when the dashboard has no authored widgets.
|
|
22
|
+
portable: {
|
|
23
|
+
leaveOutWhenEmptied: [{ resourceType: DASHBOARD_WIDGET_ORDER_RESOURCE_TYPE, attribute: "widget_ids", reason: "it only ordered the left-out widgets" }],
|
|
24
|
+
},
|
|
25
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type TfBlock, type TfValue } from "../../engine/tf/index.js";
|
|
2
|
+
import type { StateAdoptionFacet } from "../../graph/types.js";
|
|
3
|
+
export declare const DASHBOARD_WIDGET_ORDER_RESOURCE_TYPE = "elementum_dashboard_widget_order";
|
|
4
|
+
/**
|
|
5
|
+
* The dashboard's widget order block, or undefined when it has no widget
|
|
6
|
+
* resource. It takes the dashboard's own label (one order per dashboard), as
|
|
7
|
+
* `ei export` names it. `widgetLabels` is in authored order.
|
|
8
|
+
*/
|
|
9
|
+
export declare function dashboardWidgetOrderToTf(dashboardLabel: string, ownerId: TfValue, dashboardId: TfValue, widgetLabels: readonly string[]): TfBlock | undefined;
|
|
10
|
+
/** Attributes `inDashboardWidgetOrder` reads. */
|
|
11
|
+
export declare const KNOWN_DASHBOARD_WIDGET_ORDER_ATTRS: ReadonlySet<string>;
|
|
12
|
+
/** The order block whose `dashboard_id` references `dashboardType.dashboardLabel`. */
|
|
13
|
+
export declare function dashboardWidgetOrderFor(orderBlocks: readonly TfBlock[], dashboardType: string, dashboardLabel: string): TfBlock | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* `widgetBlocks` in the order the dashboard's widget order lists them, so pull
|
|
16
|
+
* prints widgets in the platform's order instead of the parser's label order.
|
|
17
|
+
* Widgets it doesn't list keep their relative order after the listed ones.
|
|
18
|
+
*/
|
|
19
|
+
export declare function inDashboardWidgetOrder(widgetBlocks: readonly TfBlock[], orderBlock: TfBlock | undefined): readonly TfBlock[];
|
|
20
|
+
/**
|
|
21
|
+
* A dashboard whose order has no state would plan a hidden create (a live
|
|
22
|
+
* reorder): a workspace pulled before widget order was managed, or a pull that
|
|
23
|
+
* left one of the dashboard's widgets out of source and released the order
|
|
24
|
+
* with it. When the dashboard is in state but its order isn't, import the live
|
|
25
|
+
* order, keyed `<owner id>:<dashboard id>:<widget ids>` with the ids of the
|
|
26
|
+
* widgets build lists that state already holds. The provider then tracks only
|
|
27
|
+
* those widgets, so a widget source doesn't hold never shows as a change, and
|
|
28
|
+
* any reorder of the listed ones shows as a visible in-place `widget_ids`
|
|
29
|
+
* update.
|
|
30
|
+
*/
|
|
31
|
+
export declare const dashboardWidgetOrderStateAdoption: StateAdoptionFacet;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A dashboard's widget order: `elementum_dashboard_widget_order` lists the
|
|
3
|
+
* dashboard's widget resources in authored `widgets` key order. Without it a
|
|
4
|
+
* widget keeps the position the platform gave it at create (the widget count
|
|
5
|
+
* then), and every add or delete shifts the rest, so the rendered order drifts
|
|
6
|
+
* between applies.
|
|
7
|
+
*/
|
|
8
|
+
import { resourceRefLabel } from "../../engine/pull/context.js";
|
|
9
|
+
import { expr, isTfExpr } from "../../engine/tf/index.js";
|
|
10
|
+
import { DASHBOARD_WIDGET_RESOURCE_TYPE } from "../dashboard-widget/module.js";
|
|
11
|
+
export const DASHBOARD_WIDGET_ORDER_RESOURCE_TYPE = "elementum_dashboard_widget_order";
|
|
12
|
+
/**
|
|
13
|
+
* The dashboard's widget order block, or undefined when it has no widget
|
|
14
|
+
* resource. It takes the dashboard's own label (one order per dashboard), as
|
|
15
|
+
* `ei export` names it. `widgetLabels` is in authored order.
|
|
16
|
+
*/
|
|
17
|
+
export function dashboardWidgetOrderToTf(dashboardLabel, ownerId, dashboardId, widgetLabels) {
|
|
18
|
+
if (widgetLabels.length === 0)
|
|
19
|
+
return undefined;
|
|
20
|
+
return {
|
|
21
|
+
kind: "resource",
|
|
22
|
+
type: DASHBOARD_WIDGET_ORDER_RESOURCE_TYPE,
|
|
23
|
+
label: dashboardLabel,
|
|
24
|
+
attrs: {
|
|
25
|
+
owner_id: ownerId,
|
|
26
|
+
dashboard_id: dashboardId,
|
|
27
|
+
widget_ids: widgetLabels.map((label) => expr.resourceAttr(DASHBOARD_WIDGET_RESOURCE_TYPE, label, ["id"])),
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/** Attributes `inDashboardWidgetOrder` reads. */
|
|
32
|
+
export const KNOWN_DASHBOARD_WIDGET_ORDER_ATTRS = new Set(["owner_id", "dashboard_id", "widget_ids"]);
|
|
33
|
+
/** The order block whose `dashboard_id` references `dashboardType.dashboardLabel`. */
|
|
34
|
+
export function dashboardWidgetOrderFor(orderBlocks, dashboardType, dashboardLabel) {
|
|
35
|
+
return orderBlocks.find((block) => resourceRefLabel(block.attrs["dashboard_id"], dashboardType) === dashboardLabel);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* `widgetBlocks` in the order the dashboard's widget order lists them, so pull
|
|
39
|
+
* prints widgets in the platform's order instead of the parser's label order.
|
|
40
|
+
* Widgets it doesn't list keep their relative order after the listed ones.
|
|
41
|
+
*/
|
|
42
|
+
export function inDashboardWidgetOrder(widgetBlocks, orderBlock) {
|
|
43
|
+
const widgetIds = orderBlock?.attrs["widget_ids"];
|
|
44
|
+
if (!Array.isArray(widgetIds))
|
|
45
|
+
return widgetBlocks;
|
|
46
|
+
const position = new Map();
|
|
47
|
+
for (const [index, value] of widgetIds.entries()) {
|
|
48
|
+
const label = resourceRefLabel(value, DASHBOARD_WIDGET_RESOURCE_TYPE);
|
|
49
|
+
if (label !== undefined)
|
|
50
|
+
position.set(label, index);
|
|
51
|
+
}
|
|
52
|
+
const at = (block) => position.get(block.label ?? "") ?? Number.MAX_SAFE_INTEGER;
|
|
53
|
+
return [...widgetBlocks].sort((a, b) => at(a) - at(b));
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* A dashboard whose order has no state would plan a hidden create (a live
|
|
57
|
+
* reorder): a workspace pulled before widget order was managed, or a pull that
|
|
58
|
+
* left one of the dashboard's widgets out of source and released the order
|
|
59
|
+
* with it. When the dashboard is in state but its order isn't, import the live
|
|
60
|
+
* order, keyed `<owner id>:<dashboard id>:<widget ids>` with the ids of the
|
|
61
|
+
* widgets build lists that state already holds. The provider then tracks only
|
|
62
|
+
* those widgets, so a widget source doesn't hold never shows as a change, and
|
|
63
|
+
* any reorder of the listed ones shows as a visible in-place `widget_ids`
|
|
64
|
+
* update.
|
|
65
|
+
*/
|
|
66
|
+
export const dashboardWidgetOrderStateAdoption = {
|
|
67
|
+
importsFor(blocks, state) {
|
|
68
|
+
const out = [];
|
|
69
|
+
for (const block of blocks) {
|
|
70
|
+
if (block.kind !== "resource" || block.type !== DASHBOARD_WIDGET_ORDER_RESOURCE_TYPE || block.label === undefined)
|
|
71
|
+
continue;
|
|
72
|
+
if (state.has(block.type, block.label))
|
|
73
|
+
continue;
|
|
74
|
+
const owner = block.attrs["owner_id"];
|
|
75
|
+
const dashboard = block.attrs["dashboard_id"];
|
|
76
|
+
if (!isTfExpr(owner) || owner.$expr !== "resource-attr")
|
|
77
|
+
continue;
|
|
78
|
+
if (!isTfExpr(dashboard) || dashboard.$expr !== "resource-attr")
|
|
79
|
+
continue;
|
|
80
|
+
const ownerId = state.idOf(owner.type, owner.label);
|
|
81
|
+
const dashboardId = state.idOf(dashboard.type, dashboard.label);
|
|
82
|
+
if (ownerId === undefined || dashboardId === undefined)
|
|
83
|
+
continue;
|
|
84
|
+
const widgetIds = Array.isArray(block.attrs["widget_ids"]) ? block.attrs["widget_ids"] : [];
|
|
85
|
+
const tracked = widgetIds.flatMap((value) => {
|
|
86
|
+
const label = resourceRefLabel(value, DASHBOARD_WIDGET_RESOURCE_TYPE);
|
|
87
|
+
const id = label === undefined ? undefined : state.idOf(DASHBOARD_WIDGET_RESOURCE_TYPE, label);
|
|
88
|
+
return id === undefined ? [] : [id];
|
|
89
|
+
});
|
|
90
|
+
out.push({ type: block.type, label: block.label, id: `${ownerId}:${dashboardId}:${tracked.join(",")}` });
|
|
91
|
+
}
|
|
92
|
+
return out;
|
|
93
|
+
},
|
|
94
|
+
warning(imports) {
|
|
95
|
+
const names = imports.slice(0, 5).map((i) => i.label).join(", ");
|
|
96
|
+
const more = imports.length > 5 ? `, … (+${imports.length - 5} more)` : "";
|
|
97
|
+
return [
|
|
98
|
+
`${imports.length} dashboard(s) have no ${DASHBOARD_WIDGET_ORDER_RESOURCE_TYPE} state (a workspace pulled before widget order was managed, or a pull that left one of the dashboard's widgets out): ${names}${more}.`,
|
|
99
|
+
"Importing their live widget order for the widgets in source; a widget_ids change in the plan reorders the dashboard to match the widgets' order in source.",
|
|
100
|
+
].join("\n");
|
|
101
|
+
},
|
|
102
|
+
};
|
|
@@ -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
|
};
|