@terrascale/sdk 0.0.3 → 0.0.5

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 (66) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +206 -67
  3. package/package.json +10 -4
  4. package/sdk-public-v1-route-manifest.json +85 -0
  5. package/sdk-v1-route-manifest.json +896 -15
  6. package/src/http.js +3 -48
  7. package/src/index.js +80 -1
  8. package/src/local/environment.js +0 -1
  9. package/src/ts-auth.js +1 -5
  10. package/src/v1/backups.js +111 -0
  11. package/src/v1/catalog.js +240 -0
  12. package/src/v1/changes.js +225 -0
  13. package/src/v1/database-schema.js +45 -0
  14. package/src/v1/decode.js +6 -5
  15. package/src/v1/errors.js +23 -3
  16. package/src/v1/export.js +68 -0
  17. package/src/v1/ids.js +5 -2
  18. package/src/v1/imports.js +72 -0
  19. package/src/v1/indexes.js +76 -0
  20. package/src/v1/json.js +4 -3
  21. package/src/v1/management-decode.js +24 -0
  22. package/src/v1/management-routes.js +72 -0
  23. package/src/v1/management-validation.js +25 -0
  24. package/src/v1/routes.js +32 -7
  25. package/src/v1/saved-queries.js +58 -0
  26. package/src/v1/shape-crypto.js +125 -0
  27. package/src/v1/shape-manifest.js +31 -0
  28. package/src/v1/shape-reader.js +214 -0
  29. package/src/v1/shape-subscription.js +208 -0
  30. package/src/v1/shapes.js +11 -5
  31. package/src/v1/sql.js +98 -0
  32. package/src/v1/system.js +80 -0
  33. package/src/v1/terrabase-v1.js +231 -30
  34. package/src/v1/transport.js +117 -33
  35. package/src/v1/usage.js +101 -0
  36. package/types/http.d.ts +2 -8
  37. package/types/index.d.ts +73 -0
  38. package/types/local/environment.d.ts +1 -1
  39. package/types/ts-auth.d.ts +0 -2
  40. package/types/v1/backups.d.ts +128 -0
  41. package/types/v1/catalog.d.ts +104 -0
  42. package/types/v1/changes.d.ts +53 -0
  43. package/types/v1/database-schema.d.ts +82 -0
  44. package/types/v1/decode.d.ts +20 -4
  45. package/types/v1/errors.d.ts +16 -1
  46. package/types/v1/export.d.ts +26 -0
  47. package/types/v1/ids.d.ts +2 -2
  48. package/types/v1/imports.d.ts +132 -0
  49. package/types/v1/indexes.d.ts +75 -0
  50. package/types/v1/management-decode.d.ts +15 -0
  51. package/types/v1/management-routes.d.ts +3 -0
  52. package/types/v1/management-validation.d.ts +8 -0
  53. package/types/v1/routes.d.ts +5 -2
  54. package/types/v1/saved-queries.d.ts +33 -0
  55. package/types/v1/shape-crypto.d.ts +39 -0
  56. package/types/v1/shape-manifest.d.ts +28 -0
  57. package/types/v1/shape-reader.d.ts +45 -0
  58. package/types/v1/shape-subscription.d.ts +35 -0
  59. package/types/v1/shapes.d.ts +16 -2
  60. package/types/v1/sql.d.ts +47 -0
  61. package/types/v1/system.d.ts +85 -0
  62. package/types/v1/terrabase-v1.d.ts +140 -6
  63. package/types/v1/transport.d.ts +33 -10
  64. package/types/v1/usage.d.ts +171 -0
  65. package/src/ts-auth-discovery.js +0 -207
  66. package/types/ts-auth-discovery.d.ts +0 -19
