@whizzes/wbsc 0.0.1-early-dev-8 → 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/README.md CHANGED
@@ -1 +1 @@
1
- # wsfc
1
+ # wbsc
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whizzes/wbsc",
3
- "version": "0.0.1-early-dev-8",
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 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,11 @@
1
+ mutation EntryCreate($channel: ChannelCode!, $input: EntryCreateInput!) {
2
+ entryCreate(channel: $channel, input: $input) {
3
+ entry {
4
+ ...EntriesListFields
5
+ }
6
+ error {
7
+ code
8
+ message
9
+ }
10
+ }
11
+ }
@@ -0,0 +1 @@
1
+ export { CmsService } from './service';
@@ -0,0 +1,74 @@
1
+ import { WizardGraphQLClient } from "../../client";
2
+ import {
3
+ ContentImagesListDocument,
4
+ EntriesListDocument,
5
+ EntryCreateDocument,
6
+ } from "../../types";
7
+
8
+ import type { Client } from "@urql/core";
9
+ import type {
10
+ ContentImagesListFieldsFragment,
11
+ EntriesFilterInput,
12
+ EntriesListFieldsFragment,
13
+ EntryCreateInput,
14
+ } from "../../types";
15
+
16
+ export class CmsService extends WizardGraphQLClient<unknown> {
17
+ private channel: string;
18
+
19
+ constructor(urqlClient: Client, channel: string) {
20
+ super(urqlClient);
21
+
22
+ this.channel = channel;
23
+ }
24
+
25
+ async listEntries(
26
+ filter: EntriesFilterInput,
27
+ ): Promise<EntriesListFieldsFragment[]> {
28
+ const response = await this.client
29
+ .query(EntriesListDocument, {
30
+ channel: this.channel,
31
+ filter,
32
+ })
33
+ .toPromise();
34
+
35
+ this.unwrapError(response, "entries");
36
+
37
+ return (
38
+ response.data?.entries?.edges?.map(
39
+ (edge: { node: EntriesListFieldsFragment }) => edge.node,
40
+ ) || []
41
+ );
42
+ }
43
+
44
+ async listContentImages(): Promise<ContentImagesListFieldsFragment[]> {
45
+ const response = await this.client
46
+ .query(ContentImagesListDocument, {
47
+ channel: this.channel,
48
+ })
49
+ .toPromise();
50
+
51
+ this.unwrapError(response, "contentImages");
52
+
53
+ return (
54
+ response.data?.contentImages?.edges?.map(
55
+ (edge: { node: ContentImagesListFieldsFragment }) => edge.node,
56
+ ) || []
57
+ );
58
+ }
59
+
60
+ async createEntry(
61
+ input: EntryCreateInput,
62
+ ): Promise<EntriesListFieldsFragment> {
63
+ const response = await this.client
64
+ .mutation(EntryCreateDocument, {
65
+ channel: this.channel,
66
+ input,
67
+ })
68
+ .toPromise();
69
+
70
+ this.unwrapError(response, "entryCreate");
71
+
72
+ return response.data.entryCreate?.entry || null;
73
+ }
74
+ }
package/src/index.ts CHANGED
@@ -1,17 +1,41 @@
1
- export * from './core/product';
1
+ import { cacheExchange, createClient, fetchExchange } from '@urql/core';
2
2
 
3
- import { ProductService } from './core/product';
3
+ import { CmsService } from './core/cms';
4
4
 
5
5
  import type { Client as URQLClient } from '@urql/core';
6
6
 
