@elementumai/edk 0.8.0-preview.11 → 0.8.2-alpha.5
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 +510 -324
- package/dist-sdk/src/catalog/ai-provider-models.d.ts +30 -0
- package/dist-sdk/src/catalog/ai-provider-models.js +63 -0
- package/dist-sdk/src/catalog/factories.d.ts +56 -3
- package/dist-sdk/src/catalog/factories.js +83 -4
- package/dist-sdk/src/catalog/from-authoring.js +19 -2
- package/dist-sdk/src/catalog/index.d.ts +3 -2
- package/dist-sdk/src/catalog/index.js +3 -2
- package/dist-sdk/src/catalog/org.d.ts +1 -1
- package/dist-sdk/src/catalog/org.js +134 -50
- package/dist-sdk/src/catalog/render.d.ts +13 -1
- package/dist-sdk/src/catalog/render.js +21 -4
- package/dist-sdk/src/catalog/token.js +18 -0
- package/dist-sdk/src/catalog/types.d.ts +75 -3
- package/dist-sdk/src/catalog/types.js +3 -0
- package/dist-sdk/src/core/system-fields.d.ts +2 -0
- package/dist-sdk/src/core/system-fields.js +2 -0
- package/dist-sdk/src/core/types/ai-provider.d.ts +10 -23
- package/dist-sdk/src/core/types/ai-provider.js +1 -25
- package/dist-sdk/src/core/types/app.d.ts +26 -1
- package/dist-sdk/src/engine/build/context.d.ts +58 -0
- package/dist-sdk/src/engine/build/context.js +11 -1
- package/dist-sdk/src/engine/build/source-context.d.ts +45 -0
- package/dist-sdk/src/engine/build/source-context.js +23 -0
- package/dist-sdk/src/engine/pull/context.d.ts +15 -0
- package/dist-sdk/src/engine/pull/org.d.ts +10 -0
- package/dist-sdk/src/engine/pull/org.js +34 -4
- 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 +54 -0
- package/dist-sdk/src/engine/tf/labels.js +75 -0
- package/dist-sdk/src/engine/tf/parse.d.ts +15 -0
- package/dist-sdk/src/engine/tf/parse.js +162 -0
- package/dist-sdk/src/entities/access-policy/build.d.ts +26 -0
- package/dist-sdk/src/entities/access-policy/build.js +7 -0
- package/dist-sdk/src/entities/access-policy/filter.d.ts +61 -0
- package/dist-sdk/src/entities/access-policy/filter.js +83 -0
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +66 -0
- package/dist-sdk/src/entities/access-policy/from-tf.js +187 -0
- package/dist-sdk/src/entities/access-policy/module.d.ts +3 -0
- package/dist-sdk/src/entities/access-policy/module.js +17 -0
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +43 -0
- package/dist-sdk/src/entities/access-policy/to-tf.js +164 -0
- package/dist-sdk/src/entities/access-policy/types.d.ts +4 -0
- package/dist-sdk/src/entities/access-policy/types.js +10 -0
- package/dist-sdk/src/entities/agent/build.d.ts +2 -0
- package/dist-sdk/src/entities/agent/build.js +1 -0
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +38 -3
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +257 -32
- package/dist-sdk/src/entities/agent/from-tf.d.ts +29 -9
- package/dist-sdk/src/entities/agent/from-tf.js +146 -19
- package/dist-sdk/src/entities/agent/index.d.ts +1 -1
- package/dist-sdk/src/entities/agent/module.js +14 -4
- package/dist-sdk/src/entities/agent/to-tf.d.ts +46 -1
- package/dist-sdk/src/entities/agent/to-tf.js +160 -14
- package/dist-sdk/src/entities/agent/tools.d.ts +88 -9
- package/dist-sdk/src/entities/agent/tools.js +46 -7
- package/dist-sdk/src/entities/agent-a2a-skill/from-tf.d.ts +17 -0
- package/dist-sdk/src/entities/agent-a2a-skill/from-tf.js +64 -0
- package/dist-sdk/src/entities/agent-a2a-skill/module.d.ts +4 -0
- package/dist-sdk/src/entities/agent-a2a-skill/module.js +14 -0
- package/dist-sdk/src/entities/agent-a2a-skill/to-tf.d.ts +40 -0
- package/dist-sdk/src/entities/agent-a2a-skill/to-tf.js +47 -0
- package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +51 -4
- package/dist-sdk/src/entities/agent-tool/from-tf.js +131 -35
- package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +11 -4
- package/dist-sdk/src/entities/agent-tool/to-tf.js +176 -30
- package/dist-sdk/src/entities/agent-tool/types.d.ts +5 -4
- package/dist-sdk/src/entities/agent-tool/types.js +38 -6
- package/dist-sdk/src/entities/app/build.d.ts +91 -13
- package/dist-sdk/src/entities/app/build.js +63 -5
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +3 -0
- package/dist-sdk/src/entities/app/from-tf.d.ts +1 -1
- package/dist-sdk/src/entities/app/from-tf.js +32 -22
- package/dist-sdk/src/entities/app/index.d.ts +4 -1
- package/dist-sdk/src/entities/app/index.js +2 -1
- package/dist-sdk/src/entities/app/module.js +10 -2
- package/dist-sdk/src/entities/app/to-tf.d.ts +5 -0
- package/dist-sdk/src/entities/app/to-tf.js +45 -4
- package/dist-sdk/src/entities/automation/build.d.ts +57 -13
- package/dist-sdk/src/entities/automation/build.js +62 -42
- package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +25 -8
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +16 -1
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +206 -47
- package/dist-sdk/src/entities/automation/filter.d.ts +37 -3
- package/dist-sdk/src/entities/automation/filter.js +54 -3
- package/dist-sdk/src/entities/automation/from-tf.d.ts +26 -27
- package/dist-sdk/src/entities/automation/from-tf.js +1344 -222
- package/dist-sdk/src/entities/automation/index.d.ts +4 -0
- package/dist-sdk/src/entities/automation/index.js +4 -0
- package/dist-sdk/src/entities/automation/module.js +29 -32
- package/dist-sdk/src/entities/automation/operators.d.ts +29 -2
- package/dist-sdk/src/entities/automation/operators.js +27 -1
- package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +19 -0
- package/dist-sdk/src/entities/automation/output-key-wire-name.js +24 -0
- package/dist-sdk/src/entities/automation/script-code.d.ts +10 -21
- package/dist-sdk/src/entities/automation/script-code.js +272 -5
- package/dist-sdk/src/entities/automation/tasks.d.ts +125 -19
- package/dist-sdk/src/entities/automation/tasks.js +83 -15
- package/dist-sdk/src/entities/automation/to-tf.d.ts +10 -29
- package/dist-sdk/src/entities/automation/to-tf.js +1291 -230
- package/dist-sdk/src/entities/automation/triggers.d.ts +9 -1
- package/dist-sdk/src/entities/automation/types.d.ts +29 -4
- package/dist-sdk/src/entities/automation/types.js +76 -46
- package/dist-sdk/src/entities/element/build.d.ts +44 -13
- package/dist-sdk/src/entities/element/build.js +45 -3
- package/dist-sdk/src/entities/element/from-tf.d.ts +1 -1
- package/dist-sdk/src/entities/element/from-tf.js +28 -14
- package/dist-sdk/src/entities/element/index.d.ts +4 -1
- package/dist-sdk/src/entities/element/index.js +2 -1
- package/dist-sdk/src/entities/element/module.js +4 -1
- package/dist-sdk/src/entities/element/to-tf.js +26 -3
- package/dist-sdk/src/entities/field/build.d.ts +61 -14
- package/dist-sdk/src/entities/field/build.js +10 -0
- package/dist-sdk/src/entities/field/calc/runtime.js +4 -0
- package/dist-sdk/src/entities/field/from-tf.d.ts +5 -3
- package/dist-sdk/src/entities/field/from-tf.js +118 -7
- package/dist-sdk/src/entities/field/module.js +3 -2
- package/dist-sdk/src/entities/field/to-tf.d.ts +46 -11
- package/dist-sdk/src/entities/field/to-tf.js +166 -17
- package/dist-sdk/src/entities/field/types.d.ts +26 -0
- package/dist-sdk/src/entities/field/types.js +34 -12
- package/dist-sdk/src/entities/file-reader/build.d.ts +108 -50
- package/dist-sdk/src/entities/file-reader/build.js +23 -23
- package/dist-sdk/src/entities/file-reader/deserializer/print-file-reader.d.ts +6 -0
- package/dist-sdk/src/entities/file-reader/deserializer/print-file-reader.js +109 -0
- package/dist-sdk/src/entities/file-reader/from-tf.d.ts +13 -0
- package/dist-sdk/src/entities/file-reader/from-tf.js +172 -0
- package/dist-sdk/src/entities/file-reader/index.d.ts +8 -3
- package/dist-sdk/src/entities/file-reader/index.js +7 -2
- package/dist-sdk/src/entities/file-reader/module.d.ts +3 -0
- package/dist-sdk/src/entities/file-reader/module.js +115 -0
- package/dist-sdk/src/entities/file-reader/to-tf.d.ts +14 -0
- package/dist-sdk/src/entities/file-reader/to-tf.js +84 -0
- package/dist-sdk/src/entities/file-reader/types.d.ts +32 -0
- package/dist-sdk/src/entities/file-reader/types.js +30 -0
- package/dist-sdk/src/entities/org/ai-provider.d.ts +13 -0
- package/dist-sdk/src/entities/org/ai-provider.js +46 -0
- package/dist-sdk/src/entities/org/connector.d.ts +8 -1
- package/dist-sdk/src/entities/org/connector.js +12 -14
- package/dist-sdk/src/entities/org/group.js +10 -1
- package/dist-sdk/src/entities/org/index.d.ts +1 -0
- package/dist-sdk/src/entities/org/index.js +1 -0
- package/dist-sdk/src/entities/org/user.js +10 -1
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +59 -9
- package/dist-sdk/src/entities/shared/filters/types.d.ts +1 -1
- package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +17 -0
- package/dist-sdk/src/entities/shared/tool-field-ref.js +46 -0
- package/dist-sdk/src/entities/shared/types/field-types.d.ts +10 -1
- package/dist-sdk/src/entities/shared/types/field-types.js +9 -0
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +19 -0
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +128 -11
- package/dist-sdk/src/entities/skill/from-tf.js +4 -3
- package/dist-sdk/src/entities/skill/index.d.ts +1 -1
- package/dist-sdk/src/entities/skill/module.js +7 -1
- package/dist-sdk/src/entities/skill/to-tf.d.ts +26 -0
- package/dist-sdk/src/entities/skill/to-tf.js +65 -4
- package/dist-sdk/src/entities/skill/tools.d.ts +37 -8
- package/dist-sdk/src/entities/skill/tools.js +43 -1
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +34 -4
- package/dist-sdk/src/entities/skill-tool/from-tf.js +128 -18
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +13 -1
- package/dist-sdk/src/entities/skill-tool/to-tf.js +164 -25
- package/dist-sdk/src/entities/skill-tool/types.d.ts +5 -7
- package/dist-sdk/src/entities/skill-tool/types.js +47 -11
- package/dist-sdk/src/entities/view/from-tf.d.ts +6 -2
- package/dist-sdk/src/entities/view/from-tf.js +11 -9
- package/dist-sdk/src/entities/view/to-tf.d.ts +9 -7
- package/dist-sdk/src/entities/view/to-tf.js +39 -18
- package/dist-sdk/src/entities/view/types.d.ts +1 -1
- package/dist-sdk/src/entities/view/types.js +1 -1
- package/dist-sdk/src/graph/deferred-catalog-render.d.ts +0 -5
- package/dist-sdk/src/graph/deferred-catalog-render.js +1 -20
- package/dist-sdk/src/graph/index.d.ts +8 -0
- package/dist-sdk/src/graph/index.js +13 -9
- package/dist-sdk/src/graph/modules.js +8 -1
- package/dist-sdk/src/graph/types.d.ts +98 -4
- package/package.json +49 -16
- package/dist-sdk/src/entities/automation/value-ref-tf.d.ts +0 -76
- package/dist-sdk/src/entities/automation/value-ref-tf.js +0 -190
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `elementum_excel_file_reader` / `elementum_json_file_reader` /
|
|
3
|
+
* `elementum_text_file_reader` → `FileReaderPayload` (see `build.ts`). One
|
|
4
|
+
* `.ts` file per instance, own-file like skills — `module.ts` wires
|
|
5
|
+
* `extractOwnFile` per app-owned file reader block.
|
|
6
|
+
*/
|
|
7
|
+
import { EntityTfError } from "../../engine/entity.js";
|
|
8
|
+
import { isTfExpr, scopedLabelToBagKey } from "../../engine/tf/index.js";
|
|
9
|
+
import { FILE_READER_SUB_TYPE_BY_RESOURCE } from "./types.js";
|
|
10
|
+
function isObject(value) {
|
|
11
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) && !("$expr" in value);
|
|
12
|
+
}
|
|
13
|
+
const KNOWN_EXCEL_ATTRS = new Set([
|
|
14
|
+
"app_id", "name", "first_row_is_header", "document_content", "document_name", "file_type", "fields",
|
|
15
|
+
]);
|
|
16
|
+
const KNOWN_JSON_ATTRS = new Set(["app_id", "name", "structure"]);
|
|
17
|
+
const KNOWN_TEXT_ATTRS = new Set(["app_id", "name"]);
|
|
18
|
+
const KNOWN_AI_ATTRS = new Set(["app_id", "name", "instructions", "fields"]);
|
|
19
|
+
function assertAllowed(block, allowed) {
|
|
20
|
+
for (const key of Object.keys(block.attrs)) {
|
|
21
|
+
if (!allowed.has(key)) {
|
|
22
|
+
throw new EntityTfError(`${block.type}.${block.label}: unrecognized attribute "${key}" — this EDK version doesn't know how to round-trip it`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function decodeJson(value) {
|
|
27
|
+
if (isTfExpr(value)) {
|
|
28
|
+
if (value.$expr === "jsonencode")
|
|
29
|
+
return decodeJson(value.value);
|
|
30
|
+
throw new EntityTfError(`unsupported expression "${value.$expr}" inside a file reader's structure`);
|
|
31
|
+
}
|
|
32
|
+
if (Array.isArray(value))
|
|
33
|
+
return value.map(decodeJson);
|
|
34
|
+
if (isObject(value))
|
|
35
|
+
return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, decodeJson(v)]));
|
|
36
|
+
return value;
|
|
37
|
+
}
|
|
38
|
+
function parseStructureField(node, where) {
|
|
39
|
+
if (!isObject(node))
|
|
40
|
+
throw new EntityTfError(`${where}: invalid structure node`);
|
|
41
|
+
const [type, body] = Object.entries(node)[0] ?? [];
|
|
42
|
+
if (type === undefined || !isObject(body) || typeof body.name !== "string") {
|
|
43
|
+
throw new EntityTfError(`${where}: invalid structure node`);
|
|
44
|
+
}
|
|
45
|
+
switch (type) {
|
|
46
|
+
case "text":
|
|
47
|
+
case "number":
|
|
48
|
+
case "decimal":
|
|
49
|
+
case "bool": {
|
|
50
|
+
const kind = type === "bool" ? "boolean" : type;
|
|
51
|
+
return { type: kind, name: body.name };
|
|
52
|
+
}
|
|
53
|
+
case "date":
|
|
54
|
+
case "datetime": {
|
|
55
|
+
if (typeof body.format !== "string")
|
|
56
|
+
throw new EntityTfError(`${where}: "${body.name}" is missing its date format`);
|
|
57
|
+
return { type, name: body.name, format: body.format };
|
|
58
|
+
}
|
|
59
|
+
case "object": {
|
|
60
|
+
const properties = Array.isArray(body.properties) ? body.properties : [];
|
|
61
|
+
return { type: "object", name: body.name, properties: properties.map((p) => parseStructureField(p, where)) };
|
|
62
|
+
}
|
|
63
|
+
case "array": {
|
|
64
|
+
if (body.arrayType === undefined)
|
|
65
|
+
throw new EntityTfError(`${where}: "${body.name}" is missing its arrayType`);
|
|
66
|
+
return { type: "array", name: body.name, itemType: parseStructureField(body.arrayType, where) };
|
|
67
|
+
}
|
|
68
|
+
default:
|
|
69
|
+
throw new EntityTfError(`${where}: unsupported structure node type "${type}"`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function parseStructure(raw, where) {
|
|
73
|
+
if (!isObject(raw) || !Array.isArray(raw.properties))
|
|
74
|
+
throw new EntityTfError(`${where}: invalid structure`);
|
|
75
|
+
return raw.properties.map((p) => parseStructureField(p, where));
|
|
76
|
+
}
|
|
77
|
+
function parseExcelFields(value, where) {
|
|
78
|
+
if (!Array.isArray(value))
|
|
79
|
+
throw new EntityTfError(`${where}: "fields" must be an array`);
|
|
80
|
+
return value.map((item) => {
|
|
81
|
+
if (!isObject(item) || typeof item.name !== "string" || typeof item.type !== "string") {
|
|
82
|
+
throw new EntityTfError(`${where}: invalid field entry`);
|
|
83
|
+
}
|
|
84
|
+
const location = item.location;
|
|
85
|
+
if (!isObject(location) || typeof location.column !== "number" || typeof location.row !== "number" || typeof location.sheet !== "number") {
|
|
86
|
+
throw new EntityTfError(`${where}: field "${item.name}" is missing its cell location`);
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
name: item.name,
|
|
90
|
+
type: item.type,
|
|
91
|
+
location: { column: location.column, row: location.row, sheet: location.sheet },
|
|
92
|
+
...(typeof item.include === "boolean" ? { include: item.include } : {}),
|
|
93
|
+
...(typeof item.required === "boolean" ? { required: item.required } : {}),
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
function parseAiFields(value, where) {
|
|
98
|
+
if (!Array.isArray(value))
|
|
99
|
+
throw new EntityTfError(`${where}: "fields" must be an array`);
|
|
100
|
+
return value.map((item) => {
|
|
101
|
+
if (!isObject(item) || typeof item.name !== "string" || typeof item.description !== "string" || typeof item.type !== "string") {
|
|
102
|
+
throw new EntityTfError(`${where}: invalid field entry`);
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
name: item.name,
|
|
106
|
+
description: item.description,
|
|
107
|
+
type: item.type,
|
|
108
|
+
...(typeof item.required === "boolean" ? { required: item.required } : {}),
|
|
109
|
+
};
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
export function fileReaderFromTf(block, appTfLabel, _ctx) {
|
|
113
|
+
const label = block.label;
|
|
114
|
+
if (label === undefined || label === "")
|
|
115
|
+
throw new EntityTfError(`${block.type} block is missing its label`);
|
|
116
|
+
const subType = FILE_READER_SUB_TYPE_BY_RESOURCE.get(block.type ?? "");
|
|
117
|
+
if (subType === undefined)
|
|
118
|
+
throw new EntityTfError(`unknown file reader resource type "${block.type}"`);
|
|
119
|
+
if (subType.implemented !== true) {
|
|
120
|
+
return { skippedReason: `${block.type}.${label}: ${subType.typeKey} file readers are not yet supported` };
|
|
121
|
+
}
|
|
122
|
+
const attrs = block.attrs;
|
|
123
|
+
const name = typeof attrs.name === "string" ? attrs.name : undefined;
|
|
124
|
+
if (name === undefined)
|
|
125
|
+
throw new EntityTfError(`${block.type}.${label}: "name" is required`);
|
|
126
|
+
const refName = scopedLabelToBagKey(appTfLabel, label);
|
|
127
|
+
const where = `${block.type}.${label}`;
|
|
128
|
+
if (subType.typeKey === "excel") {
|
|
129
|
+
assertAllowed(block, KNOWN_EXCEL_ATTRS);
|
|
130
|
+
if (typeof attrs.first_row_is_header !== "boolean")
|
|
131
|
+
throw new EntityTfError(`${where}: "first_row_is_header" is required`);
|
|
132
|
+
const fields = parseExcelFields(attrs.fields ?? [], where);
|
|
133
|
+
// document_content/document_name/file_type are never returned by
|
|
134
|
+
// Read() on an already-imported resource (the provider's schema docs
|
|
135
|
+
// say so), yet ei's export still emits placeholders for them - even
|
|
136
|
+
// document_content's empty-string placeholder counts as a change on
|
|
137
|
+
// this always-forces-replacement attribute, so reproducing any of the
|
|
138
|
+
// three plans a spurious destroy+recreate. Never extract them; the
|
|
139
|
+
// printer leaves a comment for anyone authoring a genuinely NEW reader.
|
|
140
|
+
// Adoption separately strips these placeholders from `.tf/in/` itself
|
|
141
|
+
// (stripUnrecoverableExcelFileReaderAttrs in engine/adopt/adopt.ts),
|
|
142
|
+
// since its gate plans against ei's raw export, not this extractor.
|
|
143
|
+
return {
|
|
144
|
+
fileReader: {
|
|
145
|
+
refName,
|
|
146
|
+
payload: {
|
|
147
|
+
type: "excel",
|
|
148
|
+
name,
|
|
149
|
+
firstRowIsHeader: attrs.first_row_is_header,
|
|
150
|
+
fields,
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
if (subType.typeKey === "json") {
|
|
156
|
+
assertAllowed(block, KNOWN_JSON_ATTRS);
|
|
157
|
+
if (attrs.structure === undefined)
|
|
158
|
+
throw new EntityTfError(`${where}: "structure" is required`);
|
|
159
|
+
const structure = parseStructure(decodeJson(attrs.structure), where);
|
|
160
|
+
return { fileReader: { refName, payload: { type: "json", name, structure } } };
|
|
161
|
+
}
|
|
162
|
+
if (subType.typeKey === "ai") {
|
|
163
|
+
assertAllowed(block, KNOWN_AI_ATTRS);
|
|
164
|
+
if (typeof attrs.instructions !== "string")
|
|
165
|
+
throw new EntityTfError(`${where}: "instructions" is required`);
|
|
166
|
+
const fields = parseAiFields(attrs.fields ?? [], where);
|
|
167
|
+
return { fileReader: { refName, payload: { type: "ai", name, instructions: attrs.instructions, fields } } };
|
|
168
|
+
}
|
|
169
|
+
// text
|
|
170
|
+
assertAllowed(block, KNOWN_TEXT_ATTRS);
|
|
171
|
+
return { fileReader: { refName, payload: { type: "text", name } } };
|
|
172
|
+
}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* File-reader authoring — create/edit Excel, JSON, and text (OCR) file
|
|
3
|
+
* readers, referenced by an automation's `readFile` task.
|
|
4
|
+
*
|
|
5
|
+
* The `Legacy*`/`@deprecated` exports below are the pre-terraform,
|
|
6
|
+
* GraphQL-mutation-based API this file replaced — kept for published
|
|
7
|
+
* `@elementumai/edk/fileReaders` API back-compat only, not used by
|
|
8
|
+
* `elementum build`/`pull`. See `build.ts`'s "Legacy" section doc comment.
|
|
4
9
|
*/
|
|
5
|
-
export { defineFileReader,
|
|
10
|
+
export { defineFileReader, type AiFileReaderField, type AiFileReaderOptions, type ExcelCellLocation, type FileReaderConfigured, type FileReaderExcelField, type FileReaderExcelOptions, type FileReaderJsonOptions, type FileReaderOptions, type FileReaderPayload, type FileReaderTextOptions, type JsonStructureField, fileReaderCreateBody, fileReaderUpdateBody, type FileReaderAiField, type FileReaderAiOptions, type FileReaderExcelCellOptions, type FileReaderInvoiceOptions, type FileReaderOcrOptions, type FileReaderXmlOptions, type LegacyFileReaderExcelField, type LegacyFileReaderExcelOptions, type LegacyFileReaderOptions, type LegacyFileReaderPayload, } from "./build.js";
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* File-reader authoring — create/edit Excel, JSON, and text (OCR) file
|
|
3
|
+
* readers, referenced by an automation's `readFile` task.
|
|
4
|
+
*
|
|
5
|
+
* The `Legacy*`/`@deprecated` exports below are the pre-terraform,
|
|
6
|
+
* GraphQL-mutation-based API this file replaced — kept for published
|
|
7
|
+
* `@elementumai/edk/fileReaders` API back-compat only, not used by
|
|
8
|
+
* `elementum build`/`pull`. See `build.ts`'s "Legacy" section doc comment.
|
|
4
9
|
*/
|
|
5
10
|
export { defineFileReader, fileReaderCreateBody, fileReaderUpdateBody, } from "./build.js";
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/** The file-reader entity's registry entry (see src/graph/). */
|
|
2
|
+
import { safeCatalogKey } from "../../catalog/render-helpers.js";
|
|
3
|
+
import { NO_CANVAS, } from "../../graph/types.js";
|
|
4
|
+
import { NO_DATA } from "../../graph/types.js";
|
|
5
|
+
import { printFileReader } from "./deserializer/print-file-reader.js";
|
|
6
|
+
import { fileReaderFromTf } from "./from-tf.js";
|
|
7
|
+
import { fileReaderToTf } from "./to-tf.js";
|
|
8
|
+
import { ALL_FILE_READER_RESOURCE_TYPES, FILE_READER_SUB_TYPES } from "./types.js";
|
|
9
|
+
function isConfigured(value) {
|
|
10
|
+
return (typeof value === "object" &&
|
|
11
|
+
value !== null &&
|
|
12
|
+
typeof value.ref === "function" &&
|
|
13
|
+
typeof value.def === "function");
|
|
14
|
+
}
|
|
15
|
+
function fileReaderStubRef(refName, parent) {
|
|
16
|
+
return { __kind: "documentModel", refName, name: refName, parent, readerType: "text" };
|
|
17
|
+
}
|
|
18
|
+
/** Top-level field names a file reader's payload exposes for downstream reference. */
|
|
19
|
+
function topLevelFieldNames(payload) {
|
|
20
|
+
if (payload.type === "excel")
|
|
21
|
+
return payload.fields.map((f) => f.name);
|
|
22
|
+
if (payload.type === "json")
|
|
23
|
+
return payload.structure.map((f) => f.name);
|
|
24
|
+
if (payload.type === "ai")
|
|
25
|
+
return payload.fields.map((f) => f.name);
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
function fileReaderRefFromAuthoring(args) {
|
|
29
|
+
const { refName, parent, defaultExport } = args;
|
|
30
|
+
if (!isConfigured(defaultExport))
|
|
31
|
+
return undefined;
|
|
32
|
+
const catalogRef = defaultExport.ref(refName);
|
|
33
|
+
if (catalogRef.__kind !== "documentModel")
|
|
34
|
+
return undefined;
|
|
35
|
+
const entity = defaultExport.def(refName);
|
|
36
|
+
const payload = entity.payload;
|
|
37
|
+
const fieldNames = topLevelFieldNames(payload);
|
|
38
|
+
const fields = Object.fromEntries(fieldNames.map((name) => [name, { __kind: "documentModelField", refName: name, name, parent: refName }]));
|
|
39
|
+
return {
|
|
40
|
+
...catalogRef,
|
|
41
|
+
parent,
|
|
42
|
+
...(fieldNames.length > 0 ? { fields } : {}),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function renderFileReaderEntry(args) {
|
|
46
|
+
const ref = args.ref;
|
|
47
|
+
const fieldKeys = Object.keys(ref.fields ?? {}).sort();
|
|
48
|
+
const head = `${args.baseIndent}${safeCatalogKey(args.keyName)}: documentModelRef({ name: ${JSON.stringify(ref.name)}, readerType: ${JSON.stringify(ref.readerType)}`;
|
|
49
|
+
if (fieldKeys.length === 0)
|
|
50
|
+
return { lines: [`${head} }),`] };
|
|
51
|
+
const lines = [`${head},`, `${args.baseIndent} fields: {`];
|
|
52
|
+
for (const key of fieldKeys) {
|
|
53
|
+
const field = ref.fields[key];
|
|
54
|
+
lines.push(`${args.baseIndent} ${safeCatalogKey(key)}: documentModelFieldRef({ name: ${JSON.stringify(field.name)}, parent: ${JSON.stringify(field.parent ?? "")} }),`);
|
|
55
|
+
}
|
|
56
|
+
lines.push(`${args.baseIndent} },`, `${args.baseIndent}}),`);
|
|
57
|
+
return { lines, extraFactories: ["documentModelFieldRef"] };
|
|
58
|
+
}
|
|
59
|
+
function extractFileReaders(ownBlocks, _stream, ctx) {
|
|
60
|
+
const items = [];
|
|
61
|
+
const skipped = [];
|
|
62
|
+
const diagnostics = [];
|
|
63
|
+
for (const block of ownBlocks) {
|
|
64
|
+
if (!ALL_FILE_READER_RESOURCE_TYPES.includes(block.type ?? ""))
|
|
65
|
+
continue;
|
|
66
|
+
try {
|
|
67
|
+
const { fileReader, skippedReason } = fileReaderFromTf(block, ctx.appTfLabel, ctx);
|
|
68
|
+
if (fileReader !== undefined)
|
|
69
|
+
items.push(fileReader);
|
|
70
|
+
else if (skippedReason !== undefined)
|
|
71
|
+
skipped.push(skippedReason);
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
diagnostics.push(err instanceof Error ? err.message : String(err));
|
|
75
|
+
skipped.push(`${block.type}.${block.label ?? ""}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return { items, skipped, diagnostics };
|
|
79
|
+
}
|
|
80
|
+
export const fileReaderModule = {
|
|
81
|
+
kind: "file-reader",
|
|
82
|
+
stream: { role: "streamMember" },
|
|
83
|
+
authoring: { unit: "ownFile", bag: "fileReaders" },
|
|
84
|
+
parents: [{ parent: "app", child: "file-reader" }],
|
|
85
|
+
resource: {
|
|
86
|
+
shape: "subTypes",
|
|
87
|
+
rows: FILE_READER_SUB_TYPES.map((t) => ({
|
|
88
|
+
key: t.typeKey,
|
|
89
|
+
resourceType: t.resourceType,
|
|
90
|
+
implemented: t.implemented === true,
|
|
91
|
+
})),
|
|
92
|
+
},
|
|
93
|
+
data: NO_DATA,
|
|
94
|
+
lifecycle: {
|
|
95
|
+
participates: true,
|
|
96
|
+
extractOwnFile: extractFileReaders,
|
|
97
|
+
printOwnFile: (item, opts) => {
|
|
98
|
+
const fileReader = item;
|
|
99
|
+
return { refName: fileReader.refName, source: printFileReader(fileReader, { parent: opts.appRefName }) };
|
|
100
|
+
},
|
|
101
|
+
toTf: (entity, ctx) => fileReaderToTf(entity, { appTfLabel: ctx.appTfLabel }),
|
|
102
|
+
},
|
|
103
|
+
canvas: NO_CANVAS,
|
|
104
|
+
catalog: {
|
|
105
|
+
participates: true,
|
|
106
|
+
refKind: "documentModel",
|
|
107
|
+
catalogBag: "fileReaders",
|
|
108
|
+
renderOrder: 55,
|
|
109
|
+
catalogRoot: "app",
|
|
110
|
+
factoryName: "documentModelRef",
|
|
111
|
+
renderEntry: renderFileReaderEntry,
|
|
112
|
+
stubRef: fileReaderStubRef,
|
|
113
|
+
refFromAuthoring: fileReaderRefFromAuthoring,
|
|
114
|
+
},
|
|
115
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `DeployableEntity` (kind "documentModel", built by `defineFileReader`) →
|
|
3
|
+
* one `elementum_<excel|json|text>_file_reader` resource block. Mirrors
|
|
4
|
+
* `skill/to-tf.ts`'s shape for a single-resource own-file kind.
|
|
5
|
+
*/
|
|
6
|
+
import { type DeployableEntity } from "../../engine/entity.js";
|
|
7
|
+
import { type TfBlock } from "../../engine/tf/index.js";
|
|
8
|
+
export interface FileReaderToTfContext {
|
|
9
|
+
readonly appTfLabel: string;
|
|
10
|
+
}
|
|
11
|
+
export interface FileReaderToTfResult {
|
|
12
|
+
readonly blocks: readonly TfBlock[];
|
|
13
|
+
}
|
|
14
|
+
export declare function fileReaderToTf(entity: DeployableEntity, ctx: FileReaderToTfContext): FileReaderToTfResult;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `DeployableEntity` (kind "documentModel", built by `defineFileReader`) →
|
|
3
|
+
* one `elementum_<excel|json|text>_file_reader` resource block. Mirrors
|
|
4
|
+
* `skill/to-tf.ts`'s shape for a single-resource own-file kind.
|
|
5
|
+
*/
|
|
6
|
+
import { EntityTfError } from "../../engine/entity.js";
|
|
7
|
+
import { appScopedResourceLabel, expr, tsLabelToTfLabel } from "../../engine/tf/index.js";
|
|
8
|
+
import { APP_RESOURCE_TYPE } from "../app/module.js";
|
|
9
|
+
import { FILE_READER_SUB_TYPE_BY_TYPE_KEY } from "./types.js";
|
|
10
|
+
function serializeStructureField(f) {
|
|
11
|
+
switch (f.type) {
|
|
12
|
+
case "text":
|
|
13
|
+
return { text: { name: f.name } };
|
|
14
|
+
case "number":
|
|
15
|
+
return { number: { name: f.name } };
|
|
16
|
+
case "decimal":
|
|
17
|
+
return { decimal: { name: f.name } };
|
|
18
|
+
case "boolean":
|
|
19
|
+
return { bool: { name: f.name } };
|
|
20
|
+
case "date":
|
|
21
|
+
return { date: { name: f.name, format: f.format } };
|
|
22
|
+
case "datetime":
|
|
23
|
+
return { datetime: { name: f.name, format: f.format } };
|
|
24
|
+
case "object":
|
|
25
|
+
return { object: { name: f.name, properties: f.properties.map(serializeStructureField) } };
|
|
26
|
+
case "array":
|
|
27
|
+
return { array: { name: f.name, arrayType: serializeStructureField(f.itemType) } };
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function aiFieldToTf(f) {
|
|
31
|
+
return {
|
|
32
|
+
name: f.name,
|
|
33
|
+
description: f.description,
|
|
34
|
+
type: f.type,
|
|
35
|
+
...(f.required !== undefined ? { required: f.required } : {}),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function excelFieldToTf(f) {
|
|
39
|
+
const location = f.location;
|
|
40
|
+
return {
|
|
41
|
+
name: f.name,
|
|
42
|
+
type: f.type,
|
|
43
|
+
location: { sheet: location.sheet, row: location.row, column: location.column },
|
|
44
|
+
...(f.include !== undefined ? { include: f.include } : {}),
|
|
45
|
+
...(f.required !== undefined ? { required: f.required } : {}),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export function fileReaderToTf(entity, ctx) {
|
|
49
|
+
if (entity.kind !== "documentModel") {
|
|
50
|
+
throw new EntityTfError(`fileReaderToTf expects kind "documentModel"; got "${entity.kind}" (refName "${entity.refName}")`);
|
|
51
|
+
}
|
|
52
|
+
const payload = entity.payload;
|
|
53
|
+
if (payload === null || typeof payload !== "object") {
|
|
54
|
+
throw new EntityTfError(`file reader "${entity.refName}" has no payload — was it built with defineFileReader?`);
|
|
55
|
+
}
|
|
56
|
+
const subType = FILE_READER_SUB_TYPE_BY_TYPE_KEY.get(payload.type);
|
|
57
|
+
if (subType === undefined || subType.implemented !== true) {
|
|
58
|
+
throw new EntityTfError(`file reader "${entity.refName}": type "${payload.type}" does not build on the terraform path yet`);
|
|
59
|
+
}
|
|
60
|
+
const tfLabel = appScopedResourceLabel(ctx.appTfLabel, tsLabelToTfLabel(entity.refName));
|
|
61
|
+
const attrs = {
|
|
62
|
+
app_id: expr.resourceAttr(APP_RESOURCE_TYPE, ctx.appTfLabel, ["id"]),
|
|
63
|
+
name: payload.name,
|
|
64
|
+
};
|
|
65
|
+
if (payload.type === "excel") {
|
|
66
|
+
attrs.first_row_is_header = payload.firstRowIsHeader;
|
|
67
|
+
attrs.fields = payload.fields.map(excelFieldToTf);
|
|
68
|
+
if (payload.documentContent !== undefined)
|
|
69
|
+
attrs.document_content = payload.documentContent;
|
|
70
|
+
if (payload.documentName !== undefined)
|
|
71
|
+
attrs.document_name = payload.documentName;
|
|
72
|
+
if (payload.fileType !== undefined)
|
|
73
|
+
attrs.file_type = payload.fileType;
|
|
74
|
+
}
|
|
75
|
+
else if (payload.type === "json") {
|
|
76
|
+
attrs.structure = expr.jsonencode({ properties: payload.structure.map(serializeStructureField) });
|
|
77
|
+
}
|
|
78
|
+
else if (payload.type === "ai") {
|
|
79
|
+
attrs.instructions = payload.instructions;
|
|
80
|
+
attrs.fields = payload.fields.map(aiFieldToTf);
|
|
81
|
+
}
|
|
82
|
+
// text: name only, already set above.
|
|
83
|
+
return { blocks: [{ kind: "resource", type: subType.resourceType, label: tfLabel, attrs }] };
|
|
84
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The file-reader entity's sub-type table. Five platform resource types share
|
|
3
|
+
* one ownership shape (app-scoped, own-file, one `.ts` per instance):
|
|
4
|
+
* `elementum_excel_file_reader`, `elementum_json_file_reader`,
|
|
5
|
+
* `elementum_text_file_reader`, `elementum_xml_file_reader`, and
|
|
6
|
+
* `elementum_ai_file_reader` — exactly the `entities/field/types.ts` /
|
|
7
|
+
* `entities/agent-tool/types.ts` pattern, one ROW per sub-type.
|
|
8
|
+
*
|
|
9
|
+
* excel/json/text/ai are implemented. excel/json/text are the three
|
|
10
|
+
* `elementum_file_reader_task.file_reader_id` accepts (the provider's own
|
|
11
|
+
* schema docs say so explicitly); `ai` backs `elementum_ai_file_read_task`
|
|
12
|
+
* instead (see `entities/automation/types.ts`'s `aiFileAnalysis` row) — a
|
|
13
|
+
* live capture also confirms a plain `elementum_file_reader_task` can
|
|
14
|
+
* reference one. `xml` is declared so streams REPORT it by name (plan §6)
|
|
15
|
+
* instead of "unknown resource" — it has no confirmed live capture yet —
|
|
16
|
+
* and adoption scopes ONLY the implemented ones.
|
|
17
|
+
*/
|
|
18
|
+
export interface FileReaderSubType {
|
|
19
|
+
/** The authoring `type` discriminant (`FileReaderOptions.type`). */
|
|
20
|
+
readonly typeKey: "excel" | "json" | "text" | "xml" | "ai";
|
|
21
|
+
/** Terraform resource type, e.g. "elementum_excel_file_reader". */
|
|
22
|
+
readonly resourceType: string;
|
|
23
|
+
/** Round-trips on the terraform path (to-tf + from-tf + printer). */
|
|
24
|
+
readonly implemented?: true;
|
|
25
|
+
}
|
|
26
|
+
export declare const FILE_READER_SUB_TYPES: readonly FileReaderSubType[];
|
|
27
|
+
export declare const FILE_READER_SUB_TYPE_BY_TYPE_KEY: ReadonlyMap<string, FileReaderSubType>;
|
|
28
|
+
export declare const FILE_READER_SUB_TYPE_BY_RESOURCE: ReadonlyMap<string, FileReaderSubType>;
|
|
29
|
+
/** The resource types the terraform path round-trips today (adoption scope). */
|
|
30
|
+
export declare const IMPLEMENTED_FILE_READER_RESOURCE_TYPES: readonly string[];
|
|
31
|
+
/** Every declared file-reader resource type — stream partition recognizes these by name. */
|
|
32
|
+
export declare const ALL_FILE_READER_RESOURCE_TYPES: readonly string[];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The file-reader entity's sub-type table. Five platform resource types share
|
|
3
|
+
* one ownership shape (app-scoped, own-file, one `.ts` per instance):
|
|
4
|
+
* `elementum_excel_file_reader`, `elementum_json_file_reader`,
|
|
5
|
+
* `elementum_text_file_reader`, `elementum_xml_file_reader`, and
|
|
6
|
+
* `elementum_ai_file_reader` — exactly the `entities/field/types.ts` /
|
|
7
|
+
* `entities/agent-tool/types.ts` pattern, one ROW per sub-type.
|
|
8
|
+
*
|
|
9
|
+
* excel/json/text/ai are implemented. excel/json/text are the three
|
|
10
|
+
* `elementum_file_reader_task.file_reader_id` accepts (the provider's own
|
|
11
|
+
* schema docs say so explicitly); `ai` backs `elementum_ai_file_read_task`
|
|
12
|
+
* instead (see `entities/automation/types.ts`'s `aiFileAnalysis` row) — a
|
|
13
|
+
* live capture also confirms a plain `elementum_file_reader_task` can
|
|
14
|
+
* reference one. `xml` is declared so streams REPORT it by name (plan §6)
|
|
15
|
+
* instead of "unknown resource" — it has no confirmed live capture yet —
|
|
16
|
+
* and adoption scopes ONLY the implemented ones.
|
|
17
|
+
*/
|
|
18
|
+
export const FILE_READER_SUB_TYPES = [
|
|
19
|
+
{ typeKey: "excel", resourceType: "elementum_excel_file_reader", implemented: true },
|
|
20
|
+
{ typeKey: "json", resourceType: "elementum_json_file_reader", implemented: true },
|
|
21
|
+
{ typeKey: "text", resourceType: "elementum_text_file_reader", implemented: true },
|
|
22
|
+
{ typeKey: "xml", resourceType: "elementum_xml_file_reader" },
|
|
23
|
+
{ typeKey: "ai", resourceType: "elementum_ai_file_reader", implemented: true },
|
|
24
|
+
];
|
|
25
|
+
export const FILE_READER_SUB_TYPE_BY_TYPE_KEY = new Map(FILE_READER_SUB_TYPES.map((t) => [t.typeKey, t]));
|
|
26
|
+
export const FILE_READER_SUB_TYPE_BY_RESOURCE = new Map(FILE_READER_SUB_TYPES.map((t) => [t.resourceType, t]));
|
|
27
|
+
/** The resource types the terraform path round-trips today (adoption scope). */
|
|
28
|
+
export const IMPLEMENTED_FILE_READER_RESOURCE_TYPES = FILE_READER_SUB_TYPES.filter((t) => t.implemented === true).map((t) => t.resourceType);
|
|
29
|
+
/** Every declared file-reader resource type — stream partition recognizes these by name. */
|
|
30
|
+
export const ALL_FILE_READER_RESOURCE_TYPES = FILE_READER_SUB_TYPES.map((t) => t.resourceType);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI providers: org-owned reference identities, name-keyed lookups — never
|
|
3
|
+
* authored/created (they hold credentials, manually configured on the
|
|
4
|
+
* platform; src/CLAUDE.md), only referenced. One kind per AiProviderType
|
|
5
|
+
* (Anthropic, Bedrock, ..., matching the 10 distinct `elementum_<type>_
|
|
6
|
+
* ai_provider` terraform data sources) sharing the single "aiProviders" org
|
|
7
|
+
* bag — `pull org`/`catalog/org.ts` treat that bag's entries uniformly
|
|
8
|
+
* regardless of which of the 10 kinds produced them.
|
|
9
|
+
*/
|
|
10
|
+
import { type EntityKindModule } from "../../graph/types.js";
|
|
11
|
+
/** org.ts / OrgRefLookup bag — keep in lockstep with `data.orgBag`. */
|
|
12
|
+
export declare const AI_PROVIDER_ORG_BAG: "aiProviders";
|
|
13
|
+
export declare const aiProviderModules: readonly EntityKindModule[];
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI providers: org-owned reference identities, name-keyed lookups — never
|
|
3
|
+
* authored/created (they hold credentials, manually configured on the
|
|
4
|
+
* platform; src/CLAUDE.md), only referenced. One kind per AiProviderType
|
|
5
|
+
* (Anthropic, Bedrock, ..., matching the 10 distinct `elementum_<type>_
|
|
6
|
+
* ai_provider` terraform data sources) sharing the single "aiProviders" org
|
|
7
|
+
* bag — `pull org`/`catalog/org.ts` treat that bag's entries uniformly
|
|
8
|
+
* regardless of which of the 10 kinds produced them.
|
|
9
|
+
*/
|
|
10
|
+
import { NO_CATALOG, NO_LIFECYCLE } from "../../graph/types.js";
|
|
11
|
+
/** org.ts / OrgRefLookup bag — keep in lockstep with `data.orgBag`. */
|
|
12
|
+
export const AI_PROVIDER_ORG_BAG = "aiProviders";
|
|
13
|
+
const AI_PROVIDER_TYPES = [
|
|
14
|
+
{ kind: "ai-provider-anthropic", resourceType: "elementum_anthropic_ai_provider", label: "Anthropic" },
|
|
15
|
+
{ kind: "ai-provider-bedrock", resourceType: "elementum_bedrock_ai_provider", label: "Bedrock" },
|
|
16
|
+
{ kind: "ai-provider-custom", resourceType: "elementum_custom_ai_provider", label: "Custom" },
|
|
17
|
+
{ kind: "ai-provider-deepgram", resourceType: "elementum_deepgram_ai_provider", label: "Deepgram" },
|
|
18
|
+
{ kind: "ai-provider-elevenlab", resourceType: "elementum_elevenlab_ai_provider", label: "ElevenLab" },
|
|
19
|
+
{ kind: "ai-provider-gemini", resourceType: "elementum_gemini_ai_provider", label: "Gemini" },
|
|
20
|
+
{ kind: "ai-provider-openai", resourceType: "elementum_openai_ai_provider", label: "OpenAI" },
|
|
21
|
+
{ kind: "ai-provider-snowflake", resourceType: "elementum_snowflake_ai_provider", label: "Snowflake" },
|
|
22
|
+
{ kind: "ai-provider-xai", resourceType: "elementum_xai_ai_provider", label: "xAI" },
|
|
23
|
+
{ kind: "ai-provider-managed", resourceType: "elementum_managed_ai_provider", label: "Elementum Managed" },
|
|
24
|
+
];
|
|
25
|
+
export const aiProviderModules = AI_PROVIDER_TYPES.map(({ kind, resourceType, label }) => ({
|
|
26
|
+
kind,
|
|
27
|
+
stream: { role: "orgExport" },
|
|
28
|
+
data: {
|
|
29
|
+
participates: true,
|
|
30
|
+
lookupAttr: "name",
|
|
31
|
+
catalogKind: "aiProvider",
|
|
32
|
+
orgBag: AI_PROVIDER_ORG_BAG,
|
|
33
|
+
// Connectors reference their provider (`provider_id`), so build emits
|
|
34
|
+
// this data source and the build-vs-export scopes it.
|
|
35
|
+
referencedByBuild: true,
|
|
36
|
+
},
|
|
37
|
+
authoring: { unit: "none" },
|
|
38
|
+
parents: [{ parent: "org", child: kind }],
|
|
39
|
+
resource: { shape: "single", resourceType, adoptable: false },
|
|
40
|
+
lifecycle: NO_LIFECYCLE,
|
|
41
|
+
canvas: { participates: true, label: `AI Providers (${label})`, glyph: "◆", component: "orgIdentity" },
|
|
42
|
+
// Rendered specially in src/catalog/org.ts (nested with each provider's
|
|
43
|
+
// connectors under `aiProviders.<provider>.models.<model>`), not through
|
|
44
|
+
// the generic per-bag catalog renderer.
|
|
45
|
+
catalog: NO_CATALOG,
|
|
46
|
+
}));
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* AI provider connectors: org-owned reference identities, model_name-keyed
|
|
3
|
+
* lookups. Never their own top-level catalog bag — nested under their
|
|
4
|
+
* owning provider instead (`catalog.aiProviders.<provider>.models.<model>`,
|
|
5
|
+
* rendered specially in `src/catalog/org.ts`), since a connector's
|
|
6
|
+
* `provider_id` is a real reference to one of the 10 `elementum_<type>_
|
|
7
|
+
* ai_provider` blocks (entities/org/ai-provider.ts), not a plain string.
|
|
8
|
+
*/
|
|
2
9
|
import { type EntityKindModule } from "../../graph/types.js";
|
|
3
10
|
/** org.ts / OrgRefLookup bag — keep in lockstep with `data.orgBag`. */
|
|
4
11
|
export declare const CONNECTOR_ORG_BAG: "connectors";
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* AI provider connectors: org-owned reference identities, model_name-keyed
|
|
3
|
+
* lookups. Never their own top-level catalog bag — nested under their
|
|
4
|
+
* owning provider instead (`catalog.aiProviders.<provider>.models.<model>`,
|
|
5
|
+
* rendered specially in `src/catalog/org.ts`), since a connector's
|
|
6
|
+
* `provider_id` is a real reference to one of the 10 `elementum_<type>_
|
|
7
|
+
* ai_provider` blocks (entities/org/ai-provider.ts), not a plain string.
|
|
8
|
+
*/
|
|
9
|
+
import { NO_CATALOG, NO_LIFECYCLE } from "../../graph/types.js";
|
|
4
10
|
/** org.ts / OrgRefLookup bag — keep in lockstep with `data.orgBag`. */
|
|
5
11
|
export const CONNECTOR_ORG_BAG = "connectors";
|
|
6
12
|
export const connectorModule = {
|
|
@@ -9,6 +15,7 @@ export const connectorModule = {
|
|
|
9
15
|
data: {
|
|
10
16
|
participates: true,
|
|
11
17
|
lookupAttr: "model_name",
|
|
18
|
+
providerRefAttr: "provider_id",
|
|
12
19
|
catalogKind: "connector",
|
|
13
20
|
orgBag: CONNECTOR_ORG_BAG,
|
|
14
21
|
// Agents pin connectors (`ai_provider_connector_id`), so build emits this
|
|
@@ -23,15 +30,6 @@ export const connectorModule = {
|
|
|
23
30
|
adoptable: false,
|
|
24
31
|
},
|
|
25
32
|
lifecycle: NO_LIFECYCLE,
|
|
26
|
-
canvas: { participates: true, label: "Connectors", glyph: "⚡", component: "orgIdentity" },
|
|
27
|
-
catalog:
|
|
28
|
-
participates: true,
|
|
29
|
-
refKind: "connector",
|
|
30
|
-
catalogBag: "connectors",
|
|
31
|
-
renderOrder: 90,
|
|
32
|
-
catalogRoot: "org",
|
|
33
|
-
renderEntry: namedOnlyFactoryEntry("connectorRef"),
|
|
34
|
-
stubRef: (refName) => ({ __kind: "connector", refName, name: refName }),
|
|
35
|
-
refFromAuthoring: () => undefined,
|
|
36
|
-
},
|
|
33
|
+
canvas: { participates: true, label: "AI Provider Connectors", glyph: "⚡", component: "orgIdentity" },
|
|
34
|
+
catalog: NO_CATALOG,
|
|
37
35
|
};
|
|
@@ -11,7 +11,16 @@ export const groupModule = {
|
|
|
11
11
|
lookupAttr: "name",
|
|
12
12
|
catalogKind: "group",
|
|
13
13
|
orgBag: GROUP_ORG_BAG,
|
|
14
|
-
|
|
14
|
+
// A GROUP field's `default_value` (entities/field/types.ts's
|
|
15
|
+
// OrgFieldRefValue) and an access policy's `group_ids` (board issue #69)
|
|
16
|
+
// both round-trip as `data.elementum_group` lookups via the generic
|
|
17
|
+
// `rawLookup` mechanism — real, tested coverage, so this participates in
|
|
18
|
+
// the byte-fidelity roundtrip scope. A captured `elementum_group` data
|
|
19
|
+
// block for any OTHER reason still fails loud (missing from build
|
|
20
|
+
// output) rather than silently passing — surfacing gaps instead of
|
|
21
|
+
// hiding them was the tradeoff of leaving this false; if that surfaces a
|
|
22
|
+
// real one, extend the reproducing path rather than reverting this flag.
|
|
23
|
+
referencedByBuild: true,
|
|
15
24
|
},
|
|
16
25
|
authoring: { unit: "none" },
|
|
17
26
|
parents: [{ parent: "org", child: "group" }],
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Org identity / data-facet kinds. Each file exports an EntityKindModule;
|
|
3
3
|
* assembly into KIND_MODULES lives in src/graph/modules.ts.
|
|
4
4
|
*/
|
|
5
|
+
export { aiProviderModules } from "./ai-provider.js";
|
|
5
6
|
export { categoryModule } from "./category.js";
|
|
6
7
|
export { cloudLinkModule } from "./cloud-link.js";
|
|
7
8
|
export { connectorModule } from "./connector.js";
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Org identity / data-facet kinds. Each file exports an EntityKindModule;
|
|
3
3
|
* assembly into KIND_MODULES lives in src/graph/modules.ts.
|
|
4
4
|
*/
|
|
5
|
+
export { aiProviderModules } from "./ai-provider.js";
|
|
5
6
|
export { categoryModule } from "./category.js";
|
|
6
7
|
export { cloudLinkModule } from "./cloud-link.js";
|
|
7
8
|
export { connectorModule } from "./connector.js";
|