@spine-event-engine/storage 2.0.0-snapshot.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +160 -0
  3. package/REFERENCE.md +120 -0
  4. package/dist/entity/entity-history-record-spec.d.ts +26 -0
  5. package/dist/entity/entity-history-record-spec.d.ts.map +1 -0
  6. package/dist/entity/entity-history-record-spec.js +77 -0
  7. package/dist/entity/entity-history-record-spec.js.map +1 -0
  8. package/dist/entity/entity-history-storage.d.ts +111 -0
  9. package/dist/entity/entity-history-storage.d.ts.map +1 -0
  10. package/dist/entity/entity-history-storage.js +40 -0
  11. package/dist/entity/entity-history-storage.js.map +1 -0
  12. package/dist/entity/entity-record.d.ts +31 -0
  13. package/dist/entity/entity-record.d.ts.map +1 -0
  14. package/dist/entity/entity-record.js +15 -0
  15. package/dist/entity/entity-record.js.map +1 -0
  16. package/dist/entity/history-conformance.d.ts +55 -0
  17. package/dist/entity/history-conformance.d.ts.map +1 -0
  18. package/dist/entity/history-conformance.js +165 -0
  19. package/dist/entity/history-conformance.js.map +1 -0
  20. package/dist/event/event-store.d.ts +141 -0
  21. package/dist/event/event-store.d.ts.map +1 -0
  22. package/dist/event/event-store.js +407 -0
  23. package/dist/event/event-store.js.map +1 -0
  24. package/dist/index.d.ts +23 -0
  25. package/dist/index.d.ts.map +1 -0
  26. package/dist/index.js +30 -0
  27. package/dist/index.js.map +1 -0
  28. package/dist/internal/delivery-cleanup.d.ts +99 -0
  29. package/dist/internal/delivery-cleanup.d.ts.map +1 -0
  30. package/dist/internal/delivery-cleanup.js +38 -0
  31. package/dist/internal/delivery-cleanup.js.map +1 -0
  32. package/dist/internal/entity-commit.d.ts +108 -0
  33. package/dist/internal/entity-commit.d.ts.map +1 -0
  34. package/dist/internal/entity-commit.js +32 -0
  35. package/dist/internal/entity-commit.js.map +1 -0
  36. package/dist/internal/entity-history.d.ts +12 -0
  37. package/dist/internal/entity-history.d.ts.map +1 -0
  38. package/dist/internal/entity-history.js +17 -0
  39. package/dist/internal/entity-history.js.map +1 -0
  40. package/dist/internal/event-store.d.ts +8 -0
  41. package/dist/internal/event-store.d.ts.map +1 -0
  42. package/dist/internal/event-store.js +21 -0
  43. package/dist/internal/event-store.js.map +1 -0
  44. package/dist/internal/query-values.d.ts +5 -0
  45. package/dist/internal/query-values.d.ts.map +1 -0
  46. package/dist/internal/query-values.js +18 -0
  47. package/dist/internal/query-values.js.map +1 -0
  48. package/dist/internal/tenancy.d.ts +89 -0
  49. package/dist/internal/tenancy.d.ts.map +1 -0
  50. package/dist/internal/tenancy.js +97 -0
  51. package/dist/internal/tenancy.js.map +1 -0
  52. package/dist/memory/canonical-utf8.d.ts +21 -0
  53. package/dist/memory/canonical-utf8.d.ts.map +1 -0
  54. package/dist/memory/canonical-utf8.js +65 -0
  55. package/dist/memory/canonical-utf8.js.map +1 -0
  56. package/dist/memory/in-memory-entity-commit.d.ts +35 -0
  57. package/dist/memory/in-memory-entity-commit.d.ts.map +1 -0
  58. package/dist/memory/in-memory-entity-commit.js +183 -0
  59. package/dist/memory/in-memory-entity-commit.js.map +1 -0
  60. package/dist/memory/in-memory-entity-history.d.ts +379 -0
  61. package/dist/memory/in-memory-entity-history.d.ts.map +1 -0
  62. package/dist/memory/in-memory-entity-history.js +756 -0
  63. package/dist/memory/in-memory-entity-history.js.map +1 -0
  64. package/dist/memory/in-memory-record-storage.d.ts +78 -0
  65. package/dist/memory/in-memory-record-storage.d.ts.map +1 -0
  66. package/dist/memory/in-memory-record-storage.js +127 -0
  67. package/dist/memory/in-memory-record-storage.js.map +1 -0
  68. package/dist/memory/in-memory-storage-backend.d.ts +38 -0
  69. package/dist/memory/in-memory-storage-backend.d.ts.map +1 -0
  70. package/dist/memory/in-memory-storage-backend.js +108 -0
  71. package/dist/memory/in-memory-storage-backend.js.map +1 -0
  72. package/dist/memory/in-memory-storage-factory.d.ts +58 -0
  73. package/dist/memory/in-memory-storage-factory.d.ts.map +1 -0
  74. package/dist/memory/in-memory-storage-factory.js +148 -0
  75. package/dist/memory/in-memory-storage-factory.js.map +1 -0
  76. package/dist/memory/memory-delivery-cleanup.d.ts +32 -0
  77. package/dist/memory/memory-delivery-cleanup.d.ts.map +1 -0
  78. package/dist/memory/memory-delivery-cleanup.js +61 -0
  79. package/dist/memory/memory-delivery-cleanup.js.map +1 -0
  80. package/dist/memory/tenant-records.d.ts +66 -0
  81. package/dist/memory/tenant-records.d.ts.map +1 -0
  82. package/dist/memory/tenant-records.js +573 -0
  83. package/dist/memory/tenant-records.js.map +1 -0
  84. package/dist/query/query-execution.d.ts +50 -0
  85. package/dist/query/query-execution.d.ts.map +1 -0
  86. package/dist/query/query-execution.js +222 -0
  87. package/dist/query/query-execution.js.map +1 -0
  88. package/dist/query/query-policy.d.ts +115 -0
  89. package/dist/query/query-policy.d.ts.map +1 -0
  90. package/dist/query/query-policy.js +294 -0
  91. package/dist/query/query-policy.js.map +1 -0
  92. package/dist/record/column-mapping.d.ts +41 -0
  93. package/dist/record/column-mapping.d.ts.map +1 -0
  94. package/dist/record/column-mapping.js +36 -0
  95. package/dist/record/column-mapping.js.map +1 -0
  96. package/dist/record/column-type.d.ts +75 -0
  97. package/dist/record/column-type.d.ts.map +1 -0
  98. package/dist/record/column-type.js +69 -0
  99. package/dist/record/column-type.js.map +1 -0
  100. package/dist/record/record-column.d.ts +23 -0
  101. package/dist/record/record-column.d.ts.map +1 -0
  102. package/dist/record/record-column.js +41 -0
  103. package/dist/record/record-column.js.map +1 -0
  104. package/dist/record/record-mask.d.ts +11 -0
  105. package/dist/record/record-mask.d.ts.map +1 -0
  106. package/dist/record/record-mask.js +82 -0
  107. package/dist/record/record-mask.js.map +1 -0
  108. package/dist/record/record-query.d.ts +102 -0
  109. package/dist/record/record-query.d.ts.map +1 -0
  110. package/dist/record/record-query.js +44 -0
  111. package/dist/record/record-query.js.map +1 -0
  112. package/dist/record/record-spec.d.ts +101 -0
  113. package/dist/record/record-spec.d.ts.map +1 -0
  114. package/dist/record/record-spec.js +159 -0
  115. package/dist/record/record-spec.js.map +1 -0
  116. package/dist/record/record-storage.d.ts +202 -0
  117. package/dist/record/record-storage.d.ts.map +1 -0
  118. package/dist/record/record-storage.js +234 -0
  119. package/dist/record/record-storage.js.map +1 -0
  120. package/dist/record/storage-group.d.ts +17 -0
  121. package/dist/record/storage-group.d.ts.map +1 -0
  122. package/dist/record/storage-group.js +37 -0
  123. package/dist/record/storage-group.js.map +1 -0
  124. package/dist/storage/storage-factory.d.ts +44 -0
  125. package/dist/storage/storage-factory.d.ts.map +1 -0
  126. package/dist/storage/storage-factory.js +54 -0
  127. package/dist/storage/storage-factory.js.map +1 -0
  128. package/dist/storage/storage.d.ts +62 -0
  129. package/dist/storage/storage.d.ts.map +1 -0
  130. package/dist/storage/storage.js +15 -0
  131. package/dist/storage/storage.js.map +1 -0
  132. package/dist/tsconfig.tsbuildinfo +1 -0
  133. package/package.json +56 -0
