@cargo-ai/cdk 1.0.10 → 1.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/build/src/cli/commands/deploy.d.ts.map +1 -1
  2. package/build/src/cli/commands/deploy.js +105 -1
  3. package/build/src/cli/commands/inputTypes.d.ts +7 -0
  4. package/build/src/cli/commands/inputTypes.d.ts.map +1 -1
  5. package/build/src/cli/commands/inputTypes.js +23 -0
  6. package/build/src/cli/commands/types.d.ts.map +1 -1
  7. package/build/src/cli/commands/types.js +43 -2
  8. package/build/src/deploy/executors.live.d.ts.map +1 -1
  9. package/build/src/deploy/executors.live.js +56 -2
  10. package/build/src/deploy/import.d.ts +12 -0
  11. package/build/src/deploy/import.d.ts.map +1 -1
  12. package/build/src/deploy/import.js +79 -9
  13. package/build/src/deploy/index.d.ts +2 -0
  14. package/build/src/deploy/index.d.ts.map +1 -1
  15. package/build/src/deploy/index.js +1 -0
  16. package/build/src/deploy/pull/enumerate.d.ts +8 -0
  17. package/build/src/deploy/pull/enumerate.d.ts.map +1 -0
  18. package/build/src/deploy/pull/enumerate.js +258 -0
  19. package/build/src/deploy/pull/index.d.ts +28 -0
  20. package/build/src/deploy/pull/index.d.ts.map +1 -0
  21. package/build/src/deploy/pull/index.js +152 -0
  22. package/build/src/deploy/pull/ir.d.ts +45 -0
  23. package/build/src/deploy/pull/ir.d.ts.map +1 -0
  24. package/build/src/deploy/pull/ir.js +72 -0
  25. package/build/src/deploy/pull/mappers.d.ts +10 -0
  26. package/build/src/deploy/pull/mappers.d.ts.map +1 -0
  27. package/build/src/deploy/pull/mappers.js +689 -0
  28. package/build/src/deploy/pull/print.d.ts +9 -0
  29. package/build/src/deploy/pull/print.d.ts.map +1 -0
  30. package/build/src/deploy/pull/print.js +59 -0
  31. package/build/src/deploy/pull/resolve.d.ts +24 -0
  32. package/build/src/deploy/pull/resolve.d.ts.map +1 -0
  33. package/build/src/deploy/pull/resolve.js +113 -0
  34. package/build/src/deploy/pull/untar.d.ts +6 -0
  35. package/build/src/deploy/pull/untar.d.ts.map +1 -0
  36. package/build/src/deploy/pull/untar.js +84 -0
  37. package/build/src/deploy/readers.live.d.ts +3 -0
  38. package/build/src/deploy/readers.live.d.ts.map +1 -1
  39. package/build/src/deploy/readers.live.js +12 -6
  40. package/build/src/index.d.ts +3 -3
  41. package/build/src/index.d.ts.map +1 -1
  42. package/build/src/index.js +1 -1
  43. package/build/src/refs.d.ts +7 -1
  44. package/build/src/refs.d.ts.map +1 -1
  45. package/build/src/refs.js +10 -0
  46. package/build/src/resources/customIntegration.d.ts +3 -2
  47. package/build/src/resources/customIntegration.d.ts.map +1 -1
  48. package/build/src/resources/model.d.ts +67 -12
  49. package/build/src/resources/model.d.ts.map +1 -1
  50. package/build/src/resources/model.js +48 -1
  51. package/build/tsconfig.tsbuildinfo +1 -1
  52. package/package.json +3 -3
