@pindownai/client-js 1.3.1 → 1.3.3
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 +18 -5
- package/dist/index.cjs +7 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +138 -4
- package/dist/index.d.ts +138 -4
- package/dist/index.js +7 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ Requires a **Workspace** plan API key (`pk_…`).
|
|
|
6
6
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
9
|
-
- Typed **`pin_type` + `pin_config`** for all
|
|
9
|
+
- Typed **`pin_type` + `pin_config`** for all 37 pin shapes
|
|
10
10
|
- Full CRUD + batch + share on `/v1/pins`
|
|
11
11
|
- ESM + CJS, zero runtime dependencies (native `fetch`)
|
|
12
12
|
|
|
@@ -36,10 +36,8 @@ const pin = await client.pins.get(created.id)
|
|
|
36
36
|
const content = (pin.metadata?.pin_config as MarkdownPinConfig | undefined)?.content
|
|
37
37
|
|
|
38
38
|
await client.pins.update(created.id, {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
pin_config: { content: '# Updated body' },
|
|
42
|
-
},
|
|
39
|
+
pin_config: { content: '# Updated body' },
|
|
40
|
+
metadata: { title: 'My doc (updated)' },
|
|
43
41
|
})
|
|
44
42
|
|
|
45
43
|
await client.pins.delete(created.id)
|
|
@@ -64,6 +62,10 @@ Product types: `PRODUCT_PIN_TYPES` (same as `ALL_PIN_TYPES`)
|
|
|
64
62
|
|
|
65
63
|
## Helpers
|
|
66
64
|
|
|
65
|
+
Use either:
|
|
66
|
+
- `createPin(pinType, input)` / `updatePin(pinId, pinType, input)` for every type, or
|
|
67
|
+
- generated named helpers: `createMarkdown`, `updateMarkdown`, `createTable`, `updateTable`, `createTimeline`, etc.
|
|
68
|
+
|
|
67
69
|
```typescript
|
|
68
70
|
await client.pins.createMarkdown({
|
|
69
71
|
title: 'Notes',
|
|
@@ -87,6 +89,17 @@ await client.pins.createEmbed({
|
|
|
87
89
|
url: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ',
|
|
88
90
|
type: 'youtube',
|
|
89
91
|
})
|
|
92
|
+
|
|
93
|
+
// Generic helper for any pin_type
|
|
94
|
+
await client.pins.createPin('timeline', {
|
|
95
|
+
title: 'Roadmap timeline',
|
|
96
|
+
items: [{ id: 'm1', title: 'Milestone 1' }],
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
// Generated update helper per type
|
|
100
|
+
await client.pins.updateMarkdown('p-abc123', {
|
|
101
|
+
content: '# Updated via updateMarkdown helper',
|
|
102
|
+
})
|
|
90
103
|
```
|
|
91
104
|
|
|
92
105
|
## Pins API surface
|
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
'use strict';var C=class{constructor(e){this.client=e;}async create(e){return this.client.request("POST","/pins",e)}async get(e){return this.client.request("GET",`/pins/${e}`)}async list(e){let
|
|
2
|
-
|
|
1
|
+
'use strict';var C=["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"];[...C];var S={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 v(t){return t.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join("")}function T(t,e){let i=S[t],n={};for(let a of i)a in e&&e[a]!==void 0&&(n[a]=e[a]);return n}function k(t,e){let n=T(t,e),a={title:e.title,tags:e.tags,description:e.description,allow_edit:e.allow_edit,require_sign_in:e.require_sign_in,allow_comments:e.allow_comments};return {pin_type:t,pin_config:n,pin_layout:e.pin_layout,is_public:e.is_public,allow_edit:e.allow_edit,require_sign_in:e.require_sign_in,allow_comments:e.allow_comments,pending_invites:e.pending_invites,metadata:a}}function b(t,e){let n=T(t,e),a=Object.keys(n).length>0,o={...e.metadata??{}};e.title!==void 0&&(o.title=e.title),e.tags!==void 0&&(o.tags=e.tags),e.description!==void 0&&(o.description=e.description);let s=Object.keys(o).length>0;return {...a?{pin_config:n}:{},pin_layout:e.pin_layout,is_public:e.is_public,...s?{metadata:o}:{}}}function x(t){for(let e of C){let i=v(e);t.prototype[`create${i}`]=function(n){return this.createPin(e,n)},t.prototype[`update${i}`]=function(n,a){return this.updatePin(n,e,a)};}}var y=class{constructor(e){this.client=e;}async create(e){return this.client.request("POST","/pins",e)}async createPin(e,i){return this.create(k(e,i))}async get(e){return this.client.request("GET",`/pins/${e}`)}async list(e){let i=new URLSearchParams;e?.limit&&i.append("limit",e.limit.toString()),e?.offset&&i.append("offset",e.offset.toString());let n=i.toString(),a=n?`/pins?${n}`:"/pins";return this.client.request("GET",a)}async update(e,i){return this.client.request("PUT",`/pins/${e}`,i)}async updatePin(e,i,n){return this.update(e,b(i,n))}async delete(e){return this.client.request("DELETE",`/pins/${e}`)}async share(e,i){return this.client.request("POST",`/pins/${e}/share`,i)}async batchGet(e){return this.client.request("POST","/pins/batch/get",{pin_ids:e})}async batchCreate(e){return this.client.request("POST","/pins/batch",{pins:e})}async batchUpdate(e){return this.client.request("PATCH","/pins/batch",{updates:e})}async batchDelete(e){return this.client.request("DELETE","/pins/batch",{pin_ids:e})}async createMarkdown(e){let{content:i,title:n,tags:a,description:o,pin_layout:s,is_public:r,allow_edit:l,require_sign_in:I,allow_comments:R,pending_invites:q}=e;return this.create({pin_type:"markdown",pin_config:{content:i},pin_layout:s,is_public:r,allow_edit:l,require_sign_in:I,allow_comments:R,pending_invites:q,metadata:{title:n,tags:a,description:o}})}async createStatCards(e){let{cards:i,title:n,tags:a,description:o,pin_layout:s,is_public:r}=e;return this.create({pin_type:"stat-cards",pin_config:{cards:i},pin_layout:s,is_public:r,metadata:{title:n,tags:a,description:o}})}async createTable(e){let{columns:i,rows:n,title:a,tags:o,description:s,pin_layout:r,is_public:l}=e;return this.create({pin_type:"table",pin_config:{columns:i,rows:n},pin_layout:r,is_public:l,metadata:{title:a,tags:o,description:s}})}async updateTable(e,i){return this.updatePin(e,"table",i)}async createEmbed(e){let{url:i,type:n,title:a,tags:o,description:s,pin_layout:r,is_public:l}=e;return this.create({pin_type:"embed",pin_config:{url:i,type:n},pin_layout:r,is_public:l,metadata:{title:a,tags:o,description:s}})}async createMarkdownLegacy(e,i){return this.createMarkdown({title:e,content:"",...i})}};x(y);var p=class extends Error{constructor(e){super(e),this.name="PindownError";}},g=class extends p{constructor(e="Authentication failed"){super(e),this.name="AuthenticationError";}},c=class extends p{constructor(e="Access forbidden"){super(e),this.name="ForbiddenError";}},u=class extends p{constructor(e){super(`${e} not found`),this.name="NotFoundError";}},P=class extends p{constructor(e,i){super(e),this.name="ValidationError",this.details=i;}},f=class extends p{constructor(e="Rate limit exceeded (429 RATE_LIMITED)"){super(e),this.name="RateLimitError";}},d=class extends p{constructor(e,i=500){super(e),this.name="ServerError",this.statusCode=i;}},m=class extends p{constructor(e="Network request failed"){super(e),this.name="NetworkError";}};var w=class{constructor(e){if(!e.apiKey)throw new Error("API key is required");this.config={apiKey:e.apiKey,baseURL:e.baseURL||"https://api.pindown.ai/v1",maxRetries:e.maxRetries??3,timeout:e.timeout??3e4},this.pins=new y(this);}async request(e,i,n){let a=`${this.config.baseURL}${i}`,o={Authorization:`Bearer ${this.config.apiKey}`};n&&(e==="POST"||e==="PUT"||e==="PATCH"||e==="DELETE")&&(o["Content-Type"]="application/json");let s={method:e,headers:o,signal:AbortSignal.timeout(this.config.timeout)};n&&(e==="POST"||e==="PUT"||e==="PATCH"||e==="DELETE")&&(s.body=JSON.stringify(n));try{let r=await fetch(a,s);return r.ok||await this.handleErrorResponse(r),(await r.json()).data}catch(r){throw r instanceof g||r instanceof c||r instanceof u||r instanceof P||r instanceof f||r instanceof d?r:r instanceof Error&&(r.name==="AbortError"||r.name==="TimeoutError")?new m("Request timeout"):new m(r instanceof Error?r.message:"Network request failed")}}async handleErrorResponse(e){let i;try{i=await e.json();}catch{i={message:e.statusText};}let n=i.error?.message||i.message||"Unknown error";switch(e.status){case 401:throw new g(n);case 403:throw new c(n);case 404:throw new u(n);case 400:case 422:throw new P(n,i.error?.details);case 429:throw new f(n);case 500:case 502:case 503:throw new d(n,e.status);default:throw new d(n,e.status)}}};var E={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}}]}}},_={table:E,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 h(t){return _[t]}function L(t){let e=h(t);return e?[`Pin type: ${e.pin_type}`,e.summary,"","Required pin_config fields:",...e.required_fields.map(n=>` - ${n}`),"","Optional pin_config fields:",...e.optional_fields.length?e.optional_fields.map(n=>` - ${n}`):[" (none documented)"],"","Field reference:",...e.fields.map(n=>` ${n.path} (${n.type}${n.required?", required":""}): ${n.description}`),"","Example update payload:",JSON.stringify(e.example_update,null,2)].join(`
|
|
6
|
+
`):[`No built-in hint for pin type "${t}".`,"Use CreatePinRequest<typeof pinType> / PinConfigByType[typeof pinType] in TypeScript,","or client.pins.create({ pin_type, pin_config, metadata }) with typed pin_config."].join(`
|
|
7
|
+
`)}exports.AuthenticationError=g;exports.ForbiddenError=c;exports.NetworkError=m;exports.NotFoundError=u;exports.PIN_CONFIG_HINTS=_;exports.PindownClient=w;exports.PindownError=p;exports.RateLimitError=f;exports.ServerError=d;exports.ValidationError=P;exports.formatPinConfigHint=L;exports.getPinConfigHint=h;//# sourceMappingURL=index.cjs.map
|
|
3
8
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/client/pins/index.ts","../src/errors/index.ts","../src/client/PindownClient.ts"],"names":["PinsMethods","client","request","pinId","options","params","query","endpoint","pinIds","pins","updates","input","content","title","tags","description","pin_layout","is_public","allow_edit","require_sign_in","allow_comments","pending_invites","cards","columns","rows","url","type","additionalMetadata","PindownError","message","AuthenticationError","ForbiddenError","NotFoundError","resource","ValidationError","details","RateLimitError","ServerError","statusCode","NetworkError","PindownClient","config","method","data","headers","requestOptions","response","error","errorData"],"mappings":"aAmBO,IAAMA,CAAAA,CAAN,KAAkB,CACvB,WAAA,CAAoBC,EAAuB,CAAvB,IAAA,CAAA,MAAA,CAAAA,EAAwB,CAG5C,MAAM,OAA4BC,CAAAA,CAA+C,CAC/E,OAAO,IAAA,CAAK,MAAA,CAAO,QAAgB,MAAA,CAAQ,OAAA,CAASA,CAAO,CAC7D,CAEA,MAAM,IAAqCC,CAAAA,CAAgC,CACzE,OAAO,IAAA,CAAK,MAAA,CAAO,QAAgB,KAAA,CAAO,CAAA,MAAA,EAASA,CAAK,CAAA,CAAE,CAC5D,CAEA,MAAM,IAAA,CAAKC,CAAAA,CAA4D,CACrE,IAAMC,CAAAA,CAAS,IAAI,eAAA,CACfD,CAAAA,EAAS,KAAA,EAAOC,CAAAA,CAAO,MAAA,CAAO,OAAA,CAASD,EAAQ,KAAA,CAAM,QAAA,EAAU,CAAA,CAC/DA,CAAAA,EAAS,QAAQC,CAAAA,CAAO,MAAA,CAAO,QAAA,CAAUD,CAAAA,CAAQ,MAAA,CAAO,QAAA,EAAU,CAAA,CAEtE,IAAME,EAAQD,CAAAA,CAAO,QAAA,GACfE,CAAAA,CAAWD,CAAAA,CAAQ,CAAA,MAAA,EAASA,CAAK,CAAA,CAAA,CAAK,OAAA,CAE5C,OAAO,IAAA,CAAK,MAAA,C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V,CAAAA,CAEXU,CAAAA,CAGJA,CAAAA,YAAiB,KAAA,GAAUA,CAAAA,CAAM,OAAS,YAAA,EAAgBA,CAAAA,CAAM,OAAS,cAAA,CAAA,CACrE,IAAIR,EAAa,iBAAiB,CAAA,CAGpC,IAAIA,CAAAA,CAAaQ,CAAAA,YAAiB,KAAA,CAAQA,EAAM,OAAA,CAAU,wBAAwB,CAC1F,CACF,CAEA,MAAc,mBAAA,CAAoBD,CAAAA,CAAoC,CACpE,IAAIE,CAAAA,CAEJ,GAAI,CACFA,CAAAA,CAAY,MAAMF,EAAS,IAAA,GAC7B,MAAQ,CACNE,CAAAA,CAAY,CAAE,OAAA,CAASF,CAAAA,CAAS,UAAW,EAC7C,CAEA,IAAMjB,EAAUmB,CAAAA,CAAU,KAAA,EAAO,SAAWA,CAAAA,CAAU,OAAA,EAAW,eAAA,CAEjE,OAAQF,CAAAA,CAAS,MAAA,EACf,KAAK,GAAA,CACH,MAAM,IAAIhB,CAAAA,CAAoBD,CAAO,CAAA,CACvC,KAAK,GAAA,CACH,MAAM,IAAIE,CAAAA,CAAeF,CAAO,CAAA,CAClC,SACE,MAAM,IAAIG,EAAcH,CAAO,CAAA,CACjC,KAAK,GAAA,CACL,KAAK,GAAA,CACH,MAAM,IAAIK,CAAAA,CAAgBL,EAASmB,CAAAA,CAAU,KAAA,EAAO,OAAO,CAAA,CAC7D,KAAK,GAAA,CACH,MAAM,IAAIZ,CAAAA,CAAeP,CAAO,CAAA,CAClC,SACA,KAAK,GAAA,CACL,KAAK,GAAA,CACH,MAAM,IAAIQ,CAAAA,CAAYR,CAAAA,CAASiB,CAAAA,CAAS,MAAM,CAAA,CAChD,QACE,MAAM,IAAIT,CAAAA,CAAYR,EAASiB,CAAAA,CAAS,MAAM,CAClD,CACF,CACF","file":"index.cjs","sourcesContent":["/**\n * Pins API Methods\n */\n\nimport type { PindownClient } from '../PindownClient'\nimport type {\n Pin,\n PinTypeId,\n CreatePinRequest,\n UpdatePinRequest,\n SharePinRequest,\n ListPinsOptions,\n CreateMarkdownPinInput,\n CreateStatCardsPinInput,\n CreateTablePinInput,\n CreateEmbedPinInput,\n} from '../../types/pins'\nimport type { PaginatedResponse } from '../../types/api'\n\nexport class PinsMethods {\n constructor(private client: PindownClient) {}\n\n /** Create a pin (typed via CreatePinRequest<T>) */\n async create<T extends PinTypeId>(request: CreatePinRequest<T>): Promise<Pin<T>> {\n return this.client.request<Pin<T>>('POST', '/pins', request)\n }\n\n async get<T extends PinTypeId = PinTypeId>(pinId: string): Promise<Pin<T>> {\n return this.client.request<Pin<T>>('GET', `/pins/${pinId}`)\n }\n\n async list(options?: ListPinsOptions): Promise<PaginatedResponse<Pin>> {\n const params = new URLSearchParams()\n if (options?.limit) params.append('limit', options.limit.toString())\n if (options?.offset) params.append('offset', options.offset.toString())\n\n const query = params.toString()\n const endpoint = query ? `/pins?${query}` : '/pins'\n\n return this.client.request<PaginatedResponse<Pin>>('GET', endpoint)\n }\n\n async update<T extends PinTypeId = PinTypeId>(pinId: string, request: UpdatePinRequest<T>): Promise<Pin<T>> {\n return this.client.request<Pin<T>>('PUT', `/pins/${pinId}`, request)\n }\n\n async delete(pinId: string): Promise<void> {\n return this.client.request<void>('DELETE', `/pins/${pinId}`)\n }\n\n async share(pinId: string, request: SharePinRequest): Promise<Pin> {\n return this.client.request<Pin>('POST', `/pins/${pinId}/share`, request)\n }\n\n async batchGet(pinIds: string[]): Promise<{\n found: Pin[]\n not_found: string[]\n permission_denied: string[]\n }> {\n return this.client.request('POST', '/pins/batch/get', { pin_ids: pinIds })\n }\n\n async batchCreate(pins: CreatePinRequest[]): Promise<{\n created: Array<{ id: string; index: number; created_at: number }>\n failed: Array<{ index: number; error: string }>\n }> {\n return this.client.request('POST', '/pins/batch', { pins })\n }\n\n async batchUpdate(updates: Array<{ id: string } & UpdatePinRequest>): Promise<{\n updated: string[]\n failed: Array<{ id: string; error: string }>\n updated_at: number\n }> {\n return this.client.request('PATCH', '/pins/batch', { updates })\n }\n\n async batchDelete(pinIds: string[]): Promise<{\n deleted: string[]\n failed: Array<{ id: string; error: string }>\n }> {\n return this.client.request('DELETE', '/pins/batch', { pin_ids: pinIds })\n }\n\n /** Create a markdown pin with pin_config.content (seeds Yjs on the server). */\n async createMarkdown(input: CreateMarkdownPinInput): Promise<Pin<'markdown'>> {\n const { content, title, tags, description, pin_layout, is_public, allow_edit, require_sign_in, allow_comments, pending_invites } = input\n return this.create({\n pin_type: 'markdown',\n pin_config: { content },\n pin_layout,\n is_public,\n allow_edit,\n require_sign_in,\n allow_comments,\n pending_invites,\n metadata: { title, tags, description },\n })\n }\n\n async createStatCards(input: CreateStatCardsPinInput): Promise<Pin<'stat-cards'>> {\n const { cards, title, tags, description, pin_layout, is_public } = input\n return this.create({\n pin_type: 'stat-cards',\n pin_config: { cards },\n pin_layout,\n is_public,\n metadata: { title, tags, description },\n })\n }\n\n async createTable(input: CreateTablePinInput): Promise<Pin<'table'>> {\n const { columns, rows, title, tags, description, pin_layout, is_public } = input\n return this.create({\n pin_type: 'table',\n pin_config: { columns, rows },\n pin_layout,\n is_public,\n metadata: { title, tags, description },\n })\n }\n\n async createEmbed(input: CreateEmbedPinInput): Promise<Pin<'embed'>> {\n const { url, type, title, tags, description, pin_layout, is_public } = input\n return this.create({\n pin_type: 'embed',\n pin_config: { url, type },\n pin_layout,\n is_public,\n metadata: { title, tags, description },\n })\n }\n\n /**\n * @deprecated Use createMarkdown({ title, content, ... }) — old signature ignored content in title\n */\n async createMarkdownLegacy(title: string, additionalMetadata?: Record<string, unknown>): Promise<Pin<'markdown'>> {\n return this.createMarkdown({\n title,\n content: '',\n ...(additionalMetadata as Partial<CreateMarkdownPinInput>),\n })\n }\n}\n","/**\n * Error classes for the v1 Pins API client\n */\n\nexport class PindownError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'PindownError'\n }\n}\n\nexport class AuthenticationError extends PindownError {\n constructor(message: string = 'Authentication failed') {\n super(message)\n this.name = 'AuthenticationError'\n }\n}\n\nexport class ForbiddenError extends PindownError {\n constructor(message: string = 'Access forbidden') {\n super(message)\n this.name = 'ForbiddenError'\n }\n}\n\nexport class NotFoundError extends PindownError {\n constructor(resource: string) {\n super(`${resource} not found`)\n this.name = 'NotFoundError'\n }\n}\n\nexport class ValidationError extends PindownError {\n public details?: unknown\n\n constructor(message: string, details?: unknown) {\n super(message)\n this.name = 'ValidationError'\n this.details = details\n }\n}\n\nexport class RateLimitError extends PindownError {\n constructor(message: string = 'Rate limit exceeded (429 RATE_LIMITED)') {\n super(message)\n this.name = 'RateLimitError'\n }\n}\n\nexport class ServerError extends PindownError {\n public statusCode: number\n\n constructor(message: string, statusCode: number = 500) {\n super(message)\n this.name = 'ServerError'\n this.statusCode = statusCode\n }\n}\n\nexport class NetworkError extends PindownError {\n constructor(message: string = 'Network request failed') {\n super(message)\n this.name = 'NetworkError'\n }\n}\n","/**\n * Pindown API Client — v1 Pins API only\n */\n\nimport { PinsMethods } from './pins'\nimport type { PindownConfig } from '../types/config'\nimport {\n AuthenticationError,\n ForbiddenError,\n NotFoundError,\n ValidationError,\n RateLimitError,\n ServerError,\n NetworkError,\n} from '../errors'\n\nexport class PindownClient {\n private config: Required<Omit<PindownConfig, 'baseURL'>> & { baseURL: string }\n\n public readonly pins: PinsMethods\n\n constructor(config: PindownConfig) {\n if (!config.apiKey) {\n throw new Error('API key is required')\n }\n\n this.config = {\n apiKey: config.apiKey,\n baseURL: config.baseURL || 'https://api.pindown.ai/v1',\n maxRetries: config.maxRetries ?? 3,\n timeout: config.timeout ?? 30000,\n }\n\n this.pins = new PinsMethods(this)\n }\n\n async request<T = unknown>(method: string, endpoint: string, data?: unknown): Promise<T> {\n const url = `${this.config.baseURL}${endpoint}`\n const headers: Record<string, string> = {\n Authorization: `Bearer ${this.config.apiKey}`,\n }\n\n if (data && (method === 'POST' || method === 'PUT' || method === 'PATCH' || method === 'DELETE')) {\n headers['Content-Type'] = 'application/json'\n }\n\n const requestOptions: RequestInit = {\n method,\n headers,\n signal: AbortSignal.timeout(this.config.timeout),\n }\n\n if (data && (method === 'POST' || method === 'PUT' || method === 'PATCH' || method === 'DELETE')) {\n requestOptions.body = JSON.stringify(data)\n }\n\n try {\n const response = await fetch(url, requestOptions)\n\n if (!response.ok) {\n await this.handleErrorResponse(response)\n }\n\n const result = await response.json()\n return result.data as T\n } catch (error: unknown) {\n if (\n error instanceof AuthenticationError ||\n error instanceof ForbiddenError ||\n error instanceof NotFoundError ||\n error instanceof ValidationError ||\n error instanceof RateLimitError ||\n error instanceof ServerError\n ) {\n throw error\n }\n\n if (error instanceof Error && (error.name === 'AbortError' || error.name === 'TimeoutError')) {\n throw new NetworkError('Request timeout')\n }\n\n throw new NetworkError(error instanceof Error ? error.message : 'Network request failed')\n }\n }\n\n private async handleErrorResponse(response: Response): Promise<never> {\n let errorData: { error?: { code?: string; message?: string; details?: unknown }; message?: string }\n\n try {\n errorData = await response.json()\n } catch {\n errorData = { message: response.statusText }\n }\n\n const message = errorData.error?.message || errorData.message || 'Unknown error'\n\n switch (response.status) {\n case 401:\n throw new AuthenticationError(message)\n case 403:\n throw new ForbiddenError(message)\n case 404:\n throw new NotFoundError(message)\n case 400:\n case 422:\n throw new ValidationError(message, errorData.error?.details)\n case 429:\n throw new RateLimitError(message)\n case 500:\n case 502:\n case 503:\n throw new ServerError(message, response.status)\n default:\n throw new ServerError(message, response.status)\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/types/pins.ts","../src/client/pins/pin-helper-core.ts","../src/client/pins/index.ts","../src/errors/index.ts","../src/client/PindownClient.ts","../src/pin-config-hints.ts"],"names":["PRODUCT_PIN_TYPES","PIN_CONFIG_FIELDS","pinTypeToMethodSuffix","pinType","part","pickPinConfig","input","fields","pin_config","key","toCreatePinRequest","metadata","toUpdatePinRequest","hasPinConfig","hasMetadata","attachNamedPinHelpers","ctor","suffix","pinId","PinsMethods","client","request","options","params","query","endpoint","pinIds","pins","updates","content","title","tags","description","pin_layout","is_public","allow_edit","require_sign_in","allow_comments","pending_invites","cards","columns","rows","url","type","additionalMetadata","PindownError","message","AuthenticationError","ForbiddenError","NotFoundError","resource","ValidationError","details","RateLimitError","ServerError","statusCode","NetworkError","PindownClient","config","method","data","headers","requestOptions","response","error","errorData","TABLE_HINT","PIN_CONFIG_HINTS","getPinConfigHint","formatPinConfigHint","hint","f"],"mappings":"aAMO,IAAMA,CAAAA,CAAoB,CAC/B,UAAA,CACA,OAAA,CACA,UACA,OAAA,CACA,QAAA,CACA,UACA,MAAA,CACA,OAAA,CACA,aACA,cAAA,CACA,YAAA,CACA,WACA,aAAA,CACA,WAAA,CACA,QACA,SAAA,CACA,gBAAA,CACA,QACA,OAAA,CACA,MAAA,CACA,QACA,YAAA,CACA,YAAA,CACA,OACA,OAAA,CACA,QAAA,CACA,aACA,eAAA,CACA,OAAA,CACA,QACA,aAAA,CACA,cAAA,CACA,YACA,YAAA,CACA,UAAA,CACA,UACA,iBACF,CAAA,CAE6B,CAAC,GAAGA,CAAiB,EClC3C,IAAMC,EAAmG,CAC9G,QAAA,CAAU,CAAC,SAAA,CAAW,eAAe,EACrC,KAAA,CAAO,CAAC,MAAO,SAAA,CAAW,KAAK,EAC/B,OAAA,CAAS,CAAC,QAAQ,CAAA,CAClB,KAAA,CAAO,CAAC,SAAA,CAAW,MAAM,EACzB,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,MAAO,CAAC,KAAA,CAAO,MAAM,CAAA,CACrB,YAAA,CAAc,CAAC,KAAK,CAAA,CACpB,cAAA,CAAgB,CAAC,OAAO,CAAA,CACxB,aAAc,CAAC,OAAO,EACtB,QAAA,CAAU,CAAC,OAAQ,OAAO,CAAA,CAC1B,cAAe,CAAC,MAAA,CAAQ,aAAc,OAA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MA,CAAAA,CAAE,WAAW,CAAA,CACnF,EACA,EAAA,CACA,yBAAA,CACA,IAAA,CAAK,SAAA,CAAUD,EAAK,cAAA,CAAgB,IAAA,CAAM,CAAC,CAC7C,EACa,IAAA,CAAK;AAAA,CAAI,CAAA,CAzBb,CACL,CAAA,+BAAA,EAAkCnE,CAAO,KACzC,uFAAA,CACA,kFACF,EAAE,IAAA,CAAK;AAAA,CAAI,CAsBf","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 ...(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 * Pins API Methods\n */\n\nimport type { PindownClient } from '../PindownClient'\nimport type {\n Pin,\n PinTypeId,\n CreatePinRequest,\n CreatePinHelperInput,\n UpdatePinRequest,\n UpdatePinHelperInput,\n SharePinRequest,\n ListPinsOptions,\n CreateMarkdownPinInput,\n CreateStatCardsPinInput,\n CreateTablePinInput,\n UpdateTablePinInput,\n CreateEmbedPinInput,\n} from '../../types/pins'\nimport type { PaginatedResponse } from '../../types/api'\nimport {\n attachNamedPinHelpers,\n toCreatePinRequest,\n toUpdatePinRequest,\n} from './pin-helper-core'\n\nexport class PinsMethods {\n constructor(private client: PindownClient) {}\n\n /** Create a pin (typed via CreatePinRequest<T>) */\n async create<T extends PinTypeId>(request: CreatePinRequest<T>): Promise<Pin<T>> {\n return this.client.request<Pin<T>>('POST', '/pins', request)\n }\n\n /** Create helper for any pin type via flat typed input. */\n async createPin<T extends PinTypeId>(\n pinType: T,\n input: CreatePinHelperInput<T>,\n ): Promise<Pin<T>> {\n return this.create(toCreatePinRequest(pinType, input))\n }\n\n async get<T extends PinTypeId = PinTypeId>(pinId: string): Promise<Pin<T>> {\n return this.client.request<Pin<T>>('GET', `/pins/${pinId}`)\n }\n\n async list(options?: ListPinsOptions): Promise<PaginatedResponse<Pin>> {\n const params = new URLSearchParams()\n if (options?.limit) params.append('limit', options.limit.toString())\n if (options?.offset) params.append('offset', options.offset.toString())\n\n const query = params.toString()\n const endpoint = query ? `/pins?${query}` : '/pins'\n\n return this.client.request<PaginatedResponse<Pin>>('GET', endpoint)\n }\n\n async update<T extends PinTypeId = PinTypeId>(pinId: string, request: UpdatePinRequest<T>): Promise<Pin<T>> {\n return this.client.request<Pin<T>>('PUT', `/pins/${pinId}`, request)\n }\n\n /** Update helper for any pin type via flat typed input. */\n async updatePin<T extends PinTypeId>(\n pinId: string,\n pinType: T,\n input: UpdatePinHelperInput<T>,\n ): Promise<Pin<T>> {\n return this.update(pinId, toUpdatePinRequest(pinType, input))\n }\n\n async delete(pinId: string): Promise<void> {\n return this.client.request<void>('DELETE', `/pins/${pinId}`)\n }\n\n async share(pinId: string, request: SharePinRequest): Promise<Pin> {\n return this.client.request<Pin>('POST', `/pins/${pinId}/share`, request)\n }\n\n async batchGet(pinIds: string[]): Promise<{\n found: Pin[]\n not_found: string[]\n permission_denied: string[]\n }> {\n return this.client.request('POST', '/pins/batch/get', { pin_ids: pinIds })\n }\n\n async batchCreate(pins: CreatePinRequest[]): Promise<{\n created: Array<{ id: string; index: number; created_at: number }>\n failed: Array<{ index: number; error: string }>\n }> {\n return this.client.request('POST', '/pins/batch', { pins })\n }\n\n async batchUpdate(updates: Array<{ id: string } & UpdatePinRequest>): Promise<{\n updated: string[]\n failed: Array<{ id: string; error: string }>\n updated_at: number\n }> {\n return this.client.request('PATCH', '/pins/batch', { updates })\n }\n\n async batchDelete(pinIds: string[]): Promise<{\n deleted: string[]\n failed: Array<{ id: string; error: string }>\n }> {\n return this.client.request('DELETE', '/pins/batch', { pin_ids: pinIds })\n }\n\n /** Create a markdown pin with pin_config.content (seeds Yjs on the server). */\n async createMarkdown(input: CreateMarkdownPinInput): Promise<Pin<'markdown'>> {\n const { content, title, tags, description, pin_layout, is_public, allow_edit, require_sign_in, allow_comments, pending_invites } = input\n return this.create({\n pin_type: 'markdown',\n pin_config: { content },\n pin_layout,\n is_public,\n allow_edit,\n require_sign_in,\n allow_comments,\n pending_invites,\n metadata: { title, tags, description },\n })\n }\n\n async createStatCards(input: CreateStatCardsPinInput): Promise<Pin<'stat-cards'>> {\n const { cards, title, tags, description, pin_layout, is_public } = input\n return this.create({\n pin_type: 'stat-cards',\n pin_config: { cards },\n pin_layout,\n is_public,\n metadata: { title, tags, description },\n })\n }\n\n async createTable(input: CreateTablePinInput): Promise<Pin<'table'>> {\n const { columns, rows, title, tags, description, pin_layout, is_public } = input\n return this.create({\n pin_type: 'table',\n pin_config: { columns, rows },\n pin_layout,\n is_public,\n metadata: { title, tags, description },\n })\n }\n\n /** Partial table pin_config update with typed columns/rows. */\n async updateTable(pinId: string, input: UpdateTablePinInput): Promise<Pin<'table'>> {\n return this.updatePin(pinId, 'table', input)\n }\n\n async createEmbed(input: CreateEmbedPinInput): Promise<Pin<'embed'>> {\n const { url, type, title, tags, description, pin_layout, is_public } = input\n return this.create({\n pin_type: 'embed',\n pin_config: { url, type },\n pin_layout,\n is_public,\n metadata: { title, tags, description },\n })\n }\n\n /**\n * @deprecated Use createMarkdown({ title, content, ... }) — old signature ignored content in title\n */\n async createMarkdownLegacy(title: string, additionalMetadata?: Record<string, unknown>): Promise<Pin<'markdown'>> {\n return this.createMarkdown({\n title,\n content: '',\n ...(additionalMetadata as Partial<CreateMarkdownPinInput>),\n })\n }\n}\n\nattachNamedPinHelpers(PinsMethods as unknown as { prototype: Record<string, unknown> })\n","/**\n * Error classes for the v1 Pins API client\n */\n\nexport class PindownError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'PindownError'\n }\n}\n\nexport class AuthenticationError extends PindownError {\n constructor(message: string = 'Authentication failed') {\n super(message)\n this.name = 'AuthenticationError'\n }\n}\n\nexport class ForbiddenError extends PindownError {\n constructor(message: string = 'Access forbidden') {\n super(message)\n this.name = 'ForbiddenError'\n }\n}\n\nexport class NotFoundError extends PindownError {\n constructor(resource: string) {\n super(`${resource} not found`)\n this.name = 'NotFoundError'\n }\n}\n\nexport class ValidationError extends PindownError {\n public details?: unknown\n\n constructor(message: string, details?: unknown) {\n super(message)\n this.name = 'ValidationError'\n this.details = details\n }\n}\n\nexport class RateLimitError extends PindownError {\n constructor(message: string = 'Rate limit exceeded (429 RATE_LIMITED)') {\n super(message)\n this.name = 'RateLimitError'\n }\n}\n\nexport class ServerError extends PindownError {\n public statusCode: number\n\n constructor(message: string, statusCode: number = 500) {\n super(message)\n this.name = 'ServerError'\n this.statusCode = statusCode\n }\n}\n\nexport class NetworkError extends PindownError {\n constructor(message: string = 'Network request failed') {\n super(message)\n this.name = 'NetworkError'\n }\n}\n","/**\n * Pindown API Client — v1 Pins API only\n */\n\nimport { PinsMethods } from './pins'\nimport type { PindownConfig } from '../types/config'\nimport {\n AuthenticationError,\n ForbiddenError,\n NotFoundError,\n ValidationError,\n RateLimitError,\n ServerError,\n NetworkError,\n} from '../errors'\n\nexport class PindownClient {\n private config: Required<Omit<PindownConfig, 'baseURL'>> & { baseURL: string }\n\n public readonly pins: PinsMethods\n\n constructor(config: PindownConfig) {\n if (!config.apiKey) {\n throw new Error('API key is required')\n }\n\n this.config = {\n apiKey: config.apiKey,\n baseURL: config.baseURL || 'https://api.pindown.ai/v1',\n maxRetries: config.maxRetries ?? 3,\n timeout: config.timeout ?? 30000,\n }\n\n this.pins = new PinsMethods(this)\n }\n\n async request<T = unknown>(method: string, endpoint: string, data?: unknown): Promise<T> {\n const url = `${this.config.baseURL}${endpoint}`\n const headers: Record<string, string> = {\n Authorization: `Bearer ${this.config.apiKey}`,\n }\n\n if (data && (method === 'POST' || method === 'PUT' || method === 'PATCH' || method === 'DELETE')) {\n headers['Content-Type'] = 'application/json'\n }\n\n const requestOptions: RequestInit = {\n method,\n headers,\n signal: AbortSignal.timeout(this.config.timeout),\n }\n\n if (data && (method === 'POST' || method === 'PUT' || method === 'PATCH' || method === 'DELETE')) {\n requestOptions.body = JSON.stringify(data)\n }\n\n try {\n const response = await fetch(url, requestOptions)\n\n if (!response.ok) {\n await this.handleErrorResponse(response)\n }\n\n const result = await response.json()\n return result.data as T\n } catch (error: unknown) {\n if (\n error instanceof AuthenticationError ||\n error instanceof ForbiddenError ||\n error instanceof NotFoundError ||\n error instanceof ValidationError ||\n error instanceof RateLimitError ||\n error instanceof ServerError\n ) {\n throw error\n }\n\n if (error instanceof Error && (error.name === 'AbortError' || error.name === 'TimeoutError')) {\n throw new NetworkError('Request timeout')\n }\n\n throw new NetworkError(error instanceof Error ? error.message : 'Network request failed')\n }\n }\n\n private async handleErrorResponse(response: Response): Promise<never> {\n let errorData: { error?: { code?: string; message?: string; details?: unknown }; message?: string }\n\n try {\n errorData = await response.json()\n } catch {\n errorData = { message: response.statusText }\n }\n\n const message = errorData.error?.message || errorData.message || 'Unknown error'\n\n switch (response.status) {\n case 401:\n throw new AuthenticationError(message)\n case 403:\n throw new ForbiddenError(message)\n case 404:\n throw new NotFoundError(message)\n case 400:\n case 422:\n throw new ValidationError(message, errorData.error?.details)\n case 429:\n throw new RateLimitError(message)\n case 500:\n case 502:\n case 503:\n throw new ServerError(message, response.status)\n default:\n throw new ServerError(message, response.status)\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"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* Aligned with backend-api/src/lib/pin-types.ts + pin-config-schemas.ts.
|
|
4
4
|
* Import per-type *PinConfig interfaces for typed CRUD payloads.
|
|
5
5
|
*/
|
|
6
|
-
declare const PRODUCT_PIN_TYPES: readonly ["markdown", "image", "gallery", "table", "charts", "mermaid", "embed", "pdf-viewer", "excel-viewer", "stat-cards", "timeline", "json-viewer", "json-list", "links", "qr-code", "steps", "trace", "plan", "notes", "csv-viewer", "user-story", "chat", "intro", "mastra", "text-media", "business-card", "video", "file-upload", "kanban-board", "checklist", "calendar", "roadmap", "realtime-canvas"];
|
|
7
|
-
declare const ALL_PIN_TYPES: readonly ["markdown", "image", "gallery", "table", "charts", "mermaid", "embed", "pdf-viewer", "excel-viewer", "stat-cards", "timeline", "json-viewer", "json-list", "links", "qr-code", "steps", "trace", "plan", "notes", "csv-viewer", "user-story", "chat", "intro", "mastra", "text-media", "business-card", "video", "file-upload", "kanban-board", "checklist", "calendar", "roadmap", "realtime-canvas"];
|
|
6
|
+
declare const PRODUCT_PIN_TYPES: readonly ["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"];
|
|
7
|
+
declare const ALL_PIN_TYPES: readonly ["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"];
|
|
8
8
|
type ProductPinTypeId = (typeof PRODUCT_PIN_TYPES)[number];
|
|
9
9
|
type PinTypeId = (typeof ALL_PIN_TYPES)[number];
|
|
10
10
|
type PinLayout = '1x1' | '1x2' | '2x1' | '2x2' | '3x1' | '3x2' | '3x3' | '4x4';
|
|
@@ -87,8 +87,15 @@ interface ChartsPinConfig {
|
|
|
87
87
|
[key: string]: unknown;
|
|
88
88
|
}
|
|
89
89
|
interface MermaidPinConfig {
|
|
90
|
-
code?: string;
|
|
91
90
|
diagram?: string;
|
|
91
|
+
code?: string;
|
|
92
|
+
title?: string;
|
|
93
|
+
[key: string]: unknown;
|
|
94
|
+
}
|
|
95
|
+
interface CodePinConfig {
|
|
96
|
+
code: string;
|
|
97
|
+
language?: string;
|
|
98
|
+
filename?: string;
|
|
92
99
|
title?: string;
|
|
93
100
|
[key: string]: unknown;
|
|
94
101
|
}
|
|
@@ -144,6 +151,20 @@ interface QrCodePinConfig {
|
|
|
144
151
|
label?: string;
|
|
145
152
|
[key: string]: unknown;
|
|
146
153
|
}
|
|
154
|
+
interface SocialHandleItem {
|
|
155
|
+
id?: string;
|
|
156
|
+
platform: string;
|
|
157
|
+
url: string;
|
|
158
|
+
label?: string;
|
|
159
|
+
[key: string]: unknown;
|
|
160
|
+
}
|
|
161
|
+
interface SocialHandlesPinConfig {
|
|
162
|
+
title?: string;
|
|
163
|
+
showLabels?: boolean;
|
|
164
|
+
iconSize?: number;
|
|
165
|
+
handles?: SocialHandleItem[];
|
|
166
|
+
[key: string]: unknown;
|
|
167
|
+
}
|
|
147
168
|
interface StepsPinConfig {
|
|
148
169
|
steps: StepItem[];
|
|
149
170
|
[key: string]: unknown;
|
|
@@ -246,6 +267,10 @@ interface UserStoryPinConfig {
|
|
|
246
267
|
interface ChatPinConfig {
|
|
247
268
|
title?: string;
|
|
248
269
|
placeholder?: string;
|
|
270
|
+
/** Pin this discussion thread is about (commentary / feedback). */
|
|
271
|
+
linked_pin_id?: string;
|
|
272
|
+
/** Cached title for display without fetching the linked pin. */
|
|
273
|
+
linked_pin_title?: string;
|
|
249
274
|
[key: string]: unknown;
|
|
250
275
|
}
|
|
251
276
|
interface IntroPinConfig {
|
|
@@ -285,6 +310,24 @@ interface VideoPinConfig {
|
|
|
285
310
|
size?: number;
|
|
286
311
|
[key: string]: unknown;
|
|
287
312
|
}
|
|
313
|
+
interface AudioPinTrack {
|
|
314
|
+
url: string;
|
|
315
|
+
fileId?: string;
|
|
316
|
+
fileName?: string;
|
|
317
|
+
mimeType?: 'audio/mpeg' | 'audio/wav' | 'audio/x-wav' | string;
|
|
318
|
+
size?: number;
|
|
319
|
+
[key: string]: unknown;
|
|
320
|
+
}
|
|
321
|
+
interface AudioPinConfig {
|
|
322
|
+
url?: string;
|
|
323
|
+
fileId?: string;
|
|
324
|
+
fileName?: string;
|
|
325
|
+
mimeType?: 'audio/mpeg' | 'audio/wav' | 'audio/x-wav' | string;
|
|
326
|
+
caption?: string;
|
|
327
|
+
size?: number;
|
|
328
|
+
tracks?: AudioPinTrack[];
|
|
329
|
+
[key: string]: unknown;
|
|
330
|
+
}
|
|
288
331
|
interface TextMediaPinConfig {
|
|
289
332
|
title?: string;
|
|
290
333
|
text?: string;
|
|
@@ -320,6 +363,26 @@ interface ChecklistPinConfig {
|
|
|
320
363
|
items: ChecklistItem[];
|
|
321
364
|
[key: string]: unknown;
|
|
322
365
|
}
|
|
366
|
+
interface ComparisonSideConfig {
|
|
367
|
+
label: string;
|
|
368
|
+
body: string;
|
|
369
|
+
}
|
|
370
|
+
interface ComparisonMatchPair {
|
|
371
|
+
left: number;
|
|
372
|
+
right: number;
|
|
373
|
+
}
|
|
374
|
+
interface ComparisonPinConfig {
|
|
375
|
+
title?: string;
|
|
376
|
+
left: ComparisonSideConfig;
|
|
377
|
+
right: ComparisonSideConfig;
|
|
378
|
+
highlightedLines?: {
|
|
379
|
+
left?: number[];
|
|
380
|
+
right?: number[];
|
|
381
|
+
};
|
|
382
|
+
matches?: ComparisonMatchPair[];
|
|
383
|
+
showVsBadge?: boolean;
|
|
384
|
+
[key: string]: unknown;
|
|
385
|
+
}
|
|
323
386
|
interface CalendarPinConfig {
|
|
324
387
|
weekStartsOn?: number;
|
|
325
388
|
events?: Array<Record<string, unknown>>;
|
|
@@ -343,6 +406,7 @@ interface PinConfigByType {
|
|
|
343
406
|
table: TablePinConfig;
|
|
344
407
|
charts: ChartsPinConfig;
|
|
345
408
|
mermaid: MermaidPinConfig;
|
|
409
|
+
code: CodePinConfig;
|
|
346
410
|
embed: EmbedPinConfig;
|
|
347
411
|
'pdf-viewer': PdfViewerPinConfig;
|
|
348
412
|
'excel-viewer': ExcelViewerPinConfig;
|
|
@@ -352,6 +416,7 @@ interface PinConfigByType {
|
|
|
352
416
|
'json-list': JsonListPinConfig;
|
|
353
417
|
links: LinksPinConfig;
|
|
354
418
|
'qr-code': QrCodePinConfig;
|
|
419
|
+
'social-handles': SocialHandlesPinConfig;
|
|
355
420
|
steps: StepsPinConfig;
|
|
356
421
|
trace: TracePinConfig;
|
|
357
422
|
plan: PlanPinConfig;
|
|
@@ -364,9 +429,11 @@ interface PinConfigByType {
|
|
|
364
429
|
'text-media': TextMediaPinConfig;
|
|
365
430
|
'business-card': BusinessCardPinConfig;
|
|
366
431
|
video: VideoPinConfig;
|
|
432
|
+
audio: AudioPinConfig;
|
|
367
433
|
'file-upload': FileUploadPinConfig;
|
|
368
434
|
'kanban-board': KanbanBoardPinConfig;
|
|
369
435
|
checklist: ChecklistPinConfig;
|
|
436
|
+
comparison: ComparisonPinConfig;
|
|
370
437
|
calendar: CalendarPinConfig;
|
|
371
438
|
roadmap: RoadmapPinConfig;
|
|
372
439
|
'realtime-canvas': RealtimeCanvasPinConfig;
|
|
@@ -440,6 +507,25 @@ interface ListPinsOptions {
|
|
|
440
507
|
limit?: number;
|
|
441
508
|
offset?: number;
|
|
442
509
|
}
|
|
510
|
+
interface CreatePinOptions {
|
|
511
|
+
pin_layout?: PinLayout;
|
|
512
|
+
is_public?: boolean;
|
|
513
|
+
allow_edit?: boolean;
|
|
514
|
+
require_sign_in?: boolean;
|
|
515
|
+
allow_comments?: boolean;
|
|
516
|
+
pending_invites?: Record<string, 'editor' | 'viewer'>;
|
|
517
|
+
}
|
|
518
|
+
/** Flat create input: metadata + pin_config fields (all pin types). */
|
|
519
|
+
type CreatePinHelperInput<T extends PinTypeId> = PinMetadataBase & CreatePinOptions & PinConfigByType[T];
|
|
520
|
+
/** Flat update input: optional metadata + partial pin_config fields. */
|
|
521
|
+
type UpdatePinHelperInput<T extends PinTypeId> = {
|
|
522
|
+
pin_layout?: PinLayout;
|
|
523
|
+
is_public?: boolean;
|
|
524
|
+
title?: string;
|
|
525
|
+
tags?: string[];
|
|
526
|
+
description?: string;
|
|
527
|
+
metadata?: Partial<PinMetadataBase>;
|
|
528
|
+
} & Partial<PinConfigByType[T]>;
|
|
443
529
|
interface CreateMarkdownPinInput extends PinMetadataBase {
|
|
444
530
|
content: string;
|
|
445
531
|
pin_layout?: PinLayout;
|
|
@@ -460,6 +546,8 @@ interface CreateTablePinInput extends PinMetadataBase {
|
|
|
460
546
|
pin_layout?: PinLayout;
|
|
461
547
|
is_public?: boolean;
|
|
462
548
|
}
|
|
549
|
+
interface UpdateTablePinInput extends UpdatePinHelperInput<'table'> {
|
|
550
|
+
}
|
|
463
551
|
interface CreateEmbedPinInput extends PinMetadataBase {
|
|
464
552
|
url: string;
|
|
465
553
|
type?: string;
|
|
@@ -495,9 +583,13 @@ declare class PinsMethods {
|
|
|
495
583
|
constructor(client: PindownClient);
|
|
496
584
|
/** Create a pin (typed via CreatePinRequest<T>) */
|
|
497
585
|
create<T extends PinTypeId>(request: CreatePinRequest<T>): Promise<Pin<T>>;
|
|
586
|
+
/** Create helper for any pin type via flat typed input. */
|
|
587
|
+
createPin<T extends PinTypeId>(pinType: T, input: CreatePinHelperInput<T>): Promise<Pin<T>>;
|
|
498
588
|
get<T extends PinTypeId = PinTypeId>(pinId: string): Promise<Pin<T>>;
|
|
499
589
|
list(options?: ListPinsOptions): Promise<PaginatedResponse<Pin>>;
|
|
500
590
|
update<T extends PinTypeId = PinTypeId>(pinId: string, request: UpdatePinRequest<T>): Promise<Pin<T>>;
|
|
591
|
+
/** Update helper for any pin type via flat typed input. */
|
|
592
|
+
updatePin<T extends PinTypeId>(pinId: string, pinType: T, input: UpdatePinHelperInput<T>): Promise<Pin<T>>;
|
|
501
593
|
delete(pinId: string): Promise<void>;
|
|
502
594
|
share(pinId: string, request: SharePinRequest): Promise<Pin>;
|
|
503
595
|
batchGet(pinIds: string[]): Promise<{
|
|
@@ -537,6 +629,8 @@ declare class PinsMethods {
|
|
|
537
629
|
createMarkdown(input: CreateMarkdownPinInput): Promise<Pin<'markdown'>>;
|
|
538
630
|
createStatCards(input: CreateStatCardsPinInput): Promise<Pin<'stat-cards'>>;
|
|
539
631
|
createTable(input: CreateTablePinInput): Promise<Pin<'table'>>;
|
|
632
|
+
/** Partial table pin_config update with typed columns/rows. */
|
|
633
|
+
updateTable(pinId: string, input: UpdateTablePinInput): Promise<Pin<'table'>>;
|
|
540
634
|
createEmbed(input: CreateEmbedPinInput): Promise<Pin<'embed'>>;
|
|
541
635
|
/**
|
|
542
636
|
* @deprecated Use createMarkdown({ title, content, ... }) — old signature ignored content in title
|
|
@@ -570,6 +664,46 @@ declare class PindownClient {
|
|
|
570
664
|
private handleErrorResponse;
|
|
571
665
|
}
|
|
572
666
|
|
|
667
|
+
type CapitalizeWord<S extends string> = S extends `${infer C}${infer R}` ? `${Uppercase<C>}${R}` : S;
|
|
668
|
+
type PascalFromKebab<S extends string> = S extends `${infer Head}-${infer Tail}` ? `${CapitalizeWord<Head>}${PascalFromKebab<Tail>}` : CapitalizeWord<S>;
|
|
669
|
+
/** `createMarkdown`, `createTable`, … — one per {@link PinTypeId}. */
|
|
670
|
+
type PinCreateMethods = {
|
|
671
|
+
[T in PinTypeId as `create${PascalFromKebab<T>}`]: (input: CreatePinHelperInput<T>) => Promise<Pin<T>>;
|
|
672
|
+
};
|
|
673
|
+
/** `updateMarkdown`, `updateTable`, … — one per {@link PinTypeId}. */
|
|
674
|
+
type PinUpdateMethods = {
|
|
675
|
+
[T in PinTypeId as `update${PascalFromKebab<T>}`]: (pinId: string, input: UpdatePinHelperInput<T>) => Promise<Pin<T>>;
|
|
676
|
+
};
|
|
677
|
+
type PinTypedHelperMethods = PinCreateMethods & PinUpdateMethods;
|
|
678
|
+
|
|
679
|
+
/**
|
|
680
|
+
* Runtime hints + minimal examples per pin type.
|
|
681
|
+
* Use when building API payloads without opening the docs every time.
|
|
682
|
+
*/
|
|
683
|
+
|
|
684
|
+
interface PinConfigFieldHint {
|
|
685
|
+
path: string;
|
|
686
|
+
type: string;
|
|
687
|
+
required: boolean;
|
|
688
|
+
description: string;
|
|
689
|
+
}
|
|
690
|
+
interface PinConfigHint<T extends PinTypeId = PinTypeId> {
|
|
691
|
+
pin_type: T;
|
|
692
|
+
summary: string;
|
|
693
|
+
required_fields: string[];
|
|
694
|
+
optional_fields: string[];
|
|
695
|
+
fields: PinConfigFieldHint[];
|
|
696
|
+
/** Minimal valid pin_config for create/update */
|
|
697
|
+
example_config: PinConfigByType[T];
|
|
698
|
+
/** Typical PUT /v1/pins/:id body (root-level pin_config) */
|
|
699
|
+
example_update: UpdatePinRequest<T>;
|
|
700
|
+
}
|
|
701
|
+
/** Per-type hints (expand over time; table is fully documented). */
|
|
702
|
+
declare const PIN_CONFIG_HINTS: Partial<Record<PinTypeId, PinConfigHint>>;
|
|
703
|
+
declare function getPinConfigHint<T extends PinTypeId>(pinType: T): PinConfigHint<T> | undefined;
|
|
704
|
+
/** Pretty-print field hints for CLI / logging. */
|
|
705
|
+
declare function formatPinConfigHint(pinType: PinTypeId): string;
|
|
706
|
+
|
|
573
707
|
/**
|
|
574
708
|
* Error classes for the v1 Pins API client
|
|
575
709
|
*/
|
|
@@ -600,4 +734,4 @@ declare class NetworkError extends PindownError {
|
|
|
600
734
|
constructor(message?: string);
|
|
601
735
|
}
|
|
602
736
|
|
|
603
|
-
export { ALL_PIN_TYPES, type ApiResponse, AuthenticationError, type BusinessCardField, type BusinessCardPinConfig, type CalendarPinConfig, type ChartsPinConfig, type ChatPinConfig, type ChecklistItem, type ChecklistPinConfig, type CreateEmbedPinInput, type CreateMarkdownPinInput, type CreateNestedPinRequest, type CreatePinRequest, type CreateStatCardsPinInput, type CreateTablePinInput, type CreateTypedPinRequest, type CsvViewerPinConfig, type EmbedPinConfig, type ExcelViewerPinConfig, type FileUploadPinConfig, ForbiddenError, type GalleryImage, type GalleryPinConfig, type ImagePinConfig, type IntroPinConfig, type JsonListPinConfig, type JsonViewerPinConfig, type KanbanBoardPinConfig, type KanbanColumn, type LinkItem, type LinksPinConfig, type ListPinsOptions, type MarkdownPinConfig, type MastraPinConfig, type MermaidPinConfig, NetworkError, NotFoundError, PRODUCT_PIN_TYPES, type PaginatedResponse, type PdfViewerPinConfig, type Pin, type PinCardType, type PinConfigByType, type PinDataType, type PinLayout, type PinMetadata, type PinMetadataBase, type PinTypeId, PindownClient, type PindownConfig, PindownError, type ProductPinTypeId, type QrCodePinConfig, RateLimitError, type RealtimeCanvasPinConfig, type RoadmapPinConfig, ServerError, type SharePinRequest, type StatCardItem, type StatCardsPinConfig, type StepItem, type StepsPinConfig, type TableColumn, type TablePinConfig, type TableRow, type TextMediaPinConfig, type TimelinePinConfig, type UpdatePinRequest, type UserStoryPinConfig, ValidationError, type VideoPinConfig };
|
|
737
|
+
export { ALL_PIN_TYPES, type ApiResponse, type AudioPinConfig, type AudioPinTrack, AuthenticationError, type BusinessCardField, type BusinessCardPinConfig, type CalendarPinConfig, type ChartsPinConfig, type ChatPinConfig, type ChecklistItem, type ChecklistPinConfig, type CreateEmbedPinInput, type CreateMarkdownPinInput, type CreateNestedPinRequest, type CreatePinHelperInput, type CreatePinOptions, type CreatePinRequest, type CreateStatCardsPinInput, type CreateTablePinInput, type CreateTypedPinRequest, type CsvViewerPinConfig, type EmbedPinConfig, type ExcelViewerPinConfig, type FileUploadPinConfig, ForbiddenError, type GalleryImage, type GalleryPinConfig, type ImagePinConfig, type IntroPinConfig, type JsonListPinConfig, type JsonViewerPinConfig, type KanbanBoardPinConfig, type KanbanColumn, type LinkItem, type LinksPinConfig, type ListPinsOptions, type MarkdownPinConfig, type MastraPinConfig, type MermaidPinConfig, NetworkError, NotFoundError, PIN_CONFIG_HINTS, PRODUCT_PIN_TYPES, type PaginatedResponse, type PdfViewerPinConfig, type Pin, type PinCardType, type PinConfigByType, type PinConfigFieldHint, type PinConfigHint, type PinCreateMethods, type PinDataType, type PinLayout, type PinMetadata, type PinMetadataBase, type PinTypeId, type PinTypedHelperMethods, type PinUpdateMethods, PindownClient, type PindownConfig, PindownError, type ProductPinTypeId, type QrCodePinConfig, RateLimitError, type RealtimeCanvasPinConfig, type RoadmapPinConfig, ServerError, type SharePinRequest, type StatCardItem, type StatCardsPinConfig, type StepItem, type StepsPinConfig, type TableColumn, type TablePinConfig, type TableRow, type TextMediaPinConfig, type TimelinePinConfig, type UpdatePinHelperInput, type UpdatePinRequest, type UpdateTablePinInput, type UserStoryPinConfig, ValidationError, type VideoPinConfig, formatPinConfigHint, getPinConfigHint };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* Aligned with backend-api/src/lib/pin-types.ts + pin-config-schemas.ts.
|
|
4
4
|
* Import per-type *PinConfig interfaces for typed CRUD payloads.
|
|
5
5
|
*/
|
|
6
|
-
declare const PRODUCT_PIN_TYPES: readonly ["markdown", "image", "gallery", "table", "charts", "mermaid", "embed", "pdf-viewer", "excel-viewer", "stat-cards", "timeline", "json-viewer", "json-list", "links", "qr-code", "steps", "trace", "plan", "notes", "csv-viewer", "user-story", "chat", "intro", "mastra", "text-media", "business-card", "video", "file-upload", "kanban-board", "checklist", "calendar", "roadmap", "realtime-canvas"];
|
|
7
|
-
declare const ALL_PIN_TYPES: readonly ["markdown", "image", "gallery", "table", "charts", "mermaid", "embed", "pdf-viewer", "excel-viewer", "stat-cards", "timeline", "json-viewer", "json-list", "links", "qr-code", "steps", "trace", "plan", "notes", "csv-viewer", "user-story", "chat", "intro", "mastra", "text-media", "business-card", "video", "file-upload", "kanban-board", "checklist", "calendar", "roadmap", "realtime-canvas"];
|
|
6
|
+
declare const PRODUCT_PIN_TYPES: readonly ["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"];
|
|
7
|
+
declare const ALL_PIN_TYPES: readonly ["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"];
|
|
8
8
|
type ProductPinTypeId = (typeof PRODUCT_PIN_TYPES)[number];
|
|
9
9
|
type PinTypeId = (typeof ALL_PIN_TYPES)[number];
|
|
10
10
|
type PinLayout = '1x1' | '1x2' | '2x1' | '2x2' | '3x1' | '3x2' | '3x3' | '4x4';
|
|
@@ -87,8 +87,15 @@ interface ChartsPinConfig {
|
|
|
87
87
|
[key: string]: unknown;
|
|
88
88
|
}
|
|
89
89
|
interface MermaidPinConfig {
|
|
90
|
-
code?: string;
|
|
91
90
|
diagram?: string;
|
|
91
|
+
code?: string;
|
|
92
|
+
title?: string;
|
|
93
|
+
[key: string]: unknown;
|
|
94
|
+
}
|
|
95
|
+
interface CodePinConfig {
|
|
96
|
+
code: string;
|
|
97
|
+
language?: string;
|
|
98
|
+
filename?: string;
|
|
92
99
|
title?: string;
|
|
93
100
|
[key: string]: unknown;
|
|
94
101
|
}
|
|
@@ -144,6 +151,20 @@ interface QrCodePinConfig {
|
|
|
144
151
|
label?: string;
|
|
145
152
|
[key: string]: unknown;
|
|
146
153
|
}
|
|
154
|
+
interface SocialHandleItem {
|
|
155
|
+
id?: string;
|
|
156
|
+
platform: string;
|
|
157
|
+
url: string;
|
|
158
|
+
label?: string;
|
|
159
|
+
[key: string]: unknown;
|
|
160
|
+
}
|
|
161
|
+
interface SocialHandlesPinConfig {
|
|
162
|
+
title?: string;
|
|
163
|
+
showLabels?: boolean;
|
|
164
|
+
iconSize?: number;
|
|
165
|
+
handles?: SocialHandleItem[];
|
|
166
|
+
[key: string]: unknown;
|
|
167
|
+
}
|
|
147
168
|
interface StepsPinConfig {
|
|
148
169
|
steps: StepItem[];
|
|
149
170
|
[key: string]: unknown;
|
|
@@ -246,6 +267,10 @@ interface UserStoryPinConfig {
|
|
|
246
267
|
interface ChatPinConfig {
|
|
247
268
|
title?: string;
|
|
248
269
|
placeholder?: string;
|
|
270
|
+
/** Pin this discussion thread is about (commentary / feedback). */
|
|
271
|
+
linked_pin_id?: string;
|
|
272
|
+
/** Cached title for display without fetching the linked pin. */
|
|
273
|
+
linked_pin_title?: string;
|
|
249
274
|
[key: string]: unknown;
|
|
250
275
|
}
|
|
251
276
|
interface IntroPinConfig {
|
|
@@ -285,6 +310,24 @@ interface VideoPinConfig {
|
|
|
285
310
|
size?: number;
|
|
286
311
|
[key: string]: unknown;
|
|
287
312
|
}
|
|
313
|
+
interface AudioPinTrack {
|
|
314
|
+
url: string;
|
|
315
|
+
fileId?: string;
|
|
316
|
+
fileName?: string;
|
|
317
|
+
mimeType?: 'audio/mpeg' | 'audio/wav' | 'audio/x-wav' | string;
|
|
318
|
+
size?: number;
|
|
319
|
+
[key: string]: unknown;
|
|
320
|
+
}
|
|
321
|
+
interface AudioPinConfig {
|
|
322
|
+
url?: string;
|
|
323
|
+
fileId?: string;
|
|
324
|
+
fileName?: string;
|
|
325
|
+
mimeType?: 'audio/mpeg' | 'audio/wav' | 'audio/x-wav' | string;
|
|
326
|
+
caption?: string;
|
|
327
|
+
size?: number;
|
|
328
|
+
tracks?: AudioPinTrack[];
|
|
329
|
+
[key: string]: unknown;
|
|
330
|
+
}
|
|
288
331
|
interface TextMediaPinConfig {
|
|
289
332
|
title?: string;
|
|
290
333
|
text?: string;
|
|
@@ -320,6 +363,26 @@ interface ChecklistPinConfig {
|
|
|
320
363
|
items: ChecklistItem[];
|
|
321
364
|
[key: string]: unknown;
|
|
322
365
|
}
|
|
366
|
+
interface ComparisonSideConfig {
|
|
367
|
+
label: string;
|
|
368
|
+
body: string;
|
|
369
|
+
}
|
|
370
|
+
interface ComparisonMatchPair {
|
|
371
|
+
left: number;
|
|
372
|
+
right: number;
|
|
373
|
+
}
|
|
374
|
+
interface ComparisonPinConfig {
|
|
375
|
+
title?: string;
|
|
376
|
+
left: ComparisonSideConfig;
|
|
377
|
+
right: ComparisonSideConfig;
|
|
378
|
+
highlightedLines?: {
|
|
379
|
+
left?: number[];
|
|
380
|
+
right?: number[];
|
|
381
|
+
};
|
|
382
|
+
matches?: ComparisonMatchPair[];
|
|
383
|
+
showVsBadge?: boolean;
|
|
384
|
+
[key: string]: unknown;
|
|
385
|
+
}
|
|
323
386
|
interface CalendarPinConfig {
|
|
324
387
|
weekStartsOn?: number;
|
|
325
388
|
events?: Array<Record<string, unknown>>;
|
|
@@ -343,6 +406,7 @@ interface PinConfigByType {
|
|
|
343
406
|
table: TablePinConfig;
|
|
344
407
|
charts: ChartsPinConfig;
|
|
345
408
|
mermaid: MermaidPinConfig;
|
|
409
|
+
code: CodePinConfig;
|
|
346
410
|
embed: EmbedPinConfig;
|
|
347
411
|
'pdf-viewer': PdfViewerPinConfig;
|
|
348
412
|
'excel-viewer': ExcelViewerPinConfig;
|
|
@@ -352,6 +416,7 @@ interface PinConfigByType {
|
|
|
352
416
|
'json-list': JsonListPinConfig;
|
|
353
417
|
links: LinksPinConfig;
|
|
354
418
|
'qr-code': QrCodePinConfig;
|
|
419
|
+
'social-handles': SocialHandlesPinConfig;
|
|
355
420
|
steps: StepsPinConfig;
|
|
356
421
|
trace: TracePinConfig;
|
|
357
422
|
plan: PlanPinConfig;
|
|
@@ -364,9 +429,11 @@ interface PinConfigByType {
|
|
|
364
429
|
'text-media': TextMediaPinConfig;
|
|
365
430
|
'business-card': BusinessCardPinConfig;
|
|
366
431
|
video: VideoPinConfig;
|
|
432
|
+
audio: AudioPinConfig;
|
|
367
433
|
'file-upload': FileUploadPinConfig;
|
|
368
434
|
'kanban-board': KanbanBoardPinConfig;
|
|
369
435
|
checklist: ChecklistPinConfig;
|
|
436
|
+
comparison: ComparisonPinConfig;
|
|
370
437
|
calendar: CalendarPinConfig;
|
|
371
438
|
roadmap: RoadmapPinConfig;
|
|
372
439
|
'realtime-canvas': RealtimeCanvasPinConfig;
|
|
@@ -440,6 +507,25 @@ interface ListPinsOptions {
|
|
|
440
507
|
limit?: number;
|
|
441
508
|
offset?: number;
|
|
442
509
|
}
|
|
510
|
+
interface CreatePinOptions {
|
|
511
|
+
pin_layout?: PinLayout;
|
|
512
|
+
is_public?: boolean;
|
|
513
|
+
allow_edit?: boolean;
|
|
514
|
+
require_sign_in?: boolean;
|
|
515
|
+
allow_comments?: boolean;
|
|
516
|
+
pending_invites?: Record<string, 'editor' | 'viewer'>;
|
|
517
|
+
}
|
|
518
|
+
/** Flat create input: metadata + pin_config fields (all pin types). */
|
|
519
|
+
type CreatePinHelperInput<T extends PinTypeId> = PinMetadataBase & CreatePinOptions & PinConfigByType[T];
|
|
520
|
+
/** Flat update input: optional metadata + partial pin_config fields. */
|
|
521
|
+
type UpdatePinHelperInput<T extends PinTypeId> = {
|
|
522
|
+
pin_layout?: PinLayout;
|
|
523
|
+
is_public?: boolean;
|
|
524
|
+
title?: string;
|
|
525
|
+
tags?: string[];
|
|
526
|
+
description?: string;
|
|
527
|
+
metadata?: Partial<PinMetadataBase>;
|
|
528
|
+
} & Partial<PinConfigByType[T]>;
|
|
443
529
|
interface CreateMarkdownPinInput extends PinMetadataBase {
|
|
444
530
|
content: string;
|
|
445
531
|
pin_layout?: PinLayout;
|
|
@@ -460,6 +546,8 @@ interface CreateTablePinInput extends PinMetadataBase {
|
|
|
460
546
|
pin_layout?: PinLayout;
|
|
461
547
|
is_public?: boolean;
|
|
462
548
|
}
|
|
549
|
+
interface UpdateTablePinInput extends UpdatePinHelperInput<'table'> {
|
|
550
|
+
}
|
|
463
551
|
interface CreateEmbedPinInput extends PinMetadataBase {
|
|
464
552
|
url: string;
|
|
465
553
|
type?: string;
|
|
@@ -495,9 +583,13 @@ declare class PinsMethods {
|
|
|
495
583
|
constructor(client: PindownClient);
|
|
496
584
|
/** Create a pin (typed via CreatePinRequest<T>) */
|
|
497
585
|
create<T extends PinTypeId>(request: CreatePinRequest<T>): Promise<Pin<T>>;
|
|
586
|
+
/** Create helper for any pin type via flat typed input. */
|
|
587
|
+
createPin<T extends PinTypeId>(pinType: T, input: CreatePinHelperInput<T>): Promise<Pin<T>>;
|
|
498
588
|
get<T extends PinTypeId = PinTypeId>(pinId: string): Promise<Pin<T>>;
|
|
499
589
|
list(options?: ListPinsOptions): Promise<PaginatedResponse<Pin>>;
|
|
500
590
|
update<T extends PinTypeId = PinTypeId>(pinId: string, request: UpdatePinRequest<T>): Promise<Pin<T>>;
|
|
591
|
+
/** Update helper for any pin type via flat typed input. */
|
|
592
|
+
updatePin<T extends PinTypeId>(pinId: string, pinType: T, input: UpdatePinHelperInput<T>): Promise<Pin<T>>;
|
|
501
593
|
delete(pinId: string): Promise<void>;
|
|
502
594
|
share(pinId: string, request: SharePinRequest): Promise<Pin>;
|
|
503
595
|
batchGet(pinIds: string[]): Promise<{
|
|
@@ -537,6 +629,8 @@ declare class PinsMethods {
|
|
|
537
629
|
createMarkdown(input: CreateMarkdownPinInput): Promise<Pin<'markdown'>>;
|
|
538
630
|
createStatCards(input: CreateStatCardsPinInput): Promise<Pin<'stat-cards'>>;
|
|
539
631
|
createTable(input: CreateTablePinInput): Promise<Pin<'table'>>;
|
|
632
|
+
/** Partial table pin_config update with typed columns/rows. */
|
|
633
|
+
updateTable(pinId: string, input: UpdateTablePinInput): Promise<Pin<'table'>>;
|
|
540
634
|
createEmbed(input: CreateEmbedPinInput): Promise<Pin<'embed'>>;
|
|
541
635
|
/**
|
|
542
636
|
* @deprecated Use createMarkdown({ title, content, ... }) — old signature ignored content in title
|
|
@@ -570,6 +664,46 @@ declare class PindownClient {
|
|
|
570
664
|
private handleErrorResponse;
|
|
571
665
|
}
|
|
572
666
|
|
|
667
|
+
type CapitalizeWord<S extends string> = S extends `${infer C}${infer R}` ? `${Uppercase<C>}${R}` : S;
|
|
668
|
+
type PascalFromKebab<S extends string> = S extends `${infer Head}-${infer Tail}` ? `${CapitalizeWord<Head>}${PascalFromKebab<Tail>}` : CapitalizeWord<S>;
|
|
669
|
+
/** `createMarkdown`, `createTable`, … — one per {@link PinTypeId}. */
|
|
670
|
+
type PinCreateMethods = {
|
|
671
|
+
[T in PinTypeId as `create${PascalFromKebab<T>}`]: (input: CreatePinHelperInput<T>) => Promise<Pin<T>>;
|
|
672
|
+
};
|
|
673
|
+
/** `updateMarkdown`, `updateTable`, … — one per {@link PinTypeId}. */
|
|
674
|
+
type PinUpdateMethods = {
|
|
675
|
+
[T in PinTypeId as `update${PascalFromKebab<T>}`]: (pinId: string, input: UpdatePinHelperInput<T>) => Promise<Pin<T>>;
|
|
676
|
+
};
|
|
677
|
+
type PinTypedHelperMethods = PinCreateMethods & PinUpdateMethods;
|
|
678
|
+
|
|
679
|
+
/**
|
|
680
|
+
* Runtime hints + minimal examples per pin type.
|
|
681
|
+
* Use when building API payloads without opening the docs every time.
|
|
682
|
+
*/
|
|
683
|
+
|
|
684
|
+
interface PinConfigFieldHint {
|
|
685
|
+
path: string;
|
|
686
|
+
type: string;
|
|
687
|
+
required: boolean;
|
|
688
|
+
description: string;
|
|
689
|
+
}
|
|
690
|
+
interface PinConfigHint<T extends PinTypeId = PinTypeId> {
|
|
691
|
+
pin_type: T;
|
|
692
|
+
summary: string;
|
|
693
|
+
required_fields: string[];
|
|
694
|
+
optional_fields: string[];
|
|
695
|
+
fields: PinConfigFieldHint[];
|
|
696
|
+
/** Minimal valid pin_config for create/update */
|
|
697
|
+
example_config: PinConfigByType[T];
|
|
698
|
+
/** Typical PUT /v1/pins/:id body (root-level pin_config) */
|
|
699
|
+
example_update: UpdatePinRequest<T>;
|
|
700
|
+
}
|
|
701
|
+
/** Per-type hints (expand over time; table is fully documented). */
|
|
702
|
+
declare const PIN_CONFIG_HINTS: Partial<Record<PinTypeId, PinConfigHint>>;
|
|
703
|
+
declare function getPinConfigHint<T extends PinTypeId>(pinType: T): PinConfigHint<T> | undefined;
|
|
704
|
+
/** Pretty-print field hints for CLI / logging. */
|
|
705
|
+
declare function formatPinConfigHint(pinType: PinTypeId): string;
|
|
706
|
+
|
|
573
707
|
/**
|
|
574
708
|
* Error classes for the v1 Pins API client
|
|
575
709
|
*/
|
|
@@ -600,4 +734,4 @@ declare class NetworkError extends PindownError {
|
|
|
600
734
|
constructor(message?: string);
|
|
601
735
|
}
|
|
602
736
|
|
|
603
|
-
export { ALL_PIN_TYPES, type ApiResponse, AuthenticationError, type BusinessCardField, type BusinessCardPinConfig, type CalendarPinConfig, type ChartsPinConfig, type ChatPinConfig, type ChecklistItem, type ChecklistPinConfig, type CreateEmbedPinInput, type CreateMarkdownPinInput, type CreateNestedPinRequest, type CreatePinRequest, type CreateStatCardsPinInput, type CreateTablePinInput, type CreateTypedPinRequest, type CsvViewerPinConfig, type EmbedPinConfig, type ExcelViewerPinConfig, type FileUploadPinConfig, ForbiddenError, type GalleryImage, type GalleryPinConfig, type ImagePinConfig, type IntroPinConfig, type JsonListPinConfig, type JsonViewerPinConfig, type KanbanBoardPinConfig, type KanbanColumn, type LinkItem, type LinksPinConfig, type ListPinsOptions, type MarkdownPinConfig, type MastraPinConfig, type MermaidPinConfig, NetworkError, NotFoundError, PRODUCT_PIN_TYPES, type PaginatedResponse, type PdfViewerPinConfig, type Pin, type PinCardType, type PinConfigByType, type PinDataType, type PinLayout, type PinMetadata, type PinMetadataBase, type PinTypeId, PindownClient, type PindownConfig, PindownError, type ProductPinTypeId, type QrCodePinConfig, RateLimitError, type RealtimeCanvasPinConfig, type RoadmapPinConfig, ServerError, type SharePinRequest, type StatCardItem, type StatCardsPinConfig, type StepItem, type StepsPinConfig, type TableColumn, type TablePinConfig, type TableRow, type TextMediaPinConfig, type TimelinePinConfig, type UpdatePinRequest, type UserStoryPinConfig, ValidationError, type VideoPinConfig };
|
|
737
|
+
export { ALL_PIN_TYPES, type ApiResponse, type AudioPinConfig, type AudioPinTrack, AuthenticationError, type BusinessCardField, type BusinessCardPinConfig, type CalendarPinConfig, type ChartsPinConfig, type ChatPinConfig, type ChecklistItem, type ChecklistPinConfig, type CreateEmbedPinInput, type CreateMarkdownPinInput, type CreateNestedPinRequest, type CreatePinHelperInput, type CreatePinOptions, type CreatePinRequest, type CreateStatCardsPinInput, type CreateTablePinInput, type CreateTypedPinRequest, type CsvViewerPinConfig, type EmbedPinConfig, type ExcelViewerPinConfig, type FileUploadPinConfig, ForbiddenError, type GalleryImage, type GalleryPinConfig, type ImagePinConfig, type IntroPinConfig, type JsonListPinConfig, type JsonViewerPinConfig, type KanbanBoardPinConfig, type KanbanColumn, type LinkItem, type LinksPinConfig, type ListPinsOptions, type MarkdownPinConfig, type MastraPinConfig, type MermaidPinConfig, NetworkError, NotFoundError, PIN_CONFIG_HINTS, PRODUCT_PIN_TYPES, type PaginatedResponse, type PdfViewerPinConfig, type Pin, type PinCardType, type PinConfigByType, type PinConfigFieldHint, type PinConfigHint, type PinCreateMethods, type PinDataType, type PinLayout, type PinMetadata, type PinMetadataBase, type PinTypeId, type PinTypedHelperMethods, type PinUpdateMethods, PindownClient, type PindownConfig, PindownError, type ProductPinTypeId, type QrCodePinConfig, RateLimitError, type RealtimeCanvasPinConfig, type RoadmapPinConfig, ServerError, type SharePinRequest, type StatCardItem, type StatCardsPinConfig, type StepItem, type StepsPinConfig, type TableColumn, type TablePinConfig, type TableRow, type TextMediaPinConfig, type TimelinePinConfig, type UpdatePinHelperInput, type UpdatePinRequest, type UpdateTablePinInput, type UserStoryPinConfig, ValidationError, type VideoPinConfig, formatPinConfigHint, getPinConfigHint };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
var C=class{constructor(e){this.client=e;}async create(e){return this.client.request("POST","/pins",e)}async get(e){return this.client.request("GET",`/pins/${e}`)}async list(e){let
|
|
2
|
-
|
|
1
|
+
var C=["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"];[...C];var S={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 v(t){return t.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join("")}function T(t,e){let i=S[t],n={};for(let a of i)a in e&&e[a]!==void 0&&(n[a]=e[a]);return n}function k(t,e){let n=T(t,e),a={title:e.title,tags:e.tags,description:e.description,allow_edit:e.allow_edit,require_sign_in:e.require_sign_in,allow_comments:e.allow_comments};return {pin_type:t,pin_config:n,pin_layout:e.pin_layout,is_public:e.is_public,allow_edit:e.allow_edit,require_sign_in:e.require_sign_in,allow_comments:e.allow_comments,pending_invites:e.pending_invites,metadata:a}}function b(t,e){let n=T(t,e),a=Object.keys(n).length>0,o={...e.metadata??{}};e.title!==void 0&&(o.title=e.title),e.tags!==void 0&&(o.tags=e.tags),e.description!==void 0&&(o.description=e.description);let s=Object.keys(o).length>0;return {...a?{pin_config:n}:{},pin_layout:e.pin_layout,is_public:e.is_public,...s?{metadata:o}:{}}}function x(t){for(let e of C){let i=v(e);t.prototype[`create${i}`]=function(n){return this.createPin(e,n)},t.prototype[`update${i}`]=function(n,a){return this.updatePin(n,e,a)};}}var y=class{constructor(e){this.client=e;}async create(e){return this.client.request("POST","/pins",e)}async createPin(e,i){return this.create(k(e,i))}async get(e){return this.client.request("GET",`/pins/${e}`)}async list(e){let i=new URLSearchParams;e?.limit&&i.append("limit",e.limit.toString()),e?.offset&&i.append("offset",e.offset.toString());let n=i.toString(),a=n?`/pins?${n}`:"/pins";return this.client.request("GET",a)}async update(e,i){return this.client.request("PUT",`/pins/${e}`,i)}async updatePin(e,i,n){return this.update(e,b(i,n))}async delete(e){return this.client.request("DELETE",`/pins/${e}`)}async share(e,i){return this.client.request("POST",`/pins/${e}/share`,i)}async batchGet(e){return this.client.request("POST","/pins/batch/get",{pin_ids:e})}async batchCreate(e){return this.client.request("POST","/pins/batch",{pins:e})}async batchUpdate(e){return this.client.request("PATCH","/pins/batch",{updates:e})}async batchDelete(e){return this.client.request("DELETE","/pins/batch",{pin_ids:e})}async createMarkdown(e){let{content:i,title:n,tags:a,description:o,pin_layout:s,is_public:r,allow_edit:l,require_sign_in:I,allow_comments:R,pending_invites:q}=e;return this.create({pin_type:"markdown",pin_config:{content:i},pin_layout:s,is_public:r,allow_edit:l,require_sign_in:I,allow_comments:R,pending_invites:q,metadata:{title:n,tags:a,description:o}})}async createStatCards(e){let{cards:i,title:n,tags:a,description:o,pin_layout:s,is_public:r}=e;return this.create({pin_type:"stat-cards",pin_config:{cards:i},pin_layout:s,is_public:r,metadata:{title:n,tags:a,description:o}})}async createTable(e){let{columns:i,rows:n,title:a,tags:o,description:s,pin_layout:r,is_public:l}=e;return this.create({pin_type:"table",pin_config:{columns:i,rows:n},pin_layout:r,is_public:l,metadata:{title:a,tags:o,description:s}})}async updateTable(e,i){return this.updatePin(e,"table",i)}async createEmbed(e){let{url:i,type:n,title:a,tags:o,description:s,pin_layout:r,is_public:l}=e;return this.create({pin_type:"embed",pin_config:{url:i,type:n},pin_layout:r,is_public:l,metadata:{title:a,tags:o,description:s}})}async createMarkdownLegacy(e,i){return this.createMarkdown({title:e,content:"",...i})}};x(y);var p=class extends Error{constructor(e){super(e),this.name="PindownError";}},g=class extends p{constructor(e="Authentication failed"){super(e),this.name="AuthenticationError";}},c=class extends p{constructor(e="Access forbidden"){super(e),this.name="ForbiddenError";}},u=class extends p{constructor(e){super(`${e} not found`),this.name="NotFoundError";}},P=class extends p{constructor(e,i){super(e),this.name="ValidationError",this.details=i;}},f=class extends p{constructor(e="Rate limit exceeded (429 RATE_LIMITED)"){super(e),this.name="RateLimitError";}},d=class extends p{constructor(e,i=500){super(e),this.name="ServerError",this.statusCode=i;}},m=class extends p{constructor(e="Network request failed"){super(e),this.name="NetworkError";}};var w=class{constructor(e){if(!e.apiKey)throw new Error("API key is required");this.config={apiKey:e.apiKey,baseURL:e.baseURL||"https://api.pindown.ai/v1",maxRetries:e.maxRetries??3,timeout:e.timeout??3e4},this.pins=new y(this);}async request(e,i,n){let a=`${this.config.baseURL}${i}`,o={Authorization:`Bearer ${this.config.apiKey}`};n&&(e==="POST"||e==="PUT"||e==="PATCH"||e==="DELETE")&&(o["Content-Type"]="application/json");let s={method:e,headers:o,signal:AbortSignal.timeout(this.config.timeout)};n&&(e==="POST"||e==="PUT"||e==="PATCH"||e==="DELETE")&&(s.body=JSON.stringify(n));try{let r=await fetch(a,s);return r.ok||await this.handleErrorResponse(r),(await r.json()).data}catch(r){throw r instanceof g||r instanceof c||r instanceof u||r instanceof P||r instanceof f||r instanceof d?r:r instanceof Error&&(r.name==="AbortError"||r.name==="TimeoutError")?new m("Request timeout"):new m(r instanceof Error?r.message:"Network request failed")}}async handleErrorResponse(e){let i;try{i=await e.json();}catch{i={message:e.statusText};}let n=i.error?.message||i.message||"Unknown error";switch(e.status){case 401:throw new g(n);case 403:throw new c(n);case 404:throw new u(n);case 400:case 422:throw new P(n,i.error?.details);case 429:throw new f(n);case 500:case 502:case 503:throw new d(n,e.status);default:throw new d(n,e.status)}}};var E={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}}]}}},_={table:E,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 h(t){return _[t]}function L(t){let e=h(t);return e?[`Pin type: ${e.pin_type}`,e.summary,"","Required pin_config fields:",...e.required_fields.map(n=>` - ${n}`),"","Optional pin_config fields:",...e.optional_fields.length?e.optional_fields.map(n=>` - ${n}`):[" (none documented)"],"","Field reference:",...e.fields.map(n=>` ${n.path} (${n.type}${n.required?", required":""}): ${n.description}`),"","Example update payload:",JSON.stringify(e.example_update,null,2)].join(`
|
|
6
|
+
`):[`No built-in hint for pin type "${t}".`,"Use CreatePinRequest<typeof pinType> / PinConfigByType[typeof pinType] in TypeScript,","or client.pins.create({ pin_type, pin_config, metadata }) with typed pin_config."].join(`
|
|
7
|
+
`)}export{g as AuthenticationError,c as ForbiddenError,m as NetworkError,u as NotFoundError,_ as PIN_CONFIG_HINTS,w as PindownClient,p as PindownError,f as RateLimitError,d as ServerError,P as ValidationError,L as formatPinConfigHint,h as getPinConfigHint};//# sourceMappingURL=index.js.map
|
|
3
8
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/client/pins/index.ts","../src/errors/index.ts","../src/client/PindownClient.ts"],"names":["PinsMethods","client","request","pinId","options","params","query","endpoint","pinIds","pins","updates","input","content","title","tags","description","pin_layout","is_public","allow_edit","require_sign_in","allow_comments","pending_invites","cards","columns","rows","url","type","additionalMetadata","PindownError","message","AuthenticationError","ForbiddenError","NotFoundError","resource","ValidationError","details","RateLimitError","ServerError","statusCode","NetworkError","PindownClient","config","method","data","headers","requestOptions","response","error","errorData"],"mappings":"AAmBO,IAAMA,CAAAA,CAAN,KAAkB,CACvB,WAAA,CAAoBC,EAAuB,CAAvB,IAAA,CAAA,MAAA,CAAAA,EAAwB,CAG5C,MAAM,OAA4BC,CAAAA,CAA+C,CAC/E,OAAO,IAAA,CAAK,MAAA,CAAO,QAAgB,MAAA,CAAQ,OAAA,CAASA,CAAO,CAC7D,CAEA,MAAM,IAAqCC,CAAAA,CAAgC,CACzE,OAAO,IAAA,CAAK,MAAA,CAAO,QAAgB,KAAA,CAAO,CAAA,MAAA,EAASA,CAAK,CAAA,CAAE,CAC5D,CAEA,MAAM,IAAA,CAAKC,CAAAA,CAA4D,CACrE,IAAMC,CAAAA,CAAS,IAAI,eAAA,CACfD,CAAAA,EAAS,KAAA,EAAOC,CAAAA,CAAO,MAAA,CAAO,OAAA,CAASD,EAAQ,KAAA,CAAM,QAAA,EAAU,CAAA,CAC/DA,CAAAA,EAAS,QAAQC,CAAAA,CAAO,MAAA,CAAO,QAAA,CAAUD,CAAAA,CAAQ,MAAA,CAAO,QAAA,EAAU,CAAA,CAEtE,IAAME,EAAQD,CAAAA,CAAO,QAAA,GACfE,CAAAA,CAAWD,CAAAA,CAAQ,CAAA,MAAA,EAASA,CAAK,CAAA,CAAA,CAAK,OAAA,CAE5C,OAAO,IAAA,CAAK,MAAA,CAAO,QAAgC,KAAA,CAAOC,CAAQ,CACpE,CAEA,MAAM,MAAA,CAAwCJ,CAAAA,CAAeD,CAAAA,CAA+C,CAC1G,OAAO,IAAA,CAAK,M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A,CACrE,IAAIR,EAAa,iBAAiB,CAAA,CAGpC,IAAIA,CAAAA,CAAaQ,CAAAA,YAAiB,KAAA,CAAQA,EAAM,OAAA,CAAU,wBAAwB,CAC1F,CACF,CAEA,MAAc,mBAAA,CAAoBD,CAAAA,CAAoC,CACpE,IAAIE,CAAAA,CAEJ,GAAI,CACFA,CAAAA,CAAY,MAAMF,EAAS,IAAA,GAC7B,MAAQ,CACNE,CAAAA,CAAY,CAAE,OAAA,CAASF,CAAAA,CAAS,UAAW,EAC7C,CAEA,IAAMjB,EAAUmB,CAAAA,CAAU,KAAA,EAAO,SAAWA,CAAAA,CAAU,OAAA,EAAW,eAAA,CAEjE,OAAQF,CAAAA,CAAS,MAAA,EACf,KAAK,GAAA,CACH,MAAM,IAAIhB,CAAAA,CAAoBD,CAAO,CAAA,CACvC,KAAK,GAAA,CACH,MAAM,IAAIE,CAAAA,CAAeF,CAAO,CAAA,CAClC,SACE,MAAM,IAAIG,EAAcH,CAAO,CAAA,CACjC,KAAK,GAAA,CACL,KAAK,GAAA,CACH,MAAM,IAAIK,CAAAA,CAAgBL,EAASmB,CAAAA,CAAU,KAAA,EAAO,OAAO,CAAA,CAC7D,KAAK,GAAA,CACH,MAAM,IAAIZ,CAAAA,CAAeP,CAAO,CAAA,CAClC,SACA,KAAK,GAAA,CACL,KAAK,GAAA,CACH,MAAM,IAAIQ,CAAAA,CAAYR,CAAAA,CAASiB,CAAAA,CAAS,MAAM,CAAA,CAChD,QACE,MAAM,IAAIT,CAAAA,CAAYR,EAASiB,CAAAA,CAAS,MAAM,CAClD,CACF,CACF","file":"index.js","sourcesContent":["/**\n * Pins API Methods\n */\n\nimport type { PindownClient } from '../PindownClient'\nimport type {\n Pin,\n PinTypeId,\n CreatePinRequest,\n UpdatePinRequest,\n SharePinRequest,\n ListPinsOptions,\n CreateMarkdownPinInput,\n CreateStatCardsPinInput,\n CreateTablePinInput,\n CreateEmbedPinInput,\n} from '../../types/pins'\nimport type { PaginatedResponse } from '../../types/api'\n\nexport class PinsMethods {\n constructor(private client: PindownClient) {}\n\n /** Create a pin (typed via CreatePinRequest<T>) */\n async create<T extends PinTypeId>(request: CreatePinRequest<T>): Promise<Pin<T>> {\n return this.client.request<Pin<T>>('POST', '/pins', request)\n }\n\n async get<T extends PinTypeId = PinTypeId>(pinId: string): Promise<Pin<T>> {\n return this.client.request<Pin<T>>('GET', `/pins/${pinId}`)\n }\n\n async list(options?: ListPinsOptions): Promise<PaginatedResponse<Pin>> {\n const params = new URLSearchParams()\n if (options?.limit) params.append('limit', options.limit.toString())\n if (options?.offset) params.append('offset', options.offset.toString())\n\n const query = params.toString()\n const endpoint = query ? `/pins?${query}` : '/pins'\n\n return this.client.request<PaginatedResponse<Pin>>('GET', endpoint)\n }\n\n async update<T extends PinTypeId = PinTypeId>(pinId: string, request: UpdatePinRequest<T>): Promise<Pin<T>> {\n return this.client.request<Pin<T>>('PUT', `/pins/${pinId}`, request)\n }\n\n async delete(pinId: string): Promise<void> {\n return this.client.request<void>('DELETE', `/pins/${pinId}`)\n }\n\n async share(pinId: string, request: SharePinRequest): Promise<Pin> {\n return this.client.request<Pin>('POST', `/pins/${pinId}/share`, request)\n }\n\n async batchGet(pinIds: string[]): Promise<{\n found: Pin[]\n not_found: string[]\n permission_denied: string[]\n }> {\n return this.client.request('POST', '/pins/batch/get', { pin_ids: pinIds })\n }\n\n async batchCreate(pins: CreatePinRequest[]): Promise<{\n created: Array<{ id: string; index: number; created_at: number }>\n failed: Array<{ index: number; error: string }>\n }> {\n return this.client.request('POST', '/pins/batch', { pins })\n }\n\n async batchUpdate(updates: Array<{ id: string } & UpdatePinRequest>): Promise<{\n updated: string[]\n failed: Array<{ id: string; error: string }>\n updated_at: number\n }> {\n return this.client.request('PATCH', '/pins/batch', { updates })\n }\n\n async batchDelete(pinIds: string[]): Promise<{\n deleted: string[]\n failed: Array<{ id: string; error: string }>\n }> {\n return this.client.request('DELETE', '/pins/batch', { pin_ids: pinIds })\n }\n\n /** Create a markdown pin with pin_config.content (seeds Yjs on the server). */\n async createMarkdown(input: CreateMarkdownPinInput): Promise<Pin<'markdown'>> {\n const { content, title, tags, description, pin_layout, is_public, allow_edit, require_sign_in, allow_comments, pending_invites } = input\n return this.create({\n pin_type: 'markdown',\n pin_config: { content },\n pin_layout,\n is_public,\n allow_edit,\n require_sign_in,\n allow_comments,\n pending_invites,\n metadata: { title, tags, description },\n })\n }\n\n async createStatCards(input: CreateStatCardsPinInput): Promise<Pin<'stat-cards'>> {\n const { cards, title, tags, description, pin_layout, is_public } = input\n return this.create({\n pin_type: 'stat-cards',\n pin_config: { cards },\n pin_layout,\n is_public,\n metadata: { title, tags, description },\n })\n }\n\n async createTable(input: CreateTablePinInput): Promise<Pin<'table'>> {\n const { columns, rows, title, tags, description, pin_layout, is_public } = input\n return this.create({\n pin_type: 'table',\n pin_config: { columns, rows },\n pin_layout,\n is_public,\n metadata: { title, tags, description },\n })\n }\n\n async createEmbed(input: CreateEmbedPinInput): Promise<Pin<'embed'>> {\n const { url, type, title, tags, description, pin_layout, is_public } = input\n return this.create({\n pin_type: 'embed',\n pin_config: { url, type },\n pin_layout,\n is_public,\n metadata: { title, tags, description },\n })\n }\n\n /**\n * @deprecated Use createMarkdown({ title, content, ... }) — old signature ignored content in title\n */\n async createMarkdownLegacy(title: string, additionalMetadata?: Record<string, unknown>): Promise<Pin<'markdown'>> {\n return this.createMarkdown({\n title,\n content: '',\n ...(additionalMetadata as Partial<CreateMarkdownPinInput>),\n })\n }\n}\n","/**\n * Error classes for the v1 Pins API client\n */\n\nexport class PindownError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'PindownError'\n }\n}\n\nexport class AuthenticationError extends PindownError {\n constructor(message: string = 'Authentication failed') {\n super(message)\n this.name = 'AuthenticationError'\n }\n}\n\nexport class ForbiddenError extends PindownError {\n constructor(message: string = 'Access forbidden') {\n super(message)\n this.name = 'ForbiddenError'\n }\n}\n\nexport class NotFoundError extends PindownError {\n constructor(resource: string) {\n super(`${resource} not found`)\n this.name = 'NotFoundError'\n }\n}\n\nexport class ValidationError extends PindownError {\n public details?: unknown\n\n constructor(message: string, details?: unknown) {\n super(message)\n this.name = 'ValidationError'\n this.details = details\n }\n}\n\nexport class RateLimitError extends PindownError {\n constructor(message: string = 'Rate limit exceeded (429 RATE_LIMITED)') {\n super(message)\n this.name = 'RateLimitError'\n }\n}\n\nexport class ServerError extends PindownError {\n public statusCode: number\n\n constructor(message: string, statusCode: number = 500) {\n super(message)\n this.name = 'ServerError'\n this.statusCode = statusCode\n }\n}\n\nexport class NetworkError extends PindownError {\n constructor(message: string = 'Network request failed') {\n super(message)\n this.name = 'NetworkError'\n }\n}\n","/**\n * Pindown API Client — v1 Pins API only\n */\n\nimport { PinsMethods } from './pins'\nimport type { PindownConfig } from '../types/config'\nimport {\n AuthenticationError,\n ForbiddenError,\n NotFoundError,\n ValidationError,\n RateLimitError,\n ServerError,\n NetworkError,\n} from '../errors'\n\nexport class PindownClient {\n private config: Required<Omit<PindownConfig, 'baseURL'>> & { baseURL: string }\n\n public readonly pins: PinsMethods\n\n constructor(config: PindownConfig) {\n if (!config.apiKey) {\n throw new Error('API key is required')\n }\n\n this.config = {\n apiKey: config.apiKey,\n baseURL: config.baseURL || 'https://api.pindown.ai/v1',\n maxRetries: config.maxRetries ?? 3,\n timeout: config.timeout ?? 30000,\n }\n\n this.pins = new PinsMethods(this)\n }\n\n async request<T = unknown>(method: string, endpoint: string, data?: unknown): Promise<T> {\n const url = `${this.config.baseURL}${endpoint}`\n const headers: Record<string, string> = {\n Authorization: `Bearer ${this.config.apiKey}`,\n }\n\n if (data && (method === 'POST' || method === 'PUT' || method === 'PATCH' || method === 'DELETE')) {\n headers['Content-Type'] = 'application/json'\n }\n\n const requestOptions: RequestInit = {\n method,\n headers,\n signal: AbortSignal.timeout(this.config.timeout),\n }\n\n if (data && (method === 'POST' || method === 'PUT' || method === 'PATCH' || method === 'DELETE')) {\n requestOptions.body = JSON.stringify(data)\n }\n\n try {\n const response = await fetch(url, requestOptions)\n\n if (!response.ok) {\n await this.handleErrorResponse(response)\n }\n\n const result = await response.json()\n return result.data as T\n } catch (error: unknown) {\n if (\n error instanceof AuthenticationError ||\n error instanceof ForbiddenError ||\n error instanceof NotFoundError ||\n error instanceof ValidationError ||\n error instanceof RateLimitError ||\n error instanceof ServerError\n ) {\n throw error\n }\n\n if (error instanceof Error && (error.name === 'AbortError' || error.name === 'TimeoutError')) {\n throw new NetworkError('Request timeout')\n }\n\n throw new NetworkError(error instanceof Error ? error.message : 'Network request failed')\n }\n }\n\n private async handleErrorResponse(response: Response): Promise<never> {\n let errorData: { error?: { code?: string; message?: string; details?: unknown }; message?: string }\n\n try {\n errorData = await response.json()\n } catch {\n errorData = { message: response.statusText }\n }\n\n const message = errorData.error?.message || errorData.message || 'Unknown error'\n\n switch (response.status) {\n case 401:\n throw new AuthenticationError(message)\n case 403:\n throw new ForbiddenError(message)\n case 404:\n throw new NotFoundError(message)\n case 400:\n case 422:\n throw new ValidationError(message, errorData.error?.details)\n case 429:\n throw new RateLimitError(message)\n case 500:\n case 502:\n case 503:\n throw new ServerError(message, response.status)\n default:\n throw new ServerError(message, response.status)\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/types/pins.ts","../src/client/pins/pin-helper-core.ts","../src/client/pins/index.ts","../src/errors/index.ts","../src/client/PindownClient.ts","../src/pin-config-hints.ts"],"names":["PRODUCT_PIN_TYPES","PIN_CONFIG_FIELDS","pinTypeToMethodSuffix","pinType","part","pickPinConfig","input","fields","pin_config","key","toCreatePinRequest","metadata","toUpdatePinRequest","hasPinConfig","hasMetadata","attachNamedPinHelpers","ctor","suffix","pinId","PinsMethods","client","request","options","params","query","endpoint","pinIds","pins","updates","content","title","tags","description","pin_layout","is_public","allow_edit","require_sign_in","allow_comments","pending_invites","cards","columns","rows","url","type","additionalMetadata","PindownError","message","AuthenticationError","ForbiddenError","NotFoundError","resource","ValidationError","details","RateLimitError","ServerError","statusCode","NetworkError","PindownClient","config","method","data","headers","requestOptions","response","error","errorData","TABLE_HINT","PIN_CONFIG_HINTS","getPinConfigHint","formatPinConfigHint","hint","f"],"mappings":"AAMO,IAAMA,CAAAA,CAAoB,CAC/B,UAAA,CACA,OAAA,CACA,UACA,OAAA,CACA,QAAA,CACA,UACA,MAAA,CACA,OAAA,CACA,aACA,cAAA,CACA,YAAA,CACA,WACA,aAAA,CACA,WAAA,CACA,QACA,SAAA,CACA,gBAAA,CACA,QACA,OAAA,CACA,MAAA,CACA,QACA,YAAA,CACA,YAAA,CACA,OACA,OAAA,CACA,QAAA,CACA,aACA,eAAA,CACA,OAAA,CACA,QACA,aAAA,CACA,cAAA,CACA,YACA,YAAA,CACA,UAAA,CACA,UACA,iBACF,CAAA,CAE6B,CAAC,GAAGA,CAAiB,EClC3C,IAAMC,EAAmG,CAC9G,QAAA,CAAU,CAAC,SAAA,CAAW,eAAe,EACrC,KAAA,CAAO,CAAC,MAAO,SAAA,CAAW,KAAK,EAC/B,OAAA,CAAS,CAAC,QAAQ,CAAA,CAClB,KAAA,CAAO,CAAC,SAAA,CAAW,MAAM,EACzB,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,MAAO,CAAC,KAAA,CAAO,MAAM,CAAA,CACrB,YAAA,CAAc,CAAC,KAAK,CAAA,CACpB,cAAA,CAAgB,CAAC,OAAO,CAAA,CACxB,aAAc,CAAC,OAAO,EACtB,QAAA,CAAU,CAAC,OAAQ,OAAO,CAAA,CAC1B,cAAe,CAAC,MAAA,CAAQ,aAAc,OAAO,CAAA,CAC7C,YAAa,CAAC,MAAA,CAAQ,YAAY,CAAA,CAClC,KAAA,CAAO,CAAC,OAAO,CAAA,CACf,UAAW,CAAC,KAAA,CAAO,OAAO,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,CAC7C,EACa,IAAA,CAAK;AAAA,CAAI,CAAA,CAzBb,CACL,CAAA,+BAAA,EAAkCnE,CAAO,KACzC,uFAAA,CACA,kFACF,EAAE,IAAA,CAAK;AAAA,CAAI,CAsBf","file":"index.js","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 ...(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 * Pins API Methods\n */\n\nimport type { PindownClient } from '../PindownClient'\nimport type {\n Pin,\n PinTypeId,\n CreatePinRequest,\n CreatePinHelperInput,\n UpdatePinRequest,\n UpdatePinHelperInput,\n SharePinRequest,\n ListPinsOptions,\n CreateMarkdownPinInput,\n CreateStatCardsPinInput,\n CreateTablePinInput,\n UpdateTablePinInput,\n CreateEmbedPinInput,\n} from '../../types/pins'\nimport type { PaginatedResponse } from '../../types/api'\nimport {\n attachNamedPinHelpers,\n toCreatePinRequest,\n toUpdatePinRequest,\n} from './pin-helper-core'\n\nexport class PinsMethods {\n constructor(private client: PindownClient) {}\n\n /** Create a pin (typed via CreatePinRequest<T>) */\n async create<T extends PinTypeId>(request: CreatePinRequest<T>): Promise<Pin<T>> {\n return this.client.request<Pin<T>>('POST', '/pins', request)\n }\n\n /** Create helper for any pin type via flat typed input. */\n async createPin<T extends PinTypeId>(\n pinType: T,\n input: CreatePinHelperInput<T>,\n ): Promise<Pin<T>> {\n return this.create(toCreatePinRequest(pinType, input))\n }\n\n async get<T extends PinTypeId = PinTypeId>(pinId: string): Promise<Pin<T>> {\n return this.client.request<Pin<T>>('GET', `/pins/${pinId}`)\n }\n\n async list(options?: ListPinsOptions): Promise<PaginatedResponse<Pin>> {\n const params = new URLSearchParams()\n if (options?.limit) params.append('limit', options.limit.toString())\n if (options?.offset) params.append('offset', options.offset.toString())\n\n const query = params.toString()\n const endpoint = query ? `/pins?${query}` : '/pins'\n\n return this.client.request<PaginatedResponse<Pin>>('GET', endpoint)\n }\n\n async update<T extends PinTypeId = PinTypeId>(pinId: string, request: UpdatePinRequest<T>): Promise<Pin<T>> {\n return this.client.request<Pin<T>>('PUT', `/pins/${pinId}`, request)\n }\n\n /** Update helper for any pin type via flat typed input. */\n async updatePin<T extends PinTypeId>(\n pinId: string,\n pinType: T,\n input: UpdatePinHelperInput<T>,\n ): Promise<Pin<T>> {\n return this.update(pinId, toUpdatePinRequest(pinType, input))\n }\n\n async delete(pinId: string): Promise<void> {\n return this.client.request<void>('DELETE', `/pins/${pinId}`)\n }\n\n async share(pinId: string, request: SharePinRequest): Promise<Pin> {\n return this.client.request<Pin>('POST', `/pins/${pinId}/share`, request)\n }\n\n async batchGet(pinIds: string[]): Promise<{\n found: Pin[]\n not_found: string[]\n permission_denied: string[]\n }> {\n return this.client.request('POST', '/pins/batch/get', { pin_ids: pinIds })\n }\n\n async batchCreate(pins: CreatePinRequest[]): Promise<{\n created: Array<{ id: string; index: number; created_at: number }>\n failed: Array<{ index: number; error: string }>\n }> {\n return this.client.request('POST', '/pins/batch', { pins })\n }\n\n async batchUpdate(updates: Array<{ id: string } & UpdatePinRequest>): Promise<{\n updated: string[]\n failed: Array<{ id: string; error: string }>\n updated_at: number\n }> {\n return this.client.request('PATCH', '/pins/batch', { updates })\n }\n\n async batchDelete(pinIds: string[]): Promise<{\n deleted: string[]\n failed: Array<{ id: string; error: string }>\n }> {\n return this.client.request('DELETE', '/pins/batch', { pin_ids: pinIds })\n }\n\n /** Create a markdown pin with pin_config.content (seeds Yjs on the server). */\n async createMarkdown(input: CreateMarkdownPinInput): Promise<Pin<'markdown'>> {\n const { content, title, tags, description, pin_layout, is_public, allow_edit, require_sign_in, allow_comments, pending_invites } = input\n return this.create({\n pin_type: 'markdown',\n pin_config: { content },\n pin_layout,\n is_public,\n allow_edit,\n require_sign_in,\n allow_comments,\n pending_invites,\n metadata: { title, tags, description },\n })\n }\n\n async createStatCards(input: CreateStatCardsPinInput): Promise<Pin<'stat-cards'>> {\n const { cards, title, tags, description, pin_layout, is_public } = input\n return this.create({\n pin_type: 'stat-cards',\n pin_config: { cards },\n pin_layout,\n is_public,\n metadata: { title, tags, description },\n })\n }\n\n async createTable(input: CreateTablePinInput): Promise<Pin<'table'>> {\n const { columns, rows, title, tags, description, pin_layout, is_public } = input\n return this.create({\n pin_type: 'table',\n pin_config: { columns, rows },\n pin_layout,\n is_public,\n metadata: { title, tags, description },\n })\n }\n\n /** Partial table pin_config update with typed columns/rows. */\n async updateTable(pinId: string, input: UpdateTablePinInput): Promise<Pin<'table'>> {\n return this.updatePin(pinId, 'table', input)\n }\n\n async createEmbed(input: CreateEmbedPinInput): Promise<Pin<'embed'>> {\n const { url, type, title, tags, description, pin_layout, is_public } = input\n return this.create({\n pin_type: 'embed',\n pin_config: { url, type },\n pin_layout,\n is_public,\n metadata: { title, tags, description },\n })\n }\n\n /**\n * @deprecated Use createMarkdown({ title, content, ... }) — old signature ignored content in title\n */\n async createMarkdownLegacy(title: string, additionalMetadata?: Record<string, unknown>): Promise<Pin<'markdown'>> {\n return this.createMarkdown({\n title,\n content: '',\n ...(additionalMetadata as Partial<CreateMarkdownPinInput>),\n })\n }\n}\n\nattachNamedPinHelpers(PinsMethods as unknown as { prototype: Record<string, unknown> })\n","/**\n * Error classes for the v1 Pins API client\n */\n\nexport class PindownError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'PindownError'\n }\n}\n\nexport class AuthenticationError extends PindownError {\n constructor(message: string = 'Authentication failed') {\n super(message)\n this.name = 'AuthenticationError'\n }\n}\n\nexport class ForbiddenError extends PindownError {\n constructor(message: string = 'Access forbidden') {\n super(message)\n this.name = 'ForbiddenError'\n }\n}\n\nexport class NotFoundError extends PindownError {\n constructor(resource: string) {\n super(`${resource} not found`)\n this.name = 'NotFoundError'\n }\n}\n\nexport class ValidationError extends PindownError {\n public details?: unknown\n\n constructor(message: string, details?: unknown) {\n super(message)\n this.name = 'ValidationError'\n this.details = details\n }\n}\n\nexport class RateLimitError extends PindownError {\n constructor(message: string = 'Rate limit exceeded (429 RATE_LIMITED)') {\n super(message)\n this.name = 'RateLimitError'\n }\n}\n\nexport class ServerError extends PindownError {\n public statusCode: number\n\n constructor(message: string, statusCode: number = 500) {\n super(message)\n this.name = 'ServerError'\n this.statusCode = statusCode\n }\n}\n\nexport class NetworkError extends PindownError {\n constructor(message: string = 'Network request failed') {\n super(message)\n this.name = 'NetworkError'\n }\n}\n","/**\n * Pindown API Client — v1 Pins API only\n */\n\nimport { PinsMethods } from './pins'\nimport type { PindownConfig } from '../types/config'\nimport {\n AuthenticationError,\n ForbiddenError,\n NotFoundError,\n ValidationError,\n RateLimitError,\n ServerError,\n NetworkError,\n} from '../errors'\n\nexport class PindownClient {\n private config: Required<Omit<PindownConfig, 'baseURL'>> & { baseURL: string }\n\n public readonly pins: PinsMethods\n\n constructor(config: PindownConfig) {\n if (!config.apiKey) {\n throw new Error('API key is required')\n }\n\n this.config = {\n apiKey: config.apiKey,\n baseURL: config.baseURL || 'https://api.pindown.ai/v1',\n maxRetries: config.maxRetries ?? 3,\n timeout: config.timeout ?? 30000,\n }\n\n this.pins = new PinsMethods(this)\n }\n\n async request<T = unknown>(method: string, endpoint: string, data?: unknown): Promise<T> {\n const url = `${this.config.baseURL}${endpoint}`\n const headers: Record<string, string> = {\n Authorization: `Bearer ${this.config.apiKey}`,\n }\n\n if (data && (method === 'POST' || method === 'PUT' || method === 'PATCH' || method === 'DELETE')) {\n headers['Content-Type'] = 'application/json'\n }\n\n const requestOptions: RequestInit = {\n method,\n headers,\n signal: AbortSignal.timeout(this.config.timeout),\n }\n\n if (data && (method === 'POST' || method === 'PUT' || method === 'PATCH' || method === 'DELETE')) {\n requestOptions.body = JSON.stringify(data)\n }\n\n try {\n const response = await fetch(url, requestOptions)\n\n if (!response.ok) {\n await this.handleErrorResponse(response)\n }\n\n const result = await response.json()\n return result.data as T\n } catch (error: unknown) {\n if (\n error instanceof AuthenticationError ||\n error instanceof ForbiddenError ||\n error instanceof NotFoundError ||\n error instanceof ValidationError ||\n error instanceof RateLimitError ||\n error instanceof ServerError\n ) {\n throw error\n }\n\n if (error instanceof Error && (error.name === 'AbortError' || error.name === 'TimeoutError')) {\n throw new NetworkError('Request timeout')\n }\n\n throw new NetworkError(error instanceof Error ? error.message : 'Network request failed')\n }\n }\n\n private async handleErrorResponse(response: Response): Promise<never> {\n let errorData: { error?: { code?: string; message?: string; details?: unknown }; message?: string }\n\n try {\n errorData = await response.json()\n } catch {\n errorData = { message: response.statusText }\n }\n\n const message = errorData.error?.message || errorData.message || 'Unknown error'\n\n switch (response.status) {\n case 401:\n throw new AuthenticationError(message)\n case 403:\n throw new ForbiddenError(message)\n case 404:\n throw new NotFoundError(message)\n case 400:\n case 422:\n throw new ValidationError(message, errorData.error?.details)\n case 429:\n throw new RateLimitError(message)\n case 500:\n case 502:\n case 503:\n throw new ServerError(message, response.status)\n default:\n throw new ServerError(message, response.status)\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"]}
|