openship 0.2.3 → 0.4.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 (82) hide show
  1. package/README.md +104 -61
  2. package/dist/bare-ITM45QBX.js +18 -0
  3. package/dist/bowser-MFQA6OS4.js +2821 -0
  4. package/dist/chunk-3U4SPZD5.js +241 -0
  5. package/dist/chunk-46YJFP4S.js +1771 -0
  6. package/dist/chunk-4CQWT2WL.js +116 -0
  7. package/dist/chunk-4FABQGQP.js +23 -0
  8. package/dist/chunk-4LEL3H2Z.js +84 -0
  9. package/dist/chunk-4MG3BVHE.js +326 -0
  10. package/dist/chunk-4VNS5WPM.js +42 -0
  11. package/dist/chunk-5N7VUGL6.js +2094 -0
  12. package/dist/chunk-5ZCKQ2MI.js +1360 -0
  13. package/dist/chunk-6ERIMTBC.js +1412 -0
  14. package/dist/chunk-7UOB5GGQ.js +132 -0
  15. package/dist/chunk-BUBSSKO6.js +1384 -0
  16. package/dist/chunk-E6W2JMMU.js +341 -0
  17. package/dist/chunk-E77LJWJK.js +1535 -0
  18. package/dist/chunk-F4DFVG6Q.js +573 -0
  19. package/dist/chunk-HFYDYK4D.js +1092 -0
  20. package/dist/chunk-JR2OCMJA.js +46 -0
  21. package/dist/chunk-JUJBBF5U.js +746 -0
  22. package/dist/chunk-JZLNHGLW.js +19145 -0
  23. package/dist/chunk-KD7VO4LG.js +2617 -0
  24. package/dist/chunk-LBFH7THC.js +435 -0
  25. package/dist/chunk-NB2VEIWG.js +129 -0
  26. package/dist/chunk-OJE6YWPQ.js +2866 -0
  27. package/dist/chunk-QKFRZNKN.js +4941 -0
  28. package/dist/chunk-RBZPFTHV.js +13354 -0
  29. package/dist/chunk-S6DSRLNE.js +121 -0
  30. package/dist/chunk-TEYJYSMT.js +409 -0
  31. package/dist/chunk-U2DPZSXA.js +112 -0
  32. package/dist/chunk-WJPCBU7Z.js +3147 -0
  33. package/dist/chunk-XIFRMKYT.js +13 -0
  34. package/dist/chunk-XVSAUO2I.js +7946 -0
  35. package/dist/chunk-Y37KHU7L.js +31 -0
  36. package/dist/chunk-YL67EWYZ.js +416 -0
  37. package/dist/chunk-ZKJOFWBJ.js +1879 -0
  38. package/dist/cloud-JMPHO3CW.js +7 -0
  39. package/dist/cloud-W5G6YXAY.js +24 -0
  40. package/dist/dist-L3MPOWCA.js +65 -0
  41. package/dist/dist-es-4C322O5D.js +22 -0
  42. package/dist/dist-es-GTAMF674.js +87 -0
  43. package/dist/dist-es-KE56MWYO.js +169 -0
  44. package/dist/dist-es-NRZIQY5B.js +484 -0
  45. package/dist/dist-es-WZCR7DHQ.js +317 -0
  46. package/dist/dist-es-XQCOTGC7.js +376 -0
  47. package/dist/dist-es-ZW3HFQUM.js +69 -0
  48. package/dist/docker-3FVJMFC3.js +12 -0
  49. package/dist/docker-edge-executor-ZIWAZWPL.js +9 -0
  50. package/dist/edge-import-53M5DGWZ.js +39 -0
  51. package/dist/event-streams-7LGDL56D.js +42 -0
  52. package/dist/executor-J7BHW5HF.js +26 -0
  53. package/dist/index.js +2459 -3461
  54. package/dist/loadSso-N273C5I7.js +577 -0
  55. package/dist/nginx-YZWKYKQU.js +16 -0
  56. package/dist/noop-RRNCIUI5.js +7 -0
  57. package/dist/openresty-lua-HAO4EUDY.js +32 -0
  58. package/dist/server/index.js +217916 -205055
  59. package/dist/server/migrations/0057_complete_prism.sql +18 -0
  60. package/dist/server/migrations/0058_add_server_is_local.sql +1 -0
  61. package/dist/server/migrations/0059_legal_fixer.sql +18 -0
  62. package/dist/server/migrations/0060_add_route_strategy_host_port.sql +3 -0
  63. package/dist/server/migrations/0061_notification_default_multi_kind.sql +3 -0
  64. package/dist/server/migrations/0062_add_incoming_webhook.sql +21 -0
  65. package/dist/server/migrations/0063_add_migration_logs.sql +1 -0
  66. package/dist/server/migrations/0064_add_migration_partial.sql +2 -0
  67. package/dist/server/migrations/0065_custom_app_template.sql +14 -0
  68. package/dist/server/migrations/0066_ensure_migration_partial_columns.sql +2 -0
  69. package/dist/server/migrations/0067_webhook_delivery.sql +28 -0
  70. package/dist/server/migrations/0068_add_migration_target_volumes.sql +1 -0
  71. package/dist/server/migrations/0069_add_project_composite_routes.sql +1 -0
  72. package/dist/server/migrations/0070_forward_git_to_server.sql +1 -0
  73. package/dist/server/migrations/meta/0057_snapshot.json +9326 -0
  74. package/dist/server/migrations/meta/0058_snapshot.json +9333 -0
  75. package/dist/server/migrations/meta/0059_snapshot.json +9495 -0
  76. package/dist/server/migrations/meta/0060_snapshot.json +9515 -0
  77. package/dist/server/migrations/meta/_journal.json +99 -1
  78. package/dist/setup-5X3WEEHA.js +14 -0
  79. package/dist/signin-DR462ERO.js +663 -0
  80. package/dist/sso-oidc-VBZLJUK5.js +830 -0
  81. package/dist/sts-EJLZ4Z77.js +1422 -0
  82. package/package.json +6 -2
