@tailor-cms/ce-modal-server 0.1.1 → 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,196 +1,32 @@
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 name in all)
7
- __defProp(target, name, { get: all[name], 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
- afterLoaded: () => afterLoaded,
23
- afterRetrieve: () => afterRetrieve,
24
- afterSave: () => afterSave,
25
- ai: () => ai,
26
- beforeDisplay: () => beforeDisplay,
27
- beforeSave: () => beforeSave,
28
- default: () => index_default,
29
- hookMap: () => hookMap,
30
- initState: () => initState,
31
- onUserInteraction: () => onUserInteraction,
32
- type: () => type
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
33
4
  });
34
- module.exports = __toCommonJS(index_exports);
35
-
36
- // ../../node_modules/.pnpm/uuid@11.1.0/node_modules/uuid/dist/esm/stringify.js
37
- var byteToHex = [];
38
- for (let i = 0; i < 256; ++i) {
39
- byteToHex.push((i + 256).toString(16).slice(1));
40
- }
41
- function unsafeStringify(arr, offset = 0) {
42
- return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
43
- }
44
-
45
- // ../../node_modules/.pnpm/uuid@11.1.0/node_modules/uuid/dist/esm/rng.js
46
- var import_crypto = require("crypto");
47
- var rnds8Pool = new Uint8Array(256);
48
- var poolPtr = rnds8Pool.length;
49
- function rng() {
50
- if (poolPtr > rnds8Pool.length - 16) {
51
- (0, import_crypto.randomFillSync)(rnds8Pool);
52
- poolPtr = 0;
53
- }
54
- return rnds8Pool.slice(poolPtr, poolPtr += 16);
55
- }
56
-
57
- // ../../node_modules/.pnpm/uuid@11.1.0/node_modules/uuid/dist/esm/native.js
58
- var import_crypto2 = require("crypto");
59
- var native_default = { randomUUID: import_crypto2.randomUUID };
60
-
61
- // ../../node_modules/.pnpm/uuid@11.1.0/node_modules/uuid/dist/esm/v4.js
62
- function v4(options, buf, offset) {
63
- var _a;
64
- if (native_default.randomUUID && !buf && !options) {
65
- return native_default.randomUUID();
66
- }
67
- options = options || {};
68
- const rnds = options.random ?? ((_a = options.rng) == null ? void 0 : _a.call(options)) ?? rng();
69
- if (rnds.length < 16) {
70
- throw new Error("Random bytes length must be >= 16");
71
- }
72
- rnds[6] = rnds[6] & 15 | 64;
73
- rnds[8] = rnds[8] & 63 | 128;
74
- if (buf) {
75
- offset = offset || 0;
76
- if (offset < 0 || offset + 16 > buf.length) {
77
- throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
78
- }
79
- for (let i = 0; i < 16; ++i) {
80
- buf[offset + i] = rnds[i];
81
- }
82
- return buf;
83
- }
84
- return unsafeStringify(rnds);
85
- }
86
- var v4_default = v4;
87
-
88
- // ../manifest/dist/index.js
89
- var type = "MODAL";
90
- var initState = () => ({
91
- title: null,
92
- embeds: {}
93
- });
94
- var ai = {
95
- Schema: {
96
- type: "json_schema",
97
- name: "ce_modal",
98
- schema: {
99
- type: "object",
100
- properties: {
101
- title: { type: "string" },
102
- content: { type: "string" }
103
- },
104
- required: ["title", "content"],
105
- additionalProperties: false
106
- }
107
- },
108
- getPrompt: () => `
109
- Generate a modal content element as an object with the following
110
- properties:
111
- {
112
- "title": "",
113
- "content": "",
114
- }
115
- where:
116
- - 'title' is the title of the modal. Do not use more than 3 words.
117
- - 'content' is the text to be displayed in the modal. Create few
118
- paragraphs about the topic.
119
- `,
120
- processResponse: (val) => {
121
- const embedId = v4_default();
122
- const embed = {
123
- id: embedId,
124
- data: { content: val.content },
125
- embedded: true,
126
- position: 1,
127
- type: "TIPTAP_HTML"
128
- };
129
- return {
130
- title: val.title,
131
- embeds: { [embedId]: embed }
132
- };
133
- }
5
+ let _tailor_cms_ce_modal_manifest = require("@tailor-cms/ce-modal-manifest");
6
+ //#region src/index.ts
7
+ const IS_CEK = process.env.CEK_RUNTIME;
8
+ const beforeDisplay = (_element, context) => context;
9
+ const onUserInteraction = (_element, context, payload) => {
10
+ if (IS_CEK) context.openedAt = payload.openedAt;
11
+ return { updateDisplayState: true };
134
12
  };
135
-
136
- // src/index.ts
137
- var IS_CEK = process.env.CEK_RUNTIME;
138
- var USER_STATE = {};
139
- function beforeSave(element, _services) {
140
- return element;
141
- }
142
- function afterSave(element, _services) {
143
- return element;
144
- }
145
- function afterLoaded(element, _services, _runtime) {
146
- return element;
147
- }
148
- function afterRetrieve(element, _services, _runtime) {
149
- return element;
150
- }
151
- function beforeDisplay(_element, context) {
152
- return { ...context, ...USER_STATE };
153
- }
154
- function onUserInteraction(_element, context, payload) {
155
- if (IS_CEK) {
156
- USER_STATE.interactionTimestamp = (/* @__PURE__ */ new Date()).getTime();
157
- context.contextTimestamp = USER_STATE.interactionTimestamp;
158
- Object.assign(USER_STATE, payload);
159
- }
160
- return { updateDisplayState: true };
161
- }
162
- var hookMap = new Map(
163
- Object.entries({
164
- beforeSave,
165
- afterSave,
166
- afterLoaded,
167
- afterRetrieve,
168
- onUserInteraction,
169
- beforeDisplay
170
- })
171
- );
172
- var index_default = {
173
- type,
174
- hookMap,
175
- initState,
176
- beforeSave,
177
- afterSave,
178
- afterLoaded,
179
- afterRetrieve,
180
- onUserInteraction,
181
- beforeDisplay,
182
- ai
13
+ const hookMap = new Map(Object.entries({
14
+ beforeDisplay,
15
+ onUserInteraction
16
+ }));
17
+ const serverModule = {
18
+ type: _tailor_cms_ce_modal_manifest.type,
19
+ initState: _tailor_cms_ce_modal_manifest.initState,
20
+ hookMap,
21
+ beforeDisplay,
22
+ onUserInteraction,
23
+ ai: _tailor_cms_ce_modal_manifest.ai
183
24
  };
184
- // Annotate the CommonJS export names for ESM import in node:
185
- 0 && (module.exports = {
186
- afterLoaded,
187
- afterRetrieve,
188
- afterSave,
189
- ai,
190
- beforeDisplay,
191
- beforeSave,
192
- hookMap,
193
- initState,
194
- onUserInteraction,
195
- type
196
- });
25
+ //#endregion
26
+ exports.ai = _tailor_cms_ce_modal_manifest.ai;
27
+ exports.beforeDisplay = beforeDisplay;
28
+ exports.default = serverModule;
29
+ exports.hookMap = hookMap;
30
+ exports.initState = _tailor_cms_ce_modal_manifest.initState;
31
+ exports.onUserInteraction = onUserInteraction;
32
+ exports.type = _tailor_cms_ce_modal_manifest.type;
package/dist/index.d.cts CHANGED
@@ -1,44 +1,10 @@
1
- import * as _tailor_cms_cek_common from '@tailor-cms/cek-common';
2
- import { HookServices, ServerRuntime } from '@tailor-cms/cek-common';
3
- import * as _tailor_cms_ce_modal_manifest from '@tailor-cms/ce-modal-manifest';
4
- import { Element } from '@tailor-cms/ce-modal-manifest';
5
- export { ai, initState, type } from '@tailor-cms/ce-modal-manifest';
1
+ import { Element, ai, initState, type } from "@tailor-cms/ce-modal-manifest";
2
+ import { BeforeDisplayHook, HookMap, OnUserInteractionHook, ServerModule } from "@tailor-cms/cek-common";
6
3
 
7
- declare function beforeSave(element: Element, _services: HookServices): Element;
8
- declare function afterSave(element: Element, _services: HookServices): Element;
9
- declare function afterLoaded(element: Element, _services: HookServices, _runtime: ServerRuntime): Element;
10
- declare function afterRetrieve(element: Element, _services: HookServices, _runtime: ServerRuntime): Element;
11
- declare function beforeDisplay(_element: Element, context: any): any;
12
- declare function onUserInteraction(_element: Element, context: any, payload: any): any;
13
- declare const hookMap: Map<string, typeof beforeSave | typeof afterSave | typeof afterLoaded | typeof afterRetrieve | typeof onUserInteraction | typeof beforeDisplay>;
14
- declare const _default: {
15
- type: string;
16
- hookMap: Map<string, typeof beforeSave | typeof afterSave | typeof afterLoaded | typeof afterRetrieve | typeof onUserInteraction | typeof beforeDisplay>;
17
- initState: _tailor_cms_ce_modal_manifest.DataInitializer;
18
- beforeSave: typeof beforeSave;
19
- afterSave: typeof afterSave;
20
- afterLoaded: typeof afterLoaded;
21
- afterRetrieve: typeof afterRetrieve;
22
- onUserInteraction: typeof onUserInteraction;
23
- beforeDisplay: typeof beforeDisplay;
24
- ai: {
25
- Schema: _tailor_cms_cek_common.OpenAISchema;
26
- getPrompt: () => string;
27
- processResponse: (val: any) => {
28
- title: any;
29
- embeds: {
30
- [x: string]: {
31
- id: string;
32
- data: {
33
- content: any;
34
- };
35
- embedded: boolean;
36
- position: number;
37
- type: string;
38
- };
39
- };
40
- };
41
- };
42
- };
43
-
44
- export { afterLoaded, afterRetrieve, afterSave, beforeDisplay, beforeSave, _default as default, hookMap, onUserInteraction };
4
+ //#region src/index.d.ts
5
+ declare const beforeDisplay: BeforeDisplayHook<Element>;
6
+ declare const onUserInteraction: OnUserInteractionHook<Element>;
7
+ declare const hookMap: HookMap<Element>;
8
+ declare const serverModule: ServerModule<Element>;
9
+ //#endregion
10
+ export { ai, beforeDisplay, serverModule as default, hookMap, initState, onUserInteraction, type };
@@ -0,0 +1,10 @@
1
+ import { Element, ai, initState, type } from "@tailor-cms/ce-modal-manifest";
2
+ import { BeforeDisplayHook, HookMap, OnUserInteractionHook, ServerModule } from "@tailor-cms/cek-common";
3
+
4
+ //#region src/index.d.ts
5
+ declare const beforeDisplay: BeforeDisplayHook<Element>;
6
+ declare const onUserInteraction: OnUserInteractionHook<Element>;
7
+ declare const hookMap: HookMap<Element>;
8
+ declare const serverModule: ServerModule<Element>;
9
+ //#endregion
10
+ export { ai, beforeDisplay, serverModule as default, hookMap, initState, onUserInteraction, type };
package/dist/index.mjs ADDED
@@ -0,0 +1,22 @@
1
+ import { ai, initState, type } from "@tailor-cms/ce-modal-manifest";
2
+ //#region src/index.ts
3
+ const IS_CEK = process.env.CEK_RUNTIME;
4
+ const beforeDisplay = (_element, context) => context;
5
+ const onUserInteraction = (_element, context, payload) => {
6
+ if (IS_CEK) context.openedAt = payload.openedAt;
7
+ return { updateDisplayState: true };
8
+ };
9
+ const hookMap = new Map(Object.entries({
10
+ beforeDisplay,
11
+ onUserInteraction
12
+ }));
13
+ const serverModule = {
14
+ type,
15
+ initState,
16
+ hookMap,
17
+ beforeDisplay,
18
+ onUserInteraction,
19
+ ai
20
+ };
21
+ //#endregion
22
+ export { ai, beforeDisplay, serverModule as default, hookMap, initState, onUserInteraction, type };
package/package.json CHANGED
@@ -3,48 +3,43 @@
3
3
  "description": "Tailor CMS modal server component",
4
4
  "author": "Studion <info@gostudion.com> (https://github.com/tailor-cms)",
5
5
  "type": "module",
6
- "version": "0.1.1",
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
+ "dependencies": {
19
+ "@tailor-cms/cek-common": "2.0.1",
20
+ "@tailor-cms/ce-modal-manifest": "2.0.0"
21
+ },
18
22
  "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
- "@tailor-cms/ce-modal-manifest": "0.1.1"
23
+ "@tailor-cms/eslint-config": "2.0.1",
24
+ "tsdown": "^0.21.10",
25
+ "typescript": "^6.0.3"
24
26
  },
25
- "tsup": {
26
- "entry": [
27
- "src/index.ts"
28
- ],
29
- "target": [
30
- "node14",
31
- "es2022"
32
- ],
27
+ "tsdown": {
28
+ "target": "node24",
33
29
  "format": [
34
30
  "cjs",
35
31
  "esm"
36
- ],
37
- "bundle": true,
38
- "minify": false,
39
- "clean": false,
40
- "dts": true
32
+ ]
41
33
  },
42
34
  "publishConfig": {
43
35
  "access": "public"
44
36
  },
37
+ "engines": {
38
+ "node": ">=24"
39
+ },
45
40
  "scripts": {
46
- "dev": "tsup --watch src --watch ../manifest/dist",
47
- "build": "pnpm nuke:dist && tsup",
41
+ "dev": "tsdown --watch src --watch ../manifest/dist",
42
+ "build": "pnpm nuke:dist && tsdown",
48
43
  "lint": "eslint .",
49
44
  "lint:fix": "pnpm lint --fix",
50
45
  "nuke": "pnpm dlx del-cli dist node_modules",
package/dist/index.d.ts DELETED
@@ -1,44 +0,0 @@
1
- import * as _tailor_cms_cek_common from '@tailor-cms/cek-common';
2
- import { HookServices, ServerRuntime } from '@tailor-cms/cek-common';
3
- import * as _tailor_cms_ce_modal_manifest from '@tailor-cms/ce-modal-manifest';
4
- import { Element } from '@tailor-cms/ce-modal-manifest';
5
- export { ai, initState, type } from '@tailor-cms/ce-modal-manifest';
6
-
7
- declare function beforeSave(element: Element, _services: HookServices): Element;
8
- declare function afterSave(element: Element, _services: HookServices): Element;
9
- declare function afterLoaded(element: Element, _services: HookServices, _runtime: ServerRuntime): Element;
10
- declare function afterRetrieve(element: Element, _services: HookServices, _runtime: ServerRuntime): Element;
11
- declare function beforeDisplay(_element: Element, context: any): any;
12
- declare function onUserInteraction(_element: Element, context: any, payload: any): any;
13
- declare const hookMap: Map<string, typeof beforeSave | typeof afterSave | typeof afterLoaded | typeof afterRetrieve | typeof onUserInteraction | typeof beforeDisplay>;
14
- declare const _default: {
15
- type: string;
16
- hookMap: Map<string, typeof beforeSave | typeof afterSave | typeof afterLoaded | typeof afterRetrieve | typeof onUserInteraction | typeof beforeDisplay>;
17
- initState: _tailor_cms_ce_modal_manifest.DataInitializer;
18
- beforeSave: typeof beforeSave;
19
- afterSave: typeof afterSave;
20
- afterLoaded: typeof afterLoaded;
21
- afterRetrieve: typeof afterRetrieve;
22
- onUserInteraction: typeof onUserInteraction;
23
- beforeDisplay: typeof beforeDisplay;
24
- ai: {
25
- Schema: _tailor_cms_cek_common.OpenAISchema;
26
- getPrompt: () => string;
27
- processResponse: (val: any) => {
28
- title: any;
29
- embeds: {
30
- [x: string]: {
31
- id: string;
32
- data: {
33
- content: any;
34
- };
35
- embedded: boolean;
36
- position: number;
37
- type: string;
38
- };
39
- };
40
- };
41
- };
42
- };
43
-
44
- export { afterLoaded, afterRetrieve, afterSave, beforeDisplay, beforeSave, _default as default, hookMap, onUserInteraction };
package/dist/index.js DELETED
@@ -1,161 +0,0 @@
1
- // ../../node_modules/.pnpm/uuid@11.1.0/node_modules/uuid/dist/esm/stringify.js
2
- var byteToHex = [];
3
- for (let i = 0; i < 256; ++i) {
4
- byteToHex.push((i + 256).toString(16).slice(1));
5
- }
6
- function unsafeStringify(arr, offset = 0) {
7
- return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
8
- }
9
-
10
- // ../../node_modules/.pnpm/uuid@11.1.0/node_modules/uuid/dist/esm/rng.js
11
- import { randomFillSync } from "crypto";
12
- var rnds8Pool = new Uint8Array(256);
13
- var poolPtr = rnds8Pool.length;
14
- function rng() {
15
- if (poolPtr > rnds8Pool.length - 16) {
16
- randomFillSync(rnds8Pool);
17
- poolPtr = 0;
18
- }
19
- return rnds8Pool.slice(poolPtr, poolPtr += 16);
20
- }
21
-
22
- // ../../node_modules/.pnpm/uuid@11.1.0/node_modules/uuid/dist/esm/native.js
23
- import { randomUUID } from "crypto";
24
- var native_default = { randomUUID };
25
-
26
- // ../../node_modules/.pnpm/uuid@11.1.0/node_modules/uuid/dist/esm/v4.js
27
- function v4(options, buf, offset) {
28
- var _a;
29
- if (native_default.randomUUID && !buf && !options) {
30
- return native_default.randomUUID();
31
- }
32
- options = options || {};
33
- const rnds = options.random ?? ((_a = options.rng) == null ? void 0 : _a.call(options)) ?? rng();
34
- if (rnds.length < 16) {
35
- throw new Error("Random bytes length must be >= 16");
36
- }
37
- rnds[6] = rnds[6] & 15 | 64;
38
- rnds[8] = rnds[8] & 63 | 128;
39
- if (buf) {
40
- offset = offset || 0;
41
- if (offset < 0 || offset + 16 > buf.length) {
42
- throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
43
- }
44
- for (let i = 0; i < 16; ++i) {
45
- buf[offset + i] = rnds[i];
46
- }
47
- return buf;
48
- }
49
- return unsafeStringify(rnds);
50
- }
51
- var v4_default = v4;
52
-
53
- // ../manifest/dist/index.js
54
- var type = "MODAL";
55
- var initState = () => ({
56
- title: null,
57
- embeds: {}
58
- });
59
- var ai = {
60
- Schema: {
61
- type: "json_schema",
62
- name: "ce_modal",
63
- schema: {
64
- type: "object",
65
- properties: {
66
- title: { type: "string" },
67
- content: { type: "string" }
68
- },
69
- required: ["title", "content"],
70
- additionalProperties: false
71
- }
72
- },
73
- getPrompt: () => `
74
- Generate a modal content element as an object with the following
75
- properties:
76
- {
77
- "title": "",
78
- "content": "",
79
- }
80
- where:
81
- - 'title' is the title of the modal. Do not use more than 3 words.
82
- - 'content' is the text to be displayed in the modal. Create few
83
- paragraphs about the topic.
84
- `,
85
- processResponse: (val) => {
86
- const embedId = v4_default();
87
- const embed = {
88
- id: embedId,
89
- data: { content: val.content },
90
- embedded: true,
91
- position: 1,
92
- type: "TIPTAP_HTML"
93
- };
94
- return {
95
- title: val.title,
96
- embeds: { [embedId]: embed }
97
- };
98
- }
99
- };
100
-
101
- // src/index.ts
102
- var IS_CEK = process.env.CEK_RUNTIME;
103
- var USER_STATE = {};
104
- function beforeSave(element, _services) {
105
- return element;
106
- }
107
- function afterSave(element, _services) {
108
- return element;
109
- }
110
- function afterLoaded(element, _services, _runtime) {
111
- return element;
112
- }
113
- function afterRetrieve(element, _services, _runtime) {
114
- return element;
115
- }
116
- function beforeDisplay(_element, context) {
117
- return { ...context, ...USER_STATE };
118
- }
119
- function onUserInteraction(_element, context, payload) {
120
- if (IS_CEK) {
121
- USER_STATE.interactionTimestamp = (/* @__PURE__ */ new Date()).getTime();
122
- context.contextTimestamp = USER_STATE.interactionTimestamp;
123
- Object.assign(USER_STATE, payload);
124
- }
125
- return { updateDisplayState: true };
126
- }
127
- var hookMap = new Map(
128
- Object.entries({
129
- beforeSave,
130
- afterSave,
131
- afterLoaded,
132
- afterRetrieve,
133
- onUserInteraction,
134
- beforeDisplay
135
- })
136
- );
137
- var index_default = {
138
- type,
139
- hookMap,
140
- initState,
141
- beforeSave,
142
- afterSave,
143
- afterLoaded,
144
- afterRetrieve,
145
- onUserInteraction,
146
- beforeDisplay,
147
- ai
148
- };
149
- export {
150
- afterLoaded,
151
- afterRetrieve,
152
- afterSave,
153
- ai,
154
- beforeDisplay,
155
- beforeSave,
156
- index_default as default,
157
- hookMap,
158
- initState,
159
- onUserInteraction,
160
- type
161
- };