@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
|
@@ -2,13 +2,55 @@ 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 { InboxContractError, asksBlock, continueAsk, defineHandler, fileBlock,
|
|
6
|
-
export type { AskInput, AuthoredSource, CapturedRecords, CsvDetails, DigestInput, Handler, HandlerReference, HandlerRuntime, HandlerTransition, InboxBlock, InboxFile, JsonObject, JsonValue,
|
|
5
|
+
export { InboxContractError, asksBlock, continueAsk, defineHandler, fileBlock, question, recordBlock, recordsBlock, resolveAsk, respond, richTextBlock, selection, } from '../../../shared/inbox-contract.js';
|
|
6
|
+
export type { AskInput, AuthoredSource, CapturedRecords, CsvDetails, DigestInput, Handler, HandlerReference, HandlerRuntime, HandlerTransition, InboxBlock, InboxFile, JsonObject, JsonValue, PresentedField, PresentedRecord, PresentedRecordSummary, PublishedAsk, PublishedDigest, PublishedView, PublicationRequest, Question, QuestionInput, QuestionResponse, RecordCreate, RecordDelete, RecordReference, RecordSource, RecordUpdate, RepositoryCapabilities, RepositoryReceipt, Resolution, ResolutionInput, ResponseDefinition, } from '../../../shared/inbox-contract.js';
|
|
7
7
|
export type { CapturedRecordTableInput, RecordField, RecordTableInput, RecordValue, RecordViewInput, TableColumn, ViewRecord, } from '../../../shared/inbox-views.js';
|
|
8
8
|
export type { FileAddOptions } from '../../../shared/inbox-files.js';
|
|
9
9
|
export type { RecordReadInput } from '../../../shared/record-capture.js';
|
|
10
10
|
export type { RecordDeleteRequest, RecordUpdateRequest, RecordWriteRequest } from '../../../shared/record-write.js';
|
|
11
11
|
export { RoutineRecordWriteError } from '../../../shared/record-write.js';
|
|
12
|
+
export { AirtableOperationError } from '../../../shared/airtable-contract.js';
|
|
13
|
+
export type { AirtableField, AirtableTable, AirtableRecord, AirtableListInput, AirtableGetInput, AirtableCreateInput, AirtableUpdateInput, AirtableDeleteInput, AirtableReceipt, AirtableWriteResult, AirtableClient, Connections } from '../../../shared/airtable-contract.js';
|
|
14
|
+
export declare const connections: import('../../../shared/airtable-contract.js').Connections;
|
|
15
|
+
export { DataOperationError } from '../../../shared/data-contract.js';
|
|
16
|
+
export type { DataRepository, DataErrorCode, PublicValueDefinition, PublicField, CollectionSummary, CollectionSchema, QueryScalar, SelectionOptions, RecordSelection, RecordsQuery, DataValue, SelectedRecord, SelectionMetadata, RecordsResult } from '../../../shared/data-contract.js';
|
|
17
|
+
export declare const data: {
|
|
18
|
+
repository(name: string): import('../../../shared/data-contract.js').DataRepository;
|
|
19
|
+
};
|
|
20
|
+
/** The host's existing refreshing session source; supplies identity, never membership. */
|
|
21
|
+
export type HostedSessionSource = {
|
|
22
|
+
getSession(): Promise<{
|
|
23
|
+
data: {
|
|
24
|
+
session: {
|
|
25
|
+
access_token: string;
|
|
26
|
+
expires_at?: number;
|
|
27
|
+
user: {
|
|
28
|
+
id: string;
|
|
29
|
+
};
|
|
30
|
+
} | null;
|
|
31
|
+
};
|
|
32
|
+
error: unknown;
|
|
33
|
+
}>;
|
|
34
|
+
onAuthStateChange(callback: (event: string, session: {
|
|
35
|
+
access_token: string;
|
|
36
|
+
expires_at?: number;
|
|
37
|
+
user: {
|
|
38
|
+
id: string;
|
|
39
|
+
};
|
|
40
|
+
} | null) => void): {
|
|
41
|
+
data: {
|
|
42
|
+
subscription: {
|
|
43
|
+
unsubscribe(): void;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
/** OS-owned HTTPS browser bootstrap. Reinitialization replaces the previous context. */
|
|
49
|
+
export declare const os: {
|
|
50
|
+
init(options: {
|
|
51
|
+
auth: HostedSessionSource;
|
|
52
|
+
}): void;
|
|
53
|
+
};
|
|
12
54
|
export type InboxRequester = (path: string, init?: RequestInit) => Promise<Response>;
|
|
13
55
|
export type RoutinePublicationClientOptions = {
|
|
14
56
|
workspace?: string;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { JsonObject, JsonValue } from './inbox-contract.js';
|
|
2
|
+
export type AirtableField = {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
type: string;
|
|
6
|
+
options?: JsonValue;
|
|
7
|
+
};
|
|
8
|
+
export type AirtableTable = {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
primaryFieldId: string;
|
|
12
|
+
fields: AirtableField[];
|
|
13
|
+
};
|
|
14
|
+
export type AirtableRecord = {
|
|
15
|
+
id: string;
|
|
16
|
+
createdTime?: string;
|
|
17
|
+
fields: JsonObject;
|
|
18
|
+
};
|
|
19
|
+
export type AirtableListInput = {
|
|
20
|
+
table: string;
|
|
21
|
+
fields?: string[];
|
|
22
|
+
};
|
|
23
|
+
export type AirtableGetInput = {
|
|
24
|
+
table: string;
|
|
25
|
+
id: string;
|
|
26
|
+
};
|
|
27
|
+
export type AirtableCreateInput = {
|
|
28
|
+
table: string;
|
|
29
|
+
records: Array<{
|
|
30
|
+
fields: JsonObject;
|
|
31
|
+
}>;
|
|
32
|
+
};
|
|
33
|
+
export type AirtableUpdateInput = {
|
|
34
|
+
table: string;
|
|
35
|
+
records: Array<{
|
|
36
|
+
id: string;
|
|
37
|
+
expected: JsonObject;
|
|
38
|
+
set: JsonObject;
|
|
39
|
+
}>;
|
|
40
|
+
};
|
|
41
|
+
export type AirtableDeleteInput = {
|
|
42
|
+
table: string;
|
|
43
|
+
records: Array<{
|
|
44
|
+
id: string;
|
|
45
|
+
expected: JsonObject;
|
|
46
|
+
}>;
|
|
47
|
+
};
|
|
48
|
+
export type AirtableReceipt = {
|
|
49
|
+
provider: 'airtable';
|
|
50
|
+
connection: `airtable/${string}`;
|
|
51
|
+
baseId: string;
|
|
52
|
+
table: string;
|
|
53
|
+
operation: 'create' | 'update' | 'delete';
|
|
54
|
+
records: Array<{
|
|
55
|
+
id: string;
|
|
56
|
+
}>;
|
|
57
|
+
};
|
|
58
|
+
export type AirtableWriteResult = {
|
|
59
|
+
receipt: AirtableReceipt;
|
|
60
|
+
records?: AirtableRecord[];
|
|
61
|
+
};
|
|
62
|
+
export interface AirtableClient {
|
|
63
|
+
tables: {
|
|
64
|
+
list(): Promise<AirtableTable[]>;
|
|
65
|
+
};
|
|
66
|
+
records: {
|
|
67
|
+
list(input: AirtableListInput): Promise<AirtableRecord[]>;
|
|
68
|
+
get(input: AirtableGetInput): Promise<AirtableRecord>;
|
|
69
|
+
create(input: AirtableCreateInput): Promise<AirtableWriteResult>;
|
|
70
|
+
update(input: AirtableUpdateInput): Promise<AirtableWriteResult>;
|
|
71
|
+
delete(input: AirtableDeleteInput): Promise<AirtableWriteResult>;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
export interface Connections {
|
|
75
|
+
airtable(name: string): AirtableClient;
|
|
76
|
+
}
|
|
77
|
+
/** Safe provider failure. An uncertain or partial mutation must never be retried blindly. */
|
|
78
|
+
export declare class AirtableOperationError extends Error {
|
|
79
|
+
readonly effect: 'unapplied' | 'partial' | 'uncertain';
|
|
80
|
+
readonly receipts: AirtableReceipt[];
|
|
81
|
+
constructor(message: string, effect?: 'unapplied' | 'partial' | 'uncertain', receipts?: AirtableReceipt[]);
|
|
82
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/** Canonical value vocabulary shared by schema normalization and public reads. */
|
|
2
|
+
export type DataValueDefinition<Extra extends object = object> = {
|
|
3
|
+
nullable: boolean;
|
|
4
|
+
many: boolean;
|
|
5
|
+
description?: string;
|
|
6
|
+
term?: string;
|
|
7
|
+
} & Extra & ({
|
|
8
|
+
kind: 'string' | 'integer' | 'boolean';
|
|
9
|
+
} | {
|
|
10
|
+
kind: 'number';
|
|
11
|
+
precision?: number;
|
|
12
|
+
} | {
|
|
13
|
+
kind: 'date';
|
|
14
|
+
format?: 'month';
|
|
15
|
+
} | {
|
|
16
|
+
kind: 'const';
|
|
17
|
+
value: string | number | boolean;
|
|
18
|
+
} | {
|
|
19
|
+
kind: 'enum';
|
|
20
|
+
values: string[];
|
|
21
|
+
} | {
|
|
22
|
+
kind: 'link';
|
|
23
|
+
to: string[];
|
|
24
|
+
} | {
|
|
25
|
+
kind: 'object';
|
|
26
|
+
fields: Array<DataValueDefinition<Extra> & {
|
|
27
|
+
name: string;
|
|
28
|
+
}>;
|
|
29
|
+
} | {
|
|
30
|
+
kind: 'map';
|
|
31
|
+
key: DataValueDefinition<Extra>;
|
|
32
|
+
value: DataValueDefinition<Extra>;
|
|
33
|
+
});
|
|
34
|
+
export type PublicValueDefinition = DataValueDefinition;
|
|
35
|
+
export type PublicField = PublicValueDefinition & {
|
|
36
|
+
name: string;
|
|
37
|
+
};
|
|
38
|
+
export type CollectionSummary = {
|
|
39
|
+
name: string;
|
|
40
|
+
type: string;
|
|
41
|
+
description?: string;
|
|
42
|
+
};
|
|
43
|
+
export type CollectionSchema = CollectionSummary & {
|
|
44
|
+
fields: PublicField[];
|
|
45
|
+
};
|
|
46
|
+
export type QueryScalar = string | number | boolean | null;
|
|
47
|
+
export type SelectionOptions = {
|
|
48
|
+
where?: Record<string, QueryScalar | {
|
|
49
|
+
$in: QueryScalar[];
|
|
50
|
+
}>;
|
|
51
|
+
fields?: string[];
|
|
52
|
+
order?: Record<string, 'asc' | 'desc'>;
|
|
53
|
+
limit?: number;
|
|
54
|
+
count?: boolean;
|
|
55
|
+
after?: string;
|
|
56
|
+
};
|
|
57
|
+
export type RecordSelection = {
|
|
58
|
+
$?: SelectionOptions;
|
|
59
|
+
[link: string]: RecordSelection | SelectionOptions | undefined;
|
|
60
|
+
};
|
|
61
|
+
export type RecordsQuery = Record<string, RecordSelection>;
|
|
62
|
+
export type DataValue = QueryScalar | DataValue[] | {
|
|
63
|
+
[field: string]: DataValue;
|
|
64
|
+
};
|
|
65
|
+
export type SelectedRecord = {
|
|
66
|
+
$ref: string;
|
|
67
|
+
$version: string;
|
|
68
|
+
[field: string]: DataValue;
|
|
69
|
+
};
|
|
70
|
+
export type SelectionMetadata = {
|
|
71
|
+
version: string;
|
|
72
|
+
collections: Record<string, {
|
|
73
|
+
count?: number;
|
|
74
|
+
next?: string;
|
|
75
|
+
}>;
|
|
76
|
+
};
|
|
77
|
+
export type RecordsResult = {
|
|
78
|
+
$meta: SelectionMetadata;
|
|
79
|
+
[collection: string]: SelectedRecord[] | SelectionMetadata;
|
|
80
|
+
};
|
|
81
|
+
export interface DataRepository {
|
|
82
|
+
collections: {
|
|
83
|
+
list(): Promise<CollectionSummary[]>;
|
|
84
|
+
schema(name: string): Promise<CollectionSchema>;
|
|
85
|
+
};
|
|
86
|
+
records: {
|
|
87
|
+
select(query: RecordsQuery): Promise<RecordsResult>;
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
export type DataErrorCode = 'context_unavailable' | 'unauthenticated' | 'access_denied' | 'invalid_query' | 'request_too_large' | 'capacity' | 'unavailable';
|
|
91
|
+
export declare class DataOperationError extends Error {
|
|
92
|
+
readonly code: DataErrorCode;
|
|
93
|
+
readonly retryable: boolean;
|
|
94
|
+
constructor(code: DataErrorCode, retryable?: boolean);
|
|
95
|
+
}
|
|
@@ -188,17 +188,12 @@ export type QuestionInstance = {
|
|
|
188
188
|
export type ResponseSubmission = QuestionInstance & {
|
|
189
189
|
response: QuestionResponse;
|
|
190
190
|
};
|
|
191
|
-
export type OddingtonAssignment = {
|
|
192
|
-
type: 'oddington';
|
|
193
|
-
reason: string;
|
|
194
|
-
};
|
|
195
191
|
export type Resolution = {
|
|
196
192
|
outcome: string;
|
|
197
193
|
evidence?: JsonValue[];
|
|
198
194
|
};
|
|
199
195
|
export type HandlerTransition = {
|
|
200
196
|
type: 'continue';
|
|
201
|
-
assignTo?: OddingtonAssignment;
|
|
202
197
|
} | ({
|
|
203
198
|
type: 'resolve';
|
|
204
199
|
} & Resolution);
|
|
@@ -268,6 +263,7 @@ export type HandlerRuntime<Input extends JsonValue = JsonValue> = {
|
|
|
268
263
|
responseDefinition: ResponseDefinition;
|
|
269
264
|
questionId: string;
|
|
270
265
|
repository: RepositoryCapabilities;
|
|
266
|
+
connections: import('./airtable-contract.js').Connections;
|
|
271
267
|
};
|
|
272
268
|
export type Handler<Input extends JsonValue = JsonValue> = {
|
|
273
269
|
id: string;
|
|
@@ -322,12 +318,7 @@ export declare function validatePublication(value: unknown): Publication;
|
|
|
322
318
|
/** Structural projection only. The read boundary must check current recipient,
|
|
323
319
|
* workspace and repository/file access before returning this content. */
|
|
324
320
|
export declare function recipientPresentation(value: unknown): RecipientPublication;
|
|
325
|
-
export declare function
|
|
326
|
-
reason: string;
|
|
327
|
-
}): OddingtonAssignment;
|
|
328
|
-
export declare function continueAsk(value: {
|
|
329
|
-
assignTo?: OddingtonAssignment;
|
|
330
|
-
}): HandlerTransition;
|
|
321
|
+
export declare function continueAsk(value: Record<string, never>): HandlerTransition;
|
|
331
322
|
export declare function resolveAsk(value: Resolution): HandlerTransition;
|
|
332
323
|
/** Call at the durable transition boundary with server-derived remaining work,
|
|
333
324
|
* excluding the execution being completed. Lifecycle/effect guards also apply. */
|