@lightdash/common 2.255.0 → 2.255.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/ee/AiAgent/schemas/tools/mcpDocumentContent.d.ts +2 -2
- package/dist/cjs/ee/AiAgent/schemas/tools/mcpDocumentContent.js +3 -3
- package/dist/cjs/ee/AiAgent/schemas/tools/mcpDocumentContent.js.map +1 -1
- package/dist/cjs/ee/AiAgent/schemas/tools/toolDefinitions.d.ts +2 -2
- package/dist/cjs/ee/AiAgent/schemas/tools/toolDefinitions.js +1 -1
- package/dist/cjs/index.d.ts +0 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +0 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/content.d.ts +3 -3
- package/dist/cjs/types/content.d.ts.map +1 -1
- package/dist/cjs/types/document.d.ts +11 -61
- package/dist/cjs/types/document.d.ts.map +1 -1
- package/dist/cjs/utils/document.d.ts +3 -3
- package/dist/cjs/utils/document.d.ts.map +1 -1
- package/dist/cjs/utils/document.js +20 -85
- package/dist/cjs/utils/document.js.map +1 -1
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/ee/AiAgent/schemas/tools/mcpDocumentContent.d.ts +2 -2
- package/dist/esm/ee/AiAgent/schemas/tools/mcpDocumentContent.js +3 -3
- package/dist/esm/ee/AiAgent/schemas/tools/mcpDocumentContent.js.map +1 -1
- package/dist/esm/ee/AiAgent/schemas/tools/toolDefinitions.d.ts +2 -2
- package/dist/esm/ee/AiAgent/schemas/tools/toolDefinitions.js +1 -1
- package/dist/esm/index.d.ts +0 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/content.d.ts +3 -3
- package/dist/esm/types/content.d.ts.map +1 -1
- package/dist/esm/types/document.d.ts +11 -61
- package/dist/esm/types/document.d.ts.map +1 -1
- package/dist/esm/utils/document.d.ts +3 -3
- package/dist/esm/utils/document.d.ts.map +1 -1
- package/dist/esm/utils/document.js +20 -85
- package/dist/esm/utils/document.js.map +1 -1
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/ee/AiAgent/schemas/tools/mcpDocumentContent.d.ts +2 -2
- package/dist/types/ee/AiAgent/schemas/tools/mcpDocumentContent.js +3 -3
- package/dist/types/ee/AiAgent/schemas/tools/mcpDocumentContent.js.map +1 -1
- package/dist/types/ee/AiAgent/schemas/tools/toolDefinitions.d.ts +2 -2
- package/dist/types/ee/AiAgent/schemas/tools/toolDefinitions.js +1 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +0 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/types/content.d.ts +3 -3
- package/dist/types/types/content.d.ts.map +1 -1
- package/dist/types/types/document.d.ts +11 -61
- package/dist/types/types/document.d.ts.map +1 -1
- package/dist/types/utils/document.d.ts +3 -3
- package/dist/types/utils/document.d.ts.map +1 -1
- package/dist/types/utils/document.js +20 -85
- package/dist/types/utils/document.js.map +1 -1
- package/package.json +1 -1
- package/dist/cjs/utils/documentOperations.d.ts +0 -3
- package/dist/cjs/utils/documentOperations.d.ts.map +0 -1
- package/dist/cjs/utils/documentOperations.js +0 -60
- package/dist/cjs/utils/documentOperations.js.map +0 -1
- package/dist/esm/utils/documentOperations.d.ts +0 -3
- package/dist/esm/utils/documentOperations.d.ts.map +0 -1
- package/dist/esm/utils/documentOperations.js +0 -55
- package/dist/esm/utils/documentOperations.js.map +0 -1
- package/dist/types/utils/documentOperations.d.ts +0 -3
- package/dist/types/utils/documentOperations.d.ts.map +0 -1
- package/dist/types/utils/documentOperations.js +0 -55
- package/dist/types/utils/documentOperations.js.map +0 -1
|
@@ -7,7 +7,7 @@ const chart_as_code_1_0_json_1 = tslib_1.__importDefault(require("../schemas/jso
|
|
|
7
7
|
const errors_1 = require("../types/errors");
|
|
8
8
|
const mergeQuery_1 = require("../types/mergeQuery");
|
|
9
9
|
const savedCharts_1 = require("../types/savedCharts");
|
|
10
|
-
exports.DOCUMENT_SCHEMA_VERSION =
|
|
10
|
+
exports.DOCUMENT_SCHEMA_VERSION = 1;
|
|
11
11
|
const getDocumentUrl = (projectUuid, documentUuid) => `/projects/${projectUuid}/documents/${documentUuid}`;
|
|
12
12
|
exports.getDocumentUrl = getDocumentUrl;
|
|
13
13
|
const chartProperties = {
|
|
@@ -35,11 +35,9 @@ const chartSchema = (merge) => ({
|
|
|
35
35
|
...(merge ? ['merge'] : []),
|
|
36
36
|
],
|
|
37
37
|
});
|
|
38
|
-
let
|
|
39
|
-
let titledValidator;
|
|
40
|
-
let currentValidator;
|
|
38
|
+
let contentValidator;
|
|
41
39
|
// Lazy compilation keeps importing common safe under browser CSP.
|
|
42
|
-
const createValidator = (
|
|
40
|
+
const createValidator = () => new ajv_1.default({
|
|
43
41
|
strict: false,
|
|
44
42
|
validateFormats: false,
|
|
45
43
|
}).compile({
|
|
@@ -53,13 +51,8 @@ const createValidator = (schemaVersion) => new ajv_1.default({
|
|
|
53
51
|
items: {
|
|
54
52
|
type: 'object',
|
|
55
53
|
additionalProperties: false,
|
|
56
|
-
required: ['
|
|
54
|
+
required: ['type', 'content'],
|
|
57
55
|
properties: {
|
|
58
|
-
id: {
|
|
59
|
-
type: 'string',
|
|
60
|
-
minLength: 1,
|
|
61
|
-
pattern: '\\S',
|
|
62
|
-
},
|
|
63
56
|
type: { enum: ['markdown', 'chart'] },
|
|
64
57
|
content: {},
|
|
65
58
|
},
|
|
@@ -67,24 +60,14 @@ const createValidator = (schemaVersion) => new ajv_1.default({
|
|
|
67
60
|
{
|
|
68
61
|
properties: {
|
|
69
62
|
type: { const: 'markdown' },
|
|
70
|
-
content:
|
|
71
|
-
|
|
72
|
-
:
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
properties: {
|
|
77
|
-
markdown: { type: 'string' },
|
|
78
|
-
...(schemaVersion === 2
|
|
79
|
-
? {
|
|
80
|
-
title: {
|
|
81
|
-
type: 'string',
|
|
82
|
-
pattern: '\\S',
|
|
83
|
-
},
|
|
84
|
-
}
|
|
85
|
-
: {}),
|
|
86
|
-
},
|
|
63
|
+
content: {
|
|
64
|
+
type: 'object',
|
|
65
|
+
additionalProperties: false,
|
|
66
|
+
required: ['markdown'],
|
|
67
|
+
properties: {
|
|
68
|
+
markdown: { type: 'string' },
|
|
87
69
|
},
|
|
70
|
+
},
|
|
88
71
|
},
|
|
89
72
|
},
|
|
90
73
|
{
|
|
@@ -96,14 +79,6 @@ const createValidator = (schemaVersion) => new ajv_1.default({
|
|
|
96
79
|
additionalProperties: false,
|
|
97
80
|
required: ['source', 'chart'],
|
|
98
81
|
properties: {
|
|
99
|
-
...(schemaVersion === 2
|
|
100
|
-
? {
|
|
101
|
-
title: {
|
|
102
|
-
type: 'string',
|
|
103
|
-
pattern: '\\S',
|
|
104
|
-
},
|
|
105
|
-
}
|
|
106
|
-
: {}),
|
|
107
82
|
source: {
|
|
108
83
|
const: merge
|
|
109
84
|
? 'merge'
|
|
@@ -120,55 +95,15 @@ const createValidator = (schemaVersion) => new ajv_1.default({
|
|
|
120
95
|
},
|
|
121
96
|
},
|
|
122
97
|
});
|
|
123
|
-
const validateContent = (validate, raw) => {
|
|
124
|
-
if (!validate(raw)) {
|
|
125
|
-
throw new errors_1.ParameterError(`Invalid Document content: ${validate.errors?.map((error) => `${error.instancePath} ${error.message}`).join('; ')}`);
|
|
126
|
-
}
|
|
127
|
-
return raw;
|
|
128
|
-
};
|
|
129
|
-
const readContent = (schemaVersion, raw) => {
|
|
130
|
-
if (schemaVersion === 1) {
|
|
131
|
-
legacyValidator ?? (legacyValidator = createValidator(1));
|
|
132
|
-
const legacy = validateContent(legacyValidator, raw);
|
|
133
|
-
return {
|
|
134
|
-
cells: legacy.cells.map((cell) => cell.type === 'markdown'
|
|
135
|
-
? { ...cell, content: { markdown: cell.content } }
|
|
136
|
-
: { ...cell, content: { ...cell.content } }),
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
if (schemaVersion === 2) {
|
|
140
|
-
titledValidator ?? (titledValidator = createValidator(2));
|
|
141
|
-
const legacy = validateContent(titledValidator, raw);
|
|
142
|
-
return {
|
|
143
|
-
cells: legacy.cells.map((cell) => cell.type === 'markdown'
|
|
144
|
-
? { ...cell, content: { markdown: cell.content.markdown } }
|
|
145
|
-
: {
|
|
146
|
-
...cell,
|
|
147
|
-
content: cell.content.source === 'semantic'
|
|
148
|
-
? {
|
|
149
|
-
source: 'semantic',
|
|
150
|
-
chart: cell.content.chart,
|
|
151
|
-
}
|
|
152
|
-
: {
|
|
153
|
-
source: 'merge',
|
|
154
|
-
chart: cell.content.chart,
|
|
155
|
-
},
|
|
156
|
-
}),
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
if (schemaVersion === exports.DOCUMENT_SCHEMA_VERSION) {
|
|
160
|
-
currentValidator ?? (currentValidator = createValidator(3));
|
|
161
|
-
return validateContent(currentValidator, raw);
|
|
162
|
-
}
|
|
163
|
-
throw new errors_1.ParameterError(`Unsupported Document schema version: ${schemaVersion}`);
|
|
164
|
-
};
|
|
165
98
|
const parseDocumentContent = (schemaVersion, raw) => {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
if (new Set(ids).size !== ids.length) {
|
|
169
|
-
throw new errors_1.ParameterError('Document cell IDs must be unique');
|
|
99
|
+
if (schemaVersion !== exports.DOCUMENT_SCHEMA_VERSION) {
|
|
100
|
+
throw new errors_1.ParameterError(`Unsupported Document schema version: ${schemaVersion}`);
|
|
170
101
|
}
|
|
171
|
-
|
|
102
|
+
contentValidator ?? (contentValidator = createValidator());
|
|
103
|
+
if (!contentValidator(raw)) {
|
|
104
|
+
throw new errors_1.ParameterError(`Invalid Document content: ${contentValidator.errors?.map((error) => `${error.instancePath} ${error.message}`).join('; ')}`);
|
|
105
|
+
}
|
|
106
|
+
raw.cells.forEach((cell, cellIndex) => {
|
|
172
107
|
if (cell.type !== 'chart') {
|
|
173
108
|
return;
|
|
174
109
|
}
|
|
@@ -192,11 +127,11 @@ const parseDocumentContent = (schemaVersion, raw) => {
|
|
|
192
127
|
if (merge.sources.some((source) => 'queryUuid' in source) ||
|
|
193
128
|
merge.sources.length !== 2 ||
|
|
194
129
|
!(0, mergeQuery_1.parseSavedMergeQuery)(mergeQuery_1.SAVED_MERGE_QUERY_SCHEMA_VERSION, merge)) {
|
|
195
|
-
throw new errors_1.ParameterError(`Invalid merge sources or join keys in cell ${
|
|
130
|
+
throw new errors_1.ParameterError(`Invalid merge sources or join keys in cell ${cellIndex}`);
|
|
196
131
|
}
|
|
197
132
|
}
|
|
198
133
|
});
|
|
199
|
-
return
|
|
134
|
+
return raw;
|
|
200
135
|
};
|
|
201
136
|
exports.parseDocumentContent = parseDocumentContent;
|
|
202
137
|
//# sourceMappingURL=document.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.js","sourceRoot":"","sources":["../../../src/utils/document.ts"],"names":[],"mappings":";;;;AAAA,sDAAiD;AACjD,4GAAuE;
|
|
1
|
+
{"version":3,"file":"document.js","sourceRoot":"","sources":["../../../src/utils/document.ts"],"names":[],"mappings":";;;;AAAA,sDAAiD;AACjD,4GAAuE;AAEvE,4CAAiD;AACjD,oDAG6B;AAC7B,sDAAiD;AAEpC,QAAA,uBAAuB,GAAG,CAAC,CAAC;AAElC,MAAM,cAAc,GAAG,CAC1B,WAAmB,EACnB,YAAoB,EACd,EAAE,CAAC,aAAa,WAAW,cAAc,YAAY,EAAE,CAAC;AAHrD,QAAA,cAAc,GAAd,cAAc,CAGuC;AAElE,MAAM,eAAe,GAAG;IACpB,IAAI,EAAE,gCAAiB,CAAC,UAAU,CAAC,IAAI;IACvC,WAAW,EAAE,gCAAiB,CAAC,UAAU,CAAC,WAAW;IACrD,SAAS,EAAE,gCAAiB,CAAC,UAAU,CAAC,SAAS;IACjD,WAAW,EAAE,gCA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