@valbuild/shared 0.136.3 → 0.136.10

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 CHANGED
@@ -1,5 +1,20 @@
1
1
  # @valbuild/shared
2
2
 
3
+ ## 0.136.10
4
+
5
+ ### Patch Changes
6
+
7
+ - [#743](https://github.com/valbuild/val/pull/743) [`fef29b0`](https://github.com/valbuild/val/commit/fef29b0d9e826e4e7e63a3ae61553137a3f9d280) Thanks [@freekh](https://github.com/freekh)! - Saving no longer gets stuck on "Changes cannot be saved: something else keeps changing them first" when another editor has an unpublished change and later work has been published.
8
+
9
+ A new change is now written on top of the latest change the content service has registered, which it reports alongside the list of pending changes, instead of the last change this deployment was shown. Since changes can be published independently, those two can differ for good: an unpublished change can sit before published ones that the running deployment already contains. The Studio and the MCP tools both name the reported head, and fall back to the old behaviour against a content service that does not report one.
10
+
11
+ ## 0.136.8
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [[`35577be`](https://github.com/valbuild/val/commit/35577be50981fec35fc27ee9435a092a26909395)]:
16
+ - @valbuild/core@0.136.8
17
+
3
18
  ## 0.136.3
4
19
 
5
20
  ### Patch Changes
@@ -439,6 +439,7 @@ export declare const Api: {
439
439
  patches: z.ZodArray<z.ZodString & z.ZodType<import("@valbuild/core").PatchId, string, z.core.$ZodTypeInternals<import("@valbuild/core").PatchId, string>>>;
440
440
  appliedPatches: z.ZodOptional<z.ZodArray<z.ZodString & z.ZodType<import("@valbuild/core").PatchId, string, z.core.$ZodTypeInternals<import("@valbuild/core").PatchId, string>>>>;
441
441
  headCommitSha: z.ZodOptional<z.ZodString>;
442
+ headPatchId: z.ZodOptional<z.ZodNullable<z.ZodString & z.ZodType<import("@valbuild/core").PatchId, string, z.core.$ZodTypeInternals<import("@valbuild/core").PatchId, string>>>>;
442
443
  commits: z.ZodArray<z.ZodObject<{
443
444
  commitSha: z.ZodString;
444
445
  clientCommitSha: z.ZodNullable<z.ZodString>;
@@ -0,0 +1,24 @@
1
+ import type { PatchId } from "@valbuild/core";
2
+ /**
3
+ * The patch a new write names as its parent: the HEAD of the chain, or `null`
4
+ * when the chain is empty and the write goes on the base.
5
+ *
6
+ * The head the server REPORTS (`headPatchId`) when it reports one, and not the
7
+ * last patch it listed. The list — `/applicable/patches`, and `/stat` on top of
8
+ * it — leaves out patches the running deployment already contains, and since
9
+ * patch groups a publish can ship later patches while an earlier one stays
10
+ * pending (another author's change that nets to nothing can never be published
11
+ * at all). The last listed id is then behind the head for good, and the content
12
+ * service accepts a write only on the head, so every save naming it is refused
13
+ * — and a re-sync returns the same list. What fixed it in the Studio before
14
+ * this existed was discarding the other author's change.
15
+ *
16
+ * `null` is a REPORTED empty chain, not "unknown". `undefined` is a server
17
+ * that reports no head (`fs` mode, which ignores the parent anyway, or a
18
+ * content service that predates the field), and only then does this fall back
19
+ * to the last listed id.
20
+ *
21
+ * One rule for both writers, the Studio's `PatchSync` and the MCP's
22
+ * `deriveParentRef`, so they cannot come to name different parents.
23
+ */
24
+ export declare function chainHeadOf(reportedHead: PatchId | null | undefined, listed: readonly PatchId[]): PatchId | null;
@@ -6,6 +6,7 @@ export * from "./ValUrls.js";
6
6
  export * from "./ApiRoutes.js";
7
7
  export * from "./schema/compatibility.js";
8
8
  export * from "./newestCommitSha.js";
9
+ export * from "./chainHead.js";
9
10
  export * from "./zod/Patch.js";
10
11
  export * from "./sessionStorage.js";
11
12
  export * from "./SharedValConfig.js";
@@ -1984,6 +1984,13 @@ var Api = {
1984
1984
  * carries back to `/save` to say which world it decided against.
1985
1985
  */
1986
1986
  headCommitSha: zod.z.string().optional(),
1987
+ /**
1988
+ * The head of the PATCH CHAIN: the last patch registered on the
1989
+ * branch, published or not. `null` when there is none. What a
1990
+ * new patch names as its parent — see `chainHeadOf`. Optional: a
1991
+ * content service that predates it sends nothing.
1992
+ */
1993
+ headPatchId: PatchId.nullable().optional(),
1987
1994
  commits: zod.z.array(ValCommit),
1988
1995
  /**
1989
1996
  * The publishes the content service knows about.
@@ -4060,6 +4067,36 @@ function newestCommitSha(commits) {
4060
4067
  return (_newest$commitSha = (_newest = newest) === null || _newest === void 0 ? void 0 : _newest.commitSha) !== null && _newest$commitSha !== void 0 ? _newest$commitSha : null;
4061
4068
  }
4062
4069
 
4070
+ /**
4071
+ * The patch a new write names as its parent: the HEAD of the chain, or `null`
4072
+ * when the chain is empty and the write goes on the base.
4073
+ *
4074
+ * The head the server REPORTS (`headPatchId`) when it reports one, and not the
4075
+ * last patch it listed. The list — `/applicable/patches`, and `/stat` on top of
4076
+ * it — leaves out patches the running deployment already contains, and since
4077
+ * patch groups a publish can ship later patches while an earlier one stays
4078
+ * pending (another author's change that nets to nothing can never be published
4079
+ * at all). The last listed id is then behind the head for good, and the content
4080
+ * service accepts a write only on the head, so every save naming it is refused
4081
+ * — and a re-sync returns the same list. What fixed it in the Studio before
4082
+ * this existed was discarding the other author's change.
4083
+ *
4084
+ * `null` is a REPORTED empty chain, not "unknown". `undefined` is a server
4085
+ * that reports no head (`fs` mode, which ignores the parent anyway, or a
4086
+ * content service that predates the field), and only then does this fall back
4087
+ * to the last listed id.
4088
+ *
4089
+ * One rule for both writers, the Studio's `PatchSync` and the MCP's
4090
+ * `deriveParentRef`, so they cannot come to name different parents.
4091
+ */
4092
+ function chainHeadOf(reportedHead, listed) {
4093
+ var _listed;
4094
+ if (reportedHead !== undefined) {
4095
+ return reportedHead;
4096
+ }
4097
+ return (_listed = listed[listed.length - 1]) !== null && _listed !== void 0 ? _listed : null;
4098
+ }
4099
+
4063
4100
  var SharedValConfig = zod.z.object({
4064
4101
  contentHostUrl: zod.z.string().optional(),
4065
4102
  appHostUrl: zod.z.string().optional(),
@@ -7454,6 +7491,7 @@ exports.buildFileRefValue = buildFileRefValue;
7454
7491
  exports.buildImageGalleryPatch = buildImageGalleryPatch;
7455
7492
  exports.buildRemoveImageGalleryEntryPatch = buildRemoveImageGalleryEntryPatch;
7456
7493
  exports.buildSearchIndex = buildSearchIndex;
7494
+ exports.chainHeadOf = chainHeadOf;
7457
7495
  exports.checkCompatibility = checkCompatibility;
7458
7496
  exports.chooseEncoded = chooseEncoded;
7459
7497
  exports.concatModulePath = concatModulePath;
@@ -1984,6 +1984,13 @@ var Api = {
1984
1984
  * carries back to `/save` to say which world it decided against.
1985
1985
  */
1986
1986
  headCommitSha: zod.z.string().optional(),
1987
+ /**
1988
+ * The head of the PATCH CHAIN: the last patch registered on the
1989
+ * branch, published or not. `null` when there is none. What a
1990
+ * new patch names as its parent — see `chainHeadOf`. Optional: a
1991
+ * content service that predates it sends nothing.
1992
+ */
1993
+ headPatchId: PatchId.nullable().optional(),
1987
1994
  commits: zod.z.array(ValCommit),
1988
1995
  /**
1989
1996
  * The publishes the content service knows about.
@@ -4060,6 +4067,36 @@ function newestCommitSha(commits) {
4060
4067
  return (_newest$commitSha = (_newest = newest) === null || _newest === void 0 ? void 0 : _newest.commitSha) !== null && _newest$commitSha !== void 0 ? _newest$commitSha : null;
4061
4068
  }
4062
4069
 
4070
+ /**
4071
+ * The patch a new write names as its parent: the HEAD of the chain, or `null`
4072
+ * when the chain is empty and the write goes on the base.
4073
+ *
4074
+ * The head the server REPORTS (`headPatchId`) when it reports one, and not the
4075
+ * last patch it listed. The list — `/applicable/patches`, and `/stat` on top of
4076
+ * it — leaves out patches the running deployment already contains, and since
4077
+ * patch groups a publish can ship later patches while an earlier one stays
4078
+ * pending (another author's change that nets to nothing can never be published
4079
+ * at all). The last listed id is then behind the head for good, and the content
4080
+ * service accepts a write only on the head, so every save naming it is refused
4081
+ * — and a re-sync returns the same list. What fixed it in the Studio before
4082
+ * this existed was discarding the other author's change.
4083
+ *
4084
+ * `null` is a REPORTED empty chain, not "unknown". `undefined` is a server
4085
+ * that reports no head (`fs` mode, which ignores the parent anyway, or a
4086
+ * content service that predates the field), and only then does this fall back
4087
+ * to the last listed id.
4088
+ *
4089
+ * One rule for both writers, the Studio's `PatchSync` and the MCP's
4090
+ * `deriveParentRef`, so they cannot come to name different parents.
4091
+ */
4092
+ function chainHeadOf(reportedHead, listed) {
4093
+ var _listed;
4094
+ if (reportedHead !== undefined) {
4095
+ return reportedHead;
4096
+ }
4097
+ return (_listed = listed[listed.length - 1]) !== null && _listed !== void 0 ? _listed : null;
4098
+ }
4099
+
4063
4100
  var SharedValConfig = zod.z.object({
4064
4101
  contentHostUrl: zod.z.string().optional(),
4065
4102
  appHostUrl: zod.z.string().optional(),
@@ -7454,6 +7491,7 @@ exports.buildFileRefValue = buildFileRefValue;
7454
7491
  exports.buildImageGalleryPatch = buildImageGalleryPatch;
7455
7492
  exports.buildRemoveImageGalleryEntryPatch = buildRemoveImageGalleryEntryPatch;
7456
7493
  exports.buildSearchIndex = buildSearchIndex;
7494
+ exports.chainHeadOf = chainHeadOf;
7457
7495
  exports.checkCompatibility = checkCompatibility;
7458
7496
  exports.chooseEncoded = chooseEncoded;
7459
7497
  exports.concatModulePath = concatModulePath;
@@ -1977,6 +1977,13 @@ var Api = {
1977
1977
  * carries back to `/save` to say which world it decided against.
1978
1978
  */
1979
1979
  headCommitSha: z.string().optional(),
1980
+ /**
1981
+ * The head of the PATCH CHAIN: the last patch registered on the
1982
+ * branch, published or not. `null` when there is none. What a
1983
+ * new patch names as its parent — see `chainHeadOf`. Optional: a
1984
+ * content service that predates it sends nothing.
1985
+ */
1986
+ headPatchId: PatchId.nullable().optional(),
1980
1987
  commits: z.array(ValCommit),
1981
1988
  /**
1982
1989
  * The publishes the content service knows about.
@@ -4053,6 +4060,36 @@ function newestCommitSha(commits) {
4053
4060
  return (_newest$commitSha = (_newest = newest) === null || _newest === void 0 ? void 0 : _newest.commitSha) !== null && _newest$commitSha !== void 0 ? _newest$commitSha : null;
4054
4061
  }
4055
4062
 
4063
+ /**
4064
+ * The patch a new write names as its parent: the HEAD of the chain, or `null`
4065
+ * when the chain is empty and the write goes on the base.
4066
+ *
4067
+ * The head the server REPORTS (`headPatchId`) when it reports one, and not the
4068
+ * last patch it listed. The list — `/applicable/patches`, and `/stat` on top of
4069
+ * it — leaves out patches the running deployment already contains, and since
4070
+ * patch groups a publish can ship later patches while an earlier one stays
4071
+ * pending (another author's change that nets to nothing can never be published
4072
+ * at all). The last listed id is then behind the head for good, and the content
4073
+ * service accepts a write only on the head, so every save naming it is refused
4074
+ * — and a re-sync returns the same list. What fixed it in the Studio before
4075
+ * this existed was discarding the other author's change.
4076
+ *
4077
+ * `null` is a REPORTED empty chain, not "unknown". `undefined` is a server
4078
+ * that reports no head (`fs` mode, which ignores the parent anyway, or a
4079
+ * content service that predates the field), and only then does this fall back
4080
+ * to the last listed id.
4081
+ *
4082
+ * One rule for both writers, the Studio's `PatchSync` and the MCP's
4083
+ * `deriveParentRef`, so they cannot come to name different parents.
4084
+ */
4085
+ function chainHeadOf(reportedHead, listed) {
4086
+ var _listed;
4087
+ if (reportedHead !== undefined) {
4088
+ return reportedHead;
4089
+ }
4090
+ return (_listed = listed[listed.length - 1]) !== null && _listed !== void 0 ? _listed : null;
4091
+ }
4092
+
4056
4093
  var SharedValConfig = z.object({
4057
4094
  contentHostUrl: z.string().optional(),
4058
4095
  appHostUrl: z.string().optional(),
@@ -7349,4 +7386,4 @@ function parse(schema, body, call) {
7349
7386
  return parsed.data;
7350
7387
  }
7351
7388
 
7352
- 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 };
7389
+ 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, chainHeadOf, 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.3",
3
+ "version": "0.136.10",
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.1"
40
+ "@valbuild/core": "0.136.8"
41
41
  },
42
42
  "files": [
43
43
  "CHANGELOG.md",