@daffodil/customer 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.
Files changed (43) hide show
  1. package/fesm2022/daffodil-customer-driver-in-memory.mjs +344 -324
  2. package/fesm2022/daffodil-customer-driver-in-memory.mjs.map +1 -1
  3. package/fesm2022/daffodil-customer-driver-magento-2.4.7-testing.mjs +116 -0
  4. package/fesm2022/daffodil-customer-driver-magento-2.4.7-testing.mjs.map +1 -0
  5. package/fesm2022/daffodil-customer-driver-magento-2.4.7.mjs +399 -0
  6. package/fesm2022/daffodil-customer-driver-magento-2.4.7.mjs.map +1 -0
  7. package/fesm2022/daffodil-customer-driver-magento-auto-testing.mjs +7 -0
  8. package/fesm2022/daffodil-customer-driver-magento-auto-testing.mjs.map +1 -0
  9. package/fesm2022/daffodil-customer-driver-magento-auto.mjs +7 -0
  10. package/fesm2022/daffodil-customer-driver-magento-auto.mjs.map +1 -0
  11. package/fesm2022/daffodil-customer-driver-testing.mjs +152 -105
  12. package/fesm2022/daffodil-customer-driver-testing.mjs.map +1 -1
  13. package/fesm2022/daffodil-customer-driver.mjs +45 -88
  14. package/fesm2022/daffodil-customer-driver.mjs.map +1 -1
  15. package/fesm2022/daffodil-customer-routing.mjs +86 -52
  16. package/fesm2022/daffodil-customer-routing.mjs.map +1 -1
  17. package/fesm2022/daffodil-customer-state-testing.mjs +176 -108
  18. package/fesm2022/daffodil-customer-state-testing.mjs.map +1 -1
  19. package/fesm2022/daffodil-customer-state.mjs +581 -718
  20. package/fesm2022/daffodil-customer-state.mjs.map +1 -1
  21. package/fesm2022/daffodil-customer-testing.mjs +102 -75
  22. package/fesm2022/daffodil-customer-testing.mjs.map +1 -1
  23. package/fesm2022/daffodil-customer.mjs +0 -4
  24. package/package.json +1 -1
  25. package/types/daffodil-customer-driver-in-memory.d.ts +102 -104
  26. package/types/daffodil-customer-driver-magento-2.4.7-testing.d.ts +33 -0
  27. package/types/daffodil-customer-driver-magento-2.4.7.d.ts +193 -0
  28. package/types/daffodil-customer-driver-magento-auto-testing.d.ts +1 -0
  29. package/types/daffodil-customer-driver-magento-auto.d.ts +1 -0
  30. package/types/daffodil-customer-driver-testing.d.ts +38 -37
  31. package/types/daffodil-customer-driver.d.ts +76 -90
  32. package/types/daffodil-customer-routing.d.ts +18 -22
  33. package/types/daffodil-customer-state-testing.d.ts +43 -43
  34. package/types/daffodil-customer-state.d.ts +240 -264
  35. package/types/daffodil-customer-testing.d.ts +27 -31
  36. package/types/daffodil-customer.d.ts +33 -37
  37. package/fesm2022/daffodil-customer-driver-magento-testing.mjs +0 -75
  38. package/fesm2022/daffodil-customer-driver-magento-testing.mjs.map +0 -1
  39. package/fesm2022/daffodil-customer-driver-magento.mjs +0 -448
  40. package/fesm2022/daffodil-customer-driver-magento.mjs.map +0 -1
  41. package/fesm2022/daffodil-customer.mjs.map +0 -1
  42. package/types/daffodil-customer-driver-magento-testing.d.ts +0 -37
  43. package/types/daffodil-customer-driver-magento.d.ts +0 -205
