@valbuild/shared 0.148.7 → 0.150.1
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/CHANGELOG.md +62 -0
- package/client/dist/valbuild-shared-client.cjs.dev.js +2 -1
- package/client/dist/valbuild-shared-client.cjs.prod.js +2 -1
- package/client/dist/valbuild-shared-client.esm.js +2 -1
- package/dist/acquireTypes-50960f2c.esm.js +1801 -0
- package/dist/acquireTypes-de10005d.cjs.dev.js +1815 -0
- package/dist/acquireTypes-e9467a2a.cjs.prod.js +1815 -0
- package/dist/createForOfIteratorHelper-3db5d737.esm.js +121 -0
- package/dist/createForOfIteratorHelper-90e6a8b6.cjs.prod.js +129 -0
- package/dist/createForOfIteratorHelper-d86bb352.cjs.dev.js +129 -0
- package/dist/declarations/src/internal/ApiRoutes.d.ts +3 -3
- package/dist/declarations/src/internal/index.d.ts +2 -0
- package/dist/declarations/src/internal/selfCheck.d.ts +51 -0
- package/dist/declarations/src/internal/validation/validationWarnings.d.ts +33 -0
- package/dist/declarations/src/publish/buildProposal.d.ts +106 -0
- package/dist/declarations/src/publish/builder.d.ts +22 -0
- package/dist/declarations/src/publish/callJson.d.ts +21 -0
- package/dist/declarations/src/publish/index.d.ts +23 -0
- package/dist/declarations/src/publish/jobClient.d.ts +96 -0
- package/dist/declarations/src/publish/loadedLayer.d.ts +50 -0
- package/dist/declarations/src/publish/proposalProject.d.ts +2 -0
- package/dist/declarations/src/publish/publishClient.d.ts +95 -0
- package/dist/declarations/src/publish/runStudioDeploy.d.ts +244 -0
- package/dist/declarations/src/publish/runStudioJob.d.ts +102 -0
- package/dist/declarations/src/publish/runStudioPublish.d.ts +80 -0
- package/dist/declarations/src/typecheck/acquireTypes.d.ts +109 -0
- package/dist/declarations/src/typecheck/adeptSources.d.ts +9 -0
- package/dist/declarations/src/typecheck/index.d.ts +20 -0
- package/dist/declarations/src/typecheck/linkedFileSystem.d.ts +53 -0
- package/dist/declarations/src/typecheck/lockedVersions.d.ts +14 -0
- package/dist/declarations/src/typecheck/pnpmLayout.d.ts +95 -0
- package/dist/declarations/src/typecheck/pnpmLockfile.d.ts +57 -0
- package/dist/declarations/src/typecheck/proposalTypecheck.d.ts +76 -0
- package/dist/declarations/src/typecheck/testing/index.d.ts +6 -0
- package/dist/declarations/src/typecheck/testing/nodeModulesSources.d.ts +5 -0
- package/dist/declarations/src/typecheck/typecheckProject.d.ts +89 -0
- package/dist/declarations/src/typecheck/typescriptCompiler.d.ts +52 -0
- package/dist/{getSitemapTree-40d76bf8.cjs.prod.js → getSitemapTree-0fa0569c.cjs.dev.js} +5 -131
- package/dist/{getSitemapTree-cd006a36.esm.js → getSitemapTree-5afbc3ac.esm.js} +2 -121
- package/dist/{getSitemapTree-a7f2cc6d.cjs.dev.js → getSitemapTree-667bcb3c.cjs.prod.js} +5 -131
- package/dist/proposalProject-28550146.cjs.prod.js +18 -0
- package/dist/proposalProject-a3d3ad76.esm.js +16 -0
- package/dist/proposalProject-cdc53711.cjs.dev.js +18 -0
- package/dist/protocol-1c13de0d.cjs.prod.js +433 -0
- package/dist/protocol-3b9ef786.esm.js +413 -0
- package/dist/protocol-d8a6efda.cjs.dev.js +433 -0
- package/dist/slicedToArray-62e428df.cjs.dev.js +309 -0
- package/dist/slicedToArray-6cd80315.esm.js +299 -0
- package/dist/slicedToArray-af50e684.cjs.prod.js +309 -0
- package/internal/dist/valbuild-shared-internal.cjs.dev.js +464 -888
- package/internal/dist/valbuild-shared-internal.cjs.prod.js +464 -888
- package/internal/dist/valbuild-shared-internal.esm.js +276 -707
- package/package.json +28 -5
- package/publish/dist/valbuild-shared-publish.cjs.d.ts +2 -0
- package/publish/dist/valbuild-shared-publish.cjs.dev.js +2466 -0
- package/publish/dist/valbuild-shared-publish.cjs.js +7 -0
- package/publish/dist/valbuild-shared-publish.cjs.prod.js +2466 -0
- package/publish/dist/valbuild-shared-publish.esm.js +2428 -0
- package/publish/package.json +4 -0
- package/typecheck/dist/valbuild-shared-typecheck.cjs.d.ts +2 -0
- package/typecheck/dist/valbuild-shared-typecheck.cjs.dev.js +1173 -0
- package/typecheck/dist/valbuild-shared-typecheck.cjs.js +7 -0
- package/typecheck/dist/valbuild-shared-typecheck.cjs.prod.js +1173 -0
- package/typecheck/dist/valbuild-shared-typecheck.esm.js +1152 -0
- package/typecheck/package.json +4 -0
- package/typecheck/testing/dist/valbuild-shared-typecheck-testing.cjs.d.ts +2 -0
- package/typecheck/testing/dist/valbuild-shared-typecheck-testing.cjs.dev.js +202 -0
- package/typecheck/testing/dist/valbuild-shared-typecheck-testing.cjs.js +7 -0
- package/typecheck/testing/dist/valbuild-shared-typecheck-testing.cjs.prod.js +202 -0
- package/typecheck/testing/dist/valbuild-shared-typecheck-testing.esm.js +177 -0
- package/typecheck/testing/package.json +4 -0
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var slicedToArray = require('./slicedToArray-af50e684.cjs.prod.js');
|
|
4
|
+
var zod = require('zod');
|
|
5
|
+
var zodValidationError = require('zod-validation-error');
|
|
6
|
+
|
|
7
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
8
|
+
if (null == r) return {};
|
|
9
|
+
var t = {};
|
|
10
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
11
|
+
if (-1 !== e.indexOf(n)) continue;
|
|
12
|
+
t[n] = r[n];
|
|
13
|
+
}
|
|
14
|
+
return t;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function _objectWithoutProperties(e, t) {
|
|
18
|
+
if (null == e) return {};
|
|
19
|
+
var o,
|
|
20
|
+
r,
|
|
21
|
+
i = _objectWithoutPropertiesLoose(e, t);
|
|
22
|
+
if (Object.getOwnPropertySymbols) {
|
|
23
|
+
var n = Object.getOwnPropertySymbols(e);
|
|
24
|
+
for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
25
|
+
}
|
|
26
|
+
return i;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Reading what content answers.
|
|
31
|
+
*
|
|
32
|
+
* Every type here comes from `contentApi.ts`, which is a copy of the
|
|
33
|
+
* service's own `Api.ts` - so the shapes are not re-derived from what this end
|
|
34
|
+
* wishes it received, and a copy brought up to date fails to compile wherever
|
|
35
|
+
* this CLI has not caught up.
|
|
36
|
+
*
|
|
37
|
+
* The schemas are the runtime half, and they are needed as well as the types:
|
|
38
|
+
* what arrives is JSON over HTTP from a service that versions separately, so a
|
|
39
|
+
* type alone asserts a shape rather than checking one. Each schema is
|
|
40
|
+
* annotated with the copied type it must produce (`z.ZodType<DeclareResponse>`
|
|
41
|
+
* and so on), which is what ties the two halves together - a schema that drifts
|
|
42
|
+
* from the copy does not compile, and an answer that drifts from the schema
|
|
43
|
+
* does not parse. `ValOpsHttp` in `@valbuild/server` reads every other content
|
|
44
|
+
* route the same way.
|
|
45
|
+
*
|
|
46
|
+
* Nothing here is laxer than the copy. An optional field is optional because
|
|
47
|
+
* the service says so; making a required one optional here would hide exactly
|
|
48
|
+
* the drift this file exists to catch.
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
/** An artifact, as it is declared: by key, by hash, by size. */
|
|
52
|
+
|
|
53
|
+
/** Permission to write one artifact's bytes to object storage. */
|
|
54
|
+
|
|
55
|
+
var publishState = zod.z["enum"](["awaiting-artifacts", "ready", "verified", "live", "failed", "expired"]);
|
|
56
|
+
var publishProblem = zod.z.object({
|
|
57
|
+
code: zod.z.string(),
|
|
58
|
+
message: zod.z.string(),
|
|
59
|
+
hint: zod.z.string().optional(),
|
|
60
|
+
keys: zod.z.array(zod.z.string()).optional()
|
|
61
|
+
});
|
|
62
|
+
var uploadSlot = zod.z.object({
|
|
63
|
+
key: zod.z.string(),
|
|
64
|
+
url: zod.z.string(),
|
|
65
|
+
method: zod.z.literal("PUT"),
|
|
66
|
+
headers: zod.z.record(zod.z.string(), zod.z.string()),
|
|
67
|
+
expiresAt: zod.z.string()
|
|
68
|
+
});
|
|
69
|
+
var declareResponse = zod.z.object({
|
|
70
|
+
publishId: zod.z.string(),
|
|
71
|
+
state: publishState,
|
|
72
|
+
project: zod.z.object({
|
|
73
|
+
publicProjectId: zod.z.string(),
|
|
74
|
+
siteUrl: zod.z.string().nullable()
|
|
75
|
+
}),
|
|
76
|
+
uploads: zod.z.array(uploadSlot),
|
|
77
|
+
have: zod.z.array(zod.z.string())
|
|
78
|
+
});
|
|
79
|
+
var artifactsResponse = zod.z.object({
|
|
80
|
+
state: publishState,
|
|
81
|
+
problems: zod.z.array(publishProblem)
|
|
82
|
+
});
|
|
83
|
+
var verifyResponse = zod.z.object({
|
|
84
|
+
state: publishState,
|
|
85
|
+
ok: zod.z["boolean"](),
|
|
86
|
+
previewUrl: zod.z.string().nullable(),
|
|
87
|
+
problems: zod.z.array(publishProblem)
|
|
88
|
+
});
|
|
89
|
+
var promoteResponse = zod.z.object({
|
|
90
|
+
state: publishState,
|
|
91
|
+
url: zod.z.string().nullable(),
|
|
92
|
+
commit: zod.z.string().nullable()
|
|
93
|
+
});
|
|
94
|
+
var statusResponse = zod.z.object({
|
|
95
|
+
publishId: zod.z.string(),
|
|
96
|
+
state: publishState,
|
|
97
|
+
buildHash: zod.z.string(),
|
|
98
|
+
missing: zod.z.array(zod.z.string()),
|
|
99
|
+
problems: zod.z.array(publishProblem)
|
|
100
|
+
});
|
|
101
|
+
var publishTokenResponse = zod.z.object({
|
|
102
|
+
token: zod.z.string(),
|
|
103
|
+
expiresAt: zod.z.string().nullable(),
|
|
104
|
+
publicProjectId: zod.z.string(),
|
|
105
|
+
productionUrl: zod.z.string().nullable()
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Content answered, and the answer was not one this CLI can act on.
|
|
110
|
+
*
|
|
111
|
+
* Separate from a refusal, which is content saying no in a sentence meant for
|
|
112
|
+
* a person. This is two programs disagreeing - the copy in `contentApi.ts` and
|
|
113
|
+
* the service that has moved on from it - and the two want opposite things
|
|
114
|
+
* said about them.
|
|
115
|
+
*/
|
|
116
|
+
var PublishProtocolError = /*#__PURE__*/function (_Error) {
|
|
117
|
+
function PublishProtocolError(message) {
|
|
118
|
+
var _this;
|
|
119
|
+
slicedToArray._classCallCheck(this, PublishProtocolError);
|
|
120
|
+
_this = slicedToArray._callSuper(this, PublishProtocolError, [message]);
|
|
121
|
+
_this.name = "PublishProtocolError";
|
|
122
|
+
return _this;
|
|
123
|
+
}
|
|
124
|
+
slicedToArray._inherits(PublishProtocolError, _Error);
|
|
125
|
+
return slicedToArray._createClass(PublishProtocolError);
|
|
126
|
+
}(/*#__PURE__*/slicedToArray._wrapNativeSuper(Error));
|
|
127
|
+
var parseDeclare = function parseDeclare(body) {
|
|
128
|
+
return parse(declareResponse, body, "POST /v1/publish");
|
|
129
|
+
};
|
|
130
|
+
var parseArtifacts = function parseArtifacts(body) {
|
|
131
|
+
return parse(artifactsResponse, body, "POST /v1/publish/{id}/artifacts");
|
|
132
|
+
};
|
|
133
|
+
var parseVerify = function parseVerify(body) {
|
|
134
|
+
return parse(verifyResponse, body, "POST /v1/publish/{id}/verify");
|
|
135
|
+
};
|
|
136
|
+
var parsePromote = function parsePromote(body) {
|
|
137
|
+
return parse(promoteResponse, body, "POST /v1/publish/{id}/promote");
|
|
138
|
+
};
|
|
139
|
+
var parseStatus = function parseStatus(body) {
|
|
140
|
+
return parse(statusResponse, body, "GET /v1/publish/{id}");
|
|
141
|
+
};
|
|
142
|
+
var parsePublishToken = function parsePublishToken(body, call) {
|
|
143
|
+
return parse(publishTokenResponse, body, call);
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* What a build targets, and the project's files, as the Studio asks for them.
|
|
148
|
+
*
|
|
149
|
+
* Both are read through `/publish-api` rather than fetched from the loader,
|
|
150
|
+
* because a browser has neither the loader's address nor a credential it would
|
|
151
|
+
* accept. `fetchBuildTarget` in `@valbuild/tanstack-build` is the other half --
|
|
152
|
+
* same shape, a different caller, and it CASTS where this parses.
|
|
153
|
+
*
|
|
154
|
+
* Parsed rather than cast here because of what sits in between: a proxy, a
|
|
155
|
+
* gateway and a service boundary. An HTML error page cast to `BuildTarget`
|
|
156
|
+
* fails several layers down inside rolldown with a message about a module
|
|
157
|
+
* specifier, and the publish that follows would label a build against a layer
|
|
158
|
+
* that was never there.
|
|
159
|
+
*
|
|
160
|
+
* The TYPE is inferred from this schema instead of imported. `BuildTarget` is
|
|
161
|
+
* declared in `@valbuild/tanstack-build`, which has no zod and deliberately
|
|
162
|
+
* almost no dependencies -- it goes into a browser bundle -- and this package
|
|
163
|
+
* is imported by everything. The declarations are kept honest at the one place
|
|
164
|
+
* the value is used: it is passed straight into `buildUserApp({ target })`, so
|
|
165
|
+
* a drift between them is a compile error at that call rather than a runtime
|
|
166
|
+
* surprise.
|
|
167
|
+
*/
|
|
168
|
+
var buildTargetResponse = zod.z.object({
|
|
169
|
+
base: zod.z.object({
|
|
170
|
+
rev: zod.z.string(),
|
|
171
|
+
shellRev: zod.z.string(),
|
|
172
|
+
rscShellRev: zod.z.string(),
|
|
173
|
+
modules: zod.z.record(zod.z.string(), zod.z.string()),
|
|
174
|
+
rscModules: zod.z.record(zod.z.string(), zod.z.string()),
|
|
175
|
+
paths: zod.z.object({
|
|
176
|
+
baseFromProject: zod.z.string(),
|
|
177
|
+
projectVendorDir: zod.z.string(),
|
|
178
|
+
rscVendorBase: zod.z.string(),
|
|
179
|
+
rscRuntimeSpecifier: zod.z.string(),
|
|
180
|
+
rscRuntimePath: zod.z.string(),
|
|
181
|
+
flightServer: zod.z.string(),
|
|
182
|
+
serverFnBase: zod.z.string()
|
|
183
|
+
}),
|
|
184
|
+
/*
|
|
185
|
+
* What the base layer is built from and what its chunks export, which
|
|
186
|
+
* `val publish` checks a project's layer against (`BuildTarget.base` in
|
|
187
|
+
* @valbuild/tanstack-build). Declared, because `z.object` DROPS a key it
|
|
188
|
+
* does not name: left out, they never reached the build, and every
|
|
189
|
+
* publish skipped both checks while saying the platform had not sent them.
|
|
190
|
+
* Optional, for a platform that predates them.
|
|
191
|
+
*/
|
|
192
|
+
pins: zod.z.record(zod.z.string(), zod.z.string()).optional(),
|
|
193
|
+
exports: zod.z.object({
|
|
194
|
+
worker: zod.z.record(zod.z.string(), zod.z.array(zod.z.string())),
|
|
195
|
+
browser: zod.z.record(zod.z.string(), zod.z.array(zod.z.string()))
|
|
196
|
+
}).optional()
|
|
197
|
+
}),
|
|
198
|
+
project: zod.z.object({
|
|
199
|
+
rev: zod.z.string().nullable(),
|
|
200
|
+
rsc: zod.z["boolean"](),
|
|
201
|
+
modules: zod.z.record(zod.z.string(), zod.z.string()),
|
|
202
|
+
css: zod.z.record(zod.z.string(), zod.z.string()),
|
|
203
|
+
workerOnly: zod.z.array(zod.z.string())
|
|
204
|
+
}),
|
|
205
|
+
/**
|
|
206
|
+
* The project's branch: what a build is wired at, so its Val saves where
|
|
207
|
+
* publishes commit. Optional, for a content service that predates it.
|
|
208
|
+
*/
|
|
209
|
+
branch: zod.z.string().optional()
|
|
210
|
+
});
|
|
211
|
+
/**
|
|
212
|
+
* `null` files is a real answer: a project that has never published.
|
|
213
|
+
*
|
|
214
|
+
* Distinguished from an empty record, which would be a project that published
|
|
215
|
+
* nothing -- and which a build would take as "no entry point" rather than as
|
|
216
|
+
* "there is nothing here yet".
|
|
217
|
+
*/
|
|
218
|
+
var projectSourceResponse = zod.z.object({
|
|
219
|
+
files: zod.z.record(zod.z.string(), zod.z.string()).nullable(),
|
|
220
|
+
/**
|
|
221
|
+
* The live build's `public/*` artifacts, by hash -- what a publisher with no
|
|
222
|
+
* checkout carries into its build so the site keeps its favicon and images.
|
|
223
|
+
*
|
|
224
|
+
* The loader stores public files PER BUILD, so a build that names none
|
|
225
|
+
* serves none. A publisher with a checkout has them on disk; the Studio has
|
|
226
|
+
* this. Re-declaring one costs nothing: content holds the bytes for the
|
|
227
|
+
* project already and asks for no upload.
|
|
228
|
+
*
|
|
229
|
+
* `null` when content cannot say -- the live build was not published through
|
|
230
|
+
* it -- and absent from a content service that predates it. A publisher
|
|
231
|
+
* must treat both as "unknown", never as "none": publishing on that guess
|
|
232
|
+
* deletes every public file the site has.
|
|
233
|
+
*/
|
|
234
|
+
publicFiles: zod.z.array(zod.z.object({
|
|
235
|
+
key: zod.z.string(),
|
|
236
|
+
sha256: zod.z.string(),
|
|
237
|
+
bytes: zod.z.number()["int"]().nonnegative()
|
|
238
|
+
})).nullable().optional(),
|
|
239
|
+
/**
|
|
240
|
+
* The URL paths the live build serves from `public/`, as the loader has
|
|
241
|
+
* them -- without the bytes' hashes.
|
|
242
|
+
*
|
|
243
|
+
* The fallback for when `publicFiles` is `null`: a build content has no
|
|
244
|
+
* record of, which is every project cloned from a template seed. A publisher
|
|
245
|
+
* running on the site's own origin can fetch these and build with them;
|
|
246
|
+
* after that publish content holds their hashes and `publicFiles` answers.
|
|
247
|
+
* `null` when the loader serves no build or does not say.
|
|
248
|
+
*/
|
|
249
|
+
publicPaths: zod.z.array(zod.z.string()).nullable().optional()
|
|
250
|
+
});
|
|
251
|
+
/**
|
|
252
|
+
* Whether a managed project can be updated onto its template's current seed,
|
|
253
|
+
* and -- when it is asked with `POST`, the press -- what to build against.
|
|
254
|
+
*
|
|
255
|
+
* An update rebuilds the site as it is on newer dependencies. The loader
|
|
256
|
+
* decides whether there is one; content adds whether the project is managed at
|
|
257
|
+
* all, and the branch head the rebuild is wired at, because an update
|
|
258
|
+
* publishes no content of its own.
|
|
259
|
+
*
|
|
260
|
+
* `target` is a `/build-target` answer whose project half is the SEED's
|
|
261
|
+
* dependency layer, already copied into the project so a publish can name it.
|
|
262
|
+
* Only a `POST` carries it.
|
|
263
|
+
*/
|
|
264
|
+
var dependencyChange = zod.z.object({
|
|
265
|
+
name: zod.z.string(),
|
|
266
|
+
section: zod.z["enum"](["dependencies", "devDependencies"]),
|
|
267
|
+
/** `null` for a dependency the template added. */
|
|
268
|
+
from: zod.z.string().nullable(),
|
|
269
|
+
/** `null` for a dependency the template dropped: it leaves `package.json`. */
|
|
270
|
+
to: zod.z.string().nullable()
|
|
271
|
+
});
|
|
272
|
+
var updateTargetResponse = zod.z.discriminatedUnion("status", [zod.z.object({
|
|
273
|
+
status: zod.z.literal("current"),
|
|
274
|
+
template: zod.z.string(),
|
|
275
|
+
layerRev: zod.z.string()
|
|
276
|
+
}), zod.z.object({
|
|
277
|
+
status: zod.z.literal("available"),
|
|
278
|
+
template: zod.z.string(),
|
|
279
|
+
/** Empty when only the dependency layer moved, and no version did. */
|
|
280
|
+
changes: zod.z.array(dependencyChange),
|
|
281
|
+
layerRev: zod.z.object({
|
|
282
|
+
from: zod.z.string().nullable(),
|
|
283
|
+
to: zod.z.string()
|
|
284
|
+
}),
|
|
285
|
+
/** The project's `package.json`, rewritten to the seed's versions. */
|
|
286
|
+
packageJson: zod.z.string(),
|
|
287
|
+
/** The branch head to build at; `null` for a project with no commits. */
|
|
288
|
+
commit: zod.z.string().nullable(),
|
|
289
|
+
branch: zod.z.string(),
|
|
290
|
+
target: buildTargetResponse.optional()
|
|
291
|
+
}), zod.z.object({
|
|
292
|
+
status: zod.z.literal("unavailable"),
|
|
293
|
+
reason: zod.z.string(),
|
|
294
|
+
message: zod.z.string()
|
|
295
|
+
})]);
|
|
296
|
+
var parseUpdateTarget = function parseUpdateTarget(body) {
|
|
297
|
+
return parse(updateTargetResponse, body, "/v1/update-target");
|
|
298
|
+
};
|
|
299
|
+
var parseBuildTarget = function parseBuildTarget(body) {
|
|
300
|
+
return parse(buildTargetResponse, body, "GET /v1/build-target");
|
|
301
|
+
};
|
|
302
|
+
var parseProjectSource = function parseProjectSource(body) {
|
|
303
|
+
return parse(projectSourceResponse, body, "GET /v1/project-source");
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
// ------------------------------------------------------ publish jobs
|
|
307
|
+
|
|
308
|
+
/*
|
|
309
|
+
* Publishing as a queued job (valbuild/home docs/app-mode.md, "Publishing is a
|
|
310
|
+
* queued job"): a press is a request, the tab builds and uploads the job it is
|
|
311
|
+
* given, and content runs verify and the seal. Each parser is typed against
|
|
312
|
+
* the copy in `contentApi.ts`, so a copy brought up to date fails to compile
|
|
313
|
+
* here until these follow it.
|
|
314
|
+
*/
|
|
315
|
+
|
|
316
|
+
var requestStatus = zod.z.union([zod.z.object({
|
|
317
|
+
kind: zod.z.literal("queued")
|
|
318
|
+
}), zod.z.object({
|
|
319
|
+
kind: zod.z.literal("publishing")
|
|
320
|
+
}), zod.z.object({
|
|
321
|
+
kind: zod.z.literal("live"),
|
|
322
|
+
commit: zod.z.string()
|
|
323
|
+
}), zod.z.object({
|
|
324
|
+
kind: zod.z.literal("failed"),
|
|
325
|
+
message: zod.z.string(),
|
|
326
|
+
actions: zod.z.array(zod.z["enum"](["try-again", "discard", "re-run-build"])),
|
|
327
|
+
job: zod.z.string(),
|
|
328
|
+
movedTo: zod.z.object({
|
|
329
|
+
proposal: zod.z.string(),
|
|
330
|
+
displayName: zod.z.string(),
|
|
331
|
+
changes: zod.z.number()
|
|
332
|
+
}).optional()
|
|
333
|
+
}), zod.z.object({
|
|
334
|
+
kind: zod.z.literal("cancelled")
|
|
335
|
+
}), zod.z.object({
|
|
336
|
+
kind: zod.z.literal("nothing-to-publish")
|
|
337
|
+
})]);
|
|
338
|
+
var tabJob = zod.z.object({
|
|
339
|
+
id: zod.z.string(),
|
|
340
|
+
step: zod.z["enum"](["prepare", "build", "upload"]).nullable(),
|
|
341
|
+
base: zod.z.string().nullable(),
|
|
342
|
+
patches: zod.z.array(zod.z.string()),
|
|
343
|
+
contentOnly: zod.z.literal(true).optional()
|
|
344
|
+
});
|
|
345
|
+
var pressResponse = zod.z.object({
|
|
346
|
+
request: requestStatus,
|
|
347
|
+
job: tabJob.nullable()
|
|
348
|
+
});
|
|
349
|
+
var requestStatusResponse = zod.z.object({
|
|
350
|
+
request: requestStatus
|
|
351
|
+
});
|
|
352
|
+
// `/next`, `/prepare` and `/steps` all answer with the job as it now is.
|
|
353
|
+
var jobResponse = zod.z.object({
|
|
354
|
+
job: tabJob.nullable()
|
|
355
|
+
});
|
|
356
|
+
var renewResponse = zod.z.object({
|
|
357
|
+
renewed: zod.z["boolean"]()
|
|
358
|
+
});
|
|
359
|
+
var cancelResponse = zod.z.object({
|
|
360
|
+
cancelled: zod.z["boolean"]()
|
|
361
|
+
});
|
|
362
|
+
var discardResponse = zod.z.object({
|
|
363
|
+
stillHeld: zod.z.array(zod.z.string())
|
|
364
|
+
});
|
|
365
|
+
var parsePress = function parsePress(body, call) {
|
|
366
|
+
return parse(pressResponse, body, call);
|
|
367
|
+
};
|
|
368
|
+
var parseRequestStatus = function parseRequestStatus(body) {
|
|
369
|
+
return parse(requestStatusResponse, body, "GET /v1/publish-requests/{id}");
|
|
370
|
+
};
|
|
371
|
+
var parseJob = function parseJob(body, call) {
|
|
372
|
+
return parse(jobResponse, body, call);
|
|
373
|
+
};
|
|
374
|
+
var parseRenew = function parseRenew(body) {
|
|
375
|
+
return parse(renewResponse, body, "POST /v1/publish-jobs/{id}/renew");
|
|
376
|
+
};
|
|
377
|
+
var parseCancel = function parseCancel(body) {
|
|
378
|
+
return parse(cancelResponse, body, "POST /v1/publish-jobs/{id}/cancel");
|
|
379
|
+
};
|
|
380
|
+
var parseDiscard = function parseDiscard(body) {
|
|
381
|
+
return parse(discardResponse, body, "POST /v1/publish-jobs/{id}/discard");
|
|
382
|
+
};
|
|
383
|
+
var newestCiRunResponse = zod.z.object({
|
|
384
|
+
run: zod.z.object({
|
|
385
|
+
commit: zod.z.string(),
|
|
386
|
+
status: zod.z["enum"](["failed", "succeeded"]),
|
|
387
|
+
url: zod.z.string().nullable()
|
|
388
|
+
}).nullable()
|
|
389
|
+
});
|
|
390
|
+
var parseNewestCiRun = function parseNewestCiRun(body) {
|
|
391
|
+
return parse(newestCiRunResponse, body, "GET /v1/ci-runs/newest");
|
|
392
|
+
};
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* The `details` of a refusal, when it carries a list of problems.
|
|
396
|
+
*
|
|
397
|
+
* Every non-2xx is `{ statusCode, message, details? }`, and the publish routes
|
|
398
|
+
* put `PublishProblem[]` in `details` - a declaration is answered with EVERY
|
|
399
|
+
* problem rather than the first, because finding them one round trip at a time
|
|
400
|
+
* is how a publish takes six attempts. Anything else in there is somebody
|
|
401
|
+
* else's `details` and is left to the caller's own message.
|
|
402
|
+
*/
|
|
403
|
+
function parseProblems(details) {
|
|
404
|
+
var parsed = zod.z.array(publishProblem).safeParse(details);
|
|
405
|
+
return parsed.success ? parsed.data : [];
|
|
406
|
+
}
|
|
407
|
+
function parse(schema, body, call) {
|
|
408
|
+
var parsed = schema.safeParse(body);
|
|
409
|
+
if (!parsed.success) {
|
|
410
|
+
throw new PublishProtocolError("".concat(call, " answered with something this publisher cannot read: ").concat(zodValidationError.fromError(parsed.error).toString()));
|
|
411
|
+
}
|
|
412
|
+
return parsed.data;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
exports.PublishProtocolError = PublishProtocolError;
|
|
416
|
+
exports._objectWithoutProperties = _objectWithoutProperties;
|
|
417
|
+
exports.parseArtifacts = parseArtifacts;
|
|
418
|
+
exports.parseBuildTarget = parseBuildTarget;
|
|
419
|
+
exports.parseCancel = parseCancel;
|
|
420
|
+
exports.parseDeclare = parseDeclare;
|
|
421
|
+
exports.parseDiscard = parseDiscard;
|
|
422
|
+
exports.parseJob = parseJob;
|
|
423
|
+
exports.parseNewestCiRun = parseNewestCiRun;
|
|
424
|
+
exports.parsePress = parsePress;
|
|
425
|
+
exports.parseProblems = parseProblems;
|
|
426
|
+
exports.parseProjectSource = parseProjectSource;
|
|
427
|
+
exports.parsePromote = parsePromote;
|
|
428
|
+
exports.parsePublishToken = parsePublishToken;
|
|
429
|
+
exports.parseRenew = parseRenew;
|
|
430
|
+
exports.parseRequestStatus = parseRequestStatus;
|
|
431
|
+
exports.parseStatus = parseStatus;
|
|
432
|
+
exports.parseUpdateTarget = parseUpdateTarget;
|
|
433
|
+
exports.parseVerify = parseVerify;
|