@daffodil/customer-order 0.94.1-rc.0 → 0.95.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-customer-order-driver-magento-2.4.5-testing.mjs +148 -86
- package/fesm2022/daffodil-customer-order-driver-magento-2.4.5-testing.mjs.map +1 -1
- package/fesm2022/daffodil-customer-order-driver-magento-2.4.5.mjs +401 -420
- package/fesm2022/daffodil-customer-order-driver-magento-2.4.5.mjs.map +1 -1
- package/fesm2022/daffodil-customer-order-driver-magento-2.4.6-testing.mjs +148 -86
- package/fesm2022/daffodil-customer-order-driver-magento-2.4.6-testing.mjs.map +1 -1
- package/fesm2022/daffodil-customer-order-driver-magento-2.4.6.mjs +415 -432
- package/fesm2022/daffodil-customer-order-driver-magento-2.4.6.mjs.map +1 -1
- package/fesm2022/daffodil-customer-order-driver-magento-auto-testing.mjs +7 -0
- package/fesm2022/daffodil-customer-order-driver-magento-auto-testing.mjs.map +1 -0
- package/fesm2022/daffodil-customer-order-driver-magento-auto.mjs +7 -0
- package/fesm2022/daffodil-customer-order-driver-magento-auto.mjs.map +1 -0
- package/fesm2022/daffodil-customer-order-driver.mjs +21 -37
- package/fesm2022/daffodil-customer-order-driver.mjs.map +1 -1
- package/fesm2022/daffodil-customer-order-state.mjs +5 -19
- package/fesm2022/daffodil-customer-order-state.mjs.map +1 -1
- package/fesm2022/daffodil-customer-order.mjs +0 -4
- package/package.json +1 -1
- package/types/daffodil-customer-order-driver-magento-2.4.5-testing.d.ts +49 -54
- package/types/daffodil-customer-order-driver-magento-2.4.5.d.ts +123 -136
- package/types/daffodil-customer-order-driver-magento-2.4.6-testing.d.ts +49 -54
- package/types/daffodil-customer-order-driver-magento-2.4.6.d.ts +135 -152
- package/types/daffodil-customer-order-driver-magento-auto-testing.d.ts +1 -0
- package/types/daffodil-customer-order-driver-magento-auto.d.ts +1 -0
- package/types/daffodil-customer-order-driver.d.ts +15 -20
- package/types/daffodil-customer-order-state.d.ts +2 -7
- package/types/daffodil-customer-order.d.ts +1 -2
- package/fesm2022/daffodil-customer-order.mjs.map +0 -1
|
@@ -1,339 +1,312 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import * as i3 from
|
|
4
|
-
import { MagentoOrderItemType,
|
|
5
|
-
import * as i0 from
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import * as i1 from
|
|
9
|
-
import { gql } from
|
|
10
|
-
import {
|
|
11
|
-
import { DaffCustomerInvalidAPIResponseError } from
|
|
12
|
-
import { throwError } from
|
|
13
|
-
import {
|
|
14
|
-
import * as i2 from
|
|
15
|
-
import { CommonModule } from
|
|
16
|
-
import { provideDaffOrderDriver } from
|
|
17
|
-
|
|
1
|
+
import { createMultiInjectionToken, daffAdd, daffIdentifiableArrayToDict, daffSubtract } from "@daffodil/core";
|
|
2
|
+
import { DaffOrderItemType, DaffOrderTotalTypeEnum } from "@daffodil/order";
|
|
3
|
+
import * as i3 from "@daffodil/order/driver/magento/2.4.1";
|
|
4
|
+
import { MagentoOrderItemType, orderAddressFragment, orderCreditFragment, orderInvoiceFragment, orderItemFragment, orderPaymentFragment, orderShipmentFragment, orderTotalFragment } from "@daffodil/order/driver/magento/2.4.1";
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
import { Inject, Injectable, InjectionToken, NgModule, inject, makeEnvironmentProviders } from "@angular/core";
|
|
7
|
+
import { MagentoSortEnum, daffTransformMagentoError, magentoPageInfoTransform, magentoSearchResultPageInfoFragment, magentoSortDirectionRequestTransform } from "@daffodil/driver/magento/2.4.7";
|
|
8
|
+
import * as i1 from "apollo-angular";
|
|
9
|
+
import { gql } from "apollo-angular";
|
|
10
|
+
import { daffBuildFragmentDefinition, daffBuildFragmentNameSpread } from "@daffodil/core/graphql";
|
|
11
|
+
import { DaffCustomerInvalidAPIResponseError } from "@daffodil/customer-order/driver";
|
|
12
|
+
import { throwError } from "rxjs";
|
|
13
|
+
import { catchError, map } from "rxjs/operators";
|
|
14
|
+
import * as i2 from "@daffodil/auth";
|
|
15
|
+
import { CommonModule } from "@angular/common";
|
|
16
|
+
import { provideDaffOrderDriver } from "@daffodil/order/driver";
|
|
18
17
|
function daffMagentoCustomerOrderTransformTotals(totals) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
18
|
+
return [
|
|
19
|
+
{
|
|
20
|
+
label: "Subtotal",
|
|
21
|
+
type: DaffOrderTotalTypeEnum.Subtotal,
|
|
22
|
+
value: totals.subtotal.value,
|
|
23
|
+
sort_order: 0
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
label: "Discount",
|
|
27
|
+
type: DaffOrderTotalTypeEnum.Discount,
|
|
28
|
+
value: totals.discounts.reduce((acc, discount) => daffAdd(acc, discount.amount.value), 0),
|
|
29
|
+
sort_order: 10
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
label: "Shipping",
|
|
33
|
+
type: DaffOrderTotalTypeEnum.Shipping,
|
|
34
|
+
value: totals.total_shipping.value,
|
|
35
|
+
sort_order: 20
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
label: "Tax",
|
|
39
|
+
type: DaffOrderTotalTypeEnum.Tax,
|
|
40
|
+
value: totals.total_tax.value,
|
|
41
|
+
sort_order: 30
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
label: "Grand Total",
|
|
45
|
+
type: DaffOrderTotalTypeEnum.GrandTotal,
|
|
46
|
+
value: totals.grand_total.value,
|
|
47
|
+
sort_order: 40
|
|
48
|
+
}
|
|
49
|
+
];
|
|
51
50
|
}
|
|
52
51
|
function daffMagentoCustomerOrderTransformCouponDiscount(discount) {
|
|
53
|
-
|
|
54
|
-
code: discount.label,
|
|
55
|
-
};
|
|
52
|
+
return { code: discount.label };
|
|
56
53
|
}
|
|
57
54
|
function daffMagentoCustomerOrderTransformConfigurableOption(option) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
55
|
+
return {
|
|
56
|
+
attribute_label: option.label,
|
|
57
|
+
value_label: option.value
|
|
58
|
+
};
|
|
62
59
|
}
|
|
63
60
|
function daffMagentoCustomerOrderTransformBundleOption(option) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
61
|
+
return {
|
|
62
|
+
option_label: option.label,
|
|
63
|
+
value_label: option.values && option.values[0] && option.values[0].product_name
|
|
64
|
+
};
|
|
68
65
|
}
|
|
69
66
|
function daffMagentoCustomerOrderTransformAdditionalItemFields(item) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return {
|
|
83
|
-
type: DaffOrderItemType.Simple,
|
|
84
|
-
};
|
|
85
|
-
default:
|
|
86
|
-
return {};
|
|
87
|
-
}
|
|
67
|
+
switch (item.product_type) {
|
|
68
|
+
case MagentoOrderItemType.Bundle: return {
|
|
69
|
+
type: DaffOrderItemType.Composite,
|
|
70
|
+
options: item.bundle_options.map(daffMagentoCustomerOrderTransformBundleOption)
|
|
71
|
+
};
|
|
72
|
+
case MagentoOrderItemType.Configurable: return {
|
|
73
|
+
type: DaffOrderItemType.Configurable,
|
|
74
|
+
attributes: item.selected_options.map(daffMagentoCustomerOrderTransformConfigurableOption)
|
|
75
|
+
};
|
|
76
|
+
case MagentoOrderItemType.Simple: return { type: DaffOrderItemType.Simple };
|
|
77
|
+
default: return {};
|
|
78
|
+
}
|
|
88
79
|
}
|
|
89
80
|
function daffMagentoCustomerOrderTransformItem(item, order, qty) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
81
|
+
const discount = item.discounts.reduce((acc, d) => daffAdd(acc, d.amount.value), 0);
|
|
82
|
+
const rowTotal = qty * item.product_sale_price.value;
|
|
83
|
+
const rowTotalWithDiscount = qty * daffSubtract(item.product_sale_price.value, discount);
|
|
84
|
+
return {
|
|
85
|
+
type: DaffOrderItemType.Simple,
|
|
86
|
+
id: null,
|
|
87
|
+
qty_ordered: item.quantity_ordered,
|
|
88
|
+
qty_canceled: item.quantity_canceled,
|
|
89
|
+
qty_fulfilled: item.quantity_shipped,
|
|
90
|
+
qty,
|
|
91
|
+
image: {
|
|
92
|
+
url: item.product_url_key,
|
|
93
|
+
id: null,
|
|
94
|
+
label: null
|
|
95
|
+
},
|
|
96
|
+
order_id: order.id,
|
|
97
|
+
created_at: null,
|
|
98
|
+
updated_at: null,
|
|
99
|
+
product_id: null,
|
|
100
|
+
parent_item_id: null,
|
|
101
|
+
sku: item.product_sku,
|
|
102
|
+
name: item.product_name,
|
|
103
|
+
weight: null,
|
|
104
|
+
price: item.product_sale_price.value,
|
|
105
|
+
discount_percent: Math.floor(discount / item.product_sale_price.value * 100),
|
|
106
|
+
discount_amount: discount,
|
|
107
|
+
tax_percent: null,
|
|
108
|
+
tax_amount: null,
|
|
109
|
+
row_total: rowTotal,
|
|
110
|
+
row_total_with_discount: rowTotalWithDiscount,
|
|
111
|
+
row_weight: null,
|
|
112
|
+
tax_before_discount: null,
|
|
113
|
+
...daffMagentoCustomerOrderTransformAdditionalItemFields(item)
|
|
114
|
+
};
|
|
124
115
|
}
|
|
125
116
|
function daffMagentoCustomerOrderTransformAddress(address, order) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
117
|
+
return {
|
|
118
|
+
order_id: order.id,
|
|
119
|
+
prefix: address.prefix,
|
|
120
|
+
suffix: address.suffix,
|
|
121
|
+
firstname: address.firstname,
|
|
122
|
+
middlename: address.middlename,
|
|
123
|
+
lastname: address.lastname,
|
|
124
|
+
telephone: address.telephone,
|
|
125
|
+
street: address.street[0],
|
|
126
|
+
street2: address.street[1],
|
|
127
|
+
city: address.city,
|
|
128
|
+
region: String(address.region_id),
|
|
129
|
+
region_code: address.region_code,
|
|
130
|
+
country: address.country_code,
|
|
131
|
+
postcode: address.postcode
|
|
132
|
+
};
|
|
142
133
|
}
|
|
143
134
|
function daffMagentoCustomerOrderTransformShipmentItem(shipmentItem, order) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
135
|
+
return {
|
|
136
|
+
item: daffMagentoCustomerOrderTransformItem(shipmentItem.order_item, order, shipmentItem.quantity_shipped),
|
|
137
|
+
qty: shipmentItem.quantity_shipped
|
|
138
|
+
};
|
|
148
139
|
}
|
|
149
140
|
function daffMagentoCustomerOrderTransformShipmentTracking(tracking) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
141
|
+
return {
|
|
142
|
+
tracking_number: tracking.number,
|
|
143
|
+
tracking_url: null,
|
|
144
|
+
carrier: tracking.carrier,
|
|
145
|
+
title: tracking.title,
|
|
146
|
+
carrier_logo: null
|
|
147
|
+
};
|
|
157
148
|
}
|
|
158
149
|
function daffMagentoCustomerOrderTransformShipment(shipment, order) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
150
|
+
return {
|
|
151
|
+
carrier: order.carrier,
|
|
152
|
+
carrier_title: null,
|
|
153
|
+
code: null,
|
|
154
|
+
method: order.shipping_method,
|
|
155
|
+
method_description: null,
|
|
156
|
+
tracking: shipment.tracking.map(daffMagentoCustomerOrderTransformShipmentTracking),
|
|
157
|
+
items: shipment.items.map((item) => daffMagentoCustomerOrderTransformShipmentItem(item, order))
|
|
158
|
+
};
|
|
168
159
|
}
|
|
169
160
|
function daffMagentoCustomerOrderTransformPayment(payment, order) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
161
|
+
const findAdditionalData = (key) => {
|
|
162
|
+
const index = payment.additional_data.findIndex(({ name }) => name === key);
|
|
163
|
+
return index > -1 ? payment.additional_data[index].value : null;
|
|
164
|
+
};
|
|
165
|
+
return {
|
|
166
|
+
id: null,
|
|
167
|
+
order_id: order.id,
|
|
168
|
+
created_at: null,
|
|
169
|
+
updated_at: null,
|
|
170
|
+
method: payment.type,
|
|
171
|
+
cc_type: findAdditionalData("cc_type"),
|
|
172
|
+
cc_last4: findAdditionalData("cc_last4"),
|
|
173
|
+
cc_owner: findAdditionalData("cc_owner"),
|
|
174
|
+
cc_exp_month: findAdditionalData("cc_exp_month"),
|
|
175
|
+
cc_exp_year: findAdditionalData("cc_exp_year")
|
|
176
|
+
};
|
|
186
177
|
}
|
|
187
178
|
function daffMagentoCustomerOrderTransformInvoiceItem(invoiceItem, order) {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
179
|
+
return {
|
|
180
|
+
item: daffMagentoCustomerOrderTransformItem(invoiceItem.order_item, order, invoiceItem.quantity_invoiced),
|
|
181
|
+
qty: invoiceItem.quantity_invoiced
|
|
182
|
+
};
|
|
192
183
|
}
|
|
193
184
|
function daffMagentoCustomerOrderTransformInvoice(invoice, order, payment) {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
185
|
+
return {
|
|
186
|
+
totals: daffMagentoCustomerOrderTransformTotals(invoice.total),
|
|
187
|
+
billing_address: daffMagentoCustomerOrderTransformAddress(order.billing_address, order),
|
|
188
|
+
shipping_address: daffMagentoCustomerOrderTransformAddress(order.shipping_address, order),
|
|
189
|
+
payment: daffMagentoCustomerOrderTransformPayment(payment, order),
|
|
190
|
+
items: invoice.items.map((item) => daffMagentoCustomerOrderTransformInvoiceItem(item, order)),
|
|
191
|
+
shipping_method: null
|
|
192
|
+
};
|
|
202
193
|
}
|
|
203
194
|
function daffMagentoCustomerOrderTransformCreditItem(creditItem, order) {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
195
|
+
return {
|
|
196
|
+
item: daffMagentoCustomerOrderTransformItem(creditItem.order_item, order, creditItem.quantity_refunded),
|
|
197
|
+
qty: creditItem.quantity_refunded
|
|
198
|
+
};
|
|
208
199
|
}
|
|
209
200
|
function daffMagentoCustomerOrderTransformCredit(credit, order) {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
201
|
+
return {
|
|
202
|
+
totals: daffMagentoCustomerOrderTransformTotals(credit.total),
|
|
203
|
+
billing_address: daffMagentoCustomerOrderTransformAddress(order.billing_address, order),
|
|
204
|
+
shipping_address: daffMagentoCustomerOrderTransformAddress(order.shipping_address, order),
|
|
205
|
+
payment: daffMagentoCustomerOrderTransformPayment(order.payment_methods[0], order),
|
|
206
|
+
items: credit.items.map((item) => daffMagentoCustomerOrderTransformCreditItem(item, order)),
|
|
207
|
+
shipping_method: null
|
|
208
|
+
};
|
|
218
209
|
}
|
|
219
|
-
/**
|
|
220
|
-
* Transforms the MagentoCustomerOrder from the magento order query into a DaffOrder.
|
|
221
|
-
*/
|
|
222
210
|
function daffMagentoCustomerOrderTransformOrder(order, email) {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
payment: daffMagentoCustomerOrderTransformPayment(order.payment_methods[0], order),
|
|
242
|
-
// TODO: find out if the index is the correct payment for invoice
|
|
243
|
-
invoices: order.invoices.map((invoice, index) => daffMagentoCustomerOrderTransformInvoice(invoice, order, order.payment_methods[index])),
|
|
244
|
-
credits: order.credit_memos.map(credit => daffMagentoCustomerOrderTransformCredit(credit, order)),
|
|
245
|
-
};
|
|
211
|
+
return {
|
|
212
|
+
extra_attributes: order,
|
|
213
|
+
id: order.number,
|
|
214
|
+
email,
|
|
215
|
+
customer_id: null,
|
|
216
|
+
updated_at: null,
|
|
217
|
+
created_at: order.order_date,
|
|
218
|
+
status: order.status,
|
|
219
|
+
totals: daffMagentoCustomerOrderTransformTotals(order.total),
|
|
220
|
+
applied_codes: order.total.discounts.map(daffMagentoCustomerOrderTransformCouponDiscount),
|
|
221
|
+
items: order.items.map((item) => daffMagentoCustomerOrderTransformItem(item, order, item.quantity_ordered)),
|
|
222
|
+
billing_addresses: [daffMagentoCustomerOrderTransformAddress(order.billing_address, order)],
|
|
223
|
+
shipping_addresses: [daffMagentoCustomerOrderTransformAddress(order.shipping_address, order)],
|
|
224
|
+
shipments: order.shipments.map((shipment) => daffMagentoCustomerOrderTransformShipment(shipment, order)),
|
|
225
|
+
payment: daffMagentoCustomerOrderTransformPayment(order.payment_methods[0], order),
|
|
226
|
+
invoices: order.invoices.map((invoice, index) => daffMagentoCustomerOrderTransformInvoice(invoice, order, order.payment_methods[index])),
|
|
227
|
+
credits: order.credit_memos.map((credit) => daffMagentoCustomerOrderTransformCredit(credit, order))
|
|
228
|
+
};
|
|
246
229
|
}
|
|
247
|
-
|
|
248
230
|
var MagentoCustomerOrderSortableField;
|
|
249
|
-
(function
|
|
250
|
-
|
|
251
|
-
|
|
231
|
+
(function(MagentoCustomerOrderSortableField) {
|
|
232
|
+
MagentoCustomerOrderSortableField["NUMBER"] = "NUMBER";
|
|
233
|
+
MagentoCustomerOrderSortableField["CREATED_AT"] = "CREATED_AT";
|
|
252
234
|
})(MagentoCustomerOrderSortableField || (MagentoCustomerOrderSortableField = {}));
|
|
253
|
-
|
|
254
235
|
const magentoCustomerOrderSortFields = {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
},
|
|
264
|
-
],
|
|
265
|
-
default: MagentoCustomerOrderSortableField.CREATED_AT,
|
|
236
|
+
options: [{
|
|
237
|
+
label: "Date",
|
|
238
|
+
value: MagentoCustomerOrderSortableField.CREATED_AT
|
|
239
|
+
}, {
|
|
240
|
+
label: "Number",
|
|
241
|
+
value: MagentoCustomerOrderSortableField.NUMBER
|
|
242
|
+
}],
|
|
243
|
+
default: MagentoCustomerOrderSortableField.CREATED_AT
|
|
266
244
|
};
|
|
267
|
-
|
|
268
|
-
const {
|
|
269
|
-
/**
|
|
270
|
-
* A multi-provider injection token for providing extra transform logic in the Order Magento driver.
|
|
271
|
-
* It is run after the standard transforms for each customer order preview and passed both the current transformed Daffodil customer order and the Magento customer order.
|
|
272
|
-
*
|
|
273
|
-
* See {@link MagentoCustomerOrder} for more info.
|
|
274
|
-
*/
|
|
275
|
-
token: DAFF_CUSTOMER_ORDER_MAGENTO_EXTRA_ORDER_TRANSFORMS, provider: provider$1, } = createMultiInjectionToken('DAFF_CUSTOMER_ORDER_MAGENTO_EXTRA_ORDER_TRANSFORMS');
|
|
276
|
-
/**
|
|
277
|
-
* Provides extra customer order preview transforms for the Magento customer order driver.
|
|
278
|
-
*
|
|
279
|
-
* See {@link DAFF_CUSTOMER_ORDER_MAGENTO_EXTRA_ORDER_TRANSFORMS}.
|
|
280
|
-
*
|
|
281
|
-
* @example
|
|
282
|
-
* ```ts
|
|
283
|
-
* providers: [
|
|
284
|
-
* ...provideDaffCustomerOrderMagentoExtraOrderTransforms(
|
|
285
|
-
* myExtraOrderTransform
|
|
286
|
-
* )
|
|
287
|
-
* ]
|
|
288
|
-
* ```
|
|
289
|
-
*/
|
|
245
|
+
const { token: DAFF_CUSTOMER_ORDER_MAGENTO_EXTRA_ORDER_TRANSFORMS, provider: provider$1 } = createMultiInjectionToken("DAFF_CUSTOMER_ORDER_MAGENTO_EXTRA_ORDER_TRANSFORMS");
|
|
290
246
|
function provideDaffCustomerOrderMagentoExtraOrderTransforms(...transforms) {
|
|
291
|
-
|
|
247
|
+
return provider$1(...transforms);
|
|
292
248
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
249
|
+
const DAFF_CUSTOMER_ORDER_MAGENTO_ORDER_TRANSFORM = new InjectionToken("DAFF_CUSTOMER_ORDER_MAGENTO_ORDER_TRANSFORM", { factory: () => {
|
|
250
|
+
const transforms = inject(DAFF_CUSTOMER_ORDER_MAGENTO_EXTRA_ORDER_TRANSFORMS);
|
|
251
|
+
return (magentoOrder, email) => transforms.reduce((daffOrder, transform) => transform(daffOrder, magentoOrder, email), daffMagentoCustomerOrderTransformOrder(magentoOrder, email));
|
|
252
|
+
} });
|
|
253
|
+
var MagentoCustomerOrderCollectionTransformer = class MagentoCustomerOrderCollectionTransformer {
|
|
254
|
+
constructor(orderTransform) {
|
|
255
|
+
this.orderTransform = orderTransform;
|
|
256
|
+
}
|
|
257
|
+
transform(response, request) {
|
|
258
|
+
const orders = response.customer.orders.items.map((order) => this.orderTransform(order, response.customer.email));
|
|
259
|
+
return {
|
|
260
|
+
data: daffIdentifiableArrayToDict(orders),
|
|
261
|
+
metadata: {
|
|
262
|
+
...magentoPageInfoTransform(response.customer.orders.page_info),
|
|
263
|
+
count: response.customer.orders.total_count,
|
|
264
|
+
filters: {},
|
|
265
|
+
ids: orders.map((order) => order.id),
|
|
266
|
+
sortOptions: magentoCustomerOrderSortFields,
|
|
267
|
+
appliedSortDirection: request.appliedSortDirection,
|
|
268
|
+
appliedSortOption: request.appliedSortOption
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
static {
|
|
273
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
274
|
+
minVersion: "12.0.0",
|
|
275
|
+
version: "22.2.4",
|
|
276
|
+
ngImport: i0,
|
|
277
|
+
type: MagentoCustomerOrderCollectionTransformer,
|
|
278
|
+
deps: [{ token: DAFF_CUSTOMER_ORDER_MAGENTO_ORDER_TRANSFORM }],
|
|
279
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
static {
|
|
283
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
284
|
+
minVersion: "12.0.0",
|
|
285
|
+
version: "22.2.4",
|
|
286
|
+
ngImport: i0,
|
|
287
|
+
type: MagentoCustomerOrderCollectionTransformer,
|
|
288
|
+
providedIn: "any"
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
293
|
+
minVersion: "12.0.0",
|
|
294
|
+
version: "22.2.4",
|
|
295
|
+
ngImport: i0,
|
|
296
|
+
type: MagentoCustomerOrderCollectionTransformer,
|
|
297
|
+
decorators: [{
|
|
298
|
+
type: Injectable,
|
|
299
|
+
args: [{ providedIn: "any" }]
|
|
300
|
+
}],
|
|
301
|
+
ctorParameters: () => [{
|
|
302
|
+
type: void 0,
|
|
303
|
+
decorators: [{
|
|
304
|
+
type: Inject,
|
|
305
|
+
args: [DAFF_CUSTOMER_ORDER_MAGENTO_ORDER_TRANSFORM]
|
|
306
|
+
}]
|
|
307
|
+
}]
|
|
302
308
|
});
|
|
303
|
-
|
|
304
|
-
class MagentoCustomerOrderCollectionTransformer {
|
|
305
|
-
constructor(orderTransform) {
|
|
306
|
-
this.orderTransform = orderTransform;
|
|
307
|
-
}
|
|
308
|
-
transform(response, request) {
|
|
309
|
-
const orders = response.customer.orders.items.map((order) => this.orderTransform(order, response.customer.email));
|
|
310
|
-
return {
|
|
311
|
-
data: daffIdentifiableArrayToDict(orders),
|
|
312
|
-
metadata: {
|
|
313
|
-
...magentoPageInfoTransform(response.customer.orders.page_info),
|
|
314
|
-
count: response.customer.orders.total_count,
|
|
315
|
-
filters: {},
|
|
316
|
-
ids: orders.map(order => order.id),
|
|
317
|
-
sortOptions: magentoCustomerOrderSortFields,
|
|
318
|
-
appliedSortDirection: request.appliedSortDirection,
|
|
319
|
-
appliedSortOption: request.appliedSortOption,
|
|
320
|
-
},
|
|
321
|
-
};
|
|
322
|
-
}
|
|
323
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: MagentoCustomerOrderCollectionTransformer, deps: [{ token: DAFF_CUSTOMER_ORDER_MAGENTO_ORDER_TRANSFORM }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
324
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: MagentoCustomerOrderCollectionTransformer, providedIn: 'any' }); }
|
|
325
|
-
}
|
|
326
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: MagentoCustomerOrderCollectionTransformer, decorators: [{
|
|
327
|
-
type: Injectable,
|
|
328
|
-
args: [{
|
|
329
|
-
providedIn: 'any',
|
|
330
|
-
}]
|
|
331
|
-
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
332
|
-
type: Inject,
|
|
333
|
-
args: [DAFF_CUSTOMER_ORDER_MAGENTO_ORDER_TRANSFORM]
|
|
334
|
-
}] }] });
|
|
335
|
-
|
|
336
|
-
const magentoCustomerOrderFragment = gql `
|
|
309
|
+
const magentoCustomerOrderFragment = gql`
|
|
337
310
|
fragment magentoCustomerOrder on CustomerOrder {
|
|
338
311
|
id
|
|
339
312
|
order_date
|
|
@@ -374,9 +347,8 @@ const magentoCustomerOrderFragment = gql `
|
|
|
374
347
|
${orderAddressFragment}
|
|
375
348
|
${orderTotalFragment}
|
|
376
349
|
`;
|
|
377
|
-
|
|
378
|
-
const
|
|
379
|
-
const getCustomerOrders = (extraProductFragments = []) => gql `
|
|
350
|
+
const MAGENTO_GET_CUSTOMER_ORDERS_QUERY_NAME = "MagentoGetCustomerOrders";
|
|
351
|
+
const getCustomerOrders = (extraProductFragments = []) => gql`
|
|
380
352
|
query ${MAGENTO_GET_CUSTOMER_ORDERS_QUERY_NAME}(
|
|
381
353
|
$currentPage: Int,
|
|
382
354
|
$pageSize: Int,
|
|
@@ -400,9 +372,8 @@ const getCustomerOrders = (extraProductFragments = []) => gql `
|
|
|
400
372
|
${magentoSearchResultPageInfoFragment}
|
|
401
373
|
${daffBuildFragmentDefinition(...extraProductFragments)}
|
|
402
374
|
`;
|
|
403
|
-
|
|
404
|
-
const
|
|
405
|
-
const getCustomerOrder = (extraProductFragments = []) => gql `
|
|
375
|
+
const MAGENTO_GET_CUSTOMER_ORDER_QUERY_NAME = "MagentoGetCustomerOrder";
|
|
376
|
+
const getCustomerOrder = (extraProductFragments = []) => gql`
|
|
406
377
|
query ${MAGENTO_GET_CUSTOMER_ORDER_QUERY_NAME}($id: String!) {
|
|
407
378
|
customer {
|
|
408
379
|
email
|
|
@@ -417,141 +388,153 @@ const getCustomerOrder = (extraProductFragments = []) => gql `
|
|
|
417
388
|
${magentoCustomerOrderFragment}
|
|
418
389
|
${daffBuildFragmentDefinition(...extraProductFragments)}
|
|
419
390
|
`;
|
|
420
|
-
|
|
421
391
|
function transformMagentoReviewsError(error) {
|
|
422
|
-
|
|
392
|
+
return daffTransformMagentoError(error, {}) || new DaffCustomerInvalidAPIResponseError(error.message);
|
|
423
393
|
}
|
|
424
|
-
|
|
425
394
|
const validateGetCustomerOrdersResponse = (response) => {
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
}
|
|
429
|
-
else {
|
|
430
|
-
throw new DaffCustomerInvalidAPIResponseError('Get customer orders response does not contain customer orders.');
|
|
431
|
-
}
|
|
395
|
+
if (response.data.customer?.orders.items) return response;
|
|
396
|
+
else throw new DaffCustomerInvalidAPIResponseError("Get customer orders response does not contain customer orders.");
|
|
432
397
|
};
|
|
433
|
-
|
|
434
|
-
const {
|
|
435
|
-
/**
|
|
436
|
-
* A multi-provider injection token for providing extra GraphQL fragments that will be spread into order queries.
|
|
437
|
-
* This can be used to retrieve additional data that is not covered by the standard Daffodil interfaces.
|
|
438
|
-
*
|
|
439
|
-
* Fragment structure is platform-specific and this feature should be used with care.
|
|
440
|
-
*
|
|
441
|
-
* This can increase query complexity above the Magento default of 300.
|
|
442
|
-
* Daffodil only guarantees that stock queries don't exceed the limit of 300.
|
|
443
|
-
* Apps using this token should therefore increase the query complexity limit
|
|
444
|
-
* to accommodate the extra complexity contributed by the provided fragments.
|
|
445
|
-
*/
|
|
446
|
-
token: DAFF_CUSTOMER_ORDER_MAGENTO_EXTRA_ORDER_FRAGMENTS, provider, } = createMultiInjectionToken('DAFF_CUSTOMER_ORDER_MAGENTO_EXTRA_ORDER_FRAGMENTS');
|
|
447
|
-
/**
|
|
448
|
-
* Provides extra GraphQL fragments for the Magento order driver.
|
|
449
|
-
*
|
|
450
|
-
* See {@link DAFF_CUSTOMER_ORDER_MAGENTO_EXTRA_ORDER_FRAGMENTS}.
|
|
451
|
-
*
|
|
452
|
-
* @example
|
|
453
|
-
* ```ts
|
|
454
|
-
* providers: [
|
|
455
|
-
* ...provideDaffCustomerOrderMagentoExtraOrderFragments(
|
|
456
|
-
* myExtraOrderFragment
|
|
457
|
-
* )
|
|
458
|
-
* ]
|
|
459
|
-
* ```
|
|
460
|
-
*/
|
|
398
|
+
const { token: DAFF_CUSTOMER_ORDER_MAGENTO_EXTRA_ORDER_FRAGMENTS, provider } = createMultiInjectionToken("DAFF_CUSTOMER_ORDER_MAGENTO_EXTRA_ORDER_FRAGMENTS");
|
|
461
399
|
function provideDaffCustomerOrderMagentoExtraOrderFragments(...fragments) {
|
|
462
|
-
|
|
400
|
+
return provider(...fragments);
|
|
463
401
|
}
|
|
464
|
-
|
|
465
402
|
const validateGetCustomerOrderResponse = (response) => {
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
}
|
|
469
|
-
else {
|
|
470
|
-
throw new DaffCustomerInvalidAPIResponseError('Get customer order response does not contain a customer order.');
|
|
471
|
-
}
|
|
403
|
+
if (response.data.customer?.orders.items[0]) return response;
|
|
404
|
+
else throw new DaffCustomerInvalidAPIResponseError("Get customer order response does not contain a customer order.");
|
|
472
405
|
};
|
|
406
|
+
var DaffCustomerOrderMagentoService = class DaffCustomerOrderMagentoService {
|
|
407
|
+
constructor(apollo, authStorage, guestDriver, extraFragments, transformer, orderTransform) {
|
|
408
|
+
this.apollo = apollo;
|
|
409
|
+
this.authStorage = authStorage;
|
|
410
|
+
this.guestDriver = guestDriver;
|
|
411
|
+
this.extraFragments = extraFragments;
|
|
412
|
+
this.transformer = transformer;
|
|
413
|
+
this.orderTransform = orderTransform;
|
|
414
|
+
}
|
|
415
|
+
list(cartId, request = {}) {
|
|
416
|
+
return this.authStorage.getAuthToken() ? this.apollo.query({
|
|
417
|
+
query: getCustomerOrders(this.extraFragments),
|
|
418
|
+
variables: {
|
|
419
|
+
currentPage: request.currentPage,
|
|
420
|
+
pageSize: request.pageSize,
|
|
421
|
+
sort: {
|
|
422
|
+
sort_direction: request.appliedSortDirection ? magentoSortDirectionRequestTransform(request.appliedSortDirection) : MagentoSortEnum.DESC,
|
|
423
|
+
sort_field: request.appliedSortOption || MagentoCustomerOrderSortableField.CREATED_AT
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}).pipe(map(validateGetCustomerOrdersResponse), map((response) => this.transformer.transform(response.data, request)), catchError((err) => throwError(() => transformMagentoReviewsError(err)))) : this.guestDriver.list(cartId);
|
|
427
|
+
}
|
|
428
|
+
get(orderId, cartId) {
|
|
429
|
+
return this.authStorage.getAuthToken() ? this.apollo.query({
|
|
430
|
+
query: getCustomerOrder(this.extraFragments),
|
|
431
|
+
variables: { id: orderId }
|
|
432
|
+
}).pipe(map(validateGetCustomerOrderResponse), map((result) => this.orderTransform(result.data.customer.orders.items[0], result.data.customer.email)), catchError((err) => throwError(() => transformMagentoReviewsError(err)))) : this.guestDriver.get(orderId, cartId);
|
|
433
|
+
}
|
|
434
|
+
static {
|
|
435
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
436
|
+
minVersion: "12.0.0",
|
|
437
|
+
version: "22.2.4",
|
|
438
|
+
ngImport: i0,
|
|
439
|
+
type: DaffCustomerOrderMagentoService,
|
|
440
|
+
deps: [
|
|
441
|
+
{ token: i1.Apollo },
|
|
442
|
+
{ token: i2.DaffAuthStorageService },
|
|
443
|
+
{ token: i3.DaffOrderMagentoService },
|
|
444
|
+
{ token: DAFF_CUSTOMER_ORDER_MAGENTO_EXTRA_ORDER_FRAGMENTS },
|
|
445
|
+
{ token: MagentoCustomerOrderCollectionTransformer },
|
|
446
|
+
{ token: DAFF_CUSTOMER_ORDER_MAGENTO_ORDER_TRANSFORM }
|
|
447
|
+
],
|
|
448
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
static {
|
|
452
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
453
|
+
minVersion: "12.0.0",
|
|
454
|
+
version: "22.2.4",
|
|
455
|
+
ngImport: i0,
|
|
456
|
+
type: DaffCustomerOrderMagentoService,
|
|
457
|
+
providedIn: "root"
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
};
|
|
461
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
462
|
+
minVersion: "12.0.0",
|
|
463
|
+
version: "22.2.4",
|
|
464
|
+
ngImport: i0,
|
|
465
|
+
type: DaffCustomerOrderMagentoService,
|
|
466
|
+
decorators: [{
|
|
467
|
+
type: Injectable,
|
|
468
|
+
args: [{ providedIn: "root" }]
|
|
469
|
+
}],
|
|
470
|
+
ctorParameters: () => [
|
|
471
|
+
{ type: i1.Apollo },
|
|
472
|
+
{ type: i2.DaffAuthStorageService },
|
|
473
|
+
{ type: i3.DaffOrderMagentoService },
|
|
474
|
+
{
|
|
475
|
+
type: void 0,
|
|
476
|
+
decorators: [{
|
|
477
|
+
type: Inject,
|
|
478
|
+
args: [DAFF_CUSTOMER_ORDER_MAGENTO_EXTRA_ORDER_FRAGMENTS]
|
|
479
|
+
}]
|
|
480
|
+
},
|
|
481
|
+
{ type: MagentoCustomerOrderCollectionTransformer },
|
|
482
|
+
{
|
|
483
|
+
type: void 0,
|
|
484
|
+
decorators: [{
|
|
485
|
+
type: Inject,
|
|
486
|
+
args: [DAFF_CUSTOMER_ORDER_MAGENTO_ORDER_TRANSFORM]
|
|
487
|
+
}]
|
|
488
|
+
}
|
|
489
|
+
]
|
|
490
|
+
});
|
|
491
|
+
const provideDaffCustomerOrderMagentoDriver = () => makeEnvironmentProviders([MagentoCustomerOrderCollectionTransformer, provideDaffOrderDriver(DaffCustomerOrderMagentoService)]);
|
|
492
|
+
var DaffCustomerOrderMagentoDriverModule = class DaffCustomerOrderMagentoDriverModule {
|
|
493
|
+
static forRoot() {
|
|
494
|
+
return {
|
|
495
|
+
ngModule: DaffCustomerOrderMagentoDriverModule,
|
|
496
|
+
providers: [provideDaffCustomerOrderMagentoDriver()]
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
static {
|
|
500
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
501
|
+
minVersion: "12.0.0",
|
|
502
|
+
version: "22.2.4",
|
|
503
|
+
ngImport: i0,
|
|
504
|
+
type: DaffCustomerOrderMagentoDriverModule,
|
|
505
|
+
deps: [],
|
|
506
|
+
target: i0.ɵɵFactoryTarget.NgModule
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
static {
|
|
510
|
+
this.ɵmod = i0.ɵɵngDeclareNgModule({
|
|
511
|
+
minVersion: "14.0.0",
|
|
512
|
+
version: "22.2.4",
|
|
513
|
+
ngImport: i0,
|
|
514
|
+
type: DaffCustomerOrderMagentoDriverModule,
|
|
515
|
+
imports: [CommonModule]
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
static {
|
|
519
|
+
this.ɵinj = i0.ɵɵngDeclareInjector({
|
|
520
|
+
minVersion: "12.0.0",
|
|
521
|
+
version: "22.2.4",
|
|
522
|
+
ngImport: i0,
|
|
523
|
+
type: DaffCustomerOrderMagentoDriverModule,
|
|
524
|
+
imports: [CommonModule]
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
};
|
|
528
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
529
|
+
minVersion: "12.0.0",
|
|
530
|
+
version: "22.2.4",
|
|
531
|
+
ngImport: i0,
|
|
532
|
+
type: DaffCustomerOrderMagentoDriverModule,
|
|
533
|
+
decorators: [{
|
|
534
|
+
type: NgModule,
|
|
535
|
+
args: [{ imports: [CommonModule] }]
|
|
536
|
+
}]
|
|
537
|
+
});
|
|
538
|
+
export { DAFF_CUSTOMER_ORDER_MAGENTO_EXTRA_ORDER_FRAGMENTS, DAFF_CUSTOMER_ORDER_MAGENTO_EXTRA_ORDER_TRANSFORMS, DAFF_CUSTOMER_ORDER_MAGENTO_ORDER_TRANSFORM, DaffCustomerOrderMagentoDriverModule, DaffCustomerOrderMagentoService, MAGENTO_GET_CUSTOMER_ORDERS_QUERY_NAME, MAGENTO_GET_CUSTOMER_ORDER_QUERY_NAME, MagentoCustomerOrderCollectionTransformer, MagentoCustomerOrderSortableField, daffMagentoCustomerOrderTransformAdditionalItemFields, daffMagentoCustomerOrderTransformAddress, daffMagentoCustomerOrderTransformBundleOption, daffMagentoCustomerOrderTransformConfigurableOption, daffMagentoCustomerOrderTransformCouponDiscount, daffMagentoCustomerOrderTransformCredit, daffMagentoCustomerOrderTransformCreditItem, daffMagentoCustomerOrderTransformInvoice, daffMagentoCustomerOrderTransformInvoiceItem, daffMagentoCustomerOrderTransformItem, daffMagentoCustomerOrderTransformOrder, daffMagentoCustomerOrderTransformPayment, daffMagentoCustomerOrderTransformShipment, daffMagentoCustomerOrderTransformShipmentItem, daffMagentoCustomerOrderTransformShipmentTracking, daffMagentoCustomerOrderTransformTotals, getCustomerOrder, getCustomerOrders, magentoCustomerOrderFragment, provideDaffCustomerOrderMagentoDriver, provideDaffCustomerOrderMagentoExtraOrderFragments, provideDaffCustomerOrderMagentoExtraOrderTransforms, transformMagentoReviewsError, validateGetCustomerOrdersResponse };
|
|
473
539
|
|
|
474
|
-
|
|
475
|
-
* A service for making Magento GraphQL queries for customers.
|
|
476
|
-
*
|
|
477
|
-
* @inheritdoc
|
|
478
|
-
*/
|
|
479
|
-
class DaffCustomerOrderMagentoService {
|
|
480
|
-
constructor(apollo, authStorage, guestDriver, extraFragments, transformer, orderTransform) {
|
|
481
|
-
this.apollo = apollo;
|
|
482
|
-
this.authStorage = authStorage;
|
|
483
|
-
this.guestDriver = guestDriver;
|
|
484
|
-
this.extraFragments = extraFragments;
|
|
485
|
-
this.transformer = transformer;
|
|
486
|
-
this.orderTransform = orderTransform;
|
|
487
|
-
}
|
|
488
|
-
list(cartId, request = {}) {
|
|
489
|
-
return this.authStorage.getAuthToken()
|
|
490
|
-
? this.apollo.query({
|
|
491
|
-
query: getCustomerOrders(this.extraFragments),
|
|
492
|
-
variables: {
|
|
493
|
-
currentPage: request.currentPage,
|
|
494
|
-
pageSize: request.pageSize,
|
|
495
|
-
sort: {
|
|
496
|
-
sort_direction: request.appliedSortDirection ? magentoSortDirectionRequestTransform(request.appliedSortDirection) : MagentoSortEnum.DESC,
|
|
497
|
-
sort_field: request.appliedSortOption || MagentoCustomerOrderSortableField.CREATED_AT,
|
|
498
|
-
},
|
|
499
|
-
},
|
|
500
|
-
}).pipe(map(validateGetCustomerOrdersResponse), map(response => this.transformer.transform(response.data, request)), catchError(err => throwError(() => transformMagentoReviewsError(err))))
|
|
501
|
-
: this.guestDriver.list(cartId);
|
|
502
|
-
}
|
|
503
|
-
get(orderId, cartId) {
|
|
504
|
-
return this.authStorage.getAuthToken()
|
|
505
|
-
? this.apollo.query({
|
|
506
|
-
query: getCustomerOrder(this.extraFragments),
|
|
507
|
-
variables: {
|
|
508
|
-
id: orderId,
|
|
509
|
-
},
|
|
510
|
-
}).pipe(map(validateGetCustomerOrderResponse), map(result => this.orderTransform(result.data.customer.orders.items[0], result.data.customer.email)), catchError(err => throwError(() => transformMagentoReviewsError(err))))
|
|
511
|
-
: this.guestDriver.get(orderId, cartId);
|
|
512
|
-
}
|
|
513
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCustomerOrderMagentoService, deps: [{ token: i1.Apollo }, { token: i2.DaffAuthStorageService }, { token: i3.DaffOrderMagentoService }, { token: DAFF_CUSTOMER_ORDER_MAGENTO_EXTRA_ORDER_FRAGMENTS }, { token: MagentoCustomerOrderCollectionTransformer }, { token: DAFF_CUSTOMER_ORDER_MAGENTO_ORDER_TRANSFORM }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
514
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCustomerOrderMagentoService, providedIn: 'root' }); }
|
|
515
|
-
}
|
|
516
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCustomerOrderMagentoService, decorators: [{
|
|
517
|
-
type: Injectable,
|
|
518
|
-
args: [{
|
|
519
|
-
providedIn: 'root',
|
|
520
|
-
}]
|
|
521
|
-
}], ctorParameters: () => [{ type: i1.Apollo }, { type: i2.DaffAuthStorageService }, { type: i3.DaffOrderMagentoService }, { type: undefined, decorators: [{
|
|
522
|
-
type: Inject,
|
|
523
|
-
args: [DAFF_CUSTOMER_ORDER_MAGENTO_EXTRA_ORDER_FRAGMENTS]
|
|
524
|
-
}] }, { type: MagentoCustomerOrderCollectionTransformer }, { type: undefined, decorators: [{
|
|
525
|
-
type: Inject,
|
|
526
|
-
args: [DAFF_CUSTOMER_ORDER_MAGENTO_ORDER_TRANSFORM]
|
|
527
|
-
}] }] });
|
|
528
|
-
|
|
529
|
-
class DaffCustomerOrderMagentoDriverModule {
|
|
530
|
-
static forRoot() {
|
|
531
|
-
return {
|
|
532
|
-
ngModule: DaffCustomerOrderMagentoDriverModule,
|
|
533
|
-
providers: [
|
|
534
|
-
MagentoCustomerOrderCollectionTransformer,
|
|
535
|
-
provideDaffOrderDriver(DaffCustomerOrderMagentoService),
|
|
536
|
-
],
|
|
537
|
-
};
|
|
538
|
-
}
|
|
539
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCustomerOrderMagentoDriverModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
540
|
-
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.9", ngImport: i0, type: DaffCustomerOrderMagentoDriverModule, imports: [CommonModule] }); }
|
|
541
|
-
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCustomerOrderMagentoDriverModule, imports: [CommonModule] }); }
|
|
542
|
-
}
|
|
543
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCustomerOrderMagentoDriverModule, decorators: [{
|
|
544
|
-
type: NgModule,
|
|
545
|
-
args: [{
|
|
546
|
-
imports: [
|
|
547
|
-
CommonModule,
|
|
548
|
-
],
|
|
549
|
-
}]
|
|
550
|
-
}] });
|
|
551
|
-
|
|
552
|
-
/**
|
|
553
|
-
* Generated bundle index. Do not edit.
|
|
554
|
-
*/
|
|
555
|
-
|
|
556
|
-
export { DAFF_CUSTOMER_ORDER_MAGENTO_EXTRA_ORDER_FRAGMENTS, DAFF_CUSTOMER_ORDER_MAGENTO_EXTRA_ORDER_TRANSFORMS, DAFF_CUSTOMER_ORDER_MAGENTO_ORDER_TRANSFORM, DaffCustomerOrderMagentoDriverModule, DaffCustomerOrderMagentoService, MAGENTO_GET_CUSTOMER_ORDERS_QUERY_NAME, MAGENTO_GET_CUSTOMER_ORDER_QUERY_NAME, MagentoCustomerOrderCollectionTransformer, MagentoCustomerOrderSortableField, daffMagentoCustomerOrderTransformAdditionalItemFields, daffMagentoCustomerOrderTransformAddress, daffMagentoCustomerOrderTransformBundleOption, daffMagentoCustomerOrderTransformConfigurableOption, daffMagentoCustomerOrderTransformCouponDiscount, daffMagentoCustomerOrderTransformCredit, daffMagentoCustomerOrderTransformCreditItem, daffMagentoCustomerOrderTransformInvoice, daffMagentoCustomerOrderTransformInvoiceItem, daffMagentoCustomerOrderTransformItem, daffMagentoCustomerOrderTransformOrder, daffMagentoCustomerOrderTransformPayment, daffMagentoCustomerOrderTransformShipment, daffMagentoCustomerOrderTransformShipmentItem, daffMagentoCustomerOrderTransformShipmentTracking, daffMagentoCustomerOrderTransformTotals, getCustomerOrder, getCustomerOrders, magentoCustomerOrderFragment, provideDaffCustomerOrderMagentoExtraOrderFragments, provideDaffCustomerOrderMagentoExtraOrderTransforms, transformMagentoReviewsError, validateGetCustomerOrdersResponse };
|
|
557
|
-
//# sourceMappingURL=daffodil-customer-order-driver-magento-2.4.6.mjs.map
|
|
540
|
+
//# sourceMappingURL=daffodil-customer-order-driver-magento-2.4.6.mjs.map
|