@valbuild/shared 0.136.0 → 0.136.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 +49 -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 +58 -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 +123 -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 +469 -1
- package/internal/dist/valbuild-shared-internal.cjs.prod.js +469 -1
- package/internal/dist/valbuild-shared-internal.esm.js +460 -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-c732e09a.cjs.dev.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,21 @@ 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(),
|
|
2458
2609
|
/**
|
|
2459
2610
|
* Unpublished changes the save threw away because they could not be
|
|
2460
2611
|
* applied.
|
|
@@ -6804,6 +6955,312 @@ function resolvePairGround(ground, ramp) {
|
|
|
6804
6955
|
return typeof ground === "number" ? ramp[ground] : ground;
|
|
6805
6956
|
}
|
|
6806
6957
|
|
|
6958
|
+
function _defineProperties(e, r) {
|
|
6959
|
+
for (var t = 0; t < r.length; t++) {
|
|
6960
|
+
var o = r[t];
|
|
6961
|
+
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, getSitemapTree._toPropertyKey(o.key), o);
|
|
6962
|
+
}
|
|
6963
|
+
}
|
|
6964
|
+
function _createClass(e, r, t) {
|
|
6965
|
+
return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
|
|
6966
|
+
writable: !1
|
|
6967
|
+
}), e;
|
|
6968
|
+
}
|
|
6969
|
+
|
|
6970
|
+
function _classCallCheck(a, n) {
|
|
6971
|
+
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
6972
|
+
}
|
|
6973
|
+
|
|
6974
|
+
function _getPrototypeOf(t) {
|
|
6975
|
+
return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
|
|
6976
|
+
return t.__proto__ || Object.getPrototypeOf(t);
|
|
6977
|
+
}, _getPrototypeOf(t);
|
|
6978
|
+
}
|
|
6979
|
+
|
|
6980
|
+
function _isNativeReflectConstruct() {
|
|
6981
|
+
try {
|
|
6982
|
+
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
6983
|
+
} catch (t) {}
|
|
6984
|
+
return (_isNativeReflectConstruct = function () {
|
|
6985
|
+
return !!t;
|
|
6986
|
+
})();
|
|
6987
|
+
}
|
|
6988
|
+
|
|
6989
|
+
function _assertThisInitialized(e) {
|
|
6990
|
+
if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
6991
|
+
return e;
|
|
6992
|
+
}
|
|
6993
|
+
|
|
6994
|
+
function _possibleConstructorReturn(t, e) {
|
|
6995
|
+
if (e && ("object" == typeof e || "function" == typeof e)) return e;
|
|
6996
|
+
if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
|
|
6997
|
+
return _assertThisInitialized(t);
|
|
6998
|
+
}
|
|
6999
|
+
|
|
7000
|
+
function _callSuper(t, o, e) {
|
|
7001
|
+
return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
|
|
7002
|
+
}
|
|
7003
|
+
|
|
7004
|
+
function _setPrototypeOf(t, e) {
|
|
7005
|
+
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
7006
|
+
return t.__proto__ = e, t;
|
|
7007
|
+
}, _setPrototypeOf(t, e);
|
|
7008
|
+
}
|
|
7009
|
+
|
|
7010
|
+
function _inherits(t, e) {
|
|
7011
|
+
if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
|
|
7012
|
+
t.prototype = Object.create(e && e.prototype, {
|
|
7013
|
+
constructor: {
|
|
7014
|
+
value: t,
|
|
7015
|
+
writable: !0,
|
|
7016
|
+
configurable: !0
|
|
7017
|
+
}
|
|
7018
|
+
}), Object.defineProperty(t, "prototype", {
|
|
7019
|
+
writable: !1
|
|
7020
|
+
}), e && _setPrototypeOf(t, e);
|
|
7021
|
+
}
|
|
7022
|
+
|
|
7023
|
+
function _isNativeFunction(t) {
|
|
7024
|
+
try {
|
|
7025
|
+
return -1 !== Function.toString.call(t).indexOf("[native code]");
|
|
7026
|
+
} catch (n) {
|
|
7027
|
+
return "function" == typeof t;
|
|
7028
|
+
}
|
|
7029
|
+
}
|
|
7030
|
+
|
|
7031
|
+
function _construct(t, e, r) {
|
|
7032
|
+
if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
|
|
7033
|
+
var o = [null];
|
|
7034
|
+
o.push.apply(o, e);
|
|
7035
|
+
var p = new (t.bind.apply(t, o))();
|
|
7036
|
+
return r && _setPrototypeOf(p, r.prototype), p;
|
|
7037
|
+
}
|
|
7038
|
+
|
|
7039
|
+
function _wrapNativeSuper(t) {
|
|
7040
|
+
var r = "function" == typeof Map ? new Map() : void 0;
|
|
7041
|
+
return _wrapNativeSuper = function (t) {
|
|
7042
|
+
if (null === t || !_isNativeFunction(t)) return t;
|
|
7043
|
+
if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
|
|
7044
|
+
if (void 0 !== r) {
|
|
7045
|
+
if (r.has(t)) return r.get(t);
|
|
7046
|
+
r.set(t, Wrapper);
|
|
7047
|
+
}
|
|
7048
|
+
function Wrapper() {
|
|
7049
|
+
return _construct(t, arguments, _getPrototypeOf(this).constructor);
|
|
7050
|
+
}
|
|
7051
|
+
return Wrapper.prototype = Object.create(t.prototype, {
|
|
7052
|
+
constructor: {
|
|
7053
|
+
value: Wrapper,
|
|
7054
|
+
enumerable: !1,
|
|
7055
|
+
writable: !0,
|
|
7056
|
+
configurable: !0
|
|
7057
|
+
}
|
|
7058
|
+
}), _setPrototypeOf(Wrapper, t);
|
|
7059
|
+
}, _wrapNativeSuper(t);
|
|
7060
|
+
}
|
|
7061
|
+
|
|
7062
|
+
/**
|
|
7063
|
+
* Reading what content answers.
|
|
7064
|
+
*
|
|
7065
|
+
* Every type here comes from `contentApi.ts`, which is a copy of the
|
|
7066
|
+
* service's own `Api.ts` - so the shapes are not re-derived from what this end
|
|
7067
|
+
* wishes it received, and a copy brought up to date fails to compile wherever
|
|
7068
|
+
* this CLI has not caught up.
|
|
7069
|
+
*
|
|
7070
|
+
* The schemas are the runtime half, and they are needed as well as the types:
|
|
7071
|
+
* what arrives is JSON over HTTP from a service that versions separately, so a
|
|
7072
|
+
* type alone asserts a shape rather than checking one. Each schema is
|
|
7073
|
+
* annotated with the copied type it must produce (`z.ZodType<DeclareResponse>`
|
|
7074
|
+
* and so on), which is what ties the two halves together - a schema that drifts
|
|
7075
|
+
* from the copy does not compile, and an answer that drifts from the schema
|
|
7076
|
+
* does not parse. `ValOpsHttp` in `@valbuild/server` reads every other content
|
|
7077
|
+
* route the same way.
|
|
7078
|
+
*
|
|
7079
|
+
* Nothing here is laxer than the copy. An optional field is optional because
|
|
7080
|
+
* the service says so; making a required one optional here would hide exactly
|
|
7081
|
+
* the drift this file exists to catch.
|
|
7082
|
+
*/
|
|
7083
|
+
|
|
7084
|
+
/** An artifact, as it is declared: by key, by hash, by size. */
|
|
7085
|
+
|
|
7086
|
+
/** Permission to write one artifact's bytes to object storage. */
|
|
7087
|
+
|
|
7088
|
+
var publishState = zod.z["enum"](["awaiting-artifacts", "ready", "verified", "live", "failed", "expired"]);
|
|
7089
|
+
var publishProblem = zod.z.object({
|
|
7090
|
+
code: zod.z.string(),
|
|
7091
|
+
message: zod.z.string(),
|
|
7092
|
+
hint: zod.z.string().optional(),
|
|
7093
|
+
keys: zod.z.array(zod.z.string()).optional()
|
|
7094
|
+
});
|
|
7095
|
+
var uploadSlot = zod.z.object({
|
|
7096
|
+
key: zod.z.string(),
|
|
7097
|
+
url: zod.z.string(),
|
|
7098
|
+
method: zod.z.literal("PUT"),
|
|
7099
|
+
headers: zod.z.record(zod.z.string(), zod.z.string()),
|
|
7100
|
+
expiresAt: zod.z.string()
|
|
7101
|
+
});
|
|
7102
|
+
var declareResponse = zod.z.object({
|
|
7103
|
+
publishId: zod.z.string(),
|
|
7104
|
+
state: publishState,
|
|
7105
|
+
project: zod.z.object({
|
|
7106
|
+
publicProjectId: zod.z.string(),
|
|
7107
|
+
siteUrl: zod.z.string().nullable()
|
|
7108
|
+
}),
|
|
7109
|
+
uploads: zod.z.array(uploadSlot),
|
|
7110
|
+
have: zod.z.array(zod.z.string())
|
|
7111
|
+
});
|
|
7112
|
+
var artifactsResponse = zod.z.object({
|
|
7113
|
+
state: publishState,
|
|
7114
|
+
problems: zod.z.array(publishProblem)
|
|
7115
|
+
});
|
|
7116
|
+
var verifyResponse = zod.z.object({
|
|
7117
|
+
state: publishState,
|
|
7118
|
+
ok: zod.z["boolean"](),
|
|
7119
|
+
previewUrl: zod.z.string().nullable(),
|
|
7120
|
+
problems: zod.z.array(publishProblem)
|
|
7121
|
+
});
|
|
7122
|
+
var promoteResponse = zod.z.object({
|
|
7123
|
+
state: publishState,
|
|
7124
|
+
url: zod.z.string().nullable(),
|
|
7125
|
+
commit: zod.z.string().nullable()
|
|
7126
|
+
});
|
|
7127
|
+
var statusResponse = zod.z.object({
|
|
7128
|
+
publishId: zod.z.string(),
|
|
7129
|
+
state: publishState,
|
|
7130
|
+
buildHash: zod.z.string(),
|
|
7131
|
+
missing: zod.z.array(zod.z.string()),
|
|
7132
|
+
problems: zod.z.array(publishProblem)
|
|
7133
|
+
});
|
|
7134
|
+
var publishTokenResponse = zod.z.object({
|
|
7135
|
+
token: zod.z.string(),
|
|
7136
|
+
expiresAt: zod.z.string().nullable(),
|
|
7137
|
+
publicProjectId: zod.z.string(),
|
|
7138
|
+
productionUrl: zod.z.string().nullable()
|
|
7139
|
+
});
|
|
7140
|
+
|
|
7141
|
+
/**
|
|
7142
|
+
* Content answered, and the answer was not one this CLI can act on.
|
|
7143
|
+
*
|
|
7144
|
+
* Separate from a refusal, which is content saying no in a sentence meant for
|
|
7145
|
+
* a person. This is two programs disagreeing - the copy in `contentApi.ts` and
|
|
7146
|
+
* the service that has moved on from it - and the two want opposite things
|
|
7147
|
+
* said about them.
|
|
7148
|
+
*/
|
|
7149
|
+
var PublishProtocolError = /*#__PURE__*/function (_Error) {
|
|
7150
|
+
function PublishProtocolError(message) {
|
|
7151
|
+
var _this;
|
|
7152
|
+
_classCallCheck(this, PublishProtocolError);
|
|
7153
|
+
_this = _callSuper(this, PublishProtocolError, [message]);
|
|
7154
|
+
_this.name = "PublishProtocolError";
|
|
7155
|
+
return _this;
|
|
7156
|
+
}
|
|
7157
|
+
_inherits(PublishProtocolError, _Error);
|
|
7158
|
+
return _createClass(PublishProtocolError);
|
|
7159
|
+
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
7160
|
+
var parseDeclare = function parseDeclare(body) {
|
|
7161
|
+
return parse(declareResponse, body, "POST /v1/publish");
|
|
7162
|
+
};
|
|
7163
|
+
var parseArtifacts = function parseArtifacts(body) {
|
|
7164
|
+
return parse(artifactsResponse, body, "POST /v1/publish/{id}/artifacts");
|
|
7165
|
+
};
|
|
7166
|
+
var parseVerify = function parseVerify(body) {
|
|
7167
|
+
return parse(verifyResponse, body, "POST /v1/publish/{id}/verify");
|
|
7168
|
+
};
|
|
7169
|
+
var parsePromote = function parsePromote(body) {
|
|
7170
|
+
return parse(promoteResponse, body, "POST /v1/publish/{id}/promote");
|
|
7171
|
+
};
|
|
7172
|
+
var parseStatus = function parseStatus(body) {
|
|
7173
|
+
return parse(statusResponse, body, "GET /v1/publish/{id}");
|
|
7174
|
+
};
|
|
7175
|
+
var parsePublishToken = function parsePublishToken(body, call) {
|
|
7176
|
+
return parse(publishTokenResponse, body, call);
|
|
7177
|
+
};
|
|
7178
|
+
|
|
7179
|
+
/**
|
|
7180
|
+
* What a build targets, and the project's files, as the Studio asks for them.
|
|
7181
|
+
*
|
|
7182
|
+
* Both are read through `/publish-api` rather than fetched from the loader,
|
|
7183
|
+
* because a browser has neither the loader's address nor a credential it would
|
|
7184
|
+
* accept. `fetchBuildTarget` in `@valbuild/tanstack-build` is the other half --
|
|
7185
|
+
* same shape, a different caller, and it CASTS where this parses.
|
|
7186
|
+
*
|
|
7187
|
+
* Parsed rather than cast here because of what sits in between: a proxy, a
|
|
7188
|
+
* gateway and a service boundary. An HTML error page cast to `BuildTarget`
|
|
7189
|
+
* fails several layers down inside rolldown with a message about a module
|
|
7190
|
+
* specifier, and the publish that follows would label a build against a layer
|
|
7191
|
+
* that was never there.
|
|
7192
|
+
*
|
|
7193
|
+
* The TYPE is inferred from this schema instead of imported. `BuildTarget` is
|
|
7194
|
+
* declared in `@valbuild/tanstack-build`, which has no zod and deliberately
|
|
7195
|
+
* almost no dependencies -- it goes into a browser bundle -- and this package
|
|
7196
|
+
* is imported by everything. The declarations are kept honest at the one place
|
|
7197
|
+
* the value is used: it is passed straight into `buildUserApp({ target })`, so
|
|
7198
|
+
* a drift between them is a compile error at that call rather than a runtime
|
|
7199
|
+
* surprise.
|
|
7200
|
+
*/
|
|
7201
|
+
var buildTargetResponse = zod.z.object({
|
|
7202
|
+
base: zod.z.object({
|
|
7203
|
+
rev: zod.z.string(),
|
|
7204
|
+
shellRev: zod.z.string(),
|
|
7205
|
+
rscShellRev: zod.z.string(),
|
|
7206
|
+
modules: zod.z.record(zod.z.string(), zod.z.string()),
|
|
7207
|
+
rscModules: zod.z.record(zod.z.string(), zod.z.string()),
|
|
7208
|
+
paths: zod.z.object({
|
|
7209
|
+
baseFromProject: zod.z.string(),
|
|
7210
|
+
projectVendorDir: zod.z.string(),
|
|
7211
|
+
rscVendorBase: zod.z.string(),
|
|
7212
|
+
rscRuntimeSpecifier: zod.z.string(),
|
|
7213
|
+
rscRuntimePath: zod.z.string(),
|
|
7214
|
+
flightServer: zod.z.string(),
|
|
7215
|
+
serverFnBase: zod.z.string()
|
|
7216
|
+
})
|
|
7217
|
+
}),
|
|
7218
|
+
project: zod.z.object({
|
|
7219
|
+
rev: zod.z.string().nullable(),
|
|
7220
|
+
rsc: zod.z["boolean"](),
|
|
7221
|
+
modules: zod.z.record(zod.z.string(), zod.z.string()),
|
|
7222
|
+
css: zod.z.record(zod.z.string(), zod.z.string()),
|
|
7223
|
+
workerOnly: zod.z.array(zod.z.string())
|
|
7224
|
+
})
|
|
7225
|
+
});
|
|
7226
|
+
/**
|
|
7227
|
+
* `null` files is a real answer: a project that has never published.
|
|
7228
|
+
*
|
|
7229
|
+
* Distinguished from an empty record, which would be a project that published
|
|
7230
|
+
* nothing -- and which a build would take as "no entry point" rather than as
|
|
7231
|
+
* "there is nothing here yet".
|
|
7232
|
+
*/
|
|
7233
|
+
var projectSourceResponse = zod.z.object({
|
|
7234
|
+
files: zod.z.record(zod.z.string(), zod.z.string()).nullable()
|
|
7235
|
+
});
|
|
7236
|
+
var parseBuildTarget = function parseBuildTarget(body) {
|
|
7237
|
+
return parse(buildTargetResponse, body, "GET /v1/build-target");
|
|
7238
|
+
};
|
|
7239
|
+
var parseProjectSource = function parseProjectSource(body) {
|
|
7240
|
+
return parse(projectSourceResponse, body, "GET /v1/project-source");
|
|
7241
|
+
};
|
|
7242
|
+
|
|
7243
|
+
/**
|
|
7244
|
+
* The `details` of a refusal, when it carries a list of problems.
|
|
7245
|
+
*
|
|
7246
|
+
* Every non-2xx is `{ statusCode, message, details? }`, and the publish routes
|
|
7247
|
+
* put `PublishProblem[]` in `details` - a declaration is answered with EVERY
|
|
7248
|
+
* problem rather than the first, because finding them one round trip at a time
|
|
7249
|
+
* is how a publish takes six attempts. Anything else in there is somebody
|
|
7250
|
+
* else's `details` and is left to the caller's own message.
|
|
7251
|
+
*/
|
|
7252
|
+
function parseProblems(details) {
|
|
7253
|
+
var parsed = zod.z.array(publishProblem).safeParse(details);
|
|
7254
|
+
return parsed.success ? parsed.data : [];
|
|
7255
|
+
}
|
|
7256
|
+
function parse(schema, body, call) {
|
|
7257
|
+
var parsed = schema.safeParse(body);
|
|
7258
|
+
if (!parsed.success) {
|
|
7259
|
+
throw new PublishProtocolError("".concat(call, " answered with something this publisher cannot read: ").concat(zodValidationError.fromError(parsed.error).toString()));
|
|
7260
|
+
}
|
|
7261
|
+
return parsed.data;
|
|
7262
|
+
}
|
|
7263
|
+
|
|
6807
7264
|
exports.DEFAULT_CANVAS_SELECTION = getSitemapTree.DEFAULT_CANVAS_SELECTION;
|
|
6808
7265
|
exports.DEFAULT_CANVAS_SELECTION_SOFT = getSitemapTree.DEFAULT_CANVAS_SELECTION_SOFT;
|
|
6809
7266
|
exports.VAL_AI_SESSION_STORAGE_KEY = getSitemapTree.VAL_AI_SESSION_STORAGE_KEY;
|
|
@@ -6850,6 +7307,7 @@ exports.PatchBlock = PatchBlock;
|
|
|
6850
7307
|
exports.PatchGroup = PatchGroup;
|
|
6851
7308
|
exports.PatchId = PatchId;
|
|
6852
7309
|
exports.PatchJSON = PatchJSON;
|
|
7310
|
+
exports.PublishProtocolError = PublishProtocolError;
|
|
6853
7311
|
exports.RAMP_STEPS = RAMP_STEPS;
|
|
6854
7312
|
exports.RemirrorBr = RemirrorBr;
|
|
6855
7313
|
exports.RemirrorBulletList = RemirrorBulletList;
|
|
@@ -6933,7 +7391,17 @@ exports.isSkippedSource = isSkippedSource;
|
|
|
6933
7391
|
exports.keyOfRecordPath = keyOfRecordPath;
|
|
6934
7392
|
exports.levenshtein = levenshtein;
|
|
6935
7393
|
exports.localeAt = localeAt;
|
|
7394
|
+
exports.memoizePerRequest = memoizePerRequest;
|
|
6936
7395
|
exports.newestCommitSha = newestCommitSha;
|
|
7396
|
+
exports.parseArtifacts = parseArtifacts;
|
|
7397
|
+
exports.parseBuildTarget = parseBuildTarget;
|
|
7398
|
+
exports.parseDeclare = parseDeclare;
|
|
7399
|
+
exports.parseProblems = parseProblems;
|
|
7400
|
+
exports.parseProjectSource = parseProjectSource;
|
|
7401
|
+
exports.parsePromote = parsePromote;
|
|
7402
|
+
exports.parsePublishToken = parsePublishToken;
|
|
7403
|
+
exports.parseStatus = parseStatus;
|
|
7404
|
+
exports.parseVerify = parseVerify;
|
|
6937
7405
|
exports.partitionValidationErrors = partitionValidationErrors;
|
|
6938
7406
|
exports.performSearch = performSearch;
|
|
6939
7407
|
exports.relativeLuminance = relativeLuminance;
|