@tailor-cms/ce-accordion-manifest 0.0.16 → 2.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/dist/index.cjs CHANGED
@@ -1,68 +1,117 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name2 in all)
7
- __defProp(target, name2, { get: all[name2], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/index.ts
20
- var index_exports = {};
21
- __export(index_exports, {
22
- default: () => index_default,
23
- initState: () => initState,
24
- name: () => name,
25
- type: () => type,
26
- version: () => version
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
27
4
  });
28
- module.exports = __toCommonJS(index_exports);
29
- var import_uuid = require("uuid");
30
- var id = (0, import_uuid.v4)();
31
- var type = "ACCORDION";
32
- var name = "Accordion";
33
- var initState = () => ({
34
- embeds: {},
35
- items: {
36
- [id]: {
37
- id,
38
- header: "Accordion Item Title",
39
- body: {},
40
- position: 1
41
- }
42
- }
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 = "ACCORDION";
10
+ const name = "Accordion";
11
+ const initState = () => ({
12
+ embeds: {},
13
+ items: {
14
+ [id1]: {
15
+ id: id1,
16
+ header: "Accordion Item Title",
17
+ body: {},
18
+ position: 1
19
+ },
20
+ [id2]: {
21
+ id: id2,
22
+ header: "Accordion Item Title",
23
+ body: {},
24
+ position: 1
25
+ }
26
+ }
43
27
  });
44
- var version = "1.0";
45
- var ui = {
46
- // Display icon, https://pictogrammers.com/library/mdi/
47
- icon: "mdi-view-day",
48
- // Does element support only full width or can be used within layouts
49
- // (e.g. 50/50 layout)
50
- forceFullWidth: true
28
+ const version = "1.0";
29
+ const ui = {
30
+ icon: "mdi-view-day",
31
+ forceFullWidth: true
51
32
  };
52
- var manifest = {
53
- type,
54
- version: "1.0",
55
- name,
56
- isComposite: true,
57
- ssr: false,
58
- initState,
59
- ui
33
+ const isEmpty = (data) => !data.items || Object.keys(data.items).length === 0;
34
+ const ai = {
35
+ Schema: {
36
+ type: "json_schema",
37
+ name: "ce_accordion",
38
+ schema: {
39
+ type: "object",
40
+ properties: { items: {
41
+ type: "array",
42
+ minItems: 2,
43
+ items: {
44
+ type: "object",
45
+ properties: {
46
+ header: { type: "string" },
47
+ content: { type: "string" }
48
+ },
49
+ required: ["header", "content"],
50
+ additionalProperties: false
51
+ }
52
+ } },
53
+ required: ["items"],
54
+ additionalProperties: false
55
+ }
56
+ },
57
+ getPrompt: () => `
58
+ Generate a accordion content element as an object with the following
59
+ properties:
60
+ {
61
+ "items": [
62
+ {
63
+ "header": "",
64
+ "content": ""
65
+ }
66
+ ]
67
+ }
68
+ where:
69
+ - 'items' is an array of accordion item objects where:
70
+ - 'header' is the title of the accordion item.
71
+ - 'content' is the text to be displayed in the accordion item.
72
+ The content should be relevant to the topic of the accordion and
73
+ have a few paragraphs about the topic.
74
+ `,
75
+ processResponse: (val) => {
76
+ return val.items.reduce((acc, { header, content }, index) => {
77
+ const embedId = (0, uuid.v4)();
78
+ const itemId = (0, uuid.v4)();
79
+ acc.embeds[embedId] = {
80
+ id: embedId,
81
+ data: { content },
82
+ embedded: true,
83
+ position: 1,
84
+ type: "TIPTAP_HTML"
85
+ };
86
+ acc.items[itemId] = {
87
+ id: itemId,
88
+ body: { [embedId]: true },
89
+ header,
90
+ position: index + 1
91
+ };
92
+ return acc;
93
+ }, {
94
+ items: {},
95
+ embeds: {}
96
+ });
97
+ }
60
98
  };
61
- var index_default = manifest;
62
- // Annotate the CommonJS export names for ESM import in node:
63
- 0 && (module.exports = {
64
- initState,
65
- name,
66
- type,
67
- version
68
- });
99
+ const manifest = {
100
+ type,
101
+ version: "1.0",
102
+ name,
103
+ isComposite: true,
104
+ ssr: false,
105
+ initState,
106
+ isEmpty,
107
+ ui,
108
+ ai
109
+ };
110
+ //#endregion
111
+ exports.ai = ai;
112
+ exports.default = manifest;
113
+ exports.initState = initState;
114
+ exports.isEmpty = isEmpty;
115
+ exports.name = name;
116
+ exports.type = type;
117
+ exports.version = version;
package/dist/index.d.cts CHANGED
@@ -1,63 +1,28 @@
1
+ import * as common from "@tailor-cms/cek-common";
2
+ import { AiConfig } from "@tailor-cms/cek-common";
3
+
4
+ //#region src/interfaces.d.ts
1
5
  interface AccordionItem {
2
- id: string;
3
- header: string;
4
- body: Record<string, any>;
5
- position: number;
6
- }
7
- interface ElementData {
8
- embeds: Record<string, any>;
9
- items: Record<string, AccordionItem>;
10
- }
11
- interface Element {
12
- id: number;
13
- uid: string;
14
- activityId: number;
15
- repositoryId: number;
16
- contentId: string;
17
- contentSignature: string;
18
- type: string;
19
- position: number;
20
- data: ElementData;
21
- meta: {
22
- [key: string]: unknown;
23
- };
24
- refs: {
25
- [key: string]: unknown;
26
- };
27
- linked: boolean;
28
- detached: boolean;
29
- createdAt: string;
30
- updatedAt: string;
31
- deletedAt: string | null;
6
+ id: string;
7
+ header: string;
8
+ body: Record<string, any>;
9
+ position: number;
32
10
  }
33
- type DataInitializer = () => ElementData;
34
- interface ElementManifest {
35
- type: string;
36
- version: string;
37
- name: string;
38
- ssr: boolean;
39
- isComposite: boolean;
40
- initState: DataInitializer;
41
- Edit?: object;
42
- TopToolbar?: object;
43
- SideToolbar?: object;
44
- Display?: object;
45
- ui: {
46
- icon: string;
47
- forceFullWidth: boolean;
48
- };
49
- mocks?: {
50
- displayContexts: Array<{
51
- name: string;
52
- data: any;
53
- }>;
54
- };
11
+ interface ElementData extends common.ElementConfig {
12
+ embeds: Record<string, any>;
13
+ items: Record<string, AccordionItem>;
55
14
  }
56
-
15
+ type DataInitializer = common.DataInitializer<ElementData>;
16
+ type Element = common.Element<ElementData>;
17
+ type ElementManifest = common.ElementManifest<ElementData>;
18
+ //#endregion
19
+ //#region src/index.d.ts
57
20
  declare const type = "ACCORDION";
58
21
  declare const name = "Accordion";
59
22
  declare const initState: DataInitializer;
60
23
  declare const version = "1.0";
24
+ declare const isEmpty: (data: ElementData) => boolean;
25
+ declare const ai: AiConfig;
61
26
  declare const manifest: ElementManifest;
62
-
63
- export { type AccordionItem, type DataInitializer, type Element, type ElementData, type ElementManifest, manifest as default, initState, name, type, version };
27
+ //#endregion
28
+ export { AccordionItem, DataInitializer, Element, ElementData, ElementManifest, ai, manifest as default, initState, isEmpty, name, type, version };
@@ -0,0 +1,28 @@
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
+ interface AccordionItem {
6
+ id: string;
7
+ header: string;
8
+ body: Record<string, any>;
9
+ position: number;
10
+ }
11
+ interface ElementData extends common.ElementConfig {
12
+ embeds: Record<string, any>;
13
+ items: Record<string, AccordionItem>;
14
+ }
15
+ type DataInitializer = common.DataInitializer<ElementData>;
16
+ type Element = common.Element<ElementData>;
17
+ type ElementManifest = common.ElementManifest<ElementData>;
18
+ //#endregion
19
+ //#region src/index.d.ts
20
+ declare const type = "ACCORDION";
21
+ declare const name = "Accordion";
22
+ declare const initState: DataInitializer;
23
+ declare const version = "1.0";
24
+ declare const isEmpty: (data: ElementData) => boolean;
25
+ declare const ai: AiConfig;
26
+ declare const manifest: ElementManifest;
27
+ //#endregion
28
+ export { AccordionItem, DataInitializer, Element, ElementData, ElementManifest, ai, manifest as default, initState, isEmpty, name, type, version };
package/dist/index.mjs ADDED
@@ -0,0 +1,107 @@
1
+ import { v4 } from "uuid";
2
+ //#region src/index.ts
3
+ const id1 = v4();
4
+ const id2 = v4();
5
+ const type = "ACCORDION";
6
+ const name = "Accordion";
7
+ const initState = () => ({
8
+ embeds: {},
9
+ items: {
10
+ [id1]: {
11
+ id: id1,
12
+ header: "Accordion Item Title",
13
+ body: {},
14
+ position: 1
15
+ },
16
+ [id2]: {
17
+ id: id2,
18
+ header: "Accordion Item Title",
19
+ body: {},
20
+ position: 1
21
+ }
22
+ }
23
+ });
24
+ const version = "1.0";
25
+ const ui = {
26
+ icon: "mdi-view-day",
27
+ forceFullWidth: true
28
+ };
29
+ const isEmpty = (data) => !data.items || Object.keys(data.items).length === 0;
30
+ const ai = {
31
+ Schema: {
32
+ type: "json_schema",
33
+ name: "ce_accordion",
34
+ schema: {
35
+ type: "object",
36
+ properties: { items: {
37
+ type: "array",
38
+ minItems: 2,
39
+ items: {
40
+ type: "object",
41
+ properties: {
42
+ header: { type: "string" },
43
+ content: { type: "string" }
44
+ },
45
+ required: ["header", "content"],
46
+ additionalProperties: false
47
+ }
48
+ } },
49
+ required: ["items"],
50
+ additionalProperties: false
51
+ }
52
+ },
53
+ getPrompt: () => `
54
+ Generate a accordion content element as an object with the following
55
+ properties:
56
+ {
57
+ "items": [
58
+ {
59
+ "header": "",
60
+ "content": ""
61
+ }
62
+ ]
63
+ }
64
+ where:
65
+ - 'items' is an array of accordion item objects where:
66
+ - 'header' is the title of the accordion item.
67
+ - 'content' is the text to be displayed in the accordion item.
68
+ The content should be relevant to the topic of the accordion and
69
+ have a few paragraphs about the topic.
70
+ `,
71
+ processResponse: (val) => {
72
+ return val.items.reduce((acc, { header, content }, index) => {
73
+ const embedId = v4();
74
+ const itemId = v4();
75
+ acc.embeds[embedId] = {
76
+ id: embedId,
77
+ data: { content },
78
+ embedded: true,
79
+ position: 1,
80
+ type: "TIPTAP_HTML"
81
+ };
82
+ acc.items[itemId] = {
83
+ id: itemId,
84
+ body: { [embedId]: true },
85
+ header,
86
+ position: index + 1
87
+ };
88
+ return acc;
89
+ }, {
90
+ items: {},
91
+ embeds: {}
92
+ });
93
+ }
94
+ };
95
+ const manifest = {
96
+ type,
97
+ version: "1.0",
98
+ name,
99
+ isComposite: true,
100
+ ssr: false,
101
+ initState,
102
+ isEmpty,
103
+ ui,
104
+ ai
105
+ };
106
+ //#endregion
107
+ export { ai, manifest as default, initState, isEmpty, name, type, version };
package/package.json CHANGED
@@ -3,50 +3,47 @@
3
3
  "description": "Tailor CMS accordion element",
4
4
  "author": "Studion <info@gostudion.com> (https://github.com/tailor-cms)",
5
5
  "type": "module",
6
- "version": "0.0.16",
6
+ "version": "2.0.0",
7
7
  "exports": {
8
8
  ".": {
9
- "import": "./dist/index.js",
9
+ "import": "./dist/index.mjs",
10
10
  "require": "./dist/index.cjs"
11
11
  }
12
12
  },
13
13
  "main": "./dist/index.cjs",
14
- "types": "./dist/index.d.ts",
14
+ "types": "./dist/index.d.mts",
15
15
  "files": [
16
16
  "dist"
17
17
  ],
18
- "devDependencies": {
19
- "@tailor-cms/eslint-config": "0.0.2",
20
- "tsup": "^8.3.6",
21
- "typescript": "^5.7.3"
22
- },
23
18
  "dependencies": {
24
- "uuid": "^11.0.5"
19
+ "@tailor-cms/cek-common": "2.0.1",
20
+ "uuid": "^14.0.0"
25
21
  },
26
- "tsup": {
27
- "entry": [
28
- "src/index.ts"
29
- ],
30
- "target": [
31
- "node14",
32
- "es2022"
33
- ],
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",
34
29
  "format": [
35
30
  "cjs",
36
31
  "esm"
37
- ],
38
- "bundle": true,
39
- "minify": false,
40
- "clean": false,
41
- "dts": true
32
+ ]
42
33
  },
43
34
  "publishConfig": {
44
35
  "access": "public"
45
36
  },
37
+ "engines": {
38
+ "node": ">=24"
39
+ },
46
40
  "scripts": {
47
- "dev": "tsup --watch",
48
- "build": "tsup",
49
- "lint": "eslint --ext .js,.ts .",
50
- "lint:fix": "pnpm lint --fix"
41
+ "dev": "tsdown --watch",
42
+ "build": "pnpm nuke:dist && 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"
51
48
  }
52
49
  }
package/dist/index.d.ts DELETED
@@ -1,63 +0,0 @@
1
- interface AccordionItem {
2
- id: string;
3
- header: string;
4
- body: Record<string, any>;
5
- position: number;
6
- }
7
- interface ElementData {
8
- embeds: Record<string, any>;
9
- items: Record<string, AccordionItem>;
10
- }
11
- interface Element {
12
- id: number;
13
- uid: string;
14
- activityId: number;
15
- repositoryId: number;
16
- contentId: string;
17
- contentSignature: string;
18
- type: string;
19
- position: number;
20
- data: ElementData;
21
- meta: {
22
- [key: string]: unknown;
23
- };
24
- refs: {
25
- [key: string]: unknown;
26
- };
27
- linked: boolean;
28
- detached: boolean;
29
- createdAt: string;
30
- updatedAt: string;
31
- deletedAt: string | null;
32
- }
33
- type DataInitializer = () => ElementData;
34
- interface ElementManifest {
35
- type: string;
36
- version: string;
37
- name: string;
38
- ssr: boolean;
39
- isComposite: boolean;
40
- initState: DataInitializer;
41
- Edit?: object;
42
- TopToolbar?: object;
43
- SideToolbar?: object;
44
- Display?: object;
45
- ui: {
46
- icon: string;
47
- forceFullWidth: boolean;
48
- };
49
- mocks?: {
50
- displayContexts: Array<{
51
- name: string;
52
- data: any;
53
- }>;
54
- };
55
- }
56
-
57
- declare const type = "ACCORDION";
58
- declare const name = "Accordion";
59
- declare const initState: DataInitializer;
60
- declare const version = "1.0";
61
- declare const manifest: ElementManifest;
62
-
63
- export { type AccordionItem, type DataInitializer, type Element, type ElementData, type ElementManifest, manifest as default, initState, name, type, version };
package/dist/index.js DELETED
@@ -1,41 +0,0 @@
1
- // src/index.ts
2
- import { v4 as uuid } from "uuid";
3
- var id = uuid();
4
- var type = "ACCORDION";
5
- var name = "Accordion";
6
- var initState = () => ({
7
- embeds: {},
8
- items: {
9
- [id]: {
10
- id,
11
- header: "Accordion Item Title",
12
- body: {},
13
- position: 1
14
- }
15
- }
16
- });
17
- var version = "1.0";
18
- var ui = {
19
- // Display icon, https://pictogrammers.com/library/mdi/
20
- icon: "mdi-view-day",
21
- // Does element support only full width or can be used within layouts
22
- // (e.g. 50/50 layout)
23
- forceFullWidth: true
24
- };
25
- var manifest = {
26
- type,
27
- version: "1.0",
28
- name,
29
- isComposite: true,
30
- ssr: false,
31
- initState,
32
- ui
33
- };
34
- var index_default = manifest;
35
- export {
36
- index_default as default,
37
- initState,
38
- name,
39
- type,
40
- version
41
- };