@elementumai/edk 0.9.13 → 0.9.15
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 +4 -0
- package/dist-sdk/src/catalog/from-authoring.js +5 -1
- package/dist-sdk/src/catalog/index.d.ts +2 -2
- package/dist-sdk/src/catalog/index.js +1 -1
- package/dist-sdk/src/catalog/token.js +2 -2
- package/dist-sdk/src/catalog/types.d.ts +7 -2
- package/dist-sdk/src/core/types/app.d.ts +4 -4
- package/dist-sdk/src/engine/build/context.d.ts +3 -2
- package/dist-sdk/src/engine/build/source-context.d.ts +2 -0
- package/dist-sdk/src/engine/build/source-context.js +16 -0
- package/dist-sdk/src/engine/progress.d.ts +15 -1
- package/dist-sdk/src/engine/progress.js +17 -1
- package/dist-sdk/src/engine/pull/context.d.ts +4 -1
- package/dist-sdk/src/engine/pull/ref-only.d.ts +2 -2
- package/dist-sdk/src/engine/pull/ref-only.js +3 -3
- package/dist-sdk/src/engine/workspace/loader.js +23 -2
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +6 -0
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +23 -2
- package/dist-sdk/src/entities/agent/module.js +1 -0
- package/dist-sdk/src/entities/agent/to-tf.js +1 -0
- package/dist-sdk/src/entities/agent/tools.d.ts +20 -4
- package/dist-sdk/src/entities/agent/tools.js +10 -2
- package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +4 -0
- package/dist-sdk/src/entities/agent-tool/from-tf.js +2 -1
- package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/agent-tool/to-tf.js +11 -6
- package/dist-sdk/src/entities/app/build.d.ts +2 -2
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +4 -4
- package/dist-sdk/src/entities/approval-chain/build.d.ts +8 -1
- package/dist-sdk/src/entities/approval-chain/build.js +3 -0
- package/dist-sdk/src/entities/approval-chain/from-tf.d.ts +2 -1
- package/dist-sdk/src/entities/approval-chain/from-tf.js +20 -7
- package/dist-sdk/src/entities/approval-chain/printer.js +13 -2
- package/dist-sdk/src/entities/approval-chain/to-tf.js +3 -0
- package/dist-sdk/src/entities/automation/build.d.ts +7 -7
- package/dist-sdk/src/entities/automation/build.js +6 -2
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +19 -0
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +114 -42
- package/dist-sdk/src/entities/automation/from-tf.d.ts +13 -1
- package/dist-sdk/src/entities/automation/from-tf.js +105 -33
- package/dist-sdk/src/entities/automation/index.d.ts +2 -2
- package/dist-sdk/src/entities/automation/index.js +2 -2
- package/dist-sdk/src/entities/automation/module.js +15 -9
- package/dist-sdk/src/entities/automation/script-code.d.ts +32 -0
- package/dist-sdk/src/entities/automation/script-code.js +59 -1
- package/dist-sdk/src/entities/automation/tasks.d.ts +19 -19
- package/dist-sdk/src/entities/automation/tasks.js +2 -5
- package/dist-sdk/src/entities/automation/to-tf.js +38 -10
- package/dist-sdk/src/entities/chart/build.d.ts +3 -3
- package/dist-sdk/src/entities/chart/from-tf.d.ts +2 -2
- package/dist-sdk/src/entities/chart/from-tf.js +20 -13
- package/dist-sdk/src/entities/chart/to-tf.js +7 -5
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +3 -2
- package/dist-sdk/src/entities/field/build.d.ts +2 -2
- package/dist-sdk/src/entities/field/from-tf.js +35 -3
- package/dist-sdk/src/entities/field/to-tf.d.ts +1 -1
- package/dist-sdk/src/entities/field/to-tf.js +11 -4
- package/dist-sdk/src/entities/record-create-form/from-tf.js +3 -2
- package/dist-sdk/src/entities/relationship/from-tf.js +6 -3
- package/dist-sdk/src/entities/relationship/to-tf.js +12 -3
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +3 -3
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +10 -6
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +2 -2
- package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +1 -1
- package/dist-sdk/src/entities/shared/tool-field-ref.js +6 -2
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +6 -0
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +29 -16
- package/dist-sdk/src/entities/skill/module.js +1 -0
- package/dist-sdk/src/entities/skill/to-tf.js +1 -0
- package/dist-sdk/src/entities/skill/tools.d.ts +11 -3
- package/dist-sdk/src/entities/skill/tools.js +5 -1
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +6 -0
- package/dist-sdk/src/entities/skill-tool/from-tf.js +19 -1
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/skill-tool/to-tf.js +13 -4
- package/dist-sdk/src/entities/task/module.js +1 -1
- package/dist-sdk/src/entities/widget/from-tf.js +2 -2
- package/dist-sdk/src/graph/index.d.ts +2 -0
- package/dist-sdk/src/graph/index.js +14 -0
- package/dist-sdk/src/graph/types.d.ts +27 -1
- package/package.json +1 -1
|
@@ -51,7 +51,7 @@ function resolveTarget(token, ctx) {
|
|
|
51
51
|
return { value: token.value, refName: token.value, kind: "app" };
|
|
52
52
|
}
|
|
53
53
|
const refName = token.refName ?? "";
|
|
54
|
-
const kind = token.__kind === "element" ? "element" : "app";
|
|
54
|
+
const kind = token.__kind === "element" ? "element" : token.__kind === "task" ? "task" : "app";
|
|
55
55
|
if (kind === "app" && refName === ctx.appRefName) {
|
|
56
56
|
return {
|
|
57
57
|
value: expr.resourceAttr("elementum_app", ctx.appTfLabel, ["id"]),
|
|
@@ -62,7 +62,7 @@ function resolveTarget(token, ctx) {
|
|
|
62
62
|
}
|
|
63
63
|
const sibling = ctx.workspaceAspects?.get(workspaceAspectKey(kind, refName));
|
|
64
64
|
if (sibling !== undefined) {
|
|
65
|
-
const resourceType = kind === "element" ? "elementum_element" : "elementum_app";
|
|
65
|
+
const resourceType = kind === "element" ? "elementum_element" : kind === "task" ? "elementum_task" : "elementum_app";
|
|
66
66
|
return {
|
|
67
67
|
value: expr.resourceAttr(resourceType, sibling.tfLabel, ["id"]),
|
|
68
68
|
refName,
|
|
@@ -80,6 +80,10 @@ function resolveTarget(token, ctx) {
|
|
|
80
80
|
ctx.foreignElementRef(tfLabel, name, token.namespace);
|
|
81
81
|
return { value: expr.dataAttr("elementum_element", tfLabel, ["id"]), refName, kind, foreignTfLabel: tfLabel };
|
|
82
82
|
}
|
|
83
|
+
if (kind === "task") {
|
|
84
|
+
ctx.foreignTaskRef?.(tfLabel, name, token.namespace);
|
|
85
|
+
return { value: expr.dataAttr("elementum_task", tfLabel, ["id"]), refName, kind, foreignTfLabel: tfLabel };
|
|
86
|
+
}
|
|
83
87
|
ctx.foreignAppRef(tfLabel, name, token.namespace);
|
|
84
88
|
return { value: expr.dataAttr("elementum_app", tfLabel, ["id"]), refName, kind, foreignTfLabel: tfLabel };
|
|
85
89
|
}
|
|
@@ -95,7 +99,8 @@ function resolveTarget(token, ctx) {
|
|
|
95
99
|
*/
|
|
96
100
|
function foreignTargetFieldRefValue(token, refName, target, ctx) {
|
|
97
101
|
const fieldName = token.name ?? refName;
|
|
98
|
-
const
|
|
102
|
+
const ownerLabel = target.foreignTfLabel ?? sanitizeName(target.refName);
|
|
103
|
+
const fieldLabel = `${target.kind}_${ownerLabel}_${tsLabelToTfLabel(refName)}`;
|
|
99
104
|
ctx.foreignFieldRef("elementum_field", fieldLabel, target.value, fieldName);
|
|
100
105
|
return expr.dataAttr("elementum_field", fieldLabel, ["id"]);
|
|
101
106
|
}
|
|
@@ -139,7 +144,7 @@ function fieldRefValue(token, where, ctx, target) {
|
|
|
139
144
|
ctx.diagnostics.push(`${where}: field "${refName}" belongs to ${parentKind} "${parent}", not the tool's target ${target.kind} "${target.refName}" — a tool's fields must belong to its own target aspect; dropped`);
|
|
140
145
|
return undefined;
|
|
141
146
|
}
|
|
142
|
-
if (target.localTfLabel === undefined)
|
|
147
|
+
if (target.localTfLabel === undefined || target.kind === "task")
|
|
143
148
|
return foreignTargetFieldRefValue(token, refName, target, ctx);
|
|
144
149
|
// Falls through to the local resource-address resolution below.
|
|
145
150
|
}
|
|
@@ -151,7 +156,7 @@ function fieldRefValue(token, where, ctx, target) {
|
|
|
151
156
|
// vs. real field resource, by authoring type) rather than reimplementing
|
|
152
157
|
// it here — see fieldRefToTfValue's doc comment for the system-field
|
|
153
158
|
// ordering rationale.
|
|
154
|
-
const value = fieldRefToTfValue(token.fieldType ?? "", refName, target?.localTfLabel ?? ctx.appTfLabel, target?.kind
|
|
159
|
+
const value = fieldRefToTfValue(token.fieldType ?? "", refName, target?.localTfLabel ?? ctx.appTfLabel, target?.kind === "element" ? "element" : "app");
|
|
155
160
|
if (value === undefined) {
|
|
156
161
|
ctx.diagnostics.push(`${where}: field token "${refName}" has no terraform field resource mapping (fieldType ${JSON.stringify(token.fieldType ?? "")}); dropped`);
|
|
157
162
|
}
|
|
@@ -352,7 +357,7 @@ export function toolToTf(entry, ctx) {
|
|
|
352
357
|
: table.__variant === "table"
|
|
353
358
|
? "elementum_table_search_table"
|
|
354
359
|
: "elementum_ai_search_table";
|
|
355
|
-
attrs["search_table_id"] = expr.resourceAttr(resourceType, scopedResourceLabel(target.localTfLabel, tsLabelToTfLabel(table.refName), target.kind), ["id"]);
|
|
360
|
+
attrs["search_table_id"] = expr.resourceAttr(resourceType, scopedResourceLabel(target.localTfLabel, tsLabelToTfLabel(table.refName), target.kind === "element" ? "element" : "app"), ["id"]);
|
|
356
361
|
}
|
|
357
362
|
else if (target !== undefined) {
|
|
358
363
|
const lookupLabel = sanitizeName(`${target.foreignTfLabel}_${table.name ?? table.refName}`);
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* Includes typed scalar, Dropdown/Multi-Select, relation, calculation, and
|
|
12
12
|
* record-experience configuration with build/pull round-trip support.
|
|
13
13
|
*/
|
|
14
|
-
import { type AgentRef, type AppOrElementRef, type AutomationCatalogRef, type CatalogRef, type ChartRef, type CloudLinkRef, type DashboardRef, type FieldRef, type WidgetRef } from "../../catalog/index.js";
|
|
14
|
+
import { type AgentRef, type AppOrElementOrTaskRef, type AppOrElementRef, type AutomationCatalogRef, type CatalogRef, type ChartRef, type CloudLinkRef, type DashboardRef, type FieldRef, type WidgetRef } from "../../catalog/index.js";
|
|
15
15
|
import type { WorkflowFieldType } from "../shared/types/field-types.js";
|
|
16
16
|
import { type SystemFieldKey } from "../../core/system-fields.js";
|
|
17
17
|
import type { DeployableEntity, EntityDeployOptions } from "../../engine/entity.js";
|
|
@@ -61,7 +61,7 @@ export interface AppPicklistDynamicSortOrder {
|
|
|
61
61
|
* doesn't recognize trips its post-apply consistency check).
|
|
62
62
|
*/
|
|
63
63
|
export interface AppPicklistDynamicConfig {
|
|
64
|
-
readonly relatedAspectId:
|
|
64
|
+
readonly relatedAspectId: AppOrElementOrTaskRef | UnsafePlatformId;
|
|
65
65
|
readonly relatedLabelFieldId: FieldRef | UnsafePlatformId;
|
|
66
66
|
readonly parentFieldId?: FieldRef | UnsafePlatformId;
|
|
67
67
|
readonly parentMappings?: readonly {
|
|
@@ -191,7 +191,7 @@ export type NormalizedDashboardWidget = {
|
|
|
191
191
|
readonly chartKey: string;
|
|
192
192
|
};
|
|
193
193
|
export interface NormalizedWidgetRef {
|
|
194
|
-
readonly kind: "app" | "element" | "automation" | "field" | "recordIdentity";
|
|
194
|
+
readonly kind: "app" | "element" | "task" | "automation" | "field" | "recordIdentity";
|
|
195
195
|
readonly key: string;
|
|
196
196
|
readonly name: string;
|
|
197
197
|
readonly parent?: string;
|
|
@@ -267,7 +267,7 @@ export interface NormalizedRecordCreateForm {
|
|
|
267
267
|
readonly sections: readonly NormalizedRecordCreateFormSection[];
|
|
268
268
|
}
|
|
269
269
|
export interface PulledDynamicLayoutRef {
|
|
270
|
-
readonly __pulledRef: "field" | "automation" | "agent" | "app" | "element";
|
|
270
|
+
readonly __pulledRef: "field" | "automation" | "agent" | "app" | "element" | "task";
|
|
271
271
|
readonly key: string;
|
|
272
272
|
readonly parent?: string;
|
|
273
273
|
readonly name?: string;
|
|
@@ -280,7 +280,7 @@ export interface NormalizedDynamicLayout {
|
|
|
280
280
|
readonly layout: Readonly<Record<string, unknown>>;
|
|
281
281
|
}
|
|
282
282
|
export interface PulledRelationshipRef {
|
|
283
|
-
readonly kind: "app" | "element" | "table" | "field" | "tableColumn" | "recordIdentity";
|
|
283
|
+
readonly kind: "app" | "element" | "table" | "task" | "field" | "tableColumn" | "recordIdentity";
|
|
284
284
|
readonly key: string;
|
|
285
285
|
readonly name: string;
|
|
286
286
|
readonly parent?: string;
|
|
@@ -290,7 +290,7 @@ export interface PulledRelationshipRef {
|
|
|
290
290
|
/** The recursive pull resolved this reference to an on-disk generated catalog token. */
|
|
291
291
|
readonly catalogRef?: boolean;
|
|
292
292
|
readonly namespace?: string;
|
|
293
|
-
readonly parentKind?: "app" | "element";
|
|
293
|
+
readonly parentKind?: "app" | "element" | "task";
|
|
294
294
|
readonly parentName?: string;
|
|
295
295
|
readonly parentNamespace?: string;
|
|
296
296
|
readonly target?: PulledRelationshipRef;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ApprovalProcessRef, type CatalogRef, type FieldRef } from "../../catalog/index.js";
|
|
2
|
+
import { type UnsafePlatformId } from "../../core/platform-id.js";
|
|
2
3
|
import type { DeployableEntity, EntityDeployOptions } from "../../engine/entity.js";
|
|
3
4
|
type AppOwner = CatalogRef<"app">;
|
|
4
5
|
type OwnedField<App extends AppOwner> = App extends {
|
|
@@ -21,7 +22,13 @@ interface DefineApprovalProcessBase<App extends AppOwner> extends EntityDeployOp
|
|
|
21
22
|
readonly approveButton?: string;
|
|
22
23
|
readonly denyButton?: string;
|
|
23
24
|
readonly exceptionButton?: string;
|
|
24
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Fields locked while approval is active.
|
|
27
|
+
*
|
|
28
|
+
* Pull uses `unsafePlatformId(...)` only when the platform export contains a
|
|
29
|
+
* system-field UUID that cannot be reconstructed as a portable catalog ref.
|
|
30
|
+
*/
|
|
31
|
+
readonly lockedFields?: readonly (OwnedField<App> | UnsafePlatformId)[];
|
|
25
32
|
}
|
|
26
33
|
export type DefineApprovalProcessOptions<App extends AppOwner = AppOwner> = DefineApprovalProcessBase<App> & ({
|
|
27
34
|
readonly stage?: string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { EdkValidationError } from "../../../elementum-entity-client/errors.js";
|
|
2
2
|
import { slimTokens, } from "../../catalog/index.js";
|
|
3
|
+
import { isUnsafePlatformId } from "../../core/platform-id.js";
|
|
3
4
|
/** Explicit escape hatch used only when pull cannot recover a portable stage key. */
|
|
4
5
|
export function unsafeApprovalStageId(value) {
|
|
5
6
|
if (value.trim() === "")
|
|
@@ -17,6 +18,8 @@ export function approvalProcess(opts) {
|
|
|
17
18
|
throw new EdkValidationError("approvalProcess numberOfDynamicApprovers must be an integer >= 0.");
|
|
18
19
|
}
|
|
19
20
|
for (const field of opts.lockedFields ?? []) {
|
|
21
|
+
if (isUnsafePlatformId(field))
|
|
22
|
+
continue;
|
|
20
23
|
if (field.parent !== opts.app.refName) {
|
|
21
24
|
throw new EdkValidationError(`approvalProcess locked field ${JSON.stringify(field.refName)} belongs to ${JSON.stringify(field.parent)}, not app ${JSON.stringify(opts.app.refName)}.`);
|
|
22
25
|
}
|
|
@@ -13,5 +13,6 @@ export interface NormalizedApprovalChain {
|
|
|
13
13
|
readonly defaultReason?: string;
|
|
14
14
|
readonly summary?: string;
|
|
15
15
|
readonly lockedFields: readonly string[];
|
|
16
|
+
readonly unsafeLockedFieldIds?: readonly string[];
|
|
16
17
|
}
|
|
17
|
-
export declare function approvalChainFromTf(block: TfBlock, appTfLabel: string,
|
|
18
|
+
export declare function approvalChainFromTf(block: TfBlock, appTfLabel: string, ctx: FromTfContext): NormalizedApprovalChain;
|
|
@@ -5,7 +5,7 @@ import { fieldKeyFromTfRef } from "../field/from-tf.js";
|
|
|
5
5
|
import { APPROVAL_PROCESS_RESOURCE_TYPE } from "./module.js";
|
|
6
6
|
const KNOWN = new Set(["id", "app_id", "name", "stage_id", "number_of_dynamic_approvers", "locked_field_ids", "managed_by_automation", "approve_button_text", "deny_button_text", "exception_button_text", "default_reason", "approval_summary"]);
|
|
7
7
|
function stringAttr(attrs, key) { return typeof attrs[key] === "string" ? attrs[key] : undefined; }
|
|
8
|
-
export function approvalChainFromTf(block, appTfLabel,
|
|
8
|
+
export function approvalChainFromTf(block, appTfLabel, ctx) {
|
|
9
9
|
if (block.type !== APPROVAL_PROCESS_RESOURCE_TYPE || block.label === undefined)
|
|
10
10
|
throw new EntityTfError(`expected ${APPROVAL_PROCESS_RESOURCE_TYPE}`);
|
|
11
11
|
for (const key of Object.keys(block.attrs))
|
|
@@ -40,16 +40,29 @@ export function approvalChainFromTf(block, appTfLabel, _ctx) {
|
|
|
40
40
|
const rawFields = block.attrs["locked_field_ids"];
|
|
41
41
|
if (rawFields !== undefined && !Array.isArray(rawFields))
|
|
42
42
|
throw new EntityTfError(`${block.type}.${block.label}: locked_field_ids must be a list`);
|
|
43
|
-
const lockedFields =
|
|
43
|
+
const lockedFields = [];
|
|
44
|
+
const unsafeLockedFieldIds = [];
|
|
45
|
+
for (const value of rawFields ?? []) {
|
|
46
|
+
// Keep literal IDs literal even when state can identify the corresponding
|
|
47
|
+
// system field. Export deliberately avoids the owning app's computed
|
|
48
|
+
// `*_field_id` locals because they can be null during fresh import.
|
|
44
49
|
const key = fieldKeyFromTfRef(value, appTfLabel, "app");
|
|
45
|
-
if (key
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
50
|
+
if (key !== undefined) {
|
|
51
|
+
lockedFields.push(key);
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
if (typeof value === "string" && value.trim() !== "") {
|
|
55
|
+
unsafeLockedFieldIds.push(value);
|
|
56
|
+
ctx.diagnostics.push(`${block.type}.${block.label}: locked field ${value} could not be resolved to a portable field reference; preserved with unsafePlatformId`);
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
throw new EntityTfError(`${block.type}.${block.label}: locked field is not a local field reference or platform id`);
|
|
60
|
+
}
|
|
49
61
|
return {
|
|
50
62
|
refName: scopedLabelToBagKey(appTfLabel, block.label, "app"), name,
|
|
51
63
|
...(stage !== undefined && { stage }), ...(stageId !== undefined && { stageId }),
|
|
52
|
-
numberOfDynamicApprovers: count, managedByAutomation: managed, denyButton: deny, approveButton: approve,
|
|
64
|
+
numberOfDynamicApprovers: count, managedByAutomation: managed, denyButton: deny, approveButton: approve,
|
|
65
|
+
lockedFields, unsafeLockedFieldIds,
|
|
53
66
|
...(stringAttr(block.attrs, "exception_button_text") !== undefined && { exceptionButton: stringAttr(block.attrs, "exception_button_text") }),
|
|
54
67
|
...(stringAttr(block.attrs, "default_reason") !== undefined && { defaultReason: stringAttr(block.attrs, "default_reason") }),
|
|
55
68
|
...(stringAttr(block.attrs, "approval_summary") !== undefined && { summary: stringAttr(block.attrs, "approval_summary") }),
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
const safe = (value) => /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(value) ? value : JSON.stringify(value);
|
|
2
2
|
export function printApprovalChain(chain, appRefName) {
|
|
3
3
|
const imports = ["approvalProcess", ...(chain.stageId !== undefined ? ["unsafeApprovalStageId"] : [])];
|
|
4
|
-
const
|
|
4
|
+
const unsafeLockedFieldIds = chain.unsafeLockedFieldIds ?? [];
|
|
5
|
+
const lines = [
|
|
6
|
+
`import { ${imports.join(", ")} } from "@elementumai/edk/approvalProcesses";`,
|
|
7
|
+
...(unsafeLockedFieldIds.length > 0
|
|
8
|
+
? [`import { unsafePlatformId } from "@elementumai/edk/core";`]
|
|
9
|
+
: []),
|
|
10
|
+
`import catalog from "@catalog";`,
|
|
11
|
+
];
|
|
12
|
+
const lockedFields = [
|
|
13
|
+
...[...chain.lockedFields].sort().map((key) => `catalog.${safe(appRefName)}.fields.${safe(key)}`),
|
|
14
|
+
...[...unsafeLockedFieldIds].sort().map((id) => `unsafePlatformId(${JSON.stringify(id)})`),
|
|
15
|
+
];
|
|
5
16
|
const props = [
|
|
6
17
|
`app: catalog.${safe(appRefName)}`,
|
|
7
18
|
`name: ${JSON.stringify(chain.name)}`,
|
|
@@ -14,7 +25,7 @@ export function printApprovalChain(chain, appRefName) {
|
|
|
14
25
|
...(chain.exceptionButton !== undefined ? [`exceptionButton: ${JSON.stringify(chain.exceptionButton)}`] : []),
|
|
15
26
|
...(chain.defaultReason !== undefined ? [`defaultReason: ${JSON.stringify(chain.defaultReason)}`] : []),
|
|
16
27
|
...(chain.summary !== undefined ? [`summary: ${JSON.stringify(chain.summary)}`] : []),
|
|
17
|
-
...(
|
|
28
|
+
...(lockedFields.length > 0 ? [`lockedFields: [${lockedFields.join(", ")}]`] : []),
|
|
18
29
|
];
|
|
19
30
|
lines.push(``, `export default approvalProcess({`, ...props.map((prop) => ` ${prop},`), `});`, ``);
|
|
20
31
|
return lines.join("\n");
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isUnsafePlatformId } from "../../core/platform-id.js";
|
|
1
2
|
import { EntityTfError } from "../../engine/entity.js";
|
|
2
3
|
import { appScopedResourceLabel, expr, tsLabelToTfLabel } from "../../engine/tf/index.js";
|
|
3
4
|
import { APP_RESOURCE_TYPE } from "../app/module.js";
|
|
@@ -30,6 +31,8 @@ export function approvalChainToTf(entity, ctx) {
|
|
|
30
31
|
attrs["approval_summary"] = payload.summary;
|
|
31
32
|
if (payload.lockedFieldIds !== undefined) {
|
|
32
33
|
attrs["locked_field_ids"] = payload.lockedFieldIds.map((field) => {
|
|
34
|
+
if (isUnsafePlatformId(field))
|
|
35
|
+
return field.value;
|
|
33
36
|
if (field.parent !== undefined && field.parent !== "" && field.parent !== ctx.appRefName)
|
|
34
37
|
throw new EntityTfError(`approval chain ${entity.refName}: locked field belongs to ${field.parent}`);
|
|
35
38
|
const value = fieldRefToTfValue(field.fieldType ?? "", field.refName ?? "", ctx.appTfLabel);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { AppOrElementRef, AutomationCatalogRef } from "../../catalog/index.js";
|
|
1
|
+
import type { AppOrElementOrTaskRef, AppOrElementRef, AutomationCatalogRef } from "../../catalog/index.js";
|
|
2
2
|
import { type DeployableEntity, type EntityDeployOptions, type RecordFieldContext } from "../../engine/entity.js";
|
|
3
3
|
import type { RecordShape } from "../field/record-shape.js";
|
|
4
4
|
import type { ServiceAccountRef } from "../service-account/ref.js";
|
|
5
5
|
import { type Context, type ForEachItem } from "../shared/context.js";
|
|
6
6
|
import { type Ref, type Simplify, type ValueOrRef } from "../shared/ref.js";
|
|
7
7
|
import type { Filter } from "./filter.js";
|
|
8
|
-
import { type ScriptInput } from "./script-code.js";
|
|
8
|
+
import { type ScriptFile, type ScriptInput } from "./script-code.js";
|
|
9
9
|
import type { ScriptOutputs } from "./tasks.js";
|
|
10
10
|
/** Structural empty object — neutral element for the accumulated action map. */
|
|
11
11
|
type EmptyObject = {
|
|
@@ -173,7 +173,7 @@ interface ActionMethods<TTrigger, TActions extends Record<string, unknown>, TVar
|
|
|
173
173
|
*/
|
|
174
174
|
executeScript<TName extends string, I extends Record<string, ValueOrRef<unknown>>, R extends Record<string, unknown> = Record<string, unknown>>(name: TName, opts: {
|
|
175
175
|
readonly inputs?: (ctx: NestedActionContext<TTrigger, TActions, TVars, TItem>) => I;
|
|
176
|
-
readonly code: (input: ScriptInput<ResolvedRefs<NoInfer<I>>>) => R;
|
|
176
|
+
readonly code: ((input: ScriptInput<ResolvedRefs<NoInfer<I>>>) => R) | ScriptFile;
|
|
177
177
|
/**
|
|
178
178
|
* Override the inferred output schema: property name → scalar type or a
|
|
179
179
|
* recursive `{ type: "array", items }` / `{ type: "object", properties }`
|
|
@@ -204,13 +204,13 @@ interface ActionMethods<TTrigger, TActions extends Record<string, unknown>, TVar
|
|
|
204
204
|
readonly type?: TType;
|
|
205
205
|
}, displayName?: string, hclParent?: "trigger" | string): FluentActionBuilder<TMode, TItem, TTrigger, Simplify<TActions & Record<TName, Record<string, never>>>, Simplify<TVars & Record<TName, VariableValueOf<TType>>>>;
|
|
206
206
|
setVariable<TName extends string>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").SetVariableOptions>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, EmptyObject>;
|
|
207
|
-
recordSearch<TName extends string, A extends
|
|
207
|
+
recordSearch<TName extends string, A extends AppOrElementOrTaskRef>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").RecordSearchOptions<A>>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, import("./tasks.js").RecordSearchOutput<A>>;
|
|
208
208
|
tableRecordsSearch<TName extends string, A extends AppOrElementRef = AppOrElementRef>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").TableRecordsSearchOptions<A>>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, import("./tasks.js").TableRecordsSearchOutput<A>>;
|
|
209
|
-
createRecord<TName extends string, A extends
|
|
210
|
-
updateField<TName extends string, A extends
|
|
209
|
+
createRecord<TName extends string, A extends AppOrElementOrTaskRef>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").CreateRecordOptions<A>>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, import("./tasks.js").CreateRecordOutput<A>>;
|
|
210
|
+
updateField<TName extends string, A extends AppOrElementOrTaskRef, const Fields extends readonly import("./tasks.js").FieldAssignment[]>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").UpdateFieldOptions<A, Fields>>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, {
|
|
211
211
|
record: RecordShape<A>;
|
|
212
212
|
}>;
|
|
213
|
-
findRelatedRecords<TName extends string, A extends
|
|
213
|
+
findRelatedRecords<TName extends string, A extends AppOrElementOrTaskRef>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").FindRelatedRecordsOptions<A>>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, import("./tasks.js").FindRelatedRecordsOutput<A>>;
|
|
214
214
|
relateRecords<TName extends string>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").RelateRecordsOptions>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, EmptyObject>;
|
|
215
215
|
sendEmail<TName extends string>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").SendEmailOptions>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, EmptyObject>;
|
|
216
216
|
postComment<TName extends string>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").PostCommentOptions>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, EmptyObject>;
|
|
@@ -32,7 +32,7 @@ import { buildContext, createForEachItemProxy } from "../shared/context.js";
|
|
|
32
32
|
import { outputFieldTypesFromScriptSchema } from "./output-field-types.js";
|
|
33
33
|
import { isRef } from "../shared/ref.js";
|
|
34
34
|
import { API_TASK_REF_WIRE_NAMES, OUTPUT_KEY_WIRE_NAME } from "./output-key-wire-name.js";
|
|
35
|
-
import { extractScriptBody, inferOutputSchema, tryExtractFromCurrentSource } from "./script-code.js";
|
|
35
|
+
import { extractScriptBody, inferOutputSchema, isScriptFile, readScriptFile, tryExtractFromCurrentSource } from "./script-code.js";
|
|
36
36
|
import { serializeNode } from "./serialize.js";
|
|
37
37
|
// Runtime factory imports stay below the public action-native surface. Their
|
|
38
38
|
// ActionDef return values are an internal serialization detail; authored
|
|
@@ -430,7 +430,11 @@ function makeActionBuilder(state, mode = "root", item) {
|
|
|
430
430
|
// and suppresses inference (pulled sources with no platform
|
|
431
431
|
// output_schema print this, so adopted no-schema scripts do not
|
|
432
432
|
// drift); omitting `outputs` entirely infers from the body.
|
|
433
|
-
|
|
433
|
+
// A `scriptFile(...)` reference IS the exact text (no source scan, no
|
|
434
|
+
// toString(), no closure hazard: it is never a JS closure).
|
|
435
|
+
const body = isScriptFile(opts.code)
|
|
436
|
+
? readScriptFile(opts.code)
|
|
437
|
+
: tryExtractFromCurrentSource(name) ?? extractScriptBody(opts.code);
|
|
434
438
|
const outputs = opts.outputs === undefined ? inferOutputSchema(body) : (opts.outputs ?? undefined);
|
|
435
439
|
const def = actionFactories.executeScriptActionDefWithBody(body, {
|
|
436
440
|
...(opts.inputs !== undefined ? { inputs: opts.inputs(context()) } : {}),
|
|
@@ -53,6 +53,13 @@ export declare function extractAuthoredAutomationDescription(source: string): st
|
|
|
53
53
|
export declare function preserveAuthoredAutomationDescription(freshSource: string, existingSource: string): string;
|
|
54
54
|
/** Pull merge: preserve authored revision + description across live reprint. */
|
|
55
55
|
export declare function preserveAuthoredAutomationPullMeta(freshSource: string, existingSource: string): string;
|
|
56
|
+
/** A plain-JS script file printed beside the automation, relative to the automations folder. */
|
|
57
|
+
export interface PrintedScriptFile {
|
|
58
|
+
readonly path: string;
|
|
59
|
+
readonly content: string;
|
|
60
|
+
}
|
|
61
|
+
/** Folder (inside the automations folder) that holds printed script files. */
|
|
62
|
+
export declare const SCRIPT_FILES_DIR = "scripts";
|
|
56
63
|
export interface PrintAutomationV2Options {
|
|
57
64
|
readonly refName?: string;
|
|
58
65
|
/**
|
|
@@ -69,6 +76,7 @@ export interface PrintAutomationV2Options {
|
|
|
69
76
|
*/
|
|
70
77
|
readonly foreignAppRefNames?: ReadonlyMap<string, string>;
|
|
71
78
|
readonly foreignElementRefNames?: ReadonlyMap<string, string>;
|
|
79
|
+
readonly foreignTaskRefNames?: ReadonlyMap<string, string>;
|
|
72
80
|
/** Diagnostics emitted by the bridge for raw UUIDs retained in this pull. */
|
|
73
81
|
readonly unresolvedReferences?: readonly UnresolvedReferenceDiagnostic[];
|
|
74
82
|
}
|
|
@@ -77,3 +85,14 @@ export interface PrintAutomationV2Options {
|
|
|
77
85
|
* printer's `printAutomationFinalized` convention.
|
|
78
86
|
*/
|
|
79
87
|
export declare function printAutomationV2(ast: AutomationAst, opts?: PrintAutomationV2Options): string;
|
|
88
|
+
/**
|
|
89
|
+
* Like {@link printAutomationV2}, but `executeScript` bodies print as
|
|
90
|
+
* `scriptFile("./scripts/<automation>.<task>.js")` references and the bodies
|
|
91
|
+
* come back as files to write beside the automation (relative to the
|
|
92
|
+
* automations folder). The bodies never enter the TypeScript source, so they
|
|
93
|
+
* are never type-checked, annotated or type-stripped.
|
|
94
|
+
*/
|
|
95
|
+
export declare function printAutomationV2WithScriptFiles(ast: AutomationAst, opts?: PrintAutomationV2Options): {
|
|
96
|
+
readonly source: string;
|
|
97
|
+
readonly scriptFiles: readonly PrintedScriptFile[];
|
|
98
|
+
};
|