sanity 5.7.0-next.24 → 5.7.0-next.25

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,4 +1,4 @@
1
- var version = "5.7.0-next.24+1af0e35075", peerDependencies = {
1
+ var version = "5.7.0-next.25+d517d2afdc", peerDependencies = {
2
2
  "styled-components": "^6.1.15"
3
3
  };
4
4
  export {
@@ -7,7 +7,7 @@ try {
7
7
  try {
8
8
  buildVersion = buildVersion || // This is replaced by `@sanity/pkg-utils` at build time
9
9
  // and must always be references by its full static name, e.g. no optional chaining, no `if (process && process.env)` etc.
10
- "5.7.0-next.24+1af0e35075";
10
+ "5.7.0-next.25+d517d2afdc";
11
11
  } catch {
12
12
  }
13
13
  const SANITY_VERSION = buildVersion || `${version}-dev`;
package/lib/index.js CHANGED
@@ -10698,7 +10698,8 @@ const documentRevisionCache = /* @__PURE__ */ Object.create(null);
10698
10698
  function getDocumentAtRevision({
10699
10699
  client,
10700
10700
  documentId,
10701
- revisionId
10701
+ revisionId,
10702
+ time
10702
10703
  }) {
10703
10704
  if (revisionId === HISTORY_CLEARED_EVENT_ID)
10704
10705
  return of({
@@ -10706,23 +10707,34 @@ function getDocumentAtRevision({
10706
10707
  loading: !1,
10707
10708
  revisionId
10708
10709
  });
10709
- const cacheKey = `${documentId}@${revisionId}`, dataset = client.config().dataset;
10710
- return documentRevisionCache[cacheKey] || (documentRevisionCache[cacheKey] = client.observable.request({
10711
- url: `/data/history/${dataset}/documents/${documentId}?revision=${revisionId}`,
10712
- tag: "get-document-revision"
10713
- }).pipe(map((response) => ({
10714
- document: response.documents[0],
10715
- loading: !1,
10716
- revisionId
10717
- })), catchError((error) => (console.error("Error fetching document at revision", error), [{
10718
- document: null,
10719
- loading: !1,
10720
- revisionId
10721
- }])), startWith({
10722
- document: null,
10723
- loading: !0,
10724
- revisionId
10725
- }), shareReplay(1))), documentRevisionCache[cacheKey];
10710
+ const cacheKey = `${documentId}@${revisionId ? ["revisionId", revisionId].join(".") : ["time", time].join(".")}`, dataset = client.config().dataset;
10711
+ if (!documentRevisionCache[cacheKey]) {
10712
+ const searchParams = new URLSearchParams(typeof revisionId == "string" ? {
10713
+ revision: revisionId
10714
+ } : {
10715
+ time
10716
+ });
10717
+ documentRevisionCache[cacheKey] = client.observable.request({
10718
+ url: `/data/history/${dataset}/documents/${documentId}?${searchParams}`,
10719
+ tag: "get-document-revision"
10720
+ }).pipe(map((response) => {
10721
+ const document2 = response.documents[0];
10722
+ return {
10723
+ document: document2,
10724
+ loading: !1,
10725
+ revisionId: document2._rev
10726
+ };
10727
+ }), catchError((error) => (console.error("Error fetching document at revision", error), [{
10728
+ document: null,
10729
+ loading: !1,
10730
+ revisionId
10731
+ }])), startWith({
10732
+ document: null,
10733
+ loading: !0,
10734
+ revisionId
10735
+ }), shareReplay(1));
10736
+ }
10737
+ return documentRevisionCache[cacheKey];
10726
10738
  }
10727
10739
  const INITIAL_VALUE$4 = {
10728
10740
  events: [],