@daffodil/driver 0.47.3 → 0.48.1

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.
@@ -1,3 +1,4 @@
1
1
  export { DaffMagentoApolloCacheableOperationsLinkGenerator } from './cacheable-operations/apollo-cacheable-operations-link-generator';
2
2
  export * from './cacheable-operations/cacheable-operations-token';
3
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX2FwaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL2xpYnMvZHJpdmVyL21hZ2VudG8vc3JjL2dyYXBocWwvcHVibGljX2FwaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsaURBQWlELEVBQUUsTUFBTSxtRUFBbUUsQ0FBQztBQUN0SSxjQUFjLG1EQUFtRCxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IHsgRGFmZk1hZ2VudG9BcG9sbG9DYWNoZWFibGVPcGVyYXRpb25zTGlua0dlbmVyYXRvciB9IGZyb20gJy4vY2FjaGVhYmxlLW9wZXJhdGlvbnMvYXBvbGxvLWNhY2hlYWJsZS1vcGVyYXRpb25zLWxpbmstZ2VuZXJhdG9yJztcbmV4cG9ydCAqIGZyb20gJy4vY2FjaGVhYmxlLW9wZXJhdGlvbnMvY2FjaGVhYmxlLW9wZXJhdGlvbnMtdG9rZW4nO1xuIl19
3
+ export * from './type-policies';
4
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX2FwaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL2xpYnMvZHJpdmVyL21hZ2VudG8vc3JjL2dyYXBocWwvcHVibGljX2FwaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsaURBQWlELEVBQUUsTUFBTSxtRUFBbUUsQ0FBQztBQUN0SSxjQUFjLG1EQUFtRCxDQUFDO0FBQ2xFLGNBQWMsaUJBQWlCLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgeyBEYWZmTWFnZW50b0Fwb2xsb0NhY2hlYWJsZU9wZXJhdGlvbnNMaW5rR2VuZXJhdG9yIH0gZnJvbSAnLi9jYWNoZWFibGUtb3BlcmF0aW9ucy9hcG9sbG8tY2FjaGVhYmxlLW9wZXJhdGlvbnMtbGluay1nZW5lcmF0b3InO1xuZXhwb3J0ICogZnJvbSAnLi9jYWNoZWFibGUtb3BlcmF0aW9ucy9jYWNoZWFibGUtb3BlcmF0aW9ucy10b2tlbic7XG5leHBvcnQgKiBmcm9tICcuL3R5cGUtcG9saWNpZXMnO1xuIl19
@@ -0,0 +1,231 @@
1
+ /**
2
+ * Custom type policies that allow us to have more granular control
3
+ * over how ApolloClient reads from and writes to the cache.
4
+ *
5
+ * This is applicable to Magento 2.4.3 and up.
6
+ * Heavily based on https://github.com/magento/pwa-studio/blob/99270701b2b607551f2e5881af272ed48ba7064c/packages/peregrine/lib/Apollo/policies/index.js.
7
+ *
8
+ * https://www.apollographql.com/docs/react/caching/cache-configuration/#typepolicy-fields
9
+ * https://www.apollographql.com/docs/react/caching/cache-field-behavior/
10
+ */
11
+ export const DAFF_MAGENTO_2_4_3_TYPE_POLICIES = {
12
+ Query: {
13
+ fields: {
14
+ cart: {
15
+ // Replaces @connection(key: "Cart")
16
+ keyArgs: () => 'Cart',
17
+ },
18
+ customer: {
19
+ keyArgs: () => 'Customer',
20
+ },
21
+ customerCart: {
22
+ keyArgs: () => 'Cart',
23
+ },
24
+ },
25
+ },
26
+ AppliedGiftCard: {
27
+ keyFields: ['code'],
28
+ },
29
+ AvailablePaymentMethod: {
30
+ keyFields: ['code'],
31
+ },
32
+ AvailableShippingMethod: {
33
+ // The combination of these fields makes an instance of
34
+ // AvailableShippingMethod unique.
35
+ keyFields: ['carrier_code', 'method_code'],
36
+ },
37
+ Breadcrumb: {
38
+ // Uses provided fields on the object as the `id`.
39
+ keyFields: ['category_uid'],
40
+ },
41
+ Cart: {
42
+ keyFields: () => 'Cart',
43
+ fields: {
44
+ applied_gift_cards: {
45
+ // eslint-disable-next-line no-unused-vars
46
+ merge: (existing, incoming) => incoming,
47
+ },
48
+ available_payment_methods: {
49
+ // eslint-disable-next-line no-unused-vars
50
+ merge: (existing, incoming) => incoming,
51
+ },
52
+ items: {
53
+ // eslint-disable-next-line no-unused-vars
54
+ merge: (existing, incoming) => incoming,
55
+ },
56
+ prices: {
57
+ // `merge: true` can be used for an object field.
58
+ merge: true,
59
+ },
60
+ shipping_addresses: {
61
+ merge: (existing = [], incoming, { readField, mergeObjects }) => {
62
+ // street makes these things unique
63
+ const mergeResult = new Set();
64
+ const streetToIndex = new Map();
65
+ existing.forEach((existingShippingAddress, index) => {
66
+ // Use readField instead of existingShippingAddress.street directly because it will follow cache references.
67
+ const street = readField('street', existingShippingAddress);
68
+ streetToIndex.set(street, index);
69
+ });
70
+ incoming.forEach(incomingShippingAddress => {
71
+ const street = readField('street', incomingShippingAddress);
72
+ if (streetToIndex.has(street)) {
73
+ const targetIndex = streetToIndex.get(street);
74
+ const existingShippingAddress = existing[targetIndex];
75
+ const merged = mergeObjects(existingShippingAddress, incomingShippingAddress);
76
+ mergeResult.add(merged);
77
+ }
78
+ else {
79
+ // We do not have an address with this street yet, add it on to the end.
80
+ streetToIndex.set(street, streetToIndex.size);
81
+ mergeResult.add(incomingShippingAddress);
82
+ }
83
+ });
84
+ return Array.from(mergeResult);
85
+ },
86
+ },
87
+ },
88
+ },
89
+ Customer: {
90
+ keyFields: () => 'Customer',
91
+ fields: {
92
+ addresses: {
93
+ merge: (existing, incoming) => incoming,
94
+ read: (cachedAddresses, { toReference }) => {
95
+ if (cachedAddresses) {
96
+ return cachedAddresses.map(address => {
97
+ // Update v2 identifiers to new references. Previous
98
+ // entries had `id: CustomerAddress:1` which caused
99
+ // v3's lookup to fail. If we find a legacy id,
100
+ // point it at the object using a reference.
101
+ if (address.id?.includes('CustomerAddress')) {
102
+ return toReference(address.id);
103
+ }
104
+ else {
105
+ return address;
106
+ }
107
+ });
108
+ }
109
+ // If there are no cached addresses that's fine - the schema
110
+ // shows that it is a nullable field.
111
+ },
112
+ },
113
+ orders: {
114
+ keyArgs: ['filter'],
115
+ // TODO: write merge function that handles pagination
116
+ // items: {
117
+ // merge: true,
118
+ // },
119
+ },
120
+ },
121
+ },
122
+ CustomerAddress: {
123
+ fields: {
124
+ street: {
125
+ // eslint-disable-next-line no-unused-vars
126
+ merge: (existing, incoming) => incoming,
127
+ },
128
+ },
129
+ },
130
+ CustomerPaymentTokens: {
131
+ keyFields: () => 'CustomerPaymentTokens',
132
+ fields: {
133
+ items: {
134
+ // eslint-disable-next-line no-unused-vars
135
+ merge: (existing, incoming) => incoming,
136
+ },
137
+ },
138
+ },
139
+ ProductImage: {
140
+ keyFields: ['url'],
141
+ },
142
+ SelectedConfigurableOption: {
143
+ // id alone is not enough to identify a selected option as it can refer
144
+ // to something like "size" where value_id refers to "large".
145
+ keyFields: ['id', 'value_id'],
146
+ },
147
+ SelectedPaymentMethod: {
148
+ keyFields: ['code'],
149
+ },
150
+ ShippingCartAddress: {
151
+ keyFields: ['street'],
152
+ fields: {
153
+ available_shipping_methods: {
154
+ merge: (existing = [], incoming, { readField, mergeObjects }) => {
155
+ // carrier_code + method_code makes these things unique
156
+ const mergeResult = new Set();
157
+ const carrierToIndex = new Map();
158
+ existing.forEach((existingShippingMethod, index) => {
159
+ // Use readField because it will follow cache references.
160
+ const carrierCode = readField('carrier_code', existingShippingMethod);
161
+ const methodCode = readField('method_code', existingShippingMethod);
162
+ const carrierKey = `${carrierCode}|${methodCode}`;
163
+ carrierToIndex.set(carrierKey, index);
164
+ });
165
+ incoming.forEach(incomingShippingMethod => {
166
+ // Use readField because it will follow cache references.
167
+ const carrierCode = readField('carrier_code', incomingShippingMethod);
168
+ const methodCode = readField('method_code', incomingShippingMethod);
169
+ const carrierKey = `${carrierCode}|${methodCode}`;
170
+ if (carrierToIndex.has(carrierKey)) {
171
+ const targetIndex = carrierToIndex.get(carrierKey);
172
+ const existingShippingMethod = existing[targetIndex];
173
+ const merged = mergeObjects(existingShippingMethod, incomingShippingMethod);
174
+ mergeResult.add(merged);
175
+ }
176
+ else {
177
+ // We do not have a method with this key yet, add it on to the end.
178
+ carrierToIndex.set(carrierKey, carrierToIndex.size);
179
+ mergeResult.add(incomingShippingMethod);
180
+ }
181
+ });
182
+ return Array.from(mergeResult);
183
+ },
184
+ },
185
+ country: {
186
+ merge: true,
187
+ },
188
+ region: {
189
+ merge: true,
190
+ },
191
+ selected_shipping_method: {
192
+ merge: true,
193
+ },
194
+ },
195
+ },
196
+ CategoryTree: {
197
+ fields: {
198
+ children: {
199
+ merge: (existing, incoming) => incoming,
200
+ },
201
+ },
202
+ },
203
+ Wishlist: {
204
+ keyFields: ({ id }) => `CustomerWishlist:${id}`,
205
+ },
206
+ WishlistItem: {
207
+ keyFields: ({ id }) => `CustomerWishlistItem:${id}`,
208
+ },
209
+ SimpleWishlistItem: {
210
+ keyFields: ({ id }) => `CustomerSimpleWishlistItem:${id}`,
211
+ },
212
+ VirtualWishlistItem: {
213
+ keyFields: ({ id }) => `CustomerVirtualWishlistItem:${id}`,
214
+ },
215
+ DownloadableWishlistItem: {
216
+ keyFields: ({ id }) => `CustomerDownloadableWishlistItem:${id}`,
217
+ },
218
+ BundleWishlistItem: {
219
+ keyFields: ({ id }) => `CustomerBundleWishlistItem:${id}`,
220
+ },
221
+ GroupedProductWishlistItem: {
222
+ keyFields: ({ id }) => `CustomerGroupedProductWishlistItem:${id}`,
223
+ },
224
+ ConfigurableWishlistItem: {
225
+ keyFields: ({ id }) => `CustomerConfigurableWishlistItem:${id}`,
226
+ },
227
+ GiftCardWishlistItem: {
228
+ keyFields: ({ id }) => `CustomerGiftCardWishlistItem:${id}`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YWN5IGlkLFxuICAgICAgICAgICAgICAvLyBwb2ludCBpdCBhdCB0aGUgb2JqZWN0IHVzaW5nIGEgcmVmZXJlbmNlLlxuICAgICAgICAgICAgICBpZiAoYWRkcmVzcy5pZD8uaW5jbHVkZXMoJ0N1c3RvbWVyQWRkcmVzcycpKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHRvUmVmZXJlbmNlKGFkZHJlc3MuaWQpO1xuICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHJldHVybiBhZGRyZXNzO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICB9XG4gICAgICAgICAgLy8gSWYgdGhlcmUgYXJlIG5vIGNhY2hlZCBhZGRyZXNzZXMgdGhhdCdzIGZpbmUgLSB0aGUgc2NoZW1hXG4gICAgICAgICAgLy8gc2hvd3MgdGhhdCBpdCBpcyBhIG51bGxhYmxlIGZpZWxkLlxuICAgICAgICB9LFxuICAgICAgfSxcbiAgICAgIG9yZGVyczoge1xuICAgICAgICBrZXlBcmdzOiBbJ2ZpbHRlciddLFxuICAgICAgICAvLyBUT0RPOiB3cml0ZSBtZXJnZSBmdW5jdGlvbiB0aGF0IGhhbmRsZXMgcGFnaW5hdGlvblxuICAgICAgICAvLyBpdGVtczoge1xuICAgICAgICAvLyAgIG1lcmdlOiB0cnVlLFxuICAgICAgICAvLyB9LFxuICAgICAgfSxcbiAgICB9LFxuICB9LFxuICBDdXN0b21lckFkZHJlc3M6IHtcbiAgICBmaWVsZHM6IHtcbiAgICAgIHN0cmVldDoge1xuICAgICAgICAvLyBlc2xpbnQtZGlzYWJsZS1uZXh0LWxpbmUgbm8tdW51c2VkLXZhcnNcbiAgICAgICAgbWVyZ2U6IChleGlzdGluZywgaW5jb21pbmcpID0+IGluY29taW5nLFxuICAgICAgfSxcbiAgICB9LFxuICB9LFxuICBDdXN0b21lclBheW1lbnRUb2tlbnM6IHtcbiAgICBrZXlGaWVsZHM6ICg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gICBjb25zdCBjYXJyaWVyVG9JbmRleCA9IG5ldyBNYXAoKTtcblxuICAgICAgICAgIGV4aXN0aW5nLmZvckVhY2goKGV4aXN0aW5nU2hpcHBpbmdNZXRob2QsIGluZGV4KSA9PiB7XG4gICAgICAgICAgICAvLyBVc2UgcmVhZEZpZWxkIGJlY2F1c2UgaXQgd2lsbCBmb2xsb3cgY2FjaGUgcmVmZXJlbmNlcy5cbiAgICAgICAgICAgIGNvbnN0IGNhcnJpZXJDb2RlID0gcmVhZEZpZWxkKFxuICAgICAgICAgICAgICAnY2Fycmllcl9jb2RlJyxcbiAgICAgICAgICAgICAgZXhpc3RpbmdTaGlwcGluZ01ldGhvZCxcbiAgICAgICAgICAgICk7XG4gICAgICAgICAgICBjb25zdCBtZXRob2RDb2RlID0gcmVhZEZpZWxkKFxuICAgICAgICAgICAgICAnbWV0aG9kX2NvZGUnLFxuICAgICAgICAgICAgICBleGlzdGluZ1NoaXBwaW5nTWV0aG9kLFxuICAgICAgICAgICAgKTtcbiAgICAgICAgICAgIGNvbnN0IGNhcnJpZXJLZXkgPSBgJHtjYXJyaWVyQ29kZX18JHttZXRob2RDb2RlfWA7XG4gICAgICAgICAgICBjYXJyaWVyVG9JbmRleC5zZXQoY2FycmllcktleSwgaW5kZXgpO1xuICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgaW5jb21pbmcuZm9yRWFjaChpbmNvbWluZ1NoaXBwaW5nTWV0aG9kID0+IHtcbiAgICAgICAgICAgIC8vIFVzZSByZWFkRmllbGQgYmVjYXVzZSBpdCB3aWxsIGZvbGxvdyBjYWNoZSByZWZlcmVuY2VzLlxuICAgICAgICAgICAgY29uc3QgY2FycmllckNvZGUgPSByZWFkRmllbGQoXG4gICAgICAgICAgICAgICdjYXJyaWVyX2NvZGUnLFxuICAgICAgICAgICAgICBpbmNvbWluZ1NoaXBwaW5nTWV0aG9kLFxuICAgICAgICAgICAgKTtcbiAgICAgICAgICAgIGNvbnN0IG1ldGhvZENvZGUgPSByZWFkRmllbGQoXG4gICAgICAgICAgICAgICdtZXRob2RfY29kZScsXG4gICAgICAgICAgICAgIGluY29taW5nU2hpcHBpbmdNZXRob2QsXG4gICAgICAgICAgICApO1xuICAgICAgICAgICAgY29uc3QgY2FycmllcktleSA9IGAke2NhcnJpZXJDb2RlfXwke21ldGhvZENvZGV9YDtcbiAgICAgICAgICAgIGlmIChjYXJyaWVyVG9JbmRleC5oYXMoY2FycmllcktleSkpIHtcbiAgICAgICAgICAgICAgY29uc3QgdGFyZ2V0SW5kZXggPSBjYXJyaWVyVG9JbmRleC5nZXQoY2FycmllcktleSk7XG4gICAgICAgICAgICAgIGNvbnN0IGV4aXN0aW5nU2hpcHBpbmdNZXRob2QgPSBleGlzdGluZ1t0YXJnZXRJbmRleF07XG4gICAgICAgICAgICAgIGNvbnN0IG1lcmdlZCA9IG1lcmdlT2JqZWN0cyhcbiAgICAgICAgICAgICAgICBleGlzdGluZ1NoaXBwaW5nTWV0aG9kLFxuICAgICAgICAgICAgICAgIGluY29taW5nU2hpcHBpbmdNZXRob2QsXG4gICAgICAgICAgICAgICk7XG4gICAgICAgICAgICAgIG1lcmdlUmVzdWx0LmFkZChtZXJnZWQpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgLy8gV2UgZG8gbm90IGhhdmUgYSBtZXRob2Qgd2l0aCB0aGlzIGtleSB5ZXQsIGFkZCBpdCBvbiB0byB0aGUgZW5kLlxuICAgICAgICAgICAgICBjYXJyaWVyVG9JbmRleC5zZXQoY2FycmllcktleSwgY2FycmllclRvSW5kZXguc2l6ZSk7XG4gICAgICAgICAgICAgIG1lcmdlUmVzdWx0LmFkZChpbmNvbWluZ1NoaXBwaW5nTWV0aG9kKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9KTtcblxuICAgICAgICAgIHJldHVybiBBcnJheS5mcm9tKG1lcmdlUmVzdWx0KTtcbiAgICAgICAgfSxcbiAgICAgIH0sXG4gICAgICBjb3VudHJ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ZW06JHtpZH1gLFxuICB9LFxuICBHcm91cGVkUHJvZHVjdFdpc2hsaXN0SXRlbToge1xuICAgIGtleUZpZWxkczogKHsgaWQgfSkgPT4gYEN1c3RvbWVyR3JvdXBlZFByb2R1Y3RXaXNobGlzdEl0ZW06JHtpZH1gLFxuICB9LFxuICBDb25maWd1cmFibGVXaXNobGlzdEl0ZW06IHtcbiAgICBrZXlGaWVsZHM6ICh7IGlkIH0pID0+IGBDdXN0b21lckNvbmZpZ3VyYWJsZVdpc2hsaXN0SXRlbToke2lkfWAsXG4gIH0sXG4gIEdpZnRDYXJkV2lzaGxpc3RJdGVtOiB7XG4gICAga2V5RmllbGRzOiAoeyBpZCB9KSA9PiBgQ3VzdG9tZXJHaWZ0Q2FyZFdpc2hsaXN0SXRlbToke2lkfWAsXG4gIH0sXG59O1xuIl19
@@ -192,9 +192,241 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImpor
192
192
  }] }];
