@daffodil/customer 0.48.2
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/README.md +9 -0
- package/daffodil-customer.d.ts +5 -0
- package/driver/daffodil-customer-driver.d.ts +5 -0
- package/driver/errors/invalid-api-response.d.ts +10 -0
- package/driver/errors/map.d.ts +7 -0
- package/driver/errors/public_api.d.ts +2 -0
- package/driver/in-memory/backend/customer.service.d.ts +39 -0
- package/driver/in-memory/daffodil-customer-driver-in-memory.d.ts +5 -0
- package/driver/in-memory/driver/customer-driver.module.d.ts +12 -0
- package/driver/in-memory/driver/customer.service.d.ts +24 -0
- package/driver/in-memory/index.d.ts +1 -0
- package/driver/in-memory/package.json +10 -0
- package/driver/in-memory/public_api.d.ts +3 -0
- package/driver/index.d.ts +1 -0
- package/driver/interfaces/customer-service.interface.d.ts +30 -0
- package/driver/magento/customer-driver.module.d.ts +9 -0
- package/driver/magento/customer.service.d.ts +20 -0
- package/driver/magento/daffodil-customer-driver-magento.d.ts +5 -0
- package/driver/magento/errors/public_api.d.ts +1 -0
- package/driver/magento/errors/transform.d.ts +1 -0
- package/driver/magento/index.d.ts +1 -0
- package/driver/magento/models/gender.enum.d.ts +4 -0
- package/driver/magento/models/public_api.d.ts +3 -0
- package/driver/magento/models/requests/customer-input.type.d.ts +14 -0
- package/driver/magento/models/requests/public_api.d.ts +1 -0
- package/driver/magento/models/responses/change-email.type.d.ts +6 -0
- package/driver/magento/models/responses/change-password.type.d.ts +5 -0
- package/driver/magento/models/responses/customer-address.type.d.ts +16 -0
- package/driver/magento/models/responses/customer.type.d.ts +8 -0
- package/driver/magento/models/responses/get-customer.type.d.ts +4 -0
- package/driver/magento/models/responses/public_api.d.ts +6 -0
- package/driver/magento/models/responses/update-customer.type.d.ts +6 -0
- package/driver/magento/package.json +10 -0
- package/driver/magento/public_api.d.ts +7 -0
- package/driver/magento/queries/change-password.d.ts +2 -0
- package/driver/magento/queries/fragments/customer-address.d.ts +1 -0
- package/driver/magento/queries/fragments/customer.d.ts +1 -0
- package/driver/magento/queries/fragments/public_api.d.ts +2 -0
- package/driver/magento/queries/get-customer.d.ts +2 -0
- package/driver/magento/queries/public_api.d.ts +5 -0
- package/driver/magento/queries/update-customer.d.ts +2 -0
- package/driver/magento/queries/update-email.d.ts +2 -0
- package/driver/magento/testing/daffodil-customer-driver-magento-testing.d.ts +5 -0
- package/driver/magento/testing/factories/address.factory.d.ts +26 -0
- package/driver/magento/testing/factories/customer.factory.d.ts +9 -0
- package/driver/magento/testing/factories/public_api.d.ts +2 -0
- package/driver/magento/testing/index.d.ts +1 -0
- package/driver/magento/testing/package.json +10 -0
- package/driver/magento/testing/public_api.d.ts +1 -0
- package/driver/magento/transforms/public_api.d.ts +2 -0
- package/driver/magento/transforms/requests/customer-input.d.ts +3 -0
- package/driver/magento/transforms/requests/public_api.d.ts +1 -0
- package/driver/magento/transforms/responses/customer-address.d.ts +3 -0
- package/driver/magento/transforms/responses/customer.d.ts +3 -0
- package/driver/magento/transforms/responses/public_api.d.ts +2 -0
- package/driver/magento/validators/change-email.d.ts +3 -0
- package/driver/magento/validators/change-password.d.ts +3 -0
- package/driver/magento/validators/get-customer.d.ts +3 -0
- package/driver/magento/validators/public_api.d.ts +1 -0
- package/driver/magento/validators/update-customer.d.ts +3 -0
- package/driver/package.json +10 -0
- package/driver/public_api.d.ts +2 -0
- package/driver/testing/daffodil-customer-driver-testing.d.ts +5 -0
- package/driver/testing/drivers/customer-driver.module.d.ts +12 -0
- package/driver/testing/drivers/customer.service.d.ts +21 -0
- package/driver/testing/drivers/public_api.d.ts +2 -0
- package/driver/testing/index.d.ts +1 -0
- package/driver/testing/package.json +10 -0
- package/driver/testing/public_api.d.ts +1 -0
- package/esm2020/daffodil-customer.mjs +5 -0
- package/esm2020/driver/daffodil-customer-driver.mjs +5 -0
- package/esm2020/driver/errors/invalid-api-response.mjs +13 -0
- package/esm2020/driver/errors/map.mjs +8 -0
- package/esm2020/driver/errors/public_api.mjs +3 -0
- package/esm2020/driver/in-memory/backend/customer.service.mjs +108 -0
- package/esm2020/driver/in-memory/daffodil-customer-driver-in-memory.mjs +5 -0
- package/esm2020/driver/in-memory/driver/customer-driver.module.mjs +35 -0
- package/esm2020/driver/in-memory/driver/customer.service.mjs +40 -0
- package/esm2020/driver/in-memory/index.mjs +2 -0
- package/esm2020/driver/in-memory/public_api.mjs +4 -0
- package/esm2020/driver/index.mjs +2 -0
- package/esm2020/driver/interfaces/customer-service.interface.mjs +6 -0
- package/esm2020/driver/magento/customer-driver.module.mjs +39 -0
- package/esm2020/driver/magento/customer.service.mjs +63 -0
- package/esm2020/driver/magento/daffodil-customer-driver-magento.mjs +5 -0
- package/esm2020/driver/magento/errors/public_api.mjs +2 -0
- package/esm2020/driver/magento/errors/transform.mjs +6 -0
- package/esm2020/driver/magento/index.mjs +2 -0
- package/esm2020/driver/magento/models/gender.enum.mjs +6 -0
- package/esm2020/driver/magento/models/public_api.mjs +4 -0
- package/esm2020/driver/magento/models/requests/customer-input.type.mjs +2 -0
- package/esm2020/driver/magento/models/requests/public_api.mjs +2 -0
- package/esm2020/driver/magento/models/responses/change-email.type.mjs +2 -0
- package/esm2020/driver/magento/models/responses/change-password.type.mjs +2 -0
- package/esm2020/driver/magento/models/responses/customer-address.type.mjs +2 -0
- package/esm2020/driver/magento/models/responses/customer.type.mjs +2 -0
- package/esm2020/driver/magento/models/responses/get-customer.type.mjs +2 -0
- package/esm2020/driver/magento/models/responses/public_api.mjs +2 -0
- package/esm2020/driver/magento/models/responses/update-customer.type.mjs +2 -0
- package/esm2020/driver/magento/public_api.mjs +8 -0
- package/esm2020/driver/magento/queries/change-password.mjs +13 -0
- package/esm2020/driver/magento/queries/fragments/customer-address.mjs +19 -0
- package/esm2020/driver/magento/queries/fragments/customer.mjs +15 -0
- package/esm2020/driver/magento/queries/fragments/public_api.mjs +3 -0
- package/esm2020/driver/magento/queries/get-customer.mjs +12 -0
- package/esm2020/driver/magento/queries/public_api.mjs +6 -0
- package/esm2020/driver/magento/queries/update-customer.mjs +14 -0
- package/esm2020/driver/magento/queries/update-email.mjs +14 -0
- package/esm2020/driver/magento/testing/daffodil-customer-driver-magento-testing.mjs +5 -0
- package/esm2020/driver/magento/testing/factories/address.factory.mjs +38 -0
- package/esm2020/driver/magento/testing/factories/customer.factory.mjs +34 -0
- package/esm2020/driver/magento/testing/factories/public_api.mjs +3 -0
- package/esm2020/driver/magento/testing/index.mjs +2 -0
- package/esm2020/driver/magento/testing/public_api.mjs +2 -0
- package/esm2020/driver/magento/transforms/public_api.mjs +3 -0
- package/esm2020/driver/magento/transforms/requests/customer-input.mjs +6 -0
- package/esm2020/driver/magento/transforms/requests/public_api.mjs +2 -0
- package/esm2020/driver/magento/transforms/responses/customer-address.mjs +14 -0
- package/esm2020/driver/magento/transforms/responses/customer.mjs +10 -0
- package/esm2020/driver/magento/transforms/responses/public_api.mjs +3 -0
- package/esm2020/driver/magento/validators/change-email.mjs +10 -0
- package/esm2020/driver/magento/validators/change-password.mjs +10 -0
- package/esm2020/driver/magento/validators/get-customer.mjs +10 -0
- package/esm2020/driver/magento/validators/public_api.mjs +2 -0
- package/esm2020/driver/magento/validators/update-customer.mjs +10 -0
- package/esm2020/driver/public_api.mjs +3 -0
- package/esm2020/driver/testing/daffodil-customer-driver-testing.mjs +5 -0
- package/esm2020/driver/testing/drivers/customer-driver.module.mjs +35 -0
- package/esm2020/driver/testing/drivers/customer.service.mjs +37 -0
- package/esm2020/driver/testing/drivers/public_api.mjs +3 -0
- package/esm2020/driver/testing/index.mjs +2 -0
- package/esm2020/driver/testing/public_api.mjs +2 -0
- package/esm2020/index.mjs +2 -0
- package/esm2020/injection-tokens/error-matcher.token.mjs +8 -0
- package/esm2020/injection-tokens/public_api.mjs +2 -0
- package/esm2020/models/address.type.mjs +2 -0
- package/esm2020/models/customer.type.mjs +2 -0
- package/esm2020/models/public_api.mjs +2 -0
- package/esm2020/public_api.mjs +3 -0
- package/esm2020/routing/daffodil-customer-routing.mjs +5 -0
- package/esm2020/routing/guards/clear-errors.guard.mjs +24 -0
- package/esm2020/routing/guards/public_api.mjs +2 -0
- package/esm2020/routing/index.mjs +2 -0
- package/esm2020/routing/public_api.mjs +3 -0
- package/esm2020/routing/resolvers/customer.resolver.mjs +26 -0
- package/esm2020/routing/resolvers/public_api.mjs +2 -0
- package/esm2020/state/actions/customer.actions.mjs +144 -0
- package/esm2020/state/customer.module.mjs +34 -0
- package/esm2020/state/daffodil-customer-state.mjs +5 -0
- package/esm2020/state/effects/customer.effects.mjs +44 -0
- package/esm2020/state/facades/customer/facade.mjs +36 -0
- package/esm2020/state/facades/customer/interface.mjs +2 -0
- package/esm2020/state/facades/public_api.mjs +2 -0
- package/esm2020/state/index.mjs +2 -0
- package/esm2020/state/public_api.mjs +6 -0
- package/esm2020/state/reducers/customer/adapter.mjs +13 -0
- package/esm2020/state/reducers/customer/initial-state.mjs +9 -0
- package/esm2020/state/reducers/customer/interface.mjs +2 -0
- package/esm2020/state/reducers/customer/public_api.mjs +4 -0
- package/esm2020/state/reducers/customer/reducer.mjs +33 -0
- package/esm2020/state/reducers/public_api.mjs +4 -0
- package/esm2020/state/reducers/reducers.interface.mjs +2 -0
- package/esm2020/state/reducers/store-feature-key.mjs +5 -0
- package/esm2020/state/reducers/token/extra.token.mjs +30 -0
- package/esm2020/state/reducers/token/public_api.mjs +2 -0
- package/esm2020/state/reducers/token/reducers.token.mjs +21 -0
- package/esm2020/state/selectors/customer.selector.mjs +20 -0
- package/esm2020/state/selectors/feature.selector.mjs +9 -0
- package/esm2020/state/selectors/public_api.mjs +2 -0
- package/esm2020/state/testing/customer-testing.module.mjs +23 -0
- package/esm2020/state/testing/daffodil-customer-state-testing.mjs +5 -0
- package/esm2020/state/testing/index.mjs +2 -0
- package/esm2020/state/testing/mock-customer-facade.mjs +26 -0
- package/esm2020/state/testing/public_api.mjs +3 -0
- package/esm2020/testing/daffodil-customer-testing.mjs +5 -0
- package/esm2020/testing/factories/customer-address.factory.mjs +32 -0
- package/esm2020/testing/factories/customer.factory.mjs +41 -0
- package/esm2020/testing/factories/public_api.mjs +3 -0
- package/esm2020/testing/index.mjs +2 -0
- package/esm2020/testing/public_api.mjs +2 -0
- package/fesm2015/daffodil-customer-driver-in-memory.mjs +180 -0
- package/fesm2015/daffodil-customer-driver-in-memory.mjs.map +1 -0
- package/fesm2015/daffodil-customer-driver-magento-testing.mjs +73 -0
- package/fesm2015/daffodil-customer-driver-magento-testing.mjs.map +1 -0
- package/fesm2015/daffodil-customer-driver-magento.mjs +254 -0
- package/fesm2015/daffodil-customer-driver-magento.mjs.map +1 -0
- package/fesm2015/daffodil-customer-driver-testing.mjs +75 -0
- package/fesm2015/daffodil-customer-driver-testing.mjs.map +1 -0
- package/fesm2015/daffodil-customer-driver.mjs +33 -0
- package/fesm2015/daffodil-customer-driver.mjs.map +1 -0
- package/fesm2015/daffodil-customer-routing.mjs +53 -0
- package/fesm2015/daffodil-customer-routing.mjs.map +1 -0
- package/fesm2015/daffodil-customer-state-testing.mjs +53 -0
- package/fesm2015/daffodil-customer-state-testing.mjs.map +1 -0
- package/fesm2015/daffodil-customer-state.mjs +368 -0
- package/fesm2015/daffodil-customer-state.mjs.map +1 -0
- package/fesm2015/daffodil-customer-testing.mjs +74 -0
- package/fesm2015/daffodil-customer-testing.mjs.map +1 -0
- package/fesm2015/daffodil-customer.mjs +15 -0
- package/fesm2015/daffodil-customer.mjs.map +1 -0
- package/fesm2020/daffodil-customer-driver-in-memory.mjs +183 -0
- package/fesm2020/daffodil-customer-driver-in-memory.mjs.map +1 -0
- package/fesm2020/daffodil-customer-driver-magento-testing.mjs +73 -0
- package/fesm2020/daffodil-customer-driver-magento-testing.mjs.map +1 -0
- package/fesm2020/daffodil-customer-driver-magento.mjs +250 -0
- package/fesm2020/daffodil-customer-driver-magento.mjs.map +1 -0
- package/fesm2020/daffodil-customer-driver-testing.mjs +75 -0
- package/fesm2020/daffodil-customer-driver-testing.mjs.map +1 -0
- package/fesm2020/daffodil-customer-driver.mjs +33 -0
- package/fesm2020/daffodil-customer-driver.mjs.map +1 -0
- package/fesm2020/daffodil-customer-routing.mjs +53 -0
- package/fesm2020/daffodil-customer-routing.mjs.map +1 -0
- package/fesm2020/daffodil-customer-state-testing.mjs +53 -0
- package/fesm2020/daffodil-customer-state-testing.mjs.map +1 -0
- package/fesm2020/daffodil-customer-state.mjs +376 -0
- package/fesm2020/daffodil-customer-state.mjs.map +1 -0
- package/fesm2020/daffodil-customer-testing.mjs +74 -0
- package/fesm2020/daffodil-customer-testing.mjs.map +1 -0
- package/fesm2020/daffodil-customer.mjs +15 -0
- package/fesm2020/daffodil-customer.mjs.map +1 -0
- package/index.d.ts +1 -0
- package/injection-tokens/error-matcher.token.d.ts +7 -0
- package/injection-tokens/public_api.d.ts +1 -0
- package/models/address.type.d.ts +7 -0
- package/models/customer.type.d.ts +27 -0
- package/models/public_api.d.ts +2 -0
- package/package.json +125 -0
- package/public_api.d.ts +2 -0
- package/routing/daffodil-customer-routing.d.ts +5 -0
- package/routing/guards/clear-errors.guard.d.ts +14 -0
- package/routing/guards/public_api.d.ts +1 -0
- package/routing/index.d.ts +1 -0
- package/routing/package.json +10 -0
- package/routing/public_api.d.ts +2 -0
- package/routing/resolvers/customer.resolver.d.ts +14 -0
- package/routing/resolvers/public_api.d.ts +1 -0
- package/state/actions/customer.actions.d.ts +133 -0
- package/state/customer.module.d.ts +11 -0
- package/state/daffodil-customer-state.d.ts +5 -0
- package/state/effects/customer.effects.d.ts +30 -0
- package/state/facades/customer/facade.d.ts +26 -0
- package/state/facades/customer/interface.d.ts +13 -0
- package/state/facades/public_api.d.ts +2 -0
- package/state/index.d.ts +1 -0
- package/state/package.json +10 -0
- package/state/public_api.d.ts +5 -0
- package/state/reducers/customer/adapter.d.ts +7 -0
- package/state/reducers/customer/initial-state.d.ts +5 -0
- package/state/reducers/customer/interface.d.ts +9 -0
- package/state/reducers/customer/public_api.d.ts +4 -0
- package/state/reducers/customer/reducer.d.ts +7 -0
- package/state/reducers/public_api.d.ts +4 -0
- package/state/reducers/reducers.interface.d.ts +15 -0
- package/state/reducers/store-feature-key.d.ts +4 -0
- package/state/reducers/token/extra.token.d.ts +22 -0
- package/state/reducers/token/public_api.d.ts +1 -0
- package/state/reducers/token/reducers.token.d.ts +11 -0
- package/state/selectors/customer.selector.d.ts +14 -0
- package/state/selectors/feature.selector.d.ts +10 -0
- package/state/selectors/public_api.d.ts +1 -0
- package/state/testing/customer-testing.module.d.ts +9 -0
- package/state/testing/daffodil-customer-state-testing.d.ts +5 -0
- package/state/testing/index.d.ts +1 -0
- package/state/testing/mock-customer-facade.d.ts +20 -0
- package/state/testing/package.json +10 -0
- package/state/testing/public_api.d.ts +2 -0
- package/testing/daffodil-customer-testing.d.ts +5 -0
- package/testing/factories/customer-address.factory.d.ts +18 -0
- package/testing/factories/customer.factory.d.ts +26 -0
- package/testing/factories/public_api.d.ts +2 -0
- package/testing/index.d.ts +1 -0
- package/testing/package.json +10 -0
- package/testing/public_api.d.ts +1 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Injectable, NgModule } from '@angular/core';
|
|
3
|
+
import { STATUS } from 'angular-in-memory-web-api';
|
|
4
|
+
import * as i1 from '@daffodil/customer/testing';
|
|
5
|
+
import * as i1$1 from '@angular/common/http';
|
|
6
|
+
import { map } from 'rxjs';
|
|
7
|
+
import { CommonModule } from '@angular/common';
|
|
8
|
+
import { DaffCustomerDriver } from '@daffodil/customer/driver';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* An in-memory service that delegates customer queries to child backends
|
|
12
|
+
* via the {@link DAFF_CUSTOMER_IN_MEMORY_BACKENDS}.
|
|
13
|
+
*/
|
|
14
|
+
class DaffCustomerInMemoryBackendService {
|
|
15
|
+
constructor(factory) {
|
|
16
|
+
this.factory = factory;
|
|
17
|
+
this.customers = {};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Automatically called as part of the InMemoryDbService to parse incoming urls to match the InMemory backend urls.
|
|
21
|
+
*
|
|
22
|
+
* @param url initial url
|
|
23
|
+
* @param utils utility to parse url
|
|
24
|
+
* @returns ParsedRequestUrl
|
|
25
|
+
* @docs-private
|
|
26
|
+
*/
|
|
27
|
+
parseRequestUrl(url, utils) {
|
|
28
|
+
return utils.parseRequestUrl(url);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* @docs-private
|
|
32
|
+
*/
|
|
33
|
+
createDb() {
|
|
34
|
+
return {
|
|
35
|
+
customers: this.customers,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Gets a customer.
|
|
40
|
+
*
|
|
41
|
+
* @param reqInfo request object
|
|
42
|
+
* @returns An http response object
|
|
43
|
+
*/
|
|
44
|
+
get(reqInfo) {
|
|
45
|
+
const customer = this.factory.create();
|
|
46
|
+
this.customers[customer.id] = customer;
|
|
47
|
+
return reqInfo.utils.createResponse$(() => ({
|
|
48
|
+
status: STATUS.OK,
|
|
49
|
+
body: customer,
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
put(reqInfo) {
|
|
53
|
+
switch (reqInfo.id) {
|
|
54
|
+
case 'email':
|
|
55
|
+
return this.changeEmail(reqInfo);
|
|
56
|
+
case 'password':
|
|
57
|
+
return this.changePassword(reqInfo);
|
|
58
|
+
case 'customer':
|
|
59
|
+
return this.updateCustomer(reqInfo);
|
|
60
|
+
default:
|
|
61
|
+
return reqInfo.utils.createResponse$(() => ({
|
|
62
|
+
status: STATUS.NOT_FOUND,
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
updateCustomer(reqInfo) {
|
|
67
|
+
// TODO: fix bug where id can be nully
|
|
68
|
+
// interface with auth to actually find logged in customer?
|
|
69
|
+
const body = reqInfo.utils.getJsonBody(reqInfo.req);
|
|
70
|
+
const customer = this.customers[body.id];
|
|
71
|
+
if (!customer) {
|
|
72
|
+
return reqInfo.utils.createResponse$(() => ({
|
|
73
|
+
status: STATUS.NOT_FOUND,
|
|
74
|
+
}));
|
|
75
|
+
}
|
|
76
|
+
this.customers[body.id] = {
|
|
77
|
+
...customer,
|
|
78
|
+
...body,
|
|
79
|
+
};
|
|
80
|
+
return reqInfo.utils.createResponse$(() => ({
|
|
81
|
+
status: STATUS.OK,
|
|
82
|
+
body: this.customers[body.id],
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
changeEmail(reqInfo) {
|
|
86
|
+
// interface with auth to actually find logged in customer?
|
|
87
|
+
// const customer = this.factory.create(reqInfo.utils.getJsonBody(reqInfo.req));
|
|
88
|
+
// this.customers.push(customer);
|
|
89
|
+
return reqInfo.utils.createResponse$(() => ({
|
|
90
|
+
status: STATUS.OK,
|
|
91
|
+
body: {},
|
|
92
|
+
}));
|
|
93
|
+
}
|
|
94
|
+
changePassword(reqInfo) {
|
|
95
|
+
// interface with auth to actually find logged in customer?
|
|
96
|
+
// const customer = this.factory.create(reqInfo.utils.getJsonBody(reqInfo.req));
|
|
97
|
+
// this.customers.push(customer);
|
|
98
|
+
return reqInfo.utils.createResponse$(() => ({
|
|
99
|
+
status: STATUS.OK,
|
|
100
|
+
body: {},
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/** @nocollapse */ DaffCustomerInMemoryBackendService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCustomerInMemoryBackendService, deps: [{ token: i1.DaffCustomerFactory }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
105
|
+
/** @nocollapse */ DaffCustomerInMemoryBackendService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCustomerInMemoryBackendService, providedIn: 'root' });
|
|
106
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCustomerInMemoryBackendService, decorators: [{
|
|
107
|
+
type: Injectable,
|
|
108
|
+
args: [{
|
|
109
|
+
providedIn: 'root',
|
|
110
|
+
}]
|
|
111
|
+
}], ctorParameters: function () { return [{ type: i1.DaffCustomerFactory }]; } });
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* The customer inmemory driver to mock the customer backend service.
|
|
115
|
+
*
|
|
116
|
+
* @inheritdoc
|
|
117
|
+
*/
|
|
118
|
+
class DaffCustomerInMemoryDriver {
|
|
119
|
+
constructor(http) {
|
|
120
|
+
this.http = http;
|
|
121
|
+
/**
|
|
122
|
+
* @docs-private
|
|
123
|
+
*/
|
|
124
|
+
this.url = '/api/customer';
|
|
125
|
+
}
|
|
126
|
+
changeEmail(email, password) {
|
|
127
|
+
return this.http.put(`${this.url}/email`, { email, password });
|
|
128
|
+
}
|
|
129
|
+
changePassword(oldPassword, newPassword) {
|
|
130
|
+
return this.http.put(`${this.url}/password`, { new: newPassword, old: oldPassword }).pipe(map(() => undefined));
|
|
131
|
+
}
|
|
132
|
+
get() {
|
|
133
|
+
return this.http.get(this.url);
|
|
134
|
+
}
|
|
135
|
+
update(customer) {
|
|
136
|
+
return this.http.put(`${this.url}/customer`, customer);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/** @nocollapse */ DaffCustomerInMemoryDriver.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCustomerInMemoryDriver, deps: [{ token: i1$1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
140
|
+
/** @nocollapse */ DaffCustomerInMemoryDriver.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCustomerInMemoryDriver, providedIn: 'root' });
|
|
141
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCustomerInMemoryDriver, decorators: [{
|
|
142
|
+
type: Injectable,
|
|
143
|
+
args: [{
|
|
144
|
+
providedIn: 'root',
|
|
145
|
+
}]
|
|
146
|
+
}], ctorParameters: function () { return [{ type: i1$1.HttpClient }]; } });
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Provides the {@link DaffCustomerInMemoryDriver} as the {@link DaffCustomerDriver}.
|
|
150
|
+
*/
|
|
151
|
+
class DaffCustomerInMemoryDriverModule {
|
|
152
|
+
static forRoot() {
|
|
153
|
+
return {
|
|
154
|
+
ngModule: DaffCustomerInMemoryDriverModule,
|
|
155
|
+
providers: [
|
|
156
|
+
{
|
|
157
|
+
provide: DaffCustomerDriver,
|
|
158
|
+
useExisting: DaffCustomerInMemoryDriver,
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/** @nocollapse */ DaffCustomerInMemoryDriverModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCustomerInMemoryDriverModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
165
|
+
/** @nocollapse */ DaffCustomerInMemoryDriverModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCustomerInMemoryDriverModule, imports: [CommonModule] });
|
|
166
|
+
/** @nocollapse */ DaffCustomerInMemoryDriverModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCustomerInMemoryDriverModule, imports: [[
|
|
167
|
+
CommonModule,
|
|
168
|
+
]] });
|
|
169
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCustomerInMemoryDriverModule, decorators: [{
|
|
170
|
+
type: NgModule,
|
|
171
|
+
args: [{
|
|
172
|
+
imports: [
|
|
173
|
+
CommonModule,
|
|
174
|
+
],
|
|
175
|
+
}]
|
|
176
|
+
}] });
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Generated bundle index. Do not edit.
|
|
180
|
+
*/
|
|
181
|
+
|
|
182
|
+
export { DaffCustomerInMemoryBackendService, DaffCustomerInMemoryDriver, DaffCustomerInMemoryDriverModule };
|
|
183
|
+
//# sourceMappingURL=daffodil-customer-driver-in-memory.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daffodil-customer-driver-in-memory.mjs","sources":["../../../libs/customer/driver/in-memory/src/backend/customer.service.ts","../../../libs/customer/driver/in-memory/src/driver/customer.service.ts","../../../libs/customer/driver/in-memory/src/driver/customer-driver.module.ts","../../../libs/customer/driver/in-memory/src/daffodil-customer-driver-in-memory.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\nimport {\n InMemoryDbService,\n RequestInfoUtilities,\n ParsedRequestUrl,\n STATUS,\n RequestInfo,\n} from 'angular-in-memory-web-api';\n\nimport { DaffCustomer } from '@daffodil/customer';\nimport { DaffCustomerFactory } from '@daffodil/customer/testing';\n\n/**\n * An in-memory service that delegates customer queries to child backends\n * via the {@link DAFF_CUSTOMER_IN_MEMORY_BACKENDS}.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffCustomerInMemoryBackendService implements InMemoryDbService {\n customers: Record<DaffCustomer['id'], DaffCustomer> = {};\n\n constructor(\n private factory: DaffCustomerFactory,\n ) {}\n\n /**\n * Automatically called as part of the InMemoryDbService to parse incoming urls to match the InMemory backend urls.\n *\n * @param url initial url\n * @param utils utility to parse url\n * @returns ParsedRequestUrl\n * @docs-private\n */\n parseRequestUrl(url: string, utils: RequestInfoUtilities): ParsedRequestUrl {\n return utils.parseRequestUrl(url);\n }\n\n /**\n * @docs-private\n */\n createDb(): any {\n return {\n customers: this.customers,\n };\n }\n\n /**\n * Gets a customer.\n *\n * @param reqInfo request object\n * @returns An http response object\n */\n get(reqInfo: RequestInfo) {\n const customer = this.factory.create();\n this.customers[customer.id] = customer;\n\n return reqInfo.utils.createResponse$(() => ({\n status: STATUS.OK,\n body: customer,\n }));\n }\n\n put(reqInfo: RequestInfo) {\n switch (reqInfo.id) {\n case 'email':\n return this.changeEmail(reqInfo);\n\n case 'password':\n return this.changePassword(reqInfo);\n\n case 'customer':\n return this.updateCustomer(reqInfo);\n\n default:\n return reqInfo.utils.createResponse$(() => ({\n status: STATUS.NOT_FOUND,\n }));\n }\n }\n\n private updateCustomer(reqInfo: RequestInfo) {\n // TODO: fix bug where id can be nully\n // interface with auth to actually find logged in customer?\n const body = reqInfo.utils.getJsonBody(reqInfo.req);\n const customer = this.customers[body.id];\n\n if (!customer) {\n return reqInfo.utils.createResponse$(() => ({\n status: STATUS.NOT_FOUND,\n }));\n }\n\n this.customers[body.id] = {\n ...customer,\n ...body,\n };\n\n return reqInfo.utils.createResponse$(() => ({\n status: STATUS.OK,\n body: this.customers[body.id],\n }));\n }\n\n private changeEmail(reqInfo: RequestInfo) {\n // interface with auth to actually find logged in customer?\n // const customer = this.factory.create(reqInfo.utils.getJsonBody(reqInfo.req));\n // this.customers.push(customer);\n\n return reqInfo.utils.createResponse$(() => ({\n status: STATUS.OK,\n body: {},\n }));\n }\n\n private changePassword(reqInfo: RequestInfo) {\n // interface with auth to actually find logged in customer?\n // const customer = this.factory.create(reqInfo.utils.getJsonBody(reqInfo.req));\n // this.customers.push(customer);\n\n return reqInfo.utils.createResponse$(() => ({\n status: STATUS.OK,\n body: {},\n }));\n }\n}\n","import { HttpClient } from '@angular/common/http';\nimport { Injectable } from '@angular/core';\nimport {\n map,\n Observable,\n} from 'rxjs';\n\nimport { DaffCustomer } from '@daffodil/customer';\nimport { DaffCustomerDriverInterface } from '@daffodil/customer/driver';\n\n/**\n * The customer inmemory driver to mock the customer backend service.\n *\n * @inheritdoc\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffCustomerInMemoryDriver implements DaffCustomerDriverInterface {\n /**\n * @docs-private\n */\n url = '/api/customer';\n\n constructor(\n private http: HttpClient,\n ) {}\n\n changeEmail(email: string, password: string): Observable<DaffCustomer> {\n return this.http.put<DaffCustomer>(`${this.url}/email`, { email, password });\n }\n\n changePassword(oldPassword: string, newPassword: string): Observable<void> {\n return this.http.put<string>(`${this.url}/password`, { new: newPassword, old: oldPassword }).pipe(\n map(() => undefined),\n );\n }\n\n get(): Observable<DaffCustomer> {\n return this.http.get<DaffCustomer>(this.url);\n }\n\n update(customer: Partial<DaffCustomer>): Observable<DaffCustomer> {\n return this.http.put<DaffCustomer>(`${this.url}/customer`, customer);\n }\n}\n","import { CommonModule } from '@angular/common';\nimport {\n NgModule,\n ModuleWithProviders,\n} from '@angular/core';\n\nimport { DaffCustomerDriver } from '@daffodil/customer/driver';\n\nimport { DaffCustomerInMemoryDriver } from './customer.service';\n\n/**\n * Provides the {@link DaffCustomerInMemoryDriver} as the {@link DaffCustomerDriver}.\n */\n@NgModule({\n imports: [\n CommonModule,\n ],\n})\nexport class DaffCustomerInMemoryDriverModule {\n static forRoot(): ModuleWithProviders<DaffCustomerInMemoryDriverModule> {\n return {\n ngModule: DaffCustomerInMemoryDriverModule,\n providers: [\n {\n provide: DaffCustomerDriver,\n useExisting: DaffCustomerInMemoryDriver,\n },\n ],\n };\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["i1"],"mappings":";;;;;;;;;AAYA;;;AAGG;MAIU,kCAAkC,CAAA;AAG7C,IAAA,WAAA,CACU,OAA4B,EAAA;QAA5B,IAAO,CAAA,OAAA,GAAP,OAAO,CAAqB;QAHtC,IAAS,CAAA,SAAA,GAA6C,EAAE,CAAC;KAIrD;AAEJ;;;;;;;AAOG;IACH,eAAe,CAAC,GAAW,EAAE,KAA2B,EAAA;AACtD,QAAA,OAAO,KAAK,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;KACnC;AAED;;AAEG;IACH,QAAQ,GAAA;QACN,OAAO;YACL,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,CAAC;KACH;AAED;;;;;AAKG;AACH,IAAA,GAA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A;kBAHtC,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA,CAAA;;;ACPD;;AAEG;MAMU,gCAAgC,CAAA;AAC3C,IAAA,OAAO,OAAO,GAAA;QACZ,OAAO;AACL,YAAA,QAAQ,EAAE,gCAAgC;AAC1C,YAAA,SAAS,EAAE;AACT,gBAAA;AACE,oBAAA,OAAO,EAAE,kBAAkB;AAC3B,oBAAA,WAAW,EAAE,0BAA0B;AACxC,iBAAA;AACF,aAAA;SACF,CAAC;KACH;;gJAXU,gCAAgC,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;AAAhC,mBAAA,gCAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,gCAAgC,YAHzC,YAAY,CAAA,EAAA,CAAA,CAAA;AAGH,mBAAA,gCAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,gCAAgC,EAJlC,OAAA,EAAA,CAAA;YACP,YAAY;AACb,SAAA,CAAA,EAAA,CAAA,CAAA;2FAEU,gCAAgC,EAAA,UAAA,EAAA,CAAA;kBAL5C,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,OAAO,EAAE;wBACP,YAAY;AACb,qBAAA;AACF,iBAAA,CAAA;;;ACjBD;;AAEG;;;;"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Injectable } from '@angular/core';
|
|
3
|
+
import * as faker from '@faker-js/faker/locale/en_US';
|
|
4
|
+
import { DaffModelFactory } from '@daffodil/core/testing';
|
|
5
|
+
|
|
6
|
+
class MockMagentoCustomerAddress {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.__typename = 'CustomerAddress';
|
|
9
|
+
this.id = faker.datatype.uuid();
|
|
10
|
+
this.region = {
|
|
11
|
+
__typename: 'CustomerAddressRegion',
|
|
12
|
+
region_code: faker.address.stateAbbr(),
|
|
13
|
+
region: faker.address.state(),
|
|
14
|
+
};
|
|
15
|
+
this.country_code = faker.address.countryCode();
|
|
16
|
+
this.street = [faker.address.streetAddress()];
|
|
17
|
+
this.company = faker.company.companyName();
|
|
18
|
+
this.telephone = faker.phone.phoneNumber();
|
|
19
|
+
this.postcode = faker.address.zipCode();
|
|
20
|
+
this.city = faker.address.city();
|
|
21
|
+
this.firstname = faker.name.firstName();
|
|
22
|
+
this.lastname = faker.name.lastName();
|
|
23
|
+
this.email = faker.internet.email();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
class MagentoCustomerAddressFactory extends DaffModelFactory {
|
|
27
|
+
constructor() {
|
|
28
|
+
super(MockMagentoCustomerAddress);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/** @nocollapse */ MagentoCustomerAddressFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: MagentoCustomerAddressFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
32
|
+
/** @nocollapse */ MagentoCustomerAddressFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: MagentoCustomerAddressFactory, providedIn: 'root' });
|
|
33
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: MagentoCustomerAddressFactory, decorators: [{
|
|
34
|
+
type: Injectable,
|
|
35
|
+
args: [{
|
|
36
|
+
providedIn: 'root',
|
|
37
|
+
}]
|
|
38
|
+
}], ctorParameters: function () { return []; } });
|
|
39
|
+
|
|
40
|
+
class MockMagentoCustomer {
|
|
41
|
+
constructor(addressFactory) {
|
|
42
|
+
this.addressFactory = addressFactory;
|
|
43
|
+
this.__typename = 'Customer';
|
|
44
|
+
this.email = faker.internet.email();
|
|
45
|
+
this.firstname = faker.name.firstName();
|
|
46
|
+
this.lastname = faker.name.lastName();
|
|
47
|
+
this.is_subscribed = faker.datatype.boolean();
|
|
48
|
+
this.addresses = this.createAddresses();
|
|
49
|
+
}
|
|
50
|
+
createAddresses() {
|
|
51
|
+
return this.addressFactory.createMany(faker.datatype.number({ min: 3, max: 5 }));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
class MagentoCustomerFactory extends DaffModelFactory {
|
|
55
|
+
constructor(addressFactory) {
|
|
56
|
+
super(MockMagentoCustomer, addressFactory);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/** @nocollapse */ MagentoCustomerFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: MagentoCustomerFactory, deps: [{ token: MagentoCustomerAddressFactory }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
60
|
+
/** @nocollapse */ MagentoCustomerFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: MagentoCustomerFactory, providedIn: 'root' });
|
|
61
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: MagentoCustomerFactory, decorators: [{
|
|
62
|
+
type: Injectable,
|
|
63
|
+
args: [{
|
|
64
|
+
providedIn: 'root',
|
|
65
|
+
}]
|
|
66
|
+
}], ctorParameters: function () { return [{ type: MagentoCustomerAddressFactory }]; } });
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Generated bundle index. Do not edit.
|
|
70
|
+
*/
|
|
71
|
+
|
|
72
|
+
export { MagentoCustomerAddressFactory, MagentoCustomerFactory, MockMagentoCustomerAddress };
|
|
73
|
+
//# sourceMappingURL=daffodil-customer-driver-magento-testing.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daffodil-customer-driver-magento-testing.mjs","sources":["../../../libs/customer/driver/magento/testing/src/factories/address.factory.ts","../../../libs/customer/driver/magento/testing/src/factories/customer.factory.ts","../../../libs/customer/driver/magento/testing/src/daffodil-customer-driver-magento-testing.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\nimport * as faker from '@faker-js/faker/locale/en_US';\n\nimport { DaffModelFactory } from '@daffodil/core/testing';\nimport { MagentoCustomerAddress } from '@daffodil/customer/driver/magento';\n\nexport class MockMagentoCustomerAddress implements MagentoCustomerAddress {\n __typename = 'CustomerAddress';\n id = faker.datatype.uuid();\n region = {\n __typename: 'CustomerAddressRegion',\n region_code: faker.address.stateAbbr(),\n region: faker.address.state(),\n };\n country_code = faker.address.countryCode();\n street = [faker.address.streetAddress()];\n company = faker.company.companyName();\n telephone = faker.phone.phoneNumber();\n postcode = faker.address.zipCode();\n city = faker.address.city();\n firstname = faker.name.firstName();\n lastname = faker.name.lastName();\n email = faker.internet.email();\n}\n\n@Injectable({\n providedIn: 'root',\n})\nexport class MagentoCustomerAddressFactory extends DaffModelFactory<MagentoCustomerAddress> {\n constructor() {\n super(MockMagentoCustomerAddress);\n }\n}\n","import { Injectable } from '@angular/core';\nimport * as faker from '@faker-js/faker/locale/en_US';\n\nimport { DaffModelFactory } from '@daffodil/core/testing';\nimport {\n MagentoCustomer,\n MagentoCustomerAddress,\n} from '@daffodil/customer/driver/magento';\n\nimport { MagentoCustomerAddressFactory } from './address.factory';\n\nclass MockMagentoCustomer implements MagentoCustomer {\n __typename: 'Customer' = 'Customer';\n email = faker.internet.email();\n firstname = faker.name.firstName();\n lastname = faker.name.lastName();\n is_subscribed = faker.datatype.boolean();\n addresses = this.createAddresses();\n\n constructor(\n private addressFactory: MagentoCustomerAddressFactory,\n ) {}\n\n private createAddresses(): MagentoCustomerAddress[] {\n return this.addressFactory.createMany(faker.datatype.number({ min: 3, max: 5 }));\n }\n}\n\n@Injectable({\n providedIn: 'root',\n})\nexport class MagentoCustomerFactory extends DaffModelFactory<MagentoCustomer> {\n constructor(\n addressFactory: MagentoCustomerAddressFactory,\n ) {\n super(MockMagentoCustomer, addressFactory);\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["i1.MagentoCustomerAddressFactory"],"mappings":";;;;;MAMa,0BAA0B,CAAA;AAAvC,IAAA,WAAA,GAAA;QACE,IAAU,CAAA,UAAA,GAAG,iBAAiB,CAAC;AAC/B,QAAA,IAAA,CAAA,EAAE,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;AAC3B,QAAA,IAAA,CAAA,MAAM,GAAG;AACP,YAAA,UAAU,EAAE,uBAAuB;AACnC,YAAA,WAAW,EAAE,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE;AACtC,YAAA,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE;SAC9B,CAAC;AACF,QAAA,IAAA,CAAA,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;QAC3C,IAAM,CAAA,MAAA,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;AACzC,QAAA,IAAA,CAAA,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;AACtC,QAAA,IAAA,CAAA,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;AACtC,QAAA,IAAA,CAAA,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;AACnC,QAAA,IAAA,CAAA,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;AAC5B,QAAA,IAAA,CAAA,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;AACnC,QAAA,IAAA,CAAA,QAAQ,GAAG,KAAK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eAAe,GAAA;QACrB,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;KAClF;AACF,CAAA;AAKK,MAAO,sBAAuB,SAAQ,gBAAiC,CAAA;AAC3E,IAAA,WAAA,CACE,cAA6C,EAAA;AAE7C,QAAA,KAAK,CAAC,mBAAmB,EAAE,cAAc,CAAC,CAAC;KAC5C;;sIALU,sBAAsB,EAAA,IAAA,EAAA,CAAA,EAAA,KAAA,EAAAA,6BAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAAtB,mBAAA,sBAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,sBAAsB,cAFrB,MAAM,EAAA,CAAA,CAAA;2FAEP,sBAAsB,EAAA,UAAA,EAAA,CAAA;kBAHlC,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA,CAAA;;;AC9BD;;AAEG;;;;"}
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import * as i1 from 'apollo-angular';
|
|
2
|
+
import { gql } from 'apollo-angular';
|
|
3
|
+
import { DaffCustomerInvalidAPIResponseError, DaffCustomerDriver } from '@daffodil/customer/driver';
|
|
4
|
+
import { daffTransformMagentoError, DAFF_MAGENTO_CACHEABLE_OPERATIONS } from '@daffodil/driver/magento';
|
|
5
|
+
import * as i0 from '@angular/core';
|
|
6
|
+
import { Injectable, NgModule } from '@angular/core';
|
|
7
|
+
import { throwError } from 'rxjs';
|
|
8
|
+
import { map, catchError } from 'rxjs/operators';
|
|
9
|
+
import { CommonModule } from '@angular/common';
|
|
10
|
+
|
|
11
|
+
const magentoCustomerInputTransform = (customer) => ({
|
|
12
|
+
firstname: customer.firstName,
|
|
13
|
+
lastname: customer.lastName,
|
|
14
|
+
is_subscribed: customer.isSubscribed,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const magentoCustomerAddressTransform = (address) => ({
|
|
18
|
+
id: address.id,
|
|
19
|
+
street: address.street[0],
|
|
20
|
+
city: address.city,
|
|
21
|
+
region: address.region.region_code,
|
|
22
|
+
country: address.country_code,
|
|
23
|
+
country_id: address.country_code,
|
|
24
|
+
postcode: address.postcode,
|
|
25
|
+
firstname: address.firstname,
|
|
26
|
+
lastname: address.lastname,
|
|
27
|
+
telephone: address.telephone,
|
|
28
|
+
email: address.email,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const magentoCustomerTransform = (customer) => ({
|
|
32
|
+
id: customer.email,
|
|
33
|
+
email: customer.email,
|
|
34
|
+
firstName: customer.firstname,
|
|
35
|
+
lastName: customer.lastname,
|
|
36
|
+
isSubscribed: customer.is_subscribed,
|
|
37
|
+
addresses: customer.addresses.map(magentoCustomerAddressTransform),
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
var MagentoCustomerGender;
|
|
41
|
+
(function (MagentoCustomerGender) {
|
|
42
|
+
MagentoCustomerGender[MagentoCustomerGender["MALE"] = 1] = "MALE";
|
|
43
|
+
MagentoCustomerGender[MagentoCustomerGender["FEMALE"] = 2] = "FEMALE";
|
|
44
|
+
})(MagentoCustomerGender || (MagentoCustomerGender = {}));
|
|
45
|
+
|
|
46
|
+
const magentoCustomerAddressFragment = gql `
|
|
47
|
+
fragment magentoCustomerAddress on CustomerAddress {
|
|
48
|
+
id
|
|
49
|
+
city
|
|
50
|
+
country_code
|
|
51
|
+
firstname
|
|
52
|
+
lastname
|
|
53
|
+
postcode
|
|
54
|
+
region {
|
|
55
|
+
region_code
|
|
56
|
+
region
|
|
57
|
+
}
|
|
58
|
+
street
|
|
59
|
+
telephone
|
|
60
|
+
company
|
|
61
|
+
}
|
|
62
|
+
`;
|
|
63
|
+
|
|
64
|
+
const magentoCustomerFragment = gql `
|
|
65
|
+
fragment magentoCustomer on Customer {
|
|
66
|
+
email
|
|
67
|
+
firstname
|
|
68
|
+
lastname
|
|
69
|
+
is_subscribed
|
|
70
|
+
addresses {
|
|
71
|
+
...magentoCustomerAddress
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
${magentoCustomerAddressFragment}
|
|
75
|
+
`;
|
|
76
|
+
|
|
77
|
+
const MAGENTO_GET_CUSTOMER_QUERY_NAME = 'MagentoGetCustomer';
|
|
78
|
+
const getCustomer = gql `
|
|
79
|
+
query ${MAGENTO_GET_CUSTOMER_QUERY_NAME} {
|
|
80
|
+
customer {
|
|
81
|
+
...magentoCustomer
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
${magentoCustomerFragment}
|
|
85
|
+
`;
|
|
86
|
+
|
|
87
|
+
const MAGENTO_UPDATE_CUSTOMER_QUERY_NAME = 'MagentoUpdateCustomer';
|
|
88
|
+
const updateCustomer = gql `
|
|
89
|
+
mutation ${MAGENTO_UPDATE_CUSTOMER_QUERY_NAME}($customer: CustomerUpdateInput!) {
|
|
90
|
+
updateCustomerV2(input: $customer) {
|
|
91
|
+
customer {
|
|
92
|
+
...magentoCustomer
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
${magentoCustomerFragment}
|
|
97
|
+
`;
|
|
98
|
+
|
|
99
|
+
const MAGENTO_UPDATE_EMAIL_QUERY_NAME = 'MagentoUpdateEmail';
|
|
100
|
+
const updateEmail = gql `
|
|
101
|
+
mutation ${MAGENTO_UPDATE_EMAIL_QUERY_NAME}($email: String!, $password: String!) {
|
|
102
|
+
updateCustomerEmail(email: $email, password: $password) {
|
|
103
|
+
customer {
|
|
104
|
+
...magentoCustomer
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
${magentoCustomerFragment}
|
|
109
|
+
`;
|
|
110
|
+
|
|
111
|
+
const MAGENTO_CHANGE_PASSWORD_QUERY_NAME = 'MagentoChangePassword';
|
|
112
|
+
const changePassword = gql `
|
|
113
|
+
mutation ${MAGENTO_CHANGE_PASSWORD_QUERY_NAME}($old: String!, $new: String!) {
|
|
114
|
+
changeCustomerPassword(
|
|
115
|
+
currentPassword: $old
|
|
116
|
+
newPassword: $new
|
|
117
|
+
) {
|
|
118
|
+
email
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
`;
|
|
122
|
+
|
|
123
|
+
function transformMagentoReviewsError(error) {
|
|
124
|
+
return daffTransformMagentoError(error, {}) || new DaffCustomerInvalidAPIResponseError(error.message);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const validateGetCustomerResponse = (response) => {
|
|
128
|
+
if (response.data.customer?.email) {
|
|
129
|
+
return response;
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
throw new DaffCustomerInvalidAPIResponseError('Get customer response does not contain a valid customer.');
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const validateChangeEmailResponse = (response) => {
|
|
137
|
+
if (response.data.updateCustomerEmail.customer?.email) {
|
|
138
|
+
return response;
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
throw new DaffCustomerInvalidAPIResponseError('Update email response does not contain a valid customer.');
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const validateChangePasswordResponse = (response) => {
|
|
146
|
+
if (response.data.changeCustomerPassword?.email) {
|
|
147
|
+
return response;
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
throw new DaffCustomerInvalidAPIResponseError('Change password response does not contain a valid customer.');
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const validateUpdateCustomerResponse = (response) => {
|
|
155
|
+
if (response.data.updateCustomerV2.customer?.email) {
|
|
156
|
+
return response;
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
throw new DaffCustomerInvalidAPIResponseError('Update customer response does not contain a valid customer.');
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* A service for making Magento GraphQL queries for customers.
|
|
165
|
+
*
|
|
166
|
+
* @inheritdoc
|
|
167
|
+
*/
|
|
168
|
+
class DaffCustomerMagentoService {
|
|
169
|
+
constructor(apollo) {
|
|
170
|
+
this.apollo = apollo;
|
|
171
|
+
}
|
|
172
|
+
changeEmail(email, password) {
|
|
173
|
+
return this.apollo.mutate({
|
|
174
|
+
mutation: updateEmail,
|
|
175
|
+
variables: {
|
|
176
|
+
email,
|
|
177
|
+
password,
|
|
178
|
+
},
|
|
179
|
+
}).pipe(map(validateChangeEmailResponse), map(result => magentoCustomerTransform(result.data.updateCustomerEmail.customer)), catchError(err => throwError(() => transformMagentoReviewsError(err))));
|
|
180
|
+
}
|
|
181
|
+
changePassword(oldPassword, newPassword) {
|
|
182
|
+
return this.apollo.mutate({
|
|
183
|
+
mutation: changePassword,
|
|
184
|
+
variables: {
|
|
185
|
+
old: oldPassword,
|
|
186
|
+
new: newPassword,
|
|
187
|
+
},
|
|
188
|
+
}).pipe(map(validateChangePasswordResponse), map(() => undefined), catchError(err => throwError(() => transformMagentoReviewsError(err))));
|
|
189
|
+
}
|
|
190
|
+
get() {
|
|
191
|
+
return this.apollo.query({
|
|
192
|
+
query: getCustomer,
|
|
193
|
+
}).pipe(map(validateGetCustomerResponse), map(result => magentoCustomerTransform(result.data.customer)), catchError(err => throwError(() => transformMagentoReviewsError(err))));
|
|
194
|
+
}
|
|
195
|
+
update(customer) {
|
|
196
|
+
return this.apollo.mutate({
|
|
197
|
+
mutation: updateCustomer,
|
|
198
|
+
variables: {
|
|
199
|
+
customer: magentoCustomerInputTransform(customer),
|
|
200
|
+
},
|
|
201
|
+
}).pipe(map(validateUpdateCustomerResponse), map(result => magentoCustomerTransform(result.data.updateCustomerV2.customer)), catchError(err => throwError(() => transformMagentoReviewsError(err))));
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
/** @nocollapse */ DaffCustomerMagentoService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCustomerMagentoService, deps: [{ token: i1.Apollo }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
205
|
+
/** @nocollapse */ DaffCustomerMagentoService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCustomerMagentoService, providedIn: 'root' });
|
|
206
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCustomerMagentoService, decorators: [{
|
|
207
|
+
type: Injectable,
|
|
208
|
+
args: [{
|
|
209
|
+
providedIn: 'root',
|
|
210
|
+
}]
|
|
211
|
+
}], ctorParameters: function () { return [{ type: i1.Apollo }]; } });
|
|
212
|
+
|
|
213
|
+
class DaffCustomerMagentoDriverModule {
|
|
214
|
+
static forRoot() {
|
|
215
|
+
return {
|
|
216
|
+
ngModule: DaffCustomerMagentoDriverModule,
|
|
217
|
+
providers: [
|
|
218
|
+
{
|
|
219
|
+
provide: DaffCustomerDriver,
|
|
220
|
+
useExisting: DaffCustomerMagentoService,
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
provide: DAFF_MAGENTO_CACHEABLE_OPERATIONS,
|
|
224
|
+
useValue: MAGENTO_GET_CUSTOMER_QUERY_NAME,
|
|
225
|
+
multi: true,
|
|
226
|
+
},
|
|
227
|
+
],
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
/** @nocollapse */ DaffCustomerMagentoDriverModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCustomerMagentoDriverModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
232
|
+
/** @nocollapse */ DaffCustomerMagentoDriverModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCustomerMagentoDriverModule, imports: [CommonModule] });
|
|
233
|
+
/** @nocollapse */ DaffCustomerMagentoDriverModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCustomerMagentoDriverModule, imports: [[
|
|
234
|
+
CommonModule,
|
|
235
|
+
]] });
|
|
236
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCustomerMagentoDriverModule, decorators: [{
|
|
237
|
+
type: NgModule,
|
|
238
|
+
args: [{
|
|
239
|
+
imports: [
|
|
240
|
+
CommonModule,
|
|
241
|
+
],
|
|
242
|
+
}]
|
|
243
|
+
}] });
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Generated bundle index. Do not edit.
|
|
247
|
+
*/
|
|
248
|
+
|
|
249
|
+
export { DaffCustomerMagentoDriverModule, DaffCustomerMagentoService, MAGENTO_CHANGE_PASSWORD_QUERY_NAME, MAGENTO_GET_CUSTOMER_QUERY_NAME, MAGENTO_UPDATE_CUSTOMER_QUERY_NAME, MAGENTO_UPDATE_EMAIL_QUERY_NAME, MagentoCustomerGender, changePassword, getCustomer, magentoCustomerAddressFragment, magentoCustomerAddressTransform, magentoCustomerFragment, magentoCustomerInputTransform, magentoCustomerTransform, transformMagentoReviewsError, updateCustomer, updateEmail, validateGetCustomerResponse };
|
|
250
|
+
//# sourceMappingURL=daffodil-customer-driver-magento.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daffodil-customer-driver-magento.mjs","sources":["../../../libs/customer/driver/magento/src/transforms/requests/customer-input.ts","../../../libs/customer/driver/magento/src/transforms/responses/customer-address.ts","../../../libs/customer/driver/magento/src/transforms/responses/customer.ts","../../../libs/customer/driver/magento/src/models/gender.enum.ts","../../../libs/customer/driver/magento/src/queries/fragments/customer-address.ts","../../../libs/customer/driver/magento/src/queries/fragments/customer.ts","../../../libs/customer/driver/magento/src/queries/get-customer.ts","../../../libs/customer/driver/magento/src/queries/update-customer.ts","../../../libs/customer/driver/magento/src/queries/update-email.ts","../../../libs/customer/driver/magento/src/queries/change-password.ts","../../../libs/customer/driver/magento/src/errors/transform.ts","../../../libs/customer/driver/magento/src/validators/get-customer.ts","../../../libs/customer/driver/magento/src/validators/change-email.ts","../../../libs/customer/driver/magento/src/validators/change-password.ts","../../../libs/customer/driver/magento/src/validators/update-customer.ts","../../../libs/customer/driver/magento/src/customer.service.ts","../../../libs/customer/driver/magento/src/customer-driver.module.ts","../../../libs/customer/driver/magento/src/daffodil-customer-driver-magento.ts"],"sourcesContent":["import { DaffCustomer } from '@daffodil/customer';\n\nimport { MagentoCustomerInput } from '../../models/public_api';\n\nexport const magentoCustomerInputTransform = (customer: Partial<DaffCustomer>): MagentoCustomerInput => ({\n firstname: customer.firstName,\n lastname: customer.lastName,\n is_subscribed: customer.isSubscribed,\n});\n","import { DaffCustomerAddress } from '@daffodil/customer';\n\nimport { MagentoCustomerAddress } from '../../models/public_api';\n\nexport const magentoCustomerAddressTransform = (address: MagentoCustomerAddress): DaffCustomerAddress => ({\n id: address.id,\n street: address.street[0],\n city: address.city,\n region: address.region.region_code,\n country: address.country_code,\n country_id: address.country_code,\n postcode: address.postcode,\n firstname: address.firstname,\n lastname: address.lastname,\n telephone: address.telephone,\n email: address.email,\n});\n","import { DaffCustomer } from '@daffodil/customer';\n\nimport { MagentoCustomer } from '../../models/public_api';\nimport { magentoCustomerAddressTransform } from './customer-address';\n\nexport const magentoCustomerTransform = (customer: MagentoCustomer): DaffCustomer => ({\n id: customer.email,\n email: customer.email,\n firstName: customer.firstname,\n lastName: customer.lastname,\n isSubscribed: customer.is_subscribed,\n addresses: customer.addresses.map(magentoCustomerAddressTransform),\n});\n","export enum MagentoCustomerGender {\n MALE = 1,\n FEMALE = 2\n}\n","import { gql } from 'apollo-angular';\n\nexport const magentoCustomerAddressFragment = gql`\n fragment magentoCustomerAddress on CustomerAddress {\n id\n city\n country_code\n firstname\n lastname\n postcode\n region {\n region_code\n region\n }\n street\n telephone\n company\n }\n`;\n","import { gql } from 'apollo-angular';\n\nimport { magentoCustomerAddressFragment } from './customer-address';\n\nexport const magentoCustomerFragment = gql`\n fragment magentoCustomer on Customer {\n email\n firstname\n lastname\n is_subscribed\n addresses {\n ...magentoCustomerAddress\n }\n }\n ${magentoCustomerAddressFragment}\n`;\n","import { gql } from 'apollo-angular';\n\nimport { magentoCustomerFragment } from './fragments/public_api';\n\nexport const MAGENTO_GET_CUSTOMER_QUERY_NAME = 'MagentoGetCustomer';\n\nexport const getCustomer = gql`\n query ${MAGENTO_GET_CUSTOMER_QUERY_NAME} {\n customer {\n ...magentoCustomer\n }\n }\n ${magentoCustomerFragment}\n`;\n","import { gql } from 'apollo-angular';\n\nimport { magentoCustomerFragment } from './fragments/public_api';\n\nexport const MAGENTO_UPDATE_CUSTOMER_QUERY_NAME = 'MagentoUpdateCustomer';\n\nexport const updateCustomer = gql`\n mutation ${MAGENTO_UPDATE_CUSTOMER_QUERY_NAME}($customer: CustomerUpdateInput!) {\n updateCustomerV2(input: $customer) {\n customer {\n ...magentoCustomer\n }\n }\n }\n ${magentoCustomerFragment}\n`;\n","import { gql } from 'apollo-angular';\n\nimport { magentoCustomerFragment } from './fragments/public_api';\n\nexport const MAGENTO_UPDATE_EMAIL_QUERY_NAME = 'MagentoUpdateEmail';\n\nexport const updateEmail = gql`\n mutation ${MAGENTO_UPDATE_EMAIL_QUERY_NAME}($email: String!, $password: String!) {\n updateCustomerEmail(email: $email, password: $password) {\n customer {\n ...magentoCustomer\n }\n }\n }\n ${magentoCustomerFragment}\n`;\n","import { gql } from 'apollo-angular';\n\nexport const MAGENTO_CHANGE_PASSWORD_QUERY_NAME = 'MagentoChangePassword';\n\nexport const changePassword = gql`\n mutation ${MAGENTO_CHANGE_PASSWORD_QUERY_NAME}($old: String!, $new: String!) {\n changeCustomerPassword(\n currentPassword: $old\n newPassword: $new\n ) {\n email\n }\n }\n`;\n","import { DaffCustomerInvalidAPIResponseError } from '@daffodil/customer/driver';\nimport { daffTransformMagentoError } from '@daffodil/driver/magento';\n\nexport function transformMagentoReviewsError(error: any) {\n return daffTransformMagentoError(error, {}) || new DaffCustomerInvalidAPIResponseError(error.message);\n}\n","import { ApolloQueryResult } from '@apollo/client/core';\n\nimport { DaffCustomerInvalidAPIResponseError } from '@daffodil/customer/driver';\n\nimport { MagentoGetCustomerResponse } from '../models/public_api';\n\nexport const validateGetCustomerResponse = (response: ApolloQueryResult<MagentoGetCustomerResponse>) => {\n if (response.data.customer?.email) {\n return response;\n } else {\n throw new DaffCustomerInvalidAPIResponseError('Get customer response does not contain a valid customer.');\n }\n};\n","import { ApolloQueryResult } from '@apollo/client/core';\n\nimport { DaffCustomerInvalidAPIResponseError } from '@daffodil/customer/driver';\n\nimport { MagentoChangeEmailResponse } from '../models/public_api';\n\nexport const validateChangeEmailResponse = (response: ApolloQueryResult<MagentoChangeEmailResponse>) => {\n if (response.data.updateCustomerEmail.customer?.email) {\n return response;\n } else {\n throw new DaffCustomerInvalidAPIResponseError('Update email response does not contain a valid customer.');\n }\n};\n","import { ApolloQueryResult } from '@apollo/client/core';\n\nimport { DaffCustomerInvalidAPIResponseError } from '@daffodil/customer/driver';\n\nimport { MagentoChangePasswordResponse } from '../models/public_api';\n\nexport const validateChangePasswordResponse = (response: ApolloQueryResult<MagentoChangePasswordResponse>) => {\n if (response.data.changeCustomerPassword?.email) {\n return response;\n } else {\n throw new DaffCustomerInvalidAPIResponseError('Change password response does not contain a valid customer.');\n }\n};\n","import { ApolloQueryResult } from '@apollo/client/core';\n\nimport { DaffCustomerInvalidAPIResponseError } from '@daffodil/customer/driver';\n\nimport { MagentoUpdateCustomerResponse } from '../models/public_api';\n\nexport const validateUpdateCustomerResponse = (response: ApolloQueryResult<MagentoUpdateCustomerResponse>) => {\n if (response.data.updateCustomerV2.customer?.email) {\n return response;\n } else {\n throw new DaffCustomerInvalidAPIResponseError('Update customer response does not contain a valid customer.');\n }\n};\n","import { Injectable } from '@angular/core';\nimport { Apollo } from 'apollo-angular';\nimport {\n Observable,\n throwError,\n} from 'rxjs';\nimport {\n map,\n catchError,\n} from 'rxjs/operators';\n\nimport { DaffCustomer } from '@daffodil/customer';\nimport { DaffCustomerDriverInterface } from '@daffodil/customer/driver';\n\nimport { transformMagentoReviewsError } from './errors/transform';\nimport {\n MagentoChangeEmailResponse,\n MagentoChangePasswordResponse,\n MagentoGetCustomerResponse,\n MagentoUpdateCustomerResponse,\n} from './models/public_api';\nimport {\n changePassword,\n getCustomer,\n updateCustomer,\n updateEmail,\n} from './queries/public_api';\nimport {\n magentoCustomerInputTransform,\n magentoCustomerTransform,\n} from './transforms/public_api';\nimport { validateChangeEmailResponse } from './validators/change-email';\nimport { validateChangePasswordResponse } from './validators/change-password';\nimport { validateGetCustomerResponse } from './validators/public_api';\nimport { validateUpdateCustomerResponse } from './validators/update-customer';\n\n/**\n * A service for making Magento GraphQL queries for customers.\n *\n * @inheritdoc\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffCustomerMagentoService implements DaffCustomerDriverInterface {\n constructor(\n private apollo: Apollo,\n ) {}\n\n changeEmail(email: string, password: string): Observable<DaffCustomer> {\n return this.apollo.mutate<MagentoChangeEmailResponse>({\n mutation: updateEmail,\n variables: {\n email,\n password,\n },\n }).pipe(\n map(validateChangeEmailResponse),\n map(result => magentoCustomerTransform(result.data.updateCustomerEmail.customer)),\n catchError(err => throwError(() => transformMagentoReviewsError(err))),\n );\n }\n\n changePassword(oldPassword: string, newPassword: string): Observable<void> {\n return this.apollo.mutate<MagentoChangePasswordResponse>({\n mutation: changePassword,\n variables: {\n old: oldPassword,\n new: newPassword,\n },\n }).pipe(\n map(validateChangePasswordResponse),\n map(() => undefined),\n catchError(err => throwError(() => transformMagentoReviewsError(err))),\n );\n }\n\n get(): Observable<DaffCustomer> {\n return this.apollo.query<MagentoGetCustomerResponse>({\n query: getCustomer,\n }).pipe(\n map(validateGetCustomerResponse),\n map(result => magentoCustomerTransform(result.data.customer)),\n catchError(err => throwError(() => transformMagentoReviewsError(err))),\n );\n }\n\n update(customer: Partial<DaffCustomer>): Observable<DaffCustomer> {\n return this.apollo.mutate<MagentoUpdateCustomerResponse>({\n mutation: updateCustomer,\n variables: {\n customer: magentoCustomerInputTransform(customer),\n },\n }).pipe(\n map(validateUpdateCustomerResponse),\n map(result => magentoCustomerTransform(result.data.updateCustomerV2.customer)),\n catchError(err => throwError(() => transformMagentoReviewsError(err))),\n );\n }\n\n}\n","import { CommonModule } from '@angular/common';\nimport {\n NgModule,\n ModuleWithProviders,\n} from '@angular/core';\n\nimport { DaffCustomerDriver } from '@daffodil/customer/driver';\nimport { DAFF_MAGENTO_CACHEABLE_OPERATIONS } from '@daffodil/driver/magento';\n\nimport { DaffCustomerMagentoService } from './customer.service';\nimport { MAGENTO_GET_CUSTOMER_QUERY_NAME } from './queries/public_api';\n\n@NgModule({\n imports: [\n CommonModule,\n ],\n})\nexport class DaffCustomerMagentoDriverModule {\n static forRoot(): ModuleWithProviders<DaffCustomerMagentoDriverModule> {\n return {\n ngModule: DaffCustomerMagentoDriverModule,\n providers: [\n {\n provide: DaffCustomerDriver,\n useExisting: DaffCustomerMagentoService,\n },\n {\n provide: DAFF_MAGENTO_CACHEABLE_OPERATIONS,\n useValue: MAGENTO_GET_CUSTOMER_QUERY_NAME,\n multi: true,\n },\n ],\n };\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;MAIa,6BAA6B,GAAG,CAAC,QAA+B,MAA4B;IACvG,SAAS,EAAE,QAAQ,CAAC,SAAS;IAC7B,QAAQ,EAAE,QAAQ,CAAC,QAAQ;IAC3B,aAAa,EAAE,QAAQ,CAAC,YAAY;AACrC,CAAA;;MCJY,+BAA+B,GAAG,CAAC,OAA+B,MAA2B;IACxG,EAAE,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AQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,OAAO,EAAE;wBACP,YAAY;AACb,qBAAA;AACF,iBAAA,CAAA;;;AChBD;;AAEG;;;;"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { CommonModule } from '@angular/common';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { Injectable, NgModule } from '@angular/core';
|
|
4
|
+
import { DaffCustomerDriver } from '@daffodil/customer/driver';
|
|
5
|
+
import { of } from 'rxjs';
|
|
6
|
+
import * as i1 from '@daffodil/customer/testing';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A basic customer driver that creates mock customer results of different kinds.
|
|
10
|
+
* For testing purposes.
|
|
11
|
+
*
|
|
12
|
+
* @inheritdoc
|
|
13
|
+
*/
|
|
14
|
+
class DaffCustomerTestingDriver {
|
|
15
|
+
constructor(customerFactory) {
|
|
16
|
+
this.customerFactory = customerFactory;
|
|
17
|
+
}
|
|
18
|
+
changeEmail(email, password) {
|
|
19
|
+
return of(this.customerFactory.create({ email }));
|
|
20
|
+
}
|
|
21
|
+
changePassword(oldPassword, newPassword) {
|
|
22
|
+
return of(undefined);
|
|
23
|
+
}
|
|
24
|
+
get() {
|
|
25
|
+
return of(this.customerFactory.create());
|
|
26
|
+
}
|
|
27
|
+
update(customer) {
|
|
28
|
+
return of(this.customerFactory.create(customer));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/** @nocollapse */ DaffCustomerTestingDriver.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCustomerTestingDriver, deps: [{ token: i1.DaffCustomerFactory }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
32
|
+
/** @nocollapse */ DaffCustomerTestingDriver.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCustomerTestingDriver, providedIn: 'root' });
|
|
33
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCustomerTestingDriver, decorators: [{
|
|
34
|
+
type: Injectable,
|
|
35
|
+
args: [{
|
|
36
|
+
providedIn: 'root',
|
|
37
|
+
}]
|
|
38
|
+
}], ctorParameters: function () { return [{ type: i1.DaffCustomerFactory }]; } });
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Provides the {@link DaffCustomerTestingDriver} as the {@link DaffCustomerDriver}.
|
|
42
|
+
*/
|
|
43
|
+
class DaffCustomerTestingDriverModule {
|
|
44
|
+
static forRoot() {
|
|
45
|
+
return {
|
|
46
|
+
ngModule: DaffCustomerTestingDriverModule,
|
|
47
|
+
providers: [
|
|
48
|
+
{
|
|
49
|
+
provide: DaffCustomerDriver,
|
|
50
|
+
useExisting: DaffCustomerTestingDriver,
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/** @nocollapse */ DaffCustomerTestingDriverModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCustomerTestingDriverModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
57
|
+
/** @nocollapse */ DaffCustomerTestingDriverModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCustomerTestingDriverModule, imports: [CommonModule] });
|
|
58
|
+
/** @nocollapse */ DaffCustomerTestingDriverModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCustomerTestingDriverModule, imports: [[
|
|
59
|
+
CommonModule,
|
|
60
|
+
]] });
|
|
61
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCustomerTestingDriverModule, decorators: [{
|
|
62
|
+
type: NgModule,
|
|
63
|
+
args: [{
|
|
64
|
+
imports: [
|
|
65
|
+
CommonModule,
|
|
66
|
+
],
|
|
67
|
+
}]
|
|
68
|
+
}] });
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Generated bundle index. Do not edit.
|
|
72
|
+
*/
|
|
73
|
+
|
|
74
|
+
export { DaffCustomerTestingDriver, DaffCustomerTestingDriverModule };
|
|
75
|
+
//# sourceMappingURL=daffodil-customer-driver-testing.mjs.map
|