@daffodil/external-router 0.94.1 → 0.95.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/fesm2022/daffodil-external-router-driver-in-memory.mjs +70 -88
  2. package/fesm2022/daffodil-external-router-driver-in-memory.mjs.map +1 -1
  3. package/fesm2022/daffodil-external-router-driver-magento-2.4.1.mjs +117 -118
  4. package/fesm2022/daffodil-external-router-driver-magento-2.4.1.mjs.map +1 -1
  5. package/fesm2022/daffodil-external-router-driver-magento-2.4.2.mjs +117 -118
  6. package/fesm2022/daffodil-external-router-driver-magento-2.4.2.mjs.map +1 -1
  7. package/fesm2022/daffodil-external-router-driver-magento-2.4.3.mjs +216 -266
  8. package/fesm2022/daffodil-external-router-driver-magento-2.4.3.mjs.map +1 -1
  9. package/fesm2022/daffodil-external-router-driver-magento-auto.mjs +7 -0
  10. package/fesm2022/daffodil-external-router-driver-magento-auto.mjs.map +1 -0
  11. package/fesm2022/daffodil-external-router-driver-magento.mjs +6 -18
  12. package/fesm2022/daffodil-external-router-driver-magento.mjs.map +1 -1
  13. package/fesm2022/daffodil-external-router-driver-shopify.mjs +49 -39
  14. package/fesm2022/daffodil-external-router-driver-shopify.mjs.map +1 -1
  15. package/fesm2022/daffodil-external-router-driver-testing.mjs +118 -115
  16. package/fesm2022/daffodil-external-router-driver-testing.mjs.map +1 -1
  17. package/fesm2022/daffodil-external-router-driver.mjs +8 -32
  18. package/fesm2022/daffodil-external-router-driver.mjs.map +1 -1
  19. package/fesm2022/daffodil-external-router-routing.mjs +31 -66
  20. package/fesm2022/daffodil-external-router-routing.mjs.map +1 -1
  21. package/fesm2022/daffodil-external-router.mjs +37 -81
  22. package/fesm2022/daffodil-external-router.mjs.map +1 -1
  23. package/package.json +1 -1
  24. package/types/daffodil-external-router-driver-in-memory.d.ts +15 -21
  25. package/types/daffodil-external-router-driver-magento-2.4.1.d.ts +29 -25
  26. package/types/daffodil-external-router-driver-magento-2.4.2.d.ts +29 -25
  27. package/types/daffodil-external-router-driver-magento-2.4.3.d.ts +25 -28
  28. package/types/daffodil-external-router-driver-magento-auto.d.ts +1 -0
  29. package/types/daffodil-external-router-driver-magento.d.ts +251 -263
  30. package/types/daffodil-external-router-driver-shopify.d.ts +10 -14
  31. package/types/daffodil-external-router-driver-testing.d.ts +22 -27
  32. package/types/daffodil-external-router-driver.d.ts +12 -19
  33. package/types/daffodil-external-router-routing.d.ts +4 -7
  34. package/types/daffodil-external-router.d.ts +72 -86
@@ -0,0 +1,7 @@
1
+ import { isDevMode } from "@angular/core";
2
+ import { daffAutoDriverErrorMessage } from "@daffodil/driver";
3
+ const MESSAGE = daffAutoDriverErrorMessage("external-router");
4
+ if (isDevMode()) throw new Error(MESSAGE);
5
+ else console.error(MESSAGE);
6
+
7
+ //# sourceMappingURL=daffodil-external-router-driver-magento-auto.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"daffodil-external-router-driver-magento-auto.mjs","names":[],"sources":["../../../libs/external-router/driver/magento/auto/src/index.ts"],"sourcesContent":["import { isDevMode } from '@angular/core';\n\nimport { daffAutoDriverErrorMessage } from '@daffodil/driver';\n\nconst MESSAGE = daffAutoDriverErrorMessage('external-router');\n\nif (isDevMode()) {\n throw new Error(MESSAGE);\n} else {\n console.error(MESSAGE);\n}\n\nexport {};\n"],"mappings":";;AAIA,MAAM,UAAU,2BAA2B,iBAAiB;AAE5D,IAAI,UAAS,GACX,MAAM,IAAI,MAAM,OAAO;KAEvB,QAAQ,MAAM,OAAO"}
@@ -1,22 +1,10 @@
1
1
  var MagentoUrlRewriteEntityTypeEnum;
