@elementumai/edk 0.10.4 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -7
- package/dist-sdk/src/catalog/token.js +2 -1
- package/dist-sdk/src/core/wire/ref-serializer.js +26 -1
- package/dist-sdk/src/engine/build/context.d.ts +4 -0
- package/dist-sdk/src/engine/coverage-gaps.d.ts +2 -0
- package/dist-sdk/src/engine/coverage-gaps.js +3 -0
- package/dist-sdk/src/engine/ei/json-stream-reader.d.ts +43 -0
- package/dist-sdk/src/engine/ei/json-stream-reader.js +234 -0
- package/dist-sdk/src/engine/ei/run.d.ts +22 -0
- package/dist-sdk/src/engine/ei/run.js +99 -18
- package/dist-sdk/src/engine/ei/saved-plan.d.ts +16 -0
- package/dist-sdk/src/engine/ei/saved-plan.js +19 -0
- package/dist-sdk/src/engine/ei/state.d.ts +1 -1
- package/dist-sdk/src/engine/ei/state.js +17 -4
- package/dist-sdk/src/engine/progress.d.ts +3 -1
- package/dist-sdk/src/engine/progress.js +7 -3
- package/dist-sdk/src/engine/pull/authored-address.d.ts +15 -1
- package/dist-sdk/src/engine/pull/authored-address.js +180 -29
- package/dist-sdk/src/engine/pull/context.d.ts +37 -2
- package/dist-sdk/src/engine/pull/context.js +7 -4
- package/dist-sdk/src/engine/tf/index.d.ts +2 -2
- package/dist-sdk/src/engine/tf/index.js +2 -2
- package/dist-sdk/src/engine/tf/labels.d.ts +22 -0
- package/dist-sdk/src/engine/tf/labels.js +50 -0
- package/dist-sdk/src/engine/tf/model.d.ts +2 -0
- package/dist-sdk/src/engine/tf/model.js +26 -0
- package/dist-sdk/src/engine/validation.d.ts +2 -0
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +17 -0
- package/dist-sdk/src/entities/access-policy/from-tf.js +52 -24
- package/dist-sdk/src/entities/access-policy/member-list.d.ts +32 -0
- package/dist-sdk/src/entities/access-policy/member-list.js +57 -0
- package/dist-sdk/src/entities/access-policy/module.js +5 -0
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +4 -3
- package/dist-sdk/src/entities/access-policy/to-tf.js +21 -12
- package/dist-sdk/src/entities/agent/build.js +7 -5
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +2 -0
- package/dist-sdk/src/entities/agent/from-tf.js +13 -3
- package/dist-sdk/src/entities/agent/to-tf.js +11 -5
- package/dist-sdk/src/entities/agent/tools.d.ts +8 -0
- package/dist-sdk/src/entities/agent/tools.js +6 -2
- package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +29 -0
- package/dist-sdk/src/entities/agent-tool/to-tf.js +56 -3
- package/dist-sdk/src/entities/agent-tool/types.d.ts +12 -8
- package/dist-sdk/src/entities/agent-tool/types.js +13 -9
- package/dist-sdk/src/entities/app/build.d.ts +11 -0
- package/dist-sdk/src/entities/app/build.js +1 -0
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +5 -7
- package/dist-sdk/src/entities/app/from-tf.js +16 -10
- package/dist-sdk/src/entities/app/to-tf.js +6 -4
- package/dist-sdk/src/entities/automation/build.d.ts +2 -7
- package/dist-sdk/src/entities/automation/build.js +43 -14
- package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +7 -4
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +7 -11
- package/dist-sdk/src/entities/automation/from-tf.d.ts +23 -1
- package/dist-sdk/src/entities/automation/from-tf.js +456 -34
- package/dist-sdk/src/entities/automation/index.d.ts +1 -1
- package/dist-sdk/src/entities/automation/module.d.ts +22 -2
- package/dist-sdk/src/entities/automation/module.js +244 -57
- package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +22 -2
- package/dist-sdk/src/entities/automation/output-key-wire-name.js +54 -3
- package/dist-sdk/src/entities/automation/run-target.d.ts +59 -0
- package/dist-sdk/src/entities/automation/run-target.js +99 -0
- package/dist-sdk/src/entities/automation/script-code.d.ts +9 -0
- package/dist-sdk/src/entities/automation/script-code.js +24 -3
- package/dist-sdk/src/entities/automation/task-output-labels.d.ts +16 -0
- package/dist-sdk/src/entities/automation/task-output-labels.js +49 -0
- package/dist-sdk/src/entities/automation/tasks.d.ts +20 -8
- package/dist-sdk/src/entities/automation/to-tf.d.ts +1 -3
- package/dist-sdk/src/entities/automation/to-tf.js +102 -40
- package/dist-sdk/src/entities/automation/triggers.d.ts +22 -3
- package/dist-sdk/src/entities/automation/triggers.js +40 -0
- package/dist-sdk/src/entities/automation/types.d.ts +21 -0
- package/dist-sdk/src/entities/automation/types.js +26 -0
- package/dist-sdk/src/entities/dashboard/from-tf.d.ts +11 -1
- package/dist-sdk/src/entities/dashboard/from-tf.js +57 -7
- package/dist-sdk/src/entities/dashboard/to-tf.js +13 -0
- package/dist-sdk/src/entities/dynamic-layout/build.d.ts +7 -2
- package/dist-sdk/src/entities/dynamic-layout/from-tf.d.ts +3 -0
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +65 -19
- package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +4 -2
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +341 -32
- package/dist-sdk/src/entities/element/build.d.ts +10 -0
- package/dist-sdk/src/entities/element/build.js +1 -0
- package/dist-sdk/src/entities/element/from-tf.js +14 -9
- package/dist-sdk/src/entities/element/to-tf.js +6 -4
- package/dist-sdk/src/entities/field/from-tf.d.ts +24 -0
- package/dist-sdk/src/entities/field/from-tf.js +79 -1
- package/dist-sdk/src/entities/field/module.js +7 -0
- package/dist-sdk/src/entities/field/to-tf.d.ts +30 -1
- package/dist-sdk/src/entities/field/to-tf.js +51 -0
- package/dist-sdk/src/entities/file-reader/module.js +3 -3
- package/dist-sdk/src/entities/file-reader/to-tf.js +3 -3
- package/dist-sdk/src/entities/file-reader/types.d.ts +4 -16
- package/dist-sdk/src/entities/file-reader/types.js +7 -0
- package/dist-sdk/src/entities/org/group.d.ts +1 -0
- package/dist-sdk/src/entities/org/group.js +2 -1
- package/dist-sdk/src/entities/record-create-form/from-tf.d.ts +8 -0
- package/dist-sdk/src/entities/record-create-form/from-tf.js +10 -2
- package/dist-sdk/src/entities/record-create-form/to-tf.d.ts +2 -1
- package/dist-sdk/src/entities/record-create-form/to-tf.js +14 -2
- package/dist-sdk/src/entities/relationship/from-tf.d.ts +8 -0
- package/dist-sdk/src/entities/relationship/from-tf.js +88 -10
- package/dist-sdk/src/entities/relationship/to-tf.d.ts +3 -2
- package/dist-sdk/src/entities/relationship/to-tf.js +79 -8
- package/dist-sdk/src/entities/role/from-tf.js +24 -7
- package/dist-sdk/src/entities/role/to-tf.js +25 -7
- package/dist-sdk/src/entities/service-account/from-tf.js +2 -1
- package/dist-sdk/src/entities/service-account/module.js +15 -0
- package/dist-sdk/src/entities/service-account/to-tf.js +12 -4
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +1 -1
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +12 -7
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +5 -2
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +8 -1
- package/dist-sdk/src/entities/skill/from-tf.js +10 -3
- package/dist-sdk/src/entities/skill/module.js +16 -0
- package/dist-sdk/src/entities/skill/to-tf.d.ts +8 -1
- package/dist-sdk/src/entities/skill/to-tf.js +23 -14
- package/dist-sdk/src/entities/skill/tools.d.ts +8 -0
- package/dist-sdk/src/entities/skill/tools.js +6 -2
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +8 -0
- package/dist-sdk/src/entities/skill-tool/to-tf.js +6 -2
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +8 -2
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +20 -10
- package/dist-sdk/src/entities/view/from-tf.d.ts +60 -0
- package/dist-sdk/src/entities/view/from-tf.js +391 -17
- package/dist-sdk/src/entities/view/module.js +15 -0
- package/dist-sdk/src/entities/view/portable.d.ts +11 -0
- package/dist-sdk/src/entities/view/portable.js +47 -0
- package/dist-sdk/src/entities/view/to-tf.d.ts +4 -1
- package/dist-sdk/src/entities/view/to-tf.js +25 -7
- package/dist-sdk/src/entities/view/types.js +1 -1
- package/dist-sdk/src/entities/widget/build.d.ts +4 -3
- package/dist-sdk/src/entities/widget/from-tf.d.ts +3 -0
- package/dist-sdk/src/entities/widget/from-tf.js +100 -3
- package/dist-sdk/src/entities/widget/to-tf.d.ts +16 -1
- package/dist-sdk/src/entities/widget/to-tf.js +77 -14
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +27 -8
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
- package/dist-sdk/src/graph/field-resource-types.d.ts +2 -0
- package/dist-sdk/src/graph/field-resource-types.js +11 -0
- package/dist-sdk/src/graph/index.d.ts +28 -3
- package/dist-sdk/src/graph/index.js +12 -2
- package/dist-sdk/src/graph/types.d.ts +157 -5
- package/package.json +1 -1
|
@@ -2,11 +2,12 @@ import { workspaceAspectKey, } from "../../engine/build/context.js";
|
|
|
2
2
|
import { expr, isCanonicalTsLabel, scopedResourceLabel, tsLabelToTfLabel, } from "../../engine/tf/index.js";
|
|
3
3
|
import { filterToTf } from "../access-policy/to-tf.js";
|
|
4
4
|
import { foreignFieldDataLabel, resolveForeignRef } from "../shared/foreign-ref.js";
|
|
5
|
-
import { authoredFieldKeysFromPayload, fieldRefToTfValue, } from "../field/to-tf.js";
|
|
5
|
+
import { authoredFieldKeysFromPayload, droppedEntryGap, fieldLookupName, fieldRefToTfValue, skippedResourceGap, unauthoredSiblingFieldRef, UNRESOLVED_FIELD_REF, } from "../field/to-tf.js";
|
|
6
6
|
import { SYSTEM_FIELD_ID_ATTR_BY_KEY } from "../view/types.js";
|
|
7
7
|
import { autoRelationColumnError } from "./column-contract.js";
|
|
8
8
|
import { RELATIONSHIP_RESOURCE_TYPE } from "./module.js";
|
|
9
9
|
import { EntityTfError } from "../../engine/entity.js";
|
|
10
|
+
import { isUnsafePlatformId } from "../../core/platform-id.js";
|
|
10
11
|
export function relationshipsToTf(relationships, opts) {
|
|
11
12
|
const blocks = [];
|
|
12
13
|
for (const [key, relationship] of Object.entries(relationships ?? {})) {
|
|
@@ -25,22 +26,52 @@ export function relationshipsToTf(relationships, opts) {
|
|
|
25
26
|
`Model the link with a reference field on "${opts.ownerRefName}" instead, or relate through a child element.`);
|
|
26
27
|
}
|
|
27
28
|
const columns = [];
|
|
28
|
-
|
|
29
|
+
// A relationship whose every column was dropped for an invalid join is
|
|
30
|
+
// left out rather than built with no join at all. When a field build
|
|
31
|
+
// can't resolve dropped one, build fails instead (Dax, #1978): leaving
|
|
32
|
+
// out an adopted relationship would make plan destroy it.
|
|
33
|
+
let droppedColumn = false;
|
|
34
|
+
const unresolvedColumns = [];
|
|
29
35
|
for (const [index, column] of (relationship.columns ?? []).entries()) {
|
|
30
36
|
const columnWhere = `${where}.columns[${index}]`;
|
|
31
|
-
const contractError =
|
|
37
|
+
const contractError = isUnsafePlatformId(column.field) || isUnsafePlatformId(column.relatedField)
|
|
38
|
+
? undefined
|
|
39
|
+
: autoRelationColumnError(column.field, column.relatedField);
|
|
32
40
|
if (contractError !== undefined) {
|
|
33
41
|
opts.diagnostics.push(`${columnWhere}: ${contractError}; dropped`);
|
|
34
|
-
|
|
42
|
+
droppedColumn = true;
|
|
35
43
|
continue;
|
|
36
44
|
}
|
|
37
45
|
const field = resolveOwnerField(column.field, `${columnWhere}.field`, opts);
|
|
38
|
-
|
|
46
|
+
// Another app's or element's field that its source doesn't have has no
|
|
47
|
+
// resource to reference (#1966): look it up on the platform by name, as
|
|
48
|
+
// the export did. A ref with no name can't be resolved, so it drops.
|
|
49
|
+
const unauthored = unauthoredRelatedField(column.relatedField, target, opts);
|
|
50
|
+
if (unauthored !== undefined && unauthored.name === undefined) {
|
|
51
|
+
opts.diagnostics.push(droppedEntryGap(`${columnWhere}.relatedField`, `${unauthored.reason}; column dropped`, "relationship"));
|
|
52
|
+
}
|
|
53
|
+
const relatedField = unauthored === undefined
|
|
54
|
+
? resolveRelatedField(column.relatedField, target, `${columnWhere}.relatedField`, opts)
|
|
55
|
+
: unauthored.name === undefined
|
|
56
|
+
? undefined
|
|
57
|
+
: relatedFieldLookup(target, unauthored.name, opts);
|
|
39
58
|
if (field !== undefined && relatedField !== undefined)
|
|
40
59
|
columns.push({ field_id: field, related_field_id: relatedField });
|
|
60
|
+
else {
|
|
61
|
+
droppedColumn = true;
|
|
62
|
+
unresolvedColumns.push(field === undefined
|
|
63
|
+
? `${columnWhere}.field: ${describeFieldRef(column.field)}`
|
|
64
|
+
: `${columnWhere}.relatedField: ${unauthored?.reason ?? describeFieldRef(column.relatedField)}`);
|
|
65
|
+
}
|
|
41
66
|
}
|
|
42
|
-
if (columns.length === 0 &&
|
|
43
|
-
opts.
|
|
67
|
+
if (columns.length === 0 && unresolvedColumns.length > 0) {
|
|
68
|
+
throw new EntityTfError(`${opts.ownerType === "elementum_app" ? "app" : "element"} "${opts.ownerRefName}" ${where}: no join column is left, because build ` +
|
|
69
|
+
`can't resolve these field references:\n${unresolvedColumns.map((column) => ` - ${column}`).join("\n")}\n` +
|
|
70
|
+
"Build refuses to leave the relationship out: if it is already managed, plan would destroy it. " +
|
|
71
|
+
"Point each column at a field in source (or its unsafePlatformId), or remove the relationship (#1978).");
|
|
72
|
+
}
|
|
73
|
+
if (columns.length === 0 && droppedColumn) {
|
|
74
|
+
opts.diagnostics.push(skippedResourceGap(where, "no valid join columns remain; relationship left out of build", "relationship"));
|
|
44
75
|
continue;
|
|
45
76
|
}
|
|
46
77
|
const attrs = {
|
|
@@ -74,7 +105,20 @@ export function relationshipsToTf(relationships, opts) {
|
|
|
74
105
|
}
|
|
75
106
|
return blocks;
|
|
76
107
|
}
|
|
108
|
+
/** How an unresolved column field reference reads in a build error (#1978). */
|
|
109
|
+
function describeFieldRef(value) {
|
|
110
|
+
if (value == null)
|
|
111
|
+
return UNRESOLVED_FIELD_REF;
|
|
112
|
+
return `field reference ${JSON.stringify(value)} does not resolve`;
|
|
113
|
+
}
|
|
77
114
|
function resolveOwnerField(value, where, opts) {
|
|
115
|
+
// A field pull did not extract stays as its platform id (#1736, #1966).
|
|
116
|
+
if (isUnsafePlatformId(value))
|
|
117
|
+
return value.value;
|
|
118
|
+
if (value == null) {
|
|
119
|
+
opts.diagnostics.push(droppedEntryGap(where, `${UNRESOLVED_FIELD_REF}; column dropped`, "relationship"));
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
78
122
|
if (typeof value === "string") {
|
|
79
123
|
if (opts.scope === "element" && value !== "id" && value !== "title") {
|
|
80
124
|
opts.diagnostics.push(`${where}: element relationships only support system fields "id" and "title"; dropped`);
|
|
@@ -161,7 +205,31 @@ export function targetFilterFieldResolver(targetToken, where, opts) {
|
|
|
161
205
|
? resolveRelatedField({ __kind: "field", ...token }, target, fieldWhere, opts)
|
|
162
206
|
: undefined;
|
|
163
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* A join column's related field that another app or element of this
|
|
210
|
+
* workspace doesn't have in source (#1966): why its resource can't be built,
|
|
211
|
+
* and the name to look it up by instead, if the ref has one. Undefined for the
|
|
212
|
+
* relationship's own owner, an unmanaged target, a kept platform id, or any
|
|
213
|
+
* other reference `resolveRelatedField` handles.
|
|
214
|
+
*/
|
|
215
|
+
function unauthoredRelatedField(value, target, opts) {
|
|
216
|
+
if (value === undefined || isUnsafePlatformId(value) || value.__kind === "recordIdentity")
|
|
217
|
+
return undefined;
|
|
218
|
+
if (!target.managed || (target.kind !== "app" && target.kind !== "element"))
|
|
219
|
+
return undefined;
|
|
220
|
+
if (target.kind === opts.scope && target.refName === opts.ownerRefName)
|
|
221
|
+
return undefined;
|
|
222
|
+
const refName = value.refName ?? "";
|
|
223
|
+
if (refName === "" || (value.parent !== undefined && value.parent !== target.refName))
|
|
224
|
+
return undefined;
|
|
225
|
+
const reason = unauthoredSiblingFieldRef(refName, { kind: target.kind, refName: target.refName, fieldOwnership: target.fieldOwnership });
|
|
226
|
+
return reason === undefined ? undefined : { reason, name: fieldLookupName(value) };
|
|
227
|
+
}
|
|
164
228
|
function resolveRelatedField(value, target, where, opts) {
|
|
229
|
+
// A related field pull kept by its platform id: another owner's field ei
|
|
230
|
+
// couldn't name (#1991).
|
|
231
|
+
if (isUnsafePlatformId(value))
|
|
232
|
+
return value.value;
|
|
165
233
|
if (value?.__kind === "recordIdentity") {
|
|
166
234
|
if (value.target === undefined) {
|
|
167
235
|
opts.diagnostics.push(`${where}: record identity has no target; dropped`);
|
|
@@ -199,7 +267,10 @@ function resolveRelatedField(value, target, where, opts) {
|
|
|
199
267
|
if (direct !== undefined)
|
|
200
268
|
return direct;
|
|
201
269
|
}
|
|
202
|
-
|
|
270
|
+
return relatedFieldLookup(target, value?.name ?? refName, opts);
|
|
271
|
+
}
|
|
272
|
+
/** The target's field looked up on the platform by name: a `data.elementum_field`. */
|
|
273
|
+
function relatedFieldLookup(target, name, opts) {
|
|
203
274
|
const label = foreignFieldDataLabel(target.kind, target.tfLabel ?? target.refName, name);
|
|
204
275
|
opts.orgRefs.foreignField("elementum_field", label, target.value, name);
|
|
205
276
|
return expr.dataAttr("elementum_field", label, ["id"]);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { dataRefLabel, groupCatalogKey, resourceRefLabel } from "../../engine/pull/context.js";
|
|
2
2
|
import { scopedLabelToBagKey } from "../../engine/tf/index.js";
|
|
3
3
|
import { ROLE_RESOURCE_TYPE } from "../org/role.js";
|
|
4
|
+
import { finishPulledMemberList } from "../access-policy/member-list.js";
|
|
5
|
+
import { serviceAccountAppRefName } from "../access-policy/from-tf.js";
|
|
4
6
|
const KNOWN = new Set(["id", "object_id", "name", "description", "auto_share", "user_ids", "group_ids", "service_account_ids", "permissions", "managed", "tags"]);
|
|
5
7
|
function strings(value, where, ctx) {
|
|
6
8
|
if (value === undefined)
|
|
@@ -30,6 +32,8 @@ function principal(value, type, where, ctx) {
|
|
|
30
32
|
}
|
|
31
33
|
if (typeof value === "string")
|
|
32
34
|
ctx.diagnostics.push(`${where}: raw platform ids are not part of the public EDK API; dropped`);
|
|
35
|
+
else
|
|
36
|
+
ctx.diagnostics.push(`${where}: unrecognized principal (${JSON.stringify(value)?.slice(0, 120)}); dropped`);
|
|
33
37
|
return undefined;
|
|
34
38
|
}
|
|
35
39
|
function principalList(value, type, where, ctx) {
|
|
@@ -42,7 +46,7 @@ function principalList(value, type, where, ctx) {
|
|
|
42
46
|
const out = value.flatMap((item) => (type === "elementum_user"
|
|
43
47
|
? principal(item, "elementum_user", where, ctx)
|
|
44
48
|
: principal(item, "elementum_group", where, ctx)) ?? []);
|
|
45
|
-
return out.length
|
|
49
|
+
return finishPulledMemberList(where, out, value.length - out.length, ctx.diagnostics);
|
|
46
50
|
}
|
|
47
51
|
function permissions(value, where, ctx) {
|
|
48
52
|
if (value === undefined)
|
|
@@ -101,23 +105,33 @@ export function rolesFromTf(blocks, owner, ctx) {
|
|
|
101
105
|
for (const value of serviceAccountsValue) {
|
|
102
106
|
const resourceLabel = resourceRefLabel(value, "elementum_service_account");
|
|
103
107
|
if (resourceLabel !== undefined) {
|
|
104
|
-
|
|
108
|
+
// A real pull passes only role blocks here, so read the account from
|
|
109
|
+
// the stream; `blocks` serves a caller that passed it in directly.
|
|
110
|
+
const account = ctx.resourceByAddress?.(`elementum_service_account.${resourceLabel}`)
|
|
111
|
+
?? blocks.find((candidate) => candidate.type === "elementum_service_account" && candidate.label === resourceLabel);
|
|
105
112
|
const explicitName = account?.attrs["name"];
|
|
106
113
|
const firstName = account?.attrs["first_name"];
|
|
107
114
|
const lastName = account?.attrs["last_name"];
|
|
108
115
|
const name = typeof explicitName === "string"
|
|
109
116
|
? explicitName
|
|
110
117
|
: typeof firstName === "string" && typeof lastName === "string" ? `${firstName} ${lastName}` : undefined;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
else
|
|
118
|
+
const appRefName = serviceAccountAppRefName(account?.attrs["app_id"], owner, ctx);
|
|
119
|
+
if (name === undefined)
|
|
114
120
|
ctx.diagnostics.push(`${where}.service_account_ids: ${resourceLabel} has no recoverable display name; dropped`);
|
|
121
|
+
else if (appRefName === undefined)
|
|
122
|
+
ctx.diagnostics.push(`${where}.service_account_ids: ${resourceLabel} has no resolvable app_id owner; dropped`);
|
|
123
|
+
else
|
|
124
|
+
serviceAccounts.push({ __kind: "serviceAccount", appRefName, name });
|
|
115
125
|
continue;
|
|
116
126
|
}
|
|
117
127
|
const dataLabel = dataRefLabel(value, "elementum_service_account");
|
|
118
128
|
const name = dataLabel === undefined ? undefined : ctx.dataName("elementum_service_account", dataLabel);
|
|
119
129
|
if (name !== undefined) {
|
|
120
|
-
|
|
130
|
+
const appRefName = serviceAccountAppRefName(ctx.dataAttrs?.("elementum_service_account", dataLabel)?.["app_id"], owner, ctx);
|
|
131
|
+
if (appRefName === undefined)
|
|
132
|
+
ctx.diagnostics.push(`${where}.service_account_ids: data.elementum_service_account.${dataLabel} has no resolvable app_id owner; dropped`);
|
|
133
|
+
else
|
|
134
|
+
serviceAccounts.push({ __kind: "serviceAccount", appRefName, name });
|
|
121
135
|
continue;
|
|
122
136
|
}
|
|
123
137
|
if (typeof value === "string")
|
|
@@ -127,6 +141,9 @@ export function rolesFromTf(blocks, owner, ctx) {
|
|
|
127
141
|
}
|
|
128
142
|
}
|
|
129
143
|
}
|
|
144
|
+
if (serviceAccounts !== undefined && Array.isArray(serviceAccountsValue)) {
|
|
145
|
+
serviceAccounts = finishPulledMemberList(`${where}.service_account_ids`, serviceAccounts, serviceAccountsValue.length - serviceAccounts.length, ctx.diagnostics);
|
|
146
|
+
}
|
|
130
147
|
const users = principalList(block.attrs["user_ids"], "elementum_user", `${where}.user_ids`, ctx);
|
|
131
148
|
const groups = principalList(block.attrs["group_ids"], "elementum_group", `${where}.group_ids`, ctx);
|
|
132
149
|
const rolePermissions = permissions(block.attrs["permissions"], `${where}.permissions`, ctx);
|
|
@@ -137,7 +154,7 @@ export function rolesFromTf(blocks, owner, ctx) {
|
|
|
137
154
|
...(autoShare !== undefined && { autoShare }),
|
|
138
155
|
...(users !== undefined && { users }),
|
|
139
156
|
...(groups !== undefined && { groups }),
|
|
140
|
-
...(serviceAccounts !== undefined &&
|
|
157
|
+
...(serviceAccounts !== undefined && { serviceAccounts }),
|
|
141
158
|
...(rolePermissions !== undefined && { permissions: rolePermissions }),
|
|
142
159
|
}];
|
|
143
160
|
});
|
|
@@ -2,10 +2,16 @@ import { expr, sanitizeName, scopedResourceLabel, tsLabelToTfLabel } from "../..
|
|
|
2
2
|
import { ROLE_RESOURCE_TYPE } from "../org/role.js";
|
|
3
3
|
import { SERVICE_ACCOUNT_RESOURCE_TYPE } from "../service-account/module.js";
|
|
4
4
|
import { serviceAccountRefToTf } from "../service-account/to-tf.js";
|
|
5
|
+
import { describeDroppedEntry, finishMemberList } from "../access-policy/member-list.js";
|
|
5
6
|
function principals(values, type, where, orgRefs, diagnostics) {
|
|
6
|
-
if (values === undefined
|
|
7
|
+
if (values === undefined)
|
|
7
8
|
return undefined;
|
|
9
|
+
// `users: []` / `groups: []` removes every member, so it must reach the
|
|
10
|
+
// provider as `[]`: an omitted list changes nothing (#2158).
|
|
11
|
+
if (values.length === 0)
|
|
12
|
+
return [];
|
|
8
13
|
const out = [];
|
|
14
|
+
const dropped = [];
|
|
9
15
|
for (const value of values) {
|
|
10
16
|
const user = value;
|
|
11
17
|
if (type === "elementum_user" && user?.__kind === "user" && user.email) {
|
|
@@ -18,14 +24,17 @@ function principals(values, type, where, orgRefs, diagnostics) {
|
|
|
18
24
|
if (type === "elementum_group" && token?.__kind === "group") {
|
|
19
25
|
const resolved = orgRefs.byTsLabel("groups", token.refName ?? "");
|
|
20
26
|
if (resolved === undefined)
|
|
21
|
-
|
|
27
|
+
dropped.push(`${where}: group token ${JSON.stringify(token.refName ?? "")} is not in org.ts; dropped`);
|
|
22
28
|
else
|
|
23
29
|
out.push(expr.dataAttr(type, resolved.tfLabel, ["id"]));
|
|
24
30
|
continue;
|
|
25
31
|
}
|
|
26
|
-
|
|
32
|
+
dropped.push(`${where}: unrecognized typed principal (${describeDroppedEntry(value)}); dropped`);
|
|
27
33
|
}
|
|
28
|
-
|
|
34
|
+
// Every entry dropped: the list is left out so apply changes nothing,
|
|
35
|
+
// rather than emit [] and remove every member. Some dropped: the build
|
|
36
|
+
// fails (edk#2198).
|
|
37
|
+
return finishMemberList(where, out, dropped, diagnostics);
|
|
29
38
|
}
|
|
30
39
|
export function rolesToTf(roles, opts) {
|
|
31
40
|
return Object.entries(roles ?? {}).map(([key, role]) => {
|
|
@@ -41,16 +50,18 @@ export function rolesToTf(roles, opts) {
|
|
|
41
50
|
if (groups !== undefined)
|
|
42
51
|
attrs["group_ids"] = groups;
|
|
43
52
|
if (role.serviceAccounts !== undefined) {
|
|
44
|
-
|
|
53
|
+
const where = `roles.${key}.serviceAccounts`;
|
|
54
|
+
const dropped = [];
|
|
55
|
+
const built = role.serviceAccounts.flatMap((account) => {
|
|
45
56
|
if (opts.scope !== "app" || account.appRefName !== opts.ownerRefName) {
|
|
46
57
|
// Another app's account (or any account on an element role, which
|
|
47
58
|
// owns none): resolve it under its OWNING app (#1592).
|
|
48
59
|
const owning = opts.resolveServiceAccountApp?.(account.appRefName);
|
|
49
60
|
if (owning === undefined) {
|
|
50
|
-
|
|
61
|
+
dropped.push(`${where}: ${JSON.stringify(account.name)} belongs to app ${JSON.stringify(account.appRefName)}, which is not in this workspace; dropped`);
|
|
51
62
|
return [];
|
|
52
63
|
}
|
|
53
|
-
const value = serviceAccountRefToTf({ __kind: "serviceAccount", appRefName: account.appRefName, name: account.name }, { appRefName: account.appRefName, ...owning, orgRefs: opts.orgRefs },
|
|
64
|
+
const value = serviceAccountRefToTf({ __kind: "serviceAccount", appRefName: account.appRefName, name: account.name }, { appRefName: account.appRefName, ...owning, orgRefs: opts.orgRefs }, where, dropped);
|
|
54
65
|
return value === undefined ? [] : [value];
|
|
55
66
|
}
|
|
56
67
|
const local = Object.entries(opts.serviceAccounts ?? {}).find(([, candidate]) => `${candidate.firstName} ${candidate.lastName}`.trim() === account.name);
|
|
@@ -60,6 +71,13 @@ export function rolesToTf(roles, opts) {
|
|
|
60
71
|
opts.orgRefs.rawLookup(SERVICE_ACCOUNT_RESOURCE_TYPE, label, account.name, { app_id: opts.objectId });
|
|
61
72
|
return [expr.dataAttr(SERVICE_ACCOUNT_RESOURCE_TYPE, label, ["id"])];
|
|
62
73
|
});
|
|
74
|
+
// `serviceAccounts: []` removes every member and must reach the
|
|
75
|
+
// provider as `[]` (#2158). Otherwise a list whose every entry was
|
|
76
|
+
// dropped is left out (it used to build as [] and remove every member),
|
|
77
|
+
// and a partly dropped list fails the build (edk#2198).
|
|
78
|
+
const serviceAccountIds = role.serviceAccounts.length === 0 ? [] : finishMemberList(where, built, dropped, opts.diagnostics);
|
|
79
|
+
if (serviceAccountIds !== undefined)
|
|
80
|
+
attrs["service_account_ids"] = serviceAccountIds;
|
|
63
81
|
}
|
|
64
82
|
if (role.permissions !== undefined)
|
|
65
83
|
attrs["permissions"] = [...role.permissions].sort((a, b) => a.group.localeCompare(b.group)).map((permission) => ({
|
|
@@ -4,6 +4,7 @@ import { scopedLabelToBagKey } from "../../engine/tf/index.js";
|
|
|
4
4
|
import { serviceAccountRoleRef, serviceAccountStatus, } from "./build.js";
|
|
5
5
|
import { SERVICE_ACCOUNT_ACCESS_POLICY_RESOURCE_TYPE, SERVICE_ACCOUNT_RESOURCE_TYPE } from "./module.js";
|
|
6
6
|
import { serviceAccountRoleIdMismatches } from "./role-fidelity.js";
|
|
7
|
+
import { finishPulledMemberList } from "../access-policy/member-list.js";
|
|
7
8
|
const ACCOUNT_ATTRS = new Set(["id", "app_id", "first_name", "last_name", "purpose", "name", "status", "role_ids"]);
|
|
8
9
|
const POLICY_ATTRS = new Set(["id", "app_id", "service_account_id", "user_ids", "group_ids"]);
|
|
9
10
|
function principal(value, type, where, ctx) {
|
|
@@ -39,7 +40,7 @@ function principalList(value, type, where, ctx) {
|
|
|
39
40
|
const out = value.flatMap((item) => (type === "elementum_user"
|
|
40
41
|
? principal(item, "elementum_user", where, ctx)
|
|
41
42
|
: principal(item, "elementum_group", where, ctx)) ?? []);
|
|
42
|
-
return out.length
|
|
43
|
+
return finishPulledMemberList(where, out, value.length - out.length, ctx.diagnostics);
|
|
43
44
|
}
|
|
44
45
|
function keptPlatformId(id, where, ctx) {
|
|
45
46
|
ctx.diagnostics.push(`${where}: role reference has no recoverable name; kept as unsafePlatformId`);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { NO_CANVAS, NO_CATALOG, NO_LIFECYCLE } from "../../graph/types.js";
|
|
2
|
+
import { GROUP_RESOURCE_TYPE } from "../org/group.js";
|
|
2
3
|
export const SERVICE_ACCOUNT_RESOURCE_TYPE = "elementum_service_account";
|
|
3
4
|
export const SERVICE_ACCOUNT_ACCESS_POLICY_RESOURCE_TYPE = "elementum_service_account_access_policy";
|
|
4
5
|
export const serviceAccountModule = {
|
|
@@ -18,4 +19,18 @@ export const serviceAccountModule = {
|
|
|
18
19
|
lifecycle: NO_LIFECYCLE,
|
|
19
20
|
canvas: NO_CANVAS,
|
|
20
21
|
catalog: NO_CATALOG,
|
|
22
|
+
// The platform's own policy names the account's creator, a user, so it is
|
|
23
|
+
// always dropped; a group-only policy is kept when every group is mapped.
|
|
24
|
+
portable: {
|
|
25
|
+
principals: [
|
|
26
|
+
{
|
|
27
|
+
resourceType: SERVICE_ACCOUNT_ACCESS_POLICY_RESOURCE_TYPE,
|
|
28
|
+
groupAttribute: "group_ids",
|
|
29
|
+
groupDataType: GROUP_RESOURCE_TYPE,
|
|
30
|
+
userAttributes: ["user_ids"],
|
|
31
|
+
whenDropped: "block",
|
|
32
|
+
noun: "service account access policy",
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
},
|
|
21
36
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isUnsafePlatformId } from "../../core/platform-id.js";
|
|
2
2
|
import { appScopedResourceLabel, expr, sanitizeName, scopedResourceLabel, tsLabelToTfLabel } from "../../engine/tf/index.js";
|
|
3
3
|
import { SERVICE_ACCOUNT_ACCESS_POLICY_RESOURCE_TYPE, SERVICE_ACCOUNT_RESOURCE_TYPE } from "./module.js";
|
|
4
|
+
import { describeDroppedEntry, finishMemberList } from "../access-policy/member-list.js";
|
|
4
5
|
/**
|
|
5
6
|
* Resolve a `serviceAccountRef({ app, name })` token to its terraform value:
|
|
6
7
|
* `elementum_service_account.<label>.id` when the name matches an account
|
|
@@ -40,9 +41,14 @@ export function serviceAccountRefToTf(token, opts, where, diagnostics) {
|
|
|
40
41
|
return expr.dataAttr(SERVICE_ACCOUNT_RESOURCE_TYPE, label, ["id"]);
|
|
41
42
|
}
|
|
42
43
|
function principalValues(values, type, where, orgRefs, diagnostics) {
|
|
43
|
-
if (values === undefined
|
|
44
|
+
if (values === undefined)
|
|
44
45
|
return undefined;
|
|
46
|
+
// `users: []` / `groups: []` removes every member, so it must reach the
|
|
47
|
+
// provider as `[]`: an omitted list changes nothing (#2160).
|
|
48
|
+
if (values.length === 0)
|
|
49
|
+
return [];
|
|
45
50
|
const out = [];
|
|
51
|
+
const dropped = [];
|
|
46
52
|
for (const value of values) {
|
|
47
53
|
if (type === "elementum_user" && value.__kind === "user") {
|
|
48
54
|
const email = value.email;
|
|
@@ -55,14 +61,16 @@ function principalValues(values, type, where, orgRefs, diagnostics) {
|
|
|
55
61
|
const refName = value.refName ?? "";
|
|
56
62
|
const resolved = orgRefs.byTsLabel("groups", refName);
|
|
57
63
|
if (resolved === undefined)
|
|
58
|
-
|
|
64
|
+
dropped.push(`${where}: group ${JSON.stringify(refName)} is not in org.ts; dropped`);
|
|
59
65
|
else
|
|
60
66
|
out.push(expr.dataAttr(type, resolved.tfLabel, ["id"]));
|
|
61
67
|
continue;
|
|
62
68
|
}
|
|
63
|
-
|
|
69
|
+
dropped.push(`${where}: expected a typed ${type === "elementum_user" ? "userRef" : "group ref"} (${describeDroppedEntry(value)}); dropped`);
|
|
64
70
|
}
|
|
65
|
-
|
|
71
|
+
// Every entry dropped: leave the list out so apply changes nothing. Some
|
|
72
|
+
// dropped: fail the build rather than remove those members (edk#2198).
|
|
73
|
+
return finishMemberList(where, out, dropped, diagnostics);
|
|
66
74
|
}
|
|
67
75
|
function roleValue(value, roles, ownerTfLabel, appId, orgRefs) {
|
|
68
76
|
if (isUnsafePlatformId(value))
|
|
@@ -123,7 +123,7 @@ export interface FilterFromTfCodec<Field = string, ReferenceValue = never> {
|
|
|
123
123
|
* that understand that envelope may override the fallback here.
|
|
124
124
|
*/
|
|
125
125
|
readonly referenceType?: (value: TfValue, fallback: ValueType) => ValueType;
|
|
126
|
-
readonly literal?: (value: TfValue, valueType: string) => TfValue;
|
|
126
|
+
readonly literal?: (value: TfValue, valueType: string, field?: Field) => TfValue;
|
|
127
127
|
/** Decode a RECORD_FIELD value's source-record field reference; without it only raw platform ids decode. */
|
|
128
128
|
readonly recordField?: (value: TfValue) => Field;
|
|
129
129
|
/** Whether a RECORD_FIELD `object` reference names the owning app or element; without it only raw platform ids decode. */
|
|
@@ -516,6 +516,11 @@ export function filterFromTf(value, codec, fieldScope = "app") {
|
|
|
516
516
|
})();
|
|
517
517
|
if (left === undefined)
|
|
518
518
|
throw new EntityTfError(`${type} filter has no left side`);
|
|
519
|
+
const comparedField = "field" in left
|
|
520
|
+
? left.field
|
|
521
|
+
: left.leftValue.type === "FIELD"
|
|
522
|
+
? left.leftValue.value
|
|
523
|
+
: undefined;
|
|
519
524
|
if ("not" in filter && filter.not === true && !NEGATABLE_FILTER_TYPES.has(type)) {
|
|
520
525
|
throw new EntityTfError(`${type} filter does not support not`);
|
|
521
526
|
}
|
|
@@ -535,13 +540,13 @@ export function filterFromTf(value, codec, fieldScope = "app") {
|
|
|
535
540
|
return { type: "CONSECUTIVE_RANGE", ...left, ...options, unit: filter.unit.toUpperCase(), count: filter.count, offset: filter.offset, ...(filter.iso_week !== undefined && { isoWeek: filter.iso_week }) };
|
|
536
541
|
}
|
|
537
542
|
if (type === "in") {
|
|
538
|
-
return { type: "IN", ...left, ...options, values: filter.values.map((item) => filterValueFromTf(item, codec, fieldScope)), ...not };
|
|
543
|
+
return { type: "IN", ...left, ...options, values: filter.values.map((item) => filterValueFromTf(item, codec, fieldScope, comparedField)), ...not };
|
|
539
544
|
}
|
|
540
545
|
if (type === "contains" || type === "overlaps") {
|
|
541
|
-
return { type: type.toUpperCase(), ...left, ...options, values: filter.values.map((item) => filterValueFromTf(item, codec, fieldScope)), ...not };
|
|
546
|
+
return { type: type.toUpperCase(), ...left, ...options, values: filter.values.map((item) => filterValueFromTf(item, codec, fieldScope, comparedField)), ...not };
|
|
542
547
|
}
|
|
543
548
|
if (type === "between") {
|
|
544
|
-
return { type: "BETWEEN", ...left, ...options, min: filterValueFromTf(filter.min, codec, fieldScope), max: filterValueFromTf(filter.max, codec, fieldScope), ...not };
|
|
549
|
+
return { type: "BETWEEN", ...left, ...options, min: filterValueFromTf(filter.min, codec, fieldScope, comparedField), max: filterValueFromTf(filter.max, codec, fieldScope, comparedField), ...not };
|
|
545
550
|
}
|
|
546
551
|
const single = filter;
|
|
547
552
|
const filterType = {
|
|
@@ -554,12 +559,12 @@ export function filterFromTf(value, codec, fieldScope = "app") {
|
|
|
554
559
|
};
|
|
555
560
|
const canonical = filterType[type];
|
|
556
561
|
return canonical === "LIKE"
|
|
557
|
-
? { type: canonical, ...left, ...options, value: filterValueFromTf(single.value, codec, fieldScope), ...not, ...(single.case_insensitive !== undefined && { caseInsensitive: single.case_insensitive }), ...(single.mode !== undefined && { mode: single.mode.toUpperCase() }) }
|
|
558
|
-
: { type: canonical, ...left, ...options, value: filterValueFromTf(single.value, codec, fieldScope), ...not };
|
|
562
|
+
? { type: canonical, ...left, ...options, value: filterValueFromTf(single.value, codec, fieldScope, comparedField), ...not, ...(single.case_insensitive !== undefined && { caseInsensitive: single.case_insensitive }), ...(single.mode !== undefined && { mode: single.mode.toUpperCase() }) }
|
|
563
|
+
: { type: canonical, ...left, ...options, value: filterValueFromTf(single.value, codec, fieldScope, comparedField), ...not };
|
|
559
564
|
}
|
|
560
|
-
function filterValueFromTf(value, codec, fieldScope) {
|
|
565
|
+
function filterValueFromTf(value, codec, fieldScope, field) {
|
|
561
566
|
const type = value.type.toLowerCase();
|
|
562
|
-
const literal = codec.literal?.(value.value, type) ?? value.value;
|
|
567
|
+
const literal = codec.literal?.(value.value, type, field) ?? value.value;
|
|
563
568
|
if (["text", "uuid", "number", "boolean", "date", "datetime"].includes(type) && typeof literal === "object" && literal !== null) {
|
|
564
569
|
throw new EntityTfError(`${type} filter literal contains an unresolved expression or object`);
|
|
565
570
|
}
|
|
@@ -21,11 +21,14 @@ export interface PrintSkillV2Options {
|
|
|
21
21
|
/**
|
|
22
22
|
* Set for a cross-org clone: a foreign-app tool target was resolved
|
|
23
23
|
* against the SOURCE org, so it's flagged as a TODO for manual review
|
|
24
|
-
* instead of silently carried over.
|
|
25
|
-
*
|
|
24
|
+
* instead of silently carried over. An access-policy group prints a
|
|
25
|
+
* build-blocking placeholder unless {@link destinationGroups} names it
|
|
26
|
+
* (kept through `--map`, edk#1894) — same treatment as agent tools
|
|
26
27
|
* (`src/entities/agent/deserializer/print-agent-v2.ts`).
|
|
27
28
|
*/
|
|
28
29
|
readonly crossOrg?: boolean;
|
|
30
|
+
/** Cross-org only: the destination's group name → `org.groups` key; a policy group named there prints as that key (edk#1894). */
|
|
31
|
+
readonly destinationGroups?: ReadonlyMap<string, string>;
|
|
29
32
|
/**
|
|
30
33
|
* Name → refName for every app already on disk in this workspace (board
|
|
31
34
|
* issue #40). A foreign-app tool target whose name is a key here prints
|
|
@@ -127,7 +127,12 @@ export function printSkillV2(skill, opts) {
|
|
|
127
127
|
if (crossOrg && skill.accessPolicy.groups.length > 0) {
|
|
128
128
|
lines.push(" groups: [");
|
|
129
129
|
for (const group of skill.accessPolicy.groups) {
|
|
130
|
-
|
|
130
|
+
// A group the destination org has, by name, was kept through --map (edk#1894).
|
|
131
|
+
const destinationKey = opts.destinationGroups?.get(group.name);
|
|
132
|
+
if (destinationKey !== undefined)
|
|
133
|
+
lines.push(` org.groups${safeMember(destinationKey)},`);
|
|
134
|
+
else
|
|
135
|
+
lines.push(` TODO_DESTINATION_GROUP, // TODO: cross-org clone — verify the destination group's membership, then replace with org.groups.<key> for source group ${quote(group.name)}.`);
|
|
131
136
|
}
|
|
132
137
|
lines.push(" ],");
|
|
133
138
|
}
|
|
@@ -206,6 +211,8 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
|
|
|
206
211
|
: undefined;
|
|
207
212
|
lines.push(` name: ${quote(tool.name)},`);
|
|
208
213
|
lines.push(` description: ${quote(tool.description)},`);
|
|
214
|
+
if (tool.labelSuffix !== undefined)
|
|
215
|
+
lines.push(` labelSuffix: ${tool.labelSuffix},`);
|
|
209
216
|
if (tool.status !== undefined)
|
|
210
217
|
lines.push(` status: ${quote(tool.status)},`);
|
|
211
218
|
if (tool.startMessage !== undefined)
|
|
@@ -7,8 +7,9 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { EntityTfError } from "../../engine/entity.js";
|
|
9
9
|
import { optionalString, ownerMismatchBlocker, reportAuthoringBlocker, resourceRefLabel } from "../../engine/pull/context.js";
|
|
10
|
-
import { isTfExpr, scopedLabelToBagKey } from "../../engine/tf/index.js";
|
|
10
|
+
import { appScopedResourceLabel, exportLabelSuffix, isTfExpr, scopedLabelToBagKey, tsLabelToTfLabel } from "../../engine/tf/index.js";
|
|
11
11
|
import { skillToolFromTf } from "../skill-tool/from-tf.js";
|
|
12
|
+
import { skillToolBareLabel } from "../skill-tool/to-tf.js";
|
|
12
13
|
import { APP_RESOURCE_TYPE } from "../app/module.js";
|
|
13
14
|
import { analyzeSkillInputCoverage, decomposeSkillInstructionsLossless, skillCoverageGapDiagnostics, skillCoverageReportLines, } from "./input-coverage.js";
|
|
14
15
|
import { SKILL_RESOURCE_TYPE } from "./module.js";
|
|
@@ -151,11 +152,17 @@ export function skillFromTf(skillBlock, toolBlocks, appLabel, ctx) {
|
|
|
151
152
|
...(negativeKeywords !== undefined && { negativeKeywords }),
|
|
152
153
|
};
|
|
153
154
|
const owner = { appType: APP_RESOURCE_TYPE, appLabel, ownerTfLabel: appLabel, skillType: SKILL_RESOURCE_TYPE, skillLabel: label };
|
|
155
|
+
// Pin the `_N` ei gave each suffixed tool, as for agent tools (edk#1987).
|
|
156
|
+
const skillBare = tsLabelToTfLabel(scopedLabelToBagKey(appLabel, label));
|
|
154
157
|
const tools = [];
|
|
155
158
|
for (const block of toolBlocks) {
|
|
156
159
|
const tool = skillToolFromTf(block, owner, ctx);
|
|
157
|
-
if (tool
|
|
158
|
-
|
|
160
|
+
if (tool === undefined)
|
|
161
|
+
continue;
|
|
162
|
+
const labelSuffix = block.label === undefined
|
|
163
|
+
? undefined
|
|
164
|
+
: exportLabelSuffix(appScopedResourceLabel(appLabel, skillToolBareLabel(skillBare, tool.name, "")), block.label);
|
|
165
|
+
tools.push(labelSuffix === undefined ? tool : { ...tool, labelSuffix });
|
|
159
166
|
}
|
|
160
167
|
const rawInstructions = optionalString(attrs, "instructions", where, ctx) ?? "";
|
|
161
168
|
const coverageTools = tools.map((tool) => ({
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** The skill entity's registry entry + resource-type constant (see src/graph/). */
|
|
2
2
|
import { rootParentFactoryEntry } from "../../catalog/render-helpers.js";
|
|
3
3
|
import { isTfExpr, scopedLabelToBagKey } from "../../engine/tf/index.js";
|
|
4
|
+
import { GROUP_RESOURCE_TYPE } from "../org/group.js";
|
|
4
5
|
import { printSkillV2 } from "./deserializer/print-skill-v2.js";
|
|
5
6
|
import { skillFromTf } from "./from-tf.js";
|
|
6
7
|
import { skillToTf } from "./to-tf.js";
|
|
@@ -113,6 +114,7 @@ export const skillModule = {
|
|
|
113
114
|
appRefName: opts.appRefName,
|
|
114
115
|
orgImportPath: opts.orgImportPath,
|
|
115
116
|
...(opts.crossOrg !== undefined && { crossOrg: opts.crossOrg }),
|
|
117
|
+
...(opts.destinationGroups !== undefined && { destinationGroups: opts.destinationGroups }),
|
|
116
118
|
...(opts.foreignAppRefNames !== undefined && { foreignAppRefNames: opts.foreignAppRefNames }),
|
|
117
119
|
...(opts.foreignElementRefNames !== undefined && { foreignElementRefNames: opts.foreignElementRefNames }),
|
|
118
120
|
...(opts.foreignTaskRefNames !== undefined && { foreignTaskRefNames: opts.foreignTaskRefNames }),
|
|
@@ -157,4 +159,18 @@ export const skillModule = {
|
|
|
157
159
|
stubRef: skillStubRef,
|
|
158
160
|
refFromAuthoring: skillRefFromAuthoring,
|
|
159
161
|
},
|
|
162
|
+
// A skill's access policy is its user_ids/group_ids; dropping it keeps the skill.
|
|
163
|
+
portable: {
|
|
164
|
+
principals: [
|
|
165
|
+
{
|
|
166
|
+
resourceType: SKILL_RESOURCE_TYPE,
|
|
167
|
+
groupAttribute: "group_ids",
|
|
168
|
+
groupDataType: GROUP_RESOURCE_TYPE,
|
|
169
|
+
userAttributes: ["user_ids"],
|
|
170
|
+
whenDropped: "attributes",
|
|
171
|
+
noun: "skill access policy",
|
|
172
|
+
whenDroppedNote: "the skill is now open to everyone who can see the app's agents",
|
|
173
|
+
},
|
|
174
|
+
],
|
|
175
|
+
},
|
|
160
176
|
};
|
|
@@ -41,7 +41,14 @@ export interface SkillToTfResult {
|
|
|
41
41
|
/** The skill's terraform address. */
|
|
42
42
|
readonly address: string;
|
|
43
43
|
}
|
|
44
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* `_N` suffixes for each skill's tools whose labels collide, keyed
|
|
46
|
+
* `<refName>#<index>`, one counter per skill across tool kinds, as ei's
|
|
47
|
+
* export (`generateAppSkillImportBlocks`) counts known tool kinds. A tool with
|
|
48
|
+
* `labelSuffix` keeps that `_N`; the others take the lowest free count in tool
|
|
49
|
+
* order (`collisionLabelSuffixes`). Pull pins every tool ei suffixed
|
|
50
|
+
* (skillFromTf), so a pulled skill rebuilds its exported labels.
|
|
51
|
+
*/
|
|
45
52
|
export declare function computeToolLabelSuffixes(siblingSkills: readonly DeployableEntity[]): ReadonlyMap<string, string>;
|
|
46
53
|
/** `elementum_agentic_skill` + one tool resource per implemented tool, in the platform's dialect. */
|
|
47
54
|
export declare function skillToTf(entity: DeployableEntity, ctx: SkillToTfContext): SkillToTfResult;
|