@elementumai/edk 0.9.17 → 0.9.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -3
- package/dist-sdk/src/catalog/factories.d.ts +11 -0
- package/dist-sdk/src/catalog/factories.js +6 -0
- package/dist-sdk/src/catalog/index.d.ts +2 -2
- package/dist-sdk/src/catalog/index.js +2 -2
- package/dist-sdk/src/catalog/org.d.ts +39 -1
- package/dist-sdk/src/catalog/org.js +460 -50
- package/dist-sdk/src/catalog/types.d.ts +12 -2
- package/dist-sdk/src/catalog/types.js +2 -0
- package/dist-sdk/src/engine/pull/ref-only.js +54 -20
- package/dist-sdk/src/engine/pull/result-output.d.ts +2 -0
- package/dist-sdk/src/engine/pull/result-output.js +1 -1
- package/dist-sdk/src/engine/tf/expr.js +38 -13
- package/dist-sdk/src/engine/tf/index.d.ts +2 -2
- package/dist-sdk/src/engine/tf/index.js +2 -2
- package/dist-sdk/src/engine/tf/labels.d.ts +2 -0
- package/dist-sdk/src/engine/tf/labels.js +4 -0
- package/dist-sdk/src/engine/tf/parse.d.ts +19 -0
- package/dist-sdk/src/engine/tf/parse.js +105 -6
- package/dist-sdk/src/engine/workspace/loader.js +49 -12
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +11 -1
- package/dist-sdk/src/entities/access-policy/from-tf.js +6 -1
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +11 -0
- package/dist-sdk/src/entities/access-policy/to-tf.js +11 -4
- package/dist-sdk/src/entities/agent-tool/to-tf.js +2 -1
- package/dist-sdk/src/entities/app/build.d.ts +10 -0
- package/dist-sdk/src/entities/app/build.js +0 -13
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +6 -1
- package/dist-sdk/src/entities/app/from-tf.js +4 -3
- package/dist-sdk/src/entities/app/index.d.ts +2 -0
- package/dist-sdk/src/entities/app/index.js +1 -0
- package/dist-sdk/src/entities/app/module.js +13 -0
- package/dist-sdk/src/entities/app/to-tf.js +2 -0
- package/dist-sdk/src/entities/automation/build.d.ts +2 -1
- package/dist-sdk/src/entities/automation/build.js +27 -0
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +6 -0
- package/dist-sdk/src/entities/automation/from-tf.js +156 -26
- package/dist-sdk/src/entities/automation/index.d.ts +1 -1
- package/dist-sdk/src/entities/automation/module.d.ts +2 -0
- package/dist-sdk/src/entities/automation/module.js +56 -0
- package/dist-sdk/src/entities/automation/output-field-types.d.ts +5 -4
- package/dist-sdk/src/entities/automation/output-field-types.js +23 -5
- package/dist-sdk/src/entities/automation/system-ref-name.d.ts +16 -0
- package/dist-sdk/src/entities/automation/system-ref-name.js +44 -0
- package/dist-sdk/src/entities/automation/task-output-labels.d.ts +15 -0
- package/dist-sdk/src/entities/automation/task-output-labels.js +38 -0
- package/dist-sdk/src/entities/automation/tasks.d.ts +37 -5
- package/dist-sdk/src/entities/automation/tasks.js +23 -1
- package/dist-sdk/src/entities/automation/to-tf.js +158 -84
- package/dist-sdk/src/entities/automation/types.js +1 -0
- package/dist-sdk/src/entities/chart/from-tf.js +33 -17
- package/dist-sdk/src/entities/chart/module.js +3 -1
- package/dist-sdk/src/entities/chart/printer.d.ts +1 -0
- package/dist-sdk/src/entities/chart/printer.js +26 -16
- package/dist-sdk/src/entities/chart/rebind-owner.d.ts +3 -0
- package/dist-sdk/src/entities/chart/rebind-owner.js +42 -0
- package/dist-sdk/src/entities/chart/to-tf.js +12 -10
- package/dist-sdk/src/entities/dashboard/build.d.ts +4 -0
- package/dist-sdk/src/entities/dashboard/from-tf.js +15 -4
- package/dist-sdk/src/entities/dashboard/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/dashboard/to-tf.js +13 -0
- package/dist-sdk/src/entities/dashboard-widget/module.js +4 -0
- package/dist-sdk/src/entities/dynamic-layout/build.d.ts +51 -2
- package/dist-sdk/src/entities/dynamic-layout/dialect.d.ts +3 -0
- package/dist-sdk/src/entities/dynamic-layout/dialect.js +5 -0
- package/dist-sdk/src/entities/dynamic-layout/from-tf.d.ts +9 -6
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +188 -26
- package/dist-sdk/src/entities/dynamic-layout/module.js +4 -1
- package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +5 -1
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +254 -23
- package/dist-sdk/src/entities/element/build.d.ts +8 -0
- package/dist-sdk/src/entities/element/build.js +1 -0
- package/dist-sdk/src/entities/element/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/element/from-tf.js +6 -2
- package/dist-sdk/src/entities/element/index.d.ts +1 -0
- package/dist-sdk/src/entities/element/index.js +1 -0
- package/dist-sdk/src/entities/element/module.js +2 -0
- package/dist-sdk/src/entities/element/to-tf.js +12 -0
- package/dist-sdk/src/entities/field/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/field/from-tf.js +11 -0
- package/dist-sdk/src/entities/field/to-tf.js +13 -9
- package/dist-sdk/src/entities/relationship/from-tf.d.ts +8 -1
- package/dist-sdk/src/entities/relationship/from-tf.js +53 -10
- package/dist-sdk/src/entities/relationship/to-tf.d.ts +8 -0
- package/dist-sdk/src/entities/relationship/to-tf.js +19 -10
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +7 -2
- package/dist-sdk/src/entities/shared/filters/index.d.ts +23 -2
- package/dist-sdk/src/entities/shared/filters/index.js +24 -1
- package/dist-sdk/src/entities/shared/filters/print.js +22 -4
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +23 -3
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +60 -18
- package/dist-sdk/src/entities/shared/filters/types.d.ts +13 -4
- package/dist-sdk/src/entities/shared/foreign-ref.d.ts +16 -0
- package/dist-sdk/src/entities/shared/foreign-ref.js +17 -1
- package/dist-sdk/src/entities/shared/tool-field-ref.js +6 -9
- package/dist-sdk/src/entities/skill/access-policy.d.ts +17 -0
- package/dist-sdk/src/entities/skill/access-policy.js +101 -0
- package/dist-sdk/src/entities/skill/build.d.ts +3 -0
- package/dist-sdk/src/entities/skill/build.js +3 -0
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +4 -1
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +21 -0
- package/dist-sdk/src/entities/skill/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/skill/from-tf.js +4 -9
- package/dist-sdk/src/entities/skill/index.d.ts +2 -0
- package/dist-sdk/src/entities/skill/index.js +1 -0
- package/dist-sdk/src/entities/skill/module.js +1 -0
- package/dist-sdk/src/entities/skill/to-tf.d.ts +2 -2
- package/dist-sdk/src/entities/skill/to-tf.js +5 -2
- package/dist-sdk/src/entities/skill-tool/to-tf.js +2 -1
- package/dist-sdk/src/entities/table/to-tf.js +3 -3
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +49 -0
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +224 -0
- package/dist-sdk/src/entities/view/agent-view-layout-to-tf.d.ts +36 -0
- package/dist-sdk/src/entities/view/agent-view-layout-to-tf.js +288 -0
- package/dist-sdk/src/entities/view/agent-view-layout.d.ts +121 -0
- package/dist-sdk/src/entities/view/agent-view-layout.js +21 -0
- package/dist-sdk/src/entities/view/from-tf.d.ts +3 -1
- package/dist-sdk/src/entities/view/from-tf.js +42 -7
- package/dist-sdk/src/entities/view/ragnarok.d.ts +7 -0
- package/dist-sdk/src/entities/view/ragnarok.js +1 -0
- package/dist-sdk/src/entities/view/to-tf.d.ts +10 -1
- package/dist-sdk/src/entities/view/to-tf.js +30 -1
- package/dist-sdk/src/entities/view/types.js +2 -0
- package/dist-sdk/src/entities/widget/to-tf.js +2 -2
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +815 -0
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +5 -0
- package/dist-sdk/src/graph/index.d.ts +43 -0
- package/dist-sdk/src/graph/index.js +9 -0
- package/dist-sdk/src/graph/types.d.ts +78 -0
- package/package.json +11 -1
|
@@ -16,9 +16,10 @@
|
|
|
16
16
|
* Called by every import command that touches org state (importApp,
|
|
17
17
|
* importCloudLinks, importConnectors) so the catalog is always in sync.
|
|
18
18
|
*/
|
|
19
|
+
import { spawnSync } from "node:child_process";
|
|
19
20
|
import { existsSync } from "node:fs";
|
|
20
21
|
import { readdir } from "node:fs/promises";
|
|
21
|
-
import { mkdir, writeFile } from "node:fs/promises";
|
|
22
|
+
import { appendFile, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
22
23
|
import { join } from "node:path";
|
|
23
24
|
import { AI_PROVIDER_TYPE_BY_RESOURCE_TYPE, ORG_IDENTITY_BAGS, orgRootOwnFileBags } from "../graph/index.js";
|
|
24
25
|
import { sanitizeName, tfLabelToTsLabel, tsLabelToTfLabel } from "../engine/tf/index.js";
|
|
@@ -29,27 +30,169 @@ import { writeTechnicalLog } from "../engine/progress.js";
|
|
|
29
30
|
// Public entry points
|
|
30
31
|
// ---------------------------------------------------------------------------
|
|
31
32
|
export async function writeOrgCatalogFromExtract(root, extract) {
|
|
32
|
-
const genDir = join(root, "generated");
|
|
33
|
-
const catalogPath = join(genDir, "catalog.ts");
|
|
34
33
|
const orgPath = join(root, "org.ts");
|
|
35
|
-
const
|
|
36
|
-
await mkdir(
|
|
34
|
+
const state = await readBarrelState(root);
|
|
35
|
+
await mkdir(join(root, "generated"), { recursive: true });
|
|
37
36
|
await writeFile(orgPath, renderOrgTs(extract), "utf8");
|
|
38
|
-
await
|
|
39
|
-
return { catalogPath, orgPath };
|
|
37
|
+
await writeBarrel(root, state);
|
|
38
|
+
return { catalogPath: join(root, BARREL_RELATIVE_PATH), orgPath };
|
|
40
39
|
}
|
|
41
40
|
/**
|
|
42
41
|
* Rewrite generated/catalog.ts ALONE from the current file tree — org.ts is
|
|
43
42
|
* untouched (it belongs to `pull org`). Called after a pull writes new
|
|
44
|
-
* authoring (apps/agents) so `@catalog` resolves the fresh entries.
|
|
43
|
+
* authoring (apps/agents) so `@catalog` resolves the fresh entries. While
|
|
44
|
+
* git may still track the barrel, entries it lists are kept even when their
|
|
45
|
+
* folder is not checked out (see {@link refreshCatalogBarrel}).
|
|
45
46
|
*/
|
|
46
47
|
export async function writeCatalogBarrel(root) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
await writeBarrel(root, await readBarrelState(root));
|
|
49
|
+
return join(root, BARREL_RELATIVE_PATH);
|
|
50
|
+
}
|
|
51
|
+
const BARREL_ENTRY_PATH = /"\.\.\/(apps|elements|tables)\/([^/"]+)\/generated\/catalog\.js"/g;
|
|
52
|
+
const BARREL_RELATIVE_PATH = "generated/catalog.ts";
|
|
53
|
+
export const ORG_BARREL_IGNORE_COMMENT = "# org catalog barrel — local derived state, written by elementum build/plan/apply and elementum generate";
|
|
54
|
+
export const ORG_BARREL_IGNORE_RULE = `/${BARREL_RELATIVE_PATH}`;
|
|
55
|
+
/**
|
|
56
|
+
* Only a definite "git does not track it" (or "not a repository") lets a
|
|
57
|
+
* writer drop entries. A failing git — dubious ownership, a corrupt index, no
|
|
58
|
+
* git binary — keeps them, since a missing folder may just not be checked out.
|
|
59
|
+
*/
|
|
60
|
+
function barrelGitStatus(root) {
|
|
61
|
+
const result = spawnSync("git", ["ls-files", "--error-unmatch", "--", BARREL_RELATIVE_PATH], {
|
|
62
|
+
cwd: root,
|
|
63
|
+
encoding: "utf8",
|
|
64
|
+
});
|
|
65
|
+
if (result.error !== undefined)
|
|
66
|
+
return { kind: "unknown", reason: `git could not run: ${result.error.message}` };
|
|
67
|
+
if (result.status === 0)
|
|
68
|
+
return { kind: "tracked" };
|
|
69
|
+
if (result.status === 1)
|
|
70
|
+
return { kind: "untracked" };
|
|
71
|
+
const stderr = (result.stderr ?? "").trim();
|
|
72
|
+
if (/not a git repository/i.test(stderr))
|
|
73
|
+
return { kind: "untracked" };
|
|
74
|
+
return { kind: "unknown", reason: stderr.split("\n")[0] || `git exited ${String(result.status)}` };
|
|
75
|
+
}
|
|
76
|
+
/** git's index copy of the barrel, for a tracked barrel deleted from the worktree. */
|
|
77
|
+
function indexedBarrel(root) {
|
|
78
|
+
const result = spawnSync("git", ["show", `:./${BARREL_RELATIVE_PATH}`], {
|
|
79
|
+
cwd: root,
|
|
80
|
+
encoding: "utf8",
|
|
81
|
+
maxBuffer: 16 * 1024 * 1024,
|
|
82
|
+
});
|
|
83
|
+
return result.status === 0 ? result.stdout : undefined;
|
|
84
|
+
}
|
|
85
|
+
async function readOptional(path) {
|
|
86
|
+
try {
|
|
87
|
+
return await readFile(path, "utf8");
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
if (error.code === "ENOENT")
|
|
91
|
+
return undefined;
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
async function readBarrelState(root) {
|
|
96
|
+
const worktree = await readOptional(join(root, BARREL_RELATIVE_PATH));
|
|
97
|
+
const git = barrelGitStatus(root);
|
|
98
|
+
const barrel = worktree ?? (git.kind === "tracked" ? indexedBarrel(root) : undefined);
|
|
99
|
+
const handles = await discoverOrgRootHandles(root);
|
|
100
|
+
const expected = new Set([
|
|
101
|
+
...handles.appHandles.map((h) => `apps/${h}`),
|
|
102
|
+
...handles.elementHandles.map((h) => `elements/${h}`),
|
|
103
|
+
...handles.tableHandles.map((h) => `tables/${h}`),
|
|
104
|
+
]);
|
|
105
|
+
const listed = new Set(barrel === undefined ? [] : [...barrel.matchAll(BARREL_ENTRY_PATH)].map((m) => `${m[1]}/${m[2]}`));
|
|
106
|
+
return {
|
|
107
|
+
present: worktree !== undefined,
|
|
108
|
+
git,
|
|
109
|
+
handles,
|
|
110
|
+
missing: [...expected].filter((e) => !listed.has(e)).sort(),
|
|
111
|
+
stale: [...listed].filter((e) => !expected.has(e)).sort(),
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
function keptReason(state) {
|
|
115
|
+
if (state.stale.length === 0)
|
|
116
|
+
return undefined;
|
|
117
|
+
if (state.git.kind === "tracked")
|
|
118
|
+
return `git tracks ${BARREL_RELATIVE_PATH}`;
|
|
119
|
+
if (state.git.kind === "unknown") {
|
|
120
|
+
return `git could not tell whether ${BARREL_RELATIVE_PATH} is tracked (${state.git.reason})`;
|
|
121
|
+
}
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
/** The exact handle sets reserved by every barrel writer and reference printer. */
|
|
125
|
+
function reservedBarrelHandles(state) {
|
|
126
|
+
const kept = keptReason(state) === undefined ? [] : state.stale;
|
|
127
|
+
const withKept = (bag, handles) => [...handles, ...kept.filter((e) => e.startsWith(`${bag}/`)).map((e) => e.slice(bag.length + 1))].sort();
|
|
128
|
+
return {
|
|
129
|
+
appHandles: withKept("apps", state.handles.appHandles),
|
|
130
|
+
elementHandles: withKept("elements", state.handles.elementHandles),
|
|
131
|
+
tableHandles: withKept("tables", state.handles.tableHandles),
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
/** Write the barrel from the tree plus any entries `keptReason` protects; returns the entry count. */
|
|
135
|
+
async function writeBarrel(root, state) {
|
|
136
|
+
const { appHandles: apps, elementHandles: elements, tableHandles: tables } = reservedBarrelHandles(state);
|
|
137
|
+
await mkdir(join(root, "generated"), { recursive: true });
|
|
138
|
+
await writeFile(join(root, BARREL_RELATIVE_PATH), renderBarrel(apps, elements, tables), "utf8");
|
|
139
|
+
await ensureBarrelIgnored(root);
|
|
140
|
+
return apps.length + elements.length + tables.length;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Compare generated/catalog.ts against the catalogs `writeCatalogBarrel`
|
|
144
|
+
* would list today. Entries are matched by their `../<bag>/<handle>/generated/catalog.js`
|
|
145
|
+
* path so older barrel renderings compare the same.
|
|
146
|
+
*/
|
|
147
|
+
export async function findCatalogBarrelDrift(root) {
|
|
148
|
+
const { missing, stale } = await readBarrelState(root);
|
|
149
|
+
return { missing, stale };
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Bring generated/catalog.ts in line with the catalogs on disk when it is
|
|
153
|
+
* absent or lists a different set of entries, and make sure the org
|
|
154
|
+
* .gitignore covers it. While git may still track the barrel, a missing
|
|
155
|
+
* folder may just not be checked out, so entries are only added, never
|
|
156
|
+
* dropped — otherwise a partial tree would commit the very truncation this
|
|
157
|
+
* guards. Every barrel writer shares that rule.
|
|
158
|
+
*/
|
|
159
|
+
export async function refreshCatalogBarrel(root) {
|
|
160
|
+
const state = await readBarrelState(root);
|
|
161
|
+
const { missing, stale } = state;
|
|
162
|
+
const reason = keptReason(state);
|
|
163
|
+
const kept = { keptStale: reason !== undefined, ...(reason !== undefined && { keptReason: reason }) };
|
|
164
|
+
if (state.present && missing.length === 0 && (stale.length === 0 || reason !== undefined)) {
|
|
165
|
+
await ensureBarrelIgnored(root);
|
|
166
|
+
const entries = state.handles.appHandles.length + state.handles.elementHandles.length +
|
|
167
|
+
state.handles.tableHandles.length + (reason === undefined ? 0 : stale.length);
|
|
168
|
+
return { missing, stale, created: false, written: false, entries, ...kept };
|
|
169
|
+
}
|
|
170
|
+
const entries = await writeBarrel(root, state);
|
|
171
|
+
return { missing, stale, created: !state.present, written: true, entries, ...kept };
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Add the ignore rule to the org-root .gitignore unless git already ignores
|
|
175
|
+
* the barrel. Outside a repository, or without git, leave the tree alone.
|
|
176
|
+
*/
|
|
177
|
+
async function ensureBarrelIgnored(root) {
|
|
178
|
+
const path = join(root, ".gitignore");
|
|
179
|
+
const existing = (await readOptional(path)) ?? "";
|
|
180
|
+
if (existing.split(/\r?\n/).includes(ORG_BARREL_IGNORE_RULE))
|
|
181
|
+
return;
|
|
182
|
+
const check = spawnSync("git", ["check-ignore", "-q", "--no-index", "--", BARREL_RELATIVE_PATH], {
|
|
183
|
+
cwd: root,
|
|
184
|
+
stdio: "ignore",
|
|
185
|
+
});
|
|
186
|
+
if (check.status !== 1)
|
|
187
|
+
return;
|
|
188
|
+
const prefix = existing === "" || existing.endsWith("\n") ? "" : "\n";
|
|
189
|
+
await appendFile(path, `${prefix}${ORG_BARREL_IGNORE_COMMENT}\n${ORG_BARREL_IGNORE_RULE}\n`, "utf8");
|
|
190
|
+
}
|
|
191
|
+
/** Element keys, reserving all app/element catalogs about to be written. */
|
|
192
|
+
export async function readElementCatalogKeys(root, pendingAppHandles = [], pendingElementHandles = []) {
|
|
193
|
+
const { appHandles, elementHandles } = reservedBarrelHandles(await readBarrelState(root));
|
|
194
|
+
// Match discoverHandles' lexical order, including elements not on disk yet.
|
|
195
|
+
return computeElementKeys([...new Set([...appHandles, ...pendingAppHandles])], [...new Set([...elementHandles, ...pendingElementHandles])].sort());
|
|
53
196
|
}
|
|
54
197
|
/** Render generated/org.ts from the stream extract — bag/factory from CatalogFacet. */
|
|
55
198
|
function renderOrgTs(extract) {
|
|
@@ -67,19 +210,7 @@ function renderOrgTs(extract) {
|
|
|
67
210
|
// they never appear in `bags` above. Models nest on their provider instead
|
|
68
211
|
// (`aiProviders.<provider>.models.<model>`), rendered specially here.
|
|
69
212
|
const aiProvidersLines = renderAiProvidersBag(extract);
|
|
70
|
-
const supportedFunctionsByCloudLink =
|
|
71
|
-
const supportedProceduresByCloudLink = new Map();
|
|
72
|
-
for (const fn of extract.storedFunctions ?? []) {
|
|
73
|
-
const mapped = supportedStoredFunction(fn);
|
|
74
|
-
if (mapped === undefined)
|
|
75
|
-
continue;
|
|
76
|
-
const target = fn.functionType === "PROCEDURE"
|
|
77
|
-
? supportedProceduresByCloudLink
|
|
78
|
-
: supportedFunctionsByCloudLink;
|
|
79
|
-
const entries = target.get(fn.cloudLinkName) ?? [];
|
|
80
|
-
entries.push({ fn, mapped });
|
|
81
|
-
target.set(fn.cloudLinkName, entries);
|
|
82
|
-
}
|
|
213
|
+
const { functionsByCloudLink: supportedFunctionsByCloudLink, proceduresByCloudLink: supportedProceduresByCloudLink, } = catalogStoredFunctions(extract.storedFunctions ?? []);
|
|
83
214
|
const factories = new Set(["orgCatalog", ...bags.map((b) => b.factory)]);
|
|
84
215
|
if (aiProvidersLines.length > 0) {
|
|
85
216
|
factories.add("aiProvider");
|
|
@@ -114,18 +245,14 @@ function renderOrgTs(extract) {
|
|
|
114
245
|
lines.push(` ${e.tsLabel}: ${factory}({ name: ${q(e.name)},`);
|
|
115
246
|
if (functions.length > 0) {
|
|
116
247
|
lines.push(" storedFunctions: {");
|
|
117
|
-
const
|
|
118
|
-
for (const { fn, mapped } of functions) {
|
|
119
|
-
const key = uniqueCatalogKey(tfLabelToTsLabel(sanitizeName(fn.name)), used);
|
|
248
|
+
for (const { fn, mapped, key } of functions) {
|
|
120
249
|
lines.push(` ${key}: storedFunctionRef({ name: ${q(fn.name)}, parameters: ${JSON.stringify(mapped.parameters)}, result: ${q(mapped.result)} }),`);
|
|
121
250
|
}
|
|
122
251
|
lines.push(" },");
|
|
123
252
|
}
|
|
124
253
|
if (procedures.length > 0) {
|
|
125
254
|
lines.push(" procedures: {");
|
|
126
|
-
const
|
|
127
|
-
for (const { fn, mapped } of procedures) {
|
|
128
|
-
const key = uniqueCatalogKey(tfLabelToTsLabel(sanitizeName(fn.name)), used);
|
|
255
|
+
for (const { fn, mapped, key } of procedures) {
|
|
129
256
|
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)} }),`);
|
|
130
257
|
}
|
|
131
258
|
lines.push(" },");
|
|
@@ -150,24 +277,300 @@ const STORED_FUNCTION_TYPE = {
|
|
|
150
277
|
UUID: "text",
|
|
151
278
|
BINARY: undefined,
|
|
152
279
|
};
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
280
|
+
/**
|
|
281
|
+
* Why a stored function is left out of org.ts, in report order. Each reason
|
|
282
|
+
* is reported as ONE summary line per pull — a Snowflake CloudLink routinely
|
|
283
|
+
* holds many functions the catalog can't expose, and a line per function
|
|
284
|
+
* buries the warnings that need action. Table results are an expected
|
|
285
|
+
* platform limitation (Run Function rejects table output; calculations take
|
|
286
|
+
* scalars), so they are INFO; everything else may need a builder's attention.
|
|
287
|
+
*/
|
|
288
|
+
const STORED_FUNCTION_OMISSIONS = {
|
|
289
|
+
procedureTableResult: {
|
|
290
|
+
level: "INFO",
|
|
291
|
+
summary: (count, noun) => `omitted ${count} ${noun} with ${count === 1 ? "a TABLE result" : "TABLE results"} (automations cannot call table-returning procedures)`,
|
|
292
|
+
},
|
|
293
|
+
functionTableResult: {
|
|
294
|
+
level: "INFO",
|
|
295
|
+
summary: (count, noun) => `omitted ${count} ${noun} with ${count === 1 ? "a TABLE result" : "TABLE results"} (calculations cannot call table-returning functions)`,
|
|
296
|
+
},
|
|
297
|
+
unknownType: {
|
|
298
|
+
level: "WARN",
|
|
299
|
+
summary: (count, noun) => `omitted ${count} ${noun} with an unrecognized function type`,
|
|
300
|
+
},
|
|
301
|
+
notConfigured: {
|
|
302
|
+
level: "WARN",
|
|
303
|
+
summary: (count, noun) => `omitted ${count} ${noun} that ${count === 1 ? "is" : "are"} not configured in Elementum`,
|
|
304
|
+
},
|
|
305
|
+
procedureAutoIncrementArgument: {
|
|
306
|
+
level: "WARN",
|
|
307
|
+
summary: (count, noun) => `omitted ${count} ${noun} with an AUTO_INCREMENT argument (automations built with the EDK cannot pass AUTO_INCREMENT values)`,
|
|
308
|
+
},
|
|
309
|
+
unsupportedResult: {
|
|
310
|
+
level: "WARN",
|
|
311
|
+
summary: (count, noun) => `omitted ${count} ${noun} with an unsupported result type`,
|
|
312
|
+
},
|
|
313
|
+
unsupportedArgument: {
|
|
314
|
+
level: "WARN",
|
|
315
|
+
summary: (count, noun) => `omitted ${count} ${noun} with an unsupported argument type`,
|
|
316
|
+
},
|
|
317
|
+
};
|
|
318
|
+
function classifyStoredFunction(fn) {
|
|
319
|
+
const omitted = (reason, detail) => ({ kind: "omitted", reason, ...(detail !== undefined && { detail }) });
|
|
320
|
+
if (fn.functionType !== "USER_DEFINED_FUNCTION" && fn.functionType !== "PROCEDURE")
|
|
321
|
+
return omitted("unknownType", fn.functionType);
|
|
322
|
+
if (!fn.configured)
|
|
323
|
+
return omitted("notConfigured");
|
|
324
|
+
if (fn.returnType === "TABLE")
|
|
325
|
+
return omitted(fn.functionType === "PROCEDURE" ? "procedureTableResult" : "functionTableResult");
|
|
326
|
+
if (fn.functionType === "PROCEDURE" && fn.parameterTypes.includes("AUTO_INCREMENT"))
|
|
327
|
+
return omitted("procedureAutoIncrementArgument");
|
|
328
|
+
const result = STORED_FUNCTION_TYPE[fn.returnType];
|
|
329
|
+
if (result === undefined)
|
|
330
|
+
return omitted("unsupportedResult", fn.returnType);
|
|
331
|
+
const unsupported = [...new Set(fn.parameterTypes.filter((type) => STORED_FUNCTION_TYPE[type] === undefined))];
|
|
332
|
+
if (unsupported.length > 0)
|
|
333
|
+
return omitted("unsupportedArgument", unsupported.join(", "));
|
|
334
|
+
return {
|
|
335
|
+
kind: "catalog",
|
|
336
|
+
signature: { parameters: fn.parameterTypes.map((type) => STORED_FUNCTION_TYPE[type]), result },
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* The provider's `elementum_stored_function` selector: CloudLink, name,
|
|
341
|
+
* database, schema, type, and parameter types, compared case-insensitively
|
|
342
|
+
* (`selectStoredFunction` uses EqualFold and never reads the computed
|
|
343
|
+
* `return_type`). Records that share this key are indistinguishable to the
|
|
344
|
+
* data lookup, which fails as ambiguous when more than one matches. The
|
|
345
|
+
* platform no longer enforces uniqueness, so one Snowflake function can be
|
|
346
|
+
* configured twice. Configured state is excluded: the lookup sees configured
|
|
347
|
+
* and unconfigured records alike.
|
|
348
|
+
*/
|
|
349
|
+
function storedFunctionSelectorKey(fn) {
|
|
350
|
+
return JSON.stringify([
|
|
351
|
+
fn.cloudLinkName,
|
|
352
|
+
fn.name.toUpperCase(),
|
|
353
|
+
fn.databaseName.toUpperCase(),
|
|
354
|
+
fn.schemaName.toUpperCase(),
|
|
355
|
+
fn.functionType.toUpperCase(),
|
|
356
|
+
fn.parameterTypes.map((type) => type.toUpperCase()),
|
|
357
|
+
]);
|
|
358
|
+
}
|
|
359
|
+
/** `DATABASE.SCHEMA.NAME(TYPE, TYPE)`: one exact signature, as diagnostics name it. */
|
|
360
|
+
function storedFunctionSignatureLabel(fn) {
|
|
361
|
+
return `${fn.databaseName}.${fn.schemaName}.${fn.name}(${fn.parameterTypes.join(", ")})`;
|
|
362
|
+
}
|
|
363
|
+
function storedFunctionBaseKey(fn) {
|
|
364
|
+
return tfLabelToTsLabel(sanitizeName(fn.name));
|
|
365
|
+
}
|
|
366
|
+
function storedFunctionBagId(fn) {
|
|
367
|
+
return `${fn.functionType === "PROCEDURE" ? "procedures" : "storedFunctions"}\u0000${fn.cloudLinkName}`;
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Partition the export's stored functions into the per-CloudLink entries
|
|
371
|
+
* org.ts lists, and report what it leaves out.
|
|
372
|
+
*
|
|
373
|
+
* Records with the same provider selector ({@link storedFunctionSelectorKey})
|
|
374
|
+
* are one lookup target:
|
|
375
|
+
* - same result type: ONE entry under the base key. A numbered twin
|
|
376
|
+
* (`greetPerson2`) is never usable — the lookup is ambiguous whenever two
|
|
377
|
+
* records match — and it would leave the surviving key unstable once an
|
|
378
|
+
* admin removes the duplicate;
|
|
379
|
+
* - different result types: no entry. Picking one result type would hide
|
|
380
|
+
* that the lookup cannot select either configuration.
|
|
381
|
+
* Distinct-signature overloads are separate entries and keep
|
|
382
|
+
* {@link uniqueCatalogKey}'s numeric suffixes. Earlier pulls numbered every
|
|
383
|
+
* catalogable record, duplicates included; any overload whose key changes
|
|
384
|
+
* because duplicates no longer take a suffix is reported, old → new.
|
|
385
|
+
*/
|
|
386
|
+
function catalogStoredFunctions(functions) {
|
|
387
|
+
// Keys as earlier pulls assigned them: every catalogable record in export
|
|
388
|
+
// order. Each occurrence consumes a suffix, but an object listed more than
|
|
389
|
+
// once keeps the key of its first occurrence — the one it is listed under.
|
|
390
|
+
const previousKeys = new Map();
|
|
391
|
+
const previousUsed = new Map();
|
|
392
|
+
for (const fn of functions) {
|
|
393
|
+
if (classifyStoredFunction(fn).kind !== "catalog")
|
|
394
|
+
continue;
|
|
395
|
+
const used = previousUsed.get(storedFunctionBagId(fn)) ?? new Set();
|
|
396
|
+
previousUsed.set(storedFunctionBagId(fn), used);
|
|
397
|
+
const key = uniqueCatalogKey(storedFunctionBaseKey(fn), used);
|
|
398
|
+
if (!previousKeys.has(fn))
|
|
399
|
+
previousKeys.set(fn, key);
|
|
165
400
|
}
|
|
401
|
+
const groups = new Map();
|
|
402
|
+
for (const fn of functions) {
|
|
403
|
+
const selector = storedFunctionSelectorKey(fn);
|
|
404
|
+
const group = groups.get(selector);
|
|
405
|
+
if (group === undefined)
|
|
406
|
+
groups.set(selector, [fn]);
|
|
407
|
+
else
|
|
408
|
+
group.push(fn);
|
|
409
|
+
}
|
|
410
|
+
const functionsByCloudLink = new Map();
|
|
411
|
+
const proceduresByCloudLink = new Map();
|
|
412
|
+
const omitted = new Map();
|
|
413
|
+
const duplicated = [];
|
|
414
|
+
const conflicting = [];
|
|
415
|
+
const keyUsed = new Map();
|
|
416
|
+
const renumbered = [];
|
|
417
|
+
for (const group of groups.values()) {
|
|
418
|
+
const outcomes = group.map((fn) => ({ fn, outcome: classifyStoredFunction(fn) }));
|
|
419
|
+
const listed = outcomes.find(({ outcome }) => outcome.kind === "catalog");
|
|
420
|
+
if (listed === undefined || listed.outcome.kind !== "catalog") {
|
|
421
|
+
// A duplicate that is omitted anyway is reported once, for the reason
|
|
422
|
+
// it is omitted; removing the duplicate would not make it callable.
|
|
423
|
+
for (const { fn, outcome } of outcomes) {
|
|
424
|
+
if (outcome.kind !== "omitted")
|
|
425
|
+
continue;
|
|
426
|
+
const entries = omitted.get(outcome.reason) ?? [];
|
|
427
|
+
entries.push({ fn, ...(outcome.detail !== undefined && { detail: outcome.detail }) });
|
|
428
|
+
omitted.set(outcome.reason, entries);
|
|
429
|
+
}
|
|
430
|
+
continue;
|
|
431
|
+
}
|
|
432
|
+
const resultTypes = [...new Set(group.map((fn) => fn.returnType.toUpperCase()))].sort();
|
|
433
|
+
if (resultTypes.length > 1) {
|
|
434
|
+
conflicting.push({ fn: listed.fn, resultTypes });
|
|
435
|
+
continue;
|
|
436
|
+
}
|
|
437
|
+
if (group.length > 1)
|
|
438
|
+
duplicated.push(listed.fn);
|
|
439
|
+
const used = keyUsed.get(storedFunctionBagId(listed.fn)) ?? new Set();
|
|
440
|
+
keyUsed.set(storedFunctionBagId(listed.fn), used);
|
|
441
|
+
const key = uniqueCatalogKey(storedFunctionBaseKey(listed.fn), used);
|
|
442
|
+
const previous = previousKeys.get(listed.fn);
|
|
443
|
+
if (previous !== undefined && previous !== key)
|
|
444
|
+
renumbered.push({ fn: listed.fn, previous, key });
|
|
445
|
+
const target = listed.fn.functionType === "PROCEDURE" ? proceduresByCloudLink : functionsByCloudLink;
|
|
446
|
+
const entries = target.get(listed.fn.cloudLinkName) ?? [];
|
|
447
|
+
entries.push({ fn: listed.fn, mapped: listed.outcome.signature, key });
|
|
448
|
+
target.set(listed.fn.cloudLinkName, entries);
|
|
449
|
+
}
|
|
450
|
+
for (const [reason, report] of Object.entries(STORED_FUNCTION_OMISSIONS)) {
|
|
451
|
+
const entries = omitted.get(reason);
|
|
452
|
+
if (entries === undefined)
|
|
453
|
+
continue;
|
|
454
|
+
const listing = listStoredFunctionNames(entries);
|
|
455
|
+
const noun = storedFunctionNoun(new Set(entries.map(({ fn }) => fn.functionType)), listing.count);
|
|
456
|
+
writeTechnicalLog(report.level, "edk", `${report.summary(listing.count, noun)}: ${listing.text}`);
|
|
457
|
+
}
|
|
458
|
+
reportDuplicatedStoredFunctions(duplicated);
|
|
459
|
+
reportConflictingStoredFunctions(conflicting);
|
|
460
|
+
reportRenumberedStoredFunctions(renumbered);
|
|
461
|
+
return { functionsByCloudLink, proceduresByCloudLink };
|
|
462
|
+
}
|
|
463
|
+
/** Group by CloudLink (sorted), then by function kind, preserving input order within each. */
|
|
464
|
+
function byCloudLinkAndKind(items) {
|
|
465
|
+
const byCloudLink = new Map();
|
|
466
|
+
for (const item of items) {
|
|
467
|
+
const bucket = byCloudLink.get(item.fn.cloudLinkName) ?? { procedures: [], functions: [] };
|
|
468
|
+
(item.fn.functionType === "PROCEDURE" ? bucket.procedures : bucket.functions).push(item);
|
|
469
|
+
byCloudLink.set(item.fn.cloudLinkName, bucket);
|
|
470
|
+
}
|
|
471
|
+
return [...byCloudLink.keys()].sort().map((cloudLinkName) => ({ cloudLinkName, ...byCloudLink.get(cloudLinkName) }));
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* One WARN per CloudLink and function kind naming the exact signatures that
|
|
475
|
+
* are configured more than once. A distinct overload of the same name still
|
|
476
|
+
* resolves (the lookup sends `parameter_types`), so only these signatures
|
|
477
|
+
* are called out.
|
|
478
|
+
*/
|
|
479
|
+
function reportDuplicatedStoredFunctions(duplicated) {
|
|
480
|
+
for (const { cloudLinkName, procedures, functions } of byCloudLinkAndKind(duplicated.map((fn) => ({ fn })))) {
|
|
481
|
+
const configuredTwice = (items, noun) => {
|
|
482
|
+
const one = items.length === 1;
|
|
483
|
+
const labels = items.map(({ fn }) => storedFunctionSignatureLabel(fn)).sort().join(", ");
|
|
484
|
+
return `${items.length} ${noun} signature${one ? " is" : "s are"} configured more than once on CloudLink ${q(cloudLinkName)} (${labels})`;
|
|
485
|
+
};
|
|
486
|
+
if (procedures.length > 0) {
|
|
487
|
+
const those = procedures.length === 1 ? "that signature" : "those signatures";
|
|
488
|
+
writeTechnicalLog("WARN", "edk", `${configuredTwice(procedures, "stored procedure")}; automations cannot reference ${those} until the duplicate configuration is removed in Elementum`);
|
|
489
|
+
}
|
|
490
|
+
if (functions.length > 0) {
|
|
491
|
+
writeTechnicalLog("WARN", "edk", `${configuredTwice(functions, "user-defined function")}; org.ts lists ${functions.length === 1 ? "it" : "each"} once — remove the duplicate configuration in Elementum`);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
/** One WARN per CloudLink and function kind for selectors whose configurations disagree on the result type. */
|
|
496
|
+
function reportConflictingStoredFunctions(conflicting) {
|
|
497
|
+
for (const { cloudLinkName, procedures, functions } of byCloudLinkAndKind(conflicting)) {
|
|
498
|
+
for (const [items, noun] of [[procedures, "stored procedure"], [functions, "user-defined function"]]) {
|
|
499
|
+
if (items.length === 0)
|
|
500
|
+
continue;
|
|
501
|
+
const one = items.length === 1;
|
|
502
|
+
const labels = items
|
|
503
|
+
.map(({ fn, resultTypes }) => `${storedFunctionSignatureLabel(fn)} returns ${resultTypes.join(", ")}`)
|
|
504
|
+
.sort()
|
|
505
|
+
.join("; ");
|
|
506
|
+
writeTechnicalLog("WARN", "edk", `${items.length} ${noun} signature${one ? " is" : "s are"} configured more than once on CloudLink ${q(cloudLinkName)} ` +
|
|
507
|
+
`with different result types (${labels}); org.ts omits ${one ? "it" : "them"} because no lookup can select one configuration — ` +
|
|
508
|
+
"remove the extra configuration in Elementum");
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* One WARN per CloudLink and function kind listing keys that moved because
|
|
514
|
+
* duplicate configurations no longer take a numeric suffix. An authored
|
|
515
|
+
* reference to the old key stops resolving, and a reference to a new key may
|
|
516
|
+
* have named a different configuration before.
|
|
517
|
+
*/
|
|
518
|
+
function reportRenumberedStoredFunctions(renumbered) {
|
|
519
|
+
for (const { cloudLinkName, procedures, functions } of byCloudLinkAndKind(renumbered)) {
|
|
520
|
+
for (const [items, noun] of [[procedures, "stored procedure"], [functions, "user-defined function"]]) {
|
|
521
|
+
if (items.length === 0)
|
|
522
|
+
continue;
|
|
523
|
+
const moves = items.map(({ fn, previous, key }) => `${previous} → ${key} (${storedFunctionSignatureLabel(fn)})`).join(", ");
|
|
524
|
+
writeTechnicalLog("WARN", "edk", `renumbered ${items.length} ${noun} key${items.length === 1 ? "" : "s"} on CloudLink ${q(cloudLinkName)} ` +
|
|
525
|
+
`because duplicate configurations are no longer listed separately: ${moves}; ` +
|
|
526
|
+
"update authored references, and check any reference to a new key that previously named a different configuration");
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Distinct omitted functions, counted by full location (the provider
|
|
532
|
+
* selector) so identical configurations collapse but the same name in
|
|
533
|
+
* another database, schema, or signature does not. A name that repeats on one
|
|
534
|
+
* CloudLink is qualified as `DATABASE.SCHEMA.NAME(TYPES)`. Labels are sorted
|
|
535
|
+
* and grouped under their CloudLink only when the entries span more than one.
|
|
536
|
+
*/
|
|
537
|
+
function listStoredFunctionNames(entries) {
|
|
538
|
+
const byCloudLink = new Map();
|
|
539
|
+
for (const entry of entries) {
|
|
540
|
+
const distinct = byCloudLink.get(entry.fn.cloudLinkName) ?? new Map();
|
|
541
|
+
const location = JSON.stringify([storedFunctionSelectorKey(entry.fn), entry.detail ?? null]);
|
|
542
|
+
if (!distinct.has(location))
|
|
543
|
+
distinct.set(location, entry);
|
|
544
|
+
byCloudLink.set(entry.fn.cloudLinkName, distinct);
|
|
545
|
+
}
|
|
546
|
+
const labelsOf = (cloudLinkName) => {
|
|
547
|
+
const distinct = [...byCloudLink.get(cloudLinkName).values()];
|
|
548
|
+
const nameCounts = new Map();
|
|
549
|
+
for (const { fn } of distinct)
|
|
550
|
+
nameCounts.set(fn.name.toUpperCase(), (nameCounts.get(fn.name.toUpperCase()) ?? 0) + 1);
|
|
551
|
+
return distinct
|
|
552
|
+
.map(({ fn, detail }) => {
|
|
553
|
+
const name = (nameCounts.get(fn.name.toUpperCase()) ?? 0) > 1 ? storedFunctionSignatureLabel(fn) : fn.name;
|
|
554
|
+
return detail === undefined ? name : `${name} (${detail})`;
|
|
555
|
+
})
|
|
556
|
+
.sort()
|
|
557
|
+
.join(", ");
|
|
558
|
+
};
|
|
559
|
+
const cloudLinks = [...byCloudLink.keys()].sort();
|
|
166
560
|
return {
|
|
167
|
-
|
|
168
|
-
|
|
561
|
+
count: [...byCloudLink.values()].reduce((total, distinct) => total + distinct.size, 0),
|
|
562
|
+
text: cloudLinks.length === 1
|
|
563
|
+
? labelsOf(cloudLinks[0])
|
|
564
|
+
: cloudLinks.map((cloudLinkName) => `CloudLink ${q(cloudLinkName)}: ${labelsOf(cloudLinkName)}`).join("; "),
|
|
169
565
|
};
|
|
170
566
|
}
|
|
567
|
+
function storedFunctionNoun(functionTypes, count) {
|
|
568
|
+
const only = functionTypes.size === 1 ? [...functionTypes][0] : undefined;
|
|
569
|
+
const noun = only === "PROCEDURE" ? "stored procedure"
|
|
570
|
+
: only === "USER_DEFINED_FUNCTION" ? "user-defined function"
|
|
571
|
+
: "stored function";
|
|
572
|
+
return count === 1 ? noun : `${noun}s`;
|
|
573
|
+
}
|
|
171
574
|
/**
|
|
172
575
|
* Connectors nest one level under their provider — model names alone collide
|
|
173
576
|
* across providers, so `aiProviders.<provider>.models.<model>` disambiguates
|
|
@@ -258,13 +661,18 @@ function renderAiProvidersBag(extract) {
|
|
|
258
661
|
*/
|
|
259
662
|
function renderBarrel(appHandles, elementHandles, tableHandles) {
|
|
260
663
|
const elementKeys = computeElementKeys(appHandles, elementHandles);
|
|
664
|
+
for (const [handle, key] of elementKeys) {
|
|
665
|
+
if (key === handle)
|
|
666
|
+
continue;
|
|
667
|
+
writeTechnicalLog("WARN", "edk", `"${handle}" names both an app and an element — the element is exposed as catalog.${key} (the app keeps catalog.${handle}) to avoid a collision.`);
|
|
668
|
+
}
|
|
261
669
|
const hasLazyEntries = appHandles.length > 0 || elementHandles.length > 0 || tableHandles.length > 0;
|
|
262
670
|
const lines = [
|
|
263
671
|
// Alias so we can re-export `org` with the pulled `tables` bag attached —
|
|
264
672
|
// table printers emit `org.tables.*` while automations historically use
|
|
265
673
|
// `catalog.tables.*`. Both must resolve the same lazy getters.
|
|
266
674
|
'import { org as orgIdentities } from "../org.js";',
|
|
267
|
-
'import { usersCatalog } from "@elementumai/edk/catalog";',
|
|
675
|
+
'import { userGroupsCatalog, usersCatalog } from "@elementumai/edk/catalog";',
|
|
268
676
|
"",
|
|
269
677
|
];
|
|
270
678
|
if (hasLazyEntries) {
|
|
@@ -289,6 +697,7 @@ function renderBarrel(appHandles, elementHandles, tableHandles) {
|
|
|
289
697
|
lines.push(...lazyAspectGetter(elementKeys.get(h), `../elements/${h}/generated/catalog.js`, h));
|
|
290
698
|
}
|
|
291
699
|
lines.push(" users: usersCatalog,");
|
|
700
|
+
lines.push(" userGroups: userGroupsCatalog,");
|
|
292
701
|
lines.push(" aiProviders: orgIdentities.aiProviders,");
|
|
293
702
|
lines.push(" cloudLinks: orgIdentities.cloudLinks,");
|
|
294
703
|
lines.push(" categories: orgIdentities.categories,");
|
|
@@ -317,7 +726,7 @@ function lazyAspectGetter(key, importPath, exportName, indent = " ") {
|
|
|
317
726
|
`${indent}get ${key}() { return (catalogRequire(${quoted}) as typeof import(${quoted})).${exportName}; },`,
|
|
318
727
|
];
|
|
319
728
|
}
|
|
320
|
-
/**
|
|
729
|
+
/** Pure shared allocator: app/element collisions receive disambiguated keys. */
|
|
321
730
|
function computeElementKeys(appHandles, elementHandles) {
|
|
322
731
|
const used = new Set(appHandles);
|
|
323
732
|
const elementKeys = new Map();
|
|
@@ -335,7 +744,6 @@ function computeElementKeys(appHandles, elementHandles) {
|
|
|
335
744
|
}
|
|
336
745
|
elementKeys.set(h, candidate);
|
|
337
746
|
used.add(candidate);
|
|
338
|
-
writeTechnicalLog("WARN", "edk", `"${h}" names both an app and an element — the element is exposed as catalog.${candidate} (the app keeps catalog.${h}) to avoid a collision.`);
|
|
339
747
|
}
|
|
340
748
|
return elementKeys;
|
|
341
749
|
}
|
|
@@ -383,6 +791,8 @@ function q(s) {
|
|
|
383
791
|
* (same name, distinct parameter signature) derive the same `sanitizeName`
|
|
384
792
|
* base; each still carries its own exact `name`/`database`/`schema`/
|
|
385
793
|
* `parameters` in the emitted ref, so only the bag KEY needs disambiguating.
|
|
794
|
+
* Configurations that share one provider selector never get here as separate
|
|
795
|
+
* entries — {@link catalogStoredFunctions} collapses or omits them first.
|
|
386
796
|
*/
|
|
387
797
|
function uniqueCatalogKey(base, used) {
|
|
388
798
|
let key = base;
|
|
@@ -257,6 +257,16 @@ export interface UserFieldRef {
|
|
|
257
257
|
readonly name: UserFieldKey;
|
|
258
258
|
readonly fieldType: "TEXT";
|
|
259
259
|
}
|
|
260
|
+
/** Platform-owned user-group attributes accepted by user-group-search task filters. */
|
|
261
|
+
export declare const USER_GROUP_FIELD_KEYS: readonly ["name"];
|
|
262
|
+
export type UserGroupFieldKey = (typeof USER_GROUP_FIELD_KEYS)[number];
|
|
263
|
+
/** The user-group counterpart of {@link UserFieldRef}; serializes to its literal platform key. */
|
|
264
|
+
export interface UserGroupFieldRef {
|
|
265
|
+
readonly __kind: "userGroupField";
|
|
266
|
+
readonly refName: UserGroupFieldKey;
|
|
267
|
+
readonly name: UserGroupFieldKey;
|
|
268
|
+
readonly fieldType: "TEXT";
|
|
269
|
+
}
|
|
260
270
|
export interface TriggerParameterRef extends CatalogRef<"triggerParameter"> {
|
|
261
271
|
/**
|
|
262
272
|
* True when the automation's onDemand trigger declares this parameter
|
|
@@ -270,8 +280,8 @@ export interface TriggerParameterRef extends CatalogRef<"triggerParameter"> {
|
|
|
270
280
|
/**
|
|
271
281
|
* An automation output property reference. `valueType` (when known) is the
|
|
272
282
|
* platform's workflow field-type tag for this output — `"TEXT"`,
|
|
273
|
-
* `"BOOLEAN"`, `"NUMBER"`, `"DECIMAL"` — the same
|
|
274
|
-
* `entities/automation`'s `outputFieldTypesFromScriptSchema` already
|
|
283
|
+
* `"BOOLEAN"`, `"NUMBER"`, `"DECIMAL"`, `"DATE"`, `"DATETIME"` — the same
|
|
284
|
+
* domain `entities/automation`'s `outputFieldTypesFromScriptSchema` already
|
|
275
285
|
* computes for the wire; not populated when the output's source can't be
|
|
276
286
|
* resolved to a typed schema (a literal, a trigger ref, a variable ref, or
|
|
277
287
|
* a non-executeScript task). Kept a bare generic `string` here (no import
|
|
@@ -29,6 +29,8 @@ export const PROCEDURE_PARAMETER_TYPES = [
|
|
|
29
29
|
];
|
|
30
30
|
/** Platform-owned user attributes accepted by user-search task filters. */
|
|
31
31
|
export const USER_FIELD_KEYS = ["firstName", "email", "jobTitle", "lastName"];
|
|
32
|
+
/** Platform-owned user-group attributes accepted by user-group-search task filters. */
|
|
33
|
+
export const USER_GROUP_FIELD_KEYS = ["name"];
|
|
32
34
|
/**
|
|
33
35
|
* Which scope resolves a kind's id at deploy:
|
|
34
36
|
* - `"app"` — the app's v2 state (app-owned entities + fields/tables);
|