timeback-studio 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.
- package/README.md +51 -0
- package/dist/bin.js +21905 -0
- package/dist/cli/commands/credentials/add.d.ts +7 -0
- package/dist/cli/commands/credentials/add.d.ts.map +1 -0
- package/dist/cli/commands/credentials/email.d.ts +7 -0
- package/dist/cli/commands/credentials/email.d.ts.map +1 -0
- package/dist/cli/commands/credentials/index.d.ts +8 -0
- package/dist/cli/commands/credentials/index.d.ts.map +1 -0
- package/dist/cli/commands/credentials/lib/index.d.ts +3 -0
- package/dist/cli/commands/credentials/lib/index.d.ts.map +1 -0
- package/dist/cli/commands/credentials/lib/initial.d.ts +7 -0
- package/dist/cli/commands/credentials/lib/initial.d.ts.map +1 -0
- package/dist/cli/commands/credentials/lib/types.d.ts +11 -0
- package/dist/cli/commands/credentials/lib/types.d.ts.map +1 -0
- package/dist/cli/commands/credentials/list.d.ts +7 -0
- package/dist/cli/commands/credentials/list.d.ts.map +1 -0
- package/dist/cli/commands/credentials/menu.d.ts +7 -0
- package/dist/cli/commands/credentials/menu.d.ts.map +1 -0
- package/dist/cli/commands/credentials/remove.d.ts +7 -0
- package/dist/cli/commands/credentials/remove.d.ts.map +1 -0
- package/dist/cli/commands/serve/config.d.ts +57 -0
- package/dist/cli/commands/serve/config.d.ts.map +1 -0
- package/dist/cli/commands/serve/index.d.ts +19 -0
- package/dist/cli/commands/serve/index.d.ts.map +1 -0
- package/dist/cli/commands/serve/server.d.ts +12 -0
- package/dist/cli/commands/serve/server.d.ts.map +1 -0
- package/dist/cli/commands/serve/types.d.ts +16 -0
- package/dist/cli/commands/serve/types.d.ts.map +1 -0
- package/dist/cli/lib/courses.d.ts +17 -0
- package/dist/cli/lib/courses.d.ts.map +1 -0
- package/dist/cli/lib/credentials.d.ts +35 -0
- package/dist/cli/lib/credentials.d.ts.map +1 -0
- package/dist/cli/lib/index.d.ts +6 -0
- package/dist/cli/lib/index.d.ts.map +1 -0
- package/dist/cli/lib/onboarding/import.d.ts +23 -0
- package/dist/cli/lib/onboarding/import.d.ts.map +1 -0
- package/dist/cli/lib/onboarding/index.d.ts +27 -0
- package/dist/cli/lib/onboarding/index.d.ts.map +1 -0
- package/dist/cli/lib/onboarding/types.d.ts +18 -0
- package/dist/cli/lib/onboarding/types.d.ts.map +1 -0
- package/dist/cli/lib/terminal.d.ts +6 -0
- package/dist/cli/lib/terminal.d.ts.map +1 -0
- package/dist/config/constants.d.ts +60 -0
- package/dist/config/constants.d.ts.map +1 -0
- package/dist/config/index.d.ts +6 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/timeback.d.ts +31 -0
- package/dist/config/timeback.d.ts.map +1 -0
- package/dist/config/types.d.ts +59 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/utils.d.ts +12 -0
- package/dist/config/utils.d.ts.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19787 -0
- package/dist/server/app.d.ts +9 -0
- package/dist/server/app.d.ts.map +1 -0
- package/dist/server/controllers/bootstrap.d.ts +619 -0
- package/dist/server/controllers/bootstrap.d.ts.map +1 -0
- package/dist/server/controllers/enrollment.d.ts +98 -0
- package/dist/server/controllers/enrollment.d.ts.map +1 -0
- package/dist/server/controllers/events.d.ts +82 -0
- package/dist/server/controllers/events.d.ts.map +1 -0
- package/dist/server/controllers/index.d.ts +7 -0
- package/dist/server/controllers/index.d.ts.map +1 -0
- package/dist/server/controllers/live.d.ts +22 -0
- package/dist/server/controllers/live.d.ts.map +1 -0
- package/dist/server/controllers/status.d.ts +95 -0
- package/dist/server/controllers/status.d.ts.map +1 -0
- package/dist/server/controllers/student-search.d.ts +39 -0
- package/dist/server/controllers/student-search.d.ts.map +1 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/lib/context.d.ts +15 -0
- package/dist/server/lib/context.d.ts.map +1 -0
- package/dist/server/lib/errors.d.ts +40 -0
- package/dist/server/lib/errors.d.ts.map +1 -0
- package/dist/server/lib/index.d.ts +8 -0
- package/dist/server/lib/index.d.ts.map +1 -0
- package/dist/server/lib/manager.d.ts +10 -0
- package/dist/server/lib/manager.d.ts.map +1 -0
- package/dist/server/lib/middleware.d.ts +23 -0
- package/dist/server/lib/middleware.d.ts.map +1 -0
- package/dist/server/lib/request.d.ts +19 -0
- package/dist/server/lib/request.d.ts.map +1 -0
- package/dist/server/lib/sse.d.ts +26 -0
- package/dist/server/lib/sse.d.ts.map +1 -0
- package/dist/server/lib/types.d.ts +64 -0
- package/dist/server/lib/types.d.ts.map +1 -0
- package/dist/server/services/bootstrap.d.ts +38 -0
- package/dist/server/services/bootstrap.d.ts.map +1 -0
- package/dist/server/services/enrollment.d.ts +54 -0
- package/dist/server/services/enrollment.d.ts.map +1 -0
- package/dist/server/services/events.d.ts +50 -0
- package/dist/server/services/events.d.ts.map +1 -0
- package/dist/server/services/index.d.ts +13 -0
- package/dist/server/services/index.d.ts.map +1 -0
- package/dist/server/services/live.d.ts +83 -0
- package/dist/server/services/live.d.ts.map +1 -0
- package/dist/server/services/status.d.ts +24 -0
- package/dist/server/services/status.d.ts.map +1 -0
- package/dist/server/services/student-search.d.ts +32 -0
- package/dist/server/services/student-search.d.ts.map +1 -0
- package/dist/server/services/types/bootstrap.d.ts +47 -0
- package/dist/server/services/types/bootstrap.d.ts.map +1 -0
- package/dist/server/services/types/enrollment.d.ts +26 -0
- package/dist/server/services/types/enrollment.d.ts.map +1 -0
- package/dist/server/services/types/events.d.ts +22 -0
- package/dist/server/services/types/events.d.ts.map +1 -0
- package/dist/server/services/types/index.d.ts +11 -0
- package/dist/server/services/types/index.d.ts.map +1 -0
- package/dist/server/services/types/live.d.ts +34 -0
- package/dist/server/services/types/live.d.ts.map +1 -0
- package/dist/server/services/types/student-search.d.ts +31 -0
- package/dist/server/services/types/student-search.d.ts.map +1 -0
- package/dist/types.d.ts +83 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +0 -0
- package/package.json +47 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bootstrap Service
|
|
3
|
+
*
|
|
4
|
+
* Business logic for bootstrapping Studio with user and course data.
|
|
5
|
+
*/
|
|
6
|
+
import type { TimebackClient } from '@timeback/core';
|
|
7
|
+
import type { BootstrapResult, GetBootstrapOptions } from './types';
|
|
8
|
+
/**
|
|
9
|
+
* Service for bootstrapping Studio with initial data.
|
|
10
|
+
*
|
|
11
|
+
* Fetches user, courses, components, classes, enrollments, and resources.
|
|
12
|
+
*/
|
|
13
|
+
export declare class BootstrapService {
|
|
14
|
+
private readonly client;
|
|
15
|
+
constructor(client: TimebackClient);
|
|
16
|
+
/**
|
|
17
|
+
* Get bootstrap data.
|
|
18
|
+
*
|
|
19
|
+
* @param options - Bootstrap options (email, courseIds)
|
|
20
|
+
* @returns User, courses, components, classes, enrollments, and errors
|
|
21
|
+
*/
|
|
22
|
+
getBootstrap(options: GetBootstrapOptions): Promise<BootstrapResult>;
|
|
23
|
+
/**
|
|
24
|
+
* Compute stats from enrollment data.
|
|
25
|
+
*
|
|
26
|
+
* @param enrollmentData - Enrollment data with unique IDs
|
|
27
|
+
* @param courses - All courses
|
|
28
|
+
* @returns Aggregate stats
|
|
29
|
+
*/
|
|
30
|
+
private computeStats;
|
|
31
|
+
private fetchCourseStructure;
|
|
32
|
+
private enrichEnrollmentsWithUsers;
|
|
33
|
+
private fetchResources;
|
|
34
|
+
private fetchCourses;
|
|
35
|
+
private fetchCurrentUser;
|
|
36
|
+
private fetchEnrollments;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=bootstrap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../../src/server/services/bootstrap.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAUH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAGpD,OAAO,KAAK,EACX,eAAe,EAIf,mBAAmB,EACnB,MAAM,SAAS,CAAA;AAyBhB;;;;GAIG;AACH,qBAAa,gBAAgB;IAC5B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;IAEvC,YAAY,MAAM,EAAE,cAAc,EAEjC;IAED;;;;;OAKG;IACG,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,eAAe,CAAC,CA8CzE;IAMD;;;;;;OAMG;IACH,OAAO,CAAC,YAAY;YAkBN,oBAAoB;YAoEpB,0BAA0B;YAuC1B,cAAc;YA0Cd,YAAY;YAgCZ,gBAAgB;YAyBhB,gBAAgB;CAuD9B"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enrollment Service
|
|
3
|
+
*
|
|
4
|
+
* Business logic for enrolling and unenrolling students.
|
|
5
|
+
*/
|
|
6
|
+
import type { TimebackClient } from '@timeback/core';
|
|
7
|
+
import type { EnrollmentActionOptions, EnrollmentResult, EnrollStudentOptions } from './types';
|
|
8
|
+
/**
|
|
9
|
+
* Service for managing student enrollments.
|
|
10
|
+
*
|
|
11
|
+
* Handles enrolling, unenrolling, and reactivating students in classes.
|
|
12
|
+
*/
|
|
13
|
+
export declare class EnrollmentService {
|
|
14
|
+
private readonly client;
|
|
15
|
+
constructor(client: TimebackClient);
|
|
16
|
+
/**
|
|
17
|
+
* Enroll a student in a class.
|
|
18
|
+
*
|
|
19
|
+
* Creates a new enrollment linking the student to the specified class.
|
|
20
|
+
*
|
|
21
|
+
* @param options - Enrollment options (classId, userId)
|
|
22
|
+
* @returns Result with enrollment ID or errors
|
|
23
|
+
*/
|
|
24
|
+
enroll(options: EnrollStudentOptions): Promise<EnrollmentResult>;
|
|
25
|
+
/**
|
|
26
|
+
* Unenroll a student from a class.
|
|
27
|
+
*
|
|
28
|
+
* Marks the enrollment as 'tobedeleted'.
|
|
29
|
+
*
|
|
30
|
+
* @param options - Unenrollment options (enrollmentId)
|
|
31
|
+
* @returns Result indicating success or errors
|
|
32
|
+
*/
|
|
33
|
+
unenroll(options: EnrollmentActionOptions): Promise<EnrollmentResult>;
|
|
34
|
+
/**
|
|
35
|
+
* Reactivate a student enrollment.
|
|
36
|
+
*
|
|
37
|
+
* Marks the enrollment as 'active'.
|
|
38
|
+
*
|
|
39
|
+
* @param options - Reactivation options (enrollmentId)
|
|
40
|
+
* @returns Result indicating success or errors
|
|
41
|
+
*/
|
|
42
|
+
reactivate(options: EnrollmentActionOptions): Promise<EnrollmentResult>;
|
|
43
|
+
/**
|
|
44
|
+
* Handle enrollment operation errors consistently.
|
|
45
|
+
*
|
|
46
|
+
* @param error - The caught error
|
|
47
|
+
* @param operation - Name of the operation for logging
|
|
48
|
+
* @param context - Context data for logging
|
|
49
|
+
* @param errors - Error array to push to
|
|
50
|
+
* @returns Failure result
|
|
51
|
+
*/
|
|
52
|
+
private handleEnrollmentError;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=enrollment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enrollment.d.ts","sourceRoot":"","sources":["../../../src/server/services/enrollment.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,OAAO,KAAK,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAI9F;;;;GAIG;AACH,qBAAa,iBAAiB;IAC7B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;IAEvC,YAAY,MAAM,EAAE,cAAc,EAEjC;IAED;;;;;;;OAOG;IACG,MAAM,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CA0BrE;IAED;;;;;;;OAOG;IACG,QAAQ,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAqB1E;IAED;;;;;;;OAOG;IACG,UAAU,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAqB5E;IAED;;;;;;;;OAQG;IACH,OAAO,CAAC,qBAAqB;CAuB7B"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Events Service
|
|
3
|
+
*
|
|
4
|
+
* Business logic for fetching Caliper events (Activity and Time Spent).
|
|
5
|
+
*/
|
|
6
|
+
import type { TimebackClient } from '@timeback/core';
|
|
7
|
+
import type { Caliper } from '@timeback/core/types';
|
|
8
|
+
import type { GetNewEventsOptions, GetRecentEventsOptions } from './types';
|
|
9
|
+
/**
|
|
10
|
+
* Service for fetching and managing Caliper events.
|
|
11
|
+
*
|
|
12
|
+
* Handles delta sync, backward pagination, and real-time polling.
|
|
13
|
+
*/
|
|
14
|
+
export declare class EventsService {
|
|
15
|
+
private readonly client;
|
|
16
|
+
private readonly sensors;
|
|
17
|
+
constructor(client: TimebackClient, sensors?: string[]);
|
|
18
|
+
/**
|
|
19
|
+
* Fetch recent events, optionally filtered by timestamp.
|
|
20
|
+
*
|
|
21
|
+
* Supports two pagination modes:
|
|
22
|
+
* - `since`: Delta sync - paginates to catch up on ALL events after this timestamp
|
|
23
|
+
* - `before`: Backward pagination - fetch events BEFORE this timestamp (for older events)
|
|
24
|
+
*
|
|
25
|
+
* Delta sync uses large batch limits and paginates until caught up, capped at syncMaxTotal.
|
|
26
|
+
*
|
|
27
|
+
* @param options - Fetch options (limit, since, before)
|
|
28
|
+
* @returns Array of stored events
|
|
29
|
+
*/
|
|
30
|
+
getRecent(options?: GetRecentEventsOptions): Promise<Caliper.StoredEvent[]>;
|
|
31
|
+
/**
|
|
32
|
+
* Fetch new events since a given timestamp.
|
|
33
|
+
*
|
|
34
|
+
* Used for polling to get events that occurred after the last fetch.
|
|
35
|
+
*
|
|
36
|
+
* @param options - Fetch options (since)
|
|
37
|
+
* @returns Array of new events
|
|
38
|
+
*/
|
|
39
|
+
getNew(options: GetNewEventsOptions): Promise<Caliper.StoredEvent[]>;
|
|
40
|
+
/**
|
|
41
|
+
* Deduplicate events by id and sort by eventTime descending.
|
|
42
|
+
*
|
|
43
|
+
* @param events - Array of events (may contain duplicates)
|
|
44
|
+
* @returns Deduplicated and sorted events
|
|
45
|
+
*/
|
|
46
|
+
private dedupeAndSort;
|
|
47
|
+
private fetchEvents;
|
|
48
|
+
private fetchEventsSince;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../src/server/services/events.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAUH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,KAAK,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAa1E;;;;GAIG;AACH,qBAAa,aAAa;IACzB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;IACvC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAsB;IAE9C,YAAY,MAAM,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,EAGrD;IAMD;;;;;;;;;;;OAWG;IACG,SAAS,CAAC,OAAO,GAAE,sBAA2B,GAAG,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAqCpF;IAED;;;;;;;OAOG;IACG,MAAM,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAiBzE;IAMD;;;;;OAKG;IACH,OAAO,CAAC,aAAa;YAwBP,WAAW;YA4BX,gBAAgB;CA+C9B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Services Index
|
|
3
|
+
*
|
|
4
|
+
* Exports all service classes and their types.
|
|
5
|
+
*/
|
|
6
|
+
export { BootstrapService } from './bootstrap';
|
|
7
|
+
export { EnrollmentService } from './enrollment';
|
|
8
|
+
export { EventsService } from './events';
|
|
9
|
+
export { LiveService } from './live';
|
|
10
|
+
export { StatusService } from './status';
|
|
11
|
+
export { StudentSearchService } from './student-search';
|
|
12
|
+
export type { BootstrapResult, BootstrapStats, EnrichedComponentResource, EnrichedEnrollment, GetBootstrapOptions, EnrollmentActionOptions, EnrollmentResult, EnrollStudentOptions, GetNewEventsOptions, GetRecentEventsOptions, TickResult, TickState, SearchStudentsOptions, StudentSearchResponse, StudentSearchResult, } from './types';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/services/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAMvD,YAAY,EAEX,eAAe,EACf,cAAc,EACd,yBAAyB,EACzB,kBAAkB,EAClB,mBAAmB,EAEnB,uBAAuB,EACvB,gBAAgB,EAChB,oBAAoB,EAEpB,mBAAmB,EACnB,sBAAsB,EAEtB,UAAU,EACV,SAAS,EAET,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,GACnB,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Live Service
|
|
3
|
+
*
|
|
4
|
+
* Orchestrates multiple data sources for the multiplexed /api/live SSE endpoint.
|
|
5
|
+
*
|
|
6
|
+
* ## How It Works
|
|
7
|
+
*
|
|
8
|
+
* The SSE connection ticks every 1 second (base interval). On each tick,
|
|
9
|
+
* this service decides what to check based on each data source's rules:
|
|
10
|
+
*
|
|
11
|
+
* ```
|
|
12
|
+
* runSSE setInterval(1s)
|
|
13
|
+
* => every tick, calls liveService.tick(state)
|
|
14
|
+
*
|
|
15
|
+
* liveService.tick():
|
|
16
|
+
* => ALWAYS fetch status, but only emit if hash changed
|
|
17
|
+
* => Check if 30s elapsed since lastEventsTick:
|
|
18
|
+
* - YES: fetch events, emit if any new
|
|
19
|
+
* - NO: skip events entirely
|
|
20
|
+
*
|
|
21
|
+
* => return { updates: [...], newState }
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* ## Data Sources
|
|
25
|
+
*
|
|
26
|
+
* | Source | Check Frequency | Emit Condition |
|
|
27
|
+
* |---------|-----------------|---------------------|
|
|
28
|
+
* | Status | Every tick (1s) | Payload hash changed |
|
|
29
|
+
* | Events | Every 30s | New events exist |
|
|
30
|
+
*
|
|
31
|
+
* This means 29 out of 30 ticks only check status. The 30th tick checks both.
|
|
32
|
+
*/
|
|
33
|
+
import type { EventsService } from './events';
|
|
34
|
+
import type { StatusService } from './status';
|
|
35
|
+
import type { TickResult, TickState } from './types';
|
|
36
|
+
/**
|
|
37
|
+
* Options for creating a LiveService.
|
|
38
|
+
*/
|
|
39
|
+
interface LiveServiceOptions {
|
|
40
|
+
statusService: StatusService;
|
|
41
|
+
eventsService: EventsService;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Service that orchestrates status and event updates for the multiplexed SSE endpoint.
|
|
45
|
+
*
|
|
46
|
+
* Each SSE connection gets its own instance. The service manages independent tick
|
|
47
|
+
* intervals: status is checked every tick (1s) but only emitted on hash change,
|
|
48
|
+
* while events are fetched every 30s and emitted when new events exist.
|
|
49
|
+
*/
|
|
50
|
+
export declare class LiveService {
|
|
51
|
+
private readonly statusService;
|
|
52
|
+
private readonly eventsService;
|
|
53
|
+
constructor(options: LiveServiceOptions);
|
|
54
|
+
/**
|
|
55
|
+
* Create initial tick state for a new SSE connection.
|
|
56
|
+
*
|
|
57
|
+
* @returns Fresh tick state with empty hash and current timestamps
|
|
58
|
+
*/
|
|
59
|
+
static createInitialState(): TickState;
|
|
60
|
+
/**
|
|
61
|
+
* Perform a tick operation.
|
|
62
|
+
*
|
|
63
|
+
* Called every base tick (1s) by the SSE loop. Checks each data source
|
|
64
|
+
* according to its rules and returns any updates to emit.
|
|
65
|
+
*
|
|
66
|
+
* @param state - Current tick state from previous tick
|
|
67
|
+
* @returns Updates to emit and new state for next tick
|
|
68
|
+
*/
|
|
69
|
+
tick(state: TickState): Promise<TickResult>;
|
|
70
|
+
/**
|
|
71
|
+
* Check if enough time has passed since the last check.
|
|
72
|
+
*
|
|
73
|
+
* @param lastTick - Timestamp (ms) of last check
|
|
74
|
+
* @param now - Current timestamp (ms)
|
|
75
|
+
* @param intervalMs - Required interval between checks
|
|
76
|
+
* @returns True if interval has elapsed
|
|
77
|
+
*/
|
|
78
|
+
private hasIntervalElapsed;
|
|
79
|
+
private fetchStatusIfChanged;
|
|
80
|
+
private fetchEventsIfNew;
|
|
81
|
+
}
|
|
82
|
+
export {};
|
|
83
|
+
//# sourceMappingURL=live.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"live.d.ts","sourceRoot":"","sources":["../../../src/server/services/live.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAYH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAIpD;;GAEG;AACH,UAAU,kBAAkB;IAC3B,aAAa,EAAE,aAAa,CAAA;IAC5B,aAAa,EAAE,aAAa,CAAA;CAC5B;AAED;;;;;;GAMG;AACH,qBAAa,WAAW;IACvB,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAe;IAC7C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAe;IAE7C,YAAY,OAAO,EAAE,kBAAkB,EAGtC;IAED;;;;OAIG;IACH,MAAM,CAAC,kBAAkB,IAAI,SAAS,CAQrC;IAED;;;;;;;;OAQG;IACG,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAoChD;IAED;;;;;;;OAOG;IACH,OAAO,CAAC,kBAAkB;YAUZ,oBAAoB;YA4BpB,gBAAgB;CAiC9B"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Status Service
|
|
3
|
+
*
|
|
4
|
+
* Business logic for server status and configuration.
|
|
5
|
+
*/
|
|
6
|
+
import type { AppContext } from '../../config';
|
|
7
|
+
import type { StatusEventPayload } from '../../types';
|
|
8
|
+
/**
|
|
9
|
+
* Service for server status and configuration.
|
|
10
|
+
*
|
|
11
|
+
* Note: This service uses AppContext rather than TimebackClient,
|
|
12
|
+
* so it's instantiated separately from other services.
|
|
13
|
+
*/
|
|
14
|
+
export declare class StatusService {
|
|
15
|
+
private readonly ctx;
|
|
16
|
+
constructor(ctx: AppContext);
|
|
17
|
+
/**
|
|
18
|
+
* Build the status payload.
|
|
19
|
+
*
|
|
20
|
+
* @returns Status payload object
|
|
21
|
+
*/
|
|
22
|
+
getStatus(): Promise<StatusEventPayload>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/server/services/status.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAErD;;;;;GAKG;AACH,qBAAa,aAAa;IACzB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAY;IAEhC,YAAY,GAAG,EAAE,UAAU,EAE1B;IAED;;;;GAIE;IACI,SAAS,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAU7C;CACD"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Student Search Service
|
|
3
|
+
*
|
|
4
|
+
* Business logic for searching students globally.
|
|
5
|
+
*/
|
|
6
|
+
import type { TimebackClient } from '@timeback/core';
|
|
7
|
+
import type { SearchStudentsOptions, StudentSearchResponse } from './types';
|
|
8
|
+
/**
|
|
9
|
+
* Service for searching students.
|
|
10
|
+
*/
|
|
11
|
+
export declare class StudentSearchService {
|
|
12
|
+
private readonly client;
|
|
13
|
+
constructor(client: TimebackClient);
|
|
14
|
+
/**
|
|
15
|
+
* Search students by name or email.
|
|
16
|
+
*
|
|
17
|
+
* Uses the `search` parameter which performs free-text search across
|
|
18
|
+
* givenName, familyName, and email fields.
|
|
19
|
+
*
|
|
20
|
+
* @param options - Search options (query, max)
|
|
21
|
+
* @returns Matching students and any errors
|
|
22
|
+
*/
|
|
23
|
+
search(options: SearchStudentsOptions): Promise<StudentSearchResponse>;
|
|
24
|
+
/**
|
|
25
|
+
* Transform OneRoster User to simplified StudentSearchResult.
|
|
26
|
+
*
|
|
27
|
+
* @param user - OneRoster user object
|
|
28
|
+
* @returns Simplified student result
|
|
29
|
+
*/
|
|
30
|
+
private toSearchResult;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=student-search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"student-search.d.ts","sourceRoot":"","sources":["../../../src/server/services/student-search.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAGpD,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAuB,MAAM,SAAS,CAAA;AAIhG;;GAEG;AACH,qBAAa,oBAAoB;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;IAEvC,YAAY,MAAM,EAAE,cAAc,EAEjC;IAED;;;;;;;;OAQG;IACG,MAAM,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAwC3E;IAED;;;;;OAKG;IACH,OAAO,CAAC,cAAc;CAUtB"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bootstrap Service Types
|
|
3
|
+
*/
|
|
4
|
+
import type { OneRoster } from '@timeback/core/types';
|
|
5
|
+
import type { StudioError } from '../../lib';
|
|
6
|
+
/**
|
|
7
|
+
* Enrollment with embedded user details.
|
|
8
|
+
*/
|
|
9
|
+
export interface EnrichedEnrollment extends OneRoster.Enrollment {
|
|
10
|
+
userDetails?: OneRoster.User;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* ComponentResource with embedded resource details.
|
|
14
|
+
*/
|
|
15
|
+
export interface EnrichedComponentResource extends OneRoster.ComponentResource {
|
|
16
|
+
resourceDetails?: OneRoster.Resource;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Bootstrap statistics.
|
|
20
|
+
*/
|
|
21
|
+
export interface BootstrapStats {
|
|
22
|
+
totalStudents: number;
|
|
23
|
+
totalTeachers: number;
|
|
24
|
+
totalCourses: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Options for getting bootstrap data.
|
|
28
|
+
*/
|
|
29
|
+
export interface GetBootstrapOptions {
|
|
30
|
+
email?: string;
|
|
31
|
+
courseIds: string[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Result of bootstrap data fetch.
|
|
35
|
+
*/
|
|
36
|
+
export interface BootstrapResult {
|
|
37
|
+
user: OneRoster.User | null;
|
|
38
|
+
courses: OneRoster.Course[];
|
|
39
|
+
components: OneRoster.CourseComponent[];
|
|
40
|
+
componentResources: EnrichedComponentResource[];
|
|
41
|
+
classes: OneRoster.Class[];
|
|
42
|
+
enrollments: EnrichedEnrollment[];
|
|
43
|
+
classEnrollmentCounts: Record<string, number>;
|
|
44
|
+
stats: BootstrapStats;
|
|
45
|
+
errors: StudioError[];
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=bootstrap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../../../src/server/services/types/bootstrap.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAE5C;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,SAAS,CAAC,UAAU;IAC/D,WAAW,CAAC,EAAE,SAAS,CAAC,IAAI,CAAA;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,yBAA0B,SAAQ,SAAS,CAAC,iBAAiB;IAC7E,eAAe,CAAC,EAAE,SAAS,CAAC,QAAQ,CAAA;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;IACrB,YAAY,EAAE,MAAM,CAAA;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,EAAE,CAAA;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B,IAAI,EAAE,SAAS,CAAC,IAAI,GAAG,IAAI,CAAA;IAC3B,OAAO,EAAE,SAAS,CAAC,MAAM,EAAE,CAAA;IAC3B,UAAU,EAAE,SAAS,CAAC,eAAe,EAAE,CAAA;IACvC,kBAAkB,EAAE,yBAAyB,EAAE,CAAA;IAC/C,OAAO,EAAE,SAAS,CAAC,KAAK,EAAE,CAAA;IAC1B,WAAW,EAAE,kBAAkB,EAAE,CAAA;IACjC,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC7C,KAAK,EAAE,cAAc,CAAA;IACrB,MAAM,EAAE,WAAW,EAAE,CAAA;CACrB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enrollment Service Types
|
|
3
|
+
*/
|
|
4
|
+
import type { StudioError } from '../../lib';
|
|
5
|
+
/**
|
|
6
|
+
* Result of an enrollment operation.
|
|
7
|
+
*/
|
|
8
|
+
export interface EnrollmentResult {
|
|
9
|
+
success: boolean;
|
|
10
|
+
enrollmentId?: string;
|
|
11
|
+
errors: StudioError[];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Options for enrolling a student.
|
|
15
|
+
*/
|
|
16
|
+
export interface EnrollStudentOptions {
|
|
17
|
+
classId: string;
|
|
18
|
+
userId: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Options for unenrolling or reactivating a student.
|
|
22
|
+
*/
|
|
23
|
+
export interface EnrollmentActionOptions {
|
|
24
|
+
enrollmentId: string;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=enrollment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enrollment.d.ts","sourceRoot":"","sources":["../../../../src/server/services/types/enrollment.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAE5C;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC,OAAO,EAAE,OAAO,CAAA;IAChB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,MAAM,EAAE,WAAW,EAAE,CAAA;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;CACd;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACvC,YAAY,EAAE,MAAM,CAAA;CACpB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Events Service Types
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Options for fetching recent events.
|
|
6
|
+
*/
|
|
7
|
+
export interface GetRecentEventsOptions {
|
|
8
|
+
/** Maximum number of events to fetch */
|
|
9
|
+
limit?: number;
|
|
10
|
+
/** Only fetch events after this ISO timestamp (delta sync) */
|
|
11
|
+
since?: string;
|
|
12
|
+
/** Only fetch events before this ISO timestamp (pagination for older events) */
|
|
13
|
+
before?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Options for fetching new events (polling).
|
|
17
|
+
*/
|
|
18
|
+
export interface GetNewEventsOptions {
|
|
19
|
+
/** ISO timestamp to fetch events after */
|
|
20
|
+
since: string;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../../src/server/services/types/events.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,8DAA8D;IAC9D,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,gFAAgF;IAChF,MAAM,CAAC,EAAE,MAAM,CAAA;CACf;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAA;CACb"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Service Types
|
|
3
|
+
*
|
|
4
|
+
* Barrel file for all service type exports.
|
|
5
|
+
*/
|
|
6
|
+
export type { BootstrapResult, BootstrapStats, EnrichedComponentResource, EnrichedEnrollment, GetBootstrapOptions, } from './bootstrap';
|
|
7
|
+
export type { EnrollmentActionOptions, EnrollmentResult, EnrollStudentOptions } from './enrollment';
|
|
8
|
+
export type { GetNewEventsOptions, GetRecentEventsOptions } from './events';
|
|
9
|
+
export type { SearchStudentsOptions, StudentSearchResponse, StudentSearchResult, } from './student-search';
|
|
10
|
+
export type { TickResult, TickState } from './live';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/server/services/types/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,EACX,eAAe,EACf,cAAc,EACd,yBAAyB,EACzB,kBAAkB,EAClB,mBAAmB,GACnB,MAAM,aAAa,CAAA;AAEpB,YAAY,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAEnG,YAAY,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAE3E,YAAY,EACX,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,GACnB,MAAM,kBAAkB,CAAA;AAEzB,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Live Service Types
|
|
3
|
+
*
|
|
4
|
+
* Types for the multiplexed SSE endpoint that combines status and events.
|
|
5
|
+
*/
|
|
6
|
+
import type { LiveUpdate } from '../../../types';
|
|
7
|
+
/**
|
|
8
|
+
* Per-connection state for tracking when to check each data source.
|
|
9
|
+
*
|
|
10
|
+
* Each SSE connection maintains its own TickState. The LiveService uses
|
|
11
|
+
* this state to determine:
|
|
12
|
+
* - Status: Has the payload hash changed since last emit?
|
|
13
|
+
* - Events: Has 30s elapsed since last check?
|
|
14
|
+
*/
|
|
15
|
+
export interface TickState {
|
|
16
|
+
/** Hash of last emitted status payload. Empty string on first tick. */
|
|
17
|
+
lastStatusHash: string;
|
|
18
|
+
/** Timestamp (ms) of last status check. Used for diagnostics. */
|
|
19
|
+
lastStatusTick: number;
|
|
20
|
+
/** ISO timestamp of most recent event. Used as cursor for "since" queries. */
|
|
21
|
+
lastEventTime: string;
|
|
22
|
+
/** Timestamp (ms) of last events check. Used to enforce 30s interval. */
|
|
23
|
+
lastEventsTick: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Result of a tick operation.
|
|
27
|
+
*/
|
|
28
|
+
export interface TickResult {
|
|
29
|
+
/** Updates to emit to the client (may be empty if nothing changed) */
|
|
30
|
+
updates: LiveUpdate[];
|
|
31
|
+
/** Updated state to pass to the next tick */
|
|
32
|
+
newState: TickState;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=live.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"live.d.ts","sourceRoot":"","sources":["../../../../src/server/services/types/live.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAEhD;;;;;;;GAOG;AACH,MAAM,WAAW,SAAS;IAKzB,uEAAuE;IACvE,cAAc,EAAE,MAAM,CAAA;IAEtB,iEAAiE;IACjE,cAAc,EAAE,MAAM,CAAA;IAMtB,8EAA8E;IAC9E,aAAa,EAAE,MAAM,CAAA;IAErB,yEAAyE;IACzE,cAAc,EAAE,MAAM,CAAA;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,sEAAsE;IACtE,OAAO,EAAE,UAAU,EAAE,CAAA;IAErB,6CAA6C;IAC7C,QAAQ,EAAE,SAAS,CAAA;CACnB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Student Search Service Types
|
|
3
|
+
*/
|
|
4
|
+
import type { StudioError } from '../../lib';
|
|
5
|
+
/**
|
|
6
|
+
* Simplified student search result.
|
|
7
|
+
*/
|
|
8
|
+
export interface StudentSearchResult {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
email: string;
|
|
12
|
+
givenName: string;
|
|
13
|
+
familyName: string;
|
|
14
|
+
grades: string[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Options for searching students.
|
|
18
|
+
*/
|
|
19
|
+
export interface SearchStudentsOptions {
|
|
20
|
+
query: string;
|
|
21
|
+
/** Maximum total results to return */
|
|
22
|
+
max?: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Result of a student search.
|
|
26
|
+
*/
|
|
27
|
+
export interface StudentSearchResponse {
|
|
28
|
+
students: StudentSearchResult[];
|
|
29
|
+
errors: StudioError[];
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=student-search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"student-search.d.ts","sourceRoot":"","sources":["../../../../src/server/services/types/student-search.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAE5C;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,MAAM,EAAE,CAAA;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACrC,KAAK,EAAE,MAAM,CAAA;IACb,sCAAsC;IACtC,GAAG,CAAC,EAAE,MAAM,CAAA;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACrC,QAAQ,EAAE,mBAAmB,EAAE,CAAA;IAC/B,MAAM,EAAE,WAAW,EAAE,CAAA;CACrB"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Studio Shared Types
|
|
3
|
+
*
|
|
4
|
+
* Shared type definitions for server and client.
|
|
5
|
+
* Used by both server (packages/studio) and client (apps/studio).
|
|
6
|
+
*/
|
|
7
|
+
import type { Caliper } from '@timeback/core/types';
|
|
8
|
+
import type { LoadedUserConfig, StudioEnvironment } from './config/types';
|
|
9
|
+
export type { StudioEnvironment } from './config/types';
|
|
10
|
+
export type { LoadedUserConfig as StudioConfig } from './config/types';
|
|
11
|
+
/**
|
|
12
|
+
* Standard error codes for Studio API.
|
|
13
|
+
*/
|
|
14
|
+
export type StudioErrorCode = 'USER_FETCH_FAILED' | 'USERS_FETCH_FAILED' | 'COURSE_FETCH_FAILED' | 'COMPONENTS_FETCH_FAILED' | 'COMPONENT_RESOURCES_FETCH_FAILED' | 'RESOURCES_FETCH_FAILED' | 'CLASSES_FETCH_FAILED' | 'ANALYTICS_FETCH_FAILED' | 'ENV_NOT_CONFIGURED' | 'ENV_INVALID' | 'ENROLLMENT_FAILED' | 'UNENROLLMENT_FAILED' | 'UNKNOWN_ERROR';
|
|
15
|
+
/**
|
|
16
|
+
* Serializable error in Studio API responses.
|
|
17
|
+
*
|
|
18
|
+
* Not to be confused with `ApiError` from `@timeback/internal-client-infra`,
|
|
19
|
+
* which is a throwable Error class for HTTP failures.
|
|
20
|
+
*/
|
|
21
|
+
export interface StudioError {
|
|
22
|
+
/** Error code for programmatic handling */
|
|
23
|
+
code: StudioErrorCode;
|
|
24
|
+
/** Human-readable message */
|
|
25
|
+
message: string;
|
|
26
|
+
/** Additional context (e.g., IDs, field names) */
|
|
27
|
+
details?: Record<string, unknown>;
|
|
28
|
+
}
|
|
29
|
+
/** Payload for 'status' events */
|
|
30
|
+
export interface StatusEventPayload {
|
|
31
|
+
config: LoadedUserConfig;
|
|
32
|
+
environment: StudioEnvironment;
|
|
33
|
+
configuredEnvironments: StudioEnvironment[];
|
|
34
|
+
hasEmail: boolean;
|
|
35
|
+
}
|
|
36
|
+
/** Payload for 'events' SSE events (Caliper events stream) */
|
|
37
|
+
export interface EventsEventPayload {
|
|
38
|
+
/** New events since last poll */
|
|
39
|
+
events: Caliper.StoredEvent[];
|
|
40
|
+
/** Timestamp of this payload for client-side deduplication */
|
|
41
|
+
timestamp: string;
|
|
42
|
+
}
|
|
43
|
+
/** Types of updates that can be sent via the multiplexed /api/live endpoint */
|
|
44
|
+
export type LiveUpdateType = 'status' | 'events';
|
|
45
|
+
/** Status update wrapper for live endpoint */
|
|
46
|
+
export interface LiveStatusUpdate {
|
|
47
|
+
type: 'status';
|
|
48
|
+
data: StatusEventPayload;
|
|
49
|
+
}
|
|
50
|
+
/** Events update wrapper for live endpoint */
|
|
51
|
+
export interface LiveEventsUpdate {
|
|
52
|
+
type: 'events';
|
|
53
|
+
data: EventsEventPayload;
|
|
54
|
+
}
|
|
55
|
+
/** Union of all live update types */
|
|
56
|
+
export type LiveUpdate = LiveStatusUpdate | LiveEventsUpdate;
|
|
57
|
+
/**
|
|
58
|
+
* Map of SSE event names to their payload types.
|
|
59
|
+
*
|
|
60
|
+
* Add new events here as the API grows.
|
|
61
|
+
*/
|
|
62
|
+
export interface StudioEventMap {
|
|
63
|
+
status: StatusEventPayload;
|
|
64
|
+
events: EventsEventPayload;
|
|
65
|
+
live: LiveUpdate[];
|
|
66
|
+
}
|
|
67
|
+
/** Union of all valid SSE event names */
|
|
68
|
+
export type StudioEventName = keyof StudioEventMap;
|
|
69
|
+
/**
|
|
70
|
+
* Event handlers for a subset of studio events.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* const handlers: StudioEventHandlers<'status' | 'enrollment'> = {
|
|
75
|
+
* status: (data) => setStatus(data),
|
|
76
|
+
* enrollment: (data) => handleEnrollment(data),
|
|
77
|
+
* }
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export type StudioEventHandlers<K extends StudioEventName = StudioEventName> = {
|
|
81
|
+
[E in K]?: (data: StudioEventMap[E]) => void;
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAGzE,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AACvD,YAAY,EAAE,gBAAgB,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAMtE;;GAEG;AACH,MAAM,MAAM,eAAe,GAExB,mBAAmB,GACnB,oBAAoB,GACpB,qBAAqB,GACrB,yBAAyB,GACzB,kCAAkC,GAClC,wBAAwB,GACxB,sBAAsB,GACtB,wBAAwB,GAExB,oBAAoB,GACpB,aAAa,GAEb,mBAAmB,GACnB,qBAAqB,GAErB,eAAe,CAAA;AAElB;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC3B,2CAA2C;IAC3C,IAAI,EAAE,eAAe,CAAA;IACrB,6BAA6B;IAC7B,OAAO,EAAE,MAAM,CAAA;IACf,kDAAkD;IAClD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACjC;AAMD,kCAAkC;AAClC,MAAM,WAAW,kBAAkB;IAClC,MAAM,EAAE,gBAAgB,CAAA;IACxB,WAAW,EAAE,iBAAiB,CAAA;IAC9B,sBAAsB,EAAE,iBAAiB,EAAE,CAAA;IAC3C,QAAQ,EAAE,OAAO,CAAA;CACjB;AAED,8DAA8D;AAC9D,MAAM,WAAW,kBAAkB;IAClC,iCAAiC;IACjC,MAAM,EAAE,OAAO,CAAC,WAAW,EAAE,CAAA;IAC7B,8DAA8D;IAC9D,SAAS,EAAE,MAAM,CAAA;CACjB;AAMD,+EAA+E;AAC/E,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAEhD,8CAA8C;AAC9C,MAAM,WAAW,gBAAgB;IAChC,IAAI,EAAE,QAAQ,CAAA;IACd,IAAI,EAAE,kBAAkB,CAAA;CACxB;AAED,8CAA8C;AAC9C,MAAM,WAAW,gBAAgB;IAChC,IAAI,EAAE,QAAQ,CAAA;IACd,IAAI,EAAE,kBAAkB,CAAA;CACxB;AAED,qCAAqC;AACrC,MAAM,MAAM,UAAU,GAAG,gBAAgB,GAAG,gBAAgB,CAAA;AAM5D;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC9B,MAAM,EAAE,kBAAkB,CAAA;IAC1B,MAAM,EAAE,kBAAkB,CAAA;IAC1B,IAAI,EAAE,UAAU,EAAE,CAAA;CAClB;AAED,yCAAyC;AACzC,MAAM,MAAM,eAAe,GAAG,MAAM,cAAc,CAAA;AAMlD;;;;;;;;;;GAUG;AACH,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,eAAe,GAAG,eAAe,IAAI;KAC7E,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,KAAK,IAAI;CAC5C,CAAA"}
|
package/dist/types.js
ADDED
|
File without changes
|