timeback 0.1.0 → 0.1.1

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/dist/index.js CHANGED
@@ -358,19 +358,255 @@ var SubjectTrackInput = z4.object({
358
358
  targetCourseId: z4.string(),
359
359
  metadata: z4.record(z4.string(), z4.unknown()).optional()
360
360
  });
361
+ // ../types/src/zod/qti.ts
362
+ import { z as z5 } from "zod/v4";
363
+ var QtiAssessmentItemType = z5.enum([
364
+ "choice",
365
+ "text-entry",
366
+ "extended-text",
367
+ "inline-choice",
368
+ "match",
369
+ "order",
370
+ "associate",
371
+ "select-point",
372
+ "graphic-order",
373
+ "graphic-associate",
374
+ "graphic-gap-match",
375
+ "hotspot",
376
+ "hottext",
377
+ "slider",
378
+ "drawing",
379
+ "media",
380
+ "upload"
381
+ ]);
382
+ var QtiCardinality = z5.enum(["single", "multiple", "ordered", "record"]);
383
+ var QtiBaseType = z5.enum([
384
+ "identifier",
385
+ "boolean",
386
+ "integer",
387
+ "float",
388
+ "string",
389
+ "point",
390
+ "pair",
391
+ "directedPair",
392
+ "duration",
393
+ "file",
394
+ "uri"
395
+ ]);
396
+ var QtiDifficulty = z5.enum(["easy", "medium", "hard"]);
397
+ var QtiNavigationMode = z5.enum(["linear", "nonlinear"]);
398
+ var QtiSubmissionMode = z5.enum(["individual", "simultaneous"]);
399
+ var QtiShowHide = z5.enum(["show", "hide"]);
400
+ var QtiValidationSchema = z5.enum(["test", "item", "stimulus"]);
401
+ var QtiFeedbackType = z5.enum(["QUESTION", "LESSON"]);
402
+ var QtiCorrectResponse = z5.object({
403
+ value: z5.array(z5.string())
404
+ }).strict();
405
+ var QtiResponseDeclaration = z5.object({
406
+ identifier: z5.string().min(1),
407
+ cardinality: QtiCardinality,
408
+ baseType: QtiBaseType.optional(),
409
+ correctResponse: QtiCorrectResponse
410
+ }).strict();
411
+ var QtiOutcomeDeclaration = z5.object({
412
+ identifier: z5.string().min(1),
413
+ cardinality: QtiCardinality,
414
+ baseType: QtiBaseType.optional()
415
+ }).strict();
416
+ var QtiTestOutcomeDeclaration = z5.object({
417
+ identifier: z5.string().min(1),
418
+ cardinality: QtiCardinality.optional(),
419
+ baseType: QtiBaseType,
420
+ normalMaximum: z5.number().optional(),
421
+ normalMinimum: z5.number().optional(),
422
+ defaultValue: z5.object({
423
+ value: z5.unknown().optional()
424
+ }).strict().optional()
425
+ }).strict();
426
+ var QtiInlineFeedback = z5.object({
427
+ outcomeIdentifier: z5.string().min(1),
428
+ variableIdentifier: z5.string().min(1)
429
+ }).strict();
430
+ var QtiResponseProcessing = z5.object({
431
+ templateType: z5.enum(["match_correct", "map_response"]),
432
+ responseDeclarationIdentifier: z5.string().min(1),
433
+ outcomeIdentifier: z5.string().min(1),
434
+ correctResponseIdentifier: z5.string().min(1),
435
+ incorrectResponseIdentifier: z5.string().min(1),
436
+ inlineFeedback: QtiInlineFeedback.optional()
437
+ }).strict();
438
+ var QtiLearningObjectiveSet = z5.object({
439
+ source: z5.string().min(1),
440
+ learningObjectiveIds: z5.array(z5.string())
441
+ }).strict();
442
+ var QtiItemMetadata = z5.object({
443
+ subject: z5.string().optional(),
444
+ grade: TimebackGrade.optional(),
445
+ difficulty: QtiDifficulty.optional(),
446
+ learningObjectiveSet: z5.array(QtiLearningObjectiveSet).optional()
447
+ }).strict();
448
+ var QtiModalFeedback = z5.object({
449
+ outcomeIdentifier: z5.string().min(1),
450
+ identifier: z5.string().min(1),
451
+ showHide: QtiShowHide,
452
+ content: z5.string(),
453
+ title: z5.string()
454
+ }).strict();
455
+ var QtiFeedbackInline = z5.object({
456
+ outcomeIdentifier: z5.string().min(1),
457
+ identifier: z5.string().min(1),
458
+ showHide: QtiShowHide,
459
+ content: z5.string(),
460
+ class: z5.array(z5.string())
461
+ }).strict();
462
+ var QtiFeedbackBlock = z5.object({
463
+ outcomeIdentifier: z5.string().min(1),
464
+ identifier: z5.string().min(1),
465
+ showHide: QtiShowHide,
466
+ content: z5.string(),
467
+ class: z5.array(z5.string())
468
+ }).strict();
469
+ var QtiStylesheet = z5.object({
470
+ href: z5.string().min(1),
471
+ type: z5.string().min(1)
472
+ }).strict();
473
+ var QtiCatalogInfo = z5.object({
474
+ id: z5.string().min(1),
475
+ support: z5.string(),
476
+ content: z5.string()
477
+ }).strict();
478
+ var QtiAssessmentItemCreateInput = z5.object({
479
+ identifier: z5.string().min(1),
480
+ title: z5.string().min(1),
481
+ type: QtiAssessmentItemType,
482
+ qtiVersion: z5.string().optional(),
483
+ timeDependent: z5.boolean().optional(),
484
+ adaptive: z5.boolean().optional(),
485
+ responseDeclarations: z5.array(QtiResponseDeclaration).optional(),
486
+ outcomeDeclarations: z5.array(QtiOutcomeDeclaration).optional(),
487
+ responseProcessing: QtiResponseProcessing.optional(),
488
+ metadata: QtiItemMetadata.optional(),
489
+ modalFeedback: z5.array(QtiModalFeedback).optional(),
490
+ feedbackInline: z5.array(QtiFeedbackInline).optional(),
491
+ feedbackBlock: z5.array(QtiFeedbackBlock).optional()
492
+ }).strict();
493
+ var QtiAssessmentItemUpdateInput = z5.object({
494
+ title: z5.string().min(1),
495
+ type: QtiAssessmentItemType,
496
+ qtiVersion: z5.string().optional(),
497
+ timeDependent: z5.boolean().optional(),
498
+ adaptive: z5.boolean().optional(),
499
+ responseDeclarations: z5.array(QtiResponseDeclaration).optional(),
500
+ outcomeDeclarations: z5.array(QtiOutcomeDeclaration).optional(),
501
+ responseProcessing: QtiResponseProcessing.optional(),
502
+ metadata: QtiItemMetadata.optional(),
503
+ modalFeedback: z5.array(QtiModalFeedback).optional(),
504
+ feedbackInline: z5.array(QtiFeedbackInline).optional(),
505
+ feedbackBlock: z5.array(QtiFeedbackBlock).optional(),
506
+ rawXml: z5.string(),
507
+ content: z5.record(z5.string(), z5.unknown())
508
+ }).strict();
509
+ var QtiAssessmentItemProcessResponseInput = z5.object({
510
+ response: z5.union([z5.string(), z5.array(z5.string())])
511
+ }).strict();
512
+ var QtiAssessmentItemRef = z5.object({
513
+ identifier: z5.string().min(1),
514
+ href: z5.union([z5.string(), z5.array(z5.string()), z5.array(z5.array(z5.string()))]).optional(),
515
+ sequence: z5.number().optional()
516
+ }).strict();
517
+ var QtiAssessmentSection = z5.object({
518
+ identifier: z5.string().min(1),
519
+ title: z5.string().min(1),
520
+ visible: z5.boolean(),
521
+ required: z5.boolean().optional(),
522
+ fixed: z5.boolean().optional(),
523
+ sequence: z5.number().optional(),
524
+ "qti-assessment-item-ref": z5.array(QtiAssessmentItemRef).optional()
525
+ }).strict();
526
+ var QtiTestPart = z5.object({
527
+ identifier: z5.string().min(1),
528
+ navigationMode: QtiNavigationMode,
529
+ submissionMode: QtiSubmissionMode,
530
+ "qti-assessment-section": z5.union([QtiAssessmentSection, z5.array(QtiAssessmentSection)])
531
+ }).strict();
532
+ var QtiAssessmentTestCreateInput = z5.object({
533
+ identifier: z5.string().min(1),
534
+ title: z5.string().min(1),
535
+ qtiVersion: z5.string().optional(),
536
+ toolName: z5.string().optional(),
537
+ toolVersion: z5.string().optional(),
538
+ timeLimit: z5.number().optional(),
539
+ maxAttempts: z5.number().optional(),
540
+ toolsEnabled: z5.record(z5.string(), z5.boolean()).optional(),
541
+ metadata: z5.record(z5.string(), z5.unknown()).optional(),
542
+ "qti-test-part": QtiTestPart,
543
+ "qti-outcome-declaration": z5.array(QtiTestOutcomeDeclaration).optional()
544
+ }).strict();
545
+ var QtiAssessmentTestUpdateInput = z5.object({
546
+ title: z5.string().min(1),
547
+ qtiVersion: z5.string().optional(),
548
+ toolName: z5.string().optional(),
549
+ toolVersion: z5.string().optional(),
550
+ timeLimit: z5.number().optional(),
551
+ maxAttempts: z5.number().optional(),
552
+ toolsEnabled: z5.record(z5.string(), z5.boolean()).optional(),
553
+ metadata: z5.record(z5.string(), z5.unknown()).optional(),
554
+ "qti-test-part": QtiTestPart,
555
+ "qti-outcome-declaration": z5.array(QtiTestOutcomeDeclaration).optional()
556
+ }).strict();
557
+ var QtiStimulusCreateInput = z5.object({
558
+ identifier: z5.string().min(1),
559
+ title: z5.string().min(1),
560
+ label: z5.string().optional(),
561
+ language: z5.string().optional(),
562
+ stylesheet: QtiStylesheet.optional(),
563
+ content: z5.string(),
564
+ catalogInfo: z5.array(QtiCatalogInfo).optional(),
565
+ toolName: z5.string().optional(),
566
+ toolVersion: z5.string().optional(),
567
+ metadata: z5.record(z5.string(), z5.unknown()).optional()
568
+ }).strict();
569
+ var QtiStimulusUpdateInput = z5.object({
570
+ title: z5.string().min(1),
571
+ label: z5.string().optional(),
572
+ language: z5.string().optional(),
573
+ stylesheet: QtiStylesheet.optional(),
574
+ content: z5.string(),
575
+ catalogInfo: z5.array(QtiCatalogInfo).optional(),
576
+ toolName: z5.string().optional(),
577
+ toolVersion: z5.string().optional(),
578
+ metadata: z5.record(z5.string(), z5.unknown()).optional()
579
+ }).strict();
580
+ var QtiValidateInput = z5.object({
581
+ xml: z5.string().optional(),
582
+ schema: QtiValidationSchema,
583
+ entityId: z5.string().optional()
584
+ }).strict();
585
+ var QtiValidateBatchInput = z5.object({
586
+ xml: z5.array(z5.string()),
587
+ schema: QtiValidationSchema,
588
+ entityIds: z5.array(z5.string())
589
+ }).strict();
590
+ var QtiLessonFeedbackInput = z5.object({
591
+ questionId: z5.string().optional(),
592
+ userId: z5.string().min(1),
593
+ feedback: z5.string().min(1),
594
+ lessonId: z5.string().min(1),
595
+ humanApproved: z5.boolean().optional()
596
+ }).strict();
361
597
  // ../internal/cli-infra/src/credentials/store.ts
