@sisense/sdk-ai-core 0.2.11
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/README.md +51 -0
- package/dist/constants.d.ts +9 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/engines/chart-builder/chart-builder-engine.d.ts +14 -0
- package/dist/engines/chart-builder/chart-builder-engine.d.ts.map +1 -0
- package/dist/engines/chart-builder/chart-builder-service.d.ts +7 -0
- package/dist/engines/chart-builder/chart-builder-service.d.ts.map +1 -0
- package/dist/engines/chart-builder/create-chart/create-chart.d.ts +14 -0
- package/dist/engines/chart-builder/create-chart/create-chart.d.ts.map +1 -0
- package/dist/engines/chart-builder/create-chart/generate-chart-recommendations.d.ts +5 -0
- package/dist/engines/chart-builder/create-chart/generate-chart-recommendations.d.ts.map +1 -0
- package/dist/engines/chart-builder/create-chart/generate-chart-table.d.ts +3 -0
- package/dist/engines/chart-builder/create-chart/generate-chart-table.d.ts.map +1 -0
- package/dist/engines/chart-builder/types.d.ts +612 -0
- package/dist/engines/chart-builder/types.d.ts.map +1 -0
- package/dist/engines/chart-builder/update-chart/chart-options-schemas.d.ts +8629 -0
- package/dist/engines/chart-builder/update-chart/chart-options-schemas.d.ts.map +1 -0
- package/dist/engines/chart-builder/update-chart/schemas.d.ts +1136 -0
- package/dist/engines/chart-builder/update-chart/schemas.d.ts.map +1 -0
- package/dist/engines/chart-builder/update-chart/update-chart-data-options.d.ts +18 -0
- package/dist/engines/chart-builder/update-chart/update-chart-data-options.d.ts.map +1 -0
- package/dist/engines/chart-builder/update-chart/update-chart-style-options.d.ts +18 -0
- package/dist/engines/chart-builder/update-chart/update-chart-style-options.d.ts.map +1 -0
- package/dist/engines/chart-builder/update-chart/update-chart-title.d.ts +12 -0
- package/dist/engines/chart-builder/update-chart/update-chart-title.d.ts.map +1 -0
- package/dist/engines/chart-builder/update-chart/update-chart-type.d.ts +14 -0
- package/dist/engines/chart-builder/update-chart/update-chart-type.d.ts.map +1 -0
- package/dist/engines/index.d.ts +6 -0
- package/dist/engines/index.d.ts.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5035 -0
- package/dist/index.js.map +1 -0
- package/dist/services/dashboards/dashboards-service.d.ts +47 -0
- package/dist/services/dashboards/dashboards-service.d.ts.map +1 -0
- package/dist/services/dashboards/fusion-dashboards-service.d.ts +71 -0
- package/dist/services/dashboards/fusion-dashboards-service.d.ts.map +1 -0
- package/dist/services/data-models/data-models-service.d.ts +6 -0
- package/dist/services/data-models/data-models-service.d.ts.map +1 -0
- package/dist/services/data-models/ecm-service.d.ts +497 -0
- package/dist/services/data-models/ecm-service.d.ts.map +1 -0
- package/dist/services/data-sources/data-sources-service.d.ts +41 -0
- package/dist/services/data-sources/data-sources-service.d.ts.map +1 -0
- package/dist/services/globals/globals-service.d.ts +2 -0
- package/dist/services/globals/globals-service.d.ts.map +1 -0
- package/dist/services/llm/llm-settings-service.d.ts +18 -0
- package/dist/services/llm/llm-settings-service.d.ts.map +1 -0
- package/dist/services/nlq/nlq-service.d.ts +33 -0
- package/dist/services/nlq/nlq-service.d.ts.map +1 -0
- package/dist/singleton-clients.d.ts +48 -0
- package/dist/singleton-clients.d.ts.map +1 -0
- package/dist/utils/chat-completion-utils.d.ts +55 -0
- package/dist/utils/chat-completion-utils.d.ts.map +1 -0
- package/dist/utils/http-client.d.ts +33 -0
- package/dist/utils/http-client.d.ts.map +1 -0
- package/dist/utils/id-utils.d.ts +9 -0
- package/dist/utils/id-utils.d.ts.map +1 -0
- package/dist/utils/openai-client.d.ts +11 -0
- package/dist/utils/openai-client.d.ts.map +1 -0
- package/dist/utils/proxy-utils.d.ts +5 -0
- package/dist/utils/proxy-utils.d.ts.map +1 -0
- package/dist/utils/utils.d.ts +12 -0
- package/dist/utils/utils.d.ts.map +1 -0
- package/dist/utils/zod-utils.d.ts +60 -0
- package/dist/utils/zod-utils.d.ts.map +1 -0
- package/package.json +62 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,5035 @@
|
|
|
1
|
+
import { z as o, ZodFirstPartyTypeKind as g } from "zod";
|
|
2
|
+
import { translateQueryJSON as mt, translateQueryToJaql as ht, widgetComposer as gt, getChartStyleOptions as ke } from "@sisense/sdk-ui/analytics-composer";
|
|
3
|
+
import { HttpClient as ft, getAuthenticator as bt } from "@sisense/sdk-rest-client";
|
|
4
|
+
import yt from "openai";
|
|
5
|
+
import { isChartWidgetProps as Ee, getDashboardModel as vt, dashboardModelTranslator as wt, widgetModelTranslator as ye, translateFiltersAndRelationsToDto as St } from "@sisense/sdk-ui";
|
|
6
|
+
import { convertDataSource as Me, normalizeName as ve, DateLevels as Ot, convertJaqlDataSourceForDto as ie, isDataSourceInfo as se } from "@sisense/sdk-data";
|
|
7
|
+
const Ct = Symbol("Let zodToJsonSchema decide on which parser to use"), Dt = {
|
|
8
|
+
name: void 0,
|
|
9
|
+
$refStrategy: "root",
|
|
10
|
+
basePath: ["#"],
|
|
11
|
+
effectStrategy: "input",
|
|
12
|
+
pipeStrategy: "all",
|
|
13
|
+
dateStrategy: "format:date-time",
|
|
14
|
+
mapStrategy: "entries",
|
|
15
|
+
removeAdditionalStrategy: "passthrough",
|
|
16
|
+
allowedAdditionalProperties: !0,
|
|
17
|
+
rejectedAdditionalProperties: !1,
|
|
18
|
+
definitionPath: "definitions",
|
|
19
|
+
target: "jsonSchema7",
|
|
20
|
+
strictUnions: !1,
|
|
21
|
+
definitions: {},
|
|
22
|
+
errorMessages: !1,
|
|
23
|
+
markdownDescription: !1,
|
|
24
|
+
patternStrategy: "escape",
|
|
25
|
+
applyRegexFlags: !1,
|
|
26
|
+
emailStrategy: "format:email",
|
|
27
|
+
base64Strategy: "contentEncoding:base64",
|
|
28
|
+
nameStrategy: "ref",
|
|
29
|
+
openAiAnyTypeName: "OpenAiAnyType"
|
|
30
|
+
}, _t = (e) => ({
|
|
31
|
+
...Dt,
|
|
32
|
+
...e
|
|
33
|
+
}), Pt = (e) => {
|
|
34
|
+
const t = _t(e), n = t.name !== void 0 ? [...t.basePath, t.definitionPath, t.name] : t.basePath;
|
|
35
|
+
return {
|
|
36
|
+
...t,
|
|
37
|
+
flags: { hasReferencedOpenAiAnyType: !1 },
|
|
38
|
+
currentPath: n,
|
|
39
|
+
propertyPath: void 0,
|
|
40
|
+
seen: new Map(Object.entries(t.definitions).map(([a, r]) => [
|
|
41
|
+
r._def,
|
|
42
|
+
{
|
|
43
|
+
def: r._def,
|
|
44
|
+
path: [...t.basePath, t.definitionPath, a],
|
|
45
|
+
// Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
|
|
46
|
+
jsonSchema: void 0
|
|
47
|
+
}
|
|
48
|
+
]))
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
function Ne(e, t, n, a) {
|
|
52
|
+
a != null && a.errorMessages && n && (e.errorMessage = {
|
|
53
|
+
...e.errorMessage,
|
|
54
|
+
[t]: n
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function v(e, t, n, a, r) {
|
|
58
|
+
e[t] = n, Ne(e, t, a, r);
|
|
59
|
+
}
|
|
60
|
+
const Ze = (e, t) => {
|
|
61
|
+
let n = 0;
|
|
62
|
+
for (; n < e.length && n < t.length && e[n] === t[n]; n++)
|
|
63
|
+
;
|
|
64
|
+
return [(e.length - n).toString(), ...t.slice(n)].join("/");
|
|
65
|
+
};
|
|
66
|
+
var h;
|
|
67
|
+
(function(e) {
|
|
68
|
+
e.ZodString = "ZodString", e.ZodNumber = "ZodNumber", e.ZodNaN = "ZodNaN", e.ZodBigInt = "ZodBigInt", e.ZodBoolean = "ZodBoolean", e.ZodDate = "ZodDate", e.ZodSymbol = "ZodSymbol", e.ZodUndefined = "ZodUndefined", e.ZodNull = "ZodNull", e.ZodAny = "ZodAny", e.ZodUnknown = "ZodUnknown", e.ZodNever = "ZodNever", e.ZodVoid = "ZodVoid", e.ZodArray = "ZodArray", e.ZodObject = "ZodObject", e.ZodUnion = "ZodUnion", e.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", e.ZodIntersection = "ZodIntersection", e.ZodTuple = "ZodTuple", e.ZodRecord = "ZodRecord", e.ZodMap = "ZodMap", e.ZodSet = "ZodSet", e.ZodFunction = "ZodFunction", e.ZodLazy = "ZodLazy", e.ZodLiteral = "ZodLiteral", e.ZodEnum = "ZodEnum", e.ZodEffects = "ZodEffects", e.ZodNativeEnum = "ZodNativeEnum", e.ZodOptional = "ZodOptional", e.ZodNullable = "ZodNullable", e.ZodDefault = "ZodDefault", e.ZodCatch = "ZodCatch", e.ZodPromise = "ZodPromise", e.ZodBranded = "ZodBranded", e.ZodPipeline = "ZodPipeline", e.ZodReadonly = "ZodReadonly";
|
|
69
|
+
})(h || (h = {}));
|
|
70
|
+
function _(e) {
|
|
71
|
+
if (e.target !== "openAi")
|
|
72
|
+
return {};
|
|
73
|
+
const t = [
|
|
74
|
+
...e.basePath,
|
|
75
|
+
e.definitionPath,
|
|
76
|
+
e.openAiAnyTypeName
|
|
77
|
+
];
|
|
78
|
+
return e.flags.hasReferencedOpenAiAnyType = !0, {
|
|
79
|
+
$ref: e.$refStrategy === "relative" ? Ze(t, e.currentPath) : t.join("/")
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function At(e, t) {
|
|
83
|
+
var a, r, i;
|
|
84
|
+
const n = {
|
|
85
|
+
type: "array"
|
|
86
|
+
};
|
|
87
|
+
return (a = e.type) != null && a._def && ((i = (r = e.type) == null ? void 0 : r._def) == null ? void 0 : i.typeName) !== h.ZodAny && (n.items = y(e.type._def, {
|
|
88
|
+
...t,
|
|
89
|
+
currentPath: [...t.currentPath, "items"]
|
|
90
|
+
})), e.minLength && v(n, "minItems", e.minLength.value, e.minLength.message, t), e.maxLength && v(n, "maxItems", e.maxLength.value, e.maxLength.message, t), e.exactLength && (v(n, "minItems", e.exactLength.value, e.exactLength.message, t), v(n, "maxItems", e.exactLength.value, e.exactLength.message, t)), n;
|
|
91
|
+
}
|
|
92
|
+
function xt(e, t) {
|
|
93
|
+
const n = {
|
|
94
|
+
type: "integer",
|
|
95
|
+
format: "int64"
|
|
96
|
+
};
|
|
97
|
+
if (!e.checks)
|
|
98
|
+
return n;
|
|
99
|
+
for (const a of e.checks)
|
|
100
|
+
switch (a.kind) {
|
|
101
|
+
case "min":
|
|
102
|
+
t.target === "jsonSchema7" ? a.inclusive ? v(n, "minimum", a.value, a.message, t) : v(n, "exclusiveMinimum", a.value, a.message, t) : (a.inclusive || (n.exclusiveMinimum = !0), v(n, "minimum", a.value, a.message, t));
|
|
103
|
+
break;
|
|
104
|
+
case "max":
|
|
105
|
+
t.target === "jsonSchema7" ? a.inclusive ? v(n, "maximum", a.value, a.message, t) : v(n, "exclusiveMaximum", a.value, a.message, t) : (a.inclusive || (n.exclusiveMaximum = !0), v(n, "maximum", a.value, a.message, t));
|
|
106
|
+
break;
|
|
107
|
+
case "multipleOf":
|
|
108
|
+
v(n, "multipleOf", a.value, a.message, t);
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
return n;
|
|
112
|
+
}
|
|
113
|
+
function $t() {
|
|
114
|
+
return {
|
|
115
|
+
type: "boolean"
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function Ie(e, t) {
|
|
119
|
+
return y(e.type._def, t);
|
|
120
|
+
}
|
|
121
|
+
const Tt = (e, t) => y(e.innerType._def, t);
|
|
122
|
+
function Le(e, t, n) {
|
|
123
|
+
const a = n ?? t.dateStrategy;
|
|
124
|
+
if (Array.isArray(a))
|
|
125
|
+
return {
|
|
126
|
+
anyOf: a.map((r, i) => Le(e, t, r))
|
|
127
|
+
};
|
|
128
|
+
switch (a) {
|
|
129
|
+
case "string":
|
|
130
|
+
case "format:date-time":
|
|
131
|
+
return {
|
|
132
|
+
type: "string",
|
|
133
|
+
format: "date-time"
|
|
134
|
+
};
|
|
135
|
+
case "format:date":
|
|
136
|
+
return {
|
|
137
|
+
type: "string",
|
|
138
|
+
format: "date"
|
|
139
|
+
};
|
|
140
|
+
case "integer":
|
|
141
|
+
return jt(e, t);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
const jt = (e, t) => {
|
|
145
|
+
const n = {
|
|
146
|
+
type: "integer",
|
|
147
|
+
format: "unix-time"
|
|
148
|
+
};
|
|
149
|
+
if (t.target === "openApi3")
|
|
150
|
+
return n;
|
|
151
|
+
for (const a of e.checks)
|
|
152
|
+
switch (a.kind) {
|
|
153
|
+
case "min":
|
|
154
|
+
v(
|
|
155
|
+
n,
|
|
156
|
+
"minimum",
|
|
157
|
+
a.value,
|
|
158
|
+
// This is in milliseconds
|
|
159
|
+
a.message,
|
|
160
|
+
t
|
|
161
|
+
);
|
|
162
|
+
break;
|
|
163
|
+
case "max":
|
|
164
|
+
v(
|
|
165
|
+
n,
|
|
166
|
+
"maximum",
|
|
167
|
+
a.value,
|
|
168
|
+
// This is in milliseconds
|
|
169
|
+
a.message,
|
|
170
|
+
t
|
|
171
|
+
);
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
return n;
|
|
175
|
+
};
|
|
176
|
+
function kt(e, t) {
|
|
177
|
+
return {
|
|
178
|
+
...y(e.innerType._def, t),
|
|
179
|
+
default: e.defaultValue()
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
function Et(e, t) {
|
|
183
|
+
return t.effectStrategy === "input" ? y(e.schema._def, t) : _(t);
|
|
184
|
+
}
|
|
185
|
+
function Mt(e) {
|
|
186
|
+
return {
|
|
187
|
+
type: "string",
|
|
188
|
+
enum: Array.from(e.values)
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
const Nt = (e) => "type" in e && e.type === "string" ? !1 : "allOf" in e;
|
|
192
|
+
function Zt(e, t) {
|
|
193
|
+
const n = [
|
|
194
|
+
y(e.left._def, {
|
|
195
|
+
...t,
|
|
196
|
+
currentPath: [...t.currentPath, "allOf", "0"]
|
|
197
|
+
}),
|
|
198
|
+
y(e.right._def, {
|
|
199
|
+
...t,
|
|
200
|
+
currentPath: [...t.currentPath, "allOf", "1"]
|
|
201
|
+
})
|
|
202
|
+
].filter((i) => !!i);
|
|
203
|
+
let a = t.target === "jsonSchema2019-09" ? { unevaluatedProperties: !1 } : void 0;
|
|
204
|
+
const r = [];
|
|
205
|
+
return n.forEach((i) => {
|
|
206
|
+
if (Nt(i))
|
|
207
|
+
r.push(...i.allOf), i.unevaluatedProperties === void 0 && (a = void 0);
|
|
208
|
+
else {
|
|
209
|
+
let s = i;
|
|
210
|
+
if ("additionalProperties" in i && i.additionalProperties === !1) {
|
|
211
|
+
const { additionalProperties: l, ...c } = i;
|
|
212
|
+
s = c;
|
|
213
|
+
} else
|
|
214
|
+
a = void 0;
|
|
215
|
+
r.push(s);
|
|
216
|
+
}
|
|
217
|
+
}), r.length ? {
|
|
218
|
+
allOf: r,
|
|
219
|
+
...a
|
|
220
|
+
} : void 0;
|
|
221
|
+
}
|
|
222
|
+
function It(e, t) {
|
|
223
|
+
const n = typeof e.value;
|
|
224
|
+
return n !== "bigint" && n !== "number" && n !== "boolean" && n !== "string" ? {
|
|
225
|
+
type: Array.isArray(e.value) ? "array" : "object"
|
|
226
|
+
} : t.target === "openApi3" ? {
|
|
227
|
+
type: n === "bigint" ? "integer" : n,
|
|
228
|
+
enum: [e.value]
|
|
229
|
+
} : {
|
|
230
|
+
type: n === "bigint" ? "integer" : n,
|
|
231
|
+
const: e.value
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
let ne;
|
|
235
|
+
const A = {
|
|
236
|
+
/**
|
|
237
|
+
* `c` was changed to `[cC]` to replicate /i flag
|
|
238
|
+
*/
|
|
239
|
+
cuid: /^[cC][^\s-]{8,}$/,
|
|
240
|
+
cuid2: /^[0-9a-z]+$/,
|
|
241
|
+
ulid: /^[0-9A-HJKMNP-TV-Z]{26}$/,
|
|
242
|
+
/**
|
|
243
|
+
* `a-z` was added to replicate /i flag
|
|
244
|
+
*/
|
|
245
|
+
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,
|
|
246
|
+
/**
|
|
247
|
+
* Constructed a valid Unicode RegExp
|
|
248
|
+
*
|
|
249
|
+
* Lazily instantiate since this type of regex isn't supported
|
|
250
|
+
* in all envs (e.g. React Native).
|
|
251
|
+
*
|
|
252
|
+
* See:
|
|
253
|
+
* https://github.com/colinhacks/zod/issues/2433
|
|
254
|
+
* Fix in Zod:
|
|
255
|
+
* https://github.com/colinhacks/zod/commit/9340fd51e48576a75adc919bff65dbc4a5d4c99b
|
|
256
|
+
*/
|
|
257
|
+
emoji: () => (ne === void 0 && (ne = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u")), ne),
|
|
258
|
+
/**
|
|
259
|
+
* Unused
|
|
260
|
+
*/
|
|
261
|
+
uuid: /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,
|
|
262
|
+
/**
|
|
263
|
+
* Unused
|
|
264
|
+
*/
|
|
265
|
+
ipv4: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,
|
|
266
|
+
ipv4Cidr: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,
|
|
267
|
+
/**
|
|
268
|
+
* Unused
|
|
269
|
+
*/
|
|
270
|
+
ipv6: /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,
|
|
271
|
+
ipv6Cidr: /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,
|
|
272
|
+
base64: /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,
|
|
273
|
+
base64url: /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,
|
|
274
|
+
nanoid: /^[a-zA-Z0-9_-]{21}$/,
|
|
275
|
+
jwt: /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/
|
|
276
|
+
};
|
|
277
|
+
function Re(e, t) {
|
|
278
|
+
const n = {
|
|
279
|
+
type: "string"
|
|
280
|
+
};
|
|
281
|
+
if (e.checks)
|
|
282
|
+
for (const a of e.checks)
|
|
283
|
+
switch (a.kind) {
|
|
284
|
+
case "min":
|
|
285
|
+
v(n, "minLength", typeof n.minLength == "number" ? Math.max(n.minLength, a.value) : a.value, a.message, t);
|
|
286
|
+
break;
|
|
287
|
+
case "max":
|
|
288
|
+
v(n, "maxLength", typeof n.maxLength == "number" ? Math.min(n.maxLength, a.value) : a.value, a.message, t);
|
|
289
|
+
break;
|
|
290
|
+
case "email":
|
|
291
|
+
switch (t.emailStrategy) {
|
|
292
|
+
case "format:email":
|
|
293
|
+
x(n, "email", a.message, t);
|
|
294
|
+
break;
|
|
295
|
+
case "format:idn-email":
|
|
296
|
+
x(n, "idn-email", a.message, t);
|
|
297
|
+
break;
|
|
298
|
+
case "pattern:zod":
|
|
299
|
+
D(n, A.email, a.message, t);
|
|
300
|
+
break;
|
|
301
|
+
}
|
|
302
|
+
break;
|
|
303
|
+
case "url":
|
|
304
|
+
x(n, "uri", a.message, t);
|
|
305
|
+
break;
|
|
306
|
+
case "uuid":
|
|
307
|
+
x(n, "uuid", a.message, t);
|
|
308
|
+
break;
|
|
309
|
+
case "regex":
|
|
310
|
+
D(n, a.regex, a.message, t);
|
|
311
|
+
break;
|
|
312
|
+
case "cuid":
|
|
313
|
+
D(n, A.cuid, a.message, t);
|
|
314
|
+
break;
|
|
315
|
+
case "cuid2":
|
|
316
|
+
D(n, A.cuid2, a.message, t);
|
|
317
|
+
break;
|
|
318
|
+
case "startsWith":
|
|
319
|
+
D(n, RegExp(`^${ae(a.value, t)}`), a.message, t);
|
|
320
|
+
break;
|
|
321
|
+
case "endsWith":
|
|
322
|
+
D(n, RegExp(`${ae(a.value, t)}$`), a.message, t);
|
|
323
|
+
break;
|
|
324
|
+
case "datetime":
|
|
325
|
+
x(n, "date-time", a.message, t);
|
|
326
|
+
break;
|
|
327
|
+
case "date":
|
|
328
|
+
x(n, "date", a.message, t);
|
|
329
|
+
break;
|
|
330
|
+
case "time":
|
|
331
|
+
x(n, "time", a.message, t);
|
|
332
|
+
break;
|
|
333
|
+
case "duration":
|
|
334
|
+
x(n, "duration", a.message, t);
|
|
335
|
+
break;
|
|
336
|
+
case "length":
|
|
337
|
+
v(n, "minLength", typeof n.minLength == "number" ? Math.max(n.minLength, a.value) : a.value, a.message, t), v(n, "maxLength", typeof n.maxLength == "number" ? Math.min(n.maxLength, a.value) : a.value, a.message, t);
|
|
338
|
+
break;
|
|
339
|
+
case "includes": {
|
|
340
|
+
D(n, RegExp(ae(a.value, t)), a.message, t);
|
|
341
|
+
break;
|
|
342
|
+
}
|
|
343
|
+
case "ip": {
|
|
344
|
+
a.version !== "v6" && x(n, "ipv4", a.message, t), a.version !== "v4" && x(n, "ipv6", a.message, t);
|
|
345
|
+
break;
|
|
346
|
+
}
|
|
347
|
+
case "base64url":
|
|
348
|
+
D(n, A.base64url, a.message, t);
|
|
349
|
+
break;
|
|
350
|
+
case "jwt":
|
|
351
|
+
D(n, A.jwt, a.message, t);
|
|
352
|
+
break;
|
|
353
|
+
case "cidr": {
|
|
354
|
+
a.version !== "v6" && D(n, A.ipv4Cidr, a.message, t), a.version !== "v4" && D(n, A.ipv6Cidr, a.message, t);
|
|
355
|
+
break;
|
|
356
|
+
}
|
|
357
|
+
case "emoji":
|
|
358
|
+
D(n, A.emoji(), a.message, t);
|
|
359
|
+
break;
|
|
360
|
+
case "ulid": {
|
|
361
|
+
D(n, A.ulid, a.message, t);
|
|
362
|
+
break;
|
|
363
|
+
}
|
|
364
|
+
case "base64": {
|
|
365
|
+
switch (t.base64Strategy) {
|
|
366
|
+
case "format:binary": {
|
|
367
|
+
x(n, "binary", a.message, t);
|
|
368
|
+
break;
|
|
369
|
+
}
|
|
370
|
+
case "contentEncoding:base64": {
|
|
371
|
+
v(n, "contentEncoding", "base64", a.message, t);
|
|
372
|
+
break;
|
|
373
|
+
}
|
|
374
|
+
case "pattern:zod": {
|
|
375
|
+
D(n, A.base64, a.message, t);
|
|
376
|
+
break;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
break;
|
|
380
|
+
}
|
|
381
|
+
case "nanoid":
|
|
382
|
+
D(n, A.nanoid, a.message, t);
|
|
383
|
+
}
|
|
384
|
+
return n;
|
|
385
|
+
}
|
|
386
|
+
function ae(e, t) {
|
|
387
|
+
return t.patternStrategy === "escape" ? Rt(e) : e;
|
|
388
|
+
}
|
|
389
|
+
const Lt = new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
|
|
390
|
+
function Rt(e) {
|
|
391
|
+
let t = "";
|
|
392
|
+
for (let n = 0; n < e.length; n++)
|
|
393
|
+
Lt.has(e[n]) || (t += "\\"), t += e[n];
|
|
394
|
+
return t;
|
|
395
|
+
}
|
|
396
|
+
function x(e, t, n, a) {
|
|
397
|
+
var r;
|
|
398
|
+
e.format || (r = e.anyOf) != null && r.some((i) => i.format) ? (e.anyOf || (e.anyOf = []), e.format && (e.anyOf.push({
|
|
399
|
+
format: e.format,
|
|
400
|
+
...e.errorMessage && a.errorMessages && {
|
|
401
|
+
errorMessage: { format: e.errorMessage.format }
|
|
402
|
+
}
|
|
403
|
+
}), delete e.format, e.errorMessage && (delete e.errorMessage.format, Object.keys(e.errorMessage).length === 0 && delete e.errorMessage)), e.anyOf.push({
|
|
404
|
+
format: t,
|
|
405
|
+
...n && a.errorMessages && { errorMessage: { format: n } }
|
|
406
|
+
})) : v(e, "format", t, n, a);
|
|
407
|
+
}
|
|
408
|
+
function D(e, t, n, a) {
|
|
409
|
+
var r;
|
|
410
|
+
e.pattern || (r = e.allOf) != null && r.some((i) => i.pattern) ? (e.allOf || (e.allOf = []), e.pattern && (e.allOf.push({
|
|
411
|
+
pattern: e.pattern,
|
|
412
|
+
...e.errorMessage && a.errorMessages && {
|
|
413
|
+
errorMessage: { pattern: e.errorMessage.pattern }
|
|
414
|
+
}
|
|
415
|
+
}), delete e.pattern, e.errorMessage && (delete e.errorMessage.pattern, Object.keys(e.errorMessage).length === 0 && delete e.errorMessage)), e.allOf.push({
|
|
416
|
+
pattern: we(t, a),
|
|
417
|
+
...n && a.errorMessages && { errorMessage: { pattern: n } }
|
|
418
|
+
})) : v(e, "pattern", we(t, a), n, a);
|
|
419
|
+
}
|
|
420
|
+
function we(e, t) {
|
|
421
|
+
var c;
|
|
422
|
+
if (!t.applyRegexFlags || !e.flags)
|
|
423
|
+
return e.source;
|
|
424
|
+
const n = {
|
|
425
|
+
i: e.flags.includes("i"),
|
|
426
|
+
m: e.flags.includes("m"),
|
|
427
|
+
s: e.flags.includes("s")
|
|
428
|
+
// `.` matches newlines
|
|
429
|
+
}, a = n.i ? e.source.toLowerCase() : e.source;
|
|
430
|
+
let r = "", i = !1, s = !1, l = !1;
|
|
431
|
+
for (let u = 0; u < a.length; u++) {
|
|
432
|
+
if (i) {
|
|
433
|
+
r += a[u], i = !1;
|
|
434
|
+
continue;
|
|
435
|
+
}
|
|
436
|
+
if (n.i) {
|
|
437
|
+
if (s) {
|
|
438
|
+
if (a[u].match(/[a-z]/)) {
|
|
439
|
+
l ? (r += a[u], r += `${a[u - 2]}-${a[u]}`.toUpperCase(), l = !1) : a[u + 1] === "-" && ((c = a[u + 2]) != null && c.match(/[a-z]/)) ? (r += a[u], l = !0) : r += `${a[u]}${a[u].toUpperCase()}`;
|
|
440
|
+
continue;
|
|
441
|
+
}
|
|
442
|
+
} else if (a[u].match(/[a-z]/)) {
|
|
443
|
+
r += `[${a[u]}${a[u].toUpperCase()}]`;
|
|
444
|
+
continue;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
if (n.m) {
|
|
448
|
+
if (a[u] === "^") {
|
|
449
|
+
r += `(^|(?<=[\r
|
|
450
|
+
]))`;
|
|
451
|
+
continue;
|
|
452
|
+
} else if (a[u] === "$") {
|
|
453
|
+
r += `($|(?=[\r
|
|
454
|
+
]))`;
|
|
455
|
+
continue;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
if (n.s && a[u] === ".") {
|
|
459
|
+
r += s ? `${a[u]}\r
|
|
460
|
+
` : `[${a[u]}\r
|
|
461
|
+
]`;
|
|
462
|
+
continue;
|
|
463
|
+
}
|
|
464
|
+
r += a[u], a[u] === "\\" ? i = !0 : s && a[u] === "]" ? s = !1 : !s && a[u] === "[" && (s = !0);
|
|
465
|
+
}
|
|
466
|
+
try {
|
|
467
|
+
new RegExp(r);
|
|
468
|
+
} catch {
|
|
469
|
+
return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`), e.source;
|
|
470
|
+
}
|
|
471
|
+
return r;
|
|
472
|
+
}
|
|
473
|
+
function ze(e, t) {
|
|
474
|
+
var a, r, i, s, l, c;
|
|
475
|
+
if (t.target === "openAi" && console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."), t.target === "openApi3" && ((a = e.keyType) == null ? void 0 : a._def.typeName) === h.ZodEnum)
|
|
476
|
+
return {
|
|
477
|
+
type: "object",
|
|
478
|
+
required: e.keyType._def.values,
|
|
479
|
+
properties: e.keyType._def.values.reduce((u, d) => ({
|
|
480
|
+
...u,
|
|
481
|
+
[d]: y(e.valueType._def, {
|
|
482
|
+
...t,
|
|
483
|
+
currentPath: [...t.currentPath, "properties", d]
|
|
484
|
+
}) ?? _(t)
|
|
485
|
+
}), {}),
|
|
486
|
+
additionalProperties: t.rejectedAdditionalProperties
|
|
487
|
+
};
|
|
488
|
+
const n = {
|
|
489
|
+
type: "object",
|
|
490
|
+
additionalProperties: y(e.valueType._def, {
|
|
491
|
+
...t,
|
|
492
|
+
currentPath: [...t.currentPath, "additionalProperties"]
|
|
493
|
+
}) ?? t.allowedAdditionalProperties
|
|
494
|
+
};
|
|
495
|
+
if (t.target === "openApi3")
|
|
496
|
+
return n;
|
|
497
|
+
if (((r = e.keyType) == null ? void 0 : r._def.typeName) === h.ZodString && ((i = e.keyType._def.checks) != null && i.length)) {
|
|
498
|
+
const { type: u, ...d } = Re(e.keyType._def, t);
|
|
499
|
+
return {
|
|
500
|
+
...n,
|
|
501
|
+
propertyNames: d
|
|
502
|
+
};
|
|
503
|
+
} else {
|
|
504
|
+
if (((s = e.keyType) == null ? void 0 : s._def.typeName) === h.ZodEnum)
|
|
505
|
+
return {
|
|
506
|
+
...n,
|
|
507
|
+
propertyNames: {
|
|
508
|
+
enum: e.keyType._def.values
|
|
509
|
+
}
|
|
510
|
+
};
|
|
511
|
+
if (((l = e.keyType) == null ? void 0 : l._def.typeName) === h.ZodBranded && e.keyType._def.type._def.typeName === h.ZodString && ((c = e.keyType._def.type._def.checks) != null && c.length)) {
|
|
512
|
+
const { type: u, ...d } = Ie(e.keyType._def, t);
|
|
513
|
+
return {
|
|
514
|
+
...n,
|
|
515
|
+
propertyNames: d
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
return n;
|
|
520
|
+
}
|
|
521
|
+
function zt(e, t) {
|
|
522
|
+
if (t.mapStrategy === "record")
|
|
523
|
+
return ze(e, t);
|
|
524
|
+
const n = y(e.keyType._def, {
|
|
525
|
+
...t,
|
|
526
|
+
currentPath: [...t.currentPath, "items", "items", "0"]
|
|
527
|
+
}) || _(t), a = y(e.valueType._def, {
|
|
528
|
+
...t,
|
|
529
|
+
currentPath: [...t.currentPath, "items", "items", "1"]
|
|
530
|
+
}) || _(t);
|
|
531
|
+
return {
|
|
532
|
+
type: "array",
|
|
533
|
+
maxItems: 125,
|
|
534
|
+
items: {
|
|
535
|
+
type: "array",
|
|
536
|
+
items: [n, a],
|
|
537
|
+
minItems: 2,
|
|
538
|
+
maxItems: 2
|
|
539
|
+
}
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
function Bt(e) {
|
|
543
|
+
const t = e.values, a = Object.keys(e.values).filter((i) => typeof t[t[i]] != "number").map((i) => t[i]), r = Array.from(new Set(a.map((i) => typeof i)));
|
|
544
|
+
return {
|
|
545
|
+
type: r.length === 1 ? r[0] === "string" ? "string" : "number" : ["string", "number"],
|
|
546
|
+
enum: a
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
function Ut(e) {
|
|
550
|
+
return e.target === "openAi" ? void 0 : {
|
|
551
|
+
not: _({
|
|
552
|
+
...e,
|
|
553
|
+
currentPath: [...e.currentPath, "not"]
|
|
554
|
+
})
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
function Ft(e) {
|
|
558
|
+
return e.target === "openApi3" ? {
|
|
559
|
+
enum: ["null"],
|
|
560
|
+
nullable: !0
|
|
561
|
+
} : {
|
|
562
|
+
type: "null"
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
const X = {
|
|
566
|
+
ZodString: "string",
|
|
567
|
+
ZodNumber: "number",
|
|
568
|
+
ZodBigInt: "integer",
|
|
569
|
+
ZodBoolean: "boolean",
|
|
570
|
+
ZodNull: "null"
|
|
571
|
+
};
|
|
572
|
+
function qt(e, t) {
|
|
573
|
+
if (t.target === "openApi3")
|
|
574
|
+
return Se(e, t);
|
|
575
|
+
const n = e.options instanceof Map ? Array.from(e.options.values()) : e.options;
|
|
576
|
+
if (n.every((a) => a._def.typeName in X && (!a._def.checks || !a._def.checks.length))) {
|
|
577
|
+
const a = n.reduce((r, i) => {
|
|
578
|
+
const s = X[i._def.typeName];
|
|
579
|
+
return s && !r.includes(s) ? [...r, s] : r;
|
|
580
|
+
}, []);
|
|
581
|
+
return {
|
|
582
|
+
type: a.length > 1 ? a : a[0]
|
|
583
|
+
};
|
|
584
|
+
} else if (n.every((a) => a._def.typeName === "ZodLiteral" && !a.description)) {
|
|
585
|
+
const a = n.reduce((r, i) => {
|
|
586
|
+
const s = typeof i._def.value;
|
|
587
|
+
switch (s) {
|
|
588
|
+
case "string":
|
|
589
|
+
case "number":
|
|
590
|
+
case "boolean":
|
|
591
|
+
return [...r, s];
|
|
592
|
+
case "bigint":
|
|
593
|
+
return [...r, "integer"];
|
|
594
|
+
case "object":
|
|
595
|
+
if (i._def.value === null)
|
|
596
|
+
return [...r, "null"];
|
|
597
|
+
case "symbol":
|
|
598
|
+
case "undefined":
|
|
599
|
+
case "function":
|
|
600
|
+
default:
|
|
601
|
+
return r;
|
|
602
|
+
}
|
|
603
|
+
}, []);
|
|
604
|
+
if (a.length === n.length) {
|
|
605
|
+
const r = a.filter((i, s, l) => l.indexOf(i) === s);
|
|
606
|
+
return {
|
|
607
|
+
type: r.length > 1 ? r : r[0],
|
|
608
|
+
enum: n.reduce((i, s) => i.includes(s._def.value) ? i : [...i, s._def.value], [])
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
} else if (n.every((a) => a._def.typeName === "ZodEnum"))
|
|
612
|
+
return {
|
|
613
|
+
type: "string",
|
|
614
|
+
enum: n.reduce((a, r) => [
|
|
615
|
+
...a,
|
|
616
|
+
...r._def.values.filter((i) => !a.includes(i))
|
|
617
|
+
], [])
|
|
618
|
+
};
|
|
619
|
+
return Se(e, t);
|
|
620
|
+
}
|
|
621
|
+
const Se = (e, t) => {
|
|
622
|
+
const n = (e.options instanceof Map ? Array.from(e.options.values()) : e.options).map((a, r) => y(a._def, {
|
|
623
|
+
...t,
|
|
624
|
+
currentPath: [...t.currentPath, "anyOf", `${r}`]
|
|
625
|
+
})).filter((a) => !!a && (!t.strictUnions || typeof a == "object" && Object.keys(a).length > 0));
|
|
626
|
+
return n.length ? { anyOf: n } : void 0;
|
|
627
|
+
};
|
|
628
|
+
function Wt(e, t) {
|
|
629
|
+
if (["ZodString", "ZodNumber", "ZodBigInt", "ZodBoolean", "ZodNull"].includes(e.innerType._def.typeName) && (!e.innerType._def.checks || !e.innerType._def.checks.length))
|
|
630
|
+
return t.target === "openApi3" ? {
|
|
631
|
+
type: X[e.innerType._def.typeName],
|
|
632
|
+
nullable: !0
|
|
633
|
+
} : {
|
|
634
|
+
type: [
|
|
635
|
+
X[e.innerType._def.typeName],
|
|
636
|
+
"null"
|
|
637
|
+
]
|
|
638
|
+
};
|
|
639
|
+
if (t.target === "openApi3") {
|
|
640
|
+
const a = y(e.innerType._def, {
|
|
641
|
+
...t,
|
|
642
|
+
currentPath: [...t.currentPath]
|
|
643
|
+
});
|
|
644
|
+
return a && "$ref" in a ? { allOf: [a], nullable: !0 } : a && { ...a, nullable: !0 };
|
|
645
|
+
}
|
|
646
|
+
const n = y(e.innerType._def, {
|
|
647
|
+
...t,
|
|
648
|
+
currentPath: [...t.currentPath, "anyOf", "0"]
|
|
649
|
+
});
|
|
650
|
+
return n && { anyOf: [n, { type: "null" }] };
|
|
651
|
+
}
|
|
652
|
+
function Ht(e, t) {
|
|
653
|
+
const n = {
|
|
654
|
+
type: "number"
|
|
655
|
+
};
|
|
656
|
+
if (!e.checks)
|
|
657
|
+
return n;
|
|
658
|
+
for (const a of e.checks)
|
|
659
|
+
switch (a.kind) {
|
|
660
|
+
case "int":
|
|
661
|
+
n.type = "integer", Ne(n, "type", a.message, t);
|
|
662
|
+
break;
|
|
663
|
+
case "min":
|
|
664
|
+
t.target === "jsonSchema7" ? a.inclusive ? v(n, "minimum", a.value, a.message, t) : v(n, "exclusiveMinimum", a.value, a.message, t) : (a.inclusive || (n.exclusiveMinimum = !0), v(n, "minimum", a.value, a.message, t));
|
|
665
|
+
break;
|
|
666
|
+
case "max":
|
|
667
|
+
t.target === "jsonSchema7" ? a.inclusive ? v(n, "maximum", a.value, a.message, t) : v(n, "exclusiveMaximum", a.value, a.message, t) : (a.inclusive || (n.exclusiveMaximum = !0), v(n, "maximum", a.value, a.message, t));
|
|
668
|
+
break;
|
|
669
|
+
case "multipleOf":
|
|
670
|
+
v(n, "multipleOf", a.value, a.message, t);
|
|
671
|
+
break;
|
|
672
|
+
}
|
|
673
|
+
return n;
|
|
674
|
+
}
|
|
675
|
+
function Vt(e, t) {
|
|
676
|
+
const n = t.target === "openAi", a = {
|
|
677
|
+
type: "object",
|
|
678
|
+
properties: {}
|
|
679
|
+
}, r = [], i = e.shape();
|
|
680
|
+
for (const l in i) {
|
|
681
|
+
let c = i[l];
|
|
682
|
+
if (c === void 0 || c._def === void 0)
|
|
683
|
+
continue;
|
|
684
|
+
let u = Yt(c);
|
|
685
|
+
u && n && (c._def.typeName === "ZodOptional" && (c = c._def.innerType), c.isNullable() || (c = c.nullable()), u = !1);
|
|
686
|
+
const d = y(c._def, {
|
|
687
|
+
...t,
|
|
688
|
+
currentPath: [...t.currentPath, "properties", l],
|
|
689
|
+
propertyPath: [...t.currentPath, "properties", l]
|
|
690
|
+
});
|
|
691
|
+
d !== void 0 && (a.properties[l] = d, u || r.push(l));
|
|
692
|
+
}
|
|
693
|
+
r.length && (a.required = r);
|
|
694
|
+
const s = Jt(e, t);
|
|
695
|
+
return s !== void 0 && (a.additionalProperties = s), a;
|
|
696
|
+
}
|
|
697
|
+
function Jt(e, t) {
|
|
698
|
+
if (e.catchall._def.typeName !== "ZodNever")
|
|
699
|
+
return y(e.catchall._def, {
|
|
700
|
+
...t,
|
|
701
|
+
currentPath: [...t.currentPath, "additionalProperties"]
|
|
702
|
+
});
|
|
703
|
+
switch (e.unknownKeys) {
|
|
704
|
+
case "passthrough":
|
|
705
|
+
return t.allowedAdditionalProperties;
|
|
706
|
+
case "strict":
|
|
707
|
+
return t.rejectedAdditionalProperties;
|
|
708
|
+
case "strip":
|
|
709
|
+
return t.removeAdditionalStrategy === "strict" ? t.allowedAdditionalProperties : t.rejectedAdditionalProperties;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
function Yt(e) {
|
|
713
|
+
try {
|
|
714
|
+
return e.isOptional();
|
|
715
|
+
} catch {
|
|
716
|
+
return !0;
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
const Gt = (e, t) => {
|
|
720
|
+
var a;
|
|
721
|
+
if (t.currentPath.toString() === ((a = t.propertyPath) == null ? void 0 : a.toString()))
|
|
722
|
+
return y(e.innerType._def, t);
|
|
723
|
+
const n = y(e.innerType._def, {
|
|
724
|
+
...t,
|
|
725
|
+
currentPath: [...t.currentPath, "anyOf", "1"]
|
|
726
|
+
});
|
|
727
|
+
return n ? {
|
|
728
|
+
anyOf: [
|
|
729
|
+
{
|
|
730
|
+
not: _(t)
|
|
731
|
+
},
|
|
732
|
+
n
|
|
733
|
+
]
|
|
734
|
+
} : _(t);
|
|
735
|
+
}, Qt = (e, t) => {
|
|
736
|
+
if (t.pipeStrategy === "input")
|
|
737
|
+
return y(e.in._def, t);
|
|
738
|
+
if (t.pipeStrategy === "output")
|
|
739
|
+
return y(e.out._def, t);
|
|
740
|
+
const n = y(e.in._def, {
|
|
741
|
+
...t,
|
|
742
|
+
currentPath: [...t.currentPath, "allOf", "0"]
|
|
743
|
+
}), a = y(e.out._def, {
|
|
744
|
+
...t,
|
|
745
|
+
currentPath: [...t.currentPath, "allOf", n ? "1" : "0"]
|
|
746
|
+
});
|
|
747
|
+
return {
|
|
748
|
+
allOf: [n, a].filter((r) => r !== void 0)
|
|
749
|
+
};
|
|
750
|
+
};
|
|
751
|
+
function Xt(e, t) {
|
|
752
|
+
return y(e.type._def, t);
|
|
753
|
+
}
|
|
754
|
+
function Kt(e, t) {
|
|
755
|
+
const a = {
|
|
756
|
+
type: "array",
|
|
757
|
+
uniqueItems: !0,
|
|
758
|
+
items: y(e.valueType._def, {
|
|
759
|
+
...t,
|
|
760
|
+
currentPath: [...t.currentPath, "items"]
|
|
761
|
+
})
|
|
762
|
+
};
|
|
763
|
+
return e.minSize && v(a, "minItems", e.minSize.value, e.minSize.message, t), e.maxSize && v(a, "maxItems", e.maxSize.value, e.maxSize.message, t), a;
|
|
764
|
+
}
|
|
765
|
+
function en(e, t) {
|
|
766
|
+
return e.rest ? {
|
|
767
|
+
type: "array",
|
|
768
|
+
minItems: e.items.length,
|
|
769
|
+
items: e.items.map((n, a) => y(n._def, {
|
|
770
|
+
...t,
|
|
771
|
+
currentPath: [...t.currentPath, "items", `${a}`]
|
|
772
|
+
})).reduce((n, a) => a === void 0 ? n : [...n, a], []),
|
|
773
|
+
additionalItems: y(e.rest._def, {
|
|
774
|
+
...t,
|
|
775
|
+
currentPath: [...t.currentPath, "additionalItems"]
|
|
776
|
+
})
|
|
777
|
+
} : {
|
|
778
|
+
type: "array",
|
|
779
|
+
minItems: e.items.length,
|
|
780
|
+
maxItems: e.items.length,
|
|
781
|
+
items: e.items.map((n, a) => y(n._def, {
|
|
782
|
+
...t,
|
|
783
|
+
currentPath: [...t.currentPath, "items", `${a}`]
|
|
784
|
+
})).reduce((n, a) => a === void 0 ? n : [...n, a], [])
|
|
785
|
+
};
|
|
786
|
+
}
|
|
787
|
+
function tn(e) {
|
|
788
|
+
return {
|
|
789
|
+
not: _(e)
|
|
790
|
+
};
|
|
791
|
+
}
|
|
792
|
+
function nn(e) {
|
|
793
|
+
return _(e);
|
|
794
|
+
}
|
|
795
|
+
const an = (e, t) => y(e.innerType._def, t), rn = (e, t, n) => {
|
|
796
|
+
switch (t) {
|
|
797
|
+
case h.ZodString:
|
|
798
|
+
return Re(e, n);
|
|
799
|
+
case h.ZodNumber:
|
|
800
|
+
return Ht(e, n);
|
|
801
|
+
case h.ZodObject:
|
|
802
|
+
return Vt(e, n);
|
|
803
|
+
case h.ZodBigInt:
|
|
804
|
+
return xt(e, n);
|
|
805
|
+
case h.ZodBoolean:
|
|
806
|
+
return $t();
|
|
807
|
+
case h.ZodDate:
|
|
808
|
+
return Le(e, n);
|
|
809
|
+
case h.ZodUndefined:
|
|
810
|
+
return tn(n);
|
|
811
|
+
case h.ZodNull:
|
|
812
|
+
return Ft(n);
|
|
813
|
+
case h.ZodArray:
|
|
814
|
+
return At(e, n);
|
|
815
|
+
case h.ZodUnion:
|
|
816
|
+
case h.ZodDiscriminatedUnion:
|
|
817
|
+
return qt(e, n);
|
|
818
|
+
case h.ZodIntersection:
|
|
819
|
+
return Zt(e, n);
|
|
820
|
+
case h.ZodTuple:
|
|
821
|
+
return en(e, n);
|
|
822
|
+
case h.ZodRecord:
|
|
823
|
+
return ze(e, n);
|
|
824
|
+
case h.ZodLiteral:
|
|
825
|
+
return It(e, n);
|
|
826
|
+
case h.ZodEnum:
|
|
827
|
+
return Mt(e);
|
|
828
|
+
case h.ZodNativeEnum:
|
|
829
|
+
return Bt(e);
|
|
830
|
+
case h.ZodNullable:
|
|
831
|
+
return Wt(e, n);
|
|
832
|
+
case h.ZodOptional:
|
|
833
|
+
return Gt(e, n);
|
|
834
|
+
case h.ZodMap:
|
|
835
|
+
return zt(e, n);
|
|
836
|
+
case h.ZodSet:
|
|
837
|
+
return Kt(e, n);
|
|
838
|
+
case h.ZodLazy:
|
|
839
|
+
return () => e.getter()._def;
|
|
840
|
+
case h.ZodPromise:
|
|
841
|
+
return Xt(e, n);
|
|
842
|
+
case h.ZodNaN:
|
|
843
|
+
case h.ZodNever:
|
|
844
|
+
return Ut(n);
|
|
845
|
+
case h.ZodEffects:
|
|
846
|
+
return Et(e, n);
|
|
847
|
+
case h.ZodAny:
|
|
848
|
+
return _(n);
|
|
849
|
+
case h.ZodUnknown:
|
|
850
|
+
return nn(n);
|
|
851
|
+
case h.ZodDefault:
|
|
852
|
+
return kt(e, n);
|
|
853
|
+
case h.ZodBranded:
|
|
854
|
+
return Ie(e, n);
|
|
855
|
+
case h.ZodReadonly:
|
|
856
|
+
return an(e, n);
|
|
857
|
+
case h.ZodCatch:
|
|
858
|
+
return Tt(e, n);
|
|
859
|
+
case h.ZodPipeline:
|
|
860
|
+
return Qt(e, n);
|
|
861
|
+
case h.ZodFunction:
|
|
862
|
+
case h.ZodVoid:
|
|
863
|
+
case h.ZodSymbol:
|
|
864
|
+
return;
|
|
865
|
+
default:
|
|
866
|
+
return /* @__PURE__ */ ((a) => {
|
|
867
|
+
})();
|
|
868
|
+
}
|
|
869
|
+
};
|
|
870
|
+
function y(e, t, n = !1) {
|
|
871
|
+
var l;
|
|
872
|
+
const a = t.seen.get(e);
|
|
873
|
+
if (t.override) {
|
|
874
|
+
const c = (l = t.override) == null ? void 0 : l.call(t, e, t, a, n);
|
|
875
|
+
if (c !== Ct)
|
|
876
|
+
return c;
|
|
877
|
+
}
|
|
878
|
+
if (a && !n) {
|
|
879
|
+
const c = on(a, t);
|
|
880
|
+
if (c !== void 0)
|
|
881
|
+
return c;
|
|
882
|
+
}
|
|
883
|
+
const r = { def: e, path: t.currentPath, jsonSchema: void 0 };
|
|
884
|
+
t.seen.set(e, r);
|
|
885
|
+
const i = rn(e, e.typeName, t), s = typeof i == "function" ? y(i(), t) : i;
|
|
886
|
+
if (s && sn(e, t, s), t.postProcess) {
|
|
887
|
+
const c = t.postProcess(s, e, t);
|
|
888
|
+
return r.jsonSchema = s, c;
|
|
889
|
+
}
|
|
890
|
+
return r.jsonSchema = s, s;
|
|
891
|
+
}
|
|
892
|
+
const on = (e, t) => {
|
|
893
|
+
switch (t.$refStrategy) {
|
|
894
|
+
case "root":
|
|
895
|
+
return { $ref: e.path.join("/") };
|
|
896
|
+
case "relative":
|
|
897
|
+
return { $ref: Ze(t.currentPath, e.path) };
|
|
898
|
+
case "none":
|
|
899
|
+
case "seen":
|
|
900
|
+
return e.path.length < t.currentPath.length && e.path.every((n, a) => t.currentPath[a] === n) ? (console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`), _(t)) : t.$refStrategy === "seen" ? _(t) : void 0;
|
|
901
|
+
}
|
|
902
|
+
}, sn = (e, t, n) => (e.description && (n.description = e.description, t.markdownDescription && (n.markdownDescription = e.description)), n), ln = (e, t) => {
|
|
903
|
+
const n = Pt(t);
|
|
904
|
+
let a;
|
|
905
|
+
const r = t == null ? void 0 : t.name, i = y(
|
|
906
|
+
e._def,
|
|
907
|
+
n,
|
|
908
|
+
!1
|
|
909
|
+
) ?? _(n);
|
|
910
|
+
n.flags.hasReferencedOpenAiAnyType && (a || (a = {}), a[n.openAiAnyTypeName] || (a[n.openAiAnyTypeName] = {
|
|
911
|
+
// Skipping "object" as no properties can be defined and additionalProperties must be "false"
|
|
912
|
+
type: ["string", "number", "integer", "boolean", "array", "null"],
|
|
913
|
+
items: {
|
|
914
|
+
$ref: n.$refStrategy === "relative" ? "1" : [
|
|
915
|
+
...n.basePath,
|
|
916
|
+
n.definitionPath,
|
|
917
|
+
n.openAiAnyTypeName
|
|
918
|
+
].join("/")
|
|
919
|
+
}
|
|
920
|
+
}));
|
|
921
|
+
const s = r === void 0 ? a ? {
|
|
922
|
+
...i,
|
|
923
|
+
[n.definitionPath]: a
|
|
924
|
+
} : i : {
|
|
925
|
+
$ref: [
|
|
926
|
+
...n.$refStrategy === "relative" ? [] : n.basePath,
|
|
927
|
+
n.definitionPath,
|
|
928
|
+
r
|
|
929
|
+
].join("/"),
|
|
930
|
+
[n.definitionPath]: {
|
|
931
|
+
...a,
|
|
932
|
+
[r]: i
|
|
933
|
+
}
|
|
934
|
+
};
|
|
935
|
+
return n.target === "jsonSchema7" ? s.$schema = "http://json-schema.org/draft-07/schema#" : (n.target === "jsonSchema2019-09" || n.target === "openAi") && (s.$schema = "https://json-schema.org/draft/2019-09/schema#"), n.target === "openAi" && ("anyOf" in s || "oneOf" in s || "allOf" in s || "type" in s && Array.isArray(s.type)) && console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."), s;
|
|
936
|
+
}, Oe = (e) => " ".repeat(e), G = (e, t) => {
|
|
937
|
+
let n = e;
|
|
938
|
+
for (; n instanceof o.ZodOptional || n instanceof o.ZodNullable; )
|
|
939
|
+
n = n.unwrap();
|
|
940
|
+
if (n instanceof o.ZodArray)
|
|
941
|
+
return G(n.element, t);
|
|
942
|
+
if (n instanceof o.ZodUnion)
|
|
943
|
+
return n.options.some(
|
|
944
|
+
(a) => G(a, t)
|
|
945
|
+
);
|
|
946
|
+
if (n instanceof o.ZodObject) {
|
|
947
|
+
for (const [a, r] of Object.entries(n.shape))
|
|
948
|
+
if (t.includes(a) || G(r, t))
|
|
949
|
+
return !0;
|
|
950
|
+
}
|
|
951
|
+
return !1;
|
|
952
|
+
}, M = (e, t, n) => {
|
|
953
|
+
if (e instanceof o.ZodOptional)
|
|
954
|
+
return o.ZodOptional.create(
|
|
955
|
+
M(e.unwrap(), t, n)
|
|
956
|
+
);
|
|
957
|
+
if (e instanceof o.ZodNullable)
|
|
958
|
+
return o.ZodNullable.create(
|
|
959
|
+
M(e.unwrap(), t, n)
|
|
960
|
+
);
|
|
961
|
+
if (e instanceof o.ZodArray) {
|
|
962
|
+
const a = M(
|
|
963
|
+
e.element,
|
|
964
|
+
t,
|
|
965
|
+
n
|
|
966
|
+
);
|
|
967
|
+
return o.ZodArray.create(a, e._def);
|
|
968
|
+
}
|
|
969
|
+
if (e instanceof o.ZodUnion) {
|
|
970
|
+
const a = e.options.map(
|
|
971
|
+
(r) => M(r, t, n)
|
|
972
|
+
);
|
|
973
|
+
return o.ZodUnion.create(a);
|
|
974
|
+
}
|
|
975
|
+
if (e instanceof o.ZodObject) {
|
|
976
|
+
const a = [];
|
|
977
|
+
for (const [i, s] of Object.entries(e.shape))
|
|
978
|
+
if (n === "include") {
|
|
979
|
+
if (t.includes(i))
|
|
980
|
+
a.push([i, s]);
|
|
981
|
+
else if (G(s, t)) {
|
|
982
|
+
const l = M(
|
|
983
|
+
s,
|
|
984
|
+
t,
|
|
985
|
+
n
|
|
986
|
+
);
|
|
987
|
+
a.push([i, l]);
|
|
988
|
+
}
|
|
989
|
+
} else if (!t.includes(i)) {
|
|
990
|
+
const l = M(
|
|
991
|
+
s,
|
|
992
|
+
t,
|
|
993
|
+
n
|
|
994
|
+
);
|
|
995
|
+
a.push([i, l]);
|
|
996
|
+
}
|
|
997
|
+
const r = Object.fromEntries(
|
|
998
|
+
a
|
|
999
|
+
);
|
|
1000
|
+
return o.ZodObject.create(r, e._def);
|
|
1001
|
+
}
|
|
1002
|
+
return e;
|
|
1003
|
+
}, re = (e, t) => M(e, t, "include"), cn = (e, t) => M(e, t, "exclude"), P = (e, t = 0, n, a) => e instanceof o.ZodOptional ? P(e.unwrap(), t) : e instanceof o.ZodNullable ? P(e.unwrap(), t) + " | null" : e instanceof o.ZodArray ? `Array<${P(e.element, t)}>${e.description ? ` - ${e.description}` : ""}` : e instanceof o.ZodObject ? `{
|
|
1004
|
+
${Object.entries(e.shape).map(
|
|
1005
|
+
([i, s]) => `${Oe(t + 1)}${i}${s.isOptional() ? "?" : ""}: ${P(s, t + 1, i, s.isOptional())}${s.description ? ` - ${s.description}` : ""}`
|
|
1006
|
+
).join(`,
|
|
1007
|
+
`)}
|
|
1008
|
+
${Oe(t)}}` + (e.description ? ` - ${e.description}` : "") : e instanceof o.ZodEnum ? e.options.map((i) => `"${i}"`).join(" | ") + (e.description ? ` - ${e.description}` : "") : e instanceof o.ZodUnion ? e.options.map((r) => P(r, t)).join(" | ") : e instanceof o.ZodLiteral ? JSON.stringify(e.value) : e instanceof o.ZodString ? "string" : e instanceof o.ZodNumber ? "number" : e instanceof o.ZodBoolean ? "boolean" : "any";
|
|
1009
|
+
function un({
|
|
1010
|
+
function: e,
|
|
1011
|
+
schema: t,
|
|
1012
|
+
description: n = "",
|
|
1013
|
+
name: a,
|
|
1014
|
+
strict: r = !1
|
|
1015
|
+
}) {
|
|
1016
|
+
return {
|
|
1017
|
+
type: "function",
|
|
1018
|
+
function: {
|
|
1019
|
+
function: async (i, s) => e(i, s),
|
|
1020
|
+
name: a ?? e.name,
|
|
1021
|
+
description: n,
|
|
1022
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1023
|
+
parameters: ln(t),
|
|
1024
|
+
strict: r,
|
|
1025
|
+
parse(i) {
|
|
1026
|
+
const s = JSON.parse(i);
|
|
1027
|
+
return t.parse(s);
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
};
|
|
1031
|
+
}
|
|
1032
|
+
const Be = o.enum(["bar", "column", "area", "line", "polar"]), Ue = o.enum(["pie", "funnel", "treemap", "sunburst"]), dn = o.enum([
|
|
1033
|
+
"scatter",
|
|
1034
|
+
"table",
|
|
1035
|
+
"indicator",
|
|
1036
|
+
"boxplot",
|
|
1037
|
+
"areamap",
|
|
1038
|
+
"scattermap",
|
|
1039
|
+
"arearange"
|
|
1040
|
+
]), ee = o.enum([
|
|
1041
|
+
...Be.options,
|
|
1042
|
+
...Ue.options,
|
|
1043
|
+
...dn.options
|
|
1044
|
+
]), pn = o.object({
|
|
1045
|
+
type: Be,
|
|
1046
|
+
category: o.array(o.number()),
|
|
1047
|
+
value: o.array(o.number()),
|
|
1048
|
+
breakBy: o.array(o.number())
|
|
1049
|
+
}).strict(), mn = o.object({
|
|
1050
|
+
type: Ue,
|
|
1051
|
+
category: o.array(o.number()),
|
|
1052
|
+
value: o.array(o.number())
|
|
1053
|
+
}).strict(), hn = o.object({
|
|
1054
|
+
type: o.literal("scatter"),
|
|
1055
|
+
x: o.array(o.number()),
|
|
1056
|
+
y: o.array(o.number()),
|
|
1057
|
+
breakByPoint: o.array(o.number()),
|
|
1058
|
+
breakByColor: o.array(o.number()),
|
|
1059
|
+
size: o.array(o.number())
|
|
1060
|
+
// showLegend: z.boolean(),
|
|
1061
|
+
}).strict(), gn = o.object({
|
|
1062
|
+
type: o.literal("table"),
|
|
1063
|
+
columns: o.array(o.number()),
|
|
1064
|
+
pagination: o.boolean(),
|
|
1065
|
+
rowsPerPage: o.number()
|
|
1066
|
+
}).strict(), fn = o.object({
|
|
1067
|
+
type: o.literal("range"),
|
|
1068
|
+
category: o.array(o.number()),
|
|
1069
|
+
value: o.array(o.number()),
|
|
1070
|
+
breakBy: o.array(o.number())
|
|
1071
|
+
}).strict(), bn = o.object({
|
|
1072
|
+
type: o.literal("indicator"),
|
|
1073
|
+
value: o.array(o.number()),
|
|
1074
|
+
secondary: o.array(o.number()),
|
|
1075
|
+
min: o.array(o.number()),
|
|
1076
|
+
max: o.array(o.number())
|
|
1077
|
+
}).strict(), yn = o.object({
|
|
1078
|
+
type: o.literal("boxplot"),
|
|
1079
|
+
category: o.array(o.number()),
|
|
1080
|
+
value: o.array(o.number()),
|
|
1081
|
+
boxType: o.enum(["iqr", "extremums", "standardDeviation"]),
|
|
1082
|
+
outliersEnabled: o.boolean()
|
|
1083
|
+
}).strict(), vn = o.object({
|
|
1084
|
+
type: o.literal("areamap"),
|
|
1085
|
+
geo: o.array(o.number()),
|
|
1086
|
+
color: o.array(o.number())
|
|
1087
|
+
}).strict(), wn = o.object({
|
|
1088
|
+
type: o.literal("scattermap"),
|
|
1089
|
+
geo: o.array(o.number()),
|
|
1090
|
+
size: o.array(o.number()),
|
|
1091
|
+
colorBy: o.array(o.number()),
|
|
1092
|
+
details: o.array(o.number()),
|
|
1093
|
+
locationLevel: o.enum(["auto", "country", "state", "city"])
|
|
1094
|
+
}).strict(), Sn = o.discriminatedUnion("type", [
|
|
1095
|
+
pn,
|
|
1096
|
+
mn,
|
|
1097
|
+
hn,
|
|
1098
|
+
gn,
|
|
1099
|
+
fn,
|
|
1100
|
+
bn,
|
|
1101
|
+
yn,
|
|
1102
|
+
vn,
|
|
1103
|
+
wn
|
|
1104
|
+
]), On = ee.nullable().describe(
|
|
1105
|
+
"If the user prompt does not specify a known chart type, pass null; otherwise, pass the specified chart type"
|
|
1106
|
+
), Cn = o.string().describe(
|
|
1107
|
+
'The ID of the chart to update. If not provided, use value "chart_id_placeholder"'
|
|
1108
|
+
).default("chart_id_placeholder"), Dn = o.object({
|
|
1109
|
+
chartType: ee,
|
|
1110
|
+
axesMapping: Sn
|
|
1111
|
+
}), Do = o.object({
|
|
1112
|
+
dataSourceTitle: o.string().describe("Data source title"),
|
|
1113
|
+
userPrompt: o.string().describe(
|
|
1114
|
+
`Combined natural language user prompt describing multiple actions on a chart. Do not split the user prompt into multiple requests.
|
|
1115
|
+
When responding to changes involving an existing chart:
|
|
1116
|
+
- If the prompt involves **adding or removing** chart's data structure such as dimensions, measures, or filters (e.g., "add revenue", "remove date", "filter by region"), do **not** modify the existing chart. Instead, **create a new chart** with the requested changes.
|
|
1117
|
+
- If the prompt involves **enhancing** how existing fields are displayed (e.g., "show cost on the right axis", "add trend line", "change color", "adjust scale"), apply the changes **to the existing chart**.
|
|
1118
|
+
`
|
|
1119
|
+
)
|
|
1120
|
+
}), Fe = o.object({
|
|
1121
|
+
userPrompt: o.string().describe(
|
|
1122
|
+
"Natural language user prompt describing a single action on a chart"
|
|
1123
|
+
)
|
|
1124
|
+
}), _n = Fe.extend({
|
|
1125
|
+
chartType: On,
|
|
1126
|
+
chartTitle: o.string().describe("The new chart title")
|
|
1127
|
+
}), L = Fe.extend({
|
|
1128
|
+
chartId: Cn
|
|
1129
|
+
}), Pn = L.extend({
|
|
1130
|
+
chartTitle: o.string().describe("The new chart title")
|
|
1131
|
+
}), An = L.extend({
|
|
1132
|
+
chartType: ee
|
|
1133
|
+
}), xn = L, $n = L, Tn = L, jn = L, kn = L;
|
|
1134
|
+
let En = (e) => crypto.getRandomValues(new Uint8Array(e)), Mn = (e, t, n) => {
|
|
1135
|
+
let a = (2 << Math.log2(e.length - 1)) - 1, r = -~(1.6 * a * t / e.length);
|
|
1136
|
+
return (i = t) => {
|
|
1137
|
+
let s = "";
|
|
1138
|
+
for (; ; ) {
|
|
1139
|
+
let l = n(r), c = r | 0;
|
|
1140
|
+
for (; c--; )
|
|
1141
|
+
if (s += e[l[c] & a] || "", s.length >= i) return s;
|
|
1142
|
+
}
|
|
1143
|
+
};
|
|
1144
|
+
}, qe = (e, t = 21) => Mn(e, t | 0, En);
|
|
1145
|
+
const me = qe("0123456789abcdef", 24);
|
|
1146
|
+
function le() {
|
|
1147
|
+
const t = qe("0123456789abcdef", 32)();
|
|
1148
|
+
return t.substring(0, 8) + "-" + t.substring(8, 12) + "-4" + t.substring(13, 16) + "-" + (parseInt(t[16], 16) & 3 | 8).toString(16) + t.substring(17, 20) + "-" + t.substring(20);
|
|
1149
|
+
}
|
|
1150
|
+
function Nn(e, t) {
|
|
1151
|
+
const n = { ...e };
|
|
1152
|
+
return Object.defineProperties(n, {
|
|
1153
|
+
$brand: {
|
|
1154
|
+
value: "auto-parseable-response-format",
|
|
1155
|
+
enumerable: !1
|
|
1156
|
+
},
|
|
1157
|
+
$parseRaw: {
|
|
1158
|
+
value: t,
|
|
1159
|
+
enumerable: !1
|
|
1160
|
+
}
|
|
1161
|
+
}), n;
|
|
1162
|
+
}
|
|
1163
|
+
const Zn = Symbol("Let zodToJsonSchema decide on which parser to use"), Ce = {
|
|
1164
|
+
name: void 0,
|
|
1165
|
+
$refStrategy: "root",
|
|
1166
|
+
effectStrategy: "input",
|
|
1167
|
+
pipeStrategy: "all",
|
|
1168
|
+
dateStrategy: "format:date-time",
|
|
1169
|
+
mapStrategy: "entries",
|
|
1170
|
+
nullableStrategy: "from-target",
|
|
1171
|
+
removeAdditionalStrategy: "passthrough",
|
|
1172
|
+
definitionPath: "definitions",
|
|
1173
|
+
target: "jsonSchema7",
|
|
1174
|
+
strictUnions: !1,
|
|
1175
|
+
errorMessages: !1,
|
|
1176
|
+
markdownDescription: !1,
|
|
1177
|
+
patternStrategy: "escape",
|
|
1178
|
+
applyRegexFlags: !1,
|
|
1179
|
+
emailStrategy: "format:email",
|
|
1180
|
+
base64Strategy: "contentEncoding:base64",
|
|
1181
|
+
nameStrategy: "ref"
|
|
1182
|
+
}, In = (e) => typeof e == "string" ? {
|
|
1183
|
+
...Ce,
|
|
1184
|
+
basePath: ["#"],
|
|
1185
|
+
definitions: {},
|
|
1186
|
+
name: e
|
|
1187
|
+
} : {
|
|
1188
|
+
...Ce,
|
|
1189
|
+
basePath: ["#"],
|
|
1190
|
+
definitions: {},
|
|
1191
|
+
...e
|
|
1192
|
+
}, ce = (e) => "_def" in e ? e._def : e;
|
|
1193
|
+
function Ln(e) {
|
|
1194
|
+
if (!e)
|
|
1195
|
+
return !0;
|
|
1196
|
+
for (const t in e)
|
|
1197
|
+
return !1;
|
|
1198
|
+
return !0;
|
|
1199
|
+
}
|
|
1200
|
+
const Rn = (e) => {
|
|
1201
|
+
const t = In(e), n = t.name !== void 0 ? [...t.basePath, t.definitionPath, t.name] : t.basePath;
|
|
1202
|
+
return {
|
|
1203
|
+
...t,
|
|
1204
|
+
currentPath: n,
|
|
1205
|
+
propertyPath: void 0,
|
|
1206
|
+
seenRefs: /* @__PURE__ */ new Set(),
|
|
1207
|
+
seen: new Map(Object.entries(t.definitions).map(([a, r]) => [
|
|
1208
|
+
ce(r),
|
|
1209
|
+
{
|
|
1210
|
+
def: ce(r),
|
|
1211
|
+
path: [...t.basePath, t.definitionPath, a],
|
|
1212
|
+
// Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
|
|
1213
|
+
jsonSchema: void 0
|
|
1214
|
+
}
|
|
1215
|
+
]))
|
|
1216
|
+
};
|
|
1217
|
+
};
|
|
1218
|
+
function We(e, t, n, a) {
|
|
1219
|
+
a != null && a.errorMessages && n && (e.errorMessage = {
|
|
1220
|
+
...e.errorMessage,
|
|
1221
|
+
[t]: n
|
|
1222
|
+
});
|
|
1223
|
+
}
|
|
1224
|
+
function w(e, t, n, a, r) {
|
|
1225
|
+
e[t] = n, We(e, t, a, r);
|
|
1226
|
+
}
|
|
1227
|
+
function zn() {
|
|
1228
|
+
return {};
|
|
1229
|
+
}
|
|
1230
|
+
function Bn(e, t) {
|
|
1231
|
+
var a, r;
|
|
1232
|
+
const n = {
|
|
1233
|
+
type: "array"
|
|
1234
|
+
};
|
|
1235
|
+
return ((r = (a = e.type) == null ? void 0 : a._def) == null ? void 0 : r.typeName) !== g.ZodAny && (n.items = b(e.type._def, {
|
|
1236
|
+
...t,
|
|
1237
|
+
currentPath: [...t.currentPath, "items"]
|
|
1238
|
+
})), e.minLength && w(n, "minItems", e.minLength.value, e.minLength.message, t), e.maxLength && w(n, "maxItems", e.maxLength.value, e.maxLength.message, t), e.exactLength && (w(n, "minItems", e.exactLength.value, e.exactLength.message, t), w(n, "maxItems", e.exactLength.value, e.exactLength.message, t)), n;
|
|
1239
|
+
}
|
|
1240
|
+
function Un(e, t) {
|
|
1241
|
+
const n = {
|
|
1242
|
+
type: "integer",
|
|
1243
|
+
format: "int64"
|
|
1244
|
+
};
|
|
1245
|
+
if (!e.checks)
|
|
1246
|
+
return n;
|
|
1247
|
+
for (const a of e.checks)
|
|
1248
|
+
switch (a.kind) {
|
|
1249
|
+
case "min":
|
|
1250
|
+
t.target === "jsonSchema7" ? a.inclusive ? w(n, "minimum", a.value, a.message, t) : w(n, "exclusiveMinimum", a.value, a.message, t) : (a.inclusive || (n.exclusiveMinimum = !0), w(n, "minimum", a.value, a.message, t));
|
|
1251
|
+
break;
|
|
1252
|
+
case "max":
|
|
1253
|
+
t.target === "jsonSchema7" ? a.inclusive ? w(n, "maximum", a.value, a.message, t) : w(n, "exclusiveMaximum", a.value, a.message, t) : (a.inclusive || (n.exclusiveMaximum = !0), w(n, "maximum", a.value, a.message, t));
|
|
1254
|
+
break;
|
|
1255
|
+
case "multipleOf":
|
|
1256
|
+
w(n, "multipleOf", a.value, a.message, t);
|
|
1257
|
+
break;
|
|
1258
|
+
}
|
|
1259
|
+
return n;
|
|
1260
|
+
}
|
|
1261
|
+
function Fn() {
|
|
1262
|
+
return {
|
|
1263
|
+
type: "boolean"
|
|
1264
|
+
};
|
|
1265
|
+
}
|
|
1266
|
+
function qn(e, t) {
|
|
1267
|
+
return b(e.type._def, t);
|
|
1268
|
+
}
|
|
1269
|
+
const Wn = (e, t) => b(e.innerType._def, t);
|
|
1270
|
+
function He(e, t, n) {
|
|
1271
|
+
const a = n ?? t.dateStrategy;
|
|
1272
|
+
if (Array.isArray(a))
|
|
1273
|
+
return {
|
|
1274
|
+
anyOf: a.map((r, i) => He(e, t, r))
|
|
1275
|
+
};
|
|
1276
|
+
switch (a) {
|
|
1277
|
+
case "string":
|
|
1278
|
+
case "format:date-time":
|
|
1279
|
+
return {
|
|
1280
|
+
type: "string",
|
|
1281
|
+
format: "date-time"
|
|
1282
|
+
};
|
|
1283
|
+
case "format:date":
|
|
1284
|
+
return {
|
|
1285
|
+
type: "string",
|
|
1286
|
+
format: "date"
|
|
1287
|
+
};
|
|
1288
|
+
case "integer":
|
|
1289
|
+
return Hn(e, t);
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
const Hn = (e, t) => {
|
|
1293
|
+
const n = {
|
|
1294
|
+
type: "integer",
|
|
1295
|
+
format: "unix-time"
|
|
1296
|
+
};
|
|
1297
|
+
if (t.target === "openApi3")
|
|
1298
|
+
return n;
|
|
1299
|
+
for (const a of e.checks)
|
|
1300
|
+
switch (a.kind) {
|
|
1301
|
+
case "min":
|
|
1302
|
+
w(
|
|
1303
|
+
n,
|
|
1304
|
+
"minimum",
|
|
1305
|
+
a.value,
|
|
1306
|
+
// This is in milliseconds
|
|
1307
|
+
a.message,
|
|
1308
|
+
t
|
|
1309
|
+
);
|
|
1310
|
+
break;
|
|
1311
|
+
case "max":
|
|
1312
|
+
w(
|
|
1313
|
+
n,
|
|
1314
|
+
"maximum",
|
|
1315
|
+
a.value,
|
|
1316
|
+
// This is in milliseconds
|
|
1317
|
+
a.message,
|
|
1318
|
+
t
|
|
1319
|
+
);
|
|
1320
|
+
break;
|
|
1321
|
+
}
|
|
1322
|
+
return n;
|
|
1323
|
+
};
|
|
1324
|
+
function Vn(e, t) {
|
|
1325
|
+
return {
|
|
1326
|
+
...b(e.innerType._def, t),
|
|
1327
|
+
default: e.defaultValue()
|
|
1328
|
+
};
|
|
1329
|
+
}
|
|
1330
|
+
function Jn(e, t, n) {
|
|
1331
|
+
return t.effectStrategy === "input" ? b(e.schema._def, t, n) : {};
|
|
1332
|
+
}
|
|
1333
|
+
function Yn(e) {
|
|
1334
|
+
return {
|
|
1335
|
+
type: "string",
|
|
1336
|
+
enum: [...e.values]
|
|
1337
|
+
};
|
|
1338
|
+
}
|
|
1339
|
+
const Gn = (e) => "type" in e && e.type === "string" ? !1 : "allOf" in e;
|
|
1340
|
+
function Qn(e, t) {
|
|
1341
|
+
const n = [
|
|
1342
|
+
b(e.left._def, {
|
|
1343
|
+
...t,
|
|
1344
|
+
currentPath: [...t.currentPath, "allOf", "0"]
|
|
1345
|
+
}),
|
|
1346
|
+
b(e.right._def, {
|
|
1347
|
+
...t,
|
|
1348
|
+
currentPath: [...t.currentPath, "allOf", "1"]
|
|
1349
|
+
})
|
|
1350
|
+
].filter((i) => !!i);
|
|
1351
|
+
let a = t.target === "jsonSchema2019-09" ? { unevaluatedProperties: !1 } : void 0;
|
|
1352
|
+
const r = [];
|
|
1353
|
+
return n.forEach((i) => {
|
|
1354
|
+
if (Gn(i))
|
|
1355
|
+
r.push(...i.allOf), i.unevaluatedProperties === void 0 && (a = void 0);
|
|
1356
|
+
else {
|
|
1357
|
+
let s = i;
|
|
1358
|
+
if ("additionalProperties" in i && i.additionalProperties === !1) {
|
|
1359
|
+
const { additionalProperties: l, ...c } = i;
|
|
1360
|
+
s = c;
|
|
1361
|
+
} else
|
|
1362
|
+
a = void 0;
|
|
1363
|
+
r.push(s);
|
|
1364
|
+
}
|
|
1365
|
+
}), r.length ? {
|
|
1366
|
+
allOf: r,
|
|
1367
|
+
...a
|
|
1368
|
+
} : void 0;
|
|
1369
|
+
}
|
|
1370
|
+
function Xn(e, t) {
|
|
1371
|
+
const n = typeof e.value;
|
|
1372
|
+
return n !== "bigint" && n !== "number" && n !== "boolean" && n !== "string" ? {
|
|
1373
|
+
type: Array.isArray(e.value) ? "array" : "object"
|
|
1374
|
+
} : t.target === "openApi3" ? {
|
|
1375
|
+
type: n === "bigint" ? "integer" : n,
|
|
1376
|
+
enum: [e.value]
|
|
1377
|
+
} : {
|
|
1378
|
+
type: n === "bigint" ? "integer" : n,
|
|
1379
|
+
const: e.value
|
|
1380
|
+
};
|
|
1381
|
+
}
|
|
1382
|
+
let oe;
|
|
1383
|
+
const Z = {
|
|
1384
|
+
/**
|
|
1385
|
+
* `c` was changed to `[cC]` to replicate /i flag
|
|
1386
|
+
*/
|
|
1387
|
+
cuid: /^[cC][^\s-]{8,}$/,
|
|
1388
|
+
cuid2: /^[0-9a-z]+$/,
|
|
1389
|
+
ulid: /^[0-9A-HJKMNP-TV-Z]{26}$/,
|
|
1390
|
+
/**
|
|
1391
|
+
* `a-z` was added to replicate /i flag
|
|
1392
|
+
*/
|
|
1393
|
+
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,
|
|
1394
|
+
/**
|
|
1395
|
+
* Constructed a valid Unicode RegExp
|
|
1396
|
+
*
|
|
1397
|
+
* Lazily instantiate since this type of regex isn't supported
|
|
1398
|
+
* in all envs (e.g. React Native).
|
|
1399
|
+
*
|
|
1400
|
+
* See:
|
|
1401
|
+
* https://github.com/colinhacks/zod/issues/2433
|
|
1402
|
+
* Fix in Zod:
|
|
1403
|
+
* https://github.com/colinhacks/zod/commit/9340fd51e48576a75adc919bff65dbc4a5d4c99b
|
|
1404
|
+
*/
|
|
1405
|
+
emoji: () => (oe === void 0 && (oe = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u")), oe),
|
|
1406
|
+
base64: /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,
|
|
1407
|
+
nanoid: /^[a-zA-Z0-9_-]{21}$/
|
|
1408
|
+
};
|
|
1409
|
+
function Ve(e, t) {
|
|
1410
|
+
const n = {
|
|
1411
|
+
type: "string"
|
|
1412
|
+
};
|
|
1413
|
+
function a(r) {
|
|
1414
|
+
return t.patternStrategy === "escape" ? Kn(r) : r;
|
|
1415
|
+
}
|
|
1416
|
+
if (e.checks)
|
|
1417
|
+
for (const r of e.checks)
|
|
1418
|
+
switch (r.kind) {
|
|
1419
|
+
case "min":
|
|
1420
|
+
w(n, "minLength", typeof n.minLength == "number" ? Math.max(n.minLength, r.value) : r.value, r.message, t);
|
|
1421
|
+
break;
|
|
1422
|
+
case "max":
|
|
1423
|
+
w(n, "maxLength", typeof n.maxLength == "number" ? Math.min(n.maxLength, r.value) : r.value, r.message, t);
|
|
1424
|
+
break;
|
|
1425
|
+
case "email":
|
|
1426
|
+
switch (t.emailStrategy) {
|
|
1427
|
+
case "format:email":
|
|
1428
|
+
$(n, "email", r.message, t);
|
|
1429
|
+
break;
|
|
1430
|
+
case "format:idn-email":
|
|
1431
|
+
$(n, "idn-email", r.message, t);
|
|
1432
|
+
break;
|
|
1433
|
+
case "pattern:zod":
|
|
1434
|
+
T(n, Z.email, r.message, t);
|
|
1435
|
+
break;
|
|
1436
|
+
}
|
|
1437
|
+
break;
|
|
1438
|
+
case "url":
|
|
1439
|
+
$(n, "uri", r.message, t);
|
|
1440
|
+
break;
|
|
1441
|
+
case "uuid":
|
|
1442
|
+
$(n, "uuid", r.message, t);
|
|
1443
|
+
break;
|
|
1444
|
+
case "regex":
|
|
1445
|
+
T(n, r.regex, r.message, t);
|
|
1446
|
+
break;
|
|
1447
|
+
case "cuid":
|
|
1448
|
+
T(n, Z.cuid, r.message, t);
|
|
1449
|
+
break;
|
|
1450
|
+
case "cuid2":
|
|
1451
|
+
T(n, Z.cuid2, r.message, t);
|
|
1452
|
+
break;
|
|
1453
|
+
case "startsWith":
|
|
1454
|
+
T(n, RegExp(`^${a(r.value)}`), r.message, t);
|
|
1455
|
+
break;
|
|
1456
|
+
case "endsWith":
|
|
1457
|
+
T(n, RegExp(`${a(r.value)}$`), r.message, t);
|
|
1458
|
+
break;
|
|
1459
|
+
case "datetime":
|
|
1460
|
+
$(n, "date-time", r.message, t);
|
|
1461
|
+
break;
|
|
1462
|
+
case "date":
|
|
1463
|
+
$(n, "date", r.message, t);
|
|
1464
|
+
break;
|
|
1465
|
+
case "time":
|
|
1466
|
+
$(n, "time", r.message, t);
|
|
1467
|
+
break;
|
|
1468
|
+
case "duration":
|
|
1469
|
+
$(n, "duration", r.message, t);
|
|
1470
|
+
break;
|
|
1471
|
+
case "length":
|
|
1472
|
+
w(n, "minLength", typeof n.minLength == "number" ? Math.max(n.minLength, r.value) : r.value, r.message, t), w(n, "maxLength", typeof n.maxLength == "number" ? Math.min(n.maxLength, r.value) : r.value, r.message, t);
|
|
1473
|
+
break;
|
|
1474
|
+
case "includes": {
|
|
1475
|
+
T(n, RegExp(a(r.value)), r.message, t);
|
|
1476
|
+
break;
|
|
1477
|
+
}
|
|
1478
|
+
case "ip": {
|
|
1479
|
+
r.version !== "v6" && $(n, "ipv4", r.message, t), r.version !== "v4" && $(n, "ipv6", r.message, t);
|
|
1480
|
+
break;
|
|
1481
|
+
}
|
|
1482
|
+
case "emoji":
|
|
1483
|
+
T(n, Z.emoji, r.message, t);
|
|
1484
|
+
break;
|
|
1485
|
+
case "ulid": {
|
|
1486
|
+
T(n, Z.ulid, r.message, t);
|
|
1487
|
+
break;
|
|
1488
|
+
}
|
|
1489
|
+
case "base64": {
|
|
1490
|
+
switch (t.base64Strategy) {
|
|
1491
|
+
case "format:binary": {
|
|
1492
|
+
$(n, "binary", r.message, t);
|
|
1493
|
+
break;
|
|
1494
|
+
}
|
|
1495
|
+
case "contentEncoding:base64": {
|
|
1496
|
+
w(n, "contentEncoding", "base64", r.message, t);
|
|
1497
|
+
break;
|
|
1498
|
+
}
|
|
1499
|
+
case "pattern:zod": {
|
|
1500
|
+
T(n, Z.base64, r.message, t);
|
|
1501
|
+
break;
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
break;
|
|
1505
|
+
}
|
|
1506
|
+
case "nanoid":
|
|
1507
|
+
T(n, Z.nanoid, r.message, t);
|
|
1508
|
+
}
|
|
1509
|
+
return n;
|
|
1510
|
+
}
|
|
1511
|
+
const Kn = (e) => Array.from(e).map((t) => /[a-zA-Z0-9]/.test(t) ? t : `\\${t}`).join(""), $ = (e, t, n, a) => {
|
|
1512
|
+
var r;
|
|
1513
|
+
e.format || (r = e.anyOf) != null && r.some((i) => i.format) ? (e.anyOf || (e.anyOf = []), e.format && (e.anyOf.push({
|
|
1514
|
+
format: e.format,
|
|
1515
|
+
...e.errorMessage && a.errorMessages && {
|
|
1516
|
+
errorMessage: { format: e.errorMessage.format }
|
|
1517
|
+
}
|
|
1518
|
+
}), delete e.format, e.errorMessage && (delete e.errorMessage.format, Object.keys(e.errorMessage).length === 0 && delete e.errorMessage)), e.anyOf.push({
|
|
1519
|
+
format: t,
|
|
1520
|
+
...n && a.errorMessages && { errorMessage: { format: n } }
|
|
1521
|
+
})) : w(e, "format", t, n, a);
|
|
1522
|
+
}, T = (e, t, n, a) => {
|
|
1523
|
+
var r;
|
|
1524
|
+
e.pattern || (r = e.allOf) != null && r.some((i) => i.pattern) ? (e.allOf || (e.allOf = []), e.pattern && (e.allOf.push({
|
|
1525
|
+
pattern: e.pattern,
|
|
1526
|
+
...e.errorMessage && a.errorMessages && {
|
|
1527
|
+
errorMessage: { pattern: e.errorMessage.pattern }
|
|
1528
|
+
}
|
|
1529
|
+
}), delete e.pattern, e.errorMessage && (delete e.errorMessage.pattern, Object.keys(e.errorMessage).length === 0 && delete e.errorMessage)), e.allOf.push({
|
|
1530
|
+
pattern: De(t, a),
|
|
1531
|
+
...n && a.errorMessages && { errorMessage: { pattern: n } }
|
|
1532
|
+
})) : w(e, "pattern", De(t, a), n, a);
|
|
1533
|
+
}, De = (e, t) => {
|
|
1534
|
+
var u;
|
|
1535
|
+
const n = typeof e == "function" ? e() : e;
|
|
1536
|
+
if (!t.applyRegexFlags || !n.flags)
|
|
1537
|
+
return n.source;
|
|
1538
|
+
const a = {
|
|
1539
|
+
i: n.flags.includes("i"),
|
|
1540
|
+
m: n.flags.includes("m"),
|
|
1541
|
+
s: n.flags.includes("s")
|
|
1542
|
+
// `.` matches newlines
|
|
1543
|
+
}, r = a.i ? n.source.toLowerCase() : n.source;
|
|
1544
|
+
let i = "", s = !1, l = !1, c = !1;
|
|
1545
|
+
for (let d = 0; d < r.length; d++) {
|
|
1546
|
+
if (s) {
|
|
1547
|
+
i += r[d], s = !1;
|
|
1548
|
+
continue;
|
|
1549
|
+
}
|
|
1550
|
+
if (a.i) {
|
|
1551
|
+
if (l) {
|
|
1552
|
+
if (r[d].match(/[a-z]/)) {
|
|
1553
|
+
c ? (i += r[d], i += `${r[d - 2]}-${r[d]}`.toUpperCase(), c = !1) : r[d + 1] === "-" && ((u = r[d + 2]) != null && u.match(/[a-z]/)) ? (i += r[d], c = !0) : i += `${r[d]}${r[d].toUpperCase()}`;
|
|
1554
|
+
continue;
|
|
1555
|
+
}
|
|
1556
|
+
} else if (r[d].match(/[a-z]/)) {
|
|
1557
|
+
i += `[${r[d]}${r[d].toUpperCase()}]`;
|
|
1558
|
+
continue;
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
if (a.m) {
|
|
1562
|
+
if (r[d] === "^") {
|
|
1563
|
+
i += `(^|(?<=[\r
|
|
1564
|
+
]))`;
|
|
1565
|
+
continue;
|
|
1566
|
+
} else if (r[d] === "$") {
|
|
1567
|
+
i += `($|(?=[\r
|
|
1568
|
+
]))`;
|
|
1569
|
+
continue;
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
if (a.s && r[d] === ".") {
|
|
1573
|
+
i += l ? `${r[d]}\r
|
|
1574
|
+
` : `[${r[d]}\r
|
|
1575
|
+
]`;
|
|
1576
|
+
continue;
|
|
1577
|
+
}
|
|
1578
|
+
i += r[d], r[d] === "\\" ? s = !0 : l && r[d] === "]" ? l = !1 : !l && r[d] === "[" && (l = !0);
|
|
1579
|
+
}
|
|
1580
|
+
try {
|
|
1581
|
+
const d = new RegExp(i);
|
|
1582
|
+
} catch {
|
|
1583
|
+
return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`), n.source;
|
|
1584
|
+
}
|
|
1585
|
+
return i;
|
|
1586
|
+
};
|
|
1587
|
+
function Je(e, t) {
|
|
1588
|
+
var a, r, i, s;
|
|
1589
|
+
if (t.target === "openApi3" && ((a = e.keyType) == null ? void 0 : a._def.typeName) === g.ZodEnum)
|
|
1590
|
+
return {
|
|
1591
|
+
type: "object",
|
|
1592
|
+
required: e.keyType._def.values,
|
|
1593
|
+
properties: e.keyType._def.values.reduce((l, c) => ({
|
|
1594
|
+
...l,
|
|
1595
|
+
[c]: b(e.valueType._def, {
|
|
1596
|
+
...t,
|
|
1597
|
+
currentPath: [...t.currentPath, "properties", c]
|
|
1598
|
+
}) ?? {}
|
|
1599
|
+
}), {}),
|
|
1600
|
+
additionalProperties: !1
|
|
1601
|
+
};
|
|
1602
|
+
const n = {
|
|
1603
|
+
type: "object",
|
|
1604
|
+
additionalProperties: b(e.valueType._def, {
|
|
1605
|
+
...t,
|
|
1606
|
+
currentPath: [...t.currentPath, "additionalProperties"]
|
|
1607
|
+
}) ?? {}
|
|
1608
|
+
};
|
|
1609
|
+
if (t.target === "openApi3")
|
|
1610
|
+
return n;
|
|
1611
|
+
if (((r = e.keyType) == null ? void 0 : r._def.typeName) === g.ZodString && ((i = e.keyType._def.checks) != null && i.length)) {
|
|
1612
|
+
const l = Object.entries(Ve(e.keyType._def, t)).reduce((c, [u, d]) => u === "type" ? c : { ...c, [u]: d }, {});
|
|
1613
|
+
return {
|
|
1614
|
+
...n,
|
|
1615
|
+
propertyNames: l
|
|
1616
|
+
};
|
|
1617
|
+
} else if (((s = e.keyType) == null ? void 0 : s._def.typeName) === g.ZodEnum)
|
|
1618
|
+
return {
|
|
1619
|
+
...n,
|
|
1620
|
+
propertyNames: {
|
|
1621
|
+
enum: e.keyType._def.values
|
|
1622
|
+
}
|
|
1623
|
+
};
|
|
1624
|
+
return n;
|
|
1625
|
+
}
|
|
1626
|
+
function ea(e, t) {
|
|
1627
|
+
if (t.mapStrategy === "record")
|
|
1628
|
+
return Je(e, t);
|
|
1629
|
+
const n = b(e.keyType._def, {
|
|
1630
|
+
...t,
|
|
1631
|
+
currentPath: [...t.currentPath, "items", "items", "0"]
|
|
1632
|
+
}) || {}, a = b(e.valueType._def, {
|
|
1633
|
+
...t,
|
|
1634
|
+
currentPath: [...t.currentPath, "items", "items", "1"]
|
|
1635
|
+
}) || {};
|
|
1636
|
+
return {
|
|
1637
|
+
type: "array",
|
|
1638
|
+
maxItems: 125,
|
|
1639
|
+
items: {
|
|
1640
|
+
type: "array",
|
|
1641
|
+
items: [n, a],
|
|
1642
|
+
minItems: 2,
|
|
1643
|
+
maxItems: 2
|
|
1644
|
+
}
|
|
1645
|
+
};
|
|
1646
|
+
}
|
|
1647
|
+
function ta(e) {
|
|
1648
|
+
const t = e.values, a = Object.keys(e.values).filter((i) => typeof t[t[i]] != "number").map((i) => t[i]), r = Array.from(new Set(a.map((i) => typeof i)));
|
|
1649
|
+
return {
|
|
1650
|
+
type: r.length === 1 ? r[0] === "string" ? "string" : "number" : ["string", "number"],
|
|
1651
|
+
enum: a
|
|
1652
|
+
};
|
|
1653
|
+
}
|
|
1654
|
+
function na() {
|
|
1655
|
+
return {
|
|
1656
|
+
not: {}
|
|
1657
|
+
};
|
|
1658
|
+
}
|
|
1659
|
+
function aa(e) {
|
|
1660
|
+
return e.target === "openApi3" ? {
|
|
1661
|
+
enum: ["null"],
|
|
1662
|
+
nullable: !0
|
|
1663
|
+
} : {
|
|
1664
|
+
type: "null"
|
|
1665
|
+
};
|
|
1666
|
+
}
|
|
1667
|
+
const K = {
|
|
1668
|
+
ZodString: "string",
|
|
1669
|
+
ZodNumber: "number",
|
|
1670
|
+
ZodBigInt: "integer",
|
|
1671
|
+
ZodBoolean: "boolean",
|
|
1672
|
+
ZodNull: "null"
|
|
1673
|
+
};
|
|
1674
|
+
function ra(e, t) {
|
|
1675
|
+
if (t.target === "openApi3")
|
|
1676
|
+
return _e(e, t);
|
|
1677
|
+
const n = e.options instanceof Map ? Array.from(e.options.values()) : e.options;
|
|
1678
|
+
if (n.every((a) => a._def.typeName in K && (!a._def.checks || !a._def.checks.length))) {
|
|
1679
|
+
const a = n.reduce((r, i) => {
|
|
1680
|
+
const s = K[i._def.typeName];
|
|
1681
|
+
return s && !r.includes(s) ? [...r, s] : r;
|
|
1682
|
+
}, []);
|
|
1683
|
+
return {
|
|
1684
|
+
type: a.length > 1 ? a : a[0]
|
|
1685
|
+
};
|
|
1686
|
+
} else if (n.every((a) => a._def.typeName === "ZodLiteral" && !a.description)) {
|
|
1687
|
+
const a = n.reduce((r, i) => {
|
|
1688
|
+
const s = typeof i._def.value;
|
|
1689
|
+
switch (s) {
|
|
1690
|
+
case "string":
|
|
1691
|
+
case "number":
|
|
1692
|
+
case "boolean":
|
|
1693
|
+
return [...r, s];
|
|
1694
|
+
case "bigint":
|
|
1695
|
+
return [...r, "integer"];
|
|
1696
|
+
case "object":
|
|
1697
|
+
if (i._def.value === null)
|
|
1698
|
+
return [...r, "null"];
|
|
1699
|
+
case "symbol":
|
|
1700
|
+
case "undefined":
|
|
1701
|
+
case "function":
|
|
1702
|
+
default:
|
|
1703
|
+
return r;
|
|
1704
|
+
}
|
|
1705
|
+
}, []);
|
|
1706
|
+
if (a.length === n.length) {
|
|
1707
|
+
const r = a.filter((i, s, l) => l.indexOf(i) === s);
|
|
1708
|
+
return {
|
|
1709
|
+
type: r.length > 1 ? r : r[0],
|
|
1710
|
+
enum: n.reduce((i, s) => i.includes(s._def.value) ? i : [...i, s._def.value], [])
|
|
1711
|
+
};
|
|
1712
|
+
}
|
|
1713
|
+
} else if (n.every((a) => a._def.typeName === "ZodEnum"))
|
|
1714
|
+
return {
|
|
1715
|
+
type: "string",
|
|
1716
|
+
enum: n.reduce((a, r) => [...a, ...r._def.values.filter((i) => !a.includes(i))], [])
|
|
1717
|
+
};
|
|
1718
|
+
return _e(e, t);
|
|
1719
|
+
}
|
|
1720
|
+
const _e = (e, t) => {
|
|
1721
|
+
const n = (e.options instanceof Map ? Array.from(e.options.values()) : e.options).map((a, r) => b(a._def, {
|
|
1722
|
+
...t,
|
|
1723
|
+
currentPath: [...t.currentPath, "anyOf", `${r}`]
|
|
1724
|
+
})).filter((a) => !!a && (!t.strictUnions || typeof a == "object" && Object.keys(a).length > 0));
|
|
1725
|
+
return n.length ? { anyOf: n } : void 0;
|
|
1726
|
+
};
|
|
1727
|
+
function oa(e, t) {
|
|
1728
|
+
if (["ZodString", "ZodNumber", "ZodBigInt", "ZodBoolean", "ZodNull"].includes(e.innerType._def.typeName) && (!e.innerType._def.checks || !e.innerType._def.checks.length))
|
|
1729
|
+
return t.target === "openApi3" || t.nullableStrategy === "property" ? {
|
|
1730
|
+
type: K[e.innerType._def.typeName],
|
|
1731
|
+
nullable: !0
|
|
1732
|
+
} : {
|
|
1733
|
+
type: [K[e.innerType._def.typeName], "null"]
|
|
1734
|
+
};
|
|
1735
|
+
if (t.target === "openApi3") {
|
|
1736
|
+
const a = b(e.innerType._def, {
|
|
1737
|
+
...t,
|
|
1738
|
+
currentPath: [...t.currentPath]
|
|
1739
|
+
});
|
|
1740
|
+
return a && "$ref" in a ? { allOf: [a], nullable: !0 } : a && { ...a, nullable: !0 };
|
|
1741
|
+
}
|
|
1742
|
+
const n = b(e.innerType._def, {
|
|
1743
|
+
...t,
|
|
1744
|
+
currentPath: [...t.currentPath, "anyOf", "0"]
|
|
1745
|
+
});
|
|
1746
|
+
return n && { anyOf: [n, { type: "null" }] };
|
|
1747
|
+
}
|
|
1748
|
+
function ia(e, t) {
|
|
1749
|
+
const n = {
|
|
1750
|
+
type: "number"
|
|
1751
|
+
};
|
|
1752
|
+
if (!e.checks)
|
|
1753
|
+
return n;
|
|
1754
|
+
for (const a of e.checks)
|
|
1755
|
+
switch (a.kind) {
|
|
1756
|
+
case "int":
|
|
1757
|
+
n.type = "integer", We(n, "type", a.message, t);
|
|
1758
|
+
break;
|
|
1759
|
+
case "min":
|
|
1760
|
+
t.target === "jsonSchema7" ? a.inclusive ? w(n, "minimum", a.value, a.message, t) : w(n, "exclusiveMinimum", a.value, a.message, t) : (a.inclusive || (n.exclusiveMinimum = !0), w(n, "minimum", a.value, a.message, t));
|
|
1761
|
+
break;
|
|
1762
|
+
case "max":
|
|
1763
|
+
t.target === "jsonSchema7" ? a.inclusive ? w(n, "maximum", a.value, a.message, t) : w(n, "exclusiveMaximum", a.value, a.message, t) : (a.inclusive || (n.exclusiveMaximum = !0), w(n, "maximum", a.value, a.message, t));
|
|
1764
|
+
break;
|
|
1765
|
+
case "multipleOf":
|
|
1766
|
+
w(n, "multipleOf", a.value, a.message, t);
|
|
1767
|
+
break;
|
|
1768
|
+
}
|
|
1769
|
+
return n;
|
|
1770
|
+
}
|
|
1771
|
+
function sa(e, t) {
|
|
1772
|
+
return t.removeAdditionalStrategy === "strict" ? e.catchall._def.typeName === "ZodNever" ? e.unknownKeys !== "strict" : b(e.catchall._def, {
|
|
1773
|
+
...t,
|
|
1774
|
+
currentPath: [...t.currentPath, "additionalProperties"]
|
|
1775
|
+
}) ?? !0 : e.catchall._def.typeName === "ZodNever" ? e.unknownKeys === "passthrough" : b(e.catchall._def, {
|
|
1776
|
+
...t,
|
|
1777
|
+
currentPath: [...t.currentPath, "additionalProperties"]
|
|
1778
|
+
}) ?? !0;
|
|
1779
|
+
}
|
|
1780
|
+
function la(e, t) {
|
|
1781
|
+
const n = {
|
|
1782
|
+
type: "object",
|
|
1783
|
+
...Object.entries(e.shape()).reduce((a, [r, i]) => {
|
|
1784
|
+
if (i === void 0 || i._def === void 0)
|
|
1785
|
+
return a;
|
|
1786
|
+
const s = [...t.currentPath, "properties", r], l = b(i._def, {
|
|
1787
|
+
...t,
|
|
1788
|
+
currentPath: s,
|
|
1789
|
+
propertyPath: s
|
|
1790
|
+
});
|
|
1791
|
+
return l === void 0 ? a : (t.openaiStrictMode && i.isOptional() && !i.isNullable() && console.warn(`Zod field at \`${s.join("/")}\` uses \`.optional()\` without \`.nullable()\` which is not supported by the API. See: https://platform.openai.com/docs/guides/structured-outputs?api-mode=responses#all-fields-must-be-required
|
|
1792
|
+
This will become an error in a future version of the SDK.`), {
|
|
1793
|
+
properties: {
|
|
1794
|
+
...a.properties,
|
|
1795
|
+
[r]: l
|
|
1796
|
+
},
|
|
1797
|
+
required: i.isOptional() && !t.openaiStrictMode ? a.required : [...a.required, r]
|
|
1798
|
+
});
|
|
1799
|
+
}, { properties: {}, required: [] }),
|
|
1800
|
+
additionalProperties: sa(e, t)
|
|
1801
|
+
};
|
|
1802
|
+
return n.required.length || delete n.required, n;
|
|
1803
|
+
}
|
|
1804
|
+
const ca = (e, t) => {
|
|
1805
|
+
var a;
|
|
1806
|
+
if (t.currentPath.toString() === ((a = t.propertyPath) == null ? void 0 : a.toString()))
|
|
1807
|
+
return b(e.innerType._def, t);
|
|
1808
|
+
const n = b(e.innerType._def, {
|
|
1809
|
+
...t,
|
|
1810
|
+
currentPath: [...t.currentPath, "anyOf", "1"]
|
|
1811
|
+
});
|
|
1812
|
+
return n ? {
|
|
1813
|
+
anyOf: [
|
|
1814
|
+
{
|
|
1815
|
+
not: {}
|
|
1816
|
+
},
|
|
1817
|
+
n
|
|
1818
|
+
]
|
|
1819
|
+
} : {};
|
|
1820
|
+
}, ua = (e, t) => {
|
|
1821
|
+
if (t.pipeStrategy === "input")
|
|
1822
|
+
return b(e.in._def, t);
|
|
1823
|
+
if (t.pipeStrategy === "output")
|
|
1824
|
+
return b(e.out._def, t);
|
|
1825
|
+
const n = b(e.in._def, {
|
|
1826
|
+
...t,
|
|
1827
|
+
currentPath: [...t.currentPath, "allOf", "0"]
|
|
1828
|
+
}), a = b(e.out._def, {
|
|
1829
|
+
...t,
|
|
1830
|
+
currentPath: [...t.currentPath, "allOf", n ? "1" : "0"]
|
|
1831
|
+
});
|
|
1832
|
+
return {
|
|
1833
|
+
allOf: [n, a].filter((r) => r !== void 0)
|
|
1834
|
+
};
|
|
1835
|
+
};
|
|
1836
|
+
function da(e, t) {
|
|
1837
|
+
return b(e.type._def, t);
|
|
1838
|
+
}
|
|
1839
|
+
function pa(e, t) {
|
|
1840
|
+
const a = {
|
|
1841
|
+
type: "array",
|
|
1842
|
+
uniqueItems: !0,
|
|
1843
|
+
items: b(e.valueType._def, {
|
|
1844
|
+
...t,
|
|
1845
|
+
currentPath: [...t.currentPath, "items"]
|
|
1846
|
+
})
|
|
1847
|
+
};
|
|
1848
|
+
return e.minSize && w(a, "minItems", e.minSize.value, e.minSize.message, t), e.maxSize && w(a, "maxItems", e.maxSize.value, e.maxSize.message, t), a;
|
|
1849
|
+
}
|
|
1850
|
+
function ma(e, t) {
|
|
1851
|
+
return e.rest ? {
|
|
1852
|
+
type: "array",
|
|
1853
|
+
minItems: e.items.length,
|
|
1854
|
+
items: e.items.map((n, a) => b(n._def, {
|
|
1855
|
+
...t,
|
|
1856
|
+
currentPath: [...t.currentPath, "items", `${a}`]
|
|
1857
|
+
})).reduce((n, a) => a === void 0 ? n : [...n, a], []),
|
|
1858
|
+
additionalItems: b(e.rest._def, {
|
|
1859
|
+
...t,
|
|
1860
|
+
currentPath: [...t.currentPath, "additionalItems"]
|
|
1861
|
+
})
|
|
1862
|
+
} : {
|
|
1863
|
+
type: "array",
|
|
1864
|
+
minItems: e.items.length,
|
|
1865
|
+
maxItems: e.items.length,
|
|
1866
|
+
items: e.items.map((n, a) => b(n._def, {
|
|
1867
|
+
...t,
|
|
1868
|
+
currentPath: [...t.currentPath, "items", `${a}`]
|
|
1869
|
+
})).reduce((n, a) => a === void 0 ? n : [...n, a], [])
|
|
1870
|
+
};
|
|
1871
|
+
}
|
|
1872
|
+
function ha() {
|
|
1873
|
+
return {
|
|
1874
|
+
not: {}
|
|
1875
|
+
};
|
|
1876
|
+
}
|
|
1877
|
+
function ga() {
|
|
1878
|
+
return {};
|
|
1879
|
+
}
|
|
1880
|
+
const fa = (e, t) => b(e.innerType._def, t);
|
|
1881
|
+
function b(e, t, n = !1) {
|
|
1882
|
+
var s;
|
|
1883
|
+
const a = t.seen.get(e);
|
|
1884
|
+
if (t.override) {
|
|
1885
|
+
const l = (s = t.override) == null ? void 0 : s.call(t, e, t, a, n);
|
|
1886
|
+
if (l !== Zn)
|
|
1887
|
+
return l;
|
|
1888
|
+
}
|
|
1889
|
+
if (a && !n) {
|
|
1890
|
+
const l = ba(a, t);
|
|
1891
|
+
if (l !== void 0)
|
|
1892
|
+
return "$ref" in l && t.seenRefs.add(l.$ref), l;
|
|
1893
|
+
}
|
|
1894
|
+
const r = { def: e, path: t.currentPath, jsonSchema: void 0 };
|
|
1895
|
+
t.seen.set(e, r);
|
|
1896
|
+
const i = va(e, e.typeName, t, n);
|
|
1897
|
+
return i && wa(e, t, i), r.jsonSchema = i, i;
|
|
1898
|
+
}
|
|
1899
|
+
const ba = (e, t) => {
|
|
1900
|
+
switch (t.$refStrategy) {
|
|
1901
|
+
case "root":
|
|
1902
|
+
return { $ref: e.path.join("/") };
|
|
1903
|
+
case "extract-to-root":
|
|
1904
|
+
const n = e.path.slice(t.basePath.length + 1).join("_");
|
|
1905
|
+
return n !== t.name && t.nameStrategy === "duplicate-ref" && (t.definitions[n] = e.def), { $ref: [...t.basePath, t.definitionPath, n].join("/") };
|
|
1906
|
+
case "relative":
|
|
1907
|
+
return { $ref: ya(t.currentPath, e.path) };
|
|
1908
|
+
case "none":
|
|
1909
|
+
case "seen":
|
|
1910
|
+
return e.path.length < t.currentPath.length && e.path.every((a, r) => t.currentPath[r] === a) ? (console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`), {}) : t.$refStrategy === "seen" ? {} : void 0;
|
|
1911
|
+
}
|
|
1912
|
+
}, ya = (e, t) => {
|
|
1913
|
+
let n = 0;
|
|
1914
|
+
for (; n < e.length && n < t.length && e[n] === t[n]; n++)
|
|
1915
|
+
;
|
|
1916
|
+
return [(e.length - n).toString(), ...t.slice(n)].join("/");
|
|
1917
|
+
}, va = (e, t, n, a) => {
|
|
1918
|
+
switch (t) {
|
|
1919
|
+
case g.ZodString:
|
|
1920
|
+
return Ve(e, n);
|
|
1921
|
+
case g.ZodNumber:
|
|
1922
|
+
return ia(e, n);
|
|
1923
|
+
case g.ZodObject:
|
|
1924
|
+
return la(e, n);
|
|
1925
|
+
case g.ZodBigInt:
|
|
1926
|
+
return Un(e, n);
|
|
1927
|
+
case g.ZodBoolean:
|
|
1928
|
+
return Fn();
|
|
1929
|
+
case g.ZodDate:
|
|
1930
|
+
return He(e, n);
|
|
1931
|
+
case g.ZodUndefined:
|
|
1932
|
+
return ha();
|
|
1933
|
+
case g.ZodNull:
|
|
1934
|
+
return aa(n);
|
|
1935
|
+
case g.ZodArray:
|
|
1936
|
+
return Bn(e, n);
|
|
1937
|
+
case g.ZodUnion:
|
|
1938
|
+
case g.ZodDiscriminatedUnion:
|
|
1939
|
+
return ra(e, n);
|
|
1940
|
+
case g.ZodIntersection:
|
|
1941
|
+
return Qn(e, n);
|
|
1942
|
+
case g.ZodTuple:
|
|
1943
|
+
return ma(e, n);
|
|
1944
|
+
case g.ZodRecord:
|
|
1945
|
+
return Je(e, n);
|
|
1946
|
+
case g.ZodLiteral:
|
|
1947
|
+
return Xn(e, n);
|
|
1948
|
+
case g.ZodEnum:
|
|
1949
|
+
return Yn(e);
|
|
1950
|
+
case g.ZodNativeEnum:
|
|
1951
|
+
return ta(e);
|
|
1952
|
+
case g.ZodNullable:
|
|
1953
|
+
return oa(e, n);
|
|
1954
|
+
case g.ZodOptional:
|
|
1955
|
+
return ca(e, n);
|
|
1956
|
+
case g.ZodMap:
|
|
1957
|
+
return ea(e, n);
|
|
1958
|
+
case g.ZodSet:
|
|
1959
|
+
return pa(e, n);
|
|
1960
|
+
case g.ZodLazy:
|
|
1961
|
+
return b(e.getter()._def, n);
|
|
1962
|
+
case g.ZodPromise:
|
|
1963
|
+
return da(e, n);
|
|
1964
|
+
case g.ZodNaN:
|
|
1965
|
+
case g.ZodNever:
|
|
1966
|
+
return na();
|
|
1967
|
+
case g.ZodEffects:
|
|
1968
|
+
return Jn(e, n, a);
|
|
1969
|
+
case g.ZodAny:
|
|
1970
|
+
return zn();
|
|
1971
|
+
case g.ZodUnknown:
|
|
1972
|
+
return ga();
|
|
1973
|
+
case g.ZodDefault:
|
|
1974
|
+
return Vn(e, n);
|
|
1975
|
+
case g.ZodBranded:
|
|
1976
|
+
return qn(e, n);
|
|
1977
|
+
case g.ZodReadonly:
|
|
1978
|
+
return fa(e, n);
|
|
1979
|
+
case g.ZodCatch:
|
|
1980
|
+
return Wn(e, n);
|
|
1981
|
+
case g.ZodPipeline:
|
|
1982
|
+
return ua(e, n);
|
|
1983
|
+
case g.ZodFunction:
|
|
1984
|
+
case g.ZodVoid:
|
|
1985
|
+
case g.ZodSymbol:
|
|
1986
|
+
return;
|
|
1987
|
+
default:
|
|
1988
|
+
return /* @__PURE__ */ ((r) => {
|
|
1989
|
+
})();
|
|
1990
|
+
}
|
|
1991
|
+
}, wa = (e, t, n) => (e.description && (n.description = e.description, t.markdownDescription && (n.markdownDescription = e.description)), n), Sa = (e, t) => {
|
|
1992
|
+
const n = Rn(t), a = typeof t == "string" ? t : (t == null ? void 0 : t.nameStrategy) === "title" || t == null ? void 0 : t.name, r = b(e._def, a === void 0 ? n : {
|
|
1993
|
+
...n,
|
|
1994
|
+
currentPath: [...n.basePath, n.definitionPath, a]
|
|
1995
|
+
}, !1) ?? {}, i = typeof t == "object" && t.name !== void 0 && t.nameStrategy === "title" ? t.name : void 0;
|
|
1996
|
+
i !== void 0 && (r.title = i);
|
|
1997
|
+
const s = (() => {
|
|
1998
|
+
if (Ln(n.definitions))
|
|
1999
|
+
return;
|
|
2000
|
+
const c = {}, u = /* @__PURE__ */ new Set();
|
|
2001
|
+
for (let d = 0; d < 500; d++) {
|
|
2002
|
+
const m = Object.entries(n.definitions).filter(([p]) => !u.has(p));
|
|
2003
|
+
if (m.length === 0)
|
|
2004
|
+
break;
|
|
2005
|
+
for (const [p, O] of m)
|
|
2006
|
+
c[p] = b(ce(O), { ...n, currentPath: [...n.basePath, n.definitionPath, p] }, !0) ?? {}, u.add(p);
|
|
2007
|
+
}
|
|
2008
|
+
return c;
|
|
2009
|
+
})(), l = a === void 0 ? s ? {
|
|
2010
|
+
...r,
|
|
2011
|
+
[n.definitionPath]: s
|
|
2012
|
+
} : r : n.nameStrategy === "duplicate-ref" ? {
|
|
2013
|
+
...r,
|
|
2014
|
+
...s || n.seenRefs.size ? {
|
|
2015
|
+
[n.definitionPath]: {
|
|
2016
|
+
...s,
|
|
2017
|
+
// only actually duplicate the schema definition if it was ever referenced
|
|
2018
|
+
// otherwise the duplication is completely pointless
|
|
2019
|
+
...n.seenRefs.size ? { [a]: r } : void 0
|
|
2020
|
+
}
|
|
2021
|
+
} : void 0
|
|
2022
|
+
} : {
|
|
2023
|
+
$ref: [...n.$refStrategy === "relative" ? [] : n.basePath, n.definitionPath, a].join("/"),
|
|
2024
|
+
[n.definitionPath]: {
|
|
2025
|
+
...s,
|
|
2026
|
+
[a]: r
|
|
2027
|
+
}
|
|
2028
|
+
};
|
|
2029
|
+
return n.target === "jsonSchema7" ? l.$schema = "http://json-schema.org/draft-07/schema#" : n.target === "jsonSchema2019-09" && (l.$schema = "https://json-schema.org/draft/2019-09/schema#"), l;
|
|
2030
|
+
};
|
|
2031
|
+
function Oa(e, t) {
|
|
2032
|
+
return Sa(e, {
|
|
2033
|
+
openaiStrictMode: !0,
|
|
2034
|
+
name: t.name,
|
|
2035
|
+
nameStrategy: "duplicate-ref",
|
|
2036
|
+
$refStrategy: "extract-to-root",
|
|
2037
|
+
nullableStrategy: "property"
|
|
2038
|
+
});
|
|
2039
|
+
}
|
|
2040
|
+
function Ca(e, t, n) {
|
|
2041
|
+
return Nn({
|
|
2042
|
+
type: "json_schema",
|
|
2043
|
+
json_schema: {
|
|
2044
|
+
...n,
|
|
2045
|
+
name: t,
|
|
2046
|
+
strict: !0,
|
|
2047
|
+
schema: Oa(e, { name: t })
|
|
2048
|
+
}
|
|
2049
|
+
}, (a) => e.parse(JSON.parse(a)));
|
|
2050
|
+
}
|
|
2051
|
+
function he(e) {
|
|
2052
|
+
return e.endsWith("/") ? e : `${e}/`;
|
|
2053
|
+
}
|
|
2054
|
+
const _o = (e) => {
|
|
2055
|
+
if (e instanceof Error)
|
|
2056
|
+
try {
|
|
2057
|
+
return JSON.parse(e.message);
|
|
2058
|
+
} catch {
|
|
2059
|
+
return e.message;
|
|
2060
|
+
}
|
|
2061
|
+
return e;
|
|
2062
|
+
};
|
|
2063
|
+
function Da() {
|
|
2064
|
+
try {
|
|
2065
|
+
const e = window.location.host, {
|
|
2066
|
+
tenant: { tenantDomainNames: t, name: n }
|
|
2067
|
+
} = window.App.user;
|
|
2068
|
+
return e && t && t.some((i) => i.includes(e)) || n === "system" ? "" : `/${n}`;
|
|
2069
|
+
} catch (e) {
|
|
2070
|
+
return console.debug("no tenant prefix", e), "";
|
|
2071
|
+
}
|
|
2072
|
+
}
|
|
2073
|
+
function Ye(e, t) {
|
|
2074
|
+
let n = Da();
|
|
2075
|
+
n.startsWith("/") && (n = n.slice(1));
|
|
2076
|
+
const a = new ft(
|
|
2077
|
+
`${he(e)}${n}`,
|
|
2078
|
+
t,
|
|
2079
|
+
"sdk-ai-core-0.2.11"
|
|
2080
|
+
);
|
|
2081
|
+
return a.login(), a;
|
|
2082
|
+
}
|
|
2083
|
+
function _a(e) {
|
|
2084
|
+
const t = bt(e);
|
|
2085
|
+
if (!t)
|
|
2086
|
+
throw new Error("Invalid authentication method");
|
|
2087
|
+
return Ye(e.url, t);
|
|
2088
|
+
}
|
|
2089
|
+
function Pa(e) {
|
|
2090
|
+
return async (t, n) => {
|
|
2091
|
+
if (!t.toString().includes("chat/completions"))
|
|
2092
|
+
throw new Error("Use httpClient for non-completion requests");
|
|
2093
|
+
const a = new Headers(), r = e.auth.type === "bearer";
|
|
2094
|
+
n != null && n.headers && new Headers(n.headers).forEach((l, c) => {
|
|
2095
|
+
!c.toLowerCase().startsWith("x-") && (r || c.toLowerCase() !== "authorization") && a.set(c, l);
|
|
2096
|
+
}), e.auth.applyHeaders(a);
|
|
2097
|
+
const i = { ...n || {}, headers: a };
|
|
2098
|
+
return fetch(t, i);
|
|
2099
|
+
};
|
|
2100
|
+
}
|
|
2101
|
+
const Aa = "api/v2/ai";
|
|
2102
|
+
function xa(e, t) {
|
|
2103
|
+
return new yt({
|
|
2104
|
+
// @ts-expect-error - OpenAI client requires apiKey but we're using custom auth
|
|
2105
|
+
apiKey: null,
|
|
2106
|
+
dangerouslyAllowBrowser: !0,
|
|
2107
|
+
baseURL: e,
|
|
2108
|
+
fetch: t
|
|
2109
|
+
});
|
|
2110
|
+
}
|
|
2111
|
+
function Ge(e) {
|
|
2112
|
+
const t = he(e.url) + Aa;
|
|
2113
|
+
return xa(t, Pa(e));
|
|
2114
|
+
}
|
|
2115
|
+
let ue = null;
|
|
2116
|
+
function Qe(e) {
|
|
2117
|
+
ue = e;
|
|
2118
|
+
}
|
|
2119
|
+
function f() {
|
|
2120
|
+
if (!ue)
|
|
2121
|
+
throw new Error(
|
|
2122
|
+
"HttpClient not initialized. Create one using createHttpClient() and then initialize it using initializeHttpClient()."
|
|
2123
|
+
);
|
|
2124
|
+
return ue;
|
|
2125
|
+
}
|
|
2126
|
+
function Po() {
|
|
2127
|
+
const e = f(), t = e.url, n = e.auth, a = Ye(t, n);
|
|
2128
|
+
Qe(a);
|
|
2129
|
+
}
|
|
2130
|
+
let de = null;
|
|
2131
|
+
function Xe(e) {
|
|
2132
|
+
de = e;
|
|
2133
|
+
}
|
|
2134
|
+
function Ke() {
|
|
2135
|
+
if (!de)
|
|
2136
|
+
throw new Error(
|
|
2137
|
+
"OpenAI client not initialized. Create one using createOpenAIClient() and then initialize it using initializeOpenAIClient()."
|
|
2138
|
+
);
|
|
2139
|
+
return de;
|
|
2140
|
+
}
|
|
2141
|
+
function Ao() {
|
|
2142
|
+
const e = Ge(f());
|
|
2143
|
+
Xe(e);
|
|
2144
|
+
}
|
|
2145
|
+
function xo(e) {
|
|
2146
|
+
const t = _a(e);
|
|
2147
|
+
Qe(t);
|
|
2148
|
+
const n = Ge(t);
|
|
2149
|
+
Xe(n);
|
|
2150
|
+
}
|
|
2151
|
+
async function ge(e) {
|
|
2152
|
+
const {
|
|
2153
|
+
systemPrompt: t,
|
|
2154
|
+
userPrompt: n,
|
|
2155
|
+
responseFormat: a,
|
|
2156
|
+
model: r = "gpt-4o-mini",
|
|
2157
|
+
temperature: i = 0,
|
|
2158
|
+
sessionId: s,
|
|
2159
|
+
openAIClient: l = Ke()
|
|
2160
|
+
} = e, c = a.type === "json_schema" ? Ca(a.schema, a.name) : { type: "json_object" }, d = (await l.beta.chat.completions.parse({
|
|
2161
|
+
model: r,
|
|
2162
|
+
messages: [
|
|
2163
|
+
{ role: "system", content: t },
|
|
2164
|
+
{ role: "user", content: n }
|
|
2165
|
+
],
|
|
2166
|
+
response_format: c,
|
|
2167
|
+
tools: [],
|
|
2168
|
+
tool_choice: "none",
|
|
2169
|
+
temperature: i,
|
|
2170
|
+
metadata: s ? { refSessionId: s } : void 0
|
|
2171
|
+
})).choices[0].message;
|
|
2172
|
+
if (a.type === "json_schema") {
|
|
2173
|
+
if (d.tool_calls && d.tool_calls.length > 0) {
|
|
2174
|
+
const p = d.tool_calls[0];
|
|
2175
|
+
if (p.function && p.function.arguments)
|
|
2176
|
+
return JSON.parse(p.function.arguments);
|
|
2177
|
+
}
|
|
2178
|
+
const m = d.parsed;
|
|
2179
|
+
if (!m)
|
|
2180
|
+
throw new Error("No valid response from AI");
|
|
2181
|
+
return m;
|
|
2182
|
+
} else {
|
|
2183
|
+
const m = d.content || "{}", p = JSON.parse(m);
|
|
2184
|
+
if (!p)
|
|
2185
|
+
throw new Error("No valid response from AI");
|
|
2186
|
+
return p;
|
|
2187
|
+
}
|
|
2188
|
+
}
|
|
2189
|
+
async function $a(e) {
|
|
2190
|
+
const {
|
|
2191
|
+
systemPrompt: t,
|
|
2192
|
+
userPrompt: n,
|
|
2193
|
+
tools: a,
|
|
2194
|
+
model: r = "gpt-4o-mini",
|
|
2195
|
+
temperature: i = 0,
|
|
2196
|
+
toolChoice: s = "auto",
|
|
2197
|
+
openAIClient: l = Ke()
|
|
2198
|
+
} = e;
|
|
2199
|
+
return new Promise((c) => {
|
|
2200
|
+
const u = [], d = [];
|
|
2201
|
+
l.beta.chat.completions.runTools({
|
|
2202
|
+
messages: [
|
|
2203
|
+
{
|
|
2204
|
+
role: "system",
|
|
2205
|
+
content: t
|
|
2206
|
+
},
|
|
2207
|
+
{
|
|
2208
|
+
role: "user",
|
|
2209
|
+
content: [
|
|
2210
|
+
{
|
|
2211
|
+
type: "text",
|
|
2212
|
+
text: n
|
|
2213
|
+
}
|
|
2214
|
+
]
|
|
2215
|
+
}
|
|
2216
|
+
],
|
|
2217
|
+
model: r,
|
|
2218
|
+
stream: !0,
|
|
2219
|
+
temperature: i,
|
|
2220
|
+
tools: a,
|
|
2221
|
+
tool_choice: s
|
|
2222
|
+
}).on("message", (m) => {
|
|
2223
|
+
m.role === "tool" ? u.push(m) : m.role === "assistant" && m.content && d.push(m.content);
|
|
2224
|
+
}).on("end", () => {
|
|
2225
|
+
let m = !1, p = "";
|
|
2226
|
+
try {
|
|
2227
|
+
const O = u.map(
|
|
2228
|
+
(N) => JSON.parse(N.content).message
|
|
2229
|
+
).join(`
|
|
2230
|
+
`), C = d.join(`
|
|
2231
|
+
`);
|
|
2232
|
+
u.length === 0 && d.length > 0 ? (m = !0, p = C) : u.length === 0 && d.length === 0 ? (m = !0, p = "No tools executed and no response from LLM") : (p = [
|
|
2233
|
+
O,
|
|
2234
|
+
C
|
|
2235
|
+
].filter(Boolean).join(`
|
|
2236
|
+
`), p.trim() === "" && (m = !0, p = "Tools executed but returned empty results"));
|
|
2237
|
+
} catch {
|
|
2238
|
+
m = !0, p = "Malformed tool response detected";
|
|
2239
|
+
}
|
|
2240
|
+
c({
|
|
2241
|
+
toolMessages: u,
|
|
2242
|
+
assistantMessages: d,
|
|
2243
|
+
combinedMessage: p,
|
|
2244
|
+
isError: m
|
|
2245
|
+
});
|
|
2246
|
+
}).on("error", (m) => {
|
|
2247
|
+
const p = m instanceof Error ? JSON.stringify(
|
|
2248
|
+
{
|
|
2249
|
+
name: m.name,
|
|
2250
|
+
message: m.message,
|
|
2251
|
+
stack: m.stack
|
|
2252
|
+
},
|
|
2253
|
+
null,
|
|
2254
|
+
2
|
|
2255
|
+
) : JSON.stringify(m, null, 2);
|
|
2256
|
+
c({
|
|
2257
|
+
toolMessages: [],
|
|
2258
|
+
assistantMessages: [],
|
|
2259
|
+
combinedMessage: p,
|
|
2260
|
+
isError: !0
|
|
2261
|
+
});
|
|
2262
|
+
});
|
|
2263
|
+
});
|
|
2264
|
+
}
|
|
2265
|
+
const Ta = `
|
|
2266
|
+
You are an expert in chart visualization and data query structuring. Your task is to assist users in generating the optimal chart type and axes mapping based on their input, adhering to the provided schema (schema object with chartType and axesMapping). Your goal is to interpret the user's prompt, analyze the provided column data, select an appropriate chart type (unless specified by the user), and map column indices to the axes mapping arrays in a way that produces a valid, effective visualization.
|
|
2267
|
+
|
|
2268
|
+
DO NOT use any tools.
|
|
2269
|
+
|
|
2270
|
+
### Input Expectations
|
|
2271
|
+
- **User Prompt**: A natural language description of the desired visualization (e.g., "Show sales over time by region" or "Compare product prices").
|
|
2272
|
+
- **Column Data**: A list of columns adhering to the Column interface (e.g., { id: 0, name: "Sales", type: "number" } ), representing available data fields.
|
|
2273
|
+
- If the user provides only a prompt without column data, assume a reasonable set of columns based on the prompt and state your assumptions.
|
|
2274
|
+
|
|
2275
|
+
### Chart Selection Process
|
|
2276
|
+
1. If the user specifies a chart type, use it and proceed to axes mapping.
|
|
2277
|
+
2. Otherwise, determine the best chart type by:
|
|
2278
|
+
- Analyzing the data types of columns (e.g., numeric, categorical, temporal, geographic).
|
|
2279
|
+
- Identifying relationships in the prompt (e.g., trends over time, comparisons, distributions).
|
|
2280
|
+
- Matching to a suitable chart type from chartTypes (e.g., bar for comparisons, line for trends, pie for proportions).
|
|
2281
|
+
- Default to bar for categorical-numeric pairs if no clear choice emerges.
|
|
2282
|
+
3. Ensure the selected chart type aligns with the corresponding axesMapping schema (e.g., cartesianChartSchema for bar).
|
|
2283
|
+
|
|
2284
|
+
### Axes Mapping Guidelines
|
|
2285
|
+
- Map column indices (from id in Column) to the appropriate arrays in the axesMapping object (e.g., category, value, x, y).
|
|
2286
|
+
- Prioritize essential fields first:
|
|
2287
|
+
- For cartesian charts: Fill category (e.g., time, names) and value (e.g., numbers) before optional fields like breakBy.
|
|
2288
|
+
- For scatter charts: Fill x and y before breakByPoint or size.
|
|
2289
|
+
- For categorical charts: Fill category and value.
|
|
2290
|
+
- Columns can appear in multiple arrays only if logical (e.g., a category used in both category and breakBy for stacked bars).
|
|
2291
|
+
- Respect schema constraints (e.g., z.strict() means no extra fields; required arrays like value must be non-empty).
|
|
2292
|
+
|
|
2293
|
+
### Edge Cases
|
|
2294
|
+
- If insufficient columns are provided, suggest additional columns needed (e.g., "A time column is required for a line chart").
|
|
2295
|
+
- If the user-specified chart type conflicts with data (e.g., pie with continuous data), recommend an alternative and explain why.
|
|
2296
|
+
- If a column's role is ambiguous, infer based on type (e.g., string → category, number → value) and prompt context.
|
|
2297
|
+
|
|
2298
|
+
### Output Format
|
|
2299
|
+
Return a JSON object matching the schema structure, with:
|
|
2300
|
+
- chartType: The selected or user-specified chart type.
|
|
2301
|
+
- axesMapping: The populated axes mapping object per the relevant schema.
|
|
2302
|
+
Provide a brief explanation of your chart type choice and axes mapping decisions, referencing the prompt and column data.
|
|
2303
|
+
`;
|
|
2304
|
+
function ja(e, t) {
|
|
2305
|
+
return e ? e.map((n) => ({
|
|
2306
|
+
column: t[n]
|
|
2307
|
+
})).filter(({ column: n }) => !!n) : [];
|
|
2308
|
+
}
|
|
2309
|
+
function ka(e, t) {
|
|
2310
|
+
if (!e) return e;
|
|
2311
|
+
const n = e.axesMapping, a = {
|
|
2312
|
+
chartType: e.chartType,
|
|
2313
|
+
axesMapping: {}
|
|
2314
|
+
};
|
|
2315
|
+
for (const [r, i] of Object.entries(n))
|
|
2316
|
+
r !== "type" && (Array.isArray(i) ? a.axesMapping[r] = ja(i, t) : a.axesMapping[r] = i);
|
|
2317
|
+
return a;
|
|
2318
|
+
}
|
|
2319
|
+
const et = async (e, t = [], n) => {
|
|
2320
|
+
var c;
|
|
2321
|
+
const a = [];
|
|
2322
|
+
let r = 0;
|
|
2323
|
+
for (const u of t) {
|
|
2324
|
+
const d = "column" in u ? (c = u.column) == null ? void 0 : c.name : u.name, m = (() => {
|
|
2325
|
+
if ("column" in u && u.column && "type" in u.column)
|
|
2326
|
+
return u.column.type;
|
|
2327
|
+
if ("type" in u && typeof u.type == "string")
|
|
2328
|
+
return u.type;
|
|
2329
|
+
})();
|
|
2330
|
+
a.push({ id: r++, name: d, type: m });
|
|
2331
|
+
}
|
|
2332
|
+
let i = e + `
|
|
2333
|
+
|
|
2334
|
+
${JSON.stringify(a)}`;
|
|
2335
|
+
n && (i += `
|
|
2336
|
+
User selected the following chart type: ${n}
|
|
2337
|
+
|
|
2338
|
+
`);
|
|
2339
|
+
const s = await ge({
|
|
2340
|
+
systemPrompt: Ta,
|
|
2341
|
+
userPrompt: i,
|
|
2342
|
+
responseFormat: {
|
|
2343
|
+
type: "json_schema",
|
|
2344
|
+
schema: Dn,
|
|
2345
|
+
name: "chartRecommendations"
|
|
2346
|
+
}
|
|
2347
|
+
}), l = ka(
|
|
2348
|
+
s,
|
|
2349
|
+
t
|
|
2350
|
+
);
|
|
2351
|
+
switch (l.chartType) {
|
|
2352
|
+
case "scatter":
|
|
2353
|
+
l.axesMapping.x = l.axesMapping.x[0], l.axesMapping.y = l.axesMapping.y[0], l.axesMapping.breakByPoint = l.axesMapping.breakByPoint[0], l.axesMapping.breakByColor = l.axesMapping.breakByColor[0], l.axesMapping.size = l.axesMapping.size[0];
|
|
2354
|
+
break;
|
|
2355
|
+
case "indicator":
|
|
2356
|
+
l.axesMapping.secondary = [];
|
|
2357
|
+
break;
|
|
2358
|
+
}
|
|
2359
|
+
return l;
|
|
2360
|
+
};
|
|
2361
|
+
async function $o(e, t) {
|
|
2362
|
+
return await f().post(
|
|
2363
|
+
`api/v2/ai/nlq/query/${e}`,
|
|
2364
|
+
t
|
|
2365
|
+
) ?? null;
|
|
2366
|
+
}
|
|
2367
|
+
async function Ea(e, t) {
|
|
2368
|
+
return await f().post(
|
|
2369
|
+
`api/v2/ai/nlq/query-light/${e}`,
|
|
2370
|
+
t
|
|
2371
|
+
) ?? null;
|
|
2372
|
+
}
|
|
2373
|
+
async function Ma(e, t) {
|
|
2374
|
+
return await f().post(
|
|
2375
|
+
`api/v2/ai/nlq/smartQuery/${e}`,
|
|
2376
|
+
t
|
|
2377
|
+
) ?? null;
|
|
2378
|
+
}
|
|
2379
|
+
async function To(e, t) {
|
|
2380
|
+
return await f().get(
|
|
2381
|
+
`api/v2/ai/recommendations/query/${e}/${t.numOfRecommendations}`
|
|
2382
|
+
) ?? null;
|
|
2383
|
+
}
|
|
2384
|
+
async function jo(e, t) {
|
|
2385
|
+
return await f().get(
|
|
2386
|
+
`api/v2/ai/recommendations/query-light/${e}/${t.numOfRecommendations}${t.userPrompt ? `?userPrompt=${t.userPrompt}` : ""}`
|
|
2387
|
+
) ?? null;
|
|
2388
|
+
}
|
|
2389
|
+
const Na = async (e, t) => {
|
|
2390
|
+
const n = await Ea(e, {
|
|
2391
|
+
text: t,
|
|
2392
|
+
timezone: "UTC"
|
|
2393
|
+
});
|
|
2394
|
+
if (!n)
|
|
2395
|
+
throw new Error(
|
|
2396
|
+
"Error: Failed to get NLQ result. Ask the user to specify the data source again."
|
|
2397
|
+
);
|
|
2398
|
+
const a = gt.toWidgetProps(
|
|
2399
|
+
{ ...n, chartRecommendations: {} },
|
|
2400
|
+
{
|
|
2401
|
+
useCustomizedStyleOptions: !0
|
|
2402
|
+
}
|
|
2403
|
+
);
|
|
2404
|
+
if (!a)
|
|
2405
|
+
throw new Error("Error: Failed to generate widget props");
|
|
2406
|
+
if (a.nlqResponse = n, !Ee(a))
|
|
2407
|
+
throw new Error("Error: Non-chart widget props not supported yet");
|
|
2408
|
+
return a.title = a.title || n.nlqPrompt || t, a;
|
|
2409
|
+
}, Za = async (e, t) => {
|
|
2410
|
+
const n = await Ma(e, {
|
|
2411
|
+
text: t,
|
|
2412
|
+
forceGeneration: !0
|
|
2413
|
+
});
|
|
2414
|
+
if (!n)
|
|
2415
|
+
throw new Error("Error: Failed to get NLQ result.");
|
|
2416
|
+
const a = n.dataSchema;
|
|
2417
|
+
if (!a)
|
|
2418
|
+
throw new Error("Error: Data schema not found");
|
|
2419
|
+
const r = mt({
|
|
2420
|
+
data: n.chartState,
|
|
2421
|
+
context: a
|
|
2422
|
+
});
|
|
2423
|
+
if (!r.success)
|
|
2424
|
+
throw new Error(
|
|
2425
|
+
"Error: Failed to translate query JSON: " + JSON.stringify(r.errors)
|
|
2426
|
+
);
|
|
2427
|
+
const i = r.data, s = ht(
|
|
2428
|
+
i,
|
|
2429
|
+
Me(a.dataSource)
|
|
2430
|
+
), l = [
|
|
2431
|
+
...i.dimensions || [],
|
|
2432
|
+
...i.measures || []
|
|
2433
|
+
];
|
|
2434
|
+
return {
|
|
2435
|
+
title: t,
|
|
2436
|
+
id: me(),
|
|
2437
|
+
widgetType: "chart",
|
|
2438
|
+
dataSource: i.dataSource,
|
|
2439
|
+
chartType: "table",
|
|
2440
|
+
dataOptions: { columns: l },
|
|
2441
|
+
filters: i.filters || [],
|
|
2442
|
+
highlights: i.highlights || [],
|
|
2443
|
+
nlqResponse: {
|
|
2444
|
+
chartRecommendations: {},
|
|
2445
|
+
detailedDescription: t,
|
|
2446
|
+
nlqPrompt: t,
|
|
2447
|
+
userMsg: t,
|
|
2448
|
+
queryTitle: t,
|
|
2449
|
+
jaql: s
|
|
2450
|
+
}
|
|
2451
|
+
};
|
|
2452
|
+
}, Ia = async (e, t, n) => n ? (console.debug("Generating chart table from NLQ V3"), Za(e, t)) : (console.debug("Generating chart table from NLQ V2"), Na(e, t)), La = async ({ dataSourceTitle: e, userPrompt: t, chartType: n, chartTitle: a }, r) => {
|
|
2453
|
+
const i = await Ia(
|
|
2454
|
+
e,
|
|
2455
|
+
t,
|
|
2456
|
+
r.isNlqV3Enabled ?? !1
|
|
2457
|
+
), s = i.dataOptions.columns, l = await et(
|
|
2458
|
+
t,
|
|
2459
|
+
s,
|
|
2460
|
+
n
|
|
2461
|
+
);
|
|
2462
|
+
i.nlqResponse.chartRecommendations = l || i.nlqResponse.chartRecommendations;
|
|
2463
|
+
const { axesMapping: c, chartType: u } = l;
|
|
2464
|
+
i.dataOptions = c, i.chartType = u, i.title = a;
|
|
2465
|
+
const d = ke(
|
|
2466
|
+
u,
|
|
2467
|
+
i.dataOptions,
|
|
2468
|
+
{},
|
|
2469
|
+
!0
|
|
2470
|
+
);
|
|
2471
|
+
return i.styleOptions = {
|
|
2472
|
+
...d,
|
|
2473
|
+
..."legend" in d ? { legend: { enabled: !0, position: "bottom" } } : {}
|
|
2474
|
+
}, {
|
|
2475
|
+
...i,
|
|
2476
|
+
artifactId: me(),
|
|
2477
|
+
dataColumns: s
|
|
2478
|
+
};
|
|
2479
|
+
}, Ra = async ({ userPrompt: e, chartType: t, chartTitle: n }, a) => {
|
|
2480
|
+
var l;
|
|
2481
|
+
console.debug("toolCall", "createChart", e, t, n);
|
|
2482
|
+
const r = a.dataSourceTitle;
|
|
2483
|
+
if (!r)
|
|
2484
|
+
throw new Error(
|
|
2485
|
+
"Error: Please ask the user to specify a data source title"
|
|
2486
|
+
);
|
|
2487
|
+
const i = a.toolCallId, s = await La(
|
|
2488
|
+
{
|
|
2489
|
+
dataSourceTitle: r,
|
|
2490
|
+
userPrompt: e,
|
|
2491
|
+
chartType: t,
|
|
2492
|
+
chartTitle: n
|
|
2493
|
+
},
|
|
2494
|
+
a
|
|
2495
|
+
);
|
|
2496
|
+
return (l = a.saveChart) == null || l.call(a, i, s), {
|
|
2497
|
+
message: `New chart (chartId: ${i}) created successfully`
|
|
2498
|
+
};
|
|
2499
|
+
}, za = ({
|
|
2500
|
+
chartTitle: e,
|
|
2501
|
+
chartWidgetProps: t
|
|
2502
|
+
}) => ({
|
|
2503
|
+
...t,
|
|
2504
|
+
title: e
|
|
2505
|
+
}), Ba = async ({ chartId: e, chartTitle: t }, n) => {
|
|
2506
|
+
var i, s;
|
|
2507
|
+
console.debug("toolCall", "updateChartTitle", e, t);
|
|
2508
|
+
const a = (i = n.retrieveChart) == null ? void 0 : i.call(n, e);
|
|
2509
|
+
if (!a)
|
|
2510
|
+
throw new Error("Chart not found");
|
|
2511
|
+
const r = za({
|
|
2512
|
+
chartTitle: t,
|
|
2513
|
+
chartWidgetProps: a
|
|
2514
|
+
});
|
|
2515
|
+
return (s = n.saveChart) == null || s.call(n, e, r), {
|
|
2516
|
+
message: "Chart title updated successfully"
|
|
2517
|
+
};
|
|
2518
|
+
}, Ua = async ({
|
|
2519
|
+
userPrompt: e,
|
|
2520
|
+
chartType: t,
|
|
2521
|
+
chartWidgetProps: n
|
|
2522
|
+
}) => {
|
|
2523
|
+
const { dataColumns: a, styleOptions: r } = n, i = await et(
|
|
2524
|
+
e,
|
|
2525
|
+
a,
|
|
2526
|
+
t
|
|
2527
|
+
), { axesMapping: s, chartType: l } = i;
|
|
2528
|
+
n.dataOptions = s, n.chartType = l;
|
|
2529
|
+
const c = ke(
|
|
2530
|
+
l,
|
|
2531
|
+
n.dataOptions,
|
|
2532
|
+
{},
|
|
2533
|
+
!0
|
|
2534
|
+
), u = r ? {
|
|
2535
|
+
...c,
|
|
2536
|
+
// Preserve specific properties from existingStyleOptions
|
|
2537
|
+
..."legend" in r && "legend" in c ? { legend: r.legend } : {},
|
|
2538
|
+
..."labels" in r && "labels" in c ? { labels: r.labels } : {},
|
|
2539
|
+
..."xAxis" in r && "xAxis" in c ? { xAxis: r.xAxis } : {},
|
|
2540
|
+
..."yAxis" in r && "yAxis" in c ? { yAxis: r.yAxis } : {},
|
|
2541
|
+
..."y2Axis" in r && "y2Axis" in c ? { y2Axis: r.y2Axis } : {},
|
|
2542
|
+
..."dataLimits" in r && "dataLimits" in c ? { dataLimits: r.dataLimits } : {},
|
|
2543
|
+
..."markerSize" in r && "markerSize" in c ? { markerSize: r.markerSize } : {}
|
|
2544
|
+
} : c;
|
|
2545
|
+
return n.styleOptions = u, n;
|
|
2546
|
+
}, Fa = async ({ chartId: e, userPrompt: t, chartType: n }, a) => {
|
|
2547
|
+
var s, l;
|
|
2548
|
+
console.debug(
|
|
2549
|
+
"toolCall",
|
|
2550
|
+
"updateChartType",
|
|
2551
|
+
e,
|
|
2552
|
+
t,
|
|
2553
|
+
n
|
|
2554
|
+
);
|
|
2555
|
+
const r = (s = a.retrieveChart) == null ? void 0 : s.call(a, e);
|
|
2556
|
+
if (!r)
|
|
2557
|
+
throw new Error("Chart not found");
|
|
2558
|
+
const i = await Ua({
|
|
2559
|
+
userPrompt: t,
|
|
2560
|
+
chartType: n,
|
|
2561
|
+
chartWidgetProps: r
|
|
2562
|
+
});
|
|
2563
|
+
return (l = a.saveChart) == null || l.call(a, e, i), {
|
|
2564
|
+
message: "Chart type updated successfully"
|
|
2565
|
+
};
|
|
2566
|
+
}, qa = o.object({
|
|
2567
|
+
width: o.enum(["thin", "bold", "thick"])
|
|
2568
|
+
}), Wa = o.enum(["line/basic", "line/spline"]), j = o.object({
|
|
2569
|
+
enabled: o.boolean().optional().describe(
|
|
2570
|
+
"Boolean flag that defines if legend should be shown on the chart"
|
|
2571
|
+
),
|
|
2572
|
+
position: o.enum(["top", "left", "right", "bottom"]).optional().describe("Position of the legend")
|
|
2573
|
+
}).describe(
|
|
2574
|
+
"Options that define legend - a key that provides information about the data series or colors used in chart."
|
|
2575
|
+
).strict(), k = o.object({
|
|
2576
|
+
enabled: o.boolean().optional(),
|
|
2577
|
+
showValue: o.boolean().optional(),
|
|
2578
|
+
showPercentage: o.boolean().optional(),
|
|
2579
|
+
fontSize: o.string().optional()
|
|
2580
|
+
// color: z.string().optional(),
|
|
2581
|
+
}).strict(), fe = o.object({
|
|
2582
|
+
enabled: o.boolean().optional(),
|
|
2583
|
+
title: o.object({
|
|
2584
|
+
enabled: o.boolean().default(!0).optional(),
|
|
2585
|
+
text: o.string().optional()
|
|
2586
|
+
}).optional().describe("The title or name of the x-axis"),
|
|
2587
|
+
min: o.number().nullable().optional().describe("The minimum value of the x-axis"),
|
|
2588
|
+
max: o.number().nullable().optional().describe("The maximum value of the x-axis"),
|
|
2589
|
+
gridLines: o.boolean().optional().describe(
|
|
2590
|
+
"Boolean flag that defines if grid lines should be shown on the chart"
|
|
2591
|
+
),
|
|
2592
|
+
intervalJumps: o.number().optional().describe("Interval of the tick marks (jumps) in axis units."),
|
|
2593
|
+
isIntervalEnabled: o.boolean().optional().describe(
|
|
2594
|
+
"Boolean flag that defines if tick marks should be shown on the axis"
|
|
2595
|
+
),
|
|
2596
|
+
labels: o.object({
|
|
2597
|
+
enabled: o.boolean().optional(),
|
|
2598
|
+
showValue: o.boolean().optional(),
|
|
2599
|
+
showPercentage: o.boolean().optional()
|
|
2600
|
+
}).optional().describe("Configuration for labels on the axis"),
|
|
2601
|
+
logarithmic: o.boolean().optional().describe(
|
|
2602
|
+
"Boolean flag that defines if the axis should have logarithmic scale"
|
|
2603
|
+
),
|
|
2604
|
+
templateMainYHasGridLines: o.boolean().optional().describe(
|
|
2605
|
+
"Boolean flag that defines if the Y axis should have grid lines extending the ticks across the plot area"
|
|
2606
|
+
)
|
|
2607
|
+
}).strict(), U = fe.describe("X-axis configuration"), F = fe.describe("Y-axis configuration"), q = fe.describe("Y2-axis configuration"), V = o.object({
|
|
2608
|
+
enabled: o.boolean().optional().describe(
|
|
2609
|
+
"Boolean flag that defines if markers should be shown on the chart"
|
|
2610
|
+
),
|
|
2611
|
+
fill: o.enum(["filled", "hollow"]).optional().describe("Marker fill style"),
|
|
2612
|
+
size: o.enum(["small", "medium", "large"]).optional().describe("Size of markers")
|
|
2613
|
+
}).describe(
|
|
2614
|
+
"Options that define markers - symbols or data points that highlight specific values."
|
|
2615
|
+
).strict(), te = o.object({
|
|
2616
|
+
enabled: o.boolean().optional().describe(
|
|
2617
|
+
"Boolean flag that defines if navigator should be shown on the chart"
|
|
2618
|
+
),
|
|
2619
|
+
scrollerLocation: o.object({
|
|
2620
|
+
max: o.number().optional().describe("The maximum value of the navigator scroller"),
|
|
2621
|
+
min: o.number().optional().describe("The minimum value of the navigator scroller")
|
|
2622
|
+
}).optional().describe(
|
|
2623
|
+
"The scroll location of the navigator scroller / auto zoom feature"
|
|
2624
|
+
)
|
|
2625
|
+
}).describe(
|
|
2626
|
+
"Options that define navigator - zoom/pan tool for large datasets in a chart."
|
|
2627
|
+
).strict(), R = o.object({
|
|
2628
|
+
categoriesCapacity: o.number().optional().describe("Maximum number of categories to chart"),
|
|
2629
|
+
seriesCapacity: o.number().optional().describe("Maximum number of series to chart")
|
|
2630
|
+
}).describe(
|
|
2631
|
+
"Configuration that limits the series or categories that are charted."
|
|
2632
|
+
).strict(), Ha = o.object({
|
|
2633
|
+
lineWidth: qa.optional(),
|
|
2634
|
+
subtype: Wa.optional(),
|
|
2635
|
+
markers: V.optional(),
|
|
2636
|
+
navigator: te.optional(),
|
|
2637
|
+
dataLimits: R.optional(),
|
|
2638
|
+
legend: j.optional(),
|
|
2639
|
+
xAxis: U.optional(),
|
|
2640
|
+
yAxis: F.optional(),
|
|
2641
|
+
y2Axis: q.optional(),
|
|
2642
|
+
seriesLabels: k.optional()
|
|
2643
|
+
}).strict(), Pe = o.object({
|
|
2644
|
+
subtype: o.enum(["bar/classic", "bar/stacked", "bar/stacked100"]).optional(),
|
|
2645
|
+
markers: V.optional(),
|
|
2646
|
+
navigator: te.optional(),
|
|
2647
|
+
legend: j.optional(),
|
|
2648
|
+
xAxis: U.optional(),
|
|
2649
|
+
yAxis: F.optional(),
|
|
2650
|
+
y2Axis: q.optional(),
|
|
2651
|
+
seriesLabels: k.optional()
|
|
2652
|
+
}).strict(), Va = o.object({
|
|
2653
|
+
enabled: o.boolean().optional().describe(
|
|
2654
|
+
"Boolean flag that defines if convolution ability should be enabled on chart"
|
|
2655
|
+
),
|
|
2656
|
+
independentSlicesCount: o.number().optional().describe(
|
|
2657
|
+
"Number that defines of how many independent slices should be present in chart (other will be convolved)"
|
|
2658
|
+
),
|
|
2659
|
+
minimalIndependentSlicePercentage: o.number().optional().describe(
|
|
2660
|
+
"Value that defines what minimal size in percent should a slice take to fall under the convolution"
|
|
2661
|
+
),
|
|
2662
|
+
selectedConvolutionType: o.enum(["byPercentage", "bySlicesCount"]).optional().describe("Selected type of convolution behavior")
|
|
2663
|
+
}).describe(
|
|
2664
|
+
'Configuration that defines the ability of the Pie chart to collapse (convolve) and hide part of the data under the single category "Others".'
|
|
2665
|
+
).strict(), Ja = o.object({
|
|
2666
|
+
subtype: o.enum(["pie/basic", "pie/donut", "pie/ring"]).optional(),
|
|
2667
|
+
seriesLabels: k.optional(),
|
|
2668
|
+
legend: j.optional(),
|
|
2669
|
+
convolution: Va.optional()
|
|
2670
|
+
}).strict(), Ya = o.object({
|
|
2671
|
+
markers: V.optional(),
|
|
2672
|
+
dataLimits: R.optional(),
|
|
2673
|
+
markerSize: o.object({
|
|
2674
|
+
scatterBubbleMaxSize: o.number().optional().describe("Maximum size of markers"),
|
|
2675
|
+
scatterBubbleMinSize: o.number().optional().describe("Minimum size of markers"),
|
|
2676
|
+
scatterDefaultSize: o.number().optional().describe("Default size of markers")
|
|
2677
|
+
}).optional().describe("Size of markers"),
|
|
2678
|
+
legend: j.optional(),
|
|
2679
|
+
xAxis: U.optional(),
|
|
2680
|
+
yAxis: F.optional(),
|
|
2681
|
+
y2Axis: q.optional(),
|
|
2682
|
+
seriesLabels: k.optional()
|
|
2683
|
+
}).strict(), Ga = o.object({
|
|
2684
|
+
subtype: o.enum([
|
|
2685
|
+
"area/basic",
|
|
2686
|
+
"area/spline",
|
|
2687
|
+
"area/stacked",
|
|
2688
|
+
"area/stacked100",
|
|
2689
|
+
"area/stackedspline",
|
|
2690
|
+
"area/stackedspline100"
|
|
2691
|
+
]).optional(),
|
|
2692
|
+
opacity: o.number().optional(),
|
|
2693
|
+
navigator: te.optional(),
|
|
2694
|
+
legend: j.optional(),
|
|
2695
|
+
xAxis: U.optional(),
|
|
2696
|
+
yAxis: F.optional(),
|
|
2697
|
+
y2Axis: q.optional(),
|
|
2698
|
+
seriesLabels: k.optional()
|
|
2699
|
+
}).strict(), Qa = o.object({
|
|
2700
|
+
dataLimits: R.optional(),
|
|
2701
|
+
funnelDirection: o.enum(["inverted", "regular"]).optional().describe("Direction of FunnelChart narrowing"),
|
|
2702
|
+
funnelSize: o.enum(["narrow", "regular", "wide"]).optional().describe(
|
|
2703
|
+
"Visual size of the lowest slice (degree of funnel narrowing from highest to lowest slices)"
|
|
2704
|
+
),
|
|
2705
|
+
funnelType: o.enum(["pinched", "regular"]).optional().describe("Visual type of the lowest slice of FunnelChar"),
|
|
2706
|
+
subtype: o.enum(["funnel/basic", "funnel/pyramid"]).optional(),
|
|
2707
|
+
neckHeight: o.number().optional(),
|
|
2708
|
+
neckWidth: o.number().optional(),
|
|
2709
|
+
seriesLabels: k.optional(),
|
|
2710
|
+
legend: j.optional()
|
|
2711
|
+
}).strict(), Xa = o.object({
|
|
2712
|
+
dataLimits: R.optional(),
|
|
2713
|
+
layout: o.enum([
|
|
2714
|
+
"squarified",
|
|
2715
|
+
"stripes",
|
|
2716
|
+
"stripes-vertical",
|
|
2717
|
+
"stripes-horizontal"
|
|
2718
|
+
]).optional(),
|
|
2719
|
+
borderWidth: o.number().optional(),
|
|
2720
|
+
borderColor: o.string().optional(),
|
|
2721
|
+
seriesLabels: k.optional(),
|
|
2722
|
+
legend: j.optional(),
|
|
2723
|
+
tooltip: o.object({
|
|
2724
|
+
mode: o.enum(["contribution", "value"]).optional().describe("Define mode of data showing")
|
|
2725
|
+
})
|
|
2726
|
+
}).strict(), Ka = o.object({
|
|
2727
|
+
dataLimits: R.optional(),
|
|
2728
|
+
levels: o.number().optional(),
|
|
2729
|
+
borderWidth: o.number().optional(),
|
|
2730
|
+
borderColor: o.string().optional(),
|
|
2731
|
+
seriesLabels: k.optional(),
|
|
2732
|
+
legend: j.optional()
|
|
2733
|
+
}).strict(), er = o.object({
|
|
2734
|
+
dataLimits: R.optional(),
|
|
2735
|
+
subtype: o.enum(["boxplot/full", "boxplot/hollow"]).optional(),
|
|
2736
|
+
boxType: o.enum(["iqr", "extremums", "standardDeviation"]).optional(),
|
|
2737
|
+
outliersEnabled: o.boolean().optional(),
|
|
2738
|
+
width: o.number().optional(),
|
|
2739
|
+
legend: j.optional(),
|
|
2740
|
+
xAxis: U.optional(),
|
|
2741
|
+
yAxis: F.optional(),
|
|
2742
|
+
y2Axis: q.optional(),
|
|
2743
|
+
markers: V.optional(),
|
|
2744
|
+
seriesLabels: k.optional()
|
|
2745
|
+
}).strict(), tr = o.object({
|
|
2746
|
+
subtype: o.enum(["indicator/numeric", "indicator/gauge"]).optional(),
|
|
2747
|
+
value: o.number().optional(),
|
|
2748
|
+
min: o.number().optional(),
|
|
2749
|
+
max: o.number().optional(),
|
|
2750
|
+
thresholds: o.array(o.number()).optional(),
|
|
2751
|
+
seriesLabels: k.optional(),
|
|
2752
|
+
legend: j.optional(),
|
|
2753
|
+
forceTickerView: o.boolean().optional().describe(
|
|
2754
|
+
"Boolean flag to force render indicator in ticker mode regardless of display size"
|
|
2755
|
+
),
|
|
2756
|
+
skin: o.enum(["1", "2"]).optional().describe("Skin gauge indicator")
|
|
2757
|
+
}).strict(), nr = o.object({
|
|
2758
|
+
dataLimits: R.optional(),
|
|
2759
|
+
height: o.number().optional(),
|
|
2760
|
+
width: o.number().optional(),
|
|
2761
|
+
legend: j.optional(),
|
|
2762
|
+
markers: V.optional(),
|
|
2763
|
+
navigator: te.optional(),
|
|
2764
|
+
subtype: o.enum(["polar/area", "polar/column", "polar/line"]).optional(),
|
|
2765
|
+
xAxis: U.optional(),
|
|
2766
|
+
yAxis: F.optional(),
|
|
2767
|
+
y2Axis: q.optional(),
|
|
2768
|
+
seriesLabels: k.optional()
|
|
2769
|
+
}), tt = o.object({
|
|
2770
|
+
columns: o.object({
|
|
2771
|
+
alternatingColor: o.object({
|
|
2772
|
+
enabled: o.boolean().optional(),
|
|
2773
|
+
textColor: o.string().optional(),
|
|
2774
|
+
backgroundColor: o.string().optional()
|
|
2775
|
+
}).optional().describe("Alternating color for columns"),
|
|
2776
|
+
width: o.enum(["auto", "content"]).optional().describe("Width of columns")
|
|
2777
|
+
}).optional().describe("Configuration for columns"),
|
|
2778
|
+
header: o.object({
|
|
2779
|
+
color: o.object({
|
|
2780
|
+
enabled: o.boolean().optional(),
|
|
2781
|
+
textColor: o.string().optional(),
|
|
2782
|
+
backgroundColor: o.string().optional()
|
|
2783
|
+
}).optional().describe("Color of header")
|
|
2784
|
+
}).optional().describe("Configuration for header"),
|
|
2785
|
+
rows: o.object({
|
|
2786
|
+
alternatingColor: o.object({
|
|
2787
|
+
enabled: o.boolean().optional(),
|
|
2788
|
+
textColor: o.string().optional(),
|
|
2789
|
+
backgroundColor: o.string().optional()
|
|
2790
|
+
}).optional().describe("Alternating color for rows")
|
|
2791
|
+
}).optional().describe("Configuration for rows"),
|
|
2792
|
+
rowsPerPage: o.number().optional().describe("Number of rows per page"),
|
|
2793
|
+
paddingHorizontal: o.number().optional().describe("Horizontal padding around whole table"),
|
|
2794
|
+
paddingVertical: o.number().optional().describe("Vertical padding around whole table")
|
|
2795
|
+
}), nt = {
|
|
2796
|
+
line: Ha,
|
|
2797
|
+
bar: Pe,
|
|
2798
|
+
area: Ga,
|
|
2799
|
+
column: Pe,
|
|
2800
|
+
// Assuming column is similar to bar; adjust as needed
|
|
2801
|
+
pie: Ja,
|
|
2802
|
+
scatter: Ya,
|
|
2803
|
+
funnel: Qa,
|
|
2804
|
+
treemap: Xa,
|
|
2805
|
+
sunburst: Ka,
|
|
2806
|
+
boxplot: er,
|
|
2807
|
+
indicator: tr,
|
|
2808
|
+
polar: nr,
|
|
2809
|
+
table: tt,
|
|
2810
|
+
arearange: o.object({}),
|
|
2811
|
+
scattermap: o.object({}),
|
|
2812
|
+
areamap: o.object({}),
|
|
2813
|
+
"calendar-heatmap": o.object({}),
|
|
2814
|
+
streamgraph: o.object({})
|
|
2815
|
+
}, ar = o.object({
|
|
2816
|
+
chartType: ee
|
|
2817
|
+
});
|
|
2818
|
+
function rr(e) {
|
|
2819
|
+
const t = nt[e];
|
|
2820
|
+
if (!t)
|
|
2821
|
+
throw new Error(`Unsupported chart type: ${e}`);
|
|
2822
|
+
return ar.extend({
|
|
2823
|
+
styleOptions: t
|
|
2824
|
+
});
|
|
2825
|
+
}
|
|
2826
|
+
o.object({
|
|
2827
|
+
category: o.array(
|
|
2828
|
+
o.object({
|
|
2829
|
+
column: o.object({})
|
|
2830
|
+
})
|
|
2831
|
+
),
|
|
2832
|
+
value: o.array(
|
|
2833
|
+
o.object({
|
|
2834
|
+
column: o.object({})
|
|
2835
|
+
})
|
|
2836
|
+
)
|
|
2837
|
+
}), o.object({
|
|
2838
|
+
category: o.array(o.object({})),
|
|
2839
|
+
value: o.array(o.object({}))
|
|
2840
|
+
}), o.object({
|
|
2841
|
+
x: o.object({}),
|
|
2842
|
+
y: o.object({})
|
|
2843
|
+
}), o.object({}), o.object({}), o.object({}), o.object({});
|
|
2844
|
+
const Ae = o.object({
|
|
2845
|
+
name: o.string(),
|
|
2846
|
+
title: o.string()
|
|
2847
|
+
}), W = o.string().describe("hex color code for the measure.");
|
|
2848
|
+
o.object({
|
|
2849
|
+
color: W,
|
|
2850
|
+
type: o.enum(["uniform"]).describe("Type of color to be used for the measure.")
|
|
2851
|
+
}).describe(
|
|
2852
|
+
"Uniform color options for data similar to the Single Color option in the Sisense UI."
|
|
2853
|
+
);
|
|
2854
|
+
o.object({
|
|
2855
|
+
conditions: o.array(
|
|
2856
|
+
o.object({
|
|
2857
|
+
color: W,
|
|
2858
|
+
expression: o.string(),
|
|
2859
|
+
operator: o.enum(["<", ">", ">=", "<="])
|
|
2860
|
+
})
|
|
2861
|
+
).describe("Array of color conditions"),
|
|
2862
|
+
defaultColor: W.describe(
|
|
2863
|
+
"Default color when no condition is met"
|
|
2864
|
+
),
|
|
2865
|
+
type: o.enum(["conditional"]).describe("Color options type")
|
|
2866
|
+
}).describe(
|
|
2867
|
+
"Conditional color options for data similar to the Conditional Color option in the Sisense UI."
|
|
2868
|
+
);
|
|
2869
|
+
o.object({
|
|
2870
|
+
color: o.string().describe("hex color code for the measure.")
|
|
2871
|
+
});
|
|
2872
|
+
o.object({
|
|
2873
|
+
maxColor: W.describe(
|
|
2874
|
+
"End color of the range"
|
|
2875
|
+
).optional(),
|
|
2876
|
+
maxValue: o.number().describe(
|
|
2877
|
+
"Maximum value explicitly set to override the maximum value of the data"
|
|
2878
|
+
).optional(),
|
|
2879
|
+
midValue: o.number().describe(
|
|
2880
|
+
"Middle value explicitly set to override the middle value of the data"
|
|
2881
|
+
).optional(),
|
|
2882
|
+
minColor: W.describe(
|
|
2883
|
+
"Start color of the range"
|
|
2884
|
+
).optional(),
|
|
2885
|
+
minValue: o.number().describe(
|
|
2886
|
+
"Minimum value explicitly set to override the minimum value of the data"
|
|
2887
|
+
).optional(),
|
|
2888
|
+
steps: o.number().describe("Distinct number of colors in the range").optional(),
|
|
2889
|
+
type: o.enum(["range"]).describe("Color options type")
|
|
2890
|
+
}).describe("Color options for range color.");
|
|
2891
|
+
const xe = o.object({
|
|
2892
|
+
bilion: o.boolean().optional().describe(
|
|
2893
|
+
"Boolean flag whether to show an abbreviation for a number greater than or equal one billion - e.g. 1B"
|
|
2894
|
+
),
|
|
2895
|
+
decimalScale: o.number().optional().describe("The number of decimal places"),
|
|
2896
|
+
kilo: o.boolean().optional().describe(
|
|
2897
|
+
"Boolean flag whether to show an abbreviation for a number greater than or equal one thousand - e.g. 1K"
|
|
2898
|
+
),
|
|
2899
|
+
million: o.boolean().optional().describe(
|
|
2900
|
+
"Boolean flag whether to show an abbreviation for a number greater than or equal one million - e.g. 1M"
|
|
2901
|
+
),
|
|
2902
|
+
name: o.enum(["Currency", "Numbers", "Percent"]).optional().describe("Supported formats"),
|
|
2903
|
+
prefix: o.boolean().optional().describe(
|
|
2904
|
+
"Boolean flag whether symbol is shown in front of or after the number"
|
|
2905
|
+
),
|
|
2906
|
+
symbol: o.string().optional().describe(
|
|
2907
|
+
"Symbol to show in front of or after the number depending on the value of prefix."
|
|
2908
|
+
),
|
|
2909
|
+
thousandSeparator: o.boolean().optional().describe("Boolean flag whether the thousand separator is shown"),
|
|
2910
|
+
trillion: o.boolean().optional().describe(
|
|
2911
|
+
"Boolean flag whether to show an abbreviation for a number greater than or equal one trillion - e.g. 1T"
|
|
2912
|
+
)
|
|
2913
|
+
}), or = o.object({
|
|
2914
|
+
ignoreAnomalies: o.boolean().optional().describe(
|
|
2915
|
+
"Boolean flag that enables the function to automatically identify and ignore anomalous values in the series. This can be particularly useful when you want to maintain the integrity of your analysis by avoiding potential outliers. default is false"
|
|
2916
|
+
),
|
|
2917
|
+
modelType: o.enum([
|
|
2918
|
+
"advancedSmoothing",
|
|
2919
|
+
"linear",
|
|
2920
|
+
"localEstimates",
|
|
2921
|
+
"logarithmic"
|
|
2922
|
+
]).optional().describe(
|
|
2923
|
+
"Trend analysis model type to be used for the operation. default is linear"
|
|
2924
|
+
)
|
|
2925
|
+
}).describe("Trend analysis options for the measure"), ir = o.object({
|
|
2926
|
+
confidenceInterval: o.number().optional().describe(
|
|
2927
|
+
"Confidence interval showing the probabilistic upper and lower limits of the forecasted series according to the uncertainty level. The valid range is (0.8 <= X < 1). default is 0.8"
|
|
2928
|
+
),
|
|
2929
|
+
endDate: o.string().optional().describe(
|
|
2930
|
+
"End date of the time series data that the forecasting model will be trained on. This parameter can be used to discard the end of the series. Specify a ISO 8601 date string or Date object."
|
|
2931
|
+
),
|
|
2932
|
+
forecastHorizon: o.number().optional().describe(
|
|
2933
|
+
"Number of data points to be predicted. The accepted value range is between 1-1,000. default is 3"
|
|
2934
|
+
),
|
|
2935
|
+
lowerBound: o.number().optional().describe(
|
|
2936
|
+
"Expected lower limit to improve the forecast accuracy when reaching the limit. Note that values in the confidence interval can exceed this limit."
|
|
2937
|
+
),
|
|
2938
|
+
modelType: o.enum(["auto", "autoArima", "holtWinters", "prophet"]).optional().describe(
|
|
2939
|
+
"Forecasting model type. The 'auto' option automatically fits the best combination of models. default is auto"
|
|
2940
|
+
),
|
|
2941
|
+
roundToInt: o.boolean().optional().describe(
|
|
2942
|
+
"Boolean flag to round the predicted result to an integer if set to true. Otherwise, the predicted result is left as a float. default is false"
|
|
2943
|
+
),
|
|
2944
|
+
startDate: o.string().optional().describe(
|
|
2945
|
+
"Start date of the time series data that the forecasting model will be trained on. This parameter can be used to discard the beginning of the series. Specify a ISO 8601 date string or Date object."
|
|
2946
|
+
),
|
|
2947
|
+
upperBound: o.number().optional().describe(
|
|
2948
|
+
"Expected upper limit to improve the forecast accuracy when reaching the limit. Note that values in the confidence interval can exceed this limit."
|
|
2949
|
+
)
|
|
2950
|
+
}).describe("Forecast analysis options for the measure"), S = {
|
|
2951
|
+
measures: o.object({
|
|
2952
|
+
column: Ae,
|
|
2953
|
+
chartType: o.enum(["line", "bar", "column", "area"]).describe(
|
|
2954
|
+
"Series chart type, which is used with StyledMeasure to customize series in a mixed chart."
|
|
2955
|
+
).optional(),
|
|
2956
|
+
sortType: o.enum(["sortAsc", "sortDesc", "sortNone"]).describe(
|
|
2957
|
+
"Sorting direction, either in Ascending order, Descending order, or None"
|
|
2958
|
+
),
|
|
2959
|
+
color: o.string().describe("hex color code for the measure."),
|
|
2960
|
+
connectNulls: o.boolean().describe(
|
|
2961
|
+
"Boolean flag whether to connect a graph line across null points or render a gap"
|
|
2962
|
+
),
|
|
2963
|
+
dataBars: o.boolean().describe(
|
|
2964
|
+
"pivot table only -Boolean flag whether to display data bars for this measure in the pivot table."
|
|
2965
|
+
),
|
|
2966
|
+
dataBarsColor: o.string().describe(
|
|
2967
|
+
"pivot table only - Color options for data bars for this measure in the pivot table"
|
|
2968
|
+
),
|
|
2969
|
+
numberFormatConfig: xe.describe(
|
|
2970
|
+
"Configuration for number formatting."
|
|
2971
|
+
),
|
|
2972
|
+
seriesStyleOptions: o.object({}).describe(
|
|
2973
|
+
"Specific style options to be applied to specific series in Chart. Supported only for cartesian and polar charts."
|
|
2974
|
+
),
|
|
2975
|
+
showOnRightAxis: o.boolean().describe(
|
|
2976
|
+
"Boolean flag whether to show this value/measure on the right axis (true) or on the left axis (false)."
|
|
2977
|
+
),
|
|
2978
|
+
totalsCalculation: o.enum(["sum", "avg", "min", "max", "count"]).describe(
|
|
2979
|
+
"Calculation for the totals of this measure in the pivot table."
|
|
2980
|
+
),
|
|
2981
|
+
treatNullDataAsZeros: o.boolean().describe(
|
|
2982
|
+
"Boolean flag whether null values are treated as zeros in the chart"
|
|
2983
|
+
),
|
|
2984
|
+
trend: or.optional().describe("Trend analysis options for the measure."),
|
|
2985
|
+
forecast: ir.optional().describe("Forecast analysis options for the measure.")
|
|
2986
|
+
}).describe("Configuration for measures.StyledMeasure"),
|
|
2987
|
+
dimensions: o.object({
|
|
2988
|
+
column: Ae,
|
|
2989
|
+
continuous: o.boolean().describe(
|
|
2990
|
+
"Boolean flag to toggle continuous timeline on this date column."
|
|
2991
|
+
),
|
|
2992
|
+
dateFormat: o.string().describe(
|
|
2993
|
+
'Date format. See ECMAScript Date Time String Format(opens new window) Note that "YYYY" and "DD" have been disabled since they often get confused with "yyyy" and "dd" and can produce unexpected results.'
|
|
2994
|
+
),
|
|
2995
|
+
geoLevel: o.enum([
|
|
2996
|
+
"country",
|
|
2997
|
+
"state",
|
|
2998
|
+
"city",
|
|
2999
|
+
"zip",
|
|
3000
|
+
"latitude",
|
|
3001
|
+
"longitude"
|
|
3002
|
+
]).describe("Geographic location level for Scattermap chart."),
|
|
3003
|
+
granularity: o.enum(["day", "week", "month", "year"]).describe(
|
|
3004
|
+
"Date granularity that works with continuous timeline. Values from DateLevels."
|
|
3005
|
+
),
|
|
3006
|
+
includeSubTotals: o.boolean().describe(
|
|
3007
|
+
"Boolean flag whether to include subtotals for this dimension in the pivot table."
|
|
3008
|
+
),
|
|
3009
|
+
isColored: o.boolean().describe("Boolean flag whether to color the dimension."),
|
|
3010
|
+
isHtml: o.boolean().describe(
|
|
3011
|
+
"Boolean flag whether to render category/column value as HTML in the Table component."
|
|
3012
|
+
),
|
|
3013
|
+
numberFormatConfig: xe.describe(
|
|
3014
|
+
"Configuration for number formatting."
|
|
3015
|
+
),
|
|
3016
|
+
sortType: o.enum(["sortAsc", "sortDesc", "sortNone"]).describe(
|
|
3017
|
+
"Sorting configuration that represents either SortDirection or PivotRowsSort for the pivot table"
|
|
3018
|
+
)
|
|
3019
|
+
}).describe("Configuration for dimensions. StyledColumn")
|
|
3020
|
+
}, Q = o.object({
|
|
3021
|
+
values: o.array(S.measures),
|
|
3022
|
+
categories: o.array(S.dimensions),
|
|
3023
|
+
breakBy: o.array(S.dimensions),
|
|
3024
|
+
seriesToColorMap: o.object({}).describe(
|
|
3025
|
+
"Optional mapping of each of the series to colors. (key: color)"
|
|
3026
|
+
)
|
|
3027
|
+
}), I = o.object({
|
|
3028
|
+
values: o.array(S.measures),
|
|
3029
|
+
categories: o.array(S.dimensions),
|
|
3030
|
+
seriesToColorMap: o.object({}).describe("Color mapping for series to color.")
|
|
3031
|
+
}), at = o.object({
|
|
3032
|
+
y: S.measures,
|
|
3033
|
+
x: S.dimensions,
|
|
3034
|
+
breakByColor: S.measures,
|
|
3035
|
+
breakBySize: S.measures,
|
|
3036
|
+
seriesToColorMap: S.measures,
|
|
3037
|
+
size: S.measures
|
|
3038
|
+
}), rt = o.object({
|
|
3039
|
+
min: o.array(S.measures),
|
|
3040
|
+
max: o.array(S.measures),
|
|
3041
|
+
secondary: o.array(S.measures),
|
|
3042
|
+
value: S.measures
|
|
3043
|
+
}), ot = o.object({
|
|
3044
|
+
boxType: o.enum(["extremums", "iqr", "standardDeviation"]),
|
|
3045
|
+
category: o.array(S.dimensions),
|
|
3046
|
+
outliersEnabled: o.boolean().optional(),
|
|
3047
|
+
value: o.array(S.measures)
|
|
3048
|
+
}), sr = o.object({
|
|
3049
|
+
colorBy: S.measures,
|
|
3050
|
+
// todo: or statement dimensions or measures
|
|
3051
|
+
details: S.dimensions,
|
|
3052
|
+
geo: o.array(S.dimensions),
|
|
3053
|
+
size: S.measures
|
|
3054
|
+
}), lr = o.object({
|
|
3055
|
+
color: o.array(S.measures),
|
|
3056
|
+
geo: o.array(S.dimensions)
|
|
3057
|
+
}), it = o.object({
|
|
3058
|
+
date: o.array(S.dimensions),
|
|
3059
|
+
value: o.array(S.measures)
|
|
3060
|
+
}), cr = o.object({
|
|
3061
|
+
columns: o.array(S.dimensions)
|
|
3062
|
+
}), ur = (e) => {
|
|
3063
|
+
switch (e) {
|
|
3064
|
+
case "line":
|
|
3065
|
+
case "bar":
|
|
3066
|
+
case "column":
|
|
3067
|
+
case "area":
|
|
3068
|
+
case "polar":
|
|
3069
|
+
return Q;
|
|
3070
|
+
case "pie":
|
|
3071
|
+
case "funnel":
|
|
3072
|
+
case "treemap":
|
|
3073
|
+
case "sunburst":
|
|
3074
|
+
return I;
|
|
3075
|
+
case "scatter":
|
|
3076
|
+
return at;
|
|
3077
|
+
case "indicator":
|
|
3078
|
+
return rt;
|
|
3079
|
+
case "table":
|
|
3080
|
+
return cr;
|
|
3081
|
+
case "boxplot":
|
|
3082
|
+
return ot;
|
|
3083
|
+
case "scattermap":
|
|
3084
|
+
return sr;
|
|
3085
|
+
case "areamap":
|
|
3086
|
+
return lr;
|
|
3087
|
+
case "calendar-heatmap":
|
|
3088
|
+
return it;
|
|
3089
|
+
default:
|
|
3090
|
+
return o.object({});
|
|
3091
|
+
}
|
|
3092
|
+
}, J = {
|
|
3093
|
+
line: Q,
|
|
3094
|
+
bar: I,
|
|
3095
|
+
area: Q,
|
|
3096
|
+
column: I,
|
|
3097
|
+
// Assuming column is similar to bar; adjust as needed
|
|
3098
|
+
pie: I,
|
|
3099
|
+
scatter: at,
|
|
3100
|
+
funnel: I,
|
|
3101
|
+
treemap: I,
|
|
3102
|
+
sunburst: I,
|
|
3103
|
+
boxplot: ot,
|
|
3104
|
+
indicator: rt,
|
|
3105
|
+
polar: Q,
|
|
3106
|
+
table: tt,
|
|
3107
|
+
arearange: o.object({}),
|
|
3108
|
+
scattermap: o.object({}),
|
|
3109
|
+
areamap: o.object({}),
|
|
3110
|
+
"calendar-heatmap": it,
|
|
3111
|
+
streamgraph: o.object({})
|
|
3112
|
+
}, dr = async ({
|
|
3113
|
+
userPrompt: e,
|
|
3114
|
+
chartWidgetProps: t
|
|
3115
|
+
}) => {
|
|
3116
|
+
const { dataOptions: n, chartType: a } = t, r = ur(a);
|
|
3117
|
+
o.object({
|
|
3118
|
+
dataOptions: r
|
|
3119
|
+
});
|
|
3120
|
+
const s = `
|
|
3121
|
+
You are a chart data options assistant. You edit only the fields the user mentions.
|
|
3122
|
+
|
|
3123
|
+
DO NOT use any tools.
|
|
3124
|
+
|
|
3125
|
+
Here are the editable properties:
|
|
3126
|
+
${`
|
|
3127
|
+
Editable chart data options properties are as follows:
|
|
3128
|
+
|
|
3129
|
+
|
|
3130
|
+
dataOptions: {
|
|
3131
|
+
${Object.entries(r.shape).map(
|
|
3132
|
+
([m, p]) => `- ${m}: ${P(p)}`
|
|
3133
|
+
).join(`
|
|
3134
|
+
`)}
|
|
3135
|
+
}
|
|
3136
|
+
|
|
3137
|
+
current dataOptions: {
|
|
3138
|
+
${JSON.stringify(n, null, 2)}
|
|
3139
|
+
}
|
|
3140
|
+
`}
|
|
3141
|
+
|
|
3142
|
+
Your output must be a JSON object with only the requested changes.
|
|
3143
|
+
|
|
3144
|
+
The 'column' object, containing only the item's 'name', MUST be included for any change to an item within a list field ('values', 'categories', 'breakBy', etc.)
|
|
3145
|
+
to maintain identity.
|
|
3146
|
+
|
|
3147
|
+
Do not include unchanged fields.
|
|
3148
|
+
|
|
3149
|
+
Example:
|
|
3150
|
+
|
|
3151
|
+
User: "Sort revenue in descending order"
|
|
3152
|
+
Output: { "dataOptions": { "value" : [
|
|
3153
|
+
{
|
|
3154
|
+
"column": {
|
|
3155
|
+
"name": "Total Revenue",
|
|
3156
|
+
},
|
|
3157
|
+
"sortType": "sortDesc"
|
|
3158
|
+
}
|
|
3159
|
+
] } }
|
|
3160
|
+
|
|
3161
|
+
`, l = await ge({
|
|
3162
|
+
systemPrompt: s,
|
|
3163
|
+
userPrompt: e,
|
|
3164
|
+
responseFormat: { type: "json_object" }
|
|
3165
|
+
});
|
|
3166
|
+
console.debug("LLM RESPONSE DATA OPTIONS", l);
|
|
3167
|
+
const { dataOptions: c = null } = l, u = c ? pr(t.dataOptions, c) : t.dataOptions;
|
|
3168
|
+
return {
|
|
3169
|
+
...t,
|
|
3170
|
+
dataOptions: u
|
|
3171
|
+
};
|
|
3172
|
+
};
|
|
3173
|
+
function pr(e, t) {
|
|
3174
|
+
const n = { ...e };
|
|
3175
|
+
for (const a of Object.keys(t)) {
|
|
3176
|
+
const r = a, i = t[r], s = e[r] || [];
|
|
3177
|
+
n[r] = s.map((l) => {
|
|
3178
|
+
var d;
|
|
3179
|
+
const c = (d = l == null ? void 0 : l.column) == null ? void 0 : d.name, u = i.find(
|
|
3180
|
+
(m) => {
|
|
3181
|
+
var p;
|
|
3182
|
+
return ((p = m == null ? void 0 : m.column) == null ? void 0 : p.name) === c;
|
|
3183
|
+
}
|
|
3184
|
+
);
|
|
3185
|
+
if (u) {
|
|
3186
|
+
const m = { ...l };
|
|
3187
|
+
return Object.keys(u).forEach((p) => {
|
|
3188
|
+
if (p !== "column") {
|
|
3189
|
+
const O = u[p];
|
|
3190
|
+
O == null ? delete m[p] : m[p] = O;
|
|
3191
|
+
}
|
|
3192
|
+
}), m;
|
|
3193
|
+
}
|
|
3194
|
+
return l;
|
|
3195
|
+
});
|
|
3196
|
+
}
|
|
3197
|
+
return n;
|
|
3198
|
+
}
|
|
3199
|
+
const Y = async ({ chartId: e, userPrompt: t }, n) => {
|
|
3200
|
+
var i, s;
|
|
3201
|
+
console.debug("toolCall", "updateChartDataOptions", e, t);
|
|
3202
|
+
const a = (i = n.retrieveChart) == null ? void 0 : i.call(n, e);
|
|
3203
|
+
if (!a)
|
|
3204
|
+
throw new Error("Chart not found");
|
|
3205
|
+
const r = await dr({
|
|
3206
|
+
userPrompt: t,
|
|
3207
|
+
chartWidgetProps: a
|
|
3208
|
+
});
|
|
3209
|
+
return (s = n.saveChart) == null || s.call(n, e, r), {
|
|
3210
|
+
message: "Chart data options updated successfully"
|
|
3211
|
+
};
|
|
3212
|
+
};
|
|
3213
|
+
function st(e) {
|
|
3214
|
+
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
3215
|
+
}
|
|
3216
|
+
var mr = function(t) {
|
|
3217
|
+
return hr(t) && !gr(t);
|
|
3218
|
+
};
|
|
3219
|
+
function hr(e) {
|
|
3220
|
+
return !!e && typeof e == "object";
|
|
3221
|
+
}
|
|
3222
|
+
function gr(e) {
|
|
3223
|
+
var t = Object.prototype.toString.call(e);
|
|
3224
|
+
return t === "[object RegExp]" || t === "[object Date]" || yr(e);
|
|
3225
|
+
}
|
|
3226
|
+
var fr = typeof Symbol == "function" && Symbol.for, br = fr ? Symbol.for("react.element") : 60103;
|
|
3227
|
+
function yr(e) {
|
|
3228
|
+
return e.$$typeof === br;
|
|
3229
|
+
}
|
|
3230
|
+
function vr(e) {
|
|
3231
|
+
return Array.isArray(e) ? [] : {};
|
|
3232
|
+
}
|
|
3233
|
+
function H(e, t) {
|
|
3234
|
+
return t.clone !== !1 && t.isMergeableObject(e) ? B(vr(e), e, t) : e;
|
|
3235
|
+
}
|
|
3236
|
+
function wr(e, t, n) {
|
|
3237
|
+
return e.concat(t).map(function(a) {
|
|
3238
|
+
return H(a, n);
|
|
3239
|
+
});
|
|
3240
|
+
}
|
|
3241
|
+
function Sr(e, t) {
|
|
3242
|
+
if (!t.customMerge)
|
|
3243
|
+
return B;
|
|
3244
|
+
var n = t.customMerge(e);
|
|
3245
|
+
return typeof n == "function" ? n : B;
|
|
3246
|
+
}
|
|
3247
|
+
function Or(e) {
|
|
3248
|
+
return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(e).filter(function(t) {
|
|
3249
|
+
return Object.propertyIsEnumerable.call(e, t);
|
|
3250
|
+
}) : [];
|
|
3251
|
+
}
|
|
3252
|
+
function $e(e) {
|
|
3253
|
+
return Object.keys(e).concat(Or(e));
|
|
3254
|
+
}
|
|
3255
|
+
function lt(e, t) {
|
|
3256
|
+
try {
|
|
3257
|
+
return t in e;
|
|
3258
|
+
} catch {
|
|
3259
|
+
return !1;
|
|
3260
|
+
}
|
|
3261
|
+
}
|
|
3262
|
+
function Cr(e, t) {
|
|
3263
|
+
return lt(e, t) && !(Object.hasOwnProperty.call(e, t) && Object.propertyIsEnumerable.call(e, t));
|
|
3264
|
+
}
|
|
3265
|
+
function Dr(e, t, n) {
|
|
3266
|
+
var a = {};
|
|
3267
|
+
return n.isMergeableObject(e) && $e(e).forEach(function(r) {
|
|
3268
|
+
a[r] = H(e[r], n);
|
|
3269
|
+
}), $e(t).forEach(function(r) {
|
|
3270
|
+
Cr(e, r) || (lt(e, r) && n.isMergeableObject(t[r]) ? a[r] = Sr(r, n)(e[r], t[r], n) : a[r] = H(t[r], n));
|
|
3271
|
+
}), a;
|
|
3272
|
+
}
|
|
3273
|
+
function B(e, t, n) {
|
|
3274
|
+
n = n || {}, n.arrayMerge = n.arrayMerge || wr, n.isMergeableObject = n.isMergeableObject || mr, n.cloneUnlessOtherwiseSpecified = H;
|
|
3275
|
+
var a = Array.isArray(t), r = Array.isArray(e), i = a === r;
|
|
3276
|
+
return i ? a ? n.arrayMerge(e, t, n) : Dr(e, t, n) : H(t, n);
|
|
3277
|
+
}
|
|
3278
|
+
B.all = function(t, n) {
|
|
3279
|
+
if (!Array.isArray(t))
|
|
3280
|
+
throw new Error("first argument should be an array");
|
|
3281
|
+
return t.reduce(function(a, r) {
|
|
3282
|
+
return B(a, r, n);
|
|
3283
|
+
}, {});
|
|
3284
|
+
};
|
|
3285
|
+
var _r = B, Pr = _r;
|
|
3286
|
+
const Ar = /* @__PURE__ */ st(Pr), xr = async ({
|
|
3287
|
+
userPrompt: e,
|
|
3288
|
+
chartWidgetProps: t
|
|
3289
|
+
}) => {
|
|
3290
|
+
const { styleOptions: n, chartType: a } = t, r = rr(a), s = `
|
|
3291
|
+
You are a chart style options assistant. You edit only the fields the user mentions.
|
|
3292
|
+
|
|
3293
|
+
DO NOT use any tools.
|
|
3294
|
+
|
|
3295
|
+
Here are the editable properties:
|
|
3296
|
+
${`
|
|
3297
|
+
Editable chart style properties are as follows:
|
|
3298
|
+
|
|
3299
|
+
styleOptions: {
|
|
3300
|
+
${Object.entries(r.shape).map(([m, p]) => `- ${m}: ${P(p)}`).join(`
|
|
3301
|
+
`)}
|
|
3302
|
+
}
|
|
3303
|
+
`}
|
|
3304
|
+
|
|
3305
|
+
DO NOT return any field unless the user directly references it.
|
|
3306
|
+
Your output must be a JSON object with only the requested changes.
|
|
3307
|
+
Do not include unchanged fields.
|
|
3308
|
+
|
|
3309
|
+
Example:
|
|
3310
|
+
User "name the y axis title to Awesome Revenue"
|
|
3311
|
+
Output: { "styleOptions": { "yAxis": { "title": "Awesome Revenue", enabled: true } } }
|
|
3312
|
+
|
|
3313
|
+
User: "move legend to top"
|
|
3314
|
+
Output: { "styleOptions": { "legend": { "position": "top" } } }
|
|
3315
|
+
|
|
3316
|
+
`, l = await ge({
|
|
3317
|
+
systemPrompt: s,
|
|
3318
|
+
userPrompt: e,
|
|
3319
|
+
responseFormat: { type: "json_object" }
|
|
3320
|
+
}), { styleOptions: c = n } = l, u = Ar(
|
|
3321
|
+
n || {},
|
|
3322
|
+
c || {}
|
|
3323
|
+
);
|
|
3324
|
+
return {
|
|
3325
|
+
...t,
|
|
3326
|
+
styleOptions: u
|
|
3327
|
+
};
|
|
3328
|
+
}, $r = async ({ chartId: e, userPrompt: t }, n) => {
|
|
3329
|
+
var i, s;
|
|
3330
|
+
console.debug("toolCall", "updateChartStyleOptions", e, t);
|
|
3331
|
+
const a = (i = n.retrieveChart) == null ? void 0 : i.call(n, e);
|
|
3332
|
+
if (!a)
|
|
3333
|
+
throw new Error("Chart not found");
|
|
3334
|
+
const r = await xr({
|
|
3335
|
+
userPrompt: t,
|
|
3336
|
+
chartWidgetProps: a
|
|
3337
|
+
});
|
|
3338
|
+
return (s = n.saveChart) == null || s.call(n, e, r), {
|
|
3339
|
+
message: "Chart style options updated successfully"
|
|
3340
|
+
};
|
|
3341
|
+
}, Tr = "buildChart", ko = "buildDashboard", Eo = "buildDataModel", Mo = "recommendQueries", No = "getDashboards", Zo = "getDataSources", Io = "getDataSourceFields", jr = 10, kr = (e, t) => ({
|
|
3342
|
+
title: e.title,
|
|
3343
|
+
dataSourceTitle: t,
|
|
3344
|
+
chartType: e.chartType,
|
|
3345
|
+
filters: "Filters to be updated",
|
|
3346
|
+
dataOptions: "Data options to be updated",
|
|
3347
|
+
styleOptions: "Style options to be updated"
|
|
3348
|
+
}), E = (e, t, n, a, r) => un({
|
|
3349
|
+
schema: e,
|
|
3350
|
+
name: t,
|
|
3351
|
+
description: n,
|
|
3352
|
+
function: async (i, s) => a(
|
|
3353
|
+
{ ...i },
|
|
3354
|
+
{ ...r, ...s }
|
|
3355
|
+
)
|
|
3356
|
+
}), Er = (e) => [
|
|
3357
|
+
E(
|
|
3358
|
+
_n,
|
|
3359
|
+
"createChart",
|
|
3360
|
+
"Create a new chart from user prompt. Use this tool for initial creation OR when adding/removing/swapping data fields (e.g. changing Revenue to Profit). This tool also handles data limits (Top 10, Bottom 5).",
|
|
3361
|
+
Ra,
|
|
3362
|
+
e
|
|
3363
|
+
),
|
|
3364
|
+
E(
|
|
3365
|
+
Pn,
|
|
3366
|
+
"updateChartTitle",
|
|
3367
|
+
"Update the title of an existing chart",
|
|
3368
|
+
Ba,
|
|
3369
|
+
e
|
|
3370
|
+
),
|
|
3371
|
+
E(
|
|
3372
|
+
An,
|
|
3373
|
+
"updateChartType",
|
|
3374
|
+
"Switch the chart type of an existing chart",
|
|
3375
|
+
Fa,
|
|
3376
|
+
e
|
|
3377
|
+
),
|
|
3378
|
+
E(
|
|
3379
|
+
xn,
|
|
3380
|
+
"updateChartTypeOfMeasures",
|
|
3381
|
+
`Update the chart type of specific measures within a mixed/combo chart (e.g., make one measure a Bar and another a Line).
|
|
3382
|
+
|
|
3383
|
+
See the following options for editing the chart type of existing measures:
|
|
3384
|
+
|
|
3385
|
+
${Object.entries(J).map(
|
|
3386
|
+
([t, n]) => `- ${t}: ${P(
|
|
3387
|
+
re(n, ["column", "chartType"])
|
|
3388
|
+
)}`
|
|
3389
|
+
).join(`
|
|
3390
|
+
`)}
|
|
3391
|
+
`,
|
|
3392
|
+
Y,
|
|
3393
|
+
e
|
|
3394
|
+
),
|
|
3395
|
+
E(
|
|
3396
|
+
$n,
|
|
3397
|
+
"updateChartSorting",
|
|
3398
|
+
`Update the sorting order (Ascending/Descending) of an existing chart.
|
|
3399
|
+
|
|
3400
|
+
IMPORTANT: This tool ONLY handles the sorting order. It does NOT handle data limits or filtering (e.g., "Top 10", "Bottom 5"). Those constraints must be applied during chart creation or regeneration.
|
|
3401
|
+
|
|
3402
|
+
See the following sorting options for editing:
|
|
3403
|
+
|
|
3404
|
+
${Object.entries(J).map(
|
|
3405
|
+
([t, n]) => `- ${t}: ${P(
|
|
3406
|
+
re(n, ["column", "sortType"])
|
|
3407
|
+
)}`
|
|
3408
|
+
).join(`
|
|
3409
|
+
`)}
|
|
3410
|
+
`,
|
|
3411
|
+
Y,
|
|
3412
|
+
e
|
|
3413
|
+
),
|
|
3414
|
+
E(
|
|
3415
|
+
Tn,
|
|
3416
|
+
"updateTrendAndForecast",
|
|
3417
|
+
`Update the trend and forecast analysis of existing measures in an existing chart
|
|
3418
|
+
|
|
3419
|
+
See the following trend and forecast analysis options for editing:
|
|
3420
|
+
|
|
3421
|
+
${Object.entries(J).map(
|
|
3422
|
+
([t, n]) => `- ${t}: ${P(
|
|
3423
|
+
re(n, [
|
|
3424
|
+
"column",
|
|
3425
|
+
"trend",
|
|
3426
|
+
"forecast"
|
|
3427
|
+
])
|
|
3428
|
+
)}`
|
|
3429
|
+
).join(`
|
|
3430
|
+
`)}
|
|
3431
|
+
`,
|
|
3432
|
+
Y,
|
|
3433
|
+
e
|
|
3434
|
+
),
|
|
3435
|
+
E(
|
|
3436
|
+
jn,
|
|
3437
|
+
"updateOtherChartDataOptions",
|
|
3438
|
+
`Update other data options of an existing chart including visual encodings of axes (x-axis, y-axis, and right y-axis), dimensions, and measures
|
|
3439
|
+
|
|
3440
|
+
For a measure, for example, you can update its color and show it on the right axis.
|
|
3441
|
+
|
|
3442
|
+
IMPORTANT: This tool cannot swap data columns (e.g. changing "Revenue" to "Profit"). Use createChart for that.
|
|
3443
|
+
|
|
3444
|
+
See the following data options for editing:
|
|
3445
|
+
|
|
3446
|
+
${Object.entries(J).map(
|
|
3447
|
+
([t, n]) => `- ${t}: ${P(
|
|
3448
|
+
cn(n, [
|
|
3449
|
+
"sortType",
|
|
3450
|
+
// Has dedicated sorting tool
|
|
3451
|
+
"trend",
|
|
3452
|
+
// Has dedicated trend/forecast tool
|
|
3453
|
+
"forecast",
|
|
3454
|
+
// Has dedicated trend/forecast tool
|
|
3455
|
+
"chartType"
|
|
3456
|
+
// Has dedicated chartType tool
|
|
3457
|
+
])
|
|
3458
|
+
)}`
|
|
3459
|
+
).join(`
|
|
3460
|
+
`)}
|
|
3461
|
+
`,
|
|
3462
|
+
Y,
|
|
3463
|
+
e
|
|
3464
|
+
),
|
|
3465
|
+
E(
|
|
3466
|
+
kn,
|
|
3467
|
+
"updateChartStyleOptions",
|
|
3468
|
+
`Update cosmetic styling options: legend position, axis titles (text), axis label formatting.
|
|
3469
|
+
|
|
3470
|
+
See the following styling options for editing:
|
|
3471
|
+
|
|
3472
|
+
${Object.entries(nt).map(([t, n]) => `- ${t}: ${P(n)}`).join(`
|
|
3473
|
+
`)}
|
|
3474
|
+
|
|
3475
|
+
`,
|
|
3476
|
+
$r,
|
|
3477
|
+
e
|
|
3478
|
+
)
|
|
3479
|
+
];
|
|
3480
|
+
function Mr(e) {
|
|
3481
|
+
return `You are an intelligent and proactive chart assistant.
|
|
3482
|
+
Your role is to create and update a chart based on natural language requests by using the available tools.
|
|
3483
|
+
|
|
3484
|
+
IMPORTANT INSTRUCTIONS:
|
|
3485
|
+
1. Use the charts and their revisions in the following context to build the chart: ${JSON.stringify(
|
|
3486
|
+
{
|
|
3487
|
+
charts: e
|
|
3488
|
+
},
|
|
3489
|
+
null,
|
|
3490
|
+
2
|
|
3491
|
+
)}
|
|
3492
|
+
2. Always reference the charts by their IDs instead of their titles.
|
|
3493
|
+
|
|
3494
|
+
3. Use the last chart in the context as the current chart unless the user prompt specifies otherwise.
|
|
3495
|
+
|
|
3496
|
+
4. If the user prompt involves multiple actions that require different available tools (e.g., sorting, trend and forecast, chart type of measures, and other data options),
|
|
3497
|
+
split it into multiple prompts. For example, if the user prompt is "create a new chart showing total revenue by brand, and sort by revenue in descending order",
|
|
3498
|
+
split it into two prompts: "create a new chart showing total revenue by brand" and "sort by revenue in descending order" in step by step.
|
|
3499
|
+
If the prompt can be handled by a single tool, use that tool without splitting the prompt into multiple steps.
|
|
3500
|
+
|
|
3501
|
+
5. When responding to changes involving an existing chart:
|
|
3502
|
+
- If the prompt involves **adding or removing** chart's data structure such as dimensions, measures, or filters (e.g., "add revenue", "remove date", "filter by region"), do **not** modify the existing chart. Instead, **redo a new chart** with the requested changes in step-by-step prompts.
|
|
3503
|
+
- If the prompt involves **enhancing** how existing fields are displayed (e.g., "sort by revenue in descending order", "show cost on the right axis", "add trend line", "add forecast line", "remove trend line", "remove forecast line"), apply the changes **to the existing chart** in step by step.
|
|
3504
|
+
|
|
3505
|
+
6. When updating the chart type of existing measures, re-apply the data options and style options changes to the new chart.
|
|
3506
|
+
|
|
3507
|
+
`;
|
|
3508
|
+
}
|
|
3509
|
+
async function Lo(e, t) {
|
|
3510
|
+
const { dataSourceTitle: n, userPrompt: a } = e;
|
|
3511
|
+
if (console.debug(Tr, n, a), !n)
|
|
3512
|
+
throw new Error(
|
|
3513
|
+
"Error: Please ask the user to specify a data source title"
|
|
3514
|
+
);
|
|
3515
|
+
if (!a)
|
|
3516
|
+
throw new Error(
|
|
3517
|
+
"Error: Please ask the user to specify textual user input"
|
|
3518
|
+
);
|
|
3519
|
+
const r = t.toolCallId;
|
|
3520
|
+
let i = null, s = "", l = !1;
|
|
3521
|
+
const c = {
|
|
3522
|
+
...t,
|
|
3523
|
+
dataSourceTitle: n,
|
|
3524
|
+
retrieveChart: (O) => i || (O && t.retrieveChart ? t.retrieveChart(O) : null),
|
|
3525
|
+
saveChart: (O, C) => {
|
|
3526
|
+
var N;
|
|
3527
|
+
(N = t.saveChart) == null || N.call(t, r, C), i = C;
|
|
3528
|
+
}
|
|
3529
|
+
}, u = Mr(
|
|
3530
|
+
(t.chartSummaries ?? []).slice(-jr)
|
|
3531
|
+
), d = Er(c), { combinedMessage: m, isError: p } = await $a({
|
|
3532
|
+
systemPrompt: u,
|
|
3533
|
+
userPrompt: a,
|
|
3534
|
+
tools: d
|
|
3535
|
+
});
|
|
3536
|
+
if (s = m, l = p, l)
|
|
3537
|
+
throw new Error(s);
|
|
3538
|
+
return {
|
|
3539
|
+
message: s,
|
|
3540
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3541
|
+
chartId: r,
|
|
3542
|
+
chart: i ? kr(i, n) : void 0
|
|
3543
|
+
};
|
|
3544
|
+
}
|
|
3545
|
+
const Nr = "api/v2/datamodels";
|
|
3546
|
+
async function Zr(e) {
|
|
3547
|
+
const t = f(), n = `${Nr}/schema?title=${encodeURIComponent(
|
|
3548
|
+
e
|
|
3549
|
+
)}`;
|
|
3550
|
+
return await t.get(n) ?? null;
|
|
3551
|
+
}
|
|
3552
|
+
const be = "api/datasources";
|
|
3553
|
+
function Ir(e, t) {
|
|
3554
|
+
const n = t.reduce(
|
|
3555
|
+
(a, r) => (r.schema.tables.forEach((i) => {
|
|
3556
|
+
a[i.name] = {}, i.columns.forEach((s) => {
|
|
3557
|
+
a[i.name][s.name] = s.description;
|
|
3558
|
+
});
|
|
3559
|
+
}), a),
|
|
3560
|
+
{}
|
|
3561
|
+
);
|
|
3562
|
+
return e.map((a) => {
|
|
3563
|
+
var r;
|
|
3564
|
+
return {
|
|
3565
|
+
...a,
|
|
3566
|
+
description: ((r = n[a.table]) == null ? void 0 : r[a.column]) || ""
|
|
3567
|
+
};
|
|
3568
|
+
});
|
|
3569
|
+
}
|
|
3570
|
+
async function Ro() {
|
|
3571
|
+
const e = f(), t = `${be}/?sharedWith=r,w`;
|
|
3572
|
+
return await e.get(t) || [];
|
|
3573
|
+
}
|
|
3574
|
+
async function ct(e) {
|
|
3575
|
+
return await f().get(
|
|
3576
|
+
`${be}/${encodeURIComponent(e)}`
|
|
3577
|
+
) ?? null;
|
|
3578
|
+
}
|
|
3579
|
+
async function Lr(e) {
|
|
3580
|
+
return f().post(
|
|
3581
|
+
`${be}/${encodeURIComponent(
|
|
3582
|
+
e
|
|
3583
|
+
)}/fields/search`,
|
|
3584
|
+
{
|
|
3585
|
+
offset: 0,
|
|
3586
|
+
count: 9999
|
|
3587
|
+
}
|
|
3588
|
+
).then((n) => n ?? null);
|
|
3589
|
+
}
|
|
3590
|
+
async function Rr(e) {
|
|
3591
|
+
var n;
|
|
3592
|
+
const t = await Lr(e);
|
|
3593
|
+
if (!t) return [];
|
|
3594
|
+
try {
|
|
3595
|
+
const a = await Zr(e);
|
|
3596
|
+
return a != null && a.datasets ? Ir(
|
|
3597
|
+
t,
|
|
3598
|
+
a.datasets
|
|
3599
|
+
) : t;
|
|
3600
|
+
} catch (a) {
|
|
3601
|
+
const r = a, i = (r == null ? void 0 : r.status) ?? (r == null ? void 0 : r.statusCode) ?? ((n = r == null ? void 0 : r.response) == null ? void 0 : n.status);
|
|
3602
|
+
if ((i === 404 || i === "404") && t.length)
|
|
3603
|
+
return t;
|
|
3604
|
+
if (i === 401 || i === "401" || i === 403 || i === "403")
|
|
3605
|
+
return console.log(
|
|
3606
|
+
"Note: Field descriptions are omitted from the data model due to restricted role of your account"
|
|
3607
|
+
), t;
|
|
3608
|
+
throw a;
|
|
3609
|
+
}
|
|
3610
|
+
}
|
|
3611
|
+
function zr(e) {
|
|
3612
|
+
const t = [];
|
|
3613
|
+
return e.forEach((n) => {
|
|
3614
|
+
const a = ve(n.column), r = {
|
|
3615
|
+
table: ve(n.table),
|
|
3616
|
+
column: a,
|
|
3617
|
+
type: n.dimtype,
|
|
3618
|
+
expression: n.id,
|
|
3619
|
+
description: n.description || `${n.table}.${n.column}`
|
|
3620
|
+
};
|
|
3621
|
+
t.push(r), n.dimtype === "datetime" && Ot.all.forEach((i) => {
|
|
3622
|
+
t.push({
|
|
3623
|
+
...r,
|
|
3624
|
+
column: `${a}.${i}`,
|
|
3625
|
+
type: "datetime",
|
|
3626
|
+
level: i,
|
|
3627
|
+
expression: n.id,
|
|
3628
|
+
description: n.description || `${n.table}.${n.column}.${i}`
|
|
3629
|
+
});
|
|
3630
|
+
});
|
|
3631
|
+
}), t;
|
|
3632
|
+
}
|
|
3633
|
+
async function zo(e, t = Rr) {
|
|
3634
|
+
const n = await t(e);
|
|
3635
|
+
return zr(n);
|
|
3636
|
+
}
|
|
3637
|
+
const z = "api/v1/dashboards";
|
|
3638
|
+
function Bo(e) {
|
|
3639
|
+
const t = f();
|
|
3640
|
+
return `${he(t.url)}app/main/dashboards/${e}`;
|
|
3641
|
+
}
|
|
3642
|
+
async function Br(e = {}) {
|
|
3643
|
+
const t = f(), { fields: n, expand: a, searchByTitle: r } = e, i = new URLSearchParams({
|
|
3644
|
+
...r && { name: r },
|
|
3645
|
+
...(n == null ? void 0 : n.length) && { fields: n == null ? void 0 : n.join(",") },
|
|
3646
|
+
...(a == null ? void 0 : a.length) && { expand: a == null ? void 0 : a.join(",") }
|
|
3647
|
+
}).toString(), s = await t.get(
|
|
3648
|
+
`${z}?${i}`
|
|
3649
|
+
);
|
|
3650
|
+
return s || [];
|
|
3651
|
+
}
|
|
3652
|
+
async function Ur(e) {
|
|
3653
|
+
const t = f();
|
|
3654
|
+
try {
|
|
3655
|
+
return await t.get(
|
|
3656
|
+
`${z}/${e}/widgets`
|
|
3657
|
+
) ?? [];
|
|
3658
|
+
} catch {
|
|
3659
|
+
throw new Error(
|
|
3660
|
+
"Failed to retrieve dashboard widgets. Please make sure the dashboard exists and is accessible."
|
|
3661
|
+
);
|
|
3662
|
+
}
|
|
3663
|
+
}
|
|
3664
|
+
async function Fr(e) {
|
|
3665
|
+
const t = f();
|
|
3666
|
+
return await vt(t, e, {
|
|
3667
|
+
includeWidgets: !0,
|
|
3668
|
+
includeFilters: !0
|
|
3669
|
+
});
|
|
3670
|
+
}
|
|
3671
|
+
async function pe(e, t) {
|
|
3672
|
+
return await f().patch(
|
|
3673
|
+
`${z}/${e}`,
|
|
3674
|
+
t
|
|
3675
|
+
) ?? null;
|
|
3676
|
+
}
|
|
3677
|
+
async function qr(e, t) {
|
|
3678
|
+
return await f().post(
|
|
3679
|
+
`${z}/${e}/widgets`,
|
|
3680
|
+
t
|
|
3681
|
+
) ?? null;
|
|
3682
|
+
}
|
|
3683
|
+
async function Te(e, t) {
|
|
3684
|
+
return await f().post(
|
|
3685
|
+
`${z}`,
|
|
3686
|
+
{
|
|
3687
|
+
title: e,
|
|
3688
|
+
datasource: t,
|
|
3689
|
+
settings: { managedByTool: "studio-assistant" }
|
|
3690
|
+
}
|
|
3691
|
+
) ?? null;
|
|
3692
|
+
}
|
|
3693
|
+
function Uo(e) {
|
|
3694
|
+
return f().delete(
|
|
3695
|
+
`${z}/${e}`
|
|
3696
|
+
);
|
|
3697
|
+
}
|
|
3698
|
+
function Wr(e, t) {
|
|
3699
|
+
return f().delete(
|
|
3700
|
+
`${z}/${e}/widgets/${t}`
|
|
3701
|
+
);
|
|
3702
|
+
}
|
|
3703
|
+
function Hr(e) {
|
|
3704
|
+
return {
|
|
3705
|
+
columns: e.columns.map((t) => ({
|
|
3706
|
+
width: t.widthPercentage,
|
|
3707
|
+
cells: t.rows.map((n) => ({
|
|
3708
|
+
subcells: n.cells.map((a) => ({
|
|
3709
|
+
width: a.widthPercentage,
|
|
3710
|
+
elements: [
|
|
3711
|
+
{
|
|
3712
|
+
height: a.height ?? 384,
|
|
3713
|
+
widgetid: a.widgetId,
|
|
3714
|
+
widthPercentage: 100,
|
|
3715
|
+
minWidth: 200,
|
|
3716
|
+
maxWidth: 2e3,
|
|
3717
|
+
minHeight: 200,
|
|
3718
|
+
maxHeight: 2e3
|
|
3719
|
+
}
|
|
3720
|
+
]
|
|
3721
|
+
}))
|
|
3722
|
+
}))
|
|
3723
|
+
}))
|
|
3724
|
+
};
|
|
3725
|
+
}
|
|
3726
|
+
async function Fo() {
|
|
3727
|
+
return (await Br({
|
|
3728
|
+
fields: ["title", "oid", "datasource", "settings"]
|
|
3729
|
+
})).filter(
|
|
3730
|
+
(n) => {
|
|
3731
|
+
var a;
|
|
3732
|
+
return ((a = n.settings) == null ? void 0 : a.managedByTool) === "studio-assistant";
|
|
3733
|
+
}
|
|
3734
|
+
).map((n) => ({
|
|
3735
|
+
dashboardTitle: n.title,
|
|
3736
|
+
dashboardId: n.oid,
|
|
3737
|
+
dataSourceTitle: n.datasource.title
|
|
3738
|
+
}));
|
|
3739
|
+
}
|
|
3740
|
+
async function Vr(e) {
|
|
3741
|
+
var n;
|
|
3742
|
+
const t = await Fr(e);
|
|
3743
|
+
if (!(t && ((n = t.settings) == null ? void 0 : n.managedByTool) !== "studio-assistant"))
|
|
3744
|
+
return t ? wt.toDashboardProps(t) : void 0;
|
|
3745
|
+
}
|
|
3746
|
+
async function qo(e) {
|
|
3747
|
+
const t = await Vr(e);
|
|
3748
|
+
if (!t)
|
|
3749
|
+
throw new Error(
|
|
3750
|
+
"Dashboard not available for editing. Please specify a different dashboard."
|
|
3751
|
+
);
|
|
3752
|
+
return t;
|
|
3753
|
+
}
|
|
3754
|
+
async function Jr(e, t) {
|
|
3755
|
+
if (t.length === 0)
|
|
3756
|
+
return [];
|
|
3757
|
+
const a = t.map((s) => {
|
|
3758
|
+
const l = ye.fromWidgetProps(s), c = Ee(s) && s.dataSource ? ie(s.dataSource) : void 0;
|
|
3759
|
+
return ye.toWidgetDto(l, c);
|
|
3760
|
+
}).map(
|
|
3761
|
+
(s, l) => qr(e, s).then((c) => ({
|
|
3762
|
+
index: l,
|
|
3763
|
+
result: c
|
|
3764
|
+
}))
|
|
3765
|
+
);
|
|
3766
|
+
return (await Promise.all(a)).sort((s, l) => s.index - l.index).map((s) => s.result).filter((s) => s !== void 0);
|
|
3767
|
+
}
|
|
3768
|
+
async function Yr(e, t) {
|
|
3769
|
+
const n = St(t);
|
|
3770
|
+
await pe(e, n);
|
|
3771
|
+
}
|
|
3772
|
+
function Wo(e) {
|
|
3773
|
+
return !!e.id;
|
|
3774
|
+
}
|
|
3775
|
+
async function Ho(e) {
|
|
3776
|
+
var d, m;
|
|
3777
|
+
const t = e.defaultDataSource;
|
|
3778
|
+
if (!t)
|
|
3779
|
+
throw new Error("Dashboard must have a data source");
|
|
3780
|
+
const n = se(t) ? t.title : t, a = await ct(n);
|
|
3781
|
+
if (!a)
|
|
3782
|
+
throw new Error(
|
|
3783
|
+
"Error: Data source not found. Please ask the user to specify a valid data source."
|
|
3784
|
+
);
|
|
3785
|
+
let r, i = e.title || `Dashboard for ${n}`;
|
|
3786
|
+
if (e.id) {
|
|
3787
|
+
r = e.id;
|
|
3788
|
+
try {
|
|
3789
|
+
await pe(e.id, {
|
|
3790
|
+
title: i
|
|
3791
|
+
});
|
|
3792
|
+
const p = await Ur(
|
|
3793
|
+
r
|
|
3794
|
+
);
|
|
3795
|
+
p && await Promise.all(
|
|
3796
|
+
p.map(
|
|
3797
|
+
(O) => Wr(
|
|
3798
|
+
r,
|
|
3799
|
+
O.oid
|
|
3800
|
+
)
|
|
3801
|
+
)
|
|
3802
|
+
);
|
|
3803
|
+
} catch (p) {
|
|
3804
|
+
if ((p == null ? void 0 : p.status) === "404" || (p == null ? void 0 : p.status) === 404) {
|
|
3805
|
+
const O = await Te(
|
|
3806
|
+
i,
|
|
3807
|
+
a
|
|
3808
|
+
);
|
|
3809
|
+
if (!O)
|
|
3810
|
+
throw new Error("Error: Failed to create Fusion dashboard");
|
|
3811
|
+
r = O.oid, i = O.title;
|
|
3812
|
+
} else
|
|
3813
|
+
throw p;
|
|
3814
|
+
}
|
|
3815
|
+
} else {
|
|
3816
|
+
const p = await Te(
|
|
3817
|
+
i,
|
|
3818
|
+
a
|
|
3819
|
+
);
|
|
3820
|
+
if (!p)
|
|
3821
|
+
throw new Error("Error: Failed to create Fusion dashboard");
|
|
3822
|
+
r = p.oid, i = p.title;
|
|
3823
|
+
}
|
|
3824
|
+
const s = {
|
|
3825
|
+
...e,
|
|
3826
|
+
id: r,
|
|
3827
|
+
title: i
|
|
3828
|
+
}, l = await Jr(
|
|
3829
|
+
r,
|
|
3830
|
+
e.widgets
|
|
3831
|
+
), c = e.widgets.map((p, O) => {
|
|
3832
|
+
var C;
|
|
3833
|
+
return {
|
|
3834
|
+
...p,
|
|
3835
|
+
id: ((C = l[O]) == null ? void 0 : C.oid) ?? p.id,
|
|
3836
|
+
oldId: p.id
|
|
3837
|
+
};
|
|
3838
|
+
}), u = (d = e.layoutOptions) != null && d.widgetsPanel ? {
|
|
3839
|
+
...e.layoutOptions.widgetsPanel,
|
|
3840
|
+
columns: e.layoutOptions.widgetsPanel.columns.map(
|
|
3841
|
+
(p) => ({
|
|
3842
|
+
...p,
|
|
3843
|
+
rows: p.rows.map((O) => ({
|
|
3844
|
+
...O,
|
|
3845
|
+
cells: O.cells.map((C) => {
|
|
3846
|
+
var N;
|
|
3847
|
+
return {
|
|
3848
|
+
...C,
|
|
3849
|
+
widgetId: ((N = c.find(
|
|
3850
|
+
(pt) => pt.oldId === C.widgetId
|
|
3851
|
+
)) == null ? void 0 : N.id) || C.widgetId
|
|
3852
|
+
};
|
|
3853
|
+
})
|
|
3854
|
+
}))
|
|
3855
|
+
})
|
|
3856
|
+
)
|
|
3857
|
+
} : (m = e.layoutOptions) == null ? void 0 : m.widgetsPanel;
|
|
3858
|
+
return u && await pe(r, {
|
|
3859
|
+
layout: Hr(u)
|
|
3860
|
+
}), await Yr(
|
|
3861
|
+
r,
|
|
3862
|
+
e.filters ?? []
|
|
3863
|
+
), {
|
|
3864
|
+
...s,
|
|
3865
|
+
widgets: c,
|
|
3866
|
+
layoutOptions: { widgetsPanel: u }
|
|
3867
|
+
};
|
|
3868
|
+
}
|
|
3869
|
+
var Gr = function e(t, n) {
|
|
3870
|
+
if (t === n) return !0;
|
|
3871
|
+
if (t && n && typeof t == "object" && typeof n == "object") {
|
|
3872
|
+
if (t.constructor !== n.constructor) return !1;
|
|
3873
|
+
var a, r, i;
|
|
3874
|
+
if (Array.isArray(t)) {
|
|
3875
|
+
if (a = t.length, a != n.length) return !1;
|
|
3876
|
+
for (r = a; r-- !== 0; )
|
|
3877
|
+
if (!e(t[r], n[r])) return !1;
|
|
3878
|
+
return !0;
|
|
3879
|
+
}
|
|
3880
|
+
if (t.constructor === RegExp) return t.source === n.source && t.flags === n.flags;
|
|
3881
|
+
if (t.valueOf !== Object.prototype.valueOf) return t.valueOf() === n.valueOf();
|
|
3882
|
+
if (t.toString !== Object.prototype.toString) return t.toString() === n.toString();
|
|
3883
|
+
if (i = Object.keys(t), a = i.length, a !== Object.keys(n).length) return !1;
|
|
3884
|
+
for (r = a; r-- !== 0; )
|
|
3885
|
+
if (!Object.prototype.hasOwnProperty.call(n, i[r])) return !1;
|
|
3886
|
+
for (r = a; r-- !== 0; ) {
|
|
3887
|
+
var s = i[r];
|
|
3888
|
+
if (!e(t[s], n[s])) return !1;
|
|
3889
|
+
}
|
|
3890
|
+
return !0;
|
|
3891
|
+
}
|
|
3892
|
+
return t !== t && n !== n;
|
|
3893
|
+
};
|
|
3894
|
+
const Qr = /* @__PURE__ */ st(Gr);
|
|
3895
|
+
function Xr(e) {
|
|
3896
|
+
return e.columns.flatMap(
|
|
3897
|
+
(t) => t.rows.flatMap((n) => n.cells.map((a) => a.widgetId))
|
|
3898
|
+
);
|
|
3899
|
+
}
|
|
3900
|
+
function Kr(e, t) {
|
|
3901
|
+
const n = e.columns.map((a) => ({
|
|
3902
|
+
...a,
|
|
3903
|
+
rows: a.rows.map((r) => ({
|
|
3904
|
+
...r,
|
|
3905
|
+
cells: r.cells.filter(
|
|
3906
|
+
(i) => t.has(i.widgetId)
|
|
3907
|
+
)
|
|
3908
|
+
})).filter((r) => r.cells.length > 0)
|
|
3909
|
+
// Remove empty rows
|
|
3910
|
+
})).filter((a) => a.rows.length > 0);
|
|
3911
|
+
return n.length > 0 ? { columns: n } : { columns: [] };
|
|
3912
|
+
}
|
|
3913
|
+
function eo(e) {
|
|
3914
|
+
return e.columns.length === 1 ? {
|
|
3915
|
+
...e,
|
|
3916
|
+
columns: [
|
|
3917
|
+
{
|
|
3918
|
+
...e.columns[0],
|
|
3919
|
+
widthPercentage: 100
|
|
3920
|
+
}
|
|
3921
|
+
]
|
|
3922
|
+
} : e;
|
|
3923
|
+
}
|
|
3924
|
+
function to(e, t) {
|
|
3925
|
+
if (!t)
|
|
3926
|
+
return [];
|
|
3927
|
+
const n = Xr(t);
|
|
3928
|
+
return e.filter((a) => !n.includes(a.id)).map((a) => a.id);
|
|
3929
|
+
}
|
|
3930
|
+
function no(e) {
|
|
3931
|
+
var a, r;
|
|
3932
|
+
let t = { ...e };
|
|
3933
|
+
const n = to(
|
|
3934
|
+
t.widgets,
|
|
3935
|
+
(a = t.layoutOptions) == null ? void 0 : a.widgetsPanel
|
|
3936
|
+
);
|
|
3937
|
+
if (n.length > 0 && (t = ut(
|
|
3938
|
+
t,
|
|
3939
|
+
n
|
|
3940
|
+
)), (r = t.layoutOptions) != null && r.widgetsPanel) {
|
|
3941
|
+
const i = new Set(
|
|
3942
|
+
t.widgets.map((l) => l.id)
|
|
3943
|
+
);
|
|
3944
|
+
let s = Kr(
|
|
3945
|
+
t.layoutOptions.widgetsPanel,
|
|
3946
|
+
i
|
|
3947
|
+
);
|
|
3948
|
+
s = eo(s), t = {
|
|
3949
|
+
...t,
|
|
3950
|
+
layoutOptions: {
|
|
3951
|
+
...t.layoutOptions,
|
|
3952
|
+
widgetsPanel: s
|
|
3953
|
+
}
|
|
3954
|
+
};
|
|
3955
|
+
}
|
|
3956
|
+
return { changed: !0, updatedDashboardProps: t };
|
|
3957
|
+
}
|
|
3958
|
+
function ao(e, t) {
|
|
3959
|
+
return {
|
|
3960
|
+
changed: !0,
|
|
3961
|
+
updatedDashboardProps: {
|
|
3962
|
+
...e,
|
|
3963
|
+
filters: t
|
|
3964
|
+
}
|
|
3965
|
+
};
|
|
3966
|
+
}
|
|
3967
|
+
function ro(e, t) {
|
|
3968
|
+
var n;
|
|
3969
|
+
return {
|
|
3970
|
+
changed: !0,
|
|
3971
|
+
updatedDashboardProps: {
|
|
3972
|
+
...e,
|
|
3973
|
+
config: {
|
|
3974
|
+
...e.config,
|
|
3975
|
+
filtersPanel: {
|
|
3976
|
+
...(n = e.config) == null ? void 0 : n.filtersPanel,
|
|
3977
|
+
collapsedInitially: t
|
|
3978
|
+
}
|
|
3979
|
+
}
|
|
3980
|
+
}
|
|
3981
|
+
};
|
|
3982
|
+
}
|
|
3983
|
+
function oo(e, t) {
|
|
3984
|
+
var n;
|
|
3985
|
+
return Qr(t, (n = e.layoutOptions) == null ? void 0 : n.widgetsPanel) ? { changed: !1, updatedDashboardProps: e } : {
|
|
3986
|
+
changed: !0,
|
|
3987
|
+
updatedDashboardProps: {
|
|
3988
|
+
...e,
|
|
3989
|
+
layoutOptions: {
|
|
3990
|
+
...e.layoutOptions,
|
|
3991
|
+
widgetsPanel: t
|
|
3992
|
+
}
|
|
3993
|
+
}
|
|
3994
|
+
};
|
|
3995
|
+
}
|
|
3996
|
+
function io(e, t) {
|
|
3997
|
+
return {
|
|
3998
|
+
changed: !0,
|
|
3999
|
+
updatedDashboardProps: ut(
|
|
4000
|
+
e,
|
|
4001
|
+
t
|
|
4002
|
+
)
|
|
4003
|
+
};
|
|
4004
|
+
}
|
|
4005
|
+
function so(e, t) {
|
|
4006
|
+
var n, a, r;
|
|
4007
|
+
return {
|
|
4008
|
+
changed: !0,
|
|
4009
|
+
updatedDashboardProps: {
|
|
4010
|
+
...e,
|
|
4011
|
+
config: {
|
|
4012
|
+
...e.config,
|
|
4013
|
+
widgetsPanel: {
|
|
4014
|
+
...(n = e.config) == null ? void 0 : n.widgetsPanel,
|
|
4015
|
+
editMode: {
|
|
4016
|
+
...(r = (a = e.config) == null ? void 0 : a.widgetsPanel) == null ? void 0 : r.editMode,
|
|
4017
|
+
enabled: !0,
|
|
4018
|
+
isEditing: t
|
|
4019
|
+
}
|
|
4020
|
+
}
|
|
4021
|
+
}
|
|
4022
|
+
}
|
|
4023
|
+
};
|
|
4024
|
+
}
|
|
4025
|
+
function Vo(e) {
|
|
4026
|
+
const t = /* @__PURE__ */ new Map(), { widgets: n, defaultDataSource: a } = e;
|
|
4027
|
+
return a && se(a) && t.set(
|
|
4028
|
+
a.title,
|
|
4029
|
+
ie(a)
|
|
4030
|
+
), n.forEach((r) => {
|
|
4031
|
+
if ("dataSource" in r && r.dataSource && se(r.dataSource)) {
|
|
4032
|
+
const i = r.dataSource.title;
|
|
4033
|
+
t.has(i) || t.set(
|
|
4034
|
+
i,
|
|
4035
|
+
ie(r.dataSource)
|
|
4036
|
+
);
|
|
4037
|
+
}
|
|
4038
|
+
}), t;
|
|
4039
|
+
}
|
|
4040
|
+
function je(e) {
|
|
4041
|
+
return e.length === 1 ? {
|
|
4042
|
+
// use a 1-column layout
|
|
4043
|
+
columns: [
|
|
4044
|
+
{
|
|
4045
|
+
widthPercentage: 100,
|
|
4046
|
+
rows: e.map((n) => ({
|
|
4047
|
+
cells: [
|
|
4048
|
+
{
|
|
4049
|
+
widgetId: n,
|
|
4050
|
+
height: 384,
|
|
4051
|
+
widthPercentage: 100
|
|
4052
|
+
}
|
|
4053
|
+
]
|
|
4054
|
+
}))
|
|
4055
|
+
}
|
|
4056
|
+
]
|
|
4057
|
+
} : {
|
|
4058
|
+
// use a 2-column layout
|
|
4059
|
+
columns: [
|
|
4060
|
+
{
|
|
4061
|
+
widthPercentage: 50,
|
|
4062
|
+
rows: e.filter((n, a) => a % 2 === 0).map((n) => ({
|
|
4063
|
+
cells: [
|
|
4064
|
+
{
|
|
4065
|
+
widgetId: n,
|
|
4066
|
+
height: 384,
|
|
4067
|
+
widthPercentage: 100
|
|
4068
|
+
}
|
|
4069
|
+
]
|
|
4070
|
+
}))
|
|
4071
|
+
},
|
|
4072
|
+
{
|
|
4073
|
+
widthPercentage: 50,
|
|
4074
|
+
rows: e.filter((n, a) => a % 2 !== 0).map((n) => ({
|
|
4075
|
+
cells: [
|
|
4076
|
+
{
|
|
4077
|
+
widgetId: n,
|
|
4078
|
+
height: 384,
|
|
4079
|
+
widthPercentage: 100
|
|
4080
|
+
}
|
|
4081
|
+
]
|
|
4082
|
+
}))
|
|
4083
|
+
}
|
|
4084
|
+
]
|
|
4085
|
+
};
|
|
4086
|
+
}
|
|
4087
|
+
function lo(e, t) {
|
|
4088
|
+
const a = {
|
|
4089
|
+
cells: [{
|
|
4090
|
+
widthPercentage: 100,
|
|
4091
|
+
// Assuming the new cell takes the full width of the row
|
|
4092
|
+
height: "400px",
|
|
4093
|
+
widgetId: t
|
|
4094
|
+
}]
|
|
4095
|
+
};
|
|
4096
|
+
if (!e.columns || e.columns.length === 0)
|
|
4097
|
+
return {
|
|
4098
|
+
...e || { columns: [] },
|
|
4099
|
+
columns: [
|
|
4100
|
+
{
|
|
4101
|
+
widthPercentage: 100,
|
|
4102
|
+
rows: [a]
|
|
4103
|
+
}
|
|
4104
|
+
]
|
|
4105
|
+
};
|
|
4106
|
+
let r = e.columns[0].rows.length, i = 0;
|
|
4107
|
+
for (let s = 1; s < e.columns.length; s++)
|
|
4108
|
+
e.columns[s].rows.length < r && (r = e.columns[s].rows.length, i = s);
|
|
4109
|
+
return {
|
|
4110
|
+
...e || { columns: [] },
|
|
4111
|
+
columns: e.columns.map(
|
|
4112
|
+
(s, l) => l === i ? { ...s, rows: [...s.rows, a] } : s
|
|
4113
|
+
)
|
|
4114
|
+
};
|
|
4115
|
+
}
|
|
4116
|
+
function co() {
|
|
4117
|
+
return {
|
|
4118
|
+
toolbar: { visible: !0 },
|
|
4119
|
+
widgetsPanel: {
|
|
4120
|
+
responsive: !0,
|
|
4121
|
+
editMode: {
|
|
4122
|
+
enabled: !0,
|
|
4123
|
+
isEditing: !0,
|
|
4124
|
+
applyChangesAsBatch: {
|
|
4125
|
+
enabled: !1
|
|
4126
|
+
}
|
|
4127
|
+
}
|
|
4128
|
+
},
|
|
4129
|
+
filtersPanel: {
|
|
4130
|
+
visible: !0,
|
|
4131
|
+
collapsedInitially: !1,
|
|
4132
|
+
actions: {
|
|
4133
|
+
addFilter: {
|
|
4134
|
+
enabled: !0
|
|
4135
|
+
},
|
|
4136
|
+
editFilter: {
|
|
4137
|
+
enabled: !0
|
|
4138
|
+
},
|
|
4139
|
+
deleteFilter: {
|
|
4140
|
+
enabled: !0
|
|
4141
|
+
}
|
|
4142
|
+
}
|
|
4143
|
+
}
|
|
4144
|
+
};
|
|
4145
|
+
}
|
|
4146
|
+
function uo() {
|
|
4147
|
+
return {
|
|
4148
|
+
title: "Dashboard Title",
|
|
4149
|
+
widgets: [],
|
|
4150
|
+
layoutOptions: {},
|
|
4151
|
+
config: co(),
|
|
4152
|
+
filters: []
|
|
4153
|
+
};
|
|
4154
|
+
}
|
|
4155
|
+
async function po(e, t) {
|
|
4156
|
+
const n = await ct(e);
|
|
4157
|
+
if (!n)
|
|
4158
|
+
throw new Error(
|
|
4159
|
+
"Error: Data source not found. Please ask the user to specify a valid data source."
|
|
4160
|
+
);
|
|
4161
|
+
const a = Me(n);
|
|
4162
|
+
return {
|
|
4163
|
+
...uo(),
|
|
4164
|
+
title: t,
|
|
4165
|
+
defaultDataSource: a
|
|
4166
|
+
};
|
|
4167
|
+
}
|
|
4168
|
+
function Jo(e) {
|
|
4169
|
+
return {
|
|
4170
|
+
...e,
|
|
4171
|
+
id: me()
|
|
4172
|
+
};
|
|
4173
|
+
}
|
|
4174
|
+
function mo(e, t) {
|
|
4175
|
+
return {
|
|
4176
|
+
...e,
|
|
4177
|
+
widgets: [...e.widgets, ...t]
|
|
4178
|
+
};
|
|
4179
|
+
}
|
|
4180
|
+
function ho(e, t = []) {
|
|
4181
|
+
var i;
|
|
4182
|
+
const n = (i = e.layoutOptions) == null ? void 0 : i.widgetsPanel;
|
|
4183
|
+
let a = n || {
|
|
4184
|
+
columns: []
|
|
4185
|
+
};
|
|
4186
|
+
return !n || !n.columns || n.columns.length === 0 ? a = je(
|
|
4187
|
+
e.widgets.map((s) => s.id)
|
|
4188
|
+
) : (a || (a = je(
|
|
4189
|
+
e.widgets.map((s) => s.id)
|
|
4190
|
+
)), t.forEach((s) => {
|
|
4191
|
+
a = lo(a, s);
|
|
4192
|
+
})), {
|
|
4193
|
+
...e,
|
|
4194
|
+
layoutOptions: { widgetsPanel: a }
|
|
4195
|
+
};
|
|
4196
|
+
}
|
|
4197
|
+
function Yo(e, t) {
|
|
4198
|
+
return {
|
|
4199
|
+
...e,
|
|
4200
|
+
title: t
|
|
4201
|
+
};
|
|
4202
|
+
}
|
|
4203
|
+
async function Go(e, t, n = []) {
|
|
4204
|
+
const a = await po(
|
|
4205
|
+
e,
|
|
4206
|
+
t
|
|
4207
|
+
);
|
|
4208
|
+
return go(a, n);
|
|
4209
|
+
}
|
|
4210
|
+
function go(e, t) {
|
|
4211
|
+
if (t.length === 0)
|
|
4212
|
+
return e;
|
|
4213
|
+
const n = mo(
|
|
4214
|
+
e,
|
|
4215
|
+
t
|
|
4216
|
+
);
|
|
4217
|
+
return ho(
|
|
4218
|
+
n,
|
|
4219
|
+
t.map((r) => r.id)
|
|
4220
|
+
);
|
|
4221
|
+
}
|
|
4222
|
+
function ut(e, t) {
|
|
4223
|
+
return {
|
|
4224
|
+
...e,
|
|
4225
|
+
widgets: e.widgets.filter(
|
|
4226
|
+
(n) => !t.includes(n.id)
|
|
4227
|
+
)
|
|
4228
|
+
};
|
|
4229
|
+
}
|
|
4230
|
+
function fo(e, t) {
|
|
4231
|
+
switch (t.type) {
|
|
4232
|
+
case "filters/updated":
|
|
4233
|
+
return ao(e, t.payload);
|
|
4234
|
+
case "filtersPanel/collapse/changed":
|
|
4235
|
+
return ro(e, t.payload);
|
|
4236
|
+
case "widgetsPanel/layout/updated":
|
|
4237
|
+
return oo(
|
|
4238
|
+
e,
|
|
4239
|
+
t.payload
|
|
4240
|
+
);
|
|
4241
|
+
case "widgets/deleted":
|
|
4242
|
+
return io(e, t.payload);
|
|
4243
|
+
case "widgetsPanel/editMode/isEditing/changed":
|
|
4244
|
+
return so(
|
|
4245
|
+
e,
|
|
4246
|
+
t.payload
|
|
4247
|
+
);
|
|
4248
|
+
default:
|
|
4249
|
+
return { changed: !1, updatedDashboardProps: e };
|
|
4250
|
+
}
|
|
4251
|
+
}
|
|
4252
|
+
function Qo(e, t) {
|
|
4253
|
+
const { changed: n, updatedDashboardProps: a } = fo(
|
|
4254
|
+
e,
|
|
4255
|
+
t
|
|
4256
|
+
);
|
|
4257
|
+
return n ? no(a) : { changed: n, updatedDashboardProps: a };
|
|
4258
|
+
}
|
|
4259
|
+
async function Xo({ title: e }) {
|
|
4260
|
+
var r;
|
|
4261
|
+
const t = f(), n = {
|
|
4262
|
+
operationName: "createNewElasticube",
|
|
4263
|
+
variables: {
|
|
4264
|
+
title: e,
|
|
4265
|
+
type: "extract",
|
|
4266
|
+
relationType: "direct",
|
|
4267
|
+
experiments: {},
|
|
4268
|
+
buildDestination: {
|
|
4269
|
+
destination: "elasticube"
|
|
4270
|
+
}
|
|
4271
|
+
},
|
|
4272
|
+
query: `mutation createNewElasticube($title: String!, $type: ElasticubeType, $relationType: RelationType, $experiments: ExperimentsInput, $buildDestination: BuildDestinationInput, $fiscal: String) {
|
|
4273
|
+
newCube: createNewElasticube(
|
|
4274
|
+
title: $title
|
|
4275
|
+
type: $type
|
|
4276
|
+
relationType: $relationType
|
|
4277
|
+
experiments: $experiments
|
|
4278
|
+
buildDestination: $buildDestination
|
|
4279
|
+
fiscal: $fiscal
|
|
4280
|
+
) {
|
|
4281
|
+
oid
|
|
4282
|
+
title
|
|
4283
|
+
server
|
|
4284
|
+
type
|
|
4285
|
+
relationType
|
|
4286
|
+
lastBuildTime
|
|
4287
|
+
lastUpdated
|
|
4288
|
+
fiscal
|
|
4289
|
+
creator {
|
|
4290
|
+
id
|
|
4291
|
+
firstName
|
|
4292
|
+
lastName
|
|
4293
|
+
__typename
|
|
4294
|
+
}
|
|
4295
|
+
shares {
|
|
4296
|
+
partyId
|
|
4297
|
+
type
|
|
4298
|
+
... on ShareUserInfo {
|
|
4299
|
+
firstName
|
|
4300
|
+
lastName
|
|
4301
|
+
email
|
|
4302
|
+
__typename
|
|
4303
|
+
}
|
|
4304
|
+
... on ShareGroupInfo {
|
|
4305
|
+
name
|
|
4306
|
+
ad
|
|
4307
|
+
objectSid
|
|
4308
|
+
everyone
|
|
4309
|
+
tenantEveryone
|
|
4310
|
+
admins
|
|
4311
|
+
__typename
|
|
4312
|
+
}
|
|
4313
|
+
__typename
|
|
4314
|
+
}
|
|
4315
|
+
experiments {
|
|
4316
|
+
...experiments
|
|
4317
|
+
__typename
|
|
4318
|
+
}
|
|
4319
|
+
buildDestination {
|
|
4320
|
+
destination
|
|
4321
|
+
__typename
|
|
4322
|
+
}
|
|
4323
|
+
__typename
|
|
4324
|
+
}
|
|
4325
|
+
}
|
|
4326
|
+
|
|
4327
|
+
fragment experiments on Experiments {
|
|
4328
|
+
__typename
|
|
4329
|
+
}
|
|
4330
|
+
`
|
|
4331
|
+
};
|
|
4332
|
+
let a;
|
|
4333
|
+
try {
|
|
4334
|
+
a = await t.post(
|
|
4335
|
+
"/api/v2/ecm/",
|
|
4336
|
+
n
|
|
4337
|
+
);
|
|
4338
|
+
} catch (i) {
|
|
4339
|
+
throw console.error(i), new Error(i.message);
|
|
4340
|
+
}
|
|
4341
|
+
if (a != null && a.errors)
|
|
4342
|
+
throw new Error(a.errors[0].error.message);
|
|
4343
|
+
return (r = a == null ? void 0 : a.data) == null ? void 0 : r.newCube;
|
|
4344
|
+
}
|
|
4345
|
+
async function Ko({
|
|
4346
|
+
filePath: e,
|
|
4347
|
+
fileName: t
|
|
4348
|
+
}) {
|
|
4349
|
+
const n = {
|
|
4350
|
+
connection: {
|
|
4351
|
+
ApiVersion: 2,
|
|
4352
|
+
files: [e],
|
|
4353
|
+
delimiter: ",",
|
|
4354
|
+
hasHeader: !0,
|
|
4355
|
+
ignoreMissingColumns: !1,
|
|
4356
|
+
excludeIfBegins: "",
|
|
4357
|
+
excludeIfContains: "",
|
|
4358
|
+
stringQuote: '"',
|
|
4359
|
+
ignoreFirstRows: "",
|
|
4360
|
+
culture: "en-US",
|
|
4361
|
+
columnsDateTimePatterns: "{}",
|
|
4362
|
+
fileNames: [t]
|
|
4363
|
+
},
|
|
4364
|
+
schema: e,
|
|
4365
|
+
table: e.split("/").pop()
|
|
4366
|
+
};
|
|
4367
|
+
return await f().post(
|
|
4368
|
+
"/api/v1/live_connectors/CSV/table_schema_details",
|
|
4369
|
+
n
|
|
4370
|
+
) ?? null;
|
|
4371
|
+
}
|
|
4372
|
+
async function ei({
|
|
4373
|
+
elasticubeOid: e
|
|
4374
|
+
}) {
|
|
4375
|
+
return await f().get(
|
|
4376
|
+
`/api/v2/perspectives/getPerspectiveElasticubesAndLatestRevisionsByOid?parentOid=${e}`
|
|
4377
|
+
) ?? null;
|
|
4378
|
+
}
|
|
4379
|
+
async function ti({
|
|
4380
|
+
elasticubeOid: e,
|
|
4381
|
+
filePath: t,
|
|
4382
|
+
fileName: n,
|
|
4383
|
+
table: a,
|
|
4384
|
+
perspectiveOid: r
|
|
4385
|
+
}) {
|
|
4386
|
+
const i = t.split("/").pop(), s = (i == null ? void 0 : i.replace(".csv", "")) || "", l = n.replace(".csv", ""), { schemaName: c, columns: u } = a, d = u.map((C) => ({
|
|
4387
|
+
name: C.columnName,
|
|
4388
|
+
type: C.dbType,
|
|
4389
|
+
oid: le(),
|
|
4390
|
+
size: C.size,
|
|
4391
|
+
precision: C.precision,
|
|
4392
|
+
scale: C.scale,
|
|
4393
|
+
hidden: !1,
|
|
4394
|
+
indexed: !0,
|
|
4395
|
+
id: C.columnName
|
|
4396
|
+
})), m = {
|
|
4397
|
+
operationName: "addDataset",
|
|
4398
|
+
variables: {
|
|
4399
|
+
elasticubeOid: e,
|
|
4400
|
+
connection: {
|
|
4401
|
+
provider: "CSV",
|
|
4402
|
+
schema: t,
|
|
4403
|
+
parameters: {
|
|
4404
|
+
ApiVersion: 2,
|
|
4405
|
+
files: [t]
|
|
4406
|
+
},
|
|
4407
|
+
uiParams: {},
|
|
4408
|
+
globalTableConfigOptions: {
|
|
4409
|
+
datesPicker: {}
|
|
4410
|
+
},
|
|
4411
|
+
fileName: n
|
|
4412
|
+
},
|
|
4413
|
+
tables: [
|
|
4414
|
+
{
|
|
4415
|
+
id: i,
|
|
4416
|
+
name: l,
|
|
4417
|
+
oid: s,
|
|
4418
|
+
hidden: !1,
|
|
4419
|
+
schemaName: c,
|
|
4420
|
+
buildBehavior: {
|
|
4421
|
+
type: "sync"
|
|
4422
|
+
},
|
|
4423
|
+
columns: d,
|
|
4424
|
+
configOptions: {
|
|
4425
|
+
delimiter: ",",
|
|
4426
|
+
hasHeader: !0,
|
|
4427
|
+
ignoreMissingColumns: !1,
|
|
4428
|
+
excludeIfBegins: "",
|
|
4429
|
+
excludeIfContains: "",
|
|
4430
|
+
stringQuote: '"',
|
|
4431
|
+
ignoreFirstRows: "",
|
|
4432
|
+
culture: "en-US",
|
|
4433
|
+
columnsDateTimePatterns: "{}"
|
|
4434
|
+
},
|
|
4435
|
+
tupleTransformations: []
|
|
4436
|
+
}
|
|
4437
|
+
],
|
|
4438
|
+
suggestedOid: le(),
|
|
4439
|
+
schemaName: c,
|
|
4440
|
+
perspectiveOid: r,
|
|
4441
|
+
updatedPerspectiveData: {
|
|
4442
|
+
relationsTables: []
|
|
4443
|
+
}
|
|
4444
|
+
},
|
|
4445
|
+
query: `mutation addDataset($elasticubeOid: UUID!, $connection: ConnectionInput!, $tables: [TableInput!]!, $name: String, $suggestedOid: UUID!, $database: String, $schemaName: String, $perspectiveOid: UUID!, $updatedPerspectiveData: PerspectiveInput) {
|
|
4446
|
+
markTransactional(elasticubeOid: $elasticubeOid)
|
|
4447
|
+
dataset: addDatasetToElasticube(
|
|
4448
|
+
elasticubeOid: $elasticubeOid
|
|
4449
|
+
connection: $connection
|
|
4450
|
+
tables: $tables
|
|
4451
|
+
name: $name
|
|
4452
|
+
suggestedOid: $suggestedOid
|
|
4453
|
+
database: $database
|
|
4454
|
+
schemaName: $schemaName
|
|
4455
|
+
) {
|
|
4456
|
+
oid
|
|
4457
|
+
connection {
|
|
4458
|
+
oid
|
|
4459
|
+
protectedParameters
|
|
4460
|
+
__typename
|
|
4461
|
+
}
|
|
4462
|
+
__typename
|
|
4463
|
+
}
|
|
4464
|
+
updatePerspective(
|
|
4465
|
+
perspectiveOid: $perspectiveOid
|
|
4466
|
+
updatedPerspectiveData: $updatedPerspectiveData
|
|
4467
|
+
)
|
|
4468
|
+
}`
|
|
4469
|
+
};
|
|
4470
|
+
return { dataSet: await f().post(
|
|
4471
|
+
"/api/v2/ecm/",
|
|
4472
|
+
m
|
|
4473
|
+
), columns: d, tableOid: s };
|
|
4474
|
+
}
|
|
4475
|
+
async function ni({
|
|
4476
|
+
elasticubeOid: e
|
|
4477
|
+
}) {
|
|
4478
|
+
const t = {
|
|
4479
|
+
operationName: "buildElasticube",
|
|
4480
|
+
variables: {
|
|
4481
|
+
elasticubeOid: e,
|
|
4482
|
+
buildType: "restart"
|
|
4483
|
+
},
|
|
4484
|
+
query: `mutation buildElasticube($elasticubeOid: UUID!, $buildType: ElasticubeBuildType, $buildRows: Int) {
|
|
4485
|
+
buildElasticube(
|
|
4486
|
+
elasticubeOid: $elasticubeOid
|
|
4487
|
+
type: $buildType
|
|
4488
|
+
rows: $buildRows
|
|
4489
|
+
)
|
|
4490
|
+
}
|
|
4491
|
+
`
|
|
4492
|
+
};
|
|
4493
|
+
return await f().post(
|
|
4494
|
+
"/api/v2/ecm/",
|
|
4495
|
+
t
|
|
4496
|
+
) ?? null;
|
|
4497
|
+
}
|
|
4498
|
+
async function ai() {
|
|
4499
|
+
return await f().get(
|
|
4500
|
+
"/api/v2/builds"
|
|
4501
|
+
) ?? null;
|
|
4502
|
+
}
|
|
4503
|
+
async function ri({
|
|
4504
|
+
elasticubeOid: e,
|
|
4505
|
+
source: t,
|
|
4506
|
+
target: n
|
|
4507
|
+
}) {
|
|
4508
|
+
const a = {
|
|
4509
|
+
operationName: "addRelation",
|
|
4510
|
+
variables: {
|
|
4511
|
+
elasticubeOid: e,
|
|
4512
|
+
source: t,
|
|
4513
|
+
target: n,
|
|
4514
|
+
suggestedOid: le()
|
|
4515
|
+
},
|
|
4516
|
+
query: `mutation addRelation($elasticubeOid: UUID!, $source: RelationReferenceInput!, $target: RelationReferenceInput!, $suggestedOid: UUID!) {
|
|
4517
|
+
relation: addRelation(
|
|
4518
|
+
elasticubeOid: $elasticubeOid
|
|
4519
|
+
source: $source
|
|
4520
|
+
target: $target
|
|
4521
|
+
suggestedOid: $suggestedOid
|
|
4522
|
+
) {
|
|
4523
|
+
oid
|
|
4524
|
+
columns {
|
|
4525
|
+
column
|
|
4526
|
+
__typename
|
|
4527
|
+
}
|
|
4528
|
+
__typename
|
|
4529
|
+
}
|
|
4530
|
+
}
|
|
4531
|
+
`
|
|
4532
|
+
};
|
|
4533
|
+
return await f().post(
|
|
4534
|
+
"/api/v2/ecm/",
|
|
4535
|
+
a
|
|
4536
|
+
) ?? null;
|
|
4537
|
+
}
|
|
4538
|
+
async function oi() {
|
|
4539
|
+
var a;
|
|
4540
|
+
const e = f(), t = {
|
|
4541
|
+
operationName: "elasticubesMetadata",
|
|
4542
|
+
variables: { isViewMode: !1 },
|
|
4543
|
+
query: `query elasticubesMetadata($tenantFilter: String, $isViewMode: Boolean) {
|
|
4544
|
+
elasticubesMetadata(tenantFilter: $tenantFilter, isViewMode: $isViewMode) {
|
|
4545
|
+
...ecMetaData
|
|
4546
|
+
__typename
|
|
4547
|
+
}
|
|
4548
|
+
}
|
|
4549
|
+
|
|
4550
|
+
fragment ecMetaData on ElasticubeMetadata {
|
|
4551
|
+
oid
|
|
4552
|
+
title
|
|
4553
|
+
server
|
|
4554
|
+
tenant {
|
|
4555
|
+
_id
|
|
4556
|
+
name
|
|
4557
|
+
systemManagement
|
|
4558
|
+
__typename
|
|
4559
|
+
}
|
|
4560
|
+
fiscal
|
|
4561
|
+
serverId
|
|
4562
|
+
hasDatasets
|
|
4563
|
+
type
|
|
4564
|
+
relationType
|
|
4565
|
+
provider
|
|
4566
|
+
importTime
|
|
4567
|
+
hasDatasetsWithoutConnectionParameters
|
|
4568
|
+
datasets {
|
|
4569
|
+
oid
|
|
4570
|
+
database
|
|
4571
|
+
schemaName
|
|
4572
|
+
connection {
|
|
4573
|
+
id
|
|
4574
|
+
__typename
|
|
4575
|
+
}
|
|
4576
|
+
__typename
|
|
4577
|
+
}
|
|
4578
|
+
set {
|
|
4579
|
+
title
|
|
4580
|
+
__typename
|
|
4581
|
+
}
|
|
4582
|
+
status
|
|
4583
|
+
lastBuildTime
|
|
4584
|
+
lastBuildStatus
|
|
4585
|
+
lastSuccessfulBuildStartTime
|
|
4586
|
+
lastSuccessfulManualBuildStartTime
|
|
4587
|
+
lastSuccessfulBuildTime
|
|
4588
|
+
lastPublishTime
|
|
4589
|
+
lastUpdated
|
|
4590
|
+
hasPendingChanges
|
|
4591
|
+
nextBuildTime
|
|
4592
|
+
creator {
|
|
4593
|
+
id
|
|
4594
|
+
firstName
|
|
4595
|
+
lastName
|
|
4596
|
+
__typename
|
|
4597
|
+
}
|
|
4598
|
+
sizeInMb
|
|
4599
|
+
shares {
|
|
4600
|
+
partyId
|
|
4601
|
+
type
|
|
4602
|
+
permission
|
|
4603
|
+
... on ShareUserInfo {
|
|
4604
|
+
firstName
|
|
4605
|
+
lastName
|
|
4606
|
+
email
|
|
4607
|
+
__typename
|
|
4608
|
+
}
|
|
4609
|
+
... on ShareGroupInfo {
|
|
4610
|
+
name
|
|
4611
|
+
ad
|
|
4612
|
+
objectSid
|
|
4613
|
+
everyone
|
|
4614
|
+
tenantEveryone
|
|
4615
|
+
admins
|
|
4616
|
+
__typename
|
|
4617
|
+
}
|
|
4618
|
+
__typename
|
|
4619
|
+
}
|
|
4620
|
+
buildDestination {
|
|
4621
|
+
destination
|
|
4622
|
+
database
|
|
4623
|
+
schema
|
|
4624
|
+
resultLimit
|
|
4625
|
+
queryTimeout
|
|
4626
|
+
__typename
|
|
4627
|
+
}
|
|
4628
|
+
modelStatistics {
|
|
4629
|
+
enableModelStatistics
|
|
4630
|
+
allTablesPerCollection
|
|
4631
|
+
maxTablesPerCollection
|
|
4632
|
+
__typename
|
|
4633
|
+
}
|
|
4634
|
+
experiments {
|
|
4635
|
+
...experiments
|
|
4636
|
+
__typename
|
|
4637
|
+
}
|
|
4638
|
+
acceleration {
|
|
4639
|
+
parentModelOid
|
|
4640
|
+
__typename
|
|
4641
|
+
}
|
|
4642
|
+
analyticalEngine {
|
|
4643
|
+
queryAeMode
|
|
4644
|
+
customTranslationMode
|
|
4645
|
+
generateDependenciesMode
|
|
4646
|
+
__typename
|
|
4647
|
+
}
|
|
4648
|
+
__typename
|
|
4649
|
+
}
|
|
4650
|
+
|
|
4651
|
+
fragment experiments on Experiments {
|
|
4652
|
+
__typename
|
|
4653
|
+
}
|
|
4654
|
+
`
|
|
4655
|
+
}, n = await e.post(
|
|
4656
|
+
"/api/v2/ecm/",
|
|
4657
|
+
t
|
|
4658
|
+
);
|
|
4659
|
+
if (!((a = n == null ? void 0 : n.data) != null && a.elasticubesMetadata))
|
|
4660
|
+
throw new Error("Failed to get elasticubes list");
|
|
4661
|
+
return n.data.elasticubesMetadata;
|
|
4662
|
+
}
|
|
4663
|
+
async function ii({
|
|
4664
|
+
cubeOid: e
|
|
4665
|
+
}) {
|
|
4666
|
+
const t = f(), n = {
|
|
4667
|
+
operationName: "elasticubeByOid",
|
|
4668
|
+
variables: { cubeOid: e },
|
|
4669
|
+
query: `query elasticubeByOid($cubeOid: UUID!) {
|
|
4670
|
+
elasticube: elasticubeByOid(oid: $cubeOid) {
|
|
4671
|
+
...ecData
|
|
4672
|
+
__typename
|
|
4673
|
+
}
|
|
4674
|
+
}
|
|
4675
|
+
|
|
4676
|
+
fragment ecData on Elasticube {
|
|
4677
|
+
oid
|
|
4678
|
+
title
|
|
4679
|
+
server
|
|
4680
|
+
tenant {
|
|
4681
|
+
_id
|
|
4682
|
+
name
|
|
4683
|
+
systemManagement
|
|
4684
|
+
__typename
|
|
4685
|
+
}
|
|
4686
|
+
fiscal
|
|
4687
|
+
type
|
|
4688
|
+
relationType
|
|
4689
|
+
enableDimensionalModeling
|
|
4690
|
+
lastSuccessfulManualBuildStartTime
|
|
4691
|
+
lastBuildTime
|
|
4692
|
+
lastPublishTime
|
|
4693
|
+
hasDatasetsWithoutConnectionParameters
|
|
4694
|
+
datasets {
|
|
4695
|
+
oid
|
|
4696
|
+
name
|
|
4697
|
+
database
|
|
4698
|
+
schemaName
|
|
4699
|
+
lastUpdated
|
|
4700
|
+
type
|
|
4701
|
+
liveQuerySettings {
|
|
4702
|
+
timeout
|
|
4703
|
+
autoRefresh
|
|
4704
|
+
refreshRate
|
|
4705
|
+
resultLimit
|
|
4706
|
+
__typename
|
|
4707
|
+
}
|
|
4708
|
+
connection {
|
|
4709
|
+
id
|
|
4710
|
+
oid
|
|
4711
|
+
provider
|
|
4712
|
+
schema
|
|
4713
|
+
fileName
|
|
4714
|
+
parameters
|
|
4715
|
+
protectedParameters
|
|
4716
|
+
globalTableConfigOptions
|
|
4717
|
+
__typename
|
|
4718
|
+
}
|
|
4719
|
+
schema {
|
|
4720
|
+
tables {
|
|
4721
|
+
oid
|
|
4722
|
+
id
|
|
4723
|
+
name
|
|
4724
|
+
role
|
|
4725
|
+
isRoleBySystem
|
|
4726
|
+
description
|
|
4727
|
+
type
|
|
4728
|
+
tags
|
|
4729
|
+
hidden
|
|
4730
|
+
lastUpdated
|
|
4731
|
+
configOptions
|
|
4732
|
+
schemaName
|
|
4733
|
+
isMaterialized
|
|
4734
|
+
buildBehavior {
|
|
4735
|
+
type
|
|
4736
|
+
accumulativeConfig {
|
|
4737
|
+
type
|
|
4738
|
+
column
|
|
4739
|
+
lastDays
|
|
4740
|
+
keepOnlyDays
|
|
4741
|
+
__typename
|
|
4742
|
+
}
|
|
4743
|
+
__typename
|
|
4744
|
+
}
|
|
4745
|
+
columns {
|
|
4746
|
+
oid
|
|
4747
|
+
id
|
|
4748
|
+
name
|
|
4749
|
+
role
|
|
4750
|
+
isRoleBySystem
|
|
4751
|
+
description
|
|
4752
|
+
type
|
|
4753
|
+
size
|
|
4754
|
+
precision
|
|
4755
|
+
scale
|
|
4756
|
+
hidden
|
|
4757
|
+
indexed
|
|
4758
|
+
isUpsertBy
|
|
4759
|
+
__typename
|
|
4760
|
+
}
|
|
4761
|
+
expression {
|
|
4762
|
+
oid
|
|
4763
|
+
lastUpdated
|
|
4764
|
+
expression
|
|
4765
|
+
isDatabaseDialect
|
|
4766
|
+
__typename
|
|
4767
|
+
}
|
|
4768
|
+
customCode {
|
|
4769
|
+
noteBookId
|
|
4770
|
+
dependsOn
|
|
4771
|
+
additionalParameters
|
|
4772
|
+
codePath
|
|
4773
|
+
cellsDisable
|
|
4774
|
+
language
|
|
4775
|
+
mode
|
|
4776
|
+
serverUrl
|
|
4777
|
+
timeout
|
|
4778
|
+
__typename
|
|
4779
|
+
}
|
|
4780
|
+
tupleTransformations {
|
|
4781
|
+
type
|
|
4782
|
+
arguments
|
|
4783
|
+
__typename
|
|
4784
|
+
}
|
|
4785
|
+
__typename
|
|
4786
|
+
}
|
|
4787
|
+
__typename
|
|
4788
|
+
}
|
|
4789
|
+
__typename
|
|
4790
|
+
}
|
|
4791
|
+
relationsTables {
|
|
4792
|
+
firstTable
|
|
4793
|
+
secondTable
|
|
4794
|
+
directionType
|
|
4795
|
+
condition
|
|
4796
|
+
__typename
|
|
4797
|
+
}
|
|
4798
|
+
relations {
|
|
4799
|
+
oid
|
|
4800
|
+
columns {
|
|
4801
|
+
dataset
|
|
4802
|
+
table
|
|
4803
|
+
column
|
|
4804
|
+
isDropped
|
|
4805
|
+
__typename
|
|
4806
|
+
}
|
|
4807
|
+
__typename
|
|
4808
|
+
}
|
|
4809
|
+
experiments {
|
|
4810
|
+
...experiments
|
|
4811
|
+
__typename
|
|
4812
|
+
}
|
|
4813
|
+
buildDestination {
|
|
4814
|
+
destination
|
|
4815
|
+
database
|
|
4816
|
+
schema
|
|
4817
|
+
__typename
|
|
4818
|
+
}
|
|
4819
|
+
modelStatistics {
|
|
4820
|
+
enableModelStatistics
|
|
4821
|
+
allTablesPerCollection
|
|
4822
|
+
maxTablesPerCollection
|
|
4823
|
+
recollectStatsInterval
|
|
4824
|
+
__typename
|
|
4825
|
+
}
|
|
4826
|
+
__typename
|
|
4827
|
+
}
|
|
4828
|
+
|
|
4829
|
+
fragment experiments on Experiments {
|
|
4830
|
+
__typename
|
|
4831
|
+
}
|
|
4832
|
+
`
|
|
4833
|
+
};
|
|
4834
|
+
return await t.post(
|
|
4835
|
+
"/api/v2/ecm/",
|
|
4836
|
+
n
|
|
4837
|
+
) ?? null;
|
|
4838
|
+
}
|
|
4839
|
+
async function si({
|
|
4840
|
+
oid: e,
|
|
4841
|
+
replacementDataSource: t
|
|
4842
|
+
}) {
|
|
4843
|
+
const n = {
|
|
4844
|
+
operationName: "removeElasticubeByOid",
|
|
4845
|
+
variables: {
|
|
4846
|
+
oid: e,
|
|
4847
|
+
replacementDataSource: t
|
|
4848
|
+
},
|
|
4849
|
+
query: `mutation removeElasticubeByOid($oid: UUID!, $replacementDataSource: DataSourceInput) {
|
|
4850
|
+
removeElasticubeByOid(oid: $oid, replacementDataSource: $replacementDataSource)
|
|
4851
|
+
}
|
|
4852
|
+
`
|
|
4853
|
+
}, r = await f().post(
|
|
4854
|
+
"/api/v2/ecm/",
|
|
4855
|
+
n
|
|
4856
|
+
);
|
|
4857
|
+
if (!(r != null && r.data))
|
|
4858
|
+
throw new Error("Failed to delete elasticube");
|
|
4859
|
+
return r.data.removeElasticubeByOid;
|
|
4860
|
+
}
|
|
4861
|
+
async function bo(e, t) {
|
|
4862
|
+
const n = f(), a = new File([t], e, { type: "text/csv" }), r = {
|
|
4863
|
+
filename: e,
|
|
4864
|
+
size: a.size
|
|
4865
|
+
}, i = await n.post(
|
|
4866
|
+
"/storage/fs/validate_file",
|
|
4867
|
+
r
|
|
4868
|
+
);
|
|
4869
|
+
if (!(i != null && i.token))
|
|
4870
|
+
throw new Error("Failed to get file validation token");
|
|
4871
|
+
return { file: a, fileToken: i.token };
|
|
4872
|
+
}
|
|
4873
|
+
async function li(e, t) {
|
|
4874
|
+
const n = f(), { fileToken: a, file: r } = await bo(e, t), i = new FormData();
|
|
4875
|
+
i.append("file", r);
|
|
4876
|
+
const s = {
|
|
4877
|
+
Accept: "application/json",
|
|
4878
|
+
Internal: "true",
|
|
4879
|
+
"x-upload-token": a
|
|
4880
|
+
};
|
|
4881
|
+
n.auth.applyHeaders(s);
|
|
4882
|
+
const l = await fetch(`${n.url}/storage/fs/upload`, {
|
|
4883
|
+
method: "POST",
|
|
4884
|
+
headers: s,
|
|
4885
|
+
body: i,
|
|
4886
|
+
credentials: "include"
|
|
4887
|
+
});
|
|
4888
|
+
if (!l.ok)
|
|
4889
|
+
throw l.status === 403 ? new Error(
|
|
4890
|
+
"Sorry, file upload is not available for this instance as it's behind Cloudflare and we don't have a proper API for connection file upload"
|
|
4891
|
+
) : new Error("Failed to upload file");
|
|
4892
|
+
return await l.json();
|
|
4893
|
+
}
|
|
4894
|
+
async function ci() {
|
|
4895
|
+
return await f().get("api/globals");
|
|
4896
|
+
}
|
|
4897
|
+
const dt = "api/v2/settings/ai/llm";
|
|
4898
|
+
async function ui() {
|
|
4899
|
+
const t = await f().get(
|
|
4900
|
+
dt
|
|
4901
|
+
);
|
|
4902
|
+
if (!t)
|
|
4903
|
+
throw new Error("Failed to load LLM settings");
|
|
4904
|
+
return t;
|
|
4905
|
+
}
|
|
4906
|
+
async function di(e) {
|
|
4907
|
+
const t = f(), n = {
|
|
4908
|
+
provider: e.provider,
|
|
4909
|
+
model: e.model,
|
|
4910
|
+
baseUrl: e.baseUrl,
|
|
4911
|
+
apiKey: e.apiKey || "dummy-api-key",
|
|
4912
|
+
// API requires this field
|
|
4913
|
+
llmTerms: e.llmTerms,
|
|
4914
|
+
llmServices: e.llmServices,
|
|
4915
|
+
aiAssistant: e.aiAssistant
|
|
4916
|
+
};
|
|
4917
|
+
try {
|
|
4918
|
+
return await t.post(dt, n), e;
|
|
4919
|
+
} catch (a) {
|
|
4920
|
+
throw console.error("Error updating LLM settings:", a), a;
|
|
4921
|
+
}
|
|
4922
|
+
}
|
|
4923
|
+
export {
|
|
4924
|
+
be as DATA_SOURCES_API_URL_PATH,
|
|
4925
|
+
jr as TOOL_CONTEXT_MAX_ASSETS,
|
|
4926
|
+
Tr as TOOL_NAME_CHART_BUILDER,
|
|
4927
|
+
ko as TOOL_NAME_DASHBOARD_BUILDER,
|
|
4928
|
+
Eo as TOOL_NAME_DATA_MODEL_BUILDER,
|
|
4929
|
+
No as TOOL_NAME_GET_DASHBOARDS,
|
|
4930
|
+
Zo as TOOL_NAME_GET_DATA_SOURCES,
|
|
4931
|
+
Io as TOOL_NAME_GET_DATA_SOURCE_FIELDS,
|
|
4932
|
+
Mo as TOOL_NAME_RECOMMEND_QUERIES,
|
|
4933
|
+
ti as addDataSet,
|
|
4934
|
+
ri as addRelation,
|
|
4935
|
+
qr as addWidgetToFusionDashboard,
|
|
4936
|
+
mo as addWidgetsToDashboard,
|
|
4937
|
+
go as addWidgetsToExistingDashboard,
|
|
4938
|
+
Jr as addWidgetsToFusionDashboard,
|
|
4939
|
+
eo as adjustSingleColumnWidth,
|
|
4940
|
+
Sn as axesMapping,
|
|
4941
|
+
Lo as buildChartEngine,
|
|
4942
|
+
Do as buildChartSchema,
|
|
4943
|
+
ni as buildElasticube,
|
|
4944
|
+
ai as buildStatus,
|
|
4945
|
+
Qo as changeDashboard,
|
|
4946
|
+
J as chartDataOptionsSchemas,
|
|
4947
|
+
Cn as chartIdSchema,
|
|
4948
|
+
Dn as chartRecommendationsSchema,
|
|
4949
|
+
ee as chartType,
|
|
4950
|
+
no as cleanupDashboardAfterChange,
|
|
4951
|
+
Kr as cleanupOrphanedCells,
|
|
4952
|
+
_n as createChartSchema,
|
|
4953
|
+
Pa as createCustomFetch,
|
|
4954
|
+
Xo as createElasticube,
|
|
4955
|
+
po as createEmptyDashboard,
|
|
4956
|
+
Te as createEmptyFusionDashboard,
|
|
4957
|
+
Ye as createHttpClientFromAuthenticator,
|
|
4958
|
+
_a as createHttpClientFromConfig,
|
|
4959
|
+
Go as createNewDashboard,
|
|
4960
|
+
Ge as createOpenAIClient,
|
|
4961
|
+
xa as createOpenAIClientHelper,
|
|
4962
|
+
ge as createStructuredCompletion,
|
|
4963
|
+
$a as createToolsCompletion,
|
|
4964
|
+
S as dataOptionsEditingSchemas,
|
|
4965
|
+
si as deleteElasticube,
|
|
4966
|
+
Uo as deleteFusionDashboard,
|
|
4967
|
+
ut as deleteWidgetsFromDashboard,
|
|
4968
|
+
cn as excludeSchemaProperties,
|
|
4969
|
+
Xr as extractWidgetIdsFromLayout,
|
|
4970
|
+
re as filterSchemaProperties,
|
|
4971
|
+
to as findOutOfPlaceWidgets,
|
|
4972
|
+
La as generateChart,
|
|
4973
|
+
Fo as getAvailableFusionDashboards,
|
|
4974
|
+
kr as getBaseChartSummary,
|
|
4975
|
+
co as getBaseDashboardConfig,
|
|
4976
|
+
Ko as getCSVSchemaDetails,
|
|
4977
|
+
Vo as getDashboardDataSourcesMap,
|
|
4978
|
+
ct as getDataSourceByTitle,
|
|
4979
|
+
Lr as getDataSourceFields,
|
|
4980
|
+
Rr as getDataSourceFieldsWithDescriptions,
|
|
4981
|
+
Zr as getDataSourceSchema,
|
|
4982
|
+
Ro as getDataSources,
|
|
4983
|
+
ii as getElasticube,
|
|
4984
|
+
oi as getElasticubes,
|
|
4985
|
+
Fr as getFusionDashboardModel,
|
|
4986
|
+
Vr as getFusionDashboardProps,
|
|
4987
|
+
Bo as getFusionDashboardUrl,
|
|
4988
|
+
Ur as getFusionDashboardWidgets,
|
|
4989
|
+
Br as getFusionDashboards,
|
|
4990
|
+
f as getHttpClient,
|
|
4991
|
+
ui as getLlmSettings,
|
|
4992
|
+
$o as getNlqResult,
|
|
4993
|
+
Ea as getNlqResultLight,
|
|
4994
|
+
Ma as getNlqV3Result,
|
|
4995
|
+
zo as getNormalizedDataSourceFields,
|
|
4996
|
+
Ke as getOpenAIClient,
|
|
4997
|
+
ei as getPerspectiveOid,
|
|
4998
|
+
To as getQueryRecommendations,
|
|
4999
|
+
jo as getQueryRecommendationsLight,
|
|
5000
|
+
xo as initializeClients,
|
|
5001
|
+
Qe as initializeHttpClient,
|
|
5002
|
+
Xe as initializeOpenAIClient,
|
|
5003
|
+
Wo as isDashboardSaved,
|
|
5004
|
+
je as layoutDashboardWidgets,
|
|
5005
|
+
qo as loadExistingDashboardFromFusion,
|
|
5006
|
+
ci as loadGlobals,
|
|
5007
|
+
me as nanoidHex,
|
|
5008
|
+
le as nanoidUUIDv4,
|
|
5009
|
+
zr as normalizeFields,
|
|
5010
|
+
he as normalizeUrl,
|
|
5011
|
+
On as nullableChartType,
|
|
5012
|
+
_o as parseError,
|
|
5013
|
+
pe as patchFusionDashboard,
|
|
5014
|
+
Ho as persistDashboardToFusion,
|
|
5015
|
+
Po as resetHttpClient,
|
|
5016
|
+
Ao as resetOpenAIClient,
|
|
5017
|
+
Jo as resetWidgetForDashboard,
|
|
5018
|
+
L as updateChartSchema,
|
|
5019
|
+
$n as updateChartSortingSchema,
|
|
5020
|
+
kn as updateChartStyleOptionsSchema,
|
|
5021
|
+
Pn as updateChartTitleSchema,
|
|
5022
|
+
xn as updateChartTypeOfMeasuresSchema,
|
|
5023
|
+
An as updateChartTypeSchema,
|
|
5024
|
+
Yo as updateDashboardTitle,
|
|
5025
|
+
ho as updateDashboardWidgetsLayout,
|
|
5026
|
+
Yr as updateFusionDashboardFilters,
|
|
5027
|
+
di as updateLlmSettings,
|
|
5028
|
+
jn as updateOtherChartDataOptionsSchema,
|
|
5029
|
+
Tn as updateTrendAndForecastSchema,
|
|
5030
|
+
li as uploadCSVMultipart,
|
|
5031
|
+
lo as withWidgetAdded,
|
|
5032
|
+
un as zodFunction,
|
|
5033
|
+
P as zodToReadableType
|
|
5034
|
+
};
|
|
5035
|
+
//# sourceMappingURL=index.js.map
|