@valbuild/shared 0.136.10 → 0.138.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.
@@ -1503,6 +1503,28 @@ var GenericError = zod.z.object({
1503
1503
  message: zod.z.string()
1504
1504
  });
1505
1505
 
1506
+ /**
1507
+ * What answered when one URL was opened.
1508
+ *
1509
+ * The one place the Studio's `ExternalUrlProbeResult` and the server's
1510
+ * `ProbeResult` meet, so the two cannot drift without this failing to parse.
1511
+ */
1512
+ var ExternalUrlProbeResult = zod.z.union([zod.z.object({
1513
+ kind: zod.z.literal("answered"),
1514
+ code: zod.z.number(),
1515
+ finalUrl: zod.z.string(),
1516
+ ms: zod.z.number()
1517
+ }), zod.z.object({
1518
+ kind: zod.z.literal("unreachable"),
1519
+ message: zod.z.string()
1520
+ }), zod.z.object({
1521
+ kind: zod.z.literal("timeout"),
1522
+ ms: zod.z.number()
1523
+ }), zod.z.object({
1524
+ kind: zod.z.literal("skipped"),
1525
+ message: zod.z.string()
1526
+ })]);
1527
+
1506
1528
  /**
1507
1529
  * Why a publish cannot happen, in a form the Studio can show.
1508
1530
  *
@@ -1941,6 +1963,13 @@ var Api = {
1941
1963
  * which is the one the Studio has always told.
1942
1964
  */
1943
1965
  sourceMode: zod.z.union([zod.z.literal("managed"), zod.z.literal("connected")]).optional(),
1966
+ /**
1967
+ * A press of Publish is a publish JOB: every managed project,
1968
+ * and a connected one hosted on the platform. Absent from a
1969
+ * server that predates it: managed projects publish as jobs,
1970
+ * connected ones by commit.
1971
+ */
1972
+ publishJobs: zod.z["boolean"]().optional(),
1944
1973
  publishRefusal: PublishRefusal.optional()
1945
1974
  }), zod.z.object({
1946
1975
  type: zod.z.literal("use-websocket"),
@@ -1991,6 +2020,13 @@ var Api = {
1991
2020
  * content service that predates it sends nothing.
1992
2021
  */
1993
2022
  headPatchId: PatchId.nullable().optional(),
2023
+ /**
2024
+ * The version of the chain `headPatchId` was read at, bumped by
2025
+ * every write and delete. `/stat` has more than one caller, so
2026
+ * answers can land out of order; a client keeps the head with the
2027
+ * highest version. Optional, for the same reason `headPatchId` is.
2028
+ */
2029
+ headVersion: zod.z.number().optional(),
1994
2030
  commits: zod.z.array(ValCommit),
1995
2031
  /**
1996
2032
  * The publishes the content service knows about.
@@ -2031,6 +2067,13 @@ var Api = {
2031
2067
  * which is the one the Studio has always told.
2032
2068
  */
2033
2069
  sourceMode: zod.z.union([zod.z.literal("managed"), zod.z.literal("connected")]).optional(),
2070
+ /**
2071
+ * A press of Publish is a publish JOB: every managed project,
2072
+ * and a connected one hosted on the platform. Absent from a
2073
+ * server that predates it: managed projects publish as jobs,
2074
+ * connected ones by commit.
2075
+ */
2076
+ publishJobs: zod.z["boolean"]().optional(),
2034
2077
  publishRefusal: PublishRefusal.optional()
2035
2078
  })])
2036
2079
  })])
@@ -2144,6 +2187,42 @@ var Api = {
2144
2187
  })])
2145
2188
  }
2146
2189
  },
