@elementumai/edk 0.9.2 → 0.9.6
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 +34 -26
- package/dist-sdk/elementum-entity-client/clients/automation/models/automation.d.ts +1 -1
- package/dist-sdk/elementum-entity-client/clients/skills/models/skill.d.ts +1 -1
- package/dist-sdk/elementum-entity-client/clients/skills/models/skill.js +1 -1
- package/dist-sdk/pull/util.d.ts +1 -1
- package/dist-sdk/pull/util.js +3 -3
- package/dist-sdk/src/catalog/factories.d.ts +49 -10
- package/dist-sdk/src/catalog/factories.js +94 -13
- package/dist-sdk/src/catalog/from-authoring.d.ts +5 -5
- package/dist-sdk/src/catalog/from-authoring.js +7 -7
- package/dist-sdk/src/catalog/index.d.ts +2 -2
- package/dist-sdk/src/catalog/index.js +1 -1
- package/dist-sdk/src/catalog/org.js +62 -4
- package/dist-sdk/src/catalog/render-helpers.d.ts +1 -1
- package/dist-sdk/src/catalog/render-helpers.js +1 -1
- package/dist-sdk/src/catalog/render.d.ts +1 -0
- package/dist-sdk/src/catalog/render.js +2 -2
- package/dist-sdk/src/catalog/token.js +11 -4
- package/dist-sdk/src/catalog/types.d.ts +33 -4
- package/dist-sdk/src/catalog/types.js +5 -0
- package/dist-sdk/src/core/index.d.ts +10 -10
- package/dist-sdk/src/core/index.js +9 -9
- package/dist-sdk/src/core/render-tree.d.ts +1 -1
- package/dist-sdk/src/core/render-tree.js +1 -2
- package/dist-sdk/src/core/types/ai-provider.d.ts +1 -1
- package/dist-sdk/src/core/types/ai-provider.js +1 -1
- package/dist-sdk/src/core/types/app.d.ts +66 -30
- package/dist-sdk/src/core/types/app.js +2 -2
- package/dist-sdk/src/core/types/aspect-category.d.ts +4 -4
- package/dist-sdk/src/core/types/aspect-category.js +4 -4
- package/dist-sdk/src/core/types/cloud-link.d.ts +3 -3
- package/dist-sdk/src/core/types/cloud-link.js +3 -3
- package/dist-sdk/src/core/types/display-block.d.ts +2 -2
- package/dist-sdk/src/core/types/display-block.js +2 -2
- package/dist-sdk/src/core/types/group.d.ts +1 -1
- package/dist-sdk/src/core/types/group.js +1 -1
- package/dist-sdk/src/core/types/user.d.ts +1 -1
- package/dist-sdk/src/core/types/user.js +1 -1
- package/dist-sdk/src/core/wire/ref-serializer.js +3 -3
- package/dist-sdk/src/engine/build/context.d.ts +20 -13
- package/dist-sdk/src/engine/entity.d.ts +1 -1
- package/dist-sdk/src/engine/pull/context.d.ts +34 -0
- package/dist-sdk/src/engine/pull/context.js +14 -0
- package/dist-sdk/src/engine/pull/org.d.ts +9 -0
- package/dist-sdk/src/engine/pull/org.js +33 -0
- package/dist-sdk/src/engine/pull/ref-only.d.ts +37 -0
- package/dist-sdk/src/engine/pull/ref-only.js +204 -0
- package/dist-sdk/src/engine/tf/expr.d.ts +6 -2
- package/dist-sdk/src/engine/tf/expr.js +18 -13
- 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/model.d.ts +8 -1
- package/dist-sdk/src/engine/tf/model.js +4 -0
- package/dist-sdk/src/engine/tf/parse.js +13 -2
- package/dist-sdk/src/engine/tf/render.js +4 -0
- package/dist-sdk/src/entities/access-policy/build.d.ts +4 -5
- package/dist-sdk/src/entities/access-policy/build.js +1 -1
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +4 -4
- package/dist-sdk/src/entities/access-policy/from-tf.js +12 -13
- package/dist-sdk/src/entities/access-policy/principal.d.ts +14 -4
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +14 -2
- package/dist-sdk/src/entities/access-policy/to-tf.js +36 -6
- package/dist-sdk/src/entities/agent/build.d.ts +3 -3
- package/dist-sdk/src/entities/agent/build.js +5 -5
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +6 -1
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +68 -18
- package/dist-sdk/src/entities/agent/from-tf.d.ts +3 -1
- package/dist-sdk/src/entities/agent/from-tf.js +12 -4
- package/dist-sdk/src/entities/agent/index.d.ts +2 -2
- package/dist-sdk/src/entities/agent/index.js +1 -1
- package/dist-sdk/src/entities/agent/module.js +2 -0
- package/dist-sdk/src/entities/agent/to-tf.d.ts +5 -2
- package/dist-sdk/src/entities/agent/to-tf.js +56 -8
- package/dist-sdk/src/entities/agent/tools.d.ts +38 -23
- package/dist-sdk/src/entities/agent/tools.js +21 -7
- package/dist-sdk/src/entities/agent-evaluation/build.d.ts +19 -0
- package/dist-sdk/src/entities/agent-evaluation/build.js +41 -0
- package/dist-sdk/src/entities/agent-evaluation/deserializer/print-agent-evaluation.d.ts +4 -0
- package/dist-sdk/src/entities/agent-evaluation/deserializer/print-agent-evaluation.js +30 -0
- package/dist-sdk/src/entities/agent-evaluation/from-tf.d.ts +12 -0
- package/dist-sdk/src/entities/agent-evaluation/from-tf.js +46 -0
- package/dist-sdk/src/entities/agent-evaluation/index.d.ts +1 -0
- package/dist-sdk/src/entities/agent-evaluation/index.js +1 -0
- package/dist-sdk/src/entities/agent-evaluation/module.d.ts +3 -0
- package/dist-sdk/src/entities/agent-evaluation/module.js +58 -0
- package/dist-sdk/src/entities/agent-evaluation/to-tf.d.ts +12 -0
- package/dist-sdk/src/entities/agent-evaluation/to-tf.js +35 -0
- package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +8 -7
- package/dist-sdk/src/entities/agent-tool/from-tf.js +48 -6
- package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +10 -2
- package/dist-sdk/src/entities/agent-tool/to-tf.js +76 -28
- package/dist-sdk/src/entities/agent-tool/types.d.ts +0 -1
- package/dist-sdk/src/entities/agent-tool/types.js +10 -37
- package/dist-sdk/src/entities/app/build.d.ts +97 -42
- package/dist-sdk/src/entities/app/build.js +25 -14
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +32 -24
- package/dist-sdk/src/entities/app/deserializer/pulled-expression.d.ts +1 -1
- package/dist-sdk/src/entities/app/deserializer/pulled-expression.js +2 -0
- package/dist-sdk/src/entities/app/index.d.ts +11 -8
- package/dist-sdk/src/entities/app/index.js +10 -7
- package/dist-sdk/src/entities/app/module.js +2 -2
- package/dist-sdk/src/entities/app/to-tf.d.ts +1 -1
- package/dist-sdk/src/entities/app/to-tf.js +22 -6
- package/dist-sdk/src/entities/approval-chain/build.d.ts +1 -1
- package/dist-sdk/src/entities/approval-chain/build.js +5 -5
- package/dist-sdk/src/entities/approval-chain/index.d.ts +1 -1
- package/dist-sdk/src/entities/approval-chain/index.js +1 -1
- package/dist-sdk/src/entities/approval-chain/printer.js +2 -2
- package/dist-sdk/src/entities/automation/build.d.ts +172 -94
- package/dist-sdk/src/entities/automation/build.js +159 -68
- package/dist-sdk/src/entities/automation/calculation-expression.d.ts +191 -0
- package/dist-sdk/src/entities/automation/calculation-expression.js +57 -0
- package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +11 -4
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +18 -14
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +164 -198
- package/dist-sdk/src/entities/automation/from-tf.d.ts +26 -2
- package/dist-sdk/src/entities/automation/from-tf.js +510 -80
- package/dist-sdk/src/entities/automation/index.d.ts +9 -12
- package/dist-sdk/src/entities/automation/index.js +11 -13
- package/dist-sdk/src/entities/automation/module.js +74 -6
- package/dist-sdk/src/entities/automation/operators.d.ts +32 -48
- package/dist-sdk/src/entities/automation/operators.js +10 -37
- package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +1 -1
- package/dist-sdk/src/entities/automation/output-key-wire-name.js +1 -1
- package/dist-sdk/src/entities/automation/script-code.js +13 -22
- package/dist-sdk/src/entities/automation/serialize.js +1 -1
- package/dist-sdk/src/entities/automation/tasks.d.ts +153 -89
- package/dist-sdk/src/entities/automation/tasks.js +64 -11
- package/dist-sdk/src/entities/automation/to-tf.d.ts +10 -1
- package/dist-sdk/src/entities/automation/to-tf.js +342 -71
- package/dist-sdk/src/entities/automation/triggers.d.ts +17 -10
- package/dist-sdk/src/entities/automation/triggers.js +7 -1
- package/dist-sdk/src/entities/automation/types.d.ts +3 -2
- package/dist-sdk/src/entities/automation/types.js +3 -2
- package/dist-sdk/src/entities/chart/build.d.ts +95 -0
- package/dist-sdk/src/entities/chart/build.js +42 -0
- package/dist-sdk/src/entities/chart/from-tf.d.ts +55 -0
- package/dist-sdk/src/entities/chart/from-tf.js +269 -0
- package/dist-sdk/src/entities/chart/index.d.ts +4 -0
- package/dist-sdk/src/entities/chart/index.js +3 -0
- package/dist-sdk/src/entities/chart/module.d.ts +3 -0
- package/dist-sdk/src/entities/chart/module.js +61 -0
- package/dist-sdk/src/entities/chart/printer.d.ts +5 -0
- package/dist-sdk/src/entities/chart/printer.js +104 -0
- package/dist-sdk/src/entities/chart/to-tf.d.ts +15 -0
- package/dist-sdk/src/entities/chart/to-tf.js +150 -0
- package/dist-sdk/src/entities/chart/types.d.ts +53 -0
- package/dist-sdk/src/entities/chart/types.js +22 -0
- package/dist-sdk/src/entities/dashboard/build.d.ts +34 -7
- package/dist-sdk/src/entities/dashboard/build.js +16 -1
- package/dist-sdk/src/entities/dashboard/from-tf.js +22 -4
- package/dist-sdk/src/entities/dashboard/to-tf.d.ts +16 -3
- package/dist-sdk/src/entities/dashboard/to-tf.js +37 -10
- package/dist-sdk/src/entities/datamine/module.js +1 -1
- package/dist-sdk/src/entities/dynamic-layout/build.d.ts +4 -3
- package/dist-sdk/src/entities/dynamic-layout/build.js +1 -1
- package/dist-sdk/src/entities/dynamic-layout/dialect.d.ts +2 -0
- package/dist-sdk/src/entities/dynamic-layout/dialect.js +43 -5
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +12 -6
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +10 -10
- package/dist-sdk/src/entities/element/build.d.ts +25 -32
- package/dist-sdk/src/entities/element/build.js +15 -32
- package/dist-sdk/src/entities/element/index.d.ts +7 -5
- package/dist-sdk/src/entities/element/index.js +7 -4
- package/dist-sdk/src/entities/element/module.js +7 -3
- package/dist-sdk/src/entities/element/to-tf.d.ts +2 -1
- package/dist-sdk/src/entities/element/to-tf.js +7 -3
- package/dist-sdk/src/entities/field/build.d.ts +51 -24
- package/dist-sdk/src/entities/field/build.js +31 -6
- package/dist-sdk/src/entities/field/calc/aggregate.d.ts +52 -21
- package/dist-sdk/src/entities/field/calc/aggregate.js +59 -29
- package/dist-sdk/src/entities/field/calc/date.d.ts +78 -29
- package/dist-sdk/src/entities/field/calc/date.js +120 -29
- package/dist-sdk/src/entities/field/calc/index.d.ts +80 -85
- package/dist-sdk/src/entities/field/calc/index.js +82 -139
- package/dist-sdk/src/entities/field/calc/numeric.d.ts +8 -12
- package/dist-sdk/src/entities/field/calc/numeric.js +10 -27
- package/dist-sdk/src/entities/field/calc/runtime.d.ts +19 -2
- package/dist-sdk/src/entities/field/calc/runtime.js +79 -8
- package/dist-sdk/src/entities/field/calc/text.d.ts +32 -23
- package/dist-sdk/src/entities/field/calc/text.js +43 -31
- package/dist-sdk/src/entities/field/calc/types.d.ts +36 -81
- package/dist-sdk/src/entities/field/calc/types.js +1 -22
- package/dist-sdk/src/entities/field/calc.d.ts +71 -48
- package/dist-sdk/src/entities/field/calc.js +5 -15
- package/dist-sdk/src/entities/field/calculation-types.js +10 -3
- package/dist-sdk/src/entities/field/from-tf.js +156 -10
- package/dist-sdk/src/entities/field/locals.d.ts +11 -3
- package/dist-sdk/src/entities/field/locals.js +15 -2
- package/dist-sdk/src/entities/field/module.js +23 -6
- package/dist-sdk/src/entities/field/record-shape.d.ts +24 -10
- package/dist-sdk/src/entities/field/to-tf.d.ts +40 -1
- package/dist-sdk/src/entities/field/to-tf.js +293 -35
- package/dist-sdk/src/entities/field/types.d.ts +1 -1
- package/dist-sdk/src/entities/field/types.js +7 -1
- package/dist-sdk/src/entities/file-reader/build.d.ts +5 -0
- package/dist-sdk/src/entities/file-reader/deserializer/print-file-reader.js +1 -1
- package/dist-sdk/src/entities/org/cloud-link.js +4 -5
- package/dist-sdk/src/entities/org/email-alias.d.ts +2 -0
- package/dist-sdk/src/entities/org/email-alias.js +12 -0
- package/dist-sdk/src/entities/org/index.d.ts +1 -0
- package/dist-sdk/src/entities/org/index.js +1 -0
- package/dist-sdk/src/entities/org/phone-provider.js +4 -7
- package/dist-sdk/src/entities/organization/build.d.ts +214 -2
- package/dist-sdk/src/entities/organization/build.js +145 -4
- package/dist-sdk/src/entities/organization/index.d.ts +1 -1
- package/dist-sdk/src/entities/organization/index.js +1 -1
- package/dist-sdk/src/entities/organization/module.js +4 -1
- package/dist-sdk/src/entities/organization/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/organization/to-tf.js +118 -1
- package/dist-sdk/src/entities/phone-service/build.d.ts +1 -1
- package/dist-sdk/src/entities/phone-service/build.js +2 -2
- package/dist-sdk/src/entities/phone-service/deserializer/print-phone-service.js +5 -3
- package/dist-sdk/src/entities/phone-service/index.d.ts +1 -1
- package/dist-sdk/src/entities/phone-service/index.js +1 -1
- package/dist-sdk/src/entities/phone-service/types.js +1 -1
- package/dist-sdk/src/entities/record-create-form/to-tf.js +9 -1
- package/dist-sdk/src/entities/relationship/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/relationship/to-tf.js +5 -13
- package/dist-sdk/src/entities/search-table/build.d.ts +4 -4
- package/dist-sdk/src/entities/search-table/build.js +13 -13
- package/dist-sdk/src/entities/search-table/index.d.ts +2 -2
- package/dist-sdk/src/entities/search-table/index.js +2 -2
- package/dist-sdk/src/entities/search-table/printer.js +5 -5
- package/dist-sdk/src/entities/service-account/to-tf.d.ts +21 -0
- package/dist-sdk/src/entities/service-account/to-tf.js +32 -1
- package/dist-sdk/src/entities/shared/context.d.ts +25 -24
- package/dist-sdk/src/entities/shared/context.js +36 -35
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +10 -3
- package/dist-sdk/src/entities/shared/filters/ast.js +1 -0
- package/dist-sdk/src/entities/shared/filters/index.d.ts +2 -1
- package/dist-sdk/src/entities/shared/filters/index.js +11 -4
- package/dist-sdk/src/entities/shared/foreign-ref.d.ts +14 -0
- package/dist-sdk/src/entities/shared/foreign-ref.js +12 -0
- package/dist-sdk/src/entities/shared/ref.d.ts +26 -11
- package/dist-sdk/src/entities/shared/ref.js +8 -3
- package/dist-sdk/src/entities/shared/types/common.d.ts +2 -2
- package/dist-sdk/src/entities/shared/types/field-types.d.ts +1 -1
- package/dist-sdk/src/entities/shared/types/field-types.js +1 -1
- package/dist-sdk/src/entities/skill/build.d.ts +2 -2
- package/dist-sdk/src/entities/skill/build.js +3 -3
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +1 -1
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +26 -7
- package/dist-sdk/src/entities/skill/index.d.ts +1 -1
- package/dist-sdk/src/entities/skill/index.js +1 -1
- package/dist-sdk/src/entities/skill/module.js +2 -2
- package/dist-sdk/src/entities/skill/to-tf.d.ts +1 -1
- package/dist-sdk/src/entities/skill/to-tf.js +2 -2
- package/dist-sdk/src/entities/skill/tools.d.ts +4 -3
- package/dist-sdk/src/entities/skill/tools.js +4 -3
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +13 -0
- package/dist-sdk/src/entities/skill-tool/from-tf.js +42 -0
- package/dist-sdk/src/entities/skill-tool/to-tf.js +6 -6
- package/dist-sdk/src/entities/table/build.d.ts +1 -1
- package/dist-sdk/src/entities/table/build.js +9 -9
- package/dist-sdk/src/entities/table/catalog-render.js +9 -1
- package/dist-sdk/src/entities/table/deserializer/normalize.js +4 -4
- package/dist-sdk/src/entities/table/fields/types.d.ts +1 -1
- package/dist-sdk/src/entities/table/fields/types.js +1 -1
- package/dist-sdk/src/entities/table/index.d.ts +2 -2
- package/dist-sdk/src/entities/table/index.js +3 -3
- package/dist-sdk/src/entities/table/module.js +1 -1
- package/dist-sdk/src/entities/table/to-tf.js +22 -30
- package/dist-sdk/src/entities/task/build.d.ts +1 -1
- package/dist-sdk/src/entities/task/build.js +5 -5
- package/dist-sdk/src/entities/task/index.d.ts +1 -1
- package/dist-sdk/src/entities/task/index.js +1 -1
- package/dist-sdk/src/entities/view/build.d.ts +46 -0
- package/dist-sdk/src/entities/view/build.js +19 -0
- package/dist-sdk/src/entities/view/from-tf.js +68 -18
- package/dist-sdk/src/entities/view/module.d.ts +6 -13
- package/dist-sdk/src/entities/view/module.js +7 -14
- package/dist-sdk/src/entities/view/sharing.d.ts +10 -0
- package/dist-sdk/src/entities/view/sharing.js +6 -0
- package/dist-sdk/src/entities/view/to-tf.d.ts +21 -19
- package/dist-sdk/src/entities/view/to-tf.js +61 -26
- package/dist-sdk/src/entities/view/types.js +3 -0
- package/dist-sdk/src/entities/visual-flow/build.d.ts +1 -1
- package/dist-sdk/src/entities/visual-flow/build.js +8 -8
- package/dist-sdk/src/entities/visual-flow/index.d.ts +1 -1
- package/dist-sdk/src/entities/visual-flow/index.js +1 -1
- package/dist-sdk/src/entities/visual-flow/module.js +1 -1
- package/dist-sdk/src/entities/visual-flow/printer.js +3 -3
- package/dist-sdk/src/entities/visual-flow/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/visual-flow/to-tf.js +3 -7
- package/dist-sdk/src/entities/widget/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/widget/to-tf.js +9 -7
- package/dist-sdk/src/graph/index.d.ts +5 -1
- package/dist-sdk/src/graph/index.js +4 -1
- package/dist-sdk/src/graph/modules.js +6 -1
- package/dist-sdk/src/graph/types.d.ts +52 -1
- package/dist-sdk/src/internal/safe-identifier.d.ts +4 -0
- package/dist-sdk/src/internal/safe-identifier.js +13 -0
- package/dist-sdk/src/internal/sdk-package.d.ts +1 -1
- package/dist-sdk/src/internal/sdk-package.js +1 -0
- package/package.json +12 -3
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { isTfExpr, tfLabelToTsLabel } from "../tf/index.js";
|
|
2
|
+
function singleLineComment(value) {
|
|
3
|
+
return value.replace(/\*\//g, "* /").replace(/\s+/g, " ").trim();
|
|
4
|
+
}
|
|
5
|
+
/** Format the diagnostic suffix printed beside an existing `unsafePlatformId(...)` call. */
|
|
6
|
+
export function unresolvedReferenceComment(uuid, unresolvedReferences) {
|
|
7
|
+
const details = [...new Set(unresolvedReferences
|
|
8
|
+
.filter((reference) => reference.uuid === uuid)
|
|
9
|
+
.map((reference) => {
|
|
10
|
+
const kind = singleLineComment(reference.kind || "unknown");
|
|
11
|
+
const usage = singleLineComment(reference.usage || "unknown");
|
|
12
|
+
const reason = singleLineComment(reference.reason || "metadata lookup failed");
|
|
13
|
+
return `unresolved ${kind} reference at ${usage}: ${reason}`;
|
|
14
|
+
}))];
|
|
15
|
+
return details.length === 0 ? "" : ` /* ${details.join(" | ")}; source-org-only */`;
|
|
16
|
+
}
|
|
17
|
+
function record(v) {
|
|
18
|
+
return typeof v === "object" && v !== null && !Array.isArray(v) ? v : undefined;
|
|
19
|
+
}
|
|
20
|
+
function stringAt(obj, ...keys) {
|
|
21
|
+
for (const key of keys)
|
|
22
|
+
if (typeof obj[key] === "string")
|
|
23
|
+
return obj[key];
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
function parseRoot(payload) {
|
|
27
|
+
let raw;
|
|
28
|
+
try {
|
|
29
|
+
raw = JSON.parse(payload);
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
const obj = record(raw);
|
|
35
|
+
if (obj === undefined)
|
|
36
|
+
return undefined;
|
|
37
|
+
const kind = stringAt(obj, "kind");
|
|
38
|
+
const name = stringAt(obj, "name");
|
|
39
|
+
const wireRefName = stringAt(obj, "refName");
|
|
40
|
+
if ((kind !== "app" && kind !== "element" && kind !== "table") || name === undefined || wireRefName === undefined)
|
|
41
|
+
return undefined;
|
|
42
|
+
const fields = [];
|
|
43
|
+
for (const rawField of Array.isArray(obj.fields) ? obj.fields : []) {
|
|
44
|
+
const field = record(rawField);
|
|
45
|
+
if (field === undefined)
|
|
46
|
+
continue;
|
|
47
|
+
const fieldName = stringAt(field, "name");
|
|
48
|
+
const fieldRefName = stringAt(field, "refName");
|
|
49
|
+
const fieldType = stringAt(field, "fieldType");
|
|
50
|
+
if (fieldName === undefined || fieldRefName === undefined || fieldType === undefined)
|
|
51
|
+
continue;
|
|
52
|
+
const tags = Array.isArray(field.tags) && field.tags.every((v) => typeof v === "string") ? field.tags : undefined;
|
|
53
|
+
const options = Array.isArray(field.options) && field.options.every((v) => typeof v === "string") ? field.options : undefined;
|
|
54
|
+
fields.push({
|
|
55
|
+
__kind: "field",
|
|
56
|
+
refName: tfLabelToTsLabel(fieldRefName),
|
|
57
|
+
name: fieldName,
|
|
58
|
+
parent: tfLabelToTsLabel(wireRefName),
|
|
59
|
+
fieldType,
|
|
60
|
+
...(tags !== undefined && tags.length > 0 ? { tags } : {}),
|
|
61
|
+
...(options !== undefined && options.length > 0 ? { options } : {}),
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
const columns = (Array.isArray(obj.columns) ? obj.columns : []).flatMap((rawColumn) => {
|
|
65
|
+
const column = record(rawColumn);
|
|
66
|
+
if (column === undefined)
|
|
67
|
+
return [];
|
|
68
|
+
const columnName = stringAt(column, "name");
|
|
69
|
+
const columnRefName = stringAt(column, "refName");
|
|
70
|
+
if (columnName === undefined || columnRefName === undefined)
|
|
71
|
+
return [];
|
|
72
|
+
const fieldType = stringAt(column, "fieldType");
|
|
73
|
+
return [{ refName: tfLabelToTsLabel(columnRefName), name: columnName, ...(fieldType !== undefined ? { fieldType } : {}) }];
|
|
74
|
+
});
|
|
75
|
+
const datamines = (Array.isArray(obj.datamines) ? obj.datamines : []).flatMap((rawDatamine) => {
|
|
76
|
+
const datamine = record(rawDatamine);
|
|
77
|
+
if (datamine === undefined)
|
|
78
|
+
return [];
|
|
79
|
+
const datamineName = stringAt(datamine, "name");
|
|
80
|
+
const datamineRefName = stringAt(datamine, "refName");
|
|
81
|
+
return datamineName === undefined || datamineRefName === undefined ? [] : [{ refName: tfLabelToTsLabel(datamineRefName), name: datamineName }];
|
|
82
|
+
});
|
|
83
|
+
const automations = (Array.isArray(obj.automations) ? obj.automations : []).flatMap((rawAutomation) => {
|
|
84
|
+
const automation = record(rawAutomation);
|
|
85
|
+
if (automation === undefined)
|
|
86
|
+
return [];
|
|
87
|
+
const automationName = stringAt(automation, "name");
|
|
88
|
+
const automationRefName = stringAt(automation, "refName");
|
|
89
|
+
return automationName === undefined || automationRefName === undefined ? [] : [{ refName: tfLabelToTsLabel(automationRefName), name: automationName }];
|
|
90
|
+
});
|
|
91
|
+
return {
|
|
92
|
+
kind,
|
|
93
|
+
refName: tfLabelToTsLabel(wireRefName),
|
|
94
|
+
name,
|
|
95
|
+
...(stringAt(obj, "namespace") !== undefined ? { namespace: stringAt(obj, "namespace") } : {}),
|
|
96
|
+
fields,
|
|
97
|
+
columns,
|
|
98
|
+
datamines,
|
|
99
|
+
automations,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function parseUnresolved(payload) {
|
|
103
|
+
let raw;
|
|
104
|
+
try {
|
|
105
|
+
raw = JSON.parse(payload);
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
const obj = record(raw);
|
|
111
|
+
if (obj === undefined)
|
|
112
|
+
return undefined;
|
|
113
|
+
const usage = stringAt(obj, "usage", "Usage") ?? "unknown";
|
|
114
|
+
const kind = stringAt(obj, "kind", "Kind") ?? "unknown";
|
|
115
|
+
const uuid = stringAt(obj, "uuid", "UUID");
|
|
116
|
+
const reason = stringAt(obj, "reason", "Reason") ?? "metadata lookup failed";
|
|
117
|
+
return uuid === undefined ? undefined : { usage, kind, uuid, reason, portability: "source-org-only" };
|
|
118
|
+
}
|
|
119
|
+
/** Reads bridge-owned, ID-free reference metadata without knowing provider resource names. */
|
|
120
|
+
export function readRefOnlyMetadata(doc) {
|
|
121
|
+
const roots = [];
|
|
122
|
+
const unresolved = [];
|
|
123
|
+
const diagnostics = [];
|
|
124
|
+
for (const block of doc.blocks) {
|
|
125
|
+
if (block.kind !== "locals")
|
|
126
|
+
continue;
|
|
127
|
+
for (const [key, value] of Object.entries(block.attrs)) {
|
|
128
|
+
if (typeof value !== "string")
|
|
129
|
+
continue;
|
|
130
|
+
if (key.startsWith("edk_ref_only_")) {
|
|
131
|
+
const root = parseRoot(value);
|
|
132
|
+
if (root !== undefined) {
|
|
133
|
+
if ((root.kind === "app" || root.kind === "element") && (root.namespace === undefined || root.namespace === "")) {
|
|
134
|
+
diagnostics.push(`ref-only ${root.kind} "${root.name}" is missing its required namespace; catalog materialization was skipped`);
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
roots.push(root);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
else if (key.startsWith("edk_unresolved_reference_")) {
|
|
142
|
+
const ref = parseUnresolved(value);
|
|
143
|
+
if (ref !== undefined)
|
|
144
|
+
unresolved.push(ref);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
const knownFallbacks = new Set(unresolved.map((ref) => ref.uuid));
|
|
149
|
+
const uuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
150
|
+
const visit = (value, usage, kind) => {
|
|
151
|
+
if (typeof value === "string") {
|
|
152
|
+
if (uuid.test(value) && !knownFallbacks.has(value)) {
|
|
153
|
+
knownFallbacks.add(value);
|
|
154
|
+
unresolved.push({ usage, kind, uuid: value, reason: "export retained a raw UUID because no portable lookup was available", portability: "source-org-only" });
|
|
155
|
+
}
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
if (Array.isArray(value))
|
|
159
|
+
value.forEach((item, index) => visit(item, `${usage}[${index}]`, kind));
|
|
160
|
+
else if (typeof value === "object" && value !== null && !isTfExpr(value)) {
|
|
161
|
+
for (const [key, child] of Object.entries(value))
|
|
162
|
+
visit(child, `${usage}.${key}`, kind);
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
for (const block of doc.blocks) {
|
|
166
|
+
if (block.kind !== "resource" || block.label === undefined || block.type === undefined)
|
|
167
|
+
continue;
|
|
168
|
+
for (const [attr, value] of Object.entries(block.attrs)) {
|
|
169
|
+
if (attr === "object_id" || attr === "app_id" || attr === "stage_id" || (!attr.endsWith("_id") && !attr.endsWith("_ids") && attr !== "filter" && attr !== "sort" && attr !== "dynamic_config"))
|
|
170
|
+
continue;
|
|
171
|
+
visit(value, `${block.type}.${block.label}.${attr}`, attr.replace(/_ids?$/, ""));
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
const deduped = new Map(roots.map((root) => [
|
|
175
|
+
root.kind === "table" ? `table:${root.name}` : `${root.kind}:${root.namespace}`,
|
|
176
|
+
root,
|
|
177
|
+
]));
|
|
178
|
+
return { roots: [...deduped.values()], unresolved, diagnostics };
|
|
179
|
+
}
|
|
180
|
+
export function fieldDataReferenceMap(doc, roots) {
|
|
181
|
+
const ownerByDataAddress = new Map();
|
|
182
|
+
for (const block of doc.blocks) {
|
|
183
|
+
if (block.kind !== "data" || block.label === undefined)
|
|
184
|
+
continue;
|
|
185
|
+
const namespace = typeof block.attrs.namespace === "string" ? block.attrs.namespace : undefined;
|
|
186
|
+
const name = typeof block.attrs.name === "string" ? block.attrs.name : undefined;
|
|
187
|
+
const root = roots.find((candidate) => (namespace !== undefined && candidate.namespace === namespace) || (name !== undefined && candidate.name === name));
|
|
188
|
+
if (root !== undefined)
|
|
189
|
+
ownerByDataAddress.set(`${block.type}.${block.label}`, root);
|
|
190
|
+
}
|
|
191
|
+
const out = new Map();
|
|
192
|
+
for (const block of doc.blocks) {
|
|
193
|
+
if (block.kind !== "data" || block.label === undefined || typeof block.attrs.name !== "string")
|
|
194
|
+
continue;
|
|
195
|
+
const ownerExpr = block.attrs.object_id;
|
|
196
|
+
if (!isTfExpr(ownerExpr) || ownerExpr.$expr !== "data-attr" || ownerExpr.path.join(".") !== "id")
|
|
197
|
+
continue;
|
|
198
|
+
const owner = ownerByDataAddress.get(`${ownerExpr.type}.${ownerExpr.label}`);
|
|
199
|
+
const field = owner?.fields.find((candidate) => candidate.name === block.attrs.name);
|
|
200
|
+
if (owner !== undefined && field !== undefined)
|
|
201
|
+
out.set(`${block.type}.${block.label}`, { ownerRefName: owner.refName, fieldKey: field.refName });
|
|
202
|
+
}
|
|
203
|
+
return out;
|
|
204
|
+
}
|
|
@@ -20,6 +20,10 @@ export declare class TfExprError extends Error {
|
|
|
20
20
|
* hcl2json encodes every expression attribute as "${...}"; plain strings
|
|
21
21
|
* stay plain (with template escapes still doubled).
|
|
22
22
|
*/
|
|
23
|
-
export
|
|
23
|
+
export interface ExpressionParseOptions {
|
|
24
|
+
/** Terraform variables are accepted only in explicitly modeled credential positions. */
|
|
25
|
+
readonly allowVariables?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export declare function parseStringValue(raw: string, options?: ExpressionParseOptions): string | TfExpr;
|
|
24
28
|
/** Parse the inside of a ${...} interpolation. */
|
|
25
|
-
export declare function parseExpression(src: string): TfExpr;
|
|
29
|
+
export declare function parseExpression(src: string, options?: ExpressionParseOptions): TfExpr;
|
|
@@ -19,13 +19,8 @@ export class TfExprError extends Error {
|
|
|
19
19
|
this.name = "TfExprError";
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
* hcl2json encodes every expression attribute as "${...}"; plain strings
|
|
25
|
-
* stay plain (with template escapes still doubled).
|
|
26
|
-
*/
|
|
27
|
-
export function parseStringValue(raw) {
|
|
28
|
-
const parts = splitTemplate(raw);
|
|
22
|
+
export function parseStringValue(raw, options = {}) {
|
|
23
|
+
const parts = splitTemplate(raw, options);
|
|
29
24
|
if (parts.length === 1 && typeof parts[0] === "string") {
|
|
30
25
|
return parts[0]; // plain string, already decoded
|
|
31
26
|
}
|
|
@@ -38,7 +33,7 @@ export function parseStringValue(raw) {
|
|
|
38
33
|
* Split a raw template string into alternating literal text (decoded) and
|
|
39
34
|
* parsed expressions. "$${" is an escape, not an interpolation start.
|
|
40
35
|
*/
|
|
41
|
-
function splitTemplate(raw) {
|
|
36
|
+
function splitTemplate(raw, options) {
|
|
42
37
|
const parts = [];
|
|
43
38
|
let literal = "";
|
|
44
39
|
let i = 0;
|
|
@@ -54,7 +49,7 @@ function splitTemplate(raw) {
|
|
|
54
49
|
parts.push(decodeTemplateEscapes(literal));
|
|
55
50
|
literal = "";
|
|
56
51
|
}
|
|
57
|
-
parts.push(parseExpression(raw.slice(i + 2, end)));
|
|
52
|
+
parts.push(parseExpression(raw.slice(i + 2, end), options));
|
|
58
53
|
i = end + 1;
|
|
59
54
|
continue;
|
|
60
55
|
}
|
|
@@ -104,8 +99,8 @@ function skipQuotedString(s, openQuote) {
|
|
|
104
99
|
throw new TfExprError("unterminated string literal", s);
|
|
105
100
|
}
|
|
106
101
|
/** Parse the inside of a ${...} interpolation. */
|
|
107
|
-
export function parseExpression(src) {
|
|
108
|
-
const p = new Parser(src);
|
|
102
|
+
export function parseExpression(src, options = {}) {
|
|
103
|
+
const p = new Parser(src, options);
|
|
109
104
|
const e = p.parseExpr();
|
|
110
105
|
p.skipWs();
|
|
111
106
|
if (!p.done()) {
|
|
@@ -116,9 +111,11 @@ export function parseExpression(src) {
|
|
|
116
111
|
const IDENT_RE = /^[A-Za-z_][A-Za-z0-9_-]*/;
|
|
117
112
|
class Parser {
|
|
118
113
|
src;
|
|
114
|
+
options;
|
|
119
115
|
pos = 0;
|
|
120
|
-
constructor(src) {
|
|
116
|
+
constructor(src, options) {
|
|
121
117
|
this.src = src;
|
|
118
|
+
this.options = options;
|
|
122
119
|
}
|
|
123
120
|
parseExpr() {
|
|
124
121
|
this.skipWs();
|
|
@@ -180,6 +177,14 @@ class Parser {
|
|
|
180
177
|
const name = this.takeIdent();
|
|
181
178
|
return expr.local(name, this.parsePath());
|
|
182
179
|
}
|
|
180
|
+
if (first === "var") {
|
|
181
|
+
if (this.options.allowVariables !== true) {
|
|
182
|
+
throw new TfExprError("Terraform variables are only supported in modeled credential attributes", this.src);
|
|
183
|
+
}
|
|
184
|
+
this.expect(".");
|
|
185
|
+
const name = this.takeIdent();
|
|
186
|
+
return expr.variable(name, this.parsePath());
|
|
187
|
+
}
|
|
183
188
|
let type;
|
|
184
189
|
let isData = false;
|
|
185
190
|
if (first === "data") {
|
|
@@ -244,7 +249,7 @@ class Parser {
|
|
|
244
249
|
return null;
|
|
245
250
|
if (ident !== null) {
|
|
246
251
|
this.pos = identStart;
|
|
247
|
-
if (ident === "data" || ident === "local" || ident.startsWith("elementum_")) {
|
|
252
|
+
if (ident === "data" || ident === "local" || ident === "var" || ident.startsWith("elementum_")) {
|
|
248
253
|
return this.parseReference();
|
|
249
254
|
}
|
|
250
255
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* src/tf — the ONE HCL parse/render surface
|
|
2
|
+
* src/tf — the ONE HCL parse/render surface.
|
|
3
3
|
* A second dialect must not exist: extractors consume TfBlock from parseHcl;
|
|
4
4
|
* toHcl emitters produce TfBlock rendered by renderDocument.
|
|
5
5
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* src/tf — the ONE HCL parse/render surface
|
|
2
|
+
* src/tf — the ONE HCL parse/render surface.
|
|
3
3
|
* A second dialect must not exist: extractors consume TfBlock from parseHcl;
|
|
4
4
|
* toHcl emitters produce TfBlock rendered by renderDocument.
|
|
5
5
|
*/
|
|
@@ -33,6 +33,12 @@ export type TfExpr =
|
|
|
33
33
|
name: string;
|
|
34
34
|
path: PathSeg[];
|
|
35
35
|
}
|
|
36
|
+
/** var.secret_name — used for sensitive organization credentials. */
|
|
37
|
+
| {
|
|
38
|
+
$expr: "variable";
|
|
39
|
+
name: string;
|
|
40
|
+
path: PathSeg[];
|
|
41
|
+
}
|
|
36
42
|
/** jsonencode({ ... }) — value is the payload as plain data */
|
|
37
43
|
| {
|
|
38
44
|
$expr: "jsonencode";
|
|
@@ -60,7 +66,7 @@ export type TfExpr =
|
|
|
60
66
|
export type TfValue = string | number | boolean | null | TfValue[] | {
|
|
61
67
|
[k: string]: TfValue;
|
|
62
68
|
} | TfExpr;
|
|
63
|
-
export type TfBlockKind = "resource" | "data" | "locals" | "import" | "provider" | "terraform";
|
|
69
|
+
export type TfBlockKind = "resource" | "data" | "locals" | "import" | "provider" | "terraform" | "variable";
|
|
64
70
|
export interface TfBlock {
|
|
65
71
|
kind: TfBlockKind;
|
|
66
72
|
/** resource/data only: the terraform type, e.g. "elementum_app" */
|
|
@@ -77,6 +83,7 @@ export declare const expr: {
|
|
|
77
83
|
resourceAttr(type: string, label: string, path?: PathSeg[]): TfExpr;
|
|
78
84
|
dataAttr(type: string, label: string, path?: PathSeg[]): TfExpr;
|
|
79
85
|
local(name: string, path?: PathSeg[]): TfExpr;
|
|
86
|
+
variable(name: string, path?: PathSeg[]): TfExpr;
|
|
80
87
|
jsonencode(value: TfValue): TfExpr;
|
|
81
88
|
template(parts: (string | TfExpr)[]): TfExpr;
|
|
82
89
|
scopedAttr(name: string, path?: PathSeg[]): TfExpr;
|
|
@@ -12,6 +12,7 @@ const EXPR_KINDS = new Set([
|
|
|
12
12
|
"resource-attr",
|
|
13
13
|
"data-attr",
|
|
14
14
|
"local",
|
|
15
|
+
"variable",
|
|
15
16
|
"jsonencode",
|
|
16
17
|
"template",
|
|
17
18
|
"scoped-attr",
|
|
@@ -34,6 +35,9 @@ export const expr = {
|
|
|
34
35
|
local(name, path = []) {
|
|
35
36
|
return { $expr: "local", name, path };
|
|
36
37
|
},
|
|
38
|
+
variable(name, path = []) {
|
|
39
|
+
return { $expr: "variable", name, path };
|
|
40
|
+
},
|
|
37
41
|
jsonencode(value) {
|
|
38
42
|
return { $expr: "jsonencode", value };
|
|
39
43
|
},
|
|
@@ -43,7 +43,7 @@ export class TfParseError extends Error {
|
|
|
43
43
|
this.name = "TfParseError";
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
const KNOWN_TOP_LEVEL = new Set(["resource", "data", "locals", "import", "provider", "terraform"]);
|
|
46
|
+
const KNOWN_TOP_LEVEL = new Set(["resource", "data", "locals", "import", "provider", "terraform", "variable"]);
|
|
47
47
|
const BACKEND_TOP_LEVEL = new Set(["terraform", "variable", "locals"]);
|
|
48
48
|
const BACKEND_SECRET_KEYS = new Set([
|
|
49
49
|
"access_key",
|
|
@@ -252,6 +252,13 @@ export async function parseHcl(text) {
|
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
254
|
}
|
|
255
|
+
const variables = raw["variable"];
|
|
256
|
+
if (variables) {
|
|
257
|
+
for (const [name, bodies] of Object.entries(variables)) {
|
|
258
|
+
for (const body of bodies)
|
|
259
|
+
blocks.push({ kind: "variable", label: name, attrs: convertBody(body, `variable.${name}`) });
|
|
260
|
+
}
|
|
261
|
+
}
|
|
255
262
|
const terraformBodies = raw["terraform"];
|
|
256
263
|
if (terraformBodies) {
|
|
257
264
|
for (const body of terraformBodies) {
|
|
@@ -277,7 +284,7 @@ function convertValue(value, ctx) {
|
|
|
277
284
|
return value;
|
|
278
285
|
if (typeof value === "string") {
|
|
279
286
|
try {
|
|
280
|
-
return parseStringValue(value);
|
|
287
|
+
return parseStringValue(value, { allowVariables: isCredentialVariableContext(ctx) });
|
|
281
288
|
}
|
|
282
289
|
catch (e) {
|
|
283
290
|
if (e instanceof TfExprError) {
|
|
@@ -303,6 +310,10 @@ function convertValue(value, ctx) {
|
|
|
303
310
|
}
|
|
304
311
|
throw new TfParseError(`unsupported value type "${typeof value}" at ${ctx}`);
|
|
305
312
|
}
|
|
313
|
+
function isCredentialVariableContext(ctx) {
|
|
314
|
+
return /^resource\.elementum_cloudlink\.[^.]+\.credentials(?:\.|$)/.test(ctx) ||
|
|
315
|
+
/^resource\.elementum_phone_provider\.[^.]+\.twilio(?:\.|$)/.test(ctx);
|
|
316
|
+
}
|
|
306
317
|
/**
|
|
307
318
|
* Refuse to parse text whose integer literals exceed Number.MAX_SAFE_INTEGER —
|
|
308
319
|
* hcl2json would round them silently (verified: 2^53+1 → 2^53).
|
|
@@ -28,6 +28,8 @@ function blockHeader(block) {
|
|
|
28
28
|
return `${block.kind} ${quoteLabel(block.type)} ${quoteLabel(block.label)}`;
|
|
29
29
|
case "provider":
|
|
30
30
|
return `provider ${quoteLabel(block.label)}`;
|
|
31
|
+
case "variable":
|
|
32
|
+
return `variable ${quoteLabel(block.label)}`;
|
|
31
33
|
case "locals":
|
|
32
34
|
case "import":
|
|
33
35
|
case "terraform":
|
|
@@ -76,6 +78,8 @@ function renderExpr(e, depth) {
|
|
|
76
78
|
return `data.${e.type}.${e.label}${renderPath(e.path)}`;
|
|
77
79
|
case "local":
|
|
78
80
|
return `local.${e.name}${renderPath(e.path)}`;
|
|
81
|
+
case "variable":
|
|
82
|
+
return `var.${e.name}${renderPath(e.path)}`;
|
|
79
83
|
case "jsonencode":
|
|
80
84
|
return `jsonencode(${renderValue(e.value, depth)})`;
|
|
81
85
|
case "template": {
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Access-policy authoring options — the `accessPolicies: [...]` array shared
|
|
3
|
-
* by `
|
|
3
|
+
* by `app`/`element` (`entities/app/build.ts` /
|
|
4
4
|
* `entities/element/build.ts`). Kept here, not duplicated per parent, since
|
|
5
5
|
* both parents accept the identical shape.
|
|
6
6
|
*/
|
|
7
7
|
import type { Filter } from "../shared/filters/types.js";
|
|
8
|
-
import type { AccessPolicyGroupRef, AccessPolicyUserRef } from "./principal.js";
|
|
9
|
-
export { groupId, userId, type AccessPolicyGroupRef, type AccessPolicyPrincipal, type AccessPolicyPrincipalRef, type AccessPolicyUserRef, type GroupId, type UserId, } from "./principal.js";
|
|
8
|
+
import type { AccessPolicyGroupRef, AccessPolicyServiceAccountRef, AccessPolicyUserRef } from "./principal.js";
|
|
9
|
+
export { groupId, userId, type AccessPolicyGroupRef, type AccessPolicyPrincipal, type AccessPolicyPrincipalRef, type AccessPolicyServiceAccountRef, type AccessPolicyUserRef, type GroupId, type UserId, } from "./principal.js";
|
|
10
10
|
export interface AccessPolicyOptions {
|
|
11
11
|
/** Row-level-security predicate. Omit for the platform default (matches every record). */
|
|
12
12
|
readonly filter?: Filter;
|
|
13
13
|
readonly userIds?: readonly AccessPolicyUserRef[];
|
|
14
14
|
readonly groupIds?: readonly AccessPolicyGroupRef[];
|
|
15
|
-
|
|
16
|
-
readonly serviceAccountIds?: readonly string[];
|
|
15
|
+
readonly serviceAccountIds?: readonly AccessPolicyServiceAccountRef[];
|
|
17
16
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Access-policy authoring options — the `accessPolicies: [...]` array shared
|
|
3
|
-
* by `
|
|
3
|
+
* by `app`/`element` (`entities/app/build.ts` /
|
|
4
4
|
* `entities/element/build.ts`). Kept here, not duplicated per parent, since
|
|
5
5
|
* both parents accept the identical shape.
|
|
6
6
|
*/
|
|
@@ -14,8 +14,8 @@ import { type FromTfContext } from "../../engine/pull/context.js";
|
|
|
14
14
|
import { type ChildResourceScope, type TfBlock, type TfValue } from "../../engine/tf/index.js";
|
|
15
15
|
import type { RefExpr } from "../shared/filters/ast.js";
|
|
16
16
|
import type { Filter } from "../shared/filters/types.js";
|
|
17
|
-
import { type AccessPolicyGroupRef, type AccessPolicyUserRef } from "./principal.js";
|
|
18
|
-
export type { AccessPolicyPrincipalRef } from "./principal.js";
|
|
17
|
+
import { type AccessPolicyGroupRef, type AccessPolicyServiceAccountRef, type AccessPolicyUserRef } from "./principal.js";
|
|
18
|
+
export type { AccessPolicyPrincipalRef, AccessPolicyServiceAccountRef } from "./principal.js";
|
|
19
19
|
export interface AccessPolicyOwner {
|
|
20
20
|
readonly type: string;
|
|
21
21
|
readonly label: string;
|
|
@@ -29,12 +29,12 @@ export interface NormalizedAccessPolicy {
|
|
|
29
29
|
readonly filter: Filter<RefExpr, RefExpr>;
|
|
30
30
|
readonly userIds?: readonly AccessPolicyUserRef[];
|
|
31
31
|
readonly groupIds?: readonly AccessPolicyGroupRef[];
|
|
32
|
-
|
|
33
|
-
readonly serviceAccountIds?: readonly string[];
|
|
32
|
+
readonly serviceAccountIds?: readonly AccessPolicyServiceAccountRef[];
|
|
34
33
|
}
|
|
35
34
|
/** Decode one `filter` attribute through the shared exhaustive codec. */
|
|
36
35
|
export declare function filterFromTf(value: TfValue, owner: AccessPolicyOwner, where: string): Filter<RefExpr, RefExpr>;
|
|
37
36
|
export declare function principalList(value: TfValue | undefined, dataType: "elementum_user", where: string, ctx: FromTfContext): AccessPolicyUserRef[] | undefined;
|
|
38
37
|
export declare function principalList(value: TfValue | undefined, dataType: "elementum_group", where: string, ctx: FromTfContext): AccessPolicyGroupRef[] | undefined;
|
|
38
|
+
export declare function principalList(value: TfValue | undefined, dataType: "elementum_service_account", where: string, ctx: FromTfContext): AccessPolicyServiceAccountRef[] | undefined;
|
|
39
39
|
/** One `elementum_access_policy` block → its normalized shape, or undefined when it belongs to a different owner. */
|
|
40
40
|
export declare function accessPolicyFromTf(block: TfBlock, owner: AccessPolicyOwner, ctx: FromTfContext): NormalizedAccessPolicy | undefined;
|
|
@@ -69,8 +69,14 @@ function principalListItem(item, dataType, where, ctx) {
|
|
|
69
69
|
ctx.diagnostics.push(`${where}: references data.${dataType}.${label}, but the stream has no matching data block; dropped`);
|
|
70
70
|
return undefined;
|
|
71
71
|
}
|
|
72
|
-
if (typeof item === "string")
|
|
73
|
-
|
|
72
|
+
if (typeof item === "string") {
|
|
73
|
+
if (dataType === "elementum_user")
|
|
74
|
+
return userId(item);
|
|
75
|
+
if (dataType === "elementum_group")
|
|
76
|
+
return groupId(item);
|
|
77
|
+
ctx.diagnostics.push(`${where}: raw service account id could not be resolved to a name; dropped`);
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
74
80
|
ctx.diagnostics.push(`${where}: list item has an unrecognized shape; dropped`);
|
|
75
81
|
return undefined;
|
|
76
82
|
}
|
|
@@ -85,7 +91,9 @@ export function principalList(value, dataType, where, ctx) {
|
|
|
85
91
|
for (const item of value) {
|
|
86
92
|
const decoded = dataType === "elementum_user"
|
|
87
93
|
? principalListItem(item, "elementum_user", where, ctx)
|
|
88
|
-
:
|
|
94
|
+
: dataType === "elementum_group"
|
|
95
|
+
? principalListItem(item, "elementum_group", where, ctx)
|
|
96
|
+
: principalListItem(item, "elementum_service_account", where, ctx);
|
|
89
97
|
if (decoded !== undefined)
|
|
90
98
|
items.push(decoded);
|
|
91
99
|
}
|
|
@@ -110,16 +118,7 @@ export function accessPolicyFromTf(block, owner, ctx) {
|
|
|
110
118
|
const filter = attrs["filter"] !== undefined ? filterFromTf(attrs["filter"], owner, where) : { type: "TRUE" };
|
|
111
119
|
const userIds = principalList(attrs["user_ids"], "elementum_user", `${where}: user_ids`, ctx);
|
|
112
120
|
const groupIds = principalList(attrs["group_ids"], "elementum_group", `${where}: group_ids`, ctx);
|
|
113
|
-
|
|
114
|
-
const saAttr = attrs["service_account_ids"];
|
|
115
|
-
if (Array.isArray(saAttr)) {
|
|
116
|
-
serviceAccountIds = saAttr.filter((id) => typeof id === "string");
|
|
117
|
-
if (serviceAccountIds.length === 0)
|
|
118
|
-
serviceAccountIds = undefined;
|
|
119
|
-
}
|
|
120
|
-
else if (saAttr !== undefined) {
|
|
121
|
-
ctx.diagnostics.push(`${where}: service_account_ids is not a list; dropped`);
|
|
122
|
-
}
|
|
121
|
+
const serviceAccountIds = principalList(attrs["service_account_ids"], "elementum_service_account", `${where}: service_account_ids`, ctx);
|
|
123
122
|
return {
|
|
124
123
|
filter,
|
|
125
124
|
...(userIds !== undefined && { userIds }),
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { GroupRef } from "../../catalog/index.js";
|
|
2
|
+
import type { ServiceAccountRef } from "../service-account/ref.js";
|
|
3
|
+
import type { RoleUserRef } from "../role/build.js";
|
|
2
4
|
declare const userIdBrand: unique symbol;
|
|
3
5
|
declare const groupIdBrand: unique symbol;
|
|
4
6
|
/** A platform user id, kept distinct from every other string id. */
|
|
@@ -13,17 +15,25 @@ export type GroupId = string & {
|
|
|
13
15
|
export declare function userId(value: string): UserId;
|
|
14
16
|
/** Mark an explicit platform group id. Prefer an `org.groups.*` token when one is available. */
|
|
15
17
|
export declare function groupId(value: string): GroupId;
|
|
16
|
-
export type PrincipalDataType = "elementum_user" | "elementum_group";
|
|
18
|
+
export type PrincipalDataType = "elementum_user" | "elementum_group" | "elementum_service_account";
|
|
17
19
|
/** A portable principal lookup preserved verbatim from pulled Terraform. */
|
|
18
20
|
export interface AccessPolicyPrincipalRef<DataType extends PrincipalDataType = PrincipalDataType> {
|
|
19
21
|
readonly __kind: "orgPrincipalRef";
|
|
20
22
|
readonly dataType: DataType;
|
|
21
23
|
/** The data block's own label, captured verbatim. */
|
|
22
24
|
readonly label: string;
|
|
23
|
-
/** The data block's lookup value: email for a user
|
|
25
|
+
/** The data block's lookup value: email for a user, name for a group or service account. */
|
|
24
26
|
readonly value: string;
|
|
25
27
|
}
|
|
26
|
-
export type AccessPolicyUserRef = UserId | AccessPolicyPrincipalRef<"elementum_user">;
|
|
28
|
+
export type AccessPolicyUserRef = UserId | RoleUserRef | AccessPolicyPrincipalRef<"elementum_user">;
|
|
27
29
|
export type AccessPolicyGroupRef = GroupId | GroupRef | AccessPolicyPrincipalRef<"elementum_group">;
|
|
28
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Service accounts have no bare-id brand (unlike users/groups): they are
|
|
32
|
+
* always app-owned, so there is no context-free "raw id" worth authoring.
|
|
33
|
+
* Fresh authoring uses the same `serviceAccountRef({ app, name })` token
|
|
34
|
+
* agent/skill `runAs` already accepts; a pulled policy round-trips through
|
|
35
|
+
* the resolved data-source lookup instead (elementum-fde/edk#388).
|
|
36
|
+
*/
|
|
37
|
+
export type AccessPolicyServiceAccountRef = ServiceAccountRef | AccessPolicyPrincipalRef<"elementum_service_account">;
|
|
38
|
+
export type AccessPolicyPrincipal = AccessPolicyUserRef | AccessPolicyGroupRef | AccessPolicyServiceAccountRef;
|
|
29
39
|
export {};
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
import type { OrgRefLookup } from "../../engine/build/context.js";
|
|
21
21
|
import { type ChildResourceScope, type TfBlock, type TfValue } from "../../engine/tf/index.js";
|
|
22
22
|
import type { Filter } from "../shared/filters/types.js";
|
|
23
|
-
import type {
|
|
23
|
+
import type { AppServiceAccount } from "../service-account/build.js";
|
|
24
|
+
import type { AccessPolicyGroupRef, AccessPolicyServiceAccountRef, AccessPolicyUserRef } from "./principal.js";
|
|
24
25
|
export interface AccessPolicyToTfContext {
|
|
25
26
|
readonly ownerTfLabel: string;
|
|
26
27
|
readonly scope: ChildResourceScope;
|
|
@@ -28,6 +29,14 @@ export interface AccessPolicyToTfContext {
|
|
|
28
29
|
readonly objectId: TfValue;
|
|
29
30
|
readonly orgRefs: OrgRefLookup;
|
|
30
31
|
readonly diagnostics: string[];
|
|
32
|
+
/**
|
|
33
|
+
* Owner's EDK refName + the same app's authored `serviceAccounts` bag —
|
|
34
|
+
* only apps own service accounts, so element/task owners omit these and a
|
|
35
|
+
* `serviceAccountRef` token in their policies is dropped with a
|
|
36
|
+
* diagnostic (there is nothing local it could match).
|
|
37
|
+
*/
|
|
38
|
+
readonly appRefName?: string;
|
|
39
|
+
readonly serviceAccounts?: Readonly<Record<string, AppServiceAccount>>;
|
|
31
40
|
}
|
|
32
41
|
/** Filter conversion only needs owner/field context; org lookups are accepted so full policy contexts remain assignable. */
|
|
33
42
|
export interface FilterToTfContext extends Omit<AccessPolicyToTfContext, "orgRefs"> {
|
|
@@ -46,7 +55,7 @@ export interface AccessPolicyEntryWire {
|
|
|
46
55
|
readonly filter?: Filter;
|
|
47
56
|
readonly userIds?: readonly AccessPolicyUserRef[];
|
|
48
57
|
readonly groupIds?: readonly AccessPolicyGroupRef[];
|
|
49
|
-
readonly serviceAccountIds?: readonly
|
|
58
|
+
readonly serviceAccountIds?: readonly AccessPolicyServiceAccountRef[];
|
|
50
59
|
}
|
|
51
60
|
export declare function principalListToTf(items: readonly AccessPolicyUserRef[] | undefined, dataType: "elementum_user", where: string, ctx: Omit<AccessPolicyToTfContext, "orgRefs"> & {
|
|
52
61
|
readonly orgRefs?: OrgRefLookup;
|
|
@@ -54,5 +63,8 @@ export declare function principalListToTf(items: readonly AccessPolicyUserRef[]
|
|
|
54
63
|
export declare function principalListToTf(items: readonly AccessPolicyGroupRef[] | undefined, dataType: "elementum_group", where: string, ctx: Omit<AccessPolicyToTfContext, "orgRefs"> & {
|
|
55
64
|
readonly orgRefs?: OrgRefLookup;
|
|
56
65
|
}): TfValue[] | undefined;
|
|
66
|
+
export declare function principalListToTf(items: readonly AccessPolicyServiceAccountRef[] | undefined, dataType: "elementum_service_account", where: string, ctx: Omit<AccessPolicyToTfContext, "orgRefs"> & {
|
|
67
|
+
readonly orgRefs?: OrgRefLookup;
|
|
68
|
+
}): TfValue[] | undefined;
|
|
57
69
|
/** One authored access-policy entry → its resource block, positioned by `index` (0-based) for label numbering. */
|
|
58
70
|
export declare function accessPolicyToTf(entry: AccessPolicyEntryWire, index: number, ctx: AccessPolicyToTfContext): AccessPolicyToTfResult;
|