@elementumai/edk 0.13.3 → 0.14.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/dist-sdk/src/catalog/factories.d.ts +4 -2
- package/dist-sdk/src/catalog/factories.js +3 -1
- package/dist-sdk/src/catalog/from-authoring.d.ts +8 -3
- package/dist-sdk/src/catalog/from-authoring.js +21 -8
- package/dist-sdk/src/engine/build/context.d.ts +17 -0
- package/dist-sdk/src/engine/coverage-gaps.d.ts +13 -0
- package/dist-sdk/src/engine/coverage-gaps.js +21 -0
- package/dist-sdk/src/engine/pull/context.d.ts +57 -1
- package/dist-sdk/src/engine/pull/context.js +9 -1
- package/dist-sdk/src/engine/pull/pulled-roots.d.ts +14 -1
- package/dist-sdk/src/engine/pull/pulled-roots.js +23 -3
- package/dist-sdk/src/engine/pull/ref-only.d.ts +6 -1
- package/dist-sdk/src/engine/pull/ref-only.js +4 -1
- package/dist-sdk/src/engine/pull/stream-root.d.ts +17 -1
- package/dist-sdk/src/engine/pull/stream-root.js +57 -4
- package/dist-sdk/src/engine/tf/index.d.ts +1 -0
- package/dist-sdk/src/engine/tf/index.js +1 -0
- package/dist-sdk/src/engine/tf/jsonencode.d.ts +19 -0
- package/dist-sdk/src/engine/tf/jsonencode.js +49 -0
- package/dist-sdk/src/engine/validation.d.ts +36 -1
- package/dist-sdk/src/engine/validation.js +56 -2
- package/dist-sdk/src/engine/workspace/loader.d.ts +6 -0
- package/dist-sdk/src/engine/workspace/loader.js +87 -2
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +7 -0
- package/dist-sdk/src/entities/access-policy/from-tf.js +58 -17
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +3 -1
- package/dist-sdk/src/entities/access-policy/to-tf.js +1 -1
- package/dist-sdk/src/entities/agent/build.d.ts +15 -0
- package/dist-sdk/src/entities/agent/build.js +139 -16
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +3 -3
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +39 -25
- package/dist-sdk/src/entities/agent/module.js +95 -3
- package/dist-sdk/src/entities/agent/to-tf.js +6 -4
- package/dist-sdk/src/entities/agent-evaluation/from-tf.d.ts +7 -0
- package/dist-sdk/src/entities/agent-evaluation/from-tf.js +14 -5
- package/dist-sdk/src/entities/agent-evaluation/module.js +4 -2
- package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +11 -2
- package/dist-sdk/src/entities/agent-tool/from-tf.js +38 -40
- package/dist-sdk/src/entities/agent-tool/to-tf.js +12 -5
- package/dist-sdk/src/entities/app/build.d.ts +1 -1
- package/dist-sdk/src/entities/app/index.d.ts +1 -1
- package/dist-sdk/src/entities/automation/approval-trigger-refs.d.ts +20 -0
- package/dist-sdk/src/entities/automation/approval-trigger-refs.js +83 -0
- package/dist-sdk/src/entities/automation/build.d.ts +75 -42
- package/dist-sdk/src/entities/automation/build.js +18 -8
- package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +14 -2
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +9 -0
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +64 -12
- package/dist-sdk/src/entities/automation/from-tf.d.ts +53 -0
- package/dist-sdk/src/entities/automation/from-tf.js +579 -106
- 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/lookup-owner.d.ts +23 -0
- package/dist-sdk/src/entities/automation/lookup-owner.js +27 -0
- package/dist-sdk/src/entities/automation/module.js +265 -26
- package/dist-sdk/src/entities/automation/operators.d.ts +6 -2
- package/dist-sdk/src/entities/automation/operators.js +0 -2
- package/dist-sdk/src/entities/automation/task-output-labels.d.ts +8 -0
- package/dist-sdk/src/entities/automation/task-output-labels.js +11 -0
- package/dist-sdk/src/entities/automation/tasks.d.ts +37 -2
- package/dist-sdk/src/entities/automation/tasks.js +38 -1
- package/dist-sdk/src/entities/automation/to-tf.d.ts +8 -0
- package/dist-sdk/src/entities/automation/to-tf.js +576 -52
- package/dist-sdk/src/entities/automation/triggers.d.ts +47 -1
- package/dist-sdk/src/entities/automation/unsafe-script-output.d.ts +10 -5
- package/dist-sdk/src/entities/automation/unsafe-script-output.js +10 -5
- package/dist-sdk/src/entities/chart/to-tf.js +18 -5
- package/dist-sdk/src/entities/dashboard/from-tf.js +45 -11
- package/dist-sdk/src/entities/dashboard-widget-order/order.d.ts +5 -3
- package/dist-sdk/src/entities/dashboard-widget-order/order.js +6 -4
- package/dist-sdk/src/entities/datamine/from-tf.js +10 -3
- package/dist-sdk/src/entities/dynamic-layout/build.d.ts +38 -11
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +35 -7
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +101 -9
- package/dist-sdk/src/entities/element/build.d.ts +4 -1
- package/dist-sdk/src/entities/element/build.js +3 -4
- package/dist-sdk/src/entities/element/index.d.ts +1 -1
- package/dist-sdk/src/entities/field/from-tf.js +8 -1
- package/dist-sdk/src/entities/field/to-tf.d.ts +29 -2
- package/dist-sdk/src/entities/field/to-tf.js +106 -7
- package/dist-sdk/src/entities/phone-service/from-tf.d.ts +7 -0
- package/dist-sdk/src/entities/phone-service/from-tf.js +15 -7
- package/dist-sdk/src/entities/phone-service/module.js +4 -2
- package/dist-sdk/src/entities/portal/to-tf.d.ts +1 -1
- package/dist-sdk/src/entities/portal/to-tf.js +61 -2
- package/dist-sdk/src/entities/record-create-form/from-tf.js +3 -1
- package/dist-sdk/src/entities/relationship/from-tf.js +34 -4
- package/dist-sdk/src/entities/relationship/to-tf.js +24 -6
- package/dist-sdk/src/entities/role/from-tf.js +3 -1
- package/dist-sdk/src/entities/search-table/from-tf.d.ts +3 -1
- package/dist-sdk/src/entities/search-table/from-tf.js +6 -3
- package/dist-sdk/src/entities/search-table/module.js +18 -2
- package/dist-sdk/src/entities/search-table/to-tf.js +10 -16
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +6 -1
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +6 -0
- package/dist-sdk/src/entities/shared/filters/index.d.ts +21 -4
- package/dist-sdk/src/entities/shared/filters/index.js +27 -3
- package/dist-sdk/src/entities/shared/filters/print.js +23 -7
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +24 -0
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +98 -3
- package/dist-sdk/src/entities/shared/filters/types.d.ts +8 -1
- package/dist-sdk/src/entities/shared/run-automation-requirement.d.ts +15 -0
- package/dist-sdk/src/entities/shared/run-automation-requirement.js +28 -0
- package/dist-sdk/src/entities/shared/search-table-address.d.ts +17 -0
- package/dist-sdk/src/entities/shared/search-table-address.js +24 -0
- package/dist-sdk/src/entities/shared/skip-release.d.ts +49 -0
- package/dist-sdk/src/entities/shared/skip-release.js +74 -0
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +3 -3
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +11 -5
- package/dist-sdk/src/entities/skill/module.js +3 -25
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +4 -2
- package/dist-sdk/src/entities/skill-tool/from-tf.js +28 -27
- package/dist-sdk/src/entities/skill-tool/to-tf.js +12 -5
- package/dist-sdk/src/entities/skill-tool/types.d.ts +1 -0
- package/dist-sdk/src/entities/skill-tool/types.js +2 -1
- package/dist-sdk/src/entities/table/catalog.d.ts +16 -0
- package/dist-sdk/src/entities/table/catalog.js +44 -2
- package/dist-sdk/src/entities/table/from-tf.js +30 -4
- package/dist-sdk/src/entities/table/keys.d.ts +27 -0
- package/dist-sdk/src/entities/table/keys.js +46 -0
- package/dist-sdk/src/entities/table/to-tf.js +2 -2
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +12 -1
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +9 -4
- package/dist-sdk/src/entities/view/agent-view-layout-to-tf.js +215 -10
- package/dist-sdk/src/entities/view/agent-view-layout.d.ts +10 -4
- package/dist-sdk/src/entities/view/custom-view-runtime-rules.d.ts +43 -0
- package/dist-sdk/src/entities/view/custom-view-runtime-rules.js +285 -0
- package/dist-sdk/src/entities/view/custom-view-validate.d.ts +3 -1
- package/dist-sdk/src/entities/view/custom-view-validate.js +24 -5
- package/dist-sdk/src/entities/view/from-tf.js +14 -1
- package/dist-sdk/src/entities/widget/from-tf.js +14 -7
- package/dist-sdk/src/entities/widget/to-tf.js +9 -6
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +4 -2
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
- package/dist-sdk/src/graph/index.d.ts +14 -1
- package/dist-sdk/src/graph/index.js +2 -0
- package/dist-sdk/src/graph/resource-types.d.ts +2 -0
- package/dist-sdk/src/graph/resource-types.js +3 -0
- package/dist-sdk/src/graph/types.d.ts +105 -0
- package/package.json +1 -1
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import { EntityTfError } from "../../../engine/entity.js";
|
|
2
2
|
import { isTfExpr } from "../../../engine/tf/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* A filter value the platform holds but authored source can't, such as a
|
|
5
|
+
* FIELD value restricted to an app or element (`aspect`). A pull fails on it
|
|
6
|
+
* with an authoring blocker instead of dropping the filter, because writing
|
|
7
|
+
* the owner without it would remove the live filter on the next apply
|
|
8
|
+
* (#3144).
|
|
9
|
+
*/
|
|
10
|
+
export class UnauthorableFilterValueError extends EntityTfError {
|
|
11
|
+
constructor(message) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.name = "UnauthorableFilterValueError";
|
|
14
|
+
}
|
|
15
|
+
}
|
|
3
16
|
const TYPE_ALIASES = {
|
|
4
17
|
and: "and",
|
|
5
18
|
or: "or",
|
|
@@ -64,6 +77,78 @@ function fieldOptions(filter, codec, type) {
|
|
|
64
77
|
: {}),
|
|
65
78
|
};
|
|
66
79
|
}
|
|
80
|
+
function isGroupsOfValue(value) {
|
|
81
|
+
if (typeof value !== "object" || value === null)
|
|
82
|
+
return false;
|
|
83
|
+
const raw = value;
|
|
84
|
+
const realType = raw.realType ?? raw.real_type;
|
|
85
|
+
return typeof realType === "string" && realType.toUpperCase() === "USER_GROUPS";
|
|
86
|
+
}
|
|
87
|
+
/** Why a reference of this declared type isn't one user's id, in product words. */
|
|
88
|
+
function groupsOfTypeProblem(declared) {
|
|
89
|
+
if (declared === "USER")
|
|
90
|
+
return "is a whole user (use its .id)";
|
|
91
|
+
if (declared === "OBJECT")
|
|
92
|
+
return "is a whole item, not one user's id";
|
|
93
|
+
if (declared === "ASPECT_RECORD_ID" || declared === "RECORD_ID")
|
|
94
|
+
return "is a record's id, not a user's id";
|
|
95
|
+
if (declared === "GROUP" || declared === "GROUP_ID")
|
|
96
|
+
return "is a group, not a user's id";
|
|
97
|
+
if (declared === "RECORD_HANDLE")
|
|
98
|
+
return "is the record's ID, not a user's id";
|
|
99
|
+
if (declared === "DROPDOWN" || declared === "PICKLIST" || declared === "SYSTEM_FIELD" || declared.endsWith("_PART"))
|
|
100
|
+
return "is not a user's id";
|
|
101
|
+
return `holds a ${declared.toLowerCase().replace(/_/g, " ")} value, not a user's id`;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The platform expands `filter.groupsOf(...)` (realType USER_GROUPS) only as
|
|
105
|
+
* the sole value of an IN filter on a Group field, from one user's id (jarvis
|
|
106
|
+
* UserGroupsFilterResolver); anything else fails when the automation runs.
|
|
107
|
+
* edk#3039.
|
|
108
|
+
*/
|
|
109
|
+
function checkGroupsOfPlacement(filter, type, field, codec) {
|
|
110
|
+
const values = Array.isArray(filter.values) ? filter.values : [];
|
|
111
|
+
const others = [filter.leftValue, filter.value, filter.min, filter.max];
|
|
112
|
+
if (!others.some(isGroupsOfValue) && !values.some(isGroupsOfValue))
|
|
113
|
+
return;
|
|
114
|
+
const fail = (why) => {
|
|
115
|
+
throw new EntityTfError(`filter.groupsOf(...) ${why}: use it as the only value of filter.isIn / filter.isNotIn on a Group field in a record search`);
|
|
116
|
+
};
|
|
117
|
+
// A problem with the reference itself: its own advice, not the placement's.
|
|
118
|
+
const failReference = (why) => {
|
|
119
|
+
throw new EntityTfError(`filter.groupsOf(...) ${why}; it takes one user's id, such as ctx.trigger.triggeredBy.id or a user field's .id`);
|
|
120
|
+
};
|
|
121
|
+
if (codec.allowGroupsOf !== true)
|
|
122
|
+
fail("works only in a record search filter");
|
|
123
|
+
if (isGroupsOfValue(filter.leftValue))
|
|
124
|
+
fail("can't be the compared side");
|
|
125
|
+
// The platform reads the compared field's id (operator.getField()); a
|
|
126
|
+
// fieldValue(...) left side leaves it empty.
|
|
127
|
+
if (filter.field === undefined)
|
|
128
|
+
fail("needs a field as the compared side, not a fieldValue(...) or a reference");
|
|
129
|
+
if (type !== "in")
|
|
130
|
+
fail(`can't be used with ${type}`);
|
|
131
|
+
if (values.length !== 1)
|
|
132
|
+
fail("must be the only value in its list");
|
|
133
|
+
const fieldType = typeof field === "object" && field !== null ? field.fieldType : undefined;
|
|
134
|
+
if (typeof fieldType === "string" && fieldType !== "GROUP" && fieldType !== "GROUP_ID")
|
|
135
|
+
fail(`compares a ${fieldType} field`);
|
|
136
|
+
const groupsOfValue = values[0];
|
|
137
|
+
if (groupsOfValue.multiple === true)
|
|
138
|
+
failReference("holds a list");
|
|
139
|
+
const reference = groupsOfValue.value;
|
|
140
|
+
const declaredType = codec.referenceDeclaredType?.(reference);
|
|
141
|
+
const declared = declaredType?.type.toUpperCase();
|
|
142
|
+
if (declaredType?.multiple === true)
|
|
143
|
+
failReference("holds a list");
|
|
144
|
+
if (declared !== undefined && declared !== "USER_ID")
|
|
145
|
+
failReference(groupsOfTypeProblem(declared));
|
|
146
|
+
const name = typeof reference === "object" && reference !== null ? reference.name : undefined;
|
|
147
|
+
// Without a declared type, a reference named for an email or a name
|
|
148
|
+
// ("triggeredBy.email", "User's Email", "managerEmail") never holds an id.
|
|
149
|
+
if (declared === undefined && typeof name === "string" && /(?:email|name)$/i.test(name))
|
|
150
|
+
failReference(`holds ${JSON.stringify(name)}, not a user's id`);
|
|
151
|
+
}
|
|
67
152
|
/** The only authored/wire-filter -> Terraform-HCL filter serializer. */
|
|
68
153
|
export function filterToTf(value, codec) {
|
|
69
154
|
const filter = wireFilter(value);
|
|
@@ -76,6 +161,7 @@ export function filterToTf(value, codec) {
|
|
|
76
161
|
return { type, children: filter.children.map((child) => filterToTf(child, codec)) };
|
|
77
162
|
}
|
|
78
163
|
const field = filter.field ?? codec.fieldFromLeftValue?.(filter.leftValue);
|
|
164
|
+
checkGroupsOfPlacement(filter, type, field, codec);
|
|
79
165
|
const left = withLeft(filter, codec, type);
|
|
80
166
|
if (left.field_id === undefined && left.left_value === undefined) {
|
|
81
167
|
throw new EntityTfError(`${type} filter has no left side`);
|
|
@@ -146,7 +232,10 @@ function filterValueToWire(value) {
|
|
|
146
232
|
...(value.current_user_type !== undefined && { valueType: value.current_user_type.toUpperCase() }),
|
|
147
233
|
...(value.real_type !== undefined && { realType: value.real_type.toUpperCase() }),
|
|
148
234
|
...(value.multiple !== undefined && { multiple: value.multiple }),
|
|
149
|
-
|
|
235
|
+
// The compared field goes under canonical `value`, as the provider sends
|
|
236
|
+
// it: jarvis's FieldValue has no `field` and dropped it (#3144). A FIELD
|
|
237
|
+
// value has no literal, so this never meets the `value` above.
|
|
238
|
+
...(value.field_id !== undefined && { value: value.field_id }),
|
|
150
239
|
...(value.aspect_id !== undefined && { aspect: value.aspect_id }),
|
|
151
240
|
...(value.treat_null_as_equals !== undefined && { treatNullAsEquals: value.treat_null_as_equals }),
|
|
152
241
|
...(value.object !== undefined && { aspect: value.object }),
|
|
@@ -491,7 +580,7 @@ function decodedReferenceRealType(codec, reference, stored) {
|
|
|
491
580
|
const fallback = (present ? stored.toUpperCase() : "TEXT");
|
|
492
581
|
if (present)
|
|
493
582
|
return fallback;
|
|
494
|
-
return codec.referenceType?.(reference,
|
|
583
|
+
return codec.referenceType?.(reference, "TEXT") ?? fallback;
|
|
495
584
|
}
|
|
496
585
|
/** The only Terraform-HCL filter -> strongly typed deserializer AST. */
|
|
497
586
|
export function filterFromTf(value, codec, fieldScope = "app") {
|
|
@@ -603,10 +692,16 @@ function filterValueFromTf(value, codec, fieldScope, field) {
|
|
|
603
692
|
case "field":
|
|
604
693
|
if (value.field_id === undefined)
|
|
605
694
|
throw new EntityTfError("field filter value requires field_id");
|
|
695
|
+
// A FIELD value's aspect has no portable authored form: a reference
|
|
696
|
+
// can't be held and a raw id would put a platform id in source. Export
|
|
697
|
+
// writes aspect_id since #3144 (no platform code sets one today), and
|
|
698
|
+
// dropping it would remove it on the next apply, so pull fails instead.
|
|
699
|
+
if (value.aspect_id !== undefined) {
|
|
700
|
+
throw new UnauthorableFilterValueError("field filter value names an app or element (aspect_id), which source can't hold yet");
|
|
701
|
+
}
|
|
606
702
|
return {
|
|
607
703
|
type: "FIELD",
|
|
608
704
|
value: codec.field(value.field_id, fieldScope),
|
|
609
|
-
...(typeof value.aspect_id === "string" && { aspect: value.aspect_id }),
|
|
610
705
|
...(value.treat_null_as_equals !== undefined && { treatNullAsEquals: value.treat_null_as_equals }),
|
|
611
706
|
};
|
|
612
707
|
case "record_field": {
|
|
@@ -4,6 +4,13 @@
|
|
|
4
4
|
* Discriminated on `type` with values matching platform filter type names.
|
|
5
5
|
*/
|
|
6
6
|
export type ValueType = "BOOLEAN" | "CURRENT_USER" | "DATE" | "DATETIME" | "FIELD" | "NULL" | "NUMBER" | "RECORD_FIELD" | "REFERENCE" | "TEXT" | "UUID";
|
|
7
|
+
/**
|
|
8
|
+
* The type a REFERENCE value compares as. Besides every comparison type it
|
|
9
|
+
* can be USER_GROUPS: the groups of the user the reference holds, which only
|
|
10
|
+
* `filter.groupsOf(...)` writes (edk#3039). It is not a comparison type an
|
|
11
|
+
* operator accepts.
|
|
12
|
+
*/
|
|
13
|
+
export type ReferenceValueType = ValueType | "USER_GROUPS";
|
|
7
14
|
export type FilterReference = {
|
|
8
15
|
type: "TRIGGER";
|
|
9
16
|
name: string;
|
|
@@ -95,7 +102,7 @@ export type FilterValue<FieldValue = string, ReferenceValue = FilterReference> =
|
|
|
95
102
|
*/
|
|
96
103
|
| {
|
|
97
104
|
type: "REFERENCE";
|
|
98
|
-
realType?:
|
|
105
|
+
realType?: ReferenceValueType;
|
|
99
106
|
explicit?: true;
|
|
100
107
|
value: ReferenceValue;
|
|
101
108
|
label?: string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type TfBlock } from "../../engine/tf/index.js";
|
|
2
|
+
import type { StreamExtractContext } from "../../graph/types.js";
|
|
3
|
+
/**
|
|
4
|
+
* A skill or agent tool that runs a same-stream automation prints a catalog
|
|
5
|
+
* ref to it. If pull skips that automation and keeps no authored file for
|
|
6
|
+
* it, build cannot emit the tool, so stream-root drops it from its owner's
|
|
7
|
+
* file and releases it (#1731). A skill tool names the automation through
|
|
8
|
+
* its workflow_publish when it is active and through the automation itself
|
|
9
|
+
* when it is not; an agent tool always names the automation itself. Both
|
|
10
|
+
* forms are required here (edk#3151).
|
|
11
|
+
*/
|
|
12
|
+
export declare function requireRunAutomationTarget(tool: TfBlock, owner: {
|
|
13
|
+
readonly kind: "skill" | "agent";
|
|
14
|
+
readonly refName: string;
|
|
15
|
+
}, ctx: StreamExtractContext): void;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { isTfExpr, scopedLabelToBagKey } from "../../engine/tf/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* A skill or agent tool that runs a same-stream automation prints a catalog
|
|
4
|
+
* ref to it. If pull skips that automation and keeps no authored file for
|
|
5
|
+
* it, build cannot emit the tool, so stream-root drops it from its owner's
|
|
6
|
+
* file and releases it (#1731). A skill tool names the automation through
|
|
7
|
+
* its workflow_publish when it is active and through the automation itself
|
|
8
|
+
* when it is not; an agent tool always names the automation itself. Both
|
|
9
|
+
* forms are required here (edk#3151).
|
|
10
|
+
*/
|
|
11
|
+
export function requireRunAutomationTarget(tool, owner, ctx) {
|
|
12
|
+
const automation = tool.attrs["automation_id"];
|
|
13
|
+
const toolName = tool.attrs["name"];
|
|
14
|
+
if (!isTfExpr(automation) || automation.$expr !== "resource-attr" || typeof toolName !== "string")
|
|
15
|
+
return;
|
|
16
|
+
if (automation.type !== "elementum_workflow_publish" && automation.type !== "elementum_automation")
|
|
17
|
+
return;
|
|
18
|
+
ctx.requiresExtracted?.push({
|
|
19
|
+
address: `${tool.type}.${tool.label}`,
|
|
20
|
+
requires: `${automation.type}.${automation.label}`,
|
|
21
|
+
requiresOwnFile: { kind: "automation", refName: scopedLabelToBagKey(ctx.appTfLabel, automation.label) },
|
|
22
|
+
prune: (root) => root,
|
|
23
|
+
pruneOwnFile: {
|
|
24
|
+
kind: owner.kind,
|
|
25
|
+
prune: (items) => items.map((item) => item.refName === owner.refName ? { ...item, tools: item.tools.filter((t) => t.name !== toolName) } : item),
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ChildResourceScope } from "../../engine/tf/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* The resource label of an agent or skill tool's search table owned by an app
|
|
4
|
+
* or element built in this project. edk#2880: a table pull couldn't key (an
|
|
5
|
+
* unnamed table added after the element was pulled, or an element pulled with
|
|
6
|
+
* --no-adopt) reaches here as a literal whose refName is the platform's display
|
|
7
|
+
* name ("Search Table"). Its label would contain a space, so name the causes
|
|
8
|
+
* and their remedies instead of emitting a reference OpenTofu can't read.
|
|
9
|
+
*/
|
|
10
|
+
export declare function localSearchTableLabel(where: string, table: {
|
|
11
|
+
readonly refName: string;
|
|
12
|
+
readonly name?: string;
|
|
13
|
+
}, owner: {
|
|
14
|
+
readonly refName: string;
|
|
15
|
+
readonly tfLabel: string;
|
|
16
|
+
readonly scope: ChildResourceScope;
|
|
17
|
+
}): string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { EntityTfError } from "../../engine/entity.js";
|
|
2
|
+
import { scopedResourceLabel, tsLabelToTfLabel } from "../../engine/tf/index.js";
|
|
3
|
+
/** A label OpenTofu accepts in a reference (`<type>.<label>.id`). */
|
|
4
|
+
const REFERENCE_LABEL = /^[A-Za-z_][A-Za-z0-9_-]*$/;
|
|
5
|
+
/**
|
|
6
|
+
* The resource label of an agent or skill tool's search table owned by an app
|
|
7
|
+
* or element built in this project. edk#2880: a table pull couldn't key (an
|
|
8
|
+
* unnamed table added after the element was pulled, or an element pulled with
|
|
9
|
+
* --no-adopt) reaches here as a literal whose refName is the platform's display
|
|
10
|
+
* name ("Search Table"). Its label would contain a space, so name the causes
|
|
11
|
+
* and their remedies instead of emitting a reference OpenTofu can't read.
|
|
12
|
+
*/
|
|
13
|
+
export function localSearchTableLabel(where, table, owner) {
|
|
14
|
+
const label = scopedResourceLabel(owner.tfLabel, tsLabelToTfLabel(table.refName), owner.scope);
|
|
15
|
+
if (REFERENCE_LABEL.test(label))
|
|
16
|
+
return label;
|
|
17
|
+
const kind = owner.scope === "element" ? "element" : "app";
|
|
18
|
+
throw new EntityTfError(`${where}: search table ${JSON.stringify(table.name ?? table.refName)} isn't a catalog search table of ${kind} "${owner.refName}" ` +
|
|
19
|
+
`(pull wrote it this way because it couldn't match the table to a key of the ${kind}'s catalog), so it has no address here ` +
|
|
20
|
+
`(it would build as "${label}"). If the table was added after the ${kind} was pulled, re-pull the ${kind} ` +
|
|
21
|
+
`(\`elementum pull ${kind} ${owner.tfLabel}\`) and then this app. If the ${kind} was pulled with --no-adopt or --portable, ` +
|
|
22
|
+
`set the tool's table to \`catalog.${owner.refName}.searchTables.<key>\` with the key the ${kind}'s catalog gives it, ` +
|
|
23
|
+
`or re-pull the ${kind} with adoption and then this app.`);
|
|
24
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type FromTfContext } from "../../engine/pull/context.js";
|
|
2
|
+
import { type TfValue } from "../../engine/tf/index.js";
|
|
3
|
+
import type { EntityKindId, QuarantinedOwnFile } from "../../graph/types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Leave an inline resource out of source and out of adoption (edk#3166).
|
|
6
|
+
*
|
|
7
|
+
* A resource that pull writes no source for must not be imported either, or
|
|
8
|
+
* the next plan destroys it on the platform. Every extract context has
|
|
9
|
+
* `ctx.skipped` and `ctx.releaseIfManaged` for that; this helper adds the
|
|
10
|
+
* typed skipped gap and picks the route by why the resource can't be written:
|
|
11
|
+
*
|
|
12
|
+
* - `{ reference }`: a reference pull can't resolve (how the export names it,
|
|
13
|
+
* see {@link unresolvedReferenceName}). It registers an unresolved
|
|
14
|
+
* requirement, the route #1731 uses for a chart widget whose chart is
|
|
15
|
+
* skipped, so stream-root skips and releases it and reports "it needs
|
|
16
|
+
* <reference>, which is not a resource this pull extracts". Without a
|
|
17
|
+
* requirement list (a context that does not adopt) it records `fallback`.
|
|
18
|
+
* - `{ problem }`: a shape the export gives that pull can't author ("its
|
|
19
|
+
* size \"XL\" is not a dashboard widget size"). It skips and releases the
|
|
20
|
+
* resource directly and reports the problem as the reason.
|
|
21
|
+
*/
|
|
22
|
+
export declare function skipAndRelease(ctx: Pick<FromTfContext, "requiresExtracted" | "skipped" | "releaseIfManaged" | "diagnostics">, address: string, why: {
|
|
23
|
+
readonly reference: string;
|
|
24
|
+
} | {
|
|
25
|
+
readonly problem: string;
|
|
26
|
+
}, fallback: string, ownFile?: OwnFileSkip): void;
|
|
27
|
+
/** A skipped resource printed as its own file, and the extract result's list its file is quarantined in. */
|
|
28
|
+
interface OwnFileSkip {
|
|
29
|
+
readonly kind: EntityKindId;
|
|
30
|
+
readonly refName: string;
|
|
31
|
+
readonly quarantineOwnFiles: QuarantinedOwnFile[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* {@link skipAndRelease} for a resource printed as its own file (a phone
|
|
35
|
+
* service, an agent evaluation). The sweep keeps an earlier pull's file of a
|
|
36
|
+
* skipped child, so build would emit it again and the next plan would
|
|
37
|
+
* create a second copy of the live resource once adoption releases it. The
|
|
38
|
+
* file is quarantined instead, and archived to .edk-state/pull-backups once
|
|
39
|
+
* state no longer manages `address` (#1858, #2054); the skipped gap says so.
|
|
40
|
+
* Only a route that skips the resource quarantines its file: without a
|
|
41
|
+
* requirement list nothing is skipped, so nothing is quarantined.
|
|
42
|
+
*/
|
|
43
|
+
export declare function skipOwnFileAndRelease(ctx: Parameters<typeof skipAndRelease>[0], address: string, why: Parameters<typeof skipAndRelease>[2], fallback: string, ownFile: {
|
|
44
|
+
readonly kind: EntityKindId;
|
|
45
|
+
readonly refName: string;
|
|
46
|
+
}, quarantineOwnFiles: QuarantinedOwnFile[]): void;
|
|
47
|
+
/** How the export named a reference pull could not resolve, for {@link skipAndRelease}'s `reference`. */
|
|
48
|
+
export declare function unresolvedReferenceName(value: TfValue | undefined, attribute: string): string;
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { typedCoverageGap } from "../../engine/coverage-gaps.js";
|
|
2
|
+
import { dataRefLabel, ownFileArchiveConsequence } from "../../engine/pull/context.js";
|
|
3
|
+
import { isTfExpr } from "../../engine/tf/index.js";
|
|
4
|
+
const SKIPPED_CONSEQUENCE = "it is not written to source or adopted, and adoption releases it if state already manages it; it keeps running on the platform unmanaged until a later pull can write it";
|
|
5
|
+
/**
|
|
6
|
+
* Leave an inline resource out of source and out of adoption (edk#3166).
|
|
7
|
+
*
|
|
8
|
+
* A resource that pull writes no source for must not be imported either, or
|
|
9
|
+
* the next plan destroys it on the platform. Every extract context has
|
|
10
|
+
* `ctx.skipped` and `ctx.releaseIfManaged` for that; this helper adds the
|
|
11
|
+
* typed skipped gap and picks the route by why the resource can't be written:
|
|
12
|
+
*
|
|
13
|
+
* - `{ reference }`: a reference pull can't resolve (how the export names it,
|
|
14
|
+
* see {@link unresolvedReferenceName}). It registers an unresolved
|
|
15
|
+
* requirement, the route #1731 uses for a chart widget whose chart is
|
|
16
|
+
* skipped, so stream-root skips and releases it and reports "it needs
|
|
17
|
+
* <reference>, which is not a resource this pull extracts". Without a
|
|
18
|
+
* requirement list (a context that does not adopt) it records `fallback`.
|
|
19
|
+
* - `{ problem }`: a shape the export gives that pull can't author ("its
|
|
20
|
+
* size \"XL\" is not a dashboard widget size"). It skips and releases the
|
|
21
|
+
* resource directly and reports the problem as the reason.
|
|
22
|
+
*/
|
|
23
|
+
export function skipAndRelease(ctx, address, why, fallback, ownFile) {
|
|
24
|
+
if ("reference" in why) {
|
|
25
|
+
if (ctx.requiresExtracted === undefined) {
|
|
26
|
+
ctx.diagnostics.push(fallback);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
ctx.requiresExtracted.push({
|
|
30
|
+
address,
|
|
31
|
+
requires: why.reference,
|
|
32
|
+
unresolved: true,
|
|
33
|
+
prune: (root) => root,
|
|
34
|
+
// Stream-root quarantines the file once it releases the address and
|
|
35
|
+
// says so in the skipped gap (#2892).
|
|
36
|
+
...(ownFile !== undefined && { pruneOwnFile: { kind: ownFile.kind, prune: (items) => items, archiveRefName: ownFile.refName } }),
|
|
37
|
+
});
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
ctx.skipped.push(address);
|
|
41
|
+
ctx.releaseIfManaged?.push(address);
|
|
42
|
+
if (ownFile !== undefined)
|
|
43
|
+
ownFile.quarantineOwnFiles.push({ kind: ownFile.kind, refName: ownFile.refName, afterRelease: [address] });
|
|
44
|
+
const consequence = SKIPPED_CONSEQUENCE + (ownFile !== undefined ? ownFileArchiveConsequence(ownFile.kind, ownFile.refName) : "");
|
|
45
|
+
ctx.diagnostics.push(typedCoverageGap({ kind: "skipped", entity: address, detail: `left out of the pull, skipped: ${why.problem}`, consequence }));
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* {@link skipAndRelease} for a resource printed as its own file (a phone
|
|
49
|
+
* service, an agent evaluation). The sweep keeps an earlier pull's file of a
|
|
50
|
+
* skipped child, so build would emit it again and the next plan would
|
|
51
|
+
* create a second copy of the live resource once adoption releases it. The
|
|
52
|
+
* file is quarantined instead, and archived to .edk-state/pull-backups once
|
|
53
|
+
* state no longer manages `address` (#1858, #2054); the skipped gap says so.
|
|
54
|
+
* Only a route that skips the resource quarantines its file: without a
|
|
55
|
+
* requirement list nothing is skipped, so nothing is quarantined.
|
|
56
|
+
*/
|
|
57
|
+
export function skipOwnFileAndRelease(ctx, address, why, fallback, ownFile, quarantineOwnFiles) {
|
|
58
|
+
skipAndRelease(ctx, address, why, fallback, { ...ownFile, quarantineOwnFiles });
|
|
59
|
+
}
|
|
60
|
+
/** How the export named a reference pull could not resolve, for {@link skipAndRelease}'s `reference`. */
|
|
61
|
+
export function unresolvedReferenceName(value, attribute) {
|
|
62
|
+
if (value === undefined)
|
|
63
|
+
return `a resolvable ${attribute}`;
|
|
64
|
+
if (isTfExpr(value) && value.$expr === "data-attr") {
|
|
65
|
+
const label = dataRefLabel(value, value.type);
|
|
66
|
+
if (label !== undefined)
|
|
67
|
+
return `data.${value.type}.${label}`;
|
|
68
|
+
}
|
|
69
|
+
if (isTfExpr(value) && value.$expr === "resource-attr")
|
|
70
|
+
return `${value.type}.${value.label}`;
|
|
71
|
+
if (typeof value === "string")
|
|
72
|
+
return `${attribute} ${JSON.stringify(value)}`;
|
|
73
|
+
return `a resolvable ${attribute}`;
|
|
74
|
+
}
|
|
@@ -42,9 +42,9 @@ export interface PrintSkillV2Options {
|
|
|
42
42
|
*/
|
|
43
43
|
readonly foreignElementRefNames?: ReadonlyMap<string, string>;
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
46
|
-
* `foreignTask` tool target whose name is a key here
|
|
47
|
-
*
|
|
45
|
+
* Display name → refName for standalone tasks on disk. A task has no
|
|
46
|
+
* catalog entry, so a `foreignTask` tool target whose name is a key here
|
|
47
|
+
* still prints the inline stub, carrying this refName (#3148).
|
|
48
48
|
*/
|
|
49
49
|
readonly foreignTaskRefNames?: ReadonlyMap<string, string>;
|
|
50
50
|
/** Terraform label → authored catalog ref. Field identities stay on the label. */
|
|
@@ -296,10 +296,12 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
|
|
|
296
296
|
: foreignAppRefNames;
|
|
297
297
|
// Display-name map first: the terraform label and the authored catalog key
|
|
298
298
|
// differ (#1427). Extract-time refName is the state/namespace join for
|
|
299
|
-
// apps and elements.
|
|
300
|
-
//
|
|
299
|
+
// apps and elements. A task-type app has no catalog entry, even once
|
|
300
|
+
// pulled (#3148), so it always prints the inline stub, carrying the
|
|
301
|
+
// pulled task's refName when the map names one.
|
|
301
302
|
const mapped = refNames?.get(tool.target.name);
|
|
302
|
-
const catalogRefName =
|
|
303
|
+
const catalogRefName = tool.target.kind === "foreignTask" ? undefined : mapped ?? tool.target.refName;
|
|
304
|
+
const stubRefName = (tool.target.kind === "foreignTask" ? mapped : undefined) ?? tool.target.refName ?? tool.target.name;
|
|
303
305
|
if (catalogRefName !== undefined) {
|
|
304
306
|
lines.push(` ${entityKind}: catalog.${catalogRefName},`);
|
|
305
307
|
}
|
|
@@ -311,7 +313,7 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
|
|
|
311
313
|
const todo = crossOrg
|
|
312
314
|
? ` // TODO: cross-org clone — "${tool.target.name}" was resolved in the SOURCE org; verify it exists (with this name) in the destination org`
|
|
313
315
|
: "";
|
|
314
|
-
lines.push(` ${entityKind}: { __kind: ${quote(entityKind)}, refName: ${quote(
|
|
316
|
+
lines.push(` ${entityKind}: { __kind: ${quote(entityKind)}, refName: ${quote(stubRefName)}, name: ${quote(tool.target.name)}${tool.target.namespace !== undefined ? `, namespace: ${quote(tool.target.namespace)}` : ""} },${todo}`);
|
|
315
317
|
}
|
|
316
318
|
}
|
|
317
319
|
if (tool.typeKey === "searchAspect") {
|
|
@@ -362,7 +364,11 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
|
|
|
362
364
|
lines.push(` table: catalog.${tableOwner}.searchTables${safeMember(typedTable.tableKey)},`);
|
|
363
365
|
}
|
|
364
366
|
else {
|
|
365
|
-
|
|
367
|
+
// An id-pinned lookup (a name two tables of the owner share, e.g. two
|
|
368
|
+
// unnamed tables) keeps its id, as print-agent-v2.ts does; without it
|
|
369
|
+
// build writes a name lookup that plan rejects as ambiguous (edk#2881).
|
|
370
|
+
const pinnedId = tool.searchTableId !== undefined ? `, id: ${quote(tool.searchTableId)}` : "";
|
|
371
|
+
lines.push(` table: { __kind: "searchTable", refName: ${quote(tool.searchTableName ?? "")}, name: ${quote(tool.searchTableName ?? "")}, parent: ${quote(parent)}${pinnedId} },`);
|
|
366
372
|
}
|
|
367
373
|
}
|
|
368
374
|
lines.push(` queryDescription: ${quote(tool.queryDescription ?? "")},`);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/** The skill entity's registry entry + resource-type constant (see src/graph/). */
|
|
2
2
|
import { rootParentFactoryEntry } from "../../catalog/render-helpers.js";
|
|
3
|
-
import { isTfExpr
|
|
3
|
+
import { isTfExpr } from "../../engine/tf/index.js";
|
|
4
4
|
import { GROUP_RESOURCE_TYPE } from "../org/group.js";
|
|
5
|
+
import { requireRunAutomationTarget } from "../shared/run-automation-requirement.js";
|
|
5
6
|
import { printSkillV2 } from "./deserializer/print-skill-v2.js";
|
|
6
7
|
import { skillFromTf } from "./from-tf.js";
|
|
7
8
|
import { skillToTf } from "./to-tf.js";
|
|
@@ -42,29 +43,6 @@ function skillRefFromAuthoring(args) {
|
|
|
42
43
|
: entityRefName;
|
|
43
44
|
return { __kind: "skill", refName: entityRefName, name, parent: entityParent };
|
|
44
45
|
}
|
|
45
|
-
/**
|
|
46
|
-
* A tool that runs a same-stream automation prints a catalog ref to it. If
|
|
47
|
-
* pull skips that automation and keeps no authored file for it, build cannot
|
|
48
|
-
* emit the tool, so stream-root drops it from the skill and releases it.
|
|
49
|
-
*/
|
|
50
|
-
function requireRunAutomationTarget(tool, skillRefName, ctx) {
|
|
51
|
-
const automation = tool.attrs["automation_id"];
|
|
52
|
-
const toolName = tool.attrs["name"];
|
|
53
|
-
if (!isTfExpr(automation) || automation.$expr !== "resource-attr" || typeof toolName !== "string")
|
|
54
|
-
return;
|
|
55
|
-
if (automation.type !== "elementum_workflow_publish" && automation.type !== "elementum_automation")
|
|
56
|
-
return;
|
|
57
|
-
ctx.requiresExtracted?.push({
|
|
58
|
-
address: `${tool.type}.${tool.label}`,
|
|
59
|
-
requires: `${automation.type}.${automation.label}`,
|
|
60
|
-
requiresOwnFile: { kind: "automation", refName: scopedLabelToBagKey(ctx.appTfLabel, automation.label) },
|
|
61
|
-
prune: (root) => root,
|
|
62
|
-
pruneOwnFile: {
|
|
63
|
-
kind: "skill",
|
|
64
|
-
prune: (skills) => skills.map((skill) => skill.refName === skillRefName ? { ...skill, tools: skill.tools.filter((t) => t.name !== toolName) } : skill),
|
|
65
|
-
},
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
46
|
function extractSkills(ownBlocks, stream, ctx) {
|
|
69
47
|
const toolBlocks = stream.byKind.get("skill-tool") ?? [];
|
|
70
48
|
const items = [];
|
|
@@ -80,7 +58,7 @@ function extractSkills(ownBlocks, stream, ctx) {
|
|
|
80
58
|
if (skill !== undefined) {
|
|
81
59
|
items.push(skill);
|
|
82
60
|
for (const tool of ownTools)
|
|
83
|
-
requireRunAutomationTarget(tool, skill.refName, ctx);
|
|
61
|
+
requireRunAutomationTarget(tool, { kind: "skill", refName: skill.refName }, ctx);
|
|
84
62
|
}
|
|
85
63
|
else if (skippedReason !== undefined) {
|
|
86
64
|
skipped.push(`${SKILL_RESOURCE_TYPE}.${skillLabel}`);
|
|
@@ -133,7 +133,9 @@ export interface SkillToolOwner {
|
|
|
133
133
|
readonly skillLabel: string;
|
|
134
134
|
}
|
|
135
135
|
/**
|
|
136
|
-
* One tool block → its normalized shape; undefined = skipped
|
|
137
|
-
*
|
|
136
|
+
* One tool block → its normalized shape; undefined = skipped (unimplemented
|
|
137
|
+
* sub-type, wrong owner, unresolvable target). A tool written to no source
|
|
138
|
+
* is also left out of adoption, or released if state has it, so the next
|
|
139
|
+
* plan doesn't destroy it (edk#3172); skipAndRelease does both.
|
|
138
140
|
*/
|
|
139
141
|
export declare function skillToolFromTf(block: TfBlock, owner: SkillToolOwner, ctx: FromTfContext): NormalizedSkillTool | undefined;
|