@oneclick.dev/cms-core-modules 0.0.122 → 0.0.123
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/{ContentEditor-CoJjsV-m.js → ContentEditor-C-Wm48ai.js} +63 -59
- package/dist/{ContentEditor-DIwqplfB.mjs → ContentEditor-MDGolnIP.mjs} +27596 -26138
- package/dist/{NewReservationDialog.vue_vue_type_script_setup_true_lang-bZidw6RT.mjs → NewReservationDialog.vue_vue_type_script_setup_true_lang-8I_Z9cD_.mjs} +530 -530
- package/dist/NewReservationDialog.vue_vue_type_script_setup_true_lang-BVE_uURZ.js +1 -0
- package/dist/OrderDetailDialog.vue_vue_type_script_setup_true_lang-BdFa-xNf.mjs +3566 -0
- package/dist/OrderDetailDialog.vue_vue_type_script_setup_true_lang-DzPOadcU.js +925 -0
- package/dist/TableCalculationWidget-CkQPrVUd.js +59 -0
- package/dist/TableCalculationWidget-CrqcLGfU.mjs +254 -0
- package/dist/TableDataWidget-7qvC3Egd.js +1 -0
- package/dist/TableDataWidget-DMTSoGRO.mjs +121 -0
- package/dist/TableOverviewCard-AFq-puJs.js +1 -0
- package/dist/TableOverviewCard-Ci0d4o4w.mjs +391 -0
- package/dist/TableResultView.vue_vue_type_script_setup_true_lang-CBn-Oxl9.mjs +534 -0
- package/dist/TableResultView.vue_vue_type_script_setup_true_lang-C_Lv-SmJ.js +1 -0
- package/dist/TableRowActionCard-BhdnnPaq.mjs +266 -0
- package/dist/TableRowActionCard-IzB6tNN-.js +1 -0
- package/dist/TableView-BkwoKREo.js +4 -0
- package/dist/TableView-C4Zyp8d7.mjs +8228 -0
- package/dist/{agenda-BCKDYOeF.mjs → agenda-DWdbWUbb.mjs} +10 -9
- package/dist/agenda-r9Gl85GL.js +1 -0
- package/dist/dateRangePresets-B-l5b_wR.mjs +48 -0
- package/dist/dateRangePresets-CPWqst_x.js +1 -0
- package/dist/fuse-Deb-Iq39.mjs +1473 -0
- package/dist/fuse-_CGUd5Zq.js +1 -0
- package/dist/{index-DU3Ib10Z.mjs → index-B_qaX29C.mjs} +7 -6
- package/dist/{index-Bk3yLv_G.js → index-yHLT6gaZ.js} +3 -3
- package/dist/index.cjs.js +1 -1
- package/dist/index.mjs +419 -109
- package/dist/{orders-CElKNc1v.mjs → orders-BfTLIm7U.mjs} +10 -9
- package/dist/orders-DUa2PVoa.js +1 -0
- package/dist/reports-ChCsd1Gk.mjs +1107 -0
- package/dist/reports-DmJPm8uP.js +158 -0
- package/dist/row-item-C1dUyimV.mjs +204 -0
- package/dist/row-item-Cyo3m3MZ.js +1 -0
- package/dist/src/appointments/components/edit/EventDialog/BookingsList.vue.d.ts +9 -3
- package/dist/src/appointments/components/edit/EventDialog/OrderDetailDialog.vue.d.ts +2 -0
- package/dist/src/appointments/components/edit/EventDialog/ReservationDetailDialog.vue.d.ts +4 -2
- package/dist/src/appointments/components/edit/dashboard/BookingsList.vue.d.ts +9 -3
- package/dist/src/appointments/pages/edit/orders.vue.d.ts +9 -3
- package/dist/src/appointments/pages/edit/reports.vue.d.ts +229 -1
- package/dist/src/table/chat-components/TableCalculationWidget.vue.d.ts +15 -0
- package/dist/src/table/chat-components/TableDataWidget.vue.d.ts +15 -0
- package/dist/src/table/chat-components/TableOverviewCard.vue.d.ts +61 -0
- package/dist/src/table/chat-components/TableResultView.vue.d.ts +48 -0
- package/dist/src/table/chat-components/TableRowActionCard.vue.d.ts +15 -0
- package/dist/src/table/components/filters/DialogTableFilterOptionItem.vue.d.ts +16 -0
- package/dist/src/table/components/filters/NumberComparisonFilter.vue.d.ts +12 -0
- package/dist/src/table/components/filters/NumberComparisonFilterSettings.vue.d.ts +12 -0
- package/dist/src/table/components/filters/NumberRangeFilter.vue.d.ts +12 -0
- package/dist/src/table/components/filters/NumberRangeFilterSettings.vue.d.ts +12 -0
- package/dist/src/table/components/filters/filter-utils.d.ts +14 -0
- package/dist/src/table/composables/useTableAgentTools.d.ts +33 -0
- package/dist/src/table/index.d.ts +339 -0
- package/dist/src/table/tool-sandbox.d.ts +13 -0
- package/dist/src/table/tool-utils.d.ts +11 -0
- package/dist/src/table/tools.d.ts +333 -1
- package/dist/src/table/types.d.ts +79 -0
- package/dist/tool-sandbox-DdkMLkDK.mjs +182 -0
- package/dist/tool-sandbox-DoF1PsyS.js +115 -0
- package/dist/useTableAgentTools-D5mzGf3A.js +1 -0
- package/dist/useTableAgentTools-DcN3kYRL.mjs +131 -0
- package/package.json +17 -17
- package/src/table/tools.ts +304 -1
- package/dist/NewReservationDialog.vue_vue_type_script_setup_true_lang-BdZbcubW.js +0 -1
- package/dist/OrderDetailDialog.vue_vue_type_script_setup_true_lang-BYSeUW_V.js +0 -925
- package/dist/OrderDetailDialog.vue_vue_type_script_setup_true_lang-DwAUYR8p.mjs +0 -5021
- package/dist/TableView-Ctnep-Qu.mjs +0 -6247
- package/dist/TableView-DJqyJL9L.js +0 -4
- package/dist/agenda-B54F8cEr.js +0 -1
- package/dist/orders-BMosTk6r.js +0 -1
- package/dist/reports-BQT_GZzU.js +0 -158
- package/dist/reports-DksZCTOw.mjs +0 -837
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export type TableColumnType = 'text' | 'number' | 'date' | 'datetime' | 'boolean' | 'URL' | 'email' | 'phone' | 'currency' | 'image' | 'array' | 'array-counter' | 'html';
|
|
2
|
+
export interface TableColumn {
|
|
3
|
+
id?: string;
|
|
4
|
+
property: string;
|
|
5
|
+
label: string;
|
|
6
|
+
type: TableColumnType | string;
|
|
7
|
+
visible: boolean;
|
|
8
|
+
_remove?: boolean;
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
}
|
|
11
|
+
export type TableFilterType = 'multi-select' | 'number-range' | 'number-comparison';
|
|
12
|
+
export type TableFilterApplyMode = 'instant' | 'manual';
|
|
13
|
+
export type NumberComparisonOperator = 'equals' | 'not-equals' | 'greater-than' | 'greater-than-or-equal' | 'less-than' | 'less-than-or-equal';
|
|
14
|
+
export interface BaseTableFilter {
|
|
15
|
+
id?: string;
|
|
16
|
+
type: TableFilterType;
|
|
17
|
+
property: string;
|
|
18
|
+
label: string;
|
|
19
|
+
applyMode?: TableFilterApplyMode;
|
|
20
|
+
}
|
|
21
|
+
export interface MultiSelectFilterOption {
|
|
22
|
+
id: string;
|
|
23
|
+
value: string;
|
|
24
|
+
label: string;
|
|
25
|
+
checked: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface MultiSelectTableFilter extends BaseTableFilter {
|
|
28
|
+
type: 'multi-select';
|
|
29
|
+
options: MultiSelectFilterOption[];
|
|
30
|
+
}
|
|
31
|
+
export interface NumberRangeTableFilter extends BaseTableFilter {
|
|
32
|
+
type: 'number-range';
|
|
33
|
+
min?: number;
|
|
34
|
+
max?: number;
|
|
35
|
+
step?: number;
|
|
36
|
+
defaultMin?: number;
|
|
37
|
+
defaultMax?: number;
|
|
38
|
+
prefix?: string;
|
|
39
|
+
suffix?: string;
|
|
40
|
+
locale?: string;
|
|
41
|
+
showSlider?: boolean;
|
|
42
|
+
showInputs?: boolean;
|
|
43
|
+
showHistogram?: boolean;
|
|
44
|
+
histogramBins?: number;
|
|
45
|
+
allowOpenMin?: boolean;
|
|
46
|
+
allowOpenMax?: boolean;
|
|
47
|
+
inclusive?: boolean;
|
|
48
|
+
}
|
|
49
|
+
export interface NumberComparisonTableFilter extends BaseTableFilter {
|
|
50
|
+
type: 'number-comparison';
|
|
51
|
+
operators?: NumberComparisonOperator[];
|
|
52
|
+
defaultOperator?: NumberComparisonOperator;
|
|
53
|
+
defaultValue?: number | null;
|
|
54
|
+
step?: number;
|
|
55
|
+
prefix?: string;
|
|
56
|
+
suffix?: string;
|
|
57
|
+
}
|
|
58
|
+
export type NumberRangeFilter = NumberRangeTableFilter;
|
|
59
|
+
export type NumberComparisonFilter = NumberComparisonTableFilter;
|
|
60
|
+
export type TableFilter = MultiSelectTableFilter | NumberRangeTableFilter | NumberComparisonTableFilter;
|
|
61
|
+
export interface NumberRangeFilterValue {
|
|
62
|
+
min: number | null;
|
|
63
|
+
max: number | null;
|
|
64
|
+
}
|
|
65
|
+
export interface NumberComparisonFilterValue {
|
|
66
|
+
operator: NumberComparisonOperator;
|
|
67
|
+
value: number;
|
|
68
|
+
}
|
|
69
|
+
export type TableFilterOperator = '==' | '!=' | '>' | '>=' | '<' | '<=' | 'contains' | 'startsWith' | 'endsWith' | 'in' | 'notIn' | 'isEmpty' | 'isNotEmpty';
|
|
70
|
+
export interface TableToolFilter {
|
|
71
|
+
property: string;
|
|
72
|
+
operator: TableFilterOperator | string;
|
|
73
|
+
value?: any;
|
|
74
|
+
values?: any[];
|
|
75
|
+
}
|
|
76
|
+
export interface TableRowMatch {
|
|
77
|
+
property: string;
|
|
78
|
+
value: string | number | boolean | null;
|
|
79
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { s as p } from "./TableResultView.vue_vue_type_script_setup_true_lang-CBn-Oxl9.mjs";
|
|
2
|
+
const E = 1500, S = 8 * 1024 * 1024, _ = 256 * 1024, g = 2e4, M = String.raw`
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
const nativePostMessage = self.postMessage.bind(self);
|
|
6
|
+
const nativeStringify = JSON.stringify.bind(JSON);
|
|
7
|
+
const nativeParse = JSON.parse.bind(JSON);
|
|
8
|
+
const NativeWeakSet = WeakSet;
|
|
9
|
+
const nativeEncoder = new TextEncoder();
|
|
10
|
+
const nativeEncode = nativeEncoder.encode.bind(nativeEncoder);
|
|
11
|
+
const arrayBufferByteLengthGetter = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, 'byteLength').get;
|
|
12
|
+
const nativeBufferByteLength = Function.prototype.call.bind(arrayBufferByteLengthGetter);
|
|
13
|
+
|
|
14
|
+
function encodedByteLength(value) {
|
|
15
|
+
return nativeBufferByteLength(nativeEncode(value).buffer);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function safeResult(value, maxBytes) {
|
|
19
|
+
const seen = new NativeWeakSet();
|
|
20
|
+
const serialized = nativeStringify(value, (key, nested) => {
|
|
21
|
+
if (key === '__proto__' || key === 'constructor' || key === 'prototype') return undefined;
|
|
22
|
+
if (typeof nested === 'bigint') return String(nested);
|
|
23
|
+
if (nested instanceof Date) return nested.toISOString();
|
|
24
|
+
if (nested && typeof nested === 'object') {
|
|
25
|
+
if (seen.has(nested)) return '[Circular]';
|
|
26
|
+
seen.add(nested);
|
|
27
|
+
}
|
|
28
|
+
return nested;
|
|
29
|
+
});
|
|
30
|
+
if (serialized === undefined) throw new Error('The calculation returned undefined or a non-serializable value.');
|
|
31
|
+
if (encodedByteLength(serialized) > maxBytes) {
|
|
32
|
+
throw new Error('The calculation result is too large. Return a smaller summary or fewer rows.');
|
|
33
|
+
}
|
|
34
|
+
return nativeParse(serialized);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
self.onmessage = async event => {
|
|
38
|
+
const message = event.data || {};
|
|
39
|
+
if (message.type !== 'run' || typeof message.token !== 'string') return;
|
|
40
|
+
const token = message.token;
|
|
41
|
+
|
|
42
|
+
try {
|
|
43
|
+
for (const name of ['fetch', 'XMLHttpRequest', 'WebSocket', 'EventSource', 'importScripts', 'Worker', 'SharedWorker']) {
|
|
44
|
+
try {
|
|
45
|
+
Object.defineProperty(self, name, { value: undefined, writable: false, configurable: false });
|
|
46
|
+
} catch {}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const args = message.args && typeof message.args === 'object' ? message.args : {};
|
|
50
|
+
const keys = Object.keys(args);
|
|
51
|
+
if (!keys.every(key => /^[$A-Z_][0-9A-Z_$]*$/i.test(key) && !['constructor', 'prototype', '__proto__'].includes(key))) {
|
|
52
|
+
throw new Error('The calculation contains an invalid argument name.');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const calculate = Function(...keys, "'use strict';\n" + message.code);
|
|
56
|
+
const result = await Promise.resolve(calculate(...keys.map(key => args[key])));
|
|
57
|
+
nativePostMessage({
|
|
58
|
+
type: 'result',
|
|
59
|
+
token,
|
|
60
|
+
ok: true,
|
|
61
|
+
result: safeResult(result, message.maxOutputBytes),
|
|
62
|
+
});
|
|
63
|
+
} catch (error) {
|
|
64
|
+
nativePostMessage({
|
|
65
|
+
type: 'result',
|
|
66
|
+
token,
|
|
67
|
+
ok: false,
|
|
68
|
+
error: String(error && error.message ? error.message : error).slice(0, 500),
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
`, T = String.raw`
|
|
73
|
+
'use strict';
|
|
74
|
+
const workerSource = __WORKER_SOURCE__;
|
|
75
|
+
|
|
76
|
+
window.addEventListener('message', event => {
|
|
77
|
+
const message = event.data || {};
|
|
78
|
+
if (event.source !== parent || message.type !== 'table-sandbox-run' || typeof message.token !== 'string') return;
|
|
79
|
+
|
|
80
|
+
const workerUrl = URL.createObjectURL(new Blob([workerSource], { type: 'text/javascript' }));
|
|
81
|
+
const worker = new Worker(workerUrl);
|
|
82
|
+
URL.revokeObjectURL(workerUrl);
|
|
83
|
+
let finished = false;
|
|
84
|
+
|
|
85
|
+
const finish = payload => {
|
|
86
|
+
if (finished) return;
|
|
87
|
+
finished = true;
|
|
88
|
+
clearTimeout(timer);
|
|
89
|
+
worker.terminate();
|
|
90
|
+
parent.postMessage({ type: 'table-sandbox-result', token: message.token, ...payload }, '*');
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const timer = setTimeout(() => {
|
|
94
|
+
finish({ ok: false, error: 'The calculation timed out.' });
|
|
95
|
+
}, message.timeoutMs);
|
|
96
|
+
|
|
97
|
+
worker.onmessage = workerEvent => {
|
|
98
|
+
const response = workerEvent.data || {};
|
|
99
|
+
if (response.type !== 'result' || response.token !== message.token) return;
|
|
100
|
+
finish(response.ok
|
|
101
|
+
? { ok: true, result: response.result }
|
|
102
|
+
: { ok: false, error: response.error || 'The calculation failed.' });
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
worker.onerror = () => finish({ ok: false, error: 'The isolated calculation worker failed.' });
|
|
106
|
+
worker.postMessage({
|
|
107
|
+
type: 'run',
|
|
108
|
+
token: message.token,
|
|
109
|
+
code: message.code,
|
|
110
|
+
args: message.args,
|
|
111
|
+
maxOutputBytes: message.maxOutputBytes,
|
|
112
|
+
});
|
|
113
|
+
}, { passive: true });
|
|
114
|
+
|
|
115
|
+
parent.postMessage({ type: 'table-sandbox-ready' }, '*');
|
|
116
|
+
`.replace("__WORKER_SOURCE__", JSON.stringify(M));
|
|
117
|
+
function x() {
|
|
118
|
+
return `<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval' blob:; worker-src blob:; child-src blob:; connect-src 'none'; img-src 'none'; media-src 'none'; object-src 'none'; frame-src 'none'; style-src 'unsafe-inline'"></head><body><script>${T.replace(/<\/script/gi, "<\\/script")}<\/script></body></html>`;
|
|
119
|
+
}
|
|
120
|
+
function O() {
|
|
121
|
+
return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `table-sandbox-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
122
|
+
}
|
|
123
|
+
function U(r, h = {}, s = {}) {
|
|
124
|
+
if (typeof document > "u" || !document.body)
|
|
125
|
+
return Promise.reject(new Error("Table calculations can only run in a browser session."));
|
|
126
|
+
if (typeof r != "string" || !r.trim())
|
|
127
|
+
return Promise.reject(new Error("No calculation code was provided."));
|
|
128
|
+
if (r.length > g)
|
|
129
|
+
return Promise.reject(new Error(`Calculation code is limited to ${g} characters.`));
|
|
130
|
+
const u = Math.min(Math.max(Math.trunc(s.timeoutMs ?? E), 100), 5e3), k = Math.min(Math.max(Math.trunc(s.maxInputBytes ?? S), 1024), 16 * 1024 * 1024), l = Math.min(Math.max(Math.trunc(s.maxOutputBytes ?? _), 1024), 1024 * 1024);
|
|
131
|
+
let d;
|
|
132
|
+
try {
|
|
133
|
+
d = p(h, k);
|
|
134
|
+
} catch (o) {
|
|
135
|
+
return Promise.reject(o);
|
|
136
|
+
}
|
|
137
|
+
return new Promise((o, a) => {
|
|
138
|
+
const e = document.createElement("iframe"), f = O();
|
|
139
|
+
let i = !1, m = !1;
|
|
140
|
+
e.setAttribute("sandbox", "allow-scripts"), e.setAttribute("aria-hidden", "true"), e.tabIndex = -1, e.style.position = "fixed", e.style.width = "0", e.style.height = "0", e.style.border = "0", e.style.opacity = "0", e.style.pointerEvents = "none", e.srcdoc = x();
|
|
141
|
+
const b = () => {
|
|
142
|
+
clearTimeout(v), window.removeEventListener("message", y), e.remove();
|
|
143
|
+
}, n = (t) => {
|
|
144
|
+
m || (m = !0, b(), t());
|
|
145
|
+
}, w = () => {
|
|
146
|
+
e.contentWindow?.postMessage({
|
|
147
|
+
type: "table-sandbox-run",
|
|
148
|
+
token: f,
|
|
149
|
+
code: r,
|
|
150
|
+
args: d,
|
|
151
|
+
timeoutMs: u,
|
|
152
|
+
maxOutputBytes: l
|
|
153
|
+
}, "*");
|
|
154
|
+
}, y = (t) => {
|
|
155
|
+
if (!(t.source !== e.contentWindow || !t.data || typeof t.data != "object")) {
|
|
156
|
+
if (t.data.type === "table-sandbox-ready") {
|
|
157
|
+
if (i) return;
|
|
158
|
+
i = !0, w();
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
if (!(t.data.type !== "table-sandbox-result" || t.data.token !== f)) {
|
|
162
|
+
if (!t.data.ok) {
|
|
163
|
+
n(() => a(new Error(t.data.error || "The isolated calculation failed.")));
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
try {
|
|
167
|
+
const c = p(t.data.result, l);
|
|
168
|
+
n(() => o(c));
|
|
169
|
+
} catch (c) {
|
|
170
|
+
n(() => a(c));
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}, v = window.setTimeout(() => {
|
|
175
|
+
n(() => a(new Error(i ? "The calculation timed out." : "The isolated calculation environment could not start.")));
|
|
176
|
+
}, u + 1e3);
|
|
177
|
+
window.addEventListener("message", y), document.body.appendChild(e);
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
export {
|
|
181
|
+
U as r
|
|
182
|
+
};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";const p=require("./TableResultView.vue_vue_type_script_setup_true_lang-C_Lv-SmJ.js"),_=1500,E=8*1024*1024,S=256*1024,g=2e4,T=String.raw`
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const nativePostMessage = self.postMessage.bind(self);
|
|
5
|
+
const nativeStringify = JSON.stringify.bind(JSON);
|
|
6
|
+
const nativeParse = JSON.parse.bind(JSON);
|
|
7
|
+
const NativeWeakSet = WeakSet;
|
|
8
|
+
const nativeEncoder = new TextEncoder();
|
|
9
|
+
const nativeEncode = nativeEncoder.encode.bind(nativeEncoder);
|
|
10
|
+
const arrayBufferByteLengthGetter = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, 'byteLength').get;
|
|
11
|
+
const nativeBufferByteLength = Function.prototype.call.bind(arrayBufferByteLengthGetter);
|
|
12
|
+
|
|
13
|
+
function encodedByteLength(value) {
|
|
14
|
+
return nativeBufferByteLength(nativeEncode(value).buffer);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function safeResult(value, maxBytes) {
|
|
18
|
+
const seen = new NativeWeakSet();
|
|
19
|
+
const serialized = nativeStringify(value, (key, nested) => {
|
|
20
|
+
if (key === '__proto__' || key === 'constructor' || key === 'prototype') return undefined;
|
|
21
|
+
if (typeof nested === 'bigint') return String(nested);
|
|
22
|
+
if (nested instanceof Date) return nested.toISOString();
|
|
23
|
+
if (nested && typeof nested === 'object') {
|
|
24
|
+
if (seen.has(nested)) return '[Circular]';
|
|
25
|
+
seen.add(nested);
|
|
26
|
+
}
|
|
27
|
+
return nested;
|
|
28
|
+
});
|
|
29
|
+
if (serialized === undefined) throw new Error('The calculation returned undefined or a non-serializable value.');
|
|
30
|
+
if (encodedByteLength(serialized) > maxBytes) {
|
|
31
|
+
throw new Error('The calculation result is too large. Return a smaller summary or fewer rows.');
|
|
32
|
+
}
|
|
33
|
+
return nativeParse(serialized);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
self.onmessage = async event => {
|
|
37
|
+
const message = event.data || {};
|
|
38
|
+
if (message.type !== 'run' || typeof message.token !== 'string') return;
|
|
39
|
+
const token = message.token;
|
|
40
|
+
|
|
41
|
+
try {
|
|
42
|
+
for (const name of ['fetch', 'XMLHttpRequest', 'WebSocket', 'EventSource', 'importScripts', 'Worker', 'SharedWorker']) {
|
|
43
|
+
try {
|
|
44
|
+
Object.defineProperty(self, name, { value: undefined, writable: false, configurable: false });
|
|
45
|
+
} catch {}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const args = message.args && typeof message.args === 'object' ? message.args : {};
|
|
49
|
+
const keys = Object.keys(args);
|
|
50
|
+
if (!keys.every(key => /^[$A-Z_][0-9A-Z_$]*$/i.test(key) && !['constructor', 'prototype', '__proto__'].includes(key))) {
|
|
51
|
+
throw new Error('The calculation contains an invalid argument name.');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const calculate = Function(...keys, "'use strict';\n" + message.code);
|
|
55
|
+
const result = await Promise.resolve(calculate(...keys.map(key => args[key])));
|
|
56
|
+
nativePostMessage({
|
|
57
|
+
type: 'result',
|
|
58
|
+
token,
|
|
59
|
+
ok: true,
|
|
60
|
+
result: safeResult(result, message.maxOutputBytes),
|
|
61
|
+
});
|
|
62
|
+
} catch (error) {
|
|
63
|
+
nativePostMessage({
|
|
64
|
+
type: 'result',
|
|
65
|
+
token,
|
|
66
|
+
ok: false,
|
|
67
|
+
error: String(error && error.message ? error.message : error).slice(0, 500),
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
`,M=String.raw`
|
|
72
|
+
'use strict';
|
|
73
|
+
const workerSource = __WORKER_SOURCE__;
|
|
74
|
+
|
|
75
|
+
window.addEventListener('message', event => {
|
|
76
|
+
const message = event.data || {};
|
|
77
|
+
if (event.source !== parent || message.type !== 'table-sandbox-run' || typeof message.token !== 'string') return;
|
|
78
|
+
|
|
79
|
+
const workerUrl = URL.createObjectURL(new Blob([workerSource], { type: 'text/javascript' }));
|
|
80
|
+
const worker = new Worker(workerUrl);
|
|
81
|
+
URL.revokeObjectURL(workerUrl);
|
|
82
|
+
let finished = false;
|
|
83
|
+
|
|
84
|
+
const finish = payload => {
|
|
85
|
+
if (finished) return;
|
|
86
|
+
finished = true;
|
|
87
|
+
clearTimeout(timer);
|
|
88
|
+
worker.terminate();
|
|
89
|
+
parent.postMessage({ type: 'table-sandbox-result', token: message.token, ...payload }, '*');
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const timer = setTimeout(() => {
|
|
93
|
+
finish({ ok: false, error: 'The calculation timed out.' });
|
|
94
|
+
}, message.timeoutMs);
|
|
95
|
+
|
|
96
|
+
worker.onmessage = workerEvent => {
|
|
97
|
+
const response = workerEvent.data || {};
|
|
98
|
+
if (response.type !== 'result' || response.token !== message.token) return;
|
|
99
|
+
finish(response.ok
|
|
100
|
+
? { ok: true, result: response.result }
|
|
101
|
+
: { ok: false, error: response.error || 'The calculation failed.' });
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
worker.onerror = () => finish({ ok: false, error: 'The isolated calculation worker failed.' });
|
|
105
|
+
worker.postMessage({
|
|
106
|
+
type: 'run',
|
|
107
|
+
token: message.token,
|
|
108
|
+
code: message.code,
|
|
109
|
+
args: message.args,
|
|
110
|
+
maxOutputBytes: message.maxOutputBytes,
|
|
111
|
+
});
|
|
112
|
+
}, { passive: true });
|
|
113
|
+
|
|
114
|
+
parent.postMessage({ type: 'table-sandbox-ready' }, '*');
|
|
115
|
+
`.replace("__WORKER_SOURCE__",JSON.stringify(T));function x(){return`<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval' blob:; worker-src blob:; child-src blob:; connect-src 'none'; img-src 'none'; media-src 'none'; object-src 'none'; frame-src 'none'; style-src 'unsafe-inline'"></head><body><script>${M.replace(/<\/script/gi,"<\\/script")}<\/script></body></html>`}function O(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`table-sandbox-${Date.now()}-${Math.random().toString(36).slice(2)}`}function B(r,h={},s={}){if(typeof document>"u"||!document.body)return Promise.reject(new Error("Table calculations can only run in a browser session."));if(typeof r!="string"||!r.trim())return Promise.reject(new Error("No calculation code was provided."));if(r.length>g)return Promise.reject(new Error(`Calculation code is limited to ${g} characters.`));const u=Math.min(Math.max(Math.trunc(s.timeoutMs??_),100),5e3),k=Math.min(Math.max(Math.trunc(s.maxInputBytes??E),1024),16*1024*1024),l=Math.min(Math.max(Math.trunc(s.maxOutputBytes??S),1024),1024*1024);let d;try{d=p.serializeBounded(h,k)}catch(o){return Promise.reject(o)}return new Promise((o,a)=>{const e=document.createElement("iframe"),f=O();let i=!1,y=!1;e.setAttribute("sandbox","allow-scripts"),e.setAttribute("aria-hidden","true"),e.tabIndex=-1,e.style.position="fixed",e.style.width="0",e.style.height="0",e.style.border="0",e.style.opacity="0",e.style.pointerEvents="none",e.srcdoc=x();const b=()=>{clearTimeout(v),window.removeEventListener("message",m),e.remove()},n=t=>{y||(y=!0,b(),t())},w=()=>{e.contentWindow?.postMessage({type:"table-sandbox-run",token:f,code:r,args:d,timeoutMs:u,maxOutputBytes:l},"*")},m=t=>{if(!(t.source!==e.contentWindow||!t.data||typeof t.data!="object")){if(t.data.type==="table-sandbox-ready"){if(i)return;i=!0,w();return}if(!(t.data.type!=="table-sandbox-result"||t.data.token!==f)){if(!t.data.ok){n(()=>a(new Error(t.data.error||"The isolated calculation failed.")));return}try{const c=p.serializeBounded(t.data.result,l);n(()=>o(c))}catch(c){n(()=>a(c))}}}},v=window.setTimeout(()=>{n(()=>a(new Error(i?"The calculation timed out.":"The isolated calculation environment could not start.")))},u+1e3);window.addEventListener("message",m),document.body.appendChild(e)})}exports.runSandboxedTableCode=B;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const j=require("@oneclick.dev/cms-kit"),$=require("nuxt/app"),q=require("./dateRangePresets-CPWqst_x.js"),_=require("./row-item-Cyo3m3MZ.js"),p=require("./TableResultView.vue_vue_type_script_setup_true_lang-C_Lv-SmJ.js");function P(o,s=!1){const r=/^\d{4}-\d{2}-\d{2}$/.test(o)?new Date(`${o}T${s?"23:59:59.999":"00:00:00.000"}`):new Date(o);if(Number.isNaN(r.getTime()))throw new Error(`Invalid date "${o}". Use YYYY-MM-DD.`);return s&&!/^\d{4}-\d{2}-\d{2}$/.test(o)&&r.setHours(23,59,59,999),r}function E(o){return o.replace(/-([a-z])/g,(s,r)=>r.toUpperCase())}function I(o,s){let r=o.startDate,d=o.endDate;if(!r&&!d&&o.useDefaultDateRange!==!1&&s){const w=q.getDateRangePresets()[s];w&&(r=w[0],d=w[1]||w[0])}if(!r&&!d)return null;r||=d,d||=r;const f=P(r,!1),g=P(d,!0);if(f.getTime()>g.getTime())throw new Error("The start date must be before the end date.");return{from:f,to:g,startDate:r,endDate:d}}function S(o){const s=$.useNuxtApp(),{runFlow:r}=j.useFlowBuilder(),d=typeof s.$useRoute=="function"?s.$useRoute():null;let f=null;async function g(l={}){return l.fresh&&(f=null),f||(f=(async()=>{const m=s.$useProjectService(),u=s.$useModuleStorage({projectId:o.projectSlug,moduleId:o.instanceId}),[y,t]=await Promise.all([m.getModule(o.projectSlug,o.instanceId),u.getAllModuleData()]),n=Array.isArray(t)?Object.fromEntries(t.filter(e=>e&&typeof e.key=="string").map(e=>[e.key,e.value])):t&&typeof t=="object"?t:{},h=p.normalizeTableColumns(n.columns),a=Array.isArray(n.itemActions)?n.itemActions.filter(e=>e&&typeof e=="object"&&e.id&&e.label&&e.flow).map(e=>({...e})):[];return{moduleRecord:y,config:y?.config||{},columns:h,actions:a,dateRangeFilter:n.dateRangeFilter&&typeof n.dateRangeFilter=="object"?n.dateRangeFilter:null}})().catch(m=>{throw f=null,m}),f)}async function w(l={},m={}){const u=await g({fresh:m.freshMetadata}),y=u.config?.getItems;if(!y)throw new Error("This table has no Fetch items flow configured.");const t=I(l,u.dateRangeFilter?.defaultDate||void 0),n=Object.entries(d?.query||{}).map(([T,D])=>({name:E(T),type:"routeQueryParam",value:D??null})),h=t?[...n,{name:"dateRangeFilter",type:"dateRangeFilter",value:{from:t.from,to:t.to}}]:n,a=await r(y,h),e=p.normalizeTableRows(a),i=u.columns.length?u.columns:p.inferTableColumns(e);let c=[...e],b=null;if(t){const T=!!u.dateRangeFilter?.defaultDate,D=l.dateProperty?p.resolveColumn(l.dateProperty,i)||{property:l.dateProperty}:null,v=i.filter(A=>["date","datetime"].includes(String(A.type||"").toLowerCase())),R=D||(!T&&v.length===1?v[0]:null);if(R?.property){if(!(e.length===0||e.some(F=>p.resolveProperty(F,R.property)!==void 0)))throw new Error(`The date property "${R.property}" does not exist in the fetched rows.`);b=R.property,c=p.applyLocalDateRange(c,R.property,t.from,t.to)}else if(!T)throw new Error("This table has no configured date-range flow and no unambiguous date column. Provide dateProperty using a property reported by inspectTable.")}return c=p.applyTableFilters(c,l.filters||[],i),c=p.applyTableSort(c,l.sortBy,l.sortDirection||"asc",i),{...u,columns:i,sourceRows:e,rows:c,requestedRange:t,localDateProperty:b}}async function C(l,m,u,y){let t=[...y];const n=[];return{flowResult:await r(l.flow,[{name:"item",value:{data:{...m}},type:"object"},{name:"tableActiveRowIndex",type:"number",value:u}],[],[_.createTableRowExtension({tableRowActions:{create:a=>{t=[...t,a],n.push({type:"create",data:a})},update:(a,e,i=!1)=>{t=t.map((c,b)=>b!==a?c:i?{...c,...e}:e),n.push({type:"update",index:a,data:e,merge:i})},remove:a=>{t=t.filter((e,i)=>i!==a),n.push({type:"remove",index:a})}}})]),effects:n,rows:t}}return{loadMetadata:g,loadRows:w,runStoredRowAction:C}}exports.useTableAgentTools=S;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { useFlowBuilder as P } from "@oneclick.dev/cms-kit";
|
|
2
|
+
import { useNuxtApp as j } from "nuxt/app";
|
|
3
|
+
import { g as $ } from "./dateRangePresets-B-l5b_wR.mjs";
|
|
4
|
+
import { c as E } from "./row-item-C1dUyimV.mjs";
|
|
5
|
+
import { n as S, i as I, r as M, a as x, c as k, d as q, e as B, f as N } from "./TableResultView.vue_vue_type_script_setup_true_lang-CBn-Oxl9.mjs";
|
|
6
|
+
function A(o, s = !1) {
|
|
7
|
+
const r = /^\d{4}-\d{2}-\d{2}$/.test(o) ? /* @__PURE__ */ new Date(`${o}T${s ? "23:59:59.999" : "00:00:00.000"}`) : new Date(o);
|
|
8
|
+
if (Number.isNaN(r.getTime()))
|
|
9
|
+
throw new Error(`Invalid date "${o}". Use YYYY-MM-DD.`);
|
|
10
|
+
return s && !/^\d{4}-\d{2}-\d{2}$/.test(o) && r.setHours(23, 59, 59, 999), r;
|
|
11
|
+
}
|
|
12
|
+
function Y(o) {
|
|
13
|
+
return o.replace(/-([a-z])/g, (s, r) => r.toUpperCase());
|
|
14
|
+
}
|
|
15
|
+
function z(o, s) {
|
|
16
|
+
let r = o.startDate, d = o.endDate;
|
|
17
|
+
if (!r && !d && o.useDefaultDateRange !== !1 && s) {
|
|
18
|
+
const y = $()[s];
|
|
19
|
+
y && (r = y[0], d = y[1] || y[0]);
|
|
20
|
+
}
|
|
21
|
+
if (!r && !d) return null;
|
|
22
|
+
r ||= d, d ||= r;
|
|
23
|
+
const f = A(r, !1), w = A(d, !0);
|
|
24
|
+
if (f.getTime() > w.getTime())
|
|
25
|
+
throw new Error("The start date must be before the end date.");
|
|
26
|
+
return { from: f, to: w, startDate: r, endDate: d };
|
|
27
|
+
}
|
|
28
|
+
function O(o) {
|
|
29
|
+
const s = j(), { runFlow: r } = P(), d = typeof s.$useRoute == "function" ? s.$useRoute() : null;
|
|
30
|
+
let f = null;
|
|
31
|
+
async function w(l = {}) {
|
|
32
|
+
return l.fresh && (f = null), f || (f = (async () => {
|
|
33
|
+
const p = s.$useProjectService(), u = s.$useModuleStorage({
|
|
34
|
+
projectId: o.projectSlug,
|
|
35
|
+
moduleId: o.instanceId
|
|
36
|
+
}), [m, t] = await Promise.all([
|
|
37
|
+
p.getModule(o.projectSlug, o.instanceId),
|
|
38
|
+
u.getAllModuleData()
|
|
39
|
+
]), a = Array.isArray(t) ? Object.fromEntries(
|
|
40
|
+
t.filter((e) => e && typeof e.key == "string").map((e) => [e.key, e.value])
|
|
41
|
+
) : t && typeof t == "object" ? t : {}, h = N(a.columns), n = Array.isArray(a.itemActions) ? a.itemActions.filter((e) => e && typeof e == "object" && e.id && e.label && e.flow).map((e) => ({ ...e })) : [];
|
|
42
|
+
return {
|
|
43
|
+
moduleRecord: m,
|
|
44
|
+
config: m?.config || {},
|
|
45
|
+
columns: h,
|
|
46
|
+
actions: n,
|
|
47
|
+
dateRangeFilter: a.dateRangeFilter && typeof a.dateRangeFilter == "object" ? a.dateRangeFilter : null
|
|
48
|
+
};
|
|
49
|
+
})().catch((p) => {
|
|
50
|
+
throw f = null, p;
|
|
51
|
+
}), f);
|
|
52
|
+
}
|
|
53
|
+
async function y(l = {}, p = {}) {
|
|
54
|
+
const u = await w({ fresh: p.freshMetadata }), m = u.config?.getItems;
|
|
55
|
+
if (!m)
|
|
56
|
+
throw new Error("This table has no Fetch items flow configured.");
|
|
57
|
+
const t = z(
|
|
58
|
+
l,
|
|
59
|
+
u.dateRangeFilter?.defaultDate || void 0
|
|
60
|
+
), a = Object.entries(d?.query || {}).map(([b, D]) => ({
|
|
61
|
+
name: Y(b),
|
|
62
|
+
type: "routeQueryParam",
|
|
63
|
+
value: D ?? null
|
|
64
|
+
})), h = t ? [...a, {
|
|
65
|
+
name: "dateRangeFilter",
|
|
66
|
+
type: "dateRangeFilter",
|
|
67
|
+
value: {
|
|
68
|
+
from: t.from,
|
|
69
|
+
to: t.to
|
|
70
|
+
}
|
|
71
|
+
}] : a, n = await r(m, h), e = S(n), i = u.columns.length ? u.columns : I(e);
|
|
72
|
+
let c = [...e], R = null;
|
|
73
|
+
if (t) {
|
|
74
|
+
const b = !!u.dateRangeFilter?.defaultDate, D = l.dateProperty ? M(l.dateProperty, i) || { property: l.dateProperty } : null, T = i.filter(
|
|
75
|
+
(v) => ["date", "datetime"].includes(String(v.type || "").toLowerCase())
|
|
76
|
+
), g = D || (!b && T.length === 1 ? T[0] : null);
|
|
77
|
+
if (g?.property) {
|
|
78
|
+
if (!(e.length === 0 || e.some((F) => x(F, g.property) !== void 0)))
|
|
79
|
+
throw new Error(`The date property "${g.property}" does not exist in the fetched rows.`);
|
|
80
|
+
R = g.property, c = k(c, g.property, t.from, t.to);
|
|
81
|
+
} else if (!b)
|
|
82
|
+
throw new Error("This table has no configured date-range flow and no unambiguous date column. Provide dateProperty using a property reported by inspectTable.");
|
|
83
|
+
}
|
|
84
|
+
return c = q(c, l.filters || [], i), c = B(c, l.sortBy, l.sortDirection || "asc", i), {
|
|
85
|
+
...u,
|
|
86
|
+
columns: i,
|
|
87
|
+
sourceRows: e,
|
|
88
|
+
rows: c,
|
|
89
|
+
requestedRange: t,
|
|
90
|
+
localDateProperty: R
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
async function C(l, p, u, m) {
|
|
94
|
+
let t = [...m];
|
|
95
|
+
const a = [];
|
|
96
|
+
return { flowResult: await r(l.flow, [
|
|
97
|
+
{
|
|
98
|
+
name: "item",
|
|
99
|
+
value: { data: { ...p } },
|
|
100
|
+
type: "object"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: "tableActiveRowIndex",
|
|
104
|
+
type: "number",
|
|
105
|
+
value: u
|
|
106
|
+
}
|
|
107
|
+
], [], [
|
|
108
|
+
E({
|
|
109
|
+
tableRowActions: {
|
|
110
|
+
create: (n) => {
|
|
111
|
+
t = [...t, n], a.push({ type: "create", data: n });
|
|
112
|
+
},
|
|
113
|
+
update: (n, e, i = !1) => {
|
|
114
|
+
t = t.map((c, R) => R !== n ? c : i ? { ...c, ...e } : e), a.push({ type: "update", index: n, data: e, merge: i });
|
|
115
|
+
},
|
|
116
|
+
remove: (n) => {
|
|
117
|
+
t = t.filter((e, i) => i !== n), a.push({ type: "remove", index: n });
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
})
|
|
121
|
+
]), effects: a, rows: t };
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
loadMetadata: w,
|
|
125
|
+
loadRows: y,
|
|
126
|
+
runStoredRowAction: C
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
export {
|
|
130
|
+
O as u
|
|
131
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oneclick.dev/cms-core-modules",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.123",
|
|
4
4
|
"main": "dist/index.cjs.js",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"@formkit/drag-and-drop": "^0.5.3",
|
|
30
30
|
"@internationalized/date": "^3.8.0",
|
|
31
|
-
"@oneclick.dev/cms-kit": "0.0.
|
|
31
|
+
"@oneclick.dev/cms-kit": "0.0.144",
|
|
32
32
|
"@tanstack/vue-table": "^8.21.3",
|
|
33
33
|
"@vee-validate/zod": "^4.15.0",
|
|
34
34
|
"@vue-flow/core": "^1.48.1",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@floating-ui/dom": "^1.7.4",
|
|
52
|
-
"@tiptap/extension-collaboration": "3.
|
|
53
|
-
"@tiptap/extension-node-range": "3.
|
|
52
|
+
"@tiptap/extension-collaboration": "3.30.2",
|
|
53
|
+
"@tiptap/extension-node-range": "3.30.2",
|
|
54
54
|
"@tiptap/y-tiptap": "3.0.2",
|
|
55
55
|
"@vitejs/plugin-vue": "^6.0.3",
|
|
56
56
|
"@vue-flow/core": "^1.48.1",
|
|
@@ -60,19 +60,19 @@
|
|
|
60
60
|
"vite-plugin-dts": "^4.5.4"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@tiptap/core": "3.
|
|
64
|
-
"@tiptap/extension-bubble-menu": "3.
|
|
65
|
-
"@tiptap/extension-collaboration": "3.
|
|
66
|
-
"@tiptap/extension-collaboration-caret": "3.
|
|
67
|
-
"@tiptap/extension-document": "3.
|
|
68
|
-
"@tiptap/extension-link": "3.
|
|
69
|
-
"@tiptap/extension-node-range": "3.
|
|
70
|
-
"@tiptap/extension-underline": "3.
|
|
71
|
-
"@tiptap/extension-unique-id": "3.
|
|
72
|
-
"@tiptap/extensions": "3.
|
|
73
|
-
"@tiptap/pm": "3.
|
|
74
|
-
"@tiptap/starter-kit": "3.
|
|
75
|
-
"@tiptap/vue-3": "3.
|
|
63
|
+
"@tiptap/core": "3.30.2",
|
|
64
|
+
"@tiptap/extension-bubble-menu": "3.30.2",
|
|
65
|
+
"@tiptap/extension-collaboration": "3.30.2",
|
|
66
|
+
"@tiptap/extension-collaboration-caret": "3.30.2",
|
|
67
|
+
"@tiptap/extension-document": "3.30.2",
|
|
68
|
+
"@tiptap/extension-link": "3.30.2",
|
|
69
|
+
"@tiptap/extension-node-range": "3.30.2",
|
|
70
|
+
"@tiptap/extension-underline": "3.30.2",
|
|
71
|
+
"@tiptap/extension-unique-id": "3.30.2",
|
|
72
|
+
"@tiptap/extensions": "3.30.2",
|
|
73
|
+
"@tiptap/pm": "3.30.2",
|
|
74
|
+
"@tiptap/starter-kit": "3.30.2",
|
|
75
|
+
"@tiptap/vue-3": "3.30.2",
|
|
76
76
|
"@tiptap/y-tiptap": "3.0.2",
|
|
77
77
|
"@unovis/ts": "^1.5.2",
|
|
78
78
|
"@unovis/vue": "^1.5.2",
|