@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.
@@ -1,6 +1,6 @@
1
1
  import { Internal, CODE_LANGUAGES, resolveSettingsModule, missingDeclaredKeys, localeOfValue, discriminatedUnionBranchOf, DEFAULT_COLOR_FORMAT, declaredKeySetOf } from '@valbuild/core';
2
- import { _ as _createForOfIteratorHelper, o as _objectSpread2, q as _arrayLikeToArray, r as _unsupportedIterableToArray, s as _typeof, t as _defineProperty } from '../../dist/getSitemapTree-878d3888.esm.js';
3
- export { D as DEFAULT_CANVAS_SELECTION, e as DEFAULT_CANVAS_SELECTION_SOFT, b as VAL_AI_SESSION_STORAGE_KEY, d as VAL_CANVAS_MESSAGE, c as VAL_CANVAS_PARAM, V as VAL_CONFIG_SESSION_STORAGE_KEY, a as VAL_THEME_SESSION_STORAGE_KEY, h as getNextAppRouterSourceFolder, m as getPageRouterSitemapTree, k as getPageRouterSourceFolder, n as getPatternFromModuleFilePath, j as getTanStackRouterSourceFolder, l as isTanStackRoutesFolder, g as isValCanvasFrame, i as isValCanvasPageMessage, f as isValCanvasStudioMessage, p as parseRoutePattern, w as withValCanvasParam } from '../../dist/getSitemapTree-878d3888.esm.js';
2
+ import { _ as _createForOfIteratorHelper, o as _objectSpread2, q as _arrayLikeToArray, r as _unsupportedIterableToArray, s as _typeof, t as _defineProperty, u as _toPropertyKey } from '../../dist/getSitemapTree-6fcdf745.esm.js';
3
+ export { D as DEFAULT_CANVAS_SELECTION, e as DEFAULT_CANVAS_SELECTION_SOFT, b as VAL_AI_SESSION_STORAGE_KEY, d as VAL_CANVAS_MESSAGE, c as VAL_CANVAS_PARAM, V as VAL_CONFIG_SESSION_STORAGE_KEY, a as VAL_THEME_SESSION_STORAGE_KEY, h as getNextAppRouterSourceFolder, m as getPageRouterSitemapTree, k as getPageRouterSourceFolder, n as getPatternFromModuleFilePath, j as getTanStackRouterSourceFolder, l as isTanStackRoutesFolder, g as isValCanvasFrame, i as isValCanvasPageMessage, f as isValCanvasStudioMessage, p as parseRoutePattern, w as withValCanvasParam } from '../../dist/getSitemapTree-6fcdf745.esm.js';
4
4
  import { z } from 'zod';
5
5
  import { fromError } from 'zod-validation-error';
6
6
  import FlexSearch from 'flexsearch';
@@ -654,6 +654,62 @@ var VAL_SESSION_COOKIE = Internal.VAL_SESSION_COOKIE;
654
654
  var VAL_STATE_COOKIE = Internal.VAL_STATE_COOKIE;
655
655
  var VAL_ENABLE_COOKIE_NAME = Internal.VAL_ENABLE_COOKIE_NAME;
656
656
 
