@oddington/sdk 0.1.2 → 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.
@@ -12,6 +12,45 @@ 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 } 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
+ };
15
54
  export type InboxRequester = (path: string, init?: RequestInit) => Promise<Response>;
16
55
  export type RoutinePublicationClientOptions = {
17
56
  workspace?: string;
@@ -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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oddington/sdk",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Oddington routine and response-handler SDK",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",