2190
+ /**
2191
+ * Open a batch of external URLs and report what answered.
2192
+ *
2193
+ * A batch rather than one URL because the client checks a list, and a POST
2194
+ * rather than a GET because the list is the input and does not belong in a
2195
+ * URL or a cache.
2196
+ *
2197
+ * The server makes outbound requests to addresses this body supplies, which
2198
+ * is SSRF by construction - see `linkCheck/addressGuard.ts` for the deny
2199
+ * list that makes it safe, and `docs/plans/external-page-link-checks.md` for
2200
+ * why it is a deny list on the RESOLVED address.
2201
+ */
2202
+ "/external-urls/check": {
2203
+ POST: {
2204
+ req: {
2205
+ body: zod.z.object({
2206
+ /*
2207
+ * Capped, and the cap is the point rather than a formality: each URL
2208
+ * is an outbound connection, and a body is not allowed to ask this
2209
+ * server to open a thousand of them. The client sends ten at a time.
2210
+ */
2211
+ urls: zod.z.array(zod.z.string()).min(1).max(20)
2212
+ }),
2213
+ cookies: {
2214
+ val_session: zod.z.string().optional()
2215
+ }
2216
+ },
2217
+ res: zod.z.union([unauthorizedResponse, zod.z.object({
2218
+ status: zod.z.literal(200),
2219
+ json: zod.z.object({
2220
+ /** Keyed by the URL exactly as it was asked about. */
2221
+ results: zod.z.record(zod.z.string(), ExternalUrlProbeResult)
2222
+ })
2223
+ })])
2224
+ }
2225
+ },
2147
2226
  "/direct-file-upload-settings": {
2148
2227
  POST: {
2149
2228
  req: {
@@ -2195,7 +2274,14 @@ var Api = {
2195
2274
  * groups, and a client that predates this is deleting correctly,
2196
2275
  * just not repairing.
2197
2276
  */
2198
- unstagePatchIds: zod.z.array(PatchId).optional()
2277
+ unstagePatchIds: zod.z.array(PatchId).optional(),
2278
+ /*
2279
+ * Answer with `{ deleted, headVersion }` rather than the bare id
2280
+ * array. Asked for rather than always sent, because the array is
2281
+ * what a Studio bundle from before this parses — and a tab left
2282
+ * open across a deploy still runs one.
2283
+ */
2284
+ reportHeadVersion: zod.z.literal(true).optional()
2199
2285
  }).optional(),
2200
2286
  cookies: {
2201
2287
  val_session: zod.z.string().optional()
@@ -2209,7 +2295,16 @@ var Api = {
2209
2295
  })
2210
2296
  }), zod.z.object({
2211
2297
  status: zod.z.literal(200),
2212
- json: zod.z.array(PatchId)
2298
+ json: zod.z.union([zod.z.array(PatchId), zod.z.object({
2299
+ deleted: zod.z.array(PatchId),
2300
+ /**
2301
+ * The chain version this delete moved the branch to. Absent when
2302
+ * it moved nothing, or the content service does not version its
2303
+ * chain. Compared with `headVersion` on `/stat`: an answer read
2304
+ * before the delete would put the deleted head back.
2305
+ */
2306
+ headVersion: zod.z.number().optional()
2307
+ })])
2213
2308
  })])
2214
2309
  },
2215
2310
  PUT: {
@@ -2257,7 +2352,14 @@ var Api = {
2257
2352
  json: zod.z.object({
2258
2353
  newPatchIds: zod.z.array(PatchId),
2259
2354
  parentRef: ParentRef,
2260
- patchGroupId: zod.z.string().optional()
2355
+ patchGroupId: zod.z.string().optional(),
2356
+ /**
2357
+ * The chain version the last of these patches made, comparable with
2358
+ * `headVersion` on `/stat`. A client keeps the highest version, so a
2359
+ * stat read before this write does not put its parent back behind
2360
+ * it. Absent in `fs` mode and from an older content service.
2361
+ */
2362
+ headVersion: zod.z.number().optional()
2261
2363
  })
2262
2364
  })])
2263
2365
  },
@@ -2513,39 +2615,49 @@ var Api = {
2513
2615
  })])
2514
2616
  }
2515
2617
  },
