@timeback/sdk 0.1.9 → 0.1.11
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-6b0ppq9d.js +2 -0
- package/dist/chunk-92nnwa7t.js +2 -0
- package/dist/chunk-bavxzt1k.js +2 -0
- package/dist/chunk-c8pw96sp.js +10 -0
- package/dist/chunk-edk3nfj7.js +2 -0
- package/dist/chunk-g67efaph.js +4 -0
- package/dist/chunk-pd91g539.js +1 -0
- package/dist/chunk-sgcwg4j6.js +1 -0
- package/dist/client/adapters/react/hooks/types.d.ts +2 -29
- package/dist/client/adapters/react/hooks/types.d.ts.map +1 -1
- package/dist/client/adapters/react/hooks/useTimebackVerification.d.ts.map +1 -1
- package/dist/client/adapters/react/index.js +2 -2
- package/dist/client/adapters/solid/types.d.ts +2 -29
- package/dist/client/adapters/solid/types.d.ts.map +1 -1
- package/dist/client/adapters/solid/types.ts +2 -18
- package/dist/client/adapters/svelte/stores/client.d.ts.map +1 -1
- package/dist/client/adapters/svelte/stores/client.ts +2 -9
- package/dist/client/adapters/svelte/stores/profile.d.ts +1 -1
- package/dist/client/adapters/svelte/stores/profile.d.ts.map +1 -1
- package/dist/client/adapters/svelte/stores/profile.ts +4 -11
- package/dist/client/adapters/svelte/stores/verification.d.ts.map +1 -1
- package/dist/client/adapters/svelte/stores/verification.ts +1 -10
- package/dist/client/adapters/svelte/types.d.ts +1 -29
- package/dist/client/adapters/svelte/types.d.ts.map +1 -1
- package/dist/client/adapters/vue/provider.d.ts.map +1 -1
- package/dist/client/adapters/vue/provider.ts +4 -11
- package/dist/client/adapters/vue/types.d.ts +2 -29
- package/dist/client/adapters/vue/types.d.ts.map +1 -1
- package/dist/client/adapters/vue/types.ts +2 -18
- package/dist/client/auth/types.d.ts +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/lib/activity/activity.class.d.ts +130 -22
- package/dist/client/lib/activity/activity.class.d.ts.map +1 -1
- package/dist/client/lib/activity/transport.d.ts +15 -0
- package/dist/client/lib/activity/transport.d.ts.map +1 -0
- package/dist/client/lib/activity/types.d.ts +53 -0
- package/dist/client/lib/activity/types.d.ts.map +1 -0
- package/dist/client/lib/utils.d.ts +18 -0
- package/dist/client/lib/utils.d.ts.map +1 -1
- package/dist/client/lib/utils.ts +109 -0
- package/dist/client/namespaces/activity.d.ts +49 -7
- package/dist/client/namespaces/activity.d.ts.map +1 -1
- package/dist/client/timeback-client.class.d.ts +7 -1
- package/dist/client/timeback-client.class.d.ts.map +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js +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 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +30 -21
- package/dist/server/adapters/express.d.ts.map +1 -1
- package/dist/server/adapters/express.js +1 -1
- package/dist/server/adapters/native.d.ts.map +1 -1
- package/dist/server/adapters/native.js +2 -2
- package/dist/server/adapters/nextjs.js +1 -1
- package/dist/server/adapters/nuxt.d.ts.map +1 -1
- package/dist/server/adapters/nuxt.js +1 -1
- package/dist/server/adapters/solid-start.d.ts.map +1 -1
- package/dist/server/adapters/solid-start.js +1 -1
- package/dist/server/adapters/svelte-kit.d.ts.map +1 -1
- package/dist/server/adapters/svelte-kit.js +1 -1
- package/dist/server/adapters/tanstack-start.d.ts.map +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/adapters/utils.d.ts +1 -1
- package/dist/server/adapters/utils.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 +54 -16
- package/dist/server/handlers/activity/caliper.d.ts.map +1 -1
- package/dist/server/handlers/activity/heartbeat-handler.d.ts +15 -0
- package/dist/server/handlers/activity/heartbeat-handler.d.ts.map +1 -0
- package/dist/server/handlers/activity/index.d.ts +5 -3
- package/dist/server/handlers/activity/index.d.ts.map +1 -1
- package/dist/server/handlers/activity/progress.d.ts +2 -2
- package/dist/server/handlers/activity/progress.d.ts.map +1 -1
- package/dist/server/handlers/activity/schema.d.ts +40 -6
- package/dist/server/handlers/activity/schema.d.ts.map +1 -1
- package/dist/server/handlers/activity/submit-handler.d.ts +29 -0
- package/dist/server/handlers/activity/submit-handler.d.ts.map +1 -0
- package/dist/server/handlers/activity/submit.d.ts +44 -0
- package/dist/server/handlers/activity/submit.d.ts.map +1 -0
- package/dist/server/handlers/activity/types.d.ts +126 -5
- package/dist/server/handlers/activity/types.d.ts.map +1 -1
- package/dist/server/handlers/identity/handler.d.ts +23 -4
- package/dist/server/handlers/identity/handler.d.ts.map +1 -1
- package/dist/server/handlers/identity/index.d.ts +2 -2
- package/dist/server/handlers/identity/index.d.ts.map +1 -1
- package/dist/server/handlers/identity/oidc.d.ts.map +1 -1
- package/dist/server/handlers/identity/types.d.ts +0 -6
- package/dist/server/handlers/identity/types.d.ts.map +1 -1
- package/dist/server/handlers/index.d.ts +3 -3
- package/dist/server/handlers/index.d.ts.map +1 -1
- package/dist/server/handlers/user/handler.d.ts.map +1 -1
- package/dist/server/handlers/user/profile.d.ts.map +1 -1
- package/dist/server/handlers/user/types.d.ts +3 -0
- package/dist/server/handlers/user/types.d.ts.map +1 -1
- package/dist/server/handlers/user/verify.d.ts.map +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/lib/hooks.d.ts +20 -0
- package/dist/server/lib/hooks.d.ts.map +1 -0
- package/dist/server/lib/index.d.ts +4 -2
- package/dist/server/lib/index.d.ts.map +1 -1
- package/dist/server/lib/logger.d.ts +36 -9
- package/dist/server/lib/logger.d.ts.map +1 -1
- package/dist/server/lib/resolve.d.ts +1 -1
- package/dist/server/lib/resolve.d.ts.map +1 -1
- package/dist/server/lib/utils.d.ts +23 -2
- package/dist/server/lib/utils.d.ts.map +1 -1
- package/dist/server/lib/validation.d.ts +55 -0
- package/dist/server/lib/validation.d.ts.map +1 -0
- package/dist/server/namespaces/activity/index.d.ts +8 -0
- package/dist/server/namespaces/activity/index.d.ts.map +1 -0
- package/dist/server/namespaces/activity/record.d.ts +49 -0
- package/dist/server/namespaces/activity/record.d.ts.map +1 -0
- package/dist/server/namespaces/activity/schema.d.ts +50 -0
- package/dist/server/namespaces/activity/schema.d.ts.map +1 -0
- package/dist/server/namespaces/user/get-profile.d.ts +32 -0
- package/dist/server/namespaces/user/get-profile.d.ts.map +1 -0
- package/dist/server/namespaces/user/index.d.ts +8 -0
- package/dist/server/namespaces/user/index.d.ts.map +1 -0
- package/dist/server/namespaces/user/verify.d.ts +28 -0
- package/dist/server/namespaces/user/verify.d.ts.map +1 -0
- package/dist/server/timeback-identity.d.ts +3 -3
- package/dist/server/timeback.d.ts +5 -3
- package/dist/server/timeback.d.ts.map +1 -1
- package/dist/server/types.d.ts +407 -14
- package/dist/server/types.d.ts.map +1 -1
- package/dist/shared/constants.d.ts +7 -0
- package/dist/shared/constants.d.ts.map +1 -1
- package/dist/shared/constants.ts +51 -0
- package/dist/shared/index.d.ts +9 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/schemas.d.ts +57 -0
- package/dist/shared/schemas.d.ts.map +1 -0
- package/dist/shared/types.d.ts +287 -18
- package/dist/shared/types.d.ts.map +1 -1
- package/dist/shared/types.ts +636 -0
- package/package.json +7 -10
- package/dist/chunk-07j8zre9.js +0 -2
- package/dist/chunk-5171mkp2.js +0 -2
- package/dist/chunk-63afdp3y.js +0 -8
- package/dist/chunk-8gg8n8v9.js +0 -2
- package/dist/chunk-9se82640.js +0 -1
- package/dist/chunk-agpf1x3g.js +0 -16
- package/dist/chunk-hnf0tart.js +0 -2
- package/dist/chunk-qr0bbnsr.js +0 -1
- package/dist/chunk-whc53e0y.js +0 -11
- package/dist/chunk-x9gvef7q.js +0 -1
- package/dist/edge.d.ts +0 -13
- package/dist/edge.d.ts.map +0 -1
- package/dist/edge.js +0 -1
- package/dist/server/handlers/activity/handler.d.ts +0 -32
- package/dist/server/handlers/activity/handler.d.ts.map +0 -1
- package/dist/shared/xp-calculator.d.ts +0 -25
- package/dist/shared/xp-calculator.d.ts.map +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,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};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var A="/api/timeback",W={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"}},L=15000,B=600000;var M=3,I=[100,300,1000];function j(){return typeof window<"u"}function J(){if(!j())return;return`${window.location.origin}${A}`}function k(q){return new Promise((X)=>{setTimeout(X,q)})}function T(q,X){if(typeof q==="number")return q;return q[Math.min(X,q.length-1)]??1000}async function S(q,X,z){let $;for(let K=0;K<=X;K++)try{return await q()}catch(Z){if($=Z,K<X)await k(T(z,K))}throw $ instanceof Error?$:Error(String($))}function E(){if(typeof crypto<"u"&&crypto.randomUUID)return crypto.randomUUID();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(q)=>{let X=Math.random()*16|0;return(q==="x"?X:X&3|8).toString(16)})}class V{params;id;runId;_startedAt;_timeEnabled;_timeOptions;_callbacks;_windowStartMs;_activeSinceMs;_accumulatedActiveMs=0;_totalFlushedActiveMs=0;_isPaused=!1;_ended=!1;_ending=!1;_heartbeatTimer=null;_flushInFlight=null;_boundVisibilityHandler=null;_boundPageHideHandler=null;_hiddenTimeoutTimer=null;_timedOutWhileHidden=!1;constructor(q,X){this.params=q;this._callbacks=X;let z=Date.now();this.id=q.id,this.runId=q.runId??E(),this._startedAt=new Date(z),this._windowStartMs=z,this._timeEnabled=q.time!==!1;let $=q.time===!1?{}:q.time??{};if(this._timeOptions={flushIntervalMs:$.flushIntervalMs??L,visibilityAware:$.visibilityAware??!0,flushOnVisibilityHidden:$.flushOnVisibilityHidden??!0,flushOnPageHide:$.flushOnPageHide??!0,hiddenTimeoutMs:$.hiddenTimeoutMs??B,retryAttempts:$.retryAttempts??0,retryDelaysMs:$.retryDelaysMs??[...I]},this._timeEnabled)this._activeSinceMs=z,this._startHeartbeatTimer(),this._setupVisibilityHandlers();else this._activeSinceMs=null}_errorContext(q){return{type:q,activityId:this.params.id,runId:this.runId}}get startedAt(){return this._startedAt}get isPaused(){return this._isPaused}get isEnded(){return this._ended}get elapsedMs(){return this._getCurrentWindowActiveMs()}get totalActiveMs(){return this._totalFlushedActiveMs+this._getCurrentWindowActiveMs()}_getCurrentWindowActiveMs(){let q=this._accumulatedActiveMs;if(this._activeSinceMs!==null)q+=Date.now()-this._activeSinceMs;return Math.max(0,q)}_startHeartbeatTimer(){if(this._heartbeatTimer!==null)return;this._heartbeatTimer=setInterval(()=>{this.flushTimeSpent()},this._timeOptions.flushIntervalMs)}_stopHeartbeatTimer(){if(this._heartbeatTimer!==null)clearInterval(this._heartbeatTimer),this._heartbeatTimer=null}_restartHeartbeatTimer(){this._stopHeartbeatTimer(),this._startHeartbeatTimer()}_setupVisibilityHandlers(){if(typeof document>"u")return;if(this._timeOptions.visibilityAware||this._timeOptions.flushOnVisibilityHidden)this._boundVisibilityHandler=this._handleVisibilityChange.bind(this),document.addEventListener("visibilitychange",this._boundVisibilityHandler);if(this._timeOptions.flushOnPageHide&&typeof window<"u")this._boundPageHideHandler=this._handlePageHide.bind(this),window.addEventListener("pagehide",this._boundPageHideHandler)}_teardownVisibilityHandlers(){if(this._clearHiddenTimeout(),this._boundVisibilityHandler)document.removeEventListener("visibilitychange",this._boundVisibilityHandler),this._boundVisibilityHandler=null;if(this._boundPageHideHandler&&typeof window<"u")window.removeEventListener("pagehide",this._boundPageHideHandler),this._boundPageHideHandler=null}_handleVisibilityChange(){if(this._ended)return;if(document.visibilityState==="hidden"){if(this._timeOptions.visibilityAware&&this._activeSinceMs!==null)this._accumulatedActiveMs+=Date.now()-this._activeSinceMs,this._activeSinceMs=null;if(this._timeOptions.flushOnVisibilityHidden)this.flushTimeSpent();this._startHiddenTimeout()}else{if(this._clearHiddenTimeout(),this._timedOutWhileHidden){this._timedOutWhileHidden=!1;let X=Date.now();if(this._windowStartMs=X,this._accumulatedActiveMs=0,!this._isPaused)this.params.onResume?.()}if(this._restartHeartbeatTimer(),this._timeOptions.visibilityAware&&!this._isPaused&&this._activeSinceMs===null)this._activeSinceMs=Date.now()}}_startHiddenTimeout(){let q=this._timeOptions.hiddenTimeoutMs;if(q===null||!Number.isFinite(q))return;this._clearHiddenTimeout(),this._hiddenTimeoutTimer=setTimeout(()=>{if(this._hiddenTimeoutTimer=null,this._stopHeartbeatTimer(),this._timedOutWhileHidden=!0,!this._isPaused)this.params.onPause?.()},q)}_clearHiddenTimeout(){if(this._hiddenTimeoutTimer!==null)clearTimeout(this._hiddenTimeoutTimer),this._hiddenTimeoutTimer=null}_handlePageHide(){if(this._ended)return;let q=Date.now(),X=this._accumulatedActiveMs;if(this._activeSinceMs!==null)X+=q-this._activeSinceMs;if(X<=0)return;this._flushSync(q,X)}async _flushSync(q,X){let z=this._buildHeartbeatPayload(q,X);if(this._totalFlushedActiveMs+=X,this._windowStartMs=q,this._accumulatedActiveMs=0,this._activeSinceMs!==null)this._activeSinceMs=q;try{await this._callbacks.sendHeartbeatOnPageHide(z),this.params.onFlush?.(X)}catch($){let K=$ instanceof Error?$:Error(String($));this.params.onError?.(K,this._errorContext("timeSpent"))}}_buildHeartbeatPayload(q,X){let z=q-this._windowStartMs-X;return{id:this.params.id,name:this.params.name,course:this.params.course,runId:this.runId,startedAt:new Date(this._windowStartMs).toISOString(),endedAt:new Date(q).toISOString(),elapsedMs:Math.max(0,X),pausedMs:Math.max(0,z)}}async flushTimeSpent(){if(!this._timeEnabled)return;if(this._isPaused&&!this._ended&&!this._ending)return;if(this._flushInFlight){await this._flushInFlight;return}let q=Date.now(),X=this._accumulatedActiveMs;if(this._activeSinceMs!==null)X+=q-this._activeSinceMs;if(q-this._windowStartMs<=0)return;let $=this._buildHeartbeatPayload(q,X);if(this._totalFlushedActiveMs+=X,this._windowStartMs=q,this._accumulatedActiveMs=0,this._activeSinceMs!==null)this._activeSinceMs=q;let{retryAttempts:K,retryDelaysMs:Z}=this._timeOptions;this._flushInFlight=S(()=>this._callbacks.sendHeartbeat($),K,Z).then(()=>{this.params.onFlush?.(X)}).catch((H)=>{let C=H instanceof Error?H:Error(String(H));this.params.onError?.(C,this._errorContext("timeSpent"))}).finally(()=>{this._flushInFlight=null}),await this._flushInFlight}pause(){if(this._isPaused||this._ended)return;if(this._activeSinceMs!==null)this._accumulatedActiveMs+=Date.now()-this._activeSinceMs,this._activeSinceMs=null;this.flushTimeSpent(),this._isPaused=!0,this._stopHeartbeatTimer(),this.params.onPause?.()}resume(){if(!this._isPaused||this._ended)return;if(this._isPaused=!1,this._timeEnabled){let q=Date.now();if(this._windowStartMs=q,this._accumulatedActiveMs=0,!this._timeOptions.visibilityAware||document.visibilityState==="visible")this._activeSinceMs=q;this._startHeartbeatTimer()}this.params.onResume?.()}async end(q={}){if(this._ended||this._ending)return;this._ending=!0,this._stopHeartbeatTimer(),this._teardownVisibilityHandlers();let X=this._activeSinceMs!==null,z=this._activeSinceMs;if(this._activeSinceMs!==null)this._accumulatedActiveMs+=Date.now()-this._activeSinceMs,this._activeSinceMs=null;try{if(await this.flushTimeSpent(),q.totalQuestions!==void 0||q.correctQuestions!==void 0||q.xpEarned!==void 0||q.masteredUnits!==void 0||q.pctComplete!==void 0)await this._sendCompletion(q);this._ended=!0,this._ending=!1}catch($){if(this._ending=!1,X)this._activeSinceMs=z;if(this._timeEnabled)this._startHeartbeatTimer(),this._setupVisibilityHandlers();let K=$ instanceof Error?$:Error(String($));throw this.params.onError?.(K,this._errorContext("completion")),$}}async _sendCompletion(q){if(q.xpEarned===void 0)throw Error("Invalid activity completion: xpEarned is required. The SDK cannot auto-calculate XP because total elapsed time may span multiple browser sessions.");let X=new Date,z=q.totalQuestions!==void 0,$=q.correctQuestions!==void 0;if(z!==$)throw Error("Invalid activity metrics: totalQuestions and correctQuestions must be provided together.");if(z&&$&&q.correctQuestions>q.totalQuestions)throw Error("Invalid activity metrics: correctQuestions cannot exceed totalQuestions.");let K={xpEarned:q.xpEarned,...z?{totalQuestions:q.totalQuestions}:{},...$?{correctQuestions:q.correctQuestions}:{},...q.masteredUnits===void 0?{}:{masteredUnits:q.masteredUnits}},Z={id:this.params.id,name:this.params.name,course:this.params.course,runId:this.runId,endedAt:X.toISOString(),metrics:K,...q.pctComplete===void 0?{}:{pctComplete:q.pctComplete}};await this._callbacks.sendSubmit(Z)}}function R(){if(!(typeof globalThis>"u"?void 0:globalThis.fetch))return;return(X,z)=>globalThis.fetch(X,z)}function U(q){let{baseURL:X,fetch:z,canUseBeacon:$,credentials:K}=q,Z=`${X}${W.ACTIVITY_HEARTBEAT}`,H=`${X}${W.ACTIVITY_SUBMIT}`;function C(Q,G){if(!$)return!1;if(typeof navigator>"u")return!1;if(typeof navigator.sendBeacon!=="function")return!1;try{let N=new Blob([G],{type:"application/json"});return navigator.sendBeacon(Q,N)}catch{return!1}}function F(Q,G,N=!1){return z(Q,{method:"POST",headers:{"Content-Type":"application/json"},body:G,credentials:K,keepalive:N})}return{async sendHeartbeat(Q){let G=JSON.stringify(Q),N=await F(Z,G);if(!N.ok){let Y=await N.json().catch(()=>({error:{message:"Unknown error"}})),_=typeof Y.error==="object"?Y.error?.message:Y.error;throw Error(_??"Failed to send heartbeat")}},async sendHeartbeatOnPageHide(Q){let G=JSON.stringify(Q);if(C(Z,G))return;if(!(await F(Z,G,!0)).ok)throw Error("Failed to send heartbeat on page exit")},async sendSubmit(Q){let G=JSON.stringify(Q),N=await F(H,G);if(!N.ok){let Y=await N.json().catch(()=>({error:{message:"Unknown error"}})),_=typeof Y.error==="object"?Y.error?.message:Y.error;throw Error(_??"Failed to submit activity")}}}}class P{transport;_current=null;constructor(q){this.transport=U(q)}get current(){if(this._current?.isEnded)this._current=null;return this._current}start(q){if(this._current&&!this._current.isEnded)throw Error(`An activity is already active (id: "${this._current.id}"). End it before starting a new one.`);return this._current=new V(q,this.transport),this._current}}class x{getBaseURL;constructor(q){this.getBaseURL=q}signIn(){if(!j())throw Error("signIn() requires a browser environment");window.location.href=`${this.getBaseURL()}${W.IDENTITY.SIGNIN}`}}class O{getBaseURL;fetchImpl;constructor(q,X){this.getBaseURL=q;this.fetchImpl=X}async fetch(){if(!j())throw Error("user.fetch() requires a browser environment");let q=await this.fetchImpl(`${this.getBaseURL()}${W.USER.ME}`,{method:"GET",credentials:"include"});if(!q.ok){let X=await q.json().catch(()=>({error:"Unknown error"}));throw Error(X.error??"Failed to fetch user profile")}return q.json()}async verify(){if(!j())throw Error("user.verify() requires a browser environment");let q=await this.fetchImpl(`${this.getBaseURL()}${W.USER.VERIFY}`,{method:"GET",credentials:"include"});if(!q.ok){let z=await q.json().catch(()=>({error:"Unknown error"}));throw Error(z.error??"Failed to verify Timeback user")}let X=await q.json();if(X.verified&&X.timebackId)return{verified:!0,timebackId:X.timebackId};return{verified:!1}}}class D{activity;auth;user;_baseURL;_fetch;constructor(q={}){this._baseURL=q.baseURL;let X=q.fetch??R();if(!X)throw Error("TimebackClient requires a fetch implementation. Provide `fetch` in the constructor config for non-browser runtimes.");let z=q.plugins,$=Array.isArray(z)?z:z?[z]:[];this._fetch=$.reduce((K,Z)=>Z.wrapFetch(K),X),this.activity=new P({baseURL:this.baseURL,fetch:this._fetch,canUseBeacon:$.length===0,credentials:q.credentials??"include"}),this.auth=new x(()=>this.baseURL),this.user=new O(()=>this.baseURL,this._fetch)}get baseURL(){if(!this._baseURL){let q=J();if(!q)throw Error("Timeback client requires a browser environment for default baseURL. Provide an explicit baseURL for server-side usage.");this._baseURL=q}return this._baseURL}}function Wq(q={}){let X=q.baseURL??J();return new D({baseURL:X,fetch:q.fetch,plugins:q.plugins})}
|
|
2
|
+
export{M as a,I as b,k as c,T as d,V as e,D as f,Wq as g};
|
|
@@ -0,0 +1,2 @@
|
|
|
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,4 @@
|
|
|
1
|
+
import{c as Y}from"./chunk-sgcwg4j6.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};
|
|
@@ -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 @@
|
|
|
1
|
+
import{z as H}from"zod/v4";import{z as _}from"zod/v4";var jZ=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/,x=_.string().min(1).regex(jZ,"must be a valid ISO 8601 datetime"),k=_.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)"}),l=_.enum(["exempt","fully graded","not submitted","partially graded","submitted"]),T=_.enum(["department","school","district","local","state","national"]),C=_.enum(["administrator","aide","guardian","parent","proctor","relative","student","teacher"]),R=_.enum(["administrator","proctor","student","teacher"]),u=_.enum(["qti","text","audio","video","interactive","visual","course-material","assessment-bank"]),d=_.enum(["qti-test","qti-question","qti-stimulus","qti-test-bank"]),N=_.enum(["unit","course","resource-collection"]),c=_.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"]),E=_.array(_.object({source:_.string(),learningObjectiveIds:_.array(_.string())})),y=_.object({consecutive_failures:_.number().int().min(1).optional(),stagnation_limit:_.number().int().min(1).optional()}).optional(),Wq=_.enum(["powerpath-100","quiz","test-out","placement","unit-test","alpha-read-article"]).nullable(),Xq=_.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 PZ=H.object({staging:H.string().meta({description:"Course ID in staging environment"}).optional(),production:H.string().meta({description:"Course ID in production environment"}).optional()}).meta({id:"CourseIds",description:"Environment-specific course IDs (populated by sync)"}),GZ=H.enum(["base","hole-filling","optional"]).meta({id:"CourseType",description:"Course classification type"}),BZ=H.enum(["draft","testing","published","deactivated"]).meta({id:"PublishStatus",description:"Course publication status"}),AZ=H.object({dailyXp:H.number().int().positive().meta({description:"Target XP to earn per day"}).optional(),dailyLessons:H.number().int().positive().meta({description:"Target lessons to complete per day"}).optional(),dailyActiveMinutes:H.number().int().positive().meta({description:"Target active learning minutes per day"}).optional(),dailyAccuracy:H.number().int().min(0).max(100).meta({description:"Target accuracy percentage (0-100)"}).optional(),dailyMasteredUnits:H.number().int().positive().meta({description:"Target units to master per day"}).optional()}).meta({id:"CourseGoals",description:"Daily learning goals for a course"}),hZ=H.object({totalXp:H.number().int().positive().meta({description:"Total XP available in the course"}).optional(),totalLessons:H.number().int().positive().meta({description:"Total number of lessons/activities"}).optional(),totalGrades:H.number().int().positive().meta({description:"Total grade levels covered"}).optional()}).meta({id:"CourseMetrics",description:"Aggregate metrics for a course"}),g=H.object({courseType:GZ.optional(),isSupplemental:H.boolean().meta({description:"Whether this is supplemental to a base course"}).optional(),isCustom:H.boolean().meta({description:"Whether this is a custom course for an individual student"}).optional(),publishStatus:BZ.optional(),contactEmail:H.email().meta({description:"Contact email for course issues"}).optional(),primaryApp:H.string().meta({description:"Primary application identifier"}).optional(),goals:AZ.optional(),metrics:hZ.optional()}).meta({id:"CourseMetadata",description:"Course metadata (matches API metadata object)"}),m=H.object({courseCode:H.string().meta({description:"Course code (e.g., 'MATH101')"}).optional(),level:H.string().meta({description:"Course level (e.g., 'AP', 'Honors')"}).optional(),metadata:g.optional()}).meta({id:"CourseDefaults",description:"Default properties that apply to all courses unless overridden"}),s=H.object({level:H.string().meta({description:"Course level for this environment"}).optional(),sensor:H.url().meta({description:"Caliper sensor endpoint URL for this environment"}).optional(),launchUrl:H.url().meta({description:"LTI launch URL for this environment"}).optional(),metadata:g.optional()}).meta({id:"CourseEnvOverrides",description:"Environment-specific course overrides (non-identity fields)"}),OZ=H.object({staging:s.meta({description:"Overrides for staging environment"}).optional(),production:s.meta({description:"Overrides for production environment"}).optional()}).meta({id:"CourseOverrides",description:"Per-environment course overrides"}),vZ=m.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:PZ.nullable().optional(),sensor:H.url().meta({description:"Caliper sensor endpoint URL for this course"}).optional(),launchUrl:H.url().meta({description:"LTI launch URL for this course"}).optional(),overrides:OZ.optional()}).meta({id:"CourseConfig",description:"Configuration for a single course. Must have either grade or courseCode (or both)."}),Hq=H.object({$schema:H.string().meta({description:"JSON Schema reference for editor support"}).optional(),name:H.string().min(1,"App name is required").meta({description:"Display name for your app"}),defaults:m.meta({description:"Default properties applied to all courses"}).optional(),courses:H.array(vZ).min(1,"At least one course is required").meta({description:"Courses available in this app"}),sensor:H.url().meta({description:"Default Caliper sensor endpoint URL for all courses"}).optional(),launchUrl:H.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((U)=>{return U.courses.every((j)=>j.grade!==void 0||j.courseCode!==void 0)},{message:"Each course must have either a grade or a courseCode",path:["courses"]}).refine((U)=>{let v=U.courses.filter((h)=>h.grade!==void 0).map((h)=>`${h.subject}:${h.grade}`);return new Set(v).size===v.length},{message:"Duplicate (subject, grade) pair found; each must be unique",path:["courses"]}).refine((U)=>{let v=U.courses.filter((h)=>h.courseCode!==void 0).map((h)=>h.courseCode);return new Set(v).size===v.length},{message:"Duplicate courseCode found; each must be unique",path:["courses"]}).refine((U)=>{return U.courses.every((j)=>{if(j.sensor!==void 0||U.sensor!==void 0)return!0;return[j.launchUrl,U.launchUrl,j.overrides?.staging?.launchUrl,j.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 J}from"zod/v4";var D=J.object({id:J.string(),type:J.literal("TimebackUser"),email:J.string()}),Q=J.object({id:J.string(),type:J.literal("TimebackActivityContext"),subject:L,app:J.object({name:J.string()}),activity:J.object({id:J.string().optional(),name:J.string()}).strict().optional(),course:J.object({id:J.string().optional(),name:J.string()}).strict().optional(),process:J.boolean().optional()}),S=J.object({"@context":J.literal("http://purl.imsglobal.org/ctx/caliper/v1p2"),id:J.string(),type:J.string(),eventTime:x,profile:J.literal("TimebackProfile"),actor:D,action:J.string(),object:Q,edApp:J.object({id:J.string(),name:J.string().optional()}).optional()}),o=J.object({type:J.enum(["totalQuestions","correctQuestions","xpEarned","masteredUnits"]),value:J.number()}),IZ=J.object({id:J.string(),type:J.literal("TimebackActivityMetricsCollection"),attempt:J.number().optional(),items:J.array(o),extensions:J.record(J.string(),J.unknown()).optional()}),CZ=S.extend({type:J.literal("ActivityEvent"),action:J.literal("Completed"),generated:IZ}),r=J.object({type:J.enum(["active","inactive","waste","unknown","anti-pattern"]),value:J.number(),subType:J.string().optional()}),kZ=J.object({id:J.string(),type:J.literal("TimebackTimeSpentMetricsCollection"),items:J.array(r)}),DZ=S.extend({type:J.literal("TimeSpentEvent"),action:J.literal("SpentTime"),generated:kZ}),Fq=J.object({actor:D,object:Q,metrics:J.array(o).min(1,"metrics must contain at least one metric"),eventTime:x.optional(),metricsId:J.string().optional(),id:J.string().optional(),extensions:J.record(J.string(),J.unknown()).optional(),edApp:J.union([J.string(),J.record(J.string(),J.unknown())]).optional(),session:J.union([J.string(),J.record(J.string(),J.unknown())]).optional(),attempt:J.number().int().min(1).optional(),generatedExtensions:J.object({pctCompleteApp:J.number().optional()}).loose().optional()}).strict(),Lq=J.object({actor:D,object:Q,metrics:J.array(r).min(1,"metrics must contain at least one metric"),eventTime:x.optional(),metricsId:J.string().optional(),id:J.string().optional(),extensions:J.record(J.string(),J.unknown()).optional(),edApp:J.union([J.string(),J.record(J.string(),J.unknown())]).optional(),session:J.union([J.string(),J.record(J.string(),J.unknown())]).optional()}).strict(),QZ=J.union([CZ,DZ]),Uq=J.object({sensor:J.string(),sendTime:x,dataVersion:J.literal("http://purl.imsglobal.org/ctx/caliper/v1p2"),data:J.array(QZ)}),MZ=J.enum(["AnnotationProfile","AssessmentProfile","ToolUseProfile","GeneralProfile","FeedbackProfile","MediaProfile","SurveyProfile","ResourceManagementProfile","ForumProfile","AssignableProfile","GradingProfile","ReadingProfile","SessionProfile","SearchProfile","ToolLaunchProfile","TimebackProfile"]),B=J.union([J.string(),J.record(J.string(),J.unknown())]),fZ=J.object({id:J.string(),type:J.string(),extensions:J.object({email:J.email()}).loose()}).strict(),a=J.object({"@context":J.string().optional(),id:J.string(),type:J.string(),actor:J.union([J.string(),fZ,D]),action:J.string(),object:B,eventTime:x,profile:MZ,edApp:B.optional(),generated:B.optional(),target:B.optional(),referrer:B.optional(),group:B.optional(),membership:B.optional(),session:B.optional(),federatedSession:B.optional(),extensions:J.record(J.string(),J.unknown()).optional()}).strict(),jq=J.object({sensor:J.string().min(1,"sensor must be a non-empty string"),sendTime:x,dataVersion:J.literal("http://purl.imsglobal.org/ctx/caliper/v1p2"),data:J.array(a).min(1,"data must contain at least one event")}),Pq=J.object({sensor:J.string().min(1,"sensor must be a non-empty string"),events:J.array(a).min(1,"events must contain at least one event")}),Gq=J.object({limit:J.number().int().positive().optional(),offset:J.number().int().min(0).optional(),sensor:J.string().min(1).optional(),startDate:x.optional(),endDate:x.optional(),actorId:J.string().min(1).optional(),actorEmail:J.email().optional()}).strict();import{z as X}from"zod/v4";var G=X.union([x,k]),Oq=X.object({id:X.string(),role:X.string(),beginDate:G.nullable(),endDate:G.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()})}),bZ=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(),bZ)),vq=X.object({message:X.string(),enrollmentId:X.string(),startDate:G,endDate:G,facts:lZ,factsByApp:X.unknown()}),A=X.string().trim().min(1),i=X.object({email:X.email().optional(),studentId:A.optional()}).superRefine((U,j)=>{if(!U.email&&!U.studentId)j.addIssue({code:X.ZodIssueCode.custom,message:"must provide either email or studentId",path:["email"]}),j.addIssue({code:X.ZodIssueCode.custom,message:"must provide either email or studentId",path:["studentId"]})}),Iq=X.object({subject:A,grade:A,courseId:A,orgSourcedId:A.optional()});var Cq=X.object({userId:A}),kq=X.object({sourcedId:A.optional(),role:R.optional(),beginDate:G.optional(),metadata:X.record(X.string(),X.unknown()).optional()}),Dq=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(C).min(1),orgSourcedIds:X.array(A).optional()}),Qq=i.extend({startDate:G,endDate:G,timezone:X.string().optional()}),Mq=i.extend({weekDate:G,timezone:X.string().optional()}),fq=X.object({enrollmentId:A,startDate:G.optional(),endDate:G.optional(),timezone:X.string().optional()});import{z as q}from"zod/v4";var Y=q.string().min(1),V=q.enum(["active","tobedeleted"]),w=q.record(q.string(),q.unknown()).nullable().optional(),$=q.object({sourcedId:Y,type:q.string().optional(),href:q.string().optional()}).strict(),P=q.union([k,x]),TZ=q.object({roleType:q.enum(["primary","secondary"]),role:C,org:$,userProfile:q.string().optional(),metadata:w,beginDate:P.optional(),endDate:P.optional()}).strict(),Rq=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(TZ).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:w}).strict(),uq=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:w}).strict(),dq=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:w}).strict(),n=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:C,primary:n.optional(),beginDate:P.optional(),endDate:P.optional(),metadata:w}).strict(),cq=q.object({sourcedId:Y.optional(),title:Y.describe("title must be a non-empty string"),status:V,weight:q.number().nullable().optional(),metadata:w}).strict(),pq=q.object({sourcedId:Y.optional(),title:Y.describe("title must be a non-empty string"),class:$,school:$,category:$,assignDate:P,dueDate:P,status:V,description:q.string().optional(),resultValueMin:q.number().nullable().optional(),resultValueMax:q.number().nullable().optional(),scoreScale:$.optional(),metadata:w}).strict(),Eq=q.object({sourcedId:Y.optional(),lineItem:$,student:$,class:$.optional(),scoreDate:P,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:w}).strict(),yq=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:w}).strict(),sq=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:w}).strict(),RZ=q.object({learningObjectiveId:q.string(),score:q.number().optional(),textScore:q.string().optional()}),uZ=q.array(q.object({source:q.string(),learningObjectiveResults:q.array(RZ)})),gq=q.object({sourcedId:Y.optional(),status:V.optional(),dateLastModified:x.optional(),metadata:w,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:uZ.nullable().optional(),inProgress:q.string().nullable().optional(),incomplete:q.string().nullable().optional(),late:q.string().nullable().optional(),missing:q.string().nullable().optional()}).strict(),mq=q.object({sourcedId:Y.optional(),status:V.optional(),name:Y.describe("name must be a non-empty string"),type:T,identifier:Y.optional(),parent:$.optional(),metadata:w}).strict(),Sq=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:w}).strict(),oq=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:P,endDate:P,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:w}).strict(),rq=q.object({sourcedId:Y.optional(),title:Y.describe("title must be a non-empty string"),courseComponent:$,resource:$,status:V,metadata:w}).strict(),aq=q.object({sourcedId:Y.optional(),title:Y.describe("title must be a non-empty string"),course:$,status:V,metadata:w}).strict(),iq=q.object({sourcedId:Y.describe("sourcedId must be a non-empty string"),role:q.enum(["student","teacher"]),primary:n.optional(),beginDate:P.optional(),endDate:P.optional(),metadata:w}).strict(),nq=q.object({agentSourcedId:Y.describe("agentSourcedId must be a non-empty string")}).strict(),eq=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:w}).strict(),zq=q.object({sourcedId:Y.describe("sourcedId must be a non-empty string")}).loose(),O=q.object({type:u,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:E.nullish(),lessonType:q.string().nullish()}).passthrough(),dZ=O.extend({type:q.literal("qti"),subType:d,questionType:c.optional(),difficulty:p.optional()}),NZ=O.extend({type:q.literal("text"),format:q.string(),author:q.string().optional(),pageCount:q.number().optional()}),cZ=O.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()}),pZ=O.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()}),EZ=O.extend({type:q.literal("interactive"),launchUrl:q.url().optional(),toolProvider:q.string().optional(),instructionalMethod:q.string().optional(),courseIdOnFail:q.string().nullable().optional(),fail_fast:y}),yZ=O.extend({type:q.literal("visual"),format:q.string(),resolution:q.string().optional()}),sZ=O.extend({type:q.literal("course-material"),subType:N,author:q.string().optional(),format:q.string(),instructionalMethod:q.string().optional()}),gZ=O.extend({type:q.literal("assessment-bank"),resources:q.array(q.string())}),mZ=q.discriminatedUnion("type",[dZ,NZ,cZ,pZ,EZ,yZ,sZ,gZ]),tq=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:mZ.nullable().optional()}).strict(),SZ=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(),ZJ=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:w}).strict(),courseStructure:q.record(q.string(),SZ)}).strict(),oZ=q.object({student:$}).loose(),qJ=q.array(oZ).min(1,"results must have at least one item");import{z as K}from"zod/v4";var W=K.string().trim().min(1),rZ=K.enum(["edulastic","mastery-track"]),aZ=K.enum(["powerpath-100","quiz","test-out","placement","unit-test","alpha-read-article"]),z=K.array(F),t=K.record(K.string(),K.unknown()).optional(),ZZ=K.object({courseId:W,lessonTitle:W.optional(),launchUrl:K.url().optional(),toolProvider:rZ,unitTitle:W.optional(),courseComponentSourcedId:W.optional(),vendorId:W.optional(),description:W.optional(),resourceMetadata:t.nullable().optional(),grades:z}),XJ=ZZ.extend({lessonType:K.literal("test-out"),xp:K.number()}),YJ=ZZ.extend({lessonType:K.literal("placement"),courseIdOnFail:W.optional(),xp:K.number().optional()});var e=K.object({courseId:W,lessonType:aZ,lessonTitle:W.optional(),unitTitle:W.optional(),courseComponentSourcedId:W.optional(),resourceMetadata:t.nullable().optional(),xp:K.number().optional(),grades:z.optional(),courseIdOnFail:W.optional()}),_J=K.union([e.extend({testType:K.literal("qti"),qti:K.object({url:K.url(),title:W.optional(),metadata:K.record(K.string(),K.unknown()).optional()})}),e.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()}))})})]),$J=K.object({student:W,lesson:W}),HJ=K.object({student:W,lesson:W}),wJ=K.object({courseId:W,userId:W,classId:W.optional()}),I=K.object({type:K.enum(["component","resource"]),id:W}),iZ=K.union([K.object({type:K.literal("set-skipped"),payload:K.object({target:I,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:I,reference_id:W})}),K.object({type:K.literal("move-item-after"),payload:K.object({target:I,reference_id:W})}),K.object({type:K.literal("move-item-to-start"),payload:K.object({target:I})}),K.object({type:K.literal("move-item-to-end"),payload:K.object({target:I})}),K.object({type:K.literal("change-item-parent"),payload:K.object({target:I,new_parent_id:W,position:K.enum(["start","end"]).optional()})})]),VJ=K.object({operation:K.array(iZ),reason:W.optional()}),xJ=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:l,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()})}),FJ=K.object({student:W,lesson:W,applicationName:W.optional(),testId:W.optional(),skipCourseEnrollment:K.boolean().optional()}),LJ=K.object({student:W,subject:L}),UJ=K.object({student:W,lesson:W}),jJ=K.object({userId:W}),PJ=K.object({userId:W,subject:K.enum(["Math","Reading","Language","Science"])}),GJ=K.object({student:W,subject:L,grade:F,testName:W.optional()}),BJ=K.object({testName:W}),nZ=K.object({student:W,subject:L,grade:F,testName:W.optional()}),AJ=K.object({items:K.array(nZ)}),hJ=K.object({spreadsheetUrl:K.url(),sheet:W}),OJ=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()}),vJ=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()}),IJ=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}),CJ=K.object({student:W,lesson:W,attempt:K.number().int().positive().optional()}),kJ=K.object({student:W,lesson:W}),DJ=K.object({student:W,lesson:W}),QJ=K.object({student:W,lesson:W.optional(),finalized:K.boolean().optional(),toolProvider:W.optional(),attempt:K.number().int().positive().optional()}),MJ=K.object({student:W,lesson:W,applicationName:W.optional()}),fJ=K.object({student:W,subject:L}),bJ=K.object({status:K.enum(["active","tobedeleted"]).optional()});import{z as Z}from"zod/v4";var JZ=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"]),M=Z.enum(["single","multiple","ordered","record"]),f=Z.enum(["identifier","boolean","integer","float","string","point","pair","directedPair","duration","file","uri"]),eZ=Z.enum(["easy","medium","hard"]),zZ=Z.enum(["linear","nonlinear"]),tZ=Z.enum(["individual","simultaneous"]),b=Z.enum(["show","hide"]),KZ=Z.enum(["test","item","stimulus"]),uJ=Z.enum(["QUESTION","LESSON"]),Zq=Z.object({value:Z.array(Z.string())}).strict(),WZ=Z.object({identifier:Z.string().min(1),cardinality:M,baseType:f.optional(),correctResponse:Zq}).strict(),XZ=Z.object({identifier:Z.string().min(1),cardinality:M,baseType:f.optional()}).strict(),YZ=Z.object({identifier:Z.string().min(1),cardinality:M.optional(),baseType:f,normalMaximum:Z.number().optional(),normalMinimum:Z.number().optional(),defaultValue:Z.object({value:Z.unknown().optional()}).strict().optional()}).strict(),qq=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:qq.optional()}).strict(),Jq=Z.object({source:Z.string().min(1),learningObjectiveIds:Z.array(Z.string())}).strict(),$Z=Z.object({subject:Z.string().optional(),grade:F.optional(),difficulty:eZ.optional(),learningObjectiveSet:Z.array(Jq).optional()}).strict(),HZ=Z.object({outcomeIdentifier:Z.string().min(1),identifier:Z.string().min(1),showHide:b,content:Z.string(),title:Z.string()}).strict(),wZ=Z.object({outcomeIdentifier:Z.string().min(1),identifier:Z.string().min(1),showHide:b,content:Z.string(),class:Z.array(Z.string())}).strict(),VZ=Z.object({outcomeIdentifier:Z.string().min(1),identifier:Z.string().min(1),showHide:b,content:Z.string(),class:Z.array(Z.string())}).strict(),xZ=Z.object({href:Z.string().min(1),type:Z.string().min(1)}).strict(),FZ=Z.object({id:Z.string().min(1),support:Z.string(),content:Z.string()}).strict(),dJ=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(),NJ=Z.object({identifier:Z.string().min(1),title:Z.string().min(1),type:JZ,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:$Z.optional(),modalFeedback:Z.array(HZ).optional(),feedbackInline:Z.array(wZ).optional(),feedbackBlock:Z.array(VZ).optional()}).strict(),cJ=Z.object({identifier:Z.string().min(1).optional(),title:Z.string().min(1),type:JZ,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:$Z.optional(),modalFeedback:Z.array(HZ).optional(),feedbackInline:Z.array(wZ).optional(),feedbackBlock:Z.array(VZ).optional(),rawXml:Z.string(),content:Z.record(Z.string(),Z.unknown())}).strict(),pJ=Z.object({response:Z.union([Z.string(),Z.array(Z.string())])}).strict(),LZ=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(),qZ=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(LZ).optional()}).strict(),UZ=Z.object({identifier:Z.string().min(1),navigationMode:zZ,submissionMode:tZ,"qti-assessment-section":Z.union([qZ,Z.array(qZ)])}).strict(),EJ=Z.object({items:Z.array(LZ).min(1)}).strict(),yJ=Z.object({metadata:Z.record(Z.string(),Z.unknown()).optional()}).strict(),sJ=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":UZ,"qti-outcome-declaration":Z.array(YZ).optional()}).strict(),gJ=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":UZ,"qti-outcome-declaration":Z.array(YZ).optional()}).strict(),mJ=Z.object({identifier:Z.string().min(1),title:Z.string().min(1),label:Z.string().optional(),language:Z.string().optional(),stylesheet:xZ.optional(),content:Z.string(),catalogInfo:Z.array(FZ).optional(),toolName:Z.string().optional(),toolVersion:Z.string().optional(),metadata:Z.record(Z.string(),Z.unknown()).optional()}).strict(),SJ=Z.object({identifier:Z.string().min(1).optional(),title:Z.string().min(1),label:Z.string().optional(),language:Z.string().optional(),stylesheet:xZ.optional(),content:Z.string(),catalogInfo:Z.array(FZ).optional(),toolName:Z.string().optional(),toolVersion:Z.string().optional(),metadata:Z.record(Z.string(),Z.unknown()).optional()}).strict(),oJ=Z.object({xml:Z.string().optional(),schema:KZ,entityId:Z.string().optional()}).strict(),rJ=Z.object({xml:Z.array(Z.string()),schema:KZ,entityIds:Z.array(Z.string())}).strict(),aJ=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,Hq as c};
|
|
@@ -1,18 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
* Verification state for the current user.
|
|
4
|
-
*/
|
|
5
|
-
export type TimebackVerificationState = {
|
|
6
|
-
status: 'loading';
|
|
7
|
-
} | {
|
|
8
|
-
status: 'verified';
|
|
9
|
-
timebackId: string;
|
|
10
|
-
} | {
|
|
11
|
-
status: 'unverified';
|
|
12
|
-
} | {
|
|
13
|
-
status: 'error';
|
|
14
|
-
message: string;
|
|
15
|
-
};
|
|
1
|
+
import type { TimebackProfileState } from '../../../../shared/types';
|
|
2
|
+
export type { TimebackProfileState, TimebackVerificationState } from '../../../../shared/types';
|
|
16
3
|
/**
|
|
17
4
|
* Options for useTimebackVerification hook.
|
|
18
5
|
*/
|
|
@@ -47,20 +34,6 @@ export interface UseTimebackVerificationOptions {
|
|
|
47
34
|
*/
|
|
48
35
|
retryDelays?: number | readonly number[];
|
|
49
36
|
}
|
|
50
|
-
/**
|
|
51
|
-
* Profile state for the current user.
|
|
52
|
-
*/
|
|
53
|
-
export type TimebackProfileState = {
|
|
54
|
-
status: 'idle';
|
|
55
|
-
} | {
|
|
56
|
-
status: 'loading';
|
|
57
|
-
} | {
|
|
58
|
-
status: 'loaded';
|
|
59
|
-
profile: TimebackProfile;
|
|
60
|
-
} | {
|
|
61
|
-
status: 'error';
|
|
62
|
-
message: string;
|
|
63
|
-
};
|
|
64
37
|
/**
|
|
65
38
|
* Options for the useTimebackProfile hook.
|
|
66
39
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/client/adapters/react/hooks/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/client/adapters/react/hooks/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAEpE,YAAY,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAA;AAE/F;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC9C;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IAEjB;;;;;;;;;OASG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IAEtB;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAA;CACxC;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACzC;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IAEjB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;CACd;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACxC,4BAA4B;IAC5B,KAAK,EAAE,oBAAoB,CAAA;IAE3B,gFAAgF;IAChF,QAAQ,EAAE,OAAO,CAAA;IAEjB,oEAAoE;IACpE,YAAY,EAAE,MAAM,IAAI,CAAA;IAExB,2EAA2E;IAC3E,OAAO,EAAE,MAAM,IAAI,CAAA;CACnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTimebackVerification.d.ts","sourceRoot":"","sources":["../../../../../src/client/adapters/react/hooks/useTimebackVerification.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,yBAAyB,EAAE,8BAA8B,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"useTimebackVerification.d.ts","sourceRoot":"","sources":["../../../../../src/client/adapters/react/hooks/useTimebackVerification.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,yBAAyB,EAAE,8BAA8B,EAAE,MAAM,SAAS,CAAA;AAcxF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,GAAE,8BAAmC,GAAG;IACtF,KAAK,EAAE,yBAAyB,CAAA;IAChC,OAAO,EAAE,MAAM,IAAI,CAAA;CACnB,CAiGA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as h,b as o,c as l,d as r,e as QK,f as S,g as UK}from"../../../chunk-92nnwa7t.js";import*as D from"react";import{jsx as a}from"react/jsx-runtime";var p=D.createContext(void 0),R;function c(){if(!R)R=new S;return R}function i({client:K,children:J}){let[M,q]=D.useState(void 0);D.useEffect(()=>{if(!K&&!M)q(c())},[K,M]);let Q=K??M;return a(p.Provider,{value:Q,children:J})}function w(){return D.useContext(p)}import*as _ from"react";var T=new WeakMap,F=new WeakMap,j=new WeakMap,N=new WeakMap;function k(K){return!!K&&Date.now()-K.atMs<1500}function m(K){return!!K&&Date.now()-K.atMs<5000}async function b(K,J){if(!J){let q=F.get(K);if(k(q))return q.result;let Q=T.get(K);if(Q)return await Q}let M=K.user.verify().then((q)=>{if(T.get(K)===M)F.set(K,{atMs:Date.now(),result:q});return q});T.set(K,M);try{return await M}finally{if(T.get(K)===M)T.delete(K)}}function u(K){let J=F.get(K);return k(J)?J.result:void 0}async function d(K,J){if(!J){let q=N.get(K);if(m(q))return q.profile;let Q=j.get(K);if(Q)return await Q}let M=K.user.fetch().then((q)=>{if(j.get(K)===M)N.set(K,{atMs:Date.now(),profile:q});return q});j.set(K,M);try{return await M}finally{if(j.get(K)===M)j.delete(K)}}function v(K){let J=N.get(K);return m(J)?J.profile:void 0}function f(K){return K.verified?{status:"verified",timebackId:K.timebackId}:{status:"unverified"}}function C(K={}){let J=w(),M=K.enabled??!0,q=K.retryAttempts??h,Q=K.retryDelays??o,[L,Z]=_.useState({status:"loading"}),[G,H]=_.useState(0),V=_.useRef(0),E=_.useCallback(()=>{H((U)=>U+1)},[]);return _.useEffect(()=>{if(!M)return;let U=!1,A=G>V.current;if(J&&!A){let $=u(J);if($)return Z(f($)),()=>{U=!0}}return Z({status:"loading"}),(async()=>{if(!J)return;if(A)V.current=G;let $;for(let Y=0;Y<=q;Y++){if(U)return;if(Y>0){let X=r(Q,Y-1);if(await l(X),U)return}try{let X=await b(J,A||Y>0);if(U)return;Z(f(X));return}catch(X){$=X instanceof Error?X:Error("Failed to verify Timeback user")}}if(!U&&$)Z({status:"error",message:$.message})})(),()=>{U=!0}},[M,G,q,Q,J]),{state:L,refresh:E}}import*as z from"react";function t(K={}){let{enabled:J=!0,auto:M=!1}=K,q=w(),{state:Q}=C({enabled:J}),[L,Z]=z.useState({status:"idle"}),[G,H]=z.useState(0),[V,E]=z.useState(0),U=z.useRef(0),A=z.useRef(0),$=J&&Q.status==="verified"&&!!q,Y=z.useCallback(()=>{if(!$)return;H((O)=>O+1)},[$]),X=z.useCallback(()=>{if(!$)return;E((O)=>O+1)},[$]),P=z.useRef(!1);return z.useEffect(()=>{if(!J){Z({status:"idle"});return}if(Q.status!=="verified"){Z((W)=>W.status==="idle"?W:{status:"idle"}),P.current=!1;return}if(M&&!P.current&&G===0){P.current=!0,H(1);return}if(G===0&&V===0)return;let O=!1,n=G>U.current,y=V>A.current,g=y;if(!n&&!y){if(q){let W=v(q);if(W)return Z({status:"loaded",profile:W}),()=>{O=!0}}return}if(q&&!g){let W=v(q);if(W)return Z({status:"loaded",profile:W}),U.current=G,()=>{O=!0}}return Z({status:"loading"}),(async()=>{try{if(!q)return;U.current=G,A.current=V;let W=await d(q,g);if(O)return;Z({status:"loaded",profile:W})}catch(W){if(!O)Z({status:"error",message:W instanceof Error?W.message:"Failed to fetch profile"})}})(),()=>{O=!0}},[J,Q.status,G,V,q,M]),{state:L,canFetch:$,fetchProfile:Y,refresh:X}}import*as I from"react";import{jsx as B,jsxs as x}from"react/jsx-runtime";function e({className:K}){return x("svg",{className:K,width:"20",height:"18",viewBox:"0 0 199 180",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[x("g",{clipPath:"url(#tb-logo-clip)",children:[B("path",{d:"M121.432 179.456C110.607 177.871 101.153 173.91 92.4882 168.085C91.1274 167.17 89.4598 165.404 89.4375 164.008C89.2123 149.891 89.3002 135.77 89.3002 119.86C93.1365 123.255 95.8538 125.706 98.6224 128.099C103.151 132.012 107.437 136.28 112.314 139.703C126.466 149.635 145.037 147.25 156.045 134.448C166.919 121.803 167.226 101.374 155.695 89.6399C145.727 79.4958 134.693 70.3995 123.251 60.0438C123.251 77.8871 123.251 94.5637 123.251 112.15C121.428 110.999 120.279 110.479 119.383 109.676C110.329 101.573 101.241 93.5044 92.3634 85.2109C90.8519 83.7988 89.4363 81.3758 89.4209 79.4084C89.2249 54.4218 89.2905 29.4332 89.3061 4.44502C89.3066 3.64954 89.3061 2.22136 89.3061 1.47755C90.8061 1.47755 92.694 1.47857 94.1427 1.47755C118.131 1.46071 142.12 1.52088 166.108 1.39821C169.235 1.38222 171.33 2.18661 173.251 4.75826C180.607 14.6032 188.189 24.279 196.266 34.7705C179.79 34.7705 164.169 34.7705 148.548 34.7705C147.871 34.7705 147.366 34.7705 146.866 34.7705C147.866 35.7705 150.35 38.3018 151.61 39.4825C162.643 49.8249 174.663 59.3807 184.245 70.947C202.474 92.9508 203.539 118.134 191.204 143.046C178.598 168.508 156.61 180.302 128.298 180.295C126.154 180.295 124.011 179.778 121.432 179.456Z",fill:"currentColor"}),B("circle",{cx:"40",cy:"133",r:"39",fill:"currentColor"}),B("circle",{cx:"39",cy:"39",r:"39",fill:"currentColor"})]}),B("defs",{children:B("clipPath",{id:"tb-logo-clip",children:B("rect",{width:"199",height:"180",fill:"currentColor"})})})]})}function KK({className:K}){return x("svg",{className:K,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[B("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.25"}),B("path",{d:"M12 2C6.48 2 2 6.48 2 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}var qK=`
|
|
2
2
|
.timeback-signin-btn {
|
|
3
3
|
/* Colors */
|
|
4
4
|
--tb-btn-bg: #0f172a;
|
|
@@ -110,4 +110,4 @@ import{a as m,b as u,c as b,d,e as UK,f as S,g as ZK}from"../../../chunk-8gg8n8v
|
|
|
110
110
|
from { transform: rotate(0deg); }
|
|
111
111
|
to { transform: rotate(360deg); }
|
|
112
112
|
}
|
|
113
|
-
`,
|
|
113
|
+
`,s=!1;function JK(){if(typeof document>"u"||s)return;let K=document.createElement("style");K.setAttribute("data-timeback-styles",""),K.textContent=qK,document.head.appendChild(K),s=!0}function MK(K){let{children:J="Sign in with Timeback",className:M,style:q,disabled:Q,showLoading:L=!0,onClick:Z,variant:G="default",size:H="md",showLogo:V=!0}=K,E=w(),[U,A]=I.useState(!1),$=!!E;I.useEffect(()=>{JK()},[]);let Y=(P)=>{if(Z){if(Z(P),P.defaultPrevented)return}if(L)A(!0);E?.auth.signIn()},X=["timeback-signin-btn",G!=="default"&&`timeback-signin-btn--${G}`,H!=="md"&&`timeback-signin-btn--${H}`,M].filter(Boolean).join(" ");return x("button",{type:"button",className:X,style:q,disabled:Q||!$||U,onClick:Y,"aria-busy":U,children:[U?B(KK,{className:"timeback-signin-btn__spinner"}):V?B(e,{className:"timeback-signin-btn__logo"}):null,J]})}export{C as useTimebackVerification,t as useTimebackProfile,w as useTimeback,UK as createClient,i as TimebackProvider,S as TimebackClient,MK as SignInButton,QK as Activity};
|
|
@@ -3,35 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Types for Solid-specific primitives.
|
|
5
5
|
*/
|
|
6
|
-
import type {
|
|
7
|
-
|
|
8
|
-
* Verification state for the current user.
|
|
9
|
-
*/
|
|
10
|
-
export type TimebackVerificationState = {
|
|
11
|
-
status: 'loading';
|
|
12
|
-
} | {
|
|
13
|
-
status: 'verified';
|
|
14
|
-
timebackId: string;
|
|
15
|
-
} | {
|
|
16
|
-
status: 'unverified';
|
|
17
|
-
} | {
|
|
18
|
-
status: 'error';
|
|
19
|
-
message: string;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Profile state for the current user.
|
|
23
|
-
*/
|
|
24
|
-
export type TimebackProfileState = {
|
|
25
|
-
status: 'idle';
|
|
26
|
-
} | {
|
|
27
|
-
status: 'loading';
|
|
28
|
-
} | {
|
|
29
|
-
status: 'loaded';
|
|
30
|
-
profile: TimebackProfile;
|
|
31
|
-
} | {
|
|
32
|
-
status: 'error';
|
|
33
|
-
message: string;
|
|
34
|
-
};
|
|
6
|
+
import type { TimebackProfileState, TimebackVerificationState } from '../../../shared/types';
|
|
7
|
+
export type { TimebackProfileState, TimebackVerificationState } from '../../../shared/types';
|
|
35
8
|
/**
|
|
36
9
|
* Options for createTimebackVerification.
|
|
37
10
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/client/adapters/solid/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/client/adapters/solid/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAA;AAE5F,YAAY,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAA;AAE5F;;GAEG;AACH,MAAM,WAAW,iCAAiC;IACjD;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IAEjB;;;;;;;;;OASG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IAEtB;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAA;CACxC;AAED;;GAEG;AACH,MAAM,WAAW,gCAAgC;IAChD,iCAAiC;IACjC,KAAK,EAAE,yBAAyB,CAAA;IAEhC,qDAAqD;IACrD,OAAO,EAAE,MAAM,IAAI,CAAA;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC5C;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IAEjB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;CACd;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC3C,4BAA4B;IAC5B,KAAK,EAAE,oBAAoB,CAAA;IAE3B,gFAAgF;IAChF,QAAQ,EAAE,OAAO,CAAA;IAEjB,oEAAoE;IACpE,YAAY,EAAE,MAAM,IAAI,CAAA;IAExB,2EAA2E;IAC3E,OAAO,EAAE,MAAM,IAAI,CAAA;CACnB"}
|
|
@@ -4,25 +4,9 @@
|
|
|
4
4
|
* Types for Solid-specific primitives.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import type {
|
|
7
|
+
import type { TimebackProfileState, TimebackVerificationState } from '../../../shared/types'
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
* Verification state for the current user.
|
|
11
|
-
*/
|
|
12
|
-
export type TimebackVerificationState =
|
|
13
|
-
| { status: 'loading' }
|
|
14
|
-
| { status: 'verified'; timebackId: string }
|
|
15
|
-
| { status: 'unverified' }
|
|
16
|
-
| { status: 'error'; message: string }
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Profile state for the current user.
|
|
20
|
-
*/
|
|
21
|
-
export type TimebackProfileState =
|
|
22
|
-
| { status: 'idle' }
|
|
23
|
-
| { status: 'loading' }
|
|
24
|
-
| { status: 'loaded'; profile: TimebackProfile }
|
|
25
|
-
| { status: 'error'; message: string }
|
|
9
|
+
export type { TimebackProfileState, TimebackVerificationState } from '../../../shared/types'
|
|
26
10
|
|
|
27
11
|
/**
|
|
28
12
|
* Options for createTimebackVerification.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../src/client/adapters/svelte/stores/client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../src/client/adapters/svelte/stores/client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAIrD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAgB5C;;GAEG;AACH,eAAO,MAAM,WAAW,6DAAkD,CAAA;AAE1E;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,cAAc,GAAG,SAAS,CAE9D;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,YAAY,CAAC,MAAM,CAAC,EAAE,cAAc,GAAG,IAAI,CAQ1D;AASD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,cAAc,GAAG,SAAS,CAAe,CAAA"}
|
|
@@ -8,6 +8,8 @@ import { writable } from 'svelte/store'
|
|
|
8
8
|
|
|
9
9
|
import { TimebackClient } from '@timeback/sdk/client'
|
|
10
10
|
|
|
11
|
+
import { isBrowser } from '../../../lib/utils'
|
|
12
|
+
|
|
11
13
|
import type { Readable } from 'svelte/store'
|
|
12
14
|
|
|
13
15
|
let clientInstance: TimebackClient | undefined
|
|
@@ -24,15 +26,6 @@ function getOrCreateClient(): TimebackClient {
|
|
|
24
26
|
return clientInstance
|
|
25
27
|
}
|
|
26
28
|
|
|
27
|
-
/**
|
|
28
|
-
* Check if we're running in the browser.
|
|
29
|
-
*
|
|
30
|
-
* @returns True if in browser
|
|
31
|
-
*/
|
|
32
|
-
function isBrowser(): boolean {
|
|
33
|
-
return typeof window !== 'undefined'
|
|
34
|
-
}
|
|
35
|
-
|
|
36
29
|
/**
|
|
37
30
|
* Internal client store.
|
|
38
31
|
*/
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Svelte store for user profile state.
|
|
5
5
|
*/
|
|
6
|
-
import type { TimebackProfileState } from '../types';
|
|
7
6
|
import type { Readable } from 'svelte/store';
|
|
7
|
+
import type { TimebackProfileState } from '../types';
|
|
8
8
|
/**
|
|
9
9
|
* Store containing the Timeback profile state.
|
|
10
10
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../../../../src/client/adapters/svelte/stores/profile.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../../../../src/client/adapters/svelte/stores/profile.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,KAAK,EAAE,oBAAoB,EAA6B,MAAM,UAAU,CAAA;AAoE/E;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,oBAAoB,CAAgB,CAAA;AAE3E;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,OAAO,CAAiB,CAAA;AAEvE;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAS3C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAS7C"}
|
|
@@ -4,27 +4,20 @@
|
|
|
4
4
|
* Svelte store for user profile state.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import { writable } from 'svelte/store'
|
|
8
|
+
|
|
7
9
|
import { fetchProfileOnce, getProfileCache } from '../../../lib/user-cache'
|
|
10
|
+
import { isBrowser } from '../../../lib/utils'
|
|
8
11
|
import { getClientInstance } from './client'
|
|
9
|
-
import { writable } from 'svelte/store'
|
|
10
12
|
import { verificationStore } from './verification'
|
|
11
13
|
|
|
12
|
-
import type { TimebackProfileState, TimebackVerificationState } from '../types'
|
|
13
14
|
import type { Readable } from 'svelte/store'
|
|
15
|
+
import type { TimebackProfileState, TimebackVerificationState } from '../types'
|
|
14
16
|
|
|
15
17
|
const profileStore = writable<TimebackProfileState>({ status: 'idle' })
|
|
16
18
|
const canFetchStore = writable<boolean>(false)
|
|
17
19
|
let profileInitialized = false
|
|
18
20
|
|
|
19
|
-
/**
|
|
20
|
-
* Check if we're running in the browser.
|
|
21
|
-
*
|
|
22
|
-
* @returns True if in browser
|
|
23
|
-
*/
|
|
24
|
-
function isBrowser(): boolean {
|
|
25
|
-
return typeof window !== 'undefined'
|
|
26
|
-
}
|
|
27
|
-
|
|
28
21
|
/**
|
|
29
22
|
* Run the profile fetch.
|
|
30
23
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verification.d.ts","sourceRoot":"","sources":["../../../../../src/client/adapters/svelte/stores/verification.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAE5C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAA;AAczD,eAAO,MAAM,iBAAiB,4DAA6D,CAAA;
|
|
1
|
+
{"version":3,"file":"verification.d.ts","sourceRoot":"","sources":["../../../../../src/client/adapters/svelte/stores/verification.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAE5C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAA;AAczD,eAAO,MAAM,iBAAiB,4DAA6D,CAAA;AAoI3F;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,yBAAyB,CAAqB,CAAA;AAE1F;;;;;;;;;;;GAWG;AACH,wBAAgB,2BAA2B,IAAI,IAAI,CAGlD"}
|
|
@@ -8,7 +8,7 @@ import { writable } from 'svelte/store'
|
|
|
8
8
|
|
|
9
9
|
import { DEFAULT_RETRY_ATTEMPTS, DEFAULT_RETRY_DELAYS_MS } from '../../../../shared/constants'
|
|
10
10
|
import { getVerifyCache, verifyOnce } from '../../../lib/user-cache'
|
|
11
|
-
import { getRetryDelay, sleep } from '../../../lib/utils'
|
|
11
|
+
import { getRetryDelay, isBrowser, sleep } from '../../../lib/utils'
|
|
12
12
|
import { clientStore, getClientInstance } from './client'
|
|
13
13
|
|
|
14
14
|
import type { Readable } from 'svelte/store'
|
|
@@ -40,15 +40,6 @@ let verificationInitialized = false
|
|
|
40
40
|
*/
|
|
41
41
|
let currentRunId = 0
|
|
42
42
|
|
|
43
|
-
/**
|
|
44
|
-
* Check if we're running in the browser.
|
|
45
|
-
*
|
|
46
|
-
* @returns True if in browser
|
|
47
|
-
*/
|
|
48
|
-
function isBrowser(): boolean {
|
|
49
|
-
return typeof window !== 'undefined'
|
|
50
|
-
}
|
|
51
|
-
|
|
52
43
|
/**
|
|
53
44
|
* Run the verification check with retry logic.
|
|
54
45
|
*
|