@daffodil/product 0.89.0 → 0.91.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/driver/in-memory/index.d.ts +9 -9
- package/fesm2022/daffodil-product-driver-in-memory.mjs +34 -52
- package/fesm2022/daffodil-product-driver-in-memory.mjs.map +1 -1
- package/fesm2022/daffodil-product-driver-shopify.mjs +1 -1
- package/fesm2022/daffodil-product-driver-shopify.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as rxjs from 'rxjs';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { InMemoryDbService, RequestInfoUtilities, ParsedRequestUrl, RequestInfo, InMemoryBackendConfigArgs } from 'angular-in-memory-web-api';
|
|
2
4
|
import { DaffInMemorySingleRouteableBackend, DaffInMemoryDriverBase } from '@daffodil/driver/in-memory';
|
|
3
5
|
import { DaffProduct } from '@daffodil/product';
|
|
4
6
|
import * as i2 from '@daffodil/product/testing';
|
|
5
|
-
import { DaffProductExtensionFactory
|
|
7
|
+
import { DaffProductExtensionFactory } from '@daffodil/product/testing';
|
|
6
8
|
import * as i0 from '@angular/core';
|
|
7
|
-
import { ModuleWithProviders, Provider } from '@angular/core';
|
|
9
|
+
import { ModuleWithProviders, Provider, EnvironmentProviders } from '@angular/core';
|
|
8
10
|
import { HttpClient } from '@angular/common/http';
|
|
9
|
-
import { Observable } from 'rxjs';
|
|
10
11
|
import { DaffProductDriverResponse, DaffProductServiceInterface } from '@daffodil/product/driver';
|
|
11
12
|
import * as i1 from '@angular/common';
|
|
12
13
|
|
|
@@ -18,15 +19,14 @@ import * as i1 from '@angular/common';
|
|
|
18
19
|
* @Param products: An array of Products
|
|
19
20
|
*/
|
|
20
21
|
declare class DaffInMemoryBackendProductService implements InMemoryDbService, DaffInMemorySingleRouteableBackend {
|
|
21
|
-
private productFactory;
|
|
22
|
-
private productImageFactory;
|
|
23
22
|
readonly collectionName = "products";
|
|
24
23
|
protected _products: DaffProduct[];
|
|
25
24
|
/**
|
|
26
25
|
* The collection of products in the backend.
|
|
27
26
|
*/
|
|
28
27
|
get products(): DaffProduct[];
|
|
29
|
-
|
|
28
|
+
productFactory: DaffProductExtensionFactory<any>;
|
|
29
|
+
constructor();
|
|
30
30
|
/**
|
|
31
31
|
* Automatically called as part of the InMemoryDbService to parse incoming urls to match the InMemory backend urls.
|
|
32
32
|
*
|
|
@@ -49,7 +49,7 @@ declare class DaffInMemoryBackendProductService implements InMemoryDbService, Da
|
|
|
49
49
|
* @param reqInfo request object
|
|
50
50
|
* @returns An http response object
|
|
51
51
|
*/
|
|
52
|
-
get(reqInfo:
|
|
52
|
+
get(reqInfo: RequestInfo): rxjs.Observable<any>;
|
|
53
53
|
static ɵfac: i0.ɵɵFactoryDeclaration<DaffInMemoryBackendProductService, never>;
|
|
54
54
|
static ɵprov: i0.ɵɵInjectableDeclaration<DaffInMemoryBackendProductService>;
|
|
55
55
|
}
|
|
@@ -88,7 +88,7 @@ declare class DaffProductInMemoryDriverModule {
|
|
|
88
88
|
/**
|
|
89
89
|
* Provides the Daffodil product in-memory driver and its dependencies.
|
|
90
90
|
*/
|
|
91
|
-
declare const provideDaffProductInMemoryDriver: () => Provider
|
|
91
|
+
declare const provideDaffProductInMemoryDriver: () => Array<Provider | EnvironmentProviders>;
|
|
92
92
|
|
|
93
93
|
declare const DAFF_PRODUCT_IN_MEMORY_EXTRA_PRODUCT_RESPONSE_TRANSFORMS: i0.InjectionToken<DaffInMemoryProductResponseExtraTransform[]>;
|
|
94
94
|
declare const provideDaffProductInMemoryExtraProductResponseTransforms: <R extends DaffInMemoryProductResponseExtraTransform = DaffInMemoryProductResponseExtraTransform>(...values: R[]) => Array<i0.ValueProvider>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import {
|
|
2
|
+
import { inject, Injectable, Inject, NgModule } from '@angular/core';
|
|
3
3
|
import * as i2 from 'angular-in-memory-web-api';
|
|
4
4
|
import { STATUS, InMemoryBackendConfig } from 'angular-in-memory-web-api';
|
|
5
|
-
import
|
|
6
|
-
import { provideDaffProductExtraFactoryTypes, DaffDefaultProductFactory, DaffProductTestingModule } from '@daffodil/product/testing';
|
|
7
|
-
import * as i1
|
|
5
|
+
import { daffUriTruncateLeadingSlash } from '@daffodil/core/routing';
|
|
6
|
+
import { DaffProductExtensionFactory, provideDaffProductExtraFactoryTypes, DaffDefaultProductFactory, DaffProductTestingModule } from '@daffodil/product/testing';
|
|
7
|
+
import * as i1 from '@angular/common/http';
|
|
8
8
|
import { map } from 'rxjs/operators';
|
|
9
|
-
import { DaffInMemoryDriverBase, provideDaffInMemoryBackends } from '@daffodil/driver/in-memory';
|
|
9
|
+
import { DaffInMemoryDriverBase, provideDaffInMemoryBackends, provideDaffInMemoryRoutableObjects } from '@daffodil/driver/in-memory';
|
|
10
10
|
import { createMultiInjectionToken, createSingleInjectionToken } from '@daffodil/core';
|
|
11
11
|
import { CommonModule } from '@angular/common';
|
|
12
12
|
import { provideDaffProductDriver } from '@daffodil/product/driver';
|
|
@@ -28,48 +28,11 @@ class DaffInMemoryBackendProductService {
|
|
|
28
28
|
return this._products;
|
|
29
29
|
}
|
|
30
30
|
;
|
|
31
|
-
constructor(
|
|
32
|
-
this.productFactory = productFactory;
|
|
33
|
-
this.productImageFactory = productImageFactory;
|
|
31
|
+
constructor() {
|
|
34
32
|
this.collectionName = DAFF_PRODUCT_IN_MEMORY_COLLECTION_NAME;
|
|
35
33
|
this._products = [];
|
|
36
|
-
this.
|
|
37
|
-
|
|
38
|
-
'1002',
|
|
39
|
-
'1003',
|
|
40
|
-
'1004',
|
|
41
|
-
'1005',
|
|
42
|
-
'1006',
|
|
43
|
-
'1007',
|
|
44
|
-
'1008',
|
|
45
|
-
'1009',
|
|
46
|
-
'1010',
|
|
47
|
-
'1011',
|
|
48
|
-
'1012',
|
|
49
|
-
'1013',
|
|
50
|
-
'1014',
|
|
51
|
-
'1015',
|
|
52
|
-
'1016',
|
|
53
|
-
'1017',
|
|
54
|
-
'1018',
|
|
55
|
-
'1019',
|
|
56
|
-
'1020',
|
|
57
|
-
'1021',
|
|
58
|
-
'1022',
|
|
59
|
-
'1023',
|
|
60
|
-
'1024',
|
|
61
|
-
'1025',
|
|
62
|
-
'1026',
|
|
63
|
-
'1027',
|
|
64
|
-
'1028',
|
|
65
|
-
'1029',
|
|
66
|
-
'1030',
|
|
67
|
-
'1031',
|
|
68
|
-
'1032',
|
|
69
|
-
'1033',
|
|
70
|
-
'1034',
|
|
71
|
-
'1035',
|
|
72
|
-
].map(id => this.productFactory.create({ id, url: `/${id}` }));
|
|
34
|
+
this.productFactory = inject(DaffProductExtensionFactory);
|
|
35
|
+
this._products = this.productFactory.createMany(35);
|
|
73
36
|
}
|
|
74
37
|
/**
|
|
75
38
|
* Automatically called as part of the InMemoryDbService to parse incoming urls to match the InMemory backend urls.
|
|
@@ -100,15 +63,19 @@ class DaffInMemoryBackendProductService {
|
|
|
100
63
|
* @returns An http response object
|
|
101
64
|
*/
|
|
102
65
|
get(reqInfo) {
|
|
103
|
-
if (reqInfo.id
|
|
66
|
+
if (reqInfo.id?.includes('.html')) {
|
|
67
|
+
const product = this._products.find((p) => daffUriTruncateLeadingSlash(p.url) === reqInfo.id);
|
|
68
|
+
if (!product) {
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
104
71
|
return reqInfo.utils.createResponse$(() => ({
|
|
105
|
-
body:
|
|
72
|
+
body: product,
|
|
106
73
|
status: STATUS.OK,
|
|
107
74
|
}));
|
|
108
75
|
}
|
|
109
76
|
return undefined;
|
|
110
77
|
}
|
|
111
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.1", ngImport: i0, type: DaffInMemoryBackendProductService, deps: [
|
|
78
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.1", ngImport: i0, type: DaffInMemoryBackendProductService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
112
79
|
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.1", ngImport: i0, type: DaffInMemoryBackendProductService, providedIn: 'root' }); }
|
|
113
80
|
}
|
|
114
81
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.1", ngImport: i0, type: DaffInMemoryBackendProductService, decorators: [{
|
|
@@ -116,7 +83,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.1", ngImpor
|
|
|
116
83
|
args: [{
|
|
117
84
|
providedIn: 'root',
|
|
118
85
|
}]
|
|
119
|
-
}], ctorParameters: () => [
|
|
86
|
+
}], ctorParameters: () => [] });
|
|
120
87
|
|
|
121
88
|
const {
|
|
122
89
|
/**
|
|
@@ -177,14 +144,14 @@ class DaffInMemoryProductService extends DaffInMemoryDriverBase {
|
|
|
177
144
|
return this.http.get(`${this.url}/${productId}`).pipe(map(this.transform));
|
|
178
145
|
}
|
|
179
146
|
getByUrl(url) {
|
|
180
|
-
return this.http.get(`${this.url}
|
|
147
|
+
return this.http.get(`${this.url}/${daffUriTruncateLeadingSlash(url)}`).pipe(map(this.transform));
|
|
181
148
|
}
|
|
182
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.1", ngImport: i0, type: DaffInMemoryProductService, deps: [{ token: i1
|
|
149
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.1", ngImport: i0, type: DaffInMemoryProductService, deps: [{ token: i1.HttpClient }, { token: InMemoryBackendConfig }, { token: DAFF_PRODUCT_IN_MEMORY_PRODUCT_RESPONSE_TRANSFORM }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
183
150
|
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.1", ngImport: i0, type: DaffInMemoryProductService }); }
|
|
184
151
|
}
|
|
185
152
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.1", ngImport: i0, type: DaffInMemoryProductService, decorators: [{
|
|
186
153
|
type: Injectable
|
|
187
|
-
}], ctorParameters: () => [{ type: i1
|
|
154
|
+
}], ctorParameters: () => [{ type: i1.HttpClient }, { type: i2.InMemoryBackendConfigArgs, decorators: [{
|
|
188
155
|
type: Inject,
|
|
189
156
|
args: [InMemoryBackendConfig]
|
|
190
157
|
}] }, { type: undefined, decorators: [{
|
|
@@ -223,6 +190,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.1", ngImpor
|
|
|
223
190
|
}]
|
|
224
191
|
}] });
|
|
225
192
|
|
|
193
|
+
/**
|
|
194
|
+
* A factory function that provides routable product objects for the in-memory driver.
|
|
195
|
+
*
|
|
196
|
+
* Returns a function that provides all product entities with their URL properties.
|
|
197
|
+
* Used internally by {@link provideDaffProductInMemoryDriver} with
|
|
198
|
+
* {@link provideDaffInMemoryRoutableObjects} to enable automatic URL resolution for products.
|
|
199
|
+
*
|
|
200
|
+
* @docs-private
|
|
201
|
+
*/
|
|
202
|
+
const daffProductInMemoryRoutableObjects = () => {
|
|
203
|
+
const service = inject(DaffInMemoryBackendProductService);
|
|
204
|
+
return service.products.map((p) => ({ url: p.url }));
|
|
205
|
+
};
|
|
206
|
+
|
|
226
207
|
/**
|
|
227
208
|
* Provides the Daffodil product in-memory driver and its dependencies.
|
|
228
209
|
*/
|
|
@@ -231,6 +212,7 @@ const provideDaffProductInMemoryDriver = () => [
|
|
|
231
212
|
provideDaffProductDriver(DaffInMemoryProductService),
|
|
232
213
|
provideDaffProductExtraFactoryTypes(DaffDefaultProductFactory),
|
|
233
214
|
provideDaffInMemoryBackends(DaffInMemoryBackendProductService),
|
|
215
|
+
provideDaffInMemoryRoutableObjects('PRODUCT', daffProductInMemoryRoutableObjects),
|
|
234
216
|
];
|
|
235
217
|
|
|
236
218
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"daffodil-product-driver-in-memory.mjs","sources":["../../../libs/product/driver/in-memory/src/collection-name.const.ts","../../../libs/product/driver/in-memory/src/backend/product.service.ts","../../../libs/product/driver/in-memory/src/injection-tokens/transforms/product-response/response-extra.token.ts","../../../libs/product/driver/in-memory/src/injection-tokens/transforms/product-response/response.token.ts","../../../libs/product/driver/in-memory/src/driver/product.service.ts","../../../libs/product/driver/in-memory/src/driver/product-driver.module.ts","../../../libs/product/driver/in-memory/src/driver/provider.ts","../../../libs/product/driver/in-memory/src/daffodil-product-driver-in-memory.ts"],"sourcesContent":["export const DAFF_PRODUCT_IN_MEMORY_COLLECTION_NAME = 'products';\n","import { Injectable } from '@angular/core';\nimport {\n InMemoryDbService,\n RequestInfoUtilities,\n ParsedRequestUrl,\n STATUS,\n} from 'angular-in-memory-web-api';\n\nimport { DaffInMemorySingleRouteableBackend } from '@daffodil/driver/in-memory';\nimport { DaffProduct } from '@daffodil/product';\nimport {\n DaffProductImageFactory,\n DaffProductExtensionFactory,\n} from '@daffodil/product/testing';\n\nimport { DAFF_PRODUCT_IN_MEMORY_COLLECTION_NAME } from '../collection-name.const';\n\n/**\n * An in-memory service that stubs out the backend services for getting products.\n *\n * @Param productFactory: DaffProductFactory instance\n * @Param productImageFactory: DaffProductImageFactory instance\n * @Param products: An array of Products\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffInMemoryBackendProductService implements InMemoryDbService, DaffInMemorySingleRouteableBackend {\n readonly collectionName = DAFF_PRODUCT_IN_MEMORY_COLLECTION_NAME;\n\n protected _products: DaffProduct[] = [];\n\n /**\n * The collection of products in the backend.\n */\n get products(): DaffProduct[] {\n return this._products;\n };\n\n constructor(\n private productFactory: DaffProductExtensionFactory,\n private productImageFactory: DaffProductImageFactory) {\n this._products = [\n '1001',\n '1002',\n '1003',\n '1004',\n '1005',\n '1006',\n '1007',\n '1008',\n '1009',\n '1010',\n '1011',\n '1012',\n '1013',\n '1014',\n '1015',\n '1016',\n '1017',\n '1018',\n '1019',\n '1020',\n '1021',\n '1022',\n '1023',\n '1024',\n '1025',\n '1026',\n '1027',\n '1028',\n '1029',\n '1030',\n '1031',\n '1032',\n '1033',\n '1034',\n '1035',\n ].map(id => this.productFactory.create({ id, url: `/${id}` }));\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 * Creates a fake database of products for the product inmemory backend service.\n *\n * @returns A fake database of an array of products\n * @docs-private\n */\n createDb(): any {\n return {\n products: this._products,\n };\n }\n\n /**\n * Returns products based on the url given.\n *\n * @param reqInfo request object\n * @returns An http response object\n */\n get(reqInfo: any) {\n if (reqInfo.id === 'best-sellers') {\n return reqInfo.utils.createResponse$(() => ({\n body: this._products.slice(0,4),\n status: STATUS.OK,\n }));\n }\n\n return undefined;\n }\n}\n","import { createMultiInjectionToken } from '@daffodil/core';\n\nimport { DaffInMemoryProductResponseExtraTransform } from '../../../interfaces/public_api';\n\nexport const {\n /**\n * A multi-provider injection token for providing extra transform logic in the Product In-Memory driver.\n * It is run after the standard transforms and passed both the current transformed Daffodil response and the In-Memory product response.\n */\n token: DAFF_PRODUCT_IN_MEMORY_EXTRA_PRODUCT_RESPONSE_TRANSFORMS,\n\n /**\n * Provides extra product transforms for the In-Memory product driver.\n *\n * See {@link DAFF_PRODUCT_IN_MEMORY_EXTRA_PRODUCT_RESPONSE_TRANSFORMS}.\n *\n * @example\n * ```ts\n * providers: [\n * ...provideDaffProductInMemoryExtraProductResponseTransforms(\n * myExtraProductTransform\n * )\n * ]\n * ```\n */\n provider: provideDaffProductInMemoryExtraProductResponseTransforms,\n} = createMultiInjectionToken<DaffInMemoryProductResponseExtraTransform>('DAFF_PRODUCT_IN_MEMORY_EXTRA_PRODUCT_RESPONSE_TRANSFORMS');\n","import { inject } from '@angular/core';\n\nimport { createSingleInjectionToken } from '@daffodil/core';\nimport { DaffProduct } from '@daffodil/product';\n\nimport { DAFF_PRODUCT_IN_MEMORY_EXTRA_PRODUCT_RESPONSE_TRANSFORMS } from './response-extra.token';\nimport { DaffInMemoryProductResponseTransform } from '../../../interfaces/public_api';\n\nexport const {\n /**\n * An internal token to combine the In-Memory response transform with the injected transforms.\n */\n token: DAFF_PRODUCT_IN_MEMORY_PRODUCT_RESPONSE_TRANSFORM,\n /**\n * Provider function for {@link DAFF_PRODUCT_IN_MEMORY_PRODUCT_RESPONSE_TRANSFORM}.\n */\n provider: provideDaffProductInMemoryProductResponseTransform,\n} = createSingleInjectionToken<DaffInMemoryProductResponseTransform>(\n 'DAFF_PRODUCT_IN_MEMORY_PRODUCT_RESPONSE_TRANSFORM',\n {\n factory: () => {\n const transforms = inject(DAFF_PRODUCT_IN_MEMORY_EXTRA_PRODUCT_RESPONSE_TRANSFORMS);\n return (product: DaffProduct) =>\n transforms.reduce(\n (daffProductResponse, transform) => transform(daffProductResponse, product),\n {\n id: product.id,\n products: [product],\n },\n );\n },\n },\n);\n","import { HttpClient } from '@angular/common/http';\nimport {\n Inject,\n Injectable,\n} from '@angular/core';\nimport {\n InMemoryBackendConfig,\n InMemoryBackendConfigArgs,\n} from 'angular-in-memory-web-api';\nimport { Observable } from 'rxjs';\nimport { map } from 'rxjs/operators';\n\nimport { DaffInMemoryDriverBase } from '@daffodil/driver/in-memory';\nimport { DaffProduct } from '@daffodil/product';\nimport {\n DaffProductDriverResponse,\n DaffProductServiceInterface,\n} from '@daffodil/product/driver';\n\nimport { DAFF_PRODUCT_IN_MEMORY_COLLECTION_NAME } from '../collection-name.const';\nimport { DAFF_PRODUCT_IN_MEMORY_PRODUCT_RESPONSE_TRANSFORM } from '../injection-tokens/public_api';\nimport { DaffInMemoryProductResponseTransform } from '../interfaces/public_api';\n\n/**\n * The product inmemory driver to mock the product backend service.\n *\n * @inheritdoc\n * @Param HttpClient\n */\n@Injectable()\nexport class DaffInMemoryProductService extends DaffInMemoryDriverBase implements DaffProductServiceInterface {\n constructor(\n private http: HttpClient,\n @Inject(InMemoryBackendConfig) config: InMemoryBackendConfigArgs,\n @Inject(DAFF_PRODUCT_IN_MEMORY_PRODUCT_RESPONSE_TRANSFORM) private transform: DaffInMemoryProductResponseTransform,\n ) {\n super(config, DAFF_PRODUCT_IN_MEMORY_COLLECTION_NAME);\n }\n\n getAll(): Observable<DaffProduct[]> {\n return this.http.get<DaffProduct[]>(this.url);\n }\n\n get(productId: DaffProduct['id']): Observable<DaffProductDriverResponse> {\n return this.http.get<DaffProduct>(`${this.url}/${productId}`).pipe(\n map(this.transform),\n );\n }\n\n getByUrl(url: DaffProduct['url']): Observable<DaffProductDriverResponse> {\n return this.http.get<DaffProduct>(`${this.url}${url}`).pipe(\n map(this.transform),\n );\n }\n}\n","import { CommonModule } from '@angular/common';\nimport {\n NgModule,\n ModuleWithProviders,\n} from '@angular/core';\n\nimport { provideDaffInMemoryBackends } from '@daffodil/driver/in-memory';\nimport { provideDaffProductDriver } from '@daffodil/product/driver';\nimport {\n DaffDefaultProductFactory,\n DaffProductTestingModule,\n provideDaffProductExtraFactoryTypes,\n} from '@daffodil/product/testing';\n\nimport { DaffInMemoryProductService } from './product.service';\nimport { DaffInMemoryBackendProductService } from '../backend/product.service';\n\n/**\n * Module for providing the DaffInMemoryProductService driver to your application.\n */\n@NgModule({\n imports: [\n CommonModule,\n DaffProductTestingModule,\n ],\n})\nexport class DaffProductInMemoryDriverModule {\n static forRoot(): ModuleWithProviders<DaffProductInMemoryDriverModule> {\n return {\n ngModule: DaffProductInMemoryDriverModule,\n providers: [\n DaffInMemoryProductService,\n provideDaffProductDriver(DaffInMemoryProductService),\n provideDaffProductExtraFactoryTypes(DaffDefaultProductFactory),\n provideDaffInMemoryBackends(DaffInMemoryBackendProductService),\n ],\n };\n }\n}\n","import { Provider } from '@angular/core';\n\nimport { provideDaffInMemoryBackends } from '@daffodil/driver/in-memory';\nimport { provideDaffProductDriver } from '@daffodil/product/driver';\nimport {\n DaffDefaultProductFactory,\n provideDaffProductExtraFactoryTypes,\n} from '@daffodil/product/testing';\n\nimport {\n DaffInMemoryBackendProductService,\n DaffInMemoryProductService,\n} from '../public_api';\n\n/**\n * Provides the Daffodil product in-memory driver and its dependencies.\n */\nexport const provideDaffProductInMemoryDriver = (): Provider[] => [\n DaffInMemoryProductService,\n provideDaffProductDriver(DaffInMemoryProductService),\n provideDaffProductExtraFactoryTypes(DaffDefaultProductFactory),\n provideDaffInMemoryBackends(DaffInMemoryBackendProductService),\n];\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["i1"],"mappings":";;;;;;;;;;;;;AAAO,MAAM,sCAAsC,GAAG,UAAU;;ACiBhE;;;;;;AAMG;MAIU,iCAAiC,CAAA;AAK5C;;AAEG;AACH,IAAA,IAAI,QAAQ,GAAA;QACV,OAAO,IAAI,CAAC,SAAS;IACvB;;IAEA,WAAA,CACU,cAA2C,EAC3C,mBAA4C,EAAA;QAD5C,IAAA,CAAA,cAAc,GAAd,cAAc;QACd,IAAA,CAAA,mBAAmB,GAAnB,mBAAmB;QAbpB,IAAA,CAAA,cAAc,GAAG,sCAAsC;QAEtD,IAAA,CAAA,SAAS,GAAkB,EAAE;QAYrC,IAAI,CAAC,SAAS,GAAG;YACf,MAAM;YACN,MAAM;YACN,MAAM;YACN,MAAM;YACN,MAAM;YACN,MAAM;YACN,MAAM;YACN,MAAM;YACN,MAAM;YACN,MAAM;YACN,MAAM;YACN,MAAM;YACN,MAAM;YACN,MAAM;YACN,MAAM;YACN,MAAM;YACN,MAAM;YACN,MAAM;YACN,MAAM;YACN,MAAM;YACN,MAAM;YACN,MAAM;YACN,MAAM;YACN,MAAM;YACN,MAAM;YACN,MAA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wB,CAAA,EAAA,CAAA,CAAA;AAGf,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,+BAA+B,YAJxC,YAAY;YACZ,wBAAwB,CAAA,EAAA,CAAA,CAAA;;2FAGf,+BAA+B,EAAA,UAAA,EAAA,CAAA;kBAN3C,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,OAAO,EAAE;wBACP,YAAY;wBACZ,wBAAwB;AACzB,qBAAA;AACF,iBAAA;;;ACXD;;AAEG;AACI,MAAM,gCAAgC,GAAG,MAAkB;IAChE,0BAA0B;IAC1B,wBAAwB,CAAC,0BAA0B,CAAC;IACpD,mCAAmC,CAAC,yBAAyB,CAAC;IAC9D,2BAA2B,CAAC,iCAAiC,CAAC;;;ACrBhE;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"daffodil-product-driver-in-memory.mjs","sources":["../../../libs/product/driver/in-memory/src/collection-name.const.ts","../../../libs/product/driver/in-memory/src/backend/product.service.ts","../../../libs/product/driver/in-memory/src/injection-tokens/transforms/product-response/response-extra.token.ts","../../../libs/product/driver/in-memory/src/injection-tokens/transforms/product-response/response.token.ts","../../../libs/product/driver/in-memory/src/driver/product.service.ts","../../../libs/product/driver/in-memory/src/driver/product-driver.module.ts","../../../libs/product/driver/in-memory/src/driver/routable-objects.token.ts","../../../libs/product/driver/in-memory/src/driver/provider.ts","../../../libs/product/driver/in-memory/src/daffodil-product-driver-in-memory.ts"],"sourcesContent":["export const DAFF_PRODUCT_IN_MEMORY_COLLECTION_NAME = 'products';\n","import {\n inject,\n Injectable,\n} from '@angular/core';\nimport {\n InMemoryDbService,\n RequestInfoUtilities,\n ParsedRequestUrl,\n RequestInfo,\n STATUS,\n} from 'angular-in-memory-web-api';\n\nimport { daffUriTruncateLeadingSlash } from '@daffodil/core/routing';\nimport { DaffInMemorySingleRouteableBackend } from '@daffodil/driver/in-memory';\nimport { DaffProduct } from '@daffodil/product';\nimport { DaffProductExtensionFactory } from '@daffodil/product/testing';\n\nimport { DAFF_PRODUCT_IN_MEMORY_COLLECTION_NAME } from '../collection-name.const';\n/**\n * An in-memory service that stubs out the backend services for getting products.\n *\n * @Param productFactory: DaffProductFactory instance\n * @Param productImageFactory: DaffProductImageFactory instance\n * @Param products: An array of Products\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffInMemoryBackendProductService implements InMemoryDbService, DaffInMemorySingleRouteableBackend {\n readonly collectionName = DAFF_PRODUCT_IN_MEMORY_COLLECTION_NAME;\n\n protected _products: DaffProduct[] = [];\n\n /**\n * The collection of products in the backend.\n */\n get products(): DaffProduct[] {\n return this._products;\n };\n\n productFactory = inject(DaffProductExtensionFactory);\n\n constructor(){\n this._products = this.productFactory.createMany(35);\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 * Creates a fake database of products for the product inmemory backend service.\n *\n * @returns A fake database of an array of products\n * @docs-private\n */\n createDb(): any {\n return {\n products: this._products,\n };\n }\n\n /**\n * Returns products based on the url given.\n *\n * @param reqInfo request object\n * @returns An http response object\n */\n get(reqInfo: RequestInfo) {\n if(reqInfo.id?.includes('.html')) {\n const product = this._products.find((p) => daffUriTruncateLeadingSlash(p.url) === reqInfo.id);\n\n if(!product) {\n return undefined;\n }\n\n return reqInfo.utils.createResponse$(() => ({\n body: product,\n status: STATUS.OK,\n }));\n }\n return undefined;\n }\n}\n","import { createMultiInjectionToken } from '@daffodil/core';\n\nimport { DaffInMemoryProductResponseExtraTransform } from '../../../interfaces/public_api';\n\nexport const {\n /**\n * A multi-provider injection token for providing extra transform logic in the Product In-Memory driver.\n * It is run after the standard transforms and passed both the current transformed Daffodil response and the In-Memory product response.\n */\n token: DAFF_PRODUCT_IN_MEMORY_EXTRA_PRODUCT_RESPONSE_TRANSFORMS,\n\n /**\n * Provides extra product transforms for the In-Memory product driver.\n *\n * See {@link DAFF_PRODUCT_IN_MEMORY_EXTRA_PRODUCT_RESPONSE_TRANSFORMS}.\n *\n * @example\n * ```ts\n * providers: [\n * ...provideDaffProductInMemoryExtraProductResponseTransforms(\n * myExtraProductTransform\n * )\n * ]\n * ```\n */\n provider: provideDaffProductInMemoryExtraProductResponseTransforms,\n} = createMultiInjectionToken<DaffInMemoryProductResponseExtraTransform>('DAFF_PRODUCT_IN_MEMORY_EXTRA_PRODUCT_RESPONSE_TRANSFORMS');\n","import { inject } from '@angular/core';\n\nimport { createSingleInjectionToken } from '@daffodil/core';\nimport { DaffProduct } from '@daffodil/product';\n\nimport { DAFF_PRODUCT_IN_MEMORY_EXTRA_PRODUCT_RESPONSE_TRANSFORMS } from './response-extra.token';\nimport { DaffInMemoryProductResponseTransform } from '../../../interfaces/public_api';\n\nexport const {\n /**\n * An internal token to combine the In-Memory response transform with the injected transforms.\n */\n token: DAFF_PRODUCT_IN_MEMORY_PRODUCT_RESPONSE_TRANSFORM,\n /**\n * Provider function for {@link DAFF_PRODUCT_IN_MEMORY_PRODUCT_RESPONSE_TRANSFORM}.\n */\n provider: provideDaffProductInMemoryProductResponseTransform,\n} = createSingleInjectionToken<DaffInMemoryProductResponseTransform>(\n 'DAFF_PRODUCT_IN_MEMORY_PRODUCT_RESPONSE_TRANSFORM',\n {\n factory: () => {\n const transforms = inject(DAFF_PRODUCT_IN_MEMORY_EXTRA_PRODUCT_RESPONSE_TRANSFORMS);\n return (product: DaffProduct) =>\n transforms.reduce(\n (daffProductResponse, transform) => transform(daffProductResponse, product),\n {\n id: product.id,\n products: [product],\n },\n );\n },\n },\n);\n","import { HttpClient } from '@angular/common/http';\nimport {\n Inject,\n Injectable,\n} from '@angular/core';\nimport {\n InMemoryBackendConfig,\n InMemoryBackendConfigArgs,\n} from 'angular-in-memory-web-api';\nimport { Observable } from 'rxjs';\nimport { map } from 'rxjs/operators';\n\nimport { daffUriTruncateLeadingSlash } from '@daffodil/core/routing';\nimport { DaffInMemoryDriverBase } from '@daffodil/driver/in-memory';\nimport { DaffProduct } from '@daffodil/product';\nimport {\n DaffProductDriverResponse,\n DaffProductServiceInterface,\n} from '@daffodil/product/driver';\n\nimport { DAFF_PRODUCT_IN_MEMORY_COLLECTION_NAME } from '../collection-name.const';\nimport { DAFF_PRODUCT_IN_MEMORY_PRODUCT_RESPONSE_TRANSFORM } from '../injection-tokens/public_api';\nimport { DaffInMemoryProductResponseTransform } from '../interfaces/public_api';\n\n/**\n * The product inmemory driver to mock the product backend service.\n *\n * @inheritdoc\n * @Param HttpClient\n */\n@Injectable()\nexport class DaffInMemoryProductService extends DaffInMemoryDriverBase implements DaffProductServiceInterface {\n constructor(\n private http: HttpClient,\n @Inject(InMemoryBackendConfig) config: InMemoryBackendConfigArgs,\n @Inject(DAFF_PRODUCT_IN_MEMORY_PRODUCT_RESPONSE_TRANSFORM) private transform: DaffInMemoryProductResponseTransform,\n ) {\n super(config, DAFF_PRODUCT_IN_MEMORY_COLLECTION_NAME);\n }\n\n getAll(): Observable<DaffProduct[]> {\n return this.http.get<DaffProduct[]>(this.url);\n }\n\n get(productId: DaffProduct['id']): Observable<DaffProductDriverResponse> {\n return this.http.get<DaffProduct>(`${this.url}/${productId}`).pipe(\n map(this.transform),\n );\n }\n\n getByUrl(url: DaffProduct['url']): Observable<DaffProductDriverResponse> {\n return this.http.get<DaffProduct>(`${this.url}/${daffUriTruncateLeadingSlash(url)}`).pipe(\n map(this.transform),\n );\n }\n}\n","import { CommonModule } from '@angular/common';\nimport {\n NgModule,\n ModuleWithProviders,\n} from '@angular/core';\n\nimport { provideDaffInMemoryBackends } from '@daffodil/driver/in-memory';\nimport { provideDaffProductDriver } from '@daffodil/product/driver';\nimport {\n DaffDefaultProductFactory,\n DaffProductTestingModule,\n provideDaffProductExtraFactoryTypes,\n} from '@daffodil/product/testing';\n\nimport { DaffInMemoryProductService } from './product.service';\nimport { DaffInMemoryBackendProductService } from '../backend/product.service';\n\n/**\n * Module for providing the DaffInMemoryProductService driver to your application.\n */\n@NgModule({\n imports: [\n CommonModule,\n DaffProductTestingModule,\n ],\n})\nexport class DaffProductInMemoryDriverModule {\n static forRoot(): ModuleWithProviders<DaffProductInMemoryDriverModule> {\n return {\n ngModule: DaffProductInMemoryDriverModule,\n providers: [\n DaffInMemoryProductService,\n provideDaffProductDriver(DaffInMemoryProductService),\n provideDaffProductExtraFactoryTypes(DaffDefaultProductFactory),\n provideDaffInMemoryBackends(DaffInMemoryBackendProductService),\n ],\n };\n }\n}\n","import { inject } from '@angular/core';\n\n\nimport { DaffInMemoryBackendProductService } from '../backend/product.service';\n\n/**\n * A factory function that provides routable product objects for the in-memory driver.\n *\n * Returns a function that provides all product entities with their URL properties.\n * Used internally by {@link provideDaffProductInMemoryDriver} with\n * {@link provideDaffInMemoryRoutableObjects} to enable automatic URL resolution for products.\n *\n * @docs-private\n */\nexport const daffProductInMemoryRoutableObjects = () => {\n const service = inject(DaffInMemoryBackendProductService);\n return service.products.map((p) => ({ url: p.url }));\n};\n","import {\n EnvironmentProviders,\n Provider,\n} from '@angular/core';\n\nimport {\n provideDaffInMemoryBackends,\n provideDaffInMemoryRoutableObjects,\n} from '@daffodil/driver/in-memory';\nimport { provideDaffProductDriver } from '@daffodil/product/driver';\nimport {\n DaffDefaultProductFactory,\n provideDaffProductExtraFactoryTypes,\n} from '@daffodil/product/testing';\n\nimport {\n DaffInMemoryBackendProductService,\n DaffInMemoryProductService,\n} from '../public_api';\nimport { daffProductInMemoryRoutableObjects } from './routable-objects.token';\n\n/**\n * Provides the Daffodil product in-memory driver and its dependencies.\n */\nexport const provideDaffProductInMemoryDriver = (): Array<Provider | EnvironmentProviders> => [\n DaffInMemoryProductService,\n provideDaffProductDriver(DaffInMemoryProductService),\n provideDaffProductExtraFactoryTypes(DaffDefaultProductFactory),\n provideDaffInMemoryBackends(DaffInMemoryBackendProductService),\n provideDaffInMemoryRoutableObjects('PRODUCT', daffProductInMemoryRoutableObjects),\n];\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;;AAAO,MAAM,sCAAsC,GAAG,UAAU;;ACkBhE;;;;;;AAMG;MAIU,iCAAiC,CAAA;AAK5C;;AAEG;AACH,IAAA,IAAI,QAAQ,GAAA;QACV,OAAO,IAAI,CAAC,SAAS;IACvB;;AAIA,IAAA,WAAA,GAAA;QAbS,IAAA,CAAA,cAAc,GAAG,sCAAsC;QAEtD,IAAA,CAAA,SAAS,GAAkB,EAAE;AASvC,QAAA,IAAA,CAAA,cAAc,GAAG,MAAM,CAAC,2BAA2B,CAAC;QAGlD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE,CAAC;IACrD;AAEA;;;;;;;AAOG;IACH,eAAe,CAAC,GAAW,EAAE,KAA2B,EAAA;AACtD,QAAA,OAAO,KAAK,CAAC,eAAe,CAAC,GAAG,CAAC;IACnC;AAEA;;;;;AAKG;IACH,QAAQ,GAAA;QACN,OAAO;YACL,QAAQ,EAAE,IAAI,CAAC,SAAS;SACzB;IACH;AAEA;;;;;AAKG;AACH,IAAA,GAAG,CAAC,OAAoB,EAAA;QACtB,IAAG,OAAO,CAAC,EAAE,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE;YAChC,MAAM,OAAO,GAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,2BAA2B,CAAC,CAAC,CAAC,GAAG,CAAC,KAAM,OAAO,CAAC,EAAE,CAAC;YAE/F,IAAG,CAAC,OAAO,EAAE;AACX,gBAAA,OAAO,SAAS;YAClB;YAEA,OAAO,OAAO,CAAC,KAAK,CAAC,eAAe,CAAC,OAAO;AAC1C,gB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mC,CAAC,yBAAyB,CAAC;IAC9D,2BAA2B,CAAC,iCAAiC,CAAC;AAC9D,IAAA,kCAAkC,CAAC,SAAS,EAAE,kCAAkC,CAAC;;;AC7BnF;;AAEG;;;;"}
|
|
@@ -132,7 +132,7 @@ const daffShopifyProductTransformer = (node) => ({
|
|
|
132
132
|
id: node.images.nodes[0]?.id,
|
|
133
133
|
},
|
|
134
134
|
id: node.id,
|
|
135
|
-
url: `/${node.handle}`,
|
|
135
|
+
url: `/${"products" /* SHOPIFY_ROUTE_PREFIXES.PRODUCTS */}/${node.handle}`,
|
|
136
136
|
type: DaffProductTypeEnum.Simple,
|
|
137
137
|
price: node.priceRange.maxVariantPrice.amount,
|
|
138
138
|
in_stock: node.availableForSale,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"daffodil-product-driver-shopify.mjs","sources":["../../../libs/product/driver/shopify/src/queries/gql/get-all-products.ts","../../../libs/product/driver/shopify/src/queries/gql/get-product-by-url.ts","../../../libs/product/driver/shopify/src/queries/gql/get-product.ts","../../../libs/product/driver/shopify/src/queries/response.types.ts","../../../libs/product/driver/shopify/src/transforms/shopify-daff-product-transform.ts","../../../libs/product/driver/shopify/src/product.service.ts","../../../libs/product/driver/shopify/src/provider.ts","../../../libs/product/driver/shopify/src/product-driver.module.ts","../../../libs/product/driver/shopify/src/daffodil-product-driver-shopify.ts"],"sourcesContent":["import { gql } from 'apollo-angular';\n\nimport { ShopifyProductAllResponse } from '../response.types';\nimport { ShopifyProductAllVariables } from '../variables.types';\n\n/**\n * GraphQL query object for getting all products.\n */\nexport const getAllProducts = gql<ShopifyProductAllResponse, ShopifyProductAllVariables>`\n\tquery ShopifyGetAllProducts($length: Int) {\n\t\tproducts(first: $length) {\n\t\t\tnodes {\n\t\t\t\thandle\n\t\t\t\tonlineStoreUrl\n\t\t\t\tavailableForSale\n\t\t\t\tpriceRange {\n\t\t\t\t\tmaxVariantPrice {\n\t\t\t\t\t\tamount\n\t\t\t\t\t\tcurrencyCode\n\t\t\t\t\t}\n\t\t\t\t\tminVariantPrice {\n\t\t\t\t\t\tamount\n\t\t\t\t\t\tcurrencyCode\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tid\n\t\t\t\ttitle\n\t\t\t\tdescription\n\t\t\t\timages(first: 1) {\n\t\t\t\t\tnodes {\n\t\t\t\t\t\tid\n\t\t\t\t\t\turl\n\t\t\t\t\t\taltText\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n`;\n","import { gql } from 'apollo-angular';\n\nimport { ShopifyProductSingleResponse } from '../response.types';\nimport { ShopifyProductUrlVariables } from '../variables.types';\n\n/**\n * GraphQL query object for getting a product by URL.\n *\n * The DaffLocatable url is transformed into a Shopify product handle for querying.\n */\nexport const getProductByUrl = gql<ShopifyProductSingleResponse, ShopifyProductUrlVariables>`\n query ShopifyGetProductByURL($handle: String!) {\n\t product(handle: $handle) {\n\t\t handle\n\t\t id\n\t\t title\n\t\t description\n\t\t availableForSale\n\t\t priceRange {\n\t\t\t maxVariantPrice {\n\t\t\t\t amount\n\t\t\t\t currencyCode\n\t\t\t }\n\t\t\t minVariantPrice {\n\t\t\t\t\t\tamount\n\t\t\t\t\t\tcurrencyCode\n\t\t\t }\n\t\t }\n\t\t images(first: 1) {\n\t\t\t nodes {\n\t\t\t\t id\n\t\t\t\t url\n\t\t\t\t altText\n\t\t\t }\n\t\t }\n\t\t onlineStoreUrl\n\t }\n }\n`;\n","import { gql } from 'apollo-angular';\n\nimport { ShopifyProductSingleResponse } from '../response.types';\nimport { ShopifyProductIDVariables } from '../variables.types';\n\n/**\n * GraphQL query object for getting a single product by ID.\n */\nexport const getProduct = gql<ShopifyProductSingleResponse, ShopifyProductIDVariables>`\n query ShopifyGetAProduct($id: ID!) {\n\t product(id: $id) {\n\t\t handle\n\t\t id\n\t\t title\n\t\t description\n\t\t availableForSale\n\t\t priceRange {\n\t\t\t maxVariantPrice {\n\t\t\t\t amount\n\t\t\t\t currencyCode\n\t\t\t }\n\t\t\t minVariantPrice {\n\t\t\t\t\t\tamount\n\t\t\t\t\t\tcurrencyCode\n\t\t\t }\n\t\t }\n\t\t images(first: 1) {\n\t\t\t nodes {\n\t\t\t\t id\n\t\t\t\t url\n\t\t\t\t altText\n\t\t\t }\n\t\t }\n\t\t onlineStoreUrl\n\t }\n }\n`;\n","import {\n ShopifyProductNode,\n ShopifyProductGraph,\n} from '@daffodil/driver/shopify';\n\nexport interface ShopifyProductAllResponse {\n products?: ShopifyProductGraph;\n}\n\nexport interface ShopifyProductSingleResponse {\n product: ShopifyProductNode;\n};\n","import { ShopifyProductNode } from '@daffodil/driver/shopify';\nimport {\n DaffProduct,\n DaffProductTypeEnum,\n} from '@daffodil/product';\n\n\n/**\n * Transforms a ProductNode into a different object.\n *\n * @param node - ProductNode object\n * @returns A Product object\n */\nexport const daffShopifyProductTransformer = (node: ShopifyProductNode): DaffProduct => ({\n name: node.title,\n images: node.images.nodes.map(imageNode => ({\n id: imageNode.id,\n url: imageNode.url,\n label: imageNode.altText ?? '',\n })),\n thumbnail: {\n url: node.images.nodes[0]?.url,\n label: node.images.nodes[0]?.altText ?? '',\n id: node.images.nodes[0]?.id,\n },\n id: node.id,\n url: `/${node.handle}`,\n type: DaffProductTypeEnum.Simple,\n price: node.priceRange.maxVariantPrice.amount,\n in_stock: node.availableForSale,\n description: node.description,\n});\n","import { Injectable } from '@angular/core';\nimport { Apollo } from 'apollo-angular';\nimport { Observable } from 'rxjs';\nimport { map } from 'rxjs/operators';\n\nimport {\n shopifyIdTransformer,\n shopifyUrlTransformer,\n APOLLO_CLIENT_NAME,\n} from '@daffodil/driver/shopify';\nimport { DaffProduct } from '@daffodil/product';\nimport {\n DaffProductDriverResponse,\n DaffProductServiceInterface,\n} from '@daffodil/product/driver';\n\nimport {\n getAllProducts,\n getProduct,\n getProductByUrl,\n} from './queries/public_api';\nimport { daffShopifyProductTransformer } from './transforms/public_api';\n/**\n * A service for getting DaffProducts {@link DaffProduct} from apollo shopify product requests.\n *\n * @inheritdoc\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffShopifyProductService\nimplements DaffProductServiceInterface {\n defaultLength = 20;\n\n constructor(private apollo: Apollo) {}\n\n getAll(): Observable<DaffProduct[]> {\n return this.apollo.use(APOLLO_CLIENT_NAME)\n .query({\n query: getAllProducts,\n variables: {\n length: this.defaultLength,\n },\n })\n .pipe(\n map((result) => {\n const nodes = result.data?.products?.nodes || [];\n return nodes.map((node) => daffShopifyProductTransformer(node));\n }),\n );\n }\n\n get(productId: DaffProduct['id']): Observable<DaffProductDriverResponse> {\n return this.apollo.use(APOLLO_CLIENT_NAME)\n .query({\n query: getProduct,\n variables: { id: shopifyIdTransformer(productId, 'Product') },\n })\n .pipe(\n map((result) => {\n const productNode = result.data.product;\n return {\n id: productNode.id,\n products: [daffShopifyProductTransformer(productNode)],\n };\n }),\n );\n }\n\n getByUrl(url: DaffProduct['url']): Observable<DaffProductDriverResponse> {\n return this.apollo.use(APOLLO_CLIENT_NAME)\n .query({\n query: getProductByUrl,\n variables: { handle: shopifyUrlTransformer(url) },\n })\n .pipe(\n map((result) => {\n const productNode = result.data.product;\n return {\n id: productNode.id,\n products: [daffShopifyProductTransformer(productNode)],\n };\n }),\n );\n }\n}\n","import { Provider } from '@angular/core';\n\nimport { provideDaffProductDriver } from '@daffodil/product/driver';\n\nimport { DaffShopifyProductService } from './product.service';\n\n/**\n * Provides the Shopify product driver.\n *\n * @returns Array of Angular providers for the Shopify product driver\n */\nexport const provideDaffProductShopifyDriver = (): Provider[] => [\n DaffShopifyProductService,\n provideDaffProductDriver(DaffShopifyProductService),\n];\n","import { CommonModule } from '@angular/common';\nimport {\n NgModule,\n ModuleWithProviders,\n} from '@angular/core';\n\n\nimport { provideDaffProductShopifyDriver } from './provider';\n\n/**\n * A module that provides the {@link DaffProductDriver} as the {@link DaffShopifyProductService}.\n *\n * @deprecated Use {@link provideDaffProductShopifyDriver} instead. Deprecated in version 0.89.0. Will be removed in version 0.92.0.\n */\n@NgModule({\n imports: [\n CommonModule,\n ],\n})\nexport class DaffProductShopifyDriverModule {\n static forRoot(): ModuleWithProviders<DaffProductShopifyDriverModule> {\n return {\n ngModule: DaffProductShopifyDriverModule,\n providers: [\n provideDaffProductShopifyDriver(),\n ],\n };\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;AAKA;;AAEG;AACI,MAAM,cAAc,GAAG,GAAG,CAAuD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACHxF;;;;AAIG;AACI,MAAM,eAAe,GAAG,GAAG,CAA0D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACL5F;;AAEG;AACI,MAAM,UAAU,GAAG,GAAG,CAAyD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACGrF;;ACJD;;;;;AAKG;MACU,6BAA6B,GAAG,CAAC,IAAwB,MAAmB;IACvF,IAAI,EAAE,IAAI,CAAC,KAAK;AAChB,IAAA,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,KAAK;QAC1C,EAAE,EAAE,SAAS,CAAC,EAAE;QAChB,GAAG,EAAE,SAAS,CAAC,GAAG;AAClB,QAAA,KAAK,EAAE,SAAS,CAAC,OAAO,IAAI,EAAE;AAC/B,KAAA,CAAC,CAAC;AACH,IAAA,SAAS,EAAE;QACT,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG;AAC9B,QAAA,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,IAAI,EAAE;QAC1C,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;AAC7B,KAAA;IACD,EAAE,EAAE,IAAI,CAAC,EAAE;AACX,IAAA,GAAG,EAAE,CAAA,CAAA,EAAI,IAA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AAO,OAAO,GAAA;QACZ,OAAO;AACL,YAAA,QAAQ,EAAE,8BAA8B;AACxC,YAAA,SAAS,EAAE;AACT,gBAAA,+BAA+B,EAAE;AAClC,aAAA;SACF;IACH;iIARW,8BAA8B,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;AAA9B,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,8BAA8B,YAHvC,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,8BAA8B,YAHvC,YAAY,CAAA,EAAA,CAAA,CAAA;;2FAGH,8BAA8B,EAAA,UAAA,EAAA,CAAA;kBAL1C,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,OAAO,EAAE;wBACP,YAAY;AACb,qBAAA;AACF,iBAAA;;;AClBD;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"daffodil-product-driver-shopify.mjs","sources":["../../../libs/product/driver/shopify/src/queries/gql/get-all-products.ts","../../../libs/product/driver/shopify/src/queries/gql/get-product-by-url.ts","../../../libs/product/driver/shopify/src/queries/gql/get-product.ts","../../../libs/product/driver/shopify/src/queries/response.types.ts","../../../libs/product/driver/shopify/src/transforms/shopify-daff-product-transform.ts","../../../libs/product/driver/shopify/src/product.service.ts","../../../libs/product/driver/shopify/src/provider.ts","../../../libs/product/driver/shopify/src/product-driver.module.ts","../../../libs/product/driver/shopify/src/daffodil-product-driver-shopify.ts"],"sourcesContent":["import { gql } from 'apollo-angular';\n\nimport { ShopifyProductAllResponse } from '../response.types';\nimport { ShopifyProductAllVariables } from '../variables.types';\n\n/**\n * GraphQL query object for getting all products.\n */\nexport const getAllProducts = gql<ShopifyProductAllResponse, ShopifyProductAllVariables>`\n\tquery ShopifyGetAllProducts($length: Int) {\n\t\tproducts(first: $length) {\n\t\t\tnodes {\n\t\t\t\thandle\n\t\t\t\tonlineStoreUrl\n\t\t\t\tavailableForSale\n\t\t\t\tpriceRange {\n\t\t\t\t\tmaxVariantPrice {\n\t\t\t\t\t\tamount\n\t\t\t\t\t\tcurrencyCode\n\t\t\t\t\t}\n\t\t\t\t\tminVariantPrice {\n\t\t\t\t\t\tamount\n\t\t\t\t\t\tcurrencyCode\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tid\n\t\t\t\ttitle\n\t\t\t\tdescription\n\t\t\t\timages(first: 1) {\n\t\t\t\t\tnodes {\n\t\t\t\t\t\tid\n\t\t\t\t\t\turl\n\t\t\t\t\t\taltText\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n`;\n","import { gql } from 'apollo-angular';\n\nimport { ShopifyProductSingleResponse } from '../response.types';\nimport { ShopifyProductUrlVariables } from '../variables.types';\n\n/**\n * GraphQL query object for getting a product by URL.\n *\n * The DaffLocatable url is transformed into a Shopify product handle for querying.\n */\nexport const getProductByUrl = gql<ShopifyProductSingleResponse, ShopifyProductUrlVariables>`\n query ShopifyGetProductByURL($handle: String!) {\n\t product(handle: $handle) {\n\t\t handle\n\t\t id\n\t\t title\n\t\t description\n\t\t availableForSale\n\t\t priceRange {\n\t\t\t maxVariantPrice {\n\t\t\t\t amount\n\t\t\t\t currencyCode\n\t\t\t }\n\t\t\t minVariantPrice {\n\t\t\t\t\t\tamount\n\t\t\t\t\t\tcurrencyCode\n\t\t\t }\n\t\t }\n\t\t images(first: 1) {\n\t\t\t nodes {\n\t\t\t\t id\n\t\t\t\t url\n\t\t\t\t altText\n\t\t\t }\n\t\t }\n\t\t onlineStoreUrl\n\t }\n }\n`;\n","import { gql } from 'apollo-angular';\n\nimport { ShopifyProductSingleResponse } from '../response.types';\nimport { ShopifyProductIDVariables } from '../variables.types';\n\n/**\n * GraphQL query object for getting a single product by ID.\n */\nexport const getProduct = gql<ShopifyProductSingleResponse, ShopifyProductIDVariables>`\n query ShopifyGetAProduct($id: ID!) {\n\t product(id: $id) {\n\t\t handle\n\t\t id\n\t\t title\n\t\t description\n\t\t availableForSale\n\t\t priceRange {\n\t\t\t maxVariantPrice {\n\t\t\t\t amount\n\t\t\t\t currencyCode\n\t\t\t }\n\t\t\t minVariantPrice {\n\t\t\t\t\t\tamount\n\t\t\t\t\t\tcurrencyCode\n\t\t\t }\n\t\t }\n\t\t images(first: 1) {\n\t\t\t nodes {\n\t\t\t\t id\n\t\t\t\t url\n\t\t\t\t altText\n\t\t\t }\n\t\t }\n\t\t onlineStoreUrl\n\t }\n }\n`;\n","import {\n ShopifyProductNode,\n ShopifyProductGraph,\n} from '@daffodil/driver/shopify';\n\nexport interface ShopifyProductAllResponse {\n products?: ShopifyProductGraph;\n}\n\nexport interface ShopifyProductSingleResponse {\n product: ShopifyProductNode;\n};\n","import {\n SHOPIFY_ROUTE_PREFIXES,\n ShopifyProductNode,\n} from '@daffodil/driver/shopify';\nimport {\n DaffProduct,\n DaffProductTypeEnum,\n} from '@daffodil/product';\n\n\n/**\n * Transforms a ProductNode into a different object.\n *\n * @param node - ProductNode object\n * @returns A Product object\n */\nexport const daffShopifyProductTransformer = (node: ShopifyProductNode): DaffProduct => ({\n name: node.title,\n images: node.images.nodes.map(imageNode => ({\n id: imageNode.id,\n url: imageNode.url,\n label: imageNode.altText ?? '',\n })),\n thumbnail: {\n url: node.images.nodes[0]?.url,\n label: node.images.nodes[0]?.altText ?? '',\n id: node.images.nodes[0]?.id,\n },\n id: node.id,\n url: `/${SHOPIFY_ROUTE_PREFIXES.PRODUCTS}/${node.handle}`,\n type: DaffProductTypeEnum.Simple,\n price: node.priceRange.maxVariantPrice.amount,\n in_stock: node.availableForSale,\n description: node.description,\n});\n","import { Injectable } from '@angular/core';\nimport { Apollo } from 'apollo-angular';\nimport { Observable } from 'rxjs';\nimport { map } from 'rxjs/operators';\n\nimport {\n shopifyIdTransformer,\n shopifyUrlTransformer,\n APOLLO_CLIENT_NAME,\n} from '@daffodil/driver/shopify';\nimport { DaffProduct } from '@daffodil/product';\nimport {\n DaffProductDriverResponse,\n DaffProductServiceInterface,\n} from '@daffodil/product/driver';\n\nimport {\n getAllProducts,\n getProduct,\n getProductByUrl,\n} from './queries/public_api';\nimport { daffShopifyProductTransformer } from './transforms/public_api';\n/**\n * A service for getting DaffProducts {@link DaffProduct} from apollo shopify product requests.\n *\n * @inheritdoc\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffShopifyProductService\nimplements DaffProductServiceInterface {\n defaultLength = 20;\n\n constructor(private apollo: Apollo) {}\n\n getAll(): Observable<DaffProduct[]> {\n return this.apollo.use(APOLLO_CLIENT_NAME)\n .query({\n query: getAllProducts,\n variables: {\n length: this.defaultLength,\n },\n })\n .pipe(\n map((result) => {\n const nodes = result.data?.products?.nodes || [];\n return nodes.map((node) => daffShopifyProductTransformer(node));\n }),\n );\n }\n\n get(productId: DaffProduct['id']): Observable<DaffProductDriverResponse> {\n return this.apollo.use(APOLLO_CLIENT_NAME)\n .query({\n query: getProduct,\n variables: { id: shopifyIdTransformer(productId, 'Product') },\n })\n .pipe(\n map((result) => {\n const productNode = result.data.product;\n return {\n id: productNode.id,\n products: [daffShopifyProductTransformer(productNode)],\n };\n }),\n );\n }\n\n getByUrl(url: DaffProduct['url']): Observable<DaffProductDriverResponse> {\n return this.apollo.use(APOLLO_CLIENT_NAME)\n .query({\n query: getProductByUrl,\n variables: { handle: shopifyUrlTransformer(url) },\n })\n .pipe(\n map((result) => {\n const productNode = result.data.product;\n return {\n id: productNode.id,\n products: [daffShopifyProductTransformer(productNode)],\n };\n }),\n );\n }\n}\n","import { Provider } from '@angular/core';\n\nimport { provideDaffProductDriver } from '@daffodil/product/driver';\n\nimport { DaffShopifyProductService } from './product.service';\n\n/**\n * Provides the Shopify product driver.\n *\n * @returns Array of Angular providers for the Shopify product driver\n */\nexport const provideDaffProductShopifyDriver = (): Provider[] => [\n DaffShopifyProductService,\n provideDaffProductDriver(DaffShopifyProductService),\n];\n","import { CommonModule } from '@angular/common';\nimport {\n NgModule,\n ModuleWithProviders,\n} from '@angular/core';\n\n\nimport { provideDaffProductShopifyDriver } from './provider';\n\n/**\n * A module that provides the {@link DaffProductDriver} as the {@link DaffShopifyProductService}.\n *\n * @deprecated Use {@link provideDaffProductShopifyDriver} instead. Deprecated in version 0.89.0. Will be removed in version 0.92.0.\n */\n@NgModule({\n imports: [\n CommonModule,\n ],\n})\nexport class DaffProductShopifyDriverModule {\n static forRoot(): ModuleWithProviders<DaffProductShopifyDriverModule> {\n return {\n ngModule: DaffProductShopifyDriverModule,\n providers: [\n provideDaffProductShopifyDriver(),\n ],\n };\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;AAKA;;AAEG;AACI,MAAM,cAAc,GAAG,GAAG,CAAuD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACHxF;;;;AAIG;AACI,MAAM,eAAe,GAAG,GAAG,CAA0D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACL5F;;AAEG;AACI,MAAM,UAAU,GAAG,GAAG,CAAyD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACGrF;;ACDD;;;;;AAKG;MACU,6BAA6B,GAAG,CAAC,IAAwB,MAAmB;IACvF,IAAI,EAAE,IAAI,CAAC,KAAK;AAChB,IAAA,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,KAAK;QAC1C,EAAE,EAAE,SAAS,CAAC,EAAE;QAChB,GAAG,EAAE,SAAS,CAAC,GAAG;AAClB,QAAA,KAAK,EAAE,SAAS,CAAC,OAAO,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;;;"}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@daffodil/product","nx":{"targets":{"build":{"outputs":["{workspaceRoot}/dist/product"]}}},"version":"0.
|
|
1
|
+
{"name":"@daffodil/product","nx":{"targets":{"build":{"outputs":["{workspaceRoot}/dist/product"]}}},"version":"0.91.0","description":"Interfaces built for daffodil/state","repository":{"type":"git","url":"https://github.com/graycoreio/daffodil"},"author":"Graycore LLC","license":"MIT","bugs":{"url":"https://github.com/graycoreio/daffodil/issues"},"publishConfig":{"directory":"../../dist/product"},"homepage":"https://github.com/graycoreio/daffodil","peerDependencies":{"@angular/common":"^20.0.0","@angular/core":"^20.0.0","@daffodil/core":"0.91.0","@ngrx/effects":"^20.0.0","@ngrx/entity":"^20.0.0","@ngrx/store":"^20.0.0","rxjs":"^7.0.0"},"optionalDependencies":{"@apollo/client":"^3.12.6","@daffodil/driver":"0.91.0","angular-in-memory-web-api":"^0.20.0","apollo-angular":"^11.0.0","@faker-js/faker":"^9.8.0"},"module":"fesm2022/daffodil-product.mjs","typings":"index.d.ts","exports":{"./package.json":{"default":"./package.json"},".":{"types":"./index.d.ts","default":"./fesm2022/daffodil-product.mjs"},"./driver":{"types":"./driver/index.d.ts","default":"./fesm2022/daffodil-product-driver.mjs"},"./routing":{"types":"./routing/index.d.ts","default":"./fesm2022/daffodil-product-routing.mjs"},"./state":{"types":"./state/index.d.ts","default":"./fesm2022/daffodil-product-state.mjs"},"./testing":{"types":"./testing/index.d.ts","default":"./fesm2022/daffodil-product-testing.mjs"},"./driver/in-memory":{"types":"./driver/in-memory/index.d.ts","default":"./fesm2022/daffodil-product-driver-in-memory.mjs"},"./driver/magento":{"types":"./driver/magento/index.d.ts","default":"./fesm2022/daffodil-product-driver-magento.mjs"},"./driver/shopify":{"types":"./driver/shopify/index.d.ts","default":"./fesm2022/daffodil-product-driver-shopify.mjs"},"./driver/testing":{"types":"./driver/testing/index.d.ts","default":"./fesm2022/daffodil-product-driver-testing.mjs"},"./state/testing":{"types":"./state/testing/index.d.ts","default":"./fesm2022/daffodil-product-state-testing.mjs"},"./driver/magento/testing":{"types":"./driver/magento/testing/index.d.ts","default":"./fesm2022/daffodil-product-driver-magento-testing.mjs"}},"sideEffects":false,"dependencies":{"tslib":"^2.6.2"}}
|