2516
- /**
2517
- * The `.val.ts` text of every module that changed since the RUNNING build,
2518
- * with every commit since it applied, for a build made in the browser.
2519
- *
2520
- * A Studio build starts from the source stored with the live build. A commit
2521
- * whose own publish failed -- or the first commit of a project that started
2522
- * as a copy of a template -- is in content and in no stored source, so a build
2523
- * that added only its own save's files shipped without it. Only this server
2524
- * can render those commits back into text: content keeps a managed project's
2525
- * content as Source, not as files.
2526
- *
2527
- * Committed patches only. A pending one is somebody's unpublished work, and
2528
- * is not this build's to ship. 409 where there is nothing to answer with: a
2529
- * project with a repository, or a build that did not embed its source.
2530
- */
2531
- "/built-source": {
2532
- GET: {
2618
+ "/publish-job-prepare": {
2619
+ POST: {
2533
2620
  req: {
2621
+ body: zod.z.object({
2622
+ jobId: zod.z.string().regex(/^[A-Za-z0-9_-]{1,100}$/),
2623
+ tab: zod.z.string().regex(/^[A-Za-z0-9_-]{1,100}$/),
2624
+ /** The job's changes, as content handed them to the tab. */
2625
+ patchIds: zod.z.array(PatchId)
2626
+ }),
2534
2627
  cookies: {
2535
2628
  val_session: zod.z.string().optional()
2536
2629
  }
2537
2630
  },
2538
2631
  res: zod.z.union([unauthorizedResponse, zod.z.object({
2632
+ status: zod.z.literal(400),
2633
+ json: GenericError
2634
+ }), zod.z.object({
2539
2635
  status: zod.z.literal(409),
2540
2636
  json: GenericError
2541
2637
  }), zod.z.object({
2542
2638
  status: zod.z.literal(500),
2543
2639
  json: GenericError
2640
+ }), zod.z.object({
2641
+ status: zod.z.literal(502),
2642
+ json: GenericError
2544
2643
  }), zod.z.object({
2545
2644
  status: zod.z.literal(200),
2546
2645
  json: zod.z.object({
2547
- /** By path, as `/save`'s `sourceFiles`. `null` is a deleted file. */
2548
- files: zod.z.record(zod.z.string(), zod.z.string().nullable())
2646
+ /** The job as content has it now: its next step is the build. */
2647
+ job: zod.z.object({
2648
+ id: zod.z.string(),
2649
+ step: zod.z["enum"](["prepare", "build", "upload"]).nullable(),
2650
+ base: zod.z.string().nullable(),
2651
+ patches: zod.z.array(zod.z.string())
2652
+ }).nullable(),
2653
+ /** Every source file of the job's content, by path. `null` is deleted. */
2654
+ sourceFiles: zod.z.record(zod.z.string(), zod.z.string().nullable()),
2655
+ /** The job's own local binary files, base64, by path. */
2656
+ binaryFiles: zod.z.record(zod.z.string(), zod.z.string()),
2657
+ /** Binary files whose bytes could not be read back. */
2658
+ binaryFilesUnread: zod.z.array(zod.z.string()),
2659
+ /** The branch the job publishes to. */
2660
+ branch: zod.z.string().nullable()
2549
2661
  })
2550
2662
  })])
2551
2663
  }
@@ -2692,7 +2804,14 @@ var Api = {
2692
2804
  patchId: PatchId,
2693
2805
  moduleFilePath: ModuleFilePath,
2694
2806
  message: zod.z.string()
2695
- })).optional()
2807
+ })).optional(),
2808
+ /**
2809
+ * The chain version this publish moved the branch to, where the
2810
+ * content service versions its chain and the publish applied
2811
+ * anything. See `headVersion` on `/stat`: a `/stat` answer read
2812
+ * before the publish would put its patches back to pending.
2813
+ */
2814
+ headVersion: zod.z.number().optional()
2696
2815
  })
2697
2816
  }),
2698
2817
  /*
@@ -7365,6 +7484,54 @@ var projectSourceResponse = zod.z.object({
7365
7484
  */
7366
7485
  publicPaths: zod.z.array(zod.z.string()).nullable().optional()
7367
7486
  });
