@documentdb-js/schema-analyzer 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,511 @@
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Microsoft Corporation. All rights reserved.
4
+ * Licensed under the MIT License. See License.txt in the project root for license information.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ var __importDefault = (this && this.__importDefault) || function (mod) {
7
+ return (mod && mod.__esModule) ? mod : { "default": mod };
8
+ };
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.SchemaAnalyzer = void 0;
11
+ exports.getPropertyNamesAtLevel = getPropertyNamesAtLevel;
12
+ exports.buildFullPaths = buildFullPaths;
13
+ const denque_1 = __importDefault(require("denque"));
14
+ const strict_1 = __importDefault(require("node:assert/strict"));
15
+ const BSONTypes_1 = require("./BSONTypes");
16
+ const getKnownFields_1 = require("./getKnownFields");
17
+ /**
18
+ * Incremental schema analyzer for documents from the MongoDB API / DocumentDB API.
19
+ *
20
+ * Analyzes documents one at a time (or in batches) and builds a cumulative
21
+ * JSON Schema with statistical extensions (x-occurrence, x-bsonType, etc.).
22
+ *
23
+ * The output schema follows JSON Schema draft-07 with custom x- extensions.
24
+ */
25
+ class SchemaAnalyzer {
26
+ _schema = {};
27
+ _version = 0;
28
+ _knownFieldsCache = null;
29
+ _knownFieldsCacheVersion = -1;
30
+ /**
31
+ * A monotonically increasing version counter. Incremented on every mutation
32
+ * (addDocument, addDocuments, reset). Adapters can store this value alongside
33
+ * their cached derived data and recompute only when it changes.
34
+ */
35
+ get version() {
36
+ return this._version;
37
+ }
38
+ /**
39
+ * Adds a single document to the accumulated schema.
40
+ * This is the primary incremental API — call once per document.
41
+ */
42
+ addDocument(document) {
43
+ updateSchemaWithDocumentInternal(this._schema, document);
44
+ this._version++;
45
+ }
46
+ /**
47
+ * Adds multiple documents to the accumulated schema.
48
+ * Convenience method equivalent to calling addDocument() for each.
49
+ * Increments version once for the entire batch — not per document.
50
+ */
51
+ addDocuments(documents) {
52
+ for (const doc of documents) {
53
+ updateSchemaWithDocumentInternal(this._schema, doc);
54
+ }
55
+ this._version++;
56
+ }
57
+ /**
58
+ * Returns the current accumulated JSON Schema.
59
+ * The returned object is a live reference (not a copy) — do not mutate externally.
60
+ */
61
+ getSchema() {
62
+ return this._schema;
63
+ }
64
+ /**
65
+ * Returns the number of documents analyzed so far.
66
+ */
67
+ getDocumentCount() {
68
+ return this._schema['x-documentsInspected'] ?? 0;
69
+ }
70
+ /**
71
+ * Resets the analyzer to its initial empty state.
72
+ */
73
+ reset() {
74
+ this._schema = {};
75
+ this._version++;
76
+ }
77
+ /**
78
+ * Creates a deep copy of this analyzer, including all accumulated schema data.
79
+ * Useful for aggregation stage branching where each stage needs its own schema state.
80
+ * The clone starts with version 0, independent from the original.
81
+ */
82
+ clone() {
83
+ const copy = new SchemaAnalyzer();
84
+ copy._schema = structuredClone(this._schema);
85
+ return copy;
86
+ }
87
+ /**
88
+ * Returns the cached list of known fields (all nesting levels, sorted).
89
+ * Recomputed only when the schema version has changed since the last call.
90
+ */
91
+ getKnownFields() {
92
+ if (this._knownFieldsCacheVersion !== this._version || this._knownFieldsCache === null) {
93
+ this._knownFieldsCache = (0, getKnownFields_1.getKnownFields)(this._schema);
94
+ this._knownFieldsCacheVersion = this._version;
95
+ }
96
+ return this._knownFieldsCache;
97
+ }
98
+ /**
99
+ * Creates a SchemaAnalyzer from a single document.
100
+ * Equivalent to creating an instance and calling addDocument() once.
101
+ */
102
+ static fromDocument(document) {
103
+ const analyzer = new SchemaAnalyzer();
104
+ analyzer.addDocument(document);
105
+ return analyzer;
106
+ }
107
+ /**
108
+ * Creates a SchemaAnalyzer from multiple documents.
109
+ * Equivalent to creating an instance and calling addDocuments().
110
+ */
111
+ static fromDocuments(documents) {
112
+ const analyzer = new SchemaAnalyzer();
113
+ analyzer.addDocuments(documents);
114
+ return analyzer;
115
+ }
116
+ }
117
+ exports.SchemaAnalyzer = SchemaAnalyzer;
118
+ function updateSchemaWithDocumentInternal(schema, document) {
119
+ // Initialize schema if it's empty
120
+ if (!schema.properties) {
121
+ schema.properties = {};
122
+ schema['x-documentsInspected'] = 0;
123
+ }
124
+ schema['x-documentsInspected'] = (schema['x-documentsInspected'] ?? 0) + 1;
125
+ // Initialize a FIFO queue for breadth-first traversal
126
+ const fifoQueue = new denque_1.default();
127
+ /**
128
+ * Start by pushing all root-level elements of the document into the queue
129
+ */
130
+ for (const [name, value] of Object.entries(document)) {
131
+ const mongoDatatype = BSONTypes_1.BSONTypes.inferType(value);
132
+ // Ensure the field exists in the schema
133
+ if (!schema.properties[name]) {
134
+ // Initialize the property schema if it doesn't exist
135
+ schema.properties[name] = {
136
+ anyOf: [],
137
+ 'x-occurrence': 0,
138
+ };
139
+ }
140
+ const propertySchema = schema.properties[name];
141
+ (0, strict_1.default)(propertySchema !== undefined, 'propertySchema should not be undefined');
142
+ // Increment the field occurrence count
143
+ propertySchema['x-occurrence'] = (propertySchema['x-occurrence'] ?? 0) + 1;
144
+ // Find or create the type entry in 'anyOf'
145
+ let typeEntry = findTypeEntry(propertySchema.anyOf, mongoDatatype);
146
+ if (!typeEntry) {
147
+ // Create a new type entry
148
+ typeEntry = {
149
+ type: BSONTypes_1.BSONTypes.toJSONType(mongoDatatype),
150
+ 'x-bsonType': mongoDatatype,
151
+ 'x-typeOccurrence': 0,
152
+ };
153
+ if (!propertySchema.anyOf) {
154
+ propertySchema.anyOf = [];
155
+ }
156
+ propertySchema.anyOf.push(typeEntry);
157
+ }
158
+ // Increment the type occurrence count
159
+ typeEntry['x-typeOccurrence'] = (typeEntry['x-typeOccurrence'] ?? 0) + 1;
160
+ // Push a work item into the queue for further processing
161
+ fifoQueue.push({
162
+ fieldName: name,
163
+ fieldMongoType: mongoDatatype,
164
+ propertySchema: typeEntry,
165
+ fieldValue: value,
166
+ pathSoFar: name,
167
+ });
168
+ }
169
+ /**
170
+ * Process items in the queue to build/update the schema
171
+ * This is a breadth-first traversal of the document structure
172
+ */
173
+ while (fifoQueue.length > 0) {
174
+ const item = fifoQueue.shift();
175
+ if (item === undefined) {
176
+ continue;
177
+ }
178
+ switch (item.fieldMongoType) {
179
+ case BSONTypes_1.BSONTypes.Object: {
180
+ const objValue = item.fieldValue;
181
+ const objKeysCount = Object.keys(objValue).length;
182
+ // Update min and max property counts
183
+ updateMinMaxStats(item.propertySchema, 'x-minProperties', 'x-maxProperties', objKeysCount);
184
+ // Track how many object instances contributed to this sub-schema.
185
+ // This enables uniform probability computation at every nesting level:
186
+ // probability = property.x-occurrence / parentObject.x-documentsInspected
187
+ //
188
+ // Without this, array-embedded objects have no denominator for probability.
189
+ // Example: doc1.a=[], doc2.a=[{b:1},...,{b:100}]
190
+ // b.x-occurrence = 100, root.x-documentsInspected = 2
191
+ // Naive: 100/2 = 5000% — wrong!
192
+ // With fix: objectEntry.x-documentsInspected = 100, so 100/100 = 100%
193
+ item.propertySchema['x-documentsInspected'] = (item.propertySchema['x-documentsInspected'] ?? 0) + 1;
194
+ // Ensure 'properties' exists
195
+ if (!item.propertySchema.properties) {
196
+ item.propertySchema.properties = {};
197
+ }
198
+ // Iterate over the object's properties
199
+ for (const [name, value] of Object.entries(objValue)) {
200
+ const mongoDatatype = BSONTypes_1.BSONTypes.inferType(value);
201
+ // Ensure the field exists in the schema
202
+ if (!item.propertySchema.properties[name]) {
203
+ // Initialize the property schema if it doesn't exist
204
+ item.propertySchema.properties[name] = {
205
+ anyOf: [],
206
+ 'x-occurrence': 0,
207
+ };
208
+ }
209
+ const propertySchema = item.propertySchema.properties[name];
210
+ (0, strict_1.default)(propertySchema !== undefined, 'propertySchema should not be undefined');
211
+ // Increment the field occurrence count
212
+ propertySchema['x-occurrence'] = (propertySchema['x-occurrence'] ?? 0) + 1;
213
+ // Find or create the type entry in 'anyOf'
214
+ let typeEntry = findTypeEntry(propertySchema.anyOf, mongoDatatype);
215
+ if (!typeEntry) {
216
+ // Create a new type entry
217
+ typeEntry = {
218
+ type: BSONTypes_1.BSONTypes.toJSONType(mongoDatatype),
219
+ 'x-bsonType': mongoDatatype,
220
+ 'x-typeOccurrence': 0,
221
+ };
222
+ if (!propertySchema.anyOf) {
223
+ propertySchema.anyOf = [];
224
+ }
225
+ propertySchema.anyOf.push(typeEntry);
226
+ }
227
+ // Increment the type occurrence count
228
+ typeEntry['x-typeOccurrence'] = (typeEntry['x-typeOccurrence'] ?? 0) + 1;
229
+ // Queue the property's value for further processing
230
+ fifoQueue.push({
231
+ fieldName: name,
232
+ fieldMongoType: mongoDatatype,
233
+ propertySchema: typeEntry,
234
+ fieldValue: value,
235
+ pathSoFar: `${item.pathSoFar}.${name}`,
236
+ });
237
+ }
238
+ break;
239
+ }
240
+ case BSONTypes_1.BSONTypes.Array: {
241
+ const arrayValue = item.fieldValue;
242
+ const arrayLength = arrayValue.length;
243
+ // Update min and max array lengths
244
+ updateMinMaxStats(item.propertySchema, 'x-minItems', 'x-maxItems', arrayLength);
245
+ // Ensure 'items' exists
246
+ if (!item.propertySchema.items) {
247
+ item.propertySchema.items = {
248
+ anyOf: [],
249
+ };
250
+ }
251
+ const itemsSchema = item.propertySchema.items;
252
+ (0, strict_1.default)(itemsSchema !== undefined, 'itemsSchema should not be undefined');
253
+ // Iterate over the array elements
254
+ for (const element of arrayValue) {
255
+ const elementMongoType = BSONTypes_1.BSONTypes.inferType(element);
256
+ // Find or create the type entry in 'items.anyOf'
257
+ let itemEntry = findTypeEntry(itemsSchema.anyOf, elementMongoType);
258
+ const isNewTypeEntry = !itemEntry;
259
+ if (!itemEntry) {
260
+ // Create a new type entry
261
+ itemEntry = {
262
+ type: BSONTypes_1.BSONTypes.toJSONType(elementMongoType),
263
+ 'x-bsonType': elementMongoType,
264
+ 'x-typeOccurrence': 0,
265
+ };
266
+ if (!itemsSchema.anyOf) {
267
+ itemsSchema.anyOf = [];
268
+ }
269
+ itemsSchema.anyOf.push(itemEntry);
270
+ }
271
+ // Increment the type occurrence count
272
+ itemEntry['x-typeOccurrence'] = (itemEntry['x-typeOccurrence'] ?? 0) + 1;
273
+ // Update stats for the element.
274
+ // Use initializeStatsForValue only when the type entry is brand new
275
+ // (first element of this type ever seen). For subsequent elements —
276
+ // whether in the same array or across documents — always aggregate
277
+ // to avoid overwriting previously accumulated min/max stats.
278
+ if (isNewTypeEntry) {
279
+ initializeStatsForValue(element, elementMongoType, itemEntry);
280
+ }
281
+ else {
282
+ aggregateStatsForValue(element, elementMongoType, itemEntry);
283
+ }
284
+ // If the element is an object or array, queue it for further processing
285
+ if (elementMongoType === BSONTypes_1.BSONTypes.Object || elementMongoType === BSONTypes_1.BSONTypes.Array) {
286
+ fifoQueue.push({
287
+ fieldName: '[]', // Array items don't have a specific field name
288
+ fieldMongoType: elementMongoType,
289
+ propertySchema: itemEntry,
290
+ fieldValue: element,
291
+ pathSoFar: `${item.pathSoFar}[]`,
292
+ });
293
+ }
294
+ }
295
+ break;
296
+ }
297
+ default: {
298
+ // Update stats for the value
299
+ if (item.propertySchema['x-typeOccurrence'] === 1) {
300
+ // First occurrence, initialize stats
301
+ initializeStatsForValue(item.fieldValue, item.fieldMongoType, item.propertySchema);
302
+ }
303
+ else {
304
+ // Subsequent occurrences, aggregate stats
305
+ aggregateStatsForValue(item.fieldValue, item.fieldMongoType, item.propertySchema);
306
+ }
307
+ break;
308
+ }
309
+ }
310
+ }
311
+ }
312
+ /**
313
+ * Helper function to find a type entry in 'anyOf' array based on 'x-bsonType'
314
+ */
315
+ function findTypeEntry(anyOfArray, bsonType) {
316
+ return anyOfArray.find((entry) => entry['x-bsonType'] === bsonType);
317
+ }
318
+ /**
319
+ * Helper function to update min and max stats
320
+ */
321
+ function updateMinMaxStats(schema, minKey, maxKey, value) {
322
+ const record = schema;
323
+ if (record[minKey] === undefined || value < record[minKey]) {
324
+ record[minKey] = value;
325
+ }
326
+ if (record[maxKey] === undefined || value > record[maxKey]) {
327
+ record[maxKey] = value;
328
+ }
329
+ }
330
+ /**
331
+ * Helper function to compute stats for a value based on its MongoDB data type
332
+ * Updates the provided propertyTypeEntry with the computed stats
333
+ */
334
+ function initializeStatsForValue(value, mongoType, propertyTypeEntry) {
335
+ switch (mongoType) {
336
+ case BSONTypes_1.BSONTypes.String: {
337
+ const currentLength = value.length;
338
+ propertyTypeEntry['x-maxLength'] = currentLength;
339
+ propertyTypeEntry['x-minLength'] = currentLength;
340
+ break;
341
+ }
342
+ case BSONTypes_1.BSONTypes.Number:
343
+ case BSONTypes_1.BSONTypes.Int32:
344
+ case BSONTypes_1.BSONTypes.Long:
345
+ case BSONTypes_1.BSONTypes.Double:
346
+ case BSONTypes_1.BSONTypes.Decimal128: {
347
+ const numericValue = Number(value);
348
+ propertyTypeEntry['x-maxValue'] = numericValue;
349
+ propertyTypeEntry['x-minValue'] = numericValue;
350
+ break;
351
+ }
352
+ case BSONTypes_1.BSONTypes.Boolean: {
353
+ const boolValue = value;
354
+ propertyTypeEntry['x-trueCount'] = boolValue ? 1 : 0;
355
+ propertyTypeEntry['x-falseCount'] = boolValue ? 0 : 1;
356
+ break;
357
+ }
358
+ case BSONTypes_1.BSONTypes.Date: {
359
+ const dateValue = value.getTime();
360
+ propertyTypeEntry['x-maxDate'] = dateValue;
361
+ propertyTypeEntry['x-minDate'] = dateValue;
362
+ break;
363
+ }
364
+ case BSONTypes_1.BSONTypes.Binary: {
365
+ const binaryLength = value.length;
366
+ propertyTypeEntry['x-maxLength'] = binaryLength;
367
+ propertyTypeEntry['x-minLength'] = binaryLength;
368
+ break;
369
+ }
370
+ case BSONTypes_1.BSONTypes.Null:
371
+ case BSONTypes_1.BSONTypes.RegExp:
372
+ case BSONTypes_1.BSONTypes.ObjectId:
373
+ case BSONTypes_1.BSONTypes.MinKey:
374
+ case BSONTypes_1.BSONTypes.MaxKey:
375
+ case BSONTypes_1.BSONTypes.Symbol:
376
+ case BSONTypes_1.BSONTypes.Timestamp:
377
+ case BSONTypes_1.BSONTypes.DBRef:
378
+ case BSONTypes_1.BSONTypes.Map:
379
+ // No stats computation for other types
380
+ break;
381
+ default:
382
+ // No stats computation for other types
383
+ break;
384
+ }
385
+ }
386
+ /**
387
+ * Helper function to aggregate stats for a value based on its MongoDB data type
388
+ * Used when processing multiple values (e.g., elements in arrays)
389
+ */
390
+ function aggregateStatsForValue(value, mongoType, propertyTypeEntry) {
391
+ switch (mongoType) {
392
+ case BSONTypes_1.BSONTypes.String: {
393
+ const currentLength = value.length;
394
+ // Update minLength
395
+ if (propertyTypeEntry['x-minLength'] === undefined || currentLength < propertyTypeEntry['x-minLength']) {
396
+ propertyTypeEntry['x-minLength'] = currentLength;
397
+ }
398
+ // Update maxLength
399
+ if (propertyTypeEntry['x-maxLength'] === undefined || currentLength > propertyTypeEntry['x-maxLength']) {
400
+ propertyTypeEntry['x-maxLength'] = currentLength;
401
+ }
402
+ break;
403
+ }
404
+ case BSONTypes_1.BSONTypes.Number:
405
+ case BSONTypes_1.BSONTypes.Int32:
406
+ case BSONTypes_1.BSONTypes.Long:
407
+ case BSONTypes_1.BSONTypes.Double:
408
+ case BSONTypes_1.BSONTypes.Decimal128: {
409
+ const numericValue = Number(value);
410
+ // Update minValue
411
+ if (propertyTypeEntry['x-minValue'] === undefined || numericValue < propertyTypeEntry['x-minValue']) {
412
+ propertyTypeEntry['x-minValue'] = numericValue;
413
+ }
414
+ // Update maxValue
415
+ if (propertyTypeEntry['x-maxValue'] === undefined || numericValue > propertyTypeEntry['x-maxValue']) {
416
+ propertyTypeEntry['x-maxValue'] = numericValue;
417
+ }
418
+ break;
419
+ }
420
+ case BSONTypes_1.BSONTypes.Boolean: {
421
+ const boolValue = value;
422
+ // Update trueCount and falseCount
423
+ if (propertyTypeEntry['x-trueCount'] === undefined) {
424
+ propertyTypeEntry['x-trueCount'] = boolValue ? 1 : 0;
425
+ }
426
+ else {
427
+ propertyTypeEntry['x-trueCount'] += boolValue ? 1 : 0;
428
+ }
429
+ if (propertyTypeEntry['x-falseCount'] === undefined) {
430
+ propertyTypeEntry['x-falseCount'] = boolValue ? 0 : 1;
431
+ }
432
+ else {
433
+ propertyTypeEntry['x-falseCount'] += boolValue ? 0 : 1;
434
+ }
435
+ break;
436
+ }
437
+ case BSONTypes_1.BSONTypes.Date: {
438
+ const dateValue = value.getTime();
439
+ // Update minDate
440
+ if (propertyTypeEntry['x-minDate'] === undefined || dateValue < propertyTypeEntry['x-minDate']) {
441
+ propertyTypeEntry['x-minDate'] = dateValue;
442
+ }
443
+ // Update maxDate
444
+ if (propertyTypeEntry['x-maxDate'] === undefined || dateValue > propertyTypeEntry['x-maxDate']) {
445
+ propertyTypeEntry['x-maxDate'] = dateValue;
446
+ }
447
+ break;
448
+ }
449
+ case BSONTypes_1.BSONTypes.Binary: {
450
+ const binaryLength = value.length;
451
+ // Update minLength
452
+ if (propertyTypeEntry['x-minLength'] === undefined || binaryLength < propertyTypeEntry['x-minLength']) {
453
+ propertyTypeEntry['x-minLength'] = binaryLength;
454
+ }
455
+ // Update maxLength
456
+ if (propertyTypeEntry['x-maxLength'] === undefined || binaryLength > propertyTypeEntry['x-maxLength']) {
457
+ propertyTypeEntry['x-maxLength'] = binaryLength;
458
+ }
459
+ break;
460
+ }
461
+ default:
462
+ // No stats computation for other types
463
+ break;
464
+ }
465
+ }
466
+ function getSchemaAtPath(schema, path) {
467
+ let currentNode = schema;
468
+ for (let i = 0; i < path.length; i++) {
469
+ const key = path[i];
470
+ // Move to the next property in the schema
471
+ if (currentNode && currentNode.properties && currentNode.properties[key]) {
472
+ const nextNode = currentNode.properties[key];
473
+ /**
474
+ * Now, with our JSON Schema, there are "anyOf" entries that we need to consider.
475
+ * We're looking at the "Object"-one, because these have the properties we're interested in.
476
+ */
477
+ if (nextNode.anyOf && nextNode.anyOf.length > 0) {
478
+ currentNode = nextNode.anyOf.find((entry) => typeof entry === 'object' && entry.type === 'object');
479
+ }
480
+ else {
481
+ // we can't continue, as we're missing the next node, we abort at the last node we managed to extract
482
+ return currentNode;
483
+ }
484
+ }
485
+ else {
486
+ throw new Error(`No properties found in the schema at path "${path.slice(0, i + 1).join('/')}"`);
487
+ }
488
+ }
489
+ return currentNode; // Return the node at the path
490
+ }
491
+ function getPropertyNamesAtLevel(jsonSchema, path) {
492
+ const headers = new Set();
493
+ // Explore the schema and apply the callback to collect headers at the specified path
494
+ const selectedSchema = getSchemaAtPath(jsonSchema, path);
495
+ if (selectedSchema && selectedSchema.properties) {
496
+ Object.keys(selectedSchema.properties).forEach((key) => {
497
+ headers.add(key);
498
+ });
499
+ }
500
+ return Array.from(headers).sort((a, b) => {
501
+ if (a === '_id')
502
+ return -1; // _id should come before b
503
+ if (b === '_id')
504
+ return 1; // _id should come after a
505
+ return a.localeCompare(b); // regular sorting
506
+ });
507
+ }
508
+ function buildFullPaths(path, propertyNames) {
509
+ return propertyNames.map((name) => path.concat(name).join('.'));
510
+ }
511
+ //# sourceMappingURL=SchemaAnalyzer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaAnalyzer.js","sourceRoot":"","sources":["../src/SchemaAnalyzer.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;;;;AAkjBhG,0DAiBC;AAED,wCAEC;AArkBD,oDAA4B;AAE5B,gEAAwC;AACxC,2CAAwC;AAExC,qDAA+F;AAE/F;;;;;;;GAOG;AACH,MAAa,cAAc;IACf,OAAO,GAAe,EAAE,CAAC;IACzB,QAAQ,GAAW,CAAC,CAAC;IACrB,iBAAiB,GAAwB,IAAI,CAAC;IAC9C,wBAAwB,GAAW,CAAC,CAAC,CAAC;IAE9C;;;;OAIG;IACH,IAAI,OAAO;QACP,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAED;;;OAGG;IACH,WAAW,CAAC,QAA0B;QAClC,gCAAgC,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QACzD,IAAI,CAAC,QAAQ,EAAE,CAAC;IACpB,CAAC;IAED;;;;OAIG;IACH,YAAY,CAAC,SAA0C;QACnD,KAAK,MAAM,GAAG,IA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AC,UAAU,EAAE,IAAI,CAAC,CAAC;IAEzD,IAAI,cAAc,IAAI,cAAc,CAAC,UAAU,EAAE,CAAC;QAC9C,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YACnD,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACrB,CAAC,CAAC,CAAC;IACP,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACrC,IAAI,CAAC,KAAK,KAAK;YAAE,OAAO,CAAC,CAAC,CAAC,CAAC,2BAA2B;QACvD,IAAI,CAAC,KAAK,KAAK;YAAE,OAAO,CAAC,CAAC,CAAC,0BAA0B;QACrD,OAAO,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,kBAAkB;IACjD,CAAC,CAAC,CAAC;AACP,CAAC;AAED,SAAgB,cAAc,CAAC,IAAc,EAAE,aAAuB;IAClE,OAAO,aAAa,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACpE,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { BSONTypes } from './BSONTypes';
2
+ /**
3
+ * Converts a MongoDB API value to its display string representation based on its type.
4
+ *
5
+ * @param value - The value to be converted to a display string.
6
+ * @param type - The MongoDB API data type of the value.
7
+ * @returns The string representation of the value.
8
+ *
9
+ * The function handles various MongoDB API data types including:
10
+ * - String
11
+ * - Number, Int32, Double, Decimal128, Long
12
+ * - Boolean
13
+ * - Date
14
+ * - ObjectId
15
+ * - Binary
16
+ * - ...
17
+ *
18
+ * For unsupported or unknown types, the function defaults to JSON stringification.
19
+ */
20
+ export declare function valueToDisplayString(value: unknown, type: BSONTypes): string;
21
+ //# sourceMappingURL=ValueFormatters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ValueFormatters.d.ts","sourceRoot":"","sources":["../src/ValueFormatters.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,GAAG,MAAM,CA0D5E"}
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Microsoft Corporation. All rights reserved.
4
+ * Licensed under the MIT License. See License.txt in the project root for license information.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.valueToDisplayString = valueToDisplayString;
8
+ const BSONTypes_1 = require("./BSONTypes");
9
+ /**
10
+ * Converts a MongoDB API value to its display string representation based on its type.
11
+ *
12
+ * @param value - The value to be converted to a display string.
13
+ * @param type - The MongoDB API data type of the value.
14
+ * @returns The string representation of the value.
15
+ *
16
+ * The function handles various MongoDB API data types including:
17
+ * - String
18
+ * - Number, Int32, Double, Decimal128, Long
19
+ * - Boolean
20
+ * - Date
21
+ * - ObjectId
22
+ * - Binary
23
+ * - ...
24
+ *
25
+ * For unsupported or unknown types, the function defaults to JSON stringification.
26
+ */
27
+ function valueToDisplayString(value, type) {
28
+ switch (type) {
29
+ case BSONTypes_1.BSONTypes.String: {
30
+ return value;
31
+ }
32
+ case BSONTypes_1.BSONTypes.Number:
33
+ case BSONTypes_1.BSONTypes.Int32:
34
+ case BSONTypes_1.BSONTypes.Double:
35
+ case BSONTypes_1.BSONTypes.Decimal128:
36
+ case BSONTypes_1.BSONTypes.Long: {
37
+ return value.toString();
38
+ }
39
+ case BSONTypes_1.BSONTypes.Boolean: {
40
+ return value.toString();
41
+ }
42
+ case BSONTypes_1.BSONTypes.Date: {
43
+ return value.toISOString();
44
+ }
45
+ case BSONTypes_1.BSONTypes.ObjectId: {
46
+ return value.toHexString();
47
+ }
48
+ case BSONTypes_1.BSONTypes.Null: {
49
+ return 'null';
50
+ }
51
+ case BSONTypes_1.BSONTypes.RegExp: {
52
+ const v = value;
53
+ return `${v.pattern} ${v.options}`;
54
+ }
55
+ case BSONTypes_1.BSONTypes.Binary: {
56
+ return `Binary[${value.length()}]`;
57
+ }
58
+ case BSONTypes_1.BSONTypes.Symbol: {
59
+ return value.toString();
60
+ }
61
+ case BSONTypes_1.BSONTypes.Timestamp: {
62
+ return value.toString();
63
+ }
64
+ case BSONTypes_1.BSONTypes.MinKey: {
65
+ return 'MinKey';
66
+ }
67
+ case BSONTypes_1.BSONTypes.MaxKey: {
68
+ return 'MaxKey';
69
+ }
70
+ case BSONTypes_1.BSONTypes.Code:
71
+ case BSONTypes_1.BSONTypes.CodeWithScope: {
72
+ return JSON.stringify(value);
73
+ }
74
+ case BSONTypes_1.BSONTypes.Array:
75
+ case BSONTypes_1.BSONTypes.Object:
76
+ case BSONTypes_1.BSONTypes.Map:
77
+ case BSONTypes_1.BSONTypes.DBRef:
78
+ case BSONTypes_1.BSONTypes.Undefined:
79
+ case BSONTypes_1.BSONTypes._UNKNOWN_:
80
+ default: {
81
+ return JSON.stringify(value);
82
+ }
83
+ }
84
+ }
85
+ //# sourceMappingURL=ValueFormatters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ValueFormatters.js","sourceRoot":"","sources":["../src/ValueFormatters.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AAuBhG,oDA0DC;AA9ED,2CAAwC;AAExC;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,oBAAoB,CAAC,KAAc,EAAE,IAAe;IAChE,QAAQ,IAAI,EAAE,CAAC;QACX,KAAK,qBAAS,CAAC,MAAM,CAAC,CAAC,CAAC;YACpB,OAAO,KAAe,CAAC;QAC3B,CAAC;QACD,KAAK,qBAAS,CAAC,MAAM,CAAC;QACtB,KAAK,qBAAS,CAAC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