UNPKG

@deepkit/bson

Version:

Deepkit BSON parser

132 lines 7.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BSON_BINARY_SUBTYPE_USER_DEFINED = exports.BSON_BINARY_SUBTYPE_COLUMN = exports.BSON_BINARY_SUBTYPE_ENCRYPT = exports.BSON_BINARY_SUBTYPE_MD5 = exports.BSON_BINARY_SUBTYPE_UUID = exports.BSON_BINARY_SUBTYPE_UUID_OLD = exports.BSON_BINARY_SUBTYPE_BYTE_ARRAY = exports.BSON_BINARY_SUBTYPE_FUNCTION = exports.BSON_BINARY_SUBTYPE_DEFAULT = exports.BSONType = exports.__ΩBSONType = exports.BSON_DATA_MAX_KEY = exports.BSON_DATA_MIN_KEY = exports.BSON_DATA_DECIMAL128 = exports.BSON_DATA_LONG = exports.BSON_DATA_TIMESTAMP = exports.BSON_DATA_INT = exports.BSON_DATA_CODE_W_SCOPE = exports.BSON_DATA_SYMBOL = exports.BSON_DATA_CODE = exports.BSON_DATA_DBPOINTER = exports.BSON_DATA_REGEXP = exports.BSON_DATA_NULL = exports.BSON_DATA_DATE = exports.BSON_DATA_BOOLEAN = exports.BSON_DATA_OID = exports.BSON_DATA_UNDEFINED = exports.BSON_DATA_BINARY = exports.BSON_DATA_ARRAY = exports.BSON_DATA_OBJECT = exports.BSON_DATA_STRING = exports.BSON_DATA_NUMBER = exports.TWO_PWR_32_DBL_N = void 0; exports.digitByteSize = digitByteSize; exports.getEmbeddedPropertyName = getEmbeddedPropertyName; exports.getEmbeddedAccessor = getEmbeddedAccessor; exports.isSerializable = isSerializable; /*@ts-ignore*/ var { __ΩTypeProperty, __ΩEmbeddedOptions, __ΩTypeClass } = require('@deepkit/type'); /* * Deepkit Framework * Copyright (C) 2021 Deepkit UG, Marc J. Schmidt * * This program is free software: you can redistribute it and/or modify * it under the terms of the MIT License. * * You should have received a copy of the MIT License along with this program. */ const type_1 = require("@deepkit/type"); exports.TWO_PWR_32_DBL_N = (1 << 16) * (1 << 16); exports.BSON_DATA_NUMBER = 1; exports.BSON_DATA_STRING = 2; exports.BSON_DATA_OBJECT = 3; exports.BSON_DATA_ARRAY = 4; exports.BSON_DATA_BINARY = 5; exports.BSON_DATA_UNDEFINED = 6; exports.BSON_DATA_OID = 7; exports.BSON_DATA_BOOLEAN = 8; exports.BSON_DATA_DATE = 9; exports.BSON_DATA_NULL = 10; exports.BSON_DATA_REGEXP = 11; exports.BSON_DATA_DBPOINTER = 12; exports.BSON_DATA_CODE = 13; exports.BSON_DATA_SYMBOL = 14; exports.BSON_DATA_CODE_W_SCOPE = 15; exports.BSON_DATA_INT = 16; exports.BSON_DATA_TIMESTAMP = 17; exports.BSON_DATA_LONG = 18; exports.BSON_DATA_DECIMAL128 = 19; exports.BSON_DATA_MIN_KEY = 0xff; exports.BSON_DATA_MAX_KEY = 0x7f; const __ΩBSONType = ['NUMBER', () => 1, 'STRING', () => 2, 'OBJECT', () => 3, 'ARRAY', () => 4, 'BINARY', () => 5, 'UNDEFINED', () => 6, 'OID', () => 7, 'BOOLEAN', () => 8, 'DATE', () => 9, 'NULL', () => 10, 'REGEXP', () => 11, 'DBPOINTER', () => 12, 'CODE', () => 13, 'SYMBOL', () => 14, 'CODE_W_SCOPE', () => 15, 'INT', () => 16, 'TIMESTAMP', () => 17, 'LONG', () => 18, 'DECIMAL128', () => 19, 'MIN_KEY', () => 255, 'MAX_KEY', () => 127, 'BSONType', 'PC!>"C#>$C%>&C\'>(C)>*C+>,C->.C/>0C1>2C3>4C5>6C7>8C9>:C;><C=>>C?>@CA>BCC>DCE>FCG>HCI>JBwK']; exports.__ΩBSONType = __ΩBSONType; var BSONType; (function (BSONType) { BSONType[BSONType["NUMBER"] = 1] = "NUMBER"; BSONType[BSONType["STRING"] = 2] = "STRING"; BSONType[BSONType["OBJECT"] = 3] = "OBJECT"; BSONType[BSONType["ARRAY"] = 4] = "ARRAY"; BSONType[BSONType["BINARY"] = 5] = "BINARY"; BSONType[BSONType["UNDEFINED"] = 6] = "UNDEFINED"; BSONType[BSONType["OID"] = 7] = "OID"; BSONType[BSONType["BOOLEAN"] = 8] = "BOOLEAN"; BSONType[BSONType["DATE"] = 9] = "DATE"; BSONType[BSONType["NULL"] = 10] = "NULL"; BSONType[BSONType["REGEXP"] = 11] = "REGEXP"; BSONType[BSONType["DBPOINTER"] = 12] = "DBPOINTER"; BSONType[BSONType["CODE"] = 13] = "CODE"; BSONType[BSONType["SYMBOL"] = 14] = "SYMBOL"; BSONType[BSONType["CODE_W_SCOPE"] = 15] = "CODE_W_SCOPE"; BSONType[BSONType["INT"] = 16] = "INT"; BSONType[BSONType["TIMESTAMP"] = 17] = "TIMESTAMP"; BSONType[BSONType["LONG"] = 18] = "LONG"; BSONType[BSONType["DECIMAL128"] = 19] = "DECIMAL128"; BSONType[BSONType["MIN_KEY"] = 255] = "MIN_KEY"; BSONType[BSONType["MAX_KEY"] = 127] = "MAX_KEY"; })(BSONType || (exports.BSONType = BSONType = {})); exports.BSON_BINARY_SUBTYPE_DEFAULT = 0; exports.BSON_BINARY_SUBTYPE_FUNCTION = 1; exports.BSON_BINARY_SUBTYPE_BYTE_ARRAY = 2; exports.BSON_BINARY_SUBTYPE_UUID_OLD = 3; exports.BSON_BINARY_SUBTYPE_UUID = 4; exports.BSON_BINARY_SUBTYPE_MD5 = 5; exports.BSON_BINARY_SUBTYPE_ENCRYPT = 6; exports.BSON_BINARY_SUBTYPE_COLUMN = 7; exports.BSON_BINARY_SUBTYPE_USER_DEFINED = 128; function digitByteSize(v) { if (v < 10) return 2; if (v < 100) return 3; if (v < 1000) return 4; if (v < 10000) return 5; if (v < 100000) return 6; if (v < 1000000) return 7; if (v < 10000000) return 8; if (v < 100000000) return 9; if (v < 1000000000) return 10; return 11; } digitByteSize.__type = ['v', 'digitByteSize', 'P\'2!\'/"']; function getEmbeddedPropertyName(serializer, namingStrategy, property, embedded) { let embeddedPropertyName = String(namingStrategy.getPropertyName(property, serializer.name)); if (embedded.prefix !== undefined) { embeddedPropertyName = embedded.prefix + embeddedPropertyName; } return embeddedPropertyName; } getEmbeddedPropertyName.__type = [() => type_1.Serializer, 'serializer', () => type_1.NamingStrategy, 'namingStrategy', () => __ΩTypeProperty, 'property', () => __ΩEmbeddedOptions, 'embedded', 'getEmbeddedPropertyName', 'PP7!2"P7#2$n%2&n\'2(&/)']; function getEmbeddedAccessor(type, autoPrefix, accessor, serializer, namingStrategy, property, embedded, container) { const containerProperty = (0, type_1.getEmbeddedProperty)(type); let embeddedPropertyName = String(namingStrategy.getPropertyName(property, serializer.name)); if (embedded.prefix !== undefined) { embeddedPropertyName = embedded.prefix + embeddedPropertyName; } else if (containerProperty) { embeddedPropertyName = String(containerProperty.name) + '_' + embeddedPropertyName; } if ((autoPrefix || embedded.prefix !== undefined)) { //if autoPrefix or a prefix is set the embeddedPropertyName is emitted in a container, either manually provided or from accessor. if (containerProperty) return embeddedPropertyName; if (container) return embeddedPropertyName; } if (containerProperty) return String(containerProperty.name); return accessor; } getEmbeddedAccessor.__type = [() => __ΩTypeClass, 'type', 'autoPrefix', 'accessor', () => type_1.Serializer, 'serializer', () => type_1.NamingStrategy, 'namingStrategy', () => __ΩTypeProperty, 'property', () => __ΩEmbeddedOptions, 'embedded', 'container', 'getEmbeddedAccessor', 'Pn!2")2#&2$P7%2&P7\'2(n)2*n+2,&2-8&/.']; function isSerializable(type) { return type.kind !== type_1.ReflectionKind.methodSignature && type.kind !== type_1.ReflectionKind.method && type.kind !== type_1.ReflectionKind.function; } isSerializable.__type = ['Type', 'type', 'isSerializable', 'P"w!2")/#']; //# sourceMappingURL=utils.js.map