@@ -1,5 +1,15 @@
1
1
  /**
2
- * Creates a TerraBase v1 client for documents, transactions, queries and shapes.
2
+ * @param {JsonValue | undefined} value
3
+ * @returns {V1QueryPage}
4
+ */
5
+ export function decodeQueryPage(value: JsonValue | undefined): V1QueryPage;
6
+ /** @typedef {{ readonly id: import("../ids.js").EntityId; readonly name: string; readonly createdAt: string }} V1CollectionInfo */
7
+ /** @typedef {{ readonly items: readonly V1CollectionInfo[]; readonly nextCursor: string | null }} V1CollectionPage */
8
+ /** @typedef {{ readonly limit?: number | undefined; readonly cursor?: string | undefined }} V1CollectionListOptions */
9
+ /** @param {JsonValue | undefined} value @returns {V1CollectionInfo} */
10
+ export function decodeCollection(value: JsonValue | undefined): V1CollectionInfo;
11
+ /**
12
+ * Creates a project-scoped TerraBase client for documents, SQL, changes and catalog operations.
3
13
  * @param {TerraBaseV1ClientConfig} config
4
14
  * @returns {TerraBaseV1Client}
5
15
  */
@@ -61,6 +71,26 @@ export class V1Collection {
61
71
  * @returns {Promise<V1QueryPage>}
62
72
  */
63
73
  query(query?: V1Query, options?: V1RequestOptions): Promise<V1QueryPage>;
74
+ /** @param {{ readonly limit?: number | undefined; readonly cursor?: string | undefined }} [request] @param {V1RequestOptions} [options] @returns {Promise<V1QueryPage>} */
75
+ list(request?: {
76
+ readonly limit?: number | undefined;
77
+ readonly cursor?: string | undefined;
78
+ }, options?: V1RequestOptions): Promise<V1QueryPage>;
79
+ /** @param {V1RequestOptions} [options] */
80
+ getSchema(options?: V1RequestOptions): Promise<import("./catalog.js").V1CollectionSchema>;
81
+ /** @param {import("./json.js").JsonInputObject | boolean} schema @param {V1RequestOptions} [options] */
82
+ putSchema(schema: import("./json.js").JsonInputObject | boolean, options?: V1RequestOptions): Promise<import("./catalog.js").V1CollectionSchema>;
83
+ /** @param {V1RequestOptions} [options] */
84
+ deleteSchema(options?: V1RequestOptions): Promise<import("./catalog.js").V1CollectionSchema>;
85
+ /** @param {V1RequestOptions} [options] */
86
+ getTtl(options?: V1RequestOptions): Promise<import("./catalog.js").V1CollectionTtl>;
87
+ /**
88
+ * Documents whose member at `path` holds a past RFC 3339 UTC time are deleted by an hourly sweep (up to about an hour late).
89
+ * @param {string} path JSON Pointer such as `/expiresAt`. @param {V1RequestOptions} [options]
90
+ */
91
+ putTtl(path: string, options?: V1RequestOptions): Promise<import("./catalog.js").V1CollectionTtl>;
92
+ /** @param {V1RequestOptions} [options] */
93
+ deleteTtl(options?: V1RequestOptions): Promise<import("./catalog.js").V1CollectionTtl>;
64
94
  /**
65
95
  * Iterates over every page, following `nextCursor`. `count`
66
96
  * is sent with the first page only.
@@ -79,11 +109,50 @@ export class V1Collection {
79
109
  /**
80
110
  * Reads one C# shape snapshot page or change-log chunk. Bootstrap defaults to offset -1.
81
111
  * Echo handle, nextOffset and cursor on the following read; discard state on must_refetch.
112
+ * ifNoneMatch sends a complete entity-tag list or *; 304 throws not_modified with cache headers.
82
113
  * @param {V1ShapeRequest} [request]
114
+ * @param {V1RequestOptions & {readonly ifNoneMatch?: string}} [options]
115
+ * @returns {Promise<V1ShapePage>}
116
+ */
117
+ shape(request?: V1ShapeRequest, options?: V1RequestOptions & {
118
+ readonly ifNoneMatch?: string;
119
+ }): Promise<V1ShapePage>;
120
+ /**
121
+ * Subscribe to the free-read v1 protocol. Stop with close() or the request signal.
122
+ * @param {{where?: V1Filter | undefined}} [request]
123
+ * @param {import("./shape-subscription.js").V1ShapeSubscribeOptions} [options]
124
+ * @returns {V1ShapeSubscription}
125
+ */
126
+ subscribeShape(request?: {
127
+ where?: V1Filter | undefined;
128
+ }, options?: import("./shape-subscription.js").V1ShapeSubscribeOptions): V1ShapeSubscription;
129
+ /** @param {import("./shape-manifest.js").V1ShapeManifestRequest} request @param {V1RequestOptions} [options] */
130
+ shapeManifest(request: import("./shape-manifest.js").V1ShapeManifestRequest, options?: V1RequestOptions): Promise<Readonly<{
131
+ handle: string;
132
+ objects: readonly Readonly<{
133
+ offset: string;
134
+ next_offset: string;
135
+ binding: string;
136
+ object: string;
137
+ url: string;
138
+ expires_at: string;
139
+ epoch: string;
140
+ key_id: string;
141
+ sha256: string;
142
+ size: number | ExactDecimal;
143
+ }>[];
144
+ }>>;
145
+ /** @param {import("./shape-reader.js").V1ShapeKeyRequest} request @param {V1RequestOptions} [options] */
146
+ shapeKey(request: import("./shape-reader.js").V1ShapeKeyRequest, options?: V1RequestOptions): Promise<import("./shape-reader.js").V1ShapeKey>;
147
+ /**
148
+ * Verify a complete TBS1 object using its authenticated epoch key. Applies no state.
149
+ * Object delivery through manifests is pending the producer's FR-22 contract.
150
+ * @param {Uint8Array} bytes
151
+ * @param {import("./shape-reader.js").V1SealedShapePosition} position
83
152
  * @param {V1RequestOptions} [options]
84
153
  * @returns {Promise<V1ShapePage>}
85
154
  */
86
- shape(request?: V1ShapeRequest, options?: V1RequestOptions): Promise<V1ShapePage>;
155
+ decryptShapeObject(bytes: Uint8Array, position: import("./shape-reader.js").V1SealedShapePosition, options?: V1RequestOptions): Promise<V1ShapePage>;
87
156
  #private;
88
157
  }
