@elementumai/edk 0.9.14 → 0.9.16

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 (124) hide show
  1. package/dist-sdk/pull/util.d.ts +0 -15
  2. package/dist-sdk/pull/util.js +44 -5
  3. package/dist-sdk/src/catalog/factories.d.ts +4 -2
  4. package/dist-sdk/src/catalog/factories.js +4 -0
  5. package/dist-sdk/src/catalog/from-authoring.js +5 -1
  6. package/dist-sdk/src/catalog/index.d.ts +2 -2
  7. package/dist-sdk/src/catalog/index.js +1 -1
  8. package/dist-sdk/src/catalog/token.js +2 -2
  9. package/dist-sdk/src/catalog/types.d.ts +7 -2
  10. package/dist-sdk/src/core/types/app.d.ts +4 -4
  11. package/dist-sdk/src/engine/build/context.d.ts +5 -4
  12. package/dist-sdk/src/engine/build/source-context.d.ts +2 -0
  13. package/dist-sdk/src/engine/build/source-context.js +16 -0
  14. package/dist-sdk/src/engine/progress.d.ts +19 -1
  15. package/dist-sdk/src/engine/progress.js +33 -5
  16. package/dist-sdk/src/engine/pull/context.d.ts +9 -1
  17. package/dist-sdk/src/engine/pull/ref-only.d.ts +6 -2
  18. package/dist-sdk/src/engine/pull/ref-only.js +14 -3
  19. package/dist-sdk/src/engine/workspace/loader.js +23 -2
  20. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +1 -1
  21. package/dist-sdk/src/entities/access-policy/from-tf.js +47 -12
  22. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +5 -3
  23. package/dist-sdk/src/entities/access-policy/to-tf.js +23 -1
  24. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +6 -0
  25. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +50 -4
  26. package/dist-sdk/src/entities/agent/from-tf.d.ts +1 -0
  27. package/dist-sdk/src/entities/agent/from-tf.js +18 -3
  28. package/dist-sdk/src/entities/agent/module.js +1 -0
  29. package/dist-sdk/src/entities/agent/to-tf.js +15 -0
  30. package/dist-sdk/src/entities/agent/tools.d.ts +98 -5
  31. package/dist-sdk/src/entities/agent/tools.js +12 -3
  32. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +15 -0
  33. package/dist-sdk/src/entities/agent-tool/from-tf.js +47 -4
  34. package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +9 -0
  35. package/dist-sdk/src/entities/agent-tool/to-tf.js +82 -25
  36. package/dist-sdk/src/entities/app/build.d.ts +2 -2
  37. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +4 -4
  38. package/dist-sdk/src/entities/app/module.js +8 -0
  39. package/dist-sdk/src/entities/app/to-tf.js +1 -0
  40. package/dist-sdk/src/entities/approval-chain/build.d.ts +8 -1
  41. package/dist-sdk/src/entities/approval-chain/build.js +3 -0
  42. package/dist-sdk/src/entities/approval-chain/from-tf.d.ts +2 -1
  43. package/dist-sdk/src/entities/approval-chain/from-tf.js +20 -7
  44. package/dist-sdk/src/entities/approval-chain/printer.js +13 -2
  45. package/dist-sdk/src/entities/approval-chain/to-tf.js +3 -0
  46. package/dist-sdk/src/entities/automation/build.d.ts +19 -12
  47. package/dist-sdk/src/entities/automation/build.js +36 -13
  48. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +4 -0
  49. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +19 -0
  50. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +222 -65
  51. package/dist-sdk/src/entities/automation/from-tf.d.ts +86 -6
  52. package/dist-sdk/src/entities/automation/from-tf.js +360 -63
  53. package/dist-sdk/src/entities/automation/index.d.ts +3 -2
  54. package/dist-sdk/src/entities/automation/index.js +3 -2
  55. package/dist-sdk/src/entities/automation/module.js +21 -16
  56. package/dist-sdk/src/entities/automation/output-field-types.d.ts +5 -0
  57. package/dist-sdk/src/entities/automation/output-field-types.js +12 -0
  58. package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +20 -0
  59. package/dist-sdk/src/entities/automation/output-key-wire-name.js +22 -0
  60. package/dist-sdk/src/entities/automation/script-code.d.ts +32 -0
  61. package/dist-sdk/src/entities/automation/script-code.js +72 -5
  62. package/dist-sdk/src/entities/automation/tasks.d.ts +60 -24
  63. package/dist-sdk/src/entities/automation/tasks.js +33 -14
  64. package/dist-sdk/src/entities/automation/to-tf.d.ts +0 -2
  65. package/dist-sdk/src/entities/automation/to-tf.js +123 -46
  66. package/dist-sdk/src/entities/automation/triggers.d.ts +5 -2
  67. package/dist-sdk/src/entities/automation/types.d.ts +2 -0
  68. package/dist-sdk/src/entities/automation/types.js +5 -0
  69. package/dist-sdk/src/entities/automation/workflow-output.d.ts +35 -0
  70. package/dist-sdk/src/entities/automation/workflow-output.js +53 -0
  71. package/dist-sdk/src/entities/chart/build.d.ts +3 -3
  72. package/dist-sdk/src/entities/chart/from-tf.d.ts +2 -2
  73. package/dist-sdk/src/entities/chart/from-tf.js +20 -13
  74. package/dist-sdk/src/entities/chart/to-tf.js +7 -5
  75. package/dist-sdk/src/entities/dashboard/from-tf.js +1 -1
  76. package/dist-sdk/src/entities/dashboard/to-tf.js +1 -0
  77. package/dist-sdk/src/entities/dynamic-layout/from-tf.js +3 -2
  78. package/dist-sdk/src/entities/element/build.d.ts +11 -8
  79. package/dist-sdk/src/entities/element/build.js +14 -5
  80. package/dist-sdk/src/entities/element/locals.d.ts +2 -2
  81. package/dist-sdk/src/entities/element/locals.js +6 -2
  82. package/dist-sdk/src/entities/element/system-fields.d.ts +4 -0
  83. package/dist-sdk/src/entities/element/system-fields.js +12 -0
  84. package/dist-sdk/src/entities/element/to-tf.js +1 -0
  85. package/dist-sdk/src/entities/field/build.d.ts +2 -2
  86. package/dist-sdk/src/entities/field/from-tf.js +82 -4
  87. package/dist-sdk/src/entities/field/to-tf.d.ts +1 -1
  88. package/dist-sdk/src/entities/field/to-tf.js +11 -4
  89. package/dist-sdk/src/entities/record-create-form/from-tf.js +3 -2
  90. package/dist-sdk/src/entities/relationship/from-tf.js +8 -5
  91. package/dist-sdk/src/entities/relationship/to-tf.js +13 -3
  92. package/dist-sdk/src/entities/search-table/from-tf.js +6 -6
  93. package/dist-sdk/src/entities/search-table/module.js +2 -2
  94. package/dist-sdk/src/entities/search-table/types.d.ts +1 -0
  95. package/dist-sdk/src/entities/search-table/types.js +1 -0
  96. package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +3 -3
  97. package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +10 -6
  98. package/dist-sdk/src/entities/shared/filters/ast.d.ts +4 -2
  99. package/dist-sdk/src/entities/shared/filters/index.d.ts +12 -2
  100. package/dist-sdk/src/entities/shared/filters/index.js +17 -1
  101. package/dist-sdk/src/entities/shared/filters/print.js +25 -11
  102. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +1 -1
  103. package/dist-sdk/src/entities/shared/filters/tf-codec.js +39 -7
  104. package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +1 -1
  105. package/dist-sdk/src/entities/shared/tool-field-ref.js +6 -2
  106. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +6 -0
  107. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +47 -18
  108. package/dist-sdk/src/entities/skill/module.js +10 -0
  109. package/dist-sdk/src/entities/skill/to-tf.js +19 -0
  110. package/dist-sdk/src/entities/skill/tools.d.ts +29 -7
  111. package/dist-sdk/src/entities/skill/tools.js +6 -2
  112. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +18 -0
  113. package/dist-sdk/src/entities/skill-tool/from-tf.js +77 -4
  114. package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +8 -0
  115. package/dist-sdk/src/entities/skill-tool/to-tf.js +90 -46
  116. package/dist-sdk/src/entities/task/module.js +1 -1
  117. package/dist-sdk/src/entities/view/from-tf.js +30 -9
  118. package/dist-sdk/src/entities/view/to-tf.js +18 -10
  119. package/dist-sdk/src/entities/widget/from-tf.js +3 -3
  120. package/dist-sdk/src/entities/widget/to-tf.js +1 -0
  121. package/dist-sdk/src/graph/index.d.ts +15 -0
  122. package/dist-sdk/src/graph/index.js +19 -0
  123. package/dist-sdk/src/graph/types.d.ts +37 -1
  124. package/package.json +2 -1
