@suiteop/storefront 0.1.1 → 0.2.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 +29 -0
- package/README.md +74 -0
- package/dist/astro-content-model.cjs +17 -0
- package/dist/astro-content-model.d.cts +4 -0
- package/dist/astro-content-model.d.ts +4 -0
- package/dist/astro-content-model.js +10 -0
- package/dist/astro.cjs +3 -1
- package/dist/astro.d.cts +38 -17
- package/dist/astro.d.ts +38 -17
- package/dist/astro.js +2 -2
- package/dist/checkout.cjs +3 -3
- package/dist/checkout.js +2 -2
- package/dist/chunk-2U6L33AT.cjs +19 -0
- package/dist/chunk-4GZBXKBU.cjs +18 -0
- package/dist/chunk-GJSCEBSU.js +5 -0
- package/dist/chunk-HLGSWF4I.js +9 -0
- package/dist/{chunk-YFTWGF3L.js → chunk-HMLBMNGA.js} +1 -1
- package/dist/chunk-KKJCPKPY.js +8 -0
- package/dist/chunk-PYVUDQSQ.js +3 -0
- package/dist/chunk-USOISC2R.cjs +17 -0
- package/dist/{chunk-RDREYP27.cjs → chunk-VV2UNVQ2.cjs} +2 -2
- package/dist/chunk-ZHFZ6II2.cjs +16 -0
- package/dist/chunk-ZI2PG7LS.js +6 -0
- package/dist/chunk-ZLAOY6IF.cjs +9 -0
- package/dist/{errors-y-BiaVAk.d.cts → client-DER7y1WE.d.cts} +98 -147
- package/dist/{errors-Bp_jmXbA.d.ts → client-goQnVoLP.d.ts} +98 -147
- package/dist/components.cjs +1 -1
- package/dist/components.js +1 -1
- package/dist/config.cjs +6 -2
- package/dist/config.d.cts +33 -1
- package/dist/config.d.ts +33 -1
- package/dist/config.js +3 -2
- package/dist/content.cjs +37 -0
- package/dist/content.d.cts +254 -0
- package/dist/content.d.ts +254 -0
- package/dist/content.js +4 -0
- package/dist/errors-B2eCo5Cz.d.cts +151 -0
- package/dist/errors-D-dULpp1.d.ts +151 -0
- package/dist/index.cjs +21 -20
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +4 -3
- package/dist/react.cjs +6 -5
- package/dist/react.d.cts +2 -1
- package/dist/react.d.ts +2 -1
- package/dist/react.js +5 -4
- package/package.json +22 -2
- package/dist/chunk-AIQUVZEI.cjs +0 -8
- package/dist/chunk-GIIXCS6X.cjs +0 -18
- package/dist/chunk-LIBKUMJV.js +0 -8
- package/dist/chunk-SK5TD73J.js +0 -3
- package/dist/chunk-UACP7BZ7.js +0 -6
- package/dist/chunk-XIAAWHAY.cjs +0 -17
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { R as RequestOptions, P as Page, q as StorefrontImage, o as StorefrontContentRef, j as StorefrontClient } from './client-DER7y1WE.cjs';
|
|
2
|
+
export { m as StorefrontContentItem } from './client-DER7y1WE.cjs';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import './availability-CnzmxuV3.cjs';
|
|
5
|
+
|
|
6
|
+
declare const contentLocalizedSchema: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
7
|
+
type ContentLocalized = z.infer<typeof contentLocalizedSchema>;
|
|
8
|
+
declare const contentModelSchema: z.ZodObject<{
|
|
9
|
+
version: z.ZodLiteral<1>;
|
|
10
|
+
types: z.ZodArray<z.ZodObject<{
|
|
11
|
+
key: z.ZodString;
|
|
12
|
+
kind: z.ZodEnum<{
|
|
13
|
+
fields: "fields";
|
|
14
|
+
collection: "collection";
|
|
15
|
+
section: "section";
|
|
16
|
+
}>;
|
|
17
|
+
label: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
18
|
+
description: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
19
|
+
attachesTo: z.ZodOptional<z.ZodEnum<{
|
|
20
|
+
area: "area";
|
|
21
|
+
building: "building";
|
|
22
|
+
}>>;
|
|
23
|
+
titleField: z.ZodOptional<z.ZodString>;
|
|
24
|
+
routable: z.ZodDefault<z.ZodBoolean>;
|
|
25
|
+
drafts: z.ZodDefault<z.ZodBoolean>;
|
|
26
|
+
order: z.ZodDefault<z.ZodEnum<{
|
|
27
|
+
manual: "manual";
|
|
28
|
+
newest: "newest";
|
|
29
|
+
}>>;
|
|
30
|
+
fields: z.ZodArray<z.ZodObject<{
|
|
31
|
+
key: z.ZodString;
|
|
32
|
+
type: z.ZodEnum<{
|
|
33
|
+
number: "number";
|
|
34
|
+
boolean: "boolean";
|
|
35
|
+
rich_text: "rich_text";
|
|
36
|
+
link: "link";
|
|
37
|
+
text: "text";
|
|
38
|
+
date: "date";
|
|
39
|
+
image: "image";
|
|
40
|
+
gallery: "gallery";
|
|
41
|
+
option: "option";
|
|
42
|
+
reference: "reference";
|
|
43
|
+
references: "references";
|
|
44
|
+
}>;
|
|
45
|
+
label: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
46
|
+
help: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
47
|
+
required: z.ZodDefault<z.ZodBoolean>;
|
|
48
|
+
translatable: z.ZodOptional<z.ZodBoolean>;
|
|
49
|
+
maxLength: z.ZodOptional<z.ZodNumber>;
|
|
50
|
+
options: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
51
|
+
value: z.ZodString;
|
|
52
|
+
label: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
53
|
+
}, z.core.$strip>>>;
|
|
54
|
+
to: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
55
|
+
area: "area";
|
|
56
|
+
building: "building";
|
|
57
|
+
listing: "listing";
|
|
58
|
+
}>, z.ZodString]>>;
|
|
59
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
60
|
+
removed: z.ZodOptional<z.ZodBoolean>;
|
|
61
|
+
}, z.core.$strip>>;
|
|
62
|
+
}, z.core.$strip>>;
|
|
63
|
+
}, z.core.$strip>;
|
|
64
|
+
type ContentModel = z.infer<typeof contentModelSchema>;
|
|
65
|
+
type ContentModelInput = z.input<typeof contentModelSchema>;
|
|
66
|
+
|
|
67
|
+
type Localized = ContentLocalized;
|
|
68
|
+
interface FieldBase {
|
|
69
|
+
label: Localized;
|
|
70
|
+
help?: Localized;
|
|
71
|
+
required?: boolean;
|
|
72
|
+
}
|
|
73
|
+
interface TextOptions extends FieldBase {
|
|
74
|
+
translatable?: boolean;
|
|
75
|
+
maxLength?: number;
|
|
76
|
+
}
|
|
77
|
+
interface ListOptions extends FieldBase {
|
|
78
|
+
max?: number;
|
|
79
|
+
}
|
|
80
|
+
type ReferenceTarget = 'listing' | 'building' | 'area' | `collection:${string}`;
|
|
81
|
+
type OptionChoice<V extends string = string> = V | {
|
|
82
|
+
value: V;
|
|
83
|
+
label: Localized;
|
|
84
|
+
};
|
|
85
|
+
type TextField = TextOptions & {
|
|
86
|
+
type: 'text';
|
|
87
|
+
};
|
|
88
|
+
type RichTextField = TextOptions & {
|
|
89
|
+
type: 'rich_text';
|
|
90
|
+
};
|
|
91
|
+
type ImageField = FieldBase & {
|
|
92
|
+
type: 'image';
|
|
93
|
+
};
|
|
94
|
+
type GalleryField = ListOptions & {
|
|
95
|
+
type: 'gallery';
|
|
96
|
+
};
|
|
97
|
+
type NumberField = FieldBase & {
|
|
98
|
+
type: 'number';
|
|
99
|
+
};
|
|
100
|
+
type BooleanField = FieldBase & {
|
|
101
|
+
type: 'boolean';
|
|
102
|
+
};
|
|
103
|
+
type DateField = FieldBase & {
|
|
104
|
+
type: 'date';
|
|
105
|
+
};
|
|
106
|
+
type OptionField<V extends string = string> = FieldBase & {
|
|
107
|
+
type: 'option';
|
|
108
|
+
options: readonly OptionChoice<V>[];
|
|
109
|
+
};
|
|
110
|
+
type LinkField = FieldBase & {
|
|
111
|
+
type: 'link';
|
|
112
|
+
};
|
|
113
|
+
type ReferenceField = FieldBase & {
|
|
114
|
+
type: 'reference';
|
|
115
|
+
to: ReferenceTarget;
|
|
116
|
+
};
|
|
117
|
+
type ReferencesField = ListOptions & {
|
|
118
|
+
type: 'references';
|
|
119
|
+
to: ReferenceTarget;
|
|
120
|
+
};
|
|
121
|
+
type ContentFieldDefinition = TextField | RichTextField | ImageField | GalleryField | NumberField | BooleanField | DateField | OptionField | LinkField | ReferenceField | ReferencesField;
|
|
122
|
+
interface TypeBase {
|
|
123
|
+
label: Localized;
|
|
124
|
+
description?: Localized;
|
|
125
|
+
fields: Record<string, ContentFieldDefinition>;
|
|
126
|
+
}
|
|
127
|
+
interface CollectionDefinition extends TypeBase {
|
|
128
|
+
kind: 'collection';
|
|
129
|
+
titleField: string;
|
|
130
|
+
routable?: boolean;
|
|
131
|
+
drafts?: boolean;
|
|
132
|
+
order?: 'manual' | 'newest';
|
|
133
|
+
}
|
|
134
|
+
interface SectionDefinition extends TypeBase {
|
|
135
|
+
kind: 'section';
|
|
136
|
+
}
|
|
137
|
+
interface FieldsDefinition extends TypeBase {
|
|
138
|
+
kind: 'fields';
|
|
139
|
+
attachesTo: 'building' | 'area';
|
|
140
|
+
}
|
|
141
|
+
type ContentTypeDefinition = CollectionDefinition | SectionDefinition | FieldsDefinition;
|
|
142
|
+
type ContentDefinition = Record<string, ContentTypeDefinition>;
|
|
143
|
+
declare function defineContent<const T extends ContentDefinition>(definition: T): T;
|
|
144
|
+
declare const field: {
|
|
145
|
+
text: <const O extends TextOptions>(o: O) => O & {
|
|
146
|
+
type: "text";
|
|
147
|
+
};
|
|
148
|
+
richText: <const O extends TextOptions>(o: O) => O & {
|
|
149
|
+
type: "rich_text";
|
|
150
|
+
};
|
|
151
|
+
image: <const O extends FieldBase>(o: O) => O & {
|
|
152
|
+
type: "image";
|
|
153
|
+
};
|
|
154
|
+
gallery: <const O extends ListOptions>(o: O) => O & {
|
|
155
|
+
type: "gallery";
|
|
156
|
+
};
|
|
157
|
+
number: <const O extends FieldBase>(o: O) => O & {
|
|
158
|
+
type: "number";
|
|
159
|
+
};
|
|
160
|
+
boolean: <const O extends FieldBase>(o: O) => O & {
|
|
161
|
+
type: "boolean";
|
|
162
|
+
};
|
|
163
|
+
date: <const O extends FieldBase>(o: O) => O & {
|
|
164
|
+
type: "date";
|
|
165
|
+
};
|
|
166
|
+
option: <const V extends string, const O extends FieldBase>(o: O & {
|
|
167
|
+
options: readonly OptionChoice<V>[];
|
|
168
|
+
}) => O & {
|
|
169
|
+
type: "option";
|
|
170
|
+
options: readonly OptionChoice<V>[];
|
|
171
|
+
};
|
|
172
|
+
link: <const O extends FieldBase>(o: O) => O & {
|
|
173
|
+
type: "link";
|
|
174
|
+
};
|
|
175
|
+
reference: <const O extends FieldBase & {
|
|
176
|
+
to: ReferenceTarget;
|
|
177
|
+
}>(o: O) => O & {
|
|
178
|
+
type: "reference";
|
|
179
|
+
};
|
|
180
|
+
references: <const O extends ListOptions & {
|
|
181
|
+
to: ReferenceTarget;
|
|
182
|
+
}>(o: O) => O & {
|
|
183
|
+
type: "references";
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
interface ContentLink {
|
|
187
|
+
url: string;
|
|
188
|
+
label?: string;
|
|
189
|
+
}
|
|
190
|
+
type OptionValue<C> = C extends string ? C : C extends {
|
|
191
|
+
value: infer V;
|
|
192
|
+
} ? V : never;
|
|
193
|
+
type FieldValue<F> = F extends {
|
|
194
|
+
type: 'text' | 'rich_text' | 'date';
|
|
195
|
+
} ? string | null : F extends {
|
|
196
|
+
type: 'image';
|
|
197
|
+
} ? StorefrontImage | null : F extends {
|
|
198
|
+
type: 'gallery';
|
|
199
|
+
} ? StorefrontImage[] : F extends {
|
|
200
|
+
type: 'number';
|
|
201
|
+
} ? number | null : F extends {
|
|
202
|
+
type: 'boolean';
|
|
203
|
+
} ? boolean | null : F extends {
|
|
204
|
+
type: 'option';
|
|
205
|
+
options: readonly (infer C)[];
|
|
206
|
+
} ? OptionValue<C> | null : F extends {
|
|
207
|
+
type: 'link';
|
|
208
|
+
} ? ContentLink | null : F extends {
|
|
209
|
+
type: 'reference';
|
|
210
|
+
} ? StorefrontContentRef | null : F extends {
|
|
211
|
+
type: 'references';
|
|
212
|
+
} ? StorefrontContentRef[] : unknown;
|
|
213
|
+
type FieldsOf<T> = T extends {
|
|
214
|
+
fields: infer F;
|
|
215
|
+
} ? {
|
|
216
|
+
-readonly [K in keyof F]: FieldValue<F[K]>;
|
|
217
|
+
} : never;
|
|
218
|
+
interface ItemOf<D, K extends keyof D> {
|
|
219
|
+
id: string;
|
|
220
|
+
slug: string | null;
|
|
221
|
+
publishedAt: string | null;
|
|
222
|
+
updatedAt: string;
|
|
223
|
+
sortOrder: number;
|
|
224
|
+
fields: FieldsOf<D[K]>;
|
|
225
|
+
}
|
|
226
|
+
type KeysOfKind<D, Kind> = {
|
|
227
|
+
[K in keyof D]: D[K] extends {
|
|
228
|
+
kind: Kind;
|
|
229
|
+
} ? K : never;
|
|
230
|
+
}[keyof D] & string;
|
|
231
|
+
type CollectionKeys<D> = KeysOfKind<D, 'collection'>;
|
|
232
|
+
type SectionKeys<D> = KeysOfKind<D, 'section'>;
|
|
233
|
+
type FieldsKeys<D> = KeysOfKind<D, 'fields'>;
|
|
234
|
+
declare function toContentModel(definition: ContentDefinition): ContentModelInput;
|
|
235
|
+
declare function parseContentModel(definition: ContentDefinition): ContentModel;
|
|
236
|
+
declare function readFields<T extends ContentTypeDefinition>(type: T, values: Record<string, unknown> | null | undefined): FieldsOf<T>;
|
|
237
|
+
interface ContentReader<D extends ContentDefinition> {
|
|
238
|
+
collection<K extends CollectionKeys<D>>(key: K): {
|
|
239
|
+
list(query?: {
|
|
240
|
+
limit?: number;
|
|
241
|
+
offset?: number;
|
|
242
|
+
}, opts?: RequestOptions): Promise<Page<ItemOf<D, K>>>;
|
|
243
|
+
get(slugOrId: string, opts?: RequestOptions): Promise<ItemOf<D, K> | null>;
|
|
244
|
+
};
|
|
245
|
+
section<K extends SectionKeys<D>>(key: K): {
|
|
246
|
+
get(opts?: RequestOptions): Promise<ItemOf<D, K>>;
|
|
247
|
+
};
|
|
248
|
+
fieldsOf<K extends FieldsKeys<D>>(key: K, record: {
|
|
249
|
+
fields?: Record<string, Record<string, unknown>> | null;
|
|
250
|
+
}): FieldsOf<D[K]>;
|
|
251
|
+
}
|
|
252
|
+
declare function createContentReader<D extends ContentDefinition>(client: StorefrontClient, definition: D): ContentReader<D>;
|
|
253
|
+
|
|
254
|
+
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 };
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { R as RequestOptions, P as Page, q as StorefrontImage, o as StorefrontContentRef, j as StorefrontClient } from './client-goQnVoLP.js';
|
|
2
|
+
export { m as StorefrontContentItem } from './client-goQnVoLP.js';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import './availability-CnzmxuV3.js';
|
|
5
|
+
|
|
6
|
+
declare const contentLocalizedSchema: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
7
|
+
type ContentLocalized = z.infer<typeof contentLocalizedSchema>;
|
|
8
|
+
declare const contentModelSchema: z.ZodObject<{
|
|
9
|
+
version: z.ZodLiteral<1>;
|
|
10
|
+
types: z.ZodArray<z.ZodObject<{
|
|
11
|
+
key: z.ZodString;
|
|
12
|
+
kind: z.ZodEnum<{
|
|
13
|
+
fields: "fields";
|
|
14
|
+
collection: "collection";
|
|
15
|
+
section: "section";
|
|
16
|
+
}>;
|
|
17
|
+
label: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
18
|
+
description: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
19
|
+
attachesTo: z.ZodOptional<z.ZodEnum<{
|
|
20
|
+
area: "area";
|
|
21
|
+
building: "building";
|
|
22
|
+
}>>;
|
|
23
|
+
titleField: z.ZodOptional<z.ZodString>;
|
|
24
|
+
routable: z.ZodDefault<z.ZodBoolean>;
|
|
25
|
+
drafts: z.ZodDefault<z.ZodBoolean>;
|
|
26
|
+
order: z.ZodDefault<z.ZodEnum<{
|
|
27
|
+
manual: "manual";
|
|
28
|
+
newest: "newest";
|
|
29
|
+
}>>;
|
|
30
|
+
fields: z.ZodArray<z.ZodObject<{
|
|
31
|
+
key: z.ZodString;
|
|
32
|
+
type: z.ZodEnum<{
|
|
33
|
+
number: "number";
|
|
34
|
+
boolean: "boolean";
|
|
35
|
+
rich_text: "rich_text";
|
|
36
|
+
link: "link";
|
|
37
|
+
text: "text";
|
|
38
|
+
date: "date";
|
|
39
|
+
image: "image";
|
|
40
|
+
gallery: "gallery";
|
|
41
|
+
option: "option";
|
|
42
|
+
reference: "reference";
|
|
43
|
+
references: "references";
|
|
44
|
+
}>;
|
|
45
|
+
label: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
46
|
+
help: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
47
|
+
required: z.ZodDefault<z.ZodBoolean>;
|
|
48
|
+
translatable: z.ZodOptional<z.ZodBoolean>;
|
|
49
|
+
maxLength: z.ZodOptional<z.ZodNumber>;
|
|
50
|
+
options: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
51
|
+
value: z.ZodString;
|
|
52
|
+
label: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
53
|
+
}, z.core.$strip>>>;
|
|
54
|
+
to: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
55
|
+
area: "area";
|
|
56
|
+
building: "building";
|
|
57
|
+
listing: "listing";
|
|
58
|
+
}>, z.ZodString]>>;
|
|
59
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
60
|
+
removed: z.ZodOptional<z.ZodBoolean>;
|
|
61
|
+
}, z.core.$strip>>;
|
|
62
|
+
}, z.core.$strip>>;
|
|
63
|
+
}, z.core.$strip>;
|
|
64
|
+
type ContentModel = z.infer<typeof contentModelSchema>;
|
|
65
|
+
type ContentModelInput = z.input<typeof contentModelSchema>;
|
|
66
|
+
|
|
67
|
+
type Localized = ContentLocalized;
|
|
68
|
+
interface FieldBase {
|
|
69
|
+
label: Localized;
|
|
70
|
+
help?: Localized;
|
|
71
|
+
required?: boolean;
|
|
72
|
+
}
|
|
73
|
+
interface TextOptions extends FieldBase {
|
|
74
|
+
translatable?: boolean;
|
|
75
|
+
maxLength?: number;
|
|
76
|
+
}
|
|
77
|
+
interface ListOptions extends FieldBase {
|
|
78
|
+
max?: number;
|
|
79
|
+
}
|
|
80
|
+
type ReferenceTarget = 'listing' | 'building' | 'area' | `collection:${string}`;
|
|
81
|
+
type OptionChoice<V extends string = string> = V | {
|
|
82
|
+
value: V;
|
|
83
|
+
label: Localized;
|
|
84
|
+
};
|
|
85
|
+
type TextField = TextOptions & {
|
|
86
|
+
type: 'text';
|
|
87
|
+
};
|
|
88
|
+
type RichTextField = TextOptions & {
|
|
89
|
+
type: 'rich_text';
|
|
90
|
+
};
|
|
91
|
+
type ImageField = FieldBase & {
|
|
92
|
+
type: 'image';
|
|
93
|
+
};
|
|
94
|
+
type GalleryField = ListOptions & {
|
|
95
|
+
type: 'gallery';
|
|
96
|
+
};
|
|
97
|
+
type NumberField = FieldBase & {
|
|
98
|
+
type: 'number';
|
|
99
|
+
};
|
|
100
|
+
type BooleanField = FieldBase & {
|
|
101
|
+
type: 'boolean';
|
|
102
|
+
};
|
|
103
|
+
type DateField = FieldBase & {
|
|
104
|
+
type: 'date';
|
|
105
|
+
};
|
|
106
|
+
type OptionField<V extends string = string> = FieldBase & {
|
|
107
|
+
type: 'option';
|
|
108
|
+
options: readonly OptionChoice<V>[];
|
|
109
|
+
};
|
|
110
|
+
type LinkField = FieldBase & {
|
|
111
|
+
type: 'link';
|
|
112
|
+
};
|
|
113
|
+
type ReferenceField = FieldBase & {
|
|
114
|
+
type: 'reference';
|
|
115
|
+
to: ReferenceTarget;
|
|
116
|
+
};
|
|
117
|
+
type ReferencesField = ListOptions & {
|
|
118
|
+
type: 'references';
|
|
119
|
+
to: ReferenceTarget;
|
|
120
|
+
};
|
|
121
|
+
type ContentFieldDefinition = TextField | RichTextField | ImageField | GalleryField | NumberField | BooleanField | DateField | OptionField | LinkField | ReferenceField | ReferencesField;
|
|
122
|
+
interface TypeBase {
|
|
123
|
+
label: Localized;
|
|
124
|
+
description?: Localized;
|
|
125
|
+
fields: Record<string, ContentFieldDefinition>;
|
|
126
|
+
}
|
|
127
|
+
interface CollectionDefinition extends TypeBase {
|
|
128
|
+
kind: 'collection';
|
|
129
|
+
titleField: string;
|
|
130
|
+
routable?: boolean;
|
|
131
|
+
drafts?: boolean;
|
|
132
|
+
order?: 'manual' | 'newest';
|
|
133
|
+
}
|
|
134
|
+
interface SectionDefinition extends TypeBase {
|
|
135
|
+
kind: 'section';
|
|
136
|
+
}
|
|
137
|
+
interface FieldsDefinition extends TypeBase {
|
|
138
|
+
kind: 'fields';
|
|
139
|
+
attachesTo: 'building' | 'area';
|
|
140
|
+
}
|
|
141
|
+
type ContentTypeDefinition = CollectionDefinition | SectionDefinition | FieldsDefinition;
|
|
142
|
+
type ContentDefinition = Record<string, ContentTypeDefinition>;
|
|
143
|
+
declare function defineContent<const T extends ContentDefinition>(definition: T): T;
|
|
144
|
+
declare const field: {
|
|
145
|
+
text: <const O extends TextOptions>(o: O) => O & {
|
|
146
|
+
type: "text";
|
|
147
|
+
};
|
|
148
|
+
richText: <const O extends TextOptions>(o: O) => O & {
|
|
149
|
+
type: "rich_text";
|
|
150
|
+
};
|
|
151
|
+
image: <const O extends FieldBase>(o: O) => O & {
|
|
152
|
+
type: "image";
|
|
153
|
+
};
|
|
154
|
+
gallery: <const O extends ListOptions>(o: O) => O & {
|
|
155
|
+
type: "gallery";
|
|
156
|
+
};
|
|
157
|
+
number: <const O extends FieldBase>(o: O) => O & {
|
|
158
|
+
type: "number";
|
|
159
|
+
};
|
|
160
|
+
boolean: <const O extends FieldBase>(o: O) => O & {
|
|
161
|
+
type: "boolean";
|
|
162
|
+
};
|
|
163
|
+
date: <const O extends FieldBase>(o: O) => O & {
|
|
164
|
+
type: "date";
|
|
165
|
+
};
|
|
166
|
+
option: <const V extends string, const O extends FieldBase>(o: O & {
|
|
167
|
+
options: readonly OptionChoice<V>[];
|
|
168
|
+
}) => O & {
|
|
169
|
+
type: "option";
|
|
170
|
+
options: readonly OptionChoice<V>[];
|
|
171
|
+
};
|
|
172
|
+
link: <const O extends FieldBase>(o: O) => O & {
|
|
173
|
+
type: "link";
|
|
174
|
+
};
|
|
175
|
+
reference: <const O extends FieldBase & {
|
|
176
|
+
to: ReferenceTarget;
|
|
177
|
+
}>(o: O) => O & {
|
|
178
|
+
type: "reference";
|
|
179
|
+
};
|
|
180
|
+
references: <const O extends ListOptions & {
|
|
181
|
+
to: ReferenceTarget;
|
|
182
|
+
}>(o: O) => O & {
|
|
183
|
+
type: "references";
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
interface ContentLink {
|
|
187
|
+
url: string;
|
|
188
|
+
label?: string;
|
|
189
|
+
}
|
|
190
|
+
type OptionValue<C> = C extends string ? C : C extends {
|
|
191
|
+
value: infer V;
|
|
192
|
+
} ? V : never;
|
|
193
|
+
type FieldValue<F> = F extends {
|
|
194
|
+
type: 'text' | 'rich_text' | 'date';
|
|
195
|
+
} ? string | null : F extends {
|
|
196
|
+
type: 'image';
|
|
197
|
+
} ? StorefrontImage | null : F extends {
|
|
198
|
+
type: 'gallery';
|
|
199
|
+
} ? StorefrontImage[] : F extends {
|
|
200
|
+
type: 'number';
|
|
201
|
+
} ? number | null : F extends {
|
|
202
|
+
type: 'boolean';
|
|
203
|
+
} ? boolean | null : F extends {
|
|
204
|
+
type: 'option';
|
|
205
|
+
options: readonly (infer C)[];
|
|
206
|
+
} ? OptionValue<C> | null : F extends {
|
|
207
|
+
type: 'link';
|
|
208
|
+
} ? ContentLink | null : F extends {
|
|
209
|
+
type: 'reference';
|
|
210
|
+
} ? StorefrontContentRef | null : F extends {
|
|
211
|
+
type: 'references';
|
|
212
|
+
} ? StorefrontContentRef[] : unknown;
|
|
213
|
+
type FieldsOf<T> = T extends {
|
|
214
|
+
fields: infer F;
|
|
215
|
+
} ? {
|
|
216
|
+
-readonly [K in keyof F]: FieldValue<F[K]>;
|
|
217
|
+
} : never;
|
|
218
|
+
interface ItemOf<D, K extends keyof D> {
|
|
219
|
+
id: string;
|
|
220
|
+
slug: string | null;
|
|
221
|
+
publishedAt: string | null;
|
|
222
|
+
updatedAt: string;
|
|
223
|
+
sortOrder: number;
|
|
224
|
+
fields: FieldsOf<D[K]>;
|
|
225
|
+
}
|
|
226
|
+
type KeysOfKind<D, Kind> = {
|
|
227
|
+
[K in keyof D]: D[K] extends {
|
|
228
|
+
kind: Kind;
|
|
229
|
+
} ? K : never;
|
|
230
|
+
}[keyof D] & string;
|
|
231
|
+
type CollectionKeys<D> = KeysOfKind<D, 'collection'>;
|
|
232
|
+
type SectionKeys<D> = KeysOfKind<D, 'section'>;
|
|
233
|
+
type FieldsKeys<D> = KeysOfKind<D, 'fields'>;
|
|
234
|
+
declare function toContentModel(definition: ContentDefinition): ContentModelInput;
|
|
235
|
+
declare function parseContentModel(definition: ContentDefinition): ContentModel;
|
|
236
|
+
declare function readFields<T extends ContentTypeDefinition>(type: T, values: Record<string, unknown> | null | undefined): FieldsOf<T>;
|
|
237
|
+
interface ContentReader<D extends ContentDefinition> {
|
|
238
|
+
collection<K extends CollectionKeys<D>>(key: K): {
|
|
239
|
+
list(query?: {
|
|
240
|
+
limit?: number;
|
|
241
|
+
offset?: number;
|
|
242
|
+
}, opts?: RequestOptions): Promise<Page<ItemOf<D, K>>>;
|
|
243
|
+
get(slugOrId: string, opts?: RequestOptions): Promise<ItemOf<D, K> | null>;
|
|
244
|
+
};
|
|
245
|
+
section<K extends SectionKeys<D>>(key: K): {
|
|
246
|
+
get(opts?: RequestOptions): Promise<ItemOf<D, K>>;
|
|
247
|
+
};
|
|
248
|
+
fieldsOf<K extends FieldsKeys<D>>(key: K, record: {
|
|
249
|
+
fields?: Record<string, Record<string, unknown>> | null;
|
|
250
|
+
}): FieldsOf<D[K]>;
|
|
251
|
+
}
|
|
252
|
+
declare function createContentReader<D extends ContentDefinition>(client: StorefrontClient, definition: D): ContentReader<D>;
|
|
253
|
+
|
|
254
|
+
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
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { B as BookingResult, v as StorefrontQuote } from './client-DER7y1WE.cjs';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
declare const storefrontClientEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
5
|
+
name: z.ZodLiteral<"page_view">;
|
|
6
|
+
eventId: z.ZodUUID;
|
|
7
|
+
ts: z.ZodNumber;
|
|
8
|
+
path: z.ZodString;
|
|
9
|
+
referrerHost: z.ZodNullable<z.ZodString>;
|
|
10
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
11
|
+
name: z.ZodLiteral<"view_search_results">;
|
|
12
|
+
checkIn: z.ZodOptional<z.ZodISODate>;
|
|
13
|
+
checkOut: z.ZodOptional<z.ZodISODate>;
|
|
14
|
+
guests: z.ZodOptional<z.ZodNumber>;
|
|
15
|
+
locationId: z.ZodOptional<z.ZodUUID>;
|
|
16
|
+
eventId: z.ZodUUID;
|
|
17
|
+
ts: z.ZodNumber;
|
|
18
|
+
path: z.ZodString;
|
|
19
|
+
referrerHost: z.ZodNullable<z.ZodString>;
|
|
20
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
21
|
+
name: z.ZodLiteral<"view_item_list">;
|
|
22
|
+
listName: z.ZodString;
|
|
23
|
+
itemCount: z.ZodNumber;
|
|
24
|
+
eventId: z.ZodUUID;
|
|
25
|
+
ts: z.ZodNumber;
|
|
26
|
+
path: z.ZodString;
|
|
27
|
+
referrerHost: z.ZodNullable<z.ZodString>;
|
|
28
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
29
|
+
name: z.ZodLiteral<"view_item">;
|
|
30
|
+
listingId: z.ZodUUID;
|
|
31
|
+
eventId: z.ZodUUID;
|
|
32
|
+
ts: z.ZodNumber;
|
|
33
|
+
path: z.ZodString;
|
|
34
|
+
referrerHost: z.ZodNullable<z.ZodString>;
|
|
35
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
36
|
+
name: z.ZodLiteral<"view_quote">;
|
|
37
|
+
listingId: z.ZodUUID;
|
|
38
|
+
valueMinor: z.ZodNumber;
|
|
39
|
+
currency: z.ZodString;
|
|
40
|
+
nights: z.ZodNumber;
|
|
41
|
+
eventId: z.ZodUUID;
|
|
42
|
+
ts: z.ZodNumber;
|
|
43
|
+
path: z.ZodString;
|
|
44
|
+
referrerHost: z.ZodNullable<z.ZodString>;
|
|
45
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
46
|
+
name: z.ZodLiteral<"begin_checkout">;
|
|
47
|
+
checkoutSessionId: z.ZodUUID;
|
|
48
|
+
eventId: z.ZodUUID;
|
|
49
|
+
ts: z.ZodNumber;
|
|
50
|
+
path: z.ZodString;
|
|
51
|
+
referrerHost: z.ZodNullable<z.ZodString>;
|
|
52
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
53
|
+
name: z.ZodLiteral<"add_payment_info">;
|
|
54
|
+
checkoutSessionId: z.ZodUUID;
|
|
55
|
+
eventId: z.ZodUUID;
|
|
56
|
+
ts: z.ZodNumber;
|
|
57
|
+
path: z.ZodString;
|
|
58
|
+
referrerHost: z.ZodNullable<z.ZodString>;
|
|
59
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
60
|
+
name: z.ZodLiteral<"generate_lead">;
|
|
61
|
+
formId: z.ZodOptional<z.ZodString>;
|
|
62
|
+
eventId: z.ZodUUID;
|
|
63
|
+
ts: z.ZodNumber;
|
|
64
|
+
path: z.ZodString;
|
|
65
|
+
referrerHost: z.ZodNullable<z.ZodString>;
|
|
66
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
67
|
+
name: z.ZodLiteral<"sign_up">;
|
|
68
|
+
method: z.ZodLiteral<"newsletter">;
|
|
69
|
+
eventId: z.ZodUUID;
|
|
70
|
+
ts: z.ZodNumber;
|
|
71
|
+
path: z.ZodString;
|
|
72
|
+
referrerHost: z.ZodNullable<z.ZodString>;
|
|
73
|
+
}, z.core.$strip>], "name">;
|
|
74
|
+
type StorefrontClientEvent = z.infer<typeof storefrontClientEventSchema>;
|
|
75
|
+
|
|
76
|
+
type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
|
|
77
|
+
type TrackEvent = DistributiveOmit<StorefrontClientEvent, 'eventId' | 'ts' | 'path' | 'referrerHost'>;
|
|
78
|
+
type AnalyticsReporter = (err: unknown) => void;
|
|
79
|
+
interface AnalyticsOptions {
|
|
80
|
+
publishableKey: string;
|
|
81
|
+
report?: AnalyticsReporter;
|
|
82
|
+
}
|
|
83
|
+
interface StorefrontAnalytics {
|
|
84
|
+
track(event: TrackEvent): void;
|
|
85
|
+
pageView(): void;
|
|
86
|
+
flush(opts?: {
|
|
87
|
+
beacon?: boolean;
|
|
88
|
+
}): void;
|
|
89
|
+
dispose(): void;
|
|
90
|
+
}
|
|
91
|
+
declare function trackPurchasePixel(booking: Pick<BookingResult, 'bookingRequestId'> & {
|
|
92
|
+
totalMinor?: number | null;
|
|
93
|
+
currency?: string | null;
|
|
94
|
+
}): void;
|
|
95
|
+
declare function createAnalytics(opts: AnalyticsOptions): StorefrontAnalytics;
|
|
96
|
+
declare function analyticsFor(publishableKey: string): StorefrontAnalytics;
|
|
97
|
+
|
|
98
|
+
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
|
+
type StorefrontErrorCode = (typeof STOREFRONT_ERROR_CODES)[number];
|
|
100
|
+
type StorefrontRegion = 'us' | 'eu' | 'apac';
|
|
101
|
+
interface StorefrontErrorInit {
|
|
102
|
+
status: number;
|
|
103
|
+
code: string;
|
|
104
|
+
message: string;
|
|
105
|
+
type?: string;
|
|
106
|
+
requestId?: string | null;
|
|
107
|
+
details?: Record<string, unknown>;
|
|
108
|
+
cause?: unknown;
|
|
109
|
+
}
|
|
110
|
+
declare class StorefrontError extends Error {
|
|
111
|
+
name: string;
|
|
112
|
+
readonly status: number;
|
|
113
|
+
readonly type: string;
|
|
114
|
+
readonly code: StorefrontErrorCode | (string & {});
|
|
115
|
+
readonly requestId: string | null;
|
|
116
|
+
readonly details: Record<string, unknown>;
|
|
117
|
+
constructor(init: StorefrontErrorInit);
|
|
118
|
+
}
|
|
119
|
+
declare class PriceChangedError extends StorefrontError {
|
|
120
|
+
name: string;
|
|
121
|
+
readonly quote: StorefrontQuote | null;
|
|
122
|
+
readonly requiresNewSession: boolean;
|
|
123
|
+
constructor(init: StorefrontErrorInit);
|
|
124
|
+
}
|
|
125
|
+
declare class WrongRegionError extends StorefrontError {
|
|
126
|
+
name: string;
|
|
127
|
+
readonly region: StorefrontRegion | null;
|
|
128
|
+
readonly baseUrl: string | null;
|
|
129
|
+
constructor(init: StorefrontErrorInit);
|
|
130
|
+
}
|
|
131
|
+
declare class RateLimitedError extends StorefrontError {
|
|
132
|
+
name: string;
|
|
133
|
+
readonly retryAfterSec: number | null;
|
|
134
|
+
readonly scope: 'key' | 'ip' | 'pms' | null;
|
|
135
|
+
constructor(init: StorefrontErrorInit & {
|
|
136
|
+
retryAfterSec: number | null;
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
declare class StorefrontTimeoutError extends StorefrontError {
|
|
140
|
+
name: string;
|
|
141
|
+
constructor(timeoutMs: number, requestId?: string | null);
|
|
142
|
+
}
|
|
143
|
+
declare class StorefrontNetworkError extends StorefrontError {
|
|
144
|
+
name: string;
|
|
145
|
+
constructor(cause: unknown);
|
|
146
|
+
}
|
|
147
|
+
declare class StorefrontConfigError extends Error {
|
|
148
|
+
name: string;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export { type AnalyticsOptions as A, PriceChangedError as P, RateLimitedError as R, type StorefrontRegion as S, type TrackEvent as T, WrongRegionError as W, type AnalyticsReporter as a, STOREFRONT_ERROR_CODES as b, type StorefrontAnalytics as c, StorefrontConfigError as d, StorefrontError as e, type StorefrontErrorCode as f, type StorefrontErrorInit as g, StorefrontNetworkError as h, StorefrontTimeoutError as i, analyticsFor as j, createAnalytics as k, trackPurchasePixel as t };
|