@suiteop/storefront 0.1.0 → 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.
Files changed (57) hide show
  1. package/CHANGELOG.md +38 -2
  2. package/README.md +74 -0
  3. package/dist/astro-content-model.cjs +17 -0
  4. package/dist/astro-content-model.d.cts +4 -0
  5. package/dist/astro-content-model.d.ts +4 -0
  6. package/dist/astro-content-model.js +10 -0
  7. package/dist/astro.cjs +3 -1
  8. package/dist/astro.d.cts +38 -17
  9. package/dist/astro.d.ts +38 -17
  10. package/dist/astro.js +2 -2
  11. package/dist/{availability-CYvqeJ6X.d.cts → availability-CnzmxuV3.d.cts} +2 -2
  12. package/dist/{availability-CYvqeJ6X.d.ts → availability-CnzmxuV3.d.ts} +2 -2
  13. package/dist/checkout.cjs +3 -3
  14. package/dist/checkout.js +2 -2
  15. package/dist/chunk-2U6L33AT.cjs +19 -0
  16. package/dist/chunk-4GZBXKBU.cjs +18 -0
  17. package/dist/chunk-GJSCEBSU.js +5 -0
  18. package/dist/chunk-HLGSWF4I.js +9 -0
  19. package/dist/{chunk-ZYDFRRFU.js → chunk-HMLBMNGA.js} +1 -1
  20. package/dist/chunk-KKJCPKPY.js +8 -0
  21. package/dist/chunk-PYVUDQSQ.js +3 -0
  22. package/dist/chunk-USOISC2R.cjs +17 -0
  23. package/dist/{chunk-TBADVD2J.cjs → chunk-VV2UNVQ2.cjs} +2 -2
  24. package/dist/chunk-ZHFZ6II2.cjs +16 -0
  25. package/dist/chunk-ZI2PG7LS.js +6 -0
  26. package/dist/chunk-ZLAOY6IF.cjs +9 -0
  27. package/dist/{errors-DPtiZNoK.d.ts → client-DER7y1WE.d.cts} +111 -151
  28. package/dist/{errors-B3sinzJq.d.cts → client-goQnVoLP.d.ts} +111 -151
  29. package/dist/components.cjs +1 -1
  30. package/dist/components.d.cts +1 -1
  31. package/dist/components.d.ts +1 -1
  32. package/dist/components.js +1 -1
  33. package/dist/config.cjs +6 -2
  34. package/dist/config.d.cts +33 -1
  35. package/dist/config.d.ts +33 -1
  36. package/dist/config.js +3 -2
  37. package/dist/content.cjs +37 -0
  38. package/dist/content.d.cts +254 -0
  39. package/dist/content.d.ts +254 -0
  40. package/dist/content.js +4 -0
  41. package/dist/errors-B2eCo5Cz.d.cts +151 -0
  42. package/dist/errors-D-dULpp1.d.ts +151 -0
  43. package/dist/index.cjs +21 -20
  44. package/dist/index.d.cts +11 -3
  45. package/dist/index.d.ts +11 -3
  46. package/dist/index.js +4 -3
  47. package/dist/react.cjs +6 -5
  48. package/dist/react.d.cts +3 -2
  49. package/dist/react.d.ts +3 -2
  50. package/dist/react.js +5 -4
  51. package/package.json +22 -6
  52. package/dist/chunk-AI6STRZP.cjs +0 -18
  53. package/dist/chunk-AIQUVZEI.cjs +0 -8
  54. package/dist/chunk-MJA3R7NP.js +0 -8
  55. package/dist/chunk-NNZZWGM2.js +0 -6
  56. package/dist/chunk-SK5TD73J.js +0 -3
  57. package/dist/chunk-T2GQ3DOZ.cjs +0 -17
package/dist/config.d.ts CHANGED
@@ -1,5 +1,9 @@
1
1
  import { z } from 'zod';
2
2
 
3
+ declare const STOREFRONT_FONTS: readonly ["inter", "montserrat", "poppins", "raleway", "nunito", "work_sans", "mulish", "barlow", "jost", "bitter", "archivo", "public_sans", "gantari", "anybody", "lato", "playfair_display", "karla", "reddit_sans", "overpass", "roboto", "open_sans", "merriweather", "outfit", "fraunces", "dm_sans", "cormorant_garamond", "eb_garamond", "lora", "crimson_pro", "source_serif_4", "ibm_plex_serif", "manrope", "plus_jakarta_sans", "space_grotesk", "ibm_plex_sans", "libre_franklin", "josefin_sans"];
4
+ type StorefrontFont = (typeof STOREFRONT_FONTS)[number];
5
+ declare const STOREFRONT_FONT_FAMILIES: Record<StorefrontFont, string>;
6
+
3
7
  declare const STOREFRONT_LOCALES: readonly ["en", "fr", "es", "de", "it", "pt", "nl"];
4
8
  type StorefrontLocale = (typeof STOREFRONT_LOCALES)[number];