@@ -48,21 +48,6 @@ export declare function stripType(props: {
48
48
  * decide what fallback to use (e.g. `"item1"`).
49
49
  */
50
50
  export declare function camelCase(input: string): string;
51
- /**
52
- * Mobius's `ValueReference.ofTriggerReference` canonicalizes onDemand
53
- * parameter reference names so the UI picker can resolve them:
54
- * - all alphanumeric → first char lowercased (`amountUsd` stays
55
- * `amountUsd`, `AmountUsd` → `amountUsd`)
56
- * - contains non-alnum char → camelCase via {@link camelCase}
57
- * (`amount_usd` → `amountUsd`,
58
- * `has receipt` → `hasReceipt`)
59
- *
60
- * Lives here (not in the serializer) because both sides of the wire
61
- * need it: the serializer applies it on-write so saved triggerReference
62
- * names match the picker's canonical form, and the deserializer
63
- * applies it on-read to map wire reference names back to the source's
64
- * declared parameter names.
65
- */
66
51
  export declare function normalizeOnDemandParamKey(name: string): string;
67
52
  /**
68
53
  * Pair each item with a unique camelCase key derived from
@@ -74,9 +74,21 @@ export function camelCase(input) {
74
74
  * parameter reference names so the UI picker can resolve them:
75
75
  * - all alphanumeric → first char lowercased (`amountUsd` stays
76
76
  * `amountUsd`, `AmountUsd` → `amountUsd`)
77
- * - contains non-alnum char → camelCase via {@link camelCase}
77
+ * - contains non-alnum char → every letter lowercased, then the first
78
+ * letter after each separator uppercased
78
79
  * (`amount_usd` → `amountUsd`,
79
- * `has receipt` → `hasReceipt`)
80
+ * `has receipt` → `hasReceipt`,
81
+ * `CFF_ID` → `cffId` — NOT `cFFId`)
82
+ *
83
+ * Deliberately NOT delegated to the shared {@link camelCase} (title-cases
84
+ * each word's ORIGINAL casing beyond its first letter, so `CFF_ID` → `cFFId`
85
+ * there) - this must match the platform's exact
86
+ * `normalizeOnDemandFilterRefName` (provider/internal/provider/
87
+ * on_demand_trigger_resource.go) byte for byte, or a multi-uppercase-letter
88
+ * acronym parameter name (confirmed live: `CFF_ID`, `HCP_ID`, `REP_ID` on
89
+ * conciergeforfield/sanofi) computes a filter_refs/refs key the deployed
90
+ * trigger never actually has, and `tofu plan` fails with "Invalid index"
91
+ * on every filter/task referencing it.
80
92
  *
81
93
  * Lives here (not in the serializer) because both sides of the wire
82
94
  * need it: the serializer applies it on-write so saved triggerReference
@@ -84,13 +96,40 @@ export function camelCase(input) {
84
96
  * applies it on-read to map wire reference names back to the source's
85
97
  * declared parameter names.
86
98
  */
99
+ function toSimpleLower(ch) {
100
+ if (ch === "İ")
101
+ return "i";
102
+ const lower = ch.toLowerCase();
103
+ return [...lower].length === 1 ? lower : ch;
104
+ }
105
+ function toSimpleUpper(ch) {
106
+ const upper = ch.toUpperCase();
107
+ return [...upper].length === 1 ? upper : ch;
108
+ }
87
109
  export function normalizeOnDemandParamKey(name) {
88
110
  if (!name)
89
111
  return "";
90
- if (/[^A-Za-z0-9]/.test(name)) {
91
- return camelCase(name);
112
+ // Unicode letter/decimal digit, matching Go's unicode.IsLetter/IsDigit - plain
113
+ // [A-Za-z0-9] treats non-ASCII letters as separators (dropping 'Ä' to produce
114
+ // "BcId" instead of "äbcId"), while \p{N} is too broad (treating non-decimal
115
+ // numbers like Roman numerals or fractions as alnum, which Go separates).
116
+ const chars = [...name];
117
+ const hasSeparator = chars.some((ch) => !/[\p{L}\p{Nd}]/u.test(ch));
118
+ if (!hasSeparator) {
119
+ return toSimpleLower(chars[0]) + chars.slice(1).join("");
120
+ }
121
+ let result = "";
122
+ let nextIsUpper = false;
123
+ for (const ch of chars) {
124
+ if (/[\p{L}\p{Nd}]/u.test(ch)) {
125
+ result += nextIsUpper ? toSimpleUpper(ch) : toSimpleLower(ch);
126
+ nextIsUpper = false;
127
+ }
128
+ else {
129
+ nextIsUpper = true;
130
+ }
92
131
  }
93
- return name.charAt(0).toLowerCase() + name.substring(1);
132
+ return result;
94
133
  }
95
134
  /**
96
135
  * Pair each item with a unique camelCase key derived from
@@ -21,8 +21,8 @@
21
21
  * nothing reads those interim values.
22
22
  */
23
23
  import type { AiProviderLlmModel, AiProviderType } from "./ai-provider-models.js";
24
- import type { AgentEvaluationRef, AgentRef, AppCatalogRef, AppOrElementRef, AiProviderRef, ApprovalChainRef, AutomationCatalogRef, CatalogRef, CategoryRef, ChartRef, DashboardRef, WidgetRef, CloudLinkRef, ConnectorRef, DatamineRef, GroupRef, PhoneProviderRef, PhoneServiceRef, ProcedureParameterType, ProcedureRef, FileReaderCatalogRef, DocumentModelFieldRef, ElementCatalogRef, FieldRef, OutputPropertyRef, RecordIdentityRef, SearchTableRef, StoredFunctionRef, StoredFunctionScalarType, SkillRef, TableColumnRef, TableOwnedSearchTableRef, TableRef, TriggerParameterRef } from "./types.js";
25
- export declare function recordIdentity<const Target extends AppOrElementRef | TableRef>(target: Target): RecordIdentityRef<Target>;
24
+ import type { AgentEvaluationRef, AgentRef, AppCatalogRef, AppOrElementRef, AiProviderRef, ApprovalChainRef, AutomationCatalogRef, CatalogRef, CategoryRef, ChartRef, DashboardRef, WidgetRef, CloudLinkRef, ConnectorRef, DatamineRef, GroupRef, PhoneProviderRef, PhoneServiceRef, ProcedureParameterType, ProcedureRef, FileReaderCatalogRef, DocumentModelFieldRef, ElementCatalogRef, FieldRef, OutputPropertyRef, RecordIdentityRef, SearchTableRef, StoredFunctionRef, StoredFunctionScalarType, SkillRef, TableColumnRef, TableOwnedSearchTableRef, TableRef, TaskCatalogRef, TriggerParameterRef } from "./types.js";
25
+ export declare function recordIdentity<const Target extends AppOrElementRef | TaskCatalogRef | TableRef>(target: Target): RecordIdentityRef<Target>;
26
26
  /** Fixed platform user-directory schema used by userSearch filters. */
27
27
  export declare const usersCatalog: {
28
28
  readonly fields: {
@@ -60,6 +60,8 @@ export declare function appRef<const RefName extends string>(refName: RefName, n
60
60
  export declare function elementRef<const RefName extends string>(refName: RefName, name?: string, namespace?: string): CatalogRef<"element", RefName> & {
61
61
  readonly namespace?: string;
62
62
  };
63
+ /** Lightweight typed task-owner token. Prefer the generated catalog in authored workspace source. */
64
+ export declare function taskRef<const RefName extends string>(refName: RefName, name?: string, namespace?: string): TaskCatalogRef<RefName>;
63
65
  /** An app/element catalog's bags: reference-only kinds plus behavioral kinds sourced from authoring files. */
64
66
  interface AppCatalogBags {
65
67
  readonly fields?: Record<string, FieldRef>;
@@ -18,6 +18,10 @@ export function appRef(refName, name = refName, namespace) {
18
18
  export function elementRef(refName, name = refName, namespace) {
19
19
  return { __kind: "element", refName, name, ...(namespace !== undefined ? { namespace } : {}) };
20
20
  }
21
+ /** Lightweight typed task-owner token. Prefer the generated catalog in authored workspace source. */
22
+ export function taskRef(refName, name = refName, namespace) {
23
+ return { __kind: "task", refName, name, ...(namespace !== undefined ? { namespace } : {}) };
24
+ }
21
25
  /** Build a ref-kind factory: no identity parameter, `.refName` defaults to `name` (stamped over by the enclosing bag). */
22
26
  function refFactory(kind) {
23
27
  return (opts) => ({ __kind: kind, refName: opts.name, ...opts });
@@ -23,7 +23,7 @@ import { mkdir, readdir, stat, writeFile } from "node:fs/promises";
23
23
  import { basename, dirname, join, resolve } from "node:path";
24
24
  import { createWorkspaceLoader } from "../engine/workspace/loader.js";
25
25
  import { writeTechnicalLog } from "../engine/progress.js";
26
- import { KIND_BY_ID, ownFileCatalogChildrenOf, } from "../graph/index.js";
26
+ import { companionDirsByBag, KIND_BY_ID, ownFileCatalogChildrenOf, } from "../graph/index.js";
27
27
  import { writeCatalogBarrel } from "./org.js";
28
28
  import { renderCatalog } from "./render.js";
29
29
  import { assertAuthoringPathForTenant, assertValidAuthoringLayout, isAuthoringHelperFile, isStreamRootAuthoringFile, } from "../engine/workspace/authoring-layout.js";
@@ -95,6 +95,10 @@ async function listEntityFilesRecursive(dir) {
95
95
  for (const entry of entries) {
96
96
  if (entry.isDirectory() && SKIP_DIR_NAMES.has(entry.name))
97
97
  continue;
98
+ // Printer-owned companion folders (an automation's plain-JS script
99
+ // files) hold no entity source.
100
+ if (entry.isDirectory() && companionDirsByBag().get(basename(dir))?.has(entry.name) === true)
101
+ continue;
98
102
  const full = join(dir, entry.name);
99
103
  if (entry.isDirectory())
100
104
  out.push(...(await listEntityFilesRecursive(full)));
@@ -4,9 +4,9 @@
4
4
  * ids appear here (identity lives in `src/deploy/state`).
5
5
  */
6
6
  export { AI_PROVIDER_LLM_MODELS, type AiProviderLlmModel, type AiProviderType } from "./ai-provider-models.js";
7
- export { REF_SCOPE, REF_UPDATABLE, type AgentRef, type AgentEvaluationRef, type AiProviderRef, type ApprovalChainRef, type ApprovalProcessRef, type AppCatalogRef, type AppOrElementRef, type AutomationCatalogRef, type AutomationRef, type CatalogRef, type CatalogRefKind, type CategoryRef, type ChartRef, type DashboardRef, type WidgetRef, type CloudLinkRef, type AiServiceRef, type ConnectorRef, type GroupRef, type PhoneProviderRef, type PhoneServiceRef, PROCEDURE_PARAMETER_TYPES, type ProcedureParameterType, type ProcedureRef, type FileReaderCatalogRef, type DocumentModelFieldRef, type ElementCatalogRef, type FieldRef, type OutputPropertyRef, type RecordIdentityRef, type SearchTableRef, type TableOwnedSearchTableRef, type StoredFunctionRef, type StoredFunctionScalarType, type DatamineRef, type SkillRef, type TableColumnRef, type TableRef, type TriggerParameterRef, USER_FIELD_KEYS, type UserFieldKey, type UserFieldRef, } from "./types.js";
7
+ export { REF_SCOPE, REF_UPDATABLE, type AgentRef, type AgentEvaluationRef, type AiProviderRef, type ApprovalChainRef, type ApprovalProcessRef, type AppCatalogRef, type AppOrElementRef, type AutomationCatalogRef, type AutomationRef, type CatalogRef, type CatalogRefKind, type CategoryRef, type ChartRef, type DashboardRef, type WidgetRef, type CloudLinkRef, type AiServiceRef, type ConnectorRef, type GroupRef, type PhoneProviderRef, type PhoneServiceRef, PROCEDURE_PARAMETER_TYPES, type ProcedureParameterType, type ProcedureRef, type FileReaderCatalogRef, type DocumentModelFieldRef, type ElementCatalogRef, type TaskCatalogRef, type AppOrElementOrTaskRef, type FieldRef, type OutputPropertyRef, type RecordIdentityRef, type SearchTableRef, type TableOwnedSearchTableRef, type StoredFunctionRef, type StoredFunctionScalarType, type DatamineRef, type SkillRef, type TableColumnRef, type TableRef, type TriggerParameterRef, USER_FIELD_KEYS, type UserFieldKey, type UserFieldRef, } from "./types.js";
8
8
  export { renderBarrel, renderCatalog, renderFragment, type BarrelEntry, type BarrelRoot, } from "./render.js";
9
9
  export { appCatalogTarget, barrelPathFor, orgCatalogTarget, regenerateBarrel, writeCatalog, writeFlatCatalog, writeFragment, type CatalogTarget, } from "./write.js";
10
10
  export { isCatalogToken, slimToken, slimTokens } from "./token.js";
11
11
  export { buildAppCatalogFromAuthoring, listEntityFilesFromPaths, refNameOf, regenerateAppCatalogsUnder, writeAppCatalog, writeAppCatalogFromAuthoring, type AppAuthoringCatalog, type AppCatalogRegenResult, type ConfiguredEntity, } from "./from-authoring.js";
12
- export { agentRef, agentEvaluationRef, appRef, appCatalog, approvalChainRef, automationRef, categoryRef, chartRef, dashboardRef, widgetRef, cloudLinkRef, connectorRef, aiProvider, groupRef, linkedSearchTableRef, phoneProviderRef, phoneServiceRef, procedureRef, documentModelFieldRef, documentModelRef, elementCatalog, elementRef, fieldRef, orgCatalog, outputPropertyRef, recordIdentity, searchTableRef, datamineRef, skillRef, storedFunctionRef, tableColumnRef, tableRef, tableSearchTableRef, triggerParameterRef, usersCatalog, } from "./factories.js";
12
+ export { agentRef, agentEvaluationRef, appRef, appCatalog, approvalChainRef, automationRef, categoryRef, chartRef, dashboardRef, widgetRef, cloudLinkRef, connectorRef, aiProvider, groupRef, linkedSearchTableRef, phoneProviderRef, phoneServiceRef, procedureRef, documentModelFieldRef, documentModelRef, elementCatalog, elementRef, fieldRef, orgCatalog, outputPropertyRef, recordIdentity, searchTableRef, datamineRef, skillRef, storedFunctionRef, tableColumnRef, tableRef, tableSearchTableRef, taskRef, triggerParameterRef, usersCatalog, } from "./factories.js";
@@ -9,4 +9,4 @@ export { renderBarrel, renderCatalog, renderFragment, } from "./render.js";
9
9
  export { appCatalogTarget, barrelPathFor, orgCatalogTarget, regenerateBarrel, writeCatalog, writeFlatCatalog, writeFragment, } from "./write.js";
10
10
  export { isCatalogToken, slimToken, slimTokens } from "./token.js";
11
11
  export { buildAppCatalogFromAuthoring, listEntityFilesFromPaths, refNameOf, regenerateAppCatalogsUnder, writeAppCatalog, writeAppCatalogFromAuthoring, } from "./from-authoring.js";
12
- export { agentRef, agentEvaluationRef, appRef, appCatalog, approvalChainRef, automationRef, categoryRef, chartRef, dashboardRef, widgetRef, cloudLinkRef, connectorRef, aiProvider, groupRef, linkedSearchTableRef, phoneProviderRef, phoneServiceRef, procedureRef, documentModelFieldRef, documentModelRef, elementCatalog, elementRef, fieldRef, orgCatalog, outputPropertyRef, recordIdentity, searchTableRef, datamineRef, skillRef, storedFunctionRef, tableColumnRef, tableRef, tableSearchTableRef, triggerParameterRef, usersCatalog, } from "./factories.js";
12
+ export { agentRef, agentEvaluationRef, appRef, appCatalog, approvalChainRef, automationRef, categoryRef, chartRef, dashboardRef, widgetRef, cloudLinkRef, connectorRef, aiProvider, groupRef, linkedSearchTableRef, phoneProviderRef, phoneServiceRef, procedureRef, documentModelFieldRef, documentModelRef, elementCatalog, elementRef, fieldRef, orgCatalog, outputPropertyRef, recordIdentity, searchTableRef, datamineRef, skillRef, storedFunctionRef, tableColumnRef, tableRef, tableSearchTableRef, taskRef, triggerParameterRef, usersCatalog, } from "./factories.js";
@@ -30,10 +30,10 @@ export function slimToken(token) {
30
30
  out.name = token.name;
31
31
  if (token.parent !== undefined)
32
32
  out.parent = token.parent;
33
- if ((token.__kind === "app" || token.__kind === "element") && typeof token.namespace === "string") {
33
+ if ((token.__kind === "app" || token.__kind === "element" || token.__kind === "task") && typeof token.namespace === "string") {
34
34
  out.namespace = token.namespace;
35
35
  }
36
- if ((token.parentKind === "app" || token.parentKind === "element"))
36
+ if (token.parentKind === "app" || token.parentKind === "element" || token.parentKind === "task")
37
37
  out.parentKind = token.parentKind;
38
38
  if (typeof token.parentName === "string")
39
39
  out.parentName = token.parentName;
@@ -199,9 +199,14 @@ export type ElementCatalogRef<RefName extends string = string> = CatalogRef<"ele
199
199
  /** Stable cross-organization lookup identity. Pulled/generated refs always carry it. */
200
200
  readonly namespace?: string;
201
201
  };
202
+ export type TaskCatalogRef<RefName extends string = string> = CatalogRef<"task", RefName> & {
203
+ /** Stable cross-organization lookup identity. Pulled/generated refs always carry it. */
204
+ readonly namespace?: string;
205
+ };
202
206
  export type AppOrElementRef<RefName extends string = string> = AppCatalogRef<RefName> | ElementCatalogRef<RefName>;
207
+ export type AppOrElementOrTaskRef<RefName extends string = string> = AppCatalogRef<RefName> | ElementCatalogRef<RefName> | TaskCatalogRef<RefName>;
203
208
  /** A record's own identity, referenceable without exposing its platform id. */
204
- export interface RecordIdentityRef<Target extends AppOrElementRef | TableRef = AppOrElementRef | TableRef> {
209
+ export interface RecordIdentityRef<Target extends AppOrElementRef | TaskCatalogRef | TableRef = AppOrElementRef | TaskCatalogRef | TableRef> {
205
210
  readonly __kind: "recordIdentity";
206
211
  readonly refName: "id";
207
212
  readonly name: "Record ID";
@@ -227,7 +232,7 @@ export interface FieldRef<Parent extends string = string, RefName extends string
227
232
  * `elementum_app` vs `elementum_element` for its owner lookup without
228
233
  * depending on the owner also appearing elsewhere in the same payload.
229
234
  */
230
- readonly parentKind?: "app" | "element";
235
+ readonly parentKind?: "app" | "element" | "task";
231
236
  /**
232
237
  * The parent's display NAME, stamped alongside `parent` for the same
233
238
  * reason `parentKind` is — a foreign owner lookup (`data.elementum_app` /
@@ -9,7 +9,7 @@
9
9
  */
10
10
  import { type Ref, type ValueOrRef } from "../../entities/shared/ref.js";
11
11
  import type { WorkflowFieldType } from "../../entities/shared/types/field-types.js";
12
- import type { AppOrElementRef, FieldRef } from "../../catalog/types.js";
12
+ import type { AppOrElementOrTaskRef, FieldRef } from "../../catalog/types.js";
13
13
  import type { RefExpr } from "../../entities/shared/filters/ast.js";
14
14
  import type { Filter } from "../../entities/shared/filters/types.js";
15
15
  import type { CloudLink } from "./cloud-link.js";
@@ -211,10 +211,10 @@ export interface JsonAppField<Scope extends FieldScope = "unscoped"> extends Asp
211
211
  * RefExpr>` shape `NormalizedAccessPolicy` already uses.
212
212
  */
213
213
  export interface NormalizedPicklistDynamicConfig {
214
- readonly relatedAspectId: AppOrElementRef | string;
214
+ readonly relatedAspectId: AppOrElementOrTaskRef | string;
215
215
  readonly relatedLabelFieldId: string | {
216
216
  readonly ownerRefName: string;
217
- readonly ownerKind?: "app" | "element";
217
+ readonly ownerKind?: "app" | "element" | "task";
218
218
  readonly ownerName?: string;
219
219
  readonly ownerNamespace?: string;
220
220
  readonly fieldKey: string;
@@ -336,7 +336,7 @@ export interface AttachmentAppField<Scope extends FieldScope = "unscoped"> exten
336
336
  */
337
337
  export interface RelationAppField<Scope extends FieldScope = "unscoped"> extends AspectFieldBase<Scope> {
338
338
  readonly type: "RELATION";
339
- readonly relatedObject: AppOrElementRef | string;
339
+ readonly relatedObject: AppOrElementOrTaskRef | string;
340
340
  readonly relatedLabelField: FieldRef | string;
341
341
  /** Defaults to `true` on the platform. */
342
342
  readonly autoRelate?: boolean;
@@ -50,6 +50,7 @@ export interface OrgRefLookup {
50
50
  byName(bag: string, name: string): OrgRefResolution | undefined;
51
51
  /** Legacy typed convenience routed through app's graph-declared root strategy. */
52
52
  foreignApp(tfLabel: string, name: string, namespace?: string): void;
53
+ foreignTask(tfLabel: string, name: string, namespace?: string): void;
53
54
  /**
54
55
  * Record a name-keyed `data.elementum_agentic_skill` lookup for a FOREIGN
55
56
  * skill (an agent's `skillAccess` pointing at a skill owned by a
@@ -85,12 +86,12 @@ export interface OrgRefLookup {
85
86
  }
86
87
  /** A stream root discovered elsewhere in THIS workspace build, keyed by {@link workspaceAspectKey}. */
87
88
  export interface WorkspaceAspect {
88
- readonly kind: ChildResourceScope | "table";
89
+ readonly kind: ChildResourceScope | "table" | "task";
89
90
  readonly tfLabel: string;
90
91
  /** Loaded stream root, available to entity-owned cross-stream resolvers. */
91
92
  readonly streamRootEntity?: DeployableEntity;
92
- /** ACTIVE authored automations owned by this root, keyed by source refName with their display name. */
93
- readonly activeAutomationNamesByRefName?: ReadonlyMap<string, string>;
93
+ /** Source refNames of ACTIVE authored automations owned by this root. */
94
+ readonly activeAutomationRefNames?: ReadonlySet<string>;
94
95
  /** Sole on-demand record parameter targeting this same owner, keyed by automation refName, for CURRENT_RECORD widget binding. */
95
96
  readonly onDemandRecordParamByAutomationRefName?: ReadonlyMap<string, string>;
96
97
  /** Terraform labels of datamines managed by a table in this workspace. */
@@ -106,7 +107,7 @@ export interface WorkspaceAspect {
106
107
  * so `refName` alone is not a unique map key). Keying by kind+refName keeps
107
108
  * an app "tickets" and an element "tickets" from colliding.
108
109
  */
109
- export declare function workspaceAspectKey(kind: ChildResourceScope | "table", refName: string): string;
110
+ export declare function workspaceAspectKey(kind: ChildResourceScope | "table" | "task", refName: string): string;
110
111
  export interface ToTfContext {
111
112
  /** The owning app's refName — its authoring directory / catalog key. */
112
113
  readonly appRefName: string;
@@ -40,3 +40,5 @@ export interface SourceTextContext {
40
40
  export declare function withSourceText<T>(filePath: string, text: string, fn: () => Promise<T>): Promise<T>;
41
41
  /** The file/text currently being imported via {@link withSourceText}, or undefined outside that context. */
42
42
  export declare function currentSourceText(): SourceTextContext | undefined;
43
+ /** The workspace file currently being imported by the workspace loader, if any. */
44
+ export declare function currentImportingFile(): string | undefined;
@@ -21,3 +21,19 @@ export async function withSourceText(filePath, text, fn) {
21
21
  export function currentSourceText() {
22
22
  return slot()[GLOBAL_KEY];
23
23
  }
24
+ // ---------------------------------------------------------------------------
25
+ // The file being imported (path only)
26
+ // ---------------------------------------------------------------------------
27
+ //
28
+ // {@link withSourceText} carries a file's TEXT and is only set by the build's
29
+ // own-file discovery. Some authored values need just the importing file's
30
+ // PATH to resolve a relative reference (an automation's `scriptFile("./x.js")`),
31
+ // and they must resolve for EVERY importer (canvas, catalog regeneration,
32
+ // build), not only the one that also wants the text. The workspace loader
33
+ // (`engine/workspace/loader.ts`) sets this around each import under the same
34
+ // `Symbol.for` key; same `globalThis` registry rationale as above.
35
+ const IMPORTING_FILE_KEY = Symbol.for("elementumEdk.engine.build.importingFile");
36
+ /** The workspace file currently being imported by the workspace loader, if any. */
37
+ export function currentImportingFile() {
38
+ return globalThis[IMPORTING_FILE_KEY];
39
+ }
@@ -26,8 +26,22 @@ export declare function writeTechnicalLog(level: LogLevel, source: string, messa
26
26
  /** Emit suppressed WARN/ERROR summaries at the end of a command. */
27
27
  export declare function flushRepeatedTechnicalLogs(): void;
28
28
  export declare function resetTechnicalLogDeduplication(): void;
29
- /** Write user-owned output without allowing it to collide with the live row. */
29
+ /**
30
+ * Write user-facing output without allowing it to collide with the live row.
31
+ *
32
+ * Machine-readable mode drops this channel. Status text and non-bridge
33
+ * OpenTofu transcript stay off stdout under `--json`. Bridged command
34
+ * payloads go through {@link writeUserPayload}.
35
+ */
30
36
  export declare function writeUserOutput(text: string, destination?: NodeJS.WritableStream): void;
37
+ /**
38
+ * Write a bridged passthrough payload.
39
+ *
40
+ * Unlike {@link writeUserOutput}, this still reaches `destination` when
41
+ * machine-readable logs are on, so `records list --json` and other bridged
42
+ * commands keep their stdout.
43
+ */
44
+ export declare function writeUserPayload(text: string, destination?: NodeJS.WritableStream): void;
31
45
  /** Write a final user-facing operation status without contaminating pipes. */
32
46
  export declare function writeUserStatus(message: string, color: "green" | "red" | "yellow"): void;
33
47
  export interface LiveProgressOptions {
@@ -37,6 +51,8 @@ export interface LiveProgressOptions {
37
51
  readonly intervalMs?: number;
38
52
  /** Optional stable upper bound for the status label, excluding progress suffixes. */
39
53
  readonly maxLabelLength?: number;
54
+ /** Optional fixed visible width reserved for the status label. */
55
+ readonly labelWidth?: number;
40
56
  /** Preserve the current counter when a label-only update changes phase. */
41
57
  readonly retainCountOnLabelChange?: boolean;
42
58
  /** Keep label changes as durable lines; useful for pull stage history. */
@@ -53,6 +69,7 @@ export declare class LiveProgress {
53
69
  private total?;
54
70
  private readonly intervalMs;
55
71
  private readonly maxLabelLength?;
72
+ private readonly labelWidth?;
56
73
  private readonly retainCountOnLabelChange;
57
74
  private readonly persistLabelChanges;
58
75
  private label;
@@ -98,6 +115,7 @@ export declare class LiveProgress {
98
115
  private detachTerminationHandlers;
99
116
  private render;
100
117
  private currentStatusRendered;
118
+ private fixedLabelWidth;
101
119
  private bar;
102
120
  /** Single terminal writer. Priority 0 is protocol/log output; priority 1 is animation. */
103
121
  private enqueue;
@@ -110,10 +110,26 @@ function configuredLogLevel() {
110
110
  return "DEBUG";
111
111
  return "INFO";
112
112
  }
113
- /** Write user-owned output without allowing it to collide with the live row. */
113
+ /**
114
+ * Write user-facing output without allowing it to collide with the live row.
115
+ *
116
+ * Machine-readable mode drops this channel. Status text and non-bridge
117
+ * OpenTofu transcript stay off stdout under `--json`. Bridged command
118
+ * payloads go through {@link writeUserPayload}.
119
+ */
114
120
  export function writeUserOutput(text, destination = process.stdout) {
115
121
  if (machineReadableLogs)
116
122
  return;
123
+ writeUserPayload(text, destination);
124
+ }
125
+ /**
126
+ * Write a bridged passthrough payload.
127
+ *
128
+ * Unlike {@link writeUserOutput}, this still reaches `destination` when
129
+ * machine-readable logs are on, so `records list --json` and other bridged
130
+ * commands keep their stdout.
131
+ */
132
+ export function writeUserPayload(text, destination = process.stdout) {
117
133
  const live = activeProgress;
118
134
  if (live !== undefined) {
119
135
  live.writeUserOutput(text, destination);
@@ -143,6 +159,7 @@ export class LiveProgress {
143
159
  total;
144
160
  intervalMs;
145
161
  maxLabelLength;
162
+ labelWidth;
146
163
  retainCountOnLabelChange;
147
164
  persistLabelChanges;
148
165
  label;
@@ -177,6 +194,7 @@ export class LiveProgress {
177
194
  };
178
195
  constructor(options) {
179
196
  this.maxLabelLength = options.maxLabelLength;
197
+ this.labelWidth = options.labelWidth;
180
198
  this.retainCountOnLabelChange = options.retainCountOnLabelChange ?? false;
181
199
  this.label = truncateLabel(options.label, this.maxLabelLength);
182
200
  this.total = options.total;
@@ -405,15 +423,22 @@ export class LiveProgress {
405
423
  if (this.total === undefined) {
406
424
  const elapsed = formatElapsed(Date.now() - this.startedAt);
407
425
  const suffix = elapsed === "" ? "" : ` ${applyEffect(elapsed, { start: 0, end: elapsed.length, dim: true })}`;
408
- const labelWidth = Math.max(0, columns - 2 - visibleWidth(suffix));
409
- return `${spinner} ${renderFittedText(this.label, this.textEffects, labelWidth)}${suffix}`;
426
+ const availableLabelWidth = Math.max(0, columns - 2 - visibleWidth(suffix));
427
+ const labelWidth = this.fixedLabelWidth(availableLabelWidth);
428
+ const label = renderFittedText(this.label, this.textEffects, labelWidth ?? availableLabelWidth);
429
+ return `${spinner} ${labelWidth === undefined ? label : padRenderedLabel(label, labelWidth)}${suffix}`;
410
430
  }
411
431
  let barWidth = 20;
412
432
  const fixedWidth = 2 + 1 + String(this.value).length + 1 + String(this.total).length + 1 + 2;
413
433
  barWidth = Math.max(4, Math.min(20, columns - fixedWidth - 2));
414
434
  const suffix = ` ${this.value}/${this.total} ${this.bar(barWidth)}`;
415
- const labelWidth = Math.max(0, columns - 2 - visibleWidth(suffix));
416
- return `${spinner} ${renderFittedText(this.label, this.textEffects, labelWidth)}${suffix}`;
435
+ const availableLabelWidth = Math.max(0, columns - 2 - visibleWidth(suffix));
436
+ const labelWidth = this.fixedLabelWidth(availableLabelWidth);
437
+ const label = renderFittedText(this.label, this.textEffects, labelWidth ?? availableLabelWidth);
438
+ return `${spinner} ${labelWidth === undefined ? label : padRenderedLabel(label, labelWidth)}${suffix}`;
439
+ }
440
+ fixedLabelWidth(available) {
441
+ return this.labelWidth === undefined ? undefined : Math.min(this.labelWidth, available);
417
442
  }
418
443
  bar(width = 20) {
419
444
  const total = this.total ?? 0;
@@ -557,6 +582,9 @@ function renderFittedText(text, effects, maxWidth) {
557
582
  .map((effect) => ({ ...effect, start: Math.min(effect.start, end), end: Math.min(effect.end, end) }));
558
583
  return `${renderTextEffects(text.slice(0, end), clippedEffects)}${suffix}`;
559
584
  }
585
+ function padRenderedLabel(text, width) {
586
+ return text + " ".repeat(Math.max(0, width - visibleWidth(text)));
587
+ }
560
588
  function truncateLabel(label, maxLength) {
561
589
  if (maxLength === undefined || label.length <= maxLength)
562
590
  return label;
@@ -36,12 +36,19 @@ export interface FromTfContext {
36
36
  * reference then stays unresolvable, same as before this existed).
37
37
  */
38
38
  readonly foreignAppRefNames?: ReadonlyMap<string, string>;
39
+ /** Owner display name + skill display name → materialized catalog skill ref. */
40
+ readonly foreignSkillRefsByOwnerName?: ReadonlyMap<string, {
41
+ readonly appRefName: string;
42
+ readonly skillRefName: string;
43
+ }>;
39
44
  readonly foreignElementRefNames?: ReadonlyMap<string, string>;
45
+ readonly foreignTaskRefNames?: ReadonlyMap<string, string>;
40
46
  /** Imported platform field id -> typed owner/key, assembled by the recursive pull workspace context. */
41
47
  readonly foreignFieldRefsById?: ReadonlyMap<string, {
42
48
  readonly ownerRefName: string;
43
49
  readonly fieldKey: string;
44
50
  readonly fieldName?: string;
51
+ readonly fieldType?: string;
45
52
  }>;
46
53
  /** Platform table id -> typed org catalog identity, loaded by recursive pull when table refs are present. */
47
54
  readonly foreignTableRefsById?: ReadonlyMap<string, {
@@ -53,10 +60,11 @@ export interface FromTfContext {
53
60
  /** Namespace → refName for portable ref-only app/element catalogs. */
54
61
  readonly foreignAppRefNamespaces?: ReadonlyMap<string, string>;
55
62
  readonly foreignElementRefNamespaces?: ReadonlyMap<string, string>;
63
+ readonly foreignTaskRefNamespaces?: ReadonlyMap<string, string>;
56
64
  /** `data.<field-type>.<label>` → generated ref-only catalog member. */
57
65
  readonly foreignFieldRefsByDataAddress?: ReadonlyMap<string, {
58
66
  readonly ownerRefName: string;
59
- readonly ownerKind?: "app" | "element";
67
+ readonly ownerKind?: "app" | "element" | "task";
60
68
  readonly ownerName?: string;
61
69
  readonly ownerNamespace?: string;
62
70
  readonly fieldKey: string;
@@ -2,7 +2,7 @@ import type { FieldRef } from "../../catalog/index.js";
2
2
  import type { UnresolvedReferenceDiagnostic } from "../../graph/types.js";
3
3
  import { type TfDocument } from "../tf/index.js";
4
4
  export interface DirectReferenceRoot {
5
- readonly kind: "app" | "element" | "table";
5
+ readonly kind: "app" | "element" | "table" | "task";
6
6
  readonly refName: string;
7
7
  readonly name: string;
8
8
  readonly namespace?: string;
@@ -29,6 +29,10 @@ export interface DirectReferenceRoot {
29
29
  readonly name: string;
30
30
  }[];
31
31
  }[];
32
+ readonly skills?: readonly {
33
+ readonly refName: string;
34
+ readonly name: string;
35
+ }[];
32
36
  }
33
37
  export type UnresolvedReference = UnresolvedReferenceDiagnostic;
34
38
  /** Format the diagnostic suffix printed beside an existing `unsafePlatformId(...)` call. */
@@ -42,7 +46,7 @@ export interface RefOnlyMetadata {
42
46
  export declare function readRefOnlyMetadata(doc: TfDocument): RefOnlyMetadata;
43
47
  export declare function fieldDataReferenceMap(doc: TfDocument, roots: readonly DirectReferenceRoot[]): ReadonlyMap<string, {
44
48
  readonly ownerRefName: string;
45
- readonly ownerKind?: "app" | "element";
49
+ readonly ownerKind?: "app" | "element" | "task";
46
50
  readonly ownerName?: string;
47
51
  readonly ownerNamespace?: string;
48
52
  readonly fieldKey: string;
@@ -37,7 +37,7 @@ function parseRoot(payload) {
37
37
  const kind = stringAt(obj, "kind");
38
38
  const name = stringAt(obj, "name");
39
39
  const wireRefName = stringAt(obj, "refName");
40
- if ((kind !== "app" && kind !== "element" && kind !== "table") || name === undefined || wireRefName === undefined)
40
+ if ((kind !== "app" && kind !== "element" && kind !== "table" && kind !== "task") || name === undefined || wireRefName === undefined)
41
41
  return undefined;
42
42
  const fields = [];
43
43
  for (const rawField of Array.isArray(obj.fields) ? obj.fields : []) {
@@ -113,6 +113,16 @@ function parseRoot(payload) {
113
113
  outputs,
114
114
  }];
115
115
  });
116
+ const skills = (Array.isArray(obj.skills) ? obj.skills : []).flatMap((rawSkill) => {
117
+ const skill = record(rawSkill);
118
+ if (skill === undefined)
119
+ return [];
120
+ const skillName = stringAt(skill, "name");
121
+ const skillRefName = stringAt(skill, "refName");
122
+ return skillName === undefined || skillRefName === undefined
123
+ ? []
124
+ : [{ refName: tfLabelToTsLabel(skillRefName), name: skillName }];
125
+ });
116
126
  return {
117
127
  kind,
118
128
  refName: tfLabelToTsLabel(wireRefName),
@@ -122,6 +132,7 @@ function parseRoot(payload) {
122
132
  columns,
123
133
  datamines,
124
134
  automations,
135
+ skills,
125
136
  };
126
137
  }
127
138
  function parseUnresolved(payload) {
@@ -197,7 +208,7 @@ export function readRefOnlyMetadata(doc) {
197
208
  }
198
209
  }
199
210
  const deduped = new Map(roots.map((root) => [
200
- root.kind === "table" ? `table:${root.name}` : `${root.kind}:${root.namespace}`,
211
+ root.kind === "table" || root.kind === "task" ? `${root.kind}:${root.name}` : `${root.kind}:${root.namespace}`,
201
212
  root,
202
213
  ]));
203
214
  return { roots: [...deduped.values()], unresolved, diagnostics };
@@ -225,7 +236,7 @@ export function fieldDataReferenceMap(doc, roots) {
225
236
  if (owner !== undefined && field !== undefined)
226
237
  out.set(`${block.type}.${block.label}`, {
227
238
  ownerRefName: owner.refName,
228
- ...(owner.kind === "app" || owner.kind === "element" ? { ownerKind: owner.kind } : {}),
239
+ ...(owner.kind === "app" || owner.kind === "element" || owner.kind === "task" ? { ownerKind: owner.kind } : {}),
229
240
  ownerName: owner.name,
230
241
  ...(owner.namespace !== undefined ? { ownerNamespace: owner.namespace } : {}),
231
242
  fieldKey: field.refName,
@@ -45,6 +45,25 @@ const activeRoots = new Set();
45
45
  let hooksRegistered = false;
46
46
  /** What the resolve hook stamps. Only mutated inside the import queue. */
47
47
  let stampGeneration = 0;
48
+ /**
49
+ * Records which workspace file is being imported, for authored values that
50
+ * resolve a path relative to it (an automation's `scriptFile("./x.js")`).
51
+ * Same `globalThis` registry key `engine/build/source-context.ts` reads; kept
52
+ * inline because this module is loaded natively (no `.js` -> `.ts` mapping)
53
+ * and can only import `node:` builtins.
54
+ */
55
+ const IMPORTING_FILE_KEY = Symbol.for("elementumEdk.engine.build.importingFile");
56
+ async function withImportingFile(filePath, fn) {
57
+ const slot = globalThis;
58
+ const previous = slot[IMPORTING_FILE_KEY];
59
+ slot[IMPORTING_FILE_KEY] = filePath;
60
+ try {
61
+ return await fn();
62
+ }
63
+ finally {
64
+ slot[IMPORTING_FILE_KEY] = previous;
65
+ }
66
+ }
48
67
  /** Monotonic allocator. Incremented only inside the import queue so
49
68
  * constructing a second loader cannot change the in-flight stamp. */
50
69
  let nextGeneration = 0;
@@ -294,7 +313,7 @@ function createJitiLoader(root) {
294
313
  });
295
314
  });
296
315
  const jiti = await pending;
297
- return (await jiti.import(resolve(file)));
316
+ return (await withImportingFile(resolve(file), () => jiti.import(resolve(file))));
298
317
  },
299
318
  };
300
319
  }
@@ -317,7 +336,9 @@ export function createWorkspaceLoader(orgRoot) {
317
336
  stampGeneration = generation;
318
337
  try {
319
338
  const url = pathToFileURL(resolve(file)).href;
320
- return await nativeImport(`${url}?${GENERATION_KEY}=${generation}`);
339
+ // Set inside the serialized section so overlapping imports cannot
340
+ // see each other's file.
341
+ return await withImportingFile(resolve(file), () => nativeImport(`${url}?${GENERATION_KEY}=${generation}`));
321
342
  }
322
343
  finally {
323
344
  stampGeneration = previous;
@@ -36,7 +36,7 @@ export interface NormalizedAccessPolicy {
36
36
  readonly serviceAccountIds?: readonly AccessPolicyServiceAccountRef[];
37
37
  }
38
38
  /** Decode one `filter` attribute through the shared exhaustive codec. */
39
- export declare function filterFromTf(value: TfValue, owner: AccessPolicyOwner, where: string): Filter<RefExpr, RefExpr>;
39
+ export declare function filterFromTf(value: TfValue, owner: AccessPolicyOwner, where: string, ctx?: FromTfContext): Filter<RefExpr, RefExpr>;
40
40
  export declare function principalList(value: TfValue | undefined, dataType: "elementum_user", where: string, ctx: FromTfContext, owner?: AccessPolicyOwner): AccessPolicyUserRef[] | undefined;
41
41
  export declare function principalList(value: TfValue | undefined, dataType: "elementum_group", where: string, ctx: FromTfContext, owner?: AccessPolicyOwner): AccessPolicyGroupRef[] | undefined;
42
42
  export declare function principalList(value: TfValue | undefined, dataType: "elementum_service_account", where: string, ctx: FromTfContext, owner?: AccessPolicyOwner): AccessPolicyServiceAccountRef[] | undefined;