@elementumai/edk 0.9.6 → 0.9.7

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 (97) hide show
  1. package/README.md +31 -1
  2. package/dist-sdk/src/catalog/factories.d.ts +12 -3
  3. package/dist-sdk/src/catalog/factories.js +9 -6
  4. package/dist-sdk/src/catalog/org.js +26 -13
  5. package/dist-sdk/src/catalog/types.d.ts +22 -1
  6. package/dist-sdk/src/core/index.d.ts +1 -1
  7. package/dist-sdk/src/core/system-fields.d.ts +4 -0
  8. package/dist-sdk/src/core/system-fields.js +15 -0
  9. package/dist-sdk/src/core/types/app.d.ts +14 -9
  10. package/dist-sdk/src/core/types/platform.d.ts +1 -1
  11. package/dist-sdk/src/engine/build/context.d.ts +4 -0
  12. package/dist-sdk/src/engine/pull/context.d.ts +9 -0
  13. package/dist-sdk/src/engine/pull/ref-only.d.ts +14 -0
  14. package/dist-sdk/src/engine/pull/ref-only.js +35 -2
  15. package/dist-sdk/src/entities/access-policy/from-tf.js +14 -2
  16. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +6 -0
  17. package/dist-sdk/src/entities/access-policy/to-tf.js +4 -1
  18. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +18 -1
  19. package/dist-sdk/src/entities/agent/module.js +1 -0
  20. package/dist-sdk/src/entities/agent/to-tf.d.ts +1 -0
  21. package/dist-sdk/src/entities/agent/to-tf.js +1 -0
  22. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +9 -0
  23. package/dist-sdk/src/entities/agent-tool/from-tf.js +10 -2
  24. package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +2 -0
  25. package/dist-sdk/src/entities/agent-tool/to-tf.js +2 -3
  26. package/dist-sdk/src/entities/app/build.d.ts +42 -22
  27. package/dist-sdk/src/entities/app/build.js +12 -5
  28. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +10 -0
  29. package/dist-sdk/src/entities/app/from-tf.js +71 -8
  30. package/dist-sdk/src/entities/app/index.d.ts +3 -2
  31. package/dist-sdk/src/entities/app/index.js +2 -1
  32. package/dist-sdk/src/entities/app/to-tf.js +16 -0
  33. package/dist-sdk/src/entities/automation/build.d.ts +31 -19
  34. package/dist-sdk/src/entities/automation/build.js +85 -7
  35. package/dist-sdk/src/entities/automation/catalog-render.js +5 -2
  36. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +5 -3
  37. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +26 -12
  38. package/dist-sdk/src/entities/automation/from-tf.js +364 -31
  39. package/dist-sdk/src/entities/automation/index.d.ts +1 -1
  40. package/dist-sdk/src/entities/automation/module.js +2 -2
  41. package/dist-sdk/src/entities/automation/operators.d.ts +2 -2
  42. package/dist-sdk/src/entities/automation/operators.js +1 -0
  43. package/dist-sdk/src/entities/automation/output-field-types.d.ts +17 -0
  44. package/dist-sdk/src/entities/automation/output-field-types.js +45 -0
  45. package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +8 -0
  46. package/dist-sdk/src/entities/automation/output-key-wire-name.js +16 -0
  47. package/dist-sdk/src/entities/automation/script-code.js +153 -25
  48. package/dist-sdk/src/entities/automation/tasks.d.ts +100 -37
  49. package/dist-sdk/src/entities/automation/tasks.js +44 -43
  50. package/dist-sdk/src/entities/automation/to-tf.d.ts +3 -1
  51. package/dist-sdk/src/entities/automation/to-tf.js +454 -58
  52. package/dist-sdk/src/entities/automation/value-ref-tf.d.ts +78 -0
  53. package/dist-sdk/src/entities/automation/value-ref-tf.js +193 -0
  54. package/dist-sdk/src/entities/element/build.js +1 -0
  55. package/dist-sdk/src/entities/element/index.d.ts +2 -1
  56. package/dist-sdk/src/entities/element/index.js +2 -1
  57. package/dist-sdk/src/entities/field/build.d.ts +94 -3
  58. package/dist-sdk/src/entities/field/build.js +82 -3
  59. package/dist-sdk/src/entities/field/from-tf.js +92 -1
  60. package/dist-sdk/src/entities/field/locals.js +6 -7
  61. package/dist-sdk/src/entities/field/options.d.ts +2 -0
  62. package/dist-sdk/src/entities/field/options.js +12 -2
  63. package/dist-sdk/src/entities/field/record-shape.d.ts +12 -15
  64. package/dist-sdk/src/entities/field/to-tf.d.ts +12 -2
  65. package/dist-sdk/src/entities/field/to-tf.js +172 -51
  66. package/dist-sdk/src/entities/field/types.js +2 -0
  67. package/dist-sdk/src/entities/record-create-form/to-tf.js +5 -8
  68. package/dist-sdk/src/entities/relationship/from-tf.js +91 -9
  69. package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +9 -0
  70. package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +39 -0
  71. package/dist-sdk/src/entities/shared/filters/ast.d.ts +18 -1
  72. package/dist-sdk/src/entities/shared/filters/ast.js +1 -0
  73. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +6 -1
  74. package/dist-sdk/src/entities/shared/filters/tf-codec.js +6 -4
  75. package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +5 -3
  76. package/dist-sdk/src/entities/shared/tool-field-ref.js +11 -16
  77. package/dist-sdk/src/entities/shared/types/common.d.ts +7 -5
  78. package/dist-sdk/src/entities/shared/types/platform.d.ts +15 -2
  79. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +1 -1
  80. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +44 -15
  81. package/dist-sdk/src/entities/skill/from-tf.js +11 -1
  82. package/dist-sdk/src/entities/skill/input-coverage.d.ts +68 -0
  83. package/dist-sdk/src/entities/skill/input-coverage.js +184 -0
  84. package/dist-sdk/src/entities/skill/module.js +2 -0
  85. package/dist-sdk/src/entities/skill/to-tf.d.ts +3 -0
  86. package/dist-sdk/src/entities/skill/to-tf.js +7 -2
  87. package/dist-sdk/src/entities/skill/tools.d.ts +10 -1
  88. package/dist-sdk/src/entities/skill/tools.js +0 -5
  89. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +19 -0
  90. package/dist-sdk/src/entities/skill-tool/from-tf.js +40 -11
  91. package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +4 -2
  92. package/dist-sdk/src/entities/skill-tool/to-tf.js +24 -16
  93. package/dist-sdk/src/entities/table/to-tf.js +18 -1
  94. package/dist-sdk/src/entities/view/to-tf.js +8 -3
  95. package/dist-sdk/src/entities/visual-flow/from-tf.js +6 -2
  96. package/dist-sdk/src/graph/types.d.ts +3 -0
  97. package/package.json +2 -1
