@valbuild/shared 0.134.1 → 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.
@@ -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 {
@@ -1857,6 +1913,27 @@ var Api = {
1857
1913
  profileId: z.string().nullable(),
1858
1914
  mode: z.union([z.literal("http"), z.literal("fs")]),
1859
1915
  jsonEntriesSha: z.string().optional(),
1916
+ /**
1917
+ * How this project's SOURCE is kept, when the server knows.
1918
+ *
1919
+ * `"managed"` -- the content service is the store of record,
1920
+ * there is no repository, and the Studio is the deployer: the
1921
+ * build that makes a publish live happens in the tab that started
1922
+ * it. `"connected"` -- commits are mirrored into a repository a
1923
+ * host watches, so something outside the browser finishes the
1924
+ * job.
1925
+ *
1926
+ * The Studio narrates a publish differently for each, because a
1927
+ * `building` state in managed mode is a spinner with no event
1928
+ * that can ever end it -- not on a reload, not on a retry, not
1929
+ * tomorrow.
1930
+ *
1931
+ * Optional, and absent means "not reported", never "managed":
1932
+ * `fs` mode has no project to have a mode, and so does an `http`
1933
+ * server that predates the field. Both keep the connected story,
1934
+ * which is the one the Studio has always told.
1935
+ */
1936
+ sourceMode: z.union([z.literal("managed"), z.literal("connected")]).optional(),
1860
1937
  publishRefusal: PublishRefusal.optional()
1861
1938
  }), z.object({
1862
1939
  type: z.literal("use-websocket"),
@@ -1919,12 +1996,113 @@ var Api = {
1919
1996
  config: ValConfig,
1920
1997
  profileId: z.string().nullable(),
1921
1998
  mode: z.union([z.literal("http"), z.literal("fs")]),
1999
+ /**
2000
+ * How this project's SOURCE is kept, when the server knows.
2001
+ *
2002
+ * `"managed"` -- the content service is the store of record,
2003
+ * there is no repository, and the Studio is the deployer: the
2004
+ * build that makes a publish live happens in the tab that started
2005
+ * it. `"connected"` -- commits are mirrored into a repository a
2006
+ * host watches, so something outside the browser finishes the
2007
+ * job.
2008
+ *
2009
+ * The Studio narrates a publish differently for each, because a
2010
+ * `building` state in managed mode is a spinner with no event
2011
+ * that can ever end it -- not on a reload, not on a retry, not
2012
+ * tomorrow.
2013
+ *
2014
+ * Optional, and absent means "not reported", never "managed":
2015
+ * `fs` mode has no project to have a mode, and so does an `http`
2016
+ * server that predates the field. Both keep the connected story,
2017
+ * which is the one the Studio has always told.
2018
+ */
2019
+ sourceMode: z.union([z.literal("managed"), z.literal("connected")]).optional(),
1922
2020
  publishRefusal: PublishRefusal.optional()
1923
2021
  })])
1924
2022
  })])
1925
2023
  }
1926
2024
  },
