@faststore/api 1.10.8 → 1.10.19

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/dist/index.d.ts CHANGED
@@ -181,6 +181,7 @@ export declare const getResolvers: (options: Options) => {
181
181
  }[];
182
182
  } | null>;
183
183
  validateSession: (_: any, { session: oldSession, search }: import("./__generated__/schema").MutationValidateSessionArgs, { clients }: import("./platforms/vtex").Context) => Promise<import("./__generated__/schema").StoreSession | null>;
184
+ subscribeToNewsletter: (_: any, { data }: import("./__generated__/schema").MutationSubscribeToNewsletterArgs, { clients: { commerce } }: import("./platforms/vtex").Context) => Promise<import("./__generated__/schema").PersonNewsletter | null>;
184
185
  };
185
186
  };
186
187
  export declare const getContextFactory: (options: Options) => (ctx: any) => import("./platforms/vtex").Context;
@@ -10,6 +10,7 @@ import type { Simulation, SimulationArgs, SimulationOptions } from './types/Simu
10
10
  import type { Session } from './types/Session';
11
11
  import type { Channel } from '../../utils/channel';
12
12
  import type { SalesChannel } from './types/SalesChannel';
13
+ import { MasterDataResponse } from './types/Newsletter';
13
14
  declare type ValueOf<T> = T extends Record<string, infer K> ? K : never;
14
15
  export declare const VtexCommerce: ({ account, environment }: Options, ctx: Context) => {
15
16
  catalog: {
@@ -53,5 +54,9 @@ export declare const VtexCommerce: ({ account, environment }: Options, ctx: Cont
53
54
  region: ({ postalCode, country, salesChannel, }: RegionInput) => Promise<Region>;
54
55
  };
55
56
  session: (search: string) => Promise<Session>;
57
+ subscribeToNewsletter: (data: {
58
+ name: string;
59
+ email: string;
60
+ }) => Promise<MasterDataResponse>;
56
61
  };
57
62
  export {};
@@ -0,0 +1,4 @@
1
+ export interface MasterDataResponse {
2
+ Id: string;
3
+ Href: string;
4
+ }
@@ -5,7 +5,7 @@ export interface CollectionPageType {
5
5
  url: string;
6
6
  title: string;
7
7
  metaTagDescription: string;
8
- pageType: 'Brand' | 'Category' | 'Department' | 'Subcategory' | 'Product';
8
+ pageType: 'Brand' | 'Category' | 'Department' | 'SubCategory' | 'Product' | 'Collection' | 'Cluster';
9
9
  }
10
10
  export interface FallbackPageType {
11
11
  id: null;
@@ -49,6 +49,10 @@ export declare const getClients: (options: Options, ctx: Context) => {
49
49
  region: ({ postalCode, country, salesChannel, }: import("./commerce/types/Region").RegionInput) => Promise<import("./commerce/types/Region").Region>;
50
50
  };
51
51
  session: (search: string) => Promise<import("./commerce/types/Session").Session>;
52
+ subscribeToNewsletter: (data: {
53
+ name: string;
54
+ email: string;
55
+ }) => Promise<import("./commerce/types/Newsletter").MasterDataResponse>;
52
56
  };
53
57
  sp: {
54
58
  sendEvent: (options: import("./sp").SearchEvent) => Promise<any>;
@@ -211,6 +211,7 @@ export declare const getResolvers: (_: Options) => {
211
211
  }[];
212
212
  } | null>;
213
213
  validateSession: (_: any, { session: oldSession, search }: import("../..").MutationValidateSessionArgs, { clients }: Context) => Promise<import("../..").StoreSession | null>;
214
+ subscribeToNewsletter: (_: any, { data }: import("../..").MutationSubscribeToNewsletterArgs, { clients: { commerce } }: Context) => Promise<import("../..").PersonNewsletter | null>;
214
215
  };
215
216
  };
216
217
  export {};
@@ -57,4 +57,5 @@ export declare const Mutation: {
57
57
  }[];
58
58
  } | null>;
59
59
  validateSession: (_: any, { session: oldSession, search }: import("../../..").MutationValidateSessionArgs, { clients }: import("..").Context) => Promise<import("../../..").StoreSession | null>;
60
+ subscribeToNewsletter: (_: any, { data }: import("../../..").MutationSubscribeToNewsletterArgs, { clients: { commerce } }: import("..").Context) => Promise<import("../../..").PersonNewsletter | null>;
60
61
  };
@@ -0,0 +1,3 @@
1
+ import type { Context } from '..';
2
+ import type { MutationSubscribeToNewsletterArgs, PersonNewsletter } from '../../../__generated__/schema';
3
+ export declare const subscribeToNewsletter: (_: any, { data }: MutationSubscribeToNewsletterArgs, { clients: { commerce } }: Context) => Promise<PersonNewsletter | null>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faststore/api",
3
- "version": "1.10.8",
3
+ "version": "1.10.19",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -37,7 +37,7 @@
37
37
  "express-graphql": "^0.12.0",