@@ -1,325 +1,345 @@
1
- import * as i0 from '@angular/core';
2
- import { Injectable, NgModule } from '@angular/core';
3
- import * as i2 from 'angular-in-memory-web-api';
4
- import { STATUS } from 'angular-in-memory-web-api';
5
- import * as i1 from '@daffodil/customer/testing';
6
- import * as i1$1 from '@angular/common/http';
7
- import { map } from 'rxjs';
8
- import { DaffInMemoryDriverBase, provideDaffInMemoryBackends } from '@daffodil/driver/in-memory';
9
- import { CommonModule } from '@angular/common';
10
- import { provideDaffCustomerDriver, provideDaffCustomerAddressDriver } from '@daffodil/customer/driver';
1
+ import * as i0 from "@angular/core";
2
+ import { Injectable, NgModule, makeEnvironmentProviders } from "@angular/core";
3
+ import * as i2 from "angular-in-memory-web-api";
4
+ import { STATUS } from "angular-in-memory-web-api";
5
+ import * as i1$1 from "@daffodil/customer/testing";
6
+ import * as i1 from "@angular/common/http";
7
+ import { map } from "rxjs";
8
+ import { DaffInMemoryDriverBase, provideDaffInMemoryBackends } from "@daffodil/driver/in-memory";
9
+ import { CommonModule } from "@angular/common";
10
+ import { provideDaffCustomerAddressDriver, provideDaffCustomerDriver } from "@daffodil/customer/driver";
11
+ const DAFF_CUSTOMER_IN_MEMORY_COLLECTION_NAME = "customer";
12
+ var DaffCustomerInMemoryBackendService = class DaffCustomerInMemoryBackendService {
13
+ constructor(factory) {
14
+ this.factory = factory;
15
+ this.collectionName = DAFF_CUSTOMER_IN_MEMORY_COLLECTION_NAME;
16
+ this.customers = {};
17
+ }
18
+ parseRequestUrl(url, utils) {
19
+ return utils.parseRequestUrl(url);
20
+ }
21
+ createDb() {
22
+ return { customers: this.customers };
23
+ }
24
+ get(reqInfo) {
25
+ const customer = this.factory.create();
26
+ this.customers[customer.id] = customer;
27
+ return reqInfo.utils.createResponse$(() => ({
28
+ status: STATUS.OK,
29
+ body: customer
30
+ }));
31
+ }
32
+ put(reqInfo) {
33
+ switch (reqInfo.id) {
34
+ case "email": return this.changeEmail(reqInfo);
35
+ case "password": return this.changePassword(reqInfo);
36
+ case "customer": return this.updateCustomer(reqInfo);
37
+ default: return reqInfo.utils.createResponse$(() => ({ status: STATUS.NOT_FOUND }));
38
+ }
39
+ }
40
+ updateCustomer(reqInfo) {
41
+ const body = reqInfo.utils.getJsonBody(reqInfo.req);
42
+ const customer = this.customers[body.id];
43
+ if (!customer) return reqInfo.utils.createResponse$(() => ({ status: STATUS.NOT_FOUND }));
44
+ this.customers[body.id] = {
45
+ ...customer,
46
+ ...body
47
+ };
48
+ return reqInfo.utils.createResponse$(() => ({
49
+ status: STATUS.OK,
50
+ body: this.customers[body.id]
51
+ }));
52
+ }
53
+ changeEmail(reqInfo) {
54
+ return reqInfo.utils.createResponse$(() => ({
55
+ status: STATUS.OK,
56
+ body: {}
57
+ }));
58
+ }
59
+ changePassword(reqInfo) {
60
+ return reqInfo.utils.createResponse$(() => ({
61
+ status: STATUS.OK,
62
+ body: {}
63
+ }));
64
+ }
65
+ static {
66
+ this.ɵfac = i0.ɵɵngDeclareFactory({
67
+ minVersion: "12.0.0",
68
+ version: "22.2.4",
69
+ ngImport: i0,
70
+ type: DaffCustomerInMemoryBackendService,
71
+ deps: [{ token: i1$1.DaffCustomerFactory }],
72
+ target: i0.ɵɵFactoryTarget.Injectable
73
+ });
74
+ }
75
+ static {
76
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
77
+ minVersion: "12.0.0",
78
+ version: "22.2.4",
79
+ ngImport: i0,
80
+ type: DaffCustomerInMemoryBackendService,
81
+ providedIn: "root"
82
+ });
83
+ }
84
+ };
85
+ i0.ɵɵngDeclareClassMetadata({
86
+ minVersion: "12.0.0",
87
+ version: "22.2.4",
88
+ ngImport: i0,
89
+ type: DaffCustomerInMemoryBackendService,
90
+ decorators: [{
91
+ type: Injectable,
92
+ args: [{ providedIn: "root" }]
93
+ }],
94
+ ctorParameters: () => [{ type: i1$1.DaffCustomerFactory }]
95
+ });
96
+ const DAFF_CUSTOMER_ADDRESS_IN_MEMORY_COLLECTION_NAME = "customer-address";
97
+ var DaffCustomerAddressInMemoryBackendService = class DaffCustomerAddressInMemoryBackendService {
98
+ constructor(factory) {
99
+ this.factory = factory;
100
+ this.collectionName = DAFF_CUSTOMER_ADDRESS_IN_MEMORY_COLLECTION_NAME;
101
+ this.addresses = {};
102
+ }
103
+ parseRequestUrl(url, utils) {
104
+ return utils.parseRequestUrl(url);
105
+ }
106
+ createDb() {
107
+ return { addresses: this.addresses };
108
+ }
109
+ get(reqInfo) {
110
+ return reqInfo.utils.createResponse$(() => {
111
+ if (reqInfo.id) {
112
+ const address = this.addresses[reqInfo.id];
113
+ return address ? {
114
+ status: STATUS.OK,
115
+ body: address
116
+ } : { status: STATUS.NOT_FOUND };
117
+ } else return {
118
+ status: STATUS.OK,
119
+ body: Object.values(this.addresses)
120
+ };
121
+ });
122
+ }
123
+ put(reqInfo) {
124
+ return reqInfo.utils.createResponse$(() => {
125
+ if (!reqInfo.id || !this.addresses[reqInfo.id]) return { status: STATUS.NOT_FOUND };
126
+ this.addresses[reqInfo.id] = {
127
+ ...this.addresses[reqInfo.id],
128
+ ...reqInfo.utils.getJsonBody(reqInfo.req)
129
+ };
130
+ return {
131
+ status: STATUS.OK,
132
+ body: Object.values(this.addresses)
133
+ };
134
+ });
135
+ }
136
+ post(reqInfo) {
137
+ return reqInfo.utils.createResponse$(() => {
138
+ const address = this.factory.create(reqInfo.utils.getJsonBody(reqInfo.req));
139
+ this.addresses[address.id] = address;
140
+ return {
141
+ status: STATUS.OK,
142
+ body: Object.values(this.addresses)
143
+ };
144
+ });
145
+ }
146
+ delete(reqInfo) {
147
+ return reqInfo.utils.createResponse$(() => {
148
+ if (!reqInfo.id || !this.addresses[reqInfo.id]) return { status: STATUS.NOT_FOUND };
149
+ delete this.addresses[reqInfo.id];
150
+ return {
151
+ status: STATUS.OK,
152
+ body: Object.values(this.addresses)
153
+ };
154
+ });
155
+ }
156
+ static {
157
+ this.ɵfac = i0.ɵɵngDeclareFactory({
158
+ minVersion: "12.0.0",
159
+ version: "22.2.4",
160
+ ngImport: i0,
161
+ type: DaffCustomerAddressInMemoryBackendService,
162
+ deps: [{ token: i1$1.DaffCustomerAddressFactory }],
163
+ target: i0.ɵɵFactoryTarget.Injectable
164
+ });
165
+ }
166
+ static {
167
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
168
+ minVersion: "12.0.0",
169
+ version: "22.2.4",
170
+ ngImport: i0,
171
+ type: DaffCustomerAddressInMemoryBackendService,
172
+ providedIn: "root"
173
+ });
174
+ }
175
+ };
176
+ i0.ɵɵngDeclareClassMetadata({
177
+ minVersion: "12.0.0",
178
+ version: "22.2.4",
179
+ ngImport: i0,
180
+ type: DaffCustomerAddressInMemoryBackendService,
181
+ decorators: [{
182
+ type: Injectable,
183
+ args: [{ providedIn: "root" }]
184
+ }],
185
+ ctorParameters: () => [{ type: i1$1.DaffCustomerAddressFactory }]
186
+ });
187
+ var DaffCustomerInMemoryDriver = class DaffCustomerInMemoryDriver extends DaffInMemoryDriverBase {
188
+ constructor(http, config) {
189
+ super(config, DAFF_CUSTOMER_IN_MEMORY_COLLECTION_NAME);
190
+ this.http = http;
191
+ }
192
+ changeEmail(email, password) {
193
+ return this.http.put(`${this.url}/email`, {
194
+ email,
195
+ password
196
+ });
197
+ }
198
+ changePassword(oldPassword, newPassword) {
199
+ return this.http.put(`${this.url}/password`, {
200
+ new: newPassword,
201
+ old: oldPassword
202
+ }).pipe(map(() => void 0));
203
+ }
204
+ get() {
205
+ return this.http.get(this.url);
206
+ }
207
+ update(customer) {
208
+ return this.http.put(`${this.url}/customer`, customer);
209
+ }
210
+ static {
211
+ this.ɵfac = i0.ɵɵngDeclareFactory({
212
+ minVersion: "12.0.0",
213
+ version: "22.2.4",
214
+ ngImport: i0,
215
+ type: DaffCustomerInMemoryDriver,
216
+ deps: [{ token: i1.HttpClient }, { token: i2.InMemoryBackendConfig }],
217
+ target: i0.ɵɵFactoryTarget.Injectable
218
+ });
219
+ }
220
+ static {
221
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
222
+ minVersion: "12.0.0",
223
+ version: "22.2.4",
224
+ ngImport: i0,
225
+ type: DaffCustomerInMemoryDriver,
226
+ providedIn: "root"
227
+ });
228
+ }
229
+ };
230
+ i0.ɵɵngDeclareClassMetadata({
231
+ minVersion: "12.0.0",
232
+ version: "22.2.4",
233
+ ngImport: i0,
234
+ type: DaffCustomerInMemoryDriver,
235
+ decorators: [{
236
+ type: Injectable,
237
+ args: [{ providedIn: "root" }]
238
+ }],
239
+ ctorParameters: () => [{ type: i1.HttpClient }, { type: i2.InMemoryBackendConfig }]
240
+ });
241
+ var DaffCustomerAddressInMemoryDriver = class DaffCustomerAddressInMemoryDriver extends DaffInMemoryDriverBase {
242
+ constructor(http, config) {
243
+ super(config, DAFF_CUSTOMER_ADDRESS_IN_MEMORY_COLLECTION_NAME);
244
+ this.http = http;
245
+ }
246
+ list() {
247
+ return this.http.get(this.url);
248
+ }
249
+ get(addressId) {
250
+ return this.http.get(`${this.url}/${addressId}`);
251
+ }
252
+ update(address) {
253
+ return this.http.put(`${this.url}/${address.id}`, address);
254
+ }
255
+ add(address) {
256
+ return this.http.post(this.url, address);
257
+ }
258
+ delete(addressId) {
259
+ return this.http.delete(`${this.url}/${addressId}`);
260
+ }
261
+ static {
262
+ this.ɵfac = i0.ɵɵngDeclareFactory({
263
+ minVersion: "12.0.0",
264
+ version: "22.2.4",
265
+ ngImport: i0,
266
+ type: DaffCustomerAddressInMemoryDriver,
267
+ deps: [{ token: i1.HttpClient }, { token: i2.InMemoryBackendConfig }],
268
+ target: i0.ɵɵFactoryTarget.Injectable
269
+ });
270
+ }
271
+ static {
272
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
273
+ minVersion: "12.0.0",
274
+ version: "22.2.4",
275
+ ngImport: i0,
276
+ type: DaffCustomerAddressInMemoryDriver,
277
+ providedIn: "root"
278
+ });
279
+ }
280
+ };
281
+ i0.ɵɵngDeclareClassMetadata({
282
+ minVersion: "12.0.0",
283
+ version: "22.2.4",
284
+ ngImport: i0,
285
+ type: DaffCustomerAddressInMemoryDriver,
286
+ decorators: [{
287
+ type: Injectable,
288
+ args: [{ providedIn: "root" }]
289
+ }],
290
+ ctorParameters: () => [{ type: i1.HttpClient }, { type: i2.InMemoryBackendConfig }]
291
+ });
292
+ const provideDaffCustomerInMemoryDriver = () => makeEnvironmentProviders([
293
+ provideDaffCustomerDriver(DaffCustomerInMemoryDriver),
294
+ provideDaffCustomerAddressDriver(DaffCustomerAddressInMemoryDriver),
295
+ provideDaffInMemoryBackends(DaffCustomerInMemoryBackendService, DaffCustomerAddressInMemoryBackendService)
296
+ ]);
297
+ var DaffCustomerInMemoryDriverModule = class DaffCustomerInMemoryDriverModule {
298
+ static forRoot() {
299
+ return {
300
+ ngModule: DaffCustomerInMemoryDriverModule,
301
+ providers: [provideDaffCustomerInMemoryDriver()]
302
+ };
303
+ }
304
+ static {
305
+ this.ɵfac = i0.ɵɵngDeclareFactory({
306
+ minVersion: "12.0.0",
307
+ version: "22.2.4",
308
+ ngImport: i0,
309
+ type: DaffCustomerInMemoryDriverModule,
310
+ deps: [],
311
+ target: i0.ɵɵFactoryTarget.NgModule
312
+ });
313
+ }
314
+ static {
315
+ this.ɵmod = i0.ɵɵngDeclareNgModule({
316
+ minVersion: "14.0.0",
317
+ version: "22.2.4",
318
+ ngImport: i0,
319
+ type: DaffCustomerInMemoryDriverModule,
320
+ imports: [CommonModule]
321
+ });
322
+ }
323
+ static {
324
+ this.ɵinj = i0.ɵɵngDeclareInjector({
325
+ minVersion: "12.0.0",
326
+ version: "22.2.4",
327
+ ngImport: i0,
328
+ type: DaffCustomerInMemoryDriverModule,
329
+ imports: [CommonModule]
330
+ });
331
+ }
332
+ };
333
+ i0.ɵɵngDeclareClassMetadata({
334
+ minVersion: "12.0.0",
335
+ version: "22.2.4",
336
+ ngImport: i0,
337
+ type: DaffCustomerInMemoryDriverModule,
338
+ decorators: [{
339
+ type: NgModule,
340
+ args: [{ imports: [CommonModule] }]
341
+ }]
342
+ });
343
+ export { DaffCustomerAddressInMemoryBackendService, DaffCustomerAddressInMemoryDriver, DaffCustomerInMemoryBackendService, DaffCustomerInMemoryDriver, DaffCustomerInMemoryDriverModule, provideDaffCustomerInMemoryDriver };
11
344
 
