@oddington/sdk 0.1.10 → 0.1.12

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.
@@ -0,0 +1,40 @@
1
+ export type BrowserAuthErrorReason = 'invalid_input' | 'invalid_code' | 'unavailable' | 'busy' | 'stale' | 'disposed';
2
+ export type BrowserAuthorizationResult = Readonly<{
3
+ status: 'consent';
4
+ clientName: string;
5
+ account: Readonly<{
6
+ email: string;
7
+ displayName: string;
8
+ }>;
9
+ scopes: readonly string[];
10
+ callbackAddress: string;
11
+ }> | Readonly<{
12
+ status: 'return';
13
+ returnUrl: string;
14
+ }> | Readonly<{
15
+ status: 'missing' | 'expired' | 'unavailable' | 'invalid' | 'signed_out' | 'stale' | 'disposed' | 'busy';
16
+ }>;
17
+ export interface BrowserAuthorization {
18
+ get(id: string): Promise<BrowserAuthorizationResult>;
19
+ approve(id: string): Promise<BrowserAuthorizationResult>;
20
+ deny(id: string): Promise<BrowserAuthorizationResult>;
21
+ }
22
+ export type BrowserAuthState = Readonly<{
23
+ status: 'initializing' | 'signed_out' | 'signed_in' | 'expired' | 'unavailable';
24
+ account?: Readonly<{
25
+ email: string;
26
+ displayName: string;
27
+ }>;
28
+ pending?: 'send_code' | 'verify_code' | 'sign_out';
29
+ error?: BrowserAuthErrorReason;
30
+ }>;
31
+ /** An opaque browser capability. Provider configuration and sessions stay private. */
32
+ export interface BrowserAuthHandle {
33
+ readonly authorization: BrowserAuthorization;
34
+ getState(): BrowserAuthState;
35
+ subscribe(listener: (state: BrowserAuthState) => void): () => void;
36
+ sendCode(email: string): Promise<void>;
37
+ verifyCode(email: string, code: string): Promise<void>;
38
+ signOut(): Promise<void>;
39
+ dispose(): void;
40
+ }
@@ -2,6 +2,10 @@ 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';
6
+ export declare const defineRoutine: import('./routine-definition-types.js').DefineRoutine;
7
+ export declare const schema: import('./routine-definition-types.js').RoutineSchemaBuilders;
8
+ export declare const file: import('./routine-definition-types.js').RoutineFileSchema;
5
9
  export { InboxContractError, asksBlock, continueAsk, defineHandler, fileBlock, question, recordBlock, recordsBlock, resolveAsk, respond, richTextBlock, selection, } from '../../../shared/inbox-contract.js';
6
10
  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
11
  export type { CapturedRecordTableInput, RecordField, RecordTableInput, RecordValue, RecordViewInput, TableColumn, ViewRecord, } from '../../../shared/inbox-views.js';
@@ -13,7 +17,7 @@ export { AirtableOperationError } from '../../../shared/airtable-contract.js';
13
17
  export type { AirtableField, AirtableTable, AirtableRecord, AirtableListInput, AirtableGetInput, AirtableCreateInput, AirtableUpdateInput, AirtableDeleteInput, AirtableReceipt, AirtableWriteResult, AirtableClient, Connections } from '../../../shared/airtable-contract.js';
14
18
  export declare const connections: import('../../../shared/airtable-contract.js').Connections;
15
19
  export { DataOperationError } from '../../../shared/data-contract.js';