package/README.md CHANGED
@@ -177,6 +177,7 @@ elementum new skill --app <appRef> --name "Lookup Ticket"
177
177
  elementum new automation --app <appRef> --name "Escalate Ticket"
178
178
  elementum generate [path] [--root <orgRoot>]
179
179
  elementum canvas <orgRoot-or-file> [--port <port>] [--no-open]
180
+ elementum mcp [--cwd <dir>]
180
181
  elementum playbooks list|install|status|path|print
181
182
  ```
182
183
 
@@ -227,6 +228,35 @@ The installed slash commands are `/elementum`, `/elementum-uat`,
227
228
  `elementum skills ...` remains the platform command family for agentic-skill
228
229
  operations.
229
230
 
231
+ ## MCP
232
+
233
+ `elementum mcp` starts a local MCP server on stdin/stdout so a coding agent on
234
+ this machine can run the same CLI. Start it from the org workspace (or pass
235
+ `--cwd`) and point the agent's MCP config at:
236
+
237
+ ```json
238
+ {
239
+ "mcpServers": {
240
+ "elementum": {
241
+ "command": "elementum",
242
+ "args": ["mcp"]
243
+ }
244
+ }
245
+ }
246
+ ```
247
+
248
+ The server exposes `run` (any CLI command as argument tokens after
249
+ `elementum`) and `help`. `initialize.instructions` tells the agent how to
250
+ login, auth-check, pull/build/plan/apply, and pass profiles. Nested
251
+ `mcp`/`canvas`/`chat` are refused, as are `auth env` / `auth export` /
252
+ `auth import` (credential dump or passphrase TTY). `auth login` over MCP is
253
+ non-interactive: it reads `ELEMENTUM_ORGANIZATION`, `ELEMENTUM_INSTANCE`,
254
+ `ELEMENTUM_CLIENT_ID`, `ELEMENTUM_CLIENT_SECRET`, and optional
255
+ `ELEMENTUM_PROFILE` (or the matching flags) and persists a profile. A human
256
+ TTY login still uses the form. `apply` still goes through the real CLI; after
257
+ the user reviews the plan, use `["apply", "-auto-approve"]` (stdin is not a
258
+ TTY, so a bare apply cannot prompt).
259
+
230
260
  ## Canvas
231
261
 
232
262
  Canvas is an offline, live-reloading view of authored source:
@@ -570,7 +600,7 @@ The repository builds three distinct output trees:
570
600
  - `dist-sdk/` — `tsc -p tsconfig.sdk.json` output, the sole source tree packed
571
601
  into the `@elementumai/edk` SDK package;
572
602
  - `dist-cli/` — Node-compatible `tsc -p tsconfig.cli.json` output used by local
573
- development, tests, integration tooling, and the binary build script; it is
603
+ development, tests, integration tooling, and the binary build script; it is <!-- // pragma: allowlist secret -->
574
604
  not part of the SDK package or the final release payload;
575
605
  - `dist-bin/` — standalone `elementum` executables produced from `dist-cli` by
576
606
  the locked local Bun dependency; these are the CLI release inputs distributed
@@ -98,6 +98,7 @@ type WithOwnedCatalogChildren<B extends AppCatalogBags, Parent extends string> =
98
98
  * narrow `.trigger.<name>` and `.outputs.<name>` at the call site.
99
99
  */
100
100
  export declare function automationRef<T extends Readonly<Record<string, TriggerParameterRef>> | undefined = undefined, O extends Readonly<Record<string, OutputPropertyRef>> | undefined = undefined>(opts?: {
101
+ readonly name?: string;
101
102
  readonly trigger?: T;
102
103
  readonly outputs?: O;
103
104
  }): AutomationCatalogRef & {
@@ -137,11 +138,19 @@ export declare function documentModelFieldRef(opts: {
137
138
  readonly name: string;
138
139
  readonly parent: string;
139
140
  }): DocumentModelFieldRef;
140
- /** Build an output property ref — keyed by property name; `parent` is the owning automation's refName. */
141
- export declare function outputPropertyRef(opts: {
141
+ /**
142
+ * Build an output property ref — keyed by property name; `parent` is the owning automation's
143
+ * refName. `const T` (not plain `T`) so `valueType` infers as the LITERAL — same trick as
144
+ * {@link fieldRef}'s `fieldType` and {@link triggerParameterRef}'s `required: true`.
145
+ */
146
+ export declare const outputPropertyRef: <const T extends {
142
147
  readonly name: string;
143
148
  readonly parent: string;
144
- }): OutputPropertyRef;
149
+ readonly valueType?: string;
150
+ }>(opts: T) => T & {
151
+ readonly __kind: "outputProperty";
152
+ readonly refName: string;
153
+ };
145
154
  /**
146
155
  * Agent ref — no required arguments. `handle` and `parent` are injected by the enclosing
147
156
  * `appCatalog`/`elementCatalog`; `name` defaults to `""`.
@@ -33,7 +33,7 @@ export function automationRef(opts) {
33
33
  return {
34
34
  __kind: "automation",
35
35
  refName: "",
36
- name: "",
36
+ name: opts?.name ?? "",
37
37
  ...(opts?.trigger !== undefined ? { trigger: opts.trigger } : {}),
38
38
  ...(opts?.outputs !== undefined ? { outputs: opts.outputs } : {}),
39
39
  };
@@ -65,10 +65,12 @@ export function documentModelRef(opts) {
65
65
  export function documentModelFieldRef(opts) {
66
66
  return { __kind: "documentModelField", refName: opts.name, name: opts.name, parent: opts.parent };
67
67
  }
68
- /** Build an output property ref — keyed by property name; `parent` is the owning automation's refName. */
69
- export function outputPropertyRef(opts) {
70
- return { __kind: "outputProperty", refName: opts.name, name: opts.name, parent: opts.parent };
71
- }
68
+ /**
69
+ * Build an output property ref — keyed by property name; `parent` is the owning automation's
70
+ * refName. `const T` (not plain `T`) so `valueType` infers as the LITERAL — same trick as
71
+ * {@link fieldRef}'s `fieldType` and {@link triggerParameterRef}'s `required: true`.
72
+ */
73
+ export const outputPropertyRef = (opts) => ({ __kind: "outputProperty", refName: opts.name, ...opts });
72
74
  /**
73
75
  * Agent ref — no required arguments. `handle` and `parent` are injected by the enclosing
74
76
  * `appCatalog`/`elementCatalog`; `name` defaults to `""`.
@@ -180,6 +182,7 @@ export function tableColumnRef(opts) {
180
182
  refName: opts.name,
181
183
  parent: opts.parent ?? "",
182
184
  name: opts.name,
185
+ ...(opts.parentName !== undefined ? { parentName: opts.parentName } : {}),
183
186
  ...(opts.fieldType !== undefined ? { fieldType: opts.fieldType } : {}),
184
187
  ...(opts.tags !== undefined ? { tags: opts.tags } : {}),
185
188
  };
@@ -190,7 +193,7 @@ export function tableRef(opts) {
190
193
  ? undefined
191
194
  : Object.fromEntries(Object.entries(opts.columns).map(([refName, column]) => [
192
195
  refName,
193
- { ...column, refName, parent: opts.refName ?? opts.name },
196
+ { ...column, refName, parent: opts.refName ?? opts.name, parentName: opts.name },
194
197
  ]));
195
198
  return {
196
199
  __kind: "table",
@@ -2,8 +2,9 @@
2
2
  * Regenerate the shared org catalog barrel (`generated/catalog.ts`): imports
3
3
  * every app's, element's, and table's own per-entity `generated/catalog.ts`
4
4
  * (written by `writeAppCatalog`/`writeAppCatalogFromAuthoring`) and exposes
5
- * apps/elements flat plus tables under `catalog.tables`, alongside org
6
- * AI providers/cloud links. `import catalog from "@catalog"` gives
5
+ * apps/elements flat plus tables under both `catalog.tables` and `org.tables`
6
+ * (printers emit `org.tables.*`; automations historically use `catalog.tables.*`),
7
+ * alongside org AI providers/cloud links. `import catalog from "@catalog"` gives
7
8
  * `catalog.testingAles`, `catalog.tables.orders`,
8
9
  * `catalog.aiProviders.anthropic.models.claudeOpus_4_6`, etc.
9
10
  *
@@ -239,7 +240,10 @@ function renderBarrel(appHandles, elementHandles, tableHandles) {
239
240
  const elementKeys = computeElementKeys(appHandles, elementHandles);
240
241
  const hasLazyEntries = appHandles.length > 0 || elementHandles.length > 0 || tableHandles.length > 0;
241
242
  const lines = [
242
- 'import { org } from "../org.js";',
243
+ // Alias so we can re-export `org` with the pulled `tables` bag attached —
244
+ // table printers emit `org.tables.*` while automations historically use
245
+ // `catalog.tables.*`. Both must resolve the same lazy getters.
246
+ 'import { org as orgIdentities } from "../org.js";',
243
247
  'import { usersCatalog } from "@elementumai/edk/catalog";',
244
248
  "",
245
249
  ];
@@ -250,6 +254,12 @@ function renderBarrel(appHandles, elementHandles, tableHandles) {
250
254
  // erased entirely at compile time.
251
255
  lines.push("declare const require: (id: string) => unknown;", "");
252
256
  }
257
+ if (tableHandles.length > 0) {
258
+ lines.push("const tables = {");
259
+ for (const h of tableHandles)
260
+ lines.push(...lazyAspectGetter(safeKey(h), `../tables/${h}/generated/catalog.js`, "default", " "));
261
+ lines.push("};", "");
262
+ }
253
263
  lines.push("const catalog = {");
254
264
  for (const h of appHandles)
255
265
  lines.push(...lazyAspectGetter(h, `../apps/${h}/generated/catalog.js`, h));
@@ -257,18 +267,21 @@ function renderBarrel(appHandles, elementHandles, tableHandles) {
257
267
  lines.push(...lazyAspectGetter(elementKeys.get(h), `../elements/${h}/generated/catalog.js`, h));
258
268
  }
259
269
  lines.push(" users: usersCatalog,");
260
- lines.push(" aiProviders: org.aiProviders,");
261
- lines.push(" cloudLinks: org.cloudLinks,");
262
- lines.push(" categories: org.categories,");
263
- lines.push(" groups: org.groups,");
264
- lines.push(" phoneProviders: org.phoneProviders,");
270
+ lines.push(" aiProviders: orgIdentities.aiProviders,");
271
+ lines.push(" cloudLinks: orgIdentities.cloudLinks,");
272
+ lines.push(" categories: orgIdentities.categories,");
273
+ lines.push(" groups: orgIdentities.groups,");
274
+ lines.push(" phoneProviders: orgIdentities.phoneProviders,");
275
+ if (tableHandles.length > 0)
276
+ lines.push(" tables,");
277
+ lines.push("};");
265
278
  if (tableHandles.length > 0) {
266
- lines.push(" tables: {");
267
- for (const h of tableHandles)
268
- lines.push(...lazyAspectGetter(safeKey(h), `../tables/${h}/generated/catalog.js`, "default", " "));
269
- lines.push(" },");
279
+ lines.push("", "const org = { ...orgIdentities, tables };", "export { org };");
280
+ }
281
+ else {
282
+ lines.push("", "export { orgIdentities as org };");
270
283
  }
271
- lines.push("};", "", "export { org };", "export type Ref = typeof catalog;", "export default catalog;", "");
284
+ lines.push("export type Ref = typeof catalog;", "export default catalog;", "");
272
285
  return lines.join("\n");
273
286
  }
274
287
  /**
@@ -96,6 +96,13 @@ export type ApprovalProcessRef<Parent extends string = string, RefName extends s
96
96
  export interface TableColumnRef<Parent extends string = string, RefName extends string = string> extends CatalogRef<"tableColumn", RefName, Parent> {
97
97
  /** Owning table handle. */
98
98
  readonly parent: Parent;
99
+ /**
100
+ * The owning table's display NAME, stamped alongside `parent` for the same
101
+ * reason `FieldRef.parentName` is — a column outside this workspace builds to
102
+ * `data.elementum_table.<t>.field_ids["Column"]`, and that lookup keys by the
103
+ * table's display name, which `parent` (a refName) doesn't carry.
104
+ */
105
+ readonly parentName?: string;
99
106
  readonly fieldType?: string;
100
107
  readonly tags?: readonly string[];
101
108
  }
@@ -168,6 +175,8 @@ export interface FieldRef<Parent extends string = string, RefName extends string
168
175
  readonly fieldType: FieldType;
169
176
  readonly tags?: readonly string[];
170
177
  readonly options?: readonly string[];
178
+ /** Authoring metadata: this Dropdown/Multi-Select sources values from records. */
179
+ readonly dynamicSource?: true;
171
180
  /**
172
181
  * Whether `parent` names an app or an element — stamped alongside `parent`
173
182
  * by `appCatalog`/`elementCatalog` (the field's own token doesn't otherwise
@@ -210,7 +219,19 @@ export interface TriggerParameterRef extends CatalogRef<"triggerParameter"> {
210
219
  */
211
220
  readonly required?: boolean;
212
221
  }
213
- export type OutputPropertyRef = CatalogRef<"outputProperty">;
222
+ /**
223
+ * An automation output property reference. `valueType` (when known) is the
224
+ * platform's workflow field-type tag for this output — `"TEXT"`,
225
+ * `"BOOLEAN"`, `"NUMBER"`, `"DECIMAL"` — the same domain
226
+ * `entities/automation`'s `outputFieldTypesFromScriptSchema` already
227
+ * computes for the wire; not populated when the output's source can't be
228
+ * resolved to a typed schema (a literal, a trigger ref, a variable ref, or
229
+ * a non-executeScript task). Kept a bare generic `string` here (no import
230
+ * from `entities/`) — same decoupling as {@link FieldRef}'s `fieldType`.
231
+ */
232
+ export interface OutputPropertyRef<ValueType extends string = string> extends CatalogRef<"outputProperty"> {
233
+ readonly valueType?: ValueType;
234
+ }
214
235
  export type DocumentModelFieldRef = CatalogRef<"documentModelField">;
215
236
  /**
216
237
  * A document model reference that also exposes its fields as a nested ref
@@ -2,7 +2,7 @@ export { UNRESOLVED_FIELD_MARKER, createRef, isRef, secret, template, toRefData,
2
2
  export { buildContext, createActionOutputProxy, createActionsProxy, createForEachItemProxy, createTriggerProxy, type Context, type ForEachItem } from "../entities/shared/context.js";
3
3
  export { asRowProxy, app, picklistOption, picklistStaticValueToApiId, resolveFieldValues, type App, type AppAgent, type AppAutomation, type AppCategory, type AppField, type AppFieldInputForAction, type AppFieldOf, type AppFieldValues, type AppPhoneService, type AppSearchTable, type AspectRecord, type AspectType, type FieldScope, type FieldValueForAppField, type FieldValueType, type PicklistOption, type PicklistOptionsResolver, type RowProxy, type RowScopedFields, type SearchTableRecord } from "./types/app.js";
4
4
  export { asc, desc, sortBy, type SortDirection, type SortOrder } from "../entities/shared/types/common.js";
5
- export { type Attachment, type Employee, type Group, type Manager, type PicklistValue, type RichText, type User } from "../entities/shared/types/platform.js";
5
+ export { type Attachment, type Employee, type Group, type Manager, type DropdownValue, type DynamicDropdownValue, type RecordId, type RichText, type User, } from "../entities/shared/types/platform.js";
6
6
  export { aiProviderConnector, type AiProviderConnector } from "./types/ai-provider.js";
7
7
  export { user, type UserRef } from "./types/user.js";
8
8
  export { group, type GroupRef } from "./types/group.js";
@@ -68,6 +68,10 @@ export declare const SYSTEM_FIELD_KEYS: readonly SystemFieldKey[];
68
68
  /** `SYSTEM_FIELD_KEYS` as a set — for O(1) "is this key a system field?" checks (e.g. distinguishing a system field from a custom field by bag key alone). */
69
69
  export declare const SYSTEM_FIELD_KEY_SET: ReadonlySet<SystemFieldKey>;
70
70
  export declare const SYSTEM_FIELD_KEY_BY_TAG: Readonly<Record<string, SystemFieldKey>>;
71
+ /** Internal Terraform map key for each public `systemFields` key. */
72
+ export declare const SYSTEM_FIELD_HCL_KEY_BY_KEY: Readonly<Record<SystemFieldKey, string>>;
73
+ /** Internal inverse used only at the HCL extraction boundary. */
74
+ export declare const SYSTEM_FIELD_KEY_BY_HCL_KEY: Readonly<Record<string, SystemFieldKey>>;
71
75
  /**
72
76
  * What a NO-OVERRIDE deploy produces — the terraform provider's auto-create
73
77
  * display names. This is the baseline the pull printer compares against when
@@ -104,6 +104,21 @@ export const SYSTEM_FIELD_KEYS = Object.keys(SYSTEM_FIELD_TAG_BY_KEY);
104
104
  /** `SYSTEM_FIELD_KEYS` as a set — for O(1) "is this key a system field?" checks (e.g. distinguishing a system field from a custom field by bag key alone). */
105
105
  export const SYSTEM_FIELD_KEY_SET = new Set(SYSTEM_FIELD_KEYS);
106
106
  export const SYSTEM_FIELD_KEY_BY_TAG = Object.fromEntries(Object.entries(SYSTEM_FIELD_TAG_BY_KEY).map(([k, tag]) => [tag, k]));
107
+ /** Internal Terraform map key for each public `systemFields` key. */
108
+ export const SYSTEM_FIELD_HCL_KEY_BY_KEY = {
109
+ id: "id",
110
+ title: "title",
111
+ status: "status",
112
+ stage: "stage",
113
+ createdAt: "created_at",
114
+ createdBy: "created_by",
115
+ updatedAt: "updated_at",
116
+ updatedBy: "updated_by",
117
+ closedAt: "closed_at",
118
+ closedBy: "closed_by",
119
+ };
120
+ /** Internal inverse used only at the HCL extraction boundary. */
121
+ export const SYSTEM_FIELD_KEY_BY_HCL_KEY = Object.fromEntries(Object.entries(SYSTEM_FIELD_HCL_KEY_BY_KEY).map(([key, hclKey]) => [hclKey, key]));
107
122
  /**
108
123
  * What a NO-OVERRIDE deploy produces — the terraform provider's auto-create
109
124
  * display names. This is the baseline the pull printer compares against when
@@ -42,6 +42,8 @@ export interface PicklistOption {
42
42
  readonly id: string;
43
43
  readonly label: string;
44
44
  readonly parentValues?: readonly PicklistOption[];
45
+ readonly active?: boolean;
46
+ readonly icon?: string;
45
47
  /**
46
48
  * Optional tags on this option. See {@link PicklistOptionTag}
47
49
  * for the supported values and what they drive on the platform.
@@ -212,7 +214,12 @@ export interface NormalizedPicklistDynamicConfig {
212
214
  readonly relatedAspectId: AppOrElementRef | string;
213
215
  readonly relatedLabelFieldId: string | {
214
216
  readonly ownerRefName: string;
217
+ readonly ownerKind?: "app" | "element";
218
+ readonly ownerName?: string;
219
+ readonly ownerNamespace?: string;
215
220
  readonly fieldKey: string;
221
+ readonly fieldName?: string;
222
+ readonly fieldType?: string;
216
223
  };
217
224
  /**
218
225
  * A field on the SAME owning aspect (not `relatedAspectId`'s target) — the
@@ -221,16 +228,16 @@ export interface NormalizedPicklistDynamicConfig {
221
228
  * `fieldKeyFromTfRef`, same as `AppField.parentField`'s sibling mechanism).
222
229
  */
223
230
  readonly parentFieldId?: string;
231
+ readonly parentMappings?: readonly {
232
+ readonly parentAspectFieldId: FieldRef | string;
233
+ readonly relatedAspectFieldId: FieldRef | string;
234
+ }[];
224
235
  readonly autoRelate?: boolean;
225
236
  readonly valuesRenderType?: string;
226
237
  readonly filter?: Filter<RefExpr, RefExpr>;
227
238
  readonly sort?: Readonly<Record<string, unknown>>;
228
239
  }
229
- /**
230
- * Only `dynamic` round-trips through the terraform path today — a `static`
231
- * variant exists on the platform (filter/sort/parentFieldId over a fixed
232
- * option list) but has no terraform attribute yet (see `field/to-tf.ts`).
233
- */
240
+ /** Pulled dynamic configuration. Static dependency metadata is carried on `NormalizedField.parentLinkage`. */
234
241
  export interface NormalizedPicklistConfig {
235
242
  readonly dynamic?: NormalizedPicklistDynamicConfig;
236
243
  }
@@ -266,10 +273,8 @@ export interface NormalizedPicklistConfig {
266
273
  * } satisfies PicklistAppField;
267
274
  * ```
