@timeback/qti 0.1.7-beta.20260309181241 → 0.2.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.
@@ -120,12 +120,14 @@ var LEARNWITHAI_QTI_URLS = {
120
120
  var PLATFORM_ENDPOINTS = {
121
121
  BEYOND_AI: {
122
122
  token: BEYONDAI_TOKEN_URLS,
123
+ tokenScope: undefined,
123
124
  api: BEYONDAI_API_URLS,
124
125
  caliper: BEYONDAI_CALIPER_URLS,
125
126
  qti: BEYONDAI_QTI_URLS
126
127
  },
127
128
  LEARNWITH_AI: {
128
129
  token: LEARNWITHAI_TOKEN_URLS,
130
+ tokenScope: "https://purl.imsglobal.org/spec/caliper/v1p2/scope/events.write",
129
131
  api: LEARNWITHAI_API_URLS,
130
132
  caliper: LEARNWITHAI_CALIPER_URLS,
131
133
  qti: LEARNWITHAI_QTI_URLS
@@ -509,7 +511,7 @@ class TokenManager {
509
511
  Authorization: `Basic ${credentials}`,
510
512
  "Content-Type": "application/x-www-form-urlencoded"
511
513
  },
512
- body: "grant_type=client_credentials"
514
+ body: this.config.scope ? `grant_type=client_credentials&scope=${encodeURIComponent(this.config.scope)}` : "grant_type=client_credentials"
513
515
  });
514
516
  const duration = Math.round(performance.now() - start);
515
517
  if (!response.ok) {
@@ -573,7 +575,7 @@ var BEYONDAI_PATHS = {
573
575
  };
574
576
  var LEARNWITHAI_PATHS = {
575
577
  caliper: {
576
- send: "/events/1.0/",
578
+ send: "/caliper/v1p2",
577
579
  validate: null,
578
580
  list: null,
579
581
  get: null,
@@ -588,7 +590,9 @@ var LEARNWITHAI_PATHS = {
588
590
  edubridge: null,
589
591
  powerpath: null,
590
592
  clr: null,
591
- case: null
593
+ case: {
594
+ base: "/case/1.1"
595
+ }
592
596
  };
593
597
  var PLATFORM_PATHS = {
594
598
  BEYOND_AI: BEYONDAI_PATHS,
@@ -625,6 +629,7 @@ class TimebackProvider {
625
629
  timeout;
626
630
  endpoints;
627
631
  authUrl;
632
+ tokenScope;
628
633
  pathProfiles;
629
634
  tokenManagers = new Map;
630
635
  constructor(config) {
@@ -640,6 +645,7 @@ class TimebackProvider {
640
645
  throw new Error(`Unknown platform: ${platform}`);
641
646
  }
642
647
  this.authUrl = platformEndpoints.token[env];
648
+ this.tokenScope = platformEndpoints.tokenScope ?? undefined;
643
649
  this.pathProfiles = PLATFORM_PATHS[platform] ?? BEYONDAI_PATHS;
644
650
  this.endpoints = {
645
651
  oneroster: {
@@ -765,7 +771,8 @@ class TimebackProvider {
765
771
  credentials: {
766
772
  clientId: this.auth.clientId,
767
773
  clientSecret: this.auth.clientSecret
768
- }
774
+ },
775
+ scope: this.tokenScope
769
776
  });
770
777
  this.tokenManagers.set(authUrl, manager);
771
778
  }
@@ -783,7 +790,8 @@ class TimebackProvider {
783
790
  credentials: {
784
791
  clientId: this.auth.clientId,
785
792
  clientSecret: this.auth.clientSecret
786
- }
793
+ },
794
+ scope: this.tokenScope
787
795
  });
788
796
  this.tokenManagers.set(this.authUrl, manager);
789
797
  }
@@ -1514,7 +1522,7 @@ function issue(path, message) {
1514
1522
  function validateWithSchema(schema, data, context) {
1515
1523
  const result = schema.safeParse(data);
1516
1524
  if (result.success) {
1517
- return;
1525
+ return result.data;
1518
1526
  }
1519
1527
  const issues = result.error.issues.map((errorIssue) => ({
1520
1528
  path: errorIssue.path.join(".") || "(root)",
package/dist/errors.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  NotFoundError,
6
6
  UnauthorizedError,
7
7
  ValidationError
8
- } from "./chunk-pgeezm1a.js";
8
+ } from "./chunk-epsse7wh.js";
9
9
  import"./chunk-6jf1natv.js";
10
10
  export {
11
11
  ValidationError,
package/dist/index.d.ts CHANGED
@@ -682,7 +682,7 @@ declare const QtiPaginationParams = z
682
682
  declare const QtiAssessmentItemXmlCreateInput = z
683
683
  .object({
684
684
  format: z.string().pipe(z.literal('xml')),
685
- xml: z.string().min(1),
685
+ xml: NonEmptyString,
686
686
  metadata: QtiItemMetadata.optional(),
687
687
  })
688
688
  .strict()
@@ -694,8 +694,8 @@ declare const QtiAssessmentItemXmlCreateInput = z
694
694
  */
695
695
  declare const QtiAssessmentItemJsonCreateInput = z
696
696
  .object({
697
- identifier: z.string().min(1),
698
- title: z.string().min(1),
697
+ identifier: NonEmptyString,
698
+ title: NonEmptyString,
699
699
  type: QtiAssessmentItemType,
700
700
  qtiVersion: z.string().optional(),
701
701
  timeDependent: z.boolean().optional(),
@@ -723,8 +723,8 @@ declare const QtiAssessmentItemCreateInput = z.union([
723
723
 
724
724
  declare const QtiAssessmentItemUpdateInput = z
725
725
  .object({
726
- identifier: z.string().min(1).optional(),
727
- title: z.string().min(1),
726
+ identifier: NonEmptyString.optional(),
727
+ title: NonEmptyString,
728
728
  type: QtiAssessmentItemType,
729
729
  qtiVersion: z.string().optional(),
730
730
  timeDependent: z.boolean().optional(),
@@ -743,7 +743,7 @@ declare const QtiAssessmentItemUpdateInput = z
743
743
 
744
744
  declare const QtiAssessmentItemProcessResponseInput = z
745
745
  .object({
746
- identifier: z.string().min(1),
746
+ identifier: NonEmptyString,
747
747
  response: z.union([z.string(), z.array(z.string())]),
748
748
  })
749
749
  .strict()
@@ -754,16 +754,16 @@ declare const QtiAssessmentItemProcessResponseInput = z
754
754
 
755
755
  declare const QtiAssessmentItemRef = z
756
756
  .object({
757
- identifier: z.string().min(1),
758
- href: z.string().min(1),
757
+ identifier: NonEmptyString,
758
+ href: NonEmptyString,
759
759
  sequence: z.number().int().positive().optional(),
760
760
  })
761
761
  .strict()
762
762
 
763
763
  declare const QtiAssessmentSection = z
764
764
  .object({
765
- identifier: z.string().min(1),
766
- title: z.string().min(1),
765
+ identifier: NonEmptyString,
766
+ title: NonEmptyString,
767
767
  visible: z.boolean(),
768
768
  required: z.boolean().optional(),
769
769
  fixed: z.boolean().optional(),
@@ -774,7 +774,7 @@ declare const QtiAssessmentSection = z
774
774
 
775
775
  declare const QtiTestPart = z
776
776
  .object({
777
- identifier: z.string().min(1),
777
+ identifier: NonEmptyString,
778
778
  navigationMode: z.string().pipe(QtiNavigationMode),
779
779
  submissionMode: z.string().pipe(QtiSubmissionMode),
780
780
  'qti-assessment-section': z.array(QtiAssessmentSection),
@@ -795,8 +795,8 @@ declare const QtiAssessmentTestMetadataUpdateInput = z
795
795
 
796
796
  declare const QtiAssessmentTestCreateInput = z
797
797
  .object({
798
- identifier: z.string().min(1),
799
- title: z.string().min(1),
798
+ identifier: NonEmptyString,
799
+ title: NonEmptyString,
800
800
  qtiVersion: z.string().optional(),
801
801
  toolName: z.string().optional(),
802
802
  toolVersion: z.string().optional(),
@@ -811,8 +811,8 @@ declare const QtiAssessmentTestCreateInput = z
811
811
 
812
812
  declare const QtiAssessmentTestUpdateInput = z
813
813
  .object({
814
- identifier: z.string().min(1).optional(),
815
- title: z.string().min(1),
814
+ identifier: NonEmptyString.optional(),
815
+ title: NonEmptyString,
816
816
  qtiVersion: z.string().optional(),
817
817
  toolName: z.string().optional(),
818
818
  toolVersion: z.string().optional(),
@@ -831,8 +831,8 @@ declare const QtiAssessmentTestUpdateInput = z
831
831
 
832
832
  declare const QtiStimulusCreateInput = z
833
833
  .object({
834
- identifier: z.string().min(1),
835
- title: z.string().min(1),
834
+ identifier: NonEmptyString,
835
+ title: NonEmptyString,
836
836
  label: z.string().optional(),
837
837
  language: z.string().optional(),
838
838
  stylesheet: QtiStylesheet.optional(),
@@ -846,8 +846,8 @@ declare const QtiStimulusCreateInput = z
846
846
 
847
847
  declare const QtiStimulusUpdateInput = z
848
848
  .object({
849
- identifier: z.string().min(1).optional(),
850
- title: z.string().min(1),
849
+ identifier: NonEmptyString.optional(),
850
+ title: NonEmptyString,
851
851
  label: z.string().optional(),
852
852
  language: z.string().optional(),
853
853
  stylesheet: QtiStylesheet.optional(),
@@ -886,9 +886,9 @@ declare const QtiValidateBatchInput = z
886
886
  declare const QtiLessonFeedbackInput = z
887
887
  .object({
888
888
  questionId: z.string().optional(),
889
- userId: z.string().min(1),
890
- feedback: z.string().min(1),
891
- lessonId: z.string().min(1),
889
+ userId: NonEmptyString,
890
+ feedback: NonEmptyString,
891
+ lessonId: NonEmptyString,
892
892
  humanApproved: z.boolean().optional(),
893
893
  })
894
894
  .strict()