5
9
  declare const storefrontSiteConfigSchema: z.ZodObject<{
@@ -40,6 +44,20 @@ declare const storefrontSiteConfigSchema: z.ZodObject<{
40
44
  open_sans: "open_sans";
41
45
  merriweather: "merriweather";
42
46
  outfit: "outfit";
47
+ fraunces: "fraunces";
48
+ dm_sans: "dm_sans";
49
+ cormorant_garamond: "cormorant_garamond";
50
+ eb_garamond: "eb_garamond";
51
+ lora: "lora";
52
+ crimson_pro: "crimson_pro";
53
+ source_serif_4: "source_serif_4";
54
+ ibm_plex_serif: "ibm_plex_serif";
55
+ manrope: "manrope";
56
+ plus_jakarta_sans: "plus_jakarta_sans";
57
+ space_grotesk: "space_grotesk";
58
+ ibm_plex_sans: "ibm_plex_sans";
59
+ libre_franklin: "libre_franklin";
60
+ josefin_sans: "josefin_sans";
43
61
  }>;
44
62
  body: z.ZodEnum<{
45
63
  inter: "inter";
@@ -65,6 +83,20 @@ declare const storefrontSiteConfigSchema: z.ZodObject<{
65
83
  open_sans: "open_sans";
66
84
  merriweather: "merriweather";
67
85
  outfit: "outfit";
86
+ fraunces: "fraunces";
87
+ dm_sans: "dm_sans";
88
+ cormorant_garamond: "cormorant_garamond";
89
+ eb_garamond: "eb_garamond";
90
+ lora: "lora";
91
+ crimson_pro: "crimson_pro";
92
+ source_serif_4: "source_serif_4";
93
+ ibm_plex_serif: "ibm_plex_serif";
94
+ manrope: "manrope";
95
+ plus_jakarta_sans: "plus_jakarta_sans";
96
+ space_grotesk: "space_grotesk";
97
+ ibm_plex_sans: "ibm_plex_sans";
98
+ libre_franklin: "libre_franklin";
99
+ josefin_sans: "josefin_sans";
68
100
  }>;
69
101
  }, z.core.$strip>;
70
102
  nav: z.ZodArray<z.ZodObject<{
@@ -138,4 +170,4 @@ type StorefrontSiteConfig = z.infer<typeof storefrontSiteConfigSchema>;
138
170
 
139
171
  declare function defineSuiteOpConfig(config: StorefrontSiteConfig): StorefrontSiteConfig;
140
172
 
141
- export { STOREFRONT_LOCALES, type StorefrontLocale, type StorefrontSiteConfig, defineSuiteOpConfig, storefrontSiteConfigSchema };
173
+ export { STOREFRONT_FONT_FAMILIES, STOREFRONT_LOCALES, type StorefrontLocale, type StorefrontSiteConfig, defineSuiteOpConfig, storefrontSiteConfigSchema };
package/dist/config.js CHANGED
@@ -1,6 +1,7 @@
1
- import { GOOGLE_FONTS } from './chunk-SK5TD73J.js';
1
+ import { STOREFRONT_FONTS } from './chunk-PYVUDQSQ.js';
2
+ export { STOREFRONT_FONT_FAMILIES } from './chunk-PYVUDQSQ.js';
2
3
  import { z } from 'zod';
3
4
 
4
- var STOREFRONT_LOCALES=["en","fr","es","de","it","pt","nl"];var REQUIRED="validation.required";var TOO_LONG="validation.max_length";var TOO_MANY="validation.too_large";var INVALID="validation.invalid";var text=max=>z.string(INVALID).max(max,TOO_LONG);var localeSchema=z.enum(STOREFRONT_LOCALES,"validation.storefront.locale_unsupported");var hexSchema=z.string(INVALID).regex(/^#[0-9A-Fa-f]{6}$/,"validation.storefront.color_hex");var assetUrlSchema=z.url({protocol:/^https$/,error:"validation.storefront.url_https"});var localizedSchema=z.partialRecord(localeSchema,text(200),INVALID);var linkSchema=z.object({label:localizedSchema,href:text(500).regex(/^(\/(?!\/)|https:\/\/)/,"validation.storefront.link_href")},INVALID);var fontSchema=z.enum(GOOGLE_FONTS,"validation.invalid_option");var storefrontSiteConfigSchema=z.object({brand:z.object({name:text(80).min(1,REQUIRED),logoUrl:assetUrlSchema.nullable(),faviconUrl:assetUrlSchema.nullable()},INVALID),colors:z.object({primary:hexSchema,primaryForeground:hexSchema,background:hexSchema,foreground:hexSchema,accent:hexSchema},INVALID),fonts:z.object({heading:fontSchema,body:fontSchema},INVALID),nav:z.array(linkSchema,INVALID).max(8,TOO_MANY),footer:z.object({text:localizedSchema,links:z.array(linkSchema,INVALID).max(12,TOO_MANY)},INVALID),defaultLocale:localeSchema,locales:z.array(localeSchema,INVALID).min(1,REQUIRED).max(STOREFRONT_LOCALES.length,TOO_MANY),seo:z.object({titleTemplate:text(80).includes("%s",{error:"validation.storefront.title_template_placeholder"}),defaultDescription:localizedSchema,ogImageUrl:assetUrlSchema.nullable()},INVALID)},INVALID).refine(c=>c.locales.includes(c.defaultLocale),{path:["defaultLocale"],message:"validation.storefront.default_locale_not_listed"});function defineSuiteOpConfig(config){return storefrontSiteConfigSchema.parse(config)}
5
+ var STOREFRONT_LOCALES=["en","fr","es","de","it","pt","nl"];var REQUIRED="validation.required";var TOO_LONG="validation.max_length";var TOO_MANY="validation.too_large";var INVALID="validation.invalid";var text=max=>z.string(INVALID).max(max,TOO_LONG);var localeSchema=z.enum(STOREFRONT_LOCALES,"validation.storefront.locale_unsupported");var hexSchema=z.string(INVALID).regex(/^#[0-9A-Fa-f]{6}$/,"validation.storefront.color_hex");var assetUrlSchema=z.url({protocol:/^https$/,error:"validation.storefront.url_https"});var localizedSchema=z.partialRecord(localeSchema,text(200),INVALID);var linkSchema=z.object({label:localizedSchema,href:text(500).regex(/^(\/(?!\/)|https:\/\/)/,"validation.storefront.link_href")},INVALID);var fontSchema=z.enum(STOREFRONT_FONTS,"validation.invalid_option");var storefrontSiteConfigSchema=z.object({brand:z.object({name:text(80).min(1,REQUIRED),logoUrl:assetUrlSchema.nullable(),faviconUrl:assetUrlSchema.nullable()},INVALID),colors:z.object({primary:hexSchema,primaryForeground:hexSchema,background:hexSchema,foreground:hexSchema,accent:hexSchema},INVALID),fonts:z.object({heading:fontSchema,body:fontSchema},INVALID),nav:z.array(linkSchema,INVALID).max(8,TOO_MANY),footer:z.object({text:localizedSchema,links:z.array(linkSchema,INVALID).max(12,TOO_MANY)},INVALID),defaultLocale:localeSchema,locales:z.array(localeSchema,INVALID).min(1,REQUIRED).max(STOREFRONT_LOCALES.length,TOO_MANY),seo:z.object({titleTemplate:text(80).includes("%s",{error:"validation.storefront.title_template_placeholder"}),defaultDescription:localizedSchema,ogImageUrl:assetUrlSchema.nullable()},INVALID)},INVALID).refine(c=>c.locales.includes(c.defaultLocale),{path:["defaultLocale"],message:"validation.storefront.default_locale_not_listed"});function defineSuiteOpConfig(config){return storefrontSiteConfigSchema.parse(config)}
5
6
 
6
7
  export { STOREFRONT_LOCALES, defineSuiteOpConfig, storefrontSiteConfigSchema };
@@ -0,0 +1,37 @@
1
+ 'use strict';
2
+
3
+ var chunkZHFZ6II2_cjs = require('./chunk-ZHFZ6II2.cjs');
4
+ require('./chunk-4GZBXKBU.cjs');
5
+ require('./chunk-USOISC2R.cjs');
6
+ require('./chunk-LVFRVNT3.cjs');
7
+
8
+
9
+
10
+ Object.defineProperty(exports, "contentModelSchema", {
11
+ enumerable: true,
12
+ get: function () { return chunkZHFZ6II2_cjs.contentModelSchema; }
13
+ });
14
+ Object.defineProperty(exports, "createContentReader", {
15
+ enumerable: true,
16
+ get: function () { return chunkZHFZ6II2_cjs.createContentReader; }
17
+ });
18
+ Object.defineProperty(exports, "defineContent", {
19
+ enumerable: true,
20
+ get: function () { return chunkZHFZ6II2_cjs.defineContent; }
21
+ });
22
+ Object.defineProperty(exports, "field", {
23
+ enumerable: true,
24
+ get: function () { return chunkZHFZ6II2_cjs.field; }
25
+ });
26
+ Object.defineProperty(exports, "parseContentModel", {
27
+ enumerable: true,
28
+ get: function () { return chunkZHFZ6II2_cjs.parseContentModel; }
29
+ });
30
+ Object.defineProperty(exports, "readFields", {
31
+ enumerable: true,
32
+ get: function () { return chunkZHFZ6II2_cjs.readFields; }
33
+ });
34
+ Object.defineProperty(exports, "toContentModel", {
35
+ enumerable: true,
36
+ get: function () { return chunkZHFZ6II2_cjs.toContentModel; }
37
+ });
@@ -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 };
@@ -0,0 +1,4 @@
1
+ export { contentModelSchema, createContentReader, defineContent, field, parseContentModel, readFields, toContentModel } from './chunk-KKJCPKPY.js';
2
+ import './chunk-GJSCEBSU.js';
3
+ import './chunk-ZI2PG7LS.js';
4
+ import './chunk-6NFURJXI.js';