@oddington/sdk 0.1.5 → 0.1.7
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 +119 -2
- package/dist/index.js +1419 -344
- package/dist/types/packages/sdk/src/public.d.ts +66 -2
- package/dist/types/shared/data-contract.d.ts +14 -0
- package/dist/types/shared/files-contract.d.ts +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -29,6 +29,90 @@ session subscription. Workspace existence and member access are checked by the
|
|
|
29
29
|
OS service. App modules use capability namespaces; routines and handlers receive
|
|
30
30
|
runtime context without calling `os.init`.
|
|
31
31
|
|
|
32
|
+
The same `os.init({ auth })` call also consumes authenticated bootstrap state on
|
|
33
|
+
an OS-launched IPv4 loopback origin. It checks `/_os/app/context` on that exact
|
|
34
|
+
origin for every protected operation, without reading hosted access credentials.
|
|
35
|
+
It accepts no workspace, endpoint or token option. Missing, forged, expired or
|
|
36
|
+
changed local context fails closed, as do sign-out and initialization replacement.
|
|
37
|
+
Local Data and Files currently return `context_unavailable` and
|
|
38
|
+
`unsupported_context` respectively after checking context; they do not return
|
|
39
|
+
empty data, upload locally or fall back to hosted services. Local app routine
|
|
40
|
+
execution uses the installed routine's immediate-publication authority.
|
|
41
|
+
|
|
42
|
+
Apps can assess a declared routine without starting it:
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
import { app, type AppRoutineBinding } from '@oddington/sdk';
|
|
46
|
+
|
|
47
|
+
declare module '@oddington/sdk' {
|
|
48
|
+
interface AppRoutineTypes {
|
|
49
|
+
reconcile: AppRoutineBinding<
|
|
50
|
+
{ includeArchived?: boolean; limit: number },
|
|
51
|
+
{ processed: number },
|
|
52
|
+
{ read: undefined; write: { changed: number } }
|
|
53
|
+
>;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const status = await app.routines.reconcile.availability();
|
|
58
|
+
if (status.available) {
|
|
59
|
+
const steps: ('read' | 'write')[] = status.steps;
|
|
60
|
+
}
|
|
61
|
+
const run = await app.routines.reconcile.run({ limit: 2 });
|
|
62
|
+
for await (const event of run.events()) {
|
|
63
|
+
if (event.type === 'step' && event.id === 'write') console.log(event.summary.changed);
|
|
64
|
+
if (event.type === 'finished' && event.state === 'succeeded') console.log(event.result.processed);
|
|
65
|
+
}
|
|
66
|
+
// After refresh or reopening the same live origin:
|
|
67
|
+
const recovered = await app.routines.reconcile.recover();
|
|
68
|
+
// await recovered[0]?.cancel(); // Resolves only after host acknowledgement.
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Keep these business types in a customer-owned contract module. Augmentation
|
|
72
|
+
types the property but grants no runtime authority: the local host checks its
|
|
73
|
+
retained `app.json` mapping, current member and installed routine authority,
|
|
74
|
+
and fixed local implementation on each assessment. Available status supplies
|
|
75
|
+
only the declaration's ordered public step IDs. Unavailability supplies only
|
|
76
|
+
`authority_unavailable` or `execution_unavailable`, without steps.
|
|
77
|
+
Availability and recovery accept no arguments; run accepts only declared input.
|
|
78
|
+
Bindings accept no endpoint, token, path, run selector or routine name. Hosted
|
|
79
|
+
bindings report `execution_unavailable` after checking current context, with no
|
|
80
|
+
remote request or local fallback. Availability is no reservation or guarantee
|
|
81
|
+
of later execution. `run` rejects with `AppRoutineError.reason`:
|
|
82
|
+
`authority_unavailable`, `execution_unavailable`, or `invalid_input`.
|
|
83
|
+
Only event reads reconnect, with bounded backoff and duplicate suppression;
|
|
84
|
+
launch and cancellation requests are never automatically retried. Failed
|
|
85
|
+
cancellation requests do not acknowledge cancellation. Handles expose no IDs,
|
|
86
|
+
cursors, raw output or process controls. Local sign-out, expiry, context
|
|
87
|
+
replacement and origin/credential changes invalidate pending work.
|
|
88
|
+
|
|
89
|
+
The exact-origin browser credential survives reload and tab closure in local
|
|
90
|
+
storage. Host expiry and current membership remain authoritative; stored state
|
|
91
|
+
cannot revive a stopped host. Recovery covers only the operation's current
|
|
92
|
+
session and bounded terminal grace, without relaunching or durable history.
|
|
93
|
+
Supplied File inputs currently reject `execution_unavailable` before launch;
|
|
94
|
+
File-use transfer and local Data/Files adapters are separate work.
|
|
95
|
+
|
|
96
|
+
The fixed child imports `appRun` from the same package and shares the app's
|
|
97
|
+
customer-owned input/result/step types:
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
import { appRun } from '@oddington/sdk';
|
|
101
|
+
import type { Input, Result, Steps } from './contract.ts';
|
|
102
|
+
|
|
103
|
+
const context = appRun.current<Input, Result, Steps>();
|
|
104
|
+
if (context) {
|
|
105
|
+
await context.step('read');
|
|
106
|
+
await context.step('write', { changed: 1 });
|
|
107
|
+
await context.finish({ processed: context.input.limit });
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
`appRun.current()` is absent in ordinary Node and browser execution. Child
|
|
112
|
+
input is deeply immutable; declared reports await host acceptance. Success
|
|
113
|
+
requires accepted finish and zero exit. Cancellation or later failure does not
|
|
114
|
+
undo already confirmed shared effects.
|
|
115
|
+
|
|
32
116
|
Create and recover a private immutable original through the same host context:
|
|
33
117
|
|
|
34
118
|
```ts
|
|
@@ -140,8 +224,41 @@ Each graph selection sends one request and returns only selected canonical
|
|
|
140
224
|
values, expanded forward links and exact opaque public versions. Cursors
|
|
141
225
|
continue the exact retained artifact and collection selection, even after
|
|
142
226
|
replacement; repeat its options and links while omitting unrelated collections.
|
|
143
|
-
|
|
144
|
-
|
|
227
|
+
There is no automatic retry or separate version fetch. History is not included.
|
|
228
|
+
Collection schemas omit Markdown storage hints.
|
|
229
|
+
|
|
230
|
+
Use bounded plain-text lookup to find full Records and guards:
|
|
231
|
+
|
|
232
|
+
```ts
|
|
233
|
+
const found = await general.records.search('acme overdue', {
|
|
234
|
+
collections: ['invoices'], limit: 20,
|
|
235
|
+
});
|
|
236
|
+
const searchedVersion = found.$meta.version;
|
|
237
|
+
for (const { collection, record } of found.matches) {
|
|
238
|
+
console.log(collection, record.$ref, record.$version);
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
Search sends one request. The trimmed query has 1–256 Unicode code points;
|
|
243
|
+
case-insensitive whitespace-separated terms match stable refs and structured
|
|
244
|
+
scalar values, including link refs and array values. Every term must match;
|
|
245
|
+
field names and Markdown bodies are excluded. Omitted options search all
|
|
246
|
+
accessible collections with a limit of 20. Supplied collections contain 1–16
|
|
247
|
+
distinct accessible names; the integer limit is 1–100. Invalid queries or
|
|
248
|
+
unsupported options fail with `invalid_query`. There is no cursor, count,
|
|
249
|
+
projection, highlighting, embedding or historical version option.
|
|
250
|
+
|
|
251
|
+
Matches have deterministic order and complete canonical Records. Empty matches
|
|
252
|
+
succeed with the exact searched version. Members search latest published data;
|
|
253
|
+
routines search their captured version, advancing only through their own
|
|
254
|
+
publication. Immediate `os routine run` uses hosted search. During
|
|
255
|
+
`os routine prepare`, search uses the same committed local Index as select,
|
|
256
|
+
ignores dirty/untracked files and advances only to that run's exact proposed
|
|
257
|
+
version after its own Changes publication. Validation does not advance reads;
|
|
258
|
+
another publisher does not move the captured view. Search Records can supply
|
|
259
|
+
guards for subsequent Changes. Missing or incomplete search data, including
|
|
260
|
+
retained versions without it, fails retryably with `unavailable` without an
|
|
261
|
+
alternate read path.
|
|
145
262
|
|
|
146
263
|
`where` combines field conditions with AND. Alongside exact scalar/null equality
|
|
147
264
|
and `$in`, declared one-valued `integer`, `number` and `date` fields accept
|