@loams/client 0.1.0 → 0.1.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 (45) hide show
  1. package/README.md +78 -2
  2. package/dist/app.d.ts +149 -0
  3. package/dist/app.js +317 -0
  4. package/dist/builders/filter.d.ts +96 -0
  5. package/dist/builders/filter.js +190 -0
  6. package/dist/builders/schema.d.ts +50 -0
  7. package/dist/builders/schema.js +92 -0
  8. package/dist/builders/search.d.ts +159 -0
  9. package/dist/builders/search.js +307 -0
  10. package/dist/gen/facade.d.ts +267 -2
  11. package/dist/gen/facade.js +194 -0
  12. package/dist/handle.d.ts +67 -0
  13. package/dist/handle.js +107 -0
  14. package/dist/index.d.ts +12 -5
  15. package/dist/index.js +12 -3
  16. package/dist/loams.d.ts +77 -2
  17. package/dist/loams.js +84 -6
  18. package/dist/runtime/batch.d.ts +29 -0
  19. package/dist/runtime/batch.js +95 -0
  20. package/dist/runtime/call.d.ts +63 -9
  21. package/dist/runtime/call.js +243 -41
  22. package/dist/runtime/consistency.d.ts +65 -11
  23. package/dist/runtime/consistency.js +212 -46
  24. package/dist/runtime/errors.d.ts +29 -2
  25. package/dist/runtime/errors.js +26 -0
  26. package/dist/runtime/pagination.js +8 -2
  27. package/dist/runtime/subscribe.d.ts +37 -0
  28. package/dist/runtime/subscribe.js +128 -0
  29. package/dist/vendor/proto/collection-v1.d.ts +3 -0
  30. package/dist/vendor/proto/collection-v1.js +7 -0
  31. package/dist/vendor/proto/gen/loams/collection/v1/collection_pb.d.ts +1610 -0
  32. package/dist/vendor/proto/gen/loams/collection/v1/collection_pb.js +399 -0
  33. package/dist/vendor/proto/gen/loams/collection/v1/document_pb.d.ts +1054 -0
  34. package/dist/vendor/proto/gen/loams/collection/v1/document_pb.js +327 -0
  35. package/dist/vendor/proto/gen/loams/collection/v1/query_pb.d.ts +2101 -0
  36. package/dist/vendor/proto/gen/loams/collection/v1/query_pb.js +608 -0
  37. package/dist/vendor/proto/gen/loams/graph/v1/graph_pb.d.ts +2299 -0
  38. package/dist/vendor/proto/gen/loams/graph/v1/graph_pb.js +596 -0
  39. package/dist/vendor/proto/gen/loams/operations/v1/operations_pb.d.ts +399 -0
  40. package/dist/vendor/proto/gen/loams/operations/v1/operations_pb.js +118 -0
  41. package/dist/vendor/proto/gen/loams/sql/v1/sql_pb.d.ts +182 -0
  42. package/dist/vendor/proto/gen/loams/sql/v1/sql_pb.js +72 -0
  43. package/dist/vendor/proto/gen/loams/stream/v1/stream_pb.d.ts +688 -0
  44. package/dist/vendor/proto/gen/loams/stream/v1/stream_pb.js +180 -0
  45. package/package.json +2 -2
@@ -14,8 +14,12 @@
14
14
  export const PROTO_REV = 'v1';
15
15
  import { AgentService, AuditService, KeyService, OrgService, ProjectService } from '../vendor/proto/admin.js';
16
16
  import { AuthService } from '../vendor/proto/gen/loams/auth/v1/auth_pb.js';
17
+ import { CollectionService, DocumentService, NamespaceService, QueryService } from '../vendor/proto/collection-v1.js';
18
+ import { GraphAdminService, GraphService } from '../vendor/proto/gen/loams/graph/v1/graph_pb.js';
17
19
  import { InstanceService } from '../vendor/proto/gen/loams/instance/v1/instance_pb.js';
18
20
  import { LiveAdminService, LiveService } from '@loams/live/live';
21
+ import { SqlService } from '../vendor/proto/gen/loams/sql/v1/sql_pb.js';
22
+ import { StreamService } from '../vendor/proto/gen/loams/stream/v1/stream_pb.js';
19
23
  /** Every annotated service, as the module catalogue. Order is by module name. */
