@platecms/delta-client 0.6.0 → 1.0.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/README.md +304 -96
- package/package.json +2 -2
- package/src/schema/index.d.ts +14 -2
- package/src/schema/index.js +15 -5
- package/src/schema/index.js.map +1 -1
- package/src/schema/lib/schemas/array.d.ts +6 -0
- package/src/schema/lib/schemas/array.js +20 -0
- package/src/schema/lib/schemas/array.js.map +1 -0
- package/src/schema/lib/schemas/asset.d.ts +5 -0
- package/src/schema/lib/schemas/asset.js +14 -0
- package/src/schema/lib/schemas/asset.js.map +1 -0
- package/src/schema/lib/schemas/baseSchema.d.ts +10 -0
- package/src/schema/lib/schemas/baseSchema.js +36 -0
- package/src/schema/lib/schemas/baseSchema.js.map +1 -0
- package/src/schema/lib/schemas/boolean.d.ts +4 -0
- package/src/schema/lib/schemas/boolean.js +15 -0
- package/src/schema/lib/schemas/boolean.js.map +1 -0
- package/src/schema/lib/schemas/buildingBlock.d.ts +7 -0
- package/src/schema/lib/schemas/buildingBlock.js +26 -0
- package/src/schema/lib/schemas/buildingBlock.js.map +1 -0
- package/src/schema/lib/schemas/contentItem.d.ts +6 -0
- package/src/schema/lib/schemas/contentItem.js +26 -0
- package/src/schema/lib/schemas/contentItem.js.map +1 -0
- package/src/schema/lib/schemas/contentType.d.ts +5 -0
- package/src/schema/lib/schemas/contentType.js +14 -0
- package/src/schema/lib/schemas/contentType.js.map +1 -0
- package/src/schema/lib/schemas/date.d.ts +5 -0
- package/src/schema/lib/schemas/date.js +19 -0
- package/src/schema/lib/schemas/date.js.map +1 -0
- package/src/schema/lib/schemas/gridPlacement.d.ts +5 -0
- package/src/schema/lib/schemas/gridPlacement.js +14 -0
- package/src/schema/lib/schemas/gridPlacement.js.map +1 -0
- package/src/schema/lib/schemas/index.d.ts +55 -0
- package/src/schema/lib/schemas/index.js +33 -0
- package/src/schema/lib/schemas/index.js.map +1 -0
- package/src/schema/lib/schemas/number.d.ts +4 -0
- package/src/schema/lib/schemas/number.js +15 -0
- package/src/schema/lib/schemas/number.js.map +1 -0
- package/src/schema/lib/schemas/pathPart.d.ts +5 -0
- package/src/schema/lib/schemas/pathPart.js +14 -0
- package/src/schema/lib/schemas/pathPart.js.map +1 -0
- package/src/schema/lib/schemas/smartText.d.ts +5 -0
- package/src/schema/lib/schemas/smartText.js +14 -0
- package/src/schema/lib/schemas/smartText.js.map +1 -0
- package/src/schema/lib/schemas/string.d.ts +4 -0
- package/src/schema/lib/schemas/string.js +15 -0
- package/src/schema/lib/schemas/string.js.map +1 -0
- package/src/schema/lib/schemas/tag.d.ts +5 -0
- package/src/schema/lib/schemas/tag.js +14 -0
- package/src/schema/lib/schemas/tag.js.map +1 -0
- package/src/schema/lib/utils/isContentValue.d.ts +2 -0
- package/src/schema/lib/utils/isContentValue.js +17 -0
- package/src/schema/lib/utils/isContentValue.js.map +1 -0
- package/src/schema/lib/utils/isPrimitiveValue.d.ts +5 -0
- package/src/schema/lib/utils/isPrimitiveValue.js +8 -0
- package/src/schema/lib/utils/isPrimitiveValue.js.map +1 -0
- package/src/schema/lib/nodes.d.ts +0 -46
- package/src/schema/lib/nodes.js +0 -14
- package/src/schema/lib/nodes.js.map +0 -1
- package/src/schema/lib/parser.d.ts +0 -12
- package/src/schema/lib/parser.js +0 -49
- package/src/schema/lib/parser.js.map +0 -1
- package/src/schema/lib/schema.d.ts +0 -17
- package/src/schema/lib/schema.js +0 -65
- package/src/schema/lib/schema.js.map +0 -1
- package/src/schema/lib/utils.d.ts +0 -12
- package/src/schema/lib/utils.js +0 -66
- package/src/schema/lib/utils.js.map +0 -1
package/src/schema/lib/schema.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.s = void 0;
|
|
4
|
-
const lodash_1 = require("lodash");
|
|
5
|
-
const nodes_1 = require("./nodes");
|
|
6
|
-
const delta_castscript_1 = require("@platecms/delta-castscript");
|
|
7
|
-
class Schema {
|
|
8
|
-
object(data) {
|
|
9
|
-
return {
|
|
10
|
-
type: nodes_1.Type.OBJECT,
|
|
11
|
-
data,
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
array(data, limit) {
|
|
15
|
-
return {
|
|
16
|
-
type: nodes_1.Type.ARRAY,
|
|
17
|
-
data: (0, lodash_1.isArray)(data) ? data : [data],
|
|
18
|
-
limit,
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
asset(data) {
|
|
22
|
-
return {
|
|
23
|
-
type: nodes_1.Type.ASSET,
|
|
24
|
-
data: data,
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
primitive(data) {
|
|
28
|
-
return {
|
|
29
|
-
type: nodes_1.Type.PRIMITIVE,
|
|
30
|
-
data,
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
string(data) {
|
|
34
|
-
return this.primitive(data);
|
|
35
|
-
}
|
|
36
|
-
number(data) {
|
|
37
|
-
return this.primitive(data);
|
|
38
|
-
}
|
|
39
|
-
cast(data) {
|
|
40
|
-
return {
|
|
41
|
-
type: nodes_1.Type.CAST,
|
|
42
|
-
data,
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
smartText(data) {
|
|
46
|
-
return {
|
|
47
|
-
type: nodes_1.Type.CAST,
|
|
48
|
-
data: (0, lodash_1.isString)(data) ? (0, delta_castscript_1.c)("root", data) : data,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
gridPlacement(data) {
|
|
52
|
-
return {
|
|
53
|
-
type: nodes_1.Type.GRID_PLACEMENT,
|
|
54
|
-
data: data,
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
pathPart(data) {
|
|
58
|
-
return {
|
|
59
|
-
type: nodes_1.Type.PATH_PART,
|
|
60
|
-
data: data,
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
exports.s = new Schema();
|
|
65
|
-
//# sourceMappingURL=schema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../../../../packages/delta-client/src/schema/lib/schema.ts"],"names":[],"mappings":";;;AAAA,mCAA2C;AAC3C,mCAUiB;AAEjB,iEAA+C;AAE/C,MAAM,MAAM;IACH,MAAM,CAAiC,IAAO;QACnD,OAAO;YACL,IAAI,EAAE,YAAI,CAAC,MAAM;YACjB,IAAI;SACL,CAAC;IACJ,CAAC;IAEM,KAAK,CAAiB,IAAa,EAAE,KAAc;QACxD,OAAO;YACL,IAAI,EAAE,YAAI,CAAC,KAAK;YAChB,IAAI,EAAE,IAAA,gBAAO,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;YACnC,KAAK;SACN,CAAC;IACJ,CAAC;IAEM,KAAK,CAAC,IAAoB;QAC/B,OAAO;YACL,IAAI,EAAE,YAAI,CAAC,KAAK;YAChB,IAAI,EAAE,IAAa;SACpB,CAAC;IACJ,CAAC;IAEM,SAAS,CAAsC,IAAO;QAC3D,OAAO;YACL,IAAI,EAAE,YAAI,CAAC,SAAS;YACpB,IAAI;SACL,CAAC;IACJ,CAAC;IAEM,MAAM,CAAC,IAAY;QACxB,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAEM,MAAM,CAAC,IAAY;QACxB,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAEM,IAAI,CAAC,IAAU;QACpB,OAAO;YACL,IAAI,EAAE,YAAI,CAAC,IAAI;YACf,IAAI;SACL,CAAC;IACJ,CAAC;IAEM,SAAS,CAAC,IAAmB;QAClC,OAAO;YACL,IAAI,EAAE,YAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAA,iBAAQ,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAA,oBAAC,EAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI;SAC9C,CAAC;IACJ,CAAC;IAEM,aAAa,CAAC,IAA4B;QAC/C,OAAO;YACL,IAAI,EAAE,YAAI,CAAC,cAAc;YACzB,IAAI,EAAE,IAAqB;SAC5B,CAAC;IACJ,CAAC;IAEM,QAAQ,CAAC,IAAuB;QACrC,OAAO;YACL,IAAI,EAAE,YAAI,CAAC,SAAS;YACpB,IAAI,EAAE,IAAgB;SACvB,CAAC;IACJ,CAAC;CACF;AAIY,QAAA,CAAC,GAAG,IAAI,MAAM,EAAE,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { ArrayNode, AssetNode, CastNode, GridPlacementNode, Node, ObjectNode, PathPartNode, PrimitiveNode } from "./nodes";
|
|
2
|
-
import { BuildingBlockFieldFulfillment, ContentItem, ContentValue } from "./../../__generated__/graphql";
|
|
3
|
-
declare function isObjectNode<T extends Record<string, Node>>(node: Node): node is ObjectNode<T>;
|
|
4
|
-
declare function isArrayNode<T extends Node>(node: Node): node is ArrayNode<T>;
|
|
5
|
-
declare function isPrimitiveNode<T extends boolean | number | string>(node: Node): node is PrimitiveNode<T>;
|
|
6
|
-
declare function isAssetNode(node: Node): node is AssetNode;
|
|
7
|
-
declare function isCastNode(node: Node): node is CastNode;
|
|
8
|
-
declare function isGridPlacementNode(node: Node): node is GridPlacementNode;
|
|
9
|
-
declare function isPathPartNode(node: Node): node is PathPartNode;
|
|
10
|
-
export declare function extractContentValuesFromContentItems(contentItems: ContentItem[]): Map<string, ContentValue[]>;
|
|
11
|
-
export declare function extractContentValuesFromBuildingBlockFieldFulfillments(buildingBlockFieldFulfillments: BuildingBlockFieldFulfillment[]): Map<string, ContentValue[]>;
|
|
12
|
-
export { isObjectNode, isArrayNode, isPrimitiveNode, isAssetNode, isCastNode, isGridPlacementNode, isPathPartNode };
|
package/src/schema/lib/utils.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extractContentValuesFromContentItems = extractContentValuesFromContentItems;
|
|
4
|
-
exports.extractContentValuesFromBuildingBlockFieldFulfillments = extractContentValuesFromBuildingBlockFieldFulfillments;
|
|
5
|
-
exports.isObjectNode = isObjectNode;
|
|
6
|
-
exports.isArrayNode = isArrayNode;
|
|
7
|
-
exports.isPrimitiveNode = isPrimitiveNode;
|
|
8
|
-
exports.isAssetNode = isAssetNode;
|
|
9
|
-
exports.isCastNode = isCastNode;
|
|
10
|
-
exports.isGridPlacementNode = isGridPlacementNode;
|
|
11
|
-
exports.isPathPartNode = isPathPartNode;
|
|
12
|
-
const nodes_1 = require("./nodes");
|
|
13
|
-
function isObjectNode(node) {
|
|
14
|
-
return node.type === nodes_1.Type.OBJECT;
|
|
15
|
-
}
|
|
16
|
-
function isArrayNode(node) {
|
|
17
|
-
return node.type === nodes_1.Type.ARRAY;
|
|
18
|
-
}
|
|
19
|
-
function isPrimitiveNode(node) {
|
|
20
|
-
return node.type === nodes_1.Type.PRIMITIVE;
|
|
21
|
-
}
|
|
22
|
-
function isAssetNode(node) {
|
|
23
|
-
return node.type === nodes_1.Type.ASSET;
|
|
24
|
-
}
|
|
25
|
-
function isCastNode(node) {
|
|
26
|
-
return node.type === nodes_1.Type.CAST;
|
|
27
|
-
}
|
|
28
|
-
function isGridPlacementNode(node) {
|
|
29
|
-
return node.type === nodes_1.Type.GRID_PLACEMENT;
|
|
30
|
-
}
|
|
31
|
-
function isPathPartNode(node) {
|
|
32
|
-
return node.type === nodes_1.Type.PATH_PART;
|
|
33
|
-
}
|
|
34
|
-
function extractContentValuesFromContentItems(contentItems) {
|
|
35
|
-
const map = new Map();
|
|
36
|
-
contentItems.forEach((contentItem) => {
|
|
37
|
-
contentItem.contentValues.map((contentValue) => {
|
|
38
|
-
const key = contentValue.contentField?.name;
|
|
39
|
-
if (key === undefined || key === null) {
|
|
40
|
-
return undefined;
|
|
41
|
-
}
|
|
42
|
-
if (map.has(key)) {
|
|
43
|
-
map.get(key)?.push(contentValue);
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
map.set(key, [contentValue]);
|
|
47
|
-
}
|
|
48
|
-
return undefined;
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
return map;
|
|
52
|
-
}
|
|
53
|
-
function extractContentValuesFromBuildingBlockFieldFulfillments(buildingBlockFieldFulfillments) {
|
|
54
|
-
const map = new Map();
|
|
55
|
-
buildingBlockFieldFulfillments.forEach((value) => {
|
|
56
|
-
const key = value.buildingBlockField.slug;
|
|
57
|
-
if (map.has(key)) {
|
|
58
|
-
map.get(key)?.push(value.contentValue);
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
map.set(key, [value.contentValue]);
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
return map;
|
|
65
|
-
}
|
|
66
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../../packages/delta-client/src/schema/lib/utils.ts"],"names":[],"mappings":";;AAyCA,oFAsBC;AAED,wHAgBC;AAEQ,oCAAY;AAAE,kCAAW;AAAE,0CAAe;AAAE,kCAAW;AAAE,gCAAU;AAAE,kDAAmB;AAAE,wCAAc;AAnFjH,mCAUiB;AAGjB,SAAS,YAAY,CAAiC,IAAU;IAC9D,OAAO,IAAI,CAAC,IAAI,KAAK,YAAI,CAAC,MAAM,CAAC;AACnC,CAAC;AAED,SAAS,WAAW,CAAiB,IAAU;IAC7C,OAAO,IAAI,CAAC,IAAI,KAAK,YAAI,CAAC,KAAK,CAAC;AAClC,CAAC;AAED,SAAS,eAAe,CAAsC,IAAU;IACtE,OAAO,IAAI,CAAC,IAAI,KAAK,YAAI,CAAC,SAAS,CAAC;AACtC,CAAC;AAED,SAAS,WAAW,CAAC,IAAU;IAC7B,OAAO,IAAI,CAAC,IAAI,KAAK,YAAI,CAAC,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