@daffodil/driver 0.87.2 → 0.89.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.
- package/fesm2022/daffodil-driver-hubspot-testing.mjs +3 -3
- package/fesm2022/daffodil-driver-hubspot-testing.mjs.map +1 -1
- package/fesm2022/daffodil-driver-hubspot.mjs.map +1 -1
- package/fesm2022/daffodil-driver-in-memory.mjs +52 -15
- package/fesm2022/daffodil-driver-in-memory.mjs.map +1 -1
- package/fesm2022/daffodil-driver-magento-testing.mjs +9 -9
- package/fesm2022/daffodil-driver-magento-testing.mjs.map +1 -1
- package/fesm2022/daffodil-driver-magento.mjs +482 -48
- package/fesm2022/daffodil-driver-magento.mjs.map +1 -1
- package/fesm2022/daffodil-driver-shopify-testing.mjs +18 -18
- package/fesm2022/daffodil-driver-shopify-testing.mjs.map +1 -1
- package/fesm2022/daffodil-driver-shopify.mjs +37 -18
- package/fesm2022/daffodil-driver-shopify.mjs.map +1 -1
- package/fesm2022/daffodil-driver.mjs +3 -3
- package/fesm2022/daffodil-driver.mjs.map +1 -1
- package/hubspot/index.d.ts +68 -1
- package/hubspot/testing/index.d.ts +21 -1
- package/in-memory/index.d.ts +162 -1
- package/index.d.ts +64 -1
- package/magento/index.d.ts +176 -1
- package/magento/testing/index.d.ts +23 -1
- package/package.json +1 -1
- package/shopify/index.d.ts +8296 -1
- package/shopify/testing/index.d.ts +80 -1
- package/errors/bad-input.d.ts +0 -6
- package/errors/codes.d.ts +0 -3
- package/errors/network-error.class.d.ts +0 -9
- package/errors/public_api.d.ts +0 -3
- package/http-client-cache/noop.service.d.ts +0 -12
- package/http-client-cache/public_api.d.ts +0 -3
- package/http-client-cache/service.token.d.ts +0 -2
- package/http-client-cache/service.type.d.ts +0 -10
- package/hubspot/hubspot-forms.provider.d.ts +0 -9
- package/hubspot/hubspot-forms.service.d.ts +0 -23
- package/hubspot/models/config.d.ts +0 -5
- package/hubspot/models/forms.d.ts +0 -8
- package/hubspot/models/hubspot-request.d.ts +0 -15
- package/hubspot/models/hubspot-response.d.ts +0 -9
- package/hubspot/public_api.d.ts +0 -6
- package/hubspot/testing/factories/hubspot-response.factory.d.ts +0 -18
- package/hubspot/testing/factories/public_api.d.ts +0 -1
- package/hubspot/testing/public_api.d.ts +0 -1
- package/hubspot/transformers/json-builder.d.ts +0 -2
- package/in-memory/backend/backends.token.d.ts +0 -2
- package/in-memory/backend/data-service.type.d.ts +0 -23
- package/in-memory/backend/delegate.class.d.ts +0 -25
- package/in-memory/backend/public_api.d.ts +0 -6
- package/in-memory/backend/root.service.d.ts +0 -17
- package/in-memory/backend/routeable.type.d.ts +0 -25
- package/in-memory/backend/type.d.ts +0 -6
- package/in-memory/config/default.d.ts +0 -2
- package/in-memory/config/public_api.d.ts +0 -3
- package/in-memory/config/token.d.ts +0 -2
- package/in-memory/config/type.d.ts +0 -6
- package/in-memory/driver/base.class.d.ts +0 -14
- package/in-memory/driver/public_api.d.ts +0 -1
- package/in-memory/module.d.ts +0 -12
- package/in-memory/public_api.d.ts +0 -4
- package/magento/errors/error.class.d.ts +0 -9
- package/magento/errors/public_api.d.ts +0 -3
- package/magento/errors/transform-graphql.d.ts +0 -3
- package/magento/errors/transform.d.ts +0 -5
- package/magento/fragments/money.d.ts +0 -1
- package/magento/fragments/page-info.d.ts +0 -1
- package/magento/fragments/public_api.d.ts +0 -2
- package/magento/graphql/cache-header/cache-header-apollo-link.d.ts +0 -17
- package/magento/graphql/cache.service.d.ts +0 -14
- package/magento/graphql/cacheable-operations/apollo-cacheable-operations-link-generator.d.ts +0 -15
- package/magento/graphql/cacheable-operations/cacheable-operations-token.d.ts +0 -9
- package/magento/graphql/public_api.d.ts +0 -5
- package/magento/graphql/type-policies.d.ts +0 -12
- package/magento/magento.module.d.ts +0 -6
- package/magento/models/discount.d.ts +0 -6
- package/magento/models/filter-input.type.d.ts +0 -6
- package/magento/models/money.d.ts +0 -5
- package/magento/models/page-info.d.ts +0 -6
- package/magento/models/public_api.d.ts +0 -5
- package/magento/models/sort.enum.d.ts +0 -4
- package/magento/public_api.d.ts +0 -7
- package/magento/schema/schema.d.ts +0 -21
- package/magento/testing/factories/discount.factory.d.ts +0 -14
- package/magento/testing/factories/money.factory.d.ts +0 -13
- package/magento/testing/factories/page-info.factory.d.ts +0 -8
- package/magento/testing/factories/public_api.d.ts +0 -3
- package/magento/transforms/public_api.d.ts +0 -2
- package/magento/transforms/requests/public_api.d.ts +0 -1
- package/magento/transforms/requests/sort-direction.d.ts +0 -3
- package/magento/transforms/responses/page-info.d.ts +0 -3
- package/magento/transforms/responses/public_api.d.ts +0 -2
- package/magento/transforms/responses/sort-direction.d.ts +0 -3
- package/models/public_api.d.ts +0 -1
- package/models/response.interface.d.ts +0 -15
- package/public_api.d.ts +0 -3
- package/shopify/codegen/generated-shopify-types.d.ts +0 -8214
- package/shopify/codegen/public_api.d.ts +0 -1
- package/shopify/graphql/apollo-links/auth-link.d.ts +0 -8
- package/shopify/graphql/apollo-links/error-link.d.ts +0 -7
- package/shopify/graphql/apollo-links/http-link.d.ts +0 -8
- package/shopify/graphql/apollo-links/public_api.d.ts +0 -3
- package/shopify/graphql/provide-shopify-apollo-driver.d.ts +0 -8
- package/shopify/graphql/public_api.d.ts +0 -1
- package/shopify/models/image-node.d.ts +0 -5
- package/shopify/models/money.d.ts +0 -3
- package/shopify/models/product-graph.d.ts +0 -5
- package/shopify/models/product-images.d.ts +0 -5
- package/shopify/models/product-node.d.ts +0 -4
- package/shopify/models/product-price-range.d.ts +0 -5
- package/shopify/models/public_api.d.ts +0 -6
- package/shopify/public_api.d.ts +0 -4
- package/shopify/testing/factories/money.factory.d.ts +0 -13
- package/shopify/testing/factories/product-graph.factory.d.ts +0 -15
- package/shopify/testing/factories/product-image-node.factory.d.ts +0 -14
- package/shopify/testing/factories/product-images.factory.d.ts +0 -15
- package/shopify/testing/factories/product-node.factory.d.ts +0 -24
- package/shopify/testing/factories/product-price-range.factory.d.ts +0 -16
- package/shopify/testing/factories/public_api.d.ts +0 -6
- package/shopify/transforms/public_api.d.ts +0 -3
- package/shopify/transforms/shopify-handle-transform.d.ts +0 -7
- package/shopify/transforms/shopify-id-transform.d.ts +0 -10
- package/shopify/transforms/shopify-url-transform.d.ts +0 -9
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { DaffInheritableError, daffIsError, createMultiInjectionToken, DaffSortDirectionEnum } from '@daffodil/core';
|
|
2
|
-
import { DaffDriverNetworkError, provideDaffDriverHttpClientCacheService } from '@daffodil/driver';
|
|
3
1
|
import * as i0 from '@angular/core';
|
|
4
|
-
import { Inject, Injectable,
|
|
5
|
-
import { ApolloLink } from '@apollo/client/core';
|
|
2
|
+
import { inject, PLATFORM_ID, Inject, Injectable, NgModule } from '@angular/core';
|
|
3
|
+
import { InMemoryCache, from, ApolloLink } from '@apollo/client/core';
|
|
4
|
+
import { provideApollo, gql } from 'apollo-angular';
|
|
5
|
+
import { provideDaffDriverHttpClientCacheService, DaffDriverNetworkError } from '@daffodil/driver';
|
|
6
|
+
import { HttpLink } from 'apollo-angular/http';
|
|
6
7
|
import { isPlatformBrowser } from '@angular/common';
|
|
7
|
-
import {
|
|
8
|
+
import { DaffInheritableError, daffIsError, createMultiInjectionToken, DaffSortDirectionEnum } from '@daffodil/core';
|
|
8
9
|
|
|
9
10
|
var possibleTypes = {
|
|
10
11
|
CartAddressInterface: [
|
|
@@ -100,6 +101,468 @@ var introspectionQueryResultData = {
|
|
|
100
101
|
|
|
101
102
|
const schema = introspectionQueryResultData;
|
|
102
103
|
|
|
104
|
+
/**
|
|
105
|
+
* Creates an Apollo HTTP link for GraphQL requests.
|
|
106
|
+
*
|
|
107
|
+
* @param url - The Shopify Storefront API endpoint URL for GraphQL requests.
|
|
108
|
+
* @returns An ApolloLink instance configured with the provided URL.
|
|
109
|
+
*/
|
|
110
|
+
function createHttpLink(url) {
|
|
111
|
+
const httpLink = inject(HttpLink);
|
|
112
|
+
return httpLink.create({ uri: url });
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Magento GraphQL possible types configuration for Apollo Client.
|
|
117
|
+
*
|
|
118
|
+
* This object defines the possible concrete types for each GraphQL interface
|
|
119
|
+
* used in Magento's GraphQL API. Apollo Client uses this information for
|
|
120
|
+
* proper fragment matching and union/interface type resolution.
|
|
121
|
+
*
|
|
122
|
+
* When Apollo Client encounters a GraphQL interface or union type in a query,
|
|
123
|
+
* it needs to know which concrete types can implement that interface to
|
|
124
|
+
* properly cache and normalize the data.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* new InMemoryCache({
|
|
129
|
+
* possibleTypes: MAGENTO_POSSIBLE_TYPES
|
|
130
|
+
* })
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
const MAGENTO_POSSIBLE_TYPES = {
|
|
134
|
+
CartAddressInterface: [
|
|
135
|
+
'BillingCartAddress',
|
|
136
|
+
'ShippingCartAddress',
|
|
137
|
+
],
|
|
138
|
+
CartItemInterface: [
|
|
139
|
+
'SimpleCartItem',
|
|
140
|
+
'VirtualCartItem',
|
|
141
|
+
'DownloadableCartItem',
|
|
142
|
+
'BundleCartItem',
|
|
143
|
+
'ConfigurableCartItem',
|
|
144
|
+
],
|
|
145
|
+
ProductInterface: [
|
|
146
|
+
'VirtualProduct',
|
|
147
|
+
'SimpleProduct',
|
|
148
|
+
'DownloadableProduct',
|
|
149
|
+
'BundleProduct',
|
|
150
|
+
'GroupedProduct',
|
|
151
|
+
'ConfigurableProduct',
|
|
152
|
+
],
|
|
153
|
+
CategoryInterface: [
|
|
154
|
+
'CategoryTree',
|
|
155
|
+
],
|
|
156
|
+
MediaGalleryInterface: [
|
|
157
|
+
'ProductImage',
|
|
158
|
+
'ProductVideo',
|
|
159
|
+
],
|
|
160
|
+
ProductLinksInterface: [
|
|
161
|
+
'ProductLinks',
|
|
162
|
+
],
|
|
163
|
+
CreditMemoItemInterface: [
|
|
164
|
+
'DownloadableCreditMemoItem',
|
|
165
|
+
'BundleCreditMemoItem',
|
|
166
|
+
'CreditMemoItem',
|
|
167
|
+
],
|
|
168
|
+
OrderItemInterface: [
|
|
169
|
+
'DownloadableOrderItem',
|
|
170
|
+
'BundleOrderItem',
|
|
171
|
+
'OrderItem',
|
|
172
|
+
],
|
|
173
|
+
InvoiceItemInterface: [
|
|
174
|
+
'DownloadableInvoiceItem',
|
|
175
|
+
'BundleInvoiceItem',
|
|
176
|
+
'InvoiceItem',
|
|
177
|
+
],
|
|
178
|
+
ShipmentItemInterface: [
|
|
179
|
+
'BundleShipmentItem',
|
|
180
|
+
'ShipmentItem',
|
|
181
|
+
],
|
|
182
|
+
AggregationOptionInterface: [
|
|
183
|
+
'AggregationOption',
|
|
184
|
+
],
|
|
185
|
+
LayerFilterItemInterface: [
|
|
186
|
+
'LayerFilterItem',
|
|
187
|
+
'SwatchLayerFilterItem',
|
|
188
|
+
],
|
|
189
|
+
PhysicalProductInterface: [
|
|
190
|
+
'SimpleProduct',
|
|
191
|
+
'BundleProduct',
|
|
192
|
+
'GroupedProduct',
|
|
193
|
+
'ConfigurableProduct',
|
|
194
|
+
],
|
|
195
|
+
CustomizableOptionInterface: [
|
|
196
|
+
'CustomizableAreaOption',
|
|
197
|
+
'CustomizableDateOption',
|
|
198
|
+
'CustomizableDropDownOption',
|
|
199
|
+
'CustomizableMultipleOption',
|
|
200
|
+
'CustomizableFieldOption',
|
|
201
|
+
'CustomizableFileOption',
|
|
202
|
+
'CustomizableRadioOption',
|
|
203
|
+
'CustomizableCheckboxOption',
|
|
204
|
+
],
|
|
205
|
+
CustomizableProductInterface: [
|
|
206
|
+
'VirtualProduct',
|
|
207
|
+
'SimpleProduct',
|
|
208
|
+
'DownloadableProduct',
|
|
209
|
+
'BundleProduct',
|
|
210
|
+
'ConfigurableProduct',
|
|
211
|
+
],
|
|
212
|
+
SwatchDataInterface: [
|
|
213
|
+
'ImageSwatchData',
|
|
214
|
+
'TextSwatchData',
|
|
215
|
+
'ColorSwatchData',
|
|
216
|
+
],
|
|
217
|
+
SwatchLayerFilterItemInterface: [
|
|
218
|
+
'SwatchLayerFilterItem',
|
|
219
|
+
],
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Custom type policies that allow us to have more granular control
|
|
224
|
+
* over how ApolloClient reads from and writes to the cache.
|
|
225
|
+
*
|
|
226
|
+
* https://www.apollographql.com/docs/react/caching/cache-configuration/#typepolicy-fields
|
|
227
|
+
* https://www.apollographql.com/docs/react/caching/cache-field-behavior/
|
|
228
|
+
*/
|
|
229
|
+
const typePolicies = {
|
|
230
|
+
// Query/Mutation are "types" just like "Cart".
|
|
231
|
+
Query: {
|
|
232
|
+
fields: {
|
|
233
|
+
cart: {
|
|
234
|
+
// Replaces @connection(key: "Cart")
|
|
235
|
+
keyArgs: () => 'Cart',
|
|
236
|
+
},
|
|
237
|
+
customer: {
|
|
238
|
+
keyArgs: () => 'Customer',
|
|
239
|
+
},
|
|
240
|
+
customerCart: {
|
|
241
|
+
keyArgs: () => 'Cart',
|
|
242
|
+
},
|
|
243
|
+
customerWishlistProducts: {
|
|
244
|
+
read: existing => existing || [],
|
|
245
|
+
},
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
AppliedGiftCard: {
|
|
249
|
+
keyFields: ['code'],
|
|
250
|
+
},
|
|
251
|
+
AvailablePaymentMethod: {
|
|
252
|
+
keyFields: ['code'],
|
|
253
|
+
},
|
|
254
|
+
AvailableShippingMethod: {
|
|
255
|
+
// The combination of these fields makes an instance of
|
|
256
|
+
// AvailableShippingMethod unique.
|
|
257
|
+
keyFields: ['carrier_code', 'method_code'],
|
|
258
|
+
},
|
|
259
|
+
Breadcrumb: {
|
|
260
|
+
// Uses provided fields on the object as the `uid`.
|
|
261
|
+
keyFields: ['category_uid'],
|
|
262
|
+
},
|
|
263
|
+
Cart: {
|
|
264
|
+
keyFields: () => 'Cart',
|
|
265
|
+
fields: {
|
|
266
|
+
applied_gift_cards: {
|
|
267
|
+
merge(existing, incoming) {
|
|
268
|
+
return incoming;
|
|
269
|
+
},
|
|
270
|
+
},
|
|
271
|
+
available_payment_methods: {
|
|
272
|
+
merge(existing, incoming) {
|
|
273
|
+
return incoming;
|
|
274
|
+
},
|
|
275
|
+
},
|
|
276
|
+
items: {
|
|
277
|
+
merge(existing, incoming) {
|
|
278
|
+
return incoming;
|
|
279
|
+
},
|
|
280
|
+
},
|
|
281
|
+
prices: {
|
|
282
|
+
// `merge: true` can be used for an object field.
|
|
283
|
+
merge: true,
|
|
284
|
+
},
|
|
285
|
+
shipping_addresses: {
|
|
286
|
+
merge(existing = [], incoming, { readField, mergeObjects }) {
|
|
287
|
+
// street makes these things unique
|
|
288
|
+
const mergeResult = new Set();
|
|
289
|
+
const streetToIndex = new Map();
|
|
290
|
+
existing.forEach((existingShippingAddress, index) => {
|
|
291
|
+
// Use readField instead of existingShippingAddress.street directly because it will follow cache references.
|
|
292
|
+
const street = readField('street', existingShippingAddress);
|
|
293
|
+
streetToIndex.set(street, index);
|
|
294
|
+
});
|
|
295
|
+
incoming.forEach(incomingShippingAddress => {
|
|
296
|
+
const street = readField('street', incomingShippingAddress);
|
|
297
|
+
if (streetToIndex.has(street)) {
|
|
298
|
+
const targetIndex = streetToIndex.get(street);
|
|
299
|
+
const existingShippingAddress = existing[targetIndex];
|
|
300
|
+
const merged = mergeObjects(existingShippingAddress, incomingShippingAddress);
|
|
301
|
+
mergeResult.add(merged);
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
// We do not have an address with this street yet, add it on to the end.
|
|
305
|
+
streetToIndex.set(street, streetToIndex.size);
|
|
306
|
+
mergeResult.add(incomingShippingAddress);
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
return Array.from(mergeResult);
|
|
310
|
+
},
|
|
311
|
+
},
|
|
312
|
+
},
|
|
313
|
+
},
|
|
314
|
+
Customer: {
|
|
315
|
+
keyFields: () => 'Customer',
|
|
316
|
+
merge: true,
|
|
317
|
+
fields: {
|
|
318
|
+
addresses: {
|
|
319
|
+
merge(existing, incoming) {
|
|
320
|
+
return incoming;
|
|
321
|
+
},
|
|
322
|
+
read(cachedAddresses, { toReference }) {
|
|
323
|
+
if (cachedAddresses) {
|
|
324
|
+
return cachedAddresses.map(address => {
|
|
325
|
+
// Update v2 identifiers to new references. Previous
|
|
326
|
+
// entries had `id: CustomerAddress:1` which caused
|
|
327
|
+
// v3's lookup to fail. If we find a legacy id,
|
|
328
|
+
// point it at the object using a reference.
|
|
329
|
+
if (address.id &&
|
|
330
|
+
address.id.includes('CustomerAddress')) {
|
|
331
|
+
return toReference(address.id);
|
|
332
|
+
}
|
|
333
|
+
else {
|
|
334
|
+
return address;
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
// If there are no cached addresses that's fine - the schema
|
|
339
|
+
// shows that it is a nullable field.
|
|
340
|
+
},
|
|
341
|
+
},
|
|
342
|
+
orders: {
|
|
343
|
+
keyArgs: ['filter'],
|
|
344
|
+
},
|
|
345
|
+
},
|
|
346
|
+
},
|
|
347
|
+
CustomerAddress: {
|
|
348
|
+
fields: {
|
|
349
|
+
street: {
|
|
350
|
+
merge(existing, incoming) {
|
|
351
|
+
return incoming;
|
|
352
|
+
},
|
|
353
|
+
},
|
|
354
|
+
},
|
|
355
|
+
},
|
|
356
|
+
CustomerPaymentTokens: {
|
|
357
|
+
keyFields: () => 'CustomerPaymentTokens',
|
|
358
|
+
fields: {
|
|
359
|
+
items: {
|
|
360
|
+
merge(existing, incoming) {
|
|
361
|
+
return incoming;
|
|
362
|
+
},
|
|
363
|
+
},
|
|
364
|
+
},
|
|
365
|
+
},
|
|
366
|
+
Currency: {
|
|
367
|
+
merge: true,
|
|
368
|
+
},
|
|
369
|
+
ProductImage: {
|
|
370
|
+
keyFields: ['url'],
|
|
371
|
+
},
|
|
372
|
+
ConfigurableProductOptions: {
|
|
373
|
+
keyFields: ['uid'],
|
|
374
|
+
},
|
|
375
|
+
SelectedConfigurableOption: {
|
|
376
|
+
// id alone is not enough to identify a selected option as it can refer
|
|
377
|
+
// to something like "size" where value_id refers to "large".
|
|
378
|
+
// TODO: Use configurable_product_option_uid for ConfigurableWishlistItem when available in 2.4.5
|
|
379
|
+
keyFields: fields => fields.configurable_product_option_uid
|
|
380
|
+
? [
|
|
381
|
+
'configurable_product_option_uid',
|
|
382
|
+
'configurable_product_option_value_uid',
|
|
383
|
+
]
|
|
384
|
+
: ['id', 'value_id'],
|
|
385
|
+
},
|
|
386
|
+
SelectedPaymentMethod: {
|
|
387
|
+
keyFields: ['code'],
|
|
388
|
+
},
|
|
389
|
+
ShippingCartAddress: {
|
|
390
|
+
keyFields: ['street'],
|
|
391
|
+
fields: {
|
|
392
|
+
available_shipping_methods: {
|
|
393
|
+
merge(existing = [], incoming, { readField, mergeObjects }) {
|
|
394
|
+
// carrier_code + method_code makes these things unique
|
|
395
|
+
const mergeResult = new Set();
|
|
396
|
+
const carrierToIndex = new Map();
|
|
397
|
+
existing.forEach((existingShippingMethod, index) => {
|
|
398
|
+
// Use readField because it will follow cache references.
|
|
399
|
+
const carrierCode = readField('carrier_code', existingShippingMethod);
|
|
400
|
+
const methodCode = readField('method_code', existingShippingMethod);
|
|
401
|
+
const carrierKey = `${carrierCode}|${methodCode}`;
|
|
402
|
+
carrierToIndex.set(carrierKey, index);
|
|
403
|
+
});
|
|
404
|
+
incoming.forEach(incomingShippingMethod => {
|
|
405
|
+
// Use readField because it will follow cache references.
|
|
406
|
+
const carrierCode = readField('carrier_code', incomingShippingMethod);
|
|
407
|
+
const methodCode = readField('method_code', incomingShippingMethod);
|
|
408
|
+
const carrierKey = `${carrierCode}|${methodCode}`;
|
|
409
|
+
if (carrierToIndex.has(carrierKey)) {
|
|
410
|
+
const targetIndex = carrierToIndex.get(carrierKey);
|
|
411
|
+
const existingShippingMethod = existing[targetIndex];
|
|
412
|
+
const merged = mergeObjects(existingShippingMethod, incomingShippingMethod);
|
|
413
|
+
mergeResult.add(merged);
|
|
414
|
+
}
|
|
415
|
+
else {
|
|
416
|
+
// We do not have a method with this key yet, add it on to the end.
|
|
417
|
+
carrierToIndex.set(carrierKey, carrierToIndex.size);
|
|
418
|
+
mergeResult.add(incomingShippingMethod);
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
return Array.from(mergeResult);
|
|
422
|
+
},
|
|
423
|
+
},
|
|
424
|
+
country: {
|
|
425
|
+
merge: true,
|
|
426
|
+
},
|
|
427
|
+
region: {
|
|
428
|
+
merge: true,
|
|
429
|
+
},
|
|
430
|
+
selected_shipping_method: {
|
|
431
|
+
merge: true,
|
|
432
|
+
},
|
|
433
|
+
},
|
|
434
|
+
},
|
|
435
|
+
CategoryTree: {
|
|
436
|
+
keyFields: ['uid'],
|
|
437
|
+
fields: {
|
|
438
|
+
children: {
|
|
439
|
+
merge(existing, incoming) {
|
|
440
|
+
return incoming;
|
|
441
|
+
},
|
|
442
|
+
},
|
|
443
|
+
},
|
|
444
|
+
},
|
|
445
|
+
Wishlist: {
|
|
446
|
+
keyFields: ({ id }) => `CustomerWishlist:${id}`,
|
|
447
|
+
fields: {
|
|
448
|
+
items_v2: {
|
|
449
|
+
keyArgs: false,
|
|
450
|
+
merge: false,
|
|
451
|
+
},
|
|
452
|
+
},
|
|
453
|
+
},
|
|
454
|
+
WishlistItem: {
|
|
455
|
+
keyFields: ({ id }) => `CustomerWishlistItem:${id}`,
|
|
456
|
+
},
|
|
457
|
+
WishlistItems: {
|
|
458
|
+
fields: {
|
|
459
|
+
items: {
|
|
460
|
+
merge: (existing = [], incoming, { variables }) => {
|
|
461
|
+
if (variables) {
|
|
462
|
+
const { currentPage = 1 } = variables;
|
|
463
|
+
// reset cache collection if we're on the first page
|
|
464
|
+
if (currentPage === 1) {
|
|
465
|
+
return incoming;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
return [...existing, ...incoming];
|
|
469
|
+
},
|
|
470
|
+
},
|
|
471
|
+
},
|
|
472
|
+
},
|
|
473
|
+
SimpleWishlistItem: {
|
|
474
|
+
keyFields: ({ id }) => `CustomerSimpleWishlistItem:${id}`,
|
|
475
|
+
},
|
|
476
|
+
VirtualWishlistItem: {
|
|
477
|
+
keyFields: ({ id }) => `CustomerVirtualWishlistItem:${id}`,
|
|
478
|
+
},
|
|
479
|
+
DownloadableWishlistItem: {
|
|
480
|
+
keyFields: ({ id }) => `CustomerDownloadableWishlistItem:${id}`,
|
|
481
|
+
},
|
|
482
|
+
BundleWishlistItem: {
|
|
483
|
+
keyFields: ({ id }) => `CustomerBundleWishlistItem:${id}`,
|
|
484
|
+
},
|
|
485
|
+
GroupedProductWishlistItem: {
|
|
486
|
+
keyFields: ({ id }) => `CustomerGroupedProductWishlistItem:${id}`,
|
|
487
|
+
},
|
|
488
|
+
ConfigurableWishlistItem: {
|
|
489
|
+
keyFields: ({ id }) => `CustomerConfigurableWishlistItem:${id}`,
|
|
490
|
+
},
|
|
491
|
+
GiftCardWishlistItem: {
|
|
492
|
+
keyFields: ({ id }) => `CustomerGiftCardWishlistItem:${id}`,
|
|
493
|
+
},
|
|
494
|
+
SimpleProduct: {
|
|
495
|
+
keyFields: ['uid'],
|
|
496
|
+
},
|
|
497
|
+
ConfigurableProduct: {
|
|
498
|
+
keyFields: ['uid'],
|
|
499
|
+
},
|
|
500
|
+
BundleProduct: {
|
|
501
|
+
keyFields: ['uid'],
|
|
502
|
+
},
|
|
503
|
+
GroupedProduct: {
|
|
504
|
+
keyFields: ['uid'],
|
|
505
|
+
},
|
|
506
|
+
VirtualProduct: {
|
|
507
|
+
keyFields: ['uid'],
|
|
508
|
+
},
|
|
509
|
+
CartItemInterface: {
|
|
510
|
+
keyFields: ['uid'],
|
|
511
|
+
},
|
|
512
|
+
StoreConfig: {
|
|
513
|
+
keyFields: ['store_code'],
|
|
514
|
+
},
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Interacts with the Apollo client.
|
|
519
|
+
*
|
|
520
|
+
* @inheritdoc
|
|
521
|
+
*/
|
|
522
|
+
class DaffDriverHttpClientCacheMagentoService {
|
|
523
|
+
constructor(platformId) {
|
|
524
|
+
this.platformId = platformId;
|
|
525
|
+
}
|
|
526
|
+
reset() {
|
|
527
|
+
if (isPlatformBrowser(this.platformId)) {
|
|
528
|
+
location.reload();
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.1", ngImport: i0, type: DaffDriverHttpClientCacheMagentoService, deps: [{ token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
532
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.1", ngImport: i0, type: DaffDriverHttpClientCacheMagentoService, providedIn: 'root' }); }
|
|
533
|
+
}
|
|
534
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.1", ngImport: i0, type: DaffDriverHttpClientCacheMagentoService, decorators: [{
|
|
535
|
+
type: Injectable,
|
|
536
|
+
args: [{
|
|
537
|
+
providedIn: 'root',
|
|
538
|
+
}]
|
|
539
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
540
|
+
type: Inject,
|
|
541
|
+
args: [PLATFORM_ID]
|
|
542
|
+
}] }] });
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* Sets up the Magento Daffodil driver configuration for Magento's GraphQl API.
|
|
546
|
+
*
|
|
547
|
+
* Under the hood, this creates an Apollo Client configuration.
|
|
548
|
+
*
|
|
549
|
+
* @param endpoint - The Magento store domain (e.g. "https://www.my-store.com/graphql") or an injection token for a string or function that returns a string
|
|
550
|
+
*/
|
|
551
|
+
function provideMagentoDriver(endpoint, options = {
|
|
552
|
+
possibleTypes: MAGENTO_POSSIBLE_TYPES,
|
|
553
|
+
typePolicies,
|
|
554
|
+
}) {
|
|
555
|
+
return [
|
|
556
|
+
provideApollo(() => ({
|
|
557
|
+
link: from([
|
|
558
|
+
createHttpLink(typeof endpoint === 'string' ? endpoint : inject(endpoint)),
|
|
559
|
+
]),
|
|
560
|
+
cache: new InMemoryCache({ typePolicies: options.typePolicies, possibleTypes: options.possibleTypes }),
|
|
561
|
+
})),
|
|
562
|
+
provideDaffDriverHttpClientCacheService(DaffDriverHttpClientCacheMagentoService),
|
|
563
|
+
];
|
|
564
|
+
}
|
|
565
|
+
|
|
103
566
|
const DAFF_DRIVER_MAGENTO_ERROR_CODE = 'DAFF_DRIVER_MAGENTO_ERROR';
|
|
104
567
|
/**
|
|
105
568
|
* A very general error thrown when a more specific error type cannot be determined.
|
|
@@ -183,10 +646,10 @@ class DaffMagentoApolloCacheableOperationsLinkGenerator {
|
|
|
183
646
|
return forward(operation);
|
|
184
647
|
});
|
|
185
648
|
}
|
|
186
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
187
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
649
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.1", ngImport: i0, type: DaffMagentoApolloCacheableOperationsLinkGenerator, deps: [{ token: DAFF_MAGENTO_CACHEABLE_OPERATIONS }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
650
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.1", ngImport: i0, type: DaffMagentoApolloCacheableOperationsLinkGenerator, providedIn: 'root' }); }
|
|
188
651
|
}
|
|
189
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
652
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.1", ngImport: i0, type: DaffMagentoApolloCacheableOperationsLinkGenerator, decorators: [{
|
|
190
653
|
type: Injectable,
|
|
191
654
|
args: [{
|
|
192
655
|
providedIn: 'root',
|
|
@@ -240,15 +703,12 @@ const DAFF_MAGENTO_2_4_3_TYPE_POLICIES = {
|
|
|
240
703
|
keyFields: () => 'Cart',
|
|
241
704
|
fields: {
|
|
242
705
|
applied_gift_cards: {
|
|
243
|
-
// eslint-disable-next-line no-unused-vars
|
|
244
706
|
merge: (existing, incoming) => incoming,
|
|
245
707
|
},
|
|
246
708
|
available_payment_methods: {
|
|
247
|
-
// eslint-disable-next-line no-unused-vars
|
|
248
709
|
merge: (existing, incoming) => incoming,
|
|
249
710
|
},
|
|
250
711
|
items: {
|
|
251
|
-
// eslint-disable-next-line no-unused-vars
|
|
252
712
|
merge: (existing, incoming) => incoming,
|
|
253
713
|
},
|
|
254
714
|
prices: {
|
|
@@ -320,7 +780,6 @@ const DAFF_MAGENTO_2_4_3_TYPE_POLICIES = {
|
|
|
320
780
|
CustomerAddress: {
|
|
321
781
|
fields: {
|
|
322
782
|
street: {
|
|
323
|
-
// eslint-disable-next-line no-unused-vars
|
|
324
783
|
merge: (existing, incoming) => incoming,
|
|
325
784
|
},
|
|
326
785
|
},
|
|
@@ -329,7 +788,6 @@ const DAFF_MAGENTO_2_4_3_TYPE_POLICIES = {
|
|
|
329
788
|
keyFields: () => 'CustomerPaymentTokens',
|
|
330
789
|
fields: {
|
|
331
790
|
items: {
|
|
332
|
-
// eslint-disable-next-line no-unused-vars
|
|
333
791
|
merge: (existing, incoming) => incoming,
|
|
334
792
|
},
|
|
335
793
|
},
|
|
@@ -427,33 +885,6 @@ const DAFF_MAGENTO_2_4_3_TYPE_POLICIES = {
|
|
|
427
885
|
},
|
|
428
886
|
};
|
|
429
887
|
|
|
430
|
-
/**
|
|
431
|
-
* Interacts with the Apollo client.
|
|
432
|
-
*
|
|
433
|
-
* @inheritdoc
|
|
434
|
-
*/
|
|
435
|
-
class DaffDriverHttpClientCacheMagentoService {
|
|
436
|
-
constructor(platformId) {
|
|
437
|
-
this.platformId = platformId;
|
|
438
|
-
}
|
|
439
|
-
reset() {
|
|
440
|
-
if (isPlatformBrowser(this.platformId)) {
|
|
441
|
-
location.reload();
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: DaffDriverHttpClientCacheMagentoService, deps: [{ token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
445
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: DaffDriverHttpClientCacheMagentoService, providedIn: 'root' }); }
|
|
446
|
-
}
|
|
447
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: DaffDriverHttpClientCacheMagentoService, decorators: [{
|
|
448
|
-
type: Injectable,
|
|
449
|
-
args: [{
|
|
450
|
-
providedIn: 'root',
|
|
451
|
-
}]
|
|
452
|
-
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
453
|
-
type: Inject,
|
|
454
|
-
args: [PLATFORM_ID]
|
|
455
|
-
}] }] });
|
|
456
|
-
|
|
457
888
|
const MAGENTO_CUSTOMER_CACHE_ID_HEADER = 'X-Magento-Cache-Id';
|
|
458
889
|
/**
|
|
459
890
|
* Stores and sets the Magento cache ID header.
|
|
@@ -482,10 +913,10 @@ class DaffMagentoCacheHeaderApolloLinkGenerator {
|
|
|
482
913
|
});
|
|
483
914
|
});
|
|
484
915
|
}
|
|
485
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
486
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
916
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.1", ngImport: i0, type: DaffMagentoCacheHeaderApolloLinkGenerator, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
917
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.1", ngImport: i0, type: DaffMagentoCacheHeaderApolloLinkGenerator, providedIn: 'root' }); }
|
|
487
918
|
}
|
|
488
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
919
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.1", ngImport: i0, type: DaffMagentoCacheHeaderApolloLinkGenerator, decorators: [{
|
|
489
920
|
type: Injectable,
|
|
490
921
|
args: [{
|
|
491
922
|
providedIn: 'root',
|
|
@@ -531,14 +962,17 @@ const magentoMoneyFragment = gql `
|
|
|
531
962
|
}
|
|
532
963
|
`;
|
|
533
964
|
|
|
965
|
+
/**
|
|
966
|
+
* @deprecated in favor of {@link provideMagentoDriver} Deprecated in version 0.88.0. Will be removed in version 0.91.0.
|
|
967
|
+
*/
|
|
534
968
|
class DaffDriverMagentoModule {
|
|
535
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
536
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "
|
|
537
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
969
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.1", ngImport: i0, type: DaffDriverMagentoModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
970
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.1", ngImport: i0, type: DaffDriverMagentoModule }); }
|
|
971
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.1", ngImport: i0, type: DaffDriverMagentoModule, providers: [
|
|
538
972
|
provideDaffDriverHttpClientCacheService(DaffDriverHttpClientCacheMagentoService),
|
|
539
973
|
] }); }
|
|
540
974
|
}
|
|
541
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
975
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.1", ngImport: i0, type: DaffDriverMagentoModule, decorators: [{
|
|
542
976
|
type: NgModule,
|
|
543
977
|
args: [{
|
|
544
978
|
providers: [
|
|
@@ -551,5 +985,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.11", ngImpo
|
|
|
551
985
|
* Generated bundle index. Do not edit.
|
|
552
986
|
*/
|
|
553
987
|
|
|
554
|
-
export { DAFF_DRIVER_MAGENTO_ERROR_CODE, DAFF_MAGENTO_2_4_3_TYPE_POLICIES, DAFF_MAGENTO_CACHEABLE_OPERATIONS, DaffDriverHttpClientCacheMagentoService, DaffDriverMagentoError, DaffDriverMagentoModule, DaffMagentoApolloCacheableOperationsLinkGenerator, DaffMagentoCacheHeaderApolloLinkGenerator, MAGENTO_CUSTOMER_CACHE_ID_HEADER, MagentoSortEnum, daffMagentoTransformGraphQlError, daffTransformMagentoError, magentoMoneyFragment, magentoPageInfoTransform, magentoSearchResultPageInfoFragment, magentoSortDirectionRequestTransform, magentoSortDirectionResponseTransform, provideDaffMagentoCacheableOperation, provideManyDaffMagentoCacheableOperations, schema };
|
|
988
|
+
export { DAFF_DRIVER_MAGENTO_ERROR_CODE, DAFF_MAGENTO_2_4_3_TYPE_POLICIES, DAFF_MAGENTO_CACHEABLE_OPERATIONS, DaffDriverHttpClientCacheMagentoService, DaffDriverMagentoError, DaffDriverMagentoModule, DaffMagentoApolloCacheableOperationsLinkGenerator, DaffMagentoCacheHeaderApolloLinkGenerator, MAGENTO_CUSTOMER_CACHE_ID_HEADER, MagentoSortEnum, daffMagentoTransformGraphQlError, daffTransformMagentoError, magentoMoneyFragment, magentoPageInfoTransform, magentoSearchResultPageInfoFragment, magentoSortDirectionRequestTransform, magentoSortDirectionResponseTransform, provideDaffMagentoCacheableOperation, provideMagentoDriver, provideManyDaffMagentoCacheableOperations, schema };
|
|
555
989
|
//# sourceMappingURL=daffodil-driver-magento.mjs.map
|