@timeback/sdk 0.1.10 → 0.1.12
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 +10 -8
- package/dist/chunk-1cqa51je.js +2 -0
- package/dist/chunk-3ew9vn2d.js +2 -0
- package/dist/chunk-62x5my81.js +1 -0
- package/dist/chunk-6b0ppq9d.js +2 -0
- package/dist/{chunk-3mqpr9vx.js → chunk-bavxzt1k.js} +2 -2
- package/dist/chunk-c8pw96sp.js +10 -0
- package/dist/chunk-edk3nfj7.js +2 -0
- package/dist/chunk-pd91g539.js +1 -0
- package/dist/chunk-zra03qq3.js +4 -0
- package/dist/client/namespaces/activity.d.ts +6 -3
- package/dist/client/namespaces/activity.d.ts.map +1 -1
- package/dist/identity.d.ts +2 -5
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +1 -1
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -7
- package/dist/server/adapters/express.js +1 -1
- package/dist/server/adapters/native.js +2 -2
- package/dist/server/adapters/nextjs.js +1 -1
- package/dist/server/adapters/nuxt.js +1 -1
- package/dist/server/adapters/solid-start.js +1 -1
- package/dist/server/adapters/svelte-kit.js +1 -1
- package/dist/server/adapters/tanstack-start.js +1 -1
- package/dist/server/adapters/types.d.ts +16 -4
- package/dist/server/adapters/types.d.ts.map +1 -1
- package/dist/server/handlers/activity/attempts.d.ts +1 -1
- package/dist/server/handlers/activity/attempts.d.ts.map +1 -1
- package/dist/server/handlers/activity/caliper.d.ts +4 -2
- package/dist/server/handlers/activity/caliper.d.ts.map +1 -1
- package/dist/server/lib/utils.d.ts +4 -1
- package/dist/server/lib/utils.d.ts.map +1 -1
- package/dist/server/timeback-identity.d.ts +3 -3
- package/dist/server/timeback.d.ts +4 -2
- package/dist/server/timeback.d.ts.map +1 -1
- package/dist/server/types.d.ts +18 -7
- package/dist/server/types.d.ts.map +1 -1
- package/dist/shared/types.d.ts +24 -8
- package/dist/shared/types.d.ts.map +1 -1
- package/dist/shared/types.ts +24 -8
- package/package.json +7 -10
- package/dist/chunk-af3xwwsv.js +0 -16
- package/dist/chunk-b8649tw4.js +0 -2
- package/dist/chunk-bd09q1fw.js +0 -8
- package/dist/chunk-js665z11.js +0 -1
- package/dist/chunk-nsr7a2dv.js +0 -2
- package/dist/chunk-sgcwg4j6.js +0 -1
- package/dist/chunk-txwjkpfz.js +0 -1
- package/dist/chunk-whc53e0y.js +0 -11
- package/dist/edge.d.ts +0 -13
- package/dist/edge.d.ts.map +0 -1
- package/dist/edge.js +0 -1
package/README.md
CHANGED
|
@@ -400,9 +400,10 @@ function MyComponent() {
|
|
|
400
400
|
#### Profile Primitive
|
|
401
401
|
|
|
402
402
|
```tsx
|
|
403
|
-
import { createTimebackProfile } from '@timeback/sdk/solid'
|
|
404
403
|
import { Show } from 'solid-js'
|
|
405
404
|
|
|
405
|
+
import { createTimebackProfile } from '@timeback/sdk/solid'
|
|
406
|
+
|
|
406
407
|
function ProfileButton() {
|
|
407
408
|
const { state, canFetch, fetchProfile } = createTimebackProfile()
|
|
408
409
|
|
|
@@ -516,18 +517,19 @@ If you only need Timeback SSO authentication without activity tracking or Timeba
|
|
|
516
517
|
|
|
517
518
|
**Note:** Unlike `createTimeback()`, the identity-only callback returns raw OIDC user info (`sub`, `email`, `name`, etc.) without resolving a Timeback user. Use `createTimeback()` if you need the canonical `timebackId`.
|
|
518
519
|
|
|
519
|
-
###
|
|
520
|
+
### Edge Runtime Compatibility
|
|
520
521
|
|
|
521
|
-
`
|
|
522
|
-
|
|
523
|
-
(Cloudflare Workers / workerd) do not support the Node modules that `c12` depends on.
|
|
524
|
-
|
|
525
|
-
If you're deploying identity-only SSO on Workers/workerd, import from the worker-safe entrypoint:
|
|
522
|
+
The main `@timeback/sdk` entrypoint is edge-compatible and works in Cloudflare Workers,
|
|
523
|
+
Vercel Edge, Bun, Deno, and Node.js. No separate entrypoint is needed:
|
|
526
524
|
|
|
527
525
|
```ts
|
|
528
|
-
import { createTimebackIdentity, toNativeHandler } from '@timeback/sdk
|
|
526
|
+
import { createTimebackIdentity, toNativeHandler } from '@timeback/sdk'
|
|
529
527
|
```
|
|
530
528
|
|
|
529
|
+
> **Note:** `createTimeback()` (the full SDK) uses `c12` for config file loading, which is lazily
|
|
530
|
+
> imported at runtime. On edge runtimes where `c12` isn't available, `createTimeback()` will fail
|
|
531
|
+
> at call time — use `createTimebackIdentity()` for edge deployments.
|
|
532
|
+
|
|
531
533
|
### Server Setup
|
|
532
534
|
|
|
533
535
|
```typescript
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{o as W,p as $,q as w,r as x,s as z,t as A,u as D,v as F,w as M,x as P}from"./chunk-6b0ppq9d.js";import{G as T,H as Y,J as X}from"./chunk-3ew9vn2d.js";async function j(H,G,O){return await F({req:H,env:G,clientId:O.clientId,issuer:O.issuer,redirectUri:O.redirectUri,buildState:O.buildState})}async function U(H,G,O,K,V,B){try{let J=B.issuer??$(V),N=P(G,B.redirectUri);W.debug("Exchanging auth code for tokens (identity-only)",{issuer:J,clientId:B.clientId});let _=await w({issuer:J,clientId:B.clientId,clientSecret:B.clientSecret,code:H,redirectUri:N}),Q=await x({issuer:J,accessToken:_.access_token}),E=typeof Q.identities==="string"?JSON.parse(Q.identities):Q.identities;W.debug("SSO completed (identity-only)",{user:{...Q,identities:E}});let S={tokens:_,user:Q,state:O,req:K,redirect:X,json:Y};return B.onCallbackSuccess(S)}catch(J){let N=J instanceof Error?J:Error("Unknown error");if(W.error("Token exchange failed (identity-only)",{error:N.message}),B.onCallbackError)return B.onCallbackError(z(N,void 0,O,K));return Y({error:N.message},500)}}async function L(H,G,O){let{url:K,code:V,errorParam:B,state:J}=M(H);if(B)return A(B,K,J,H,O.onCallbackError);if(!V)return D(J,H,O.onCallbackError);return await U(V,K,J,H,G,O)}function Z(H){let{env:G,identity:O}=H;if(O.mode!=="sso")throw Error('Identity-only mode requires identity.mode === "sso"');return{signIn:(K)=>j(K,G,O),callback:(K)=>L(K,G,O),signOut:()=>X("/")}}function u(H){let G=Z({env:T(H.env),identity:H.identity});return{config:H,handle:{identity:G}}}
|
|
2
|
+
export{u as d};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function F(q){return{course:q,component:`${q}-component`,resource:`${q}-resource`,componentResource:`${q}-cr`}}async function G(q){let w=new TextEncoder().encode(q),z=await crypto.subtle.digest("SHA-256",w);return Array.from(new Uint8Array(z)).map((A)=>A.toString(16).padStart(2,"0")).join("")}function J(q){if(q==="local"||q==="staging")return"staging";return"production"}function K(q){if(q==="production"||q==="local"||q==="staging")return q;return"staging"}function C(q,w=200,z){let A=new Headers(z);return A.set("Content-Type","application/json"),new Response(JSON.stringify(q),{status:w,headers:A})}function L(q,w,z,A){let B={code:q,message:w};if(A?.details!==void 0)B.details=A.details;return C({...A?.fields,error:B},z)}function M(q,w){let z=new Headers(w);return z.set("Location",q),new Response(null,{status:302,headers:z})}function N(q){let w=JSON.stringify(q);return btoa(w).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function O(q){let w=q.replace(/-/g,"+").replace(/_/g,"/"),z=atob(w);return JSON.parse(z)}var Q={ACTIVITY:"/activity",ACTIVITY_HEARTBEAT:"/activity/heartbeat",ACTIVITY_SUBMIT:"/activity/submit",IDENTITY:{SIGNIN:"/identity/signin",SIGNOUT:"/identity/signout",CALLBACK:"/identity/callback"},USER:{ME:"/user/me",VERIFY:"/user/verify"}};
|
|
2
|
+
export{F as D,G as E,J as F,K as G,C as H,L as I,M as J,N as K,O as L,Q as M};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{z as w}from"zod/v4";import{z as _}from"zod/v4";var PZ=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/,x=_.string().min(1).regex(PZ,"must be a valid ISO 8601 datetime"),C=_.string().min(1).regex(/^\d{4}-\d{2}-\d{2}$/,"must be a valid ISO 8601 date (YYYY-MM-DD)"),L=_.enum(["Reading","Language","Vocabulary","Social Studies","Writing","Science","FastMath","Math","None","Other"]).meta({id:"TimebackSubject",description:"Subject area"}),F=_.union([_.literal(-1),_.literal(0),_.literal(1),_.literal(2),_.literal(3),_.literal(4),_.literal(5),_.literal(6),_.literal(7),_.literal(8),_.literal(9),_.literal(10),_.literal(11),_.literal(12),_.literal(13)]).meta({id:"TimebackGrade",description:"Grade level (-1 = Pre-K, 0 = K, 1-12 = grades, 13 = AP)"}),T=_.enum(["exempt","fully graded","not submitted","partially graded","submitted"]),R=_.enum(["department","school","district","local","state","national"]),I=_.enum(["administrator","aide","guardian","parent","proctor","relative","student","teacher"]),u=_.enum(["administrator","proctor","student","teacher"]),d=_.enum(["qti","text","audio","video","interactive","visual","course-material","assessment-bank"]),c=_.enum(["qti-test","qti-question","qti-stimulus","qti-test-bank"]),s=_.enum(["unit","course","resource-collection"]),N=_.enum(["choice","order","associate","match","hotspot","hottext","select-point","graphic-order","graphic-associate","graphic-gap-match","text-entry","extended-text","inline-choice","upload","slider","drawing","media","custom"]),p=_.enum(["easy","medium","hard"]),y=_.array(_.object({source:_.string(),learningObjectiveIds:_.array(_.string())})),E=_.object({consecutive_failures:_.number().int().min(1).optional(),stagnation_limit:_.number().int().min(1).optional()}).optional(),Yq=_.enum(["powerpath-100","quiz","test-out","placement","unit-test","alpha-read-article"]).nullable(),_q=_.object({imsx_codeMajor:_.enum(["failure","success"]),imsx_severity:_.enum(["error","warning","status"]),imsx_description:_.string(),imsx_CodeMinor:_.object({imsx_codeMinorField:_.array(_.object({imsx_codeMinorFieldName:_.string(),imsx_codeMinorFieldValue:_.string()}))}).optional()});var UZ=w.object({staging:w.string().meta({description:"Course ID in staging environment"}).optional(),production:w.string().meta({description:"Course ID in production environment"}).optional()}).meta({id:"CourseIds",description:"Environment-specific course IDs (populated by sync)"}),QZ=w.enum(["base","hole-filling","optional"]).meta({id:"CourseType",description:"Course classification type"}),jZ=w.enum(["draft","testing","published","deactivated"]).meta({id:"PublishStatus",description:"Course publication status"}),AZ=w.object({dailyXp:w.number().int().positive().meta({description:"Target XP to earn per day"}).optional(),dailyLessons:w.number().int().positive().meta({description:"Target lessons to complete per day"}).optional(),dailyActiveMinutes:w.number().int().positive().meta({description:"Target active learning minutes per day"}).optional(),dailyAccuracy:w.number().int().min(0).max(100).meta({description:"Target accuracy percentage (0-100)"}).optional(),dailyMasteredUnits:w.number().int().positive().meta({description:"Target units to master per day"}).optional()}).meta({id:"CourseGoals",description:"Daily learning goals for a course"}),BZ=w.object({totalXp:w.number().int().positive().meta({description:"Total XP available in the course"}).optional(),totalLessons:w.number().int().positive().meta({description:"Total number of lessons/activities"}).optional(),totalGrades:w.number().int().positive().meta({description:"Total grade levels covered"}).optional()}).meta({id:"CourseMetrics",description:"Aggregate metrics for a course"}),m=w.object({courseType:QZ.optional(),isSupplemental:w.boolean().meta({description:"Whether this is supplemental to a base course"}).optional(),isCustom:w.boolean().meta({description:"Whether this is a custom course for an individual student"}).optional(),publishStatus:jZ.optional(),contactEmail:w.email().meta({description:"Contact email for course issues"}).optional(),primaryApp:w.string().meta({description:"Primary application identifier"}).optional(),goals:AZ.optional(),metrics:BZ.optional()}).meta({id:"CourseMetadata",description:"Course metadata (matches API metadata object)"}),S=w.object({courseCode:w.string().meta({description:"Course code (e.g., 'MATH101')"}).optional(),level:w.string().meta({description:"Course level (e.g., 'AP', 'Honors')"}).optional(),metadata:m.optional()}).meta({id:"CourseDefaults",description:"Default properties that apply to all courses unless overridden"}),g=w.object({level:w.string().meta({description:"Course level for this environment"}).optional(),sensor:w.url().meta({description:"Caliper sensor endpoint URL for this environment"}).optional(),launchUrl:w.url().meta({description:"LTI launch URL for this environment"}).optional(),metadata:m.optional()}).meta({id:"CourseEnvOverrides",description:"Environment-specific course overrides (non-identity fields)"}),GZ=w.object({staging:g.meta({description:"Overrides for staging environment"}).optional(),production:g.meta({description:"Overrides for production environment"}).optional()}).meta({id:"CourseOverrides",description:"Per-environment course overrides"}),hZ=S.extend({subject:L.meta({description:"Subject area for this course"}),grade:F.meta({description:"Grade level (-1 = Pre-K, 0 = K, 1-12 = grades, 13 = AP)"}).optional(),ids:UZ.nullable().optional(),sensor:w.url().meta({description:"Caliper sensor endpoint URL for this course"}).optional(),launchUrl:w.url().meta({description:"LTI launch URL for this course"}).optional(),overrides:GZ.optional()}).meta({id:"CourseConfig",description:"Configuration for a single course. Must have either grade or courseCode (or both)."}),Vq=w.object({$schema:w.string().meta({description:"JSON Schema reference for editor support"}).optional(),name:w.string().min(1,"App name is required").meta({description:"Display name for your app"}),defaults:S.meta({description:"Default properties applied to all courses"}).optional(),courses:w.array(hZ).min(1,"At least one course is required").meta({description:"Courses available in this app"}),sensor:w.url().meta({description:"Default Caliper sensor endpoint URL for all courses"}).optional(),launchUrl:w.url().meta({description:"Default LTI launch URL for all courses"}).optional()}).meta({id:"TimebackConfig",title:"Timeback Config",description:"Configuration schema for timeback.config.json files"}).refine((P)=>{return P.courses.every((U)=>U.grade!==void 0||U.courseCode!==void 0)},{message:"Each course must have either a grade or a courseCode",path:["courses"]}).refine((P)=>{let O=P.courses.filter((G)=>G.grade!==void 0).map((G)=>`${G.subject}:${G.grade}`);return new Set(O).size===O.length},{message:"Duplicate (subject, grade) pair found; each must be unique",path:["courses"]}).refine((P)=>{let O=P.courses.filter((G)=>G.courseCode!==void 0).map((G)=>G.courseCode);return new Set(O).size===O.length},{message:"Duplicate courseCode found; each must be unique",path:["courses"]}).refine((P)=>{return P.courses.every((U)=>{if(U.sensor!==void 0||P.sensor!==void 0)return!0;return[U.launchUrl,P.launchUrl,U.overrides?.staging?.launchUrl,U.overrides?.production?.launchUrl].filter(Boolean).length>0})},{message:"Each course must have an effective sensor. Either set `sensor` explicitly (top-level or per-course), or provide a `launchUrl` so sensor can be derived from its origin.",path:["courses"]});import{z as H}from"zod/v4";var D=H.object({id:H.string(),type:H.literal("TimebackUser"),email:H.string()}),k=H.object({id:H.string(),type:H.literal("TimebackActivityContext"),subject:L,app:H.object({name:H.string()}),activity:H.object({id:H.string().optional(),name:H.string()}).strict().optional(),course:H.object({id:H.string().optional(),name:H.string()}).strict().optional(),process:H.boolean().optional()}),o=H.object({"@context":H.literal("http://purl.imsglobal.org/ctx/caliper/v1p2"),id:H.string(),type:H.string(),eventTime:x,profile:H.literal("TimebackProfile"),actor:D,action:H.string(),object:k,edApp:H.object({id:H.string(),name:H.string().optional()}).optional()}),r=H.object({type:H.enum(["totalQuestions","correctQuestions","xpEarned","masteredUnits"]),value:H.number()}),OZ=H.object({id:H.string(),type:H.literal("TimebackActivityMetricsCollection"),attempt:H.number().optional(),items:H.array(r),extensions:H.record(H.string(),H.unknown()).optional()}),vZ=o.extend({type:H.literal("ActivityEvent"),action:H.literal("Completed"),generated:OZ}),a=H.object({type:H.enum(["active","inactive","waste","unknown","anti-pattern"]),value:H.number(),subType:H.string().optional()}),IZ=H.object({id:H.string(),type:H.literal("TimebackTimeSpentMetricsCollection"),items:H.array(a)}),CZ=o.extend({type:H.literal("TimeSpentEvent"),action:H.literal("SpentTime"),generated:IZ}),Pq=H.object({actor:D,object:k,metrics:H.array(r).min(1,"metrics must contain at least one metric"),eventTime:x.optional(),metricsId:H.string().optional(),id:H.string().optional(),extensions:H.record(H.string(),H.unknown()).optional(),edApp:H.union([H.string(),H.record(H.string(),H.unknown())]).optional(),session:H.union([H.string(),H.record(H.string(),H.unknown())]).optional(),attempt:H.number().int().min(1).optional(),generatedExtensions:H.object({pctCompleteApp:H.number().optional()}).loose().optional()}).strict(),Uq=H.object({actor:D,object:k,metrics:H.array(a).min(1,"metrics must contain at least one metric"),eventTime:x.optional(),metricsId:H.string().optional(),id:H.string().optional(),extensions:H.record(H.string(),H.unknown()).optional(),edApp:H.union([H.string(),H.record(H.string(),H.unknown())]).optional(),session:H.union([H.string(),H.record(H.string(),H.unknown())]).optional()}).strict(),DZ=H.union([vZ,CZ]),Qq=H.object({sensor:H.string(),sendTime:x,dataVersion:H.literal("http://purl.imsglobal.org/ctx/caliper/v1p2"),data:H.array(DZ)}),kZ=H.enum(["AnnotationProfile","AssessmentProfile","ToolUseProfile","GeneralProfile","FeedbackProfile","MediaProfile","SurveyProfile","ResourceManagementProfile","ForumProfile","AssignableProfile","GradingProfile","ReadingProfile","SessionProfile","SearchProfile","ToolLaunchProfile","TimebackProfile"]),A=H.union([H.string(),H.record(H.string(),H.unknown())]),fZ=H.object({id:H.string(),type:H.string(),extensions:H.object({email:H.email()}).loose()}).strict(),i=H.object({"@context":H.string().optional(),id:H.string(),type:H.string(),actor:H.union([H.string(),fZ,D]),action:H.string(),object:A,eventTime:x,profile:kZ,edApp:A.optional(),generated:A.optional(),target:A.optional(),referrer:A.optional(),group:A.optional(),membership:A.optional(),session:A.optional(),federatedSession:A.optional(),extensions:H.record(H.string(),H.unknown()).optional()}).strict(),jq=H.object({sensor:H.string().min(1,"sensor must be a non-empty string"),sendTime:x,dataVersion:H.literal("http://purl.imsglobal.org/ctx/caliper/v1p2"),data:H.array(i).min(1,"data must contain at least one event")}),Aq=H.object({sensor:H.string().min(1,"sensor must be a non-empty string"),events:H.array(i).min(1,"events must contain at least one event")}),Bq=H.object({limit:H.number().int().positive().optional(),offset:H.number().int().min(0).optional(),sensor:H.string().min(1).optional(),startDate:x.optional(),endDate:x.optional(),actorId:H.string().min(1).optional(),actorEmail:H.email().optional()}).strict();import{z as X}from"zod/v4";var j=X.union([x,C]),vq=X.object({id:X.string(),role:X.string(),beginDate:j.nullable(),endDate:j.nullable(),metadata:X.object({goals:X.object({dailyXp:X.number().optional()}).optional(),metrics:X.object({totalXp:X.number().optional(),totalLessons:X.number().optional()}).optional()}).optional(),course:X.object({id:X.string(),title:X.string(),subjects:X.array(X.string()).nullable(),grades:X.array(X.string()).nullable()}),school:X.object({id:X.string(),name:X.string()})}),MZ=X.object({activityMetrics:X.object({xpEarned:X.number(),totalQuestions:X.number(),correctQuestions:X.number(),masteredUnits:X.number()}),timeSpentMetrics:X.object({activeSeconds:X.number(),inactiveSeconds:X.number(),wasteSeconds:X.number()}),apps:X.array(X.string())}),lZ=X.record(X.string(),X.record(X.string(),MZ)),Iq=X.object({message:X.string(),enrollmentId:X.string(),startDate:j,endDate:j,facts:lZ,factsByApp:X.unknown()}),B=X.string().trim().min(1),z=X.object({email:X.email().optional(),studentId:B.optional()}).superRefine((P,U)=>{if(!P.email&&!P.studentId)U.addIssue({code:X.ZodIssueCode.custom,message:"must provide either email or studentId",path:["email"]}),U.addIssue({code:X.ZodIssueCode.custom,message:"must provide either email or studentId",path:["studentId"]})}),Cq=X.object({subject:B,grade:B,courseId:B,orgSourcedId:B.optional()});var Dq=X.object({userId:B}),kq=X.object({sourcedId:B.optional(),role:u.optional(),beginDate:j.optional(),metadata:X.record(X.string(),X.unknown()).optional()}),fq=X.object({fields:X.string().optional(),limit:X.number().int().positive().optional(),offset:X.number().int().nonnegative().optional(),sort:X.string().optional(),orderBy:X.enum(["asc","desc"]).optional(),filter:X.string().optional(),search:X.string().optional(),roles:X.array(I).min(1),orgSourcedIds:X.array(B).optional()}),Mq=z.extend({startDate:j,endDate:j,timezone:X.string().optional()}),lq=z.extend({weekDate:j,timezone:X.string().optional()}),bq=X.object({enrollmentId:B,startDate:j.optional(),endDate:j.optional(),timezone:X.string().optional()});import{z as q}from"zod/v4";var Y=q.string().min(1),V=q.enum(["active","tobedeleted"]),J=q.record(q.string(),q.unknown()).nullable().optional(),$=q.object({sourcedId:Y,type:q.string().optional(),href:q.string().optional()}).strict(),Q=q.union([C,x]),bZ=q.object({roleType:q.enum(["primary","secondary"]),role:I,org:$,userProfile:q.string().optional(),metadata:J,beginDate:Q.optional(),endDate:Q.optional()}).strict(),dq=q.object({sourcedId:Y.describe("sourcedId must be a non-empty string"),status:V.optional(),enabledUser:q.boolean(),givenName:Y.describe("givenName must be a non-empty string"),familyName:Y.describe("familyName must be a non-empty string"),middleName:Y.optional(),username:Y.optional(),email:q.email().optional(),roles:q.array(bZ).min(1,"roles must include at least one role"),userIds:q.array(q.object({type:Y,identifier:Y}).strict()).optional(),agents:q.array($).optional(),grades:q.array(F).optional(),identifier:Y.optional(),sms:Y.optional(),phone:Y.optional(),pronouns:Y.optional(),password:Y.optional(),metadata:J}).strict(),cq=q.object({sourcedId:Y.describe("sourcedId must be a non-empty string").optional(),status:V.optional(),title:Y.describe("title must be a non-empty string"),org:$,courseCode:Y.optional(),subjects:q.array(L).optional(),grades:q.array(F).optional(),level:Y.optional(),metadata:J}).strict(),sq=q.object({sourcedId:Y.describe("sourcedId must be a non-empty string").optional(),status:V.optional(),title:Y.describe("title must be a non-empty string"),terms:q.array($).min(1,"terms must have at least one item"),course:$,org:$,classCode:Y.optional(),classType:q.enum(["homeroom","scheduled"]).optional(),location:Y.optional(),grades:q.array(F).optional(),subjects:q.array(L).optional(),subjectCodes:q.array(Y).optional(),periods:q.array(Y).optional(),metadata:J}).strict(),e=q.enum(["true","false"]),Nq=q.object({sourcedId:Y.describe("sourcedId must be a non-empty string").optional(),status:V.optional(),user:$,class:$,school:$.optional(),role:I,primary:e.optional(),beginDate:Q.optional(),endDate:Q.optional(),metadata:J}).strict(),pq=q.object({sourcedId:Y.optional(),title:Y.describe("title must be a non-empty string"),status:V,weight:q.number().nullable().optional(),metadata:J}).strict(),yq=q.object({sourcedId:Y.optional(),title:Y.describe("title must be a non-empty string"),class:$,school:$,category:$,assignDate:Q,dueDate:Q,status:V,description:q.string().optional(),resultValueMin:q.number().nullable().optional(),resultValueMax:q.number().nullable().optional(),scoreScale:$.optional(),metadata:J}).strict(),Eq=q.object({sourcedId:Y.optional(),lineItem:$,student:$,class:$.optional(),scoreDate:Q,scoreStatus:q.enum(["exempt","fully graded","not submitted","partially graded","submitted"]),score:q.number().nullable().optional(),textScore:q.string().nullable().optional(),status:V,comment:q.string().nullable().optional(),metadata:J}).strict(),gq=q.object({sourcedId:Y.optional(),title:Y.describe("title must be a non-empty string"),status:V.optional(),type:q.string().optional(),class:$.optional(),course:$.nullable().optional(),scoreScaleValue:q.array(q.object({itemValueLHS:Y,itemValueRHS:Y,value:q.string().optional(),description:q.string().optional()}).strict()).optional(),minScore:q.number().optional(),maxScore:q.number().optional(),metadata:J}).strict(),mq=q.object({sourcedId:Y.optional(),status:V.optional(),dateLastModified:x.optional(),title:Y.describe("title must be a non-empty string"),description:q.string().nullable().optional(),class:$.nullable().optional(),parentAssessmentLineItem:$.nullable().optional(),scoreScale:$.nullable().optional(),resultValueMin:q.number().nullable().optional(),resultValueMax:q.number().nullable().optional(),component:$.nullable().optional(),componentResource:$.nullable().optional(),learningObjectiveSet:q.array(q.object({source:q.string(),learningObjectiveIds:q.array(q.string())})).optional().nullable(),course:$.nullable().optional(),metadata:J}).strict(),TZ=q.object({learningObjectiveId:q.string(),score:q.number().optional(),textScore:q.string().optional()}),RZ=q.array(q.object({source:q.string(),learningObjectiveResults:q.array(TZ)})),Sq=q.object({sourcedId:Y.optional(),status:V.optional(),dateLastModified:x.optional(),metadata:J,assessmentLineItem:$,student:$,score:q.number().nullable().optional(),textScore:q.string().nullable().optional(),scoreDate:q.string().datetime(),scoreScale:$.nullable().optional(),scorePercentile:q.number().nullable().optional(),scoreStatus:q.enum(["exempt","fully graded","not submitted","partially graded","submitted"]),comment:q.string().nullable().optional(),learningObjectiveSet:RZ.nullable().optional(),inProgress:q.string().nullable().optional(),incomplete:q.string().nullable().optional(),late:q.string().nullable().optional(),missing:q.string().nullable().optional()}).strict(),oq=q.object({sourcedId:Y.optional(),status:V.optional(),name:Y.describe("name must be a non-empty string"),type:R,identifier:Y.optional(),parent:$.optional(),metadata:J}).strict(),rq=q.object({sourcedId:Y.optional(),status:V.optional(),name:Y.describe("name must be a non-empty string"),type:q.literal("school").optional(),identifier:Y.optional(),parent:$.optional(),metadata:J}).strict(),aq=q.object({sourcedId:Y.describe("sourcedId must be a non-empty string"),status:V,title:Y.describe("title must be a non-empty string"),startDate:Q,endDate:Q,type:q.enum(["gradingPeriod","semester","schoolYear","term"]),schoolYear:Y.describe("schoolYear must be a non-empty string"),org:$,parent:$.optional(),children:q.array($).optional(),metadata:J}).strict(),iq=q.object({sourcedId:Y.optional(),title:Y.describe("title must be a non-empty string"),courseComponent:$,resource:$,status:V,metadata:J}).strict(),zq=q.object({sourcedId:Y.optional(),title:Y.describe("title must be a non-empty string"),course:$,status:V,metadata:J}).strict(),eq=q.object({sourcedId:Y.describe("sourcedId must be a non-empty string"),role:q.enum(["student","teacher"]),primary:e.optional(),beginDate:Q.optional(),endDate:Q.optional(),metadata:J}).strict(),nq=q.object({agentSourcedId:Y.describe("agentSourcedId must be a non-empty string")}).strict(),tq=q.object({type:Y.describe("type must be a non-empty string"),username:Y.describe("username must be a non-empty string"),password:q.string().optional(),metadata:J}).strict(),ZH=q.object({sourcedId:Y.describe("sourcedId must be a non-empty string")}).loose(),h=q.object({type:d,subject:L.nullish(),grades:q.array(F).nullish(),language:q.string().nullish(),xp:q.number().nullish(),url:q.url().nullish(),keywords:q.array(q.string()).nullish(),learningObjectiveSet:y.nullish(),lessonType:q.string().nullish()}).passthrough(),uZ=h.extend({type:q.literal("qti"),subType:c,questionType:N.optional(),difficulty:p.optional()}),dZ=h.extend({type:q.literal("text"),format:q.string(),author:q.string().optional(),pageCount:q.number().optional()}),cZ=h.extend({type:q.literal("audio"),duration:q.string().regex(/^\d{2}:\d{2}:\d{2}(\.\d{2})?$/).optional(),format:q.string(),speaker:q.string().optional()}),sZ=h.extend({type:q.literal("video"),duration:q.string().regex(/^\d{2}:\d{2}:\d{2}(\.\d{2})?$/).optional(),captionsAvailable:q.boolean().optional(),format:q.string()}),NZ=h.extend({type:q.literal("interactive"),launchUrl:q.url().optional(),toolProvider:q.string().optional(),instructionalMethod:q.string().optional(),courseIdOnFail:q.string().nullable().optional(),fail_fast:E}),pZ=h.extend({type:q.literal("visual"),format:q.string(),resolution:q.string().optional()}),yZ=h.extend({type:q.literal("course-material"),subType:s,author:q.string().optional(),format:q.string(),instructionalMethod:q.string().optional()}),EZ=h.extend({type:q.literal("assessment-bank"),resources:q.array(q.string())}),gZ=q.discriminatedUnion("type",[uZ,dZ,cZ,sZ,NZ,pZ,yZ,EZ]),qH=q.object({sourcedId:Y.optional(),title:Y.describe("title must be a non-empty string"),vendorResourceId:Y.describe("vendorResourceId must be a non-empty string"),roles:q.array(q.enum(["primary","secondary"])).optional(),importance:q.enum(["primary","secondary"]).optional(),vendorId:q.string().optional(),applicationId:q.string().optional(),status:V.optional(),metadata:gZ.nullable().optional()}).strict(),mZ=q.object({url:Y.describe("courseStructure.url must be a non-empty string"),skillCode:Y.describe("courseStructure.skillCode must be a non-empty string"),lessonCode:Y.describe("courseStructure.lessonCode must be a non-empty string"),title:Y.describe("courseStructure.title must be a non-empty string"),"unit-title":Y.describe("courseStructure.unit-title must be a non-empty string"),status:Y.describe("courseStructure.status must be a non-empty string"),xp:q.number()}).loose(),HH=q.object({course:q.object({sourcedId:Y.describe("course.sourcedId must be a non-empty string").optional(),title:Y.describe("course.title must be a non-empty string"),org:$,status:V,metadata:J}).strict(),courseStructure:q.record(q.string(),mZ)}).strict(),SZ=q.object({student:$}).loose(),KH=q.array(SZ).min(1,"results must have at least one item");import{z as K}from"zod/v4";var W=K.string().trim().min(1),oZ=K.enum(["edulastic","mastery-track"]),rZ=K.enum(["powerpath-100","quiz","test-out","placement","unit-test","alpha-read-article"]),t=K.array(F),ZZ=K.record(K.string(),K.unknown()).optional(),qZ=K.object({courseId:W,lessonTitle:W.optional(),launchUrl:K.url().optional(),toolProvider:oZ,unitTitle:W.optional(),courseComponentSourcedId:W.optional(),vendorId:W.optional(),description:W.optional(),resourceMetadata:ZZ.nullable().optional(),grades:t}),_H=qZ.extend({lessonType:K.literal("test-out"),xp:K.number()}),$H=qZ.extend({lessonType:K.literal("placement"),courseIdOnFail:W.optional(),xp:K.number().optional()});var n=K.object({courseId:W,lessonType:rZ,lessonTitle:W.optional(),unitTitle:W.optional(),courseComponentSourcedId:W.optional(),resourceMetadata:ZZ.nullable().optional(),xp:K.number().optional(),grades:t.optional(),courseIdOnFail:W.optional()}),wH=K.union([n.extend({testType:K.literal("qti"),qti:K.object({url:K.url(),title:W.optional(),metadata:K.record(K.string(),K.unknown()).optional()})}),n.extend({testType:K.literal("assessment-bank"),assessmentBank:K.object({resources:K.array(K.object({url:K.url(),title:W.optional(),metadata:K.record(K.string(),K.unknown()).optional()}))})})]),JH=K.object({student:W,lesson:W}),VH=K.object({student:W,lesson:W}),xH=K.object({courseId:W,userId:W,classId:W.optional()}),v=K.object({type:K.enum(["component","resource"]),id:W}),aZ=K.union([K.object({type:K.literal("set-skipped"),payload:K.object({target:v,value:K.boolean()})}),K.object({type:K.literal("add-custom-resource"),payload:K.object({resource_id:W,parent_component_id:W,skipped:K.boolean().optional()})}),K.object({type:K.literal("move-item-before"),payload:K.object({target:v,reference_id:W})}),K.object({type:K.literal("move-item-after"),payload:K.object({target:v,reference_id:W})}),K.object({type:K.literal("move-item-to-start"),payload:K.object({target:v})}),K.object({type:K.literal("move-item-to-end"),payload:K.object({target:v})}),K.object({type:K.literal("change-item-parent"),payload:K.object({target:v,new_parent_id:W,position:K.enum(["start","end"]).optional()})})]),FH=K.object({operation:K.array(aZ),reason:W.optional()}),LH=K.object({studentId:W,componentResourceId:W,result:K.object({status:K.enum(["active","tobedeleted"]),metadata:K.record(K.string(),K.unknown()).optional(),score:K.number().optional(),textScore:W.optional(),scoreDate:W,scorePercentile:K.number().optional(),scoreStatus:T,comment:W.optional(),learningObjectiveSet:K.array(K.object({source:W,learningObjectiveResults:K.array(K.object({learningObjectiveId:W,score:K.number().optional(),textScore:W.optional()}))})).optional(),inProgress:W.optional(),incomplete:W.optional(),late:W.optional(),missing:W.optional()})}),PH=K.object({student:W,lesson:W,applicationName:W.optional(),testId:W.optional(),skipCourseEnrollment:K.boolean().optional()}),UH=K.object({student:W,subject:L}),QH=K.object({student:W,lesson:W}),jH=K.object({userId:W}),AH=K.object({userId:W,subject:K.enum(["Math","Reading","Language","Science"])}),BH=K.object({student:W,subject:L,grade:F,testName:W.optional()}),GH=K.object({testName:W}),iZ=K.object({student:W,subject:L,grade:F,testName:W.optional()}),hH=K.object({items:K.array(iZ)}),OH=K.object({spreadsheetUrl:K.url(),sheet:W}),vH=K.object({student:W,status:K.enum(["assigned","in_progress","completed","failed","expired","cancelled"]).optional(),subject:W.optional(),grade:F.optional(),limit:K.number().int().positive().max(3000).optional(),offset:K.number().int().nonnegative().optional()}),IH=K.object({student:W.optional(),status:K.enum(["assigned","in_progress","completed","failed","expired","cancelled"]).optional(),subject:W.optional(),grade:F.optional(),limit:K.number().int().positive().max(3000).optional(),offset:K.number().int().nonnegative().optional()}),CH=K.object({student:W,question:W,response:K.union([W,K.array(W)]).optional(),responses:K.record(K.string(),K.union([W,K.array(W)])).optional(),lesson:W}),DH=K.object({student:W,lesson:W,attempt:K.number().int().positive().optional()}),kH=K.object({student:W,lesson:W}),fH=K.object({student:W,lesson:W}),MH=K.object({student:W,lesson:W.optional(),finalized:K.boolean().optional(),toolProvider:W.optional(),attempt:K.number().int().positive().optional()}),lH=K.object({student:W,lesson:W,applicationName:W.optional()}),bH=K.object({student:W,subject:L}),TH=K.object({status:K.enum(["active","tobedeleted"]).optional()});import{z as Z}from"zod/v4";var HZ=Z.enum(["choice","text-entry","extended-text","inline-choice","match","order","associate","select-point","graphic-order","graphic-associate","graphic-gap-match","hotspot","hottext","slider","drawing","media","upload"]),f=Z.enum(["single","multiple","ordered","record"]),M=Z.enum(["identifier","boolean","integer","float","string","point","pair","directedPair","duration","file","uri"]),zZ=Z.enum(["easy","medium","hard"]),eZ=Z.enum(["linear","nonlinear"]),nZ=Z.enum(["individual","simultaneous"]),l=Z.enum(["show","hide"]),KZ=Z.enum(["test","item","stimulus"]),cH=Z.enum(["QUESTION","LESSON"]),tZ=Z.object({value:Z.array(Z.string())}).strict(),WZ=Z.object({identifier:Z.string().min(1),cardinality:f,baseType:M.optional(),correctResponse:tZ}).strict(),XZ=Z.object({identifier:Z.string().min(1),cardinality:f,baseType:M.optional()}).strict(),YZ=Z.object({identifier:Z.string().min(1),cardinality:f.optional(),baseType:M,normalMaximum:Z.number().optional(),normalMinimum:Z.number().optional(),defaultValue:Z.object({value:Z.unknown().optional()}).strict().optional()}).strict(),Zq=Z.object({outcomeIdentifier:Z.string().min(1),variableIdentifier:Z.string().min(1)}).strict(),_Z=Z.object({templateType:Z.enum(["match_correct","map_response"]),responseDeclarationIdentifier:Z.string().min(1),outcomeIdentifier:Z.string().min(1),correctResponseIdentifier:Z.string().min(1),incorrectResponseIdentifier:Z.string().min(1),inlineFeedback:Zq.optional()}).strict(),qq=Z.object({source:Z.string().min(1),learningObjectiveIds:Z.array(Z.string())}).strict(),b=Z.object({subject:Z.string().optional(),grade:F.optional(),difficulty:zZ.optional(),learningObjectiveSet:Z.array(qq).optional()}).loose(),$Z=Z.object({outcomeIdentifier:Z.string().min(1),identifier:Z.string().min(1),showHide:l,content:Z.string(),title:Z.string()}).strict(),wZ=Z.object({outcomeIdentifier:Z.string().min(1),identifier:Z.string().min(1),showHide:l,content:Z.string(),class:Z.array(Z.string())}).strict(),JZ=Z.object({outcomeIdentifier:Z.string().min(1),identifier:Z.string().min(1),showHide:l,content:Z.string(),class:Z.array(Z.string())}).strict(),VZ=Z.object({href:Z.string().min(1),type:Z.string().min(1)}).strict(),xZ=Z.object({id:Z.string().min(1),support:Z.string(),content:Z.string()}).strict(),sH=Z.object({page:Z.number().int().positive().optional(),limit:Z.number().int().positive().optional(),sort:Z.string().optional(),order:Z.enum(["asc","desc"]).optional()}).strict(),Hq=Z.object({format:Z.string().pipe(Z.literal("xml")),xml:Z.string().min(1),metadata:b.optional()}).strict(),Kq=Z.object({identifier:Z.string().min(1),title:Z.string().min(1),type:HZ,qtiVersion:Z.string().optional(),timeDependent:Z.boolean().optional(),adaptive:Z.boolean().optional(),responseDeclarations:Z.array(WZ).optional(),outcomeDeclarations:Z.array(XZ).optional(),responseProcessing:_Z.optional(),metadata:b.optional(),modalFeedback:Z.array($Z).optional(),feedbackInline:Z.array(wZ).optional(),feedbackBlock:Z.array(JZ).optional()}).strict(),NH=Z.union([Hq,Kq]),pH=Z.object({identifier:Z.string().min(1).optional(),title:Z.string().min(1),type:HZ,qtiVersion:Z.string().optional(),timeDependent:Z.boolean().optional(),adaptive:Z.boolean().optional(),responseDeclarations:Z.array(WZ).optional(),outcomeDeclarations:Z.array(XZ).optional(),responseProcessing:_Z.optional(),metadata:b.optional(),modalFeedback:Z.array($Z).optional(),feedbackInline:Z.array(wZ).optional(),feedbackBlock:Z.array(JZ).optional(),rawXml:Z.string(),content:Z.record(Z.string(),Z.unknown())}).strict(),yH=Z.object({response:Z.union([Z.string(),Z.array(Z.string())])}).strict(),FZ=Z.object({identifier:Z.string().min(1),href:Z.union([Z.string(),Z.array(Z.string()),Z.array(Z.array(Z.string()))]).optional(),sequence:Z.number().optional()}).strict(),Wq=Z.object({identifier:Z.string().min(1),title:Z.string().min(1),visible:Z.boolean(),required:Z.boolean().optional(),fixed:Z.boolean().optional(),sequence:Z.number().optional(),"qti-assessment-item-ref":Z.array(FZ).optional()}).strict(),LZ=Z.object({identifier:Z.string().min(1),navigationMode:Z.string().pipe(eZ),submissionMode:Z.string().pipe(nZ),"qti-assessment-section":Z.array(Wq)}).strict(),EH=Z.object({items:Z.array(FZ).min(1)}).strict(),gH=Z.object({metadata:Z.record(Z.string(),Z.unknown()).optional()}).strict(),mH=Z.object({identifier:Z.string().min(1),title:Z.string().min(1),qtiVersion:Z.string().optional(),toolName:Z.string().optional(),toolVersion:Z.string().optional(),timeLimit:Z.number().optional(),maxAttempts:Z.number().optional(),toolsEnabled:Z.record(Z.string(),Z.boolean()).optional(),metadata:Z.record(Z.string(),Z.unknown()).optional(),"qti-test-part":Z.array(LZ),"qti-outcome-declaration":Z.array(YZ).optional()}).strict(),SH=Z.object({identifier:Z.string().min(1).optional(),title:Z.string().min(1),qtiVersion:Z.string().optional(),toolName:Z.string().optional(),toolVersion:Z.string().optional(),timeLimit:Z.number().optional(),maxAttempts:Z.number().optional(),toolsEnabled:Z.record(Z.string(),Z.boolean()).optional(),metadata:Z.record(Z.string(),Z.unknown()).optional(),"qti-test-part":Z.array(LZ),"qti-outcome-declaration":Z.array(YZ).optional()}).strict(),oH=Z.object({identifier:Z.string().min(1),title:Z.string().min(1),label:Z.string().optional(),language:Z.string().optional(),stylesheet:VZ.optional(),content:Z.string(),catalogInfo:Z.array(xZ).optional(),toolName:Z.string().optional(),toolVersion:Z.string().optional(),metadata:Z.record(Z.string(),Z.unknown()).optional()}).strict(),rH=Z.object({identifier:Z.string().min(1).optional(),title:Z.string().min(1),label:Z.string().optional(),language:Z.string().optional(),stylesheet:VZ.optional(),content:Z.string(),catalogInfo:Z.array(xZ).optional(),toolName:Z.string().optional(),toolVersion:Z.string().optional(),metadata:Z.record(Z.string(),Z.unknown()).optional()}).strict(),aH=Z.object({xml:Z.string().optional(),schema:KZ,entityId:Z.string().optional()}).strict(),iH=Z.object({xml:Z.array(Z.string()),schema:KZ,entityIds:Z.array(Z.string())}).strict(),zH=Z.object({questionId:Z.string().optional(),userId:Z.string().min(1),feedback:Z.string().min(1),lessonId:Z.string().min(1),humanApproved:Z.boolean().optional()}).strict();export{L as a,F as b,Vq as c};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{H as w,J as S,K as u,L as i,M as B}from"./chunk-3ew9vn2d.js";import{N as x,P as f}from"./chunk-edk3nfj7.js";var X=null,I=!1,T=!1;function E(K){let Z=K.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*");return new RegExp(`^${Z}$`)}function n(){if(X!==null)return;if(X=[],typeof process>"u"||!process.env?.DEBUG){T=!1;return}T=!0;let K=process.env.DEBUG.trim();if(K==="1"||K==="true"||K==="*"){I=!0;return}let Q=K.split(",").map(($)=>$.trim()).filter(Boolean);for(let $ of Q)if($.startsWith("-"))X.push({regex:E($.slice(1)),exclude:!0});else X.push({regex:E($),exclude:!1});if(!X.some(($)=>!$.exclude)&&X.length>0)I=!0}function h(K){if(n(),!T)return!0;if(I){if(K){for(let Q of X)if(Q.exclude&&Q.regex.test(K))return!1}return!0}if(!K)return!1;for(let Q of X)if(Q.exclude&&Q.regex.test(K))return!1;for(let Q of X)if(!Q.exclude&&Q.regex.test(K))return!0;return!1}function k(){return typeof globalThis<"u"&&"window"in globalThis}function _(){if(k())return"browser";if(typeof process<"u"&&process.env){if(process.env.CI||process.env.GITHUB_ACTIONS||process.env.GITLAB_CI||process.env.CIRCLECI||process.env.JENKINS_URL||process.env.BUILDKITE)return"ci"}return"terminal"}var D;if(!k())try{D=(await import("./chunk-c8pw96sp.js")).inspect}catch{}var Y={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",yellow:"\x1B[33m",blue:"\x1B[34m",cyan:"\x1B[36m"};function a(K){switch(K){case"debug":return Y.blue;case"info":return Y.cyan;case"warn":return Y.yellow;case"error":return Y.red}}function s(K){switch(K){case"debug":return console.debug;case"info":return console.info;case"warn":return console.warn;case"error":return console.error}}function o(K){if(D)return D(K,{depth:null,colors:!0,breakLength:80,compact:!1});return JSON.stringify(K,null,2)}var A=(K)=>{let Q=a(K.level),Z=s(K.level),$=K.level.toUpperCase().padEnd(5),z=K.timestamp.toISOString().replace(/\.\d{3}Z$/,""),W=`${Y.dim}[${z}]${Y.reset}`,F=`${Q}${$}${Y.reset}`,H=K.scope?`${Y.bold}[${K.scope}]${Y.reset} `:"",j=`${W} ${F} ${H}${K.message}`;if(K.context&&Object.keys(K.context).length>0)Z(j,o(K.context));else Z(j)};var t={debug:"[DEBUG]",info:"[INFO]",warn:"[WARN]",error:"[ERROR]"};function r(K){return Object.entries(K).map(([Q,Z])=>`${Q}=${e(Z)}`).join(" ")}function e(K){if(typeof K==="string")return K;if(typeof K==="number")return String(K);if(typeof K==="boolean")return String(K);if(K===null)return"null";if(K===void 0)return"undefined";return JSON.stringify(K)}var M=(K)=>{let Q=[];if(Q.push(K.timestamp.toISOString()),Q.push(t[K.level]),K.scope)Q.push(`[${K.scope}]`);if(Q.push(K.message),K.context&&Object.keys(K.context).length>0)Q.push(r(K.context));console.log(Q.join(" "))};var V=(K)=>{let Q={timestamp:K.timestamp.toISOString(),level:K.level,...K.scope&&{scope:K.scope},msg:K.message};if(K.context&&Object.keys(K.context).length>0)Object.assign(Q,K.context);console.log(JSON.stringify(Q))};var KK={debug:"color: gray",info:"color: #0ea5e9",warn:"color: #f59e0b",error:"color: #ef4444; font-weight: bold"},QK={debug:"log",info:"info",warn:"warn",error:"error"},q=(K)=>{let Q=QK[K.level],Z=KK[K.level],z=`%c${K.scope?`[${K.scope}]`:""} ${K.message}`;if(K.context&&Object.keys(K.context).length>0)console[Q](z,Z,K.context);else console[Q](z,Z)};var b=["debug","info","warn","error"];function ZK(K){switch(K){case"terminal":return A;case"ci":return M;case"production":return V;case"browser":return q;case"test":return()=>{}}}function $K(){if(typeof process<"u"&&process.env?.DEBUG)return"debug";return"info"}function zK(K,Q){return b.indexOf(K)>=b.indexOf(Q)}class G{scope;minLevel;environment;formatter;defaultContext;constructor(K={}){this.scope=K.scope,this.minLevel=K.minLevel??$K(),this.defaultContext=K.defaultContext??{},this.environment=K.environment??_(),this.formatter=ZK(this.environment)}child(K){let Q=this.scope?`${this.scope}:${K}`:K;return new G({scope:Q,minLevel:this.minLevel,environment:this.environment,defaultContext:{...this.defaultContext}})}withContext(K){return new G({scope:this.scope,minLevel:this.minLevel,environment:this.environment,defaultContext:{...this.defaultContext,...K}})}debug(K,Q){this.log("debug",K,Q)}info(K,Q){this.log("info",K,Q)}warn(K,Q){this.log("warn",K,Q)}error(K,Q){this.log("error",K,Q)}log(K,Q,Z){if(K==="debug"&&!h(this.scope))return;if(!zK(K,this.minLevel))return;let $={level:K,message:Q,scope:this.scope,context:Z||Object.keys(this.defaultContext).length>0?{...this.defaultContext,...Z}:void 0,timestamp:new Date};this.formatter($)}}function P(K={}){return new G(K)}var R,L,WK={debug(){},info(){},warn(){},error(){}};function XK(){try{let K=typeof process>"u"?void 0:process.env.DEBUG;return K==="1"||K==="true"}catch{return!1}}var U=new Map;function YK(K,Q){let Z=`[${Q}]`;return{debug:(...$)=>K.debug(`${Z} ${$[0]}`,...$.slice(1)),info:(...$)=>K.info(`${Z} ${$[0]}`,...$.slice(1)),warn:(...$)=>K.warn(`${Z} ${$[0]}`,...$.slice(1)),error:(...$)=>K.error(`${Z} ${$[0]}`,...$.slice(1))}}function O(K){let Q=U.get(K);if(Q)return Q;if(R)Q=YK(R,K);else{let Z=L??(XK()?"debug":"warn");if(Z==="silent")Q=WK;else Q=P({scope:K,minLevel:Z})}return U.set(K,Q),Q}function hK(K){R=K.logger,L=K.logLevel,U.clear()}function v(K){let Q=`timeback:${K}`;return{debug(Z,...$){O(Q).debug(Z,...$)},info(Z,...$){O(Q).info(Z,...$)},warn(Z,...$){O(Q).warn(Z,...$)},error(Z,...$){O(Q).error(Z,...$)}}}var J=v("sso"),N=v("oidc");var m=new Map;async function C(K){let Q=m.get(K);if(Q)return Q;let Z=`${K}/.well-known/openid-configuration`,$=await fetch(Z);if(!$.ok)throw N.error("Discovery fetch failed",{status:$.status}),Error(`Failed to fetch OIDC discovery: ${$.statusText}`);let z=await $.json();return N.debug("Fetched OIDC discovery document",{authEndpoint:z.authorization_endpoint,tokenEndpoint:z.token_endpoint}),m.set(K,z),z}function y(K){switch(K){case"production":return"https://cognito-idp.us-east-1.amazonaws.com/us-east-1_3uhuoRM3R";case"staging":return"https://cognito-idp.us-east-1.amazonaws.com/us-east-1_5EUwTP9XD";case"local":throw Error("Local environment is not yet supported for OIDC")}}async function d(K){let Q=await C(K.issuer),Z=new URL(Q.authorization_endpoint);return Z.searchParams.set("response_type","code"),Z.searchParams.set("client_id",K.clientId),Z.searchParams.set("redirect_uri",K.redirectUri),Z.searchParams.set("scope","openid profile email"),Z.searchParams.set("state",K.state),Z.toString()}async function bK(K){let Q=await C(K.issuer),Z=await fetch(Q.token_endpoint,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"authorization_code",client_id:K.clientId,client_secret:K.clientSecret,code:K.code,redirect_uri:K.redirectUri})});if(!Z.ok){let z=await Z.text();throw N.error("Token exchange failed",{status:Z.status,body:z}),Error(`Token exchange failed: ${Z.status} ${z}`)}let $=await Z.json();return N.debug("Received tokens from IdP",{expiresIn:$.expires_in}),$}async function LK(K){let Q=await C(K.issuer),Z=await fetch(Q.userinfo_endpoint,{headers:{Authorization:`Bearer ${K.accessToken}`}});if(!Z.ok)throw Error(`UserInfo request failed: ${Z.statusText}`);return Z.json()}function p(K,Q,Z,$){return{error:K,errorCode:Q,state:Z,req:$,redirect:S,json:w}}function FK(K){try{return i(K)}catch{J.warn("Failed to decode state");return}}function iK(K,Q,Z,$,z){let W=Q.searchParams.get("error_description");J.error("IdP returned error",{error:K,description:W});let F=Error(W??K);if(z)return z(p(F,K,Z,$));return w({error:K},400)}function pK(K,Q,Z){J.error("Missing authorization code in callback");let $=Error("Missing authorization code");if(Z)return Z(p($,"missing_code",K,Q));return w({error:"Missing authorization code"},400)}async function gK(K){let{req:Q,env:Z,clientId:$,buildState:z}=K,W=K.issuer??y(Z),F=new URL(Q.url),H=K.redirectUri;if(!H){let l=F.pathname.replace(B.IDENTITY.SIGNIN,"");H=`${F.origin}${l}${B.IDENTITY.CALLBACK}`}J.debug("SSO sign-in initiated",{env:Z,issuer:W,clientId:$,redirectUri:H});let j=z?z({req:Q,url:F}):{},g=u(j),c=await d({issuer:W,clientId:$,redirectUri:H,state:g});return S(c)}function cK(K){let Q=new URL(K.url),Z=Q.searchParams.get("code"),$=Q.searchParams.get("error"),z=Q.searchParams.get("state");J.debug("Received callback from IdP",{hasCode:!!Z,error:$});let W=z?FK(z):void 0;return{url:Q,code:Z,errorParam:$,state:W}}function lK(K,Q){if(Q)return Q;let Z=K.pathname.replace(B.IDENTITY.CALLBACK,"");return`${K.origin}${Z}${B.IDENTITY.CALLBACK}`}
|
|
2
|
+
export{hK as m,v as n,J as o,y as p,bK as q,LK as r,p as s,iK as t,pK as u,gK as v,cK as w,lK as x};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
export{M as
|
|
1
|
+
import{M as F}from"./chunk-3ew9vn2d.js";function M(j){let g=j.trim();if(g==="")return"/";let A=g.indexOf("?");if(A===-1)return g;let L=g.slice(0,A);if(L==="")return"/";return L}function X(j){let g=M(j);if(g!==""&&!g.startsWith("/"))g=`/${g}`;if(g==="/"||g==="")return"";if(g.endsWith("/"))return g.slice(0,-1);return g}function Z(j){let g=j.method.toUpperCase(),A=M(j.pathname),L=j.callbackPath?M(j.callbackPath):void 0;if(L&&A===L)return g==="GET"?"identity.callback":null;let N=j.basePath,Q=N!==void 0,J=Q?X(N):void 0,V=(G)=>{if(g==="GET"){if(G===F.IDENTITY.SIGNIN)return"identity.signIn";if(G===F.IDENTITY.CALLBACK)return"identity.callback";if(G===F.IDENTITY.SIGNOUT)return"identity.signOut";if(G===F.USER.ME)return"user.me";if(G===F.USER.VERIFY)return"user.verify"}if(g==="POST"){if(G===F.ACTIVITY_HEARTBEAT)return"activity.heartbeat";if(G===F.ACTIVITY_SUBMIT)return"activity.submit"}return null};if(Q&&J!==void 0){if(J!==""&&A===J)return null;if(J!==""&&!A.startsWith(`${J}/`))return null;let G=J===""?A:A.slice(J.length),W=G.startsWith("/")?G:`/${G}`;return V(W)}if(g==="GET"){if(A.endsWith(F.IDENTITY.SIGNIN))return"identity.signIn";if(A.endsWith(F.IDENTITY.CALLBACK))return"identity.callback";if(A.endsWith(F.IDENTITY.SIGNOUT))return"identity.signOut";if(A.endsWith(F.USER.ME))return"user.me";if(A.endsWith(F.USER.VERIFY))return"user.verify"}if(g==="POST"){if(A.endsWith(F.ACTIVITY_HEARTBEAT))return"activity.heartbeat";if(A.endsWith(F.ACTIVITY_SUBMIT))return"activity.submit"}return null}function _(j){return"handle"in j?j.handle:j}function $(j){return"activity"in j}function C(j){return"user"in j}
|
|
2
|
+
export{M as y,Z as z,_ as A,$ as B,C};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import"./chunk-edk3nfj7.js";var F=/%[sdj%]/g;function D(e,...t){if(!P(e)){var n=[e];for(var r=0;r<t.length;r++)n.push(l(t[r]));return n.join(" ")}var r=0,s=t.length,o=String(e).replace(F,function(f){if(f==="%%")return"%";if(r>=s)return f;switch(f){case"%s":return String(t[r++]);case"%d":return Number(t[r++]);case"%j":try{return JSON.stringify(t[r++])}catch(c){return"[Circular]"}default:return f}});for(var i=t[r];r<s;i=t[++r])if(w(i)||!y(i))o+=" "+i;else o+=" "+l(i);return o}function X(e,t){if(typeof process>"u"||process?.noDeprecation===!0)return e;var n=!1;function r(...s){if(!n){if(process.throwDeprecation)throw Error(t);else if(process.traceDeprecation)console.trace(t);else console.error(t);n=!0}return e.apply(this,...s)}return r}var Y=((e={},t={},n)=>((n=typeof process<"u"&&!1)&&(n=n.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase()),t=new RegExp("^"+n+"$","i"),(r)=>{if(r=r.toUpperCase(),!e[r])if(t.test(r))e[r]=function(...s){console.error("%s: %s",r,pid,D.apply(null,...s))};else e[r]=function(){};return e[r]}))(),l=((e)=>(e.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},e.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},e.custom=Symbol.for("nodejs.util.inspect.custom"),e))(function(e,t,...n){var r={seen:[],stylize:H};if(n.length>=1)r.depth=n[0];if(n.length>=2)r.colors=n[1];if(C(t))r.showHidden=t;else if(t)T(r,t);if(p(r.showHidden))r.showHidden=!1;if(p(r.depth))r.depth=2;if(p(r.colors))r.colors=!1;if(r.colors)r.stylize=R;return m(r,e,r.depth)});function R(e,t){var n=l.styles[t];if(n)return"\x1B["+l.colors[n][0]+"m"+e+"\x1B["+l.colors[n][1]+"m";else return e}function H(e,t){return e}function J(e){var t={};return e.forEach(function(n,r){t[n]=!0}),t}function m(e,t,n){if(e.customInspect&&t&&O(t.inspect)&&t.inspect!==l&&!(t.constructor&&t.constructor.prototype===t)){var r=t.inspect(n,e);if(!P(r))r=m(e,r,n);return r}var s=_(e,t);if(s)return s;var o=Object.keys(t),i=J(o);if(e.showHidden)o=Object.getOwnPropertyNames(t);if(g(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return b(t);if(o.length===0){if(O(t)){var f=t.name?": "+t.name:"";return e.stylize("[Function"+f+"]","special")}if(h(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(E(t))return e.stylize(Date.prototype.toString.call(t),"date");if(g(t))return b(t)}var c="",u=!1,a=["{","}"];if(M(t))u=!0,a=["[","]"];if(O(t)){var $=t.name?": "+t.name:"";c=" [Function"+$+"]"}if(h(t))c=" "+RegExp.prototype.toString.call(t);if(E(t))c=" "+Date.prototype.toUTCString.call(t);if(g(t))c=" "+b(t);if(o.length===0&&(!u||t.length==0))return a[0]+c+a[1];if(n<0)if(h(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");else return e.stylize("[Object]","special");e.seen.push(t);var d;if(u)d=B(e,t,n,i,o);else d=o.map(function(A){return S(e,t,n,i,A,u)});return e.seen.pop(),U(d,c,a)}function _(e,t){if(p(t))return e.stylize("undefined","undefined");if(P(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}if(G(t))return e.stylize(""+t,"number");if(C(t))return e.stylize(""+t,"boolean");if(w(t))return e.stylize("null","null")}function b(e){return"["+Error.prototype.toString.call(e)+"]"}function B(e,t,n,r,s){var o=[];for(var i=0,f=t.length;i<f;++i)if(k(t,String(i)))o.push(S(e,t,n,r,String(i),!0));else o.push("");return s.forEach(function(c){if(!c.match(/^\d+$/))o.push(S(e,t,n,r,c,!0))}),o}function S(e,t,n,r,s,o){var i,f,c;if(c=Object.getOwnPropertyDescriptor(t,s)||{value:t[s]},c.get)if(c.set)f=e.stylize("[Getter/Setter]","special");else f=e.stylize("[Getter]","special");else if(c.set)f=e.stylize("[Setter]","special");if(!k(r,s))i="["+s+"]";if(!f)if(e.seen.indexOf(c.value)<0){if(w(n))f=m(e,c.value,null);else f=m(e,c.value,n-1);if(f.indexOf(`
|
|
2
|
+
`)>-1)if(o)f=f.split(`
|
|
3
|
+
`).map(function(u){return" "+u}).join(`
|
|
4
|
+
`).slice(2);else f=`
|
|
5
|
+
`+f.split(`
|
|
6
|
+
`).map(function(u){return" "+u}).join(`
|
|
7
|
+
`)}else f=e.stylize("[Circular]","special");if(p(i)){if(o&&s.match(/^\d+$/))return f;if(i=JSON.stringify(""+s),i.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/))i=i.slice(1,-1),i=e.stylize(i,"name");else i=i.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),i=e.stylize(i,"string")}return i+": "+f}function U(e,t,n){var r=0,s=e.reduce(function(o,i){if(r++,i.indexOf(`
|
|
8
|
+
`)>=0)r++;return o+i.replace(/\u001b\[\d\d?m/g,"").length+1},0);if(s>60)return n[0]+(t===""?"":t+`
|
|
9
|
+
`)+" "+e.join(`,
|
|
10
|
+
`)+" "+n[1];return n[0]+t+" "+e.join(", ")+" "+n[1]}var v=()=>{};function M(e){return Array.isArray(e)}function C(e){return typeof e==="boolean"}function w(e){return e===null}function x(e){return e==null}function G(e){return typeof e==="number"}function P(e){return typeof e==="string"}function ee(e){return typeof e==="symbol"}function p(e){return e===void 0}function h(e){return y(e)&&z(e)==="[object RegExp]"}function y(e){return typeof e==="object"&&e!==null}function E(e){return y(e)&&z(e)==="[object Date]"}function g(e){return y(e)&&(z(e)==="[object Error]"||e instanceof Error)}function O(e){return typeof e==="function"}function te(e){return e===null||typeof e==="boolean"||typeof e==="number"||typeof e==="string"||typeof e==="symbol"||typeof e>"u"}function re(e){return e instanceof Buffer}function z(e){return Object.prototype.toString.call(e)}function j(e){return e<10?"0"+e.toString(10):e.toString(10)}var Z=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function I(){var e=new Date,t=[j(e.getHours()),j(e.getMinutes()),j(e.getSeconds())].join(":");return[e.getDate(),Z[e.getMonth()],t].join(" ")}function L(...e){console.log("%s - %s",I(),D.apply(null,e))}function V(e,t){if(t)e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}function T(e,t){if(!t||!y(t))return e;var n=Object.keys(t),r=n.length;while(r--)e[n[r]]=t[n[r]];return e}function k(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var W=((e)=>(e.custom=Symbol.for("nodejs.util.promisify.custom"),e))(function(e){if(typeof e!=="function")throw TypeError('The "original" argument must be of type Function');if(kCustomPromisifiedSymbol&&e[kCustomPromisifiedSymbol]){var t=e[kCustomPromisifiedSymbol];if(typeof t!=="function")throw TypeError('The "nodejs.util.promisify.custom" argument must be of type Function');return Object.defineProperty(t,kCustomPromisifiedSymbol,{value:t,enumerable:!1,writable:!1,configurable:!0}),t}function t(...n){var r,s,o=new Promise(function(i,f){r=i,s=f});n.push(function(i,f){if(i)s(i);else r(f)});try{e.apply(this,n)}catch(i){s(i)}return o}if(Object.setPrototypeOf(t,Object.getPrototypeOf(e)),kCustomPromisifiedSymbol)Object.defineProperty(t,kCustomPromisifiedSymbol,{value:t,enumerable:!1,writable:!1,configurable:!0});return Object.defineProperties(t,Object.getOwnPropertyDescriptors(e))});function N(e,t){if(!e){var n=Error("Promise was rejected with a falsy value");n.reason=e,e=n}return t(e)}function q(e){if(typeof e!=="function")throw TypeError('The "original" argument must be of type Function');function t(...n){var r=n.pop();if(typeof r!=="function")throw TypeError("The last argument must be of type Function");var s=this,o=function(...i){return r.apply(s,...i)};e.apply(this,n).then(function(i){process.nextTick(o.bind(null,null,i))},function(i){process.nextTick(N.bind(null,i,o))})}return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)),t}var{TextEncoder:K,TextDecoder:Q}=globalThis,ne={TextEncoder:K,TextDecoder:Q,promisify:W,log:L,inherits:V,_extend:T,callbackifyOnRejected:N,callbackify:q};export{v as types,W as promisify,L as log,p as isUndefined,ee as isSymbol,P as isString,h as isRegExp,te as isPrimitive,y as isObject,G as isNumber,x as isNullOrUndefined,w as isNull,O as isFunction,g as isError,E as isDate,re as isBuffer,C as isBoolean,M as isArray,l as inspect,V as inherits,D as format,X as deprecate,ne as default,Y as debuglog,N as callbackifyOnRejected,q as callbackify,T as _extend,K as TextEncoder,Q as TextDecoder};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var g=Object.create;var{getPrototypeOf:h,defineProperty:f,getOwnPropertyNames:i}=Object;var j=Object.prototype.hasOwnProperty;var k=(a,c,b)=>{b=a!=null?g(h(a)):{};let d=c||!a||!a.__esModule?f(b,"default",{value:a,enumerable:!0}):b;for(let e of i(a))if(!j.call(d,e))f(d,e,{get:()=>a[e],enumerable:!0});return d};var l=(a,c)=>{for(var b in c)f(a,b,{get:c[b],enumerable:!0,configurable:!0,set:(d)=>c[b]=()=>d})};var m=((a)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(c,b)=>(typeof require<"u"?require:c)[b]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});
|
|
2
|
+
export{k as N,l as O,m as P};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as _}from"./chunk-6b0ppq9d.js";import{F as V}from"./chunk-3ew9vn2d.js";import{TimebackClient as P}from"@timeback/core";function Z(...x){return x.map((Q)=>Q?.trim()).filter((Q)=>Boolean(Q)).join(" ")||void 0}function M(x){let $=x.lastIndexOf("@");if($<=0)return"<redacted>";let Q=x.slice(0,$),B=x.slice($+1);return`${Q.slice(0,1)}***@${B}`}var S=_("resolve");class J extends Error{code;constructor(x,$){super(x);this.code=$;this.name="TimebackUserResolutionError"}}function z(x){switch(x.code){case"timeback_user_ambiguous":return 409;case"timeback_user_not_found":return 404;default:return 502}}function L(x){return{sub:x.sub,email:x.email,firstName:x.given_name,lastName:x.family_name,pictureUrl:x.picture}}async function D(x,$){let B=(await x.oneroster.users.list({where:{email:$},limit:2})).data;if(B.length===0)throw S.warn("No Timeback user found for email",{email:M($)}),new J(`No Timeback user found with email: ${$}`,"timeback_user_not_found");if(B.length>1)throw S.error("Multiple Timeback users found for email",{email:M($),count:B.length}),new J(`Multiple Timeback users found with email: ${$}`,"timeback_user_ambiguous");let K=B[0];if(!K.sourcedId)throw new J("Timeback user is missing sourcedId","timeback_user_lookup_failed");return K}async function O(x){let{env:$,apiCredentials:Q,userInfo:B}=x;if(!B.email)throw S.error("Missing email in IdP user info",{sub:B.sub}),new J("IdP did not return an email address, which is required to resolve Timeback identity","missing_email");let K=B.email;S.debug("Resolving Timeback user by email",{email:M(K),env:$});let H=x.client,X=H??new P({env:V($),auth:{clientId:Q.clientId,clientSecret:Q.clientSecret}});try{let G=await D(X,K);return{...{id:G.sourcedId,email:G.email??K,name:Z(G.givenName,G.familyName),school:G.primaryOrg?{id:G.primaryOrg.sourcedId,name:G.primaryOrg.name??G.primaryOrg.sourcedId}:void 0,grade:G.grades?.length?Math.max(...G.grades):void 0},claims:L(B)}}catch(G){if(G instanceof J)throw G;let Y=G instanceof Error?G.message:"Unknown error";throw S.error("Failed to lookup Timeback user",{email:M(K),error:Y}),new J(`Failed to lookup Timeback user: ${Y}`,"timeback_user_lookup_failed")}finally{if(!H)X.close()}}async function F(x){let{email:$,client:Q}=x;S.debug("Looking up Timeback user ID by email",{email:M($)});try{return(await D(Q,$)).sourcedId}catch(B){if(B instanceof J)throw B;let K=B instanceof Error?B.message:"Unknown error";throw S.error("Failed to lookup Timeback user",{email:M($),error:K}),new J(`Failed to lookup Timeback user: ${K}`,"timeback_user_lookup_failed")}}function W(x,$){let Q=x.totalQuestions!==void 0,B=x.correctQuestions!==void 0;if(Q!==B){$.addIssue({code:"custom",message:"totalQuestions and correctQuestions must be provided together."});return}if(Q&&B){let{correctQuestions:K,totalQuestions:H}=x;if(K>H)$.addIssue({code:"custom",message:"correctQuestions cannot exceed totalQuestions."})}}function A(x,$,Q){let B=V(Q),K=$.overrides?.[B]?.sensor??$.sensor??x.sensor;if(!K){let H=$.overrides?.[B]?.launchUrl??$.launchUrl??x.launchUrl;if(H)try{K=new URL(H).origin}catch{}}return K}function N(x,$,Q){if(!$?.onRequestStart&&!$?.onRequestEnd)return Q;return async(B)=>{await $.onRequestStart?.({handler:x});let K=Date.now(),H;try{H=await Q(B)}catch(X){throw await $.onRequestEnd?.({handler:x,durationMs:Date.now()-K,status:500}),X}return await $.onRequestEnd?.({handler:x,durationMs:Date.now()-K,status:H.status}),H}}export{J as f,z as g,O as h,F as i,W as j,A as k,N as l};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{c as Y}from"./chunk-62x5my81.js";import{O as V}from"./chunk-edk3nfj7.js";var{existsSync:ie}=(()=>({}));function b(e){if(typeof e!=="string")throw TypeError("Path must be a string. Received "+JSON.stringify(e))}function R(e,r){var i="",t=0,l=-1,n=0,s;for(var f=0;f<=e.length;++f){if(f<e.length)s=e.charCodeAt(f);else if(s===47)break;else s=47;if(s===47){if(l===f-1||n===1);else if(l!==f-1&&n===2){if(i.length<2||t!==2||i.charCodeAt(i.length-1)!==46||i.charCodeAt(i.length-2)!==46){if(i.length>2){var o=i.lastIndexOf("/");if(o!==i.length-1){if(o===-1)i="",t=0;else i=i.slice(0,o),t=i.length-1-i.lastIndexOf("/");l=f,n=0;continue}}else if(i.length===2||i.length===1){i="",t=0,l=f,n=0;continue}}if(r){if(i.length>0)i+="/..";else i="..";t=2}}else{if(i.length>0)i+="/"+e.slice(l+1,f);else i=e.slice(l+1,f);t=f-l-1}l=f,n=0}else if(s===46&&n!==-1)++n;else n=-1}return i}function E(e,r){var i=r.dir||r.root,t=r.base||(r.name||"")+(r.ext||"");if(!i)return t;if(i===r.root)return i+t;return i+e+t}function d(){var e="",r=!1,i;for(var t=arguments.length-1;t>=-1&&!r;t--){var l;if(t>=0)l=arguments[t];else{if(i===void 0)i=process.cwd();l=i}if(b(l),l.length===0)continue;e=l+"/"+e,r=l.charCodeAt(0)===47}if(e=R(e,!r),r)if(e.length>0)return"/"+e;else return"/";else if(e.length>0)return e;else return"."}function w(e){if(b(e),e.length===0)return".";var r=e.charCodeAt(0)===47,i=e.charCodeAt(e.length-1)===47;if(e=R(e,!r),e.length===0&&!r)e=".";if(e.length>0&&i)e+="/";if(r)return"/"+e;return e}function G(e){return b(e),e.length>0&&e.charCodeAt(0)===47}function $(){if(arguments.length===0)return".";var e;for(var r=0;r<arguments.length;++r){var i=arguments[r];if(b(i),i.length>0)if(e===void 0)e=i;else e+="/"+i}if(e===void 0)return".";return w(e)}function y(e,r){if(b(e),b(r),e===r)return"";if(e=d(e),r=d(r),e===r)return"";var i=1;for(;i<e.length;++i)if(e.charCodeAt(i)!==47)break;var t=e.length,l=t-i,n=1;for(;n<r.length;++n)if(r.charCodeAt(n)!==47)break;var s=r.length,f=s-n,o=l<f?l:f,a=-1,u=0;for(;u<=o;++u){if(u===o){if(f>o){if(r.charCodeAt(n+u)===47)return r.slice(n+u+1);else if(u===0)return r.slice(n+u)}else if(l>o){if(e.charCodeAt(i+u)===47)a=u;else if(u===0)a=0}break}var k=e.charCodeAt(i+u),M=r.charCodeAt(n+u);if(k!==M)break;else if(k===47)a=u}var m="";for(u=i+a+1;u<=t;++u)if(u===t||e.charCodeAt(u)===47)if(m.length===0)m+="..";else m+="/..";if(m.length>0)return m+r.slice(n+a);else{if(n+=a,r.charCodeAt(n)===47)++n;return r.slice(n)}}function z(e){return e}function H(e){if(b(e),e.length===0)return".";var r=e.charCodeAt(0),i=r===47,t=-1,l=!0;for(var n=e.length-1;n>=1;--n)if(r=e.charCodeAt(n),r===47){if(!l){t=n;break}}else l=!1;if(t===-1)return i?"/":".";if(i&&t===1)return"//";return e.slice(0,t)}function h(e,r){if(r!==void 0&&typeof r!=="string")throw TypeError('"ext" argument must be a string');b(e);var i=0,t=-1,l=!0,n;if(r!==void 0&&r.length>0&&r.length<=e.length){if(r.length===e.length&&r===e)return"";var s=r.length-1,f=-1;for(n=e.length-1;n>=0;--n){var o=e.charCodeAt(n);if(o===47){if(!l){i=n+1;break}}else{if(f===-1)l=!1,f=n+1;if(s>=0)if(o===r.charCodeAt(s)){if(--s===-1)t=n}else s=-1,t=f}}if(i===t)t=f;else if(t===-1)t=e.length;return e.slice(i,t)}else{for(n=e.length-1;n>=0;--n)if(e.charCodeAt(n)===47){if(!l){i=n+1;break}}else if(t===-1)l=!1,t=n+1;if(t===-1)return"";return e.slice(i,t)}}function C(e){b(e);var r=-1,i=0,t=-1,l=!0,n=0;for(var s=e.length-1;s>=0;--s){var f=e.charCodeAt(s);if(f===47){if(!l){i=s+1;break}continue}if(t===-1)l=!1,t=s+1;if(f===46){if(r===-1)r=s;else if(n!==1)n=1}else if(r!==-1)n=-1}if(r===-1||t===-1||n===0||n===1&&r===t-1&&r===i+1)return"";return e.slice(r,t)}function U(e){if(e===null||typeof e!=="object")throw TypeError('The "pathObject" argument must be of type Object. Received type '+typeof e);return E("/",e)}function q(e){b(e);var r={root:"",dir:"",base:"",ext:"",name:""};if(e.length===0)return r;var i=e.charCodeAt(0),t=i===47,l;if(t)r.root="/",l=1;else l=0;var n=-1,s=0,f=-1,o=!0,a=e.length-1,u=0;for(;a>=l;--a){if(i=e.charCodeAt(a),i===47){if(!o){s=a+1;break}continue}if(f===-1)o=!1,f=a+1;if(i===46){if(n===-1)n=a;else if(u!==1)u=1}else if(n!==-1)u=-1}if(n===-1||f===-1||u===0||u===1&&n===f-1&&n===s+1){if(f!==-1)if(s===0&&t)r.base=r.name=e.slice(1,f);else r.base=r.name=e.slice(s,f)}else{if(s===0&&t)r.name=e.slice(1,n),r.base=e.slice(1,f);else r.name=e.slice(s,n),r.base=e.slice(s,f);r.ext=e.slice(n,f)}if(s>0)r.dir=e.slice(0,s-1);else if(t)r.dir="/";return r}var K="/",Q=":",le=((e)=>(e.posix=e,e))({resolve:d,normalize:w,isAbsolute:G,join:$,relative:y,_makeLong:z,dirname:H,basename:h,extname:C,format:U,parse:q,sep:K,delimiter:Q,win32:null,posix:null});import{loadConfig as ne}from"c12";var A={};V(A,{isatty:()=>B,default:()=>X,WriteStream:()=>S,ReadStream:()=>T});var B=()=>!1;function S(){throw Error("tty.WriteStream is not implemented for browsers")}function T(){throw Error("tty.ReadStream is not implemented for browsers")}var X={ReadStream:T,WriteStream:S,isatty:B};var{env:c={},argv:W=[],platform:Z=""}=typeof process>"u"?{}:process,I="NO_COLOR"in c||W.includes("--no-color"),J="FORCE_COLOR"in c||W.includes("--color"),j=Z==="win32",_=c.TERM==="dumb",F=A&&B&&B(1)&&c.TERM&&!_,N="CI"in c&&(("GITHUB_ACTIONS"in c)||("GITLAB_CI"in c)||("CIRCLECI"in c)),P=!I&&(J||j&&!_||F||N),L=(e,r,i,t,l=r.substring(0,e)+t,n=r.substring(e+i.length),s=n.indexOf(i))=>l+(s<0?n:L(s,n,i,t)),p=(e,r,i,t,l)=>e<0?i+r+t:i+L(e,r,t,l)+t,ee=(e,r,i=e,t=e.length+1)=>(l)=>l||!(l===""||l===void 0)?p((""+l).indexOf(r,t),l,e,r,i):"",g=(e,r,i)=>ee(`\x1B[${e}m`,`\x1B[${r}m`,i),D={reset:g(0,0),bold:g(1,22,"\x1B[22m\x1B[1m"),dim:g(2,22,"\x1B[22m\x1B[2m"),italic:g(3,23),underline:g(4,24),inverse:g(7,27),hidden:g(8,28),strikethrough:g(9,29),black:g(30,39),red:g(31,39),green:g(32,39),yellow:g(33,39),blue:g(34,39),magenta:g(35,39),cyan:g(36,39),white:g(37,39),gray:g(90,39),bgBlack:g(40,49),bgRed:g(41,49),bgGreen:g(42,49),bgYellow:g(43,49),bgBlue:g(44,49),bgMagenta:g(45,49),bgCyan:g(46,49),bgWhite:g(47,49),blackBright:g(90,39),redBright:g(91,39),greenBright:g(92,39),yellowBright:g(93,39),blueBright:g(94,39),magentaBright:g(95,39),cyanBright:g(96,39),whiteBright:g(97,39),bgBlackBright:g(100,49),bgRedBright:g(101,49),bgGreenBright:g(102,49),bgYellowBright:g(103,49),bgBlueBright:g(104,49),bgMagentaBright:g(105,49),bgCyanBright:g(106,49),bgWhiteBright:g(107,49)},re=({useColor:e=P}={})=>e?D:Object.keys(D).reduce((r,i)=>({...r,[i]:String}),{}),{reset:fe,bold:se,dim:ue,italic:oe,underline:ae,inverse:be,hidden:ce,strikethrough:de,black:me,red:Be,green:he,yellow:ve,blue:ye,magenta:Ce,cyan:Ae,white:ke,gray:Re,bgBlack:we,bgRed:Se,bgGreen:Te,bgYellow:De,bgBlue:We,bgMagenta:_e,bgCyan:Le,bgWhite:Oe,blackBright:Ye,redBright:xe,greenBright:O,yellowBright:Me,blueBright:Ee,magentaBright:Ge,cyanBright:$e,whiteBright:ze,bgBlackBright:He,bgRedBright:Ue,bgGreenBright:qe,bgYellowBright:Ke,bgBlueBright:Qe,bgMagentaBright:Ve,bgCyanBright:Xe,bgWhiteBright:Ze}=re();var v="timeback.config.json";function x(e){return C(e).toLowerCase()===".json"}async function te(e,r){if(r&&!x(r))throw Error(`Config file must be JSON (.json): ${r}`);let i=await ne({cwd:e,name:"timeback",configFile:r??v,rcFile:!1,packageJson:!1,dotenv:!1,envName:!1,extend:!1,omit$Keys:!0,defaults:{},overrides:{}});if(!i.config||Object.keys(i.config).length===0)return null;let t=i.config;if("extends"in t)throw Error("The 'extends' feature is not supported in timeback.config.json. Please inline all configuration.");let{$schema:l,...n}=t;return{config:n,configFile:i.configFile??d(e,r??v)}}async function rr(e={}){let r=process.cwd();try{if(e.configPath&&!x(e.configPath))return{success:!1,error:`Config file must be JSON (.json): ${e.configPath}`};if(e.configPath){let l=d(r,e.configPath);if(!ie(l))return{success:!1,error:`Config file not found: ${e.configPath}`}}let i=await te(r,e.configPath);if(!i)return{success:!1,error:`No timeback config found. Run ${O("timeback init")} to create one.`};let t=Y.safeParse(i.config);if(!t.success){let l=t.error.issues.map((n)=>` - ${n.path.join(".")}: ${n.message}`).join(`
|
|
2
|
+
`);return{success:!1,error:`Invalid config in ${h(i.configFile)}:
|
|
3
|
+
${l}`}}return{success:!0,config:t.data,configPath:i.configFile}}catch(i){return{success:!1,error:`Failed to load ${e.configPath?h(e.configPath):v}:
|
|
4
|
+
${i instanceof Error?i.message:String(i)}`}}}function ir(e){return y(process.cwd(),e)}export{te as loadWithC12,rr as loadConfig,ir as getRelativeConfigPath};
|
|
@@ -40,8 +40,9 @@ export declare class ActivityManager {
|
|
|
40
40
|
* @returns Started activity instance
|
|
41
41
|
* @throws If an activity is already active
|
|
42
42
|
*
|
|
43
|
-
* @example
|
|
43
|
+
* @example
|
|
44
44
|
* ```typescript
|
|
45
|
+
* // Basic usage
|
|
45
46
|
* const activity = timeback.activity.start({
|
|
46
47
|
* id: 'lesson-1',
|
|
47
48
|
* name: 'Intro',
|
|
@@ -56,8 +57,9 @@ export declare class ActivityManager {
|
|
|
56
57
|
* })
|
|
57
58
|
* ```
|
|
58
59
|
*
|
|
59
|
-
* @example
|
|
60
|
+
* @example
|
|
60
61
|
* ```typescript
|
|
62
|
+
* // Resume from previous session
|
|
61
63
|
* // Use the same runId from a previous session to correlate events
|
|
62
64
|
* const activity = timeback.activity.start({
|
|
63
65
|
* id: 'lesson-1',
|
|
@@ -67,8 +69,9 @@ export declare class ActivityManager {
|
|
|
67
69
|
* })
|
|
68
70
|
* ```
|
|
69
71
|
*
|
|
70
|
-
* @example
|
|
72
|
+
* @example
|
|
71
73
|
* ```typescript
|
|
74
|
+
* // Custom heartbeat interval
|
|
72
75
|
* const activity = timeback.activity.start({
|
|
73
76
|
* id: 'lesson-1',
|
|
74
77
|
* name: 'Intro',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"activity.d.ts","sourceRoot":"","sources":["../../../src/client/namespaces/activity.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAG1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACxD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AAEpE;;;;;;GAMG;AACH,qBAAa,eAAe;IAC3B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAA;IAC1B,OAAO,CAAC,QAAQ,CAAwB;IAExC;;;;OAIG;IACH,YAAY,MAAM,EAAE,uBAAuB,EAE1C;IAED;;;;OAIG;IACH,IAAI,OAAO,IAAI,QAAQ,GAAG,IAAI,CAK7B;IAED
|
|
1
|
+
{"version":3,"file":"activity.d.ts","sourceRoot":"","sources":["../../../src/client/namespaces/activity.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAG1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACxD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AAEpE;;;;;;GAMG;AACH,qBAAa,eAAe;IAC3B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAA;IAC1B,OAAO,CAAC,QAAQ,CAAwB;IAExC;;;;OAIG;IACH,YAAY,MAAM,EAAE,uBAAuB,EAE1C;IAED;;;;OAIG;IACH,IAAI,OAAO,IAAI,QAAQ,GAAG,IAAI,CAK7B;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmDG;IACH,KAAK,CAAC,MAAM,EAAE,cAAc,GAAG,QAAQ,CAUtC;CACD"}
|
package/dist/identity.d.ts
CHANGED
|
@@ -3,11 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This entrypoint is intentionally minimal: identity-only SSO, with types.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* If you're running in a Node.js server runtime, prefer importing from `timeback`
|
|
10
|
-
* to get the full SDK (including `createTimeback()` and `timeback.api`).
|
|
6
|
+
* If you need `toNativeHandler`, `ROUTES`, or the full SDK, import from
|
|
7
|
+
* `@timeback/sdk` instead — the main entry is edge-compatible.
|
|
11
8
|
*/
|
|
12
9
|
export { createTimebackIdentity } from './server/timeback-identity';
|
|
13
10
|
export type { IdentityOnlyConfig, IdentityOnlyInstance, IdentityOnlyHandlers } from './server';
|
package/dist/identity.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAA;AACnE,YAAY,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA"}
|
package/dist/identity.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{d as e}from"./chunk-1cqa51je.js";import"./chunk-6b0ppq9d.js";import"./chunk-3ew9vn2d.js";import"./chunk-edk3nfj7.js";export{e as createTimebackIdentity};
|
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Server-side exports for the Timeback SDK.
|
|
5
5
|
*
|
|
6
|
-
* @example
|
|
6
|
+
* @example
|
|
7
7
|
* ```typescript
|
|
8
|
+
* // Full SDK (activity tracking + identity)
|
|
8
9
|
* import { createTimeback } from '@timeback/sdk'
|
|
9
10
|
*
|
|
10
11
|
* export const timeback = await createTimeback({
|
|
@@ -20,8 +21,9 @@
|
|
|
20
21
|
* })
|
|
21
22
|
* ```
|
|
22
23
|
*
|
|
23
|
-
* @example
|
|
24
|
+
* @example
|
|
24
25
|
* ```typescript
|
|
26
|
+
* // Identity-only (SSO without activity tracking)
|
|
25
27
|
* import { createTimebackIdentity } from '@timeback/sdk'
|
|
26
28
|
*
|
|
27
29
|
* export const timeback = createTimebackIdentity({
|
|
@@ -38,7 +40,10 @@
|
|
|
38
40
|
* ```
|
|
39
41
|
*/
|
|
40
42
|
export { createTimeback, createTimebackIdentity } from './server';
|
|
43
|
+
export { toNativeHandler } from './server/adapters/native';
|
|
44
|
+
export { ROUTES } from './shared/constants';
|
|
41
45
|
export { TimebackClient } from '@timeback/core';
|
|
46
|
+
export { ApiError, ForbiddenError, isApiError, NotFoundError, UnauthorizedError, ValidationError, } from '@timeback/core';
|
|
42
47
|
export type { ApiCredentials, CustomIdentityConfig, Environment, IdentityConfig, SsoIdentityConfig, TimebackConfig, TimebackInstance, IdentityOnlyConfig, IdentityOnlyInstance, IdentityOnlyHandlers, BuildStateContext, CallbackSuccessContext, IdentityOnlyCallbackSuccessContext, CallbackErrorContext, OIDCTokens, OIDCUserInfo, IdpData, ActivityBeforeSendData, TimeSpentBeforeSendData, TimebackUserResolutionErrorCode, } from './server';
|
|
43
48
|
export type { TimebackIdentity, TimebackProfile, TimebackSessionUser, IdentityClaims, TimebackAuthUser, ActivityParams, ActivityMetrics, } from './shared/types';
|
|
44
49
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAEjE,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAE3C,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAM/C,OAAO,EACN,QAAQ,EACR,cAAc,EACd,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,eAAe,GACf,MAAM,gBAAgB,CAAA;AAMvB,YAAY,EACX,cAAc,EACd,oBAAoB,EACpB,WAAW,EACX,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,sBAAsB,EACtB,kCAAkC,EAClC,oBAAoB,EACpB,UAAU,EACV,YAAY,EACZ,OAAO,EACP,sBAAsB,EACtB,uBAAuB,EACvB,+BAA+B,GAC/B,MAAM,UAAU,CAAA;AAMjB,YAAY,EACX,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,eAAe,GACf,MAAM,gBAAgB,CAAA"}
|