@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
|
@@ -10,15 +10,161 @@ import { DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES, SYSTEM_FIELD_KEY_SET } from "../../c
|
|
|
10
10
|
import { dataRefLabel, groupCatalogKey, optionalString, reportAuthoringBlocker, resourceRefLabel } from "../../engine/pull/context.js";
|
|
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
|
+
import { optionLookupDecode } from "../shared/filters/option-lookups.js";
|
|
13
14
|
import { __pulledExpression } from "../app/deserializer/pulled-expression.js";
|
|
14
15
|
import { isAttachmentMediaType } from "./media-types.js";
|
|
15
16
|
import { optionsFromTf } from "./options.js";
|
|
16
17
|
import { isCalculationResultType } from "./calculation-types.js";
|
|
17
18
|
import { KNOWN_FIELD_ATTRS, SUB_TYPE_BY_RESOURCE } from "./types.js";
|
|
18
|
-
import { ELEMENT_AUDIT_SYSTEM_FIELD_KEYS, ELEMENT_SYSTEM_FIELD_KEYS } from "../element/system-fields.js";
|
|
19
|
+
import { ELEMENT_AUDIT_SYSTEM_FIELD_KEYS, ELEMENT_SYSTEM_FIELD_KEYS, platformAuditFieldToken } from "../element/system-fields.js";
|
|
19
20
|
import { resolveDataAspectTarget, resolveDataTaskTarget } from "../shared/aspect-target-from-tf.js";
|
|
20
21
|
const ELEMENT_AUDIT_SYSTEM_FIELD_KEY_SET = new Set(ELEMENT_AUDIT_SYSTEM_FIELD_KEYS);
|
|
21
22
|
const ELEMENT_SYSTEM_FIELD_KEY_SET = new Set(ELEMENT_SYSTEM_FIELD_KEYS);
|
|
23
|
+
/**
|
|
24
|
+
* System-field keys a pulled custom field of this owner scope is re-keyed off
|
|
25
|
+
* (#1871). Apps and standalone tasks share the app set; elements have their own.
|
|
26
|
+
*/
|
|
27
|
+
function reservedFieldKeysForScope(scope) {
|
|
28
|
+
return scope === "element" ? ELEMENT_SYSTEM_FIELD_KEY_SET : SYSTEM_FIELD_KEY_SET;
|
|
29
|
+
}
|
|
30
|
+
const OWNER_RESOURCE_TYPE_BY_SCOPE = {
|
|
31
|
+
app: "elementum_app",
|
|
32
|
+
element: "elementum_element",
|
|
33
|
+
task: "elementum_task",
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Bag keys for all of an owner's field labels, claimed in two passes (#1871
|
|
37
|
+
* B1): labels whose natural key isn't reserved claim it first, then labels
|
|
38
|
+
* whose natural key is a system key re-key to `<key>Custom`, `<key>Custom2`, …
|
|
39
|
+
* So a field named like a re-key (`closed_at_custom` → `closedAtCustom`) keeps
|
|
40
|
+
* its natural key. The result depends only on the set of labels, so the
|
|
41
|
+
* field extractor and every reference to one of the owner's fields agree on
|
|
42
|
+
* the key (edk#2933).
|
|
43
|
+
*/
|
|
44
|
+
function claimFieldBagKeys(ownerTfLabel, scope, fieldLabels, diagnostics) {
|
|
45
|
+
const reservedKeys = reservedFieldKeysForScope(scope);
|
|
46
|
+
const nonReserved = [];
|
|
47
|
+
const reserved = [];
|
|
48
|
+
for (const label of fieldLabels) {
|
|
49
|
+
(reservedKeys.has(scopedLabelToBagKey(ownerTfLabel, label, scope)) ? reserved : nonReserved).push(label);
|
|
50
|
+
}
|
|
51
|
+
const usedKeys = new Set();
|
|
52
|
+
const claimed = new Map();
|
|
53
|
+
for (const label of [...nonReserved, ...reserved]) {
|
|
54
|
+
if (claimed.has(label))
|
|
55
|
+
continue;
|
|
56
|
+
claimed.set(label, bagKeyForPulledCustomField(ownerTfLabel, label, scope, reservedKeys, usedKeys, diagnostics));
|
|
57
|
+
}
|
|
58
|
+
return claimed;
|
|
59
|
+
}
|
|
60
|
+
/** Claimed field keys per extraction context, by `<scope>:<owner tfLabel>`. */
|
|
61
|
+
const claimedFieldKeysByCtx = new WeakMap();
|
|
62
|
+
function claimCacheFor(ctx) {
|
|
63
|
+
let byOwner = claimedFieldKeysByCtx.get(ctx);
|
|
64
|
+
if (byOwner === undefined) {
|
|
65
|
+
byOwner = new Map();
|
|
66
|
+
claimedFieldKeysByCtx.set(ctx, byOwner);
|
|
67
|
+
}
|
|
68
|
+
return byOwner;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The owner's claimed field keys in this context: the ones {@link fieldsFromTf}
|
|
72
|
+
* recorded, else claimed over the stream's field resources whose `object_id`
|
|
73
|
+
* names the owner (the same blocks fieldFromTf extracts). Undefined when the
|
|
74
|
+
* context can't list the stream's resources.
|
|
75
|
+
*/
|
|
76
|
+
function ownerClaimedFieldKeys(ctx, ownerTfLabel, scope) {
|
|
77
|
+
if (ctx === undefined)
|
|
78
|
+
return undefined;
|
|
79
|
+
const cache = claimCacheFor(ctx);
|
|
80
|
+
const cacheKey = `${scope}:${ownerTfLabel}`;
|
|
81
|
+
const cached = cache.get(cacheKey);
|
|
82
|
+
if (cached !== undefined)
|
|
83
|
+
return cached;
|
|
84
|
+
if (ctx.resourcesOfType === undefined)
|
|
85
|
+
return undefined;
|
|
86
|
+
const ownerType = OWNER_RESOURCE_TYPE_BY_SCOPE[scope];
|
|
87
|
+
const labels = [];
|
|
88
|
+
for (const type of SUB_TYPE_BY_RESOURCE.keys()) {
|
|
89
|
+
for (const resource of ctx.resourcesOfType(type)) {
|
|
90
|
+
if (resourceRefLabel(resource.attrs["object_id"], ownerType) === ownerTfLabel)
|
|
91
|
+
labels.push(resource.label);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const claimed = claimFieldBagKeys(ownerTfLabel, scope, labels);
|
|
95
|
+
cache.set(cacheKey, claimed);
|
|
96
|
+
return claimed;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Bag key of an owner's custom field, by its Terraform label, as pull keys it
|
|
100
|
+
* (#1871, edk#2933). Every same-owner reference to a field (dropdown parents,
|
|
101
|
+
* dynamic configs, views, layouts, relationships, widgets, approval chains,
|
|
102
|
+
* access policies, tools) resolves through this, so a reference names the
|
|
103
|
+
* key the field itself was printed under. Without a context that lists the
|
|
104
|
+
* stream, a reserved natural falls back to `<key>Custom`.
|
|
105
|
+
*/
|
|
106
|
+
export function pulledFieldBagKey(ownerTfLabel, fieldLabel, scope, ctx) {
|
|
107
|
+
return ownerClaimedFieldKeys(ctx, ownerTfLabel, scope)?.get(fieldLabel)
|
|
108
|
+
?? bagKeyForPulledCustomField(ownerTfLabel, fieldLabel, scope, reservedFieldKeysForScope(scope));
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Bag key for a pulled custom field resource. A key that matches a reserved
|
|
112
|
+
* system-field key is rewritten to `<key>Custom` so pulled source builds
|
|
113
|
+
* under #1871 Q1 A (reject at build). When `usedKeys` is provided, the
|
|
114
|
+
* assignment is collision-safe: non-reserved naturals claim first, and a
|
|
115
|
+
* reserved key takes `<key>Custom`, then `<key>Custom2`, … with a warning.
|
|
116
|
+
* Terraform addresses stay on the natural key via the stamped `resourceKey` / {@link tfChildPartForFieldBagKey}.
|
|
117
|
+
*/
|
|
118
|
+
export function bagKeyForPulledCustomField(ownerTfLabel, fieldLabel, scope, reservedKeys, usedKeys, diagnostics) {
|
|
119
|
+
const natural = scopedLabelToBagKey(ownerTfLabel, fieldLabel, scope);
|
|
120
|
+
if (!reservedKeys.has(natural)) {
|
|
121
|
+
if (usedKeys === undefined || !usedKeys.has(natural)) {
|
|
122
|
+
usedKeys?.add(natural);
|
|
123
|
+
return natural;
|
|
124
|
+
}
|
|
125
|
+
// Natural key already claimed (should not happen when non-reserved
|
|
126
|
+
// fields are assigned before reserved re-keys). Suffix until free.
|
|
127
|
+
let i = 2;
|
|
128
|
+
let candidate = `${natural}${i}`;
|
|
129
|
+
while (usedKeys.has(candidate)) {
|
|
130
|
+
i += 1;
|
|
131
|
+
candidate = `${natural}${i}`;
|
|
132
|
+
if (i > 1000) {
|
|
133
|
+
throw new EntityTfError(`no free bag key for custom field "${fieldLabel}" under owner "${ownerTfLabel}"`);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
diagnostics?.push(`custom field "${fieldLabel}" keyed "${candidate}" because "${natural}" was already used`);
|
|
137
|
+
usedKeys.add(candidate);
|
|
138
|
+
return candidate;
|
|
139
|
+
}
|
|
140
|
+
let candidate = `${natural}Custom`;
|
|
141
|
+
let i = 2;
|
|
142
|
+
while (usedKeys?.has(candidate) === true) {
|
|
143
|
+
candidate = `${natural}Custom${i}`;
|
|
144
|
+
i += 1;
|
|
145
|
+
if (i > 1000) {
|
|
146
|
+
throw new EntityTfError(`no free bag key for system-keyed custom field "${natural}" under owner "${ownerTfLabel}"`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (candidate !== `${natural}Custom`) {
|
|
150
|
+
diagnostics?.push(`custom field with reserved key "${natural}" re-keyed to "${candidate}" because "${natural}Custom" was already used`);
|
|
151
|
+
}
|
|
152
|
+
usedKeys?.add(candidate);
|
|
153
|
+
return candidate;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Terraform child-part for a field bag key. Only a key that pull actually
|
|
157
|
+
* re-keyed from a reserved natural — carried as `resourceKey` / wire
|
|
158
|
+
* `__resourceKey` — keeps the address on that natural. A field whose own
|
|
159
|
+
* label is already `closed_at_custom` (bag key `closedAtCustom`) is not
|
|
160
|
+
* remapped, so Custom and Custom2 never share an address (Review B1).
|
|
161
|
+
*/
|
|
162
|
+
export function tfChildPartForFieldBagKey(bagKey, resourceKey) {
|
|
163
|
+
if (resourceKey !== undefined && resourceKey !== "") {
|
|
164
|
+
return tsLabelToTfLabel(resourceKey);
|
|
165
|
+
}
|
|
166
|
+
return tsLabelToTfLabel(bagKey);
|
|
167
|
+
}
|
|
22
168
|
/** A system field's authoring type, as the owner's own `fields.<key>` token carries it. */
|
|
23
169
|
const SYSTEM_FIELD_TYPE_BY_KEY = {
|
|
24
170
|
id: "HANDLE",
|
|
@@ -149,7 +295,7 @@ function selfRelatedField(v, owner, ctx) {
|
|
|
149
295
|
const self = selfIdentity(owner, ctx);
|
|
150
296
|
if (self === undefined || v === undefined)
|
|
151
297
|
return undefined;
|
|
152
|
-
const fieldKey = fieldKeyFromTfRef(v, owner.label, owner.scope ?? "app");
|
|
298
|
+
const fieldKey = fieldKeyFromTfRef(v, owner.label, owner.scope ?? "app", ctx);
|
|
153
299
|
if (fieldKey === undefined || !isTfExpr(v) || v.$expr !== "resource-attr")
|
|
154
300
|
return undefined;
|
|
155
301
|
// A typed fieldRef, not catalog.<self>.fields.<key>: the app file cannot
|
|
@@ -188,15 +334,15 @@ function selfSystemField(v, owner, ctx) {
|
|
|
188
334
|
fieldKey = stateRef.fieldKey;
|
|
189
335
|
}
|
|
190
336
|
else if (isTfExpr(v) && v.$expr === "local") {
|
|
191
|
-
fieldKey = fieldKeyFromTfRef(v, owner.label, scope);
|
|
337
|
+
fieldKey = fieldKeyFromTfRef(v, owner.label, scope, ctx);
|
|
192
338
|
}
|
|
193
339
|
if (fieldKey === undefined)
|
|
194
340
|
return undefined;
|
|
195
|
-
|
|
196
|
-
if (!systemKeys.has(fieldKey))
|
|
341
|
+
if (!reservedFieldKeysForScope(scope).has(fieldKey))
|
|
197
342
|
return undefined;
|
|
198
|
-
//
|
|
199
|
-
//
|
|
343
|
+
// Custom fields that would collide are re-keyed to `<key>Custom` (#1871), so
|
|
344
|
+
// a system-field local always names the platform field. Element audit still
|
|
345
|
+
// uses {@link elementAuditFieldReference} when a same-keyed custom remains.
|
|
200
346
|
if (scope === "element" && ELEMENT_AUDIT_SYSTEM_FIELD_KEY_SET.has(fieldKey) && ownerMayHaveCustomField(owner, fieldKey, ctx))
|
|
201
347
|
return undefined;
|
|
202
348
|
// Title and ID carry their display names on the owner's own block; any
|
|
@@ -324,7 +470,7 @@ function dynamicPicklistRecordFieldRef(value, owner, ctx) {
|
|
|
324
470
|
if (owner.refName === undefined)
|
|
325
471
|
throw new EntityTfError("record_field filter value requires a known owning app or element");
|
|
326
472
|
const scope = owner.scope ?? "app";
|
|
327
|
-
const fieldKey = fieldKeyFromTfRef(value, owner.label, scope) ?? fieldKeyFromTfValue(value, owner.refName, owner.label, scope, ctx);
|
|
473
|
+
const fieldKey = fieldKeyFromTfRef(value, owner.label, scope, ctx) ?? fieldKeyFromTfValue(value, owner.refName, owner.label, scope, ctx);
|
|
328
474
|
if (fieldKey === undefined)
|
|
329
475
|
throw new EntityTfError("record_field filter value field is not a field on the owning record");
|
|
330
476
|
// A clone authors the record's fields under the clone's refName (edk#1481).
|
|
@@ -430,7 +576,7 @@ function dynamicConfigFromTf(value, owner, ctx, site) {
|
|
|
430
576
|
}
|
|
431
577
|
let parentFieldId;
|
|
432
578
|
if (attrs["parent_field_id"] !== undefined) {
|
|
433
|
-
parentFieldId = fieldKeyFromTfRef(attrs["parent_field_id"], owner.label, owner.scope ?? "app");
|
|
579
|
+
parentFieldId = fieldKeyFromTfRef(attrs["parent_field_id"], owner.label, owner.scope ?? "app", ctx);
|
|
434
580
|
if (parentFieldId === undefined) {
|
|
435
581
|
blockReplaceForcingDrop(ctx, site, "parent_field_id", "could not be resolved to a same-aspect field");
|
|
436
582
|
}
|
|
@@ -447,6 +593,8 @@ function dynamicConfigFromTf(value, owner, ctx, site) {
|
|
|
447
593
|
reference: () => {
|
|
448
594
|
throw new EntityTfError("dynamic picklist filter does not support value references");
|
|
449
595
|
},
|
|
596
|
+
// #2582: a stored option lookup prints as filter.textOption(label).
|
|
597
|
+
...optionLookupDecode,
|
|
450
598
|
});
|
|
451
599
|
}
|
|
452
600
|
catch (e) {
|
|
@@ -547,7 +695,7 @@ function staticParentLinkageFromTf(value, optionsValue, owner, ctx, where) {
|
|
|
547
695
|
const parentFieldValue = value["parent_field_id"];
|
|
548
696
|
if (parentFieldValue === undefined)
|
|
549
697
|
return undefined;
|
|
550
|
-
const parentFieldKey = fieldKeyFromTfRef(parentFieldValue, owner.label, owner.scope ?? "app");
|
|
698
|
+
const parentFieldKey = fieldKeyFromTfRef(parentFieldValue, owner.label, owner.scope ?? "app", ctx);
|
|
551
699
|
if (parentFieldKey === undefined) {
|
|
552
700
|
ctx.diagnostics.push(`${where}: static_config.parent_field_id could not be resolved to a same-app field; dropped`);
|
|
553
701
|
return undefined;
|
|
@@ -660,6 +808,26 @@ function dataLookupKey(type, attrs) {
|
|
|
660
808
|
}
|
|
661
809
|
return undefined;
|
|
662
810
|
}
|
|
811
|
+
/**
|
|
812
|
+
* An owner's field blocks → their normalized entries, in the blocks' (live
|
|
813
|
+
* field) order. Keys are claimed up front over every field the owner owns
|
|
814
|
+
* (two passes, #1871 B1; see {@link claimFieldBagKeys}) and recorded on the
|
|
815
|
+
* context before any field is extracted, so a reference from one field to
|
|
816
|
+
* another (a dependent dropdown's parent, a dynamic config) and every later
|
|
817
|
+
* same-owner reference resolve to the key the field prints under. Fields
|
|
818
|
+
* print in the live order, not the claim order: a re-keyed field moved last
|
|
819
|
+
* would reorder the live fields on the next apply (edk#2920). Apps, elements
|
|
820
|
+
* and standalone tasks all extract fields here (edk#2933).
|
|
821
|
+
*/
|
|
822
|
+
export function fieldsFromTf(fieldBlocks, owner, ctx) {
|
|
823
|
+
const scope = owner.scope ?? "app";
|
|
824
|
+
const ownedLabels = fieldBlocks.flatMap((block) => block.label !== undefined && SUB_TYPE_BY_RESOURCE.has(block.type ?? "") && resourceRefLabel(block.attrs["object_id"], owner.type) === owner.label
|
|
825
|
+
? [block.label]
|
|
826
|
+
: []);
|
|
827
|
+
const claimed = claimFieldBagKeys(owner.label, scope, ownedLabels, ctx.diagnostics);
|
|
828
|
+
claimCacheFor(ctx).set(`${scope}:${owner.label}`, claimed);
|
|
829
|
+
return fieldBlocks.flatMap((block) => fieldFromTf(block, owner, ctx) ?? []);
|
|
830
|
+
}
|
|
663
831
|
/**
|
|
664
832
|
* One field block → its normalized entry; undefined = skipped with a
|
|
665
833
|
* diagnostic (unknown resource type, or a field belonging to a different
|
|
@@ -872,8 +1040,11 @@ export function fieldFromTf(block, owner, ctx) {
|
|
|
872
1040
|
ctx.diagnostics.push(`${where}: unsupported include_type ${JSON.stringify(includeType)}; defaulted to AUTO`);
|
|
873
1041
|
}
|
|
874
1042
|
}
|
|
1043
|
+
const reservedKeys = reservedFieldKeysForScope(scope);
|
|
1044
|
+
const natural = scopedLabelToBagKey(owner.label, fieldLabel, scope);
|
|
1045
|
+
const key = pulledFieldBagKey(owner.label, fieldLabel, scope, ctx);
|
|
875
1046
|
return {
|
|
876
|
-
key
|
|
1047
|
+
key,
|
|
877
1048
|
...(parentLinkage !== undefined && { parentLinkage }),
|
|
878
1049
|
...(isCalculationResultType(calculationType) && { calculationType }),
|
|
879
1050
|
...(calculationInclude !== undefined && { calculationInclude }),
|
|
@@ -881,6 +1052,9 @@ export function fieldFromTf(block, owner, ctx) {
|
|
|
881
1052
|
id: ctx.importId(`${block.type}.${fieldLabel}`) ?? "",
|
|
882
1053
|
name: fieldName,
|
|
883
1054
|
type: subType.authoringType,
|
|
1055
|
+
// Explicit re-key map for #1871: only reserved naturals that pull
|
|
1056
|
+
// re-keyed carry resourceKey so build keeps the live TF address.
|
|
1057
|
+
...(reservedKeys.has(natural) ? { resourceKey: natural } : {}),
|
|
884
1058
|
...(calculation !== undefined && { expression: __pulledExpression(calculation) }),
|
|
885
1059
|
// Only true flags are carried into authoring — false is the platform
|
|
886
1060
|
// default and stays unwritten (build re-emits explicit false; ei's
|
|
@@ -998,7 +1172,7 @@ function allowListFromTf(typeKey, attrs, owner, ctx, site) {
|
|
|
998
1172
|
* fields, view field_ids/columns). Undefined for any other shape or an
|
|
999
1173
|
* unknown resource type.
|
|
1000
1174
|
*/
|
|
1001
|
-
export function fieldKeyFromTfRef(v, ownerTfLabel, scope = "app") {
|
|
1175
|
+
export function fieldKeyFromTfRef(v, ownerTfLabel, scope = "app", ctx) {
|
|
1002
1176
|
if (!isTfExpr(v))
|
|
1003
1177
|
return undefined;
|
|
1004
1178
|
if (v.$expr === "local" && ownerTfLabel !== undefined && v.path.length === 0) {
|
|
@@ -1014,7 +1188,9 @@ export function fieldKeyFromTfRef(v, ownerTfLabel, scope = "app") {
|
|
|
1014
1188
|
if (!SUB_TYPE_BY_RESOURCE.has(v.type))
|
|
1015
1189
|
return undefined;
|
|
1016
1190
|
const bare = ownerTfLabel !== undefined ? bareChildResourceLabel(ownerTfLabel, v.label, scope) : v.label;
|
|
1017
|
-
|
|
1191
|
+
if (ownerTfLabel === undefined)
|
|
1192
|
+
return tfLabelToTsLabel(bare);
|
|
1193
|
+
return pulledFieldBagKey(ownerTfLabel, v.label, scope, ctx);
|
|
1018
1194
|
}
|
|
1019
1195
|
/**
|
|
1020
1196
|
* Resolve either a normal Terraform field reference or a raw platform field
|
|
@@ -1038,7 +1214,29 @@ export function fieldKeyFromTfValue(v, ownerRefName, ownerTfLabel, scope, ctx) {
|
|
|
1038
1214
|
return key;
|
|
1039
1215
|
}
|
|
1040
1216
|
}
|
|
1041
|
-
return fieldKeyFromTfRef(v, ownerTfLabel, scope);
|
|
1217
|
+
return fieldKeyFromTfRef(v, ownerTfLabel, scope, ctx);
|
|
1218
|
+
}
|
|
1219
|
+
/**
|
|
1220
|
+
* The key a view, layout or form entry prints from, when the owner also
|
|
1221
|
+
* authors its own field under a system key (#2513 elements, #1871 apps). Pull
|
|
1222
|
+
* resolves the platform system field and the own field to the same key, so
|
|
1223
|
+
* this keeps them apart per reference: the platform field's local or data
|
|
1224
|
+
* source becomes {@link platformAuditFieldToken} (printed as the bare key),
|
|
1225
|
+
* the own field's resource stays the key (printed as its field ref), and a
|
|
1226
|
+
* raw platform id stays raw, since pull can't tell whose it is (as
|
|
1227
|
+
* `selfSystemField` does). Any other reference returns `key` unchanged.
|
|
1228
|
+
*/
|
|
1229
|
+
export function elementAuditFieldReference(v, key, owner, ctx) {
|
|
1230
|
+
// Apps re-key colliding custom fields (#1871); only element audit still
|
|
1231
|
+
// shares a bag key with a possible same-keyed custom until that path re-keys.
|
|
1232
|
+
const scope = owner.scope ?? "app";
|
|
1233
|
+
if (scope !== "element" || !ELEMENT_AUDIT_SYSTEM_FIELD_KEY_SET.has(key))
|
|
1234
|
+
return key;
|
|
1235
|
+
if (ctx.resourcesOfType === undefined || !ownerMayHaveCustomField(owner, key, ctx))
|
|
1236
|
+
return key;
|
|
1237
|
+
if (typeof v === "string")
|
|
1238
|
+
return v;
|
|
1239
|
+
return isTfExpr(v) && (v.$expr === "local" || v.$expr === "data-attr") ? platformAuditFieldToken(key) : key;
|
|
1042
1240
|
}
|
|
1043
1241
|
/**
|
|
1044
1242
|
* Decode `data.elementum_field.<label>` to the target's public field key.
|
|
@@ -20,6 +20,10 @@ export const fieldModule = {
|
|
|
20
20
|
resourceType: t.resourceType,
|
|
21
21
|
implemented: t.implemented === true,
|
|
22
22
|
authoringType: t.authoringType,
|
|
23
|
+
// The provider's Read drops an inactive option that isn't in prior state
|
|
24
|
+
// (`keepPicklistAPIOption`), so adoption re-imports the field so state
|
|
25
|
+
// holds the inactive options a re-pull prints (#2186).
|
|
26
|
+
...(t.hasOptions === true && { stateScopedInactiveOptions: ["options"] }),
|
|
23
27
|
})),
|
|
24
28
|
},
|
|
25
29
|
// Foreign relationship/relation fields are looked up by name under their
|
|
@@ -45,6 +45,8 @@ interface FieldTokenWire {
|
|
|
45
45
|
readonly parentKind?: "app" | "element" | "task";
|
|
46
46
|
readonly parentName?: string;
|
|
47
47
|
readonly fieldType?: string;
|
|
48
|
+
/** Natural bag key when pull re-keyed off a reserved system key (#1871). */
|
|
49
|
+
readonly resourceKey?: string;
|
|
48
50
|
}
|
|
49
51
|
/**
|
|
50
52
|
* One entry of `sort.orders` in the shape actually observed live on a
|
|
@@ -95,6 +97,8 @@ interface FieldConfigWire {
|
|
|
95
97
|
export interface FieldInnerWire {
|
|
96
98
|
readonly name?: string;
|
|
97
99
|
readonly __refName?: string;
|
|
100
|
+
/** Natural bag key when pull re-keyed off a reserved system key (#1871). */
|
|
101
|
+
readonly __resourceKey?: string;
|
|
98
102
|
readonly columnName?: string;
|
|
99
103
|
readonly required?: boolean;
|
|
100
104
|
readonly requiredOnClose?: boolean;
|
|
@@ -168,7 +172,7 @@ export interface FieldToTfResult {
|
|
|
168
172
|
*/
|
|
169
173
|
export declare function claimFieldDisplayName(seen: Map<string, string>, field: FieldToTfResult): void;
|
|
170
174
|
export declare function fieldToTf(typeKey: string, inner: FieldInnerWire, opts: FieldToTfOptions): FieldToTfResult | undefined;
|
|
171
|
-
export declare function fieldRefToTfValue(fieldType: string, refName: string, ownerTfLabel: string, scope?: FieldOwnerScope, fieldOwnership?: FieldOwnership): TfExpr | undefined;
|
|
175
|
+
export declare function fieldRefToTfValue(fieldType: string, refName: string, ownerTfLabel: string, scope?: FieldOwnerScope, fieldOwnership?: FieldOwnership, resourceKey?: string): TfExpr | undefined;
|
|
172
176
|
/**
|
|
173
177
|
* Why build leaves out an entry: its field reference has no field in source
|
|
174
178
|
* and no platform id (#1966, #1978). The gaps below state what apply then
|
|
@@ -20,10 +20,12 @@ import { expr, isCanonicalTsLabel, sanitizeName, scopedResourceLabel, snakeSlug,
|
|
|
20
20
|
import { SYSTEM_FIELD_KEY_SET, systemFieldTag } from "../../core/system-fields.js";
|
|
21
21
|
import { ELEMENT_AUDIT_SYSTEM_FIELD_KEYS, ELEMENT_SYSTEM_FIELD_KEYS } from "../element/system-fields.js";
|
|
22
22
|
import { filterToTf as filterWireToTfCodec } from "../shared/filters/tf-codec.js";
|
|
23
|
+
import { optionSelectionLiteral, optionsLocalName } from "../shared/filters/option-lookups.js";
|
|
23
24
|
import { foreignFieldDataLabel } from "../shared/foreign-ref.js";
|
|
24
25
|
import { isAttachmentMediaType } from "./media-types.js";
|
|
25
26
|
import { picklistLabel } from "./options.js";
|
|
26
27
|
import { SUB_TYPE_BY_AUTHORING_TYPE, SUB_TYPE_BY_TYPE_KEY } from "./types.js";
|
|
28
|
+
import { tfChildPartForFieldBagKey } from "./from-tf.js";
|
|
27
29
|
/** Reconstruct custom-field ownership from a loaded app/element payload. */
|
|
28
30
|
export function authoredFieldKeysFromPayload(payload) {
|
|
29
31
|
if (typeof payload !== "object" || payload === null)
|
|
@@ -210,7 +212,7 @@ function resolveFieldOnObject(token, object, opts, where, attrName = "relatedLab
|
|
|
210
212
|
opts.diagnostics.push(`${where}: ${attrName} token "${refName}" resolves to table "${object.target.tfLabel}" — tables expose columns, not fields; dropped`);
|
|
211
213
|
return undefined;
|
|
212
214
|
}
|
|
213
|
-
const value = fieldRefToTfValue(token.fieldType ?? "", refName, object.target.tfLabel, object.target.kind, object.fieldOwnership);
|
|
215
|
+
const value = fieldRefToTfValue(token.fieldType ?? "", refName, object.target.tfLabel, object.target.kind, object.fieldOwnership, token.resourceKey);
|
|
214
216
|
if (value === undefined) {
|
|
215
217
|
opts.diagnostics.push(`${where}: ${attrName} token "${refName}" has no terraform field resource mapping (fieldType ${JSON.stringify(token.fieldType ?? "")}); dropped`);
|
|
216
218
|
}
|
|
@@ -389,6 +391,19 @@ function buildDynamicPicklistConfigAttr(cfg, opts, where, typeKey, field) {
|
|
|
389
391
|
reference: () => {
|
|
390
392
|
throw new EntityTfError(`${where}: dynamic picklist filter does not support value references`);
|
|
391
393
|
},
|
|
394
|
+
// #2582: a Dropdown option is selected with filter.textOption(label).
|
|
395
|
+
literal: optionSelectionLiteral({
|
|
396
|
+
where: `${where}: config.dynamic.filter`,
|
|
397
|
+
address: where,
|
|
398
|
+
name: field.name,
|
|
399
|
+
ownerKind: "field",
|
|
400
|
+
optionsLocal: (token) => {
|
|
401
|
+
const target = resolvedObject.target;
|
|
402
|
+
return target === undefined || (target.kind !== "app" && target.kind !== "element")
|
|
403
|
+
? undefined
|
|
404
|
+
: optionsLocalName(target.tfLabel, target.kind, token);
|
|
405
|
+
},
|
|
406
|
+
}),
|
|
392
407
|
});
|
|
393
408
|
let filterValue;
|
|
394
409
|
try {
|
|
@@ -534,12 +549,14 @@ export function fieldToTf(typeKey, inner, opts) {
|
|
|
534
549
|
}
|
|
535
550
|
const bagKey = inner.__refName ?? snakeSlug(name);
|
|
536
551
|
// The bag key IS the field's terraform label (via the bijection — the
|
|
537
|
-
// stable naming contract, Sean 2026-07-22)
|
|
552
|
+
// stable naming contract, Sean 2026-07-22), except a #1871 re-key that
|
|
553
|
+
// carries `__resourceKey` keeps the natural system-key address so pull
|
|
554
|
+
// then plan does not destroy the live field. Non-canonical keys have no
|
|
538
555
|
// well-defined address: hard error, not a degradation.
|
|
539
556
|
if (!isCanonicalTsLabel(bagKey)) {
|
|
540
557
|
throw new EntityTfError(`field bag key "${bagKey}" is not a canonical tsLabel (see src/engine/tf/labels.ts) — rename the key in fields: {}`);
|
|
541
558
|
}
|
|
542
|
-
const tfLabel = scopedResourceLabel(ownerTfLabel,
|
|
559
|
+
const tfLabel = scopedResourceLabel(ownerTfLabel, tfChildPartForFieldBagKey(bagKey, inner.__resourceKey), scope);
|
|
543
560
|
const attrs = {
|
|
544
561
|
object_id: objectId,
|
|
545
562
|
name,
|
|
@@ -585,7 +602,7 @@ export function fieldToTf(typeKey, inner, opts) {
|
|
|
585
602
|
if (typeof include.picklist === "object" && include.picklist !== null) {
|
|
586
603
|
const field = include.picklist.picklistFieldId;
|
|
587
604
|
if (field?.refName !== undefined) {
|
|
588
|
-
const value = fieldRefToTfValue(field.fieldType ?? "PICKLIST", field.refName, ownerTfLabel, scope, opts.fieldOwnership);
|
|
605
|
+
const value = fieldRefToTfValue(field.fieldType ?? "PICKLIST", field.refName, ownerTfLabel, scope, opts.fieldOwnership, field.resourceKey);
|
|
589
606
|
if (value !== undefined) {
|
|
590
607
|
attrs["include_type"] = "PICKLIST";
|
|
591
608
|
attrs["picklist_field_id"] = value;
|
|
@@ -725,7 +742,7 @@ export function fieldToTf(typeKey, inner, opts) {
|
|
|
725
742
|
diagnostics.push(`field "${name}": parent value reference must target a Dropdown or Multi-Select field; dropped`);
|
|
726
743
|
continue;
|
|
727
744
|
}
|
|
728
|
-
const parentTfLabel = scopedResourceLabel(opts.ownerTfLabel,
|
|
745
|
+
const parentTfLabel = scopedResourceLabel(opts.ownerTfLabel, tfChildPartForFieldBagKey(ref.field.refName ?? "", ref.field.resourceKey), opts.scope ?? "app");
|
|
729
746
|
parentValueIds.push(expr.local(`${parentTfLabel}_options_by_label`, [{ index: ref.label }]));
|
|
730
747
|
}
|
|
731
748
|
if (parentValueIds.length > 0)
|
|
@@ -819,7 +836,7 @@ function allowListToTf(typeKey, inner, opts, attrs, name) {
|
|
|
819
836
|
if (token.parent !== undefined && token.parent !== opts.appRefName) {
|
|
820
837
|
throw new EntityTfError(`${where}: parentGroupField must belong to the same app or element, not ${JSON.stringify(token.parent)}`);
|
|
821
838
|
}
|
|
822
|
-
const value = fieldRefToTfValue(token.fieldType, token.refName ?? "", opts.ownerTfLabel, opts.scope ?? "app", opts.fieldOwnership);
|
|
839
|
+
const value = fieldRefToTfValue(token.fieldType, token.refName ?? "", opts.ownerTfLabel, opts.scope ?? "app", opts.fieldOwnership, token.resourceKey);
|
|
823
840
|
if (value === undefined)
|
|
824
841
|
throw new EntityTfError(`${where}: parentGroupField ${JSON.stringify(token.refName ?? "")} does not resolve to a group field resource`);
|
|
825
842
|
attrs["parent_group_field_id"] = value;
|
|
@@ -865,13 +882,13 @@ function scalarOrUndefined(v) {
|
|
|
865
882
|
/**
|
|
866
883
|
* Element system fields resolve through their `element/locals.ts` locals.
|
|
867
884
|
* Elements have no status/stage fields; the audit fields exist only on some
|
|
868
|
-
* elements, which the build checks against `systemFields.audit`.
|
|
869
|
-
* may
|
|
870
|
-
*
|
|
885
|
+
* elements, which the build checks against `systemFields.audit`. Custom fields
|
|
886
|
+
* may not use reserved system keys (#1871); pull re-keys a collision to
|
|
887
|
+
* `<key>Custom`. A key in `fieldAddresses` is therefore always a custom field.
|
|
871
888
|
*/
|
|
872
889
|
const ELEMENT_SYSTEM_FIELD_KEY_SET = new Set(ELEMENT_SYSTEM_FIELD_KEYS);
|
|
873
890
|
const ELEMENT_AUDIT_SYSTEM_FIELD_KEY_SET = new Set(ELEMENT_AUDIT_SYSTEM_FIELD_KEYS);
|
|
874
|
-
export function fieldRefToTfValue(fieldType, refName, ownerTfLabel, scope = "app", fieldOwnership) {
|
|
891
|
+
export function fieldRefToTfValue(fieldType, refName, ownerTfLabel, scope = "app", fieldOwnership, resourceKey) {
|
|
875
892
|
if (!isCanonicalTsLabel(refName))
|
|
876
893
|
return undefined;
|
|
877
894
|
if (scope === "element" &&
|
|
@@ -879,9 +896,13 @@ export function fieldRefToTfValue(fieldType, refName, ownerTfLabel, scope = "app
|
|
|
879
896
|
fieldOwnership === undefined) {
|
|
880
897
|
throw new EntityTfError(`element field "${refName}" requires authored-field ownership metadata to distinguish a custom field from the platform audit field`);
|
|
881
898
|
}
|
|
899
|
+
// Reserved system keys are never custom after #1871 reject/re-key. The
|
|
900
|
+
// fieldOwnership escape remains for leftover source that still keys a
|
|
901
|
+
// custom field as a system key (build rejects new source) and for element
|
|
902
|
+
// audit fields until that path is fully re-keyed.
|
|
882
903
|
const isSystemField = scope === "element"
|
|
883
904
|
? ELEMENT_SYSTEM_FIELD_KEY_SET.has(refName) && !(ELEMENT_AUDIT_SYSTEM_FIELD_KEY_SET.has(refName) && fieldOwnership?.has(refName) === true)
|
|
884
|
-
: SYSTEM_FIELD_KEY_SET.has(refName);
|
|
905
|
+
: SYSTEM_FIELD_KEY_SET.has(refName) && !(fieldOwnership?.has(refName) === true);
|
|
885
906
|
if (isSystemField) {
|
|
886
907
|
return expr.local(`${ownerTfLabel}_${tsLabelToTfLabel(refName)}_field_id`);
|
|
887
908
|
}
|
|
@@ -895,7 +916,7 @@ export function fieldRefToTfValue(fieldType, refName, ownerTfLabel, scope = "app
|
|
|
895
916
|
const subType = SUB_TYPE_BY_AUTHORING_TYPE.get(fieldType);
|
|
896
917
|
if (subType === undefined)
|
|
897
918
|
return undefined;
|
|
898
|
-
return expr.resourceAttr(subType.resourceType, scopedResourceLabel(ownerTfLabel,
|
|
919
|
+
return expr.resourceAttr(subType.resourceType, scopedResourceLabel(ownerTfLabel, tfChildPartForFieldBagKey(refName, resourceKey), scope), ["id"]);
|
|
899
920
|
}
|
|
900
921
|
/**
|
|
901
922
|
* Why build leaves out an entry: its field reference has no field in source
|
|
@@ -13,6 +13,7 @@ export const categoryModule = {
|
|
|
13
13
|
// Apps reference categories (`category_id`), so build emits this data
|
|
14
14
|
// source and the build-vs-export must scope it.
|
|
15
15
|
referencedByBuild: true,
|
|
16
|
+
managedInOrganization: true,
|
|
16
17
|
},
|
|
17
18
|
authoring: { unit: "inline", bag: "categories" },
|
|
18
19
|
parents: [{ parent: "org", child: "category" }],
|
|
@@ -9,5 +9,6 @@ export { connectorModule } from "./connector.js";
|
|
|
9
9
|
export { emailAliasModule } from "./email-alias.js";
|
|
10
10
|
export { groupModule } from "./group.js";
|
|
11
11
|
export { phoneProviderModule } from "./phone-provider.js";
|
|
12
|
+
export { voiceAuthModule } from "./voice-auth.js";
|
|
12
13
|
export { roleModule } from "./role.js";
|
|
13
14
|
export { userModule } from "./user.js";
|
|
@@ -9,5 +9,6 @@ export { connectorModule } from "./connector.js";
|
|
|
9
9
|
export { emailAliasModule } from "./email-alias.js";
|
|
10
10
|
export { groupModule } from "./group.js";
|
|
11
11
|
export { phoneProviderModule } from "./phone-provider.js";
|
|
12
|
+
export { voiceAuthModule } from "./voice-auth.js";
|
|
12
13
|
export { roleModule } from "./role.js";
|
|
13
14
|
export { userModule } from "./user.js";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Voice auth configs: org-owned reference identities, name-keyed data lookups. */
|
|
2
|
+
import { type EntityKindModule } from "../../graph/types.js";
|
|
3
|
+
export declare const VOICE_AUTH_RESOURCE_TYPE = "elementum_voice_auth_config";
|
|
4
|
+
export declare const VOICE_AUTH_ORG_BAG: "voiceAuths";
|
|
5
|
+
export declare const voiceAuthModule: EntityKindModule;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** Voice auth configs: org-owned reference identities, name-keyed data lookups. */
|
|
2
|
+
import { namedOnlyFactoryEntry } from "../../catalog/render-helpers.js";
|
|
3
|
+
export const VOICE_AUTH_RESOURCE_TYPE = "elementum_voice_auth_config";
|
|
4
|
+
export const VOICE_AUTH_ORG_BAG = "voiceAuths";
|
|
5
|
+
export const voiceAuthModule = {
|
|
6
|
+
kind: "voice-auth",
|
|
7
|
+
stream: { role: "streamMember" },
|
|
8
|
+
data: {
|
|
9
|
+
participates: true,
|
|
10
|
+
resourceType: VOICE_AUTH_RESOURCE_TYPE,
|
|
11
|
+
lookupAttr: "name",
|
|
12
|
+
catalogKind: "voiceAuth",
|
|
13
|
+
orgBag: VOICE_AUTH_ORG_BAG,
|
|
14
|
+
referencedByBuild: true,
|
|
15
|
+
managedInOrganization: true,
|
|
16
|
+
},
|
|
17
|
+
authoring: { unit: "inline", bag: "voiceAuths" },
|
|
18
|
+
parents: [{ parent: "org", child: "voice-auth" }],
|
|
19
|
+
resource: { shape: "single", resourceType: VOICE_AUTH_RESOURCE_TYPE, adoptable: true },
|
|
20
|
+
lifecycle: { participates: true },
|
|
21
|
+
canvas: { participates: true, label: "Voice Auth", glyph: "◉", component: "orgIdentity" },
|
|
22
|
+
catalog: {
|
|
23
|
+
participates: true,
|
|
24
|
+
refKind: "voiceAuth",
|
|
25
|
+
catalogBag: "voiceAuths",
|
|
26
|
+
renderOrder: 116,
|
|
27
|
+
catalogRoot: "org",
|
|
28
|
+
factoryName: "voiceAuthRef",
|
|
29
|
+
renderEntry: namedOnlyFactoryEntry("voiceAuthRef"),
|
|
30
|
+
stubRef: (refName) => ({ __kind: "voiceAuth", refName, name: refName }),
|
|
31
|
+
refFromAuthoring: () => undefined,
|
|
32
|
+
},
|
|
33
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type OrganizationVoiceAuth } from "./voice-auth.js";
|
|
1
2
|
import type { RoleUserRef } from "../role/build.js";
|
|
2
3
|
export interface OrganizationCategory {
|
|
3
4
|
readonly name: string;
|
|
@@ -227,6 +228,7 @@ export interface DefineOrganizationOptions {
|
|
|
227
228
|
readonly cloudLinks?: Readonly<Record<string, OrganizationCloudLink>>;
|
|
228
229
|
readonly emailAliases?: Readonly<Record<string, OrganizationEmailAlias>>;
|
|
229
230
|
readonly phoneProviders?: Readonly<Record<string, OrganizationPhoneProvider>>;
|
|
231
|
+
readonly voiceAuths?: Readonly<Record<string, OrganizationVoiceAuth>>;
|
|
230
232
|
}
|
|
231
233
|
export interface ConfiguredOrganization {
|
|
232
234
|
readonly kind: "organizationConfig";
|
|
@@ -235,6 +237,7 @@ export interface ConfiguredOrganization {
|
|
|
235
237
|
readonly cloudLinks: Readonly<Record<string, OrganizationCloudLink>>;
|
|
236
238
|
readonly emailAliases: Readonly<Record<string, OrganizationEmailAlias>>;
|
|
237
239
|
readonly phoneProviders: Readonly<Record<string, OrganizationPhoneProvider>>;
|
|
240
|
+
readonly voiceAuths: Readonly<Record<string, OrganizationVoiceAuth>>;
|
|
238
241
|
}
|
|
239
242
|
/** Organization-owned resources live in one ergonomic, optional `organization.ts` file. */
|
|
240
243
|
export declare function organization(opts: DefineOrganizationOptions): ConfiguredOrganization;
|
|
@@ -143,6 +143,7 @@ export function organization(opts) {
|
|
|
143
143
|
requireNames("groups", opts.groups);
|
|
144
144
|
requireNames("cloudLinks", opts.cloudLinks);
|
|
145
145
|
requireNames("phoneProviders", opts.phoneProviders);
|
|
146
|
+
requireNames("voiceAuths", opts.voiceAuths);
|
|
146
147
|
for (const [key, value] of Object.entries(opts.emailAliases ?? {})) {
|
|
147
148
|
if (key.trim() === "" || value.alias.trim() === "")
|
|
148
149
|
throw new EdkValidationError(`organization emailAliases.${key} must have a non-empty alias.`);
|
|
@@ -161,5 +162,6 @@ export function organization(opts) {
|
|
|
161
162
|
cloudLinks: opts.cloudLinks ?? {},
|
|
162
163
|
emailAliases: opts.emailAliases ?? {},
|
|
163
164
|
phoneProviders: opts.phoneProviders ?? {},
|
|
165
|
+
voiceAuths: opts.voiceAuths ?? {},
|
|
164
166
|
};
|
|
165
167
|
}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export { organization, apiCloudLink, bearerTokenCredentials, bigQueryCloudLink, cloudLinkScheduleUnit, cloudLinkUsageType, cloudLinkWarehouseSize, databricksCloudLink, emailAlias, elementumCloudLink, elementumSnowflakeCloudLink, externalOauthCredentials, passwordCredentials, privateKeyCredentials, serviceAccountCredentials, snowflakeCloudLink, twilioPhoneProvider, type ConfiguredOrganization, type DefineOrganizationOptions, type OrganizationCategory, type OrganizationGroup, redactedSecret, secret, unavailableValue, type CloudLinkCredentials, type CloudLinkSchedule, type CloudLinkScheduleUnit, type CloudLinkUsageType, type CloudLinkWarehouseSize, type OrganizationCloudLink, type OrganizationEmailAlias, type OrganizationPhoneProvider, type OrganizationSecret, type OrganizationSecretValue, type RedactedOrganizationSecret, type UnavailableOrganizationValue, } from "./build.js";
|
|
2
|
+
export { knownCallerAuth, unknownCallerAuth, voiceAuth, voiceAuthFailureAction, type KnownCallerAuth, type OrganizationVoiceAuth, type UnknownCallerAuth, type VoiceAuthCallerTreatment, type VoiceAuthEndCall, type VoiceAuthFailure, type VoiceAuthFailureAction, type VoiceAuthHandoff, type VoiceAuthOtpRecovery, } from "./voice-auth.js";
|
|
2
3
|
export { userRef, type RoleUserRef as OrganizationUserRef } from "../role/build.js";
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export { organization, apiCloudLink, bearerTokenCredentials, bigQueryCloudLink, cloudLinkScheduleUnit, cloudLinkUsageType, cloudLinkWarehouseSize, databricksCloudLink, emailAlias, elementumCloudLink, elementumSnowflakeCloudLink, externalOauthCredentials, passwordCredentials, privateKeyCredentials, serviceAccountCredentials, snowflakeCloudLink, twilioPhoneProvider, redactedSecret, secret, unavailableValue, } from "./build.js";
|
|
2
|
+
export { knownCallerAuth, unknownCallerAuth, voiceAuth, voiceAuthFailureAction, } from "./voice-auth.js";
|
|
2
3
|
export { userRef } from "../role/build.js";
|
|
@@ -5,3 +5,5 @@ export declare function organizationToTf(organization: ConfiguredOrganization, c
|
|
|
5
5
|
readonly orgRefs: OrgRefLookup;
|
|
6
6
|
readonly diagnostics?: string[];
|
|
7
7
|
}): TfBlock[];
|
|
8
|
+
/** Resource HCL for one organization.ts voice auth, used when adoption imports it. */
|
|
9
|
+
export declare function renderVoiceAuthAdoptionResource(label: string, value: unknown): string | undefined;
|