@weatherboard/cms 0.1.0 → 0.3.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/README.md +122 -0
- package/dist/contracts/query.d.cts +1 -0
- package/dist/contracts/query.d.mts +1 -0
- package/dist/contracts/query.d.ts +1 -0
- package/dist/contracts/text.d.cts +26 -1
- package/dist/contracts/text.d.mts +26 -1
- package/dist/contracts/text.d.ts +26 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +3 -3
- package/dist/next.cjs +1 -1
- package/dist/next.cjs.map +3 -3
- package/dist/next.mjs +1 -1
- package/dist/next.mjs.map +3 -3
- package/dist/portable/sections.d.cts +136 -0
- package/dist/portable/sections.d.mts +136 -0
- package/dist/portable/sections.d.ts +136 -0
- package/dist/portable/site-content.d.cts +13 -0
- package/dist/portable/site-content.d.mts +13 -0
- package/dist/portable/site-content.d.ts +13 -0
- package/dist/runtime/reader.d.cts +3 -1
- package/dist/runtime/reader.d.mts +3 -1
- package/dist/runtime/reader.d.ts +3 -1
- package/dist/sanity.cjs +1 -1
- package/dist/sanity.cjs.map +2 -2
- package/dist/sanity.mjs +1 -1
- package/dist/sanity.mjs.map +2 -2
- package/dist/server.cjs +1 -1
- package/dist/server.cjs.map +3 -3
- package/dist/server.mjs +1 -1
- package/dist/server.mjs.map +3 -3
- package/dist/site-content.cjs +3 -3
- package/dist/site-content.cjs.map +4 -4
- package/dist/site-content.d.cts +4 -0
- package/dist/site-content.d.mts +4 -0
- package/dist/site-content.d.ts +4 -0
- package/dist/site-content.mjs +3 -3
- package/dist/site-content.mjs.map +4 -4
- package/package.json +34 -5
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A-1915 (A-1739 M1c). The reader's half of the shared section set that
|
|
3
|
+
* `@weatherboard/sanity-schema-base` declares in `src/sections.ts` (A-1889):
|
|
4
|
+
* `page.sections[]`, drawn from the four home section types plus
|
|
5
|
+
* `textMediaBlock`, `faqBlock` (items `faqItem`), `galleryBlock` and
|
|
6
|
+
* `contactBlock`.
|
|
7
|
+
*
|
|
8
|
+
* ===========================================================================
|
|
9
|
+
* LAYOUTS ARE THE A-1876 VARIANT NAMES, EXACTLY
|
|
10
|
+
* ===========================================================================
|
|
11
|
+
*
|
|
12
|
+
* The three lists below are the composition variant names, spelled as A-1876
|
|
13
|
+
* spells them, so a contract test can import them and compare them with the
|
|
14
|
+
* UI package's. A missing or unknown stored `layout` resolves to the
|
|
15
|
+
* composition's default and records `section.layout.defaulted`, the rule cms
|
|
16
|
+
* 0.2.0 set for `siteHero.layout`. It never throws and never yields an empty
|
|
17
|
+
* section.
|
|
18
|
+
*
|
|
19
|
+
* ===========================================================================
|
|
20
|
+
* WARNINGS, NOT REFUSALS, FOR THREE THINGS
|
|
21
|
+
* ===========================================================================
|
|
22
|
+
*
|
|
23
|
+
* The rest of this reader refuses a malformed document by name. Three things
|
|
24
|
+
* in a section are warnings instead, each recorded with its path:
|
|
25
|
+
*
|
|
26
|
+
* section.layout.defaulted missing or unknown layout: the default renders
|
|
27
|
+
* section.type.unknown a section `_type` this reader does not know is
|
|
28
|
+
* skipped, so a newer model never breaks a page
|
|
29
|
+
* section.image.missing-alt an image without alt text is DROPPED, never
|
|
30
|
+
* rendered without it
|
|
31
|
+
* section.image.missing-asset an image with no uploaded asset is dropped
|
|
32
|
+
* section.empty.skipped a section left with nothing to show (a gallery
|
|
33
|
+
* whose every photo was dropped, a contact
|
|
34
|
+
* section switched off and empty) is skipped
|
|
35
|
+
*/
|
|
36
|
+
import type { ActionInput, CompositionBlockInput, CopyInput } from "./site-content.cjs";
|
|
37
|
+
/** `Split`: text with media. */
|
|
38
|
+
export declare const SPLIT_LAYOUTS: readonly ["media-end", "media-start", "media-below"];
|
|
39
|
+
/** `HeadingList`: a heading column and a list column. */
|
|
40
|
+
export declare const HEADING_LIST_LAYOUTS: readonly ["beside", "stacked"];
|
|
41
|
+
/** `StaggerRow`: a row of two to four items. */
|
|
42
|
+
export declare const STAGGER_ROW_LAYOUTS: readonly ["staggered", "aligned"];
|
|
43
|
+
export type SplitLayout = (typeof SPLIT_LAYOUTS)[number];
|
|
44
|
+
export type HeadingListLayout = (typeof HEADING_LIST_LAYOUTS)[number];
|
|
45
|
+
export type StaggerRowLayout = (typeof STAGGER_ROW_LAYOUTS)[number];
|
|
46
|
+
/** What a missing or unknown `layout` resolves to, per composition. */
|
|
47
|
+
export declare const SECTION_LAYOUT_DEFAULTS: {
|
|
48
|
+
readonly Split: "media-end";
|
|
49
|
+
readonly HeadingList: "beside";
|
|
50
|
+
readonly StaggerRow: "staggered";
|
|
51
|
+
};
|
|
52
|
+
/** Sanity `_type` on the left, the reader's `kind` on the right; the same rows as schema-base's `SECTION_CONTRACTS`. */
|
|
53
|
+
export declare const READER_SECTION_KINDS: {
|
|
54
|
+
readonly featureStoriesBlock: "feature_stories";
|
|
55
|
+
readonly surfaceCardBlock: "cta";
|
|
56
|
+
readonly accentBandBlock: "accent_band";
|
|
57
|
+
readonly locationsBlock: "locations";
|
|
58
|
+
readonly textMediaBlock: "text_media";
|
|
59
|
+
readonly faqBlock: "faq";
|
|
60
|
+
readonly galleryBlock: "gallery";
|
|
61
|
+
readonly contactBlock: "contact";
|
|
62
|
+
};
|
|
63
|
+
/** A gallery is a `StaggerRow`, which holds two to four items. */
|
|
64
|
+
export declare const READER_GALLERY_PHOTO_MIN = 2;
|
|
65
|
+
export declare const READER_GALLERY_PHOTO_LIMIT = 4;
|
|
66
|
+
export declare const SECTION_WARNINGS: {
|
|
67
|
+
readonly layoutDefaulted: "section.layout.defaulted";
|
|
68
|
+
readonly unknownType: "section.type.unknown";
|
|
69
|
+
readonly imageMissingAlt: "section.image.missing-alt";
|
|
70
|
+
readonly imageMissingAsset: "section.image.missing-asset";
|
|
71
|
+
readonly emptySkipped: "section.empty.skipped";
|
|
72
|
+
};
|
|
73
|
+
export type SectionWarningCode = (typeof SECTION_WARNINGS)[keyof typeof SECTION_WARNINGS];
|
|
74
|
+
/** A named warning and the path in the stored document it is about. Never copy. */
|
|
75
|
+
export type SectionWarning = {
|
|
76
|
+
readonly code: SectionWarningCode;
|
|
77
|
+
readonly where: string;
|
|
78
|
+
};
|
|
79
|
+
/** A Sanity image as a site needs it. `asset` is the image asset's id; `alt` is never empty. */
|
|
80
|
+
export type SectionImageInput = {
|
|
81
|
+
readonly asset: string;
|
|
82
|
+
readonly alt: string;
|
|
83
|
+
readonly caption: string | null;
|
|
84
|
+
readonly hotspot: {
|
|
85
|
+
readonly x: number;
|
|
86
|
+
readonly y: number;
|
|
87
|
+
} | null;
|
|
88
|
+
};
|
|
89
|
+
export type TextMediaSectionInput = {
|
|
90
|
+
readonly kind: "text_media";
|
|
91
|
+
readonly anchor: string | null;
|
|
92
|
+
readonly layout: SplitLayout;
|
|
93
|
+
readonly heading: CopyInput;
|
|
94
|
+
readonly tail: CopyInput | null;
|
|
95
|
+
readonly body: CopyInput;
|
|
96
|
+
readonly action: ActionInput | null;
|
|
97
|
+
/** `null` only when the stored photo was dropped (no alt text or no asset); a warning names it. */
|
|
98
|
+
readonly image: SectionImageInput | null;
|
|
99
|
+
};
|
|
100
|
+
export type FaqSectionInput = {
|
|
101
|
+
readonly kind: "faq";
|
|
102
|
+
readonly anchor: string | null;
|
|
103
|
+
readonly layout: HeadingListLayout;
|
|
104
|
+
readonly heading: CopyInput;
|
|
105
|
+
readonly tail: CopyInput | null;
|
|
106
|
+
readonly intro: CopyInput | null;
|
|
107
|
+
readonly items: readonly {
|
|
108
|
+
readonly question: CopyInput;
|
|
109
|
+
readonly answer: CopyInput;
|
|
110
|
+
}[];
|
|
111
|
+
};
|
|
112
|
+
export type GallerySectionInput = {
|
|
113
|
+
readonly kind: "gallery";
|
|
114
|
+
readonly anchor: string | null;
|
|
115
|
+
readonly layout: StaggerRowLayout;
|
|
116
|
+
readonly heading: CopyInput | null;
|
|
117
|
+
readonly images: readonly SectionImageInput[];
|
|
118
|
+
};
|
|
119
|
+
export type ContactSectionInput = {
|
|
120
|
+
readonly kind: "contact";
|
|
121
|
+
readonly anchor: string | null;
|
|
122
|
+
readonly layout: SplitLayout;
|
|
123
|
+
readonly heading: CopyInput;
|
|
124
|
+
readonly body: CopyInput | null;
|
|
125
|
+
/** Show the site settings' email address. */
|
|
126
|
+
readonly showEmail: boolean;
|
|
127
|
+
/** Show the site settings' phone number. */
|
|
128
|
+
readonly showPhone: boolean;
|
|
129
|
+
readonly action: ActionInput | null;
|
|
130
|
+
readonly image: SectionImageInput | null;
|
|
131
|
+
};
|
|
132
|
+
export type NewSectionInput = TextMediaSectionInput | FaqSectionInput | GallerySectionInput | ContactSectionInput;
|
|
133
|
+
/** One entry of `PageContent.sections`: a home section kind or one of the new kinds. */
|
|
134
|
+
export type PageSectionInput = Exclude<CompositionBlockInput, {
|
|
135
|
+
readonly kind: "campaign";
|
|
136
|
+
}> | NewSectionInput;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A-1915 (A-1739 M1c). The reader's half of the shared section set that
|
|
3
|
+
* `@weatherboard/sanity-schema-base` declares in `src/sections.ts` (A-1889):
|
|
4
|
+
* `page.sections[]`, drawn from the four home section types plus
|
|
5
|
+
* `textMediaBlock`, `faqBlock` (items `faqItem`), `galleryBlock` and
|
|
6
|
+
* `contactBlock`.
|
|
7
|
+
*
|
|
8
|
+
* ===========================================================================
|
|
9
|
+
* LAYOUTS ARE THE A-1876 VARIANT NAMES, EXACTLY
|
|
10
|
+
* ===========================================================================
|
|
11
|
+
*
|
|
12
|
+
* The three lists below are the composition variant names, spelled as A-1876
|
|
13
|
+
* spells them, so a contract test can import them and compare them with the
|
|
14
|
+
* UI package's. A missing or unknown stored `layout` resolves to the
|
|
15
|
+
* composition's default and records `section.layout.defaulted`, the rule cms
|
|
16
|
+
* 0.2.0 set for `siteHero.layout`. It never throws and never yields an empty
|
|
17
|
+
* section.
|
|
18
|
+
*
|
|
19
|
+
* ===========================================================================
|
|
20
|
+
* WARNINGS, NOT REFUSALS, FOR THREE THINGS
|
|
21
|
+
* ===========================================================================
|
|
22
|
+
*
|
|
23
|
+
* The rest of this reader refuses a malformed document by name. Three things
|
|
24
|
+
* in a section are warnings instead, each recorded with its path:
|
|
25
|
+
*
|
|
26
|
+
* section.layout.defaulted missing or unknown layout: the default renders
|
|
27
|
+
* section.type.unknown a section `_type` this reader does not know is
|
|
28
|
+
* skipped, so a newer model never breaks a page
|
|
29
|
+
* section.image.missing-alt an image without alt text is DROPPED, never
|
|
30
|
+
* rendered without it
|
|
31
|
+
* section.image.missing-asset an image with no uploaded asset is dropped
|
|
32
|
+
* section.empty.skipped a section left with nothing to show (a gallery
|
|
33
|
+
* whose every photo was dropped, a contact
|
|
34
|
+
* section switched off and empty) is skipped
|
|
35
|
+
*/
|
|
36
|
+
import type { ActionInput, CompositionBlockInput, CopyInput } from "./site-content.mjs";
|
|
37
|
+
/** `Split`: text with media. */
|
|
38
|
+
export declare const SPLIT_LAYOUTS: readonly ["media-end", "media-start", "media-below"];
|
|
39
|
+
/** `HeadingList`: a heading column and a list column. */
|
|
40
|
+
export declare const HEADING_LIST_LAYOUTS: readonly ["beside", "stacked"];
|
|
41
|
+
/** `StaggerRow`: a row of two to four items. */
|
|
42
|
+
export declare const STAGGER_ROW_LAYOUTS: readonly ["staggered", "aligned"];
|
|
43
|
+
export type SplitLayout = (typeof SPLIT_LAYOUTS)[number];
|
|
44
|
+
export type HeadingListLayout = (typeof HEADING_LIST_LAYOUTS)[number];
|
|
45
|
+
export type StaggerRowLayout = (typeof STAGGER_ROW_LAYOUTS)[number];
|
|
46
|
+
/** What a missing or unknown `layout` resolves to, per composition. */
|
|
47
|
+
export declare const SECTION_LAYOUT_DEFAULTS: {
|
|
48
|
+
readonly Split: "media-end";
|
|
49
|
+
readonly HeadingList: "beside";
|
|
50
|
+
readonly StaggerRow: "staggered";
|
|
51
|
+
};
|
|
52
|
+
/** Sanity `_type` on the left, the reader's `kind` on the right; the same rows as schema-base's `SECTION_CONTRACTS`. */
|
|
53
|
+
export declare const READER_SECTION_KINDS: {
|
|
54
|
+
readonly featureStoriesBlock: "feature_stories";
|
|
55
|
+
readonly surfaceCardBlock: "cta";
|
|
56
|
+
readonly accentBandBlock: "accent_band";
|
|
57
|
+
readonly locationsBlock: "locations";
|
|
58
|
+
readonly textMediaBlock: "text_media";
|
|
59
|
+
readonly faqBlock: "faq";
|
|
60
|
+
readonly galleryBlock: "gallery";
|
|
61
|
+
readonly contactBlock: "contact";
|
|
62
|
+
};
|
|
63
|
+
/** A gallery is a `StaggerRow`, which holds two to four items. */
|
|
64
|
+
export declare const READER_GALLERY_PHOTO_MIN = 2;
|
|
65
|
+
export declare const READER_GALLERY_PHOTO_LIMIT = 4;
|
|
66
|
+
export declare const SECTION_WARNINGS: {
|
|
67
|
+
readonly layoutDefaulted: "section.layout.defaulted";
|
|
68
|
+
readonly unknownType: "section.type.unknown";
|
|
69
|
+
readonly imageMissingAlt: "section.image.missing-alt";
|
|
70
|
+
readonly imageMissingAsset: "section.image.missing-asset";
|
|
71
|
+
readonly emptySkipped: "section.empty.skipped";
|
|
72
|
+
};
|
|
73
|
+
export type SectionWarningCode = (typeof SECTION_WARNINGS)[keyof typeof SECTION_WARNINGS];
|
|
74
|
+
/** A named warning and the path in the stored document it is about. Never copy. */
|
|
75
|
+
export type SectionWarning = {
|
|
76
|
+
readonly code: SectionWarningCode;
|
|
77
|
+
readonly where: string;
|
|
78
|
+
};
|
|
79
|
+
/** A Sanity image as a site needs it. `asset` is the image asset's id; `alt` is never empty. */
|
|
80
|
+
export type SectionImageInput = {
|
|
81
|
+
readonly asset: string;
|
|
82
|
+
readonly alt: string;
|
|
83
|
+
readonly caption: string | null;
|
|
84
|
+
readonly hotspot: {
|
|
85
|
+
readonly x: number;
|
|
86
|
+
readonly y: number;
|
|
87
|
+
} | null;
|
|
88
|
+
};
|
|
89
|
+
export type TextMediaSectionInput = {
|
|
90
|
+
readonly kind: "text_media";
|
|
91
|
+
readonly anchor: string | null;
|
|
92
|
+
readonly layout: SplitLayout;
|
|
93
|
+
readonly heading: CopyInput;
|
|
94
|
+
readonly tail: CopyInput | null;
|
|
95
|
+
readonly body: CopyInput;
|
|
96
|
+
readonly action: ActionInput | null;
|
|
97
|
+
/** `null` only when the stored photo was dropped (no alt text or no asset); a warning names it. */
|
|
98
|
+
readonly image: SectionImageInput | null;
|
|
99
|
+
};
|
|
100
|
+
export type FaqSectionInput = {
|
|
101
|
+
readonly kind: "faq";
|
|
102
|
+
readonly anchor: string | null;
|
|
103
|
+
readonly layout: HeadingListLayout;
|
|
104
|
+
readonly heading: CopyInput;
|
|
105
|
+
readonly tail: CopyInput | null;
|
|
106
|
+
readonly intro: CopyInput | null;
|
|
107
|
+
readonly items: readonly {
|
|
108
|
+
readonly question: CopyInput;
|
|
109
|
+
readonly answer: CopyInput;
|
|
110
|
+
}[];
|
|
111
|
+
};
|
|
112
|
+
export type GallerySectionInput = {
|
|
113
|
+
readonly kind: "gallery";
|
|
114
|
+
readonly anchor: string | null;
|
|
115
|
+
readonly layout: StaggerRowLayout;
|
|
116
|
+
readonly heading: CopyInput | null;
|
|
117
|
+
readonly images: readonly SectionImageInput[];
|
|
118
|
+
};
|
|
119
|
+
export type ContactSectionInput = {
|
|
120
|
+
readonly kind: "contact";
|
|
121
|
+
readonly anchor: string | null;
|
|
122
|
+
readonly layout: SplitLayout;
|
|
123
|
+
readonly heading: CopyInput;
|
|
124
|
+
readonly body: CopyInput | null;
|
|
125
|
+
/** Show the site settings' email address. */
|
|
126
|
+
readonly showEmail: boolean;
|
|
127
|
+
/** Show the site settings' phone number. */
|
|
128
|
+
readonly showPhone: boolean;
|
|
129
|
+
readonly action: ActionInput | null;
|
|
130
|
+
readonly image: SectionImageInput | null;
|
|
131
|
+
};
|
|
132
|
+
export type NewSectionInput = TextMediaSectionInput | FaqSectionInput | GallerySectionInput | ContactSectionInput;
|
|
133
|
+
/** One entry of `PageContent.sections`: a home section kind or one of the new kinds. */
|
|
134
|
+
export type PageSectionInput = Exclude<CompositionBlockInput, {
|
|
135
|
+
readonly kind: "campaign";
|
|
136
|
+
}> | NewSectionInput;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A-1915 (A-1739 M1c). The reader's half of the shared section set that
|
|
3
|
+
* `@weatherboard/sanity-schema-base` declares in `src/sections.ts` (A-1889):
|
|
4
|
+
* `page.sections[]`, drawn from the four home section types plus
|
|
5
|
+
* `textMediaBlock`, `faqBlock` (items `faqItem`), `galleryBlock` and
|
|
6
|
+
* `contactBlock`.
|
|
7
|
+
*
|
|
8
|
+
* ===========================================================================
|
|
9
|
+
* LAYOUTS ARE THE A-1876 VARIANT NAMES, EXACTLY
|
|
10
|
+
* ===========================================================================
|
|
11
|
+
*
|
|
12
|
+
* The three lists below are the composition variant names, spelled as A-1876
|
|
13
|
+
* spells them, so a contract test can import them and compare them with the
|
|
14
|
+
* UI package's. A missing or unknown stored `layout` resolves to the
|
|
15
|
+
* composition's default and records `section.layout.defaulted`, the rule cms
|
|
16
|
+
* 0.2.0 set for `siteHero.layout`. It never throws and never yields an empty
|
|
17
|
+
* section.
|
|
18
|
+
*
|
|
19
|
+
* ===========================================================================
|
|
20
|
+
* WARNINGS, NOT REFUSALS, FOR THREE THINGS
|
|
21
|
+
* ===========================================================================
|
|
22
|
+
*
|
|
23
|
+
* The rest of this reader refuses a malformed document by name. Three things
|
|
24
|
+
* in a section are warnings instead, each recorded with its path:
|
|
25
|
+
*
|
|
26
|
+
* section.layout.defaulted missing or unknown layout: the default renders
|
|
27
|
+
* section.type.unknown a section `_type` this reader does not know is
|
|
28
|
+
* skipped, so a newer model never breaks a page
|
|
29
|
+
* section.image.missing-alt an image without alt text is DROPPED, never
|
|
30
|
+
* rendered without it
|
|
31
|
+
* section.image.missing-asset an image with no uploaded asset is dropped
|
|
32
|
+
* section.empty.skipped a section left with nothing to show (a gallery
|
|
33
|
+
* whose every photo was dropped, a contact
|
|
34
|
+
* section switched off and empty) is skipped
|
|
35
|
+
*/
|
|
36
|
+
import type { ActionInput, CompositionBlockInput, CopyInput } from "./site-content.js";
|
|
37
|
+
/** `Split`: text with media. */
|
|
38
|
+
export declare const SPLIT_LAYOUTS: readonly ["media-end", "media-start", "media-below"];
|
|
39
|
+
/** `HeadingList`: a heading column and a list column. */
|
|
40
|
+
export declare const HEADING_LIST_LAYOUTS: readonly ["beside", "stacked"];
|
|
41
|
+
/** `StaggerRow`: a row of two to four items. */
|
|
42
|
+
export declare const STAGGER_ROW_LAYOUTS: readonly ["staggered", "aligned"];
|
|
43
|
+
export type SplitLayout = (typeof SPLIT_LAYOUTS)[number];
|
|
44
|
+
export type HeadingListLayout = (typeof HEADING_LIST_LAYOUTS)[number];
|
|
45
|
+
export type StaggerRowLayout = (typeof STAGGER_ROW_LAYOUTS)[number];
|
|
46
|
+
/** What a missing or unknown `layout` resolves to, per composition. */
|
|
47
|
+
export declare const SECTION_LAYOUT_DEFAULTS: {
|
|
48
|
+
readonly Split: "media-end";
|
|
49
|
+
readonly HeadingList: "beside";
|
|
50
|
+
readonly StaggerRow: "staggered";
|
|
51
|
+
};
|
|
52
|
+
/** Sanity `_type` on the left, the reader's `kind` on the right; the same rows as schema-base's `SECTION_CONTRACTS`. */
|
|
53
|
+
export declare const READER_SECTION_KINDS: {
|
|
54
|
+
readonly featureStoriesBlock: "feature_stories";
|
|
55
|
+
readonly surfaceCardBlock: "cta";
|
|
56
|
+
readonly accentBandBlock: "accent_band";
|
|
57
|
+
readonly locationsBlock: "locations";
|
|
58
|
+
readonly textMediaBlock: "text_media";
|
|
59
|
+
readonly faqBlock: "faq";
|
|
60
|
+
readonly galleryBlock: "gallery";
|
|
61
|
+
readonly contactBlock: "contact";
|
|
62
|
+
};
|
|
63
|
+
/** A gallery is a `StaggerRow`, which holds two to four items. */
|
|
64
|
+
export declare const READER_GALLERY_PHOTO_MIN = 2;
|
|
65
|
+
export declare const READER_GALLERY_PHOTO_LIMIT = 4;
|
|
66
|
+
export declare const SECTION_WARNINGS: {
|
|
67
|
+
readonly layoutDefaulted: "section.layout.defaulted";
|
|
68
|
+
readonly unknownType: "section.type.unknown";
|
|
69
|
+
readonly imageMissingAlt: "section.image.missing-alt";
|
|
70
|
+
readonly imageMissingAsset: "section.image.missing-asset";
|
|
71
|
+
readonly emptySkipped: "section.empty.skipped";
|
|
72
|
+
};
|
|
73
|
+
export type SectionWarningCode = (typeof SECTION_WARNINGS)[keyof typeof SECTION_WARNINGS];
|
|
74
|
+
/** A named warning and the path in the stored document it is about. Never copy. */
|
|
75
|
+
export type SectionWarning = {
|
|
76
|
+
readonly code: SectionWarningCode;
|
|
77
|
+
readonly where: string;
|
|
78
|
+
};
|
|
79
|
+
/** A Sanity image as a site needs it. `asset` is the image asset's id; `alt` is never empty. */
|
|
80
|
+
export type SectionImageInput = {
|
|
81
|
+
readonly asset: string;
|
|
82
|
+
readonly alt: string;
|
|
83
|
+
readonly caption: string | null;
|
|
84
|
+
readonly hotspot: {
|
|
85
|
+
readonly x: number;
|
|
86
|
+
readonly y: number;
|
|
87
|
+
} | null;
|
|
88
|
+
};
|
|
89
|
+
export type TextMediaSectionInput = {
|
|
90
|
+
readonly kind: "text_media";
|
|
91
|
+
readonly anchor: string | null;
|
|
92
|
+
readonly layout: SplitLayout;
|
|
93
|
+
readonly heading: CopyInput;
|
|
94
|
+
readonly tail: CopyInput | null;
|
|
95
|
+
readonly body: CopyInput;
|
|
96
|
+
readonly action: ActionInput | null;
|
|
97
|
+
/** `null` only when the stored photo was dropped (no alt text or no asset); a warning names it. */
|
|
98
|
+
readonly image: SectionImageInput | null;
|
|
99
|
+
};
|
|
100
|
+
export type FaqSectionInput = {
|
|
101
|
+
readonly kind: "faq";
|
|
102
|
+
readonly anchor: string | null;
|
|
103
|
+
readonly layout: HeadingListLayout;
|
|
104
|
+
readonly heading: CopyInput;
|
|
105
|
+
readonly tail: CopyInput | null;
|
|
106
|
+
readonly intro: CopyInput | null;
|
|
107
|
+
readonly items: readonly {
|
|
108
|
+
readonly question: CopyInput;
|
|
109
|
+
readonly answer: CopyInput;
|
|
110
|
+
}[];
|
|
111
|
+
};
|
|
112
|
+
export type GallerySectionInput = {
|
|
113
|
+
readonly kind: "gallery";
|
|
114
|
+
readonly anchor: string | null;
|
|
115
|
+
readonly layout: StaggerRowLayout;
|
|
116
|
+
readonly heading: CopyInput | null;
|
|
117
|
+
readonly images: readonly SectionImageInput[];
|
|
118
|
+
};
|
|
119
|
+
export type ContactSectionInput = {
|
|
120
|
+
readonly kind: "contact";
|
|
121
|
+
readonly anchor: string | null;
|
|
122
|
+
readonly layout: SplitLayout;
|
|
123
|
+
readonly heading: CopyInput;
|
|
124
|
+
readonly body: CopyInput | null;
|
|
125
|
+
/** Show the site settings' email address. */
|
|
126
|
+
readonly showEmail: boolean;
|
|
127
|
+
/** Show the site settings' phone number. */
|
|
128
|
+
readonly showPhone: boolean;
|
|
129
|
+
readonly action: ActionInput | null;
|
|
130
|
+
readonly image: SectionImageInput | null;
|
|
131
|
+
};
|
|
132
|
+
export type NewSectionInput = TextMediaSectionInput | FaqSectionInput | GallerySectionInput | ContactSectionInput;
|
|
133
|
+
/** One entry of `PageContent.sections`: a home section kind or one of the new kinds. */
|
|
134
|
+
export type PageSectionInput = Exclude<CompositionBlockInput, {
|
|
135
|
+
readonly kind: "campaign";
|
|
136
|
+
}> | NewSectionInput;
|
|
@@ -54,6 +54,11 @@
|
|
|
54
54
|
* accentBandBlock kind `accent_band`
|
|
55
55
|
* locationsBlock kind `locations` (jumpLink → anchor)
|
|
56
56
|
*
|
|
57
|
+
* A content page's `sections[]` (A-1915) reads those four kinds plus
|
|
58
|
+
* `text_media`, `faq`, `gallery` and `contact` into `PageContent.sections`,
|
|
59
|
+
* with their named warnings in `PageContent.warnings`. `sections.ts` holds the
|
|
60
|
+
* kinds, the A-1876 layout names and the warning codes.
|
|
61
|
+
*
|
|
57
62
|
* Two places the composition cannot carry a proposed marker: a `cta` block's
|
|
58
63
|
* plain strings, and the campaign's title and body (which travel as Markdown).
|
|
59
64
|
* There the text is returned plain and the line is still listed in
|
|
@@ -61,6 +66,7 @@
|
|
|
61
66
|
* approval. Nothing is dropped silently.
|
|
62
67
|
*/
|
|
63
68
|
import { type CmsQuery } from "../contracts/query.cjs";
|
|
69
|
+
import { type PageSectionInput, type SectionWarning } from "./sections.cjs";
|
|
64
70
|
export type CopyInput = string | {
|
|
65
71
|
readonly text: string;
|
|
66
72
|
readonly copySource: "captured" | "proposed";
|
|
@@ -142,6 +148,13 @@ export type PageContent = {
|
|
|
142
148
|
readonly body: string;
|
|
143
149
|
readonly migrated: boolean;
|
|
144
150
|
readonly proposedCopy: readonly ProposedCopy[];
|
|
151
|
+
/**
|
|
152
|
+
* A-1915. Present only when the stored page has a `sections` list, so a page
|
|
153
|
+
* written before sections existed reads exactly as it did in 0.2.0.
|
|
154
|
+
*/
|
|
155
|
+
readonly sections?: readonly PageSectionInput[];
|
|
156
|
+
/** A-1915. Present with `sections`: every named section warning, with its path. */
|
|
157
|
+
readonly warnings?: readonly SectionWarning[];
|
|
145
158
|
};
|
|
146
159
|
export type SiteSettingsContent = {
|
|
147
160
|
readonly name: string;
|
|
@@ -54,6 +54,11 @@
|
|
|
54
54
|
* accentBandBlock kind `accent_band`
|
|
55
55
|
* locationsBlock kind `locations` (jumpLink → anchor)
|
|
56
56
|
*
|
|
57
|
+
* A content page's `sections[]` (A-1915) reads those four kinds plus
|
|
58
|
+
* `text_media`, `faq`, `gallery` and `contact` into `PageContent.sections`,
|
|
59
|
+
* with their named warnings in `PageContent.warnings`. `sections.ts` holds the
|
|
60
|
+
* kinds, the A-1876 layout names and the warning codes.
|
|
61
|
+
*
|
|
57
62
|
* Two places the composition cannot carry a proposed marker: a `cta` block's
|
|
58
63
|
* plain strings, and the campaign's title and body (which travel as Markdown).
|
|
59
64
|
* There the text is returned plain and the line is still listed in
|
|
@@ -61,6 +66,7 @@
|
|
|
61
66
|
* approval. Nothing is dropped silently.
|
|
62
67
|
*/
|
|
63
68
|
import { type CmsQuery } from "../contracts/query.mjs";
|
|
69
|
+
import { type PageSectionInput, type SectionWarning } from "./sections.mjs";
|
|
64
70
|
export type CopyInput = string | {
|
|
65
71
|
readonly text: string;
|
|
66
72
|
readonly copySource: "captured" | "proposed";
|
|
@@ -142,6 +148,13 @@ export type PageContent = {
|
|
|
142
148
|
readonly body: string;
|
|
143
149
|
readonly migrated: boolean;
|
|
144
150
|
readonly proposedCopy: readonly ProposedCopy[];
|
|
151
|
+
/**
|
|
152
|
+
* A-1915. Present only when the stored page has a `sections` list, so a page
|
|
153
|
+
* written before sections existed reads exactly as it did in 0.2.0.
|
|
154
|
+
*/
|
|
155
|
+
readonly sections?: readonly PageSectionInput[];
|
|
156
|
+
/** A-1915. Present with `sections`: every named section warning, with its path. */
|
|
157
|
+
readonly warnings?: readonly SectionWarning[];
|
|
145
158
|
};
|
|
146
159
|
export type SiteSettingsContent = {
|
|
147
160
|
readonly name: string;
|
|
@@ -54,6 +54,11 @@
|
|
|
54
54
|
* accentBandBlock kind `accent_band`
|
|
55
55
|
* locationsBlock kind `locations` (jumpLink → anchor)
|
|
56
56
|
*
|
|
57
|
+
* A content page's `sections[]` (A-1915) reads those four kinds plus
|
|
58
|
+
* `text_media`, `faq`, `gallery` and `contact` into `PageContent.sections`,
|
|
59
|
+
* with their named warnings in `PageContent.warnings`. `sections.ts` holds the
|
|
60
|
+
* kinds, the A-1876 layout names and the warning codes.
|
|
61
|
+
*
|
|
57
62
|
* Two places the composition cannot carry a proposed marker: a `cta` block's
|
|
58
63
|
* plain strings, and the campaign's title and body (which travel as Markdown).
|
|
59
64
|
* There the text is returned plain and the line is still listed in
|
|
@@ -61,6 +66,7 @@
|
|
|
61
66
|
* approval. Nothing is dropped silently.
|
|
62
67
|
*/
|
|
63
68
|
import { type CmsQuery } from "../contracts/query.js";
|
|
69
|
+
import { type PageSectionInput, type SectionWarning } from "./sections.js";
|
|
64
70
|
export type CopyInput = string | {
|
|
65
71
|
readonly text: string;
|
|
66
72
|
readonly copySource: "captured" | "proposed";
|
|
@@ -142,6 +148,13 @@ export type PageContent = {
|
|
|
142
148
|
readonly body: string;
|
|
143
149
|
readonly migrated: boolean;
|
|
144
150
|
readonly proposedCopy: readonly ProposedCopy[];
|
|
151
|
+
/**
|
|
152
|
+
* A-1915. Present only when the stored page has a `sections` list, so a page
|
|
153
|
+
* written before sections existed reads exactly as it did in 0.2.0.
|
|
154
|
+
*/
|
|
155
|
+
readonly sections?: readonly PageSectionInput[];
|
|
156
|
+
/** A-1915. Present with `sections`: every named section warning, with its path. */
|
|
157
|
+
readonly warnings?: readonly SectionWarning[];
|
|
145
158
|
};
|
|
146
159
|
export type SiteSettingsContent = {
|
|
147
160
|
readonly name: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CmsQuery } from "../contracts/query.cjs";
|
|
1
|
+
import { type CmsQuery, type CmsResolution } from "../contracts/query.cjs";
|
|
2
2
|
export type CmsFailure = "configuration" | "network" | "timeout" | "rate-limit" | "upstream" | "plan-limit" | "permission" | "malformed";
|
|
3
3
|
export type CmsDiagnostic = {
|
|
4
4
|
readonly event: "cms.fallback" | "cms.partial-fallback" | "cms.refused";
|
|
@@ -6,6 +6,7 @@ export type CmsDiagnostic = {
|
|
|
6
6
|
readonly reason: CmsFailure | "missing" | "invalid-field";
|
|
7
7
|
readonly status?: number;
|
|
8
8
|
readonly fields: readonly string[];
|
|
9
|
+
readonly warnings?: CmsResolution<unknown>["warnings"];
|
|
9
10
|
};
|
|
10
11
|
export type CmsFetch = (url: string, init: RequestInit & {
|
|
11
12
|
next?: {
|
|
@@ -34,6 +35,7 @@ export type CmsReadResult<T> = {
|
|
|
34
35
|
readonly source: "cms" | "mixed" | "fallback";
|
|
35
36
|
readonly fallbackFields: readonly string[];
|
|
36
37
|
readonly reason?: CmsFailure | "missing" | "invalid-field";
|
|
38
|
+
readonly warnings?: CmsResolution<unknown>["warnings"];
|
|
37
39
|
};
|
|
38
40
|
export type CmsReaderOptions = {
|
|
39
41
|
readonly adapter: CmsAdapter;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CmsQuery } from "../contracts/query.mjs";
|
|
1
|
+
import { type CmsQuery, type CmsResolution } from "../contracts/query.mjs";
|
|
2
2
|
export type CmsFailure = "configuration" | "network" | "timeout" | "rate-limit" | "upstream" | "plan-limit" | "permission" | "malformed";
|
|
3
3
|
export type CmsDiagnostic = {
|
|
4
4
|
readonly event: "cms.fallback" | "cms.partial-fallback" | "cms.refused";
|
|
@@ -6,6 +6,7 @@ export type CmsDiagnostic = {
|
|
|
6
6
|
readonly reason: CmsFailure | "missing" | "invalid-field";
|
|
7
7
|
readonly status?: number;
|
|
8
8
|
readonly fields: readonly string[];
|
|
9
|
+
readonly warnings?: CmsResolution<unknown>["warnings"];
|
|
9
10
|
};
|
|
10
11
|
export type CmsFetch = (url: string, init: RequestInit & {
|
|
11
12
|
next?: {
|
|
@@ -34,6 +35,7 @@ export type CmsReadResult<T> = {
|
|
|
34
35
|
readonly source: "cms" | "mixed" | "fallback";
|
|
35
36
|
readonly fallbackFields: readonly string[];
|
|
36
37
|
readonly reason?: CmsFailure | "missing" | "invalid-field";
|
|
38
|
+
readonly warnings?: CmsResolution<unknown>["warnings"];
|
|
37
39
|
};
|
|
38
40
|
export type CmsReaderOptions = {
|
|
39
41
|
readonly adapter: CmsAdapter;
|
package/dist/runtime/reader.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CmsQuery } from "../contracts/query.js";
|
|
1
|
+
import { type CmsQuery, type CmsResolution } from "../contracts/query.js";
|
|
2
2
|
export type CmsFailure = "configuration" | "network" | "timeout" | "rate-limit" | "upstream" | "plan-limit" | "permission" | "malformed";
|
|
3
3
|
export type CmsDiagnostic = {
|
|
4
4
|
readonly event: "cms.fallback" | "cms.partial-fallback" | "cms.refused";
|
|
@@ -6,6 +6,7 @@ export type CmsDiagnostic = {
|
|
|
6
6
|
readonly reason: CmsFailure | "missing" | "invalid-field";
|
|
7
7
|
readonly status?: number;
|
|
8
8
|
readonly fields: readonly string[];
|
|
9
|
+
readonly warnings?: CmsResolution<unknown>["warnings"];
|
|
9
10
|
};
|
|
10
11
|
export type CmsFetch = (url: string, init: RequestInit & {
|
|
11
12
|
next?: {
|
|
@@ -34,6 +35,7 @@ export type CmsReadResult<T> = {
|
|
|
34
35
|
readonly source: "cms" | "mixed" | "fallback";
|
|
35
36
|
readonly fallbackFields: readonly string[];
|
|
36
37
|
readonly reason?: CmsFailure | "missing" | "invalid-field";
|
|
38
|
+
readonly warnings?: CmsResolution<unknown>["warnings"];
|
|
37
39
|
};
|
|
38
40
|
export type CmsReaderOptions = {
|
|
39
41
|
readonly adapter: CmsAdapter;
|
package/dist/sanity.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var w=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var $=Object.prototype.hasOwnProperty;var R=(e,t)=>{for(var n in t)w(e,n,{get:t[n],enumerable:!0})},x=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of z(t))!$.call(e,s)&&s!==n&&w(e,s,{get:()=>t[s],enumerable:!(r=E(t,s))||r.enumerable});return e};var P=e=>x(w({},"__esModule",{value:!0}),e);var B={};R(B,{createSanityAdapter:()=>v,sanityBindingFromEnv:()=>I});module.exports=P(B);var Y=require("server-only");var M=/^[A-Za-z][A-Za-z0-9_]{0,63}$/,D=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/,N=/^[a-z0-9]{6,12}\.[a-z][a-z0-9_-]{0,63}$/;function T(e){if(!e||!Array.isArray(e.types)||e.types.length===0)throw new TypeError("CMS dependencies require document types");let t=[...e.types];for(let r of t)if(typeof r!="string"||!M.test(r))throw new TypeError("Invalid CMS document type");if(e.ids!==void 0&&!Array.isArray(e.ids))throw new TypeError("Invalid CMS document IDs");let n=e.ids===void 0?void 0:[...e.ids];for(let r of n??[])if(typeof r!="string"||!D.test(r)||/^(drafts|versions)\./.test(r))throw new TypeError("Invalid CMS document ID");if(new Set(t).size+new Set(n).size>128)throw new TypeError("Too many CMS tags");return Object.freeze({types:Object.freeze(t),...n===void 0?{}:{ids:Object.freeze(n)}})}function b(e){if(!e||typeof e.name!="string"||!/^[A-Za-z][A-Za-z0-9_.-]{0,127}$/.test(e.name)||typeof e.query!="string"||e.query.trim()===""||typeof e.resolve!="function")throw new TypeError("Invalid CMS query configuration");let t=e.params;if(!t||typeof t!="object"||Object.getPrototypeOf(t)!==Object.prototype&&Object.getPrototypeOf(t)!==null)throw new TypeError("CMS params must be plain JSON scalars");let n={};for(let r of Reflect.ownKeys(t)){let s=Object.getOwnPropertyDescriptor(t,r);if(typeof r!="string"||!s||!Object.hasOwn(s,"value")||!s.enumerable)throw new TypeError("CMS params must be plain JSON scalars");let i=s.value;if(!(i===null||typeof i=="string"||typeof i=="boolean"||typeof i=="number"&&Number.isFinite(i)))throw new TypeError("CMS params must be plain JSON scalars");Object.defineProperty(n,r,{value:i,enumerable:!0})}return Object.freeze({name:e.name,query:e.query,params:Object.freeze(n),dependencies:T(e.dependencies),resolve:e.resolve})}function C(e,t){if(typeof e!="string"||e.length>77||!N.test(e))throw new TypeError("Invalid CMS scope");let n=T(t),r=[...[...new Set(n.types)].sort().map(s=>`cms:${e}:type:${s}`),...[...new Set(n.ids??[])].sort().map(s=>`cms:${e}:id:${s}`)];return Object.freeze(r)}var _=2*1024*1024;function A(e){if(!e||typeof e.projectId!="string"||!/^[a-z0-9]{6,12}$/.test(e.projectId)||typeof e.dataset!="string"||!/^[a-z][a-z0-9_-]{0,63}$/.test(e.dataset)||typeof e.apiVersion!="string"||!/^v?\d{4}-\d{2}-\d{2}$/.test(e.apiVersion))throw new TypeError("Invalid Sanity binding configuration");return Object.freeze({projectId:e.projectId,dataset:e.dataset,apiVersion:e.apiVersion.replace(/^v/,"")})}function v(e){let t=A(e?.binding),n=e.timeoutMs??1500,r=e.readToken;if(!Number.isSafeInteger(n)||n<=0||n>2147483647||e.fetchImpl!==void 0&&typeof e.fetchImpl!="function"||r!==void 0&&(typeof r!="string"||r.trim()===""||/[\r\n]/.test(r)))throw new TypeError("Invalid Sanity adapter configuration");let s=e.fetchImpl,i=`${t.projectId}.${t.dataset}`;return Object.freeze({scope:i,async read(O,c){let
|
|
1
|
+
"use strict";var w=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var $=Object.prototype.hasOwnProperty;var R=(e,t)=>{for(var n in t)w(e,n,{get:t[n],enumerable:!0})},x=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of z(t))!$.call(e,s)&&s!==n&&w(e,s,{get:()=>t[s],enumerable:!(r=E(t,s))||r.enumerable});return e};var P=e=>x(w({},"__esModule",{value:!0}),e);var B={};R(B,{createSanityAdapter:()=>v,sanityBindingFromEnv:()=>I});module.exports=P(B);var Y=require("server-only");var M=/^[A-Za-z][A-Za-z0-9_]{0,63}$/,D=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/,N=/^[a-z0-9]{6,12}\.[a-z][a-z0-9_-]{0,63}$/;function T(e){if(!e||!Array.isArray(e.types)||e.types.length===0)throw new TypeError("CMS dependencies require document types");let t=[...e.types];for(let r of t)if(typeof r!="string"||!M.test(r))throw new TypeError("Invalid CMS document type");if(e.ids!==void 0&&!Array.isArray(e.ids))throw new TypeError("Invalid CMS document IDs");let n=e.ids===void 0?void 0:[...e.ids];for(let r of n??[])if(typeof r!="string"||!D.test(r)||/^(drafts|versions)\./.test(r))throw new TypeError("Invalid CMS document ID");if(new Set(t).size+new Set(n).size>128)throw new TypeError("Too many CMS tags");return Object.freeze({types:Object.freeze(t),...n===void 0?{}:{ids:Object.freeze(n)}})}function b(e){if(!e||typeof e.name!="string"||!/^[A-Za-z][A-Za-z0-9_.-]{0,127}$/.test(e.name)||typeof e.query!="string"||e.query.trim()===""||typeof e.resolve!="function")throw new TypeError("Invalid CMS query configuration");let t=e.params;if(!t||typeof t!="object"||Object.getPrototypeOf(t)!==Object.prototype&&Object.getPrototypeOf(t)!==null)throw new TypeError("CMS params must be plain JSON scalars");let n={};for(let r of Reflect.ownKeys(t)){let s=Object.getOwnPropertyDescriptor(t,r);if(typeof r!="string"||!s||!Object.hasOwn(s,"value")||!s.enumerable)throw new TypeError("CMS params must be plain JSON scalars");let i=s.value;if(!(i===null||typeof i=="string"||typeof i=="boolean"||typeof i=="number"&&Number.isFinite(i)))throw new TypeError("CMS params must be plain JSON scalars");Object.defineProperty(n,r,{value:i,enumerable:!0})}return Object.freeze({name:e.name,query:e.query,params:Object.freeze(n),dependencies:T(e.dependencies),resolve:e.resolve})}function C(e,t){if(typeof e!="string"||e.length>77||!N.test(e))throw new TypeError("Invalid CMS scope");let n=T(t),r=[...[...new Set(n.types)].sort().map(s=>`cms:${e}:type:${s}`),...[...new Set(n.ids??[])].sort().map(s=>`cms:${e}:id:${s}`)];return Object.freeze(r)}var _=2*1024*1024;function A(e){if(!e||typeof e.projectId!="string"||!/^[a-z0-9]{6,12}$/.test(e.projectId)||typeof e.dataset!="string"||!/^[a-z][a-z0-9_-]{0,63}$/.test(e.dataset)||typeof e.apiVersion!="string"||!/^v?\d{4}-\d{2}-\d{2}$/.test(e.apiVersion))throw new TypeError("Invalid Sanity binding configuration");return Object.freeze({projectId:e.projectId,dataset:e.dataset,apiVersion:e.apiVersion.replace(/^v/,"")})}function v(e){let t=A(e?.binding),n=e.timeoutMs??1500,r=e.readToken;if(!Number.isSafeInteger(n)||n<=0||n>2147483647||e.fetchImpl!==void 0&&typeof e.fetchImpl!="function"||r!==void 0&&(typeof r!="string"||r.trim()===""||/[\r\n]/.test(r)))throw new TypeError("Invalid Sanity adapter configuration");let s=e.fetchImpl,i=`${t.projectId}.${t.dataset}`;return Object.freeze({scope:i,async read(O,c){let y;try{if(!c||!Number.isSafeInteger(c.revalidateSeconds)||c.revalidateSeconds<3600||!Array.isArray(c.tags))throw new TypeError;let o=[],p=[];for(let d of c.tags){if(typeof d!="string")throw new TypeError;if(d.startsWith(`cms:${i}:type:`))o.push(d.slice(`cms:${i}:type:`.length));else if(d.startsWith(`cms:${i}:id:`))p.push(d.slice(`cms:${i}:id:`.length));else throw new TypeError}let l=C(i,{types:o,ids:p});if(l.length!==c.tags.length||l.some((d,a)=>d!==c.tags[a]))throw new TypeError;y=b({...O,dependencies:{types:o,ids:p},resolve:d=>({data:d,fallbackFields:[]})})}catch{throw new TypeError("Invalid Sanity read configuration")}let f=new URL(`https://${t.projectId}.api.sanity.io/v${t.apiVersion}/data/query/${t.dataset}`);f.searchParams.set("query",y.query),f.searchParams.set("perspective","published");for(let o of Object.keys(y.params).sort())f.searchParams.set(`$${o}`,JSON.stringify(y.params[o]));let h=new AbortController,m,u=!1,g=()=>{h.abort(),m&&m.cancel().catch(()=>{})},S,k=new Promise(o=>{S=setTimeout(()=>{u=!0,g(),o({ok:!1,reason:"timeout"})},n)}),j=async()=>{try{let o=await(s??globalThis.fetch)(f.href,{method:"GET",redirect:"error",signal:h.signal,headers:r===void 0?{}:{Authorization:`Bearer ${r}`},next:{revalidate:c.revalidateSeconds,tags:[...c.tags]}});if(u)return o.body?.cancel().catch(()=>{}),{ok:!1,reason:"timeout"};if(!o.ok){o.body?.cancel().catch(()=>{});let a=o.status;return{ok:!1,reason:a===402?"plan-limit":a===401||a===403?"permission":a===429?"rate-limit":"upstream",status:a}}if(!o.body)return{ok:!1,reason:"malformed"};m=o.body.getReader();let p=0,l="",d=new TextDecoder("utf-8",{fatal:!0});for(;;){let a=await m.read();if(u)return{ok:!1,reason:"timeout"};if(a.done)break;if(p+=a.value.byteLength,p>_)return g(),{ok:!1,reason:"malformed"};try{l+=d.decode(a.value,{stream:!0})}catch{return g(),{ok:!1,reason:"malformed"}}}try{l+=d.decode();let a=JSON.parse(l);return!a||typeof a!="object"||Array.isArray(a)||!Object.hasOwn(a,"result")?{ok:!1,reason:"malformed"}:{ok:!0,value:a.result}}catch{return{ok:!1,reason:"malformed"}}}catch{return{ok:!1,reason:u?"timeout":"network"}}};try{return await Promise.race([j(),k])}finally{clearTimeout(S)}}})}function I(e){return A({projectId:e.SANITY_PROJECT_ID,dataset:e.SANITY_DATASET,apiVersion:e.SANITY_API_VERSION})}0&&(module.exports={createSanityAdapter,sanityBindingFromEnv});
|
|
2
2
|
//# sourceMappingURL=sanity.cjs.map
|