@elementumai/edk 0.10.2 → 0.10.4

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.
Files changed (127) hide show
  1. package/README.md +7 -7
  2. package/dist-sdk/src/catalog/org.d.ts +7 -5
  3. package/dist-sdk/src/catalog/org.js +14 -9
  4. package/dist-sdk/src/catalog/token.js +4 -0
  5. package/dist-sdk/src/core/types/app.d.ts +22 -0
  6. package/dist-sdk/src/engine/build/context.d.ts +8 -0
  7. package/dist-sdk/src/engine/build/source-context.d.ts +3 -4
  8. package/dist-sdk/src/engine/coverage-gaps.d.ts +2 -0
  9. package/dist-sdk/src/engine/coverage-gaps.js +3 -0
  10. package/dist-sdk/src/engine/ei/state.d.ts +48 -0
  11. package/dist-sdk/src/engine/ei/state.js +91 -0
  12. package/dist-sdk/src/engine/pull/authored-address.d.ts +100 -0
  13. package/dist-sdk/src/engine/pull/authored-address.js +360 -0
  14. package/dist-sdk/src/engine/pull/context.d.ts +69 -0
  15. package/dist-sdk/src/engine/tf/expr.d.ts +7 -0
  16. package/dist-sdk/src/engine/tf/expr.js +62 -18
  17. package/dist-sdk/src/engine/tf/index.d.ts +2 -1
  18. package/dist-sdk/src/engine/tf/index.js +2 -1
  19. package/dist-sdk/src/engine/tf/labels.d.ts +10 -2
  20. package/dist-sdk/src/engine/tf/labels.js +15 -2
  21. package/dist-sdk/src/engine/tf/parse.js +19 -6
  22. package/dist-sdk/src/engine/tf/scan.d.ts +22 -0
  23. package/dist-sdk/src/engine/tf/scan.js +123 -0
  24. package/dist-sdk/src/engine/workspace/backend.d.ts +34 -0
  25. package/dist-sdk/src/engine/workspace/backend.js +104 -0
  26. package/dist-sdk/src/engine/workspace/generated-file.d.ts +3 -0
  27. package/dist-sdk/src/engine/workspace/generated-file.js +6 -0
  28. package/dist-sdk/src/engine/workspace/loader.d.ts +8 -0
  29. package/dist-sdk/src/engine/workspace/loader.js +22 -2
  30. package/dist-sdk/src/entities/agent/to-tf.d.ts +13 -11
  31. package/dist-sdk/src/entities/agent/to-tf.js +17 -12
  32. package/dist-sdk/src/entities/agent-tool/from-tf.js +2 -2
  33. package/dist-sdk/src/entities/agent-tool/to-tf.js +10 -1
  34. package/dist-sdk/src/entities/app/build.d.ts +36 -4
  35. package/dist-sdk/src/entities/app/build.js +67 -4
  36. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +18 -0
  37. package/dist-sdk/src/entities/app/from-tf.js +17 -9
  38. package/dist-sdk/src/entities/app/module.js +1 -0
  39. package/dist-sdk/src/entities/app/stage-keys.d.ts +82 -0
  40. package/dist-sdk/src/entities/app/stage-keys.js +160 -0
  41. package/dist-sdk/src/entities/app/to-tf.js +17 -21
  42. package/dist-sdk/src/entities/approval-chain/from-tf.d.ts +9 -1
  43. package/dist-sdk/src/entities/approval-chain/from-tf.js +31 -3
  44. package/dist-sdk/src/entities/approval-chain/module.js +12 -4
  45. package/dist-sdk/src/entities/approval-chain/to-tf.d.ts +1 -0
  46. package/dist-sdk/src/entities/approval-chain/to-tf.js +6 -1
  47. package/dist-sdk/src/entities/automation/build.js +25 -8
  48. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +3 -0
  49. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +5 -3
  50. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +90 -17
  51. package/dist-sdk/src/entities/automation/from-tf.d.ts +28 -6
  52. package/dist-sdk/src/entities/automation/from-tf.js +140 -23
  53. package/dist-sdk/src/entities/automation/module.js +158 -44
  54. package/dist-sdk/src/entities/automation/output-field-types.d.ts +8 -0
  55. package/dist-sdk/src/entities/automation/output-field-types.js +20 -0
  56. package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +2 -0
  57. package/dist-sdk/src/entities/automation/output-key-wire-name.js +18 -0
  58. package/dist-sdk/src/entities/automation/to-tf.d.ts +10 -1
  59. package/dist-sdk/src/entities/automation/to-tf.js +200 -38
  60. package/dist-sdk/src/entities/automation/triggers.d.ts +2 -0
  61. package/dist-sdk/src/entities/automation/triggers.js +1 -0
  62. package/dist-sdk/src/entities/chart/from-tf.d.ts +6 -0
  63. package/dist-sdk/src/entities/chart/from-tf.js +9 -1
  64. package/dist-sdk/src/entities/dashboard/from-tf.js +51 -4
  65. package/dist-sdk/src/entities/dynamic-layout/from-tf.d.ts +3 -0
  66. package/dist-sdk/src/entities/dynamic-layout/from-tf.js +48 -4
  67. package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +2 -0
  68. package/dist-sdk/src/entities/dynamic-layout/to-tf.js +7 -2
  69. package/dist-sdk/src/entities/element/build.js +1 -1
  70. package/dist-sdk/src/entities/element/from-tf.d.ts +12 -6
  71. package/dist-sdk/src/entities/element/from-tf.js +26 -8
  72. package/dist-sdk/src/entities/element/module.js +3 -2
  73. package/dist-sdk/src/entities/element/to-tf.d.ts +3 -2
  74. package/dist-sdk/src/entities/element/to-tf.js +32 -25
  75. package/dist-sdk/src/entities/field/allow-list.d.ts +18 -0
  76. package/dist-sdk/src/entities/field/allow-list.js +42 -0
  77. package/dist-sdk/src/entities/field/build.d.ts +38 -3
  78. package/dist-sdk/src/entities/field/build.js +7 -2
  79. package/dist-sdk/src/entities/field/from-tf.js +178 -20
  80. package/dist-sdk/src/entities/field/module.js +2 -0
  81. package/dist-sdk/src/entities/field/options.d.ts +2 -0
  82. package/dist-sdk/src/entities/field/order.d.ts +9 -0
  83. package/dist-sdk/src/entities/field/order.js +33 -0
  84. package/dist-sdk/src/entities/field/to-tf.d.ts +6 -0
  85. package/dist-sdk/src/entities/field/to-tf.js +87 -0
  86. package/dist-sdk/src/entities/field/types.js +3 -0
  87. package/dist-sdk/src/entities/relationship/build.d.ts +3 -3
  88. package/dist-sdk/src/entities/relationship/from-tf.js +4 -2
  89. package/dist-sdk/src/entities/relationship/to-tf.js +3 -1
  90. package/dist-sdk/src/entities/service-account/workspace-owner.d.ts +8 -3
  91. package/dist-sdk/src/entities/service-account/workspace-owner.js +12 -4
  92. package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +5 -0
  93. package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +13 -0
  94. package/dist-sdk/src/entities/shared/filters/ast.d.ts +7 -0
  95. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +1 -1
  96. package/dist-sdk/src/entities/skill/module.js +28 -2
  97. package/dist-sdk/src/entities/skill/to-tf.js +19 -14
  98. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +2 -0
  99. package/dist-sdk/src/entities/skill-tool/from-tf.js +3 -0
  100. package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +6 -1
  101. package/dist-sdk/src/entities/skill-tool/to-tf.js +6 -1
  102. package/dist-sdk/src/entities/task/build.js +1 -1
  103. package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +2 -0
  104. package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +6 -2
  105. package/dist-sdk/src/entities/view/agent-view-layout-to-tf.d.ts +11 -0
  106. package/dist-sdk/src/entities/view/agent-view-layout-to-tf.js +13 -38
  107. package/dist-sdk/src/entities/view/custom-view-validate.d.ts +29 -0
  108. package/dist-sdk/src/entities/view/custom-view-validate.js +293 -0
  109. package/dist-sdk/src/entities/view/from-tf.d.ts +10 -0
  110. package/dist-sdk/src/entities/view/from-tf.js +164 -26
  111. package/dist-sdk/src/entities/view/to-tf.d.ts +6 -0
  112. package/dist-sdk/src/entities/view/to-tf.js +14 -6
  113. package/dist-sdk/src/entities/visual-flow/from-tf.d.ts +2 -1
  114. package/dist-sdk/src/entities/visual-flow/from-tf.js +11 -2
  115. package/dist-sdk/src/entities/visual-flow/module.js +15 -5
  116. package/dist-sdk/src/entities/visual-flow/to-tf.d.ts +2 -0
  117. package/dist-sdk/src/entities/visual-flow/to-tf.js +1 -1
  118. package/dist-sdk/src/entities/widget/build.d.ts +8 -1
  119. package/dist-sdk/src/entities/widget/from-tf.js +12 -6
  120. package/dist-sdk/src/entities/widget/to-tf.d.ts +1 -0
  121. package/dist-sdk/src/entities/widget/to-tf.js +16 -0
  122. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +8 -2
  123. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
  124. package/dist-sdk/src/graph/index.d.ts +6 -0
  125. package/dist-sdk/src/graph/index.js +1 -0
  126. package/dist-sdk/src/graph/types.d.ts +66 -2
  127. package/package.json +2 -17
