@elementumai/edk 0.9.20 → 0.10.2
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 +19 -7
- package/dist-sdk/src/catalog/factories.d.ts +10 -2
- package/dist-sdk/src/catalog/factories.js +10 -1
- package/dist-sdk/src/catalog/index.d.ts +2 -2
- package/dist-sdk/src/catalog/index.js +1 -1
- package/dist-sdk/src/catalog/token.js +4 -0
- package/dist-sdk/src/catalog/types.d.ts +7 -1
- package/dist-sdk/src/catalog/types.js +1 -0
- package/dist-sdk/src/core/triggers/on-demand.d.ts +2 -2
- package/dist-sdk/src/core/triggers/on-demand.js +7 -0
- package/dist-sdk/src/core/types/app.d.ts +2 -2
- package/dist-sdk/src/engine/coverage-gaps.d.ts +86 -0
- package/dist-sdk/src/engine/coverage-gaps.js +156 -0
- package/dist-sdk/src/engine/ei/run.d.ts +21 -1
- package/dist-sdk/src/engine/ei/run.js +89 -2
- package/dist-sdk/src/engine/pull/catalog-ref.d.ts +16 -0
- package/dist-sdk/src/engine/pull/catalog-ref.js +24 -0
- package/dist-sdk/src/engine/pull/context.d.ts +68 -6
- package/dist-sdk/src/engine/pull/context.js +40 -1
- package/dist-sdk/src/engine/pull/procedure-refs.d.ts +8 -0
- package/dist-sdk/src/engine/pull/procedure-refs.js +28 -0
- package/dist-sdk/src/engine/pull/result-output.js +27 -1
- package/dist-sdk/src/engine/tf/index.d.ts +1 -1
- package/dist-sdk/src/engine/tf/index.js +1 -1
- package/dist-sdk/src/engine/tf/labels.d.ts +22 -5
- package/dist-sdk/src/engine/tf/labels.js +45 -3
- package/dist-sdk/src/engine/tf/parse.js +3 -2
- package/dist-sdk/src/engine/validation.d.ts +5 -0
- package/dist-sdk/src/engine/validation.js +12 -2
- package/dist-sdk/src/entities/access-policy/from-tf.js +38 -1
- package/dist-sdk/src/entities/access-policy/principal.d.ts +2 -0
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +3 -0
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +42 -19
- package/dist-sdk/src/entities/agent/from-tf.js +11 -3
- package/dist-sdk/src/entities/agent/module.js +2 -0
- package/dist-sdk/src/entities/agent/to-tf.js +14 -3
- package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +8 -1
- package/dist-sdk/src/entities/agent-tool/from-tf.js +11 -5
- package/dist-sdk/src/entities/agent-tool/module.js +3 -0
- package/dist-sdk/src/entities/app/auto-share.d.ts +38 -0
- package/dist-sdk/src/entities/app/auto-share.js +49 -0
- package/dist-sdk/src/entities/app/build.d.ts +17 -3
- package/dist-sdk/src/entities/app/build.js +56 -4
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +6 -1
- package/dist-sdk/src/entities/app/from-tf.js +4 -0
- package/dist-sdk/src/entities/app/index.d.ts +2 -1
- package/dist-sdk/src/entities/app/index.js +1 -8
- package/dist-sdk/src/entities/app/module.js +2 -1
- package/dist-sdk/src/entities/app/to-tf.d.ts +6 -0
- package/dist-sdk/src/entities/app/to-tf.js +25 -2
- package/dist-sdk/src/entities/automation/build.d.ts +12 -2
- package/dist-sdk/src/entities/automation/build.js +105 -17
- package/dist-sdk/src/entities/automation/calculation-expression.d.ts +7 -7
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +17 -4
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +187 -27
- package/dist-sdk/src/entities/automation/from-tf.d.ts +9 -2
- package/dist-sdk/src/entities/automation/from-tf.js +397 -89
- package/dist-sdk/src/entities/automation/index.d.ts +1 -1
- package/dist-sdk/src/entities/automation/index.js +1 -1
- package/dist-sdk/src/entities/automation/module.d.ts +3 -0
- package/dist-sdk/src/entities/automation/module.js +70 -7
- package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +21 -0
- package/dist-sdk/src/entities/automation/output-key-wire-name.js +38 -0
- package/dist-sdk/src/entities/automation/script-code.d.ts +5 -2
- package/dist-sdk/src/entities/automation/script-code.js +23 -5
- package/dist-sdk/src/entities/automation/task-output-labels.d.ts +37 -0
- package/dist-sdk/src/entities/automation/task-output-labels.js +76 -0
- package/dist-sdk/src/entities/automation/tasks.d.ts +92 -20
- package/dist-sdk/src/entities/automation/tasks.js +48 -15
- package/dist-sdk/src/entities/automation/to-tf.d.ts +20 -3
- package/dist-sdk/src/entities/automation/to-tf.js +656 -65
- package/dist-sdk/src/entities/automation/triggers.d.ts +8 -4
- package/dist-sdk/src/entities/automation/types.d.ts +9 -0
- package/dist-sdk/src/entities/automation/types.js +19 -0
- package/dist-sdk/src/entities/automation/value-ref-tf.d.ts +1 -1
- package/dist-sdk/src/entities/automation/value-ref-tf.js +1 -1
- package/dist-sdk/src/entities/chart/from-tf.js +9 -1
- package/dist-sdk/src/entities/data-lookup/module.js +2 -0
- package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +7 -5
- package/dist-sdk/src/entities/element/build.d.ts +3 -0
- package/dist-sdk/src/entities/element/build.js +1 -0
- package/dist-sdk/src/entities/element/from-tf.js +4 -0
- package/dist-sdk/src/entities/element/module.js +2 -1
- package/dist-sdk/src/entities/element/to-tf.d.ts +1 -1
- package/dist-sdk/src/entities/element/to-tf.js +12 -14
- package/dist-sdk/src/entities/field/build.d.ts +3 -2
- package/dist-sdk/src/entities/field/calc.d.ts +7 -7
- package/dist-sdk/src/entities/field/from-tf.d.ts +4 -4
- package/dist-sdk/src/entities/field/from-tf.js +255 -80
- package/dist-sdk/src/entities/field/module.d.ts +6 -0
- package/dist-sdk/src/entities/field/module.js +23 -2
- package/dist-sdk/src/entities/field/options.js +6 -1
- package/dist-sdk/src/entities/field/order.d.ts +16 -0
- package/dist-sdk/src/entities/field/order.js +41 -0
- package/dist-sdk/src/entities/field/to-tf.d.ts +4 -4
- package/dist-sdk/src/entities/field/to-tf.js +7 -1
- package/dist-sdk/src/entities/field/types.d.ts +7 -0
- package/dist-sdk/src/entities/field/types.js +32 -0
- package/dist-sdk/src/entities/role/from-tf.js +3 -3
- package/dist-sdk/src/entities/role/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/role/to-tf.js +12 -4
- package/dist-sdk/src/entities/service-account/from-tf.js +3 -3
- package/dist-sdk/src/entities/service-account/workspace-owner.d.ts +16 -0
- package/dist-sdk/src/entities/service-account/workspace-owner.js +22 -0
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +15 -1
- package/dist-sdk/src/entities/shared/filters/ast.js +2 -0
- package/dist-sdk/src/entities/shared/filters/index.d.ts +5 -0
- package/dist-sdk/src/entities/shared/filters/index.js +5 -0
- package/dist-sdk/src/entities/shared/filters/print.js +7 -2
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +5 -0
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +42 -7
- package/dist-sdk/src/entities/shared/filters/types.d.ts +8 -3
- package/dist-sdk/src/entities/shared/ref.d.ts +5 -7
- package/dist-sdk/src/entities/shared/ref.js +5 -7
- package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +9 -0
- package/dist-sdk/src/entities/shared/tool-field-ref.js +35 -2
- package/dist-sdk/src/entities/shared/types/field-types.d.ts +10 -0
- package/dist-sdk/src/entities/shared/types/field-types.js +4 -0
- package/dist-sdk/src/entities/skill/access-policy.js +3 -3
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +3 -0
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +12 -5
- package/dist-sdk/src/entities/skill/from-tf.js +4 -2
- package/dist-sdk/src/entities/skill/module.js +2 -0
- package/dist-sdk/src/entities/skill-tool/from-tf.js +41 -8
- package/dist-sdk/src/entities/skill-tool/module.js +3 -0
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +0 -6
- package/dist-sdk/src/entities/skill-tool/to-tf.js +22 -9
- package/dist-sdk/src/entities/task/build.d.ts +8 -0
- package/dist-sdk/src/entities/task/build.js +10 -1
- package/dist-sdk/src/entities/task/from-tf.d.ts +4 -2
- package/dist-sdk/src/entities/task/from-tf.js +7 -2
- package/dist-sdk/src/entities/task/module.js +3 -2
- package/dist-sdk/src/entities/task/to-tf.d.ts +8 -4
- package/dist-sdk/src/entities/task/to-tf.js +32 -1
- package/dist-sdk/src/entities/view/from-tf.js +9 -1
- package/dist-sdk/src/entities/view/module.js +4 -1
- package/dist-sdk/src/entities/view/to-tf.d.ts +6 -7
- package/dist-sdk/src/entities/view/to-tf.js +30 -11
- package/dist-sdk/src/entities/view/types.d.ts +6 -0
- package/dist-sdk/src/entities/view/types.js +6 -0
- package/dist-sdk/src/entities/visual-flow/build.d.ts +16 -1
- package/dist-sdk/src/entities/visual-flow/build.js +9 -0
- package/dist-sdk/src/entities/visual-flow/from-tf.d.ts +14 -0
- package/dist-sdk/src/entities/visual-flow/from-tf.js +51 -3
- package/dist-sdk/src/entities/visual-flow/index.d.ts +1 -1
- package/dist-sdk/src/entities/visual-flow/index.js +1 -1
- package/dist-sdk/src/entities/visual-flow/printer.js +19 -0
- package/dist-sdk/src/entities/visual-flow/to-tf.js +87 -3
- package/dist-sdk/src/entities/widget/from-tf.js +3 -3
- package/dist-sdk/src/entities/widget/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/widget/to-tf.js +7 -6
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +133 -9
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
- package/dist-sdk/src/graph/index.d.ts +4 -2
- package/dist-sdk/src/graph/index.js +3 -0
- package/dist-sdk/src/graph/modules.js +2 -1
- package/dist-sdk/src/graph/types.d.ts +41 -3
- package/package.json +7 -3
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* non-canonical bag key: it has no well-defined terraform address.
|
|
11
11
|
*/
|
|
12
12
|
import { type OrgRefLookup, type WorkspaceAspect } from "../../engine/build/context.js";
|
|
13
|
-
import { type
|
|
13
|
+
import { type FieldOwnerScope, type TfBlock, type TfExpr, type TfValue } from "../../engine/tf/index.js";
|
|
14
14
|
import { type PicklistValueWire } from "./options.js";
|
|
15
15
|
/**
|
|
16
16
|
* The authored fields known to belong to an app/element. Maps produced by a
|
|
@@ -122,8 +122,8 @@ export interface FieldToTfOptions {
|
|
|
122
122
|
readonly ownerTfLabel: string;
|
|
123
123
|
/** The owning stream root's refName — needed to detect a self-targeting RELATION field. */
|
|
124
124
|
readonly appRefName: string;
|
|
125
|
-
/** App children use `apps_<ns>_
|
|
126
|
-
readonly scope?:
|
|
125
|
+
/** App children use `apps_<ns>_<ns>_`, element children `elements_<ns>_<ns>_`, task children `tasks_<ns>_<ns>_` (edk#1464). */
|
|
126
|
+
readonly scope?: FieldOwnerScope;
|
|
127
127
|
/** The owner's id reference, e.g. `elementum_app.<ns>.id` — computed by the owner's to-tf. */
|
|
128
128
|
readonly objectId: TfValue;
|
|
129
129
|
/** Degradations land here — reported by the caller, never silent. */
|
|
@@ -156,5 +156,5 @@ export interface FieldToTfResult {
|
|
|
156
156
|
*/
|
|
157
157
|
export declare function claimFieldDisplayName(seen: Map<string, string>, field: FieldToTfResult): void;
|
|
158
158
|
export declare function fieldToTf(typeKey: string, inner: FieldInnerWire, opts: FieldToTfOptions): FieldToTfResult | undefined;
|
|
159
|
-
export declare function fieldRefToTfValue(fieldType: string, refName: string, ownerTfLabel: string, scope?:
|
|
159
|
+
export declare function fieldRefToTfValue(fieldType: string, refName: string, ownerTfLabel: string, scope?: FieldOwnerScope, fieldOwnership?: FieldOwnership): TfExpr | undefined;
|
|
160
160
|
export {};
|
|
@@ -194,7 +194,11 @@ function resolveFieldOnObject(token, object, opts, where, attrName = "relatedLab
|
|
|
194
194
|
opts.diagnostics.push(`${where}: ${attrName} token "${refName}" belongs to "${token.parent}", not the resolved target "${object.refName}"; dropped`);
|
|
195
195
|
return undefined;
|
|
196
196
|
}
|
|
197
|
-
|
|
197
|
+
// `target` is set only for the owner itself or a workspace app/element
|
|
198
|
+
// sibling (resolveRelatedObject); another task never carries one and falls
|
|
199
|
+
// through to the data lookup below. So a "task" target is always the
|
|
200
|
+
// owning task, whose fields are resources since edk#1464.
|
|
201
|
+
if (object.target !== undefined) {
|
|
198
202
|
// A field belongs to an app or element; a table exposes columns, not fields.
|
|
199
203
|
// Guard rather than widen fieldRefToTfValue's scope parameter.
|
|
200
204
|
if (object.target.kind === "table") {
|
|
@@ -348,6 +352,7 @@ function buildDynamicPicklistConfigAttr(cfg, opts, where, typeKey) {
|
|
|
348
352
|
}
|
|
349
353
|
return value;
|
|
350
354
|
},
|
|
355
|
+
recordFieldOwner: () => opts.objectId,
|
|
351
356
|
field: (token) => {
|
|
352
357
|
const value = resolveFieldOnObject(token, resolvedObject, opts_, where, "filter field");
|
|
353
358
|
if (value === undefined) {
|
|
@@ -402,6 +407,7 @@ function resolveDynamicMappingFieldOwner(token, opts, where) {
|
|
|
402
407
|
__kind: token.parentKind,
|
|
403
408
|
refName: token.parent,
|
|
404
409
|
name: token.parentName ?? token.parent,
|
|
410
|
+
...(token.parentNamespace !== undefined ? { namespace: token.parentNamespace } : {}),
|
|
405
411
|
}, opts, where);
|
|
406
412
|
}
|
|
407
413
|
function resolveDynamicPicklistSort(sort, relatedObject, opts, where) {
|
|
@@ -51,3 +51,10 @@ export declare const SUB_TYPE_BY_AUTHORING_TYPE: ReadonlyMap<string, FieldSubTyp
|
|
|
51
51
|
export declare const FIELD_RESOURCE_TYPES: readonly string[];
|
|
52
52
|
/** Attributes `fieldFromTf` understands — anything else is dialect growth, reported loudly. */
|
|
53
53
|
export declare const KNOWN_FIELD_ATTRS: ReadonlySet<string>;
|
|
54
|
+
/** Provider resource type a field constructor builds, or undefined for unmodeled constructors. */
|
|
55
|
+
export declare function fieldResourceTypeForCtor(ctor: string): string | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* The order of an app's, element's or task's custom fields: the default column
|
|
58
|
+
* order of its record tables (#1670). One per owner, keyed by the owner's id.
|
|
59
|
+
*/
|
|
60
|
+
export declare const MANAGED_FIELD_ORDER_RESOURCE_TYPE = "elementum_managed_field_order";
|
|
@@ -77,3 +77,35 @@ export const KNOWN_FIELD_ATTRS = new Set([
|
|
|
77
77
|
"picklist_field_id",
|
|
78
78
|
"media_types",
|
|
79
79
|
]);
|
|
80
|
+
/** Authoring constructor base name (`richText` for `richTextField`) → FIELD_SUB_TYPES typeKey. */
|
|
81
|
+
const FIELD_CTOR_TYPE_KEYS = {
|
|
82
|
+
text: "text",
|
|
83
|
+
richText: "html",
|
|
84
|
+
number: "number",
|
|
85
|
+
decimal: "decimal",
|
|
86
|
+
boolean: "bool",
|
|
87
|
+
date: "date",
|
|
88
|
+
dateTime: "dateTime",
|
|
89
|
+
user: "user",
|
|
90
|
+
group: "group",
|
|
91
|
+
attachment: "attachment",
|
|
92
|
+
json: "json",
|
|
93
|
+
dropdown: "picklist",
|
|
94
|
+
multiSelect: "multiPicklist",
|
|
95
|
+
/** @deprecated constructor; still authored in older workspaces. */
|
|
96
|
+
picklist: "picklist",
|
|
97
|
+
/** @deprecated constructor; still authored in older workspaces. */
|
|
98
|
+
multiPicklist: "multiPicklist",
|
|
99
|
+
relation: "relation",
|
|
100
|
+
calculated: "calculated",
|
|
101
|
+
};
|
|
102
|
+
/** Provider resource type a field constructor builds, or undefined for unmodeled constructors. */
|
|
103
|
+
export function fieldResourceTypeForCtor(ctor) {
|
|
104
|
+
const typeKey = FIELD_CTOR_TYPE_KEYS[ctor];
|
|
105
|
+
return typeKey === undefined ? undefined : FIELD_SUB_TYPES.find((t) => t.typeKey === typeKey)?.resourceType;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* The order of an app's, element's or task's custom fields: the default column
|
|
109
|
+
* order of its record tables (#1670). One per owner, keyed by the owner's id.
|
|
110
|
+
*/
|
|
111
|
+
export const MANAGED_FIELD_ORDER_RESOURCE_TYPE = "elementum_managed_field_order";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { dataRefLabel, resourceRefLabel } from "../../engine/pull/context.js";
|
|
2
|
-
import { scopedLabelToBagKey
|
|
1
|
+
import { dataRefLabel, groupCatalogKey, resourceRefLabel } from "../../engine/pull/context.js";
|
|
2
|
+
import { scopedLabelToBagKey } from "../../engine/tf/index.js";
|
|
3
3
|
import { ROLE_RESOURCE_TYPE } from "../org/role.js";
|
|
4
4
|
const KNOWN = new Set(["id", "object_id", "name", "description", "auto_share", "user_ids", "group_ids", "service_account_ids", "permissions", "managed", "tags"]);
|
|
5
5
|
function strings(value, where, ctx) {
|
|
@@ -23,7 +23,7 @@ function principal(value, type, where, ctx) {
|
|
|
23
23
|
}
|
|
24
24
|
return { __kind: "user", email: name.trim() };
|
|
25
25
|
}
|
|
26
|
-
return { __kind: "group", refName:
|
|
26
|
+
return { __kind: "group", refName: groupCatalogKey(ctx, label, name), name };
|
|
27
27
|
}
|
|
28
28
|
ctx.diagnostics.push(`${where}: data.${type}.${label} has no lookup value; dropped`);
|
|
29
29
|
return undefined;
|
|
@@ -2,6 +2,7 @@ import type { OrgRefLookup } from "../../engine/build/context.js";
|
|
|
2
2
|
import { type ChildResourceScope, type TfBlock, type TfValue } from "../../engine/tf/index.js";
|
|
3
3
|
import type { AppRole } from "./build.js";
|
|
4
4
|
import type { AppServiceAccount } from "../service-account/build.js";
|
|
5
|
+
import type { ServiceAccountOwningApp } from "../service-account/workspace-owner.js";
|
|
5
6
|
export declare function rolesToTf(roles: Readonly<Record<string, AppRole>> | undefined, opts: {
|
|
6
7
|
readonly ownerRefName: string;
|
|
7
8
|
readonly ownerTfLabel: string;
|
|
@@ -10,4 +11,5 @@ export declare function rolesToTf(roles: Readonly<Record<string, AppRole>> | und
|
|
|
10
11
|
readonly serviceAccounts?: Readonly<Record<string, AppServiceAccount>>;
|
|
11
12
|
readonly orgRefs: OrgRefLookup;
|
|
12
13
|
readonly diagnostics: string[];
|
|
14
|
+
readonly resolveServiceAccountApp?: (appRefName: string) => ServiceAccountOwningApp | undefined;
|
|
13
15
|
}): TfBlock[];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { expr, sanitizeName, scopedResourceLabel, tsLabelToTfLabel } from "../../engine/tf/index.js";
|
|
2
2
|
import { ROLE_RESOURCE_TYPE } from "../org/role.js";
|
|
3
3
|
import { SERVICE_ACCOUNT_RESOURCE_TYPE } from "../service-account/module.js";
|
|
4
|
+
import { serviceAccountRefToTf } from "../service-account/to-tf.js";
|
|
4
5
|
function principals(values, type, where, orgRefs, diagnostics) {
|
|
5
6
|
if (values === undefined || values.length === 0)
|
|
6
7
|
return undefined;
|
|
@@ -41,11 +42,18 @@ export function rolesToTf(roles, opts) {
|
|
|
41
42
|
attrs["group_ids"] = groups;
|
|
42
43
|
if (role.serviceAccounts !== undefined) {
|
|
43
44
|
attrs["service_account_ids"] = role.serviceAccounts.flatMap((account) => {
|
|
44
|
-
if (account.appRefName !== opts.ownerRefName) {
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
if (opts.scope !== "app" || account.appRefName !== opts.ownerRefName) {
|
|
46
|
+
// Another app's account (or any account on an element role, which
|
|
47
|
+
// owns none): resolve it under its OWNING app (#1592).
|
|
48
|
+
const owning = opts.resolveServiceAccountApp?.(account.appRefName);
|
|
49
|
+
if (owning === undefined) {
|
|
50
|
+
opts.diagnostics.push(`roles.${key}.serviceAccounts: ${JSON.stringify(account.name)} belongs to app ${JSON.stringify(account.appRefName)}, which is not in this workspace; dropped`);
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
const value = serviceAccountRefToTf({ __kind: "serviceAccount", appRefName: account.appRefName, name: account.name }, { appRefName: account.appRefName, ...owning, orgRefs: opts.orgRefs }, `roles.${key}.serviceAccounts`, opts.diagnostics);
|
|
54
|
+
return value === undefined ? [] : [value];
|
|
47
55
|
}
|
|
48
|
-
const local = Object.entries(opts.serviceAccounts ?? {}).find(([, candidate]) => `${candidate.firstName} ${candidate.lastName}
|
|
56
|
+
const local = Object.entries(opts.serviceAccounts ?? {}).find(([, candidate]) => `${candidate.firstName} ${candidate.lastName}`.trim() === account.name);
|
|
49
57
|
if (local !== undefined)
|
|
50
58
|
return [expr.resourceAttr(SERVICE_ACCOUNT_RESOURCE_TYPE, scopedResourceLabel(opts.ownerTfLabel, tsLabelToTfLabel(local[0]), "app"), ["id"])];
|
|
51
59
|
const label = sanitizeName(account.name);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { unsafePlatformId } from "../../core/platform-id.js";
|
|
2
|
-
import { dataRefLabel, resourceRefLabel } from "../../engine/pull/context.js";
|
|
3
|
-
import { scopedLabelToBagKey
|
|
2
|
+
import { dataRefLabel, groupCatalogKey, resourceRefLabel } from "../../engine/pull/context.js";
|
|
3
|
+
import { scopedLabelToBagKey } from "../../engine/tf/index.js";
|
|
4
4
|
import { serviceAccountRoleRef, serviceAccountStatus, } from "./build.js";
|
|
5
5
|
import { SERVICE_ACCOUNT_ACCESS_POLICY_RESOURCE_TYPE, SERVICE_ACCOUNT_RESOURCE_TYPE } from "./module.js";
|
|
6
6
|
import { serviceAccountRoleIdMismatches } from "./role-fidelity.js";
|
|
@@ -18,7 +18,7 @@ function principal(value, type, where, ctx) {
|
|
|
18
18
|
}
|
|
19
19
|
return { __kind: "user", email: name.trim() };
|
|
20
20
|
}
|
|
21
|
-
return { __kind: "group", refName:
|
|
21
|
+
return { __kind: "group", refName: groupCatalogKey(ctx, label, name), name };
|
|
22
22
|
}
|
|
23
23
|
ctx.diagnostics.push(`${where}: data.${type}.${label} has no lookup value; dropped`);
|
|
24
24
|
return undefined;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type WorkspaceAspect } from "../../engine/build/context.js";
|
|
2
|
+
import { type TfValue } from "../../engine/tf/index.js";
|
|
3
|
+
import type { AppServiceAccount } from "./build.js";
|
|
4
|
+
/** The app that owns a service account, as a role or policy on another object resolves it. */
|
|
5
|
+
export interface ServiceAccountOwningApp {
|
|
6
|
+
readonly appTfLabel: string;
|
|
7
|
+
readonly appId: TfValue;
|
|
8
|
+
readonly serviceAccounts?: Readonly<Record<string, AppServiceAccount>>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Resolve the workspace app that owns a `serviceAccountRef` named from a
|
|
12
|
+
* different object (another app or an element), so its lookup is scoped to the
|
|
13
|
+
* OWNING app (#1592), not the object that grants it access. A managed account
|
|
14
|
+
* becomes a direct resource ref, so same-apply creation is sequenced.
|
|
15
|
+
*/
|
|
16
|
+
export declare function workspaceServiceAccountAppResolver(workspaceAspects: ReadonlyMap<string, WorkspaceAspect> | undefined): (appRefName: string) => ServiceAccountOwningApp | undefined;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { workspaceAspectKey } from "../../engine/build/context.js";
|
|
2
|
+
import { expr } from "../../engine/tf/index.js";
|
|
3
|
+
import { APP_RESOURCE_TYPE } from "../app/module.js";
|
|
4
|
+
/**
|
|
5
|
+
* Resolve the workspace app that owns a `serviceAccountRef` named from a
|
|
6
|
+
* different object (another app or an element), so its lookup is scoped to the
|
|
7
|
+
* OWNING app (#1592), not the object that grants it access. A managed account
|
|
8
|
+
* becomes a direct resource ref, so same-apply creation is sequenced.
|
|
9
|
+
*/
|
|
10
|
+
export function workspaceServiceAccountAppResolver(workspaceAspects) {
|
|
11
|
+
return (appRefName) => {
|
|
12
|
+
const app = workspaceAspects?.get(workspaceAspectKey("app", appRefName));
|
|
13
|
+
if (app === undefined)
|
|
14
|
+
return undefined;
|
|
15
|
+
const serviceAccounts = app.streamRootEntity?.payload?.serviceAccounts;
|
|
16
|
+
return {
|
|
17
|
+
appTfLabel: app.tfLabel,
|
|
18
|
+
appId: expr.resourceAttr(APP_RESOURCE_TYPE, app.tfLabel, ["id"]),
|
|
19
|
+
...(serviceAccounts !== undefined ? { serviceAccounts } : {}),
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -42,6 +42,8 @@ export interface AppRefAst {
|
|
|
42
42
|
readonly entityType?: "app" | "element" | "task";
|
|
43
43
|
/** Provider lookup name for that foreign app/element. */
|
|
44
44
|
readonly name?: string;
|
|
45
|
+
/** Set when the export looked the foreign root up by namespace; build then does too. */
|
|
46
|
+
readonly namespace?: string;
|
|
45
47
|
}
|
|
46
48
|
/** Reference to an app field: `<appHandle>.fields.<fieldKey>`. */
|
|
47
49
|
export interface FieldRefAst {
|
|
@@ -102,6 +104,18 @@ export interface UserRefAst {
|
|
|
102
104
|
readonly kind: "user";
|
|
103
105
|
readonly email: string;
|
|
104
106
|
}
|
|
107
|
+
/** Reference to an existing vault entry by key: `secret("<key>")`. */
|
|
108
|
+
export interface SecretRefAst {
|
|
109
|
+
readonly kind: "secret";
|
|
110
|
+
readonly key: string;
|
|
111
|
+
}
|
|
112
|
+
/** Organization group from the org catalog's `groups` bag (`org.groups.<key>`). */
|
|
113
|
+
export interface GroupRefAst {
|
|
114
|
+
readonly kind: "orgGroup";
|
|
115
|
+
readonly groupKey: string;
|
|
116
|
+
/** The group's display name — the lookup value. */
|
|
117
|
+
readonly name: string;
|
|
118
|
+
}
|
|
105
119
|
/** Reference to a sub-automation via the app's `automations` bag. */
|
|
106
120
|
export interface AutomationRefAst {
|
|
107
121
|
readonly kind: "automation";
|
|
@@ -259,7 +273,7 @@ export type RefExpr =
|
|
|
259
273
|
| {
|
|
260
274
|
kind: "template";
|
|
261
275
|
parts: readonly (string | RefExpr)[];
|
|
262
|
-
} | FieldRefAst | UserFieldRefAst | UserGroupFieldRefAst | AppRefAst | AgentRefAst | AutomationRefAst | DocumentModelRefAst | DocumentModelFieldRefAst | ApprovalChainRefAst | DatamineRefAst | TableRefAst | TableColumnRefAst | SearchTableRefAst | ConnectorRefAst | CloudLinkRefAst | ProcedureRefAst | PhoneServiceRefAst | UserRefAst | UnresolvedRefAst
|
|
276
|
+
} | FieldRefAst | UserFieldRefAst | UserGroupFieldRefAst | AppRefAst | AgentRefAst | AutomationRefAst | DocumentModelRefAst | DocumentModelFieldRefAst | ApprovalChainRefAst | DatamineRefAst | TableRefAst | TableColumnRefAst | SearchTableRefAst | ConnectorRefAst | CloudLinkRefAst | ProcedureRefAst | PhoneServiceRefAst | UserRefAst | SecretRefAst | GroupRefAst | UnresolvedRefAst
|
|
263
277
|
/** Preserved terraform local expression for round-trip (e.g. status option ids by label). */
|
|
264
278
|
| {
|
|
265
279
|
kind: "localRef";
|
|
@@ -80,9 +80,14 @@ export declare function fieldValue(value: FilterField, options?: {
|
|
|
80
80
|
* Compare against a field on the record being edited — a dynamic Dropdown
|
|
81
81
|
* filter such as "source Process Area equals this record's Process Area".
|
|
82
82
|
* `field` must belong to the Dropdown's own app or element.
|
|
83
|
+
*
|
|
84
|
+
* `includeOwner` stores the Dropdown's own app or element alongside the field,
|
|
85
|
+
* the form some existing filters were saved in. Pull keeps whichever form the
|
|
86
|
+
* platform holds, so adopting the filter changes nothing.
|
|
83
87
|
*/
|
|
84
88
|
export declare function recordField(field: FilterField, options?: {
|
|
85
89
|
readonly required?: boolean;
|
|
90
|
+
readonly includeOwner?: boolean;
|
|
86
91
|
}): Extract<FilterValue<FilterField, FilterReferenceValue>, {
|
|
87
92
|
type: "RECORD_FIELD";
|
|
88
93
|
}>;
|
|
@@ -105,11 +105,16 @@ export function fieldValue(value, options) {
|
|
|
105
105
|
* Compare against a field on the record being edited — a dynamic Dropdown
|
|
106
106
|
* filter such as "source Process Area equals this record's Process Area".
|
|
107
107
|
* `field` must belong to the Dropdown's own app or element.
|
|
108
|
+
*
|
|
109
|
+
* `includeOwner` stores the Dropdown's own app or element alongside the field,
|
|
110
|
+
* the form some existing filters were saved in. Pull keeps whichever form the
|
|
111
|
+
* platform holds, so adopting the filter changes nothing.
|
|
108
112
|
*/
|
|
109
113
|
export function recordField(field, options) {
|
|
110
114
|
return {
|
|
111
115
|
type: "RECORD_FIELD",
|
|
112
116
|
field: fieldWireValue(field),
|
|
117
|
+
...(options?.includeOwner === true && { includeOwner: true }),
|
|
113
118
|
...(options?.required !== undefined && { required: options.required }),
|
|
114
119
|
};
|
|
115
120
|
}
|
|
@@ -161,8 +161,13 @@ function printFilterValue(value, codec, call, quote) {
|
|
|
161
161
|
if (typeof value.field === "string")
|
|
162
162
|
return `${JSON.stringify(value)} as const`;
|
|
163
163
|
const { type: _type, field, required, ...rest } = value;
|
|
164
|
-
|
|
165
|
-
|
|
164
|
+
const { includeOwner, ...unhelped } = rest;
|
|
165
|
+
if (Object.keys(unhelped).length === 0) {
|
|
166
|
+
const options = [
|
|
167
|
+
...(required !== undefined ? [`required: ${required}`] : []),
|
|
168
|
+
...(includeOwner === true ? ["includeOwner: true"] : []),
|
|
169
|
+
];
|
|
170
|
+
return call("recordField", `${codec.field(field)}${options.length > 0 ? `, { ${options.join(", ")} }` : ""}`);
|
|
166
171
|
}
|
|
167
172
|
const extras = Object.entries({ ...rest, ...(required !== undefined && { required }) })
|
|
168
173
|
.map(([key, item]) => `${key}: ${JSON.stringify(item)}`);
|
|
@@ -98,6 +98,8 @@ export interface FilterToTfCodec {
|
|
|
98
98
|
readonly literal?: (value: TfValue, field: unknown | undefined, valueType: string, isOptionLabel: boolean) => TfValue;
|
|
99
99
|
/** A RECORD_FIELD value's source-record field; without it only raw platform ids encode. */
|
|
100
100
|
readonly recordField?: (value: unknown) => TfValue;
|
|
101
|
+
/** The owning app or element an `includeOwner` RECORD_FIELD value stores; without it such a value cannot encode. */
|
|
102
|
+
readonly recordFieldOwner?: () => TfValue;
|
|
101
103
|
readonly fieldFromLeftValue?: (value: unknown) => unknown | undefined;
|
|
102
104
|
/**
|
|
103
105
|
* Override the REFERENCE `real_type` that would otherwise default to TEXT.
|
|
@@ -124,6 +126,8 @@ export interface FilterFromTfCodec<Field = string, ReferenceValue = never> {
|
|
|
124
126
|
readonly literal?: (value: TfValue, valueType: string) => TfValue;
|
|
125
127
|
/** Decode a RECORD_FIELD value's source-record field reference; without it only raw platform ids decode. */
|
|
126
128
|
readonly recordField?: (value: TfValue) => Field;
|
|
129
|
+
/** Whether a RECORD_FIELD `object` reference names the owning app or element; without it only raw platform ids decode. */
|
|
130
|
+
readonly recordFieldOwner?: (value: TfValue) => boolean;
|
|
127
131
|
/**
|
|
128
132
|
* A TEXT-wrapped literal `literal` resolved from an option-id lookup is an
|
|
129
133
|
* option LABEL, not a stored word. Set this when the owner cannot rebuild a
|
|
@@ -147,6 +151,7 @@ export type WireFilterValue = Readonly<{
|
|
|
147
151
|
dynamicFieldAspect?: TfValue;
|
|
148
152
|
sourceFieldType?: string;
|
|
149
153
|
required?: boolean;
|
|
154
|
+
includeOwner?: boolean;
|
|
150
155
|
}>;
|
|
151
156
|
type WireFilterBase = Readonly<{
|
|
152
157
|
field?: TfValue;
|
|
@@ -207,15 +207,21 @@ function wireFilterValueToTf(value, field, codec, role = "value", operator) {
|
|
|
207
207
|
const authoredType = typeof authored === "string" ? authored : undefined;
|
|
208
208
|
// `filter.text()` and the other typed wrappers set `explicit`. That type
|
|
209
209
|
// is the comparison the author wrote. Metadata inference replaces only an
|
|
210
|
-
// unmarked operator fallback (dropdown `.id` TEXT → UUID).
|
|
210
|
+
// unmarked operator fallback (dropdown `.id` TEXT → UUID). An operator
|
|
211
|
+
// fallback of TEXT, and a trigger-field inference that agrees with the
|
|
212
|
+
// authored type, stay off the reference callback so a runAutomation left
|
|
213
|
+
// ref is not enveloped.
|
|
211
214
|
const explicit = raw.explicit === true;
|
|
212
215
|
const inferred = explicit ? authoredType : codec.referenceRealType?.(reference, role, authoredType);
|
|
213
216
|
const realType = String(inferred ?? authoredType ?? "TEXT");
|
|
217
|
+
const inferenceDisagrees = inferred !== undefined
|
|
218
|
+
&& inferred.toUpperCase() !== (authoredType ?? "").toUpperCase();
|
|
219
|
+
const referenceRealType = explicit ? realType : inferenceDisagrees ? inferred : undefined;
|
|
214
220
|
// ei export always writes an explicit `multiple = false` on scalar text
|
|
215
221
|
// references. Omitting it plans null-vs-false drift after pull.
|
|
216
222
|
return {
|
|
217
223
|
type,
|
|
218
|
-
value_reference: codec.reference(reference, role,
|
|
224
|
+
value_reference: codec.reference(reference, role, referenceRealType, operator),
|
|
219
225
|
real_type: realType.toLowerCase(),
|
|
220
226
|
multiple: typeof raw.multiple === "boolean" ? raw.multiple : false,
|
|
221
227
|
};
|
|
@@ -237,7 +243,14 @@ function wireFilterValueToTf(value, field, codec, role = "value", operator) {
|
|
|
237
243
|
if (type === "record_field") {
|
|
238
244
|
if (raw.field === undefined)
|
|
239
245
|
throw new EntityTfError("record_field filter value requires field");
|
|
240
|
-
|
|
246
|
+
let object = (raw.aspect ?? raw.object);
|
|
247
|
+
if (raw.includeOwner === true) {
|
|
248
|
+
if (object !== undefined)
|
|
249
|
+
throw new EntityTfError("record_field filter value cannot set includeOwner and also name a raw app id");
|
|
250
|
+
if (codec.recordFieldOwner === undefined)
|
|
251
|
+
throw new EntityTfError("a record_field filter value with includeOwner needs an owning app or element in this filter context");
|
|
252
|
+
object = codec.recordFieldOwner();
|
|
253
|
+
}
|
|
241
254
|
const sourceFieldType = raw.sourceFieldType ?? raw.source_field_type;
|
|
242
255
|
let field;
|
|
243
256
|
if (codec.recordField !== undefined)
|
|
@@ -249,7 +262,7 @@ function wireFilterValueToTf(value, field, codec, role = "value", operator) {
|
|
|
249
262
|
return {
|
|
250
263
|
type,
|
|
251
264
|
field,
|
|
252
|
-
...(
|
|
265
|
+
...(object !== undefined && { object }),
|
|
253
266
|
...(sourceFieldType !== undefined && { source_field_type: String(sourceFieldType).toLowerCase() }),
|
|
254
267
|
...((raw.dynamicField ?? raw.dynamic_field) !== undefined && { dynamic_field: (raw.dynamicField ?? raw.dynamic_field) }),
|
|
255
268
|
...((raw.dynamicFieldAspect ?? raw.dynamic_field_object) !== undefined && { dynamic_field_object: (raw.dynamicFieldAspect ?? raw.dynamic_field_object) }),
|
|
@@ -578,8 +591,30 @@ function filterValueFromTf(value, codec, fieldScope) {
|
|
|
578
591
|
case "record_field": {
|
|
579
592
|
if (value.field === undefined)
|
|
580
593
|
throw new EntityTfError("record_field filter value requires field");
|
|
581
|
-
if (
|
|
582
|
-
throw new EntityTfError("record_field filter value
|
|
594
|
+
if (value.source_field_type !== undefined && typeof value.source_field_type !== "string") {
|
|
595
|
+
throw new EntityTfError("record_field filter value source_field_type must be a literal string");
|
|
596
|
+
}
|
|
597
|
+
// The exporter resolves the platform's dynamicField / dynamicFieldAspect
|
|
598
|
+
// to references (e.g. `data.elementum_app.parent.id`). No typed public
|
|
599
|
+
// value rebuilds them yet, so refuse rather than keep the rest of the
|
|
600
|
+
// value and let a rebuild silently omit them. RECORD_FIELD values only
|
|
601
|
+
// occur in dynamic Dropdown filters.
|
|
602
|
+
for (const key of ["dynamic_field", "dynamic_field_object"]) {
|
|
603
|
+
if (value[key] !== undefined && typeof value[key] !== "string") {
|
|
604
|
+
throw new EntityTfError(`record_field filter value ${key} reference cannot be reconstructed: the EDK cannot yet represent a dynamic-field comparison in a Dropdown filter`);
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
// A literal id stays as stored; a reference must name the owning app or
|
|
608
|
+
// element, which the owner context rebuilds, so only the fact survives.
|
|
609
|
+
let owner;
|
|
610
|
+
if (typeof value.object === "string")
|
|
611
|
+
owner = { aspect: value.object };
|
|
612
|
+
else if (value.object !== undefined) {
|
|
613
|
+
if (codec.recordFieldOwner === undefined)
|
|
614
|
+
throw new EntityTfError("record_field filter value object reference cannot be reconstructed in this filter context");
|
|
615
|
+
if (!codec.recordFieldOwner(value.object))
|
|
616
|
+
throw new EntityTfError("record_field filter value object must name the owning app or element");
|
|
617
|
+
owner = { includeOwner: true };
|
|
583
618
|
}
|
|
584
619
|
let field;
|
|
585
620
|
if (typeof value.field === "string")
|
|
@@ -591,7 +626,7 @@ function filterValueFromTf(value, codec, fieldScope) {
|
|
|
591
626
|
return {
|
|
592
627
|
type: "RECORD_FIELD",
|
|
593
628
|
field,
|
|
594
|
-
...
|
|
629
|
+
...owner,
|
|
595
630
|
...(value.source_field_type !== undefined && { sourceFieldType: value.source_field_type.toUpperCase() }),
|
|
596
631
|
...(typeof value.dynamic_field === "string" && { dynamicField: value.dynamic_field }),
|
|
597
632
|
...(typeof value.dynamic_field_object === "string" && { dynamicFieldAspect: value.dynamic_field_object }),
|
|
@@ -69,15 +69,20 @@ export type FilterValue<FieldValue = string, ReferenceValue = FilterReference> =
|
|
|
69
69
|
} | {
|
|
70
70
|
type: "CURRENT_USER";
|
|
71
71
|
valueType?: "ID" | "EMAIL" | "DOMAIN";
|
|
72
|
-
} | {
|
|
72
|
+
} | ({
|
|
73
73
|
type: "RECORD_FIELD";
|
|
74
74
|
field: FieldValue | string;
|
|
75
|
-
aspect?: string;
|
|
76
75
|
sourceFieldType?: string;
|
|
77
76
|
dynamicField?: string;
|
|
78
77
|
dynamicFieldAspect?: string;
|
|
79
78
|
required?: boolean;
|
|
80
|
-
}
|
|
79
|
+
} & ({
|
|
80
|
+
aspect?: string;
|
|
81
|
+
includeOwner?: never;
|
|
82
|
+
} | {
|
|
83
|
+
includeOwner: true;
|
|
84
|
+
aspect?: never;
|
|
85
|
+
}))
|
|
81
86
|
/**
|
|
82
87
|
* `explicit` is set by `filter.text()` / `filter.uuid()` / the other typed
|
|
83
88
|
* wrappers, and by an explicit comparison type. Build keeps that type.
|
|
@@ -118,16 +118,14 @@ export type ValidateTemplateArgs<Args extends readonly unknown[]> = Args extends
|
|
|
118
118
|
*/
|
|
119
119
|
export declare function template<const Args extends readonly (string | Ref<unknown>)[]>(...parts: Args & ValidateTemplateArgs<Args>): Ref<string>;
|
|
120
120
|
/**
|
|
121
|
-
* Reference
|
|
122
|
-
*
|
|
123
|
-
* plaintext.
|
|
121
|
+
* Reference an existing Elementum vault entry by key. The platform resolves
|
|
122
|
+
* its value only when the automation runs; EDK never reads or stores it.
|
|
124
123
|
*
|
|
125
124
|
* @example
|
|
126
125
|
* ```ts
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
* authorization: { type: "bearer", token: secret("payments-provider-token") },
|
|
126
|
+
* .executeScript("Call API", {
|
|
127
|
+
* inputs: { baseUrl: secret("ELEMENTUM_BASE_URL") },
|
|
128
|
+
* code: (input) => ({ url: input.parameters.baseUrl }),
|
|
131
129
|
* })
|
|
132
130
|
* ```
|
|
133
131
|
*/
|
|
@@ -50,16 +50,14 @@ export function template(...parts) {
|
|
|
50
50
|
return createRef({ kind: "template", parts: data });
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
|
-
* Reference
|
|
54
|
-
*
|
|
55
|
-
* plaintext.
|
|
53
|
+
* Reference an existing Elementum vault entry by key. The platform resolves
|
|
54
|
+
* its value only when the automation runs; EDK never reads or stores it.
|
|
56
55
|
*
|
|
57
56
|
* @example
|
|
58
57
|
* ```ts
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* authorization: { type: "bearer", token: secret("payments-provider-token") },
|
|
58
|
+
* .executeScript("Call API", {
|
|
59
|
+
* inputs: { baseUrl: secret("ELEMENTUM_BASE_URL") },
|
|
60
|
+
* code: (input) => ({ url: input.parameters.baseUrl }),
|
|
63
61
|
* })
|
|
64
62
|
* ```
|
|
65
63
|
*/
|
|
@@ -17,3 +17,12 @@
|
|
|
17
17
|
import type { FromTfContext } from "../../engine/pull/context.js";
|
|
18
18
|
import { type ChildResourceScope, type TfValue } from "../../engine/tf/index.js";
|
|
19
19
|
export declare function resolveToolFieldKey(fieldRef: TfValue | undefined, scopeTfLabel: string, scope?: ChildResourceScope | "task", ctx?: Pick<FromTfContext, "dataAttrs" | "foreignFieldRefsByDataAddress">): string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* When `fieldRef` is a field resource whose scoped label names a different
|
|
22
|
+
* owner than the tool's resolved target, return that owner as
|
|
23
|
+
* `<scope> "<label>"` for diagnostics. Unscoped labels can't be attributed
|
|
24
|
+
* and return undefined.
|
|
25
|
+
*/
|
|
26
|
+
export declare function toolFieldRefOtherOwner(fieldRef: TfValue | undefined, scopeTfLabel: string, scope?: ChildResourceScope | "task"): string | undefined;
|
|
27
|
+
/** Diagnostic for a tool fields item whose field_id could not be kept. */
|
|
28
|
+
export declare function droppedToolFieldDiagnostic(where: string, fieldRef: TfValue | undefined, scopeTfLabel: string, scope?: ChildResourceScope | "task"): string;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import { isTfExpr, scopedLabelToBagKey, tfLabelToTsLabel } from "../../engine/tf/index.js";
|
|
1
|
+
import { isTfExpr, ownerFromScopedChildLabel, scopedLabelToBagKey, tfLabelToTsLabel } from "../../engine/tf/index.js";
|
|
2
2
|
import { SUB_TYPE_BY_RESOURCE as FIELD_SUB_TYPE_BY_RESOURCE } from "../field/types.js";
|
|
3
3
|
export function resolveToolFieldKey(fieldRef, scopeTfLabel, scope = "app", ctx) {
|
|
4
4
|
if (fieldRef === undefined)
|
|
5
5
|
return undefined;
|
|
6
6
|
if (isTfExpr(fieldRef) && fieldRef.$expr === "resource-attr" && FIELD_SUB_TYPE_BY_RESOURCE.has(fieldRef.type)) {
|
|
7
|
-
|
|
7
|
+
// A field resource owned by a different app/element must not be renamed
|
|
8
|
+
// into a key on this tool's target (edk#1403 review S1).
|
|
9
|
+
if (toolFieldRefOtherOwner(fieldRef, scopeTfLabel, scope) !== undefined)
|
|
10
|
+
return undefined;
|
|
11
|
+
return scopedLabelToBagKey(scopeTfLabel, fieldRef.label, scope);
|
|
8
12
|
}
|
|
9
13
|
if (isTfExpr(fieldRef) && fieldRef.$expr === "data-attr" && fieldRef.type === "elementum_field") {
|
|
10
14
|
const fieldAttrs = ctx?.dataAttrs?.("elementum_field", fieldRef.label);
|
|
@@ -40,3 +44,32 @@ export function resolveToolFieldKey(fieldRef, scopeTfLabel, scope = "app", ctx)
|
|
|
40
44
|
}
|
|
41
45
|
return undefined;
|
|
42
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* When `fieldRef` is a field resource whose scoped label names a different
|
|
49
|
+
* owner than the tool's resolved target, return that owner as
|
|
50
|
+
* `<scope> "<label>"` for diagnostics. Unscoped labels can't be attributed
|
|
51
|
+
* and return undefined.
|
|
52
|
+
*/
|
|
53
|
+
export function toolFieldRefOtherOwner(fieldRef, scopeTfLabel, scope = "app") {
|
|
54
|
+
if (fieldRef === undefined || !isTfExpr(fieldRef) || fieldRef.$expr !== "resource-attr")
|
|
55
|
+
return undefined;
|
|
56
|
+
if (!FIELD_SUB_TYPE_BY_RESOURCE.has(fieldRef.type))
|
|
57
|
+
return undefined;
|
|
58
|
+
const owner = ownerFromScopedChildLabel(fieldRef.label);
|
|
59
|
+
if (owner === undefined)
|
|
60
|
+
return undefined;
|
|
61
|
+
if (owner.scope === scope && owner.ownerTfLabel === scopeTfLabel)
|
|
62
|
+
return undefined;
|
|
63
|
+
return `${owner.scope} "${owner.ownerTfLabel}"`;
|
|
64
|
+
}
|
|
65
|
+
/** Diagnostic for a tool fields item whose field_id could not be kept. */
|
|
66
|
+
export function droppedToolFieldDiagnostic(where, fieldRef, scopeTfLabel, scope = "app") {
|
|
67
|
+
if (fieldRef === undefined || fieldRef === "")
|
|
68
|
+
return `${where}: fields item has no field_id; dropped`;
|
|
69
|
+
const other = toolFieldRefOtherOwner(fieldRef, scopeTfLabel, scope);
|
|
70
|
+
if (other !== undefined && isTfExpr(fieldRef) && fieldRef.$expr === "resource-attr") {
|
|
71
|
+
return `${where}: fields item's field_id references ${fieldRef.type}.${fieldRef.label}, a field of ${other}, ` +
|
|
72
|
+
`not of this tool's target "${scopeTfLabel}"; dropped - set this field on the tool by hand`;
|
|
73
|
+
}
|
|
74
|
+
return `${where}: fields item's field_id is not a field resource reference; dropped`;
|
|
75
|
+
}
|
|
@@ -56,6 +56,16 @@ export declare function isOnDemandRecordType(type: string | undefined): boolean;
|
|
|
56
56
|
* clicking user with `runAutomationParameterValue.triggeredByUser`.
|
|
57
57
|
*/
|
|
58
58
|
export type TriggerFieldTypeAlias = Exclude<FieldTypeAlias, "user">;
|
|
59
|
+
/**
|
|
60
|
+
* Subset of {@link TriggerFieldTypeAlias} that an `onDemand` input may
|
|
61
|
+
* declare. Mirrors the provider's `elementum_on_demand_trigger`
|
|
62
|
+
* `parameters[].type` enum (text, number, decimal, boolean, date, datetime,
|
|
63
|
+
* user, group, attachment, record): `json` and `object` have no provider
|
|
64
|
+
* spelling, so OpenTofu rejects the generated config at plan time (#1415).
|
|
65
|
+
*/
|
|
66
|
+
export type OnDemandParamTypeAlias = Exclude<TriggerFieldTypeAlias, "json" | "object">;
|
|
67
|
+
/** Runtime list of {@link OnDemandParamTypeAlias} values. */
|
|
68
|
+
export declare const ON_DEMAND_PARAM_TYPES: readonly ["text", "number", "decimal", "boolean", "date", "datetime", "userId", "attachmentId", "record"];
|
|
59
69
|
/**
|
|
60
70
|
* Maps a user-friendly FieldTypeAlias to the TypeScript type it represents.
|
|
61
71
|
* Used to derive the phantom T in Ref<T> for trigger inputs.
|
|
@@ -32,6 +32,10 @@ export const FIELD_TYPE_MAP = {
|
|
|
32
32
|
export function isOnDemandRecordType(type) {
|
|
33
33
|
return type === "record" || type === "ASPECT_RECORD";
|
|
34
34
|
}
|
|
35
|
+
/** Runtime list of {@link OnDemandParamTypeAlias} values. */
|
|
36
|
+
export const ON_DEMAND_PARAM_TYPES = [
|
|
37
|
+
"text", "number", "decimal", "boolean", "date", "datetime", "userId", "attachmentId", "record",
|
|
38
|
+
];
|
|
35
39
|
/**
|
|
36
40
|
* Maps a user-friendly FieldTypeAlias to the TypeScript type it represents.
|
|
37
41
|
* Used to derive the phantom T in Ref<T> for trigger inputs.
|