20
24
  export const MODULES = [
21
25
  {
@@ -120,6 +124,62 @@ export const MODULES = [
120
124
  { module: 'auth', name: 'listProviders', protoName: 'listProviders', method: 'ListProviders', rpc: 'loams.auth.v1.AuthService/ListProviders', service: 'loams.auth.v1.AuthService', package: 'loams.auth.v1', idempotency: 'no_side_effects', retry: 'safe', streaming: 'unary', pagination: null },
121
125
  ],
122
126
  },
127
+ {
128
+ name: 'collections',
129
+ summary: 'Collections: schema, aliases, versions, scan plans and the hot tier.',
130
+ service: 'loams.collection.v1.CollectionService',
131
+ package: 'loams.collection.v1',
132
+ unstable: false,
133
+ derived: false,
134
+ calls: [
135
+ { module: 'collections', name: 'addFields', protoName: 'add_fields', method: 'AddFields', rpc: 'loams.collection.v1.CollectionService/AddFields', service: 'loams.collection.v1.CollectionService', package: 'loams.collection.v1', idempotency: 'none', retry: 'safe', streaming: 'unary', pagination: null },
136
+ { module: 'collections', name: 'create', protoName: 'create', method: 'CreateCollection', rpc: 'loams.collection.v1.CollectionService/CreateCollection', service: 'loams.collection.v1.CollectionService', package: 'loams.collection.v1', idempotency: 'none', retry: 'safe', streaming: 'unary', pagination: null },
137
+ { module: 'collections', name: 'drop', protoName: 'drop', method: 'DropCollection', rpc: 'loams.collection.v1.CollectionService/DropCollection', service: 'loams.collection.v1.CollectionService', package: 'loams.collection.v1', idempotency: 'none', retry: 'safe', streaming: 'unary', pagination: null },
138
+ { module: 'collections', name: 'get', protoName: 'get', method: 'GetCollection', rpc: 'loams.collection.v1.CollectionService/GetCollection', service: 'loams.collection.v1.CollectionService', package: 'loams.collection.v1', idempotency: 'no_side_effects', retry: 'safe', streaming: 'unary', pagination: null },
139
+ { module: 'collections', name: 'list', protoName: 'list', method: 'ListCollections', rpc: 'loams.collection.v1.CollectionService/ListCollections', service: 'loams.collection.v1.CollectionService', package: 'loams.collection.v1', idempotency: 'no_side_effects', retry: 'safe', streaming: 'unary', pagination: { items: 'collections', nextPageToken: 'nextPageToken' } },
140
+ { module: 'collections', name: 'listVersions', protoName: 'list_versions', method: 'ListVersions', rpc: 'loams.collection.v1.CollectionService/ListVersions', service: 'loams.collection.v1.CollectionService', package: 'loams.collection.v1', idempotency: 'no_side_effects', retry: 'safe', streaming: 'unary', pagination: { items: 'versions', nextPageToken: 'nextPageToken' } },
141
+ { module: 'collections', name: 'scan', protoName: 'scan', method: 'Scan', rpc: 'loams.collection.v1.CollectionService/Scan', service: 'loams.collection.v1.CollectionService', package: 'loams.collection.v1', idempotency: 'none', retry: 'manual', streaming: 'unary', pagination: null },
142
+ { module: 'collections', name: 'setHot', protoName: 'set_hot', method: 'SetHot', rpc: 'loams.collection.v1.CollectionService/SetHot', service: 'loams.collection.v1.CollectionService', package: 'loams.collection.v1', idempotency: 'none', retry: 'safe', streaming: 'unary', pagination: null },
143
+ { module: 'collections', name: 'updateAliases', protoName: 'update_aliases', method: 'UpdateAliases', rpc: 'loams.collection.v1.CollectionService/UpdateAliases', service: 'loams.collection.v1.CollectionService', package: 'loams.collection.v1', idempotency: 'none', retry: 'safe', streaming: 'unary', pagination: null },
144
+ { module: 'collections', name: 'warm', protoName: 'warm', method: 'WarmCollection', rpc: 'loams.collection.v1.CollectionService/WarmCollection', service: 'loams.collection.v1.CollectionService', package: 'loams.collection.v1', idempotency: 'none', retry: 'safe', streaming: 'unary', pagination: null },
145
+ ],
146
+ },
147
+ {
148
+ name: 'documents',
149
+ summary: 'Documents: write, get, scroll, count, delete by filter and patch by filter.',
150
+ service: 'loams.collection.v1.DocumentService',
151
+ package: 'loams.collection.v1',
152
+ unstable: false,
153
+ derived: false,
154
+ calls: [
155
+ { module: 'documents', name: 'count', protoName: 'count', method: 'CountDocuments', rpc: 'loams.collection.v1.DocumentService/CountDocuments', service: 'loams.collection.v1.DocumentService', package: 'loams.collection.v1', idempotency: 'no_side_effects', retry: 'safe', streaming: 'unary', pagination: null },
156
+ { module: 'documents', name: 'deleteByFilter', protoName: 'delete_by_filter', method: 'DeleteByFilter', rpc: 'loams.collection.v1.DocumentService/DeleteByFilter', service: 'loams.collection.v1.DocumentService', package: 'loams.collection.v1', idempotency: 'none', retry: 'manual', streaming: 'unary', pagination: null },
157
+ { module: 'documents', name: 'get', protoName: 'get', method: 'GetDocuments', rpc: 'loams.collection.v1.DocumentService/GetDocuments', service: 'loams.collection.v1.DocumentService', package: 'loams.collection.v1', idempotency: 'no_side_effects', retry: 'safe', streaming: 'unary', pagination: null },
158
+ { module: 'documents', name: 'patchByFilter', protoName: 'patch_by_filter', method: 'PatchByFilter', rpc: 'loams.collection.v1.DocumentService/PatchByFilter', service: 'loams.collection.v1.DocumentService', package: 'loams.collection.v1', idempotency: 'none', retry: 'manual', streaming: 'unary', pagination: null },
159
+ { module: 'documents', name: 'scroll', protoName: 'scroll', method: 'ScrollDocuments', rpc: 'loams.collection.v1.DocumentService/ScrollDocuments', service: 'loams.collection.v1.DocumentService', package: 'loams.collection.v1', idempotency: 'no_side_effects', retry: 'safe', streaming: 'unary', pagination: null },
160
+ { module: 'documents', name: 'write', protoName: 'write', method: 'WriteDocuments', rpc: 'loams.collection.v1.DocumentService/WriteDocuments', service: 'loams.collection.v1.DocumentService', package: 'loams.collection.v1', idempotency: 'none', retry: 'manual', streaming: 'unary', pagination: null },
161
+ ],
162
+ },
163
+ {
164
+ name: 'graph',
165
+ summary: 'Loams Graph: stored property graphs, queried with GQL.',
166
+ service: 'loams.graph.v1.GraphAdminService',
167
+ package: 'loams.graph.v1',
168
+ unstable: true,
169
+ derived: false,
170
+ calls: [
171
+ { module: 'graph', name: 'create', protoName: 'create', method: 'CreateGraph', rpc: 'loams.graph.v1.GraphAdminService/CreateGraph', service: 'loams.graph.v1.GraphAdminService', package: 'loams.graph.v1', idempotency: 'none', retry: 'manual', streaming: 'unary', pagination: null },
172
+ { module: 'graph', name: 'delete', protoName: 'delete', method: 'DeleteGraph', rpc: 'loams.graph.v1.GraphAdminService/DeleteGraph', service: 'loams.graph.v1.GraphAdminService', package: 'loams.graph.v1', idempotency: 'none', retry: 'manual', streaming: 'unary', pagination: null },
173
+ { module: 'graph', name: 'explain', protoName: 'explain', method: 'Explain', rpc: 'loams.graph.v1.GraphService/Explain', service: 'loams.graph.v1.GraphService', package: 'loams.graph.v1', idempotency: 'none', retry: 'safe', streaming: 'unary', pagination: null },
174
+ { module: 'graph', name: 'get', protoName: 'get', method: 'GetGraph', rpc: 'loams.graph.v1.GraphAdminService/GetGraph', service: 'loams.graph.v1.GraphAdminService', package: 'loams.graph.v1', idempotency: 'no_side_effects', retry: 'safe', streaming: 'unary', pagination: null },
175
+ { module: 'graph', name: 'list', protoName: 'list', method: 'ListGraphs', rpc: 'loams.graph.v1.GraphAdminService/ListGraphs', service: 'loams.graph.v1.GraphAdminService', package: 'loams.graph.v1', idempotency: 'no_side_effects', retry: 'safe', streaming: 'unary', pagination: { items: 'graphs', nextPageToken: 'nextPageToken' } },
176
+ { module: 'graph', name: 'query', protoName: 'query', method: 'Execute', rpc: 'loams.graph.v1.GraphService/Execute', service: 'loams.graph.v1.GraphService', package: 'loams.graph.v1', idempotency: 'none', retry: 'manual', streaming: 'unary', pagination: null },
177
+ { module: 'graph', name: 'queryBatch', protoName: 'query_batch', method: 'ExecuteBatch', rpc: 'loams.graph.v1.GraphService/ExecuteBatch', service: 'loams.graph.v1.GraphService', package: 'loams.graph.v1', idempotency: 'none', retry: 'manual', streaming: 'unary', pagination: null },
178
+ { module: 'graph', name: 'queryStream', protoName: 'query_stream', method: 'ExecuteStream', rpc: 'loams.graph.v1.GraphService/ExecuteStream', service: 'loams.graph.v1.GraphService', package: 'loams.graph.v1', idempotency: 'none', retry: 'manual', streaming: 'server', pagination: null },
179
+ { module: 'graph', name: 'schema', protoName: 'schema', method: 'GetSchema', rpc: 'loams.graph.v1.GraphAdminService/GetSchema', service: 'loams.graph.v1.GraphAdminService', package: 'loams.graph.v1', idempotency: 'no_side_effects', retry: 'safe', streaming: 'unary', pagination: null },
180
+ { module: 'graph', name: 'update', protoName: 'update', method: 'UpdateGraph', rpc: 'loams.graph.v1.GraphAdminService/UpdateGraph', service: 'loams.graph.v1.GraphAdminService', package: 'loams.graph.v1', idempotency: 'none', retry: 'manual', streaming: 'unary', pagination: null },
181
+ ],
182
+ },
123
183
  {
124
184
  name: 'instance',
125
185
  summary: 'What this instance is, and who the caller is on it.',
@@ -166,6 +226,58 @@ export const MODULES = [
166
226
  { module: 'live.admin', name: 'updateApp', protoName: 'updateApp', method: 'UpdateApp', rpc: 'loams.live.v1.LiveAdminService/UpdateApp', service: 'loams.live.v1.LiveAdminService', package: 'loams.live.v1', idempotency: 'none', retry: 'manual', streaming: 'unary', pagination: null },
167
227
  ],
168
228
  },
229
+ {
230
+ name: 'namespaces',
231
+ summary: 'Namespaces: the container every collection and stream lives in.',
232
+ service: 'loams.collection.v1.NamespaceService',
233
+ package: 'loams.collection.v1',
234
+ unstable: false,
235
+ derived: false,
236
+ calls: [
237
+ { module: 'namespaces', name: 'create', protoName: 'create', method: 'CreateNamespace', rpc: 'loams.collection.v1.NamespaceService/CreateNamespace', service: 'loams.collection.v1.NamespaceService', package: 'loams.collection.v1', idempotency: 'none', retry: 'safe', streaming: 'unary', pagination: null },
238
+ { module: 'namespaces', name: 'list', protoName: 'list', method: 'ListNamespaces', rpc: 'loams.collection.v1.NamespaceService/ListNamespaces', service: 'loams.collection.v1.NamespaceService', package: 'loams.collection.v1', idempotency: 'no_side_effects', retry: 'safe', streaming: 'unary', pagination: { items: 'namespaces', nextPageToken: 'nextPageToken' } },
239
+ ],
240
+ },
241
+ {
242
+ name: 'search',
243
+ summary: 'Queries: one search over one collection, dense, sparse, text or hybrid.',
244
+ service: 'loams.collection.v1.QueryService',
245
+ package: 'loams.collection.v1',
246
+ unstable: false,
247
+ derived: false,
248
+ calls: [
249
+ { module: 'search', name: 'query', protoName: 'query', method: 'Search', rpc: 'loams.collection.v1.QueryService/Search', service: 'loams.collection.v1.QueryService', package: 'loams.collection.v1', idempotency: 'no_side_effects', retry: 'safe', streaming: 'unary', pagination: null },
250
+ ],
251
+ },
252
+ {
253
+ name: 'sql',
254
+ summary: 'SQL: one read-only statement over a namespace\'s collections, with parameters.',
255
+ service: 'loams.sql.v1.SqlService',
256
+ package: 'loams.sql.v1',
257
+ unstable: false,
258
+ derived: false,
259
+ calls: [
260
+ { module: 'sql', name: 'query', protoName: 'query', method: 'Query', rpc: 'loams.sql.v1.SqlService/Query', service: 'loams.sql.v1.SqlService', package: 'loams.sql.v1', idempotency: 'no_side_effects', retry: 'safe', streaming: 'unary', pagination: null },
261
+ { module: 'sql', name: 'queryArrow', protoName: 'query_arrow', method: 'QueryArrow', rpc: 'loams.sql.v1.SqlService/QueryArrow', service: 'loams.sql.v1.SqlService', package: 'loams.sql.v1', idempotency: 'no_side_effects', retry: 'safe', streaming: 'unary', pagination: null },
262
+ ],
263
+ },
264
+ {
265
+ name: 'streams',
266
+ summary: 'Streams: create, list and describe a namespace\'s logs; produce and fetch records and CloudEvents.',
267
+ service: 'loams.stream.v1.StreamService',
268
+ package: 'loams.stream.v1',
269
+ unstable: false,
270
+ derived: false,
271
+ calls: [
272
+ { module: 'streams', name: 'create', protoName: 'create', method: 'CreateStream', rpc: 'loams.stream.v1.StreamService/CreateStream', service: 'loams.stream.v1.StreamService', package: 'loams.stream.v1', idempotency: 'none', retry: 'safe', streaming: 'unary', pagination: null },
273
+ { module: 'streams', name: 'fetch', protoName: 'fetch', method: 'Fetch', rpc: 'loams.stream.v1.StreamService/Fetch', service: 'loams.stream.v1.StreamService', package: 'loams.stream.v1', idempotency: 'no_side_effects', retry: 'safe', streaming: 'unary', pagination: null },
274
+ { module: 'streams', name: 'fetchEvents', protoName: 'fetch_events', method: 'FetchCloudEvents', rpc: 'loams.stream.v1.StreamService/FetchCloudEvents', service: 'loams.stream.v1.StreamService', package: 'loams.stream.v1', idempotency: 'no_side_effects', retry: 'safe', streaming: 'unary', pagination: null },
275
+ { module: 'streams', name: 'get', protoName: 'get', method: 'DescribeStream', rpc: 'loams.stream.v1.StreamService/DescribeStream', service: 'loams.stream.v1.StreamService', package: 'loams.stream.v1', idempotency: 'no_side_effects', retry: 'safe', streaming: 'unary', pagination: null },
276
+ { module: 'streams', name: 'list', protoName: 'list', method: 'ListStreams', rpc: 'loams.stream.v1.StreamService/ListStreams', service: 'loams.stream.v1.StreamService', package: 'loams.stream.v1', idempotency: 'no_side_effects', retry: 'safe', streaming: 'unary', pagination: { items: 'streams', nextPageToken: 'nextPageToken' } },
277
+ { module: 'streams', name: 'produce', protoName: 'produce', method: 'Produce', rpc: 'loams.stream.v1.StreamService/Produce', service: 'loams.stream.v1.StreamService', package: 'loams.stream.v1', idempotency: 'none', retry: 'manual', streaming: 'unary', pagination: null },
278
+ { module: 'streams', name: 'produceEvents', protoName: 'produce_events', method: 'ProduceCloudEvents', rpc: 'loams.stream.v1.StreamService/ProduceCloudEvents', service: 'loams.stream.v1.StreamService', package: 'loams.stream.v1', idempotency: 'none', retry: 'manual', streaming: 'unary', pagination: null },
279
+ ],
280
+ },
169
281
  {
170
282
  name: 'tables',
171
283
  summary: '',
@@ -178,6 +290,17 @@ export const MODULES = [
178
290
  { module: 'tables', name: 'query', protoName: 'query', method: 'Query', rpc: 'loams.live.v1.LiveService/Query', service: 'loams.live.v1.LiveService', package: 'loams.live.v1', idempotency: 'none', retry: 'manual', streaming: 'unary', pagination: null },
179
291
  ],
180
292
  },
293
+ {
294
+ name: 'vector',
295
+ summary: '',
296
+ service: 'loams.collection.v1.QueryService',
297
+ package: 'loams.collection.v1',
298
+ unstable: false,
299
+ derived: true,
300
+ calls: [
301
+ { module: 'vector', name: 'search', protoName: 'search', method: 'Search', rpc: 'loams.collection.v1.QueryService/Search', service: 'loams.collection.v1.QueryService', package: 'loams.collection.v1', idempotency: 'no_side_effects', retry: 'safe', streaming: 'unary', pagination: null },
302
+ ],
303
+ },
181
304
  ];