2
- (function (MagentoUrlRewriteEntityTypeEnum) {
3
- MagentoUrlRewriteEntityTypeEnum["PRODUCT"] = "PRODUCT";
4
- MagentoUrlRewriteEntityTypeEnum["CATEGORY"] = "CATEGORY";
5
- MagentoUrlRewriteEntityTypeEnum["CMS_PAGE"] = "CMS_PAGE";
2
+ (function(MagentoUrlRewriteEntityTypeEnum) {
3
+ MagentoUrlRewriteEntityTypeEnum["PRODUCT"] = "PRODUCT";
4
+ MagentoUrlRewriteEntityTypeEnum["CATEGORY"] = "CATEGORY";
5
+ MagentoUrlRewriteEntityTypeEnum["CMS_PAGE"] = "CMS_PAGE";
6
6
  })(MagentoUrlRewriteEntityTypeEnum || (MagentoUrlRewriteEntityTypeEnum = {}));
7
-
8
- /**
9
- * Transforms a Magento redirect code to the appropriate HTTP status code.
10
- */
11
7
  const magentoTransformRedirectToHttpCode = (code) => code === 0 ? 200 : code;
12
-
13
- /*
14
- * Public API Surface of @daffodil/external-router/driver/magento
15
- */
16
-
17
- /**
18
- * Generated bundle index. Do not edit.
19
- */
20
-
21
8
  export { MagentoUrlRewriteEntityTypeEnum, magentoTransformRedirectToHttpCode };
22
- //# sourceMappingURL=daffodil-external-router-driver-magento.mjs.map
9
+
10
+ //# sourceMappingURL=daffodil-external-router-driver-magento.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"daffodil-external-router-driver-magento.mjs","sources":["../../../libs/external-router/driver/magento/src/model/resolution-types.ts","../../../libs/external-router/driver/magento/src/transforms/redirect-to-http.ts","../../../libs/external-router/driver/magento/src/public_api.ts","../../../libs/external-router/driver/magento/src/daffodil-external-router-driver-magento.ts"],"sourcesContent":["export enum MagentoUrlRewriteEntityTypeEnum {\n PRODUCT = 'PRODUCT',\n CATEGORY = 'CATEGORY',\n CMS_PAGE = 'CMS_PAGE',\n}\n","/**\n * Transforms a Magento redirect code to the appropriate HTTP status code.\n */\nexport const magentoTransformRedirectToHttpCode = (code: number): number =>\n code === 0 ? 200 : code;\n","/*\n * Public API Surface of @daffodil/external-router/driver/magento\n */\n\nexport * from './model/public_api';\nexport * from './transforms/public_api';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":"IAAY;AAAZ,CAAA,UAAY,+BAA+B,EAAA;AACzC,IAAA,+BAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACnB,IAAA,+BAAA,CAAA,UAAA,CAAA,GAAA,UAAqB;AACrB,IAAA,+BAAA,CAAA,UAAA,CAAA,GAAA,UAAqB;AACvB,CAAC,EAJW,+BAA+B,KAA/B,+BAA+B,GAAA,EAAA,CAAA,CAAA;;ACA3C;;AAEG;MACU,kCAAkC,GAAG,CAAC,IAAY,KAC7D,IAAI,KAAK,CAAC,GAAG,GAAG,GAAG;;ACJrB;;AAEG;;ACFH;;AAEG;;;;"}
1
+ {"version":3,"file":"daffodil-external-router-driver-magento.mjs","names":[],"sources":["../../../libs/external-router/driver/magento/src/model/resolution-types.ts","../../../libs/external-router/driver/magento/src/transforms/redirect-to-http.ts"],"sourcesContent":["export enum MagentoUrlRewriteEntityTypeEnum {\n PRODUCT = 'PRODUCT',\n CATEGORY = 'CATEGORY',\n CMS_PAGE = 'CMS_PAGE',\n}\n","/**\n * Transforms a Magento redirect code to the appropriate HTTP status code.\n */\nexport const magentoTransformRedirectToHttpCode = (code: number): number =>\n code === 0 ? 200 : code;\n"],"mappings":"AAAA,IAAY;CAAZ,SAAY,iCAA+B;CACzC,gCAAA,aAAA;CACA,gCAAA,cAAA;CACA,gCAAA,cAAA;AACF,EAAA,CAJY,oCAAA,kCAA+B,CAAA,EAAA;ACG3C,MAAa,sCAAsC,SACjD,SAAS,IAAI,MAAM"}
@@ -1,40 +1,50 @@
1
- import * as i0 from '@angular/core';
2
- import { Injectable, makeEnvironmentProviders } from '@angular/core';
3
- import { of } from 'rxjs';
4
- import { daffUriTruncateLeadingSlash, daffUriTruncateFileExtension, daffUriTruncateLeadingPathSegments } from '@daffodil/core/routing';
5
- import { DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION, provideDaffExternalRouterDriver } from '@daffodil/external-router/driver';
6
-
7
- class DaffShopifyExternalRouterDriver {
8
- resolve(url) {
9
- const productsMatch = url.match(/^\/?products\/(?<slug>[^/]+?)(?:\.[^/.]+)?$/);
10
- if (productsMatch && productsMatch.groups?.['slug']) {
11
- return of({
12
- id: daffUriTruncateFileExtension(daffUriTruncateLeadingPathSegments(url)),
13
- url: daffUriTruncateLeadingSlash(url),
14
- code: 200,
15
- type: 'PRODUCT',
16
- });
17
- }
18
- return of(DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION);
19
- }
20
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffShopifyExternalRouterDriver, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
21
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffShopifyExternalRouterDriver, providedIn: 'root' }); }
22
- }
23
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffShopifyExternalRouterDriver, decorators: [{
24
- type: Injectable,
25
- args: [{
26
- providedIn: 'root',
27
- }]
28
- }] });
29
-
30
- const provideDaffExternalRouterShopifyDriver = () => [
31
- makeEnvironmentProviders([DaffShopifyExternalRouterDriver]),
32
- provideDaffExternalRouterDriver(DaffShopifyExternalRouterDriver),
33
- ];
34
-
35
- /**
36
- * Generated bundle index. Do not edit.
37
- */
38
-
1
+ import * as i0 from "@angular/core";
2
+ import { Injectable, makeEnvironmentProviders } from "@angular/core";
3
+ import { of } from "rxjs";
4
+ import { daffUriTruncateFileExtension, daffUriTruncateLeadingPathSegments, daffUriTruncateLeadingSlash } from "@daffodil/core/routing";
5
+ import { DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION, provideDaffExternalRouterDriver } from "@daffodil/external-router/driver";
6
+ var DaffShopifyExternalRouterDriver = class DaffShopifyExternalRouterDriver {
7
+ resolve(url) {
8
+ const productsMatch = url.match(/^\/?products\/(?<slug>[^/]+?)(?:\.[^/.]+)?$/);
9
+ if (productsMatch && productsMatch.groups?.["slug"]) return of({
10
+ id: daffUriTruncateFileExtension(daffUriTruncateLeadingPathSegments(url)),
11
+ url: daffUriTruncateLeadingSlash(url),
12
+ code: 200,
13
+ type: "PRODUCT"
14
+ });
15
+ return of(DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION);
16
+ }
17
+ static {
18
+ this.ɵfac = i0.ɵɵngDeclareFactory({
19
+ minVersion: "12.0.0",
20
+ version: "22.2.4",
21
+ ngImport: i0,
22
+ type: DaffShopifyExternalRouterDriver,
23
+ deps: [],
24
+ target: i0.ɵɵFactoryTarget.Injectable
25
+ });
26
+ }
27
+ static {
28
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
29
+ minVersion: "12.0.0",
30
+ version: "22.2.4",
31
+ ngImport: i0,
32
+ type: DaffShopifyExternalRouterDriver,
33
+ providedIn: "root"
34
+ });
35
+ }
36
+ };
37
+ i0.ɵɵngDeclareClassMetadata({
38
+ minVersion: "12.0.0",
39
+ version: "22.2.4",
40
+ ngImport: i0,
41
+ type: DaffShopifyExternalRouterDriver,
42
+ decorators: [{
43
+ type: Injectable,
44
+ args: [{ providedIn: "root" }]
45
+ }]
46
+ });
47
+ const provideDaffExternalRouterShopifyDriver = () => [makeEnvironmentProviders([DaffShopifyExternalRouterDriver]), provideDaffExternalRouterDriver(DaffShopifyExternalRouterDriver)];
39
48
  export { DaffShopifyExternalRouterDriver, provideDaffExternalRouterShopifyDriver };
