@cargo-ai/cdk 1.0.3 → 1.0.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 +64 -35
- package/build/src/cli/auth.d.ts +9 -0
- package/build/src/cli/auth.d.ts.map +1 -0
- package/build/src/cli/auth.js +100 -0
- package/build/src/cli/bin.d.ts +3 -0
- package/build/src/cli/bin.d.ts.map +1 -0
- package/build/src/cli/bin.js +9 -0
- package/build/src/cli/commands/deploy.d.ts +4 -0
- package/build/src/cli/commands/deploy.d.ts.map +1 -0
- package/build/src/cli/commands/deploy.js +531 -0
- package/build/src/cli/commands/index.d.ts +4 -0
- package/build/src/cli/commands/index.d.ts.map +1 -0
- package/build/src/cli/commands/index.js +11 -0
- package/build/src/cli/commands/init.d.ts +3 -0
- package/build/src/cli/commands/init.d.ts.map +1 -0
- package/build/src/cli/commands/init.js +76 -0
- package/build/src/cli/commands/inputTypes.d.ts +24 -0
- package/build/src/cli/commands/inputTypes.d.ts.map +1 -0
- package/build/src/cli/commands/inputTypes.js +273 -0
- package/build/src/cli/commands/templates.d.ts +6 -0
- package/build/src/cli/commands/templates.d.ts.map +1 -0
- package/build/src/cli/commands/templates.js +33 -0
- package/build/src/cli/commands/types.d.ts +4 -0
- package/build/src/cli/commands/types.d.ts.map +1 -0
- package/build/src/cli/commands/types.js +385 -0
- package/build/src/cli/index.d.ts +4 -0
- package/build/src/cli/index.d.ts.map +1 -0
- package/build/src/cli/index.js +20 -0
- package/build/src/cli/io.d.ts +38 -0
- package/build/src/cli/io.d.ts.map +1 -0
- package/build/src/cli/io.js +226 -0
- package/build/src/cli/version.d.ts +2 -0
- package/build/src/cli/version.d.ts.map +1 -0
- package/build/src/cli/version.js +25 -0
- package/build/src/deploy/executors.live.d.ts.map +1 -1
- package/build/src/deploy/executors.live.js +15 -3
- package/build/src/resources/bundle.d.ts +4 -2
- package/build/src/resources/bundle.d.ts.map +1 -1
- package/build/src/resources/bundle.js +11 -2
- package/build/src/resources/connector.d.ts.map +1 -1
- package/build/src/resources/connector.js +3 -2
- package/build/src/resources/worker.d.ts.map +1 -1
- package/build/src/resources/worker.js +14 -7
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +14 -4
- package/templates/blank/package.json +3 -3
- package/templates/full/README.md +21 -20
- package/templates/full/apps/dashboard/index.html +1 -1
- package/templates/full/apps/dashboard/package.json +18 -3
- package/templates/full/apps/dashboard/src/App.tsx +57 -0
- package/templates/full/apps/dashboard/src/index.css +4 -0
- package/templates/full/apps/dashboard/src/main.tsx +13 -7
- package/templates/full/apps/dashboard/tailwind.config.ts +13 -0
- package/templates/full/apps/dashboard/tsconfig.json +10 -3
- package/templates/full/apps/dashboard/vite.config.ts +22 -0
- package/templates/full/package.json +3 -3
- package/templates/full/workers/webhook/package.json +12 -1
- package/templates/full/workers/webhook/src/index.ts +53 -0
- package/templates/full/workers/webhook/tsconfig.json +14 -0
- package/templates/full/workers/webhook.ts +9 -7
- package/templates/full/apps/dashboard/package-lock.json +0 -1080
- package/templates/full/workers/webhook/index.js +0 -12
- package/templates/full/workers/webhook/package-lock.json +0 -12
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../src/cli/version.ts"],"names":[],"mappings":"AAOA,wBAAgB,cAAc,IAAI,MAAM,CAkBvC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
// Read this package's version by walking up to the nearest `@cargo-ai/cdk`
|
|
5
|
+
// package.json — a walk (not a fixed relative path) so it's independent of build
|
|
6
|
+
// layout depth.
|
|
7
|
+
export function packageVersion() {
|
|
8
|
+
let cursor = dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
for (let i = 0; i < 8; i += 1) {
|
|
10
|
+
try {
|
|
11
|
+
const pkg = JSON.parse(readFileSync(join(cursor, "package.json"), "utf-8"));
|
|
12
|
+
if (pkg.name === "@cargo-ai/cdk" && typeof pkg.version === "string") {
|
|
13
|
+
return pkg.version;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
// no package.json here (or unreadable) — keep walking up
|
|
18
|
+
}
|
|
19
|
+
const parent = dirname(cursor);
|
|
20
|
+
if (parent === cursor)
|
|
21
|
+
break;
|
|
22
|
+
cursor = parent;
|
|
23
|
+
}
|
|
24
|
+
return "0.0.0";
|
|
25
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executors.live.d.ts","sourceRoot":"","sources":["../../../src/deploy/executors.live.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"executors.live.d.ts","sourceRoot":"","sources":["../../../src/deploy/executors.live.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAIzC,OAAO,KAAK,EAAE,SAAS,EAAW,MAAM,YAAY,CAAC;AA4BrD,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,SAAS,CA4qBjD"}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
// Each executor receives the token-resolved spec (real uuids in place of tokens)
|
|
3
3
|
// and the prior state entry, and decides: prior uuid → update; else (connector/
|
|
4
4
|
// model, which have addressable slugs) exists-by-slug → adopt; else create.
|
|
5
|
+
// Explicit connector adopt (`adopt: true`) links the integration's default
|
|
6
|
+
// connector first, falling back to a slug match.
|
|
5
7
|
//
|
|
6
8
|
// This is the only file that imports @cargo-ai/api. Workspace is implicit — the
|
|
7
9
|
// authenticated client already sends the selected-workspace-uuid header.
|
|
@@ -61,15 +63,25 @@ export function liveExecutors(api) {
|
|
|
61
63
|
}
|
|
62
64
|
return out;
|
|
63
65
|
}
|
|
64
|
-
const
|
|
66
|
+
const explicitAdopt = spec["adopt"] === true;
|
|
67
|
+
const adopt = explicitAdopt ||
|
|
65
68
|
(await api.connection.connector.existsBySlug({ slug })).exists;
|
|
66
69
|
if (adopt) {
|
|
67
70
|
const { connectors } = await api.connection.connector.list({
|
|
68
71
|
integrationSlug,
|
|
69
72
|
});
|
|
70
|
-
|
|
73
|
+
// Explicit adopt (the OAuth escape hatch) links whatever connector the
|
|
74
|
+
// workspace already treats as default for this integration, falling back
|
|
75
|
+
// to a slug match. Implicit adopt (a same-slug connector already exists)
|
|
76
|
+
// recovers that exact slot, so it stays a strict slug match.
|
|
77
|
+
const found = explicitAdopt
|
|
78
|
+
? (connectors.find((c) => c.isDefault === true) ??
|
|
79
|
+
connectors.find((c) => c.slug === slug))
|
|
80
|
+
: connectors.find((c) => c.slug === slug);
|
|
71
81
|
if (found === undefined) {
|
|
72
|
-
throw new Error(
|
|
82
|
+
throw new Error(explicitAdopt
|
|
83
|
+
? `no connector found to adopt for integration "${integrationSlug}"`
|
|
84
|
+
: `connector "${slug}" reported to exist but was not found`);
|
|
73
85
|
}
|
|
74
86
|
// Mark as adopted — the CDK linked an existing connector it didn't
|
|
75
87
|
// create, so destroy must release it rather than delete it.
|
|
@@ -7,9 +7,11 @@ export declare function readBundle(root: string): SourceFile[];
|
|
|
7
7
|
/**
|
|
8
8
|
* Fail at define time (not after a multi-minute server build) when a worker/app
|
|
9
9
|
* bundle is missing a file the hosting build requires. `label` names the kind in
|
|
10
|
-
* the error message.
|
|
10
|
+
* the error message. When `anyOf` is provided, at least one of those files must
|
|
11
|
+
* also exist — used for entrypoints that may live at more than one path (e.g. a
|
|
12
|
+
* worker's `src/index.ts` TS source or a pre-built `index.js`).
|
|
11
13
|
*/
|
|
12
|
-
export declare function assertBundleFiles(root: string, label: string, required: string[]): void;
|
|
14
|
+
export declare function assertBundleFiles(root: string, label: string, required: string[], anyOf?: string[]): void;
|
|
13
15
|
/** A content hash over the whole bundle — changes when any file changes. */
|
|
14
16
|
export declare function bundleHash(root: string): string;
|
|
15
17
|
//# sourceMappingURL=bundle.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../../src/resources/bundle.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,UAAU,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAmB3D,0EAA0E;AAC1E,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,CAOrD;AAED
|
|
1
|
+
{"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../../src/resources/bundle.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,UAAU,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAmB3D,0EAA0E;AAC1E,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,CAOrD;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAAE,EAClB,KAAK,CAAC,EAAE,MAAM,EAAE,GACf,IAAI,CAqBN;AAED,4EAA4E;AAC5E,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAS/C"}
|
|
@@ -35,9 +35,11 @@ export function readBundle(root) {
|
|
|
35
35
|
/**
|
|
36
36
|
* Fail at define time (not after a multi-minute server build) when a worker/app
|
|
37
37
|
* bundle is missing a file the hosting build requires. `label` names the kind in
|
|
38
|
-
* the error message.
|
|
38
|
+
* the error message. When `anyOf` is provided, at least one of those files must
|
|
39
|
+
* also exist — used for entrypoints that may live at more than one path (e.g. a
|
|
40
|
+
* worker's `src/index.ts` TS source or a pre-built `index.js`).
|
|
39
41
|
*/
|
|
40
|
-
export function assertBundleFiles(root, label, required) {
|
|
42
|
+
export function assertBundleFiles(root, label, required, anyOf) {
|
|
41
43
|
const base = isAbsolute(root) ? root : resolve(process.cwd(), root);
|
|
42
44
|
if (!existsSync(base)) {
|
|
43
45
|
throw new Error(`${label} code path not found: ${base}`);
|
|
@@ -47,6 +49,13 @@ export function assertBundleFiles(root, label, required) {
|
|
|
47
49
|
throw new Error(`${label} bundle at "${root}" is missing required file(s): ${missing.join(", ")}. ` +
|
|
48
50
|
`A ${label} bundle must contain ${required.join(", ")} at its root.`);
|
|
49
51
|
}
|
|
52
|
+
if (anyOf !== undefined && anyOf.length > 0) {
|
|
53
|
+
const hasEntrypoint = anyOf.some((file) => existsSync(join(base, file)));
|
|
54
|
+
if (!hasEntrypoint) {
|
|
55
|
+
throw new Error(`${label} bundle at "${root}" is missing an entrypoint. ` +
|
|
56
|
+
`Expected one of: ${anyOf.join(", ")}.`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
50
59
|
}
|
|
51
60
|
/** A content hash over the whole bundle — changes when any file changes. */
|
|
52
61
|
export function bundleHash(root) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connector.d.ts","sourceRoot":"","sources":["../../../src/resources/connector.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"connector.d.ts","sourceRoot":"","sources":["../../../src/resources/connector.ts"],"names":[],"mappings":"AAYA,OAAO,EAAwB,KAAK,KAAK,EAAS,MAAM,YAAY,CAAC;AAErE,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,KAAK,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAC3C,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC;CAC9B,CAAC;AAQF,MAAM,WAAW,gBAAgB;CAAG;AAEpC,KAAK,kBAAkB,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,MAAM,gBAAgB,GACxE,gBAAgB,CAAC,CAAC,CAAC,GACnB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE5B,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI;IACrD,WAAW,EAAE,CAAC,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC;IAC/B,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI;IACvD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,eAAe,EAAE,CAAC,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,WAAW,EAAE,KAAK,CAAC;IAC5B;;mEAE+D;IAC/D,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;CAChC,CAAC;AAEF,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,EAC9C,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,GACrB,eAAe,CAAC,CAAC,CAAC,CAuBpB"}
|
|
@@ -6,8 +6,9 @@
|
|
|
6
6
|
// slug is known at define time, so it's a plain value on the handle.
|
|
7
7
|
//
|
|
8
8
|
// Two modes: create (config-based integrations, secrets via env) or adopt
|
|
9
|
-
// (`adopt: true`) to link an already-authenticated connector
|
|
10
|
-
//
|
|
9
|
+
// (`adopt: true`) to link an already-authenticated connector — the escape hatch
|
|
10
|
+
// for OAuth integrations whose tokens can't live in a repo. Adopt links the
|
|
11
|
+
// integration's default connector first, falling back to a slug match.
|
|
11
12
|
import { register, resourceId, token } from "../core.js";
|
|
12
13
|
export function defineConnector(slug, spec) {
|
|
13
14
|
const id = resourceId("connector", slug);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../../src/resources/worker.ts"],"names":[],"mappings":"AAKA,OAAO,EAAwB,KAAK,KAAK,EAAS,MAAM,YAAY,CAAC;AACrE,OAAO,EAAE,KAAK,SAAS,EAAW,MAAM,YAAY,CAAC;AAErD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../../src/resources/worker.ts"],"names":[],"mappings":"AAKA,OAAO,EAAwB,KAAK,KAAK,EAAS,MAAM,YAAY,CAAC;AACrE,OAAO,EAAE,KAAK,SAAS,EAAW,MAAM,YAAY,CAAC;AAErD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAmBhD,MAAM,MAAM,UAAU,GAAG;IACvB,wEAAwE;IACxE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,2DAA2D;IAC3D,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC;CACrB,CAAC;AAEF,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,YAAY,CAkBzE"}
|
|
@@ -5,17 +5,24 @@
|
|
|
5
5
|
import { register, resourceId, token } from "../core.js";
|
|
6
6
|
import { refUuid } from "../refs.js";
|
|
7
7
|
import { assertBundleFiles, bundleHash } from "./bundle.js";
|
|
8
|
-
// Files the hosting worker build requires at the bundle root: a
|
|
9
|
-
//
|
|
10
|
-
|
|
8
|
+
// Files the hosting worker build always requires at the bundle root: a manifest
|
|
9
|
+
// and an npm-ci'able project. Like an app, a worker is uploaded as *source* and
|
|
10
|
+
// built server-side — the hosting build runs `npm ci` then esbuilds the
|
|
11
|
+
// entrypoint (esbuild transpiles TypeScript natively).
|
|
12
|
+
const WORKER_REQUIRED = ["manifest.json", "package.json", "package-lock.json"];
|
|
13
|
+
// The entrypoint may be authored in TypeScript (`src/index.ts`) — the same way
|
|
14
|
+
// an app ships `src/main.tsx` and is built with Vite — or shipped pre-built as
|
|
15
|
+
// `index.js`. At least one of these must exist; the hosting build resolves them
|
|
16
|
+
// in this order.
|
|
17
|
+
const WORKER_ENTRYPOINTS = [
|
|
18
|
+
"src/index.ts",
|
|
19
|
+
"src/index.js",
|
|
20
|
+
"index.ts",
|
|
11
21
|
"index.js",
|
|
12
|
-
"manifest.json",
|
|
13
|
-
"package.json",
|
|
14
|
-
"package-lock.json",
|
|
15
22
|
];
|
|
16
23
|
export function defineWorker(slug, spec) {
|
|
17
24
|
const id = resourceId("worker", slug);
|
|
18
|
-
assertBundleFiles(spec.path, "worker", WORKER_REQUIRED);
|
|
25
|
+
assertBundleFiles(spec.path, "worker", WORKER_REQUIRED, WORKER_ENTRYPOINTS);
|
|
19
26
|
register({
|
|
20
27
|
id,
|
|
21
28
|
kind: "worker",
|