@bandeira-tech/b3nd-save 0.8.1

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 (177) hide show
  1. package/LICENSE +21 -0
  2. package/esm/_dnt.shims.d.ts +2 -0
  3. package/esm/_dnt.shims.d.ts.map +1 -0
  4. package/esm/_dnt.shims.js +57 -0
  5. package/esm/byte-entity-shim.d.ts +47 -0
  6. package/esm/byte-entity-shim.d.ts.map +1 -0
  7. package/esm/byte-entity-shim.js +138 -0
  8. package/esm/clients/mod.d.ts +15 -0
  9. package/esm/clients/mod.d.ts.map +1 -0
  10. package/esm/clients/mod.js +14 -0
  11. package/esm/clients/save-client.d.ts +87 -0
  12. package/esm/clients/save-client.d.ts.map +1 -0
  13. package/esm/clients/save-client.js +174 -0
  14. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/mod.d.ts +40 -0
  15. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/mod.d.ts.map +1 -0
  16. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/mod.js +31 -0
  17. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/client-console/client.d.ts +30 -0
  18. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/client-console/client.d.ts.map +1 -0
  19. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/client-console/client.js +70 -0
  20. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/encoding/encoding.d.ts +16 -0
  21. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/encoding/encoding.d.ts.map +1 -0
  22. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/encoding/encoding.js +50 -0
  23. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/encrypt/mod.d.ts +235 -0
  24. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/encrypt/mod.d.ts.map +1 -0
  25. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/encrypt/mod.js +619 -0
  26. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/functional-client/functional-client.d.ts +43 -0
  27. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/functional-client/functional-client.d.ts.map +1 -0
  28. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/functional-client/functional-client.js +54 -0
  29. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/match-pattern/match-pattern.d.ts +47 -0
  30. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/match-pattern/match-pattern.d.ts.map +1 -0
  31. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/match-pattern/match-pattern.js +134 -0
  32. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/network/decorators.d.ts +20 -0
  33. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/network/decorators.d.ts.map +1 -0
  34. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/network/decorators.js +34 -0
  35. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/network/network.d.ts +46 -0
  36. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/network/network.d.ts.map +1 -0
  37. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/network/network.js +131 -0
  38. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/network/peer.d.ts +27 -0
  39. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/network/peer.d.ts.map +1 -0
  40. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/network/peer.js +25 -0
  41. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/network/policies/flood.d.ts +59 -0
  42. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/network/policies/flood.d.ts.map +1 -0
  43. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/network/policies/flood.js +188 -0
  44. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/network/policies/path-vector.d.ts +35 -0
  45. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/network/policies/path-vector.d.ts.map +1 -0
  46. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/network/policies/path-vector.js +57 -0
  47. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/network/policies/tell-and-read.d.ts +117 -0
  48. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/network/policies/tell-and-read.d.ts.map +1 -0
  49. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/network/policies/tell-and-read.js +125 -0
  50. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/network/types.d.ts +112 -0
  51. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/network/types.d.ts.map +1 -0
  52. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/network/types.js +21 -0
  53. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/observe-emitter/observe-emitter.d.ts +35 -0
  54. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/observe-emitter/observe-emitter.d.ts.map +1 -0
  55. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/observe-emitter/observe-emitter.js +106 -0
  56. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/rig/connection.d.ts +88 -0
  57. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/rig/connection.d.ts.map +1 -0
  58. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/rig/connection.js +86 -0
  59. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/rig/events.d.ts +83 -0
  60. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/rig/events.d.ts.map +1 -0
  61. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/rig/events.js +115 -0
  62. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/rig/hooks.d.ts +164 -0
  63. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/rig/hooks.d.ts.map +1 -0
  64. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/rig/hooks.js +67 -0
  65. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/rig/identity.d.ts +99 -0
  66. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/rig/identity.d.ts.map +1 -0
  67. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/rig/identity.js +190 -0
  68. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/rig/operation-handle.d.ts +185 -0
  69. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/rig/operation-handle.d.ts.map +1 -0
  70. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/rig/operation-handle.js +103 -0
  71. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/rig/reactions.d.ts +58 -0
  72. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/rig/reactions.d.ts.map +1 -0
  73. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/rig/reactions.js +64 -0
  74. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/rig/rig.d.ts +295 -0
  75. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/rig/rig.d.ts.map +1 -0
  76. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/rig/rig.js +898 -0
  77. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/rig/types.d.ts +167 -0
  78. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/rig/types.d.ts.map +1 -0
  79. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/rig/types.js +5 -0
  80. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/types/types.d.ts +278 -0
  81. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/types/types.d.ts.map +1 -0
  82. package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/types/types.js +89 -0
  83. package/esm/dispatch.d.ts +35 -0
  84. package/esm/dispatch.d.ts.map +1 -0
  85. package/esm/dispatch.js +40 -0
  86. package/esm/elasticsearch/mod.d.ts +31 -0
  87. package/esm/elasticsearch/mod.d.ts.map +1 -0
  88. package/esm/elasticsearch/mod.js +8 -0
  89. package/esm/elasticsearch/store.d.ts +44 -0
  90. package/esm/elasticsearch/store.d.ts.map +1 -0
  91. package/esm/elasticsearch/store.js +213 -0
  92. package/esm/entity-store.d.ts +106 -0
  93. package/esm/entity-store.d.ts.map +1 -0
  94. package/esm/entity-store.js +46 -0
  95. package/esm/entity.d.ts +125 -0
  96. package/esm/entity.d.ts.map +1 -0
  97. package/esm/entity.js +66 -0
  98. package/esm/errors.d.ts +23 -0
  99. package/esm/errors.d.ts.map +1 -0
  100. package/esm/errors.js +25 -0
  101. package/esm/fs/mod.d.ts +28 -0
  102. package/esm/fs/mod.d.ts.map +1 -0
  103. package/esm/fs/mod.js +13 -0
  104. package/esm/fs/store.d.ts +45 -0
  105. package/esm/fs/store.d.ts.map +1 -0
  106. package/esm/fs/store.js +194 -0
  107. package/esm/indexeddb/mod.d.ts +9 -0
  108. package/esm/indexeddb/mod.d.ts.map +1 -0
  109. package/esm/indexeddb/mod.js +8 -0
  110. package/esm/indexeddb/store.d.ts +47 -0
  111. package/esm/indexeddb/store.d.ts.map +1 -0
  112. package/esm/indexeddb/store.js +299 -0
  113. package/esm/ipfs/mod.d.ts +24 -0
  114. package/esm/ipfs/mod.d.ts.map +1 -0
  115. package/esm/ipfs/mod.js +13 -0
  116. package/esm/ipfs/store.d.ts +42 -0
  117. package/esm/ipfs/store.d.ts.map +1 -0
  118. package/esm/ipfs/store.js +197 -0
  119. package/esm/localstorage/mod.d.ts +9 -0
  120. package/esm/localstorage/mod.d.ts.map +1 -0
  121. package/esm/localstorage/mod.js +8 -0
  122. package/esm/localstorage/store.d.ts +45 -0
  123. package/esm/localstorage/store.d.ts.map +1 -0
  124. package/esm/localstorage/store.js +147 -0
  125. package/esm/memory/mod.d.ts +12 -0
  126. package/esm/memory/mod.d.ts.map +1 -0
  127. package/esm/memory/mod.js +11 -0
  128. package/esm/memory/store.d.ts +73 -0
  129. package/esm/memory/store.d.ts.map +1 -0
  130. package/esm/memory/store.js +300 -0
  131. package/esm/mod.d.ts +36 -0
  132. package/esm/mod.d.ts.map +1 -0
  133. package/esm/mod.js +31 -0
  134. package/esm/mongo/mod.d.ts +35 -0
  135. package/esm/mongo/mod.d.ts.map +1 -0
  136. package/esm/mongo/mod.js +8 -0
  137. package/esm/mongo/store.d.ts +42 -0
  138. package/esm/mongo/store.d.ts.map +1 -0
  139. package/esm/mongo/store.js +185 -0
  140. package/esm/package.json +3 -0
  141. package/esm/payload.d.ts +24 -0
  142. package/esm/payload.d.ts.map +1 -0
  143. package/esm/payload.js +30 -0
  144. package/esm/postgres/columns.d.ts +33 -0
  145. package/esm/postgres/columns.d.ts.map +1 -0
  146. package/esm/postgres/columns.js +51 -0
  147. package/esm/postgres/mod.d.ts +19 -0
  148. package/esm/postgres/mod.d.ts.map +1 -0
  149. package/esm/postgres/mod.js +9 -0
  150. package/esm/postgres/store.d.ts +75 -0
  151. package/esm/postgres/store.d.ts.map +1 -0
  152. package/esm/postgres/store.js +364 -0
  153. package/esm/read.d.ts +40 -0
  154. package/esm/read.d.ts.map +1 -0
  155. package/esm/read.js +67 -0
  156. package/esm/s3/mod.d.ts +23 -0
  157. package/esm/s3/mod.d.ts.map +1 -0
  158. package/esm/s3/mod.js +13 -0
  159. package/esm/s3/store.d.ts +46 -0
  160. package/esm/s3/store.d.ts.map +1 -0
  161. package/esm/s3/store.js +183 -0
  162. package/esm/sqlite/mod.d.ts +18 -0
  163. package/esm/sqlite/mod.d.ts.map +1 -0
  164. package/esm/sqlite/mod.js +8 -0
  165. package/esm/sqlite/schema.d.ts +10 -0
  166. package/esm/sqlite/schema.d.ts.map +1 -0
  167. package/esm/sqlite/schema.js +26 -0
  168. package/esm/sqlite/store.d.ts +42 -0
  169. package/esm/sqlite/store.d.ts.map +1 -0
  170. package/esm/sqlite/store.js +184 -0
  171. package/esm/types.d.ts +101 -0
  172. package/esm/types.d.ts.map +1 -0
  173. package/esm/types.js +21 -0
  174. package/esm/url.d.ts +108 -0
  175. package/esm/url.d.ts.map +1 -0
  176. package/esm/url.js +151 -0
  177. package/package.json +93 -0
