@orkestrel/database 0.0.18 → 0.0.19

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.
@@ -89,6 +89,16 @@ export declare function auditDriver(factory: () => DriverInterface): Promise<rea
89
89
  */
90
90
  export declare function bindRowKey(row: Row, primary: string, key: Key): Row;
91
91
 
92
+ /**
93
+ * Captures the exact rejection or synchronous throw from a driver conformance operation.
94
+ *
95
+ * @example
96
+ * ```ts
97
+ * await captureFailure(() => Promise.reject('refused')) // 'refused'
98
+ * ```
99
+ */
100
+ export declare function captureFailure(operation: () => Promise<unknown>): Promise<unknown>;
101
+
92
102
  /**
93
103
  * Throws when an {@link OperationOptions.signal | AbortSignal} has fired — the shared
94
104
  * abort gate checked at operation boundaries and between streamed rows.
@@ -913,6 +923,11 @@ export declare function isColumnSchema(value: unknown): value is ColumnSchema;
913
923
  /**
914
924
  * Narrows an unknown caught value to a {@link DatabaseError}.
915
925
  *
926
+ * @remarks
927
+ * Accepts branded instances and subclasses across package copies and module formats.
928
+ * Requires the declared code and context shape. Refuses look-alikes and transparent
929
+ * proxies without requiring an exact `name`.
930
+ *
916
931
  * @param value - The value to test (typically a `catch` binding)
917
932
  * @returns True if `value` is a {@link DatabaseError}; false otherwise
918
933
  *
@@ -1122,19 +1137,20 @@ export declare function matchesQuery(row: Row, conditions: readonly Condition[])
1122
1137
  * `.*` segments separated by literals, matched against a long non-matching input, blow
1123
1138
  * up super-linearly — and JS has no atomic groups / possessive quantifiers to bound it,
1124
1139
  * while a `LIKE` / `GLOB` pattern is a caller-supplied operand this package cannot
1125
- * trust. So this builds no regex. It runs the classic greedy two-pointer wildcard match:
1126
- * the `any` wildcard records its position and, on a later mismatch, backtracks only to
1127
- * that last `any` (letting it absorb one more char) — so the work is O(value × pattern),
1128
- * never the exponential / polynomial backtracking a regex would do. The pattern length
1129
- * is capped at {@link MAX_PATTERN_LENGTH} (a `VALIDATION` {@link DatabaseError} over it),
1130
- * bounding the pattern factor so a match stays linear in the value length whatever the
1131
- * pattern.
1140
+ * trust. This builds no regex. It splits the pattern on `any` into fixed-length
1141
+ * segments, anchors the first at the value's start and the last at its end, and places
1142
+ * each middle segment at its leftmost match after the one before it, which is the only
1143
+ * placement a match needs, so the work is O(value × pattern) at worst, never the
1144
+ * exponential / polynomial backtracking a regex would do. The pattern length is capped
1145
+ * at {@link MAX_PATTERN_LENGTH} (a `VALIDATION` {@link DatabaseError} over it), bounding
1146
+ * the pattern factor so a match stays linear in the value length whatever the pattern.
1132
1147
  *
1133
1148
  * The `any` wildcard matches any run (including empty); `single` matches exactly one
1134
- * char; every other pattern char matches itself literally (a pattern `.` / `(` / `\` is
1135
- * a literal — the regex-metacharacter hazard is gone with the regex). `any` is tested
1136
- * before a literal match, so a value that literally contains the wildcard char never
1137
- * shadows the wildcard. Case folding is applied to both sides when `fold` is set.
1149
+ * UTF-16 code unit; every other pattern char matches itself literally (a pattern `.` /
1150
+ * `(` / `\` is a literal — the regex-metacharacter hazard is gone with the regex). The
1151
+ * pattern splits on `any` before any literal comparison, so a value that literally
1152
+ * contains the wildcard char never shadows the wildcard. Case folding is applied to
1153
+ * both sides when `fold` is set.
1138
1154
  *
1139
1155
  * @param value - The value to test
1140
1156
  * @param pattern - The wildcard pattern
@@ -1146,6 +1162,26 @@ export declare function matchesQuery(row: Row, conditions: readonly Condition[])
1146
1162
  */
