@elementumai/edk 0.10.2 → 0.10.3
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 +7 -7
- package/dist-sdk/src/catalog/org.d.ts +7 -5
- package/dist-sdk/src/catalog/org.js +14 -9
- package/dist-sdk/src/catalog/token.js +4 -0
- package/dist-sdk/src/core/types/app.d.ts +22 -0
- package/dist-sdk/src/engine/build/context.d.ts +8 -0
- package/dist-sdk/src/engine/build/source-context.d.ts +3 -4
- package/dist-sdk/src/engine/coverage-gaps.d.ts +2 -0
- package/dist-sdk/src/engine/coverage-gaps.js +3 -0
- package/dist-sdk/src/engine/ei/state.d.ts +48 -0
- package/dist-sdk/src/engine/ei/state.js +91 -0
- package/dist-sdk/src/engine/pull/authored-address.d.ts +100 -0
- package/dist-sdk/src/engine/pull/authored-address.js +360 -0
- package/dist-sdk/src/engine/pull/context.d.ts +59 -0
- package/dist-sdk/src/engine/tf/expr.d.ts +7 -0
- package/dist-sdk/src/engine/tf/expr.js +62 -18
- 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 +10 -2
- package/dist-sdk/src/engine/tf/labels.js +15 -2
- package/dist-sdk/src/engine/tf/parse.js +19 -6
- package/dist-sdk/src/engine/workspace/backend.d.ts +34 -0
- package/dist-sdk/src/engine/workspace/backend.js +104 -0
- package/dist-sdk/src/engine/workspace/generated-file.d.ts +3 -0
- package/dist-sdk/src/engine/workspace/generated-file.js +6 -0
- package/dist-sdk/src/engine/workspace/loader.js +2 -2
- package/dist-sdk/src/entities/agent-tool/to-tf.js +1 -1
- package/dist-sdk/src/entities/app/build.d.ts +36 -4
- package/dist-sdk/src/entities/app/build.js +67 -4
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +12 -0
- package/dist-sdk/src/entities/app/from-tf.js +13 -9
- package/dist-sdk/src/entities/app/module.js +1 -0
- package/dist-sdk/src/entities/app/stage-keys.d.ts +82 -0
- package/dist-sdk/src/entities/app/stage-keys.js +160 -0
- package/dist-sdk/src/entities/app/to-tf.js +17 -21
- package/dist-sdk/src/entities/approval-chain/from-tf.d.ts +9 -1
- package/dist-sdk/src/entities/approval-chain/from-tf.js +31 -3
- package/dist-sdk/src/entities/approval-chain/module.js +12 -4
- package/dist-sdk/src/entities/approval-chain/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/approval-chain/to-tf.js +6 -1
- package/dist-sdk/src/entities/automation/build.js +13 -6
- package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +3 -0
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +5 -3
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +90 -17
- package/dist-sdk/src/entities/automation/from-tf.d.ts +28 -6
- package/dist-sdk/src/entities/automation/from-tf.js +140 -23
- package/dist-sdk/src/entities/automation/module.js +123 -37
- package/dist-sdk/src/entities/automation/to-tf.d.ts +3 -1
- package/dist-sdk/src/entities/automation/to-tf.js +131 -20
- package/dist-sdk/src/entities/automation/triggers.d.ts +2 -0
- package/dist-sdk/src/entities/automation/triggers.js +1 -0
- package/dist-sdk/src/entities/chart/from-tf.d.ts +6 -0
- package/dist-sdk/src/entities/chart/from-tf.js +9 -1
- package/dist-sdk/src/entities/dashboard/from-tf.js +51 -4
- package/dist-sdk/src/entities/dynamic-layout/from-tf.d.ts +3 -0
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +48 -4
- package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +7 -2
- package/dist-sdk/src/entities/element/build.js +1 -1
- package/dist-sdk/src/entities/element/from-tf.d.ts +12 -6
- package/dist-sdk/src/entities/element/from-tf.js +23 -7
- package/dist-sdk/src/entities/element/module.js +3 -2
- package/dist-sdk/src/entities/element/to-tf.d.ts +3 -2
- package/dist-sdk/src/entities/element/to-tf.js +32 -25
- package/dist-sdk/src/entities/field/allow-list.d.ts +18 -0
- package/dist-sdk/src/entities/field/allow-list.js +42 -0
- package/dist-sdk/src/entities/field/build.d.ts +38 -3
- package/dist-sdk/src/entities/field/build.js +7 -2
- package/dist-sdk/src/entities/field/from-tf.js +178 -20
- package/dist-sdk/src/entities/field/module.js +2 -0
- package/dist-sdk/src/entities/field/options.d.ts +2 -0
- package/dist-sdk/src/entities/field/order.d.ts +9 -0
- package/dist-sdk/src/entities/field/order.js +33 -0
- package/dist-sdk/src/entities/field/to-tf.d.ts +6 -0
- package/dist-sdk/src/entities/field/to-tf.js +87 -0
- package/dist-sdk/src/entities/field/types.js +3 -0
- package/dist-sdk/src/entities/relationship/build.d.ts +3 -3
- package/dist-sdk/src/entities/relationship/from-tf.js +4 -2
- package/dist-sdk/src/entities/relationship/to-tf.js +3 -1
- package/dist-sdk/src/entities/service-account/workspace-owner.d.ts +8 -3
- package/dist-sdk/src/entities/service-account/workspace-owner.js +12 -4
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +5 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +13 -0
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +7 -0
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +1 -1
- package/dist-sdk/src/entities/skill/to-tf.js +19 -14
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/skill-tool/from-tf.js +3 -0
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +6 -1
- package/dist-sdk/src/entities/skill-tool/to-tf.js +6 -1
- package/dist-sdk/src/entities/task/build.js +1 -1
- package/dist-sdk/src/entities/view/agent-view-layout-to-tf.d.ts +11 -0
- package/dist-sdk/src/entities/view/agent-view-layout-to-tf.js +13 -38
- package/dist-sdk/src/entities/view/custom-view-validate.d.ts +29 -0
- package/dist-sdk/src/entities/view/custom-view-validate.js +292 -0
- package/dist-sdk/src/entities/view/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/view/from-tf.js +40 -6
- package/dist-sdk/src/entities/view/to-tf.d.ts +6 -0
- package/dist-sdk/src/entities/view/to-tf.js +14 -6
- package/dist-sdk/src/entities/visual-flow/from-tf.d.ts +2 -1
- package/dist-sdk/src/entities/visual-flow/from-tf.js +11 -2
- package/dist-sdk/src/entities/visual-flow/module.js +15 -5
- package/dist-sdk/src/entities/visual-flow/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/visual-flow/to-tf.js +1 -1
- package/dist-sdk/src/entities/widget/build.d.ts +8 -1
- package/dist-sdk/src/entities/widget/from-tf.js +12 -6
- package/dist-sdk/src/entities/widget/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/widget/to-tf.js +16 -0
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +8 -2
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
- package/dist-sdk/src/graph/index.d.ts +6 -0
- package/dist-sdk/src/graph/index.js +1 -0
- package/dist-sdk/src/graph/types.d.ts +59 -2
- package/package.json +2 -17
|
@@ -111,6 +111,20 @@ export function snakeSlug(s) {
|
|
|
111
111
|
.replace(/[^a-z0-9]+/g, "_")
|
|
112
112
|
.replace(/^_+|_+$/g, "");
|
|
113
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* The Terraform-label handle for a `stage_ids_by_key` index (#1136). An index
|
|
116
|
+
* that is already a tf label is its own handle. An imported key that keeps
|
|
117
|
+
* punctuation (`"enrichment_&_validation"`, `"pre-approval"`) maps to
|
|
118
|
+
* `snakeSlug(key)`, which is also the slug of the stage name build derives,
|
|
119
|
+
* so build can map the handle back to the real key. Returns `undefined` when
|
|
120
|
+
* no tf-label handle exists (for example a key whose slug starts with a digit).
|
|
121
|
+
*/
|
|
122
|
+
export function stageHandleTfLabel(key) {
|
|
123
|
+
if (TF_LABEL_RE.test(key))
|
|
124
|
+
return key;
|
|
125
|
+
const slug = snakeSlug(key);
|
|
126
|
+
return TF_LABEL_RE.test(slug) ? slug : undefined;
|
|
127
|
+
}
|
|
114
128
|
/** Faithful port of ei's SanitizeName: platform name → HCL identifier. */
|
|
115
129
|
export function sanitizeName(name) {
|
|
116
130
|
let s = splitCamelCase(name).toLowerCase();
|
|
@@ -178,8 +192,7 @@ export function appScopedResourceLabel(appTfLabel, childPart) {
|
|
|
178
192
|
* re-pulled — the old extractor never stripped the namespace, so it left prefixed bag keys
|
|
179
193
|
* (e.g. `ticketsActive`) that now over-double when rebuilt. A field FRESHLY re-extracted with
|
|
180
194
|
* `childPartFromScopedLabel`'s current (also-fixed) stripping round-trips to the exact same
|
|
181
|
-
* address ei already uses
|
|
182
|
-
* round-trip" block. Re-pull an existing element (`elementum pull element <ns>`) before your
|
|
195
|
+
* address ei already uses. Re-pull an existing element (`elementum pull element <ns>`) before your
|
|
183
196
|
* next build/plan if it predates this fix; adoption's rename guard (board item 225,
|
|
184
197
|
* `docs/design/rename-label-identity.md`) moves any address that does shift with a `moved` block.
|
|
185
198
|
*/
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* means something new is going on → Pause).
|
|
12
12
|
*/
|
|
13
13
|
import { decodeTemplateEscapes } from "./escape.js";
|
|
14
|
-
import { parseStringValue, TfExprError } from "./expr.js";
|
|
14
|
+
import { parseStringValue, quotedTemplateEnd, TfExprError } from "./expr.js";
|
|
15
15
|
let runtimeParser;
|
|
16
16
|
let batchParser;
|
|
17
17
|
let packageParser;
|
|
@@ -523,19 +523,32 @@ export function assertNoUnsafeIntegers(text) {
|
|
|
523
523
|
}
|
|
524
524
|
}
|
|
525
525
|
}
|
|
526
|
+
/** Index just past the quoted string opening at `openQuote`, ignoring holes (end of text when unclosed). */
|
|
527
|
+
function plainStringEnd(text, openQuote) {
|
|
528
|
+
let j = openQuote + 1;
|
|
529
|
+
while (j < text.length && text[j] !== '"') {
|
|
530
|
+
j += text[j] === "\\" ? 2 : 1;
|
|
531
|
+
}
|
|
532
|
+
return j + 1;
|
|
533
|
+
}
|
|
526
534
|
/** One in-order scan: strings become `""`, line comments vanish. */
|
|
527
535
|
function stripStringsAndComments(text) {
|
|
528
536
|
let out = "";
|
|
529
537
|
let i = 0;
|
|
538
|
+
// Template-aware until a string fails to close; from there on, plain
|
|
539
|
+
// scanning keeps the rest linear. That is usually invalid HCL, but a
|
|
540
|
+
// heredoc holding a lone quote can trigger it too: the plain scan then
|
|
541
|
+
// reads the rest of the file exactly as the guard did before #1542.
|
|
542
|
+
let templateAware = true;
|
|
530
543
|
while (i < text.length) {
|
|
531
544
|
const c = text[i];
|
|
532
545
|
if (c === '"') {
|
|
533
|
-
|
|
534
|
-
while (j < text.length && text[j] !== '"') {
|
|
535
|
-
j += text[j] === "\\" ? 2 : 1;
|
|
536
|
-
}
|
|
546
|
+
// A quoted key inside a ${...} hole is string text, not code (#1542).
|
|
537
547
|
out += '""';
|
|
538
|
-
|
|
548
|
+
const end = templateAware ? quotedTemplateEnd(text, i) : undefined;
|
|
549
|
+
if (end === undefined)
|
|
550
|
+
templateAware = false;
|
|
551
|
+
i = end ?? plainStringEnd(text, i);
|
|
539
552
|
continue;
|
|
540
553
|
}
|
|
541
554
|
if (c === "#" || (c === "/" && text[i + 1] === "/")) {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare const BACKEND_SOURCE_FILE = "backend.tf";
|
|
2
|
+
export declare const BACKEND_FINGERPRINT_FILE = "elementum-backend.sha256";
|
|
3
|
+
export type WorkspaceBackend = {
|
|
4
|
+
readonly mode: "local";
|
|
5
|
+
readonly type: "local";
|
|
6
|
+
readonly source: string;
|
|
7
|
+
readonly projected: string;
|
|
8
|
+
readonly fingerprint: string;
|
|
9
|
+
} | {
|
|
10
|
+
readonly mode: "declared";
|
|
11
|
+
readonly type: string;
|
|
12
|
+
readonly sourcePath: string;
|
|
13
|
+
readonly source: string;
|
|
14
|
+
readonly projected: string;
|
|
15
|
+
readonly fingerprint: string;
|
|
16
|
+
};
|
|
17
|
+
export type DeclaredWorkspaceBackend = Extract<WorkspaceBackend, {
|
|
18
|
+
mode: "declared";
|
|
19
|
+
}>;
|
|
20
|
+
export declare class WorkspaceBackendError extends Error {
|
|
21
|
+
constructor(message: string);
|
|
22
|
+
}
|
|
23
|
+
export declare function backendFingerprint(value: string): string;
|
|
24
|
+
export declare function loadWorkspaceBackend(orgRoot: string): Promise<WorkspaceBackend>;
|
|
25
|
+
/**
|
|
26
|
+
* Project the workspace-owned backend source into a generated Terraform
|
|
27
|
+
* working directory. The marker makes the copy build-owned; the org-root
|
|
28
|
+
* source remains the only file users edit.
|
|
29
|
+
*/
|
|
30
|
+
export declare function materializeWorkspaceBackend(backend: WorkspaceBackend, tfDir: string): Promise<void>;
|
|
31
|
+
export declare function backendFingerprintPath(tfDir: string): string;
|
|
32
|
+
export declare function assertNoUnmigratedLocalState(backend: WorkspaceBackend, orgRoot: string): void;
|
|
33
|
+
export declare function requireWorkspaceBackend(orgRoot: string, _operation: string): Promise<WorkspaceBackend>;
|
|
34
|
+
export declare function assertBackendBindingUnchanged(backend: WorkspaceBackend, orgRoot: string): Promise<void>;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { inspectBackendHcl } from "../tf/index.js";
|
|
6
|
+
import { MANAGED_MARKER } from "./generated-file.js";
|
|
7
|
+
export const BACKEND_SOURCE_FILE = "backend.tf";
|
|
8
|
+
export const BACKEND_FINGERPRINT_FILE = "elementum-backend.sha256";
|
|
9
|
+
const LOCAL_BACKEND_SOURCE = `terraform {
|
|
10
|
+
backend "local" {
|
|
11
|
+
path = "../../terraform.tfstate"
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
`;
|
|
15
|
+
export class WorkspaceBackendError extends Error {
|
|
16
|
+
constructor(message) {
|
|
17
|
+
super(message);
|
|
18
|
+
this.name = "WorkspaceBackendError";
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export function backendFingerprint(value) {
|
|
22
|
+
return createHash("sha256")
|
|
23
|
+
.update(`elementum:declared-backend:v1\n${value}`)
|
|
24
|
+
.digest("hex");
|
|
25
|
+
}
|
|
26
|
+
export async function loadWorkspaceBackend(orgRoot) {
|
|
27
|
+
const sourcePath = join(orgRoot, BACKEND_SOURCE_FILE);
|
|
28
|
+
if (!existsSync(sourcePath)) {
|
|
29
|
+
return {
|
|
30
|
+
mode: "local",
|
|
31
|
+
type: "local",
|
|
32
|
+
source: LOCAL_BACKEND_SOURCE,
|
|
33
|
+
projected: `${MANAGED_MARKER}\n\n${LOCAL_BACKEND_SOURCE}`,
|
|
34
|
+
fingerprint: backendFingerprint(LOCAL_BACKEND_SOURCE),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
let source;
|
|
38
|
+
try {
|
|
39
|
+
source = await readFile(sourcePath, "utf8");
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
throw new WorkspaceBackendError(`could not read backend.tf at ${sourcePath}: ${error.message}`);
|
|
43
|
+
}
|
|
44
|
+
let type;
|
|
45
|
+
try {
|
|
46
|
+
type = (await inspectBackendHcl(source)).type;
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
throw new WorkspaceBackendError(`invalid backend.tf at ${sourcePath}: ${error.message}`);
|
|
50
|
+
}
|
|
51
|
+
const normalized = source.endsWith("\n") ? source : `${source}\n`;
|
|
52
|
+
const projected = `${MANAGED_MARKER}\n\n${normalized}`;
|
|
53
|
+
return {
|
|
54
|
+
mode: "declared",
|
|
55
|
+
type,
|
|
56
|
+
sourcePath,
|
|
57
|
+
source,
|
|
58
|
+
projected,
|
|
59
|
+
fingerprint: backendFingerprint(normalized),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Project the workspace-owned backend source into a generated Terraform
|
|
64
|
+
* working directory. The marker makes the copy build-owned; the org-root
|
|
65
|
+
* source remains the only file users edit.
|
|
66
|
+
*/
|
|
67
|
+
export async function materializeWorkspaceBackend(backend, tfDir) {
|
|
68
|
+
const destination = join(tfDir, BACKEND_SOURCE_FILE);
|
|
69
|
+
await mkdir(tfDir, { recursive: true });
|
|
70
|
+
if (!existsSync(destination) || (await readFile(destination, "utf8")) !== backend.projected) {
|
|
71
|
+
await writeFile(destination, backend.projected, "utf8");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export function backendFingerprintPath(tfDir) {
|
|
75
|
+
return join(tfDir, ".terraform", BACKEND_FINGERPRINT_FILE);
|
|
76
|
+
}
|
|
77
|
+
export function assertNoUnmigratedLocalState(backend, orgRoot) {
|
|
78
|
+
const localStatePath = join(orgRoot, "terraform.tfstate");
|
|
79
|
+
if (backend.mode === "declared" && existsSync(localStatePath)) {
|
|
80
|
+
throw new WorkspaceBackendError(`backend.tf declares remote backend "${backend.type}", but ${localStatePath} still exists — ` +
|
|
81
|
+
`run \`elementum migrate backend '${orgRoot}' --check\` before using remote state`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
export async function requireWorkspaceBackend(orgRoot, _operation) {
|
|
85
|
+
const backend = await loadWorkspaceBackend(orgRoot);
|
|
86
|
+
assertNoUnmigratedLocalState(backend, orgRoot);
|
|
87
|
+
return backend;
|
|
88
|
+
}
|
|
89
|
+
export async function assertBackendBindingUnchanged(backend, orgRoot) {
|
|
90
|
+
const fingerprintPath = backendFingerprintPath(join(orgRoot, ".tf", "out"));
|
|
91
|
+
let stored;
|
|
92
|
+
try {
|
|
93
|
+
stored = (await readFile(fingerprintPath, "utf8")).trim();
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
if (error.code === "ENOENT")
|
|
97
|
+
return;
|
|
98
|
+
throw new WorkspaceBackendError(`could not read backend fingerprint at ${fingerprintPath}: ${error.message}`);
|
|
99
|
+
}
|
|
100
|
+
if (stored !== backend.fingerprint) {
|
|
101
|
+
throw new WorkspaceBackendError(`backend.tf changed since .tf/out was initialized — run ` +
|
|
102
|
+
`\`elementum migrate backend '${orgRoot}' --check\` before pull/plan/apply`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Marker shared by every file owned by `elementum build`. */
|
|
2
|
+
export const MANAGED_MARKER = "# Managed by elementum build v1 — do not edit.";
|
|
3
|
+
const LEGACY_MANAGED_MARKER = "# Managed by edk build v1 — do not edit.";
|
|
4
|
+
export function isManagedFile(content) {
|
|
5
|
+
return content.startsWith(MANAGED_MARKER) || content.startsWith(LEGACY_MANAGED_MARKER);
|
|
6
|
+
}
|
|
@@ -307,8 +307,8 @@ function stamp(url, _root) {
|
|
|
307
307
|
/**
|
|
308
308
|
* This import must be Node's, not a bundler's. Vite's SSR transform rewrites
|
|
309
309
|
* `import()` into its own module runner, which resolves authored files
|
|
310
|
-
* through Vite and never consults the hooks above
|
|
311
|
-
*
|
|
310
|
+
* through Vite and never consults the hooks above, so any bundler must
|
|
311
|
+
* externalize this module to exercise the loader the CLI ships.
|
|
312
312
|
*/
|
|
313
313
|
async function nativeImport(specifier) {
|
|
314
314
|
return (await import(specifier));
|
|
@@ -129,7 +129,7 @@ function fieldRefValue(token, where, ctx, target) {
|
|
|
129
129
|
// `elementCatalog` (see `FieldRef`'s doc comment) — but a field's own
|
|
130
130
|
// `.ref()` on ITS OWN app/element stamps `parent` (as a self-reference)
|
|
131
131
|
// without `parentKind` at all (a real, common shape — see e.g.
|
|
132
|
-
//
|
|
132
|
+
// the former update-record-tool fixture literals), so
|
|
133
133
|
// only a parent naming something OTHER than the tool's owning app is
|
|
134
134
|
// genuinely ambiguous. Defaulting `parentKind` to "app" THERE instead of
|
|
135
135
|
// failing loudly is the same silent-miss failure mode
|
|
@@ -26,7 +26,8 @@ import type { AppDynamicLayout } from "../dynamic-layout/build.js";
|
|
|
26
26
|
import type { AppRelationship } from "../relationship/build.js";
|
|
27
27
|
import type { AppWidget } from "../widget/build.js";
|
|
28
28
|
import type { DashboardWidget } from "../dashboard/build.js";
|
|
29
|
-
import type { AppRole } from "../role/build.js";
|
|
29
|
+
import type { AppRole, RoleUserRef } from "../role/build.js";
|
|
30
|
+
import type { GroupRef } from "../../catalog/index.js";
|
|
30
31
|
import type { AppServiceAccount } from "../service-account/build.js";
|
|
31
32
|
import type { Filter } from "../shared/filters/types.js";
|
|
32
33
|
import { type DisplayBlock } from "./display-blocks.js";
|
|
@@ -168,6 +169,20 @@ export interface AppField {
|
|
|
168
169
|
readonly relatedLabelField?: FieldRef | UnsafePlatformId;
|
|
169
170
|
/** `RELATION` only. Defaults to `true` on the platform. */
|
|
170
171
|
readonly autoRelate?: boolean;
|
|
172
|
+
/**
|
|
173
|
+
* `GROUP` / `USER` only — restrict the picker (edk#1776). On a group field,
|
|
174
|
+
* only these groups can be picked; on a user field, only their members.
|
|
175
|
+
* `[]` removes a live restriction. Leaving it out over a live restriction
|
|
176
|
+
* fails the plan: pull to adopt it, or clear it explicitly.
|
|
177
|
+
*/
|
|
178
|
+
readonly allowedGroups?: readonly GroupRef[];
|
|
179
|
+
/** `USER` only — users that can be picked besides `allowedGroups` members. `[]` removes a live restriction. */
|
|
180
|
+
readonly allowedUsers?: readonly RoleUserRef[];
|
|
181
|
+
/**
|
|
182
|
+
* `USER` only — a group field on the same app/element. The picker then
|
|
183
|
+
* offers only members of the group selected there. `null` removes a live link.
|
|
184
|
+
*/
|
|
185
|
+
readonly parentGroupField?: FieldRef<string, string, "GROUP" | "GROUP_ID"> | null;
|
|
171
186
|
}
|
|
172
187
|
/** @deprecated Use `DropdownOption` and `dropdownOption(...)`. */
|
|
173
188
|
export interface PicklistOption {
|
|
@@ -224,6 +239,21 @@ export interface AppSystemFieldOverride {
|
|
|
224
239
|
export interface AppSystemPicklistOverride extends AppSystemFieldOverride {
|
|
225
240
|
readonly options: readonly (string | PicklistOption)[];
|
|
226
241
|
}
|
|
242
|
+
/** The stage override: like {@link AppSystemPicklistOverride}, but options may carry a stage `key`. */
|
|
243
|
+
export interface AppStagePicklistOverride extends AppSystemFieldOverride {
|
|
244
|
+
readonly options: readonly (string | AppStageOption)[];
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* A stage option. `key` is the Terraform alias the stage carries in
|
|
248
|
+
* `stages[].key` / `stage_ids_by_key`. Omit it for authored apps (the key
|
|
249
|
+
* derives from the label via `snakeSlug`). Pull writes it only when an
|
|
250
|
+
* imported stage's existing alias differs from that derivation (e.g.
|
|
251
|
+
* `"approval_&_execution"` for "Approval & Execution"), so an unchanged
|
|
252
|
+
* imported app keeps its stage identity on rebuild (#1136).
|
|
253
|
+
*/
|
|
254
|
+
export interface AppStageOption extends PicklistOption {
|
|
255
|
+
readonly key?: string;
|
|
256
|
+
}
|
|
227
257
|
/**
|
|
228
258
|
* Overrides for the platform's auto-provisioned system fields, keyed by their
|
|
229
259
|
* canonical ref names. Every entry (and the whole bag) is optional — author
|
|
@@ -236,7 +266,7 @@ export interface AppSystemFields {
|
|
|
236
266
|
readonly id?: AppSystemFieldOverride;
|
|
237
267
|
readonly title?: AppSystemFieldOverride;
|
|
238
268
|
readonly status?: AppSystemPicklistOverride;
|
|
239
|
-
readonly stage?:
|
|
269
|
+
readonly stage?: AppStagePicklistOverride;
|
|
240
270
|
readonly createdAt?: AppSystemFieldOverride;
|
|
241
271
|
readonly createdBy?: AppSystemFieldOverride;
|
|
242
272
|
readonly updatedAt?: AppSystemFieldOverride;
|
|
@@ -542,9 +572,11 @@ interface AppV2OptionsBase<F extends Record<string, AppField> = Record<string, A
|
|
|
542
572
|
* else. Matching on the bag key instead of `name` is what lets a field's
|
|
543
573
|
* identity survive a display-`name` rename instead of being keyed by the
|
|
544
574
|
* mutable `name` (#230); the bag key itself is never rewritten by a rename,
|
|
545
|
-
* since it's just the field's fixed key in `fields: {}`.
|
|
575
|
+
* since it's just the field's fixed key in `fields: {}`. `owner` (e.g.
|
|
576
|
+
* `app "Vendor Onboarding"`) only labels authoring errors, so fields that
|
|
577
|
+
* share a display name in different owners can be told apart.
|
|
546
578
|
*/
|
|
547
|
-
export declare function serializeField(field: AppField, refName?: string): AspectFieldInput;
|
|
579
|
+
export declare function serializeField(field: AppField, refName?: string, owner?: string): AspectFieldInput;
|
|
548
580
|
/**
|
|
549
581
|
* Reject a custom `fields:` bag key that is ALSO authored under
|
|
550
582
|
* `systemFields` — the same slot provisioned twice. Keys not present in
|
|
@@ -3,6 +3,7 @@ import { DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES, SYSTEM_FIELD_KEYS, SYSTEM_FIELD_REQU
|
|
|
3
3
|
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
|
+
import { assertFieldAllowList } from "../field/allow-list.js";
|
|
6
7
|
/** Where a classic layout section renders: the main area or the record side panel. */
|
|
7
8
|
export const layoutSectionDisplayLocation = {
|
|
8
9
|
center: "CENTER",
|
|
@@ -99,6 +100,11 @@ function assertSystemFieldRules(field) {
|
|
|
99
100
|
function shouldSerializePicklistOptions(field) {
|
|
100
101
|
return field.type === "PICKLIST" || field.type === "MULTI_PICKLIST";
|
|
101
102
|
}
|
|
103
|
+
/** A stage option's wire value; only stages carry the explicit `key` alias (#1136). */
|
|
104
|
+
function stagePicklistValue(opt) {
|
|
105
|
+
const value = picklistValue(opt);
|
|
106
|
+
return typeof opt !== "string" && opt.key !== undefined ? { ...value, __stageKey: opt.key } : value;
|
|
107
|
+
}
|
|
102
108
|
function picklistValue(opt) {
|
|
103
109
|
if (typeof opt === "string")
|
|
104
110
|
return { value: opt, label: opt };
|
|
@@ -123,6 +129,47 @@ function unwrapUnsafePlatformIds(value) {
|
|
|
123
129
|
}
|
|
124
130
|
return value;
|
|
125
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* The refs a dynamic Dropdown or Multi-Select names directly in
|
|
134
|
+
* `config.dynamic` must be present (edk#1780): `source`, `label`,
|
|
135
|
+
* `parent.field`, each `parent.mappings[i]` side and each `sort[i].field`. A
|
|
136
|
+
* catalog path to a field or app/element/task that was removed or renamed (or
|
|
137
|
+
* added without re-running `elementum generate`) evaluates to `undefined`; the
|
|
138
|
+
* TF emitter then drops the whole dynamic config, omits the field resource,
|
|
139
|
+
* 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. `filter`
|
|
141
|
+
* operands are NOT checked here (out of scope for #1780).
|
|
142
|
+
*/
|
|
143
|
+
function assertDynamicPicklistRefs(field, dynamic, refName, owner) {
|
|
144
|
+
const typeLabel = field.type === "MULTI_PICKLIST" ? "Multi-Select" : "Dropdown";
|
|
145
|
+
const where = `${owner !== undefined ? `${owner} ` : ""}${refName !== undefined ? `fields.${refName}` : "field"} ` +
|
|
146
|
+
`(${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
|
+
`or task was removed or renamed, or it was just added and the catalog hasn't been regenerated (run ` +
|
|
150
|
+
`\`elementum generate\`, then build again). Building would drop this field's dynamic config and the plan ` +
|
|
151
|
+
`would destroy the field; fix or remove the ref.`);
|
|
152
|
+
};
|
|
153
|
+
if (dynamic.relatedAspectId == null)
|
|
154
|
+
missing("config.dynamic.source");
|
|
155
|
+
if (dynamic.relatedLabelFieldId == null)
|
|
156
|
+
missing("config.dynamic.label");
|
|
157
|
+
if (Object.hasOwn(dynamic, "parentFieldId") && dynamic.parentFieldId == null)
|
|
158
|
+
missing("config.dynamic.parent.field");
|
|
159
|
+
dynamic.parentMappings?.forEach((mapping, i) => {
|
|
160
|
+
if (mapping.parentAspectFieldId == null)
|
|
161
|
+
missing(`config.dynamic.parent.mappings[${i}].parentSourceField`);
|
|
162
|
+
if (mapping.relatedAspectFieldId == null)
|
|
163
|
+
missing(`config.dynamic.parent.mappings[${i}].sourceField`);
|
|
164
|
+
});
|
|
165
|
+
const orders = dynamic.sort?.orders;
|
|
166
|
+
if (Array.isArray(orders)) {
|
|
167
|
+
orders.forEach((order, i) => {
|
|
168
|
+
if (order.field == null)
|
|
169
|
+
missing(`config.dynamic.sort[${i}].field`);
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
}
|
|
126
173
|
/**
|
|
127
174
|
* Serialize an authored field to its `AspectFieldInput` wire shape — shared
|
|
128
175
|
* with `element`. `refName` is the field's bag key in `app`'s
|
|
@@ -134,9 +181,11 @@ function unwrapUnsafePlatformIds(value) {
|
|
|
134
181
|
* else. Matching on the bag key instead of `name` is what lets a field's
|
|
135
182
|
* identity survive a display-`name` rename instead of being keyed by the
|
|
136
183
|
* mutable `name` (#230); the bag key itself is never rewritten by a rename,
|
|
137
|
-
* since it's just the field's fixed key in `fields: {}`.
|
|
184
|
+
* since it's just the field's fixed key in `fields: {}`. `owner` (e.g.
|
|
185
|
+
* `app "Vendor Onboarding"`) only labels authoring errors, so fields that
|
|
186
|
+
* share a display name in different owners can be told apart.
|
|
138
187
|
*/
|
|
139
|
-
export function serializeField(field, refName) {
|
|
188
|
+
export function serializeField(field, refName, owner) {
|
|
140
189
|
assertSystemFieldRules(field);
|
|
141
190
|
const key = TYPE_TO_KEY[field.type] ?? "text";
|
|
142
191
|
const base = {
|
|
@@ -172,6 +221,8 @@ export function serializeField(field, refName) {
|
|
|
172
221
|
base.picklistValues = field.options.map(picklistValue);
|
|
173
222
|
}
|
|
174
223
|
if (field.config !== undefined) {
|
|
224
|
+
if (field.config.dynamic !== undefined)
|
|
225
|
+
assertDynamicPicklistRefs(field, field.config.dynamic, refName, owner);
|
|
175
226
|
base.config = unwrapUnsafePlatformIds(field.config);
|
|
176
227
|
}
|
|
177
228
|
else if (field.parentField !== undefined) {
|
|
@@ -195,6 +246,18 @@ export function serializeField(field, refName) {
|
|
|
195
246
|
if ((key === "text" || key === "html") && field.qrFormat !== undefined) {
|
|
196
247
|
base.format = field.qrFormat;
|
|
197
248
|
}
|
|
249
|
+
if (key === "group" || key === "user") {
|
|
250
|
+
assertFieldAllowList(field, key);
|
|
251
|
+
if (field.allowedGroups !== undefined)
|
|
252
|
+
base.allowedGroups = [...field.allowedGroups];
|
|
253
|
+
if (key === "user" && field.allowedUsers !== undefined)
|
|
254
|
+
base.allowedUsers = [...field.allowedUsers];
|
|
255
|
+
if (key === "user" && field.parentGroupField !== undefined)
|
|
256
|
+
base.parentGroupField = field.parentGroupField;
|
|
257
|
+
}
|
|
258
|
+
else if (field.allowedGroups !== undefined || field.allowedUsers !== undefined || field.parentGroupField !== undefined) {
|
|
259
|
+
throw new Error(`field "${field.name}": allowedGroups, allowedUsers and parentGroupField are only valid on group and user fields.`);
|
|
260
|
+
}
|
|
198
261
|
if (key === "relation") {
|
|
199
262
|
if (field.relatedObject !== undefined)
|
|
200
263
|
base.relatedObject = unwrapUnsafePlatformIds(field.relatedObject);
|
|
@@ -257,7 +320,7 @@ export function serializeSystemFields(overrides) {
|
|
|
257
320
|
...flags,
|
|
258
321
|
tags: [tag],
|
|
259
322
|
__refName: key,
|
|
260
|
-
picklistValues: override.options.map(
|
|
323
|
+
picklistValues: override.options.map(stagePicklistValue),
|
|
261
324
|
},
|
|
262
325
|
};
|
|
263
326
|
}
|
|
@@ -508,7 +571,7 @@ export function app(opts) {
|
|
|
508
571
|
...(opts.autoShare !== undefined ? { autoShare: opts.autoShare } : {}),
|
|
509
572
|
fields: [
|
|
510
573
|
...serializeSystemFields(opts.systemFields),
|
|
511
|
-
...Object.entries(opts.fields).map(([bagKey, field]) => serializeField(field, bagKey)),
|
|
574
|
+
...Object.entries(opts.fields).map(([bagKey, field]) => serializeField(field, bagKey, `app ${JSON.stringify(opts.name)}`)),
|
|
512
575
|
],
|
|
513
576
|
...(displayBlocks !== undefined ? { displayBlocks } : {}),
|
|
514
577
|
...(recordCreateDisplayBlocks !== undefined ? { recordCreateDisplayBlocks } : {}),
|
|
@@ -39,6 +39,12 @@ export interface NormalizedField {
|
|
|
39
39
|
readonly calculationInclude?: "manual" | "both" | {
|
|
40
40
|
readonly picklistFieldId: string;
|
|
41
41
|
};
|
|
42
|
+
/**
|
|
43
|
+
* User fields only (edk#1776): the same-owner group field whose selected
|
|
44
|
+
* group's members are the only pickable users. A bag key, resolved by the
|
|
45
|
+
* printer to a hoisted FieldRef const; `null` = an explicit clear.
|
|
46
|
+
*/
|
|
47
|
+
readonly parentGroupFieldKey?: string | null;
|
|
42
48
|
/**
|
|
43
49
|
* Side-channel pull annotation for dependent-picklist linkage.
|
|
44
50
|
* Typed-ref `parentField` / `parentValues` on the runtime AppField
|
|
@@ -215,6 +221,12 @@ export interface NormalizedWidgetRef {
|
|
|
215
221
|
readonly kind: "app" | "element" | "task" | "automation" | "field" | "recordIdentity";
|
|
216
222
|
readonly key: string;
|
|
217
223
|
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;
|
|
218
230
|
readonly parent?: string;
|
|
219
231
|
readonly fieldType?: string;
|
|
220
232
|
readonly target?: NormalizedWidgetRef;
|
|
@@ -11,7 +11,7 @@ import { autoShareFromTf } from "./auto-share.js";
|
|
|
11
11
|
import { DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES, SYSTEM_FIELD_KEYS, SYSTEM_FIELD_KEY_BY_HCL_KEY, SYSTEM_FIELD_TAG_BY_KEY, } from "../../core/system-fields.js";
|
|
12
12
|
import { EntityTfError } from "../../engine/entity.js";
|
|
13
13
|
import { dataRefLabel, optionalString, plainObject } from "../../engine/pull/context.js";
|
|
14
|
-
import {
|
|
14
|
+
import { tfLabelToTsLabel } from "../../engine/tf/index.js";
|
|
15
15
|
import { 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";
|
|
@@ -24,6 +24,7 @@ import { serviceAccountsFromTf } from "../service-account/from-tf.js";
|
|
|
24
24
|
import { 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
|
+
import { stageHandleIndex } from "./stage-keys.js";
|
|
27
28
|
/** Attributes `appFromTf` understands — anything else is dialect growth, reported loudly. */
|
|
28
29
|
const KNOWN_APP_ATTRS = new Set([
|
|
29
30
|
"name",
|
|
@@ -196,12 +197,9 @@ export function appFromTf(appBlock, fieldBlocks, ctx, viewBlocks = { layoutBlock
|
|
|
196
197
|
ctx.diagnostics.push(`app "${label}": stages item has an unrecognized shape; dropped`);
|
|
197
198
|
continue;
|
|
198
199
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
// differ there. Surface it now instead of failing the build-vs-export blind.
|
|
203
|
-
ctx.diagnostics.push(`app "${label}": stage "${stageName}" has key "${stageKey}" but build derives "${snakeSlug(stageName)}" — was the stage renamed on the platform?`);
|
|
204
|
-
}
|
|
200
|
+
// A stream key that isn't snakeSlug(name) (imported punctuation keys
|
|
201
|
+
// like "approval_&_execution") is carried verbatim: print emits it as
|
|
202
|
+
// the stage option's `key`, and build uses it instead of re-deriving (#1136).
|
|
205
203
|
stages.push({ key: stageKey, stage: { id: "", name: stageName } });
|
|
206
204
|
}
|
|
207
205
|
}
|
|
@@ -214,14 +212,20 @@ export function appFromTf(appBlock, fieldBlocks, ctx, viewBlocks = { layoutBlock
|
|
|
214
212
|
if (appId === undefined) {
|
|
215
213
|
ctx.diagnostics.push(`app "${label}": no import block in the stream — adoption has no identity to bind`);
|
|
216
214
|
}
|
|
215
|
+
// One stage-handle map for every stage reference this app pulls (#1136).
|
|
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
218
|
const dashboards = dashboardsFromTf(viewBlocks.dashboardBlocks, viewBlocks.dashboardWidgetBlocks, { type: APP_RESOURCE_TYPE, label, ownerTfLabel: refName, ownerRefName: refName, scope: "app", ownerType: "APP_ASPECT" }, ctx);
|
|
219
|
-
const { layouts, listViews, calendarViews, kanbanViews, dashboardViews, agentViews, customViews, viewOrder } = viewsFromTf(viewBlocks.layoutBlocks, viewBlocks.listViewBlocks, viewBlocks.calendarViewBlocks, viewBlocks.kanbanViewBlocks, viewBlocks.dashboardViewBlocks, viewBlocks.agentViewBlocks, viewBlocks.managedViewOrderBlocks, {
|
|
219
|
+
const { layouts, listViews, calendarViews, kanbanViews, dashboardViews, agentViews, customViews, viewOrder } = viewsFromTf(viewBlocks.layoutBlocks, viewBlocks.listViewBlocks, viewBlocks.calendarViewBlocks, viewBlocks.kanbanViewBlocks, viewBlocks.dashboardViewBlocks, viewBlocks.agentViewBlocks, viewBlocks.managedViewOrderBlocks, {
|
|
220
|
+
type: APP_RESOURCE_TYPE, label, ownerTfLabel: label, scope: "app",
|
|
221
|
+
stageKeys: stageHandles.keys,
|
|
222
|
+
stageKeyByHandle: stageHandles.byHandle,
|
|
223
|
+
}, ctx, viewBlocks.customViewBlocks);
|
|
220
224
|
if (viewBlocks.recordCreateFormBlocks.length > 1) {
|
|
221
225
|
ctx.diagnostics.push(`app "${label}": found ${viewBlocks.recordCreateFormBlocks.length} record create forms; only the first is used`);
|
|
222
226
|
}
|
|
223
227
|
const recordCreateForm = recordCreateFormFromTf(viewBlocks.recordCreateFormBlocks[0], { type: APP_RESOURCE_TYPE, label, ownerTfLabel: refName, scope: "app" }, ctx);
|
|
224
|
-
const dynamicLayoutOwner = { type: APP_RESOURCE_TYPE, label, ownerRefName: refName, ownerTfLabel: label };
|
|
228
|
+
const dynamicLayoutOwner = { type: APP_RESOURCE_TYPE, label, ownerRefName: refName, ownerTfLabel: label, stageHandles };
|
|
225
229
|
const dynamicLayouts = dynamicLayoutsFromTf(viewBlocks.dynamicLayoutBlocks, dynamicLayoutOwner, ctx);
|
|
226
230
|
const relationships = relationshipsFromTf(viewBlocks.relationshipBlocks, { kind: "app", label, ownerRefName: refName, ownerTfLabel: refName, scope: "app" }, ctx);
|
|
227
231
|
const widgets = widgetsFromTf(viewBlocks.widgetBlocks, { type: APP_RESOURCE_TYPE, label, ownerRefName: refName, ownerTfLabel: label, scope: "app" }, ctx, dynamicLayoutCompanionWidgetLabels(viewBlocks.dynamicLayoutBlocks, dynamicLayoutOwner));
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { EntityTfError } from "../../engine/entity.js";
|
|
2
|
+
import { type PicklistValueWire } from "../field/options.js";
|
|
3
|
+
/** One app stage as build emits it: the real `stage_ids_by_key` key and its display name. */
|
|
4
|
+
export interface AppStageKey {
|
|
5
|
+
readonly key: string;
|
|
6
|
+
readonly name: string;
|
|
7
|
+
}
|
|
8
|
+
/** The provider's default stages when an app authors none. */
|
|
9
|
+
export declare const DEFAULT_APP_STAGES: readonly AppStageKey[];
|
|
10
|
+
/** A stage's real key: the imported alias when pull kept one, otherwise `snakeSlug(label)`. */
|
|
11
|
+
export declare function stageKeyFromPicklistValue(pv: PicklistValueWire): AppStageKey;
|
|
12
|
+
/**
|
|
13
|
+
* Every tf-label handle that authored source or pull can use for a stage,
|
|
14
|
+
* mapped to the stage's real `stage_ids_by_key` key (#1136). A layout bag key,
|
|
15
|
+
* a dynamic-layout `stage`, an approval chain `stage` or a visual-flow
|
|
16
|
+
* `stage` resolves through this map. Handles:
|
|
17
|
+
* - the real key itself, when it is a tf label. This covers renamed stages
|
|
18
|
+
* (`legacy_key` for "Renamed stage") and keys such as `foo__bar` that are
|
|
19
|
+
* legal tf labels but not the slug;
|
|
20
|
+
* - `snakeSlug(key)`, when the real key keeps punctuation
|
|
21
|
+
* (`enrichment_&_validation` -> `enrichment_validation`), which is the
|
|
22
|
+
* handle pull writes for it;
|
|
23
|
+
* - `snakeSlug(name)`, the handle authored apps use;
|
|
24
|
+
* - `SanitizeName(name)`, ei's classic-layout label, only where no other
|
|
25
|
+
* handle claimed it.
|
|
26
|
+
*
|
|
27
|
+
* A stage's own key always wins over a derived handle. When two stages
|
|
28
|
+
* derive the same handle, the first keeps it and a diagnostic says so,
|
|
29
|
+
* instead of silently rebinding. A stage left with no handle that maps to
|
|
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. Pull never
|
|
32
|
+
* writes another stage's handle for it: see {@link pulledStageHandle}.
|
|
33
|
+
*/
|
|
34
|
+
export declare function stageKeyByHandle(stages: readonly AppStageKey[], diagnostics?: string[]): Map<string, string>;
|
|
35
|
+
/** An app's stage handles plus its real stage keys, for pull-side resolution (#1136). */
|
|
36
|
+
export interface StageHandleIndex {
|
|
37
|
+
readonly byHandle: ReadonlyMap<string, string>;
|
|
38
|
+
readonly keys: ReadonlySet<string>;
|
|
39
|
+
}
|
|
40
|
+
/** {@link stageKeyByHandle} plus the real key set. */
|
|
41
|
+
export declare function stageHandleIndex(stages: readonly AppStageKey[], diagnostics?: string[]): StageHandleIndex;
|
|
42
|
+
/** The stage handles of an `elementum_app` block's `stages` attribute, or undefined when it has none. */
|
|
43
|
+
export declare function stageHandleIndexFromTfStages(value: unknown): StageHandleIndex | undefined;
|
|
44
|
+
export type PulledStageHandle = {
|
|
45
|
+
readonly kind: "handle";
|
|
46
|
+
readonly handle: string;
|
|
47
|
+
}
|
|
48
|
+
/** The stage's only handle is another stage's: pull must not write it. */
|
|
49
|
+
| {
|
|
50
|
+
readonly kind: "lost";
|
|
51
|
+
readonly handle: string;
|
|
52
|
+
readonly owner: string;
|
|
53
|
+
} | {
|
|
54
|
+
readonly kind: "none";
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* The handle pull writes for a `stage_ids_by_key` index (#1136): one that
|
|
58
|
+
* build maps back to this same stage. Prefers `stageHandleTfLabel(index)`,
|
|
59
|
+
* then any other handle bound to the stage. When the stage has none (its
|
|
60
|
+
* slug is another stage's own key, e.g. `pre-approval` next to
|
|
61
|
+
* `pre_approval`), returns `lost`: writing that handle would bind the
|
|
62
|
+
* reference to the other stage on build, so the caller leaves the
|
|
63
|
+
* reference out with a diagnostic instead. Without an index (or for an
|
|
64
|
+
* index that is not one of the app's stages) this is `stageHandleTfLabel`.
|
|
65
|
+
*/
|
|
66
|
+
export declare function pulledStageHandle(index: string, stages: StageHandleIndex | undefined): PulledStageHandle;
|
|
67
|
+
/**
|
|
68
|
+
* Thrown by an own-file extractor whose resource is left unmanaged because
|
|
69
|
+
* its stage lost its only handle (#1136). The extractor skips the resource
|
|
70
|
+
* AND releases it from state if an earlier pull adopted it, so the next plan
|
|
71
|
+
* does not destroy the live resource.
|
|
72
|
+
*/
|
|
73
|
+
export declare class LostStageHandleError extends EntityTfError {
|
|
74
|
+
constructor(message: string);
|
|
75
|
+
}
|
|
76
|
+
/** The per-reference warning for a `lost` {@link pulledStageHandle}. */
|
|
77
|
+
export declare function lostStageMessage(where: string, index: string, lost: {
|
|
78
|
+
readonly handle: string;
|
|
79
|
+
readonly owner: string;
|
|
80
|
+
}, outcome: string): string;
|
|
81
|
+
/** The owning app's stage handles (see {@link stageKeyByHandle}) from its built payload, for child entities. */
|
|
82
|
+
export declare function appStageKeyByHandle(payload: unknown): Map<string, string> | undefined;
|