@daffodil/customer 0.94.1 → 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 +1 @@
1
- {"version":3,"file":"daffodil-customer-driver-in-memory.mjs","sources":["../../../libs/customer/driver/in-memory/src/collection-names/customer.const.ts","../../../libs/customer/driver/in-memory/src/backend/customer.service.ts","../../../libs/customer/driver/in-memory/src/collection-names/address.const.ts","../../../libs/customer/driver/in-memory/src/backend/address.service.ts","../../../libs/customer/driver/in-memory/src/driver/customer.service.ts","../../../libs/customer/driver/in-memory/src/driver/address.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":["export const DAFF_CUSTOMER_IN_MEMORY_COLLECTION_NAME = 'customer';\n","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';\nimport { DaffInMemorySingleRouteableBackend } from '@daffodil/driver/in-memory';\n\nimport { DAFF_CUSTOMER_IN_MEMORY_COLLECTION_NAME } from '../collection-names/customer.const';\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, DaffInMemorySingleRouteableBackend {\n readonly collectionName = DAFF_CUSTOMER_IN_MEMORY_COLLECTION_NAME;\n\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","export const DAFF_CUSTOMER_ADDRESS_IN_MEMORY_COLLECTION_NAME = 'customer-address';\n","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 { DaffCustomerAddress } from '@daffodil/customer';\nimport { DaffCustomerAddressFactory } from '@daffodil/customer/testing';\nimport { DaffInMemorySingleRouteableBackend } from '@daffodil/driver/in-memory';\n\nimport { DAFF_CUSTOMER_ADDRESS_IN_MEMORY_COLLECTION_NAME } from '../collection-names/address.const';\n\n/**\n * An in-memory service that handles customer address HTTP requests.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffCustomerAddressInMemoryBackendService implements InMemoryDbService, DaffInMemorySingleRouteableBackend {\n readonly collectionName = DAFF_CUSTOMER_ADDRESS_IN_MEMORY_COLLECTION_NAME;\n\n addresses: Record<DaffCustomerAddress['id'], DaffCustomerAddress> = {};\n\n constructor(\n private factory: DaffCustomerAddressFactory,\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 addresses: this.addresses,\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 return reqInfo.utils.createResponse$(() => {\n if (reqInfo.id) {\n const address = this.addresses[reqInfo.id];\n return address\n ? {\n status: STATUS.OK,\n body: address,\n }\n : {\n status: STATUS.NOT_FOUND,\n };\n } else {\n return {\n status: STATUS.OK,\n body: Object.values(this.addresses),\n };\n }\n });\n }\n\n put(reqInfo: RequestInfo) {\n return reqInfo.utils.createResponse$(() => {\n if (!reqInfo.id || !this.addresses[reqInfo.id]) {\n return {\n status: STATUS.NOT_FOUND,\n };\n }\n\n this.addresses[reqInfo.id] = {\n ...this.addresses[reqInfo.id],\n ...reqInfo.utils.getJsonBody(reqInfo.req),\n };\n\n return {\n status: STATUS.OK,\n body: Object.values(this.addresses),\n };\n });\n }\n\n post(reqInfo: RequestInfo) {\n return reqInfo.utils.createResponse$(() => {\n const address = this.factory.create(reqInfo.utils.getJsonBody(reqInfo.req));\n\n this.addresses[address.id] = address;\n\n return {\n status: STATUS.OK,\n body: Object.values(this.addresses),\n };\n });\n }\n\n delete(reqInfo: RequestInfo) {\n return reqInfo.utils.createResponse$(() => {\n if (!reqInfo.id || !this.addresses[reqInfo.id]) {\n return {\n status: STATUS.NOT_FOUND,\n };\n }\n\n delete this.addresses[reqInfo.id];\n\n return {\n status: STATUS.OK,\n body: Object.values(this.addresses),\n };\n });\n }\n}\n","import { HttpClient } from '@angular/common/http';\nimport { Injectable } from '@angular/core';\nimport { InMemoryBackendConfig } from 'angular-in-memory-web-api';\nimport {\n map,\n Observable,\n} from 'rxjs';\n\nimport { DaffCustomer } from '@daffodil/customer';\nimport { DaffCustomerDriverInterface } from '@daffodil/customer/driver';\nimport { DaffInMemoryDriverBase } from '@daffodil/driver/in-memory';\n\nimport { DAFF_CUSTOMER_IN_MEMORY_COLLECTION_NAME } from '../collection-names/customer.const';\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 extends DaffInMemoryDriverBase implements DaffCustomerDriverInterface {\n constructor(\n private http: HttpClient,\n config: InMemoryBackendConfig,\n ) {\n super(config, DAFF_CUSTOMER_IN_MEMORY_COLLECTION_NAME);\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 { HttpClient } from '@angular/common/http';\nimport { Injectable } from '@angular/core';\nimport { InMemoryBackendConfig } from 'angular-in-memory-web-api';\nimport { Observable } from 'rxjs';\n\nimport { DaffIdentifiable } from '@daffodil/core';\nimport { DaffCustomerAddress } from '@daffodil/customer';\nimport { DaffCustomerAddressDriverInterface } from '@daffodil/customer/driver';\nimport { DaffInMemoryDriverBase } from '@daffodil/driver/in-memory';\n\nimport { DAFF_CUSTOMER_ADDRESS_IN_MEMORY_COLLECTION_NAME } from '../collection-names/address.const';\n\n/**\n * The customer address in-memory driver to mock the customer address backend service.\n *\n * @inheritdoc\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffCustomerAddressInMemoryDriver extends DaffInMemoryDriverBase implements DaffCustomerAddressDriverInterface {\n constructor(\n private http: HttpClient,\n config: InMemoryBackendConfig,\n ) {\n super(config, DAFF_CUSTOMER_ADDRESS_IN_MEMORY_COLLECTION_NAME);\n }\n\n list(): Observable<DaffCustomerAddress[]> {\n return this.http.get<DaffCustomerAddress[]>(this.url);\n }\n\n get(addressId: string): Observable<DaffCustomerAddress> {\n return this.http.get<DaffCustomerAddress>(`${this.url}/${addressId}`);\n }\n\n update(address: Partial<DaffCustomerAddress> & DaffIdentifiable): Observable<DaffCustomerAddress[]> {\n return this.http.put<DaffCustomerAddress[]>(`${this.url}/${address.id}`, address);\n }\n\n add(address: DaffCustomerAddress): Observable<DaffCustomerAddress[]> {\n return this.http.post<DaffCustomerAddress[]>(this.url, address);\n }\n\n delete(addressId: string): Observable<DaffCustomerAddress[]> {\n return this.http.delete<DaffCustomerAddress[]>(`${this.url}/${addressId}`);\n }\n}\n","import { CommonModule } from '@angular/common';\nimport {\n NgModule,\n ModuleWithProviders,\n} from '@angular/core';\n\nimport {\n provideDaffCustomerAddressDriver,\n provideDaffCustomerDriver,\n} from '@daffodil/customer/driver';\nimport {\n DaffInMemoryBackendInterface,\n provideDaffInMemoryBackends,\n} from '@daffodil/driver/in-memory';\n\nimport { DaffCustomerAddressInMemoryDriver } from './address.service';\nimport { DaffCustomerInMemoryDriver } from './customer.service';\nimport { DaffCustomerAddressInMemoryBackendService } from '../backend/address.service';\nimport { DaffCustomerInMemoryBackendService } from '../backend/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 provideDaffCustomerDriver(DaffCustomerInMemoryDriver),\n provideDaffCustomerAddressDriver(DaffCustomerAddressInMemoryDriver),\n provideDaffInMemoryBackends<DaffInMemoryBackendInterface>(\n DaffCustomerInMemoryBackendService,\n DaffCustomerAddressInMemoryBackendService,\n ),\n ],\n };\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["i1"],"mappings":";;;;;;;;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P,iCAAiC,EAAA,UAAA,EAAA,CAAA;kBAH7C,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA;;;ACCD;;AAEG;MAMU,gCAAgC,CAAA;AAC3C,IAAA,OAAO,OAAO,GAAA;QACZ,OAAO;AACL,YAAA,QAAQ,EAAE,gCAAgC;AAC1C,YAAA,SAAS,EAAE;gBACT,yBAAyB,CAAC,0BAA0B,CAAC;gBACrD,gCAAgC,CAAC,iCAAiC,CAAC;AACnE,gBAAA,2BAA2B,CACzB,kCAAkC,EAClC,yCAAyC,CAC1C;AACF,aAAA;SACF;IACH;iIAbW,gCAAgC,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;AAAhC,uBAAA,SAAA,IAAA,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,uBAAA,SAAA,IAAA,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;;2FAGH,gCAAgC,EAAA,UAAA,EAAA,CAAA;kBAL5C,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,OAAO,EAAE;wBACP,YAAY;AACb,qBAAA;AACF,iBAAA;;;AC3BD;;AAEG;;;;"}
1
+ {"version":3,"file":"daffodil-customer-driver-in-memory.mjs","names":["i1","i1"],"sources":["../../../libs/customer/driver/in-memory/src/collection-names/customer.const.ts","../../../libs/customer/driver/in-memory/src/backend/customer.service.ts","../../../libs/customer/driver/in-memory/src/collection-names/address.const.ts","../../../libs/customer/driver/in-memory/src/backend/address.service.ts","../../../libs/customer/driver/in-memory/src/driver/customer.service.ts","../../../libs/customer/driver/in-memory/src/driver/address.service.ts","../../../libs/customer/driver/in-memory/src/provider.ts","../../../libs/customer/driver/in-memory/src/driver/customer-driver.module.ts"],"sourcesContent":["export const DAFF_CUSTOMER_IN_MEMORY_COLLECTION_NAME = 'customer';\n","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';\nimport { DaffInMemorySingleRouteableBackend } from '@daffodil/driver/in-memory';\n\nimport { DAFF_CUSTOMER_IN_MEMORY_COLLECTION_NAME } from '../collection-names/customer.const';\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, DaffInMemorySingleRouteableBackend {\n readonly collectionName = DAFF_CUSTOMER_IN_MEMORY_COLLECTION_NAME;\n\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","export const DAFF_CUSTOMER_ADDRESS_IN_MEMORY_COLLECTION_NAME = 'customer-address';\n","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 { DaffCustomerAddress } from '@daffodil/customer';\nimport { DaffCustomerAddressFactory } from '@daffodil/customer/testing';\nimport { DaffInMemorySingleRouteableBackend } from '@daffodil/driver/in-memory';\n\nimport { DAFF_CUSTOMER_ADDRESS_IN_MEMORY_COLLECTION_NAME } from '../collection-names/address.const';\n\n/**\n * An in-memory service that handles customer address HTTP requests.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffCustomerAddressInMemoryBackendService implements InMemoryDbService, DaffInMemorySingleRouteableBackend {\n readonly collectionName = DAFF_CUSTOMER_ADDRESS_IN_MEMORY_COLLECTION_NAME;\n\n addresses: Record<DaffCustomerAddress['id'], DaffCustomerAddress> = {};\n\n constructor(\n private factory: DaffCustomerAddressFactory,\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 addresses: this.addresses,\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 return reqInfo.utils.createResponse$(() => {\n if (reqInfo.id) {\n const address = this.addresses[reqInfo.id];\n return address\n ? {\n status: STATUS.OK,\n body: address,\n }\n : {\n status: STATUS.NOT_FOUND,\n };\n } else {\n return {\n status: STATUS.OK,\n body: Object.values(this.addresses),\n };\n }\n });\n }\n\n put(reqInfo: RequestInfo) {\n return reqInfo.utils.createResponse$(() => {\n if (!reqInfo.id || !this.addresses[reqInfo.id]) {\n return {\n status: STATUS.NOT_FOUND,\n };\n }\n\n this.addresses[reqInfo.id] = {\n ...this.addresses[reqInfo.id],\n ...reqInfo.utils.getJsonBody(reqInfo.req),\n };\n\n return {\n status: STATUS.OK,\n body: Object.values(this.addresses),\n };\n });\n }\n\n post(reqInfo: RequestInfo) {\n return reqInfo.utils.createResponse$(() => {\n const address = this.factory.create(reqInfo.utils.getJsonBody(reqInfo.req));\n\n this.addresses[address.id] = address;\n\n return {\n status: STATUS.OK,\n body: Object.values(this.addresses),\n };\n });\n }\n\n delete(reqInfo: RequestInfo) {\n return reqInfo.utils.createResponse$(() => {\n if (!reqInfo.id || !this.addresses[reqInfo.id]) {\n return {\n status: STATUS.NOT_FOUND,\n };\n }\n\n delete this.addresses[reqInfo.id];\n\n return {\n status: STATUS.OK,\n body: Object.values(this.addresses),\n };\n });\n }\n}\n","import { HttpClient } from '@angular/common/http';\nimport { Injectable } from '@angular/core';\nimport { InMemoryBackendConfig } from 'angular-in-memory-web-api';\nimport {\n map,\n Observable,\n} from 'rxjs';\n\nimport { DaffCustomer } from '@daffodil/customer';\nimport { DaffCustomerDriverInterface } from '@daffodil/customer/driver';\nimport { DaffInMemoryDriverBase } from '@daffodil/driver/in-memory';\n\nimport { DAFF_CUSTOMER_IN_MEMORY_COLLECTION_NAME } from '../collection-names/customer.const';\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 extends DaffInMemoryDriverBase implements DaffCustomerDriverInterface {\n constructor(\n private http: HttpClient,\n config: InMemoryBackendConfig,\n ) {\n super(config, DAFF_CUSTOMER_IN_MEMORY_COLLECTION_NAME);\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 { HttpClient } from '@angular/common/http';\nimport { Injectable } from '@angular/core';\nimport { InMemoryBackendConfig } from 'angular-in-memory-web-api';\nimport { Observable } from 'rxjs';\n\nimport { DaffIdentifiable } from '@daffodil/core';\nimport { DaffCustomerAddress } from '@daffodil/customer';\nimport { DaffCustomerAddressDriverInterface } from '@daffodil/customer/driver';\nimport { DaffInMemoryDriverBase } from '@daffodil/driver/in-memory';\n\nimport { DAFF_CUSTOMER_ADDRESS_IN_MEMORY_COLLECTION_NAME } from '../collection-names/address.const';\n\n/**\n * The customer address in-memory driver to mock the customer address backend service.\n *\n * @inheritdoc\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffCustomerAddressInMemoryDriver extends DaffInMemoryDriverBase implements DaffCustomerAddressDriverInterface {\n constructor(\n private http: HttpClient,\n config: InMemoryBackendConfig,\n ) {\n super(config, DAFF_CUSTOMER_ADDRESS_IN_MEMORY_COLLECTION_NAME);\n }\n\n list(): Observable<DaffCustomerAddress[]> {\n return this.http.get<DaffCustomerAddress[]>(this.url);\n }\n\n get(addressId: string): Observable<DaffCustomerAddress> {\n return this.http.get<DaffCustomerAddress>(`${this.url}/${addressId}`);\n }\n\n update(address: Partial<DaffCustomerAddress> & DaffIdentifiable): Observable<DaffCustomerAddress[]> {\n return this.http.put<DaffCustomerAddress[]>(`${this.url}/${address.id}`, address);\n }\n\n add(address: DaffCustomerAddress): Observable<DaffCustomerAddress[]> {\n return this.http.post<DaffCustomerAddress[]>(this.url, address);\n }\n\n delete(addressId: string): Observable<DaffCustomerAddress[]> {\n return this.http.delete<DaffCustomerAddress[]>(`${this.url}/${addressId}`);\n }\n}\n","import {\n EnvironmentProviders,\n makeEnvironmentProviders,\n} from '@angular/core';\n\nimport {\n provideDaffCustomerAddressDriver,\n provideDaffCustomerDriver,\n} from '@daffodil/customer/driver';\nimport {\n DaffInMemoryBackendInterface,\n provideDaffInMemoryBackends,\n} from '@daffodil/driver/in-memory';\n\nimport { DaffCustomerAddressInMemoryBackendService } from './backend/address.service';\nimport { DaffCustomerInMemoryBackendService } from './backend/customer.service';\nimport { DaffCustomerAddressInMemoryDriver } from './driver/address.service';\nimport { DaffCustomerInMemoryDriver } from './driver/customer.service';\n\n/**\n * Provides the {@link DaffCustomerInMemoryDriver} as the {@link DaffCustomerDriver}.\n */\nexport const provideDaffCustomerInMemoryDriver = (): EnvironmentProviders => makeEnvironmentProviders([\n provideDaffCustomerDriver(DaffCustomerInMemoryDriver),\n provideDaffCustomerAddressDriver(DaffCustomerAddressInMemoryDriver),\n provideDaffInMemoryBackends<DaffInMemoryBackendInterface>(\n DaffCustomerInMemoryBackendService,\n DaffCustomerAddressInMemoryBackendService,\n ),\n]);\n","import { CommonModule } from '@angular/common';\nimport {\n NgModule,\n ModuleWithProviders,\n} from '@angular/core';\n\nimport { provideDaffCustomerInMemoryDriver } from '../provider';\n\n/**\n * Provides the {@link DaffCustomerInMemoryDriver} as the {@link DaffCustomerDriver}.\n *\n * @deprecated in favor of {@link provideDaffCustomerInMemoryDriver} Deprecated in version 0.95.0. Will be removed in version 0.98.0.\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 provideDaffCustomerInMemoryDriver(),\n ],\n };\n }\n}\n"],"mappings":";;;;;;;;;;AAAA,MAAa,0CAA0C;ACsBvD,IAAa,qCAAb,MAAa,mCAAkC;CAK7C,YACU,SAA4B;EAA5B,KAAA,UAAA;EALD,KAAA,iBAAiB;EAE1B,KAAA,YAAsD,CAAA;CAInD;CAUH,gBAAgB,KAAa,OAA2B;EACtD,OAAO,MAAM,gBAAgB,GAAG;CAClC;CAKA,WAAQ;EACN,OAAO,EACL,WAAW,KAAK,UACjB;CACH;CAQA,IAAI,SAAoB;EACtB,MAAM,WAAW,KAAK,QAAQ,OAAM;EACpC,KAAK,UAAU,SAAS,MAAM;EAE9B,OAAO,QAAQ,MAAM,uBAAuB;GAC1C,QAAQ,OAAO;GACf,MAAM;EACP,EAAC;CACJ;CAEA,IAAI,SAAoB;EACtB,QAAQ,QAAQ,IAAhB;GACE,KAAK,SACH,OAAO,KAAK,YAAY,OAAO;GAEj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AA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAiC,YAAA,CAAA;EAH7C,MAAA;EAAW,MAAA,CAAA,EACV,YAAY,OACb,CAAA;;;;ACGD,MAAa,0CAAgE,yBAAyB;CACpG,0BAA0B,0BAA0B;CACpD,iCAAiC,iCAAiC;CAClE,4BACE,oCACA,yCAAyC;AAE5C,CAAA;ACXD,IAAa,mCAAb,MAAa,iCAAgC;CAC3C,OAAO,UAAO;EACZ,OAAO;GACL,UAAU;GACV,WAAW,CACT,kCAAiC,CAClC;EACF;CACH;CARW;EAAA,KAAA,OAAA,GAAA,mBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;GAAgC,MAAA,CAAA;GAAA,QAAA,GAAA,gBAAA;EAAA,CAAA;CAAA;CAAhC;EAAA,KAAA,OAAA,GAAA,oBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;GAAgC,SAAA,CAHzC,YAAY;EAAA,CAAA;CAAA;CAGH;EAAA,KAAA,OAAA,GAAA,oBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;GAAgC,SAAA,CAHzC,YAAY;EAAA,CAAA;CAAA;;AAGH,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAgC,YAAA,CAAA;EAL5C,MAAA;EAAS,MAAA,CAAA,EACR,SAAS,CACP,YACD,EACF,CAAA"}
@@ -0,0 +1,116 @@
1
+ import * as i0 from "@angular/core";
2
+ import { Injectable } from "@angular/core";
3
+ import { faker } from "@faker-js/faker/locale/en_US";
4
+ import { DaffModelFactory, enforceUnique } from "@daffodil/core/testing";
5
+ var MockMagentoCustomerAddress = class {
6
+ constructor() {
7
+ this.__typename = "CustomerAddress";
8
+ this.id = enforceUnique(faker.number.int);
9
+ this.region = {
10
+ __typename: "CustomerAddressRegion",
11
+ region_code: faker.location.state({ abbreviated: true }),
12
+ region_id: enforceUnique(faker.number.int)
13
+ };
14
+ this.country_code = faker.location.countryCode();
15
+ this.street = [faker.location.streetAddress()];
16
+ this.company = faker.company.name();
17
+ this.telephone = faker.phone.number();
18
+ this.postcode = faker.location.zipCode();
19
+ this.city = faker.location.city();
20
+ this.firstname = faker.person.firstName();
21
+ this.lastname = faker.person.lastName();
22
+ this.email = faker.internet.email();
23
+ this.default_billing = faker.datatype.boolean();
24
+ this.default_shipping = faker.datatype.boolean();
25
+ }
26
+ };
27
+ var MagentoCustomerAddressFactory = class MagentoCustomerAddressFactory extends DaffModelFactory {
28
+ constructor() {
29
+ super(MockMagentoCustomerAddress);
30
+ }
31
+ static {
32
+ this.ɵfac = i0.ɵɵngDeclareFactory({
33
+ minVersion: "12.0.0",
34
+ version: "22.2.4",
35
+ ngImport: i0,
36
+ type: MagentoCustomerAddressFactory,
37
+ deps: [],
38
+ target: i0.ɵɵFactoryTarget.Injectable
39
+ });
40
+ }
41
+ static {
42
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
43
+ minVersion: "12.0.0",
44
+ version: "22.2.4",
45
+ ngImport: i0,
46
+ type: MagentoCustomerAddressFactory,
47
+ providedIn: "root"
48
+ });
49
+ }
50
+ };
51
+ i0.ɵɵngDeclareClassMetadata({
52
+ minVersion: "12.0.0",
53
+ version: "22.2.4",
54
+ ngImport: i0,
55
+ type: MagentoCustomerAddressFactory,
56
+ decorators: [{
57
+ type: Injectable,
58
+ args: [{ providedIn: "root" }]
59
+ }],
60
+ ctorParameters: () => []
61
+ });
62
+ var MockMagentoCustomer = class {
63
+ constructor(addressFactory) {
64
+ this.addressFactory = addressFactory;
65
+ this.__typename = "Customer";
66
+ this.email = faker.internet.email();
67
+ this.firstname = faker.person.firstName();
68
+ this.lastname = faker.person.lastName();
69
+ this.is_subscribed = faker.datatype.boolean();
70
+ this.addresses = this.createAddresses();
71
+ }
72
+ createAddresses() {
73
+ return this.addressFactory.createMany(faker.number.int({
74
+ min: 3,
75
+ max: 5
76
+ }));
77
+ }
78
+ };
79
+ var MagentoCustomerFactory = class MagentoCustomerFactory extends DaffModelFactory {
80
+ constructor(addressFactory) {
81
+ super(MockMagentoCustomer, addressFactory);
82
+ }
83
+ static {
84
+ this.ɵfac = i0.ɵɵngDeclareFactory({
85
+ minVersion: "12.0.0",
86
+ version: "22.2.4",
87
+ ngImport: i0,
88
+ type: MagentoCustomerFactory,
89
+ deps: [{ token: MagentoCustomerAddressFactory }],
90
+ target: i0.ɵɵFactoryTarget.Injectable
91
+ });
92
+ }
93
+ static {
94
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
95
+ minVersion: "12.0.0",
96
+ version: "22.2.4",
97
+ ngImport: i0,
98
+ type: MagentoCustomerFactory,
99
+ providedIn: "root"
100
+ });
101
+ }
102
+ };
103
+ i0.ɵɵngDeclareClassMetadata({
104
+ minVersion: "12.0.0",
105
+ version: "22.2.4",
106
+ ngImport: i0,
107
+ type: MagentoCustomerFactory,
108
+ decorators: [{
109
+ type: Injectable,
110
+ args: [{ providedIn: "root" }]
111
+ }],
112
+ ctorParameters: () => [{ type: MagentoCustomerAddressFactory }]
113
+ });
114
+ export { MagentoCustomerAddressFactory, MagentoCustomerFactory, MockMagentoCustomerAddress };
115
+
116
+ //# sourceMappingURL=daffodil-customer-driver-magento-2.4.7-testing.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"daffodil-customer-driver-magento-2.4.7-testing.mjs","names":["i1.MagentoCustomerAddressFactory"],"sources":["../../../libs/customer/driver/magento/2.4.7/testing/src/factories/address.factory.ts","../../../libs/customer/driver/magento/2.4.7/testing/src/factories/customer.factory.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\nimport { faker } from '@faker-js/faker/locale/en_US';\n\nimport {\n DaffModelFactory,\n enforceUnique,\n} from '@daffodil/core/testing';\nimport { MagentoCustomerAddress } from '@daffodil/customer/driver/magento/2.4.7';\n\nexport class MockMagentoCustomerAddress implements MagentoCustomerAddress {\n __typename = 'CustomerAddress';\n id = enforceUnique(faker.number.int);\n region = {\n __typename: 'CustomerAddressRegion',\n region_code: faker.location.state({ abbreviated: true }),\n region_id: enforceUnique(faker.number.int),\n };\n country_code = faker.location.countryCode();\n street = [faker.location.streetAddress()];\n company = faker.company.name();\n telephone = faker.phone.number();\n postcode = faker.location.zipCode();\n city = faker.location.city();\n firstname = faker.person.firstName();\n lastname = faker.person.lastName();\n email = faker.internet.email();\n default_billing = faker.datatype.boolean();\n default_shipping = faker.datatype.boolean();\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 { 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/2.4.7';\n\nimport { MagentoCustomerAddressFactory } from './address.factory';\n\nclass MockMagentoCustomer implements MagentoCustomer {\n __typename = <const>'Customer';\n email = faker.internet.email();\n firstname = faker.person.firstName();\n lastname = faker.person.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.number.int({ 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"],"mappings":";;;;AASA,IAAa,6BAAb,MAAuC;CAAvC,cAAA;EACE,KAAA,aAAa;EACb,KAAA,KAAK,cAAc,MAAM,OAAO,GAAG;EACnC,KAAA,SAAS;GACP,YAAY;GACZ,aAAa,MAAM,SAAS,MAAM,EAAE,aAAa,KAAI,CAAE;GACvD,WAAW,cAAc,MA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AAe;EACrB,OAAO,KAAK,eAAe,WAAW,MAAM,OAAO,IAAI;GAAE,KAAK;GAAG,KAAK;EAAC,CAAE,CAAC;CAC5E;AACD;AAKD,IAAa,yBAAb,MAAa,+BAA+B,iBAAiC;CAC3E,YACE,gBAA6C;EAE7C,MAAM,qBAAqB,cAAc;CAC3C;CALW;EAAA,KAAA,OAAA,GAAA,mBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;GAAsB,MAAA,CAAA,EAAA,OAAAA,8BAAA,CAAA;GAAA,QAAA,GAAA,gBAAA;EAAA,CAAA;CAAA;CAAtB;EAAA,KAAA,QAAA,GAAA,sBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;GAAsB,YAFrB;EAAM,CAAA;CAAA;;AAEP,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAsB,YAAA,CAAA;EAHlC,MAAA;EAAW,MAAA,CAAA,EACV,YAAY,OACb,CAAA"}
@@ -0,0 +1,399 @@
1
+ import * as i1 from "apollo-angular";
2
+ import { gql } from "apollo-angular";
3
+ import { CombinedGraphQLErrors } from "@apollo/client";
4
+ import { DaffCustomerAddressNotFoundError, DaffCustomerDriverErrorCodes, DaffCustomerDriverErrorMap, DaffCustomerInvalidAPIResponseError, provideDaffCustomerAddressDriver, provideDaffCustomerDriver } from "@daffodil/customer/driver";
5
+ import { daffTransformMagentoError } from "@daffodil/driver/magento/2.4.7";
6
+ import * as i0 from "@angular/core";
7
+ import { Injectable, NgModule, makeEnvironmentProviders } from "@angular/core";
8
+ import { throwError } from "rxjs";
9
+ import { catchError, map, switchMap } from "rxjs/operators";
10
+ import { CommonModule } from "@angular/common";
11
+ import * as i2 from "@daffodil/core/graphql";
12
+ const magentoCustomerInputTransform = (customer) => ({
13
+ firstname: customer.firstName,
14
+ lastname: customer.lastName,
15
+ is_subscribed: customer.isSubscribed
16
+ });
17
+ const magentoCustomerAddressInputTransform = (address) => ({
18
+ city: address.city,
19
+ country_code: address.country,
20
+ country_id: address.country,
21
+ default_billing: address.defaultBilling,
22
+ default_shipping: address.defaultShipping,
23
+ firstname: address.firstname,
24
+ lastname: address.lastname,
25
+ middlename: address.middlename,
26
+ postcode: address.postcode,
27
+ prefix: address.prefix,
28
+ region: { region_id: Number(address.region) },
29
+ street: [address.street, ...address.street2 ? [address.street2] : []],
30
+ suffix: address.suffix,
31
+ telephone: address.telephone
32
+ });
33
+ const magentoCustomerAddressTransform = (address) => ({
34
+ id: address.id ? String(address.id) : null,
35
+ street: address.street[0],
36
+ street2: address.street[1],
37
+ city: address.city,
38
+ region: String(address.region.region_id),
39
+ region_code: address.region.region_code,
40
+ country: address.country_code,
41
+ country_id: address.country_code,
42
+ postcode: address.postcode,
43
+ firstname: address.firstname,
44
+ lastname: address.lastname,
45
+ telephone: address.telephone,
46
+ email: address.email,
47
+ defaultBilling: address.default_billing,
48
+ defaultShipping: address.default_shipping
49
+ });
50
+ const magentoCustomerTransform = (customer) => ({
51
+ id: customer.email,
52
+ email: customer.email,
53
+ firstName: customer.firstname,
54
+ lastName: customer.lastname,
55
+ isSubscribed: customer.is_subscribed,
56
+ addresses: customer.addresses.map(magentoCustomerAddressTransform)
57
+ });
58
+ var MagentoCustomerGender;
59
+ (function(MagentoCustomerGender) {
60
+ MagentoCustomerGender[MagentoCustomerGender["MALE"] = 1] = "MALE";
61
+ MagentoCustomerGender[MagentoCustomerGender["FEMALE"] = 2] = "FEMALE";
62
+ })(MagentoCustomerGender || (MagentoCustomerGender = {}));
63
+ const magentoCustomerAddressFragment = gql`
64
+ fragment magentoCustomerAddress on CustomerAddress {
65
+ id
66
+ city
67
+ country_code
68
+ firstname
69
+ lastname
70
+ postcode
71
+ region {
72
+ region_code
73
+ region_id
74
+ }
75
+ street
76
+ telephone
77
+ company
78
+ default_billing
79
+ default_shipping
80
+ }
81
+ `;
82
+ const magentoCustomerFragment = gql`
83
+ fragment magentoCustomer on Customer {
84
+ email
85
+ firstname
86
+ lastname
87
+ is_subscribed
88
+ addresses {
89
+ ...magentoCustomerAddress
90
+ }
91
+ }
92
+ ${magentoCustomerAddressFragment}
93
+ `;
94
+ const MAGENTO_GET_CUSTOMER_QUERY_NAME = "MagentoGetCustomer";
95
+ const getCustomer = gql`
96
+ query ${MAGENTO_GET_CUSTOMER_QUERY_NAME} {
97
+ customer {
98
+ ...magentoCustomer
99
+ }
100
+ }
101
+ ${magentoCustomerFragment}
102
+ `;
103
+ const MAGENTO_GET_CUSTOMER_ADDRESSES_QUERY_NAME = "MagentoGetCustomerAddresses";
104
+ const getCustomerAddresses = gql`
105
+ query ${MAGENTO_GET_CUSTOMER_ADDRESSES_QUERY_NAME} {
106
+ customer {
107
+ addresses {
108
+ ...magentoCustomerAddress
109
+ }
110
+ }
111
+ }
112
+ ${magentoCustomerAddressFragment}
113
+ `;
114
+ const createCustomerAddress = gql`
115
+ mutation MagentoCreateCustomerAddress($input: CustomerAddressInput!) {
116
+ createCustomerAddress(input: $input) {
117
+ ...magentoCustomerAddress
118
+ }
119
+ }
120
+ ${magentoCustomerAddressFragment}
121
+ `;
122
+ const updateCustomerAddress = gql`
123
+ mutation MagentoUpdateCustomerAddress($id: Int!, $input: CustomerAddressInput!) {
124
+ updateCustomerAddress(id: $id, input: $input) {
125
+ ...magentoCustomerAddress
126
+ }
127
+ }
128
+ ${magentoCustomerAddressFragment}
129
+ `;
130
+ const deleteCustomerAddress = gql`
131
+ mutation MagentoDeleteCustomerAddress($id: Int!) {
132
+ deleteCustomerAddress(id: $id)
133
+ }
134
+ `;
135
+ const MAGENTO_UPDATE_CUSTOMER_QUERY_NAME = "MagentoUpdateCustomer";
136
+ const updateCustomer = gql`
137
+ mutation ${MAGENTO_UPDATE_CUSTOMER_QUERY_NAME}($customer: CustomerUpdateInput!) {
138
+ updateCustomerV2(input: $customer) {
139
+ customer {
140
+ ...magentoCustomer
141
+ }
142
+ }
143
+ }
144
+ ${magentoCustomerFragment}
145
+ `;
146
+ const MAGENTO_UPDATE_EMAIL_QUERY_NAME = "MagentoUpdateEmail";
147
+ const updateEmail = gql`
148
+ mutation ${MAGENTO_UPDATE_EMAIL_QUERY_NAME}($email: String!, $password: String!) {
149
+ updateCustomerEmail(email: $email, password: $password) {
150
+ customer {
151
+ ...magentoCustomer
152
+ }
153
+ }
154
+ }
155
+ ${magentoCustomerFragment}
156
+ `;
157
+ const MAGENTO_CHANGE_PASSWORD_QUERY_NAME = "MagentoChangePassword";
158
+ const changePassword = gql`
159
+ mutation ${MAGENTO_CHANGE_PASSWORD_QUERY_NAME}($old: String!, $new: String!) {
160
+ changeCustomerPassword(
161
+ currentPassword: $old
162
+ newPassword: $new
163
+ ) {
164
+ email
165
+ }
166
+ }
167
+ `;
168
+ const DaffCustomerMagentoErrorMessageRegexMap = {
169
+ [DaffCustomerDriverErrorCodes.DEFAULT_SHIPPING_ADDRESS_DELETION]: /is set as default shipping address and can not be deleted/,
170
+ [DaffCustomerDriverErrorCodes.DEFAULT_BILLING_ADDRESS_DELETION]: /is set as default billing address and can not be deleted/
171
+ };
172
+ function transformMagentoCartGraphQlError(error, requestPayload) {
173
+ for (const code in DaffCustomerMagentoErrorMessageRegexMap) if (error.message.search(DaffCustomerMagentoErrorMessageRegexMap[code]) > -1 && DaffCustomerDriverErrorMap[code]) return new DaffCustomerDriverErrorMap[code](error.message);
174
+ return daffTransformMagentoError(error, {});
175
+ }
176
+ function transformMagentoReviewsError(error, requestPayload) {
177
+ if (CombinedGraphQLErrors.is(error)) return transformMagentoCartGraphQlError(error.errors[0], requestPayload);
178
+ else return daffTransformMagentoError(error, {}) || new DaffCustomerInvalidAPIResponseError(error.message);
179
+ }
180
+ const validateGetCustomerResponse = (response) => {
181
+ if (response.data.customer?.email) return response;
182
+ else throw new DaffCustomerInvalidAPIResponseError("Get customer response does not contain a valid customer.");
183
+ };
184
+ const validateChangeEmailResponse = (response) => {
185
+ if (response.data.updateCustomerEmail.customer?.email) return response;
186
+ else throw new DaffCustomerInvalidAPIResponseError("Update email response does not contain a valid customer.");
187
+ };
188
+ const validateChangePasswordResponse = (response) => {
189
+ if (response.data.changeCustomerPassword?.email) return response;
190
+ else throw new DaffCustomerInvalidAPIResponseError("Change password response does not contain a valid customer.");
191
+ };
192
+ const validateGetCustomerAddressesResponse = (response) => {
193
+ if (response.data.customer?.addresses) return response;
194
+ else throw new DaffCustomerInvalidAPIResponseError("Get customer address response does not contain addresses.");
195
+ };
196
+ const validateCreateCustomerAddressResponse = (response) => {
197
+ if (response.data.createCustomerAddress?.id) return response;
198
+ else throw new DaffCustomerInvalidAPIResponseError("Create customer address response does not contain an address.");
199
+ };
200
+ const validateUpdateCustomerAddressResponse = (response) => {
201
+ if (response.data.updateCustomerAddress?.id) return response;
202
+ else throw new DaffCustomerInvalidAPIResponseError("Update customer address response does not contain an address.");
203
+ };
204
+ const validateDeleteCustomerAddressResponse = (response) => {
205
+ if (response.data.deleteCustomerAddress) return response;
206
+ else throw new DaffCustomerInvalidAPIResponseError("Delete customer address did not complete successfully.");
207
+ };
208
+ const validateUpdateCustomerResponse = (response) => {
209
+ if (response.data.updateCustomerV2.customer?.email) return response;
210
+ else throw new DaffCustomerInvalidAPIResponseError("Update customer response does not contain a valid customer.");
211
+ };
212
+ var DaffCustomerMagentoService = class DaffCustomerMagentoService {
213
+ constructor(apollo) {
214
+ this.apollo = apollo;
215
+ }
216
+ changeEmail(email, password) {
217
+ return this.apollo.mutate({
218
+ mutation: updateEmail,
219
+ variables: {
220
+ email,
221
+ password
222
+ }
223
+ }).pipe(map(validateChangeEmailResponse), map((result) => magentoCustomerTransform(result.data.updateCustomerEmail.customer)), catchError((err) => throwError(() => transformMagentoReviewsError(err))));
224
+ }
225
+ changePassword(oldPassword, newPassword) {
226
+ return this.apollo.mutate({
227
+ mutation: changePassword,
228
+ variables: {
229
+ old: oldPassword,
230
+ new: newPassword
231
+ }
232
+ }).pipe(map(validateChangePasswordResponse), map(() => void 0), catchError((err) => throwError(() => transformMagentoReviewsError(err))));
233
+ }
234
+ get() {
235
+ return this.apollo.query({ query: getCustomer }).pipe(map(validateGetCustomerResponse), map((result) => magentoCustomerTransform(result.data.customer)), catchError((err) => throwError(() => transformMagentoReviewsError(err))));
236
+ }
237
+ update(customer) {
238
+ return this.apollo.mutate({
239
+ mutation: updateCustomer,
240
+ variables: { customer: magentoCustomerInputTransform(customer) }
241
+ }).pipe(map(validateUpdateCustomerResponse), map((result) => magentoCustomerTransform(result.data.updateCustomerV2.customer)), catchError((err) => throwError(() => transformMagentoReviewsError(err))));
242
+ }
243
+ static {
244
+ this.ɵfac = i0.ɵɵngDeclareFactory({
245
+ minVersion: "12.0.0",
246
+ version: "22.2.4",
247
+ ngImport: i0,
248
+ type: DaffCustomerMagentoService,
249
+ deps: [{ token: i1.Apollo }],
250
+ target: i0.ɵɵFactoryTarget.Injectable
251
+ });
252
+ }
253
+ static {
254
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
255
+ minVersion: "12.0.0",
256
+ version: "22.2.4",
257
+ ngImport: i0,
258
+ type: DaffCustomerMagentoService,
259
+ providedIn: "root"
260
+ });
261
+ }
262
+ };
263
+ i0.ɵɵngDeclareClassMetadata({
264
+ minVersion: "12.0.0",
265
+ version: "22.2.4",
266
+ ngImport: i0,
267
+ type: DaffCustomerMagentoService,
268
+ decorators: [{
269
+ type: Injectable,
270
+ args: [{ providedIn: "root" }]
271
+ }],
272
+ ctorParameters: () => [{ type: i1.Apollo }]
273
+ });
274
+ var DaffCustomerMagentoAddressService = class DaffCustomerMagentoAddressService {
275
+ constructor(apollo, mutationQueue) {
276
+ this.apollo = apollo;
277
+ this.mutationQueue = mutationQueue;
278
+ }
279
+ add(address) {
280
+ return this.mutationQueue.mutate({
281
+ mutation: createCustomerAddress,
282
+ variables: { input: magentoCustomerAddressInputTransform(address) },
283
+ refetchQueries: [{ query: getCustomerAddresses }],
284
+ onQueryUpdated: () => true
285
+ }).pipe(map(validateCreateCustomerAddressResponse), switchMap(() => this.listAddresses()), map(({ data }) => data.customer.addresses.map(magentoCustomerAddressTransform)), catchError((err) => throwError(() => transformMagentoReviewsError(err))));
286
+ }
287
+ delete(addressId) {
288
+ return this.mutationQueue.mutate({
289
+ mutation: deleteCustomerAddress,
290
+ variables: { id: Number(addressId) },
291
+ refetchQueries: [{ query: getCustomerAddresses }],
292
+ onQueryUpdated: (query) => true
293
+ }).pipe(map(validateDeleteCustomerAddressResponse), switchMap(() => this.listAddresses()), map(({ data }) => data.customer.addresses.map(magentoCustomerAddressTransform)), catchError((err) => throwError(() => transformMagentoReviewsError(err))));
294
+ }
295
+ list() {
296
+ return this.listAddresses().pipe(map((response) => response.data.customer.addresses.map(magentoCustomerAddressTransform)), catchError((err) => throwError(() => transformMagentoReviewsError(err))));
297
+ }
298
+ get(addressId) {
299
+ return this.listAddresses().pipe(map(({ data }) => {
300
+ const address = data.customer.addresses.find(({ id }) => String(id) === addressId);
301
+ if (!address) throw new DaffCustomerAddressNotFoundError(`Could not find an address with ID: ${addressId}`);
302
+ return address;
303
+ }), map((address) => magentoCustomerAddressTransform(address)), catchError((err) => throwError(() => transformMagentoReviewsError(err))));
304
+ }
305
+ update(address) {
306
+ return this.mutationQueue.mutate({
307
+ mutation: updateCustomerAddress,
308
+ variables: {
309
+ id: Number(address.id),
310
+ input: magentoCustomerAddressInputTransform(address)
311
+ },
312
+ refetchQueries: [{ query: getCustomerAddresses }],
313
+ onQueryUpdated: (query) => true
314
+ }).pipe(map(validateUpdateCustomerAddressResponse), switchMap(() => this.listAddresses()), map(({ data }) => data.customer.addresses.map(magentoCustomerAddressTransform)), catchError((err) => throwError(() => transformMagentoReviewsError(err))));
315
+ }
316
+ listAddresses() {
317
+ return this.apollo.query({ query: getCustomerAddresses }).pipe(map(validateGetCustomerAddressesResponse), catchError((err) => throwError(() => transformMagentoReviewsError(err))));
318
+ }
319
+ static {
320
+ this.ɵfac = i0.ɵɵngDeclareFactory({
321
+ minVersion: "12.0.0",
322
+ version: "22.2.4",
323
+ ngImport: i0,
324
+ type: DaffCustomerMagentoAddressService,
325
+ deps: [{ token: i1.Apollo }, { token: i2.DaffQueuedApollo }],
326
+ target: i0.ɵɵFactoryTarget.Injectable
327
+ });
328
+ }
329
+ static {
330
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
331
+ minVersion: "12.0.0",
332
+ version: "22.2.4",
333
+ ngImport: i0,
334
+ type: DaffCustomerMagentoAddressService,
335
+ providedIn: "root"
336
+ });
337
+ }
338
+ };
339
+ i0.ɵɵngDeclareClassMetadata({
340
+ minVersion: "12.0.0",
341
+ version: "22.2.4",
342
+ ngImport: i0,
343
+ type: DaffCustomerMagentoAddressService,
344
+ decorators: [{
345
+ type: Injectable,
346
+ args: [{ providedIn: "root" }]
347
+ }],
348
+ ctorParameters: () => [{ type: i1.Apollo }, { type: i2.DaffQueuedApollo }]
349
+ });
350
+ const provideDaffCustomerMagentoDriver = () => makeEnvironmentProviders([provideDaffCustomerDriver(DaffCustomerMagentoService), provideDaffCustomerAddressDriver(DaffCustomerMagentoAddressService)]);
351
+ var DaffCustomerMagentoDriverModule = class DaffCustomerMagentoDriverModule {
352
+ static forRoot() {
353
+ return {
354
+ ngModule: DaffCustomerMagentoDriverModule,
355
+ providers: [provideDaffCustomerMagentoDriver()]
356
+ };
357
+ }
358
+ static {
359
+ this.ɵfac = i0.ɵɵngDeclareFactory({
360
+ minVersion: "12.0.0",
361
+ version: "22.2.4",
362
+ ngImport: i0,
363
+ type: DaffCustomerMagentoDriverModule,
364
+ deps: [],
365
+ target: i0.ɵɵFactoryTarget.NgModule
366
+ });
367
+ }
368
+ static {
369
+ this.ɵmod = i0.ɵɵngDeclareNgModule({
370
+ minVersion: "14.0.0",
371
+ version: "22.2.4",
372
+ ngImport: i0,
373
+ type: DaffCustomerMagentoDriverModule,
374
+ imports: [CommonModule]
375
+ });
376
+ }
377
+ static {
378
+ this.ɵinj = i0.ɵɵngDeclareInjector({
379
+ minVersion: "12.0.0",
380
+ version: "22.2.4",
381
+ ngImport: i0,
382
+ type: DaffCustomerMagentoDriverModule,
383
+ imports: [CommonModule]
384
+ });
385
+ }
386
+ };
387
+ i0.ɵɵngDeclareClassMetadata({
388
+ minVersion: "12.0.0",
389
+ version: "22.2.4",
390
+ ngImport: i0,
391
+ type: DaffCustomerMagentoDriverModule,
392
+ decorators: [{
393
+ type: NgModule,
394
+ args: [{ imports: [CommonModule] }]
395
+ }]
396
+ });
397
+ export { DaffCustomerMagentoDriverModule, DaffCustomerMagentoService, MAGENTO_CHANGE_PASSWORD_QUERY_NAME, MAGENTO_GET_CUSTOMER_ADDRESSES_QUERY_NAME, MAGENTO_GET_CUSTOMER_QUERY_NAME, MAGENTO_UPDATE_CUSTOMER_QUERY_NAME, MAGENTO_UPDATE_EMAIL_QUERY_NAME, MagentoCustomerGender, changePassword, createCustomerAddress, deleteCustomerAddress, getCustomer, getCustomerAddresses, magentoCustomerAddressFragment, magentoCustomerAddressInputTransform, magentoCustomerAddressTransform, magentoCustomerFragment, magentoCustomerInputTransform, magentoCustomerTransform, provideDaffCustomerMagentoDriver, transformMagentoReviewsError, updateCustomer, updateCustomerAddress, updateEmail, validateChangeEmailResponse, validateChangePasswordResponse, validateCreateCustomerAddressResponse, validateDeleteCustomerAddressResponse, validateGetCustomerAddressesResponse, validateGetCustomerResponse, validateUpdateCustomerAddressResponse, validateUpdateCustomerResponse };
398
+
399
+ //# sourceMappingURL=daffodil-customer-driver-magento-2.4.7.mjs.map