@oddington/sdk 0.1.79 → 0.1.80
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 +69 -0
- package/dist/browser.js +4493 -4154
- package/dist/index.js +10 -10
- package/dist/types/packages/sdk/src/public.d.ts +7 -0
- package/dist/types/packages/sdk/src/query-definition-types.d.ts +31 -0
- package/dist/types/packages/sdk/src/routine-reference-types.d.ts +90 -0
- package/dist/types/shared/routine-ai-contract.d.ts +4 -0
- package/dist/types/shared/routine-ai-error-detail.d.ts +6 -0
- package/dist/types/shared/routine-definition-contract.d.ts +1 -0
- package/dist/types/shared/routine-deployment-contract.d.ts +2 -0
- package/dist/types/shared/routine-executable-contract.d.ts +2 -0
- package/dist/types/shared/routine-operation-error.d.ts +10 -0
- package/dist/types/shared/routine-query-contract.d.ts +16 -0
- package/dist/types/shared/routine-query-results.d.ts +41 -0
- package/dist/types/shared/routine-queue-contract.d.ts +30 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -43,6 +43,75 @@ context. API tokens belong in trusted server-side automation; do not embed them
|
|
|
43
43
|
in browser code. API clients cannot publish Asks or Files Blocks, read Inbox or
|
|
44
44
|
Records, use Connections, or start Runs.
|
|
45
45
|
|
|
46
|
+
## Routine queues and queries
|
|
47
|
+
|
|
48
|
+
SDK 0.1.80 adds customer-authored adjacent queries and retained default queues.
|
|
49
|
+
Each hosted routine has one queue, initially Paused. One complete input is one
|
|
50
|
+
item, including a deliberate array or batch. Deploy `routine.ts` and optional
|
|
51
|
+
adjacent `queries.ts` together with `os routine deploy <id>`.
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
// handle-email/queries.ts
|
|
55
|
+
import { defineQuery, routines } from '@oddington/sdk';
|
|
56
|
+
import type definition from './routine';
|
|
57
|
+
|
|
58
|
+
const email = routines.get<typeof definition>('handle-email');
|
|
59
|
+
export const mailbox = defineQuery({
|
|
60
|
+
id: 'mailbox',
|
|
61
|
+
queue: email.queue,
|
|
62
|
+
triggers: [], // Manual; optionally declare { schedule: { cron, timezone } }.
|
|
63
|
+
async *run(_trigger, os) {
|
|
64
|
+
const messages = [{ id: 'message-1' }, { id: 'message-2' }];
|
|
65
|
+
await os.query.progress({ total: messages.length });
|
|
66
|
+
yield messages.map(message => ({
|
|
67
|
+
idempotencyKey: message.id,
|
|
68
|
+
input: { messageId: message.id }, // The routine's complete input.
|
|
69
|
+
}));
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Replace the example selection and input with your routine's actual contract.
|
|
75
|
+
Queries declare their own access; processing access is not inherited. Yielded
|
|
76
|
+
arrays are groups of keyed inputs. A routine's batch input stays inside one
|
|
77
|
+
entry's `input`. Saved work survives a later query failure. Repeating a key with
|
|
78
|
+
the same input finds the retained item, including failed, succeeded or removed
|
|
79
|
+
work; changed input conflicts. Repeated discovery never requests a retry.
|
|
80
|
+
|
|
81
|
+
Reference construction performs no I/O and grants no authority. In the trusted
|
|
82
|
+
member host, the operating surface is:
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
await email.queue.current();
|
|
86
|
+
const page = await email.queue.list({ limit: 100 }); // { items, next? }
|
|
87
|
+
const item = await email.queue.add({ messageId: 'message-1' }, {
|
|
88
|
+
idempotencyKey: 'message-1',
|
|
89
|
+
});
|
|
90
|
+
await email.queue.resume();
|
|
91
|
+
const query = email.queries.get('mailbox');
|
|
92
|
+
const execution = await query.run(); // Accepted execution handle.
|
|
93
|
+
await execution.current();
|
|
94
|
+
await query.executions.list({ limit: 100 });
|
|
95
|
+
await email.runs.list();
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Queue `pause`, `get`, `remove` and `retry(itemId, { failureId })`, query
|
|
99
|
+
`current`/`list`, and retained processing `(await email.runs.get(id)).current()`/`step(stepId)`
|
|
100
|
+
share the same host-bound surface. Follow `next` for every queue/history page.
|
|
101
|
+
Resume independently drains pending work at concurrency one; one failed item
|
|
102
|
+
does not block later items. Retry uses the observed failure identity and selects
|
|
103
|
+
the current successful deployment. Historical items and Runs have unknown input
|
|
104
|
+
and result types because earlier deployments can have different contracts;
|
|
105
|
+
submitted `queue.add` inputs and direct `run` results retain current inference.
|
|
106
|
+
The SDK does not replay failed transport mutations. Query totals may be unknown.
|
|
107
|
+
|
|
108
|
+
The CLI supplies its existing signed-in member/workspace context. Public
|
|
109
|
+
references outside a supported host fail without I/O. This release adds no
|
|
110
|
+
browser queue adapter or API-token queue authority. Customer routine code can
|
|
111
|
+
add complete inputs through its admitted execution context; query additions
|
|
112
|
+
remain confined to the pinned destination. Use the CLI commands below for
|
|
113
|
+
member operations without an app.
|
|
114
|
+
|
|
46
115
|
## Apps and routines
|
|
47
116
|
|
|
48
117
|
When developing OS alongside a customer repository, use the repository's
|