@effect-dynamodb/schema 1.36.1 → 1.37.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.
- package/dist/Aggregate.d.ts +19 -11
- package/dist/Aggregate.d.ts.map +1 -1
- package/dist/Aggregate.js.map +1 -1
- package/dist/DynamoModel.d.ts +9 -1
- package/dist/DynamoModel.d.ts.map +1 -1
- package/dist/DynamoModel.js.map +1 -1
- package/dist/DynamoSchema.d.ts +20 -0
- package/dist/DynamoSchema.d.ts.map +1 -1
- package/dist/DynamoSchema.js +14 -0
- package/dist/DynamoSchema.js.map +1 -1
- package/dist/Entity.d.ts +153 -21
- package/dist/Entity.d.ts.map +1 -1
- package/dist/Entity.js +102 -2
- package/dist/Entity.js.map +1 -1
- package/dist/Errors.d.ts +27 -0
- package/dist/Errors.d.ts.map +1 -1
- package/dist/Errors.js +24 -0
- package/dist/Errors.js.map +1 -1
- package/dist/KeyComposer.d.ts +165 -27
- package/dist/KeyComposer.d.ts.map +1 -1
- package/dist/KeyComposer.js +251 -22
- package/dist/KeyComposer.js.map +1 -1
- package/dist/ZOrder.d.ts +173 -0
- package/dist/ZOrder.d.ts.map +1 -0
- package/dist/ZOrder.js +39 -0
- package/dist/ZOrder.js.map +1 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/AggregateEdges.d.ts +81 -12
- package/dist/internal/AggregateEdges.d.ts.map +1 -1
- package/dist/internal/AggregateEdges.js +17 -21
- package/dist/internal/AggregateEdges.js.map +1 -1
- package/dist/internal/AggregateTypes.d.ts +51 -2
- package/dist/internal/AggregateTypes.d.ts.map +1 -1
- package/dist/internal/CompositeCodec.d.ts +27 -12
- package/dist/internal/CompositeCodec.d.ts.map +1 -1
- package/dist/internal/CompositeCodec.js +93 -23
- package/dist/internal/CompositeCodec.js.map +1 -1
- package/dist/internal/EntityConfig.d.ts +12 -9
- package/dist/internal/EntityConfig.d.ts.map +1 -1
- package/dist/internal/EntityTypes.d.ts +77 -2
- package/dist/internal/EntityTypes.d.ts.map +1 -1
- package/dist/internal/KeyText136.d.ts +153 -0
- package/dist/internal/KeyText136.d.ts.map +1 -0
- package/dist/internal/KeyText136.js +357 -0
- package/dist/internal/KeyText136.js.map +1 -0
- package/dist/internal/NumericKey.d.ts +71 -0
- package/dist/internal/NumericKey.d.ts.map +1 -0
- package/dist/internal/NumericKey.js +128 -0
- package/dist/internal/NumericKey.js.map +1 -0
- package/dist/internal/SchemaAccessors.d.ts +6 -5
- package/dist/internal/SchemaAccessors.d.ts.map +1 -1
- package/dist/internal/SchemaAccessors.js +6 -5
- package/dist/internal/SchemaAccessors.js.map +1 -1
- package/dist/internal/ZOrderCurve.d.ts +256 -0
- package/dist/internal/ZOrderCurve.d.ts.map +1 -0
- package/dist/internal/ZOrderCurve.js +630 -0
- package/dist/internal/ZOrderCurve.js.map +1 -0
- package/dist/internal/ZOrderDimension.d.ts +70 -0
- package/dist/internal/ZOrderDimension.d.ts.map +1 -0
- package/dist/internal/ZOrderDimension.js +283 -0
- package/dist/internal/ZOrderDimension.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* KeyText136 — the key text effect-dynamodb 1.36 composed (#171).
|
|
3
|
+
*
|
|
4
|
+
* 1.37 composes some key text differently, so a row 1.36 wrote with such a
|
|
5
|
+
* value sits under a key 1.37 does not compose:
|
|
6
|
+
*
|
|
7
|
+
* - **Numbers** (`serializeValue`): 1.36 zero-padded `String(n)` to 16
|
|
8
|
+
* characters (a bigint to 38), which kept non-negative integers below 1e16
|
|
9
|
+
* in order and nothing else; 1.37 encodes every number in numeric order
|
|
10
|
+
* (`NumericKey.ts`). The text of a non-negative integer below 1e16 (1e38 for
|
|
11
|
+
* a bigint) is unchanged.
|
|
12
|
+
* - **Sort key values** holding a code point U+0000–U+0025 — a control
|
|
13
|
+
* character, space, `!`, `"`, `#`, `$` or `%` — are escaped in 1.37
|
|
14
|
+
* (`KeyComposer.sortKeyText`) and were not in 1.36. Partition keys, unique
|
|
15
|
+
* sentinels and the structural parts of a key are not escaped.
|
|
16
|
+
* - **Time-series event keys** carried the orderBy attribute's ENCODED value
|
|
17
|
+
* (a `NumberFromString` `"10"` as the string `10`); 1.37 composes its key
|
|
18
|
+
* form (`0000000000000010`).
|
|
19
|
+
*
|
|
20
|
+
* Everything else — the key layout, casing, the history, sentinel, aggregate
|
|
21
|
+
* and EventStore key shapes — is unchanged, so these functions compose 1.36's
|
|
22
|
+
* bytes through the same `DynamoSchema` composers, fed 1.36's serialization.
|
|
23
|
+
* Z-order sort keys are new in 1.37 and have no 1.36 form: `composeAllKeys`
|
|
24
|
+
* leaves a Z-order index out.
|
|
25
|
+
*
|
|
26
|
+
* Every function takes the same key-form record its `KeyComposer` counterpart
|
|
27
|
+
* does. `test/KeyText136.test.ts` checks them against golden vectors the
|
|
28
|
+
* published 1.36.0 packages composed.
|
|
29
|
+
*
|
|
30
|
+
* The 1.37.x operations read and move rows still under their 1.36 keys while
|
|
31
|
+
* the fallback is {@link enabled}; the fallback and this module go in the next
|
|
32
|
+
* major release. Not part of the public API.
|
|
33
|
+
*/
|
|
34
|
+
import * as DynamoSchema from "../DynamoSchema.js";
|
|
35
|
+
import { type IndexDefinition } from "../KeyComposer.js";
|
|
36
|
+
/** Whether operations read and move rows under their 1.36 keys (`DynamoSchema.make`'s `legacyKeys`). */
|
|
37
|
+
export declare const enabled: (schema: DynamoSchema.DynamoSchema) => boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Does sort key value text `text` hold a code point 1.37 escapes (U+0000–
|
|
40
|
+
* U+0025)? Then its key text differs from 1.36's — and holds an escape, which
|
|
41
|
+
* 1.36's text of another value can spell: `foo%20bar` is `foo bar`'s key now.
|
|
42
|
+
*/
|
|
43
|
+
export declare const holdsEscaped: (text: string) => boolean;
|
|
44
|
+
/**
|
|
45
|
+
* The first character of `text` below `%` (U+0000–U+0024), if any. Escaped
|
|
46
|
+
* text never holds one, nor does any text whose casing is escaped text, so a
|
|
47
|
+
* stored value holding it is not the 1.36 spelling of an escape.
|
|
48
|
+
*/
|
|
49
|
+
export declare const firstBelowEscape: (text: string) => string | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* 1.36's composite value text: a number zero-padded to 16 characters, a bigint
|
|
52
|
+
* to 38 — `String(n)` padded, so `-3` is `00000000000000-3` and `2.5` is
|
|
53
|
+
* `00000000000002.5` — a boolean as `true` / `false`, a date as its ISO
|
|
54
|
+
* string. Never throws: 1.36 composed `NaN` as `0000000000000NaN`.
|
|
55
|
+
*/
|
|
56
|
+
export declare const serializeValue: (value: unknown) => string;
|
|
57
|
+
/** `KeyComposer.extractComposites` with 1.36's {@link serializeValue}. */
|
|
58
|
+
export declare const extractComposites: (composite: ReadonlyArray<string>, record: Record<string, unknown>) => ReadonlyArray<string>;
|
|
59
|
+
/** {@link extractComposites}, or `undefined` when a composite is missing. */
|
|
60
|
+
export declare const tryExtractComposites: (composite: ReadonlyArray<string>, record: Record<string, unknown>) => ReadonlyArray<string> | undefined;
|
|
61
|
+
/** 1.36's partition key of `index` (`KeyComposer.composePk`). */
|
|
62
|
+
export declare const composePk: (schema: DynamoSchema.DynamoSchema, entityType: string, index: IndexDefinition, record: Record<string, unknown>) => string;
|
|
63
|
+
/** 1.36's sort key of a string-keyed `index` (`KeyComposer.composeSk`), values unescaped. */
|
|
64
|
+
export declare const composeSk: (schema: DynamoSchema.DynamoSchema, entityType: string, entityVersion: number, index: IndexDefinition, record: Record<string, unknown>) => string;
|
|
65
|
+
/** Both 1.36 keys of a string-keyed `index`. */
|
|
66
|
+
export declare const composeIndexKeys: (schema: DynamoSchema.DynamoSchema, entityType: string, entityVersion: number, index: IndexDefinition, record: Record<string, unknown>) => Record<string, string>;
|
|
67
|
+
/** {@link composeIndexKeys}, or `undefined` when a composite is missing (a sparse index). */
|
|
68
|
+
export declare const tryComposeIndexKeys: (schema: DynamoSchema.DynamoSchema, entityType: string, entityVersion: number, index: IndexDefinition, record: Record<string, unknown>) => Record<string, string> | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* Every index's 1.36 keys (`KeyComposer.composeAllKeys`): the primary index's
|
|
71
|
+
* always, a GSI's when all its composites are present. A Z-order index is new
|
|
72
|
+
* in 1.37, so it has none.
|
|
73
|
+
*/
|
|
74
|
+
export declare const composeAllKeys: (schema: DynamoSchema.DynamoSchema, entityType: string, entityVersion: number, indexes: Record<string, IndexDefinition>, record: Record<string, unknown>) => Record<string, string>;
|
|
75
|
+
/**
|
|
76
|
+
* 1.36's sort key prefix from the leading sort key composites present in
|
|
77
|
+
* `record` (`KeyComposer.composeSortKeyPrefix`).
|
|
78
|
+
*/
|
|
79
|
+
export declare const composeSortKeyPrefix: (schema: DynamoSchema.DynamoSchema, entityType: string, entityVersion: number, index: IndexDefinition, record: Record<string, unknown>) => string;
|
|
80
|
+
/**
|
|
81
|
+
* 1.36's `begins_with` operand: {@link composeSortKeyPrefix}, with the key
|
|
82
|
+
* delimiter appended while composites remain unsupplied.
|
|
83
|
+
*/
|
|
84
|
+
export declare const composeSortKeyBeginsWith: (schema: DynamoSchema.DynamoSchema, entityType: string, entityVersion: number, index: IndexDefinition, record: Record<string, unknown>) => string;
|
|
85
|
+
/**
|
|
86
|
+
* The condition that selects, under 1.36's key text, the rows a query
|
|
87
|
+
* accessor's pins select (`KeyComposer.composeSortKeyCondition`): `eq` on the
|
|
88
|
+
* complete key, else `beginsWith` on the prefix and the delimiter.
|
|
89
|
+
*/
|
|
90
|
+
export declare const composeSortKeyCondition: (schema: DynamoSchema.DynamoSchema, entityType: string, entityVersion: number, index: IndexDefinition, record: Record<string, unknown>) => {
|
|
91
|
+
readonly eq: string;
|
|
92
|
+
} | {
|
|
93
|
+
readonly beginsWith: string;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* The condition that selects, under 1.36's key text, the rows an `eq` or
|
|
97
|
+
* `beginsWith` bound on sort key composite `field` selects, every composite
|
|
98
|
+
* before it pinned in `pinned` (`composeRangeUnder` in `DynamoClient.ts`):
|
|
99
|
+
* `eq` on the last composite is its key, on any other the value's subtree (the
|
|
100
|
+
* delimiter appended); a `beginsWith` is a prefix of the value's text, or `eq`
|
|
101
|
+
* for a number, which has no text prefix.
|
|
102
|
+
*/
|
|
103
|
+
export declare const composeBoundCondition: (schema: DynamoSchema.DynamoSchema, entityType: string, entityVersion: number, index: IndexDefinition, pinned: Record<string, unknown>, field: string, bound: {
|
|
104
|
+
readonly eq: unknown;
|
|
105
|
+
} | {
|
|
106
|
+
readonly beginsWith: unknown;
|
|
107
|
+
}) => {
|
|
108
|
+
readonly eq: string;
|
|
109
|
+
} | {
|
|
110
|
+
readonly beginsWith: string;
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* 1.36's time-series event sort key: `currentSk` (the current item's 1.36 sort
|
|
114
|
+
* key), the cased `e` infix and the orderBy attribute's ENCODED value — not
|
|
115
|
+
* its key form — through 1.36's {@link serializeValue}, cased.
|
|
116
|
+
*/
|
|
117
|
+
export declare const composeEventSk: (currentSk: string, encodedOrderBy: unknown, casing?: DynamoSchema.Casing) => string;
|
|
118
|
+
/** 1.36's unique-constraint sentinel key over the constraint's field values, in order. */
|
|
119
|
+
export declare const composeUniqueKey: (schema: DynamoSchema.DynamoSchema, entityType: string, constraintName: string, values: ReadonlyArray<unknown>) => {
|
|
120
|
+
readonly pk: string;
|
|
121
|
+
readonly sk: string;
|
|
122
|
+
};
|
|
123
|
+
/** 1.36's vector index partition value, or `undefined` when a composite is missing. */
|
|
124
|
+
export declare const tryComposeVectorPartition: (schema: DynamoSchema.DynamoSchema, entityType: string, index: {
|
|
125
|
+
readonly partition: ReadonlyArray<string>;
|
|
126
|
+
readonly casing?: DynamoSchema.Casing;
|
|
127
|
+
}, record: Record<string, unknown>) => string | undefined;
|
|
128
|
+
/**
|
|
129
|
+
* The 1.36 primary key of the item at `record` when the fallback is
|
|
130
|
+
* {@link enabled} and its text differs from `current` — the key 1.37
|
|
131
|
+
* composes — else `undefined`: the item can only be at `current`.
|
|
132
|
+
*/
|
|
133
|
+
export declare const changedPrimaryKey: (schema: DynamoSchema.DynamoSchema, entityType: string, entityVersion: number, primary: IndexDefinition, record: Record<string, unknown>, current: Readonly<Record<string, unknown>>) => Record<string, string> | undefined;
|
|
134
|
+
/** The JavaScript type a composite's key form takes (`CompositeCodec.keyFormValueKind`). */
|
|
135
|
+
export type ValueKind = "string" | "number" | "bigint" | "boolean" | undefined;
|
|
136
|
+
/**
|
|
137
|
+
* The key-form values 1.36 composed `stored` — a primary key `index` stores
|
|
138
|
+
* rows under — from, read back from its text, for a row that holds no values
|
|
139
|
+
* of its own (a projection's row tombstone or outbox item, which carry only
|
|
140
|
+
* the key they were written for). Each composite's text is what lies between
|
|
141
|
+
* the key's fixed parts (the prefix, labels and delimiters {@link
|
|
142
|
+
* composeIndexKeys} writes around it), turned back into a value by `kindOf`
|
|
143
|
+
* ({@link valueOf136}); a reading counts only when {@link composeIndexKeys}
|
|
144
|
+
* composes exactly `stored` from it. `undefined` unless exactly one reading
|
|
145
|
+
* does: none, when `stored` is not 1.36 text of any values (1.37 text of a
|
|
146
|
+
* changed number, say), and more than one when a string value holds the
|
|
147
|
+
* delimiter and the next composite's label.
|
|
148
|
+
*
|
|
149
|
+
* A string comes back cased, which composes the same key text, in 1.36 and
|
|
150
|
+
* 1.37 alike, as the value it was cased from.
|
|
151
|
+
*/
|
|
152
|
+
export declare const readIndexKeys: (schema: DynamoSchema.DynamoSchema, entityType: string, entityVersion: number, index: IndexDefinition, stored: Readonly<Record<string, unknown>>, kindOf: (attr: string) => ValueKind) => Record<string, unknown> | undefined;
|
|
153
|
+
//# sourceMappingURL=KeyText136.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KeyText136.d.ts","sourceRoot":"","sources":["../../src/internal/KeyText136.ts"],"names":[],"mappings":"AAAA;;;;;;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AM,GAAG,SAOX,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,YAAY,CAAC,YAAY,EACjC,YAAY,MAAM,EAClB,eAAe,MAAM,EACrB,SAAS,eAAe,EACxB,QAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,KACzC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAO3B,CAAA;AAED,4FAA4F;AAC5F,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAA;AAkC9E;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,aAAa,GACxB,QAAQ,YAAY,CAAC,YAAY,EACjC,YAAY,MAAM,EAClB,eAAe,MAAM,EACrB,OAAO,eAAe,EACtB,QAAQ,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,KAAK,SAAS,KAClC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAoD5B,CAAA"}
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* KeyText136 — the key text effect-dynamodb 1.36 composed (#171).
|
|
3
|
+
*
|
|
4
|
+
* 1.37 composes some key text differently, so a row 1.36 wrote with such a
|
|
5
|
+
* value sits under a key 1.37 does not compose:
|
|
6
|
+
*
|
|
7
|
+
* - **Numbers** (`serializeValue`): 1.36 zero-padded `String(n)` to 16
|
|
8
|
+
* characters (a bigint to 38), which kept non-negative integers below 1e16
|
|
9
|
+
* in order and nothing else; 1.37 encodes every number in numeric order
|
|
10
|
+
* (`NumericKey.ts`). The text of a non-negative integer below 1e16 (1e38 for
|
|
11
|
+
* a bigint) is unchanged.
|
|
12
|
+
* - **Sort key values** holding a code point U+0000–U+0025 — a control
|
|
13
|
+
* character, space, `!`, `"`, `#`, `$` or `%` — are escaped in 1.37
|
|
14
|
+
* (`KeyComposer.sortKeyText`) and were not in 1.36. Partition keys, unique
|
|
15
|
+
* sentinels and the structural parts of a key are not escaped.
|
|
16
|
+
* - **Time-series event keys** carried the orderBy attribute's ENCODED value
|
|
17
|
+
* (a `NumberFromString` `"10"` as the string `10`); 1.37 composes its key
|
|
18
|
+
* form (`0000000000000010`).
|
|
19
|
+
*
|
|
20
|
+
* Everything else — the key layout, casing, the history, sentinel, aggregate
|
|
21
|
+
* and EventStore key shapes — is unchanged, so these functions compose 1.36's
|
|
22
|
+
* bytes through the same `DynamoSchema` composers, fed 1.36's serialization.
|
|
23
|
+
* Z-order sort keys are new in 1.37 and have no 1.36 form: `composeAllKeys`
|
|
24
|
+
* leaves a Z-order index out.
|
|
25
|
+
*
|
|
26
|
+
* Every function takes the same key-form record its `KeyComposer` counterpart
|
|
27
|
+
* does. `test/KeyText136.test.ts` checks them against golden vectors the
|
|
28
|
+
* published 1.36.0 packages composed.
|
|
29
|
+
*
|
|
30
|
+
* The 1.37.x operations read and move rows still under their 1.36 keys while
|
|
31
|
+
* the fallback is {@link enabled}; the fallback and this module go in the next
|
|
32
|
+
* major release. Not part of the public API.
|
|
33
|
+
*/
|
|
34
|
+
import { DateTime } from "effect";
|
|
35
|
+
import * as DynamoSchema from "../DynamoSchema.js";
|
|
36
|
+
import { applyCasing, composeClusteredSortKey, composeCollectionKey, composeIsolatedSortKey, composeKey, KEY_DELIMITER, } from "../DynamoSchema.js";
|
|
37
|
+
import { effectiveCasing, isZOrderHalf } from "../KeyComposer.js";
|
|
38
|
+
/** Whether operations read and move rows under their 1.36 keys (`DynamoSchema.make`'s `legacyKeys`). */
|
|
39
|
+
export const enabled = (schema) => schema.legacyKeys !== false;
|
|
40
|
+
/** `%`: the highest code point 1.37 escapes in sort key text, and the first of every escape. */
|
|
41
|
+
const ESCAPE = 0x25;
|
|
42
|
+
/**
|
|
43
|
+
* Does sort key value text `text` hold a code point 1.37 escapes (U+0000–
|
|
44
|
+
* U+0025)? Then its key text differs from 1.36's — and holds an escape, which
|
|
45
|
+
* 1.36's text of another value can spell: `foo%20bar` is `foo bar`'s key now.
|
|
46
|
+
*/
|
|
47
|
+
export const holdsEscaped = (text) => {
|
|
48
|
+
for (let i = 0; i < text.length; i++) {
|
|
49
|
+
if (text.charCodeAt(i) <= ESCAPE)
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
return false;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* The first character of `text` below `%` (U+0000–U+0024), if any. Escaped
|
|
56
|
+
* text never holds one, nor does any text whose casing is escaped text, so a
|
|
57
|
+
* stored value holding it is not the 1.36 spelling of an escape.
|
|
58
|
+
*/
|
|
59
|
+
export const firstBelowEscape = (text) => {
|
|
60
|
+
for (let i = 0; i < text.length; i++) {
|
|
61
|
+
if (text.charCodeAt(i) < ESCAPE)
|
|
62
|
+
return text[i];
|
|
63
|
+
}
|
|
64
|
+
return undefined;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* 1.36's composite value text: a number zero-padded to 16 characters, a bigint
|
|
68
|
+
* to 38 — `String(n)` padded, so `-3` is `00000000000000-3` and `2.5` is
|
|
69
|
+
* `00000000000002.5` — a boolean as `true` / `false`, a date as its ISO
|
|
70
|
+
* string. Never throws: 1.36 composed `NaN` as `0000000000000NaN`.
|
|
71
|
+
*/
|
|
72
|
+
export const serializeValue = (value) => {
|
|
73
|
+
if (typeof value === "string")
|
|
74
|
+
return value;
|
|
75
|
+
if (typeof value === "number")
|
|
76
|
+
return String(value).padStart(16, "0");
|
|
77
|
+
if (typeof value === "bigint")
|
|
78
|
+
return String(value).padStart(38, "0");
|
|
79
|
+
if (typeof value === "boolean")
|
|
80
|
+
return value ? "true" : "false";
|
|
81
|
+
if (typeof value === "object" && value !== null && DateTime.isDateTime(value)) {
|
|
82
|
+
return DateTime.formatIso(value);
|
|
83
|
+
}
|
|
84
|
+
if (value instanceof Date)
|
|
85
|
+
return value.toISOString();
|
|
86
|
+
return String(value);
|
|
87
|
+
};
|
|
88
|
+
/** `KeyComposer.extractComposites` with 1.36's {@link serializeValue}. */
|
|
89
|
+
export const extractComposites = (composite, record) => composite.map((attr) => {
|
|
90
|
+
const value = record[attr];
|
|
91
|
+
if (value === undefined || value === null) {
|
|
92
|
+
throw new Error(`Missing composite attribute "${attr}" in record`);
|
|
93
|
+
}
|
|
94
|
+
return serializeValue(value);
|
|
95
|
+
});
|
|
96
|
+
/** {@link extractComposites}, or `undefined` when a composite is missing. */
|
|
97
|
+
export const tryExtractComposites = (composite, record) => composite.every((attr) => record[attr] !== undefined && record[attr] !== null)
|
|
98
|
+
? extractComposites(composite, record)
|
|
99
|
+
: undefined;
|
|
100
|
+
/** 1.36's partition key of `index` (`KeyComposer.composePk`). */
|
|
101
|
+
export const composePk = (schema, entityType, index, record) => {
|
|
102
|
+
const composites = extractComposites(index.pk.composite, record);
|
|
103
|
+
const names = [...index.pk.composite];
|
|
104
|
+
const collection = index.collection;
|
|
105
|
+
if (collection !== undefined) {
|
|
106
|
+
const collectionName = Array.isArray(collection) ? collection[0] : collection;
|
|
107
|
+
return composeCollectionKey(schema, collectionName, composites, { casing: index.casing, names });
|
|
108
|
+
}
|
|
109
|
+
return composeKey(schema, entityType, composites, { casing: index.casing, names });
|
|
110
|
+
};
|
|
111
|
+
/** The sort key text 1.36 composed from `composites` (unescaped values). */
|
|
112
|
+
const sortKeyOf = (schema, entityType, entityVersion, index, composites, names) => {
|
|
113
|
+
const collection = index.collection;
|
|
114
|
+
if (collection !== undefined) {
|
|
115
|
+
if ((index.type ?? "isolated") === "clustered") {
|
|
116
|
+
return composeClusteredSortKey(schema, collection, entityType, entityVersion, composites, {
|
|
117
|
+
casing: index.casing,
|
|
118
|
+
names,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
return composeIsolatedSortKey(schema, entityType, entityVersion, composites, {
|
|
122
|
+
casing: index.casing,
|
|
123
|
+
names,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return composeKey(schema, entityType, composites, { casing: index.casing, names });
|
|
127
|
+
};
|
|
128
|
+
/** 1.36's sort key of a string-keyed `index` (`KeyComposer.composeSk`), values unescaped. */
|
|
129
|
+
export const composeSk = (schema, entityType, entityVersion, index, record) => sortKeyOf(schema, entityType, entityVersion, index, extractComposites(index.sk.composite, record), index.sk.composite);
|
|
130
|
+
/** Both 1.36 keys of a string-keyed `index`. */
|
|
131
|
+
export const composeIndexKeys = (schema, entityType, entityVersion, index, record) => ({
|
|
132
|
+
[index.pk.field]: composePk(schema, entityType, index, record),
|
|
133
|
+
[index.sk.field]: composeSk(schema, entityType, entityVersion, index, record),
|
|
134
|
+
});
|
|
135
|
+
/** {@link composeIndexKeys}, or `undefined` when a composite is missing (a sparse index). */
|
|
136
|
+
export const tryComposeIndexKeys = (schema, entityType, entityVersion, index, record) => {
|
|
137
|
+
const present = (composite) => composite.every((attr) => record[attr] !== undefined && record[attr] !== null);
|
|
138
|
+
if (!present(index.pk.composite) || !present(index.sk.composite))
|
|
139
|
+
return undefined;
|
|
140
|
+
return composeIndexKeys(schema, entityType, entityVersion, index, record);
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* Every index's 1.36 keys (`KeyComposer.composeAllKeys`): the primary index's
|
|
144
|
+
* always, a GSI's when all its composites are present. A Z-order index is new
|
|
145
|
+
* in 1.37, so it has none.
|
|
146
|
+
*/
|
|
147
|
+
export const composeAllKeys = (schema, entityType, entityVersion, indexes, record) => {
|
|
148
|
+
const result = {};
|
|
149
|
+
for (const [indexName, index] of Object.entries(indexes)) {
|
|
150
|
+
if (isZOrderHalf(index.sk))
|
|
151
|
+
continue;
|
|
152
|
+
if (indexName === "primary") {
|
|
153
|
+
Object.assign(result, composeIndexKeys(schema, entityType, entityVersion, index, record));
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
const keys = tryComposeIndexKeys(schema, entityType, entityVersion, index, record);
|
|
157
|
+
if (keys !== undefined)
|
|
158
|
+
Object.assign(result, keys);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return result;
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* 1.36's sort key prefix from the leading sort key composites present in
|
|
165
|
+
* `record` (`KeyComposer.composeSortKeyPrefix`).
|
|
166
|
+
*/
|
|
167
|
+
export const composeSortKeyPrefix = (schema, entityType, entityVersion, index, record) => {
|
|
168
|
+
const names = [];
|
|
169
|
+
for (const attr of index.sk.composite) {
|
|
170
|
+
if (record[attr] === undefined || record[attr] === null)
|
|
171
|
+
break;
|
|
172
|
+
names.push(attr);
|
|
173
|
+
}
|
|
174
|
+
return sortKeyOf(schema, entityType, entityVersion, index, extractComposites(names, record), names);
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* 1.36's `begins_with` operand: {@link composeSortKeyPrefix}, with the key
|
|
178
|
+
* delimiter appended while composites remain unsupplied.
|
|
179
|
+
*/
|
|
180
|
+
export const composeSortKeyBeginsWith = (schema, entityType, entityVersion, index, record) => {
|
|
181
|
+
const prefix = composeSortKeyPrefix(schema, entityType, entityVersion, index, record);
|
|
182
|
+
const supplied = index.sk.composite.findIndex((attr) => record[attr] === undefined || record[attr] === null);
|
|
183
|
+
return supplied === -1 ? prefix : `${prefix}${KEY_DELIMITER}`;
|
|
184
|
+
};
|
|
185
|
+
/** How many leading sort key composites `record` holds. */
|
|
186
|
+
const leadingSupplied = (index, record) => {
|
|
187
|
+
const i = index.sk.composite.findIndex((attr) => record[attr] === undefined || record[attr] === null);
|
|
188
|
+
return i === -1 ? index.sk.composite.length : i;
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* The condition that selects, under 1.36's key text, the rows a query
|
|
192
|
+
* accessor's pins select (`KeyComposer.composeSortKeyCondition`): `eq` on the
|
|
193
|
+
* complete key, else `beginsWith` on the prefix and the delimiter.
|
|
194
|
+
*/
|
|
195
|
+
export const composeSortKeyCondition = (schema, entityType, entityVersion, index, record) => {
|
|
196
|
+
const prefix = composeSortKeyPrefix(schema, entityType, entityVersion, index, record);
|
|
197
|
+
return leadingSupplied(index, record) === index.sk.composite.length
|
|
198
|
+
? { eq: prefix }
|
|
199
|
+
: { beginsWith: `${prefix}${KEY_DELIMITER}` };
|
|
200
|
+
};
|
|
201
|
+
/**
|
|
202
|
+
* The condition that selects, under 1.36's key text, the rows an `eq` or
|
|
203
|
+
* `beginsWith` bound on sort key composite `field` selects, every composite
|
|
204
|
+
* before it pinned in `pinned` (`composeRangeUnder` in `DynamoClient.ts`):
|
|
205
|
+
* `eq` on the last composite is its key, on any other the value's subtree (the
|
|
206
|
+
* delimiter appended); a `beginsWith` is a prefix of the value's text, or `eq`
|
|
207
|
+
* for a number, which has no text prefix.
|
|
208
|
+
*/
|
|
209
|
+
export const composeBoundCondition = (schema, entityType, entityVersion, index, pinned, field, bound) => {
|
|
210
|
+
const casing = effectiveCasing(schema, index);
|
|
211
|
+
const prefix = composeSortKeyBeginsWith(schema, entityType, entityVersion, index, pinned);
|
|
212
|
+
const segment = (value) => `${prefix}${applyCasing(field, casing)}_${applyCasing(serializeValue(value), casing)}`;
|
|
213
|
+
if ("beginsWith" in bound) {
|
|
214
|
+
const operand = bound.beginsWith;
|
|
215
|
+
if (typeof operand !== "number" && typeof operand !== "bigint") {
|
|
216
|
+
return { beginsWith: segment(operand) };
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
const value = "eq" in bound ? bound.eq : bound.beginsWith;
|
|
220
|
+
const last = index.sk.composite.indexOf(field) === index.sk.composite.length - 1;
|
|
221
|
+
return last ? { eq: segment(value) } : { beginsWith: `${segment(value)}${KEY_DELIMITER}` };
|
|
222
|
+
};
|
|
223
|
+
/**
|
|
224
|
+
* 1.36's time-series event sort key: `currentSk` (the current item's 1.36 sort
|
|
225
|
+
* key), the cased `e` infix and the orderBy attribute's ENCODED value — not
|
|
226
|
+
* its key form — through 1.36's {@link serializeValue}, cased.
|
|
227
|
+
*/
|
|
228
|
+
export const composeEventSk = (currentSk, encodedOrderBy, casing = "lowercase") => `${currentSk}#${applyCasing("e", casing)}#${applyCasing(serializeValue(encodedOrderBy), casing)}`;
|
|
229
|
+
/** 1.36's unique-constraint sentinel key over the constraint's field values, in order. */
|
|
230
|
+
export const composeUniqueKey = (schema, entityType, constraintName, values) => DynamoSchema.composeUniqueKey(schema, entityType, constraintName, values.map(serializeValue));
|
|
231
|
+
/** 1.36's vector index partition value, or `undefined` when a composite is missing. */
|
|
232
|
+
export const tryComposeVectorPartition = (schema, entityType, index, record) => {
|
|
233
|
+
const composites = tryExtractComposites(index.partition, record);
|
|
234
|
+
if (composites === undefined)
|
|
235
|
+
return undefined;
|
|
236
|
+
return composeKey(schema, entityType, composites, {
|
|
237
|
+
casing: index.casing,
|
|
238
|
+
names: [...index.partition],
|
|
239
|
+
});
|
|
240
|
+
};
|
|
241
|
+
/**
|
|
242
|
+
* The 1.36 primary key of the item at `record` when the fallback is
|
|
243
|
+
* {@link enabled} and its text differs from `current` — the key 1.37
|
|
244
|
+
* composes — else `undefined`: the item can only be at `current`.
|
|
245
|
+
*/
|
|
246
|
+
export const changedPrimaryKey = (schema, entityType, entityVersion, primary, record, current) => {
|
|
247
|
+
if (!enabled(schema))
|
|
248
|
+
return undefined;
|
|
249
|
+
const keys = composeIndexKeys(schema, entityType, entityVersion, primary, record);
|
|
250
|
+
return keys[primary.pk.field] === current[primary.pk.field] &&
|
|
251
|
+
keys[primary.sk.field] === current[primary.sk.field]
|
|
252
|
+
? undefined
|
|
253
|
+
: keys;
|
|
254
|
+
};
|
|
255
|
+
/**
|
|
256
|
+
* A composite's 1.36 text back as the key-form value it was composed from:
|
|
257
|
+
* a number or bigint without the zeros {@link serializeValue} padded it with,
|
|
258
|
+
* a boolean from `true` / `false` in any casing, anything else as the (cased)
|
|
259
|
+
* text. `undefined` when the text is no bigint or boolean; text that is no
|
|
260
|
+
* number reads as `NaN`, which composes only `NaN`'s text.
|
|
261
|
+
*/
|
|
262
|
+
const valueOf136 = (text, kind) => {
|
|
263
|
+
if (kind === "number" || kind === "bigint") {
|
|
264
|
+
const digits = text.replace(/^0+/, "");
|
|
265
|
+
const unpadded = digits === "" ? "0" : digits.startsWith(".") ? `0${digits}` : digits;
|
|
266
|
+
// Casing may have changed `Infinity`'s letters, which `Number` reads in one spelling.
|
|
267
|
+
if (kind === "number")
|
|
268
|
+
return Number(unpadded.replace(/^(-?)infinity$/i, "$1Infinity"));
|
|
269
|
+
try {
|
|
270
|
+
return BigInt(unpadded);
|
|
271
|
+
}
|
|
272
|
+
catch {
|
|
273
|
+
return undefined;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
if (kind === "boolean") {
|
|
277
|
+
const lower = text.toLowerCase();
|
|
278
|
+
return lower === "true" ? true : lower === "false" ? false : undefined;
|
|
279
|
+
}
|
|
280
|
+
return text;
|
|
281
|
+
};
|
|
282
|
+
/** How many readings of one key {@link readIndexKeys} tries before it gives up on it. */
|
|
283
|
+
const MAX_READINGS = 8;
|
|
284
|
+
/** Placeholder `i` in a key template: no casing changes it, and no prefix or label holds it. */
|
|
285
|
+
const placeholder = (i) => `\u0000${i}\u0000`;
|
|
286
|
+
/**
|
|
287
|
+
* The key-form values 1.36 composed `stored` — a primary key `index` stores
|
|
288
|
+
* rows under — from, read back from its text, for a row that holds no values
|
|
289
|
+
* of its own (a projection's row tombstone or outbox item, which carry only
|
|
290
|
+
* the key they were written for). Each composite's text is what lies between
|
|
291
|
+
* the key's fixed parts (the prefix, labels and delimiters {@link
|
|
292
|
+
* composeIndexKeys} writes around it), turned back into a value by `kindOf`
|
|
293
|
+
* ({@link valueOf136}); a reading counts only when {@link composeIndexKeys}
|
|
294
|
+
* composes exactly `stored` from it. `undefined` unless exactly one reading
|
|
295
|
+
* does: none, when `stored` is not 1.36 text of any values (1.37 text of a
|
|
296
|
+
* changed number, say), and more than one when a string value holds the
|
|
297
|
+
* delimiter and the next composite's label.
|
|
298
|
+
*
|
|
299
|
+
* A string comes back cased, which composes the same key text, in 1.36 and
|
|
300
|
+
* 1.37 alike, as the value it was cased from.
|
|
301
|
+
*/
|
|
302
|
+
export const readIndexKeys = (schema, entityType, entityVersion, index, stored, kindOf) => {
|
|
303
|
+
const attrs = [...new Set([...index.pk.composite, ...index.sk.composite])];
|
|
304
|
+
const template = composeIndexKeys(schema, entityType, entityVersion, index, Object.fromEntries(attrs.map((attr, i) => [attr, placeholder(i)])));
|
|
305
|
+
/** Every way `text` splits into `template`'s parts: each composite's text, by attribute. */
|
|
306
|
+
const readings = (text, layout) => {
|
|
307
|
+
// Fixed text and slot numbers alternate: `placeholder` brackets each number.
|
|
308
|
+
const parts = layout.split("\u0000");
|
|
309
|
+
const found = [];
|
|
310
|
+
const walk = (at, part, taken) => {
|
|
311
|
+
if (found.length >= MAX_READINGS)
|
|
312
|
+
return;
|
|
313
|
+
const slot = Number(parts[part]);
|
|
314
|
+
const after = parts[part + 1];
|
|
315
|
+
if (part + 2 === parts.length) {
|
|
316
|
+
if (!text.endsWith(after) || text.length - after.length < at)
|
|
317
|
+
return;
|
|
318
|
+
found.push(new Map(taken).set(slot, text.slice(at, text.length - after.length)));
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
for (let end = text.indexOf(after, at); end !== -1; end = text.indexOf(after, end + 1)) {
|
|
322
|
+
walk(end + after.length, part + 2, new Map(taken).set(slot, text.slice(at, end)));
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
if (!text.startsWith(parts[0]))
|
|
326
|
+
return [];
|
|
327
|
+
if (parts.length === 1)
|
|
328
|
+
return text === parts[0] ? [new Map()] : [];
|
|
329
|
+
walk(parts[0].length, 1, new Map());
|
|
330
|
+
return found;
|
|
331
|
+
};
|
|
332
|
+
const pk = stored[index.pk.field];
|
|
333
|
+
const sk = stored[index.sk.field];
|
|
334
|
+
if (typeof pk !== "string" || typeof sk !== "string")
|
|
335
|
+
return undefined;
|
|
336
|
+
const fits = [];
|
|
337
|
+
for (const fromPk of readings(pk, template[index.pk.field])) {
|
|
338
|
+
for (const fromSk of readings(sk, template[index.sk.field])) {
|
|
339
|
+
const record = {};
|
|
340
|
+
let consistent = true;
|
|
341
|
+
for (const [slot, text] of [...fromPk, ...fromSk]) {
|
|
342
|
+
const attr = attrs[slot];
|
|
343
|
+
const value = valueOf136(text, kindOf(attr));
|
|
344
|
+
if (value === undefined || (attr in record && record[attr] !== value))
|
|
345
|
+
consistent = false;
|
|
346
|
+
record[attr] = value;
|
|
347
|
+
}
|
|
348
|
+
if (!consistent)
|
|
349
|
+
continue;
|
|
350
|
+
const keys = composeIndexKeys(schema, entityType, entityVersion, index, record);
|
|
351
|
+
if (keys[index.pk.field] === pk && keys[index.sk.field] === sk)
|
|
352
|
+
fits.push(record);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
return fits.length === 1 ? fits[0] : undefined;
|
|
356
|
+
};
|
|
357
|
+
//# sourceMappingURL=KeyText136.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KeyText136.js","sourceRoot":"","sources":["../../src/internal/KeyText136.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AACjC,OAAO,KAAK,YAAY,MAAM,oBAAoB,CAAA;AAClD,OAAO,EACL,WAAW,EACX,uBAAuB,EACvB,oBAAoB,EACpB,sBAAsB,EACtB,UAAU,EACV,aAAa,GACd,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,eAAe,EAAwB,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEvF,wGAAwG;AACxG,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,MAAiC,EAAW,EAAE,CAAC,MAAM,CAAC,UAAU,KAAK,KAAK,CAAA;AAElG,gGAAgG;AAChG,MAAM,MAAM,GAAG,IAAI,CAAA;AAEnB;;;;GAIG;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,GAAG,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;gBAC5C,IAAI,KAAK,KAAK,SAAS,IAAI,CAAC,IAAI,IAAI,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC;oBAAE,UAAU,GAAG,KAAK,CAAA;gBACzF,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAA;YACtB,CAAC;YACD,IAAI,CAAC,UAAU;gBAAE,SAAQ;YACzB,MAAM,IAAI,GAAG,gBAAgB,CAAC,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;YAC/E,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE;gBAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACnF,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;AAChD,CAAC,CAAA"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal NumericKey — the key text of a `number` or `bigint` composite.
|
|
3
|
+
*
|
|
4
|
+
* DynamoDB compares sort keys as UTF-8 bytes, so the text must sort in numeric
|
|
5
|
+
* order. Up to 1.36 it was `String(n).padStart(16, "0")` (38 for a bigint),
|
|
6
|
+
* which only sorts non-negative integers below the pad width: `-3` came above
|
|
7
|
+
* `-5`, `10.5` below `3.14`, `1e-7` above `3`, and `1e+21` below `1e16`.
|
|
8
|
+
*
|
|
9
|
+
* `x` is a magnitude `|n|`; `W` is 16 for a number and 38 for a bigint.
|
|
10
|
+
*
|
|
11
|
+
* | value | text | e.g. |
|
|
12
|
+
* |---|---|---|
|
|
13
|
+
* | `0` (and `-0`), integer `x < 10^W` | `pad_W(x)` — the 1.36 bytes | `0000000000000042` |
|
|
14
|
+
* | non-integer `x < 10^W` | `pad_W(int) "." frac` | `0000000000000003.14` |
|
|
15
|
+
* | `x ≥ 10^W` | `":" eee digits` | `:0161` (1e16), `:02112345` (1.2345e21) |
|
|
16
|
+
* | negative, `x < 10^W` | `"-" ~pad_W(int) ["." ~frac] ":"` | `-9999999999999996.85:` (-3.14) |
|
|
17
|
+
* | negative, `x ≥ 10^W` | `"-*" ~eee ~digits ":"` | `-*9838:` (-1e16) |
|
|
18
|
+
* | `Infinity` / `-Infinity` | `";"` / `"-)"` | |
|
|
19
|
+
*
|
|
20
|
+
* `frac` is the fraction digits of the number's shortest round-trip decimal
|
|
21
|
+
* (`String(n)`, written out without an exponent), so `0.1` is `.1`, not the
|
|
22
|
+
* binary value's 55 digits; distinct doubles keep distinct, ordered decimals.
|
|
23
|
+
* `eee` is the 3-digit decimal exponent and `digits` the significant digits
|
|
24
|
+
* without trailing zeros. `~` is the 9's complement of each digit (`.` kept).
|
|
25
|
+
*
|
|
26
|
+
* Why it sorts: within one form, equal-width digit strings compare digit by
|
|
27
|
+
* digit, and a shorter fraction is a prefix of the longer (`3` < `3.14`, since
|
|
28
|
+
* the composed key continues with `#` or ends, both below `.`). Across forms
|
|
29
|
+
* the leading byte decides: `-` < digits < `:` < `;`, and under `-`,
|
|
30
|
+
* `)` < `*` < digits. Negatives complement the magnitude, which reverses its
|
|
31
|
+
* order, and end in `:` (above every digit and `.`) so that, of two negatives
|
|
32
|
+
* where one magnitude's text is a prefix of the other's (`3` and `3.1`), the
|
|
33
|
+
* shorter — the larger value — sorts last.
|
|
34
|
+
*
|
|
35
|
+
* Every byte is above the key delimiter `#` and none is a letter, so casing
|
|
36
|
+
* never changes the text and a composite's text is never cut by `#`.
|
|
37
|
+
*
|
|
38
|
+
* `NaN` has no order and is refused (`[EDD-9096]`, {@link KeyValueError}), as
|
|
39
|
+
* is a bigint of more than 1,000 digits (past the 3-digit exponent).
|
|
40
|
+
*
|
|
41
|
+
* Not part of the public API.
|
|
42
|
+
*/
|
|
43
|
+
declare const KeyValueError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
44
|
+
readonly _tag: "KeyValueError";
|
|
45
|
+
} & Readonly<A>;
|
|
46
|
+
/**
|
|
47
|
+
* A value key composition can't place in sort order: `NaN`, or a bigint of
|
|
48
|
+
* more than 1,000 digits. Thrown synchronously by `serializeValue`; the write
|
|
49
|
+
* paths turn it into a `ValidationError`.
|
|
50
|
+
*/
|
|
51
|
+
export declare class KeyValueError extends KeyValueError_base<{
|
|
52
|
+
readonly value: unknown;
|
|
53
|
+
readonly reason: string;
|
|
54
|
+
/** Human-readable description, prefixed with `EDD-9096`. */
|
|
55
|
+
readonly message: string;
|
|
56
|
+
}> {
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Is `u` a {@link KeyValueError}? By its tag, not `instanceof`: two copies of
|
|
60
|
+
* this package (a consumer's and `effect-dynamodb`'s) still agree.
|
|
61
|
+
*/
|
|
62
|
+
export declare const isKeyValueError: (u: unknown) => u is KeyValueError;
|
|
63
|
+
/** The key text of a `number`. Throws {@link KeyValueError} (`[EDD-9096]`) for `NaN`. */
|
|
64
|
+
export declare const encodeNumber: (n: number) => string;
|
|
65
|
+
/**
|
|
66
|
+
* The key text of a `bigint`. Throws {@link KeyValueError} (`[EDD-9096]`) past
|
|
67
|
+
* 1,000 digits.
|
|
68
|
+
*/
|
|
69
|
+
export declare const encodeBigInt: (n: bigint) => string;
|
|
70
|
+
export {};
|
|
71
|
+
//# sourceMappingURL=NumericKey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NumericKey.d.ts","sourceRoot":"","sources":["../../src/internal/NumericKey.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;;;;AAIH;;;;GAIG;AACH,qBAAa,aAAc,SAAQ,mBAAkC;IACnE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,4DAA4D;IAC5D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB,CAAC;CAAG;AAEL;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,aACV,CAAA;AAuDxC,yFAAyF;AACzF,eAAO,MAAM,YAAY,GAAI,GAAG,MAAM,KAAG,MAQxC,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,GAAI,GAAG,MAAM,KAAG,MAQxC,CAAA"}
|