@@ -0,0 +1,435 @@
1
+ import {
2
+ HttpResponse,
3
+ buildQueryString
4
+ } from "./chunk-5N7VUGL6.js";
5
+
6
+ // ../../node_modules/@smithy/node-http-handler/dist-es/build-abort-error.js
7
+ function buildAbortError(abortSignal) {
8
+ const reason = abortSignal && typeof abortSignal === "object" && "reason" in abortSignal ? abortSignal.reason : void 0;
9
+ if (reason) {
10
+ if (reason instanceof Error) {
11
+ const abortError3 = new Error("Request aborted");
12
+ abortError3.name = "AbortError";
13
+ abortError3.cause = reason;
14
+ return abortError3;
15
+ }
16
+ const abortError2 = new Error(String(reason));
17
+ abortError2.name = "AbortError";
18
+ return abortError2;
19
+ }
20
+ const abortError = new Error("Request aborted");
21
+ abortError.name = "AbortError";
22
+ return abortError;
23
+ }
24
+
25
+ // ../../node_modules/@smithy/node-http-handler/dist-es/constants.js
26
+ var NODEJS_TIMEOUT_ERROR_CODES = ["ECONNRESET", "EPIPE", "ETIMEDOUT"];
27
+
28
+ // ../../node_modules/@smithy/node-http-handler/dist-es/get-transformed-headers.js
29
+ var getTransformedHeaders = (headers) => {
30
+ const transformedHeaders = {};
31
+ for (const name in headers) {
32
+ const headerValues = headers[name];
33
+ transformedHeaders[name] = Array.isArray(headerValues) ? headerValues.join(",") : headerValues;
34
+ }
35
+ return transformedHeaders;
36
+ };
37
+
38
+ // ../../node_modules/@smithy/node-http-handler/dist-es/node-https.js
39
+ import node_https from "https";
40
+
41
+ // ../../node_modules/@smithy/node-http-handler/dist-es/timing.js
42
+ var timing = {
43
+ setTimeout: (cb, ms) => setTimeout(cb, ms),
44
+ clearTimeout: (timeoutId) => clearTimeout(timeoutId)
45
+ };
46
+
47
+ // ../../node_modules/@smithy/node-http-handler/dist-es/set-connection-timeout.js
48
+ var DEFER_EVENT_LISTENER_TIME = 1e3;
49
+ var setConnectionTimeout = (request, reject, timeoutInMs = 0) => {
50
+ if (!timeoutInMs) {
51
+ return -1;
52
+ }
53
+ const registerTimeout = (offset) => {
54
+ const timeoutId = timing.setTimeout(() => {
55
+ request.destroy();
56
+ reject(Object.assign(new Error(`@smithy/node-http-handler - the request socket did not establish a connection with the server within the configured timeout of ${timeoutInMs} ms.`), {
57
+ name: "TimeoutError"
58
+ }));
59
+ }, timeoutInMs - offset);
60
+ const doWithSocket = (socket) => {
61
+ if (socket?.connecting) {
62
+ socket.on("connect", () => {
63
+ timing.clearTimeout(timeoutId);
64
+ });
65
+ } else {
66
+ timing.clearTimeout(timeoutId);
67
+ }
68
+ };
69
+ if (request.socket) {
70
+ doWithSocket(request.socket);
71
+ } else {
72
+ request.on("socket", doWithSocket);
73
+ }
74
+ };
75
+ if (timeoutInMs < 2e3) {
76
+ registerTimeout(0);
77
+ return 0;
78
+ }
79
+ return timing.setTimeout(registerTimeout.bind(null, DEFER_EVENT_LISTENER_TIME), DEFER_EVENT_LISTENER_TIME);
80
+ };
81
+
82
+ // ../../node_modules/@smithy/node-http-handler/dist-es/set-request-timeout.js
83
+ var setRequestTimeout = (req, reject, timeoutInMs = 0, throwOnRequestTimeout, logger) => {
84
+ if (timeoutInMs) {
85
+ return timing.setTimeout(() => {
86
+ let msg = `@smithy/node-http-handler - [${throwOnRequestTimeout ? "ERROR" : "WARN"}] a request has exceeded the configured ${timeoutInMs} ms requestTimeout.`;
87
+ if (throwOnRequestTimeout) {
88
+ const error = Object.assign(new Error(msg), {
89
+ name: "TimeoutError",
90
+ code: "ETIMEDOUT"
91
+ });
92
+ req.destroy(error);
93
+ reject(error);
94
+ } else {
95
+ msg += ` Init client requestHandler with throwOnRequestTimeout=true to turn this into an error.`;
96
+ logger?.warn?.(msg);
97
+ }
98
+ }, timeoutInMs);
99
+ }
100
+ return -1;
101
+ };
102
+
103
+ // ../../node_modules/@smithy/node-http-handler/dist-es/set-socket-keep-alive.js
104
+ var DEFER_EVENT_LISTENER_TIME2 = 3e3;
105
+ var setSocketKeepAlive = (request, { keepAlive, keepAliveMsecs }, deferTimeMs = DEFER_EVENT_LISTENER_TIME2) => {
106
+ if (keepAlive !== true) {
107
+ return -1;
108
+ }
109
+ const registerListener = () => {
110
+ if (request.socket) {
111
+ request.socket.setKeepAlive(keepAlive, keepAliveMsecs || 0);
112
+ } else {
113
+ request.on("socket", (socket) => {
114
+ socket.setKeepAlive(keepAlive, keepAliveMsecs || 0);
115
+ });
116
+ }
117
+ };
118
+ if (deferTimeMs === 0) {
119
+ registerListener();
120
+ return 0;
121
+ }
122
+ return timing.setTimeout(registerListener, deferTimeMs);
123
+ };
124
+
125
+ // ../../node_modules/@smithy/node-http-handler/dist-es/set-socket-timeout.js
126
+ var DEFER_EVENT_LISTENER_TIME3 = 3e3;
127
+ var setSocketTimeout = (request, reject, timeoutInMs = 0) => {
128
+ const registerTimeout = (offset) => {
129
+ const timeout = timeoutInMs - offset;
130
+ const onTimeout = () => {
131
+ request.destroy();
132
+ reject(Object.assign(new Error(`@smithy/node-http-handler - the request socket timed out after ${timeoutInMs} ms of inactivity (configured by client requestHandler).`), { name: "TimeoutError" }));
133
+ };
134
+ if (request.socket) {
135
+ request.socket.setTimeout(timeout, onTimeout);
136
+ request.on("close", () => request.socket?.removeListener("timeout", onTimeout));
137
+ } else {
138
+ request.setTimeout(timeout, onTimeout);
139
+ }
140
+ };
141
+ if (0 < timeoutInMs && timeoutInMs < 6e3) {
142
+ registerTimeout(0);
143
+ return 0;
144
+ }
145
+ return timing.setTimeout(registerTimeout.bind(null, timeoutInMs === 0 ? 0 : DEFER_EVENT_LISTENER_TIME3), DEFER_EVENT_LISTENER_TIME3);
146
+ };
147
+
148
+ // ../../node_modules/@smithy/node-http-handler/dist-es/write-request-body.js
149
+ import { Readable } from "stream";
150
+ var MIN_WAIT_TIME = 6e3;
151
+ async function writeRequestBody(httpRequest, request, maxContinueTimeoutMs = MIN_WAIT_TIME, externalAgent = false) {
152
+ const headers = request.headers;
153
+ const expect = headers ? headers.Expect || headers.expect : void 0;
154
+ let timeoutId = -1;
155
+ let sendBody = true;
156
+ if (!externalAgent && expect === "100-continue") {
157
+ sendBody = await Promise.race([
158
+ new Promise((resolve) => {
159
+ timeoutId = Number(timing.setTimeout(() => resolve(true), Math.max(MIN_WAIT_TIME, maxContinueTimeoutMs)));
160
+ }),
161
+ new Promise((resolve) => {
162
+ httpRequest.on("continue", () => {
163
+ timing.clearTimeout(timeoutId);
164
+ resolve(true);
165
+ });
166
+ httpRequest.on("response", () => {
167
+ timing.clearTimeout(timeoutId);
168
+ resolve(false);
169
+ });
170
+ httpRequest.on("error", () => {
171
+ timing.clearTimeout(timeoutId);
172
+ resolve(false);
173
+ });
174
+ })
175
+ ]);
176
+ }
177
+ if (sendBody) {
178
+ writeBody(httpRequest, request.body);
179
+ }
180
+ }
181
+ function writeBody(httpRequest, body) {
182
+ if (body instanceof Readable) {
183
+ body.pipe(httpRequest);
184
+ return;
185
+ }
186
+ if (body) {
187
+ const isBuffer = Buffer.isBuffer(body);
188
+ const isString = typeof body === "string";
189
+ if (isBuffer || isString) {
190
+ if (isBuffer && body.byteLength === 0) {
191
+ httpRequest.end();
192
+ } else {
193
+ httpRequest.end(body);
194
+ }
195
+ return;
196
+ }
197
+ const uint8 = body;
198
+ if (typeof uint8 === "object" && uint8.buffer && typeof uint8.byteOffset === "number" && typeof uint8.byteLength === "number") {
199
+ httpRequest.end(Buffer.from(uint8.buffer, uint8.byteOffset, uint8.byteLength));
200
+ return;
201
+ }
202
+ httpRequest.end(Buffer.from(body));
203
+ return;
204
+ }
205
+ httpRequest.end();
206
+ }
207
+
208
+ // ../../node_modules/@smithy/node-http-handler/dist-es/node-http-handler.js
209
+ var hAgent = void 0;
210
+ var hRequest = void 0;
211
+ var NodeHttpHandler = class _NodeHttpHandler {
212
+ config;
213
+ configProvider;
214
+ socketWarningTimestamp = 0;
215
+ externalAgent = false;
216
+ metadata = { handlerProtocol: "http/1.1" };
217
+ static create(instanceOrOptions) {
218
+ if (typeof instanceOrOptions?.handle === "function") {
219
+ return instanceOrOptions;
220
+ }
221
+ return new _NodeHttpHandler(instanceOrOptions);
222
+ }
223
+ static checkSocketUsage(agent, socketWarningTimestamp, logger = console) {
224
+ const { sockets, requests, maxSockets } = agent;
225
+ if (typeof maxSockets !== "number" || maxSockets === Infinity) {
226
+ return socketWarningTimestamp;
227
+ }
228
+ const interval = 15e3;
229
+ if (Date.now() - interval < socketWarningTimestamp) {
230
+ return socketWarningTimestamp;
231
+ }
232
+ if (sockets && requests) {
233
+ for (const origin in sockets) {
234
+ const socketsInUse = sockets[origin]?.length ?? 0;
235
+ const requestsEnqueued = requests[origin]?.length ?? 0;
236
+ if (socketsInUse >= maxSockets && requestsEnqueued >= 2 * maxSockets) {
237
+ logger?.warn?.(`@smithy/node-http-handler:WARN - socket usage at capacity=${socketsInUse} and ${requestsEnqueued} additional requests are enqueued.
238
+ See https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/node-configuring-maxsockets.html
239
+ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler config.`);
240
+ return Date.now();
241
+ }
242
+ }
243
+ }
244
+ return socketWarningTimestamp;
245
+ }
246
+ constructor(options) {
247
+ this.configProvider = new Promise((resolve, reject) => {
248
+ if (typeof options === "function") {
249
+ options().then((_options) => {
250
+ resolve(this.resolveDefaultConfig(_options));
251
+ }).catch(reject);
252
+ } else {
253
+ resolve(this.resolveDefaultConfig(options));
254
+ }
255
+ });
256
+ }
257
+ destroy() {
258
+ this.config?.httpAgent?.destroy();
259
+ this.config?.httpsAgent?.destroy();
260
+ }
261
+ async handle(request, { abortSignal, requestTimeout } = {}) {
262
+ if (!this.config) {
263
+ this.config = await this.configProvider;
264
+ }
265
+ const config = this.config;
266
+ const isSSL = request.protocol === "https:";
267
+ if (!isSSL && !this.config.httpAgent) {
268
+ this.config.httpAgent = await this.config.httpAgentProvider();
269
+ }
270
+ return new Promise((_resolve, _reject) => {
271
+ let writeRequestBodyPromise = void 0;
272
+ let socketWarningTimeoutId = -1;
273
+ let connectionTimeoutId = -1;
274
+ let requestTimeoutId = -1;
275
+ let socketTimeoutId = -1;
276
+ let keepAliveTimeoutId = -1;
277
+ const clearTimeouts = () => {
278
+ timing.clearTimeout(socketWarningTimeoutId);
279
+ timing.clearTimeout(connectionTimeoutId);
280
+ timing.clearTimeout(requestTimeoutId);
281
+ timing.clearTimeout(socketTimeoutId);
282
+ timing.clearTimeout(keepAliveTimeoutId);
283
+ };
284
+ const resolve = async (arg) => {
285
+ await writeRequestBodyPromise;
286
+ clearTimeouts();
287
+ _resolve(arg);
288
+ };
289
+ const reject = async (arg) => {
290
+ await writeRequestBodyPromise;
291
+ clearTimeouts();
292
+ _reject(arg);
293
+ };
294
+ if (abortSignal?.aborted) {
295
+ const abortError = buildAbortError(abortSignal);
296
+ reject(abortError);
297
+ return;
298
+ }
299
+ const headers = request.headers;
300
+ const expectContinue = headers ? (headers.Expect ?? headers.expect) === "100-continue" : false;
301
+ let agent = isSSL ? config.httpsAgent : config.httpAgent;
302
+ if (expectContinue && !this.externalAgent) {
303
+ agent = new (isSSL ? node_https.Agent : hAgent)({
304
+ keepAlive: false,
305
+ maxSockets: Infinity
306
+ });
307
+ }
308
+ socketWarningTimeoutId = timing.setTimeout(() => {
309
+ this.socketWarningTimestamp = _NodeHttpHandler.checkSocketUsage(agent, this.socketWarningTimestamp, config.logger);
310
+ }, config.socketAcquisitionWarningTimeout ?? (config.requestTimeout ?? 2e3) + (config.connectionTimeout ?? 1e3));
311
+ const queryString = request.query ? buildQueryString(request.query) : "";
312
+ let auth = void 0;
313
+ if (request.username != null || request.password != null) {
314
+ const username = request.username ?? "";
315
+ const password = request.password ?? "";
316
+ auth = `${username}:${password}`;
317
+ }
318
+ let path = request.path;
319
+ if (queryString) {
320
+ path += `?${queryString}`;
321
+ }
322
+ if (request.fragment) {
323
+ path += `#${request.fragment}`;
324
+ }
325
+ let hostname = request.hostname ?? "";
326
+ if (hostname[0] === "[" && hostname.endsWith("]")) {
327
+ hostname = request.hostname.slice(1, -1);
328
+ } else {
329
+ hostname = request.hostname;
330
+ }
331
+ const nodeHttpsOptions = {
332
+ headers: request.headers,
333
+ host: hostname,
334
+ method: request.method,
335
+ path,
336
+ port: request.port,
337
+ agent,
338
+ auth
339
+ };
340
+ const requestFunc = isSSL ? node_https.request : hRequest;
341
+ const req = requestFunc(nodeHttpsOptions, (res) => {
342
+ const httpResponse = new HttpResponse({
343
+ statusCode: res.statusCode || -1,
344
+ reason: res.statusMessage,
345
+ headers: getTransformedHeaders(res.headers),
346
+ body: res
347
+ });
348
+ resolve({ response: httpResponse });
349
+ });
350
+ req.on("error", (err) => {
351
+ if (NODEJS_TIMEOUT_ERROR_CODES.includes(err.code)) {
352
+ reject(Object.assign(err, { name: "TimeoutError" }));
353
+ } else {
354
+ reject(err);
355
+ }
356
+ });
357
+ if (abortSignal) {
358
+ const onAbort = () => {
359
+ req.destroy();
360
+ const abortError = buildAbortError(abortSignal);
361
+ reject(abortError);
362
+ };
363
+ if (typeof abortSignal.addEventListener === "function") {
364
+ const signal = abortSignal;
365
+ signal.addEventListener("abort", onAbort, { once: true });
366
+ req.once("close", () => signal.removeEventListener("abort", onAbort));
367
+ } else {
368
+ abortSignal.onabort = onAbort;
369
+ }
370
+ }
371
+ const effectiveRequestTimeout = requestTimeout ?? config.requestTimeout;
372
+ connectionTimeoutId = setConnectionTimeout(req, reject, config.connectionTimeout);
373
+ requestTimeoutId = setRequestTimeout(req, reject, effectiveRequestTimeout, config.throwOnRequestTimeout, config.logger ?? console);
374
+ socketTimeoutId = setSocketTimeout(req, reject, config.socketTimeout);
375
+ const httpAgent = nodeHttpsOptions.agent;
376
+ if (typeof httpAgent === "object" && "keepAlive" in httpAgent) {
377
+ keepAliveTimeoutId = setSocketKeepAlive(req, {
378
+ keepAlive: httpAgent.keepAlive,
379
+ keepAliveMsecs: httpAgent.keepAliveMsecs
380
+ });
381
+ }
382
+ writeRequestBodyPromise = writeRequestBody(req, request, effectiveRequestTimeout, this.externalAgent).catch((e) => {
383
+ clearTimeouts();
384
+ return _reject(e);
385
+ });
386
+ });
387
+ }
388
+ updateHttpClientConfig(key, value) {
389
+ this.config = void 0;
390
+ this.configProvider = this.configProvider.then((config) => {
391
+ return {
392
+ ...config,
393
+ [key]: value
394
+ };
395
+ });
396
+ }
397
+ httpHandlerConfigs() {
398
+ return this.config ?? {};
399
+ }
400
+ resolveDefaultConfig(options) {
401
+ const { requestTimeout, connectionTimeout, socketTimeout, socketAcquisitionWarningTimeout, httpAgent, httpsAgent, throwOnRequestTimeout, logger } = options || {};
402
+ const keepAlive = true;
403
+ const maxSockets = 50;
404
+ return {
405
+ connectionTimeout,
406
+ requestTimeout,
407
+ socketTimeout,
408
+ socketAcquisitionWarningTimeout,
409
+ throwOnRequestTimeout,
410
+ httpAgentProvider: async () => {
411
+ const node_http = await import("http");
412
+ const { Agent, request } = node_http.default ?? node_http;
413
+ hRequest = request;
414
+ hAgent = Agent;
415
+ if (httpAgent instanceof hAgent || typeof httpAgent?.destroy === "function") {
416
+ this.externalAgent = true;
417
+ return httpAgent;
418
+ }
419
+ return new hAgent({ keepAlive, maxSockets, ...httpAgent });
420
+ },
421
+ httpsAgent: (() => {
422
+ if (httpsAgent instanceof node_https.Agent || typeof httpsAgent?.destroy === "function") {
423
+ this.externalAgent = true;
424
+ return httpsAgent;
425
+ }
426
+ return new node_https.Agent({ keepAlive, maxSockets, ...httpsAgent });
427
+ })(),
428
+ logger
429
+ };
430
+ }
431
+ };
432
+
433
+ export {
434
+ NodeHttpHandler
435
+ };
@@ -0,0 +1,129 @@
1
+ import {
2
+ detectBuildKillHint,
3
+ runBuildPipeline,
4
+ transferLocalDirectory
5
+ } from "./chunk-YL67EWYZ.js";
6
+ import {
7
+ LocalExecutor
8
+ } from "./chunk-U2DPZSXA.js";
9
+ import {
10
+ wrapLocalBuildCommand
11
+ } from "./chunk-4CQWT2WL.js";
12
+
13
+ // ../../packages/adapters/src/runtime/local-build.ts
14
+ var LOCAL_BUILD_DIR = "/tmp/openship/.builds";
15
+ async function runLocalBuild(opts) {
16
+ const { config, logger, abort } = opts;
17
+ const localExec = new LocalExecutor();
18
+ const buildDir = `${LOCAL_BUILD_DIR}/${config.sessionId}`;
19
+ await localExec.rm(buildDir);
20
+ await localExec.mkdir(buildDir);
21
+ const buildEnv = {
22
+ projectDir: buildDir,
23
+ exec: async (command, logCb) => {
24
+ if (abort?.aborted) throw new Error("Build cancelled");
25
+ const { code, output } = await localExec.streamExec(wrapLocalBuildCommand(command), logCb);
26
+ if (abort?.aborted) throw new Error("Build cancelled");
27
+ if (code !== 0) {
28
+ const hint = detectBuildKillHint(output);
29
+ throw new Error(
30
+ `Command failed with exit code ${code}${hint ? ` - ${hint}` : ""}`
31
+ );
32
+ }
33
+ },
34
+ preflight: async (cfg, plog) => {
35
+ if (abort?.aborted) throw new Error("Build cancelled");
36
+ if (opts.preflight) {
37
+ await opts.preflight(cfg, plog, localExec);
38
+ }
39
+ if (cfg.localPath) {
40
+ await transferLocalDirectory(
41
+ cfg.localPath,
42
+ {
43
+ kind: "executor",
44
+ executor: localExec,
45
+ path: buildDir
46
+ },
47
+ plog
48
+ );
49
+ }
50
+ }
51
+ };
52
+ try {
53
+ const result = await runBuildPipeline(buildEnv, config, logger);
54
+ if (result.status === "deploying") {
55
+ await opts.transferOutput(buildDir);
56
+ }
57
+ return result;
58
+ } finally {
59
+ await localExec.rm(buildDir).catch(() => {
60
+ });
61
+ await localExec.dispose();
62
+ }
63
+ }
64
+
65
+ // ../../packages/adapters/src/runtime/stack-output.ts
66
+ import { join as join2, posix as pathPosix } from "path";
67
+
68
+ // ../../packages/adapters/src/runtime/nextjs-standalone.ts
69
+ import { cp, stat } from "fs/promises";
70
+ import { join } from "path";
71
+ async function exists(p) {
72
+ try {
73
+ await stat(p);
74
+ return true;
75
+ } catch {
76
+ return false;
77
+ }
78
+ }
79
+ async function prepareNextStandalone(projectDir) {
80
+ const bundleDir = join(projectDir, ".next", "standalone");
81
+ if (!await exists(join(bundleDir, "server.js"))) return null;
82
+ const staticSrc = join(projectDir, ".next", "static");
83
+ if (await exists(staticSrc)) {
84
+ await cp(staticSrc, join(bundleDir, ".next", "static"), { recursive: true });
85
+ }
86
+ const publicSrc = join(projectDir, "public");
87
+ if (await exists(publicSrc)) {
88
+ await cp(publicSrc, join(bundleDir, "public"), { recursive: true });
89
+ }
90
+ return { bundleDir, startCommand: "node server.js" };
91
+ }
92
+
93
+ // ../../packages/adapters/src/runtime/stack-output.ts
94
+ var STACK_OUTPUT_PREPARERS = {
95
+ nextjs: prepareNextStandalone
96
+ };
97
+ async function prepareStackOutput(stack, projectDir) {
98
+ const prepare = STACK_OUTPUT_PREPARERS[stack];
99
+ return prepare ? prepare(projectDir) : null;
100
+ }
101
+ function resolveProjectDir(buildDir, rootDirectory) {
102
+ const normalized = rootDirectory?.trim().replace(/^\/+|\/+$/g, "");
103
+ return normalized ? join2(buildDir, normalized) : buildDir;
104
+ }
105
+ function resolveStaticOutputPath(base, outputDirectory) {
106
+ const normalizedBase = base.replace(/\/+$/, "");
107
+ if (!outputDirectory || outputDirectory === ".") {
108
+ return normalizedBase;
109
+ }
110
+ if (outputDirectory.startsWith("/")) {
111
+ throw new Error(
112
+ `Invalid outputDirectory "${outputDirectory}": must be relative to the project (absolute paths are not allowed).`
113
+ );
114
+ }
115
+ const resolved = pathPosix.normalize(pathPosix.join(normalizedBase, outputDirectory));
116
+ if (resolved !== normalizedBase && !resolved.startsWith(`${normalizedBase}/`)) {
117
+ throw new Error(
118
+ `Invalid outputDirectory "${outputDirectory}": escapes the deployment directory.`
119
+ );
120
+ }
121
+ return resolved;
122
+ }
123
+
124
+ export {
125
+ runLocalBuild,
126
+ prepareStackOutput,
127
+ resolveProjectDir,
128
+ resolveStaticOutputPath
129
+ };