@oddington/sdk 0.1.66 → 0.1.68

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.
@@ -1,4 +1,4 @@
1
- import type { CollectionSchema, DataRepository, DataValue, SnapshotChange, PublicValueDefinition, RecordsQuery, RecordsResult, SelectionMetadata } from '../../../shared/data-contract.js';
1
+ import type { CollectionSchema, DataRepository, DataValue, SnapshotChange, PublicValueDefinition, RecordsQuery, RecordsResult, SelectionMetadata, RecordSignal, TimelineEntry, SignalInput, TimelineInput, SignalCondition } from '../../../shared/data-contract.js';
2
2
  import type { DataRepositorySchemas, SnapshotRecordsAllOptions } from './public.js';
3
3
  type ReadonlySchema<Value> = Value extends object ? {
4
4
  readonly [Key in keyof Value]: ReadonlySchema<Value[Key]>;
@@ -100,8 +100,11 @@ type RefField = {
100
100
  };
101
101
  type Options<Schema extends Collection, Mode> = {
102
102
  fields?: Array<Fields<Schema>['name'] | '$ref' | '$version'>;
103
+ timeline?: true;
103
104
  where?: {
104
105
  [F in FilterField<Schema> | RefField as F['name']]?: Condition<F>;
106
+ } & {
107
+ $signals?: Record<string, SignalCondition>;
105
108
  };
106
109
  } & (Mode extends 'one' ? {} : {
107
110
  order?: {
@@ -115,7 +118,9 @@ type Options<Schema extends Collection, Mode> = {
115
118
  type Exact<Actual, Allowed> = Actual extends Allowed ? Record<Exclude<keyof Actual, keyof Allowed>, never> : never;
116
119
  type ExactUnion<Actual, Allowed> = Allowed extends unknown ? Exact<Actual, Allowed> : never;
117
120
  type CheckWhere<Schema extends Collection, Actual> = {
118
- [Key in keyof Actual]: Key extends (FilterField<Schema> | RefField)['name'] ? Actual[Key] extends object ? ExactUnion<Actual[Key], Condition<Extract<FilterField<Schema> | RefField, {
121
+ [Key in keyof Actual]: Key extends '$signals' ? {
122
+ [Signal in keyof Actual[Key]]: ExactUnion<Actual[Key][Signal], SignalCondition>;
123
+ } : Key extends (FilterField<Schema> | RefField)['name'] ? Actual[Key] extends object ? ExactUnion<Actual[Key], Condition<Extract<FilterField<Schema> | RefField, {
119
124
  name: Key;
120
125
  }>>> : unknown : never;
121
126
  };
@@ -150,7 +155,16 @@ type Expanded<Schemas extends Catalogue, F, Query, Body extends boolean> = F ext
150
155
  type Project<Schemas extends Catalogue, Schema extends Collection, Query, Body extends boolean> = Schema extends Collection ? {
151
156
  $ref: string;
152
157
  $version: string;
153
- } & (Body extends true ? {
158
+ $signals: RecordSignal[];
159
+ } & (Query extends {
160
+ $: {
161
+ timeline: true;
162
+ };
163
+ } ? {
164
+ $timeline: TimelineEntry[];
165
+ } : {
166
+ $timeline?: TimelineEntry[];
167
+ }) & (Body extends true ? {
154
168
  $body?: string;
155
169
  } : {}) & {
156
170
  [F in Fields<Schema> as F['nullable'] extends true ? never : F['name'] extends SelectedNames<Schema, Query> | Exclude<keyof Query, '$'> ? F['name'] : never]: F['name'] extends keyof Query ? Expanded<Schemas, F, Query[F['name']], Body> : Value<F>;
@@ -195,6 +209,8 @@ type RecordBuilder<Create, Update, Links> = {
195
209
  update<Input extends Update>(fields: Input & Exact<Input, Update>): RecordBuilder<Create, Update, Links>;
196
210
  link<Input extends Links>(fields: Input & Exact<Input, Links>): RecordBuilder<Create, Update, Links>;
197
211
  unlink<Input extends Links>(fields: Input & Exact<Input, Links>): RecordBuilder<Create, Update, Links>;
212
+ setSignal(input: SignalInput): RecordBuilder<Create, Update, Links>;
213
+ appendTimeline(input: TimelineInput): RecordBuilder<Create, Update, Links>;
198
214
  delete(): RecordBuilder<Create, Update, Links>;
199
215
  };
200
216
  type Editable<Schema extends Collection> = Exclude<Fields<Schema>, {
@@ -1,5 +1,5 @@
1
1
  import type { AskInput, DigestInput, PublicationRequest, PublishedAsk, PublishedDigest, ResolutionInput } from '../../../shared/inbox-contract.js';
2
- export type { RoutineSchema, RoutineSchemaValue, RoutineDefinition, RoutineInput, RoutineRuntime, RoutineAccess, RoutineCapabilities, SharedRoutineCapabilities, ResponseCapabilities, ResponseAction, RoutineStep, RoutineSteps, RoutineStepInput, RoutineStepResult, RoutineStepOutput, RoutineArtifactInput, RoutineArtifact, RoutineAI } from './routine-definition-types.js';
2
+ export type { RoutineSchema, RoutineSchemaValue, RoutineDefinition, RoutineInput, RoutineRuntime, RoutineAccess, RoutineSchedule, RoutineCapabilities, SharedRoutineCapabilities, ResponseCapabilities, ResponseAction, RoutineStep, RoutineSteps, RoutineStepInput, RoutineStepResult, RoutineStepOutput, RoutineArtifactInput, RoutineArtifact, RoutineAI } from './routine-definition-types.js';
3
3
  export declare const defineResponse: import('./routine-definition-types.js').DefineResponse;
4
4
  export declare const defineRoutine: import('./routine-definition-types.js').DefineRoutine;
5
5
  export declare const schema: import('./routine-definition-types.js').RoutineSchemaBuilders;
@@ -15,7 +15,7 @@ export type { GmailRuntimeConnection, AirtableRuntimeConnection, DropboxRuntimeC
15
15
  export type { Connections } from '../../../shared/airtable-contract.js';
16
16
  export declare const connections: import('../../../shared/airtable-contract.js').Connections;
17
17
  export { DataOperationError } from '../../../shared/data-contract.js';
18
- export type { DataRepository, DataErrorCode, DataValidationDetail, DataFieldExpectation, PublicValueDefinition, PublicField, CollectionSummary, CollectionSchema, QueryScalar, SelectionOptions, RecordSelection, RecordsQuery, DataValue, SelectedRecord, SelectionMetadata, SnapshotChange, RecordsResult, RecordsReadInput, RecordsReadResult, RecordsSearchOptions, RecordsSearchResult, RecordIdentity, RecordCreation, RecordUpdateSet, AppliedChanges, PublishedChanges, DataChangeOptions, DataChangeSet, DataEffect, DataFailureDetail, DataPublicationDetail, DataFailureCauseCode, LocalDataFileAction } from '../../../shared/data-contract.js';
18
+ export type { RecordSignal, TimelineEntry, SignalRelated, SignalRelatedInput, SignalInput, TimelineInput, SignalCondition, DataRepository, DataErrorCode, DataValidationDetail, DataFieldExpectation, PublicValueDefinition, PublicField, CollectionSummary, CollectionSchema, QueryScalar, SelectionOptions, RecordSelection, RecordsQuery, DataValue, SelectedRecord, SelectionMetadata, SnapshotChange, RecordsResult, RecordsReadInput, RecordsReadResult, RecordsSearchOptions, RecordsSearchResult, RecordIdentity, RecordCreation, RecordUpdateSet, AppliedChanges, PublishedChanges, DataChangeOptions, DataChangeSet, DataEffect, DataFailureDetail, DataPublicationDetail, DataFailureCauseCode, LocalDataFileAction } from '../../../shared/data-contract.js';
19
19
  declare global {
20
20
  namespace __OddingtonOS {
21
21
  /** Import-free OS-generated metadata; no runtime namespace is created. */
@@ -31,6 +31,7 @@ export type { SnapshotTransaction } from './data-schema-types.js';
31
31
  export type SnapshotRecordsAllOptions = {
32
32
  maxRecords: number;
33
33
  body?: true;
34
+ timeline?: true;
34
35
  };
35
36
  export type { SnapshotHistory, SnapshotHistoryRecord, SnapshotHistoryRecords, SnapshotHistoryChange, SnapshotHistoryEvent, SnapshotHistorySlot } from './data-snapshot-history-types.js';
36
37
  export type DataSnapshot<Name extends string = string> = {
@@ -198,7 +199,7 @@ export type RunSummary = {
198
199
  id: string;
199
200
  routine: string;
200
201
  placement: 'local' | 'remote';
201
- status: 'queued' | 'running' | 'succeeded' | 'failed';
202
+ status: 'queued' | 'running' | 'succeeded' | 'failed' | 'legacy';
202
203
  createdAt: string;
203
204
  startedAt?: string;
204
205
  finishedAt?: string;
@@ -7,6 +7,8 @@ import type { Handler, HandlerRuntime, HandlerTransition, JsonValue } from '../.
7
7
  import type { files, RoutinePublicationClient } from './public.js';
8
8
  import type { RoutineAccess } from '../../../shared/routine-definition-contract.js';
9
9
  import type { RoutineAIInput } from '../../../shared/routine-ai-contract.js';
10
+ import type { RoutineSchedule } from '../../../shared/routine-schedule.js';
11
+ export type { RoutineSchedule } from '../../../shared/routine-schedule.js';
10
12
  export type { RoutineAccess } from '../../../shared/routine-definition-contract.js';
11
13
  declare const valueType: unique symbol;
12
14
  /** Serializable declaration; the phantom type never carries authority. */
@@ -122,6 +124,7 @@ export type RoutineDefinition<Input extends RoutineSchema<unknown> | undefined =
122
124
  readonly id: Id;
123
125
  readonly title?: string;
124
126
  readonly input?: Input;
127
+ readonly schedule?: RoutineSchedule;
125
128
  readonly steps?: Steps;
126
129
  readonly result?: Result;
127
130
  readonly access?: Access;
@@ -1,3 +1,5 @@
1
+ import type { RecordSignal, TimelineEntry, SignalInput, TimelineInput } from './data-signals.js';
2
+ export type { RecordSignal, TimelineEntry, SignalRelated, SignalRelatedInput, SignalInput, TimelineInput } from './data-signals.js';
1
3
  /** Canonical value vocabulary shared by schema normalization and public reads. */
2
4
  export type DataValueDefinition<Extra extends object = object> = {
3
5
  nullable: boolean;
@@ -74,8 +76,12 @@ export type QueryCondition = QueryScalar | RangeCondition | {
74
76
  $lt?: never;
75
77
  $lte?: never;
76
78
  };
79
+ type FieldInitial = 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z';
77
80
  export type SelectionOptions = {
78
- where?: Record<string, QueryCondition>;
81
+ where?: Partial<Record<`${FieldInitial | Uppercase<FieldInitial>}${string}` | '$ref', QueryCondition>> & {
82
+ $signals?: Record<string, SignalCondition>;
83
+ };
84
+ timeline?: true;
79
85
  fields?: string[];
80
86
  order?: Record<string, 'asc' | 'desc'>;
81
87
  limit?: number;
@@ -95,6 +101,9 @@ export type SelectedRecord = {
95
101
  $version: string;
96
102
  [field: string]: DataValue;
97
103
  } & {
104
+ /** Complete on every returned current Record occurrence. */
105
+ $signals: RecordSignal[];
106
+ $timeline?: TimelineEntry[];
98
107
  /** Present on explicit body reads, including snapshot all for body-enabled collections. */
99
108
  $body?: string;
100
109
  /** Present only on an expanded qualified link occurrence. */
@@ -123,6 +132,14 @@ export type RecordIdentity = Pick<SelectedRecord, '$ref' | '$version'>;
123
132
  export type RecordsReadInput = string | readonly string[];
124
133
  export type RecordsReadOptions = {
125
134
  body?: true;
135
+ timeline?: true;
136
+ };
137
+ export type SignalCondition = string | {
138
+ $in: string[];
139
+ $exists?: never;
140
+ } | {
141
+ $exists: false;
142
+ $in?: never;
126
143
  };
127
144
  export type RecordsReadResult = {
128
145
  $meta: {
@@ -173,6 +190,8 @@ export type DataChangeOptions = {
173
190
  export interface DataChangeSet {
174
191
  create(record: RecordCreation): void;
175
192
  update(ref: string, set: RecordUpdateSet): void;
193
+ setSignal(ref: string, input: SignalInput): void;
194
+ appendTimeline(ref: string, input: TimelineInput): void;
176
195
  delete(record: RecordIdentity): void;
177
196
  validate(): Promise<void>;
178
197
  apply(): Promise<AppliedChanges>;
@@ -216,9 +235,20 @@ export type SnapshotChange = {
216
235
  kind: 'unlink';
217
236
  field: string;
218
237
  refs: string[];
238
+ } | {
239
+ kind: 'signal';
240
+ key: string;
241
+ value: Omit<RecordSignal, 'key' | 'number'> & {
242
+ number?: number;
243
+ };
244
+ } | {
245
+ kind: 'timeline';
246
+ entry: TimelineEntry;
219
247
  } | {
220
248
  kind: 'create' | 'delete';
221
249
  fields: Record<string, DataValue>;
250
+ signals?: RecordSignal[];
251
+ timeline?: TimelineEntry[];
222
252
  };
223
253
  person?: {
224
254
  id: string;
@@ -302,4 +332,3 @@ export declare class DataOperationError extends Error {
302
332
  readonly detail?: DataOperationDetail | undefined;
303
333
  constructor(code: DataErrorCode, retryable?: boolean, effect?: DataEffect | undefined, component?: string | undefined, detail?: DataOperationDetail | undefined);
304
334
  }
305
- export {};
@@ -0,0 +1,6 @@
1
+ export declare const dataText: (value: unknown) => value is string;
2
+ export declare const dataVersion: (value: unknown) => value is string;
3
+ /** Own enumerable data properties only; authored getters and symbols never run. */
4
+ export declare function dataProperties(value: unknown): Record<string, PropertyDescriptor>;
5
+ /** Dense own data only: reject holes, getters, symbols and extra properties. */
6
+ export declare function dataArray(value: unknown): unknown[];
@@ -0,0 +1,59 @@
1
+ export type SignalRelated = {
2
+ type: 'record';
3
+ ref: string;
4
+ } | {
5
+ type: 'signal';
6
+ record: string;
7
+ number: number;
8
+ } | {
9
+ type: 'ask';
10
+ number: number;
11
+ };
12
+ export type RecordSignal = {
13
+ number: number;
14
+ key: string;
15
+ label: string;
16
+ status: string;
17
+ reason?: string;
18
+ related: SignalRelated[];
19
+ asOf: string;
20
+ };
21
+ export type TimelineEntry = {
22
+ when: string;
23
+ event?: string;
24
+ activity: string;
25
+ related: SignalRelated[];
26
+ };
27
+ export type SignalRelatedInput = {
28
+ record: string;
29
+ } | {
30
+ signal: {
31
+ record: string;
32
+ number: number;
33
+ };
34
+ } | {
35
+ ask: number;
36
+ };
37
+ export type SignalInput = {
38
+ key: string;
39
+ label: string;
40
+ status: string;
41
+ reason?: string;
42
+ related?: SignalRelatedInput[];
43
+ };
44
+ export type TimelineInput = {
45
+ when: string;
46
+ event?: string;
47
+ activity: string;
48
+ related?: SignalRelatedInput[];
49
+ };
50
+ export type SignalAssessment = Omit<RecordSignal, 'number'>;
51
+ export declare const validSignalKey: (value: unknown) => value is string;
52
+ export declare const validSignalText: (value: unknown) => value is string;
53
+ export declare function validSignalInstant(value: unknown): value is string;
54
+ /** Public inputs capture assessment time once; wire recapture must retain it. */
55
+ export declare function captureSignal(value: unknown, acceptedAt?: string): SignalAssessment;
56
+ export declare function captureTimeline(value: unknown, compact?: boolean): TimelineEntry;
57
+ /** Complete canonical rows carried by snapshot artifacts and confirmed effects. */
58
+ export declare function captureRecordSignal(value: unknown): RecordSignal;
59
+ export declare function captureRecordSignals(value: unknown): RecordSignal[];
@@ -0,0 +1,23 @@
1
+ import { type AppValueSchema } from './app-routine-contract.js';
2
+ import { type File } from './files-contract.js';
3
+ export declare const LOCAL_ROUTINE_VALUE_BYTES: number;
4
+ export type LocalRoutineContract = {
5
+ id?: string;
6
+ input: AppValueSchema;
7
+ steps: Array<{
8
+ id: string;
9
+ title?: string;
10
+ summary?: AppValueSchema;
11
+ }>;
12
+ result?: AppValueSchema;
13
+ };
14
+ export declare function parseLocalRoutineContract(value: unknown): LocalRoutineContract;
15
+ export declare function validateLocalRoutineValue(schema: AppValueSchema, value: unknown): void;
16
+ /** Only declared File leaves are authority inputs; arbitrary IDs are ordinary data. */
17
+ export declare function localRoutineInputFiles(schema: AppValueSchema, value: unknown): File[];
18
+ /** Placement follows the declaration, including nested and repeated File leaves. */
19
+ export declare function routineInputFilePlacements(schema: AppValueSchema, value: unknown, host: 'local' | 'remote'): Array<{
20
+ file: File;
21
+ storage: 'local' | 'remote' | undefined;
22
+ }>;
23
+ export declare function hasLocalRoutineFileInput(schema: AppValueSchema): boolean;
@@ -1,4 +1,5 @@
1
1
  import { type AppValueSchema } from './app-routine-contract.js';
2
+ import { type RoutineSchedule } from './routine-schedule.js';
2
3
  export type RoutineAccess = {
3
4
  readonly repositories?: Readonly<Record<string, 'read' | 'write'>>;
4
5
  readonly connections?: readonly string[];
@@ -9,6 +10,7 @@ export type RoutineAccess = {
9
10
  export type RoutineContract = {
10
11
  id: string;
11
12
  title?: string;
13
+ schedule?: RoutineSchedule;
12
14
  input: AppValueSchema;
13
15
  inputDefault?: unknown;
14
16
  access: RoutineAccess;
@@ -28,6 +30,7 @@ export declare function assertRoutineJson(value: unknown, ancestors?: Set<object
28
30
  /** Inspect property descriptors before reading authored metadata or functions. */
29
31
  export declare function assertRoutineFields(value: unknown, allowed?: string[]): asserts value is Record<string, any>;
30
32
  export declare function parseRoutineAccess(value: unknown): RoutineAccess;
33
+ export declare function routineScheduleMetadata(value: unknown, input: AppValueSchema, hasDefault: boolean): RoutineSchedule;
31
34
  /** Inert report/admission grammar shared with authoring; imports no runtime or
32
35
  * capability modules and never constructs executable customer functions. */
33
36
  export declare function parseRoutineDefinitionContract(value: unknown): RoutineContract;
@@ -0,0 +1,9 @@
1
+ export type RoutineSchedule = {
2
+ readonly cron: string;
3
+ readonly timezone: string;
4
+ };
5
+ /** One occurrence evaluator for authored validation and activation/tick projection.
6
+ * The parser jumps calendar fields rather than walking elapsed minutes. Its own
7
+ * iteration ceiling plus this eight-year horizon bound even sparse schedules
8
+ * (including Feb 29 across a non-leap century). No missed times are enumerated. */
9
+ export declare function nextRoutineScheduleOccurrence(schedule: RoutineSchedule, after: Date): Date;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oddington/sdk",
3
- "version": "0.1.66",
3
+ "version": "0.1.68",
4
4
  "description": "OS routine and response-handler SDK",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",