@faststore/api 1.2.23

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 (103) hide show
  1. package/CHANGELOG.md +333 -0
  2. package/README.md +115 -0
  3. package/dist/__generated__/schema.d.ts +281 -0
  4. package/dist/api.cjs.development.js +2226 -0
  5. package/dist/api.cjs.development.js.map +1 -0
  6. package/dist/api.cjs.production.min.js +2 -0
  7. package/dist/api.cjs.production.min.js.map +1 -0
  8. package/dist/api.esm.js +2217 -0
  9. package/dist/api.esm.js.map +1 -0
  10. package/dist/index.d.ts +136 -0
  11. package/dist/index.js +8 -0
  12. package/dist/platforms/vtex/clients/commerce/index.d.ts +29 -0
  13. package/dist/platforms/vtex/clients/commerce/types/Brand.d.ts +8 -0
  14. package/dist/platforms/vtex/clients/commerce/types/CategoryTree.d.ts +9 -0
  15. package/dist/platforms/vtex/clients/commerce/types/OrderForm.d.ts +347 -0
  16. package/dist/platforms/vtex/clients/commerce/types/Simulation.d.ts +154 -0
  17. package/dist/platforms/vtex/clients/fetch.d.ts +1 -0
  18. package/dist/platforms/vtex/clients/index.d.ts +32 -0
  19. package/dist/platforms/vtex/clients/search/index.d.ts +22 -0
  20. package/dist/platforms/vtex/clients/search/types/AttributeSearchResult.d.ts +56 -0
  21. package/dist/platforms/vtex/clients/search/types/ProductSearchResult.d.ts +199 -0
  22. package/dist/platforms/vtex/index.d.ts +144 -0
  23. package/dist/platforms/vtex/loaders/index.d.ts +7 -0
  24. package/dist/platforms/vtex/loaders/simulation.d.ts +5 -0
  25. package/dist/platforms/vtex/loaders/sku.d.ts +6 -0
  26. package/dist/platforms/vtex/resolvers/aggregateOffer.d.ts +7 -0
  27. package/dist/platforms/vtex/resolvers/aggregateRating.d.ts +2 -0
  28. package/dist/platforms/vtex/resolvers/collection.d.ts +8 -0
  29. package/dist/platforms/vtex/resolvers/facet.d.ts +5 -0
  30. package/dist/platforms/vtex/resolvers/facetValue.d.ts +5 -0
  31. package/dist/platforms/vtex/resolvers/mutation.d.ts +58 -0
  32. package/dist/platforms/vtex/resolvers/offer.d.ts +11 -0
  33. package/dist/platforms/vtex/resolvers/organization.d.ts +2 -0
  34. package/dist/platforms/vtex/resolvers/product.d.ts +5 -0
  35. package/dist/platforms/vtex/resolvers/productGroup.d.ts +3 -0
  36. package/dist/platforms/vtex/resolvers/query.d.ts +51 -0
  37. package/dist/platforms/vtex/resolvers/review.d.ts +2 -0
  38. package/dist/platforms/vtex/resolvers/searchResult.d.ts +5 -0
  39. package/dist/platforms/vtex/resolvers/seo.d.ts +7 -0
  40. package/dist/platforms/vtex/resolvers/validateCart.d.ts +71 -0
  41. package/dist/platforms/vtex/utils/enhanceSku.d.ts +5 -0
  42. package/dist/platforms/vtex/utils/facets.d.ts +12 -0
  43. package/dist/platforms/vtex/utils/slugify.d.ts +1 -0
  44. package/dist/platforms/vtex/utils/sort.d.ts +10 -0
  45. package/dist/typeDefs/index.d.ts +1 -0
  46. package/package.json +44 -0
  47. package/src/__generated__/schema.ts +324 -0
  48. package/src/index.ts +33 -0
  49. package/src/platforms/vtex/clients/commerce/index.ts +100 -0
  50. package/src/platforms/vtex/clients/commerce/types/Brand.ts +8 -0
  51. package/src/platforms/vtex/clients/commerce/types/CategoryTree.ts +9 -0
  52. package/src/platforms/vtex/clients/commerce/types/OrderForm.ts +371 -0
  53. package/src/platforms/vtex/clients/commerce/types/Simulation.ts +170 -0
  54. package/src/platforms/vtex/clients/fetch.ts +13 -0
  55. package/src/platforms/vtex/clients/index.ts +15 -0
  56. package/src/platforms/vtex/clients/search/index.ts +83 -0
  57. package/src/platforms/vtex/clients/search/types/AttributeSearchResult.ts +61 -0
  58. package/src/platforms/vtex/clients/search/types/ProductSearchResult.ts +223 -0
  59. package/src/platforms/vtex/index.ts +62 -0
  60. package/src/platforms/vtex/loaders/index.ts +16 -0
  61. package/src/platforms/vtex/loaders/simulation.ts +42 -0
  62. package/src/platforms/vtex/loaders/sku.ts +61 -0
  63. package/src/platforms/vtex/resolvers/aggregateOffer.ts +20 -0
  64. package/src/platforms/vtex/resolvers/aggregateRating.ts +7 -0
  65. package/src/platforms/vtex/resolvers/collection.ts +43 -0
  66. package/src/platforms/vtex/resolvers/facet.ts +11 -0
  67. package/src/platforms/vtex/resolvers/facetValue.ts +11 -0
  68. package/src/platforms/vtex/resolvers/mutation.ts +5 -0
  69. package/src/platforms/vtex/resolvers/offer.ts +26 -0
  70. package/src/platforms/vtex/resolvers/organization.ts +5 -0
  71. package/src/platforms/vtex/resolvers/product.ts +75 -0
  72. package/src/platforms/vtex/resolvers/productGroup.ts +9 -0
  73. package/src/platforms/vtex/resolvers/query.ts +115 -0
  74. package/src/platforms/vtex/resolvers/review.ts +11 -0
  75. package/src/platforms/vtex/resolvers/searchResult.ts +46 -0
  76. package/src/platforms/vtex/resolvers/seo.ts +10 -0
  77. package/src/platforms/vtex/resolvers/validateCart.ts +166 -0
  78. package/src/platforms/vtex/utils/enhanceSku.ts +8 -0
  79. package/src/platforms/vtex/utils/facets.ts +31 -0
  80. package/src/platforms/vtex/utils/slugify.ts +4 -0
  81. package/src/platforms/vtex/utils/sort.ts +10 -0
  82. package/src/typeDefs/aggregateOffer.graphql +10 -0
  83. package/src/typeDefs/aggregateRating.graphql +4 -0
  84. package/src/typeDefs/author.graphql +3 -0
  85. package/src/typeDefs/brand.graphql +3 -0
  86. package/src/typeDefs/breadcrumb.graphql +10 -0
  87. package/src/typeDefs/cart.graphql +13 -0
  88. package/src/typeDefs/collection.graphql +26 -0
  89. package/src/typeDefs/facet.graphql +14 -0
  90. package/src/typeDefs/image.graphql +9 -0
  91. package/src/typeDefs/index.ts +47 -0
  92. package/src/typeDefs/mutation.graphql +4 -0
  93. package/src/typeDefs/offer.graphql +21 -0
  94. package/src/typeDefs/order.graphql +9 -0
  95. package/src/typeDefs/organization.graphql +7 -0
  96. package/src/typeDefs/pageInfo.graphql +8 -0
  97. package/src/typeDefs/product.graphql +25 -0
  98. package/src/typeDefs/productGroup.graphql +5 -0
  99. package/src/typeDefs/query.graphql +64 -0
  100. package/src/typeDefs/review.graphql +9 -0
  101. package/src/typeDefs/seo.graphql +6 -0
  102. package/src/typeDefs/status.graphql +5 -0
  103. package/src/typings/schema.d.ts +7 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,333 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ ## 1.2.23 (2021-10-27)
