@timeback/caliper 0.1.0

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.
Files changed (44) hide show
  1. package/README.md +278 -0
  2. package/dist/client.d.ts +85 -0
  3. package/dist/client.d.ts.map +1 -0
  4. package/dist/constants.d.ts +27 -0
  5. package/dist/constants.d.ts.map +1 -0
  6. package/dist/errors.d.ts +7 -0
  7. package/dist/errors.d.ts.map +1 -0
  8. package/dist/factory.d.ts +38 -0
  9. package/dist/factory.d.ts.map +1 -0
  10. package/dist/index.d.ts +76 -0
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +1707 -0
  13. package/dist/lib/event-factories.d.ts +67 -0
  14. package/dist/lib/event-factories.d.ts.map +1 -0
  15. package/dist/lib/index.d.ts +11 -0
  16. package/dist/lib/index.d.ts.map +1 -0
  17. package/dist/lib/pagination.d.ts +26 -0
  18. package/dist/lib/pagination.d.ts.map +1 -0
  19. package/dist/lib/resolve.d.ts +21 -0
  20. package/dist/lib/resolve.d.ts.map +1 -0
  21. package/dist/lib/transport.d.ts +32 -0
  22. package/dist/lib/transport.d.ts.map +1 -0
  23. package/dist/resources/events.d.ts +241 -0
  24. package/dist/resources/events.d.ts.map +1 -0
  25. package/dist/resources/index.d.ts +6 -0
  26. package/dist/resources/index.d.ts.map +1 -0
  27. package/dist/resources/jobs.d.ts +49 -0
  28. package/dist/resources/jobs.d.ts.map +1 -0
  29. package/dist/types/api.d.ts +101 -0
  30. package/dist/types/api.d.ts.map +1 -0
  31. package/dist/types/client.d.ts +57 -0
  32. package/dist/types/client.d.ts.map +1 -0
  33. package/dist/types/events.d.ts +203 -0
  34. package/dist/types/events.d.ts.map +1 -0
  35. package/dist/types/index.d.ts +11 -0
  36. package/dist/types/index.d.ts.map +1 -0
  37. package/dist/types/timeback.d.ts +395 -0
  38. package/dist/types/timeback.d.ts.map +1 -0
  39. package/dist/types.d.ts +7 -0
  40. package/dist/types.d.ts.map +1 -0
  41. package/dist/types.js +83 -0
  42. package/dist/utils.d.ts +10 -0
  43. package/dist/utils.d.ts.map +1 -0
  44. package/package.json +36 -0
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Event Factory Functions
3
+ *
4
+ * Pure factory functions for creating Timeback profile events.
5
+ * Use these when you want to batch multiple events into a single envelope.
6
+ */
7
+ import type { ActivityCompletedEvent, ActivityCompletedInput, TimeSpentEvent, TimeSpentInput } from '../types';
8
+ /**
9
+ * Create an ActivityEvent from input.
10
+ *
11
+ * Pure factory function - creates the event object without sending.
12
+ * Use this when you want to batch multiple events into a single envelope.
13
+ *
14
+ * @param input - Activity completion data
15
+ * @returns A fully-formed ActivityCompletedEvent ready to send
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * import { createActivityEvent, createTimeSpentEvent } from '@timeback/caliper'
20
+ *
21
+ * const activityEvent = createActivityEvent({
22
+ * actor: { id: '...', type: 'TimebackUser', email: 'student@example.edu' },
23
+ * object: { id: '...', type: 'TimebackActivityContext', subject: 'Math', app: { name: 'My App' } },
24
+ * metrics: [
25
+ * { type: 'totalQuestions', value: 10 },
26
+ * { type: 'correctQuestions', value: 8 },
27
+ * ],
28
+ * })
29
+ *
30
+ * const timeSpentEvent = createTimeSpentEvent({
31
+ * actor: { id: '...', type: 'TimebackUser', email: 'student@example.edu' },
32
+ * object: { id: '...', type: 'TimebackActivityContext', subject: 'Math', app: { name: 'My App' } },
33
+ * metrics: [{ type: 'active', value: 1800 }],
34
+ * })
35
+ *
36
+ * // Send both in one envelope
37
+ * await client.events.send(sensor, [activityEvent, timeSpentEvent])
38
+ * ```
39
+ */
40
+ export declare function createActivityEvent(input: ActivityCompletedInput): ActivityCompletedEvent;
41
+ /**
42
+ * Create a TimeSpentEvent from input.
43
+ *
44
+ * Pure factory function - creates the event object without sending.
45
+ * Use this when you want to batch multiple events into a single envelope.
46
+ *
47
+ * @param input - Time spent data
48
+ * @returns A fully-formed TimeSpentEvent ready to send
49
+ *
50
+ * @example
51
+ * ```typescript
52
+ * import { createTimeSpentEvent } from '@timeback/caliper'
53
+ *
54
+ * const event = createTimeSpentEvent({
55
+ * actor: { id: '...', type: 'TimebackUser', email: 'student@example.edu' },
56
+ * object: { id: '...', type: 'TimebackActivityContext', subject: 'Reading', app: { name: 'My App' } },
57
+ * metrics: [
58
+ * { type: 'active', value: 1800 },
59
+ * { type: 'inactive', value: 300 },
60
+ * ],
61
+ * })
62
+ *
63
+ * await client.events.send(sensor, [event])
64
+ * ```
65
+ */
66
+ export declare function createTimeSpentEvent(input: TimeSpentInput): TimeSpentEvent;
67
+ //# sourceMappingURL=event-factories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-factories.d.ts","sourceRoot":"","sources":["../../src/lib/event-factories.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EACX,sBAAsB,EACtB,sBAAsB,EACtB,cAAc,EACd,cAAc,EACd,MAAM,UAAU,CAAA;AAEjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,sBAAsB,GAAG,sBAAsB,CAoBzF;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,cAAc,GAAG,cAAc,CAoB1E"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Internal Library Exports
3
+ *
4
+ * @internal
5
+ */
6
+ export { resolveToProvider } from './resolve';
7
+ export { Transport } from './transport';
8
+ export { Paginator } from './pagination';
9
+ export { createActivityEvent, createTimeSpentEvent } from './event-factories';
10
+ export type { ResolvedConfig } from '@timeback/internal-client-infra';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AAE7E,YAAY,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAA"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Pagination Utilities
3
+ *
4
+ * Re-exports the common Paginator with Caliper-specific configuration.
5
+ */
6
+ import { Paginator as BasePaginator } from '@timeback/internal-client-infra';
7
+ import type { ListParams } from '@timeback/internal-client-infra';
8
+ import type { CaliperTransportLike } from '../types';
9
+ /**
10
+ * Caliper-specific Paginator that uses the Caliper transport.
11
+ *
12
+ * Uses body-based pagination with the events response format.
13
+ *
14
+ * @typeParam T - The type of items being paginated
15
+ */
16
+ export declare class Paginator<T> extends BasePaginator<T> {
17
+ /**
18
+ * Create a new Caliper Paginator.
19
+ *
20
+ * @param transport - Caliper transport instance
21
+ * @param path - API endpoint path
22
+ * @param params - List parameters including optional max
23
+ */
24
+ constructor(transport: CaliperTransportLike, path: string, params?: ListParams);
25
+ }
26
+ //# sourceMappingURL=pagination.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../src/lib/pagination.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,iCAAiC,CAAA;AAI5E,OAAO,KAAK,EAAE,UAAU,EAAqB,MAAM,iCAAiC,CAAA;AACpF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAEpD;;;;;;GAMG;AACH,qBAAa,SAAS,CAAC,CAAC,CAAE,SAAQ,aAAa,CAAC,CAAC,CAAC;IACjD;;;;;;OAMG;IACH,YAAY,SAAS,EAAE,oBAAoB,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAE,UAAe,EAWjF;CACD"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Provider Resolution
3
+ *
4
+ * Caliper-specific wrapper around the generic provider resolver.
5
+ *
6
+ * @internal
7
+ */
8
+ import type { ProviderRegistry } from '@timeback/internal-client-infra';
9
+ import type { CaliperClientConfig, CaliperResolvedProvider } from '../types';
10
+ /**
11
+ * Resolve Caliper client config to a TimebackProvider.
12
+ *
13
+ * @param config - Client configuration
14
+ * @param registry - Provider registry for platform/env resolution
15
+ * @returns Resolved provider or transport
16
+ * @throws {Error} If configuration is invalid or incomplete
17
+ *
18
+ * @internal
19
+ */
20
+ export declare function resolveToProvider(config: CaliperClientConfig, registry?: ProviderRegistry): CaliperResolvedProvider;
21
+ //# sourceMappingURL=resolve.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/lib/resolve.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AASH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAA;AACvE,OAAO,KAAK,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA;AAE5E;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAChC,MAAM,EAAE,mBAAmB,EAC3B,QAAQ,GAAE,gBAA4C,GACpD,uBAAuB,CAEzB"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Transport Layer
3
+ *
4
+ * HTTP transport for Caliper API communication.
5
+ */
6
+ import { BaseTransport } from '@timeback/internal-client-infra';
7
+ import type { CaliperPaths, PaginatedResponse, RequestOptions } from '@timeback/internal-client-infra';
8
+ import type { CaliperTransportConfig } from '../types';
9
+ /**
10
+ * HTTP transport layer for Caliper API communication.
11
+ *
12
+ * Extends BaseTransport with Caliper-specific path configuration.
13
+ * Uses body-based pagination (events array + pagination metadata).
14
+ */
15
+ export declare class Transport extends BaseTransport {
16
+ /** API path profiles for Caliper operations */
17
+ readonly paths: CaliperPaths;
18
+ constructor(config: CaliperTransportConfig);
19
+ /**
20
+ * Make a paginated request using body-based pagination.
21
+ *
22
+ * Caliper APIs return pagination metadata in the response body:
23
+ * - `events`: Array of items
24
+ * - `pagination`: { total, totalPages, currentPage, limit }
25
+ *
26
+ * @param path - API endpoint path
27
+ * @param options - Request options
28
+ * @returns Normalized paginated response with hasMore and total
29
+ */
30
+ requestPaginated<T>(path: string, options?: RequestOptions): Promise<PaginatedResponse<T>>;
31
+ }
32
+ //# sourceMappingURL=transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/lib/transport.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAA;AAI/D,OAAO,KAAK,EACX,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,MAAM,iCAAiC,CAAA;AACxC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAWtD;;;;;GAKG;AACH,qBAAa,SAAU,SAAQ,aAAa;IAC3C,+CAA+C;IAC/C,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAA;IAE5B,YAAY,MAAM,EAAE,sBAAsB,EAGzC;IAED;;;;;;;;;;OAUG;IACG,gBAAgB,CAAC,CAAC,EACvB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,cAAmB,GAC1B,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAY/B;CACD"}
@@ -0,0 +1,241 @@
1
+ /**
2
+ * Events Resource
3
+ *
4
+ * Manage Caliper events - send, list, and retrieve.
5
+ */
6
+ import { Paginator } from '../lib/pagination';
7
+ import type { ActivityCompletedInput, CaliperEnvelope, CaliperEvent, CaliperTransportLike, ListEventsParams, ListEventsResult, SendEventsResult, StoredEvent, TimeSpentInput, ValidationResult } from '../types';
8
+ /**
9
+ * Caliper Events resource.
10
+ *
11
+ * Provides methods to send, list, and retrieve Caliper events.
12
+ */
13
+ export declare class EventsResource {
14
+ private readonly transport;
15
+ constructor(transport: CaliperTransportLike);
16
+ /**
17
+ * Send Caliper events.
18
+ *
19
+ * Wraps events in an envelope and sends to the API.
20
+ * Events are validated against the IMS Caliper specification
21
+ * and queued for async processing.
22
+ *
23
+ * @param sensor - Sensor identifier (IRI format)
24
+ * @param events - Array of Caliper events
25
+ * @returns Job ID for tracking processing status
26
+ *
27
+ * @remarks
28
+ * **API Response Drift**: The official API docs (caliper/response.yaml) document
29
+ * the response as `{ status, message, errors? }`, but the actual API returns
30
+ * `{ jobId }`. This client correctly handles the actual response.
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * const result = await client.events.send(
35
+ * 'https://example.edu/sensors/1',
36
+ * [event1, event2]
37
+ * )
38
+ * ```
39
+ */
40
+ send(sensor: string, events: CaliperEvent[]): Promise<SendEventsResult>;
41
+ /**
42
+ * Send a raw Caliper envelope.
43
+ *
44
+ * Use this when you need full control over the envelope structure.
45
+ * For most cases, prefer `send()` which builds the envelope for you.
46
+ *
47
+ * @param envelope - Caliper envelope containing events
48
+ * @returns Job ID for tracking processing status
49
+ *
50
+ * @remarks
51
+ * **API Response Drift**: See `send()` for details on response format drift.
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * const result = await client.events.sendEnvelope({
56
+ * sensor: 'https://example.edu/sensors/1',
57
+ * sendTime: new Date().toISOString(),
58
+ * dataVersion: 'http://purl.imsglobal.org/ctx/caliper/v1p2',
59
+ * data: [event1, event2],
60
+ * })
61
+ * ```
62
+ */
63
+ sendEnvelope(envelope: CaliperEnvelope): Promise<SendEventsResult>;
64
+ /**
65
+ * Validate Caliper events without storing them.
66
+ *
67
+ * Use this to check if events conform to the IMS Caliper specification
68
+ * before sending them for processing.
69
+ *
70
+ * @param envelope - Caliper envelope containing events to validate
71
+ * @returns Validation result with status and any errors
72
+ *
73
+ * @example
74
+ * ```typescript
75
+ * const result = await client.events.validate({
76
+ * sensor: 'https://example.edu/sensors/1',
77
+ * sendTime: new Date().toISOString(),
78
+ * dataVersion: 'http://purl.imsglobal.org/ctx/caliper/v1p2',
79
+ * data: [event1, event2],
80
+ * })
81
+ *
82
+ * if (result.status === 'success') {
83
+ * console.log('Events are valid!')
84
+ * } else {
85
+ * console.log('Validation errors:', result.errors)
86
+ * }
87
+ * ```
88
+ */
89
+ validate(envelope: CaliperEnvelope): Promise<ValidationResult>;
90
+ /**
91
+ * List Caliper events with optional filtering.
92
+ *
93
+ * @param params - Filter parameters
94
+ * @returns Events array and pagination metadata
95
+ *
96
+ * @remarks
97
+ * **API Response Drift**: The official API docs (caliper/response.yaml) document
98
+ * the response as `{ status, message, errors? }`, but the actual API returns
99
+ * `{ events: StoredEvent[], pagination: { total, totalPages, currentPage, limit } }`.
100
+ * This client correctly handles the actual response.
101
+ *
102
+ * @example
103
+ * ```typescript
104
+ * const { events } = await client.events.list({
105
+ * limit: 50,
106
+ * actorEmail: 'student@example.edu',
107
+ * startDate: '2024-01-01',
108
+ * })
109
+ *
110
+ * // Access pagination metadata
111
+ * const { events, pagination } = await client.events.list({ limit: 10 })
112
+ * console.log(`Total: ${pagination.total}`)
113
+ * ```
114
+ */
115
+ list(params?: ListEventsParams): Promise<ListEventsResult>;
116
+ /**
117
+ * Stream Caliper events with automatic pagination.
118
+ *
119
+ * Returns a Paginator that lazily fetches pages as you iterate.
120
+ * Use this for large datasets or when you need all matching events.
121
+ *
122
+ * @param params - Filter parameters (same as list())
123
+ * @returns Paginator for async iteration
124
+ *
125
+ * @example Iterate over all events
126
+ * ```typescript
127
+ * for await (const event of client.events.stream({ startDate: '2024-01-01' })) {
128
+ * console.log(event.id)
129
+ * }
130
+ * ```
131
+ *
132
+ * @example Collect all events into an array
133
+ * ```typescript
134
+ * const allEvents = await client.events
135
+ * .stream({ startDate: '2024-01-01' })
136
+ * .toArray()
137
+ * ```
138
+ *
139
+ * @example Limit total events fetched
140
+ * ```typescript
141
+ * const events = await client.events
142
+ * .stream({ startDate: '2024-01-01', max: 1000 })
143
+ * .toArray()
144
+ * ```
145
+ */
146
+ stream(params?: ListEventsParams & {
147
+ max?: number;
148
+ }): Paginator<StoredEvent>;
149
+ /**
150
+ * Get a specific event by its external ID.
151
+ *
152
+ * @param externalId - The event's external ID (URN UUID format, e.g., 'urn:uuid:...')
153
+ * @returns The stored event
154
+ *
155
+ * @remarks
156
+ * **API Response Drift**: The official API docs (caliper/response.yaml) document
157
+ * the response as `{ status, message, errors? }`, but the actual API returns
158
+ * `{ status, event: StoredEvent }`. This client correctly handles the actual response.
159
+ *
160
+ * **Important**: Use `externalId` (URN UUID), not the internal numeric `id`.
161
+ * The `StoredEvent` returned from `list()` contains both - use `event.externalId`.
162
+ *
163
+ * @example
164
+ * ```typescript
165
+ * const event = await client.events.get('urn:uuid:c51570e4-f8ed-4c18-bb3a-dfe51b2cc594')
166
+ * ```
167
+ */
168
+ get(externalId: string): Promise<StoredEvent>;
169
+ /**
170
+ * Send an activity event (Timeback Profile).
171
+ *
172
+ * Records student activity completion with performance metrics.
173
+ * This is a first-class method for the Timeback platform.
174
+ *
175
+ * @param sensor - Sensor identifier (IRI format)
176
+ * @param input - Activity completion data
177
+ * @returns Job ID for tracking processing status
178
+ *
179
+ * @example
180
+ * ```typescript
181
+ * const result = await client.events.sendActivity(
182
+ * 'https://myapp.example.com/sensors/main',
183
+ * {
184
+ * actor: {
185
+ * id: 'https://api.example.com/users/123',
186
+ * type: 'TimebackUser',
187
+ * email: 'student@example.edu',
188
+ * },
189
+ * object: {
190
+ * id: 'https://myapp.example.com/activities/456',
191
+ * type: 'TimebackActivityContext',
192
+ * subject: 'Math',
193
+ * app: { name: 'My Learning App' },
194
+ * },
195
+ * metrics: [
196
+ * { type: 'totalQuestions', value: 10 },
197
+ * { type: 'correctQuestions', value: 8 },
198
+ * { type: 'xpEarned', value: 150 },
199
+ * ],
200
+ * },
201
+ * )
202
+ * ```
203
+ */
204
+ sendActivity(sensor: string, input: ActivityCompletedInput): Promise<SendEventsResult>;
205
+ /**
206
+ * Send a time spent event (Timeback Profile).
207
+ *
208
+ * Records time spent on an activity, categorized by engagement type.
209
+ * This is a first-class method for the Timeback platform.
210
+ *
211
+ * @param sensor - Sensor identifier (IRI format)
212
+ * @param input - Time spent data
213
+ * @returns Job ID for tracking processing status
214
+ *
215
+ * @example
216
+ * ```typescript
217
+ * const result = await client.events.sendTimeSpent(
218
+ * 'https://myapp.example.com/sensors/main',
219
+ * {
220
+ * actor: {
221
+ * id: 'https://api.example.com/users/123',
222
+ * type: 'TimebackUser',
223
+ * email: 'student@example.edu',
224
+ * },
225
+ * object: {
226
+ * id: 'https://myapp.example.com/activities/456',
227
+ * type: 'TimebackActivityContext',
228
+ * subject: 'Reading',
229
+ * app: { name: 'My Learning App' },
230
+ * },
231
+ * metrics: [
232
+ * { type: 'active', value: 1800 }, // 30 minutes
233
+ * { type: 'inactive', value: 300 }, // 5 minutes
234
+ * ],
235
+ * },
236
+ * )
237
+ * ```
238
+ */
239
+ sendTimeSpent(sensor: string, input: TimeSpentInput): Promise<SendEventsResult>;
240
+ }
241
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/resources/events.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAG7C,OAAO,KAAK,EACX,sBAAsB,EACtB,eAAe,EACf,YAAY,EACZ,oBAAoB,EAEpB,gBAAgB,EAEhB,gBAAgB,EAEhB,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,MAAM,UAAU,CAAA;AAEjB;;;;GAIG;AACH,qBAAa,cAAc;IACd,OAAO,CAAC,QAAQ,CAAC,SAAS;IAAtC,YAA6B,SAAS,EAAE,oBAAoB,EAAI;IAEhE;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAStE;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,YAAY,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAcvE;IAED;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACG,QAAQ,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAoBnE;IAED;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACG,IAAI,CAAC,MAAM,GAAE,gBAAqB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CA2BnE;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH,MAAM,CAAC,MAAM,GAAE,gBAAgB,GAAG;QAAE,GAAG,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,SAAS,CAAC,WAAW,CAAC,CAwB/E;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACG,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAgBlD;IAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;IACH,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAWrF;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACH,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAW9E;CACD"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Caliper Resources
3
+ */
4
+ export { EventsResource } from './events';
5
+ export { JobsResource } from './jobs';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/resources/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Jobs Resource
3
+ *
4
+ * Track status of async event processing jobs.
5
+ */
6
+ import type { CaliperTransportLike, JobStatus, WaitForCompletionOptions } from '../types';
7
+ /**
8
+ * Jobs resource for tracking async processing.
9
+ *
10
+ * When events are submitted, they are queued for async processing.
11
+ * Use this resource to check job status and retrieve results.
12
+ */
13
+ export declare class JobsResource {
14
+ private readonly transport;
15
+ constructor(transport: CaliperTransportLike);
16
+ /**
17
+ * Get the status of a processing job.
18
+ *
19
+ * @param jobId - The job ID returned from events.send()
20
+ * @returns Job status including state and results
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * const status = await client.jobs.getStatus(jobId)
25
+ *
26
+ * if (status.state === 'completed') {
27
+ * console.log('Events processed:', status.returnValue?.results)
28
+ * }
29
+ * ```
30
+ */
31
+ getStatus(jobId: string): Promise<JobStatus>;
32
+ /**
33
+ * Wait for a job to complete with polling.
34
+ *
35
+ * @param jobId - The job ID to wait for
36
+ * @param options - Polling options
37
+ * @returns Final job status
38
+ * @throws {Error} If job fails or times out
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * const result = await client.events.send(envelope)
43
+ * const status = await client.jobs.waitForCompletion(result.jobId)
44
+ * console.log('Processed events:', status.returnValue?.results)
45
+ * ```
46
+ */
47
+ waitForCompletion(jobId: string, options?: WaitForCompletionOptions): Promise<JobStatus>;
48
+ }
49
+ //# sourceMappingURL=jobs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jobs.d.ts","sourceRoot":"","sources":["../../src/resources/jobs.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EACX,oBAAoB,EACpB,SAAS,EAET,wBAAwB,EACxB,MAAM,UAAU,CAAA;AAEjB;;;;;GAKG;AACH,qBAAa,YAAY;IACZ,OAAO,CAAC,QAAQ,CAAC,SAAS;IAAtC,YAA6B,SAAS,EAAE,oBAAoB,EAAI;IAEhE;;;;;;;;;;;;;;OAcG;IACG,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAajD;IAED;;;;;;;;;;;;;;OAcG;IACG,iBAAiB,CACtB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,wBAA6B,GACpC,OAAO,CAAC,SAAS,CAAC,CAyBpB;CACD"}
@@ -0,0 +1,101 @@
1
+ /**
2
+ * API Response Types
3
+ *
4
+ * Types for Caliper API responses.
5
+ *
6
+ * @remarks
7
+ * **IMPORTANT - API Docs Drift**: The official API documentation (caliper/response.yaml
8
+ * and caliper-api.yaml) does NOT accurately reflect actual API responses. The types
9
+ * in this file were derived from testing actual API responses. See individual type
10
+ * comments for specific discrepancies.
11
+ */
12
+ import type { JobStatus, StoredEvent } from './events';
13
+ /**
14
+ * Generic API response wrapper.
15
+ */
16
+ export interface ApiResponse<T> {
17
+ status: 'success' | 'error';
18
+ message?: string;
19
+ data?: T;
20
+ }
21
+ /**
22
+ * Pagination metadata returned by list endpoints.
23
+ */
24
+ export interface PaginationMeta {
25
+ /** Total number of items across all pages */
26
+ total: number;
27
+ /** Total number of pages */
28
+ totalPages: number;
29
+ /** Current page number (1-indexed) */
30
+ currentPage: number;
31
+ /** Number of items per page */
32
+ limit: number;
33
+ }
34
+ /**
35
+ * Response from GET /caliper/events (list events).
36
+ *
37
+ * @remarks
38
+ * **API Docs Drift**: Official docs (caliper/response.yaml) incorrectly show
39
+ * `{ status, message, errors? }`. Actual response is `{ events, pagination }`.
40
+ */
41
+ export interface ListEventsResponse {
42
+ /** Array of stored events */
43
+ events: StoredEvent[];
44
+ /** Pagination metadata */
45
+ pagination: PaginationMeta;
46
+ }
47
+ /**
48
+ * Response from GET /caliper/events/:externalId (get single event).
49
+ *
50
+ * @remarks
51
+ * **API Docs Drift**: Official docs (caliper/response.yaml) incorrectly show
52
+ * `{ status, message, errors? }`. Actual response is `{ status, event }`.
53
+ */
54
+ export interface GetEventResponse {
55
+ /** Status indicator */
56
+ status: 'success' | 'error';
57
+ /** The requested event */
58
+ event: StoredEvent;
59
+ }
60
+ /**
61
+ * Response from POST /caliper/event (send events).
62
+ *
63
+ * @remarks
64
+ * **API Docs Drift**: Official docs (caliper/response.yaml) incorrectly show
65
+ * `{ status, message, errors? }`. Actual response is `{ jobId }`.
66
+ * Use the jobId with `jobs.getStatus()` to track processing.
67
+ */
68
+ export interface SendEventsResponse {
69
+ /** Job ID for tracking async processing */
70
+ jobId: string;
71
+ }
72
+ /**
73
+ * Job status response payload (GET /jobs/{jobId}/status).
74
+ *
75
+ * @remarks
76
+ * This endpoint is correctly documented in caliper/response.yaml.
77
+ */
78
+ export interface JobStatusResponse {
79
+ job: JobStatus;
80
+ }
81
+ /**
82
+ * Options for waitForCompletion polling.
83
+ */
84
+ export interface WaitForCompletionOptions {
85
+ /** Maximum time to wait in milliseconds (default: 30000) */
86
+ timeoutMs?: number;
87
+ /** Interval between status checks in milliseconds (default: 1000) */
88
+ pollIntervalMs?: number;
89
+ }
90
+ /**
91
+ * Validation result from the validate endpoint.
92
+ */
93
+ export interface ValidationResult {
94
+ /** Whether validation succeeded */
95
+ status: 'success' | 'error';
96
+ /** Human-readable message */
97
+ message?: string;
98
+ /** Validation errors (if any) */
99
+ errors?: unknown;
100
+ }
101
+ //# sourceMappingURL=api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/types/api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAEtD;;GAEG;AACH,MAAM,WAAW,WAAW,CAAC,CAAC;IAC7B,MAAM,EAAE,SAAS,GAAG,OAAO,CAAA;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,CAAC,CAAA;CACR;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAA;IACb,4BAA4B;IAC5B,UAAU,EAAE,MAAM,CAAA;IAClB,sCAAsC;IACtC,WAAW,EAAE,MAAM,CAAA;IACnB,+BAA+B;IAC/B,KAAK,EAAE,MAAM,CAAA;CACb;AAED;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IAClC,6BAA6B;IAC7B,MAAM,EAAE,WAAW,EAAE,CAAA;IACrB,0BAA0B;IAC1B,UAAU,EAAE,cAAc,CAAA;CAC1B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAChC,uBAAuB;IACvB,MAAM,EAAE,SAAS,GAAG,OAAO,CAAA;IAC3B,0BAA0B;IAC1B,KAAK,EAAE,WAAW,CAAA;CAClB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB;IAClC,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAA;CACb;AAED;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IACjC,GAAG,EAAE,SAAS,CAAA;CACd;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACxC,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,qEAAqE;IACrE,cAAc,CAAC,EAAE,MAAM,CAAA;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC,mCAAmC;IACnC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAA;IAC3B,6BAA6B;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,iCAAiC;IACjC,MAAM,CAAC,EAAE,OAAO,CAAA;CAChB"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Client Configuration Types
3
+ *
4
+ * Configuration types for the Caliper client.
5
+ */
6
+ import type { BaseTransportConfig, CaliperPaths, ClientConfig, EnvAuth, Environment, ExplicitAuth, PaginatedResponse, Platform, ProviderClientConfig, RequestOptions, ResolvedProvider, TransportOnlyConfig } from '@timeback/internal-client-infra';
7
+ import type { CaliperClient } from '../client';
8
+ /**
9
+ * Re-export vital config types for SDK users.
10
+ */
11
+ export type { Environment, EnvAuth, ExplicitAuth, Platform };
12
+ /**
13
+ * Transport interface for Caliper client.
14
+ *
15
+ * Extends base transport requirements with Caliper-specific paths.
16
+ * Required when using transport mode with CaliperClient.
17
+ */
18
+ export interface CaliperTransportLike {
19
+ /** Base URL of the API */
20
+ baseUrl: string;
21
+ /** API path profiles for Caliper operations */
22
+ paths: CaliperPaths;
23
+ /** Make an authenticated request */
24
+ request<T>(path: string, options?: RequestOptions): Promise<T>;
25
+ /** Make a paginated request using body-based pagination */
26
+ requestPaginated<T>(path: string, options?: RequestOptions): Promise<PaginatedResponse<T>>;
27
+ }
28
+ /**
29
+ * Caliper client configuration options.
30
+ *
31
+ * Supports four modes:
32
+ * - **Provider mode**: `{ provider: TimebackProvider }` — pre-built provider with token sharing
33
+ * - **Environment mode**: `{ platform?, env, auth }` — Timeback hosted APIs
34
+ * - **Explicit mode**: `{ baseUrl, auth: { authUrl } }` — custom API URLs
35
+ * - **Transport mode**: `{ transport: CaliperTransportLike }` — custom transport with paths
36
+ *
37
+ * The `platform` field (in env mode) selects which Timeback implementation to use:
38
+ * - `'BEYOND_AI'` (default): BeyondAI's Timeback platform
39
+ * - `'LEARNWITH_AI'`: Samy's LearnWith.AI platform
40
+ */
41
+ export type CaliperClientConfig = ClientConfig | TransportOnlyConfig<CaliperTransportLike> | ProviderClientConfig;
42
+ /**
43
+ * Configuration for Caliper transport.
44
+ */
45
+ export type CaliperTransportConfig = BaseTransportConfig & {
46
+ /** API path profiles for Caliper operations */
47
+ paths: CaliperPaths;
48
+ };
49
+ /**
50
+ * Resolved provider type for Caliper client.
51
+ */
52
+ export type CaliperResolvedProvider = ResolvedProvider<CaliperTransportLike>;
53
+ /**
54
+ * Instance type of CaliperClient.
55
+ */
56
+ export type CaliperClientInstance = InstanceType<typeof CaliperClient>;
57
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/types/client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACX,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,OAAO,EACP,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,QAAQ,EACR,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,MAAM,iCAAiC,CAAA;AACxC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAE9C;;GAEG;AACH,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAA;AAE5D;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACpC,0BAA0B;IAC1B,OAAO,EAAE,MAAM,CAAA;IACf,+CAA+C;IAC/C,KAAK,EAAE,YAAY,CAAA;IACnB,oCAAoC;IACpC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;IAC9D,2DAA2D;IAC3D,gBAAgB,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAA;CAC1F;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,mBAAmB,GAC5B,YAAY,GACZ,mBAAmB,CAAC,oBAAoB,CAAC,GACzC,oBAAoB,CAAA;AAEvB;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,mBAAmB,GAAG;IAC1D,+CAA+C;IAC/C,KAAK,EAAE,YAAY,CAAA;CACnB,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,gBAAgB,CAAC,oBAAoB,CAAC,CAAA;AAE5E;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,YAAY,CAAC,OAAO,aAAa,CAAC,CAAA"}