16
- export type { DataRepository, DataErrorCode, PublicValueDefinition, PublicField, CollectionSummary, CollectionSchema, QueryScalar, SelectionOptions, RecordSelection, RecordsQuery, DataValue, SelectedRecord, SelectionMetadata, RecordsResult, RecordsSearchOptions, RecordsSearchResult, HistoryListOptions, HistoryEntry, RecordIdentity, RecordCreation, RecordUpdateSet, DataPublication, DataChangeSet, DataEffect } from '../../../shared/data-contract.js';
20
+ export type { DataRepository, DataErrorCode, PublicValueDefinition, PublicField, CollectionSummary, CollectionSchema, QueryScalar, SelectionOptions, RecordSelection, RecordsQuery, DataValue, SelectedRecord, SelectionMetadata, RecordsResult, RecordsSearchOptions, RecordsSearchResult, HistoryListOptions, HistoryEntry, HistoryChangesOptions, HistoryChange, HistoryChangesResult, RecordIdentity, RecordCreation, RecordUpdateSet, DataPublication, DataChangeSet, DataEffect } from '../../../shared/data-contract.js';
17
21
  export declare const data: {
18
22
  repository(name: string): import('../../../shared/data-contract.js').DataRepository;
19
23
  };
@@ -22,6 +26,7 @@ export type { File, FileInput, FileStorage, FileCreateInput, FileCreateOptions,
22
26
  export declare const files: {
23
27
  create(input: import('../../../shared/files-contract.js').FileCreateInput, options?: import('../../../shared/files-contract.js').FileCreateOptions): Promise<import('../../../shared/files-contract.js').File>;
24
28
  get(id: string): Promise<import('../../../shared/files-contract.js').File>;
29
+ delete(id: string): Promise<void>;
25
30
  upload(id: string): Promise<import('../../../shared/files-contract.js').File>;
26
31
  enrich(input: import('../../../shared/files-contract.js').FileEnrichOptions): Promise<import('../../../shared/files-contract.js').FileEnrichResult>;
27
32
  read(id: string): Promise<Response>;
@@ -61,9 +66,17 @@ export type HostedSessionSource = {
61
66
  /** OS-owned hosted or exact-origin local browser bootstrap. Reinitialization replaces the context. */
62
67
  export declare const os: {
63
68
  init(options: {
64
- auth: HostedSessionSource;
69
+ auth: HostedSessionSource | import('./auth-types.js').BrowserAuthHandle;
65
70
  }): void;
66
71
  };
72
+ export type { BrowserAuthHandle, BrowserAuthState, BrowserAuthErrorReason, BrowserAuthorization, BrowserAuthorizationResult } from './auth-types.js';
73
+ export declare class BrowserAuthError extends Error {
74
+ readonly reason: import('./auth-types.js').BrowserAuthErrorReason;
75
+ constructor(reason: import('./auth-types.js').BrowserAuthErrorReason);
76
+ }
77
+ export declare const auth: {
78
+ create(): import('./auth-types.js').BrowserAuthHandle;
79
+ };
67
80
  /** Customer-owned module augmentation supplies types, never runtime authority. */
68
81
  export interface AppRoutineTypes {
69
82
  }
@@ -0,0 +1,56 @@
1
+ import type { AppValueSchema } from '../../../shared/app-routine-contract.js';
2
+ import type { File } from '../../../shared/files-contract.js';
3
+ import type { Connections } from '../../../shared/airtable-contract.js';
4
+ import type { DataRepository } from '../../../shared/data-contract.js';
5
+ import type { files, RoutinePublicationClient } from './public.js';
6
+ declare const valueType: unique symbol;
7
+ /** Serializable declaration; the phantom type never carries authority. */
8
+ export type RoutineSchema<Value> = AppValueSchema & {
9
+ readonly [valueType]?: Value;
10
+ };
11
+ export type RoutineSchemaValue<Schema> = Schema extends RoutineSchema<infer Value> ? Value : undefined;
12
+ export type RoutineSteps = Record<string, RoutineSchema<unknown> | null>;
13
+ export type RoutineInput<Value> = Value extends object ? {
14
+ readonly [Key in keyof Value]: RoutineInput<Value[Key]>;
15
+ } : Value;
16
+ export type RoutineRuntime<Steps extends RoutineSteps> = {
17
+ readonly run: {
18
+ readonly id: string;
19
+ };
20
+ readonly data: {
21
+ repository(name: string): DataRepository;
22
+ };
23
+ readonly files: typeof files;
24
+ readonly connections: Connections;
25
+ readonly inbox: RoutinePublicationClient;
26
+ step<Key extends Extract<keyof Steps, string>>(id: Key, ...summary: Steps[Key] extends null ? [] : [summary: RoutineSchemaValue<Steps[Key]>]): Promise<void>;
27
+ };
28
+ export type RoutineDefinition<Input extends RoutineSchema<unknown> | undefined, Steps extends RoutineSteps, Result extends RoutineSchema<unknown> | undefined> = {
29
+ readonly input?: Input;
30
+ readonly steps?: Steps;
31
+ readonly result?: Result;
32
+ readonly run: (input: RoutineInput<Input extends undefined ? Record<string, never> : RoutineSchemaValue<Input>>, os: RoutineRuntime<Steps>) => Result extends undefined ? void | Promise<void> : RoutineSchemaValue<Result> | Promise<RoutineSchemaValue<Result>>;
33
+ };
34
+ export type DefineRoutine = <Input extends RoutineSchema<unknown> | undefined = undefined, const Steps extends RoutineSteps = {}, Result extends RoutineSchema<unknown> | undefined = undefined>(definition: RoutineDefinition<Input, Steps, Result>) => RoutineDefinition<Input, Steps, Result>;
35
+ export type RoutineSchemaBuilders = {
36
+ object<const Properties extends Record<string, RoutineSchema<unknown>>>(properties: Properties): RoutineSchema<{
37
+ [Key in keyof Properties]: RoutineSchemaValue<Properties[Key]>;
38
+ }>;
39
+ array<Item extends RoutineSchema<unknown>>(items: Item, options: {
40
+ maxItems: number;
41
+ }): RoutineSchema<RoutineSchemaValue<Item>[]>;
42
+ string(options?: {
43
+ maxLength?: number;
44
+ }): RoutineSchema<string>;
45
+ integer(options?: {
46
+ minimum?: number;
47
+ maximum?: number;
48
+ }): RoutineSchema<number>;
49
+ number(options?: {
50
+ minimum?: number;
51
+ maximum?: number;
52
+ }): RoutineSchema<number>;
53
+ boolean(): RoutineSchema<boolean>;
54
+ };
55
+ export type RoutineFileSchema = () => RoutineSchema<File>;
56
+ export {};
@@ -0,0 +1,43 @@
1
+ export type AppValueSchema = {
2
+ type: 'object';
3
+ properties: Record<string, AppValueSchema>;
4
+ required?: string[];
5
+ additionalProperties: false;
6
+ } | {
7
+ type: 'array';
8
+ items: AppValueSchema;
9
+ maxItems: number;
10
+ } | {
11
+ type: 'boolean';
12
+ } | {
13
+ type: 'string';
14
+ maxLength?: number;
15
+ } | {
16
+ type: 'integer' | 'number';
17
+ minimum?: number;
18
+ maximum?: number;
19
+ } | {
20
+ type: 'file';
21
+ };
22
+ export type AppRoutineContract = {
23
+ routine: string;
24
+ input: AppValueSchema;
25
+ steps: {
26
+ id: string;
27
+ summary?: AppValueSchema;
28
+ }[];
29
+ result?: AppValueSchema;
30
+ };
31
+ /** Bounded diagnostics never echo authored values, names or paths. */
32
+ export declare class AppRoutineContractError extends Error {
33
+ readonly code: 'invalid_contract' | 'invalid_value';
34
+ constructor(code: 'invalid_contract' | 'invalid_value');
35
+ }
36
+ /** One operation owns the property budget across input, result and all summaries. */
37
+ export declare function parseAppRoutineContract(value: unknown): AppRoutineContract;
38
+ export declare function validateRoutineSchemaValue(schema: AppValueSchema, value: unknown): void;
39
+ /** Structural validation grants no execution or File-use authority. Values stay unchanged. */
40
+ export declare function validateAppRoutineInput(contract: AppRoutineContract, value: unknown): void;
41
+ export declare function validateAppRoutineResult(contract: AppRoutineContract, value?: unknown): void;
42
+ /** Validates only the declared projection; report/event envelopes belong to the runtime. */
43
+ export declare function validateAppRoutineStep(contract: AppRoutineContract, id: string, summary?: unknown): void;
@@ -138,6 +138,14 @@ export type HistoryListOptions = {
138
138
  limit?: number;
139
139
  before?: string;
140
140
  };
141
+ export type HistoryChangesOptions = {
142
+ collections?: string[];
143
+ refs?: string[];
144
+ from?: string;
145
+ through?: string;
146
+ limit?: number;
147
+ after?: string;
148
+ };
141
149
  export type HistoryEntry = {
142
150
  version: string;
143
151
  publishedAt: string;
@@ -156,6 +164,19 @@ export type HistoryEntry = {
156
164
  updated: string[];
157
165
  deleted: string[];
158
166
  };
167
+ export type HistoryChange = Omit<HistoryEntry, 'created' | 'updated' | 'deleted'> & {
168
+ $ref: string;
169
+ change: 'created' | 'updated' | 'deleted';
170
+ before: SelectedRecord | null;
171
+ after: SelectedRecord | null;
172
+ };
173
+ export type HistoryChangesResult = {
174
+ $meta: {
175
+ through: string;
176
+ next?: string;
177
+ };
178
+ changes: HistoryChange[];
179
+ };
159
180
  export interface DataChangeSet {
160
181
  create(record: RecordCreation): void;
161
182
  update(record: RecordIdentity, set: RecordUpdateSet): void;
@@ -175,6 +196,7 @@ export interface DataRepository {
175
196
  history: {
176
197
  list(options?: HistoryListOptions): Promise<HistoryEntry[]>;
177
198
  at(instant: string): Promise<HistoryEntry | null>;
199
+ changes(options?: HistoryChangesOptions): Promise<HistoryChangesResult>;
178
200
  };
179
201
  changes(): DataChangeSet;
180
202
  }
@@ -82,7 +82,15 @@ export type FileCreateMetadata = {
82
82
  path: string;
83
83
  storage?: FileStorage;
84
84
  csv?: Required<FileCsvHints>;
85
+ inputMediaType?: 'application/pdf';
85
86
  size: number;
86
87
  requestKey: string;
87
88
  };
89
+ /** A declared PDF is descriptive metadata; this rule never reads original bytes. */
90
+ export declare function declaredOriginalFormat(input: Pick<FileCreateMetadata, 'name' | 'inputMediaType'>): {
91
+ mediaType: 'application/pdf';
92
+ details: {
93
+ kind: 'pdf';
94
+ };
95
+ } | undefined;
88
96
  export declare function parseFileCreateMetadata(value: unknown, maxBytes: number): FileCreateMetadata;
@@ -267,6 +267,7 @@ export type HandlerRuntime<Input extends JsonValue = JsonValue> = {
267
267
  };
268
268
  export type Handler<Input extends JsonValue = JsonValue> = {
269
269
  id: string;
270
+ results?: readonly string[];
270
271
  run(runtime: HandlerRuntime<Input>): Promise<HandlerTransition>;
271
272
  };
272
273
  export declare class InboxContractError extends Error {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oddington/sdk",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "description": "Oddington routine and response-handler SDK",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",
@@ -22,6 +22,7 @@
22
22
  "verify:package": "bun run scripts/verify-package.ts"
23
23
  },
24
24
  "devDependencies": {
25
+ "@supabase/auth-js": "2.116.0",
25
26
  "@types/node": "26.6.1",
26
27
  "esbuild": "0.28.1",
27
28
  "typescript": "7.0.2"