@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.
- package/README.md +638 -0
- package/dist/api-client.d.ts +181 -0
- package/dist/api-client.d.ts.map +1 -0
- package/dist/api-client.js +193 -0
- package/dist/api-client.js.map +1 -0
- package/dist/archive.d.ts +11 -0
- package/dist/archive.d.ts.map +1 -0
- package/dist/archive.js +80 -0
- package/dist/archive.js.map +1 -0
- package/dist/build-strategy.d.ts +34 -0
- package/dist/build-strategy.d.ts.map +1 -0
- package/dist/build-strategy.js +33 -0
- package/dist/build-strategy.js.map +1 -0
- package/dist/bun-build.d.ts +14 -0
- package/dist/bun-build.d.ts.map +1 -0
- package/dist/bun-build.js +128 -0
- package/dist/bun-build.js.map +1 -0
- package/dist/callbacks.d.ts +44 -0
- package/dist/callbacks.d.ts.map +1 -0
- package/dist/callbacks.js +2 -0
- package/dist/callbacks.js.map +1 -0
- package/dist/compute-client.d.ts +136 -0
- package/dist/compute-client.d.ts.map +1 -0
- package/dist/compute-client.js +562 -0
- package/dist/compute-client.js.map +1 -0
- package/dist/errors.d.ts +101 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +56 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/polling.d.ts +22 -0
- package/dist/polling.d.ts.map +1 -0
- package/dist/polling.js +64 -0
- package/dist/polling.js.map +1 -0
- package/dist/types.d.ts +46 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +17 -0
- package/dist/types.js.map +1 -0
- package/package.json +43 -0
- package/src/api-client.ts +330 -0
- package/src/archive.ts +111 -0
- package/src/build-strategy.ts +66 -0
- package/src/bun-build.ts +184 -0
- package/src/callbacks.ts +50 -0
- package/src/compute-client.ts +985 -0
- package/src/errors.ts +148 -0
- package/src/index.ts +75 -0
- package/src/polling.ts +108 -0
- package/src/types.ts +65 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import type { ManagementApiClient, paths } from "@prisma/management-api-sdk";
|
|
2
|
+
import { Result } from "better-result";
|
|
3
|
+
import { ApiError, AuthenticationError } from "./errors.ts";
|
|
4
|
+
export type ApiClientError = AuthenticationError | ApiError;
|
|
5
|
+
/**
|
|
6
|
+
* Lean internal wrapper around ManagementApiClient.
|
|
7
|
+
*
|
|
8
|
+
* Provides typed, domain-specific methods with structured error handling.
|
|
9
|
+
* Has no knowledge of OAuth, service tokens, or token storage — it simply
|
|
10
|
+
* uses the ManagementApiClient it was given.
|
|
11
|
+
*/
|
|
12
|
+
export declare class InternalApiClient {
|
|
13
|
+
#private;
|
|
14
|
+
constructor(client: ManagementApiClient);
|
|
15
|
+
listProjects(signal?: AbortSignal): Promise<Result<{
|
|
16
|
+
id: string;
|
|
17
|
+
type: "project";
|
|
18
|
+
url: string;
|
|
19
|
+
name: string;
|
|
20
|
+
createdAt: string;
|
|
21
|
+
defaultRegion: string | null;
|
|
22
|
+
workspace: {
|
|
23
|
+
id: string;
|
|
24
|
+
url: string;
|
|
25
|
+
name: string;
|
|
26
|
+
};
|
|
27
|
+
}[], ApiClientError>>;
|
|
28
|
+
getProject(id: string, signal?: AbortSignal): Promise<import("better-result").Ok<{
|
|
29
|
+
id: string;
|
|
30
|
+
type: "project";
|
|
31
|
+
url: string;
|
|
32
|
+
name: string;
|
|
33
|
+
createdAt: string;
|
|
34
|
+
defaultRegion: string | null;
|
|
35
|
+
workspace: {
|
|
36
|
+
id: string;
|
|
37
|
+
url: string;
|
|
38
|
+
name: string;
|
|
39
|
+
};
|
|
40
|
+
}, ApiClientError> | import("better-result").Err<{
|
|
41
|
+
id: string;
|
|
42
|
+
type: "project";
|
|
43
|
+
url: string;
|
|
44
|
+
name: string;
|
|
45
|
+
createdAt: string;
|
|
46
|
+
defaultRegion: string | null;
|
|
47
|
+
workspace: {
|
|
48
|
+
id: string;
|
|
49
|
+
url: string;
|
|
50
|
+
name: string;
|
|
51
|
+
};
|
|
52
|
+
}, ApiClientError>>;
|
|
53
|
+
listProjectServices(projectId: string, signal?: AbortSignal): Promise<Result<{
|
|
54
|
+
id: string;
|
|
55
|
+
type: "compute-service";
|
|
56
|
+
url: string;
|
|
57
|
+
name: string;
|
|
58
|
+
region: {
|
|
59
|
+
id: string;
|
|
60
|
+
name: string;
|
|
61
|
+
};
|
|
62
|
+
projectId: string;
|
|
63
|
+
latestVersionId: string | null;
|
|
64
|
+
createdAt: string;
|
|
65
|
+
}[], ApiClientError>>;
|
|
66
|
+
createProjectService(projectId: string, body: CreateProjectServiceBody, signal?: AbortSignal): Promise<import("better-result").Err<{
|
|
67
|
+
id: string;
|
|
68
|
+
type: "compute-service";
|
|
69
|
+
url: string;
|
|
70
|
+
name: string;
|
|
71
|
+
region: {
|
|
72
|
+
id: string;
|
|
73
|
+
name: string;
|
|
74
|
+
};
|
|
75
|
+
projectId: string;
|
|
76
|
+
latestVersionId: string | null;
|
|
77
|
+
createdAt: string;
|
|
78
|
+
}, ApiClientError> | import("better-result").Ok<{
|
|
79
|
+
id: string;
|
|
80
|
+
type: "compute-service";
|
|
81
|
+
url: string;
|
|
82
|
+
name: string;
|
|
83
|
+
region: {
|
|
84
|
+
id: string;
|
|
85
|
+
name: string;
|
|
86
|
+
};
|
|
87
|
+
projectId: string;
|
|
88
|
+
latestVersionId: string | null;
|
|
89
|
+
createdAt: string;
|
|
90
|
+
}, ApiClientError>>;
|
|
91
|
+
getService(computeServiceId: string, signal?: AbortSignal): Promise<import("better-result").Err<{
|
|
92
|
+
id: string;
|
|
93
|
+
type: "compute-service";
|
|
94
|
+
url: string;
|
|
95
|
+
name: string;
|
|
96
|
+
region: {
|
|
97
|
+
id: string;
|
|
98
|
+
name: string;
|
|
99
|
+
};
|
|
100
|
+
projectId: string;
|
|
101
|
+
latestVersionId: string | null;
|
|
102
|
+
createdAt: string;
|
|
103
|
+
}, ApiClientError> | import("better-result").Ok<{
|
|
104
|
+
id: string;
|
|
105
|
+
type: "compute-service";
|
|
106
|
+
url: string;
|
|
107
|
+
name: string;
|
|
108
|
+
region: {
|
|
109
|
+
id: string;
|
|
110
|
+
name: string;
|
|
111
|
+
};
|
|
112
|
+
projectId: string;
|
|
113
|
+
latestVersionId: string | null;
|
|
114
|
+
createdAt: string;
|
|
115
|
+
}, ApiClientError>>;
|
|
116
|
+
deleteService(computeServiceId: string, signal?: AbortSignal): Promise<Result<void, ApiClientError>>;
|
|
117
|
+
listServiceVersions(computeServiceId: string, signal?: AbortSignal): Promise<Result<{
|
|
118
|
+
id: string;
|
|
119
|
+
type: "compute-version";
|
|
120
|
+
url: string;
|
|
121
|
+
foundryVersionId: string;
|
|
122
|
+
createdAt: string;
|
|
123
|
+
}[], ApiClientError>>;
|
|
124
|
+
createServiceVersion(computeServiceId: string, body?: CreateServiceVersionBody, signal?: AbortSignal): Promise<import("better-result").Err<{
|
|
125
|
+
id: string;
|
|
126
|
+
type: "compute-version";
|
|
127
|
+
url: string;
|
|
128
|
+
foundryVersionId: string;
|
|
129
|
+
uploadUrl: string | null;
|
|
130
|
+
}, ApiClientError> | import("better-result").Ok<{
|
|
131
|
+
id: string;
|
|
132
|
+
type: "compute-version";
|
|
133
|
+
url: string;
|
|
134
|
+
foundryVersionId: string;
|
|
135
|
+
uploadUrl: string | null;
|
|
136
|
+
}, ApiClientError>>;
|
|
137
|
+
getVersion(versionId: string, signal?: AbortSignal): Promise<import("better-result").Err<{
|
|
138
|
+
id: string;
|
|
139
|
+
type: "compute-version";
|
|
140
|
+
url: string;
|
|
141
|
+
foundryVersionId: string;
|
|
142
|
+
status: string;
|
|
143
|
+
previewDomain: string | null;
|
|
144
|
+
envVars?: {
|
|
145
|
+
[key: string]: string;
|
|
146
|
+
};
|
|
147
|
+
createdAt: string;
|
|
148
|
+
}, ApiClientError> | import("better-result").Ok<{
|
|
149
|
+
id: string;
|
|
150
|
+
type: "compute-version";
|
|
151
|
+
url: string;
|
|
152
|
+
foundryVersionId: string;
|
|
153
|
+
status: string;
|
|
154
|
+
previewDomain: string | null;
|
|
155
|
+
envVars?: {
|
|
156
|
+
[key: string]: string;
|
|
157
|
+
};
|
|
158
|
+
createdAt: string;
|
|
159
|
+
}, ApiClientError>>;
|
|
160
|
+
startVersion(versionId: string, signal?: AbortSignal): Promise<import("better-result").Err<{
|
|
161
|
+
previewDomain: string;
|
|
162
|
+
}, ApiClientError> | import("better-result").Ok<{
|
|
163
|
+
previewDomain: string;
|
|
164
|
+
}, ApiClientError>>;
|
|
165
|
+
stopVersion(versionId: string, signal?: AbortSignal): Promise<Result<void, ApiClientError>>;
|
|
166
|
+
deleteVersion(versionId: string, signal?: AbortSignal): Promise<Result<void, ApiClientError>>;
|
|
167
|
+
}
|
|
168
|
+
type SdkCreateProjectServiceBody = NonNullable<paths["/v1/projects/{projectId}/compute-services"]["post"]["requestBody"]>["content"]["application/json"];
|
|
169
|
+
type CreateProjectServiceBody = Omit<SdkCreateProjectServiceBody, "regionId"> & {
|
|
170
|
+
regionId?: string;
|
|
171
|
+
};
|
|
172
|
+
export type CreateServiceVersionBody = NonNullable<paths["/v1/compute-services/{computeServiceId}/versions"]["post"]["requestBody"]>["content"]["application/json"];
|
|
173
|
+
/** Extract the upload URL from a version creation response. */
|
|
174
|
+
export declare function readUploadUrl(data: {
|
|
175
|
+
uploadUrl?: string | null;
|
|
176
|
+
artifactUploadUrl?: string | null;
|
|
177
|
+
}): string | null;
|
|
178
|
+
/** Normalize a preview domain to a clickable https URL. */
|
|
179
|
+
export declare function toDeploymentUrl(value: string): string;
|
|
180
|
+
export {};
|
|
181
|
+
//# sourceMappingURL=api-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-client.d.ts","sourceRoot":"","sources":["../src/api-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAC7E,OAAO,EAA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AC,EAAE,WAAW,GACnB,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;IASlC,aAAa,CACjB,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;CAiEzC;AAMD,KAAK,2BAA2B,GAAG,WAAW,CAC5C,KAAK,CAAC,2CAA2C,CAAC,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,CAC1E,CAAC,SAAS,CAAC,CAAC,kBAAkB,CAAC,CAAC;AAEjC,KAAK,wBAAwB,GAAG,IAAI,CAClC,2BAA2B,EAC3B,UAAU,CACX,GAAG;IACF,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG,WAAW,CAChD,KAAK,CAAC,kDAAkD,CAAC,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,CACjF,CAAC,SAAS,CAAC,CAAC,kBAAkB,CAAC,CAAC;AAoEjC,+DAA+D;AAC/D,wBAAgB,aAAa,CAAC,IAAI,EAAE;IAClC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC,GAAG,MAAM,GAAG,IAAI,CAWhB;AAED,2DAA2D;AAC3D,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMrD"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { Result } from "better-result";
|
|
2
|
+
import { ApiError, AuthenticationError } from "./errors.js";
|
|
3
|
+
/**
|
|
4
|
+
* Lean internal wrapper around ManagementApiClient.
|
|
5
|
+
*
|
|
6
|
+
* Provides typed, domain-specific methods with structured error handling.
|
|
7
|
+
* Has no knowledge of OAuth, service tokens, or token storage — it simply
|
|
8
|
+
* uses the ManagementApiClient it was given.
|
|
9
|
+
*/
|
|
10
|
+
export class InternalApiClient {
|
|
11
|
+
#client;
|
|
12
|
+
constructor(client) {
|
|
13
|
+
this.#client = client;
|
|
14
|
+
}
|
|
15
|
+
async listProjects(signal) {
|
|
16
|
+
return this.#requestPaginated((cursor) => this.#client.GET("/v1/projects", {
|
|
17
|
+
params: { query: cursor ? { cursor } : {} },
|
|
18
|
+
signal,
|
|
19
|
+
}), "/v1/projects");
|
|
20
|
+
}
|
|
21
|
+
async getProject(id, signal) {
|
|
22
|
+
return this.#request(this.#client.GET("/v1/projects/{id}", {
|
|
23
|
+
params: { path: { id } },
|
|
24
|
+
signal,
|
|
25
|
+
}), "/v1/projects/{id}").then((r) => r.map((body) => body.data));
|
|
26
|
+
}
|
|
27
|
+
async listProjectServices(projectId, signal) {
|
|
28
|
+
return this.#requestPaginated((cursor) => this.#client.GET("/v1/projects/{projectId}/compute-services", {
|
|
29
|
+
params: { path: { projectId }, query: cursor ? { cursor } : {} },
|
|
30
|
+
signal,
|
|
31
|
+
}), "/v1/projects/{projectId}/compute-services");
|
|
32
|
+
}
|
|
33
|
+
async createProjectService(projectId, body, signal) {
|
|
34
|
+
return this.#request(this.#client.POST("/v1/projects/{projectId}/compute-services", {
|
|
35
|
+
params: { path: { projectId } },
|
|
36
|
+
body: body,
|
|
37
|
+
signal,
|
|
38
|
+
}), "/v1/projects/{projectId}/compute-services").then((r) => r.map((body) => body.data));
|
|
39
|
+
}
|
|
40
|
+
async getService(computeServiceId, signal) {
|
|
41
|
+
return this.#request(this.#client.GET("/v1/compute-services/{computeServiceId}", {
|
|
42
|
+
params: { path: { computeServiceId } },
|
|
43
|
+
signal,
|
|
44
|
+
}), "/v1/compute-services/{computeServiceId}").then((r) => r.map((body) => body.data));
|
|
45
|
+
}
|
|
46
|
+
async deleteService(computeServiceId, signal) {
|
|
47
|
+
return this.#unwrapVoid(this.#client.DELETE("/v1/compute-services/{computeServiceId}", {
|
|
48
|
+
params: { path: { computeServiceId } },
|
|
49
|
+
signal,
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
async listServiceVersions(computeServiceId, signal) {
|
|
53
|
+
return this.#requestPaginated((cursor) => this.#client.GET("/v1/compute-services/{computeServiceId}/versions", {
|
|
54
|
+
params: {
|
|
55
|
+
path: { computeServiceId },
|
|
56
|
+
query: cursor ? { cursor } : {},
|
|
57
|
+
},
|
|
58
|
+
signal,
|
|
59
|
+
}), "/v1/compute-services/{computeServiceId}/versions");
|
|
60
|
+
}
|
|
61
|
+
async createServiceVersion(computeServiceId, body, signal) {
|
|
62
|
+
return this.#request(this.#client.POST("/v1/compute-services/{computeServiceId}/versions", {
|
|
63
|
+
params: { path: { computeServiceId } },
|
|
64
|
+
body,
|
|
65
|
+
signal,
|
|
66
|
+
}), "/v1/compute-services/{computeServiceId}/versions").then((r) => r.map((body) => body.data));
|
|
67
|
+
}
|
|
68
|
+
async getVersion(versionId, signal) {
|
|
69
|
+
return this.#request(this.#client.GET("/v1/compute-services/versions/{versionId}", {
|
|
70
|
+
params: { path: { versionId } },
|
|
71
|
+
signal,
|
|
72
|
+
}), "/v1/compute-services/versions/{versionId}").then((r) => r.map((body) => body.data));
|
|
73
|
+
}
|
|
74
|
+
async startVersion(versionId, signal) {
|
|
75
|
+
return this.#request(this.#client.POST("/v1/compute-services/versions/{versionId}/start", {
|
|
76
|
+
params: { path: { versionId } },
|
|
77
|
+
signal,
|
|
78
|
+
}), "/v1/compute-services/versions/{versionId}/start").then((r) => r.map((body) => body.data));
|
|
79
|
+
}
|
|
80
|
+
async stopVersion(versionId, signal) {
|
|
81
|
+
return this.#unwrapVoid(this.#client.POST("/v1/compute-services/versions/{versionId}/stop", {
|
|
82
|
+
params: { path: { versionId } },
|
|
83
|
+
signal,
|
|
84
|
+
}));
|
|
85
|
+
}
|
|
86
|
+
async deleteVersion(versionId, signal) {
|
|
87
|
+
return this.#unwrapVoid(this.#client.DELETE("/v1/compute-services/versions/{versionId}", {
|
|
88
|
+
params: { path: { versionId } },
|
|
89
|
+
signal,
|
|
90
|
+
}));
|
|
91
|
+
}
|
|
92
|
+
async #request(request, endpoint) {
|
|
93
|
+
const result = await request;
|
|
94
|
+
if (result.error) {
|
|
95
|
+
return Result.err(parseApiError(result.error, result.response));
|
|
96
|
+
}
|
|
97
|
+
const body = result.data;
|
|
98
|
+
if (body == null) {
|
|
99
|
+
return Result.err(parseApiError(undefined, undefined, `Management API returned an empty response body for ${endpoint}`));
|
|
100
|
+
}
|
|
101
|
+
return Result.ok(body);
|
|
102
|
+
}
|
|
103
|
+
async #requestPaginated(makeRequest, endpoint) {
|
|
104
|
+
const allItems = [];
|
|
105
|
+
let cursor;
|
|
106
|
+
for (;;) {
|
|
107
|
+
const result = await this.#request(makeRequest(cursor), endpoint);
|
|
108
|
+
if (result.isErr())
|
|
109
|
+
return result;
|
|
110
|
+
allItems.push(...result.value.data);
|
|
111
|
+
const nextCursor = result.value.pagination?.nextCursor;
|
|
112
|
+
if (!nextCursor)
|
|
113
|
+
break;
|
|
114
|
+
cursor = nextCursor;
|
|
115
|
+
}
|
|
116
|
+
return Result.ok(allItems);
|
|
117
|
+
}
|
|
118
|
+
async #unwrapVoid(request) {
|
|
119
|
+
const result = await request;
|
|
120
|
+
if (result.error) {
|
|
121
|
+
return Result.err(parseApiError(result.error, result.response));
|
|
122
|
+
}
|
|
123
|
+
return Result.ok(undefined);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
const TRACE_HEADER_NAMES = [
|
|
127
|
+
"x-request-id",
|
|
128
|
+
"x-correlation-id",
|
|
129
|
+
"x-amzn-requestid",
|
|
130
|
+
"x-amz-request-id",
|
|
131
|
+
"traceparent",
|
|
132
|
+
"cf-ray",
|
|
133
|
+
"cf-placement",
|
|
134
|
+
];
|
|
135
|
+
function extractTraceHeaders(response) {
|
|
136
|
+
const headers = {};
|
|
137
|
+
if (!response)
|
|
138
|
+
return headers;
|
|
139
|
+
for (const name of TRACE_HEADER_NAMES) {
|
|
140
|
+
const value = response.headers.get(name);
|
|
141
|
+
if (value) {
|
|
142
|
+
headers[name] = value;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return headers;
|
|
146
|
+
}
|
|
147
|
+
function parseApiError(error, response, fallbackMessage) {
|
|
148
|
+
const traceHeaders = extractTraceHeaders(response);
|
|
149
|
+
if (response?.status === 401) {
|
|
150
|
+
return new AuthenticationError({
|
|
151
|
+
statusCode: 401,
|
|
152
|
+
message: "Authentication failed (HTTP 401)",
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
const err = error;
|
|
156
|
+
const message = err?.error?.message ??
|
|
157
|
+
err?.message ??
|
|
158
|
+
fallbackMessage ??
|
|
159
|
+
`Request failed with HTTP ${response?.status ?? "unknown"}`;
|
|
160
|
+
const code = err?.error?.code ?? err?.code;
|
|
161
|
+
const hint = err?.error?.hint ?? err?.hint;
|
|
162
|
+
return new ApiError({
|
|
163
|
+
statusCode: response?.status ?? 0,
|
|
164
|
+
statusText: response?.statusText ?? "",
|
|
165
|
+
code,
|
|
166
|
+
message,
|
|
167
|
+
hint,
|
|
168
|
+
traceHeaders,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
/** Extract the upload URL from a version creation response. */
|
|
172
|
+
export function readUploadUrl(data) {
|
|
173
|
+
if (typeof data.uploadUrl === "string" && data.uploadUrl.length > 0) {
|
|
174
|
+
return data.uploadUrl;
|
|
175
|
+
}
|
|
176
|
+
if (typeof data.artifactUploadUrl === "string" &&
|
|
177
|
+
data.artifactUploadUrl.length > 0) {
|
|
178
|
+
return data.artifactUploadUrl;
|
|
179
|
+
}
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
/** Normalize a preview domain to a clickable https URL. */
|
|
183
|
+
export function toDeploymentUrl(value) {
|
|
184
|
+
const normalized = value.trim();
|
|
185
|
+
if (normalized.length === 0)
|
|
186
|
+
return normalized;
|
|
187
|
+
if (normalized.startsWith("//"))
|
|
188
|
+
return `https:${normalized}`;
|
|
189
|
+
if (/^https?:\/\//i.test(normalized))
|
|
190
|
+
return normalized;
|
|
191
|
+
return `https://${normalized}`;
|
|
192
|
+
}
|
|
193
|
+
//# sourceMappingURL=api-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-client.js","sourceRoot":"","sources":["../src/api-client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAI5D;;;;;;GAMG;AACH,MAAM,OAAO,iBAAiB;IACnB,OAAO,CAAsB;IAEtC,YAAY,MAA2B;QACrC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,MAAoB;QACrC,OAAO,IAAI,CAAC,iBAAiB,CAC3B,CAAC,MAAM,EAAE,EAAE,CACT,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE;YAC/B,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE;YAC3C,MAAM;SACP,CAAC,EACJ,cAAc,CACf,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,EAAU,EAAE,MAAoB;QAC/C,OAAO,IAAI,CAAC,QAAQ,CAClB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE;YACpC,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,EAAE;YACxB,MAAM;SACP,CAAC,EACF,mBAAmB,CACpB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC5C,CAAC;IAED,KAAK,CAAC,mBAAmB,CAAC,SAAiB,EAAE,MAAoB;QAC/D,OAAO,IAAI,CAAC,iBAAiB,CAC3B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AAU,IAAI,EAAE;QACtC,IAAI;QACJ,OAAO;QACP,IAAI;QACJ,YAAY;KACb,CAAC,CAAC;AACL,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,aAAa,CAAC,IAG7B;IACC,IAAI,OAAO,IAAI,CAAC,SAAS,KAAK,QAAQ,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpE,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IACD,IACE,OAAO,IAAI,CAAC,iBAAiB,KAAK,QAAQ;QAC1C,IAAI,CAAC,iBAAiB,CAAC,MAAM,GAAG,CAAC,EACjC,CAAC;QACD,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAChC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,2DAA2D;AAC3D,MAAM,UAAU,eAAe,CAAC,KAAa;IAC3C,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAChC,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,UAAU,CAAC;IAC/C,IAAI,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,SAAS,UAAU,EAAE,CAAC;IAC9D,IAAI,eAAe,CAAC,IAAI,CAAC,UAAU,CAAC;QAAE,OAAO,UAAU,CAAC;IACxD,OAAO,WAAW,UAAU,EAAE,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a tar.gz archive in memory from a build artifact directory.
|
|
3
|
+
*
|
|
4
|
+
* - Files are added under the `bundle/` prefix.
|
|
5
|
+
* - Symlinks are followed (dereferenced).
|
|
6
|
+
* - A synthetic `compute.manifest.json` entry is injected at the tar root.
|
|
7
|
+
*
|
|
8
|
+
* Returns the gzipped archive as a Uint8Array.
|
|
9
|
+
*/
|
|
10
|
+
export declare function createArchive(directory: string, entrypoint: string): Promise<Uint8Array>;
|
|
11
|
+
//# sourceMappingURL=archive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"archive.d.ts","sourceRoot":"","sources":["../src/archive.ts"],"names":[],"mappings":"AAOA;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CACjC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,UAAU,CAAC,CAsBrB"}
|
package/dist/archive.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { lstat, readdir, readFile, readlink, stat } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { createGzip } from "node:zlib";
|
|
4
|
+
import { pack } from "tar-stream";
|
|
5
|
+
const COMPUTE_MANIFEST_VERSION = "1";
|
|
6
|
+
/**
|
|
7
|
+
* Create a tar.gz archive in memory from a build artifact directory.
|
|
8
|
+
*
|
|
9
|
+
* - Files are added under the `bundle/` prefix.
|
|
10
|
+
* - Symlinks are followed (dereferenced).
|
|
11
|
+
* - A synthetic `compute.manifest.json` entry is injected at the tar root.
|
|
12
|
+
*
|
|
13
|
+
* Returns the gzipped archive as a Uint8Array.
|
|
14
|
+
*/
|
|
15
|
+
export async function createArchive(directory, entrypoint) {
|
|
16
|
+
const packer = pack();
|
|
17
|
+
// Walk the directory and add all files
|
|
18
|
+
await addDirectory(packer, directory, "bundle");
|
|
19
|
+
// Inject the manifest as a synthetic entry
|
|
20
|
+
const manifest = JSON.stringify({
|
|
21
|
+
manifestVersion: COMPUTE_MANIFEST_VERSION,
|
|
22
|
+
entrypoint: `bundle/${entrypoint}`,
|
|
23
|
+
}, null, 2);
|
|
24
|
+
packer.entry({ name: "compute.manifest.json" }, manifest);
|
|
25
|
+
// Signal end of archive
|
|
26
|
+
packer.finalize();
|
|
27
|
+
// Pipe through gzip and collect into buffer
|
|
28
|
+
return await collectGzipped(packer);
|
|
29
|
+
}
|
|
30
|
+
async function addDirectory(packer, fsPath, tarPrefix) {
|
|
31
|
+
const entries = await readdir(fsPath, { withFileTypes: true });
|
|
32
|
+
for (const entry of entries) {
|
|
33
|
+
const fullPath = path.join(fsPath, entry.name);
|
|
34
|
+
const tarPath = `${tarPrefix}/${entry.name}`;
|
|
35
|
+
if (entry.isSymbolicLink()) {
|
|
36
|
+
// Dereference symlinks: stat the target and add accordingly
|
|
37
|
+
const target = await readlink(fullPath);
|
|
38
|
+
const resolvedPath = path.resolve(fsPath, target);
|
|
39
|
+
const resolvedStat = await stat(resolvedPath);
|
|
40
|
+
if (resolvedStat.isDirectory()) {
|
|
41
|
+
await addDirectory(packer, resolvedPath, tarPath);
|
|
42
|
+
}
|
|
43
|
+
else if (resolvedStat.isFile()) {
|
|
44
|
+
await addFile(packer, resolvedPath, tarPath, resolvedStat);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else if (entry.isDirectory()) {
|
|
48
|
+
await addDirectory(packer, fullPath, tarPath);
|
|
49
|
+
}
|
|
50
|
+
else if (entry.isFile()) {
|
|
51
|
+
const fileStat = await lstat(fullPath);
|
|
52
|
+
await addFile(packer, fullPath, tarPath, fileStat);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
async function addFile(packer, fsPath, tarPath, fileStat) {
|
|
57
|
+
const content = await readFile(fsPath);
|
|
58
|
+
packer.entry({
|
|
59
|
+
name: tarPath,
|
|
60
|
+
size: content.length,
|
|
61
|
+
mode: fileStat.mode,
|
|
62
|
+
mtime: fileStat.mtime,
|
|
63
|
+
}, content);
|
|
64
|
+
}
|
|
65
|
+
function collectGzipped(packer) {
|
|
66
|
+
return new Promise((resolve, reject) => {
|
|
67
|
+
const chunks = [];
|
|
68
|
+
const gzip = createGzip();
|
|
69
|
+
packer.pipe(gzip);
|
|
70
|
+
gzip.on("data", (chunk) => {
|
|
71
|
+
chunks.push(chunk);
|
|
72
|
+
});
|
|
73
|
+
gzip.on("end", () => {
|
|
74
|
+
resolve(Buffer.concat(chunks));
|
|
75
|
+
});
|
|
76
|
+
gzip.on("error", reject);
|
|
77
|
+
packer.on("error", reject);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=archive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"archive.js","sourceRoot":"","sources":["../src/archive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAa,IAAI,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,wBAAwB,GAAG,GAAY,CAAC;AAE9C;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,SAAiB,EACjB,UAAkB;IAElB,MAAM,MAAM,GAAG,IAAI,EAAE,CAAC;IAEtB,uCAAuC;IACvC,MAAM,YAAY,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;IAEhD,2CAA2C;IAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAC7B;QACE,eAAe,EAAE,wBAAwB;QACzC,UAAU,EAAE,UAAU,UAAU,EAAE;KACnC,EACD,IAAI,EACJ,CAAC,CACF,CAAC;IACF,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,uBAAuB,EAAE,EAAE,QAAQ,CAAC,CAAC;IAE1D,wBAAwB;IACxB,MAAM,CAAC,QAAQ,EAAE,CAAC;IAElB,4CAA4C;IAC5C,OAAO,MAAM,cAAc,CAAC,MAAM,CAAC,CAAC;AACtC,CAAC;AAED,KAAK,UAAU,YAAY,CACzB,MAAY,EACZ,MAAc,EACd,SAAiB;IAEjB,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,MAAM,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAE/D,KAAK,MAAM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;IACvC,MAAM,CAAC,KAAK,CACV;QACE,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,OAAO,CAAC,MAAM;QACpB,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,KAAK,EAAE,QAAQ,CAAC,KAAK;KACtB,EACD,OAAO,CACR,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,MAAY;IAClC,OAAO,IAAI,OAAO,CAAa,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACjD,MAAM,MAAM,GAAa,EAAE,CAAC;QAC5B,MAAM,IAAI,GAAG,UAAU,EAAE,CAAC;QAE1B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAElB,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE;YAChC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;YAClB,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACzB,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The result of executing a build strategy.
|
|
3
|
+
*/
|
|
4
|
+
export interface BuildArtifact {
|
|
5
|
+
/** Absolute path to the directory containing the built files. */
|
|
6
|
+
directory: string;
|
|
7
|
+
/** Entrypoint file path, relative to `directory`, using posix separators. */
|
|
8
|
+
entrypoint: string;
|
|
9
|
+
/**
|
|
10
|
+
* Optional cleanup callback. Called by the core after the archive has been
|
|
11
|
+
* created and the artifact directory is no longer needed. Strategies that
|
|
12
|
+
* create temporary output directories (e.g., BunBuild) use this to clean up.
|
|
13
|
+
*/
|
|
14
|
+
cleanup?(): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A build strategy produces a deployable artifact.
|
|
18
|
+
*/
|
|
19
|
+
export interface BuildStrategy {
|
|
20
|
+
execute(): Promise<BuildArtifact>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Reads directly from a pre-built application directory without copying.
|
|
24
|
+
* Validates the entrypoint exists.
|
|
25
|
+
*/
|
|
26
|
+
export declare class PreBuilt implements BuildStrategy {
|
|
27
|
+
#private;
|
|
28
|
+
constructor(options: {
|
|
29
|
+
appPath: string;
|
|
30
|
+
entrypoint: string;
|
|
31
|
+
});
|
|
32
|
+
execute(): Promise<BuildArtifact>;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=build-strategy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-strategy.d.ts","sourceRoot":"","sources":["../src/build-strategy.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,iEAAiE;IACjE,SAAS,EAAE,MAAM,CAAC;IAElB,6EAA6E;IAC7E,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;OAIG;IACH,OAAO,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,OAAO,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;CACnC;AAED;;;GAGG;AACH,qBAAa,QAAS,YAAW,aAAa;;gBAIhC,OAAO,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE;IAKtD,OAAO,IAAI,OAAO,CAAC,aAAa,CAAC;CAwBxC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { stat } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
/**
|
|
4
|
+
* Reads directly from a pre-built application directory without copying.
|
|
5
|
+
* Validates the entrypoint exists.
|
|
6
|
+
*/
|
|
7
|
+
export class PreBuilt {
|
|
8
|
+
#appPath;
|
|
9
|
+
#entrypoint;
|
|
10
|
+
constructor(options) {
|
|
11
|
+
this.#appPath = options.appPath;
|
|
12
|
+
this.#entrypoint = options.entrypoint;
|
|
13
|
+
}
|
|
14
|
+
async execute() {
|
|
15
|
+
const normalized = path.normalize(this.#entrypoint);
|
|
16
|
+
if (path.isAbsolute(normalized)) {
|
|
17
|
+
throw new Error("Entrypoint must be a relative path");
|
|
18
|
+
}
|
|
19
|
+
if (normalized.startsWith("..")) {
|
|
20
|
+
throw new Error("Entrypoint must not escape the application directory");
|
|
21
|
+
}
|
|
22
|
+
const fullPath = path.join(this.#appPath, normalized);
|
|
23
|
+
const stats = await stat(fullPath).catch(() => null);
|
|
24
|
+
if (!stats?.isFile()) {
|
|
25
|
+
throw new Error(`Entrypoint not found in pre-built artifact: ${this.#entrypoint}`);
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
directory: this.#appPath,
|
|
29
|
+
entrypoint: normalized.split(path.sep).join("/"),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=build-strategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-strategy.js","sourceRoot":"","sources":["../src/build-strategy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,IAAI,MAAM,WAAW,CAAC;AA2B7B;;;GAGG;AACH,MAAM,OAAO,QAAQ;IACV,QAAQ,CAAS;IACjB,WAAW,CAAS;IAE7B,YAAY,OAAgD;QAC1D,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;QAChC,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,OAAO;QACX,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAEpD,IAAI,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;QACxD,CAAC;QAED,IAAI,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;QAC1E,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;QACtD,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;QACrD,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CACb,+CAA+C,IAAI,CAAC,WAAW,EAAE,CAClE,CAAC;QACJ,CAAC;QAED,OAAO;YACL,SAAS,EAAE,IAAI,CAAC,QAAQ;YACxB,UAAU,EAAE,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;SACjD,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { BuildArtifact, BuildStrategy } from "./build-strategy.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Build strategy that runs `bun build` CLI and manages its own temp output directory.
|
|
4
|
+
* Owns entrypoint resolution from explicit arg or package.json main field.
|
|
5
|
+
*/
|
|
6
|
+
export declare class BunBuild implements BuildStrategy {
|
|
7
|
+
#private;
|
|
8
|
+
constructor(options: {
|
|
9
|
+
appPath: string;
|
|
10
|
+
entrypoint?: string;
|
|
11
|
+
});
|
|
12
|
+
execute(): Promise<BuildArtifact>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=bun-build.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bun-build.d.ts","sourceRoot":"","sources":["../src/bun-build.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAExE;;;GAGG;AACH,qBAAa,QAAS,YAAW,aAAa;;gBAIhC,OAAO,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE;IAKvD,OAAO,IAAI,OAAO,CAAC,aAAa,CAAC;CA6JxC"}
|