@cargo-ai/cdk 1.0.2 → 1.0.4

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 (96) hide show
  1. package/README.md +65 -36
  2. package/build/src/cli/auth.d.ts +9 -0
  3. package/build/src/cli/auth.d.ts.map +1 -0
  4. package/build/src/cli/auth.js +100 -0
  5. package/build/src/cli/bin.d.ts +3 -0
  6. package/build/src/cli/bin.d.ts.map +1 -0
  7. package/build/src/cli/bin.js +9 -0
  8. package/build/src/cli/commands/deploy.d.ts +4 -0
  9. package/build/src/cli/commands/deploy.d.ts.map +1 -0
  10. package/build/src/cli/commands/deploy.js +531 -0
  11. package/build/src/cli/commands/index.d.ts +4 -0
  12. package/build/src/cli/commands/index.d.ts.map +1 -0
  13. package/build/src/cli/commands/index.js +11 -0
  14. package/build/src/cli/commands/init.d.ts +3 -0
  15. package/build/src/cli/commands/init.d.ts.map +1 -0
  16. package/build/src/cli/commands/init.js +76 -0
  17. package/build/src/cli/commands/inputTypes.d.ts +24 -0
  18. package/build/src/cli/commands/inputTypes.d.ts.map +1 -0
  19. package/build/src/cli/commands/inputTypes.js +273 -0
  20. package/build/src/cli/commands/templates.d.ts +6 -0
  21. package/build/src/cli/commands/templates.d.ts.map +1 -0
  22. package/build/src/cli/commands/templates.js +33 -0
  23. package/build/src/cli/commands/types.d.ts +4 -0
  24. package/build/src/cli/commands/types.d.ts.map +1 -0
  25. package/build/src/cli/commands/types.js +385 -0
  26. package/build/src/cli/deployCommands.d.ts +4 -0
  27. package/build/src/cli/deployCommands.d.ts.map +1 -0
  28. package/build/src/cli/deployCommands.js +531 -0
  29. package/build/src/cli/index.d.ts +4 -0
  30. package/build/src/cli/index.d.ts.map +1 -0
  31. package/build/src/cli/index.js +20 -0
  32. package/build/src/cli/initCommand.d.ts +3 -0
  33. package/build/src/cli/initCommand.d.ts.map +1 -0
  34. package/build/src/cli/initCommand.js +76 -0
  35. package/build/src/cli/inputTypes.d.ts +24 -0
  36. package/build/src/cli/inputTypes.d.ts.map +1 -0
  37. package/build/src/cli/inputTypes.js +273 -0
  38. package/build/src/cli/io.d.ts +38 -0
  39. package/build/src/cli/io.d.ts.map +1 -0
  40. package/build/src/cli/io.js +226 -0
  41. package/build/src/cli/templates.d.ts +6 -0
  42. package/build/src/cli/templates.d.ts.map +1 -0
  43. package/build/src/cli/templates.js +34 -0
  44. package/build/src/cli/typesCommand.d.ts +4 -0
  45. package/build/src/cli/typesCommand.d.ts.map +1 -0
  46. package/build/src/cli/typesCommand.js +385 -0
  47. package/build/src/cli/version.d.ts +2 -0
  48. package/build/src/cli/version.d.ts.map +1 -0
  49. package/build/src/cli/version.js +25 -0
  50. package/build/src/core.d.ts +1 -1
  51. package/build/src/core.d.ts.map +1 -1
  52. package/build/src/deploy/apply.d.ts +3 -0
  53. package/build/src/deploy/apply.d.ts.map +1 -1
  54. package/build/src/deploy/apply.js +2 -0
  55. package/build/src/deploy/destroy.d.ts.map +1 -1
  56. package/build/src/deploy/destroy.js +6 -0
  57. package/build/src/deploy/executors.live.d.ts.map +1 -1
  58. package/build/src/deploy/executors.live.js +49 -3
  59. package/build/src/deploy/readers.live.d.ts.map +1 -1
  60. package/build/src/deploy/readers.live.js +16 -0
  61. package/build/src/index.d.ts +4 -2
  62. package/build/src/index.d.ts.map +1 -1
  63. package/build/src/index.js +2 -1
  64. package/build/src/refs.d.ts +4 -1
  65. package/build/src/refs.d.ts.map +1 -1
  66. package/build/src/refs.js +5 -0
  67. package/build/src/resources/bundle.d.ts +4 -2
  68. package/build/src/resources/bundle.d.ts.map +1 -1
  69. package/build/src/resources/bundle.js +11 -2
  70. package/build/src/resources/connector.d.ts.map +1 -1
  71. package/build/src/resources/connector.js +3 -2
  72. package/build/src/resources/segment.d.ts +24 -0
  73. package/build/src/resources/segment.d.ts.map +1 -0
  74. package/build/src/resources/segment.js +34 -0
  75. package/build/src/resources/worker.d.ts.map +1 -1
  76. package/build/src/resources/worker.js +14 -7
  77. package/build/tsconfig.tsbuildinfo +1 -1
  78. package/package.json +14 -4
  79. package/templates/blank/package.json +3 -3
  80. package/templates/full/README.md +21 -20
  81. package/templates/full/apps/dashboard/index.html +1 -1
  82. package/templates/full/apps/dashboard/package.json +18 -3
  83. package/templates/full/apps/dashboard/src/App.tsx +57 -0
  84. package/templates/full/apps/dashboard/src/index.css +4 -0
  85. package/templates/full/apps/dashboard/src/main.tsx +13 -7
  86. package/templates/full/apps/dashboard/tailwind.config.ts +13 -0
  87. package/templates/full/apps/dashboard/tsconfig.json +10 -3
  88. package/templates/full/apps/dashboard/vite.config.ts +22 -0
  89. package/templates/full/package.json +3 -3
  90. package/templates/full/workers/webhook/package.json +12 -1
  91. package/templates/full/workers/webhook/src/index.ts +53 -0
  92. package/templates/full/workers/webhook/tsconfig.json +14 -0
  93. package/templates/full/workers/webhook.ts +9 -7
  94. package/templates/full/apps/dashboard/package-lock.json +0 -1080
  95. package/templates/full/workers/webhook/index.js +0 -12
  96. package/templates/full/workers/webhook/package-lock.json +0 -12