89
158
  /**
@@ -197,6 +266,16 @@ export class V1Database {
197
266
  * @param {string} name
198
267
  */
199
268
  constructor(transport: V1Transport, name: string);
269
+ /** @type {V1Imports} */
270
+ imports: V1Imports;
271
+ /** @type {V1Backups} */
272
+ backups: V1Backups;
273
+ /** @type {V1DatabaseUsageClient} */
274
+ metrics: V1DatabaseUsageClient;
275
+ /** @type {V1Indexes} */
276
+ indexes: V1Indexes;
277
+ /** @type {V1DatabaseSchemaClient} */
278
+ schema: V1DatabaseSchemaClient;
200
279
  /** @type {V1Collections} */
201
280
  collections: V1Collections;
202
281
  /** @type {string} */
@@ -208,6 +287,19 @@ export class V1Database {
208
287
  collection(name: string): V1Collection;
209
288
  /** @returns {V1Transaction} */
210
289
  transaction(): V1Transaction;
290
+ /** @param {string} statement @param {V1RequestOptions} [options] */
291
+ sql(statement: string, options?: V1RequestOptions): Promise<import("./sql.js").V1SqlResult>;
292
+ /** @param {string} statement @param {V1RequestOptions} [options] */
293
+ checkSql(statement: string, options?: V1RequestOptions): Promise<import("./sql.js").V1SqlCheck>;
294
+ /** @param {string} statement @param {V1RequestOptions} [options] */
295
+ explainSql(statement: string, options?: V1RequestOptions): Promise<import("./sql.js").V1SqlCheck>;
296
+ /** @param {import("./changes.js").V1ChangeStreamRequest} [request] @param {V1RequestOptions} [options] */
297
+ changes(request?: import("./changes.js").V1ChangeStreamRequest, options?: V1RequestOptions): AsyncGenerator<import("./changes.js").V1DatabaseChange | import("./changes.js").V1DatabaseChangeCursor, void, undefined>;
298
+ /**
299
+ * Streams every live document as `{ collection, id, document }`, in collection then id order, from one snapshot.
300
+ * @param {import("./export.js").V1ExportOptions} [options]
301
+ */
302
+ export(options?: import("./export.js").V1ExportOptions): AsyncGenerator<import("./export.js").V1ExportedDocument, void, undefined>;
211
303
  #private;
212
304
  }