193
193
  } });
194
194
 
195
+ /**
196
+ * Custom type policies that allow us to have more granular control
197
+ * over how ApolloClient reads from and writes to the cache.
198
+ *
199
+ * This is applicable to Magento 2.4.3 and up.
200
+ * Heavily based on https://github.com/magento/pwa-studio/blob/99270701b2b607551f2e5881af272ed48ba7064c/packages/peregrine/lib/Apollo/policies/index.js.
201
+ *
202
+ * https://www.apollographql.com/docs/react/caching/cache-configuration/#typepolicy-fields
203
+ * https://www.apollographql.com/docs/react/caching/cache-field-behavior/
204
+ */
205
+ const DAFF_MAGENTO_2_4_3_TYPE_POLICIES = {
206
+ Query: {
207
+ fields: {
208
+ cart: {
209
+ // Replaces @connection(key: "Cart")
210
+ keyArgs: () => 'Cart',
211
+ },
212
+ customer: {
213
+ keyArgs: () => 'Customer',
214
+ },
215
+ customerCart: {
216
+ keyArgs: () => 'Cart',
217
+ },
218
+ },
219
+ },
220
+ AppliedGiftCard: {
221
+ keyFields: ['code'],
222
+ },
223
+ AvailablePaymentMethod: {
224
+ keyFields: ['code'],
225
+ },
226
+ AvailableShippingMethod: {
227
+ // The combination of these fields makes an instance of
228
+ // AvailableShippingMethod unique.
229
+ keyFields: ['carrier_code', 'method_code'],
230
+ },
231
+ Breadcrumb: {
232
+ // Uses provided fields on the object as the `id`.
233
+ keyFields: ['category_uid'],
234
+ },
235
+ Cart: {
236
+ keyFields: () => 'Cart',
237
+ fields: {
238
+ applied_gift_cards: {
239
+ // eslint-disable-next-line no-unused-vars
240
+ merge: (existing, incoming) => incoming,
241
+ },
242
+ available_payment_methods: {
243
+ // eslint-disable-next-line no-unused-vars
244
+ merge: (existing, incoming) => incoming,
245
+ },
246
+ items: {
247
+ // eslint-disable-next-line no-unused-vars
248
+ merge: (existing, incoming) => incoming,
249
+ },
250
+ prices: {
251
+ // `merge: true` can be used for an object field.
252
+ merge: true,
253
+ },
254
+ shipping_addresses: {
255
+ merge: (existing = [], incoming, { readField, mergeObjects }) => {
256
+ // street makes these things unique
257
+ const mergeResult = new Set();
258
+ const streetToIndex = new Map();
259
+ existing.forEach((existingShippingAddress, index) => {
260
+ // Use readField instead of existingShippingAddress.street directly because it will follow cache references.
261
+ const street = readField('street', existingShippingAddress);
262
+ streetToIndex.set(street, index);
263
+ });
264
+ incoming.forEach(incomingShippingAddress => {
265
+ const street = readField('street', incomingShippingAddress);
266
+ if (streetToIndex.has(street)) {
267
+ const targetIndex = streetToIndex.get(street);
268
+ const existingShippingAddress = existing[targetIndex];
269
+ const merged = mergeObjects(existingShippingAddress, incomingShippingAddress);
270
+ mergeResult.add(merged);
271
+ }
272
+ else {
273
+ // We do not have an address with this street yet, add it on to the end.
274
+ streetToIndex.set(street, streetToIndex.size);
275
+ mergeResult.add(incomingShippingAddress);
276
+ }
277
+ });
278
+ return Array.from(mergeResult);
279
+ },
280
+ },
281
+ },
282
+ },
283
+ Customer: {
284
+ keyFields: () => 'Customer',
285
+ fields: {
286
+ addresses: {
287
+ merge: (existing, incoming) => incoming,
288
+ read: (cachedAddresses, { toReference }) => {
289
+ if (cachedAddresses) {
290
+ return cachedAddresses.map(address => {
291
+ var _a;
292
+ // Update v2 identifiers to new references. Previous
293
+ // entries had `id: CustomerAddress:1` which caused
294
+ // v3's lookup to fail. If we find a legacy id,
295
+ // point it at the object using a reference.
296
+ if ((_a = address.id) === null || _a === void 0 ? void 0 : _a.includes('CustomerAddress')) {
297
+ return toReference(address.id);
298
+ }
299
+ else {
300
+ return address;
301
+ }
302
+ });
303
+ }
304
+ // If there are no cached addresses that's fine - the schema
305
+ // shows that it is a nullable field.
306
+ },
307
+ },
308
+ orders: {
309
+ keyArgs: ['filter'],
310
+ // TODO: write merge function that handles pagination
311
+ // items: {
312
+ // merge: true,
313
+ // },
314
+ },
315
+ },
316
+ },
317
+ CustomerAddress: {
318
+ fields: {
319
+ street: {
320
+ // eslint-disable-next-line no-unused-vars
321
+ merge: (existing, incoming) => incoming,
322
+ },
323
+ },
324
+ },
325
+ CustomerPaymentTokens: {
326
+ keyFields: () => 'CustomerPaymentTokens',
327
+ fields: {
328
+ items: {
329
+ // eslint-disable-next-line no-unused-vars
330
+ merge: (existing, incoming) => incoming,
331
+ },
332
+ },
333
+ },
334
+ ProductImage: {
335
+ keyFields: ['url'],
336
+ },
337
+ SelectedConfigurableOption: {
338
+ // id alone is not enough to identify a selected option as it can refer
339
+ // to something like "size" where value_id refers to "large".
340
+ keyFields: ['id', 'value_id'],
341
+ },
342
+ SelectedPaymentMethod: {
343
+ keyFields: ['code'],
344
+ },
345
+ ShippingCartAddress: {
346
+ keyFields: ['street'],
347
+ fields: {
348
+ available_shipping_methods: {
349
+ merge: (existing = [], incoming, { readField, mergeObjects }) => {
350
+ // carrier_code + method_code makes these things unique
351
+ const mergeResult = new Set();
352
+ const carrierToIndex = new Map();
353
+ existing.forEach((existingShippingMethod, index) => {
354
+ // Use readField because it will follow cache references.
355
+ const carrierCode = readField('carrier_code', existingShippingMethod);
356
+ const methodCode = readField('method_code', existingShippingMethod);
357
+ const carrierKey = `${carrierCode}|${methodCode}`;
358
+ carrierToIndex.set(carrierKey, index);
359
+ });
360
+ incoming.forEach(incomingShippingMethod => {
361
+ // Use readField because it will follow cache references.
362
+ const carrierCode = readField('carrier_code', incomingShippingMethod);
363
+ const methodCode = readField('method_code', incomingShippingMethod);
364
+ const carrierKey = `${carrierCode}|${methodCode}`;
365
+ if (carrierToIndex.has(carrierKey)) {
366
+ const targetIndex = carrierToIndex.get(carrierKey);
367
+ const existingShippingMethod = existing[targetIndex];
368
+ const merged = mergeObjects(existingShippingMethod, incomingShippingMethod);
369
+ mergeResult.add(merged);
370
+ }
371
+ else {
372
+ // We do not have a method with this key yet, add it on to the end.
373
+ carrierToIndex.set(carrierKey, carrierToIndex.size);
374
+ mergeResult.add(incomingShippingMethod);
375
+ }
376
+ });
377
+ return Array.from(mergeResult);
378
+ },
379
+ },
380
+ country: {
381
+ merge: true,
382
+ },
383
+ region: {
384
+ merge: true,
385
+ },
386
+ selected_shipping_method: {
387
+ merge: true,
388
+ },
389
+ },
390
+ },
391
+ CategoryTree: {
392
+ fields: {
393
+ children: {
394
+ merge: (existing, incoming) => incoming,
395
+ },
396
+ },
397
+ },
398
+ Wishlist: {
399
+ keyFields: ({ id }) => `CustomerWishlist:${id}`,
400
+ },
401
+ WishlistItem: {
402
+ keyFields: ({ id }) => `CustomerWishlistItem:${id}`,
403
+ },
404
+ SimpleWishlistItem: {
405
+ keyFields: ({ id }) => `CustomerSimpleWishlistItem:${id}`,
406
+ },
407
+ VirtualWishlistItem: {
408
+ keyFields: ({ id }) => `CustomerVirtualWishlistItem:${id}`,
409
+ },
410
+ DownloadableWishlistItem: {
411
+ keyFields: ({ id }) => `CustomerDownloadableWishlistItem:${id}`,
412
+ },
413
+ BundleWishlistItem: {
414
+ keyFields: ({ id }) => `CustomerBundleWishlistItem:${id}`,
415
+ },
416
+ GroupedProductWishlistItem: {
417
+ keyFields: ({ id }) => `CustomerGroupedProductWishlistItem:${id}`,
418
+ },
419
+ ConfigurableWishlistItem: {
420
+ keyFields: ({ id }) => `CustomerConfigurableWishlistItem:${id}`,
421
+ },
422
+ GiftCardWishlistItem: {
423
+ keyFields: ({ id }) => `CustomerGiftCardWishlistItem:${id}`,
424
+ },
425
+ };
426
+
195
427
  /**
196
428
  * Generated bundle index. Do not edit.
197
429
  */
