terrascale 0.3.0 → 1.0.0
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 +47 -0
- package/README.md +169 -115
- package/package.json +11 -16
- package/sdk-v1-route-manifest.json +2330 -0
- package/src/database-view.js +2 -1
- package/src/database.js +2 -420
- package/src/index.js +58 -75
- package/src/local/index.js +5 -3
- package/src/local/legacy-client.js +411 -0
- package/src/postgres.js +3 -1
- package/src/tanstack/index.js +2 -1
- package/src/v1/decode.js +110 -0
- package/src/v1/errors.js +185 -0
- package/src/v1/filter.js +230 -0
- package/src/v1/ids.js +118 -0
- package/src/v1/json.js +335 -0
- package/src/v1/routes.js +57 -0
- package/src/v1/shapes.js +145 -0
- package/src/v1/terrabase-v1.js +722 -0
- package/src/v1/transport.js +324 -0
- package/types/database-view.d.ts +3 -2
- package/types/database.d.ts +2 -98
- package/types/index.d.ts +42 -51
- package/types/local/index.d.ts +6 -4
- package/types/local/legacy-client.d.ts +94 -0
- package/types/local/test-environment.d.ts +1 -1
- package/types/postgres.d.ts +1 -0
- package/types/tanstack/index.d.ts +3 -2
- package/types/v1/decode.d.ts +105 -0
- package/types/v1/errors.d.ts +107 -0
- package/types/v1/filter.d.ts +148 -0
- package/types/v1/ids.d.ts +44 -0
- package/types/v1/json.d.ts +92 -0
- package/types/v1/routes.d.ts +26 -0
- package/types/v1/shapes.d.ts +78 -0
- package/types/v1/terrabase-v1.d.ts +374 -0
- package/types/v1/transport.d.ts +117 -0
- package/sdk-current-contract.json +0 -27
- package/sdk-route-manifest.json +0 -67
- package/src/discovery.js +0 -374
- package/types/discovery.d.ts +0 -114
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.0.0 — TS-498
|
|
4
|
+
|
|
5
|
+
### Breaking changes
|
|
6
|
+
|
|
7
|
+
1. The root entrypoint exposes only the C# TerraBase v1 client API.
|
|
8
|
+
`createTerraBaseClient` now aliases `createTerraBaseV1Client`; the retired
|
|
9
|
+
tenant/shard client, Rust discovery, schema/SQL and reactive-view
|
|
10
|
+
exports are removed from the root. Named legacy entrypoints remain separate.
|
|
11
|
+
2. Client configuration requires `project`, a Bearer `tb_` token and exactly one
|
|
12
|
+
of `baseUrl` or `endpointResolver`. Tenant, shard, `apiKey`, `endpoint` and
|
|
13
|
+
`tbk1` routing assumptions no longer apply. Database operations use
|
|
14
|
+
`/v1/projects/{project}/databases/{db}` paths.
|
|
15
|
+
3. Mutations follow the C# producer: `Idempotency-Key` is unsupported and writes
|
|
16
|
+
cannot be automatically replayed. Queries do not support `lower` or `explain`;
|
|
17
|
+
server numeric comparison and bounded-count semantics replace Rust assumptions.
|
|
18
|
+
4. Shapes use `GET …/collections/{collection}/shape` with `shapes:read`.
|
|
19
|
+
The retired shape gatekeeper, SSE, edge tokens and projection are unavailable.
|
|
20
|
+
5. `terrascale/local`, `terrascale-local` and `terrascale/postgres` are deprecated
|
|
21
|
+
legacy surfaces. SDK SQLite is no longer the required Dashboard backend;
|
|
22
|
+
real C# release binaries replace frozen Rust/fake-server qualification.
|
|
23
|
+
|
|
24
|
+
### Migration
|
|
25
|
+
|
|
26
|
+
Configure a provisioned project and `tb_` API key with `documents:read` and/or
|
|
27
|
+
`documents:write`, then obtain `client.database(name).collection(name)` handles.
|
|
28
|
+
Use `get`, `put`, `create`, `patch`, `delete` and bounded `query`/`pages`/`items`
|
|
29
|
+
operations; conditional writes carry `ifMatch` or `ifNoneMatchAny`.
|
|
30
|
+
Do not replay uncertain mutations without a producer deduplication contract.
|
|
31
|
+
|
|
32
|
+
`staticBaseUrlResolver(baseUrl)` supplies an explicit override; a custom resolver
|
|
33
|
+
receives `{ project, database }` and is resolved once per database session.
|
|
34
|
+
Atlas discovery is deferred to TS-507; no regional hostname is hardcoded.
|
|
35
|
+
Ouroboros qualification uses the real immutable C# TerraBase release binary,
|
|
36
|
+
pinned by version and SHA-256, rather than an SDK-local substitute.
|
|
37
|
+
`provision:terrabase` acquires the verified binary; `test:integration` runs it
|
|
38
|
+
with isolated TLS, real tenant provisioning and runtime OpenAPI parity.
|
|
39
|
+
The pinned official producer release is a draft after failed fast checks
|
|
40
|
+
(terrabase #110). Its verified release asset can run SDK integration without
|
|
41
|
+
publication; those results do not establish that producer source checks passed.
|
|
42
|
+
|
|
43
|
+
The package and lockfile versions advance from 0.3.0 to 1.0.0. `lint` reuses the
|
|
44
|
+
existing strict TypeScript/JSDoc check; dependencies are unchanged.
|
|
45
|
+
|
|
46
|
+
Fresh shape bootstrap requires a server runtime; browser manual redirects hide
|
|
47
|
+
the bootstrap handle and offset. Browser continuation needs those server-issued positions.
|
package/README.md
CHANGED
|
@@ -1,143 +1,197 @@
|
|
|
1
1
|
# terrascale
|
|
2
2
|
|
|
3
|
-
The JavaScript SDK for
|
|
3
|
+
The JavaScript/JSDoc SDK for the project-scoped C#/.NET TerraBase server
|
|
4
|
+
(`terrabase`, `origin/main`). Version 1.0.0 replaces the retired Rust client.
|
|
4
5
|
The package targets Node.js 22 and 24 and current Chrome, Firefox, Safari, and Edge.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
The source is plain ES modules typed with JSDoc and published as written; there
|
|
8
|
-
is no transpile step. `npm run build` generates the `.d.ts` declarations in
|
|
9
|
-
`types/`, so TypeScript and editor consumers get the same types the source is
|
|
10
|
-
checked against.
|
|
6
|
+
Plain ES modules ship as written; `nice -n 19 npm run build` generates the
|
|
7
|
+
TypeScript declarations in `types/`.
|
|
11
8
|
|
|
12
9
|
```js
|
|
13
|
-
import {
|
|
10
|
+
import { createTerraBaseV1Client, documentIdFor, v1Filter } from "terrascale";
|
|
14
11
|
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
apiKey: process.env.TERRABASE_API_KEY,
|
|
12
|
+
const client = createTerraBaseV1Client({
|
|
13
|
+
project: process.env.TERRABASE_PROJECT,
|
|
14
|
+
token: process.env.TERRABASE_API_KEY,
|
|
15
|
+
baseUrl: process.env.TERRABASE_BASE_URL,
|
|
20
16
|
});
|
|
17
|
+
const db = client.database("app");
|
|
18
|
+
const todos = db.collection("todos");
|
|
19
|
+
|
|
20
|
+
const id = await documentIdFor("todos", "first-task");
|
|
21
|
+
await todos.put(id, { title: "Use TerraBase", done: false }, { ifNoneMatchAny: true });
|
|
22
|
+
const doc = await todos.get(id);
|
|
23
|
+
await todos.patch(id, { merge: { done: true } }, { ifMatch: doc.version });
|
|
21
24
|
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
for await (const page of todos.pages({ filter: v1Filter.eq("/done", true), limit: 50 })) {
|
|
26
|
+
console.log(page.items);
|
|
27
|
+
}
|
|
25
28
|
```
|
|
26
29
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
and
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
advancing delivery, and cleanup cancels owned work. Mutations prepare and commit
|
|
45
|
-
through the same client; a presentation rollback does not establish a server abort.
|
|
46
|
-
|
|
47
|
-
Omitting `endpoint` uses authenticated, scope-bound routing at
|
|
48
|
-
`https://atlas.terrascale.tech` with the native `tbk1` database key. The client
|
|
49
|
-
selects an eligible canonical regional origin and checks its bounded lease again
|
|
50
|
-
before dispatch. `discoveryTimeoutMs` defaults to 3000 and accepts 1–30000 ms.
|
|
51
|
-
Each operation uses the receiver's highest-priority endpoint with the required
|
|
52
|
-
capabilities. Discovery denial, unavailability, invalid or expired leases, and
|
|
53
|
-
missing capabilities return a typed error before any native data request.
|
|
54
|
-
Set `endpoint` to use an independently provisioned direct HTTPS origin. HTTP is
|
|
55
|
-
allowed only on loopback for development, and the public test host is rejected.
|
|
56
|
-
Database keys and hosted identity management keys are separate credentials.
|
|
57
|
-
|
|
58
|
-
The admitted Atlas receiver advertises conditional mutations, atomic groups,
|
|
59
|
-
and security state as unavailable. Discovered clients refuse those operations
|
|
60
|
-
before native dispatch. Direct local native conditional semantics do not grant
|
|
61
|
-
those production capabilities.
|
|
62
|
-
|
|
63
|
-
For authentication/security conditional writes, use the provisioned single-writer authority, including
|
|
64
|
-
its generation and writer identity. An absent condition requires absence; a
|
|
65
|
-
version condition compares the complete point's state token. Copy the point's
|
|
66
|
-
full context into `observed` for replacement or deletion. Causal observation
|
|
67
|
-
alone does not establish compare-and-swap. Direct leaderless conditional commits
|
|
68
|
-
prove only the admitted local native exclusion semantics; they do not establish
|
|
69
|
-
distributed writer fencing. Leaderless storage is unsuitable for
|
|
70
|
-
security state and authentication invariants.
|
|
71
|
-
|
|
72
|
-
`prepareCommit` snapshots the request and computes its canonical SHA-256 effect
|
|
73
|
-
fingerprint. Reuse that prepared transaction on the same client for an exact
|
|
74
|
-
retry; a changed effect requires a new transaction identity. Mutations are not
|
|
75
|
-
automatically replayed. Resolve an uncertain mutation with transaction status;
|
|
76
|
-
unknown, pending, and expired status do not establish an abort. Persist the
|
|
77
|
-
transaction identity, authority, and fingerprint when recovery spans restarts.
|
|
78
|
-
`local_durable` and `object_durable` are distinct acknowledgement levels.
|
|
79
|
-
|
|
80
|
-
`terrascale/ts-auth` contains the separate hosted identity management and
|
|
81
|
-
OIDC client. Its private transport preserves form-encoded token operations,
|
|
82
|
-
bounded responses, deadlines, and a single changed-token refresh. Configure
|
|
83
|
-
its own origin, instance, and identity credentials.
|
|
84
|
-
|
|
85
|
-
`terrascale/local` is an explicitly enabled Node development runtime:
|
|
30
|
+
Provision the project, database and collection before using their handles.
|
|
31
|
+
API keys begin with `tb_` and travel as `Authorization: Bearer <key>`.
|
|
32
|
+
Reads and queries require `documents:read`; writes and transactions require
|
|
33
|
+
`documents:write`. Transaction assertions additionally require `documents:read`.
|
|
34
|
+
Keep keys private and out of logs and browser bundles. `createTerraBaseClient`
|
|
35
|
+
is an alias of `createTerraBaseV1Client`; it no longer accepts tenant/shard options.
|
|
36
|
+
|
|
37
|
+
## Atlas and endpoint selection
|
|
38
|
+
|
|
39
|
+
Supply exactly one of `baseUrl` or `endpointResolver`. A resolver receives
|
|
40
|
+
`{ project, database }` and returns the service URL, synchronously or asynchronously.
|
|
41
|
+
The URL is resolved once per database session and reused by its operations.
|
|
42
|
+
Shared resolution expires after 30 seconds and supplies a cancellation signal
|
|
43
|
+
to the resolver; a later operation can retry an expired or failed resolution.
|
|
44
|
+
Cancelling one operation leaves other callers' shared resolution running.
|
|
45
|
+
HTTPS is required except for loopback HTTP in local development; no regional
|
|
46
|
+
host is hardcoded and no implicit production endpoint is selected.
|
|
86
47
|
|
|
87
48
|
```js
|
|
88
|
-
import {
|
|
49
|
+
import { createTerraBaseV1Client, staticBaseUrlResolver } from "terrascale";
|
|
89
50
|
|
|
90
|
-
const
|
|
91
|
-
|
|
51
|
+
const client = createTerraBaseV1Client({
|
|
52
|
+
project: process.env.TERRABASE_PROJECT,
|
|
53
|
+
token: process.env.TERRABASE_API_KEY,
|
|
54
|
+
endpointResolver: staticBaseUrlResolver(process.env.TERRABASE_BASE_URL),
|
|
92
55
|
});
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
56
|
+
const db = client.database("app");
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Atlas (`ts-atlas`, a TypeScript Cloudflare Worker) discovers the closest eligible
|
|
60
|
+
region and the location of a project/database. The resolver seam allows that
|
|
61
|
+
choice to stay pinned for the session. Atlas discovery integration is deferred
|
|
62
|
+
to TS-507; this release requires an explicit URL or caller-supplied resolver.
|
|
63
|
+
|
|
64
|
+
## Documents, queries, transactions and shapes
|
|
65
|
+
|
|
66
|
+
The C# producer owns these routes:
|
|
67
|
+
|
|
68
|
+
| Operation | Method and path |
|
|
69
|
+
| --- | --- |
|
|
70
|
+
| Documents | `GET/PUT/PATCH/DELETE /v1/projects/{project}/databases/{db}/collections/{c}/documents/{id}`; `POST …/documents` |
|
|
71
|
+
| Query | `POST /v1/projects/{project}/databases/{db}/collections/{c}/query` |
|
|
72
|
+
| Transaction | `POST /v1/projects/{project}/databases/{db}/transactions` |
|
|
73
|
+
| Shape | `GET /v1/projects/{project}/databases/{db}/collections/{c}/shape` |
|
|
74
|
+
|
|
75
|
+
Collection methods are `get`, `put`, `create`, `patch`, `delete`, `query`,
|
|
76
|
+
`pages` and `items`. New document IDs are canonical UUIDs; `documentIdFor`
|
|
77
|
+
generates a stable UUIDv5 from a natural key. Documents return
|
|
78
|
+
`{ id, version, state: "value", document }`. Writes return the version and a
|
|
79
|
+
decimal-string commit `offset`; preserve those opaque positions and use
|
|
80
|
+
`ifMatch` or `ifNoneMatchAny` for conditional writes.
|
|
81
|
+
|
|
82
|
+
Queries support typed filters, sorting, projection and bounded cursor pages.
|
|
83
|
+
`query` returns one page; `pages` and `items` follow `nextCursor`.
|
|
84
|
+
`count.exact: false` means the count is a lower bound. The current C# producer
|
|
85
|
+
does not support `lower` paths or `explain`; query number comparisons use its
|
|
86
|
+
64-bit integer/double arithmetic, even when the SDK preserves exact JSON numbers.
|
|
87
|
+
`ExactDecimal` and bigint serialization require Node.js 22+ or a current browser.
|
|
88
|
+
|
|
89
|
+
`db.transaction()` builds one bounded atomic group across collections in that
|
|
90
|
+
database. It supports document operations, `assert`, `assertAbsent` and
|
|
91
|
+
`assertCount`; assertions examine the state before the group's writes.
|
|
92
|
+
The C# producer rejects `Idempotency-Key`. Do not enable automatic idempotency
|
|
93
|
+
or replay mutations after an uncertain result; this release does not promise
|
|
94
|
+
mutation deduplication. Validation, authentication, authorization and
|
|
95
|
+
precondition failures are not automatically retried.
|
|
96
|
+
|
|
97
|
+
Shapes require `shapes:read` and use the collection's GET route with a `where`
|
|
98
|
+
filter, handle, offset and live cursor. Snapshot bootstrap and checkpoint resume
|
|
99
|
+
provide correctness; `must_refetch` requires discarding local state and starting
|
|
100
|
+
a fresh snapshot. The C# producer has no shape gatekeeper, SSE route, edge shape
|
|
101
|
+
token or projection support. Origin responses require private cache revalidation. Fresh shape bootstrap is
|
|
102
|
+
server-only in this release: browsers hide the initial 307 redirect metadata.
|
|
103
|
+
Browser callers need a handle and snapshot offset obtained on their server.
|
|
104
|
+
|
|
105
|
+
The same public SDK supplies this metadata on the server. Pass the position to
|
|
106
|
+
the browser and repeat that immutable snapshot page with the identical filter
|
|
107
|
+
and collection:
|
|
108
|
+
|
|
109
|
+
```js
|
|
110
|
+
// Server: use the public client with the caller's shapes:read key.
|
|
111
|
+
const snapshot = await serverCollection.shape({ where });
|
|
112
|
+
const position = { handle: snapshot.handle, offset: snapshot.offset };
|
|
113
|
+
// Browser: resume using position supplied by your application server.
|
|
114
|
+
const page = await browserCollection.shape({ where, ...position });
|
|
101
115
|
```
|
|
102
116
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
117
|
+
Failures throw `TerraBaseV1Error` with the HTTP status and producer error code;
|
|
118
|
+
transaction failures may also identify the failing `op`. Request cancellation
|
|
119
|
+
uses `AbortSignal`.
|
|
120
|
+
|
|
121
|
+
## Ouroboros and qualification
|
|
122
|
+
|
|
123
|
+
Ouroboros means TerraScale services store their data in the same production
|
|
124
|
+
TerraBase that customers use. SDK boundary tests must run the real C# TerraBase
|
|
125
|
+
release binary, pinned by immutable version and SHA-256, with an isolated
|
|
126
|
+
allocation. A fixture, mocked transport, SQLite SDK runtime, frozen Rust
|
|
127
|
+
contract archive or typed build cannot establish producer compatibility.
|
|
128
|
+
|
|
129
|
+
The v1 route manifest and producer contract evidence must agree with the C#
|
|
130
|
+
release under test. Keep live tests environment-gated; report missing local
|
|
131
|
+
configuration as skipped, never as successful integration evidence. Required
|
|
132
|
+
release qualification must supply the verified binary and real producer inputs.
|
|
133
|
+
Never commit keys, cookies, environment files or real tenant data.
|
|
134
|
+
|
|
135
|
+
The immutable release pin is
|
|
136
|
+
[`scripts/ci/terrabase-release.json`](scripts/ci/terrabase-release.json): C#
|
|
137
|
+
TerraBase 0.1.0, release `ci-0248ad3ac6fb82ac900e38005840a619e5d0beac-run-13267`,
|
|
138
|
+
with binary SHA-256
|
|
139
|
+
`8abcedaa6b8487f08ecafe4485862f1f9309154e58ac1a74eda2278b78500968`.
|
|
140
|
+
This official release is currently a draft: the producer's fast checks failed
|
|
141
|
+
and publication was skipped (terrabase #110). The SDK integration harness may
|
|
142
|
+
consume its official asset read-only when the version, source revision, size and
|
|
143
|
+
SHA-256 are verified; publication is not required. Draft status does not establish
|
|
144
|
+
that the producer's source qualification passed.
|
|
145
|
+
The acquisition script verifies the official release, revision, asset size and
|
|
146
|
+
digest. Private downloads require `FORGEJO_TOKEN`. Missing or mismatched official
|
|
147
|
+
assets block qualification rather than selecting older bytes.
|
|
148
|
+
|
|
149
|
+
```sh
|
|
150
|
+
nice -n 19 npm run provision:terrabase
|
|
151
|
+
export TERRABASE_BINARY=/absolute/path/printed/by/the/provisioner
|
|
152
|
+
nice -n 19 npm run test:integration
|
|
153
|
+
```
|
|
107
154
|
|
|
108
|
-
The
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
155
|
+
The integration runner rechecks the binary digest, starts an isolated TLS server,
|
|
156
|
+
verifies its version and runtime OpenAPI digest, and provisions a disposable
|
|
157
|
+
organization, project, database, collections and scoped keys. It supplies the
|
|
158
|
+
`TB_V1_*` environment and trusted local certificate to the real-server tests and
|
|
159
|
+
cleans up the process and allocation afterwards. No TLS validation is disabled.
|
|
160
|
+
Direct live test configuration uses `TB_V1_URL`, `TB_V1_PROJECT`,
|
|
161
|
+
`TB_V1_DATA_KEY` and optionally `TB_V1_DATABASE` (default `app`);
|
|
162
|
+
`TB_V1_REQUIRED=1` makes absent integration inputs fail rather than skip.
|
|
112
163
|
|
|
113
|
-
|
|
114
|
-
when that version is not yet published. Bump the version to release.
|
|
164
|
+
Local checks run at low CPU priority:
|
|
115
165
|
|
|
116
166
|
```sh
|
|
117
|
-
npm ci
|
|
118
|
-
npm run typecheck
|
|
119
|
-
npm run
|
|
120
|
-
npm
|
|
121
|
-
npm
|
|
122
|
-
npm run check:current-contract-inputs
|
|
123
|
-
npm run check:current-contract
|
|
124
|
-
npm run test:browser
|
|
167
|
+
nice -n 19 npm ci
|
|
168
|
+
nice -n 19 npm run typecheck
|
|
169
|
+
nice -n 19 npm run lint
|
|
170
|
+
nice -n 19 npm run build
|
|
171
|
+
nice -n 19 npm test
|
|
125
172
|
```
|
|
126
173
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
174
|
+
`lint` reuses the strict TypeScript/JSDoc check, including unused-code checks,
|
|
175
|
+
without adding a linter dependency. CI runs these commands at normal priority.
|
|
176
|
+
See [CHANGELOG.md](CHANGELOG.md) for the 1.0.0 migration and breaking changes.
|
|
177
|
+
|
|
178
|
+
## Separate and deprecated entrypoints
|
|
179
|
+
|
|
180
|
+
`terrascale/ts-auth` retains its separate hosted identity management and OIDC
|
|
181
|
+
client, with its own origin, instance and credentials. Management,
|
|
182
|
+
administration and production Better Auth capabilities remain subject to their
|
|
183
|
+
explicit admission errors; they are not a shortcut into the database transport.
|
|
184
|
+
|
|
185
|
+
`terrascale/local` (including `terrascale-local`) and `terrascale/postgres` are
|
|
186
|
+
**deprecated legacy entrypoints**. SQLite stays opt-in for development only and
|
|
187
|
+
refuses CI, production, staging, qualification and deployment environments.
|
|
188
|
+
It is no longer the required Dashboard backend and does not qualify the C# API.
|
|
189
|
+
The PostgreSQL listener and retired tenant/shard client are outside the default
|
|
190
|
+
v1 API. Existing framework, schema and SQL entrypoints are separate legacy
|
|
191
|
+
surfaces; the root entrypoint exposes the C# v1 client API.
|
|
132
192
|
|
|
133
193
|
Hosted OAuth resource requests use one exact registered HTTPS `resource`. `oidc.authorizationUrl`, `oidc.deviceAuthorization`, and the code, device, refresh, and client-credentials token grants retain its bytes, including path and query. Omission on a browser code or refresh flow preserves the stored no-resource binding; it never repairs a rejected audience or falls back to browser login. Refresh requests can ask for narrower scopes. Client credentials require explicit resource and scope values. Token and originating-client introspection methods use `client_secret_post`; public-client and originating-client Basic token authentication are not currently exposed by this SDK.
|
|
134
194
|
|
|
135
195
|
`oauthClients` and `oauthResources` provide the producer's snake_case policy records and named management operations. Resource PATCH requires `expected_auth_epoch`; client PATCH accepts it. JSON epochs outside JavaScript's exact integer range are rejected. Client PATCH returns a bare client view unless `rotate_secret` is true, when it returns the client and its one-time secret. Resource create/PATCH always return the resource and nullable one-time introspection secret.
|
|
136
196
|
|
|
137
197
|
Use `oidc.introspectResource` with independently configured `issuer`, exact `audience`, `introspection_client_id`, and `introspection_secret`. It uses resource Basic authentication only, with each credential component form encoded before Base64. An active result requires the exact configured issuer/audience, `Bearer`, integer timestamps valid at the local clock with no default skew, and the required user/service session shape. Inactive results contain only `active: false`. Resource results expose no internal epochs, refresh family, or token-use fields. The provider checks current durable token/session/resource state; an active principal or scope does not grant project ownership or management authority. Product authorization remains at the caller's existing authorization boundary.
|
|
138
|
-
|
|
139
|
-
Regional native database origins use `https://<region>.api.terrascale.tech`,
|
|
140
|
-
for example `https://gru.api.terrascale.tech`. The global API host and retired
|
|
141
|
-
root regional hosts cannot serve as native origins. Auth uses its separate
|
|
142
|
-
`.auth.terrascale.tech` namespace. Direct independent origins must use ASCII
|
|
143
|
-
hostnames; percent-encoded and Unicode hostname aliases are rejected.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "terrascale",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "JavaScript SDK, typed with JSDoc, for
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "JavaScript SDK, typed with JSDoc, for project-scoped C# TerraBase v1 and hosted TerraScale identity.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"private": false,
|
|
@@ -77,34 +77,29 @@
|
|
|
77
77
|
"!src/**/*.test.js",
|
|
78
78
|
"types",
|
|
79
79
|
"!types/integration",
|
|
80
|
-
"sdk-route-manifest.json",
|
|
81
|
-
"sdk-current-contract.json",
|
|
80
|
+
"sdk-v1-route-manifest.json",
|
|
82
81
|
"README.md",
|
|
82
|
+
"CHANGELOG.md",
|
|
83
83
|
"LICENSE"
|
|
84
84
|
],
|
|
85
85
|
"scripts": {
|
|
86
86
|
"build": "node -e \"require('node:fs').rmSync('types', { recursive: true, force: true })\" && tsc -p tsconfig.build.json",
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"check:route-manifest": "node scripts/generate-client-route-manifest.js --check",
|
|
90
|
-
"check:openapi-contract-descriptor": "node scripts/generate-openapi-contract-descriptor.js --check",
|
|
91
|
-
"check:public-contract-fixture": "vitest run test/public-contract-fixture.test.js",
|
|
87
|
+
"prepack": "npm run build",
|
|
88
|
+
"check:v1-route-manifest": "node scripts/generate-v1-route-manifest.js --check",
|
|
92
89
|
"check:forbidden-surface": "vitest run test/forbidden-surface.test.js",
|
|
93
90
|
"check:sbom": "node scripts/check-sbom.js",
|
|
94
91
|
"check:vulnerabilities": "node scripts/check-vulnerabilities.js",
|
|
95
|
-
"generate:route-manifest": "
|
|
96
|
-
"generate:openapi-contract-descriptor": "npm run build && node scripts/generate-openapi-contract-descriptor.js",
|
|
92
|
+
"generate:v1-route-manifest": "node scripts/generate-v1-route-manifest.js",
|
|
97
93
|
"local": "node src/local/cli.js",
|
|
98
94
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
95
|
+
"lint": "npm run typecheck",
|
|
99
96
|
"test": "vitest run",
|
|
97
|
+
"provision:terrabase": "node scripts/ci/provision-terrabase.mjs",
|
|
98
|
+
"test:integration": "node scripts/ci/run-terrabase-integration.mjs",
|
|
100
99
|
"test:browser": "playwright test",
|
|
101
|
-
"check:current-contract": "vitest run test/current-producer-contract.test.js test/openapi-drift.test.js",
|
|
102
100
|
"qualify:auth-authority": "node scripts/qualify-auth-authority.js",
|
|
103
|
-
"qualify:release-e2e": "node scripts/run-packed-release-e2e.js",
|
|
104
|
-
"check:current-contract-inputs": "node scripts/openapi-contract-paths.js --check-inputs",
|
|
105
101
|
"check:frameworks": "vitest run src/database-view.test.js src/react/core.test.js src/svelte/index.test.js src/tanstack/index.test.js",
|
|
106
|
-
"check:local-better-auth": "vitest run src/better-auth-factory-conformance.test.js"
|
|
107
|
-
"qualify:current-postgres-producer": "node scripts/current-postgres-producer.js"
|
|
102
|
+
"check:local-better-auth": "vitest run src/better-auth-factory-conformance.test.js"
|
|
108
103
|
},
|
|
109
104
|
"peerDependencies": {
|
|
110
105
|
"@better-auth/core": "1.7.2",
|