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.
Files changed (119) hide show
  1. package/README.md +51 -0
  2. package/dist/bin.js +21905 -0
  3. package/dist/cli/commands/credentials/add.d.ts +7 -0
  4. package/dist/cli/commands/credentials/add.d.ts.map +1 -0
  5. package/dist/cli/commands/credentials/email.d.ts +7 -0
  6. package/dist/cli/commands/credentials/email.d.ts.map +1 -0
  7. package/dist/cli/commands/credentials/index.d.ts +8 -0
  8. package/dist/cli/commands/credentials/index.d.ts.map +1 -0
  9. package/dist/cli/commands/credentials/lib/index.d.ts +3 -0
  10. package/dist/cli/commands/credentials/lib/index.d.ts.map +1 -0
  11. package/dist/cli/commands/credentials/lib/initial.d.ts +7 -0
  12. package/dist/cli/commands/credentials/lib/initial.d.ts.map +1 -0
  13. package/dist/cli/commands/credentials/lib/types.d.ts +11 -0
  14. package/dist/cli/commands/credentials/lib/types.d.ts.map +1 -0
  15. package/dist/cli/commands/credentials/list.d.ts +7 -0
  16. package/dist/cli/commands/credentials/list.d.ts.map +1 -0
  17. package/dist/cli/commands/credentials/menu.d.ts +7 -0
  18. package/dist/cli/commands/credentials/menu.d.ts.map +1 -0
  19. package/dist/cli/commands/credentials/remove.d.ts +7 -0
  20. package/dist/cli/commands/credentials/remove.d.ts.map +1 -0
  21. package/dist/cli/commands/serve/config.d.ts +57 -0
  22. package/dist/cli/commands/serve/config.d.ts.map +1 -0
  23. package/dist/cli/commands/serve/index.d.ts +19 -0
  24. package/dist/cli/commands/serve/index.d.ts.map +1 -0
  25. package/dist/cli/commands/serve/server.d.ts +12 -0
  26. package/dist/cli/commands/serve/server.d.ts.map +1 -0
  27. package/dist/cli/commands/serve/types.d.ts +16 -0
  28. package/dist/cli/commands/serve/types.d.ts.map +1 -0
  29. package/dist/cli/lib/courses.d.ts +17 -0
  30. package/dist/cli/lib/courses.d.ts.map +1 -0
  31. package/dist/cli/lib/credentials.d.ts +35 -0
  32. package/dist/cli/lib/credentials.d.ts.map +1 -0
  33. package/dist/cli/lib/index.d.ts +6 -0
  34. package/dist/cli/lib/index.d.ts.map +1 -0
  35. package/dist/cli/lib/onboarding/import.d.ts +23 -0
  36. package/dist/cli/lib/onboarding/import.d.ts.map +1 -0
  37. package/dist/cli/lib/onboarding/index.d.ts +27 -0
  38. package/dist/cli/lib/onboarding/index.d.ts.map +1 -0
  39. package/dist/cli/lib/onboarding/types.d.ts +18 -0
  40. package/dist/cli/lib/onboarding/types.d.ts.map +1 -0
  41. package/dist/cli/lib/terminal.d.ts +6 -0
  42. package/dist/cli/lib/terminal.d.ts.map +1 -0
  43. package/dist/config/constants.d.ts +60 -0
  44. package/dist/config/constants.d.ts.map +1 -0
  45. package/dist/config/index.d.ts +6 -0
  46. package/dist/config/index.d.ts.map +1 -0
  47. package/dist/config/timeback.d.ts +31 -0
  48. package/dist/config/timeback.d.ts.map +1 -0
  49. package/dist/config/types.d.ts +59 -0
  50. package/dist/config/types.d.ts.map +1 -0
  51. package/dist/config/utils.d.ts +12 -0
  52. package/dist/config/utils.d.ts.map +1 -0
  53. package/dist/index.d.ts +9 -0
  54. package/dist/index.d.ts.map +1 -0
  55. package/dist/index.js +19787 -0
  56. package/dist/server/app.d.ts +9 -0
  57. package/dist/server/app.d.ts.map +1 -0
  58. package/dist/server/controllers/bootstrap.d.ts +619 -0
  59. package/dist/server/controllers/bootstrap.d.ts.map +1 -0
  60. package/dist/server/controllers/enrollment.d.ts +98 -0
  61. package/dist/server/controllers/enrollment.d.ts.map +1 -0
  62. package/dist/server/controllers/events.d.ts +82 -0
  63. package/dist/server/controllers/events.d.ts.map +1 -0
  64. package/dist/server/controllers/index.d.ts +7 -0
  65. package/dist/server/controllers/index.d.ts.map +1 -0
  66. package/dist/server/controllers/live.d.ts +22 -0
  67. package/dist/server/controllers/live.d.ts.map +1 -0
  68. package/dist/server/controllers/status.d.ts +95 -0
  69. package/dist/server/controllers/status.d.ts.map +1 -0
  70. package/dist/server/controllers/student-search.d.ts +39 -0
  71. package/dist/server/controllers/student-search.d.ts.map +1 -0
  72. package/dist/server/index.d.ts +2 -0
  73. package/dist/server/index.d.ts.map +1 -0
  74. package/dist/server/lib/context.d.ts +15 -0
  75. package/dist/server/lib/context.d.ts.map +1 -0
  76. package/dist/server/lib/errors.d.ts +40 -0
  77. package/dist/server/lib/errors.d.ts.map +1 -0
  78. package/dist/server/lib/index.d.ts +8 -0
  79. package/dist/server/lib/index.d.ts.map +1 -0
  80. package/dist/server/lib/manager.d.ts +10 -0
  81. package/dist/server/lib/manager.d.ts.map +1 -0
  82. package/dist/server/lib/middleware.d.ts +23 -0
  83. package/dist/server/lib/middleware.d.ts.map +1 -0
  84. package/dist/server/lib/request.d.ts +19 -0
  85. package/dist/server/lib/request.d.ts.map +1 -0
  86. package/dist/server/lib/sse.d.ts +26 -0
  87. package/dist/server/lib/sse.d.ts.map +1 -0
  88. package/dist/server/lib/types.d.ts +64 -0
  89. package/dist/server/lib/types.d.ts.map +1 -0
  90. package/dist/server/services/bootstrap.d.ts +38 -0
  91. package/dist/server/services/bootstrap.d.ts.map +1 -0
  92. package/dist/server/services/enrollment.d.ts +54 -0
  93. package/dist/server/services/enrollment.d.ts.map +1 -0
  94. package/dist/server/services/events.d.ts +50 -0
  95. package/dist/server/services/events.d.ts.map +1 -0
  96. package/dist/server/services/index.d.ts +13 -0
  97. package/dist/server/services/index.d.ts.map +1 -0
  98. package/dist/server/services/live.d.ts +83 -0
  99. package/dist/server/services/live.d.ts.map +1 -0
  100. package/dist/server/services/status.d.ts +24 -0
  101. package/dist/server/services/status.d.ts.map +1 -0
  102. package/dist/server/services/student-search.d.ts +32 -0
  103. package/dist/server/services/student-search.d.ts.map +1 -0
  104. package/dist/server/services/types/bootstrap.d.ts +47 -0
  105. package/dist/server/services/types/bootstrap.d.ts.map +1 -0
  106. package/dist/server/services/types/enrollment.d.ts +26 -0
  107. package/dist/server/services/types/enrollment.d.ts.map +1 -0
  108. package/dist/server/services/types/events.d.ts +22 -0
  109. package/dist/server/services/types/events.d.ts.map +1 -0
  110. package/dist/server/services/types/index.d.ts +11 -0
  111. package/dist/server/services/types/index.d.ts.map +1 -0
  112. package/dist/server/services/types/live.d.ts +34 -0
  113. package/dist/server/services/types/live.d.ts.map +1 -0
  114. package/dist/server/services/types/student-search.d.ts +31 -0
  115. package/dist/server/services/types/student-search.d.ts.map +1 -0
  116. package/dist/types.d.ts +83 -0
  117. package/dist/types.d.ts.map +1 -0
  118. package/dist/types.js +0 -0
  119. package/package.json +47 -0
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Enrollment Controller
3
+ *
4
+ * HTTP endpoints for enrolling and unenrolling students.
5
+ */
6
+ import type { Context } from 'hono';
7
+ import type { EnvVariables } from '../lib';
8
+ /**
9
+ * POST /api/enrollments/enroll - Enroll a student in a class.
10
+ *
11
+ * Requires env middleware to set `client` context variable.
12
+ *
13
+ * @param c - Hono context with env variables
14
+ * @returns JSON response with enrollment result
15
+ */
16
+ export declare function handleEnroll(c: Context<{
17
+ Variables: EnvVariables;
18
+ }>): Promise<(Response & import("hono").TypedResponse<{
19
+ success: boolean;
20
+ enrollmentId?: string | undefined;
21
+ errors: {
22
+ code: import("../lib").StudioErrorCode;
23
+ message: string;
24
+ details?: {
25
+ [x: string]: import("hono/utils/types").JSONValue;
26
+ } | undefined;
27
+ }[];
28
+ }, 200 | 400, "json">) | (Response & import("hono").TypedResponse<{
29
+ success: false;
30
+ errors: {
31
+ code: import("../lib").StudioErrorCode;
32
+ message: string;
33
+ details?: {
34
+ [x: string]: import("hono/utils/types").JSONValue;
35
+ } | undefined;
36
+ }[];
37
+ }, 400, "json">)>;
38
+ /**
39
+ * POST /api/enrollments/unenroll - Unenroll a student from a class.
40
+ *
41
+ * Requires env middleware to set `client` context variable.
42
+ *
43
+ * @param c - Hono context with env variables
44
+ * @returns JSON response with unenrollment result
45
+ */
46
+ export declare function handleUnenroll(c: Context<{
47
+ Variables: EnvVariables;
48
+ }>): Promise<(Response & import("hono").TypedResponse<{
49
+ success: boolean;
50
+ enrollmentId?: string | undefined;
51
+ errors: {
52
+ code: import("../lib").StudioErrorCode;
53
+ message: string;
54
+ details?: {
55
+ [x: string]: import("hono/utils/types").JSONValue;
56
+ } | undefined;
57
+ }[];
58
+ }, 200 | 400, "json">) | (Response & import("hono").TypedResponse<{
59
+ success: false;
60
+ errors: {
61
+ code: import("../lib").StudioErrorCode;
62
+ message: string;
63
+ details?: {
64
+ [x: string]: import("hono/utils/types").JSONValue;
65
+ } | undefined;
66
+ }[];
67
+ }, 400, "json">)>;
68
+ /**
69
+ * POST /api/enrollments/reactivate - Reactivate a student enrollment.
70
+ *
71
+ * Requires env middleware to set `client` context variable.
72
+ *
73
+ * @param c - Hono context with env variables
74
+ * @returns JSON response with reactivation result
75
+ */
76
+ export declare function handleReactivate(c: Context<{
77
+ Variables: EnvVariables;
78
+ }>): Promise<(Response & import("hono").TypedResponse<{
79
+ success: boolean;
80
+ enrollmentId?: string | undefined;
81
+ errors: {
82
+ code: import("../lib").StudioErrorCode;
83
+ message: string;
84
+ details?: {
85
+ [x: string]: import("hono/utils/types").JSONValue;
86
+ } | undefined;
87
+ }[];
88
+ }, 200 | 400, "json">) | (Response & import("hono").TypedResponse<{
89
+ success: false;
90
+ errors: {
91
+ code: import("../lib").StudioErrorCode;
92
+ message: string;
93
+ details?: {
94
+ [x: string]: import("hono/utils/types").JSONValue;
95
+ } | undefined;
96
+ }[];
97
+ }, 400, "json">)>;
98
+ //# sourceMappingURL=enrollment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enrollment.d.ts","sourceRoot":"","sources":["../../../src/server/controllers/enrollment.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACnC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAa1C;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAAE,OAAO,CAAC;IAAE,SAAS,EAAE,YAAY,CAAA;CAAE,CAAC;;;;;;;;;;;;;;;;;;;kBAezE;AAED;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAAC,CAAC,EAAE,OAAO,CAAC;IAAE,SAAS,EAAE,YAAY,CAAA;CAAE,CAAC;;;;;;;;;;;;;;;;;;;kBAe3E;AAED;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EAAE,OAAO,CAAC;IAAE,SAAS,EAAE,YAAY,CAAA;CAAE,CAAC;;;;;;;;;;;;;;;;;;;kBAe7E"}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Events Controller
3
+ *
4
+ * HTTP endpoints for Caliper events (Activity and Time Spent).
5
+ * Provides both REST endpoint for initial fetch and SSE for real-time updates.
6
+ */
7
+ import type { Context } from 'hono';
8
+ import type { EnvVariables } from '../lib';
9
+ /**
10
+ * GET /api/events - Returns recent Caliper events.
11
+ *
12
+ * Query parameters:
13
+ * - `limit`: Maximum events to return (see events.fetch config)
14
+ * - `since`: Delta sync - fetch events AFTER this ISO timestamp
15
+ * - `before`: Backward pagination - fetch events BEFORE this ISO timestamp
16
+ *
17
+ * @param c - Hono context with env variables
18
+ * @returns JSON response with events array
19
+ */
20
+ export declare function handleEvents(c: Context<{
21
+ Variables: EnvVariables;
22
+ }>): Promise<Response & import("hono").TypedResponse<{
23
+ events: {
24
+ id: number;
25
+ externalId: string;
26
+ sensor: string;
27
+ type: string;
28
+ profile?: string | undefined;
29
+ action: string;
30
+ eventTime: string;
31
+ sendTime: string;
32
+ updated_at: string | null;
33
+ created_at: string;
34
+ deleted_at: string | null;
35
+ actor: string | {
36
+ [x: string]: import("hono/utils/types").JSONValue;
37
+ };
38
+ object: string | {
39
+ [x: string]: import("hono/utils/types").JSONValue;
40
+ };
41
+ generated?: string | {
42
+ [x: string]: import("hono/utils/types").JSONValue;
43
+ } | null | undefined;
44
+ target?: string | {
45
+ [x: string]: import("hono/utils/types").JSONValue;
46
+ } | null | undefined;
47
+ referrer?: string | {
48
+ [x: string]: import("hono/utils/types").JSONValue;
49
+ } | null | undefined;
50
+ edApp?: string | {
51
+ [x: string]: import("hono/utils/types").JSONValue;
52
+ } | null | undefined;
53
+ group?: string | {
54
+ [x: string]: import("hono/utils/types").JSONValue;
55
+ } | null | undefined;
56
+ membership?: string | {
57
+ [x: string]: import("hono/utils/types").JSONValue;
58
+ } | null | undefined;
59
+ session?: string | {
60
+ [x: string]: import("hono/utils/types").JSONValue;
61
+ } | null | undefined;
62
+ federatedSession?: string | {
63
+ [x: string]: import("hono/utils/types").JSONValue;
64
+ } | null | undefined;
65
+ extensions?: {
66
+ [x: string]: import("hono/utils/types").JSONValue;
67
+ } | null | undefined;
68
+ clientAppId?: string | null | undefined;
69
+ }[];
70
+ }, import("hono/utils/http-status").ContentfulStatusCode, "json">>;
71
+ /**
72
+ * GET /api/events/stream - SSE stream for real-time event updates.
73
+ *
74
+ * Polls for new events and pushes them to connected clients.
75
+ *
76
+ * @param c - Hono context with env variables
77
+ * @returns SSE stream
78
+ */
79
+ export declare function handleEventsStream(c: Context<{
80
+ Variables: EnvVariables;
81
+ }>): Response;
82
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../src/server/controllers/events.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAEnC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAiB1C;;;;;;;;;;GAUG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAAE,OAAO,CAAC;IAAE,SAAS,EAAE,YAAY,CAAA;CAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mEAYzE;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,OAAO,CAAC;IAAE,SAAS,EAAE,YAAY,CAAA;CAAE,CAAC,YAqCzE"}
@@ -0,0 +1,7 @@
1
+ export { handleBootstrap } from './bootstrap';
2
+ export { handleEnroll, handleUnenroll, handleReactivate } from './enrollment';
3
+ export { handleEvents, handleEventsStream } from './events';
4
+ export { handleLive } from './live';
5
+ export { handleStatus, handleStatusStream } from './status';
6
+ export { handleStudentSearch } from './student-search';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/controllers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC7E,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Live Controller
3
+ *
4
+ * GET /api/live - Multiplexed SSE stream combining status and events.
5
+ *
6
+ * See LiveService for detailed documentation on how tick intervals work.
7
+ */
8
+ import type { Context } from 'hono';
9
+ import type { EnvVariables } from '../lib';
10
+ /**
11
+ * GET /api/live - Multiplexed SSE stream for status and events.
12
+ *
13
+ * Combines status updates (on change) and event updates (every 30s) into
14
+ * a single SSE connection. Emits an array of LiveUpdate objects.
15
+ *
16
+ * @param c - Hono context with env variables
17
+ * @returns SSE stream
18
+ */
19
+ export declare function handleLive(c: Context<{
20
+ Variables: EnvVariables;
21
+ }>): Response;
22
+ //# sourceMappingURL=live.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"live.d.ts","sourceRoot":"","sources":["../../../src/server/controllers/live.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACnC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAE1C;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC;IAAE,SAAS,EAAE,YAAY,CAAA;CAAE,CAAC,YAqBjE"}
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Status Controller
3
+ *
4
+ * HTTP endpoints for server status and configuration.
5
+ * These routes don't require environment selection.
6
+ */
7
+ import type { Context } from 'hono';
8
+ import type { AppContext } from '../../config';
9
+ /**
10
+ * GET /api/status - Returns server status and configuration.
11
+ *
12
+ * @param c - Hono context
13
+ * @param ctx - App context
14
+ * @returns JSON response with status and configuration
15
+ */
16
+ export declare function handleStatus(c: Context, ctx: AppContext): Promise<(Response & import("hono").TypedResponse<{
17
+ config: {
18
+ name: string;
19
+ defaults?: {
20
+ courseCode?: string | undefined;
21
+ level?: string | undefined;
22
+ metadata?: {
23
+ courseType?: import("@timeback/types").CourseType | undefined;
24
+ isSupplemental?: boolean | undefined;
25
+ isCustom?: boolean | undefined;
26
+ publishStatus?: import("@timeback/types").PublishStatus | undefined;
27
+ contactEmail?: string | undefined;
28
+ primaryApp?: string | undefined;
29
+ goals?: {
30
+ dailyXp?: number | undefined;
31
+ dailyLessons?: number | undefined;
32
+ dailyActiveMinutes?: number | undefined;
33
+ dailyAccuracy?: number | undefined;
34
+ dailyMasteredUnits?: number | undefined;
35
+ } | undefined;
36
+ metrics?: {
37
+ totalXp?: number | undefined;
38
+ totalLessons?: number | undefined;
39
+ totalGrades?: number | undefined;
40
+ } | undefined;
41
+ } | undefined;
42
+ } | undefined;
43
+ courses: {
44
+ courseCode?: string | undefined;
45
+ level?: string | undefined;
46
+ metadata?: {
47
+ courseType?: import("@timeback/types").CourseType | undefined;
48
+ isSupplemental?: boolean | undefined;
49
+ isCustom?: boolean | undefined;
50
+ publishStatus?: import("@timeback/types").PublishStatus | undefined;
51
+ contactEmail?: string | undefined;
52
+ primaryApp?: string | undefined;
53
+ goals?: {
54
+ dailyXp?: number | undefined;
55
+ dailyLessons?: number | undefined;
56
+ dailyActiveMinutes?: number | undefined;
57
+ dailyAccuracy?: number | undefined;
58
+ dailyMasteredUnits?: number | undefined;
59
+ } | undefined;
60
+ metrics?: {
61
+ totalXp?: number | undefined;
62
+ totalLessons?: number | undefined;
63
+ totalGrades?: number | undefined;
64
+ } | undefined;
65
+ } | undefined;
66
+ subject: import("@timeback/types").TimebackSubject;
67
+ grade: import("@timeback/types").TimebackGrade;
68
+ ids?: {
69
+ staging?: string | undefined;
70
+ production?: string | undefined;
71
+ } | null | undefined;
72
+ }[];
73
+ sensors?: string[] | undefined;
74
+ version: string;
75
+ path: string;
76
+ courseIds: {
77
+ production: string[];
78
+ staging: string[];
79
+ };
80
+ };
81
+ environment: import("../../config").StudioEnvironment;
82
+ configuredEnvironments: import("../../config").StudioEnvironment[];
83
+ hasEmail: boolean;
84
+ }, import("hono/utils/http-status").ContentfulStatusCode, "json">) | (Response & import("hono").TypedResponse<null, 304, "body">)>;
85
+ /**
86
+ * GET /api/status/stream - SSE stream for status updates.
87
+ *
88
+ * Sends current status immediately, then pushes updates only when changed.
89
+ *
90
+ * @param c - Hono context
91
+ * @param ctx - App context
92
+ * @returns SSE stream
93
+ */
94
+ export declare function handleStatusStream(c: Context, ctx: AppContext): Response;
95
+ //# sourceMappingURL=status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/server/controllers/status.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACnC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAE9C;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mIAY7D;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,YAoB7D"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Student Search Controller
3
+ *
4
+ * Thin HTTP layer - parses request, delegates to service, returns response.
5
+ */
6
+ import type { Context } from 'hono';
7
+ import type { EnvVariables } from '../lib';
8
+ /**
9
+ * GET /api/students/search - Search students by name or email.
10
+ *
11
+ * Requires env middleware to set `env` and `client` context variables.
12
+ *
13
+ * Query parameters:
14
+ * - q: Search query (required, min 2 characters)
15
+ * - max: Maximum total results (optional, default 20, max 50)
16
+ *
17
+ * @param c - Hono context with env variables
18
+ * @returns JSON response with matching students
19
+ */
20
+ export declare function handleStudentSearch(c: Context<{
21
+ Variables: EnvVariables;
22
+ }>): Promise<Response & import("hono").TypedResponse<{
23
+ students: {
24
+ id: string;
25
+ name: string;
26
+ email: string;
27
+ givenName: string;
28
+ familyName: string;
29
+ grades: string[];
30
+ }[];
31
+ errors: {
32
+ code: import("../lib").StudioErrorCode;
33
+ message: string;
34
+ details?: {
35
+ [x: string]: import("hono/utils/types").JSONValue;
36
+ } | undefined;
37
+ }[];
38
+ }, import("hono/utils/http-status").ContentfulStatusCode, "json">>;
39
+ //# sourceMappingURL=student-search.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"student-search.d.ts","sourceRoot":"","sources":["../../../src/server/controllers/student-search.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACnC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAE1C;;;;;;;;;;;GAWG;AACH,wBAAsB,mBAAmB,CAAC,CAAC,EAAE,OAAO,CAAC;IAAE,SAAS,EAAE,YAAY,CAAA;CAAE,CAAC;;;;;;;;;;;;;;;;mEAiBhF"}
@@ -0,0 +1,2 @@
1
+ export { createApp } from './app';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Service Context
3
+ *
4
+ * Aggregates all services into a single context that can be
5
+ * injected into route handlers via middleware.
6
+ */
7
+ import type { ServiceContext, ServiceContextOptions } from './types';
8
+ /**
9
+ * Creates a service context with all services initialized.
10
+ *
11
+ * @param options - Context options
12
+ * @returns Service context with all services
13
+ */
14
+ export declare function createServiceContext(options: ServiceContextOptions): ServiceContext;
15
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/server/lib/context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH,OAAO,KAAK,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAEpE;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,cAAc,CAUnF"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Studio API Errors
3
+ *
4
+ * Standardized error handling for the Studio API.
5
+ *
6
+ * ## Error Codes
7
+ *
8
+ * Codes follow the pattern: `RESOURCE_ACTION` (e.g., `COURSE_FETCH_FAILED`)
9
+ *
10
+ * ## Usage
11
+ *
12
+ * ```typescript
13
+ * // Create an error
14
+ * const error = createStudioError('COURSE_FETCH_FAILED', 'Course not found', { courseId })
15
+ *
16
+ * // In services, collect errors
17
+ * const errors: StudioError[] = []
18
+ * errors.push(createStudioError('USER_FETCH_FAILED', 'User not found'))
19
+ *
20
+ * // Return in response
21
+ * return { data, errors }
22
+ * ```
23
+ */
24
+ import type { StudioError, StudioErrorCode } from './types';
25
+ /**
26
+ * Create a standardized Studio API error.
27
+ *
28
+ * @param code - Error code
29
+ * @param message - Human-readable message
30
+ * @param details - Optional additional context
31
+ * @returns Studio error object
32
+ */
33
+ export declare function createStudioError(code: StudioErrorCode, message: string, details?: Record<string, unknown>): StudioError;
34
+ /**
35
+ * Extract error message from an unknown error.
36
+ * @param error - Unknown error value
37
+ * @returns Error message string
38
+ */
39
+ export declare function getErrorMessage(error: unknown): string;
40
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/server/lib/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE3D;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAChC,IAAI,EAAE,eAAe,EACrB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,WAAW,CAEb;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAItD"}
@@ -0,0 +1,8 @@
1
+ export { createServiceContext } from './context';
2
+ export { createStudioError, getErrorMessage } from './errors';
3
+ export { createManager } from './manager';
4
+ export { createEnvMiddleware } from './middleware';
5
+ export { parseEnvironment } from './request';
6
+ export { hashString, runSSE } from './sse';
7
+ export type { EnvErrorResponse, EnvVariables, RunSSEOptions, ServiceContext, ServiceContextOptions, StudioError, StudioErrorCode, } from './types';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAE1C,YAAY,EACX,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,cAAc,EACd,qBAAqB,EACrB,WAAW,EACX,eAAe,GACf,MAAM,SAAS,CAAA"}
@@ -0,0 +1,10 @@
1
+ import { TimebackManager } from '@timeback/core';
2
+ import type { CredentialEnvironment } from '@timeback/internal-cli-infra';
3
+ import type { AppContext } from '../../config';
4
+ /**
5
+ * Creates a TimebackManager with clients for all configured environments.
6
+ * @param ctx - App context with credentials
7
+ * @returns Manager with registered clients
8
+ */
9
+ export declare function createManager(ctx: AppContext): TimebackManager<CredentialEnvironment>;
10
+ //# sourceMappingURL=manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../src/server/lib/manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAIhD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAA;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAI9C;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,UAAU,GAAG,eAAe,CAAC,qBAAqB,CAAC,CAmBrF"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Hono Middleware
3
+ *
4
+ * Shared middleware for route handlers.
5
+ */
6
+ import type { TimebackManager } from '@timeback/core';
7
+ import type { AppContext, Environment } from '../../config';
8
+ import type { EnvVariables } from './types';
9
+ /**
10
+ * Creates middleware that validates the X-Environment header and provides
11
+ * the Timeback client to route handlers.
12
+ *
13
+ * On success, sets `c.get('env')` and `c.get('client')` for use in handlers.
14
+ * On failure, returns a 400 response with standardized error format.
15
+ *
16
+ * @param ctx - Application context
17
+ * @param manager - Timeback manager instance
18
+ * @returns Hono middleware
19
+ */
20
+ export declare function createEnvMiddleware(ctx: AppContext, manager: TimebackManager<Environment>): import("hono").MiddlewareHandler<{
21
+ Variables: EnvVariables;
22
+ }, string, {}, Response>;
23
+ //# sourceMappingURL=middleware.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../../src/server/lib/middleware.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAUH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC3D,OAAO,KAAK,EAAoB,YAAY,EAAE,MAAM,SAAS,CAAA;AAI7D;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,eAAe,CAAC,WAAW,CAAC;;yBAgDzF"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Request Utilities
3
+ *
4
+ * Helpers for parsing and validating HTTP request data.
5
+ */
6
+ import type { Context } from 'hono';
7
+ import type { Environment } from '../../config';
8
+ /**
9
+ * Parse and validate the environment from query parameter.
10
+ *
11
+ * While passing environment via an HTTP header (e.g. `X-Environment`) would typically be more idiomatic,
12
+ * we standardize on the query param `?environment=staging|production` to support SSE endpoints,
13
+ * since SSE (EventSource) does not allow custom headers.
14
+ *
15
+ * @param c - Hono context
16
+ * @returns Valid environment or null
17
+ */
18
+ export declare function parseEnvironment(c: Context): Environment | null;
19
+ //# sourceMappingURL=request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../../src/server/lib/request.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACnC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE/C;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,OAAO,GAAG,WAAW,GAAG,IAAI,CAM/D"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * SSE (Server-Sent Events) Utilities
3
+ *
4
+ * Tick-based SSE streaming. Routes provide a `tick` function that returns
5
+ * data to send (or undefined to skip). The core handles connection lifecycle,
6
+ * heartbeats, and deduplication.
7
+ */
8
+ import type { Context } from 'hono';
9
+ import type { RunSSEOptions } from './types';
10
+ /**
11
+ * Simple hash function for change detection.
12
+ * Used by routes for ETag generation and payload comparison.
13
+ *
14
+ * @param str - String to hash
15
+ * @returns Hash as a base-36 string
16
+ */
17
+ export declare function hashString(str: string): string;
18
+ /**
19
+ * Run an SSE stream with a tick-based emission model.
20
+ *
21
+ * @param c - Hono context
22
+ * @param options - Stream options
23
+ * @returns SSE response
24
+ */
25
+ export declare function runSSE(c: Context, options: RunSSEOptions): Response;
26
+ //# sourceMappingURL=sse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sse.d.ts","sourceRoot":"","sources":["../../../src/server/lib/sse.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACnC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AA6C5C;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAQ9C;AAMD;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,YA4ExD"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Server Lib Types
3
+ */
4
+ import type { TimebackClient } from '@timeback/core';
5
+ import type { AppContext, Environment } from '../../config';
6
+ import type { StudioError } from '../../types';
7
+ import type { BootstrapService, EnrollmentService, EventsService, StatusService, StudentSearchService } from '../services';
8
+ export type { StudioError, StudioErrorCode } from '../../types';
9
+ /**
10
+ * Aggregated service context available to route handlers.
11
+ *
12
+ * Created once per request by the environment middleware.
13
+ */
14
+ export interface ServiceContext {
15
+ bootstrap: BootstrapService;
16
+ enrollment: EnrollmentService;
17
+ events: EventsService;
18
+ status: StatusService;
19
+ studentSearch: StudentSearchService;
20
+ }
21
+ /**
22
+ * Options for creating a service context.
23
+ */
24
+ export interface ServiceContextOptions {
25
+ /** Application context (for status service) */
26
+ appContext: AppContext;
27
+ /** Authenticated Timeback client */
28
+ client: TimebackClient;
29
+ /** Optional sensor URLs to scope event queries */
30
+ sensors?: string[];
31
+ }
32
+ /**
33
+ * Context variables set by the environment middleware.
34
+ */
35
+ export interface EnvVariables {
36
+ env: Environment;
37
+ client: TimebackClient;
38
+ sensors: string[] | undefined;
39
+ services: ServiceContext;
40
+ }
41
+ /**
42
+ * Standardized error response for environment validation failures.
43
+ */
44
+ export interface EnvErrorResponse {
45
+ success: false;
46
+ error: string;
47
+ errors: StudioError[];
48
+ }
49
+ /**
50
+ * Options for the tick-based SSE stream.
51
+ */
52
+ export interface RunSSEOptions {
53
+ /** Event name to emit */
54
+ event: string;
55
+ /** Interval in ms between ticks (default: SSE_CHECK_INTERVAL_MS) */
56
+ intervalMs?: number;
57
+ /** Interval in ms between heartbeats (default: SSE_HEARTBEAT_INTERVAL_MS) */
58
+ heartbeatMs?: number;
59
+ /** Whether to call tick and emit immediately on connection (default: false) */
60
+ sendInitial?: boolean;
61
+ /** Return a string to emit, or undefined to skip this tick */
62
+ tick: () => Promise<string | undefined>;
63
+ }
64
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/server/lib/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,KAAK,EACX,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,oBAAoB,EACpB,MAAM,aAAa,CAAA;AAEpB,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAM/D;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC9B,SAAS,EAAE,gBAAgB,CAAA;IAC3B,UAAU,EAAE,iBAAiB,CAAA;IAC7B,MAAM,EAAE,aAAa,CAAA;IACrB,MAAM,EAAE,aAAa,CAAA;IACrB,aAAa,EAAE,oBAAoB,CAAA;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACrC,+CAA+C;IAC/C,UAAU,EAAE,UAAU,CAAA;IACtB,oCAAoC;IACpC,MAAM,EAAE,cAAc,CAAA;IACtB,kDAAkD;IAClD,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CAClB;AAMD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,GAAG,EAAE,WAAW,CAAA;IAChB,MAAM,EAAE,cAAc,CAAA;IACtB,OAAO,EAAE,MAAM,EAAE,GAAG,SAAS,CAAA;IAC7B,QAAQ,EAAE,cAAc,CAAA;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC,OAAO,EAAE,KAAK,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,WAAW,EAAE,CAAA;CACrB;AAMD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B,yBAAyB;IACzB,KAAK,EAAE,MAAM,CAAA;IACb,oEAAoE;IACpE,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,6EAA6E;IAC7E,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,+EAA+E;IAC/E,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,8DAA8D;IAC9D,IAAI,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;CACvC"}