40
- //# sourceMappingURL=daffodil-external-router-driver-shopify.mjs.map
49
+
50
+ //# sourceMappingURL=daffodil-external-router-driver-shopify.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"daffodil-external-router-driver-shopify.mjs","sources":["../../../libs/external-router/driver/shopify/src/shopify.service.ts","../../../libs/external-router/driver/shopify/src/provider.ts","../../../libs/external-router/driver/shopify/src/daffodil-external-router-driver-shopify.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\nimport {\n Observable,\n of,\n} from 'rxjs';\n\nimport {\n daffUriTruncateFileExtension,\n daffUriTruncateLeadingPathSegments,\n daffUriTruncateLeadingSlash,\n} from '@daffodil/core/routing';\nimport { DaffExternallyResolvableUrl } from '@daffodil/external-router';\nimport {\n DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION,\n DaffExternalRouterDriverInterface,\n} from '@daffodil/external-router/driver';\n\n@Injectable({\n providedIn:'root',\n})\nexport class DaffShopifyExternalRouterDriver implements DaffExternalRouterDriverInterface {\n\n resolve(url: string): Observable<DaffExternallyResolvableUrl> {\n const productsMatch = url.match(/^\\/?products\\/(?<slug>[^/]+?)(?:\\.[^/.]+)?$/);\n if(productsMatch && productsMatch.groups?.['slug']) {\n return of({\n id: daffUriTruncateFileExtension(daffUriTruncateLeadingPathSegments(url)),\n url: daffUriTruncateLeadingSlash(url),\n code: 200,\n type: 'PRODUCT',\n });\n }\n\n return of(DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION);\n }\n}\n","import {\n EnvironmentProviders,\n makeEnvironmentProviders,\n Provider,\n} from '@angular/core';\n\nimport { provideDaffExternalRouterDriver } from '@daffodil/external-router/driver';\n\nimport { DaffShopifyExternalRouterDriver } from './shopify.service';\n\nexport const provideDaffExternalRouterShopifyDriver = (): (Provider | EnvironmentProviders)[] => [\n makeEnvironmentProviders([DaffShopifyExternalRouterDriver]),\n provideDaffExternalRouterDriver(DaffShopifyExternalRouterDriver),\n];\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;MAoBa,+BAA+B,CAAA;AAE1C,IAAA,OAAO,CAAC,GAAW,EAAA;QACjB,MAAM,aAAa,GAAG,GAAG,CAAC,KAAK,CAAC,6CAA6C,CAAC;QAC9E,IAAG,aAAa,IAAI,aAAa,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE;AAClD,YAAA,OAAO,EAAE,CAAC;AACR,gBAAA,EAAE,EAAE,4BAA4B,CAAC,kCAAkC,CAAC,GAAG,CAAC,CAAC;AACzE,gBAAA,GAAG,EAAE,2BAA2B,CAAC,GAAG,CAAC;AACrC,gBAAA,IAAI,EAAE,GAAG;AACT,gBAAA,IAAI,EAAE,SAAS;AAChB,aAAA,CAAC;QACJ;AAEA,QAAA,OAAO,EAAE,CAAC,yCAAyC,CAAC;IACtD;iIAdW,+BAA+B,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAA/B,uBAAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,+BAA+B,cAF/B,MAAM,EAAA,CAAA,CAAA;;2FAEN,+BAA+B,EAAA,UAAA,EAAA,CAAA;kBAH3C,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAC,MAAM;AAClB,iBAAA;;;ACTM,MAAM,sCAAsC,GAAG,MAA2C;AAC/F,IAAA,wBAAwB,CAAC,CAAC,+BAA+B,CAAC,CAAC;IAC3D,+BAA+B,CAAC,+BAA+B,CAAC;;;ACZlE;;AAEG;;;;"}
1
+ {"version":3,"file":"daffodil-external-router-driver-shopify.mjs","names":[],"sources":["../../../libs/external-router/driver/shopify/src/shopify.service.ts","../../../libs/external-router/driver/shopify/src/provider.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\nimport {\n Observable,\n of,\n} from 'rxjs';\n\nimport {\n daffUriTruncateFileExtension,\n daffUriTruncateLeadingPathSegments,\n daffUriTruncateLeadingSlash,\n} from '@daffodil/core/routing';\nimport { DaffExternallyResolvableUrl } from '@daffodil/external-router';\nimport {\n DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION,\n DaffExternalRouterDriverInterface,\n} from '@daffodil/external-router/driver';\n\n@Injectable({\n providedIn:'root',\n})\nexport class DaffShopifyExternalRouterDriver implements DaffExternalRouterDriverInterface {\n\n resolve(url: string): Observable<DaffExternallyResolvableUrl> {\n const productsMatch = url.match(/^\\/?products\\/(?<slug>[^/]+?)(?:\\.[^/.]+)?$/);\n if(productsMatch && productsMatch.groups?.['slug']) {\n return of({\n id: daffUriTruncateFileExtension(daffUriTruncateLeadingPathSegments(url)),\n url: daffUriTruncateLeadingSlash(url),\n code: 200,\n type: 'PRODUCT',\n });\n }\n\n return of(DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION);\n }\n}\n","import {\n EnvironmentProviders,\n makeEnvironmentProviders,\n Provider,\n} from '@angular/core';\n\nimport { provideDaffExternalRouterDriver } from '@daffodil/external-router/driver';\n\nimport { DaffShopifyExternalRouterDriver } from './shopify.service';\n\nexport const provideDaffExternalRouterShopifyDriver = (): (Provider | EnvironmentProviders)[] => [\n makeEnvironmentProviders([DaffShopifyExternalRouterDriver]),\n provideDaffExternalRouterDriver(DaffShopifyExternalRouterDriver),\n];\n"],"mappings":";;;;;AAoBA,IAAa,kCAAb,MAAa,gCAA+B;CAE1C,QAAQ,KAAW;EACjB,MAAM,gBAAgB,IAAI,MAAM,6CAA6C;EAC7E,IAAG,iBAAiB,cAAc,SAAS,SACzC,OAAO,GAAG;GACR,IAAI,6BAA6B,mCAAmC,GAAG,CAAC;GACxE,KAAK,4BAA4B,GAAG;GACpC,MAAM;GACN,MAAM;EACP,CAAA;EAGH,OAAO,GAAG,yCAAyC;CACrD;CAdW;EAAA,KAAA,OAAA,GAAA,mBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;GAA+B,MAAA,CAAA;GAAA,QAAA,GAAA,gBAAA;EAAA,CAAA;CAAA;CAA/B;EAAA,KAAA,QAAA,GAAA,sBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;GAA+B,YAF/B;EAAM,CAAA;CAAA;;AAEN,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAA+B,YAAA,CAAA;EAH3C,MAAA;EAAW,MAAA,CAAA,EACV,YAAW,OACZ,CAAA;;;ACTD,MAAa,+CAAoF,CAC/F,yBAAyB,CAAC,+BAA+B,CAAC,GAC1D,gCAAgC,+BAA+B,CAChE"}
@@ -1,116 +1,119 @@
1
- import * as i0 from '@angular/core';
2
- import { Inject, Injectable, NgModule, makeEnvironmentProviders } from '@angular/core';
3
- import { faker } from '@faker-js/faker/locale/en_US';
4
- import { throwError, of } from 'rxjs';
5
- import { daffUriTruncateLeadingSlash, daffUriTruncateQueryFragment } from '@daffodil/core/routing';
6
- import { DaffExternalRouterNotFoundError, DaffExternalRouterClientError, DaffExternalRouterServerError } from '@daffodil/external-router';
7
- import { createConfigInjectionToken } from '@daffodil/core';
8
- import { CommonModule } from '@angular/common';
9
- import { provideDaffExternalRouterDriver } from '@daffodil/external-router/driver';
10
-
11
- const {
12
- /**
13
- * The token used by Daffodil to hold the driver's configuration.
14
- *
15
- * @docs-private
16
- */
17
- token: DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG,
18
- /**
19
- * Provider function for {@link DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG}.
20
- */
21
- provider: provideDaffExternalRouterDriverTestingConfig, } = createConfigInjectionToken(({}), 'DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG');
22
-
23
- /**
24
- * The DaffExternalRouterTestingDriver is responsible for translating an
25
- * arbitrary URI into a DaffExternallyResolvableUrl in testing environments.
26
- *
27
- * @inheritdoc
28
- *
29
- * @see {@link DaffExternalRouterTestingDriver}
30
- */
31
- class DaffExternalRouterTestingDriver {
32
- constructor(testingConfiguration = {}) {
33
- this.testingConfiguration = testingConfiguration;
34
- }
35
- resolve(url) {
36
- const truncatedUrl = daffUriTruncateLeadingSlash(daffUriTruncateQueryFragment(url));
37
- const configuredResolution = this.testingConfiguration[truncatedUrl];
38
- if (!configuredResolution) {
39
- return throwError(() => new DaffExternalRouterNotFoundError());
40
- }
41
- const resolution = typeof configuredResolution === 'string'
42
- ? {
43
- id: faker.string.uuid(),
44
- url: truncatedUrl,
45
- type: configuredResolution,
46
- code: 200,
47
- }
48
- : configuredResolution;
49
- if (resolution.code === 404) {
50
- return throwError(() => new DaffExternalRouterNotFoundError());
51
- }
52
- if (resolution.code >= 400 && resolution.code < 500) {
53
- return throwError(() => new DaffExternalRouterClientError());
54
- }
55
- if (resolution.code >= 500) {
56
- return throwError(() => new DaffExternalRouterServerError());
57
- }
58
- return of(resolution);
59
- }
60
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffExternalRouterTestingDriver, deps: [{ token: DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG }], target: i0.ɵɵFactoryTarget.Injectable }); }
61
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffExternalRouterTestingDriver, providedIn: 'root' }); }
62
- }
63
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffExternalRouterTestingDriver, decorators: [{
64
- type: Injectable,
65
- args: [{
66
- providedIn: 'root',
67
- }]
68
- }], ctorParameters: () => [{ type: undefined, decorators: [{
69
- type: Inject,
70
- args: [DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG]
71
- }] }] });
72
-
73
- /**
74
- * The `DaffExternalRouterDriverTestingModule` is an importable NgModule that can
75
- * be used to configure the {@link DaffExternalRouterTestingDriver}.
76
- */
77
- class DaffExternalRouterDriverTestingModule {
78
- static forRoot(config) {
79
- return {
80
- ngModule: DaffExternalRouterDriverTestingModule,
81
- providers: [
82
- provideDaffExternalRouterDriver(DaffExternalRouterTestingDriver),
83
- provideDaffExternalRouterDriverTestingConfig(config),
84
- ],
85
- };
86
- }
87
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffExternalRouterDriverTestingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
88
- /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.9", ngImport: i0, type: DaffExternalRouterDriverTestingModule, imports: [CommonModule] }); }
89
- /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffExternalRouterDriverTestingModule, imports: [CommonModule] }); }
90
- }
91
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffExternalRouterDriverTestingModule, decorators: [{
92
- type: NgModule,
93
- args: [{
94
- declarations: [],
95
- imports: [CommonModule],
96
- }]
97
- }] });
98
-
99
- /**
100
- * Provides a testing implementation of {@link DaffExternalRouterDriver}
101
- */
102
- const provideDaffExternalRouterTestingDriver = (config) => makeEnvironmentProviders([
103
- provideDaffExternalRouterDriver(DaffExternalRouterTestingDriver),
104
- provideDaffExternalRouterDriverTestingConfig(config),
105
- ]);
106
-
107
- /*
108
- * Public API Surface of @daffodil/external-router/driver/testing
109
- */
110
-
111
- /**
112
- * Generated bundle index. Do not edit.
113
- */
114
-
1
+ import * as i0 from "@angular/core";
2
+ import { Inject, Injectable, NgModule, makeEnvironmentProviders } from "@angular/core";
3
+ import { faker } from "@faker-js/faker/locale/en_US";
4
+ import { of, throwError } from "rxjs";
5
+ import { daffUriTruncateLeadingSlash, daffUriTruncateQueryFragment } from "@daffodil/core/routing";
6
+ import { DaffExternalRouterClientError, DaffExternalRouterNotFoundError, DaffExternalRouterServerError } from "@daffodil/external-router";
7
+ import { createConfigInjectionToken } from "@daffodil/core";
8
+ import { CommonModule } from "@angular/common";
9
+ import { provideDaffExternalRouterDriver } from "@daffodil/external-router/driver";
10
+ const { token: DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG, provider: provideDaffExternalRouterDriverTestingConfig } = createConfigInjectionToken({}, "DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG");
11
+ var DaffExternalRouterTestingDriver = class DaffExternalRouterTestingDriver {
12
+ constructor(testingConfiguration = {}) {
13
+ this.testingConfiguration = testingConfiguration;
14
+ }
15
+ resolve(url) {
16
+ const truncatedUrl = daffUriTruncateLeadingSlash(daffUriTruncateQueryFragment(url));
17
+ const configuredResolution = this.testingConfiguration[truncatedUrl];
18
+ if (!configuredResolution) return throwError(() => new DaffExternalRouterNotFoundError());
19
+ const resolution = typeof configuredResolution === "string" ? {
20
+ id: faker.string.uuid(),
21
+ url: truncatedUrl,
22
+ type: configuredResolution,
23
+ code: 200
24
+ } : configuredResolution;
25
+ if (resolution.code === 404) return throwError(() => new DaffExternalRouterNotFoundError());
26
+ if (resolution.code >= 400 && resolution.code < 500) return throwError(() => new DaffExternalRouterClientError());
27
+ if (resolution.code >= 500) return throwError(() => new DaffExternalRouterServerError());
28
+ return of(resolution);
29
+ }
30
+ static {
31
+ this.ɵfac = i0.ɵɵngDeclareFactory({
32
+ minVersion: "12.0.0",
33
+ version: "22.2.4",
34
+ ngImport: i0,
35
+ type: DaffExternalRouterTestingDriver,
36
+ deps: [{ token: DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG }],
37
+ target: i0.ɵɵFactoryTarget.Injectable
38
+ });
39
+ }
40
+ static {
41
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
42
+ minVersion: "12.0.0",
43
+ version: "22.2.4",
44
+ ngImport: i0,
45
+ type: DaffExternalRouterTestingDriver,
46
+ providedIn: "root"
47
+ });
48
+ }
49
+ };
50
+ i0.ɵɵngDeclareClassMetadata({
51
+ minVersion: "12.0.0",
52
+ version: "22.2.4",
53
+ ngImport: i0,
54
+ type: DaffExternalRouterTestingDriver,
55
+ decorators: [{
56
+ type: Injectable,
57
+ args: [{ providedIn: "root" }]
58
+ }],
59
+ ctorParameters: () => [{
60
+ type: void 0,
61
+ decorators: [{
62
+ type: Inject,
63
+ args: [DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG]
64
+ }]
65
+ }]
66
+ });
67
+ const provideDaffExternalRouterTestingDriver = (config) => makeEnvironmentProviders([provideDaffExternalRouterDriver(DaffExternalRouterTestingDriver), provideDaffExternalRouterDriverTestingConfig(config)]);
68
+ var DaffExternalRouterDriverTestingModule = class DaffExternalRouterDriverTestingModule {
69
+ static forRoot(config) {
70
+ return {
71
+ ngModule: DaffExternalRouterDriverTestingModule,
72
+ providers: [provideDaffExternalRouterTestingDriver(config)]
73
+ };
74
+ }
75
+ static {
76
+ this.ɵfac = i0.ɵɵngDeclareFactory({
77
+ minVersion: "12.0.0",
78
+ version: "22.2.4",
79
+ ngImport: i0,
80
+ type: DaffExternalRouterDriverTestingModule,
81
+ deps: [],
82
+ target: i0.ɵɵFactoryTarget.NgModule
83
+ });
84
+ }
85
+ static {
86
+ this.ɵmod = i0.ɵɵngDeclareNgModule({
87
+ minVersion: "14.0.0",
88
+ version: "22.2.4",
89
+ ngImport: i0,
90
+ type: DaffExternalRouterDriverTestingModule,
91
+ imports: [CommonModule]
92
+ });
93
+ }
94
+ static {
95
+ this.ɵinj = i0.ɵɵngDeclareInjector({
96
+ minVersion: "12.0.0",
97
+ version: "22.2.4",
98
+ ngImport: i0,
99
+ type: DaffExternalRouterDriverTestingModule,
100
+ imports: [CommonModule]
101
+ });
102
+ }
103
+ };
104
+ i0.ɵɵngDeclareClassMetadata({
105
+ minVersion: "12.0.0",
106
+ version: "22.2.4",
107
+ ngImport: i0,
108
+ type: DaffExternalRouterDriverTestingModule,
109
+ decorators: [{
110
+ type: NgModule,
111
+ args: [{
112
+ declarations: [],
113
+ imports: [CommonModule]
114
+ }]
115
+ }]
116
+ });
115
117
  export { DaffExternalRouterDriverTestingModule, DaffExternalRouterTestingDriver, provideDaffExternalRouterTestingDriver };
