@whizzes/wsfc 0.0.1-early-dev-9 → 0.0.1-early-dev-11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whizzes/wsfc",
3
- "version": "0.0.1-early-dev-9",
3
+ "version": "0.0.1-early-dev-11",
4
4
  "main": "./src/index.ts",
5
5
  "module": "./src/index.ts",
6
6
  "types": "./src/index.d.ts",
@@ -0,0 +1,9 @@
1
+ query CategoriesList($channel: ChannelCode!) {
2
+ categories(channelCode: $channel) {
3
+ edges {
4
+ node {
5
+ ...CategoriesListFields
6
+ }
7
+ }
8
+ }
9
+ }
@@ -0,0 +1,11 @@
1
+ fragment CategoriesListFields on Category {
2
+ channelCode
3
+ id
4
+ name
5
+ description
6
+ path
7
+ position
8
+ isActive
9
+ createdAt
10
+ updatedAt
11
+ }
@@ -0,0 +1 @@
1
+ export { CategoryService } from './service';
@@ -0,0 +1,31 @@
1
+ import { WizardGraphQLClient } from "../../client";
2
+ import { CategoriesListDocument } from "../../types";
3
+
4
+ import type { Client } from "@urql/core";
5
+ import type { CategoriesListFieldsFragment } from "../../types";
6
+
7
+ export class CategoryService extends WizardGraphQLClient<unknown> {
8
+ private channel: string;
9
+
10
+ constructor(urqlClient: Client, channel: string) {
11
+ super(urqlClient);
12
+
13
+ this.channel = channel;
14
+ }
15
+
16
+ async listCategories(): Promise<CategoriesListFieldsFragment[]> {
17
+ const response = await this.client
18
+ .query(CategoriesListDocument, {
19
+ channel: this.channel,
20
+ })
21
+ .toPromise();
22
+
23
+ this.unwrapError(response, "categories");
24
+
25
+ return (
26
+ response.data?.categories?.edges?.map(
27
+ (edge: { node: CategoriesListFieldsFragment }) => edge.node,
28
+ ) || []
29
+ );
30
+ }
31
+ }
@@ -0,0 +1,9 @@
1
+ query ContentImagesList($channel: ChannelCode!) {
2
+ contentImages(channelCode: $channel) {
3
+ edges {
4
+ node {
5
+ ...ContentImagesListFields
6
+ }
7
+ }
8
+ }
9
+ }
@@ -0,0 +1,21 @@
1
+ fragment ContentImagesListFields on ContentImage {
2
+ channelCode
3
+ slug
4
+ imageId
5
+ image {
6
+ id
7
+ channelCode
8
+ alt
9
+ height
10
+ width
11
+ url
12
+ thumbnailUrl
13
+ size
14
+ mimeType
15
+ useCase
16
+ createdAt
17
+ updatedAt
18
+ }
19
+ createdAt
20
+ updatedAt
21
+ }
@@ -0,0 +1,9 @@
1
+ query EntriesList($channel: ChannelCode!, $filter: EntriesFilterInput!) {
2
+ entries(channelCode: $channel, filter: $filter) {
3
+ edges {
4
+ node {
5
+ ...EntriesListFields
6
+ }
7
+ }
8
+ }
9
+ }
@@ -0,0 +1,8 @@
1
+ fragment EntriesListFields on Entry {
2
+ channelCode
3
+ id
4
+ collectionSlug
5
+ value
6
+ createdAt
7
+ updatedAt
8
+ }
@@ -0,0 +1 @@
1
+ export { CmsService } from './service';
@@ -0,0 +1,56 @@
1
+ import { WizardGraphQLClient } from "../../client";
2
+ import {
3
+ ContentImagesListDocument,
4
+ EntriesListDocument,
5
+ } from "../../types";
6
+
7
+ import type { Client } from "@urql/core";
8
+ import type {
9
+ ContentImagesListFieldsFragment,
10
+ EntriesListFieldsFragment,
11
+ } from "../../types";
12
+
13
+ export class CmsService extends WizardGraphQLClient<unknown> {
14
+ private channel: string;
15
+
16
+ constructor(urqlClient: Client, channel: string) {
17
+ super(urqlClient);
18
+
19
+ this.channel = channel;
20
+ }
21
+
22
+ async listEntries(
23
+ collectionSlug: string,
24
+ ): Promise<EntriesListFieldsFragment[]> {
25
+ const response = await this.client
26
+ .query(EntriesListDocument, {
27
+ channel: this.channel,
28
+ collectionSlug: collectionSlug,
29
+ })
30
+ .toPromise();
31
+
32
+ this.unwrapError(response, "entries");
33
+
34
+ return (
35
+ response.data?.entries?.edges?.map(
36
+ (edge: { node: EntriesListFieldsFragment }) => edge.node,
37
+ ) || []
38
+ );
39
+ }
40
+
41
+ async listContentImages(): Promise<ContentImagesListFieldsFragment[]> {
42
+ const response = await this.client
43
+ .query(ContentImagesListDocument, {
44
+ channel: this.channel,
45
+ })
46
+ .toPromise();
47
+
48
+ this.unwrapError(response, "contentImages");
49
+
50
+ return (
51
+ response.data?.contentImages?.edges?.map(
52
+ (edge: { node: ContentImagesListFieldsFragment }) => edge.node,
53
+ ) || []
54
+ );
55
+ }
56
+ }
@@ -5,21 +5,20 @@ import {
5
5
 
6
6
  import type { Client } from '@urql/core';
7
7
  import type {
8
- ProductErrorCode,
9
8
  ProductsListFieldsFragment
10
9
  } from '../../types';
11
10
 
12
- export class ProductService extends WizardGraphQLClient<ProductErrorCode> {
13
- constructor(urqlClient: Client) {
11
+ export class ProductService extends WizardGraphQLClient<unknown> {
12
+ private channel: string;
13
+
14
+ constructor(urqlClient: Client, channel: string) {
14
15
  super(urqlClient);
15
16
  }
16
17
 
17
- async listProducts(
18
- channel: string,
19
- ): Promise<ProductsListFieldsFragment[]> {
18
+ async listProducts(): Promise<ProductsListFieldsFragment[]> {
20
19
  const response = await this.client
21
20
  .query(ProductsListDocument, {
22
- channel
21
+ channel: this.channel
23
22
  })
24
23
  .toPromise();
25
24
 
package/src/index.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  export * from './core/product';
2
2
 
3
+ import { CategoryService } from './core/category';
4
+ import { CmsService } from './core/cms';
3
5
  import { ProductService } from './core/product';
4
6
 
5
7
  import type { Client as URQLClient } from '@urql/core';
@@ -7,11 +9,15 @@ import type { Client as URQLClient } from '@urql/core';
7
9
  export class WizardStorefrontClient {
8
10
  readonly baseURL: URL;
9
11
  readonly urqlClient: URQLClient;
12
+ readonly category: CategoryService;
13
+ readonly cms: CmsService;
10
14
  readonly product: ProductService;
11
15
 
12
- constructor(baseURL: URL, graphQLClient: URQLClient) {
16
+ constructor(baseURL: URL, graphQLClient: URQLClient, channelCode: string) {
13
17
  this.baseURL = baseURL;
14
18
  this.urqlClient = graphQLClient;
15
- this.product = new ProductService(graphQLClient);
19
+ this.category = new CategoryService(graphQLClient, channelCode);
20
+ this.cms = new CmsService(graphQLClient, channelCode);
21
+ this.product = new ProductService(graphQLClient, channelCode);
16
22
  }
17
23
  }
@@ -28,6 +28,7 @@ export type Category = {
28
28
  __typename?: 'Category';
29
29
  channelCode: Scalars['ChannelCode']['output'];
30
30
  createdAt: Scalars['DateTime']['output'];
31
+ description: Scalars['JsonString']['output'];
31
32
  id: Scalars['UUID']['output'];
32
33
  isActive: Scalars['Boolean']['output'];
33
34
  name: Scalars['String']['output'];
@@ -36,9 +37,99 @@ export type Category = {
36
37
  updatedAt: Scalars['DateTime']['output'];
37
38
  };
38
39
 
40
+ export type CategoryConnection = {
41
+ __typename?: 'CategoryConnection';
42
+ /** A list of edges. */
43
+ edges: Array<CategoryEdge>;
44
+ /** A list of nodes. */
45
+ nodes: Array<Category>;
46
+ /** Information to aid in pagination. */
47
+ pageInfo: PageInfo;
48
+ totalCount: Scalars['Int']['output'];
49
+ totalPages: Scalars['Int']['output'];
50
+ };
51
+
52
+ /** An edge in a connection. */
53
+ export type CategoryEdge = {
54
+ __typename?: 'CategoryEdge';
55
+ /** A cursor for use in pagination */
56
+ cursor: Scalars['String']['output'];
57
+ /** The item at the end of the edge */
58
+ node: Category;
59
+ };
60
+
61
+ /** CMS Image */
62
+ export type ContentImage = {
63
+ __typename?: 'ContentImage';
64
+ channelCode: Scalars['ChannelCode']['output'];
65
+ createdAt: Scalars['DateTime']['output'];
66
+ image: Image;
67
+ imageId: Scalars['UUID']['output'];
68
+ slug: Scalars['Slug']['output'];
69
+ updatedAt: Scalars['DateTime']['output'];
70
+ };
71
+
72
+ export type ContentImageConnection = {
73
+ __typename?: 'ContentImageConnection';
74
+ /** A list of edges. */
75
+ edges: Array<ContentImageEdge>;
76
+ /** A list of nodes. */
77
+ nodes: Array<ContentImage>;
78
+ /** Information to aid in pagination. */
79
+ pageInfo: PageInfo;
80
+ totalCount: Scalars['Int']['output'];
81
+ totalPages: Scalars['Int']['output'];
82
+ };
83
+
84
+ /** An edge in a connection. */
85
+ export type ContentImageEdge = {
86
+ __typename?: 'ContentImageEdge';
87
+ /** A cursor for use in pagination */
88
+ cursor: Scalars['String']['output'];
89
+ /** The item at the end of the edge */
90
+ node: ContentImage;
91
+ };
92
+
93
+ export type EntriesFilterInput = {
94
+ collectionSlug: Scalars['Slug']['input'];
95
+ };
96
+
97
+ /** CMS Entry */
98
+ export type Entry = {
99
+ __typename?: 'Entry';
100
+ channelCode: Scalars['ChannelCode']['output'];
101
+ collectionSlug: Scalars['Slug']['output'];
102
+ createdAt: Scalars['DateTime']['output'];
103
+ id: Scalars['UUID']['output'];
104
+ updatedAt: Scalars['DateTime']['output'];
105
+ value: Scalars['JsonString']['output'];
106
+ };
107
+
108
+ export type EntryConnection = {
109
+ __typename?: 'EntryConnection';
110
+ /** A list of edges. */
111
+ edges: Array<EntryEdge>;
112
+ /** A list of nodes. */
113
+ nodes: Array<Entry>;
114
+ /** Information to aid in pagination. */
115
+ pageInfo: PageInfo;
116
+ totalCount: Scalars['Int']['output'];
117
+ totalPages: Scalars['Int']['output'];
118
+ };
119
+
120
+ /** An edge in a connection. */
121
+ export type EntryEdge = {
122
+ __typename?: 'EntryEdge';
123
+ /** A cursor for use in pagination */
124
+ cursor: Scalars['String']['output'];
125
+ /** The item at the end of the edge */
126
+ node: Entry;
127
+ };
128
+
39
129
  /** Platform Image */
40
130
  export type Image = {
41
131
  __typename?: 'Image';
132
+ alt?: Maybe<Scalars['String']['output']>;
42
133
  channelCode: Scalars['ChannelCode']['output'];
43
134
  createdAt: Scalars['DateTime']['output'];
44
135
  height: Scalars['Int']['output'];
@@ -167,11 +258,45 @@ export type ProductEdge = {
167
258
 
168
259
  export type Query = {
169
260
  __typename?: 'Query';
261
+ /** Retrieves Categories */
262
+ categories: CategoryConnection;
263
+ /** Retrieves CMS Content Images */
264
+ contentImages: ContentImageConnection;
265
+ /** Retrieves CMS Entries */
266
+ entries: EntryConnection;
170
267
  /** Retrieves Products */
171
268
  products: ProductConnection;
172
269
  };
173
270
 
174
271
 
272
+ export type QueryCategoriesArgs = {
273
+ after?: InputMaybe<Scalars['String']['input']>;
274
+ before?: InputMaybe<Scalars['String']['input']>;
275
+ channelCode: Scalars['ChannelCode']['input'];
276
+ first?: InputMaybe<Scalars['Int']['input']>;
277
+ last?: InputMaybe<Scalars['Int']['input']>;
278
+ };
279
+
280
+
281
+ export type QueryContentImagesArgs = {
282
+ after?: InputMaybe<Scalars['String']['input']>;
283
+ before?: InputMaybe<Scalars['String']['input']>;
284
+ channelCode: Scalars['ChannelCode']['input'];
285
+ first?: InputMaybe<Scalars['Int']['input']>;
286
+ last?: InputMaybe<Scalars['Int']['input']>;
287
+ };
288
+
289
+
290
+ export type QueryEntriesArgs = {
291
+ after?: InputMaybe<Scalars['String']['input']>;
292
+ before?: InputMaybe<Scalars['String']['input']>;
293
+ channelCode: Scalars['ChannelCode']['input'];
294
+ filter: EntriesFilterInput;
295
+ first?: InputMaybe<Scalars['Int']['input']>;
296
+ last?: InputMaybe<Scalars['Int']['input']>;
297
+ };
298
+
299
+
175
300
  export type QueryProductsArgs = {
176
301
  after?: InputMaybe<Scalars['String']['input']>;
177
302
  before?: InputMaybe<Scalars['String']['input']>;
@@ -183,6 +308,8 @@ export type QueryProductsArgs = {
183
308
  export enum UseCase {
184
309
  /** Profile Picture for a user instance */
185
310
  Avatar = 'AVATAR',
311
+ /** Image associated to a CMS resource */
312
+ Cms = 'CMS',
186
313
  /** Logo associated to a brand */
187
314
  Logo = 'LOGO',
188
315
  /** Image associated to a product variant */
@@ -204,6 +331,34 @@ export type Variant = {
204
331
  updatedAt: Scalars['DateTime']['output'];
205
332
  };
206
333
 
334
+ export type CategoriesListQueryVariables = Exact<{
335
+ channel: Scalars['ChannelCode']['input'];
336
+ }>;
337
+
338
+
339
+ export type CategoriesListQuery = { __typename?: 'Query', categories: { __typename?: 'CategoryConnection', edges: Array<{ __typename?: 'CategoryEdge', node: { __typename?: 'Category', channelCode: any, id: any, name: string, description: any, path: Array<any>, position: number, isActive: boolean, createdAt: any, updatedAt: any } }> } };
340
+
341
+ export type CategoriesListFieldsFragment = { __typename?: 'Category', channelCode: any, id: any, name: string, description: any, path: Array<any>, position: number, isActive: boolean, createdAt: any, updatedAt: any };
342
+
343
+ export type ContentImagesListQueryVariables = Exact<{
344
+ channel: Scalars['ChannelCode']['input'];
345
+ }>;
346
+
347
+
348
+ export type ContentImagesListQuery = { __typename?: 'Query', contentImages: { __typename?: 'ContentImageConnection', edges: Array<{ __typename?: 'ContentImageEdge', node: { __typename?: 'ContentImage', channelCode: any, slug: any, imageId: any, createdAt: any, updatedAt: any, image: { __typename?: 'Image', id: any, channelCode: any, alt?: string | null, height: number, width: number, url: string, thumbnailUrl?: string | null, size: number, mimeType: MimeType, useCase: UseCase, createdAt: any, updatedAt: any } } }> } };
349
+
350
+ export type ContentImagesListFieldsFragment = { __typename?: 'ContentImage', channelCode: any, slug: any, imageId: any, createdAt: any, updatedAt: any, image: { __typename?: 'Image', id: any, channelCode: any, alt?: string | null, height: number, width: number, url: string, thumbnailUrl?: string | null, size: number, mimeType: MimeType, useCase: UseCase, createdAt: any, updatedAt: any } };
351
+
352
+ export type EntriesListQueryVariables = Exact<{
353
+ channel: Scalars['ChannelCode']['input'];
354
+ filter: EntriesFilterInput;
355
+ }>;
356
+
357
+
358
+ export type EntriesListQuery = { __typename?: 'Query', entries: { __typename?: 'EntryConnection', edges: Array<{ __typename?: 'EntryEdge', node: { __typename?: 'Entry', channelCode: any, id: any, collectionSlug: any, value: any, createdAt: any, updatedAt: any } }> } };
359
+
360
+ export type EntriesListFieldsFragment = { __typename?: 'Entry', channelCode: any, id: any, collectionSlug: any, value: any, createdAt: any, updatedAt: any };
361
+
207
362
  export type ProductsListQueryVariables = Exact<{
208
363
  channel: Scalars['ChannelCode']['input'];
209
364
  }>;
@@ -213,6 +368,52 @@ export type ProductsListQuery = { __typename?: 'Query', products: { __typename?:
213
368
 
214
369
  export type ProductsListFieldsFragment = { __typename?: 'Product', channelCode: any, id: any, name: string, slug: any, description: any, metadata?: any | null, defaultVariantId: any, position: number, defaultVariant: { __typename?: 'Variant', id: any, channelCode: any, sku?: string | null, productId: any, requiresShipping: boolean, images: Array<{ __typename?: 'Image', id: any, channelCode: any, height: number, width: number, url: string, thumbnailUrl?: string | null, size: number, mimeType: MimeType, useCase: UseCase, createdAt: any, updatedAt: any }>, prices: Array<{ __typename?: 'Price', variantId: any, channelCode: any, currency: Iso4217, price: any }> }, categories: Array<{ __typename?: 'Category', id: any, name: string, path: Array<any>, position: number, isActive: boolean, createdAt: any, updatedAt: any }> };
215
370
 
371
+ export const CategoriesListFieldsFragmentDoc = gql`
372
+ fragment CategoriesListFields on Category {
373
+ channelCode
374
+ id
375
+ name
376
+ description
377
+ path
378
+ position
379
+ isActive
380
+ createdAt
381
+ updatedAt
382
+ }
383
+ `;
384
+ export const ContentImagesListFieldsFragmentDoc = gql`
385
+ fragment ContentImagesListFields on ContentImage {
386
+ channelCode
387
+ slug
388
+ imageId
389
+ image {
390
+ id
391
+ channelCode
392
+ alt
393
+ height
394
+ width
395
+ url
396
+ thumbnailUrl
397
+ size
398
+ mimeType
399
+ useCase
400
+ createdAt
401
+ updatedAt
402
+ }
403
+ createdAt
404
+ updatedAt
405
+ }
406
+ `;
407
+ export const EntriesListFieldsFragmentDoc = gql`
408
+ fragment EntriesListFields on Entry {
409
+ channelCode
410
+ id
411
+ collectionSlug
412
+ value
413
+ createdAt
414
+ updatedAt
415
+ }
416
+ `;
216
417
  export const ProductsListFieldsFragmentDoc = gql`
217
418
  fragment ProductsListFields on Product {
218
419
  channelCode
@@ -260,6 +461,39 @@ export const ProductsListFieldsFragmentDoc = gql`
260
461
  }
261
462
  }
262
463
  `;
464
+ export const CategoriesListDocument = gql`
465
+ query CategoriesList($channel: ChannelCode!) {
466
+ categories(channelCode: $channel) {
467
+ edges {
468
+ node {
469
+ ...CategoriesListFields
470
+ }
471
+ }
472
+ }
473
+ }
474
+ ${CategoriesListFieldsFragmentDoc}`;
475
+ export const ContentImagesListDocument = gql`
476
+ query ContentImagesList($channel: ChannelCode!) {
477
+ contentImages(channelCode: $channel) {
478
+ edges {
479
+ node {
480
+ ...ContentImagesListFields
481
+ }
482
+ }
483
+ }
484
+ }
485
+ ${ContentImagesListFieldsFragmentDoc}`;
486
+ export const EntriesListDocument = gql`
487
+ query EntriesList($channel: ChannelCode!, $filter: EntriesFilterInput!) {
488
+ entries(channelCode: $channel, filter: $filter) {
489
+ edges {
490
+ node {
491
+ ...EntriesListFields
492
+ }
493
+ }
494
+ }
495
+ }
496
+ ${EntriesListFieldsFragmentDoc}`;
263
497
  export const ProductsListDocument = gql`
264
498
  query ProductsList($channel: ChannelCode!) {
265
499
  products(channelCode: $channel) {