@elementumai/edk 0.9.7 → 0.9.9

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 (148) hide show
  1. package/README.md +3 -2
  2. package/dist-sdk/src/catalog/factories.d.ts +14 -3
  3. package/dist-sdk/src/catalog/factories.js +32 -0
  4. package/dist-sdk/src/catalog/from-authoring.js +27 -33
  5. package/dist-sdk/src/catalog/index.d.ts +2 -2
  6. package/dist-sdk/src/catalog/index.js +2 -2
  7. package/dist-sdk/src/catalog/org.js +67 -29
  8. package/dist-sdk/src/catalog/token.js +10 -0
  9. package/dist-sdk/src/catalog/types.d.ts +20 -2
  10. package/dist-sdk/src/catalog/types.js +5 -0
  11. package/dist-sdk/src/core/index.d.ts +1 -1
  12. package/dist-sdk/src/core/index.js +1 -1
  13. package/dist-sdk/src/core/platform-id.d.ts +2 -0
  14. package/dist-sdk/src/core/platform-id.js +4 -0
  15. package/dist-sdk/src/core/system-fields.d.ts +14 -0
  16. package/dist-sdk/src/core/system-fields.js +6 -0
  17. package/dist-sdk/src/core/triggers/on-demand.d.ts +27 -24
  18. package/dist-sdk/src/core/triggers/on-demand.js +33 -12
  19. package/dist-sdk/src/core/types/aspect-category.d.ts +1 -0
  20. package/dist-sdk/src/core/types/aspect-category.js +1 -0
  21. package/dist-sdk/src/engine/build/context.d.ts +20 -8
  22. package/dist-sdk/src/engine/build/source-context.d.ts +14 -17
  23. package/dist-sdk/src/engine/build/source-context.js +1 -1
  24. package/dist-sdk/src/engine/pull/context.d.ts +9 -0
  25. package/dist-sdk/src/engine/pull/org.d.ts +4 -0
  26. package/dist-sdk/src/engine/pull/org.js +17 -2
  27. package/dist-sdk/src/engine/pull/procedure-refs.d.ts +16 -0
  28. package/dist-sdk/src/engine/pull/procedure-refs.js +69 -0
  29. package/dist-sdk/src/engine/tf/expr.js +1 -1
  30. package/dist-sdk/src/engine/workspace/authoring-layout.d.ts +15 -0
  31. package/dist-sdk/src/engine/workspace/authoring-layout.js +33 -1
  32. package/dist-sdk/src/engine/workspace/loader.d.ts +40 -0
  33. package/dist-sdk/src/engine/workspace/loader.js +328 -0
  34. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +4 -0
  35. package/dist-sdk/src/entities/access-policy/from-tf.js +10 -2
  36. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +1 -0
  37. package/dist-sdk/src/entities/access-policy/to-tf.js +7 -2
  38. package/dist-sdk/src/entities/agent/build.d.ts +54 -8
  39. package/dist-sdk/src/entities/agent/build.js +36 -1
  40. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +126 -2
  41. package/dist-sdk/src/entities/agent/from-tf.d.ts +7 -6
  42. package/dist-sdk/src/entities/agent/from-tf.js +176 -5
  43. package/dist-sdk/src/entities/agent/index.d.ts +2 -2
  44. package/dist-sdk/src/entities/agent/index.js +1 -1
  45. package/dist-sdk/src/entities/agent/to-tf.d.ts +4 -4
  46. package/dist-sdk/src/entities/agent/to-tf.js +185 -11
  47. package/dist-sdk/src/entities/agent/tools.d.ts +16 -5
  48. package/dist-sdk/src/entities/agent/tools.js +13 -1
  49. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +7 -0
  50. package/dist-sdk/src/entities/agent-tool/from-tf.js +29 -4
  51. package/dist-sdk/src/entities/agent-tool/to-tf.js +10 -9
  52. package/dist-sdk/src/entities/agent-tool/types.js +1 -0
  53. package/dist-sdk/src/entities/app/build.d.ts +2 -2
  54. package/dist-sdk/src/entities/app/build.js +6 -3
  55. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +5 -0
  56. package/dist-sdk/src/entities/app/display-blocks-to-layout.d.ts +45 -0
  57. package/dist-sdk/src/entities/app/display-blocks-to-layout.js +98 -0
  58. package/dist-sdk/src/entities/app/display-blocks-to-record-create-form.d.ts +55 -0
  59. package/dist-sdk/src/entities/app/display-blocks-to-record-create-form.js +99 -0
  60. package/dist-sdk/src/entities/app/from-tf.js +9 -7
  61. package/dist-sdk/src/entities/app/to-tf.js +15 -7
  62. package/dist-sdk/src/entities/automation/build.d.ts +8 -1
  63. package/dist-sdk/src/entities/automation/build.js +36 -5
  64. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +3 -7
  65. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +2 -0
  66. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +77 -8
  67. package/dist-sdk/src/entities/automation/from-tf.d.ts +10 -1
  68. package/dist-sdk/src/entities/automation/from-tf.js +803 -62
  69. package/dist-sdk/src/entities/automation/index.d.ts +1 -1
  70. package/dist-sdk/src/entities/automation/module.js +13 -3
  71. package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +12 -4
  72. package/dist-sdk/src/entities/automation/output-key-wire-name.js +17 -6
  73. package/dist-sdk/src/entities/automation/script-code.d.ts +1 -1
  74. package/dist-sdk/src/entities/automation/script-code.js +15 -11
  75. package/dist-sdk/src/entities/automation/task-label.d.ts +2 -0
  76. package/dist-sdk/src/entities/automation/task-label.js +18 -0
  77. package/dist-sdk/src/entities/automation/tasks.d.ts +60 -9
  78. package/dist-sdk/src/entities/automation/tasks.js +16 -4
  79. package/dist-sdk/src/entities/automation/to-tf.d.ts +4 -0
  80. package/dist-sdk/src/entities/automation/to-tf.js +385 -52
  81. package/dist-sdk/src/entities/automation/triggers.d.ts +14 -5
  82. package/dist-sdk/src/entities/automation/triggers.js +1 -1
  83. package/dist-sdk/src/entities/dashboard/from-tf.js +1 -1
  84. package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +1 -0
  85. package/dist-sdk/src/entities/dynamic-layout/to-tf.js +1 -1
  86. package/dist-sdk/src/entities/element/build.d.ts +30 -7
  87. package/dist-sdk/src/entities/element/build.js +6 -3
  88. package/dist-sdk/src/entities/element/from-tf.js +7 -3
  89. package/dist-sdk/src/entities/element/index.d.ts +1 -1
  90. package/dist-sdk/src/entities/element/index.js +1 -1
  91. package/dist-sdk/src/entities/element/to-tf.js +49 -8
  92. package/dist-sdk/src/entities/field/from-tf.d.ts +6 -0
  93. package/dist-sdk/src/entities/field/from-tf.js +12 -0
  94. package/dist-sdk/src/entities/field/module.js +1 -0
  95. package/dist-sdk/src/entities/field/to-tf.d.ts +1 -1
  96. package/dist-sdk/src/entities/field/to-tf.js +19 -5
  97. package/dist-sdk/src/entities/org/category-ref.d.ts +5 -0
  98. package/dist-sdk/src/entities/org/category-ref.js +12 -0
  99. package/dist-sdk/src/entities/record-create-form/from-tf.js +3 -3
  100. package/dist-sdk/src/entities/record-create-form/to-tf.d.ts +1 -0
  101. package/dist-sdk/src/entities/record-create-form/to-tf.js +13 -5
  102. package/dist-sdk/src/entities/relationship/from-tf.js +15 -4
  103. package/dist-sdk/src/entities/role/from-tf.js +10 -4
  104. package/dist-sdk/src/entities/search-table/build.d.ts +1 -1
  105. package/dist-sdk/src/entities/search-table/from-tf.d.ts +1 -0
  106. package/dist-sdk/src/entities/search-table/from-tf.js +6 -0
  107. package/dist-sdk/src/entities/search-table/printer.js +3 -1
  108. package/dist-sdk/src/entities/search-table/to-tf.js +3 -3
  109. package/dist-sdk/src/entities/search-table/types.js +1 -0
  110. package/dist-sdk/src/entities/service-account/from-tf.js +10 -4
  111. package/dist-sdk/src/entities/service-account/to-tf.d.ts +2 -1
  112. package/dist-sdk/src/entities/service-account/to-tf.js +7 -0
  113. package/dist-sdk/src/entities/shared/filters/ast.d.ts +7 -1
  114. package/dist-sdk/src/entities/shared/filters/ast.js +3 -0
  115. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +7 -1
  116. package/dist-sdk/src/entities/shared/filters/tf-codec.js +8 -4
  117. package/dist-sdk/src/entities/shared/handle-description.d.ts +12 -0
  118. package/dist-sdk/src/entities/shared/handle-description.js +20 -0
  119. package/dist-sdk/src/entities/shared/types/field-types.d.ts +6 -1
  120. package/dist-sdk/src/entities/shared/types/field-types.js +5 -8
  121. package/dist-sdk/src/entities/skill/build.d.ts +51 -2
  122. package/dist-sdk/src/entities/skill/build.js +65 -8
  123. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +35 -3
  124. package/dist-sdk/src/entities/skill/from-tf.d.ts +11 -0
  125. package/dist-sdk/src/entities/skill/from-tf.js +39 -7
  126. package/dist-sdk/src/entities/skill/index.d.ts +1 -1
  127. package/dist-sdk/src/entities/skill/index.js +1 -1
  128. package/dist-sdk/src/entities/skill/input-coverage.d.ts +21 -0
  129. package/dist-sdk/src/entities/skill/input-coverage.js +148 -5
  130. package/dist-sdk/src/entities/skill/to-tf.d.ts +6 -25
  131. package/dist-sdk/src/entities/skill/to-tf.js +22 -38
  132. package/dist-sdk/src/entities/skill/tools.d.ts +2 -1
  133. package/dist-sdk/src/entities/skill/tools.js +3 -1
  134. package/dist-sdk/src/entities/skill-tool/from-tf.js +10 -3
  135. package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +5 -5
  136. package/dist-sdk/src/entities/skill-tool/to-tf.js +5 -7
  137. package/dist-sdk/src/entities/table/to-tf.js +3 -4
  138. package/dist-sdk/src/entities/task/to-tf.js +3 -2
  139. package/dist-sdk/src/entities/view/from-tf.js +36 -10
  140. package/dist-sdk/src/entities/view/to-tf.d.ts +2 -0
  141. package/dist-sdk/src/entities/view/to-tf.js +44 -30
  142. package/dist-sdk/src/entities/widget/from-tf.js +2 -2
  143. package/dist-sdk/src/entities/widget/to-tf.d.ts +1 -0
  144. package/dist-sdk/src/entities/widget/to-tf.js +52 -23
  145. package/dist-sdk/src/graph/index.d.ts +19 -1
  146. package/dist-sdk/src/graph/index.js +20 -0
  147. package/dist-sdk/src/graph/types.d.ts +19 -0
  148. package/package.json +10 -5