@@ -16,6 +16,7 @@ export { defineFolder } from "./resources/folder.js";
16
16
  export { defineMcpServer } from "./resources/mcpServer.js";
17
17
  export { defineModel } from "./resources/model.js";
18
18
  export { definePlay } from "./resources/play.js";
19
+ export { defineSegment } from "./resources/segment.js";
19
20
  export { defineTerritory } from "./resources/territory.js";
20
21
  export { defineTool } from "./resources/tool.js";
21
22
  export { defineWorker } from "./resources/worker.js";
@@ -27,6 +28,6 @@ export { createWorker, OpenAPIRoute } from "@cargo-ai/worker-sdk";
27
28
  // types stay in `@cargo-ai/workflow-sdk`.
28
29
  export { agentRef, defineWorkflow, toolRef, } from "@cargo-ai/workflow-sdk";
29
30
  export { env, isSecret, isToken, resolveSecrets, secret, token, } from "./core.js";
30
- export { connectorRef, datasetRef, folderRef, memberRef, modelRef, playRef, refUuid, } from "./refs.js";
31
+ export { connectorRef, datasetRef, folderRef, memberRef, modelRef, playRef, refUuid, segmentRef, } from "./refs.js";
31
32
  // ── deployment: plan + apply ─────────────────────────────────────────────────
32
33
  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";
