@oddington/sdk 0.1.6 → 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 +84 -0
- package/dist/index.js +1249 -298
- package/dist/types/packages/sdk/src/public.d.ts +65 -1
- 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
|