@elementumai/edk 0.9.18 → 0.9.20
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 +154 -9
- package/dist-sdk/src/catalog/factories.d.ts +35 -1
- package/dist-sdk/src/catalog/factories.js +36 -0
- package/dist-sdk/src/catalog/from-authoring.d.ts +13 -8
- package/dist-sdk/src/catalog/from-authoring.js +34 -9
- package/dist-sdk/src/catalog/index.d.ts +2 -2
- package/dist-sdk/src/catalog/index.js +2 -2
- package/dist-sdk/src/catalog/org.d.ts +39 -1
- package/dist-sdk/src/catalog/org.js +460 -50
- package/dist-sdk/src/catalog/render.js +6 -6
- package/dist-sdk/src/catalog/token.js +7 -0
- package/dist-sdk/src/catalog/types.d.ts +44 -1
- package/dist-sdk/src/catalog/types.js +13 -0
- package/dist-sdk/src/core/triggers/on-demand.d.ts +39 -3
- package/dist-sdk/src/core/triggers/on-demand.js +10 -2
- package/dist-sdk/src/engine/build/context.d.ts +1 -1
- package/dist-sdk/src/engine/ei/run.d.ts +149 -0
- package/dist-sdk/src/engine/ei/run.js +1132 -0
- package/dist-sdk/src/engine/logging.d.ts +17 -0
- package/dist-sdk/src/engine/logging.js +18 -0
- package/dist-sdk/src/engine/pull/ref-only.d.ts +5 -0
- package/dist-sdk/src/engine/pull/ref-only.js +64 -27
- package/dist-sdk/src/engine/pull/result-output.d.ts +8 -0
- package/dist-sdk/src/engine/pull/result-output.js +88 -4
- package/dist-sdk/src/engine/tf/expr.js +39 -14
- package/dist-sdk/src/engine/tf/index.d.ts +3 -3
- package/dist-sdk/src/engine/tf/index.js +2 -2
- package/dist-sdk/src/engine/tf/labels.d.ts +8 -0
- package/dist-sdk/src/engine/tf/labels.js +13 -0
- package/dist-sdk/src/engine/tf/model.d.ts +22 -1
- package/dist-sdk/src/engine/tf/parse.d.ts +19 -0
- package/dist-sdk/src/engine/tf/parse.js +197 -10
- package/dist-sdk/src/engine/tf/render.d.ts +4 -2
- package/dist-sdk/src/engine/tf/render.js +41 -7
- package/dist-sdk/src/engine/validation.d.ts +39 -0
- package/dist-sdk/src/engine/validation.js +85 -0
- package/dist-sdk/src/engine/workspace/loader.js +49 -12
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +11 -1
- package/dist-sdk/src/entities/access-policy/from-tf.js +6 -1
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +11 -0
- package/dist-sdk/src/entities/access-policy/to-tf.js +16 -6
- package/dist-sdk/src/entities/agent/build.d.ts +4 -16
- package/dist-sdk/src/entities/agent/build.js +40 -5
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +4 -2
- package/dist-sdk/src/entities/agent/to-tf.js +6 -3
- package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/agent-tool/from-tf.js +7 -1
- package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +2 -2
- package/dist-sdk/src/entities/agent-tool/to-tf.js +29 -6
- package/dist-sdk/src/entities/app/build.d.ts +98 -19
- package/dist-sdk/src/entities/app/build.js +51 -19
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +22 -1
- package/dist-sdk/src/entities/app/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/app/from-tf.js +11 -5
- package/dist-sdk/src/entities/app/index.d.ts +6 -5
- package/dist-sdk/src/entities/app/index.js +2 -0
- package/dist-sdk/src/entities/app/module.js +18 -2
- package/dist-sdk/src/entities/app/to-tf.js +21 -11
- package/dist-sdk/src/entities/automation/build.d.ts +49 -6
- package/dist-sdk/src/entities/automation/build.js +163 -19
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +24 -1
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +320 -39
- package/dist-sdk/src/entities/automation/from-tf.d.ts +28 -6
- package/dist-sdk/src/entities/automation/from-tf.js +563 -74
- package/dist-sdk/src/entities/automation/generated/task-output-contracts.d.ts +33 -0
- package/dist-sdk/src/entities/automation/generated/task-output-contracts.js +183 -0
- package/dist-sdk/src/entities/automation/index.d.ts +2 -2
- package/dist-sdk/src/entities/automation/index.js +1 -1
- package/dist-sdk/src/entities/automation/module.d.ts +2 -0
- package/dist-sdk/src/entities/automation/module.js +93 -8
- package/dist-sdk/src/entities/automation/output-field-types.d.ts +7 -0
- package/dist-sdk/src/entities/automation/output-field-types.js +36 -0
- package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +9 -0
- package/dist-sdk/src/entities/automation/output-key-wire-name.js +13 -0
- package/dist-sdk/src/entities/automation/script-code.d.ts +17 -0
- package/dist-sdk/src/entities/automation/script-code.js +91 -5
- package/dist-sdk/src/entities/automation/system-ref-name.d.ts +16 -0
- package/dist-sdk/src/entities/automation/system-ref-name.js +48 -0
- package/dist-sdk/src/entities/automation/task-output-labels.d.ts +17 -0
- package/dist-sdk/src/entities/automation/task-output-labels.js +47 -0
- package/dist-sdk/src/entities/automation/tasks.d.ts +53 -4
- package/dist-sdk/src/entities/automation/tasks.js +38 -9
- package/dist-sdk/src/entities/automation/to-tf.d.ts +4 -0
- package/dist-sdk/src/entities/automation/to-tf.js +647 -167
- package/dist-sdk/src/entities/automation/triggers.d.ts +4 -2
- package/dist-sdk/src/entities/automation/triggers.js +4 -0
- package/dist-sdk/src/entities/automation/types.js +1 -0
- package/dist-sdk/src/entities/chart/from-tf.js +33 -17
- package/dist-sdk/src/entities/chart/module.js +3 -1
- package/dist-sdk/src/entities/chart/printer.d.ts +1 -0
- package/dist-sdk/src/entities/chart/printer.js +26 -16
- package/dist-sdk/src/entities/chart/rebind-owner.d.ts +3 -0
- package/dist-sdk/src/entities/chart/rebind-owner.js +42 -0
- package/dist-sdk/src/entities/chart/to-tf.js +21 -12
- package/dist-sdk/src/entities/dashboard/build.d.ts +4 -0
- package/dist-sdk/src/entities/dashboard/from-tf.js +15 -4
- package/dist-sdk/src/entities/dashboard/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/dashboard/to-tf.js +13 -0
- package/dist-sdk/src/entities/dashboard-widget/module.js +4 -0
- package/dist-sdk/src/entities/dynamic-layout/build.d.ts +72 -30
- package/dist-sdk/src/entities/dynamic-layout/dialect.d.ts +3 -0
- package/dist-sdk/src/entities/dynamic-layout/dialect.js +5 -0
- package/dist-sdk/src/entities/dynamic-layout/from-tf.d.ts +9 -6
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +188 -26
- package/dist-sdk/src/entities/dynamic-layout/module.js +4 -1
- package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +5 -1
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +254 -23
- package/dist-sdk/src/entities/element/build.d.ts +33 -13
- package/dist-sdk/src/entities/element/build.js +5 -1
- package/dist-sdk/src/entities/element/from-tf.d.ts +12 -0
- package/dist-sdk/src/entities/element/from-tf.js +64 -3
- package/dist-sdk/src/entities/element/index.d.ts +5 -2
- package/dist-sdk/src/entities/element/index.js +2 -0
- package/dist-sdk/src/entities/element/module.js +11 -3
- package/dist-sdk/src/entities/element/to-tf.js +20 -2
- package/dist-sdk/src/entities/field/build.d.ts +14 -1
- package/dist-sdk/src/entities/field/build.js +3 -0
- package/dist-sdk/src/entities/field/from-tf.d.ts +3 -0
- package/dist-sdk/src/entities/field/from-tf.js +50 -1
- package/dist-sdk/src/entities/field/media-types.d.ts +6 -0
- package/dist-sdk/src/entities/field/media-types.js +30 -0
- package/dist-sdk/src/entities/field/module.js +1 -0
- package/dist-sdk/src/entities/field/to-tf.d.ts +23 -2
- package/dist-sdk/src/entities/field/to-tf.js +142 -22
- package/dist-sdk/src/entities/file-reader/from-tf.js +14 -5
- package/dist-sdk/src/entities/file-reader/module.js +1 -0
- package/dist-sdk/src/entities/file-reader/types.d.ts +2 -0
- package/dist-sdk/src/entities/file-reader/types.js +1 -1
- package/dist-sdk/src/entities/portal/build.d.ts +26 -0
- package/dist-sdk/src/entities/portal/build.js +37 -0
- package/dist-sdk/src/entities/portal/from-tf.d.ts +27 -0
- package/dist-sdk/src/entities/portal/from-tf.js +75 -0
- package/dist-sdk/src/entities/portal/index.d.ts +1 -0
- package/dist-sdk/src/entities/portal/index.js +1 -0
- package/dist-sdk/src/entities/portal/module.d.ts +3 -0
- package/dist-sdk/src/entities/portal/module.js +28 -0
- package/dist-sdk/src/entities/portal/to-tf.d.ts +12 -0
- package/dist-sdk/src/entities/portal/to-tf.js +73 -0
- package/dist-sdk/src/entities/portal/types.d.ts +1 -0
- package/dist-sdk/src/entities/portal/types.js +1 -0
- package/dist-sdk/src/entities/relationship/from-tf.d.ts +8 -1
- package/dist-sdk/src/entities/relationship/from-tf.js +53 -10
- package/dist-sdk/src/entities/relationship/module.js +2 -0
- package/dist-sdk/src/entities/relationship/pair-check.d.ts +7 -0
- package/dist-sdk/src/entities/relationship/pair-check.js +68 -0
- package/dist-sdk/src/entities/relationship/to-tf.d.ts +10 -0
- package/dist-sdk/src/entities/relationship/to-tf.js +31 -13
- package/dist-sdk/src/entities/search-table/module.js +1 -0
- package/dist-sdk/src/entities/search-table/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/search-table/to-tf.js +1 -1
- package/dist-sdk/src/entities/service-account/build.d.ts +15 -2
- package/dist-sdk/src/entities/service-account/from-tf.d.ts +2 -4
- package/dist-sdk/src/entities/service-account/from-tf.js +17 -5
- package/dist-sdk/src/entities/service-account/role-fidelity.d.ts +56 -0
- package/dist-sdk/src/entities/service-account/role-fidelity.js +243 -0
- package/dist-sdk/src/entities/service-account/to-tf.d.ts +14 -0
- package/dist-sdk/src/entities/service-account/to-tf.js +17 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +1 -1
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +5 -2
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +15 -2
- package/dist-sdk/src/entities/shared/filters/index.d.ts +25 -2
- package/dist-sdk/src/entities/shared/filters/index.js +38 -5
- package/dist-sdk/src/entities/shared/filters/print.js +31 -3
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +25 -3
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +51 -15
- package/dist-sdk/src/entities/shared/filters/types.d.ts +22 -5
- package/dist-sdk/src/entities/shared/foreign-ref.d.ts +16 -0
- package/dist-sdk/src/entities/shared/foreign-ref.js +17 -1
- package/dist-sdk/src/entities/shared/tool-field-ref.js +6 -9
- package/dist-sdk/src/entities/shared/types/field-types.d.ts +10 -5
- package/dist-sdk/src/entities/shared/types/field-types.js +4 -0
- package/dist-sdk/src/entities/skill/access-policy.d.ts +17 -0
- package/dist-sdk/src/entities/skill/access-policy.js +101 -0
- package/dist-sdk/src/entities/skill/build.d.ts +3 -0
- package/dist-sdk/src/entities/skill/build.js +3 -0
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +4 -1
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +23 -1
- package/dist-sdk/src/entities/skill/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/skill/from-tf.js +70 -22
- package/dist-sdk/src/entities/skill/index.d.ts +2 -0
- package/dist-sdk/src/entities/skill/index.js +1 -0
- package/dist-sdk/src/entities/skill/input-coverage.d.ts +7 -0
- package/dist-sdk/src/entities/skill/input-coverage.js +11 -0
- package/dist-sdk/src/entities/skill/module.js +1 -0
- package/dist-sdk/src/entities/skill/to-tf.d.ts +2 -2
- package/dist-sdk/src/entities/skill/to-tf.js +19 -6
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/skill-tool/from-tf.js +8 -2
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +2 -2
- package/dist-sdk/src/entities/skill-tool/to-tf.js +29 -6
- package/dist-sdk/src/entities/table/catalog.d.ts +14 -0
- package/dist-sdk/src/entities/table/catalog.js +66 -0
- package/dist-sdk/src/entities/table/module.js +2 -1
- package/dist-sdk/src/entities/table/to-tf.js +5 -5
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +89 -0
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +277 -0
- package/dist-sdk/src/entities/view/agent-view-layout-to-tf.d.ts +51 -0
- package/dist-sdk/src/entities/view/agent-view-layout-to-tf.js +360 -0
- package/dist-sdk/src/entities/view/agent-view-layout.d.ts +151 -0
- package/dist-sdk/src/entities/view/agent-view-layout.js +21 -0
- package/dist-sdk/src/entities/view/from-tf.d.ts +6 -3
- package/dist-sdk/src/entities/view/from-tf.js +161 -14
- package/dist-sdk/src/entities/view/module.js +30 -3
- package/dist-sdk/src/entities/view/to-tf.d.ts +24 -2
- package/dist-sdk/src/entities/view/to-tf.js +95 -9
- package/dist-sdk/src/entities/view/types.d.ts +4 -15
- package/dist-sdk/src/entities/view/types.js +17 -15
- package/dist-sdk/src/entities/widget/build.d.ts +16 -1
- package/dist-sdk/src/entities/widget/build.js +11 -1
- package/dist-sdk/src/entities/widget/to-tf.js +36 -10
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +38 -10
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
- package/dist-sdk/src/graph/index.d.ts +54 -0
- package/dist-sdk/src/graph/index.js +30 -0
- package/dist-sdk/src/graph/modules.js +2 -0
- package/dist-sdk/src/graph/types.d.ts +133 -2
- package/dist-sdk/src/internal/sdk-package.d.ts +1 -1
- package/dist-sdk/src/internal/sdk-package.js +1 -0
- package/package.json +11 -1
|
@@ -9,6 +9,7 @@ import { dataRefLabel, optionalBoolean, optionalString } from "../../engine/pull
|
|
|
9
9
|
import { tfLabelToTsLabel } from "../../engine/tf/index.js";
|
|
10
10
|
import { accessPolicyFromTf } from "../access-policy/from-tf.js";
|
|
11
11
|
import { dashboardsFromTf } from "../dashboard/from-tf.js";
|
|
12
|
+
import { dynamicLayoutCompanionWidgetLabels, dynamicLayoutsFromTf } from "../dynamic-layout/from-tf.js";
|
|
12
13
|
import { fieldFromTf } from "../field/from-tf.js";
|
|
13
14
|
import { recordCreateFormFromTf } from "../record-create-form/from-tf.js";
|
|
14
15
|
import { relationshipsFromTf } from "../relationship/from-tf.js";
|
|
@@ -134,7 +135,7 @@ export function elementFromTf(elementBlock, fieldBlocks, ctx, viewBlocks = {
|
|
|
134
135
|
if (idName !== undefined || idFieldDescription !== undefined) {
|
|
135
136
|
fields.push(systemEntry("id", idName ?? DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES.id, "TEXT", "HANDLE", idFieldDescription));
|
|
136
137
|
}
|
|
137
|
-
const owner = { type: ELEMENT_RESOURCE_TYPE, label, scope: "element" };
|
|
138
|
+
const owner = { type: ELEMENT_RESOURCE_TYPE, label, scope: "element", refName };
|
|
138
139
|
for (const block of fieldBlocks) {
|
|
139
140
|
const entry = fieldFromTf(block, owner, ctx);
|
|
140
141
|
if (entry !== undefined)
|
|
@@ -145,13 +146,15 @@ export function elementFromTf(elementBlock, fieldBlocks, ctx, viewBlocks = {
|
|
|
145
146
|
ctx.diagnostics.push(`element "${label}": no import block in the stream — adoption has no identity to bind`);
|
|
146
147
|
}
|
|
147
148
|
const dashboards = dashboardsFromTf(viewBlocks.dashboardBlocks, viewBlocks.dashboardWidgetBlocks, { type: ELEMENT_RESOURCE_TYPE, label, ownerTfLabel: refName, ownerRefName: refName, scope: "element", ownerType: "ELEMENT_ASPECT" }, ctx);
|
|
148
|
-
const { layouts, listViews, calendarViews, kanbanViews, dashboardViews, viewOrder } = viewsFromTf(viewBlocks.layoutBlocks, viewBlocks.listViewBlocks, viewBlocks.calendarViewBlocks, viewBlocks.kanbanViewBlocks, viewBlocks.dashboardViewBlocks, [], viewBlocks.managedViewOrderBlocks, { type: ELEMENT_RESOURCE_TYPE, label, ownerTfLabel: label, scope: "element" }, ctx);
|
|
149
|
+
const { layouts, listViews, calendarViews, kanbanViews, dashboardViews, customViews, viewOrder } = viewsFromTf(viewBlocks.layoutBlocks, viewBlocks.listViewBlocks, viewBlocks.calendarViewBlocks, viewBlocks.kanbanViewBlocks, viewBlocks.dashboardViewBlocks, [], viewBlocks.managedViewOrderBlocks, { type: ELEMENT_RESOURCE_TYPE, label, ownerTfLabel: label, scope: "element" }, ctx, viewBlocks.customViewBlocks);
|
|
149
150
|
if (viewBlocks.recordCreateFormBlocks.length > 1) {
|
|
150
151
|
ctx.diagnostics.push(`element "${label}": found ${viewBlocks.recordCreateFormBlocks.length} record create forms; only the first is used`);
|
|
151
152
|
}
|
|
152
153
|
const recordCreateForm = recordCreateFormFromTf(viewBlocks.recordCreateFormBlocks[0], { type: ELEMENT_RESOURCE_TYPE, label, ownerTfLabel: refName, scope: "element" }, ctx);
|
|
153
154
|
const relationships = relationshipsFromTf(viewBlocks.relationshipBlocks, { kind: "element", label, ownerRefName: refName, ownerTfLabel: refName, scope: "element" }, ctx);
|
|
154
|
-
const
|
|
155
|
+
const dynamicLayoutBlocks = viewBlocks.dynamicLayoutBlocks ?? [];
|
|
156
|
+
const dynamicLayouts = dynamicLayoutsFromTf(dynamicLayoutBlocks, { type: ELEMENT_RESOURCE_TYPE, label, ownerRefName: refName, ownerTfLabel: label, scope: "element" }, ctx);
|
|
157
|
+
const widgets = widgetsFromTf(viewBlocks.widgetBlocks, { type: ELEMENT_RESOURCE_TYPE, label, ownerRefName: refName, ownerTfLabel: label, scope: "element" }, ctx, dynamicLayoutCompanionWidgetLabels(dynamicLayoutBlocks, { type: ELEMENT_RESOURCE_TYPE, label, ownerRefName: refName, ownerTfLabel: label, scope: "element" }));
|
|
155
158
|
const accessPolicyOwner = {
|
|
156
159
|
type: ELEMENT_RESOURCE_TYPE,
|
|
157
160
|
label,
|
|
@@ -166,6 +169,11 @@ export function elementFromTf(elementBlock, fieldBlocks, ctx, viewBlocks = {
|
|
|
166
169
|
accessPolicies.push(entry);
|
|
167
170
|
}
|
|
168
171
|
const roles = rolesFromTf(roleBlocks, accessPolicyOwner, ctx);
|
|
172
|
+
const auditFields = referencesElementAuditFields(label, [
|
|
173
|
+
...Object.values(viewBlocks).flatMap((blocks) => blocks ?? []),
|
|
174
|
+
...accessPolicyBlocks,
|
|
175
|
+
...roleBlocks,
|
|
176
|
+
], new Set(fields.map(({ field }) => field.name.toLowerCase())));
|
|
169
177
|
const element = {
|
|
170
178
|
id: elementId ?? "",
|
|
171
179
|
name,
|
|
@@ -183,14 +191,17 @@ export function elementFromTf(elementBlock, fieldBlocks, ctx, viewBlocks = {
|
|
|
183
191
|
...(cloudOptions !== undefined && { cloudOptions }),
|
|
184
192
|
...(cloudConnection !== undefined && { cloudConnection }),
|
|
185
193
|
...(commentsEnabled !== undefined && { commentsEnabled }),
|
|
194
|
+
...(auditFields && { auditFields }),
|
|
186
195
|
...(layouts.length > 0 && { layouts }),
|
|
187
196
|
...(listViews.length > 0 && { listViews }),
|
|
188
197
|
...(calendarViews.length > 0 && { calendarViews }),
|
|
189
198
|
...(kanbanViews.length > 0 && { kanbanViews }),
|
|
190
199
|
...(dashboardViews.length > 0 && { dashboardViews }),
|
|
200
|
+
...(customViews.length > 0 && { customViews }),
|
|
191
201
|
...(dashboards.length > 0 && { dashboards }),
|
|
192
202
|
...(widgets.length > 0 && { widgets }),
|
|
193
203
|
...(recordCreateForm !== undefined && { recordCreateForm }),
|
|
204
|
+
...(dynamicLayouts.length > 0 && { dynamicLayouts }),
|
|
194
205
|
...(relationships.length > 0 && { relationships }),
|
|
195
206
|
...(viewOrder !== undefined && { viewOrder }),
|
|
196
207
|
...(accessPolicies.length > 0 && { accessPolicies }),
|
|
@@ -201,3 +212,53 @@ export function elementFromTf(elementBlock, fieldBlocks, ctx, viewBlocks = {
|
|
|
201
212
|
function systemEntry(key, name, type, tag, description) {
|
|
202
213
|
return { key, field: { id: "", name, type, tags: [tag], ...(description !== undefined && { description }) } };
|
|
203
214
|
}
|
|
215
|
+
const AUDIT_TRIGGER_REF_NAME = /^(?:Created|Updated) (?:At|On|By)\b/i;
|
|
216
|
+
/**
|
|
217
|
+
* The export references an element's audit fields only when the platform
|
|
218
|
+
* gave it those fields, which EDK cannot otherwise observe: through its
|
|
219
|
+
* `<label>_(created|updated)_(at|by)_field_id` locals, or, in the element's
|
|
220
|
+
* own automations, through a trigger's Created/Updated outputs. Locals
|
|
221
|
+
* blocks are skipped by callers: `ei` defines those locals on every element.
|
|
222
|
+
* An authored field with the same display name wins over trigger-output
|
|
223
|
+
* heuristics.
|
|
224
|
+
*/
|
|
225
|
+
export function referencesElementAuditFields(label, blocks, authoredFieldNames = new Set()) {
|
|
226
|
+
const auditLocal = new RegExp(`^${label}_(?:created|updated)_(?:at|by)_field_id$`);
|
|
227
|
+
const ownedTriggers = elementTriggerAddresses(label, blocks);
|
|
228
|
+
const visit = (value) => {
|
|
229
|
+
if (Array.isArray(value))
|
|
230
|
+
return value.some(visit);
|
|
231
|
+
if (typeof value !== "object" || value === null)
|
|
232
|
+
return false;
|
|
233
|
+
const node = value;
|
|
234
|
+
if (node["$expr"] === "local" && typeof node["name"] === "string" && auditLocal.test(node["name"]))
|
|
235
|
+
return true;
|
|
236
|
+
if (node["$expr"] === "resource-attr" && ownedTriggers.has(`${String(node["type"])}.${String(node["label"])}`)) {
|
|
237
|
+
const path = node["path"];
|
|
238
|
+
const index = path?.[1]?.index;
|
|
239
|
+
if (path?.[0] === "refs" &&
|
|
240
|
+
typeof index === "string" &&
|
|
241
|
+
AUDIT_TRIGGER_REF_NAME.test(index) &&
|
|
242
|
+
!authoredFieldNames.has(index.toLowerCase()))
|
|
243
|
+
return true;
|
|
244
|
+
}
|
|
245
|
+
return Object.values(node).some(visit);
|
|
246
|
+
};
|
|
247
|
+
return blocks.some((block) => block.kind !== "locals" && visit(block.attrs));
|
|
248
|
+
}
|
|
249
|
+
/** `<type>.<label>` of the triggers on automations whose `app_id` is this element. */
|
|
250
|
+
function elementTriggerAddresses(label, blocks) {
|
|
251
|
+
const isResource = (value, type, labels) => {
|
|
252
|
+
const node = value;
|
|
253
|
+
return typeof node === "object" && node !== null && node["$expr"] === "resource-attr" && node["type"] === type &&
|
|
254
|
+
typeof node["label"] === "string" && (labels === undefined ? node["label"] === label : labels.has(node["label"]));
|
|
255
|
+
};
|
|
256
|
+
const automations = new Set(blocks.flatMap((block) => block.kind === "resource" && block.type === "elementum_automation" && block.label !== undefined &&
|
|
257
|
+
isResource(block.attrs["app_id"], "elementum_element")
|
|
258
|
+
? [block.label]
|
|
259
|
+
: []));
|
|
260
|
+
return new Set(blocks.flatMap((block) => block.kind === "resource" && block.type?.endsWith("_trigger") === true &&
|
|
261
|
+
isResource(block.attrs["automation"], "elementum_automation", automations)
|
|
262
|
+
? [`${block.type}.${block.label}`]
|
|
263
|
+
: []));
|
|
264
|
+
}
|
|
@@ -5,12 +5,15 @@
|
|
|
5
5
|
* than folding into `src/aspects/` (which still owns `app` and the
|
|
6
6
|
* field/print internals genuinely shared between both aspect kinds).
|
|
7
7
|
*/
|
|
8
|
-
export { element, type ElementCloudConnection, type ElementConfigured, type ElementRef, type ElementV2Options, } from "./build.js";
|
|
8
|
+
export { element, type ElementCloudConnection, type ElementConfigured, type ElementCustomView, type ElementRef, type ElementSystemFields, type ElementV2Options, } from "./build.js";
|
|
9
|
+
export { type ViewBlock, type ViewBlocksField, type ViewBlocksFilterRef, type ViewBlocksLayout, type ViewBlocksSource, } from "../view/agent-view-layout.js";
|
|
9
10
|
export { type AppRecordCreateForm, type AppRecordCreateFormSection } from "../app/build.js";
|
|
10
11
|
export { listViewDensity, managedViewSortAggregation, managedViewSortDirection, type ListViewDensity, type ManagedViewSort, type ManagedViewSortAggregation, type ManagedViewSortDirection, type ManagedViewSortField, type ManagedViewSortOrder, } from "../view/build.js";
|
|
11
12
|
export { type AppRelationship, type AppRelationshipColumn } from "../relationship/build.js";
|
|
13
|
+
export { runAutomationParameterValue, type RunAutomationParameterValue } from "../widget/build.js";
|
|
14
|
+
export { type DynamicLayoutBlockCommon, type DynamicLayoutComponent, type DynamicLayoutCondition, type DynamicLayoutCssLength, type DynamicLayoutDependency, type DynamicLayoutFieldComponent, type DynamicLayoutFieldValidation, type DynamicLayoutSaveGroup, type DynamicLayoutStyle, type DynamicLayoutTypedValue, type DynamicLayoutValidationRule, type ElementDynamicLayout, dynamicLayout, } from "../dynamic-layout/build.js";
|
|
12
15
|
export { dashboardChartWidget, dashboardRecordsWidget, dashboardWidgetSize, type DashboardChartWidget, type DashboardRecordsWidget, type DashboardWidget, type DashboardWidgetSize, } from "../dashboard/build.js";
|
|
13
|
-
export { attachmentField, booleanField, calculatedField, dateField, dateTimeField, decimalField, dropdownDisplay, dropdownField, dropdownOption, dropdownValue, groupField, jsonField, multiSelectField, numberField, relationField, richTextField, textField, userField, type BaseFieldOptions, type CalculatedFieldOptions, type InferredCalculatedField, type NumericFieldFormat, type DropdownConfig, type DropdownDisplay, type DropdownFieldOptions, type DropdownOption, type DropdownParentValueRef, type DynamicDropdownConfig, type DynamicDropdownParent, type DynamicDropdownParentMapping, type MultiSelectFieldOptions, type NumericFieldOptions, type RelationFieldOptions, type QrFieldFormat, type TextFieldOptions, } from "../field/build.js";
|
|
16
|
+
export { attachmentField, booleanField, calculatedField, dateField, dateTimeField, decimalField, dropdownDisplay, dropdownField, dropdownOption, dropdownValue, groupField, jsonField, multiSelectField, numberField, relationField, richTextField, textField, userField, type AttachmentFieldOptions, type BaseFieldOptions, type CalculatedFieldOptions, type InferredCalculatedField, type NumericFieldFormat, type DropdownConfig, type DropdownDisplay, type DropdownFieldOptions, type DropdownOption, type DropdownParentValueRef, type DynamicDropdownConfig, type DynamicDropdownParent, type DynamicDropdownParentMapping, type MultiSelectFieldOptions, type NumericFieldOptions, type RelationFieldOptions, type QrFieldFormat, type TextFieldOptions, } from "../field/build.js";
|
|
14
17
|
export { calc, dateDifUnit, dateTimeTruncPrecision, field, orderByDirection, predicateOp, weekdayMode, type ConcatExprType, type DateDifUnit, type DateTimeTruncPrecision, type Expr, type ExprType, type FieldRefExprType, type OrderByDirection, type Predicate, type PredicateOp, type StringAggOptions, type StringAggOrderBy, type WeekdayMode, } from "../field/calc.js";
|
|
15
18
|
export { asc, desc, sortBy, type SortDirection, type SortOrder } from "../shared/types/common.js";
|
|
16
19
|
export { groupId, userId, type AccessPolicyGroupRef, type AccessPolicyOptions, type AccessPolicyPrincipalRef, type AccessPolicyUserRef, type GroupId, type UserId } from "../access-policy/build.js";
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export { element, } from "./build.js";
|
|
9
9
|
export { listViewDensity, managedViewSortAggregation, managedViewSortDirection, } from "../view/build.js";
|
|
10
|
+
export { runAutomationParameterValue } from "../widget/build.js";
|
|
11
|
+
export { dynamicLayout, } from "../dynamic-layout/build.js";
|
|
10
12
|
export { dashboardChartWidget, dashboardRecordsWidget, dashboardWidgetSize, } from "../dashboard/build.js";
|
|
11
13
|
export { attachmentField, booleanField, calculatedField, dateField, dateTimeField, decimalField, dropdownDisplay, dropdownField, dropdownOption, dropdownValue, groupField, jsonField, multiSelectField, numberField, relationField, richTextField, textField, userField, } from "../field/build.js";
|
|
12
14
|
export { calc, dateDifUnit, dateTimeTruncPrecision, field, orderByDirection, predicateOp, weekdayMode, } from "../field/calc.js";
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { NO_CATALOG, } from "../../graph/types.js";
|
|
7
7
|
import { appendFieldLocals } from "../field/locals.js";
|
|
8
|
-
import { CALENDAR_VIEW_RESOURCE_TYPE, DASHBOARD_VIEW_RESOURCE_TYPE, KANBAN_VIEW_RESOURCE_TYPE, LAYOUT_RESOURCE_TYPE, LIST_VIEW_RESOURCE_TYPE } from "../view/types.js";
|
|
9
|
-
import { elementFromTf } from "./from-tf.js";
|
|
8
|
+
import { CALENDAR_VIEW_RESOURCE_TYPE, CUSTOM_VIEW_RESOURCE_TYPE, DASHBOARD_VIEW_RESOURCE_TYPE, KANBAN_VIEW_RESOURCE_TYPE, LAYOUT_RESOURCE_TYPE, LIST_VIEW_RESOURCE_TYPE } from "../view/types.js";
|
|
9
|
+
import { elementFromTf, referencesElementAuditFields } from "./from-tf.js";
|
|
10
10
|
import { appendElementLocals } from "./locals.js";
|
|
11
11
|
import { elementToTf } from "./to-tf.js";
|
|
12
12
|
export const ELEMENT_RESOURCE_TYPE = "elementum_element";
|
|
@@ -23,8 +23,10 @@ function extractElementStreamRoot(stream, ctx) {
|
|
|
23
23
|
const calendarViewBlocks = viewBlocks.filter((b) => b.type === CALENDAR_VIEW_RESOURCE_TYPE);
|
|
24
24
|
const kanbanViewBlocks = viewBlocks.filter((b) => b.type === KANBAN_VIEW_RESOURCE_TYPE);
|
|
25
25
|
const dashboardViewBlocks = viewBlocks.filter((b) => b.type === DASHBOARD_VIEW_RESOURCE_TYPE);
|
|
26
|
+
const customViewBlocks = viewBlocks.filter((b) => b.type === CUSTOM_VIEW_RESOURCE_TYPE);
|
|
26
27
|
const managedViewOrderBlocks = stream.byKind.get("managed-view-order") ?? [];
|
|
27
28
|
const recordCreateFormBlocks = stream.byKind.get("record-create-form") ?? [];
|
|
29
|
+
const dynamicLayoutBlocks = stream.byKind.get("dynamic-layout") ?? [];
|
|
28
30
|
const relationshipBlocks = stream.byKind.get("relationship") ?? [];
|
|
29
31
|
const dashboardBlocks = stream.byKind.get("dashboard") ?? [];
|
|
30
32
|
const dashboardWidgetBlocks = stream.byKind.get("dashboard-widget") ?? [];
|
|
@@ -37,15 +39,21 @@ function extractElementStreamRoot(stream, ctx) {
|
|
|
37
39
|
calendarViewBlocks,
|
|
38
40
|
kanbanViewBlocks,
|
|
39
41
|
dashboardViewBlocks,
|
|
42
|
+
customViewBlocks,
|
|
40
43
|
managedViewOrderBlocks,
|
|
41
44
|
recordCreateFormBlocks,
|
|
45
|
+
dynamicLayoutBlocks,
|
|
42
46
|
relationshipBlocks,
|
|
43
47
|
dashboardBlocks,
|
|
44
48
|
dashboardWidgetBlocks,
|
|
45
49
|
widgetBlocks,
|
|
46
50
|
}, accessPolicyBlocks, roleBlocks);
|
|
51
|
+
// Automations are extracted separately, but their trigger outputs are the
|
|
52
|
+
// only audit reference some elements have.
|
|
53
|
+
const auditFields = element.auditFields === true ||
|
|
54
|
+
referencesElementAuditFields(elementBlocks[0].label ?? "", stream.allResources, new Set(element.fields.map(({ field }) => field.name.toLowerCase())));
|
|
47
55
|
return {
|
|
48
|
-
instance: element,
|
|
56
|
+
instance: auditFields && element.auditFields !== true ? { ...element, auditFields } : element,
|
|
49
57
|
...(cloudLinkHandle !== undefined && { cloudLinkHandle }),
|
|
50
58
|
};
|
|
51
59
|
}
|
|
@@ -11,8 +11,9 @@ import { displayBlocksToLayoutSections } from "../app/display-blocks-to-layout.j
|
|
|
11
11
|
import { APP_RESOURCE_TYPE } from "../app/module.js";
|
|
12
12
|
import { displayBlocksToRecordCreateFormSections } from "../app/display-blocks-to-record-create-form.js";
|
|
13
13
|
import { dashboardsToTf } from "../dashboard/to-tf.js";
|
|
14
|
+
import { dynamicLayoutsToTf } from "../dynamic-layout/to-tf.js";
|
|
14
15
|
import { fieldMetadataFromEntries } from "../field/metadata.js";
|
|
15
|
-
import { fieldToTf } from "../field/to-tf.js";
|
|
16
|
+
import { authoredFieldKeysFromPayload, claimFieldDisplayName, fieldToTf } from "../field/to-tf.js";
|
|
16
17
|
import { CATEGORY_ORG_BAG } from "../org/category.js";
|
|
17
18
|
import { categoryIdExpr, missingCategoryDiagnostic } from "../org/category-ref.js";
|
|
18
19
|
import { CLOUD_LINK_ORG_BAG } from "../org/cloud-link.js";
|
|
@@ -128,9 +129,11 @@ export function elementToTf(entity, ctx) {
|
|
|
128
129
|
}
|
|
129
130
|
const blocks = [];
|
|
130
131
|
const fieldAddresses = new Map();
|
|
132
|
+
const fieldOwnership = authoredFieldKeysFromPayload(payload);
|
|
131
133
|
const fieldNames = new Map();
|
|
132
134
|
const fieldMetadata = fieldMetadataFromEntries(payload.fields);
|
|
133
135
|
const objectId = expr.resourceAttr(ELEMENT_RESOURCE_TYPE, ctx.appTfLabel, ["id"]);
|
|
136
|
+
const fieldDisplayNames = new Map();
|
|
134
137
|
for (const fieldEntry of payload.fields ?? []) {
|
|
135
138
|
const typeKey = Object.keys(fieldEntry)[0];
|
|
136
139
|
if (typeKey === undefined)
|
|
@@ -178,9 +181,11 @@ export function elementToTf(entity, ctx) {
|
|
|
178
181
|
diagnostics: ctx.diagnostics,
|
|
179
182
|
orgRefs: ctx.orgRefs,
|
|
180
183
|
workspaceAspects: ctx.workspaceAspects,
|
|
184
|
+
fieldOwnership,
|
|
181
185
|
});
|
|
182
186
|
if (field === undefined)
|
|
183
187
|
continue;
|
|
188
|
+
claimFieldDisplayName(fieldDisplayNames, field);
|
|
184
189
|
blocks.push(field.block);
|
|
185
190
|
fieldAddresses.set(field.bagKey, field.address);
|
|
186
191
|
}
|
|
@@ -226,10 +231,11 @@ export function elementToTf(entity, ctx) {
|
|
|
226
231
|
objectId,
|
|
227
232
|
dashboardKeys: new Set(Object.keys(payload.dashboards ?? {})),
|
|
228
233
|
orgRefs: ctx.orgRefs,
|
|
234
|
+
workspaceAspects: ctx.workspaceAspects,
|
|
229
235
|
diagnostics: ctx.diagnostics,
|
|
230
236
|
fieldAddresses,
|
|
231
237
|
widgetKeys: new Set(Object.keys(payload.widgets ?? {})),
|
|
232
|
-
});
|
|
238
|
+
}, payload.customViews);
|
|
233
239
|
blocks.push(...viewBlocks);
|
|
234
240
|
const recordCreateFormForToTf = payload.recordCreateForm ??
|
|
235
241
|
(mappedRecordCreateFormSections !== undefined && mappedRecordCreateFormSections.length > 0
|
|
@@ -245,6 +251,17 @@ export function elementToTf(entity, ctx) {
|
|
|
245
251
|
});
|
|
246
252
|
if (recordCreateForm !== undefined)
|
|
247
253
|
blocks.push(recordCreateForm);
|
|
254
|
+
blocks.push(...dynamicLayoutsToTf(payload.dynamicLayouts, {
|
|
255
|
+
ownerRefName: ctx.appRefName,
|
|
256
|
+
ownerTfLabel: ctx.appTfLabel,
|
|
257
|
+
scope: "element",
|
|
258
|
+
objectId,
|
|
259
|
+
diagnostics: ctx.diagnostics,
|
|
260
|
+
orgRefs: ctx.orgRefs,
|
|
261
|
+
workspaceAspects: ctx.workspaceAspects,
|
|
262
|
+
fieldAddresses,
|
|
263
|
+
widgetKeys: new Set(Object.keys(payload.widgets ?? {})),
|
|
264
|
+
}));
|
|
248
265
|
blocks.push(...relationshipsToTf(payload.relationships, {
|
|
249
266
|
ownerRefName: ctx.appRefName,
|
|
250
267
|
ownerTfLabel: ctx.appTfLabel,
|
|
@@ -254,6 +271,7 @@ export function elementToTf(entity, ctx) {
|
|
|
254
271
|
orgRefs: ctx.orgRefs,
|
|
255
272
|
workspaceAspects: ctx.workspaceAspects,
|
|
256
273
|
diagnostics: ctx.diagnostics,
|
|
274
|
+
fieldOwnership: fieldAddresses,
|
|
257
275
|
}));
|
|
258
276
|
// Authored entries only. Creating an element also has the platform mint a
|
|
259
277
|
// creator policy (userIds = [you]) that is NOT in this payload — pull
|
|
@@ -140,6 +140,19 @@ export interface TextFieldOptions extends BaseFieldOptions {
|
|
|
140
140
|
/** @deprecated Prefer `calculatedField({ name, expression })`. */
|
|
141
141
|
readonly expression?: ScalarExpression<"text" | "uuid">;
|
|
142
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* Options for `attachmentField`. Always set `mediaTypes` on a new attachment
|
|
145
|
+
* field. Each entry is a MIME type (`application/pdf`, `image/*`,
|
|
146
|
+
* `image/png`); `*` is allowed only as the subtype.
|
|
147
|
+
*
|
|
148
|
+
* Omitting `mediaTypes` on a newly created field leaves the live value null,
|
|
149
|
+
* and the platform rejects every upload. An existing field keeps its live
|
|
150
|
+
* value when `mediaTypes` is omitted (provider UseStateForNullSet; EDK
|
|
151
|
+
* neither sets nor clears it).
|
|
152
|
+
*/
|
|
153
|
+
export interface AttachmentFieldOptions extends BaseFieldOptions {
|
|
154
|
+
readonly mediaTypes?: readonly string[];
|
|
155
|
+
}
|
|
143
156
|
/**
|
|
144
157
|
* Options for `relationField` — a dynamic dropdown sourced from another
|
|
145
158
|
* App/Element/Task's records (`elementum_relation_field`), distinct from a
|
|
@@ -187,7 +200,7 @@ export declare function userField(opts: BaseFieldOptions & WithExpression<"user"
|
|
|
187
200
|
export declare function groupField(opts: BaseFieldOptions & WithExpression<"group">): AppField & {
|
|
188
201
|
readonly type: "GROUP";
|
|
189
202
|
};
|
|
190
|
-
export declare function attachmentField(opts:
|
|
203
|
+
export declare function attachmentField(opts: AttachmentFieldOptions & WithExpression<"attachment">): AppField & {
|
|
191
204
|
readonly type: "ATTACHMENT";
|
|
192
205
|
};
|
|
193
206
|
export declare function jsonField(opts: BaseFieldOptions & WithExpression<"json">): AppField & {
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
* AppField is accepted.
|
|
19
19
|
*/
|
|
20
20
|
import { assertCalculatedFieldRoot, coerce } from "./calc/runtime.js";
|
|
21
|
+
import { assertAttachmentMediaTypes } from "./media-types.js";
|
|
21
22
|
/** Product-visible rendering modes for dynamically sourced values. */
|
|
22
23
|
export const dropdownDisplay = {
|
|
23
24
|
dropdown: "DROPDOWN",
|
|
@@ -71,6 +72,8 @@ export function groupField(opts) {
|
|
|
71
72
|
return field("GROUP", opts);
|
|
72
73
|
}
|
|
73
74
|
export function attachmentField(opts) {
|
|
75
|
+
if (opts.mediaTypes !== undefined)
|
|
76
|
+
assertAttachmentMediaTypes(opts.name, opts.mediaTypes);
|
|
74
77
|
return field("ATTACHMENT", opts);
|
|
75
78
|
}
|
|
76
79
|
export function jsonField(opts) {
|
|
@@ -15,6 +15,8 @@ export interface FieldOwner {
|
|
|
15
15
|
readonly label: string;
|
|
16
16
|
/** Scope for stripping child label prefixes (defaults to app). */
|
|
17
17
|
readonly scope?: ChildResourceScope;
|
|
18
|
+
/** The owner's catalog refName — the `appHandle` of same-owner field RefExprs. */
|
|
19
|
+
readonly refName?: string;
|
|
18
20
|
}
|
|
19
21
|
/**
|
|
20
22
|
* One field block → its normalized entry; undefined = skipped with a
|
|
@@ -58,4 +60,5 @@ export declare function fieldKeyFromForeignDataLabel(dataLabel: string, target:
|
|
|
58
60
|
readonly name?: string;
|
|
59
61
|
readonly namespace?: string;
|
|
60
62
|
readonly kind?: string;
|
|
63
|
+
readonly ownerDataLabel?: string;
|
|
61
64
|
}): string | undefined;
|
|
@@ -11,6 +11,7 @@ import { dataRefLabel, optionalString, resourceRefLabel } from "../../engine/pul
|
|
|
11
11
|
import { bareChildResourceLabel, isTfExpr, sanitizeName, scopedLabelToBagKey, tfLabelToTsLabel, tsLabelToTfLabel } from "../../engine/tf/index.js";
|
|
12
12
|
import { filterFromTf as deserializeFilterFromTf } from "../shared/filters/tf-codec.js";
|
|
13
13
|
import { __pulledExpression } from "../app/deserializer/pulled-expression.js";
|
|
14
|
+
import { isAttachmentMediaType } from "./media-types.js";
|
|
14
15
|
import { optionsFromTf } from "./options.js";
|
|
15
16
|
import { isCalculationResultType } from "./calculation-types.js";
|
|
16
17
|
import { KNOWN_FIELD_ATTRS, SUB_TYPE_BY_RESOURCE } from "./types.js";
|
|
@@ -152,6 +153,16 @@ function dynamicPicklistFilterFieldRef(value, ctx) {
|
|
|
152
153
|
}
|
|
153
154
|
throw new EntityTfError("dynamic picklist filter field reference cannot be reconstructed");
|
|
154
155
|
}
|
|
156
|
+
/** A `record_field` value names a field on the Dropdown's own record, not the source. */
|
|
157
|
+
function dynamicPicklistRecordFieldRef(value, owner, ctx) {
|
|
158
|
+
if (owner.refName === undefined)
|
|
159
|
+
throw new EntityTfError("record_field filter value requires a known owning app or element");
|
|
160
|
+
const scope = owner.scope ?? "app";
|
|
161
|
+
const fieldKey = fieldKeyFromTfRef(value, owner.label, scope) ?? fieldKeyFromTfValue(value, owner.refName, owner.label, scope, ctx);
|
|
162
|
+
if (fieldKey === undefined)
|
|
163
|
+
throw new EntityTfError("record_field filter value field is not a field on the owning record");
|
|
164
|
+
return { kind: "field", appHandle: owner.refName, fieldKey };
|
|
165
|
+
}
|
|
155
166
|
/**
|
|
156
167
|
* `dynamic_config` → `AppField.config` (picklist/multiPicklist only). Mirrors
|
|
157
168
|
* `related_object_id`/`related_label_field_id` resolution exactly (both are
|
|
@@ -193,6 +204,7 @@ function dynamicConfigFromTf(value, owner, ctx, where) {
|
|
|
193
204
|
try {
|
|
194
205
|
filter = deserializeFilterFromTf(attrs["filter"], {
|
|
195
206
|
field: (v) => dynamicPicklistFilterFieldRef(v, ctx),
|
|
207
|
+
recordField: (v) => dynamicPicklistRecordFieldRef(v, owner, ctx),
|
|
196
208
|
reference: () => {
|
|
197
209
|
throw new EntityTfError("dynamic picklist filter does not support value references");
|
|
198
210
|
},
|
|
@@ -454,6 +466,34 @@ export function fieldFromTf(block, owner, ctx) {
|
|
|
454
466
|
const tags = Array.isArray(fieldRole) && fieldRole.every((t) => typeof t === "string")
|
|
455
467
|
? fieldRole
|
|
456
468
|
: undefined;
|
|
469
|
+
let mediaTypes;
|
|
470
|
+
if (subType.typeKey === "attachment" && attrs["media_types"] !== undefined) {
|
|
471
|
+
const raw = attrs["media_types"];
|
|
472
|
+
if (!Array.isArray(raw)) {
|
|
473
|
+
ctx.diagnostics.push(`${where}: media_types must be a list of MIME types; omitted`);
|
|
474
|
+
}
|
|
475
|
+
else {
|
|
476
|
+
// Any invalid entry drops the whole list. Printing only the valid
|
|
477
|
+
// entries would shrink the live restriction on the next build.
|
|
478
|
+
// Omitting mediaTypes leaves the live value in place (provider
|
|
479
|
+
// UseStateForNullSet). `*/*` is invalid here too — see media-types.ts.
|
|
480
|
+
const values = [];
|
|
481
|
+
const invalid = [];
|
|
482
|
+
for (const entry of raw) {
|
|
483
|
+
if (isAttachmentMediaType(entry))
|
|
484
|
+
values.push(entry);
|
|
485
|
+
else
|
|
486
|
+
invalid.push(entry);
|
|
487
|
+
}
|
|
488
|
+
if (invalid.length > 0) {
|
|
489
|
+
const shown = invalid.map((entry) => JSON.stringify(entry)).join(", ");
|
|
490
|
+
ctx.diagnostics.push(`${where}: media_types entries ${shown} are not MIME types (expected type/subtype); omitted so the live restriction is kept`);
|
|
491
|
+
}
|
|
492
|
+
else if (values.length > 0) {
|
|
493
|
+
mediaTypes = values;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
}
|
|
457
497
|
// A group/user field's default_value is a `data.elementum_group|user.<label>.id`
|
|
458
498
|
// EXPRESSION on the wire (the platform has no stable raw id to hand
|
|
459
499
|
// authored source, and the field is Optional-without-Computed — omitting
|
|
@@ -532,6 +572,7 @@ export function fieldFromTf(block, owner, ctx) {
|
|
|
532
572
|
...(options !== undefined && { options }),
|
|
533
573
|
...(config !== undefined && { config }),
|
|
534
574
|
...(tags !== undefined && tags.length > 0 && { tags }),
|
|
575
|
+
...(mediaTypes !== undefined && { mediaTypes }),
|
|
535
576
|
...(relatedObject !== undefined && { relatedObject }),
|
|
536
577
|
...(relatedLabelField !== undefined && { relatedLabelField }),
|
|
537
578
|
...(autoRelate !== undefined && { autoRelate }),
|
|
@@ -609,7 +650,7 @@ export function decodeForeignDataField(dataLabel, target, ctx) {
|
|
|
609
650
|
const fieldType = fieldTypeFromRegistry(ctx, target.key, catalogFieldKey);
|
|
610
651
|
return { key: catalogFieldKey, name, ...(fieldType !== undefined ? { fieldType } : {}) };
|
|
611
652
|
}
|
|
612
|
-
const stripped = fieldKeyFromForeignDataLabel(dataLabel, target);
|
|
653
|
+
const stripped = fieldKeyFromForeignDataLabel(dataLabel, { ...target, ownerDataLabel: foreignFieldOwnerDataLabel(dataLabel, ctx) });
|
|
613
654
|
if (stripped !== undefined) {
|
|
614
655
|
const fieldType = fieldTypeFromRegistry(ctx, target.key, stripped);
|
|
615
656
|
return { key: stripped, name, ...(fieldType !== undefined ? { fieldType } : {}) };
|
|
@@ -635,11 +676,19 @@ function fieldTypeFromRegistry(ctx, ownerRefName, fieldKey) {
|
|
|
635
676
|
return "TEXT";
|
|
636
677
|
return undefined;
|
|
637
678
|
}
|
|
679
|
+
/** The label of the app/element/task lookup a foreign `data.elementum_field` reads through its `object_id`. */
|
|
680
|
+
function foreignFieldOwnerDataLabel(dataLabel, ctx) {
|
|
681
|
+
const objectId = ctx.dataAttrs?.("elementum_field", dataLabel)?.["object_id"];
|
|
682
|
+
return dataRefLabel(objectId, "elementum_app") ?? dataRefLabel(objectId, "elementum_element") ?? dataRefLabel(objectId, "elementum_task");
|
|
683
|
+
}
|
|
638
684
|
/** Strip ei's owner-display prefix from a `data.elementum_field` label. */
|
|
639
685
|
export function fieldKeyFromForeignDataLabel(dataLabel, target) {
|
|
640
686
|
const kind = target.kind === "element" || target.kind === "app" || target.kind === "task" ? target.kind : undefined;
|
|
641
687
|
const ownerType = kind === "element" ? "elementum_element" : kind === "app" ? "elementum_app" : kind === "task" ? "elementum_task" : undefined;
|
|
688
|
+
// ei prefixes a foreign field lookup's label with its owner lookup's label, which can differ from the
|
|
689
|
+
// owner's catalog key (a namespace-derived refName), so strip by that label too.
|
|
642
690
|
const slugs = [
|
|
691
|
+
target.ownerDataLabel,
|
|
643
692
|
target.name !== undefined && target.name !== "" ? sanitizeName(target.name) : undefined,
|
|
644
693
|
target.namespace,
|
|
645
694
|
tsLabelToTfLabel(target.key),
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function isAttachmentMediaType(entry: unknown): entry is string;
|
|
2
|
+
/**
|
|
3
|
+
* Throws when an authored attachment field lists nothing, or lists a value
|
|
4
|
+
* that is not `type/subtype`. An empty list would reject every upload.
|
|
5
|
+
*/
|
|
6
|
+
export declare function assertAttachmentMediaTypes(fieldName: string, mediaTypes: readonly unknown[]): void;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Attachment `mediaTypes` entries. A value is `type/subtype`: token
|
|
3
|
+
* characters, no surrounding whitespace, and `*` only as the whole subtype
|
|
4
|
+
* (`image/*`). An extension (`pdf`, `.docx`) or a partial type (`image/`)
|
|
5
|
+
* is rejected so a field cannot deploy a list that matches no upload.
|
|
6
|
+
*
|
|
7
|
+
* `*`/`*` stays rejected in authoring and on pull. A null `mediaTypes` list
|
|
8
|
+
* rejects every upload (#1374), and there is no evidence yet that the
|
|
9
|
+
* platform treats `*`/`*` as allow-all. Whether it does is an open question;
|
|
10
|
+
* until that is confirmed, do not accept `*`/`*` as a way to clear the
|
|
11
|
+
* restriction.
|
|
12
|
+
*/
|
|
13
|
+
const MIME_MEDIA_TYPE = /^[A-Za-z0-9][\w.+-]*\/(\*|[A-Za-z0-9][\w.+-]*)$/;
|
|
14
|
+
export function isAttachmentMediaType(entry) {
|
|
15
|
+
return typeof entry === "string" && MIME_MEDIA_TYPE.test(entry);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Throws when an authored attachment field lists nothing, or lists a value
|
|
19
|
+
* that is not `type/subtype`. An empty list would reject every upload.
|
|
20
|
+
*/
|
|
21
|
+
export function assertAttachmentMediaTypes(fieldName, mediaTypes) {
|
|
22
|
+
if (mediaTypes.length === 0) {
|
|
23
|
+
throw new Error(`attachment field "${fieldName}": mediaTypes is empty; an empty list would reject every upload.`);
|
|
24
|
+
}
|
|
25
|
+
for (const entry of mediaTypes) {
|
|
26
|
+
if (!isAttachmentMediaType(entry)) {
|
|
27
|
+
throw new Error(`attachment field "${fieldName}": mediaTypes entry ${JSON.stringify(entry)} is not a MIME type (expected type/subtype).`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -12,6 +12,18 @@
|
|
|
12
12
|
import { type OrgRefLookup, type WorkspaceAspect } from "../../engine/build/context.js";
|
|
13
13
|
import { type ChildResourceScope, type TfBlock, type TfExpr, type TfValue } from "../../engine/tf/index.js";
|
|
14
14
|
import { type PicklistValueWire } from "./options.js";
|
|
15
|
+
/**
|
|
16
|
+
* The authored fields known to belong to an app/element. Maps produced by a
|
|
17
|
+
* root emitter also provide exact addresses; sets reconstructed from a
|
|
18
|
+
* workspace sibling still provide the ownership fact needed to distinguish
|
|
19
|
+
* an authored audit-key field from the element's platform audit field.
|
|
20
|
+
*/
|
|
21
|
+
export interface FieldOwnership {
|
|
22
|
+
has(refName: string): boolean;
|
|
23
|
+
get?(refName: string): string | undefined;
|
|
24
|
+
}
|
|
25
|
+
/** Reconstruct custom-field ownership from a loaded app/element payload. */
|
|
26
|
+
export declare function authoredFieldKeysFromPayload(payload: unknown): ReadonlySet<string> | undefined;
|
|
15
27
|
/** Slim `AppOrElementRef` token shape as it appears in a def() payload (post-`slimTokens`). */
|
|
16
28
|
interface AspectTokenWire {
|
|
17
29
|
readonly __kind?: string;
|
|
@@ -102,6 +114,8 @@ export interface FieldInnerWire {
|
|
|
102
114
|
readonly autoRelate?: boolean;
|
|
103
115
|
/** "decimal" fields only. */
|
|
104
116
|
readonly decimalPlaces?: number;
|
|
117
|
+
/** Attachment fields only — allowed MIME types. Omitted from HCL when unset or empty. */
|
|
118
|
+
readonly mediaTypes?: readonly string[];
|
|
105
119
|
}
|
|
106
120
|
export interface FieldToTfOptions {
|
|
107
121
|
/** The owning stream root's terraform label (namespace). */
|
|
@@ -125,6 +139,8 @@ export interface FieldToTfOptions {
|
|
|
125
139
|
* `data` lookup, which can only ever find something already live).
|
|
126
140
|
*/
|
|
127
141
|
readonly workspaceAspects?: ReadonlyMap<string, WorkspaceAspect>;
|
|
142
|
+
/** All custom fields authored by the owning root, including later entries. */
|
|
143
|
+
readonly fieldOwnership?: FieldOwnership;
|
|
128
144
|
}
|
|
129
145
|
export interface FieldToTfResult {
|
|
130
146
|
readonly block: TfBlock;
|
|
@@ -133,7 +149,12 @@ export interface FieldToTfResult {
|
|
|
133
149
|
/** `<resourceType>.<tfLabel>` — locals/build-vs-export bookkeeping. */
|
|
134
150
|
readonly address: string;
|
|
135
151
|
}
|
|
136
|
-
/**
|
|
152
|
+
/**
|
|
153
|
+
* Field display names must be unique within an app or element. The platform rejects the second one only at
|
|
154
|
+
* apply ("Duplicate key found.", naming neither field) after the rest of the apply has landed, so fail the build
|
|
155
|
+
* first and name both fields.
|
|
156
|
+
*/
|
|
157
|
+
export declare function claimFieldDisplayName(seen: Map<string, string>, field: FieldToTfResult): void;
|
|
137
158
|
export declare function fieldToTf(typeKey: string, inner: FieldInnerWire, opts: FieldToTfOptions): FieldToTfResult | undefined;
|
|
138
|
-
export declare function fieldRefToTfValue(fieldType: string, refName: string, ownerTfLabel: string, scope?: ChildResourceScope,
|
|
159
|
+
export declare function fieldRefToTfValue(fieldType: string, refName: string, ownerTfLabel: string, scope?: ChildResourceScope, fieldOwnership?: FieldOwnership): TfExpr | undefined;
|
|
139
160
|
export {};
|