@tailor-cms/ce-sequence-manifest 0.0.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.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # Content element manifest
2
+
3
+ Exposes shared element definition
package/dist/index.cjs ADDED
@@ -0,0 +1,147 @@
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
5
+ let uuid = require("uuid");
6
+ //#region src/index.ts
7
+ const id1 = (0, uuid.v4)();
8
+ const id2 = (0, uuid.v4)();
9
+ const type = "SEQUENCE";
10
+ const name = "Sequence";
11
+ const initState = () => ({
12
+ mode: "steps",
13
+ embeds: {},
14
+ items: {
15
+ [id1]: {
16
+ id: id1,
17
+ marker: "",
18
+ title: "",
19
+ body: {},
20
+ position: 1
21
+ },
22
+ [id2]: {
23
+ id: id2,
24
+ marker: "",
25
+ title: "",
26
+ body: {},
27
+ position: 2
28
+ }
29
+ }
30
+ });
31
+ const version = "1.0";
32
+ const ui = {
33
+ icon: "mdi-timeline-text",
34
+ forceFullWidth: true
35
+ };
36
+ const isEmpty = (data) => !data.items || Object.keys(data.items).length === 0;
37
+ const ai = {
38
+ Schema: {
39
+ type: "json_schema",
40
+ name: "ce_sequence",
41
+ schema: {
42
+ type: "object",
43
+ properties: {
44
+ mode: {
45
+ type: "string",
46
+ enum: ["steps", "timeline"]
47
+ },
48
+ entries: {
49
+ type: "array",
50
+ minItems: 2,
51
+ items: {
52
+ type: "object",
53
+ properties: {
54
+ marker: { type: "string" },
55
+ title: { type: "string" },
56
+ content: { type: "string" }
57
+ },
58
+ required: [
59
+ "marker",
60
+ "title",
61
+ "content"
62
+ ],
63
+ additionalProperties: false
64
+ }
65
+ }
66
+ },
67
+ required: ["mode", "entries"],
68
+ additionalProperties: false
69
+ }
70
+ },
71
+ getPrompt: () => `
72
+ Generate a sequence content element as an object with the following
73
+ properties:
74
+ {
75
+ "mode": "steps" | "timeline",
76
+ "entries": [
77
+ {
78
+ "marker": "",
79
+ "title": "",
80
+ "content": ""
81
+ }
82
+ ]
83
+ }
84
+ where:
85
+ - 'mode' describes how the sequence is presented. Choose it from the topic:
86
+ - 'timeline' for chronological subjects (historical events, milestones,
87
+ anything organised by date or period).
88
+ - 'steps' for procedural subjects (how-tos, processes, ordered
89
+ instructions).
90
+ - 'entries' is an ordered array of entries where:
91
+ - 'marker' is the entry's date or period (e.g. "1990", "Q1 2024",
92
+ "Day 1") — fill it only in 'timeline' mode; leave it "" in 'steps'
93
+ mode.
94
+ - 'title' is a short heading for the entry. Do not prefix it with an
95
+ ordinal or step number (e.g. "Step 1:", "1.", "First:") — entries are
96
+ numbered automatically.
97
+ - 'content' is a paragraph of detail for the entry.
98
+ `,
99
+ processResponse: (val) => {
100
+ const stripOrdinal = (title) => title.replace(/^\s*(step\s*)?\d+\s*[.):-]\s*/i, "").trim();
101
+ const isTimeline = val.mode === "timeline";
102
+ return {
103
+ ...val.entries.reduce((acc, entry, index) => {
104
+ const embedId = (0, uuid.v4)();
105
+ const itemId = (0, uuid.v4)();
106
+ acc.embeds[embedId] = {
107
+ id: embedId,
108
+ data: { content: entry.content },
109
+ embedded: true,
110
+ position: 1,
111
+ type: "TIPTAP_HTML"
112
+ };
113
+ acc.items[itemId] = {
114
+ id: itemId,
115
+ marker: isTimeline ? entry.marker ?? "" : "",
116
+ title: stripOrdinal(entry.title),
117
+ body: { [embedId]: true },
118
+ position: index + 1
119
+ };
120
+ return acc;
121
+ }, {
122
+ items: {},
123
+ embeds: {}
124
+ }),
125
+ mode: isTimeline ? "timeline" : "steps"
126
+ };
127
+ }
128
+ };
129
+ const manifest = {
130
+ type,
131
+ version: "1.0",
132
+ name,
133
+ isComposite: true,
134
+ ssr: false,
135
+ initState,
136
+ isEmpty,
137
+ ui,
138
+ ai
139
+ };
140
+ //#endregion
141
+ exports.ai = ai;
142
+ exports.default = manifest;
143
+ exports.initState = initState;
144
+ exports.isEmpty = isEmpty;
145
+ exports.name = name;
146
+ exports.type = type;
147
+ exports.version = version;
@@ -0,0 +1,31 @@
1
+ import * as common from "@tailor-cms/cek-common";
2
+ import { AiConfig } from "@tailor-cms/cek-common";
3
+
4
+ //#region src/interfaces.d.ts
5
+ type SequenceMode = "steps" | "timeline";
6
+ interface SequenceItem {
7
+ id: string;
8
+ marker: string;
9
+ title: string;
10
+ body: Record<string, any>;
11
+ position: number;
12
+ }
13
+ interface ElementData extends common.ElementConfig {
14
+ mode: SequenceMode;
15
+ embeds: Record<string, any>;
16
+ items: Record<string, SequenceItem>;
17
+ }
18
+ type DataInitializer = common.DataInitializer<ElementData>;
19
+ type Element = common.Element<ElementData>;
20
+ type ElementManifest = common.ElementManifest<ElementData>;
21
+ //#endregion
22
+ //#region src/index.d.ts
23
+ declare const type = "SEQUENCE";
24
+ declare const name = "Sequence";
25
+ declare const initState: DataInitializer;
26
+ declare const version = "1.0";
27
+ declare const isEmpty: (data: ElementData) => boolean;
28
+ declare const ai: AiConfig;
29
+ declare const manifest: ElementManifest;
30
+ //#endregion
31
+ export { DataInitializer, Element, ElementData, ElementManifest, SequenceItem, SequenceMode, ai, manifest as default, initState, isEmpty, name, type, version };
@@ -0,0 +1,31 @@
1
+ import * as common from "@tailor-cms/cek-common";
2
+ import { AiConfig } from "@tailor-cms/cek-common";
3
+
4
+ //#region src/interfaces.d.ts
5
+ type SequenceMode = "steps" | "timeline";
6
+ interface SequenceItem {
7
+ id: string;
8
+ marker: string;
9
+ title: string;
10
+ body: Record<string, any>;
11
+ position: number;
12
+ }
13
+ interface ElementData extends common.ElementConfig {
14
+ mode: SequenceMode;
15
+ embeds: Record<string, any>;
16
+ items: Record<string, SequenceItem>;
17
+ }
18
+ type DataInitializer = common.DataInitializer<ElementData>;
19
+ type Element = common.Element<ElementData>;
20
+ type ElementManifest = common.ElementManifest<ElementData>;
21
+ //#endregion
22
+ //#region src/index.d.ts
23
+ declare const type = "SEQUENCE";
24
+ declare const name = "Sequence";
25
+ declare const initState: DataInitializer;
26
+ declare const version = "1.0";
27
+ declare const isEmpty: (data: ElementData) => boolean;
28
+ declare const ai: AiConfig;
29
+ declare const manifest: ElementManifest;
30
+ //#endregion
31
+ export { DataInitializer, Element, ElementData, ElementManifest, SequenceItem, SequenceMode, ai, manifest as default, initState, isEmpty, name, type, version };
package/dist/index.mjs ADDED
@@ -0,0 +1,137 @@
1
+ import { v4 } from "uuid";
2
+ //#region src/index.ts
3
+ const id1 = v4();
4
+ const id2 = v4();
5
+ const type = "SEQUENCE";
6
+ const name = "Sequence";
7
+ const initState = () => ({
8
+ mode: "steps",
9
+ embeds: {},
10
+ items: {
11
+ [id1]: {
12
+ id: id1,
13
+ marker: "",
14
+ title: "",
15
+ body: {},
16
+ position: 1
17
+ },
18
+ [id2]: {
19
+ id: id2,
20
+ marker: "",
21
+ title: "",
22
+ body: {},
23
+ position: 2
24
+ }
25
+ }
26
+ });
27
+ const version = "1.0";
28
+ const ui = {
29
+ icon: "mdi-timeline-text",
30
+ forceFullWidth: true
31
+ };
32
+ const isEmpty = (data) => !data.items || Object.keys(data.items).length === 0;
33
+ const ai = {
34
+ Schema: {
35
+ type: "json_schema",
36
+ name: "ce_sequence",
37
+ schema: {
38
+ type: "object",
39
+ properties: {
40
+ mode: {
41
+ type: "string",
42
+ enum: ["steps", "timeline"]
43
+ },
44
+ entries: {
45
+ type: "array",
46
+ minItems: 2,
47
+ items: {
48
+ type: "object",
49
+ properties: {
50
+ marker: { type: "string" },
51
+ title: { type: "string" },
52
+ content: { type: "string" }
53
+ },
54
+ required: [
55
+ "marker",
56
+ "title",
57
+ "content"
58
+ ],
59
+ additionalProperties: false
60
+ }
61
+ }
62
+ },
63
+ required: ["mode", "entries"],
64
+ additionalProperties: false
65
+ }
66
+ },
67
+ getPrompt: () => `
68
+ Generate a sequence content element as an object with the following
69
+ properties:
70
+ {
71
+ "mode": "steps" | "timeline",
72
+ "entries": [
73
+ {
74
+ "marker": "",
75
+ "title": "",
76
+ "content": ""
77
+ }
78
+ ]
79
+ }
80
+ where:
81
+ - 'mode' describes how the sequence is presented. Choose it from the topic:
82
+ - 'timeline' for chronological subjects (historical events, milestones,
83
+ anything organised by date or period).
84
+ - 'steps' for procedural subjects (how-tos, processes, ordered
85
+ instructions).
86
+ - 'entries' is an ordered array of entries where:
87
+ - 'marker' is the entry's date or period (e.g. "1990", "Q1 2024",
88
+ "Day 1") — fill it only in 'timeline' mode; leave it "" in 'steps'
89
+ mode.
90
+ - 'title' is a short heading for the entry. Do not prefix it with an
91
+ ordinal or step number (e.g. "Step 1:", "1.", "First:") — entries are
92
+ numbered automatically.
93
+ - 'content' is a paragraph of detail for the entry.
94
+ `,
95
+ processResponse: (val) => {
96
+ const stripOrdinal = (title) => title.replace(/^\s*(step\s*)?\d+\s*[.):-]\s*/i, "").trim();
97
+ const isTimeline = val.mode === "timeline";
98
+ return {
99
+ ...val.entries.reduce((acc, entry, index) => {
100
+ const embedId = v4();
101
+ const itemId = v4();
102
+ acc.embeds[embedId] = {
103
+ id: embedId,
104
+ data: { content: entry.content },
105
+ embedded: true,
106
+ position: 1,
107
+ type: "TIPTAP_HTML"
108
+ };
109
+ acc.items[itemId] = {
110
+ id: itemId,
111
+ marker: isTimeline ? entry.marker ?? "" : "",
112
+ title: stripOrdinal(entry.title),
113
+ body: { [embedId]: true },
114
+ position: index + 1
115
+ };
116
+ return acc;
117
+ }, {
118
+ items: {},
119
+ embeds: {}
120
+ }),
121
+ mode: isTimeline ? "timeline" : "steps"
122
+ };
123
+ }
124
+ };
125
+ const manifest = {
126
+ type,
127
+ version: "1.0",
128
+ name,
129
+ isComposite: true,
130
+ ssr: false,
131
+ initState,
132
+ isEmpty,
133
+ ui,
134
+ ai
135
+ };
136
+ //#endregion
137
+ export { ai, manifest as default, initState, isEmpty, name, type, version };
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@tailor-cms/ce-sequence-manifest",
3
+ "description": "Tailor CMS sequence element manifest",
4
+ "author": "Studion <info@gostudion.com> (https://github.com/tailor-cms)",
5
+ "type": "module",
6
+ "version": "0.0.1",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/index.mjs",
10
+ "require": "./dist/index.cjs"
11
+ }
12
+ },
13
+ "main": "./dist/index.cjs",
14
+ "types": "./dist/index.d.mts",
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "dependencies": {
19
+ "@tailor-cms/cek-common": "^2.0.1",
20
+ "uuid": "^14.0.0"
21
+ },
22
+ "devDependencies": {
23
+ "@tailor-cms/eslint-config": "^2.0.1",
24
+ "tsdown": "^0.21.10",
25
+ "typescript": "^6.0.3"
26
+ },
27
+ "tsdown": {
28
+ "target": "node24",
29
+ "format": [
30
+ "cjs",
31
+ "esm"
32
+ ]
33
+ },
34
+ "publishConfig": {
35
+ "access": "public"
36
+ },
37
+ "engines": {
38
+ "node": ">=24"
39
+ },
40
+ "scripts": {
41
+ "dev": "tsdown --watch",
42
+ "build": "tsdown",
43
+ "lint": "eslint .",
44
+ "lint:fix": "pnpm lint --fix",
45
+ "nuke": "pnpm dlx del-cli dist node_modules",
46
+ "nuke:dist": "pnpm dlx del-cli dist",
47
+ "prepublish": "pnpm build"
48
+ }
49
+ }