362
598
  import { homedir, platform as platform2 } from "node:os";
363
599
  import { join } from "node:path";
364
600
 
365
601
  // ../internal/cli-infra/src/credentials/schema.ts
366
- import { z as z5 } from "zod";
367
- var CredentialsSchema = z5.object({
368
- clientId: z5.string().min(1, "Client ID is required"),
369
- clientSecret: z5.string().min(1, "Client secret is required"),
370
- email: z5.email("Valid email is required").optional()
602
+ import { z as z6 } from "zod";
603
+ var CredentialsSchema = z6.object({
604
+ clientId: z6.string().min(1, "Client ID is required"),
605
+ clientSecret: z6.string().min(1, "Client secret is required"),
606
+ email: z6.email("Valid email is required").optional()
371
607
  });
372
- var ClientIdSchema = z5.string().min(1, "Client ID is required").regex(/^[a-z0-9]+$/, "Client ID must contain only lowercase letters and numbers").length(26, "Client ID must be exactly 26 characters");
373
- var ClientSecretSchema = z5.string().min(1, "Client secret is required").regex(/^[a-z0-9]+$/, "Client secret must contain only lowercase letters and numbers").max(53, "Client secret must be less than 53 characters");
608
+ var ClientIdSchema = z6.string().min(1, "Client ID is required").regex(/^[a-z0-9]+$/, "Client ID must contain only lowercase letters and numbers").length(26, "Client ID must be exactly 26 characters");
609
+ var ClientSecretSchema = z6.string().min(1, "Client secret is required").regex(/^[a-z0-9]+$/, "Client secret must contain only lowercase letters and numbers").max(53, "Client secret must be less than 53 characters");
374
610
 
375
611
  // ../internal/cli-infra/src/credentials/store.ts
376
612
  function getConfigDir() {
@@ -1036,21 +1272,21 @@ function createIdentityHandlers(params) {
1036
1272
  };
1037
1273
  }
1038
1274
  // src/server/handlers/activity.ts
1039
- import * as z6 from "zod";
1040
- var activityMetricsSchema = z6.object({
1041
- totalQuestions: z6.number().int().nonnegative().optional(),
1042
- correctQuestions: z6.number().int().nonnegative().optional(),
1043
- xpEarned: z6.number().int().nonnegative().optional(),
1044
- masteredUnits: z6.number().int().nonnegative().optional()
1275
+ import * as z7 from "zod";
1276
+ var activityMetricsSchema = z7.object({
1277
+ totalQuestions: z7.number().int().nonnegative().optional(),
1278
+ correctQuestions: z7.number().int().nonnegative().optional(),
1279
+ xpEarned: z7.number().int().nonnegative().optional(),
1280
+ masteredUnits: z7.number().int().nonnegative().optional()
1045
1281
  });
1046
- var activityEndPayloadSchema = z6.object({
1047
- id: z6.string().min(1),
1048
- name: z6.string().min(1),
1049
- courseCode: z6.string().min(1),
1050
- startedAt: z6.iso.datetime(),
1051
- endedAt: z6.iso.datetime(),
1052
- elapsedMs: z6.number().int().nonnegative(),
1053
- pausedMs: z6.number().int().nonnegative(),
1282
+ var activityEndPayloadSchema = z7.object({
1283
+ id: z7.string().min(1),
1284
+ name: z7.string().min(1),
1285
+ courseCode: z7.string().min(1),
1286
+ startedAt: z7.iso.datetime(),
1287
+ endedAt: z7.iso.datetime(),
1288
+ elapsedMs: z7.number().int().nonnegative(),
1289
+ pausedMs: z7.number().int().nonnegative(),
1054
1290
  metrics: activityMetricsSchema
1055
1291
  });
1056
1292
  function createActivityHandler(config2) {
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Nuxt Adapter
3
+ *
4
+ * Adapts Timeback handlers for Nuxt 3.
5
+ * Supports both middleware-based (recommended) and route-based approaches.
6
+ *
7
+ * This adapter does NOT import h3 or nuxt - it uses minimal interfaces
8
+ * that are compatible with H3's event structure.
9
+ */
10
+ import type { NuxtHandlerOptions, NuxtHandlers, NuxtLikeEvent, TimebackInput } from './types';
11
+ /**
12
+ * Nuxt server middleware handler for Timeback.
13
+ *
14
+ * This is the **recommended** approach for Nuxt 3 integration.
15
+ * It intercepts requests at the middleware level before they reach route handlers.
16
+ *
17
+ * Returns a Response if the request matches a Timeback route, or undefined
18
+ * to let the request continue to other handlers.
19
+ *
20
+ * @param options - Handler options
21
+ * @returns Response from Timeback or undefined to continue
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * // server/middleware/timeback.ts
26
+ * import { timeback } from '~/lib/timeback'
27
+ * import { nuxtHandler } from 'timeback/nuxt'
28
+ *
29
+ * export default defineEventHandler(async (event) => {
30
+ * const response = await nuxtHandler({
31
+ * timeback,
32
+ * event,
33
+ * })
34
+ *
35
+ * if (response) {
36
+ * return response
37
+ * }
38
+ * })
39
+ * ```
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * // server/middleware/timeback.ts - with custom callback path
44
+ * import { timeback } from '~/lib/timeback'
45
+ * import { nuxtHandler } from 'timeback/nuxt'
46
+ *
47
+ * export default defineEventHandler(async (event) => {
48
+ * const response = await nuxtHandler({
49
+ * timeback,
50
+ * event,
51
+ * callbackPath: '/api/auth/sso/callback/timeback',
52
+ * })
53
+ *
54
+ * if (response) {
55
+ * return response
56
+ * }
57
+ * })
58
+ * ```
59
+ */
60
+ export declare function nuxtHandler<TEvent extends NuxtLikeEvent>(options: NuxtHandlerOptions<TEvent>): Promise<Response | undefined>;
61
+ /**
62
+ * Convert Timeback instance to Nuxt route handlers.
63
+ *
64
+ * This is an **alternative** approach using Nuxt's catch-all route handlers.
65
+ * Use this if you prefer explicit route files over middleware.
66
+ *
67
+ * Accepts either the full Timeback instance or just the handlers:
68
+ * - `toNuxtHandler(timeback)`
69
+ * - `toNuxtHandler(timeback.handle)`
70
+ *
71
+ * @param input - Timeback instance or handlers, or options object
72
+ * @returns Object with HTTP method handlers for Nuxt
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * // server/api/timeback/[...timeback].ts
77
+ * import { timeback } from '~/lib/timeback'
78
+ * import { toNuxtHandler } from 'timeback/nuxt'
79
+ *
80
+ * const handlers = toNuxtHandler(timeback)
81
+ *
82
+ * export default defineEventHandler(async (event) => {
83
+ * const method = event.request?.method ?? event.node?.req?.method ?? 'GET'
84
+ * const handler = handlers[method as keyof typeof handlers]
85
+ * if (handler) {
86
+ * return handler(event)
87
+ * }
88
+ * return new Response('Method not allowed', { status: 405 })
89
+ * })
90
+ * ```
91
+ */
92
+ export declare function toNuxtHandler(input: TimebackInput | {
93
+ timeback: TimebackInput;
94
+ callbackPath?: string;
95
+ }): NuxtHandlers;
96
+ //# sourceMappingURL=nuxt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nuxt.d.ts","sourceRoot":"","sources":["../../../src/server/adapters/nuxt.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,OAAO,KAAK,EAEX,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,aAAa,EACb,MAAM,SAAS,CAAA;AAsNhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,wBAAsB,WAAW,CAAC,MAAM,SAAS,aAAa,EAC7D,OAAO,EAAE,kBAAkB,CAAC,MAAM,CAAC,GACjC,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CA6C/B;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,aAAa,CAC5B,KAAK,EAAE,aAAa,GAAG;IAAE,QAAQ,EAAE,aAAa,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,GACvE,YAAY,CAqDd"}