@nascentdigital/funnel-core 6.0.0 → 6.1.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/dist/schema/Page.d.ts +11 -7
- package/dist/schema/Page.js +7 -4
- package/dist/schema/Site.js +9 -0
- package/package.json +2 -2
package/dist/schema/Page.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ import { Section } from './Section';
|
|
|
14
14
|
import type { Seo } from './Seo';
|
|
15
15
|
import { Tag } from './Tag';
|
|
16
16
|
import { TagGroup } from './TagGroup';
|
|
17
|
-
export declare class Page<TContent extends Page.Content =
|
|
17
|
+
export declare class Page<TContent extends Page.Content = any, TPreview extends Page.PreviewTarget<TContent> = any> {
|
|
18
18
|
private _type?;
|
|
19
19
|
readonly variant: Page.Variant;
|
|
20
20
|
readonly route: Localized.Maybe<PageRoute>;
|
|
@@ -25,13 +25,14 @@ export declare class Page<TContent extends Page.Content = Page.Content, TPreview
|
|
|
25
25
|
readonly optional: boolean;
|
|
26
26
|
readonly preview?: TPreview;
|
|
27
27
|
readonly content: TContent;
|
|
28
|
+
readonly navigation: ReadonlyArray<Page.Content.BlockKeys<TContent>>;
|
|
28
29
|
readonly parent?: string;
|
|
29
30
|
private constructor();
|
|
30
31
|
get type(): Page.Type;
|
|
31
32
|
parseTags(tags: Tag.Data[]): Tag[];
|
|
32
33
|
bind(type: Page.Type): void;
|
|
33
|
-
static static<TContent extends Page.Content, TPreview extends Page.PreviewTarget<TContent>>({ route, ...args }: Page.FactoryArgs.Static<TContent, TPreview>): Page<TContent, TPreview>;
|
|
34
|
-
static dynamic<TContent extends Page.Content, TPreview extends Page.PreviewTarget<TContent>>(args: Page.FactoryArgs.Dynamic<TContent, TPreview>): Page<TContent, TPreview>;
|
|
34
|
+
static static<TContent extends Page.Content, TPreview extends Page.PreviewTarget<TContent>>({ route, navigation, ...args }: Page.FactoryArgs.Static<TContent, TPreview>): Page<TContent, TPreview>;
|
|
35
|
+
static dynamic<TContent extends Page.Content, TPreview extends Page.PreviewTarget<TContent>>({ navigation, ...args }: Page.FactoryArgs.Dynamic<TContent, TPreview>): Page<TContent, TPreview>;
|
|
35
36
|
}
|
|
36
37
|
export declare namespace Page {
|
|
37
38
|
type Content = Record<string, Content.Item>;
|
|
@@ -40,12 +41,13 @@ export declare namespace Page {
|
|
|
40
41
|
type Blocks<TContent extends Content = Content> = {
|
|
41
42
|
[TKey in StringKeyOf<TContent>]: TContent[TKey] extends Block ? TContent[TKey] : never;
|
|
42
43
|
};
|
|
44
|
+
type BlockKeys<TContent extends Content = Content> = StringKeyOf<Blocks<TContent>>;
|
|
43
45
|
}
|
|
44
46
|
type PreviewTarget<TContent extends Content = Content> = StringKeyOf<Content.Blocks<TContent>>;
|
|
45
|
-
type DisplayName<TContent extends Content =
|
|
47
|
+
type DisplayName<TContent extends Content = any> = DisplayName.For<TContent>;
|
|
46
48
|
namespace DisplayName {
|
|
47
49
|
type For<TContent extends Content> = {
|
|
48
|
-
[TKey in StringKeyOf<Content.Blocks<TContent>>]: TContent[TKey] extends Block<infer TId, infer TFields> ? `${TKey}.${
|
|
50
|
+
[TKey in StringKeyOf<Content.Blocks<TContent>>]: TContent[TKey] extends Block<infer TId, infer TFields> ? StringKeyOf<Fields.TextLikeFields<TFields>> extends string ? `${TKey}.${StringKeyOf<Fields.TextLikeFields<TFields>>}` : never : never;
|
|
49
51
|
}[StringKeyOf<Content.Blocks<TContent>>];
|
|
50
52
|
}
|
|
51
53
|
type Update = Update.Page | Update.BlockCreate | Update.BlockDelete | Update.SectionInsert | Update.SectionDelete | Update.SectionReorder | Update.SectionBlockName | Update.ObjectInsert | Update.ArrayInsert | Update.ArrayDelete | Update.ArrayReorder | Update.Value;
|
|
@@ -229,7 +231,7 @@ export declare namespace Page {
|
|
|
229
231
|
type Prop = Props.Id | Extract<Props.Content, 'preview'> | Props.Links | Props.Audit;
|
|
230
232
|
const props: ReadonlyArray<Prop>;
|
|
231
233
|
function from(data: LegacyData): AsPreview;
|
|
232
|
-
function filter(data: LegacyData | AsPreview): data is
|
|
234
|
+
function filter(data: LegacyData | AsPreview): data is AsPreview;
|
|
233
235
|
}
|
|
234
236
|
type AsContent<TPage extends Page = Page, TRegion extends string = string> = Pick<LegacyData<TPage, TRegion>, AsContent.Prop>;
|
|
235
237
|
namespace AsContent {
|
|
@@ -325,6 +327,7 @@ export declare namespace Page {
|
|
|
325
327
|
optional?: boolean;
|
|
326
328
|
preview?: TPreview;
|
|
327
329
|
content: TContent;
|
|
330
|
+
navigation: ReadonlyArray<Content.BlockKeys<TContent>>;
|
|
328
331
|
};
|
|
329
332
|
type Static<TContent extends Content = Content, TPreview extends PreviewTarget<TContent> = PreviewTarget<TContent>> = Base<TContent, TPreview> & {
|
|
330
333
|
variant: Extract<Variant, 'static'>;
|
|
@@ -341,8 +344,9 @@ export declare namespace Page {
|
|
|
341
344
|
}
|
|
342
345
|
}
|
|
343
346
|
namespace FactoryArgs {
|
|
344
|
-
type Base<TContent extends Content, TPreview extends PreviewTarget<TContent>> = Omit<ConstructorArgs.Base<TContent, TPreview>, 'route'> & {
|
|
347
|
+
type Base<TContent extends Content, TPreview extends PreviewTarget<TContent>> = Omit<ConstructorArgs.Base<TContent, TPreview>, 'route' | 'navigation'> & {
|
|
345
348
|
route: Localized.Maybe<string>;
|
|
349
|
+
navigation?: Content.BlockKeys<TContent> | ReadonlyArray<Content.BlockKeys<TContent>>;
|
|
346
350
|
};
|
|
347
351
|
export type Static<TContent extends Content, TPreview extends PreviewTarget<TContent>> = Base<TContent, TPreview>;
|
|
348
352
|
export type Dynamic<TContent extends Content, TPreview extends PreviewTarget<TContent>> = Base<TContent, TPreview> & Pick<ConstructorArgs.Dynamic<TContent, TPreview>, 'parent'>;
|
package/dist/schema/Page.js
CHANGED
|
@@ -30,6 +30,7 @@ class Page {
|
|
|
30
30
|
this.optional = (_b = args.optional) !== null && _b !== void 0 ? _b : false;
|
|
31
31
|
this.preview = args.preview;
|
|
32
32
|
this.content = args.content;
|
|
33
|
+
this.navigation = args.navigation;
|
|
33
34
|
// or dynamic args (basic)
|
|
34
35
|
if (Page.ConstructorArgs.Dynamic.filter(args)) {
|
|
35
36
|
this.parent = args.parent;
|
|
@@ -65,10 +66,11 @@ class Page {
|
|
|
65
66
|
this._type = type;
|
|
66
67
|
}
|
|
67
68
|
static static(_a) {
|
|
68
|
-
var { route } = _a, args = __rest(_a, ["route"]);
|
|
69
|
-
return new Page(Object.assign({ variant: 'static', route: route }, args));
|
|
69
|
+
var { route, navigation = [] } = _a, args = __rest(_a, ["route", "navigation"]);
|
|
70
|
+
return new Page(Object.assign({ variant: 'static', route: route, navigation: typeof navigation === 'string' ? [navigation] : navigation }, args));
|
|
70
71
|
}
|
|
71
|
-
static dynamic(
|
|
72
|
+
static dynamic(_a) {
|
|
73
|
+
var { navigation = [] } = _a, args = __rest(_a, ["navigation"]);
|
|
72
74
|
return new Page({
|
|
73
75
|
variant: 'dynamic',
|
|
74
76
|
route: args.route,
|
|
@@ -76,8 +78,9 @@ class Page {
|
|
|
76
78
|
name: args.name,
|
|
77
79
|
preview: args.preview,
|
|
78
80
|
content: args.content,
|
|
81
|
+
navigation: typeof navigation === 'string' ? [navigation] : navigation,
|
|
79
82
|
displayName: args.displayName,
|
|
80
|
-
parent: args.parent
|
|
83
|
+
parent: args.parent
|
|
81
84
|
});
|
|
82
85
|
}
|
|
83
86
|
}
|
package/dist/schema/Site.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Site = void 0;
|
|
4
|
+
const app_1 = require("../app");
|
|
4
5
|
const errors_1 = require("../errors");
|
|
5
6
|
const utils_1 = require("../utils");
|
|
6
7
|
const field_1 = require("./field");
|
|
@@ -11,6 +12,14 @@ class Site {
|
|
|
11
12
|
// initialize instance variables
|
|
12
13
|
this.regions = args.regions;
|
|
13
14
|
this.collections = args.collections;
|
|
15
|
+
// blow up if we're mossing a region
|
|
16
|
+
const { regionalization } = app_1.AppConfig.brandConfig();
|
|
17
|
+
const expectedRegionIds = new Set(app_1.RegionsConfig.getRegions(regionalization).map(({ id }) => id));
|
|
18
|
+
const providedRegionIds = new Set(Object.keys(this.regions));
|
|
19
|
+
const missingRegionIds = expectedRegionIds.difference(providedRegionIds);
|
|
20
|
+
if (missingRegionIds.size > 0) {
|
|
21
|
+
throw new errors_1.ArgumentError('Site configuration is missing the following region(s): ' + missingRegionIds.values().toArray().join(', '));
|
|
22
|
+
}
|
|
14
23
|
// bind pages within each region
|
|
15
24
|
Object.values(this.regions).forEach(region => Object.entries(region).forEach(([pageType, page]) => page.bind(pageType)));
|
|
16
25
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nascentdigital/funnel-core",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"url": "git+https://github.com/nascentdigital/funnel.git",
|
|
6
6
|
"directory": "libs/core"
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"jest-tsd": "^0.2.2",
|
|
66
66
|
"ts-jest": "^29.3.2"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "7b491cfadfcb458bf5882ec8da6c9c5401d61312"
|
|
69
69
|
}
|