7487
+ /**
7488
+ * Whether a managed project can be updated onto its template's current seed,
7489
+ * and -- when it is asked with `POST`, the press -- what to build against.
7490
+ *
7491
+ * An update rebuilds the site as it is on newer dependencies. The loader
7492
+ * decides whether there is one; content adds whether the project is managed at
7493
+ * all, and the branch head the rebuild is wired at, because an update
7494
+ * publishes no content of its own.
7495
+ *
7496
+ * `target` is a `/build-target` answer whose project half is the SEED's
7497
+ * dependency layer, already copied into the project so a publish can name it.
7498
+ * Only a `POST` carries it.
7499
+ */
7500
+ var dependencyChange = zod.z.object({
7501
+ name: zod.z.string(),
7502
+ section: zod.z["enum"](["dependencies", "devDependencies"]),
7503
+ /** `null` for a dependency the template added. */
7504
+ from: zod.z.string().nullable(),
7505
+ /** `null` for a dependency the template dropped: it leaves `package.json`. */
7506
+ to: zod.z.string().nullable()
7507
+ });
7508
+ var updateTargetResponse = zod.z.discriminatedUnion("status", [zod.z.object({
7509
+ status: zod.z.literal("current"),
7510
+ template: zod.z.string(),
7511
+ layerRev: zod.z.string()
7512
+ }), zod.z.object({
7513
+ status: zod.z.literal("available"),
7514
+ template: zod.z.string(),
7515
+ /** Empty when only the dependency layer moved, and no version did. */
7516
+ changes: zod.z.array(dependencyChange),
7517
+ layerRev: zod.z.object({
7518
+ from: zod.z.string().nullable(),
7519
+ to: zod.z.string()
7520
+ }),
7521
+ /** The project's `package.json`, rewritten to the seed's versions. */
7522
+ packageJson: zod.z.string(),
7523
+ /** The branch head to build at; `null` for a project with no commits. */
7524
+ commit: zod.z.string().nullable(),
7525
+ branch: zod.z.string(),
7526
+ target: buildTargetResponse.optional()
7527
+ }), zod.z.object({
7528
+ status: zod.z.literal("unavailable"),
7529
+ reason: zod.z.string(),
7530
+ message: zod.z.string()
7531
+ })]);
7532
+ var parseUpdateTarget = function parseUpdateTarget(body) {
7533
+ return parse(updateTargetResponse, body, "/v1/update-target");
7534
+ };
7368
7535
  var parseBuildTarget = function parseBuildTarget(body) {
7369
7536
  return parse(buildTargetResponse, body, "GET /v1/build-target");
7370
7537
  };
@@ -7372,6 +7539,88 @@ var parseProjectSource = function parseProjectSource(body) {
7372
7539
  return parse(projectSourceResponse, body, "GET /v1/project-source");
7373
7540
  };
7374
7541
 
