UNPKG

@azure/cosmos

Version:
64 lines (63 loc) 2.79 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var typeChecks_exports = {}; __export(typeChecks_exports, { assertNotUndefined: () => assertNotUndefined, isNonePartitionKeyValue: () => isNonePartitionKeyValue, isNullPartitionKeyValue: () => isNullPartitionKeyValue, isPartitionKey: () => isPartitionKey, isPrefixPartitionKey: () => isPrefixPartitionKey, isPrimitivePartitionKeyValue: () => isPrimitivePartitionKeyValue, isWellDefinedPartitionKeyValue: () => isWellDefinedPartitionKeyValue }); module.exports = __toCommonJS(typeChecks_exports); var import_documents = require("../documents/index.js"); function assertNotUndefined(value, msg) { if (value !== void 0) { return value; } throw new Error(msg || "Unexpected 'undefined' value encountered"); } function isPrimitivePartitionKeyValue(value) { return isWellDefinedPartitionKeyValue(value) || isNonePartitionKeyValue(value) || isNullPartitionKeyValue(value); } function isWellDefinedPartitionKeyValue(value) { return typeof value === "string" || typeof value === "boolean" || typeof value === "number"; } function isNonePartitionKeyValue(value) { return value !== void 0 && JSON.stringify(value) === JSON.stringify(import_documents.NonePartitionKeyLiteral); } function isNullPartitionKeyValue(value) { return value === import_documents.NullPartitionKeyLiteral; } function isPartitionKey(partitionKey) { return isPrimitivePartitionKeyValue(partitionKey) || Array.isArray(partitionKey); } function isPrefixPartitionKey(partitionKey, partitionKeyDefinition) { return partitionKeyDefinition && partitionKeyDefinition.paths && partitionKeyDefinition.kind === import_documents.PartitionKeyKind.MultiHash && Array.isArray(partitionKey) && partitionKey.length < partitionKeyDefinition.paths.length; } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { assertNotUndefined, isNonePartitionKeyValue, isNullPartitionKeyValue, isPartitionKey, isPrefixPartitionKey, isPrimitivePartitionKeyValue, isWellDefinedPartitionKeyValue });