116
- //# sourceMappingURL=daffodil-external-router-driver-testing.mjs.map
118
+
119
+ //# sourceMappingURL=daffodil-external-router-driver-testing.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"daffodil-external-router-driver-testing.mjs","sources":["../../../libs/external-router/driver/testing/src/config.ts","../../../libs/external-router/driver/testing/src/testing.service.ts","../../../libs/external-router/driver/testing/src/testing.module.ts","../../../libs/external-router/driver/testing/src/provider.ts","../../../libs/external-router/driver/testing/src/public_api.ts","../../../libs/external-router/driver/testing/src/daffodil-external-router-driver-testing.ts"],"sourcesContent":["import { createConfigInjectionToken } from '@daffodil/core';\nimport {\n DaffExternallyResolvableUrl,\n DaffExternalRouteType,\n} from '@daffodil/external-router';\n\n/**\n * The configuration for the testing driver. It is a dictionary of \"url\": \"type\",\n * pairs, where the URL is a URL-safe routeable path, e.g. \"sweatshirts\" or \"t-shirts\"\n * and the type is a known type to your application, e.g. \"CATEGORY\".\n */\nexport interface DaffExternalRouterDriverTestingConfig {\n [url: string]: DaffExternalRouteType | DaffExternallyResolvableUrl;\n}\n\nexport const {\n /**\n * The token used by Daffodil to hold the driver's configuration.\n *\n * @docs-private\n */\n token: DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG,\n /**\n * Provider function for {@link DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG}.\n */\n provider: provideDaffExternalRouterDriverTestingConfig,\n} = createConfigInjectionToken<DaffExternalRouterDriverTestingConfig>(({}), 'DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG');\n","import {\n Injectable,\n Inject,\n} from '@angular/core';\nimport { faker } from '@faker-js/faker/locale/en_US';\nimport {\n Observable,\n of,\n throwError,\n} from 'rxjs';\n\nimport {\n daffUriTruncateLeadingSlash,\n daffUriTruncateQueryFragment,\n} from '@daffodil/core/routing';\nimport {\n DaffExternallyResolvableUrl,\n DaffExternalRouterClientError,\n DaffExternalRouterNotFoundError,\n DaffExternalRouterServerError,\n} from '@daffodil/external-router';\nimport { DaffExternalRouterDriverInterface } from '@daffodil/external-router/driver';\n\nimport {\n DaffExternalRouterDriverTestingConfig,\n DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG,\n} from './config';\n\n/**\n * The DaffExternalRouterTestingDriver is responsible for translating an\n * arbitrary URI into a DaffExternallyResolvableUrl in testing environments.\n *\n * @inheritdoc\n *\n * @see {@link DaffExternalRouterTestingDriver}\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffExternalRouterTestingDriver\nimplements DaffExternalRouterDriverInterface {\n constructor(\n @Inject(DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG)\n private testingConfiguration: DaffExternalRouterDriverTestingConfig = {},\n ) {}\n\n resolve(url: string): Observable<DaffExternallyResolvableUrl> {\n const truncatedUrl = daffUriTruncateLeadingSlash(daffUriTruncateQueryFragment(url));\n\n const configuredResolution = this.testingConfiguration[truncatedUrl];\n\n if (!configuredResolution) {\n return throwError(() => new DaffExternalRouterNotFoundError());\n }\n\n const resolution: DaffExternallyResolvableUrl = typeof configuredResolution === 'string'\n ? {\n id: faker.string.uuid(),\n url: truncatedUrl,\n type: configuredResolution,\n code: 200,\n }\n : configuredResolution;\n\n if (resolution.code === 404) {\n return throwError(() => new DaffExternalRouterNotFoundError());\n }\n\n if (resolution.code >= 400 && resolution.code < 500) {\n return throwError(() => new DaffExternalRouterClientError());\n }\n\n if (resolution.code >= 500) {\n return throwError(() => new DaffExternalRouterServerError());\n }\n\n return of(resolution);\n }\n}\n","import { CommonModule } from '@angular/common';\nimport {\n NgModule,\n ModuleWithProviders,\n} from '@angular/core';\n\nimport { provideDaffExternalRouterDriver } from '@daffodil/external-router/driver';\n\nimport {\n DaffExternalRouterDriverTestingConfig,\n provideDaffExternalRouterDriverTestingConfig,\n} from './config';\nimport { DaffExternalRouterTestingDriver } from './testing.service';\n\n/**\n * The `DaffExternalRouterDriverTestingModule` is an importable NgModule that can\n * be used to configure the {@link DaffExternalRouterTestingDriver}.\n */\n@NgModule({\n declarations: [],\n imports: [CommonModule],\n})\nexport class DaffExternalRouterDriverTestingModule {\n static forRoot(\n config: DaffExternalRouterDriverTestingConfig,\n ): ModuleWithProviders<DaffExternalRouterDriverTestingModule> {\n return {\n ngModule: DaffExternalRouterDriverTestingModule,\n providers: [\n provideDaffExternalRouterDriver(DaffExternalRouterTestingDriver),\n provideDaffExternalRouterDriverTestingConfig(config),\n ],\n };\n }\n}\n","import {\n EnvironmentProviders,\n InjectionToken,\n makeEnvironmentProviders,\n} from '@angular/core';\n\nimport { provideDaffExternalRouterDriver } from '@daffodil/external-router/driver';\n\nimport {\n DaffExternalRouterDriverTestingConfig,\n provideDaffExternalRouterDriverTestingConfig,\n} from './config';\nimport { DaffExternalRouterTestingDriver } from './testing.service';\n\n/**\n * Provides a testing implementation of {@link DaffExternalRouterDriver}\n */\nexport const provideDaffExternalRouterTestingDriver = (config:\n DaffExternalRouterDriverTestingConfig | InjectionToken<DaffExternalRouterDriverTestingConfig>,\n): EnvironmentProviders => makeEnvironmentProviders([\n provideDaffExternalRouterDriver(DaffExternalRouterTestingDriver),\n provideDaffExternalRouterDriverTestingConfig(config),\n]);\n","/*\n * Public API Surface of @daffodil/external-router/driver/testing\n */\n\nexport { DaffExternalRouterTestingDriver } from './testing.service';\nexport { DaffExternalRouterDriverTestingModule } from './testing.module';\n\nexport { DaffExternalRouterDriverTestingConfig } from './config';\nexport { provideDaffExternalRouterTestingDriver } from './provider';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;AAeO,MAAM;AACX;;;;AAIG;AACH,KAAK,EAAE,0CAA0C;AACjD;;AAEG;AACH,QAAQ,EAAE,4CAA4C,GACvD,GAAG,0BAA0B,EAAyC,EAAE,GAAG,4CAA4C,CAAC;;ACEzH;;;;;;;AAOG;MAIU,+BAA+B,CAAA;AAE1C,IAAA,WAAA,CAEU,uBAA8D,EAAE,EAAA;QAAhE,IAAA,CAAA,oBAAoB,GAApB,oBAAoB;IAC3B;AAEH,IAAA,OAAO,CAAC,GAAW,EAAA;QACjB,MAAM,YAAY,GAAG,2BAA2B,CAAC,4BAA4B,CAAC,GAAG,CAAC,CAAC;QAEnF,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CAAC,+BAA+B,CAAC;IAChE,4CAA4C,CAAC,MAAM,CAAC;AACrD,CAAA;;ACtBD;;AAEG;;ACFH;;AAEG;;;;"}
1
+ {"version":3,"file":"daffodil-external-router-driver-testing.mjs","names":[],"sources":["../../../libs/external-router/driver/testing/src/config.ts","../../../libs/external-router/driver/testing/src/testing.service.ts","../../../libs/external-router/driver/testing/src/provider.ts","../../../libs/external-router/driver/testing/src/testing.module.ts"],"sourcesContent":["import { createConfigInjectionToken } from '@daffodil/core';\nimport {\n DaffExternallyResolvableUrl,\n DaffExternalRouteType,\n} from '@daffodil/external-router';\n\n/**\n * The configuration for the testing driver. It is a dictionary of \"url\": \"type\",\n * pairs, where the URL is a URL-safe routeable path, e.g. \"sweatshirts\" or \"t-shirts\"\n * and the type is a known type to your application, e.g. \"CATEGORY\".\n */\nexport interface DaffExternalRouterDriverTestingConfig {\n [url: string]: DaffExternalRouteType | DaffExternallyResolvableUrl;\n}\n\nexport const {\n /**\n * The token used by Daffodil to hold the driver's configuration.\n *\n * @docs-private\n */\n token: DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG,\n /**\n * Provider function for {@link DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG}.\n */\n provider: provideDaffExternalRouterDriverTestingConfig,\n} = createConfigInjectionToken<DaffExternalRouterDriverTestingConfig>(({}), 'DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG');\n","import {\n Injectable,\n Inject,\n} from '@angular/core';\nimport { faker } from '@faker-js/faker/locale/en_US';\nimport {\n Observable,\n of,\n throwError,\n} from 'rxjs';\n\nimport {\n daffUriTruncateLeadingSlash,\n daffUriTruncateQueryFragment,\n} from '@daffodil/core/routing';\nimport {\n DaffExternallyResolvableUrl,\n DaffExternalRouterClientError,\n DaffExternalRouterNotFoundError,\n DaffExternalRouterServerError,\n} from '@daffodil/external-router';\nimport { DaffExternalRouterDriverInterface } from '@daffodil/external-router/driver';\n\nimport {\n DaffExternalRouterDriverTestingConfig,\n DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG,\n} from './config';\n\n/**\n * The DaffExternalRouterTestingDriver is responsible for translating an\n * arbitrary URI into a DaffExternallyResolvableUrl in testing environments.\n *\n * @inheritdoc\n *\n * @see {@link DaffExternalRouterTestingDriver}\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffExternalRouterTestingDriver\nimplements DaffExternalRouterDriverInterface {\n constructor(\n @Inject(DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG)\n private testingConfiguration: DaffExternalRouterDriverTestingConfig = {},\n ) {}\n\n resolve(url: string): Observable<DaffExternallyResolvableUrl> {\n const truncatedUrl = daffUriTruncateLeadingSlash(daffUriTruncateQueryFragment(url));\n\n const configuredResolution = this.testingConfiguration[truncatedUrl];\n\n if (!configuredResolution) {\n return throwError(() => new DaffExternalRouterNotFoundError());\n }\n\n const resolution: DaffExternallyResolvableUrl = typeof configuredResolution === 'string'\n ? {\n id: faker.string.uuid(),\n url: truncatedUrl,\n type: configuredResolution,\n code: 200,\n }\n : configuredResolution;\n\n if (resolution.code === 404) {\n return throwError(() => new DaffExternalRouterNotFoundError());\n }\n\n if (resolution.code >= 400 && resolution.code < 500) {\n return throwError(() => new DaffExternalRouterClientError());\n }\n\n if (resolution.code >= 500) {\n return throwError(() => new DaffExternalRouterServerError());\n }\n\n return of(resolution);\n }\n}\n","import {\n EnvironmentProviders,\n InjectionToken,\n makeEnvironmentProviders,\n} from '@angular/core';\n\nimport { provideDaffExternalRouterDriver } from '@daffodil/external-router/driver';\n\nimport {\n DaffExternalRouterDriverTestingConfig,\n provideDaffExternalRouterDriverTestingConfig,\n} from './config';\nimport { DaffExternalRouterTestingDriver } from './testing.service';\n\n/**\n * Provides a testing implementation of {@link DaffExternalRouterDriver}\n */\nexport const provideDaffExternalRouterTestingDriver = (config:\n DaffExternalRouterDriverTestingConfig | InjectionToken<DaffExternalRouterDriverTestingConfig>,\n): EnvironmentProviders => makeEnvironmentProviders([\n provideDaffExternalRouterDriver(DaffExternalRouterTestingDriver),\n provideDaffExternalRouterDriverTestingConfig(config),\n]);\n","import { CommonModule } from '@angular/common';\nimport {\n NgModule,\n ModuleWithProviders,\n} from '@angular/core';\n\nimport { DaffExternalRouterDriverTestingConfig } from './config';\nimport { provideDaffExternalRouterTestingDriver } from './provider';\n\n/**\n * The `DaffExternalRouterDriverTestingModule` is an importable NgModule that can\n * be used to configure the {@link DaffExternalRouterTestingDriver}.\n *\n * @deprecated in favor of {@link provideDaffExternalRouterTestingDriver} Deprecated in version 0.95.0. Will be removed in version 0.98.0.\n */\n@NgModule({\n declarations: [],\n imports: [CommonModule],\n})\nexport class DaffExternalRouterDriverTestingModule {\n static forRoot(\n config: DaffExternalRouterDriverTestingConfig,\n ): ModuleWithProviders<DaffExternalRouterDriverTestingModule> {\n return {\n ngModule: DaffExternalRouterDriverTestingModule,\n providers: [\n provideDaffExternalRouterTestingDriver(config),\n ],\n };\n }\n}\n"],"mappings":";;;;;;;;;AAeA,MAAa,EAMX,OAAO,4CAIP,UAAU,iDACR,2BAAmE,CAAA,GAAK,4CAA4C;ACaxH,IAAa,kCAAb,MAAa,gCAA+B;CAE1C,YAEU,uBAA8D,CAAA,GAAE;EAAhE,KAAA,uBAAA;CACP;CAEH,QAAQ,KAAW;EACjB,MAAM,eAAe,4BAA4B,6BAA6B,GAAG,CAAC;EAElF,MAAM,uBAAuB,KAAK,qBAAqB;EAEvD,IAAI,CAAC,sBACH,OAAO,iBAAiB,IAAI,gCAA+B,CAAE;EAG/D,MAAM,aAA0C,OAAO,yBAAyB,WAC5E;GACA,IAAI,MAAM,OAAO,KAAI;GACrB,KAAK;GACL,MAAM;GACN,MAAM;EACP,IACC;EAEJ,IAAI,WAAW,SAAS,KACtB,OAAO,iBAAiB,IAAI,gCAA+B,CAAE;EAG/D,IAAI,WAAW,QAAQ,OAAO,WAAW,OAAO,KAC9C,OAAO,iBAAiB,IAAI,8BAA6B,CAAE;EAG7D,IAAI,WAA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A,SAAA;CAAA,UAAA;CAAA,MAAA;CAAqC,YAAA,CAAA;EAJjD,MAAA;EAAS,MAAA,CAAA;GACR,cAAc,CAAA;GACd,SAAS,CAAC,YAAY;EACvB,CAAA"}
@@ -1,35 +1,11 @@
1
- import { createSingletonInjectionToken } from '@daffodil/core';
2
-
3
- const {
4
- /**
5
- * The token for the `@daffodil/external-router` driver.
6
- */
7
- token: DaffExternalRouterDriver,
8
- /**
9
- * Provider function for {@link DaffExternalRouterDriver}.
10
- */
11
- provider: provideDaffExternalRouterDriver, } = createSingletonInjectionToken('DaffExternalRouterDriver');
12
-
13
- /**
14
- * When a driver fails to find a resolution, it should return a 404.
15
- * This const represents the standard "Not Found" resolution that a driver
16
- * should return. Drivers are not required to return this value, but may do so
17
- * if they would like.
18
- */
1
+ import { createSingletonInjectionToken } from "@daffodil/core";
2
+ const { token: DaffExternalRouterDriver, provider: provideDaffExternalRouterDriver } = createSingletonInjectionToken("DaffExternalRouterDriver");
19
3
  const DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION = {
20
- id: null,
21
- url: null,
22
- code: 404,
23
- type: null,
4
+ id: null,
5
+ url: null,
6
+ code: 404,
7
+ type: null
24
8
  };