@@ -0,0 +1,9 @@
1
+ import { type GeneratedAsset } from "./ir.js";
2
+ import { type ResolvedResource } from "./resolve.js";
3
+ export type GeneratedSource = {
4
+ readonly path: string;
5
+ readonly source: string;
6
+ };
7
+ export type GeneratedFile = GeneratedSource | GeneratedAsset;
8
+ export declare function printResource(resource: ResolvedResource): GeneratedSource;
9
+ //# sourceMappingURL=print.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"print.d.ts","sourceRoot":"","sources":["../../../../src/deploy/pull/print.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,cAAc,EAAgB,MAAM,SAAS,CAAC;AAC5D,OAAO,EAAa,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAsChE,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CAAC;AAGF,MAAM,MAAM,aAAa,GAAG,eAAe,GAAG,cAAc,CAAC;AAE7D,wBAAgB,aAAa,CAAC,QAAQ,EAAE,gBAAgB,GAAG,eAAe,CAoBzE"}
@@ -0,0 +1,59 @@
1
+ // TS source printer. Turns a ResolvedResource into a `<dir>/<slug>.ts` module:
2
+ // the import header followed by `export const <id> = define<Kind>("slug", {…})`.
3
+ // Formatting is cosmetic — the content hash is computed from the runtime spec,
4
+ // not the source text — but output is deterministic so re-pulls diff cleanly.
5
+ import { isCallMarker } from "./ir.js";
6
+ import { isRawExpr } from "./resolve.js";
7
+ const IDENT = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
8
+ function printKey(key) {
9
+ return IDENT.test(key) ? key : JSON.stringify(key);
10
+ }
11
+ function printValue(value, indent) {
12
+ if (isRawExpr(value))
13
+ return value.__expr;
14
+ if (isCallMarker(value)) {
15
+ const args = value.args.map((arg) => printValue(arg, indent));
16
+ return `${value.fn}(${args.join(", ")})`;
17
+ }
18
+ if (value === null)
19
+ return "null";
20
+ if (typeof value === "string")
21
+ return JSON.stringify(value);
22
+ if (typeof value === "number" || typeof value === "boolean") {
23
+ return String(value);
24
+ }
25
+ if (Array.isArray(value)) {
26
+ if (value.length === 0)
27
+ return "[]";
28
+ const inner = indent + " ";
29
+ const items = value.map((item) => `${inner}${printValue(item, inner)}`);
30
+ return `[\n${items.join(",\n")},\n${indent}]`;
31
+ }
32
+ if (typeof value === "object") {
33
+ const entries = Object.entries(value).filter(([, v]) => v !== undefined);
34
+ if (entries.length === 0)
35
+ return "{}";
36
+ const inner = indent + " ";
37
+ const lines = entries.map(([key, v]) => `${inner}${printKey(key)}: ${printValue(v, inner)}`);
38
+ return `{\n${lines.join(",\n")},\n${indent}}`;
39
+ }
40
+ // undefined / functions — should never reach here for a mapped spec.
41
+ return "undefined";
42
+ }
43
+ export function printResource(resource) {
44
+ const header = [
45
+ `import { ${resource.cdkImports.join(", ")} } from "@cargo-ai/cdk";`,
46
+ ];
47
+ if (resource.localImports.length > 0) {
48
+ header.push("");
49
+ for (const imp of resource.localImports) {
50
+ header.push(`import { ${imp.identifier} } from ${JSON.stringify(imp.from)};`);
51
+ }
52
+ }
53
+ const args = resource.singleton
54
+ ? printValue(resource.spec, "")
55
+ : `${JSON.stringify(resource.slug)}, ${printValue(resource.spec, "")}`;
56
+ const body = `export const ${resource.identifier} = ${resource.defineFn}(${args});`;
57
+ const source = `${header.join("\n")}\n\n${body}\n`;
58
+ return { path: `${resource.dir}/${resource.slug}.ts`, source };
59
+ }
@@ -0,0 +1,24 @@
1
+ import { type IRResource } from "./ir.js";
2
+ export type RawExpr = {
3
+ readonly __expr: string;
4
+ };
5
+ export declare function rawExpr(code: string): RawExpr;
6
+ export declare function isRawExpr(value: unknown): value is RawExpr;
7
+ export type LocalImport = {
8
+ readonly identifier: string;
9
+ readonly from: string;
10
+ };
11
+ export type ResolvedResource = {
12
+ readonly kind: IRResource["kind"];
13
+ readonly slug: string;
14
+ readonly uuid: string;
15
+ readonly identifier: string;
16
+ readonly defineFn: string;
17
+ readonly dir: string;
18
+ readonly singleton: boolean;
19
+ readonly cdkImports: readonly string[];
20
+ readonly localImports: readonly LocalImport[];
21
+ readonly spec: Record<string, unknown>;
22
+ };
23
+ export declare function resolveResources(resources: readonly IRResource[]): ResolvedResource[];
24
+ //# sourceMappingURL=resolve.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../../src/deploy/pull/resolve.ts"],"names":[],"mappings":"AAgBA,OAAO,EAEL,KAAK,UAAU,EAMhB,MAAM,SAAS,CAAC;AAEjB,MAAM,MAAM,OAAO,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAElD,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE7C;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAM1D;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAE5B,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IAEvC,QAAQ,CAAC,YAAY,EAAE,SAAS,WAAW,EAAE,CAAC;IAE9C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACxC,CAAC;AA6BF,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,SAAS,UAAU,EAAE,GAC/B,gBAAgB,EAAE,CAsEpB"}
@@ -0,0 +1,113 @@
1
+ // Cross-reference resolution. Given all pulled IR resources, rewrite every
2
+ // RefMarker into either a code handle (when the target is also being pulled —
3
+ // the preferred form, which auto-wires the deploy dependency) or a literal
4
+ // `xxRef("uuid")` (when it isn't). SecretMarkers become `secret("NAME")` —
5
+ // core's `secret()` takes the env-var NAME, read at apply time.
6
+ // The output carries the exact import set each generated file needs.
7
+ //
8
+ // Export identifiers are assigned globally and uniquely: slugs are only unique
9
+ // per kind (and distinct slugs can camelCase identically), so a colliding
10
+ // identifier gets a deterministic numeric suffix — otherwise a folder named
11
+ // like its model would shadow it (duplicate binding / silently mis-wired
12
+ // import).
13
+ //
14
+ // Markers are replaced by `RawExpr` nodes ({ __expr }) so the printer emits them
15
+ // verbatim instead of quoting them as JSON.
16
+ import { isCallMarker, isRefMarker, isSecretMarker, KIND_META, toIdentifier, } from "./ir.js";
17
+ export function rawExpr(code) {
18
+ return { __expr: code };
19
+ }
20
+ export function isRawExpr(value) {
21
+ return (typeof value === "object" &&
22
+ value !== null &&
23
+ typeof value.__expr === "string");
24
+ }
25
+ // Relative import path from one resource file to another (each resource is its
26
+ // own `<dir>/<slug>.ts`). Same dir → "./slug"; else "../otherDir/slug".
27
+ function importPath(fromDir, toDir, toSlug) {
28
+ return fromDir === toDir ? `./${toSlug}` : `../${toDir}/${toSlug}`;
29
+ }
30
+ // One unique identifier per resource, in input order: the first taker keeps
31
+ // the plain camelCased slug, later collisions get `<identifier>2`, `…3`.
32
+ function assignIdentifiers(resources) {
33
+ const byUuid = new Map();
34
+ const used = new Set();
35
+ for (const resource of resources) {
36
+ const base = toIdentifier(resource.slug);
37
+ let identifier = base;
38
+ let n = 1;
39
+ while (used.has(identifier)) {
40
+ n += 1;
41
+ identifier = `${base}${String(n)}`;
42
+ }
43
+ used.add(identifier);
44
+ byUuid.set(resource.uuid, identifier);
45
+ }
46
+ return byUuid;
47
+ }
48
+ export function resolveResources(resources) {
49
+ const byUuid = new Map();
50
+ for (const resource of resources)
51
+ byUuid.set(resource.uuid, resource);
52
+ const identifiers = assignIdentifiers(resources);
53
+ return resources.map((resource) => {
54
+ const meta = KIND_META[resource.kind];
55
+ if (meta === undefined) {
56
+ throw new Error(`cdk pull: unsupported kind "${resource.kind}"`);
57
+ }
58
+ const cdkImports = new Set([meta.defineFn]);
59
+ const localImports = new Map();
60
+ const walk = (value) => {
61
+ if (isSecretMarker(value)) {
62
+ cdkImports.add("secret");
63
+ return rawExpr(`secret(${JSON.stringify(value.envName)})`);
64
+ }
65
+ if (isRefMarker(value)) {
66
+ const target = byUuid.get(value.uuid);
67
+ if (target !== undefined && target.uuid !== resource.uuid) {
68
+ const targetMeta = KIND_META[target.kind];
69
+ if (targetMeta !== undefined) {
70
+ const identifier = identifiers.get(target.uuid);
71
+ localImports.set(identifier, importPath(meta.dir, targetMeta.dir, target.slug));
72
+ const accessor = value.accessor === undefined ? "" : value.accessor;
73
+ return rawExpr(`${identifier}${accessor}`);
74
+ }
75
+ }
76
+ return walk(value.fallback);
77
+ }
78
+ if (isCallMarker(value)) {
79
+ cdkImports.add(value.fn);
80
+ const marker = {
81
+ __call: true,
82
+ fn: value.fn,
83
+ args: value.args.map(walk),
84
+ };
85
+ return marker;
86
+ }
87
+ if (Array.isArray(value))
88
+ return value.map(walk);
89
+ if (typeof value === "object" && value !== null) {
90
+ const out = {};
91
+ for (const [key, inner] of Object.entries(value))
92
+ out[key] = walk(inner);
93
+ return out;
94
+ }
95
+ return value;
96
+ };
97
+ const spec = walk(resource.spec);
98
+ return {
99
+ kind: resource.kind,
100
+ slug: resource.slug,
101
+ uuid: resource.uuid,
102
+ identifier: identifiers.get(resource.uuid),
103
+ defineFn: meta.defineFn,
104
+ dir: meta.dir,
105
+ singleton: meta.singleton === true,
106
+ cdkImports: [...cdkImports].sort(),
107
+ localImports: [...localImports.entries()]
108
+ .map(([identifier, from]) => ({ identifier, from }))
109
+ .sort((a, b) => a.from.localeCompare(b.from)),
110
+ spec,
111
+ };
112
+ });
113
+ }
@@ -0,0 +1,6 @@
1
+ export type ArchiveFile = {
2
+ path: string;
3
+ bytes: Uint8Array;
4
+ };
5
+ export declare function untarGz(archive: Uint8Array): ArchiveFile[];
6
+ //# sourceMappingURL=untar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"untar.d.ts","sourceRoot":"","sources":["../../../../src/deploy/pull/untar.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,WAAW,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,UAAU,CAAA;CAAE,CAAC;AA2B9D,wBAAgB,OAAO,CAAC,OAAO,EAAE,UAAU,GAAG,WAAW,EAAE,CA6D1D"}
@@ -0,0 +1,84 @@
1
+ // Minimal tar.gz extraction for pulled worker/app source archives. The backend
2
+ // builds them with archiver's tar-stream (USTAR headers, PAX extended headers
3
+ // only for >100-char paths), so a small reader covers the format: 512-byte
4
+ // header blocks, octal size, `prefix` field, and PAX `path=` overrides.
5
+ import { gunzipSync } from "node:zlib";
6
+ const BLOCK = 512;
7
+ function readString(block, offset, length) {
8
+ const slice = block.subarray(offset, offset + length);
9
+ const end = slice.indexOf(0);
10
+ return new TextDecoder().decode(end === -1 ? slice : slice.subarray(0, end));
11
+ }
12
+ function readOctal(block, offset, length) {
13
+ const text = readString(block, offset, length).trim();
14
+ return text.length === 0 ? 0 : parseInt(text, 8);
15
+ }
16
+ // Parse a PAX extended header body: lines of `<len> <key>=<value>\n`.
17
+ function paxPath(body) {
18
+ const text = new TextDecoder().decode(body);
19
+ for (const line of text.split("\n")) {
20
+ const space = line.indexOf(" ");
21
+ if (space === -1)
22
+ continue;
23
+ const entry = line.slice(space + 1);
24
+ if (entry.startsWith("path="))
25
+ return entry.slice("path=".length);
26
+ }
27
+ return undefined;
28
+ }
29
+ export function untarGz(archive) {
30
+ const tar = gunzipSync(archive);
31
+ const files = [];
32
+ let offset = 0;
33
+ let overridePath;
34
+ while (offset + BLOCK <= tar.length) {
35
+ const header = tar.subarray(offset, offset + BLOCK);
36
+ // Two all-zero blocks mark the end of the archive.
37
+ if (header.every((byte) => byte === 0))
38
+ break;
39
+ const size = readOctal(header, 124, 12);
40
+ const typeflag = String.fromCharCode(header[156] ?? 0);
41
+ const dataStart = offset + BLOCK;
42
+ const dataEnd = dataStart + size;
43
+ offset = dataStart + Math.ceil(size / BLOCK) * BLOCK;
44
+ // PAX extended header ('x') — may carry a long `path=` for the NEXT entry.
45
+ if (typeflag === "x" || typeflag === "g") {
46
+ const pathFromPax = paxPath(tar.subarray(dataStart, dataEnd));
47
+ if (typeflag === "x" && pathFromPax !== undefined) {
48
+ overridePath = pathFromPax;
49
+ }
50
+ continue;
51
+ }
52
+ // GNU long-name entry ('L') — the data IS the next entry's name.
53
+ if (typeflag === "L") {
54
+ overridePath = new TextDecoder()
55
+ .decode(tar.subarray(dataStart, dataEnd))
56
+ .replace(/\0+$/, "");
57
+ continue;
58
+ }
59
+ // Regular file ('0' or NUL); everything else (dirs, links) is skipped.
60
+ if (typeflag === "0" || typeflag === "\0") {
61
+ const name = readString(header, 0, 100);
62
+ const prefix = readString(header, 345, 155);
63
+ const rawPath = overridePath !== undefined
64
+ ? overridePath
65
+ : prefix.length > 0
66
+ ? `${prefix}/${name}`
67
+ : name;
68
+ overridePath = undefined;
69
+ // Normalize away leading ./ and /; reject traversal. The `..` check is
70
+ // segment-wise so legitimate names like `CHANGELOG..md` survive, and a
71
+ // backslash anywhere is rejected (a path separator on Windows).
72
+ const path = rawPath.replace(/^\.\//, "").replace(/^\/+/, "");
73
+ if (path.length === 0 ||
74
+ path.includes("\\") ||
75
+ path.split("/").includes("..")) {
76
+ continue;
77
+ }
78
+ files.push({ path, bytes: tar.subarray(dataStart, dataEnd) });
79
+ continue;
80
+ }
81
+ overridePath = undefined;
82
+ }
83
+ return files;
84
+ }
@@ -1,4 +1,7 @@
1
1
  import type { Api } from "@cargo-ai/api";
2
2
  import { type LiveReaders } from "./refresh.js";
3
+ export declare const VOLATILE: Set<string>;
4
+ export declare function deepOmit(value: unknown, isLeaf?: (value: unknown) => boolean): unknown;
5
+ export declare function isNotFound(error: unknown): boolean;
3
6
  export declare function liveReaders(api: Api): LiveReaders;
4
7
  //# sourceMappingURL=readers.live.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"readers.live.d.ts","sourceRoot":"","sources":["../../../src/deploy/readers.live.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAGzC,OAAO,EAA8B,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAoD5E,wBAAgB,WAAW,CAAC,GAAG,EAAE,GAAG,GAAG,WAAW,CAoUjD"}
1
+ {"version":3,"file":"readers.live.d.ts","sourceRoot":"","sources":["../../../src/deploy/readers.live.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAGzC,OAAO,EAA8B,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAO5E,eAAO,MAAM,QAAQ,aAOnB,CAAC;AAIH,wBAAgB,QAAQ,CACtB,KAAK,EAAE,OAAO,EACd,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,GACnC,OAAO,CAYT;AAMD,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAKlD;AAeD,wBAAgB,WAAW,CAAC,GAAG,EAAE,GAAG,GAAG,WAAW,CAqUjD"}
@@ -8,8 +8,9 @@
8
8
  import { fingerprint } from "./refresh.js";
9
9
  const GONE = { exists: false };
10
10
  // Keys stripped anywhere in a projection before hashing: per-resource volatile
11
- // ids and canvas coordinates that change without being user edits.
12
- const VOLATILE = new Set([
11
+ // ids and canvas coordinates that change without being user edits. Shared with
12
+ // the pull mappers, whose generated specs must hash-match this projection.
13
+ export const VOLATILE = new Set([
13
14
  "temporalScheduleWorkflowId",
14
15
  "temporalWorkflowId",
15
16
  "position",
@@ -17,15 +18,19 @@ const VOLATILE = new Set([
17
18
  "updatedAt",
18
19
  "deletedAt",
19
20
  ]);
20
- function deepOmit(value) {
21
+ // Deep-copy dropping VOLATILE keys. `isLeaf` stops descent (pull passes its
22
+ // marker guard so embedded markers ship verbatim).
23
+ export function deepOmit(value, isLeaf) {
24
+ if (isLeaf !== undefined && isLeaf(value))
25
+ return value;
21
26
  if (Array.isArray(value))
22
- return value.map(deepOmit);
27
+ return value.map((item) => deepOmit(item, isLeaf));
23
28
  if (value !== null && typeof value === "object") {
24
29
  const out = {};
25
30
  for (const [key, inner] of Object.entries(value)) {
26
31
  if (VOLATILE.has(key))
27
32
  continue;
28
- out[key] = deepOmit(inner);
33
+ out[key] = deepOmit(inner, isLeaf);
29
34
  }
30
35
  return out;
31
36
  }
@@ -34,7 +39,7 @@ function deepOmit(value) {
34
39
  function present(config) {
35
40
  return { exists: true, fingerprint: fingerprint(deepOmit(config)) };
36
41
  }
37
- function isNotFound(error) {
42
+ export function isNotFound(error) {
38
43
  const reason = error.reason;
39
44
  if (typeof reason === "string" && /notfound/i.test(reason))
40
45
  return true;
@@ -132,6 +137,7 @@ export function liveReaders(api) {
132
137
  "config",
133
138
  "schedule",
134
139
  "unification",
140
+ "additionalColumns",
135
141
  "folderUuid",
136
142
  "kind",
137
143
  "connectorUuid",
@@ -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, ModelColumns, ModelHandle, ModelSpec, UnificationColumnSpec, UnificationParentSpec, UnificationSpec, } from "./resources/model.js";
19
+ export type { ExtractorColumns, ExtractorConfigs, ExtractorSlugs, ModelAdditionalColumnSpec, ModelAdditionalColumnSpecBase, ModelColumns, ModelComputedColumnSpec, ModelCustomColumnSpec, ModelHandle, ModelLookupColumnSpec, ModelMetricColumnSpec, ModelSpec, ModelUnificationColumnSpec, ModelUnificationParentSpec, ModelUnificationSpec, } 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";
@@ -34,7 +34,7 @@ export { createWorker, OpenAPIRoute } from "@cargo-ai/worker-sdk";
34
34
  export { agentRef, defineWorkflow, defineWorkflowFromNodes, toolRef, type WorkflowFromNodes, type WorkflowResourceRef, } from "@cargo-ai/workflow-sdk";
35
35
  export type { EncryptionRef, ResourceKind, ResourceNode, SecretRef, Token, } from "./core.js";
36
36
  export { env, isSecret, isToken, resolveSecrets, secret, token, } from "./core.js";
37
- export type { AgentRef, ConnectorActionRef, ConnectorRef, DatasetRef, FolderRef, MemberRef, ModelRef, PlayRef, ResourceRef, SegmentRef, ToolRef, } from "./refs.js";
38
- export { connectorActionRef, connectorRef, datasetRef, folderRef, memberRef, modelRef, playRef, refUuid, segmentRef, } from "./refs.js";
37
+ export type { AgentRef, ConnectorActionRef, ConnectorRef, DatasetRef, FolderRef, MemberRef, ModelRef, PlayRef, RelationshipRef, ResourceRef, SegmentRef, ToolRef, WorkerRef, } from "./refs.js";
38
+ export { connectorActionRef, connectorRef, datasetRef, folderRef, memberRef, modelRef, playRef, refUuid, relationshipRef, segmentRef, workerRef, } from "./refs.js";
39
39
  export * from "./deploy/index.js";
40
40
  //# sourceMappingURL=index.d.ts.map
@@ -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,M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kB,EAClB,YAAY,EACZ,UAAU,EACV,SAAS,EACT,SAAS,EACT,QAAQ,EACR,OAAO,EACP,OAAO,EACP,eAAe,EACf,UAAU,EACV,SAAS,GACV,MAAM,WAAW,CAAC;AAGnB,cAAc,mBAAmB,CAAC"}
@@ -30,6 +30,6 @@ export { createWorker, OpenAPIRoute } from "@cargo-ai/worker-sdk";
30
30
  // types stay in `@cargo-ai/workflow-sdk`.
31
31
  export { agentRef, defineWorkflow, defineWorkflowFromNodes, toolRef, } from "@cargo-ai/workflow-sdk";
32
32
  export { env, isSecret, isToken, resolveSecrets, secret, token, } from "./core.js";
33
- export { connectorActionRef, connectorRef, datasetRef, folderRef, memberRef, modelRef, playRef, refUuid, segmentRef, } from "./refs.js";
33
+ export { connectorActionRef, connectorRef, datasetRef, folderRef, memberRef, modelRef, playRef, refUuid, relationshipRef, segmentRef, workerRef, } from "./refs.js";
34
34
  // ── deployment: plan + apply ─────────────────────────────────────────────────
35
35
  export * from "./deploy/index.js";
@@ -1,5 +1,5 @@
1
1
  import type { Token } from "./core.js";
2
- export type ResourceKindRef = "connector" | "dataset" | "model" | "folder" | "play" | "tool" | "agent" | "member" | "segment";
2
+ export type ResourceKindRef = "connector" | "dataset" | "model" | "folder" | "play" | "tool" | "agent" | "member" | "segment" | "relationship" | "worker";
3
3
  export type ResourceRef<K extends ResourceKindRef = ResourceKindRef> = {
4
4
  readonly uuid: Token | string;
5
5
  readonly resource: K;
@@ -13,6 +13,8 @@ export type ToolRef = ResourceRef<"tool">;
13
13
  export type AgentRef = ResourceRef<"agent">;
14
14
  export type MemberRef = ResourceRef<"member">;
15
15
  export type SegmentRef = ResourceRef<"segment">;
16
+ export type RelationshipRef = ResourceRef<"relationship">;
17
+ export type WorkerRef = ResourceRef<"worker">;
16
18
  /** Reference a connector by uuid (e.g. an adopted OAuth connector). */
17
19
  export declare const connectorRef: (uuid: string) => ConnectorRef;
18
20
  /** Reference a connector's auto-created dataset by uuid, for `defineModel`. */
@@ -27,6 +29,10 @@ export declare const playRef: (uuid: string) => PlayRef;
27
29
  export declare const memberRef: (uuid: string) => MemberRef;
28
30
  /** Reference a segment by uuid. */
29
31
  export declare const segmentRef: (uuid: string) => SegmentRef;
32
+ /** Reference a model relationship by uuid (e.g. for a metric column). */
33
+ export declare const relationshipRef: (uuid: string) => RelationshipRef;
34
+ /** Reference a hosting worker by uuid (e.g. a custom integration's backend). */
35
+ export declare const workerRef: (uuid: string) => WorkerRef;
30
36
  /**
31
37
  * A reference to one action of a connector (e.g. an enrichment endpoint), for an
32
38
  * agent's / MCP server's `uses`. Produced by accessing the action off a connector
@@ -1 +1 @@
1
- {"version":3,"file":"refs.d.ts","sourceRoot":"","sources":["../../src/refs.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAEvC,MAAM,MAAM,eAAe,GACvB,WAAW,GACX,SAAS,GACT,OAAO,GACP,QAAQ,GACR,MAAM,GACN,MAAM,GACN,OAAO,GACP,QAAQ,GACR,SAAS,CAAC;AAEd,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,eAAe,GAAG,eAAe,IAAI;IACrE,QAAQ,CAAC,IAAI,EAAE,KAAK,GAAG,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,WAAW,CAAC,WAAW,CAAC,CAAC;AACpD,MAAM,MAAM,UAAU,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;AAChD,MAAM,MAAM,QAAQ,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;AAC5C,MAAM,MAAM,SAAS,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;AAC9C,MAAM,MAAM,OAAO,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;AAC1C,MAAM,MAAM,OAAO,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;AAC1C,MAAM,MAAM,QAAQ,GAAG,WAAW,CAA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,sCAAsC;AACtC,eAAO,MAAM,QAAQ,SAAU,MAAM,KAAG,QAGtC,CAAC;AACH,kCAAkC;AAClC,eAAO,MAAM,SAAS,SAAU,MAAM,KAAG,SAGvC,CAAC;AACH,+EAA+E;AAC/E,eAAO,MAAM,OAAO,SAAU,MAAM,KAAG,OAAuC,CAAC;AAC/E,gFAAgF;AAChF,eAAO,MAAM,SAAS,SAAU,MAAM,KAAG,SAGvC,CAAC;AACH,mCAAmC;AACnC,eAAO,MAAM,UAAU,SAAU,MAAM,KAAG,UAGxC,CAAC;AACH,yEAAyE;AACzE,eAAO,MAAM,eAAe,SAAU,MAAM,KAAG,eAG7C,CAAC;AACH,gFAAgF;AAChF,eAAO,MAAM,SAAS,SAAU,MAAM,KAAG,SAGvC,CAAC;AAKH;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IACrC,QAAQ,CAAC,aAAa,EAAE,KAAK,GAAG,MAAM,CAAC;IACvC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,cAClB;IAAE,IAAI,EAAE,KAAK,GAAG,MAAM,CAAC;IAAC,eAAe,CAAC,EAAE,MAAM,CAAA;CAAE,cACjD,MAAM,gBACJ,MAAM,KACnB,kBAUD,CAAC;AAEH,iEAAiE;AACjE,eAAO,MAAM,OAAO,QAAS;IAAE,IAAI,EAAE,KAAK,GAAG,MAAM,CAAA;CAAE,KAAG,KAAK,GAAG,MACtD,CAAC"}
package/build/src/refs.js CHANGED
@@ -38,6 +38,16 @@ export const segmentRef = (uuid) => ({
38
38
  uuid,
39
39
  resource: "segment",
40
40
  });
41
+ /** Reference a model relationship by uuid (e.g. for a metric column). */
42
+ export const relationshipRef = (uuid) => ({
43
+ uuid,
44
+ resource: "relationship",
45
+ });
46
+ /** Reference a hosting worker by uuid (e.g. a custom integration's backend). */
47
+ export const workerRef = (uuid) => ({
48
+ uuid,
49
+ resource: "worker",
50
+ });
41
51
  /**
42
52
  * Reference a connector action by an explicit connector + action slug — the
43
53
  * escape hatch when you don't have a typed connector handle (`connector.actions.<slug>`
@@ -1,8 +1,9 @@
1
1
  import { type Token } from "../core.js";
2
+ import { type WorkerRef } from "../refs.js";
2
3
  import type { WorkerHandle } from "./worker.js";
3
4
  export type CustomIntegrationSpec = {
4
- /** The worker serving the Custom Integration HTTP contract. */
5
- worker: WorkerHandle;
5
+ /** The worker serving the Custom Integration HTTP contract — a handle or `workerRef(uuid)`. */
6
+ worker: WorkerHandle | WorkerRef;
6
7
  };
7
8
  export type CustomIntegrationHandle = {
8
9
  readonly slug: string;
@@ -1 +1 @@
1
- {"version":3,"file":"customIntegration.d.ts","sourceRoot":"","sources":["../../../src/resources/customIntegration.ts"],"names":[],"mappings":"AAKA,OAAO,EAAwB,KAAK,KAAK,EAAS,MAAM,YAAY,CAAC;AAErE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,MAAM,qBAAqB,GAAG;IAClC,+DAA+D;IAC/D,MAAM,EAAE,YAAY,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;CACtB,CAAC;AAEF,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,qBAAqB,GAC1B,uBAAuB,CAWzB"}
1
+ {"version":3,"file":"customIntegration.d.ts","sourceRoot":"","sources":["../../../src/resources/customIntegration.ts"],"names":[],"mappings":"AAKA,OAAO,EAAwB,KAAK,KAAK,EAAS,MAAM,YAAY,CAAC;AACrE,OAAO,EAAW,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,MAAM,qBAAqB,GAAG;IAClC,+FAA+F;IAC/F,MAAM,EAAE,YAAY,GAAG,SAAS,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;CACtB,CAAC;AAEF,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,qBAAqB,GAC1B,uBAAuB,CAWzB"}
@@ -1,8 +1,9 @@
1
- import type { SegmentationTypes, StorageTypes } from "@cargo-ai/types";
1
+ import type { ExpressionTypes, SegmentationTypes, StorageTypes } from "@cargo-ai/types";
2
2
  import { type Token } from "../core.js";
3
- import { type DatasetRef, type FolderRef, type ModelRef } from "../refs.js";
3
+ import { type DatasetRef, type FolderRef, type ModelRef, type RelationshipRef } from "../refs.js";
4
4
  import type { ConnectorHandle } from "./connector.js";
5
5
  import type { FolderHandle } from "./folder.js";
6
+ import type { RelationshipHandle } from "./relationship.js";
6
7
  export type ScheduleSpec = {
7
8
  type: "cron";
8
9
  cron: string;
@@ -10,11 +11,11 @@ export type ScheduleSpec = {
10
11
  type: "dbt";
11
12
  jobId: string;
12
13
  };
13
- export type UnificationColumnSpec = {
14
+ export type ModelUnificationColumnSpec = {
14
15
  slug: string;
15
16
  reference: string;
16
17
  };
17
- export type UnificationParentSpec = {
18
+ export type ModelUnificationParentSpec = {
18
19
  kind: "model";
19
20
  columnSlug: string;
20
21
  parent: ModelHandle | ModelRef;
@@ -23,20 +24,60 @@ export type UnificationParentSpec = {
23
24
  columnSlug: string;
24
25
  reference: string;
25
26
  };
26
- export type UnificationSpec = {
27
+ export type ModelUnificationSpec = {
27
28
  source: "integration";
28
29
  } | {
29
30
  source: "custom";
30
31
  type: StorageTypes.ModelUnificationType;
31
- uniqueColumns: UnificationColumnSpec[];
32
+ uniqueColumns: ModelUnificationColumnSpec[];
32
33
  /** Columns exposed on the unified model (defaults to all). */
33
34
  selectedColumnSlugs?: string[];
34
35
  /** Column carrying the event timestamp (event unification types only). */
35
36
  timeColumnSlug?: string;
36
- parent?: UnificationParentSpec;
37
+ parent?: ModelUnificationParentSpec;
37
38
  /** Restrict which rows take part in unification (defaults to all rows). */
38
39
  filter?: SegmentationTypes.Filter;
39
40
  };
41
+ export type ModelAdditionalColumnSpecBase = {
42
+ slug: string;
43
+ type: StorageTypes.ColumnType;
44
+ /** Display name. Defaults to the title-cased slug. */
45
+ label?: string;
46
+ description?: string;
47
+ properties?: string[];
48
+ };
49
+ /** A manually-filled column (values written per record, no formula). */
50
+ export type ModelCustomColumnSpec = ModelAdditionalColumnSpecBase & {
51
+ kind: "custom";
52
+ };
53
+ /** A formula column evaluated per record. */
54
+ export type ModelComputedColumnSpec = ModelAdditionalColumnSpecBase & {
55
+ kind: "computed";
56
+ expression: ExpressionTypes.Expression;
57
+ columnsUsed?: string[];
58
+ };
59
+ /** An aggregation over the records a relationship joins to. */
60
+ export type ModelMetricColumnSpec = ModelAdditionalColumnSpecBase & {
61
+ kind: "metric";
62
+ relationship: RelationshipHandle | RelationshipRef;
63
+ aggregation: {
64
+ function: StorageTypes.AggregationFunction;
65
+ columnSlug: string;
66
+ };
67
+ filter?: SegmentationTypes.Filter;
68
+ };
69
+ /** A value copied from a matching record of another model. */
70
+ export type ModelLookupColumnSpec = ModelAdditionalColumnSpecBase & {
71
+ kind: "lookup";
72
+ join: {
73
+ model: ModelHandle | ModelRef;
74
+ fromColumnSlug: string;
75
+ toColumnSlug: string;
76
+ };
77
+ extractColumnSlug: string;
78
+ filter?: SegmentationTypes.Filter;
79
+ };
80
+ export type ModelAdditionalColumnSpec = ModelCustomColumnSpec | ModelComputedColumnSpec | ModelMetricColumnSpec | ModelLookupColumnSpec;
40
81
  export interface ExtractorConfigs {
41
82
  }
42
83
  type ExtractorConfigFor<S extends string, E extends string> = S extends keyof ExtractorConfigs ? E extends keyof ExtractorConfigs[S] ? ExtractorConfigs[S][E] : Record<string, unknown> : Record<string, unknown>;
@@ -45,11 +86,18 @@ export interface ExtractorSlugs {
45
86
  type ExtractorSlugFor<S extends string> = S extends keyof ExtractorSlugs ? ExtractorSlugs[S] & string : string;
46
87
  export interface ModelColumns {
47
88
  }
48
- type ModelColumnsAccessor<Slug extends string> = Slug extends keyof ModelColumns ? {
89
+ export interface ExtractorColumns {
90
+ }
91
+ type ExtractorColumnsFor<S extends string, E extends string> = S extends keyof ExtractorColumns ? E extends keyof ExtractorColumns[S] ? ExtractorColumns[S][E] & string : never : never;
92
+ type ModelColumnsAccessor<Slug extends string, S extends string, E extends string> = Slug extends keyof ModelColumns ? {
49
93
  readonly [C in ModelColumns[Slug] & string]: C;
50
94
  } & {
51
95
  readonly [columnSlug: string]: string;
96
+ } : [ExtractorColumnsFor<S, E>] extends [never] ? {
97
+ readonly [columnSlug: string]: string;
52
98
  } : {
99
+ readonly [C in ExtractorColumnsFor<S, E>]: C;
100
+ } & {
53
101
  readonly [columnSlug: string]: string;
54
102
  };
55
103
  type LiteralUnion<T extends string> = T | (string & {});
@@ -74,16 +122,23 @@ export type ModelSpec<S extends string = string, E extends LiteralUnion<Extracto
74
122
  * via an update once the model exists, so it also covers models the deploy
75
123
  * adopts.
76
124
  */
77
- unification?: UnificationSpec;
125
+ unification?: ModelUnificationSpec;
126
+ /**
127
+ * Columns added on top of the extracted schema (custom / computed / metric /
128
+ * lookup). When declared, the list is authoritative: deploy creates missing
129
+ * columns, updates changed ones, and removes additional columns no longer
130
+ * listed. Omit to leave the model's live additional columns untouched.
131
+ */
132
+ additionalColumns?: ModelAdditionalColumnSpec[];
78
133
  };
79
- export type ModelHandle<Slug extends string = string> = {
134
+ export type ModelHandle<Slug extends string = string, S extends string = string, E extends string = string> = {
80
135
  readonly slug: string;
81
136
  readonly uuid: Token;
82
137
  readonly resource: "model";
83
138
  /** This model's columns — `model.columns.<columnSlug>` yields the slug
84
139
  * string, for relationships, unification, and segment column lists. */
85
- readonly columns: ModelColumnsAccessor<Slug>;
140
+ readonly columns: ModelColumnsAccessor<Slug, S, E>;
86
141
  };
87
- export declare function defineModel<Slug extends string, S extends string, E extends LiteralUnion<ExtractorSlugFor<S>>>(slug: Slug, spec: ModelSpec<S, E>): ModelHandle<Slug>;
142
+ 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>;
88
143
  export {};
89
144
  //# sourceMappingURL=model.d.ts.map