2
+ export type ResourceKindRef = "connector" | "dataset" | "model" | "folder" | "play" | "tool" | "agent" | "member" | "segment";
3
3
  export type ResourceRef<K extends ResourceKindRef = ResourceKindRef> = {
4
4
  readonly uuid: Token | string;
5
5
  readonly resource: K;
@@ -12,6 +12,7 @@ export type PlayRef = ResourceRef<"play">;
12
12
  export type ToolRef = ResourceRef<"tool">;
13
13
  export type AgentRef = ResourceRef<"agent">;
14
14
  export type MemberRef = ResourceRef<"member">;
15
+ export type SegmentRef = ResourceRef<"segment">;
15
16
  /** Reference a connector by uuid (e.g. an adopted OAuth connector). */
16
17
  export declare const connectorRef: (uuid: string) => ConnectorRef;
17
18
  /** Reference a connector's auto-created dataset by uuid, for `defineModel`. */
@@ -24,6 +25,8 @@ export declare const folderRef: (uuid: string) => FolderRef;
24
25
  export declare const playRef: (uuid: string) => PlayRef;
25
26
  /** Reference a workspace member (user) by uuid — for territories/capacities. */
26
27
  export declare const memberRef: (uuid: string) => MemberRef;
28
+ /** Reference a segment by uuid. */
29
+ export declare const segmentRef: (uuid: string) => SegmentRef;
27
30
  /** Extract the uuid from a handle or ref (both carry `uuid`). */
28
31
  export declare const refUuid: (ref: {
29
32
  uuid: Token | string;
@@ -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,CAAC;AAEb,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,eAAe,GAAG,eAAe,IAAI;IACrE,QAA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AAuC,CAAC;AAC/E,gFAAgF;AAChF,eAAO,MAAM,SAAS,SAAU,MAAM,KAAG,SAGvC,CAAC;AACH,mCAAmC;AACnC,eAAO,MAAM,UAAU,SAAU,MAAM,KAAG,UAGxC,CAAC;AAKH,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
@@ -33,6 +33,11 @@ export const memberRef = (uuid) => ({
33
33
  uuid,
34
34
  resource: "member",
35
35
  });
36
+ /** Reference a segment by uuid. */
37
+ export const segmentRef = (uuid) => ({
38
+ uuid,
39
+ resource: "segment",
40
+ });
36
41
  // `toolRef` / `agentRef` are re-exported from `@cargo-ai/workflow-sdk` — their
37
42
  // `WorkflowResourceRef` is structurally a `ResourceRef<"tool" | "agent">`.
38
43
  /** Extract the uuid from a handle or ref (both carry `uuid`). */
@@ -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;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAAE,GACjB,IAAI,CAYN;AAED,4EAA4E;AAC5E,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAS/C"}
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":"AAWA,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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AAC;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 by slug the
10
- // escape hatch for OAuth integrations whose tokens can't live in a repo.
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);
@@ -0,0 +1,24 @@
1
+ import type { SegmentationTypes } from "@cargo-ai/types";
2
+ import { type Token } from "../core.js";
3
+ import { type ModelRef } from "../refs.js";
4
+ import type { ModelHandle } from "./model.js";
5
+ export type SegmentSpec = {
6
+ name?: string;
7
+ /** The data model this segment filters — a model handle or `modelRef` (fixed at create). */
8
+ model: ModelHandle | ModelRef;
9
+ /** Which records the segment includes. */
10
+ filter: SegmentationTypes.Filter;
11
+ sort?: SegmentationTypes.Sort;
12
+ limit?: number;
13
+ /** Columns whose changes are tracked (for the segment's change feed). */
14
+ trackingColumnSlugs?: string[];
15
+ /** Columns the segment exposes (defaults to all). */
16
+ columnSlugs?: string[];
17
+ };
18
+ export type SegmentHandle = {
19
+ readonly slug: string;
20
+ readonly uuid: Token;
21
+ readonly resource: "segment";
22
+ };
23
+ export declare function defineSegment(slug: string, spec: SegmentSpec): SegmentHandle;
24
+ //# sourceMappingURL=segment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"segment.d.ts","sourceRoot":"","sources":["../../../src/resources/segment.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,EAAwB,KAAK,KAAK,EAAS,MAAM,YAAY,CAAC;AACrE,OAAO,EAAE,KAAK,QAAQ,EAAW,MAAM,YAAY,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,4FAA4F;IAC5F,KAAK,EAAE,WAAW,GAAG,QAAQ,CAAC;IAC9B,0CAA0C;IAC1C,MAAM,EAAE,iBAAiB,CAAC,MAAM,CAAC;IACjC,IAAI,CAAC,EAAE,iBAAiB,CAAC,IAAI,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yEAAyE;IACzE,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC/B,qDAAqD;IACrD,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;CAC9B,CAAC;AAEF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,aAAa,CAqB5E"}
@@ -0,0 +1,34 @@
1
+ // defineSegment — a segmentation segment: a named, filtered view of a data model
2
+ // (the records matching a filter, optionally sorted, limited, and column-scoped).
3
+ // References its `model` by handle. The server derives the segment's own slug from
4
+ // its name, so it's state-tracked and adopted by name. The model is fixed at
5
+ // create. Compiles to the segmentation `CreateSegmentPayload`.
6
+ import { register, resourceId, token } from "../core.js";
7
+ import { refUuid } from "../refs.js";
8
+ export function defineSegment(slug, spec) {
9
+ const id = resourceId("segment", slug);
10
+ register({
11
+ id,
12
+ kind: "segment",
13
+ slug,
14
+ spec: {
15
+ slug,
16
+ name: spec.name === undefined ? toTitle(slug) : spec.name,
17
+ modelUuid: refUuid(spec.model),
18
+ filter: spec.filter,
19
+ sort: spec.sort === undefined ? null : spec.sort,
20
+ limit: spec.limit === undefined ? null : spec.limit,
21
+ trackingColumnSlugs: spec.trackingColumnSlugs === undefined
22
+ ? null
23
+ : spec.trackingColumnSlugs,
24
+ columnSlugs: spec.columnSlugs === undefined ? null : spec.columnSlugs,
25
+ },
26
+ });
27
+ return { slug, uuid: token(id, "uuid"), resource: "segment" };
28
+ }
29
+ function toTitle(slug) {
30
+ return slug
31
+ .split(/[-_]/)
32
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
33
+ .join(" ");
34
+ }
@@ -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;AAWhD,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"}
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 built entry
9
- // (esbuild bundles it no TS transpile), a manifest, and an npm-ci'able project.
10
- const WORKER_REQUIRED = [
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",