25
-
26
- /*
27
- * Public API Surface of @daffodil/external-router/driver
28
- */
29
-
30
- /**
31
- * Generated bundle index. Do not edit.
32
- */
33
-
34
9
  export { DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION, DaffExternalRouterDriver, provideDaffExternalRouterDriver };
35
- //# sourceMappingURL=daffodil-external-router-driver.mjs.map
10
+
11
+ //# sourceMappingURL=daffodil-external-router-driver.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"daffodil-external-router-driver.mjs","sources":["../../../libs/external-router/driver/src/interfaces/external-router-driver.interface.ts","../../../libs/external-router/driver/src/not-found-resolution.ts","../../../libs/external-router/driver/src/public_api.ts","../../../libs/external-router/driver/src/daffodil-external-router-driver.ts"],"sourcesContent":["import { Observable } from 'rxjs';\n\nimport { createSingletonInjectionToken } from '@daffodil/core';\nimport { DaffExternallyResolvableUrl } from '@daffodil/external-router';\n\nexport const {\n /**\n * The token for the `@daffodil/external-router` driver.\n */\n token: DaffExternalRouterDriver,\n /**\n * Provider function for {@link DaffExternalRouterDriver}.\n */\n provider: provideDaffExternalRouterDriver,\n} = createSingletonInjectionToken<DaffExternalRouterDriverInterface>('DaffExternalRouterDriver');\n\n/**\n * The interface for a `@daffodil/external-router` driver.\n *\n * This driver is responsible for translating a URL into a Route consumable by\n * Daffodil.\n */\nexport interface DaffExternalRouterDriverInterface {\n /**\n * Resolves a URL with a platform.\n * Returns information about the type of URL.\n *\n * @param url The full URL path qualified with file extension and leading slash but without domain. i.e. /full/path/to/thing.html\n */\n resolve(url: string): Observable<DaffExternallyResolvableUrl>;\n}\n","import { DaffExternallyResolvableUrl } from '@daffodil/external-router';\n\n/**\n * When a driver fails to find a resolution, it should return a 404.\n * This const represents the standard \"Not Found\" resolution that a driver\n * should return. Drivers are not required to return this value, but may do so\n * if they would like.\n */\nexport const DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION: DaffExternallyResolvableUrl = {\n id: null,\n url: null,\n code: 404,\n type: null,\n};\n","/*\n * Public API Surface of @daffodil/external-router/driver\n */\n\nexport {\n DaffExternalRouterDriverInterface,\n DaffExternalRouterDriver,\n provideDaffExternalRouterDriver,\n} from './interfaces/external-router-driver.interface';\nexport { DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION } from './not-found-resolution';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAKO,MAAM;AACX;;AAEG;AACH,KAAK,EAAE,wBAAwB;AAC/B;;AAEG;AACH,QAAQ,EAAE,+BAA+B,GAC1C,GAAG,6BAA6B,CAAoC,0BAA0B;;ACZ/F;;;;;AAKG;AACI,MAAM,yCAAyC,GAAgC;AACpF,IAAA,EAAE,EAAE,IAAI;AACR,IAAA,GAAG,EAAE,IAAI;AACT,IAAA,IAAI,EAAE,GAAG;AACT,IAAA,IAAI,EAAE,IAAI;;;ACZZ;;AAEG;;ACFH;;AAEG;;;;"}
1
+ {"version":3,"file":"daffodil-external-router-driver.mjs","names":[],"sources":["../../../libs/external-router/driver/src/interfaces/external-router-driver.interface.ts","../../../libs/external-router/driver/src/not-found-resolution.ts"],"sourcesContent":["import { Observable } from 'rxjs';\n\nimport { createSingletonInjectionToken } from '@daffodil/core';\nimport { DaffExternallyResolvableUrl } from '@daffodil/external-router';\n\nexport const {\n /**\n * The token for the `@daffodil/external-router` driver.\n */\n token: DaffExternalRouterDriver,\n /**\n * Provider function for {@link DaffExternalRouterDriver}.\n */\n provider: provideDaffExternalRouterDriver,\n} = createSingletonInjectionToken<DaffExternalRouterDriverInterface>('DaffExternalRouterDriver');\n\n/**\n * The interface for a `@daffodil/external-router` driver.\n *\n * This driver is responsible for translating a URL into a Route consumable by\n * Daffodil.\n */\nexport interface DaffExternalRouterDriverInterface {\n /**\n * Resolves a URL with a platform.\n * Returns information about the type of URL.\n *\n * @param url The full URL path qualified with file extension and leading slash but without domain. i.e. /full/path/to/thing.html\n */\n resolve(url: string): Observable<DaffExternallyResolvableUrl>;\n}\n","import { DaffExternallyResolvableUrl } from '@daffodil/external-router';\n\n/**\n * When a driver fails to find a resolution, it should return a 404.\n * This const represents the standard \"Not Found\" resolution that a driver\n * should return. Drivers are not required to return this value, but may do so\n * if they would like.\n */\nexport const DAFF_EXTERNAL_ROUTER_NOT_FOUND_RESOLUTION: DaffExternallyResolvableUrl = {\n id: null,\n url: null,\n code: 404,\n type: null,\n};\n"],"mappings":";AAKA,MAAa,EAIX,OAAO,0BAIP,UAAU,oCACR,8BAAiE,0BAA0B;ACN/F,MAAa,4CAAyE;CACpF,IAAI;CACJ,KAAK;CACL,MAAM;CACN,MAAM;AACP"}