@daffodil/geography 0.94.1-rc.0 → 0.95.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/daffodil-geography-driver-in-memory.mjs +161 -121
- package/fesm2022/daffodil-geography-driver-in-memory.mjs.map +1 -1
- package/fesm2022/daffodil-geography-driver-magento-2.4.7.mjs +246 -0
- package/fesm2022/daffodil-geography-driver-magento-2.4.7.mjs.map +1 -0
- package/fesm2022/daffodil-geography-driver-magento-auto.mjs +7 -0
- package/fesm2022/daffodil-geography-driver-magento-auto.mjs.map +1 -0
- package/fesm2022/daffodil-geography-driver-testing.mjs +100 -61
- package/fesm2022/daffodil-geography-driver-testing.mjs.map +1 -1
- package/fesm2022/daffodil-geography-driver.mjs +18 -29
- package/fesm2022/daffodil-geography-driver.mjs.map +1 -1
- package/fesm2022/daffodil-geography-state-testing.mjs +98 -57
- package/fesm2022/daffodil-geography-state-testing.mjs.map +1 -1
- package/fesm2022/daffodil-geography-state.mjs +275 -275
- package/fesm2022/daffodil-geography-state.mjs.map +1 -1
- package/fesm2022/daffodil-geography-testing.mjs +190 -107
- package/fesm2022/daffodil-geography-testing.mjs.map +1 -1
- package/fesm2022/daffodil-geography.mjs +21 -43
- package/fesm2022/daffodil-geography.mjs.map +1 -1
- package/package.json +1 -1
- package/types/daffodil-geography-driver-in-memory.d.ts +51 -49
- package/types/daffodil-geography-driver-magento-2.4.7.d.ts +86 -0
- package/types/daffodil-geography-driver-magento-auto.d.ts +1 -0
- package/types/daffodil-geography-driver-testing.d.ts +28 -25
- package/types/daffodil-geography-driver.d.ts +22 -30
- package/types/daffodil-geography-state-testing.d.ts +33 -29
- package/types/daffodil-geography-state.d.ts +124 -139
- package/types/daffodil-geography-testing.d.ts +56 -63
- package/types/daffodil-geography.d.ts +37 -46
- package/fesm2022/daffodil-geography-driver-magento.mjs +0 -196
- package/fesm2022/daffodil-geography-driver-magento.mjs.map +0 -1
- package/types/daffodil-geography-driver-magento.d.ts +0 -95
|
@@ -1,122 +1,162 @@
|
|
|
1
|
-
import { CommonModule } from
|
|
2
|
-
import * as i0 from
|
|
3
|
-
import { Injectable, NgModule } from
|
|
4
|
-
import { DaffInMemoryDriverBase, provideDaffInMemoryBackends } from
|
|
5
|
-
import { DaffCountryNotFoundError, provideDaffGeographyDriver } from
|
|
6
|
-
import * as i1 from
|
|
7
|
-
import * as i2 from
|
|
8
|
-
import { STATUS } from
|
|
9
|
-
import { throwError } from
|
|
10
|
-
import { catchError, map } from
|
|
11
|
-
import * as i1
|
|
1
|
+
import { CommonModule } from "@angular/common";
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
import { Injectable, NgModule, makeEnvironmentProviders } from "@angular/core";
|
|
4
|
+
import { DaffInMemoryDriverBase, provideDaffInMemoryBackends } from "@daffodil/driver/in-memory";
|
|
5
|
+
import { DaffCountryNotFoundError, provideDaffGeographyDriver } from "@daffodil/geography/driver";
|
|
6
|
+
import * as i1$1 from "@angular/common/http";
|
|
7
|
+
import * as i2 from "angular-in-memory-web-api";
|
|
8
|
+
import { STATUS } from "angular-in-memory-web-api";
|
|
9
|
+
import { throwError } from "rxjs";
|
|
10
|
+
import { catchError, map } from "rxjs/operators";
|
|
11
|
+
import * as i1 from "@daffodil/geography/testing";
|
|
12
|
+
const DAFF_GEOGRAPHY_IN_MEMORY_COLLECTION_NAME = "countries";
|
|
13
|
+
var DaffInMemoryGeographyService = class DaffInMemoryGeographyService extends DaffInMemoryDriverBase {
|
|
14
|
+
constructor(http, config) {
|
|
15
|
+
super(config, DAFF_GEOGRAPHY_IN_MEMORY_COLLECTION_NAME);
|
|
16
|
+
this.http = http;
|
|
17
|
+
}
|
|
18
|
+
get(countryId) {
|
|
19
|
+
return this.http.get(`${this.url}/${countryId}`).pipe(catchError((error) => throwError(() => new DaffCountryNotFoundError("Country could not be found"))), map((result) => result));
|
|
20
|
+
}
|
|
21
|
+
list() {
|
|
22
|
+
return this.http.get(`${this.url}/`);
|
|
23
|
+
}
|
|
24
|
+
static {
|
|
25
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
26
|
+
minVersion: "12.0.0",
|
|
27
|
+
version: "22.2.4",
|
|
28
|
+
ngImport: i0,
|
|
29
|
+
type: DaffInMemoryGeographyService,
|
|
30
|
+
deps: [{ token: i1$1.HttpClient }, { token: i2.InMemoryBackendConfig }],
|
|
31
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
static {
|
|
35
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
36
|
+
minVersion: "12.0.0",
|
|
37
|
+
version: "22.2.4",
|
|
38
|
+
ngImport: i0,
|
|
39
|
+
type: DaffInMemoryGeographyService,
|
|
40
|
+
providedIn: "root"
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
45
|
+
minVersion: "12.0.0",
|
|
46
|
+
version: "22.2.4",
|
|
47
|
+
ngImport: i0,
|
|
48
|
+
type: DaffInMemoryGeographyService,
|
|
49
|
+
decorators: [{
|
|
50
|
+
type: Injectable,
|
|
51
|
+
args: [{ providedIn: "root" }]
|
|
52
|
+
}],
|
|
53
|
+
ctorParameters: () => [{ type: i1$1.HttpClient }, { type: i2.InMemoryBackendConfig }]
|
|
54
|
+
});
|
|
55
|
+
var DaffInMemoryBackendGeographyService = class DaffInMemoryBackendGeographyService {
|
|
56
|
+
constructor(countryFactory, subdivisionFactory) {
|
|
57
|
+
this.countryFactory = countryFactory;
|
|
58
|
+
this.subdivisionFactory = subdivisionFactory;
|
|
59
|
+
this.collectionName = DAFF_GEOGRAPHY_IN_MEMORY_COLLECTION_NAME;
|
|
60
|
+
this.countries = this.countryFactory.createMany(5);
|
|
61
|
+
this.countries.forEach((country) => country.subdivisions = this.subdivisionFactory.createMany(5));
|
|
62
|
+
}
|
|
63
|
+
createDb(reqInfo) {
|
|
64
|
+
if (reqInfo) {
|
|
65
|
+
const seedData = reqInfo.utils.getJsonBody(reqInfo.req).countries;
|
|
66
|
+
if (seedData) this.countries = seedData;
|
|
67
|
+
}
|
|
68
|
+
return { countries: this.countries };
|
|
69
|
+
}
|
|
70
|
+
get(reqInfo) {
|
|
71
|
+
return reqInfo.utils.createResponse$(() => ({
|
|
72
|
+
body: reqInfo.id ? this.getCountry(reqInfo) : this.listCountries(reqInfo),
|
|
73
|
+
status: STATUS.OK
|
|
74
|
+
}));
|
|
75
|
+
}
|
|
76
|
+
getCountry(reqInfo) {
|
|
77
|
+
return this.countries.find((country) => country.id === reqInfo.id);
|
|
78
|
+
}
|
|
79
|
+
listCountries(reqInfo) {
|
|
80
|
+
return this.countries;
|
|
81
|
+
}
|
|
82
|
+
static {
|
|
83
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
84
|
+
minVersion: "12.0.0",
|
|
85
|
+
version: "22.2.4",
|
|
86
|
+
ngImport: i0,
|
|
87
|
+
type: DaffInMemoryBackendGeographyService,
|
|
88
|
+
deps: [{ token: i1.DaffCountryFactory }, { token: i1.DaffSubdivisionFactory }],
|
|
89
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
static {
|
|
93
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
94
|
+
minVersion: "12.0.0",
|
|
95
|
+
version: "22.2.4",
|
|
96
|
+
ngImport: i0,
|
|
97
|
+
type: DaffInMemoryBackendGeographyService,
|
|
98
|
+
providedIn: "root"
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
103
|
+
minVersion: "12.0.0",
|
|
104
|
+
version: "22.2.4",
|
|
105
|
+
ngImport: i0,
|
|
106
|
+
type: DaffInMemoryBackendGeographyService,
|
|
107
|
+
decorators: [{
|
|
108
|
+
type: Injectable,
|
|
109
|
+
args: [{ providedIn: "root" }]
|
|
110
|
+
}],
|
|
111
|
+
ctorParameters: () => [{ type: i1.DaffCountryFactory }, { type: i1.DaffSubdivisionFactory }]
|
|
112
|
+
});
|
|
113
|
+
const provideDaffGeographyInMemoryDriver = () => makeEnvironmentProviders([provideDaffGeographyDriver(DaffInMemoryGeographyService), provideDaffInMemoryBackends(DaffInMemoryBackendGeographyService)]);
|
|
114
|
+
var DaffGeographyInMemoryDriverModule = class DaffGeographyInMemoryDriverModule {
|
|
115
|
+
static forRoot() {
|
|
116
|
+
return {
|
|
117
|
+
ngModule: DaffGeographyInMemoryDriverModule,
|
|
118
|
+
providers: [provideDaffGeographyInMemoryDriver()]
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
static {
|
|
122
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
123
|
+
minVersion: "12.0.0",
|
|
124
|
+
version: "22.2.4",
|
|
125
|
+
ngImport: i0,
|
|
126
|
+
type: DaffGeographyInMemoryDriverModule,
|
|
127
|
+
deps: [],
|
|
128
|
+
target: i0.ɵɵFactoryTarget.NgModule
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
static {
|
|
132
|
+
this.ɵmod = i0.ɵɵngDeclareNgModule({
|
|
133
|
+
minVersion: "14.0.0",
|
|
134
|
+
version: "22.2.4",
|
|
135
|
+
ngImport: i0,
|
|
136
|
+
type: DaffGeographyInMemoryDriverModule,
|
|
137
|
+
imports: [CommonModule]
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
static {
|
|
141
|
+
this.ɵinj = i0.ɵɵngDeclareInjector({
|
|
142
|
+
minVersion: "12.0.0",
|
|
143
|
+
version: "22.2.4",
|
|
144
|
+
ngImport: i0,
|
|
145
|
+
type: DaffGeographyInMemoryDriverModule,
|
|
146
|
+
imports: [CommonModule]
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
151
|
+
minVersion: "12.0.0",
|
|
152
|
+
version: "22.2.4",
|
|
153
|
+
ngImport: i0,
|
|
154
|
+
type: DaffGeographyInMemoryDriverModule,
|
|
155
|
+
decorators: [{
|
|
156
|
+
type: NgModule,
|
|
157
|
+
args: [{ imports: [CommonModule] }]
|
|
158
|
+
}]
|
|
159
|
+
});
|
|
160
|
+
export { DaffGeographyInMemoryDriverModule, DaffInMemoryBackendGeographyService, DaffInMemoryGeographyService, provideDaffGeographyInMemoryDriver };
|
|
12
161
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @inheritdoc
|
|
17
|
-
*/
|
|
18
|
-
class DaffInMemoryGeographyService extends DaffInMemoryDriverBase {
|
|
19
|
-
constructor(http, config) {
|
|
20
|
-
super(config, DAFF_GEOGRAPHY_IN_MEMORY_COLLECTION_NAME);
|
|
21
|
-
this.http = http;
|
|
22
|
-
}
|
|
23
|
-
get(countryId) {
|
|
24
|
-
return this.http.get(`${this.url}/${countryId}`).pipe(catchError((error) => throwError(() => new DaffCountryNotFoundError('Country could not be found'))), map(result => result));
|
|
25
|
-
}
|
|
26
|
-
list() {
|
|
27
|
-
return this.http.get(`${this.url}/`);
|
|
28
|
-
}
|
|
29
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffInMemoryGeographyService, deps: [{ token: i1.HttpClient }, { token: i2.InMemoryBackendConfig }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
30
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffInMemoryGeographyService, providedIn: 'root' }); }
|
|
31
|
-
}
|
|
32
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffInMemoryGeographyService, decorators: [{
|
|
33
|
-
type: Injectable,
|
|
34
|
-
args: [{
|
|
35
|
-
providedIn: 'root',
|
|
36
|
-
}]
|
|
37
|
-
}], ctorParameters: () => [{ type: i1.HttpClient }, { type: i2.InMemoryBackendConfig }] });
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* An in-memory service that stubs out the backend services for getting countries.
|
|
41
|
-
*
|
|
42
|
-
* @inheritdoc
|
|
43
|
-
*/
|
|
44
|
-
class DaffInMemoryBackendGeographyService {
|
|
45
|
-
constructor(countryFactory, subdivisionFactory) {
|
|
46
|
-
this.countryFactory = countryFactory;
|
|
47
|
-
this.subdivisionFactory = subdivisionFactory;
|
|
48
|
-
this.collectionName = DAFF_GEOGRAPHY_IN_MEMORY_COLLECTION_NAME;
|
|
49
|
-
this.countries = this.countryFactory.createMany(5);
|
|
50
|
-
this.countries.forEach(country => country.subdivisions = this.subdivisionFactory.createMany(5));
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Creates a fake database of countries for the geography inmemory backend service.
|
|
54
|
-
*
|
|
55
|
-
* @docs-private
|
|
56
|
-
* @returns A fake database of an array of countries
|
|
57
|
-
*/
|
|
58
|
-
createDb(reqInfo) {
|
|
59
|
-
if (reqInfo) {
|
|
60
|
-
const seedData = reqInfo.utils.getJsonBody(reqInfo.req).countries;
|
|
61
|
-
if (seedData) {
|
|
62
|
-
this.countries = seedData;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return {
|
|
66
|
-
countries: this.countries,
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Responds to GET requests.
|
|
71
|
-
*/
|
|
72
|
-
get(reqInfo) {
|
|
73
|
-
return reqInfo.utils.createResponse$(() => ({
|
|
74
|
-
body: reqInfo.id ? this.getCountry(reqInfo) : this.listCountries(reqInfo),
|
|
75
|
-
status: STATUS.OK,
|
|
76
|
-
}));
|
|
77
|
-
}
|
|
78
|
-
getCountry(reqInfo) {
|
|
79
|
-
return this.countries.find(country => country.id === reqInfo.id);
|
|
80
|
-
}
|
|
81
|
-
listCountries(reqInfo) {
|
|
82
|
-
return this.countries;
|
|
83
|
-
}
|
|
84
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffInMemoryBackendGeographyService, deps: [{ token: i1$1.DaffCountryFactory }, { token: i1$1.DaffSubdivisionFactory }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
85
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffInMemoryBackendGeographyService, providedIn: 'root' }); }
|
|
86
|
-
}
|
|
87
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffInMemoryBackendGeographyService, decorators: [{
|
|
88
|
-
type: Injectable,
|
|
89
|
-
args: [{
|
|
90
|
-
providedIn: 'root',
|
|
91
|
-
}]
|
|
92
|
-
}], ctorParameters: () => [{ type: i1$1.DaffCountryFactory }, { type: i1$1.DaffSubdivisionFactory }] });
|
|
93
|
-
|
|
94
|
-
class DaffGeographyInMemoryDriverModule {
|
|
95
|
-
static forRoot() {
|
|
96
|
-
return {
|
|
97
|
-
ngModule: DaffGeographyInMemoryDriverModule,
|
|
98
|
-
providers: [
|
|
99
|
-
provideDaffGeographyDriver(DaffInMemoryGeographyService),
|
|
100
|
-
provideDaffInMemoryBackends(DaffInMemoryBackendGeographyService),
|
|
101
|
-
],
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffGeographyInMemoryDriverModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
105
|
-
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.9", ngImport: i0, type: DaffGeographyInMemoryDriverModule, imports: [CommonModule] }); }
|
|
106
|
-
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffGeographyInMemoryDriverModule, imports: [CommonModule] }); }
|
|
107
|
-
}
|
|
108
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffGeographyInMemoryDriverModule, decorators: [{
|
|
109
|
-
type: NgModule,
|
|
110
|
-
args: [{
|
|
111
|
-
imports: [
|
|
112
|
-
CommonModule,
|
|
113
|
-
],
|
|
114
|
-
}]
|
|
115
|
-
}] });
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Generated bundle index. Do not edit.
|
|
119
|
-
*/
|
|
120
|
-
|
|
121
|
-
export { DaffGeographyInMemoryDriverModule, DaffInMemoryBackendGeographyService, DaffInMemoryGeographyService };
|
|
122
|
-
//# sourceMappingURL=daffodil-geography-driver-in-memory.mjs.map
|
|
162
|
+
//# sourceMappingURL=daffodil-geography-driver-in-memory.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"daffodil-geography-driver-in-memory.mjs","sources":["../../../libs/geography/driver/in-memory/src/collection-name.const.ts","../../../libs/geography/driver/in-memory/src/drivers/geography.service.ts","../../../libs/geography/driver/in-memory/src/backend/geography.service.ts","../../../libs/geography/driver/in-memory/src/drivers/
|
|
1
|
+
{"version":3,"file":"daffodil-geography-driver-in-memory.mjs","names":["i1"],"sources":["../../../libs/geography/driver/in-memory/src/collection-name.const.ts","../../../libs/geography/driver/in-memory/src/drivers/geography.service.ts","../../../libs/geography/driver/in-memory/src/backend/geography.service.ts","../../../libs/geography/driver/in-memory/src/drivers/provider.ts","../../../libs/geography/driver/in-memory/src/drivers/geography-driver.module.ts"],"sourcesContent":["export const DAFF_GEOGRAPHY_IN_MEMORY_COLLECTION_NAME = 'countries';\n","import { HttpClient } from '@angular/common/http';\nimport { Injectable } from '@angular/core';\nimport { InMemoryBackendConfig } from 'angular-in-memory-web-api';\nimport {\n Observable,\n throwError,\n} from 'rxjs';\nimport {\n catchError,\n map,\n} from 'rxjs/operators';\n\nimport { DaffInMemoryDriverBase } from '@daffodil/driver/in-memory';\nimport { DaffCountry } from '@daffodil/geography';\nimport {\n DaffGeographyServiceInterface,\n DaffCountryNotFoundError,\n} from '@daffodil/geography/driver';\n\nimport { DAFF_GEOGRAPHY_IN_MEMORY_COLLECTION_NAME } from '../collection-name.const';\n\n/**\n * @inheritdoc\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffInMemoryGeographyService extends DaffInMemoryDriverBase implements DaffGeographyServiceInterface<DaffCountry> {\n constructor(\n private http: HttpClient,\n config: InMemoryBackendConfig,\n ) {\n super(config, DAFF_GEOGRAPHY_IN_MEMORY_COLLECTION_NAME);\n }\n\n get(countryId: DaffCountry['id']): Observable<DaffCountry> {\n return this.http.get<DaffCountry>(`${this.url}/${countryId}`).pipe(\n catchError((error: Error) => throwError(() => new DaffCountryNotFoundError('Country could not be found'))),\n map(result => result),\n );\n }\n\n list(): Observable<DaffCountry[]> {\n return this.http.get<DaffCountry[]>(`${this.url}/`);\n }\n}\n","import { Injectable } from '@angular/core';\nimport {\n InMemoryDbService,\n RequestInfo,\n STATUS,\n} from 'angular-in-memory-web-api';\n\nimport { DaffInMemorySingleRouteableBackend } from '@daffodil/driver/in-memory';\nimport { DaffCountry } from '@daffodil/geography';\nimport {\n DaffCountryFactory,\n DaffSubdivisionFactory,\n} from '@daffodil/geography/testing';\n\nimport { DAFF_GEOGRAPHY_IN_MEMORY_COLLECTION_NAME } from '../collection-name.const';\n\n/**\n * An in-memory service that stubs out the backend services for getting countries.\n *\n * @inheritdoc\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffInMemoryBackendGeographyService implements InMemoryDbService, DaffInMemorySingleRouteableBackend {\n readonly collectionName = DAFF_GEOGRAPHY_IN_MEMORY_COLLECTION_NAME;\n\n countries: DaffCountry[];\n\n constructor(\n private countryFactory: DaffCountryFactory,\n private subdivisionFactory: DaffSubdivisionFactory,\n ) {\n this.countries = this.countryFactory.createMany(5);\n this.countries.forEach(country => country.subdivisions = this.subdivisionFactory.createMany(5));\n }\n\n /**\n * Creates a fake database of countries for the geography inmemory backend service.\n *\n * @docs-private\n * @returns A fake database of an array of countries\n */\n createDb(reqInfo: RequestInfo): any {\n if (reqInfo) {\n const seedData = reqInfo.utils.getJsonBody(reqInfo.req).countries;\n if (seedData) {\n this.countries = seedData;\n }\n }\n\n return {\n countries: this.countries,\n };\n }\n\n /**\n * Responds to GET requests.\n */\n get(reqInfo: RequestInfo): any {\n return reqInfo.utils.createResponse$(() => ({\n body: reqInfo.id ? this.getCountry(reqInfo) : this.listCountries(reqInfo),\n status: STATUS.OK,\n }));\n }\n\n private getCountry(reqInfo: RequestInfo) {\n return this.countries.find(country => country.id === reqInfo.id);\n }\n\n private listCountries(reqInfo: RequestInfo) {\n return this.countries;\n }\n}\n","import {\n EnvironmentProviders,\n makeEnvironmentProviders,\n} from '@angular/core';\n\nimport { provideDaffInMemoryBackends } from '@daffodil/driver/in-memory';\nimport { provideDaffGeographyDriver } from '@daffodil/geography/driver';\n\nimport { DaffInMemoryGeographyService } from './geography.service';\nimport { DaffInMemoryBackendGeographyService } from '../backend/geography.service';\n\n/**\n * Provides the in-memory implementation of the `@daffodil/geography/driver` interfaces.\n */\nexport const provideDaffGeographyInMemoryDriver = (): EnvironmentProviders => makeEnvironmentProviders([\n provideDaffGeographyDriver(DaffInMemoryGeographyService),\n provideDaffInMemoryBackends(DaffInMemoryBackendGeographyService),\n]);\n","import { CommonModule } from '@angular/common';\nimport {\n NgModule,\n ModuleWithProviders,\n} from '@angular/core';\n\nimport { provideDaffGeographyInMemoryDriver } from './provider';\n\n/**\n * @deprecated in favor of {@link provideDaffGeographyInMemoryDriver} 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 DaffGeographyInMemoryDriverModule {\n static forRoot(): ModuleWithProviders<D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A,UAAA;GAAA,MAAA;GAAiC,MAAA,CAAA;GAAA,QAAA,GAAA,gBAAA;EAAA,CAAA;CAAA;CAAjC;EAAA,KAAA,OAAA,GAAA,oBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;GAAiC,SAAA,CAH1C,YAAY;EAAA,CAAA;CAAA;CAGH;EAAA,KAAA,OAAA,GAAA,oBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;GAAiC,SAAA,CAH1C,YAAY;EAAA,CAAA;CAAA;;AAGH,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAiC,YAAA,CAAA;EAL7C,MAAA;EAAS,MAAA,CAAA,EACR,SAAS,CACP,YACD,EACF,CAAA"}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { Injectable, NgModule, makeEnvironmentProviders } from "@angular/core";
|
|
3
|
+
import * as i1 from "apollo-angular";
|
|
4
|
+
import { gql } from "apollo-angular";
|
|
5
|
+
import { throwError } from "rxjs";
|
|
6
|
+
import { catchError, map } from "rxjs/operators";
|
|
7
|
+
import { daffTransformMagentoError, provideDaffMagentoCacheableOperation } from "@daffodil/driver/magento/2.4.7";
|
|
8
|
+
import { DaffCountryNotFoundError, DaffGeographyInvalidAPIResponseError, provideDaffGeographyDriver } from "@daffodil/geography/driver";
|
|
9
|
+
import { CommonModule } from "@angular/common";
|
|
10
|
+
var DaffMagentoSubdivisionTransformer = class DaffMagentoSubdivisionTransformer {
|
|
11
|
+
transform(region) {
|
|
12
|
+
return region ? {
|
|
13
|
+
magento_region: region,
|
|
14
|
+
id: String(region.id),
|
|
15
|
+
name: region.name,
|
|
16
|
+
iso_3166_2: region.code
|
|
17
|
+
} : null;
|
|
18
|
+
}
|
|
19
|
+
static {
|
|
20
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
21
|
+
minVersion: "12.0.0",
|
|
22
|
+
version: "22.2.4",
|
|
23
|
+
ngImport: i0,
|
|
24
|
+
type: DaffMagentoSubdivisionTransformer,
|
|
25
|
+
deps: [],
|
|
26
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
static {
|
|
30
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
31
|
+
minVersion: "12.0.0",
|
|
32
|
+
version: "22.2.4",
|
|
33
|
+
ngImport: i0,
|
|
34
|
+
type: DaffMagentoSubdivisionTransformer,
|
|
35
|
+
providedIn: "root"
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
40
|
+
minVersion: "12.0.0",
|
|
41
|
+
version: "22.2.4",
|
|
42
|
+
ngImport: i0,
|
|
43
|
+
type: DaffMagentoSubdivisionTransformer,
|
|
44
|
+
decorators: [{
|
|
45
|
+
type: Injectable,
|
|
46
|
+
args: [{ providedIn: "root" }]
|
|
47
|
+
}]
|
|
48
|
+
});
|
|
49
|
+
var DaffMagentoCountryTransformer = class DaffMagentoCountryTransformer {
|
|
50
|
+
constructor(subdivisionTransformer) {
|
|
51
|
+
this.subdivisionTransformer = subdivisionTransformer;
|
|
52
|
+
}
|
|
53
|
+
transformSubdivisions(regions) {
|
|
54
|
+
return regions.map((region) => this.subdivisionTransformer.transform(region));
|
|
55
|
+
}
|
|
56
|
+
transform(country) {
|
|
57
|
+
return country ? {
|
|
58
|
+
magento_country: country,
|
|
59
|
+
subdivisions: this.transformSubdivisions(country.available_regions || []),
|
|
60
|
+
id: country.id,
|
|
61
|
+
name: country.full_name_locale,
|
|
62
|
+
name_en: country.full_name_english,
|
|
63
|
+
alpha2: country.two_letter_abbreviation,
|
|
64
|
+
alpha3: country.three_letter_abbreviation
|
|
65
|
+
} : null;
|
|
66
|
+
}
|
|
67
|
+
static {
|
|
68
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
69
|
+
minVersion: "12.0.0",
|
|
70
|
+
version: "22.2.4",
|
|
71
|
+
ngImport: i0,
|
|
72
|
+
type: DaffMagentoCountryTransformer,
|
|
73
|
+
deps: [{ token: DaffMagentoSubdivisionTransformer }],
|
|
74
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
static {
|
|
78
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
79
|
+
minVersion: "12.0.0",
|
|
80
|
+
version: "22.2.4",
|
|
81
|
+
ngImport: i0,
|
|
82
|
+
type: DaffMagentoCountryTransformer,
|
|
83
|
+
providedIn: "root"
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
88
|
+
minVersion: "12.0.0",
|
|
89
|
+
version: "22.2.4",
|
|
90
|
+
ngImport: i0,
|
|
91
|
+
type: DaffMagentoCountryTransformer,
|
|
92
|
+
decorators: [{
|
|
93
|
+
type: Injectable,
|
|
94
|
+
args: [{ providedIn: "root" }]
|
|
95
|
+
}],
|
|
96
|
+
ctorParameters: () => [{ type: DaffMagentoSubdivisionTransformer }]
|
|
97
|
+
});
|
|
98
|
+
const countryFragment = gql`
|
|
99
|
+
fragment country on Country {
|
|
100
|
+
id
|
|
101
|
+
full_name_english
|
|
102
|
+
full_name_locale
|
|
103
|
+
three_letter_abbreviation
|
|
104
|
+
two_letter_abbreviation
|
|
105
|
+
}
|
|
106
|
+
`;
|
|
107
|
+
const regionFragment = gql`
|
|
108
|
+
fragment region on Region {
|
|
109
|
+
code
|
|
110
|
+
id
|
|
111
|
+
name
|
|
112
|
+
}
|
|
113
|
+
`;
|
|
114
|
+
const MAGENTO_GET_COUNTRIES_QUERY_NAME = "MagentoGetCountries";
|
|
115
|
+
const getCountries = gql`
|
|
116
|
+
query ${MAGENTO_GET_COUNTRIES_QUERY_NAME} {
|
|
117
|
+
countries {
|
|
118
|
+
...country
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
${countryFragment}
|
|
122
|
+
`;
|
|
123
|
+
const MAGENTO_GET_COUNTRY_QUERY_NAME = "MagentoGetCountry";
|
|
124
|
+
const getCountry = gql`
|
|
125
|
+
query ${MAGENTO_GET_COUNTRY_QUERY_NAME}($countryId: String!) {
|
|
126
|
+
country(id: $countryId) {
|
|
127
|
+
...country
|
|
128
|
+
available_regions {
|
|
129
|
+
...region
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
${countryFragment}
|
|
134
|
+
${regionFragment}
|
|
135
|
+
`;
|
|
136
|
+
var MagentoGeographyGraphQlErrorCode;
|
|
137
|
+
(function(MagentoGeographyGraphQlErrorCode) {
|
|
138
|
+
MagentoGeographyGraphQlErrorCode["COUNTRY_NOT_FOUND"] = "graphql-no-such-entity";
|
|
139
|
+
})(MagentoGeographyGraphQlErrorCode || (MagentoGeographyGraphQlErrorCode = {}));
|
|
140
|
+
const DaffGeographyMagentoErrorMap = { [MagentoGeographyGraphQlErrorCode.COUNTRY_NOT_FOUND]: DaffCountryNotFoundError };
|
|
141
|
+
function transformMagentoGeographyError(error) {
|
|
142
|
+
return daffTransformMagentoError(error, DaffGeographyMagentoErrorMap);
|
|
143
|
+
}
|
|
144
|
+
const validateGetCountriesResponse = (response) => {
|
|
145
|
+
if (response.data.countries) return response;
|
|
146
|
+
else throw new DaffGeographyInvalidAPIResponseError("Get countries response does not contain a valid list of countries.");
|
|
147
|
+
};
|
|
148
|
+
var DaffGeographyMagentoService = class DaffGeographyMagentoService {
|
|
149
|
+
constructor(apollo, countryTransformer) {
|
|
150
|
+
this.apollo = apollo;
|
|
151
|
+
this.countryTransformer = countryTransformer;
|
|
152
|
+
}
|
|
153
|
+
list() {
|
|
154
|
+
return this.apollo.query({ query: getCountries }).pipe(map(validateGetCountriesResponse), map((result) => result.data.countries.map((country) => this.countryTransformer.transform(country))), catchError((err) => throwError(() => transformMagentoGeographyError(err))));
|
|
155
|
+
}
|
|
156
|
+
get(countryId) {
|
|
157
|
+
return this.apollo.query({
|
|
158
|
+
query: getCountry,
|
|
159
|
+
variables: { countryId }
|
|
160
|
+
}).pipe(map((result) => this.countryTransformer.transform(result.data.country)), catchError((err) => throwError(() => transformMagentoGeographyError(err))));
|
|
161
|
+
}
|
|
162
|
+
static {
|
|
163
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
164
|
+
minVersion: "12.0.0",
|
|
165
|
+
version: "22.2.4",
|
|
166
|
+
ngImport: i0,
|
|
167
|
+
type: DaffGeographyMagentoService,
|
|
168
|
+
deps: [{ token: i1.Apollo }, { token: DaffMagentoCountryTransformer }],
|
|
169
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
static {
|
|
173
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
174
|
+
minVersion: "12.0.0",
|
|
175
|
+
version: "22.2.4",
|
|
176
|
+
ngImport: i0,
|
|
177
|
+
type: DaffGeographyMagentoService,
|
|
178
|
+
providedIn: "root"
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
183
|
+
minVersion: "12.0.0",
|
|
184
|
+
version: "22.2.4",
|
|
185
|
+
ngImport: i0,
|
|
186
|
+
type: DaffGeographyMagentoService,
|
|
187
|
+
decorators: [{
|
|
188
|
+
type: Injectable,
|
|
189
|
+
args: [{ providedIn: "root" }]
|
|
190
|
+
}],
|
|
191
|
+
ctorParameters: () => [{ type: i1.Apollo }, { type: DaffMagentoCountryTransformer }]
|
|
192
|
+
});
|
|
193
|
+
const provideDaffGeographyMagentoDriver = () => makeEnvironmentProviders([
|
|
194
|
+
provideDaffGeographyDriver(DaffGeographyMagentoService),
|
|
195
|
+
provideDaffMagentoCacheableOperation(MAGENTO_GET_COUNTRY_QUERY_NAME),
|
|
196
|
+
provideDaffMagentoCacheableOperation(MAGENTO_GET_COUNTRIES_QUERY_NAME)
|
|
197
|
+
]);
|
|
198
|
+
var DaffGeographyMagentoDriverModule = class DaffGeographyMagentoDriverModule {
|
|
199
|
+
static forRoot() {
|
|
200
|
+
return {
|
|
201
|
+
ngModule: DaffGeographyMagentoDriverModule,
|
|
202
|
+
providers: [provideDaffGeographyMagentoDriver()]
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
static {
|
|
206
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
207
|
+
minVersion: "12.0.0",
|
|
208
|
+
version: "22.2.4",
|
|
209
|
+
ngImport: i0,
|
|
210
|
+
type: DaffGeographyMagentoDriverModule,
|
|
211
|
+
deps: [],
|
|
212
|
+
target: i0.ɵɵFactoryTarget.NgModule
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
static {
|
|
216
|
+
this.ɵmod = i0.ɵɵngDeclareNgModule({
|
|
217
|
+
minVersion: "14.0.0",
|
|
218
|
+
version: "22.2.4",
|
|
219
|
+
ngImport: i0,
|
|
220
|
+
type: DaffGeographyMagentoDriverModule,
|
|
221
|
+
imports: [CommonModule]
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
static {
|
|
225
|
+
this.ɵinj = i0.ɵɵngDeclareInjector({
|
|
226
|
+
minVersion: "12.0.0",
|
|
227
|
+
version: "22.2.4",
|
|
228
|
+
ngImport: i0,
|
|
229
|
+
type: DaffGeographyMagentoDriverModule,
|
|
230
|
+
imports: [CommonModule]
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
235
|
+
minVersion: "12.0.0",
|
|
236
|
+
version: "22.2.4",
|
|
237
|
+
ngImport: i0,
|
|
238
|
+
type: DaffGeographyMagentoDriverModule,
|
|
239
|
+
decorators: [{
|
|
240
|
+
type: NgModule,
|
|
241
|
+
args: [{ imports: [CommonModule] }]
|
|
242
|
+
}]
|
|
243
|
+
});
|
|
244
|
+
export { DaffGeographyMagentoDriverModule, DaffGeographyMagentoService, DaffMagentoCountryTransformer, DaffMagentoSubdivisionTransformer, MAGENTO_GET_COUNTRIES_QUERY_NAME, MAGENTO_GET_COUNTRY_QUERY_NAME, countryFragment, getCountries, getCountry, provideDaffGeographyMagentoDriver, regionFragment };
|
|
245
|
+
|
|
246
|
+
//# sourceMappingURL=daffodil-geography-driver-magento-2.4.7.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daffodil-geography-driver-magento-2.4.7.mjs","names":["i1.DaffMagentoSubdivisionTransformer","i2.DaffMagentoCountryTransformer"],"sources":["../../../libs/geography/driver/magento/2.4.7/src/transforms/responses/subdivision.service.ts","../../../libs/geography/driver/magento/2.4.7/src/transforms/responses/country.service.ts","../../../libs/geography/driver/magento/2.4.7/src/queries/fragments/country.ts","../../../libs/geography/driver/magento/2.4.7/src/queries/fragments/region.ts","../../../libs/geography/driver/magento/2.4.7/src/queries/get-countries.ts","../../../libs/geography/driver/magento/2.4.7/src/queries/get-country.ts","../../../libs/geography/driver/magento/2.4.7/src/errors/codes.ts","../../../libs/geography/driver/magento/2.4.7/src/errors/map.ts","../../../libs/geography/driver/magento/2.4.7/src/errors/transform.ts","../../../libs/geography/driver/magento/2.4.7/src/validators/get-countries.ts","../../../libs/geography/driver/magento/2.4.7/src/geography.service.ts","../../../libs/geography/driver/magento/2.4.7/src/provider.ts","../../../libs/geography/driver/magento/2.4.7/src/geography-driver.module.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\n\nimport { DaffSubdivision } from '@daffodil/geography';\n\nimport { MagentoRegion } from '../../models/responses/region';\n\n/**\n * Transforms magento carts into an object usable by daffodil.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffMagentoSubdivisionTransformer {\n /**\n * Transforms the MagentoRegion from the magento region query into a DaffSubdivision.\n */\n transform(region: MagentoRegion): DaffSubdivision {\n return region ? {\n ...{ magento_region: region },\n\n id: String(region.id),\n name: region.name,\n iso_3166_2: region.code,\n } : null;\n }\n}\n","import { Injectable } from '@angular/core';\n\nimport { DaffCountry } from '@daffodil/geography';\n\nimport { DaffMagentoSubdivisionTransformer } from './subdivision.service';\nimport { MagentoCountry } from '../../models/responses/country';\n\n/**\n * Transforms magento carts into an object usable by daffodil.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffMagentoCountryTransformer {\n constructor(public subdivisionTransformer: DaffMagentoSubdivisionTransformer) {}\n\n private transformSubdivisions(regions: MagentoCountry['available_regions']): DaffCountry['subdivisions'] {\n return regions.map(region => this.subdivisionTransformer.transform(region));\n }\n\n /**\n * Transforms the MagentoCountry from the magento country query into a DaffCountry.\n */\n transform(country: MagentoCountry): DaffCountry {\n return country ? {\n ...{ magento_country: country },\n\n subdivisions: this.transformSubdivisions(country.available_regions || []),\n\n id: country.id,\n name: country.full_name_locale,\n name_en: country.full_name_english,\n alpha2: country.two_letter_abbreviation,\n alpha3: country.three_letter_abbreviation,\n } : null;\n }\n}\n","import { gql } from 'apollo-angular';\n\n\nexport const countryFragment = gql`\n fragment country on Country {\n id\n full_name_english\n full_name_locale\n three_letter_abbreviation\n two_letter_abbreviation\n }\n`;\n","import { gql } from 'apollo-angular';\n\n\nexport const regionFragment = gql`\n fragment region on Region {\n code\n id\n name\n }\n`;\n","import { gql } from 'apollo-angular';\n\nimport { countryFragment } from './fragments/public_api';\n\nexport const MAGENTO_GET_COUNTRIES_QUERY_NAME = 'MagentoGetCountries';\n\nexport const getCountries = gql`\n query ${MAGENTO_GET_COUNTRIES_QUERY_NAME} {\n countries {\n ...country\n }\n }\n ${countryFragment}\n`;\n","import { gql } from 'apollo-angular';\n\nimport {\n countryFragment,\n regionFragment,\n} from './fragments/public_api';\n\nexport const MAGENTO_GET_COUNTRY_QUERY_NAME = 'MagentoGetCountry';\n\nexport const getCountry = gql`\n query ${MAGENTO_GET_COUNTRY_QUERY_NAME}($countryId: String!) {\n country(id: $countryId) {\n ...country\n available_regions {\n ...region\n }\n }\n }\n ${countryFragment}\n ${regionFragment}\n`;\n","export enum MagentoGeographyGraphQlErrorCode {\n COUNTRY_NOT_FOUND = 'graphql-no-such-entity',\n}\n","import { DaffErrorCodeMap } from '@daffodil/core';\nimport { DaffCountryNotFoundError } from '@daffodil/geography/driver';\n\nimport { MagentoGeographyGraphQlErrorCode } from './codes';\n\nexport const DaffGeographyMagentoErrorMap: DaffErrorCodeMap = {\n [MagentoGeographyGraphQlErrorCode.COUNTRY_NOT_FOUND]: DaffCountryNotFoundError,\n};\n","import { daffTransformMagentoError } from '@daffodil/driver/magento/2.4.7';\n\nimport { DaffGeographyMagentoErrorMap } from './map';\n\nexport function transformMagentoGeographyError(error: any) {\n return daffTransformMagentoError(error, DaffGeographyMagentoErrorMap);\n}\n","import { Apollo } from 'apollo-angular';\n\nimport { DaffGeographyInvalidAPIResponseError } from '@daffodil/geography/driver';\n\nimport { MagentoGetCountriesResponse } from '../queries/public_api';\n\nexport const validateGetCountriesResponse = (response: Apollo.QueryResult<MagentoGetCountriesResponse>) => {\n if (response.data.countries) {\n return response;\n } else {\n throw new DaffGeographyInvalidAPIResponseError('Get countries response does not contain a valid list of countries.');\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 { DaffCountry } from '@daffodil/geography';\nimport { DaffGeographyServiceInterface } from '@daffodil/geography/driver';\n\nimport { transformMagentoGeographyError } from './errors/transform';\nimport { getCountry } from './queries/get-country';\nimport {\n getCountries,\n MagentoGetCountriesResponse,\n} from './queries/public_api';\nimport { MagentoGetCountryResponse } from './queries/responses/get-country';\nimport { DaffMagentoCountryTransformer } from './transforms/responses/country.service';\nimport { validateGetCountriesResponse } from './validators/public_api';\n\n/**\n * A service for making Magento GraphQL queries for carts.\n *\n * @inheritdoc\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffGeographyMagentoService implements DaffGeographyServiceInterface<DaffCountry> {\n constructor(\n private apollo: Apollo,\n public countryTransformer: DaffMagentoCountryTransformer,\n ) {}\n\n list(): Observable<DaffCountry[]> {\n return this.apollo.query<MagentoGetCountriesResponse>({\n query: getCountries,\n }).pipe(\n map(validateGetCountriesResponse),\n map(result => result.data.countries.map(country => this.countryTransformer.transform(country))),\n catchError(err => throwError(() => transformMagentoGeographyError(err))),\n );\n }\n\n get(countryId: DaffCountry['id']): Observable<DaffCountry> {\n return this.apollo.query<MagentoGetCountryResponse>({\n query: getCountry,\n variables: {\n countryId,\n },\n }).pipe(\n map(result => this.countryTransformer.transform(result.data.country)),\n catchError(err => throwError(() => transformMagentoGeographyError(err))),\n );\n }\n}\n","import {\n EnvironmentProviders,\n makeEnvironmentProviders,\n} from '@angular/core';\n\nimport { provideDaffMagentoCacheableOperation } from '@daffodil/driver/magento/2.4.7';\nimport { provideDaffGeographyDriver } from '@daffodil/geography/driver';\n\nimport { DaffGeographyMagentoService } from './geography.service';\nimport {\n MAGENTO_GET_COUNTRIES_QUERY_NAME,\n MAGENTO_GET_COUNTRY_QUERY_NAME,\n} from './queries/public_api';\n\n/**\n * Provides the Magento implementation of the `@daffodil/geography/driver` interfaces.\n */\nexport const provideDaffGeographyMagentoDriver = (): EnvironmentProviders => makeEnvironmentProviders([\n provideDaffGeographyDriver(DaffGeographyMagentoService),\n provideDaffMagentoCacheableOperation(MAGENTO_GET_COUNTRY_QUERY_NAME),\n provideDaffMagentoCacheableOperation(MAGENTO_GET_COUNTRIES_QUERY_NAME),\n]);\n","import { CommonModule } from '@angular/common';\nimport {\n NgModule,\n ModuleWithProviders,\n} from '@angular/core';\n\nimport { provideDaffGeographyMagentoDriver } from './provider';\n\n/**\n * @deprecated in favor of {@link provideDaffGeographyMagentoDriver} 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 DaffGeographyMagentoDriverModule {\n static forRoot(): ModuleWithProviders<DaffGeographyMagentoDriverMod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AA,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,7 @@
|
|
|
1
|
+
import { isDevMode } from "@angular/core";
|
|
2
|
+
import { daffAutoDriverErrorMessage } from "@daffodil/driver";
|
|
3
|
+
const MESSAGE = daffAutoDriverErrorMessage("geography");
|
|
4
|
+
if (isDevMode()) throw new Error(MESSAGE);
|
|
5
|
+
else console.error(MESSAGE);
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=daffodil-geography-driver-magento-auto.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daffodil-geography-driver-magento-auto.mjs","names":[],"sources":["../../../libs/geography/driver/magento/auto/src/index.ts"],"sourcesContent":["import { isDevMode } from '@angular/core';\n\nimport { daffAutoDriverErrorMessage } from '@daffodil/driver';\n\nconst MESSAGE = daffAutoDriverErrorMessage('geography');\n\nif (isDevMode()) {\n throw new Error(MESSAGE);\n} else {\n console.error(MESSAGE);\n}\n\nexport {};\n"],"mappings":";;AAIA,MAAM,UAAU,2BAA2B,WAAW;AAEtD,IAAI,UAAS,GACX,MAAM,IAAI,MAAM,OAAO;KAEvB,QAAQ,MAAM,OAAO"}
|