@catamorphic/fastify-plugin 0.1.0-alpha.42 → 0.1.0-alpha.43

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/dist/index.js CHANGED
@@ -454,8 +454,11 @@ var PublishedRevisionSchema = z.object({
454
454
  "superseded",
455
455
  "failed"
456
456
  ]),
457
- deployWorkflow: z.string().nullable(),
458
- deployRunId: z.string().uuid().nullable(),
457
+ deployEventId: z.string().uuid().nullable(),
458
+ deployRuns: z.array(z.object({
459
+ workflowName: z.string(),
460
+ runId: z.string().uuid().nullable()
461
+ })),
459
462
  previousCommitSha: z.string().nullable(),
460
463
  error: z.string().nullable(),
461
464
  report: z.array(z.object({
@@ -1853,7 +1856,12 @@ var TurnAttemptsSchema = z.object({
1853
1856
  completedAt: z.string().nullable(),
1854
1857
  progressAt: z.string().nullable(),
1855
1858
  stalledAt: z.string().nullable(),
1856
- diagnostics: z.object({ runner: z.string(), harness: z.string() }).nullable()
1859
+ diagnostics: z.object({ runner: z.string(), harness: z.string() }).nullable(),
1860
+ phases: z.array(z.object({
1861
+ phase: z.string(),
1862
+ startedAt: z.string(),
1863
+ endedAt: z.string().nullable()
1864
+ }))
1857
1865
  }))
1858
1866
  });
