@oddington/sdk 0.1.1 → 0.1.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/README.md +89 -2
- package/dist/index.js +8180 -8356
- package/dist/types/packages/sdk/src/public.d.ts +44 -2
- package/dist/types/shared/airtable-contract.d.ts +82 -0
- package/dist/types/shared/data-contract.d.ts +95 -0
- package/dist/types/shared/inbox-contract.d.ts +2 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# Oddington SDK
|
|
2
2
|
|
|
3
|
-
The importable client for Oddington routines and response handlers.
|
|
4
|
-
Node.js 22.12.0 or later.
|
|
3
|
+
The importable client for Oddington apps, routines and response handlers.
|
|
4
|
+
Node operations require Node.js 22.12.0 or later. The root import and hosted
|
|
5
|
+
Data API work in browsers. Installing the package grants no authority.
|
|
5
6
|
|
|
6
7
|
```sh
|
|
7
8
|
npm install @oddington/sdk
|
|
@@ -13,6 +14,92 @@ import { defineHandler, resolveAsk, routinePublicationClient } from '@oddington/
|
|
|
13
14
|
const inbox = routinePublicationClient();
|
|
14
15
|
```
|
|
15
16
|
|
|
17
|
+
The OS-owned browser entry point initializes the existing shared refreshing
|
|
18
|
+
session source before app code runs:
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { os } from '@oddington/sdk';
|
|
22
|
+
|
|
23
|
+
os.init({ auth });
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
This returns `void` and derives context from the current HTTPS workspace origin
|
|
27
|
+
under `oddington.ai`, excluding `auth`. Reinitialization replaces the previous
|
|
28
|
+
session subscription. Workspace existence and member access are checked by the
|
|
29
|
+
OS service. App modules use capability namespaces; routines and handlers receive
|
|
30
|
+
runtime context without calling `os.init`.
|
|
31
|
+
|
|
32
|
+
Read a named repository through the authenticated host context:
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { data, DataOperationError } from '@oddington/sdk';
|
|
36
|
+
|
|
37
|
+
const general = data.repository('general');
|
|
38
|
+
const collections = await general.collections.list();
|
|
39
|
+
const schema = await general.collections.schema('invoices');
|
|
40
|
+
const first = await general.records.select({
|
|
41
|
+
invoices: { $: { limit: 50 }, supplier: { $: { fields: ['name'] } } },
|
|
42
|
+
suppliers: {},
|
|
43
|
+
});
|
|
44
|
+
const next = first.$meta.collections.invoices.next;
|
|
45
|
+
if (next) await general.records.select({
|
|
46
|
+
invoices: { $: { limit: 50, after: next }, supplier: { $: { fields: ['name'] } } },
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Binding is inert. Each operation resolves current workspace, endpoint and
|
|
51
|
+
short-lived authority from the trusted app host or managed routine context.
|
|
52
|
+
Customer calls cannot configure those values. Missing or expired context
|
|
53
|
+
rejects; a named handle does not expand repository access. During explicit
|
|
54
|
+
`os routine run --local`, the same calls use the matched checkout's committed
|
|
55
|
+
version through a private parent transport. Dirty files are ignored. An OS
|
|
56
|
+
cache outside the checkout reuses derived data; reads require no remote access
|
|
57
|
+
or preparation storage. Later accepted record effects advance the run's view
|
|
58
|
+
to their exact proposed version. Login, installed grants and provider authority
|
|
59
|
+
retain their normal checks. A dead local parent fails without hosted fallback.
|
|
60
|
+
|
|
61
|
+
Each graph selection sends one request and returns only selected canonical
|
|
62
|
+
values, expanded forward links and exact opaque public versions. Cursors
|
|
63
|
+
continue the exact retained artifact and collection selection, even after
|
|
64
|
+
replacement; repeat its options and links while omitting unrelated collections.
|
|
65
|
+
No automatic retry, separate version fetch, search, history or changes operation
|
|
66
|
+
is included. Collection schemas omit Markdown storage hints.
|
|
67
|
+
`DataOperationError.code` distinguishes `context_unavailable`, `unauthenticated`,
|
|
68
|
+
`access_denied`, `invalid_query`, `request_too_large`, `capacity` and `unavailable`.
|
|
69
|
+
Only `capacity` and `unavailable` are retryable; an error never includes private
|
|
70
|
+
server details. Server boundaries own query bounds and authorization.
|
|
71
|
+
|
|
72
|
+
Bind a declared Airtable connection with `connections.airtable('project-management')`
|
|
73
|
+
from the package root. Import and binding perform no network or credential work.
|
|
74
|
+
The client exposes `tables.list()` and `records.list`, `get`, `create`, `update`
|
|
75
|
+
and `delete`. Reads allow table names or stable IDs and return all ordered pages;
|
|
76
|
+
writes require a stable table ID and one nonempty batch of at most ten records.
|
|
77
|
+
Operations cannot select another workspace, base, token or provider URL.
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
import { connections } from '@oddington/sdk';
|
|
81
|
+
|
|
82
|
+
const airtable = connections.airtable('project-management');
|
|
83
|
+
const changed = await airtable.records.update({ table: 'tblContacts', records: [{
|
|
84
|
+
id: 'recRetained', expected: { Email: 'james@example.com', Company: null },
|
|
85
|
+
set: { Company: ['recCompany'] },
|
|
86
|
+
}] });
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Preserve original reviewed `expected` values. Non-null values must match exactly;
|
|
90
|
+
`null` requires an omitted field key and cannot be used as an update value. Reads
|
|
91
|
+
preserve Airtable's omitted-field shape. Create requires nonempty `fields`, update
|
|
92
|
+
requires nonempty `set`, and untouched fields remain unchanged. Guarded methods
|
|
93
|
+
read before a single batch write; this leaves a concurrency race and provides no
|
|
94
|
+
atomic compare-and-swap, rollback or implicit retry.
|
|
95
|
+
|
|
96
|
+
Success returns a safe Airtable `receipt` with the connection, configured base,
|
|
97
|
+
table, operation and acknowledged IDs. Create/update also return acknowledged
|
|
98
|
+
records separately. `AirtableOperationError` reports `unapplied`, `partial` or
|
|
99
|
+
`uncertain` effects and known safe `receipts`. Stop after partial or uncertain
|
|
100
|
+
work; never repeat the whole change blindly. Credentials must never be retained
|
|
101
|
+
in files, publication, logs, handler input, errors or receipts.
|
|
102
|
+
|
|
16
103
|
Managed routine launches supply workspace, scoped capability and working root.
|
|
17
104
|
The defaults read `ODDINGTON_ROUTINE_WORKSPACE`, `ODDINGTON_ROUTINE_RUN` and
|
|
18
105
|
`ODDINGTON_INBOX_WORKING_ROOT` (or the current directory). Callers may supply the
|