@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,203 @@
1
+ /**
2
+ * Caliper Event Types
3
+ *
4
+ * Types for Caliper Analytics events and envelopes.
5
+ */
6
+ import type { CALIPER_DATA_VERSION } from '../constants';
7
+ import type { PaginationMeta } from './api';
8
+ import type { TimebackUser } from './timeback';
9
+ /**
10
+ * Supported Caliper profiles.
11
+ */
12
+ export type CaliperProfile = 'AnnotationProfile' | 'AssessmentProfile' | 'ToolUseProfile' | 'GeneralProfile' | 'FeedbackProfile' | 'MediaProfile' | 'SurveyProfile' | 'ResourceManagementProfile' | 'ForumProfile' | 'AssignableProfile' | 'GradingProfile' | 'ReadingProfile' | 'SessionProfile' | 'SearchProfile' | 'ToolLaunchProfile' | 'TimebackProfile';
13
+ /**
14
+ * Base Caliper entity - can be a URI string or an object with properties.
15
+ */
16
+ export type CaliperEntity = string | {
17
+ [key: string]: unknown;
18
+ };
19
+ /**
20
+ * Caliper actor entity (for sending events).
21
+ *
22
+ * Timeback API requires actors to have extensions.email.
23
+ */
24
+ export interface CaliperActor {
25
+ /** Unique identifier (IRI format) */
26
+ id: string;
27
+ /** Entity type (e.g., 'Person', 'TimebackUser') */
28
+ type: string;
29
+ /** Extensions - email is required by Timeback API */
30
+ extensions: {
31
+ /** Actor's email address (required by Timeback) */
32
+ email: string;
33
+ /** Additional extension properties */
34
+ [key: string]: unknown;
35
+ };
36
+ }
37
+ /**
38
+ * Caliper Event.
39
+ *
40
+ * Represents a learning activity event conforming to IMS Caliper v1.2.
41
+ */
42
+ export interface CaliperEvent {
43
+ /** JSON-LD context */
44
+ '@context'?: string;
45
+ /** Unique identifier (URN UUID format) */
46
+ id: string;
47
+ /** Event type */
48
+ type: string;
49
+ /** The agent who initiated the event (string URL, CaliperActor, or TimebackUser) */
50
+ actor: string | CaliperActor | TimebackUser;
51
+ /** The action or predicate */
52
+ action: string;
53
+ /** The object of the interaction */
54
+ object: CaliperEntity;
55
+ /** ISO 8601 datetime when event occurred */
56
+ eventTime: string;
57
+ /** Profile governing interpretation */
58
+ profile: CaliperProfile;
59
+ /** Application context */
60
+ edApp?: CaliperEntity;
61
+ /** Entity generated as result */
62
+ generated?: CaliperEntity;
63
+ /** Target segment within object */
64
+ target?: CaliperEntity;
65
+ /** Referring context */
66
+ referrer?: CaliperEntity;
67
+ /** Organization/group context */
68
+ group?: CaliperEntity;
69
+ /** User's membership/role */
70
+ membership?: CaliperEntity;
71
+ /** Current user session */
72
+ session?: CaliperEntity;
73
+ /** LTI session context */
74
+ federatedSession?: CaliperEntity;
75
+ /** Additional custom attributes */
76
+ extensions?: Record<string, unknown>;
77
+ }
78
+ /**
79
+ * Caliper Envelope.
80
+ *
81
+ * Container for transmitting Caliper events to the API.
82
+ */
83
+ export interface CaliperEnvelope {
84
+ /** Sensor identifier (IRI format) */
85
+ sensor: string;
86
+ /** ISO 8601 datetime when data was sent */
87
+ sendTime: string;
88
+ /** Caliper data version */
89
+ dataVersion: typeof CALIPER_DATA_VERSION;
90
+ /** Array of events or entities */
91
+ data: CaliperEvent[];
92
+ }
93
+ /**
94
+ * Result of sending events.
95
+ */
96
+ export interface SendEventsResult {
97
+ /** Job ID for tracking async processing */
98
+ jobId: string;
99
+ }
100
+ /**
101
+ * Individual event result from job completion.
102
+ */
103
+ export interface EventResult {
104
+ /** Allocated internal ID */
105
+ allocatedId: string;
106
+ /** External event ID */
107
+ externalId: string;
108
+ }
109
+ /**
110
+ * Job status response.
111
+ */
112
+ export interface JobStatus {
113
+ id: string;
114
+ state: 'waiting' | 'active' | 'completed' | 'failed';
115
+ returnValue?: {
116
+ status: 'success' | 'error';
117
+ results: EventResult[];
118
+ };
119
+ processedOn?: string | null;
120
+ }
121
+ /**
122
+ * Stored Caliper event (from list/get).
123
+ *
124
+ * This represents an event as returned by the API, which differs from the
125
+ * input CaliperEvent format. The API adds internal fields and transforms
126
+ * the original event ID to `externalId`.
127
+ *
128
+ * @remarks
129
+ * **API Docs Drift**: The official OpenAPI spec (caliper-api.yaml) does not
130
+ * accurately document this response structure. This type was derived from
131
+ * actual API responses. Key differences:
132
+ * - `id` is a number (internal DB ID), not a string
133
+ * - `externalId` contains the original URN UUID (use this for `get()` calls)
134
+ * - Response is wrapped in `{ events: StoredEvent[] }` for list, `{ event: StoredEvent }` for get
135
+ */
136
+ export interface StoredEvent {
137
+ /** Internal numeric ID (allocated by the database) */
138
+ id: number;
139
+ /** Original event ID (URN UUID format) - use this for get() calls */
140
+ externalId: string;
141
+ /** Sensor that sent the event */
142
+ sensor: string;
143
+ /** Event type (e.g., 'ActivityEvent', 'Event') */
144
+ type: string;
145
+ /** Caliper profile (e.g., 'TimebackProfile') */
146
+ profile?: string;
147
+ /** The action or predicate */
148
+ action: string;
149
+ /** When the event occurred */
150
+ eventTime: string;
151
+ /** When the event was sent */
152
+ sendTime: string;
153
+ /** When the record was last updated */
154
+ updated_at: string | null;
155
+ /** When the record was created */
156
+ created_at: string;
157
+ /** When the record was deleted (soft delete) */
158
+ deleted_at: string | null;
159
+ /** The agent who initiated the event */
160
+ actor: CaliperEntity;
161
+ /** The object of the event */
162
+ object: CaliperEntity;
163
+ /** Generated entity (e.g., result, score) */
164
+ generated?: CaliperEntity | null;
165
+ /** Target entity */
166
+ target?: CaliperEntity | null;
167
+ /** Referrer entity */
168
+ referrer?: CaliperEntity | null;
169
+ /** EdApp entity */
170
+ edApp?: CaliperEntity | null;
171
+ /** Group/organization entity */
172
+ group?: CaliperEntity | null;
173
+ /** Membership entity */
174
+ membership?: CaliperEntity | null;
175
+ /** Session entity */
176
+ session?: CaliperEntity | null;
177
+ /** Federated session entity */
178
+ federatedSession?: CaliperEntity | null;
179
+ /** Extension data */
180
+ extensions?: Record<string, unknown> | null;
181
+ /** Client application ID */
182
+ clientAppId?: string | null;
183
+ }
184
+ /**
185
+ * Parameters for listing events.
186
+ */
187
+ export interface ListEventsParams {
188
+ limit?: number;
189
+ offset?: number;
190
+ sensor?: string;
191
+ startDate?: string;
192
+ endDate?: string;
193
+ actorId?: string;
194
+ actorEmail?: string;
195
+ }
196
+ /**
197
+ * Result from listing events.
198
+ */
199
+ export interface ListEventsResult {
200
+ events: StoredEvent[];
201
+ pagination: PaginationMeta;
202
+ }
203
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C;;GAEG;AACH,MAAM,MAAM,cAAc,GACvB,mBAAmB,GACnB,mBAAmB,GACnB,gBAAgB,GAChB,gBAAgB,GAChB,iBAAiB,GACjB,cAAc,GACd,eAAe,GACf,2BAA2B,GAC3B,cAAc,GACd,mBAAmB,GACnB,gBAAgB,GAChB,gBAAgB,GAChB,gBAAgB,GAChB,eAAe,GACf,mBAAmB,GACnB,iBAAiB,CAAA;AAEpB;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAA;AAE/D;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC5B,qCAAqC;IACrC,EAAE,EAAE,MAAM,CAAA;IACV,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAA;IACZ,qDAAqD;IACrD,UAAU,EAAE;QACX,mDAAmD;QACnD,KAAK,EAAE,MAAM,CAAA;QACb,sCAAsC;QACtC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KACtB,CAAA;CACD;AAED;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC5B,sBAAsB;IACtB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,0C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,KAAK,CAAC,EAAE,aAAa,GAAG,IAAI,CAAA;IAC5B,gCAAgC;IAChC,KAAK,CAAC,EAAE,aAAa,GAAG,IAAI,CAAA;IAC5B,wBAAwB;IACxB,UAAU,CAAC,EAAE,aAAa,GAAG,IAAI,CAAA;IACjC,qBAAqB;IACrB,OAAO,CAAC,EAAE,aAAa,GAAG,IAAI,CAAA;IAC9B,+BAA+B;IAC/B,gBAAgB,CAAC,EAAE,aAAa,GAAG,IAAI,CAAA;IACvC,qBAAqB;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;IAC3C,4BAA4B;IAC5B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC,MAAM,EAAE,WAAW,EAAE,CAAA;IACrB,UAAU,EAAE,cAAc,CAAA;CAC1B"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Caliper Types
3
+ *
4
+ * Type definitions for the Caliper client.
5
+ */
6
+ export * from './api';
7
+ export * from './client';
8
+ export * from './events';
9
+ export * from './timeback';
10
+ export { CALIPER_DATA_VERSION } from '../constants';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,OAAO,CAAA;AACrB,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAE1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA"}
@@ -0,0 +1,395 @@
1
+ /**
2
+ * Timeback Profile Types
3
+ *
4
+ * First-class types for the Timeback Caliper profile, including
5
+ * ActivityCompletedEvent and TimeSpentEvent.
6
+ */
7
+ import type { CALIPER_DATA_VERSION } from '../constants';
8
+ /**
9
+ * User role in the Timeback platform.
10
+ */
11
+ export type TimebackUserRole = 'student' | 'teacher' | 'admin' | 'guide';
12
+ /**
13
+ * Timeback user entity.
14
+ *
15
+ * Represents a user in the Timeback platform. The `id` should ideally be
16
+ * the OneRoster URL for the user when available.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * const user: TimebackUser = {
21
+ * id: 'https://api.alpha-1edtech.ai/ims/oneroster/rostering/v1p2/users/123',
22
+ * type: 'TimebackUser',
23
+ * email: 'student@example.edu',
24
+ * name: 'Jane Doe',
25
+ * role: 'student',
26
+ * }
27
+ * ```
28
+ */
29
+ export interface TimebackUser {
30
+ /** User identifier (IRI format, preferably OneRoster URL) */
31
+ id: string;
32
+ /** Must be 'TimebackUser' */
33
+ type: 'TimebackUser';
34
+ /** User email address */
35
+ email: string;
36
+ /** User display name */
37
+ name?: string;
38
+ /** User role */
39
+ role?: TimebackUserRole;
40
+ /** Additional custom attributes */
41
+ extensions?: Record<string, unknown>;
42
+ /** Index signature for Caliper compatibility */
43
+ [key: string]: unknown;
44
+ }
45
+ /**
46
+ * Subject areas supported by the Timeback platform.
47
+ */
48
+ export type TimebackSubject = 'Reading' | 'Language' | 'Vocabulary' | 'Social Studies' | 'Writing' | 'Science' | 'FastMath' | 'Math' | 'None' | 'Other';
49
+ /**
50
+ * Application reference within activity context.
51
+ */
52
+ export interface TimebackApp {
53
+ /** Application identifier (IRI format) */
54
+ id?: string;
55
+ /** Application name */
56
+ name: string;
57
+ /** Additional custom attributes */
58
+ extensions?: Record<string, unknown>;
59
+ }
60
+ /**
61
+ * Course reference within activity context.
62
+ */
63
+ export interface TimebackCourse {
64
+ /** Course identifier (IRI format, preferably OneRoster URL) */
65
+ id?: string;
66
+ /** Course name */
67
+ name: string;
68
+ /** Additional custom attributes */
69
+ extensions?: Record<string, unknown>;
70
+ }
71
+ /**
72
+ * Activity reference within activity context.
73
+ */
74
+ export interface TimebackActivity {
75
+ /** Activity identifier (IRI format) */
76
+ id?: string;
77
+ /** Activity name */
78
+ name: string;
79
+ /** Additional custom attributes */
80
+ extensions?: Record<string, unknown>;
81
+ }
82
+ /**
83
+ * Timeback activity context.
84
+ *
85
+ * Represents the context where an event was recorded, including
86
+ * subject, application, course, and activity information.
87
+ *
88
+ * @example
89
+ * ```typescript
90
+ * const context: TimebackActivityContext = {
91
+ * id: 'https://myapp.example.com/activities/123',
92
+ * type: 'TimebackActivityContext',
93
+ * subject: 'Math',
94
+ * app: { name: 'My Learning App' },
95
+ * course: { name: 'Algebra 101' },
96
+ * activity: { name: 'Chapter 1 Quiz' },
97
+ * }
98
+ * ```
99
+ */
100
+ export interface TimebackActivityContext {
101
+ /** Context identifier (IRI format) */
102
+ id: string;
103
+ /** Must be 'TimebackActivityContext' */
104
+ type: 'TimebackActivityContext';
105
+ /** Subject area */
106
+ subject: TimebackSubject;
107
+ /** Application where event was recorded */
108
+ app: TimebackApp;
109
+ /** Course where event was recorded */
110
+ course?: TimebackCourse;
111
+ /** Activity where event was recorded */
112
+ activity?: TimebackActivity;
113
+ /** Whether to process this event */
114
+ process?: boolean;
115
+ /** Index signature for Caliper compatibility */
116
+ [key: string]: unknown;
117
+ }
118
+ /**
119
+ * Types of activity metrics.
120
+ */
121
+ export type ActivityMetricType = 'xpEarned' | 'totalQuestions' | 'correctQuestions' | 'masteredUnits';
122
+ /**
123
+ * Individual activity metric.
124
+ *
125
+ * @example
126
+ * ```typescript
127
+ * const metric: TimebackActivityMetric = {
128
+ * type: 'correctQuestions',
129
+ * value: 8,
130
+ * }
131
+ * ```
132
+ */
133
+ export interface TimebackActivityMetric {
134
+ /** Metric type */
135
+ type: ActivityMetricType;
136
+ /** Metric value */
137
+ value: number;
138
+ /** Additional custom attributes */
139
+ extensions?: Record<string, unknown>;
140
+ }
141
+ /**
142
+ * Collection of activity metrics.
143
+ *
144
+ * @example
145
+ * ```typescript
146
+ * const metrics: TimebackActivityMetricsCollection = {
147
+ * id: 'https://myapp.example.com/metrics/123',
148
+ * type: 'TimebackActivityMetricsCollection',
149
+ * items: [
150
+ * { type: 'totalQuestions', value: 10 },
151
+ * { type: 'correctQuestions', value: 8 },
152
+ * { type: 'xpEarned', value: 150 },
153
+ * ],
154
+ * }
155
+ * ```
156
+ */
157
+ export interface TimebackActivityMetricsCollection {
158
+ /** Collection identifier (IRI format) */
159
+ id: string;
160
+ /** Must be 'TimebackActivityMetricsCollection' */
161
+ type: 'TimebackActivityMetricsCollection';
162
+ /** Array of metrics */
163
+ items: TimebackActivityMetric[];
164
+ /** Additional custom attributes */
165
+ extensions?: Record<string, unknown>;
166
+ /** Index signature for Caliper compatibility */
167
+ [key: string]: unknown;
168
+ }
169
+ /**
170
+ * Types of time spent metrics.
171
+ */
172
+ export type TimeSpentMetricType = 'active' | 'inactive' | 'waste' | 'unknown' | 'anti-pattern';
173
+ /**
174
+ * Individual time spent metric.
175
+ *
176
+ * @example
177
+ * ```typescript
178
+ * const metric: TimeSpentMetric = {
179
+ * type: 'active',
180
+ * value: 1800, // 30 minutes in seconds
181
+ * startDate: '2024-01-15T10:00:00Z',
182
+ * endDate: '2024-01-15T10:30:00Z',
183
+ * }
184
+ * ```
185
+ */
186
+ export interface TimeSpentMetric {
187
+ /** Metric type */
188
+ type: TimeSpentMetricType;
189
+ /** Time spent in seconds (max 86400 = 24 hours) */
190
+ value: number;
191
+ /** Sub-type for additional categorization */
192
+ subType?: string;
193
+ /** Start of the time period */
194
+ startDate?: string;
195
+ /** End of the time period */
196
+ endDate?: string;
197
+ /** Additional custom attributes */
198
+ extensions?: Record<string, unknown>;
199
+ }
200
+ /**
201
+ * Collection of time spent metrics.
202
+ *
203
+ * @example
204
+ * ```typescript
205
+ * const metrics: TimebackTimeSpentMetricsCollection = {
206
+ * id: 'https://myapp.example.com/time-metrics/123',
207
+ * type: 'TimebackTimeSpentMetricsCollection',
208
+ * items: [
209
+ * { type: 'active', value: 1800 },
210
+ * { type: 'inactive', value: 300 },
211
+ * ],
212
+ * }
213
+ * ```
214
+ */
215
+ export interface TimebackTimeSpentMetricsCollection {
216
+ /** Collection identifier (IRI format) */
217
+ id: string;
218
+ /** Must be 'TimebackTimeSpentMetricsCollection' */
219
+ type: 'TimebackTimeSpentMetricsCollection';
220
+ /** Array of time spent metrics */
221
+ items: TimeSpentMetric[];
222
+ /** Additional custom attributes */
223
+ extensions?: Record<string, unknown>;
224
+ /** Index signature for Caliper compatibility */
225
+ [key: string]: unknown;
226
+ }
227
+ /**
228
+ * Base properties common to all Timeback events.
229
+ */
230
+ interface TimebackEventBase {
231
+ /** JSON-LD context */
232
+ '@context': typeof CALIPER_DATA_VERSION;
233
+ /** Unique identifier (URN UUID format) */
234
+ id: string;
235
+ /** The user who performed the action */
236
+ actor: TimebackUser;
237
+ /** The activity context */
238
+ object: TimebackActivityContext;
239
+ /** ISO 8601 datetime when event occurred */
240
+ eventTime: string;
241
+ /** Must be 'TimebackProfile' */
242
+ profile: 'TimebackProfile';
243
+ /** Application context (IRI or entity) */
244
+ edApp?: string | Record<string, unknown>;
245
+ /** Target segment within object */
246
+ target?: string | Record<string, unknown>;
247
+ /** Referring context */
248
+ referrer?: string | Record<string, unknown>;
249
+ /** Organization/group context */
250
+ group?: string | Record<string, unknown>;
251
+ /** User's membership/role */
252
+ membership?: string | Record<string, unknown>;
253
+ /** Current user session */
254
+ session?: string | Record<string, unknown>;
255
+ /** LTI session context */
256
+ federatedSession?: string | Record<string, unknown>;
257
+ /** Additional custom attributes */
258
+ extensions?: Record<string, unknown>;
259
+ }
260
+ /**
261
+ * Timeback Activity Completed Event.
262
+ *
263
+ * Records when a student completes an activity, along with performance metrics.
264
+ *
265
+ * @example
266
+ * ```typescript
267
+ * const event: ActivityCompletedEvent = {
268
+ * '@context': 'http://purl.imsglobal.org/ctx/caliper/v1p2',
269
+ * id: 'urn:uuid:c51570e4-f8ed-4c18-bb3a-dfe51b2cc594',
270
+ * type: 'ActivityEvent',
271
+ * action: 'Completed',
272
+ * actor: {
273
+ * id: 'https://api.example.com/users/123',
274
+ * type: 'TimebackUser',
275
+ * email: 'student@example.edu',
276
+ * },
277
+ * object: {
278
+ * id: 'https://myapp.example.com/activities/456',
279
+ * type: 'TimebackActivityContext',
280
+ * subject: 'Math',
281
+ * app: { name: 'My Learning App' },
282
+ * },
283
+ * eventTime: '2024-01-15T14:30:00Z',
284
+ * profile: 'TimebackProfile',
285
+ * generated: {
286
+ * id: 'https://myapp.example.com/metrics/789',
287
+ * type: 'TimebackActivityMetricsCollection',
288
+ * items: [
289
+ * { type: 'totalQuestions', value: 10 },
290
+ * { type: 'correctQuestions', value: 8 },
291
+ * ],
292
+ * },
293
+ * }
294
+ * ```
295
+ */
296
+ export interface ActivityCompletedEvent extends TimebackEventBase {
297
+ /** Must be 'ActivityEvent' */
298
+ type: 'ActivityEvent';
299
+ /** Must be 'Completed' */
300
+ action: 'Completed';
301
+ /** Activity metrics generated from this completion */
302
+ generated: TimebackActivityMetricsCollection;
303
+ }
304
+ /**
305
+ * Timeback Time Spent Event.
306
+ *
307
+ * Records time spent on an activity, categorized by engagement type.
308
+ *
309
+ * @example
310
+ * ```typescript
311
+ * const event: TimeSpentEvent = {
312
+ * '@context': 'http://purl.imsglobal.org/ctx/caliper/v1p2',
313
+ * id: 'urn:uuid:d62681f5-g9fe-5d29-cc4b-efg62c3dd695',
314
+ * type: 'TimeSpentEvent',
315
+ * action: 'SpentTime',
316
+ * actor: {
317
+ * id: 'https://api.example.com/users/123',
318
+ * type: 'TimebackUser',
319
+ * email: 'student@example.edu',
320
+ * },
321
+ * object: {
322
+ * id: 'https://myapp.example.com/activities/456',
323
+ * type: 'TimebackActivityContext',
324
+ * subject: 'Reading',
325
+ * app: { name: 'My Learning App' },
326
+ * },
327
+ * eventTime: '2024-01-15T15:00:00Z',
328
+ * profile: 'TimebackProfile',
329
+ * generated: {
330
+ * id: 'https://myapp.example.com/time-metrics/789',
331
+ * type: 'TimebackTimeSpentMetricsCollection',
332
+ * items: [
333
+ * { type: 'active', value: 1800 },
334
+ * { type: 'inactive', value: 300 },
335
+ * ],
336
+ * },
337
+ * }
338
+ * ```
339
+ */
340
+ export interface TimeSpentEvent extends TimebackEventBase {
341
+ /** Must be 'TimeSpentEvent' */
342
+ type: 'TimeSpentEvent';
343
+ /** Must be 'SpentTime' */
344
+ action: 'SpentTime';
345
+ /** Time spent metrics generated from this session */
346
+ generated: TimebackTimeSpentMetricsCollection;
347
+ }
348
+ /**
349
+ * Union of all Timeback event types.
350
+ */
351
+ export type TimebackEvent = ActivityCompletedEvent | TimeSpentEvent;
352
+ /**
353
+ * Input for creating an ActivityCompletedEvent.
354
+ *
355
+ * Omits fields that are auto-generated (id, eventTime, @context, profile).
356
+ */
357
+ export interface ActivityCompletedInput {
358
+ /** The user who completed the activity */
359
+ actor: TimebackUser;
360
+ /** The activity context */
361
+ object: TimebackActivityContext;
362
+ /** Activity metrics */
363
+ metrics: TimebackActivityMetric[];
364
+ /** Optional: Event time (defaults to now) */
365
+ eventTime?: string;
366
+ /** Optional: Metrics collection ID (auto-generated if not provided) */
367
+ metricsId?: string;
368
+ /** Optional: Event ID (auto-generated if not provided) */
369
+ id?: string;
370
+ /** Optional: Additional custom attributes */
371
+ extensions?: Record<string, unknown>;
372
+ }
373
+ /**
374
+ * Input for creating a TimeSpentEvent.
375
+ *
376
+ * Omits fields that are auto-generated (id, eventTime, @context, profile).
377
+ */
378
+ export interface TimeSpentInput {
379
+ /** The user who spent time */
380
+ actor: TimebackUser;
381
+ /** The activity context */
382
+ object: TimebackActivityContext;
383
+ /** Time spent metrics */
384
+ metrics: TimeSpentMetric[];
385
+ /** Optional: Event time (defaults to now) */
386
+ eventTime?: string;
387
+ /** Optional: Metrics collection ID (auto-generated if not provided) */
388
+ metricsId?: string;
389
+ /** Optional: Event ID (auto-generated if not provided) */
390
+ id?: string;
391
+ /** Optional: Additional custom attributes */
392
+ extensions?: Record<string, unknown>;
393
+ }
394
+ export {};
395
+ //# sourceMappingURL=timeback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timeback.d.ts","sourceRoot":"","sources":["../../src/types/timeback.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAMxD;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,CAAA;AAExE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,YAAY;IAC5B,6DAA6D;IAC7D,EAAE,EAAE,MAAM,CAAA;IACV,6BAA6B;IAC7B,IAAI,EAAE,cAAc,CAAA;IACpB,yBAAyB;IACzB,KAAK,EAAE,MAAM,CAAA;IACb,wBAAwB;IACxB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,gBAAgB;IAChB,IAAI,CAAC,EAAE,gBAAgB,CAAA;IACvB,mCAAmC;IACnC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACpC,gDAAgD;IAChD,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACtB;AAMD;;GAEG;AACH,MAAM,MAAM,eAAe,GACxB,SAAS,GACT,UAAU,GACV,YAAY,GACZ,gBAAgB,GAChB,SAAS,GACT,SAAS,GACT,UAAU,GACV,MAAM,GACN,MAAM,GACN,OAAO,CAAA;AAEV;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B,0CAA0C;IAC1C,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,mCAAmC;IACnC,UAAU,CAAC,EAA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0 +1,7 @@
1
+ /**
2
+ * Caliper Types (subpath export)
3
+ *
4
+ * Re-exports all types for the ./types subpath.
5
+ */
6
+ export * from './types/index';
7
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,eAAe,CAAA"}