@suiteop/storefront 0.5.0 → 0.6.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 +14 -0
- package/README.md +4 -2
- package/dist/astro-content-model.cjs +3 -3
- package/dist/astro-content-model.js +2 -2
- package/dist/astro.cjs +1 -1
- package/dist/astro.d.cts +66 -1
- package/dist/astro.d.ts +66 -1
- package/dist/astro.js +1 -1
- package/dist/{availability-Dh0yLSkj.d.cts → availability.d-Cla9GuGc.d.cts} +8 -8
- package/dist/{availability-Dh0yLSkj.d.ts → availability.d-Cla9GuGc.d.ts} +8 -8
- package/dist/checkout.d.cts +11 -0
- package/dist/checkout.d.ts +11 -0
- package/dist/{chunk-IUNIQSFB.js → chunk-3B6ZYRYF.js} +1 -1
- package/dist/chunk-3NE27PHL.cjs +19 -0
- package/dist/chunk-JF245QUY.cjs +9 -0
- package/dist/{chunk-NNWJZUQL.cjs → chunk-OXCLLFCY.cjs} +2 -2
- package/dist/chunk-QBHOJGZI.cjs +21 -0
- package/dist/chunk-UQWQPTHO.js +3 -0
- package/dist/chunk-XOCFEVP4.js +6 -0
- package/dist/chunk-YIYGBTAM.js +9 -0
- package/dist/{client-C9Igm7O-.d.ts → client-CX8K7JNt.d.cts} +65 -11
- package/dist/{client-2KyVv-2l.d.cts → client-s-lEwqzc.d.ts} +65 -11
- package/dist/components.d.cts +43 -1
- package/dist/components.d.ts +43 -1
- package/dist/config.cjs +3 -3
- package/dist/config.d.cts +78 -74
- package/dist/config.d.ts +78 -74
- package/dist/config.js +2 -2
- package/dist/content.cjs +9 -9
- package/dist/content.d.cts +53 -9
- package/dist/content.d.ts +53 -9
- package/dist/content.js +2 -2
- package/dist/{errors-DpImb0Uf.d.cts → errors-Oax7djdp.d.ts} +54 -13
- package/dist/{errors-BGgJ--XR.d.ts → errors-welPvrD6.d.cts} +54 -13
- package/dist/index.cjs +12 -12
- package/dist/index.d.cts +27 -8
- package/dist/index.d.ts +27 -8
- package/dist/index.js +3 -3
- package/dist/react.cjs +4 -4
- package/dist/react.d.cts +24 -3
- package/dist/react.d.ts +24 -3
- package/dist/react.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-5TUJX6GY.js +0 -5
- package/dist/chunk-LY73ZYN5.cjs +0 -20
- package/dist/chunk-NZWYOV5Y.cjs +0 -19
- package/dist/chunk-PYVUDQSQ.js +0 -3
- package/dist/chunk-YSKWSL2F.js +0 -9
- package/dist/chunk-ZLAOY6IF.cjs +0 -9
package/dist/content.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { R as RequestOptions, P as Page, s as StorefrontImage, o as StorefrontContentRef, j as StorefrontClient } from './client-
|
|
2
|
-
export { m as StorefrontContentItem } from './client-
|
|
1
|
+
import { R as RequestOptions, P as Page, s as StorefrontImage, o as StorefrontContentRef, j as StorefrontClient } from './client-CX8K7JNt.cjs';
|
|
2
|
+
export { m as StorefrontContentItem } from './client-CX8K7JNt.cjs';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import './availability-
|
|
4
|
+
import './availability.d-Cla9GuGc.cjs';
|
|
5
5
|
|
|
6
6
|
declare const contentLocalizedSchema: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
7
7
|
type ContentLocalized = z.infer<typeof contentLocalizedSchema>;
|
|
@@ -10,8 +10,8 @@ declare const contentModelSchema: z.ZodObject<{
|
|
|
10
10
|
types: z.ZodArray<z.ZodObject<{
|
|
11
11
|
key: z.ZodString;
|
|
12
12
|
kind: z.ZodEnum<{
|
|
13
|
-
fields: "fields";
|
|
14
13
|
collection: "collection";
|
|
14
|
+
fields: "fields";
|
|
15
15
|
section: "section";
|
|
16
16
|
}>;
|
|
17
17
|
label: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
@@ -30,17 +30,17 @@ declare const contentModelSchema: z.ZodObject<{
|
|
|
30
30
|
fields: z.ZodArray<z.ZodObject<{
|
|
31
31
|
key: z.ZodString;
|
|
32
32
|
type: z.ZodEnum<{
|
|
33
|
-
number: "number";
|
|
34
33
|
boolean: "boolean";
|
|
35
|
-
rich_text: "rich_text";
|
|
36
|
-
link: "link";
|
|
37
|
-
text: "text";
|
|
38
34
|
date: "date";
|
|
39
|
-
image: "image";
|
|
40
35
|
gallery: "gallery";
|
|
36
|
+
image: "image";
|
|
37
|
+
link: "link";
|
|
38
|
+
number: "number";
|
|
41
39
|
option: "option";
|
|
42
40
|
reference: "reference";
|
|
43
41
|
references: "references";
|
|
42
|
+
rich_text: "rich_text";
|
|
43
|
+
text: "text";
|
|
44
44
|
}>;
|
|
45
45
|
label: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
46
46
|
help: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
@@ -64,20 +64,27 @@ declare const contentModelSchema: z.ZodObject<{
|
|
|
64
64
|
type ContentModel = z.infer<typeof contentModelSchema>;
|
|
65
65
|
type ContentModelInput = z.input<typeof contentModelSchema>;
|
|
66
66
|
|
|
67
|
+
/** A label in one language, or one per language (`{ en: 'Blog', fr: 'Blog' }`). */
|
|
67
68
|
type Localized = ContentLocalized;
|
|
68
69
|
interface FieldBase {
|
|
69
70
|
label: Localized;
|
|
71
|
+
/** A hint under the field in the dashboard. */
|
|
70
72
|
help?: Localized;
|
|
73
|
+
/** The property manager must fill it in before saving. */
|
|
71
74
|
required?: boolean;
|
|
72
75
|
}
|
|
73
76
|
interface TextOptions extends FieldBase {
|
|
77
|
+
/** Written once and AI-translated to the site's other languages. Default true. */
|
|
74
78
|
translatable?: boolean;
|
|
75
79
|
maxLength?: number;
|
|
76
80
|
}
|
|
77
81
|
interface ListOptions extends FieldBase {
|
|
82
|
+
/** Most photos (gallery) or items (references). */
|
|
78
83
|
max?: number;
|
|
79
84
|
}
|
|
85
|
+
/** What a reference points at: a listing, a building, an area, or an item of a collection. */
|
|
80
86
|
type ReferenceTarget = 'listing' | 'building' | 'area' | `collection:${string}`;
|
|
87
|
+
/** An option of an `option` field: its value, or a value with a label. */
|
|
81
88
|
type OptionChoice<V extends string = string> = V | {
|
|
82
89
|
value: V;
|
|
83
90
|
label: Localized;
|
|
@@ -122,25 +129,39 @@ type ContentFieldDefinition = TextField | RichTextField | ImageField | GalleryFi
|
|
|
122
129
|
interface TypeBase {
|
|
123
130
|
label: Localized;
|
|
124
131
|
description?: Localized;
|
|
132
|
+
/** Keyed by field key: lower-case letters, digits and `_`, starting with a letter. */
|
|
125
133
|
fields: Record<string, ContentFieldDefinition>;
|
|
126
134
|
}
|
|
135
|
+
/** Many items: a blog, press mentions, perks. */
|
|
127
136
|
interface CollectionDefinition extends TypeBase {
|
|
128
137
|
kind: 'collection';
|
|
138
|
+
/** The key of the `text` field that titles an item. */
|
|
129
139
|
titleField: string;
|
|
140
|
+
/** Each item gets a web address (slug). */
|
|
130
141
|
routable?: boolean;
|
|
142
|
+
/** Items start as drafts and are published explicitly. */
|
|
131
143
|
drafts?: boolean;
|
|
144
|
+
/** `manual` (the property manager's drag order, the default) or `newest` (by publish date). */
|
|
132
145
|
order?: 'manual' | 'newest';
|
|
133
146
|
}
|
|
147
|
+
/** One item: a home-page banner. */
|
|
134
148
|
interface SectionDefinition extends TypeBase {
|
|
135
149
|
kind: 'section';
|
|
136
150
|
}
|
|
151
|
+
/** Extra fields every building or every area carries. */
|
|
137
152
|
interface FieldsDefinition extends TypeBase {
|
|
138
153
|
kind: 'fields';
|
|
139
154
|
attachesTo: 'building' | 'area';
|
|
140
155
|
}
|
|
141
156
|
type ContentTypeDefinition = CollectionDefinition | SectionDefinition | FieldsDefinition;
|
|
157
|
+
/** Keyed by type key: what the site's code reads it by (`blog`, `home_hero`). */
|
|
142
158
|
type ContentDefinition = Record<string, ContentTypeDefinition>;
|
|
159
|
+
/**
|
|
160
|
+
* Declare the site's content model. Returns the object unchanged; its exact type is what
|
|
161
|
+
* `createContentReader` reads values as.
|
|
162
|
+
*/
|
|
143
163
|
declare function defineContent<const T extends ContentDefinition>(definition: T): T;
|
|
164
|
+
/** Field builders. Each returns its options with the field's `type`. */
|
|
144
165
|
declare const field: {
|
|
145
166
|
text: <const O extends TextOptions>(o: O) => O & {
|
|
146
167
|
type: "text";
|
|
@@ -183,6 +204,7 @@ declare const field: {
|
|
|
183
204
|
type: "references";
|
|
184
205
|
};
|
|
185
206
|
};
|
|
207
|
+
/** A link value. `url` is `https://…` or a path on the site (`/stays`). */
|
|
186
208
|
interface ContentLink {
|
|
187
209
|
url: string;
|
|
188
210
|
label?: string;
|
|
@@ -190,6 +212,10 @@ interface ContentLink {
|
|
|
190
212
|
type OptionValue<C> = C extends string ? C : C extends {
|
|
191
213
|
value: infer V;
|
|
192
214
|
} ? V : never;
|
|
215
|
+
/**
|
|
216
|
+
* What a field reads as. Every single value can be null — not filled in yet, or no longer fitting
|
|
217
|
+
* the field after the site's code changed it — and lists are empty instead.
|
|
218
|
+
*/
|
|
193
219
|
type FieldValue<F> = F extends {
|
|
194
220
|
type: 'text' | 'rich_text' | 'date';
|
|
195
221
|
} ? string | null : F extends {
|
|
@@ -210,11 +236,13 @@ type FieldValue<F> = F extends {
|
|
|
210
236
|
} ? StorefrontContentRef | null : F extends {
|
|
211
237
|
type: 'references';
|
|
212
238
|
} ? StorefrontContentRef[] : unknown;
|
|
239
|
+
/** The values of one item of type `T`, by field key. */
|
|
213
240
|
type FieldsOf<T> = T extends {
|
|
214
241
|
fields: infer F;
|
|
215
242
|
} ? {
|
|
216
243
|
-readonly [K in keyof F]: FieldValue<F[K]>;
|
|
217
244
|
} : never;
|
|
245
|
+
/** One published item of type `K`. */
|
|
218
246
|
interface ItemOf<D, K extends keyof D> {
|
|
219
247
|
id: string;
|
|
220
248
|
slug: string | null;
|
|
@@ -231,8 +259,18 @@ type KeysOfKind<D, Kind> = {
|
|
|
231
259
|
type CollectionKeys<D> = KeysOfKind<D, 'collection'>;
|
|
232
260
|
type SectionKeys<D> = KeysOfKind<D, 'section'>;
|
|
233
261
|
type FieldsKeys<D> = KeysOfKind<D, 'fields'>;
|
|
262
|
+
/** The declaration as the Storefront API stores it (`{ version: 1, types: [...] }`). */
|
|
234
263
|
declare function toContentModel(definition: ContentDefinition): ContentModelInput;
|
|
264
|
+
/**
|
|
265
|
+
* {@link toContentModel}, checked against the rules the API applies (keys, a collection's title
|
|
266
|
+
* field, reference targets…). Throws an error naming each problem's path.
|
|
267
|
+
*/
|
|
235
268
|
declare function parseContentModel(definition: ContentDefinition): ContentModel;
|
|
269
|
+
/**
|
|
270
|
+
* Stored values as the declared fields read them: each one checked against its field's type, a
|
|
271
|
+
* missing or mistyped one as null (or `[]` for a list), undeclared keys dropped. A published site
|
|
272
|
+
* never breaks on a value its code no longer expects.
|
|
273
|
+
*/
|
|
236
274
|
declare function readFields<T extends ContentTypeDefinition>(type: T, values: Record<string, unknown> | null | undefined): FieldsOf<T>;
|
|
237
275
|
interface ContentReader<D extends ContentDefinition> {
|
|
238
276
|
collection<K extends CollectionKeys<D>>(key: K): {
|
|
@@ -240,15 +278,21 @@ interface ContentReader<D extends ContentDefinition> {
|
|
|
240
278
|
limit?: number;
|
|
241
279
|
offset?: number;
|
|
242
280
|
}, opts?: RequestOptions): Promise<Page<ItemOf<D, K>>>;
|
|
281
|
+
/** By slug or id; null when nothing published answers to it. */
|
|
243
282
|
get(slugOrId: string, opts?: RequestOptions): Promise<ItemOf<D, K> | null>;
|
|
244
283
|
};
|
|
245
284
|
section<K extends SectionKeys<D>>(key: K): {
|
|
246
285
|
get(opts?: RequestOptions): Promise<ItemOf<D, K>>;
|
|
247
286
|
};
|
|
287
|
+
/**
|
|
288
|
+
* The custom fields of type `key` on a building or an area the client returned
|
|
289
|
+
* (`client.buildings.get(id)`), typed; all empty when the record carries none.
|
|
290
|
+
*/
|
|
248
291
|
fieldsOf<K extends FieldsKeys<D>>(key: K, record: {
|
|
249
292
|
fields?: Record<string, Record<string, unknown>> | null;
|
|
250
293
|
}): FieldsOf<D[K]>;
|
|
251
294
|
}
|
|
295
|
+
/** Typed reads of the content `definition` declares, through `client`. */
|
|
252
296
|
declare function createContentReader<D extends ContentDefinition>(client: StorefrontClient, definition: D): ContentReader<D>;
|
|
253
297
|
|
|
254
298
|
export { type BooleanField, type CollectionDefinition, type CollectionKeys, type ContentDefinition, type ContentFieldDefinition, type ContentLink, type ContentReader, type ContentTypeDefinition, type DateField, type FieldValue, type FieldsDefinition, type FieldsKeys, type FieldsOf, type GalleryField, type ImageField, type ItemOf, type LinkField, type Localized, type NumberField, type OptionChoice, type OptionField, type ReferenceField, type ReferenceTarget, type ReferencesField, type RichTextField, type SectionDefinition, type SectionKeys, StorefrontContentRef, StorefrontImage, type TextField, contentModelSchema, createContentReader, defineContent, field, parseContentModel, readFields, toContentModel };
|
package/dist/content.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { R as RequestOptions, P as Page, s as StorefrontImage, o as StorefrontContentRef, j as StorefrontClient } from './client-
|
|
2
|
-
export { m as StorefrontContentItem } from './client-
|
|
1
|
+
import { R as RequestOptions, P as Page, s as StorefrontImage, o as StorefrontContentRef, j as StorefrontClient } from './client-s-lEwqzc.js';
|
|
2
|
+
export { m as StorefrontContentItem } from './client-s-lEwqzc.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import './availability-
|
|
4
|
+
import './availability.d-Cla9GuGc.js';
|
|
5
5
|
|
|
6
6
|
declare const contentLocalizedSchema: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
7
7
|
type ContentLocalized = z.infer<typeof contentLocalizedSchema>;
|
|
@@ -10,8 +10,8 @@ declare const contentModelSchema: z.ZodObject<{
|
|
|
10
10
|
types: z.ZodArray<z.ZodObject<{
|
|
11
11
|
key: z.ZodString;
|
|
12
12
|
kind: z.ZodEnum<{
|
|
13
|
-
fields: "fields";
|
|
14
13
|
collection: "collection";
|
|
14
|
+
fields: "fields";
|
|
15
15
|
section: "section";
|
|
16
16
|
}>;
|
|
17
17
|
label: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
@@ -30,17 +30,17 @@ declare const contentModelSchema: z.ZodObject<{
|
|
|
30
30
|
fields: z.ZodArray<z.ZodObject<{
|
|
31
31
|
key: z.ZodString;
|
|
32
32
|
type: z.ZodEnum<{
|
|
33
|
-
number: "number";
|
|
34
33
|
boolean: "boolean";
|
|
35
|
-
rich_text: "rich_text";
|
|
36
|
-
link: "link";
|
|
37
|
-
text: "text";
|
|
38
34
|
date: "date";
|
|
39
|
-
image: "image";
|
|
40
35
|
gallery: "gallery";
|
|
36
|
+
image: "image";
|
|
37
|
+
link: "link";
|
|
38
|
+
number: "number";
|
|
41
39
|
option: "option";
|
|
42
40
|
reference: "reference";
|
|
43
41
|
references: "references";
|
|
42
|
+
rich_text: "rich_text";
|
|
43
|
+
text: "text";
|
|
44
44
|
}>;
|
|
45
45
|
label: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
46
46
|
help: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
@@ -64,20 +64,27 @@ declare const contentModelSchema: z.ZodObject<{
|
|
|
64
64
|
type ContentModel = z.infer<typeof contentModelSchema>;
|
|
65
65
|
type ContentModelInput = z.input<typeof contentModelSchema>;
|
|
66
66
|
|
|
67
|
+
/** A label in one language, or one per language (`{ en: 'Blog', fr: 'Blog' }`). */
|
|
67
68
|
type Localized = ContentLocalized;
|
|
68
69
|
interface FieldBase {
|
|
69
70
|
label: Localized;
|
|
71
|
+
/** A hint under the field in the dashboard. */
|
|
70
72
|
help?: Localized;
|
|
73
|
+
/** The property manager must fill it in before saving. */
|
|
71
74
|
required?: boolean;
|
|
72
75
|
}
|
|
73
76
|
interface TextOptions extends FieldBase {
|
|
77
|
+
/** Written once and AI-translated to the site's other languages. Default true. */
|
|
74
78
|
translatable?: boolean;
|
|
75
79
|
maxLength?: number;
|
|
76
80
|
}
|
|
77
81
|
interface ListOptions extends FieldBase {
|
|
82
|
+
/** Most photos (gallery) or items (references). */
|
|
78
83
|
max?: number;
|
|
79
84
|
}
|
|
85
|
+
/** What a reference points at: a listing, a building, an area, or an item of a collection. */
|
|
80
86
|
type ReferenceTarget = 'listing' | 'building' | 'area' | `collection:${string}`;
|
|
87
|
+
/** An option of an `option` field: its value, or a value with a label. */
|
|
81
88
|
type OptionChoice<V extends string = string> = V | {
|
|
82
89
|
value: V;
|
|
83
90
|
label: Localized;
|
|
@@ -122,25 +129,39 @@ type ContentFieldDefinition = TextField | RichTextField | ImageField | GalleryFi
|
|
|
122
129
|
interface TypeBase {
|
|
123
130
|
label: Localized;
|
|
124
131
|
description?: Localized;
|
|
132
|
+
/** Keyed by field key: lower-case letters, digits and `_`, starting with a letter. */
|
|
125
133
|
fields: Record<string, ContentFieldDefinition>;
|
|
126
134
|
}
|
|
135
|
+
/** Many items: a blog, press mentions, perks. */
|
|
127
136
|
interface CollectionDefinition extends TypeBase {
|
|
128
137
|
kind: 'collection';
|
|
138
|
+
/** The key of the `text` field that titles an item. */
|
|
129
139
|
titleField: string;
|
|
140
|
+
/** Each item gets a web address (slug). */
|
|
130
141
|
routable?: boolean;
|
|
142
|
+
/** Items start as drafts and are published explicitly. */
|
|
131
143
|
drafts?: boolean;
|
|
144
|
+
/** `manual` (the property manager's drag order, the default) or `newest` (by publish date). */
|
|
132
145
|
order?: 'manual' | 'newest';
|
|
133
146
|
}
|
|
147
|
+
/** One item: a home-page banner. */
|
|
134
148
|
interface SectionDefinition extends TypeBase {
|
|
135
149
|
kind: 'section';
|
|
136
150
|
}
|
|
151
|
+
/** Extra fields every building or every area carries. */
|
|
137
152
|
interface FieldsDefinition extends TypeBase {
|
|
138
153
|
kind: 'fields';
|
|
139
154
|
attachesTo: 'building' | 'area';
|
|
140
155
|
}
|
|
141
156
|
type ContentTypeDefinition = CollectionDefinition | SectionDefinition | FieldsDefinition;
|
|
157
|
+
/** Keyed by type key: what the site's code reads it by (`blog`, `home_hero`). */
|
|
142
158
|
type ContentDefinition = Record<string, ContentTypeDefinition>;
|
|
159
|
+
/**
|
|
160
|
+
* Declare the site's content model. Returns the object unchanged; its exact type is what
|
|
161
|
+
* `createContentReader` reads values as.
|
|
162
|
+
*/
|
|
143
163
|
declare function defineContent<const T extends ContentDefinition>(definition: T): T;
|
|
164
|
+
/** Field builders. Each returns its options with the field's `type`. */
|
|
144
165
|
declare const field: {
|
|
145
166
|
text: <const O extends TextOptions>(o: O) => O & {
|
|
146
167
|
type: "text";
|
|
@@ -183,6 +204,7 @@ declare const field: {
|
|
|
183
204
|
type: "references";
|
|
184
205
|
};
|
|
185
206
|
};
|
|
207
|
+
/** A link value. `url` is `https://…` or a path on the site (`/stays`). */
|
|
186
208
|
interface ContentLink {
|
|
187
209
|
url: string;
|
|
188
210
|
label?: string;
|
|
@@ -190,6 +212,10 @@ interface ContentLink {
|
|
|
190
212
|
type OptionValue<C> = C extends string ? C : C extends {
|
|
191
213
|
value: infer V;
|
|
192
214
|
} ? V : never;
|
|
215
|
+
/**
|
|
216
|
+
* What a field reads as. Every single value can be null — not filled in yet, or no longer fitting
|
|
217
|
+
* the field after the site's code changed it — and lists are empty instead.
|
|
218
|
+
*/
|
|
193
219
|
type FieldValue<F> = F extends {
|
|
194
220
|
type: 'text' | 'rich_text' | 'date';
|
|
195
221
|
} ? string | null : F extends {
|
|
@@ -210,11 +236,13 @@ type FieldValue<F> = F extends {
|
|
|
210
236
|
} ? StorefrontContentRef | null : F extends {
|
|
211
237
|
type: 'references';
|
|
212
238
|
} ? StorefrontContentRef[] : unknown;
|
|
239
|
+
/** The values of one item of type `T`, by field key. */
|
|
213
240
|
type FieldsOf<T> = T extends {
|
|
214
241
|
fields: infer F;
|
|
215
242
|
} ? {
|
|
216
243
|
-readonly [K in keyof F]: FieldValue<F[K]>;
|
|
217
244
|
} : never;
|
|
245
|
+
/** One published item of type `K`. */
|
|
218
246
|
interface ItemOf<D, K extends keyof D> {
|
|
219
247
|
id: string;
|
|
220
248
|
slug: string | null;
|
|
@@ -231,8 +259,18 @@ type KeysOfKind<D, Kind> = {
|
|
|
231
259
|
type CollectionKeys<D> = KeysOfKind<D, 'collection'>;
|
|
232
260
|
type SectionKeys<D> = KeysOfKind<D, 'section'>;
|
|
233
261
|
type FieldsKeys<D> = KeysOfKind<D, 'fields'>;
|
|
262
|
+
/** The declaration as the Storefront API stores it (`{ version: 1, types: [...] }`). */
|
|
234
263
|
declare function toContentModel(definition: ContentDefinition): ContentModelInput;
|
|
264
|
+
/**
|
|
265
|
+
* {@link toContentModel}, checked against the rules the API applies (keys, a collection's title
|
|
266
|
+
* field, reference targets…). Throws an error naming each problem's path.
|
|
267
|
+
*/
|
|
235
268
|
declare function parseContentModel(definition: ContentDefinition): ContentModel;
|
|
269
|
+
/**
|
|
270
|
+
* Stored values as the declared fields read them: each one checked against its field's type, a
|
|
271
|
+
* missing or mistyped one as null (or `[]` for a list), undeclared keys dropped. A published site
|
|
272
|
+
* never breaks on a value its code no longer expects.
|
|
273
|
+
*/
|
|
236
274
|
declare function readFields<T extends ContentTypeDefinition>(type: T, values: Record<string, unknown> | null | undefined): FieldsOf<T>;
|
|
237
275
|
interface ContentReader<D extends ContentDefinition> {
|
|
238
276
|
collection<K extends CollectionKeys<D>>(key: K): {
|
|
@@ -240,15 +278,21 @@ interface ContentReader<D extends ContentDefinition> {
|
|
|
240
278
|
limit?: number;
|
|
241
279
|
offset?: number;
|
|
242
280
|
}, opts?: RequestOptions): Promise<Page<ItemOf<D, K>>>;
|
|
281
|
+
/** By slug or id; null when nothing published answers to it. */
|
|
243
282
|
get(slugOrId: string, opts?: RequestOptions): Promise<ItemOf<D, K> | null>;
|
|
244
283
|
};
|
|
245
284
|
section<K extends SectionKeys<D>>(key: K): {
|
|
246
285
|
get(opts?: RequestOptions): Promise<ItemOf<D, K>>;
|
|
247
286
|
};
|
|
287
|
+
/**
|
|
288
|
+
* The custom fields of type `key` on a building or an area the client returned
|
|
289
|
+
* (`client.buildings.get(id)`), typed; all empty when the record carries none.
|
|
290
|
+
*/
|
|
248
291
|
fieldsOf<K extends FieldsKeys<D>>(key: K, record: {
|
|
249
292
|
fields?: Record<string, Record<string, unknown>> | null;
|
|
250
293
|
}): FieldsOf<D[K]>;
|
|
251
294
|
}
|
|
295
|
+
/** Typed reads of the content `definition` declares, through `client`. */
|
|
252
296
|
declare function createContentReader<D extends ContentDefinition>(client: StorefrontClient, definition: D): ContentReader<D>;
|
|
253
297
|
|
|
254
298
|
export { type BooleanField, type CollectionDefinition, type CollectionKeys, type ContentDefinition, type ContentFieldDefinition, type ContentLink, type ContentReader, type ContentTypeDefinition, type DateField, type FieldValue, type FieldsDefinition, type FieldsKeys, type FieldsOf, type GalleryField, type ImageField, type ItemOf, type LinkField, type Localized, type NumberField, type OptionChoice, type OptionField, type ReferenceField, type ReferenceTarget, type ReferencesField, type RichTextField, type SectionDefinition, type SectionKeys, StorefrontContentRef, StorefrontImage, type TextField, contentModelSchema, createContentReader, defineContent, field, parseContentModel, readFields, toContentModel };
|
package/dist/content.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { contentModelSchema, createContentReader, defineContent, field, parseContentModel, readFields, toContentModel } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { contentModelSchema, createContentReader, defineContent, field, parseContentModel, readFields, toContentModel } from './chunk-3B6ZYRYF.js';
|
|
2
|
+
import './chunk-XOCFEVP4.js';
|
|
3
3
|
import './chunk-W5K7IDYN.js';
|
|
4
4
|
import './chunk-IBCBDAGY.js';
|
|
@@ -1,100 +1,131 @@
|
|
|
1
|
-
import { B as BookingResult, z as StorefrontQuote } from './client-
|
|
1
|
+
import { B as BookingResult, z as StorefrontQuote } from './client-s-lEwqzc.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
4
|
declare const storefrontClientEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
5
|
-
name: z.ZodLiteral<"page_view">;
|
|
6
5
|
eventId: z.ZodUUID;
|
|
7
6
|
ts: z.ZodNumber;
|
|
8
7
|
path: z.ZodString;
|
|
9
8
|
referrerHost: z.ZodNullable<z.ZodString>;
|
|
9
|
+
name: z.ZodLiteral<"page_view">;
|
|
10
10
|
}, z.core.$strip>, z.ZodObject<{
|
|
11
|
+
eventId: z.ZodUUID;
|
|
12
|
+
ts: z.ZodNumber;
|
|
13
|
+
path: z.ZodString;
|
|
14
|
+
referrerHost: z.ZodNullable<z.ZodString>;
|
|
11
15
|
name: z.ZodLiteral<"view_search_results">;
|
|
12
16
|
checkIn: z.ZodOptional<z.ZodISODate>;
|
|
13
17
|
checkOut: z.ZodOptional<z.ZodISODate>;
|
|
14
18
|
guests: z.ZodOptional<z.ZodNumber>;
|
|
15
19
|
locationId: z.ZodOptional<z.ZodUUID>;
|
|
20
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
16
21
|
eventId: z.ZodUUID;
|
|
17
22
|
ts: z.ZodNumber;
|
|
18
23
|
path: z.ZodString;
|
|
19
24
|
referrerHost: z.ZodNullable<z.ZodString>;
|
|
20
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
21
25
|
name: z.ZodLiteral<"view_item_list">;
|
|
22
26
|
listName: z.ZodString;
|
|
23
27
|
itemCount: z.ZodNumber;
|
|
28
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
24
29
|
eventId: z.ZodUUID;
|
|
25
30
|
ts: z.ZodNumber;
|
|
26
31
|
path: z.ZodString;
|
|
27
32
|
referrerHost: z.ZodNullable<z.ZodString>;
|
|
28
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
29
33
|
name: z.ZodLiteral<"view_item">;
|
|
30
34
|
listingId: z.ZodUUID;
|
|
35
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
31
36
|
eventId: z.ZodUUID;
|
|
32
37
|
ts: z.ZodNumber;
|
|
33
38
|
path: z.ZodString;
|
|
34
39
|
referrerHost: z.ZodNullable<z.ZodString>;
|
|
35
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
36
40
|
name: z.ZodLiteral<"view_quote">;
|
|
37
41
|
listingId: z.ZodUUID;
|
|
38
42
|
valueMinor: z.ZodNumber;
|
|
39
43
|
currency: z.ZodString;
|
|
40
44
|
nights: z.ZodNumber;
|
|
45
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
41
46
|
eventId: z.ZodUUID;
|
|
42
47
|
ts: z.ZodNumber;
|
|
43
48
|
path: z.ZodString;
|
|
44
49
|
referrerHost: z.ZodNullable<z.ZodString>;
|
|
45
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
46
50
|
name: z.ZodLiteral<"begin_checkout">;
|
|
47
51
|
checkoutSessionId: z.ZodUUID;
|
|
52
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
48
53
|
eventId: z.ZodUUID;
|
|
49
54
|
ts: z.ZodNumber;
|
|
50
55
|
path: z.ZodString;
|
|
51
56
|
referrerHost: z.ZodNullable<z.ZodString>;
|
|
52
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
53
57
|
name: z.ZodLiteral<"add_payment_info">;
|
|
54
58
|
checkoutSessionId: z.ZodUUID;
|
|
59
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
55
60
|
eventId: z.ZodUUID;
|
|
56
61
|
ts: z.ZodNumber;
|
|
57
62
|
path: z.ZodString;
|
|
58
63
|
referrerHost: z.ZodNullable<z.ZodString>;
|
|
59
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
60
64
|
name: z.ZodLiteral<"generate_lead">;
|
|
61
65
|
formId: z.ZodOptional<z.ZodString>;
|
|
66
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
62
67
|
eventId: z.ZodUUID;
|
|
63
68
|
ts: z.ZodNumber;
|
|
64
69
|
path: z.ZodString;
|
|
65
70
|
referrerHost: z.ZodNullable<z.ZodString>;
|
|
66
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
67
71
|
name: z.ZodLiteral<"sign_up">;
|
|
68
72
|
method: z.ZodLiteral<"newsletter">;
|
|
69
|
-
eventId: z.ZodUUID;
|
|
70
|
-
ts: z.ZodNumber;
|
|
71
|
-
path: z.ZodString;
|
|
72
|
-
referrerHost: z.ZodNullable<z.ZodString>;
|
|
73
73
|
}, z.core.$strip>], "name">;
|
|
74
74
|
type StorefrontClientEvent = z.infer<typeof storefrontClientEventSchema>;
|
|
75
75
|
|
|
76
76
|
type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
|
|
77
|
+
/**
|
|
78
|
+
* An event as a page tracks it: the SDK fills `eventId`, `ts`, `path` and `referrerHost`.
|
|
79
|
+
* `purchase` is not among them — revenue is written by the server when a booking confirms.
|
|
80
|
+
*/
|
|
77
81
|
type TrackEvent = DistributiveOmit<StorefrontClientEvent, 'eventId' | 'ts' | 'path' | 'referrerHost'>;
|
|
82
|
+
/** Called once per analytics instance, on the first failed send. */
|
|
78
83
|
type AnalyticsReporter = (err: unknown) => void;
|
|
79
84
|
interface AnalyticsOptions {
|
|
85
|
+
/** The site's publishable key — sent as `?key=` (`navigator.sendBeacon` cannot set headers). */
|
|
80
86
|
publishableKey: string;
|
|
81
87
|
report?: AnalyticsReporter;
|
|
82
88
|
}
|
|
83
89
|
interface StorefrontAnalytics {
|
|
84
90
|
track(event: TrackEvent): void;
|
|
91
|
+
/** A `page_view` of the current location. */
|
|
85
92
|
pageView(): void;
|
|
93
|
+
/** Send what is queued now; `beacon` for a page that is going away. */
|
|
86
94
|
flush(opts?: {
|
|
87
95
|
beacon?: boolean;
|
|
88
96
|
}): void;
|
|
89
97
|
dispose(): void;
|
|
90
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* The Meta Pixel `Purchase` for a confirmed booking, under ads consent only, with the booking
|
|
101
|
+
* request id as `eventID` — the same `event_id` the server's Conversions API purchase carries, so
|
|
102
|
+
* Meta keeps one. `value` / `currency` are sent when the caller has the amount (minor units,
|
|
103
|
+
* ×100). Never sent to gtag: GA4 and Google Ads get purchase from the server only.
|
|
104
|
+
*/
|
|
91
105
|
declare function trackPurchasePixel(booking: Pick<BookingResult, 'bookingRequestId'> & {
|
|
92
106
|
totalMinor?: number | null;
|
|
93
107
|
currency?: string | null;
|
|
94
108
|
}): void;
|
|
109
|
+
/**
|
|
110
|
+
* Storefront analytics: batches GA4-aligned events in memory and posts them to the
|
|
111
|
+
* storefront edge every 2 s, at 10 events, and on `pagehide` (`navigator.sendBeacon`, else
|
|
112
|
+
* `fetch` with `keepalive`). Sent regardless of consent: the edge stores labels only — no IP, no
|
|
113
|
+
* user agent, no identifier — and nothing here reads or writes a cookie or web storage. Each
|
|
114
|
+
* event is also mirrored to the site's client tags (`gtag` / `fbq`) when the consent allows.
|
|
115
|
+
* A 404 means the site is not behind the SuiteOp edge: the instance goes quiet.
|
|
116
|
+
*/
|
|
95
117
|
declare function createAnalytics(opts: AnalyticsOptions): StorefrontAnalytics;
|
|
118
|
+
/**
|
|
119
|
+
* The document's one analytics instance for a publishable key. It outlives any component — an
|
|
120
|
+
* Astro island unmounted by a view transition keeps its queue — and flushes on `pagehide`.
|
|
121
|
+
*/
|
|
96
122
|
declare function analyticsFor(publishableKey: string): StorefrontAnalytics;
|
|
97
123
|
|
|
124
|
+
/**
|
|
125
|
+
* Every `error.code` the Storefront API answers, the codes the SuiteOp storefront edge answers,
|
|
126
|
+
* and the SDK's own.
|
|
127
|
+
* `StorefrontError.code` stays `string`, so a code a newer API adds degrades, never throws.
|
|
128
|
+
*/
|
|
98
129
|
declare const STOREFRONT_ERROR_CODES: readonly ["wrong_region", "origin_not_allowed", "origin_required", "site_archived", "not_bookable", "quote_invalid", "quote_expired", "price_changed", "currency_unsupported", "payment_declined", "session_expired", "rate_limited", "contact_not_configured", "payment_account_unavailable", "idempotency_key_required", "idempotency_key_reused", "payment_mode_unsupported", "payment_not_authorized", "payment_method_required", "site_not_published", "preview_read_only", "bookings_closed", "extras_invalid", "UNAUTHORIZED", "VALIDATION_ERROR", "NOT_FOUND", "site_not_found", "upstream_timeout", "timeout", "network", "invalid_response", "internal_error", "checkout_unavailable"];
|
|
99
130
|
type StorefrontErrorCode = (typeof STOREFRONT_ERROR_CODES)[number];
|
|
100
131
|
type StorefrontRegion = 'us' | 'eu' | 'apac';
|
|
@@ -107,27 +138,36 @@ interface StorefrontErrorInit {
|
|
|
107
138
|
details?: Record<string, unknown>;
|
|
108
139
|
cause?: unknown;
|
|
109
140
|
}
|
|
141
|
+
/** Any failure the client reports: an API refusal, a malformed answer, a timeout, the network. */
|
|
110
142
|
declare class StorefrontError extends Error {
|
|
111
143
|
name: string;
|
|
144
|
+
/** HTTP status; 0 when no response arrived (timeout, network). */
|
|
112
145
|
readonly status: number;
|
|
113
146
|
readonly type: string;
|
|
147
|
+
/** `StorefrontErrorCode` for every code this version knows; any string for newer ones. */
|
|
114
148
|
readonly code: StorefrontErrorCode | (string & {});
|
|
115
149
|
readonly requestId: string | null;
|
|
116
150
|
readonly details: Record<string, unknown>;
|
|
117
151
|
constructor(init: StorefrontErrorInit);
|
|
118
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* `price_changed` (409). At checkout-session creation `quote` is the fresh quote to show the
|
|
155
|
+
* guest; at confirm it is null and `requiresNewSession` is true — start a new checkout.
|
|
156
|
+
*/
|
|
119
157
|
declare class PriceChangedError extends StorefrontError {
|
|
120
158
|
name: string;
|
|
121
159
|
readonly quote: StorefrontQuote | null;
|
|
122
160
|
readonly requiresNewSession: boolean;
|
|
123
161
|
constructor(init: StorefrontErrorInit);
|
|
124
162
|
}
|
|
163
|
+
/** `wrong_region` (421): the key belongs to another region. `baseUrl` is null when the API could not name it. */
|
|
125
164
|
declare class WrongRegionError extends StorefrontError {
|
|
126
165
|
name: string;
|
|
127
166
|
readonly region: StorefrontRegion | null;
|
|
128
167
|
readonly baseUrl: string | null;
|
|
129
168
|
constructor(init: StorefrontErrorInit);
|
|
130
169
|
}
|
|
170
|
+
/** `rate_limited` (429). `scope` names the budget: this key, this visitor's IP, or the PMS account. */
|
|
131
171
|
declare class RateLimitedError extends StorefrontError {
|
|
132
172
|
name: string;
|
|
133
173
|
readonly retryAfterSec: number | null;
|
|
@@ -144,6 +184,7 @@ declare class StorefrontNetworkError extends StorefrontError {
|
|
|
144
184
|
name: string;
|
|
145
185
|
constructor(cause: unknown);
|
|
146
186
|
}
|
|
187
|
+
/** A mistake in how the SDK is set up (bad key, bad base URL, hook outside its provider). */
|
|
147
188
|
declare class StorefrontConfigError extends Error {
|
|
148
189
|
name: string;
|
|
149
190
|
}
|