@routier/core 0.6.0 → 0.7.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.
Files changed (52) hide show
  1. package/dist/assertions/index.cjs +19 -8
  2. package/dist/assertions/index.cjs.map +1 -1
  3. package/dist/assertions/index.d.ts +5 -1
  4. package/dist/assertions/index.js +21 -9
  5. package/dist/assertions/index.js.map +1 -1
  6. package/dist/collections/MemoryDataCollection.d.ts +10 -0
  7. package/dist/collections/index.cjs +29 -4
  8. package/dist/collections/index.cjs.map +1 -1
  9. package/dist/collections/index.js +29 -4
  10. package/dist/collections/index.js.map +1 -1
  11. package/dist/expressions/callSource.d.ts +41 -0
  12. package/dist/expressions/evaluate.d.ts +3 -0
  13. package/dist/expressions/fold.d.ts +7 -0
  14. package/dist/expressions/index.cjs +1754 -233
  15. package/dist/expressions/index.cjs.map +1 -1
  16. package/dist/expressions/index.d.ts +2 -0
  17. package/dist/expressions/index.js +1765 -234
  18. package/dist/expressions/index.js.map +1 -1
  19. package/dist/expressions/types.d.ts +45 -26
  20. package/dist/expressions/utils.d.ts +19 -1
  21. package/dist/index.cjs +2415 -364
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.js +2755 -684
  24. package/dist/index.js.map +1 -1
  25. package/dist/performance/index.cjs +6 -4
  26. package/dist/performance/index.cjs.map +1 -1
  27. package/dist/performance/index.js +6 -4
  28. package/dist/performance/index.js.map +1 -1
  29. package/dist/pipeline/index.cjs +6 -4
  30. package/dist/pipeline/index.cjs.map +1 -1
  31. package/dist/pipeline/index.js +6 -4
  32. package/dist/pipeline/index.js.map +1 -1
  33. package/dist/plugins/index.cjs +2309 -316
  34. package/dist/plugins/index.cjs.map +1 -1
  35. package/dist/plugins/index.js +2313 -311
  36. package/dist/plugins/index.js.map +1 -1
  37. package/dist/plugins/query/QueryOptionsCollection.d.ts +38 -10
  38. package/dist/plugins/query/describeFilter.d.ts +83 -0
  39. package/dist/plugins/query/explain.d.ts +71 -9
  40. package/dist/plugins/query/index.d.ts +1 -0
  41. package/dist/plugins/query/join.d.ts +4 -1
  42. package/dist/plugins/query/types.d.ts +36 -4
  43. package/dist/schema/PropertyInfo.d.ts +0 -1
  44. package/dist/schema/index.cjs +7 -14
  45. package/dist/schema/index.cjs.map +1 -1
  46. package/dist/schema/index.js +7 -14
  47. package/dist/schema/index.js.map +1 -1
  48. package/dist/utilities/index.cjs +242 -49
  49. package/dist/utilities/index.cjs.map +1 -1
  50. package/dist/utilities/index.js +242 -49
  51. package/dist/utilities/index.js.map +1 -1
  52. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"utilities/index.cjs","sources":["webpack://@routier/core/./src/assertions/index.ts","webpack://@routier/core/./src/expressions/utils.ts","webpack://@routier/core/./src/plugins/query/QueryOptionsCollection.ts","webpack://@routier/core/./src/utilities/dates.ts","webpack://@routier/core/./src/utilities/logger.ts","webpack://@routier/core/./src/utilities/strings.ts","webpack://@routier/core/./src/utilities/uuid.ts","webpack://@routier/core/webpack/runtime/define_property_getters","webpack://@routier/core/webpack/runtime/has_own_property","webpack://@routier/core/webpack/runtime/make_namespace_object","webpack://@routier/core/./src/utilities/arrays.ts","webpack://@routier/core/./src/utilities/objects.ts","webpack://@routier/core/./src/utilities/runtime.ts","webpack://@routier/core/./src/utilities/replication.ts","webpack://@routier/core/./src/utilities/queryOptionsCollection.ts","webpack://@routier/core/./src/utilities/dbPluginEventUtils.ts","webpack://@routier/core/./src/utilities/functions.ts","webpack://@routier/core/./src/utilities/unsafeCast.ts","webpack://@routier/core/./src/utilities/index.ts"],"sourcesContent":["import { EXPRESSION_TYPES } from \"../expressions/constants\";\nimport { ComparatorExpression, EmptyExpression, Expression, ExpressionType, NotParsableExpression, OperatorExpression, PropertyExpression, ValueExpression } from \"../expressions/types\";\nimport { isDate } from \"../utilities\";\n\nexport function assertDate(data: unknown): asserts data is Date {\n if (isDate(data) === false) {\n throw new TypeError('Value is not a Date');\n }\n}\n\nexport function assertIsNotNull<T>(data: T | null | undefined, message?: string | (() => string)): asserts data is NonNullable<T> {\n if (data == null) {\n if (message == null) {\n throw new TypeError('Assertion failed, data is null');\n }\n\n if (typeof message === \"string\") {\n throw new TypeError(message);\n }\n\n throw new TypeError(message());\n }\n}\n\nexport function assertIsArray<T>(data: unknown, message?: string): asserts data is T[] {\n if (!Array.isArray(data)) {\n throw new TypeError(message ?? 'Assertion failed, data is not of type Array');\n }\n}\n\nexport function assertString(data: unknown, message?: string): asserts data is string {\n if (typeof data !== \"string\") {\n throw new TypeError(message ?? 'Assertion failed, data is not of type String');\n }\n}\n\nexport function assertInstanceOf<T extends new (...args: any[]) => any>(value: unknown, Instance: T): asserts value is T {\n if (value instanceof Instance) {\n return;\n }\n\n if (value != null && typeof value === \"object\" && \"constructor\" in value) {\n throw new TypeError(`value is not instance of type. Type: ${value.constructor.name}`);\n }\n\n throw new TypeError(`value is not instance of type`);\n}\n\nexport function assertIsNumber(value: unknown): asserts value is number {\n if (typeof value !== \"number\") {\n throw new TypeError(\"value is not of type `number`\");\n }\n}\n\n\nfunction isObjectWithType(value: unknown): value is Record<\"type\", unknown> {\n return typeof value === \"object\" && value !== null && \"type\" in value;\n}\n\n/**\n * Type guard: narrows `value` to `Expression` when it is an object with a valid `type` property.\n */\nexport function isExpression(value: unknown): value is Expression {\n return isObjectWithType(value) && EXPRESSION_TYPES.includes(value.type as ExpressionType);\n}\n\n/**\n * Type guard: narrows `value` to `OperatorExpression` when it is an object with `type === \"operator\"`.\n */\nexport function isOperatorExpression(value: unknown): value is OperatorExpression {\n return isObjectWithType(value) && value.type === \"operator\";\n}\n\n/**\n * Type guard: narrows `value` to `ComparatorExpression` when it is an object with `type === \"comparator\"`.\n */\nexport function isComparatorExpression(value: unknown): value is ComparatorExpression {\n return isObjectWithType(value) && value.type === \"comparator\";\n}\n\n/**\n * Type guard: narrows `value` to `PropertyExpression` when it is an object with `type === \"property\"`.\n */\nexport function isPropertyExpression(value: unknown): value is PropertyExpression {\n return isObjectWithType(value) && value.type === \"property\";\n}\n\n/**\n * Type guard: narrows `value` to `ValueExpression` when it is an object with `type === \"value\"`.\n */\nexport function isValueExpression(value: unknown): value is ValueExpression {\n return isObjectWithType(value) && value.type === \"value\";\n}\n\n/**\n * Type guard: narrows `value` to `EmptyExpression` when it is an object with `type === \"empty\"`.\n */\nexport function isEmptyExpression(value: unknown): value is EmptyExpression {\n return isObjectWithType(value) && value.type === \"empty\";\n}\n\n/**\n * Type guard: narrows `value` to `NotParsableExpression` when it is an object with `type === \"not-parsable\"`.\n */\nexport function isNotParsableExpression(value: unknown): value is NotParsableExpression {\n return isObjectWithType(value) && value.type === \"not-parsable\";\n}","import { PropertyInfo } from \"../schema\";\nimport { Expression, PropertyExpression } from \"./types\";\n\n/**\n * Extracts all properties referenced in an expression\n * @param expression The expression to analyze\n * @returns Array of PropertyInfo objects referenced in the expression\n */\nexport function getProperties(expression: Expression): PropertyInfo<any>[] {\n const properties: PropertyInfo<any>[] = [];\n\n function traverse(expr: Expression) {\n // If this is a property expression, add it to our collection\n if (expr.type === \"property\") {\n properties.push((expr as PropertyExpression).property);\n }\n\n // Traverse left and right expressions if they exist\n if (expr.left) {\n traverse(expr.left);\n }\n if (expr.right) {\n traverse(expr.right);\n }\n }\n\n traverse(expression);\n return properties;\n}\n\nexport function forEach(expression: Expression, callback: (expression: Expression) => boolean) {\n function traverse(expr: Expression): boolean {\n // Call the callback for this expression\n // If callback returns false, stop traversing\n if (!callback(expr)) {\n return false;\n }\n\n // Traverse left and right expressions if they exist\n if (expr.left) {\n if (!traverse(expr.left)) {\n return false;\n }\n }\n if (expr.right) {\n if (!traverse(expr.right)) {\n return false;\n }\n }\n\n return true;\n }\n\n traverse(expression);\n}","import { isPropertyExpression } from \"../../assertions\";\nimport { forEach } from \"../../expressions/utils\";\nimport { MemoryExecutionReason, QueryOption, QueryOptionName, QueryOptionExecutionTarget, QueryOptionValueMap } from \"./types\";\n\nexport type QueryCollectionItem<T, K extends QueryOptionName> = { index: number, option: QueryOption<T, K> };\n\nexport class QueryOptionsCollection<T> {\n\n private options: Map<QueryOptionName, QueryCollectionItem<any, any>[]> = new Map<QueryOptionName, QueryCollectionItem<any, any>[]>();\n private nextExecutionTarget: QueryOptionExecutionTarget = \"database\";\n private nextExecutionReason: MemoryExecutionReason | null = null;\n private nextIndex: number = 0;\n private enumeratedItems: QueryCollectionItem<any, any>[] = [];\n\n /** Cuts over to memory execution, keeping the first cause. See `MemoryExecutionReason`. */\n private cutOverToMemory(reason: MemoryExecutionReason) {\n this.nextExecutionTarget = \"memory\";\n\n if (this.nextExecutionReason == null) {\n this.nextExecutionReason = reason;\n }\n }\n\n /**\n * True when `split()` or `splitAt()` produced this collection.\n *\n * Those rebuild each half by re-adding its options, which re-derives execution targets\n * without the options that caused them — a post-join filter alone in the memory half\n * derives back to `\"database\"`. Anything reading `target` as a report of where work runs\n * has to reject a derived collection; see `explainQuery`.\n */\n private derived: boolean = false;\n\n get isDerived() {\n return this.derived;\n }\n\n get items() {\n return this.options;\n }\n\n get isEmpty() {\n return this.items.size === 0;\n }\n\n static EMPTY<R>() {\n return new QueryOptionsCollection<R>();\n }\n\n static isEmpty<T>(options: QueryOptionsCollection<T>) {\n return options.isEmpty;\n }\n\n add<K extends QueryOptionName>(name: K, value: QueryOption<T, K>[\"value\"]) {\n\n if (name === \"map\") {\n const mapValue = value as QueryOptionValueMap<T>[\"map\"];\n\n // Evaluate the map value to see if we are renaming properties, \n // if we are we need to perform everything after in memory\n if (mapValue.fields.some(x => x.isRename === true) || mapValue.fields.some(x => x.property?.isUnmapped === true)) {\n // Cut over to memory execution since we are renaming a property with .map\n // We do not want to figure out how the new name flows through the entire query\n this.cutOverToMemory(\"map-rename\");\n }\n }\n\n if (name === \"filter\") {\n // Need to check for unmapped and renamed properties\n const filterValue = value as QueryOptionValueMap<T>[\"filter\"];\n\n // A tautology (`x => true`) filters nothing — skip it entirely so\n // plugins never see it\n if (filterValue.expression.type === \"empty\") {\n return;\n }\n\n if (filterValue.expression.type === \"not-parsable\") {\n this.cutOverToMemory(\"not-parsable\");\n } else {\n forEach(filterValue.expression, (expression) => {\n\n if (isPropertyExpression(expression) && expression.property.isUnmapped) {\n // Cut over to memory execution, unmapped properties are not in the database and\n // cannot be queried\n this.cutOverToMemory(\"unmapped-property\");\n return false;\n }\n\n if (isPropertyExpression(expression) && expression.property.hasRenamedSegments) {\n // Cut over to memory execution: the plugin stores data under the\n // `from` (storage) names, but filter selectors reference the\n // in-memory names. Memory execution runs after deserialization,\n // where the in-memory names exist\n this.cutOverToMemory(\"renamed-property\");\n return false;\n }\n\n return true;\n });\n }\n }\n\n if (name === \"sort\") {\n const sortValue = value as QueryOptionValueMap<T>[\"sort\"];\n\n // Same rule as filters: sort selectors reference in-memory names, which\n // only exist after deserialization when the property is renamed or unmapped\n if (sortValue.property != null && sortValue.property.isUnmapped) {\n this.cutOverToMemory(\"unmapped-property\");\n } else if (sortValue.property != null && sortValue.property.hasRenamedSegments) {\n this.cutOverToMemory(\"renamed-property\");\n }\n }\n\n if (name === \"nearest\") {\n const nearestValue = value as QueryOptionValueMap<T>[\"nearest\"];\n\n // Same rule as sort, and for the same reason: the plugin stores the vector under\n // the `from` name, and an unmapped property is not stored at all. Both are only\n // readable after deserialization, which is where memory execution runs.\n //\n // This is also what lets every translator's in-memory fallback read the column by\n // its resolved name — anything whose storage name differs never reaches them.\n if (nearestValue.property != null && nearestValue.property.isUnmapped) {\n this.cutOverToMemory(\"unmapped-property\");\n } else if (nearestValue.property != null && nearestValue.property.hasRenamedSegments) {\n this.cutOverToMemory(\"renamed-property\");\n }\n }\n\n if (name === \"join\") {\n const joinValue = value as QueryOptionValueMap<T>[\"join\"];\n\n // A join whose two sides live on different plugins cannot be sent to EITHER of\n // them — neither can read the other's rows — so the option itself belongs to the\n // memory half, where the datastore interprets it.\n //\n // Set BEFORE the item is created, unlike `nearest`'s ratchet below, because this\n // moves the join option itself rather than everything after it.\n if (joinValue.crossPlugin === true) {\n this.cutOverToMemory(\"cross-plugin-join\");\n }\n }\n\n const item: QueryCollectionItem<T, K> = {\n index: this.nextIndex,\n option: {\n name,\n target: this.nextExecutionTarget,\n value,\n ...(this.nextExecutionReason == null ? {} : { reason: this.nextExecutionReason })\n }\n }\n\n this.nextIndex++;\n\n const found = this.options.get(name);\n\n this.options.set(name, [...found ?? [], item]);\n\n if (name === \"nearest\") {\n // Everything AFTER a similarity search runs in memory, whatever the backend.\n //\n // Whether the search was pushed down is a fact about the plugin, which this\n // collection cannot see — so a later option is only safe if it runs after the\n // scoring definitely happened, and in memory is the only place that is true of.\n //\n // The failure this prevents is silent. `.nearest(x => x.embedding, v, 10).take(3)`\n // sends `LIMIT 3` to a backend that ignored the ordering, so three arbitrary rows\n // come back and get scored — three real rows, in a plausible order, and not the\n // three nearest. Nothing errors.\n //\n // A plugin that DID push the search down loses nothing but the chance to also\n // push down what follows it, which is a limit over ten rows.\n this.cutOverToMemory(\"after-nearest\");\n }\n\n if (name === \"join\") {\n // Everything AFTER a join runs in memory, for the same reason as `nearest`: this\n // collection cannot see HOW the plugin executed the join, and the rows it produced\n // are TUPLES rather than entities of the root schema.\n //\n // A `take` sent to a backend that hash-joined in its translator would limit the\n // OUTER rows read, not the pairs produced — a plausible-looking result with the\n // wrong number of rows in it. Conjuncts that can safely run earlier are split off\n // by the query builder BEFORE dispatch, which is the only exception.\n this.cutOverToMemory(\"after-join\");\n }\n }\n\n /**\n * Splits the collection around the FIRST occurrence of `name`, preserving order.\n *\n * For a join: the options recorded before it operate on entity rows, the option itself\n * produces tuples, and the ones after it operate on tuples. Three different shapes, so the\n * caller has to run them in three steps rather than one pass.\n */\n splitAt<K extends QueryOptionName>(name: K): { before: QueryOptionsCollection<T>, at: QueryOption<T, K> | null, after: QueryOptionsCollection<T> } {\n this.resolveEnumeration();\n\n const sortedItems = this.enumeratedItems.toSorted((a, b) => a.index - b.index);\n const before = new QueryOptionsCollection<T>();\n const after = new QueryOptionsCollection<T>();\n\n before.derived = true;\n after.derived = true;\n let at: QueryOption<T, K> | null = null;\n\n for (let i = 0, length = sortedItems.length; i < length; i++) {\n const { option } = sortedItems[i];\n\n if (at == null && option.name === name) {\n at = option as QueryOption<T, K>;\n continue;\n }\n\n const destination = at == null ? before : after;\n destination.add(option.name, option.value);\n }\n\n return { before, at, after };\n }\n\n /**\n * Captures the collection's current state and returns a function that restores it.\n *\n * Terminal queryable operations (count, first, aggregates, …) record their option on\n * the shared collection before executing. Without restoring, a re-executed terminal —\n * the whole point of a subscribed queryable — stacks its option a second time and\n * runs it over the first execution's scalar result.\n */\n snapshot(): () => void {\n const options = new Map([...this.options.entries()].map(([key, items]): [QueryOptionName, QueryCollectionItem<any, any>[]] => [key, [...items]]));\n const nextExecutionTarget = this.nextExecutionTarget;\n const nextExecutionReason = this.nextExecutionReason;\n const nextIndex = this.nextIndex;\n\n return () => {\n this.options = new Map(options);\n this.nextExecutionTarget = nextExecutionTarget;\n this.nextExecutionReason = nextExecutionReason;\n this.nextIndex = nextIndex;\n this.enumeratedItems = [];\n };\n }\n\n split(): { memory: QueryOptionsCollection<T>, database: QueryOptionsCollection<T> } {\n this.resolveEnumeration();\n\n const sortedItems = this.enumeratedItems.toSorted((a, b) => a.index - b.index);\n const memoryQueryOptionsCollection = new QueryOptionsCollection<T>();\n const databaseQueryOptionsCollection = new QueryOptionsCollection<T>();\n\n memoryQueryOptionsCollection.derived = true;\n databaseQueryOptionsCollection.derived = true;\n\n for (let i = 0, length = sortedItems.length; i < length; i++) {\n const sortedItem = sortedItems[i];\n\n if (sortedItem.option.target === \"database\") {\n databaseQueryOptionsCollection.add(sortedItem.option.name, sortedItem.option.value);\n continue;\n }\n\n memoryQueryOptionsCollection.add(sortedItem.option.name, sortedItem.option.value);\n }\n\n return {\n memory: memoryQueryOptionsCollection,\n database: databaseQueryOptionsCollection\n }\n }\n\n hasTransformations(): boolean {\n const transformationOptions: QueryOptionName[] = [\"map\", \"group\", \"min\", \"max\", \"count\", \"sum\"];\n return transformationOptions.some((name) => this.options.has(name));\n }\n\n has<K extends QueryOptionName>(name: K): boolean {\n return this.options.has(name);\n }\n\n get<K extends QueryOptionName>(name: K): QueryCollectionItem<T, K>[] {\n return this.options.get(name) ?? [] as QueryCollectionItem<T, K>[];\n }\n\n getLast<K extends QueryOptionName>(name: K): QueryOption<T, K> | null {\n this.resolveEnumeration();\n\n for (let i = this.enumeratedItems.length - 1; i >= 0; i--) {\n const item = this.enumeratedItems[i];\n\n if (item.option.name === name) {\n return item.option;\n }\n }\n\n return null\n }\n\n getValues<K extends QueryOptionName>(name: K): QueryCollectionItem<T, K>[\"option\"][\"value\"][] | undefined {\n\n const found = this.options.get(name);\n\n if (found == null) {\n return [];\n }\n\n return found.map(w => w.option.value) as QueryCollectionItem<T, K>[\"option\"][\"value\"][];\n }\n\n private getEnumeration() {\n return [...this.options.values()].flat().toSorted((a, b) => a.index - b.index);\n }\n\n private resolveEnumeration() {\n if (this.enumeratedItems.length != this.nextIndex) {\n this.enumeratedItems = this.getEnumeration();\n }\n }\n\n forEach(iterator: (item: QueryCollectionItem<T, any>[\"option\"]) => void) {\n this.resolveEnumeration();\n\n for (let i = 0, length = this.enumeratedItems.length; i < length; i++) {\n iterator(this.enumeratedItems[i].option);\n }\n }\n}","export const isDate = (data: unknown): data is Date => {\n if (data == null) {\n return false;\n }\n\n if (typeof data !== \"object\") {\n return false;\n }\n\n return data instanceof Date;\n}","/**\n * Levelled logging, resolved once.\n *\n * Three things about the previous implementation drove this shape:\n *\n * - **There was no way to turn logging off.** `globalThis.__ROUTIER_DEBUG__` was only ever\n * compared against `true`, so setting it to `false` did nothing — while\n * `docs/how-to/debug-logging.md` documented exactly that as the way to force logging off.\n * A documented switch that silently does nothing is worse than no switch.\n * - **`NODE_ENV === 'test'` enabled it.** Every Jest run therefore logged, because Jest always\n * sets `NODE_ENV=test`. Measured on the S7 stress scenario, which drives ~2,000 saves through\n * a plugin that logs three lines per query: 12.4s with logging, ~6s without. Test runners also\n * capture console output by snapshotting a stack trace per call, so the cost is far above what\n * writing to a terminal would suggest — and the output buries whatever the failure was.\n * - **It was all-or-nothing, and re-resolved per call.** An error could not be kept while debug\n * was dropped, and every one of the ~97 call sites re-read `globalThis` and `process.env`.\n *\n * Levels are compared numerically against a value cached at module load. Measured against a\n * no-op console at 200k calls: an enabled call costs ~70ns, a call rejected by the gate ~3ns.\n * Building the arguments the call site passes in accounts for ~0.2ns of that 3ns, which is why\n * this keeps the ordinary `logger.debug(msg, payload)` signature instead of taking a thunk —\n * a lazy API would recover 0.3% of an enabled call's cost and would have to change every call\n * site to do it.\n */\n\n/** Ordered from most severe to most verbose. `silent` discards everything. */\nexport const LOG_LEVELS = ['silent', 'error', 'warn', 'info', 'debug'] as const;\n\nexport type LogLevel = (typeof LOG_LEVELS)[number];\n\n/** Numeric rank, so a gate is one integer comparison. */\nconst RANK: Record<LogLevel, number> = {\n silent: 0,\n error: 1,\n warn: 2,\n info: 3,\n debug: 4,\n};\n\nconst isLogLevel = (value: unknown): value is LogLevel =>\n typeof value === 'string' && (LOG_LEVELS as readonly string[]).includes(value);\n\n/**\n * Resolves the configured level, in precedence order.\n *\n * Ordered most specific first: an explicit level beats a boolean flag, a boolean flag beats an\n * environment variable, and an environment variable beats an inference from `NODE_ENV`. Anything\n * unrecognised is ignored rather than treated as an error — a typo'd level should not take down\n * an application, and `silent` is the safe direction to fall back to.\n */\nconst resolveLevel = (): LogLevel => {\n if (typeof globalThis !== 'undefined') {\n const g = globalThis as { __ROUTIER_LOG_LEVEL__?: unknown; __ROUTIER_DEBUG__?: unknown };\n\n if (isLogLevel(g.__ROUTIER_LOG_LEVEL__)) {\n return g.__ROUTIER_LOG_LEVEL__;\n }\n\n // Both directions honoured. `=== false` used to fall through to the NODE_ENV checks\n // below and re-enable the logging it was asked to suppress.\n if (g.__ROUTIER_DEBUG__ === true) return 'debug';\n if (g.__ROUTIER_DEBUG__ === false) return 'silent';\n }\n\n // There is deliberately no `import.meta.env` branch, although the documentation used to\n // promise one. It could never work: this package is bundled with rspack, which replaces\n // `import.meta` with `undefined`, so the check would read the *library's* build-time\n // environment rather than the application's — and referencing `import.meta` at all is a parse\n // error under a CommonJS build target, which is how the test suite loads this file. Vite and\n // similar apps set `__ROUTIER_LOG_LEVEL__` or `__ROUTIER_DEBUG__` from their own\n // `import.meta.env`, which is what the docs now describe.\n if (typeof process !== 'undefined' && process.env != null) {\n if (isLogLevel(process.env.ROUTIER_LOG_LEVEL)) {\n return process.env.ROUTIER_LOG_LEVEL as LogLevel;\n }\n\n const debug = process.env.DEBUG;\n if (debug === 'routier' || debug === '*') return 'debug';\n\n const env = process.env.NODE_ENV?.toLowerCase();\n\n // `test` is deliberately absent. It used to be here, which meant no test suite anywhere\n // could run Routier quietly. Opt in with DEBUG=routier or ROUTIER_LOG_LEVEL when a test\n // needs the output.\n if (env === 'dev' || env === 'development') return 'debug';\n }\n\n return 'silent';\n};\n\nlet level: LogLevel = resolveLevel();\nlet rank = RANK[level];\n\n/**\n * Overrides the level for the rest of the process.\n *\n * The configuration above is read once, at import, which is what makes the gate cheap — but it\n * also means an application that decides its verbosity after startup, or a test that wants to\n * assert on output, has no way in. This is that way in.\n */\nexport const setLogLevel = (next: LogLevel): void => {\n if (isLogLevel(next) === false) {\n throw new Error(`Unknown log level \"${next}\". Expected one of: ${LOG_LEVELS.join(', ')}`);\n }\n\n level = next;\n rank = RANK[next];\n};\n\nexport const getLogLevel = (): LogLevel => level;\n\n/** Re-reads the environment. For tests that change it after this module was imported. */\nexport const resetLogLevel = (): void => {\n level = resolveLevel();\n rank = RANK[level];\n};\n\n/**\n * Whether a message at this level would be emitted.\n *\n * For the rare call site whose *arguments* are expensive to build — a serialization, a deep\n * clone, a join over a large collection. An ordinary payload object is not worth guarding; see\n * the measurement in the header.\n */\nexport const isLogLevelEnabled = (at: LogLevel): boolean => rank >= RANK[at];\n\ntype ConsoleMethod = 'log' | 'info' | 'warn' | 'error' | 'debug' | 'table';\n\nconst emit = (at: LogLevel, method: ConsoleMethod, args: unknown[]) => {\n if (rank < RANK[at]) {\n return;\n }\n\n // Resolved at call time rather than captured once: test harnesses and browser devtools both\n // replace console methods after modules have loaded, and a captured reference would keep\n // writing past the replacement.\n (console[method] as (...a: unknown[]) => void)(...args);\n};\n\nexport const logger = {\n /** General-purpose output. Carried at `info`, since `log` names a console method, not a level. */\n log: (...args: unknown[]): void => emit('info', 'log', args),\n info: (...args: unknown[]): void => emit('info', 'info', args),\n warn: (...args: unknown[]): void => emit('warn', 'warn', args),\n error: (...args: unknown[]): void => emit('error', 'error', args),\n debug: (...args: unknown[]): void => emit('debug', 'debug', args),\n /** Diagnostic tabular output; verbose by nature, so it sits at `debug`. */\n table: (...args: unknown[]): void => emit('debug', 'table', args),\n};\n","export const hash = (value: string, seed: number = 0) => {\n // From Stack Overflow\n // https://stackoverflow.com/a/52171480/3329760\n let h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed;\n\n for (let i = 0, ch: number; i < value.length; i++) {\n ch = value.charCodeAt(i);\n h1 = Math.imul(h1 ^ ch, 2654435761);\n h2 = Math.imul(h2 ^ ch, 1597334677);\n }\n\n h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507);\n h1 ^= Math.imul(h2 ^ (h2 >>> 13), 3266489909);\n h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507);\n h2 ^= Math.imul(h1 ^ (h1 >>> 13), 3266489909);\n\n return 4294967296 * (2097151 & h2) + (h1 >>> 0);\n}\n\n/**\n * Fast string hash optimized for comparisons.\n * Uses djb2 algorithm - very fast and good distribution for short to medium strings.\n * Same input always produces same output (deterministic).\n * \n * @param value - The string to hash\n * @param seed - Optional seed value (default: 5381)\n * @returns A positive 32-bit integer hash value\n * \n * @example\n * ```ts\n * fastHash(\"test\") === fastHash(\"test\") // true\n * fastHash(\"test\") !== fastHash(\"test2\") // true\n * ```\n */\nexport const fastHash = (value: string, seed: number = 5381): number => {\n let hash = seed;\n for (let i = 0; i < value.length; i++) {\n hash = ((hash << 5) + hash) + value.charCodeAt(i);\n }\n return hash >>> 0; // Convert to unsigned 32-bit integer\n}\n\n/**\n * Converts any value to a readable string representation.\n * Handles primitives, objects, arrays, classes, dates, errors, and functions.\n * Supports depth limiting to prevent infinite recursion on circular references.\n * \n * @param obj - The value to stringify\n * @param maxDepth - Maximum depth for nested objects (default: 3)\n * @param currentDepth - Current recursion depth (default: 0)\n * @returns String representation of the value\n * \n * @example\n * ```ts\n * stringifyObject({ name: \"test\", count: 5 }) // '{ name: \"test\", count: 5 }'\n * stringifyObject([1, 2, 3]) // '[1, 2, 3]'\n * stringifyObject(new Date()) // 'Date(2024-01-01T00:00:00.000Z)'\n * ```\n */\nexport function stringifyObject(obj: unknown, maxDepth: number = 3, currentDepth: number = 0): string {\n if (obj === null) return 'null';\n if (obj === undefined) return 'undefined';\n\n const type = typeof obj;\n\n switch (type) {\n case 'string':\n return `\"${obj}\"`;\n case 'number':\n case 'boolean':\n return String(obj);\n case 'function':\n return `[Function: ${getFunctionName(obj as Function)}]`;\n case 'object':\n if (currentDepth >= maxDepth) {\n return '[Max Depth Reached]';\n }\n return stringifyObjectValue(obj, maxDepth, currentDepth);\n default:\n return `[${type}]`;\n }\n}\n\nfunction getFunctionName(fn: Function): string {\n const name = fn.name;\n return name || 'anonymous';\n}\n\nfunction getObjectProperties(obj: any): Record<string, any> {\n const properties: Record<string, any> = {};\n\n for (const key in obj) {\n if (obj.hasOwnProperty(key)) {\n properties[key] = obj[key];\n }\n }\n\n return properties;\n}\n\nfunction stringifyObjectValue(obj: any, maxDepth: number, currentDepth: number): string {\n if (obj === null) return 'null';\n\n if (obj instanceof Date) {\n return `Date(${obj.toISOString()})`;\n }\n\n if (obj instanceof Error) {\n return `Error(${obj.message})`;\n }\n\n if (obj instanceof RegExp) {\n return obj.toString();\n }\n\n if (Array.isArray(obj)) {\n return stringifyArray(obj, maxDepth, currentDepth);\n }\n\n if (obj.constructor && obj.constructor.name !== 'Object') {\n return stringifyClassInstance(obj, maxDepth, currentDepth);\n }\n\n return stringifyPlainObject(obj, maxDepth, currentDepth);\n}\n\nfunction stringifyArray(arr: any[], maxDepth: number, currentDepth: number): string {\n if (arr.length === 0) return '[]';\n\n const items = arr.slice(0, 5).map(item =>\n stringifyObject(item, maxDepth, currentDepth + 1)\n );\n\n const suffix = arr.length > 5 ? `... (+${arr.length - 5} more)` : '';\n return `[${items.join(', ')}${suffix}]`;\n}\n\nfunction stringifyClassInstance(obj: any, maxDepth: number, currentDepth: number): string {\n const className = obj.constructor.name;\n const properties = getObjectProperties(obj);\n\n if (Object.keys(properties).length === 0) {\n return `${className} {}`;\n }\n\n const props = Object.entries(properties)\n .slice(0, 5)\n .map(([key, value]) => {\n const isPrimitive = value === null || value === undefined ||\n (typeof value !== 'object' && typeof value !== 'function');\n const depth = isPrimitive ? currentDepth : currentDepth + 1;\n return `${key}: ${stringifyObject(value, maxDepth, depth)}`;\n });\n\n const suffix = Object.keys(properties).length > 5 ?\n `... (+${Object.keys(properties).length - 5} more)` : '';\n\n return `${className} { ${props.join(', ')}${suffix} }`;\n}\n\nfunction stringifyPlainObject(obj: any, maxDepth: number, currentDepth: number): string {\n const properties = getObjectProperties(obj);\n\n if (Object.keys(properties).length === 0) {\n return '{}';\n }\n\n const props = Object.entries(properties)\n .slice(0, 5)\n .map(([key, value]) => {\n const isPrimitive = value === null || value === undefined ||\n (typeof value !== 'object' && typeof value !== 'function');\n const depth = isPrimitive ? currentDepth : currentDepth + 1;\n return `${key}: ${stringifyObject(value, maxDepth, depth)}`;\n });\n\n const suffix = Object.keys(properties).length > 5 ?\n `... (+${Object.keys(properties).length - 5} more)` : '';\n\n return `{ ${props.join(', ')}${suffix} }`;\n}","export const uuid = (length: number = 16): string => {\n const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n const charLength = chars.length;\n let result = '';\n\n for (let i = 0; i < length; i++) {\n result += chars[Math.random() * charLength | 0];\n }\n return result;\n}\n\nconst HEX_CHARS = '0123456789abcdef';\nconst UUID_TEMPLATE = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';\n\nconst hasCrypto =\n typeof crypto !== 'undefined' && typeof crypto.getRandomValues === 'function';\n\nconst hasRandomUUID =\n typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function';\n\nexport const uuidv4 = (): string => {\n if (hasRandomUUID) {\n return crypto.randomUUID();\n }\n\n return uuidv4Fallback();\n};\n\nconst uuidv4Fallback = (): string => {\n let randomBytes: Uint8Array | null = null;\n if (hasCrypto) {\n randomBytes = crypto.getRandomValues(new Uint8Array(16));\n }\n\n let byteIndex = 0;\n let uuid = '';\n\n for (let i = 0; i < UUID_TEMPLATE.length; i++) {\n const c = UUID_TEMPLATE[i];\n if (c === '-') {\n uuid += '-';\n continue;\n }\n\n let r: number;\n if (hasCrypto && randomBytes) {\n // Each byte gives two hex digits (nibbles)\n r =\n (i % 2 === 0\n ? randomBytes[byteIndex] >> 4\n : randomBytes[byteIndex++] & 0x0f);\n } else {\n r = Math.floor(Math.random() * 16);\n }\n\n if (c === 'x') {\n uuid += HEX_CHARS[r];\n } else if (c === 'y') {\n // Variant bits: 8, 9, A, or B\n uuid += HEX_CHARS[(r & 0x3) | 0x8];\n } else if (c === '4') {\n uuid += '4';\n }\n }\n\n return uuid;\n};\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","export const toMap = <T extends {}>(data: T[], keySelector: (item: T) => T[keyof T] | string) => {\n\n const result = new Map<T[keyof T] | string, T>();\n\n for (let i = 0; i < data.length; i++) {\n const item = data[i];\n const key = keySelector(item);\n result.set(key, item);\n }\n\n return result;\n}\n","export const cast = <TIn, TOut>(item: TIn) => {\n return item as unknown as TOut;\n}\n\nexport function clone<T extends {}>(data: T): T {\n return JSON.parse(JSON.stringify(data)) as T;\n}","export const isNodeRuntime = () => typeof process !== 'undefined' &&\n process.versions != null &&\n process.versions.node != null;","import { BulkPersistResult, BulkPersistChanges } from \"../collections\";\nimport { DbPluginBulkPersistEvent } from \"../plugins\";\n\nexport const resolveBulkPersistChanges = (event: DbPluginBulkPersistEvent, result: BulkPersistResult, bulkPersistChanges: BulkPersistChanges) => {\n // make sure we swap the adds here, that way we can make sure other persist events\n // don't take their additions and try to change subsequent calls\n for (const [schemaId, changes] of event.operation) {\n\n const schemmaBulkPersistResult = result.get(schemaId);\n const schemaBulkPersistChanges = bulkPersistChanges.resolve(schemaId);\n\n // Set the original removes\n schemaBulkPersistChanges.removes = changes.removes;\n\n // Set the original updates\n schemaBulkPersistChanges.updates = changes.updates;\n\n // Take the adds from the result and set them to be persisted\n // in the replicated plugins because the id's are set in the \n // memory data store\n schemaBulkPersistChanges.adds = schemmaBulkPersistResult.adds;\n }\n}","import { QueryOptionsCollection } from \"../plugins/query\";\n\nexport const combineQueryOptionsCollections = <T>(...collections: QueryOptionsCollection<T>[]) => {\n const result = new QueryOptionsCollection<T>();\n\n for (let i = 0, length = collections.length; i < length; i++) {\n const collection = collections[i];\n\n // Add scoped items first\n collection.forEach(item => {\n result.add(item.name, item.value);\n });\n }\n\n return result;\n}","import { InferCreateType, InferType, SchemaId } from \"../schema\";\nimport { DbPluginBulkPersistEvent, EntityUpdateInfo } from \"../plugins\";\n\ntype DbEvent = {\n type: \"add\",\n data: InferCreateType<unknown>;\n} | {\n type: \"update\",\n data: EntityUpdateInfo<unknown>;\n} | {\n type: \"remove\",\n data: InferType<unknown>;\n}\n\nexport const toEventArray = (event: DbPluginBulkPersistEvent): [SchemaId, DbEvent][] => {\n\n const result: [SchemaId, DbEvent][] = [];\n for (const [schemaId, changes] of event.operation) {\n\n if (changes.hasItems === false) {\n continue;\n }\n\n if (changes.adds.length > 0) {\n result.push(...changes.adds.map(add => {\n return [schemaId as SchemaId, { data: { ...add }, type: \"add\" }] as [SchemaId, DbEvent];\n }));\n }\n\n if (changes.updates.length > 0) {\n result.push(...changes.updates.map(update => {\n return [schemaId as SchemaId, { data: { ...update }, type: \"update\" }] as [SchemaId, DbEvent];\n }));\n }\n\n if (changes.removes.length > 0) {\n result.push(...changes.removes.map(remove => {\n return [schemaId as SchemaId, { data: { ...remove }, type: \"remove\" }] as [SchemaId, DbEvent];\n }));\n }\n }\n\n return result\n}","export const noop = (..._args: any[]) => { };","export const unsafeCast = <T>(value: unknown): T => {\n return value as T\n}","export * from './arrays';\nexport * from './strings';\nexport * from './dates';\nexport * from './objects';\nexport * from './runtime';\nexport * from './uuid';\nexport * from './replication';\nexport * from './types';\nexport * from './queryOptionsCollection';\nexport * from './dbPluginEventUtils';\nexport * from './functions';\nexport * from './unsafeCast';\nexport * from './logger';"],"names":["EXPRESSION_TYPES","isDate","assertDate","data","TypeError","assertIsNotNull","message","assertIsArray","Array","assertString","assertInstanceOf","value","Instance","assertIsNumber","isObjectWithType","isExpression","isOperatorExpression","isComparatorExpression","isPropertyExpression","isValueExpression","isEmptyExpression","isNotParsableExpression","getProperties","expression","properties","traverse","expr","forEach","callback","QueryOptionsCollection","Map","reason","options","name","mapValue","x","filterValue","sortValue","nearestValue","joinValue","item","found","sortedItems","a","b","before","after","at","i","length","option","destination","key","items","nextExecutionTarget","nextExecutionReason","nextIndex","memoryQueryOptionsCollection","databaseQueryOptionsCollection","sortedItem","transformationOptions","w","iterator","Date","LOG_LEVELS","RANK","isLogLevel","resolveLevel","globalThis","g","process","debug","env","level","rank","setLogLevel","next","Error","getLogLevel","resetLogLevel","isLogLevelEnabled","emit","method","args","console","logger","hash","seed","h1","h2","ch","Math","fastHash","stringifyObject","obj","maxDepth","currentDepth","undefined","type","String","getFunctionName","stringifyObjectValue","fn","getObjectProperties","RegExp","stringifyArray","stringifyClassInstance","stringifyPlainObject","arr","suffix","className","Object","props","isPrimitive","depth","uuid","chars","charLength","result","HEX_CHARS","UUID_TEMPLATE","hasCrypto","crypto","hasRandomUUID","uuidv4","uuidv4Fallback","randomBytes","Uint8Array","byteIndex","c","r","toMap","keySelector","cast","clone","JSON","isNodeRuntime","resolveBulkPersistChanges","event","bulkPersistChanges","schemaId","changes","schemmaBulkPersistResult","schemaBulkPersistChanges","combineQueryOptionsCollections","collections","collection","toEventArray","add","update","remove","noop","_args","unsafeCast"],"mappings":";;;;;;;AAA4D;AAEtB;AAE/B,SAASE,WAAWC,IAAa;IACpC,IAAIF,OAAOE,UAAU,OAAO;QACxB,MAAM,IAAIC,UAAU;IACxB;AACJ;AAEO,SAASC,gBAAmBF,IAA0B,EAAEG,OAAiC;IAC5F,IAAIH,QAAQ,MAAM;QACd,IAAIG,WAAW,MAAM;YACjB,MAAM,IAAIF,UAAU;QACxB;QAEA,IAAI,OAAOE,YAAY,UAAU;YAC7B,MAAM,IAAIF,UAAUE;QACxB;QAEA,MAAM,IAAIF,UAAUE;IACxB;AACJ;AAEO,SAASC,cAAiBJ,IAAa,EAAEG,OAAgB;IAC5D,IAAI,CAACE,MAAM,OAAO,CAACL,OAAO;QACtB,MAAM,IAAIC,UAAUE,WAAW;IACnC;AACJ;AAEO,SAASG,aAAaN,IAAa,EAAEG,OAAgB;IACxD,IAAI,OAAOH,SAAS,UAAU;QAC1B,MAAM,IAAIC,UAAUE,WAAW;IACnC;AACJ;AAEO,SAASI,iBAAwDC,KAAc,EAAEC,QAAW;IAC/F,IAAID,iBAAiBC,UAAU;QAC3B;IACJ;IAEA,IAAID,SAAS,QAAQ,OAAOA,UAAU,YAAY,iBAAiBA,OAAO;QACtE,MAAM,IAAIP,UAAU,CAAC,sCAAsC,EAAEO,MAAM,WAAW,CAAC,IAAI,EAAE;IACzF;IAEA,MAAM,IA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5BvB,OAAO,IAAI,IAAIuB,QAAQ,OAAO,CAAC,GAAG,CAACS,CAAAA;gBAC/B,OAAO;oBAACV;oBAAsB;wBAAE,MAAM;4BAAE,GAAGU,MAAM;wBAAC;wBAAG,MAAM;oBAAS;iBAAE;YAC1E;QACJ;IACJ;IAEA,OAAOhC;AACX,EAAC;;;AC3CM,MAAMiC,OAAO,CAAC,GAAGC,SAAmB,EAAE;;;ACAtC,MAAMC,aAAa,CAAI9I;IAC1B,OAAOA;AACX,EAAC;;;;;ACFwB;AACC;AACF;AACE;AACA;AACH;AACO;AACN;AACiB;AACJ;AACT;AACC;AACJ"}