7
+ export * from './core/cms';
8
+
7
9
  export class WizardStorefrontClient {
8
- readonly baseURL: URL;
10
+ readonly serverURL: URL;
9
11
  readonly urqlClient: URQLClient;
10
- readonly product: ProductService;
12
+ readonly channelCode: string;
13
+ readonly apiToken: string;
14
+
15
+ // Application Services
16
+ readonly cms: CmsService;
17
+
18
+ constructor(serverURL: URL, channelCode: string, apiToken: string) {
19
+ const url = new URL(serverURL);
20
+ url.pathname = '/api/v0/backstore/graphql';
21
+
22
+ const graphQLClient = createClient({
23
+ url: url.toString(),
24
+ exchanges: [cacheExchange, fetchExchange],
25
+ fetchOptions() {
26
+ return {
27
+ headers: {
28
+ 'Authorization': `Bearer ${apiToken}`,
29
+ 'X-Channel-Code': channelCode,
30
+ },
31
+ };
32
+ },
33
+ });
11
34
 
12
- constructor(baseURL: URL, graphQLClient: URQLClient) {
13
- this.baseURL = baseURL;
35
+ this.apiToken = apiToken;
36
+ this.channelCode = channelCode;
37
+ this.serverURL = serverURL;
14
38
  this.urqlClient = graphQLClient;
15
- this.product = new ProductService(graphQLClient);
39
+ this.cms = new CmsService(graphQLClient, channelCode);
16
40
  }
17
41
  }
@@ -21,6 +21,7 @@ export type Scalars = {
21
21
  Email: { input: any; output: any; }
22
22
  JsonSchema: { input: any; output: any; }
23
23
  JsonString: { input: any; output: any; }
24
+ NaiveDate: { input: any; output: any; }
24
25
  Slug: { input: any; output: any; }
25
26
  UUID: { input: any; output: any; }
26
27
  Upload: { input: any; output: any; }
@@ -40,6 +41,61 @@ export enum ActorTypeKind {
40
41
  Storefront = 'STOREFRONT'
41
42
  }
42
43
 
44
+ /** Platform API Token */
45
+ export type ApiToken = {
46
+ __typename?: 'ApiToken';
47
+ channelCode: Scalars['ChannelCode']['output'];
48
+ createdAt: Scalars['DateTime']['output'];
49
+ expiresOn: Scalars['DateTime']['output'];
50
+ id: Scalars['UUID']['output'];
51
+ name: Scalars['String']['output'];
52
+ scopes: Array<Scope>;
53
+ token?: Maybe<Scalars['String']['output']>;
54
+ updatedAt: Scalars['DateTime']['output'];
55
+ };
56
+
57
+ export type ApiTokenConnection = {
58
+ __typename?: 'ApiTokenConnection';
59
+ /** A list of edges. */
60
+ edges: Array<ApiTokenEdge>;
61
+ /** A list of nodes. */
62
+ nodes: Array<ApiToken>;
63
+ /** Information to aid in pagination. */
64
+ pageInfo: PageInfo;
65
+ totalCount: Scalars['Int']['output'];
66
+ totalPages: Scalars['Int']['output'];
67
+ };
68
+
69
+ export type ApiTokenCreate = {
70
+ __typename?: 'ApiTokenCreate';
71
+ apiToken?: Maybe<ApiToken>;
72
+ error?: Maybe<ApiTokenError>;
73
+ };
74
+
75
+ export type ApiTokenCreateInput = {
76
+ expiresOn: Scalars['NaiveDate']['input'];
77
+ name: Scalars['String']['input'];
78
+ };
79
+
80
+ /** An edge in a connection. */
81
+ export type ApiTokenEdge = {
82
+ __typename?: 'ApiTokenEdge';
83
+ /** A cursor for use in pagination */
84
+ cursor: Scalars['String']['output'];
85
+ /** The item at the end of the edge */
86
+ node: ApiToken;
87
+ };
88
+
89
+ export type ApiTokenError = {
90
+ __typename?: 'ApiTokenError';
91
+ code: ApiTokenErrorCode;
92
+ message: Scalars['String']['output'];
93
+ };
94
+
95
+ export enum ApiTokenErrorCode {
96
+ Unknown = 'UNKNOWN'
97
+ }
98
+
43
99
  export type AuthError = {
44
100
  __typename?: 'AuthError';
45
101
  code: AuthErrorCode;
@@ -57,10 +113,13 @@ export type Category = {
57
113
  __typename?: 'Category';
58
114
  channelCode: Scalars['ChannelCode']['output'];
59
115
  createdAt: Scalars['DateTime']['output'];
116
+ description: Scalars['JsonString']['output'];
60
117
  id: Scalars['UUID']['output'];
61
118
  isActive: Scalars['Boolean']['output'];
62
119
  name: Scalars['String']['output'];
63
120
  path: Array<Scalars['CategoryLabel']['output']>;
121
+ /** String representation of the category path. */
122
+ pathString: Scalars['String']['output'];
64
123
  position: Scalars['Int']['output'];
65
124
  updatedAt: Scalars['DateTime']['output'];
66
125
  };
@@ -84,6 +143,7 @@ export type CategoryCreate = {
84
143
  };
85
144
 
86
145
  export type CategoryCreateInput = {
146
+ description?: InputMaybe<Scalars['JsonString']['input']>;
87
147
  isActive: Scalars['Boolean']['input'];
88
148
  name: Scalars['String']['input'];
89
149
  path: Array<Scalars['CategoryLabel']['input']>;
@@ -114,6 +174,46 @@ export enum CategoryErrorCode {
114
174
  DatabaseError = 'DATABASE_ERROR'
115
175
  }
116
176
 
177
+ /** Platform Channel */
178
+ export type Channel = {
179
+ __typename?: 'Channel';
180
+ channelCode: Scalars['ChannelCode']['output'];
181
+ country: Country;
182
+ createdAt: Scalars['DateTime']['output'];
183
+ currencies: Array<ChannelCurrency>;
184
+ name: Scalars['String']['output'];
185
+ updatedAt: Scalars['DateTime']['output'];
186
+ };
187
+
188
+ export type ChannelConnection = {
189
+ __typename?: 'ChannelConnection';
190
+ /** A list of edges. */
191
+ edges: Array<ChannelEdge>;
192
+ /** A list of nodes. */
193
+ nodes: Array<Channel>;
194
+ /** Information to aid in pagination. */
195
+ pageInfo: PageInfo;
196
+ totalCount: Scalars['Int']['output'];
197
+ totalPages: Scalars['Int']['output'];
198
+ };
199
+
200
+ /** Platform Channel */
201
+ export type ChannelCurrency = {
202
+ __typename?: 'ChannelCurrency';
203
+ channelCode: Scalars['ChannelCode']['output'];
204
+ currencyCode: Iso4217;
205
+ isDefault: Scalars['Boolean']['output'];
206
+ };
207
+
208
+ /** An edge in a connection. */
209
+ export type ChannelEdge = {
210
+ __typename?: 'ChannelEdge';
211
+ /** A cursor for use in pagination */
212
+ cursor: Scalars['String']['output'];
213
+ /** The item at the end of the edge */
214
+ node: Channel;
215
+ };
216
+
117
217
  /** A user's Channel Role */
118
218
  export type ChannelRole = {
119
219
  __typename?: 'ChannelRole';
@@ -132,10 +232,55 @@ export enum CmsErrorCode {
132
232
  EntryCollectionMismatch = 'ENTRY_COLLECTION_MISMATCH',
133
233
  EntryValidationError = 'ENTRY_VALIDATION_ERROR',
134
234
  FieldAlreadyExists = 'FIELD_ALREADY_EXISTS',
235
+ ImageUploadError = 'IMAGE_UPLOAD_ERROR',
135
236
  SerdeError = 'SERDE_ERROR',
136
237
  Unknown = 'UNKNOWN'
137
238
  }
138
239
 
240
+ /** CMS Image */
241
+ export type ContentImage = {
242
+ __typename?: 'ContentImage';
243
+ channelCode: Scalars['ChannelCode']['output'];
244
+ createdAt: Scalars['DateTime']['output'];
245
+ image: Image;
246
+ imageId: Scalars['UUID']['output'];
247
+ slug: Scalars['Slug']['output'];
248
+ updatedAt: Scalars['DateTime']['output'];
249
+ };
250
+
251
+ export type ContentImageConnection = {
252
+ __typename?: 'ContentImageConnection';
253
+ /** A list of edges. */
254
+ edges: Array<ContentImageEdge>;
255
+ /** A list of nodes. */
256
+ nodes: Array<ContentImage>;
257
+ /** Information to aid in pagination. */
258
+ pageInfo: PageInfo;
259
+ totalCount: Scalars['Int']['output'];
260
+ totalPages: Scalars['Int']['output'];
261
+ };
262
+
263
+ /** An edge in a connection. */
264
+ export type ContentImageEdge = {
265
+ __typename?: 'ContentImageEdge';
266
+ /** A cursor for use in pagination */
267
+ cursor: Scalars['String']['output'];
268
+ /** The item at the end of the edge */
269
+ node: ContentImage;
270
+ };
271
+
272
+ export type ContentImageUpload = {
273
+ __typename?: 'ContentImageUpload';
274
+ error?: Maybe<CmsError>;
275
+ image?: Maybe<ContentImage>;
276
+ };
277
+
278
+ export type ContentImageUploadInput = {
279
+ alt?: InputMaybe<Scalars['String']['input']>;
280
+ file: Scalars['Upload']['input'];
281
+ slug: Scalars['Slug']['input'];
282
+ };
283
+
139
284
  /** CMS Content-Type */
140
285
  export type ContentType = {
141
286
  __typename?: 'ContentType';
@@ -180,6 +325,32 @@ export type ContentTypeEdge = {
180
325
  node: ContentType;
181
326
  };
182
327
 
328
+ export type ContentTypeUpdate = {
329
+ __typename?: 'ContentTypeUpdate';
330
+ contentType?: Maybe<ContentType>;
331
+ error?: Maybe<CmsError>;
332
+ };
333
+
334
+ export type ContentTypeUpdateInput = {
335
+ schema: Scalars['JsonSchema']['input'];
336
+ };
337
+
338
+ export enum Country {
339
+ Arg = 'ARG',
340
+ Bol = 'BOL',
341
+ Bra = 'BRA',
342
+ Chl = 'CHL',
343
+ Col = 'COL',
344
+ Ecu = 'ECU',
345
+ Guy = 'GUY',
346
+ Per = 'PER',
347
+ Pry = 'PRY',
348
+ Sur = 'SUR',
349
+ Ury = 'URY',
350
+ Usa = 'USA',
351
+ Ven = 'VEN'
352
+ }
353
+
183
354
  /** Platform Customer belonging to a Channel. */
184
355
  export type Customer = {
185
356
  __typename?: 'Customer';
@@ -260,6 +431,7 @@ export type EntryCollection = {
260
431
  contentTypeSlug: Scalars['Slug']['output'];
261
432
  createdAt: Scalars['DateTime']['output'];
262
433
  description?: Maybe<Scalars['String']['output']>;
434
+ entries: Array<Entry>;
263
435
  name: Scalars['String']['output'];
264
436
  slug: Scalars['Slug']['output'];
265
437
  updatedAt: Scalars['DateTime']['output'];
@@ -334,6 +506,7 @@ export type EntryEdge = {
334
506
  /** Platform Image */
335
507
  export type Image = {
336
508
  __typename?: 'Image';
509
+ alt?: Maybe<Scalars['String']['output']>;
337
510
  channelCode: Scalars['ChannelCode']['output'];
338
511
  createdAt: Scalars['DateTime']['output'];
339
512
  height: Scalars['Int']['output'];
@@ -417,12 +590,17 @@ export enum MimeType {
417
590
 
418
591
  export type Mutation = {
419
592
  __typename?: 'Mutation';
593
+ apiTokenCreate: ApiTokenCreate;
420
594
  /** Creates a Category */
421
595
  categoryCreate: CategoryCreate;
422
596
  /** Deletes a Category */
423
597
  categoryDelete: CategoryDelete;
598
+ /** Uploads an image to a CMS Resource */
599
+ contentImageUpload: ContentImageUpload;
424
600
  /** Creates a CMS Content-Type */
425
601
  contentTypeCreate: ContentTypeCreate;
602
+ /** Updates a CMS Content-Type */
603
+ contentTypeUpdate: ContentTypeUpdate;
426
604
  /** Creates a Customer */
427
605
  customerCreate: CustomerCreate;
428
606
  /** Creates a CMS Entry Collection */
@@ -451,8 +629,6 @@ export type Mutation = {
451
629
  * This will update the order status to `Address` or `Payment` depending on the order type.
452
630
  */
453
631
  startCheckout: OrderStartCheckout;
454
- /** List Users */
455
- userCreate: UserCreate;
456
632
  /** Uploads an Image and attaches it to a Product Variant */
457
633
  variantImageUpload: VariantImageUpload;
458
634
  /** Creates a price for a Product Variant */
@@ -460,6 +636,12 @@ export type Mutation = {
460
636
  };
461
637
 
462
638
 
639
+ export type MutationApiTokenCreateArgs = {
640
+ channelCode: Scalars['ChannelCode']['input'];
641
+ input: ApiTokenCreateInput;
642
+ };
643
+
644
+
463
645
  export type MutationCategoryCreateArgs = {
464
646
  channel: Scalars['ChannelCode']['input'];
465
647
  input: CategoryCreateInput;
@@ -472,12 +654,25 @@ export type MutationCategoryDeleteArgs = {
472
654
  };
473
655
 
474
656
 
657
+ export type MutationContentImageUploadArgs = {
658
+ channel: Scalars['ChannelCode']['input'];
659
+ input: ContentImageUploadInput;
660
+ };
661
+
662
+
475
663
  export type MutationContentTypeCreateArgs = {
476
664
  channel: Scalars['ChannelCode']['input'];
477
665
  input: ContentTypeCreateInput;
478
666
  };
479
667
 
480
668
 
669
+ export type MutationContentTypeUpdateArgs = {
670
+ channel: Scalars['ChannelCode']['input'];
671
+ input: ContentTypeUpdateInput;
672
+ slug: Scalars['Slug']['input'];
673
+ };
674
+
675
+
481
676
  export type MutationCustomerCreateArgs = {
482
677
  channel: Scalars['ChannelCode']['input'];
483
678
  input: CustomerCreateInput;
@@ -550,11 +745,6 @@ export type MutationStartCheckoutArgs = {
550
745
  };
551
746
 
552
747
 
553
- export type MutationUserCreateArgs = {
554
- channelCode: Scalars['ChannelCode']['input'];
555
- };
556
-
557
-
558
748
  export type MutationVariantImageUploadArgs = {
559
749
  channel: Scalars['ChannelCode']['input'];
560
750
  input: VariantImageUploadInput;
@@ -768,6 +958,7 @@ export type ProductCreate = {
768
958
 
769
959
  export type ProductCreateInput = {
770
960
  name: Scalars['String']['input'];
961
+ requiresShipping?: InputMaybe<Scalars['Boolean']['input']>;
771
962
  };
772
963
 
773
964
  /** An edge in a connection. */
@@ -805,8 +996,14 @@ export type ProductUpdateInput = {
805
996
 
806
997
  export type Query = {
807
998
  __typename?: 'Query';
999
+ /** Retrieves API Tokens */
1000
+ apiTokens: ApiTokenConnection;
808
1001
  /** Retrieves Categories */
809
1002
  categories: CategoryConnection;
1003
+ /** Retrieves Channels for current user */
1004
+ channels: ChannelConnection;
1005
+ /** Retrieves CMS Content Images */
1006
+ contentImages: ContentImageConnection;
810
1007
  /** Retrieves CMS Content Types */
811
1008
  contentTypes: ContentTypeConnection;
812
1009
  /** Retrieves Customers */
@@ -820,8 +1017,15 @@ export type Query = {
820
1017
  orders: OrderConnection;
821
1018
  /** Retrieves Products */
822
1019
  products: ProductConnection;
823
- /** List Users */
824
- users: Scalars['String']['output'];
1020
+ };
1021
+
1022
+
1023
+ export type QueryApiTokensArgs = {
1024
+ after?: InputMaybe<Scalars['String']['input']>;
1025
+ before?: InputMaybe<Scalars['String']['input']>;
1026
+ channelCode: Scalars['ChannelCode']['input'];
1027
+ first?: InputMaybe<Scalars['Int']['input']>;
1028
+ last?: InputMaybe<Scalars['Int']['input']>;
825
1029
  };
826
1030
 
827
1031
 
@@ -834,6 +1038,23 @@ export type QueryCategoriesArgs = {
834
1038
  };
835
1039
 
836
1040
 
1041
+ export type QueryChannelsArgs = {
1042
+ after?: InputMaybe<Scalars['String']['input']>;
1043
+ before?: InputMaybe<Scalars['String']['input']>;
1044
+ first?: InputMaybe<Scalars['Int']['input']>;
1045
+ last?: InputMaybe<Scalars['Int']['input']>;
1046
+ };
1047
+
1048
+
1049
+ export type QueryContentImagesArgs = {
1050
+ after?: InputMaybe<Scalars['String']['input']>;
1051
+ before?: InputMaybe<Scalars['String']['input']>;
1052
+ channelCode: Scalars['ChannelCode']['input'];
1053
+ first?: InputMaybe<Scalars['Int']['input']>;
1054
+ last?: InputMaybe<Scalars['Int']['input']>;
1055
+ };
1056
+
1057
+
837
1058
  export type QueryContentTypesArgs = {
838
1059
  after?: InputMaybe<Scalars['String']['input']>;
839
1060
  before?: InputMaybe<Scalars['String']['input']>;
@@ -888,11 +1109,6 @@ export type QueryProductsArgs = {
888
1109
  last?: InputMaybe<Scalars['Int']['input']>;
889
1110
  };
890
1111
 
891
-
892
- export type QueryUsersArgs = {
893
- channelCode: Scalars['ChannelCode']['input'];
894
- };
895
-
896
1112
  /**
897
1113
  * Channel Role is a role that a user can have in a channel.
898
1114
  * The roles are:
@@ -906,9 +1122,15 @@ export enum Role {
906
1122
  Staff = 'STAFF'
907
1123
  }
908
1124
 
1125
+ export enum Scope {
1126
+ Global = 'GLOBAL'
1127
+ }
1128
+
909
1129
  export enum UseCase {
910
1130
  /** Profile Picture for a user instance */
911
1131
  Avatar = 'AVATAR',
1132
+ /** Image associated to a CMS resource */
1133
+ Cms = 'CMS',
912
1134
  /** Logo associated to a brand */
913
1135
  Logo = 'LOGO',
914
1136
  /** Image associated to a product variant */
@@ -928,22 +1150,6 @@ export type User = {
928
1150
  updatedAt: Scalars['DateTime']['output'];
929
1151
  };
930
1152
 
931
- export type UserCreate = {
932
- __typename?: 'UserCreate';
933
- error?: Maybe<UserError>;
934
- user?: Maybe<User>;
935
- };
936
-
937
- export type UserError = {
938
- __typename?: 'UserError';
939
- code: UserErrorCode;
940
- message: Scalars['String']['output'];
941
- };
942
-
943
- export enum UserErrorCode {
944
- DatabaseError = 'DATABASE_ERROR'
945
- }
946
-
947
1153
  /** Platform Product Variant */
948
1154
  export type Variant = {
949
1155
  __typename?: 'Variant';
@@ -993,70 +1199,98 @@ export type VariantPriceCreateInput = {
993
1199
  variantId: Scalars['UUID']['input'];
994
1200
  };
995
1201
 
996
- export type ProductsListQueryVariables = Exact<{
1202
+ export type ContentImagesListQueryVariables = Exact<{
997
1203
  channel: Scalars['ChannelCode']['input'];
998
1204
  }>;
999
1205
 
1000
1206
 
1001
- export type ProductsListQuery = { __typename?: 'Query', products: { __typename?: 'ProductConnection', edges: Array<{ __typename?: 'ProductEdge', node: { __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 }> } }> } };
1207
+ 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 } } }> } };
1208
+
1209
+ 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 } };
1210
+
1211
+ export type EntriesListQueryVariables = Exact<{
1212
+ channel: Scalars['ChannelCode']['input'];
1213
+ filter: EntriesFilterInput;
1214
+ }>;
1002
1215
 
1003
- 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 }> };
1004
1216
 
1005
- export const ProductsListFieldsFragmentDoc = gql`
1006
- fragment ProductsListFields on Product {
1217
+ 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 } }> } };
1218
+
1219
+ export type EntriesListFieldsFragment = { __typename?: 'Entry', channelCode: any, id: any, collectionSlug: any, value: any, createdAt: any, updatedAt: any };
1220
+
1221
+ export type EntryCreateMutationVariables = Exact<{
1222
+ channel: Scalars['ChannelCode']['input'];
1223
+ input: EntryCreateInput;
1224
+ }>;
1225
+
1226
+
1227
+ export type EntryCreateMutation = { __typename?: 'Mutation', entryCreate: { __typename?: 'EntryCreate', entry?: { __typename?: 'Entry', channelCode: any, id: any, collectionSlug: any, value: any, createdAt: any, updatedAt: any } | null, error?: { __typename?: 'CmsError', code: CmsErrorCode, message: string } | null } };
1228
+
1229
+ export const ContentImagesListFieldsFragmentDoc = gql`
1230
+ fragment ContentImagesListFields on ContentImage {
1007
1231
  channelCode
1008
- id
1009
- name
1010
1232
  slug
1011
- description
1012
- metadata
1013
- defaultVariantId
1014
- defaultVariant {
1233
+ imageId
1234
+ image {
1015
1235
  id
1016
1236
  channelCode
1017
- sku
1018
- productId
1019
- requiresShipping
1020
- images {
1021
- id
1022
- channelCode
1023
- height
1024
- width
1025
- url
1026
- thumbnailUrl
1027
- size
1028
- mimeType
1029
- useCase
1030
- createdAt
1031
- updatedAt
1032
- }
1033
- prices {
1034
- variantId
1035
- channelCode
1036
- currency
1037
- price
1038
- }
1039
- }
1040
- position
1041
- categories {
1042
- id
1043
- name
1044
- path
1045
- position
1046
- isActive
1237
+ alt
1238
+ height
1239
+ width
1240
+ url
1241
+ thumbnailUrl
1242
+ size
1243
+ mimeType
1244
+ useCase
1047
1245
  createdAt
1048
1246
  updatedAt
1049
1247
  }
1248
+ createdAt
1249
+ updatedAt
1250
+ }
1251
+ `;
1252
+ export const EntriesListFieldsFragmentDoc = gql`
1253
+ fragment EntriesListFields on Entry {
1254
+ channelCode
1255
+ id
1256
+ collectionSlug
1257
+ value
1258
+ createdAt
1259
+ updatedAt
1050
1260
  }
1051
1261
  `;
1052
- export const ProductsListDocument = gql`
1053
- query ProductsList($channel: ChannelCode!) {
1054
- products(channelCode: $channel) {
1262
+ export const ContentImagesListDocument = gql`
1263
+ query ContentImagesList($channel: ChannelCode!) {
1264
+ contentImages(channelCode: $channel) {
1055
1265
  edges {
1056
1266
  node {
1057
- ...ProductsListFields
1267
+ ...ContentImagesListFields
1058
1268
  }
1059
1269
  }
1060
1270
  }
1061
1271
  }
1062
- ${ProductsListFieldsFragmentDoc}`;
1272
+ ${ContentImagesListFieldsFragmentDoc}`;
1273
+ export const EntriesListDocument = gql`
1274
+ query EntriesList($channel: ChannelCode!, $filter: EntriesFilterInput!) {
1275
+ entries(channelCode: $channel, filter: $filter) {
1276
+ edges {
1277
+ node {
1278
+ ...EntriesListFields
1279
+ }
1280
+ }
1281
+ }
1282
+ }
1283
+ ${EntriesListFieldsFragmentDoc}`;
1284
+ export const EntryCreateDocument = gql`
1285
+ mutation EntryCreate($channel: ChannelCode!, $input: EntryCreateInput!) {
1286
+ entryCreate(channel: $channel, input: $input) {
1287
+ entry {
1288
+ ...EntriesListFields
1289
+ }
1290
+ error {
1291
+ code
1292
+ message
1293
+ }
1294
+ }
1295
+ }
1296
+ ${EntriesListFieldsFragmentDoc}`;
@@ -1,9 +0,0 @@
1
- query ProductsList($channel: ChannelCode!) {
2
- products(channelCode: $channel) {
3
- edges {
4
- node {
5
- ...ProductsListFields
6
- }
7
- }
8
- }
9
- }
@@ -1,45 +0,0 @@
1
- fragment ProductsListFields on Product {
2
- channelCode
3
- id
4
- name
5
- slug
6
- description
7
- metadata
8
- defaultVariantId
9
- defaultVariant {
10
- id
11
- channelCode
12
- sku
13
- productId
14
- requiresShipping
15
- images {
16
- id
17
- channelCode
18
- height
19
- width
20
- url
21
- thumbnailUrl
22
- size
23
- mimeType
24
- useCase
25
- createdAt
26
- updatedAt
27
- }
28
- prices {
29
- variantId
30
- channelCode
31
- currency
32
- price
33
- }
34
- }
35
- position
36
- categories {
37
- id
38
- name
39
- path
40
- position
41
- isActive
42
- createdAt
43
- updatedAt
44
- }
45
- }
@@ -1 +0,0 @@
1
- export { ProductService } from './service';
@@ -1,34 +0,0 @@
1
- import { WizardGraphQLClient } from '../../client';
2
- import {
3
- ProductsListDocument
4
- } from '../../types';
5
-
6
- import type { Client } from '@urql/core';
7
- import type {
8
- ProductErrorCode,
9
- ProductsListFieldsFragment
10
- } from '../../types';
11
-
12
- export class ProductService extends WizardGraphQLClient<ProductErrorCode> {
13
- constructor(urqlClient: Client) {
14
- super(urqlClient);
15
- }
16
-
17
- async listProducts(
18
- channel: string,
19
- ): Promise<ProductsListFieldsFragment[]> {
20
- const response = await this.client
21
- .query(ProductsListDocument, {
22
- channel
23
- })
24
- .toPromise();
25
-
26
- this.unwrapError(response, 'products');
27
-
28
- return (
29
- response.data?.products?.edges?.map(
30
- (edge: { node: ProductsListFieldsFragment }) => edge.node
31
- ) || []
32
- );
33
- }
34
- }