@pindownai/client-js 1.3.2 → 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 +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +37 -7
- package/dist/index.d.ts +37 -7
- package/dist/index.js +4 -4
- 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,8 +1,8 @@
|
|
|
1
|
-
'use strict';var y=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 i=new URLSearchParams;e?.limit&&i.append("limit",e.limit.toString()),e?.offset&&i.append("offset",e.offset.toString());let n=i.toString(),
|
|
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
2
|
|
|
3
3
|
Body text.`},example_update:{pin_config:{content:`# Updated
|
|
4
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(
|
|
6
|
-
`):[`No built-in hint for pin type "${
|
|
7
|
-
`)}exports.AuthenticationError=
|
|
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
|
|
8
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","../src/pin-config-hints.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","pin_config","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","pinType","formatPinConfigHint","hint","f"],"mappings":"aAqBO,IAAMA,CAAAA,CAAN,KAAkB,CACvB,WAAA,CAAoBC,CAAAA,CAAuB,CAAvB,IAAA,CAAA,MAAA,CAAAA,EAAwB,CAG5C,MAAM,MAAA,CAA4BC,CAAAA,CAA+C,CAC/E,OAAO,IAAA,CAAK,MAAA,CAAO,OAAA,CAAgB,MAAA,CAAQ,OAAA,CAASA,CAAO,CAC7D,CAEA,MAAM,GAAA,CAAqCC,CAAAA,CAAgC,CACzE,OAAO,IAAA,CAAK,OAAO,OAAA,CAAgB,KAAA,C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AAgB,IAAA,CAAM,CAAC,CAC7C,EACa,IAAA,CAAK;AAAA,CAAI,CAAA,CAzBb,CACL,CAAA,+BAAA,EAAkCF,CAAO,KACzC,uFAAA,CACA,kFACF,EAAE,IAAA,CAAK;AAAA,CAAI,CAsBf","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 UpdateTablePinInput,\n CreateEmbedPinInput,\n TablePinConfig,\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 /** Partial table pin_config update with typed columns/rows. */\n async updateTable(pinId: string, input: UpdateTablePinInput): Promise<Pin<'table'>> {\n const { columns, rows, title, tags, description } = input\n const pin_config: Partial<TablePinConfig> = {}\n if (columns !== undefined) pin_config.columns = columns\n if (rows !== undefined) pin_config.rows = rows\n\n return this.update<'table'>(pinId, {\n pin_config: pin_config as TablePinConfig,\n ...(title !== undefined || tags !== undefined || description !== undefined\n ? { metadata: { ...(title !== undefined && { title }), ...(tags !== undefined && { tags }), ...(description !== undefined && { description }) } }\n : {}),\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","/**\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"]}
|
|
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,CA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EAAK,QAAQ,CAAA,CAAA,CAC1BA,CAAAA,CAAK,OAAA,CACL,GACA,6BAAA,CACA,GAAGA,CAAAA,CAAK,eAAA,CAAgB,IAAKC,CAAAA,EAAM,CAAA,IAAA,EAAOA,CAAC,CAAA,CAAE,EAC7C,EAAA,CACA,6BAAA,CACA,GAAID,CAAAA,CAAK,gBAAgB,MAAA,CAASA,CAAAA,CAAK,eAAA,CAAgB,GAAA,CAAKC,GAAM,CAAA,IAAA,EAAOA,CAAC,CAAA,CAAE,CAAA,CAAI,CAAC,qBAAqB,CAAA,CACtG,EAAA,CACA,kBAAA,CACA,GAAGD,CAAAA,CAAK,MAAA,CAAO,GAAA,CACZC,CAAAA,EAAM,KAAKA,CAAAA,CAAE,IAAI,CAAA,EAAA,EAAKA,CAAAA,CAAE,IAAI,CAAA,EAAGA,CAAAA,CAAE,QAAA,CAAW,YAAA,CAAe,EAAE,CAAA,GAAA,EAAMA,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
|
@@ -507,6 +507,25 @@ interface ListPinsOptions {
|
|
|
507
507
|
limit?: number;
|
|
508
508
|
offset?: number;
|
|
509
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]>;
|
|
510
529
|
interface CreateMarkdownPinInput extends PinMetadataBase {
|
|
511
530
|
content: string;
|
|
512
531
|
pin_layout?: PinLayout;
|
|
@@ -527,12 +546,7 @@ interface CreateTablePinInput extends PinMetadataBase {
|
|
|
527
546
|
pin_layout?: PinLayout;
|
|
528
547
|
is_public?: boolean;
|
|
529
548
|
}
|
|
530
|
-
interface UpdateTablePinInput {
|
|
531
|
-
columns?: TableColumn[];
|
|
532
|
-
rows?: TableRow[];
|
|
533
|
-
title?: string;
|
|
534
|
-
tags?: string[];
|
|
535
|
-
description?: string;
|
|
549
|
+
interface UpdateTablePinInput extends UpdatePinHelperInput<'table'> {
|
|
536
550
|
}
|
|
537
551
|
interface CreateEmbedPinInput extends PinMetadataBase {
|
|
538
552
|
url: string;
|
|
@@ -569,9 +583,13 @@ declare class PinsMethods {
|
|
|
569
583
|
constructor(client: PindownClient);
|
|
570
584
|
/** Create a pin (typed via CreatePinRequest<T>) */
|
|
571
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>>;
|
|
572
588
|
get<T extends PinTypeId = PinTypeId>(pinId: string): Promise<Pin<T>>;
|
|
573
589
|
list(options?: ListPinsOptions): Promise<PaginatedResponse<Pin>>;
|
|
574
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>>;
|
|
575
593
|
delete(pinId: string): Promise<void>;
|
|
576
594
|
share(pinId: string, request: SharePinRequest): Promise<Pin>;
|
|
577
595
|
batchGet(pinIds: string[]): Promise<{
|
|
@@ -646,6 +664,18 @@ declare class PindownClient {
|
|
|
646
664
|
private handleErrorResponse;
|
|
647
665
|
}
|
|
648
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
|
+
|
|
649
679
|
/**
|
|
650
680
|
* Runtime hints + minimal examples per pin type.
|
|
651
681
|
* Use when building API payloads without opening the docs every time.
|
|
@@ -704,4 +734,4 @@ declare class NetworkError extends PindownError {
|
|
|
704
734
|
constructor(message?: string);
|
|
705
735
|
}
|
|
706
736
|
|
|
707
|
-
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 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 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 UpdateTablePinInput, type UserStoryPinConfig, ValidationError, type VideoPinConfig, formatPinConfigHint, getPinConfigHint };
|
|
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
|
@@ -507,6 +507,25 @@ interface ListPinsOptions {
|
|
|
507
507
|
limit?: number;
|
|
508
508
|
offset?: number;
|
|
509
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]>;
|
|
510
529
|
interface CreateMarkdownPinInput extends PinMetadataBase {
|
|
511
530
|
content: string;
|
|
512
531
|
pin_layout?: PinLayout;
|
|
@@ -527,12 +546,7 @@ interface CreateTablePinInput extends PinMetadataBase {
|
|
|
527
546
|
pin_layout?: PinLayout;
|
|
528
547
|
is_public?: boolean;
|
|
529
548
|
}
|
|
530
|
-
interface UpdateTablePinInput {
|
|
531
|
-
columns?: TableColumn[];
|
|
532
|
-
rows?: TableRow[];
|
|
533
|
-
title?: string;
|
|
534
|
-
tags?: string[];
|
|
535
|
-
description?: string;
|
|
549
|
+
interface UpdateTablePinInput extends UpdatePinHelperInput<'table'> {
|
|
536
550
|
}
|
|
537
551
|
interface CreateEmbedPinInput extends PinMetadataBase {
|
|
538
552
|
url: string;
|
|
@@ -569,9 +583,13 @@ declare class PinsMethods {
|
|
|
569
583
|
constructor(client: PindownClient);
|
|
570
584
|
/** Create a pin (typed via CreatePinRequest<T>) */
|
|
571
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>>;
|
|
572
588
|
get<T extends PinTypeId = PinTypeId>(pinId: string): Promise<Pin<T>>;
|
|
573
589
|
list(options?: ListPinsOptions): Promise<PaginatedResponse<Pin>>;
|
|
574
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>>;
|
|
575
593
|
delete(pinId: string): Promise<void>;
|
|
576
594
|
share(pinId: string, request: SharePinRequest): Promise<Pin>;
|
|
577
595
|
batchGet(pinIds: string[]): Promise<{
|
|
@@ -646,6 +664,18 @@ declare class PindownClient {
|
|
|
646
664
|
private handleErrorResponse;
|
|
647
665
|
}
|
|
648
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
|
+
|
|
649
679
|
/**
|
|
650
680
|
* Runtime hints + minimal examples per pin type.
|
|
651
681
|
* Use when building API payloads without opening the docs every time.
|
|
@@ -704,4 +734,4 @@ declare class NetworkError extends PindownError {
|
|
|
704
734
|
constructor(message?: string);
|
|
705
735
|
}
|
|
706
736
|
|
|
707
|
-
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 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 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 UpdateTablePinInput, type UserStoryPinConfig, ValidationError, type VideoPinConfig, formatPinConfigHint, getPinConfigHint };
|
|
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,8 +1,8 @@
|
|
|
1
|
-
var y=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 i=new URLSearchParams;e?.limit&&i.append("limit",e.limit.toString()),e?.offset&&i.append("offset",e.offset.toString());let n=i.toString(),
|
|
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
2
|
|
|
3
3
|
Body text.`},example_update:{pin_config:{content:`# Updated
|
|
4
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(
|
|
6
|
-
`):[`No built-in hint for pin type "${
|
|
7
|
-
`)}export{
|
|
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
|
|
8
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","../src/pin-config-hints.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","pin_config","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","pinType","formatPinConfigHint","hint","f"],"mappings":"AAqBO,IAAMA,CAAAA,CAAN,KAAkB,CACvB,WAAA,CAAoBC,CAAAA,CAAuB,CAAvB,IAAA,CAAA,MAAA,CAAAA,EAAwB,CAG5C,MAAM,MAAA,CAA4BC,CAAAA,CAA+C,CAC/E,OAAO,IAAA,CAAK,MAAA,CAAO,OAAA,CAAgB,MAAA,CAA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AE,CAAA,GAAA,EAAMA,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,EAAkCF,CAAO,KACzC,uFAAA,CACA,kFACF,EAAE,IAAA,CAAK;AAAA,CAAI,CAsBf","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 UpdateTablePinInput,\n CreateEmbedPinInput,\n TablePinConfig,\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 /** Partial table pin_config update with typed columns/rows. */\n async updateTable(pinId: string, input: UpdateTablePinInput): Promise<Pin<'table'>> {\n const { columns, rows, title, tags, description } = input\n const pin_config: Partial<TablePinConfig> = {}\n if (columns !== undefined) pin_config.columns = columns\n if (rows !== undefined) pin_config.rows = rows\n\n return this.update<'table'>(pinId, {\n pin_config: pin_config as TablePinConfig,\n ...(title !== undefined || tags !== undefined || description !== undefined\n ? { metadata: { ...(title !== undefined && { title }), ...(tags !== undefined && { tags }), ...(description !== undefined && { description }) } }\n : {}),\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","/**\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"]}
|
|
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,C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AAA,CAA4B,CAC9D,IAAMmE,CAAAA,CAAOF,CAAAA,CAAiBjE,CAAO,EACrC,OAAKmE,CAAAA,CAQS,CACZ,CAAA,UAAA,EAAaA,EAAK,QAAQ,CAAA,CAAA,CAC1BA,CAAAA,CAAK,OAAA,CACL,GACA,6BAAA,CACA,GAAGA,CAAAA,CAAK,eAAA,CAAgB,IAAKC,CAAAA,EAAM,CAAA,IAAA,EAAOA,CAAC,CAAA,CAAE,EAC7C,EAAA,CACA,6BAAA,CACA,GAAID,CAAAA,CAAK,gBAAgB,MAAA,CAASA,CAAAA,CAAK,eAAA,CAAgB,GAAA,CAAKC,GAAM,CAAA,IAAA,EAAOA,CAAC,CAAA,CAAE,CAAA,CAAI,CAAC,qBAAqB,CAAA,CACtG,EAAA,CACA,kBAAA,CACA,GAAGD,CAAAA,CAAK,MAAA,CAAO,GAAA,CACZC,CAAAA,EAAM,KAAKA,CAAAA,CAAE,IAAI,CAAA,EAAA,EAAKA,CAAAA,CAAE,IAAI,CAAA,EAAGA,CAAAA,CAAE,QAAA,CAAW,YAAA,CAAe,EAAE,CAAA,GAAA,EAAMA,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.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"]}
|