@terrascale/sdk 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/README.md +42 -15
- package/package.json +5 -2
- package/sdk-v1-route-manifest.json +7593 -1175
- package/src/database-codec.js +21 -26
- package/src/database-types.js +11 -11
- package/src/database-view.js +6 -6
- package/src/http.js +10 -0
- package/src/ids.js +22 -0
- package/src/index.js +2 -1
- package/src/local/better-auth.js +17 -6
- package/src/local/index.js +2 -2
- package/src/local/legacy-client.js +5 -5
- package/src/local/router.js +12 -12
- package/src/local/store.js +29 -28
- package/src/local/test-environment.js +3 -2
- package/src/postgres.js +5 -4
- package/src/react/core.js +2 -2
- package/src/ts-auth-ids.js +122 -0
- package/src/ts-auth.js +74 -72
- package/src/v1/decode.js +20 -8
- package/src/v1/ids.js +7 -60
- package/src/v1/routes.js +5 -5
- package/src/v1/shapes.js +6 -7
- package/src/v1/terrabase-v1.js +24 -16
- package/src/v1/transport.js +6 -4
- package/types/database-codec.d.ts +1 -6
- package/types/database-types.d.ts +11 -11
- package/types/ids.d.ts +10 -0
- package/types/index.d.ts +2 -1
- package/types/local/store.d.ts +10 -0
- package/types/local/test-environment.d.ts +2 -2
- package/types/postgres.d.ts +4 -4
- package/types/ts-auth-ids.d.ts +14 -0
- package/types/ts-auth.d.ts +99 -99
- package/types/v1/decode.d.ts +8 -6
- package/types/v1/ids.d.ts +5 -17
- package/types/v1/shapes.d.ts +2 -2
- package/types/v1/terrabase-v1.d.ts +3 -3
- package/types/v1/transport.d.ts +2 -2
package/types/v1/ids.d.ts
CHANGED
|
@@ -5,16 +5,13 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export function requireName(kind: "database" | "collection", name: unknown): string;
|
|
7
7
|
/**
|
|
8
|
-
* The
|
|
8
|
+
* The catalog project ID is a canonical ULID; database and collection routes use names.
|
|
9
9
|
* @param {unknown} project
|
|
10
|
-
* @returns {
|
|
11
|
-
*/
|
|
12
|
-
export function requireProject(project: unknown): string;
|
|
13
|
-
/**
|
|
14
|
-
* @param {unknown} id
|
|
15
|
-
* @returns {string}
|
|
10
|
+
* @returns {import("../ids.js").EntityId}
|
|
16
11
|
*/
|
|
17
|
-
export function
|
|
12
|
+
export function requireProject(project: unknown): import("../ids.js").EntityId;
|
|
13
|
+
/** @param {unknown} id @returns {import("../ids.js").EntityId} */
|
|
14
|
+
export function requireDocumentId(id: unknown): import("../ids.js").EntityId;
|
|
18
15
|
/**
|
|
19
16
|
* @param {unknown} version
|
|
20
17
|
* @returns {string}
|
|
@@ -33,12 +30,3 @@ export function parseU64(value: unknown): bigint | undefined;
|
|
|
33
30
|
* @returns {bigint}
|
|
34
31
|
*/
|
|
35
32
|
export function requireU64(value: unknown, what: string): bigint;
|
|
36
|
-
/**
|
|
37
|
-
* The deterministic document ID for a natural key in a collection:
|
|
38
|
-
* `uuidv5(uuidv5(NAMESPACE_URL, "terrabase:collection:" + collection), key)`.
|
|
39
|
-
* Uses WebCrypto, so it works in Node.js, browsers and workers.
|
|
40
|
-
* @param {string} collection
|
|
41
|
-
* @param {string} key
|
|
42
|
-
* @returns {Promise<string>}
|
|
43
|
-
*/
|
|
44
|
-
export function documentIdFor(collection: string, key: string): Promise<string>;
|
package/types/v1/shapes.d.ts
CHANGED
|
@@ -42,12 +42,12 @@ export type V1ShapeRequest = {
|
|
|
42
42
|
};
|
|
43
43
|
export type V1ShapeOp = {
|
|
44
44
|
readonly op: "upsert";
|
|
45
|
-
readonly id:
|
|
45
|
+
readonly id: import("../ids.js").EntityId;
|
|
46
46
|
readonly version: string;
|
|
47
47
|
readonly document: JsonObject;
|
|
48
48
|
} | {
|
|
49
49
|
readonly op: "delete";
|
|
50
|
-
readonly id:
|
|
50
|
+
readonly id: import("../ids.js").EntityId;
|
|
51
51
|
};
|
|
52
52
|
export type V1ShapeChange = {
|
|
53
53
|
readonly offset: string;
|
|
@@ -33,7 +33,7 @@ export class V1Collection {
|
|
|
33
33
|
*/
|
|
34
34
|
put(id: string, document: JsonInputObject, options?: V1WriteOptions): Promise<V1WriteResult>;
|
|
35
35
|
/**
|
|
36
|
-
* Creates a document under a server-generated
|
|
36
|
+
* Creates a document under a server-generated ULID.
|
|
37
37
|
* @param {JsonInputObject} document
|
|
38
38
|
* @param {V1CreateOptions} [options]
|
|
39
39
|
* @returns {Promise<V1WriteResult>}
|
|
@@ -107,7 +107,7 @@ export class V1Transaction {
|
|
|
107
107
|
get size(): number;
|
|
108
108
|
/**
|
|
109
109
|
* Adds a create (a put requiring absence). Omit `id` to have the server
|
|
110
|
-
* generate a
|
|
110
|
+
* generate a ULID, returned in the op's result.
|
|
111
111
|
* @param {string} collection
|
|
112
112
|
* @param {JsonInputObject} document
|
|
113
113
|
* @param {string} [id]
|
|
@@ -211,7 +211,7 @@ export class V1Database {
|
|
|
211
211
|
#private;
|
|
212
212
|
}
|
|
213
213
|
/**
|
|
214
|
-
* A TerraBase v1 data-plane client for one project and
|
|
214
|
+
* A TerraBase v1 data-plane client for one project and access token. The token is held
|
|
215
215
|
* privately; it is never serialized, logged or forwarded to redirects.
|
|
216
216
|
*/
|
|
217
217
|
export class TerraBaseV1Client {
|
package/types/v1/transport.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export class BodyTransportError extends Error {
|
|
|
23
23
|
/** @param {unknown} cause */
|
|
24
24
|
constructor(cause: unknown);
|
|
25
25
|
}
|
|
26
|
-
/** Internal transport bound to one
|
|
26
|
+
/** Internal transport bound to one project credential. */
|
|
27
27
|
export class V1Transport {
|
|
28
28
|
/**
|
|
29
29
|
* @param {Response} response
|
|
@@ -85,7 +85,7 @@ export type V1EndpointResolver = (context: V1EndpointContext) => string | Promis
|
|
|
85
85
|
export type TerraBaseV1ClientConfig = {
|
|
86
86
|
project: string;
|
|
87
87
|
/**
|
|
88
|
-
* A tb_
|
|
88
|
+
* A ts-auth project access JWT (or a legacy C# tb_ key); held privately.
|
|
89
89
|
*/
|
|
90
90
|
token: string;
|
|
91
91
|
baseUrl?: string | undefined;
|