@cargo-ai/cdk 1.0.9 → 1.0.11
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/build/src/cli/commands/inputTypes.d.ts +7 -0
- package/build/src/cli/commands/inputTypes.d.ts.map +1 -1
- package/build/src/cli/commands/inputTypes.js +23 -0
- package/build/src/cli/commands/types.d.ts.map +1 -1
- package/build/src/cli/commands/types.js +79 -3
- package/build/src/index.d.ts +1 -1
- package/build/src/index.d.ts.map +1 -1
- package/build/src/resources/model.d.ts +21 -2
- package/build/src/resources/model.d.ts.map +1 -1
- package/build/src/resources/model.js +12 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -23,6 +23,13 @@ export declare function printJsonSchemaType(schema: unknown): string;
|
|
|
23
23
|
* would not.
|
|
24
24
|
*/
|
|
25
25
|
export declare function printJsonSchemaOutput(schema: unknown): string | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* The top-level property names of an object JSON Schema — e.g. the column
|
|
28
|
+
* slugs an extractor's `columns.schema` declares. `allOf`/`anyOf`/`oneOf`
|
|
29
|
+
* members contribute the union of their keys; anything that isn't
|
|
30
|
+
* object-shaped contributes none.
|
|
31
|
+
*/
|
|
32
|
+
export declare function jsonSchemaPropertyKeys(schema: unknown): string[];
|
|
26
33
|
/**
|
|
27
34
|
* Print a tool release's `formFields` as a TS input type. Returns
|
|
28
35
|
* `undefined` when the fields can't be interpreted (caller falls back to
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inputTypes.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/inputTypes.ts"],"names":[],"mappings":"AAqCA;;;GAGG;AACH,eAAO,MAAM,oBAAoB,QAE+D,CAAC;AAEjG;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAM5D;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAQ3D;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAQzE;
|
|
1
|
+
{"version":3,"file":"inputTypes.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/inputTypes.ts"],"names":[],"mappings":"AAqCA;;;GAGG;AACH,eAAO,MAAM,oBAAoB,QAE+D,CAAC;AAEjG;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAM5D;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAQ3D;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAQzE;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,EAAE,CAGhE;AAgVD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAU5E"}
|
|
@@ -65,6 +65,29 @@ export function printJsonSchemaOutput(schema) {
|
|
|
65
65
|
? undefined
|
|
66
66
|
: printed;
|
|
67
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* The top-level property names of an object JSON Schema — e.g. the column
|
|
70
|
+
* slugs an extractor's `columns.schema` declares. `allOf`/`anyOf`/`oneOf`
|
|
71
|
+
* members contribute the union of their keys; anything that isn't
|
|
72
|
+
* object-shaped contributes none.
|
|
73
|
+
*/
|
|
74
|
+
export function jsonSchemaPropertyKeys(schema) {
|
|
75
|
+
if (schema === null || typeof schema !== "object")
|
|
76
|
+
return [];
|
|
77
|
+
return [...collectPropertyKeys(schema)];
|
|
78
|
+
}
|
|
79
|
+
function collectPropertyKeys(schema) {
|
|
80
|
+
const keys = new Set(schema.properties === undefined ? [] : Object.keys(schema.properties));
|
|
81
|
+
for (const members of [schema.allOf, schema.anyOf, schema.oneOf]) {
|
|
82
|
+
if (members === undefined)
|
|
83
|
+
continue;
|
|
84
|
+
for (const member of members) {
|
|
85
|
+
for (const key of collectPropertyKeys(member))
|
|
86
|
+
keys.add(key);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return keys;
|
|
90
|
+
}
|
|
68
91
|
// The platform's shared `encryption` schema definition: an object with a `type`
|
|
69
92
|
// const/enum of "encryption" plus `isEncrypted` and `value`. In CDK config types
|
|
70
93
|
// these positions become `EncryptionRef` (see printObject).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/types.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/types.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAoJzC,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,GAAG,IAAI,CAoE7E"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mkdirSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
3
|
import { handleApiCall, info, success } from "../io.js";
|
|
4
|
-
import { printJsonSchemaInput, printJsonSchemaOutput, printJsonSchemaType, } from "./inputTypes.js";
|
|
4
|
+
import { jsonSchemaPropertyKeys, printJsonSchemaInput, printJsonSchemaOutput, printJsonSchemaType, } from "./inputTypes.js";
|
|
5
5
|
// Composite natives surfaced via dedicated SDK syntax / scope helpers —
|
|
6
6
|
// excluded so we don't double-register them. Mirrors the codegen exclusion
|
|
7
7
|
// list in `packages/workflow-sdk/scripts/generateNativeIntegration.ts`
|
|
@@ -37,7 +37,7 @@ const BUNDLED_NATIVE = new Set([
|
|
|
37
37
|
export function registerTypesCommand(parent, getApi) {
|
|
38
38
|
parent
|
|
39
39
|
.command("types")
|
|
40
|
-
.description("Generate per-workspace TypeScript types for the Cargo CDK — typed defineConnector/defineModel config + integration actions in workflow bodies")
|
|
40
|
+
.description("Generate per-workspace TypeScript types for the Cargo CDK — typed defineConnector/defineModel config, model columns + integration actions in workflow bodies")
|
|
41
41
|
.option("--dir <path>", "Repo root the generated files are written into (default: cwd)")
|
|
42
42
|
.option("--out <dir>", "Output subdirectory for generated files (default: .cargo-ai)", ".cargo-ai")
|
|
43
43
|
.action(async (opts) => {
|
|
@@ -69,26 +69,31 @@ export function registerTypesCommand(parent, getApi) {
|
|
|
69
69
|
].join("\n"));
|
|
70
70
|
info(``);
|
|
71
71
|
const extractorCount = payload.extractorConfigs.reduce((n, e) => n + e.extractors.length, 0);
|
|
72
|
-
info(`Typed ${String(payload.connectorConfigs.length)} connector config(s), ${String(extractorCount)} extractor config(s), ${String(payload.agentTriggerConfigs.length)} agent trigger config(s), ${String(payload.integrations.length)} integration(s), ${String(payload.native.length)} native action(s).`);
|
|
72
|
+
info(`Typed ${String(payload.connectorConfigs.length)} connector config(s), ${String(extractorCount)} extractor config(s), ${String(payload.agentTriggerConfigs.length)} agent trigger config(s), ${String(payload.modelColumns.length)} model column set(s), ${String(payload.extractorColumns.reduce((n, e) => n + e.extractors.length, 0))} extractor column set(s), ${String(payload.integrations.length)} integration(s), ${String(payload.native.length)} native action(s).`);
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
async function fetchWorkspaceSurface(api) {
|
|
76
76
|
const integrationsResult = await handleApiCall(() => api.connection.integration.list({}));
|
|
77
77
|
const nativeIntegrationResult = await handleApiCall(() => api.connection.nativeIntegration.get());
|
|
78
|
+
const modelsResult = await handleApiCall(() => api.storage.model.all());
|
|
78
79
|
const rawIntegrations = integrationsResult.integrations;
|
|
79
80
|
const integrations = collectIntegrations(rawIntegrations);
|
|
80
81
|
const native = collectNative(nativeIntegrationResult.nativeIntegration.actions);
|
|
81
82
|
const connectorConfigs = collectConnectorConfigs(rawIntegrations);
|
|
82
83
|
const extractorConfigs = collectExtractorConfigs(rawIntegrations);
|
|
83
84
|
const extractorSlugs = collectExtractorSlugs(rawIntegrations);
|
|
85
|
+
const extractorColumns = collectExtractorColumns(rawIntegrations);
|
|
84
86
|
const agentTriggerConfigs = collectAgentTriggerConfigs(rawIntegrations);
|
|
87
|
+
const modelColumns = collectModelColumns(modelsResult.models);
|
|
85
88
|
return {
|
|
86
89
|
integrations,
|
|
87
90
|
native,
|
|
88
91
|
connectorConfigs,
|
|
89
92
|
extractorConfigs,
|
|
90
93
|
extractorSlugs,
|
|
94
|
+
extractorColumns,
|
|
91
95
|
agentTriggerConfigs,
|
|
96
|
+
modelColumns,
|
|
92
97
|
};
|
|
93
98
|
}
|
|
94
99
|
// integrationSlug → connector config type. Skips integrations whose schema
|
|
@@ -177,6 +182,57 @@ function collectExtractorSlugs(integrations) {
|
|
|
177
182
|
out.sort((a, b) => a.integrationSlug.localeCompare(b.integrationSlug));
|
|
178
183
|
return out;
|
|
179
184
|
}
|
|
185
|
+
// integrationSlug → the column slugs each of its extractors statically
|
|
186
|
+
// declares (`extractor.columns.schema`, one property per column). Skips
|
|
187
|
+
// extractors without a declared schema — most compute their columns from the
|
|
188
|
+
// fetched records — and integrations left with none.
|
|
189
|
+
function collectExtractorColumns(integrations) {
|
|
190
|
+
return integrations
|
|
191
|
+
.map((integration) => ({
|
|
192
|
+
integrationSlug: integration.slug,
|
|
193
|
+
extractors: collectDeclaredColumns(integration),
|
|
194
|
+
}))
|
|
195
|
+
.filter((entry) => entry.extractors.length > 0)
|
|
196
|
+
.sort((a, b) => a.integrationSlug.localeCompare(b.integrationSlug));
|
|
197
|
+
}
|
|
198
|
+
// One `{ slug, columns }` entry per extractor that declares a non-empty
|
|
199
|
+
// `columns.schema`, extractors and columns both sorted.
|
|
200
|
+
function collectDeclaredColumns(integration) {
|
|
201
|
+
const { extractors = {} } = integration;
|
|
202
|
+
return Object.entries(extractors)
|
|
203
|
+
.map(([slug, { columns }]) => ({
|
|
204
|
+
slug,
|
|
205
|
+
columns: columns === undefined
|
|
206
|
+
? []
|
|
207
|
+
: jsonSchemaPropertyKeys(columns.schema).sort((a, b) => a.localeCompare(b)),
|
|
208
|
+
}))
|
|
209
|
+
.filter((extractor) => extractor.columns.length > 0)
|
|
210
|
+
.sort((a, b) => a.slug.localeCompare(b.slug));
|
|
211
|
+
}
|
|
212
|
+
// modelSlug → every column slug it exposes. Additional columns are addressed
|
|
213
|
+
// with their kind as a storage prefix (`computed__score`, `custom__notes`, …) —
|
|
214
|
+
// the same slugs `/storage/columns/list` returns — while original columns stay
|
|
215
|
+
// bare. Models whose columns haven't been inferred yet are skipped; two models
|
|
216
|
+
// sharing a slug (across datasets) merge their column sets so the generated
|
|
217
|
+
// union accepts either.
|
|
218
|
+
function collectModelColumns(models) {
|
|
219
|
+
const bySlug = new Map();
|
|
220
|
+
for (const model of models) {
|
|
221
|
+
const previous = bySlug.get(model.slug);
|
|
222
|
+
bySlug.set(model.slug, [
|
|
223
|
+
...(previous === undefined ? [] : previous),
|
|
224
|
+
...model.columns.map((column) => column.slug),
|
|
225
|
+
...model.additionalColumns.map((column) => `${column.kind}__${column.slug}`),
|
|
226
|
+
]);
|
|
227
|
+
}
|
|
228
|
+
return [...bySlug]
|
|
229
|
+
.filter(([, slugs]) => slugs.length > 0)
|
|
230
|
+
.map(([modelSlug, slugs]) => ({
|
|
231
|
+
modelSlug,
|
|
232
|
+
columns: [...new Set(slugs)].sort((a, b) => a.localeCompare(b)),
|
|
233
|
+
}))
|
|
234
|
+
.sort((a, b) => a.modelSlug.localeCompare(b.modelSlug));
|
|
235
|
+
}
|
|
180
236
|
function collectIntegrations(integrations) {
|
|
181
237
|
const out = [];
|
|
182
238
|
for (const integration of integrations) {
|
|
@@ -271,6 +327,26 @@ function renderTypes(payload) {
|
|
|
271
327
|
}
|
|
272
328
|
cdkLines.push(` }`);
|
|
273
329
|
}
|
|
330
|
+
if (payload.extractorColumns.length > 0) {
|
|
331
|
+
cdkLines.push(` interface ExtractorColumns {`);
|
|
332
|
+
for (const e of payload.extractorColumns) {
|
|
333
|
+
cdkLines.push(` ${jsonKey(e.integrationSlug)}: {`);
|
|
334
|
+
for (const x of e.extractors) {
|
|
335
|
+
const union = x.columns.map((c) => JSON.stringify(c)).join(" | ");
|
|
336
|
+
cdkLines.push(` ${jsonKey(x.slug)}: ${union};`);
|
|
337
|
+
}
|
|
338
|
+
cdkLines.push(` };`);
|
|
339
|
+
}
|
|
340
|
+
cdkLines.push(` }`);
|
|
341
|
+
}
|
|
342
|
+
if (payload.modelColumns.length > 0) {
|
|
343
|
+
cdkLines.push(` interface ModelColumns {`);
|
|
344
|
+
for (const m of payload.modelColumns) {
|
|
345
|
+
const union = m.columns.map((c) => JSON.stringify(c)).join(" | ");
|
|
346
|
+
cdkLines.push(` ${jsonKey(m.modelSlug)}: ${union};`);
|
|
347
|
+
}
|
|
348
|
+
cdkLines.push(` }`);
|
|
349
|
+
}
|
|
274
350
|
if (payload.agentTriggerConfigs.length > 0) {
|
|
275
351
|
cdkLines.push(` interface AgentTriggerConfigs {`);
|
|
276
352
|
for (const t of payload.agentTriggerConfigs) {
|
package/build/src/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export type { FolderHandle, FolderKind, FolderSpec, } from "./resources/folder.j
|
|
|
16
16
|
export { defineFolder } from "./resources/folder.js";
|
|
17
17
|
export type { McpServerHandle, McpServerSpec } from "./resources/mcpServer.js";
|
|
18
18
|
export { defineMcpServer } from "./resources/mcpServer.js";
|
|
19
|
-
export type { ExtractorConfigs, ExtractorSlugs, ModelHandle, ModelSpec, UnificationColumnSpec, UnificationParentSpec, UnificationSpec, } from "./resources/model.js";
|
|
19
|
+
export type { ExtractorColumns, ExtractorConfigs, ExtractorSlugs, ModelColumns, ModelHandle, ModelSpec, UnificationColumnSpec, UnificationParentSpec, UnificationSpec, } from "./resources/model.js";
|
|
20
20
|
export { defineModel } from "./resources/model.js";
|
|
21
21
|
export type { PlayHandle, PlaySpec } from "./resources/play.js";
|
|
22
22
|
export { definePlay } from "./resources/play.js";
|
package/build/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAUA,YAAY,EACV,aAAa,EACb,WAAW,EACX,SAAS,EACT,mBAAmB,EACnB,QAAQ,EACR,sBAAsB,EACtB,YAAY,EACZ,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACrE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,YAAY,EACV,0BAA0B,EAC1B,aAAa,EACb,cAAc,EACd,YAAY,GACb,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpE,YAAY,EACV,gBAAgB,EAChB,eAAe,EACf,aAAa,GACd,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,YAAY,EACV,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO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
|
43
43
|
export interface ExtractorSlugs {
|
|
44
44
|
}
|
|
45
45
|
type ExtractorSlugFor<S extends string> = S extends keyof ExtractorSlugs ? ExtractorSlugs[S] & string : string;
|
|
46
|
+
export interface ModelColumns {
|
|
47
|
+
}
|
|
48
|
+
export interface ExtractorColumns {
|
|
49
|
+
}
|
|
50
|
+
type ExtractorColumnsFor<S extends string, E extends string> = S extends keyof ExtractorColumns ? E extends keyof ExtractorColumns[S] ? ExtractorColumns[S][E] & string : never : never;
|
|
51
|
+
type ModelColumnsAccessor<Slug extends string, S extends string, E extends string> = Slug extends keyof ModelColumns ? {
|
|
52
|
+
readonly [C in ModelColumns[Slug] & string]: C;
|
|
53
|
+
} & {
|
|
54
|
+
readonly [columnSlug: string]: string;
|
|
55
|
+
} : [ExtractorColumnsFor<S, E>] extends [never] ? {
|
|
56
|
+
readonly [columnSlug: string]: string;
|
|
57
|
+
} : {
|
|
58
|
+
readonly [C in ExtractorColumnsFor<S, E>]: C;
|
|
59
|
+
} & {
|
|
60
|
+
readonly [columnSlug: string]: string;
|
|
61
|
+
};
|
|
46
62
|
type LiteralUnion<T extends string> = T | (string & {});
|
|
47
63
|
export type ModelSpec<S extends string = string, E extends LiteralUnion<ExtractorSlugFor<S>> = LiteralUnion<ExtractorSlugFor<S>>> = {
|
|
48
64
|
name?: string;
|
|
@@ -67,11 +83,14 @@ export type ModelSpec<S extends string = string, E extends LiteralUnion<Extracto
|
|
|
67
83
|
*/
|
|
68
84
|
unification?: UnificationSpec;
|
|
69
85
|
};
|
|
70
|
-
export type ModelHandle = {
|
|
86
|
+
export type ModelHandle<Slug extends string = string, S extends string = string, E extends string = string> = {
|
|
71
87
|
readonly slug: string;
|
|
72
88
|
readonly uuid: Token;
|
|
73
89
|
readonly resource: "model";
|
|
90
|
+
/** This model's columns — `model.columns.<columnSlug>` yields the slug
|
|
91
|
+
* string, for relationships, unification, and segment column lists. */
|
|
92
|
+
readonly columns: ModelColumnsAccessor<Slug, S, E>;
|
|
74
93
|
};
|
|
75
|
-
export declare function defineModel<S extends string, E extends LiteralUnion<ExtractorSlugFor<S>>>(slug:
|
|
94
|
+
export declare function defineModel<Slug extends string, S extends string, E extends LiteralUnion<ExtractorSlugFor<S>>>(slug: Slug, spec: ModelSpec<S, E>): ModelHandle<Slug, S, E & string>;
|
|
76
95
|
export {};
|
|
77
96
|
//# sourceMappingURL=model.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../src/resources/model.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEvE,OAAO,EAAwB,KAAK,KAAK,EAAS,MAAM,YAAY,CAAC;AACrE,OAAO,EACL,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,QAAQ,EAEd,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,MAAM,YAAY,GACpB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAKnC,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAKF,MAAM,MAAM,qBAAqB,GAC7B;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,WAAW,GAAG,QAAQ,CAAA;CAAE,GACrE;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AAOjE,MAAM,MAAM,eAAe,GAC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,WAAW,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,CAgCrE"}
|
|
@@ -36,7 +36,18 @@ export function defineModel(slug, spec) {
|
|
|
36
36
|
: compileUnification(spec.unification),
|
|
37
37
|
},
|
|
38
38
|
});
|
|
39
|
-
|
|
39
|
+
// A small Proxy mirroring `connector.actions`: `model.columns.<columnSlug>`
|
|
40
|
+
// echoes the slug back as a plain string. No server knowledge is needed —
|
|
41
|
+
// columns are slug-addressed, so the accessor works before the model exists
|
|
42
|
+
// (symbols and `then` pass through as undefined).
|
|
43
|
+
const columns = new Proxy({}, {
|
|
44
|
+
get(_target, prop) {
|
|
45
|
+
if (typeof prop !== "string" || prop === "then")
|
|
46
|
+
return undefined;
|
|
47
|
+
return prop;
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
return { slug, uuid: token(id, "uuid"), resource: "model", columns };
|
|
40
51
|
}
|
|
41
52
|
// Lower a `UnificationSpec` to the wire shape `StorageTypes.ModelUnification`.
|
|
42
53
|
// The only reshaping is the parent link: a `model` parent carries a handle/ref
|