1147
1163
  export declare function matchesWildcardPattern(value: string, pattern: string, any: string, single: string, fold: boolean): boolean;
1148
1164
 
1165
+ /**
1166
+ * Checks whether a fixed-length wildcard segment matches a value at an offset.
1167
+ *
1168
+ * @remarks
1169
+ * Compares UTF-16 code units: `single` matches any one unit, and every other segment
1170
+ * unit matches itself. An offset that leaves the segment outside the value fails.
1171
+ *
1172
+ * @param value - The value to read
1173
+ * @param segment - The segment, holding no any-run wildcard
1174
+ * @param at - The value offset the segment starts at
1175
+ * @param single - The single-char wildcard char
1176
+ * @returns True if every segment unit matches the value unit at its offset; false otherwise
1177
+ *
1178
+ * @example
1179
+ * ```ts
1180
+ * matchesWildcardSegment('hello', 'l_o', 2, '_') // true
1181
+ * ```
1182
+ */
1183
+ export declare function matchesWildcardSegment(value: string, segment: string, at: number, single: string): boolean;
1184
+
1149
1185
  /**
1150
1186
  * Sets the longest `LIKE` / `GLOB` pattern the wildcard matcher accepts, 1024 characters, before
1151
1187
  * rejecting it.
@@ -1770,6 +1806,24 @@ export declare interface StorageInterface {
1770
1806
  stamp?(metadata: DriverMetadata): Promise<void>;
1771
1807
  }
1772
1808
 
1809
+ /**
1810
+ * Tracks the matching-row position of one streaming page.
1811
+ *
1812
+ * @example
1813
+ * ```ts
1814
+ * const page = new StreamPage(1)
1815
+ * page.next() // false
1816
+ * page.next() // true
1817
+ * page.count // 1
1818
+ * ```
1819
+ */
1820
+ export declare class StreamPage {
1821
+ #private;
1822
+ constructor(offset: number);
1823
+ get count(): number;
1824
+ next(): boolean;
1825
+ }
1826
+
1773
1827
  /**
1774
1828
  * Represents one table's portable definition, produced by `export` — the unit of schema /
1775
1829
  * migration exchange across environments.
@@ -89,6 +89,16 @@ export declare function auditDriver(factory: () => DriverInterface): Promise<rea
89
89
  */
90
90
  export declare function bindRowKey(row: Row, primary: string, key: Key): Row;
91
91
 