1859
1867
  var TurnIdParamsSchema = z.object({
@@ -6231,6 +6239,9 @@ function registerEnvironmentRoutes(app, ctx) {
6231
6239
 
6232
6240
  // src/routes/git-gateway.ts
6233
6241
  import { Readable } from "node:stream";
6242
+ import {
6243
+ checkoutTarget
6244
+ } from "@catamorphic/core";
6234
6245
  function registerGitGatewayRoutes(app, ctx) {
6235
6246
  app.register(async (git) => {
6236
6247
  git.removeAllContentTypeParsers();
@@ -6241,8 +6252,44 @@ function registerGitGatewayRoutes(app, ctx) {
6241
6252
  };
6242
6253
  git.get("/gateway/git/:alias/*", options, (request, reply) => serve(ctx, request, reply, "GET"));
6243
6254
  git.post("/gateway/git/:alias/*", options, (request, reply) => serve(ctx, request, reply, "POST"));
6255
+ git.get("/gateway/checkout/*", options, (request, reply) => serveCheckout(ctx, request, reply, "GET"));
6256
+ git.post("/gateway/checkout/*", options, (request, reply) => serveCheckout(ctx, request, reply, "POST"));
6244
6257
  });
6245
6258
  }
6259
+ async function serveCheckout(ctx, request, reply, method) {
6260
+ const checkouts = ctx.core?.workspaceCheckouts;
6261
+ if (!checkouts)
6262
+ return reply.status(404).type("text/plain").send(`This host serves no checkouts
6263
+ `);
6264
+ const params = request.params;
6265
+ const query = request.query;
6266
+ const target = checkoutTarget({
6267
+ method,
6268
+ path: params["*"] ?? "",
6269
+ service: query.service
6270
+ });
6271
+ if (!target)
6272
+ return reply.status(404).type("text/plain").send(`Not a Git request
6273
+ `);
6274
+ const headers = {};
6275
+ for (const [name, value] of Object.entries(request.headers))
6276
+ headers[name] = Array.isArray(value) ? value.join(", ") : value;
6277
+ return send(reply, method, await checkouts.handle({
6278
+ id: target.id,
6279
+ operation: target.operation,
6280
+ authorization: headers.authorization,
6281
+ headers,
6282
+ ...method === "POST" ? { body: request.raw } : {}
6283
+ }));
6284
+ }
6285
+ function send(reply, method, response) {
6286
+ reply.status(response.status);
6287
+ for (const [name, value] of Object.entries(response.headers))
6288
+ reply.header(name, value);
6289
+ if (method === "POST" && response.status >= 400)
6290
+ reply.header("connection", "close");
6291
+ return reply.send(response.body instanceof Uint8Array ? Buffer.from(response.body) : Readable.from(response.body));
6292
+ }
6246
6293
  async function serve(ctx, request, reply, method) {
6247
6294
  const gateway = ctx.core?.gitGateway;
6248
6295
  if (!gateway)
@@ -6259,20 +6306,14 @@ async function serve(ctx, request, reply, method) {
6259
6306
  const headers = {};
6260
6307
  for (const [name, value] of Object.entries(request.headers))
6261
6308
  headers[name] = Array.isArray(value) ? value.join(", ") : value;
6262
- const response = await gateway.handle({
6309
+ return send(reply, method, await gateway.handle({
6263
6310
  alias,
6264
6311
  repositoryPath: target.repositoryPath,
6265
6312
  operation: target.operation,
6266
6313
  authorization: headers.authorization,
6267
6314
  headers,
6268
6315
  ...method === "POST" ? { body: request.raw } : {}
6269
- });
6270
- reply.status(response.status);
6271
- for (const [name, value] of Object.entries(response.headers))
6272
- reply.header(name, value);
6273
- if (method === "POST" && response.status >= 400)
6274
- reply.header("connection", "close");
6275
- return reply.send(response.body instanceof Uint8Array ? Buffer.from(response.body) : Readable.from(response.body));
6316
+ }));
6276
6317
  }
6277
6318
  function gitTarget(input) {
6278
6319
  const path = input.path.replace(/\/+$/, "");
@@ -6338,7 +6379,7 @@ function routeTarget(request) {
6338
6379
  ...query ? { query } : {}
6339
6380
  };
6340
6381
  }
6341
- function send(reply, response) {
6382
+ function send2(reply, response) {
6342
6383
  reply.status(response.status);
6343
6384
  for (const [name, value] of Object.entries(response.headers))
6344
6385
  reply.header(name, value);
@@ -6356,7 +6397,7 @@ async function admit(ctx, request, reply) {
6356
6397
  if ("admitted" in result)
6357
6398
  return;
6358
6399
  reply.header("connection", "close");
6359
- return send(reply, result.refused);
6400
+ return send2(reply, result.refused);
6360
6401
  }
6361
6402
  async function serve2(ctx, request, reply) {
6362
6403
  const gateway = ctx.core?.httpGateway;
@@ -6370,7 +6411,7 @@ async function serve2(ctx, request, reply) {
6370
6411
  body: new Uint8Array(request.body.buffer, request.body.byteOffset, request.body.byteLength)
6371
6412
  } : {}
6372
6413
  });
6373
- return send(reply, response);
6414
+ return send2(reply, response);
6374
6415
  }
6375
6416
 
6376
6417
  // src/routes/me.ts
@@ -6630,7 +6671,7 @@ function routeTarget2(request) {
6630
6671
  ...query ? { query } : {}
6631
6672
  };
6632
6673
  }
6633
- function send2(reply, response) {
6674
+ function send3(reply, response) {
6634
6675
  reply.status(response.status);
6635
6676
  for (const [name, value] of Object.entries(response.headers))
6636
6677
  reply.header(name, value);
@@ -6649,7 +6690,7 @@ async function admit2(ctx, request, reply) {
6649
6690
  if ("admitted" in result)
6650
6691
  return;
6651
6692
  reply.header("connection", "close");
6652
- return send2(reply, result.refused);
6693
+ return send3(reply, result.refused);
6653
6694
  }
6654
6695
  async function serve3(ctx, request, reply) {
6655
6696
  const gateway = ctx.core?.modelGateway;
@@ -6663,7 +6704,7 @@ async function serve3(ctx, request, reply) {
6663
6704
  body: new Uint8Array(request.body.buffer, request.body.byteOffset, request.body.byteLength)
6664
6705
  } : {}
6665
6706
  });
6666
- return send2(reply, response);
6707
+ return send3(reply, response);
6667
6708
  }
6668
6709
 
6669
6710
  // src/routes/notifications.ts
@@ -11405,7 +11446,7 @@ async function serve4(ctx, request, reply) {
11405
11446
  } : {}
11406
11447
  });
11407
11448
  reply.removeHeader(PREVIEW_REFUSAL_HEADER);
11408
- return send3({ reply, response, prefix: target.prefix, port });
11449
+ return send4({ reply, response, prefix: target.prefix, port });
11409
11450
  } catch (error) {
11410
11451
  if (error instanceof SessionPreviewError)
11411
11452
  return reply.status(error.reason === "invalid" ? 400 : 502).send({ error: error.message, code: error.reason });
@@ -11455,7 +11496,7 @@ function requestHeaderPairs(request) {
11455
11496
  }
11456
11497
  return pairs;
11457
11498
  }
11458
- function send3(input) {
11499
+ function send4(input) {
11459
11500
  const { reply, response } = input;
11460
11501
  reply.status(response.status);
11461
11502
  const grouped = new Map;
@@ -12398,5 +12439,5 @@ export {
12398
12439
  serveSpaDist
12399
12440
  };
12400
12441
 
12401
- //# debugId=4D3EA05EB4E27D3164756E2164756E21
12442
+ //# debugId=5480BA3A186A01A664756E2164756E21
12402
12443
  //# sourceMappingURL=index.js.map