198
430
 
199
- export { DAFF_DRIVER_MAGENTO_ERROR_CODE, DAFF_MAGENTO_CACHEABLE_OPERATIONS, DaffDriverMagentoError, DaffMagentoApolloCacheableOperationsLinkGenerator, daffMagentoTransformGraphQlError, daffTransformMagentoError, provideDaffMagentoCacheableOperation, provideManyDaffMagentoCacheableOperations, schema };
431
+ export { DAFF_DRIVER_MAGENTO_ERROR_CODE, DAFF_MAGENTO_2_4_3_TYPE_POLICIES, DAFF_MAGENTO_CACHEABLE_OPERATIONS, DaffDriverMagentoError, DaffMagentoApolloCacheableOperationsLinkGenerator, daffMagentoTransformGraphQlError, daffTransformMagentoError, provideDaffMagentoCacheableOperation, provideManyDaffMagentoCacheableOperations, schema };
200
432
  //# sourceMappingURL=daffodil-driver-magento.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"daffodil-driver-magento.mjs","sources":["../../../libs/driver/magento/src/schema/schema.ts","../../../libs/driver/magento/src/errors/error.class.ts","../../../libs/driver/magento/src/errors/transform-graphql.ts","../../../libs/driver/magento/src/errors/transform.ts","../../../libs/driver/magento/src/graphql/cacheable-operations/cacheable-operations-token.ts","../../../libs/driver/magento/src/graphql/cacheable-operations/apollo-cacheable-operations-link-generator.ts","../../../libs/driver/magento/src/daffodil-driver-magento.ts"],"sourcesContent":["import introspectionQueryResultData from './introspection.json';\n\nexport const schema = introspectionQueryResultData;\n","import {\n DaffError,\n DaffInheritableError,\n} from '@daffodil/core';\n\nexport const DAFF_DRIVER_MAGENTO_ERROR_CODE = 'DAFF_DRIVER_MAGENTO_ERROR';\n\n/**\n * A very general error thrown when a more specific error type cannot be determined.\n */\nexport class DaffDriverMagentoError extends DaffInheritableError implements DaffError {\n public readonly code: string = DAFF_DRIVER_MAGENTO_ERROR_CODE;\n\n constructor(message?: string) {\n\t super(message);\n }\n}\n","import { GraphQLError } from 'graphql';\n\nimport {\n DaffError,\n DaffErrorCodeMap,\n} from '@daffodil/core';\n\nimport { DaffDriverMagentoError } from './error.class';\n\nexport function daffMagentoTransformGraphQlError<T extends DaffErrorCodeMap>(\n error: GraphQLError,\n map: T,\n): DaffError {\n const ErrorClass = map[error.extensions.category] || DaffDriverMagentoError;\n\n return new ErrorClass(error.message) ;\n};\n","import {\n DaffError,\n DaffErrorCodeMap,\n daffIsError,\n} from '@daffodil/core';\n\nimport { DaffDriverMagentoError } from './error.class';\nimport { daffMagentoTransformGraphQlError } from './transform-graphql';\n\n/**\n * Transforms the passed error according to the lookup in the passed map.\n */\n// TODO: return array of errors\nexport function daffTransformMagentoError<T extends DaffErrorCodeMap>(error: any, map: T): DaffError {\n // TODO: handle network errors\n if (error.graphQLErrors) {\n return error.graphQLErrors.map(err => daffMagentoTransformGraphQlError<T>(err, map))[0];\n } else if (daffIsError(error)) {\n return error;\n } else {\n return new DaffDriverMagentoError(error.message);\n }\n};\n","import { InjectionToken } from '@angular/core';\n\n/**\n * A multi-provider injection token of the operation names of magento queries that should\n * be cached. This is needed because queries need to be converted into GET queries in order for Magento\n * to cache them. This token should be used by daffodil driver platform modules to register operation names that are cacheable, and is\n * intended for internal daffodil use only.\n */\nexport const DAFF_MAGENTO_CACHEABLE_OPERATIONS = new InjectionToken<string[]>('DAFF_MAGENTO_CACHEABLE_OPERATIONS', { factory: () => []});\n\n/**\n * Adds an operation name to the list of cacheable Magento operations. Use only with Angular 9+.\n */\nexport function provideDaffMagentoCacheableOperation(operationName: string) {\n return {\n provide: DAFF_MAGENTO_CACHEABLE_OPERATIONS,\n useValue: operationName,\n multi: true,\n };\n}\n\n/**\n * Adds many operation names to the list of cacheable Magento operations. Use only with Angular 9+.\n */\nexport function provideManyDaffMagentoCacheableOperations(...operationNames: string[]) {\n return operationNames.map(name => ({\n provide: DAFF_MAGENTO_CACHEABLE_OPERATIONS,\n useValue: name,\n multi: true,\n }));\n}\n","import {\n Inject,\n Injectable,\n} from '@angular/core';\nimport { ApolloLink } from '@apollo/client/core';\n\nimport { DaffApolloLinkGenerator } from '@daffodil/core/graphql';\n\nimport { DAFF_MAGENTO_CACHEABLE_OPERATIONS } from './cacheable-operations-token';\n\n/**\n * A service that will convert cacheable apollo operations into a format that Magento will understand as cacheable.\n *\n * @inheritdoc\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffMagentoApolloCacheableOperationsLinkGenerator implements DaffApolloLinkGenerator {\n constructor(\n @Inject(DAFF_MAGENTO_CACHEABLE_OPERATIONS) private apolloGetRequests: string[],\n ) {}\n\n getLink(): ApolloLink {\n return new ApolloLink((operation, forward) => {\n if(this.apolloGetRequests.indexOf(operation.operationName) > -1) {\n operation.setContext({ method: 'GET' });\n }\n return forward(operation);\n });\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,MAAM,MAAM,GAAG;;ACGf,MAAM,8BAA8B,GAAG,4BAA4B;AAE1E;;AAEG;AACG,MAAO,sBAAuB,SAAQ,oBAAoB,CAAA;AAG9D,IAAA,WAAA,CAAY,OAAgB,EAAA;QAC3B,KAAK,CAAC,OAAO,CAAC,CAAC;AAHA,QAAA,IAAI,CAAA,IAAA,GAAW,8BAA8B,CAAC;KAI7D;AACF;;ACPe,SAAA,gCAAgC,CAC9C,KAAmB,EACnB,GAAM,EAAA;AAEN,IAAA,MAAM,UAAU,GAAG,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,sBAAsB,CAAC;AAE5E,IAAA,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAE;AACxC,CAAC;AAAA;;ACP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AAiB,CAAC,OAAO,CAAC,SAAS,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,EAAE;gBAC/D,SAAS,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;AACzC,aAAA;AACD,YAAA,OAAO,OAAO,CAAC,SAAS,CAAC,CAAC;AAC5B,SAAC,CAAC,CAAC;KACJ;;AAZU,iDAAA,CAAA,IAAA,GAAA,EAAA,CAAA,kBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,iDAAiD,kBAElD,iCAAiC,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAFhC,iDAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,iDAAiD,cAFhD,MAAM,EAAA,CAAA,CAAA;2FAEP,iDAAiD,EAAA,UAAA,EAAA,CAAA;kBAH7D,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;iBACnB,CAAA;;;8BAGI,MAAM;+BAAC,iCAAiC,CAAA;;;;ACpB7C;;AAEG;;;;"}