268
275
  *
269
- * This dependent-option-link mechanism (`parentField`/`parentValues`) is a
270
- * DIFFERENT, still-unimplemented feature from `config.dynamic`'s own
271
- * `parentFieldId` (a dynamic picklist's cascading-parent trigger) — see
272
- * `field/to-tf.ts`'s handling of `relatedParentValues`.
276
+ * This dependent-option-link mechanism (`parentField`/`parentValues`) is
277
+ * distinct from `config.dynamic`'s cascading parent/source-field mappings.
273
278
  */
274
279
  export interface PicklistAppFieldBase<Scope extends FieldScope = "unscoped"> extends AspectFieldBase<Scope> {
275
280
  readonly options?: Readonly<Record<string, PicklistOption>>;
@@ -1,2 +1,2 @@
1
1
  /** Re-export — canonical home is `src/entities/shared/types/platform.ts`. */
2
- export type { Attachment, Employee, Group, Manager, PicklistValue, RichText, User, } from "../../entities/shared/types/platform.js";
2
+ export type { Attachment, Employee, Group, Manager, DropdownValue, DynamicDropdownValue, RecordId, RichText, User, } from "../../entities/shared/types/platform.js";
@@ -98,6 +98,8 @@ export interface ToTfContext {
98
98
  readonly orgRefs: OrgRefLookup;
99
99
  /** Degradations land here — reported by the caller, never silent. */
100
100
  readonly diagnostics: string[];
101
+ /** Informational build reports, kept separate from warnings. */
102
+ readonly reports?: string[];
101
103
  /**
102
104
  * Every app/element stream root discovered in THIS build, keyed by
103
105
  * {@link workspaceAspectKey} — lets a cross-aspect reference (e.g. a
@@ -111,4 +113,6 @@ export interface ToTfContext {
111
113
  * supply it.
112
114
  */
113
115
  readonly workspaceAspects?: ReadonlyMap<string, WorkspaceAspect>;
116
+ /** App-local automations whose workflow_publish block is emitted in this build. */
117
+ readonly activeAutomationRefNames?: ReadonlySet<string>;
114
118
  }
@@ -56,8 +56,15 @@ export interface FromTfContext {
56
56
  /** `data.<field-type>.<label>` → generated ref-only catalog member. */
57
57
  readonly foreignFieldRefsByDataAddress?: ReadonlyMap<string, {
58
58
  readonly ownerRefName: string;
59
+ readonly ownerKind?: "app" | "element";
60
+ readonly ownerName?: string;
61
+ readonly ownerNamespace?: string;
59
62
  readonly fieldKey: string;
63
+ readonly fieldName?: string;
64
+ readonly fieldType?: string;
60
65
  }>;
66
+ /** Lower-cased field display name -> typed field key for each on-disk app/element catalog. */
67
+ readonly fieldNamesByOwnerRefName?: ReadonlyMap<string, ReadonlyMap<string, string>>;
61
68
  /**
62
69
  * Foreign app/element display names this stream saw referenced (currently:
63
70
  * a RELATION field's `related_object_id` as a `data.elementum_app`/
@@ -91,6 +98,8 @@ export interface FromTfContext {
91
98
  resourcesOfType?(type: string): readonly ImportedResourceRef[];
92
99
  /** Degradations land here — reported by the caller, never silent. */
93
100
  readonly diagnostics: string[];
101
+ /** Informational extraction reports, kept separate from warnings. */
102
+ readonly reports?: string[];
94
103
  /**
95
104
  * Resource addresses that must NOT be adopted - nothing in authored
96
105
  * source can reproduce them (e.g. a known-but-unimplemented field
@@ -19,6 +19,15 @@ export interface DirectReferenceRoot {
19
19
  readonly automations: readonly {
20
20
  readonly refName: string;
21
21
  readonly name: string;
22
+ readonly trigger: readonly {
23
+ readonly refName: string;
24
+ readonly name: string;
25
+ readonly required?: true;
26
+ }[];
27
+ readonly outputs: readonly {
28
+ readonly refName: string;
29
+ readonly name: string;
30
+ }[];
22
31
  }[];
23
32
  }
24
33
  export type UnresolvedReference = UnresolvedReferenceDiagnostic;
@@ -33,5 +42,10 @@ export interface RefOnlyMetadata {
33
42
  export declare function readRefOnlyMetadata(doc: TfDocument): RefOnlyMetadata;
34
43
  export declare function fieldDataReferenceMap(doc: TfDocument, roots: readonly DirectReferenceRoot[]): ReadonlyMap<string, {
35
44
  readonly ownerRefName: string;
45
+ readonly ownerKind?: "app" | "element";
46
+ readonly ownerName?: string;
47
+ readonly ownerNamespace?: string;
36
48
  readonly fieldKey: string;
49
+ readonly fieldName?: string;
50
+ readonly fieldType?: string;
37
51
  }>;
@@ -86,7 +86,32 @@ function parseRoot(payload) {
86
86
  return [];
87
87
  const automationName = stringAt(automation, "name");
88
88
  const automationRefName = stringAt(automation, "refName");
89
- return automationName === undefined || automationRefName === undefined ? [] : [{ refName: tfLabelToTsLabel(automationRefName), name: automationName }];
89
+ if (automationName === undefined || automationRefName === undefined)
90
+ return [];
91
+ const trigger = (Array.isArray(automation.trigger) ? automation.trigger : []).flatMap((rawParam) => {
92
+ const param = record(rawParam);
93
+ if (param === undefined)
94
+ return [];
95
+ const name = stringAt(param, "name");
96
+ const refName = stringAt(param, "refName");
97
+ return name === undefined || refName === undefined
98
+ ? []
99
+ : [{ refName: tfLabelToTsLabel(refName), name, ...(param.required === true ? { required: true } : {}) }];
100
+ });
101
+ const outputs = (Array.isArray(automation.outputs) ? automation.outputs : []).flatMap((rawOutput) => {
102
+ const output = record(rawOutput);
103
+ if (output === undefined)
104
+ return [];
105
+ const name = stringAt(output, "name");
106
+ const refName = stringAt(output, "refName");
107
+ return name === undefined || refName === undefined ? [] : [{ refName: tfLabelToTsLabel(refName), name }];
108
+ });
109
+ return [{
110
+ refName: tfLabelToTsLabel(automationRefName),
111
+ name: automationName,
112
+ trigger,
113
+ outputs,
114
+ }];
90
115
  });
91
116
  return {
92
117
  kind,
@@ -198,7 +223,15 @@ export function fieldDataReferenceMap(doc, roots) {
198
223
  const owner = ownerByDataAddress.get(`${ownerExpr.type}.${ownerExpr.label}`);
199
224
  const field = owner?.fields.find((candidate) => candidate.name === block.attrs.name);
200
225
  if (owner !== undefined && field !== undefined)
201
- out.set(`${block.type}.${block.label}`, { ownerRefName: owner.refName, fieldKey: field.refName });
226
+ out.set(`${block.type}.${block.label}`, {
227
+ ownerRefName: owner.refName,
228
+ ...(owner.kind === "app" || owner.kind === "element" ? { ownerKind: owner.kind } : {}),
229
+ ownerName: owner.name,
230
+ ...(owner.namespace !== undefined ? { ownerNamespace: owner.namespace } : {}),
231
+ fieldKey: field.refName,
232
+ fieldName: field.name,
233
+ fieldType: field.fieldType,
234
+ });
202
235
  }
203
236
  return out;
204
237
  }
@@ -12,13 +12,25 @@
12
12
  */
13
13
  import { EntityTfError } from "../../engine/entity.js";
14
14
  import { dataRefLabel, resourceRefLabel } from "../../engine/pull/context.js";
15
- import { isTfExpr, scopedLabelToBagKey, tfLabelToTsLabel } from "../../engine/tf/index.js";
15
+ import { appResourceLabelPrefix, elementResourceLabelPrefix, isTfExpr, scopedLabelToBagKey, tfLabelToTsLabel, } from "../../engine/tf/index.js";
16
16
  import { filterFromTf as deserializeFilterFromTf } from "../shared/filters/tf-codec.js";
17
17
  import { groupId, userId, } from "./principal.js";
18
18
  import { KNOWN_ACCESS_POLICY_ATTRS } from "./types.js";
19
19
  function fieldRef(value, owner, where) {
20
20
  if (isTfExpr(value) && value.$expr === "resource-attr" && value.type.endsWith("_field") && value.path[0] === "id") {
21
- return { kind: "field", appHandle: owner.ownerRefName, fieldKey: scopedLabelToBagKey(owner.ownerTfLabel, value.label, owner.scope) };
21
+ // scopedLabelToBagKey's stripping is a documented no-op when the label
22
+ // isn't actually prefixed for this owner (src/engine/tf/labels.ts) - it
23
+ // would otherwise "succeed" here with a garbled key and the wrong
24
+ // appHandle for a field that belongs to a DIFFERENT aspect than `owner`
25
+ // (e.g. a relationship's filter referencing the TARGET's own field, not
26
+ // the relationship's owner - edk#650 review). Only take this branch when
27
+ // the label actually belongs to `owner`; otherwise fall through so a
28
+ // caller's owner-then-target retry (relationship/from-tf.ts) or the
29
+ // final throw below can handle it instead of a silent wrong answer.
30
+ const prefix = owner.scope === "element" ? elementResourceLabelPrefix(owner.ownerTfLabel) : appResourceLabelPrefix(owner.ownerTfLabel);
31
+ if (value.label.startsWith(prefix)) {
32
+ return { kind: "field", appHandle: owner.ownerRefName, fieldKey: scopedLabelToBagKey(owner.ownerTfLabel, value.label, owner.scope) };
33
+ }
22
34
  }
23
35
  // A system field (status/title/id/stage/…) has no own resource block — ei
24
36
  // addresses its id via a `<ownerTfLabel>_<field>_field_id` local instead
@@ -41,6 +41,12 @@ export interface AccessPolicyToTfContext {
41
41
  /** Filter conversion only needs owner/field context; org lookups are accepted so full policy contexts remain assignable. */
42
42
  export interface FilterToTfContext extends Omit<AccessPolicyToTfContext, "orgRefs"> {
43
43
  readonly orgRefs?: OrgRefLookup;
44
+ /**
45
+ * List/agent/calendar view filters are exported as option labels, not
46
+ * `local.*_options_by_label` lookups. Resolving labels to option UUIDs
47
+ * plans live views that still hold the label (Sanofi `submitted`).
48
+ */
49
+ readonly resolvePicklistLiterals?: boolean;
44
50
  }
45
51
  export interface AccessPolicyToTfResult {
46
52
  readonly block: TfBlock;
@@ -61,8 +61,11 @@ export function filterToTf(f, where, ctx) {
61
61
  },
62
62
  reference: () => { throw new EntityTfError(`${where}: access-policy filters do not support reference values`); },
63
63
  literal: (value, field) => {
64
- if (typeof value === "string")
64
+ if (typeof value === "string") {
65
+ if (ctx.resolvePicklistLiterals === false)
66
+ return value;
65
67
  return picklistLiteralToTf(value, isFieldToken(field) ? field : undefined, ctx) ?? value;
68
+ }
66
69
  return value;
67
70
  },
68
71
  });
@@ -257,6 +257,8 @@ function printA2ASkill(skill) {
257
257
  function fieldOwnerRef(tool, appRefName, foreignAppRefNames, foreignElementRefNames) {
258
258
  if (tool.target === undefined || tool.target.kind === "self")
259
259
  return { kind: "catalog", expr: `catalog.${appRefName}` };
260
+ if (tool.target.kind === "unresolved")
261
+ return { kind: "raw", entityType: "app", name: tool.target.uuid };
260
262
  if (tool.target.kind === "foreignApp") {
261
263
  const foreignRefName = foreignAppRefNames?.get(tool.target.name);
262
264
  return foreignRefName !== undefined
@@ -355,6 +357,13 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
355
357
  // element.)
356
358
  lines.push(` ${tool.typeKey === "searchTable" ? "element" : "app"}: catalog.${appRefName},`);
357
359
  }
360
+ else if (tool.target?.kind === "unresolved") {
361
+ // Export couldn't resolve target_id to any portable app/element
362
+ // reference (board issue #648) — keep the raw platform id visible and
363
+ // cast past the type system instead of silently dropping the tool.
364
+ const entityKind = tool.typeKey === "searchTable" ? "element" : "app";
365
+ lines.push(` ${entityKind}: ${quote(tool.target.uuid)} as any /* TODO: unresolved ${entityKind} - export couldn't resolve target_id to a portable reference; replace with a real ref before deploying */,`);
366
+ }
358
367
  else if (tool.target !== undefined && tool.target.kind === "foreignApp") {
359
368
  const foreignRefName = foreignAppRefNames?.get(tool.target.name);
360
369
  if (foreignRefName !== undefined) {
@@ -390,6 +399,12 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
390
399
  if (tool.typeKey === "relateRecord" && tool.relatedTarget?.kind === "self") {
391
400
  lines.push(` relatedApp: catalog.${appRefName},`);
392
401
  }
402
+ else if (tool.typeKey === "relateRecord" && tool.relatedTarget?.kind === "unresolved") {
403
+ // Export couldn't resolve related_target_id to any portable reference
404
+ // (board issue #648) — keep the raw platform id visible instead of
405
+ // silently dropping the tool.
406
+ lines.push(` relatedApp: ${quote(tool.relatedTarget.uuid)} as any /* TODO: unresolved relatedApp - export couldn't resolve related_target_id to a portable reference; replace with a real ref before deploying */,`);
407
+ }
393
408
  else if (tool.typeKey === "relateRecord" && tool.relatedTarget?.kind === "foreignApp") {
394
409
  const foreignRefName = foreignAppRefNames?.get(tool.relatedTarget.name);
395
410
  if (foreignRefName !== undefined) {
@@ -434,7 +449,9 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
434
449
  lines.push(` table: catalog.${targetRefName ?? appRefName}.searchTables${safeMember(tool.searchTableKey)},`);
435
450
  }
436
451
  else {
437
- const parent = tool.target?.kind === "self" ? appRefName : tool.target?.name ?? "";
452
+ const parent = tool.target?.kind === "self"
453
+ ? appRefName
454
+ : tool.target?.kind === "unresolved" ? tool.target.uuid : tool.target?.name ?? "";
438
455
  const typedTable = tool.searchTableName === undefined
439
456
  ? undefined
440
457
  : foreignSearchTableRefsByName?.get(JSON.stringify([parent, tool.searchTableName]));
@@ -116,6 +116,7 @@ export const agentModule = {
116
116
  serviceAccounts: ctx.streamRootEntity?.payload?.serviceAccounts,
117
117
  diagnostics: ctx.diagnostics,
118
118
  ...(ctx.siblingEntities !== undefined && { siblingEntities: ctx.siblingEntities }),
119
+ ...(ctx.activeAutomationRefNames !== undefined && { activeAutomationRefNames: ctx.activeAutomationRefNames }),
119
120
  }),
120
121
  },
121
122
  catalog: {
@@ -38,6 +38,7 @@ export interface AgentToTfContext {
38
38
  * behavior.
39
39
  */
40
40
  readonly siblingEntities?: readonly DeployableEntity[];
41
+ readonly activeAutomationRefNames?: ReadonlySet<string>;
41
42
  }
42
43
  export interface AgentToTfResult {
43
44
  readonly blocks: readonly TfBlock[];
@@ -285,6 +285,7 @@ export function agentToTf(entity, ctx) {
285
285
  appRefName: ctx.appRefName,
286
286
  appTfLabel: ctx.appTfLabel,
287
287
  agentBareTfLabel,
288
+ activeAutomationRefNames: ctx.activeAutomationRefNames,
288
289
  foreignAppRef: (l, n, ns) => ctx.orgRefs.foreignApp(l, n, ns),
289
290
  foreignElementRef: (l, n, ns) => ctx.orgRefs.foreignElement(l, n, ns),
290
291
  foreignAutomationRef: (l, n, owner) => {
@@ -50,6 +50,15 @@ export type NormalizedToolTarget = {
50
50
  /** A foreign ELEMENT via `data.elementum_element.<label>` — `name` from the stream's data block (board issue #42). */
51
51
  readonly kind: "foreignElement";
52
52
  readonly name: string;
53
+ } | {
54
+ /**
55
+ * `target_id` didn't resolve to any portable reference at export
56
+ * time (ei fell back to a bare platform UUID — board issue #648).
57
+ * Kept, not dropped, so the tool's other data survives the pull; the
58
+ * printer marks it with a TODO instead of silently losing the tool.
59
+ */
60
+ readonly kind: "unresolved";
61
+ readonly uuid: string;
53
62
  };
54
63
  export interface NormalizedExecuteWorkflowInput {
55
64
  /** The published workflow's declared trigger parameter name. */