@tailor-cms/ce-accordion-manifest 0.0.16 → 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/dist/index.cjs +81 -4
- package/dist/index.d.cts +13 -47
- package/dist/index.d.ts +13 -47
- package/dist/index.js +80 -4
- package/package.json +12 -8
package/dist/index.cjs
CHANGED
|
@@ -19,6 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
// src/index.ts
|
|
20
20
|
var index_exports = {};
|
|
21
21
|
__export(index_exports, {
|
|
22
|
+
ai: () => ai,
|
|
22
23
|
default: () => index_default,
|
|
23
24
|
initState: () => initState,
|
|
24
25
|
name: () => name,
|
|
@@ -27,14 +28,21 @@ __export(index_exports, {
|
|
|
27
28
|
});
|
|
28
29
|
module.exports = __toCommonJS(index_exports);
|
|
29
30
|
var import_uuid = require("uuid");
|
|
30
|
-
var
|
|
31
|
+
var id1 = (0, import_uuid.v4)();
|
|
32
|
+
var id2 = (0, import_uuid.v4)();
|
|
31
33
|
var type = "ACCORDION";
|
|
32
34
|
var name = "Accordion";
|
|
33
35
|
var initState = () => ({
|
|
34
36
|
embeds: {},
|
|
35
37
|
items: {
|
|
36
|
-
[
|
|
37
|
-
id,
|
|
38
|
+
[id1]: {
|
|
39
|
+
id: id1,
|
|
40
|
+
header: "Accordion Item Title",
|
|
41
|
+
body: {},
|
|
42
|
+
position: 1
|
|
43
|
+
},
|
|
44
|
+
[id2]: {
|
|
45
|
+
id: id2,
|
|
38
46
|
header: "Accordion Item Title",
|
|
39
47
|
body: {},
|
|
40
48
|
position: 1
|
|
@@ -49,6 +57,73 @@ var ui = {
|
|
|
49
57
|
// (e.g. 50/50 layout)
|
|
50
58
|
forceFullWidth: true
|
|
51
59
|
};
|
|
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: () => `
|
|
86
|
+
Generate a accordion content element as an object with the following
|
|
87
|
+
properties:
|
|
88
|
+
{
|
|
89
|
+
"items": [
|
|
90
|
+
{
|
|
91
|
+
"header": "",
|
|
92
|
+
"content": ""
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
where:
|
|
97
|
+
- 'items' is an array of accordion item objects where:
|
|
98
|
+
- 'header' is the title of the accordion item.
|
|
99
|
+
- 'content' is the text to be displayed in the accordion item.
|
|
100
|
+
The content should be relevant to the topic of the accordion and
|
|
101
|
+
have a few paragraphs about the topic.
|
|
102
|
+
`,
|
|
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
|
+
}
|
|
126
|
+
};
|
|
52
127
|
var manifest = {
|
|
53
128
|
type,
|
|
54
129
|
version: "1.0",
|
|
@@ -56,11 +131,13 @@ var manifest = {
|
|
|
56
131
|
isComposite: true,
|
|
57
132
|
ssr: false,
|
|
58
133
|
initState,
|
|
59
|
-
ui
|
|
134
|
+
ui,
|
|
135
|
+
ai
|
|
60
136
|
};
|
|
61
137
|
var index_default = manifest;
|
|
62
138
|
// Annotate the CommonJS export names for ESM import in node:
|
|
63
139
|
0 && (module.exports = {
|
|
140
|
+
ai,
|
|
64
141
|
initState,
|
|
65
142
|
name,
|
|
66
143
|
type,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,63 +1,29 @@
|
|
|
1
|
+
import * as common from '@tailor-cms/cek-common';
|
|
2
|
+
import { OpenAISchema } from '@tailor-cms/cek-common';
|
|
3
|
+
|
|
1
4
|
interface AccordionItem {
|
|
2
5
|
id: string;
|
|
3
6
|
header: string;
|
|
4
7
|
body: Record<string, any>;
|
|
5
8
|
position: number;
|
|
6
9
|
}
|
|
7
|
-
interface ElementData {
|
|
10
|
+
interface ElementData extends common.ElementConfig {
|
|
8
11
|
embeds: Record<string, any>;
|
|
9
12
|
items: Record<string, AccordionItem>;
|
|
10
13
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
}
|
|
14
|
+
type DataInitializer = common.DataInitializer<ElementData>;
|
|
15
|
+
type Element = common.Element<ElementData>;
|
|
16
|
+
type ElementManifest = common.ElementManifest<ElementData>;
|
|
56
17
|
|
|
57
18
|
declare const type = "ACCORDION";
|
|
58
19
|
declare const name = "Accordion";
|
|
59
20
|
declare const initState: DataInitializer;
|
|
60
21
|
declare const version = "1.0";
|
|
22
|
+
declare const ai: {
|
|
23
|
+
Schema: OpenAISchema;
|
|
24
|
+
getPrompt: () => string;
|
|
25
|
+
processResponse: (val: any) => any;
|
|
26
|
+
};
|
|
61
27
|
declare const manifest: ElementManifest;
|
|
62
28
|
|
|
63
|
-
export { type AccordionItem, type DataInitializer, type Element, type ElementData, type ElementManifest, manifest as default, initState, name, type, version };
|
|
29
|
+
export { type AccordionItem, type DataInitializer, type Element, type ElementData, type ElementManifest, ai, manifest as default, initState, name, type, version };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,63 +1,29 @@
|
|
|
1
|
+
import * as common from '@tailor-cms/cek-common';
|
|
2
|
+
import { OpenAISchema } from '@tailor-cms/cek-common';
|
|
3
|
+
|
|
1
4
|
interface AccordionItem {
|
|
2
5
|
id: string;
|
|
3
6
|
header: string;
|
|
4
7
|
body: Record<string, any>;
|
|
5
8
|
position: number;
|
|
6
9
|
}
|
|
7
|
-
interface ElementData {
|
|
10
|
+
interface ElementData extends common.ElementConfig {
|
|
8
11
|
embeds: Record<string, any>;
|
|
9
12
|
items: Record<string, AccordionItem>;
|
|
10
13
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
}
|
|
14
|
+
type DataInitializer = common.DataInitializer<ElementData>;
|
|
15
|
+
type Element = common.Element<ElementData>;
|
|
16
|
+
type ElementManifest = common.ElementManifest<ElementData>;
|
|
56
17
|
|
|
57
18
|
declare const type = "ACCORDION";
|
|
58
19
|
declare const name = "Accordion";
|
|
59
20
|
declare const initState: DataInitializer;
|
|
60
21
|
declare const version = "1.0";
|
|
22
|
+
declare const ai: {
|
|
23
|
+
Schema: OpenAISchema;
|
|
24
|
+
getPrompt: () => string;
|
|
25
|
+
processResponse: (val: any) => any;
|
|
26
|
+
};
|
|
61
27
|
declare const manifest: ElementManifest;
|
|
62
28
|
|
|
63
|
-
export { type AccordionItem, type DataInitializer, type Element, type ElementData, type ElementManifest, manifest as default, initState, name, type, version };
|
|
29
|
+
export { type AccordionItem, type DataInitializer, type Element, type ElementData, type ElementManifest, ai, manifest as default, initState, name, type, version };
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import { v4 as uuid } from "uuid";
|
|
3
|
-
var
|
|
3
|
+
var id1 = uuid();
|
|
4
|
+
var id2 = uuid();
|
|
4
5
|
var type = "ACCORDION";
|
|
5
6
|
var name = "Accordion";
|
|
6
7
|
var initState = () => ({
|
|
7
8
|
embeds: {},
|
|
8
9
|
items: {
|
|
9
|
-
[
|
|
10
|
-
id,
|
|
10
|
+
[id1]: {
|
|
11
|
+
id: id1,
|
|
12
|
+
header: "Accordion Item Title",
|
|
13
|
+
body: {},
|
|
14
|
+
position: 1
|
|
15
|
+
},
|
|
16
|
+
[id2]: {
|
|
17
|
+
id: id2,
|
|
11
18
|
header: "Accordion Item Title",
|
|
12
19
|
body: {},
|
|
13
20
|
position: 1
|
|
@@ -22,6 +29,73 @@ var ui = {
|
|
|
22
29
|
// (e.g. 50/50 layout)
|
|
23
30
|
forceFullWidth: true
|
|
24
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
|
+
};
|
|
25
99
|
var manifest = {
|
|
26
100
|
type,
|
|
27
101
|
version: "1.0",
|
|
@@ -29,10 +103,12 @@ var manifest = {
|
|
|
29
103
|
isComposite: true,
|
|
30
104
|
ssr: false,
|
|
31
105
|
initState,
|
|
32
|
-
ui
|
|
106
|
+
ui,
|
|
107
|
+
ai
|
|
33
108
|
};
|
|
34
109
|
var index_default = manifest;
|
|
35
110
|
export {
|
|
111
|
+
ai,
|
|
36
112
|
index_default as default,
|
|
37
113
|
initState,
|
|
38
114
|
name,
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
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
|
|
6
|
+
"version": "0.1.0",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
9
|
"import": "./dist/index.js",
|
|
@@ -16,12 +16,13 @@
|
|
|
16
16
|
"dist"
|
|
17
17
|
],
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@tailor-cms/
|
|
20
|
-
"
|
|
21
|
-
"
|
|
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"
|
|
22
23
|
},
|
|
23
24
|
"dependencies": {
|
|
24
|
-
"uuid": "^11.0
|
|
25
|
+
"uuid": "^11.1.0"
|
|
25
26
|
},
|
|
26
27
|
"tsup": {
|
|
27
28
|
"entry": [
|
|
@@ -45,8 +46,11 @@
|
|
|
45
46
|
},
|
|
46
47
|
"scripts": {
|
|
47
48
|
"dev": "tsup --watch",
|
|
48
|
-
"build": "tsup",
|
|
49
|
-
"lint": "eslint
|
|
50
|
-
"lint:fix": "pnpm lint --fix"
|
|
49
|
+
"build": "pnpm nuke:dist && tsup",
|
|
50
|
+
"lint": "eslint .",
|
|
51
|
+
"lint:fix": "pnpm lint --fix",
|
|
52
|
+
"nuke": "pnpm dlx del-cli dist node_modules",
|
|
53
|
+
"nuke:dist": "pnpm dlx del-cli dist",
|
|
54
|
+
"prepublish": "pnpm build"
|
|
51
55
|
}
|
|
52
56
|
}
|