1
+ {"version":3,"file":"daffodil-driver-magento.mjs","sources":["../../../libs/driver/magento/src/schema/schema.ts","../../../libs/driver/magento/src/errors/error.class.ts","../../../libs/driver/magento/src/errors/transform-graphql.ts","../../../libs/driver/magento/src/errors/transform.ts","../../../libs/driver/magento/src/graphql/cacheable-operations/cacheable-operations-token.ts","../../../libs/driver/magento/src/graphql/cacheable-operations/apollo-cacheable-operations-link-generator.ts","../../../libs/driver/magento/src/graphql/type-policies.ts","../../../libs/driver/magento/src/daffodil-driver-magento.ts"],"sourcesContent":["import introspectionQueryResultData from './introspection.json';\n\nexport const schema = introspectionQueryResultData;\n","import {\n DaffError,\n DaffInheritableError,\n} from '@daffodil/core';\n\nexport const DAFF_DRIVER_MAGENTO_ERROR_CODE = 'DAFF_DRIVER_MAGENTO_ERROR';\n\n/**\n * A very general error thrown when a more specific error type cannot be determined.\n */\nexport class DaffDriverMagentoError extends DaffInheritableError implements DaffError {\n public readonly code: string = DAFF_DRIVER_MAGENTO_ERROR_CODE;\n\n constructor(message?: string) {\n\t super(message);\n }\n}\n","import { GraphQLError } from 'graphql';\n\nimport {\n DaffError,\n DaffErrorCodeMap,\n} from '@daffodil/core';\n\nimport { DaffDriverMagentoError } from './error.class';\n\nexport function daffMagentoTransformGraphQlError<T extends DaffErrorCodeMap>(\n error: GraphQLError,\n map: T,\n): DaffError {\n const ErrorClass = map[error.extensions.category] || DaffDriverMagentoError;\n\n return new ErrorClass(error.message) ;\n};\n","import {\n DaffError,\n DaffErrorCodeMap,\n daffIsError,\n} from '@daffodil/core';\n\nimport { DaffDriverMagentoError } from './error.class';\nimport { daffMagentoTransformGraphQlError } from './transform-graphql';\n\n/**\n * Transforms the passed error according to the lookup in the passed map.\n */\n// TODO: return array of errors\nexport function daffTransformMagentoError<T extends DaffErrorCodeMap>(error: any, map: T): DaffError {\n // TODO: handle network errors\n if (error.graphQLErrors) {\n return error.graphQLErrors.map(err => daffMagentoTransformGraphQlError<T>(err, map))[0];\n } else if (daffIsError(error)) {\n return error;\n } else {\n return new DaffDriverMagentoError(error.message);\n }\n};\n","import { InjectionToken } from '@angular/core';\n\n/**\n * A multi-provider injection token of the operation names of magento queries that should\n * be cached. This is needed because queries need to be converted into GET queries in order for Magento\n * to cache them. This token should be used by daffodil driver platform modules to register operation names that are cacheable, and is\n * intended for internal daffodil use only.\n */\nexport const DAFF_MAGENTO_CACHEABLE_OPERATIONS = new InjectionToken<string[]>('DAFF_MAGENTO_CACHEABLE_OPERATIONS', { factory: () => []});\n\n/**\n * Adds an operation name to the list of cacheable Magento operations. Use only with Angular 9+.\n */\nexport function provideDaffMagentoCacheableOperation(operationName: string) {\n return {\n provide: DAFF_MAGENTO_CACHEABLE_OPERATIONS,\n useValue: operationName,\n multi: true,\n };\n}\n\n/**\n * Adds many operation names to the list of cacheable Magento operations. Use only with Angular 9+.\n */\nexport function provideManyDaffMagentoCacheableOperations(...operationNames: string[]) {\n return operationNames.map(name => ({\n provide: DAFF_MAGENTO_CACHEABLE_OPERATIONS,\n useValue: name,\n multi: true,\n }));\n}\n","import {\n Inject,\n Injectable,\n} from '@angular/core';\nimport { ApolloLink } from '@apollo/client/core';\n\nimport { DaffApolloLinkGenerator } from '@daffodil/core/graphql';\n\nimport { DAFF_MAGENTO_CACHEABLE_OPERATIONS } from './cacheable-operations-token';\n\n/**\n * A service that will convert cacheable apollo operations into a format that Magento will understand as cacheable.\n *\n * @inheritdoc\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffMagentoApolloCacheableOperationsLinkGenerator implements DaffApolloLinkGenerator {\n constructor(\n @Inject(DAFF_MAGENTO_CACHEABLE_OPERATIONS) private apolloGetRequests: string[],\n ) {}\n\n getLink(): ApolloLink {\n return new ApolloLink((operation, forward) => {\n if(this.apolloGetRequests.indexOf(operation.operationName) > -1) {\n operation.setContext({ method: 'GET' });\n }\n return forward(operation);\n });\n }\n}\n","import { TypePolicies } from '@apollo/client/core';\n\n/**\n * Custom type policies that allow us to have more granular control\n * over how ApolloClient reads from and writes to the cache.\n *\n * This is applicable to Magento 2.4.3 and up.\n * Heavily based on https://github.com/magento/pwa-studio/blob/99270701b2b607551f2e5881af272ed48ba7064c/packages/peregrine/lib/Apollo/policies/index.js.\n *\n * https://www.apollographql.com/docs/react/caching/cache-configuration/#typepolicy-fields\n * https://www.apollographql.com/docs/react/caching/cache-field-behavior/\n */\nexport const DAFF_MAGENTO_2_4_3_TYPE_POLICIES: TypePolicies = {\n Query: {\n fields: {\n cart: {\n // Replaces @connection(key: \"Cart\")\n keyArgs: () => 'Cart',\n },\n customer: {\n keyArgs: () => 'Customer',\n },\n customerCart: {\n keyArgs: () => 'Cart',\n },\n },\n },\n AppliedGiftCard: {\n keyFields: ['code'],\n },\n AvailablePaymentMethod: {\n keyFields: ['code'],\n },\n AvailableShippingMethod: {\n // The combination of these fields makes an instance of\n // AvailableShippingMethod unique.\n keyFields: ['carrier_code', 'method_code'],\n },\n Breadcrumb: {\n // Uses provided fields on the object as the `id`.\n keyFields: ['category_uid'],\n },\n Cart: {\n keyFields: () => 'Cart',\n fields: {\n applied_gift_cards: {\n // eslint-disable-next-line no-unused-vars\n merge: (existing, incoming) => incoming,\n },\n available_payment_methods: {\n // eslint-disable-next-line no-unused-vars\n merge: (existing, incoming) => incoming,\n },\n items: {\n // eslint-disable-next-line no-unused-vars\n merge: (existing, incoming) => incoming,\n },\n prices: {\n // `merge: true` can be used for an object field.\n merge: true,\n },\n shipping_addresses: {\n merge:(existing = [], incoming, { readField, mergeObjects }) => {\n // street makes these things unique\n const mergeResult = new Set();\n const streetToIndex = new Map();\n\n existing.forEach((existingShippingAddress, index) => {\n // Use readField instead of existingShippingAddress.street directly because it will follow cache references.\n const street = readField(\n 'street',\n existingShippingAddress,\n );\n streetToIndex.set(street, index);\n });\n\n incoming.forEach(incomingShippingAddress => {\n const street = readField(\n 'street',\n incomingShippingAddress,\n );\n\n if (streetToIndex.has(street)) {\n const targetIndex = streetToIndex.get(street);\n const existingShippingAddress = existing[targetIndex];\n const merged = mergeObjects(\n existingShippingAddress,\n incomingShippingAddress,\n );\n mergeResult.add(merged);\n } else {\n // We do not have an address with this street yet, add it on to the end.\n streetToIndex.set(street, streetToIndex.size);\n mergeResult.add(incomingShippingAddress);\n }\n });\n\n return Array.from(mergeResult);\n },\n },\n },\n },\n Customer: {\n keyFields: () => 'Customer',\n fields: {\n addresses: {\n merge: (existing, incoming) => incoming,\n read: (cachedAddresses, { toReference }) => {\n if (cachedAddresses) {\n return cachedAddresses.map(address => {\n // Update v2 identifiers to new references. Previous\n // entries had `id: CustomerAddress:1` which caused\n // v3's lookup to fail. If we find a legacy id,\n // point it at the object using a reference.\n if (address.id?.includes('CustomerAddress')) {\n return toReference(address.id);\n } else {\n return address;\n }\n });\n }\n // If there are no cached addresses that's fine - the schema\n // shows that it is a nullable field.\n },\n },\n orders: {\n keyArgs: ['filter'],\n // TODO: write merge function that handles pagination\n // items: {\n // merge: true,\n // },\n },\n },\n },\n CustomerAddress: {\n fields: {\n street: {\n // eslint-disable-next-line no-unused-vars\n merge: (existing, incoming) => incoming,\n },\n },\n },\n CustomerPaymentTokens: {\n keyFields: () => 'CustomerPaymentTokens',\n fields: {\n items: {\n // eslint-disable-next-line no-unused-vars\n merge: (existing, incoming) => incoming,\n },\n },\n },\n ProductImage: {\n keyFields: ['url'],\n },\n SelectedConfigurableOption: {\n // id alone is not enough to identify a selected option as it can refer\n // to something like \"size\" where value_id refers to \"large\".\n keyFields: ['id', 'value_id'],\n },\n SelectedPaymentMethod: {\n keyFields: ['code'],\n },\n ShippingCartAddress: {\n keyFields: ['street'],\n fields: {\n available_shipping_methods: {\n merge: (existing = [], incoming, { readField, mergeObjects }) => {\n // carrier_code + method_code makes these things unique\n const mergeResult = new Set();\n const carrierToIndex = new Map();\n\n existing.forEach((existingShippingMethod, index) => {\n // Use readField because it will follow cache references.\n const carrierCode = readField(\n 'carrier_code',\n existingShippingMethod,\n );\n const methodCode = readField(\n 'method_code',\n existingShippingMethod,\n );\n const carrierKey = `${carrierCode}|${methodCode}`;\n carrierToIndex.set(carrierKey, index);\n });\n\n incoming.forEach(incomingShippingMethod => {\n // Use readField because it will follow cache references.\n const carrierCode = readField(\n 'carrier_code',\n incomingShippingMethod,\n );\n const methodCode = readField(\n 'method_code',\n incomingShippingMethod,\n );\n const carrierKey = `${carrierCode}|${methodCode}`;\n if (carrierToIndex.has(carrierKey)) {\n const targetIndex = carrierToIndex.get(carrierKey);\n const existingShippingMethod = existing[targetIndex];\n const merged = mergeObjects(\n existingShippingMethod,\n incomingShippingMethod,\n );\n mergeResult.add(merged);\n } else {\n // We do not have a method with this key yet, add it on to the end.\n carrierToIndex.set(carrierKey, carrierToIndex.size);\n mergeResult.add(incomingShippingMethod);\n }\n });\n\n return Array.from(mergeResult);\n },\n },\n country: {\n merge: true,\n },\n region: {\n merge: true,\n },\n selected_shipping_method: {\n merge: true,\n },\n },\n },\n CategoryTree: {\n fields: {\n children: {\n merge: (existing, incoming) => incoming,\n },\n },\n },\n Wishlist: {\n keyFields: ({ id }) => `CustomerWishlist:${id}`,\n },\n WishlistItem: {\n keyFields: ({ id }) => `CustomerWishlistItem:${id}`,\n },\n SimpleWishlistItem: {\n keyFields: ({ id }) => `CustomerSimpleWishlistItem:${id}`,\n },\n VirtualWishlistItem: {\n keyFields: ({ id }) => `CustomerVirtualWishlistItem:${id}`,\n },\n DownloadableWishlistItem: {\n keyFields: ({ id }) => `CustomerDownloadableWishlistItem:${id}`,\n },\n BundleWishlistItem: {\n keyFields: ({ id }) => `CustomerBundleWishlistItem:${id}`,\n },\n GroupedProductWishlistItem: {\n keyFields: ({ id }) => `CustomerGroupedProductWishlistItem:${id}`,\n },\n ConfigurableWishlistItem: {\n keyFields: ({ id }) => `CustomerConfigurableWishlistItem:${id}`,\n },\n GiftCardWishlistItem: {\n keyFields: ({ id }) => `CustomerGiftCardWishlistItem:${id}`,\n },\n};\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,MAAM,MAAM,GAAG;;ACGf,MAAM,8BAA8B,GAAG,4BAA4B;AAE1E;;AAEG;AACG,MAAO,sBAAuB,SAAQ,oBAAoB,CAAA;AAG9D,IAAA,WAAA,CAAY,OAAgB,EAAA;QAC3B,KAAK,CAAC,OAAO,CAAC,CAAC;AAHA,QAAA,IAAI,CAAA,IAAA,GAAW,8BAA8B,CAAC;KAI7D;AACF;;ACPe,SA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CAAA;AAC1D,KAAA;AACD,IAAA,0BAA0B,EAAE;QAC1B,SAAS,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,CAAsC,mCAAA,EAAA,EAAE,CAAE,CAAA;AAClE,KAAA;AACD,IAAA,wBAAwB,EAAE;QACxB,SAAS,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,CAAoC,iCAAA,EAAA,EAAE,CAAE,CAAA;AAChE,KAAA;AACD,IAAA,oBAAoB,EAAE;QACpB,SAAS,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,CAAgC,6BAAA,EAAA,EAAE,CAAE,CAAA;AAC5D,KAAA;;;AClQH;;AAEG;;;;"}
@@ -190,9 +190,240 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImpor
190
190
  args: [DAFF_MAGENTO_CACHEABLE_OPERATIONS]
191
191
  }] }]; } });
