@oddington/sdk 0.1.13 → 0.1.15

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.
@@ -2,7 +2,7 @@ import type { AskInput, CapturedRecords, DigestInput, InboxFile, PublicationRequ
2
2
  import type { FileAddOptions } from '../../../shared/inbox-files.js';
3
3
  import type { RecordReadInput } from '../../../shared/record-capture.js';
4
4
  import type { RecordDeleteRequest, RecordUpdateRequest, RecordWriteRequest } from '../../../shared/record-write.js';
5
- export type { RoutineSchema, RoutineSchemaValue, RoutineDefinition, RoutineInput, RoutineRuntime } from './routine-definition-types.js';
5
+ export type { RoutineSchema, RoutineSchemaValue, RoutineDefinition, RoutineInput, RoutineRuntime, RoutineArtifactInput, RoutineArtifact } from './routine-definition-types.js';
6
6
  export declare const defineRoutine: import('./routine-definition-types.js').DefineRoutine;
7
7
  export declare const schema: import('./routine-definition-types.js').RoutineSchemaBuilders;
8
8
  export declare const file: import('./routine-definition-types.js').RoutineFileSchema;
@@ -22,6 +22,10 @@ export declare const data: {
22
22
  repository(name: string): import('../../../shared/data-contract.js').DataRepository;
23
23
  };
24
24
  export { FileOperationError } from '../../../shared/files-contract.js';
25
+ export { InboxOperationError } from '../../../shared/inbox-member-contract.js';
26
+ export type { InboxMember, InboxCurrent, QuestionItemSnapshot, QuestionSnapshot, ResponseConsequence, LinkedAskSnapshot, AskUpdate, DigestReadConfirmation, RecipientCandidate, RecipientAddition, ResponseAcceptance, InboxAnswerInput, InboxSearchInput } from '../../../shared/inbox-member-types.js';
27
+ export type { RecordSelectionResult } from '../../../shared/record-selection.js';
28
+ export declare const inbox: import('../../../shared/inbox-member-types.js').InboxMember;
25
29
  export type { File, FileInput, FileStorage, FileCreateInput, FileCreateOptions, FileEnrichment, FileEnrichOptions, FileEnrichResult, FileErrorCode } from '../../../shared/files-contract.js';
26
30
  export declare const files: {
27
31
  create(input: import('../../../shared/files-contract.js').FileCreateInput, options?: import('../../../shared/files-contract.js').FileCreateOptions): Promise<import('../../../shared/files-contract.js').File>;
@@ -13,6 +13,22 @@ export type RoutineSteps = Record<string, RoutineSchema<unknown> | null>;
13
13
  export type RoutineInput<Value> = Value extends object ? {
14
14
  readonly [Key in keyof Value]: RoutineInput<Value[Key]>;
15
15
  } : Value;
16
+ export type RoutineArtifactInput = Readonly<{
17
+ requestKey: string;
18
+ name: string;
19
+ mediaType: string;
20
+ size: number;
21
+ sha256: string;
22
+ content: Uint8Array | Blob | ReadableStream<Uint8Array>;
23
+ }>;
24
+ export type RoutineArtifact = Readonly<{
25
+ id: string;
26
+ attempt: string;
27
+ name: string;
28
+ mediaType: string;
29
+ size: number;
30
+ sha256: string;
31
+ }>;
16
32
  export type RoutineRuntime<Steps extends RoutineSteps> = {
17
33
  readonly run: {
18
34
  readonly id: string;
@@ -23,6 +39,7 @@ export type RoutineRuntime<Steps extends RoutineSteps> = {
23
39
  readonly files: typeof files;
24
40
  readonly connections: Connections;
25
41
  readonly inbox: RoutinePublicationClient;
42
+ artifact(input: RoutineArtifactInput): Promise<RoutineArtifact>;
26
43
  step<Key extends Extract<keyof Steps, string>>(id: Key, ...summary: Steps[Key] extends null ? [] : [summary: RoutineSchemaValue<Steps[Key]>]): Promise<void>;
27
44
  };
28
45
  export type RoutineDefinition<Input extends RoutineSchema<unknown> | undefined, Steps extends RoutineSteps, Result extends RoutineSchema<unknown> | undefined> = {
@@ -0,0 +1,19 @@
1
+ import type { InboxCurrent, QuestionItemSnapshot, ResponseAcceptance } from './inbox-member-types.js';
2
+ export declare class InboxOperationError extends Error {
3
+ readonly status: number;
4
+ readonly reason: 'invalid_input' | 'access_denied' | 'authority_unavailable' | 'conflict' | 'unavailable';
5
+ constructor(status: number, reason: 'invalid_input' | 'access_denied' | 'authority_unavailable' | 'conflict' | 'unavailable');
6
+ }
7
+ export declare const INBOX_RESULT_BYTES: number;
8
+ export declare const INBOX_INPUT_BYTES = 8192;
9
+ export declare const INBOX_UUID: RegExp;
10
+ export type InboxOperation = 'current' | 'items.list' | 'items.read' | 'items.see' | 'items.markDigestRead' | 'items.rename' | 'items.setLifecycle' | 'items.listRecipientCandidates' | 'items.addRecipient' | 'questions.answer' | 'questions.searchRecords' | 'files.read';
11
+ /** Closed wire vocabulary, shared by the SDK and its owning Worker. */
12
+ export declare function parseInboxRequest(value: unknown): {
13
+ operation: InboxOperation;
14
+ input: Record<string, unknown>;
15
+ };
16
+ export declare function parseInboxCurrent(value: unknown): InboxCurrent;
17
+ export declare function parseInboxItem(value: unknown): QuestionItemSnapshot;
18
+ export declare function parseInboxAcceptance(value: unknown): ResponseAcceptance;
19
+ export declare function parseInboxResult(operation: InboxOperation, value: unknown): unknown;
@@ -0,0 +1,174 @@
1
+ import type { InboxBlock, QuestionResponse, ResponseDefinition, RepositoryReceipt, RecordReference } from './inbox-contract.js';
2
+ import type { ResolvedView } from './inbox-views.js';
3
+ import type { RecordSelectionResult } from './record-selection.js';
4
+ export interface InboxCurrent {
5
+ workspace: {
6
+ id: string;
7
+ slug: string;
8
+ name: string;
9
+ locale: string;
10
+ timezone: string;
11
+ };
12
+ viewer: {
13
+ id: string;
14
+ name: string;
15
+ email: string;
16
+ };
17
+ }
18
+ export interface ResponseConsequence {
19
+ state: 'pending' | 'running' | 'applied' | 'no-write' | 'stopped' | 'partial' | 'uncertain';
20
+ phase: 'loading' | 'invoking' | 'committing' | null;
21
+ updatedAt: string;
22
+ evidence: RepositoryReceipt[];
23
+ needsReconciliation: boolean;
24
+ reason: string | null;
25
+ }
26
+ export interface QuestionSnapshot {
27
+ id: string;
28
+ to: string;
29
+ prompt: string;
30
+ instructions: string | null;
31
+ response: ResponseDefinition;
32
+ allowedResponders: string[];
33
+ available: boolean;
34
+ acceptedResponse: {
35
+ id: string;
36
+ userId: string;
37
+ response: QuestionResponse;
38
+ acceptedAt: string;
39
+ label?: string;
40
+ acceptanceOrder?: number;
41
+ } | null;
42
+ execution: {
43
+ id: string;
44
+ state: 'pending' | 'running' | 'completed' | 'failed';
45
+ attempt: number;
46
+ consequence?: ResponseConsequence;
47
+ } | null;
48
+ }
49
+ export type LinkedAskSnapshot = {
50
+ id: string;
51
+ title: string;
52
+ state: 'yours' | 'done' | 'open';
53
+ } | {
54
+ id: string;
55
+ title: string;
56
+ state: 'theirs';
57
+ assignee: {
58
+ id: string;
59
+ name: string;
60
+ };
61
+ } | {
62
+ id: string;
63
+ state: 'unavailable';
64
+ done: boolean;
65
+ };
66
+ export interface QuestionItemSnapshot {
67
+ id: string;
68
+ workspaceId: string;
69
+ number: number;
70
+ kind: 'ask' | 'digest';
71
+ title: string;
72
+ description: string;
73
+ author: string;
74
+ revision: number;
75
+ publishedAt: string;
76
+ outcome: {
77
+ outcome: string;
78
+ } | null;
79
+ seenAt: string | null;
80
+ digestReadAt: string | null;
81
+ lifecycle: 'open' | 'closed';
82
+ activityVersion: number;
83
+ views: ResolvedView[];
84
+ body: InboxBlock[];
85
+ linkedAsks: LinkedAskSnapshot[];
86
+ questions: QuestionSnapshot[];
87
+ people: {
88
+ id: string;
89
+ name: string;
90
+ }[];
91
+ activity: {
92
+ id: number;
93
+ type: string;
94
+ actorId: string | null;
95
+ questionId: string | null;
96
+ revision: number;
97
+ createdAt: string;
98
+ data: Record<string, unknown>;
99
+ }[];
100
+ work: {
101
+ id: string;
102
+ questionId: string;
103
+ reason: string;
104
+ settledAt: string | null;
105
+ }[];
106
+ }
107
+ export interface DigestReadConfirmation {
108
+ readAt: string;
109
+ activityId: number;
110
+ }
111
+ export interface ResponseAcceptance {
112
+ responseId: string;
113
+ executionId?: string;
114
+ acceptedAt: string;
115
+ label?: string;
116
+ acceptanceOrder?: number;
117
+ }
118
+ export interface AskUpdate {
119
+ item: QuestionItemSnapshot;
120
+ activityId: number | null;
121
+ changedAt: string | null;
122
+ }
123
+ export interface RecipientCandidate {
124
+ id: string;
125
+ name: string;
126
+ email: string;
127
+ }
128
+ export interface RecipientAddition {
129
+ item: QuestionItemSnapshot;
130
+ addedPersonId: string;
131
+ }
132
+ export type ItemRevision = {
133
+ itemId: string;
134
+ revision: number;
135
+ };
136
+ export type InboxAnswerInput = ItemRevision & {
137
+ questionId: string;
138
+ response: QuestionResponse;
139
+ };
140
+ export type InboxSearchInput = ItemRevision & {
141
+ questionId: string;
142
+ query: string;
143
+ selected?: RecordReference;
144
+ };
145
+ export interface InboxMember {
146
+ current(): Promise<InboxCurrent>;
147
+ items: {
148
+ list(): Promise<QuestionItemSnapshot[]>;
149
+ read(itemId: string): Promise<QuestionItemSnapshot>;
150
+ see(itemId: string): Promise<void>;
151
+ markDigestRead(itemId: string): Promise<DigestReadConfirmation>;
152
+ rename(input: ItemRevision & {
153
+ title: string;
154
+ }): Promise<AskUpdate>;
155
+ setLifecycle(input: ItemRevision & {
156
+ lifecycle: 'open' | 'closed';
157
+ }): Promise<AskUpdate>;
158
+ listRecipientCandidates(itemId: string): Promise<RecipientCandidate[]>;
159
+ addRecipient(input: {
160
+ itemId: string;
161
+ personId: string;
162
+ }): Promise<RecipientAddition>;
163
+ };
164
+ questions: {
165
+ answer(input: InboxAnswerInput): Promise<ResponseAcceptance>;
166
+ searchRecords(input: InboxSearchInput): Promise<RecordSelectionResult>;
167
+ };
168
+ files: {
169
+ read(input: {
170
+ itemId: string;
171
+ fileId: string;
172
+ }): Promise<Response>;
173
+ };
174
+ }
@@ -0,0 +1,21 @@
1
+ import { type RecordSource, type RecordReference } from './inbox-contract.js';
2
+ export type RecordSelectionInput = {
3
+ source: RecordSource;
4
+ query: string;
5
+ selected?: RecordReference;
6
+ publication?: boolean;
7
+ };
8
+ export type LabeledRecord = RecordReference & {
9
+ label: string;
10
+ };
11
+ export type RecordSelectionResult = {
12
+ recordType: string;
13
+ eligibleCount: number;
14
+ matchCount: number;
15
+ matches: LabeledRecord[];
16
+ suggestions: Array<LabeledRecord & {
17
+ reason?: string;
18
+ }>;
19
+ selected?: LabeledRecord;
20
+ };
21
+ export declare function validateRecordSelectionInput(value: unknown): RecordSelectionInput;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oddington/sdk",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "description": "Oddington routine and response-handler SDK",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",