@prisma/compute-sdk 0.1.0

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/README.md +638 -0
  2. package/dist/api-client.d.ts +181 -0
  3. package/dist/api-client.d.ts.map +1 -0
  4. package/dist/api-client.js +193 -0
  5. package/dist/api-client.js.map +1 -0
  6. package/dist/archive.d.ts +11 -0
  7. package/dist/archive.d.ts.map +1 -0
  8. package/dist/archive.js +80 -0
  9. package/dist/archive.js.map +1 -0
  10. package/dist/build-strategy.d.ts +34 -0
  11. package/dist/build-strategy.d.ts.map +1 -0
  12. package/dist/build-strategy.js +33 -0
  13. package/dist/build-strategy.js.map +1 -0
  14. package/dist/bun-build.d.ts +14 -0
  15. package/dist/bun-build.d.ts.map +1 -0
  16. package/dist/bun-build.js +128 -0
  17. package/dist/bun-build.js.map +1 -0
  18. package/dist/callbacks.d.ts +44 -0
  19. package/dist/callbacks.d.ts.map +1 -0
  20. package/dist/callbacks.js +2 -0
  21. package/dist/callbacks.js.map +1 -0
  22. package/dist/compute-client.d.ts +136 -0
  23. package/dist/compute-client.d.ts.map +1 -0
  24. package/dist/compute-client.js +562 -0
  25. package/dist/compute-client.js.map +1 -0
  26. package/dist/errors.d.ts +101 -0
  27. package/dist/errors.d.ts.map +1 -0
  28. package/dist/errors.js +56 -0
  29. package/dist/errors.js.map +1 -0
  30. package/dist/index.d.ts +12 -0
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.js +10 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/polling.d.ts +22 -0
  35. package/dist/polling.d.ts.map +1 -0
  36. package/dist/polling.js +64 -0
  37. package/dist/polling.js.map +1 -0
  38. package/dist/types.d.ts +46 -0
  39. package/dist/types.d.ts.map +1 -0
  40. package/dist/types.js +17 -0
  41. package/dist/types.js.map +1 -0
  42. package/package.json +43 -0
  43. package/src/api-client.ts +330 -0
  44. package/src/archive.ts +111 -0
  45. package/src/build-strategy.ts +66 -0
  46. package/src/bun-build.ts +184 -0
  47. package/src/callbacks.ts +50 -0
  48. package/src/compute-client.ts +985 -0
  49. package/src/errors.ts +148 -0
  50. package/src/index.ts +75 -0
  51. package/src/polling.ts +108 -0
  52. package/src/types.ts +65 -0
