@oddington/sdk 0.1.2 → 0.1.4

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.
@@ -12,6 +12,52 @@ export { RoutineRecordWriteError } from '../../../shared/record-write.js';
12
12
  export { AirtableOperationError } from '../../../shared/airtable-contract.js';
13
13
  export type { AirtableField, AirtableTable, AirtableRecord, AirtableListInput, AirtableGetInput, AirtableCreateInput, AirtableUpdateInput, AirtableDeleteInput, AirtableReceipt, AirtableWriteResult, AirtableClient, Connections } from '../../../shared/airtable-contract.js';
14
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, RecordIdentity, RecordUpdateSet, DataPublication, DataChangeSet, DataEffect } from '../../../shared/data-contract.js';
17
+ export declare const data: {
18
+ repository(name: string): import('../../../shared/data-contract.js').DataRepository;
19
+ };
20
+ export { FileOperationError } from '../../../shared/files-contract.js';
21
+ export type { File, FileInput, FileStorage, FileCreateInput, FileCreateOptions, FileErrorCode } from '../../../shared/files-contract.js';
22
+ export declare const files: {
23
+ create(input: import('../../../shared/files-contract.js').FileCreateInput, options?: import('../../../shared/files-contract.js').FileCreateOptions): Promise<import('../../../shared/files-contract.js').File>;
24
+ get(id: string): Promise<import('../../../shared/files-contract.js').File>;
25
+ read(id: string): Promise<Response>;
26
+ };
27
+ /** The host's existing refreshing session source; supplies identity, never membership. */
28
+ export type HostedSessionSource = {
29
+ getSession(): Promise<{
30
+ data: {
31
+ session: {
32
+ access_token: string;
33
+ expires_at?: number;
34
+ user: {
35
+ id: string;
36
+ };
37
+ } | null;
38
+ };
39
+ error: unknown;
40
+ }>;
41
+ onAuthStateChange(callback: (event: string, session: {
42
+ access_token: string;
43
+ expires_at?: number;
44
+ user: {
45
+ id: string;
46
+ };
47
+ } | null) => void): {
48
+ data: {
49
+ subscription: {
50
+ unsubscribe(): void;
51
+ };
52
+ };
53
+ };
54
+ };
55
+ /** OS-owned HTTPS browser bootstrap. Reinitialization replaces the previous context. */
56
+ export declare const os: {
57
+ init(options: {
58
+ auth: HostedSessionSource;
59
+ }): void;
60
+ };
15
61
  export type InboxRequester = (path: string, init?: RequestInit) => Promise<Response>;