182
305
  /**
183
306
  * The generated service descriptors, by fully qualified name. The runtime
@@ -192,9 +315,17 @@ export const SERVICE_DESCRIPTORS = {
192
315
  'loams.admin.v1.OrgService': OrgService,
193
316
  'loams.admin.v1.ProjectService': ProjectService,
194
317
  'loams.auth.v1.AuthService': AuthService,
318
+ 'loams.collection.v1.CollectionService': CollectionService,
319
+ 'loams.collection.v1.DocumentService': DocumentService,
320
+ 'loams.collection.v1.NamespaceService': NamespaceService,
321
+ 'loams.collection.v1.QueryService': QueryService,
322
+ 'loams.graph.v1.GraphAdminService': GraphAdminService,
323
+ 'loams.graph.v1.GraphService': GraphService,
195
324
  'loams.instance.v1.InstanceService': InstanceService,
196
325
  'loams.live.v1.LiveAdminService': LiveAdminService,
197
326
  'loams.live.v1.LiveService': LiveService,
327
+ 'loams.sql.v1.SqlService': SqlService,
328
+ 'loams.stream.v1.StreamService': StreamService,
198
329
  };
199
330
  /** The proto packages this SDK speaks, as `GetInstance.api_versions` names them. */
200
331
  export const PROTO_PACKAGES = [
@@ -210,11 +341,14 @@ export const PROTO_PACKAGES = [
210
341
  'loams.instance.v1',
211
342
  'loams.live.v1',
212
343
  'loams.live.worker.v1',
344
+ 'loams.memory.v1',
213
345
  'loams.notifications.v1',
214
346
  'loams.operations.v1',
215
347
  'loams.options.v1',
216
348
  'loams.postgres.v1',
217
349
  'loams.repos.v1',
350
+ 'loams.sql.v1',
351
+ 'loams.stream.v1',
218
352
  ];
219
353
  /**
220
354
  * Every `reason` in `docs/api/reasons.md` (design §44 §7.4, D611). Within
@@ -271,6 +405,7 @@ export const REASONS = [
271
405
  'idempotency_key_reused',
272
406
  'workspace_not_found',
273
407
  'workspace_fenced',
408
+ 'batch_partially_applied',
274
409
  'workspace_read_only',
275
410
  'workspace_name_taken',
276
411
  'object_missing',
@@ -278,17 +413,46 @@ export const REASONS = [
278
413
  'env_unsealed',
279
414
  'env_access_denied',
280
415
  'env_foreign_reference',
416
+ 'memory_store_not_found',
417
+ 'memory_space_not_found',
418
+ 'memory_space_limit',
419
+ 'memory_managed_object',
420
+ 'memory_block_version_mismatch',
421
+ 'memory_block_too_large',
422
+ 'memory_core_budget_exceeded',
423
+ 'memory_content_too_large',
424
+ 'memory_secret_detected',
425
+ 'memory_pii_refused',
426
+ 'memory_model_not_configured',
427
+ 'memory_model_not_local',
428
+ 'memory_token_budget_exhausted',
429
+ 'memory_extraction_failed',
430
+ 'memory_too_many_spaces',
431
+ 'memory_cross_space_write',
432
+ 'memory_not_yet_available',
433
+ 'code_repo_not_indexed',
434
+ 'code_index_building',
435
+ 'code_change_too_large',
436
+ 'code_language_unsupported',
437
+ 'code_scip_invalid',
281
438
  'live_bad_cursor',
282
439
  'live_worker_crashed',
283
440
  'live_deploy_conflict',
284
441
  'live_schema_violation',
442
+ 'filter_conflict',
443
+ 'search_after_needs_tiebreak',
444
+ 'invalid_consistency_token',
445
+ 'namespace_required',
446
+ 'sql_param_count',
285
447
  'live_index_not_ready',
286
448
  'live_app_disabled',
287
449
  'live_app_exists',
288
450
  'live_function_error',
289
451
  'live_function_timeout',
452
+ 'client_deadline_exceeded',
290
453
  'live_function_out_of_memory',
291
454
  'live_limit_exceeded',
455
+ 'result_too_large',
292
456
  'live_app_mismatch',
293
457
  'live_origin_not_allowed',
294
458
  'session_rotate',
@@ -376,6 +540,7 @@ export const REASON_CODES = {
376
540
  idempotency_key_reused: 'failed_precondition',
377
541
  workspace_not_found: 'not_found',
378
542
  workspace_fenced: 'aborted',
543
+ batch_partially_applied: 'aborted',
379
544
  workspace_read_only: 'failed_precondition',
380
545
  workspace_name_taken: 'already_exists',
381
546
  object_missing: 'failed_precondition',
@@ -383,17 +548,46 @@ export const REASON_CODES = {
383
548
  env_unsealed: 'invalid_argument',
384
549
  env_access_denied: 'permission_denied',
385
550
  env_foreign_reference: 'permission_denied',
551
+ memory_store_not_found: 'not_found',
552
+ memory_space_not_found: 'not_found',
553
+ memory_space_limit: 'resource_exhausted',
554
+ memory_managed_object: 'failed_precondition',
555
+ memory_block_version_mismatch: 'aborted',
556
+ memory_block_too_large: 'invalid_argument',
557
+ memory_core_budget_exceeded: 'resource_exhausted',
558
+ memory_content_too_large: 'invalid_argument',
559
+ memory_secret_detected: 'failed_precondition',
560
+ memory_pii_refused: 'failed_precondition',
561
+ memory_model_not_configured: 'failed_precondition',
562
+ memory_model_not_local: 'failed_precondition',
563
+ memory_token_budget_exhausted: 'resource_exhausted',
564
+ memory_extraction_failed: 'failed_precondition',
565
+ memory_too_many_spaces: 'invalid_argument',
566
+ memory_cross_space_write: 'invalid_argument',
567
+ memory_not_yet_available: 'unimplemented',
568
+ code_repo_not_indexed: 'failed_precondition',
569
+ code_index_building: 'unavailable',
570
+ code_change_too_large: 'invalid_argument',
571
+ code_language_unsupported: 'failed_precondition',
572
+ code_scip_invalid: 'invalid_argument',
386
573
  live_bad_cursor: 'invalid_argument',
387
574
  live_worker_crashed: 'internal',
388
575
  live_deploy_conflict: 'failed_precondition',
389
576
  live_schema_violation: 'invalid_argument',
577
+ filter_conflict: 'invalid_argument',
578
+ search_after_needs_tiebreak: 'invalid_argument',
579
+ invalid_consistency_token: 'invalid_argument',
580
+ namespace_required: 'invalid_argument',
581
+ sql_param_count: 'invalid_argument',
390
582
  live_index_not_ready: 'failed_precondition',
391
583
  live_app_disabled: 'failed_precondition',
392
584
  live_app_exists: 'failed_precondition',
393
585
  live_function_error: 'unknown',
394
586
  live_function_timeout: 'deadline_exceeded',
587
+ client_deadline_exceeded: 'deadline_exceeded',
395
588
  live_function_out_of_memory: 'resource_exhausted',
396
589
  live_limit_exceeded: 'resource_exhausted',
590
+ result_too_large: 'resource_exhausted',
397
591
  live_app_mismatch: 'permission_denied',
398
592
  live_origin_not_allowed: 'permission_denied',
399
593
  session_rotate: 'unavailable',
@@ -0,0 +1,67 @@
1
+ import { type JsonObject } from '@bufbuild/protobuf';
2
+ import type { DocumentInput, PatchChange, ScrollOptions, Target, UnaryCall } from './app.js';
3
+ import type { DocId, FilterJson } from './builders/filter.js';
4
+ import { Search, type VectorOptions } from './builders/search.js';
5
+ import type { BatchOptions, BatchResult } from './runtime/batch.js';
6
+ import type { CallOptions } from './runtime/call.js';
7
+ /** The module calls a handle delegates to. Each is optional so a handle can
8
+ * be built over a facade that lacks a module; calling into a missing one is a
9
+ * clear error rather than a `TypeError`. */
10
+ export interface HandleModules {
11
+ documents?: {
12
+ upsert?: (target: Target, docs: DocumentInput[], options?: CallOptions) => Promise<unknown>;
13
+ delete?: (target: Target, ids: DocId[], options?: CallOptions) => Promise<unknown>;
14
+ patch?: (target: Target, id: DocId, change: PatchChange, options?: CallOptions) => Promise<unknown>;
15
+ writeBatch?: (target: Target, docs: Iterable<DocumentInput> | AsyncIterable<DocumentInput>, options?: BatchOptions & CallOptions) => Promise<BatchResult>;
16
+ scrollAll?: (target: Target, options?: ScrollOptions) => AsyncGenerator<unknown>;
17
+ get?: UnaryCall;
18
+ count?: UnaryCall;
19
+ };
20
+ search?: {
21
+ query?: UnaryCall;
22
+ };
23
+ collections?: {
24
+ get?: UnaryCall;
25
+ drop?: UnaryCall;
26
+ };
27
+ }
28
+ /** A collection, by name, with the document and search calls bound to it. */
29
+ export declare class CollectionHandle {
30
+ #private;
31
+ readonly name: string;
32
+ readonly namespace: string | undefined;
33
+ constructor(modules: HandleModules, name: string, options?: {
34
+ namespace?: string;
35
+ });
36
+ /** Writes (creates or replaces) documents. */
37
+ upsert(docs: DocumentInput[], options?: CallOptions): Promise<unknown>;
38
+ /** Reads documents by id. */
39
+ get(ids: DocId[], options?: CallOptions & {
40
+ select?: JsonObject;
41
+ }): Promise<any>;
42
+ /** Removes documents by id. */
43
+ delete(ids: DocId[], options?: CallOptions): Promise<unknown>;
44
+ /** Changes part of one document. */
45
+ patch(id: DocId, change: PatchChange, options?: CallOptions): Promise<unknown>;
46
+ /** A chunked bulk upsert (R13). */
47
+ writeBatch(docs: Iterable<DocumentInput> | AsyncIterable<DocumentInput>, options?: BatchOptions & CallOptions): Promise<BatchResult>;
48
+ /** How many documents match `where` (every document without one). */
49
+ count(options?: CallOptions & {
50
+ where?: FilterJson;
51
+ }): Promise<any>;
52
+ /** Every document, page by page. */
53
+ scrollAll(options?: ScrollOptions): AsyncGenerator<unknown, any, any>;
54
+ /** A search builder already pointed at this collection. */
55
+ query(): Search;
56
+ /** Runs a search; the builder's collection is replaced by this one. */
57
+ search(builder: Search, options?: CallOptions): Promise<any>;
58
+ /** A kNN search on one vector field. */
59
+ vectorSearch(field: string, vector: readonly number[], options?: CallOptions & VectorOptions & {
60
+ limit?: number;
61
+ filter?: FilterJson;
62
+ }): Promise<any>;
63
+ /** The collection's schema and stats. */
64
+ info(options?: CallOptions): Promise<any>;
65
+ /** Drops the collection. */
66
+ drop(options?: CallOptions): Promise<any>;
67
+ }
package/dist/handle.js ADDED
@@ -0,0 +1,107 @@
1
+ // The collection handle (SDKP §2.8).
2
+ //
3
+ // const notes = loams.collection('notes');
4
+ // await notes.upsert([{ id: 1, source: { title: 'Refunds' } }]);
5
+ // const hits = await notes.search(notes.query().text('refund', { fields: ['body'] }));
6
+ //
7
+ // Every call delegates to the module call of the same meaning with
8
+ // `collection` (and `namespace`, when the handle was given one) filled in. The
9
+ // handle holds no state of its own: two handles on the same collection are
10
+ // interchangeable, and a handle is as cheap as the object literal it is.
11
+ import { fromJson } from '@bufbuild/protobuf';
12
+ import { Code } from '@connectrpc/connect';
13
+ import { DocumentIdSchema } from './vendor/proto/gen/loams/collection/v1/document_pb.js';
14
+ import { Search } from './builders/search.js';
15
+ import { LoamsError } from './runtime/errors.js';
16
+ import { documentIdJson } from './app.js';
17
+ function need(fn, name) {
18
+ if (fn === undefined) {
19
+ throw new LoamsError(`this SDK's facade has no ${name}`, { code: Code.Unimplemented });
20
+ }
21
+ return fn;
22
+ }
23
+ /** A collection, by name, with the document and search calls bound to it. */
24
+ export class CollectionHandle {
25
+ name;
26
+ namespace;
27
+ #modules;
28
+ constructor(modules, name, options = {}) {
29
+ this.#modules = modules;
30
+ this.name = name;
31
+ this.namespace = options.namespace;
32
+ }
33
+ get #target() {
34
+ return this.namespace === undefined
35
+ ? { collection: this.name }
36
+ : { collection: this.name, namespace: this.namespace };
37
+ }
38
+ /** The request fields every call carries. */
39
+ get #fields() {
40
+ return this.#target;
41
+ }
42
+ /** Writes (creates or replaces) documents. */
43
+ upsert(docs, options) {
44
+ return need(this.#modules.documents?.upsert, 'documents.upsert')(this.#target, docs, options);
45
+ }
46
+ /** Reads documents by id. */
47
+ get(ids, options = {}) {
48
+ const { select, ...call } = options;
49
+ return need(this.#modules.documents?.get, 'documents.get')({
50
+ ...this.#fields,
51
+ ids: ids.map((id) => fromJson(DocumentIdSchema, documentIdJson(id))),
52
+ ...(select === undefined ? {} : { select }),
53
+ }, call);
54
+ }
55
+ /** Removes documents by id. */
56
+ delete(ids, options) {
57
+ return need(this.#modules.documents?.delete, 'documents.delete')(this.#target, ids, options);
58
+ }
59
+ /** Changes part of one document. */
60
+ patch(id, change, options) {
61
+ return need(this.#modules.documents?.patch, 'documents.patch')(this.#target, id, change, options);
62
+ }
63
+ /** A chunked bulk upsert (R13). */
64
+ writeBatch(docs, options) {
65
+ return need(this.#modules.documents?.writeBatch, 'documents.writeBatch')(this.#target, docs, options);
66
+ }
67
+ /** How many documents match `where` (every document without one). */
68
+ count(options = {}) {
69
+ const { where, ...call } = options;
70
+ return need(this.#modules.documents?.count, 'documents.count')({ ...this.#fields, ...(where === undefined ? {} : { where }) }, call);
71
+ }
72
+ /** Every document, page by page. */
73
+ scrollAll(options) {
74
+ return need(this.#modules.documents?.scrollAll, 'documents.scrollAll')(this.#target, options);
75
+ }
76
+ /** A search builder already pointed at this collection. */
77
+ query() {
78
+ return Search.on(this.name, this.namespace === undefined ? {} : { namespace: this.namespace });
79
+ }
80
+ /** Runs a search; the builder's collection is replaced by this one. */
81
+ search(builder, options) {
82
+ const json = builder.toJson();
83
+ json.collection = this.name;
84
+ if (this.namespace !== undefined) {
85
+ json.namespace = this.namespace;
86
+ }
87
+ return need(this.#modules.search?.query, 'search.query')(Search.fromJson(json).build(), options);
88
+ }
89
+ /** A kNN search on one vector field. */
90
+ vectorSearch(field, vector, options = {}) {
91
+ const { limit, filter, k, exact, nprobes, refineFactor, ef, oversampling, distance, ...call } = options;
92
+ let builder = this.query().vector(field, vector, { k, exact, nprobes, refineFactor, ef, oversampling, distance });
93
+ if (filter !== undefined)
94
+ builder = builder.filter(filter);
95
+ if (limit !== undefined)
96
+ builder = builder.limit(limit);
97
+ return this.search(builder, call);
98
+ }
99
+ /** The collection's schema and stats. */
100
+ info(options) {
101
+ return need(this.#modules.collections?.get, 'collections.get')(this.#fields, options);
102
+ }
103
+ /** Drops the collection. */
104
+ drop(options) {
105
+ return need(this.#modules.collections?.drop, 'collections.drop')(this.#fields, options);
106
+ }
107
+ }
package/dist/index.d.ts CHANGED
@@ -1,9 +1,16 @@
1
- export { Loams, type AdminNamespace, type LiveNamespace, type LoamsModules, type LoamsOptions, } from './loams.js';
1
+ export { Loams, type AdminNamespace, type CollectionsNamespace, type DocumentsNamespace, type LiveNamespace, type NamespacesNamespace, type SearchNamespace, type SqlNamespace, type StreamsNamespace, type LoamsEnvironment, type LoamsModules, type LoamsOptions, } from './loams.js';
2
+ export { Schema, type DynamicMapping, type FieldOptions, type TextOptions as SchemaTextOptions } from './builders/schema.js';
3
+ export { Filter, idValue, toQuery, type Bounds, type DocId, type FilterJson, type Fuzziness, type MatchOptions, type MultiMatchOptions, type QueryStringOptions, } from './builders/filter.js';
4
+ export { Fusion, Search, Sort, consistencyJson, dbsf, rrf, weighted, type ConsistencyLevel, type ExpandOptions, type FusionJson, type HighlightOptions, type SelectOptions, type SortJson, type SortValue, type SparseOptions, type TextOptions, type VectorOptions, } from './builders/search.js';
5
+ export { CollectionHandle, type HandleModules } from './handle.js';
6
+ export { WriteOps, attachAppCalls, documentCalls, documentIdJson, searchCalls, sqlCalls, sqlRecords, streamCalls, type DocumentInput, type PatchChange, type ScrollOptions, type SearchShorthandOptions, type SqlAnswer, type SqlRecordsOptions, type Target, } from './app.js';
7
+ export { DEFAULT_CHUNK_BYTES, DEFAULT_CHUNK_ROWS, writeBatch, type BatchOptions, type BatchResult, type ChunkWriter, } from './runtime/batch.js';
8
+ export { SUBSCRIBE_MAX_BACKOFF_MS, SUBSCRIBE_MIN_BACKOFF_MS, subscribe, type OffsetRecord, type RecordFetcher, type SubscribeRequest, type Subscription, } from './runtime/subscribe.js';
2
9
  export { SystemApi, type Catalogue, type SystemConfig, type VersionReport, } from './system.js';
3
- export { FEATURE_NOT_IN_VARIANT, MODULES, PROTO_PACKAGES, PROTO_REV, REASON_CODES, REASONS, SERVICE_DESCRIPTORS, type CallBinding, type InstanceModule, type LiveModule, type ModuleBinding, type Reason, type TablesModule, } from './gen/facade.js';
4
- export { CallInvoker, callWithRetry, withIdempotencyKey, type Attempt, type CallOptions, type ConsistencyOptions, type ConsistencyTokenStore, type RetryPlan, type Send, } from './runtime/call.js';
5
- export { ConsistencySession, TOKEN_PREFIX, isConsistencyToken } from './runtime/consistency.js';
6
- export { AlreadyExistsError, AbortedError, DeadlineExceededError, FailedPreconditionError, FeatureNotInVariantError, InternalError, InvalidArgumentError, LoamsError, NotFoundError, PermissionDeniedError, ResourceExhaustedError, TokenExpiredError, UnauthenticatedError, UnavailableError, UnimplementedError, errorInfo, isLoamsError, toLoamsError, type ErrorInfoShape, } from './runtime/errors.js';
10
+ export { FEATURE_NOT_IN_VARIANT, MODULES, PROTO_PACKAGES, PROTO_REV, REASON_CODES, REASONS, SERVICE_DESCRIPTORS, type CallBinding, type CollectionsModule, type DocumentsModule, type GraphModule, type InstanceModule, type NamespacesModule, type SearchModule, type VectorModule, type LiveModule, type ModuleBinding, type Reason, type TablesModule, } from './gen/facade.js';
11
+ export { CONSISTENCY_TOKEN_HEADER, CallInvoker, DEFAULT_TIMEOUT_MS, callWithRetry, withIdempotencyKey, type Attempt, type CallOptions, type ConsistencyOptions, type ConsistencyTokenStore, type InvokerDefaults, type RetryPlan, type Send, } from './runtime/call.js';
12
+ export { ConsistencySession, ConsistencyToken, TOKEN_PREFIX, isConsistencyToken, type TokenPosition, } from './runtime/consistency.js';
13
+ export { AlreadyExistsError, AbortedError, BatchError, CLIENT_REASONS, DeadlineExceededError, FailedPreconditionError, FeatureNotInVariantError, InternalError, InvalidArgumentError, LoamsError, NotFoundError, PermissionDeniedError, ResourceExhaustedError, TokenExpiredError, UnauthenticatedError, UnavailableError, UnimplementedError, errorInfo, isLoamsError, type ClientReason, toLoamsError, type ErrorInfoShape, } from './runtime/errors.js';
7
14
  export { paginate, pageFields, type PageFetcher, type PageRequestOptions } from './runtime/pagination.js';
8
15
  export { BASE_DELAY_MS, DEFAULT_MAX_RETRIES, MAX_DELAY_MS, MAX_SERVER_DELAY_MS, backoffMs, isRetryableCode, shouldRetry, sleep, } from './runtime/retry.js';
9
16
  export { watch, type CursorOf, type ResumeOptions, type StreamOpener } from './runtime/streams.js';
package/dist/index.js CHANGED
@@ -15,15 +15,24 @@
15
15
  // generator produced, the typed error hierarchy, the token sources, and the
16
16
  // reason registry as a type.
17
17
  export { Loams, } from './loams.js';
18
+ // The app-building layer (SDKP): the builders, the collection handle and the
19
+ // hand-written conveniences the module objects carry.
20
+ export { Schema } from './builders/schema.js';
21
+ export { Filter, idValue, toQuery, } from './builders/filter.js';
22
+ export { Fusion, Search, Sort, consistencyJson, dbsf, rrf, weighted, } from './builders/search.js';
23
+ export { CollectionHandle } from './handle.js';
24
+ export { WriteOps, attachAppCalls, documentCalls, documentIdJson, searchCalls, sqlCalls, sqlRecords, streamCalls, } from './app.js';
25
+ export { DEFAULT_CHUNK_BYTES, DEFAULT_CHUNK_ROWS, writeBatch, } from './runtime/batch.js';
26
+ export { SUBSCRIBE_MAX_BACKOFF_MS, SUBSCRIBE_MIN_BACKOFF_MS, subscribe, } from './runtime/subscribe.js';
18
27
  export { SystemApi, } from './system.js';
19
28
  // The generated facade: the module interfaces, the binding table, the proto
20
29
  // revision, and the reason registry as a type. Everything here is written by
21
30
  // `buf generate`; do not hand-edit it.
22
31
  export { FEATURE_NOT_IN_VARIANT, MODULES, PROTO_PACKAGES, PROTO_REV, REASON_CODES, REASONS, SERVICE_DESCRIPTORS, } from './gen/facade.js';
23
32
  // The runtime, for a caller who composes rather than uses.
24
- export { CallInvoker, callWithRetry, withIdempotencyKey, } from './runtime/call.js';
25
- export { ConsistencySession, TOKEN_PREFIX, isConsistencyToken } from './runtime/consistency.js';
26
- export { AlreadyExistsError, AbortedError, DeadlineExceededError, FailedPreconditionError, FeatureNotInVariantError, InternalError, InvalidArgumentError, LoamsError, NotFoundError, PermissionDeniedError, ResourceExhaustedError, TokenExpiredError, UnauthenticatedError, UnavailableError, UnimplementedError, errorInfo, isLoamsError, toLoamsError, } from './runtime/errors.js';
33
+ export { CONSISTENCY_TOKEN_HEADER, CallInvoker, DEFAULT_TIMEOUT_MS, callWithRetry, withIdempotencyKey, } from './runtime/call.js';
34
+ export { ConsistencySession, ConsistencyToken, TOKEN_PREFIX, isConsistencyToken, } from './runtime/consistency.js';
35
+ export { AlreadyExistsError, AbortedError, BatchError, CLIENT_REASONS, DeadlineExceededError, FailedPreconditionError, FeatureNotInVariantError, InternalError, InvalidArgumentError, LoamsError, NotFoundError, PermissionDeniedError, ResourceExhaustedError, TokenExpiredError, UnauthenticatedError, UnavailableError, UnimplementedError, errorInfo, isLoamsError, toLoamsError, } from './runtime/errors.js';
27
36
  export { paginate, pageFields } from './runtime/pagination.js';
28
37
  export { BASE_DELAY_MS, DEFAULT_MAX_RETRIES, MAX_DELAY_MS, MAX_SERVER_DELAY_MS, backoffMs, isRetryableCode, shouldRetry, sleep, } from './runtime/retry.js';
29
38
  export { watch } from './runtime/streams.js';