@@ -0,0 +1,101 @@
1
+ declare const AuthenticationError_base: import("better-result").TaggedErrorClass<"AuthenticationError", {
2
+ statusCode: 401;
3
+ message: string;
4
+ }>;
5
+ export declare class AuthenticationError extends AuthenticationError_base {
6
+ }
7
+ declare const ApiError_base: import("better-result").TaggedErrorClass<"ApiError", {
8
+ statusCode: number;
9
+ statusText: string;
10
+ code?: string;
11
+ message: string;
12
+ hint?: string;
13
+ traceHeaders: Record<string, string>;
14
+ }>;
15
+ export declare class ApiError extends ApiError_base {
16
+ }
17
+ declare const MissingArgumentError_base: import("better-result").TaggedErrorClass<"MissingArgumentError", {
18
+ field: string;
19
+ message: string;
20
+ }>;
21
+ export declare class MissingArgumentError extends MissingArgumentError_base {
22
+ constructor(args: {
23
+ field: string;
24
+ });
25
+ }
26
+ declare const BuildError_base: import("better-result").TaggedErrorClass<"BuildError", {
27
+ message: string;
28
+ logs?: string[];
29
+ }>;
30
+ export declare class BuildError extends BuildError_base {
31
+ }
32
+ declare const ArtifactError_base: import("better-result").TaggedErrorClass<"ArtifactError", {
33
+ message: string;
34
+ cause?: unknown;
35
+ }>;
36
+ export declare class ArtifactError extends ArtifactError_base {
37
+ }
38
+ declare const TimeoutError_base: import("better-result").TaggedErrorClass<"TimeoutError", {
39
+ versionId: string;
40
+ elapsedMs: number;
41
+ lastStatus: string;
42
+ message: string;
43
+ }>;
44
+ export declare class TimeoutError extends TimeoutError_base {
45
+ constructor(args: {
46
+ versionId: string;
47
+ elapsedMs: number;
48
+ lastStatus: string;
49
+ });
50
+ }
51
+ declare const VersionFailedError_base: import("better-result").TaggedErrorClass<"VersionFailedError", {
52
+ versionId: string;
53
+ message: string;
54
+ }>;
55
+ export declare class VersionFailedError extends VersionFailedError_base {
56
+ constructor(args: {
57
+ versionId: string;
58
+ });
59
+ }
60
+ declare const NoExistingVersionError_base: import("better-result").TaggedErrorClass<"NoExistingVersionError", {
61
+ serviceId: string;
62
+ message: string;
63
+ }>;
64
+ export declare class NoExistingVersionError extends NoExistingVersionError_base {
65
+ constructor(args: {
66
+ serviceId: string;
67
+ });
68
+ }
69
+ declare const CancelledError_base: import("better-result").TaggedErrorClass<"CancelledError", {
70
+ message: string;
71
+ }>;
72
+ export declare class CancelledError extends CancelledError_base {
73
+ constructor(args?: {
74
+ message?: string;
75
+ });
76
+ }
77
+ declare const DestroyAggregateError_base: import("better-result").TaggedErrorClass<"DestroyAggregateError", {
78
+ message: string;
79
+ succeededVersionIds: string[];
80
+ failures: Array<{
81
+ versionId: string;
82
+ error: ComputeError;
83
+ }>;
84
+ serviceDeleted: boolean;
85
+ }>;
86
+ export declare class DestroyAggregateError extends DestroyAggregateError_base {
87
+ constructor(args: {
88
+ succeededVersionIds: string[];
89
+ failures: Array<{
90
+ versionId: string;
91
+ error: ComputeError;
92
+ }>;
93
+ serviceDeleted: boolean;
94
+ });
95
+ }
96
+ export type ComputeError = AuthenticationError | ApiError | MissingArgumentError | BuildError | ArtifactError | TimeoutError | VersionFailedError | NoExistingVersionError | CancelledError | DestroyAggregateError;
97
+ export type DeployError = AuthenticationError | ApiError | MissingArgumentError | BuildError | ArtifactError | TimeoutError | VersionFailedError | CancelledError;
98
+ export type UpdateEnvError = AuthenticationError | ApiError | MissingArgumentError | NoExistingVersionError | TimeoutError | VersionFailedError | CancelledError;
99
+ export type DestroyError = AuthenticationError | ApiError | MissingArgumentError | CancelledError | DestroyAggregateError;
100
+ export {};
101
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";gBAGc,GAAG;aACN,MAAM;;AAFjB,qBAAa,mBAAoB,SAAQ,wBAGrC;CAAG;;gBAGO,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AK,CAAC;YAAE,SAAS,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,YAAY,CAAA;SAAE,CAAC,CAAC;QAC5D,cAAc,EAAE,OAAO,CAAC;KACzB;CAOF;AAED,MAAM,MAAM,YAAY,GACpB,mBAAmB,GACnB,QAAQ,GACR,oBAAoB,GACpB,UAAU,GACV,aAAa,GACb,YAAY,GACZ,kBAAkB,GAClB,sBAAsB,GACtB,cAAc,GACd,qBAAqB,CAAC;AAE1B,MAAM,MAAM,WAAW,GACnB,mBAAmB,GACnB,QAAQ,GACR,oBAAoB,GACpB,UAAU,GACV,aAAa,GACb,YAAY,GACZ,kBAAkB,GAClB,cAAc,CAAC;AAEnB,MAAM,MAAM,cAAc,GACtB,mBAAmB,GACnB,QAAQ,GACR,oBAAoB,GACpB,sBAAsB,GACtB,YAAY,GACZ,kBAAkB,GAClB,cAAc,CAAC;AAEnB,MAAM,MAAM,YAAY,GACpB,mBAAmB,GACnB,QAAQ,GACR,oBAAoB,GACpB,cAAc,GACd,qBAAqB,CAAC"}
package/dist/errors.js ADDED
@@ -0,0 +1,56 @@
1
+ import { TaggedError } from "better-result";
2
+ export class AuthenticationError extends TaggedError("AuthenticationError")() {
3
+ }
4
+ export class ApiError extends TaggedError("ApiError")() {
5
+ }
6
+ export class MissingArgumentError extends TaggedError("MissingArgumentError")() {
7
+ constructor(args) {
8
+ super({
9
+ field: args.field,
10
+ message: `Missing required argument: ${args.field}`,
11
+ });
12
+ }
13
+ }
14
+ export class BuildError extends TaggedError("BuildError")() {
15
+ }
16
+ export class ArtifactError extends TaggedError("ArtifactError")() {
17
+ }
18
+ export class TimeoutError extends TaggedError("TimeoutError")() {
19
+ constructor(args) {
20
+ super({
21
+ ...args,
22
+ message: `Timed out waiting for version ${args.versionId} to reach target state (last status: ${args.lastStatus}, elapsed: ${Math.round(args.elapsedMs / 1000)}s)`,
23
+ });
24
+ }
25
+ }
26
+ export class VersionFailedError extends TaggedError("VersionFailedError")() {
27
+ constructor(args) {
28
+ super({
29
+ versionId: args.versionId,
30
+ message: `Version ${args.versionId} transitioned to failed status`,
31
+ });
32
+ }
33
+ }
34
+ export class NoExistingVersionError extends TaggedError("NoExistingVersionError")() {
35
+ constructor(args) {
36
+ super({
37
+ serviceId: args.serviceId,
38
+ message: `Service ${args.serviceId} has no existing versions. Environment-only updates require at least one prior deployment.`,
39
+ });
40
+ }
41
+ }
42
+ export class CancelledError extends TaggedError("CancelledError")() {
43
+ constructor(args) {
44
+ super({ message: args?.message ?? "Operation cancelled" });
45
+ }
46
+ }
47
+ export class DestroyAggregateError extends TaggedError("DestroyAggregateError")() {
48
+ constructor(args) {
49
+ const failedIds = args.failures.map((f) => f.versionId).join(", ");
50
+ super({
51
+ ...args,
52
+ message: `Failed to destroy ${args.failures.length} version(s): ${failedIds}`,
53
+ });
54
+ }
55
+ }
56
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,OAAO,mBAAoB,SAAQ,WAAW,CAAC,qBAAqB,CAAC,EAGvE;CAAG;AAEP,MAAM,OAAO,QAAS,SAAQ,WAAW,CAAC,UAAU,CAAC,EAOjD;CAAG;AAEP,MAAM,OAAO,oBAAqB,SAAQ,WAAW,CAAC,sBAAsB,CAAC,EAGzE;IACF,YAAY,IAAuB;QACjC,KAAK,CAAC;YACJ,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,OAAO,EAAE,8BAA8B,IAAI,CAAC,KAAK,EAAE;SACpD,CAAC,CAAC;IACL,CAAC;CACF;AAED,MAAM,OAAO,UAAW,SAAQ,WAAW,CAAC,YAAY,CAAC,EAGrD;CAAG;AAEP,MAAM,OAAO,aAAc,SAAQ,WAAW,CAAC,eAAe,CAAC,EAG3D;CAAG;AAEP,MAAM,OAAO,YAAa,SAAQ,WAAW,CAAC,cAAc,CAA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;IACL,CAAC;CACF"}
@@ -0,0 +1,12 @@
1
+ export { Err, matchError, matchErrorPartial, Ok, type Result, TaggedError, } from "better-result";
2
+ export type { BuildArtifact, BuildStrategy } from "./build-strategy.ts";
3
+ export { PreBuilt } from "./build-strategy.ts";
4
+ export { BunBuild } from "./bun-build.ts";
5
+ export type { DeployInteraction, DeployProgress, DestroyServiceProgress, DestroyVersionInteraction, DestroyVersionProgress, UpdateEnvProgress, } from "./callbacks.ts";
6
+ export type { CreateServiceOptions, DeleteServiceOptions, DeleteVersionOptions, DeployOptions, DeployResult, DestroyServiceOptions, DestroyServiceResult, DestroyVersionOptions, DestroyVersionResult, ListProjectsOptions, ListServicesOptions, ListVersionsOptions, ShowServiceOptions, ShowVersionOptions, StartVersionOptions, StopVersionOptions, UpdateEnvOptions, UpdateEnvResult, } from "./compute-client.ts";
7
+ export { ComputeClient } from "./compute-client.ts";
8
+ export type { ComputeError, DeployError, DestroyError, UpdateEnvError, } from "./errors.ts";
9
+ export { ApiError, ArtifactError, AuthenticationError, BuildError, CancelledError, DestroyAggregateError, MissingArgumentError, NoExistingVersionError, TimeoutError, VersionFailedError, } from "./errors.ts";
10
+ export type { PortMapping, ProjectInfo, RegionInfo, ResolvedConfig, ServiceDetail, ServiceInfo, VersionDetail, VersionInfo, } from "./types.ts";
11
+ export { KNOWN_REGION_IDS, REGIONS } from "./types.ts";
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,GAAG,EACH,UAAU,EACV,iBAAiB,EACjB,EAAE,EACF,KAAK,MAAM,EACX,WAAW,GACZ,MAAM,eAAe,CAAC;AAEvB,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,YAAY,EACV,iBAAiB,EACjB,cAAc,EACd,sBAAsB,EACtB,yBAAyB,EACzB,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,aAAa,EACb,YAAY,EACZ,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,GAChB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,YAAY,EACV,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,cAAc,GACf,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,QAAQ,EACR,aAAa,EACb,mBAAmB,EACnB,UAAU,EACV,cAAc,EACd,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,YAAY,EACZ,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAErB,YAAY,EACV,WAAW,EACX,WAAW,EACX,UAAU,EACV,cAAc,EACd,aAAa,EACb,WAAW,EACX,aAAa,EACb,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
1
+ // Re-export Result utilities so consumers don't need a direct better-result dependency
2
+ export { Err, matchError, matchErrorPartial, Ok, TaggedError, } from "better-result";
3
+ export { PreBuilt } from "./build-strategy.js";
4
+ export { BunBuild } from "./bun-build.js";
5
+ // Core client
6
+ export { ComputeClient } from "./compute-client.js";
7
+ // Errors
8
+ export { ApiError, ArtifactError, AuthenticationError, BuildError, CancelledError, DestroyAggregateError, MissingArgumentError, NoExistingVersionError, TimeoutError, VersionFailedError, } from "./errors.js";
9
+ export { KNOWN_REGION_IDS, REGIONS } from "./types.js";
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,OAAO,EACL,GAAG,EACH,UAAU,EACV,iBAAiB,EACjB,EAAE,EAEF,WAAW,GACZ,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AA8B1C,cAAc;AACd,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAOpD,SAAS;AACT,OAAO,EACL,QAAQ,EACR,aAAa,EACb,mBAAmB,EACnB,UAAU,EACV,cAAc,EACd,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,YAAY,EACZ,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAYrB,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { Result } from "better-result";
2
+ import type { ApiClientError, InternalApiClient } from "./api-client.ts";
3
+ import { CancelledError, TimeoutError, VersionFailedError } from "./errors.ts";
4
+ export type PollOptions = {
5
+ targetStatus: "running" | "stopped";
6
+ timeoutSeconds: number;
7
+ pollIntervalMs: number;
8
+ signal?: AbortSignal;
9
+ onStatusChange?(status: string): void;
10
+ };
11
+ export type PollResult = {
12
+ previewDomain: string;
13
+ lastStatus: string;
14
+ };
15
+ export type PollError = CancelledError | TimeoutError | VersionFailedError | ApiClientError;
16
+ /**
17
+ * Polls a compute version until it reaches the target status, fails, or times out.
18
+ *
19
+ * Returns a Result with the preview domain on success or a typed error.
20
+ */
21
+ export declare function pollVersionStatus(api: InternalApiClient, versionId: string, options: PollOptions): Promise<Result<PollResult, PollError>>;
22
+ //# sourceMappingURL=polling.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"polling.d.ts","sourceRoot":"","sources":["../src/polling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAEL,cAAc,EACd,YAAY,EACZ,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAErB,MAAM,MAAM,WAAW,GAAG;IACxB,YAAY,EAAE,SAAS,GAAG,SAAS,CAAC;IACpC,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,cAAc,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,SAAS,GACjB,cAAc,GACd,YAAY,GACZ,kBAAkB,GAClB,cAAc,CAAC;AAEnB;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,iBAAiB,EACtB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC,CAiDxC"}
@@ -0,0 +1,64 @@
1
+ import { Result } from "better-result";
2
+ import { ApiError, CancelledError, TimeoutError, VersionFailedError, } from "./errors.js";
3
+ /**
4
+ * Polls a compute version until it reaches the target status, fails, or times out.
5
+ *
6
+ * Returns a Result with the preview domain on success or a typed error.
7
+ */
8
+ export async function pollVersionStatus(api, versionId, options) {
9
+ return Result.gen(async function* () {
10
+ const deadline = Date.now() + options.timeoutSeconds * 1_000;
11
+ let lastStatus = "";
12
+ while (Date.now() <= deadline) {
13
+ if (options.signal?.aborted) {
14
+ return Result.err(new CancelledError());
15
+ }
16
+ const version = yield* Result.await(api.getVersion(versionId));
17
+ if (version.status !== lastStatus) {
18
+ lastStatus = version.status;
19
+ options.onStatusChange?.(version.status);
20
+ }
21
+ if (version.status === options.targetStatus) {
22
+ if (options.targetStatus === "running" && !version.previewDomain) {
23
+ return Result.err(new ApiError({
24
+ statusCode: 0,
25
+ statusText: "",
26
+ message: "Version reached running state without a previewDomain",
27
+ traceHeaders: {},
28
+ }));
29
+ }
30
+ return Result.ok({
31
+ previewDomain: version.previewDomain ?? "",
32
+ lastStatus: version.status,
33
+ });
34
+ }
35
+ if (version.status === "failed") {
36
+ return Result.err(new VersionFailedError({ versionId }));
37
+ }
38
+ await sleep(options.pollIntervalMs, options.signal);
39
+ }
40
+ return Result.err(new TimeoutError({
41
+ versionId,
42
+ elapsedMs: Date.now() - (deadline - options.timeoutSeconds * 1_000),
43
+ lastStatus,
44
+ }));
45
+ });
46
+ }
47
+ function sleep(ms, signal) {
48
+ return new Promise((resolve) => {
49
+ if (signal?.aborted) {
50
+ resolve();
51
+ return;
52
+ }
53
+ const onAbort = () => {
54
+ clearTimeout(timer);
55
+ resolve();
56
+ };
57
+ const timer = setTimeout(() => {
58
+ signal?.removeEventListener("abort", onAbort);
59
+ resolve();
60
+ }, ms);
61
+ signal?.addEventListener("abort", onAbort, { once: true });
62
+ });
63
+ }
64
+ //# sourceMappingURL=polling.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"polling.js","sourceRoot":"","sources":["../src/polling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,OAAO,EACL,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAqBrB;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,GAAsB,EACtB,SAAiB,EACjB,OAAoB;IAEpB,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC;QAC/B,MAAM,QAAQ,GA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C,CAAC,CAAC;YAC3D,CAAC;YAED,MAAM,KAAK,CAAC,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QACtD,CAAC;QAED,OAAO,MAAM,CAAC,GAAG,CACf,IAAI,YAAY,CAAC;YACf,SAAS;YACT,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,QAAQ,GAAG,OAAO,CAAC,cAAc,GAAG,KAAK,CAAC;YACnE,UAAU;SACX,CAAC,CACH,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,KAAK,CAAC,EAAU,EAAE,MAAoB;IAC7C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;YACpB,OAAO,EAAE,CAAC;YACV,OAAO;QACT,CAAC;QAED,MAAM,OAAO,GAAG,GAAG,EAAE;YACnB,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC;QAEF,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;YAC5B,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC9C,OAAO,EAAE,CAAC;QACZ,CAAC,EAAE,EAAE,CAAC,CAAC;QAEP,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Domain types for the Compute SDK.
3
+ */
4
+ export interface PortMapping {
5
+ http?: number | null;
6
+ }
7
+ export interface ProjectInfo {
8
+ id: string;
9
+ name: string;
10
+ defaultRegion?: string;
11
+ }
12
+ export interface ServiceInfo {
13
+ id: string;
14
+ name: string;
15
+ region: string;
16
+ projectId: string;
17
+ createdAt?: string;
18
+ }
19
+ export interface ServiceDetail extends ServiceInfo {
20
+ latestVersionId?: string | null;
21
+ }
22
+ export interface VersionInfo {
23
+ id: string;
24
+ status: string;
25
+ createdAt: string;
26
+ previewDomain?: string | null;
27
+ }
28
+ export interface VersionDetail extends VersionInfo {
29
+ envVars?: Record<string, string | null>;
30
+ foundryVersionId?: string;
31
+ }
32
+ export interface RegionInfo {
33
+ id: string;
34
+ displayName: string;
35
+ }
36
+ export interface ResolvedConfig {
37
+ projectId: string;
38
+ serviceId: string;
39
+ serviceName: string;
40
+ region: string;
41
+ portMapping?: PortMapping;
42
+ }
43
+ /** Known compute region identifiers, used by the CLI for interactive prompts. */
44
+ export declare const KNOWN_REGION_IDS: readonly ["us-east-1", "us-west-1", "eu-west-3", "eu-central-1", "ap-northeast-1", "ap-southeast-1"];
45
+ export declare const REGIONS: RegionInfo[];
46
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAc,SAAQ,WAAW;IAChD,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED,MAAM,WAAW,aAAc,SAAQ,WAAW;IAChD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;IACxC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAED,iFAAiF;AACjF,eAAO,MAAM,gBAAgB,sGAOnB,CAAC;AAEX,eAAO,MAAM,OAAO,EAAE,UAAU,EAG7B,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Domain types for the Compute SDK.
3
+ */
4
+ /** Known compute region identifiers, used by the CLI for interactive prompts. */
5
+ export const KNOWN_REGION_IDS = [
6
+ "us-east-1",
7
+ "us-west-1",
8
+ "eu-west-3",
9
+ "eu-central-1",
10
+ "ap-northeast-1",
11
+ "ap-southeast-1",
12
+ ];
13
+ export const REGIONS = KNOWN_REGION_IDS.map((id) => ({
14
+ id,
15
+ displayName: id,
16
+ }));
17
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAiDH,iFAAiF;AACjF,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,WAAW;IACX,WAAW;IACX,WAAW;IACX,cAAc;IACd,gBAAgB;IAChB,gBAAgB;CACR,CAAC;AAEX,MAAM,CAAC,MAAM,OAAO,GAAiB,gBAAgB,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IACjE,EAAE;IACF,WAAW,EAAE,EAAE;CAChB,CAAC,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@prisma/compute-sdk",
3
+ "version": "0.1.0",
4
+ "description": "TypeScript SDK for deploying and managing applications on Prisma Compute",
5
+ "license": "Apache-2.0",
6
+ "type": "module",
7
+ "exports": {
8
+ ".": {
9
+ "import": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ }
13
+ }
14
+ },
15
+ "main": "./dist/index.js",
16
+ "types": "./dist/index.d.ts",
17
+ "files": [
18
+ "dist",
19
+ "src"
20
+ ],
21
+ "engines": {
22
+ "node": ">=18.0.0"
23
+ },
24
+ "scripts": {
25
+ "build": "tsc --project tsconfig.build.json",
26
+ "prepublishOnly": "npm run build",
27
+ "test": "bun test",
28
+ "check:types": "tsc --noEmit"
29
+ },
30
+ "dependencies": {
31
+ "better-result": "^2.7.0",
32
+ "tar-stream": "^3.1.7"
33
+ },
34
+ "peerDependencies": {
35
+ "@prisma/management-api-sdk": ">=1.20.1"
36
+ },
37
+ "devDependencies": {
38
+ "@types/bun": "latest",
39
+ "@types/node": "^22.0.0",
40
+ "@types/tar-stream": "^3.1.3",
41
+ "typescript": "^5.9.3"
42
+ }
43
+ }