@@ -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":"column-type.js","sourceRoot":"","sources":["../../src/record/column-type.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AA+DH;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,kBAAkB;IAElB;;;;;OAKG;IACH,MAAM,CACJ,MAAkB,EAClB,YAAsB;QAEtB,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,IAAI,KAAK,EAAE,CAAC,CAAC;IACxF,CAAC;IAED;;;;OAIG;IACH,IAAI,CAAc,MAAgB;QAChC,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;IACvD,CAAC;IAED;;;;OAIG;IACH,OAAO,CAAc,MAAmB;QACtC,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;IAC7D,CAAC;IAED;;;;;OAKG;IACH,SAAS,CAAc,KAAgB;QACrC,QAAQ,KAAK,CAAC,SAAS,EAAE,CAAC;YACxB,KAAK,QAAQ;gBACX,OAAO,MAAM,CAAC,MAAM,CAAC;oBACnB,IAAI,EAAE,QAAQ;oBACd,MAAM,EAAE,KAAK,CAAC,MAAM;oBACpB,YAAY,EAAE,KAAK,CAAC,YAAY;iBACjC,CAAC,CAAC;YACL,KAAK,MAAM;gBACT,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;YAC3D,KAAK,SAAS;gBACZ,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YACpE,KAAK,MAAM,CAAC;YACZ,KAAK,KAAK;gBACR,MAAM,IAAI,KAAK,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"}
@@ -0,0 +1,82 @@
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
+ * Provides record-mask operations.
16
+ */
17
+ export const RecordMask = Object.freeze({
18
+ // prettier-ignore
19
+ /**
20
+ * Applies a simple field mask to a cloned record.
21
+ * @param record The cloned record to prune.
22
+ * @param mask The paths to retain.
23
+ * @returns The pruned record.
24
+ */
25
+ apply(record, mask) {
26
+ if (mask === undefined || mask.length === 0) {
27
+ return record;
28
+ }
29
+ const root = MaskTree.create(mask);
30
+ MaskTree.prune(record, root);
31
+ return record;
32
+ },
33
+ });
34
+ /**
35
+ * Builds and applies the tree used by one record-mask operation.
36
+ */
37
+ const MaskTree = Object.freeze({
38
+ create(mask) {
39
+ const root = this.node();
40
+ for (const path of mask) {
41
+ if (path.trim().length === 0) {
42
+ continue;
43
+ }
44
+ let node = root;
45
+ for (const segment of path.split(".").filter((part) => part.length > 0)) {
46
+ let next = node.children.get(segment);
47
+ if (next === undefined) {
48
+ next = this.node();
49
+ node.children.set(segment, next);
50
+ }
51
+ node = next;
52
+ }
53
+ }
54
+ return root;
55
+ },
56
+ node() {
57
+ return { children: new Map() };
58
+ },
59
+ prune(value, node) {
60
+ if (typeof value !== "object" || value === null || node.children.size === 0) {
61
+ return;
62
+ }
63
+ if (Array.isArray(value)) {
64
+ for (const item of value) {
65
+ this.prune(item, node);
66
+ }
67
+ return;
68
+ }
69
+ for (const key of Object.keys(value)) {
70
+ if (key === "$typeName") {
71
+ continue;
72
+ }
73
+ const child = node.children.get(key);
74
+ if (child === undefined) {
75
+ Reflect.deleteProperty(value, key);
76
+ continue;
77
+ }
78
+ this.prune(Reflect.get(value, key), child);
79
+ }
80
+ },
81
+ });
82
+ //# sourceMappingURL=record-mask.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record-mask.js","sourceRoot":"","sources":["../../src/record/record-mask.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAWH;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAElB,MAAM,CAAC,MAAM,CAAC;IACjB,kBAAkB;IAElB;;;;;OAKG;IACH,KAAK,CAAI,MAAS,EAAE,IAA4B;QAC9C,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC5C,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACnC,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC7B,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,QAAQ,GAAG,MAAM,CAAC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;YACD,OAAO;QACT,CAAC;QAED,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACrC,IAAI,GAAG,KAAK,WAAW,EAAE,CAAC;gBACxB,SAAS;YACX,CAAC;YACD,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAErC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACxB,OAAO,CAAC,cAAc,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;gBACnC,SAAS;YACX,CAAC;YAED,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Defines a deterministic record query by IDs, columns, sorting, continuations,
3
+ * offsets, limits, and masks.
4
+ */
5
+ export interface RecordQuery<I> extends RecordReadOptions {
6
+ /**
7
+ * Exact storage slot identifier filter.
8
+ */
9
+ readonly ids?: readonly I[];
10
+ /**
11
+ * Exact column filters.
12
+ */
13
+ readonly filters?: readonly RecordFilter[];
14
+ /**
15
+ * Deterministic sort order.
16
+ */
17
+ readonly sort?: readonly RecordOrder[];
18
+ /**
19
+ * Stable ordered row key after which the query should continue.
20
+ */
21
+ readonly after?: RecordContinuation<I>;
22
+ /**
23
+ * Positive limit applied after sorting.
24
+ */
25
+ readonly limit?: number;
26
+ /**
27
+ * Non-negative row offset applied after sorting and before the limit.
28
+ */
29
+ readonly offset?: number;
30
+ }
31
+ /**
32
+ * Provides record-query validation operations.
33
+ */
34
+ export declare const RecordQuery: Readonly<{
35
+ validate<I>(query: RecordQuery<I>): void;
36
+ }>;
37
+ /**
38
+ * Read-time options for one record fetch.
39
+ */
40
+ export interface RecordReadOptions {
41
+ /**
42
+ * Optional simple mask applied to the cloned result.
43
+ */
44
+ readonly mask?: import("./record-mask.js").RecordMask;
45
+ }
46
+ /**
47
+ * Query sort order against one stored column, `id`, or a dotted record path.
48
+ */
49
+ export interface RecordOrder {
50
+ /**
51
+ * Stored column name, `id`, or a dotted record path.
52
+ */
53
+ readonly field: string;
54
+ /**
55
+ * Sort direction, ascending by default.
56
+ */
57
+ readonly direction?: "asc" | "desc";
58
+ }
59
+ /**
60
+ * Stable ordered row key used to continue a sorted query after one row.
61
+ *
62
+ * `values` must name the same fields, in the same order, as `RecordQuery.sort`.
63
+ * `id` is the actual storage slot identifier for the row and breaks any
64
+ * remaining ties.
65
+ */
66
+ export interface RecordContinuation<I> {
67
+ /**
68
+ * Ordered field values captured from the last row of the previous page.
69
+ */
70
+ readonly values: readonly RecordContinuationValue[];
71
+ /**
72
+ * Actual storage slot identifier captured from the last row of the previous page.
73
+ */
74
+ readonly id: I;
75
+ }
76
+ /**
77
+ * One captured sort-field value in a record continuation.
78
+ */
79
+ export interface RecordContinuationValue {
80
+ /**
81
+ * Sort field this value was captured from.
82
+ */
83
+ readonly field: string;
84
+ /**
85
+ * Captured value for the sort field.
86
+ */
87
+ readonly value: unknown;
88
+ }
89
+ /**
90
+ * Equality filter against one stored column or the `id` field.
91
+ */
92
+ export interface RecordFilter {
93
+ /**
94
+ * Stored column name or `id`.
95
+ */
96
+ readonly column: string;
97
+ /**
98
+ * One accepted value or a small accepted set.
99
+ */
100
+ readonly value: unknown;
101
+ }
102
+ //# sourceMappingURL=record-query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record-query.d.ts","sourceRoot":"","sources":["../../src/record/record-query.ts"],"names":[],"mappings":"AAcA;;;GAGG;AACH,MAAM,WAAW,WAAW,CAAC,CAAC,CAAE,SAAQ,iBAAiB;IAGvD;;OAEG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,EAAE,CAAC;IAE5B;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,YAAY,EAAE,CAAC;IAE3C;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CACzB"}
@@ -0,0 +1,44 @@
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
+ * Provides record-query validation operations.
16
+ */
17
+ export const RecordQuery = Object.freeze({
18
+ // prettier-ignore
19
+ /**
20
+ * Validate a record query before execution.
21
+ */
22
+ validate(query) {
23
+ if (query.limit !== undefined &&
24
+ (!Number.isInteger(query.limit) || !Number.isFinite(query.limit) || query.limit <= 0)) {
25
+ throw new Error("Record query limit must be positive.");
26
+ }
27
+ if (query.offset !== undefined &&
28
+ (!Number.isInteger(query.offset) || !Number.isFinite(query.offset) || query.offset < 0)) {
29
+ throw new Error("Record query offset must be non-negative.");
30
+ }
31
+ if (query.after !== undefined) {
32
+ const sort = query.sort ?? [];
33
+ if (query.after.values.length !== sort.length) {
34
+ throw new Error("Record query continuation must match the sort order.");
35
+ }
36
+ for (let index = 0; index < sort.length; index += 1) {
37
+ if (query.after.values[index]?.field !== sort[index]?.field) {
38
+ throw new Error("Record query continuation must match the sort order.");
39
+ }
40
+ }
41
+ }
42
+ },
43
+ });
44
+ //# sourceMappingURL=record-query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record-query.js","sourceRoot":"","sources":["../../src/record/record-query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAwCH;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAEnB,MAAM,CAAC,MAAM,CAAC;IACjB,kBAAkB;IAElB;;OAEG;IACH,QAAQ,CAAI,KAAqB;QAC/B,IACE,KAAK,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