213
305
  /**
@@ -222,9 +314,22 @@ export class TerraBaseV1Client {
222
314
  * @returns {V1Database}
223
315
  */
224
316
  database(name: string): V1Database;
317
+ /** @returns {V1Databases} Project-scoped database catalog. */
318
+ get databases(): V1Databases;
319
+ /** @returns {V1SavedQueries} */
320
+ get savedQueries(): V1SavedQueries;
321
+ /** @returns {V1ProjectUsageClient} */
322
+ get metrics(): V1ProjectUsageClient;
323
+ /** @returns {V1BackupDestinationClient} */
324
+ get backupDestination(): V1BackupDestinationClient;
325
+ /** @returns {V1Health} */
326
+ get health(): V1Health;
327
+ /** @returns {V1Platform} */
328
+ get platform(): V1Platform;
225
329
  #private;
226
330
  }
227
331
  export type V1CollectionInfo = {
332
+ readonly id: import("../ids.js").EntityId;
228
333
  readonly name: string;
229
334
  readonly createdAt: string;
230
335
  };
@@ -277,6 +382,10 @@ export type V1PatchOp = {
277
382
  readonly op: "inc";
278
383
  readonly path: string;
279
384
  readonly by: number | bigint | ExactDecimal;
385
+ } | {
386
+ readonly op: "add" | "remove";
387
+ readonly path: string;
388
+ readonly value: import("./filter.js").V1Scalar;
280
389
  } | {
281
390
  readonly op: "append";
282
391
  readonly path: string;
@@ -290,17 +399,28 @@ export type V1Patch = {
290
399
  } | {
291
400
  readonly ops: readonly V1PatchOp[];
292
401
  };
293
- export type V1SortKey = {
402
+ export type V1FieldSortKey = {
294
403
  readonly path: V1Path;
295
404
  readonly order?: "asc" | "desc" | undefined;
296
405
  };
406
+ /**
407
+ * Vector similarity sort, nearest first. It must be the only sort key; limit is at most 100 and there is no cursor.
408
+ */
409
+ export type V1NearSortKey = {
410
+ readonly near: {
411
+ readonly path: V1Path;
412
+ readonly vector: readonly number[];
413
+ readonly metric?: "cosine" | "l2" | undefined;
414
+ };
415
+ };
416
+ export type V1SortKey = V1FieldSortKey | V1NearSortKey;
297
417
  /**
298
418
  * A query-v1 request. Every member is optional.
299
419
  */
300
420
  export type V1Query = {
301
421
  filter?: V1Filter | null | undefined;
302
422
  /**
303
- * At most 4 keys; results are finally ordered by `$id`.
423
+ * At most 4 keys, or one `near` key; results are finally ordered by `$id`.
304
424
  */
305
425
  sort?: readonly V1SortKey[] | undefined;
306
426
  /**
@@ -344,6 +464,7 @@ export type V1Precondition = {
344
464
  export type V1TransactionOpResult = {
345
465
  readonly id: string;
346
466
  readonly version: string;
467
+ readonly document?: import("./json.js").JsonObject;
347
468
  } | {
348
469
  readonly asserted: true;
349
470
  readonly count?: string;
@@ -360,15 +481,28 @@ export type V1TransactionResult = {
360
481
  */
361
482
  results: readonly V1TransactionOpResult[];
362
483
  };
484
+ import type { JsonValue } from "./json.js";
363
485
  import type { TerraBaseV1ClientConfig } from "./transport.js";
364
486
  import type { V1Document } from "./decode.js";
365
487
  import type { JsonInputObject } from "./json.js";
366
488
  import type { V1WriteResult } from "./decode.js";
367
489
  import type { V1ShapeRequest } from "./shapes.js";
368
490
  import type { V1ShapePage } from "./shapes.js";
369
- import { V1Transport } from "./transport.js";
370
491
  import type { V1Filter } from "./filter.js";
371
- import type { JsonInput } from "./json.js";
492
+ import { V1ShapeSubscription } from "./shape-subscription.js";
372
493
  import { ExactDecimal } from "./json.js";
494
+ import { V1Transport } from "./transport.js";
495
+ import { V1Imports } from "./imports.js";
496
+ import { V1Backups } from "./backups.js";
497
+ import { V1DatabaseUsageClient } from "./usage.js";
498
+ import { V1Indexes } from "./indexes.js";
499
+ import { V1DatabaseSchemaClient } from "./database-schema.js";
500
+ import { V1Databases } from "./catalog.js";
501
+ import { V1SavedQueries } from "./saved-queries.js";
502
+ import { V1ProjectUsageClient } from "./usage.js";
503
+ import { V1BackupDestinationClient } from "./backups.js";
504
+ import { V1Health } from "./system.js";
505
+ import { V1Platform } from "./system.js";
506
+ import type { JsonInput } from "./json.js";
373
507
  import type { V1Path } from "./filter.js";
374
508
  import type { V1Durability } from "./decode.js";
@@ -31,8 +31,13 @@ export class V1Transport {
31
31
  * @returns {JsonValue | undefined}
32
32
  */
33
33
  static "__#private@#decodeJson"(response: Response, text: string): JsonValue | undefined;
34
- /** @param {TerraBaseV1ClientConfig} config */
35
- constructor(config: TerraBaseV1ClientConfig);
34
+ /** @param {TerraBaseV1ClientConfig | (import("./system.js").TerraBaseSystemClientConfig & { project?: undefined; endpointResolver?: undefined })} config */
35
+ constructor(config: TerraBaseV1ClientConfig | (import("./system.js").TerraBaseSystemClientConfig & {
36
+ project?: undefined;
37
+ endpointResolver?: undefined;
38
+ }));
39
+ /** Internal credential lifetime metadata; never exposes the bearer value. */
40
+ get hasTokenProvider(): boolean;
36
41
  /**
37
42
  * @param {V1Operation} operation
38
43
  * @param {Readonly<Record<string, string>>} params
@@ -44,21 +49,24 @@ export class V1Transport {
44
49
  * Reads a response body as UTF-8 text within the response byte bound. A
45
50
  * connection failure while reading is a BodyTransportError.
46
51
  * @param {Response} response
52
+ * @param {AbortSignal | undefined} [signal]
47
53
  * @returns {Promise<string>}
48
54
  */
49
- readText(response: Response): Promise<string>;
55
+ readText(response: Response, signal?: AbortSignal | undefined): Promise<string>;
50
56
  /**
51
57
  * Parses a JSON response body exactly.
52
58
  * @param {Response} response
59
+ * @param {AbortSignal | undefined} [signal]
53
60
  * @returns {Promise<JsonValue | undefined>}
54
61
  */
55
- readJson(response: Response): Promise<JsonValue | undefined>;
62
+ readJson(response: Response, signal?: AbortSignal | undefined): Promise<JsonValue | undefined>;
56
63
  /**
57
64
  * Converts a non-success response to a TerraBaseV1Error.
58
65
  * @param {Response} response
66
+ * @param {AbortSignal | undefined} [signal]
59
67
  * @returns {Promise<TerraBaseV1Error>}
60
68
  */
61
- error(response: Response): Promise<TerraBaseV1Error>;
69
+ error(response: Response, signal?: AbortSignal | undefined): Promise<TerraBaseV1Error>;
62
70
  /**
63
71
  * Calls only a named producer route. Redirects and failed mutations are never replayed.
64
72
  * @param {V1Operation} operation
@@ -67,17 +75,28 @@ export class V1Transport {
67
75
  * @returns {Promise<V1CallResult>}
68
76
  */
69
77
  call(operation: V1Operation, params: Readonly<Record<string, string>>, options?: V1CallOptions): Promise<V1CallResult>;
78
+ /**
79
+ * @param {"streamDatabaseChanges" | "exportDatabase"} operation
80
+ * @param {Readonly<Record<string, string>>} params
81
+ * @param {V1CallOptions} [options]
82
+ * @returns {Promise<Response>}
83
+ */
84
+ openStream(operation: "streamDatabaseChanges" | "exportDatabase", params: Readonly<Record<string, string>>, options?: V1CallOptions): Promise<Response>;
70
85
  #private;
71
86
  }
72
87
  /**
73
88
  * Resolver input contains no credential. A successful URL is cached for this client/database.
74
89
  */
75
90
  export type V1EndpointContext = {
76
- readonly project: string;
77
- readonly database: string;
91
+ readonly project: string | undefined;
92
+ readonly database?: string | undefined;
78
93
  readonly signal?: AbortSignal | undefined;
79
94
  };
80
95
  export type V1EndpointResolver = (context: V1EndpointContext) => string | Promise<string>;
96
+ /**
97
+ * A fresh access token for each authenticated request, including stream reconnects.
98
+ */
99
+ export type V1TokenProvider = () => string | Promise<string>;
81
100
  /**
82
101
  * Project-scoped C# Documents API client. Supply exactly one of baseUrl or endpointResolver.
83
102
  * URLs must use HTTPS or loopback HTTP. Mutations are never automatically replayed.
@@ -85,9 +104,9 @@ export type V1EndpointResolver = (context: V1EndpointContext) => string | Promis
85
104
  export type TerraBaseV1ClientConfig = {
86
105
  project: string;
87
106
  /**
88
- * A ts-auth project access JWT (or a legacy C# tb_ key); held privately.
107
+ * An access JWT (or a legacy C# tb_ key), or a provider resolved per authenticated request; held privately. Browser callers must use end-user tokens, never project credentials.
89
108
  */
90
- token: string;
109
+ token: string | V1TokenProvider;
91
110
  baseUrl?: string | undefined;
92
111
  endpointResolver?: V1EndpointResolver | undefined;
93
112
  fetch?: FetchLike | undefined;
@@ -97,7 +116,7 @@ export type TerraBaseV1ClientConfig = {
97
116
  maxResponseBytes?: number | undefined;
98
117
  };
99
118
  export type V1CallOptions = {
100
- body?: string;
119
+ body?: string | Uint8Array;
101
120
  contentType?: string;
102
121
  /**
103
122
  * Contract headers only (If-Match, If-None-Match).
@@ -105,6 +124,10 @@ export type V1CallOptions = {
105
124
  headers?: Readonly<Record<string, string>>;
106
125
  query?: URLSearchParams | undefined;
107
126
  signal?: AbortSignal | undefined;
127
+ /**
128
+ * Authenticated shape epoch keys must bypass caches.
129
+ */
130
+ cache?: "no-store" | undefined;
108
131
  };
109
132
  export type V1CallResult = {
110
133
  status: number;
@@ -0,0 +1,171 @@
1
+ /** Project and database usage retain the producer's separate response envelopes. */
2
+ export class V1ProjectUsageClient {
3
+ /** @param {V1Transport} transport */
4
+ constructor(transport: V1Transport);
5
+ /** @param {V1UsageRequest} [request] @param {V1RequestOptions} [options] @returns {Promise<V1ProjectUsage>} */
6
+ usage(request?: V1UsageRequest, options?: V1RequestOptions): Promise<V1ProjectUsage>;
7
+ /** @param {V1AnalyticsRequest} [request] @param {V1RequestOptions} [options] @returns {Promise<V1Analytics>} */
8
+ analytics(request?: V1AnalyticsRequest, options?: V1RequestOptions): Promise<V1Analytics>;
9
+ /** @param {V1AnalyticsRequest} [request] @param {V1RequestOptions} [options] @returns {Promise<V1Replication>} */
10
+ replication(request?: V1AnalyticsRequest, options?: V1RequestOptions): Promise<V1Replication>;
11
+ #private;
12
+ }
13
+ export class V1DatabaseUsageClient {
14
+ /** @param {V1Transport} transport @param {string} database */
15
+ constructor(transport: V1Transport, database: string);
16
+ /** @param {V1UsageRequest} [request] @param {V1RequestOptions} [options] @returns {Promise<V1DatabaseUsage>} */
17
+ usage(request?: V1UsageRequest, options?: V1RequestOptions): Promise<V1DatabaseUsage>;
18
+ /** @param {Omit<V1AnalyticsRequest, "database">} [request] @param {V1RequestOptions} [options] @returns {Promise<V1Analytics>} */
19
+ analytics(request?: Omit<V1AnalyticsRequest, "database">, options?: V1RequestOptions): Promise<V1Analytics>;
20
+ /** @param {Omit<V1AnalyticsRequest, "database">} [request] @param {V1RequestOptions} [options] @returns {Promise<V1Replication>} */
21
+ replication(request?: Omit<V1AnalyticsRequest, "database">, options?: V1RequestOptions): Promise<V1Replication>;
22
+ #private;
23
+ }
24
+ export type V1DatabaseUsage = ReturnType<typeof databaseUsage>;
25
+ export type V1ProjectUsage = ReturnType<typeof projectUsage>;
26
+ export type V1Analytics = ReturnType<typeof analytics>;
27
+ export type V1Replication = ReturnType<typeof replication>;
28
+ export type V1UsageRequest = {
29
+ readonly granularity?: "hour" | "day";
30
+ readonly from?: string;
31
+ readonly to?: string;
32
+ };
33
+ export type V1AnalyticsRequest = {
34
+ readonly range?: "1h" | "24h" | "7d" | "30d";
35
+ readonly database?: string;
36
+ readonly region?: string;
37
+ };
38
+ import type { V1RequestOptions } from "./terrabase-v1.js";
39
+ import type { V1Transport } from "./transport.js";
40
+ declare const databaseUsage: import("./management-decode.js").Decoder<Readonly<{
41
+ databaseId: string;
42
+ storageBytes: number | import("./json.js").ExactDecimal;
43
+ logicalBytes: number | import("./json.js").ExactDecimal;
44
+ collections: number | import("./json.js").ExactDecimal;
45
+ documents: number | import("./json.js").ExactDecimal;
46
+ reads: number | import("./json.js").ExactDecimal;
47
+ writes: number | import("./json.js").ExactDecimal;
48
+ period: Readonly<{
49
+ from: string;
50
+ to: string;
51
+ granularity: string;
52
+ reads: number | import("./json.js").ExactDecimal;
53
+ writes: number | import("./json.js").ExactDecimal;
54
+ }>;
55
+ series: readonly Readonly<{
56
+ start: string;
57
+ reads: number | import("./json.js").ExactDecimal;
58
+ writes: number | import("./json.js").ExactDecimal;
59
+ }>[];
60
+ }>>;
61
+ declare const projectUsage: import("./management-decode.js").Decoder<Readonly<{
62
+ projectId: string;
63
+ databases: number | import("./json.js").ExactDecimal;
64
+ storageBytes: number | import("./json.js").ExactDecimal;
65
+ logicalBytes: number | import("./json.js").ExactDecimal;
66
+ documents: number | import("./json.js").ExactDecimal;
67
+ reads: number | import("./json.js").ExactDecimal;
68
+ writes: number | import("./json.js").ExactDecimal;
69
+ period: Readonly<{
70
+ from: string;
71
+ to: string;
72
+ granularity: string;
73
+ reads: number | import("./json.js").ExactDecimal;
74
+ writes: number | import("./json.js").ExactDecimal;
75
+ }>;
76
+ series: readonly Readonly<{
77
+ start: string;
78
+ reads: number | import("./json.js").ExactDecimal;
79
+ writes: number | import("./json.js").ExactDecimal;
80
+ }>[];
81
+ items: readonly Readonly<{
82
+ databaseId: string;
83
+ storageBytes: number | import("./json.js").ExactDecimal;
84
+ logicalBytes: number | import("./json.js").ExactDecimal;
85
+ collections: number | import("./json.js").ExactDecimal;
86
+ documents: number | import("./json.js").ExactDecimal;
87
+ reads: number | import("./json.js").ExactDecimal;
88
+ writes: number | import("./json.js").ExactDecimal;
89
+ period: Readonly<{
90
+ from: string;
91
+ to: string;
92
+ granularity: string;
93
+ reads: number | import("./json.js").ExactDecimal;
94
+ writes: number | import("./json.js").ExactDecimal;
95
+ }>;
96
+ series: readonly Readonly<{
97
+ start: string;
98
+ reads: number | import("./json.js").ExactDecimal;
99
+ writes: number | import("./json.js").ExactDecimal;
100
+ }>[];
101
+ }>[];
102
+ }>>;
103
+ declare const analytics: import("./management-decode.js").Decoder<Readonly<{
104
+ projectId: string;
105
+ range: string;
106
+ from: string;
107
+ to: string;
108
+ bucketSeconds: number | import("./json.js").ExactDecimal;
109
+ items: readonly Readonly<{
110
+ databaseId: string;
111
+ databaseName: string;
112
+ region: string;
113
+ series: readonly Readonly<{
114
+ start: string;
115
+ requests: Readonly<Record<string, number | import("./json.js").ExactDecimal>>;
116
+ operations: Readonly<Record<string, number | import("./json.js").ExactDecimal>>;
117
+ errors: number | import("./json.js").ExactDecimal;
118
+ latency: Readonly<{
119
+ p50Ms: /*elided*/ any;
120
+ p95Ms: /*elided*/ any;
121
+ p99Ms: /*elided*/ any;
122
+ }>;
123
+ storageBytes: number | import("./json.js").ExactDecimal | null;
124
+ clientBandwidth: Readonly<{
125
+ bytesSent: /*elided*/ any;
126
+ bytesReceived: /*elided*/ any;
127
+ }>;
128
+ replicationBandwidth: Readonly<{
129
+ bytesSent: /*elided*/ any;
130
+ bytesReceived: /*elided*/ any;
131
+ }>;
132
+ }>[];
133
+ }>[];
134
+ }>>;
135
+ declare const replication: import("./management-decode.js").Decoder<Readonly<{
136
+ projectId: string;
137
+ range: string;
138
+ from: string;
139
+ to: string;
140
+ bucketSeconds: number | import("./json.js").ExactDecimal;
141
+ items: readonly Readonly<{
142
+ databaseId: string;
143
+ databaseName: string;
144
+ region: string;
145
+ status: string;
146
+ replicatedOps: number | import("./json.js").ExactDecimal;
147
+ lagMs: number | import("./json.js").ExactDecimal | null;
148
+ divergence: boolean | null;
149
+ convergenceMs: number | import("./json.js").ExactDecimal | null;
150
+ lastApplied: string | null;
151
+ bandwidth: readonly Readonly<{
152
+ sourceRegion: string;
153
+ destinationRegion: string;
154
+ kind: string;
155
+ bytesSent: number | import("./json.js").ExactDecimal;
156
+ bytesReceived: number | import("./json.js").ExactDecimal;
157
+ }>[];
158
+ series: readonly Readonly<{
159
+ start: string;
160
+ replicatedOps: number | import("./json.js").ExactDecimal;
161
+ bandwidth: readonly Readonly<{
162
+ sourceRegion: /*elided*/ any;
163
+ destinationRegion: /*elided*/ any;
164
+ kind: /*elided*/ any;
165
+ bytesSent: /*elided*/ any;
166
+ bytesReceived: /*elided*/ any;
167
+ }>[];
168
+ }>[];
169
+ }>[];
170
+ }>>;
171
+ export {};