package/README.md CHANGED
@@ -170,8 +170,9 @@ elementum apply [orgRoot-or-nested-target] [bridge args...]
170
170
 
171
171
  elementum list apps|elements|users|groups|categories|cloud-links
172
172
  elementum list ai-provider-connectors|automations|tables
173
- elementum new app --name "Support Tickets" --namespace support --category "Operations"
174
- elementum new element --name "Locations" --namespace locations --category "Operations"
173
+ elementum new category --name "Operations"
174
+ elementum new app --name "Support Tickets" --namespace support --category "Operations" --handle SUPPORT
175
+ elementum new element --name "Locations" --namespace locations --category "Operations" --handle LOCATION
175
176
  elementum new agent --app <appRef> --name "Triage Bot"
176
177
  elementum new skill --app <appRef> --name "Lookup Ticket"
177
178
  elementum new automation --app <appRef> --name "Escalate Ticket"
@@ -19,7 +19,7 @@
19
19
  * nothing reads those interim values.
20
20
  */
21
21
  import type { AiProviderLlmModel, AiProviderType } from "./ai-provider-models.js";
22
- import type { AgentEvaluationRef, AgentRef, AppCatalogRef, AiProviderRef, ApprovalChainRef, AutomationCatalogRef, CatalogRef, CategoryRef, ChartRef, DashboardRef, CloudLinkRef, ConnectorRef, DatamineRef, GroupRef, PhoneProviderRef, PhoneServiceRef, FileReaderCatalogRef, DocumentModelFieldRef, ElementCatalogRef, FieldRef, OutputPropertyRef, SearchTableRef, StoredFunctionRef, StoredFunctionScalarType, SkillRef, TableColumnRef, TableRef, TriggerParameterRef } from "./types.js";
22
+ import type { AgentEvaluationRef, AgentRef, AppCatalogRef, AiProviderRef, ApprovalChainRef, AutomationCatalogRef, CatalogRef, CategoryRef, ChartRef, DashboardRef, CloudLinkRef, ConnectorRef, DatamineRef, GroupRef, PhoneProviderRef, PhoneServiceRef, ProcedureParameterType, ProcedureRef, FileReaderCatalogRef, DocumentModelFieldRef, ElementCatalogRef, FieldRef, OutputPropertyRef, SearchTableRef, StoredFunctionRef, StoredFunctionScalarType, SkillRef, TableColumnRef, TableRef, TriggerParameterRef } from "./types.js";
23
23
  /** Fixed platform user-directory schema used by userSearch filters. */
