@squiz/dxp-page-content-types 0.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/lib/Nodes/Nodes.d.ts +91 -0
- package/lib/Nodes/Nodes.js +7 -0
- package/lib/Nodes/Nodes.js.map +1 -0
- package/lib/PageContent/PageContent.d.ts +75 -0
- package/lib/PageContent/PageContent.js +7 -0
- package/lib/PageContent/PageContent.js.map +1 -0
- package/lib/Zones/Zones.d.ts +15 -0
- package/lib/Zones/Zones.js +13 -0
- package/lib/Zones/Zones.js.map +1 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.js +24 -0
- package/lib/index.js.map +1 -0
- package/package.json +28 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Squiz Australia Pty Ltd. All Rights Reserved.
|
|
4
|
+
*/
|
|
5
|
+
import { FORMATTED_TEXT_MODELS } from '@squiz/dx-json-schema-lib';
|
|
6
|
+
import { Conditions } from '../PageContent/PageContent';
|
|
7
|
+
/**
|
|
8
|
+
* Semi-resolved (referenced content items, not resolved Matrix references) formatted nodes union type.
|
|
9
|
+
* TODO: new layout node
|
|
10
|
+
*/
|
|
11
|
+
export type LayoutContentNodes = (Exclude<FORMATTED_TEXT_MODELS.v1.FormattedNodes, {
|
|
12
|
+
type: 'component';
|
|
13
|
+
}> | ComponentNode | VariationNode) & {
|
|
14
|
+
nodeId?: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Resolved component node.
|
|
18
|
+
*/
|
|
19
|
+
export type ComponentNode<T extends ContentItemBody = ContentItemBody> = {
|
|
20
|
+
/**
|
|
21
|
+
* Property which identifies this is a component node.
|
|
22
|
+
*/
|
|
23
|
+
type: 'component';
|
|
24
|
+
/**
|
|
25
|
+
* Component set ID.
|
|
26
|
+
*/
|
|
27
|
+
componentSet: string;
|
|
28
|
+
/**
|
|
29
|
+
* Component ID (in the format "namespace/component-name/version").
|
|
30
|
+
*/
|
|
31
|
+
componentId: string;
|
|
32
|
+
/**
|
|
33
|
+
* Property which identifies the render path for the component node.
|
|
34
|
+
*/
|
|
35
|
+
componentType: 'server' | 'edge';
|
|
36
|
+
/**
|
|
37
|
+
* Content item referenced by the component node. Will be undefined if component does not have a content item.
|
|
38
|
+
*/
|
|
39
|
+
contentItem?: ContentItem<T>;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Variation node variant.
|
|
43
|
+
*/
|
|
44
|
+
export type VariationNodeVariant = {
|
|
45
|
+
/**
|
|
46
|
+
* Node to render when the conditions are met.
|
|
47
|
+
*/
|
|
48
|
+
node: LayoutContentNodes | null;
|
|
49
|
+
/**
|
|
50
|
+
* The conditions required for the variant to render.
|
|
51
|
+
*/
|
|
52
|
+
conditions: Conditions;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Variation node.
|
|
56
|
+
*/
|
|
57
|
+
export type VariationNode = {
|
|
58
|
+
/**
|
|
59
|
+
* Property which identifies this as a variation node.
|
|
60
|
+
*/
|
|
61
|
+
type: 'variation';
|
|
62
|
+
/**
|
|
63
|
+
* Default variant to render when none of the conditions from the other variants are met.
|
|
64
|
+
*/
|
|
65
|
+
default: {
|
|
66
|
+
/**
|
|
67
|
+
* The node to render.
|
|
68
|
+
*/
|
|
69
|
+
node: LayoutContentNodes | null;
|
|
70
|
+
};
|
|
71
|
+
variants: Array<VariationNodeVariant>;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Structure of the resolved component's content item.
|
|
75
|
+
*/
|
|
76
|
+
export type ContentItemBody = {
|
|
77
|
+
[key: string]: string | boolean | number | null | Record<string, ContentItemBody> | Array<ContentItemBody>;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Content item for a resolved component node.
|
|
81
|
+
*/
|
|
82
|
+
export type ContentItem<T extends ContentItemBody> = {
|
|
83
|
+
/**
|
|
84
|
+
* Schema which the content is validated against.
|
|
85
|
+
*/
|
|
86
|
+
schemaName?: string;
|
|
87
|
+
/**
|
|
88
|
+
* Content of the content item.
|
|
89
|
+
*/
|
|
90
|
+
content?: T;
|
|
91
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Nodes.js","sourceRoot":"","sources":["../../src/Nodes/Nodes.ts"],"names":[],"mappings":";AAAA;;;GAGG"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Squiz Australia Pty Ltd. All Rights Reserved.
|
|
4
|
+
*/
|
|
5
|
+
import { LayoutContentNodes } from '../Nodes/Nodes';
|
|
6
|
+
export type Conditions = {
|
|
7
|
+
/**
|
|
8
|
+
* Segment required for the condition to evaluate as true.
|
|
9
|
+
*/
|
|
10
|
+
segment?: {
|
|
11
|
+
/**
|
|
12
|
+
* The code of the segment required for the condition to evaluate as true.
|
|
13
|
+
*/
|
|
14
|
+
code: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Experiment required for the condition to evaluate as true.
|
|
18
|
+
*/
|
|
19
|
+
experiment?: {
|
|
20
|
+
/**
|
|
21
|
+
* The id of the experiment.
|
|
22
|
+
*/
|
|
23
|
+
id: string;
|
|
24
|
+
/**
|
|
25
|
+
* The name of the variant for this experiment.
|
|
26
|
+
*/
|
|
27
|
+
variant: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export type RawLayout = {
|
|
31
|
+
name: 'layout-raw';
|
|
32
|
+
content: {
|
|
33
|
+
main: Array<LayoutContentNodes>;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
export type PageConfig = {
|
|
37
|
+
pageExperimentId?: string;
|
|
38
|
+
pageSegmentIds?: string[];
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Resolved page content.
|
|
42
|
+
*/
|
|
43
|
+
export type PageContent = {
|
|
44
|
+
/**
|
|
45
|
+
* Page content ID.
|
|
46
|
+
* @type {string}
|
|
47
|
+
* @memberof PageContent
|
|
48
|
+
*/
|
|
49
|
+
id: string;
|
|
50
|
+
/**
|
|
51
|
+
* User defined name of the page.
|
|
52
|
+
* @type {string}
|
|
53
|
+
* @memberof PageContent
|
|
54
|
+
*/
|
|
55
|
+
name: string;
|
|
56
|
+
/**
|
|
57
|
+
* Array of layout objects that exist on the page.
|
|
58
|
+
* @type {Array}
|
|
59
|
+
* @memberof PageContent
|
|
60
|
+
*/
|
|
61
|
+
layouts: Array<RawLayout>;
|
|
62
|
+
/**
|
|
63
|
+
* New content model with nodes grouped by zone.
|
|
64
|
+
*/
|
|
65
|
+
content?: ContentStructure;
|
|
66
|
+
/**
|
|
67
|
+
* Page level config object that exist on the page.
|
|
68
|
+
*/
|
|
69
|
+
config?: PageConfig;
|
|
70
|
+
/**
|
|
71
|
+
* Template ID.
|
|
72
|
+
*/
|
|
73
|
+
templateId?: string | null;
|
|
74
|
+
};
|
|
75
|
+
export type ContentStructure = Record<string, Array<LayoutContentNodes>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PageContent.js","sourceRoot":"","sources":["../../src/PageContent/PageContent.ts"],"names":[],"mappings":";AAAA;;;GAGG"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Squiz Australia Pty Ltd. All Rights Reserved.
|
|
4
|
+
*/
|
|
5
|
+
export declare const ZoneType: {
|
|
6
|
+
readonly page: "page";
|
|
7
|
+
readonly 'template-locked': "template-locked";
|
|
8
|
+
readonly 'template-unlocked': "template-unlocked";
|
|
9
|
+
};
|
|
10
|
+
export type ZoneType = (typeof ZoneType)[keyof typeof ZoneType];
|
|
11
|
+
export interface BaseZone<T> {
|
|
12
|
+
zoneId: string;
|
|
13
|
+
zoneName: string;
|
|
14
|
+
zoneNodes: Array<T>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Squiz Australia Pty Ltd. All Rights Reserved.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.ZoneType = void 0;
|
|
8
|
+
exports.ZoneType = {
|
|
9
|
+
page: 'page',
|
|
10
|
+
'template-locked': 'template-locked',
|
|
11
|
+
'template-unlocked': 'template-unlocked',
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=Zones.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Zones.js","sourceRoot":"","sources":["../../src/Zones/Zones.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEU,QAAA,QAAQ,GAAG;IACtB,IAAI,EAAE,MAAM;IACZ,iBAAiB,EAAE,iBAAiB;IACpC,mBAAmB,EAAE,mBAAmB;CAChC,CAAC"}
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Squiz Australia Pty Ltd. All Rights Reserved.
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
18
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
__exportStar(require("./Nodes/Nodes"), exports);
|
|
22
|
+
__exportStar(require("./PageContent/PageContent"), exports);
|
|
23
|
+
__exportStar(require("./Zones/Zones"), exports);
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;AAEH,gDAA8B;AAC9B,4DAA0C;AAC1C,gDAA8B"}
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@squiz/dxp-page-content-types",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"license": "ISC",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git@gitlab.squiz.net:developer-experience/cmp"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"lib"
|
|
12
|
+
],
|
|
13
|
+
"main": "lib/index.js",
|
|
14
|
+
"private": false,
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"compile": "npm run clean && tsc -p ./tsconfig.json",
|
|
20
|
+
"clean": "rm -rf ./lib && rm -f tsconfig.tsbuildinfo"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"typescript": "5.8.3"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@squiz/dx-json-schema-lib": "1.81.8"
|
|
27
|
+
}
|
|
28
|
+
}
|