92
+ /**
93
+ * Captures the exact rejection or synchronous throw from a driver conformance operation.
94
+ *
95
+ * @example
96
+ * ```ts
97
+ * await captureFailure(() => Promise.reject('refused')) // 'refused'
98
+ * ```
99
+ */
100
+ export declare function captureFailure(operation: () => Promise<unknown>): Promise<unknown>;
101
+
92
102
  /**
93
103
  * Throws when an {@link OperationOptions.signal | AbortSignal} has fired — the shared
94
104
  * abort gate checked at operation boundaries and between streamed rows.
@@ -913,6 +923,11 @@ export declare function isColumnSchema(value: unknown): value is ColumnSchema;
913
923
  /**
914
924
  * Narrows an unknown caught value to a {@link DatabaseError}.
915
925
  *
926
+ * @remarks
927
+ * Accepts branded instances and subclasses across package copies and module formats.
928
+ * Requires the declared code and context shape. Refuses look-alikes and transparent
929
+ * proxies without requiring an exact `name`.
930
+ *
916
931
  * @param value - The value to test (typically a `catch` binding)
917
932
  * @returns True if `value` is a {@link DatabaseError}; false otherwise
918
933
  *
@@ -1122,19 +1137,20 @@ export declare function matchesQuery(row: Row, conditions: readonly Condition[])
1122
1137
  * `.*` segments separated by literals, matched against a long non-matching input, blow
1123
1138
  * up super-linearly — and JS has no atomic groups / possessive quantifiers to bound it,
1124
1139
  * while a `LIKE` / `GLOB` pattern is a caller-supplied operand this package cannot
1125
- * trust. So this builds no regex. It runs the classic greedy two-pointer wildcard match:
1126
- * the `any` wildcard records its position and, on a later mismatch, backtracks only to
1127
- * that last `any` (letting it absorb one more char) — so the work is O(value × pattern),
1128
- * never the exponential / polynomial backtracking a regex would do. The pattern length
1129
- * is capped at {@link MAX_PATTERN_LENGTH} (a `VALIDATION` {@link DatabaseError} over it),
1130
- * bounding the pattern factor so a match stays linear in the value length whatever the
1131
- * pattern.
1140
+ * trust. This builds no regex. It splits the pattern on `any` into fixed-length
1141
+ * segments, anchors the first at the value's start and the last at its end, and places
1142
+ * each middle segment at its leftmost match after the one before it, which is the only
1143
+ * placement a match needs, so the work is O(value × pattern) at worst, never the
1144
+ * exponential / polynomial backtracking a regex would do. The pattern length is capped
1145
+ * at {@link MAX_PATTERN_LENGTH} (a `VALIDATION` {@link DatabaseError} over it), bounding
1146
+ * the pattern factor so a match stays linear in the value length whatever the pattern.
1132
1147
  *
1133
1148
  * The `any` wildcard matches any run (including empty); `single` matches exactly one
1134
- * char; every other pattern char matches itself literally (a pattern `.` / `(` / `\` is
1135
- * a literal — the regex-metacharacter hazard is gone with the regex). `any` is tested
1136
- * before a literal match, so a value that literally contains the wildcard char never
1137
- * shadows the wildcard. Case folding is applied to both sides when `fold` is set.
1149
+ * UTF-16 code unit; every other pattern char matches itself literally (a pattern `.` /
1150
+ * `(` / `\` is a literal — the regex-metacharacter hazard is gone with the regex). The
1151
+ * pattern splits on `any` before any literal comparison, so a value that literally
1152
+ * contains the wildcard char never shadows the wildcard. Case folding is applied to
1153
+ * both sides when `fold` is set.
1138
1154
  *
1139
1155
  * @param value - The value to test
1140
1156
  * @param pattern - The wildcard pattern
@@ -1146,6 +1162,26 @@ export declare function matchesQuery(row: Row, conditions: readonly Condition[])
1146
1162
  */
1147
1163
  export declare function matchesWildcardPattern(value: string, pattern: string, any: string, single: string, fold: boolean): boolean;
1148
1164
 
1165
+ /**
1166
+ * Checks whether a fixed-length wildcard segment matches a value at an offset.
1167
+ *
1168
+ * @remarks
1169
+ * Compares UTF-16 code units: `single` matches any one unit, and every other segment
1170
+ * unit matches itself. An offset that leaves the segment outside the value fails.
1171
+ *
1172
+ * @param value - The value to read
1173
+ * @param segment - The segment, holding no any-run wildcard
1174
+ * @param at - The value offset the segment starts at
1175
+ * @param single - The single-char wildcard char
1176
+ * @returns True if every segment unit matches the value unit at its offset; false otherwise
1177
+ *
1178
+ * @example
1179
+ * ```ts
1180
+ * matchesWildcardSegment('hello', 'l_o', 2, '_') // true
1181
+ * ```
1182
+ */
1183
+ export declare function matchesWildcardSegment(value: string, segment: string, at: number, single: string): boolean;
1184
+
1149
1185
  /**
1150
1186
  * Sets the longest `LIKE` / `GLOB` pattern the wildcard matcher accepts, 1024 characters, before
1151
1187
  * rejecting it.
@@ -1770,6 +1806,24 @@ export declare interface StorageInterface {
1770
1806
  stamp?(metadata: DriverMetadata): Promise<void>;
1771
1807
  }
1772
1808
 
1809
+ /**
1810
+ * Tracks the matching-row position of one streaming page.
1811
+ *
1812
+ * @example
1813
+ * ```ts
1814
+ * const page = new StreamPage(1)
1815
+ * page.next() // false
1816
+ * page.next() // true
1817
+ * page.count // 1
1818
+ * ```
1819
+ */
1820
+ export declare class StreamPage {
1821
+ #private;
1822
+ constructor(offset: number);
1823
+ get count(): number;
1824
+ next(): boolean;
1825
+ }
1826
+
1773
1827
  /**
1774
1828
  * Represents one table's portable definition, produced by `export` — the unit of schema /
1775
1829
  * migration exchange across environments.