effect-dynamodb 1.24.0 → 1.26.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 +12 -2
- package/dist/Aggregate.d.ts.map +1 -1
- package/dist/Aggregate.js +284 -55
- package/dist/Aggregate.js.map +1 -1
- package/dist/Batch.d.ts +14 -5
- package/dist/Batch.d.ts.map +1 -1
- package/dist/Batch.js +184 -119
- package/dist/Batch.js.map +1 -1
- package/dist/Collection.d.ts +9 -1
- package/dist/Collection.d.ts.map +1 -1
- package/dist/Collection.js +5 -4
- package/dist/Collection.js.map +1 -1
- package/dist/DynamoClient.d.ts +80 -28
- package/dist/DynamoClient.d.ts.map +1 -1
- package/dist/DynamoClient.js +125 -25
- package/dist/DynamoClient.js.map +1 -1
- package/dist/Entity.d.ts +99 -40
- package/dist/Entity.d.ts.map +1 -1
- package/dist/Entity.js +693 -302
- package/dist/Entity.js.map +1 -1
- package/dist/EventStore.d.ts +598 -75
- package/dist/EventStore.d.ts.map +1 -1
- package/dist/EventStore.js +852 -221
- package/dist/EventStore.js.map +1 -1
- package/dist/Query.d.ts +100 -14
- package/dist/Query.d.ts.map +1 -1
- package/dist/Query.js +275 -71
- package/dist/Query.js.map +1 -1
- package/dist/StorageEncoding.d.ts +160 -0
- package/dist/StorageEncoding.d.ts.map +1 -0
- package/dist/StorageEncoding.js +258 -0
- package/dist/StorageEncoding.js.map +1 -0
- package/dist/Table.d.ts +56 -6
- package/dist/Table.d.ts.map +1 -1
- package/dist/Table.js +142 -60
- package/dist/Table.js.map +1 -1
- package/dist/Transaction.d.ts +8 -0
- package/dist/Transaction.d.ts.map +1 -1
- package/dist/Transaction.js +72 -22
- package/dist/Transaction.js.map +1 -1
- package/dist/VectorSearchEmulation.d.ts +3 -2
- package/dist/VectorSearchEmulation.d.ts.map +1 -1
- package/dist/VectorSearchEmulation.js +14 -2
- package/dist/VectorSearchEmulation.js.map +1 -1
- package/dist/compression/zlib.d.ts +75 -0
- package/dist/compression/zlib.d.ts.map +1 -0
- package/dist/compression/zlib.js +109 -0
- package/dist/compression/zlib.js.map +1 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/BoundCrud.d.ts +39 -35
- package/dist/internal/BoundCrud.d.ts.map +1 -1
- package/dist/internal/BoundCrud.js.map +1 -1
- package/dist/internal/BoundQuery.d.ts +6 -5
- package/dist/internal/BoundQuery.d.ts.map +1 -1
- package/dist/internal/BoundQuery.js.map +1 -1
- package/dist/internal/BoundVectorQuery.d.ts +17 -1
- package/dist/internal/BoundVectorQuery.d.ts.map +1 -1
- package/dist/internal/BoundVectorQuery.js +31 -6
- package/dist/internal/BoundVectorQuery.js.map +1 -1
- package/dist/internal/EntityCombinators.d.ts +8 -5
- package/dist/internal/EntityCombinators.d.ts.map +1 -1
- package/dist/internal/EntityCombinators.js +24 -6
- package/dist/internal/EntityCombinators.js.map +1 -1
- package/dist/internal/EntityOps.d.ts +1 -1
- package/dist/internal/Expr.d.ts +9 -3
- package/dist/internal/Expr.d.ts.map +1 -1
- package/dist/internal/Expr.js +7 -5
- package/dist/internal/Expr.js.map +1 -1
- package/dist/internal/ExpressionLimits.d.ts +45 -0
- package/dist/internal/ExpressionLimits.d.ts.map +1 -0
- package/dist/internal/ExpressionLimits.js +89 -0
- package/dist/internal/ExpressionLimits.js.map +1 -0
- package/dist/internal/Hydrate.d.ts +62 -0
- package/dist/internal/Hydrate.d.ts.map +1 -0
- package/dist/internal/Hydrate.js +191 -0
- package/dist/internal/Hydrate.js.map +1 -0
- package/dist/internal/ItemSize.d.ts +60 -24
- package/dist/internal/ItemSize.d.ts.map +1 -1
- package/dist/internal/ItemSize.js +122 -39
- package/dist/internal/ItemSize.js.map +1 -1
- package/dist/internal/Packed.d.ts +289 -0
- package/dist/internal/Packed.d.ts.map +1 -0
- package/dist/internal/Packed.js +654 -0
- package/dist/internal/Packed.js.map +1 -0
- package/dist/internal/PathBuilder.d.ts +45 -2
- package/dist/internal/PathBuilder.d.ts.map +1 -1
- package/dist/internal/PathBuilder.js +4 -0
- package/dist/internal/PathBuilder.js.map +1 -1
- package/dist/internal/TransactWriteOps.d.ts +22 -46
- package/dist/internal/TransactWriteOps.d.ts.map +1 -1
- package/dist/internal/TransactWriteOps.js +26 -95
- package/dist/internal/TransactWriteOps.js.map +1 -1
- package/dist/internal/TransactableOps.d.ts +1 -1
- package/dist/internal/TransactableOps.d.ts.map +1 -1
- package/dist/internal/TransactableOps.js +2 -0
- package/dist/internal/TransactableOps.js.map +1 -1
- package/dist/internal/WriteDiagnosis.d.ts +353 -0
- package/dist/internal/WriteDiagnosis.d.ts.map +1 -0
- package/dist/internal/WriteDiagnosis.js +1028 -0
- package/dist/internal/WriteDiagnosis.js.map +1 -0
- package/dist/internal/sparse_check.js +43 -79
- package/dist/internal/sparse_check.js.map +1 -1
- package/package.json +6 -2
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal Packed storage at the Marshaller boundary — item-level pack/unpack
|
|
3
|
+
* over the pure codec (`@effect-dynamodb/schema/internal/PackedCodec`), the
|
|
4
|
+
* compressor registry in scope, and DynamoDB Streams image normalisation.
|
|
5
|
+
*
|
|
6
|
+
* Where it runs:
|
|
7
|
+
*
|
|
8
|
+
* - **Write:** after the schema encode, field renames and sparse flattening,
|
|
9
|
+
* before `toAttributeMap` — {@link packItem} replaces each packed attribute's
|
|
10
|
+
* wire value with the JS value that marshals to its stored form (`string` →
|
|
11
|
+
* `S`, `Uint8Array` → `B`, `null` → `NULL`). Everything measured afterwards
|
|
12
|
+
* (item-size diagnosis, `Batch.write` chunking) therefore sees stored bytes.
|
|
13
|
+
* - **Read:** after `fromAttributeMap`, before sparse rebuild and renames —
|
|
14
|
+
* {@link unpackItem} dispatches each dispatch-eligible attribute on its
|
|
15
|
+
* stored form (native → unchanged, `S` → JSON, `B` → header + payload).
|
|
16
|
+
* - **Streams:** {@link normalizeImage} turns a Streams image (DynamoDB JSON,
|
|
17
|
+
* `B`/`BS` as bytes or base64, or an already-unmarshalled item) into an
|
|
18
|
+
* unmarshalled item with real bytes, and {@link unpackImageItem} additionally
|
|
19
|
+
* reads base64 text on a dispatch-eligible attribute as `B`.
|
|
20
|
+
*
|
|
21
|
+
* The registry is read from the fiber's context (as `Effect.serviceOption`
|
|
22
|
+
* would), so nothing here adds a requirement; an absent service is the empty
|
|
23
|
+
* registry. Every per-value step is synchronous — a plain function returning
|
|
24
|
+
* its result or the `ValidationError` it fails with — and is lifted into an
|
|
25
|
+
* Effect once per item (or per operation), not once per value: a read of
|
|
26
|
+
* thousands of rows pays for `JSON.parse` / decompression, not for Effect
|
|
27
|
+
* plumbing around each value.
|
|
28
|
+
*/
|
|
29
|
+
import type { AttributeValue } from "@aws-sdk/client-dynamodb";
|
|
30
|
+
import { type CompressionRegistry } from "@effect-dynamodb/schema/Compression.js";
|
|
31
|
+
import type { CompressionCodec, PackedConfig } from "@effect-dynamodb/schema/DynamoModel.js";
|
|
32
|
+
import { ValidationError } from "@effect-dynamodb/schema/Errors.js";
|
|
33
|
+
import { type OperationContext, type PackedContext, type PackedStored } from "@effect-dynamodb/schema/internal/PackedCodec.js";
|
|
34
|
+
import { Context, Effect } from "effect";
|
|
35
|
+
import type { QueryRawRow } from "../Query.js";
|
|
36
|
+
import type { Expr } from "./Expr.js";
|
|
37
|
+
export type { PackedContext, PackedStored } from "@effect-dynamodb/schema/internal/PackedCodec.js";
|
|
38
|
+
/** Who is packing/unpacking an item; the attribute is named per value only on failure. */
|
|
39
|
+
export type ItemContext = OperationContext;
|
|
40
|
+
/** The compressor registry in a context — the empty registry when none is provided. */
|
|
41
|
+
export declare const registryOf: (context: Context.Context<never>) => CompressionRegistry;
|
|
42
|
+
/** The compressor registry in scope — the empty registry when none is provided. */
|
|
43
|
+
export declare const currentRegistry: Effect.Effect<CompressionRegistry>;
|
|
44
|
+
/**
|
|
45
|
+
* Run a synchronous pack/unpack step with the registry in scope, as ONE
|
|
46
|
+
* Effect: `step` returns its result, or the `ValidationError` it fails with.
|
|
47
|
+
* (`step` must never succeed with a `ValidationError` value — none of the
|
|
48
|
+
* steps here can: they return parsed JSON, stored values or `undefined`.)
|
|
49
|
+
*/
|
|
50
|
+
export declare const withRegistry: <A>(step: (registry: CompressionRegistry) => A | ValidationError) => Effect.Effect<A, ValidationError>;
|
|
51
|
+
/** Lift a synchronous step's result (or the `ValidationError` it returned) into an Effect. */
|
|
52
|
+
export declare const fromStep: <A>(result: A | ValidationError) => Effect.Effect<A, ValidationError>;
|
|
53
|
+
/** A codec a store's packed config names — every reader and writer of it needs it registered. */
|
|
54
|
+
export interface CodecRequirement {
|
|
55
|
+
/** Who configures it, for the message — e.g. `entity "Orders"`. */
|
|
56
|
+
readonly owner: string;
|
|
57
|
+
/** The stored attribute. */
|
|
58
|
+
readonly attribute: string;
|
|
59
|
+
readonly codec: CompressionCodec;
|
|
60
|
+
}
|
|
61
|
+
/** The codecs `configs` (stored attribute → packed config) name. */
|
|
62
|
+
export declare const codecRequirements: (owner: string, configs: Iterable<readonly [attribute: string, config: PackedConfig | undefined]>) => Array<CodecRequirement>;
|
|
63
|
+
/**
|
|
64
|
+
* The `[EDD-9078]` configuration error for `requirements` the registry in scope
|
|
65
|
+
* (`undefined`: none) cannot meet, or `undefined` when it meets them all.
|
|
66
|
+
* `where` names the binding — `DynamoClient.make`, `EventStore.bind`, ….
|
|
67
|
+
*/
|
|
68
|
+
export declare const unregisteredCodecError: (where: string, requirements: ReadonlyArray<CodecRequirement>, registry: CompressionRegistry | undefined) => Error | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* A once-per-registry check of `requirements` for code that resolves its
|
|
71
|
+
* registry at run time (an unbound `EventStream`): the first operation run
|
|
72
|
+
* with a given registry checks it; later ones cost a `WeakSet` lookup. Dies
|
|
73
|
+
* with the `[EDD-9078]` error — a configuration defect, not a typed failure.
|
|
74
|
+
* `undefined` when nothing names a codec.
|
|
75
|
+
*/
|
|
76
|
+
export declare const runtimeCodecCheck: (where: string, requirements: ReadonlyArray<CodecRequirement>) => Effect.Effect<void> | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* Pack, in place, every attribute of `item` (keyed by **stored** name) that
|
|
79
|
+
* `packed` configures. An attribute the item does not carry is left absent; a
|
|
80
|
+
* wire value of `undefined` removes it. Returns the `ValidationError` of the
|
|
81
|
+
* first attribute that fails (the item is then partly packed — discard it), or
|
|
82
|
+
* `undefined`.
|
|
83
|
+
*/
|
|
84
|
+
export declare const packItemSync: (item: Record<string, unknown>, packed: Readonly<Record<string, PackedConfig>>, registry: CompressionRegistry, ctx: ItemContext) => ValidationError | undefined;
|
|
85
|
+
/** {@link packItemSync} as an Effect. */
|
|
86
|
+
export declare const packItem: (item: Record<string, unknown>, packed: Readonly<Record<string, PackedConfig>>, registry: CompressionRegistry, ctx: ItemContext) => Effect.Effect<void, ValidationError>;
|
|
87
|
+
/** The `AttributeValue` a packed stored value marshals to (`undefined`: no attribute). */
|
|
88
|
+
export declare const storedToAttributeValue: (stored: PackedStored) => AttributeValue | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* Pack one wire value straight to its `AttributeValue` — for an `UpdateItem`
|
|
91
|
+
* `SET #f = :v`, where the value never passes through `toAttributeMap`.
|
|
92
|
+
*/
|
|
93
|
+
export declare const packAttributeValue: (config: PackedConfig, wire: unknown, registry: CompressionRegistry, ctx: PackedContext) => Effect.Effect<AttributeValue | undefined, ValidationError>;
|
|
94
|
+
/** {@link packAttributeValue} without an Effect: the value, or the failure (returned). */
|
|
95
|
+
export declare const packAttributeValueSync: (config: PackedConfig, wire: unknown, registry: CompressionRegistry, ctx: ItemContext, attribute: string) => AttributeValue | undefined | ValidationError;
|
|
96
|
+
/**
|
|
97
|
+
* True iff any listed attribute of `raw` holds a string or bytes — a value
|
|
98
|
+
* read by its stored form. A native row (maps, lists, absent) is false, and
|
|
99
|
+
* costs one `typeof` per attribute.
|
|
100
|
+
*/
|
|
101
|
+
export declare const hasStoredForm: (raw: Record<string, unknown>, attributes: ReadonlyArray<string>) => boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Unpack, in place, every listed attribute of an unmarshalled item (keyed by
|
|
104
|
+
* **stored** name) by its stored form. Native values cost one `typeof` check.
|
|
105
|
+
* Returns the `ValidationError` of the first value that fails, or `undefined`.
|
|
106
|
+
*/
|
|
107
|
+
export declare const unpackItemSync: (raw: Record<string, unknown>, attributes: Iterable<string>, registry: CompressionRegistry, ctx: ItemContext) => ValidationError | undefined;
|
|
108
|
+
/** {@link unpackItemSync} as an Effect. */
|
|
109
|
+
export declare const unpackItem: (raw: Record<string, unknown>, attributes: Iterable<string>, registry: CompressionRegistry, ctx: ItemContext) => Effect.Effect<void, ValidationError>;
|
|
110
|
+
/**
|
|
111
|
+
* {@link unpackItemSync} with the registry in scope, as one Effect — and no
|
|
112
|
+
* registry lookup at all for a row with nothing stored packed.
|
|
113
|
+
*/
|
|
114
|
+
export declare const unpackRow: (raw: Record<string, unknown>, attributes: ReadonlyArray<string>, ctx: ItemContext) => Effect.Effect<void, ValidationError>;
|
|
115
|
+
/**
|
|
116
|
+
* An `AttributeValue` as DynamoDB Streams delivers it through Lambda or
|
|
117
|
+
* EventBridge Pipes: DynamoDB JSON whose `B` / `BS` members are base64 text.
|
|
118
|
+
*/
|
|
119
|
+
export type LambdaAttributeValue = {
|
|
120
|
+
readonly S: string;
|
|
121
|
+
} | {
|
|
122
|
+
readonly N: string;
|
|
123
|
+
} | {
|
|
124
|
+
readonly B: string | Uint8Array;
|
|
125
|
+
} | {
|
|
126
|
+
readonly BOOL: boolean;
|
|
127
|
+
} | {
|
|
128
|
+
readonly NULL: boolean;
|
|
129
|
+
} | {
|
|
130
|
+
readonly SS: ReadonlyArray<string>;
|
|
131
|
+
} | {
|
|
132
|
+
readonly NS: ReadonlyArray<string>;
|
|
133
|
+
} | {
|
|
134
|
+
readonly BS: ReadonlyArray<string | Uint8Array>;
|
|
135
|
+
} | {
|
|
136
|
+
readonly M: Readonly<Record<string, LambdaAttributeValue>>;
|
|
137
|
+
} | {
|
|
138
|
+
readonly L: ReadonlyArray<LambdaAttributeValue>;
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* A DynamoDB Streams image: DynamoDB JSON (`B`/`BS` as bytes or base64 text) or
|
|
142
|
+
* an already-unmarshalled item.
|
|
143
|
+
*/
|
|
144
|
+
export type StreamImage = Readonly<Record<string, AttributeValue | LambdaAttributeValue>> | Readonly<Record<string, unknown>>;
|
|
145
|
+
/** True iff `value` is shaped like one DynamoDB JSON `AttributeValue` (one known tag key). */
|
|
146
|
+
export declare const isAttributeValueShape: (value: unknown) => boolean;
|
|
147
|
+
/**
|
|
148
|
+
* True iff `image` is DynamoDB JSON rather than an unmarshalled item: its
|
|
149
|
+
* `probe` attribute (default `"pk"`, a string key attribute on every item the
|
|
150
|
+
* library writes) is an object with a string `S` member — or, without that
|
|
151
|
+
* attribute, every value is shaped like an `AttributeValue`.
|
|
152
|
+
*/
|
|
153
|
+
export declare const isAttributeValueImage: (image: StreamImage, probe?: string) => boolean;
|
|
154
|
+
/**
|
|
155
|
+
* The entity type (`__edd_e__`) a stream image names, read straight off the
|
|
156
|
+
* image — `{ S }` in DynamoDB JSON, a string when unmarshalled — so a decoder
|
|
157
|
+
* can turn away an image of another type **before** unmarshalling it: an
|
|
158
|
+
* attribute the SDK cannot unmarshall (a number beyond what it represents,
|
|
159
|
+
* say) in some other entity's image must not fail the decode of a batch.
|
|
160
|
+
* `undefined` when the image names none.
|
|
161
|
+
*/
|
|
162
|
+
export declare const imageEntityType: (image: StreamImage) => string | undefined;
|
|
163
|
+
/** How {@link normalizeImage} reads an image. */
|
|
164
|
+
export interface ImageOptions {
|
|
165
|
+
/** The attribute {@link isAttributeValueImage} probes (default `"pk"`). */
|
|
166
|
+
readonly probe?: string | undefined;
|
|
167
|
+
/** Skip detection: the image is known to be DynamoDB JSON, or unmarshalled. */
|
|
168
|
+
readonly form?: "attributeValues" | "unmarshalled" | undefined;
|
|
169
|
+
}
|
|
170
|
+
/** The form of `image` — `options.form`, or detected (see {@link isAttributeValueImage}). */
|
|
171
|
+
export declare const imageForm: (image: StreamImage, options?: ImageOptions) => "attributeValues" | "unmarshalled";
|
|
172
|
+
/**
|
|
173
|
+
* {@link normalizeImage} without an Effect: the unmarshalled item, or the
|
|
174
|
+
* `ValidationError` it fails with (returned, never thrown).
|
|
175
|
+
*/
|
|
176
|
+
export declare const normalizeImageSync: (image: StreamImage, ctx: ItemContext, options?: ImageOptions) => Record<string, unknown> | ValidationError;
|
|
177
|
+
/**
|
|
178
|
+
* Normalise a DynamoDB Streams image to an unmarshalled item.
|
|
179
|
+
*
|
|
180
|
+
* - DynamoDB JSON (see {@link isAttributeValueImage}): `B` / `BS` members given
|
|
181
|
+
* as base64 text are decoded at any depth (Lambda and EventBridge Pipes
|
|
182
|
+
* deliver them that way; `unmarshall` does not decode them), then the image is
|
|
183
|
+
* unmarshalled.
|
|
184
|
+
* - Already unmarshalled: returned as a shallow copy. A packed attribute's `B`
|
|
185
|
+
* may still be base64 text there — {@link unpackImageItem} handles it.
|
|
186
|
+
*/
|
|
187
|
+
export declare const normalizeImage: (image: StreamImage, ctx: ItemContext, options?: ImageOptions) => Effect.Effect<Record<string, unknown>, ValidationError>;
|
|
188
|
+
/**
|
|
189
|
+
* {@link unpackItemSync} for a normalised **unmarshalled** stream image: on a
|
|
190
|
+
* listed attribute, a string that is base64 of a `B` value (it starts with
|
|
191
|
+
* `I`–`P`, which JSON text never does — see `PackedCodec.isBase64PackedText`)
|
|
192
|
+
* is decoded to bytes and read as `B`; any other string is JSON.
|
|
193
|
+
*/
|
|
194
|
+
export declare const unpackImageItemSync: (raw: Record<string, unknown>, attributes: Iterable<string>, registry: CompressionRegistry, ctx: ItemContext) => ValidationError | undefined;
|
|
195
|
+
/** {@link unpackImageItemSync} as an Effect. */
|
|
196
|
+
export declare const unpackImageItem: (raw: Record<string, unknown>, attributes: Iterable<string>, registry: CompressionRegistry, ctx: ItemContext) => Effect.Effect<void, ValidationError>;
|
|
197
|
+
/**
|
|
198
|
+
* {@link decodeImage} without an Effect, with an explicit registry: the
|
|
199
|
+
* unmarshalled item, or the `ValidationError` it fails with.
|
|
200
|
+
*/
|
|
201
|
+
export declare const decodeImageSync: (image: StreamImage, attributes: Iterable<string>, registry: CompressionRegistry, ctx: ItemContext, options?: ImageOptions) => Record<string, unknown> | ValidationError;
|
|
202
|
+
/**
|
|
203
|
+
* The stream-image decode primitive: normalise `image` and unpack its
|
|
204
|
+
* dispatch-eligible `attributes` (stored names), returning the unmarshalled
|
|
205
|
+
* item with each packed value as its JSON wire form — ready for the same
|
|
206
|
+
* sparse rebuild, renames and schema decode a table read applies. One Effect
|
|
207
|
+
* per image; the work inside is synchronous.
|
|
208
|
+
*
|
|
209
|
+
* In DynamoDB JSON the `S` / `B` tag says what each value is; in an
|
|
210
|
+
* unmarshalled image a string on a listed attribute is read as base64 `B`
|
|
211
|
+
* when it starts with `I`–`P` (see {@link unpackImageItemSync}).
|
|
212
|
+
*/
|
|
213
|
+
export declare const decodeImage: (image: StreamImage, attributes: Iterable<string>, ctx: ItemContext, options?: ImageOptions) => Effect.Effect<Record<string, unknown>, ValidationError>;
|
|
214
|
+
/**
|
|
215
|
+
* A packed attribute an expression or projection may not look inside: DynamoDB
|
|
216
|
+
* sees one opaque `S` or `B` value, so a path below it, or any operator but
|
|
217
|
+
* `attribute_exists` / `attribute_not_exists` on it as a whole, can never
|
|
218
|
+
* match what the reader means.
|
|
219
|
+
*/
|
|
220
|
+
export interface PackedAttributeGuard {
|
|
221
|
+
/** The stored (top-level) attribute name. */
|
|
222
|
+
readonly attribute: string;
|
|
223
|
+
/** Who stores it, for the message — e.g. `EventStream "Ledger"`. */
|
|
224
|
+
readonly owner: string;
|
|
225
|
+
/** Its storage config (the message names the format). */
|
|
226
|
+
readonly storedAs: PackedConfig;
|
|
227
|
+
/** What to do instead, given the refused path as written (`data.amount`). */
|
|
228
|
+
readonly alternative: (path: string) => string;
|
|
229
|
+
}
|
|
230
|
+
/** Render path segments as written: `data.items[0].sku`. */
|
|
231
|
+
export declare const formatPath: (segments: ReadonlyArray<string | number>) => string;
|
|
232
|
+
/**
|
|
233
|
+
* Why `expr` cannot be sent against an item with these packed attributes, or
|
|
234
|
+
* `undefined` when it can: it addresses a path inside one, or applies anything
|
|
235
|
+
* but `attribute_exists` / `attribute_not_exists` to one (`size()` included).
|
|
236
|
+
* `usage` names the expression in the message (`"filter"`, `"condition"`).
|
|
237
|
+
*/
|
|
238
|
+
export declare const packedExprRefusal: (expr: Expr, guards: ReadonlyArray<PackedAttributeGuard>, usage: string) => string | undefined;
|
|
239
|
+
/**
|
|
240
|
+
* Why a projection cannot be sent against an item with these packed
|
|
241
|
+
* attributes, or `undefined` when it can: a packed attribute may be projected
|
|
242
|
+
* only whole. `paths` are segment lists (`selectPaths`); a dotted or indexed
|
|
243
|
+
* name given to `select` (`"data.amount"`, `"data[0]"`) is read as the path it
|
|
244
|
+
* spells.
|
|
245
|
+
*/
|
|
246
|
+
export declare const packedProjectionRefusal: (paths: ReadonlyArray<ReadonlyArray<string | number>>, guards: ReadonlyArray<PackedAttributeGuard>) => string | undefined;
|
|
247
|
+
/** The packed-storage surface of an entity a query is built over. */
|
|
248
|
+
export interface PackedEntityLike {
|
|
249
|
+
readonly entityType: string;
|
|
250
|
+
readonly _packedGuards?: ReadonlyArray<PackedAttributeGuard> | undefined;
|
|
251
|
+
readonly _unpackFields?: ((raw: Record<string, unknown>, operation?: string) => Effect.Effect<void, ValidationError>) | undefined;
|
|
252
|
+
/** The stored attributes `_unpackFields` reads by stored form (packed ∪ dispatch-eligible). */
|
|
253
|
+
readonly _dispatchAttributes?: ReadonlyArray<string> | undefined;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* The raw-row hook of one entity type's projections (`Query.select` /
|
|
257
|
+
* `selectPaths`): reads `attributes` of the type's **own** rows by their stored
|
|
258
|
+
* form, and hands every other row back untouched. `ignoreOwnership()` lets
|
|
259
|
+
* rows of other types through, and their plain strings must never be parsed
|
|
260
|
+
* as packed JSON. The type is read from `__edd_e__`, borrowed into the
|
|
261
|
+
* projection (and stripped again) when the caller did not select it; a row
|
|
262
|
+
* without it is not attributable, so it is left as is. No hook when there is
|
|
263
|
+
* nothing to read, and none on a projection that names none of `attributes`.
|
|
264
|
+
*/
|
|
265
|
+
export declare const ownRowsRawRow: (entityType: string, attributes: ReadonlyArray<string> | undefined, unpack: (raw: Record<string, unknown>) => Effect.Effect<unknown, ValidationError>) => QueryRawRow | undefined;
|
|
266
|
+
/** `Query.make` options for the queries of one entity: guards + raw-row unpack. */
|
|
267
|
+
export declare const entityPackedQueryOptions: (entity: PackedEntityLike) => {
|
|
268
|
+
readonly packed: ReadonlyArray<PackedAttributeGuard>;
|
|
269
|
+
readonly rawRow: QueryRawRow | undefined;
|
|
270
|
+
};
|
|
271
|
+
/**
|
|
272
|
+
* `Query.make` options for a query over several entities (a collection): every
|
|
273
|
+
* member's guards (a path packed in any member is refused, naming it), and a
|
|
274
|
+
* raw-row unpack by the member the row's `__edd_e__` names.
|
|
275
|
+
*/
|
|
276
|
+
export declare const collectionPackedQueryOptions: (members: ReadonlyArray<PackedEntityLike>) => {
|
|
277
|
+
readonly packed: ReadonlyArray<PackedAttributeGuard>;
|
|
278
|
+
readonly rawRow: QueryRawRow | undefined;
|
|
279
|
+
};
|
|
280
|
+
/**
|
|
281
|
+
* {@link packedExprRefusal} for an already-compiled expression
|
|
282
|
+
* (`Transaction.check`'s `ExpressionResult`): every placeholder naming a packed
|
|
283
|
+
* attribute must appear as the whole operand of `attribute_exists(...)` /
|
|
284
|
+
* `attribute_not_exists(...)` — never with a path below it or under another
|
|
285
|
+
* operator. A placeholder used as a nested segment (`#a.#b`) is another
|
|
286
|
+
* attribute's path, and is left alone.
|
|
287
|
+
*/
|
|
288
|
+
export declare const packedCompiledRefusal: (expression: string, names: Readonly<Record<string, string>>, guards: ReadonlyArray<PackedAttributeGuard>, usage: string) => string | undefined;
|
|
289
|
+
//# sourceMappingURL=Packed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Packed.d.ts","sourceRoot":"","sources":["../../src/internal/Packed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAEL,KAAK,mBAAmB,EAEzB,MAAM,wCAAwC,CAAA;AAC/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,YAAY,EAIlB,MAAM,iDAAiD,CAAA;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAA;AAGhD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,KAAK,EAAE,IAAI,EAAW,MAAM,WAAW,CAAA;AAE9C,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,iDAAiD,CAAA;AAElG,0FAA0F;AAC1F,MAAM,MAAM,WAAW,GAAG,gBAAgB,CAAA;AAM1C,uFAAuF;AACvF,eAAO,MAAM,UAAU,GAAI,SAAS,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,KAAG,mBACE,CAAA;AAE/D,mFAAmF;AACnF,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAE9D,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,EAC5B,MAAM,CAAC,QAAQ,EAAE,mBAAmB,KAAK,CAAC,GAAG,eAAe,KAC3D,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,e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