16
62
  export type RoutinePublicationClientOptions = {
17
63
  workspace?: string;
@@ -0,0 +1,140 @@
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
+ type LowerBound = {
48
+ $gt: number | string;
49
+ $gte?: never;
50
+ } | {
51
+ $gte: number | string;
52
+ $gt?: never;
53
+ };
54
+ type UpperBound = {
55
+ $lt: number | string;
56
+ $lte?: never;
57
+ } | {
58
+ $lte: number | string;
59
+ $lt?: never;
60
+ };
61
+ export type RangeCondition = ((LowerBound & {
62
+ $lt?: never;
63
+ $lte?: never;
64
+ }) | (UpperBound & {
65
+ $gt?: never;
66
+ $gte?: never;
67
+ }) | (LowerBound & UpperBound)) & {
68
+ $in?: never;
69
+ };
70
+ export type QueryCondition = QueryScalar | RangeCondition | {
71
+ $in: QueryScalar[];
72
+ $gt?: never;
73
+ $gte?: never;
74
+ $lt?: never;
75
+ $lte?: never;
76
+ };
77
+ export type SelectionOptions = {
78
+ where?: Record<string, QueryCondition>;
79
+ fields?: string[];
80
+ order?: Record<string, 'asc' | 'desc'>;
81
+ limit?: number;
82
+ count?: boolean;
83
+ after?: string;
84
+ };
85
+ export type RecordSelection = {
86
+ $?: SelectionOptions;
87
+ [link: string]: RecordSelection | SelectionOptions | undefined;
88
+ };
89
+ export type RecordsQuery = Record<string, RecordSelection>;
90
+ export type DataValue = QueryScalar | DataValue[] | {
91
+ [field: string]: DataValue;
92
+ };
93
+ export type SelectedRecord = {
94
+ $ref: string;
95
+ $version: string;
96
+ [field: string]: DataValue;
97
+ };
98
+ export type SelectionMetadata = {
99
+ version: string;
100
+ collections: Record<string, {
101
+ count?: number;
102
+ next?: string;
103
+ }>;
104
+ };
105
+ export type RecordsResult = {
106
+ $meta: SelectionMetadata;
107
+ [collection: string]: SelectedRecord[] | SelectionMetadata;
108
+ };
109
+ export type RecordIdentity = Pick<SelectedRecord, '$ref' | '$version'>;
110
+ export type RecordUpdateSet = Record<string, DataValue>;
111
+ export type DataPublication = {
112
+ version: string;
113
+ created: [];
114
+ updated: RecordIdentity[];
115
+ deleted: [];
116
+ };
117
+ export interface DataChangeSet {
118
+ update(record: RecordIdentity, set: RecordUpdateSet): void;
119
+ validate(): Promise<void>;
120
+ publish(): Promise<DataPublication>;
121
+ }
122
+ export interface DataRepository {
123
+ collections: {
124
+ list(): Promise<CollectionSummary[]>;
125
+ schema(name: string): Promise<CollectionSchema>;
126
+ };
127
+ records: {
128
+ select(query: RecordsQuery): Promise<RecordsResult>;
129
+ };
130
+ changes(): DataChangeSet;
131
+ }
132
+ export type DataErrorCode = 'context_unavailable' | 'unauthenticated' | 'access_denied' | 'invalid_query' | 'request_too_large' | 'capacity' | 'unavailable' | 'invalid_change' | 'conflict' | 'publication_pending';
133
+ export type DataEffect = 'unapplied' | 'uncertain' | 'applied';
134
+ export declare class DataOperationError extends Error {
135
+ readonly code: DataErrorCode;
136
+ readonly retryable: boolean;
137
+ readonly effect?: DataEffect | undefined;
138
+ constructor(code: DataErrorCode, retryable?: boolean, effect?: DataEffect | undefined);
139
+ }
140
+ export {};
@@ -0,0 +1,66 @@
1
+ /** Provider-neutral authored contract. Registries and object locations stay server-side. */
2
+ export type FileStorage = 'local' | 'remote' | 'both';
3
+ export type FileInput = Blob | Uint8Array | ReadableStream<Uint8Array>;
4
+ export type FileCsvHints = {
5
+ encoding?: 'utf-8' | 'windows-1252';
6
+ delimiter?: ',' | ';' | '\t';
7
+ headerRow?: number;
8
+ };
9
+ export type FileCreateInput = {
10
+ file: FileInput;
11
+ size?: number;
12
+ path?: string;
13
+ name?: string;
14
+ storage?: FileStorage;
15
+ csv?: FileCsvHints;
16
+ };
17
+ export type FileCreateOptions = {
18
+ requestKey?: string;
19
+ };
20
+ export type File = {
21
+ id: string;
22
+ name: string;
23
+ path: string;
24
+ mediaType: string;
25
+ size: number;
26
+ sha256: string;
27
+ enrichments: Record<string, {
28
+ mediaType: string;
29
+ size: number;
30
+ sha256: string;
31
+ }>;
32
+ details: {
33
+ kind: 'csv';
34
+ encoding: 'utf-8' | 'windows-1252';
35
+ delimiter: ',' | ';' | '\t';
36
+ headerRow: number;
37
+ dataRows: number;
38
+ } | {
39
+ kind: 'pdf';
40
+ pages?: number;
41
+ } | {
42
+ kind: 'other';
43
+ };
44
+ };
45
+ export type FileErrorCode = 'invalid_input' | 'unsupported_context' | 'unauthenticated' | 'access_denied' | 'request_too_large' | 'conflict' | 'integrity' | 'unavailable' | 'capacity' | 'method_not_allowed';
46
+ export declare class FileOperationError extends Error {
47
+ readonly code: FileErrorCode;
48
+ readonly status: number;
49
+ readonly retryable: boolean;
50
+ constructor(code: FileErrorCode, status: number, retryable?: boolean);
51
+ }
52
+ export declare const FILE_ID_PATTERN: RegExp;
53
+ /** Treat descriptor transport as untrusted; no provider fields escape the boundary. */
54
+ export declare function parseFileDescriptor(value: unknown): File;
55
+ export declare function safeFileName(value: unknown): value is string;
56
+ export declare function safeFilePath(value: unknown): value is string;
57
+ /** Private transport metadata: normalized material options exclude the request key and size declaration. */
58
+ export type FileCreateMetadata = {
59
+ name: string;
60
+ path: string;
61
+ storage: 'remote';
62
+ csv?: Required<FileCsvHints>;
63
+ size: number;
64
+ requestKey: string;
65
+ };
66
+ export declare function parseFileCreateMetadata(value: unknown, maxBytes: number): FileCreateMetadata;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oddington/sdk",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Oddington routine and response-handler SDK",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",