@spine-event-engine/storage 2.0.0-snapshot.10
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/LICENSE +201 -0
- package/README.md +190 -0
- package/REFERENCE.md +122 -0
- package/dist/entity/entity-history-record-spec.d.ts +26 -0
- package/dist/entity/entity-history-record-spec.d.ts.map +1 -0
- package/dist/entity/entity-history-record-spec.js +77 -0
- package/dist/entity/entity-history-record-spec.js.map +1 -0
- package/dist/entity/entity-history-storage.d.ts +111 -0
- package/dist/entity/entity-history-storage.d.ts.map +1 -0
- package/dist/entity/entity-history-storage.js +40 -0
- package/dist/entity/entity-history-storage.js.map +1 -0
- package/dist/entity/entity-record.d.ts +31 -0
- package/dist/entity/entity-record.d.ts.map +1 -0
- package/dist/entity/entity-record.js +15 -0
- package/dist/entity/entity-record.js.map +1 -0
- package/dist/entity/history-conformance.d.ts +55 -0
- package/dist/entity/history-conformance.d.ts.map +1 -0
- package/dist/entity/history-conformance.js +165 -0
- package/dist/entity/history-conformance.js.map +1 -0
- package/dist/event/event-store.d.ts +141 -0
- package/dist/event/event-store.d.ts.map +1 -0
- package/dist/event/event-store.js +407 -0
- package/dist/event/event-store.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/delivery-cleanup.d.ts +99 -0
- package/dist/internal/delivery-cleanup.d.ts.map +1 -0
- package/dist/internal/delivery-cleanup.js +38 -0
- package/dist/internal/delivery-cleanup.js.map +1 -0
- package/dist/internal/entity-commit.d.ts +108 -0
- package/dist/internal/entity-commit.d.ts.map +1 -0
- package/dist/internal/entity-commit.js +32 -0
- package/dist/internal/entity-commit.js.map +1 -0
- package/dist/internal/entity-history.d.ts +12 -0
- package/dist/internal/entity-history.d.ts.map +1 -0
- package/dist/internal/entity-history.js +17 -0
- package/dist/internal/entity-history.js.map +1 -0
- package/dist/internal/event-store.d.ts +8 -0
- package/dist/internal/event-store.d.ts.map +1 -0
- package/dist/internal/event-store.js +21 -0
- package/dist/internal/event-store.js.map +1 -0
- package/dist/internal/query-values.d.ts +5 -0
- package/dist/internal/query-values.d.ts.map +1 -0
- package/dist/internal/query-values.js +18 -0
- package/dist/internal/query-values.js.map +1 -0
- package/dist/internal/tenancy.d.ts +89 -0
- package/dist/internal/tenancy.d.ts.map +1 -0
- package/dist/internal/tenancy.js +97 -0
- package/dist/internal/tenancy.js.map +1 -0
- package/dist/memory/canonical-utf8.d.ts +21 -0
- package/dist/memory/canonical-utf8.d.ts.map +1 -0
- package/dist/memory/canonical-utf8.js +65 -0
- package/dist/memory/canonical-utf8.js.map +1 -0
- package/dist/memory/in-memory-entity-commit.d.ts +35 -0
- package/dist/memory/in-memory-entity-commit.d.ts.map +1 -0
- package/dist/memory/in-memory-entity-commit.js +183 -0
- package/dist/memory/in-memory-entity-commit.js.map +1 -0
- package/dist/memory/in-memory-entity-history.d.ts +379 -0
- package/dist/memory/in-memory-entity-history.d.ts.map +1 -0
- package/dist/memory/in-memory-entity-history.js +756 -0
- package/dist/memory/in-memory-entity-history.js.map +1 -0
- package/dist/memory/in-memory-record-storage.d.ts +78 -0
- package/dist/memory/in-memory-record-storage.d.ts.map +1 -0
- package/dist/memory/in-memory-record-storage.js +127 -0
- package/dist/memory/in-memory-record-storage.js.map +1 -0
- package/dist/memory/in-memory-storage-backend.d.ts +38 -0
- package/dist/memory/in-memory-storage-backend.d.ts.map +1 -0
- package/dist/memory/in-memory-storage-backend.js +108 -0
- package/dist/memory/in-memory-storage-backend.js.map +1 -0
- package/dist/memory/in-memory-storage-factory.d.ts +58 -0
- package/dist/memory/in-memory-storage-factory.d.ts.map +1 -0
- package/dist/memory/in-memory-storage-factory.js +148 -0
- package/dist/memory/in-memory-storage-factory.js.map +1 -0
- package/dist/memory/memory-delivery-cleanup.d.ts +32 -0
- package/dist/memory/memory-delivery-cleanup.d.ts.map +1 -0
- package/dist/memory/memory-delivery-cleanup.js +61 -0
- package/dist/memory/memory-delivery-cleanup.js.map +1 -0
- package/dist/memory/tenant-records.d.ts +66 -0
- package/dist/memory/tenant-records.d.ts.map +1 -0
- package/dist/memory/tenant-records.js +573 -0
- package/dist/memory/tenant-records.js.map +1 -0
- package/dist/provider.d.ts +18 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +23 -0
- package/dist/provider.js.map +1 -0
- package/dist/query/query-execution.d.ts +50 -0
- package/dist/query/query-execution.d.ts.map +1 -0
- package/dist/query/query-execution.js +222 -0
- package/dist/query/query-execution.js.map +1 -0
- package/dist/query/query-policy.d.ts +115 -0
- package/dist/query/query-policy.d.ts.map +1 -0
- package/dist/query/query-policy.js +294 -0
- package/dist/query/query-policy.js.map +1 -0
- package/dist/record/column-mapping.d.ts +41 -0
- package/dist/record/column-mapping.d.ts.map +1 -0
- package/dist/record/column-mapping.js +36 -0
- package/dist/record/column-mapping.js.map +1 -0
- package/dist/record/column-type.d.ts +75 -0
- package/dist/record/column-type.d.ts.map +1 -0
- package/dist/record/column-type.js +69 -0
- package/dist/record/column-type.js.map +1 -0
- package/dist/record/record-column.d.ts +23 -0
- package/dist/record/record-column.d.ts.map +1 -0
- package/dist/record/record-column.js +41 -0
- package/dist/record/record-column.js.map +1 -0
- package/dist/record/record-mask.d.ts +11 -0
- package/dist/record/record-mask.d.ts.map +1 -0
- package/dist/record/record-mask.js +82 -0
- package/dist/record/record-mask.js.map +1 -0
- package/dist/record/record-query.d.ts +102 -0
- package/dist/record/record-query.d.ts.map +1 -0
- package/dist/record/record-query.js +44 -0
- package/dist/record/record-query.js.map +1 -0
- package/dist/record/record-spec.d.ts +101 -0
- package/dist/record/record-spec.d.ts.map +1 -0
- package/dist/record/record-spec.js +159 -0
- package/dist/record/record-spec.js.map +1 -0
- package/dist/record/record-storage.d.ts +202 -0
- package/dist/record/record-storage.d.ts.map +1 -0
- package/dist/record/record-storage.js +234 -0
- package/dist/record/record-storage.js.map +1 -0
- package/dist/record/storage-group.d.ts +17 -0
- package/dist/record/storage-group.d.ts.map +1 -0
- package/dist/record/storage-group.js +37 -0
- package/dist/record/storage-group.js.map +1 -0
- package/dist/storage/storage-factory.d.ts +44 -0
- package/dist/storage/storage-factory.d.ts.map +1 -0
- package/dist/storage/storage-factory.js +54 -0
- package/dist/storage/storage-factory.js.map +1 -0
- package/dist/storage/storage.d.ts +62 -0
- package/dist/storage/storage.d.ts.map +1 -0
- package/dist/storage/storage.js +15 -0
- package/dist/storage/storage.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +35 -0
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026, CodeMatters. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
|
5
|
+
* in compliance with the License. You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
|
10
|
+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
|
11
|
+
* or implied. See the License for the specific language governing permissions and limitations under
|
|
12
|
+
* the License.
|
|
13
|
+
*/
|
|
14
|
+
const maximumPredicateDepth = 64;
|
|
15
|
+
const maximumPredicateNodes = 10_000;
|
|
16
|
+
const knownComparisons = new Set([
|
|
17
|
+
"equal",
|
|
18
|
+
"greaterThan",
|
|
19
|
+
"lessThan",
|
|
20
|
+
"greaterOrEqual",
|
|
21
|
+
"lessOrEqual",
|
|
22
|
+
]);
|
|
23
|
+
const knownFeatures = new Set(["either", "nested", "order", "mask", "limit"]);
|
|
24
|
+
const knownPlanProperties = new Set(["predicate", "order", "mask", "limit", "candidateLimit"]);
|
|
25
|
+
/**
|
|
26
|
+
* Shared fail-fast validation for normalized plans before provider execution.
|
|
27
|
+
*/
|
|
28
|
+
export const StorageQueryPolicy = Object.freeze({
|
|
29
|
+
validate(plan, capabilities) {
|
|
30
|
+
const normalizedPlan = QueryPlanValidator.requireRecord(plan, "query plan must be an object.");
|
|
31
|
+
const normalizedCapabilities = QueryPlanValidator.requireRecord(capabilities, "query capabilities must be an object.");
|
|
32
|
+
QueryPlanValidator.validatePlanProperties(normalizedPlan);
|
|
33
|
+
const comparisons = QueryCapabilities.validateComparisons(normalizedCapabilities.comparisons);
|
|
34
|
+
const features = QueryCapabilities.validateFeatures(normalizedCapabilities.features);
|
|
35
|
+
const requirements = {
|
|
36
|
+
comparisons: new Set(),
|
|
37
|
+
features: new Set(),
|
|
38
|
+
};
|
|
39
|
+
if (normalizedPlan.predicate !== undefined) {
|
|
40
|
+
QueryPlanValidator.validatePredicate(normalizedPlan.predicate, requirements);
|
|
41
|
+
}
|
|
42
|
+
QueryPlanValidator.validateOrder(normalizedPlan.order, requirements);
|
|
43
|
+
QueryPlanValidator.validateMask(normalizedPlan.mask, requirements);
|
|
44
|
+
QueryPlanValidator.validateLimit(normalizedPlan.limit, normalizedPlan.order, requirements);
|
|
45
|
+
QueryPlanValidator.validateCandidateLimit(normalizedPlan.candidateLimit);
|
|
46
|
+
QueryCapabilities.admit(requirements, comparisons, features);
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
/**
|
|
50
|
+
* Validates normalized plan values and accumulates their required capabilities.
|
|
51
|
+
*/
|
|
52
|
+
const QueryPlanValidator = {
|
|
53
|
+
// prettier-ignore
|
|
54
|
+
/**
|
|
55
|
+
* Rejects unsupported or misspelled normalized-plan properties.
|
|
56
|
+
*/
|
|
57
|
+
validatePlanProperties(plan) {
|
|
58
|
+
if (Object.hasOwn(plan, "offset")) {
|
|
59
|
+
throw new TypeError("normalized query plans do not support offset.");
|
|
60
|
+
}
|
|
61
|
+
for (const property of Object.keys(plan)) {
|
|
62
|
+
if (!knownPlanProperties.has(property)) {
|
|
63
|
+
throw new TypeError("query plan property must be recognized.");
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
/**
|
|
68
|
+
* Validates the maximum materialized candidate count.
|
|
69
|
+
*/
|
|
70
|
+
validateCandidateLimit(value) {
|
|
71
|
+
if (value === undefined)
|
|
72
|
+
return;
|
|
73
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0) {
|
|
74
|
+
throw new TypeError("query candidate limit must be a positive safe integer.");
|
|
75
|
+
}
|
|
76
|
+
if (value > 10_000)
|
|
77
|
+
throw new TypeError("query candidate limit must not exceed 10,000.");
|
|
78
|
+
},
|
|
79
|
+
/**
|
|
80
|
+
* Validates a normalized predicate tree and records its required capabilities.
|
|
81
|
+
*/
|
|
82
|
+
validatePredicate(root, requirements) {
|
|
83
|
+
const pending = [
|
|
84
|
+
{ predicate: root, depth: 0 },
|
|
85
|
+
];
|
|
86
|
+
const seen = new WeakSet();
|
|
87
|
+
let visited = 0;
|
|
88
|
+
while (pending.length > 0) {
|
|
89
|
+
const current = pending.pop();
|
|
90
|
+
if (current === undefined)
|
|
91
|
+
break;
|
|
92
|
+
visited += 1;
|
|
93
|
+
if (visited > maximumPredicateNodes) {
|
|
94
|
+
throw new TypeError(`query predicate exceeds maximum node count ${String(maximumPredicateNodes)}.`);
|
|
95
|
+
}
|
|
96
|
+
if (current.depth > maximumPredicateDepth) {
|
|
97
|
+
throw new TypeError(`query predicate exceeds maximum depth ${String(maximumPredicateDepth)}.`);
|
|
98
|
+
}
|
|
99
|
+
const predicate = QueryPlanValidator.requireRecord(current.predicate, "query predicate must be an object.");
|
|
100
|
+
if (seen.has(predicate))
|
|
101
|
+
throw new TypeError("query predicate must not contain cycles.");
|
|
102
|
+
seen.add(predicate);
|
|
103
|
+
if (predicate.kind === "ids") {
|
|
104
|
+
if (!Array.isArray(predicate.ids))
|
|
105
|
+
throw new TypeError("ID predicate IDs must be an array.");
|
|
106
|
+
if (predicate.ids.length === 0)
|
|
107
|
+
throw new TypeError("ID predicate must not be empty.");
|
|
108
|
+
for (let index = 0; index < predicate.ids.length; index += 1) {
|
|
109
|
+
if (!Object.hasOwn(predicate.ids, index) || predicate.ids[index] === undefined) {
|
|
110
|
+
throw new TypeError("ID predicate entries must be defined.");
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
if (predicate.kind === "comparison") {
|
|
116
|
+
if (typeof predicate.column !== "string") {
|
|
117
|
+
throw new TypeError("comparison column must be a string.");
|
|
118
|
+
}
|
|
119
|
+
if (predicate.column.trim().length === 0) {
|
|
120
|
+
throw new TypeError("comparison column must not be blank.");
|
|
121
|
+
}
|
|
122
|
+
if (typeof predicate.operator !== "string" ||
|
|
123
|
+
!knownComparisons.has(predicate.operator)) {
|
|
124
|
+
throw new TypeError("comparison operator must be recognized.");
|
|
125
|
+
}
|
|
126
|
+
if (predicate.value === undefined)
|
|
127
|
+
throw new TypeError("comparison value must be defined.");
|
|
128
|
+
requirements.comparisons.add(predicate.operator);
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
if (predicate.kind !== "all" && predicate.kind !== "either") {
|
|
132
|
+
throw new TypeError("query predicate kind must be recognized.");
|
|
133
|
+
}
|
|
134
|
+
if (!Array.isArray(predicate.predicates)) {
|
|
135
|
+
throw new TypeError(`${predicate.kind.toUpperCase()} predicate predicates must be an array.`);
|
|
136
|
+
}
|
|
137
|
+
if (predicate.predicates.length === 0) {
|
|
138
|
+
throw new TypeError(`${predicate.kind.toUpperCase()} predicate must not be empty.`);
|
|
139
|
+
}
|
|
140
|
+
if (predicate.kind === "either")
|
|
141
|
+
requirements.features.add("either");
|
|
142
|
+
if (current.depth > 0)
|
|
143
|
+
requirements.features.add("nested");
|
|
144
|
+
if (visited + pending.length + predicate.predicates.length > maximumPredicateNodes) {
|
|
145
|
+
throw new TypeError(`query predicate exceeds maximum node count ${String(maximumPredicateNodes)}.`);
|
|
146
|
+
}
|
|
147
|
+
for (let index = predicate.predicates.length - 1; index >= 0; index -= 1) {
|
|
148
|
+
if (!Object.hasOwn(predicate.predicates, index)) {
|
|
149
|
+
throw new TypeError("query predicate entries must be defined.");
|
|
150
|
+
}
|
|
151
|
+
pending.push({ predicate: predicate.predicates[index], depth: current.depth + 1 });
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
/**
|
|
156
|
+
* Validates normalized ordering and records the ordering capability.
|
|
157
|
+
*/
|
|
158
|
+
validateOrder(value, requirements) {
|
|
159
|
+
if (value === undefined)
|
|
160
|
+
return;
|
|
161
|
+
if (!Array.isArray(value))
|
|
162
|
+
throw new TypeError("query order must be an array.");
|
|
163
|
+
if (value.length === 0)
|
|
164
|
+
throw new TypeError("query order must not be empty.");
|
|
165
|
+
for (const candidate of value) {
|
|
166
|
+
const order = QueryPlanValidator.requireRecord(candidate, "query order entry must be an object.");
|
|
167
|
+
if (typeof order.column !== "string")
|
|
168
|
+
throw new TypeError("query order column must be a string.");
|
|
169
|
+
if (order.column.trim().length === 0)
|
|
170
|
+
throw new TypeError("query order column must not be blank.");
|
|
171
|
+
if (order.direction !== "asc" && order.direction !== "desc") {
|
|
172
|
+
throw new TypeError("query order direction must be asc or desc.");
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
requirements.features.add("order");
|
|
176
|
+
},
|
|
177
|
+
/**
|
|
178
|
+
* Validates a normalized field mask and records the mask capability.
|
|
179
|
+
*/
|
|
180
|
+
validateMask(value, requirements) {
|
|
181
|
+
if (value === undefined)
|
|
182
|
+
return;
|
|
183
|
+
const mask = QueryPlanValidator.requireRecord(value, "field mask must be an object.");
|
|
184
|
+
if (!Array.isArray(mask.paths))
|
|
185
|
+
throw new TypeError("field-mask paths must be an array.");
|
|
186
|
+
if (mask.paths.length === 0)
|
|
187
|
+
throw new TypeError("field mask must not be empty.");
|
|
188
|
+
const paths = mask.paths;
|
|
189
|
+
for (let index = 0; index < paths.length; index += 1) {
|
|
190
|
+
const path = paths[index];
|
|
191
|
+
if (!Object.hasOwn(paths, index) || typeof path !== "string") {
|
|
192
|
+
throw new TypeError("field-mask paths must be strings.");
|
|
193
|
+
}
|
|
194
|
+
if (path.trim().length === 0)
|
|
195
|
+
throw new TypeError("field-mask paths must not be blank.");
|
|
196
|
+
}
|
|
197
|
+
requirements.features.add("mask");
|
|
198
|
+
},
|
|
199
|
+
/**
|
|
200
|
+
* Validates a result limit and records the limit capability.
|
|
201
|
+
*/
|
|
202
|
+
validateLimit(value, order, requirements) {
|
|
203
|
+
if (value === undefined)
|
|
204
|
+
return;
|
|
205
|
+
if (typeof value !== "number" || !Number.isInteger(value) || value <= 0) {
|
|
206
|
+
throw new TypeError("query limit must be a positive integer.");
|
|
207
|
+
}
|
|
208
|
+
if (!Array.isArray(order) || order.length === 0) {
|
|
209
|
+
throw new TypeError("query limit requires ordering.");
|
|
210
|
+
}
|
|
211
|
+
requirements.features.add("limit");
|
|
212
|
+
},
|
|
213
|
+
/**
|
|
214
|
+
* Requires a non-array object value and returns its properties.
|
|
215
|
+
*/
|
|
216
|
+
requireRecord(value, message) {
|
|
217
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
218
|
+
throw new TypeError(message);
|
|
219
|
+
}
|
|
220
|
+
return value;
|
|
221
|
+
},
|
|
222
|
+
};
|
|
223
|
+
/**
|
|
224
|
+
* Validates advertised capabilities and admits normalized query requirements.
|
|
225
|
+
*/
|
|
226
|
+
const QueryCapabilities = {
|
|
227
|
+
// prettier-ignore
|
|
228
|
+
/**
|
|
229
|
+
* Validates advertised comparison operators.
|
|
230
|
+
*/
|
|
231
|
+
validateComparisons(value) {
|
|
232
|
+
if (!Array.isArray(value))
|
|
233
|
+
throw new TypeError("comparison capabilities must be an array.");
|
|
234
|
+
const validated = [];
|
|
235
|
+
for (const comparison of value) {
|
|
236
|
+
if (typeof comparison !== "string" || !knownComparisons.has(comparison)) {
|
|
237
|
+
throw new TypeError("comparison capability must be recognized.");
|
|
238
|
+
}
|
|
239
|
+
validated.push(comparison);
|
|
240
|
+
}
|
|
241
|
+
return new Set(validated);
|
|
242
|
+
},
|
|
243
|
+
/**
|
|
244
|
+
* Validates advertised normalized query features.
|
|
245
|
+
*/
|
|
246
|
+
validateFeatures(value) {
|
|
247
|
+
if (!Array.isArray(value))
|
|
248
|
+
throw new TypeError("query features must be an array.");
|
|
249
|
+
const validated = [];
|
|
250
|
+
for (const feature of value) {
|
|
251
|
+
if (typeof feature !== "string" || !knownFeatures.has(feature)) {
|
|
252
|
+
throw new TypeError("query feature must be recognized.");
|
|
253
|
+
}
|
|
254
|
+
validated.push(feature);
|
|
255
|
+
}
|
|
256
|
+
return new Set(validated);
|
|
257
|
+
},
|
|
258
|
+
/**
|
|
259
|
+
* Rejects requirements that an advertised provider capability set does not satisfy.
|
|
260
|
+
*/
|
|
261
|
+
admit(requirements, comparisons, features) {
|
|
262
|
+
for (const feature of requirements.features) {
|
|
263
|
+
QueryCapabilities.requireFeature(features, feature, QueryCapabilities.featureDescription(feature));
|
|
264
|
+
}
|
|
265
|
+
for (const comparison of requirements.comparisons) {
|
|
266
|
+
if (!comparisons.has(comparison)) {
|
|
267
|
+
throw new TypeError(`Storage provider does not support comparison operator "${comparison}".`);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
/**
|
|
272
|
+
* Describes a capability in a provider-rejection message.
|
|
273
|
+
*/
|
|
274
|
+
featureDescription(feature) {
|
|
275
|
+
if (feature === "either")
|
|
276
|
+
return "EITHER predicates";
|
|
277
|
+
if (feature === "nested")
|
|
278
|
+
return "nested predicates";
|
|
279
|
+
if (feature === "order")
|
|
280
|
+
return "ordering";
|
|
281
|
+
if (feature === "mask")
|
|
282
|
+
return "field masks";
|
|
283
|
+
return "limits";
|
|
284
|
+
},
|
|
285
|
+
/**
|
|
286
|
+
* Rejects a missing required feature with its provider-facing description.
|
|
287
|
+
*/
|
|
288
|
+
requireFeature(features, feature, description) {
|
|
289
|
+
if (!features.has(feature)) {
|
|
290
|
+
throw new TypeError(`Storage provider does not support ${description}.`);
|
|
291
|
+
}
|
|
292
|
+
},
|
|
293
|
+
};
|
|
294
|
+
//# sourceMappingURL=query-policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-policy.js","sourceRoot":"","sources":["../../src/query/query-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAkJH,MAAM,qBAAqB,GAAG,EAAE,CAAC;AACjC,MAAM,qBAAqB,GAAG,MAAM,CAAC;AACrC,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAA+B;IAC7D,OAAO;IACP,aAAa;IACb,UAAU;IACV,gBAAgB;IAChB,aAAa;CACd,CAAC,CAAC;AACH,MAAM,aAAa,GAAG,IAAI,GAAG,CAAsB,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AACnG,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC;AAE/F;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAE1B,MAAM,CAAC,MAAM,CAAC;IACjB,QAAQ,CAAK,IAA6B,EAAE,YAAsC;QAChF,MAAM,cAAc,GAAG,kBAAkB,CAAC,aAAa,CAAC,IAAI,EAAE,+BAA+B,CAAC,CAAC;QAC/F,MAAM,sBAAsB,GAAG,kBAAkB,CAAC,aAAa,CAC7D,YAAY,EACZ,uCAAuC,CACxC,CAAC;QACF,kBAAkB,CAAC,sBAAsB,CAAC,cAAc,CAAC,CAAC;QAC1D,MAAM,WAAW,GAAG,iBAAiB,CAAC,mBAAmB,CAAC,sBAAsB,CAAC,WAAW,CAAC,CAAC;QAC9F,MAAM,QAAQ,GAAG,iBAAiB,CAAC,gBAAgB,CAAC,sBAAsB,CAAC,QAAQ,CAAC,CAAC;QACrF,MAAM,YAAY,GAAsB;YACtC,WAAW,EAAE,I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CAAC,qCAAqC,WAAW,GAAG,CAAC,CAAC;QAC3E,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { RecordColumnType } from "./column-type.js";
|
|
2
|
+
/**
|
|
3
|
+
* Converts one typed record-column value to its provider representation.
|
|
4
|
+
*
|
|
5
|
+
* @param value The typed Protobuf value.
|
|
6
|
+
* @returns The provider representation.
|
|
7
|
+
*/
|
|
8
|
+
export type ColumnTypeMapping<V, R> = (value: V) => R;
|
|
9
|
+
/**
|
|
10
|
+
* Supplies provider conversion rules for generated Protobuf column types.
|
|
11
|
+
*/
|
|
12
|
+
export interface ColumnMapping<R> {
|
|
13
|
+
/**
|
|
14
|
+
* Returns the conversion rule for a declared column type.
|
|
15
|
+
* @param type The generated Protobuf column type.
|
|
16
|
+
* @returns The provider conversion rule.
|
|
17
|
+
*/
|
|
18
|
+
of<V>(type: RecordColumnType<V>): ColumnTypeMapping<V, R>;
|
|
19
|
+
/**
|
|
20
|
+
* Returns the provider conversion rule for an absent column value.
|
|
21
|
+
* @returns The provider null conversion rule.
|
|
22
|
+
*/
|
|
23
|
+
ofNull(): ColumnTypeMapping<null, R>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Applies one provider mapping to stored and queried column values.
|
|
27
|
+
*/
|
|
28
|
+
export declare const ColumnMappings: {
|
|
29
|
+
/**
|
|
30
|
+
* Converts a value through its declared provider rule.
|
|
31
|
+
*
|
|
32
|
+
* Both record materialization and query planning must call this operation.
|
|
33
|
+
*
|
|
34
|
+
* @param mapping The provider mapping.
|
|
35
|
+
* @param type The declared column type.
|
|
36
|
+
* @param value The stored or queried value.
|
|
37
|
+
* @returns The provider value.
|
|
38
|
+
*/
|
|
39
|
+
readonly value: <V, R>(mapping: ColumnMapping<R>, type: RecordColumnType<V>, value: V | null | undefined) => R;
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=column-mapping.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column-mapping.d.ts","sourceRoot":"","sources":["../../src/record/column-mapping.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC;IAG9B;;;;OAIG;IACH,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAE1D;;;OAGG;IACH,MAAM,IAAI,iBAAiB,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;CACtC;AAED;;GAEG;AACH,eAAO,MAAM,cAAc;IAGzB;;;;;;;;;OASG;qBACG,CAAC,EAAE,CAAC,WACC,aAAa,CAAC,CAAC,CAAC,QACnB,gBAAgB,CAAC,CAAC,CAAC,SAClB,CAAC,GAAG,IAAI,GAAG,SAAS,KAC1B,CAAC;CAKI,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026, CodeMatters. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
|
5
|
+
* in compliance with the License. You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
|
10
|
+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
|
11
|
+
* or implied. See the License for the specific language governing permissions and limitations under
|
|
12
|
+
* the License.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Applies one provider mapping to stored and queried column values.
|
|
16
|
+
*/
|
|
17
|
+
export const ColumnMappings = {
|
|
18
|
+
// prettier-ignore
|
|
19
|
+
/**
|
|
20
|
+
* Converts a value through its declared provider rule.
|
|
21
|
+
*
|
|
22
|
+
* Both record materialization and query planning must call this operation.
|
|
23
|
+
*
|
|
24
|
+
* @param mapping The provider mapping.
|
|
25
|
+
* @param type The declared column type.
|
|
26
|
+
* @param value The stored or queried value.
|
|
27
|
+
* @returns The provider value.
|
|
28
|
+
*/
|
|
29
|
+
value(mapping, type, value) {
|
|
30
|
+
return value === null || value === undefined
|
|
31
|
+
? mapping.ofNull()(null)
|
|
32
|
+
: mapping.of(type)(value);
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
Object.freeze(ColumnMappings);
|
|
36
|
+
//# sourceMappingURL=column-mapping.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column-mapping.js","sourceRoot":"","sources":["../../src/record/column-mapping.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAgCH;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,kBAAkB;IAElB;;;;;;;;;OASG;IACH,KAAK,CACH,OAAyB,EACzB,IAAyB,EACzB,KAA2B;QAE3B,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;YAC1C,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC;YACxB,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;CACO,CAAC;AACX,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { DescEnum, DescField, DescMessage, ScalarType } from "@bufbuild/protobuf";
|
|
2
|
+
declare const columnValueType: unique symbol;
|
|
3
|
+
/**
|
|
4
|
+
* Generated Protobuf type retained for one materialized record column.
|
|
5
|
+
*/
|
|
6
|
+
export type RecordColumnType<V = unknown> = ({
|
|
7
|
+
/**
|
|
8
|
+
* Identifies a Protobuf scalar column.
|
|
9
|
+
*/
|
|
10
|
+
readonly kind: "scalar";
|
|
11
|
+
/**
|
|
12
|
+
* Protobuf scalar kind retained by the column.
|
|
13
|
+
*/
|
|
14
|
+
readonly scalar: ScalarType;
|
|
15
|
+
/**
|
|
16
|
+
* Whether generated code represents a 64-bit value as a string.
|
|
17
|
+
*/
|
|
18
|
+
readonly longAsString: boolean;
|
|
19
|
+
} | {
|
|
20
|
+
/**
|
|
21
|
+
* Identifies a Protobuf enum column.
|
|
22
|
+
*/
|
|
23
|
+
readonly kind: "enum";
|
|
24
|
+
/**
|
|
25
|
+
* Generated enum descriptor retained by the column.
|
|
26
|
+
*/
|
|
27
|
+
readonly enum: DescEnum;
|
|
28
|
+
} | {
|
|
29
|
+
/**
|
|
30
|
+
* Identifies a Protobuf message column.
|
|
31
|
+
*/
|
|
32
|
+
readonly kind: "message";
|
|
33
|
+
/**
|
|
34
|
+
* Generated message descriptor retained by the column.
|
|
35
|
+
*/
|
|
36
|
+
readonly message: DescMessage;
|
|
37
|
+
}) & {
|
|
38
|
+
/**
|
|
39
|
+
* Compile-time value type carried by the column declaration.
|
|
40
|
+
*/
|
|
41
|
+
readonly [columnValueType]?: V;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Creates record-column types from generated Protobuf descriptors.
|
|
45
|
+
*/
|
|
46
|
+
export declare const ColumnTypes: {
|
|
47
|
+
/**
|
|
48
|
+
* Declares a scalar type for a derived column value.
|
|
49
|
+
* @param scalar The Protobuf scalar type.
|
|
50
|
+
* @param longAsString Whether a 64-bit value uses its generated string form.
|
|
51
|
+
* @returns The scalar column type.
|
|
52
|
+
*/
|
|
53
|
+
readonly scalar: <V = unknown>(scalar: ScalarType, longAsString?: boolean) => RecordColumnType<V>;
|
|
54
|
+
/**
|
|
55
|
+
* Declares an enum type for a derived column value.
|
|
56
|
+
* @param schema The generated enum descriptor.
|
|
57
|
+
* @returns The enum column type.
|
|
58
|
+
*/
|
|
59
|
+
readonly enum: <V = unknown>(schema: DescEnum) => RecordColumnType<V>;
|
|
60
|
+
/**
|
|
61
|
+
* Declares a message type for a derived column value.
|
|
62
|
+
* @param schema The generated message descriptor.
|
|
63
|
+
* @returns The message column type.
|
|
64
|
+
*/
|
|
65
|
+
readonly message: <V = unknown>(schema: DescMessage) => RecordColumnType<V>;
|
|
66
|
+
/**
|
|
67
|
+
* Retains the singular value type declared by a generated Protobuf field.
|
|
68
|
+
* @param field The generated field descriptor.
|
|
69
|
+
* @returns The corresponding column type.
|
|
70
|
+
* @throws Error when the field is repeated or a map.
|
|
71
|
+
*/
|
|
72
|
+
readonly fromField: <V = unknown>(field: DescField) => RecordColumnType<V>;
|
|
73
|
+
};
|
|
74
|
+
export {};
|
|
75
|
+
//# sourceMappingURL=column-type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column-type.d.ts","sourceRoot":"","sources":["../../src/record/column-type.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEvF,OAAO,CAAC,MAAM,eAAe,EAAE,OAAO,MAAM,CAAC;AAE7C;;GAEG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,GAAG,OAAO,IAAI,CACxC;IAGE;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAExB;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAE5B;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;CAChC,GACD;IAGE;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;CACzB,GACD;IAGE;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;CAC/B,CACJ,GAAG;IAGF;;OAEG;IACH,QAAQ,CAAC,CAAC,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC;CAChC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW;IAGtB;;;;;OAKG;sBACI,CAAC,oBACE,UAAU,iBACH,OAAO,KACrB,gBAAgB,CAAC,CAAC,CAAC;IAItB;;;;OAIG;oBACE,CAAC,oBAAoB,QAAQ,KAAG,gBAAgB,CAAC,CAAC,CAAC;IAIxD;;;;OAIG;uBACK,CAAC,oBAAoB,WAAW,KAAG,gBAAgB,CAAC,CAAC,CAAC;IAI9D;;;;;OAKG;yBACO,CAAC,mBAAmB,SAAS,KAAG,gBAAgB,CAAC,CAAC,CAAC;CAiBrD,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026, CodeMatters. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
|
5
|
+
* in compliance with the License. You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
|
10
|
+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
|
11
|
+
* or implied. See the License for the specific language governing permissions and limitations under
|
|
12
|
+
* the License.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Creates record-column types from generated Protobuf descriptors.
|
|
16
|
+
*/
|
|
17
|
+
export const ColumnTypes = {
|
|
18
|
+
// prettier-ignore
|
|
19
|
+
/**
|
|
20
|
+
* Declares a scalar type for a derived column value.
|
|
21
|
+
* @param scalar The Protobuf scalar type.
|
|
22
|
+
* @param longAsString Whether a 64-bit value uses its generated string form.
|
|
23
|
+
* @returns The scalar column type.
|
|
24
|
+
*/
|
|
25
|
+
scalar(scalar, longAsString) {
|
|
26
|
+
return Object.freeze({ kind: "scalar", scalar, longAsString: longAsString ?? false });
|
|
27
|
+
},
|
|
28
|
+
/**
|
|
29
|
+
* Declares an enum type for a derived column value.
|
|
30
|
+
* @param schema The generated enum descriptor.
|
|
31
|
+
* @returns The enum column type.
|
|
32
|
+
*/
|
|
33
|
+
enum(schema) {
|
|
34
|
+
return Object.freeze({ kind: "enum", enum: schema });
|
|
35
|
+
},
|
|
36
|
+
/**
|
|
37
|
+
* Declares a message type for a derived column value.
|
|
38
|
+
* @param schema The generated message descriptor.
|
|
39
|
+
* @returns The message column type.
|
|
40
|
+
*/
|
|
41
|
+
message(schema) {
|
|
42
|
+
return Object.freeze({ kind: "message", message: schema });
|
|
43
|
+
},
|
|
44
|
+
/**
|
|
45
|
+
* Retains the singular value type declared by a generated Protobuf field.
|
|
46
|
+
* @param field The generated field descriptor.
|
|
47
|
+
* @returns The corresponding column type.
|
|
48
|
+
* @throws Error when the field is repeated or a map.
|
|
49
|
+
*/
|
|
50
|
+
fromField(field) {
|
|
51
|
+
switch (field.fieldKind) {
|
|
52
|
+
case "scalar":
|
|
53
|
+
return Object.freeze({
|
|
54
|
+
kind: "scalar",
|
|
55
|
+
scalar: field.scalar,
|
|
56
|
+
longAsString: field.longAsString,
|
|
57
|
+
});
|
|
58
|
+
case "enum":
|
|
59
|
+
return Object.freeze({ kind: "enum", enum: field.enum });
|
|
60
|
+
case "message":
|
|
61
|
+
return Object.freeze({ kind: "message", message: field.message });
|
|
62
|
+
case "list":
|
|
63
|
+
case "map":
|
|
64
|
+
throw new Error(`Record column "${field.name}" must have one singular value.`);
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
Object.freeze(ColumnTypes);
|
|
69
|
+
//# sourceMappingURL=column-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file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AK,CAAC,kBAAkB,KAAK,CAAC,IAAI,iCAAiC,CAAC,CAAC;QACnF,CAAC;IACH,CAAC;CACO,CAAC;AACX,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { RecordColumnType } from "./column-type.js";
|
|
2
|
+
/**
|
|
3
|
+
* Queryable column calculated from a stored record.
|
|
4
|
+
*/
|
|
5
|
+
export declare class RecordColumn<R extends object, V = unknown> {
|
|
6
|
+
#private;
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly type: RecordColumnType<V>;
|
|
9
|
+
/**
|
|
10
|
+
* Creates a named column reader.
|
|
11
|
+
* @param name The stable column name.
|
|
12
|
+
* @param type The generated Protobuf value type.
|
|
13
|
+
* @param read The record value reader.
|
|
14
|
+
*/
|
|
15
|
+
constructor(name: string, type: RecordColumnType<V>, read: (record: R) => V);
|
|
16
|
+
/**
|
|
17
|
+
* Reads the stored column value from a record snapshot.
|
|
18
|
+
* @param record The record snapshot.
|
|
19
|
+
* @returns The column value.
|
|
20
|
+
*/
|
|
21
|
+
valueIn(record: R): V;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=record-column.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record-column.d.ts","sourceRoot":"","sources":["../../src/record/record-column.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD;;GAEG;AACH,qBAAa,YAAY,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,GAAG,OAAO;;IAUnD,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC;IARpC;;;;;OAKG;gBAEQ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAClC,IAAI,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC;IAKxB;;;;OAIG;IACH,OAAO,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC;CAGtB"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026, CodeMatters. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
|
5
|
+
* in compliance with the License. You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
|
10
|
+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
|
11
|
+
* or implied. See the License for the specific language governing permissions and limitations under
|
|
12
|
+
* the License.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Queryable column calculated from a stored record.
|
|
16
|
+
*/
|
|
17
|
+
export class RecordColumn {
|
|
18
|
+
name;
|
|
19
|
+
type;
|
|
20
|
+
#read;
|
|
21
|
+
/**
|
|
22
|
+
* Creates a named column reader.
|
|
23
|
+
* @param name The stable column name.
|
|
24
|
+
* @param type The generated Protobuf value type.
|
|
25
|
+
* @param read The record value reader.
|
|
26
|
+
*/
|
|
27
|
+
constructor(name, type, read) {
|
|
28
|
+
this.name = name;
|
|
29
|
+
this.type = type;
|
|
30
|
+
this.#read = read;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Reads the stored column value from a record snapshot.
|
|
34
|
+
* @param record The record snapshot.
|
|
35
|
+
* @returns The column value.
|
|
36
|
+
*/
|
|
37
|
+
valueIn(record) {
|
|
38
|
+
return this.#read(record);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=record-column.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record-column.js","sourceRoot":"","sources":["../../src/record/record-column.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH;;GAEG;AACH,MAAM,OAAO,YAAY;IAUZ;IACA;IAVF,KAAK,CAAmB;IAEjC;;;;;OAKG;IACH,YACW,IAAY,EACZ,IAAyB,EAClC,IAAsB;QAFb,SAAI,GAAJ,IAAI,CAAQ;QACZ,SAAI,GAAJ,IAAI,CAAqB;QAGlC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED;;;;OAIG;IACH,OAAO,CAAC,MAAS;QACf,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;CACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents dotted record paths retained by a masked read.
|
|
3
|
+
*/
|
|
4
|
+
export type RecordMask = readonly string[];
|
|
5
|
+
/**
|
|
6
|
+
* Provides record-mask operations.
|
|
7
|
+
*/
|
|
8
|
+
export declare const RecordMask: Readonly<{
|
|
9
|
+
apply<R>(record: R, mask: RecordMask | undefined): R;
|
|
10
|
+
}>;
|
|
11
|
+
//# sourceMappingURL=record-mask.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record-mask.d.ts","sourceRoot":"","sources":["../../src/record/record-mask.ts"],"names":[],"mappings":"AAcA;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,SAAS,MAAM,EAAE,CAAC;AAM3C;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC;IAChC,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,UAAU,GAAG,SAAS,GAAG,CAAC,CAAC;CACtD,CAkBC,CAAC"}
|