@a-company/paradigm 6.3.0 → 6.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,7 +8,7 @@
8
8
  <link rel="preconnect" href="https://fonts.googleapis.com">
9
9
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
10
10
  <link href="https://fonts.googleapis.com/css2?family=Crimson+Pro:ital,wght@0,400;0,500;0,600;0,700;1,400&family=Inter:wght@300;400;500;600&display=swap" rel="stylesheet">
11
- <script type="module" crossorigin src="/assets/index-SNyIB61M.js"></script>
11
+ <script type="module" crossorigin src="/assets/index-BlS8W3tC.js"></script>
12
12
  <link rel="stylesheet" crossorigin href="/assets/index-CMrxD7y5.css">
13
13
  </head>
14
14
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@a-company/paradigm",
3
- "version": "6.3.0",
3
+ "version": "6.3.1",
4
4
  "description": "Unified CLI for Paradigm developer tools",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env node
2
- import'./chunk-5TAVYPOV.js';import P,{Router}from'express';import*as u from'path';import*as c from'fs';import {fileURLToPath}from'url';import f from'chalk';import*as I from'js-yaml';function k(e){let t=e.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n([\s\S]*)$/);if(!t)return null;try{return {fm:E(t[1]),body:t[2].trim()}}catch{return null}}function E(e){let t={},i=e.split(/\r?\n/);for(let s of i){if(!s.trim()||s.trim().startsWith("#"))continue;let r=s.match(/^([A-Za-z_][A-Za-z0-9_-]*)\s*:\s*(.*)$/);if(!r)continue;let n=r[1],o=r[2],a=r[2].trim();if(a.startsWith("[")&&a.endsWith("]")){let l=a.slice(1,-1).trim();o=l.length===0?[]:l.split(",").map(p=>p.trim().replace(/^['"]|['"]$/g,""));}else a.startsWith('"')&&a.endsWith('"')||a.startsWith("'")&&a.endsWith("'")?o=a.slice(1,-1):/^\d+$/.test(a)?o=parseInt(a,10):a==="true"||a==="false"?o=a==="true":o=a;t[n]=o;}return t}function b(e){try{let t=c.readFileSync(e,"utf-8");return I.load(t)}catch{return null}}function z(e){let t=u.join(e,"paths");if(!c.existsSync(t))return [];let i=c.readdirSync(t).filter(r=>r.startsWith("LP-")&&r.endsWith(".yaml")),s=[];for(let r of i){let n=b(u.join(t,r));n?.id&&s.push(n);}return s}function L(e,t,i){let s=u.join(e,"notes"),r=u.join(e,"quizzes"),n=[],o=new Set,a=i.steps||[];for(let l of a){let p=l.content;if(!p.startsWith("N-")||o.has(p))continue;o.add(p);let d=p.slice(`N-${t}-`.length),j=u.join(s,`${p}.md`);if(!c.existsSync(j))continue;let D=c.readFileSync(j,"utf-8"),y=k(D);if(!y)continue;let g=y.fm,m={id:d,title:g.title||d,content:y.body},$=u.join(r,`Q-${t}-${d}.yaml`);if(c.existsSync($)){let v=b($);v?.questions&&(m.quiz=v.questions);}n.push(m);}return n}function O(e,t){let i=u.join(e,"paths",`LP-${t}.yaml`);if(!c.existsSync(i))return null;let s=b(i);if(!s?.id)return null;let r=L(e,t,s);return {id:t,title:s.title,description:s.description||"",lessons:r}}function R(e){let t=Router();return t.get("/",(i,s)=>{let r=z(e).filter(n=>n.id.startsWith("LP-para-")).map(n=>{let o=n.id.slice(3),a=L(e,o,n);return {id:o,title:n.title,description:n.description||"",lessonCount:a.length,lessons:a.map(l=>({id:l.id,title:l.title}))}});return r.sort((n,o)=>n.id.localeCompare(o.id)),s.json({courses:r})}),t.get("/:id",(i,s)=>{let r=O(e,i.params.id);return r?s.json(r):s.status(404).json({error:`Course '${i.params.id}' not found`})}),t.get("/:id/lessons/:lessonId",(i,s)=>{let r=O(e,i.params.id);if(!r)return s.status(404).json({error:`Course '${i.params.id}' not found`});let n=r.lessons.find(o=>o.id===i.params.lessonId);return n?s.json(n):s.status(404).json({error:`Lesson '${i.params.lessonId}' not found`})}),t}function q(e){try{let t=c.readFileSync(e,"utf-8");return I.load(t)}catch{return null}}function Q(e){for(let t=e.length-1;t>0;t--){let i=Math.floor(Math.random()*(t+1));[e[t],e[i]]=[e[i],e[t]];}return e}function J(e){if(!e.variants||e.variants.length===0)return e;let t=[{id:e.id,scenario:e.scenario??"",question:e.question,choices:e.choices,correct:e.correct,explanation:e.explanation??""},...e.variants];return t[Math.floor(Math.random()*t.length)]}function U(e){return e.questions.length}function V(e){let t={},i=[],s=new Map;for(let r of e.questions){let n=J(r),o={id:n.id,course:r.section??"",scenario:n.scenario??r.scenario??"",question:n.question,choices:n.choices,correct:n.correct,explanation:n.explanation??r.explanation??"",...r.passageId?{passageId:r.passageId}:{}};r.passageId?(r.passage&&(t[r.passageId]=r.passage),s.has(r.passageId)||s.set(r.passageId,[]),s.get(r.passageId).push(o)):i.push([o]);}for(let r of s.values())i.push(r);return Q(i),{questions:i.flat(),passages:t}}function Z(e,t){let i=Router(),s=u.join(e,"quizzes");return i.get("/",(r,n)=>{if(!c.existsSync(s))return n.json({versions:[]});let o=c.readdirSync(s).filter(a=>a.startsWith("Q-plsat-v")&&a.endsWith(".yaml")).map(a=>{let l=q(u.join(s,a));if(!l)return null;let p=a.match(/^Q-plsat-v(\d+)\.yaml$/);return {version:p?`${p[1]}.0`:"0.0",frameworkVersion:"2.0",questionCount:U(l),timeLimit:l.timeLimit,passThreshold:l.passThreshold}}).filter(a=>a!==null);return o.sort((a,l)=>l.version.localeCompare(a.version)),n.json({versions:o})}),i.get("/:version",(r,n)=>{try{let o=r.params.version.split(".")[0],a=u.join(s,`Q-plsat-v${o}.yaml`);if(!c.existsSync(a))return n.status(404).json({error:`PLSAT version '${r.params.version}' not found`});let l=q(a);if(!l)return n.status(500).json({error:"Failed to parse PLSAT exam"});let{questions:p,passages:d}=V(l);return n.json({version:r.params.version,frameworkVersion:"2.0",timeLimit:l.timeLimit,passThreshold:l.passThreshold,title:l.title,description:l.description??"",questions:p,...Object.keys(d).length>0?{passages:d}:{}})}catch(o){let a=o instanceof Error?o.message:"Internal error";return n.status(500).json({error:`Failed to load PLSAT exam: ${a}`})}}),i.post("/diploma",(r,n)=>{if(!t)return n.status(400).json({error:"No project directory configured"});let o=u.join(t,".paradigm","university","diplomas");if(!c.existsSync(o))return n.json({saved:false,reason:"university directory not found"});try{let{student:a,version:l,score:p,total:d,percentage:j,passed:D}=r.body;if(!a||!l||p==null||d==null)return n.status(400).json({error:"Missing required fields: student, version, score, total"});let y=new Date().toISOString().slice(0,10),g=String(a).toLowerCase().replace(/[^a-z0-9-]/g,"-").slice(0,20),m=`D-${y}-${g}-plsat-v${l}`,$={id:m,type:"plsat",student:g,earnedAt:new Date().toISOString(),source:`plsat:v${l}`,score:p,total:d,percentage:j??(d>0?Math.round(p/d*1e4)/100:0),passed:D??!1,details:{plsatVersion:l}},v=u.join(o,`${m}.yaml`),W=Object.entries($).map(([w,S])=>{if(typeof S=="object"&&S!==null){let F=Object.entries(S).map(([N,C])=>` ${N}: ${JSON.stringify(C)}`).join(`
3
- `);return `${w}:
4
- ${F}`}return `${w}: ${JSON.stringify(S)}`});return c.writeFileSync(v,W.join(`
5
- `)+`
6
- `,"utf8"),n.json({saved:!0,diplomaId:m})}catch(a){let l=a instanceof Error?a.message:"Internal error";return n.status(500).json({error:`Failed to save diploma: ${l}`})}}),i}var _=fileURLToPath(import.meta.url),x=u.dirname(_);function G(e){let t=e;for(;t!==u.dirname(t);){if(c.existsSync(u.join(t,"package.json"))&&JSON.parse(c.readFileSync(u.join(t,"package.json"),"utf-8")).name==="@a-company/university")return t;t=u.dirname(t);}return e}var h={component(e){let t=f.magenta(`#${e}`);return {info:(i,s)=>{let r=s?f.gray(` ${Object.entries(s).map(([n,o])=>`${n}=${o}`).join(" ")}`):"";console.log(`${f.blue("\u2139")} ${t} ${i}${r}`);},success:(i,s)=>{let r=s?f.gray(` ${Object.entries(s).map(([n,o])=>`${n}=${o}`).join(" ")}`):"";console.log(`${f.green("\u2714")} ${t} ${i}${r}`);},warn:(i,s)=>{let r=s?f.gray(` ${Object.entries(s).map(([n,o])=>`${n}=${o}`).join(" ")}`):"";console.log(`${f.yellow("\u26A0")} ${t} ${i}${r}`);},error:(i,s)=>{let r=s?f.gray(` ${Object.entries(s).map(([n,o])=>`${n}=${o}`).join(" ")}`):"";console.error(`${f.red("\u2716")} ${t} ${i}${r}`);}}}};function B(e){if(e?.contentDir&&e?.uiDistPath)return {contentDir:e.contentDir,uiDistPath:e.uiDistPath};let t=u.join(x,"university-content"),i=u.join(x,"university-ui");if(c.existsSync(t)&&c.existsSync(i))return {contentDir:e?.contentDir||t,uiDistPath:e?.uiDistPath||i};let s=G(x);return {contentDir:e?.contentDir||u.join(s,"src","content"),uiDistPath:e?.uiDistPath||u.join(s,"ui","dist")}}function T(e){let t=P();t.use(P.json()),t.use((r,n,o)=>{n.header("Access-Control-Allow-Origin","*"),n.header("Access-Control-Allow-Methods","GET, POST, PUT, DELETE, OPTIONS"),n.header("Access-Control-Allow-Headers","Content-Type"),o();});let{contentDir:i,uiDistPath:s}=B(e);return t.use("/api/courses",R(i)),t.use("/api/plsat",Z(i,e?.projectDir)),t.get("/api/reference",(r,n)=>{let o=u.join(i,"reference.json");if(c.existsSync(o)){let a=JSON.parse(c.readFileSync(o,"utf-8"));n.json(a);}else n.status(404).json({error:"Reference data not found"});}),t.get("/api/health",(r,n)=>{n.json({status:"ok",timestamp:new Date().toISOString()});}),c.existsSync(s)&&(t.use(P.static(s)),t.get("{*path}",(r,n)=>{r.path.startsWith("/api")||n.sendFile(u.join(s,"index.html"));})),t}async function H(e){let t=T({contentDir:e.contentDir,uiDistPath:e.uiDistPath,projectDir:e.projectDir});return h.component("university-server").info("Starting server",{port:e.port}),new Promise((i,s)=>{t.listen(e.port,()=>{h.component("university-server").success("Server running",{url:`http://localhost:${e.port}`}),e.open&&import('open').then(r=>{r.default(`http://localhost:${e.port}`),h.component("university-server").info("Opened browser");}).catch(()=>{h.component("university-server").warn("Could not open browser automatically");}),i();}).on("error",r=>{r.code==="EADDRINUSE"?h.component("university-server").error("Port already in use",{port:e.port}):h.component("university-server").error("Server error",{error:r.message}),s(r);});})}
7
- export{T as createApp,H as startServer};