@rebasepro/inference 0.9.1-canary.f2f61da → 0.9.1-canary.fd3754b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.umd.cjs +470 -0
- package/dist/index.umd.cjs.map +1 -0
- package/package.json +7 -6
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
(function(global, factory) {
|
|
2
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("@rebasepro/utils"), require("@rebasepro/types")) : typeof define === "function" && define.amd ? define([
|
|
3
|
+
"exports",
|
|
4
|
+
"@rebasepro/utils",
|
|
5
|
+
"@rebasepro/types"
|
|
6
|
+
], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["Rebase schema inference"] = {}, global._rebasepro_utils, global._rebasepro_types));
|
|
7
|
+
})(this, function(exports, _rebasepro_utils, _rebasepro_types) {
|
|
8
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
9
|
+
//#region src/strings.ts
|
|
10
|
+
/**
|
|
11
|
+
* Parse a reference string value which can be in the format:
|
|
12
|
+
* - Simple: "path/entityId"
|
|
13
|
+
* - With database: "database_name:::path/entityId"
|
|
14
|
+
* Returns the path and database (undefined if not specified or if "(default)")
|
|
15
|
+
*/
|
|
16
|
+
function parseReferenceString(value) {
|
|
17
|
+
if (!value) return null;
|
|
18
|
+
let database = void 0;
|
|
19
|
+
let fullPath = value;
|
|
20
|
+
if (value.includes(":::")) {
|
|
21
|
+
const [dbName, pathPart] = value.split(":::");
|
|
22
|
+
if (dbName && dbName !== "(default)") database = dbName;
|
|
23
|
+
fullPath = pathPart;
|
|
24
|
+
}
|
|
25
|
+
if (!fullPath || !fullPath.includes("/")) return null;
|
|
26
|
+
return {
|
|
27
|
+
path: fullPath.substring(0, fullPath.lastIndexOf("/")),
|
|
28
|
+
database
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Check if a string value looks like a reference
|
|
33
|
+
*/
|
|
34
|
+
function looksLikeReference(value) {
|
|
35
|
+
if (typeof value !== "string") return false;
|
|
36
|
+
return parseReferenceString(value) !== null;
|
|
37
|
+
}
|
|
38
|
+
function findCommonInitialStringInPath(valuesCount) {
|
|
39
|
+
if (!valuesCount) return void 0;
|
|
40
|
+
function getPath(value) {
|
|
41
|
+
let pathString;
|
|
42
|
+
if (typeof value === "string") pathString = value;
|
|
43
|
+
else if (value && typeof value === "object" && "slug" in value && typeof value.slug === "string") pathString = value.slug;
|
|
44
|
+
else {
|
|
45
|
+
console.warn("findCommonInitialStringInPath: value is not a string or document with path", value);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (!pathString) return void 0;
|
|
49
|
+
if (pathString.includes(":::")) {
|
|
50
|
+
const [, pathPart] = pathString.split(":::");
|
|
51
|
+
pathString = pathPart;
|
|
52
|
+
}
|
|
53
|
+
return pathString;
|
|
54
|
+
}
|
|
55
|
+
const pathWithSlash = valuesCount.values.map((v) => getPath(v)).filter((v) => !!v).find((s) => s.includes("/"));
|
|
56
|
+
if (!pathWithSlash) return void 0;
|
|
57
|
+
const searchedPath = pathWithSlash.substring(0, pathWithSlash.lastIndexOf("/"));
|
|
58
|
+
return valuesCount.values.filter((value) => {
|
|
59
|
+
const path = getPath(value);
|
|
60
|
+
if (!path) return false;
|
|
61
|
+
return path.startsWith(searchedPath);
|
|
62
|
+
}).length > valuesCount.values.length / 3 * 2 ? searchedPath : void 0;
|
|
63
|
+
}
|
|
64
|
+
function removeInitialAndTrailingSlashes(s) {
|
|
65
|
+
return removeInitialSlash(removeTrailingSlash(s));
|
|
66
|
+
}
|
|
67
|
+
function removeInitialSlash(s) {
|
|
68
|
+
if (s.startsWith("/")) return s.slice(1);
|
|
69
|
+
else return s;
|
|
70
|
+
}
|
|
71
|
+
function removeTrailingSlash(s) {
|
|
72
|
+
if (s.endsWith("/")) return s.slice(0, -1);
|
|
73
|
+
else return s;
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region src/util.ts
|
|
77
|
+
/**
|
|
78
|
+
* Extract enum values from a list of sample values.
|
|
79
|
+
* This is inference-specific logic (not a general utility).
|
|
80
|
+
*/
|
|
81
|
+
function extractEnumFromValues(values) {
|
|
82
|
+
if (!Array.isArray(values)) return [];
|
|
83
|
+
const enumValues = values.map((value) => {
|
|
84
|
+
if (typeof value === "string") return {
|
|
85
|
+
id: value,
|
|
86
|
+
label: (0, _rebasepro_utils.unslugify)(value)
|
|
87
|
+
};
|
|
88
|
+
else return null;
|
|
89
|
+
}).filter(Boolean);
|
|
90
|
+
enumValues.sort((a, b) => a.label.localeCompare(b.label));
|
|
91
|
+
return enumValues;
|
|
92
|
+
}
|
|
93
|
+
function resolveEnumValues(input) {
|
|
94
|
+
if (Array.isArray(input)) return input;
|
|
95
|
+
else if (typeof input === "object" && input !== null) return Object.entries(input).map(([id, value]) => typeof value === "string" ? {
|
|
96
|
+
id,
|
|
97
|
+
label: value
|
|
98
|
+
} : value);
|
|
99
|
+
else return;
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region src/builders/string_property_builder.ts
|
|
103
|
+
var IMAGE_EXTENSIONS = [
|
|
104
|
+
".jpg",
|
|
105
|
+
".jpeg",
|
|
106
|
+
".png",
|
|
107
|
+
".webp",
|
|
108
|
+
".gif",
|
|
109
|
+
".avif"
|
|
110
|
+
];
|
|
111
|
+
var AUDIO_EXTENSIONS = [
|
|
112
|
+
".mp3",
|
|
113
|
+
".ogg",
|
|
114
|
+
".opus",
|
|
115
|
+
".aac"
|
|
116
|
+
];
|
|
117
|
+
var VIDEO_EXTENSIONS = [".avi", ".mp4"];
|
|
118
|
+
var emailRegEx = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
|
|
119
|
+
function buildStringProperty({ name, totalDocsCount, valuesResult }) {
|
|
120
|
+
let stringProperty = {
|
|
121
|
+
name: name ?? "",
|
|
122
|
+
type: "string"
|
|
123
|
+
};
|
|
124
|
+
if (valuesResult) {
|
|
125
|
+
const totalEntriesCount = valuesResult.values.length;
|
|
126
|
+
const totalValues = Array.from(valuesResult.valuesCount.keys()).length;
|
|
127
|
+
const config = {};
|
|
128
|
+
const probablyAURL = valuesResult.values.filter((value) => typeof value === "string" && value.toString().startsWith("http")).length > totalDocsCount / 3 * 2;
|
|
129
|
+
if (probablyAURL) config.ui = { url: true };
|
|
130
|
+
const probablyAnEmail = valuesResult.values.filter((value) => typeof value === "string" && emailRegEx.test(value)).length > totalDocsCount / 3 * 2;
|
|
131
|
+
if (probablyAnEmail) config.email = true;
|
|
132
|
+
const probablyUserIds = valuesResult.values.filter((value) => typeof value === "string" && value.length === 28 && !value.includes(" ")).length > totalDocsCount / 3 * 2;
|
|
133
|
+
if (probablyUserIds) config.ui = {
|
|
134
|
+
...config.ui,
|
|
135
|
+
readOnly: true
|
|
136
|
+
};
|
|
137
|
+
if (!probablyAnEmail && !probablyAURL && !probablyUserIds && !probablyAURL && totalValues < totalEntriesCount / 3) {
|
|
138
|
+
const enumValues = extractEnumFromValues(Array.from(valuesResult.valuesCount.keys()));
|
|
139
|
+
if (Object.keys(enumValues).length > 1) config.enum = enumValues;
|
|
140
|
+
}
|
|
141
|
+
if (!probablyAnEmail && !probablyAURL && !probablyUserIds && !probablyAURL && !config.enum) {
|
|
142
|
+
const fileType = probableFileType(valuesResult, totalDocsCount);
|
|
143
|
+
if (fileType) config.storage = {
|
|
144
|
+
acceptedFiles: fileType,
|
|
145
|
+
storagePath: findCommonInitialStringInPath(valuesResult) ?? "/"
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
if (Object.keys(config).length > 0) stringProperty = {
|
|
149
|
+
...stringProperty,
|
|
150
|
+
...config
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
return stringProperty;
|
|
154
|
+
}
|
|
155
|
+
function probableFileType(valuesCount, totalDocsCount) {
|
|
156
|
+
const isImage = (value) => IMAGE_EXTENSIONS.some((extension) => value.toString().endsWith(extension));
|
|
157
|
+
const isAudio = (value) => AUDIO_EXTENSIONS.some((extension) => value.toString().endsWith(extension));
|
|
158
|
+
const isVideo = (value) => VIDEO_EXTENSIONS.some((extension) => value.toString().endsWith(extension));
|
|
159
|
+
const stringValues = valuesCount.values.filter((v) => typeof v === "string");
|
|
160
|
+
let imageCount = 0;
|
|
161
|
+
let audioCount = 0;
|
|
162
|
+
let videoCount = 0;
|
|
163
|
+
for (const value of stringValues) if (isImage(value)) imageCount++;
|
|
164
|
+
else if (isAudio(value)) audioCount++;
|
|
165
|
+
else if (isVideo(value)) videoCount++;
|
|
166
|
+
if (imageCount + audioCount + videoCount > totalDocsCount * 2 / 3) {
|
|
167
|
+
const fileTypes = [];
|
|
168
|
+
if (imageCount > 0) fileTypes.push("image/*");
|
|
169
|
+
if (audioCount > 0) fileTypes.push("audio/*");
|
|
170
|
+
if (videoCount > 0) fileTypes.push("video/*");
|
|
171
|
+
return fileTypes.length > 0 ? fileTypes : false;
|
|
172
|
+
}
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
//#endregion
|
|
176
|
+
//#region src/builders/validation_builder.ts
|
|
177
|
+
function buildValidation({ totalDocsCount, valuesResult }) {
|
|
178
|
+
if (valuesResult) {
|
|
179
|
+
if (totalDocsCount === valuesResult.values.length) return { required: true };
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
//#endregion
|
|
183
|
+
//#region src/builders/reference_property_builder.ts
|
|
184
|
+
function buildReferenceProperty({ name, totalDocsCount, valuesResult }) {
|
|
185
|
+
return {
|
|
186
|
+
name: name ?? "",
|
|
187
|
+
type: "reference",
|
|
188
|
+
path: findCommonInitialStringInPath(valuesResult) ?? "!!!FIX_ME!!!"
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
//#endregion
|
|
192
|
+
//#region src/collection_builder.ts
|
|
193
|
+
async function buildEntityPropertiesFromData(data, getType) {
|
|
194
|
+
const typesCount = {};
|
|
195
|
+
const valuesCount = {};
|
|
196
|
+
if (data) data.forEach((entry) => {
|
|
197
|
+
if (entry) Object.entries(entry).forEach(([key, value]) => {
|
|
198
|
+
if (key.startsWith("_")) return;
|
|
199
|
+
increaseMapTypeCount(typesCount, key, value, getType);
|
|
200
|
+
increaseValuesCount(valuesCount, key, value, getType);
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
return buildPropertiesFromCount(data.length, typesCount, valuesCount);
|
|
204
|
+
}
|
|
205
|
+
function buildPropertyFromData(data, property, getType) {
|
|
206
|
+
const typesCount = {};
|
|
207
|
+
const valuesCount = {};
|
|
208
|
+
if (data) data.forEach((entry) => {
|
|
209
|
+
increaseTypeCount(property.type, typesCount, entry, getType);
|
|
210
|
+
increaseValuesCount(valuesCount, "inferred_prop", entry, getType);
|
|
211
|
+
});
|
|
212
|
+
const enumValues = "enum" in property ? resolveEnumValues(property["enum"]) : void 0;
|
|
213
|
+
if (enumValues) {
|
|
214
|
+
const newEnumValues = extractEnumFromValues(Array.from(valuesCount["inferred_prop"].valuesCount.keys()));
|
|
215
|
+
return {
|
|
216
|
+
...property,
|
|
217
|
+
enum: [...newEnumValues, ...enumValues]
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
return (0, _rebasepro_utils.mergeDeep)(buildPropertyFromCount("inferred_prop", data.length, property.type, typesCount, valuesCount["inferred_prop"]), property);
|
|
221
|
+
}
|
|
222
|
+
function buildPropertiesOrder(properties, propertiesOrder, priorityKeys) {
|
|
223
|
+
const lowerCasePriorityKeys = (priorityKeys ?? []).map((key) => key.toLowerCase());
|
|
224
|
+
function propOrder(s) {
|
|
225
|
+
const k = s.toLowerCase();
|
|
226
|
+
if (lowerCasePriorityKeys.includes(k)) return 4;
|
|
227
|
+
if (k === "title" || k === "name") return 3;
|
|
228
|
+
if (k.includes("title") || k.includes("name")) return 2;
|
|
229
|
+
if (k.includes("image") || k.includes("picture")) return 1;
|
|
230
|
+
return 0;
|
|
231
|
+
}
|
|
232
|
+
const keys = propertiesOrder ?? Object.keys(properties);
|
|
233
|
+
keys.sort();
|
|
234
|
+
keys.sort((a, b) => {
|
|
235
|
+
return propOrder(b) - propOrder(a);
|
|
236
|
+
});
|
|
237
|
+
return keys;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* @param type
|
|
241
|
+
* @param typesCount
|
|
242
|
+
* @param fieldValue
|
|
243
|
+
* @param getType
|
|
244
|
+
*/
|
|
245
|
+
function increaseTypeCount(type, typesCount, fieldValue, getType) {
|
|
246
|
+
if (type === "map") {
|
|
247
|
+
if (fieldValue) {
|
|
248
|
+
let mapTypesCount = typesCount[type];
|
|
249
|
+
if (!mapTypesCount) {
|
|
250
|
+
mapTypesCount = {};
|
|
251
|
+
typesCount[type] = mapTypesCount;
|
|
252
|
+
}
|
|
253
|
+
Object.entries(fieldValue).forEach(([key, value]) => {
|
|
254
|
+
increaseMapTypeCount(mapTypesCount, key, value, getType);
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
} else if (type === "array") {
|
|
258
|
+
let arrayTypesCount = typesCount[type];
|
|
259
|
+
if (!arrayTypesCount) {
|
|
260
|
+
arrayTypesCount = {};
|
|
261
|
+
typesCount[type] = arrayTypesCount;
|
|
262
|
+
}
|
|
263
|
+
if (fieldValue && Array.isArray(fieldValue) && fieldValue.length > 0) {
|
|
264
|
+
const arrayType = getMostProbableTypeInArray(fieldValue, getType);
|
|
265
|
+
if (arrayType === "map") {
|
|
266
|
+
let mapTypesCount = arrayTypesCount[arrayType];
|
|
267
|
+
if (!mapTypesCount) mapTypesCount = {};
|
|
268
|
+
fieldValue.forEach((value) => {
|
|
269
|
+
if (value && typeof value === "object" && !Array.isArray(value)) Object.entries(value).forEach(([key, v]) => increaseMapTypeCount(mapTypesCount, key, v, getType));
|
|
270
|
+
});
|
|
271
|
+
arrayTypesCount[arrayType] = mapTypesCount;
|
|
272
|
+
} else if (!arrayTypesCount[arrayType]) arrayTypesCount[arrayType] = 1;
|
|
273
|
+
else arrayTypesCount[arrayType] = Number(arrayTypesCount[arrayType]) + 1;
|
|
274
|
+
}
|
|
275
|
+
} else if (!typesCount[type]) typesCount[type] = 1;
|
|
276
|
+
else typesCount[type] = Number(typesCount[type]) + 1;
|
|
277
|
+
}
|
|
278
|
+
function increaseMapTypeCount(typesCountRecord, key, fieldValue, getType) {
|
|
279
|
+
if (key.startsWith("_")) return;
|
|
280
|
+
let typesCount = typesCountRecord[key];
|
|
281
|
+
if (!typesCount) {
|
|
282
|
+
typesCount = {};
|
|
283
|
+
typesCountRecord[key] = typesCount;
|
|
284
|
+
}
|
|
285
|
+
if (fieldValue != null) increaseTypeCount(getType(fieldValue), typesCount, fieldValue, getType);
|
|
286
|
+
}
|
|
287
|
+
function increaseValuesCount(typeValuesRecord, key, fieldValue, getType) {
|
|
288
|
+
if (key.startsWith("_")) return;
|
|
289
|
+
const type = getType(fieldValue);
|
|
290
|
+
let valuesRecord = typeValuesRecord[key];
|
|
291
|
+
if (!valuesRecord) {
|
|
292
|
+
valuesRecord = {
|
|
293
|
+
values: [],
|
|
294
|
+
valuesCount: /* @__PURE__ */ new Map()
|
|
295
|
+
};
|
|
296
|
+
typeValuesRecord[key] = valuesRecord;
|
|
297
|
+
}
|
|
298
|
+
if (type === "map") {
|
|
299
|
+
let mapValuesRecord = valuesRecord.map;
|
|
300
|
+
if (!mapValuesRecord) {
|
|
301
|
+
mapValuesRecord = {};
|
|
302
|
+
valuesRecord.map = mapValuesRecord;
|
|
303
|
+
}
|
|
304
|
+
if (fieldValue) Object.entries(fieldValue).forEach(([subKey, value]) => increaseValuesCount(mapValuesRecord, subKey, value, getType));
|
|
305
|
+
} else if (type === "array") {
|
|
306
|
+
if (Array.isArray(fieldValue)) fieldValue.forEach((value) => {
|
|
307
|
+
valuesRecord.values.push(value);
|
|
308
|
+
valuesRecord.valuesCount.set(value, (valuesRecord.valuesCount.get(value) ?? 0) + 1);
|
|
309
|
+
});
|
|
310
|
+
} else if (fieldValue !== null && fieldValue !== void 0) {
|
|
311
|
+
valuesRecord.values.push(fieldValue);
|
|
312
|
+
valuesRecord.valuesCount.set(fieldValue, (valuesRecord.valuesCount.get(fieldValue) ?? 0) + 1);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
function getHighestTypesCount(typesCount) {
|
|
316
|
+
let highestCount = 0;
|
|
317
|
+
Object.entries(typesCount).forEach(([type, count]) => {
|
|
318
|
+
let countValue = 0;
|
|
319
|
+
if (type === "map") countValue = getHighestRecordCount(count);
|
|
320
|
+
else if (type === "array") countValue = getHighestTypesCount(count);
|
|
321
|
+
else countValue = Number(count);
|
|
322
|
+
if (countValue > highestCount) highestCount = countValue;
|
|
323
|
+
});
|
|
324
|
+
return highestCount;
|
|
325
|
+
}
|
|
326
|
+
function getHighestRecordCount(record) {
|
|
327
|
+
return Object.entries(record).map(([key, typesCount]) => getHighestTypesCount(typesCount)).reduce((a, b) => Math.max(a, b), 0);
|
|
328
|
+
}
|
|
329
|
+
function getMostProbableType(typesCount) {
|
|
330
|
+
let highestCount = -1;
|
|
331
|
+
let probableType = "string";
|
|
332
|
+
Object.entries(typesCount).forEach(([type, count]) => {
|
|
333
|
+
let countValue;
|
|
334
|
+
if (type === "map") countValue = getHighestRecordCount(count);
|
|
335
|
+
else if (type === "array") countValue = getHighestTypesCount(count);
|
|
336
|
+
else countValue = Number(count);
|
|
337
|
+
if (countValue > highestCount) {
|
|
338
|
+
highestCount = countValue;
|
|
339
|
+
probableType = type;
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
return probableType;
|
|
343
|
+
}
|
|
344
|
+
function buildPropertyFromCount(key, totalDocsCount, mostProbableType, typesCount, valuesResult) {
|
|
345
|
+
let title;
|
|
346
|
+
if (key) title = (0, _rebasepro_utils.prettifyIdentifier)(key);
|
|
347
|
+
let result = void 0;
|
|
348
|
+
if (mostProbableType === "map") {
|
|
349
|
+
if (checkTypesCountHighVariability(typesCount)) result = {
|
|
350
|
+
type: "map",
|
|
351
|
+
name: title ?? key ?? "",
|
|
352
|
+
keyValue: true,
|
|
353
|
+
properties: {}
|
|
354
|
+
};
|
|
355
|
+
const properties = buildPropertiesFromCount(totalDocsCount, typesCount.map, valuesResult ? valuesResult.mapValues : void 0);
|
|
356
|
+
result = {
|
|
357
|
+
type: "map",
|
|
358
|
+
name: title ?? key ?? "",
|
|
359
|
+
properties
|
|
360
|
+
};
|
|
361
|
+
} else if (mostProbableType === "array") {
|
|
362
|
+
const arrayTypesCount = typesCount.array;
|
|
363
|
+
const of = buildPropertyFromCount(key, totalDocsCount, getMostProbableType(arrayTypesCount), arrayTypesCount, valuesResult);
|
|
364
|
+
result = {
|
|
365
|
+
type: "array",
|
|
366
|
+
name: title ?? key ?? "",
|
|
367
|
+
of
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
if (!result) {
|
|
371
|
+
const propertyProps = {
|
|
372
|
+
name: key,
|
|
373
|
+
totalDocsCount,
|
|
374
|
+
valuesResult
|
|
375
|
+
};
|
|
376
|
+
if (mostProbableType === "string") result = buildStringProperty(propertyProps);
|
|
377
|
+
else if (mostProbableType === "reference") result = buildReferenceProperty(propertyProps);
|
|
378
|
+
else result = { type: mostProbableType };
|
|
379
|
+
if (title) result.name = title;
|
|
380
|
+
const validation = buildValidation(propertyProps);
|
|
381
|
+
if (validation) result.validation = validation;
|
|
382
|
+
}
|
|
383
|
+
return result;
|
|
384
|
+
}
|
|
385
|
+
function buildPropertiesFromCount(totalDocsCount, typesCountRecord, valuesCountRecord) {
|
|
386
|
+
const res = {};
|
|
387
|
+
Object.entries(typesCountRecord).forEach(([key, typesCount]) => {
|
|
388
|
+
res[key] = buildPropertyFromCount(key, totalDocsCount, getMostProbableType(typesCount), typesCount, valuesCountRecord ? valuesCountRecord[key] : void 0);
|
|
389
|
+
});
|
|
390
|
+
return res;
|
|
391
|
+
}
|
|
392
|
+
function countMaxDocumentsUnder(typesCount) {
|
|
393
|
+
let count = 0;
|
|
394
|
+
Object.entries(typesCount).forEach(([type, value]) => {
|
|
395
|
+
if (typeof value === "object") count = Math.max(count, countMaxDocumentsUnder(value));
|
|
396
|
+
else count = Math.max(count, Number(value));
|
|
397
|
+
});
|
|
398
|
+
return count;
|
|
399
|
+
}
|
|
400
|
+
function getMostProbableTypeInArray(array, getType) {
|
|
401
|
+
const typesCount = {};
|
|
402
|
+
array.forEach((value) => {
|
|
403
|
+
increaseTypeCount(getType(value), typesCount, value, getType);
|
|
404
|
+
});
|
|
405
|
+
return getMostProbableType(typesCount);
|
|
406
|
+
}
|
|
407
|
+
function checkTypesCountHighVariability(typesCount) {
|
|
408
|
+
const maxCount = countMaxDocumentsUnder(typesCount);
|
|
409
|
+
let keysWithFewValues = 0;
|
|
410
|
+
Object.entries(typesCount.map ?? {}).forEach(([key, value]) => {
|
|
411
|
+
if (countMaxDocumentsUnder(value) < maxCount / 3) keysWithFewValues++;
|
|
412
|
+
});
|
|
413
|
+
return keysWithFewValues / Object.entries(typesCount.map ?? {}).length > .5;
|
|
414
|
+
}
|
|
415
|
+
function inferTypeFromValue(value) {
|
|
416
|
+
if (value === null || value === void 0) return "string";
|
|
417
|
+
if (value instanceof _rebasepro_types.Vector || value && typeof value === "object" && "__type" in value && value.__type === "Vector") return "vector";
|
|
418
|
+
if (typeof value === "string") return "string";
|
|
419
|
+
if (typeof value === "number") return "number";
|
|
420
|
+
if (typeof value === "boolean") return "boolean";
|
|
421
|
+
if (Array.isArray(value)) return "array";
|
|
422
|
+
if (typeof value === "object") return "map";
|
|
423
|
+
return "string";
|
|
424
|
+
}
|
|
425
|
+
//#endregion
|
|
426
|
+
exports.buildEntityPropertiesFromData = buildEntityPropertiesFromData;
|
|
427
|
+
exports.buildPropertiesOrder = buildPropertiesOrder;
|
|
428
|
+
exports.buildPropertyFromData = buildPropertyFromData;
|
|
429
|
+
exports.extractEnumFromValues = extractEnumFromValues;
|
|
430
|
+
exports.findCommonInitialStringInPath = findCommonInitialStringInPath;
|
|
431
|
+
exports.inferTypeFromValue = inferTypeFromValue;
|
|
432
|
+
Object.defineProperty(exports, "isObject", {
|
|
433
|
+
enumerable: true,
|
|
434
|
+
get: function() {
|
|
435
|
+
return _rebasepro_utils.isObject;
|
|
436
|
+
}
|
|
437
|
+
});
|
|
438
|
+
Object.defineProperty(exports, "isPlainObject", {
|
|
439
|
+
enumerable: true,
|
|
440
|
+
get: function() {
|
|
441
|
+
return _rebasepro_utils.isPlainObject;
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
exports.looksLikeReference = looksLikeReference;
|
|
445
|
+
Object.defineProperty(exports, "mergeDeep", {
|
|
446
|
+
enumerable: true,
|
|
447
|
+
get: function() {
|
|
448
|
+
return _rebasepro_utils.mergeDeep;
|
|
449
|
+
}
|
|
450
|
+
});
|
|
451
|
+
exports.parseReferenceString = parseReferenceString;
|
|
452
|
+
Object.defineProperty(exports, "prettifyIdentifier", {
|
|
453
|
+
enumerable: true,
|
|
454
|
+
get: function() {
|
|
455
|
+
return _rebasepro_utils.prettifyIdentifier;
|
|
456
|
+
}
|
|
457
|
+
});
|
|
458
|
+
exports.removeInitialAndTrailingSlashes = removeInitialAndTrailingSlashes;
|
|
459
|
+
exports.removeInitialSlash = removeInitialSlash;
|
|
460
|
+
exports.removeTrailingSlash = removeTrailingSlash;
|
|
461
|
+
exports.resolveEnumValues = resolveEnumValues;
|
|
462
|
+
Object.defineProperty(exports, "unslugify", {
|
|
463
|
+
enumerable: true,
|
|
464
|
+
get: function() {
|
|
465
|
+
return _rebasepro_utils.unslugify;
|
|
466
|
+
}
|
|
467
|
+
});
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
//# sourceMappingURL=index.umd.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.umd.cjs","names":[],"sources":["../src/strings.ts","../src/util.ts","../src/builders/string_property_builder.ts","../src/builders/validation_builder.ts","../src/builders/reference_property_builder.ts","../src/collection_builder.ts"],"sourcesContent":["import { ValuesCountEntry } from \"./types\";\n\n/**\n * Parse a reference string value which can be in the format:\n * - Simple: \"path/entityId\"\n * - With database: \"database_name:::path/entityId\"\n * Returns the path and database (undefined if not specified or if \"(default)\")\n */\nexport function parseReferenceString(value: string): { path: string; database?: string } | null {\n if (!value) return null;\n\n let database: string | undefined = undefined;\n let fullPath = value;\n\n // Parse the new format: database_name:::path/entityId\n if (value.includes(\":::\")) {\n const [dbName, pathPart] = value.split(\":::\");\n if (dbName && dbName !== \"(default)\") {\n database = dbName;\n }\n fullPath = pathPart;\n }\n\n // Check if it looks like a path (contains at least one slash)\n if (!fullPath || !fullPath.includes(\"/\")) {\n return null;\n }\n\n // Extract the collection path (everything before the last slash)\n const path = fullPath.substring(0, fullPath.lastIndexOf(\"/\"));\n\n return { path,\ndatabase };\n}\n\n/**\n * Check if a string value looks like a reference\n */\nexport function looksLikeReference(value: unknown): boolean {\n if (typeof value !== \"string\") return false;\n return parseReferenceString(value) !== null;\n}\n\nexport function findCommonInitialStringInPath(valuesCount?: ValuesCountEntry) {\n\n if (!valuesCount) return undefined;\n\n function getPath(value: unknown): string | undefined {\n let pathString: string | undefined;\n\n if (typeof value === \"string\") {\n pathString = value;\n } else if (value && typeof value === \"object\" && \"slug\" in value && typeof (value as Record<string, unknown>).slug === \"string\") {\n pathString = (value as Record<string, unknown>).slug as string;\n } else {\n console.warn(\"findCommonInitialStringInPath: value is not a string or document with path\", value);\n return undefined;\n }\n\n if (!pathString) return undefined;\n\n // Parse the new format: database_name:::path/entityId\n // Extract just the path portion for comparison\n if (pathString.includes(\":::\")) {\n const [, pathPart] = pathString.split(\":::\");\n pathString = pathPart;\n }\n\n return pathString;\n }\n\n const strings: string[] = valuesCount.values.map((v) => getPath(v)).filter(v => !!v) as string[];\n const pathWithSlash = strings.find((s) => s.includes(\"/\"));\n if (!pathWithSlash)\n return undefined;\n\n const searchedPath = pathWithSlash.substring(0, pathWithSlash.lastIndexOf(\"/\"));\n\n const yep = valuesCount.values\n .filter((value) => {\n const path = getPath(value);\n if (!path) return false;\n return path.startsWith(searchedPath)\n }).length > valuesCount.values.length / 3 * 2;\n\n return yep ? searchedPath : undefined;\n\n}\n\nexport function removeInitialAndTrailingSlashes(s: string): string {\n return removeInitialSlash(removeTrailingSlash(s));\n}\n\nexport function removeInitialSlash(s: string) {\n if (s.startsWith(\"/\"))\n return s.slice(1);\n else return s;\n}\n\nexport function removeTrailingSlash(s: string) {\n if (s.endsWith(\"/\"))\n return s.slice(0, -1);\n else return s;\n}\n","import { EnumValueConfig, EnumValues } from \"@rebasepro/types\";\nimport { unslugify } from \"@rebasepro/utils\";\n\n// Canonical utility functions — single source of truth in @rebasepro/utils\nexport { unslugify, prettifyIdentifier, isObject, isPlainObject, mergeDeep } from \"@rebasepro/utils\";\n\n/**\n * Extract enum values from a list of sample values.\n * This is inference-specific logic (not a general utility).\n */\nexport function extractEnumFromValues(values: unknown[]) {\n if (!Array.isArray(values)) {\n return [];\n }\n const enumValues = values\n .map((value) => {\n if (typeof value === \"string\") {\n return ({\n id: value,\n label: unslugify(value)\n });\n } else\n return null;\n }).filter(Boolean) as Array<{ id: string, label: string }>;\n enumValues.sort((a, b) => a.label.localeCompare(b.label));\n return enumValues;\n}\n\nexport function resolveEnumValues(input: EnumValues): EnumValueConfig[] | undefined {\n // Check Array.isArray first since typeof [] === \"object\" is true in JavaScript\n if (Array.isArray(input)) {\n return input as EnumValueConfig[];\n } else if (typeof input === \"object\" && input !== null) {\n return Object.entries(input).map(([id, value]) =>\n (typeof value === \"string\"\n ? {\n id,\n label: value\n }\n : value));\n } else {\n return undefined;\n }\n}\n","import { findCommonInitialStringInPath } from \"../strings\";\nimport { extractEnumFromValues } from \"../util\";\nimport { FileType, Property, StringProperty } from \"@rebasepro/types\";\nimport { InferencePropertyBuilderProps, ValuesCountEntry } from \"../types\";\n\nconst IMAGE_EXTENSIONS = [\".jpg\", \".jpeg\", \".png\", \".webp\", \".gif\", \".avif\"];\nconst AUDIO_EXTENSIONS = [\".mp3\", \".ogg\", \".opus\", \".aac\"];\nconst VIDEO_EXTENSIONS = [\".avi\", \".mp4\"];\n\nconst emailRegEx = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;\n\nexport function buildStringProperty({\n name,\n totalDocsCount,\n valuesResult\n}: InferencePropertyBuilderProps): Property {\n\n let stringProperty: Property = {\n name: name ?? \"\",\n type: \"string\"\n\n };\n\n if (valuesResult) {\n\n const totalEntriesCount = valuesResult.values.length;\n const totalValues = Array.from(valuesResult.valuesCount.keys()).length;\n\n const config: Partial<StringProperty> = {};\n\n const probablyAURL = valuesResult.values\n .filter((value) => typeof value === \"string\" &&\n value.toString().startsWith(\"http\")).length > totalDocsCount / 3 * 2;\n if (probablyAURL) {\n config.ui = { url: true };\n }\n\n const probablyAnEmail = valuesResult.values\n .filter((value) => typeof value === \"string\" &&\n emailRegEx.test(value)).length > totalDocsCount / 3 * 2;\n if (probablyAnEmail) {\n config.email = true;\n }\n\n const probablyUserIds = valuesResult.values\n .filter((value) => typeof value === \"string\" && value.length === 28 && !value.includes(\" \"))\n .length > totalDocsCount / 3 * 2;\n if (probablyUserIds)\n config.ui = { ...config.ui,\nreadOnly: true };\n\n if (!probablyAnEmail &&\n !probablyAURL &&\n !probablyUserIds &&\n !probablyAURL &&\n totalValues < totalEntriesCount / 3\n ) {\n const enumValues = extractEnumFromValues(Array.from(valuesResult.valuesCount.keys()));\n\n if (Object.keys(enumValues).length > 1)\n config.enum = enumValues;\n }\n\n // regular string\n if (!probablyAnEmail &&\n !probablyAURL &&\n !probablyUserIds &&\n !probablyAURL &&\n !config.enum) {\n const fileType = probableFileType(valuesResult, totalDocsCount);\n if (fileType) {\n config.storage = {\n acceptedFiles: fileType as FileType[],\n storagePath: findCommonInitialStringInPath(valuesResult) ?? \"/\"\n };\n }\n }\n\n if (Object.keys(config).length > 0)\n stringProperty = {\n ...stringProperty,\n ...config\n } as StringProperty;\n }\n\n return stringProperty;\n}\n\nfunction probableFileType(valuesCount: ValuesCountEntry, totalDocsCount: number): false | FileType[] {\n const isImage = (value: string) => IMAGE_EXTENSIONS.some((extension) => value.toString().endsWith(extension));\n const isAudio = (value: string) => AUDIO_EXTENSIONS.some((extension) => value.toString().endsWith(extension));\n const isVideo = (value: string) => VIDEO_EXTENSIONS.some((extension) => value.toString().endsWith(extension));\n\n const stringValues = valuesCount.values.filter((v): v is string => typeof v === \"string\");\n\n let imageCount = 0;\n let audioCount = 0;\n let videoCount = 0;\n\n for (const value of stringValues) {\n if (isImage(value)) imageCount++;\n else if (isAudio(value)) audioCount++;\n else if (isVideo(value)) videoCount++;\n }\n\n const totalMediaCount = imageCount + audioCount + videoCount;\n if (totalMediaCount > (totalDocsCount * 2) / 3) {\n const fileTypes: FileType[] = [];\n if (imageCount > 0) fileTypes.push(\"image/*\");\n if (audioCount > 0) fileTypes.push(\"audio/*\");\n if (videoCount > 0) fileTypes.push(\"video/*\");\n return fileTypes.length > 0 ? fileTypes : false;\n }\n\n return false;\n}\n","import { PropertyValidationSchema } from \"@rebasepro/types\";\nimport { InferencePropertyBuilderProps } from \"../types\";\n\nexport function buildValidation({\n totalDocsCount,\n valuesResult\n}: InferencePropertyBuilderProps): PropertyValidationSchema | undefined {\n\n if (valuesResult) {\n const totalEntriesCount = valuesResult.values.length;\n if (totalDocsCount === totalEntriesCount)\n return {\n required: true\n }\n }\n\n return undefined;\n}\n","import { findCommonInitialStringInPath } from \"../strings\";\nimport { InferencePropertyBuilderProps } from \"../types\";\nimport { Property } from \"@rebasepro/types\";\n\nexport function buildReferenceProperty({\n name,\n totalDocsCount,\n valuesResult\n}: InferencePropertyBuilderProps): Property {\n\n const property: Property = {\n name: name ?? \"\",\n type: \"reference\",\n path: findCommonInitialStringInPath(valuesResult) ?? \"!!!FIX_ME!!!\"\n };\n\n return property;\n}\n","import {\n InferencePropertyBuilderProps,\n TypesCount,\n TypesCountRecord,\n ValuesCountEntry,\n ValuesCountRecord\n} from \"./types\";\nimport { buildStringProperty } from \"./builders/string_property_builder\";\nimport { buildValidation } from \"./builders/validation_builder\";\nimport { buildReferenceProperty } from \"./builders/reference_property_builder\";\nimport { extractEnumFromValues, mergeDeep, prettifyIdentifier, resolveEnumValues } from \"./util\";\nimport { DataType, EnumValues, Properties, Property, StringProperty, Vector } from \"@rebasepro/types\";\n\nexport type InferenceTypeBuilder = (value: unknown) => DataType;\n\nexport async function buildEntityPropertiesFromData(\n data: object[],\n getType: InferenceTypeBuilder\n): Promise<Properties> {\n const typesCount: TypesCountRecord = {};\n const valuesCount: ValuesCountRecord = {};\n if (data) {\n data.forEach((entry) => {\n if (entry) {\n Object.entries(entry).forEach(([key, value]) => {\n if (key.startsWith(\"_\")) return; // Ignore properties starting with _\n increaseMapTypeCount(typesCount, key, value, getType);\n increaseValuesCount(valuesCount, key, value, getType);\n });\n }\n });\n }\n return buildPropertiesFromCount(data.length, typesCount, valuesCount);\n}\n\nexport function buildPropertyFromData(\n data: unknown[],\n property: Property,\n getType: InferenceTypeBuilder\n): Property {\n const typesCount = {};\n const valuesCount: ValuesCountRecord = {};\n if (data) {\n data.forEach((entry) => {\n increaseTypeCount(property.type, typesCount, entry, getType);\n increaseValuesCount(valuesCount, \"inferred_prop\", entry, getType);\n });\n }\n const enumValues = \"enum\" in property ? resolveEnumValues(property[\"enum\"] as EnumValues) : undefined;\n if (enumValues) {\n const newEnumValues = extractEnumFromValues(Array.from(valuesCount[\"inferred_prop\"].valuesCount.keys()));\n return {\n ...property,\n enum: [...newEnumValues, ...enumValues]\n } as StringProperty;\n }\n const generatedProperty = buildPropertyFromCount(\n \"inferred_prop\",\n data.length,\n property.type,\n typesCount,\n valuesCount[\"inferred_prop\"]\n );\n return mergeDeep(generatedProperty, property);\n}\n\nexport function buildPropertiesOrder(\n properties: Properties,\n propertiesOrder?: string[],\n priorityKeys?: string[]\n): string[] {\n const lowerCasePriorityKeys = (priorityKeys ?? []).map((key) => key.toLowerCase());\n\n function propOrder(s: string) {\n const k = s.toLowerCase();\n if (lowerCasePriorityKeys.includes(k)) return 4;\n if (k === \"title\" || k === \"name\") return 3;\n if (k.includes(\"title\") || k.includes(\"name\")) return 2;\n if (k.includes(\"image\") || k.includes(\"picture\")) return 1;\n return 0;\n }\n\n const keys = propertiesOrder ?? Object.keys(properties);\n keys.sort(); // alphabetically\n keys.sort((a, b) => {\n return propOrder(b) - propOrder(a);\n });\n return keys;\n}\n\n/**\n * @param type\n * @param typesCount\n * @param fieldValue\n * @param getType\n */\nfunction increaseTypeCount(\n type: DataType,\n typesCount: TypesCount,\n fieldValue: unknown,\n getType: InferenceTypeBuilder\n) {\n if (type === \"map\") {\n if (fieldValue) {\n let mapTypesCount = typesCount[type];\n if (!mapTypesCount) {\n mapTypesCount = {};\n typesCount[type] = mapTypesCount;\n }\n Object.entries(fieldValue as Record<string, unknown>).forEach(([key, value]) => {\n increaseMapTypeCount(mapTypesCount as TypesCountRecord, key, value, getType);\n });\n }\n } else if (type === \"array\") {\n let arrayTypesCount = typesCount[type];\n if (!arrayTypesCount) {\n arrayTypesCount = {};\n typesCount[type] = arrayTypesCount;\n }\n if (fieldValue && Array.isArray(fieldValue) && fieldValue.length > 0) {\n const arrayType = getMostProbableTypeInArray(fieldValue, getType);\n if (arrayType === \"map\") {\n let mapTypesCount = arrayTypesCount[arrayType];\n if (!mapTypesCount) {\n mapTypesCount = {};\n }\n fieldValue.forEach((value) => {\n if (value && typeof value === \"object\" && !Array.isArray(value)) { // Ensure value is an object for Object.entries\n Object.entries(value).forEach(([key, v]) =>\n increaseMapTypeCount(mapTypesCount, key, v, getType)\n );\n }\n });\n arrayTypesCount[arrayType] = mapTypesCount;\n } else {\n if (!arrayTypesCount[arrayType]) arrayTypesCount[arrayType] = 1;\n else arrayTypesCount[arrayType] = Number(arrayTypesCount[arrayType]) + 1;\n }\n }\n } else {\n if (!typesCount[type]) typesCount[type] = 1;\n else typesCount[type] = Number(typesCount[type]) + 1;\n }\n}\n\nfunction increaseMapTypeCount(\n typesCountRecord: TypesCountRecord,\n key: string,\n fieldValue: unknown,\n getType: InferenceTypeBuilder\n) {\n if (key.startsWith(\"_\")) return; // Ignore properties starting with _\n\n let typesCount: TypesCount = typesCountRecord[key];\n if (!typesCount) {\n typesCount = {};\n typesCountRecord[key] = typesCount;\n }\n\n if (fieldValue != null) {\n // Check that fieldValue is not null or undefined before proceeding\n const type = getType(fieldValue);\n increaseTypeCount(type, typesCount, fieldValue, getType);\n }\n}\n\nfunction increaseValuesCount(\n typeValuesRecord: ValuesCountRecord,\n key: string,\n fieldValue: unknown,\n getType: InferenceTypeBuilder\n) {\n if (key.startsWith(\"_\")) return; // Ignore properties starting with _\n\n const type = getType(fieldValue);\n\n let valuesRecord: {\n values: unknown[];\n valuesCount: Map<unknown, number>;\n map?: ValuesCountRecord;\n } = typeValuesRecord[key];\n\n if (!valuesRecord) {\n valuesRecord = {\n values: [],\n valuesCount: new Map()\n };\n typeValuesRecord[key] = valuesRecord;\n }\n\n if (type === \"map\") {\n let mapValuesRecord: ValuesCountRecord | undefined = valuesRecord.map;\n if (!mapValuesRecord) {\n mapValuesRecord = {};\n valuesRecord.map = mapValuesRecord;\n }\n if (fieldValue)\n Object.entries(fieldValue as Record<string, unknown>).forEach(([subKey, value]) =>\n increaseValuesCount(mapValuesRecord as ValuesCountRecord, subKey, value, getType)\n );\n } else if (type === \"array\") {\n if (Array.isArray(fieldValue)) {\n fieldValue.forEach((value) => {\n valuesRecord.values.push(value);\n valuesRecord.valuesCount.set(value, (valuesRecord.valuesCount.get(value) ?? 0) + 1);\n });\n }\n } else {\n if (fieldValue !== null && fieldValue !== undefined) {\n valuesRecord.values.push(fieldValue);\n valuesRecord.valuesCount.set(fieldValue, (valuesRecord.valuesCount.get(fieldValue) ?? 0) + 1);\n }\n }\n}\n\nfunction getHighestTypesCount(typesCount: TypesCount): number {\n let highestCount = 0;\n Object.entries(typesCount).forEach(([type, count]) => {\n let countValue = 0;\n if (type === \"map\") {\n countValue = getHighestRecordCount(count as TypesCountRecord);\n } else if (type === \"array\") {\n countValue = getHighestTypesCount(count as TypesCount);\n } else {\n countValue = Number(count);\n }\n if (countValue > highestCount) {\n highestCount = countValue;\n }\n });\n\n return highestCount;\n}\n\nfunction getHighestRecordCount(record: TypesCountRecord): number {\n return Object.entries(record)\n .map(([key, typesCount]) => getHighestTypesCount(typesCount))\n .reduce((a, b) => Math.max(a, b), 0);\n}\n\nfunction getMostProbableType(typesCount: TypesCount): DataType {\n let highestCount = -1;\n let probableType: DataType = \"string\"; // default\n Object.entries(typesCount).forEach(([type, count]) => {\n let countValue;\n if (type === \"map\") {\n countValue = getHighestRecordCount(count as TypesCountRecord);\n } else if (type === \"array\") {\n countValue = getHighestTypesCount(count as TypesCount);\n } else {\n countValue = Number(count);\n }\n if (countValue > highestCount) {\n highestCount = countValue;\n probableType = type as DataType;\n }\n });\n return probableType;\n}\n\nfunction buildPropertyFromCount(\n key: string,\n totalDocsCount: number,\n mostProbableType: DataType,\n typesCount: TypesCount,\n valuesResult?: ValuesCountEntry\n): Property {\n let title: string | undefined;\n\n if (key) {\n title = prettifyIdentifier(key);\n }\n\n let result: Property | undefined = undefined;\n if (mostProbableType === \"map\") {\n const highVariability = checkTypesCountHighVariability(typesCount);\n if (highVariability) {\n result = {\n type: \"map\",\n name: title ?? key ?? \"\",\n keyValue: true,\n properties: {}\n };\n }\n const properties = buildPropertiesFromCount(\n totalDocsCount,\n typesCount.map as TypesCountRecord,\n valuesResult ? valuesResult.mapValues : undefined\n );\n result = {\n type: \"map\",\n name: title ?? key ?? \"\",\n properties\n };\n } else if (mostProbableType === \"array\") {\n const arrayTypesCount = typesCount.array as TypesCount;\n const arrayMostProbableType = getMostProbableType(arrayTypesCount);\n const of = buildPropertyFromCount(\n key,\n totalDocsCount,\n arrayMostProbableType,\n arrayTypesCount,\n valuesResult\n );\n result = {\n type: \"array\",\n name: title ?? key ?? \"\",\n of\n };\n }\n\n if (!result) {\n const propertyProps: InferencePropertyBuilderProps = {\n name: key,\n totalDocsCount,\n valuesResult\n };\n if (mostProbableType === \"string\") {\n result = buildStringProperty(propertyProps);\n } else if (mostProbableType === \"reference\") {\n result = buildReferenceProperty(propertyProps);\n } else {\n result = {\n type: mostProbableType\n } as Property;\n }\n\n if (title) {\n result.name = title;\n }\n\n const validation = buildValidation(propertyProps);\n if (validation) {\n result.validation = validation;\n }\n }\n\n return result;\n}\n\nfunction buildPropertiesFromCount(\n totalDocsCount: number,\n typesCountRecord: TypesCountRecord,\n valuesCountRecord?: ValuesCountRecord\n): Properties {\n const res: Properties = {};\n Object.entries(typesCountRecord).forEach(([key, typesCount]) => {\n const mostProbableType = getMostProbableType(typesCount);\n res[key] = buildPropertyFromCount(\n key,\n totalDocsCount,\n mostProbableType,\n typesCount,\n valuesCountRecord ? valuesCountRecord[key] : undefined\n );\n });\n return res;\n}\n\nfunction countMaxDocumentsUnder(typesCount: TypesCount) {\n let count = 0;\n Object.entries(typesCount).forEach(([type, value]) => {\n if (typeof value === \"object\") {\n count = Math.max(count, countMaxDocumentsUnder(value as TypesCountRecord));\n } else {\n count = Math.max(count, Number(value));\n }\n });\n return count;\n}\n\nfunction getMostProbableTypeInArray(\n array: unknown[],\n getType: InferenceTypeBuilder\n): DataType {\n const typesCount: TypesCount = {};\n array.forEach((value) => {\n increaseTypeCount(getType(value), typesCount, value, getType);\n });\n return getMostProbableType(typesCount);\n}\n\nfunction checkTypesCountHighVariability(typesCount: TypesCount) {\n const maxCount = countMaxDocumentsUnder(typesCount);\n let keysWithFewValues = 0;\n Object.entries(typesCount.map ?? {}).forEach(([key, value]) => {\n const count = countMaxDocumentsUnder(value);\n if (count < maxCount / 3) {\n keysWithFewValues++;\n }\n });\n return keysWithFewValues / Object.entries(typesCount.map ?? {}).length > 0.5;\n}\n\n\nexport function inferTypeFromValue(value: unknown): DataType {\n if (value === null || value === undefined) return \"string\";\n if (value instanceof Vector || (value && typeof value === \"object\" && \"__type\" in value && (value as Record<string, unknown>).__type === \"Vector\")) return \"vector\";\n if (typeof value === \"string\") return \"string\";\n if (typeof value === \"number\") return \"number\";\n if (typeof value === \"boolean\") return \"boolean\";\n if (Array.isArray(value)) return \"array\";\n if (typeof value === \"object\") return \"map\";\n return \"string\";\n}\n"],"mappings":";;;;;;;;;;;;;;;CAQA,SAAgB,qBAAqB,OAA2D;EAC5F,IAAI,CAAC,OAAO,OAAO;EAEnB,IAAI,WAA+B,KAAA;EACnC,IAAI,WAAW;EAGf,IAAI,MAAM,SAAS,KAAK,GAAG;GACvB,MAAM,CAAC,QAAQ,YAAY,MAAM,MAAM,KAAK;GAC5C,IAAI,UAAU,WAAW,aACrB,WAAW;GAEf,WAAW;EACf;EAGA,IAAI,CAAC,YAAY,CAAC,SAAS,SAAS,GAAG,GACnC,OAAO;EAMX,OAAO;GAAE,MAFI,SAAS,UAAU,GAAG,SAAS,YAAY,GAAG,CAElD;GACb;EAAS;CACT;;;;CAKA,SAAgB,mBAAmB,OAAyB;EACxD,IAAI,OAAO,UAAU,UAAU,OAAO;EACtC,OAAO,qBAAqB,KAAK,MAAM;CAC3C;CAEA,SAAgB,8BAA8B,aAAgC;EAE1E,IAAI,CAAC,aAAa,OAAO,KAAA;EAEzB,SAAS,QAAQ,OAAoC;GACjD,IAAI;GAEJ,IAAI,OAAO,UAAU,UACjB,aAAa;QACV,IAAI,SAAS,OAAO,UAAU,YAAY,UAAU,SAAS,OAAQ,MAAkC,SAAS,UACnH,aAAc,MAAkC;QAC7C;IACH,QAAQ,KAAK,8EAA8E,KAAK;IAChG;GACJ;GAEA,IAAI,CAAC,YAAY,OAAO,KAAA;GAIxB,IAAI,WAAW,SAAS,KAAK,GAAG;IAC5B,MAAM,GAAG,YAAY,WAAW,MAAM,KAAK;IAC3C,aA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BAA+B,YAAwB;EAC5D,MAAM,WAAW,uBAAuB,UAAU;EAClD,IAAI,oBAAoB;EACxB,OAAO,QAAQ,WAAW,OAAO,CAAC,CAAC,EAAE,SAAS,CAAC,KAAK,WAAW;GAE3D,IADc,uBAAuB,KACjC,IAAQ,WAAW,GACnB;EAER,CAAC;EACD,OAAO,oBAAoB,OAAO,QAAQ,WAAW,OAAO,CAAC,CAAC,EAAE,SAAS;CAC7E;CAGA,SAAgB,mBAAmB,OAA0B;EACzD,IAAI,UAAU,QAAQ,UAAU,KAAA,GAAW,OAAO;EAClD,IAAI,iBAAiB,iBAAA,UAAW,SAAS,OAAO,UAAU,YAAY,YAAY,SAAU,MAAkC,WAAW,UAAW,OAAO;EAC3J,IAAI,OAAO,UAAU,UAAU,OAAO;EACtC,IAAI,OAAO,UAAU,UAAU,OAAO;EACtC,IAAI,OAAO,UAAU,WAAW,OAAO;EACvC,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO;EACjC,IAAI,OAAO,UAAU,UAAU,OAAO;EACtC,OAAO;CACX"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebasepro/inference",
|
|
3
|
-
"version": "0.9.1-canary.
|
|
3
|
+
"version": "0.9.1-canary.fd3754b",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
8
|
-
"main": "./dist/index.
|
|
8
|
+
"main": "./dist/index.umd.cjs",
|
|
9
9
|
"module": "./dist/index.es.js",
|
|
10
10
|
"types": "dist/index.d.ts",
|
|
11
11
|
"source": "src/index.ts",
|
|
@@ -16,14 +16,15 @@
|
|
|
16
16
|
"ts-jest": "^29.4.11",
|
|
17
17
|
"typescript": "^6.0.3",
|
|
18
18
|
"vite": "^8.0.16",
|
|
19
|
-
"@rebasepro/
|
|
20
|
-
"@rebasepro/
|
|
19
|
+
"@rebasepro/types": "0.9.1-canary.fd3754b",
|
|
20
|
+
"@rebasepro/utils": "0.9.1-canary.fd3754b"
|
|
21
21
|
},
|
|
22
22
|
"exports": {
|
|
23
23
|
".": {
|
|
24
24
|
"types": "./dist/index.d.ts",
|
|
25
25
|
"development": "./dist/index.es.js",
|
|
26
|
-
"import": "./dist/index.es.js"
|
|
26
|
+
"import": "./dist/index.es.js",
|
|
27
|
+
"require": "./dist/index.umd.cjs"
|
|
27
28
|
},
|
|
28
29
|
"./package.json": "./package.json"
|
|
29
30
|
},
|
|
@@ -39,7 +40,7 @@
|
|
|
39
40
|
},
|
|
40
41
|
"scripts": {
|
|
41
42
|
"dev": "vite",
|
|
42
|
-
"build": "vite build && tsc --emitDeclarationOnly -p tsconfig.prod.json
|
|
43
|
+
"build": "vite build && tsc --emitDeclarationOnly -p tsconfig.prod.json",
|
|
43
44
|
"test": "jest --passWithNoTests",
|
|
44
45
|
"clean": "rm -rf dist && find ./src -name '*.js' -type f | xargs rm -f"
|
|
45
46
|
}
|