@pindownai/client-js 1.3.2 → 1.3.5
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 +29 -5
- package/dist/PindownClient-Blc0tgqw.d.cts +668 -0
- package/dist/PindownClient-Blc0tgqw.d.ts +668 -0
- package/dist/ai/index.cjs +9 -0
- package/dist/ai/index.cjs.map +1 -0
- package/dist/ai/index.d.cts +93 -0
- package/dist/ai/index.d.ts +93 -0
- package/dist/ai/index.js +9 -0
- package/dist/ai/index.js.map +1 -0
- package/dist/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +33 -646
- package/dist/index.d.ts +33 -646
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/package.json +27 -2
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use strict';var ai=require('ai'),zod=require('zod');var P=["markdown","image","gallery","table","charts","mermaid","code","embed","pdf-viewer","excel-viewer","stat-cards","timeline","json-viewer","json-list","links","qr-code","social-handles","steps","trace","plan","notes","csv-viewer","user-story","chat","intro","mastra","text-media","business-card","video","audio","file-upload","kanban-board","checklist","comparison","calendar","roadmap","realtime-canvas"];[...P];var d={markdown:["content","collaboration"],image:["url","altText","fit"],gallery:["images"],table:["columns","rows"],charts:["chartType","data","xAxis","yAxis"],mermaid:["diagram","code","title"],code:["code","language","filename","title"],embed:["url","type"],"pdf-viewer":["pdf"],"excel-viewer":["excel"],"stat-cards":["cards"],timeline:["mode","items"],"json-viewer":["json","jsonString","title"],"json-list":["json","jsonString"],links:["links"],"qr-code":["url","label"],"social-handles":["title","showLabels","iconSize","handles"],steps:["steps"],trace:["title","live","spans"],plan:["title","status","breadcrumbs","phases"],notes:["notes"],"csv-viewer":["csvText","csvData","fileName"],"user-story":["title","userStory","acceptanceCriteria"],chat:["title","placeholder","linked_pin_id","linked_pin_title"],intro:["heading","subheading"],mastra:["mode","agentId","workflowId"],"text-media":["title","text","subtext","textPosition","mediaType","embedConfig","imageConfig"],"business-card":["sectionTitle","fields","imageConfig","imagePosition"],video:["url","fileId","fileName","mimeType","caption","size"],audio:["url","fileId","fileName","mimeType","caption","size","tracks"],"file-upload":["files","displayMode"],"kanban-board":["columns"],checklist:["title","items"],comparison:["title","left","right","highlightedLines","matches","showVsBadge"],calendar:["weekStartsOn","events"],roadmap:["title","months"],"realtime-canvas":["title","description","roomId"]};function S(e){return e.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join("")}var wn={pin_type:"table",summary:"Spreadsheet-style pin. columns is required; rows are optional but needed for visible data.",required_fields:["columns"],optional_fields:["rows"],fields:[{path:"columns",type:"TableColumn[]",required:true,description:"At least one column. Each column needs id + name (type optional, e.g. text | number)."},{path:"columns[].id",type:"string",required:true,description:"Stable column key used in row.cells."},{path:"columns[].name",type:"string",required:true,description:"Column header label."},{path:"rows",type:"TableRow[]",required:false,description:"Table data. Each row: { id, cells: { [columnId]: value } }."}],example_config:{columns:[{id:"col1",name:"Name",type:"text"},{id:"col2",name:"Value",type:"number"}],rows:[{id:"row1",cells:{col1:"Item",col2:1}}]},example_update:{pin_config:{columns:[{id:"col1",name:"Name",type:"text"},{id:"col2",name:"Value",type:"number"}],rows:[{id:"row1",cells:{col1:"Updated",col2:42}}]}}},xn={table:wn,markdown:{pin_type:"markdown",summary:"Rich text / markdown body.",required_fields:[],optional_fields:["content","collaboration"],fields:[{path:"content",type:"string",required:false,description:"Markdown source. Server seeds Yjs when set on create."}],example_config:{content:`# Hello
|
|
2
|
+
|
|
3
|
+
Body text.`},example_update:{pin_config:{content:`# Updated
|
|
4
|
+
|
|
5
|
+
New body.`}}},"stat-cards":{pin_type:"stat-cards",summary:"KPI cards grid.",required_fields:["cards"],optional_fields:[],fields:[{path:"cards",type:"StatCardItem[]",required:true,description:"Each card: title, value; optional change, trend (up|down|neutral)."}],example_config:{cards:[{title:"Revenue",value:"1000",change:"+5%",trend:"up"}]},example_update:{pin_config:{cards:[{title:"Revenue",value:"1234",change:"+8%",trend:"up"}]}}}};function Tn(e){return xn[e]}function j(e){let t=Tn(e);return t?[`Pin type: ${t.pin_type}`,t.summary,"","Required pin_config fields:",...t.required_fields.map(o=>` - ${o}`),"","Optional pin_config fields:",...t.optional_fields.length?t.optional_fields.map(o=>` - ${o}`):[" (none documented)"],"","Field reference:",...t.fields.map(o=>` ${o.path} (${o.type}${o.required?", required":""}): ${o.description}`),"","Example update payload:",JSON.stringify(t.example_update,null,2)].join(`
|
|
6
|
+
`):[`No built-in hint for pin type "${e}".`,"Use CreatePinRequest<typeof pinType> / PinConfigByType[typeof pinType] in TypeScript,","or client.pins.create({ pin_type, pin_config, metadata }) with typed pin_config."].join(`
|
|
7
|
+
`)}function v(e){let t=e;for(;;){if(t instanceof zod.z.ZodOptional||t instanceof zod.z.ZodNullable){t=t.unwrap();continue}if(t instanceof zod.z.ZodDefault){t=t.removeDefault();continue}if(t instanceof zod.z.ZodEffects){t=t.innerType();continue}break}return t}var _n=()=>zod.z.union([zod.z.string(),zod.z.number(),zod.z.boolean(),zod.z.null()]);function u(e){let t=v(e);if(t instanceof zod.z.ZodRecord)return zod.z.array(zod.z.object({key:zod.z.string(),value:_n()}));if(t instanceof zod.z.ZodArray)return zod.z.array(u(t.element));if(t instanceof zod.z.ZodObject){let i={};for(let[o,r]of Object.entries(t.shape))i[o]=u(r);return t._def.unknownKeys==="passthrough"?zod.z.object(i).passthrough():zod.z.object(i)}return e}function w(e){let t={};if(!Array.isArray(e))return t;for(let i of e){if(!i||typeof i!="object")continue;let o=i,r=o.key??o.columnId;if(r==null)continue;let a=o.value;t[r]=Array.isArray(a)&&A(a)?w(a):a;}return t}function A(e){return e.every(t=>t&&typeof t=="object"&&("key"in t||"columnId"in t))}function R(e){if(Array.isArray(e)&&A(e))return w(e);if(e&&typeof e=="object"&&!Array.isArray(e)){let t=e,i={};for(let[o,r]of Object.entries(t))i[o]=R(r);return i}return e}function m(e,t){if(e==null)return e;let i=v(t);if(i instanceof zod.z.ZodRecord)return Array.isArray(e)?w(e):R(e);if(i instanceof zod.z.ZodArray)return Array.isArray(e)?e.map(o=>m(o,i.element)):e;if(i instanceof zod.z.ZodObject){if(!e||typeof e!="object"||Array.isArray(e))return e;let r={...e};for(let[a,p]of Object.entries(i.shape))a in r&&(r[a]=m(r[a],p));return r}return e}var l={TABLE_MAX_ROWS:100,KEY_VALUE_MAX_ITEMS:48,CARDS_MAX_ITEMS:24,TRACE_MAX_SPANS:50,OKR_MAX_KEY_RESULTS:50,GALLERY_MAX_IMAGES:32};var In=zod.z.object({}).passthrough(),M=zod.z.object({content:zod.z.string().optional(),collaboration:zod.z.object({enabled:zod.z.boolean().optional()}).optional()}).passthrough(),E=zod.z.object({cards:zod.z.array(zod.z.object({title:zod.z.string(),value:zod.z.union([zod.z.string(),zod.z.number()])}).passthrough()).min(1,"stat-cards pin_config.cards must contain at least one card")}).passthrough(),L=zod.z.object({url:zod.z.string().optional(),altText:zod.z.string().optional(),fit:zod.z.string().optional()}).passthrough(),z=zod.z.object({url:zod.z.string().min(1).optional(),fileId:zod.z.string().optional(),fileName:zod.z.string().optional(),mimeType:zod.z.literal("video/mp4").optional(),caption:zod.z.string().optional(),size:zod.z.number().positive().optional()}).passthrough(),Sn=zod.z.object({url:zod.z.string().min(1),fileId:zod.z.string().optional(),fileName:zod.z.string().optional(),mimeType:zod.z.enum(["audio/mpeg","audio/wav","audio/x-wav"]).optional(),size:zod.z.number().positive().optional()}).passthrough(),O=zod.z.object({url:zod.z.string().min(1).optional(),fileId:zod.z.string().optional(),fileName:zod.z.string().optional(),mimeType:zod.z.enum(["audio/mpeg","audio/wav","audio/x-wav"]).optional(),caption:zod.z.string().optional(),size:zod.z.number().positive().optional(),tracks:zod.z.array(Sn).max(10).optional()}).passthrough().refine(e=>!!String(e.url??"").trim()||Array.isArray(e.tracks)&&e.tracks.length>0,{message:"Audio pin requires url or at least one track"}),q=zod.z.object({columns:zod.z.array(zod.z.object({id:zod.z.string(),name:zod.z.string(),type:zod.z.string().optional()}).passthrough()).min(1),rows:zod.z.array(zod.z.object({id:zod.z.string(),cells:zod.z.record(zod.z.string(),zod.z.union([zod.z.string(),zod.z.number(),zod.z.boolean(),zod.z.null()])).refine(e=>Object.keys(e).length>0,{message:"each table row must include at least one cell value"})}).passthrough()).min(1).max(l.TABLE_MAX_ROWS).optional()}).passthrough(),N=zod.z.object({chartType:zod.z.string().optional(),data:zod.z.array(zod.z.record(zod.z.string(),zod.z.unknown())).optional()}).passthrough(),B=zod.z.object({url:zod.z.string().optional(),type:zod.z.string().optional()}).passthrough(),H=zod.z.object({pdf:zod.z.object({url:zod.z.string().min(1)}).passthrough()}).passthrough(),U=zod.z.object({excel:zod.z.object({url:zod.z.string().min(1)}).passthrough()}).passthrough(),V=zod.z.object({items:zod.z.array(zod.z.record(zod.z.string(),zod.z.unknown())).optional(),mode:zod.z.string().optional()}).passthrough(),G=zod.z.object({json:zod.z.unknown().optional(),jsonString:zod.z.string().optional(),title:zod.z.string().optional()}).passthrough(),Z=zod.z.object({json:zod.z.array(zod.z.unknown()).optional(),jsonString:zod.z.string().optional()}).passthrough(),K=zod.z.object({links:zod.z.array(zod.z.record(zod.z.string(),zod.z.unknown())).optional()}).passthrough(),$=zod.z.object({steps:zod.z.array(zod.z.object({title:zod.z.string()}).passthrough()).min(1)}).passthrough(),F=zod.z.object({spans:zod.z.array(zod.z.object({name:zod.z.string(),status:zod.z.enum(["completed","running","pending","failed"])}).passthrough()).min(1,"trace pin_config.spans must contain at least one span").max(l.TRACE_MAX_SPANS)}).passthrough(),jn=zod.z.object({type:zod.z.enum(["details","command","code","text","link","mermaid","summary"])}).passthrough(),vn=zod.z.object({title:zod.z.string(),blocks:zod.z.array(jn).optional()}).passthrough(),Y=zod.z.object({phases:zod.z.array(zod.z.object({title:zod.z.string(),tasks:zod.z.array(vn).min(1)}).passthrough()).min(1,"plan pin_config.phases must contain at least one phase")}).passthrough(),D=zod.z.object({notes:zod.z.array(zod.z.object({title:zod.z.string()}).passthrough()).optional()}).passthrough(),X=zod.z.object({csvData:zod.z.array(zod.z.record(zod.z.string(),zod.z.unknown())).optional(),csvText:zod.z.string().optional(),fileName:zod.z.string().optional()}).passthrough(),J=zod.z.object({images:zod.z.array(zod.z.record(zod.z.string(),zod.z.unknown())).max(l.GALLERY_MAX_IMAGES).optional()}).passthrough(),W=zod.z.object({code:zod.z.string().optional(),diagram:zod.z.string().optional(),title:zod.z.string().optional()}).passthrough().refine(e=>!!(e.code?.trim()||e.diagram?.trim()),{message:"mermaid pin_config requires code or diagram"}),Q=zod.z.object({code:zod.z.string().min(1),language:zod.z.string().optional(),filename:zod.z.string().optional(),title:zod.z.string().optional()}).passthrough(),nn=zod.z.object({userStory:zod.z.string().min(1)}).passthrough(),en=zod.z.object({title:zod.z.string().optional(),placeholder:zod.z.string().optional(),linked_pin_id:zod.z.string().optional(),linked_pin_title:zod.z.string().optional()}).passthrough(),tn=zod.z.object({heading:zod.z.string().min(1)}).passthrough(),on=zod.z.object({title:zod.z.string().optional(),text:zod.z.string().optional()}).passthrough(),rn=zod.z.object({sectionTitle:zod.z.string().optional(),fields:zod.z.array(zod.z.object({id:zod.z.string(),key:zod.z.string(),value:zod.z.string()}).passthrough()).min(1),imagePosition:zod.z.enum(["left","right"]).optional()}).passthrough(),an=zod.z.object({url:zod.z.string().optional(),label:zod.z.string().optional()}).passthrough(),sn=zod.z.object({title:zod.z.string().optional(),showLabels:zod.z.boolean().optional(),iconSize:zod.z.number().optional(),handles:zod.z.array(zod.z.object({platform:zod.z.string(),url:zod.z.string(),label:zod.z.string().optional()}).passthrough()).optional()}).passthrough(),pn=zod.z.object({files:zod.z.array(zod.z.record(zod.z.string(),zod.z.unknown())).optional(),displayMode:zod.z.string().optional()}).passthrough(),ln=zod.z.object({columns:zod.z.array(zod.z.object({id:zod.z.string(),title:zod.z.string()}).passthrough()).min(1)}).passthrough(),cn=zod.z.object({id:zod.z.string(),name:zod.z.string(),description:zod.z.string().optional(),checked:zod.z.boolean().optional()}).passthrough(),An=zod.z.object({id:zod.z.string(),title:zod.z.string(),label:zod.z.string().optional(),items:zod.z.array(cn).min(1)}).passthrough(),gn=zod.z.object({mode:zod.z.enum(["flat","sections"]).optional(),title:zod.z.string().optional(),footer:zod.z.string().optional(),items:zod.z.array(cn).optional(),sections:zod.z.array(An).optional()}).passthrough().superRefine((e,t)=>{if((e.mode==="sections"?"sections":"flat")==="sections"){(!Array.isArray(e.sections)||e.sections.length===0)&&t.addIssue({code:zod.z.ZodIssueCode.custom,message:"checklist sections mode requires at least one section"});return}(!Array.isArray(e.items)||e.items.length===0)&&t.addIssue({code:zod.z.ZodIssueCode.custom,message:"checklist flat mode requires at least one item"});}),Rn=zod.z.object({url:zod.z.string(),alt:zod.z.string().optional(),link:zod.z.string().optional(),fileId:zod.z.string().optional()}).passthrough(),Mn=zod.z.object({id:zod.z.string(),image:Rn,title:zod.z.string(),subtext:zod.z.string().optional()}).passthrough();zod.z.object({title:zod.z.string().optional(),layout:zod.z.enum(["horizontal","vertical","gallery"]).optional(),columns:zod.z.union([zod.z.literal(2),zod.z.literal(3),zod.z.literal(4)]).optional(),items:zod.z.array(Mn).min(1).max(l.CARDS_MAX_ITEMS)}).passthrough();var En=zod.z.object({id:zod.z.string(),key:zod.z.string(),value:zod.z.union([zod.z.string(),zod.z.number()]),unit:zod.z.string().optional(),hint:zod.z.string().optional()}).passthrough();zod.z.object({title:zod.z.string().optional(),subtitle:zod.z.string().optional(),period:zod.z.string().optional(),layout:zod.z.enum(["list","grid"]).optional(),columns:zod.z.union([zod.z.literal(2),zod.z.literal(3),zod.z.literal(4)]).optional(),items:zod.z.array(En).min(1).max(l.KEY_VALUE_MAX_ITEMS)}).passthrough();var Ln=zod.z.object({id:zod.z.string(),question:zod.z.string(),answer:zod.z.string()}).passthrough();zod.z.object({title:zod.z.string().optional(),items:zod.z.array(Ln).min(1)}).passthrough();var zn=zod.z.object({id:zod.z.string(),label:zod.z.string(),url:zod.z.string(),variant:zod.z.enum(["primary","secondary","outline"]).optional()}).passthrough();zod.z.object({headline:zod.z.string().optional(),subline:zod.z.string().optional(),buttons:zod.z.array(zn).min(1).max(2)}).passthrough();var dn=zod.z.object({title:zod.z.string().optional(),left:zod.z.object({label:zod.z.string(),body:zod.z.string()}).passthrough(),right:zod.z.object({label:zod.z.string(),body:zod.z.string()}).passthrough(),highlightedLines:zod.z.object({left:zod.z.array(zod.z.number().int().nonnegative()).optional(),right:zod.z.array(zod.z.number().int().nonnegative()).optional()}).optional(),matches:zod.z.array(zod.z.object({left:zod.z.number().int().nonnegative(),right:zod.z.number().int().nonnegative()})).optional(),showVsBadge:zod.z.boolean().optional()}).passthrough(),un=zod.z.object({events:zod.z.array(zod.z.record(zod.z.string(),zod.z.unknown())).optional(),weekStartsOn:zod.z.number().optional()}).passthrough(),mn=zod.z.object({months:zod.z.array(zod.z.record(zod.z.string(),zod.z.unknown())).optional(),title:zod.z.string().optional()}).passthrough();zod.z.object({title:zod.z.string().optional(),defaultView:zod.z.enum(["onboarding","bottlenecks"]).optional(),showTeam:zod.z.boolean().optional(),team:zod.z.array(zod.z.object({id:zod.z.string(),name:zod.z.string(),role:zod.z.string(),avatarUrl:zod.z.string().optional(),status:zod.z.enum(["live","away","offline"]).optional()}).passthrough()).optional(),swimlanes:zod.z.array(zod.z.object({id:zod.z.string(),title:zod.z.string()}).passthrough()).min(1),nodes:zod.z.array(zod.z.object({id:zod.z.string(),swimlane:zod.z.string(),label:zod.z.string()}).passthrough()).min(1),edges:zod.z.array(zod.z.object({source:zod.z.string(),target:zod.z.string()}).passthrough()).optional()}).passthrough();zod.z.object({title:zod.z.string().optional(),subtitle:zod.z.string().optional(),valueFormat:zod.z.enum(["number","percent","currency"]).optional(),currency:zod.z.string().optional(),highlightBiggestDrop:zod.z.boolean().optional(),stages:zod.z.array(zod.z.object({id:zod.z.string(),label:zod.z.string(),value:zod.z.number()}).passthrough()).min(1)}).passthrough();zod.z.object({title:zod.z.string().optional(),subtitle:zod.z.string().optional(),maxScore:zod.z.number().optional(),options:zod.z.array(zod.z.object({id:zod.z.string(),label:zod.z.string()}).passthrough()).min(2),criteria:zod.z.array(zod.z.object({id:zod.z.string(),label:zod.z.string(),scores:zod.z.record(zod.z.string(),zod.z.number())}).passthrough()).min(1)}).passthrough();zod.z.object({title:zod.z.string().optional(),subtitle:zod.z.string().optional(),period:zod.z.string().optional(),objectives:zod.z.array(zod.z.object({id:zod.z.string(),title:zod.z.string(),keyResults:zod.z.array(zod.z.record(zod.z.string(),zod.z.unknown())).min(1)}).passthrough()).min(1)}).passthrough().refine(e=>(Array.isArray(e.objectives)?e.objectives:[]).reduce((o,r)=>o+(Array.isArray(r.keyResults)?r.keyResults.length:0),0)<=l.OKR_MAX_KEY_RESULTS,{message:`okr pin_config supports at most ${l.OKR_MAX_KEY_RESULTS} key results total`});zod.z.object({question:zod.z.string().min(1),options:zod.z.array(zod.z.object({id:zod.z.string(),label:zod.z.string()}).passthrough()).min(2),status:zod.z.enum(["open","closed"]).optional(),showVoteCount:zod.z.boolean().optional(),allowChangeVote:zod.z.boolean().optional()}).passthrough();zod.z.object({title:zod.z.string().optional(),description:zod.z.string().optional(),prompt:zod.z.string().optional(),items:zod.z.array(zod.z.object({id:zod.z.string(),label:zod.z.string(),description:zod.z.string().optional(),required:zod.z.boolean().optional()}).passthrough()).optional(),status:zod.z.enum(["open","closed"]).optional(),maxStars:zod.z.number().min(3).max(5).optional(),allowHalfStars:zod.z.boolean().optional(),allowChangeRating:zod.z.boolean().optional(),showAverage:zod.z.boolean().optional()}).passthrough();zod.z.object({title:zod.z.string().optional(),description:zod.z.string().optional(),status:zod.z.enum(["open","closed"]).optional(),allowEditResponse:zod.z.boolean().optional(),questions:zod.z.array(zod.z.object({id:zod.z.string(),label:zod.z.string(),type:zod.z.enum(["short-text","long-text","single-choice","multiple-choice","scale"]),required:zod.z.boolean().optional(),options:zod.z.array(zod.z.object({id:zod.z.string(),label:zod.z.string()}).passthrough()).optional(),scaleMin:zod.z.number().optional(),scaleMax:zod.z.number().optional()}).passthrough()).min(1)}).passthrough();var fn=zod.z.object({title:zod.z.string().optional(),description:zod.z.string().optional(),roomId:zod.z.string().optional()}).passthrough(),yn=In;var hn={markdown:M,image:L,gallery:J,table:q,charts:N,mermaid:W,code:Q,embed:B,"pdf-viewer":H,"excel-viewer":U,"stat-cards":E,timeline:V,"json-viewer":G,"json-list":Z,links:K,"qr-code":an,"social-handles":sn,steps:$,trace:F,plan:Y,notes:D,"csv-viewer":X,"user-story":nn,chat:en,intro:tn,mastra:yn,"text-media":on,"business-card":rn,video:z,audio:O,"file-upload":pn,"kanban-board":ln,checklist:gn,comparison:dn,calendar:un,roadmap:mn,"realtime-canvas":fn};function C(e){return hn[e]}function x(e){return u(C(e))}var On={table:qn};function T(e,t){let i=On[e];return i?i(t):t}function qn(e){if(!e||typeof e!="object")return e;let t=e;if(!Array.isArray(t.rows))return e;let i=new Set((t.columns??[]).map(r=>r?.id).filter(r=>!!r)),o=t.rows.map((r,a)=>{if(!r||typeof r!="object"||Array.isArray(r))return r;let p=r,c=String(p.id??`row-${a+1}`);if(p.cells&&typeof p.cells=="object"&&!Array.isArray(p.cells))return {...p,id:c,cells:p.cells};let y={};for(let[g,k]of Object.entries(p))g!=="id"&&(i.size===0||i.has(g))&&(y[g]=k);return {id:c,cells:y}});return {...t,rows:o}}var Nn={google:"@ai-sdk/google",anthropic:"@ai-sdk/anthropic",openai:"@ai-sdk/openai"},Pn={google:"GOOGLE_GENERATIVE_AI_API_KEY",anthropic:"ANTHROPIC_API_KEY",openai:"OPENAI_API_KEY"};async function Bn(e){let t=Nn[e];try{let i=await import(t);return e==="google"?o=>i.createGoogleGenerativeAI(o):e==="anthropic"?o=>i.createAnthropic(o):o=>i.createOpenAI(o)}catch{throw new Error(`Missing optional dependency "${t}". Install it to use provider "${e}" (npm install ${t} ai zod).`)}}function Cn(){let e=[process.env.GOOGLE_GENERATIVE_AI_API_KEY,process.env.GOOGLE_API_KEY].map(i=>i?.trim()).filter(i=>!!i);if(!e.length)return;let t=e.find(i=>i.startsWith("AIzaSy")&&i.length===39);return t||e.sort((i,o)=>o.length-i.length)[0]}async function _(e){let t=e.apiKey??(e.provider==="google"?Cn():process.env[Pn[e.provider]]);if(!t){let o="GOOGLE_GENERATIVE_AI_API_KEY or GOOGLE_API_KEY";throw new Error(`No API key for provider "${e.provider}". Pass llm.apiKey or set ${e.provider==="google"?o:Pn[e.provider]}.`)}return (await Bn(e.provider))({apiKey:t})(e.model)}var b=class extends Error{constructor(t,i,o){super(i),this.name="PinConfigMaterializeError",this.pinType=t,this.zodError=o;}};function Un(e){if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Vn(e,t){if(t)return t;let i=d[e].join(", ");return [`You convert arbitrary user text or JSON into a valid Pindown pin_config for pin_type "${e}".`,`Only output top-level pin_config fields for this type: ${i}.`,"Map user data faithfully. Invent stable string ids where needed (columns, rows, cards, etc.).","Where a field is a key-value map, output it as [{ key, value }, ...] (one entry per key).","Do not include metadata (title, tags) \u2014 only pin_config shape."].join(" ")}var Gn=ai.generateObject;async function I(e,t,i,o){let r=C(t),a=x(t),p=await _(i),c=j(t),y=Un(e),{object:g}=await Gn({model:p,schema:a,temperature:o?.temperature??0,maxRetries:o?.maxRetries??2,system:Vn(t,o?.system),prompt:[`Pin type: ${t}`,"",c,"","User input:",y].join(`
|
|
8
|
+
`)}),k=m(g,r),kn=T(t,k),h=r.safeParse(kn);if(!h.success)throw new b(t,`LLM output failed validation for pin_type "${t}": ${h.error.message}`,h.error);return h.data}function Zn(e,t,i){let o={...i};for(let r of d[e]){let a=i[r],p=t[r];o[r]=a!==void 0?a:p;}return o}function Kn(e,t,i){let o={...i??{}};for(let r of d[e]){let a=i?i[r]:void 0,p=t[r];a!==void 0?o[r]=a:p!==void 0&&(o[r]=p);}return o}var f=class{constructor(t,i,o,r){this.input=t;this.pinType=i;this.llm=o;this.options=r;}using(t){return this.client=t,this}with(t){return this.using(t)}async materialize(){return this.materializedPromise||(this.materializedPromise=I(this.input,this.pinType,this.llm,this.options)),this.materializedPromise}async createPin(t,i){let o=i??this.requireClient(),r=await this.materialize();return o.pins.createPin(this.pinType,Zn(this.pinType,r,t))}async updatePin(t,i,o){let r=o??this.requireClient(),a=await this.materialize();return r.pins.updatePin(t,this.pinType,Kn(this.pinType,a,i))}requireClient(){if(!this.client)throw new Error("Pindown client required. Call .using(client) first or pass client as the last argument.");return this.client}};function $n(e){for(let t of P){let i=S(t),o=`create${i}`,r=`update${i}`;e[o]=function(a,p){if(this.pinType!==t)throw new Error(`${o}() requires pin type "${t}", got "${this.pinType}"`);return this.createPin(a,p)},e[r]=function(a,p,c){if(this.pinType!==t)throw new Error(`${r}() requires pin type "${t}", got "${this.pinType}"`);return this.updatePin(a,p,c)};}}$n(f.prototype);function bn(e,t,i,o){return new f(e,t,i,o)}var Fn=bn;exports.PIN_CONFIG_ZOD_SCHEMAS=hn;exports.PinConfigMaterializeError=b;exports.PinConfigPipe=f;exports.canonicalizePinConfigForApi=T;exports.getLlmPinConfigZodSchema=x;exports.getPinConfigZodSchema=C;exports.materializePinConfig=I;exports.normalizeLlmPinConfigOutput=m;exports.pipePinConfig=Fn;exports.resolveGoogleApiKey=Cn;exports.resolveLanguageModel=_;exports.toConfig=bn;exports.toLlmPinConfigSchema=u;//# sourceMappingURL=index.cjs.map
|
|
9
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/types/pins.ts","../../src/client/pins/pin-helper-core.ts","../../src/pin-config-hints.ts","../../src/ai/llm-schema-transform.ts","../../src/ai/pin-config-limits.ts","../../src/ai/pin-config-schemas.ts","../../src/ai/pin-config-zod-map.ts","../../src/ai/pin-config-canonical.ts","../../src/ai/providers.ts","../../src/ai/materialize.ts","../../src/ai/pipe.ts"],"names":["PRODUCT_PIN_TYPES","PIN_CONFIG_FIELDS","pinTypeToMethodSuffix","pinType","part","TABLE_HINT","PIN_CONFIG_HINTS","getPinConfigHint","formatPinConfigHint","hint","f","unwrapSchema","schema","current","z","llmEntryValue","toLlmPinConfigSchema","base","shape","key","value","entriesArrayToRecord","data","record","item","entry","looksLikeEntryArray","normalizeRecordValue","obj","out","k","v","normalizeLlmPinConfigOutput","apiSchema","output","fieldSchema","PIN_TYPE_ITEM_LIMITS","looseObject","markdownPinConfigSchema","statCardsPinConfigSchema","imagePinConfigSchema","videoPinConfigSchema","audioPinTrackSchema","audioPinConfigSchema","tablePinConfigSchema","cells","chartsPinConfigSchema","embedPinConfigSchema","pdfViewerPinConfigSchema","excelViewerPinConfigSchema","timelinePinConfigSchema","jsonViewerPinConfigSchema","jsonListPinConfigSchema","linksPinConfigSchema","stepsPinConfigSchema","tracePinConfigSchema","planContentBlockSchema","planTaskSchema","planPinConfigSchema","notesPinConfigSchema","csvViewerPinConfigSchema","galleryPinConfigSchema","mermaidPinConfigSchema","codePinConfigSchema","userStoryPinConfigSchema","chatPinConfigSchema","introPinConfigSchema","textMediaPinConfigSchema","businessCardPinConfigSchema","qrCodePinConfigSchema","socialHandlesPinConfigSchema","fileUploadPinConfigSchema","kanbanBoardPinConfigSchema","checklistItemSchema","checklistSectionSchema","checklistPinConfigSchema","ctx","cardsImageSchema","cardsItemSchema","keyValueItemSchema","faqItemSchema","ctaButtonSchema","comparisonPinConfigSchema","calendarPinConfigSchema","roadmapPinConfigSchema","config","sum","objective","realtimeCanvasPinConfigSchema","mastraPinConfigSchema","PIN_CONFIG_ZOD_SCHEMAS","getPinConfigZodSchema","getLlmPinConfigZodSchema","PIN_CONFIG_CANONICAL_NORMALIZERS","canonicalizeTablePinConfig","canonicalizePinConfigForApi","normalizer","table","columnIds","col","id","rows","row","index","PROVIDER_PACKAGES","DEFAULT_ENV_KEYS","loadProviderFactory","provider","pkg","mod","opts","resolveGoogleApiKey","candidates","validAiza","a","b","resolveLanguageModel","apiKey","googleHint","PinConfigMaterializeError","message","zodError","serializePipeInput","input","buildSystemPrompt","override","fields","runGenerateObject","generateObject","materializePinConfig","llm","options","llmSchema","model","inputText","object","normalized","canonical","parsed","mergeConfigIntoCreateInput","materialized","merged","fromInput","fromLlm","mergeConfigIntoUpdateInput","PinConfigPipe","client","c","pin_config","pinId","attachNamedPipeMethods","proto","suffix","createMethod","updateMethod","toConfig","pipePinConfig"],"mappings":"qDAMO,IAAMA,CAAAA,CAAoB,CAC/B,UAAA,CACA,OAAA,CACA,SAAA,CACA,QACA,QAAA,CACA,SAAA,CACA,MAAA,CACA,OAAA,CACA,YAAA,CACA,cAAA,CACA,aACA,UAAA,CACA,aAAA,CACA,WAAA,CACA,OAAA,CACA,SAAA,CACA,gBAAA,CACA,OAAA,CACA,OAAA,CACA,MAAA,CACA,OAAA,CACA,YAAA,CACA,YAAA,CACA,MAAA,CACA,OAAA,CACA,SACA,YAAA,CACA,eAAA,CACA,OAAA,CACA,OAAA,CACA,aAAA,CACA,cAAA,CACA,YACA,YAAA,CACA,UAAA,CACA,SAAA,CACA,iBACF,CAAA,CAE6B,CAAC,GAAGA,CAAiB,EClC3C,IAAMC,CAAAA,CAAmG,CAC9G,QAAA,CAAU,CAAC,SAAA,CAAW,eAAe,CAAA,CACrC,KAAA,CAAO,CAAC,KAAA,CAAO,UAAW,KAAK,CAAA,CAC/B,OAAA,CAAS,CAAC,QAAQ,CAAA,CAClB,MAAO,CAAC,SAAA,CAAW,MAAM,CAAA,CACzB,MAAA,CAAQ,CAAC,YAAa,MAAA,CAAQ,OAAA,CAAS,OAAO,CAAA,CAC9C,OAAA,CAAS,CAAC,SAAA,CAAW,MAAA,CAAQ,OAAO,CAAA,CACpC,IAAA,CAAM,CAAC,MAAA,CAAQ,UAAA,CAAY,WAAY,OAAO,CAAA,CAC9C,KAAA,CAAO,CAAC,KAAA,CAAO,MAAM,EACrB,YAAA,CAAc,CAAC,KAAK,CAAA,CACpB,cAAA,CAAgB,CAAC,OAAO,CAAA,CACxB,YAAA,CAAc,CAAC,OAAO,CAAA,CACtB,QAAA,CAAU,CAAC,MAAA,CAAQ,O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A1B,CAAAA,CACAuB,CAAAA,CACA,CACA,GAAI,IAAA,CAAK,OAAA,GAAY/I,CAAAA,CACnB,MAAM,IAAI,KAAA,CAAM,GAAGuJ,CAAY,CAAA,sBAAA,EAAyBvJ,CAAO,CAAA,QAAA,EAAW,IAAA,CAAK,OAAO,CAAA,CAAA,CAAG,CAAA,CAE3F,OAAO,IAAA,CAAK,SAAA,CAAUkJ,EAAO1B,CAAAA,CAAOuB,CAAM,CAC5C,EACF,CACF,CAEAI,EAAAA,CAAuBL,CAAAA,CAAc,SAAS,CAAA,CAgBvC,SAASU,GACdhC,CAAAA,CACAxH,CAAAA,CACA+H,EACAC,CAAAA,CAC4C,CAC5C,OAAO,IAAIc,CAAAA,CAActB,EAAOxH,CAAAA,CAAS+H,CAAAA,CAAKC,CAAO,CACvD,KAGayB,EAAAA,CAAgBD","file":"index.cjs","sourcesContent":["/**\n * Pin types for the v1 Pins API.\n * Aligned with backend-api/src/lib/pin-types.ts + pin-config-schemas.ts.\n * Import per-type *PinConfig interfaces for typed CRUD payloads.\n */\n\nexport const PRODUCT_PIN_TYPES = [\n 'markdown',\n 'image',\n 'gallery',\n 'table',\n 'charts',\n 'mermaid',\n 'code',\n 'embed',\n 'pdf-viewer',\n 'excel-viewer',\n 'stat-cards',\n 'timeline',\n 'json-viewer',\n 'json-list',\n 'links',\n 'qr-code',\n 'social-handles',\n 'steps',\n 'trace',\n 'plan',\n 'notes',\n 'csv-viewer',\n 'user-story',\n 'chat',\n 'intro',\n 'mastra',\n 'text-media',\n 'business-card',\n 'video',\n 'audio',\n 'file-upload',\n 'kanban-board',\n 'checklist',\n 'comparison',\n 'calendar',\n 'roadmap',\n 'realtime-canvas',\n] as const\n\nexport const ALL_PIN_TYPES = [...PRODUCT_PIN_TYPES] as const\n\nexport type ProductPinTypeId = (typeof PRODUCT_PIN_TYPES)[number]\nexport type PinTypeId = (typeof ALL_PIN_TYPES)[number]\n\nexport type PinLayout = '1x1' | '1x2' | '2x1' | '2x2' | '3x1' | '3x2' | '3x3' | '4x4'\n\nexport type PinDataType = 'markdown' | 'json' | 'text' | 'pin-card'\n\n/** @deprecated Use PinTypeId */\nexport type PinCardType = PinTypeId\n\nexport interface StatCardItem {\n title: string\n value: string | number\n change?: string\n trend?: 'up' | 'down' | 'neutral' | string\n icon?: string\n [key: string]: unknown\n}\n\nexport interface TableColumn {\n id: string\n name: string\n type?: string\n [key: string]: unknown\n}\n\nexport interface TableRow {\n id: string\n cells: Record<string, unknown>\n [key: string]: unknown\n}\n\nexport interface KanbanColumn {\n id: string\n title: string\n cards?: Array<Record<string, unknown>>\n [key: string]: unknown\n}\n\nexport interface ChecklistItem {\n id: string\n name: string\n checked?: boolean\n [key: string]: unknown\n}\n\nexport interface GalleryImage {\n url: string\n alt?: string\n [key: string]: unknown\n}\n\nexport interface LinkItem {\n title: string\n url: string\n [key: string]: unknown\n}\n\nexport interface StepItem {\n title: string\n description?: string\n [key: string]: unknown\n}\n\nexport interface MarkdownPinConfig {\n content?: string\n collaboration?: { enabled?: boolean }\n [key: string]: unknown\n}\n\nexport interface ImagePinConfig {\n url?: string\n altText?: string\n fit?: 'cover' | 'contain' | string\n [key: string]: unknown\n}\n\nexport interface GalleryPinConfig {\n images?: GalleryImage[]\n [key: string]: unknown\n}\n\nexport interface TablePinConfig {\n columns: TableColumn[]\n rows?: TableRow[]\n [key: string]: unknown\n}\n\nexport interface ChartsPinConfig {\n chartType?: string\n data?: Array<Record<string, unknown>>\n xAxis?: string\n yAxis?: string\n [key: string]: unknown\n}\n\nexport interface MermaidPinConfig {\n diagram?: string\n code?: string\n title?: string\n [key: string]: unknown\n}\n\nexport interface CodePinConfig {\n code: string\n language?: string\n filename?: string\n title?: string\n [key: string]: unknown\n}\n\nexport interface EmbedPinConfig {\n url?: string\n type?: string\n [key: string]: unknown\n}\n\nexport interface PdfViewerPinConfig {\n pdf: { url: string; fileName?: string; title?: string; [key: string]: unknown }\n [key: string]: unknown\n}\n\nexport interface ExcelViewerPinConfig {\n excel: { url: string; fileName?: string; title?: string; [key: string]: unknown }\n [key: string]: unknown\n}\n\nexport interface StatCardsPinConfig {\n cards: StatCardItem[]\n [key: string]: unknown\n}\n\nexport interface TimelinePinConfig {\n mode?: string\n items?: Array<Record<string, unknown>>\n [key: string]: unknown\n}\n\nexport interface JsonViewerPinConfig {\n json?: unknown\n jsonString?: string\n title?: string\n [key: string]: unknown\n}\n\nexport interface JsonListPinConfig {\n json?: unknown[]\n jsonString?: string\n [key: string]: unknown\n}\n\nexport interface LinksPinConfig {\n links?: LinkItem[]\n [key: string]: unknown\n}\n\nexport interface QrCodePinConfig {\n url?: string\n label?: string\n [key: string]: unknown\n}\n\nexport interface SocialHandleItem {\n id?: string\n platform: string\n url: string\n label?: string\n [key: string]: unknown\n}\n\nexport interface SocialHandlesPinConfig {\n title?: string\n showLabels?: boolean\n iconSize?: number\n handles?: SocialHandleItem[]\n [key: string]: unknown\n}\n\nexport interface StepsPinConfig {\n steps: StepItem[]\n [key: string]: unknown\n}\n\nexport type TraceSpanStatus = 'completed' | 'running' | 'pending' | 'failed'\nexport type TraceSpanType = 'system' | 'agent' | 'tool'\n\nexport interface TraceSpanItem {\n id?: string\n type?: TraceSpanType\n name: string\n status: TraceSpanStatus\n timestamp?: string\n duration?: string\n details?: string\n}\n\nexport interface TracePinConfig {\n title?: string\n live?: boolean\n spans: TraceSpanItem[]\n [key: string]: unknown\n}\n\nexport type PlanContentBlock =\n | { type: 'details'; title?: string; items: string[] }\n | { type: 'command'; command: string; label?: string }\n | { type: 'code'; code: string; language?: string; filename?: string }\n | { type: 'text'; content: string }\n | { type: 'link'; url: string; label?: string }\n | { type: 'mermaid'; diagram: string; title?: string }\n | { type: 'summary'; content: string; title?: string }\n\nexport interface PlanTaskItem {\n id?: string\n number?: string\n title: string\n label?: string\n description?: string\n blocks?: PlanContentBlock[]\n [key: string]: unknown\n}\n\nexport interface PlanPhaseItem {\n id?: string\n title: string\n status?: 'pending' | 'in-progress' | 'completed'\n tasks: PlanTaskItem[]\n [key: string]: unknown\n}\n\nexport interface PlanPinConfig {\n title?: string\n status?: 'draft' | 'in-progress' | 'completed'\n breadcrumbs?: Array<{ label: string }>\n phases: PlanPhaseItem[]\n [key: string]: unknown\n}\n\nexport interface NoteItem {\n id?: string\n title: string\n content?: string\n order?: number\n createdAt?: number\n updatedAt?: number\n}\n\nexport interface NotesPinConfig {\n notes?: NoteItem[]\n [key: string]: unknown\n}\n\nexport interface CsvViewerPinConfig {\n csvText?: string\n csvData?: Array<Record<string, unknown>>\n fileName?: string\n [key: string]: unknown\n}\n\nexport interface UserStoryPinConfig {\n title?: string\n userStory: string\n acceptanceCriteria?: string\n [key: string]: unknown\n}\n\nexport interface ChatPinConfig {\n title?: string\n placeholder?: string\n /** Pin this discussion thread is about (commentary / feedback). */\n linked_pin_id?: string\n /** Cached title for display without fetching the linked pin. */\n linked_pin_title?: string\n [key: string]: unknown\n}\n\nexport interface IntroPinConfig {\n heading: string\n subheading?: string\n [key: string]: unknown\n}\n\nexport interface MastraPinConfig {\n mode?: 'workflow' | 'agent' | string\n agentId?: string\n workflowId?: string\n [key: string]: unknown\n}\n\nexport interface BusinessCardField {\n id: string\n key: string\n value: string\n}\n\nexport interface BusinessCardPinConfig {\n sectionTitle?: string\n fields?: BusinessCardField[]\n imageConfig?: { url?: string; alt?: string; fileId?: string; [key: string]: unknown }\n imagePosition?: 'left' | 'right' | string\n [key: string]: unknown\n}\n\nexport interface VideoPinConfig {\n url?: string\n fileId?: string\n fileName?: string\n mimeType?: 'video/mp4' | string\n caption?: string\n size?: number\n [key: string]: unknown\n}\n\nexport interface AudioPinTrack {\n url: string\n fileId?: string\n fileName?: string\n mimeType?: 'audio/mpeg' | 'audio/wav' | 'audio/x-wav' | string\n size?: number\n [key: string]: unknown\n}\n\nexport interface AudioPinConfig {\n url?: string\n fileId?: string\n fileName?: string\n mimeType?: 'audio/mpeg' | 'audio/wav' | 'audio/x-wav' | string\n caption?: string\n size?: number\n tracks?: AudioPinTrack[]\n [key: string]: unknown\n}\n\nexport interface TextMediaPinConfig {\n title?: string\n text?: string\n subtext?: string\n textPosition?: 'left' | 'right' | string\n mediaType?: 'embed' | 'image' | string\n embedConfig?: {\n type?: string\n url?: string\n aspectRatio?: string\n autoplay?: boolean\n [key: string]: unknown\n }\n imageConfig?: {\n url?: string\n alt?: string\n fileId?: string\n [key: string]: unknown\n }\n [key: string]: unknown\n}\n\nexport interface FileUploadPinConfig {\n files?: Array<Record<string, unknown>>\n displayMode?: string\n [key: string]: unknown\n}\n\nexport interface KanbanBoardPinConfig {\n columns: KanbanColumn[]\n [key: string]: unknown\n}\n\nexport interface ChecklistPinConfig {\n title?: string\n items: ChecklistItem[]\n [key: string]: unknown\n}\n\nexport interface ComparisonSideConfig {\n label: string\n body: string\n}\n\nexport interface ComparisonMatchPair {\n left: number\n right: number\n}\n\nexport interface ComparisonPinConfig {\n title?: string\n left: ComparisonSideConfig\n right: ComparisonSideConfig\n highlightedLines?: { left?: number[]; right?: number[] }\n matches?: ComparisonMatchPair[]\n showVsBadge?: boolean\n [key: string]: unknown\n}\n\nexport interface CalendarPinConfig {\n weekStartsOn?: number\n events?: Array<Record<string, unknown>>\n [key: string]: unknown\n}\n\nexport interface RoadmapPinConfig {\n title?: string\n months?: Array<Record<string, unknown>>\n [key: string]: unknown\n}\n\nexport interface RealtimeCanvasPinConfig {\n title?: string\n description?: string\n roomId?: string\n [key: string]: unknown\n}\n\nexport interface PinConfigByType {\n markdown: MarkdownPinConfig\n image: ImagePinConfig\n gallery: GalleryPinConfig\n table: TablePinConfig\n charts: ChartsPinConfig\n mermaid: MermaidPinConfig\n code: CodePinConfig\n embed: EmbedPinConfig\n 'pdf-viewer': PdfViewerPinConfig\n 'excel-viewer': ExcelViewerPinConfig\n 'stat-cards': StatCardsPinConfig\n timeline: TimelinePinConfig\n 'json-viewer': JsonViewerPinConfig\n 'json-list': JsonListPinConfig\n links: LinksPinConfig\n 'qr-code': QrCodePinConfig\n 'social-handles': SocialHandlesPinConfig\n steps: StepsPinConfig\n trace: TracePinConfig\n plan: PlanPinConfig\n notes: NotesPinConfig\n 'csv-viewer': CsvViewerPinConfig\n 'user-story': UserStoryPinConfig\n chat: ChatPinConfig\n intro: IntroPinConfig\n mastra: MastraPinConfig\n 'text-media': TextMediaPinConfig\n 'business-card': BusinessCardPinConfig\n video: VideoPinConfig\n audio: AudioPinConfig\n 'file-upload': FileUploadPinConfig\n 'kanban-board': KanbanBoardPinConfig\n checklist: ChecklistPinConfig\n comparison: ComparisonPinConfig\n calendar: CalendarPinConfig\n roadmap: RoadmapPinConfig\n 'realtime-canvas': RealtimeCanvasPinConfig\n}\n\nexport interface PinMetadataBase {\n title: string\n tags?: string[]\n description?: string\n allow_edit?: boolean\n require_sign_in?: boolean\n allow_comments?: boolean\n}\n\nexport type PinMetadata<T extends PinTypeId = PinTypeId> = PinMetadataBase & {\n pin_type?: T\n pin_config?: PinConfigByType[T]\n pin_layout?: PinLayout\n}\n\nexport interface CreateTypedPinRequest<T extends PinTypeId> {\n pin_type: T\n pin_config: PinConfigByType[T]\n pin_layout?: PinLayout\n is_public?: boolean\n allow_edit?: boolean\n require_sign_in?: boolean\n allow_comments?: boolean\n metadata: PinMetadataBase\n pending_invites?: Record<string, 'editor' | 'viewer'>\n /** @deprecated Inferred from pin_type */\n data_type?: PinDataType\n}\n\nexport interface CreateNestedPinRequest<T extends PinTypeId> {\n pin_layout?: PinLayout\n is_public?: boolean\n allow_edit?: boolean\n require_sign_in?: boolean\n allow_comments?: boolean\n metadata: PinMetadata<T> & PinMetadataBase\n pending_invites?: Record<string, 'editor' | 'viewer'>\n data_type?: PinDataType\n}\n\nexport type CreatePinRequest<T extends PinTypeId = PinTypeId> =\n | CreateTypedPinRequest<T>\n | CreateNestedPinRequest<T>\n\nexport interface UpdatePinRequest<T extends PinTypeId = PinTypeId> {\n pin_type?: T\n pin_config?: PinConfigByType[T]\n pin_layout?: PinLayout\n is_public?: boolean\n metadata?: Partial<PinMetadata<T>>\n}\n\nexport interface Pin<T extends PinTypeId = PinTypeId> {\n id: string\n owner_id: string\n user_id?: string\n title?: string\n description?: string\n data_type: PinDataType\n is_public: boolean\n allow_edit: boolean\n require_sign_in: boolean\n allow_comments: boolean\n metadata?: PinMetadata<T>\n created_at: string | number\n updated_at: string | number\n}\n\nexport interface SharePinRequest {\n is_public?: boolean\n allow_edit?: boolean\n require_sign_in?: boolean\n allow_comments?: boolean\n}\n\nexport interface ListPinsOptions {\n limit?: number\n offset?: number\n}\n\nexport interface CreatePinOptions {\n pin_layout?: PinLayout\n is_public?: boolean\n allow_edit?: boolean\n require_sign_in?: boolean\n allow_comments?: boolean\n pending_invites?: Record<string, 'editor' | 'viewer'>\n}\n\n/** Flat create input: metadata + pin_config fields (all pin types). */\nexport type CreatePinHelperInput<T extends PinTypeId> = PinMetadataBase &\n CreatePinOptions &\n PinConfigByType[T]\n\n/** Flat update input: optional metadata + partial pin_config fields. */\nexport type UpdatePinHelperInput<T extends PinTypeId> = {\n pin_layout?: PinLayout\n is_public?: boolean\n title?: string\n tags?: string[]\n description?: string\n metadata?: Partial<PinMetadataBase>\n} & Partial<PinConfigByType[T]>\n\nexport interface CreateMarkdownPinInput extends PinMetadataBase {\n content: string\n pin_layout?: PinLayout\n is_public?: boolean\n allow_edit?: boolean\n require_sign_in?: boolean\n allow_comments?: boolean\n pending_invites?: Record<string, 'editor' | 'viewer'>\n}\n\nexport interface CreateStatCardsPinInput extends PinMetadataBase {\n cards: StatCardItem[]\n pin_layout?: PinLayout\n is_public?: boolean\n}\n\nexport interface CreateTablePinInput extends PinMetadataBase {\n columns: TableColumn[]\n rows?: TableRow[]\n pin_layout?: PinLayout\n is_public?: boolean\n}\n\nexport interface UpdateTablePinInput extends UpdatePinHelperInput<'table'> {}\n\nexport interface CreateEmbedPinInput extends PinMetadataBase {\n url: string\n type?: string\n pin_layout?: PinLayout\n is_public?: boolean\n}\n","import {\n PRODUCT_PIN_TYPES,\n type CreatePinHelperInput,\n type CreateTypedPinRequest,\n type PinConfigByType,\n type PinMetadataBase,\n type PinTypeId,\n type UpdatePinHelperInput,\n type UpdatePinRequest,\n} from '../../types/pins'\n\n/** Known pin_config keys per type (top-level only). */\nexport const PIN_CONFIG_FIELDS: { readonly [K in PinTypeId]: readonly (keyof PinConfigByType[K] & string)[] } = {\n markdown: ['content', 'collaboration'],\n image: ['url', 'altText', 'fit'],\n gallery: ['images'],\n table: ['columns', 'rows'],\n charts: ['chartType', 'data', 'xAxis', 'yAxis'],\n mermaid: ['diagram', 'code', 'title'],\n code: ['code', 'language', 'filename', 'title'],\n embed: ['url', 'type'],\n 'pdf-viewer': ['pdf'],\n 'excel-viewer': ['excel'],\n 'stat-cards': ['cards'],\n timeline: ['mode', 'items'],\n 'json-viewer': ['json', 'jsonString', 'title'],\n 'json-list': ['json', 'jsonString'],\n links: ['links'],\n 'qr-code': ['url', 'label'],\n 'social-handles': ['title', 'showLabels', 'iconSize', 'handles'],\n steps: ['steps'],\n trace: ['title', 'live', 'spans'],\n plan: ['title', 'status', 'breadcrumbs', 'phases'],\n notes: ['notes'],\n 'csv-viewer': ['csvText', 'csvData', 'fileName'],\n 'user-story': ['title', 'userStory', 'acceptanceCriteria'],\n chat: ['title', 'placeholder', 'linked_pin_id', 'linked_pin_title'],\n intro: ['heading', 'subheading'],\n mastra: ['mode', 'agentId', 'workflowId'],\n 'text-media': ['title', 'text', 'subtext', 'textPosition', 'mediaType', 'embedConfig', 'imageConfig'],\n 'business-card': ['sectionTitle', 'fields', 'imageConfig', 'imagePosition'],\n video: ['url', 'fileId', 'fileName', 'mimeType', 'caption', 'size'],\n audio: ['url', 'fileId', 'fileName', 'mimeType', 'caption', 'size', 'tracks'],\n 'file-upload': ['files', 'displayMode'],\n 'kanban-board': ['columns'],\n checklist: ['title', 'items'],\n comparison: ['title', 'left', 'right', 'highlightedLines', 'matches', 'showVsBadge'],\n calendar: ['weekStartsOn', 'events'],\n roadmap: ['title', 'months'],\n 'realtime-canvas': ['title', 'description', 'roomId'],\n}\n\nexport function pinTypeToMethodSuffix(pinType: PinTypeId): string {\n return pinType\n .split('-')\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join('')\n}\n\nfunction pickPinConfig<T extends PinTypeId>(\n pinType: T,\n input: Record<string, unknown>,\n): PinConfigByType[T] {\n const fields = PIN_CONFIG_FIELDS[pinType]\n const pin_config = {} as PinConfigByType[T]\n for (const key of fields) {\n if (key in input && input[key] !== undefined) {\n ;(pin_config as Record<string, unknown>)[key] = input[key]\n }\n }\n return pin_config\n}\n\nexport function toCreatePinRequest<T extends PinTypeId>(\n pinType: T,\n input: CreatePinHelperInput<T>,\n): CreateTypedPinRequest<T> {\n const raw = input as Record<string, unknown>\n const pin_config = pickPinConfig(pinType, raw)\n\n const metadata: PinMetadataBase = {\n title: input.title,\n tags: input.tags,\n description: input.description,\n allow_edit: input.allow_edit,\n require_sign_in: input.require_sign_in,\n allow_comments: input.allow_comments,\n }\n\n return {\n pin_type: pinType,\n pin_config,\n pin_layout: input.pin_layout,\n is_public: input.is_public,\n allow_edit: input.allow_edit,\n require_sign_in: input.require_sign_in,\n allow_comments: input.allow_comments,\n pending_invites: input.pending_invites,\n metadata,\n }\n}\n\nexport function toUpdatePinRequest<T extends PinTypeId>(\n pinType: T,\n input: UpdatePinHelperInput<T>,\n): UpdatePinRequest<T> {\n const raw = input as Record<string, unknown>\n const pin_config = pickPinConfig(pinType, raw) as PinConfigByType[T]\n const hasPinConfig = Object.keys(pin_config as object).length > 0\n\n const metadata: Partial<PinMetadataBase> = {\n ...(input.metadata ?? {}),\n }\n if (input.title !== undefined) metadata.title = input.title\n if (input.tags !== undefined) metadata.tags = input.tags\n if (input.description !== undefined) metadata.description = input.description\n\n const hasMetadata = Object.keys(metadata).length > 0\n\n return {\n pin_type: pinType,\n ...(hasPinConfig ? { pin_config } : {}),\n pin_layout: input.pin_layout,\n is_public: input.is_public,\n ...(hasMetadata ? { metadata } : {}),\n }\n}\n\nexport function attachNamedPinHelpers(ctor: { prototype: Record<string, unknown> }) {\n for (const pinType of PRODUCT_PIN_TYPES as readonly PinTypeId[]) {\n const suffix = pinTypeToMethodSuffix(pinType)\n ctor.prototype[`create${suffix}`] = function (\n this: { createPin: (t: PinTypeId, i: unknown) => unknown },\n input: unknown,\n ) {\n return this.createPin(pinType, input)\n }\n ctor.prototype[`update${suffix}`] = function (\n this: { updatePin: (id: string, t: PinTypeId, i: unknown) => unknown },\n pinId: string,\n input: unknown,\n ) {\n return this.updatePin(pinId, pinType, input)\n }\n }\n}\n","/**\n * Runtime hints + minimal examples per pin type.\n * Use when building API payloads without opening the docs every time.\n */\n\nimport type { PinConfigByType, PinTypeId, UpdatePinRequest } from './types/pins'\n\nexport interface PinConfigFieldHint {\n path: string\n type: string\n required: boolean\n description: string\n}\n\nexport interface PinConfigHint<T extends PinTypeId = PinTypeId> {\n pin_type: T\n summary: string\n required_fields: string[]\n optional_fields: string[]\n fields: PinConfigFieldHint[]\n /** Minimal valid pin_config for create/update */\n example_config: PinConfigByType[T]\n /** Typical PUT /v1/pins/:id body (root-level pin_config) */\n example_update: UpdatePinRequest<T>\n}\n\nconst TABLE_HINT: PinConfigHint<'table'> = {\n pin_type: 'table',\n summary: 'Spreadsheet-style pin. columns is required; rows are optional but needed for visible data.',\n required_fields: ['columns'],\n optional_fields: ['rows'],\n fields: [\n {\n path: 'columns',\n type: 'TableColumn[]',\n required: true,\n description: 'At least one column. Each column needs id + name (type optional, e.g. text | number).',\n },\n {\n path: 'columns[].id',\n type: 'string',\n required: true,\n description: 'Stable column key used in row.cells.',\n },\n {\n path: 'columns[].name',\n type: 'string',\n required: true,\n description: 'Column header label.',\n },\n {\n path: 'rows',\n type: 'TableRow[]',\n required: false,\n description: 'Table data. Each row: { id, cells: { [columnId]: value } }.',\n },\n ],\n example_config: {\n columns: [\n { id: 'col1', name: 'Name', type: 'text' },\n { id: 'col2', name: 'Value', type: 'number' },\n ],\n rows: [{ id: 'row1', cells: { col1: 'Item', col2: 1 } }],\n },\n example_update: {\n pin_config: {\n columns: [\n { id: 'col1', name: 'Name', type: 'text' },\n { id: 'col2', name: 'Value', type: 'number' },\n ],\n rows: [{ id: 'row1', cells: { col1: 'Updated', col2: 42 } }],\n },\n },\n}\n\n/** Per-type hints (expand over time; table is fully documented). */\nexport const PIN_CONFIG_HINTS: Partial<Record<PinTypeId, PinConfigHint>> = {\n table: TABLE_HINT,\n markdown: {\n pin_type: 'markdown',\n summary: 'Rich text / markdown body.',\n required_fields: [],\n optional_fields: ['content', 'collaboration'],\n fields: [\n {\n path: 'content',\n type: 'string',\n required: false,\n description: 'Markdown source. Server seeds Yjs when set on create.',\n },\n ],\n example_config: { content: '# Hello\\n\\nBody text.' },\n example_update: { pin_config: { content: '# Updated\\n\\nNew body.' } },\n },\n 'stat-cards': {\n pin_type: 'stat-cards',\n summary: 'KPI cards grid.',\n required_fields: ['cards'],\n optional_fields: [],\n fields: [\n {\n path: 'cards',\n type: 'StatCardItem[]',\n required: true,\n description: 'Each card: title, value; optional change, trend (up|down|neutral).',\n },\n ],\n example_config: {\n cards: [{ title: 'Revenue', value: '1000', change: '+5%', trend: 'up' }],\n },\n example_update: {\n pin_config: {\n cards: [{ title: 'Revenue', value: '1234', change: '+8%', trend: 'up' }],\n },\n },\n },\n}\n\nexport function getPinConfigHint<T extends PinTypeId>(pinType: T): PinConfigHint<T> | undefined {\n return PIN_CONFIG_HINTS[pinType] as PinConfigHint<T> | undefined\n}\n\n/** Pretty-print field hints for CLI / logging. */\nexport function formatPinConfigHint(pinType: PinTypeId): string {\n const hint = getPinConfigHint(pinType)\n if (!hint) {\n return [\n `No built-in hint for pin type \"${pinType}\".`,\n 'Use CreatePinRequest<typeof pinType> / PinConfigByType[typeof pinType] in TypeScript,',\n 'or client.pins.create({ pin_type, pin_config, metadata }) with typed pin_config.',\n ].join('\\n')\n }\n\n const lines = [\n `Pin type: ${hint.pin_type}`,\n hint.summary,\n '',\n 'Required pin_config fields:',\n ...hint.required_fields.map((f) => ` - ${f}`),\n '',\n 'Optional pin_config fields:',\n ...(hint.optional_fields.length ? hint.optional_fields.map((f) => ` - ${f}`) : [' (none documented)']),\n '',\n 'Field reference:',\n ...hint.fields.map(\n (f) => ` ${f.path} (${f.type}${f.required ? ', required' : ''}): ${f.description}`,\n ),\n '',\n 'Example update payload:',\n JSON.stringify(hint.example_update, null, 2),\n ]\n return lines.join('\\n')\n}\n","import { z } from 'zod'\n\n/** Unwrap optional/nullable/default/effects wrappers. */\nfunction unwrapSchema(schema: z.ZodTypeAny): z.ZodTypeAny {\n let current = schema\n for (;;) {\n if (current instanceof z.ZodOptional || current instanceof z.ZodNullable) {\n current = current.unwrap()\n continue\n }\n if (current instanceof z.ZodDefault) {\n current = current.removeDefault()\n continue\n }\n if (current instanceof z.ZodEffects) {\n current = current.innerType()\n continue\n }\n break\n }\n return current\n}\n\nconst llmEntryValue = (): z.ZodTypeAny =>\n z.union([z.string(), z.number(), z.boolean(), z.null()])\n\n/**\n * Convert API zod schemas → LLM-friendly schemas.\n * `z.record()` becomes `[{ key, value }]` because structured-output APIs struggle with open records.\n */\nexport function toLlmPinConfigSchema(schema: z.ZodTypeAny): z.ZodTypeAny {\n const base = unwrapSchema(schema)\n\n if (base instanceof z.ZodRecord) {\n return z.array(\n z.object({\n key: z.string(),\n value: llmEntryValue(),\n }),\n )\n }\n\n if (base instanceof z.ZodArray) {\n return z.array(toLlmPinConfigSchema(base.element))\n }\n\n if (base instanceof z.ZodObject) {\n const shape: Record<string, z.ZodTypeAny> = {}\n for (const [key, value] of Object.entries(base.shape)) {\n shape[key] = toLlmPinConfigSchema(value as z.ZodTypeAny)\n }\n if (base._def.unknownKeys === 'passthrough') {\n return z.object(shape).passthrough()\n }\n return z.object(shape)\n }\n\n return schema\n}\n\nfunction entriesArrayToRecord(data: unknown): Record<string, unknown> {\n const record: Record<string, unknown> = {}\n if (!Array.isArray(data)) return record\n for (const item of data) {\n if (!item || typeof item !== 'object') continue\n const entry = item as { key?: string; columnId?: string; value?: unknown }\n const key = entry.key ?? entry.columnId\n if (key == null) continue\n const value = entry.value\n record[key] =\n Array.isArray(value) && looksLikeEntryArray(value)\n ? entriesArrayToRecord(value)\n : value\n }\n return record\n}\n\nfunction looksLikeEntryArray(value: unknown[]): boolean {\n return value.every(\n (item) =>\n item &&\n typeof item === 'object' &&\n ('key' in item || 'columnId' in item),\n )\n}\n\nfunction normalizeRecordValue(value: unknown): unknown {\n if (Array.isArray(value) && looksLikeEntryArray(value)) {\n return entriesArrayToRecord(value)\n }\n if (value && typeof value === 'object' && !Array.isArray(value)) {\n const obj = value as Record<string, unknown>\n const out: Record<string, unknown> = {}\n for (const [k, v] of Object.entries(obj)) {\n out[k] = normalizeRecordValue(v)\n }\n return out\n }\n return value\n}\n\n/**\n * Convert LLM output back to API pin_config shape using the same API zod schema as guide.\n */\nexport function normalizeLlmPinConfigOutput(data: unknown, apiSchema: z.ZodTypeAny): unknown {\n if (data == null) return data\n\n const base = unwrapSchema(apiSchema)\n\n if (base instanceof z.ZodRecord) {\n if (Array.isArray(data)) return entriesArrayToRecord(data)\n return normalizeRecordValue(data)\n }\n\n if (base instanceof z.ZodArray) {\n if (!Array.isArray(data)) return data\n return data.map((item) => normalizeLlmPinConfigOutput(item, base.element))\n }\n\n if (base instanceof z.ZodObject) {\n if (!data || typeof data !== 'object' || Array.isArray(data)) return data\n const input = data as Record<string, unknown>\n const output: Record<string, unknown> = { ...input }\n for (const [key, fieldSchema] of Object.entries(base.shape)) {\n if (key in output) {\n output[key] = normalizeLlmPinConfigOutput(output[key], fieldSchema as z.ZodTypeAny)\n }\n }\n return output\n }\n\n return data\n}\n","export const PIN_TYPE_ITEM_LIMITS = {\n TABLE_MAX_ROWS: 100,\n KEY_VALUE_MAX_ITEMS: 48,\n CARDS_MAX_ITEMS: 24,\n TRACE_MAX_SPANS: 50,\n OKR_MAX_KEY_RESULTS: 50,\n GALLERY_MAX_IMAGES: 32,\n} as const\n","import { z } from \"zod\";\nimport { PIN_TYPE_ITEM_LIMITS } from \"./pin-config-limits\";\n\n/** Lightweight zod validators for `metadata.pin_config` — aligned with product + agents-content shapes. */\n\nconst looseObject = z.object({}).passthrough();\n\nexport const markdownPinConfigSchema = z\n .object({\n content: z.string().optional(),\n collaboration: z.object({ enabled: z.boolean().optional() }).optional(),\n })\n .passthrough();\n\nexport const statCardsPinConfigSchema = z\n .object({\n cards: z\n .array(\n z\n .object({\n title: z.string(),\n value: z.union([z.string(), z.number()]),\n })\n .passthrough(),\n )\n .min(1, \"stat-cards pin_config.cards must contain at least one card\"),\n })\n .passthrough();\n\nexport const imagePinConfigSchema = z\n .object({\n url: z.string().optional(),\n altText: z.string().optional(),\n fit: z.string().optional(),\n })\n .passthrough();\n\nexport const videoPinConfigSchema = z\n .object({\n url: z.string().min(1).optional(),\n fileId: z.string().optional(),\n fileName: z.string().optional(),\n mimeType: z.literal('video/mp4').optional(),\n caption: z.string().optional(),\n size: z.number().positive().optional(),\n })\n .passthrough();\n\nconst audioPinTrackSchema = z\n .object({\n url: z.string().min(1),\n fileId: z.string().optional(),\n fileName: z.string().optional(),\n mimeType: z.enum(['audio/mpeg', 'audio/wav', 'audio/x-wav']).optional(),\n size: z.number().positive().optional(),\n })\n .passthrough();\n\nexport const audioPinConfigSchema = z\n .object({\n url: z.string().min(1).optional(),\n fileId: z.string().optional(),\n fileName: z.string().optional(),\n mimeType: z.enum(['audio/mpeg', 'audio/wav', 'audio/x-wav']).optional(),\n caption: z.string().optional(),\n size: z.number().positive().optional(),\n tracks: z.array(audioPinTrackSchema).max(10).optional(),\n })\n .passthrough()\n .refine(\n (value) =>\n Boolean(String(value.url ?? '').trim()) ||\n (Array.isArray(value.tracks) && value.tracks.length > 0),\n { message: 'Audio pin requires url or at least one track' },\n );\n\nexport const tablePinConfigSchema = z\n .object({\n columns: z\n .array(\n z\n .object({\n id: z.string(),\n name: z.string(),\n type: z.string().optional(),\n })\n .passthrough(),\n )\n .min(1),\n rows: z\n .array(\n z\n .object({\n id: z.string(),\n cells: z\n .record(z.string(), z.union([z.string(), z.number(), z.boolean(), z.null()]))\n .refine((cells) => Object.keys(cells).length > 0, {\n message: 'each table row must include at least one cell value',\n }),\n })\n .passthrough(),\n )\n .min(1)\n .max(PIN_TYPE_ITEM_LIMITS.TABLE_MAX_ROWS)\n .optional(),\n })\n .passthrough();\n\nexport const chartsPinConfigSchema = z\n .object({\n chartType: z.string().optional(),\n data: z.array(z.record(z.string(), z.unknown())).optional(),\n })\n .passthrough();\n\nexport const embedPinConfigSchema = z\n .object({\n url: z.string().optional(),\n type: z.string().optional(),\n })\n .passthrough();\n\nexport const pdfViewerPinConfigSchema = z\n .object({\n pdf: z.object({ url: z.string().min(1) }).passthrough(),\n })\n .passthrough();\n\nexport const excelViewerPinConfigSchema = z\n .object({\n excel: z.object({ url: z.string().min(1) }).passthrough(),\n })\n .passthrough();\n\nexport const timelinePinConfigSchema = z\n .object({\n items: z.array(z.record(z.string(), z.unknown())).optional(),\n mode: z.string().optional(),\n })\n .passthrough();\n\nexport const jsonViewerPinConfigSchema = z\n .object({\n json: z.unknown().optional(),\n jsonString: z.string().optional(),\n title: z.string().optional(),\n })\n .passthrough();\n\nexport const jsonListPinConfigSchema = z\n .object({\n json: z.array(z.unknown()).optional(),\n jsonString: z.string().optional(),\n })\n .passthrough();\n\nexport const linksPinConfigSchema = z\n .object({\n links: z.array(z.record(z.string(), z.unknown())).optional(),\n })\n .passthrough();\n\nexport const stepsPinConfigSchema = z\n .object({\n steps: z.array(z.object({ title: z.string() }).passthrough()).min(1),\n })\n .passthrough();\n\nexport const tracePinConfigSchema = z\n .object({\n spans: z\n .array(\n z\n .object({\n name: z.string(),\n status: z.enum(['completed', 'running', 'pending', 'failed']),\n })\n .passthrough(),\n )\n .min(1, 'trace pin_config.spans must contain at least one span')\n .max(PIN_TYPE_ITEM_LIMITS.TRACE_MAX_SPANS),\n })\n .passthrough();\n\nconst planContentBlockSchema = z\n .object({\n type: z.enum(['details', 'command', 'code', 'text', 'link', 'mermaid', 'summary']),\n })\n .passthrough();\n\nconst planTaskSchema = z\n .object({\n title: z.string(),\n blocks: z.array(planContentBlockSchema).optional(),\n })\n .passthrough();\n\nexport const planPinConfigSchema = z\n .object({\n phases: z\n .array(\n z\n .object({\n title: z.string(),\n tasks: z.array(planTaskSchema).min(1),\n })\n .passthrough(),\n )\n .min(1, 'plan pin_config.phases must contain at least one phase'),\n })\n .passthrough();\n\nexport const notesPinConfigSchema = z\n .object({\n notes: z\n .array(\n z\n .object({\n title: z.string(),\n })\n .passthrough(),\n )\n .optional(),\n })\n .passthrough();\n\nexport const csvViewerPinConfigSchema = z\n .object({\n csvData: z.array(z.record(z.string(), z.unknown())).optional(),\n csvText: z.string().optional(),\n fileName: z.string().optional(),\n })\n .passthrough();\n\nexport const galleryPinConfigSchema = z\n .object({\n images: z\n .array(z.record(z.string(), z.unknown()))\n .max(PIN_TYPE_ITEM_LIMITS.GALLERY_MAX_IMAGES)\n .optional(),\n })\n .passthrough();\n\nexport const mermaidPinConfigSchema = z\n .object({\n code: z.string().optional(),\n diagram: z.string().optional(),\n title: z.string().optional(),\n })\n .passthrough()\n .refine((v) => Boolean(v.code?.trim() || v.diagram?.trim()), {\n message: \"mermaid pin_config requires code or diagram\",\n });\n\nexport const codePinConfigSchema = z\n .object({\n code: z.string().min(1),\n language: z.string().optional(),\n filename: z.string().optional(),\n title: z.string().optional(),\n })\n .passthrough();\n\nexport const userStoryPinConfigSchema = z\n .object({\n userStory: z.string().min(1),\n })\n .passthrough();\n\nexport const chatPinConfigSchema = z\n .object({\n title: z.string().optional(),\n placeholder: z.string().optional(),\n linked_pin_id: z.string().optional(),\n linked_pin_title: z.string().optional(),\n })\n .passthrough();\n\nexport const introPinConfigSchema = z\n .object({\n heading: z.string().min(1),\n })\n .passthrough();\n\nexport const textMediaPinConfigSchema = z\n .object({\n title: z.string().optional(),\n text: z.string().optional(),\n })\n .passthrough();\n\nexport const businessCardPinConfigSchema = z\n .object({\n sectionTitle: z.string().optional(),\n fields: z\n .array(\n z\n .object({\n id: z.string(),\n key: z.string(),\n value: z.string(),\n })\n .passthrough(),\n )\n .min(1),\n imagePosition: z.enum([\"left\", \"right\"]).optional(),\n })\n .passthrough();\n\nexport const qrCodePinConfigSchema = z\n .object({\n url: z.string().optional(),\n label: z.string().optional(),\n })\n .passthrough();\n\nexport const socialHandlesPinConfigSchema = z\n .object({\n title: z.string().optional(),\n showLabels: z.boolean().optional(),\n iconSize: z.number().optional(),\n handles: z\n .array(\n z\n .object({\n platform: z.string(),\n url: z.string(),\n label: z.string().optional(),\n })\n .passthrough(),\n )\n .optional(),\n })\n .passthrough();\n\nexport const fileUploadPinConfigSchema = z\n .object({\n files: z.array(z.record(z.string(), z.unknown())).optional(),\n displayMode: z.string().optional(),\n })\n .passthrough();\n\nexport const kanbanBoardPinConfigSchema = z\n .object({\n columns: z.array(z.object({ id: z.string(), title: z.string() }).passthrough()).min(1),\n })\n .passthrough();\n\nexport const checklistItemSchema = z\n .object({\n id: z.string(),\n name: z.string(),\n description: z.string().optional(),\n checked: z.boolean().optional(),\n })\n .passthrough();\n\nexport const checklistSectionSchema = z\n .object({\n id: z.string(),\n title: z.string(),\n label: z.string().optional(),\n items: z.array(checklistItemSchema).min(1),\n })\n .passthrough();\n\nexport const checklistPinConfigSchema = z\n .object({\n mode: z.enum([\"flat\", \"sections\"]).optional(),\n title: z.string().optional(),\n footer: z.string().optional(),\n items: z.array(checklistItemSchema).optional(),\n sections: z.array(checklistSectionSchema).optional(),\n })\n .passthrough()\n .superRefine((data, ctx) => {\n const mode = data.mode === \"sections\" ? \"sections\" : \"flat\";\n if (mode === \"sections\") {\n if (!Array.isArray(data.sections) || data.sections.length === 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: \"checklist sections mode requires at least one section\",\n });\n }\n return;\n }\n if (!Array.isArray(data.items) || data.items.length === 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: \"checklist flat mode requires at least one item\",\n });\n }\n });\n\nexport const cardsImageSchema = z\n .object({\n url: z.string(),\n alt: z.string().optional(),\n link: z.string().optional(),\n fileId: z.string().optional(),\n })\n .passthrough();\n\nexport const cardsItemSchema = z\n .object({\n id: z.string(),\n image: cardsImageSchema,\n title: z.string(),\n subtext: z.string().optional(),\n })\n .passthrough();\n\nexport const cardsPinConfigSchema = z\n .object({\n title: z.string().optional(),\n layout: z.enum([\"horizontal\", \"vertical\", \"gallery\"]).optional(),\n columns: z.union([z.literal(2), z.literal(3), z.literal(4)]).optional(),\n items: z\n .array(cardsItemSchema)\n .min(1)\n .max(PIN_TYPE_ITEM_LIMITS.CARDS_MAX_ITEMS),\n })\n .passthrough();\n\nexport const keyValueItemSchema = z\n .object({\n id: z.string(),\n key: z.string(),\n value: z.union([z.string(), z.number()]),\n unit: z.string().optional(),\n hint: z.string().optional(),\n })\n .passthrough();\n\nexport const keyValuePinConfigSchema = z\n .object({\n title: z.string().optional(),\n subtitle: z.string().optional(),\n period: z.string().optional(),\n layout: z.enum([\"list\", \"grid\"]).optional(),\n columns: z.union([z.literal(2), z.literal(3), z.literal(4)]).optional(),\n items: z\n .array(keyValueItemSchema)\n .min(1)\n .max(PIN_TYPE_ITEM_LIMITS.KEY_VALUE_MAX_ITEMS),\n })\n .passthrough();\n\nexport const faqItemSchema = z\n .object({\n id: z.string(),\n question: z.string(),\n answer: z.string(),\n })\n .passthrough();\n\nexport const faqPinConfigSchema = z\n .object({\n title: z.string().optional(),\n items: z.array(faqItemSchema).min(1),\n })\n .passthrough();\n\nexport const ctaButtonSchema = z\n .object({\n id: z.string(),\n label: z.string(),\n url: z.string(),\n variant: z.enum([\"primary\", \"secondary\", \"outline\"]).optional(),\n })\n .passthrough();\n\nexport const ctaPinConfigSchema = z\n .object({\n headline: z.string().optional(),\n subline: z.string().optional(),\n buttons: z.array(ctaButtonSchema).min(1).max(2),\n })\n .passthrough();\n\nexport const comparisonPinConfigSchema = z\n .object({\n title: z.string().optional(),\n left: z.object({ label: z.string(), body: z.string() }).passthrough(),\n right: z.object({ label: z.string(), body: z.string() }).passthrough(),\n highlightedLines: z\n .object({\n left: z.array(z.number().int().nonnegative()).optional(),\n right: z.array(z.number().int().nonnegative()).optional(),\n })\n .optional(),\n matches: z\n .array(\n z.object({\n left: z.number().int().nonnegative(),\n right: z.number().int().nonnegative(),\n }),\n )\n .optional(),\n showVsBadge: z.boolean().optional(),\n })\n .passthrough();\n\nexport const calendarPinConfigSchema = z\n .object({\n events: z.array(z.record(z.string(), z.unknown())).optional(),\n weekStartsOn: z.number().optional(),\n })\n .passthrough();\n\nexport const roadmapPinConfigSchema = z\n .object({\n months: z.array(z.record(z.string(), z.unknown())).optional(),\n title: z.string().optional(),\n })\n .passthrough();\n\nexport const processFlowPinConfigSchema = z\n .object({\n title: z.string().optional(),\n defaultView: z.enum([\"onboarding\", \"bottlenecks\"]).optional(),\n showTeam: z.boolean().optional(),\n team: z\n .array(\n z\n .object({\n id: z.string(),\n name: z.string(),\n role: z.string(),\n avatarUrl: z.string().optional(),\n status: z.enum([\"live\", \"away\", \"offline\"]).optional(),\n })\n .passthrough(),\n )\n .optional(),\n swimlanes: z\n .array(z.object({ id: z.string(), title: z.string() }).passthrough())\n .min(1),\n nodes: z\n .array(\n z\n .object({\n id: z.string(),\n swimlane: z.string(),\n label: z.string(),\n })\n .passthrough(),\n )\n .min(1),\n edges: z.array(z.object({ source: z.string(), target: z.string() }).passthrough()).optional(),\n })\n .passthrough();\n\nexport const funnelPinConfigSchema = z\n .object({\n title: z.string().optional(),\n subtitle: z.string().optional(),\n valueFormat: z.enum([\"number\", \"percent\", \"currency\"]).optional(),\n currency: z.string().optional(),\n highlightBiggestDrop: z.boolean().optional(),\n stages: z\n .array(\n z\n .object({\n id: z.string(),\n label: z.string(),\n value: z.number(),\n })\n .passthrough(),\n )\n .min(1),\n })\n .passthrough();\n\nexport const decisionMatrixPinConfigSchema = z\n .object({\n title: z.string().optional(),\n subtitle: z.string().optional(),\n maxScore: z.number().optional(),\n options: z\n .array(z.object({ id: z.string(), label: z.string() }).passthrough())\n .min(2),\n criteria: z\n .array(\n z\n .object({\n id: z.string(),\n label: z.string(),\n scores: z.record(z.string(), z.number()),\n })\n .passthrough(),\n )\n .min(1),\n })\n .passthrough();\n\nexport const okrPinConfigSchema = z\n .object({\n title: z.string().optional(),\n subtitle: z.string().optional(),\n period: z.string().optional(),\n objectives: z\n .array(\n z\n .object({\n id: z.string(),\n title: z.string(),\n keyResults: z.array(z.record(z.string(), z.unknown())).min(1),\n })\n .passthrough(),\n )\n .min(1),\n })\n .passthrough()\n .refine(\n (config) => {\n const objectives = Array.isArray(config.objectives) ? config.objectives : [];\n const keyResultCount = objectives.reduce(\n (sum, objective) =>\n sum + (Array.isArray(objective.keyResults) ? objective.keyResults.length : 0),\n 0,\n );\n return keyResultCount <= PIN_TYPE_ITEM_LIMITS.OKR_MAX_KEY_RESULTS;\n },\n {\n message: `okr pin_config supports at most ${PIN_TYPE_ITEM_LIMITS.OKR_MAX_KEY_RESULTS} key results total`,\n },\n );\n\nexport const pollPinConfigSchema = z\n .object({\n question: z.string().min(1),\n options: z\n .array(z.object({ id: z.string(), label: z.string() }).passthrough())\n .min(2),\n status: z.enum([\"open\", \"closed\"]).optional(),\n showVoteCount: z.boolean().optional(),\n allowChangeVote: z.boolean().optional(),\n })\n .passthrough();\n\nexport const ratingPinConfigSchema = z\n .object({\n title: z.string().optional(),\n description: z.string().optional(),\n prompt: z.string().optional(),\n items: z\n .array(\n z\n .object({\n id: z.string(),\n label: z.string(),\n description: z.string().optional(),\n required: z.boolean().optional(),\n })\n .passthrough(),\n )\n .optional(),\n status: z.enum([\"open\", \"closed\"]).optional(),\n maxStars: z.number().min(3).max(5).optional(),\n allowHalfStars: z.boolean().optional(),\n allowChangeRating: z.boolean().optional(),\n showAverage: z.boolean().optional(),\n })\n .passthrough();\n\nexport const surveyPinConfigSchema = z\n .object({\n title: z.string().optional(),\n description: z.string().optional(),\n status: z.enum([\"open\", \"closed\"]).optional(),\n allowEditResponse: z.boolean().optional(),\n questions: z\n .array(\n z\n .object({\n id: z.string(),\n label: z.string(),\n type: z.enum([\n \"short-text\",\n \"long-text\",\n \"single-choice\",\n \"multiple-choice\",\n \"scale\",\n ]),\n required: z.boolean().optional(),\n options: z\n .array(z.object({ id: z.string(), label: z.string() }).passthrough())\n .optional(),\n scaleMin: z.number().optional(),\n scaleMax: z.number().optional(),\n })\n .passthrough(),\n )\n .min(1),\n })\n .passthrough();\n\nexport const realtimeCanvasPinConfigSchema = z\n .object({\n title: z.string().optional(),\n description: z.string().optional(),\n roomId: z.string().optional(),\n })\n .passthrough();\n\nexport const mastraPinConfigSchema = looseObject;\n","import { z } from 'zod'\nimport type { PinTypeId } from '../types/pins'\nimport { toLlmPinConfigSchema } from './llm-schema-transform'\nimport {\n audioPinConfigSchema,\n businessCardPinConfigSchema,\n calendarPinConfigSchema,\n chartsPinConfigSchema,\n chatPinConfigSchema,\n checklistPinConfigSchema,\n codePinConfigSchema,\n comparisonPinConfigSchema,\n csvViewerPinConfigSchema,\n embedPinConfigSchema,\n excelViewerPinConfigSchema,\n fileUploadPinConfigSchema,\n galleryPinConfigSchema,\n imagePinConfigSchema,\n introPinConfigSchema,\n jsonListPinConfigSchema,\n jsonViewerPinConfigSchema,\n kanbanBoardPinConfigSchema,\n linksPinConfigSchema,\n markdownPinConfigSchema,\n mastraPinConfigSchema,\n mermaidPinConfigSchema,\n notesPinConfigSchema,\n pdfViewerPinConfigSchema,\n planPinConfigSchema,\n qrCodePinConfigSchema,\n realtimeCanvasPinConfigSchema,\n roadmapPinConfigSchema,\n socialHandlesPinConfigSchema,\n statCardsPinConfigSchema,\n stepsPinConfigSchema,\n tablePinConfigSchema,\n textMediaPinConfigSchema,\n timelinePinConfigSchema,\n tracePinConfigSchema,\n userStoryPinConfigSchema,\n videoPinConfigSchema,\n} from './pin-config-schemas'\n\n/** Zod validators for product pin types — aligned with backend PIN_CONFIG_SCHEMAS. */\nexport const PIN_CONFIG_ZOD_SCHEMAS: Record<PinTypeId, z.ZodTypeAny> = {\n markdown: markdownPinConfigSchema,\n image: imagePinConfigSchema,\n gallery: galleryPinConfigSchema,\n table: tablePinConfigSchema,\n charts: chartsPinConfigSchema,\n mermaid: mermaidPinConfigSchema,\n code: codePinConfigSchema,\n embed: embedPinConfigSchema,\n 'pdf-viewer': pdfViewerPinConfigSchema,\n 'excel-viewer': excelViewerPinConfigSchema,\n 'stat-cards': statCardsPinConfigSchema,\n timeline: timelinePinConfigSchema,\n 'json-viewer': jsonViewerPinConfigSchema,\n 'json-list': jsonListPinConfigSchema,\n links: linksPinConfigSchema,\n 'qr-code': qrCodePinConfigSchema,\n 'social-handles': socialHandlesPinConfigSchema,\n steps: stepsPinConfigSchema,\n trace: tracePinConfigSchema,\n plan: planPinConfigSchema,\n notes: notesPinConfigSchema,\n 'csv-viewer': csvViewerPinConfigSchema,\n 'user-story': userStoryPinConfigSchema,\n chat: chatPinConfigSchema,\n intro: introPinConfigSchema,\n mastra: mastraPinConfigSchema,\n 'text-media': textMediaPinConfigSchema,\n 'business-card': businessCardPinConfigSchema,\n video: videoPinConfigSchema,\n audio: audioPinConfigSchema,\n 'file-upload': fileUploadPinConfigSchema,\n 'kanban-board': kanbanBoardPinConfigSchema,\n checklist: checklistPinConfigSchema,\n comparison: comparisonPinConfigSchema,\n calendar: calendarPinConfigSchema,\n roadmap: roadmapPinConfigSchema,\n 'realtime-canvas': realtimeCanvasPinConfigSchema,\n}\n\nexport function getPinConfigZodSchema(pinType: PinTypeId): z.ZodTypeAny {\n return PIN_CONFIG_ZOD_SCHEMAS[pinType]\n}\n\n/** LLM structured-output schema (records → entry arrays). Validated output is normalized back via API schema. */\nexport function getLlmPinConfigZodSchema(pinType: PinTypeId): z.ZodTypeAny {\n return toLlmPinConfigSchema(getPinConfigZodSchema(pinType))\n}\n","import type { PinTypeId } from '../types/pins'\n\ntype Canonicalizer = (config: unknown) => unknown\n\n/** UI/API canonical shapes after generic LLM normalize (one entry per pin type that needs it). */\nconst PIN_CONFIG_CANONICAL_NORMALIZERS: Partial<Record<PinTypeId, Canonicalizer>> = {\n table: canonicalizeTablePinConfig,\n}\n\nexport function canonicalizePinConfigForApi(pinType: PinTypeId, config: unknown): unknown {\n const normalizer = PIN_CONFIG_CANONICAL_NORMALIZERS[pinType]\n return normalizer ? normalizer(config) : config\n}\n\nfunction canonicalizeTablePinConfig(config: unknown): unknown {\n if (!config || typeof config !== 'object') return config\n const table = config as {\n columns?: Array<{ id?: string; name?: string }>\n rows?: unknown[]\n }\n if (!Array.isArray(table.rows)) return config\n\n const columnIds = new Set(\n (table.columns ?? [])\n .map((col) => col?.id)\n .filter((id): id is string => Boolean(id)),\n )\n\n const rows = table.rows.map((row, index) => {\n if (!row || typeof row !== 'object' || Array.isArray(row)) return row\n const record = row as Record<string, unknown>\n const id = String(record.id ?? `row-${index + 1}`)\n\n if (record.cells && typeof record.cells === 'object' && !Array.isArray(record.cells)) {\n return { ...record, id, cells: record.cells as Record<string, unknown> }\n }\n\n const cells: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(record)) {\n if (key === 'id') continue\n if (columnIds.size === 0 || columnIds.has(key)) {\n cells[key] = value\n }\n }\n\n return { id, cells }\n })\n\n return { ...table, rows }\n}\n","import type { LanguageModel } from 'ai'\n\nexport type AiProvider = 'google' | 'anthropic' | 'openai'\n\nexport interface LlmConfig {\n provider: AiProvider\n /** Model id, e.g. gemini-2.0-flash, claude-sonnet-4-20250514, gpt-4o */\n model: string\n /** Falls back to GOOGLE_GENERATIVE_AI_API_KEY / ANTHROPIC_API_KEY / OPENAI_API_KEY */\n apiKey?: string\n}\n\nconst PROVIDER_PACKAGES: Record<AiProvider, string> = {\n google: '@ai-sdk/google',\n anthropic: '@ai-sdk/anthropic',\n openai: '@ai-sdk/openai',\n}\n\nconst DEFAULT_ENV_KEYS: Record<AiProvider, string> = {\n google: 'GOOGLE_GENERATIVE_AI_API_KEY',\n anthropic: 'ANTHROPIC_API_KEY',\n openai: 'OPENAI_API_KEY',\n}\n\nasync function loadProviderFactory(provider: AiProvider): Promise<(opts?: { apiKey?: string }) => (model: string) => LanguageModel> {\n const pkg = PROVIDER_PACKAGES[provider]\n try {\n const mod = await import(pkg)\n if (provider === 'google') {\n return (opts) => mod.createGoogleGenerativeAI(opts)\n }\n if (provider === 'anthropic') {\n return (opts) => mod.createAnthropic(opts)\n }\n return (opts) => mod.createOpenAI(opts)\n } catch {\n throw new Error(\n `Missing optional dependency \"${pkg}\". Install it to use provider \"${provider}\" (npm install ${pkg} ai zod).`,\n )\n }\n}\n\n/** Prefer a valid-length key when both env vars are set (truncated keys are common in .env). */\nexport function resolveGoogleApiKey(): string | undefined {\n const candidates = [process.env.GOOGLE_GENERATIVE_AI_API_KEY, process.env.GOOGLE_API_KEY]\n .map((k) => k?.trim())\n .filter((k): k is string => Boolean(k))\n if (!candidates.length) return undefined\n const validAiza = candidates.find((k) => k.startsWith('AIzaSy') && k.length === 39)\n if (validAiza) return validAiza\n return candidates.sort((a, b) => b.length - a.length)[0]\n}\n\nexport async function resolveLanguageModel(config: LlmConfig): Promise<LanguageModel> {\n const apiKey =\n config.apiKey ??\n (config.provider === 'google'\n ? resolveGoogleApiKey()\n : process.env[DEFAULT_ENV_KEYS[config.provider]])\n if (!apiKey) {\n const googleHint =\n 'GOOGLE_GENERATIVE_AI_API_KEY or GOOGLE_API_KEY'\n throw new Error(\n `No API key for provider \"${config.provider}\". Pass llm.apiKey or set ${\n config.provider === 'google' ? googleHint : DEFAULT_ENV_KEYS[config.provider]\n }.`,\n )\n }\n const factory = await loadProviderFactory(config.provider)\n return factory({ apiKey })(config.model)\n}\n","import { generateObject } from 'ai'\nimport type { z } from 'zod'\nimport { formatPinConfigHint } from '../pin-config-hints'\nimport { PIN_CONFIG_FIELDS } from '../client/pins/pin-helper-core'\nimport type { PinConfigByType, PinTypeId } from '../types/pins'\nimport { getLlmPinConfigZodSchema, getPinConfigZodSchema } from './pin-config-zod-map'\nimport { canonicalizePinConfigForApi } from './pin-config-canonical'\nimport { normalizeLlmPinConfigOutput } from './llm-schema-transform'\nimport { resolveLanguageModel, type LlmConfig } from './providers'\n\nexport type PipeInput = string | Record<string, unknown> | unknown[] | unknown\n\nexport interface MaterializeOptions {\n system?: string\n temperature?: number\n maxRetries?: number\n}\n\nexport class PinConfigMaterializeError extends Error {\n readonly pinType: PinTypeId\n readonly zodError?: z.ZodError\n\n constructor(pinType: PinTypeId, message: string, zodError?: z.ZodError) {\n super(message)\n this.name = 'PinConfigMaterializeError'\n this.pinType = pinType\n this.zodError = zodError\n }\n}\n\nfunction serializePipeInput(input: PipeInput): string {\n if (typeof input === 'string') return input\n try {\n return JSON.stringify(input, null, 2)\n } catch {\n return String(input)\n }\n}\n\nfunction buildSystemPrompt(pinType: PinTypeId, override?: string): string {\n if (override) return override\n const fields = PIN_CONFIG_FIELDS[pinType].join(', ')\n return [\n `You convert arbitrary user text or JSON into a valid Pindown pin_config for pin_type \"${pinType}\".`,\n `Only output top-level pin_config fields for this type: ${fields}.`,\n 'Map user data faithfully. Invent stable string ids where needed (columns, rows, cards, etc.).',\n 'Where a field is a key-value map, output it as [{ key, value }, ...] (one entry per key).',\n 'Do not include metadata (title, tags) — only pin_config shape.',\n ].join(' ')\n}\n\ntype GenerateObjectFn = (opts: {\n model: unknown\n schema: z.ZodTypeAny\n temperature?: number\n maxRetries?: number\n system?: string\n prompt: string\n}) => Promise<{ object: unknown }>\n\nconst runGenerateObject = generateObject as unknown as GenerateObjectFn\n\nexport async function materializePinConfig<T extends PinTypeId>(\n input: PipeInput,\n pinType: T,\n llm: LlmConfig,\n options?: MaterializeOptions,\n): Promise<PinConfigByType[T]> {\n const apiSchema = getPinConfigZodSchema(pinType)\n const llmSchema = getLlmPinConfigZodSchema(pinType)\n const model = await resolveLanguageModel(llm)\n const hint = formatPinConfigHint(pinType)\n const inputText = serializePipeInput(input)\n\n const { object } = await runGenerateObject({\n model,\n schema: llmSchema,\n temperature: options?.temperature ?? 0,\n maxRetries: options?.maxRetries ?? 2,\n system: buildSystemPrompt(pinType, options?.system),\n prompt: [`Pin type: ${pinType}`, '', hint, '', 'User input:', inputText].join('\\n'),\n })\n\n const normalized = normalizeLlmPinConfigOutput(object, apiSchema)\n const canonical = canonicalizePinConfigForApi(pinType, normalized)\n const parsed = apiSchema.safeParse(canonical)\n if (!parsed.success) {\n throw new PinConfigMaterializeError(\n pinType,\n `LLM output failed validation for pin_type \"${pinType}\": ${parsed.error.message}`,\n parsed.error,\n )\n }\n\n return parsed.data as PinConfigByType[T]\n}\n","import type { PindownClient } from '../client/PindownClient'\nimport { PIN_CONFIG_FIELDS, pinTypeToMethodSuffix } from '../client/pins/pin-helper-core'\nimport { PRODUCT_PIN_TYPES } from '../types/pins'\nimport type {\n CreatePinHelperInput,\n Pin,\n PinConfigByType,\n PinTypeId,\n UpdatePinHelperInput,\n} from '../types/pins'\nimport type { ConfigPipeHelperMethods } from './pipe-types'\nimport { materializePinConfig, type MaterializeOptions, type PipeInput } from './materialize'\nimport type { LlmConfig } from './providers'\n\nexport type { PipeInput, MaterializeOptions } from './materialize'\nexport type { LlmConfig } from './providers'\nexport type { ConfigPipeHelperMethods } from './pipe-types'\n\nfunction mergeConfigIntoCreateInput<T extends PinTypeId>(\n pinType: T,\n materialized: PinConfigByType[T],\n input: CreatePinHelperInput<T>,\n): CreatePinHelperInput<T> {\n const merged = { ...input } as Record<string, unknown>\n for (const key of PIN_CONFIG_FIELDS[pinType]) {\n const fromInput = (input as Record<string, unknown>)[key]\n const fromLlm = (materialized as Record<string, unknown>)[key]\n merged[key] = fromInput !== undefined ? fromInput : fromLlm\n }\n return merged as CreatePinHelperInput<T>\n}\n\nfunction mergeConfigIntoUpdateInput<T extends PinTypeId>(\n pinType: T,\n materialized: PinConfigByType[T],\n input?: UpdatePinHelperInput<T>,\n): UpdatePinHelperInput<T> {\n const base = { ...(input ?? {}) } as Record<string, unknown>\n for (const key of PIN_CONFIG_FIELDS[pinType]) {\n const fromInput = input ? (input as Record<string, unknown>)[key] : undefined\n const fromLlm = (materialized as Record<string, unknown>)[key]\n if (fromInput !== undefined) {\n base[key] = fromInput\n } else if (fromLlm !== undefined) {\n base[key] = fromLlm\n }\n }\n return base as UpdatePinHelperInput<T>\n}\n\nexport class PinConfigPipe<T extends PinTypeId> {\n private client?: PindownClient\n private materializedPromise?: Promise<PinConfigByType[T]>\n\n constructor(\n private readonly input: PipeInput,\n readonly pinType: T,\n private readonly llm: LlmConfig,\n private readonly options?: MaterializeOptions,\n ) {}\n\n /** Attach a Pindown client for create/update helpers. */\n using(client: PindownClient): this {\n this.client = client\n return this\n }\n\n /** Alias for {@link using}. */\n with(client: PindownClient): this {\n return this.using(client)\n }\n\n /** Run the LLM once and return validated pin_config (cached on this pipe). */\n async materialize(): Promise<PinConfigByType[T]> {\n if (!this.materializedPromise) {\n this.materializedPromise = materializePinConfig(this.input, this.pinType, this.llm, this.options)\n }\n return this.materializedPromise\n }\n\n async createPin(\n input: CreatePinHelperInput<T>,\n client?: PindownClient,\n ): Promise<Pin<T>> {\n const c = client ?? this.requireClient()\n const pin_config = await this.materialize()\n return c.pins.createPin(this.pinType, mergeConfigIntoCreateInput(this.pinType, pin_config, input))\n }\n\n async updatePin(\n pinId: string,\n input?: UpdatePinHelperInput<T>,\n client?: PindownClient,\n ): Promise<Pin<T>> {\n const c = client ?? this.requireClient()\n const pin_config = await this.materialize()\n return c.pins.updatePin(\n pinId,\n this.pinType,\n mergeConfigIntoUpdateInput(this.pinType, pin_config, input),\n )\n }\n\n private requireClient(): PindownClient {\n if (!this.client) {\n throw new Error(\n 'Pindown client required. Call .using(client) first or pass client as the last argument.',\n )\n }\n return this.client\n }\n}\n\nfunction attachNamedPipeMethods(proto: PinConfigPipe<PinTypeId>): void {\n for (const pinType of PRODUCT_PIN_TYPES as readonly PinTypeId[]) {\n const suffix = pinTypeToMethodSuffix(pinType)\n const createMethod = `create${suffix}`\n const updateMethod = `update${suffix}`\n\n ;(proto as unknown as Record<string, unknown>)[createMethod] = function (\n this: PinConfigPipe<PinTypeId>,\n input: CreatePinHelperInput<typeof pinType>,\n client?: PindownClient,\n ) {\n if (this.pinType !== pinType) {\n throw new Error(`${createMethod}() requires pin type \"${pinType}\", got \"${this.pinType}\"`)\n }\n return this.createPin(input, client)\n }\n\n ;(proto as unknown as Record<string, unknown>)[updateMethod] = function (\n this: PinConfigPipe<PinTypeId>,\n pinId: string,\n input?: UpdatePinHelperInput<typeof pinType>,\n client?: PindownClient,\n ) {\n if (this.pinType !== pinType) {\n throw new Error(`${updateMethod}() requires pin type \"${pinType}\", got \"${this.pinType}\"`)\n }\n return this.updatePin(pinId, input, client)\n }\n }\n}\n\nattachNamedPipeMethods(PinConfigPipe.prototype)\n\n/**\n * Pipe arbitrary text or JSON through an LLM into a typed pin_config, then create or update pins.\n *\n * @example\n * ```ts\n * const pin = await toConfig(myJson, 'table', { provider: 'google', model: 'gemini-2.0-flash' })\n * .using(client)\n * .createTable({ title: 'Inventory' })\n *\n * await toConfig('weekly KPIs...', 'stat-cards', llm)\n * .using(client)\n * .updateStatCards(pinId)\n * ```\n */\nexport function toConfig<T extends PinTypeId>(\n input: PipeInput,\n pinType: T,\n llm: LlmConfig,\n options?: MaterializeOptions,\n): PinConfigPipe<T> & ConfigPipeHelperMethods {\n return new PinConfigPipe(input, pinType, llm, options) as PinConfigPipe<T> & ConfigPipeHelperMethods\n}\n\n/** Alias for {@link toConfig}. */\nexport const pipePinConfig = toConfig\n"]}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { P as PinTypeId, C as CreatePinHelperInput, e as PindownClient, a as Pin, U as UpdatePinHelperInput, b as PinConfigByType } from '../PindownClient-Blc0tgqw.cjs';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { LanguageModel } from 'ai';
|
|
4
|
+
|
|
5
|
+
type CapitalizeWord<S extends string> = S extends `${infer C}${infer R}` ? `${Uppercase<C>}${R}` : S;
|
|
6
|
+
type PascalFromKebab<S extends string> = S extends `${infer Head}-${infer Tail}` ? `${CapitalizeWord<Head>}${PascalFromKebab<Tail>}` : CapitalizeWord<S>;
|
|
7
|
+
/** `createTable`, `updateMarkdown`, … on a {@link PinConfigPipe} (runtime-checked vs pin type). */
|
|
8
|
+
type ConfigPipeHelperMethods = {
|
|
9
|
+
[T in PinTypeId as `create${PascalFromKebab<T>}`]: (input: CreatePinHelperInput<T>, client?: PindownClient) => Promise<Pin<T>>;
|
|
10
|
+
} & {
|
|
11
|
+
[T in PinTypeId as `update${PascalFromKebab<T>}`]: (pinId: string, input?: UpdatePinHelperInput<T>, client?: PindownClient) => Promise<Pin<T>>;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
type AiProvider = 'google' | 'anthropic' | 'openai';
|
|
15
|
+
interface LlmConfig {
|
|
16
|
+
provider: AiProvider;
|
|
17
|
+
/** Model id, e.g. gemini-2.0-flash, claude-sonnet-4-20250514, gpt-4o */
|
|
18
|
+
model: string;
|
|
19
|
+
/** Falls back to GOOGLE_GENERATIVE_AI_API_KEY / ANTHROPIC_API_KEY / OPENAI_API_KEY */
|
|
20
|
+
apiKey?: string;
|
|
21
|
+
}
|
|
22
|
+
/** Prefer a valid-length key when both env vars are set (truncated keys are common in .env). */
|
|
23
|
+
declare function resolveGoogleApiKey(): string | undefined;
|
|
24
|
+
declare function resolveLanguageModel(config: LlmConfig): Promise<LanguageModel>;
|
|
25
|
+
|
|
26
|
+
type PipeInput = string | Record<string, unknown> | unknown[] | unknown;
|
|
27
|
+
interface MaterializeOptions {
|
|
28
|
+
system?: string;
|
|
29
|
+
temperature?: number;
|
|
30
|
+
maxRetries?: number;
|
|
31
|
+
}
|
|
32
|
+
declare class PinConfigMaterializeError extends Error {
|
|
33
|
+
readonly pinType: PinTypeId;
|
|
34
|
+
readonly zodError?: z.ZodError;
|
|
35
|
+
constructor(pinType: PinTypeId, message: string, zodError?: z.ZodError);
|
|
36
|
+
}
|
|
37
|
+
declare function materializePinConfig<T extends PinTypeId>(input: PipeInput, pinType: T, llm: LlmConfig, options?: MaterializeOptions): Promise<PinConfigByType[T]>;
|
|
38
|
+
|
|
39
|
+
declare class PinConfigPipe<T extends PinTypeId> {
|
|
40
|
+
private readonly input;
|
|
41
|
+
readonly pinType: T;
|
|
42
|
+
private readonly llm;
|
|
43
|
+
private readonly options?;
|
|
44
|
+
private client?;
|
|
45
|
+
private materializedPromise?;
|
|
46
|
+
constructor(input: PipeInput, pinType: T, llm: LlmConfig, options?: MaterializeOptions | undefined);
|
|
47
|
+
/** Attach a Pindown client for create/update helpers. */
|
|
48
|
+
using(client: PindownClient): this;
|
|
49
|
+
/** Alias for {@link using}. */
|
|
50
|
+
with(client: PindownClient): this;
|
|
51
|
+
/** Run the LLM once and return validated pin_config (cached on this pipe). */
|
|
52
|
+
materialize(): Promise<PinConfigByType[T]>;
|
|
53
|
+
createPin(input: CreatePinHelperInput<T>, client?: PindownClient): Promise<Pin<T>>;
|
|
54
|
+
updatePin(pinId: string, input?: UpdatePinHelperInput<T>, client?: PindownClient): Promise<Pin<T>>;
|
|
55
|
+
private requireClient;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Pipe arbitrary text or JSON through an LLM into a typed pin_config, then create or update pins.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* const pin = await toConfig(myJson, 'table', { provider: 'google', model: 'gemini-2.0-flash' })
|
|
63
|
+
* .using(client)
|
|
64
|
+
* .createTable({ title: 'Inventory' })
|
|
65
|
+
*
|
|
66
|
+
* await toConfig('weekly KPIs...', 'stat-cards', llm)
|
|
67
|
+
* .using(client)
|
|
68
|
+
* .updateStatCards(pinId)
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
declare function toConfig<T extends PinTypeId>(input: PipeInput, pinType: T, llm: LlmConfig, options?: MaterializeOptions): PinConfigPipe<T> & ConfigPipeHelperMethods;
|
|
72
|
+
/** Alias for {@link toConfig}. */
|
|
73
|
+
declare const pipePinConfig: typeof toConfig;
|
|
74
|
+
|
|
75
|
+
/** Zod validators for product pin types — aligned with backend PIN_CONFIG_SCHEMAS. */
|
|
76
|
+
declare const PIN_CONFIG_ZOD_SCHEMAS: Record<PinTypeId, z.ZodTypeAny>;
|
|
77
|
+
declare function getPinConfigZodSchema(pinType: PinTypeId): z.ZodTypeAny;
|
|
78
|
+
/** LLM structured-output schema (records → entry arrays). Validated output is normalized back via API schema. */
|
|
79
|
+
declare function getLlmPinConfigZodSchema(pinType: PinTypeId): z.ZodTypeAny;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Convert API zod schemas → LLM-friendly schemas.
|
|
83
|
+
* `z.record()` becomes `[{ key, value }]` because structured-output APIs struggle with open records.
|
|
84
|
+
*/
|
|
85
|
+
declare function toLlmPinConfigSchema(schema: z.ZodTypeAny): z.ZodTypeAny;
|
|
86
|
+
/**
|
|
87
|
+
* Convert LLM output back to API pin_config shape using the same API zod schema as guide.
|
|
88
|
+
*/
|
|
89
|
+
declare function normalizeLlmPinConfigOutput(data: unknown, apiSchema: z.ZodTypeAny): unknown;
|
|
90
|
+
|
|
91
|
+
declare function canonicalizePinConfigForApi(pinType: PinTypeId, config: unknown): unknown;
|
|
92
|
+
|
|
93
|
+
export { type AiProvider, type ConfigPipeHelperMethods, type LlmConfig, type MaterializeOptions, PIN_CONFIG_ZOD_SCHEMAS, PinConfigMaterializeError, PinConfigPipe, type PipeInput, canonicalizePinConfigForApi, getLlmPinConfigZodSchema, getPinConfigZodSchema, materializePinConfig, normalizeLlmPinConfigOutput, pipePinConfig, resolveGoogleApiKey, resolveLanguageModel, toConfig, toLlmPinConfigSchema };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { P as PinTypeId, C as CreatePinHelperInput, e as PindownClient, a as Pin, U as UpdatePinHelperInput, b as PinConfigByType } from '../PindownClient-Blc0tgqw.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { LanguageModel } from 'ai';
|
|
4
|
+
|
|
5
|
+
type CapitalizeWord<S extends string> = S extends `${infer C}${infer R}` ? `${Uppercase<C>}${R}` : S;
|
|
6
|
+
type PascalFromKebab<S extends string> = S extends `${infer Head}-${infer Tail}` ? `${CapitalizeWord<Head>}${PascalFromKebab<Tail>}` : CapitalizeWord<S>;
|
|
7
|
+
/** `createTable`, `updateMarkdown`, … on a {@link PinConfigPipe} (runtime-checked vs pin type). */
|
|
8
|
+
type ConfigPipeHelperMethods = {
|
|
9
|
+
[T in PinTypeId as `create${PascalFromKebab<T>}`]: (input: CreatePinHelperInput<T>, client?: PindownClient) => Promise<Pin<T>>;
|
|
10
|
+
} & {
|
|
11
|
+
[T in PinTypeId as `update${PascalFromKebab<T>}`]: (pinId: string, input?: UpdatePinHelperInput<T>, client?: PindownClient) => Promise<Pin<T>>;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
type AiProvider = 'google' | 'anthropic' | 'openai';
|
|
15
|
+
interface LlmConfig {
|
|
16
|
+
provider: AiProvider;
|
|
17
|
+
/** Model id, e.g. gemini-2.0-flash, claude-sonnet-4-20250514, gpt-4o */
|
|
18
|
+
model: string;
|
|
19
|
+
/** Falls back to GOOGLE_GENERATIVE_AI_API_KEY / ANTHROPIC_API_KEY / OPENAI_API_KEY */
|
|
20
|
+
apiKey?: string;
|
|
21
|
+
}
|
|
22
|
+
/** Prefer a valid-length key when both env vars are set (truncated keys are common in .env). */
|
|
23
|
+
declare function resolveGoogleApiKey(): string | undefined;
|
|
24
|
+
declare function resolveLanguageModel(config: LlmConfig): Promise<LanguageModel>;
|
|
25
|
+
|
|
26
|
+
type PipeInput = string | Record<string, unknown> | unknown[] | unknown;
|
|
27
|
+
interface MaterializeOptions {
|
|
28
|
+
system?: string;
|
|
29
|
+
temperature?: number;
|
|
30
|
+
maxRetries?: number;
|
|
31
|
+
}
|
|
32
|
+
declare class PinConfigMaterializeError extends Error {
|
|
33
|
+
readonly pinType: PinTypeId;
|
|
34
|
+
readonly zodError?: z.ZodError;
|
|
35
|
+
constructor(pinType: PinTypeId, message: string, zodError?: z.ZodError);
|
|
36
|
+
}
|
|
37
|
+
declare function materializePinConfig<T extends PinTypeId>(input: PipeInput, pinType: T, llm: LlmConfig, options?: MaterializeOptions): Promise<PinConfigByType[T]>;
|
|
38
|
+
|
|
39
|
+
declare class PinConfigPipe<T extends PinTypeId> {
|
|
40
|
+
private readonly input;
|
|
41
|
+
readonly pinType: T;
|
|
42
|
+
private readonly llm;
|
|
43
|
+
private readonly options?;
|
|
44
|
+
private client?;
|
|
45
|
+
private materializedPromise?;
|
|
46
|
+
constructor(input: PipeInput, pinType: T, llm: LlmConfig, options?: MaterializeOptions | undefined);
|
|
47
|
+
/** Attach a Pindown client for create/update helpers. */
|
|
48
|
+
using(client: PindownClient): this;
|
|
49
|
+
/** Alias for {@link using}. */
|
|
50
|
+
with(client: PindownClient): this;
|
|
51
|
+
/** Run the LLM once and return validated pin_config (cached on this pipe). */
|
|
52
|
+
materialize(): Promise<PinConfigByType[T]>;
|
|
53
|
+
createPin(input: CreatePinHelperInput<T>, client?: PindownClient): Promise<Pin<T>>;
|
|
54
|
+
updatePin(pinId: string, input?: UpdatePinHelperInput<T>, client?: PindownClient): Promise<Pin<T>>;
|
|
55
|
+
private requireClient;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Pipe arbitrary text or JSON through an LLM into a typed pin_config, then create or update pins.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* const pin = await toConfig(myJson, 'table', { provider: 'google', model: 'gemini-2.0-flash' })
|
|
63
|
+
* .using(client)
|
|
64
|
+
* .createTable({ title: 'Inventory' })
|
|
65
|
+
*
|
|
66
|
+
* await toConfig('weekly KPIs...', 'stat-cards', llm)
|
|
67
|
+
* .using(client)
|
|
68
|
+
* .updateStatCards(pinId)
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
declare function toConfig<T extends PinTypeId>(input: PipeInput, pinType: T, llm: LlmConfig, options?: MaterializeOptions): PinConfigPipe<T> & ConfigPipeHelperMethods;
|
|
72
|
+
/** Alias for {@link toConfig}. */
|
|
73
|
+
declare const pipePinConfig: typeof toConfig;
|
|
74
|
+
|
|
75
|
+
/** Zod validators for product pin types — aligned with backend PIN_CONFIG_SCHEMAS. */
|
|
76
|
+
declare const PIN_CONFIG_ZOD_SCHEMAS: Record<PinTypeId, z.ZodTypeAny>;
|
|
77
|
+
declare function getPinConfigZodSchema(pinType: PinTypeId): z.ZodTypeAny;
|
|
78
|
+
/** LLM structured-output schema (records → entry arrays). Validated output is normalized back via API schema. */
|
|
79
|
+
declare function getLlmPinConfigZodSchema(pinType: PinTypeId): z.ZodTypeAny;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Convert API zod schemas → LLM-friendly schemas.
|
|
83
|
+
* `z.record()` becomes `[{ key, value }]` because structured-output APIs struggle with open records.
|
|
84
|
+
*/
|
|
85
|
+
declare function toLlmPinConfigSchema(schema: z.ZodTypeAny): z.ZodTypeAny;
|
|
86
|
+
/**
|
|
87
|
+
* Convert LLM output back to API pin_config shape using the same API zod schema as guide.
|
|
88
|
+
*/
|
|
89
|
+
declare function normalizeLlmPinConfigOutput(data: unknown, apiSchema: z.ZodTypeAny): unknown;
|
|
90
|
+
|
|
91
|
+
declare function canonicalizePinConfigForApi(pinType: PinTypeId, config: unknown): unknown;
|
|
92
|
+
|
|
93
|
+
export { type AiProvider, type ConfigPipeHelperMethods, type LlmConfig, type MaterializeOptions, PIN_CONFIG_ZOD_SCHEMAS, PinConfigMaterializeError, PinConfigPipe, type PipeInput, canonicalizePinConfigForApi, getLlmPinConfigZodSchema, getPinConfigZodSchema, materializePinConfig, normalizeLlmPinConfigOutput, pipePinConfig, resolveGoogleApiKey, resolveLanguageModel, toConfig, toLlmPinConfigSchema };
|
package/dist/ai/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import {generateObject}from'ai';import {z as z$1}from'zod';var P=["markdown","image","gallery","table","charts","mermaid","code","embed","pdf-viewer","excel-viewer","stat-cards","timeline","json-viewer","json-list","links","qr-code","social-handles","steps","trace","plan","notes","csv-viewer","user-story","chat","intro","mastra","text-media","business-card","video","audio","file-upload","kanban-board","checklist","comparison","calendar","roadmap","realtime-canvas"];[...P];var d={markdown:["content","collaboration"],image:["url","altText","fit"],gallery:["images"],table:["columns","rows"],charts:["chartType","data","xAxis","yAxis"],mermaid:["diagram","code","title"],code:["code","language","filename","title"],embed:["url","type"],"pdf-viewer":["pdf"],"excel-viewer":["excel"],"stat-cards":["cards"],timeline:["mode","items"],"json-viewer":["json","jsonString","title"],"json-list":["json","jsonString"],links:["links"],"qr-code":["url","label"],"social-handles":["title","showLabels","iconSize","handles"],steps:["steps"],trace:["title","live","spans"],plan:["title","status","breadcrumbs","phases"],notes:["notes"],"csv-viewer":["csvText","csvData","fileName"],"user-story":["title","userStory","acceptanceCriteria"],chat:["title","placeholder","linked_pin_id","linked_pin_title"],intro:["heading","subheading"],mastra:["mode","agentId","workflowId"],"text-media":["title","text","subtext","textPosition","mediaType","embedConfig","imageConfig"],"business-card":["sectionTitle","fields","imageConfig","imagePosition"],video:["url","fileId","fileName","mimeType","caption","size"],audio:["url","fileId","fileName","mimeType","caption","size","tracks"],"file-upload":["files","displayMode"],"kanban-board":["columns"],checklist:["title","items"],comparison:["title","left","right","highlightedLines","matches","showVsBadge"],calendar:["weekStartsOn","events"],roadmap:["title","months"],"realtime-canvas":["title","description","roomId"]};function S(e){return e.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join("")}var wn={pin_type:"table",summary:"Spreadsheet-style pin. columns is required; rows are optional but needed for visible data.",required_fields:["columns"],optional_fields:["rows"],fields:[{path:"columns",type:"TableColumn[]",required:true,description:"At least one column. Each column needs id + name (type optional, e.g. text | number)."},{path:"columns[].id",type:"string",required:true,description:"Stable column key used in row.cells."},{path:"columns[].name",type:"string",required:true,description:"Column header label."},{path:"rows",type:"TableRow[]",required:false,description:"Table data. Each row: { id, cells: { [columnId]: value } }."}],example_config:{columns:[{id:"col1",name:"Name",type:"text"},{id:"col2",name:"Value",type:"number"}],rows:[{id:"row1",cells:{col1:"Item",col2:1}}]},example_update:{pin_config:{columns:[{id:"col1",name:"Name",type:"text"},{id:"col2",name:"Value",type:"number"}],rows:[{id:"row1",cells:{col1:"Updated",col2:42}}]}}},xn={table:wn,markdown:{pin_type:"markdown",summary:"Rich text / markdown body.",required_fields:[],optional_fields:["content","collaboration"],fields:[{path:"content",type:"string",required:false,description:"Markdown source. Server seeds Yjs when set on create."}],example_config:{content:`# Hello
|
|
2
|
+
|
|
3
|
+
Body text.`},example_update:{pin_config:{content:`# Updated
|
|
4
|
+
|
|
5
|
+
New body.`}}},"stat-cards":{pin_type:"stat-cards",summary:"KPI cards grid.",required_fields:["cards"],optional_fields:[],fields:[{path:"cards",type:"StatCardItem[]",required:true,description:"Each card: title, value; optional change, trend (up|down|neutral)."}],example_config:{cards:[{title:"Revenue",value:"1000",change:"+5%",trend:"up"}]},example_update:{pin_config:{cards:[{title:"Revenue",value:"1234",change:"+8%",trend:"up"}]}}}};function Tn(e){return xn[e]}function j(e){let t=Tn(e);return t?[`Pin type: ${t.pin_type}`,t.summary,"","Required pin_config fields:",...t.required_fields.map(o=>` - ${o}`),"","Optional pin_config fields:",...t.optional_fields.length?t.optional_fields.map(o=>` - ${o}`):[" (none documented)"],"","Field reference:",...t.fields.map(o=>` ${o.path} (${o.type}${o.required?", required":""}): ${o.description}`),"","Example update payload:",JSON.stringify(t.example_update,null,2)].join(`
|
|
6
|
+
`):[`No built-in hint for pin type "${e}".`,"Use CreatePinRequest<typeof pinType> / PinConfigByType[typeof pinType] in TypeScript,","or client.pins.create({ pin_type, pin_config, metadata }) with typed pin_config."].join(`
|
|
7
|
+
`)}function v(e){let t=e;for(;;){if(t instanceof z$1.ZodOptional||t instanceof z$1.ZodNullable){t=t.unwrap();continue}if(t instanceof z$1.ZodDefault){t=t.removeDefault();continue}if(t instanceof z$1.ZodEffects){t=t.innerType();continue}break}return t}var _n=()=>z$1.union([z$1.string(),z$1.number(),z$1.boolean(),z$1.null()]);function u(e){let t=v(e);if(t instanceof z$1.ZodRecord)return z$1.array(z$1.object({key:z$1.string(),value:_n()}));if(t instanceof z$1.ZodArray)return z$1.array(u(t.element));if(t instanceof z$1.ZodObject){let i={};for(let[o,r]of Object.entries(t.shape))i[o]=u(r);return t._def.unknownKeys==="passthrough"?z$1.object(i).passthrough():z$1.object(i)}return e}function w(e){let t={};if(!Array.isArray(e))return t;for(let i of e){if(!i||typeof i!="object")continue;let o=i,r=o.key??o.columnId;if(r==null)continue;let a=o.value;t[r]=Array.isArray(a)&&A(a)?w(a):a;}return t}function A(e){return e.every(t=>t&&typeof t=="object"&&("key"in t||"columnId"in t))}function R(e){if(Array.isArray(e)&&A(e))return w(e);if(e&&typeof e=="object"&&!Array.isArray(e)){let t=e,i={};for(let[o,r]of Object.entries(t))i[o]=R(r);return i}return e}function m(e,t){if(e==null)return e;let i=v(t);if(i instanceof z$1.ZodRecord)return Array.isArray(e)?w(e):R(e);if(i instanceof z$1.ZodArray)return Array.isArray(e)?e.map(o=>m(o,i.element)):e;if(i instanceof z$1.ZodObject){if(!e||typeof e!="object"||Array.isArray(e))return e;let r={...e};for(let[a,p]of Object.entries(i.shape))a in r&&(r[a]=m(r[a],p));return r}return e}var l={TABLE_MAX_ROWS:100,KEY_VALUE_MAX_ITEMS:48,CARDS_MAX_ITEMS:24,TRACE_MAX_SPANS:50,OKR_MAX_KEY_RESULTS:50,GALLERY_MAX_IMAGES:32};var In=z$1.object({}).passthrough(),M=z$1.object({content:z$1.string().optional(),collaboration:z$1.object({enabled:z$1.boolean().optional()}).optional()}).passthrough(),E=z$1.object({cards:z$1.array(z$1.object({title:z$1.string(),value:z$1.union([z$1.string(),z$1.number()])}).passthrough()).min(1,"stat-cards pin_config.cards must contain at least one card")}).passthrough(),L=z$1.object({url:z$1.string().optional(),altText:z$1.string().optional(),fit:z$1.string().optional()}).passthrough(),z=z$1.object({url:z$1.string().min(1).optional(),fileId:z$1.string().optional(),fileName:z$1.string().optional(),mimeType:z$1.literal("video/mp4").optional(),caption:z$1.string().optional(),size:z$1.number().positive().optional()}).passthrough(),Sn=z$1.object({url:z$1.string().min(1),fileId:z$1.string().optional(),fileName:z$1.string().optional(),mimeType:z$1.enum(["audio/mpeg","audio/wav","audio/x-wav"]).optional(),size:z$1.number().positive().optional()}).passthrough(),O=z$1.object({url:z$1.string().min(1).optional(),fileId:z$1.string().optional(),fileName:z$1.string().optional(),mimeType:z$1.enum(["audio/mpeg","audio/wav","audio/x-wav"]).optional(),caption:z$1.string().optional(),size:z$1.number().positive().optional(),tracks:z$1.array(Sn).max(10).optional()}).passthrough().refine(e=>!!String(e.url??"").trim()||Array.isArray(e.tracks)&&e.tracks.length>0,{message:"Audio pin requires url or at least one track"}),q=z$1.object({columns:z$1.array(z$1.object({id:z$1.string(),name:z$1.string(),type:z$1.string().optional()}).passthrough()).min(1),rows:z$1.array(z$1.object({id:z$1.string(),cells:z$1.record(z$1.string(),z$1.union([z$1.string(),z$1.number(),z$1.boolean(),z$1.null()])).refine(e=>Object.keys(e).length>0,{message:"each table row must include at least one cell value"})}).passthrough()).min(1).max(l.TABLE_MAX_ROWS).optional()}).passthrough(),N=z$1.object({chartType:z$1.string().optional(),data:z$1.array(z$1.record(z$1.string(),z$1.unknown())).optional()}).passthrough(),B=z$1.object({url:z$1.string().optional(),type:z$1.string().optional()}).passthrough(),H=z$1.object({pdf:z$1.object({url:z$1.string().min(1)}).passthrough()}).passthrough(),U=z$1.object({excel:z$1.object({url:z$1.string().min(1)}).passthrough()}).passthrough(),V=z$1.object({items:z$1.array(z$1.record(z$1.string(),z$1.unknown())).optional(),mode:z$1.string().optional()}).passthrough(),G=z$1.object({json:z$1.unknown().optional(),jsonString:z$1.string().optional(),title:z$1.string().optional()}).passthrough(),Z=z$1.object({json:z$1.array(z$1.unknown()).optional(),jsonString:z$1.string().optional()}).passthrough(),K=z$1.object({links:z$1.array(z$1.record(z$1.string(),z$1.unknown())).optional()}).passthrough(),$=z$1.object({steps:z$1.array(z$1.object({title:z$1.string()}).passthrough()).min(1)}).passthrough(),F=z$1.object({spans:z$1.array(z$1.object({name:z$1.string(),status:z$1.enum(["completed","running","pending","failed"])}).passthrough()).min(1,"trace pin_config.spans must contain at least one span").max(l.TRACE_MAX_SPANS)}).passthrough(),jn=z$1.object({type:z$1.enum(["details","command","code","text","link","mermaid","summary"])}).passthrough(),vn=z$1.object({title:z$1.string(),blocks:z$1.array(jn).optional()}).passthrough(),Y=z$1.object({phases:z$1.array(z$1.object({title:z$1.string(),tasks:z$1.array(vn).min(1)}).passthrough()).min(1,"plan pin_config.phases must contain at least one phase")}).passthrough(),D=z$1.object({notes:z$1.array(z$1.object({title:z$1.string()}).passthrough()).optional()}).passthrough(),X=z$1.object({csvData:z$1.array(z$1.record(z$1.string(),z$1.unknown())).optional(),csvText:z$1.string().optional(),fileName:z$1.string().optional()}).passthrough(),J=z$1.object({images:z$1.array(z$1.record(z$1.string(),z$1.unknown())).max(l.GALLERY_MAX_IMAGES).optional()}).passthrough(),W=z$1.object({code:z$1.string().optional(),diagram:z$1.string().optional(),title:z$1.string().optional()}).passthrough().refine(e=>!!(e.code?.trim()||e.diagram?.trim()),{message:"mermaid pin_config requires code or diagram"}),Q=z$1.object({code:z$1.string().min(1),language:z$1.string().optional(),filename:z$1.string().optional(),title:z$1.string().optional()}).passthrough(),nn=z$1.object({userStory:z$1.string().min(1)}).passthrough(),en=z$1.object({title:z$1.string().optional(),placeholder:z$1.string().optional(),linked_pin_id:z$1.string().optional(),linked_pin_title:z$1.string().optional()}).passthrough(),tn=z$1.object({heading:z$1.string().min(1)}).passthrough(),on=z$1.object({title:z$1.string().optional(),text:z$1.string().optional()}).passthrough(),rn=z$1.object({sectionTitle:z$1.string().optional(),fields:z$1.array(z$1.object({id:z$1.string(),key:z$1.string(),value:z$1.string()}).passthrough()).min(1),imagePosition:z$1.enum(["left","right"]).optional()}).passthrough(),an=z$1.object({url:z$1.string().optional(),label:z$1.string().optional()}).passthrough(),sn=z$1.object({title:z$1.string().optional(),showLabels:z$1.boolean().optional(),iconSize:z$1.number().optional(),handles:z$1.array(z$1.object({platform:z$1.string(),url:z$1.string(),label:z$1.string().optional()}).passthrough()).optional()}).passthrough(),pn=z$1.object({files:z$1.array(z$1.record(z$1.string(),z$1.unknown())).optional(),displayMode:z$1.string().optional()}).passthrough(),ln=z$1.object({columns:z$1.array(z$1.object({id:z$1.string(),title:z$1.string()}).passthrough()).min(1)}).passthrough(),cn=z$1.object({id:z$1.string(),name:z$1.string(),description:z$1.string().optional(),checked:z$1.boolean().optional()}).passthrough(),An=z$1.object({id:z$1.string(),title:z$1.string(),label:z$1.string().optional(),items:z$1.array(cn).min(1)}).passthrough(),gn=z$1.object({mode:z$1.enum(["flat","sections"]).optional(),title:z$1.string().optional(),footer:z$1.string().optional(),items:z$1.array(cn).optional(),sections:z$1.array(An).optional()}).passthrough().superRefine((e,t)=>{if((e.mode==="sections"?"sections":"flat")==="sections"){(!Array.isArray(e.sections)||e.sections.length===0)&&t.addIssue({code:z$1.ZodIssueCode.custom,message:"checklist sections mode requires at least one section"});return}(!Array.isArray(e.items)||e.items.length===0)&&t.addIssue({code:z$1.ZodIssueCode.custom,message:"checklist flat mode requires at least one item"});}),Rn=z$1.object({url:z$1.string(),alt:z$1.string().optional(),link:z$1.string().optional(),fileId:z$1.string().optional()}).passthrough(),Mn=z$1.object({id:z$1.string(),image:Rn,title:z$1.string(),subtext:z$1.string().optional()}).passthrough();z$1.object({title:z$1.string().optional(),layout:z$1.enum(["horizontal","vertical","gallery"]).optional(),columns:z$1.union([z$1.literal(2),z$1.literal(3),z$1.literal(4)]).optional(),items:z$1.array(Mn).min(1).max(l.CARDS_MAX_ITEMS)}).passthrough();var En=z$1.object({id:z$1.string(),key:z$1.string(),value:z$1.union([z$1.string(),z$1.number()]),unit:z$1.string().optional(),hint:z$1.string().optional()}).passthrough();z$1.object({title:z$1.string().optional(),subtitle:z$1.string().optional(),period:z$1.string().optional(),layout:z$1.enum(["list","grid"]).optional(),columns:z$1.union([z$1.literal(2),z$1.literal(3),z$1.literal(4)]).optional(),items:z$1.array(En).min(1).max(l.KEY_VALUE_MAX_ITEMS)}).passthrough();var Ln=z$1.object({id:z$1.string(),question:z$1.string(),answer:z$1.string()}).passthrough();z$1.object({title:z$1.string().optional(),items:z$1.array(Ln).min(1)}).passthrough();var zn=z$1.object({id:z$1.string(),label:z$1.string(),url:z$1.string(),variant:z$1.enum(["primary","secondary","outline"]).optional()}).passthrough();z$1.object({headline:z$1.string().optional(),subline:z$1.string().optional(),buttons:z$1.array(zn).min(1).max(2)}).passthrough();var dn=z$1.object({title:z$1.string().optional(),left:z$1.object({label:z$1.string(),body:z$1.string()}).passthrough(),right:z$1.object({label:z$1.string(),body:z$1.string()}).passthrough(),highlightedLines:z$1.object({left:z$1.array(z$1.number().int().nonnegative()).optional(),right:z$1.array(z$1.number().int().nonnegative()).optional()}).optional(),matches:z$1.array(z$1.object({left:z$1.number().int().nonnegative(),right:z$1.number().int().nonnegative()})).optional(),showVsBadge:z$1.boolean().optional()}).passthrough(),un=z$1.object({events:z$1.array(z$1.record(z$1.string(),z$1.unknown())).optional(),weekStartsOn:z$1.number().optional()}).passthrough(),mn=z$1.object({months:z$1.array(z$1.record(z$1.string(),z$1.unknown())).optional(),title:z$1.string().optional()}).passthrough();z$1.object({title:z$1.string().optional(),defaultView:z$1.enum(["onboarding","bottlenecks"]).optional(),showTeam:z$1.boolean().optional(),team:z$1.array(z$1.object({id:z$1.string(),name:z$1.string(),role:z$1.string(),avatarUrl:z$1.string().optional(),status:z$1.enum(["live","away","offline"]).optional()}).passthrough()).optional(),swimlanes:z$1.array(z$1.object({id:z$1.string(),title:z$1.string()}).passthrough()).min(1),nodes:z$1.array(z$1.object({id:z$1.string(),swimlane:z$1.string(),label:z$1.string()}).passthrough()).min(1),edges:z$1.array(z$1.object({source:z$1.string(),target:z$1.string()}).passthrough()).optional()}).passthrough();z$1.object({title:z$1.string().optional(),subtitle:z$1.string().optional(),valueFormat:z$1.enum(["number","percent","currency"]).optional(),currency:z$1.string().optional(),highlightBiggestDrop:z$1.boolean().optional(),stages:z$1.array(z$1.object({id:z$1.string(),label:z$1.string(),value:z$1.number()}).passthrough()).min(1)}).passthrough();z$1.object({title:z$1.string().optional(),subtitle:z$1.string().optional(),maxScore:z$1.number().optional(),options:z$1.array(z$1.object({id:z$1.string(),label:z$1.string()}).passthrough()).min(2),criteria:z$1.array(z$1.object({id:z$1.string(),label:z$1.string(),scores:z$1.record(z$1.string(),z$1.number())}).passthrough()).min(1)}).passthrough();z$1.object({title:z$1.string().optional(),subtitle:z$1.string().optional(),period:z$1.string().optional(),objectives:z$1.array(z$1.object({id:z$1.string(),title:z$1.string(),keyResults:z$1.array(z$1.record(z$1.string(),z$1.unknown())).min(1)}).passthrough()).min(1)}).passthrough().refine(e=>(Array.isArray(e.objectives)?e.objectives:[]).reduce((o,r)=>o+(Array.isArray(r.keyResults)?r.keyResults.length:0),0)<=l.OKR_MAX_KEY_RESULTS,{message:`okr pin_config supports at most ${l.OKR_MAX_KEY_RESULTS} key results total`});z$1.object({question:z$1.string().min(1),options:z$1.array(z$1.object({id:z$1.string(),label:z$1.string()}).passthrough()).min(2),status:z$1.enum(["open","closed"]).optional(),showVoteCount:z$1.boolean().optional(),allowChangeVote:z$1.boolean().optional()}).passthrough();z$1.object({title:z$1.string().optional(),description:z$1.string().optional(),prompt:z$1.string().optional(),items:z$1.array(z$1.object({id:z$1.string(),label:z$1.string(),description:z$1.string().optional(),required:z$1.boolean().optional()}).passthrough()).optional(),status:z$1.enum(["open","closed"]).optional(),maxStars:z$1.number().min(3).max(5).optional(),allowHalfStars:z$1.boolean().optional(),allowChangeRating:z$1.boolean().optional(),showAverage:z$1.boolean().optional()}).passthrough();z$1.object({title:z$1.string().optional(),description:z$1.string().optional(),status:z$1.enum(["open","closed"]).optional(),allowEditResponse:z$1.boolean().optional(),questions:z$1.array(z$1.object({id:z$1.string(),label:z$1.string(),type:z$1.enum(["short-text","long-text","single-choice","multiple-choice","scale"]),required:z$1.boolean().optional(),options:z$1.array(z$1.object({id:z$1.string(),label:z$1.string()}).passthrough()).optional(),scaleMin:z$1.number().optional(),scaleMax:z$1.number().optional()}).passthrough()).min(1)}).passthrough();var fn=z$1.object({title:z$1.string().optional(),description:z$1.string().optional(),roomId:z$1.string().optional()}).passthrough(),yn=In;var hn={markdown:M,image:L,gallery:J,table:q,charts:N,mermaid:W,code:Q,embed:B,"pdf-viewer":H,"excel-viewer":U,"stat-cards":E,timeline:V,"json-viewer":G,"json-list":Z,links:K,"qr-code":an,"social-handles":sn,steps:$,trace:F,plan:Y,notes:D,"csv-viewer":X,"user-story":nn,chat:en,intro:tn,mastra:yn,"text-media":on,"business-card":rn,video:z,audio:O,"file-upload":pn,"kanban-board":ln,checklist:gn,comparison:dn,calendar:un,roadmap:mn,"realtime-canvas":fn};function C(e){return hn[e]}function x(e){return u(C(e))}var On={table:qn};function T(e,t){let i=On[e];return i?i(t):t}function qn(e){if(!e||typeof e!="object")return e;let t=e;if(!Array.isArray(t.rows))return e;let i=new Set((t.columns??[]).map(r=>r?.id).filter(r=>!!r)),o=t.rows.map((r,a)=>{if(!r||typeof r!="object"||Array.isArray(r))return r;let p=r,c=String(p.id??`row-${a+1}`);if(p.cells&&typeof p.cells=="object"&&!Array.isArray(p.cells))return {...p,id:c,cells:p.cells};let y={};for(let[g,k]of Object.entries(p))g!=="id"&&(i.size===0||i.has(g))&&(y[g]=k);return {id:c,cells:y}});return {...t,rows:o}}var Nn={google:"@ai-sdk/google",anthropic:"@ai-sdk/anthropic",openai:"@ai-sdk/openai"},Pn={google:"GOOGLE_GENERATIVE_AI_API_KEY",anthropic:"ANTHROPIC_API_KEY",openai:"OPENAI_API_KEY"};async function Bn(e){let t=Nn[e];try{let i=await import(t);return e==="google"?o=>i.createGoogleGenerativeAI(o):e==="anthropic"?o=>i.createAnthropic(o):o=>i.createOpenAI(o)}catch{throw new Error(`Missing optional dependency "${t}". Install it to use provider "${e}" (npm install ${t} ai zod).`)}}function Cn(){let e=[process.env.GOOGLE_GENERATIVE_AI_API_KEY,process.env.GOOGLE_API_KEY].map(i=>i?.trim()).filter(i=>!!i);if(!e.length)return;let t=e.find(i=>i.startsWith("AIzaSy")&&i.length===39);return t||e.sort((i,o)=>o.length-i.length)[0]}async function _(e){let t=e.apiKey??(e.provider==="google"?Cn():process.env[Pn[e.provider]]);if(!t){let o="GOOGLE_GENERATIVE_AI_API_KEY or GOOGLE_API_KEY";throw new Error(`No API key for provider "${e.provider}". Pass llm.apiKey or set ${e.provider==="google"?o:Pn[e.provider]}.`)}return (await Bn(e.provider))({apiKey:t})(e.model)}var b=class extends Error{constructor(t,i,o){super(i),this.name="PinConfigMaterializeError",this.pinType=t,this.zodError=o;}};function Un(e){if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Vn(e,t){if(t)return t;let i=d[e].join(", ");return [`You convert arbitrary user text or JSON into a valid Pindown pin_config for pin_type "${e}".`,`Only output top-level pin_config fields for this type: ${i}.`,"Map user data faithfully. Invent stable string ids where needed (columns, rows, cards, etc.).","Where a field is a key-value map, output it as [{ key, value }, ...] (one entry per key).","Do not include metadata (title, tags) \u2014 only pin_config shape."].join(" ")}var Gn=generateObject;async function I(e,t,i,o){let r=C(t),a=x(t),p=await _(i),c=j(t),y=Un(e),{object:g}=await Gn({model:p,schema:a,temperature:o?.temperature??0,maxRetries:o?.maxRetries??2,system:Vn(t,o?.system),prompt:[`Pin type: ${t}`,"",c,"","User input:",y].join(`
|
|
8
|
+
`)}),k=m(g,r),kn=T(t,k),h=r.safeParse(kn);if(!h.success)throw new b(t,`LLM output failed validation for pin_type "${t}": ${h.error.message}`,h.error);return h.data}function Zn(e,t,i){let o={...i};for(let r of d[e]){let a=i[r],p=t[r];o[r]=a!==void 0?a:p;}return o}function Kn(e,t,i){let o={...i??{}};for(let r of d[e]){let a=i?i[r]:void 0,p=t[r];a!==void 0?o[r]=a:p!==void 0&&(o[r]=p);}return o}var f=class{constructor(t,i,o,r){this.input=t;this.pinType=i;this.llm=o;this.options=r;}using(t){return this.client=t,this}with(t){return this.using(t)}async materialize(){return this.materializedPromise||(this.materializedPromise=I(this.input,this.pinType,this.llm,this.options)),this.materializedPromise}async createPin(t,i){let o=i??this.requireClient(),r=await this.materialize();return o.pins.createPin(this.pinType,Zn(this.pinType,r,t))}async updatePin(t,i,o){let r=o??this.requireClient(),a=await this.materialize();return r.pins.updatePin(t,this.pinType,Kn(this.pinType,a,i))}requireClient(){if(!this.client)throw new Error("Pindown client required. Call .using(client) first or pass client as the last argument.");return this.client}};function $n(e){for(let t of P){let i=S(t),o=`create${i}`,r=`update${i}`;e[o]=function(a,p){if(this.pinType!==t)throw new Error(`${o}() requires pin type "${t}", got "${this.pinType}"`);return this.createPin(a,p)},e[r]=function(a,p,c){if(this.pinType!==t)throw new Error(`${r}() requires pin type "${t}", got "${this.pinType}"`);return this.updatePin(a,p,c)};}}$n(f.prototype);function bn(e,t,i,o){return new f(e,t,i,o)}var Fn=bn;export{hn as PIN_CONFIG_ZOD_SCHEMAS,b as PinConfigMaterializeError,f as PinConfigPipe,T as canonicalizePinConfigForApi,x as getLlmPinConfigZodSchema,C as getPinConfigZodSchema,I as materializePinConfig,m as normalizeLlmPinConfigOutput,Fn as pipePinConfig,Cn as resolveGoogleApiKey,_ as resolveLanguageModel,bn as toConfig,u as toLlmPinConfigSchema};//# sourceMappingURL=index.js.map
|
|
9
|
+
//# sourceMappingURL=index.js.map
|