@@ -0,0 +1,167 @@
1
+ /**
2
+ * @module
3
+ * Types for the b3nd Rig — the universal harness.
4
+ */
5
+ import type { CodeHandler, Program, ProtocolInterfaceNode } from "../types/types.js";
6
+ import type { HooksConfig } from "./hooks.js";
7
+ import type { EventHandler, RigEventName } from "./events.js";
8
+ import type { ReactionHandler } from "./reactions.js";
9
+ import type { Connection } from "./connection.js";
10
+ export type { ProtocolInterfaceNode };
11
+ /**
12
+ * Per-operation route bindings.
13
+ *
14
+ * Each route is an ordered list of connections. The rig treats the
15
+ * three routes independently:
16
+ *
17
+ * - `receive` — broadcast: a tuple lands at every connection whose
18
+ * pattern accepts its URI. Per-route outcomes surface as
19
+ * `route:success` / `route:error` on the operation handle.
20
+ * - `read` — sequential: per url, the first connection whose pattern
21
+ * accepts the routing key gets the request. No fall-through, no
22
+ * aggregation. Aggregation across sources is the job of an
23
+ * aggregating client (e.g. memcache + shards), not the rig.
24
+ * - `observe` — urls are grouped by the first matching connection;
25
+ * the rig multiplexes the per-connection streams into one.
26
+ *
27
+ * The same connection value can appear in multiple routes when one
28
+ * client serves all three with the same filter. A different filter
29
+ * for a different op means a separate `connection(...)` call.
30
+ */
31
+ export interface RigRoutes {
32
+ receive?: Connection[];
33
+ read?: Connection[];
34
+ observe?: Connection[];
35
+ }
36
+ /**
37
+ * Configuration for `new Rig()`.
38
+ *
39
+ * The rig is pure orchestration — build clients outside, hand them
40
+ * in via `routes`. Routes are the only way the rig learns about
41
+ * clients.
42
+ */
43
+ export interface RigConfig {
44
+ /**
45
+ * Routes — per-op connection lists.
46
+ *
47
+ * @example
48
+ * ```typescript
49
+ * const node = connection(httpClient, ["mutable://**", "hash://**"]);
50
+ *
51
+ * const rig = new Rig({
52
+ * routes: {
53
+ * receive: [node],
54
+ * read: [node],
55
+ * observe: [node],
56
+ * },
57
+ * });
58
+ * ```
59
+ */
60
+ routes: RigRoutes;
61
+ /**
62
+ * Programs — pure classifiers that return protocol-defined codes.
63
+ *
64
+ * Maps URI prefixes (e.g. `"store://balance"`) to Program functions.
65
+ * When a message arrives, the rig looks up the program for its URI,
66
+ * runs classification, and routes to the handler for the returned code.
67
+ *
68
+ * ```typescript
69
+ * const rig = new Rig({
70
+ * routes: { ... },
71
+ * programs: {
72
+ * "store://balance": balanceProgram,
73
+ * "msg://app": appMsgProgram,
74
+ * },
75
+ * handlers: {
76
+ * "app:valid": async (out) => [out],
77
+ * "app:confirmed": async (out, _result, read) => {
78
+ * // ...inspect state via read; return what to dispatch
79
+ * return [out];
80
+ * },
81
+ * },
82
+ * });
83
+ * ```
84
+ */
85
+ programs?: Record<string, Program>;
86
+ /**
87
+ * Code handlers — what to do when a program returns a specific code.
88
+ *
89
+ * Each handler returns `Output[]` — the tuples it wants the rig
90
+ * to dispatch through `routes.receive`. Handler emissions skip
91
+ * `process` (handlers are canonical interpreters); reactions run
92
+ * after broadcast lands.
93
+ */
94
+ handlers?: Record<string, CodeHandler>;
95
+ /**
96
+ * Hooks — frozen after construction, one function per slot.
97
+ *
98
+ * Before-hooks **throw** to reject (no silent aborts).
99
+ * After-hooks **observe** (cannot modify the result; throw if violated).
100
+ *
101
+ * @example
102
+ * ```typescript
103
+ * const rig = new Rig({
104
+ * routes: { ... },
105
+ * hooks: {
106
+ * beforeReceive: (ctx) => { validate(ctx.uri); },
107
+ * afterRead: (ctx, result) => { audit(ctx.uri, result); },
108
+ * },
109
+ * });
110
+ * ```
111
+ */
112
+ hooks?: HooksConfig;
113
+ /**
114
+ * Async event handlers — fire-and-forget after operations complete.
115
+ *
116
+ * Events never block the caller. Handler errors are caught and logged.
117
+ * Wildcard events (`*:success`, `*:error`) fire for all operations.
118
+ *
119
+ * @example
120
+ * ```typescript
121
+ * const rig = new Rig({
122
+ * routes: { ... },
123
+ * on: {
124
+ * "send:success": [audit, notifyPeers],
125
+ * "*:error": [alertOps],
126
+ * },
127
+ * });
128
+ * ```
129
+ */
130
+ on?: Partial<Record<RigEventName, EventHandler[]>>;
131
+ /**
132
+ * URI-pattern reactions — fire on successful writes.
133
+ *
134
+ * Patterns use the shared glob grammar: `*` matches one segment,
135
+ * `**` matches the rest. Handlers are fire-and-forget; if you need
136
+ * a segment value, extract it from `out[0]` inside the handler.
137
+ *
138
+ * @example
139
+ * ```typescript
140
+ * const rig = new Rig({
141
+ * routes: { ... },
142
+ * reactions: {
143
+ * "mutable://app/users/*": async (out, _read) => {
144
+ * const id = out[0].split("/").pop();
145
+ * return [[`notify://email/${id}`, { kind: "user-updated" }]];
146
+ * },
147
+ * },
148
+ * });
149
+ * ```
150
+ */
151
+ reactions?: Record<string, ReactionHandler>;
152
+ }
153
+ /**
154
+ * Snapshot of a Rig's current state — returned by `rig.info()`.
155
+ *
156
+ * Pure local inspection, no network calls. Useful for debugging,
157
+ * logging, and UI display of identity/capability status.
158
+ */
159
+ export interface RigInfo {
160
+ /** Behavior layer counts — hooks, events, and observers registered. */
161
+ behavior: {
162
+ hooks: string[];
163
+ events: Record<string, number>;
164
+ reactors: number;
165
+ };
166
+ }
167
+ //# sourceMappingURL=types.d.ts.map
@@ -0,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CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;CAC7C;AAED;;;;;GAKG;AACH,MAAM,WAAW,OAAO;IACtB,uEAAuE;IACvE,QAAQ,EAAE;QACR,KAAK,EAAE,MAAM,EAAE,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC/B,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;CACH"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @module
3
+ * Types for the b3nd Rig — the universal harness.
4
+ */
5
+ export {};
@@ -0,0 +1,278 @@
1
+ /**
2
+ * @b3nd/sdk Types
3
+ * Core types for the universal B3nd protocol interface
4
+ */
5
+ /**
6
+ * Result of a write operation
7
+ */
8
+ export interface WriteResult<T = unknown> {
9
+ success: boolean;
10
+ record?: {
11
+ data: T;
12
+ };
13
+ error?: string;
14
+ }
15
+ /**
16
+ * Result of a delete operation
17
+ */
18
+ export interface DeleteResult {
19
+ success: boolean;
20
+ error?: string;
21
+ errorDetail?: B3ndError;
22
+ }
23
+ /**
24
+ * Health status response
25
+ */
26
+ export interface HealthStatus {
27
+ status: "healthy" | "degraded" | "unhealthy";
28
+ message?: string;
29
+ details?: Record<string, unknown>;
30
+ }
31
+ /**
32
+ * Status response — replaces health() + getSchema().
33
+ * Each client reports its health + capabilities.
34
+ * The rig aggregates and adds schema info.
35
+ *
36
+ * `fns` advertises the set of named read functions this node supports,
37
+ * if its locator grammar defines such a concept. Provider-specific —
38
+ * the framework neither populates nor interprets it. Clients may use
39
+ * it to surface capability info to humans/diagnostic UIs.
40
+ */
41
+ export interface StatusResult {
42
+ status: "healthy" | "degraded" | "unhealthy";
43
+ message?: string;
44
+ schema?: string[];
45
+ fns?: string[];
46
+ details?: Record<string, unknown>;
47
+ }
48
+ /**
49
+ * Output — the universal addressed-content primitive: [uri, payload]
50
+ *
51
+ * The framework treats `payload` as opaque on both sides. The first
52
+ * element's meaning differs by direction:
53
+ *
54
+ * - **write** (`receive`, `send`, programs): `uri` is the canonical
55
+ * identifier the payload is written under.
56
+ * - **read** (`read` results): the first element echoes the caller's
57
+ * input locator so results pair positionally or by lookup. Payload
58
+ * shape is entirely the executing client's choice — what a miss
59
+ * looks like, what a listing yields, what an extension function
60
+ * returns, all defined by the client's locator-grammar contract.
61
+ */
62
+ export type Output<T = unknown> = [
63
+ uri: string,
64
+ payload: T
65
+ ];
66
+ /**
67
+ * Read function for storage lookups.
68
+ *
69
+ * Single-locator convenience used by program authors — wraps
70
+ * `read([locator])[0]`. Because `read` is 1:1 with its input, the
71
+ * tuple is always present. What "miss" looks like in the payload is up
72
+ * to the executing client; the type parameter `T` should reflect that
73
+ * (e.g. `T | undefined` if your client uses `undefined` for miss).
74
+ */
75
+ export type ReadFn = <T = unknown>(locator: string) => Promise<Output<T>>;
76
+ /**
77
+ * Receive function — batch of outputs through the rig pipeline.
78
+ */
79
+ export type ReceiveFn = (msgs: Output[]) => Promise<ReceiveResult[]>;
80
+ /**
81
+ * Program result — classification of a message by a program.
82
+ * Programs return protocol-defined codes, not binary valid/invalid.
83
+ */
84
+ export interface ProgramResult {
85
+ code: string;
86
+ error?: string;
87
+ }
88
+ /**
89
+ * Program — classifies a message and returns a protocol-defined code.
90
+ *
91
+ * Programs are pure classifiers with no side effects. A protocol ships its
92
+ * own programs as a closed package — sub-output classification is handled
93
+ * internally by the protocol, not by calling back into the rig.
94
+ *
95
+ * - `output` — the [uri, payload] being classified
96
+ * - `upstream` — the parent output (undefined at top level)
97
+ * - `read` — storage lookup (only confirmed state)
98
+ */
99
+ export type Program<T = unknown> = (output: Output<T>, upstream: Output | undefined, read: ReadFn) => Promise<ProgramResult>;
100
+ /**
101
+ * Code handler — what to do when a program returns a specific code.
102
+ *
103
+ * Handlers are pure transforms: they take the classified output and
104
+ * return the `Output[]` they want the Rig to dispatch. The Rig owns
105
+ * the wire — handlers never call broadcast directly.
106
+ *
107
+ * Common shapes:
108
+ * - persist: `return [out]` (the simple "write this" case)
109
+ * - decompose: `return [envelope, ...payload.outputs, ...deletions]`
110
+ * - conditional: `return existing.success ? [] : [out]`
111
+ * - refuse: `return []`
112
+ *
113
+ * - `out` — the classified output `[uri, payload]`
114
+ * - `result` — the `ProgramResult` that produced this code
115
+ * - `read` — storage lookup (confirmed state)
116
+ */
117
+ export type CodeHandler = (out: Output, result: ProgramResult, read: ReadFn) => Promise<Output[]>;
118
+ /**
119
+ * Result of a receive operation.
120
+ * `error` remains a string for backward compatibility.
121
+ * `errorDetail` provides structured error info for programmatic handling.
122
+ */
123
+ export interface ReceiveResult {
124
+ accepted: boolean;
125
+ error?: string;
126
+ errorDetail?: B3ndError;
127
+ }
128
+ /**
129
+ * ProtocolInterfaceNode — the universal interface implemented by all clients.
130
+ *
131
+ * Four primitives:
132
+ * - `receive` — all state changes (writes), addressed by **uri**
133
+ * - `read` — all queries, addressed by **locator**
134
+ * - `observe` — stream of changes, subscribed by **locator**
135
+ * - `status` — health + capabilities
136
+ *
137
+ * **URIs vs locators.** A *uri* is the canonical identifier of a
138
+ * resource — used for writes and emitted on observe so listeners learn
139
+ * which resource changed. A *locator* is any addressing string a caller
140
+ * passes to `read`/`observe`: it may be a bare uri, a pattern with
141
+ * wildcards, or a uri decorated with request-time directives. The
142
+ * framework treats locators as opaque — it routes them by string
143
+ * pattern matching and hands them to the executing client verbatim.
144
+ * What grammar (if any) a locator follows is a contract between the
145
+ * caller and the executing client.
146
+ *
147
+ * All B3nd clients (Memory, HTTP, WebSocket, Postgres, IndexedDB, etc.)
148
+ * implement this interface, enabling recursive composition and uniform usage.
149
+ */
150
+ export interface ProtocolInterfaceNode {
151
+ /**
152
+ * Receive a batch of outputs — the unified entry point for all state changes.
153
+ *
154
+ * Each output is `[uri, payload]` where `uri` is the canonical
155
+ * resource identifier the payload is written under. Clients interpret
156
+ * the payload per their role (storage clients persist, audit clients
157
+ * append, forwarders forward). Returns one `ReceiveResult` per output.
158
+ *
159
+ * The return type is `PromiseLike` (not `Promise`) so implementations
160
+ * can return richer await-targets — e.g., the Rig returns an
161
+ * `OperationHandle` that's awaitable AND exposes per-route events.
162
+ * Plain `Promise<ReceiveResult[]>` still satisfies the contract.
163
+ */
164
+ receive(msgs: Output[]): PromiseLike<ReceiveResult[]>;
165
+ /**
166
+ * Read a batch of locators.
167
+ *
168
+ * Locators are opaque to the framework: their grammar is a contract
169
+ * between the caller and the executing client. The rig routes each
170
+ * locator to the first connection whose pattern accepts it (pure
171
+ * string pattern matching, no normalization).
172
+ *
173
+ * **Shape: 1:1 with input.** Returns one `Output<T>` per input
174
+ * locator, in input order. Each output is `[inputLocator, payload]` —
175
+ * the first element echoes the caller's locator so results are
176
+ * addressable positionally or by lookup.
177
+ *
178
+ * Payload semantics are entirely the client's concern. What "not
179
+ * found" looks like, what listing shapes look like, what extension
180
+ * functions return — all defined by the executing client and agreed
181
+ * with its callers out-of-band.
182
+ *
183
+ * **Errors:** transport / programmer errors throw (network down, no
184
+ * route accepts, grammar violations the client rejects). Anything
185
+ * else — "not found", auth refusals, etc. — is encoded in the payload
186
+ * per the client's convention.
187
+ */
188
+ read<T = unknown>(locators: string[]): Promise<Output<T>[]>;
189
+ /**
190
+ * Observe a batch of locators. Yields INV-style batches of uris that
191
+ * changed under any subscribed pattern. The observer reads each uri
192
+ * to learn its current state.
193
+ *
194
+ * Locators are matched against emitted uris as segment-globs — pure
195
+ * string pattern matching, no grammar awareness. Each yield is a
196
+ * non-empty `readonly string[]` of concrete uris that fired in this
197
+ * batch. Which of the caller's subscription locators matched is not
198
+ * surfaced; the caller can re-match locally if it needs that routing,
199
+ * which keeps the wire (and in-process surface) minimal.
200
+ *
201
+ * The `signal` controls lifecycle — abort to stop observing.
202
+ *
203
+ * @example
204
+ * ```ts
205
+ * const abort = new AbortController();
206
+ * for await (const uris of client.observe(["mutable://market/**"], abort.signal)) {
207
+ * const outputs = await client.read(uris);
208
+ * for (const [uri, payload] of outputs) console.log(uri, payload);
209
+ * }
210
+ * ```
211
+ */
212
+ observe(locators: string[], signal: AbortSignal): AsyncIterable<readonly string[]>;
213
+ /**
214
+ * Status — health + capabilities.
215
+ * Clients report health. The rig aggregates and adds schema.
216
+ */
217
+ status(): Promise<StatusResult>;
218
+ }
219
+ /**
220
+ * Structured error codes for programmatic error handling.
221
+ * Callers can switch on `error.code` without string parsing.
222
+ */
223
+ export declare enum ErrorCode {
224
+ UNAUTHORIZED = "UNAUTHORIZED",
225
+ FORBIDDEN = "FORBIDDEN",
226
+ INVALID_URI = "INVALID_URI",
227
+ INVALID_SCHEMA = "INVALID_SCHEMA",
228
+ INVALID_SEQUENCE = "INVALID_SEQUENCE",
229
+ NOT_FOUND = "NOT_FOUND",
230
+ CONFLICT = "CONFLICT",
231
+ STORAGE_ERROR = "STORAGE_ERROR",
232
+ INTERNAL_ERROR = "INTERNAL_ERROR"
233
+ }
234
+ /**
235
+ * Structured error returned by protocol operations.
236
+ */
237
+ export interface B3ndError {
238
+ code: ErrorCode;
239
+ message: string;
240
+ uri?: string;
241
+ details?: unknown;
242
+ }
243
+ /**
244
+ * Convenience constructors for B3ndError
245
+ */
246
+ export declare const Errors: {
247
+ unauthorized: (uri: string, msg?: string) => B3ndError;
248
+ forbidden: (uri: string, msg?: string) => B3ndError;
249
+ invalidUri: (uri: string, msg?: string) => B3ndError;
250
+ invalidSchema: (uri: string, details?: unknown) => B3ndError;
251
+ invalidSequence: (uri: string, msg?: string) => B3ndError;
252
+ notFound: (uri: string) => B3ndError;
253
+ conflict: (uri: string, msg?: string) => B3ndError;
254
+ storageError: (msg: string, uri?: string) => B3ndError;
255
+ internal: (msg: string, uri?: string) => B3ndError;
256
+ };
257
+ /**
258
+ * Error class for client operations
259
+ * Preserves error context without hiding details
260
+ */
261
+ export declare class ClientError extends Error {
262
+ readonly code: string;
263
+ readonly details?: unknown | undefined;
264
+ constructor(message: string, code: string, details?: unknown | undefined);
265
+ }
266
+ /**
267
+ * Link value - just a string URI pointing to another resource
268
+ */
269
+ export type LinkValue = string;
270
+ /**
271
+ * Content-addressed data metadata (optional wrapper for hash:// data)
272
+ */
273
+ export interface ContentData<T = unknown> {
274
+ type?: string;
275
+ encoding?: string;
276
+ data: T;
277
+ }
278
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../../../src/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/types/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,OAAO;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,SAAS,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,SAAS,GAAG,UAAU,GAAG,WAAW,CAAC;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,SAAS,GAAG,UAAU,GAAG,WAAW,CAAC;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,GAAG,OAAO,IAAI;IAChC,GAAG,EAAE,MAAM;IACX,OAAO,EAAE,CAAC;CACX,CAA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AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAE/B;;GAEG;AACH,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,OAAO;IACtC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,CAAC,CAAC;CACT"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * @b3nd/sdk Types
3
+ * Core types for the universal B3nd protocol interface
4
+ */
5
+ /**
6
+ * Structured error codes for programmatic error handling.
7
+ * Callers can switch on `error.code` without string parsing.
8
+ */
9
+ export var ErrorCode;
10
+ (function (ErrorCode) {
11
+ // Auth errors
12
+ ErrorCode["UNAUTHORIZED"] = "UNAUTHORIZED";
13
+ ErrorCode["FORBIDDEN"] = "FORBIDDEN";
14
+ // Validation errors
15
+ ErrorCode["INVALID_URI"] = "INVALID_URI";
16
+ ErrorCode["INVALID_SCHEMA"] = "INVALID_SCHEMA";
17
+ ErrorCode["INVALID_SEQUENCE"] = "INVALID_SEQUENCE";
18
+ // State errors
19
+ ErrorCode["NOT_FOUND"] = "NOT_FOUND";
20
+ ErrorCode["CONFLICT"] = "CONFLICT";
21
+ // Internal errors
22
+ ErrorCode["STORAGE_ERROR"] = "STORAGE_ERROR";
23
+ ErrorCode["INTERNAL_ERROR"] = "INTERNAL_ERROR";
24
+ })(ErrorCode || (ErrorCode = {}));
25
+ /**
26
+ * Convenience constructors for B3ndError
27
+ */
28
+ export const Errors = {
29
+ unauthorized: (uri, msg) => ({
30
+ code: ErrorCode.UNAUTHORIZED,
31
+ message: msg ?? "Unauthorized",
32
+ uri,
33
+ }),
34
+ forbidden: (uri, msg) => ({
35
+ code: ErrorCode.FORBIDDEN,
36
+ message: msg ?? "Forbidden",
37
+ uri,
38
+ }),
39
+ invalidUri: (uri, msg) => ({
40
+ code: ErrorCode.INVALID_URI,
41
+ message: msg ?? "Invalid URI",
42
+ uri,
43
+ }),
44
+ invalidSchema: (uri, details) => ({
45
+ code: ErrorCode.INVALID_SCHEMA,
46
+ message: "Schema validation failed",
47
+ uri,
48
+ details,
49
+ }),
50
+ invalidSequence: (uri, msg) => ({
51
+ code: ErrorCode.INVALID_SEQUENCE,
52
+ message: msg ?? "Invalid sequence number",
53
+ uri,
54
+ }),
55
+ notFound: (uri) => ({
56
+ code: ErrorCode.NOT_FOUND,
57
+ message: `Not found: ${uri}`,
58
+ uri,
59
+ }),
60
+ conflict: (uri, msg) => ({
61
+ code: ErrorCode.CONFLICT,
62
+ message: msg ?? "Conflict",
63
+ uri,
64
+ }),
65
+ storageError: (msg, uri) => ({
66
+ code: ErrorCode.STORAGE_ERROR,
67
+ message: msg,
68
+ uri,
69
+ }),
70
+ internal: (msg, uri) => ({
71
+ code: ErrorCode.INTERNAL_ERROR,
72
+ message: msg,
73
+ uri,
74
+ }),
75
+ };
76
+ /**
77
+ * Error class for client operations
78
+ * Preserves error context without hiding details
79
+ */
80
+ export class ClientError extends Error {
81
+ code;
82
+ details;
83
+ constructor(message, code, details) {
84
+ super(message);
85
+ this.code = code;
86
+ this.details = details;
87
+ this.name = "ClientError";
88
+ }
89
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * URL dispatch helper for Store.read implementations.
3
+ *
4
+ * Every store parses the input url, switches on `fn`, and calls back
5
+ * into store-supplied handlers. Centralising the dispatch keeps the
6
+ * `read`/`ls`/`count`/`x-*` switch identical across stores so they
7
+ * cannot drift apart.
8
+ *
9
+ * Stores call `dispatchRead(urls, handlers)`; the helper handles
10
+ * parsing, the fn switch, and tuple assembly. Each handler receives
11
+ * the parsed url and returns the payload — the helper wraps it into
12
+ * `[inputUrl, payload]`.
13
+ */
14
+ import type { Output } from "./deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/types/types.js";
15
+ import type { ParsedUrl } from "./url.js";
16
+ export interface ReadHandlers {
17
+ /** Point read. Return `undefined` for a miss. */
18
+ read: (parsed: ParsedUrl) => unknown | Promise<unknown>;
19
+ /**
20
+ * List entries under a prefix. Return `Output[]` for `format=full`
21
+ * (default) or `string[]` for `format=uris`. Handler is responsible
22
+ * for honoring `params.format` itself — typically by calling
23
+ * `applyReadParams` from `./read.ts`.
24
+ */
25
+ ls: (parsed: ParsedUrl) => unknown | Promise<unknown>;
26
+ /** Count entries under a prefix. Return a number. */
27
+ count: (parsed: ParsedUrl) => number | Promise<number>;
28
+ /**
29
+ * Optional handler for provider-defined `x-*.*` extension fns.
30
+ * If absent, unknown fns throw.
31
+ */
32
+ ext?: (parsed: ParsedUrl) => unknown | Promise<unknown>;
33
+ }
34
+ export declare function dispatchRead<T = unknown>(urls: string[], storeName: string, handlers: ReadHandlers): Promise<Output<T>[]>;
35
+ //# sourceMappingURL=dispatch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../src/dispatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kEAAkE,CAAC;AAC/F,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAG1C,MAAM,WAAW,YAAY;IAC3B,iDAAiD;IACjD,IAAI,EAAE,CAAC,MAAM,EAAE,SAAS,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACxD;;;;;OAKG;IACH,EAAE,EAAE,CAAC,MAAM,EAAE,SAAS,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACtD,qDAAqD;IACrD,KAAK,EAAE,CAAC,MAAM,EAAE,SAAS,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACvD;;;OAGG;IACH,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,SAAS,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACzD;AAED,wBAAsB,YAAY,CAAC,CAAC,GAAG,OAAO,EAC5C,IAAI,EAAE,MAAM,EAAE,EACd,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,YAAY,GACrB,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAyBtB"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * URL dispatch helper for Store.read implementations.
3
+ *
4
+ * Every store parses the input url, switches on `fn`, and calls back
5
+ * into store-supplied handlers. Centralising the dispatch keeps the
6
+ * `read`/`ls`/`count`/`x-*` switch identical across stores so they
7
+ * cannot drift apart.
8
+ *
9
+ * Stores call `dispatchRead(urls, handlers)`; the helper handles
10
+ * parsing, the fn switch, and tuple assembly. Each handler receives
11
+ * the parsed url and returns the payload — the helper wraps it into
12
+ * `[inputUrl, payload]`.
13
+ */
14
+ import { parseUrl } from "./url.js";
15
+ export async function dispatchRead(urls, storeName, handlers) {
16
+ const out = [];
17
+ for (const url of urls) {
18
+ const parsed = parseUrl(url);
19
+ let payload;
20
+ switch (parsed.fn) {
21
+ case "read":
22
+ payload = await handlers.read(parsed);
23
+ break;
24
+ case "ls":
25
+ payload = await handlers.ls(parsed);
26
+ break;
27
+ case "count":
28
+ payload = await handlers.count(parsed);
29
+ break;
30
+ default:
31
+ if (parsed.fn.startsWith("x-") && handlers.ext) {
32
+ payload = await handlers.ext(parsed);
33
+ break;
34
+ }
35
+ throw new Error(`${storeName}: unsupported fn '${parsed.fn}'`);
36
+ }
37
+ out.push([url, payload]);
38
+ }
39
+ return out;
40
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Elasticsearch backend for b3nd.
3
+ *
4
+ * Store implementation backed by Elasticsearch. Requires an injected
5
+ * ElasticsearchExecutor so the package does not depend on a specific
6
+ * ES client.
7
+ */
8
+ export interface ElasticsearchClientConfig {
9
+ /** Index name prefix for b3nd data (e.g., "b3nd") */
10
+ indexPrefix: string;
11
+ }
12
+ export interface ElasticsearchSearchResult {
13
+ hits: Array<{
14
+ _id: string;
15
+ _source?: Record<string, unknown>;
16
+ }>;
17
+ }
18
+ export interface ElasticsearchExecutor {
19
+ index: (index: string, id: string, body: Record<string, unknown>) => Promise<void>;
20
+ get: (index: string, id: string) => Promise<Record<string, unknown> | null>;
21
+ search: (index: string, body: Record<string, unknown>) => Promise<ElasticsearchSearchResult>;
22
+ /**
23
+ * Count documents matching a query. Maps to the ES `_count` endpoint.
24
+ */
25
+ count: (index: string, body: Record<string, unknown>) => Promise<number>;
26
+ delete: (index: string, id: string) => Promise<void>;
27
+ ping: () => Promise<boolean>;
28
+ cleanup?: () => Promise<void>;
29
+ }
30
+ export { ElasticsearchStore } from "./store.js";
31
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/elasticsearch/mod.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,WAAW,yBAAyB;IACxC,qDAAqD;IACrD,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,KAAK,CACT;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CACnD,CAAC;CACH;AAED,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,CACL,KAAK,EAAE,MAAM,EACb,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC1B,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,GAAG,EAAE,CACH,KAAK,EAAE,MAAM,EACb,EAAE,EAAE,MAAM,KACP,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;IAC7C,MAAM,EAAE,CACN,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC1B,OAAO,CAAC,yBAAyB,CAAC,CAAC;IACxC;;OAEG;IACH,KAAK,EAAE,CACL,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC1B,OAAO,CAAC,MAAM,CAAC,CAAC;IACrB,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,IAAI,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/B;AAED,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Elasticsearch backend for b3nd.
3
+ *
4
+ * Store implementation backed by Elasticsearch. Requires an injected
5
+ * ElasticsearchExecutor so the package does not depend on a specific
6
+ * ES client.
7
+ */
8
+ export { ElasticsearchStore } from "./store.js";