192
192
 
193
+ /**
194
+ * Custom type policies that allow us to have more granular control
195
+ * over how ApolloClient reads from and writes to the cache.
196
+ *
197
+ * This is applicable to Magento 2.4.3 and up.
198
+ * Heavily based on https://github.com/magento/pwa-studio/blob/99270701b2b607551f2e5881af272ed48ba7064c/packages/peregrine/lib/Apollo/policies/index.js.
199
+ *
200
+ * https://www.apollographql.com/docs/react/caching/cache-configuration/#typepolicy-fields
201
+ * https://www.apollographql.com/docs/react/caching/cache-field-behavior/
202
+ */
203
+ const DAFF_MAGENTO_2_4_3_TYPE_POLICIES = {
204
+ Query: {
205
+ fields: {
206
+ cart: {
207
+ // Replaces @connection(key: "Cart")
208
+ keyArgs: () => 'Cart',
209
+ },
210
+ customer: {
211
+ keyArgs: () => 'Customer',
212
+ },
213
+ customerCart: {
214
+ keyArgs: () => 'Cart',
215
+ },
216
+ },
217
+ },
218
+ AppliedGiftCard: {
219
+ keyFields: ['code'],
220
+ },
221
+ AvailablePaymentMethod: {
222
+ keyFields: ['code'],
223
+ },
224
+ AvailableShippingMethod: {
225
+ // The combination of these fields makes an instance of
226
+ // AvailableShippingMethod unique.
227
+ keyFields: ['carrier_code', 'method_code'],
228
+ },
229
+ Breadcrumb: {
230
+ // Uses provided fields on the object as the `id`.
231
+ keyFields: ['category_uid'],
232
+ },
233
+ Cart: {
234
+ keyFields: () => 'Cart',
235
+ fields: {
236
+ applied_gift_cards: {
237
+ // eslint-disable-next-line no-unused-vars
238
+ merge: (existing, incoming) => incoming,
239
+ },
240
+ available_payment_methods: {
241
+ // eslint-disable-next-line no-unused-vars
242
+ merge: (existing, incoming) => incoming,
243
+ },
244
+ items: {
245
+ // eslint-disable-next-line no-unused-vars
246
+ merge: (existing, incoming) => incoming,
247
+ },
248
+ prices: {
249
+ // `merge: true` can be used for an object field.
250
+ merge: true,
251
+ },
252
+ shipping_addresses: {
253
+ merge: (existing = [], incoming, { readField, mergeObjects }) => {
254
+ // street makes these things unique
255
+ const mergeResult = new Set();
256
+ const streetToIndex = new Map();
257
+ existing.forEach((existingShippingAddress, index) => {
258
+ // Use readField instead of existingShippingAddress.street directly because it will follow cache references.
259
+ const street = readField('street', existingShippingAddress);
260
+ streetToIndex.set(street, index);
261
+ });
262
+ incoming.forEach(incomingShippingAddress => {
263
+ const street = readField('street', incomingShippingAddress);
264
+ if (streetToIndex.has(street)) {
265
+ const targetIndex = streetToIndex.get(street);
266
+ const existingShippingAddress = existing[targetIndex];
267
+ const merged = mergeObjects(existingShippingAddress, incomingShippingAddress);
268
+ mergeResult.add(merged);
269
+ }
270
+ else {
271
+ // We do not have an address with this street yet, add it on to the end.
272
+ streetToIndex.set(street, streetToIndex.size);
273
+ mergeResult.add(incomingShippingAddress);
274
+ }
275
+ });
276
+ return Array.from(mergeResult);
277
+ },
278
+ },
279
+ },
280
+ },
281
+ Customer: {
282
+ keyFields: () => 'Customer',
283
+ fields: {
284
+ addresses: {
285
+ merge: (existing, incoming) => incoming,
286
+ read: (cachedAddresses, { toReference }) => {
287
+ if (cachedAddresses) {
288
+ return cachedAddresses.map(address => {
289
+ // Update v2 identifiers to new references. Previous
290
+ // entries had `id: CustomerAddress:1` which caused
291
+ // v3's lookup to fail. If we find a legacy id,
292
+ // point it at the object using a reference.
293
+ if (address.id?.includes('CustomerAddress')) {
294
+ return toReference(address.id);
295
+ }
296
+ else {
297
+ return address;
298
+ }
299
+ });
300
+ }
301
+ // If there are no cached addresses that's fine - the schema
302
+ // shows that it is a nullable field.
303
+ },
304
+ },
305
+ orders: {
306
+ keyArgs: ['filter'],
307
+ // TODO: write merge function that handles pagination
308
+ // items: {
309
+ // merge: true,
310
+ // },
311
+ },
312
+ },
313
+ },
314
+ CustomerAddress: {
315
+ fields: {
316
+ street: {
317
+ // eslint-disable-next-line no-unused-vars
318
+ merge: (existing, incoming) => incoming,
319
+ },
320
+ },
321
+ },
322
+ CustomerPaymentTokens: {
323
+ keyFields: () => 'CustomerPaymentTokens',
324
+ fields: {
325
+ items: {
326
+ // eslint-disable-next-line no-unused-vars
327
+ merge: (existing, incoming) => incoming,
328
+ },
329
+ },
330
+ },
331
+ ProductImage: {
332
+ keyFields: ['url'],
333
+ },
334
+ SelectedConfigurableOption: {
335
+ // id alone is not enough to identify a selected option as it can refer
336
+ // to something like "size" where value_id refers to "large".
337
+ keyFields: ['id', 'value_id'],
338
+ },
339
+ SelectedPaymentMethod: {
340
+ keyFields: ['code'],
341
+ },
342
+ ShippingCartAddress: {
343
+ keyFields: ['street'],
344
+ fields: {
345
+ available_shipping_methods: {
346
+ merge: (existing = [], incoming, { readField, mergeObjects }) => {
347
+ // carrier_code + method_code makes these things unique
348
+ const mergeResult = new Set();
349
+ const carrierToIndex = new Map();
350
+ existing.forEach((existingShippingMethod, index) => {
351
+ // Use readField because it will follow cache references.
352
+ const carrierCode = readField('carrier_code', existingShippingMethod);
353
+ const methodCode = readField('method_code', existingShippingMethod);
354
+ const carrierKey = `${carrierCode}|${methodCode}`;
355
+ carrierToIndex.set(carrierKey, index);
356
+ });
357
+ incoming.forEach(incomingShippingMethod => {
358
+ // Use readField because it will follow cache references.
359
+ const carrierCode = readField('carrier_code', incomingShippingMethod);
360
+ const methodCode = readField('method_code', incomingShippingMethod);
361
+ const carrierKey = `${carrierCode}|${methodCode}`;
362
+ if (carrierToIndex.has(carrierKey)) {
363
+ const targetIndex = carrierToIndex.get(carrierKey);
364
+ const existingShippingMethod = existing[targetIndex];
365
+ const merged = mergeObjects(existingShippingMethod, incomingShippingMethod);
366
+ mergeResult.add(merged);
367
+ }
368
+ else {
369
+ // We do not have a method with this key yet, add it on to the end.
370
+ carrierToIndex.set(carrierKey, carrierToIndex.size);
371
+ mergeResult.add(incomingShippingMethod);
372
+ }
373
+ });
374
+ return Array.from(mergeResult);
375
+ },
376
+ },
377
+ country: {
378
+ merge: true,
379
+ },
380
+ region: {
381
+ merge: true,
382
+ },
383
+ selected_shipping_method: {
384
+ merge: true,
385
+ },
386
+ },
387
+ },
388
+ CategoryTree: {
389
+ fields: {
390
+ children: {
391
+ merge: (existing, incoming) => incoming,
392
+ },
393
+ },
394
+ },
395
+ Wishlist: {
396
+ keyFields: ({ id }) => `CustomerWishlist:${id}`,
397
+ },
398
+ WishlistItem: {
399
+ keyFields: ({ id }) => `CustomerWishlistItem:${id}`,
400
+ },
401
+ SimpleWishlistItem: {
402
+ keyFields: ({ id }) => `CustomerSimpleWishlistItem:${id}`,
403
+ },
404
+ VirtualWishlistItem: {
405
+ keyFields: ({ id }) => `CustomerVirtualWishlistItem:${id}`,
406
+ },
407
+ DownloadableWishlistItem: {
408
+ keyFields: ({ id }) => `CustomerDownloadableWishlistItem:${id}`,
409
+ },
410
+ BundleWishlistItem: {
411
+ keyFields: ({ id }) => `CustomerBundleWishlistItem:${id}`,
412
+ },
413
+ GroupedProductWishlistItem: {
414
+ keyFields: ({ id }) => `CustomerGroupedProductWishlistItem:${id}`,
415
+ },
416
+ ConfigurableWishlistItem: {
417
+ keyFields: ({ id }) => `CustomerConfigurableWishlistItem:${id}`,
418
+ },
419
+ GiftCardWishlistItem: {
420
+ keyFields: ({ id }) => `CustomerGiftCardWishlistItem:${id}`,
421
+ },
422
+ };
423
+
193
424
  /**
194
425
  * Generated bundle index. Do not edit.
195
426
  */
