@elementumai/edk 0.10.4 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -13
- package/dist-sdk/src/catalog/token.js +2 -1
- package/dist-sdk/src/core/triggers/on-demand.d.ts +2 -0
- package/dist-sdk/src/core/triggers/on-demand.js +3 -0
- package/dist-sdk/src/core/wire/ref-serializer.js +26 -1
- package/dist-sdk/src/engine/build/context.d.ts +4 -0
- package/dist-sdk/src/engine/coverage-gaps.d.ts +7 -0
- package/dist-sdk/src/engine/coverage-gaps.js +12 -0
- package/dist-sdk/src/engine/ei/json-stream-reader.d.ts +43 -0
- package/dist-sdk/src/engine/ei/json-stream-reader.js +234 -0
- package/dist-sdk/src/engine/ei/run.d.ts +42 -1
- package/dist-sdk/src/engine/ei/run.js +201 -32
- package/dist-sdk/src/engine/ei/saved-plan.d.ts +16 -0
- package/dist-sdk/src/engine/ei/saved-plan.js +19 -0
- package/dist-sdk/src/engine/ei/state.d.ts +1 -1
- package/dist-sdk/src/engine/ei/state.js +17 -4
- package/dist-sdk/src/engine/progress.d.ts +3 -1
- package/dist-sdk/src/engine/progress.js +7 -3
- package/dist-sdk/src/engine/pull/authored-address.d.ts +15 -1
- package/dist-sdk/src/engine/pull/authored-address.js +180 -29
- package/dist-sdk/src/engine/pull/context.d.ts +37 -2
- package/dist-sdk/src/engine/pull/context.js +7 -4
- package/dist-sdk/src/engine/pull/ref-only.d.ts +18 -0
- package/dist-sdk/src/engine/pull/ref-only.js +52 -0
- package/dist-sdk/src/engine/tf/index.d.ts +2 -2
- package/dist-sdk/src/engine/tf/index.js +2 -2
- package/dist-sdk/src/engine/tf/labels.d.ts +22 -0
- package/dist-sdk/src/engine/tf/labels.js +50 -0
- package/dist-sdk/src/engine/tf/model.d.ts +2 -0
- package/dist-sdk/src/engine/tf/model.js +26 -0
- package/dist-sdk/src/engine/validation.d.ts +2 -0
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +18 -0
- package/dist-sdk/src/entities/access-policy/from-tf.js +58 -24
- package/dist-sdk/src/entities/access-policy/member-list.d.ts +32 -0
- package/dist-sdk/src/entities/access-policy/member-list.js +57 -0
- package/dist-sdk/src/entities/access-policy/module.js +10 -0
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +4 -3
- package/dist-sdk/src/entities/access-policy/to-tf.js +21 -12
- package/dist-sdk/src/entities/agent/build.js +7 -5
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +2 -0
- package/dist-sdk/src/entities/agent/from-tf.js +13 -3
- package/dist-sdk/src/entities/agent/to-tf.js +11 -5
- package/dist-sdk/src/entities/agent/tools.d.ts +8 -0
- package/dist-sdk/src/entities/agent/tools.js +6 -2
- package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +29 -0
- package/dist-sdk/src/entities/agent-tool/to-tf.js +56 -3
- package/dist-sdk/src/entities/agent-tool/types.d.ts +12 -8
- package/dist-sdk/src/entities/agent-tool/types.js +13 -9
- package/dist-sdk/src/entities/app/build.d.ts +12 -1
- package/dist-sdk/src/entities/app/build.js +80 -4
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +5 -7
- package/dist-sdk/src/entities/app/from-tf.js +17 -12
- package/dist-sdk/src/entities/app/stage-keys.d.ts +18 -3
- package/dist-sdk/src/entities/app/stage-keys.js +40 -6
- package/dist-sdk/src/entities/app/to-tf.js +7 -4
- package/dist-sdk/src/entities/automation/build.d.ts +52 -31
- package/dist-sdk/src/entities/automation/build.js +59 -20
- package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +7 -4
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +39 -14
- package/dist-sdk/src/entities/automation/from-tf.d.ts +35 -2
- package/dist-sdk/src/entities/automation/from-tf.js +721 -93
- package/dist-sdk/src/entities/automation/index.d.ts +1 -1
- package/dist-sdk/src/entities/automation/module.d.ts +22 -2
- package/dist-sdk/src/entities/automation/module.js +244 -57
- package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +22 -2
- package/dist-sdk/src/entities/automation/output-key-wire-name.js +54 -3
- package/dist-sdk/src/entities/automation/run-target.d.ts +61 -0
- package/dist-sdk/src/entities/automation/run-target.js +104 -0
- package/dist-sdk/src/entities/automation/script-code.d.ts +11 -1
- package/dist-sdk/src/entities/automation/script-code.js +106 -4
- package/dist-sdk/src/entities/automation/script-lint.d.ts +13 -0
- package/dist-sdk/src/entities/automation/script-lint.js +418 -0
- package/dist-sdk/src/entities/automation/task-output-labels.d.ts +17 -1
- package/dist-sdk/src/entities/automation/task-output-labels.js +58 -1
- package/dist-sdk/src/entities/automation/tasks.d.ts +67 -22
- package/dist-sdk/src/entities/automation/tasks.js +18 -4
- package/dist-sdk/src/entities/automation/to-tf.d.ts +1 -3
- package/dist-sdk/src/entities/automation/to-tf.js +354 -64
- package/dist-sdk/src/entities/automation/triggers.d.ts +63 -11
- package/dist-sdk/src/entities/automation/triggers.js +45 -5
- package/dist-sdk/src/entities/automation/types.d.ts +21 -0
- package/dist-sdk/src/entities/automation/types.js +26 -0
- package/dist-sdk/src/entities/chart/build.d.ts +9 -1
- package/dist-sdk/src/entities/chart/from-tf.d.ts +2 -2
- package/dist-sdk/src/entities/chart/from-tf.js +25 -1
- package/dist-sdk/src/entities/chart/index.d.ts +1 -1
- package/dist-sdk/src/entities/chart/printer.js +5 -2
- package/dist-sdk/src/entities/chart/to-tf.js +19 -1
- package/dist-sdk/src/entities/dashboard/from-tf.d.ts +11 -1
- package/dist-sdk/src/entities/dashboard/from-tf.js +57 -7
- package/dist-sdk/src/entities/dashboard/to-tf.js +13 -0
- package/dist-sdk/src/entities/dynamic-layout/build.d.ts +8 -2
- package/dist-sdk/src/entities/dynamic-layout/condition-keys.d.ts +48 -0
- package/dist-sdk/src/entities/dynamic-layout/condition-keys.js +261 -0
- package/dist-sdk/src/entities/dynamic-layout/from-tf.d.ts +3 -0
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +66 -20
- package/dist-sdk/src/entities/dynamic-layout/module.js +2 -1
- package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +4 -2
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +341 -32
- package/dist-sdk/src/entities/element/build.d.ts +10 -0
- package/dist-sdk/src/entities/element/build.js +1 -0
- package/dist-sdk/src/entities/element/from-tf.js +14 -9
- package/dist-sdk/src/entities/element/to-tf.js +7 -4
- package/dist-sdk/src/entities/field/from-tf.d.ts +24 -0
- package/dist-sdk/src/entities/field/from-tf.js +79 -1
- package/dist-sdk/src/entities/field/module.js +14 -1
- package/dist-sdk/src/entities/field/to-tf.d.ts +38 -3
- package/dist-sdk/src/entities/field/to-tf.js +108 -34
- package/dist-sdk/src/entities/file-reader/module.js +3 -3
- package/dist-sdk/src/entities/file-reader/to-tf.js +3 -3
- package/dist-sdk/src/entities/file-reader/types.d.ts +4 -16
- package/dist-sdk/src/entities/file-reader/types.js +7 -0
- package/dist-sdk/src/entities/org/group.d.ts +1 -0
- package/dist-sdk/src/entities/org/group.js +2 -1
- package/dist-sdk/src/entities/org/role.js +5 -0
- package/dist-sdk/src/entities/record-create-form/from-tf.d.ts +8 -0
- package/dist-sdk/src/entities/record-create-form/from-tf.js +10 -2
- package/dist-sdk/src/entities/record-create-form/to-tf.d.ts +2 -1
- package/dist-sdk/src/entities/record-create-form/to-tf.js +14 -2
- package/dist-sdk/src/entities/relationship/from-tf.d.ts +8 -0
- package/dist-sdk/src/entities/relationship/from-tf.js +88 -10
- package/dist-sdk/src/entities/relationship/to-tf.d.ts +3 -2
- package/dist-sdk/src/entities/relationship/to-tf.js +79 -8
- package/dist-sdk/src/entities/role/from-tf.js +24 -7
- package/dist-sdk/src/entities/role/to-tf.js +25 -7
- package/dist-sdk/src/entities/service-account/from-tf.js +2 -1
- package/dist-sdk/src/entities/service-account/module.js +20 -0
- package/dist-sdk/src/entities/service-account/role-fidelity.d.ts +5 -5
- package/dist-sdk/src/entities/service-account/role-fidelity.js +21 -13
- package/dist-sdk/src/entities/service-account/to-tf.js +12 -4
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +2 -0
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +1 -1
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +12 -7
- package/dist-sdk/src/entities/shared/types/field-types.d.ts +6 -3
- package/dist-sdk/src/entities/shared/types/field-types.js +3 -1
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +5 -2
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +8 -1
- package/dist-sdk/src/entities/skill/from-tf.js +10 -3
- package/dist-sdk/src/entities/skill/module.js +18 -0
- package/dist-sdk/src/entities/skill/to-tf.d.ts +8 -1
- package/dist-sdk/src/entities/skill/to-tf.js +23 -14
- package/dist-sdk/src/entities/skill/tools.d.ts +8 -0
- package/dist-sdk/src/entities/skill/tools.js +6 -2
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +8 -0
- package/dist-sdk/src/entities/skill-tool/to-tf.js +6 -2
- package/dist-sdk/src/entities/task/to-tf.js +1 -0
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +8 -2
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +20 -10
- package/dist-sdk/src/entities/view/from-tf.d.ts +68 -4
- package/dist-sdk/src/entities/view/from-tf.js +394 -22
- package/dist-sdk/src/entities/view/module.js +20 -0
- package/dist-sdk/src/entities/view/portable.d.ts +11 -0
- package/dist-sdk/src/entities/view/portable.js +47 -0
- package/dist-sdk/src/entities/view/to-tf.d.ts +4 -1
- package/dist-sdk/src/entities/view/to-tf.js +25 -7
- package/dist-sdk/src/entities/view/types.js +1 -1
- package/dist-sdk/src/entities/widget/build.d.ts +4 -3
- package/dist-sdk/src/entities/widget/from-tf.d.ts +3 -0
- package/dist-sdk/src/entities/widget/from-tf.js +100 -3
- package/dist-sdk/src/entities/widget/to-tf.d.ts +16 -1
- package/dist-sdk/src/entities/widget/to-tf.js +77 -14
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +30 -9
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
- package/dist-sdk/src/graph/field-resource-types.d.ts +2 -0
- package/dist-sdk/src/graph/field-resource-types.js +11 -0
- package/dist-sdk/src/graph/index.d.ts +41 -3
- package/dist-sdk/src/graph/index.js +24 -2
- package/dist-sdk/src/graph/types.d.ts +195 -5
- package/package.json +1 -1
|
@@ -13,8 +13,9 @@
|
|
|
13
13
|
* `data.elementum_field` lookup when the typed target is foreign.
|
|
14
14
|
*/
|
|
15
15
|
import { workspaceAspectKey } from "../../engine/build/context.js";
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
16
|
+
import { EntityTfError } from "../../engine/entity.js";
|
|
17
|
+
import { automationRunTargetResourceAttr } from "../automation/run-target.js";
|
|
18
|
+
import { appScopedResourceLabel, collisionLabelSuffixes, expr, sanitizeName, scopedResourceLabel, stableIdSuffix, tsLabelToTfLabel } from "../../engine/tf/index.js";
|
|
18
19
|
import { authoredFieldKeysFromPayload, fieldRefToTfValue, } from "../field/to-tf.js";
|
|
19
20
|
import { foreignFieldDataLabel } from "../shared/foreign-ref.js";
|
|
20
21
|
import { encodeOptionalHandleDescription } from "../shared/handle-description.js";
|
|
@@ -164,6 +165,58 @@ function fieldRefValue(token, where, ctx, target) {
|
|
|
164
165
|
}
|
|
165
166
|
return value;
|
|
166
167
|
}
|
|
168
|
+
/** An agent tool's bare label: `sanitizeName(<agent>_<tool name>)` plus its collision suffix. */
|
|
169
|
+
export function agentToolBareLabel(agentBareTfLabel, toolName, labelSuffix) {
|
|
170
|
+
return `${sanitizeName(`${agentBareTfLabel}_${toolName}`)}${labelSuffix}`;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* `_N` suffixes, by tool index, for one agent's tools whose labels collide
|
|
174
|
+
* (`a-b` and `a_b` both sanitize to `a_b`), with one counter across tool
|
|
175
|
+
* kinds as in ei's export (`GenerateImportBlocks`, `toolNames` in
|
|
176
|
+
* imports.go). A tool with `labelSuffix` keeps that `_N`; the others take the
|
|
177
|
+
* lowest free count in tool order (`collisionLabelSuffixes`), so an unpinned
|
|
178
|
+
* tool's order is part of its address. Pull pins every tool ei suffixed
|
|
179
|
+
* (agentFromTf), so a pulled agent rebuilds its exported labels even when ei
|
|
180
|
+
* counted a tool pull doesn't print. Every known tool kind counts, implemented
|
|
181
|
+
* or not, as in ei. Parity holds within one agent only: ei's counter spans
|
|
182
|
+
* the whole app and is keyed on the agent's display name (edk#2000).
|
|
183
|
+
*/
|
|
184
|
+
export function agentToolLabelSuffixes(agentBareTfLabel, tools) {
|
|
185
|
+
return collisionLabelSuffixes(tools.map((entry) => {
|
|
186
|
+
const typeKey = Object.keys(entry)[0];
|
|
187
|
+
if (typeKey === undefined || !TOOL_SUB_TYPE_BY_TYPE_KEY.has(typeKey))
|
|
188
|
+
return undefined;
|
|
189
|
+
const inner = entry[typeKey];
|
|
190
|
+
return {
|
|
191
|
+
base: sanitizeName(`${agentBareTfLabel}_${inner?.name ?? ""}`),
|
|
192
|
+
...(inner?.labelSuffix !== undefined && { pinned: inner.labelSuffix }),
|
|
193
|
+
};
|
|
194
|
+
}));
|
|
195
|
+
}
|
|
196
|
+
/** A tool entry's (`{ createRecord: { name, ... } }`) platform name, or "". */
|
|
197
|
+
export function toolName(entry) {
|
|
198
|
+
const typeKey = Object.keys(entry)[0];
|
|
199
|
+
const inner = typeKey === undefined ? undefined : entry[typeKey];
|
|
200
|
+
return typeof inner?.name === "string" ? inner.name : "";
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Fail the build when two of one owner's tools land on one resource address
|
|
204
|
+
* (`a-b`, `a_b` and `a_b_1` of one kind: the second gets `_1`, the third is
|
|
205
|
+
* `a_b_1` already). OpenTofu would reject the duplicate only at plan, so name
|
|
206
|
+
* both tools here instead (edk#1987).
|
|
207
|
+
*/
|
|
208
|
+
export function assertUniqueToolAddresses(owner, tools) {
|
|
209
|
+
const seen = new Map();
|
|
210
|
+
for (const tool of tools) {
|
|
211
|
+
const other = seen.get(tool.address);
|
|
212
|
+
if (other !== undefined) {
|
|
213
|
+
throw new EntityTfError(`${owner}: tools ${JSON.stringify(other)} and ${JSON.stringify(tool.name)} both get the address ${tool.address} ` +
|
|
214
|
+
`(names that differ only in hyphens, underscores or case share a label; a colliding tool's _N comes from its labelSuffix or, without one, its tool order). ` +
|
|
215
|
+
`Rename one of them.`);
|
|
216
|
+
}
|
|
217
|
+
seen.set(tool.address, tool.name);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
167
220
|
/**
|
|
168
221
|
* One authored tool entry (`{ createRecord: {...} }`) → its resource block;
|
|
169
222
|
* undefined = degraded with a diagnostic (unimplemented sub-type, missing
|
|
@@ -191,7 +244,7 @@ export function toolToTf(entry, ctx) {
|
|
|
191
244
|
}
|
|
192
245
|
const where = `agent tool "${name}"`;
|
|
193
246
|
const agentTfLabel = appScopedResourceLabel(ctx.appTfLabel, ctx.agentBareTfLabel);
|
|
194
|
-
const tfLabel = appScopedResourceLabel(ctx.appTfLabel,
|
|
247
|
+
const tfLabel = appScopedResourceLabel(ctx.appTfLabel, agentToolBareLabel(ctx.agentBareTfLabel, name, ctx.labelSuffix ?? ""));
|
|
195
248
|
const attrs = {
|
|
196
249
|
agent_id: expr.resourceAttr("elementum_agent", agentTfLabel, ["id"]),
|
|
197
250
|
app_id: expr.resourceAttr("elementum_app", ctx.appTfLabel, ["id"]),
|
|
@@ -28,14 +28,18 @@ export declare const IMPLEMENTED_TOOL_RESOURCE_TYPES: readonly string[];
|
|
|
28
28
|
export declare const ALL_TOOL_RESOURCE_TYPES: readonly string[];
|
|
29
29
|
/**
|
|
30
30
|
* EDK's tool-name rule — enforced in the authoring builders (see
|
|
31
|
-
* `entities/agent/tools.ts`), never in the tf
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* the
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
31
|
+
* `entities/agent/tools.ts` and `entities/skill/tools.ts`), never in the tf
|
|
32
|
+
* passes. It is the platform's own rule: 1–64 chars of letters, digits,
|
|
33
|
+
* underscores, and hyphens (`[A-Za-z0-9_-]`); no spaces; no consecutive
|
|
34
|
+
* underscores (the platform rejects those, opaquely). Hyphens are allowed
|
|
35
|
+
* because the platform mints them itself — its skill generator names a lookup
|
|
36
|
+
* tool `resolve_<label>` cut to 55 chars plus `-<8 hex>` — and pull prints the
|
|
37
|
+
* live name verbatim, so a stricter rule makes a pulled file fail to load
|
|
38
|
+
* (edk#1987). The name is sent to the platform verbatim; the terraform label is
|
|
39
|
+
* `sanitizeName(name)` (hyphens become underscores, the same as ei's export
|
|
40
|
+
* `SanitizeName`), and names that sanitize to one label get `_N` suffixes from
|
|
41
|
+
* a pinned `labelSuffix` or tool order (`computeToolLabelSuffixes`,
|
|
42
|
+
* `agentToolLabelSuffixes`).
|
|
39
43
|
*/
|
|
40
44
|
export declare function isValidToolName(name: string): boolean;
|
|
41
45
|
export declare const KNOWN_TOOL_ATTRS: Readonly<Record<string, ReadonlySet<string>>>;
|
|
@@ -29,17 +29,21 @@ export const IMPLEMENTED_TOOL_RESOURCE_TYPES = AGENT_TOOL_SUB_TYPES.filter((t) =
|
|
|
29
29
|
export const ALL_TOOL_RESOURCE_TYPES = AGENT_TOOL_SUB_TYPES.map((t) => t.resourceType);
|
|
30
30
|
/**
|
|
31
31
|
* EDK's tool-name rule — enforced in the authoring builders (see
|
|
32
|
-
* `entities/agent/tools.ts`), never in the tf
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* the
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
32
|
+
* `entities/agent/tools.ts` and `entities/skill/tools.ts`), never in the tf
|
|
33
|
+
* passes. It is the platform's own rule: 1–64 chars of letters, digits,
|
|
34
|
+
* underscores, and hyphens (`[A-Za-z0-9_-]`); no spaces; no consecutive
|
|
35
|
+
* underscores (the platform rejects those, opaquely). Hyphens are allowed
|
|
36
|
+
* because the platform mints them itself — its skill generator names a lookup
|
|
37
|
+
* tool `resolve_<label>` cut to 55 chars plus `-<8 hex>` — and pull prints the
|
|
38
|
+
* live name verbatim, so a stricter rule makes a pulled file fail to load
|
|
39
|
+
* (edk#1987). The name is sent to the platform verbatim; the terraform label is
|
|
40
|
+
* `sanitizeName(name)` (hyphens become underscores, the same as ei's export
|
|
41
|
+
* `SanitizeName`), and names that sanitize to one label get `_N` suffixes from
|
|
42
|
+
* a pinned `labelSuffix` or tool order (`computeToolLabelSuffixes`,
|
|
43
|
+
* `agentToolLabelSuffixes`).
|
|
40
44
|
*/
|
|
41
45
|
export function isValidToolName(name) {
|
|
42
|
-
return /^[A-Za-z0-9_]{1,64}$/.test(name) && !name.includes("__");
|
|
46
|
+
return /^[A-Za-z0-9_-]{1,64}$/.test(name) && !name.includes("__");
|
|
43
47
|
}
|
|
44
48
|
/** Attributes `toolFromTf` understands per implemented sub-type — growth is reported loudly. */
|
|
45
49
|
const COMMON_TOOL_ATTRS = ["agent_id", "app_id", "name", "description", "start_message", "run_as", "service_account_id"];
|
|
@@ -32,7 +32,7 @@ import type { AppServiceAccount } from "../service-account/build.js";
|
|
|
32
32
|
import type { Filter } from "../shared/filters/types.js";
|
|
33
33
|
import { type DisplayBlock } from "./display-blocks.js";
|
|
34
34
|
import type { CalculationInclude, Expr, ExprContext, ExprType } from "../field/calc.js";
|
|
35
|
-
import type
|
|
35
|
+
import { type UnsafePlatformId } from "../../core/platform-id.js";
|
|
36
36
|
/**
|
|
37
37
|
* One entry of a dynamic picklist's `sort.orders` — `field` is a token on
|
|
38
38
|
* the related aspect (same convention as `relatedLabelFieldId`), resolved
|
|
@@ -550,6 +550,17 @@ interface AppV2OptionsBase<F extends Record<string, AppField> = Record<string, A
|
|
|
550
550
|
readonly relationships?: Readonly<Record<string, AppRelationship>>;
|
|
551
551
|
/** Display order of all authored views (by key). Defaults to declaration order by view bag. */
|
|
552
552
|
readonly viewOrder?: readonly string[];
|
|
553
|
+
/**
|
|
554
|
+
* Delete the platform's default "List" view (the LIST-type view named
|
|
555
|
+
* "List" the platform creates on every app and element), so the first entry
|
|
556
|
+
* of `viewOrder` is the main surface. The delete runs once: when the view
|
|
557
|
+
* order is created with it set, or when it changes from unset/`false` to
|
|
558
|
+
* `true`; later applies, including reorders, never delete a view. The plan
|
|
559
|
+
* warns with the view's id and name, and fails if several views qualify.
|
|
560
|
+
* Omitting it means `false` (nothing is deleted). `elementum new app` sets
|
|
561
|
+
* it. No declared view may be named "List".
|
|
562
|
+
*/
|
|
563
|
+
readonly deleteDefaultListView?: boolean;
|
|
553
564
|
/**
|
|
554
565
|
* App-level sharing & row-level-security policies (`elementum_access_policy`), in declaration order.
|
|
555
566
|
* Creating the app also has the platform mint a separate creator policy
|
|
@@ -4,6 +4,7 @@ import { serializeDisplayBlocks } from "./display-blocks.js";
|
|
|
4
4
|
import { assertCalculatedFieldRoot } from "../field/calc/runtime.js";
|
|
5
5
|
import { assertAttachmentMediaTypes } from "../field/media-types.js";
|
|
6
6
|
import { assertFieldAllowList } from "../field/allow-list.js";
|
|
7
|
+
import { isUnsafePlatformId } from "../../core/platform-id.js";
|
|
7
8
|
/** Where a classic layout section renders: the main area or the record side panel. */
|
|
8
9
|
export const layoutSectionDisplayLocation = {
|
|
9
10
|
center: "CENTER",
|
|
@@ -137,15 +138,16 @@ function unwrapUnsafePlatformIds(value) {
|
|
|
137
138
|
* added without re-running `elementum generate`) evaluates to `undefined`; the
|
|
138
139
|
* TF emitter then drops the whole dynamic config, omits the field resource,
|
|
139
140
|
* and the plan destroys the field. Throw instead, naming the owner, the
|
|
140
|
-
* field's bag key and the missing ref, so the build fails closed.
|
|
141
|
-
*
|
|
141
|
+
* field's bag key and the missing ref, so the build fails closed. Every field
|
|
142
|
+
* operand inside `filter` is checked the same way (#2309): see
|
|
143
|
+
* {@link assertDynamicFilterRefs}.
|
|
142
144
|
*/
|
|
143
145
|
function assertDynamicPicklistRefs(field, dynamic, refName, owner) {
|
|
144
146
|
const typeLabel = field.type === "MULTI_PICKLIST" ? "Multi-Select" : "Dropdown";
|
|
145
147
|
const where = `${owner !== undefined ? `${owner} ` : ""}${refName !== undefined ? `fields.${refName}` : "field"} ` +
|
|
146
148
|
`(${JSON.stringify(field.name)}, dynamic ${typeLabel})`;
|
|
147
|
-
const missing = (path) => {
|
|
148
|
-
throw new Error(`${where}: ${path} is undefined. The catalog ref it names doesn't resolve: the referenced field, app, element ` +
|
|
149
|
+
const missing = (path, refersTo) => {
|
|
150
|
+
throw new Error(`${where}: ${path} is undefined${refersTo !== undefined ? ` (${refersTo})` : ""}. The catalog ref it names doesn't resolve: the referenced field, app, element ` +
|
|
149
151
|
`or task was removed or renamed, or it was just added and the catalog hasn't been regenerated (run ` +
|
|
150
152
|
`\`elementum generate\`, then build again). Building would drop this field's dynamic config and the plan ` +
|
|
151
153
|
`would destroy the field; fix or remove the ref.`);
|
|
@@ -169,6 +171,79 @@ function assertDynamicPicklistRefs(field, dynamic, refName, owner) {
|
|
|
169
171
|
missing(`config.dynamic.sort[${i}].field`);
|
|
170
172
|
});
|
|
171
173
|
}
|
|
174
|
+
if (dynamic.filter !== undefined) {
|
|
175
|
+
// Name where each filter field lives (#2309): a left side or `fieldValue`
|
|
176
|
+
// operand is a field of the Dropdown's source, a `recordField` operand a
|
|
177
|
+
// field of the record that owns the Dropdown.
|
|
178
|
+
const source = describeDynamicSource(dynamic.relatedAspectId);
|
|
179
|
+
const scopes = {
|
|
180
|
+
source: source !== undefined ? `a field of the Dropdown's source, ${source}` : "a field of the Dropdown's source",
|
|
181
|
+
record: `a field of ${owner ?? "the record that owns this Dropdown"}`,
|
|
182
|
+
};
|
|
183
|
+
assertDynamicFilterRefs(dynamic.filter, "config.dynamic.filter", missing, scopes);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
/** `element "demoSharedVendor"` for a catalog ref, `platform id "…"` for an unsafe id; `undefined` if absent. */
|
|
187
|
+
function describeDynamicSource(source) {
|
|
188
|
+
if (source === null || typeof source !== "object")
|
|
189
|
+
return undefined;
|
|
190
|
+
if (isUnsafePlatformId(source))
|
|
191
|
+
return `platform id ${JSON.stringify(source.value)}`;
|
|
192
|
+
const ref = source;
|
|
193
|
+
if (typeof ref.__kind !== "string" || typeof ref.refName !== "string")
|
|
194
|
+
return undefined;
|
|
195
|
+
return `${ref.__kind} ${JSON.stringify(ref.refName)}`;
|
|
196
|
+
}
|
|
197
|
+
/** Filter types whose node carries children or nothing, not a left side. */
|
|
198
|
+
const DYNAMIC_FILTER_BRANCH_TYPES = new Set(["AND", "OR"]);
|
|
199
|
+
const DYNAMIC_FILTER_CONSTANT_TYPES = new Set(["TRUE", "FALSE"]);
|
|
200
|
+
/**
|
|
201
|
+
* A dynamic Dropdown filter's field operands must be present, the same rule as
|
|
202
|
+
* the refs {@link assertDynamicPicklistRefs} checks (#2309). A removed field
|
|
203
|
+
* evaluates to `undefined`: `filter.isNotNull(catalog.x.fields.removed)` keeps
|
|
204
|
+
* `field: undefined`, and `fieldValue(...)` / `recordField(...)` keep an
|
|
205
|
+
* `undefined` operand. The TF emitter can't build that filter, drops the whole
|
|
206
|
+
* dynamic config, leaves the field out, and the plan destroys it. Walks
|
|
207
|
+
* `and`/`or` children so the error names the exact path.
|
|
208
|
+
*/
|
|
209
|
+
function assertDynamicFilterRefs(node, path, missing, scopes) {
|
|
210
|
+
if (node == null)
|
|
211
|
+
missing(path);
|
|
212
|
+
if (typeof node !== "object")
|
|
213
|
+
return;
|
|
214
|
+
const filter = node;
|
|
215
|
+
const type = typeof filter.type === "string" ? filter.type.toUpperCase() : undefined;
|
|
216
|
+
if (type === undefined || DYNAMIC_FILTER_CONSTANT_TYPES.has(type))
|
|
217
|
+
return;
|
|
218
|
+
if (DYNAMIC_FILTER_BRANCH_TYPES.has(type)) {
|
|
219
|
+
if (Array.isArray(filter.children)) {
|
|
220
|
+
filter.children.forEach((child, i) => assertDynamicFilterRefs(child, `${path}.children[${i}]`, missing, scopes));
|
|
221
|
+
}
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
const hasLeft = ["field", "field_id", "leftValue", "left_value"].some((key) => Object.hasOwn(filter, key));
|
|
225
|
+
if (!hasLeft || (Object.hasOwn(filter, "field") && filter.field == null))
|
|
226
|
+
missing(`${path}.field`, scopes.source);
|
|
227
|
+
if (Object.hasOwn(filter, "leftValue"))
|
|
228
|
+
assertDynamicFilterOperand(filter.leftValue, `${path}.leftValue`, missing, scopes);
|
|
229
|
+
for (const key of ["value", "min", "max"]) {
|
|
230
|
+
if (Object.hasOwn(filter, key))
|
|
231
|
+
assertDynamicFilterOperand(filter[key], `${path}.${key}`, missing, scopes);
|
|
232
|
+
}
|
|
233
|
+
if (Array.isArray(filter.values)) {
|
|
234
|
+
filter.values.forEach((value, i) => assertDynamicFilterOperand(value, `${path}.values[${i}]`, missing, scopes));
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
/** A `FIELD` or `RECORD_FIELD` operand whose field is `undefined` names a removed field. */
|
|
238
|
+
function assertDynamicFilterOperand(operand, path, missing, scopes) {
|
|
239
|
+
if (operand === null || typeof operand !== "object")
|
|
240
|
+
return;
|
|
241
|
+
const value = operand;
|
|
242
|
+
const type = typeof value.type === "string" ? value.type.toUpperCase() : undefined;
|
|
243
|
+
if (type === "FIELD" && value.value == null && value.field == null && value.field_id == null)
|
|
244
|
+
missing(`${path}.value`, scopes.source);
|
|
245
|
+
if (type === "RECORD_FIELD" && value.field == null)
|
|
246
|
+
missing(`${path}.field`, scopes.record);
|
|
172
247
|
}
|
|
173
248
|
/**
|
|
174
249
|
* Serialize an authored field to its `AspectFieldInput` wire shape — shared
|
|
@@ -588,6 +663,7 @@ export function app(opts) {
|
|
|
588
663
|
...(opts.dynamicLayouts !== undefined ? { dynamicLayouts: opts.dynamicLayouts } : {}),
|
|
589
664
|
...(opts.relationships !== undefined ? { relationships: opts.relationships } : {}),
|
|
590
665
|
...(opts.viewOrder !== undefined ? { viewOrder: opts.viewOrder } : {}),
|
|
666
|
+
...(opts.deleteDefaultListView !== undefined ? { deleteDefaultListView: opts.deleteDefaultListView } : {}),
|
|
591
667
|
...(opts.accessPolicies !== undefined ? { accessPolicies: opts.accessPolicies } : {}),
|
|
592
668
|
...(opts.roles !== undefined ? { roles: opts.roles } : {}),
|
|
593
669
|
...(opts.serviceAccounts !== undefined ? { serviceAccounts: opts.serviceAccounts } : {}),
|
|
@@ -220,13 +220,8 @@ export type NormalizedDashboardWidget = {
|
|
|
220
220
|
export interface NormalizedWidgetRef {
|
|
221
221
|
readonly kind: "app" | "element" | "task" | "automation" | "field" | "recordIdentity";
|
|
222
222
|
readonly key: string;
|
|
223
|
+
/** The display name; build looks an automation that is not in source up by it (#1900). */
|
|
223
224
|
readonly name: string;
|
|
224
|
-
/**
|
|
225
|
-
* Export display name, present only when pull read one. Build uses it to
|
|
226
|
-
* look up an automation that is not in source. Absent means `name` is not
|
|
227
|
-
* a display name.
|
|
228
|
-
*/
|
|
229
|
-
readonly displayName?: string;
|
|
230
225
|
readonly parent?: string;
|
|
231
226
|
readonly fieldType?: string;
|
|
232
227
|
readonly target?: NormalizedWidgetRef;
|
|
@@ -331,9 +326,10 @@ export interface PulledRelationshipRef {
|
|
|
331
326
|
export interface NormalizedRelationship {
|
|
332
327
|
readonly key: string;
|
|
333
328
|
readonly target: PulledRelationshipRef;
|
|
329
|
+
/** `relatedField` is a platform id when ei couldn't name another owner's field (#1991). */
|
|
334
330
|
readonly columns: readonly {
|
|
335
331
|
readonly field: string;
|
|
336
|
-
readonly relatedField: PulledRelationshipRef;
|
|
332
|
+
readonly relatedField: PulledRelationshipRef | string;
|
|
337
333
|
}[];
|
|
338
334
|
readonly filter?: NormalizedAccessPolicy["filter"];
|
|
339
335
|
}
|
|
@@ -409,6 +405,8 @@ export interface NormalizedApp {
|
|
|
409
405
|
readonly relationships?: readonly NormalizedRelationship[];
|
|
410
406
|
/** Display order of `listViews`, by key (`elementum_managed_view_order`). */
|
|
411
407
|
readonly viewOrder?: readonly string[];
|
|
408
|
+
/** `elementum_managed_view_order.delete_platform_default_list_view` (#1773). */
|
|
409
|
+
readonly deleteDefaultListView?: boolean;
|
|
412
410
|
/** App/element-level sharing & row-level-security policies (`elementum_access_policy`), in export order. */
|
|
413
411
|
readonly accessPolicies?: readonly NormalizedAccessPolicy[];
|
|
414
412
|
/** Custom roles only; managed roles are represented by data lookups. */
|
|
@@ -12,7 +12,7 @@ import { DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES, SYSTEM_FIELD_KEYS, SYSTEM_FIELD_KEY_
|
|
|
12
12
|
import { EntityTfError } from "../../engine/entity.js";
|
|
13
13
|
import { dataRefLabel, optionalString, plainObject } from "../../engine/pull/context.js";
|
|
14
14
|
import { tfLabelToTsLabel } from "../../engine/tf/index.js";
|
|
15
|
-
import { accessPolicyFromTf } from "../access-policy/from-tf.js";
|
|
15
|
+
import { accessPolicyBlocksInLabelOrder, accessPolicyFromTf } from "../access-policy/from-tf.js";
|
|
16
16
|
import { dynamicLayoutCompanionWidgetLabels, dynamicLayoutsFromTf, } from "../dynamic-layout/from-tf.js";
|
|
17
17
|
import { dashboardsFromTf } from "../dashboard/from-tf.js";
|
|
18
18
|
import { fieldFromTf } from "../field/from-tf.js";
|
|
@@ -21,7 +21,7 @@ import { recordCreateFormFromTf } from "../record-create-form/from-tf.js";
|
|
|
21
21
|
import { relationshipsFromTf } from "../relationship/from-tf.js";
|
|
22
22
|
import { rolesFromTf } from "../role/from-tf.js";
|
|
23
23
|
import { serviceAccountsFromTf } from "../service-account/from-tf.js";
|
|
24
|
-
import { viewsFromTf } from "../view/from-tf.js";
|
|
24
|
+
import { fieldKeysByDisplayName, viewsFromTf } from "../view/from-tf.js";
|
|
25
25
|
import { widgetsFromTf } from "../widget/from-tf.js";
|
|
26
26
|
import { APP_RESOURCE_TYPE } from "./module.js";
|
|
27
27
|
import { stageHandleIndex } from "./stage-keys.js";
|
|
@@ -215,23 +215,27 @@ export function appFromTf(appBlock, fieldBlocks, ctx, viewBlocks = { layoutBlock
|
|
|
215
215
|
// One stage-handle map for every stage reference this app pulls (#1136).
|
|
216
216
|
const stageHandles = stageHandleIndex(stages.map((stage) => ({ key: stage.key, name: stage.stage.name })), ctx.diagnostics);
|
|
217
217
|
// --- View pass: layouts / list views / view order (entities/view), owner passed in.
|
|
218
|
-
const dashboards = dashboardsFromTf(viewBlocks.dashboardBlocks, viewBlocks.dashboardWidgetBlocks, { type: APP_RESOURCE_TYPE, label, ownerTfLabel: refName, ownerRefName: refName, scope: "app", ownerType: "APP_ASPECT" }, ctx);
|
|
219
218
|
const unextractedFieldIds = new Set();
|
|
220
|
-
const
|
|
219
|
+
const fieldKeys = new Set(fields.map((field) => field.key));
|
|
220
|
+
// Every field reference pull writes keeps an unextracted field as its platform id (#1736, #1966).
|
|
221
|
+
const fieldKeysByName = fieldKeysByDisplayName(fields);
|
|
222
|
+
const dashboards = dashboardsFromTf(viewBlocks.dashboardBlocks, viewBlocks.dashboardWidgetBlocks, { type: APP_RESOURCE_TYPE, label, ownerTfLabel: label, ownerRefName: refName, scope: "app", ownerType: "APP_ASPECT", fieldKeys, fieldKeysByName, unextractedFieldIds }, ctx);
|
|
223
|
+
const unextracted = { type: APP_RESOURCE_TYPE, label, ownerTfLabel: label, scope: "app", fieldKeys, fieldKeysByName, unextractedFieldIds };
|
|
224
|
+
const { layouts, listViews, calendarViews, kanbanViews, dashboardViews, agentViews, customViews, viewOrder, deleteDefaultListView } = viewsFromTf(viewBlocks.layoutBlocks, viewBlocks.listViewBlocks, viewBlocks.calendarViewBlocks, viewBlocks.kanbanViewBlocks, viewBlocks.dashboardViewBlocks, viewBlocks.agentViewBlocks, viewBlocks.managedViewOrderBlocks, {
|
|
221
225
|
type: APP_RESOURCE_TYPE, label, ownerTfLabel: label, scope: "app",
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
226
|
+
stageHandles,
|
|
227
|
+
fieldKeys,
|
|
228
|
+
fieldKeysByName,
|
|
225
229
|
unextractedFieldIds,
|
|
226
230
|
}, ctx, viewBlocks.customViewBlocks);
|
|
227
231
|
if (viewBlocks.recordCreateFormBlocks.length > 1) {
|
|
228
232
|
ctx.diagnostics.push(`app "${label}": found ${viewBlocks.recordCreateFormBlocks.length} record create forms; only the first is used`);
|
|
229
233
|
}
|
|
230
|
-
const recordCreateForm = recordCreateFormFromTf(viewBlocks.recordCreateFormBlocks[0], { type: APP_RESOURCE_TYPE, label, ownerTfLabel:
|
|
231
|
-
const dynamicLayoutOwner = { type: APP_RESOURCE_TYPE, label, ownerRefName: refName, ownerTfLabel: label, stageHandles };
|
|
234
|
+
const recordCreateForm = recordCreateFormFromTf(viewBlocks.recordCreateFormBlocks[0], { type: APP_RESOURCE_TYPE, label, ownerTfLabel: label, scope: "app", unextracted }, ctx);
|
|
235
|
+
const dynamicLayoutOwner = { type: APP_RESOURCE_TYPE, label, ownerRefName: refName, ownerTfLabel: label, stageHandles, unextracted };
|
|
232
236
|
const dynamicLayouts = dynamicLayoutsFromTf(viewBlocks.dynamicLayoutBlocks, dynamicLayoutOwner, ctx);
|
|
233
|
-
const relationships = relationshipsFromTf(viewBlocks.relationshipBlocks, { kind: "app", label, ownerRefName: refName, ownerTfLabel:
|
|
234
|
-
const widgets = widgetsFromTf(viewBlocks.widgetBlocks, { type: APP_RESOURCE_TYPE, label, ownerRefName: refName, ownerTfLabel: label, scope: "app" }, ctx, dynamicLayoutCompanionWidgetLabels(viewBlocks.dynamicLayoutBlocks, dynamicLayoutOwner));
|
|
237
|
+
const relationships = relationshipsFromTf(viewBlocks.relationshipBlocks, { kind: "app", label, ownerRefName: refName, ownerTfLabel: label, scope: "app", unextracted }, ctx);
|
|
238
|
+
const widgets = widgetsFromTf(viewBlocks.widgetBlocks, { type: APP_RESOURCE_TYPE, label, ownerRefName: refName, ownerTfLabel: label, scope: "app", unextracted }, ctx, dynamicLayoutCompanionWidgetLabels(viewBlocks.dynamicLayoutBlocks, dynamicLayoutOwner));
|
|
235
239
|
// --- Access policies (entities/access-policy), owner passed in.
|
|
236
240
|
const accessPolicyOwner = {
|
|
237
241
|
type: APP_RESOURCE_TYPE,
|
|
@@ -241,7 +245,7 @@ export function appFromTf(appBlock, fieldBlocks, ctx, viewBlocks = { layoutBlock
|
|
|
241
245
|
scope: "app",
|
|
242
246
|
};
|
|
243
247
|
const accessPolicies = [];
|
|
244
|
-
for (const block of accessPolicyBlocks) {
|
|
248
|
+
for (const block of accessPolicyBlocksInLabelOrder(accessPolicyBlocks)) {
|
|
245
249
|
const entry = accessPolicyFromTf(block, accessPolicyOwner, ctx);
|
|
246
250
|
if (entry !== undefined)
|
|
247
251
|
accessPolicies.push(entry);
|
|
@@ -283,6 +287,7 @@ export function appFromTf(appBlock, fieldBlocks, ctx, viewBlocks = { layoutBlock
|
|
|
283
287
|
...(dynamicLayouts.length > 0 && { dynamicLayouts }),
|
|
284
288
|
...(relationships.length > 0 && { relationships }),
|
|
285
289
|
...(viewOrder !== undefined && { viewOrder }),
|
|
290
|
+
...(deleteDefaultListView !== undefined && { deleteDefaultListView }),
|
|
286
291
|
...(accessPolicies.length > 0 && { accessPolicies }),
|
|
287
292
|
...(roles.length > 0 && { roles }),
|
|
288
293
|
...(serviceAccounts.length > 0 && { serviceAccounts }),
|
|
@@ -28,14 +28,25 @@ export declare function stageKeyFromPicklistValue(pv: PicklistValueWire): AppSta
|
|
|
28
28
|
* derive the same handle, the first keeps it and a diagnostic says so,
|
|
29
29
|
* instead of silently rebinding. A stage left with no handle that maps to
|
|
30
30
|
* its own key (a punctuation key whose only handle is another stage's key,
|
|
31
|
-
* e.g. `pre-approval` next to `pre_approval`) is diagnosed too.
|
|
32
|
-
*
|
|
31
|
+
* e.g. `pre-approval` next to `pre_approval`) is diagnosed too. So is a
|
|
32
|
+
* stage whose only handle is the `SanitizeName` fallback and another stage
|
|
33
|
+
* already holds it: two stages whose names have no usable characters
|
|
34
|
+
* (`"!!!"` and `"日本"`) both fall back to `resource`, and the second has no
|
|
35
|
+
* handle at all (#1767). Pull never writes another stage's handle for it:
|
|
36
|
+
* see {@link pulledStageHandle}.
|
|
33
37
|
*/
|
|
34
38
|
export declare function stageKeyByHandle(stages: readonly AppStageKey[], diagnostics?: string[]): Map<string, string>;
|
|
39
|
+
/** A stage left with no handle because its only fallback handle belongs to another stage (#1767). */
|
|
40
|
+
export interface FallbackLostStage {
|
|
41
|
+
readonly handle: string;
|
|
42
|
+
readonly owner: string;
|
|
43
|
+
}
|
|
35
44
|
/** An app's stage handles plus its real stage keys, for pull-side resolution (#1136). */
|
|
36
45
|
export interface StageHandleIndex {
|
|
37
46
|
readonly byHandle: ReadonlyMap<string, string>;
|
|
38
47
|
readonly keys: ReadonlySet<string>;
|
|
48
|
+
/** Stages whose only (fallback) handle another stage holds, by real key (#1767). */
|
|
49
|
+
readonly fallbackLost?: ReadonlyMap<string, FallbackLostStage>;
|
|
39
50
|
}
|
|
40
51
|
/** {@link stageKeyByHandle} plus the real key set. */
|
|
41
52
|
export declare function stageHandleIndex(stages: readonly AppStageKey[], diagnostics?: string[]): StageHandleIndex;
|
|
@@ -50,6 +61,7 @@ export type PulledStageHandle = {
|
|
|
50
61
|
readonly kind: "lost";
|
|
51
62
|
readonly handle: string;
|
|
52
63
|
readonly owner: string;
|
|
64
|
+
readonly fallback?: true;
|
|
53
65
|
} | {
|
|
54
66
|
readonly kind: "none";
|
|
55
67
|
};
|
|
@@ -60,7 +72,9 @@ export type PulledStageHandle = {
|
|
|
60
72
|
* slug is another stage's own key, e.g. `pre-approval` next to
|
|
61
73
|
* `pre_approval`), returns `lost`: writing that handle would bind the
|
|
62
74
|
* reference to the other stage on build, so the caller leaves the
|
|
63
|
-
* reference out with a diagnostic instead.
|
|
75
|
+
* reference out with a diagnostic instead. The same holds for a stage whose
|
|
76
|
+
* only handle is the shared `SanitizeName` fallback another stage holds
|
|
77
|
+
* (#1767). Without an index (or for an
|
|
64
78
|
* index that is not one of the app's stages) this is `stageHandleTfLabel`.
|
|
65
79
|
*/
|
|
66
80
|
export declare function pulledStageHandle(index: string, stages: StageHandleIndex | undefined): PulledStageHandle;
|
|
@@ -77,6 +91,7 @@ export declare class LostStageHandleError extends EntityTfError {
|
|
|
77
91
|
export declare function lostStageMessage(where: string, index: string, lost: {
|
|
78
92
|
readonly handle: string;
|
|
79
93
|
readonly owner: string;
|
|
94
|
+
readonly fallback?: true;
|
|
80
95
|
}, outcome: string): string;
|
|
81
96
|
/** The owning app's stage handles (see {@link stageKeyByHandle}) from its built payload, for child entities. */
|
|
82
97
|
export declare function appStageKeyByHandle(payload: unknown): Map<string, string> | undefined;
|
|
@@ -30,10 +30,17 @@ export function stageKeyFromPicklistValue(pv) {
|
|
|
30
30
|
* derive the same handle, the first keeps it and a diagnostic says so,
|
|
31
31
|
* instead of silently rebinding. A stage left with no handle that maps to
|
|
32
32
|
* its own key (a punctuation key whose only handle is another stage's key,
|
|
33
|
-
* e.g. `pre-approval` next to `pre_approval`) is diagnosed too.
|
|
34
|
-
*
|
|
33
|
+
* e.g. `pre-approval` next to `pre_approval`) is diagnosed too. So is a
|
|
34
|
+
* stage whose only handle is the `SanitizeName` fallback and another stage
|
|
35
|
+
* already holds it: two stages whose names have no usable characters
|
|
36
|
+
* (`"!!!"` and `"日本"`) both fall back to `resource`, and the second has no
|
|
37
|
+
* handle at all (#1767). Pull never writes another stage's handle for it:
|
|
38
|
+
* see {@link pulledStageHandle}.
|
|
35
39
|
*/
|
|
36
40
|
export function stageKeyByHandle(stages, diagnostics) {
|
|
41
|
+
return stageHandleBindings(stages, diagnostics).byHandle;
|
|
42
|
+
}
|
|
43
|
+
function stageHandleBindings(stages, diagnostics) {
|
|
37
44
|
const byHandle = new Map();
|
|
38
45
|
for (const stage of stages) {
|
|
39
46
|
if (isTfLabel(stage.key) && !byHandle.has(stage.key))
|
|
@@ -78,17 +85,34 @@ export function stageKeyByHandle(stages, diagnostics) {
|
|
|
78
85
|
byHandle.set(exportHandle, stage.key);
|
|
79
86
|
}
|
|
80
87
|
const bound = new Set(byHandle.values());
|
|
88
|
+
const fallbackLost = new Map();
|
|
89
|
+
for (const stage of stages) {
|
|
90
|
+
if (bound.has(stage.key) || reported.has(stage.key) || lostTo.has(stage.key) || fallbackLost.has(stage.key))
|
|
91
|
+
continue;
|
|
92
|
+
const exportHandle = sanitizeName(stage.name);
|
|
93
|
+
const owner = byHandle.get(exportHandle);
|
|
94
|
+
if (owner === undefined || owner === stage.key)
|
|
95
|
+
continue;
|
|
96
|
+
fallbackLost.set(stage.key, { handle: exportHandle, owner });
|
|
97
|
+
// An empty slug ("!!!", "日本") has no handle characters at all; a
|
|
98
|
+
// non-empty one ("1st!!!") has them, but only as the same fallback.
|
|
99
|
+
const why = snakeSlug(stage.name) === ""
|
|
100
|
+
? `its name ${JSON.stringify(stage.name)} has no characters a handle can use, so its only handle is the fallback handle "${exportHandle}"`
|
|
101
|
+
: `its only handle is the fallback handle "${exportHandle}" that its name ${JSON.stringify(stage.name)} produces`;
|
|
102
|
+
diagnostics?.push(`systemFields.stage: stage "${stage.key}" has no handle of its own: ${why}, and stage "${owner}" already holds that handle. Source cannot reference "${stage.key}", so pull leaves its layouts, dynamic layouts, approval chains and flows unmanaged (each one warned) instead of binding them to "${owner}". Rename one of the stages so their names produce different handles (#1767).`);
|
|
103
|
+
}
|
|
81
104
|
for (const stage of stages) {
|
|
82
105
|
const lost = lostTo.get(stage.key);
|
|
83
106
|
if (bound.has(stage.key) || reported.has(stage.key) || lost === undefined)
|
|
84
107
|
continue;
|
|
85
108
|
diagnostics?.push(`systemFields.stage: stage "${stage.key}" has no handle of its own: its handle "${lost.handle}" is stage "${lost.owner}"'s key. Source cannot reference "${stage.key}", so pull leaves its layouts, dynamic layouts, approval chains and flows unmanaged (each one warned) instead of binding them to "${lost.owner}". Rename one of the stages so each has its own handle.`);
|
|
86
109
|
}
|
|
87
|
-
return byHandle;
|
|
110
|
+
return { byHandle, fallbackLost };
|
|
88
111
|
}
|
|
89
112
|
/** {@link stageKeyByHandle} plus the real key set. */
|
|
90
113
|
export function stageHandleIndex(stages, diagnostics) {
|
|
91
|
-
|
|
114
|
+
const { byHandle, fallbackLost } = stageHandleBindings(stages, diagnostics);
|
|
115
|
+
return { byHandle, keys: new Set(stages.map((stage) => stage.key)), ...(fallbackLost.size > 0 ? { fallbackLost } : {}) };
|
|
92
116
|
}
|
|
93
117
|
/** The stage handles of an `elementum_app` block's `stages` attribute, or undefined when it has none. */
|
|
94
118
|
export function stageHandleIndexFromTfStages(value) {
|
|
@@ -111,7 +135,9 @@ export function stageHandleIndexFromTfStages(value) {
|
|
|
111
135
|
* slug is another stage's own key, e.g. `pre-approval` next to
|
|
112
136
|
* `pre_approval`), returns `lost`: writing that handle would bind the
|
|
113
137
|
* reference to the other stage on build, so the caller leaves the
|
|
114
|
-
* reference out with a diagnostic instead.
|
|
138
|
+
* reference out with a diagnostic instead. The same holds for a stage whose
|
|
139
|
+
* only handle is the shared `SanitizeName` fallback another stage holds
|
|
140
|
+
* (#1767). Without an index (or for an
|
|
115
141
|
* index that is not one of the app's stages) this is `stageHandleTfLabel`.
|
|
116
142
|
*/
|
|
117
143
|
export function pulledStageHandle(index, stages) {
|
|
@@ -123,6 +149,9 @@ export function pulledStageHandle(index, stages) {
|
|
|
123
149
|
for (const [handle, key] of stages.byHandle)
|
|
124
150
|
if (key === index && isTfLabel(handle))
|
|
125
151
|
return { kind: "handle", handle };
|
|
152
|
+
const fallbackLost = stages.fallbackLost?.get(index);
|
|
153
|
+
if (fallbackLost !== undefined)
|
|
154
|
+
return { kind: "lost", handle: fallbackLost.handle, owner: fallbackLost.owner, fallback: true };
|
|
126
155
|
if (preferred === undefined)
|
|
127
156
|
return { kind: "none" };
|
|
128
157
|
const owner = stages.byHandle.get(preferred);
|
|
@@ -142,7 +171,12 @@ export class LostStageHandleError extends EntityTfError {
|
|
|
142
171
|
}
|
|
143
172
|
/** The per-reference warning for a `lost` {@link pulledStageHandle}. */
|
|
144
173
|
export function lostStageMessage(where, index, lost, outcome) {
|
|
145
|
-
|
|
174
|
+
// A fallback loss (#1767): the handle is the SanitizeName fallback the other
|
|
175
|
+
// stage holds, not that stage's key, so the #1136 sentence would be false.
|
|
176
|
+
const why = lost.fallback === true
|
|
177
|
+
? `its only handle is the fallback handle "${lost.handle}", which stage "${lost.owner}" already holds`
|
|
178
|
+
: `its handle "${lost.handle}" is stage "${lost.owner}"'s key`;
|
|
179
|
+
return `${where}: stage "${index}" has no handle of its own (${why}); ${outcome} instead of binding it to "${lost.owner}" (${lost.fallback === true ? "#1767" : "#1136"})`;
|
|
146
180
|
}
|
|
147
181
|
/** The owning app's stage handles (see {@link stageKeyByHandle}) from its built payload, for child entities. */
|
|
148
182
|
export function appStageKeyByHandle(payload) {
|
|
@@ -227,6 +227,7 @@ export function appToTf(entity, ctx) {
|
|
|
227
227
|
const field = fieldToTf(typeKey, inner, {
|
|
228
228
|
ownerTfLabel: ctx.appTfLabel,
|
|
229
229
|
appRefName: ctx.appRefName,
|
|
230
|
+
...(payload.name !== undefined && { ownerName: payload.name }),
|
|
230
231
|
objectId,
|
|
231
232
|
diagnostics: ctx.diagnostics,
|
|
232
233
|
orgRefs: ctx.orgRefs,
|
|
@@ -270,7 +271,7 @@ export function appToTf(entity, ctx) {
|
|
|
270
271
|
availableChartRefNames: ctx.workspaceAspects?.get(workspaceAspectKey("app", ctx.appRefName))?.managedChildRefNames?.get("chart"),
|
|
271
272
|
diagnostics: ctx.diagnostics,
|
|
272
273
|
}));
|
|
273
|
-
|
|
274
|
+
const widgets = widgetsToTf(payload.widgets, {
|
|
274
275
|
ownerRefName: ctx.appRefName,
|
|
275
276
|
ownerTfLabel: ctx.appTfLabel,
|
|
276
277
|
ownerType: APP_RESOURCE_TYPE,
|
|
@@ -281,7 +282,8 @@ export function appToTf(entity, ctx) {
|
|
|
281
282
|
diagnostics: ctx.diagnostics,
|
|
282
283
|
fieldAddresses,
|
|
283
284
|
relationshipTargets: relationshipTargetsFromBag(payload.relationships),
|
|
284
|
-
})
|
|
285
|
+
});
|
|
286
|
+
blocks.push(...widgets.blocks);
|
|
285
287
|
const { blocks: viewBlocks } = viewToTf(payload.layouts, payload.listViews, payload.calendarViews, payload.kanbanViews, payload.dashboardViews, payload.agentViews, payload.viewOrder, {
|
|
286
288
|
ownerRefName: ctx.appRefName,
|
|
287
289
|
ownerTfLabel: ctx.appTfLabel,
|
|
@@ -295,7 +297,8 @@ export function appToTf(entity, ctx) {
|
|
|
295
297
|
fieldAddresses,
|
|
296
298
|
fieldNames,
|
|
297
299
|
fieldMetadata,
|
|
298
|
-
|
|
300
|
+
widgets: widgets.widgets,
|
|
301
|
+
...(payload.deleteDefaultListView !== undefined ? { deleteDefaultListView: payload.deleteDefaultListView } : {}),
|
|
299
302
|
}, payload.customViews);
|
|
300
303
|
blocks.push(...viewBlocks);
|
|
301
304
|
const recordCreateForm = recordCreateFormToTf(payload.recordCreateForm, {
|
|
@@ -316,7 +319,7 @@ export function appToTf(entity, ctx) {
|
|
|
316
319
|
orgRefs: ctx.orgRefs,
|
|
317
320
|
workspaceAspects: ctx.workspaceAspects,
|
|
318
321
|
fieldAddresses,
|
|
319
|
-
|
|
322
|
+
widgets: widgets.widgets,
|
|
320
323
|
stageKeyByTfLabel,
|
|
321
324
|
}));
|
|
322
325
|
blocks.push(...relationshipsToTf(payload.relationships, {
|