@elementumai/edk 0.9.19 → 0.9.20
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 +146 -6
- package/dist-sdk/src/catalog/factories.d.ts +24 -1
- package/dist-sdk/src/catalog/factories.js +30 -0
- package/dist-sdk/src/catalog/from-authoring.d.ts +13 -8
- package/dist-sdk/src/catalog/from-authoring.js +34 -9
- package/dist-sdk/src/catalog/index.d.ts +2 -2
- package/dist-sdk/src/catalog/index.js +2 -2
- package/dist-sdk/src/catalog/render.js +6 -6
- package/dist-sdk/src/catalog/token.js +7 -0
- package/dist-sdk/src/catalog/types.d.ts +34 -1
- package/dist-sdk/src/catalog/types.js +11 -0
- package/dist-sdk/src/core/triggers/on-demand.d.ts +39 -3
- package/dist-sdk/src/core/triggers/on-demand.js +10 -2
- package/dist-sdk/src/engine/build/context.d.ts +1 -1
- package/dist-sdk/src/engine/ei/run.d.ts +149 -0
- package/dist-sdk/src/engine/ei/run.js +1132 -0
- package/dist-sdk/src/engine/logging.d.ts +17 -0
- package/dist-sdk/src/engine/logging.js +18 -0
- package/dist-sdk/src/engine/pull/ref-only.d.ts +5 -0
- package/dist-sdk/src/engine/pull/ref-only.js +10 -7
- package/dist-sdk/src/engine/pull/result-output.d.ts +6 -0
- package/dist-sdk/src/engine/pull/result-output.js +87 -3
- package/dist-sdk/src/engine/tf/expr.js +1 -1
- package/dist-sdk/src/engine/tf/index.d.ts +2 -2
- package/dist-sdk/src/engine/tf/index.js +1 -1
- package/dist-sdk/src/engine/tf/labels.d.ts +6 -0
- package/dist-sdk/src/engine/tf/labels.js +9 -0
- package/dist-sdk/src/engine/tf/model.d.ts +22 -1
- package/dist-sdk/src/engine/tf/parse.js +92 -4
- package/dist-sdk/src/engine/tf/render.d.ts +4 -2
- package/dist-sdk/src/engine/tf/render.js +41 -7
- package/dist-sdk/src/engine/validation.d.ts +39 -0
- package/dist-sdk/src/engine/validation.js +85 -0
- package/dist-sdk/src/entities/access-policy/to-tf.js +5 -2
- package/dist-sdk/src/entities/agent/build.d.ts +4 -16
- package/dist-sdk/src/entities/agent/build.js +40 -5
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +4 -2
- package/dist-sdk/src/entities/agent/to-tf.js +6 -3
- package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/agent-tool/from-tf.js +7 -1
- package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +2 -2
- package/dist-sdk/src/entities/agent-tool/to-tf.js +27 -5
- package/dist-sdk/src/entities/app/build.d.ts +89 -20
- package/dist-sdk/src/entities/app/build.js +51 -6
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +16 -0
- package/dist-sdk/src/entities/app/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/app/from-tf.js +7 -2
- package/dist-sdk/src/entities/app/index.d.ts +6 -6
- package/dist-sdk/src/entities/app/index.js +1 -0
- package/dist-sdk/src/entities/app/module.js +5 -2
- package/dist-sdk/src/entities/app/to-tf.js +19 -11
- package/dist-sdk/src/entities/automation/build.d.ts +47 -5
- package/dist-sdk/src/entities/automation/build.js +137 -20
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +24 -1
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +314 -39
- package/dist-sdk/src/entities/automation/from-tf.d.ts +28 -6
- package/dist-sdk/src/entities/automation/from-tf.js +428 -48
- package/dist-sdk/src/entities/automation/generated/task-output-contracts.d.ts +33 -0
- package/dist-sdk/src/entities/automation/generated/task-output-contracts.js +183 -0
- package/dist-sdk/src/entities/automation/index.d.ts +2 -2
- package/dist-sdk/src/entities/automation/index.js +1 -1
- package/dist-sdk/src/entities/automation/module.js +37 -8
- package/dist-sdk/src/entities/automation/output-field-types.d.ts +7 -0
- package/dist-sdk/src/entities/automation/output-field-types.js +36 -0
- package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +9 -0
- package/dist-sdk/src/entities/automation/output-key-wire-name.js +13 -0
- package/dist-sdk/src/entities/automation/script-code.d.ts +17 -0
- package/dist-sdk/src/entities/automation/script-code.js +91 -5
- package/dist-sdk/src/entities/automation/system-ref-name.js +4 -0
- package/dist-sdk/src/entities/automation/task-output-labels.d.ts +2 -0
- package/dist-sdk/src/entities/automation/task-output-labels.js +9 -0
- package/dist-sdk/src/entities/automation/tasks.d.ts +24 -2
- package/dist-sdk/src/entities/automation/tasks.js +38 -9
- package/dist-sdk/src/entities/automation/to-tf.d.ts +4 -0
- package/dist-sdk/src/entities/automation/to-tf.js +489 -83
- package/dist-sdk/src/entities/automation/triggers.d.ts +4 -2
- package/dist-sdk/src/entities/automation/triggers.js +4 -0
- package/dist-sdk/src/entities/chart/to-tf.js +10 -3
- package/dist-sdk/src/entities/dynamic-layout/build.d.ts +24 -31
- package/dist-sdk/src/entities/element/build.d.ts +25 -13
- package/dist-sdk/src/entities/element/build.js +4 -1
- package/dist-sdk/src/entities/element/from-tf.d.ts +11 -0
- package/dist-sdk/src/entities/element/from-tf.js +58 -1
- package/dist-sdk/src/entities/element/index.d.ts +5 -3
- package/dist-sdk/src/entities/element/index.js +1 -0
- package/dist-sdk/src/entities/element/module.js +9 -3
- package/dist-sdk/src/entities/element/to-tf.js +8 -2
- package/dist-sdk/src/entities/field/build.d.ts +14 -1
- package/dist-sdk/src/entities/field/build.js +3 -0
- package/dist-sdk/src/entities/field/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/field/from-tf.js +39 -1
- package/dist-sdk/src/entities/field/media-types.d.ts +6 -0
- package/dist-sdk/src/entities/field/media-types.js +30 -0
- package/dist-sdk/src/entities/field/module.js +1 -0
- package/dist-sdk/src/entities/field/to-tf.d.ts +23 -2
- package/dist-sdk/src/entities/field/to-tf.js +130 -14
- package/dist-sdk/src/entities/file-reader/from-tf.js +14 -5
- package/dist-sdk/src/entities/file-reader/module.js +1 -0
- package/dist-sdk/src/entities/file-reader/types.d.ts +2 -0
- package/dist-sdk/src/entities/file-reader/types.js +1 -1
- package/dist-sdk/src/entities/portal/build.d.ts +26 -0
- package/dist-sdk/src/entities/portal/build.js +37 -0
- package/dist-sdk/src/entities/portal/from-tf.d.ts +27 -0
- package/dist-sdk/src/entities/portal/from-tf.js +75 -0
- package/dist-sdk/src/entities/portal/index.d.ts +1 -0
- package/dist-sdk/src/entities/portal/index.js +1 -0
- package/dist-sdk/src/entities/portal/module.d.ts +3 -0
- package/dist-sdk/src/entities/portal/module.js +28 -0
- package/dist-sdk/src/entities/portal/to-tf.d.ts +12 -0
- package/dist-sdk/src/entities/portal/to-tf.js +73 -0
- package/dist-sdk/src/entities/portal/types.d.ts +1 -0
- package/dist-sdk/src/entities/portal/types.js +1 -0
- package/dist-sdk/src/entities/relationship/module.js +2 -0
- package/dist-sdk/src/entities/relationship/pair-check.d.ts +7 -0
- package/dist-sdk/src/entities/relationship/pair-check.js +68 -0
- package/dist-sdk/src/entities/relationship/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/relationship/to-tf.js +12 -3
- package/dist-sdk/src/entities/search-table/module.js +1 -0
- package/dist-sdk/src/entities/search-table/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/search-table/to-tf.js +1 -1
- package/dist-sdk/src/entities/service-account/build.d.ts +15 -2
- package/dist-sdk/src/entities/service-account/from-tf.d.ts +2 -4
- package/dist-sdk/src/entities/service-account/from-tf.js +17 -5
- package/dist-sdk/src/entities/service-account/role-fidelity.d.ts +56 -0
- package/dist-sdk/src/entities/service-account/role-fidelity.js +243 -0
- package/dist-sdk/src/entities/service-account/to-tf.d.ts +14 -0
- package/dist-sdk/src/entities/service-account/to-tf.js +17 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +1 -1
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +5 -2
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +8 -0
- package/dist-sdk/src/entities/shared/filters/index.d.ts +2 -0
- package/dist-sdk/src/entities/shared/filters/index.js +14 -4
- package/dist-sdk/src/entities/shared/filters/print.js +17 -1
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +2 -0
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +5 -1
- package/dist-sdk/src/entities/shared/filters/types.d.ts +9 -1
- package/dist-sdk/src/entities/shared/types/field-types.d.ts +10 -5
- package/dist-sdk/src/entities/shared/types/field-types.js +4 -0
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +2 -1
- package/dist-sdk/src/entities/skill/from-tf.js +66 -13
- package/dist-sdk/src/entities/skill/input-coverage.d.ts +7 -0
- package/dist-sdk/src/entities/skill/input-coverage.js +11 -0
- package/dist-sdk/src/entities/skill/to-tf.js +14 -4
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/skill-tool/from-tf.js +8 -2
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +2 -2
- package/dist-sdk/src/entities/skill-tool/to-tf.js +27 -5
- package/dist-sdk/src/entities/table/catalog.d.ts +14 -0
- package/dist-sdk/src/entities/table/catalog.js +66 -0
- package/dist-sdk/src/entities/table/module.js +2 -1
- package/dist-sdk/src/entities/table/to-tf.js +2 -2
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +49 -9
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +71 -18
- package/dist-sdk/src/entities/view/agent-view-layout-to-tf.d.ts +19 -4
- package/dist-sdk/src/entities/view/agent-view-layout-to-tf.js +82 -10
- package/dist-sdk/src/entities/view/agent-view-layout.d.ts +53 -23
- package/dist-sdk/src/entities/view/agent-view-layout.js +1 -1
- package/dist-sdk/src/entities/view/from-tf.d.ts +3 -2
- package/dist-sdk/src/entities/view/from-tf.js +124 -12
- package/dist-sdk/src/entities/view/module.js +30 -3
- package/dist-sdk/src/entities/view/to-tf.d.ts +14 -1
- package/dist-sdk/src/entities/view/to-tf.js +67 -10
- package/dist-sdk/src/entities/view/types.d.ts +4 -15
- package/dist-sdk/src/entities/view/types.js +15 -15
- package/dist-sdk/src/entities/widget/build.d.ts +16 -1
- package/dist-sdk/src/entities/widget/build.js +11 -1
- package/dist-sdk/src/entities/widget/to-tf.js +34 -8
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +16 -5
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
- package/dist-sdk/src/graph/index.d.ts +11 -0
- package/dist-sdk/src/graph/index.js +21 -0
- package/dist-sdk/src/graph/modules.js +2 -0
- package/dist-sdk/src/graph/types.d.ts +55 -2
- package/dist-sdk/src/internal/sdk-package.d.ts +1 -1
- package/dist-sdk/src/internal/sdk-package.js +1 -0
- package/package.json +10 -1
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { isUnsafePlatformId } from "../../core/platform-id.js";
|
|
2
|
+
import { dataRefLabel, resourceRefLabel } from "../../engine/pull/context.js";
|
|
3
|
+
import { isTfExpr, scopedLabelToBagKey, tfLabelToTsLabel } from "../../engine/tf/index.js";
|
|
4
|
+
import { SERVICE_ACCOUNT_RESOURCE_TYPE } from "./module.js";
|
|
5
|
+
/**
|
|
6
|
+
* Pull must not report success when a service account's generated roles
|
|
7
|
+
* disagree with the export's `role_ids`. Adoption plans the export, so a
|
|
8
|
+
* clean adopt does not prove the authored source kept every role.
|
|
9
|
+
*/
|
|
10
|
+
export const SERVICE_ACCOUNT_ROLE_MISMATCH_PREFIX = "service-account role_ids mismatch:";
|
|
11
|
+
function sourceFileOf(owner) {
|
|
12
|
+
if (owner.sourceFile !== undefined && owner.sourceFile !== "")
|
|
13
|
+
return owner.sourceFile;
|
|
14
|
+
const ref = tfLabelToTsLabel(owner.ownerTfLabel);
|
|
15
|
+
return `apps/${ref}/${ref}.ts`;
|
|
16
|
+
}
|
|
17
|
+
function describeRoleValue(item) {
|
|
18
|
+
if (typeof item === "string")
|
|
19
|
+
return item;
|
|
20
|
+
if (isTfExpr(item) && (item.$expr === "data-attr" || item.$expr === "resource-attr")) {
|
|
21
|
+
const head = item.$expr === "data-attr" ? `data.${item.type}` : item.type;
|
|
22
|
+
return `${head}.${item.label}.${item.path.join(".")}`;
|
|
23
|
+
}
|
|
24
|
+
return JSON.stringify(item);
|
|
25
|
+
}
|
|
26
|
+
function identityText(identity) {
|
|
27
|
+
if (identity === undefined)
|
|
28
|
+
return "missing";
|
|
29
|
+
if (identity.kind === "unresolved")
|
|
30
|
+
return `unresolved (${identity.detail})`;
|
|
31
|
+
return `${identity.kind}:${identity.value}`;
|
|
32
|
+
}
|
|
33
|
+
function sameIdentity(left, right) {
|
|
34
|
+
if (left.kind === "unresolved" || right.kind === "unresolved") {
|
|
35
|
+
return left.kind === "unresolved" && right.kind === "unresolved" && left.detail === right.detail;
|
|
36
|
+
}
|
|
37
|
+
return left.kind === right.kind && left.value === right.value;
|
|
38
|
+
}
|
|
39
|
+
function exportRoleIdentity(item, blocks, ctx) {
|
|
40
|
+
const resourceLabel = resourceRefLabel(item, "elementum_role");
|
|
41
|
+
if (resourceLabel !== undefined) {
|
|
42
|
+
const role = blocks.find((candidate) => candidate.type === "elementum_role" && candidate.label === resourceLabel);
|
|
43
|
+
if (typeof role?.attrs["name"] === "string" && role.attrs["name"] !== "") {
|
|
44
|
+
return { kind: "name", value: role.attrs["name"] };
|
|
45
|
+
}
|
|
46
|
+
const id = typeof role?.attrs["id"] === "string" ? role.attrs["id"] : ctx.importId(`elementum_role.${resourceLabel}`);
|
|
47
|
+
if (typeof id === "string" && id.trim() !== "")
|
|
48
|
+
return { kind: "id", value: id };
|
|
49
|
+
return { kind: "unresolved", detail: describeRoleValue(item) };
|
|
50
|
+
}
|
|
51
|
+
const dataLabel = dataRefLabel(item, "elementum_role");
|
|
52
|
+
if (dataLabel !== undefined) {
|
|
53
|
+
const name = ctx.dataName("elementum_role", dataLabel);
|
|
54
|
+
if (name !== undefined && name !== "")
|
|
55
|
+
return { kind: "name", value: name };
|
|
56
|
+
return { kind: "unresolved", detail: describeRoleValue(item) };
|
|
57
|
+
}
|
|
58
|
+
if (typeof item === "string" && item.trim() !== "")
|
|
59
|
+
return { kind: "id", value: item };
|
|
60
|
+
return { kind: "unresolved", detail: describeRoleValue(item) };
|
|
61
|
+
}
|
|
62
|
+
function sourceRoleIdentity(role) {
|
|
63
|
+
if (isUnsafePlatformId(role))
|
|
64
|
+
return { kind: "id", value: role.value };
|
|
65
|
+
return { kind: "name", value: role.name };
|
|
66
|
+
}
|
|
67
|
+
function nextStep(sourceFile, key, index) {
|
|
68
|
+
const slot = index === undefined ? `serviceAccounts.${key}.roles` : `serviceAccounts.${key}.roles[${index}]`;
|
|
69
|
+
return `edit ${slot} in ${sourceFile} (add serviceAccountRoleRef("…") or unsafePlatformId("…")) before build/apply; applying as-is changes the account's live roles`;
|
|
70
|
+
}
|
|
71
|
+
function mismatchLine(where, index, exported, generated, sourceFile, key) {
|
|
72
|
+
return `${SERVICE_ACCOUNT_ROLE_MISMATCH_PREFIX} ${where}.role_ids[${index}] export ${identityText(exported)} vs generated ${identityText(generated)}; ${nextStep(sourceFile, key, index)}`;
|
|
73
|
+
}
|
|
74
|
+
function compareRoleLists(where, key, sourceFile, exported, generated, out) {
|
|
75
|
+
if (exported.length === 0 && generated.length === 0)
|
|
76
|
+
return;
|
|
77
|
+
const count = Math.max(exported.length, generated.length);
|
|
78
|
+
for (let index = 0; index < count; index += 1) {
|
|
79
|
+
const left = exported[index];
|
|
80
|
+
const right = generated[index];
|
|
81
|
+
if (left !== undefined && right !== undefined && sameIdentity(left, right))
|
|
82
|
+
continue;
|
|
83
|
+
out.push(mismatchLine(where, index, left, right, sourceFile, key));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function roleListFromRebuild(value, dataQueues, resourceRoleNames) {
|
|
87
|
+
if (value === undefined)
|
|
88
|
+
return [];
|
|
89
|
+
if (!Array.isArray(value))
|
|
90
|
+
return "not-a-list";
|
|
91
|
+
return value.map((item) => {
|
|
92
|
+
const resourceLabel = resourceRefLabel(item, "elementum_role");
|
|
93
|
+
if (resourceLabel !== undefined) {
|
|
94
|
+
const name = resourceRoleNames.get(resourceLabel);
|
|
95
|
+
if (name !== undefined && name !== "")
|
|
96
|
+
return { kind: "name", value: name };
|
|
97
|
+
return { kind: "unresolved", detail: describeRoleValue(item) };
|
|
98
|
+
}
|
|
99
|
+
const dataLabel = dataRefLabel(item, "elementum_role");
|
|
100
|
+
if (dataLabel !== undefined) {
|
|
101
|
+
const name = dataQueues.get(dataLabel)?.shift();
|
|
102
|
+
if (name !== undefined && name !== "")
|
|
103
|
+
return { kind: "name", value: name };
|
|
104
|
+
return { kind: "unresolved", detail: describeRoleValue(item) };
|
|
105
|
+
}
|
|
106
|
+
if (typeof item === "string" && item.trim() !== "")
|
|
107
|
+
return { kind: "id", value: item };
|
|
108
|
+
return { kind: "unresolved", detail: describeRoleValue(item) };
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
function roleList(value, blocks, ctx) {
|
|
112
|
+
if (value === undefined)
|
|
113
|
+
return [];
|
|
114
|
+
if (!Array.isArray(value))
|
|
115
|
+
return "not-a-list";
|
|
116
|
+
return value.map((item) => exportRoleIdentity(item, blocks, ctx));
|
|
117
|
+
}
|
|
118
|
+
function describedRoleIds(value) {
|
|
119
|
+
if (value === undefined)
|
|
120
|
+
return "(none)";
|
|
121
|
+
if (!Array.isArray(value))
|
|
122
|
+
return "not a list";
|
|
123
|
+
return value.map((item) => describeRoleValue(item)).join(", ");
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Order-sensitive comparison of each owned service account's export
|
|
127
|
+
* `role_ids` with the roles written into source. Named roles compare by
|
|
128
|
+
* display name; raw ids compare by platform id. A value the printer cannot
|
|
129
|
+
* represent is a disagreement, not a quiet omission.
|
|
130
|
+
*/
|
|
131
|
+
export function serviceAccountRoleIdMismatches(blocks, accounts, owner, ctx) {
|
|
132
|
+
return compareServiceAccountRoleIds(blocks, accounts, owner, ctx);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Same order-sensitive rule, against service-account blocks rebuilt from
|
|
136
|
+
* the pulled `.ts`. A printer or to-tf that drops or reorders a raw id
|
|
137
|
+
* disagrees here even when extract mirrored the export.
|
|
138
|
+
* When `lookup` is set, rebuilt refs resolve through it. Export refs still
|
|
139
|
+
* use `ctx` and the export blocks.
|
|
140
|
+
*/
|
|
141
|
+
export function rebuiltServiceAccountRoleIdMismatches(exportBlocks, rebuiltBlocks, owner, ctx, lookup) {
|
|
142
|
+
const dataQueues = new Map();
|
|
143
|
+
if (lookup !== undefined) {
|
|
144
|
+
for (const [label, names] of lookup.dataRoleNames)
|
|
145
|
+
dataQueues.set(label, [...names]);
|
|
146
|
+
}
|
|
147
|
+
const rebuiltAccounts = rebuiltBlocks.flatMap((block) => {
|
|
148
|
+
if (block.type !== SERVICE_ACCOUNT_RESOURCE_TYPE || block.label === undefined || block.label === "")
|
|
149
|
+
return [];
|
|
150
|
+
const roles = lookup === undefined
|
|
151
|
+
? roleList(block.attrs["role_ids"], exportBlocks, ctx)
|
|
152
|
+
: roleListFromRebuild(block.attrs["role_ids"], dataQueues, lookup.resourceRoleNames);
|
|
153
|
+
return [{
|
|
154
|
+
key: scopedLabelToBagKey(owner.ownerTfLabel, block.label, "app"),
|
|
155
|
+
label: block.label,
|
|
156
|
+
roles,
|
|
157
|
+
}];
|
|
158
|
+
});
|
|
159
|
+
return compareServiceAccountRoleIds(exportBlocks, rebuiltAccounts.map((account) => ({
|
|
160
|
+
key: account.key,
|
|
161
|
+
roles: account.roles === "not-a-list" ? undefined : account.roles.map((role) => {
|
|
162
|
+
if (role.kind === "id")
|
|
163
|
+
return { __unsafe: "platformId", value: role.value };
|
|
164
|
+
if (role.kind === "name")
|
|
165
|
+
return { __kind: "serviceAccountRole", name: role.value };
|
|
166
|
+
return undefined;
|
|
167
|
+
}).filter((role) => role !== undefined),
|
|
168
|
+
})), owner, ctx, rebuiltAccounts);
|
|
169
|
+
}
|
|
170
|
+
function compareServiceAccountRoleIds(blocks, accounts, owner, ctx, rebuilt) {
|
|
171
|
+
const mismatches = [];
|
|
172
|
+
const sourceFile = sourceFileOf(owner);
|
|
173
|
+
const seen = new Set();
|
|
174
|
+
for (const block of blocks) {
|
|
175
|
+
if (block.type !== SERVICE_ACCOUNT_RESOURCE_TYPE)
|
|
176
|
+
continue;
|
|
177
|
+
if (resourceRefLabel(block.attrs["app_id"], "elementum_app") !== owner.label)
|
|
178
|
+
continue;
|
|
179
|
+
const label = block.label ?? "";
|
|
180
|
+
const where = `${SERVICE_ACCOUNT_RESOURCE_TYPE}.${label || "?"}`;
|
|
181
|
+
const exported = block.attrs["role_ids"];
|
|
182
|
+
if (label === "") {
|
|
183
|
+
if (exported !== undefined) {
|
|
184
|
+
mismatches.push(`${SERVICE_ACCOUNT_ROLE_MISMATCH_PREFIX} ${where} was not written to source (role_ids: ${describedRoleIds(exported)}); ${nextStep(sourceFile, "?", undefined)}`);
|
|
185
|
+
}
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
const key = scopedLabelToBagKey(owner.ownerTfLabel, label, "app");
|
|
189
|
+
seen.add(key);
|
|
190
|
+
const account = accounts.find((candidate) => candidate.key === key);
|
|
191
|
+
const rebuiltAccount = rebuilt?.find((candidate) => candidate.key === key);
|
|
192
|
+
if (!Array.isArray(exported) && exported !== undefined) {
|
|
193
|
+
mismatches.push(`${SERVICE_ACCOUNT_ROLE_MISMATCH_PREFIX} ${where}.role_ids export role_ids is not a list (${describedRoleIds(exported)}); ${nextStep(sourceFile, key, undefined)}`);
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
const exportedRoles = exported === undefined ? [] : exported.map((item) => exportRoleIdentity(item, blocks, ctx));
|
|
197
|
+
if (rebuiltAccount !== undefined) {
|
|
198
|
+
if (rebuiltAccount.roles === "not-a-list") {
|
|
199
|
+
mismatches.push(`${SERVICE_ACCOUNT_ROLE_MISMATCH_PREFIX} ${where}.role_ids rebuild role_ids is not a list; ${nextStep(sourceFile, key, undefined)}`);
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
compareRoleLists(where, key, sourceFile, exportedRoles, rebuiltAccount.roles, mismatches);
|
|
203
|
+
}
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
const generatedRoles = account?.roles?.map(sourceRoleIdentity) ?? [];
|
|
207
|
+
if (account === undefined && exportedRoles.length > 0) {
|
|
208
|
+
mismatches.push(`${SERVICE_ACCOUNT_ROLE_MISMATCH_PREFIX} ${where} was not written to source (role_ids: ${describedRoleIds(exported)}); ${nextStep(sourceFile, key, undefined)}`);
|
|
209
|
+
}
|
|
210
|
+
compareRoleLists(where, key, sourceFile, exportedRoles, generatedRoles, mismatches);
|
|
211
|
+
}
|
|
212
|
+
if (rebuilt === undefined) {
|
|
213
|
+
for (const account of accounts) {
|
|
214
|
+
if (seen.has(account.key) || (account.roles?.length ?? 0) === 0)
|
|
215
|
+
continue;
|
|
216
|
+
mismatches.push(`${SERVICE_ACCOUNT_ROLE_MISMATCH_PREFIX} serviceAccounts.${account.key} has roles with no export service account; ${nextStep(sourceFile, account.key, undefined)}`);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return mismatches;
|
|
220
|
+
}
|
|
221
|
+
/** Authoring files named by role-mismatch lines, in first-seen order. */
|
|
222
|
+
export function serviceAccountRoleMismatchSources(lines) {
|
|
223
|
+
const files = [];
|
|
224
|
+
for (const line of lines) {
|
|
225
|
+
const match = / in (\S+\.ts) /.exec(line);
|
|
226
|
+
if (match?.[1] !== undefined && !files.includes(match[1]))
|
|
227
|
+
files.push(match[1]);
|
|
228
|
+
}
|
|
229
|
+
return files;
|
|
230
|
+
}
|
|
231
|
+
/** Single-root build-vs-export lines that are a service-account `role_ids` disagreement. */
|
|
232
|
+
export function serviceAccountRoleRoundTripMismatches(differences, sourceFile) {
|
|
233
|
+
return differences
|
|
234
|
+
.filter((line) => line.includes("resource:elementum_service_account.") && line.includes("role_ids"))
|
|
235
|
+
.map((line) => `${SERVICE_ACCOUNT_ROLE_MISMATCH_PREFIX} ${line}; edit serviceAccounts in ${sourceFile} (add serviceAccountRoleRef("…") or unsafePlatformId("…")) before build/apply; applying as-is changes the account's live roles`);
|
|
236
|
+
}
|
|
237
|
+
export function serviceAccountRoleGuardBlocksSuccess(diagnostics) {
|
|
238
|
+
return diagnostics.some((line) => line.includes(SERVICE_ACCOUNT_ROLE_MISMATCH_PREFIX));
|
|
239
|
+
}
|
|
240
|
+
/** Adoption failure fails a pull. Role-id disagreement must too, even when adoption succeeded or was skipped. */
|
|
241
|
+
export function serviceAccountPullMustFail(input) {
|
|
242
|
+
return input.adoptionFailed || serviceAccountRoleGuardBlocksSuccess(input.diagnostics);
|
|
243
|
+
}
|
|
@@ -31,3 +31,17 @@ export declare function serviceAccountsToTf(accounts: Readonly<Record<string, Ap
|
|
|
31
31
|
readonly orgRefs: OrgRefLookup;
|
|
32
32
|
readonly diagnostics: string[];
|
|
33
33
|
}): TfBlock[];
|
|
34
|
+
/**
|
|
35
|
+
* Service-account blocks for one app. `appToTf` and the pull role rebuild
|
|
36
|
+
* both call this, so the `roles` bag and the other arguments cannot drift
|
|
37
|
+
* between build and the guard.
|
|
38
|
+
*/
|
|
39
|
+
export declare function appServiceAccountBlocks(payload: {
|
|
40
|
+
readonly serviceAccounts?: Readonly<Record<string, AppServiceAccount>>;
|
|
41
|
+
readonly roles?: Readonly<Record<string, AppRole>>;
|
|
42
|
+
}, opts: {
|
|
43
|
+
readonly ownerTfLabel: string;
|
|
44
|
+
readonly appId: TfValue;
|
|
45
|
+
readonly orgRefs: OrgRefLookup;
|
|
46
|
+
readonly diagnostics: string[];
|
|
47
|
+
}): TfBlock[];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isUnsafePlatformId } from "../../core/platform-id.js";
|
|
1
2
|
import { appScopedResourceLabel, expr, sanitizeName, scopedResourceLabel, tsLabelToTfLabel } from "../../engine/tf/index.js";
|
|
2
3
|
import { SERVICE_ACCOUNT_ACCESS_POLICY_RESOURCE_TYPE, SERVICE_ACCOUNT_RESOURCE_TYPE } from "./module.js";
|
|
3
4
|
/**
|
|
@@ -64,6 +65,8 @@ function principalValues(values, type, where, orgRefs, diagnostics) {
|
|
|
64
65
|
return out.length > 0 ? out : undefined;
|
|
65
66
|
}
|
|
66
67
|
function roleValue(value, roles, ownerTfLabel, appId, orgRefs) {
|
|
68
|
+
if (isUnsafePlatformId(value))
|
|
69
|
+
return value.value;
|
|
67
70
|
const local = Object.entries(roles ?? {}).find(([, role]) => role.name === value.name);
|
|
68
71
|
if (local !== undefined) {
|
|
69
72
|
return expr.resourceAttr("elementum_role", scopedResourceLabel(ownerTfLabel, tsLabelToTfLabel(local[0]), "app"), ["id"]);
|
|
@@ -108,3 +111,17 @@ export function serviceAccountsToTf(accounts, opts) {
|
|
|
108
111
|
}
|
|
109
112
|
return blocks;
|
|
110
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* Service-account blocks for one app. `appToTf` and the pull role rebuild
|
|
116
|
+
* both call this, so the `roles` bag and the other arguments cannot drift
|
|
117
|
+
* between build and the guard.
|
|
118
|
+
*/
|
|
119
|
+
export function appServiceAccountBlocks(payload, opts) {
|
|
120
|
+
return serviceAccountsToTf(payload.serviceAccounts, {
|
|
121
|
+
ownerTfLabel: opts.ownerTfLabel,
|
|
122
|
+
appId: opts.appId,
|
|
123
|
+
roles: payload.roles,
|
|
124
|
+
orgRefs: opts.orgRefs,
|
|
125
|
+
diagnostics: opts.diagnostics,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
@@ -11,7 +11,7 @@ export interface ResolvedAspectTarget {
|
|
|
11
11
|
readonly key: string;
|
|
12
12
|
readonly name: string;
|
|
13
13
|
readonly namespace?: string;
|
|
14
|
-
/** `key
|
|
14
|
+
/** `key` is the target's real catalog identity: pulled, or derived from its namespace (its stream label). */
|
|
15
15
|
readonly catalogRef?: true;
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { tfLabelToTsLabel } from "../../engine/tf/index.js";
|
|
1
|
+
import { sanitizeName, tfLabelToTsLabel } from "../../engine/tf/index.js";
|
|
2
2
|
/**
|
|
3
3
|
* Resolve a foreign app/element data lookup to its display name. Ref-only
|
|
4
4
|
* lookups are intentionally namespace-only, so fall back through the
|
|
@@ -40,7 +40,10 @@ export function dataAspectRefName(ctx, kind, label, displayName) {
|
|
|
40
40
|
}
|
|
41
41
|
const name = displayName ?? dataAspectDisplayName(ctx, kind, label);
|
|
42
42
|
const byName = kind === "app" ? ctx.foreignAppRefNames : kind === "element" ? ctx.foreignElementRefNames : undefined;
|
|
43
|
-
|
|
43
|
+
const pulled = name === undefined ? undefined : byName?.get(name);
|
|
44
|
+
// An app's or element's stream label is its sanitized namespace (ei AppResourceName /
|
|
45
|
+
// ElementResourceName), so the namespace alone gives the real refName before the target is pulled.
|
|
46
|
+
return pulled ?? (namespace === undefined ? undefined : tfLabelToTsLabel(sanitizeName(namespace)));
|
|
44
47
|
}
|
|
45
48
|
/**
|
|
46
49
|
* Resolve a foreign app/element data lookup to the full identity a caller
|
|
@@ -82,6 +82,14 @@ export interface SearchTableRefAst {
|
|
|
82
82
|
readonly kind: "searchTable";
|
|
83
83
|
readonly appHandle: string;
|
|
84
84
|
readonly tableKey: string;
|
|
85
|
+
/** Table-owned lookup. Element-owned catalog refs leave this unset. */
|
|
86
|
+
readonly ownerKind?: "table" | "element";
|
|
87
|
+
/** Display name of the search table, when the reference is not a catalog key. */
|
|
88
|
+
readonly name?: string;
|
|
89
|
+
/** Display name of a table owner. */
|
|
90
|
+
readonly parentName?: string;
|
|
91
|
+
/** Set when the search table's name is not unique on its owner. */
|
|
92
|
+
readonly id?: string;
|
|
85
93
|
}
|
|
86
94
|
/** Reference to an app-owned phone service. */
|
|
87
95
|
export interface PhoneServiceRefAst {
|
|
@@ -23,6 +23,8 @@ export interface FilterReferenceInput {
|
|
|
23
23
|
readonly [FILTER_REFERENCE_BRAND]: true;
|
|
24
24
|
readonly ref: Ref<unknown> | string;
|
|
25
25
|
readonly valueType: ValueType;
|
|
26
|
+
/** The caller named this type. Build must not replace it with field metadata. */
|
|
27
|
+
readonly explicit: true;
|
|
26
28
|
readonly multiple?: boolean;
|
|
27
29
|
}
|
|
28
30
|
export declare function boolean(ref: Ref<unknown> | string, options?: {
|
|
@@ -52,7 +52,7 @@ export function referenceValueTypeForField(fieldType, suffix = "") {
|
|
|
52
52
|
}
|
|
53
53
|
const FILTER_REFERENCE_BRAND = Symbol("FilterReferenceInput");
|
|
54
54
|
function referenceInput(ref, valueType, options) {
|
|
55
|
-
return { [FILTER_REFERENCE_BRAND]: true, ref, valueType, ...(options?.multiple === true && { multiple: true }) };
|
|
55
|
+
return { [FILTER_REFERENCE_BRAND]: true, ref, valueType, explicit: true, ...(options?.multiple === true && { multiple: true }) };
|
|
56
56
|
}
|
|
57
57
|
export function boolean(ref, options) {
|
|
58
58
|
return referenceInput(ref, "BOOLEAN", options);
|
|
@@ -174,15 +174,25 @@ function leftType(left, fallback, explicit) {
|
|
|
174
174
|
return fallback;
|
|
175
175
|
return fieldTypeToValueType(isAppField(left) ? left.type : "fieldType" in left ? left.fieldType : undefined);
|
|
176
176
|
}
|
|
177
|
+
function referenceValue(realType, value, explicit) {
|
|
178
|
+
return {
|
|
179
|
+
type: "REFERENCE",
|
|
180
|
+
realType,
|
|
181
|
+
// A passed comparison type (`filter.eq(ref, value, "TEXT")`) is authored.
|
|
182
|
+
// An omitted type is the operator fallback, which field metadata may replace.
|
|
183
|
+
...(explicit !== undefined ? { explicit: true } : {}),
|
|
184
|
+
value,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
177
187
|
function leftDescriptor(left, fallback, explicit) {
|
|
178
188
|
if (isFieldLeftValue(left))
|
|
179
189
|
return { leftValue: left };
|
|
180
190
|
if (isFilterReferenceInput(left))
|
|
181
191
|
return { leftValue: toFilterValue(left) };
|
|
182
192
|
if (isRef(left))
|
|
183
|
-
return { leftValue:
|
|
193
|
+
return { leftValue: referenceValue(explicit ?? fallback, refDataToFilterReference(left.__data), explicit) };
|
|
184
194
|
if (typeof left === "string" && left.startsWith(UNRESOLVED_REFERENCE_MARKER)) {
|
|
185
|
-
return { leftValue:
|
|
195
|
+
return { leftValue: referenceValue(explicit ?? fallback, { __rawFilterReference: left.slice(UNRESOLVED_REFERENCE_MARKER.length) }, explicit) };
|
|
186
196
|
}
|
|
187
197
|
return { field: fieldWireValue(left) };
|
|
188
198
|
}
|
|
@@ -204,7 +214,7 @@ export function toFilterValue(input, valueType = "TEXT") {
|
|
|
204
214
|
: typeof input.ref === "string"
|
|
205
215
|
? { __rawFilterReference: input.ref }
|
|
206
216
|
: refDataToFilterReference(input.ref.__data);
|
|
207
|
-
return { type: "REFERENCE", realType: input.valueType, value, ...(input.multiple === true && { multiple: true }) };
|
|
217
|
+
return { type: "REFERENCE", realType: input.valueType, explicit: true, value, ...(input.multiple === true && { multiple: true }) };
|
|
208
218
|
}
|
|
209
219
|
if (isRef(input)) {
|
|
210
220
|
if (input.__data.kind === "static")
|
|
@@ -13,9 +13,12 @@ export function printFilter(filter, codec) {
|
|
|
13
13
|
: "min" in filter ? [filter.min, filter.max] : [];
|
|
14
14
|
const uuidValues = literals.length > 0 && literals.every((literal) => literal.type === "UUID");
|
|
15
15
|
const explicitType = uuidValues ? `, ${quote("UUID")}` : "";
|
|
16
|
+
const impliedLiteralType = stringLiteralTypeImpliedBy(filter, uuidValues);
|
|
16
17
|
const value = (input) => input.type === "UUID"
|
|
17
18
|
? uuidValues ? quote(input.value) : `{ type: "UUID", value: ${quote(input.value)} }`
|
|
18
|
-
:
|
|
19
|
+
: (input.type === "TEXT" || input.type === "DATE" || input.type === "DATETIME") && impliedLiteralType !== undefined && input.type !== impliedLiteralType
|
|
20
|
+
? `{ type: ${quote(input.type)}, value: ${quote(input.value)} }`
|
|
21
|
+
: printFilterValue(input, codec, call, quote);
|
|
19
22
|
if ("leftValue" in filter && filter.leftValue?.type === "FIELD") {
|
|
20
23
|
const operand = filter.leftValue;
|
|
21
24
|
if ((operand.aspect != null && operand.aspect !== "") || (operand.treatNullAsEquals != null && operand.treatNullAsEquals !== true)) {
|
|
@@ -76,6 +79,19 @@ export function printFilter(filter, codec) {
|
|
|
76
79
|
];
|
|
77
80
|
return options.length === 0 ? printed : call("withOptions", `${printed}, { ${options.join(", ")} }`);
|
|
78
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* The type `filter.*` gives a bare string literal when the left operand prints as a typed reference wrapper
|
|
84
|
+
* (`filter.uuid(…)`, `filter.date(…)`): the wrapper's type, narrowed to the string-valued ones, else TEXT.
|
|
85
|
+
* Undefined for every other left operand, whose literals already print as before.
|
|
86
|
+
*/
|
|
87
|
+
function stringLiteralTypeImpliedBy(filter, uuidValues) {
|
|
88
|
+
if (!("leftValue" in filter) || filter.leftValue?.type !== "REFERENCE" || filter.leftValue.realType === undefined)
|
|
89
|
+
return undefined;
|
|
90
|
+
if (uuidValues)
|
|
91
|
+
return "UUID";
|
|
92
|
+
const realType = filter.leftValue.realType;
|
|
93
|
+
return realType === "UUID" || realType === "DATE" || realType === "DATETIME" ? realType : "TEXT";
|
|
94
|
+
}
|
|
79
95
|
function printLikeOptions(filter, quote) {
|
|
80
96
|
const options = [];
|
|
81
97
|
if (filter.not === true)
|
|
@@ -104,6 +104,8 @@ export interface FilterToTfCodec {
|
|
|
104
104
|
* Return a GraphQL ValueType (TEXT/UUID/NUMBER/…) or undefined to keep the
|
|
105
105
|
* authored/default value. Used when a trigger-record Ref's field metadata
|
|
106
106
|
* is a better authority than `isNull`'s TEXT operator fallback.
|
|
107
|
+
* Not called for an explicit wrapper (`filter.text()`, `filter.uuid()`, …):
|
|
108
|
+
* that authored type is kept as written.
|
|
107
109
|
*/
|
|
108
110
|
readonly referenceRealType?: (reference: unknown, role: "left" | "value", authored: string | undefined) => string | undefined;
|
|
109
111
|
}
|
|
@@ -205,7 +205,11 @@ function wireFilterValueToTf(value, field, codec, role = "value", operator) {
|
|
|
205
205
|
throw new EntityTfError("reference filter value requires value");
|
|
206
206
|
const authored = raw.realType ?? raw.real_type;
|
|
207
207
|
const authoredType = typeof authored === "string" ? authored : undefined;
|
|
208
|
-
|
|
208
|
+
// `filter.text()` and the other typed wrappers set `explicit`. That type
|
|
209
|
+
// is the comparison the author wrote. Metadata inference replaces only an
|
|
210
|
+
// unmarked operator fallback (dropdown `.id` TEXT → UUID).
|
|
211
|
+
const explicit = raw.explicit === true;
|
|
212
|
+
const inferred = explicit ? authoredType : codec.referenceRealType?.(reference, role, authoredType);
|
|
209
213
|
const realType = String(inferred ?? authoredType ?? "TEXT");
|
|
210
214
|
// ei export always writes an explicit `multiple = false` on scalar text
|
|
211
215
|
// references. Omitting it plans null-vs-false drift after pull.
|
|
@@ -77,9 +77,17 @@ export type FilterValue<FieldValue = string, ReferenceValue = FilterReference> =
|
|
|
77
77
|
dynamicField?: string;
|
|
78
78
|
dynamicFieldAspect?: string;
|
|
79
79
|
required?: boolean;
|
|
80
|
-
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* `explicit` is set by `filter.text()` / `filter.uuid()` / the other typed
|
|
83
|
+
* wrappers, and by an explicit comparison type. Build keeps that type.
|
|
84
|
+
* Without it, `realType` is only the operator fallback and field metadata
|
|
85
|
+
* may replace TEXT (a dropdown `.id` infers UUID).
|
|
86
|
+
*/
|
|
87
|
+
| {
|
|
81
88
|
type: "REFERENCE";
|
|
82
89
|
realType?: ValueType;
|
|
90
|
+
explicit?: true;
|
|
83
91
|
value: ReferenceValue;
|
|
84
92
|
label?: string;
|
|
85
93
|
multiple?: boolean;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AppOrElementRef } from "../../../catalog/types.js";
|
|
2
2
|
import type { RecordShape } from "../../field/record-shape.js";
|
|
3
|
+
import type { CalculationTypedValue } from "../ref.js";
|
|
3
4
|
/**
|
|
4
5
|
* WorkflowFieldType — mirrors the Java enum in
|
|
5
6
|
* jarvis/util/.../WorkflowFieldType.java
|
|
@@ -21,6 +22,9 @@ export type WorkflowFieldType = "TEXT" | "HANDLE" | "NUMBER" | "DECIMAL" | "BOOL
|
|
|
21
22
|
* ATTACHMENT_ID -> "attachment" (and from-tf.ts the inverse) rather than
|
|
22
23
|
* renaming this alias, to avoid a breaking change to authored `onDemand({})`
|
|
23
24
|
* calls that already use `type: "attachmentId"`.
|
|
25
|
+
*
|
|
26
|
+
* `userId` follows the same rule: the provider's attribute spells USER_ID as
|
|
27
|
+
* a bare "user", so to-tf maps USER_ID -> "user" and from-tf maps it back.
|
|
24
28
|
*/
|
|
25
29
|
export declare const FIELD_TYPE_MAP: {
|
|
26
30
|
readonly text: "TEXT";
|
|
@@ -30,6 +34,7 @@ export declare const FIELD_TYPE_MAP: {
|
|
|
30
34
|
readonly date: "DATE";
|
|
31
35
|
readonly datetime: "DATETIME";
|
|
32
36
|
readonly user: "USER";
|
|
37
|
+
readonly userId: "USER_ID";
|
|
33
38
|
readonly json: "JSON";
|
|
34
39
|
readonly object: "OBJECT";
|
|
35
40
|
readonly attachmentId: "ATTACHMENT_ID";
|
|
@@ -41,14 +46,14 @@ export declare function isOnDemandRecordType(type: string | undefined): boolean;
|
|
|
41
46
|
/**
|
|
42
47
|
* Subset of {@link FieldTypeAlias} that Mobius's `onDemand` trigger
|
|
43
48
|
* validator accepts. Mobius rejects `WorkflowFieldType.USER` and
|
|
44
|
-
* `WorkflowFieldType.GROUP`
|
|
49
|
+
* `WorkflowFieldType.GROUP` on trigger params:
|
|
45
50
|
*
|
|
46
51
|
* parameter[submitter]: Parameter type USER is not valid for this trigger.
|
|
47
52
|
*
|
|
48
53
|
* We model the restriction at the type level so `onDemand({ x: { type: "user" } })`
|
|
49
|
-
* is a compile-time error, not a deploy-time 400.
|
|
50
|
-
*
|
|
51
|
-
*
|
|
54
|
+
* is a compile-time error, not a deploy-time 400. A user input is a
|
|
55
|
+
* `userId` (USER_ID) parameter; a Run Automation button binds it to the
|
|
56
|
+
* clicking user with `runAutomationParameterValue.triggeredByUser`.
|
|
52
57
|
*/
|
|
53
58
|
export type TriggerFieldTypeAlias = Exclude<FieldTypeAlias, "user">;
|
|
54
59
|
/**
|
|
@@ -60,4 +65,4 @@ export type TriggerFieldTypeAlias = Exclude<FieldTypeAlias, "user">;
|
|
|
60
65
|
* Used when generating app definitions from Hydra's field metadata.
|
|
61
66
|
*/
|
|
62
67
|
export declare const ASPECT_FIELD_TYPE_NAME_TO_WORKFLOW_FIELD_TYPE: Record<string, WorkflowFieldType>;
|
|
63
|
-
export type FieldTypeToTS<A extends FieldTypeAlias> = A extends "text" ? string : A extends "number" | "decimal" ? number : A extends "boolean" ? boolean : A extends "date" | "datetime" ? string : A extends "user" ? string : A extends "attachmentId" ? string : A extends "json" | "object" ? unknown : A extends "record" ? RecordShape<AppOrElementRef> : unknown;
|
|
68
|
+
export type FieldTypeToTS<A extends FieldTypeAlias> = A extends "text" ? string : A extends "number" | "decimal" ? number : A extends "boolean" ? boolean : A extends "date" | "datetime" ? string : A extends "user" ? string : A extends "userId" ? CalculationTypedValue<string, "user"> : A extends "attachmentId" ? string : A extends "json" | "object" ? unknown : A extends "record" ? RecordShape<AppOrElementRef> : unknown;
|
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
* ATTACHMENT_ID -> "attachment" (and from-tf.ts the inverse) rather than
|
|
11
11
|
* renaming this alias, to avoid a breaking change to authored `onDemand({})`
|
|
12
12
|
* calls that already use `type: "attachmentId"`.
|
|
13
|
+
*
|
|
14
|
+
* `userId` follows the same rule: the provider's attribute spells USER_ID as
|
|
15
|
+
* a bare "user", so to-tf maps USER_ID -> "user" and from-tf maps it back.
|
|
13
16
|
*/
|
|
14
17
|
export const FIELD_TYPE_MAP = {
|
|
15
18
|
text: "TEXT",
|
|
@@ -19,6 +22,7 @@ export const FIELD_TYPE_MAP = {
|
|
|
19
22
|
date: "DATE",
|
|
20
23
|
datetime: "DATETIME",
|
|
21
24
|
user: "USER",
|
|
25
|
+
userId: "USER_ID",
|
|
22
26
|
json: "JSON",
|
|
23
27
|
object: "OBJECT",
|
|
24
28
|
attachmentId: "ATTACHMENT_ID",
|
|
@@ -341,7 +341,8 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
|
|
|
341
341
|
if (tool.target?.kind === "tableOwned") {
|
|
342
342
|
const owner = tool.searchTableOwnerRefName ?? parent;
|
|
343
343
|
const ownerName = tool.searchTableOwnerName;
|
|
344
|
-
|
|
344
|
+
const pinnedId = tool.searchTableId !== undefined ? `, id: ${quote(tool.searchTableId)}` : "";
|
|
345
|
+
lines.push(` table: tableSearchTableRef({ name: ${quote(tool.searchTableName ?? "")}, parent: ${quote(owner)}${ownerName !== undefined ? `, parentName: ${quote(ownerName)}` : ""}${pinnedId} }),`);
|
|
345
346
|
}
|
|
346
347
|
else if (typedTable !== undefined) {
|
|
347
348
|
lines.push(` table: catalog.${typedTable.ownerRefName}.searchTables${safeMember(typedTable.tableKey)},`);
|