1
+ {"version":3,"file":"utilities/index.cjs","sources":["webpack://@routier/core/./src/assertions/index.ts","webpack://@routier/core/./src/expressions/utils.ts","webpack://@routier/core/./src/plugins/query/QueryOptionsCollection.ts","webpack://@routier/core/./src/schema/types.ts","webpack://@routier/core/./src/utilities/dates.ts","webpack://@routier/core/./src/utilities/logger.ts","webpack://@routier/core/./src/utilities/strings.ts","webpack://@routier/core/./src/utilities/uuid.ts","webpack://@routier/core/webpack/runtime/define_property_getters","webpack://@routier/core/webpack/runtime/has_own_property","webpack://@routier/core/webpack/runtime/make_namespace_object","webpack://@routier/core/./src/utilities/arrays.ts","webpack://@routier/core/./src/utilities/objects.ts","webpack://@routier/core/./src/utilities/runtime.ts","webpack://@routier/core/./src/utilities/replication.ts","webpack://@routier/core/./src/utilities/queryOptionsCollection.ts","webpack://@routier/core/./src/utilities/dbPluginEventUtils.ts","webpack://@routier/core/./src/utilities/functions.ts","webpack://@routier/core/./src/utilities/unsafeCast.ts","webpack://@routier/core/./src/utilities/index.ts"],"sourcesContent":["import { EXPRESSION_TYPES } from \"../expressions/constants\";\nimport { CallExpression, ComparatorExpression, EmptyExpression, Expression, ExpressionType, NotParsableExpression, OperatorExpression, PropertyExpression, ValueExpression } from \"../expressions/types\";\nimport { isDate } from \"../utilities\";\n\nexport function assertDate(data: unknown): asserts data is Date {\n if (isDate(data) === false) {\n throw new TypeError('Value is not a Date');\n }\n}\n\nexport function assertIsNotNull<T>(data: T | null | undefined, message?: string | (() => string)): asserts data is NonNullable<T> {\n if (data == null) {\n if (message == null) {\n throw new TypeError('Assertion failed, data is null');\n }\n\n if (typeof message === \"string\") {\n throw new TypeError(message);\n }\n\n throw new TypeError(message());\n }\n}\n\nexport function assertIsArray<T>(data: unknown, message?: string): asserts data is T[] {\n if (!Array.isArray(data)) {\n throw new TypeError(message ?? 'Assertion failed, data is not of type Array');\n }\n}\n\nexport function assertString(data: unknown, message?: string): asserts data is string {\n if (typeof data !== \"string\") {\n throw new TypeError(message ?? 'Assertion failed, data is not of type String');\n }\n}\n\nexport function assertInstanceOf<T extends new (...args: any[]) => any>(value: unknown, Instance: T): asserts value is T {\n if (value instanceof Instance) {\n return;\n }\n\n if (value != null && typeof value === \"object\" && \"constructor\" in value) {\n throw new TypeError(`value is not instance of type. Type: ${value.constructor.name}`);\n }\n\n throw new TypeError(`value is not instance of type`);\n}\n\nexport function assertIsNumber(value: unknown): asserts value is number {\n if (typeof value !== \"number\") {\n throw new TypeError(\"value is not of type `number`\");\n }\n}\n\n\nfunction isObjectWithType(value: unknown): value is Record<\"type\", unknown> {\n return typeof value === \"object\" && value !== null && \"type\" in value;\n}\n\n/**\n * Type guard: narrows `value` to `Expression` when it is an object with a valid `type` property.\n */\nexport function isExpression(value: unknown): value is Expression {\n return isObjectWithType(value) && EXPRESSION_TYPES.includes(value.type as ExpressionType);\n}\n\n/**\n * Type guard: narrows `value` to `OperatorExpression` when it is an object with `type === \"operator\"`.\n */\nexport function isOperatorExpression(value: unknown): value is OperatorExpression {\n return isObjectWithType(value) && value.type === \"operator\";\n}\n\n/**\n * Type guard: narrows `value` to `ComparatorExpression` when it is an object with `type === \"comparator\"`.\n */\nexport function isComparatorExpression(value: unknown): value is ComparatorExpression {\n return isObjectWithType(value) && value.type === \"comparator\";\n}\n\n/**\n * Type guard: narrows `value` to `PropertyExpression` when it is an object with `type === \"property\"`.\n */\nexport function isPropertyExpression(value: unknown): value is PropertyExpression {\n return isObjectWithType(value) && value.type === \"property\";\n}\n\n/**\n * Type guard: narrows `value` to `ValueExpression` when it is an object with `type === \"value\"`.\n */\nexport function isValueExpression(value: unknown): value is ValueExpression {\n return isObjectWithType(value) && value.type === \"value\";\n}\n\n/**\n * Type guard: narrows `value` to `CallExpression` when it is an object with `type === \"call\"`.\n */\nexport function isCallExpression(value: unknown): value is CallExpression {\n return isObjectWithType(value) && value.type === \"call\";\n}\n\n/**\n * Type guard: narrows `value` to `EmptyExpression` when it is an object with `type === \"empty\"`.\n */\nexport function isEmptyExpression(value: unknown): value is EmptyExpression {\n return isObjectWithType(value) && value.type === \"empty\";\n}\n\n/**\n * Type guard: narrows `value` to `NotParsableExpression` when it is an object with `type === \"not-parsable\"`.\n */\nexport function isNotParsableExpression(value: unknown): value is NotParsableExpression {\n return isObjectWithType(value) && value.type === \"not-parsable\";\n}","import { PropertyInfo } from \"../schema\";\nimport { CallExpression, Expression, PropertyExpression } from \"./types\";\n\n/**\n * An operand with the calls wrapping it, innermost first — the order they are applied in.\n *\n * The nodes rather than their names: a binary call carries arguments, and a consumer that only knows\n * the name renders `LOWER(col)` correctly and `col + ?` not at all.\n */\nexport type PeeledOperand = { operand: Expression, calls: CallExpression[] };\n\n/**\n * Separates an operand from the calls applied to it.\n *\n * `null` when there is no operand beneath the calls. Every consumer needs this to decide whether a\n * comparator side is a property or a value, so it lives here rather than in each translator.\n */\nexport function peelCalls(expression: Expression | undefined): PeeledOperand | null {\n const calls: CallExpression[] = [];\n let current = expression;\n\n while (current != null && current.type === \"call\") {\n calls.unshift(current as CallExpression);\n current = (current as CallExpression).expression;\n }\n\n return current == null ? null : { operand: current, calls };\n}\n\nexport function childrenOf(expression: Expression): Expression[] {\n\n if (expression.type === \"call\") {\n const call = expression as CallExpression;\n\n return [call.expression, ...(call.arguments ?? [])].filter(child => child != null);\n }\n\n const children: Expression[] = [];\n\n if (expression.left != null) {\n children.push(expression.left);\n }\n\n if (expression.right != null) {\n children.push(expression.right);\n }\n\n return children;\n}\n\n/**\n * Extracts all properties referenced in an expression\n * @param expression The expression to analyze\n * @returns Array of PropertyInfo objects referenced in the expression\n */\nexport function getProperties(expression: Expression): PropertyInfo<any>[] {\n const properties: PropertyInfo<any>[] = [];\n\n function traverse(expr: Expression) {\n // If this is a property expression, add it to our collection\n if (expr.type === \"property\") {\n properties.push((expr as PropertyExpression).property);\n }\n\n for (const child of childrenOf(expr)) {\n traverse(child);\n }\n }\n\n traverse(expression);\n return properties;\n}\n\nexport function forEach(expression: Expression, callback: (expression: Expression) => boolean) {\n function traverse(expr: Expression): boolean {\n // Call the callback for this expression\n // If callback returns false, stop traversing\n if (!callback(expr)) {\n return false;\n }\n\n for (const child of childrenOf(expr)) {\n if (!traverse(child)) {\n return false;\n }\n }\n\n return true;\n }\n\n traverse(expression);\n}","import { isComparatorExpression, isPropertyExpression, isValueExpression } from \"../../assertions\";\nimport { ComparatorExpression, Expression } from \"../../expressions/types\";\nimport { forEach } from \"../../expressions/utils\";\nimport { SchemaTypes } from \"../../schema/types\";\nimport { logger } from \"../../utilities\";\nimport { DatabaseExecutionReason, MemoryExecutionReason, QueryOption, QueryOptionName, QueryOptionExecutionTarget, QueryOptionValueMap } from \"./types\";\n\nexport type QueryCollectionItem<T, K extends QueryOptionName> = { index: number, option: QueryOption<T, K> };\n\n/** What a schema type is called in JavaScript, where one exists. A value of any other type cannot equal it. */\nconst JAVASCRIPT_TYPE_OF: Partial<Record<SchemaTypes, string>> = {\n [SchemaTypes.Number]: \"number\",\n [SchemaTypes.String]: \"string\",\n [SchemaTypes.Boolean]: \"boolean\",\n [SchemaTypes.Date]: \"object\",\n};\n\nconst mismatchedSide = (property: Expression | undefined, value: Expression | undefined) => {\n if (property == null || value == null || !isPropertyExpression(property) || !isValueExpression(value)) {\n return null;\n }\n\n const expected = JAVASCRIPT_TYPE_OF[property.property.type];\n\n if (expected == null || value.value == null || typeof value.value === expected) {\n return null;\n }\n\n return { property, value, expected };\n};\n\n/** A strict comparison whose answer is the same for every row, because the types cannot be equal. */\nconst comparesTypesThatCannotMatch = (expression: Expression): boolean => {\n if (!isComparatorExpression(expression) || expression.strict !== true) {\n return false;\n }\n\n if (expression.comparator !== \"equals\") {\n return false;\n }\n\n return mismatchedSide(expression.left, expression.right) != null\n || mismatchedSide(expression.right, expression.left) != null;\n};\n\n/** `JSON.stringify` throws on a BigInt, and this runs inside the guard that exists to catch one. */\nconst describeLiteral = (value: unknown): string =>\n typeof value === \"string\" ? `\"${value}\"` : String(value);\n\nconst mismatchWarning = (expression: ComparatorExpression): string => {\n const side = mismatchedSide(expression.left, expression.right)\n ?? mismatchedSide(expression.right, expression.left)!;\n\n const outcome = expression.negated ? \"every row matches\" : \"no row matches\";\n\n return `Routier: '${side.property.property.getAssignmentPath()}' is a ${side.expected}, and this filter ` +\n `compares it against ${describeLiteral(side.value.value)}, which is a ${typeof side.value.value}. ` +\n `A strict comparison between them is the same answer for every row, so ${outcome} and the filter ` +\n `runs in memory. https://routier.dev/guides/strict-comparison-types`;\n};\n\nexport class QueryOptionsCollection<T> {\n\n private options: Map<QueryOptionName, QueryCollectionItem<any, any>[]> = new Map<QueryOptionName, QueryCollectionItem<any, any>[]>();\n private nextExecutionTarget: QueryOptionExecutionTarget = \"database\";\n private nextExecutionReason: MemoryExecutionReason | null = null;\n private nextIndex: number = 0;\n private enumeratedItems: QueryCollectionItem<any, any>[] = [];\n private dirty: boolean = true;\n\n /** The collection a `splitAt`/`split` half came from. A capability report belongs to it. */\n private origin: QueryOptionsCollection<T> | null = null;\n\n /** Cuts over to memory execution, keeping the first cause. See `MemoryExecutionReason`. */\n private cutOverToMemory(reason: MemoryExecutionReason) {\n this.nextExecutionTarget = \"memory\";\n\n if (this.nextExecutionReason == null) {\n this.nextExecutionReason = reason;\n }\n }\n\n get items() {\n return this.options;\n }\n\n get isEmpty() {\n return this.items.size === 0;\n }\n\n static EMPTY<R>() {\n return new QueryOptionsCollection<R>();\n }\n\n static isEmpty<T>(options: QueryOptionsCollection<T>) {\n return options.isEmpty;\n }\n\n add<K extends QueryOptionName>(name: K, value: QueryOption<T, K>[\"value\"]) {\n\n if (name === \"map\") {\n const mapValue = value as QueryOptionValueMap<T>[\"map\"];\n\n // Evaluate the map value to see if we are renaming properties, \n // if we are we need to perform everything after in memory\n if (mapValue.fields.some(x => x.isRename === true) || mapValue.fields.some(x => x.property?.isUnmapped === true)) {\n // Cut over to memory execution since we are renaming a property with .map\n // We do not want to figure out how the new name flows through the entire query\n this.cutOverToMemory(\"map-rename\");\n }\n }\n\n if (name === \"filter\") {\n // Need to check for unmapped and renamed properties\n const filterValue = value as QueryOptionValueMap<T>[\"filter\"];\n\n // A tautology (`x => true`) filters nothing — skip it entirely so\n // plugins never see it\n if (filterValue.expression.type === \"empty\") {\n return;\n }\n\n if (filterValue.expression.type === \"not-parsable\") {\n this.cutOverToMemory(\"not-parsable\");\n } else {\n forEach(filterValue.expression, (expression) => {\n\n if (isPropertyExpression(expression) && expression.property.isUnmapped) {\n // Cut over to memory execution, unmapped properties are not in the database and\n // cannot be queried\n this.cutOverToMemory(\"unmapped-property\");\n return false;\n }\n\n if (isPropertyExpression(expression) && expression.property.hasRenamedSegments) {\n // Cut over to memory execution: the plugin stores data under the\n // `from` (storage) names, but filter selectors reference the\n // in-memory names. Memory execution runs after deserialization,\n // where the in-memory names exist\n this.cutOverToMemory(\"renamed-property\");\n return false;\n }\n\n if (comparesTypesThatCannotMatch(expression)) {\n logger.warn(mismatchWarning(expression as ComparatorExpression));\n this.cutOverToMemory(\"predicate-error\");\n return false;\n }\n\n return true;\n });\n }\n }\n\n if (name === \"sort\") {\n const sortValue = value as QueryOptionValueMap<T>[\"sort\"];\n\n // Same rule as filters: sort selectors reference in-memory names, which\n // only exist after deserialization when the property is renamed or unmapped\n if (sortValue.property != null && sortValue.property.isUnmapped) {\n this.cutOverToMemory(\"unmapped-property\");\n } else if (sortValue.property != null && sortValue.property.hasRenamedSegments) {\n this.cutOverToMemory(\"renamed-property\");\n }\n }\n\n if (name === \"nearest\") {\n const nearestValue = value as QueryOptionValueMap<T>[\"nearest\"];\n\n // Same rule as sort, and for the same reason: the plugin stores the vector under\n // the `from` name, and an unmapped property is not stored at all. Both are only\n // readable after deserialization, which is where memory execution runs.\n //\n // This is also what lets every translator's in-memory fallback read the column by\n // its resolved name — anything whose storage name differs never reaches them.\n if (nearestValue.property != null && nearestValue.property.isUnmapped) {\n this.cutOverToMemory(\"unmapped-property\");\n } else if (nearestValue.property != null && nearestValue.property.hasRenamedSegments) {\n this.cutOverToMemory(\"renamed-property\");\n }\n }\n\n if ((name === \"filter\" || name === \"sort\") && (this.options.has(\"skip\") || this.options.has(\"take\"))) {\n // SQL emits WHERE before LIMIT and Mongo's find() filters before skipping, so an option\n // written after a window can only see the windowed rows if it runs after it.\n this.cutOverToMemory(\"after-window\");\n }\n\n if (name === \"join\") {\n const joinValue = value as QueryOptionValueMap<T>[\"join\"];\n\n // A join whose two sides live on different plugins cannot be sent to EITHER of\n // them — neither can read the other's rows — so the option itself belongs to the\n // memory half, where the datastore interprets it.\n //\n // Set BEFORE the item is created, unlike `nearest`'s ratchet below, because this\n // moves the join option itself rather than everything after it.\n if (joinValue.crossPlugin === true) {\n this.cutOverToMemory(\"cross-plugin-join\");\n }\n }\n\n // `executed` is the plan, not a record: nothing has run when an option is added. Every\n // consumer reads it after the plugin returned, so the optimistic window is never observed.\n const item: QueryCollectionItem<T, K> = {\n index: this.nextIndex,\n option: this.nextExecutionTarget === \"database\"\n ? { name, value, target: \"database\", reason: \"executed\" }\n : { name, value, target: \"memory\", reason: this.nextExecutionReason ?? \"not-parsable\" }\n }\n\n this.nextIndex++;\n this.dirty = true;\n\n const found = this.options.get(name);\n\n this.options.set(name, [...found ?? [], item]);\n\n if (name === \"nearest\") {\n // Everything AFTER a similarity search runs in memory, whatever the backend.\n //\n // Whether the search was pushed down is a fact about the plugin, which this\n // collection cannot see — so a later option is only safe if it runs after the\n // scoring definitely happened, and in memory is the only place that is true of.\n //\n // The failure this prevents is silent. `.nearest(x => x.embedding, v, 10).take(3)`\n // sends `LIMIT 3` to a backend that ignored the ordering, so three arbitrary rows\n // come back and get scored — three real rows, in a plausible order, and not the\n // three nearest. Nothing errors.\n //\n // A plugin that DID push the search down loses nothing but the chance to also\n // push down what follows it, which is a limit over ten rows.\n this.cutOverToMemory(\"after-nearest\");\n }\n\n if (name === \"join\") {\n // Everything AFTER a join runs in memory, for the same reason as `nearest`: this\n // collection cannot see HOW the plugin executed the join, and the rows it produced\n // are TUPLES rather than entities of the root schema.\n //\n // A `take` sent to a backend that hash-joined in its translator would limit the\n // OUTER rows read, not the pairs produced — a plausible-looking result with the\n // wrong number of rows in it. Conjuncts that can safely run earlier are split off\n // by the query builder BEFORE dispatch, which is the only exception.\n this.cutOverToMemory(\"after-join\");\n }\n }\n\n /**\n * Splits the collection around the FIRST occurrence of `name`, preserving order.\n *\n * For a join: the options recorded before it operate on entity rows, the option itself\n * produces tuples, and the ones after it operate on tuples. Three different shapes, so the\n * caller has to run them in three steps rather than one pass.\n */\n splitAt<K extends QueryOptionName>(name: K): { before: QueryOptionsCollection<T>, at: QueryOption<T, K> | null, after: QueryOptionsCollection<T> } {\n this.resolveEnumeration();\n\n const sortedItems = this.enumeratedItems.toSorted((a, b) => a.index - b.index);\n const before = new QueryOptionsCollection<T>();\n const after = new QueryOptionsCollection<T>();\n let at: QueryOption<T, K> | null = null;\n\n for (let i = 0, length = sortedItems.length; i < length; i++) {\n const { option } = sortedItems[i];\n\n if (at == null && option.name === name) {\n at = option as QueryOption<T, K>;\n continue;\n }\n\n const destination = at == null ? before : after;\n destination.adopt(sortedItems[i]);\n }\n\n before.origin = this.origin ?? this;\n after.origin = this.origin ?? this;\n\n return { before, at, after };\n }\n\n /**\n * Captures the collection's current state and returns a function that restores it.\n *\n * Terminal queryable operations (count, first, aggregates, …) record their option on\n * the shared collection before executing. Without restoring, a re-executed terminal —\n * the whole point of a subscribed queryable — stacks its option a second time and\n * runs it over the first execution's scalar result.\n */\n snapshot(): () => void {\n const options = new Map([...this.options.entries()].map(([key, items]): [QueryOptionName, QueryCollectionItem<any, any>[]] => [key, [...items]]));\n const nextExecutionTarget = this.nextExecutionTarget;\n const nextExecutionReason = this.nextExecutionReason;\n const nextIndex = this.nextIndex;\n\n return () => {\n this.options = new Map(options);\n this.nextExecutionTarget = nextExecutionTarget;\n this.nextExecutionReason = nextExecutionReason;\n this.nextIndex = nextIndex;\n this.enumeratedItems = [];\n // Clearing the list is not enough now that staleness is a flag rather than a count:\n // without this, `resolveEnumeration` believes the empty list is current and every read\n // of the collection sees no options at all.\n this.dirty = true;\n };\n }\n\n /** Takes an item as it stands — same object, same index, same target and reason. */\n private adopt(item: QueryCollectionItem<any, any>) {\n const found = this.options.get(item.option.name);\n\n this.options.set(item.option.name, [...found ?? [], item]);\n this.nextIndex = Math.max(this.nextIndex, item.index + 1);\n this.dirty = true;\n }\n\n /**\n * A plugin reporting that its engine cannot express one option.\n *\n * Core marks the rest of the database phase `not-reached`, because the database has to stop\n * there — a window applied in front of a filter that was not applied returns the wrong rows.\n * Passing the cascade through core is what makes it impossible for a plugin to mark a\n * non-contiguous cut.\n *\n * A report names a culprit and never un-names one, so reports commute.\n *\n * The option is not moved to the memory arm. It stays where it was planned, which is what keeps\n * a redirect distinguishable from something core sent to memory in the first place.\n */\n reportMissingCapability(item: QueryCollectionItem<any, any>) {\n this.report(item, \"missing-capability\");\n }\n\n /**\n * A plugin reporting that its engine would answer one option differently from JavaScript.\n *\n * Same cascade as `reportMissingCapability`, and a separate reason because the caller can act on\n * one and not the other. See `DatabaseExecutionReason`.\n */\n reportEngineDivergence(item: QueryCollectionItem<any, any>) {\n this.report(item, \"engine-divergence\");\n }\n\n private report(item: QueryCollectionItem<any, any>, reason: DatabaseExecutionReason) {\n // A half can only see its own slice, and the database has to stop for the whole dispatch.\n if (this.origin != null) {\n this.origin.report(item, reason);\n return;\n }\n\n this.resolveEnumeration();\n\n for (const candidate of this.enumeratedItems) {\n if (candidate.option.target !== \"database\" || candidate.index < item.index) {\n continue;\n }\n\n if (candidate.index === item.index) {\n candidate.option.reason = reason;\n continue;\n }\n\n if (candidate.option.reason === \"executed\") {\n candidate.option.reason = \"not-reached\";\n }\n }\n }\n\n /**\n * Forgets what any previous dispatch reported.\n *\n * Capability is answered per dispatch, so a report is only an answer for the execution that\n * produced it. The items are shared with any snapshot, so a report mutated in place otherwise\n * survives a restore and a second terminal on the same queryable replays options the plugin\n * did run — a `skip` applied twice, over rows already windowed.\n */\n forgetReports() {\n this.resolveEnumeration();\n\n for (const item of this.enumeratedItems) {\n if (item.option.target === \"database\") {\n item.option.reason = \"executed\";\n }\n }\n }\n\n /** The options the database did not run, in the order they were written. */\n notExecuted(): QueryCollectionItem<any, any>[] {\n this.resolveEnumeration();\n\n return this.enumeratedItems\n .filter(item => item.option.target === \"database\" && item.option.reason !== \"executed\")\n .toSorted((a, b) => a.index - b.index);\n }\n\n split(): { memory: QueryOptionsCollection<T>, database: QueryOptionsCollection<T> } {\n this.resolveEnumeration();\n\n const sortedItems = this.enumeratedItems.toSorted((a, b) => a.index - b.index);\n const memoryQueryOptionsCollection = new QueryOptionsCollection<T>();\n const databaseQueryOptionsCollection = new QueryOptionsCollection<T>();\n\n for (let i = 0, length = sortedItems.length; i < length; i++) {\n const sortedItem = sortedItems[i];\n const half = sortedItem.option.target === \"database\"\n ? databaseQueryOptionsCollection\n : memoryQueryOptionsCollection;\n\n // The ITEM, not its name and value. Re-adding would re-derive target and reason from a\n // fresh cascade, and a memory option re-added alone comes back out as `database` with no\n // reason at all. Sharing it also means a plugin's report on the database half is the\n // same object the explanation reads.\n half.adopt(sortedItem);\n }\n\n memoryQueryOptionsCollection.origin = this.origin ?? this;\n databaseQueryOptionsCollection.origin = this.origin ?? this;\n\n return {\n memory: memoryQueryOptionsCollection,\n database: databaseQueryOptionsCollection\n }\n }\n\n hasTransformations(): boolean {\n const transformationOptions: QueryOptionName[] = [\"map\", \"group\", \"min\", \"max\", \"count\", \"sum\"];\n return transformationOptions.some((name) => this.options.has(name));\n }\n\n has<K extends QueryOptionName>(name: K): boolean {\n return this.options.has(name);\n }\n\n get<K extends QueryOptionName>(name: K): QueryCollectionItem<T, K>[] {\n return this.options.get(name) ?? [] as QueryCollectionItem<T, K>[];\n }\n\n getLast<K extends QueryOptionName>(name: K): QueryOption<T, K> | null {\n this.resolveEnumeration();\n\n for (let i = this.enumeratedItems.length - 1; i >= 0; i--) {\n const item = this.enumeratedItems[i];\n\n if (item.option.name === name) {\n return item.option;\n }\n }\n\n return null\n }\n\n getValues<K extends QueryOptionName>(name: K): QueryCollectionItem<T, K>[\"option\"][\"value\"][] | undefined {\n\n const found = this.options.get(name);\n\n if (found == null) {\n return [];\n }\n\n return found.map(w => w.option.value) as QueryCollectionItem<T, K>[\"option\"][\"value\"][];\n }\n\n private getEnumeration() {\n return [...this.options.values()].flat().toSorted((a, b) => a.index - b.index);\n }\n\n private resolveEnumeration() {\n // A flag, not a count: adopting leaves gaps in the indexes, so `length !== nextIndex` is\n // true forever on a half and the enumeration rebuilds on every read.\n if (this.dirty === true) {\n this.enumeratedItems = this.getEnumeration();\n this.dirty = false;\n }\n }\n\n forEach(iterator: (item: QueryCollectionItem<T, any>[\"option\"]) => void) {\n this.resolveEnumeration();\n\n for (let i = 0, length = this.enumeratedItems.length; i < length; i++) {\n iterator(this.enumeratedItems[i].option);\n }\n }\n}","import type { SchemaDefinition } from \"./SchemaDefinition\";\nimport type { SchemaBase } from \"./property/base/SchemaBase\";\nimport type { SchemaArray } from \"./property/types/SchemaArray\";\nimport type { SchemaVector } from \"./property/types/SchemaVector\";\nimport type { SchemaObject } from \"./property/types/SchemaObject\";\nimport type { PropertyInfo } from \"./PropertyInfo\";\nimport type { DeepPartial } from \"../types\";\nimport type { SchemaFunction } from \"./table\";\nimport type { SchemaOptional, SchemaTag } from \"./property/modifiers\";\nimport type { Branded } from \"../utilities/types\";\nimport type { SchemaSubscriptionOptions } from \"./communication/broadcast\";\n\nexport type DefaultValue<T, I = never> = T | ((injected: I) => T);\nexport type FunctionBody<TEntity, TResult> = (entity: TEntity, collectionName: CollectionName) => TResult;\nexport type IdType = string | number;\nexport type ForeignKey<T extends {}> = { \n schema: CompiledSchema<T>, \n property: PropertyInfo<T> \n};\n\nexport enum SchemaTypes {\n Array = \"Array\",\n Boolean = \"Boolean\",\n Date = \"Date\",\n Number = \"Number\",\n Object = \"Object\",\n String = \"String\",\n Definition = \"Definition\",\n Function = \"Function\",\n Computed = \"Computed\",\n /**\n * Content in, reference out. The only type whose write shape differs from its stored\n * shape, and a leaf on purpose — see `SchemaFile`.\n */\n File = \"File\",\n /**\n * A fixed-length list of numbers, carrying its dimension count — see `SchemaVector`.\n *\n * Value-shaped exactly like `s.array(s.number())`, which is why every array codegen\n * handler accepts it. It is a distinct type only so a backend can recognise it and store\n * it natively; nothing else needs to tell the two apart.\n */\n Vector = \"Vector\"\n}\n\nexport type ArrayShape = string | number | Date | {};\n\n\n/**\n * What a file property gives back: where the bytes are and what they are.\n *\n * Declared in core so `InferType` can name it. Core never reads or writes the bytes — it only\n * carries this shape — and `@routier/blob-plugin` is what puts one here.\n */\nexport type FileReferenceValue = {\n /** Where the bytes live, content-addressed by the blob plugin. */\n key: string;\n /** Byte length. */\n size: number;\n /** Media type as supplied at upload. */\n contentType: string;\n /** SHA-256 of the bytes, lowercase hex. */\n checksum: string;\n /** The name to show a user. Not part of the key. */\n fileName: string;\n};\n\n/**\n * What a file property ACCEPTS: content, or a reference you already have.\n *\n * `Blob` covers `File`, which is what an `<input type=\"file\">` yields. A reference is accepted\n * too, so re-saving an entity that was read from the database does not have to re-upload it.\n */\nexport type FileContentValue =\n | FileReferenceValue\n | Uint8Array\n | ArrayBuffer\n | Blob\n | string;\n\n/**\n * What a vector property holds, in and out: a plain list of numbers.\n *\n * Named rather than written inline because the inference rules have to recognise it after a\n * modifier has erased which class produced it — the same problem `FileReferenceValue` solves\n * above, and for the same reason.\n */\nexport type VectorValue = number[];\n\n/**\n * What `s.string({ ... })` accepts.\n *\n * Declarations only. Core stores them and never acts on them; a backend that can use one does.\n */\nexport type StringOptions = {\n /**\n * The longest value the property is declared to hold.\n *\n * MySQL uses it for `VARCHAR(maxLength)`; without it every string column is\n * `VARCHAR(255)`, which silently truncates longer values. Other backends ignore it. Core\n * never validates a value against it — see `SchemaBase.maxLength`.\n */\n maxLength?: number;\n};\n\nexport type ExpandedProperty = ExpandedChildProperty & {\n assignmentPath: string;\n selectorPath: string;\n properties: Map<string, ExpandedChildProperty>;\n childDegree: number;\n};\n\nexport type ExpandedChildProperty = {\n propertyName: string;\n type: SchemaTypes;\n isNullableOrOptional: boolean;\n isReadonly: boolean;\n isIdentity: boolean;\n isUnmapped: boolean;\n}\n\nexport enum HashType {\n Ids = \"Ids\",\n Object = \"Object\"\n}\n\nexport type HashFunction<TEntity extends {}> = {\n (entity: InferCreateType<TEntity>, type: HashType.Object): string;\n (entity: InferType<TEntity>, type: HashType.Ids): string;\n}\n\nexport type GetHashTypeFunction<TEntity extends {}> = {\n (entity: InferCreateType<TEntity>): HashType.Object;\n (entity: InferType<TEntity>): HashType.Ids;\n}\n\nexport type ChangeTrackingType = \"proxy\" | \"diff\" | \"immutable\";\n\nexport type IndexType = \"single\" | \"compound\" | \"unique\" | \"primary-key\"\nexport type Index = {\n properties: PropertyInfo<any>[],\n type: IndexType;\n name: string;\n}\n\n/**\n * Represents changes to subscriptions, categorizing them by modifications to\n * entities (additions, updates, removals) or query-driven removals.\n * @template T - The type of the entities in the subscription.\n */\nexport type SubscriptionChanges<T extends {}> = {\n /**\n * Entities that have been added to the subscription.\n */\n adds: InferType<T>[];\n /**\n * Entities that have been updated within the subscription.\n */\n updates: InferType<T>[];\n /**\n * Entities that have been removed from the subscription.\n */\n removals: InferType<T>[];\n /**\n * Entities that have been added/updated/removed from the subscription and it is unknown \n * if the entities have been added/updated/removed.\n */\n unknown: InferType<T>[];\n}\n\nexport interface ISchemaSubscription<T extends {}> extends Disposable {\n send(changes: SubscriptionChanges<T>): void;\n onMessage(callback: (changes: SubscriptionChanges<T>) => void): void;\n}\n\nexport type Enrich<TEntity extends {}> = {\n (entity: InferType<TEntity>, changeTrackingType: ChangeTrackingType): InferType<TEntity>;\n (entity: InferCreateType<TEntity>, changeTrackingType: ChangeTrackingType): InferCreateType<TEntity>;\n}\nexport type Prepare<TEntity extends {}> = {\n (entity: InferCreateType<TEntity>): InferCreateType<TEntity>;\n (entity: InferType<TEntity>): InferType<TEntity>;\n}\nexport type Preprocess<TEntity extends {}> = {\n (entity: InferCreateType<TEntity>): InferType<TEntity>;\n (entity: InferType<TEntity>): InferType<TEntity>;\n}\n\nexport type SetProperties<TEntity extends {}> = (destination: DeepPartial<InferType<TEntity> | InferCreateType<TEntity>>, source: DeepPartial<InferType<TEntity> | InferCreateType<TEntity>>) => void;\n\nexport type CompiledSchemaCore<TEntity extends {}> = Omit<CompiledSchema<TEntity>, \"createSubscription\">;\n\nexport type CompiledSchemaWithMetadata<TEntity extends {}, TMetadata> = {\n readonly metadata: TMetadata;\n} & CompiledSchema<TEntity>;\n\n/**\n * Represents a fully compiled schema with all utilities and metadata for an entity type.\n */\nexport type CompiledSchema<TEntity extends {}> = {\n\n deserializePartial: (item: Record<string, unknown>, properties: PropertyInfo<TEntity>[]) => DeepPartial<InferType<TEntity>>;\n\n createSubscription: (abortSignal?: AbortSignal, scope?: string, options?: SchemaSubscriptionOptions) => ISchemaSubscription<TEntity>;\n /** Returns the property info for a given id (full path) */\n getProperty: (id: string) => PropertyInfo<TEntity>;\n /** Returns the ID of the given entity. */\n getId: (entity: InferType<TEntity>) => IdType;\n /** Returns a deep clone of the given entity. */\n clone: (entity: InferType<TEntity>) => InferType<TEntity>;\n /**\n * Returns a deep clone of a record that is still in the STORAGE shape — renamed properties\n * under their `from` names rather than their in-memory names.\n *\n * `clone` reads in-memory names, so it returns `undefined` for every renamed property of a\n * stored record. Use this when copying rows a store holds before they have been deserialized.\n * Generated on first call; schemas that are never cloned in storage shape never build it.\n */\n cloneStorage: (entity: InferType<TEntity>) => InferType<TEntity>;\n /** Removes unmapped or extraneous properties from the entity. */\n strip: (entity: InferType<TEntity>) => InferType<TEntity>;\n /** Prepares a new entity for creation, applying defaults and transformations. */\n prepare: Prepare<TEntity>;\n /** Merges the source entity into the destination entity. */\n merge: (destination: InferType<TEntity> | InferCreateType<TEntity>, source: InferType<TEntity>) => InferType<TEntity>;\n /** Indicates if the schema has identity properties. */\n hasIdentities: boolean;\n /** List of properties that are identity keys. */\n idProperties: PropertyInfo<TEntity>[];\n /** All property metadata for the schema. */\n properties: PropertyInfo<TEntity>[],\n /** The hash type used for this schema. */\n hashType: HashType;\n /** Computes a hash for the given entity. */\n hash: HashFunction<TEntity>;\n /** Returns the hash type for the given entity. */\n getHashType: GetHashTypeFunction<TEntity>;\n /** Compares two entities for equality. */\n compare: (a: InferType<TEntity>, fromDb: InferType<TEntity>) => boolean;\n /** Deserializes an entity from storage format. */\n deserialize: (entity: InferType<TEntity>) => InferType<TEntity>;\n /** Sets 1 or many properties from the source object onto the destination object with change tracking. */\n set: SetProperties<TEntity>;\n /** Combines serializing and preparing an entity for saving. */\n preprocess: Preprocess<TEntity>;\n /** Combines deserializing and enriching an entity for selection. */\n postprocess: Enrich<TEntity>;\n\n /** Serializes an entity to storage format. */\n serialize: (entity: InferType<TEntity>) => InferType<TEntity>;\n /** Unique id for the schema. */\n id: SchemaId,\n /** The name of the collection for this schema. */\n collectionName: CollectionName;\n /** Returns all IDs for the given entity (usually a single-element tuple). */\n getIds: (entity: InferType<TEntity>) => [IdType];\n /** Enriches the entity with change tracking or other metadata. */\n enrich: Enrich<TEntity>;\n /** Indicates if the schema has identity keys. */\n hasIdentityKeys: boolean;\n /** Returns a deeply frozen (immutable) version of the entity. */\n freeze: (entity: InferType<TEntity>) => InferType<TEntity>;\n /** Enables change tracking on the entity. */\n enableChangeTracking: (entity: InferType<TEntity>) => InferType<TEntity>;\n /** The schema definition object. */\n definition: SchemaDefinition<TEntity>;\n /** Returns all indexes defined for this schema. */\n getIndexes: () => Index[];\n /** Compares two entities for Id equality. */\n compareIds: (a: InferType<TEntity>, b: InferType<TEntity>) => boolean;\n}\n\nexport type PropertySerializer<T extends any> = (value: T) => string | number;\nexport type PropertyDeserializer<T extends any> = (value: string | number) => T;\n\n/**\n * A two-way transform between the application value and the stored value.\n *\n * Both directions may be async. Held as a live reference rather than stringified, so a\n * closure works and `injected` is a convenience rather than the only way in.\n */\nexport type PropertyTransform<T extends any> = {\n /**\n * Application value to stored value. Runs before the plugin sees it. May be async.\n *\n * `entity` is there for the one-way case: a transform with no `from` derives a value\n * rather than converting one, which is what `computed` does.\n */\n to: (value: T, entity: Record<string, unknown>) => unknown | Promise<unknown>;\n\n /**\n * Stored value back to application value. Runs after the plugin returns it.\n *\n * Optional. Leave it out and the transform is one-way: the stored value is the value.\n */\n from?: (value: unknown) => T | Promise<T>;\n\n /**\n * What the column becomes, when the stored form is not the property's own type.\n *\n * Defaults to the property's own type, so nothing changes unless you say it does. A\n * library that always produces text — a cipher, a compressor — sets this once, and the\n * caller who uses that library never writes it.\n */\n stores?: SchemaTypes;\n\n /**\n * Whether a filter on this property can still run in the database.\n *\n * Defaults to `none`, which rejects the filter rather than returning wrong rows. Set\n * `equality` only when `to` is deterministic.\n */\n comparable?: 'equality' | 'none';\n};\n\nexport type SchemaId = Branded<number, \"SchemaId\">;\nexport type CollectionName = Branded<string, \"CollectionName\">;\n\nexport type SchemaModifiers = \"default\" | \"deserialize\" |\n \"identity\" | \"key\" |\n \"nullable\" | \"optional\" |\n \"readonly\" | \"serialize\" |\n \"unmapped\" | \"computed\" |\n \"distinct\" | \"searchable\";\n\n/**\n * What a tagged property infers to.\n *\n * `tag()` is metadata and must not change a type, but `SchemaTag<T>` carries the same `T` as\n * whatever it wrapped without carrying which class that was. For a string `T` is already\n * `string`; for an object `T` is the map of child schemas, which only the `SchemaObject`\n * branch below knows how to unwrap. Falling through to the generic `SchemaBase` branch\n * therefore handed the raw map back, so `s.object({ key: s.string() }).tag('x')` typed\n * `key` as `SchemaString` instead of `string` — everything ran, and only the types lied.\n *\n * An array is distinguishable because `SchemaArray`'s parameter is the ELEMENT schema, so a\n * tagged array arrives here as a `SchemaBase` rather than a plain map.\n */\ntype InferTagged<C> = ResolveWrapped<C>;\n\n/**\n * What a wrapping modifier's inner type resolves to.\n *\n * `SchemaOptional`, `SchemaNullable` and `SchemaTag` all carry the same `C` as whatever they\n * wrapped, without carrying which class that was, so each has to work out what it is holding.\n * Three shapes are possible:\n *\n * - an already-resolved value (`string` from `s.string()`, a file reference from `s.file()`)\n * - an ELEMENT schema, which is what `SchemaArray` parameterises on\n * - a map of child schemas, which is what `SchemaObject` parameterises on\n *\n * Getting this wrong is silent. The map branch applied to an already-resolved object walks\n * its keys and infers `never` for each, so `s.file().optional()` typed as\n * `{ key: never, size: never, ... }` — which no value can satisfy and no test would catch at\n * runtime.\n */\ntype ResolveWrapped<C> =\n C extends string | number | boolean | Date | FileReferenceValue ? C :\n C extends VectorValue ? C :\n C extends SchemaBase<any, any> ? InferPrimitive<C>[] :\n { [K in keyof C]: InferPrimitive<C[K]> };\n\ntype InferPrimitive<T> =\n T extends SchemaOptional<infer C, infer __> ? ResolveWrapped<C> :\n T extends SchemaTag<infer C, infer __> ? InferTagged<C> :\n // Before the generic `SchemaBase` branch below, which would see `X = number[]` and map\n // the element through `InferPrimitive<number>` — no branch matches a bare `number`, so a\n // vector would type as `never[]`: assignable from nothing, and invisible at runtime.\n T extends SchemaVector<infer __, infer ___> ? VectorValue :\n T extends SchemaArray<infer Y, infer __> ? InferPrimitive<Y>[]\n : T extends SchemaObject<infer Obj, infer _> ?\n { [K in keyof Obj]: InferPrimitive<Obj[K]> } : // Process nested objects\n T extends SchemaFunction<infer F, infer __> ? F : T extends SchemaBase<infer X, infer _> ?\n X extends Array<infer A> ? InferPrimitive<A>[] : X : // Extract the primitive type\n never;\n\nexport type InferType<T> = T extends CompiledSchema<infer R> ? InferCompiledSchema<R> : T extends {} ? InferCompiledSchema<T> : T;\nexport type InferCreateType<T> = T extends CompiledSchema<infer R> ? InferCompiledCreateSchema<R> : T extends {} ? InferCompiledCreateSchema<T> : unknown;\nexport type InferMappedType<T> = T extends SchemaBase<infer K, infer __> ? InferType<K> : InferCompiledSchema<T>;\nexport type InferRoot<T> = T extends CompiledSchema<infer R> ? R : never;\n\ntype HasModifier<T, K extends keyof T, M extends SchemaModifiers> =\n T[K] extends SchemaBase<any, infer Mods> ?\n M extends Mods ? true : false :\n false;\n\ntype IsPlainProperty<T, K extends keyof T> =\n [\n HasModifier<T, K, \"readonly\">,\n HasModifier<T, K, \"optional\">,\n HasModifier<T, K, \"nullable\">\n ] extends [\n false,\n false,\n false\n ] ? true : false;\n\ntype IsCreateExcluded<T, K extends keyof T> =\n [\n HasModifier<T, K, \"identity\">,\n HasModifier<T, K, \"computed\">,\n HasModifier<T, K, \"unmapped\">\n ] extends [\n false,\n false,\n false\n ] ? false : true;\n\ntype IsCreateOptional<T, K extends keyof T> =\n [\n HasModifier<T, K, \"optional\">,\n HasModifier<T, K, \"default\">\n ] extends [\n false,\n false\n ] ? false : true;\n\ntype IsCreateNullable<T, K extends keyof T> =\n HasModifier<T, K, \"nullable\"> extends true ? true : false;\n\n/**\n * What a property ACCEPTS on the way in, which is not always what it gives back.\n *\n * Only a file differs today: you assign content and read a reference. Matching on the read\n * type rather than on `SchemaFile` itself is deliberate — it keeps working through every\n * modifier. `s.file().optional()` is a `SchemaOptional`, `s.file().tag('x')` is a\n * `SchemaTag`, and neither carries the original class, so a check against the class alone\n * would silently stop accepting content the moment anyone added a modifier.\n *\n * Assignability is required in BOTH directions, and the tuple wrappers are load-bearing.\n * One-way `extends` matches `never` — which is assignable to everything — so a generic\n * property over `Record<string, unknown>` resolved to file content and broke the Dexie\n * plugin's types. It also matched any object that merely happens to have these five fields\n * plus more. Mutual assignability admits the reference shape and nothing else, and the\n * tuples stop the conditional distributing over a union.\n */\ntype InferWritePrimitive<T> =\n [InferPrimitive<T>] extends [FileReferenceValue]\n ? [FileReferenceValue] extends [InferPrimitive<T>] ? FileContentValue : InferPrimitive<T>\n : InferPrimitive<T>;\n\ntype InferCreateProperty<T, K extends keyof T> =\n IsCreateNullable<T, K> extends true ? null | InferWritePrimitive<T[K]> : InferWritePrimitive<T[K]>;\n\ntype InferCompiledSchema<T> = CoalesceEmpty<{\n [K in keyof T as IsPlainProperty<T, K> extends true ? K : never]: InferPrimitive<T[K]>\n}, {\n readonly [K in keyof T as HasModifier<T, K, \"readonly\"> extends true ? K : never]: InferPrimitive<T[K]>\n }, {\n [K in keyof T as HasModifier<T, K, \"optional\"> extends true ? K : never]?: InferPrimitive<T[K]>\n }, {\n [K in keyof T as HasModifier<T, K, \"nullable\"> extends true ? K : never]: null | InferPrimitive<T[K]>\n}>;\n\ntype InferCompiledCreateSchema<T> = {\n [K in keyof T as IsCreateExcluded<T, K> extends true ? never\n : IsCreateOptional<T, K> extends true ? K : never]?: InferCreateProperty<T, K>\n} & {\n [K in keyof T as IsCreateExcluded<T, K> extends true ? never\n : IsCreateOptional<T, K> extends true ? never : K]: InferCreateProperty<T, K>\n};\n\ntype IsEmptyObject<T> = keyof T extends never ? true : false;\ntype CoalesceEmpty<T1 extends {}, T2 extends {}, T3 extends {}, T4 extends {}> = (IsEmptyObject<T1> extends true ? {} : T1) & (IsEmptyObject<T2> extends true ? {} : T2) & (IsEmptyObject<T3> extends true ? {} : T3) & (IsEmptyObject<T4> extends true ? {} : T4);\n","export const isDate = (data: unknown): data is Date => {\n if (data == null) {\n return false;\n }\n\n if (typeof data !== \"object\") {\n return false;\n }\n\n return data instanceof Date;\n}","/**\n * Levelled logging, resolved once.\n *\n * Three things about the previous implementation drove this shape:\n *\n * - **There was no way to turn logging off.** `globalThis.__ROUTIER_DEBUG__` was only ever\n * compared against `true`, so setting it to `false` did nothing — while\n * `docs/how-to/debug-logging.md` documented exactly that as the way to force logging off.\n * A documented switch that silently does nothing is worse than no switch.\n * - **`NODE_ENV === 'test'` enabled it.** Every Jest run therefore logged, because Jest always\n * sets `NODE_ENV=test`. Measured on the S7 stress scenario, which drives ~2,000 saves through\n * a plugin that logs three lines per query: 12.4s with logging, ~6s without. Test runners also\n * capture console output by snapshotting a stack trace per call, so the cost is far above what\n * writing to a terminal would suggest — and the output buries whatever the failure was.\n * - **It was all-or-nothing, and re-resolved per call.** An error could not be kept while debug\n * was dropped, and every one of the ~97 call sites re-read `globalThis` and `process.env`.\n *\n * Levels are compared numerically against a value cached at module load. Measured against a\n * no-op console at 200k calls: an enabled call costs ~70ns, a call rejected by the gate ~3ns.\n * Building the arguments the call site passes in accounts for ~0.2ns of that 3ns, which is why\n * this keeps the ordinary `logger.debug(msg, payload)` signature instead of taking a thunk —\n * a lazy API would recover 0.3% of an enabled call's cost and would have to change every call\n * site to do it.\n */\n\n/** Ordered from most severe to most verbose. `silent` discards everything. */\nexport const LOG_LEVELS = ['silent', 'error', 'warn', 'info', 'debug'] as const;\n\nexport type LogLevel = (typeof LOG_LEVELS)[number];\n\n/** Numeric rank, so a gate is one integer comparison. */\nconst RANK: Record<LogLevel, number> = {\n silent: 0,\n error: 1,\n warn: 2,\n info: 3,\n debug: 4,\n};\n\nconst isLogLevel = (value: unknown): value is LogLevel =>\n typeof value === 'string' && (LOG_LEVELS as readonly string[]).includes(value);\n\n/**\n * Resolves the configured level, in precedence order.\n *\n * Ordered most specific first: an explicit level beats a boolean flag, a boolean flag beats an\n * environment variable, and an environment variable beats an inference from `NODE_ENV`. Anything\n * unrecognised is ignored rather than treated as an error — a typo'd level should not take down\n * an application, and `silent` is the safe direction to fall back to.\n */\nconst resolveLevel = (): LogLevel => {\n if (typeof globalThis !== 'undefined') {\n const g = globalThis as { __ROUTIER_LOG_LEVEL__?: unknown; __ROUTIER_DEBUG__?: unknown };\n\n if (isLogLevel(g.__ROUTIER_LOG_LEVEL__)) {\n return g.__ROUTIER_LOG_LEVEL__;\n }\n\n // Both directions honoured. `=== false` used to fall through to the NODE_ENV checks\n // below and re-enable the logging it was asked to suppress.\n if (g.__ROUTIER_DEBUG__ === true) return 'debug';\n if (g.__ROUTIER_DEBUG__ === false) return 'silent';\n }\n\n // There is deliberately no `import.meta.env` branch, although the documentation used to\n // promise one. It could never work: this package is bundled with rspack, which replaces\n // `import.meta` with `undefined`, so the check would read the *library's* build-time\n // environment rather than the application's — and referencing `import.meta` at all is a parse\n // error under a CommonJS build target, which is how the test suite loads this file. Vite and\n // similar apps set `__ROUTIER_LOG_LEVEL__` or `__ROUTIER_DEBUG__` from their own\n // `import.meta.env`, which is what the docs now describe.\n if (typeof process !== 'undefined' && process.env != null) {\n if (isLogLevel(process.env.ROUTIER_LOG_LEVEL)) {\n return process.env.ROUTIER_LOG_LEVEL as LogLevel;\n }\n\n const debug = process.env.DEBUG;\n if (debug === 'routier' || debug === '*') return 'debug';\n\n const env = process.env.NODE_ENV?.toLowerCase();\n\n if (env === 'dev' || env === 'development') return 'debug';\n }\n\n // Warnings are on unless something turns them off.\n //\n // Routier warns when a query returns correct rows a slower way than it could, or when a filter\n // compares types that can never match. Both are the caller's to act on, and a default of\n // `silent` meant the only people who ever saw them were the ones who already knew to look.\n return 'warn';\n};\n\nlet level: LogLevel = resolveLevel();\nlet rank = RANK[level];\n\n/**\n * Overrides the level for the rest of the process.\n *\n * The configuration above is read once, at import, which is what makes the gate cheap — but it\n * also means an application that decides its verbosity after startup, or a test that wants to\n * assert on output, has no way in. This is that way in.\n */\nexport const setLogLevel = (next: LogLevel): void => {\n if (isLogLevel(next) === false) {\n throw new Error(`Unknown log level \"${next}\". Expected one of: ${LOG_LEVELS.join(', ')}`);\n }\n\n level = next;\n rank = RANK[next];\n};\n\nexport const getLogLevel = (): LogLevel => level;\n\n/** Re-reads the environment. For tests that change it after this module was imported. */\nexport const resetLogLevel = (): void => {\n level = resolveLevel();\n rank = RANK[level];\n};\n\n/**\n * Whether a message at this level would be emitted.\n *\n * For the rare call site whose *arguments* are expensive to build — a serialization, a deep\n * clone, a join over a large collection. An ordinary payload object is not worth guarding; see\n * the measurement in the header.\n */\nexport const isLogLevelEnabled = (at: LogLevel): boolean => rank >= RANK[at];\n\ntype ConsoleMethod = 'log' | 'info' | 'warn' | 'error' | 'debug' | 'table';\n\nconst emit = (at: LogLevel, method: ConsoleMethod, args: unknown[]) => {\n if (rank < RANK[at]) {\n return;\n }\n\n // Resolved at call time rather than captured once: test harnesses and browser devtools both\n // replace console methods after modules have loaded, and a captured reference would keep\n // writing past the replacement.\n (console[method] as (...a: unknown[]) => void)(...args);\n};\n\nexport const logger = {\n /** General-purpose output. Carried at `info`, since `log` names a console method, not a level. */\n log: (...args: unknown[]): void => emit('info', 'log', args),\n info: (...args: unknown[]): void => emit('info', 'info', args),\n warn: (...args: unknown[]): void => emit('warn', 'warn', args),\n error: (...args: unknown[]): void => emit('error', 'error', args),\n debug: (...args: unknown[]): void => emit('debug', 'debug', args),\n /** Diagnostic tabular output; verbose by nature, so it sits at `debug`. */\n table: (...args: unknown[]): void => emit('debug', 'table', args),\n};\n","export const hash = (value: string, seed: number = 0) => {\n // From Stack Overflow\n // https://stackoverflow.com/a/52171480/3329760\n let h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed;\n\n for (let i = 0, ch: number; i < value.length; i++) {\n ch = value.charCodeAt(i);\n h1 = Math.imul(h1 ^ ch, 2654435761);\n h2 = Math.imul(h2 ^ ch, 1597334677);\n }\n\n h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507);\n h1 ^= Math.imul(h2 ^ (h2 >>> 13), 3266489909);\n h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507);\n h2 ^= Math.imul(h1 ^ (h1 >>> 13), 3266489909);\n\n return 4294967296 * (2097151 & h2) + (h1 >>> 0);\n}\n\n/**\n * Fast string hash optimized for comparisons.\n * Uses djb2 algorithm - very fast and good distribution for short to medium strings.\n * Same input always produces same output (deterministic).\n * \n * @param value - The string to hash\n * @param seed - Optional seed value (default: 5381)\n * @returns A positive 32-bit integer hash value\n * \n * @example\n * ```ts\n * fastHash(\"test\") === fastHash(\"test\") // true\n * fastHash(\"test\") !== fastHash(\"test2\") // true\n * ```\n */\nexport const fastHash = (value: string, seed: number = 5381): number => {\n let hash = seed;\n for (let i = 0; i < value.length; i++) {\n hash = ((hash << 5) + hash) + value.charCodeAt(i);\n }\n return hash >>> 0; // Convert to unsigned 32-bit integer\n}\n\n/**\n * Converts any value to a readable string representation.\n * Handles primitives, objects, arrays, classes, dates, errors, and functions.\n * Supports depth limiting to prevent infinite recursion on circular references.\n * \n * @param obj - The value to stringify\n * @param maxDepth - Maximum depth for nested objects (default: 3)\n * @param currentDepth - Current recursion depth (default: 0)\n * @returns String representation of the value\n * \n * @example\n * ```ts\n * stringifyObject({ name: \"test\", count: 5 }) // '{ name: \"test\", count: 5 }'\n * stringifyObject([1, 2, 3]) // '[1, 2, 3]'\n * stringifyObject(new Date()) // 'Date(2024-01-01T00:00:00.000Z)'\n * ```\n */\nexport function stringifyObject(obj: unknown, maxDepth: number = 3, currentDepth: number = 0): string {\n if (obj === null) return 'null';\n if (obj === undefined) return 'undefined';\n\n const type = typeof obj;\n\n switch (type) {\n case 'string':\n return `\"${obj}\"`;\n case 'number':\n case 'boolean':\n return String(obj);\n case 'function':\n return `[Function: ${getFunctionName(obj as Function)}]`;\n case 'object':\n if (currentDepth >= maxDepth) {\n return '[Max Depth Reached]';\n }\n return stringifyObjectValue(obj, maxDepth, currentDepth);\n default:\n return `[${type}]`;\n }\n}\n\nfunction getFunctionName(fn: Function): string {\n const name = fn.name;\n return name || 'anonymous';\n}\n\nfunction getObjectProperties(obj: any): Record<string, any> {\n const properties: Record<string, any> = {};\n\n for (const key in obj) {\n if (obj.hasOwnProperty(key)) {\n properties[key] = obj[key];\n }\n }\n\n return properties;\n}\n\nfunction stringifyObjectValue(obj: any, maxDepth: number, currentDepth: number): string {\n if (obj === null) return 'null';\n\n if (obj instanceof Date) {\n return `Date(${obj.toISOString()})`;\n }\n\n if (obj instanceof Error) {\n return `Error(${obj.message})`;\n }\n\n if (obj instanceof RegExp) {\n return obj.toString();\n }\n\n if (Array.isArray(obj)) {\n return stringifyArray(obj, maxDepth, currentDepth);\n }\n\n if (obj.constructor && obj.constructor.name !== 'Object') {\n return stringifyClassInstance(obj, maxDepth, currentDepth);\n }\n\n return stringifyPlainObject(obj, maxDepth, currentDepth);\n}\n\nfunction stringifyArray(arr: any[], maxDepth: number, currentDepth: number): string {\n if (arr.length === 0) return '[]';\n\n const items = arr.slice(0, 5).map(item =>\n stringifyObject(item, maxDepth, currentDepth + 1)\n );\n\n const suffix = arr.length > 5 ? `... (+${arr.length - 5} more)` : '';\n return `[${items.join(', ')}${suffix}]`;\n}\n\nfunction stringifyClassInstance(obj: any, maxDepth: number, currentDepth: number): string {\n const className = obj.constructor.name;\n const properties = getObjectProperties(obj);\n\n if (Object.keys(properties).length === 0) {\n return `${className} {}`;\n }\n\n const props = Object.entries(properties)\n .slice(0, 5)\n .map(([key, value]) => {\n const isPrimitive = value === null || value === undefined ||\n (typeof value !== 'object' && typeof value !== 'function');\n const depth = isPrimitive ? currentDepth : currentDepth + 1;\n return `${key}: ${stringifyObject(value, maxDepth, depth)}`;\n });\n\n const suffix = Object.keys(properties).length > 5 ?\n `... (+${Object.keys(properties).length - 5} more)` : '';\n\n return `${className} { ${props.join(', ')}${suffix} }`;\n}\n\nfunction stringifyPlainObject(obj: any, maxDepth: number, currentDepth: number): string {\n const properties = getObjectProperties(obj);\n\n if (Object.keys(properties).length === 0) {\n return '{}';\n }\n\n const props = Object.entries(properties)\n .slice(0, 5)\n .map(([key, value]) => {\n const isPrimitive = value === null || value === undefined ||\n (typeof value !== 'object' && typeof value !== 'function');\n const depth = isPrimitive ? currentDepth : currentDepth + 1;\n return `${key}: ${stringifyObject(value, maxDepth, depth)}`;\n });\n\n const suffix = Object.keys(properties).length > 5 ?\n `... (+${Object.keys(properties).length - 5} more)` : '';\n\n return `{ ${props.join(', ')}${suffix} }`;\n}","export const uuid = (length: number = 16): string => {\n const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n const charLength = chars.length;\n let result = '';\n\n for (let i = 0; i < length; i++) {\n result += chars[Math.random() * charLength | 0];\n }\n return result;\n}\n\nconst HEX_CHARS = '0123456789abcdef';\nconst UUID_TEMPLATE = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';\n\nconst hasCrypto =\n typeof crypto !== 'undefined' && typeof crypto.getRandomValues === 'function';\n\nconst hasRandomUUID =\n typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function';\n\nexport const uuidv4 = (): string => {\n if (hasRandomUUID) {\n return crypto.randomUUID();\n }\n\n return uuidv4Fallback();\n};\n\nconst uuidv4Fallback = (): string => {\n let randomBytes: Uint8Array | null = null;\n if (hasCrypto) {\n randomBytes = crypto.getRandomValues(new Uint8Array(16));\n }\n\n let byteIndex = 0;\n let uuid = '';\n\n for (let i = 0; i < UUID_TEMPLATE.length; i++) {\n const c = UUID_TEMPLATE[i];\n if (c === '-') {\n uuid += '-';\n continue;\n }\n\n let r: number;\n if (hasCrypto && randomBytes) {\n // Each byte gives two hex digits (nibbles)\n r =\n (i % 2 === 0\n ? randomBytes[byteIndex] >> 4\n : randomBytes[byteIndex++] & 0x0f);\n } else {\n r = Math.floor(Math.random() * 16);\n }\n\n if (c === 'x') {\n uuid += HEX_CHARS[r];\n } else if (c === 'y') {\n // Variant bits: 8, 9, A, or B\n uuid += HEX_CHARS[(r & 0x3) | 0x8];\n } else if (c === '4') {\n uuid += '4';\n }\n }\n\n return uuid;\n};\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","export const toMap = <T extends {}>(data: T[], keySelector: (item: T) => T[keyof T] | string) => {\n\n const result = new Map<T[keyof T] | string, T>();\n\n for (let i = 0; i < data.length; i++) {\n const item = data[i];\n const key = keySelector(item);\n result.set(key, item);\n }\n\n return result;\n}\n","export const cast = <TIn, TOut>(item: TIn) => {\n return item as unknown as TOut;\n}\n\nexport function clone<T extends {}>(data: T): T {\n return JSON.parse(JSON.stringify(data)) as T;\n}","export const isNodeRuntime = () => typeof process !== 'undefined' &&\n process.versions != null &&\n process.versions.node != null;","import { BulkPersistResult, BulkPersistChanges } from \"../collections\";\nimport { DbPluginBulkPersistEvent } from \"../plugins\";\n\nexport const resolveBulkPersistChanges = (event: DbPluginBulkPersistEvent, result: BulkPersistResult, bulkPersistChanges: BulkPersistChanges) => {\n // make sure we swap the adds here, that way we can make sure other persist events\n // don't take their additions and try to change subsequent calls\n for (const [schemaId, changes] of event.operation) {\n\n const schemmaBulkPersistResult = result.get(schemaId);\n const schemaBulkPersistChanges = bulkPersistChanges.resolve(schemaId);\n\n // Set the original removes\n schemaBulkPersistChanges.removes = changes.removes;\n\n // Set the original updates\n schemaBulkPersistChanges.updates = changes.updates;\n\n // Take the adds from the result and set them to be persisted\n // in the replicated plugins because the id's are set in the \n // memory data store\n schemaBulkPersistChanges.adds = schemmaBulkPersistResult.adds;\n }\n}","import { QueryOptionsCollection } from \"../plugins/query\";\n\nexport const combineQueryOptionsCollections = <T>(...collections: QueryOptionsCollection<T>[]) => {\n const result = new QueryOptionsCollection<T>();\n\n for (let i = 0, length = collections.length; i < length; i++) {\n const collection = collections[i];\n\n // Add scoped items first\n collection.forEach(item => {\n result.add(item.name, item.value);\n });\n }\n\n return result;\n}","import { InferCreateType, InferType, SchemaId } from \"../schema\";\nimport { DbPluginBulkPersistEvent, EntityUpdateInfo } from \"../plugins\";\n\ntype DbEvent = {\n type: \"add\",\n data: InferCreateType<unknown>;\n} | {\n type: \"update\",\n data: EntityUpdateInfo<unknown>;\n} | {\n type: \"remove\",\n data: InferType<unknown>;\n}\n\nexport const toEventArray = (event: DbPluginBulkPersistEvent): [SchemaId, DbEvent][] => {\n\n const result: [SchemaId, DbEvent][] = [];\n for (const [schemaId, changes] of event.operation) {\n\n if (changes.hasItems === false) {\n continue;\n }\n\n if (changes.adds.length > 0) {\n result.push(...changes.adds.map(add => {\n return [schemaId as SchemaId, { data: { ...add }, type: \"add\" }] as [SchemaId, DbEvent];\n }));\n }\n\n if (changes.updates.length > 0) {\n result.push(...changes.updates.map(update => {\n return [schemaId as SchemaId, { data: { ...update }, type: \"update\" }] as [SchemaId, DbEvent];\n }));\n }\n\n if (changes.removes.length > 0) {\n result.push(...changes.removes.map(remove => {\n return [schemaId as SchemaId, { data: { ...remove }, type: \"remove\" }] as [SchemaId, DbEvent];\n }));\n }\n }\n\n return result\n}","export const noop = (..._args: any[]) => { };","export const unsafeCast = <T>(value: unknown): T => {\n return value as T\n}","export * from './arrays';\nexport * from './strings';\nexport * from './dates';\nexport * from './objects';\nexport * from './runtime';\nexport * from './uuid';\nexport * from './replication';\nexport * from './types';\nexport * from './queryOptionsCollection';\nexport * from './dbPluginEventUtils';\nexport * from './functions';\nexport * from './unsafeCast';\nexport * from './logger';"],"names":["EXPRESSION_TYPES","isDate","assertDate","data","TypeError","assertIsNotNull","message","assertIsArray","Array","assertString","assertInstanceOf","value","Instance","assertIsNumber","isObjectWithType","isExpression","isOperatorExpression","isComparatorExpression","isPropertyExpression","isValueExpression","isCallExpression","isEmptyExpression","isNotParsableExpression","peelCalls","expression","calls","current","childrenOf","call","child","children","getProperties","properties","traverse","expr","forEach","callback","SchemaTypes","logger","JAVASCRIPT_TYPE_OF","mismatchedSide","property","expected","comparesTypesThatCannotMatch","describeLiteral","String","mismatchWarning","side","outcome","QueryOptionsCollection","Map","reason","options","name","mapValue","x","filterValue","sortValue","nearestValue","joinValue","item","found","sortedItems","a","b","before","after","at","i","length","option","destination","key","items","nextExecutionTarget","nextExecutionReason","nextIndex","Math","candidate","memoryQueryOptionsCollection","databaseQueryOptionsCollection","sortedItem","half","transformationOptions","w","iterator","HashType","Date","LOG_LEVELS","RANK","isLogLevel","resolveLevel","globalThis","g","process","debug","env","level","rank","setLogLevel","next","Error","getLogLevel","resetLogLevel","isLogLevelEnabled","emit","method","args","console","hash","seed","h1","h2","ch","fastHash","stringifyObject","obj","maxDepth","currentDepth","undefined","type","getFunctionName","stringifyObjectValue","fn","getObjectProperties","RegExp","stringifyArray","stringifyClassInstance","stringifyPlainObject","arr","suffix","className","Object","props","isPrimitive","depth","uuid","chars","charLength","result","HEX_CHARS","UUID_TEMPLATE","hasCrypto","crypto","hasRandomUUID","uuidv4","uuidv4Fallback","randomBytes","Uint8Array","byteIndex","c","r","toMap","keySelector","cast","clone","JSON","isNodeRuntime","resolveBulkPersistChanges","event","bulkPersistChanges","schemaId","changes","schemmaBulkPersistResult","schemaBulkPersistChanges","combineQueryOptionsCollections","collections","collection","toEventArray","add","update","remove","noop","_args","unsafeCast"],"mappings":";;;;;;;;;AAA4D;AAEtB;AAE/B,SAASE,WAAWC,IAAa;IACpC,IAAIF,OAAOE,UAAU,OAAO;QACxB,MAAM,IAAIC,UAAU;IACxB;AACJ;AAEO,SAASC,gBAAmBF,IAA0B,EAAEG,OAAiC;IAC5F,IAAIH,QAAQ,MAAM;QACd,IAAIG,WAAW,MAAM;YACjB,MAAM,IAAIF,UAAU;QACxB;QAEA,IAAI,OAAOE,YAAY,UAAU;YAC7B,MAAM,IAAIF,UAAUE;QACxB;QAEA,MAAM,IAAIF,UAAUE;IACxB;AACJ;AAEO,SAASC,cAAiBJ,IAAa,EAAEG,OAAgB;IAC5D,IAAI,CAACE,MAAM,OAAO,CAACL,OAAO;QACtB,MAAM,IAAIC,UAAUE,WAAW;IACnC;AACJ;AAEO,SAASG,aAAaN,I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