38
38
  "graphql": "^15.6.0",
39
39
  "jest-transform-graphql": "^2.1.0",
40
- "shared": "^1.10.6",
40
+ "shared": "^1.10.18",
41
41
  "ts-jest": "25.5.1",
42
42
  "tsdx": "^0.14.1",
43
43
  "tslib": "^2.3.1",
@@ -46,5 +46,5 @@
46
46
  "peerDependencies": {
47
47
  "graphql": "^15.6.0"
48
48
  },
49
- "gitHead": "a1cee56b400b1309489843f7be6d1cf1b0eab65e"
49
+ "gitHead": "9678f28100f7829663fddb743835a4ea1f60a0da"
50
50
  }
@@ -12,6 +12,14 @@ export type Scalars = {
12
12
  ObjectOrString: any;
13
13
  };
14
14
 
15
+ /** Person data input to the newsletter. */
16
+ export type IPersonNewsletter = {
17
+ /** Person's email. */
18
+ email: Scalars['String'];
19
+ /** Person's name. */
20
+ name: Scalars['String'];
21
+ };
22
+
15
23
  /** Shopping cart input. */
16
24
  export type IStoreCart = {
17
25
  /** Order information, including `orderNumber` and `acceptedOffer`. */
@@ -122,6 +130,8 @@ export type IStoreSession = {
122
130
 
123
131
  export type Mutation = {
124
132
  __typename?: 'Mutation';
133
+ /** Subscribes a new person to the newsletter list. */
134
+ subscribeToNewsletter?: Maybe<PersonNewsletter>;
125
135
  /** Checks for changes between the cart presented in the UI and the cart stored in the ecommerce platform. If changes are detected, it returns the cart stored on the platform. Otherwise, it returns `null`. */
126
136
  validateCart?: Maybe<StoreCart>;
127
137
  /** Updates a web session with the specified values. */
@@ -129,6 +139,11 @@ export type Mutation = {
129
139
  };
130
140
 
131
141
 
142
+ export type MutationSubscribeToNewsletterArgs = {
143
+ data: IPersonNewsletter;
144
+ };
145
+
146
+
132
147
  export type MutationValidateCartArgs = {
133
148
  cart: IStoreCart;
134
149
  };
@@ -139,6 +154,13 @@ export type MutationValidateSessionArgs = {
139
154
  session: IStoreSession;
140
155
  };
141
156
 
157
+ /** Newsletter information. */
158
+ export type PersonNewsletter = {
159
+ __typename?: 'PersonNewsletter';
160
+ /** Person's ID in the newsletter list. */
161
+ id: Scalars['String'];
162
+ };
163
+
142
164
  export type Query = {
143
165
  __typename?: 'Query';
144
166
  /** Returns information about all collections. */
@@ -300,7 +322,7 @@ export type StoreCollectionMeta = {
300
322
  selectedFacets: Array<StoreCollectionFacet>;
301
323
  };
302
324
 
303
- /** Product collection type. Possible values are `Department`, `Category`, `Brand` or `Cluster`. */
325
+ /** Product collection type. Possible values are `Department`, `Category`, `Brand`, `Cluster`, `SubCategory` or `Collection`. */
304
326
  export const enum StoreCollectionType {
305
327
  /** Product brand. */
306
328
  Brand = 'Brand',
@@ -308,8 +330,12 @@ export const enum StoreCollectionType {
308
330
  Category = 'Category',
309
331
  /** Product cluster. */
310
332
  Cluster = 'Cluster',
333
+ /** Product collection. */
334
+ Collection = 'Collection',
311
335
  /** First level of product categorization. */
312
- Department = 'Department'
336
+ Department = 'Department',
337
+ /** Third level of product categorization. */
338
+ SubCategory = 'SubCategory'
313
339
  };
314
340
 
315
341
  /** Currency information. */
@@ -16,6 +16,7 @@ import type {
16
16
  import type { Session } from './types/Session'
17
17
  import type { Channel } from '../../utils/channel'
18
18
  import type { SalesChannel } from './types/SalesChannel'
19
+ import { MasterDataResponse } from './types/Newsletter'
19
20
 
20
21
  type ValueOf<T> = T extends Record<string, infer K> ? K : never
21
22
 
@@ -178,5 +179,15 @@ export const VtexCommerce = (
178
179
  body: '{}',
179
180
  })
180
181
  },
182
+ subscribeToNewsletter: (data: {
183
+ name: string
184
+ email: string
185
+ }): Promise<MasterDataResponse> => {
186
+ return fetchAPI(`${base}/api/dataentities/NL/documents/`, {
187
+ ...BASE_INIT,
188
+ body: JSON.stringify({ ...data, isNewsletterOptIn: true }),
189
+ method: 'PATCH',
190
+ })
191
+ },
181
192
  }
182
193
  }
@@ -0,0 +1,4 @@
1
+ export interface MasterDataResponse {
2
+ Id: string
3
+ Href: string
4
+ }
@@ -6,7 +6,14 @@ export interface CollectionPageType {
6
6
  url: string
7
7
  title: string
8
8
  metaTagDescription: string
9
- pageType: 'Brand' | 'Category' | 'Department' | 'Subcategory' | 'Product'
9
+ pageType:
10
+ | 'Brand'
11
+ | 'Category'
12
+ | 'Department'
13
+ | 'SubCategory'
14
+ | 'Product'
15
+ | 'Collection'
16
+ | 'Cluster'
10
17
  }
11
18
 
12
19
  export interface FallbackPageType {
@@ -14,6 +14,8 @@ const collectionPageTypes = new Set([
14
14
  'category',
15
15
  'department',
16
16
  'subcategory',
17
+ 'collection',
18
+ 'cluster',
17
19
  ] as const)
18
20
 
19
21
  export const isCollectionPageType = (x: any): x is CollectionPageType =>
@@ -1,7 +1,9 @@
1
+ import { subscribeToNewsletter } from './subscribeToNewsletter'
1
2
  import { validateCart } from './validateCart'
2
3
  import { validateSession } from './validateSession'
3
4
 
4
5
  export const Mutation = {
5
6
  validateCart,
6
7
  validateSession,
8
+ subscribeToNewsletter,
7
9
  }
@@ -0,0 +1,14 @@
1
+ import type { Context } from '..'
2
+ import type {
3
+ MutationSubscribeToNewsletterArgs,
4
+ PersonNewsletter,
5
+ } from '../../../__generated__/schema'
6
+
7
+ export const subscribeToNewsletter = async (
8
+ _: any,
9
+ { data }: MutationSubscribeToNewsletterArgs,
10
+ { clients: { commerce } }: Context
11
+ ): Promise<PersonNewsletter | null> => {
12
+ const response = await commerce.subscribeToNewsletter(data)
13
+ return { id: response?.Id }
14
+ }
@@ -1,5 +1,5 @@
1
1
  """
2
- Product collection type. Possible values are `Department`, `Category`, `Brand` or `Cluster`.
2
+ Product collection type. Possible values are `Department`, `Category`, `Brand`, `Cluster`, `SubCategory` or `Collection`.
3
3
  """
4
4
  enum StoreCollectionType {
5
5
  """
@@ -11,6 +11,10 @@ enum StoreCollectionType {
11
11
  """
12
12
  Category
13
13
  """
14
+ Third level of product categorization.
15
+ """
16
+ SubCategory
17
+ """
14
18
  Product brand.
15
19
  """
16
20
  Brand
@@ -18,6 +22,10 @@ enum StoreCollectionType {
18
22
  Product cluster.
19
23
  """
20
24
  Cluster
25
+ """
26
+ Product collection.
27
+ """
28
+ Collection
21
29
  }
22
30
 
23
31
  """
@@ -24,6 +24,7 @@ import PropertyValue from './propertyValue.graphql'
24
24
  import Person from './person.graphql'
25
25
  import ObjectOrString from './objectOrString.graphql'
26
26
  import Session from './session.graphql'
27
+ import Newsletter from './newsletter.graphql'
27
28
 
28
29
  export const typeDefs = [
29
30
  Query,
@@ -50,6 +51,7 @@ export const typeDefs = [
50
51
  Person,
51
52
  ObjectOrString,
52
53
  Session,
54
+ Newsletter
53
55
  ]
54
56
  .map(print)
55
57
  .join('\n')
@@ -7,4 +7,8 @@ type Mutation {
7
7
  Updates a web session with the specified values.
8
8
  """
9
9
  validateSession(session: IStoreSession!, search: String!): StoreSession
10
+ """
11
+ Subscribes a new person to the newsletter list.
12
+ """
13
+ subscribeToNewsletter(data: IPersonNewsletter!): PersonNewsletter
10
14
  }
@@ -0,0 +1,24 @@
1
+ """
2
+ Newsletter information.
3
+ """
4
+
5
+ type PersonNewsletter {
6
+ """
7
+ Person's ID in the newsletter list.
8
+ """
9
+ id: String!
10
+ }
11
+
12
+ """
13
+ Person data input to the newsletter.
14
+ """
15
+ input IPersonNewsletter {
16
+ """
17
+ Person's name.
18
+ """
19
+ name: String!
20
+ """
21
+ Person's email.
22
+ """
23
+ email: String!
24
+ }