@valbuild/shared 0.145.1 → 0.146.0
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 +18 -0
- package/dist/declarations/src/internal/ApiRoutes.d.ts +73 -273
- package/dist/declarations/src/internal/chainHead.d.ts +5 -7
- package/dist/declarations/src/internal/index.d.ts +3 -0
- package/dist/declarations/src/internal/patchSets/PatchSets.d.ts +75 -0
- package/dist/declarations/src/internal/patchSets/schemaTypesOfPath.d.ts +5 -0
- package/dist/declarations/src/internal/proposalMerge/trees.d.ts +56 -0
- package/dist/declarations/src/internal/publish/contentApi.d.ts +0 -4
- package/dist/declarations/src/internal/server/requestScopedMemo.d.ts +10 -8
- package/dist/declarations/src/internal/server/types.d.ts +3 -3
- package/dist/declarations/src/internal/zod/History.d.ts +5 -5
- package/dist/declarations/src/internal/zod/Patch.d.ts +0 -1
- package/dist/declarations/src/internal/zod/SerializedSchema.d.ts +1 -1
- package/internal/dist/valbuild-shared-internal.cjs.dev.js +537 -269
- package/internal/dist/valbuild-shared-internal.cjs.prod.js +537 -269
- package/internal/dist/valbuild-shared-internal.esm.js +532 -269
- package/package.json +1 -1
|
@@ -768,14 +768,16 @@ var VAL_ENABLE_COOKIE_NAME = core.Internal.VAL_ENABLE_COOKIE_NAME;
|
|
|
768
768
|
* byte-identical each time, because the query and the session are fixed for the
|
|
769
769
|
* length of a request. This is what makes the second and third call free.
|
|
770
770
|
*
|
|
771
|
-
* ## Why the scope is the REQUEST
|
|
771
|
+
* ## Why the scope is the REQUEST
|
|
772
772
|
*
|
|
773
|
-
* The memoised response is
|
|
774
|
-
*
|
|
775
|
-
*
|
|
776
|
-
*
|
|
777
|
-
*
|
|
778
|
-
*
|
|
773
|
+
* The memoised response is a DRAFT -- unpublished work, read with the caller's
|
|
774
|
+
* session cookie. Every caller allowed to read drafts gets the same draft (patch
|
|
775
|
+
* groups, which made it per author, are gone), but whether a caller is allowed
|
|
776
|
+
* at all is decided per session. A memo that outlived the request would hand
|
|
777
|
+
* the draft to the next visitor without asking, and it would be invisible: the
|
|
778
|
+
* page would simply render somebody's half-finished sentence. Sharing it across
|
|
779
|
+
* requests is possible now, keyed on the chain's head, and would be its own
|
|
780
|
+
* measured change.
|
|
779
781
|
*
|
|
780
782
|
* So this module holds NO state of its own. The caller supplies the box, and
|
|
781
783
|
* the box has to come from something the framework already scopes to the
|
|
@@ -1733,21 +1735,6 @@ var StatProposal = zod.z.object({
|
|
|
1733
1735
|
/** `val/p/<name>`. */
|
|
1734
1736
|
branch: zod.z.string()
|
|
1735
1737
|
});
|
|
1736
|
-
|
|
1737
|
-
/**
|
|
1738
|
-
* A patch group: the set of patches one user has chosen to publish.
|
|
1739
|
-
*
|
|
1740
|
-
* Not a patch *set* — a patch set is computed from the schema and says which
|
|
1741
|
-
* patches must move together; a patch group is curated and says which ones this
|
|
1742
|
-
* user wants live. See `docs/independent-publish/PLAN.md`.
|
|
1743
|
-
*/
|
|
1744
|
-
var PatchGroup = zod.z.object({
|
|
1745
|
-
patchGroupId: zod.z.string(),
|
|
1746
|
-
authorId: zod.z.string().nullable(),
|
|
1747
|
-
createdAt: zod.z.string(),
|
|
1748
|
-
publishedAt: zod.z.string().nullable(),
|
|
1749
|
-
patchIds: zod.z.array(PatchId)
|
|
1750
|
-
});
|
|
1751
1738
|
var GenericPatchError = zod.z.union([zod.z.object({
|
|
1752
1739
|
patchId: PatchId,
|
|
1753
1740
|
message: zod.z.string(),
|
|
@@ -2256,14 +2243,6 @@ var Api = {
|
|
|
2256
2243
|
* highest version. Optional, for the same reason `headPatchId` is.
|
|
2257
2244
|
*/
|
|
2258
2245
|
headVersion: zod.z.number().optional(),
|
|
2259
|
-
/**
|
|
2260
|
-
* Every group on the branch and which listed patches it holds,
|
|
2261
|
-
* read with the list and `headVersion`. What a Studio's view of
|
|
2262
|
-
* the groups is taken from, so a stage or an unstage made in
|
|
2263
|
-
* another browser reaches it with the next stat. Absent where
|
|
2264
|
-
* the content service has no groups.
|
|
2265
|
-
*/
|
|
2266
|
-
patchGroups: zod.z.array(PatchGroup).optional(),
|
|
2267
2246
|
commits: zod.z.array(ValCommit),
|
|
2268
2247
|
/**
|
|
2269
2248
|
* The publishes the content service knows about.
|
|
@@ -2560,24 +2539,6 @@ var Api = {
|
|
|
2560
2539
|
id: zod.z.array(PatchId).min(1, "At least one patch id is required")
|
|
2561
2540
|
},
|
|
2562
2541
|
body: zod.z.object({
|
|
2563
|
-
/*
|
|
2564
|
-
* Patches that are NOT being deleted but must lose their patch
|
|
2565
|
-
* group membership because these are.
|
|
2566
|
-
*
|
|
2567
|
-
* Deleting a patch out of the middle of a patch set leaves every
|
|
2568
|
-
* group holding the rest with a non-prefix intersection, and a
|
|
2569
|
-
* prefix is the one invariant a group has. Which patches those are
|
|
2570
|
-
* needs the content schema, so the client computes the forward
|
|
2571
|
-
* closure and sends it; the content API drops the memberships
|
|
2572
|
-
* without touching the patches.
|
|
2573
|
-
*
|
|
2574
|
-
* In the BODY while the ids to delete are in the query, because
|
|
2575
|
-
* this list is unbounded in the same way and the query string is
|
|
2576
|
-
* already chunked to fit. Optional throughout: `fs` mode has no
|
|
2577
|
-
* groups, and a client that predates this is deleting correctly,
|
|
2578
|
-
* just not repairing.
|
|
2579
|
-
*/
|
|
2580
|
-
unstagePatchIds: zod.z.array(PatchId).optional(),
|
|
2581
2542
|
/*
|
|
2582
2543
|
* Answer with `{ deleted, headVersion }` rather than the bare id
|
|
2583
2544
|
* array. Asked for rather than always sent, because the array is
|
|
@@ -2619,16 +2580,7 @@ var Api = {
|
|
|
2619
2580
|
path: ModuleFilePath,
|
|
2620
2581
|
patchId: PatchId,
|
|
2621
2582
|
patch: zod.z.any() // TODO: this should be Patch instead - we got a weird validation error: although input looks good, it still does not accept objects as values... Which it should do via the z.record(JSONValue) type
|
|
2622
|
-
}))
|
|
2623
|
-
// Patch group membership. Sent with the patch itself, in one request, so
|
|
2624
|
-
// there is no window in which a patch exists but belongs to no group.
|
|
2625
|
-
// Absent means "the caller does not know about groups" - the server then
|
|
2626
|
-
// behaves exactly as before.
|
|
2627
|
-
patchGroupId: zod.z.string().nullish(),
|
|
2628
|
-
// What has to come with the patch: other patch ids that must join the
|
|
2629
|
-
// same group for it to stay applicable. Computed on the client, which
|
|
2630
|
-
// is the only side that has the schema needed to derive patch sets.
|
|
2631
|
-
withPatchIds: zod.z.array(PatchId).optional()
|
|
2583
|
+
}))
|
|
2632
2584
|
}),
|
|
2633
2585
|
cookies: {
|
|
2634
2586
|
val_session: zod.z.string().optional()
|
|
@@ -2670,7 +2622,6 @@ var Api = {
|
|
|
2670
2622
|
error: PlanRefusalError,
|
|
2671
2623
|
newPatchIds: zod.z.array(PatchId),
|
|
2672
2624
|
parentRef: ParentRef,
|
|
2673
|
-
patchGroupId: zod.z.string().optional(),
|
|
2674
2625
|
headVersion: zod.z.number().optional()
|
|
2675
2626
|
})
|
|
2676
2627
|
}), zod.z.object({
|
|
@@ -2678,7 +2629,6 @@ var Api = {
|
|
|
2678
2629
|
json: zod.z.object({
|
|
2679
2630
|
newPatchIds: zod.z.array(PatchId),
|
|
2680
2631
|
parentRef: ParentRef,
|
|
2681
|
-
patchGroupId: zod.z.string().optional(),
|
|
2682
2632
|
/**
|
|
2683
2633
|
* The chain version the last of these patches made, comparable with
|
|
2684
2634
|
* `headVersion` on `/stat`. A client keeps the highest version, so a
|
|
@@ -2693,16 +2643,7 @@ var Api = {
|
|
|
2693
2643
|
req: {
|
|
2694
2644
|
query: {
|
|
2695
2645
|
patch_id: zod.z.array(PatchId).optional(),
|
|
2696
|
-
exclude_patch_ops: onlyOneBooleanQueryParam.optional()
|
|
2697
|
-
/**
|
|
2698
|
-
* Include the patch group annotation in the answer.
|
|
2699
|
-
*
|
|
2700
|
-
* Off by default because the client CHUNKS this request — a long
|
|
2701
|
-
* chain is several round trips — and the groups are a property of the
|
|
2702
|
-
* branch, identical in every chunk. Asking on each one is N identical
|
|
2703
|
-
* lookups against the content API to learn the same thing.
|
|
2704
|
-
*/
|
|
2705
|
-
include_patch_groups: onlyOneBooleanQueryParam.optional()
|
|
2646
|
+
exclude_patch_ops: onlyOneBooleanQueryParam.optional()
|
|
2706
2647
|
},
|
|
2707
2648
|
cookies: {
|
|
2708
2649
|
val_session: zod.z.string().optional()
|
|
@@ -2731,12 +2672,8 @@ var Api = {
|
|
|
2731
2672
|
authorId: zod.z.string().nullable(),
|
|
2732
2673
|
appliedAt: zod.z.object({
|
|
2733
2674
|
commitSha: zod.z.string()
|
|
2734
|
-
}).nullable()
|
|
2735
|
-
// Which patch groups hold this patch. Optional so that FS mode, and
|
|
2736
|
-
// any server that predates patch groups, can leave it out.
|
|
2737
|
-
patchGroupIds: zod.z.array(zod.z.string()).optional()
|
|
2675
|
+
}).nullable()
|
|
2738
2676
|
})),
|
|
2739
|
-
patchGroups: zod.z.array(PatchGroup).optional(),
|
|
2740
2677
|
baseSha: zod.z.string(),
|
|
2741
2678
|
error: GenericError.optional(),
|
|
2742
2679
|
errors: zod.z.record(PatchId, GenericError).optional()
|
|
@@ -2744,111 +2681,6 @@ var Api = {
|
|
|
2744
2681
|
})])
|
|
2745
2682
|
}
|
|
2746
2683
|
},
|
|
2747
|
-
// Patch group membership. Both are idempotent set operations, and both take an
|
|
2748
|
-
// already-closed set: the client computes the prefix closure (staging) or the
|
|
2749
|
-
// forward closure (unstaging) because only the client has the schema needed to
|
|
2750
|
-
// derive patch sets. See `docs/independent-publish/PLAN.md`.
|
|
2751
|
-
"/patch-groups/~/patches": {
|
|
2752
|
-
PUT: {
|
|
2753
|
-
req: {
|
|
2754
|
-
body: zod.z.object({
|
|
2755
|
-
/**
|
|
2756
|
-
* The group to stage into. Absent means the caller's open group on
|
|
2757
|
-
* the branch, created if there is none — which is what the Studio
|
|
2758
|
-
* sends, so a stage never has to wait for a group to exist.
|
|
2759
|
-
*/
|
|
2760
|
-
patchGroupId: zod.z.string().optional(),
|
|
2761
|
-
/** What the user asked to stage. */
|
|
2762
|
-
patchIds: zod.z.array(PatchId),
|
|
2763
|
-
/*
|
|
2764
|
-
* What has to come with it, because the staged patches are written on
|
|
2765
|
-
* top of it.
|
|
2766
|
-
*
|
|
2767
|
-
* The content API records membership as `explicit` or `dependency`
|
|
2768
|
-
* and reads what it is not told about as a dependency — so folding
|
|
2769
|
-
* the two halves into `patchIds` files the patch someone clicked as
|
|
2770
|
-
* something the closure dragged in.
|
|
2771
|
-
*/
|
|
2772
|
-
withPatchIds: zod.z.array(PatchId).optional()
|
|
2773
|
-
}).refine(function (body) {
|
|
2774
|
-
var _body$withPatchIds$le, _body$withPatchIds;
|
|
2775
|
-
return body.patchIds.length > 0 || ((_body$withPatchIds$le = (_body$withPatchIds = body.withPatchIds) === null || _body$withPatchIds === void 0 ? void 0 : _body$withPatchIds.length) !== null && _body$withPatchIds$le !== void 0 ? _body$withPatchIds$le : 0) > 0;
|
|
2776
|
-
},
|
|
2777
|
-
// Either half alone is a real request: a stage of only what came with
|
|
2778
|
-
// it happens when the deferred queue's scope filter drops everything
|
|
2779
|
-
// the user originally clicked.
|
|
2780
|
-
"At least one patch id is required"),
|
|
2781
|
-
cookies: {
|
|
2782
|
-
val_session: zod.z.string().optional()
|
|
2783
|
-
}
|
|
2784
|
-
},
|
|
2785
|
-
res: zod.z.union([unauthorizedResponse, zod.z.object({
|
|
2786
|
-
status: zod.z.literal(403),
|
|
2787
|
-
json: GenericError
|
|
2788
|
-
}), zod.z.object({
|
|
2789
|
-
// The group has already been published, so its membership is frozen.
|
|
2790
|
-
status: zod.z.literal(409),
|
|
2791
|
-
json: GenericError
|
|
2792
|
-
}), zod.z.object({
|
|
2793
|
-
status: zod.z.literal(500),
|
|
2794
|
-
json: GenericError
|
|
2795
|
-
}), zod.z.object({
|
|
2796
|
-
status: zod.z.literal(200),
|
|
2797
|
-
json: zod.z.object({
|
|
2798
|
-
/** `null` for an unstage when the caller has no open group. */
|
|
2799
|
-
patchGroupId: zod.z.string().nullable(),
|
|
2800
|
-
patchIds: zod.z.array(PatchId),
|
|
2801
|
-
/**
|
|
2802
|
-
* The chain version the change committed at. The client keeps its
|
|
2803
|
-
* own view of the change until a stat at least this new shows it.
|
|
2804
|
-
* Absent from a content service that predates it.
|
|
2805
|
-
*/
|
|
2806
|
-
headVersion: zod.z.number().optional()
|
|
2807
|
-
})
|
|
2808
|
-
})])
|
|
2809
|
-
},
|
|
2810
|
-
DELETE: {
|
|
2811
|
-
req: {
|
|
2812
|
-
body: zod.z.object({
|
|
2813
|
-
/** See the PUT. Absent with no open group is a no-op. */
|
|
2814
|
-
patchGroupId: zod.z.string().optional(),
|
|
2815
|
-
/** What the user asked to unstage. */
|
|
2816
|
-
patchIds: zod.z.array(PatchId),
|
|
2817
|
-
/** What has to go with it: everything built on top of it. */
|
|
2818
|
-
withPatchIds: zod.z.array(PatchId).optional()
|
|
2819
|
-
}).refine(function (body) {
|
|
2820
|
-
var _body$withPatchIds$le2, _body$withPatchIds2;
|
|
2821
|
-
return body.patchIds.length > 0 || ((_body$withPatchIds$le2 = (_body$withPatchIds2 = body.withPatchIds) === null || _body$withPatchIds2 === void 0 ? void 0 : _body$withPatchIds2.length) !== null && _body$withPatchIds$le2 !== void 0 ? _body$withPatchIds$le2 : 0) > 0;
|
|
2822
|
-
}, "At least one patch id is required"),
|
|
2823
|
-
cookies: {
|
|
2824
|
-
val_session: zod.z.string().optional()
|
|
2825
|
-
}
|
|
2826
|
-
},
|
|
2827
|
-
res: zod.z.union([unauthorizedResponse, zod.z.object({
|
|
2828
|
-
status: zod.z.literal(403),
|
|
2829
|
-
json: GenericError
|
|
2830
|
-
}), zod.z.object({
|
|
2831
|
-
status: zod.z.literal(409),
|
|
2832
|
-
json: GenericError
|
|
2833
|
-
}), zod.z.object({
|
|
2834
|
-
status: zod.z.literal(500),
|
|
2835
|
-
json: GenericError
|
|
2836
|
-
}), zod.z.object({
|
|
2837
|
-
status: zod.z.literal(200),
|
|
2838
|
-
json: zod.z.object({
|
|
2839
|
-
/** `null` for an unstage when the caller has no open group. */
|
|
2840
|
-
patchGroupId: zod.z.string().nullable(),
|
|
2841
|
-
patchIds: zod.z.array(PatchId),
|
|
2842
|
-
/**
|
|
2843
|
-
* The chain version the change committed at. The client keeps its
|
|
2844
|
-
* own view of the change until a stat at least this new shows it.
|
|
2845
|
-
* Absent from a content service that predates it.
|
|
2846
|
-
*/
|
|
2847
|
-
headVersion: zod.z.number().optional()
|
|
2848
|
-
})
|
|
2849
|
-
})])
|
|
2850
|
-
}
|
|
2851
|
-
},
|
|
2852
2684
|
"/schema": {
|
|
2853
2685
|
GET: {
|
|
2854
2686
|
req: {
|
|
@@ -2885,34 +2717,7 @@ var Api = {
|
|
|
2885
2717
|
validate_sources: onlyOneBooleanQueryParam.optional(),
|
|
2886
2718
|
validate_binary_files: onlyOneBooleanQueryParam.optional(),
|
|
2887
2719
|
exclude_patches: onlyOneBooleanQueryParam.optional(),
|
|
2888
|
-
apply_patches: onlyOneBooleanQueryParam.optional()
|
|
2889
|
-
/**
|
|
2890
|
-
* Apply ONLY these patches, rather than everything pending.
|
|
2891
|
-
*
|
|
2892
|
-
* This is what makes a draft-mode render match the caller's staged
|
|
2893
|
-
* view. Without it `/sources/~` replays every pending patch on the
|
|
2894
|
-
* branch, so a server-rendered preview shows other people's
|
|
2895
|
-
* unpublished work — the one thing independent publish is for.
|
|
2896
|
-
*
|
|
2897
|
-
* Omitted means everything pending, which is the behaviour every
|
|
2898
|
-
* existing caller has and must keep. An EMPTY array is a different
|
|
2899
|
-
* answer and is honoured as one: a group holding nothing renders
|
|
2900
|
-
* base.
|
|
2901
|
-
*/
|
|
2902
|
-
patch_id: zod.z.array(PatchId).optional(),
|
|
2903
|
-
/**
|
|
2904
|
-
* Apply only the patches in the CALLER'S OWN patch groups.
|
|
2905
|
-
*
|
|
2906
|
-
* The server resolves them from the session, so a draft render does
|
|
2907
|
-
* not have to know its own group ids — which it cannot, since it has
|
|
2908
|
-
* no client state. This is what makes `fetchVal` in draft mode show
|
|
2909
|
-
* the person their own staged work rather than everybody's.
|
|
2910
|
-
*
|
|
2911
|
-
* Ignored when `patch_id` is given: an explicit list is a caller that
|
|
2912
|
-
* already knows what it wants, and silently intersecting the two
|
|
2913
|
-
* would make the narrower one invisible.
|
|
2914
|
-
*/
|
|
2915
|
-
own_patch_groups_only: onlyOneBooleanQueryParam.optional()
|
|
2720
|
+
apply_patches: onlyOneBooleanQueryParam.optional()
|
|
2916
2721
|
},
|
|
2917
2722
|
cookies: {
|
|
2918
2723
|
val_session: zod.z.string().optional()
|
|
@@ -3072,18 +2877,6 @@ var Api = {
|
|
|
3072
2877
|
body: zod.z.object({
|
|
3073
2878
|
message: zod.z.string().optional(),
|
|
3074
2879
|
patchIds: zod.z.array(PatchId),
|
|
3075
|
-
/*
|
|
3076
|
-
* The patch group this commit EMPTIES, if it empties one.
|
|
3077
|
-
*
|
|
3078
|
-
* Forwarded to the content API, which closes the group it names —
|
|
3079
|
-
* and closes it unconditionally, without checking that the commit
|
|
3080
|
-
* shipped all of it. So the client sends it only when the publish
|
|
3081
|
-
* accounts for every patch the group still holds; a partial publish
|
|
3082
|
-
* omits it and the group stays open with the rest in it.
|
|
3083
|
-
*
|
|
3084
|
-
* Optional, and absent in `fs` mode, which has no groups.
|
|
3085
|
-
*/
|
|
3086
|
-
patchGroupId: zod.z.string().optional(),
|
|
3087
2880
|
/*
|
|
3088
2881
|
* The newest commit this client knew about when it decided.
|
|
3089
2882
|
*
|
|
@@ -3192,19 +2985,6 @@ var Api = {
|
|
|
3192
2985
|
*/
|
|
3193
2986
|
headVersion: zod.z.number().optional()
|
|
3194
2987
|
})
|
|
3195
|
-
}),
|
|
3196
|
-
/*
|
|
3197
|
-
* The named patch group is not this caller's, or the lookup that would
|
|
3198
|
-
* say so failed.
|
|
3199
|
-
*
|
|
3200
|
-
* Publishing may CLOSE a group, and closing somebody else's leaves
|
|
3201
|
-
* their pending work in a closed group and in no open one. So `/save`
|
|
3202
|
-
* runs the same ownership check stage and unstage do, and refuses the
|
|
3203
|
-
* same way — see `refuseUnlessOwn`.
|
|
3204
|
-
*/
|
|
3205
|
-
zod.z.object({
|
|
3206
|
-
status: zod.z.literal(403),
|
|
3207
|
-
json: GenericError
|
|
3208
2988
|
}), zod.z.object({
|
|
3209
2989
|
status: zod.z.literal(500),
|
|
3210
2990
|
json: GenericError
|
|
@@ -3222,8 +3002,7 @@ var Api = {
|
|
|
3222
3002
|
zod.z.object({
|
|
3223
3003
|
message: zod.z.string(),
|
|
3224
3004
|
publishRefusal: PublishRefusal
|
|
3225
|
-
}),
|
|
3226
|
-
zod.z.object({
|
|
3005
|
+
}), zod.z.object({
|
|
3227
3006
|
message: zod.z.string()
|
|
3228
3007
|
}), zod.z.object({
|
|
3229
3008
|
message: zod.z.string(),
|
|
@@ -3242,22 +3021,6 @@ var Api = {
|
|
|
3242
3021
|
zod.z.object({
|
|
3243
3022
|
message: zod.z.string(),
|
|
3244
3023
|
headMoved: zod.z.literal(true)
|
|
3245
|
-
}),
|
|
3246
|
-
/**
|
|
3247
|
-
* The group this commit named has already been published.
|
|
3248
|
-
*
|
|
3249
|
-
* A third thing sharing 409, and flagged for the same reason
|
|
3250
|
-
* `headMoved` is: read as a plain not-fast-forward it looks
|
|
3251
|
-
* retryable, and it is the opposite — the id will never be writable
|
|
3252
|
-
* again, so retrying reproduces it forever.
|
|
3253
|
-
*
|
|
3254
|
-
* It means this author published from somewhere else. The client
|
|
3255
|
-
* forgets the id and falls back to the annotation, which is the
|
|
3256
|
-
* same recovery a 409 on stage or unstage triggers.
|
|
3257
|
-
*/
|
|
3258
|
-
zod.z.object({
|
|
3259
|
-
message: zod.z.string(),
|
|
3260
|
-
patchGroupPublished: zod.z.literal(true)
|
|
3261
3024
|
})])
|
|
3262
3025
|
}), zod.z.object({
|
|
3263
3026
|
status: zod.z.literal(400),
|
|
@@ -3552,16 +3315,7 @@ var Api = {
|
|
|
3552
3315
|
limit: onlyOneIntQueryParam.refine(function (arg) {
|
|
3553
3316
|
return arg > 0 && arg <= JSON_ENTRIES_BATCH_MAX;
|
|
3554
3317
|
}, "limit must be between 1 and ".concat(JSON_ENTRIES_BATCH_MAX)).optional(),
|
|
3555
|
-
apply_patches: onlyOneBooleanQueryParam.optional()
|
|
3556
|
-
/**
|
|
3557
|
-
* The caller's own staged work, and nobody else's.
|
|
3558
|
-
*
|
|
3559
|
-
* The same flag `/sources/~` takes, and for the same reason — a draft
|
|
3560
|
-
* page renders both, so a scoped module beside an unscoped
|
|
3561
|
-
* `jsonValues` entry showed one person's view and everybody's pending
|
|
3562
|
-
* work on the same screen.
|
|
3563
|
-
*/
|
|
3564
|
-
own_patch_groups_only: onlyOneBooleanQueryParam.optional()
|
|
3318
|
+
apply_patches: onlyOneBooleanQueryParam.optional()
|
|
3565
3319
|
},
|
|
3566
3320
|
cookies: getSitemapTree._defineProperty({}, VAL_SESSION_COOKIE, zod.z.string().optional())
|
|
3567
3321
|
},
|
|
@@ -4627,13 +4381,11 @@ function newestCommitSha(commits) {
|
|
|
4627
4381
|
*
|
|
4628
4382
|
* The head the server REPORTS (`headPatchId`) when it reports one, and not the
|
|
4629
4383
|
* last patch it listed. The list — `/applicable/patches`, and `/stat` on top of
|
|
4630
|
-
* it — leaves out patches the running deployment already contains, and
|
|
4631
|
-
*
|
|
4632
|
-
*
|
|
4633
|
-
*
|
|
4634
|
-
*
|
|
4635
|
-
* — and a re-sync returns the same list. What fixed it in the Studio before
|
|
4636
|
-
* this existed was discarding the other author's change.
|
|
4384
|
+
* it — leaves out patches the running deployment already contains, and a
|
|
4385
|
+
* publish can ship later patches while an earlier one stays pending (a failed
|
|
4386
|
+
* publish holds its changes back). The last listed id is then behind the head
|
|
4387
|
+
* for good, and the content service accepts a write only on the head, so every
|
|
4388
|
+
* save naming it is refused — and a re-sync returns the same list.
|
|
4637
4389
|
*
|
|
4638
4390
|
* `null` is a REPORTED empty chain, not "unknown". `undefined` is a server
|
|
4639
4391
|
* that reports no head (`fs` mode, which ignores the parent anyway, or a
|
|
@@ -8088,6 +7840,517 @@ function parse(schema, body, call) {
|
|
|
8088
7840
|
return parsed.data;
|
|
8089
7841
|
}
|
|
8090
7842
|
|
|
7843
|
+
/**
|
|
7844
|
+
* This functions returns all the possible schema types of a given module path.
|
|
7845
|
+
*/
|
|
7846
|
+
function schemaTypesOfPath(schema, patchPath) {
|
|
7847
|
+
if (!patchPath || patchPath.length === 0) {
|
|
7848
|
+
return new Set([schema.type]);
|
|
7849
|
+
}
|
|
7850
|
+
var branches = new Set();
|
|
7851
|
+
var current = schema;
|
|
7852
|
+
var i = -1;
|
|
7853
|
+
var _iterator = getSitemapTree._createForOfIteratorHelper(patchPath),
|
|
7854
|
+
_step;
|
|
7855
|
+
try {
|
|
7856
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
7857
|
+
var pathPart = _step.value;
|
|
7858
|
+
i++;
|
|
7859
|
+
if (!current) {
|
|
7860
|
+
break;
|
|
7861
|
+
}
|
|
7862
|
+
if (current.type === "array") {
|
|
7863
|
+
current = current.item;
|
|
7864
|
+
} else if (current.type === "record") {
|
|
7865
|
+
current = current.item;
|
|
7866
|
+
} else if (current.type === "object" || current.type === "settings") {
|
|
7867
|
+
current = current.items[pathPart];
|
|
7868
|
+
} else if (current.type === "richtext") {
|
|
7869
|
+
// richtext has internal structure (nodes with indices and tags), allow traversal
|
|
7870
|
+
break;
|
|
7871
|
+
} else if (current.type === "discriminated-union") {
|
|
7872
|
+
var types = current.items;
|
|
7873
|
+
var _iterator2 = getSitemapTree._createForOfIteratorHelper(types),
|
|
7874
|
+
_step2;
|
|
7875
|
+
try {
|
|
7876
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
7877
|
+
var type = _step2.value;
|
|
7878
|
+
var subTypes = schemaTypesOfPath(type, patchPath.slice(i));
|
|
7879
|
+
for (var _i = 0, _Array$from = Array.from(subTypes.values()); _i < _Array$from.length; _i++) {
|
|
7880
|
+
var subType = _Array$from[_i];
|
|
7881
|
+
branches.add(subType);
|
|
7882
|
+
}
|
|
7883
|
+
}
|
|
7884
|
+
} catch (err) {
|
|
7885
|
+
_iterator2.e(err);
|
|
7886
|
+
} finally {
|
|
7887
|
+
_iterator2.f();
|
|
7888
|
+
}
|
|
7889
|
+
return branches;
|
|
7890
|
+
} else if (current.type === "enum" || current.type === "boolean" || current.type === "number" || current.type === "string" || current.type === "date" || current.type === "dateTime" || current.type === "color" || current.type === "code" || current.type === "file" || current.type === "image" || current.type === "video" || current.type === "keyOf" || current.type === "route" || current.type === "locale" || current.type === "literal" ||
|
|
7891
|
+
// Nothing is patchable at a view path: the target module owns its source.
|
|
7892
|
+
current.type === "view") {
|
|
7893
|
+
if (current.type === "image" || current.type === "file") {
|
|
7894
|
+
// allow changes to metadata
|
|
7895
|
+
if (patchPath[i] === "metadata") {
|
|
7896
|
+
break;
|
|
7897
|
+
}
|
|
7898
|
+
}
|
|
7899
|
+
if (current.type === "video") {
|
|
7900
|
+
// A video is edited a property at a time — its poster time, a caption
|
|
7901
|
+
// track's label — so that two editors changing different parts of one
|
|
7902
|
+
// video do not overwrite each other. Everything below it is the video.
|
|
7903
|
+
break;
|
|
7904
|
+
}
|
|
7905
|
+
if (i !== patchPath.length - 1) {
|
|
7906
|
+
throw new Error("Found " + current.type + " (primitive), but path has more parts: " + patchPath.join("/") + " at " + pathPart);
|
|
7907
|
+
}
|
|
7908
|
+
break;
|
|
7909
|
+
} else {
|
|
7910
|
+
var _unreachable = current;
|
|
7911
|
+
var unknownType = _unreachable.type;
|
|
7912
|
+
console.error("Unexecpted resolved schema type: ".concat(unknownType, " in ").concat(patchPath.join("/"), " at ").concat(pathPart));
|
|
7913
|
+
return new Set([unknownType]);
|
|
7914
|
+
}
|
|
7915
|
+
}
|
|
7916
|
+
} catch (err) {
|
|
7917
|
+
_iterator.e(err);
|
|
7918
|
+
} finally {
|
|
7919
|
+
_iterator.f();
|
|
7920
|
+
}
|
|
7921
|
+
if (current) {
|
|
7922
|
+
branches.add(current.type);
|
|
7923
|
+
// A discriminated union's value IS an object, and an enum's IS a string:
|
|
7924
|
+
// a patch op typed for either has to be accepted here too.
|
|
7925
|
+
if (current.type === "discriminated-union") {
|
|
7926
|
+
branches.add("object");
|
|
7927
|
+
} else if (current.type === "enum") {
|
|
7928
|
+
branches.add("string");
|
|
7929
|
+
}
|
|
7930
|
+
}
|
|
7931
|
+
return branches;
|
|
7932
|
+
}
|
|
7933
|
+
|
|
7934
|
+
// Examples: /file/name.val.ts?/path/to/patch
|
|
7935
|
+
|
|
7936
|
+
/**
|
|
7937
|
+
* A patch set is a set of patches that are non-independent of each other. This is useful for example when we want to apply a set of patches atomically.
|
|
7938
|
+
* A patch set is identified by a module file path and a json patch path delimited by a '?' character. We call this the patch set path. Example: /file/name.val.ts?/path/to/patch
|
|
7939
|
+
*
|
|
7940
|
+
*
|
|
7941
|
+
* NOTE: the order of patch sets is always newest first. This is because the UX always shows the newest patches first.
|
|
7942
|
+
*/
|
|
7943
|
+
|
|
7944
|
+
/**
|
|
7945
|
+
* Is `inner` strictly nested inside the patch set `outer`?
|
|
7946
|
+
*
|
|
7947
|
+
* A plain `inner.startsWith(outer)` is not enough, and the difference is not
|
|
7948
|
+
* cosmetic. The file part of a key is terminated by the '?' delimiter, but the
|
|
7949
|
+
* segments of the patch path are not terminated by anything, so a raw prefix
|
|
7950
|
+
* test also matches siblings whose *name* merely starts with the same
|
|
7951
|
+
* characters: '/p.val.ts?foobar/title' starts with '/p.val.ts?foo', so removing
|
|
7952
|
+
* record key "foo" and retitling record key "foobar" would be merged into one
|
|
7953
|
+
* patch set.
|
|
7954
|
+
*
|
|
7955
|
+
* That used to only over-group two unrelated changes in the compare view. Now
|
|
7956
|
+
* that patch sets decide what moves between branches as one (whole patch sets,
|
|
7957
|
+
* as `changesToMove` moves them), it means moving one key silently moves its
|
|
7958
|
+
* similarly-named sibling — so the boundary has to be
|
|
7959
|
+
* checked explicitly: '?' when `outer` is a bare module file path, '/' when it
|
|
7960
|
+
* already has a patch path.
|
|
7961
|
+
*/
|
|
7962
|
+
function isInsidePatchSetPath(inner, outer) {
|
|
7963
|
+
if (!inner.startsWith(outer)) {
|
|
7964
|
+
return false;
|
|
7965
|
+
}
|
|
7966
|
+
var boundary = inner[outer.length];
|
|
7967
|
+
return outer.includes("?") ? boundary === "/" : boundary === "?";
|
|
7968
|
+
}
|
|
7969
|
+
var PatchSets = /*#__PURE__*/function () {
|
|
7970
|
+
function PatchSets() {
|
|
7971
|
+
_classCallCheck(this, PatchSets);
|
|
7972
|
+
getSitemapTree._defineProperty(this, "insertedPatches", void 0);
|
|
7973
|
+
getSitemapTree._defineProperty(this, "patchSetMetadata", void 0);
|
|
7974
|
+
getSitemapTree._defineProperty(this, "orderedInsertKeys", void 0);
|
|
7975
|
+
this.patchSetMetadata = {};
|
|
7976
|
+
this.orderedInsertKeys = [];
|
|
7977
|
+
this.insertedPatches = new Set();
|
|
7978
|
+
}
|
|
7979
|
+
return _createClass(PatchSets, [{
|
|
7980
|
+
key: "reset",
|
|
7981
|
+
value: function reset() {
|
|
7982
|
+
this.patchSetMetadata = {};
|
|
7983
|
+
this.orderedInsertKeys = [];
|
|
7984
|
+
this.insertedPatches = new Set();
|
|
7985
|
+
}
|
|
7986
|
+
}, {
|
|
7987
|
+
key: "getInsertedPatches",
|
|
7988
|
+
value: function getInsertedPatches() {
|
|
7989
|
+
return this.insertedPatches;
|
|
7990
|
+
}
|
|
7991
|
+
}, {
|
|
7992
|
+
key: "insertPath",
|
|
7993
|
+
value: function insertPath(moduleFilePath, affectsPatchPath, patchId, createdAt, author, opType, schemaTypes, opPath) {
|
|
7994
|
+
var newPatchSetPath = affectsPatchPath.length > 0 ? "".concat(moduleFilePath, "?").concat(affectsPatchPath.join("/")) : moduleFilePath;
|
|
7995
|
+
var pathIndexesThatMustBeMerged = [];
|
|
7996
|
+
// TODO: current implementation is O(n), with isInside it is: O(n x m) - there's room for optimization (Trie?). Just make sure order is maintained and that insert AND then serialize is what we optimize for because the UX will do an insert, then serialize immediately after
|
|
7997
|
+
for (var i = this.orderedInsertKeys.length - 1; i >= 0; i--) {
|
|
7998
|
+
var currentInsertKey = this.orderedInsertKeys[i];
|
|
7999
|
+
if (newPatchSetPath !== currentInsertKey) {
|
|
8000
|
+
if (isInsidePatchSetPath(newPatchSetPath, currentInsertKey)) {
|
|
8001
|
+
// This new patch set is inside an existing patch set...
|
|
8002
|
+
// Use the existing patch set as the new name
|
|
8003
|
+
newPatchSetPath = currentInsertKey;
|
|
8004
|
+
// Move to new patch set to head
|
|
8005
|
+
this.orderedInsertKeys.splice(i, 1);
|
|
8006
|
+
this.orderedInsertKeys.unshift(newPatchSetPath);
|
|
8007
|
+
} else if (isInsidePatchSetPath(currentInsertKey, newPatchSetPath)) {
|
|
8008
|
+
// We found a patch set (with a shorter path) that needs to be merged into this new patch set
|
|
8009
|
+
pathIndexesThatMustBeMerged.push(i);
|
|
8010
|
+
}
|
|
8011
|
+
} else {
|
|
8012
|
+
// This patch set already exists
|
|
8013
|
+
// Move to new patch set to head
|
|
8014
|
+
this.orderedInsertKeys.splice(i, 1);
|
|
8015
|
+
this.orderedInsertKeys.unshift(newPatchSetPath);
|
|
8016
|
+
}
|
|
8017
|
+
}
|
|
8018
|
+
|
|
8019
|
+
// Merge existing patch sets into this new one:
|
|
8020
|
+
for (var _i = 0, _pathIndexesThatMustB = pathIndexesThatMustBeMerged; _i < _pathIndexesThatMustB.length; _i++) {
|
|
8021
|
+
var pathIndexThatMustBeMerged = _pathIndexesThatMustB[_i];
|
|
8022
|
+
var moduleFileOrPatchSetPath = this.orderedInsertKeys[pathIndexThatMustBeMerged];
|
|
8023
|
+
|
|
8024
|
+
// 1) remove the old patch set path from ordered insert key
|
|
8025
|
+
this.orderedInsertKeys.splice(pathIndexThatMustBeMerged, 1);
|
|
8026
|
+
|
|
8027
|
+
// 2) merge metadata into new
|
|
8028
|
+
var existingPatchSetMetadata = this.patchSetMetadata[moduleFileOrPatchSetPath];
|
|
8029
|
+
if (!this.patchSetMetadata[newPatchSetPath]) {
|
|
8030
|
+
this.patchSetMetadata[newPatchSetPath] = {
|
|
8031
|
+
moduleFilePath: moduleFilePath,
|
|
8032
|
+
patchPath: affectsPatchPath,
|
|
8033
|
+
patches: [],
|
|
8034
|
+
authors: [],
|
|
8035
|
+
opTypes: [],
|
|
8036
|
+
schemaTypes: Array.from(schemaTypes),
|
|
8037
|
+
lastUpdated: createdAt,
|
|
8038
|
+
lastUpdatedBy: author
|
|
8039
|
+
};
|
|
8040
|
+
}
|
|
8041
|
+
if (existingPatchSetMetadata) {
|
|
8042
|
+
var _iterator = getSitemapTree._createForOfIteratorHelper(existingPatchSetMetadata.patches.slice()),
|
|
8043
|
+
_step;
|
|
8044
|
+
try {
|
|
8045
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
8046
|
+
var patchMetadata = _step.value;
|
|
8047
|
+
this.patchSetMetadata[newPatchSetPath].patches.unshift(patchMetadata);
|
|
8048
|
+
if (patchMetadata.author !== null) {
|
|
8049
|
+
this.patchSetMetadata[newPatchSetPath].authors.unshift(patchMetadata.author);
|
|
8050
|
+
}
|
|
8051
|
+
this.patchSetMetadata[newPatchSetPath].opTypes.unshift(patchMetadata.opType);
|
|
8052
|
+
}
|
|
8053
|
+
} catch (err) {
|
|
8054
|
+
_iterator.e(err);
|
|
8055
|
+
} finally {
|
|
8056
|
+
_iterator.f();
|
|
8057
|
+
}
|
|
8058
|
+
} else {
|
|
8059
|
+
throw new Error("Could not find patch set metadata or patch metadata for (inserted) patch set path: ".concat(moduleFileOrPatchSetPath));
|
|
8060
|
+
}
|
|
8061
|
+
|
|
8062
|
+
// 3) delete old metadata
|
|
8063
|
+
if (moduleFileOrPatchSetPath !== newPatchSetPath) {
|
|
8064
|
+
delete this.patchSetMetadata[moduleFileOrPatchSetPath];
|
|
8065
|
+
}
|
|
8066
|
+
}
|
|
8067
|
+
|
|
8068
|
+
// Insert new metadata
|
|
8069
|
+
if (!this.patchSetMetadata[newPatchSetPath]) {
|
|
8070
|
+
this.patchSetMetadata[newPatchSetPath] = {
|
|
8071
|
+
moduleFilePath: moduleFilePath,
|
|
8072
|
+
patchPath: affectsPatchPath,
|
|
8073
|
+
patches: [],
|
|
8074
|
+
authors: [],
|
|
8075
|
+
opTypes: [],
|
|
8076
|
+
schemaTypes: schemaTypes,
|
|
8077
|
+
lastUpdated: createdAt,
|
|
8078
|
+
lastUpdatedBy: author
|
|
8079
|
+
};
|
|
8080
|
+
}
|
|
8081
|
+
if (author !== null && !this.patchSetMetadata[newPatchSetPath].authors.includes(author)) {
|
|
8082
|
+
this.patchSetMetadata[newPatchSetPath].authors.unshift(author);
|
|
8083
|
+
}
|
|
8084
|
+
this.patchSetMetadata[newPatchSetPath].lastUpdatedBy = author;
|
|
8085
|
+
this.patchSetMetadata[newPatchSetPath].lastUpdated = createdAt;
|
|
8086
|
+
if (!this.patchSetMetadata[newPatchSetPath].opTypes.includes(opType)) {
|
|
8087
|
+
this.patchSetMetadata[newPatchSetPath].opTypes.unshift(opType);
|
|
8088
|
+
}
|
|
8089
|
+
this.patchSetMetadata[newPatchSetPath].patches.unshift({
|
|
8090
|
+
patchPath: opPath,
|
|
8091
|
+
patchId: patchId,
|
|
8092
|
+
author: author,
|
|
8093
|
+
createdAt: createdAt,
|
|
8094
|
+
opType: opType,
|
|
8095
|
+
schemaTypes: schemaTypes
|
|
8096
|
+
});
|
|
8097
|
+
if (!this.orderedInsertKeys.includes(newPatchSetPath)) {
|
|
8098
|
+
this.orderedInsertKeys.unshift(newPatchSetPath);
|
|
8099
|
+
}
|
|
8100
|
+
}
|
|
8101
|
+
|
|
8102
|
+
/**
|
|
8103
|
+
* Insert a whole patch.
|
|
8104
|
+
*
|
|
8105
|
+
* Takes the patch rather than one op because the de-duplication below is
|
|
8106
|
+
* per-*patch*: a patch is either known to this instance or it is not. When this
|
|
8107
|
+
* took a single op, callers looped and every call after the first hit the
|
|
8108
|
+
* `insertedPatches` guard and returned — so only a patch's first op ever reached
|
|
8109
|
+
* a patch set. A patch that touched two places (a `move`, or a `file` op sitting
|
|
8110
|
+
* before its source op) was therefore mis-grouped, which is invisible in the
|
|
8111
|
+
* compare view but decides what moves as one.
|
|
8112
|
+
*/
|
|
8113
|
+
}, {
|
|
8114
|
+
key: "insert",
|
|
8115
|
+
value: function insert(moduleFilePath, schema, patch, patchId, createdAt, author) {
|
|
8116
|
+
if (this.insertedPatches.has(patchId)) {
|
|
8117
|
+
return;
|
|
8118
|
+
}
|
|
8119
|
+
// Marked inserted unconditionally, schema or not. An earlier revision of this
|
|
8120
|
+
// fix only marked it once a schema was available, so that a patch grouped
|
|
8121
|
+
// under the whole-module fallback could be re-inserted later with the real
|
|
8122
|
+
// schema. That is no longer this class's problem: `PatchSetChain` invalidates
|
|
8123
|
+
// on `schema:init` and a rebuild calls `reset()`, which clears this set — so
|
|
8124
|
+
// the fallback is already re-derived from scratch when the schema lands, and a
|
|
8125
|
+
// conditional here would only leave the per-patch de-duplication half-applied.
|
|
8126
|
+
this.insertedPatches.add(patchId);
|
|
8127
|
+
var _iterator2 = getSitemapTree._createForOfIteratorHelper(patch),
|
|
8128
|
+
_step2;
|
|
8129
|
+
try {
|
|
8130
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
8131
|
+
var op = _step2.value;
|
|
8132
|
+
this.insertOp(moduleFilePath, schema, op, patchId, createdAt, author);
|
|
8133
|
+
}
|
|
8134
|
+
} catch (err) {
|
|
8135
|
+
_iterator2.e(err);
|
|
8136
|
+
} finally {
|
|
8137
|
+
_iterator2.f();
|
|
8138
|
+
}
|
|
8139
|
+
}
|
|
8140
|
+
}, {
|
|
8141
|
+
key: "insertOp",
|
|
8142
|
+
value: function insertOp(moduleFilePath, schema, op, patchId, createdAt, author) {
|
|
8143
|
+
if (!schema) {
|
|
8144
|
+
this.insertPath(moduleFilePath, [], patchId, createdAt, author, op.op, [], op.path);
|
|
8145
|
+
return;
|
|
8146
|
+
}
|
|
8147
|
+
if (op.op === "file" || op.op === "test") {
|
|
8148
|
+
return;
|
|
8149
|
+
}
|
|
8150
|
+
try {
|
|
8151
|
+
if (op.op === "replace") {
|
|
8152
|
+
var schemaTypesAtPath = schemaTypesOfPath(schema, op.path);
|
|
8153
|
+
this.insertPath(moduleFilePath, op.path, patchId, createdAt, author, op.op, Array.from(schemaTypesAtPath), op.path);
|
|
8154
|
+
} else if (op.op === "add" || op.op === "remove" || op.op === "move" || op.op === "copy") {
|
|
8155
|
+
// This is the default case, were we, to be sure, take the parent of the path and as the patch set
|
|
8156
|
+
var path = op.path.slice(0, -1);
|
|
8157
|
+
var _schemaTypesAtPath = schemaTypesOfPath(schema, path);
|
|
8158
|
+
if (_schemaTypesAtPath.size === 1 && _schemaTypesAtPath.has("array")) {
|
|
8159
|
+
// for arrays we would need a lot of logic to create a patch set that is not on the entire parent so for now we do just that
|
|
8160
|
+
this.insertPath(moduleFilePath, path, patchId, createdAt, author, op.op, Array.from(_schemaTypesAtPath), op.path);
|
|
8161
|
+
if (op.op === "move" || op.op === "copy") {
|
|
8162
|
+
// `copy` as well as `move`: it does not write the source, but it
|
|
8163
|
+
// READS it, so the value it produces depends on every pending edit
|
|
8164
|
+
// to that source and on the indices around it.
|
|
8165
|
+
var _path = op.from.slice(0, -1);
|
|
8166
|
+
var _schemaTypesAtPath2 = schemaTypesOfPath(schema, _path);
|
|
8167
|
+
this.insertPath(moduleFilePath, _path, patchId, createdAt, author, op.op, Array.from(_schemaTypesAtPath2), op.path);
|
|
8168
|
+
}
|
|
8169
|
+
} else if (_schemaTypesAtPath.size === 1 && (_schemaTypesAtPath.has("record") ||
|
|
8170
|
+
// An OBJECT is keyed too: its keys are named rather than
|
|
8171
|
+
// positional, so neither `add` (create-or-set, `addToNode` in
|
|
8172
|
+
// `@valbuild/core/patch`) nor `remove` (delete the property)
|
|
8173
|
+
// disturbs any sibling. Either way the op affects exactly the key
|
|
8174
|
+
// it names and nothing else, which is the property this branch
|
|
8175
|
+
// needs — unlike an array, where both shift every later index.
|
|
8176
|
+
//
|
|
8177
|
+
// The studio emits `add` rather than `replace` here on purpose, so
|
|
8178
|
+
// that the write survives the key having gone away in the meantime:
|
|
8179
|
+
// see `ImageField`'s alt write and
|
|
8180
|
+
// `ModuleGallery.handleAltTextChange`, which both say so.
|
|
8181
|
+
//
|
|
8182
|
+
// That last one is why this branch exists. `s.imagedir()`
|
|
8183
|
+
// serializes as a record whose ITEM is an object, so editing the
|
|
8184
|
+
// alt text of a gallery entry resolves `object` here, hit the throw
|
|
8185
|
+
// below, and terminated the whole media module into one patch set —
|
|
8186
|
+
// once per keystroke. Moving any one change in that module then
|
|
8187
|
+
// dragged every other change in it along, because changes move a
|
|
8188
|
+
// whole patch set at a time.
|
|
8189
|
+
_schemaTypesAtPath.has("object") ||
|
|
8190
|
+
// A settings SECTION is addressed like a record: its keys are
|
|
8191
|
+
// named, and an `add` at ["theme", "accent"] modifies exactly that
|
|
8192
|
+
// one. Without this it fell to the throw below — every settings
|
|
8193
|
+
// edit terminated the whole module into one patch set, which is why
|
|
8194
|
+
// the publish diff said "Settings" where `settingsChangeLabels` has
|
|
8195
|
+
// a name for the field. Both sections write `add` this way; see
|
|
8196
|
+
// `useWriteAssistantSetting`, which has to create an absent section
|
|
8197
|
+
// in a single op.
|
|
8198
|
+
_schemaTypesAtPath.has("settings"))) {
|
|
8199
|
+
// If we know this is a record, we can be more specific and only insert the path that is being modified
|
|
8200
|
+
var _path2 = op.path;
|
|
8201
|
+
var _schemaTypesAtPath3 = schemaTypesOfPath(schema, _path2);
|
|
8202
|
+
this.insertPath(moduleFilePath, _path2, patchId, createdAt, author, op.op, Array.from(_schemaTypesAtPath3), op.path);
|
|
8203
|
+
if (op.op === "move" || op.op === "copy") {
|
|
8204
|
+
// The SOURCE is classified on its own terms, not the
|
|
8205
|
+
// destination's. A move out of an array item shifts every later
|
|
8206
|
+
// index, so that side has to be the array — exactly as the branch
|
|
8207
|
+
// above does for a move whose destination is an array. Only when
|
|
8208
|
+
// the source parent is keyed too does `op.from` name the whole of
|
|
8209
|
+
// what the op affects.
|
|
8210
|
+
//
|
|
8211
|
+
// `copy` reaches here as well as `move`. It does not write the
|
|
8212
|
+
// source, but the value it produces is read from it, so it depends
|
|
8213
|
+
// on every pending edit to that source just as a move does.
|
|
8214
|
+
// Duplicating a record entry (`useDuplicateRecordEntry`) is
|
|
8215
|
+
// the copy that actually ships, and its source went ungrouped.
|
|
8216
|
+
var fromParent = op.from.slice(0, -1);
|
|
8217
|
+
var fromParentTypes = schemaTypesOfPath(schema, fromParent);
|
|
8218
|
+
// ANY possible array parent widens, rather than only an
|
|
8219
|
+
// unambiguous one: a discriminated union resolves to every
|
|
8220
|
+
// variant's type at once, so a source inside one can be an array
|
|
8221
|
+
// here and an object there. Requiring a single type grouped it at
|
|
8222
|
+
// the item, which is wrong the moment the array variant is the
|
|
8223
|
+
// live one — and the whole array is the safe direction.
|
|
8224
|
+
var isPositionalSource = fromParentTypes.has("array");
|
|
8225
|
+
var _path3 = isPositionalSource ? fromParent : op.from;
|
|
8226
|
+
var _schemaTypesAtPath4 = schemaTypesOfPath(schema, _path3);
|
|
8227
|
+
this.insertPath(moduleFilePath, _path3, patchId, createdAt, author, op.op, Array.from(_schemaTypesAtPath4), op.path);
|
|
8228
|
+
}
|
|
8229
|
+
} else if (_schemaTypesAtPath.size === 1 && !(_schemaTypesAtPath.has("image") || _schemaTypesAtPath.has("file"))) {
|
|
8230
|
+
// What is left is a parent this function cannot isolate a key
|
|
8231
|
+
// inside. Two different reasons end up here, and the message covers
|
|
8232
|
+
// both: a PRIMITIVE cannot hold the key at all, which means the path
|
|
8233
|
+
// no longer fits the schema — a genuinely stale patch; and `richtext`
|
|
8234
|
+
// can, but its children are positional, so isolating one would let a
|
|
8235
|
+
// node insert be moved without the edits whose indices it shifted.
|
|
8236
|
+
// Both keep reporting, and the catch below terminates the module,
|
|
8237
|
+
// which is the conservative thing to do when we cannot say what a
|
|
8238
|
+
// change affects.
|
|
8239
|
+
throw new Error("Cannot isolate a patch set for op: '".concat(op.op, "' \u2014 no addressable key inside schema type: ").concat(_schemaTypesAtPath.values().next().value));
|
|
8240
|
+
} else {
|
|
8241
|
+
// we cannot really know if this is a record or array so the entire module is the patch set
|
|
8242
|
+
this.insertPath(moduleFilePath, path, patchId, createdAt, author, op.op, [schema.type], op.path);
|
|
8243
|
+
}
|
|
8244
|
+
} else {
|
|
8245
|
+
var _unreachable = op;
|
|
8246
|
+
throw new Error("Unreachable op: " + _unreachable);
|
|
8247
|
+
}
|
|
8248
|
+
} catch (e) {
|
|
8249
|
+
// We might be in this situation if the schema changes, etc etc:
|
|
8250
|
+
if (e instanceof Error) {
|
|
8251
|
+
console.error("Could not resolve path while creating patch set", e.message);
|
|
8252
|
+
} else {
|
|
8253
|
+
console.error("Could not resolve path while creating patch set", e);
|
|
8254
|
+
}
|
|
8255
|
+
// "terminate" the entire module file path (i.e. all patches are their own patch set)
|
|
8256
|
+
this.insertPath(moduleFilePath, [], patchId, createdAt, author, op.op, [schema.type], op.path);
|
|
8257
|
+
}
|
|
8258
|
+
}
|
|
8259
|
+
}, {
|
|
8260
|
+
key: "isInserted",
|
|
8261
|
+
value: function isInserted(patchId) {
|
|
8262
|
+
return this.insertedPatches.has(patchId);
|
|
8263
|
+
}
|
|
8264
|
+
}, {
|
|
8265
|
+
key: "serialize",
|
|
8266
|
+
value: function serialize() {
|
|
8267
|
+
var _this = this;
|
|
8268
|
+
return this.orderedInsertKeys.map(function (key) {
|
|
8269
|
+
if (key in _this.patchSetMetadata) {
|
|
8270
|
+
return _this.patchSetMetadata[key];
|
|
8271
|
+
} else {
|
|
8272
|
+
throw new Error("Could not find patch set metadata or patch metadata for (inserted) patch set path: ".concat(key));
|
|
8273
|
+
}
|
|
8274
|
+
});
|
|
8275
|
+
}
|
|
8276
|
+
}]);
|
|
8277
|
+
}();
|
|
8278
|
+
|
|
8279
|
+
/**
|
|
8280
|
+
* Update from the site, for a proposal with code (valbuild/home
|
|
8281
|
+
* `docs/hosted-publishing.md` step 8.2, slice 1b): what content hands over,
|
|
8282
|
+
* what the builder tab makes of it, and what Val's server reads -- one
|
|
8283
|
+
* definition of each for the three.
|
|
8284
|
+
*/
|
|
8285
|
+
|
|
8286
|
+
/** Content a schema does not allow, by path in the module. */
|
|
8287
|
+
|
|
8288
|
+
/** Content's `merge-trees` answer. */
|
|
8289
|
+
|
|
8290
|
+
/** Which tree: where the proposal started, the site, or the proposal. */
|
|
8291
|
+
|
|
8292
|
+
/** A module, as evaluating its tree in the tab gave it. */
|
|
8293
|
+
|
|
8294
|
+
/** A side's files: the site's tree, the base's changes over it, the proposal's over that. */
|
|
8295
|
+
function sideFiles(trees, side) {
|
|
8296
|
+
var layers = side === "site" ? [] : side === "base" ? [trees.trees.base] : [trees.trees.base, trees.trees.proposal];
|
|
8297
|
+
var files = getSitemapTree._objectSpread2({}, trees.trees.site);
|
|
8298
|
+
for (var _i = 0, _layers = layers; _i < _layers.length; _i++) {
|
|
8299
|
+
var layer = _layers[_i];
|
|
8300
|
+
for (var _i2 = 0, _Object$entries = Object.entries(layer); _i2 < _Object$entries.length; _i2++) {
|
|
8301
|
+
var _Object$entries$_i = _slicedToArray(_Object$entries[_i2], 2),
|
|
8302
|
+
path = _Object$entries$_i[0],
|
|
8303
|
+
text = _Object$entries$_i[1];
|
|
8304
|
+
if (text === null) delete files[path];else files[path] = text;
|
|
8305
|
+
}
|
|
8306
|
+
}
|
|
8307
|
+
return files;
|
|
8308
|
+
}
|
|
8309
|
+
|
|
8310
|
+
/** A side's Source of a module, from content's index; `null` when it has none. */
|
|
8311
|
+
function sideSource(trees, side, moduleFilePath) {
|
|
8312
|
+
var _trees$modules$module, _trees$modules$module2, _trees$sources$sha;
|
|
8313
|
+
var sha = (_trees$modules$module = (_trees$modules$module2 = trees.modules[moduleFilePath]) === null || _trees$modules$module2 === void 0 ? void 0 : _trees$modules$module2[side]) !== null && _trees$modules$module !== void 0 ? _trees$modules$module : null;
|
|
8314
|
+
return sha === null ? null : (_trees$sources$sha = trees.sources[sha]) !== null && _trees$sources$sha !== void 0 ? _trees$sources$sha : null;
|
|
8315
|
+
}
|
|
8316
|
+
|
|
8317
|
+
/**
|
|
8318
|
+
* What a schema reports about this content, without the errors the server
|
|
8319
|
+
* fixes on its own (those with `fixes`): run on the schema instance that
|
|
8320
|
+
* evaluating the module made, so custom rules take part.
|
|
8321
|
+
*/
|
|
8322
|
+
function schemaErrorsOf(schema, moduleFilePath, source) {
|
|
8323
|
+
var res = schema["executeValidate"](moduleFilePath, source);
|
|
8324
|
+
if (res === false) return [];
|
|
8325
|
+
var errors = [];
|
|
8326
|
+
for (var _i3 = 0, _Object$entries2 = Object.entries(res); _i3 < _Object$entries2.length; _i3++) {
|
|
8327
|
+
var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i3], 2),
|
|
8328
|
+
sourcePath = _Object$entries2$_i[0],
|
|
8329
|
+
list = _Object$entries2$_i[1];
|
|
8330
|
+
var _Internal$splitModule = core.Internal.splitModuleFilePathAndModulePath(sourcePath),
|
|
8331
|
+
_Internal$splitModule2 = _slicedToArray(_Internal$splitModule, 2),
|
|
8332
|
+
modulePath = _Internal$splitModule2[1];
|
|
8333
|
+
var path = modulePath ? core.Internal.createPatchPath(modulePath) : [];
|
|
8334
|
+
var _iterator = getSitemapTree._createForOfIteratorHelper(list),
|
|
8335
|
+
_step;
|
|
8336
|
+
try {
|
|
8337
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
8338
|
+
var error = _step.value;
|
|
8339
|
+
if (error.fixes && error.fixes.length > 0) continue;
|
|
8340
|
+
errors.push({
|
|
8341
|
+
path: path,
|
|
8342
|
+
message: error.message
|
|
8343
|
+
});
|
|
8344
|
+
}
|
|
8345
|
+
} catch (err) {
|
|
8346
|
+
_iterator.e(err);
|
|
8347
|
+
} finally {
|
|
8348
|
+
_iterator.f();
|
|
8349
|
+
}
|
|
8350
|
+
}
|
|
8351
|
+
return errors;
|
|
8352
|
+
}
|
|
8353
|
+
|
|
8091
8354
|
exports.DEFAULT_CANVAS_SELECTION = getSitemapTree.DEFAULT_CANVAS_SELECTION;
|
|
8092
8355
|
exports.DEFAULT_CANVAS_SELECTION_SOFT = getSitemapTree.DEFAULT_CANVAS_SELECTION_SOFT;
|
|
8093
8356
|
exports.VAL_AI_SESSION_STORAGE_KEY = getSitemapTree.VAL_AI_SESSION_STORAGE_KEY;
|
|
@@ -8131,9 +8394,9 @@ exports.NEVER_ENCODED = NEVER_ENCODED;
|
|
|
8131
8394
|
exports.ParentRef = ParentRef$1;
|
|
8132
8395
|
exports.Patch = Patch;
|
|
8133
8396
|
exports.PatchBlock = PatchBlock;
|
|
8134
|
-
exports.PatchGroup = PatchGroup;
|
|
8135
8397
|
exports.PatchId = PatchId;
|
|
8136
8398
|
exports.PatchJSON = PatchJSON;
|
|
8399
|
+
exports.PatchSets = PatchSets;
|
|
8137
8400
|
exports.PlanRefusalError = PlanRefusalError;
|
|
8138
8401
|
exports.PublishProtocolError = PublishProtocolError;
|
|
8139
8402
|
exports.RAMP_STEPS = RAMP_STEPS;
|
|
@@ -8218,6 +8481,7 @@ exports.getRoutesOf = getRoutesOf;
|
|
|
8218
8481
|
exports.getRoutesWithModulePaths = getRoutesWithModulePaths;
|
|
8219
8482
|
exports.getSourceAt = getSourceAt;
|
|
8220
8483
|
exports.indexModule = indexModule;
|
|
8484
|
+
exports.isInsidePatchSetPath = isInsidePatchSetPath;
|
|
8221
8485
|
exports.isMimeTypeAccepted = isMimeTypeAccepted;
|
|
8222
8486
|
exports.isRemoteSchema = isRemoteSchema;
|
|
8223
8487
|
exports.isSchemaSourceFixError = isSchemaSourceFixError;
|
|
@@ -8257,6 +8521,10 @@ exports.resolveSerializedSchemaAtPath = resolveSerializedSchemaAtPath;
|
|
|
8257
8521
|
exports.richTextImageSchema = richTextImageSchema;
|
|
8258
8522
|
exports.richTextToRemirror = richTextToRemirror;
|
|
8259
8523
|
exports.safeParsePatch = safeParsePatch;
|
|
8524
|
+
exports.schemaErrorsOf = schemaErrorsOf;
|
|
8525
|
+
exports.schemaTypesOfPath = schemaTypesOfPath;
|
|
8526
|
+
exports.sideFiles = sideFiles;
|
|
8527
|
+
exports.sideSource = sideSource;
|
|
8260
8528
|
exports.sourcePathOfChild = sourcePathOfChild;
|
|
8261
8529
|
exports.themeCustomProperties = themeCustomProperties;
|
|
8262
8530
|
exports.toolNames = toolNames;
|