196
427
 
197
- export { DAFF_DRIVER_MAGENTO_ERROR_CODE, DAFF_MAGENTO_CACHEABLE_OPERATIONS, DaffDriverMagentoError, DaffMagentoApolloCacheableOperationsLinkGenerator, daffMagentoTransformGraphQlError, daffTransformMagentoError, provideDaffMagentoCacheableOperation, provideManyDaffMagentoCacheableOperations, schema };
428
+ export { DAFF_DRIVER_MAGENTO_ERROR_CODE, DAFF_MAGENTO_2_4_3_TYPE_POLICIES, DAFF_MAGENTO_CACHEABLE_OPERATIONS, DaffDriverMagentoError, DaffMagentoApolloCacheableOperationsLinkGenerator, daffMagentoTransformGraphQlError, daffTransformMagentoError, provideDaffMagentoCacheableOperation, provideManyDaffMagentoCacheableOperations, schema };
198
429
  //# sourceMappingURL=daffodil-driver-magento.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"daffodil-driver-magento.mjs","sources":["../../../libs/driver/magento/src/schema/schema.ts","../../../libs/driver/magento/src/errors/error.class.ts","../../../libs/driver/magento/src/errors/transform-graphql.ts","../../../libs/driver/magento/src/errors/transform.ts","../../../libs/driver/magento/src/graphql/cacheable-operations/cacheable-operations-token.ts","../../../libs/driver/magento/src/graphql/cacheable-operations/apollo-cacheable-operations-link-generator.ts","../../../libs/driver/magento/src/daffodil-driver-magento.ts"],"sourcesContent":["import introspectionQueryResultData from './introspection.json';\n\nexport const schema = introspectionQueryResultData;\n","import {\n DaffError,\n DaffInheritableError,\n} from '@daffodil/core';\n\nexport const DAFF_DRIVER_MAGENTO_ERROR_CODE = 'DAFF_DRIVER_MAGENTO_ERROR';\n\n/**\n * A very general error thrown when a more specific error type cannot be determined.\n */\nexport class DaffDriverMagentoError extends DaffInheritableError implements DaffError {\n public readonly code: string = DAFF_DRIVER_MAGENTO_ERROR_CODE;\n\n constructor(message?: string) {\n\t super(message);\n }\n}\n","import { GraphQLError } from 'graphql';\n\nimport {\n DaffError,\n DaffErrorCodeMap,\n} from '@daffodil/core';\n\nimport { DaffDriverMagentoError } from './error.class';\n\nexport function daffMagentoTransformGraphQlError<T extends DaffErrorCodeMap>(\n error: GraphQLError,\n map: T,\n): DaffError {\n const ErrorClass = map[error.extensions.category] || DaffDriverMagentoError;\n\n return new ErrorClass(error.message) ;\n};\n","import {\n DaffError,\n DaffErrorCodeMap,\n daffIsError,\n} from '@daffodil/core';\n\nimport { DaffDriverMagentoError } from './error.class';\nimport { daffMagentoTransformGraphQlError } from './transform-graphql';\n\n/**\n * Transforms the passed error according to the lookup in the passed map.\n */\n// TODO: return array of errors\nexport function daffTransformMagentoError<T extends DaffErrorCodeMap>(error: any, map: T): DaffError {\n // TODO: handle network errors\n if (error.graphQLErrors) {\n return error.graphQLErrors.map(err => daffMagentoTransformGraphQlError<T>(err, map))[0];\n } else if (daffIsError(error)) {\n return error;\n } else {\n return new DaffDriverMagentoError(error.message);\n }\n};\n","import { InjectionToken } from '@angular/core';\n\n/**\n * A multi-provider injection token of the operation names of magento queries that should\n * be cached. This is needed because queries need to be converted into GET queries in order for Magento\n * to cache them. This token should be used by daffodil driver platform modules to register operation names that are cacheable, and is\n * intended for internal daffodil use only.\n */\nexport const DAFF_MAGENTO_CACHEABLE_OPERATIONS = new InjectionToken<string[]>('DAFF_MAGENTO_CACHEABLE_OPERATIONS', { factory: () => []});\n\n/**\n * Adds an operation name to the list of cacheable Magento operations. Use only with Angular 9+.\n */\nexport function provideDaffMagentoCacheableOperation(operationName: string) {\n return {\n provide: DAFF_MAGENTO_CACHEABLE_OPERATIONS,\n useValue: operationName,\n multi: true,\n };\n}\n\n/**\n * Adds many operation names to the list of cacheable Magento operations. Use only with Angular 9+.\n */\nexport function provideManyDaffMagentoCacheableOperations(...operationNames: string[]) {\n return operationNames.map(name => ({\n provide: DAFF_MAGENTO_CACHEABLE_OPERATIONS,\n useValue: name,\n multi: true,\n }));\n}\n","import {\n Inject,\n Injectable,\n} from '@angular/core';\nimport { ApolloLink } from '@apollo/client/core';\n\nimport { DaffApolloLinkGenerator } from '@daffodil/core/graphql';\n\nimport { DAFF_MAGENTO_CACHEABLE_OPERATIONS } from './cacheable-operations-token';\n\n/**\n * A service that will convert cacheable apollo operations into a format that Magento will understand as cacheable.\n *\n * @inheritdoc\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffMagentoApolloCacheableOperationsLinkGenerator implements DaffApolloLinkGenerator {\n constructor(\n @Inject(DAFF_MAGENTO_CACHEABLE_OPERATIONS) private apolloGetRequests: string[],\n ) {}\n\n getLink(): ApolloLink {\n return new ApolloLink((operation, forward) => {\n if(this.apolloGetRequests.indexOf(operation.operationName) > -1) {\n operation.setContext({ method: 'GET' });\n }\n return forward(operation);\n });\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,MAAM,MAAM,GAAG;;ACGf,MAAM,8BAA8B,GAAG,4BAA4B;AAE1E;;AAEG;AACG,MAAO,sBAAuB,SAAQ,oBAAoB,CAAA;AAG9D,IAAA,WAAA,CAAY,OAAgB,EAAA;QAC3B,KAAK,CAAC,OAAO,CAAC,CAAC;QAHA,IAAI,CAAA,IAAA,GAAW,8BAA8B,CAAC;KAI7D;AACF;;ACPe,SAAA,gCAAgC,CAC9C,KAAmB,EACnB,GAAM,EAAA;AAEN,IAAA,MAAM,UAAU,GAAG,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,sBAAsB,CAAC;AAE5E,IAAA,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAE;AACxC,CAAC;AAAA;;ACPD;;AAEG;AACH;AACgB,SAAA,yBAAyB,CAA6B,KAAU,EAAE,GAAM,EAAA;;IAEtF,IAAI,KAAK,CAAC,aAAa,EAAE;QACv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M,EAAE,KAAK,EAAE,CAAC,CAAC;AACzC,aAAA;AACD,YAAA,OAAO,OAAO,CAAC,SAAS,CAAC,CAAC;AAC5B,SAAC,CAAC,CAAC;KACJ;;AAZU,iDAAA,CAAA,IAAA,GAAA,EAAA,CAAA,kBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,iDAAiD,kBAElD,iCAAiC,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAFhC,iDAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,iDAAiD,cAFhD,MAAM,EAAA,CAAA,CAAA;2FAEP,iDAAiD,EAAA,UAAA,EAAA,CAAA;kBAH7D,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA,CAAA;;0BAGI,MAAM;2BAAC,iCAAiC,CAAA;;;ACpB7C;;AAEG;;;;"}