24
24
  export declare const usersCatalog: {
25
25
  readonly fields: {
@@ -226,17 +226,26 @@ export declare function aiProvider<T extends AiProviderType, M extends Readonly<
226
226
  }): AiProviderRef<T> & {
227
227
  readonly models: M;
228
228
  };
229
- export declare function cloudLinkRef<const Functions extends Readonly<Record<string, StoredFunctionRef>> | undefined = undefined>(opts: {
229
+ export declare function cloudLinkRef<const Functions extends Readonly<Record<string, StoredFunctionRef>> | undefined = undefined, const Procedures extends Readonly<Record<string, ProcedureRef>> | undefined = undefined>(opts: {
230
230
  readonly name: string;
231
231
  readonly storedFunctions?: Functions;
232
+ readonly procedures?: Procedures;
232
233
  }): CloudLinkRef & {
233
234
  readonly storedFunctions: Functions;
235
+ readonly procedures: Procedures;
234
236
  };
235
237
  export declare function storedFunctionRef<const Parameters extends readonly StoredFunctionScalarType[], const Result extends StoredFunctionScalarType>(opts: {
236
238
  readonly name: string;
237
239
  readonly parameters: Parameters;
238
240
  readonly result: Result;
239
241
  }): StoredFunctionRef<Parameters, Result>;
242
+ export declare function procedureRef<const Parameters extends readonly ProcedureParameterType[], const Result extends StoredFunctionScalarType>(opts: {
243
+ readonly name: string;
244
+ readonly database: string;
245
+ readonly schema: string;
246
+ readonly parameters: Parameters;
247
+ readonly result: Result;
248
+ }): ProcedureRef<Parameters, Result>;
240
249
  export declare const categoryRef: (opts: Omit<CategoryRef, "refName" | "__kind">) => Omit<CategoryRef, "refName" | "__kind"> & {
241
250
  readonly __kind: "category";
242
251
  readonly refName: string;
@@ -252,12 +261,14 @@ export declare const phoneProviderRef: (opts: Omit<PhoneProviderRef, "refName" |
252
261
  export declare function tableColumnRef(opts: Omit<TableColumnRef, "__kind" | "refName" | "parent"> & {
253
262
  readonly parent?: string;
254
263
  }): TableColumnRef;
255
- export declare function tableRef<const Columns extends Readonly<Record<string, TableColumnRef>> | undefined = undefined, const RefName extends string = string>(opts: Omit<TableRef, "__kind" | "refName" | "columns"> & {
264
+ export declare function tableRef<const Columns extends Readonly<Record<string, TableColumnRef>> | undefined = undefined, const Datamines extends Readonly<Record<string, DatamineRef>> | undefined = undefined, const RefName extends string = string>(opts: Omit<TableRef, "__kind" | "refName" | "columns" | "datamines"> & {
256
265
  readonly refName?: RefName;
257
266
  readonly columns?: Columns;
267
+ readonly datamines?: Datamines;
258
268
  }): TableRef & {
259
269
  readonly refName: RefName;
260
270
  readonly columns: Columns;
271
+ readonly datamines: Datamines;
261
272
  };
262
273
  /**
263
274
  * `refName` is optional and defaults to `name` — for a caller with no bag-key
@@ -156,11 +156,18 @@ export function cloudLinkRef(opts) {
156
156
  const functions = opts.storedFunctions === undefined
157
157
  ? undefined
158
158
  : Object.fromEntries(Object.entries(opts.storedFunctions).map(([refName, fn]) => [refName, { ...fn, refName, parent: "" }]));
159
+ const procedures = opts.procedures === undefined
160
+ ? undefined
161
+ : Object.fromEntries(Object.entries(opts.procedures).map(([refName, procedure]) => [
162
+ refName,
163
+ { ...procedure, refName, parent: "", parentName: opts.name },
164
+ ]));
159
165
  return {
160
166
  __kind: "cloudLink",
161
167
  refName: opts.name,
162
168
  name: opts.name,
163
169
  ...(functions !== undefined ? { storedFunctions: functions } : {}),
170
+ ...(procedures !== undefined ? { procedures } : {}),
164
171
  };
165
172
  }
166
173
  export function storedFunctionRef(opts) {
@@ -173,6 +180,18 @@ export function storedFunctionRef(opts) {
173
180
  resultType: opts.result,
174
181
  };
175
182
  }
183
+ export function procedureRef(opts) {
184
+ return {
185
+ __kind: "procedure",
186
+ refName: opts.name,
187
+ name: opts.name,
188
+ parent: "",
189
+ databaseName: opts.database,
190
+ schemaName: opts.schema,
191
+ parameterTypes: opts.parameters,
192
+ resultType: opts.result,
193
+ };
194
+ }
176
195
  export const categoryRef = refFactory("category");
177
196
  export const groupRef = refFactory("group");
178
197
  export const phoneProviderRef = refFactory("phoneProvider");
@@ -195,11 +214,18 @@ export function tableRef(opts) {
195
214
  refName,
196
215
  { ...column, refName, parent: opts.refName ?? opts.name, parentName: opts.name },
197
216
  ]));
217
+ const datamines = opts.datamines === undefined
218
+ ? undefined
219
+ : Object.fromEntries(Object.entries(opts.datamines).map(([refName, datamine]) => [
220
+ refName,
221
+ { ...datamine, refName, parent: opts.refName ?? opts.name },
222
+ ]));
198
223
  return {
199
224
  __kind: "table",
200
225
  refName,
201
226
  name: opts.name,
202
227
  ...(columns !== undefined ? { columns } : {}),
228
+ ...(datamines !== undefined ? { datamines } : {}),
203
229
  ...(opts.categoryId !== undefined ? { categoryId: opts.categoryId } : {}),
204
230
  };
205
231
  }
@@ -370,6 +396,12 @@ function stampCloudLinks(bag) {
370
396
  {
371
397
  ...cloudLink,
372
398
  storedFunctions: withOwnKeyAsHandle(cloudLink.storedFunctions, cloudLinkKey) ?? {},
399
+ procedures: cloudLink.procedures === undefined
400
+ ? {}
401
+ : Object.fromEntries(Object.entries(cloudLink.procedures).map(([procedureKey, procedure]) => [
402
+ procedureKey,
403
+ { ...procedure, refName: procedureKey, parent: cloudLinkKey, parentName: cloudLink.name },
404
+ ])),
373
405
  },
374
406
  ]));
375
407
  }
@@ -21,40 +21,32 @@
21
21
  */
22
22
  import { mkdir, readdir, stat, writeFile } from "node:fs/promises";
23
23
  import { basename, dirname, join, resolve } from "node:path";
24
- import { createJiti } from "jiti/static";
24
+ import { createWorkspaceLoader } from "../engine/workspace/loader.js";
25
25
  import { KIND_BY_ID, ownFileCatalogChildrenOf, } from "../graph/index.js";
26
26
  import { writeCatalogBarrel } from "./org.js";
27
27
  import { renderCatalog } from "./render.js";
28
- import { assertAuthoringPathForTenant, assertValidAuthoringLayout, } from "../engine/workspace/authoring-layout.js";
28
+ import { assertAuthoringPathForTenant, assertValidAuthoringLayout, isAuthoringHelperFile, isStreamRootAuthoringFile, } from "../engine/workspace/authoring-layout.js";
29
29
  function isConfiguredEntity(value) {
30
30
  return (typeof value === "object" &&
31
31
  value !== null &&
32
32
  typeof value.ref === "function" &&
33
33
  typeof value.def === "function");
34
34
  }
35
- // `moduleCache: false` — every function in this module exists to reflect
36
- // whatever's *currently* on disk. Within a single `edk pull` an app's own
37
- // file gets imported here once while it's still the import-time
38
- // reference-only stub (no default export), then overwritten with the real
39
- // `app(...)` call via plain `writeFile` (not through jiti), then
40
- // imported here again. A cached jiti would return the stale pre-overwrite
35
+ // Every function in this module exists to reflect whatever's *currently* on
36
+ // disk. Within a single `edk pull` an app's own file gets imported here once
37
+ // while it's still the import-time reference-only stub (no default export),
38
+ // then overwritten with the real `app(...)` call via plain `writeFile`, then
39
+ // imported here again. A cached module would return the stale pre-overwrite
41
40
  // result for that second import — exactly the "does not default-export a
42
- // configured app" failure this avoids. Re-transpiling on every call is the
43
- // deliberate tradeoff; this isn't a hot path.
41
+ // configured app" failure this avoids.
44
42
  //
45
- // Keyed by the resolved `@catalog` path so multiple consumers (different
46
- // workspace roots) each get the right alias, and so the singleton is reused
47
- // within a single import/pull run.
48
- const jitiByAlias = new Map();
49
- function authoringJiti(catalogPath) {
50
- const key = catalogPath ?? "";
51
- let jiti = jitiByAlias.get(key);
52
- if (jiti === undefined) {
53
- const alias = catalogPath !== undefined ? { "@catalog": catalogPath } : {};
54
- jiti = createJiti(import.meta.url, { moduleCache: false, alias });
55
- jitiByAlias.set(key, jiti);
56
- }
57
- return jiti;
43
+ // A FRESH loader per call, which is what buys the freshness described above:
44
+ // each one re-reads every workspace file, while the SDK modules behind them
45
+ // stay evaluated once for the life of the process.
46
+ function authoringLoader(catalogPath) {
47
+ // `catalogPath` is `<wsRoot>/generated/catalog.ts`.
48
+ const root = catalogPath !== undefined ? dirname(dirname(catalogPath)) : process.cwd();
49
+ return createWorkspaceLoader(root);
58
50
  }
59
51
  /** The generated catalog's own filename — never treated as an authoring file. */
60
52
  const CATALOG_FILENAME = "catalog.ts";
@@ -65,8 +57,8 @@ function isEntityFile(name) {
65
57
  return false;
66
58
  if (name.endsWith(".d.ts") || name.endsWith(".test.ts"))
67
59
  return false;
68
- if (name.startsWith("_"))
69
- return false; // driver/helper convention, matches src/deploy/directory.ts
60
+ if (isAuthoringHelperFile(name))
61
+ return false;
70
62
  return name.endsWith(".ts") || name.endsWith(".js") || name.endsWith(".mjs");
71
63
  }
72
64
  async function listEntityFiles(dir) {
@@ -204,14 +196,14 @@ async function loadCatalogChildBag(appDir, child, parent, catalogPath, defsOut)
204
196
  const facet = child.catalog;
205
197
  if (!facet.participates)
206
198
  return {};
207
- const jiti = authoringJiti(catalogPath);
199
+ const loader = authoringLoader(catalogPath);
208
200
  const refs = {};
209
201
  const defs = {};
210
202
  for (const file of await listEntityFiles(catalogChildDir(appDir, child))) {
211
203
  const refName = refNameOf(file);
212
204
  let mod;
213
205
  try {
214
- mod = (await jiti.import(file));
206
+ mod = (await loader.import(file));
215
207
  }
216
208
  catch (err) {
217
209
  const message = err instanceof Error ? err.message : String(err);
@@ -292,8 +284,8 @@ async function writeStubCatalog(appDir, appRefName, appName, kind, fields, child
292
284
  export async function buildAppCatalogFromAuthoring(appDir, appFile, orgCatalogPath) {
293
285
  // `appDir` is `<wsRoot>/apps/<handle>` or `<wsRoot>/elements/<handle>`.
294
286
  const resolvedOrgCatalogPath = orgCatalogPath ?? join(dirname(dirname(appDir)), "generated", "catalog.ts");
295
- const jiti = authoringJiti(resolvedOrgCatalogPath);
296
- const appMod = (await jiti.import(appFile));
287
+ const loader = authoringLoader(resolvedOrgCatalogPath);
288
+ const appMod = (await loader.import(appFile));
297
289
  if (!isConfiguredEntity(appMod.default)) {
298
290
  throw new Error(`${appFile} does not default-export a configured app (a app(...) result)`);
299
291
  }
@@ -400,10 +392,10 @@ export async function writeAppCatalog(appDir, appRefName, appName, appFile, impo
400
392
  // `<wsRoot>/apps/<handle>`; the org catalog lives at `<wsRoot>/generated/catalog.ts`.
401
393
  const wsRoot = dirname(dirname(appDir));
402
394
  const orgCatalogPath = join(wsRoot, "generated", "catalog.ts");
403
- const jiti = authoringJiti(orgCatalogPath);
395
+ const loader = authoringLoader(orgCatalogPath);
404
396
  let appMod;
405
397
  try {
406
- appMod = (await jiti.import(appFile));
398
+ appMod = (await loader.import(appFile));
407
399
  }
408
400
  catch {
409
401
  appMod = undefined;
@@ -453,6 +445,8 @@ export async function regenerateAppCatalogsUnder(pathOrPaths, tenant) {
453
445
  const paths = typeof pathOrPaths === "string" ? [pathOrPaths] : pathOrPaths;
454
446
  const out = [];
455
447
  for (const file of await listEntityFilesFromPaths(paths, tenant)) {
448
+ if (!isStreamRootAuthoringFile(file))
449
+ continue;
456
450
  // A root app/element file may itself `import catalog from "@catalog"`
457
451
  // (e.g. a relation field referencing another workspace entity by
458
452
  // token) — without this alias that import fails to resolve and the
@@ -465,10 +459,10 @@ export async function regenerateAppCatalogsUnder(pathOrPaths, tenant) {
465
459
  // file's `ref.__kind` is never "app"/"element" and its result is
466
460
  // discarded below regardless of whether it loaded at all.
467
461
  const orgRoot = dirname(dirname(dirname(file)));
468
- const jiti = authoringJiti(join(orgRoot, "generated", CATALOG_FILENAME));
462
+ const loader = authoringLoader(join(orgRoot, "generated", CATALOG_FILENAME));
469
463
  let mod;
470
464
  try {
471
- mod = (await jiti.import(file));
465
+ mod = (await loader.import(file));
472
466
  }
473
467
  catch (err) {
474
468
  if (process.env.EDK_DEBUG) {
@@ -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 CloudLinkRef, type AiServiceRef, type ConnectorRef, type GroupRef, type PhoneProviderRef, type PhoneServiceRef, type FileReaderCatalogRef, type DocumentModelFieldRef, type ElementCatalogRef, type FieldRef, type OutputPropertyRef, type SearchTableRef, 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 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 SearchTableRef, 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, cloudLinkRef, connectorRef, aiProvider, groupRef, linkedSearchTableRef, phoneProviderRef, phoneServiceRef, documentModelFieldRef, documentModelRef, elementCatalog, elementRef, fieldRef, orgCatalog, outputPropertyRef, searchTableRef, datamineRef, skillRef, storedFunctionRef, tableColumnRef, tableRef, tableSearchTableRef, triggerParameterRef, usersCatalog, } from "./factories.js";
12
+ export { agentRef, agentEvaluationRef, appRef, appCatalog, approvalChainRef, automationRef, categoryRef, chartRef, dashboardRef, cloudLinkRef, connectorRef, aiProvider, groupRef, linkedSearchTableRef, phoneProviderRef, phoneServiceRef, procedureRef, documentModelFieldRef, documentModelRef, elementCatalog, elementRef, fieldRef, orgCatalog, outputPropertyRef, searchTableRef, datamineRef, skillRef, storedFunctionRef, tableColumnRef, tableRef, tableSearchTableRef, triggerParameterRef, usersCatalog, } from "./factories.js";
@@ -4,9 +4,9 @@
4
4
  * ids appear here (identity lives in `src/deploy/state`).
5
5
  */
6
6
  export { AI_PROVIDER_LLM_MODELS } from "./ai-provider-models.js";
7
- export { REF_SCOPE, REF_UPDATABLE, USER_FIELD_KEYS, } from "./types.js";
7
+ export { REF_SCOPE, REF_UPDATABLE, PROCEDURE_PARAMETER_TYPES, USER_FIELD_KEYS, } from "./types.js";
8
8
  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, cloudLinkRef, connectorRef, aiProvider, groupRef, linkedSearchTableRef, phoneProviderRef, phoneServiceRef, documentModelFieldRef, documentModelRef, elementCatalog, elementRef, fieldRef, orgCatalog, outputPropertyRef, searchTableRef, datamineRef, skillRef, storedFunctionRef, tableColumnRef, tableRef, tableSearchTableRef, triggerParameterRef, usersCatalog, } from "./factories.js";
12
+ export { agentRef, agentEvaluationRef, appRef, appCatalog, approvalChainRef, automationRef, categoryRef, chartRef, dashboardRef, cloudLinkRef, connectorRef, aiProvider, groupRef, linkedSearchTableRef, phoneProviderRef, phoneServiceRef, procedureRef, documentModelFieldRef, documentModelRef, elementCatalog, elementRef, fieldRef, orgCatalog, outputPropertyRef, searchTableRef, datamineRef, skillRef, storedFunctionRef, tableColumnRef, tableRef, tableSearchTableRef, triggerParameterRef, usersCatalog, } from "./factories.js";
@@ -67,13 +67,17 @@ function renderOrgTs(extract) {
67
67
  // (`aiProviders.<provider>.models.<model>`), rendered specially here.
68
68
  const aiProvidersLines = renderAiProvidersBag(extract);
69
69
  const supportedFunctionsByCloudLink = new Map();
70
+ const supportedProceduresByCloudLink = new Map();
70
71
  for (const fn of extract.storedFunctions ?? []) {
71
72
  const mapped = supportedStoredFunction(fn);
72
73
  if (mapped === undefined)
73
74
  continue;
74
- const functions = supportedFunctionsByCloudLink.get(fn.cloudLinkName) ?? [];
75
- functions.push({ fn, mapped });
76
- supportedFunctionsByCloudLink.set(fn.cloudLinkName, functions);
75
+ const target = fn.functionType === "PROCEDURE"
76
+ ? supportedProceduresByCloudLink
77
+ : supportedFunctionsByCloudLink;
78
+ const entries = target.get(fn.cloudLinkName) ?? [];
79
+ entries.push({ fn, mapped });
80
+ target.set(fn.cloudLinkName, entries);
77
81
  }
78
82
  const factories = new Set(["orgCatalog", ...bags.map((b) => b.factory)]);
79
83
  if (aiProvidersLines.length > 0) {
@@ -82,6 +86,8 @@ function renderOrgTs(extract) {
82
86
  }
83
87
  if (supportedFunctionsByCloudLink.size > 0)
84
88
  factories.add("storedFunctionRef");
89
+ if (supportedProceduresByCloudLink.size > 0)
90
+ factories.add("procedureRef");
85
91
  const lines = [
86
92
  "// Org reference identities from `elementum pull org --data-only` — refresh by re-running it.",
87
93
  "// Each key IS the identity's terraform label in camelCase: tfLabel = tsLabelToTfLabel(key)",
@@ -99,20 +105,31 @@ function renderOrgTs(extract) {
99
105
  continue;
100
106
  }
101
107
  const functions = supportedFunctionsByCloudLink.get(e.name) ?? [];
102
- if (functions.length === 0) {
108
+ const procedures = supportedProceduresByCloudLink.get(e.name) ?? [];
109
+ if (functions.length === 0 && procedures.length === 0) {
103
110
  lines.push(` ${e.tsLabel}: ${factory}({ name: ${q(e.name)} }),`);
104
111
  continue;
105
112
  }
106
- lines.push(` ${e.tsLabel}: ${factory}({ name: ${q(e.name)}, storedFunctions: {`);
107
- const used = new Set();
108
- for (const { fn, mapped } of functions) {
109
- const key = tfLabelToTsLabel(sanitizeName(fn.name));
110
- if (used.has(key))
111
- throw new OrgExtractError(`cloud link ${q(e.name)} has duplicate stored-function key ${q(key)}`);
112
- used.add(key);
113
- lines.push(` ${key}: storedFunctionRef({ name: ${q(fn.name)}, parameters: ${JSON.stringify(mapped.parameters)}, result: ${q(mapped.result)} }),`);
113
+ lines.push(` ${e.tsLabel}: ${factory}({ name: ${q(e.name)},`);
114
+ if (functions.length > 0) {
115
+ lines.push(" storedFunctions: {");
116
+ const used = new Set();
117
+ for (const { fn, mapped } of functions) {
118
+ const key = uniqueCatalogKey(tfLabelToTsLabel(sanitizeName(fn.name)), used);
119
+ lines.push(` ${key}: storedFunctionRef({ name: ${q(fn.name)}, parameters: ${JSON.stringify(mapped.parameters)}, result: ${q(mapped.result)} }),`);
120
+ }
121
+ lines.push(" },");
114
122
  }
115
- lines.push(" } }),");
123
+ if (procedures.length > 0) {
124
+ lines.push(" procedures: {");
125
+ const used = new Set();
126
+ for (const { fn, mapped } of procedures) {
127
+ const key = uniqueCatalogKey(tfLabelToTsLabel(sanitizeName(fn.name)), used);
128
+ lines.push(` ${key}: procedureRef({ name: ${q(fn.name)}, database: ${q(fn.databaseName)}, schema: ${q(fn.schemaName)}, parameters: ${JSON.stringify(fn.parameterTypes)}, result: ${q(mapped.result)} }),`);
129
+ }
130
+ lines.push(" },");
131
+ }
132
+ lines.push(" }),");
116
133
  }
117
134
  lines.push(" },");
118
135
  }
@@ -133,12 +150,14 @@ const STORED_FUNCTION_TYPE = {
133
150
  BINARY: undefined,
134
151
  };
135
152
  function supportedStoredFunction(fn) {
136
- const problem = fn.functionType !== "USER_DEFINED_FUNCTION" ? `type ${fn.functionType}`
153
+ const knownKind = fn.functionType === "USER_DEFINED_FUNCTION" || fn.functionType === "PROCEDURE";
154
+ const problem = !knownKind ? `type ${fn.functionType}`
137
155
  : !fn.configured ? "not configured"
138
156
  : fn.returnType === "TABLE" ? "table result"
139
- : STORED_FUNCTION_TYPE[fn.returnType] === undefined ? `unsupported result ${fn.returnType}`
140
- : fn.parameterTypes.some((type) => STORED_FUNCTION_TYPE[type] === undefined) ? `unsupported argument in ${fn.parameterTypes.join(", ")}`
141
- : undefined;
157
+ : fn.functionType === "PROCEDURE" && fn.parameterTypes.includes("AUTO_INCREMENT") ? "unsupported procedure argument AUTO_INCREMENT"
158
+ : STORED_FUNCTION_TYPE[fn.returnType] === undefined ? `unsupported result ${fn.returnType}`
159
+ : fn.parameterTypes.some((type) => STORED_FUNCTION_TYPE[type] === undefined) ? `unsupported argument in ${fn.parameterTypes.join(", ")}`
160
+ : undefined;
142
161
  if (problem !== undefined) {
143
162
  console.error(`[elementum] skipping stored function ${fn.name}: ${problem}`);
144
163
  return undefined;
@@ -155,9 +174,9 @@ function supportedStoredFunction(fn) {
155
174
  * independently derived from `name`/`model_name` (never split out of the
156
175
  * connector's combined tfLabel) and cross-checked against the recorded
157
176
  * tfLabel — a mismatch means ei's label construction drifted from this
158
- * derivation. Every connector is required (by `extractOrg`) to carry a
159
- * resolved `providerRef`, so an unresolved one here means its provider
160
- * wasn't itself exported — loud, not silent.
177
+ * derivation. Connectors without a resolved provider are reported by
178
+ * `extractOrg` and skipped here because they cannot be represented safely in
179
+ * the nested public catalog.
161
180
  */
162
181
  function renderAiProvidersBag(extract) {
163
182
  if (extract.aiProviders.length === 0)
@@ -169,12 +188,12 @@ function renderAiProvidersBag(extract) {
169
188
  const modelsByProviderKey = new Map();
170
189
  for (const connector of extract.connectors) {
171
190
  if (connector.providerRef === undefined) {
172
- throw new OrgExtractError(`connector "${connector.name}" (${connector.tfLabel}) has no resolved provider reference`);
191
+ continue;
173
192
  }
174
193
  const providerRefKey = `${connector.providerRef.resourceType}.${connector.providerRef.tfLabel}`;
175
194
  const provider = providerByRef.get(providerRefKey);
176
195
  if (provider === undefined) {
177
- throw new OrgExtractError(`connector "${connector.name}" (${connector.tfLabel}): its provider (${providerRefKey}) was not exported`);
196
+ continue;
178
197
  }
179
198
  const providerKey = tfLabelToTsLabel(sanitizeName(provider.name));
180
199
  const modelKey = tfLabelToTsLabel(sanitizeName(connector.name));
@@ -227,7 +246,7 @@ function renderAiProvidersBag(extract) {
227
246
  * importing file's own entry, so a static import here would statically
228
247
  * import that file's own per-entity catalog, which itself statically
229
248
  * imports the file currently mid-evaluation — a genuine circular require
230
- * (confirmed live: jiti/CJS semantics hand back a partial, `export
249
+ * (confirmed live: CJS semantics hand back a partial, `export
231
250
  * default`-less module, and `.ref()` on it throws). A lazy getter defers
232
251
  * that whole chain until the property is actually READ, by which point
233
252
  * the importing file's own module evaluation has moved past the point of
@@ -248,11 +267,13 @@ function renderBarrel(appHandles, elementHandles, tableHandles) {
248
267
  "",
249
268
  ];
250
269
  if (hasLazyEntries) {
251
- // A minimal local ambient declaration rather than relying on `@types/node`
252
- // (a consumer workspace may not have it) — the runtime `require` itself
253
- // is provided by the loader (jiti), not by this declaration, which is
254
- // erased entirely at compile time.
255
- lines.push("declare const require: (id: string) => unknown;", "");
270
+ // A synchronous require for the lazy getters below. Native ESM uses
271
+ // createRequire; the Bun binary's jiti fallback supplies its own require,
272
+ // which must win there so nested generated catalogs stay inside jiti's
273
+ // resolver. An import would eagerly pull every per-entity catalog into
274
+ // this module's evaluation and reintroduce the self-reference cycle.
275
+ lines.push('import { createRequire } from "node:module";', "");
276
+ lines.push('const catalogRequire = (globalThis as { Bun?: unknown }).Bun !== undefined && typeof require === "function"', " ? require", " : createRequire(import.meta.url);", "");
256
277
  }
257
278
  if (tableHandles.length > 0) {
258
279
  lines.push("const tables = {");
@@ -292,7 +313,7 @@ function renderBarrel(appHandles, elementHandles, tableHandles) {
292
313
  function lazyAspectGetter(key, importPath, exportName, indent = " ") {
293
314
  const quoted = JSON.stringify(importPath);
294
315
  return [
295
- `${indent}get ${key}() { return (require(${quoted}) as typeof import(${quoted})).${exportName}; },`,
316
+ `${indent}get ${key}() { return (catalogRequire(${quoted}) as typeof import(${quoted})).${exportName}; },`,
296
317
  ];
297
318
  }
298
319
  /** An app and an element MAY share a handle — expose the element under a disambiguated key, warning once. */
@@ -353,6 +374,23 @@ async function discoverOrgRootHandles(root) {
353
374
  function q(s) {
354
375
  return JSON.stringify(s);
355
376
  }
377
+ /**
378
+ * Disambiguate a catalog bag key against sibling keys already used in the
379
+ * same bag, appending numeric suffixes (`base`, `base2`, `base3`, …) — the
380
+ * same dedupe rule `withUniqueKeys` (`pull/util.ts`) applies elsewhere in the
381
+ * codebase. Needed because overloaded Snowflake stored functions/procedures
382
+ * (same name, distinct parameter signature) derive the same `sanitizeName`
383
+ * base; each still carries its own exact `name`/`database`/`schema`/
384
+ * `parameters` in the emitted ref, so only the bag KEY needs disambiguating.
385
+ */
386
+ function uniqueCatalogKey(base, used) {
387
+ let key = base;
388
+ let i = 2;
389
+ while (used.has(key))
390
+ key = `${base}${i++}`;
391
+ used.add(key);
392
+ return key;
393
+ }
356
394
  const RESERVED_IDENT = new Set([
357
395
  "break", "case", "catch", "class", "const", "continue", "debugger", "default",
358
396
  "delete", "do", "else", "export", "extends", "false", "finally", "for",
@@ -56,6 +56,16 @@ export function slimToken(token) {
56
56
  // task build.
57
57
  if (token.__kind === "documentModel" && typeof token.readerType === "string")
58
58
  out.readerType = token.readerType;
59
+ // Procedure lookup must carry the exact ordered Snowflake signature so the
60
+ // provider can distinguish a procedure from a same-name UDF and select one
61
+ // exact overload. This is identity metadata, not a barrel bag.
62
+ if (token.__kind === "procedure" && Array.isArray(token.parameterTypes)) {
63
+ out.parameterTypes = token.parameterTypes.filter((type) => typeof type === "string");
64
+ }
65
+ if (token.__kind === "procedure" && typeof token.databaseName === "string")
66
+ out.databaseName = token.databaseName;
67
+ if (token.__kind === "procedure" && typeof token.schemaName === "string")
68
+ out.schemaName = token.schemaName;
59
69
  // Search-table resource selection is generated by catalog factories, not
60
70
  // authored as public API. Preserve the private discriminator so tool HCL
61
71
  // can reference the correct resource family.
@@ -36,7 +36,7 @@ import type { AiProviderLlmModel, AiProviderType } from "./ai-provider-models.js
36
36
  * resolved to the current-version param/output id via the parent
37
37
  * automation's state binding.
38
38
  */
39
- export type CatalogRefKind = "automation" | "agent" | "agent-evaluation" | "chart" | "dashboard" | "skill" | "visual-flow" | "approvalChain" | "table" | "tableColumn" | "cloudLink" | "storedFunction" | "field" | "searchTable" | "documentModel" | "documentModelField" | "connector" | "aiProvider" | "category" | "group" | "phoneProvider" | "phone-service" | "datamine" | "app" | "element" | "task" | "triggerParameter" | "outputProperty";
39
+ export type CatalogRefKind = "automation" | "agent" | "agent-evaluation" | "chart" | "dashboard" | "skill" | "visual-flow" | "approvalChain" | "table" | "tableColumn" | "cloudLink" | "storedFunction" | "procedure" | "field" | "searchTable" | "documentModel" | "documentModelField" | "connector" | "aiProvider" | "category" | "group" | "phoneProvider" | "phone-service" | "datamine" | "app" | "element" | "task" | "triggerParameter" | "outputProperty";
40
40
  /**
41
41
  * The reference surface for a catalog entity. `handle` is the stable join key
42
42
  * (no id); `name` is for readability/diagnostics, never a match key.
@@ -141,13 +141,31 @@ export interface AiProviderRef<T extends AiProviderType = AiProviderType> extend
141
141
  }
142
142
  /** Scalar calculation families supported by configured stored functions. */
143
143
  export type StoredFunctionScalarType = "number" | "decimal" | "bool" | "date" | "datetime" | "handle" | "json" | "text";
144
+ /** Exact Snowflake signature types used to disambiguate overloaded procedures. */
145
+ export declare const PROCEDURE_PARAMETER_TYPES: readonly ["BOOLEAN", "DATE", "DATETIME", "DECIMAL", "HANDLE", "JSON", "LONG", "TEXT", "UUID"];
146
+ export type ProcedureParameterType = typeof PROCEDURE_PARAMETER_TYPES[number];
144
147
  export interface StoredFunctionRef<Parameters extends readonly StoredFunctionScalarType[] = readonly StoredFunctionScalarType[], Result extends StoredFunctionScalarType = StoredFunctionScalarType> extends CatalogRef<"storedFunction"> {
145
148
  readonly parent: string;
146
149
  readonly parameterTypes: Parameters;
147
150
  readonly resultType: Result;
148
151
  }
149
- export interface CloudLinkRef<Functions extends Readonly<Record<string, StoredFunctionRef>> = Readonly<Record<string, StoredFunctionRef>>> extends CatalogRef<"cloudLink"> {
152
+ /** A configured Snowflake procedure callable by an automation's Run Function task. */
153
+ export interface ProcedureRef<Parameters extends readonly ProcedureParameterType[] = readonly ProcedureParameterType[], Result extends StoredFunctionScalarType = StoredFunctionScalarType> extends CatalogRef<"procedure"> {
154
+ /** Owning CloudLink catalog key, stamped by {@link orgCatalog}. */
155
+ readonly parent: string;
156
+ /** Owning CloudLink display name, needed for the Terraform data lookup. */
157
+ readonly parentName?: string;
158
+ /** Snowflake database containing this configured procedure. */
159
+ readonly databaseName: string;
160
+ /** Snowflake schema containing this configured procedure. */
161
+ readonly schemaName: string;
162
+ /** Exact ordered Snowflake argument signature used by the provider lookup. */
163
+ readonly parameterTypes: Parameters;
164
+ readonly resultType: Result;
165
+ }
166
+ export interface CloudLinkRef<Functions extends Readonly<Record<string, StoredFunctionRef>> = Readonly<Record<string, StoredFunctionRef>>, Procedures extends Readonly<Record<string, ProcedureRef>> = Readonly<Record<string, ProcedureRef>>> extends CatalogRef<"cloudLink"> {
150
167
  readonly storedFunctions?: Functions;
168
+ readonly procedures?: Procedures;
151
169
  }
152
170
  /** Org-owned reference identities from `elementum pull org --data-only` (pristine-refactor). */
153
171
  export type CategoryRef = CatalogRef<"category">;
@@ -23,6 +23,10 @@
23
23
  * schema is authoring-only — at the wire boundary `resolvePayload` replaces the
24
24
  * whole token with the resolved id, discarding it.
25
25
  */
26
+ /** Exact Snowflake signature types used to disambiguate overloaded procedures. */
27
+ export const PROCEDURE_PARAMETER_TYPES = [
28
+ "BOOLEAN", "DATE", "DATETIME", "DECIMAL", "HANDLE", "JSON", "LONG", "TEXT", "UUID",
29
+ ];
26
30
  /** Platform-owned user attributes accepted by user-search task filters. */
27
31
  export const USER_FIELD_KEYS = ["firstName", "email", "jobTitle", "lastName"];
28
32
  /**
@@ -45,6 +49,7 @@ export const REF_SCOPE = {
45
49
  tableColumn: "org",
46
50
  cloudLink: "org",
47
51
  storedFunction: "org",
52
+ procedure: "org",
48
53
  field: "app",
49
54
  searchTable: "app",
50
55
  datamine: "app",
@@ -8,4 +8,4 @@ export { user, type UserRef } from "./types/user.js";
8
8
  export { group, type GroupRef } from "./types/group.js";
9
9
  export { cloudLink, type CloudLink } from "./types/cloud-link.js";
10
10
  export { category, type AspectCategoryRef } from "./types/aspect-category.js";
11
- export { unsafePlatformId, type UnsafePlatformId } from "./platform-id.js";
11
+ export { isUnsafePlatformId, unsafePlatformId, type UnsafePlatformId } from "./platform-id.js";
@@ -7,4 +7,4 @@ export { user } from "./types/user.js";
7
7
  export { group } from "./types/group.js";
8
8
  export { cloudLink } from "./types/cloud-link.js";
9
9
  export { category } from "./types/aspect-category.js";
10
- export { unsafePlatformId } from "./platform-id.js";
10
+ export { isUnsafePlatformId, unsafePlatformId } from "./platform-id.js";
@@ -9,3 +9,5 @@ export interface UnsafePlatformId {
9
9
  }
10
10
  /** Mark a non-portable platform id intentionally. Prefer catalog refs whenever possible. */
11
11
  export declare function unsafePlatformId(value: string): UnsafePlatformId;
12
+ /** Check whether `value` is an `UnsafePlatformId` wrapper. */
13
+ export declare function isUnsafePlatformId(value: unknown): value is UnsafePlatformId;
@@ -6,3 +6,7 @@ export function unsafePlatformId(value) {
6
6
  }
7
7
  return { __unsafe: "platformId", value };
8
8
  }
9
+ /** Check whether `value` is an `UnsafePlatformId` wrapper. */
10
+ export function isUnsafePlatformId(value) {
11
+ return typeof value === "object" && value !== null && value.__unsafe === "platformId";
12
+ }
@@ -92,6 +92,20 @@ export declare const DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES: Readonly<Record<SystemFi
92
92
  * platform cosmetics EDK doesn't model (the HCL fold emits labels only).
93
93
  */
94
94
  export declare const DEPLOY_DEFAULT_STATUS_OPTIONS: readonly string[];
95
+ /** Provider HCL values for the status options created by the platform baseline. */
96
+ export declare const DEPLOY_DEFAULT_STATUS_OPTION_VALUES: readonly [{
97
+ readonly label: "Open";
98
+ readonly color: "#3B82F6";
99
+ readonly tags: readonly [];
100
+ }, {
101
+ readonly label: "In Progress";
102
+ readonly color: "#F59E0B";
103
+ readonly tags: readonly [];
104
+ }, {
105
+ readonly label: "Closed";
106
+ readonly color: "#10B981";
107
+ readonly tags: readonly ["CLOSED"];
108
+ }];
95
109
  /**
96
110
  * Whether the provider marks the auto-created field `required` — synthesized
97
111
  * into the compose payload so the wire shape matches what terraform creates.
@@ -150,6 +150,12 @@ export const DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES = {
150
150
  * platform cosmetics EDK doesn't model (the HCL fold emits labels only).
151
151
  */
152
152
  export const DEPLOY_DEFAULT_STATUS_OPTIONS = ["Open", "In Progress", "Closed"];
153
+ /** Provider HCL values for the status options created by the platform baseline. */
154
+ export const DEPLOY_DEFAULT_STATUS_OPTION_VALUES = [
155
+ { label: "Open", color: "#3B82F6", tags: [] },
156
+ { label: "In Progress", color: "#F59E0B", tags: [] },
157
+ { label: "Closed", color: "#10B981", tags: ["CLOSED"] },
158
+ ];
153
159
  /**
154
160
  * Whether the provider marks the auto-created field `required` — synthesized
155
161
  * into the compose payload so the wire shape matches what terraform creates.