12
- const DAFF_CUSTOMER_IN_MEMORY_COLLECTION_NAME = 'customer';
13
-
14
- /**
15
- * An in-memory service that delegates customer queries to child backends
16
- * via the {@link DAFF_CUSTOMER_IN_MEMORY_BACKENDS}.
17
- */
18
- class DaffCustomerInMemoryBackendService {
19
- constructor(factory) {
20
- this.factory = factory;
21
- this.collectionName = DAFF_CUSTOMER_IN_MEMORY_COLLECTION_NAME;
22
- this.customers = {};
23
- }
24
- /**
25
- * Automatically called as part of the InMemoryDbService to parse incoming urls to match the InMemory backend urls.
26
- *
27
- * @param url initial url
28
- * @param utils utility to parse url
29
- * @returns ParsedRequestUrl
30
- * @docs-private
31
- */
32
- parseRequestUrl(url, utils) {
33
- return utils.parseRequestUrl(url);
34
- }
35
- /**
36
- * @docs-private
37
- */
38
- createDb() {
39
- return {
40
- customers: this.customers,
41
- };
42
- }
43
- /**
44
- * Gets a customer.
45
- *
46
- * @param reqInfo request object
47
- * @returns An http response object
48
- */
49
- get(reqInfo) {
50
- const customer = this.factory.create();
51
- this.customers[customer.id] = customer;
52
- return reqInfo.utils.createResponse$(() => ({
53
- status: STATUS.OK,
54
- body: customer,
55
- }));
56
- }
57
- put(reqInfo) {
58
- switch (reqInfo.id) {
59
- case 'email':
60
- return this.changeEmail(reqInfo);
61
- case 'password':
62
- return this.changePassword(reqInfo);
63
- case 'customer':
64
- return this.updateCustomer(reqInfo);
65
- default:
66
- return reqInfo.utils.createResponse$(() => ({
67
- status: STATUS.NOT_FOUND,
68
- }));
69
- }
70
- }
71
- updateCustomer(reqInfo) {
72
- // TODO: fix bug where id can be nully
73
- // interface with auth to actually find logged in customer?
74
- const body = reqInfo.utils.getJsonBody(reqInfo.req);
75
- const customer = this.customers[body.id];
76
- if (!customer) {
77
- return reqInfo.utils.createResponse$(() => ({
78
- status: STATUS.NOT_FOUND,
79
- }));
80
- }
81
- this.customers[body.id] = {
82
- ...customer,
83
- ...body,
84
- };
85
- return reqInfo.utils.createResponse$(() => ({
86
- status: STATUS.OK,
87
- body: this.customers[body.id],
88
- }));
89
- }
90
- changeEmail(reqInfo) {
91
- // interface with auth to actually find logged in customer?
92
- // const customer = this.factory.create(reqInfo.utils.getJsonBody(reqInfo.req));
93
- // this.customers.push(customer);
94
- return reqInfo.utils.createResponse$(() => ({
95
- status: STATUS.OK,
96
- body: {},
97
- }));
98
- }
99
- changePassword(reqInfo) {
100
- // interface with auth to actually find logged in customer?
101
- // const customer = this.factory.create(reqInfo.utils.getJsonBody(reqInfo.req));
102
- // this.customers.push(customer);
103
- return reqInfo.utils.createResponse$(() => ({
104
- status: STATUS.OK,
105
- body: {},
106
- }));
107
- }
108
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCustomerInMemoryBackendService, deps: [{ token: i1.DaffCustomerFactory }], target: i0.ɵɵFactoryTarget.Injectable }); }
109
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCustomerInMemoryBackendService, providedIn: 'root' }); }
110
- }
111
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCustomerInMemoryBackendService, decorators: [{
112
- type: Injectable,
113
- args: [{
114
- providedIn: 'root',
115
- }]
116
- }], ctorParameters: () => [{ type: i1.DaffCustomerFactory }] });
117
-
118
- const DAFF_CUSTOMER_ADDRESS_IN_MEMORY_COLLECTION_NAME = 'customer-address';
119
-
120
- /**
121
- * An in-memory service that handles customer address HTTP requests.
122
- */
123
- class DaffCustomerAddressInMemoryBackendService {
124
- constructor(factory) {
125
- this.factory = factory;
126
- this.collectionName = DAFF_CUSTOMER_ADDRESS_IN_MEMORY_COLLECTION_NAME;
127
- this.addresses = {};
128
- }
129
- /**
130
- * Automatically called as part of the InMemoryDbService to parse incoming urls to match the InMemory backend urls.
131
- *
132
- * @param url initial url
133
- * @param utils utility to parse url
134
- * @returns ParsedRequestUrl
135
- * @docs-private
136
- */
137
- parseRequestUrl(url, utils) {
138
- return utils.parseRequestUrl(url);
139
- }
140
- /**
141
- * @docs-private
142
- */
143
- createDb() {
144
- return {
145
- addresses: this.addresses,
146
- };
147
- }
148
- /**
149
- * Gets a customer.
150
- *
151
- * @param reqInfo request object
152
- * @returns An http response object
153
- */
154
- get(reqInfo) {
155
- return reqInfo.utils.createResponse$(() => {
156
- if (reqInfo.id) {
157
- const address = this.addresses[reqInfo.id];
158
- return address
159
- ? {
160
- status: STATUS.OK,
161
- body: address,
162
- }
163
- : {
164
- status: STATUS.NOT_FOUND,
165
- };
166
- }
167
- else {
168
- return {
169
- status: STATUS.OK,
170
- body: Object.values(this.addresses),
171
- };
172
- }
173
- });
174
- }
175
- put(reqInfo) {
176
- return reqInfo.utils.createResponse$(() => {
177
- if (!reqInfo.id || !this.addresses[reqInfo.id]) {
178
- return {
179
- status: STATUS.NOT_FOUND,
180
- };
181
- }
182
- this.addresses[reqInfo.id] = {
183
- ...this.addresses[reqInfo.id],
184
- ...reqInfo.utils.getJsonBody(reqInfo.req),
185
- };
186
- return {
187
- status: STATUS.OK,
188
- body: Object.values(this.addresses),
189
- };
190
- });
191
- }
192
- post(reqInfo) {
193
- return reqInfo.utils.createResponse$(() => {
194
- const address = this.factory.create(reqInfo.utils.getJsonBody(reqInfo.req));
195
- this.addresses[address.id] = address;
196
- return {
197
- status: STATUS.OK,
198
- body: Object.values(this.addresses),
199
- };
200
- });
201
- }
202
- delete(reqInfo) {
203
- return reqInfo.utils.createResponse$(() => {
204
- if (!reqInfo.id || !this.addresses[reqInfo.id]) {
205
- return {
206
- status: STATUS.NOT_FOUND,
207
- };
208
- }
209
- delete this.addresses[reqInfo.id];
210
- return {
211
- status: STATUS.OK,
212
- body: Object.values(this.addresses),
213
- };
214
- });
215
- }
216
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCustomerAddressInMemoryBackendService, deps: [{ token: i1.DaffCustomerAddressFactory }], target: i0.ɵɵFactoryTarget.Injectable }); }
217
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCustomerAddressInMemoryBackendService, providedIn: 'root' }); }
218
- }
219
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCustomerAddressInMemoryBackendService, decorators: [{
220
- type: Injectable,
221
- args: [{
222
- providedIn: 'root',
223
- }]
224
- }], ctorParameters: () => [{ type: i1.DaffCustomerAddressFactory }] });
225
-
226
- /**
227
- * The customer inmemory driver to mock the customer backend service.
228
- *
229
- * @inheritdoc
230
- */
231
- class DaffCustomerInMemoryDriver extends DaffInMemoryDriverBase {
232
- constructor(http, config) {
233
- super(config, DAFF_CUSTOMER_IN_MEMORY_COLLECTION_NAME);
234
- this.http = http;
235
- }
236
- changeEmail(email, password) {
237
- return this.http.put(`${this.url}/email`, { email, password });
238
- }
239
- changePassword(oldPassword, newPassword) {
240
- return this.http.put(`${this.url}/password`, { new: newPassword, old: oldPassword }).pipe(map(() => undefined));
241
- }
242
- get() {
243
- return this.http.get(this.url);
244
- }
245
- update(customer) {
246
- return this.http.put(`${this.url}/customer`, customer);
247
- }
248
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCustomerInMemoryDriver, deps: [{ token: i1$1.HttpClient }, { token: i2.InMemoryBackendConfig }], target: i0.ɵɵFactoryTarget.Injectable }); }
249
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCustomerInMemoryDriver, providedIn: 'root' }); }
250
- }
251
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCustomerInMemoryDriver, decorators: [{
252
- type: Injectable,
253
- args: [{
254
- providedIn: 'root',
255
- }]
256
- }], ctorParameters: () => [{ type: i1$1.HttpClient }, { type: i2.InMemoryBackendConfig }] });
257
-
258
- /**
259
- * The customer address in-memory driver to mock the customer address backend service.
260
- *
261
- * @inheritdoc
262
- */
263
- class DaffCustomerAddressInMemoryDriver extends DaffInMemoryDriverBase {
264
- constructor(http, config) {
265
- super(config, DAFF_CUSTOMER_ADDRESS_IN_MEMORY_COLLECTION_NAME);
266
- this.http = http;
267
- }
268
- list() {
269
- return this.http.get(this.url);
270
- }
271
- get(addressId) {
272
- return this.http.get(`${this.url}/${addressId}`);
273
- }
274
- update(address) {
275
- return this.http.put(`${this.url}/${address.id}`, address);
276
- }
277
- add(address) {
278
- return this.http.post(this.url, address);
279
- }
280
- delete(addressId) {
281
- return this.http.delete(`${this.url}/${addressId}`);
282
- }
283
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCustomerAddressInMemoryDriver, deps: [{ token: i1$1.HttpClient }, { token: i2.InMemoryBackendConfig }], target: i0.ɵɵFactoryTarget.Injectable }); }
284
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCustomerAddressInMemoryDriver, providedIn: 'root' }); }
285
- }
286
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCustomerAddressInMemoryDriver, decorators: [{
287
- type: Injectable,
288
- args: [{
289
- providedIn: 'root',
290
- }]
291
- }], ctorParameters: () => [{ type: i1$1.HttpClient }, { type: i2.InMemoryBackendConfig }] });
292
-
293
- /**
294
- * Provides the {@link DaffCustomerInMemoryDriver} as the {@link DaffCustomerDriver}.
295
- */
296
- class DaffCustomerInMemoryDriverModule {
297
- static forRoot() {
298
- return {
299
- ngModule: DaffCustomerInMemoryDriverModule,
300
- providers: [
301
- provideDaffCustomerDriver(DaffCustomerInMemoryDriver),
302
- provideDaffCustomerAddressDriver(DaffCustomerAddressInMemoryDriver),
303
- provideDaffInMemoryBackends(DaffCustomerInMemoryBackendService, DaffCustomerAddressInMemoryBackendService),
304
- ],
305
- };
306
- }
307
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCustomerInMemoryDriverModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
308
- /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.9", ngImport: i0, type: DaffCustomerInMemoryDriverModule, imports: [CommonModule] }); }
309
- /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCustomerInMemoryDriverModule, imports: [CommonModule] }); }
310
- }
311
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCustomerInMemoryDriverModule, decorators: [{
312
- type: NgModule,
313
- args: [{
314
- imports: [
315
- CommonModule,
316
- ],
317
- }]
318
- }] });
319
-
320
- /**
321
- * Generated bundle index. Do not edit.
322
- */
323
-
324
- export { DaffCustomerAddressInMemoryBackendService, DaffCustomerAddressInMemoryDriver, DaffCustomerInMemoryBackendService, DaffCustomerInMemoryDriver, DaffCustomerInMemoryDriverModule };
325
- //# sourceMappingURL=daffodil-customer-driver-in-memory.mjs.map
345
+ //# sourceMappingURL=daffodil-customer-driver-in-memory.mjs.map