@nascentdigital/funnel-engine 4.4.18

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 (88) hide show
  1. package/dist/LeadGen.d.ts +10 -0
  2. package/dist/LeadGen.js +51 -0
  3. package/dist/LeadGen.js.map +1 -0
  4. package/dist/RegionalSite.d.ts +31 -0
  5. package/dist/RegionalSite.js +79 -0
  6. package/dist/RegionalSite.js.map +1 -0
  7. package/dist/Site.d.ts +39 -0
  8. package/dist/Site.js +148 -0
  9. package/dist/Site.js.map +1 -0
  10. package/dist/SiteAuth.d.ts +19 -0
  11. package/dist/SiteAuth.js +103 -0
  12. package/dist/SiteAuth.js.map +1 -0
  13. package/dist/SiteContent.d.ts +45 -0
  14. package/dist/SiteContent.js +152 -0
  15. package/dist/SiteContent.js.map +1 -0
  16. package/dist/SiteEngine.d.ts +8 -0
  17. package/dist/SiteEngine.js +92 -0
  18. package/dist/SiteEngine.js.map +1 -0
  19. package/dist/SiteLayout.d.ts +49 -0
  20. package/dist/SiteLayout.js +80 -0
  21. package/dist/SiteLayout.js.map +1 -0
  22. package/dist/Sitemap.d.ts +4 -0
  23. package/dist/Sitemap.js +88 -0
  24. package/dist/Sitemap.js.map +1 -0
  25. package/dist/client.d.ts +2 -0
  26. package/dist/client.js +10 -0
  27. package/dist/client.js.map +1 -0
  28. package/dist/config/EditorConfig.d.ts +14 -0
  29. package/dist/config/EditorConfig.js +3 -0
  30. package/dist/config/EditorConfig.js.map +1 -0
  31. package/dist/config/NextConfig.d.ts +7 -0
  32. package/dist/config/NextConfig.js +3 -0
  33. package/dist/config/NextConfig.js.map +1 -0
  34. package/dist/config/ServerConfig.d.ts +12 -0
  35. package/dist/config/ServerConfig.js +35 -0
  36. package/dist/config/ServerConfig.js.map +1 -0
  37. package/dist/config/SiteConfig.d.ts +11 -0
  38. package/dist/config/SiteConfig.js +69 -0
  39. package/dist/config/SiteConfig.js.map +1 -0
  40. package/dist/config/index.d.ts +4 -0
  41. package/dist/config/index.js +21 -0
  42. package/dist/config/index.js.map +1 -0
  43. package/dist/content/Regionalization.d.ts +10 -0
  44. package/dist/content/Regionalization.js +22 -0
  45. package/dist/content/Regionalization.js.map +1 -0
  46. package/dist/content/index.d.ts +1 -0
  47. package/dist/content/index.js +18 -0
  48. package/dist/content/index.js.map +1 -0
  49. package/dist/forms/FormApi.d.ts +6 -0
  50. package/dist/forms/FormApi.js +34 -0
  51. package/dist/forms/FormApi.js.map +1 -0
  52. package/dist/forms/index.d.ts +1 -0
  53. package/dist/forms/index.js +18 -0
  54. package/dist/forms/index.js.map +1 -0
  55. package/dist/index.d.ts +12 -0
  56. package/dist/index.js +29 -0
  57. package/dist/index.js.map +1 -0
  58. package/dist/middleware/MiddlewarePriority.d.ts +4 -0
  59. package/dist/middleware/MiddlewarePriority.js +9 -0
  60. package/dist/middleware/MiddlewarePriority.js.map +1 -0
  61. package/dist/middleware/SiteMiddleware.d.ts +12 -0
  62. package/dist/middleware/SiteMiddleware.js +11 -0
  63. package/dist/middleware/SiteMiddleware.js.map +1 -0
  64. package/dist/middleware/SiteResponse.d.ts +23 -0
  65. package/dist/middleware/SiteResponse.js +133 -0
  66. package/dist/middleware/SiteResponse.js.map +1 -0
  67. package/dist/middleware/index.d.ts +4 -0
  68. package/dist/middleware/index.js +21 -0
  69. package/dist/middleware/index.js.map +1 -0
  70. package/dist/middleware/regionalization/RegionalizationMiddleware.d.ts +22 -0
  71. package/dist/middleware/regionalization/RegionalizationMiddleware.js +117 -0
  72. package/dist/middleware/regionalization/RegionalizationMiddleware.js.map +1 -0
  73. package/dist/middleware/regionalization/index.d.ts +1 -0
  74. package/dist/middleware/regionalization/index.js +18 -0
  75. package/dist/middleware/regionalization/index.js.map +1 -0
  76. package/dist/middleware/regionalization/specs/RegionalizationMiddleware.spec.d.ts +1 -0
  77. package/dist/middleware/regionalization/specs/RegionalizationMiddleware.spec.js +44 -0
  78. package/dist/middleware/regionalization/specs/RegionalizationMiddleware.spec.js.map +1 -0
  79. package/dist/query/getPages.d.ts +14 -0
  80. package/dist/query/getPages.js +22 -0
  81. package/dist/query/getPages.js.map +1 -0
  82. package/dist/query/getPreviews.d.ts +16 -0
  83. package/dist/query/getPreviews.js +38 -0
  84. package/dist/query/getPreviews.js.map +1 -0
  85. package/dist/query/index.d.ts +2 -0
  86. package/dist/query/index.js +19 -0
  87. package/dist/query/index.js.map +1 -0
  88. package/package.json +49 -0
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.RegionalizationMiddleware = void 0;
7
+ const funnel_core_1 = require("@nascentdigital/funnel-core");
8
+ const ms_1 = __importDefault(require("ms"));
9
+ const MiddlewarePriority_1 = require("../MiddlewarePriority");
10
+ const SiteMiddleware_1 = require("../SiteMiddleware");
11
+ // regionalization middleware
12
+ class RegionalizationMiddleware extends SiteMiddleware_1.SiteMiddleware {
13
+ constructor(args) {
14
+ var _a;
15
+ // construct base
16
+ super(Object.assign(Object.assign({}, args), { priority: MiddlewarePriority_1.MiddlewarePriority.REGIONALIZATION }));
17
+ // initialize instance variables
18
+ this.regionalization = args.regionalization;
19
+ this.regions = new Set(Object.keys(args.regionalization.regions)
20
+ .map(region => funnel_core_1.RegionsConfig.tryParse(args.regionalization, region))
21
+ .filter(funnel_core_1.Value.isDefined));
22
+ // set default
23
+ const defaultRegion = args.regionalization.fallback;
24
+ const defaultRegionConfig = funnel_core_1.RegionsConfig.getRegionConfig(args.regionalization, defaultRegion);
25
+ this.defaultLocale = {
26
+ region: defaultRegion,
27
+ language: (_a = defaultRegionConfig.defaultLanguage) !== null && _a !== void 0 ? _a : defaultRegionConfig.languages[0]
28
+ };
29
+ }
30
+ execute(request, response) {
31
+ var _a, _b;
32
+ // parse route
33
+ const sourceUrl = request.nextUrl.clone();
34
+ const userLocale = this.inferLocale(request);
35
+ // get source locale and target locale from incoming request
36
+ const { sourceLocale, serverLocale, pagePath } = funnel_core_1.Regionalization.parseBrowserUrl(sourceUrl, this.regionalization, userLocale);
37
+ // use target locale to get intended url for browser
38
+ const { targetLocale, targetUrl } = funnel_core_1.Regionalization.targetUrlFor(serverLocale, pagePath, this.regionalization, sourceUrl);
39
+ // if source locale is not the same as target locale, redirect to target URL
40
+ if (!funnel_core_1.Locale.isEqual(sourceLocale, targetLocale)) {
41
+ response.redirect(targetUrl.pathname);
42
+ }
43
+ // if target locale is implicit, get server url and re-write to server url path
44
+ else if (!targetLocale.region || !targetLocale.language) {
45
+ const serverUrl = funnel_core_1.Regionalization.serverUrlFor({ language: (_a = targetLocale.language) !== null && _a !== void 0 ? _a : userLocale.language, region: (_b = targetLocale.region) !== null && _b !== void 0 ? _b : userLocale.region }, pagePath, sourceUrl);
46
+ response.rewrite(serverUrl.pathname);
47
+ }
48
+ // else continue for explicit source locale
49
+ else {
50
+ response.continue();
51
+ }
52
+ // update cookie
53
+ response.setCookie(RegionalizationMiddleware.cookieName, funnel_core_1.Locale.toData(serverLocale), Date.now() + (0, ms_1.default)('30d'));
54
+ }
55
+ isLocaleValid(locale) {
56
+ // bail if there's no locale
57
+ if (!locale) {
58
+ return false;
59
+ }
60
+ // fail if region doesn't match
61
+ const { regionalization, regions } = this;
62
+ if (!regions.has(locale.region)) {
63
+ return false;
64
+ }
65
+ // otherwise, ensure language is in region's set
66
+ return funnel_core_1.RegionsConfig.getRegionConfig(regionalization, locale.region)
67
+ .languages
68
+ .includes(locale.language);
69
+ }
70
+ inferLocale(request) {
71
+ var _a, _b;
72
+ // leverage existing locale (if set)
73
+ const locale = RegionalizationMiddleware.findLocale(request.cookies);
74
+ if (locale && this.isLocaleValid(locale)) {
75
+ return locale;
76
+ }
77
+ // try to infer region if possible (or fallback)
78
+ const { regionalization, regions, defaultLocale } = this;
79
+ const headers = request.headers;
80
+ const inferredRegion = funnel_core_1.RegionsConfig.tryParse(regionalization, (_a = headers.get('X-Vercel-IP-Country')) !== null && _a !== void 0 ? _a : undefined);
81
+ const region = inferredRegion && regions.has(inferredRegion)
82
+ ? inferredRegion
83
+ : defaultLocale.region;
84
+ // infer language (if possible) or fallback
85
+ const regionConfig = funnel_core_1.RegionsConfig.getRegionConfig(regionalization, region);
86
+ const { languages } = regionConfig;
87
+ const clientLanguages = ((_b = headers.get('Accept-Language')) !== null && _b !== void 0 ? _b : '').split(',');
88
+ let language = defaultLocale.language;
89
+ const codeSplit = /[-;]/;
90
+ for (let i = 0; i < clientLanguages.length; ++i) {
91
+ // transform code (or bail)
92
+ const [code] = clientLanguages[i].split(codeSplit);
93
+ const lang = funnel_core_1.Language.tryParse(code);
94
+ // stop processing on match
95
+ if (lang && languages.includes(lang)) {
96
+ language = lang;
97
+ break;
98
+ }
99
+ }
100
+ // return locale
101
+ return { region, language };
102
+ }
103
+ }
104
+ exports.RegionalizationMiddleware = RegionalizationMiddleware;
105
+ // extension
106
+ (function (RegionalizationMiddleware) {
107
+ // constants
108
+ RegionalizationMiddleware.cookieName = 'funnel.locale';
109
+ // helpers
110
+ function findLocale(cookies) {
111
+ var _a;
112
+ const localeData = (_a = cookies.get(RegionalizationMiddleware.cookieName)) === null || _a === void 0 ? void 0 : _a.value;
113
+ return localeData ? funnel_core_1.Locale.tryParse(localeData) : undefined;
114
+ }
115
+ RegionalizationMiddleware.findLocale = findLocale;
116
+ })(RegionalizationMiddleware || (exports.RegionalizationMiddleware = RegionalizationMiddleware = {}));
117
+ //# sourceMappingURL=RegionalizationMiddleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RegionalizationMiddleware.js","sourceRoot":"","sources":["../../../src/middleware/regionalization/RegionalizationMiddleware.ts"],"names":[],"mappings":";;;;;;AAAA,6DAAmG;AACnG,4CAAmB;AAInB,8DAAwD;AACxD,sDAAgD;AAIhD,6BAA6B;AAC7B,MAAa,yBAA2D,SAAQ,+BAAc;IAO5F,YAAY,IAAwD;;QAElE,iBAA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,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;YAClD,MAAM,IAAI,GAAG,sBAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;YAEpC,2BAA2B;YAC3B,IAAI,IAAI,IAAI,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;gBACrC,QAAQ,GAAG,IAAI,CAAA;gBACf,MAAK;YACP,CAAC;QACH,CAAC;QAED,gBAAgB;QAChB,OAAO,EAAC,MAAM,EAAE,QAAQ,EAAC,CAAA;IAC3B,CAAC;CACF;AAjID,8DAiIC;AAGD,YAAY;AACZ,WAAiB,yBAAyB;IAExC,YAAY;IACC,oCAAU,GAAG,eAAe,CAAA;IASzC,UAAU;IACV,SAAgB,UAAU,CAAyB,OAAgD;;QACjG,MAAM,UAAU,GAAG,MAAA,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,UAAU,CAAC,0CAAE,KAAK,CAAA;QAC3E,OAAO,UAAU,CAAC,CAAC,CAAC,oBAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IAC7D,CAAC;IAHe,oCAAU,aAGzB,CAAA;AACH,CAAC,EAjBgB,yBAAyB,yCAAzB,yBAAyB,QAiBzC"}
@@ -0,0 +1 @@
1
+ export * from './RegionalizationMiddleware';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./RegionalizationMiddleware"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/middleware/regionalization/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8DAA2C"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ describe('RegionalizationMiddleware getChangeMechanism when url truncation is ', () => {
4
+ describe('none', () => {
5
+ it('should rewrite when the locale has the same region and language as the initial path\'s', () => { });
6
+ it('should redirect when the locale has the same region as the initial path\'s but the language is different', () => { });
7
+ it('should redirect when the locale has different region from the initial path\'s but the language is the same', () => { });
8
+ it('should redirect when the locale has different region and language from the initial path\'s', () => { });
9
+ });
10
+ describe('full', () => {
11
+ describe('and the initial path has the region and language', () => {
12
+ it('should rewrite when the locale has the same region and language as the initial path\'s', () => { });
13
+ it('should redirect when the locale has the same region as the initial path\'s but the language is different', () => { });
14
+ it('should redirect when the locale has different region from the initial path\'s but the language is the same', () => { });
15
+ it('should redirect when the locale has different region and language from the initial path\'s', () => { });
16
+ });
17
+ describe('and the initial path has the region and language truncated', () => {
18
+ it('should rewrite when the locale has the default region and language', () => { });
19
+ it('should redirect when the locale has the default region but a non default language', () => { });
20
+ it('should redirect when the locale has a non default region and the default language', () => { });
21
+ it('should redirect when the locale has a non default region and language', () => { });
22
+ });
23
+ });
24
+ describe('partial', () => {
25
+ describe('and the initial path has the region and language', () => {
26
+ it('should rewrite when the locale has the same region and language as the initial path\'s', () => { });
27
+ it('should redirect when the locale has the same region as the initial path\'s but the language is different', () => { });
28
+ it('should redirect when the locale has different region from the initial path\'s but the language is the same', () => { });
29
+ it('should redirect when the locale has different region and language from the initial path\'s', () => { });
30
+ });
31
+ describe('and the initial path has the region but the language is truncated', () => {
32
+ it('should redirect when the locale has a different region from the initial path and a default language', () => { });
33
+ it('should rewrite when the locale has a the same region as the initial path and a default language', () => { });
34
+ it('should redirect when the locale has the same region as the initial path but a non default language', () => { });
35
+ });
36
+ describe('and the initial path has the region and language truncated', () => {
37
+ it('should rewrite when the locale has the default region and language', () => { });
38
+ it('should redirect when the locale has a non default region but the default language', () => { });
39
+ it('should redirect when the locale has the default region but a non default language', () => { });
40
+ it('should redirect when the locale has a non default region and language', () => { });
41
+ });
42
+ });
43
+ });
44
+ //# sourceMappingURL=RegionalizationMiddleware.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RegionalizationMiddleware.spec.js","sourceRoot":"","sources":["../../../../src/middleware/regionalization/specs/RegionalizationMiddleware.spec.ts"],"names":[],"mappings":";;AAAA,QAAQ,CAAC,sEAAsE,EAAE,GAAG,EAAE;IAEpF,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE;QAEpB,EAAE,CAAC,wFAAwF,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;QAEtG,EAAE,CAAC,0GAA0G,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;QAExH,EAAE,CAAC,4GAA4G,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;QAE1H,EAAE,CAAC,4FAA4F,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;IAC5G,CAAC,CAAC,CAAA;IAEF,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE;QAEpB,QAAQ,CAAC,kDAAkD,EAAE,GAAG,EAAE;YAEhE,EAAE,CAAC,wFAAwF,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;YAEtG,EAAE,CAAC,0GAA0G,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;YAExH,EAAE,CAAC,4GAA4G,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;YAE1H,E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C,CAAC,CAAA;YAElF,EAAE,CAAC,mFAAmF,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;YAEjG,EAAE,CAAC,mFAAmF,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;YAEjG,EAAE,CAAC,uEAAuE,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;QACvF,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -0,0 +1,14 @@
1
+ import { Pagination } from '@nascentdigital/funnel-cms';
2
+ import { Language, Schema } from '@nascentdigital/funnel-core';
3
+ export declare function getPages(query: getPages.Args): Promise<Pagination.Paginated<Schema.Page.Data.AsLink>>;
4
+ export declare namespace getPages {
5
+ type Args = {
6
+ preview?: boolean;
7
+ brand?: string;
8
+ type: Schema.Page.Type | Schema.Page.Type[];
9
+ region?: string;
10
+ language?: Language;
11
+ tags?: Schema.Tag.Data | Schema.Tag.Data[];
12
+ pagination: Pagination;
13
+ };
14
+ }
@@ -0,0 +1,22 @@
1
+ 'use server';
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.getPages = getPages;
5
+ const funnel_cms_1 = require("@nascentdigital/funnel-cms");
6
+ const funnel_core_1 = require("@nascentdigital/funnel-core");
7
+ // hooks
8
+ async function getPages(query) {
9
+ // setup args
10
+ const { preview = false, type, brand, language, region, tags, pagination } = query;
11
+ // start query
12
+ return funnel_cms_1.ContentClient.forServer().pages.search({
13
+ version: preview ? 'draft' : 'published',
14
+ brand,
15
+ region,
16
+ language,
17
+ type,
18
+ tags: funnel_core_1.ArrayUtils.coerce(tags),
19
+ pagination
20
+ });
21
+ }
22
+ //# sourceMappingURL=getPages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getPages.js","sourceRoot":"","sources":["../../src/query/getPages.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;;;AAMZ,4BAeC;AApBD,2DAAoE;AACpE,6DAAwE;AAGxE,QAAQ;AACD,KAAK,UAAU,QAAQ,CAAC,KAAoB;IAEjD,aAAa;IACb,MAAM,EAAC,OAAO,GAAG,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAC,GAAG,KAAK,CAAA;IAEhF,cAAc;IACd,OAAO,0BAAa,CAAC,SAAS,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC;QAC5C,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW;QACxC,KAAK;QACL,MAAM;QACN,QAAQ;QACR,IAAI;QACJ,IAAI,EAAE,wBAAU,CAAC,MAAM,CAAC,IAAI,CAAC;QAC7B,UAAU;KACX,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { PageClient, Pagination } from '@nascentdigital/funnel-cms';
2
+ import { Language, Schema } from '@nascentdigital/funnel-core';
3
+ export declare function getPreviews<TPage extends Schema.Page = Schema.Page>(query: getPreviews.Args): Promise<getPreviews.Result<TPage>>;
4
+ export declare namespace getPreviews {
5
+ type Args = {
6
+ preview?: boolean;
7
+ brand: string;
8
+ type: Schema.Page.Type | Schema.Page.Type[];
9
+ region?: string;
10
+ language?: Language;
11
+ tags?: Schema.Tag.Data | Schema.Tag.Data[];
12
+ tagsMatch?: PageClient.Query.TagsMatch;
13
+ pagination: Pagination;
14
+ };
15
+ type Result<TPage extends Schema.Page> = Pagination.Paginated<Schema.Page.LinkedData.AsPreview<TPage>>;
16
+ }
@@ -0,0 +1,38 @@
1
+ 'use server';
2
+ "use strict";
3
+ var __rest = (this && this.__rest) || function (s, e) {
4
+ var t = {};
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
6
+ t[p] = s[p];
7
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
8
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
9
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
10
+ t[p[i]] = s[p[i]];
11
+ }
12
+ return t;
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.getPreviews = getPreviews;
16
+ const funnel_cms_1 = require("@nascentdigital/funnel-cms");
17
+ const funnel_core_1 = require("@nascentdigital/funnel-core");
18
+ // hooks
19
+ async function getPreviews(query) {
20
+ // setup args
21
+ const { preview = false, type, brand, language, region, tags, tagsMatch, pagination } = query;
22
+ // start query
23
+ const _a = await funnel_cms_1.ContentClient.forServer().pages.getPreviews({
24
+ version: preview ? 'draft' : 'published',
25
+ brand,
26
+ region,
27
+ language,
28
+ type,
29
+ tags: funnel_core_1.ArrayUtils.coerce(tags),
30
+ tagsMatch,
31
+ pagination
32
+ }), { items } = _a, paginationResults = __rest(_a, ["items"]);
33
+ // convert items from data to linked data
34
+ const linkedItems = items.map(item => funnel_core_1.Schema.LinkedData.resolveStatic({ unlinkedData: item }));
35
+ // return with pagination results
36
+ return Object.assign(Object.assign({}, paginationResults), { items: linkedItems });
37
+ }
38
+ //# sourceMappingURL=getPreviews.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getPreviews.js","sourceRoot":"","sources":["../../src/query/getPreviews.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;;;;;;;;;;;;;;AAMZ,kCA2BC;AAhCD,2DAAgF;AAChF,6DAAwE;AAGxE,QAAQ;AACD,KAAK,UAAU,WAAW,CAA0C,KAAuB;IAEhG,aAAa;IACb,MAAM,EAAC,OAAO,GAAG,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAC,GAAG,KAAK,CAAA;IAE3F,cAAc;IACd,MAAM,KAAgC,MAAM,0BAAa,CAAC,SAAS,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC;QACtF,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW;QACxC,KAAK;QACL,MAAM;QACN,QAAQ;QACR,IAAI;QACJ,IAAI,EAAE,wBAAU,CAAC,MAAM,CAAC,IAAI,CAAC;QAC7B,SAAS;QACT,UAAU;KACX,CAAC,EATI,EAAC,KAAK,OASV,EATe,iBAAiB,cAA5B,SAA6B,CASjC,CAAA;IAEF,yCAAyC;IACzC,MAAM,WAAW,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CACnC,oBAAM,CAAC,UAAU,CAAC,aAAa,CAA0C,EAAC,YAAY,EAAE,IAAI,EAAC,CAAC,CAC/F,CAAA;IAED,iCAAiC;IACjC,uCACK,iBAAiB,KACpB,KAAK,EAAE,WAAW,IACnB;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './getPages';
2
+ export * from './getPreviews';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./getPages"), exports);
18
+ __exportStar(require("./getPreviews"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/query/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA0B;AAC1B,gDAA6B"}
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@nascentdigital/funnel-engine",
3
+ "version": "4.4.18",
4
+ "publishConfig": {
5
+ "registry": "https://registry.npmjs.org/",
6
+ "access": "restricted"
7
+ },
8
+ "repository": {
9
+ "url": "git+https://github.com/nascentdigital/funnel.git",
10
+ "directory": "libs/engine"
11
+ },
12
+ "main": "dist/index.js",
13
+ "types": "dist/index.d.ts",
14
+ "exports": {
15
+ ".": "./dist/index.js",
16
+ "./config": "./dist/config/index.js"
17
+ },
18
+ "files": [
19
+ "dist"
20
+ ],
21
+ "engines": {
22
+ "node": ">=22.0.0"
23
+ },
24
+ "scripts": {
25
+ "build": "tsc -P tsconfig.build.json",
26
+ "clean": "rimraf -I dist"
27
+ },
28
+ "peerDependencies": {
29
+ "@nascentdigital/funnel-cms": "*",
30
+ "@nascentdigital/funnel-core": "*",
31
+ "@nascentdigital/funnel-services": "*",
32
+ "@nascentdigital/funnel-ui": "*",
33
+ "next": "^15",
34
+ "react": "^19",
35
+ "react-dom": "^19"
36
+ },
37
+ "dependencies": {
38
+ "ms": "^3.0.0-canary.1"
39
+ },
40
+ "devDependencies": {
41
+ "jest": "^29",
42
+ "next": "^15",
43
+ "react": "^19",
44
+ "react-dom": "^19",
45
+ "ts-jest": "^29",
46
+ "type-fest": "^4"
47
+ },
48
+ "gitHead": "d1bfd4468426b7326bd9662cd169242867025f5e"
49
+ }