@valbuild/shared 0.136.0 → 0.136.2
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 +60 -0
- package/client/dist/valbuild-shared-client.cjs.dev.js +1 -1
- package/client/dist/valbuild-shared-client.cjs.prod.js +1 -1
- package/client/dist/valbuild-shared-client.esm.js +1 -1
- package/dist/declarations/src/internal/ApiRoutes.d.ts +61 -0
- package/dist/declarations/src/internal/index.d.ts +3 -0
- package/dist/declarations/src/internal/publish/contentApi.d.ts +201 -0
- package/dist/declarations/src/internal/publish/protocol.d.ts +129 -0
- package/dist/declarations/src/internal/server/requestScopedMemo.d.ts +47 -0
- package/dist/{getSitemapTree-99839b02.cjs.prod.js → getSitemapTree-0ed3deac.cjs.prod.js} +1 -0
- package/dist/{getSitemapTree-878d3888.esm.js → getSitemapTree-6fcdf745.esm.js} +1 -1
- package/dist/{getSitemapTree-99c97c62.cjs.dev.js → getSitemapTree-c732e09a.cjs.dev.js} +1 -0
- package/internal/dist/valbuild-shared-internal.cjs.dev.js +527 -1
- package/internal/dist/valbuild-shared-internal.cjs.prod.js +527 -1
- package/internal/dist/valbuild-shared-internal.esm.js +518 -3
- package/package.json +2 -2
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var core = require('@valbuild/core');
|
|
6
|
-
var getSitemapTree = require('../../dist/getSitemapTree-
|
|
6
|
+
var getSitemapTree = require('../../dist/getSitemapTree-0ed3deac.cjs.prod.js');
|
|
7
7
|
var zod = require('zod');
|
|
8
8
|
var zodValidationError = require('zod-validation-error');
|
|
9
9
|
var FlexSearch = require('flexsearch');
|
|
@@ -661,6 +661,62 @@ var VAL_SESSION_COOKIE = core.Internal.VAL_SESSION_COOKIE;
|
|
|
661
661
|
var VAL_STATE_COOKIE = core.Internal.VAL_STATE_COOKIE;
|
|
662
662
|
var VAL_ENABLE_COOKIE_NAME = core.Internal.VAL_ENABLE_COOKIE_NAME;
|
|
663
663
|
|
|
664
|
+
/**
|
|
665
|
+
* One value, computed once per REQUEST.
|
|
666
|
+
*
|
|
667
|
+
* `fetchVal` in draft mode reads the whole module tree out of `/sources/~`, and
|
|
668
|
+
* a page that calls it three times used to ask three times — the answer being
|
|
669
|
+
* byte-identical each time, because the query and the session are fixed for the
|
|
670
|
+
* length of a request. This is what makes the second and third call free.
|
|
671
|
+
*
|
|
672
|
+
* ## Why the scope is the REQUEST and can never be wider
|
|
673
|
+
*
|
|
674
|
+
* The memoised response is `own_patch_groups_only: true` — it contains the
|
|
675
|
+
* CALLER'S OWN unpublished work, resolved from their session cookie. A memo
|
|
676
|
+
* that outlived the request would serve one author's staged edits to the next
|
|
677
|
+
* visitor, which is the exact failure `own_patch_groups_only` exists to
|
|
678
|
+
* prevent, and it would be invisible: the draft would simply render somebody
|
|
679
|
+
* else's half-finished sentence.
|
|
680
|
+
*
|
|
681
|
+
* So this module holds NO state of its own. The caller supplies the box, and
|
|
682
|
+
* the box has to come from something the framework already scopes to the
|
|
683
|
+
* request — React's `cache()` in an RSC, a `WeakMap` keyed on the `Request` in
|
|
684
|
+
* TanStack Start. `null` means "no request scope available", and that is not an
|
|
685
|
+
* error: it falls back to computing every time, which is what the code did
|
|
686
|
+
* before this existed. Ineffective is a safe failure here; leaking is not.
|
|
687
|
+
*
|
|
688
|
+
* The `key` is the second half of that guarantee. It carries whatever the
|
|
689
|
+
* answer depends on — the session — so a box that somehow outlived its request,
|
|
690
|
+
* or is shared by two sessions, MISSES rather than serving the wrong draft.
|
|
691
|
+
*
|
|
692
|
+
* ## The promise is cached, not the value
|
|
693
|
+
*
|
|
694
|
+
* React renders siblings concurrently, so three `fetchVal` calls in one page
|
|
695
|
+
* are usually in flight at the same time rather than one after another.
|
|
696
|
+
* Caching the resolved value would dedupe none of them; caching the promise
|
|
697
|
+
* dedupes both orderings.
|
|
698
|
+
*/
|
|
699
|
+
|
|
700
|
+
/**
|
|
701
|
+
* Returns the memoised promise for `key`, computing it only on a miss.
|
|
702
|
+
*
|
|
703
|
+
* A rejection is memoised along with everything else, on purpose: one failed
|
|
704
|
+
* read per request is the same answer for every caller in it, and retrying it
|
|
705
|
+
* two more times only makes a broken draft slower to render.
|
|
706
|
+
*/
|
|
707
|
+
function memoizePerRequest(box, key, compute) {
|
|
708
|
+
if (box === null) {
|
|
709
|
+
return compute();
|
|
710
|
+
}
|
|
711
|
+
if (box.promise !== undefined && box.key === key) {
|
|
712
|
+
return box.promise;
|
|
713
|
+
}
|
|
714
|
+
var promise = compute();
|
|
715
|
+
box.key = key;
|
|
716
|
+
box.promise = promise;
|
|
717
|
+
return promise;
|
|
718
|
+
}
|
|
719
|
+
|
|
664
720
|
function _regeneratorDefine(e, r, n, t) {
|
|
665
721
|
var i = Object.defineProperty;
|
|
666
722
|
try {
|
|
@@ -1974,6 +2030,86 @@ var Api = {
|
|
|
1974
2030
|
}
|
|
1975
2031
|
},
|
|
1976
2032
|
// This has a path which is like this: /upload/patches/:patchId/files. Example: /upload/patches/76b9237a-7712-4d60-88b4-d273e6d6fe18/files
|
|
2033
|
+
/**
|
|
2034
|
+
* The content service's publish API, reached through this deployment.
|
|
2035
|
+
*
|
|
2036
|
+
* A managed project is built in the Studio's own tab -- there is no host
|
|
2037
|
+
* watching a repository to pick a commit up -- and what it builds then has to
|
|
2038
|
+
* be published. The browser cannot do that itself: it holds a session cookie
|
|
2039
|
+
* for this origin and no credential content would accept. So the publish
|
|
2040
|
+
* conversation goes through here, exactly as patches already do.
|
|
2041
|
+
*
|
|
2042
|
+
* ## Deliberately not typed past this point
|
|
2043
|
+
*
|
|
2044
|
+
* No `res`, and a body this does not describe. The shapes belong to content,
|
|
2045
|
+
* and they are already written down twice -- once in content's own `Api.ts`
|
|
2046
|
+
* and once in the copy `@valbuild/cli` keeps beside its parser so the two can
|
|
2047
|
+
* be diffed by eye. A third copy here would be a third thing to keep in step,
|
|
2048
|
+
* and this layer has no decision to make that would need one: it authenticates
|
|
2049
|
+
* the caller, swaps the credential, and carries status and body back verbatim.
|
|
2050
|
+
* The Studio parses the answer with the same module the CLI does.
|
|
2051
|
+
*
|
|
2052
|
+
* That means this route answers with statuses the generic result type does not
|
|
2053
|
+
* model -- a 409 when a publish has already gone live, for one. `/save` has
|
|
2054
|
+
* always done the same; the dispatch boundary erases the type and the adapter
|
|
2055
|
+
* sends what it is given.
|
|
2056
|
+
*
|
|
2057
|
+
* ## What it may reach
|
|
2058
|
+
*
|
|
2059
|
+
* The sub-path is content's, minus `/v1`: `/publish`, `/publish/{id}` and its
|
|
2060
|
+
* three steps, and `/build-target`. `ValOpsHttp.publishApi` holds the allow
|
|
2061
|
+
* list, beside the credential, because the browser chooses this path.
|
|
2062
|
+
*/
|
|
2063
|
+
"/publish-api": {
|
|
2064
|
+
GET: {
|
|
2065
|
+
req: {
|
|
2066
|
+
path: zod.z.string().optional(),
|
|
2067
|
+
cookies: {
|
|
2068
|
+
val_session: zod.z.string().optional()
|
|
2069
|
+
}
|
|
2070
|
+
},
|
|
2071
|
+
/*
|
|
2072
|
+
* Content's status and body, carried through.
|
|
2073
|
+
*
|
|
2074
|
+
* Permissive on purpose: describing the shapes here would be the third
|
|
2075
|
+
* copy of a contract content owns, and this layer reads none of them. A
|
|
2076
|
+
* body that is not JSON -- a gateway's HTML error page -- arrives as
|
|
2077
|
+
* `{ message }` rather than throwing, because a publish failing is
|
|
2078
|
+
* something the editor has to be told about in words.
|
|
2079
|
+
*/
|
|
2080
|
+
res: zod.z.object({
|
|
2081
|
+
status: zod.z.number(),
|
|
2082
|
+
json: zod.z.unknown()
|
|
2083
|
+
})
|
|
2084
|
+
},
|
|
2085
|
+
POST: {
|
|
2086
|
+
req: {
|
|
2087
|
+
path: zod.z.string().optional(),
|
|
2088
|
+
/*
|
|
2089
|
+
* Unknown, and passed through unread. Every field content accepts here
|
|
2090
|
+
* would otherwise have to be declared -- and kept in step -- by a layer
|
|
2091
|
+
* that never looks at one.
|
|
2092
|
+
*/
|
|
2093
|
+
body: zod.z.unknown().optional(),
|
|
2094
|
+
cookies: {
|
|
2095
|
+
val_session: zod.z.string().optional()
|
|
2096
|
+
}
|
|
2097
|
+
},
|
|
2098
|
+
/*
|
|
2099
|
+
* Content's status and body, carried through.
|
|
2100
|
+
*
|
|
2101
|
+
* Permissive on purpose: describing the shapes here would be the third
|
|
2102
|
+
* copy of a contract content owns, and this layer reads none of them. A
|
|
2103
|
+
* body that is not JSON -- a gateway's HTML error page -- arrives as
|
|
2104
|
+
* `{ message }` rather than throwing, because a publish failing is
|
|
2105
|
+
* something the editor has to be told about in words.
|
|
2106
|
+
*/
|
|
2107
|
+
res: zod.z.object({
|
|
2108
|
+
status: zod.z.number(),
|
|
2109
|
+
json: zod.z.unknown()
|
|
2110
|
+
})
|
|
2111
|
+
}
|
|
2112
|
+
},
|
|
1977
2113
|
"/upload/patches": {
|
|
1978
2114
|
POST: {
|
|
1979
2115
|
req: {
|
|
@@ -2455,6 +2591,49 @@ var Api = {
|
|
|
2455
2591
|
* server that predates this.
|
|
2456
2592
|
*/
|
|
2457
2593
|
commitSha: zod.z.string().optional(),
|
|
2594
|
+
/**
|
|
2595
|
+
* The source files this commit wrote, by path, for a MANAGED project.
|
|
2596
|
+
*
|
|
2597
|
+
* A managed project has nobody to deploy it, so the Studio builds
|
|
2598
|
+
* the site in the tab -- and the build has to contain the text this
|
|
2599
|
+
* commit just produced. Nothing else can give it that: the
|
|
2600
|
+
* project's stored source is what the LAST build was made from, and
|
|
2601
|
+
* turning patched Source back into `.val.ts` text happens here, on
|
|
2602
|
+
* the server, not in a browser. `null` is a file the commit
|
|
2603
|
+
* deleted.
|
|
2604
|
+
*
|
|
2605
|
+
* Absent for a connected project, whose host builds from the
|
|
2606
|
+
* repository, and from a server that predates it.
|
|
2607
|
+
*/
|
|
2608
|
+
sourceFiles: zod.z.record(zod.z.string(), zod.z.string().nullable()).optional(),
|
|
2609
|
+
/**
|
|
2610
|
+
* The binary files this commit wrote -- an image uploaded in the
|
|
2611
|
+
* Studio -- base64, by path, for a MANAGED project.
|
|
2612
|
+
*
|
|
2613
|
+
* The same reason as `sourceFiles`: the in-tab build publishes the
|
|
2614
|
+
* site, and a file this commit added is in no earlier build. Local
|
|
2615
|
+
* files only; a remote one is served from its own URL and was never
|
|
2616
|
+
* part of a build. A deleted file is a `null` in `sourceFiles`, as
|
|
2617
|
+
* it always was.
|
|
2618
|
+
*/
|
|
2619
|
+
binaryFiles: zod.z.record(zod.z.string(), zod.z.string()).optional(),
|
|
2620
|
+
/**
|
|
2621
|
+
* The branch this commit is on, for a MANAGED project -- the
|
|
2622
|
+
* content service's word for it.
|
|
2623
|
+
*
|
|
2624
|
+
* The in-tab build has to name the branch it was made at, and its
|
|
2625
|
+
* only other source is the `val.server.ts` the last build was
|
|
2626
|
+
* wired with: a project cloned from a template seed has one wired
|
|
2627
|
+
* at no commit, so without this its first publish is branchless
|
|
2628
|
+
* and the loader refuses it.
|
|
2629
|
+
*/
|
|
2630
|
+
branch: zod.z.string().optional(),
|
|
2631
|
+
/**
|
|
2632
|
+
* Binary files this commit wrote whose bytes the server could not
|
|
2633
|
+
* read back before committing. Named so the Studio refuses to build
|
|
2634
|
+
* a site that would 404 them, rather than publishing it.
|
|
2635
|
+
*/
|
|
2636
|
+
binaryFilesUnread: zod.z.array(zod.z.string()).optional(),
|
|
2458
2637
|
/**
|
|
2459
2638
|
* Unpublished changes the save threw away because they could not be
|
|
2460
2639
|
* applied.
|
|
@@ -6804,6 +6983,342 @@ function resolvePairGround(ground, ramp) {
|
|
|
6804
6983
|
return typeof ground === "number" ? ramp[ground] : ground;
|
|
6805
6984
|
}
|
|
6806
6985
|
|
|
6986
|
+
function _defineProperties(e, r) {
|
|
6987
|
+
for (var t = 0; t < r.length; t++) {
|
|
6988
|
+
var o = r[t];
|
|
6989
|
+
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, getSitemapTree._toPropertyKey(o.key), o);
|
|
6990
|
+
}
|
|
6991
|
+
}
|
|
6992
|
+
function _createClass(e, r, t) {
|
|
6993
|
+
return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
|
|
6994
|
+
writable: !1
|
|
6995
|
+
}), e;
|
|
6996
|
+
}
|
|
6997
|
+
|
|
6998
|
+
function _classCallCheck(a, n) {
|
|
6999
|
+
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
7000
|
+
}
|
|
7001
|
+
|
|
7002
|
+
function _getPrototypeOf(t) {
|
|
7003
|
+
return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
|
|
7004
|
+
return t.__proto__ || Object.getPrototypeOf(t);
|
|
7005
|
+
}, _getPrototypeOf(t);
|
|
7006
|
+
}
|
|
7007
|
+
|
|
7008
|
+
function _isNativeReflectConstruct() {
|
|
7009
|
+
try {
|
|
7010
|
+
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
7011
|
+
} catch (t) {}
|
|
7012
|
+
return (_isNativeReflectConstruct = function () {
|
|
7013
|
+
return !!t;
|
|
7014
|
+
})();
|
|
7015
|
+
}
|
|
7016
|
+
|
|
7017
|
+
function _assertThisInitialized(e) {
|
|
7018
|
+
if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
7019
|
+
return e;
|
|
7020
|
+
}
|
|
7021
|
+
|
|
7022
|
+
function _possibleConstructorReturn(t, e) {
|
|
7023
|
+
if (e && ("object" == typeof e || "function" == typeof e)) return e;
|
|
7024
|
+
if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
|
|
7025
|
+
return _assertThisInitialized(t);
|
|
7026
|
+
}
|
|
7027
|
+
|
|
7028
|
+
function _callSuper(t, o, e) {
|
|
7029
|
+
return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
|
|
7030
|
+
}
|
|
7031
|
+
|
|
7032
|
+
function _setPrototypeOf(t, e) {
|
|
7033
|
+
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
7034
|
+
return t.__proto__ = e, t;
|
|
7035
|
+
}, _setPrototypeOf(t, e);
|
|
7036
|
+
}
|
|
7037
|
+
|
|
7038
|
+
function _inherits(t, e) {
|
|
7039
|
+
if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
|
|
7040
|
+
t.prototype = Object.create(e && e.prototype, {
|
|
7041
|
+
constructor: {
|
|
7042
|
+
value: t,
|
|
7043
|
+
writable: !0,
|
|
7044
|
+
configurable: !0
|
|
7045
|
+
}
|
|
7046
|
+
}), Object.defineProperty(t, "prototype", {
|
|
7047
|
+
writable: !1
|
|
7048
|
+
}), e && _setPrototypeOf(t, e);
|
|
7049
|
+
}
|
|
7050
|
+
|
|
7051
|
+
function _isNativeFunction(t) {
|
|
7052
|
+
try {
|
|
7053
|
+
return -1 !== Function.toString.call(t).indexOf("[native code]");
|
|
7054
|
+
} catch (n) {
|
|
7055
|
+
return "function" == typeof t;
|
|
7056
|
+
}
|
|
7057
|
+
}
|
|
7058
|
+
|
|
7059
|
+
function _construct(t, e, r) {
|
|
7060
|
+
if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
|
|
7061
|
+
var o = [null];
|
|
7062
|
+
o.push.apply(o, e);
|
|
7063
|
+
var p = new (t.bind.apply(t, o))();
|
|
7064
|
+
return r && _setPrototypeOf(p, r.prototype), p;
|
|
7065
|
+
}
|
|
7066
|
+
|
|
7067
|
+
function _wrapNativeSuper(t) {
|
|
7068
|
+
var r = "function" == typeof Map ? new Map() : void 0;
|
|
7069
|
+
return _wrapNativeSuper = function (t) {
|
|
7070
|
+
if (null === t || !_isNativeFunction(t)) return t;
|
|
7071
|
+
if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
|
|
7072
|
+
if (void 0 !== r) {
|
|
7073
|
+
if (r.has(t)) return r.get(t);
|
|
7074
|
+
r.set(t, Wrapper);
|
|
7075
|
+
}
|
|
7076
|
+
function Wrapper() {
|
|
7077
|
+
return _construct(t, arguments, _getPrototypeOf(this).constructor);
|
|
7078
|
+
}
|
|
7079
|
+
return Wrapper.prototype = Object.create(t.prototype, {
|
|
7080
|
+
constructor: {
|
|
7081
|
+
value: Wrapper,
|
|
7082
|
+
enumerable: !1,
|
|
7083
|
+
writable: !0,
|
|
7084
|
+
configurable: !0
|
|
7085
|
+
}
|
|
7086
|
+
}), _setPrototypeOf(Wrapper, t);
|
|
7087
|
+
}, _wrapNativeSuper(t);
|
|
7088
|
+
}
|
|
7089
|
+
|
|
7090
|
+
/**
|
|
7091
|
+
* Reading what content answers.
|
|
7092
|
+
*
|
|
7093
|
+
* Every type here comes from `contentApi.ts`, which is a copy of the
|
|
7094
|
+
* service's own `Api.ts` - so the shapes are not re-derived from what this end
|
|
7095
|
+
* wishes it received, and a copy brought up to date fails to compile wherever
|
|
7096
|
+
* this CLI has not caught up.
|
|
7097
|
+
*
|
|
7098
|
+
* The schemas are the runtime half, and they are needed as well as the types:
|
|
7099
|
+
* what arrives is JSON over HTTP from a service that versions separately, so a
|
|
7100
|
+
* type alone asserts a shape rather than checking one. Each schema is
|
|
7101
|
+
* annotated with the copied type it must produce (`z.ZodType<DeclareResponse>`
|
|
7102
|
+
* and so on), which is what ties the two halves together - a schema that drifts
|
|
7103
|
+
* from the copy does not compile, and an answer that drifts from the schema
|
|
7104
|
+
* does not parse. `ValOpsHttp` in `@valbuild/server` reads every other content
|
|
7105
|
+
* route the same way.
|
|
7106
|
+
*
|
|
7107
|
+
* Nothing here is laxer than the copy. An optional field is optional because
|
|
7108
|
+
* the service says so; making a required one optional here would hide exactly
|
|
7109
|
+
* the drift this file exists to catch.
|
|
7110
|
+
*/
|
|
7111
|
+
|
|
7112
|
+
/** An artifact, as it is declared: by key, by hash, by size. */
|
|
7113
|
+
|
|
7114
|
+
/** Permission to write one artifact's bytes to object storage. */
|
|
7115
|
+
|
|
7116
|
+
var publishState = zod.z["enum"](["awaiting-artifacts", "ready", "verified", "live", "failed", "expired"]);
|
|
7117
|
+
var publishProblem = zod.z.object({
|
|
7118
|
+
code: zod.z.string(),
|
|
7119
|
+
message: zod.z.string(),
|
|
7120
|
+
hint: zod.z.string().optional(),
|
|
7121
|
+
keys: zod.z.array(zod.z.string()).optional()
|
|
7122
|
+
});
|
|
7123
|
+
var uploadSlot = zod.z.object({
|
|
7124
|
+
key: zod.z.string(),
|
|
7125
|
+
url: zod.z.string(),
|
|
7126
|
+
method: zod.z.literal("PUT"),
|
|
7127
|
+
headers: zod.z.record(zod.z.string(), zod.z.string()),
|
|
7128
|
+
expiresAt: zod.z.string()
|
|
7129
|
+
});
|
|
7130
|
+
var declareResponse = zod.z.object({
|
|
7131
|
+
publishId: zod.z.string(),
|
|
7132
|
+
state: publishState,
|
|
7133
|
+
project: zod.z.object({
|
|
7134
|
+
publicProjectId: zod.z.string(),
|
|
7135
|
+
siteUrl: zod.z.string().nullable()
|
|
7136
|
+
}),
|
|
7137
|
+
uploads: zod.z.array(uploadSlot),
|
|
7138
|
+
have: zod.z.array(zod.z.string())
|
|
7139
|
+
});
|
|
7140
|
+
var artifactsResponse = zod.z.object({
|
|
7141
|
+
state: publishState,
|
|
7142
|
+
problems: zod.z.array(publishProblem)
|
|
7143
|
+
});
|
|
7144
|
+
var verifyResponse = zod.z.object({
|
|
7145
|
+
state: publishState,
|
|
7146
|
+
ok: zod.z["boolean"](),
|
|
7147
|
+
previewUrl: zod.z.string().nullable(),
|
|
7148
|
+
problems: zod.z.array(publishProblem)
|
|
7149
|
+
});
|
|
7150
|
+
var promoteResponse = zod.z.object({
|
|
7151
|
+
state: publishState,
|
|
7152
|
+
url: zod.z.string().nullable(),
|
|
7153
|
+
commit: zod.z.string().nullable()
|
|
7154
|
+
});
|
|
7155
|
+
var statusResponse = zod.z.object({
|
|
7156
|
+
publishId: zod.z.string(),
|
|
7157
|
+
state: publishState,
|
|
7158
|
+
buildHash: zod.z.string(),
|
|
7159
|
+
missing: zod.z.array(zod.z.string()),
|
|
7160
|
+
problems: zod.z.array(publishProblem)
|
|
7161
|
+
});
|
|
7162
|
+
var publishTokenResponse = zod.z.object({
|
|
7163
|
+
token: zod.z.string(),
|
|
7164
|
+
expiresAt: zod.z.string().nullable(),
|
|
7165
|
+
publicProjectId: zod.z.string(),
|
|
7166
|
+
productionUrl: zod.z.string().nullable()
|
|
7167
|
+
});
|
|
7168
|
+
|
|
7169
|
+
/**
|
|
7170
|
+
* Content answered, and the answer was not one this CLI can act on.
|
|
7171
|
+
*
|
|
7172
|
+
* Separate from a refusal, which is content saying no in a sentence meant for
|
|
7173
|
+
* a person. This is two programs disagreeing - the copy in `contentApi.ts` and
|
|
7174
|
+
* the service that has moved on from it - and the two want opposite things
|
|
7175
|
+
* said about them.
|
|
7176
|
+
*/
|
|
7177
|
+
var PublishProtocolError = /*#__PURE__*/function (_Error) {
|
|
7178
|
+
function PublishProtocolError(message) {
|
|
7179
|
+
var _this;
|
|
7180
|
+
_classCallCheck(this, PublishProtocolError);
|
|
7181
|
+
_this = _callSuper(this, PublishProtocolError, [message]);
|
|
7182
|
+
_this.name = "PublishProtocolError";
|
|
7183
|
+
return _this;
|
|
7184
|
+
}
|
|
7185
|
+
_inherits(PublishProtocolError, _Error);
|
|
7186
|
+
return _createClass(PublishProtocolError);
|
|
7187
|
+
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
7188
|
+
var parseDeclare = function parseDeclare(body) {
|
|
7189
|
+
return parse(declareResponse, body, "POST /v1/publish");
|
|
7190
|
+
};
|
|
7191
|
+
var parseArtifacts = function parseArtifacts(body) {
|
|
7192
|
+
return parse(artifactsResponse, body, "POST /v1/publish/{id}/artifacts");
|
|
7193
|
+
};
|
|
7194
|
+
var parseVerify = function parseVerify(body) {
|
|
7195
|
+
return parse(verifyResponse, body, "POST /v1/publish/{id}/verify");
|
|
7196
|
+
};
|
|
7197
|
+
var parsePromote = function parsePromote(body) {
|
|
7198
|
+
return parse(promoteResponse, body, "POST /v1/publish/{id}/promote");
|
|
7199
|
+
};
|
|
7200
|
+
var parseStatus = function parseStatus(body) {
|
|
7201
|
+
return parse(statusResponse, body, "GET /v1/publish/{id}");
|
|
7202
|
+
};
|
|
7203
|
+
var parsePublishToken = function parsePublishToken(body, call) {
|
|
7204
|
+
return parse(publishTokenResponse, body, call);
|
|
7205
|
+
};
|
|
7206
|
+
|
|
7207
|
+
/**
|
|
7208
|
+
* What a build targets, and the project's files, as the Studio asks for them.
|
|
7209
|
+
*
|
|
7210
|
+
* Both are read through `/publish-api` rather than fetched from the loader,
|
|
7211
|
+
* because a browser has neither the loader's address nor a credential it would
|
|
7212
|
+
* accept. `fetchBuildTarget` in `@valbuild/tanstack-build` is the other half --
|
|
7213
|
+
* same shape, a different caller, and it CASTS where this parses.
|
|
7214
|
+
*
|
|
7215
|
+
* Parsed rather than cast here because of what sits in between: a proxy, a
|
|
7216
|
+
* gateway and a service boundary. An HTML error page cast to `BuildTarget`
|
|
7217
|
+
* fails several layers down inside rolldown with a message about a module
|
|
7218
|
+
* specifier, and the publish that follows would label a build against a layer
|
|
7219
|
+
* that was never there.
|
|
7220
|
+
*
|
|
7221
|
+
* The TYPE is inferred from this schema instead of imported. `BuildTarget` is
|
|
7222
|
+
* declared in `@valbuild/tanstack-build`, which has no zod and deliberately
|
|
7223
|
+
* almost no dependencies -- it goes into a browser bundle -- and this package
|
|
7224
|
+
* is imported by everything. The declarations are kept honest at the one place
|
|
7225
|
+
* the value is used: it is passed straight into `buildUserApp({ target })`, so
|
|
7226
|
+
* a drift between them is a compile error at that call rather than a runtime
|
|
7227
|
+
* surprise.
|
|
7228
|
+
*/
|
|
7229
|
+
var buildTargetResponse = zod.z.object({
|
|
7230
|
+
base: zod.z.object({
|
|
7231
|
+
rev: zod.z.string(),
|
|
7232
|
+
shellRev: zod.z.string(),
|
|
7233
|
+
rscShellRev: zod.z.string(),
|
|
7234
|
+
modules: zod.z.record(zod.z.string(), zod.z.string()),
|
|
7235
|
+
rscModules: zod.z.record(zod.z.string(), zod.z.string()),
|
|
7236
|
+
paths: zod.z.object({
|
|
7237
|
+
baseFromProject: zod.z.string(),
|
|
7238
|
+
projectVendorDir: zod.z.string(),
|
|
7239
|
+
rscVendorBase: zod.z.string(),
|
|
7240
|
+
rscRuntimeSpecifier: zod.z.string(),
|
|
7241
|
+
rscRuntimePath: zod.z.string(),
|
|
7242
|
+
flightServer: zod.z.string(),
|
|
7243
|
+
serverFnBase: zod.z.string()
|
|
7244
|
+
})
|
|
7245
|
+
}),
|
|
7246
|
+
project: zod.z.object({
|
|
7247
|
+
rev: zod.z.string().nullable(),
|
|
7248
|
+
rsc: zod.z["boolean"](),
|
|
7249
|
+
modules: zod.z.record(zod.z.string(), zod.z.string()),
|
|
7250
|
+
css: zod.z.record(zod.z.string(), zod.z.string()),
|
|
7251
|
+
workerOnly: zod.z.array(zod.z.string())
|
|
7252
|
+
})
|
|
7253
|
+
});
|
|
7254
|
+
/**
|
|
7255
|
+
* `null` files is a real answer: a project that has never published.
|
|
7256
|
+
*
|
|
7257
|
+
* Distinguished from an empty record, which would be a project that published
|
|
7258
|
+
* nothing -- and which a build would take as "no entry point" rather than as
|
|
7259
|
+
* "there is nothing here yet".
|
|
7260
|
+
*/
|
|
7261
|
+
var projectSourceResponse = zod.z.object({
|
|
7262
|
+
files: zod.z.record(zod.z.string(), zod.z.string()).nullable(),
|
|
7263
|
+
/**
|
|
7264
|
+
* The live build's `public/*` artifacts, by hash -- what a publisher with no
|
|
7265
|
+
* checkout carries into its build so the site keeps its favicon and images.
|
|
7266
|
+
*
|
|
7267
|
+
* The loader stores public files PER BUILD, so a build that names none
|
|
7268
|
+
* serves none. A publisher with a checkout has them on disk; the Studio has
|
|
7269
|
+
* this. Re-declaring one costs nothing: content holds the bytes for the
|
|
7270
|
+
* project already and asks for no upload.
|
|
7271
|
+
*
|
|
7272
|
+
* `null` when content cannot say -- the live build was not published through
|
|
7273
|
+
* it -- and absent from a content service that predates it. A publisher
|
|
7274
|
+
* must treat both as "unknown", never as "none": publishing on that guess
|
|
7275
|
+
* deletes every public file the site has.
|
|
7276
|
+
*/
|
|
7277
|
+
publicFiles: zod.z.array(zod.z.object({
|
|
7278
|
+
key: zod.z.string(),
|
|
7279
|
+
sha256: zod.z.string(),
|
|
7280
|
+
bytes: zod.z.number()["int"]().nonnegative()
|
|
7281
|
+
})).nullable().optional(),
|
|
7282
|
+
/**
|
|
7283
|
+
* The URL paths the live build serves from `public/`, as the loader has
|
|
7284
|
+
* them -- without the bytes' hashes.
|
|
7285
|
+
*
|
|
7286
|
+
* The fallback for when `publicFiles` is `null`: a build content has no
|
|
7287
|
+
* record of, which is every project cloned from a template seed. A publisher
|
|
7288
|
+
* running on the site's own origin can fetch these and build with them;
|
|
7289
|
+
* after that publish content holds their hashes and `publicFiles` answers.
|
|
7290
|
+
* `null` when the loader serves no build or does not say.
|
|
7291
|
+
*/
|
|
7292
|
+
publicPaths: zod.z.array(zod.z.string()).nullable().optional()
|
|
7293
|
+
});
|
|
7294
|
+
var parseBuildTarget = function parseBuildTarget(body) {
|
|
7295
|
+
return parse(buildTargetResponse, body, "GET /v1/build-target");
|
|
7296
|
+
};
|
|
7297
|
+
var parseProjectSource = function parseProjectSource(body) {
|
|
7298
|
+
return parse(projectSourceResponse, body, "GET /v1/project-source");
|
|
7299
|
+
};
|
|
7300
|
+
|
|
7301
|
+
/**
|
|
7302
|
+
* The `details` of a refusal, when it carries a list of problems.
|
|
7303
|
+
*
|
|
7304
|
+
* Every non-2xx is `{ statusCode, message, details? }`, and the publish routes
|
|
7305
|
+
* put `PublishProblem[]` in `details` - a declaration is answered with EVERY
|
|
7306
|
+
* problem rather than the first, because finding them one round trip at a time
|
|
7307
|
+
* is how a publish takes six attempts. Anything else in there is somebody
|
|
7308
|
+
* else's `details` and is left to the caller's own message.
|
|
7309
|
+
*/
|
|
7310
|
+
function parseProblems(details) {
|
|
7311
|
+
var parsed = zod.z.array(publishProblem).safeParse(details);
|
|
7312
|
+
return parsed.success ? parsed.data : [];
|
|
7313
|
+
}
|
|
7314
|
+
function parse(schema, body, call) {
|
|
7315
|
+
var parsed = schema.safeParse(body);
|
|
7316
|
+
if (!parsed.success) {
|
|
7317
|
+
throw new PublishProtocolError("".concat(call, " answered with something this publisher cannot read: ").concat(zodValidationError.fromError(parsed.error).toString()));
|
|
7318
|
+
}
|
|
7319
|
+
return parsed.data;
|
|
7320
|
+
}
|
|
7321
|
+
|
|
6807
7322
|
exports.DEFAULT_CANVAS_SELECTION = getSitemapTree.DEFAULT_CANVAS_SELECTION;
|
|
6808
7323
|
exports.DEFAULT_CANVAS_SELECTION_SOFT = getSitemapTree.DEFAULT_CANVAS_SELECTION_SOFT;
|
|
6809
7324
|
exports.VAL_AI_SESSION_STORAGE_KEY = getSitemapTree.VAL_AI_SESSION_STORAGE_KEY;
|
|
@@ -6850,6 +7365,7 @@ exports.PatchBlock = PatchBlock;
|
|
|
6850
7365
|
exports.PatchGroup = PatchGroup;
|
|
6851
7366
|
exports.PatchId = PatchId;
|
|
6852
7367
|
exports.PatchJSON = PatchJSON;
|
|
7368
|
+
exports.PublishProtocolError = PublishProtocolError;
|
|
6853
7369
|
exports.RAMP_STEPS = RAMP_STEPS;
|
|
6854
7370
|
exports.RemirrorBr = RemirrorBr;
|
|
6855
7371
|
exports.RemirrorBulletList = RemirrorBulletList;
|
|
@@ -6933,7 +7449,17 @@ exports.isSkippedSource = isSkippedSource;
|
|
|
6933
7449
|
exports.keyOfRecordPath = keyOfRecordPath;
|
|
6934
7450
|
exports.levenshtein = levenshtein;
|
|
6935
7451
|
exports.localeAt = localeAt;
|
|
7452
|
+
exports.memoizePerRequest = memoizePerRequest;
|
|
6936
7453
|
exports.newestCommitSha = newestCommitSha;
|
|
7454
|
+
exports.parseArtifacts = parseArtifacts;
|
|
7455
|
+
exports.parseBuildTarget = parseBuildTarget;
|
|
7456
|
+
exports.parseDeclare = parseDeclare;
|
|
7457
|
+
exports.parseProblems = parseProblems;
|
|
7458
|
+
exports.parseProjectSource = parseProjectSource;
|
|
7459
|
+
exports.parsePromote = parsePromote;
|
|
7460
|
+
exports.parsePublishToken = parsePublishToken;
|
|
7461
|
+
exports.parseStatus = parseStatus;
|
|
7462
|
+
exports.parseVerify = parseVerify;
|
|
6937
7463
|
exports.partitionValidationErrors = partitionValidationErrors;
|
|
6938
7464
|
exports.performSearch = performSearch;
|
|
6939
7465
|
exports.relativeLuminance = relativeLuminance;
|