@@ -6,6 +6,7 @@ import { filterWireToTf } from "../shared/filters/tf-codec.js";
6
6
  import { DASHBOARD_WIDGET_RESOURCE_TYPE } from "../dashboard-widget/module.js";
7
7
  import { DASHBOARD_RESOURCE_TYPE } from "./module.js";
8
8
  import { CHART_RESOURCE_TYPE } from "../chart/types.js";
9
+ import { chartRefNameFromTfLabel } from "../chart/from-tf.js";
9
10
  import { dashboardWidgetSize } from "./build.js";
10
11
  import { resolveDataAspectTarget } from "../shared/aspect-target-from-tf.js";
11
12
  import { managedViewSortFromTf } from "../view/from-tf.js";
@@ -30,7 +31,7 @@ export function dashboardsFromTf(blocks, widgetBlocks, owner, ctx) {
30
31
  }
31
32
  const tags = stringList(block.attrs, "tags", where, ctx);
32
33
  const key = scopedLabelToBagKey(owner.ownerTfLabel, label, owner.scope);
33
- const widgets = dashboardWidgetsFromTf(widgetBlocks.filter((widget) => resourceRefLabel(widget.attrs["dashboard_id"], DASHBOARD_RESOURCE_TYPE) === label), label, owner, ctx);
34
+ const widgets = dashboardWidgetsFromTf(widgetBlocks.filter((widget) => resourceRefLabel(widget.attrs["dashboard_id"], DASHBOARD_RESOURCE_TYPE) === label), label, key, owner, ctx);
34
35
  dashboards.push({
35
36
  key,
36
37
  name: optionalString(block.attrs, "name", where, ctx) ?? "",
@@ -41,7 +42,7 @@ export function dashboardsFromTf(blocks, widgetBlocks, owner, ctx) {
41
42
  }
42
43
  return dashboards;
43
44
  }
44
- function dashboardWidgetsFromTf(blocks, dashboardLabel, owner, ctx) {
45
+ function dashboardWidgetsFromTf(blocks, dashboardLabel, dashboardKey, owner, ctx) {
45
46
  return blocks.flatMap((block) => {
46
47
  const where = `${DASHBOARD_WIDGET_RESOURCE_TYPE}.${block.label ?? "?"}`;
47
48
  const label = block.label ?? "";
@@ -58,12 +59,33 @@ function dashboardWidgetsFromTf(blocks, dashboardLabel, owner, ctx) {
58
59
  const style = { key, name, size, ...(color !== undefined && { color }), ...(icon !== undefined && { icon }) };
59
60
  const chart = plainObject(block.attrs["chart_widget"]);
60
61
  if (chart !== undefined) {
62
+ const address = `${DASHBOARD_WIDGET_RESOURCE_TYPE}.${label}`;
61
63
  const chartLabel = resourceRefLabel(chart["chart_id"], CHART_RESOURCE_TYPE);
62
64
  if (chartLabel === undefined) {
63
- ctx.diagnostics.push(`${where}.chart_widget.chart_id: expected a managed chart reference; skipped`);
65
+ // A raw chart id or a data.elementum_chart ref names no chart this
66
+ // pull writes, so the widget cannot be written either. Skip and
67
+ // release it, or adoption imports it and the next plan destroys it
68
+ // (#1731).
69
+ if (ctx.requiresExtracted === undefined)
70
+ ctx.diagnostics.push(`${where}.chart_widget.chart_id: expected a managed chart reference; skipped`);
71
+ ctx.requiresExtracted?.push({ address, requires: unresolvedChartRef(chart["chart_id"]), unresolved: true, prune: (root) => root });
64
72
  return [];
65
73
  }
66
- return [{ ...style, type: "chart", chartKey: scopedLabelToBagKey(owner.ownerTfLabel, chartLabel, owner.scope) }];
74
+ // The chart's own file is named from the app's TF label, so derive the
75
+ // key the same way: owner.ownerTfLabel is the camelCase ref, which
76
+ // differs for a namespace with underscores (#1731).
77
+ const chartKey = chartRefNameFromTfLabel(owner.label, chartLabel);
78
+ // The chart extracts later, as an own-file child. If pull skips it and
79
+ // no authored file for it is kept, build cannot emit this widget, so
80
+ // stream-root drops and releases it rather than leave it adopted for
81
+ // the next plan to destroy (#1731).
82
+ ctx.requiresExtracted?.push({
83
+ address,
84
+ requires: `${CHART_RESOURCE_TYPE}.${chartLabel}`,
85
+ requiresOwnFile: { kind: "chart", refName: chartKey },
86
+ prune: (root) => withoutDashboardWidget(root, dashboardKey, key),
87
+ });
88
+ return [{ ...style, type: "chart", chartKey }];
67
89
  }
68
90
  if (aspect === undefined) {
69
91
  ctx.diagnostics.push(`${where}: expected an aspect_widget or chart_widget; skipped`);
@@ -95,6 +117,31 @@ function dashboardWidgetsFromTf(blocks, dashboardLabel, owner, ctx) {
95
117
  }];
96
118
  });
97
119
  }
120
+ /** How an unresolved `chart_id` was exported, for the skipped gap. */
121
+ function unresolvedChartRef(value) {
122
+ const dataLabel = dataRefLabel(value, CHART_RESOURCE_TYPE);
123
+ if (dataLabel !== undefined)
124
+ return `data.${CHART_RESOURCE_TYPE}.${dataLabel}`;
125
+ if (typeof value === "string")
126
+ return `chart id ${JSON.stringify(value)}`;
127
+ return "an unresolved chart_id";
128
+ }
129
+ /** `root` without widget `widgetKey` of dashboard `dashboardKey`; unchanged when it has no such widget. */
130
+ function withoutDashboardWidget(root, dashboardKey, widgetKey) {
131
+ const dashboards = root.dashboards;
132
+ if (dashboards === undefined)
133
+ return root;
134
+ return {
135
+ ...root,
136
+ dashboards: dashboards.map((dashboard) => {
137
+ if (dashboard.key !== dashboardKey || dashboard.widgets === undefined)
138
+ return dashboard;
139
+ const { widgets, ...rest } = dashboard;
140
+ const kept = widgets.filter((widget) => widget.key !== widgetKey);
141
+ return kept.length > 0 ? { ...rest, widgets: kept } : rest;
142
+ }),
143
+ };
144
+ }
98
145
  function aspectRef(value, owner, ctx) {
99
146
  if (typeof value === "string")
100
147
  return undefined;
@@ -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, isTfLabel, scopedLabelToBagKey, tfLabelToTsLabel, } from "../../engine/tf/index.js";
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 || isTfLabel(index))
388
- return index === undefined ? undefined : tfLabelToTsLabel(index);
389
- ctx.diagnostics.push(`${where}: stage key ${JSON.stringify(index)} is outside the terraform label alphabet; stage dropped`);
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: tsLabelToTfLabel(layout.stage) }]);
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: tsLabelToTfLabel(stage) }]),
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, or, in the element's
34
- * own automations, through a trigger's Created/Updated outputs. Locals
35
- * blocks are skipped by callers: `ei` defines those locals on every element.
36
- * An authored field with the same display name wins over trigger-output
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;
@@ -149,7 +149,8 @@ export function elementFromTf(elementBlock, fieldBlocks, ctx, viewBlocks = {
149
149
  ctx.diagnostics.push(`element "${label}": no import block in the stream — adoption has no identity to bind`);
150
150
  }
151
151
  const dashboards = dashboardsFromTf(viewBlocks.dashboardBlocks, viewBlocks.dashboardWidgetBlocks, { type: ELEMENT_RESOURCE_TYPE, label, ownerTfLabel: refName, ownerRefName: refName, scope: "element", ownerType: "ELEMENT_ASPECT" }, ctx);
152
- const { layouts, listViews, calendarViews, kanbanViews, dashboardViews, customViews, viewOrder } = viewsFromTf(viewBlocks.layoutBlocks, viewBlocks.listViewBlocks, viewBlocks.calendarViewBlocks, viewBlocks.kanbanViewBlocks, viewBlocks.dashboardViewBlocks, [], viewBlocks.managedViewOrderBlocks, { type: ELEMENT_RESOURCE_TYPE, label, ownerTfLabel: label, scope: "element" }, ctx, viewBlocks.customViewBlocks);
152
+ const unextractedFieldIds = new Set();
153
+ const { layouts, listViews, calendarViews, kanbanViews, dashboardViews, customViews, viewOrder } = viewsFromTf(viewBlocks.layoutBlocks, viewBlocks.listViewBlocks, viewBlocks.calendarViewBlocks, viewBlocks.kanbanViewBlocks, viewBlocks.dashboardViewBlocks, [], viewBlocks.managedViewOrderBlocks, { type: ELEMENT_RESOURCE_TYPE, label, ownerTfLabel: label, scope: "element", fieldKeys: new Set(fields.map((field) => field.key)), unextractedFieldIds }, ctx, viewBlocks.customViewBlocks);
153
154
  if (viewBlocks.recordCreateFormBlocks.length > 1) {
154
155
  ctx.diagnostics.push(`element "${label}": found ${viewBlocks.recordCreateFormBlocks.length} record create forms; only the first is used`);
155
156
  }
@@ -176,7 +177,7 @@ export function elementFromTf(elementBlock, fieldBlocks, ctx, viewBlocks = {
176
177
  ...Object.values(viewBlocks).flatMap((blocks) => blocks ?? []),
177
178
  ...accessPolicyBlocks,
178
179
  ...roleBlocks,
179
- ], new Set(fields.map(({ field }) => field.name.toLowerCase())));
180
+ ], new Set(fields.map(({ field }) => field.name.toLowerCase())), elementAuditFieldIds(refName, ctx));
180
181
  const element = {
181
182
  id: elementId ?? "",
182
183
  name,
@@ -198,6 +199,7 @@ export function elementFromTf(elementBlock, fieldBlocks, ctx, viewBlocks = {
198
199
  ...(auditFields && { auditFields }),
199
200
  ...(layouts.length > 0 && { layouts }),
200
201
  ...(listViews.length > 0 && { listViews }),
202
+ ...(unextractedFieldIds.size > 0 && { unextractedFieldIds: [...unextractedFieldIds] }),
201
203
  ...(calendarViews.length > 0 && { calendarViews }),
202
204
  ...(kanbanViews.length > 0 && { kanbanViews }),
203
205
  ...(dashboardViews.length > 0 && { dashboardViews }),
@@ -217,21 +219,37 @@ function systemEntry(key, name, type, tag, description) {
217
219
  return { key, field: { id: "", name, type, tags: [tag], ...(description !== undefined && { description }) } };
218
220
  }
219
221
  const AUDIT_TRIGGER_REF_NAME = /^(?:Created|Updated) (?:At|On|By)\b/i;
222
+ const AUDIT_FIELD_KEYS = new Set(["createdAt", "createdBy", "updatedAt", "updatedBy"]);
223
+ /**
224
+ * Platform ids that pull knows, from state or a live read, to be this
225
+ * element's own audit fields. The export can name them by raw id only, and
226
+ * pull then prints them as typed audit refs (#1704).
227
+ */
228
+ export function elementAuditFieldIds(refName, ctx) {
229
+ const ids = new Set();
230
+ for (const [id, ref] of ctx.foreignFieldRefsById ?? []) {
231
+ if (ref.ownerRefName === refName && AUDIT_FIELD_KEYS.has(ref.fieldKey))
232
+ ids.add(id);
233
+ }
234
+ return ids;
235
+ }
220
236
  /**
221
237
  * The export references an element's audit fields only when the platform
222
238
  * gave it those fields, which EDK cannot otherwise observe: through its
223
- * `<label>_(created|updated)_(at|by)_field_id` locals, or, in the element's
224
- * own automations, through a trigger's Created/Updated outputs. Locals
225
- * blocks are skipped by callers: `ei` defines those locals on every element.
226
- * An authored field with the same display name wins over trigger-output
227
- * heuristics.
239
+ * `<label>_(created|updated)_(at|by)_field_id` locals, by the raw id of one
240
+ * of them (`auditFieldIds`), or, in the element's own automations, through a
241
+ * trigger's Created/Updated outputs. Locals blocks are skipped by callers:
242
+ * `ei` defines those locals on every element. An authored field with the
243
+ * same display name wins over trigger-output heuristics.
228
244
  */
229
- export function referencesElementAuditFields(label, blocks, authoredFieldNames = new Set()) {
245
+ export function referencesElementAuditFields(label, blocks, authoredFieldNames = new Set(), auditFieldIds = new Set()) {
230
246
  const auditLocal = new RegExp(`^${label}_(?:created|updated)_(?:at|by)_field_id$`);
231
247
  const ownedTriggers = elementTriggerAddresses(label, blocks);
232
248
  const visit = (value) => {
233
249
  if (Array.isArray(value))
234
250
  return value.some(visit);
251
+ if (typeof value === "string")
252
+ return auditFieldIds.has(value);
235
253
  if (typeof value !== "object" || value === null)
236
254
  return false;
237
255
  const node = value;
@@ -7,7 +7,7 @@ import { inManagedFieldOrder } from "../field/order.js";
7
7
  import { NO_CATALOG, } from "../../graph/types.js";
8
8
  import { appendFieldLocals } from "../field/locals.js";
9
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";
10
- import { elementFromTf, referencesElementAuditFields } from "./from-tf.js";
10
+ import { elementAuditFieldIds, elementFromTf, referencesElementAuditFields } from "./from-tf.js";
11
11
  import { appendElementLocals } from "./locals.js";
12
12
  import { elementToTf } from "./to-tf.js";
13
13
  export const ELEMENT_RESOURCE_TYPE = "elementum_element";
@@ -52,7 +52,7 @@ function extractElementStreamRoot(stream, ctx) {
52
52
  // Automations are extracted separately, but their trigger outputs are the
53
53
  // only audit reference some elements have.
54
54
  const auditFields = element.auditFields === true ||
55
- 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));
56
56
  return {
57
57
  instance: auditFields && element.auditFields !== true ? { ...element, auditFields } : element,
58
58
  ...(cloudLinkHandle !== undefined && { cloudLinkHandle }),
@@ -78,6 +78,7 @@ export const elementModule = {
78
78
  orgRefs: ctx.orgRefs,
79
79
  diagnostics: ctx.diagnostics,
80
80
  workspaceAspects: ctx.workspaceAspects,
81
+ ...(ctx.outOfScopeApps !== undefined && { outOfScopeApps: ctx.outOfScopeApps }),
81
82
  });
82
83
  return {
83
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. No status_options/stages (apps always
4
- * emit those; element captures do not).
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,7 +1,8 @@
1
1
  /**
2
2
  * Element emission: `element` DeployableEntity → `elementum_element` +
3
- * field resources in ei's dialect. No status_options/stages (apps always
4
- * emit those; element captures do not).
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 { managedFieldOrderToTf } from "../field/order.js";
7
8
  import { autoShareToTf } from "../app/auto-share.js";
@@ -153,28 +154,32 @@ export function elementToTf(entity, ctx) {
153
154
  // must resolve against "title", never snakeSlug of a renamed label.
154
155
  if (systemKey !== undefined && name !== "")
155
156
  fieldNames.set(systemKey, name);
156
- switch (systemTag) {
157
- case "TITLE":
158
- if (name !== "Title")
159
- elementAttrs["title_field_name"] = name;
160
- if (inner.description !== undefined)
161
- elementAttrs["title_field_description"] = inner.description;
162
- break;
163
- case "HANDLE":
164
- if (name !== "ID")
165
- elementAttrs["id_field_name"] = name;
166
- if (inner.description !== undefined)
167
- elementAttrs["id_field_description"] = inner.description;
168
- break;
169
- case "STATUS":
170
- case "STAGE":
171
- ctx.diagnostics.push(`systemFields.${systemTag.toLowerCase()}: elements do not carry status/stages on the terraform path; dropped`);
172
- break;
173
- default:
174
- // Audit fields are provider-managed; nothing to emit.
175
- break;
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;
176
182
  }
177
- continue;
178
183
  }
179
184
  const field = fieldToTf(typeKey, inner, {
180
185
  ownerTfLabel: ctx.appTfLabel,
@@ -240,6 +245,8 @@ export function elementToTf(entity, ctx) {
240
245
  workspaceAspects: ctx.workspaceAspects,
241
246
  diagnostics: ctx.diagnostics,
242
247
  fieldAddresses,
248
+ fieldNames,
249
+ fieldMetadata,
243
250
  widgetKeys: new Set(Object.keys(payload.widgets ?? {})),
244
251
  }, payload.customViews);
245
252
  blocks.push(...viewBlocks);
@@ -295,7 +302,7 @@ export function elementToTf(entity, ctx) {
295
302
  // An element has no service accounts of its own. Hand the sibling app's
296
303
  // authored bag to the shared resolver so a managed account becomes a
297
304
  // direct resource ref and Terraform sequences same-apply creation.
298
- resolveServiceAccountApp: workspaceServiceAccountAppResolver(ctx.workspaceAspects),
305
+ resolveServiceAccountApp: workspaceServiceAccountAppResolver(ctx.workspaceAspects, { apps: ctx.outOfScopeApps, orgRefs: ctx.orgRefs }),
299
306
  });
300
307
  blocks.push(block);
301
308
  }
@@ -306,7 +313,7 @@ export function elementToTf(entity, ctx) {
306
313
  objectId,
307
314
  orgRefs: ctx.orgRefs,
308
315
  diagnostics: ctx.diagnostics,
309
- resolveServiceAccountApp: workspaceServiceAccountAppResolver(ctx.workspaceAspects),
316
+ resolveServiceAccountApp: workspaceServiceAccountAppResolver(ctx.workspaceAspects, { apps: ctx.outOfScopeApps, orgRefs: ctx.orgRefs }),
310
317
  }));
311
318
  blocks.unshift({
312
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
- export declare function userField(opts: BaseFieldOptions & WithExpression<"user">): AppField & {
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: BaseFieldOptions & WithExpression<"group">): AppField & {
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
- return field("USER", opts);
70
+ const built = field("USER", opts);
71
+ assertFieldAllowList(built, "user");
72
+ return built;
70
73
  }
71
74
  export function groupField(opts) {
72
- return field("GROUP", opts);
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)