@tailor-cms/ce-accordion-manifest 0.1.0 → 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,88 +1,60 @@
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
- ai: () => ai,
23
- default: () => index_default,
24
- initState: () => initState,
25
- name: () => name,
26
- type: () => type,
27
- version: () => version
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
28
4
  });
29
- module.exports = __toCommonJS(index_exports);
30
- var import_uuid = require("uuid");
31
- var id1 = (0, import_uuid.v4)();
32
- var id2 = (0, import_uuid.v4)();
33
- var type = "ACCORDION";
34
- var name = "Accordion";
35
- var initState = () => ({
36
- embeds: {},
37
- items: {
38
- [id1]: {
39
- id: id1,
40
- header: "Accordion Item Title",
41
- body: {},
42
- position: 1
43
- },
44
- [id2]: {
45
- id: id2,
46
- header: "Accordion Item Title",
47
- body: {},
48
- position: 1
49
- }
50
- }
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
+ }
51
27
  });
52
- var version = "1.0";
53
- var ui = {
54
- // Display icon, https://pictogrammers.com/library/mdi/
55
- icon: "mdi-view-day",
56
- // Does element support only full width or can be used within layouts
57
- // (e.g. 50/50 layout)
58
- forceFullWidth: true
28
+ const version = "1.0";
29
+ const ui = {
30
+ icon: "mdi-view-day",
31
+ forceFullWidth: true
59
32
  };
60
- var ai = {
61
- Schema: {
62
- type: "json_schema",
63
- name: "ce_accordion",
64
- schema: {
65
- type: "object",
66
- properties: {
67
- items: {
68
- type: "array",
69
- minItems: 2,
70
- items: {
71
- type: "object",
72
- properties: {
73
- header: { type: "string" },
74
- content: { type: "string" }
75
- },
76
- required: ["header", "content"],
77
- additionalProperties: false
78
- }
79
- }
80
- },
81
- required: ["items"],
82
- additionalProperties: false
83
- }
84
- },
85
- getPrompt: () => `
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: () => `
86
58
  Generate a accordion content element as an object with the following
87
59
  properties:
88
60
  {
@@ -100,46 +72,46 @@ var ai = {
100
72
  The content should be relevant to the topic of the accordion and
101
73
  have a few paragraphs about the topic.
102
74
  `,
103
- processResponse: (val) => {
104
- return val.items.reduce(
105
- (acc, { header, content }, index) => {
106
- const embedId = (0, import_uuid.v4)();
107
- const itemId = (0, import_uuid.v4)();
108
- acc.embeds[embedId] = {
109
- id: embedId,
110
- data: { content },
111
- embedded: true,
112
- position: 1,
113
- type: "TIPTAP_HTML"
114
- };
115
- acc.items[itemId] = {
116
- id: itemId,
117
- body: { [embedId]: true },
118
- header,
119
- position: index + 1
120
- };
121
- return acc;
122
- },
123
- { items: {}, embeds: {} }
124
- );
125
- }
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
+ }
126
98
  };
127
- var manifest = {
128
- type,
129
- version: "1.0",
130
- name,
131
- isComposite: true,
132
- ssr: false,
133
- initState,
134
- ui,
135
- ai
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
136
109
  };
137
- var index_default = manifest;
138
- // Annotate the CommonJS export names for ESM import in node:
139
- 0 && (module.exports = {
140
- ai,
141
- initState,
142
- name,
143
- type,
144
- version
145
- });
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,29 +1,28 @@
1
- import * as common from '@tailor-cms/cek-common';
2
- import { OpenAISchema } from '@tailor-cms/cek-common';
1
+ import * as common from "@tailor-cms/cek-common";
2
+ import { AiConfig } from "@tailor-cms/cek-common";
3
3
 
4
+ //#region src/interfaces.d.ts
4
5
  interface AccordionItem {
5
- id: string;
6
- header: string;
7
- body: Record<string, any>;
8
- position: number;
6
+ id: string;
7
+ header: string;
8
+ body: Record<string, any>;
9
+ position: number;
9
10
  }
10
11
  interface ElementData extends common.ElementConfig {
11
- embeds: Record<string, any>;
12
- items: Record<string, AccordionItem>;
12
+ embeds: Record<string, any>;
13
+ items: Record<string, AccordionItem>;
13
14
  }
14
15
  type DataInitializer = common.DataInitializer<ElementData>;
15
16
  type Element = common.Element<ElementData>;
16
17
  type ElementManifest = common.ElementManifest<ElementData>;
17
-
18
+ //#endregion
19
+ //#region src/index.d.ts
18
20
  declare const type = "ACCORDION";
19
21
  declare const name = "Accordion";
20
22
  declare const initState: DataInitializer;
21
23
  declare const version = "1.0";
22
- declare const ai: {
23
- Schema: OpenAISchema;
24
- getPrompt: () => string;
25
- processResponse: (val: any) => any;
26
- };
24
+ declare const isEmpty: (data: ElementData) => boolean;
25
+ declare const ai: AiConfig;
27
26
  declare const manifest: ElementManifest;
28
-
29
- export { type AccordionItem, type DataInitializer, type Element, type ElementData, type ElementManifest, ai, 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,43 @@
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.1.0",
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/cek-common": "^1.3.2",
20
- "@tailor-cms/eslint-config": "1.1.2",
21
- "tsup": "^8.5.0",
22
- "typescript": "^5.8.3"
23
- },
24
18
  "dependencies": {
25
- "uuid": "^11.1.0"
19
+ "@tailor-cms/cek-common": "2.0.1",
20
+ "uuid": "^14.0.0"
26
21
  },
27
- "tsup": {
28
- "entry": [
29
- "src/index.ts"
30
- ],
31
- "target": [
32
- "node14",
33
- "es2022"
34
- ],
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",
35
29
  "format": [
36
30
  "cjs",
37
31
  "esm"
38
- ],
39
- "bundle": true,
40
- "minify": false,
41
- "clean": false,
42
- "dts": true
32
+ ]
43
33
  },
44
34
  "publishConfig": {
45
35
  "access": "public"
46
36
  },
37
+ "engines": {
38
+ "node": ">=24"
39
+ },
47
40
  "scripts": {
48
- "dev": "tsup --watch",
49
- "build": "pnpm nuke:dist && tsup",
41
+ "dev": "tsdown --watch",
42
+ "build": "pnpm nuke:dist && tsdown",
50
43
  "lint": "eslint .",
51
44
  "lint:fix": "pnpm lint --fix",
52
45
  "nuke": "pnpm dlx del-cli dist node_modules",
package/dist/index.d.ts DELETED
@@ -1,29 +0,0 @@
1
- import * as common from '@tailor-cms/cek-common';
2
- import { OpenAISchema } from '@tailor-cms/cek-common';
3
-
4
- interface AccordionItem {
5
- id: string;
6
- header: string;
7
- body: Record<string, any>;
8
- position: number;
9
- }
10
- interface ElementData extends common.ElementConfig {
11
- embeds: Record<string, any>;
12
- items: Record<string, AccordionItem>;
13
- }
14
- type DataInitializer = common.DataInitializer<ElementData>;
15
- type Element = common.Element<ElementData>;
16
- type ElementManifest = common.ElementManifest<ElementData>;
17
-
18
- declare const type = "ACCORDION";
19
- declare const name = "Accordion";
20
- declare const initState: DataInitializer;
21
- declare const version = "1.0";
22
- declare const ai: {
23
- Schema: OpenAISchema;
24
- getPrompt: () => string;
25
- processResponse: (val: any) => any;
26
- };
27
- declare const manifest: ElementManifest;
28
-
29
- export { type AccordionItem, type DataInitializer, type Element, type ElementData, type ElementManifest, ai, manifest as default, initState, name, type, version };
package/dist/index.js DELETED
@@ -1,117 +0,0 @@
1
- // src/index.ts
2
- import { v4 as uuid } from "uuid";
3
- var id1 = uuid();
4
- var id2 = uuid();
5
- var type = "ACCORDION";
6
- var name = "Accordion";
7
- var 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
- var version = "1.0";
25
- var ui = {
26
- // Display icon, https://pictogrammers.com/library/mdi/
27
- icon: "mdi-view-day",
28
- // Does element support only full width or can be used within layouts
29
- // (e.g. 50/50 layout)
30
- forceFullWidth: true
31
- };
32
- var ai = {
33
- Schema: {
34
- type: "json_schema",
35
- name: "ce_accordion",
36
- schema: {
37
- type: "object",
38
- properties: {
39
- items: {
40
- type: "array",
41
- minItems: 2,
42
- items: {
43
- type: "object",
44
- properties: {
45
- header: { type: "string" },
46
- content: { type: "string" }
47
- },
48
- required: ["header", "content"],
49
- additionalProperties: false
50
- }
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(
77
- (acc, { header, content }, index) => {
78
- const embedId = uuid();
79
- const itemId = uuid();
80
- acc.embeds[embedId] = {
81
- id: embedId,
82
- data: { content },
83
- embedded: true,
84
- position: 1,
85
- type: "TIPTAP_HTML"
86
- };
87
- acc.items[itemId] = {
88
- id: itemId,
89
- body: { [embedId]: true },
90
- header,
91
- position: index + 1
92
- };
93
- return acc;
94
- },
95
- { items: {}, embeds: {} }
96
- );
97
- }
98
- };
99
- var manifest = {
100
- type,
101
- version: "1.0",
102
- name,
103
- isComposite: true,
104
- ssr: false,
105
- initState,
106
- ui,
107
- ai
108
- };
109
- var index_default = manifest;
110
- export {
111
- ai,
112
- index_default as default,
113
- initState,
114
- name,
115
- type,
116
- version
117
- };