1
+ {"version":3,"file":"daffodil-driver-magento.mjs","sources":["../../../libs/driver/magento/src/schema/schema.ts","../../../libs/driver/magento/src/errors/error.class.ts","../../../libs/driver/magento/src/errors/transform-graphql.ts","../../../libs/driver/magento/src/errors/transform.ts","../../../libs/driver/magento/src/graphql/cacheable-operations/cacheable-operations-token.ts","../../../libs/driver/magento/src/graphql/cacheable-operations/apollo-cacheable-operations-link-generator.ts","../../../libs/driver/magento/src/graphql/type-policies.ts","../../../libs/driver/magento/src/daffodil-driver-magento.ts"],"sourcesContent":["import introspectionQueryResultData from './introspection.json';\n\nexport const schema = introspectionQueryResultData;\n","import {\n DaffError,\n DaffInheritableError,\n} from '@daffodil/core';\n\nexport const DAFF_DRIVER_MAGENTO_ERROR_CODE = 'DAFF_DRIVER_MAGENTO_ERROR';\n\n/**\n * A very general error thrown when a more specific error type cannot be determined.\n */\nexport class DaffDriverMagentoError extends DaffInheritableError implements DaffError {\n public readonly code: string = DAFF_DRIVER_MAGENTO_ERROR_CODE;\n\n constructor(message?: string) {\n\t super(message);\n }\n}\n","import { GraphQLError } from 'graphql';\n\nimport {\n DaffError,\n DaffErrorCodeMap,\n} from '@daffodil/core';\n\nimport { DaffDriverMagentoError } from './error.class';\n\nexport function daffMagentoTransformGraphQlError<T extends DaffErrorCodeMap>(\n error: GraphQLError,\n map: T,\n): DaffError {\n const ErrorClass = map[error.extensions.category] || DaffDriverMagentoError;\n\n return new ErrorClass(error.message) ;\n};\n","import {\n DaffError,\n DaffErrorCodeMap,\n daffIsError,\n} from '@daffodil/core';\n\nimport { DaffDriverMagentoError } from './error.class';\nimport { daffMagentoTransformGraphQlError } from './transform-graphql';\n\n/**\n * Transforms the passed error according to the lookup in the passed map.\n */\n// TODO: return array of errors\nexport function daffTransformMagentoError<T extends DaffErrorCodeMap>(error: any, map: T): DaffError {\n // TODO: handle network errors\n if (error.graphQLErrors) {\n return error.graphQLErrors.map(err => daffMagentoTransformGraphQlError<T>(err, map))[0];\n } else if (daffIsError(error)) {\n return error;\n } else {\n return new DaffDriverMagentoError(error.message);\n }\n};\n","import { InjectionToken } from '@angular/core';\n\n/**\n * A multi-provider injection token of the operation names of magento queries that should\n * be cached. This is needed because queries need to be converted into GET queries in order for Magento\n * to cache them. This token should be used by daffodil driver platform modules to register operation names that are cacheable, and is\n * intended for internal daffodil use only.\n */\nexport const DAFF_MAGENTO_CACHEABLE_OPERATIONS = new InjectionToken<string[]>('DAFF_MAGENTO_CACHEABLE_OPERATIONS', { factory: () => []});\n\n/**\n * Adds an operation name to the list of cacheable Magento operations. Use only with Angular 9+.\n */\nexport function provideDaffMagentoCacheableOperation(operationName: string) {\n return {\n provide: DAFF_MAGENTO_CACHEABLE_OPERATIONS,\n useValue: operationName,\n multi: true,\n };\n}\n\n/**\n * Adds many operation names to the list of cacheable Magento operations. Use only with Angular 9+.\n */\nexport function provideManyDaffMagentoCacheableOperations(...operationNames: string[]) {\n return operationNames.map(name => ({\n provide: DAFF_MAGENTO_CACHEABLE_OPERATIONS,\n useValue: name,\n multi: true,\n }));\n}\n","import {\n Inject,\n Injectable,\n} from '@angular/core';\nimport { ApolloLink } from '@apollo/client/core';\n\nimport { DaffApolloLinkGenerator } from '@daffodil/core/graphql';\n\nimport { DAFF_MAGENTO_CACHEABLE_OPERATIONS } from './cacheable-operations-token';\n\n/**\n * A service that will convert cacheable apollo operations into a format that Magento will understand as cacheable.\n *\n * @inheritdoc\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffMagentoApolloCacheableOperationsLinkGenerator implements DaffApolloLinkGenerator {\n constructor(\n @Inject(DAFF_MAGENTO_CACHEABLE_OPERATIONS) private apolloGetRequests: string[],\n ) {}\n\n getLink(): ApolloLink {\n return new ApolloLink((operation, forward) => {\n if(this.apolloGetRequests.indexOf(operation.operationName) > -1) {\n operation.setContext({ method: 'GET' });\n }\n return forward(operation);\n });\n }\n}\n","import { TypePolicies } from '@apollo/client/core';\n\n/**\n * Custom type policies that allow us to have more granular control\n * over how ApolloClient reads from and writes to the cache.\n *\n * This is applicable to Magento 2.4.3 and up.\n * Heavily based on https://github.com/magento/pwa-studio/blob/99270701b2b607551f2e5881af272ed48ba7064c/packages/peregrine/lib/Apollo/policies/index.js.\n *\n * https://www.apollographql.com/docs/react/caching/cache-configuration/#typepolicy-fields\n * https://www.apollographql.com/docs/react/caching/cache-field-behavior/\n */\nexport const DAFF_MAGENTO_2_4_3_TYPE_POLICIES: TypePolicies = {\n Query: {\n fields: {\n cart: {\n // Replaces @connection(key: \"Cart\")\n keyArgs: () => 'Cart',\n },\n customer: {\n keyArgs: () => 'Customer',\n },\n customerCart: {\n keyArgs: () => 'Cart',\n },\n },\n },\n AppliedGiftCard: {\n keyFields: ['code'],\n },\n AvailablePaymentMethod: {\n keyFields: ['code'],\n },\n AvailableShippingMethod: {\n // The combination of these fields makes an instance of\n // AvailableShippingMethod unique.\n keyFields: ['carrier_code', 'method_code'],\n },\n Breadcrumb: {\n // Uses provided fields on the object as the `id`.\n keyFields: ['category_uid'],\n },\n Cart: {\n keyFields: () => 'Cart',\n fields: {\n applied_gift_cards: {\n // eslint-disable-next-line no-unused-vars\n merge: (existing, incoming) => incoming,\n },\n available_payment_methods: {\n // eslint-disable-next-line no-unused-vars\n merge: (existing, incoming) => incoming,\n },\n items: {\n // eslint-disable-next-line no-unused-vars\n merge: (existing, incoming) => incoming,\n },\n prices: {\n // `merge: true` can be used for an object field.\n merge: true,\n },\n shipping_addresses: {\n merge:(existing = [], incoming, { readField, mergeObjects }) => {\n // street makes these things unique\n const mergeResult = new Set();\n const streetToIndex = new Map();\n\n existing.forEach((existingShippingAddress, index) => {\n // Use readField instead of existingShippingAddress.street directly because it will follow cache references.\n const street = readField(\n 'street',\n existingShippingAddress,\n );\n streetToIndex.set(street, index);\n });\n\n incoming.forEach(incomingShippingAddress => {\n const street = readField(\n 'street',\n incomingShippingAddress,\n );\n\n if (streetToIndex.has(street)) {\n const targetIndex = streetToIndex.get(street);\n const existingShippingAddress = existing[targetIndex];\n const merged = mergeObjects(\n existingShippingAddress,\n incomingShippingAddress,\n );\n mergeResult.add(merged);\n } else {\n // We do not have an address with this street yet, add it on to the end.\n streetToIndex.set(street, streetToIndex.size);\n mergeResult.add(incomingShippingAddress);\n }\n });\n\n return Array.from(mergeResult);\n },\n },\n },\n },\n Customer: {\n keyFields: () => 'Customer',\n fields: {\n addresses: {\n merge: (existing, incoming) => incoming,\n read: (cachedAddresses, { toReference }) => {\n if (cachedAddresses) {\n return cachedAddresses.map(address => {\n // Update v2 identifiers to new references. Previous\n // entries had `id: CustomerAddress:1` which caused\n // v3's lookup to fail. If we find a legacy id,\n // point it at the object using a reference.\n if (address.id?.includes('CustomerAddress')) {\n return toReference(address.id);\n } else {\n return address;\n }\n });\n }\n // If there are no cached addresses that's fine - the schema\n // shows that it is a nullable field.\n },\n },\n orders: {\n keyArgs: ['filter'],\n // TODO: write merge function that handles pagination\n // items: {\n // merge: true,\n // },\n },\n },\n },\n CustomerAddress: {\n fields: {\n street: {\n // eslint-disable-next-line no-unused-vars\n merge: (existing, incoming) => incoming,\n },\n },\n },\n CustomerPaymentTokens: {\n keyFields: () => 'CustomerPaymentTokens',\n fields: {\n items: {\n // eslint-disable-next-line no-unused-vars\n merge: (existing, incoming) => incoming,\n },\n },\n },\n ProductImage: {\n keyFields: ['url'],\n },\n SelectedConfigurableOption: {\n // id alone is not enough to identify a selected option as it can refer\n // to something like \"size\" where value_id refers to \"large\".\n keyFields: ['id', 'value_id'],\n },\n SelectedPaymentMethod: {\n keyFields: ['code'],\n },\n ShippingCartAddress: {\n keyFields: ['street'],\n fields: {\n available_shipping_methods: {\n merge: (existing = [], incoming, { readField, mergeObjects }) => {\n // carrier_code + method_code makes these things unique\n const mergeResult = new Set();\n const carrierToIndex = new Map();\n\n existing.forEach((existingShippingMethod, index) => {\n // Use readField because it will follow cache references.\n const carrierCode = readField(\n 'carrier_code',\n existingShippingMethod,\n );\n const methodCode = readField(\n 'method_code',\n existingShippingMethod,\n );\n const carrierKey = `${carrierCode}|${methodCode}`;\n carrierToIndex.set(carrierKey, index);\n });\n\n incoming.forEach(incomingShippingMethod => {\n // Use readField because it will follow cache references.\n const carrierCode = readField(\n 'carrier_code',\n incomingShippingMethod,\n );\n const methodCode = readField(\n 'method_code',\n incomingShippingMethod,\n );\n const carrierKey = `${carrierCode}|${methodCode}`;\n if (carrierToIndex.has(carrierKey)) {\n const targetIndex = carrierToIndex.get(carrierKey);\n const existingShippingMethod = existing[targetIndex];\n const merged = mergeObjects(\n existingShippingMethod,\n incomingShippingMethod,\n );\n mergeResult.add(merged);\n } else {\n // We do not have a method with this key yet, add it on to the end.\n carrierToIndex.set(carrierKey, carrierToIndex.size);\n mergeResult.add(incomingShippingMethod);\n }\n });\n\n return Array.from(mergeResult);\n },\n },\n country: {\n merge: true,\n },\n region: {\n merge: true,\n },\n selected_shipping_method: {\n merge: true,\n },\n },\n },\n CategoryTree: {\n fields: {\n children: {\n merge: (existing, incoming) => incoming,\n },\n },\n },\n Wishlist: {\n keyFields: ({ id }) => `CustomerWishlist:${id}`,\n },\n WishlistItem: {\n keyFields: ({ id }) => `CustomerWishlistItem:${id}`,\n },\n SimpleWishlistItem: {\n keyFields: ({ id }) => `CustomerSimpleWishlistItem:${id}`,\n },\n VirtualWishlistItem: {\n keyFields: ({ id }) => `CustomerVirtualWishlistItem:${id}`,\n },\n DownloadableWishlistItem: {\n keyFields: ({ id }) => `CustomerDownloadableWishlistItem:${id}`,\n },\n BundleWishlistItem: {\n keyFields: ({ id }) => `CustomerBundleWishlistItem:${id}`,\n },\n GroupedProductWishlistItem: {\n keyFields: ({ id }) => `CustomerGroupedProductWishlistItem:${id}`,\n },\n ConfigurableWishlistItem: {\n keyFields: ({ id }) => `CustomerConfigurableWishlistItem:${id}`,\n },\n GiftCardWishlistItem: {\n keyFields: ({ id }) => `CustomerGiftCardWishlistItem:${id}`,\n },\n};\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,MAAM,MAAM,GAAG;;ACGf,MAAM,8BAA8B,GAAG,4BAA4B;AAE1E;;AAEG;AACG,MAAO,sBAAuB,SAAQ,oBAAoB,CAAA;AAG9D,IAAA,WAAA,CAAY,OAAgB,EAAA;QAC3B,KAAK,CAAC,OAAO,CAAC,CAAC;QAHA,IAAI,CAAA,IAAA,GAAW,8BAA8B,CAAC;KAI7D;AACF;;ACPe,SAAA,gCAAgC,CAC9C,KAAmB,EACnB,GAAM,EAAA;AAEN,IAAA,MAAM,UAAU,GAAG,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ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AAA;AACD,IAAA,wBAAwB,EAAE;QACxB,SAAS,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,CAAoC,iCAAA,EAAA,EAAE,CAAE,CAAA;AAChE,KAAA;AACD,IAAA,oBAAoB,EAAE;QACpB,SAAS,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,CAAgC,6BAAA,EAAA,EAAE,CAAE,CAAA;AAC5D,KAAA;;;AClQH;;AAEG;;;;"}
@@ -1,2 +1,3 @@
1
1
  export { DaffMagentoApolloCacheableOperationsLinkGenerator } from './cacheable-operations/apollo-cacheable-operations-link-generator';
2
2
  export * from './cacheable-operations/cacheable-operations-token';
3
+ export * from './type-policies';
@@ -0,0 +1,12 @@
1
+ import { TypePolicies } from '@apollo/client/core';
2
+ /**
3
+ * Custom type policies that allow us to have more granular control
4
+ * over how ApolloClient reads from and writes to the cache.
5
+ *
6
+ * This is applicable to Magento 2.4.3 and up.
7
+ * Heavily based on https://github.com/magento/pwa-studio/blob/99270701b2b607551f2e5881af272ed48ba7064c/packages/peregrine/lib/Apollo/policies/index.js.
8
+ *
9
+ * https://www.apollographql.com/docs/react/caching/cache-configuration/#typepolicy-fields
10
+ * https://www.apollographql.com/docs/react/caching/cache-field-behavior/
11
+ */
12
+ export declare const DAFF_MAGENTO_2_4_3_TYPE_POLICIES: TypePolicies;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@daffodil/driver",
3
- "version": "0.47.3",
3
+ "version": "0.48.1",
4
4
  "description": "A consistent, sane api driver that works with different ecommerce systems.",
5
5
  "repository": {
6
6
  "type": "git",