7542
+ // ------------------------------------------------------ publish jobs
7543
+
7544
+ /*
7545
+ * Publishing as a queued job (valbuild/home docs/app-mode.md, "Publishing is a
7546
+ * queued job"): a press is a request, the tab builds and uploads the job it is
7547
+ * given, and content runs verify and the seal. Each parser is typed against
7548
+ * the copy in `contentApi.ts`, so a copy brought up to date fails to compile
7549
+ * here until these follow it.
7550
+ */
7551
+
7552
+ var requestStatus = zod.z.union([zod.z.object({
7553
+ kind: zod.z.literal("queued")
7554
+ }), zod.z.object({
7555
+ kind: zod.z.literal("publishing")
7556
+ }), zod.z.object({
7557
+ kind: zod.z.literal("live"),
7558
+ commit: zod.z.string()
7559
+ }), zod.z.object({
7560
+ kind: zod.z.literal("failed"),
7561
+ message: zod.z.string(),
7562
+ actions: zod.z.array(zod.z["enum"](["try-again", "discard", "re-run-build"])),
7563
+ job: zod.z.string()
7564
+ }), zod.z.object({
7565
+ kind: zod.z.literal("cancelled")
7566
+ }), zod.z.object({
7567
+ kind: zod.z.literal("nothing-to-publish")
7568
+ })]);
7569
+ var tabJob = zod.z.object({
7570
+ id: zod.z.string(),
7571
+ step: zod.z["enum"](["prepare", "build", "upload"]).nullable(),
7572
+ base: zod.z.string().nullable(),
7573
+ patches: zod.z.array(zod.z.string())
7574
+ });
7575
+ var pressResponse = zod.z.object({
7576
+ request: requestStatus,
7577
+ job: tabJob.nullable()
7578
+ });
7579
+ var requestStatusResponse = zod.z.object({
7580
+ request: requestStatus
7581
+ });
7582
+ // `/next`, `/prepare` and `/steps` all answer with the job as it now is.
7583
+ var jobResponse = zod.z.object({
7584
+ job: tabJob.nullable()
7585
+ });
7586
+ var renewResponse = zod.z.object({
7587
+ renewed: zod.z["boolean"]()
7588
+ });
7589
+ var cancelResponse = zod.z.object({
7590
+ cancelled: zod.z["boolean"]()
7591
+ });
7592
+ var discardResponse = zod.z.object({
7593
+ stillHeld: zod.z.array(zod.z.string())
7594
+ });
7595
+ var parsePress = function parsePress(body, call) {
7596
+ return parse(pressResponse, body, call);
7597
+ };
7598
+ var parseRequestStatus = function parseRequestStatus(body) {
7599
+ return parse(requestStatusResponse, body, "GET /v1/publish-requests/{id}");
7600
+ };
7601
+ var parseJob = function parseJob(body, call) {
7602
+ return parse(jobResponse, body, call);
7603
+ };
7604
+ var parseRenew = function parseRenew(body) {
7605
+ return parse(renewResponse, body, "POST /v1/publish-jobs/{id}/renew");
7606
+ };
7607
+ var parseCancel = function parseCancel(body) {
7608
+ return parse(cancelResponse, body, "POST /v1/publish-jobs/{id}/cancel");
7609
+ };
7610
+ var parseDiscard = function parseDiscard(body) {
7611
+ return parse(discardResponse, body, "POST /v1/publish-jobs/{id}/discard");
7612
+ };
7613
+ var newestCiRunResponse = zod.z.object({
7614
+ run: zod.z.object({
7615
+ commit: zod.z.string(),
7616
+ status: zod.z["enum"](["failed", "succeeded"]),
7617
+ url: zod.z.string().nullable()
7618
+ }).nullable()
7619
+ });
7620
+ var parseNewestCiRun = function parseNewestCiRun(body) {
7621
+ return parse(newestCiRunResponse, body, "GET /v1/ci-runs/newest");
7622
+ };
7623
+
7375
7624
  /**
7376
7625
  * The `details` of a refusal, when it carries a list of problems.
7377
7626
  *
@@ -7528,12 +7777,20 @@ exports.memoizePerRequest = memoizePerRequest;
7528
7777
  exports.newestCommitSha = newestCommitSha;
7529
7778
  exports.parseArtifacts = parseArtifacts;
7530
7779
  exports.parseBuildTarget = parseBuildTarget;
7780
+ exports.parseCancel = parseCancel;
7531
7781
  exports.parseDeclare = parseDeclare;
7782
+ exports.parseDiscard = parseDiscard;
7783
+ exports.parseJob = parseJob;
7784
+ exports.parseNewestCiRun = parseNewestCiRun;
7785
+ exports.parsePress = parsePress;
7532
7786
  exports.parseProblems = parseProblems;
7533
7787
  exports.parseProjectSource = parseProjectSource;
7534
7788
  exports.parsePromote = parsePromote;
7535
7789
  exports.parsePublishToken = parsePublishToken;
7790
+ exports.parseRenew = parseRenew;
7791
+ exports.parseRequestStatus = parseRequestStatus;
7536
7792
  exports.parseStatus = parseStatus;
7793
+ exports.parseUpdateTarget = parseUpdateTarget;
7537
7794
  exports.parseVerify = parseVerify;
7538
7795
  exports.partitionValidationErrors = partitionValidationErrors;
7539
7796
  exports.performSearch = performSearch;