1927
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
+ },
1928
2106
  "/upload/patches": {
1929
2107
  POST: {
1930
2108
  req: {
@@ -2406,6 +2584,21 @@ var Api = {
2406
2584
  * server that predates this.
2407
2585
  */
2408
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(),
2409
2602
  /**
2410
2603
  * Unpublished changes the save threw away because they could not be
2411
2604
  * applied.
@@ -6755,4 +6948,310 @@ function resolvePairGround(ground, ramp) {
6755
6948
  return typeof ground === "number" ? ramp[ground] : ground;
6756
6949
  }
6757
6950
 
6758
- 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 };
6951
+ function _defineProperties(e, r) {
6952
+ for (var t = 0; t < r.length; t++) {
6953
+ var o = r[t];
6954
+ o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
6955
+ }
6956
+ }
6957
+ function _createClass(e, r, t) {
6958
+ return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
6959
+ writable: !1
6960
+ }), e;
6961
+ }
6962
+
6963
+ function _classCallCheck(a, n) {
6964
+ if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
6965
+ }
6966
+
6967
+ function _getPrototypeOf(t) {
6968
+ return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
6969
+ return t.__proto__ || Object.getPrototypeOf(t);
6970
+ }, _getPrototypeOf(t);
6971
+ }
6972
+
6973
+ function _isNativeReflectConstruct() {
6974
+ try {
6975
+ var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
6976
+ } catch (t) {}
6977
+ return (_isNativeReflectConstruct = function () {
6978
+ return !!t;
6979
+ })();
6980
+ }
6981
+
6982
+ function _assertThisInitialized(e) {
6983
+ if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
6984
+ return e;
6985
+ }
6986
+
6987
+ function _possibleConstructorReturn(t, e) {
6988
+ if (e && ("object" == typeof e || "function" == typeof e)) return e;
6989
+ if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
6990
+ return _assertThisInitialized(t);
6991
+ }
6992
+
6993
+ function _callSuper(t, o, e) {
6994
+ return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
6995
+ }
6996
+
6997
+ function _setPrototypeOf(t, e) {
6998
+ return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
6999
+ return t.__proto__ = e, t;
7000
+ }, _setPrototypeOf(t, e);
7001
+ }
7002
+
7003
+ function _inherits(t, e) {
7004
+ if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
7005
+ t.prototype = Object.create(e && e.prototype, {
7006
+ constructor: {
7007
+ value: t,
7008
+ writable: !0,
7009
+ configurable: !0
7010
+ }
7011
+ }), Object.defineProperty(t, "prototype", {
7012
+ writable: !1
7013
+ }), e && _setPrototypeOf(t, e);
7014
+ }
7015
+
7016
+ function _isNativeFunction(t) {
7017
+ try {
7018
+ return -1 !== Function.toString.call(t).indexOf("[native code]");
7019
+ } catch (n) {
7020
+ return "function" == typeof t;
7021
+ }
7022
+ }
7023
+
7024
+ function _construct(t, e, r) {
7025
+ if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
7026
+ var o = [null];
7027
+ o.push.apply(o, e);
7028
+ var p = new (t.bind.apply(t, o))();
7029
+ return r && _setPrototypeOf(p, r.prototype), p;
7030
+ }
7031
+
7032
+ function _wrapNativeSuper(t) {
7033
+ var r = "function" == typeof Map ? new Map() : void 0;
7034
+ return _wrapNativeSuper = function (t) {
7035
+ if (null === t || !_isNativeFunction(t)) return t;
7036
+ if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
7037
+ if (void 0 !== r) {
7038
+ if (r.has(t)) return r.get(t);
7039
+ r.set(t, Wrapper);
7040
+ }
7041
+ function Wrapper() {
7042
+ return _construct(t, arguments, _getPrototypeOf(this).constructor);
7043
+ }
7044
+ return Wrapper.prototype = Object.create(t.prototype, {
7045
+ constructor: {
7046
+ value: Wrapper,
7047
+ enumerable: !1,
7048
+ writable: !0,
7049
+ configurable: !0
7050
+ }
7051
+ }), _setPrototypeOf(Wrapper, t);
7052
+ }, _wrapNativeSuper(t);
7053
+ }
7054
+
7055
+ /**
7056
+ * Reading what content answers.
7057
+ *
7058
+ * Every type here comes from `contentApi.ts`, which is a copy of the
7059
+ * service's own `Api.ts` - so the shapes are not re-derived from what this end
7060
+ * wishes it received, and a copy brought up to date fails to compile wherever
7061
+ * this CLI has not caught up.
7062
+ *
7063
+ * The schemas are the runtime half, and they are needed as well as the types:
7064
+ * what arrives is JSON over HTTP from a service that versions separately, so a
7065
+ * type alone asserts a shape rather than checking one. Each schema is
7066
+ * annotated with the copied type it must produce (`z.ZodType<DeclareResponse>`
7067
+ * and so on), which is what ties the two halves together - a schema that drifts
7068
+ * from the copy does not compile, and an answer that drifts from the schema
7069
+ * does not parse. `ValOpsHttp` in `@valbuild/server` reads every other content
7070
+ * route the same way.
7071
+ *
7072
+ * Nothing here is laxer than the copy. An optional field is optional because
7073
+ * the service says so; making a required one optional here would hide exactly
7074
+ * the drift this file exists to catch.
7075
+ */
7076
+
7077
+ /** An artifact, as it is declared: by key, by hash, by size. */
7078
+
7079
+ /** Permission to write one artifact's bytes to object storage. */
7080
+
7081
+ var publishState = z["enum"](["awaiting-artifacts", "ready", "verified", "live", "failed", "expired"]);
7082
+ var publishProblem = z.object({
7083
+ code: z.string(),
7084
+ message: z.string(),
7085
+ hint: z.string().optional(),
7086
+ keys: z.array(z.string()).optional()
7087
+ });
7088
+ var uploadSlot = z.object({
7089
+ key: z.string(),
7090
+ url: z.string(),
7091
+ method: z.literal("PUT"),
7092
+ headers: z.record(z.string(), z.string()),
7093
+ expiresAt: z.string()
7094
+ });
7095
+ var declareResponse = z.object({
7096
+ publishId: z.string(),
7097
+ state: publishState,
7098
+ project: z.object({
7099
+ publicProjectId: z.string(),
7100
+ siteUrl: z.string().nullable()
7101
+ }),
7102
+ uploads: z.array(uploadSlot),
7103
+ have: z.array(z.string())
7104
+ });
7105
+ var artifactsResponse = z.object({
7106
+ state: publishState,
7107
+ problems: z.array(publishProblem)
7108
+ });
7109
+ var verifyResponse = z.object({
7110
+ state: publishState,
7111
+ ok: z["boolean"](),
7112
+ previewUrl: z.string().nullable(),
7113
+ problems: z.array(publishProblem)
7114
+ });
7115
+ var promoteResponse = z.object({
7116
+ state: publishState,
7117
+ url: z.string().nullable(),
7118
+ commit: z.string().nullable()
7119
+ });
7120
+ var statusResponse = z.object({
7121
+ publishId: z.string(),
7122
+ state: publishState,
7123
+ buildHash: z.string(),
7124
+ missing: z.array(z.string()),
7125
+ problems: z.array(publishProblem)
7126
+ });
7127
+ var publishTokenResponse = z.object({
7128
+ token: z.string(),
7129
+ expiresAt: z.string().nullable(),
7130
+ publicProjectId: z.string(),
7131
+ productionUrl: z.string().nullable()
7132
+ });
7133
+
7134
+ /**
7135
+ * Content answered, and the answer was not one this CLI can act on.
7136
+ *
7137
+ * Separate from a refusal, which is content saying no in a sentence meant for
7138
+ * a person. This is two programs disagreeing - the copy in `contentApi.ts` and
7139
+ * the service that has moved on from it - and the two want opposite things
7140
+ * said about them.
7141
+ */
7142
+ var PublishProtocolError = /*#__PURE__*/function (_Error) {
7143
+ function PublishProtocolError(message) {
7144
+ var _this;
7145
+ _classCallCheck(this, PublishProtocolError);
7146
+ _this = _callSuper(this, PublishProtocolError, [message]);
7147
+ _this.name = "PublishProtocolError";
7148
+ return _this;
7149
+ }
7150
+ _inherits(PublishProtocolError, _Error);
7151
+ return _createClass(PublishProtocolError);
7152
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
7153
+ var parseDeclare = function parseDeclare(body) {
7154
+ return parse(declareResponse, body, "POST /v1/publish");
7155
+ };
7156
+ var parseArtifacts = function parseArtifacts(body) {
7157
+ return parse(artifactsResponse, body, "POST /v1/publish/{id}/artifacts");
7158
+ };
7159
+ var parseVerify = function parseVerify(body) {
7160
+ return parse(verifyResponse, body, "POST /v1/publish/{id}/verify");
7161
+ };
7162
+ var parsePromote = function parsePromote(body) {
7163
+ return parse(promoteResponse, body, "POST /v1/publish/{id}/promote");
7164
+ };
7165
+ var parseStatus = function parseStatus(body) {
7166
+ return parse(statusResponse, body, "GET /v1/publish/{id}");
7167
+ };
7168
+ var parsePublishToken = function parsePublishToken(body, call) {
7169
+ return parse(publishTokenResponse, body, call);
7170
+ };
7171
+
7172
+ /**
7173
+ * What a build targets, and the project's files, as the Studio asks for them.
7174
+ *
7175
+ * Both are read through `/publish-api` rather than fetched from the loader,
7176
+ * because a browser has neither the loader's address nor a credential it would
7177
+ * accept. `fetchBuildTarget` in `@valbuild/tanstack-build` is the other half --
7178
+ * same shape, a different caller, and it CASTS where this parses.
7179
+ *
7180
+ * Parsed rather than cast here because of what sits in between: a proxy, a
7181
+ * gateway and a service boundary. An HTML error page cast to `BuildTarget`
7182
+ * fails several layers down inside rolldown with a message about a module
7183
+ * specifier, and the publish that follows would label a build against a layer
7184
+ * that was never there.
7185
+ *
7186
+ * The TYPE is inferred from this schema instead of imported. `BuildTarget` is
7187
+ * declared in `@valbuild/tanstack-build`, which has no zod and deliberately
7188
+ * almost no dependencies -- it goes into a browser bundle -- and this package
7189
+ * is imported by everything. The declarations are kept honest at the one place
7190
+ * the value is used: it is passed straight into `buildUserApp({ target })`, so
7191
+ * a drift between them is a compile error at that call rather than a runtime
7192
+ * surprise.
7193
+ */
7194
+ var buildTargetResponse = z.object({
7195
+ base: z.object({
7196
+ rev: z.string(),
7197
+ shellRev: z.string(),
7198
+ rscShellRev: z.string(),
7199
+ modules: z.record(z.string(), z.string()),
7200
+ rscModules: z.record(z.string(), z.string()),
7201
+ paths: z.object({
7202
+ baseFromProject: z.string(),
7203
+ projectVendorDir: z.string(),
7204
+ rscVendorBase: z.string(),
7205
+ rscRuntimeSpecifier: z.string(),
7206
+ rscRuntimePath: z.string(),
7207
+ flightServer: z.string(),
7208
+ serverFnBase: z.string()
7209
+ })
7210
+ }),
7211
+ project: z.object({
7212
+ rev: z.string().nullable(),
7213
+ rsc: z["boolean"](),
7214
+ modules: z.record(z.string(), z.string()),
7215
+ css: z.record(z.string(), z.string()),
7216
+ workerOnly: z.array(z.string())
7217
+ })
7218
+ });
7219
+ /**
7220
+ * `null` files is a real answer: a project that has never published.
7221
+ *
7222
+ * Distinguished from an empty record, which would be a project that published
7223
+ * nothing -- and which a build would take as "no entry point" rather than as
7224
+ * "there is nothing here yet".
7225
+ */
7226
+ var projectSourceResponse = z.object({
7227
+ files: z.record(z.string(), z.string()).nullable()
7228
+ });
7229
+ var parseBuildTarget = function parseBuildTarget(body) {
7230
+ return parse(buildTargetResponse, body, "GET /v1/build-target");
7231
+ };
7232
+ var parseProjectSource = function parseProjectSource(body) {
7233
+ return parse(projectSourceResponse, body, "GET /v1/project-source");
7234
+ };
7235
+
7236
+ /**
7237
+ * The `details` of a refusal, when it carries a list of problems.
7238
+ *
7239
+ * Every non-2xx is `{ statusCode, message, details? }`, and the publish routes
7240
+ * put `PublishProblem[]` in `details` - a declaration is answered with EVERY
7241
+ * problem rather than the first, because finding them one round trip at a time
7242
+ * is how a publish takes six attempts. Anything else in there is somebody
7243
+ * else's `details` and is left to the caller's own message.
7244
+ */
7245
+ function parseProblems(details) {
7246
+ var parsed = z.array(publishProblem).safeParse(details);
7247
+ return parsed.success ? parsed.data : [];
7248
+ }
7249
+ function parse(schema, body, call) {
7250
+ var parsed = schema.safeParse(body);
7251
+ if (!parsed.success) {
7252
+ throw new PublishProtocolError("".concat(call, " answered with something this publisher cannot read: ").concat(fromError(parsed.error).toString()));
7253
+ }
7254
+ return parsed.data;
7255
+ }
7256
+
7257
+ 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.134.1",
3
+ "version": "0.136.1",
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.134.0"
40
+ "@valbuild/core": "0.136.1"
41
41
  },
42
42
  "files": [
43
43
  "CHANGELOG.md",