7
+
8
+
9
+ ### Features
10
+
11
+ * **store-ui:** Add carousel tablist keyboard behavior ([#996](https://github.com/vtex/faststore/issues/996)) ([9081584](https://github.com/vtex/faststore/commit/908158460028009aaaa4ebbcd22eefab59e9bff8))
12
+
13
+
14
+
15
+
16
+
17
+ ## 1.2.22 (2021-10-26)
18
+
19
+ **Note:** Version bump only for package @vtex/store-api
20
+
21
+
22
+
23
+
24
+
25
+ ## 1.2.21 (2021-10-26)
26
+
27
+
28
+ ### Features
29
+
30
+ * **store-ui:** Form molecule ([#1004](https://github.com/vtex/faststore/issues/1004)) ([c584ef6](https://github.com/vtex/faststore/commit/c584ef693d111ede70d27730ecb3cce613b9aba3))
31
+
32
+
33
+
34
+
35
+
36
+ ## 1.2.20 (2021-10-26)
37
+
38
+ **Note:** Version bump only for package @vtex/store-api
39
+
40
+
41
+
42
+
43
+
44
+ ## 1.2.19 (2021-10-25)
45
+
46
+ **Note:** Version bump only for package @vtex/store-api
47
+
48
+
49
+
50
+
51
+
52
+ ## 1.2.18 (2021-10-25)
53
+
54
+
55
+ ### Features
56
+
57
+ * **store-ui:** Breadcrumb molecule ([#986](https://github.com/vtex/faststore/issues/986)) ([325c738](https://github.com/vtex/faststore/commit/325c7387089d2f2c7152191b54fc3cb4918f1c68))
58
+
59
+
60
+
61
+
62
+
63
+ ## 1.2.17 (2021-10-21)
64
+
65
+
66
+ ### Features
67
+
68
+ * **store-ui:** Loading Button molecule ([#962](https://github.com/vtex/faststore/issues/962)) ([6083ea0](https://github.com/vtex/faststore/commit/6083ea0273646a09e66ceedfab4b17c3960ac9fc)), closes [#918](https://github.com/vtex/faststore/issues/918) [#911](https://github.com/vtex/faststore/issues/911)
69
+
70
+
71
+ ### BREAKING CHANGES
72
+
73
+ * **store-ui:** Remove deprecated folders (#927)
74
+
75
+
76
+
77
+
78
+
79
+ ## 1.2.16 (2021-10-21)
80
+
81
+
82
+ ### Features
83
+
84
+ * **store-ui:** Label atom ([#1001](https://github.com/vtex/faststore/issues/1001)) ([3306ea6](https://github.com/vtex/faststore/commit/3306ea6b9b48996574eac4b8c1b737dff94a438e))
85
+
86
+
87
+
88
+
89
+
90
+ ## 1.2.15 (2021-10-21)
91
+
92
+
93
+ ### Bug Fixes
94
+
95
+ * **store-ui:** Fix search-input a11y ([#1000](https://github.com/vtex/faststore/issues/1000)) ([f052f46](https://github.com/vtex/faststore/commit/f052f465e21aa4e2ca047327eeb0610b9b979f10))
96
+
97
+
98
+
99
+
100
+
101
+ ## 1.2.14 (2021-10-20)
102
+
103
+
104
+ ### Features
105
+
106
+ * graphql-utils ([#998](https://github.com/vtex/faststore/issues/998)) ([bddf043](https://github.com/vtex/faststore/commit/bddf04308826369f86322851b554cc58ab5b2161))
107
+
108
+
109
+
110
+
111
+
112
+ ## 1.2.13 (2021-10-20)
113
+
114
+ **Note:** Version bump only for package @vtex/store-api
115
+
116
+
117
+
118
+
119
+
120
+ ## 1.2.12 (2021-10-18)
121
+
122
+ **Note:** Version bump only for package @vtex/store-api
123
+
124
+
125
+
126
+
127
+
128
+ ## 1.2.11 (2021-10-18)
129
+
130
+ **Note:** Version bump only for package @vtex/store-api
131
+
132
+
133
+
134
+
135
+
136
+ ## 1.2.10 (2021-10-18)
137
+
138
+
139
+ ### Bug Fixes
140
+
141
+ * **store-ui:** Component Architecture doc's code snippets ([#997](https://github.com/vtex/faststore/issues/997)) ([7f0d5f3](https://github.com/vtex/faststore/commit/7f0d5f307014f794063dd8d94d873478803888c0))
142
+
143
+
144
+
145
+
146
+
147
+ ## 1.2.9 (2021-10-18)
148
+
149
+ **Note:** Version bump only for package @vtex/store-api
150
+
151
+
152
+
153
+
154
+
155
+ ## 1.2.8 (2021-10-15)
156
+
157
+ **Note:** Version bump only for package @vtex/store-api
158
+
159
+
160
+
161
+
162
+
163
+ ## 1.2.7 (2021-10-15)
164
+
165
+ **Note:** Version bump only for package @vtex/store-api
166
+
167
+
168
+
169
+
170
+
171
+ ## 1.2.6 (2021-10-15)
172
+
173
+ **Note:** Version bump only for package @vtex/store-api
174
+
175
+
176
+
177
+
178
+
179
+ ## 1.2.5 (2021-10-15)
180
+
181
+ **Note:** Version bump only for package @vtex/store-api
182
+
183
+
184
+
185
+
186
+
187
+ ## 1.2.4 (2021-10-14)
188
+
189
+
190
+ ### Features
191
+
192
+ * **store-ui:** Accordion molecule ([#985](https://github.com/vtex/faststore/issues/985)) ([a35fb51](https://github.com/vtex/faststore/commit/a35fb51b675e41af6070da8b521a3a4da25a0d65))
193
+
194
+
195
+
196
+
197
+
198
+ ## 1.2.3 (2021-10-14)
199
+
200
+ **Note:** Version bump only for package @vtex/store-api
201
+
202
+
203
+
204
+
205
+
206
+ ## 1.2.2 (2021-10-13)
207
+
208
+ **Note:** Version bump only for package @vtex/store-api
209
+
210
+
211
+
212
+
213
+
214
+ ## 1.2.1 (2021-10-08)
215
+
216
+ **Note:** Version bump only for package @vtex/store-api
217
+
218
+
219
+
220
+
221
+
222
+ ## 1.1.18 (2021-10-05)
223
+
224
+ **Note:** Version bump only for package @vtex/store-api
225
+
226
+
227
+
228
+
229
+
230
+ ## 1.1.17 (2021-10-05)
231
+
232
+
233
+ ### Features
234
+
235
+ * **store-api:** Add channel support for products ([#968](https://github.com/vtex/faststore/issues/968)) ([923d343](https://github.com/vtex/faststore/commit/923d343bcde8fbebfff9d32ba52ac26cd0504484))
236
+
237
+
238
+
239
+
240
+
241
+ ## 1.1.16 (2021-10-04)
242
+
243
+
244
+ ### Features
245
+
246
+ * **store-api:** Add cart to store-api ([#963](https://github.com/vtex/faststore/issues/963)) ([0607d82](https://github.com/vtex/faststore/commit/0607d82f9f17de0b4045a7efbe99004d43e87056))
247
+
248
+
249
+
250
+
251
+
252
+ ## 1.1.15 (2021-10-01)
253
+
254
+
255
+ ### Features
256
+
257
+ * Configure storybook theme ([#979](https://github.com/vtex/faststore/issues/979)) ([736811f](https://github.com/vtex/faststore/commit/736811f6381b4fd5f3f6d976198262216fe3ebcb))
258
+
259
+
260
+
261
+
262
+
263
+ ## 1.1.14 (2021-09-28)
264
+
265
+
266
+ ### Features
267
+
268
+ * **store-ui:** Add Modal molecule ([#957](https://github.com/vtex/faststore/issues/957)) ([530b308](https://github.com/vtex/faststore/commit/530b3085a5707be459b37757844ce2e52b2f2981))
269
+
270
+
271
+
272
+
273
+
274
+ ## 1.1.13 (2021-09-23)
275
+
276
+ **Note:** Version bump only for package @vtex/store-api
277
+
278
+
279
+
280
+
281
+
282
+ ## 1.1.12 (2021-09-22)
283
+
284
+
285
+ ### Bug Fixes
286
+
287
+ * users were unable to develop a store in an account without CMS pages ([#969](https://github.com/vtex/faststore/issues/969)) ([7b28a4e](https://github.com/vtex/faststore/commit/7b28a4e0da1edec7e843a614339909c6565b220a))
288
+
289
+
290
+
291
+
292
+
293
+ ## 1.1.11 (2021-09-17)
294
+
295
+
296
+ ### Features
297
+
298
+ * **store-ui:** Spinner atom ([#961](https://github.com/vtex/faststore/issues/961)) ([59034b7](https://github.com/vtex/faststore/commit/59034b726ac83c79f591cd24739a8c15316c92b3)), closes [#918](https://github.com/vtex/faststore/issues/918) [#911](https://github.com/vtex/faststore/issues/911)
299
+
300
+
301
+ ### BREAKING CHANGES
302
+
303
+ * **store-ui:** Remove deprecated folders (#927)
304
+
305
+
306
+
307
+
308
+
309
+ ## 1.1.10 (2021-09-16)
310
+
311
+
312
+ ### Features
313
+
314
+ * **store-api:** Add codegen ([#960](https://github.com/vtex/faststore/issues/960)) ([5231e6c](https://github.com/vtex/faststore/commit/5231e6c455be73b9d870627188c07a420651ed44))
315
+
316
+
317
+
318
+
319
+
320
+ ## 1.1.9 (2021-09-15)
321
+
322
+ **Note:** Version bump only for package @vtex/store-api
323
+
324
+
325
+
326
+
327
+
328
+ ## 1.1.8 (2021-09-14)
329
+
330
+
331
+ ### Features
332
+
333
+ * **store-api:** Store API TypeDefs ([#942](https://github.com/vtex/faststore/issues/942)) ([b440dc9](https://github.com/vtex/faststore/commit/b440dc9f023da82b5c443c465375e74f909d1b8d))
package/README.md ADDED
@@ -0,0 +1,115 @@
1
+ # @faststore/api
2
+
3
+ The only API you need for building your next ecommerce.
4
+
5
+ This package defines a front-end first, GraphQL API inspired by clean architecture and schema.org.
6
+
7
+ GraphQL types defined in this repo extends and simplifies schema.org. This makes it easier to make your frontend search friendly.
8
+ Also, by using the clean architecture, all types defined on this schema are not platform specific, but created to resolve an specific business case on your frontend, like rendering listprices, sellers etc.
9
+
10
+ Alongside the GraphQL type definitions, we provide standard implementations for common ecommerce platforms. Currently we support:
11
+ 1. VTEX
12
+ 2. Maybe add yours?
13
+
14
+ With the typedefs and resolvers, you can create an executable schema and deploy anywhere you want. For instance, one use case would be:
15
+ 1. Create an Apollo Server instane on Heroku
16
+ 2. Run the executable schema in a function on Next.JS
17
+ 3. Run the executable schema during a Gatsby build.
18
+
19
+ ## Install
20
+
21
+ ```bash
22
+ yarn add @faststore/api
23
+ ```
24
+
25
+ ## Usage
26
+ GraphQL is very versatile and can run in many places. To setup the schema in an apollo server, just:
27
+ ```ts
28
+ import { getSchema } from '@faststore/api'
29
+ import { ApolloServer } from 'apollo-server'
30
+
31
+ // Get the Store schema
32
+ const schema = await getSchema({ platform: 'vtex', account: 'my-account', environment: 'vtexcommercestable' })
33
+
34
+ // Setup Apollo Server
35
+ const server = new ApolloServer({ schema });
36
+
37
+ // The `listen` method launches a web server.
38
+ server.listen().then(({ url }) => {
39
+ console.log(`🚀 Server ready at ${url}`);
40
+ });
41
+ ```
42
+
43
+ ## Extending the schema
44
+ GraphQL is a very versatile language. By using the exported `getSchema` function, you can not only extend the base schema but also redefine the whole resolvers implementation.
45
+
46
+ To extend the schema, one can:
47
+ ```ts
48
+ import { getSchema } from '@faststore/api'
49
+ import { makeExecutableSchema, mergeSchemas } from '@graphql-tools/schema'
50
+ import { ApolloServer } from 'apollo-server'
51
+
52
+ // Setup type extensions
53
+ const typeDefs = `
54
+ extend type Product {
55
+ customField: String!
56
+ }
57
+ `
58
+
59
+ // Setup custom resolvers
60
+ const resolvers = {
61
+ Product: {
62
+ customField: async () => {
63
+ ...
64
+ // Your code goes here
65
+ ...
66
+ }
67
+ }
68
+ }
69
+
70
+ // Create custom schema
71
+ const customSchema = makeExecutableSchema({ resolvers, typeDefs })
72
+ const storeApiSchema = await getSchema({ platform: 'vtex', ...})
73
+
74
+ // Merge schemas into a final schema
75
+ const finalSchema = mergeSchemas(schemas: [
76
+ storeApiSchema,
77
+ customSchema
78
+ ])
79
+
80
+ // Setup Apollo Server
81
+ const server = new ApolloServer({ schema });
82
+
83
+ // The `listen` method launches a web server.
84
+ server.listen().then(({ url }) => {
85
+ console.log(`🚀 Server ready at ${url}`);
86
+ });
87
+ ```
88
+
89
+ ## Inline platform
90
+ If your ecommerce platform is not supported you have two options.
91
+ 1. Make a contribution
92
+ 2. Create inline resolvers for your platform
93
+
94
+ Inline resolves means you are going to write all resolvers for the api schema in your project or in an external library. This is recommended if you are supporting a niche platform and want to have full control over how each field is processed.
95
+
96
+ To create your own resolvers, you can:
97
+ ```ts
98
+ import { getTypeDefs } from '@faststore/api'
99
+ import { ApolloServer } from 'apollo-server'
100
+ import { makeExecutableSchema } from '@graphql-tools/schema'
101
+
102
+ // Get the Store API TypeDefs
103
+ const typeDefs = getTypeDefs()
104
+
105
+ const resolvers = {
106
+ ...
107
+ // add your resolvers
108
+ ...
109
+ }
110
+
111
+ // Create a runnable schema
112
+ const schema = makeExecutableSchema({ resolvers, typeDefs })
113
+
114
+ // You now have a runnable GraphQL schema, you can create a server or run queries locally.
115
+ ```