657
+ /**
658
+ * One value, computed once per REQUEST.
659
+ *
660
+ * `fetchVal` in draft mode reads the whole module tree out of `/sources/~`, and
661
+ * a page that calls it three times used to ask three times — the answer being
662
+ * byte-identical each time, because the query and the session are fixed for the
663
+ * length of a request. This is what makes the second and third call free.
664
+ *
665
+ * ## Why the scope is the REQUEST and can never be wider
666
+ *
667
+ * The memoised response is `own_patch_groups_only: true` — it contains the
668
+ * CALLER'S OWN unpublished work, resolved from their session cookie. A memo
669
+ * that outlived the request would serve one author's staged edits to the next
670
+ * visitor, which is the exact failure `own_patch_groups_only` exists to
671
+ * prevent, and it would be invisible: the draft would simply render somebody
672
+ * else's half-finished sentence.
673
+ *
674
+ * So this module holds NO state of its own. The caller supplies the box, and
675
+ * the box has to come from something the framework already scopes to the
676
+ * request — React's `cache()` in an RSC, a `WeakMap` keyed on the `Request` in
677
+ * TanStack Start. `null` means "no request scope available", and that is not an
678
+ * error: it falls back to computing every time, which is what the code did
679
+ * before this existed. Ineffective is a safe failure here; leaking is not.
680
+ *
681
+ * The `key` is the second half of that guarantee. It carries whatever the
682
+ * answer depends on — the session — so a box that somehow outlived its request,
683
+ * or is shared by two sessions, MISSES rather than serving the wrong draft.
684
+ *
685
+ * ## The promise is cached, not the value
686
+ *
687
+ * React renders siblings concurrently, so three `fetchVal` calls in one page
688
+ * are usually in flight at the same time rather than one after another.
689
+ * Caching the resolved value would dedupe none of them; caching the promise
690
+ * dedupes both orderings.
691
+ */
692
+
693
+ /**
694
+ * Returns the memoised promise for `key`, computing it only on a miss.
695
+ *
696
+ * A rejection is memoised along with everything else, on purpose: one failed
697
+ * read per request is the same answer for every caller in it, and retrying it
698
+ * two more times only makes a broken draft slower to render.
699
+ */
700
+ function memoizePerRequest(box, key, compute) {
701
+ if (box === null) {
702
+ return compute();
703
+ }
704
+ if (box.promise !== undefined && box.key === key) {
705
+ return box.promise;
706
+ }
707
+ var promise = compute();
708
+ box.key = key;
709
+ box.promise = promise;
710
+ return promise;
711
+ }
712
+
657
713
  function _regeneratorDefine(e, r, n, t) {
658
714
  var i = Object.defineProperty;
659
715
  try {
@@ -1967,6 +2023,86 @@ var Api = {
1967
2023
  }
1968
2024
  },
1969
2025
  // This has a path which is like this: /upload/patches/:patchId/files. Example: /upload/patches/76b9237a-7712-4d60-88b4-d273e6d6fe18/files
2026
+ /**
2027
+ * The content service's publish API, reached through this deployment.
2028
+ *
2029
+ * A managed project is built in the Studio's own tab -- there is no host
2030
+ * watching a repository to pick a commit up -- and what it builds then has to
2031
+ * be published. The browser cannot do that itself: it holds a session cookie
2032
+ * for this origin and no credential content would accept. So the publish
2033
+ * conversation goes through here, exactly as patches already do.
2034
+ *
2035
+ * ## Deliberately not typed past this point
2036
+ *
2037
+ * No `res`, and a body this does not describe. The shapes belong to content,
2038
+ * and they are already written down twice -- once in content's own `Api.ts`
2039
+ * and once in the copy `@valbuild/cli` keeps beside its parser so the two can
2040
+ * be diffed by eye. A third copy here would be a third thing to keep in step,
2041
+ * and this layer has no decision to make that would need one: it authenticates
2042
+ * the caller, swaps the credential, and carries status and body back verbatim.
2043
+ * The Studio parses the answer with the same module the CLI does.
2044
+ *
2045
+ * That means this route answers with statuses the generic result type does not
2046
+ * model -- a 409 when a publish has already gone live, for one. `/save` has
2047
+ * always done the same; the dispatch boundary erases the type and the adapter
2048
+ * sends what it is given.
2049
+ *
2050
+ * ## What it may reach
2051
+ *
2052
+ * The sub-path is content's, minus `/v1`: `/publish`, `/publish/{id}` and its
2053
+ * three steps, and `/build-target`. `ValOpsHttp.publishApi` holds the allow
2054
+ * list, beside the credential, because the browser chooses this path.
2055
+ */
2056
+ "/publish-api": {
2057
+ GET: {
2058
+ req: {
2059
+ path: z.string().optional(),
2060
+ cookies: {
2061
+ val_session: z.string().optional()
2062
+ }
2063
+ },
2064
+ /*
2065
+ * Content's status and body, carried through.
2066
+ *
2067
+ * Permissive on purpose: describing the shapes here would be the third
2068
+ * copy of a contract content owns, and this layer reads none of them. A
2069
+ * body that is not JSON -- a gateway's HTML error page -- arrives as
2070
+ * `{ message }` rather than throwing, because a publish failing is
2071
+ * something the editor has to be told about in words.
2072
+ */
2073
+ res: z.object({
2074
+ status: z.number(),
2075
+ json: z.unknown()
2076
+ })
2077
+ },
2078
+ POST: {
2079
+ req: {
2080
+ path: z.string().optional(),
2081
+ /*
2082
+ * Unknown, and passed through unread. Every field content accepts here
2083
+ * would otherwise have to be declared -- and kept in step -- by a layer
2084
+ * that never looks at one.
2085
+ */
2086
+ body: z.unknown().optional(),
2087
+ cookies: {
2088
+ val_session: z.string().optional()
2089
+ }
2090
+ },
2091
+ /*
2092
+ * Content's status and body, carried through.
2093
+ *
2094
+ * Permissive on purpose: describing the shapes here would be the third
2095
+ * copy of a contract content owns, and this layer reads none of them. A
2096
+ * body that is not JSON -- a gateway's HTML error page -- arrives as
2097
+ * `{ message }` rather than throwing, because a publish failing is
2098
+ * something the editor has to be told about in words.
2099
+ */
2100
+ res: z.object({
2101
+ status: z.number(),
2102
+ json: z.unknown()
2103
+ })
2104
+ }
2105
+ },
1970
2106
  "/upload/patches": {
1971
2107
  POST: {
1972
2108
  req: {
@@ -2448,6 +2584,49 @@ var Api = {
2448
2584
  * server that predates this.
2449
2585
  */
2450
2586
  commitSha: z.string().optional(),
2587
+ /**
2588
+ * The source files this commit wrote, by path, for a MANAGED project.
2589
+ *
2590
+ * A managed project has nobody to deploy it, so the Studio builds
2591
+ * the site in the tab -- and the build has to contain the text this
2592
+ * commit just produced. Nothing else can give it that: the
2593
+ * project's stored source is what the LAST build was made from, and
2594
+ * turning patched Source back into `.val.ts` text happens here, on
2595
+ * the server, not in a browser. `null` is a file the commit
2596
+ * deleted.
2597
+ *
2598
+ * Absent for a connected project, whose host builds from the
2599
+ * repository, and from a server that predates it.
2600
+ */
2601
+ sourceFiles: z.record(z.string(), z.string().nullable()).optional(),
2602
+ /**
2603
+ * The binary files this commit wrote -- an image uploaded in the
2604
+ * Studio -- base64, by path, for a MANAGED project.
2605
+ *
2606
+ * The same reason as `sourceFiles`: the in-tab build publishes the
2607
+ * site, and a file this commit added is in no earlier build. Local
2608
+ * files only; a remote one is served from its own URL and was never
2609
+ * part of a build. A deleted file is a `null` in `sourceFiles`, as
2610
+ * it always was.
2611
+ */
2612
+ binaryFiles: z.record(z.string(), z.string()).optional(),
2613
+ /**
2614
+ * The branch this commit is on, for a MANAGED project -- the
2615
+ * content service's word for it.
2616
+ *
2617
+ * The in-tab build has to name the branch it was made at, and its
2618
+ * only other source is the `val.server.ts` the last build was
2619
+ * wired with: a project cloned from a template seed has one wired
2620
+ * at no commit, so without this its first publish is branchless
2621
+ * and the loader refuses it.
2622
+ */
2623
+ branch: z.string().optional(),
2624
+ /**
2625
+ * Binary files this commit wrote whose bytes the server could not
2626
+ * read back before committing. Named so the Studio refuses to build
2627
+ * a site that would 404 them, rather than publishing it.
2628
+ */
2629
+ binaryFilesUnread: z.array(z.string()).optional(),
2451
2630
  /**
2452
2631
  * Unpublished changes the save threw away because they could not be
2453
2632
  * applied.
@@ -6797,4 +6976,340 @@ function resolvePairGround(ground, ramp) {
6797
6976
  return typeof ground === "number" ? ramp[ground] : ground;
6798
6977
  }
6799
6978
 
6800
- export { AA_LARGE, AA_TEXT, Api, BRAND_CONTRAST_PAIRS, BinaryFileRef, CodeOptions, ColorOptions, DEFAULT_ERROR_MESSAGE, DateOptions, ENCODE_DEFAULTS, ENCODE_MIME_TYPE_OF, FileOptions, HistoricalCommit, HistoricalModule, HistoricalPatchSet, HistoryError, ImageEncodeOption, ImageOptions, JSONValue, JSON_ENTRIES_BATCH_MAX, ModuleComparison, NEVER_ENCODED, ParentRef$1 as ParentRef, Patch, PatchBlock, PatchGroup, PatchId, PatchJSON, RAMP_STEPS, RemirrorBr, RemirrorBulletList, RemirrorHeading, RemirrorImage, RemirrorJSON, RemirrorLinkMark, RemirrorListItem, RemirrorOrderedList, RemirrorParagraph, RemirrorText, RemirrorTextMark, RestoreVerdict, RichTextOptions, SCHEMA_SOURCE_FIXES, SerializedArraySchema, SerializedBooleanSchema, SerializedCodeSchema, SerializedColorSchema, SerializedDateSchema, SerializedDateTimeSchema, SerializedDiscriminatedUnionSchema, SerializedEnumSchema, SerializedFileSchema, SerializedImageSchema, SerializedKeyOfSchema, SerializedLiteralSchema, SerializedLocaleSchema, SerializedNumberSchema, SerializedObjectSchema, SerializedRecordSchema, SerializedRichTextSchema, SerializedRouteSchema, SerializedSchema, SerializedSettingsSchema, SerializedStringSchema, SerializedValViewSchema, SharedValConfig, VAL_ENABLE_COOKIE_NAME, VAL_GREEN_RAMP, VAL_SESSION_COOKIE, VAL_STATE_COOKIE, ValCommit, ValDeployment, accentRamp, buildDuplicatePatch, buildEmptyAtPathPatch, buildFileRefValue, buildImageGalleryPatch, buildRemoveImageGalleryEntryPatch, buildSearchIndex, checkCompatibility, chooseEncoded, concatModulePath, contrastRatio, createRegExpFromPattern, createSearchIndex, createValClient, declaredLocales, describeContainerAtPath, emptyOf, explainIncompatible, filterBlockingValidationErrors, filterRoutesByPatterns, findSimilar, fitWithin, flattenRichText, getErrorMessageFromUnknownJson, getFilenameFromRef, getInlineImgInfo, getKeyOfRecordAt, getRefParts, getRoutesOf, getRoutesWithModulePaths, getSourceAt, indexModule, isMimeTypeAccepted, isRemoteSchema, isSchemaSourceFixError, isSkippedSource, keyOfRecordPath, levenshtein, localeAt, newestCommitSha, partitionValidationErrors, performSearch, relativeLuminance, remirrorToRichTextSource, removeModule, resolveEncodeSettings, resolvePairGround, resolveSchemaSourceFixForError, resolveSchemaSourceFixes, resolveSerializedSchemaAtPath, richTextToRemirror, safeParsePatch, sourcePathOfChild, themeCustomProperties, toolNames, traverseSchemaSource, urlOf, validateRoutePatterns, withExtension };
6979
+ function _defineProperties(e, r) {
6980
+ for (var t = 0; t < r.length; t++) {
6981
+ var o = r[t];
6982
+ o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
6983
+ }
6984
+ }
6985
+ function _createClass(e, r, t) {
6986
+ return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
6987
+ writable: !1
6988
+ }), e;
6989
+ }
6990
+
6991
+ function _classCallCheck(a, n) {
6992
+ if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
6993
+ }
6994
+
6995
+ function _getPrototypeOf(t) {
6996
+ return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
6997
+ return t.__proto__ || Object.getPrototypeOf(t);
6998
+ }, _getPrototypeOf(t);
6999
+ }
7000
+
7001
+ function _isNativeReflectConstruct() {
7002
+ try {
7003
+ var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
7004
+ } catch (t) {}
7005
+ return (_isNativeReflectConstruct = function () {
7006
+ return !!t;
7007
+ })();
7008
+ }
7009
+
7010
+ function _assertThisInitialized(e) {
7011
+ if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
7012
+ return e;
7013
+ }
7014
+
7015
+ function _possibleConstructorReturn(t, e) {
7016
+ if (e && ("object" == typeof e || "function" == typeof e)) return e;
7017
+ if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
7018
+ return _assertThisInitialized(t);
7019
+ }
7020
+
7021
+ function _callSuper(t, o, e) {
7022
+ return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
7023
+ }
7024
+
7025
+ function _setPrototypeOf(t, e) {
7026
+ return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
7027
+ return t.__proto__ = e, t;
7028
+ }, _setPrototypeOf(t, e);
7029
+ }
7030
+
7031
+ function _inherits(t, e) {
7032
+ if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
7033
+ t.prototype = Object.create(e && e.prototype, {
7034
+ constructor: {
7035
+ value: t,
7036
+ writable: !0,
7037
+ configurable: !0
7038
+ }
7039
+ }), Object.defineProperty(t, "prototype", {
7040
+ writable: !1
7041
+ }), e && _setPrototypeOf(t, e);
7042
+ }
7043
+
7044
+ function _isNativeFunction(t) {
7045
+ try {
7046
+ return -1 !== Function.toString.call(t).indexOf("[native code]");
7047
+ } catch (n) {
7048
+ return "function" == typeof t;
7049
+ }
7050
+ }
7051
+
7052
+ function _construct(t, e, r) {
7053
+ if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
7054
+ var o = [null];
7055
+ o.push.apply(o, e);
7056
+ var p = new (t.bind.apply(t, o))();
7057
+ return r && _setPrototypeOf(p, r.prototype), p;
7058
+ }
7059
+
7060
+ function _wrapNativeSuper(t) {
7061
+ var r = "function" == typeof Map ? new Map() : void 0;
7062
+ return _wrapNativeSuper = function (t) {
7063
+ if (null === t || !_isNativeFunction(t)) return t;
7064
+ if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
7065
+ if (void 0 !== r) {
7066
+ if (r.has(t)) return r.get(t);
7067
+ r.set(t, Wrapper);
7068
+ }
7069
+ function Wrapper() {
7070
+ return _construct(t, arguments, _getPrototypeOf(this).constructor);
7071
+ }
7072
+ return Wrapper.prototype = Object.create(t.prototype, {
7073
+ constructor: {
7074
+ value: Wrapper,
7075
+ enumerable: !1,
7076
+ writable: !0,
7077
+ configurable: !0
7078
+ }
7079
+ }), _setPrototypeOf(Wrapper, t);
7080
+ }, _wrapNativeSuper(t);
7081
+ }
7082
+
7083
+ /**
7084
+ * Reading what content answers.
7085
+ *
7086
+ * Every type here comes from `contentApi.ts`, which is a copy of the
7087
+ * service's own `Api.ts` - so the shapes are not re-derived from what this end
7088
+ * wishes it received, and a copy brought up to date fails to compile wherever
7089
+ * this CLI has not caught up.
7090
+ *
7091
+ * The schemas are the runtime half, and they are needed as well as the types:
7092
+ * what arrives is JSON over HTTP from a service that versions separately, so a
7093
+ * type alone asserts a shape rather than checking one. Each schema is
7094
+ * annotated with the copied type it must produce (`z.ZodType<DeclareResponse>`
7095
+ * and so on), which is what ties the two halves together - a schema that drifts
7096
+ * from the copy does not compile, and an answer that drifts from the schema
7097
+ * does not parse. `ValOpsHttp` in `@valbuild/server` reads every other content
7098
+ * route the same way.
7099
+ *
7100
+ * Nothing here is laxer than the copy. An optional field is optional because
7101
+ * the service says so; making a required one optional here would hide exactly
7102
+ * the drift this file exists to catch.
7103
+ */
7104
+
7105
+ /** An artifact, as it is declared: by key, by hash, by size. */
7106
+
7107
+ /** Permission to write one artifact's bytes to object storage. */
7108
+
7109
+ var publishState = z["enum"](["awaiting-artifacts", "ready", "verified", "live", "failed", "expired"]);
7110
+ var publishProblem = z.object({
7111
+ code: z.string(),
7112
+ message: z.string(),
7113
+ hint: z.string().optional(),
7114
+ keys: z.array(z.string()).optional()
7115
+ });
7116
+ var uploadSlot = z.object({
7117
+ key: z.string(),
7118
+ url: z.string(),
7119
+ method: z.literal("PUT"),
7120
+ headers: z.record(z.string(), z.string()),
7121
+ expiresAt: z.string()
7122
+ });
7123
+ var declareResponse = z.object({
7124
+ publishId: z.string(),
7125
+ state: publishState,
7126
+ project: z.object({
7127
+ publicProjectId: z.string(),
7128
+ siteUrl: z.string().nullable()
7129
+ }),
7130
+ uploads: z.array(uploadSlot),
7131
+ have: z.array(z.string())
7132
+ });
7133
+ var artifactsResponse = z.object({
7134
+ state: publishState,
7135
+ problems: z.array(publishProblem)
7136
+ });
7137
+ var verifyResponse = z.object({
7138
+ state: publishState,
7139
+ ok: z["boolean"](),
7140
+ previewUrl: z.string().nullable(),
7141
+ problems: z.array(publishProblem)
7142
+ });
7143
+ var promoteResponse = z.object({
7144
+ state: publishState,
7145
+ url: z.string().nullable(),
7146
+ commit: z.string().nullable()
7147
+ });
7148
+ var statusResponse = z.object({
7149
+ publishId: z.string(),
7150
+ state: publishState,
7151
+ buildHash: z.string(),
7152
+ missing: z.array(z.string()),
7153
+ problems: z.array(publishProblem)
7154
+ });
7155
+ var publishTokenResponse = z.object({
7156
+ token: z.string(),
7157
+ expiresAt: z.string().nullable(),
7158
+ publicProjectId: z.string(),
7159
+ productionUrl: z.string().nullable()
7160
+ });
7161
+
7162
+ /**
7163
+ * Content answered, and the answer was not one this CLI can act on.
7164
+ *
7165
+ * Separate from a refusal, which is content saying no in a sentence meant for
7166
+ * a person. This is two programs disagreeing - the copy in `contentApi.ts` and
7167
+ * the service that has moved on from it - and the two want opposite things
7168
+ * said about them.
7169
+ */
7170
+ var PublishProtocolError = /*#__PURE__*/function (_Error) {
7171
+ function PublishProtocolError(message) {
7172
+ var _this;
7173
+ _classCallCheck(this, PublishProtocolError);
7174
+ _this = _callSuper(this, PublishProtocolError, [message]);
7175
+ _this.name = "PublishProtocolError";
7176
+ return _this;
7177
+ }
7178
+ _inherits(PublishProtocolError, _Error);
7179
+ return _createClass(PublishProtocolError);
7180
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
7181
+ var parseDeclare = function parseDeclare(body) {
7182
+ return parse(declareResponse, body, "POST /v1/publish");
7183
+ };
7184
+ var parseArtifacts = function parseArtifacts(body) {
7185
+ return parse(artifactsResponse, body, "POST /v1/publish/{id}/artifacts");
7186
+ };
7187
+ var parseVerify = function parseVerify(body) {
7188
+ return parse(verifyResponse, body, "POST /v1/publish/{id}/verify");
7189
+ };
7190
+ var parsePromote = function parsePromote(body) {
7191
+ return parse(promoteResponse, body, "POST /v1/publish/{id}/promote");
7192
+ };
7193
+ var parseStatus = function parseStatus(body) {
7194
+ return parse(statusResponse, body, "GET /v1/publish/{id}");
7195
+ };
7196
+ var parsePublishToken = function parsePublishToken(body, call) {
7197
+ return parse(publishTokenResponse, body, call);
7198
+ };
7199
+
7200
+ /**
7201
+ * What a build targets, and the project's files, as the Studio asks for them.
7202
+ *
7203
+ * Both are read through `/publish-api` rather than fetched from the loader,
7204
+ * because a browser has neither the loader's address nor a credential it would
7205
+ * accept. `fetchBuildTarget` in `@valbuild/tanstack-build` is the other half --
7206
+ * same shape, a different caller, and it CASTS where this parses.
7207
+ *
7208
+ * Parsed rather than cast here because of what sits in between: a proxy, a
7209
+ * gateway and a service boundary. An HTML error page cast to `BuildTarget`
7210
+ * fails several layers down inside rolldown with a message about a module
7211
+ * specifier, and the publish that follows would label a build against a layer
7212
+ * that was never there.
7213
+ *
7214
+ * The TYPE is inferred from this schema instead of imported. `BuildTarget` is
7215
+ * declared in `@valbuild/tanstack-build`, which has no zod and deliberately
7216
+ * almost no dependencies -- it goes into a browser bundle -- and this package
7217
+ * is imported by everything. The declarations are kept honest at the one place
7218
+ * the value is used: it is passed straight into `buildUserApp({ target })`, so
7219
+ * a drift between them is a compile error at that call rather than a runtime
7220
+ * surprise.
7221
+ */
7222
+ var buildTargetResponse = z.object({
7223
+ base: z.object({
7224
+ rev: z.string(),
7225
+ shellRev: z.string(),
7226
+ rscShellRev: z.string(),
7227
+ modules: z.record(z.string(), z.string()),
7228
+ rscModules: z.record(z.string(), z.string()),
7229
+ paths: z.object({
7230
+ baseFromProject: z.string(),
7231
+ projectVendorDir: z.string(),
7232
+ rscVendorBase: z.string(),
7233
+ rscRuntimeSpecifier: z.string(),
7234
+ rscRuntimePath: z.string(),
7235
+ flightServer: z.string(),
7236
+ serverFnBase: z.string()
7237
+ })
7238
+ }),
7239
+ project: z.object({
7240
+ rev: z.string().nullable(),
7241
+ rsc: z["boolean"](),
7242
+ modules: z.record(z.string(), z.string()),
7243
+ css: z.record(z.string(), z.string()),
7244
+ workerOnly: z.array(z.string())
7245
+ })
7246
+ });
7247
+ /**
7248
+ * `null` files is a real answer: a project that has never published.
7249
+ *
7250
+ * Distinguished from an empty record, which would be a project that published
7251
+ * nothing -- and which a build would take as "no entry point" rather than as
7252
+ * "there is nothing here yet".
7253
+ */
7254
+ var projectSourceResponse = z.object({
7255
+ files: z.record(z.string(), z.string()).nullable(),
7256
+ /**
7257
+ * The live build's `public/*` artifacts, by hash -- what a publisher with no
7258
+ * checkout carries into its build so the site keeps its favicon and images.
7259
+ *
7260
+ * The loader stores public files PER BUILD, so a build that names none
7261
+ * serves none. A publisher with a checkout has them on disk; the Studio has
7262
+ * this. Re-declaring one costs nothing: content holds the bytes for the
7263
+ * project already and asks for no upload.
7264
+ *
7265
+ * `null` when content cannot say -- the live build was not published through
7266
+ * it -- and absent from a content service that predates it. A publisher
7267
+ * must treat both as "unknown", never as "none": publishing on that guess
7268
+ * deletes every public file the site has.
7269
+ */
7270
+ publicFiles: z.array(z.object({
7271
+ key: z.string(),
7272
+ sha256: z.string(),
7273
+ bytes: z.number()["int"]().nonnegative()
7274
+ })).nullable().optional(),
7275
+ /**
7276
+ * The URL paths the live build serves from `public/`, as the loader has
7277
+ * them -- without the bytes' hashes.
7278
+ *
7279
+ * The fallback for when `publicFiles` is `null`: a build content has no
7280
+ * record of, which is every project cloned from a template seed. A publisher
7281
+ * running on the site's own origin can fetch these and build with them;
7282
+ * after that publish content holds their hashes and `publicFiles` answers.
7283
+ * `null` when the loader serves no build or does not say.
7284
+ */
7285
+ publicPaths: z.array(z.string()).nullable().optional()
7286
+ });
7287
+ var parseBuildTarget = function parseBuildTarget(body) {
7288
+ return parse(buildTargetResponse, body, "GET /v1/build-target");
7289
+ };
7290
+ var parseProjectSource = function parseProjectSource(body) {
7291
+ return parse(projectSourceResponse, body, "GET /v1/project-source");
7292
+ };
7293
+
7294
+ /**
7295
+ * The `details` of a refusal, when it carries a list of problems.
7296
+ *
7297
+ * Every non-2xx is `{ statusCode, message, details? }`, and the publish routes
7298
+ * put `PublishProblem[]` in `details` - a declaration is answered with EVERY
7299
+ * problem rather than the first, because finding them one round trip at a time
7300
+ * is how a publish takes six attempts. Anything else in there is somebody
7301
+ * else's `details` and is left to the caller's own message.
7302
+ */
7303
+ function parseProblems(details) {
7304
+ var parsed = z.array(publishProblem).safeParse(details);
7305
+ return parsed.success ? parsed.data : [];
7306
+ }
7307
+ function parse(schema, body, call) {
7308
+ var parsed = schema.safeParse(body);
7309
+ if (!parsed.success) {
7310
+ throw new PublishProtocolError("".concat(call, " answered with something this publisher cannot read: ").concat(fromError(parsed.error).toString()));
7311
+ }
7312
+ return parsed.data;
7313
+ }
7314
+
7315
+ export { AA_LARGE, AA_TEXT, Api, BRAND_CONTRAST_PAIRS, BinaryFileRef, CodeOptions, ColorOptions, DEFAULT_ERROR_MESSAGE, DateOptions, ENCODE_DEFAULTS, ENCODE_MIME_TYPE_OF, FileOptions, HistoricalCommit, HistoricalModule, HistoricalPatchSet, HistoryError, ImageEncodeOption, ImageOptions, JSONValue, JSON_ENTRIES_BATCH_MAX, ModuleComparison, NEVER_ENCODED, ParentRef$1 as ParentRef, Patch, PatchBlock, PatchGroup, PatchId, PatchJSON, PublishProtocolError, RAMP_STEPS, RemirrorBr, RemirrorBulletList, RemirrorHeading, RemirrorImage, RemirrorJSON, RemirrorLinkMark, RemirrorListItem, RemirrorOrderedList, RemirrorParagraph, RemirrorText, RemirrorTextMark, RestoreVerdict, RichTextOptions, SCHEMA_SOURCE_FIXES, SerializedArraySchema, SerializedBooleanSchema, SerializedCodeSchema, SerializedColorSchema, SerializedDateSchema, SerializedDateTimeSchema, SerializedDiscriminatedUnionSchema, SerializedEnumSchema, SerializedFileSchema, SerializedImageSchema, SerializedKeyOfSchema, SerializedLiteralSchema, SerializedLocaleSchema, SerializedNumberSchema, SerializedObjectSchema, SerializedRecordSchema, SerializedRichTextSchema, SerializedRouteSchema, SerializedSchema, SerializedSettingsSchema, SerializedStringSchema, SerializedValViewSchema, SharedValConfig, VAL_ENABLE_COOKIE_NAME, VAL_GREEN_RAMP, VAL_SESSION_COOKIE, VAL_STATE_COOKIE, ValCommit, ValDeployment, accentRamp, buildDuplicatePatch, buildEmptyAtPathPatch, buildFileRefValue, buildImageGalleryPatch, buildRemoveImageGalleryEntryPatch, buildSearchIndex, checkCompatibility, chooseEncoded, concatModulePath, contrastRatio, createRegExpFromPattern, createSearchIndex, createValClient, declaredLocales, describeContainerAtPath, emptyOf, explainIncompatible, filterBlockingValidationErrors, filterRoutesByPatterns, findSimilar, fitWithin, flattenRichText, getErrorMessageFromUnknownJson, getFilenameFromRef, getInlineImgInfo, getKeyOfRecordAt, getRefParts, getRoutesOf, getRoutesWithModulePaths, getSourceAt, indexModule, isMimeTypeAccepted, isRemoteSchema, isSchemaSourceFixError, isSkippedSource, keyOfRecordPath, levenshtein, localeAt, memoizePerRequest, newestCommitSha, parseArtifacts, parseBuildTarget, parseDeclare, parseProblems, parseProjectSource, parsePromote, parsePublishToken, parseStatus, parseVerify, partitionValidationErrors, performSearch, relativeLuminance, remirrorToRichTextSource, removeModule, resolveEncodeSettings, resolvePairGround, resolveSchemaSourceFixForError, resolveSchemaSourceFixes, resolveSerializedSchemaAtPath, richTextToRemirror, safeParsePatch, sourcePathOfChild, themeCustomProperties, toolNames, traverseSchemaSource, urlOf, validateRoutePatterns, withExtension };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valbuild/shared",
3
- "version": "0.136.0",
3
+ "version": "0.136.2",
4
4
  "private": false,
5
5
  "description": "Val shared types and utilities",
6
6
  "repository": {
@@ -37,7 +37,7 @@
37
37
  "flexsearch": "^0.8.212",
38
38
  "zod": "^4.4.3",
39
39
  "zod-validation-error": "^5.0.0",
40
- "@valbuild/core": "0.136.0"
40
+ "@valbuild/core": "0.136.1"
41
41
  },
42
42
  "files": [
43
43
  "CHANGELOG.md",