@elementumai/edk 0.10.1 → 0.10.3
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 +7 -7
- package/dist-sdk/src/catalog/org.d.ts +7 -5
- package/dist-sdk/src/catalog/org.js +14 -9
- package/dist-sdk/src/catalog/token.js +4 -0
- package/dist-sdk/src/core/types/app.d.ts +22 -0
- package/dist-sdk/src/engine/build/context.d.ts +8 -0
- package/dist-sdk/src/engine/build/source-context.d.ts +3 -4
- 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/state.d.ts +48 -0
- package/dist-sdk/src/engine/ei/state.js +91 -0
- package/dist-sdk/src/engine/pull/authored-address.d.ts +100 -0
- package/dist-sdk/src/engine/pull/authored-address.js +360 -0
- package/dist-sdk/src/engine/pull/context.d.ts +59 -0
- package/dist-sdk/src/engine/tf/expr.d.ts +7 -0
- package/dist-sdk/src/engine/tf/expr.js +62 -18
- package/dist-sdk/src/engine/tf/index.d.ts +1 -1
- package/dist-sdk/src/engine/tf/index.js +1 -1
- package/dist-sdk/src/engine/tf/labels.d.ts +10 -2
- package/dist-sdk/src/engine/tf/labels.js +15 -2
- package/dist-sdk/src/engine/tf/parse.js +19 -6
- package/dist-sdk/src/engine/workspace/backend.d.ts +34 -0
- package/dist-sdk/src/engine/workspace/backend.js +104 -0
- package/dist-sdk/src/engine/workspace/generated-file.d.ts +3 -0
- package/dist-sdk/src/engine/workspace/generated-file.js +6 -0
- package/dist-sdk/src/engine/workspace/loader.js +2 -2
- package/dist-sdk/src/entities/agent-tool/to-tf.js +1 -1
- package/dist-sdk/src/entities/app/build.d.ts +36 -4
- package/dist-sdk/src/entities/app/build.js +67 -4
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +12 -0
- package/dist-sdk/src/entities/app/from-tf.js +13 -9
- package/dist-sdk/src/entities/app/module.js +3 -1
- package/dist-sdk/src/entities/app/stage-keys.d.ts +82 -0
- package/dist-sdk/src/entities/app/stage-keys.js +160 -0
- package/dist-sdk/src/entities/app/to-tf.js +21 -21
- package/dist-sdk/src/entities/approval-chain/from-tf.d.ts +9 -1
- package/dist-sdk/src/entities/approval-chain/from-tf.js +31 -3
- package/dist-sdk/src/entities/approval-chain/module.js +12 -4
- package/dist-sdk/src/entities/approval-chain/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/approval-chain/to-tf.js +6 -1
- package/dist-sdk/src/entities/automation/build.d.ts +2 -0
- package/dist-sdk/src/entities/automation/build.js +25 -17
- package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +3 -0
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +5 -3
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +127 -31
- package/dist-sdk/src/entities/automation/from-tf.d.ts +28 -6
- package/dist-sdk/src/entities/automation/from-tf.js +172 -27
- package/dist-sdk/src/entities/automation/module.js +123 -37
- package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +21 -0
- package/dist-sdk/src/entities/automation/output-key-wire-name.js +38 -0
- package/dist-sdk/src/entities/automation/to-tf.d.ts +3 -1
- package/dist-sdk/src/entities/automation/to-tf.js +191 -33
- package/dist-sdk/src/entities/automation/triggers.d.ts +2 -0
- package/dist-sdk/src/entities/automation/triggers.js +1 -0
- package/dist-sdk/src/entities/chart/from-tf.d.ts +6 -0
- package/dist-sdk/src/entities/chart/from-tf.js +9 -1
- package/dist-sdk/src/entities/dashboard/from-tf.js +51 -4
- package/dist-sdk/src/entities/dynamic-layout/from-tf.d.ts +3 -0
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +48 -4
- package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +7 -2
- package/dist-sdk/src/entities/element/build.js +1 -1
- package/dist-sdk/src/entities/element/from-tf.d.ts +12 -6
- package/dist-sdk/src/entities/element/from-tf.js +23 -7
- package/dist-sdk/src/entities/element/module.js +5 -3
- package/dist-sdk/src/entities/element/to-tf.d.ts +3 -2
- package/dist-sdk/src/entities/element/to-tf.js +36 -25
- package/dist-sdk/src/entities/field/allow-list.d.ts +18 -0
- package/dist-sdk/src/entities/field/allow-list.js +42 -0
- package/dist-sdk/src/entities/field/build.d.ts +38 -3
- package/dist-sdk/src/entities/field/build.js +7 -2
- package/dist-sdk/src/entities/field/from-tf.js +252 -76
- package/dist-sdk/src/entities/field/module.d.ts +6 -0
- package/dist-sdk/src/entities/field/module.js +24 -2
- package/dist-sdk/src/entities/field/options.d.ts +2 -0
- package/dist-sdk/src/entities/field/order.d.ts +25 -0
- package/dist-sdk/src/entities/field/order.js +74 -0
- package/dist-sdk/src/entities/field/to-tf.d.ts +6 -0
- package/dist-sdk/src/entities/field/to-tf.js +87 -0
- package/dist-sdk/src/entities/field/types.d.ts +5 -0
- package/dist-sdk/src/entities/field/types.js +8 -0
- package/dist-sdk/src/entities/relationship/build.d.ts +3 -3
- package/dist-sdk/src/entities/relationship/from-tf.js +4 -2
- package/dist-sdk/src/entities/relationship/to-tf.js +3 -1
- package/dist-sdk/src/entities/service-account/workspace-owner.d.ts +8 -3
- package/dist-sdk/src/entities/service-account/workspace-owner.js +12 -4
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +5 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +13 -0
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +7 -0
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +1 -1
- package/dist-sdk/src/entities/skill/to-tf.js +19 -14
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/skill-tool/from-tf.js +3 -0
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +6 -1
- package/dist-sdk/src/entities/skill-tool/to-tf.js +6 -1
- package/dist-sdk/src/entities/task/build.js +1 -1
- package/dist-sdk/src/entities/task/module.js +2 -1
- package/dist-sdk/src/entities/task/to-tf.js +4 -0
- package/dist-sdk/src/entities/view/agent-view-layout-to-tf.d.ts +11 -0
- package/dist-sdk/src/entities/view/agent-view-layout-to-tf.js +13 -38
- package/dist-sdk/src/entities/view/custom-view-validate.d.ts +29 -0
- package/dist-sdk/src/entities/view/custom-view-validate.js +292 -0
- package/dist-sdk/src/entities/view/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/view/from-tf.js +40 -6
- package/dist-sdk/src/entities/view/module.js +4 -1
- package/dist-sdk/src/entities/view/to-tf.d.ts +6 -0
- package/dist-sdk/src/entities/view/to-tf.js +25 -9
- package/dist-sdk/src/entities/view/types.d.ts +6 -0
- package/dist-sdk/src/entities/view/types.js +6 -0
- package/dist-sdk/src/entities/visual-flow/from-tf.d.ts +2 -1
- package/dist-sdk/src/entities/visual-flow/from-tf.js +11 -2
- package/dist-sdk/src/entities/visual-flow/module.js +15 -5
- package/dist-sdk/src/entities/visual-flow/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/visual-flow/to-tf.js +1 -1
- package/dist-sdk/src/entities/widget/build.d.ts +8 -1
- package/dist-sdk/src/entities/widget/from-tf.js +12 -6
- package/dist-sdk/src/entities/widget/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/widget/to-tf.js +16 -0
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +8 -2
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
- package/dist-sdk/src/graph/index.d.ts +9 -2
- package/dist-sdk/src/graph/index.js +4 -0
- package/dist-sdk/src/graph/modules.js +2 -1
- package/dist-sdk/src/graph/types.d.ts +72 -3
- package/package.json +2 -17
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type FromTfContext } from "../../engine/pull/context.js";
|
|
2
2
|
import { type ChildResourceScope, type TfBlock } from "../../engine/tf/index.js";
|
|
3
3
|
import type { NormalizedDynamicLayout } from "../app/deserializer/normalize.js";
|
|
4
|
+
import { type StageHandleIndex } from "../app/stage-keys.js";
|
|
4
5
|
export interface DynamicLayoutOwner {
|
|
5
6
|
readonly type: string;
|
|
6
7
|
readonly label: string;
|
|
@@ -8,6 +9,8 @@ export interface DynamicLayoutOwner {
|
|
|
8
9
|
readonly ownerTfLabel: string;
|
|
9
10
|
/** Owning stream root kind; defaults to `"app"`. */
|
|
10
11
|
readonly scope?: ChildResourceScope;
|
|
12
|
+
/** The owning app's stage handles, so pull never writes another stage's handle (#1136). */
|
|
13
|
+
readonly stageHandles?: StageHandleIndex;
|
|
11
14
|
}
|
|
12
15
|
export declare function dynamicLayoutsFromTf(blocks: readonly TfBlock[], owner: DynamicLayoutOwner, ctx: FromTfContext): NormalizedDynamicLayout[];
|
|
13
16
|
/**
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { dataRefLabel, optionalString, plainObject, resourceRefLabel } from "../../engine/pull/context.js";
|
|
2
|
-
import { isTfExpr,
|
|
2
|
+
import { isTfExpr, scopedLabelToBagKey, tfLabelToTsLabel, } from "../../engine/tf/index.js";
|
|
3
3
|
import { filterFromTf } from "../access-policy/from-tf.js";
|
|
4
4
|
import { fieldKeyFromTfValue } from "../field/from-tf.js";
|
|
5
5
|
import { filterOwnerForAspect } from "../relationship/from-tf.js";
|
|
6
6
|
import { filterWireToTf } from "../shared/filters/tf-codec.js";
|
|
7
7
|
import { resolveDataAspectTarget } from "../shared/aspect-target-from-tf.js";
|
|
8
8
|
import { WIDGET_RESOURCE_TYPE } from "../widget/module.js";
|
|
9
|
+
import { lostStageMessage, pulledStageHandle } from "../app/stage-keys.js";
|
|
9
10
|
import { DYNAMIC_LAYOUT_RESOURCE_TYPE } from "./module.js";
|
|
10
11
|
import { DYNAMIC_LAYOUT_COMPARISON_KEYS, DYNAMIC_LAYOUT_FIELD_COMPONENT_WIRE_KEY_BY_PUBLIC_KEY, dynamicLayoutCompanionWidgetLabel, } from "./dialect.js";
|
|
11
12
|
const KNOWN_ATTRS = new Set([
|
|
@@ -35,6 +36,9 @@ export function dynamicLayoutCompanionWidgetLabels(blocks, owner) {
|
|
|
35
36
|
const components = plainObject(block.attrs["components"]);
|
|
36
37
|
if (components === undefined)
|
|
37
38
|
continue;
|
|
39
|
+
// A layout left unmanaged (#1136) derives no companions: its widgets stay authored source.
|
|
40
|
+
if (lostStageRefs(block, owner, "").length > 0)
|
|
41
|
+
continue;
|
|
38
42
|
const layoutKey = scopedLabelToBagKey(owner.ownerTfLabel, block.label ?? "", scopeOf(owner));
|
|
39
43
|
for (const [componentId, raw] of Object.entries(components)) {
|
|
40
44
|
const component = plainObject(raw);
|
|
@@ -65,6 +69,18 @@ function dynamicLayoutFromTf(block, owner, ctx) {
|
|
|
65
69
|
ctx.diagnostics.push(`${where}: components is not an object; skipped`);
|
|
66
70
|
return undefined;
|
|
67
71
|
}
|
|
72
|
+
// A stage reference whose only handle is another stage's own key would
|
|
73
|
+
// bind to that stage on build. Keep the whole layout unmanaged instead,
|
|
74
|
+
// warning once per reference (#1136).
|
|
75
|
+
const lost = lostStageRefs(block, owner, where);
|
|
76
|
+
if (lost.length > 0) {
|
|
77
|
+
for (const ref of lost)
|
|
78
|
+
ctx.diagnostics.push(lostStageMessage(ref.where, ref.index, ref, "the dynamic layout is left unmanaged"));
|
|
79
|
+
ctx.skipped.push(`${DYNAMIC_LAYOUT_RESOURCE_TYPE}.${block.label ?? ""}`);
|
|
80
|
+
// Never authorable, so release an earlier adoption rather than destroy it.
|
|
81
|
+
ctx.releaseIfManaged?.push(`${DYNAMIC_LAYOUT_RESOURCE_TYPE}.${block.label ?? ""}`);
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
68
84
|
const resolvedStageKey = stageKey(block.attrs["stage_id"], owner, ctx, `${where}.stage_id`);
|
|
69
85
|
if (block.attrs["stage_id"] !== undefined && stageIndex(block.attrs["stage_id"], owner) === undefined) {
|
|
70
86
|
ctx.diagnostics.push(`${where}: stage_id has an unrecognized shape; layout kept unscoped instead of guessing`);
|
|
@@ -382,11 +398,39 @@ function fieldKey(value, owner, ctx, where) {
|
|
|
382
398
|
}
|
|
383
399
|
return key;
|
|
384
400
|
}
|
|
401
|
+
/** Every stage reference of a dynamic layout that has no handle of its own (see `pulledStageHandle`). */
|
|
402
|
+
function lostStageRefs(block, owner, where) {
|
|
403
|
+
if (owner.stageHandles === undefined)
|
|
404
|
+
return [];
|
|
405
|
+
const refs = [{ where: `${where}.stage_id`, value: block.attrs["stage_id"] }];
|
|
406
|
+
for (const [id, raw] of Object.entries(plainObject(block.attrs["conditions"]) ?? {})) {
|
|
407
|
+
const condition = plainObject(raw);
|
|
408
|
+
const stage = condition?.["stage"] === undefined ? undefined : plainObject(condition["stage"]);
|
|
409
|
+
if (stage !== undefined)
|
|
410
|
+
refs.push({ where: `${where}.conditions.${id}.stage`, value: stage["stage_id"] });
|
|
411
|
+
}
|
|
412
|
+
const lost = [];
|
|
413
|
+
for (const ref of refs) {
|
|
414
|
+
const index = stageIndex(ref.value, owner);
|
|
415
|
+
if (index === undefined)
|
|
416
|
+
continue;
|
|
417
|
+
const pulled = pulledStageHandle(index, owner.stageHandles);
|
|
418
|
+
if (pulled.kind === "lost")
|
|
419
|
+
lost.push({ where: ref.where, index, handle: pulled.handle, owner: pulled.owner });
|
|
420
|
+
}
|
|
421
|
+
return lost;
|
|
422
|
+
}
|
|
385
423
|
function stageKey(value, owner, ctx, where) {
|
|
386
424
|
const index = stageIndex(value, owner);
|
|
387
|
-
if (index === undefined
|
|
388
|
-
return
|
|
389
|
-
|
|
425
|
+
if (index === undefined)
|
|
426
|
+
return undefined;
|
|
427
|
+
// An imported key that keeps punctuation ("pre-approval") pulls as a handle
|
|
428
|
+
// that build maps back to this same stage (#1136). Lost handles are
|
|
429
|
+
// rejected before this runs (`lostStageRefs`).
|
|
430
|
+
const pulled = pulledStageHandle(index, owner.stageHandles);
|
|
431
|
+
if (pulled.kind === "handle")
|
|
432
|
+
return tfLabelToTsLabel(pulled.handle);
|
|
433
|
+
ctx.diagnostics.push(`${where}: stage key ${JSON.stringify(index)} has no terraform label handle; stage dropped`);
|
|
390
434
|
return undefined;
|
|
391
435
|
}
|
|
392
436
|
function stageIndex(value, owner) {
|
|
@@ -28,5 +28,7 @@ export interface DynamicLayoutToTfOptions {
|
|
|
28
28
|
readonly fieldAddresses?: ReadonlyMap<string, string>;
|
|
29
29
|
/** Widget keys the owner declares, for buttons that run through an authored widget. */
|
|
30
30
|
readonly widgetKeys?: ReadonlySet<string>;
|
|
31
|
+
/** Stage handle tfLabel → real `stage_ids_by_key` key, when they differ (#1136). */
|
|
32
|
+
readonly stageKeyByTfLabel?: ReadonlyMap<string, string>;
|
|
31
33
|
}
|
|
32
34
|
export declare function dynamicLayoutsToTf(layouts: Readonly<Record<string, DynamicLayoutWire>> | undefined, opts: DynamicLayoutToTfOptions): TfBlock[];
|
|
@@ -37,7 +37,7 @@ export function dynamicLayoutsToTf(layouts, opts) {
|
|
|
37
37
|
opts.diagnostics.push(`${where}.stage: elements have no stages; omit stage for the element's default DASHBOARD layout; dropped`);
|
|
38
38
|
}
|
|
39
39
|
else if (layout.stage !== undefined) {
|
|
40
|
-
attrs["stage_id"] = expr.local(`${opts.ownerTfLabel}_stage_ids_by_key`, [{ index:
|
|
40
|
+
attrs["stage_id"] = expr.local(`${opts.ownerTfLabel}_stage_ids_by_key`, [{ index: stageIdKey(layout.stage, opts) }]);
|
|
41
41
|
}
|
|
42
42
|
if (layout.conditions !== undefined)
|
|
43
43
|
attrs["conditions"] = conditionMap(layout.conditions, where, opts);
|
|
@@ -357,7 +357,7 @@ function conditionMap(conditions, where, opts) {
|
|
|
357
357
|
const stage = object(value)["stage"];
|
|
358
358
|
if (typeof stage === "string") {
|
|
359
359
|
attrs["stage"] = {
|
|
360
|
-
stage_id: expr.local(`${opts.ownerTfLabel}_stage_ids_by_key`, [{ index:
|
|
360
|
+
stage_id: expr.local(`${opts.ownerTfLabel}_stage_ids_by_key`, [{ index: stageIdKey(stage, opts) }]),
|
|
361
361
|
};
|
|
362
362
|
}
|
|
363
363
|
}
|
|
@@ -546,3 +546,8 @@ function snakeKey(value) {
|
|
|
546
546
|
function object(value) {
|
|
547
547
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : {};
|
|
548
548
|
}
|
|
549
|
+
/** The `stage_ids_by_key` index for a stage handle (imported keys may keep punctuation, #1136). */
|
|
550
|
+
function stageIdKey(stage, opts) {
|
|
551
|
+
const tfLabel = tsLabelToTfLabel(stage);
|
|
552
|
+
return opts.stageKeyByTfLabel?.get(tfLabel) ?? tfLabel;
|
|
553
|
+
}
|
|
@@ -129,7 +129,7 @@ export function element(opts) {
|
|
|
129
129
|
...(opts.systemFields?.audit === true ? { auditFields: true } : {}),
|
|
130
130
|
fields: [
|
|
131
131
|
...serializeElementSystemFields(opts.systemFields),
|
|
132
|
-
...Object.entries(opts.fields).map(([bagKey, field]) => serializeField(field, bagKey)),
|
|
132
|
+
...Object.entries(opts.fields).map(([bagKey, field]) => serializeField(field, bagKey, `element ${JSON.stringify(opts.name)}`)),
|
|
133
133
|
],
|
|
134
134
|
...(displayBlocks !== undefined ? { displayBlocks } : {}),
|
|
135
135
|
...(recordCreateDisplayBlocks !== undefined ? { recordCreateDisplayBlocks } : {}),
|
|
@@ -27,13 +27,19 @@ export interface ElementFromTfViewBlocks {
|
|
|
27
27
|
readonly widgetBlocks: readonly TfBlock[];
|
|
28
28
|
}
|
|
29
29
|
export declare function elementFromTf(elementBlock: TfBlock, fieldBlocks: readonly TfBlock[], ctx: FromTfContext, viewBlocks?: ElementFromTfViewBlocks, accessPolicyBlocks?: readonly TfBlock[], roleBlocks?: readonly TfBlock[]): ElementFromTfResult;
|
|
30
|
+
/**
|
|
31
|
+
* Platform ids that pull knows, from state or a live read, to be this
|
|
32
|
+
* element's own audit fields. The export can name them by raw id only, and
|
|
33
|
+
* pull then prints them as typed audit refs (#1704).
|
|
34
|
+
*/
|
|
35
|
+
export declare function elementAuditFieldIds(refName: string, ctx: Pick<FromTfContext, "foreignFieldRefsById">): ReadonlySet<string>;
|
|
30
36
|
/**
|
|
31
37
|
* The export references an element's audit fields only when the platform
|
|
32
38
|
* gave it those fields, which EDK cannot otherwise observe: through its
|
|
33
|
-
* `<label>_(created|updated)_(at|by)_field_id` locals,
|
|
34
|
-
*
|
|
35
|
-
* blocks are skipped by callers:
|
|
36
|
-
*
|
|
37
|
-
* heuristics.
|
|
39
|
+
* `<label>_(created|updated)_(at|by)_field_id` locals, by the raw id of one
|
|
40
|
+
* of them (`auditFieldIds`), or, in the element's own automations, through a
|
|
41
|
+
* trigger's Created/Updated outputs. Locals blocks are skipped by callers:
|
|
42
|
+
* `ei` defines those locals on every element. An authored field with the
|
|
43
|
+
* same display name wins over trigger-output heuristics.
|
|
38
44
|
*/
|
|
39
|
-
export declare function referencesElementAuditFields(label: string, blocks: readonly TfBlock[], authoredFieldNames?: ReadonlySet<string>): boolean;
|
|
45
|
+
export declare function referencesElementAuditFields(label: string, blocks: readonly TfBlock[], authoredFieldNames?: ReadonlySet<string>, auditFieldIds?: ReadonlySet<string>): boolean;
|
|
@@ -176,7 +176,7 @@ export function elementFromTf(elementBlock, fieldBlocks, ctx, viewBlocks = {
|
|
|
176
176
|
...Object.values(viewBlocks).flatMap((blocks) => blocks ?? []),
|
|
177
177
|
...accessPolicyBlocks,
|
|
178
178
|
...roleBlocks,
|
|
179
|
-
], new Set(fields.map(({ field }) => field.name.toLowerCase())));
|
|
179
|
+
], new Set(fields.map(({ field }) => field.name.toLowerCase())), elementAuditFieldIds(refName, ctx));
|
|
180
180
|
const element = {
|
|
181
181
|
id: elementId ?? "",
|
|
182
182
|
name,
|
|
@@ -217,21 +217,37 @@ function systemEntry(key, name, type, tag, description) {
|
|
|
217
217
|
return { key, field: { id: "", name, type, tags: [tag], ...(description !== undefined && { description }) } };
|
|
218
218
|
}
|
|
219
219
|
const AUDIT_TRIGGER_REF_NAME = /^(?:Created|Updated) (?:At|On|By)\b/i;
|
|
220
|
+
const AUDIT_FIELD_KEYS = new Set(["createdAt", "createdBy", "updatedAt", "updatedBy"]);
|
|
221
|
+
/**
|
|
222
|
+
* Platform ids that pull knows, from state or a live read, to be this
|
|
223
|
+
* element's own audit fields. The export can name them by raw id only, and
|
|
224
|
+
* pull then prints them as typed audit refs (#1704).
|
|
225
|
+
*/
|
|
226
|
+
export function elementAuditFieldIds(refName, ctx) {
|
|
227
|
+
const ids = new Set();
|
|
228
|
+
for (const [id, ref] of ctx.foreignFieldRefsById ?? []) {
|
|
229
|
+
if (ref.ownerRefName === refName && AUDIT_FIELD_KEYS.has(ref.fieldKey))
|
|
230
|
+
ids.add(id);
|
|
231
|
+
}
|
|
232
|
+
return ids;
|
|
233
|
+
}
|
|
220
234
|
/**
|
|
221
235
|
* The export references an element's audit fields only when the platform
|
|
222
236
|
* gave it those fields, which EDK cannot otherwise observe: through its
|
|
223
|
-
* `<label>_(created|updated)_(at|by)_field_id` locals,
|
|
224
|
-
*
|
|
225
|
-
* blocks are skipped by callers:
|
|
226
|
-
*
|
|
227
|
-
* heuristics.
|
|
237
|
+
* `<label>_(created|updated)_(at|by)_field_id` locals, by the raw id of one
|
|
238
|
+
* of them (`auditFieldIds`), or, in the element's own automations, through a
|
|
239
|
+
* trigger's Created/Updated outputs. Locals blocks are skipped by callers:
|
|
240
|
+
* `ei` defines those locals on every element. An authored field with the
|
|
241
|
+
* same display name wins over trigger-output heuristics.
|
|
228
242
|
*/
|
|
229
|
-
export function referencesElementAuditFields(label, blocks, authoredFieldNames = new Set()) {
|
|
243
|
+
export function referencesElementAuditFields(label, blocks, authoredFieldNames = new Set(), auditFieldIds = new Set()) {
|
|
230
244
|
const auditLocal = new RegExp(`^${label}_(?:created|updated)_(?:at|by)_field_id$`);
|
|
231
245
|
const ownedTriggers = elementTriggerAddresses(label, blocks);
|
|
232
246
|
const visit = (value) => {
|
|
233
247
|
if (Array.isArray(value))
|
|
234
248
|
return value.some(visit);
|
|
249
|
+
if (typeof value === "string")
|
|
250
|
+
return auditFieldIds.has(value);
|
|
235
251
|
if (typeof value !== "object" || value === null)
|
|
236
252
|
return false;
|
|
237
253
|
const node = value;
|
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
* Offline extract/build and live `edk pull element` (via `ei elements export
|
|
4
4
|
* --directory` with fields/imports/adoption flags).
|
|
5
5
|
*/
|
|
6
|
+
import { inManagedFieldOrder } from "../field/order.js";
|
|
6
7
|
import { NO_CATALOG, } from "../../graph/types.js";
|
|
7
8
|
import { appendFieldLocals } from "../field/locals.js";
|
|
8
9
|
import { CALENDAR_VIEW_RESOURCE_TYPE, CUSTOM_VIEW_RESOURCE_TYPE, DASHBOARD_VIEW_RESOURCE_TYPE, KANBAN_VIEW_RESOURCE_TYPE, LAYOUT_RESOURCE_TYPE, LIST_VIEW_RESOURCE_TYPE } from "../view/types.js";
|
|
9
|
-
import { elementFromTf, referencesElementAuditFields } from "./from-tf.js";
|
|
10
|
+
import { elementAuditFieldIds, elementFromTf, referencesElementAuditFields } from "./from-tf.js";
|
|
10
11
|
import { appendElementLocals } from "./locals.js";
|
|
11
12
|
import { elementToTf } from "./to-tf.js";
|
|
12
13
|
export const ELEMENT_RESOURCE_TYPE = "elementum_element";
|
|
@@ -16,7 +17,7 @@ function extractElementStreamRoot(stream, ctx) {
|
|
|
16
17
|
throw new Error(`expected exactly one ${ELEMENT_RESOURCE_TYPE} resource in the export stream, found ${elementBlocks.length}` +
|
|
17
18
|
(elementBlocks.length > 1 ? " — was this exported with --recursive?" : ""));
|
|
18
19
|
}
|
|
19
|
-
const fieldBlocks = stream.byKind.get("field") ?? [];
|
|
20
|
+
const fieldBlocks = inManagedFieldOrder(stream.byKind.get("field") ?? [], stream.byKind.get("managed-field-order") ?? []);
|
|
20
21
|
const viewBlocks = stream.byKind.get("view") ?? [];
|
|
21
22
|
const layoutBlocks = viewBlocks.filter((b) => b.type === LAYOUT_RESOURCE_TYPE);
|
|
22
23
|
const listViewBlocks = viewBlocks.filter((b) => b.type === LIST_VIEW_RESOURCE_TYPE);
|
|
@@ -51,7 +52,7 @@ function extractElementStreamRoot(stream, ctx) {
|
|
|
51
52
|
// Automations are extracted separately, but their trigger outputs are the
|
|
52
53
|
// only audit reference some elements have.
|
|
53
54
|
const auditFields = element.auditFields === true ||
|
|
54
|
-
referencesElementAuditFields(elementBlocks[0].label ?? "", stream.allResources, new Set(element.fields.map(({ field }) => field.name.toLowerCase())));
|
|
55
|
+
referencesElementAuditFields(elementBlocks[0].label ?? "", stream.allResources, new Set(element.fields.map(({ field }) => field.name.toLowerCase())), elementAuditFieldIds(element.refName, ctx));
|
|
55
56
|
return {
|
|
56
57
|
instance: auditFields && element.auditFields !== true ? { ...element, auditFields } : element,
|
|
57
58
|
...(cloudLinkHandle !== undefined && { cloudLinkHandle }),
|
|
@@ -77,6 +78,7 @@ export const elementModule = {
|
|
|
77
78
|
orgRefs: ctx.orgRefs,
|
|
78
79
|
diagnostics: ctx.diagnostics,
|
|
79
80
|
workspaceAspects: ctx.workspaceAspects,
|
|
81
|
+
...(ctx.outOfScopeApps !== undefined && { outOfScopeApps: ctx.outOfScopeApps }),
|
|
80
82
|
});
|
|
81
83
|
return {
|
|
82
84
|
blocks: result.blocks,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Element emission: `element` DeployableEntity → `elementum_element` +
|
|
3
|
-
* field resources in ei's dialect.
|
|
4
|
-
*
|
|
3
|
+
* field resources in ei's dialect. Elements do not emit app-style
|
|
4
|
+
* `status_options` / stages bags. A custom STATUS dropdown is a normal
|
|
5
|
+
* field resource; STAGE, and STATUS on any other type, stay dropped (#1690).
|
|
5
6
|
*/
|
|
6
7
|
import type { ToTfContext } from "../../engine/build/context.js";
|
|
7
8
|
import { type DeployableEntity } from "../../engine/entity.js";
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Element emission: `element` DeployableEntity → `elementum_element` +
|
|
3
|
-
* field resources in ei's dialect.
|
|
4
|
-
*
|
|
3
|
+
* field resources in ei's dialect. Elements do not emit app-style
|
|
4
|
+
* `status_options` / stages bags. A custom STATUS dropdown is a normal
|
|
5
|
+
* field resource; STAGE, and STATUS on any other type, stay dropped (#1690).
|
|
5
6
|
*/
|
|
7
|
+
import { managedFieldOrderToTf } from "../field/order.js";
|
|
6
8
|
import { autoShareToTf } from "../app/auto-share.js";
|
|
7
9
|
import { EntityTfError } from "../../engine/entity.js";
|
|
8
10
|
import { expr, snakeSlug } from "../../engine/tf/index.js";
|
|
@@ -152,28 +154,32 @@ export function elementToTf(entity, ctx) {
|
|
|
152
154
|
// must resolve against "title", never snakeSlug of a renamed label.
|
|
153
155
|
if (systemKey !== undefined && name !== "")
|
|
154
156
|
fieldNames.set(systemKey, name);
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
157
|
+
// STATUS is allowed only on an element dropdown. STAGE is never a
|
|
158
|
+
// configurable field role. Emit the dropdown; keep the diagnostic for
|
|
159
|
+
// everything else (#1690). TITLE/HANDLE still fold onto the element.
|
|
160
|
+
if (systemTag === "STATUS" && typeKey === "picklist") {
|
|
161
|
+
// fall through to fieldToTf below
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
switch (systemTag) {
|
|
165
|
+
case "TITLE":
|
|
166
|
+
if (name !== "Title")
|
|
167
|
+
elementAttrs["title_field_name"] = name;
|
|
168
|
+
if (inner.description !== undefined)
|
|
169
|
+
elementAttrs["title_field_description"] = inner.description;
|
|
170
|
+
break;
|
|
171
|
+
case "HANDLE":
|
|
172
|
+
if (name !== "ID")
|
|
173
|
+
elementAttrs["id_field_name"] = name;
|
|
174
|
+
if (inner.description !== undefined)
|
|
175
|
+
elementAttrs["id_field_description"] = inner.description;
|
|
176
|
+
break;
|
|
177
|
+
default:
|
|
178
|
+
// Audit fields are provider-managed; nothing to emit.
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
continue;
|
|
175
182
|
}
|
|
176
|
-
continue;
|
|
177
183
|
}
|
|
178
184
|
const field = fieldToTf(typeKey, inner, {
|
|
179
185
|
ownerTfLabel: ctx.appTfLabel,
|
|
@@ -191,6 +197,9 @@ export function elementToTf(entity, ctx) {
|
|
|
191
197
|
blocks.push(field.block);
|
|
192
198
|
fieldAddresses.set(field.bagKey, field.address);
|
|
193
199
|
}
|
|
200
|
+
const fieldOrder = managedFieldOrderToTf(ctx.appTfLabel, "element", objectId, fieldAddresses);
|
|
201
|
+
if (fieldOrder !== undefined)
|
|
202
|
+
blocks.push(fieldOrder);
|
|
194
203
|
blocks.push(...dashboardsToTf(payload.dashboards, {
|
|
195
204
|
ownerTfLabel: ctx.appTfLabel,
|
|
196
205
|
scope: "element",
|
|
@@ -236,6 +245,8 @@ export function elementToTf(entity, ctx) {
|
|
|
236
245
|
workspaceAspects: ctx.workspaceAspects,
|
|
237
246
|
diagnostics: ctx.diagnostics,
|
|
238
247
|
fieldAddresses,
|
|
248
|
+
fieldNames,
|
|
249
|
+
fieldMetadata,
|
|
239
250
|
widgetKeys: new Set(Object.keys(payload.widgets ?? {})),
|
|
240
251
|
}, payload.customViews);
|
|
241
252
|
blocks.push(...viewBlocks);
|
|
@@ -291,7 +302,7 @@ export function elementToTf(entity, ctx) {
|
|
|
291
302
|
// An element has no service accounts of its own. Hand the sibling app's
|
|
292
303
|
// authored bag to the shared resolver so a managed account becomes a
|
|
293
304
|
// direct resource ref and Terraform sequences same-apply creation.
|
|
294
|
-
resolveServiceAccountApp: workspaceServiceAccountAppResolver(ctx.workspaceAspects),
|
|
305
|
+
resolveServiceAccountApp: workspaceServiceAccountAppResolver(ctx.workspaceAspects, { apps: ctx.outOfScopeApps, orgRefs: ctx.orgRefs }),
|
|
295
306
|
});
|
|
296
307
|
blocks.push(block);
|
|
297
308
|
}
|
|
@@ -302,7 +313,7 @@ export function elementToTf(entity, ctx) {
|
|
|
302
313
|
objectId,
|
|
303
314
|
orgRefs: ctx.orgRefs,
|
|
304
315
|
diagnostics: ctx.diagnostics,
|
|
305
|
-
resolveServiceAccountApp: workspaceServiceAccountAppResolver(ctx.workspaceAspects),
|
|
316
|
+
resolveServiceAccountApp: workspaceServiceAccountAppResolver(ctx.workspaceAspects, { apps: ctx.outOfScopeApps, orgRefs: ctx.orgRefs }),
|
|
306
317
|
}));
|
|
307
318
|
blocks.unshift({
|
|
308
319
|
kind: "resource",
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation shared by `groupField`/`userField` and `serializeField` for the
|
|
3
|
+
* pick-list restrictions of group and user fields (edk#1776).
|
|
4
|
+
*/
|
|
5
|
+
/** The slice of an authored field this check reads. */
|
|
6
|
+
export interface AllowListField {
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly allowedGroups?: readonly unknown[];
|
|
9
|
+
readonly allowedUsers?: readonly unknown[];
|
|
10
|
+
readonly parentGroupField?: unknown;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Group/user field pick-list restrictions (edk#1776) accept only portable,
|
|
14
|
+
* typed principals: `org.groups.<key>` groups, `userRef(email)` users, and a
|
|
15
|
+
* same-owner group field ref. Anything else throws: dropping one entry would
|
|
16
|
+
* silently broaden who can be picked.
|
|
17
|
+
*/
|
|
18
|
+
export declare function assertFieldAllowList(field: AllowListField, key: "group" | "user"): void;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation shared by `groupField`/`userField` and `serializeField` for the
|
|
3
|
+
* pick-list restrictions of group and user fields (edk#1776).
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Group/user field pick-list restrictions (edk#1776) accept only portable,
|
|
7
|
+
* typed principals: `org.groups.<key>` groups, `userRef(email)` users, and a
|
|
8
|
+
* same-owner group field ref. Anything else throws: dropping one entry would
|
|
9
|
+
* silently broaden who can be picked.
|
|
10
|
+
*/
|
|
11
|
+
export function assertFieldAllowList(field, key) {
|
|
12
|
+
const where = `${key} field "${field.name}"`;
|
|
13
|
+
if (field.allowedGroups !== undefined) {
|
|
14
|
+
if (!Array.isArray(field.allowedGroups))
|
|
15
|
+
throw new Error(`${where}: allowedGroups must be a list of org.groups references.`);
|
|
16
|
+
for (const group of field.allowedGroups) {
|
|
17
|
+
const g = group;
|
|
18
|
+
if (g === null || typeof g !== "object" || g.__kind !== "group" || typeof g.refName !== "string" || g.refName.trim() === "") {
|
|
19
|
+
throw new Error(`${where}: allowedGroups requires org.groups references; raw ids and other principals are unsupported.`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (key === "group" && (field.allowedUsers !== undefined || field.parentGroupField !== undefined)) {
|
|
24
|
+
throw new Error(`${where}: allowedUsers and parentGroupField are only valid on user fields.`);
|
|
25
|
+
}
|
|
26
|
+
if (field.allowedUsers !== undefined) {
|
|
27
|
+
if (!Array.isArray(field.allowedUsers))
|
|
28
|
+
throw new Error(`${where}: allowedUsers must be a list of userRef(email) references.`);
|
|
29
|
+
for (const user of field.allowedUsers) {
|
|
30
|
+
const u = user;
|
|
31
|
+
if (u === null || typeof u !== "object" || u.__kind !== "user" || typeof u.email !== "string" || !/^[^\s@]+@[^\s@]+$/.test(u.email)) {
|
|
32
|
+
throw new Error(`${where}: allowedUsers requires userRef(email); raw ids and other principals are unsupported.`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (field.parentGroupField !== undefined && field.parentGroupField !== null) {
|
|
37
|
+
const ref = field.parentGroupField;
|
|
38
|
+
if (typeof ref !== "object" || ref.__kind !== "field" || (ref.fieldType !== "GROUP" && ref.fieldType !== "GROUP_ID")) {
|
|
39
|
+
throw new Error(`${where}: parentGroupField must reference a group field on the same app or element (or be null to remove the link).`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
* AppField is accepted.
|
|
19
19
|
*/
|
|
20
20
|
import type { AppField, AppPicklistConfig, PicklistOption } from "../app/build.js";
|
|
21
|
-
import type { AppOrElementOrTaskRef, FieldRef } from "../../catalog/index.js";
|
|
21
|
+
import type { AppOrElementOrTaskRef, FieldRef, GroupRef } from "../../catalog/index.js";
|
|
22
|
+
import type { RoleUserRef } from "../role/build.js";
|
|
22
23
|
import type { AppFieldOfExprType, CalculationInclude, Expr, ExprContext, ExprType, ExprTypeOf, FieldRefOfExprType } from "./calc/types.js";
|
|
23
24
|
import type { UnsafePlatformId } from "../../core/platform-id.js";
|
|
24
25
|
import type { AspectFieldQrFormat, AspectNumericFieldFormat } from "../../../elementum-entity-client/clients/aspects/models/format.js";
|
|
@@ -195,10 +196,44 @@ export declare function dateField(opts: BaseFieldOptions & WithExpression<"date"
|
|
|
195
196
|
export declare function dateTimeField(opts: BaseFieldOptions & WithExpression<"datetime">): AppField & {
|
|
196
197
|
readonly type: "DATETIME";
|
|
197
198
|
};
|
|
198
|
-
|
|
199
|
+
/**
|
|
200
|
+
* Options for `groupField`. `allowedGroups` restricts which groups can be
|
|
201
|
+
* picked (edk#1776):
|
|
202
|
+
*
|
|
203
|
+
* team: groupField({ name: "Team", allowedGroups: [org.groups.engPlatform, org.groups.engInfra] })
|
|
204
|
+
*
|
|
205
|
+
* Fail-closed semantics: a list is applied and read back (a mismatch fails
|
|
206
|
+
* the apply); `[]` removes a live restriction; leaving it out while the live
|
|
207
|
+
* field has a restriction fails the plan (pull to adopt it, or clear it).
|
|
208
|
+
*/
|
|
209
|
+
export interface GroupFieldOptions extends BaseFieldOptions {
|
|
210
|
+
readonly allowedGroups?: readonly GroupRef[];
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Options for `userField`. Restrict the user picker (edk#1776) to members of
|
|
214
|
+
* `allowedGroups`, to `allowedUsers`, or to members of the group selected in
|
|
215
|
+
* a sibling group field (`parentGroupField`):
|
|
216
|
+
*
|
|
217
|
+
* owner: userField({
|
|
218
|
+
* name: "Owner",
|
|
219
|
+
* allowedGroups: [org.groups.eng],
|
|
220
|
+
* allowedUsers: [userRef("lead@example.com")],
|
|
221
|
+
* parentGroupField: teamRef,
|
|
222
|
+
* })
|
|
223
|
+
*
|
|
224
|
+
* Same fail-closed semantics as {@link GroupFieldOptions}: `[]` (or
|
|
225
|
+
* `parentGroupField: null`) removes a live restriction; omitting an option
|
|
226
|
+
* over a live restriction fails the plan.
|
|
227
|
+
*/
|
|
228
|
+
export interface UserFieldOptions extends BaseFieldOptions {
|
|
229
|
+
readonly allowedGroups?: readonly GroupRef[];
|
|
230
|
+
readonly allowedUsers?: readonly RoleUserRef[];
|
|
231
|
+
readonly parentGroupField?: FieldRef<string, string, "GROUP" | "GROUP_ID"> | null;
|
|
232
|
+
}
|
|
233
|
+
export declare function userField(opts: UserFieldOptions & WithExpression<"user">): AppField & {
|
|
199
234
|
readonly type: "USER";
|
|
200
235
|
};
|
|
201
|
-
export declare function groupField(opts:
|
|
236
|
+
export declare function groupField(opts: GroupFieldOptions & WithExpression<"group">): AppField & {
|
|
202
237
|
readonly type: "GROUP";
|
|
203
238
|
};
|
|
204
239
|
export declare function attachmentField(opts: AttachmentFieldOptions & WithExpression<"attachment">): AppField & {
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
* literal form (`{ name, type: "TEXT" }`) remains valid where ever an
|
|
18
18
|
* AppField is accepted.
|
|
19
19
|
*/
|
|
20
|
+
import { assertFieldAllowList } from "./allow-list.js";
|
|
20
21
|
import { assertCalculatedFieldRoot, coerce } from "./calc/runtime.js";
|
|
21
22
|
import { assertAttachmentMediaTypes } from "./media-types.js";
|
|
22
23
|
/** Product-visible rendering modes for dynamically sourced values. */
|
|
@@ -66,10 +67,14 @@ export function dateTimeField(opts) {
|
|
|
66
67
|
return field("DATETIME", opts);
|
|
67
68
|
}
|
|
68
69
|
export function userField(opts) {
|
|
69
|
-
|
|
70
|
+
const built = field("USER", opts);
|
|
71
|
+
assertFieldAllowList(built, "user");
|
|
72
|
+
return built;
|
|
70
73
|
}
|
|
71
74
|
export function groupField(opts) {
|
|
72
|
-
|
|
75
|
+
const built = field("GROUP", opts);
|
|
76
|
+
assertFieldAllowList(built, "group");
|
|
77
|
+
return built;
|
|
73
78
|
}
|
|
74
79
|
export function attachmentField(opts) {
|
|
75
80
|
if (opts.mediaTypes !== undefined)
|