@pindownai/client-js 1.3.1 → 1.3.2

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/dist/index.cjs CHANGED
@@ -1,3 +1,8 @@
1
- 'use strict';var C=class{constructor(e){this.client=e;}async create(e){return this.client.request("POST","/pins",e)}async get(e){return this.client.request("GET",`/pins/${e}`)}async list(e){let n=new URLSearchParams;e?.limit&&n.append("limit",e.limit.toString()),e?.offset&&n.append("offset",e.offset.toString());let i=n.toString(),r=i?`/pins?${i}`:"/pins";return this.client.request("GET",r)}async update(e,n){return this.client.request("PUT",`/pins/${e}`,n)}async delete(e){return this.client.request("DELETE",`/pins/${e}`)}async share(e,n){return this.client.request("POST",`/pins/${e}/share`,n)}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:n,title:i,tags:r,description:s,pin_layout:a,is_public:t,allow_edit:d,require_sign_in:w,allow_comments:h,pending_invites:T}=e;return this.create({pin_type:"markdown",pin_config:{content:n},pin_layout:a,is_public:t,allow_edit:d,require_sign_in:w,allow_comments:h,pending_invites:T,metadata:{title:i,tags:r,description:s}})}async createStatCards(e){let{cards:n,title:i,tags:r,description:s,pin_layout:a,is_public:t}=e;return this.create({pin_type:"stat-cards",pin_config:{cards:n},pin_layout:a,is_public:t,metadata:{title:i,tags:r,description:s}})}async createTable(e){let{columns:n,rows:i,title:r,tags:s,description:a,pin_layout:t,is_public:d}=e;return this.create({pin_type:"table",pin_config:{columns:n,rows:i},pin_layout:t,is_public:d,metadata:{title:r,tags:s,description:a}})}async createEmbed(e){let{url:n,type:i,title:r,tags:s,description:a,pin_layout:t,is_public:d}=e;return this.create({pin_type:"embed",pin_config:{url:n,type:i},pin_layout:t,is_public:d,metadata:{title:r,tags:s,description:a}})}async createMarkdownLegacy(e,n){return this.createMarkdown({title:e,content:"",...n})}};var o=class extends Error{constructor(e){super(e),this.name="PindownError";}},P=class extends o{constructor(e="Authentication failed"){super(e),this.name="AuthenticationError";}},u=class extends o{constructor(e="Access forbidden"){super(e),this.name="ForbiddenError";}},g=class extends o{constructor(e){super(`${e} not found`),this.name="NotFoundError";}},l=class extends o{constructor(e,n){super(e),this.name="ValidationError",this.details=n;}},m=class extends o{constructor(e="Rate limit exceeded (429 RATE_LIMITED)"){super(e),this.name="RateLimitError";}},p=class extends o{constructor(e,n=500){super(e),this.name="ServerError",this.statusCode=n;}},f=class extends o{constructor(e="Network request failed"){super(e),this.name="NetworkError";}};var y=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 C(this);}async request(e,n,i){let r=`${this.config.baseURL}${n}`,s={Authorization:`Bearer ${this.config.apiKey}`};i&&(e==="POST"||e==="PUT"||e==="PATCH"||e==="DELETE")&&(s["Content-Type"]="application/json");let a={method:e,headers:s,signal:AbortSignal.timeout(this.config.timeout)};i&&(e==="POST"||e==="PUT"||e==="PATCH"||e==="DELETE")&&(a.body=JSON.stringify(i));try{let t=await fetch(r,a);return t.ok||await this.handleErrorResponse(t),(await t.json()).data}catch(t){throw t instanceof P||t instanceof u||t instanceof g||t instanceof l||t instanceof m||t instanceof p?t:t instanceof Error&&(t.name==="AbortError"||t.name==="TimeoutError")?new f("Request timeout"):new f(t instanceof Error?t.message:"Network request failed")}}async handleErrorResponse(e){let n;try{n=await e.json();}catch{n={message:e.statusText};}let i=n.error?.message||n.message||"Unknown error";switch(e.status){case 401:throw new P(i);case 403:throw new u(i);case 404:throw new g(i);case 400:case 422:throw new l(i,n.error?.details);case 429:throw new m(i);case 500:case 502:case 503:throw new p(i,e.status);default:throw new p(i,e.status)}}};
2
- exports.AuthenticationError=P;exports.ForbiddenError=u;exports.NetworkError=f;exports.NotFoundError=g;exports.PindownClient=y;exports.PindownError=o;exports.RateLimitError=m;exports.ServerError=p;exports.ValidationError=l;//# sourceMappingURL=index.cjs.map
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(),s=n?`/pins?${n}`:"/pins";return this.client.request("GET",s)}async update(e,i){return this.client.request("PUT",`/pins/${e}`,i)}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:s,description:a,pin_layout:o,is_public:t,allow_edit:d,require_sign_in:w,allow_comments:b,pending_invites:_}=e;return this.create({pin_type:"markdown",pin_config:{content:i},pin_layout:o,is_public:t,allow_edit:d,require_sign_in:w,allow_comments:b,pending_invites:_,metadata:{title:n,tags:s,description:a}})}async createStatCards(e){let{cards:i,title:n,tags:s,description:a,pin_layout:o,is_public:t}=e;return this.create({pin_type:"stat-cards",pin_config:{cards:i},pin_layout:o,is_public:t,metadata:{title:n,tags:s,description:a}})}async createTable(e){let{columns:i,rows:n,title:s,tags:a,description:o,pin_layout:t,is_public:d}=e;return this.create({pin_type:"table",pin_config:{columns:i,rows:n},pin_layout:t,is_public:d,metadata:{title:s,tags:a,description:o}})}async updateTable(e,i){let{columns:n,rows:s,title:a,tags:o,description:t}=i,d={};return n!==void 0&&(d.columns=n),s!==void 0&&(d.rows=s),this.update(e,{pin_config:d,...a!==void 0||o!==void 0||t!==void 0?{metadata:{...a!==void 0&&{title:a},...o!==void 0&&{tags:o},...t!==void 0&&{description:t}}}:{}})}async createEmbed(e){let{url:i,type:n,title:s,tags:a,description:o,pin_layout:t,is_public:d}=e;return this.create({pin_type:"embed",pin_config:{url:i,type:n},pin_layout:t,is_public:d,metadata:{title:s,tags:a,description:o}})}async createMarkdownLegacy(e,i){return this.createMarkdown({title:e,content:"",...i})}};var p=class extends Error{constructor(e){super(e),this.name="PindownError";}},u=class extends p{constructor(e="Authentication failed"){super(e),this.name="AuthenticationError";}},l=class extends p{constructor(e="Access forbidden"){super(e),this.name="ForbiddenError";}},P=class extends p{constructor(e){super(`${e} not found`),this.name="NotFoundError";}},f=class extends p{constructor(e,i){super(e),this.name="ValidationError",this.details=i;}},g=class extends p{constructor(e="Rate limit exceeded (429 RATE_LIMITED)"){super(e),this.name="RateLimitError";}},c=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 C=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 s=`${this.config.baseURL}${i}`,a={Authorization:`Bearer ${this.config.apiKey}`};n&&(e==="POST"||e==="PUT"||e==="PATCH"||e==="DELETE")&&(a["Content-Type"]="application/json");let o={method:e,headers:a,signal:AbortSignal.timeout(this.config.timeout)};n&&(e==="POST"||e==="PUT"||e==="PATCH"||e==="DELETE")&&(o.body=JSON.stringify(n));try{let t=await fetch(s,o);return t.ok||await this.handleErrorResponse(t),(await t.json()).data}catch(t){throw t instanceof u||t instanceof l||t instanceof P||t instanceof f||t instanceof g||t instanceof c?t:t instanceof Error&&(t.name==="AbortError"||t.name==="TimeoutError")?new m("Request timeout"):new m(t instanceof Error?t.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 u(n);case 403:throw new l(n);case 404:throw new P(n);case 400:case 422:throw new f(n,i.error?.details);case 429:throw new g(n);case 500:case 502:case 503:throw new c(n,e.status);default:throw new c(n,e.status)}}};var x={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}}]}}},T={table:x,markdown:{pin_type:"markdown",summary:"Rich text / markdown body.",required_fields:[],optional_fields:["content","collaboration"],fields:[{path:"content",type:"string",required:false,description:"Markdown source. Server seeds Yjs when set on create."}],example_config:{content:`# Hello
2
+
3
+ Body text.`},example_update:{pin_config:{content:`# Updated
4
+
5
+ New body.`}}},"stat-cards":{pin_type:"stat-cards",summary:"KPI cards grid.",required_fields:["cards"],optional_fields:[],fields:[{path:"cards",type:"StatCardItem[]",required:true,description:"Each card: title, value; optional change, trend (up|down|neutral)."}],example_config:{cards:[{title:"Revenue",value:"1000",change:"+5%",trend:"up"}]},example_update:{pin_config:{cards:[{title:"Revenue",value:"1234",change:"+8%",trend:"up"}]}}}};function h(r){return T[r]}function I(r){let e=h(r);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 "${r}".`,"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=u;exports.ForbiddenError=l;exports.NetworkError=m;exports.NotFoundError=P;exports.PIN_CONFIG_HINTS=T;exports.PindownClient=C;exports.PindownError=p;exports.RateLimitError=g;exports.ServerError=c;exports.ValidationError=f;exports.formatPinConfigHint=I;exports.getPinConfigHint=h;//# sourceMappingURL=index.cjs.map
3
8
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/client/pins/index.ts","../src/errors/index.ts","../src/client/PindownClient.ts"],"names":["PinsMethods","client","request","pinId","options","params","query","endpoint","pinIds","pins","updates","input","content","title","tags","description","pin_layout","is_public","allow_edit","require_sign_in","allow_comments","pending_invites","cards","columns","rows","url","type","additionalMetadata","PindownError","message","AuthenticationError","ForbiddenError","NotFoundError","resource","ValidationError","details","RateLimitError","ServerError","statusCode","NetworkError","PindownClient","config","method","data","headers","requestOptions","response","error","errorData"],"mappings":"aAmBO,IAAMA,CAAAA,CAAN,KAAkB,CACvB,WAAA,CAAoBC,EAAuB,CAAvB,IAAA,CAAA,MAAA,CAAAA,EAAwB,CAG5C,MAAM,OAA4BC,CAAAA,CAA+C,CAC/E,OAAO,IAAA,CAAK,MAAA,CAAO,QAAgB,MAAA,CAAQ,OAAA,CAASA,CAAO,CAC7D,CAEA,MAAM,IAAqCC,CAAAA,CAAgC,CACzE,OAAO,IAAA,CAAK,MAAA,CAAO,QAAgB,KAAA,CAAO,CAAA,MAAA,EAASA,CAAK,CAAA,CAAE,CAC5D,CAEA,MAAM,IAAA,CAAKC,CAAAA,CAA4D,CACrE,IAAMC,CAAA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OAAO,CAAA,CAC7D,KAAK,GAAA,CACH,MAAM,IAAIZ,CAAAA,CAAeP,CAAO,CAAA,CAClC,SACA,KAAK,GAAA,CACL,KAAK,GAAA,CACH,MAAM,IAAIQ,CAAAA,CAAYR,CAAAA,CAASiB,CAAAA,CAAS,MAAM,CAAA,CAChD,QACE,MAAM,IAAIT,CAAAA,CAAYR,EAASiB,CAAAA,CAAS,MAAM,CAClD,CACF,CACF","file":"index.cjs","sourcesContent":["/**\n * Pins API Methods\n */\n\nimport type { PindownClient } from '../PindownClient'\nimport type {\n Pin,\n PinTypeId,\n CreatePinRequest,\n UpdatePinRequest,\n SharePinRequest,\n ListPinsOptions,\n CreateMarkdownPinInput,\n CreateStatCardsPinInput,\n CreateTablePinInput,\n CreateEmbedPinInput,\n} from '../../types/pins'\nimport type { PaginatedResponse } from '../../types/api'\n\nexport class PinsMethods {\n constructor(private client: PindownClient) {}\n\n /** Create a pin (typed via CreatePinRequest&lt;T&gt;) */\n async create<T extends PinTypeId>(request: CreatePinRequest<T>): Promise<Pin<T>> {\n return this.client.request<Pin<T>>('POST', '/pins', request)\n }\n\n async get<T extends PinTypeId = PinTypeId>(pinId: string): Promise<Pin<T>> {\n return this.client.request<Pin<T>>('GET', `/pins/${pinId}`)\n }\n\n async list(options?: ListPinsOptions): Promise<PaginatedResponse<Pin>> {\n const params = new URLSearchParams()\n if (options?.limit) params.append('limit', options.limit.toString())\n if (options?.offset) params.append('offset', options.offset.toString())\n\n const query = params.toString()\n const endpoint = query ? `/pins?${query}` : '/pins'\n\n return this.client.request<PaginatedResponse<Pin>>('GET', endpoint)\n }\n\n async update<T extends PinTypeId = PinTypeId>(pinId: string, request: UpdatePinRequest<T>): Promise<Pin<T>> {\n return this.client.request<Pin<T>>('PUT', `/pins/${pinId}`, request)\n }\n\n async delete(pinId: string): Promise<void> {\n return this.client.request<void>('DELETE', `/pins/${pinId}`)\n }\n\n async share(pinId: string, request: SharePinRequest): Promise<Pin> {\n return this.client.request<Pin>('POST', `/pins/${pinId}/share`, request)\n }\n\n async batchGet(pinIds: string[]): Promise<{\n found: Pin[]\n not_found: string[]\n permission_denied: string[]\n }> {\n return this.client.request('POST', '/pins/batch/get', { pin_ids: pinIds })\n }\n\n async batchCreate(pins: CreatePinRequest[]): Promise<{\n created: Array<{ id: string; index: number; created_at: number }>\n failed: Array<{ index: number; error: string }>\n }> {\n return this.client.request('POST', '/pins/batch', { pins })\n }\n\n async batchUpdate(updates: Array<{ id: string } & UpdatePinRequest>): Promise<{\n updated: string[]\n failed: Array<{ id: string; error: string }>\n updated_at: number\n }> {\n return this.client.request('PATCH', '/pins/batch', { updates })\n }\n\n async batchDelete(pinIds: string[]): Promise<{\n deleted: string[]\n failed: Array<{ id: string; error: string }>\n }> {\n return this.client.request('DELETE', '/pins/batch', { pin_ids: pinIds })\n }\n\n /** Create a markdown pin with pin_config.content (seeds Yjs on the server). */\n async createMarkdown(input: CreateMarkdownPinInput): Promise<Pin<'markdown'>> {\n const { content, title, tags, description, pin_layout, is_public, allow_edit, require_sign_in, allow_comments, pending_invites } = input\n return this.create({\n pin_type: 'markdown',\n pin_config: { content },\n pin_layout,\n is_public,\n allow_edit,\n require_sign_in,\n allow_comments,\n pending_invites,\n metadata: { title, tags, description },\n })\n }\n\n async createStatCards(input: CreateStatCardsPinInput): Promise<Pin<'stat-cards'>> {\n const { cards, title, tags, description, pin_layout, is_public } = input\n return this.create({\n pin_type: 'stat-cards',\n pin_config: { cards },\n pin_layout,\n is_public,\n metadata: { title, tags, description },\n })\n }\n\n async createTable(input: CreateTablePinInput): Promise<Pin<'table'>> {\n const { columns, rows, title, tags, description, pin_layout, is_public } = input\n return this.create({\n pin_type: 'table',\n pin_config: { columns, rows },\n pin_layout,\n is_public,\n metadata: { title, tags, description },\n })\n }\n\n async createEmbed(input: CreateEmbedPinInput): Promise<Pin<'embed'>> {\n const { url, type, title, tags, description, pin_layout, is_public } = input\n return this.create({\n pin_type: 'embed',\n pin_config: { url, type },\n pin_layout,\n is_public,\n metadata: { title, tags, description },\n })\n }\n\n /**\n * @deprecated Use createMarkdown({ title, content, ... }) — old signature ignored content in title\n */\n async createMarkdownLegacy(title: string, additionalMetadata?: Record<string, unknown>): Promise<Pin<'markdown'>> {\n return this.createMarkdown({\n title,\n content: '',\n ...(additionalMetadata as Partial<CreateMarkdownPinInput>),\n })\n }\n}\n","/**\n * Error classes for the v1 Pins API client\n */\n\nexport class PindownError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'PindownError'\n }\n}\n\nexport class AuthenticationError extends PindownError {\n constructor(message: string = 'Authentication failed') {\n super(message)\n this.name = 'AuthenticationError'\n }\n}\n\nexport class ForbiddenError extends PindownError {\n constructor(message: string = 'Access forbidden') {\n super(message)\n this.name = 'ForbiddenError'\n }\n}\n\nexport class NotFoundError extends PindownError {\n constructor(resource: string) {\n super(`${resource} not found`)\n this.name = 'NotFoundError'\n }\n}\n\nexport class ValidationError extends PindownError {\n public details?: unknown\n\n constructor(message: string, details?: unknown) {\n super(message)\n this.name = 'ValidationError'\n this.details = details\n }\n}\n\nexport class RateLimitError extends PindownError {\n constructor(message: string = 'Rate limit exceeded (429 RATE_LIMITED)') {\n super(message)\n this.name = 'RateLimitError'\n }\n}\n\nexport class ServerError extends PindownError {\n public statusCode: number\n\n constructor(message: string, statusCode: number = 500) {\n super(message)\n this.name = 'ServerError'\n this.statusCode = statusCode\n }\n}\n\nexport class NetworkError extends PindownError {\n constructor(message: string = 'Network request failed') {\n super(message)\n this.name = 'NetworkError'\n }\n}\n","/**\n * Pindown API Client — v1 Pins API only\n */\n\nimport { PinsMethods } from './pins'\nimport type { PindownConfig } from '../types/config'\nimport {\n AuthenticationError,\n ForbiddenError,\n NotFoundError,\n ValidationError,\n RateLimitError,\n ServerError,\n NetworkError,\n} from '../errors'\n\nexport class PindownClient {\n private config: Required<Omit<PindownConfig, 'baseURL'>> & { baseURL: string }\n\n public readonly pins: PinsMethods\n\n constructor(config: PindownConfig) {\n if (!config.apiKey) {\n throw new Error('API key is required')\n }\n\n this.config = {\n apiKey: config.apiKey,\n baseURL: config.baseURL || 'https://api.pindown.ai/v1',\n maxRetries: config.maxRetries ?? 3,\n timeout: config.timeout ?? 30000,\n }\n\n this.pins = new PinsMethods(this)\n }\n\n async request<T = unknown>(method: string, endpoint: string, data?: unknown): Promise<T> {\n const url = `${this.config.baseURL}${endpoint}`\n const headers: Record<string, string> = {\n Authorization: `Bearer ${this.config.apiKey}`,\n }\n\n if (data && (method === 'POST' || method === 'PUT' || method === 'PATCH' || method === 'DELETE')) {\n headers['Content-Type'] = 'application/json'\n }\n\n const requestOptions: RequestInit = {\n method,\n headers,\n signal: AbortSignal.timeout(this.config.timeout),\n }\n\n if (data && (method === 'POST' || method === 'PUT' || method === 'PATCH' || method === 'DELETE')) {\n requestOptions.body = JSON.stringify(data)\n }\n\n try {\n const response = await fetch(url, requestOptions)\n\n if (!response.ok) {\n await this.handleErrorResponse(response)\n }\n\n const result = await response.json()\n return result.data as T\n } catch (error: unknown) {\n if (\n error instanceof AuthenticationError ||\n error instanceof ForbiddenError ||\n error instanceof NotFoundError ||\n error instanceof ValidationError ||\n error instanceof RateLimitError ||\n error instanceof ServerError\n ) {\n throw error\n }\n\n if (error instanceof Error && (error.name === 'AbortError' || error.name === 'TimeoutError')) {\n throw new NetworkError('Request timeout')\n }\n\n throw new NetworkError(error instanceof Error ? error.message : 'Network request failed')\n }\n }\n\n private async handleErrorResponse(response: Response): Promise<never> {\n let errorData: { error?: { code?: string; message?: string; details?: unknown }; message?: string }\n\n try {\n errorData = await response.json()\n } catch {\n errorData = { message: response.statusText }\n }\n\n const message = errorData.error?.message || errorData.message || 'Unknown error'\n\n switch (response.status) {\n case 401:\n throw new AuthenticationError(message)\n case 403:\n throw new ForbiddenError(message)\n case 404:\n throw new NotFoundError(message)\n case 400:\n case 422:\n throw new ValidationError(message, errorData.error?.details)\n case 429:\n throw new RateLimitError(message)\n case 500:\n case 502:\n case 503:\n throw new ServerError(message, response.status)\n default:\n throw new ServerError(message, response.status)\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/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,CAAO,CAAA,MAAA,EAASA,CAAK,CAAA,CAAE,CAC5D,CAEA,MAAM,IAAA,CAAKC,CAAAA,CAA4D,CACrE,IAAMC,CAAAA,CAAS,IAAI,eAAA,CACfD,CAAAA,EAAS,OAAOC,CAAAA,CAAO,MAAA,CAAO,OAAA,CAASD,CAAAA,CAAQ,KAAA,CAAM,QAAA,EAAU,CAAA,CAC/DA,CAAAA,EAAS,MAAA,EAAQC,CAAAA,CAAO,MAAA,CAAO,QAAA,CAAUD,CAAAA,CAAQ,MAAA,CAAO,QAAA,EAAU,CAAA,CAEtE,IAAME,CAAAA,CAAQD,CAAAA,CAAO,QAAA,EAAS,CACxBE,CAAAA,CAAWD,CAAAA,CAAQ,CAAA,MAAA,EAASA,CAAK,C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,CAAAA,CAAOH,CAAAA,CAAiBC,CAAO,EACrC,OAAKE,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,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&lt;T&gt;) */\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"]}
package/dist/index.d.cts CHANGED
@@ -3,8 +3,8 @@
3
3
  * Aligned with backend-api/src/lib/pin-types.ts + pin-config-schemas.ts.
4
4
  * Import per-type *PinConfig interfaces for typed CRUD payloads.
5
5
  */
6
- declare const PRODUCT_PIN_TYPES: readonly ["markdown", "image", "gallery", "table", "charts", "mermaid", "embed", "pdf-viewer", "excel-viewer", "stat-cards", "timeline", "json-viewer", "json-list", "links", "qr-code", "steps", "trace", "plan", "notes", "csv-viewer", "user-story", "chat", "intro", "mastra", "text-media", "business-card", "video", "file-upload", "kanban-board", "checklist", "calendar", "roadmap", "realtime-canvas"];
7
- declare const ALL_PIN_TYPES: readonly ["markdown", "image", "gallery", "table", "charts", "mermaid", "embed", "pdf-viewer", "excel-viewer", "stat-cards", "timeline", "json-viewer", "json-list", "links", "qr-code", "steps", "trace", "plan", "notes", "csv-viewer", "user-story", "chat", "intro", "mastra", "text-media", "business-card", "video", "file-upload", "kanban-board", "checklist", "calendar", "roadmap", "realtime-canvas"];
6
+ declare const PRODUCT_PIN_TYPES: readonly ["markdown", "image", "gallery", "table", "charts", "mermaid", "code", "embed", "pdf-viewer", "excel-viewer", "stat-cards", "timeline", "json-viewer", "json-list", "links", "qr-code", "social-handles", "steps", "trace", "plan", "notes", "csv-viewer", "user-story", "chat", "intro", "mastra", "text-media", "business-card", "video", "audio", "file-upload", "kanban-board", "checklist", "comparison", "calendar", "roadmap", "realtime-canvas"];
7
+ declare const ALL_PIN_TYPES: readonly ["markdown", "image", "gallery", "table", "charts", "mermaid", "code", "embed", "pdf-viewer", "excel-viewer", "stat-cards", "timeline", "json-viewer", "json-list", "links", "qr-code", "social-handles", "steps", "trace", "plan", "notes", "csv-viewer", "user-story", "chat", "intro", "mastra", "text-media", "business-card", "video", "audio", "file-upload", "kanban-board", "checklist", "comparison", "calendar", "roadmap", "realtime-canvas"];
8
8
  type ProductPinTypeId = (typeof PRODUCT_PIN_TYPES)[number];
9
9
  type PinTypeId = (typeof ALL_PIN_TYPES)[number];
10
10
  type PinLayout = '1x1' | '1x2' | '2x1' | '2x2' | '3x1' | '3x2' | '3x3' | '4x4';
@@ -87,8 +87,15 @@ interface ChartsPinConfig {
87
87
  [key: string]: unknown;
88
88
  }
89
89
  interface MermaidPinConfig {
90
- code?: string;
91
90
  diagram?: string;
91
+ code?: string;
92
+ title?: string;
93
+ [key: string]: unknown;
94
+ }
95
+ interface CodePinConfig {
96
+ code: string;
97
+ language?: string;
98
+ filename?: string;
92
99
  title?: string;
93
100
  [key: string]: unknown;
94
101
  }
@@ -144,6 +151,20 @@ interface QrCodePinConfig {
144
151
  label?: string;
145
152
  [key: string]: unknown;
146
153
  }
154
+ interface SocialHandleItem {
155
+ id?: string;
156
+ platform: string;
157
+ url: string;
158
+ label?: string;
159
+ [key: string]: unknown;
160
+ }
161
+ interface SocialHandlesPinConfig {
162
+ title?: string;
163
+ showLabels?: boolean;
164
+ iconSize?: number;
165
+ handles?: SocialHandleItem[];
166
+ [key: string]: unknown;
167
+ }
147
168
  interface StepsPinConfig {
148
169
  steps: StepItem[];
149
170
  [key: string]: unknown;
@@ -246,6 +267,10 @@ interface UserStoryPinConfig {
246
267
  interface ChatPinConfig {
247
268
  title?: string;
248
269
  placeholder?: string;
270
+ /** Pin this discussion thread is about (commentary / feedback). */
271
+ linked_pin_id?: string;
272
+ /** Cached title for display without fetching the linked pin. */
273
+ linked_pin_title?: string;
249
274
  [key: string]: unknown;
250
275
  }
251
276
  interface IntroPinConfig {
@@ -285,6 +310,24 @@ interface VideoPinConfig {
285
310
  size?: number;
286
311
  [key: string]: unknown;
287
312
  }
313
+ interface AudioPinTrack {
314
+ url: string;
315
+ fileId?: string;
316
+ fileName?: string;
317
+ mimeType?: 'audio/mpeg' | 'audio/wav' | 'audio/x-wav' | string;
318
+ size?: number;
319
+ [key: string]: unknown;
320
+ }
321
+ interface AudioPinConfig {
322
+ url?: string;
323
+ fileId?: string;
324
+ fileName?: string;
325
+ mimeType?: 'audio/mpeg' | 'audio/wav' | 'audio/x-wav' | string;
326
+ caption?: string;
327
+ size?: number;
328
+ tracks?: AudioPinTrack[];
329
+ [key: string]: unknown;
330
+ }
288
331
  interface TextMediaPinConfig {
289
332
  title?: string;
290
333
  text?: string;
@@ -320,6 +363,26 @@ interface ChecklistPinConfig {
320
363
  items: ChecklistItem[];
321
364
  [key: string]: unknown;
322
365
  }
366
+ interface ComparisonSideConfig {
367
+ label: string;
368
+ body: string;
369
+ }
370
+ interface ComparisonMatchPair {
371
+ left: number;
372
+ right: number;
373
+ }
374
+ interface ComparisonPinConfig {
375
+ title?: string;
376
+ left: ComparisonSideConfig;
377
+ right: ComparisonSideConfig;
378
+ highlightedLines?: {
379
+ left?: number[];
380
+ right?: number[];
381
+ };
382
+ matches?: ComparisonMatchPair[];
383
+ showVsBadge?: boolean;
384
+ [key: string]: unknown;
385
+ }
323
386
  interface CalendarPinConfig {
324
387
  weekStartsOn?: number;
325
388
  events?: Array<Record<string, unknown>>;
@@ -343,6 +406,7 @@ interface PinConfigByType {
343
406
  table: TablePinConfig;
344
407
  charts: ChartsPinConfig;
345
408
  mermaid: MermaidPinConfig;
409
+ code: CodePinConfig;
346
410
  embed: EmbedPinConfig;
347
411
  'pdf-viewer': PdfViewerPinConfig;
348
412
  'excel-viewer': ExcelViewerPinConfig;
@@ -352,6 +416,7 @@ interface PinConfigByType {
352
416
  'json-list': JsonListPinConfig;
353
417
  links: LinksPinConfig;
354
418
  'qr-code': QrCodePinConfig;
419
+ 'social-handles': SocialHandlesPinConfig;
355
420
  steps: StepsPinConfig;
356
421
  trace: TracePinConfig;
357
422
  plan: PlanPinConfig;
@@ -364,9 +429,11 @@ interface PinConfigByType {
364
429
  'text-media': TextMediaPinConfig;
365
430
  'business-card': BusinessCardPinConfig;
366
431
  video: VideoPinConfig;
432
+ audio: AudioPinConfig;
367
433
  'file-upload': FileUploadPinConfig;
368
434
  'kanban-board': KanbanBoardPinConfig;
369
435
  checklist: ChecklistPinConfig;
436
+ comparison: ComparisonPinConfig;
370
437
  calendar: CalendarPinConfig;
371
438
  roadmap: RoadmapPinConfig;
372
439
  'realtime-canvas': RealtimeCanvasPinConfig;
@@ -460,6 +527,13 @@ interface CreateTablePinInput extends PinMetadataBase {
460
527
  pin_layout?: PinLayout;
461
528
  is_public?: boolean;
462
529
  }
530
+ interface UpdateTablePinInput {
531
+ columns?: TableColumn[];
532
+ rows?: TableRow[];
533
+ title?: string;
534
+ tags?: string[];
535
+ description?: string;
536
+ }
463
537
  interface CreateEmbedPinInput extends PinMetadataBase {
464
538
  url: string;
465
539
  type?: string;
@@ -537,6 +611,8 @@ declare class PinsMethods {
537
611
  createMarkdown(input: CreateMarkdownPinInput): Promise<Pin<'markdown'>>;
538
612
  createStatCards(input: CreateStatCardsPinInput): Promise<Pin<'stat-cards'>>;
539
613
  createTable(input: CreateTablePinInput): Promise<Pin<'table'>>;
614
+ /** Partial table pin_config update with typed columns/rows. */
615
+ updateTable(pinId: string, input: UpdateTablePinInput): Promise<Pin<'table'>>;
540
616
  createEmbed(input: CreateEmbedPinInput): Promise<Pin<'embed'>>;
541
617
  /**
542
618
  * @deprecated Use createMarkdown({ title, content, ... }) — old signature ignored content in title
@@ -570,6 +646,34 @@ declare class PindownClient {
570
646
  private handleErrorResponse;
571
647
  }
572
648
 
649
+ /**
650
+ * Runtime hints + minimal examples per pin type.
651
+ * Use when building API payloads without opening the docs every time.
652
+ */
653
+
654
+ interface PinConfigFieldHint {
655
+ path: string;
656
+ type: string;
657
+ required: boolean;
658
+ description: string;
659
+ }
660
+ interface PinConfigHint<T extends PinTypeId = PinTypeId> {
661
+ pin_type: T;
662
+ summary: string;
663
+ required_fields: string[];
664
+ optional_fields: string[];
665
+ fields: PinConfigFieldHint[];
666
+ /** Minimal valid pin_config for create/update */
667
+ example_config: PinConfigByType[T];
668
+ /** Typical PUT /v1/pins/:id body (root-level pin_config) */
669
+ example_update: UpdatePinRequest<T>;
670
+ }
671
+ /** Per-type hints (expand over time; table is fully documented). */
672
+ declare const PIN_CONFIG_HINTS: Partial<Record<PinTypeId, PinConfigHint>>;
673
+ declare function getPinConfigHint<T extends PinTypeId>(pinType: T): PinConfigHint<T> | undefined;
674
+ /** Pretty-print field hints for CLI / logging. */
675
+ declare function formatPinConfigHint(pinType: PinTypeId): string;
676
+
573
677
  /**
574
678
  * Error classes for the v1 Pins API client
575
679
  */
@@ -600,4 +704,4 @@ declare class NetworkError extends PindownError {
600
704
  constructor(message?: string);
601
705
  }
602
706
 
603
- export { ALL_PIN_TYPES, type ApiResponse, AuthenticationError, type BusinessCardField, type BusinessCardPinConfig, type CalendarPinConfig, type ChartsPinConfig, type ChatPinConfig, type ChecklistItem, type ChecklistPinConfig, type CreateEmbedPinInput, type CreateMarkdownPinInput, type CreateNestedPinRequest, type CreatePinRequest, type CreateStatCardsPinInput, type CreateTablePinInput, type CreateTypedPinRequest, type CsvViewerPinConfig, type EmbedPinConfig, type ExcelViewerPinConfig, type FileUploadPinConfig, ForbiddenError, type GalleryImage, type GalleryPinConfig, type ImagePinConfig, type IntroPinConfig, type JsonListPinConfig, type JsonViewerPinConfig, type KanbanBoardPinConfig, type KanbanColumn, type LinkItem, type LinksPinConfig, type ListPinsOptions, type MarkdownPinConfig, type MastraPinConfig, type MermaidPinConfig, NetworkError, NotFoundError, PRODUCT_PIN_TYPES, type PaginatedResponse, type PdfViewerPinConfig, type Pin, type PinCardType, type PinConfigByType, type PinDataType, type PinLayout, type PinMetadata, type PinMetadataBase, type PinTypeId, PindownClient, type PindownConfig, PindownError, type ProductPinTypeId, type QrCodePinConfig, RateLimitError, type RealtimeCanvasPinConfig, type RoadmapPinConfig, ServerError, type SharePinRequest, type StatCardItem, type StatCardsPinConfig, type StepItem, type StepsPinConfig, type TableColumn, type TablePinConfig, type TableRow, type TextMediaPinConfig, type TimelinePinConfig, type UpdatePinRequest, type UserStoryPinConfig, ValidationError, type VideoPinConfig };
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 };
package/dist/index.d.ts CHANGED
@@ -3,8 +3,8 @@
3
3
  * Aligned with backend-api/src/lib/pin-types.ts + pin-config-schemas.ts.
4
4
  * Import per-type *PinConfig interfaces for typed CRUD payloads.
5
5
  */
6
- declare const PRODUCT_PIN_TYPES: readonly ["markdown", "image", "gallery", "table", "charts", "mermaid", "embed", "pdf-viewer", "excel-viewer", "stat-cards", "timeline", "json-viewer", "json-list", "links", "qr-code", "steps", "trace", "plan", "notes", "csv-viewer", "user-story", "chat", "intro", "mastra", "text-media", "business-card", "video", "file-upload", "kanban-board", "checklist", "calendar", "roadmap", "realtime-canvas"];
7
- declare const ALL_PIN_TYPES: readonly ["markdown", "image", "gallery", "table", "charts", "mermaid", "embed", "pdf-viewer", "excel-viewer", "stat-cards", "timeline", "json-viewer", "json-list", "links", "qr-code", "steps", "trace", "plan", "notes", "csv-viewer", "user-story", "chat", "intro", "mastra", "text-media", "business-card", "video", "file-upload", "kanban-board", "checklist", "calendar", "roadmap", "realtime-canvas"];
6
+ declare const PRODUCT_PIN_TYPES: readonly ["markdown", "image", "gallery", "table", "charts", "mermaid", "code", "embed", "pdf-viewer", "excel-viewer", "stat-cards", "timeline", "json-viewer", "json-list", "links", "qr-code", "social-handles", "steps", "trace", "plan", "notes", "csv-viewer", "user-story", "chat", "intro", "mastra", "text-media", "business-card", "video", "audio", "file-upload", "kanban-board", "checklist", "comparison", "calendar", "roadmap", "realtime-canvas"];
7
+ declare const ALL_PIN_TYPES: readonly ["markdown", "image", "gallery", "table", "charts", "mermaid", "code", "embed", "pdf-viewer", "excel-viewer", "stat-cards", "timeline", "json-viewer", "json-list", "links", "qr-code", "social-handles", "steps", "trace", "plan", "notes", "csv-viewer", "user-story", "chat", "intro", "mastra", "text-media", "business-card", "video", "audio", "file-upload", "kanban-board", "checklist", "comparison", "calendar", "roadmap", "realtime-canvas"];
8
8
  type ProductPinTypeId = (typeof PRODUCT_PIN_TYPES)[number];
9
9
  type PinTypeId = (typeof ALL_PIN_TYPES)[number];
10
10
  type PinLayout = '1x1' | '1x2' | '2x1' | '2x2' | '3x1' | '3x2' | '3x3' | '4x4';
@@ -87,8 +87,15 @@ interface ChartsPinConfig {
87
87
  [key: string]: unknown;
88
88
  }
89
89
  interface MermaidPinConfig {
90
- code?: string;
91
90
  diagram?: string;
91
+ code?: string;
92
+ title?: string;
93
+ [key: string]: unknown;
94
+ }
95
+ interface CodePinConfig {
96
+ code: string;
97
+ language?: string;
98
+ filename?: string;
92
99
  title?: string;
93
100
  [key: string]: unknown;
94
101
  }
@@ -144,6 +151,20 @@ interface QrCodePinConfig {
144
151
  label?: string;
145
152
  [key: string]: unknown;
146
153
  }
154
+ interface SocialHandleItem {
155
+ id?: string;
156
+ platform: string;
157
+ url: string;
158
+ label?: string;
159
+ [key: string]: unknown;
160
+ }
161
+ interface SocialHandlesPinConfig {
162
+ title?: string;
163
+ showLabels?: boolean;
164
+ iconSize?: number;
165
+ handles?: SocialHandleItem[];
166
+ [key: string]: unknown;
167
+ }
147
168
  interface StepsPinConfig {
148
169
  steps: StepItem[];
149
170
  [key: string]: unknown;
@@ -246,6 +267,10 @@ interface UserStoryPinConfig {
246
267
  interface ChatPinConfig {
247
268
  title?: string;
248
269
  placeholder?: string;
270
+ /** Pin this discussion thread is about (commentary / feedback). */
271
+ linked_pin_id?: string;
272
+ /** Cached title for display without fetching the linked pin. */
273
+ linked_pin_title?: string;
249
274
  [key: string]: unknown;
250
275
  }
251
276
  interface IntroPinConfig {
@@ -285,6 +310,24 @@ interface VideoPinConfig {
285
310
  size?: number;
286
311
  [key: string]: unknown;
287
312
  }
313
+ interface AudioPinTrack {
314
+ url: string;
315
+ fileId?: string;
316
+ fileName?: string;
317
+ mimeType?: 'audio/mpeg' | 'audio/wav' | 'audio/x-wav' | string;
318
+ size?: number;
319
+ [key: string]: unknown;
320
+ }
321
+ interface AudioPinConfig {
322
+ url?: string;
323
+ fileId?: string;
324
+ fileName?: string;
325
+ mimeType?: 'audio/mpeg' | 'audio/wav' | 'audio/x-wav' | string;
326
+ caption?: string;
327
+ size?: number;
328
+ tracks?: AudioPinTrack[];
329
+ [key: string]: unknown;
330
+ }
288
331
  interface TextMediaPinConfig {
289
332
  title?: string;
290
333
  text?: string;
@@ -320,6 +363,26 @@ interface ChecklistPinConfig {
320
363
  items: ChecklistItem[];
321
364
  [key: string]: unknown;
322
365
  }
366
+ interface ComparisonSideConfig {
367
+ label: string;
368
+ body: string;
369
+ }
370
+ interface ComparisonMatchPair {
371
+ left: number;
372
+ right: number;
373
+ }
374
+ interface ComparisonPinConfig {
375
+ title?: string;
376
+ left: ComparisonSideConfig;
377
+ right: ComparisonSideConfig;
378
+ highlightedLines?: {
379
+ left?: number[];
380
+ right?: number[];
381
+ };
382
+ matches?: ComparisonMatchPair[];
383
+ showVsBadge?: boolean;
384
+ [key: string]: unknown;
385
+ }
323
386
  interface CalendarPinConfig {
324
387
  weekStartsOn?: number;
325
388
  events?: Array<Record<string, unknown>>;
@@ -343,6 +406,7 @@ interface PinConfigByType {
343
406
  table: TablePinConfig;
344
407
  charts: ChartsPinConfig;
345
408
  mermaid: MermaidPinConfig;
409
+ code: CodePinConfig;
346
410
  embed: EmbedPinConfig;
347
411
  'pdf-viewer': PdfViewerPinConfig;
348
412
  'excel-viewer': ExcelViewerPinConfig;
@@ -352,6 +416,7 @@ interface PinConfigByType {
352
416
  'json-list': JsonListPinConfig;
353
417
  links: LinksPinConfig;
354
418
  'qr-code': QrCodePinConfig;
419
+ 'social-handles': SocialHandlesPinConfig;
355
420
  steps: StepsPinConfig;
356
421
  trace: TracePinConfig;
357
422
  plan: PlanPinConfig;
@@ -364,9 +429,11 @@ interface PinConfigByType {
364
429
  'text-media': TextMediaPinConfig;
365
430
  'business-card': BusinessCardPinConfig;
366
431
  video: VideoPinConfig;
432
+ audio: AudioPinConfig;
367
433
  'file-upload': FileUploadPinConfig;
368
434
  'kanban-board': KanbanBoardPinConfig;
369
435
  checklist: ChecklistPinConfig;
436
+ comparison: ComparisonPinConfig;
370
437
  calendar: CalendarPinConfig;
371
438
  roadmap: RoadmapPinConfig;
372
439
  'realtime-canvas': RealtimeCanvasPinConfig;
@@ -460,6 +527,13 @@ interface CreateTablePinInput extends PinMetadataBase {
460
527
  pin_layout?: PinLayout;
461
528
  is_public?: boolean;
462
529
  }
530
+ interface UpdateTablePinInput {
531
+ columns?: TableColumn[];
532
+ rows?: TableRow[];
533
+ title?: string;
534
+ tags?: string[];
535
+ description?: string;
536
+ }
463
537
  interface CreateEmbedPinInput extends PinMetadataBase {
464
538
  url: string;
465
539
  type?: string;
@@ -537,6 +611,8 @@ declare class PinsMethods {
537
611
  createMarkdown(input: CreateMarkdownPinInput): Promise<Pin<'markdown'>>;
538
612
  createStatCards(input: CreateStatCardsPinInput): Promise<Pin<'stat-cards'>>;
539
613
  createTable(input: CreateTablePinInput): Promise<Pin<'table'>>;
614
+ /** Partial table pin_config update with typed columns/rows. */
615
+ updateTable(pinId: string, input: UpdateTablePinInput): Promise<Pin<'table'>>;
540
616
  createEmbed(input: CreateEmbedPinInput): Promise<Pin<'embed'>>;
541
617
  /**
542
618
  * @deprecated Use createMarkdown({ title, content, ... }) — old signature ignored content in title
@@ -570,6 +646,34 @@ declare class PindownClient {
570
646
  private handleErrorResponse;
571
647
  }
572
648
 
649
+ /**
650
+ * Runtime hints + minimal examples per pin type.
651
+ * Use when building API payloads without opening the docs every time.
652
+ */
653
+
654
+ interface PinConfigFieldHint {
655
+ path: string;
656
+ type: string;
657
+ required: boolean;
658
+ description: string;
659
+ }
660
+ interface PinConfigHint<T extends PinTypeId = PinTypeId> {
661
+ pin_type: T;
662
+ summary: string;
663
+ required_fields: string[];
664
+ optional_fields: string[];
665
+ fields: PinConfigFieldHint[];
666
+ /** Minimal valid pin_config for create/update */
667
+ example_config: PinConfigByType[T];
668
+ /** Typical PUT /v1/pins/:id body (root-level pin_config) */
669
+ example_update: UpdatePinRequest<T>;
670
+ }
671
+ /** Per-type hints (expand over time; table is fully documented). */
672
+ declare const PIN_CONFIG_HINTS: Partial<Record<PinTypeId, PinConfigHint>>;
673
+ declare function getPinConfigHint<T extends PinTypeId>(pinType: T): PinConfigHint<T> | undefined;
674
+ /** Pretty-print field hints for CLI / logging. */
675
+ declare function formatPinConfigHint(pinType: PinTypeId): string;
676
+
573
677
  /**
574
678
  * Error classes for the v1 Pins API client
575
679
  */
@@ -600,4 +704,4 @@ declare class NetworkError extends PindownError {
600
704
  constructor(message?: string);
601
705
  }
602
706
 
603
- export { ALL_PIN_TYPES, type ApiResponse, AuthenticationError, type BusinessCardField, type BusinessCardPinConfig, type CalendarPinConfig, type ChartsPinConfig, type ChatPinConfig, type ChecklistItem, type ChecklistPinConfig, type CreateEmbedPinInput, type CreateMarkdownPinInput, type CreateNestedPinRequest, type CreatePinRequest, type CreateStatCardsPinInput, type CreateTablePinInput, type CreateTypedPinRequest, type CsvViewerPinConfig, type EmbedPinConfig, type ExcelViewerPinConfig, type FileUploadPinConfig, ForbiddenError, type GalleryImage, type GalleryPinConfig, type ImagePinConfig, type IntroPinConfig, type JsonListPinConfig, type JsonViewerPinConfig, type KanbanBoardPinConfig, type KanbanColumn, type LinkItem, type LinksPinConfig, type ListPinsOptions, type MarkdownPinConfig, type MastraPinConfig, type MermaidPinConfig, NetworkError, NotFoundError, PRODUCT_PIN_TYPES, type PaginatedResponse, type PdfViewerPinConfig, type Pin, type PinCardType, type PinConfigByType, type PinDataType, type PinLayout, type PinMetadata, type PinMetadataBase, type PinTypeId, PindownClient, type PindownConfig, PindownError, type ProductPinTypeId, type QrCodePinConfig, RateLimitError, type RealtimeCanvasPinConfig, type RoadmapPinConfig, ServerError, type SharePinRequest, type StatCardItem, type StatCardsPinConfig, type StepItem, type StepsPinConfig, type TableColumn, type TablePinConfig, type TableRow, type TextMediaPinConfig, type TimelinePinConfig, type UpdatePinRequest, type UserStoryPinConfig, ValidationError, type VideoPinConfig };
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 };
package/dist/index.js CHANGED
@@ -1,3 +1,8 @@
1
- var C=class{constructor(e){this.client=e;}async create(e){return this.client.request("POST","/pins",e)}async get(e){return this.client.request("GET",`/pins/${e}`)}async list(e){let n=new URLSearchParams;e?.limit&&n.append("limit",e.limit.toString()),e?.offset&&n.append("offset",e.offset.toString());let i=n.toString(),r=i?`/pins?${i}`:"/pins";return this.client.request("GET",r)}async update(e,n){return this.client.request("PUT",`/pins/${e}`,n)}async delete(e){return this.client.request("DELETE",`/pins/${e}`)}async share(e,n){return this.client.request("POST",`/pins/${e}/share`,n)}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:n,title:i,tags:r,description:s,pin_layout:a,is_public:t,allow_edit:d,require_sign_in:w,allow_comments:h,pending_invites:T}=e;return this.create({pin_type:"markdown",pin_config:{content:n},pin_layout:a,is_public:t,allow_edit:d,require_sign_in:w,allow_comments:h,pending_invites:T,metadata:{title:i,tags:r,description:s}})}async createStatCards(e){let{cards:n,title:i,tags:r,description:s,pin_layout:a,is_public:t}=e;return this.create({pin_type:"stat-cards",pin_config:{cards:n},pin_layout:a,is_public:t,metadata:{title:i,tags:r,description:s}})}async createTable(e){let{columns:n,rows:i,title:r,tags:s,description:a,pin_layout:t,is_public:d}=e;return this.create({pin_type:"table",pin_config:{columns:n,rows:i},pin_layout:t,is_public:d,metadata:{title:r,tags:s,description:a}})}async createEmbed(e){let{url:n,type:i,title:r,tags:s,description:a,pin_layout:t,is_public:d}=e;return this.create({pin_type:"embed",pin_config:{url:n,type:i},pin_layout:t,is_public:d,metadata:{title:r,tags:s,description:a}})}async createMarkdownLegacy(e,n){return this.createMarkdown({title:e,content:"",...n})}};var o=class extends Error{constructor(e){super(e),this.name="PindownError";}},P=class extends o{constructor(e="Authentication failed"){super(e),this.name="AuthenticationError";}},u=class extends o{constructor(e="Access forbidden"){super(e),this.name="ForbiddenError";}},g=class extends o{constructor(e){super(`${e} not found`),this.name="NotFoundError";}},l=class extends o{constructor(e,n){super(e),this.name="ValidationError",this.details=n;}},m=class extends o{constructor(e="Rate limit exceeded (429 RATE_LIMITED)"){super(e),this.name="RateLimitError";}},p=class extends o{constructor(e,n=500){super(e),this.name="ServerError",this.statusCode=n;}},f=class extends o{constructor(e="Network request failed"){super(e),this.name="NetworkError";}};var y=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 C(this);}async request(e,n,i){let r=`${this.config.baseURL}${n}`,s={Authorization:`Bearer ${this.config.apiKey}`};i&&(e==="POST"||e==="PUT"||e==="PATCH"||e==="DELETE")&&(s["Content-Type"]="application/json");let a={method:e,headers:s,signal:AbortSignal.timeout(this.config.timeout)};i&&(e==="POST"||e==="PUT"||e==="PATCH"||e==="DELETE")&&(a.body=JSON.stringify(i));try{let t=await fetch(r,a);return t.ok||await this.handleErrorResponse(t),(await t.json()).data}catch(t){throw t instanceof P||t instanceof u||t instanceof g||t instanceof l||t instanceof m||t instanceof p?t:t instanceof Error&&(t.name==="AbortError"||t.name==="TimeoutError")?new f("Request timeout"):new f(t instanceof Error?t.message:"Network request failed")}}async handleErrorResponse(e){let n;try{n=await e.json();}catch{n={message:e.statusText};}let i=n.error?.message||n.message||"Unknown error";switch(e.status){case 401:throw new P(i);case 403:throw new u(i);case 404:throw new g(i);case 400:case 422:throw new l(i,n.error?.details);case 429:throw new m(i);case 500:case 502:case 503:throw new p(i,e.status);default:throw new p(i,e.status)}}};
2
- export{P as AuthenticationError,u as ForbiddenError,f as NetworkError,g as NotFoundError,y as PindownClient,o as PindownError,m as RateLimitError,p as ServerError,l as ValidationError};//# sourceMappingURL=index.js.map
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(),s=n?`/pins?${n}`:"/pins";return this.client.request("GET",s)}async update(e,i){return this.client.request("PUT",`/pins/${e}`,i)}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:s,description:a,pin_layout:o,is_public:t,allow_edit:d,require_sign_in:w,allow_comments:b,pending_invites:_}=e;return this.create({pin_type:"markdown",pin_config:{content:i},pin_layout:o,is_public:t,allow_edit:d,require_sign_in:w,allow_comments:b,pending_invites:_,metadata:{title:n,tags:s,description:a}})}async createStatCards(e){let{cards:i,title:n,tags:s,description:a,pin_layout:o,is_public:t}=e;return this.create({pin_type:"stat-cards",pin_config:{cards:i},pin_layout:o,is_public:t,metadata:{title:n,tags:s,description:a}})}async createTable(e){let{columns:i,rows:n,title:s,tags:a,description:o,pin_layout:t,is_public:d}=e;return this.create({pin_type:"table",pin_config:{columns:i,rows:n},pin_layout:t,is_public:d,metadata:{title:s,tags:a,description:o}})}async updateTable(e,i){let{columns:n,rows:s,title:a,tags:o,description:t}=i,d={};return n!==void 0&&(d.columns=n),s!==void 0&&(d.rows=s),this.update(e,{pin_config:d,...a!==void 0||o!==void 0||t!==void 0?{metadata:{...a!==void 0&&{title:a},...o!==void 0&&{tags:o},...t!==void 0&&{description:t}}}:{}})}async createEmbed(e){let{url:i,type:n,title:s,tags:a,description:o,pin_layout:t,is_public:d}=e;return this.create({pin_type:"embed",pin_config:{url:i,type:n},pin_layout:t,is_public:d,metadata:{title:s,tags:a,description:o}})}async createMarkdownLegacy(e,i){return this.createMarkdown({title:e,content:"",...i})}};var p=class extends Error{constructor(e){super(e),this.name="PindownError";}},u=class extends p{constructor(e="Authentication failed"){super(e),this.name="AuthenticationError";}},l=class extends p{constructor(e="Access forbidden"){super(e),this.name="ForbiddenError";}},P=class extends p{constructor(e){super(`${e} not found`),this.name="NotFoundError";}},f=class extends p{constructor(e,i){super(e),this.name="ValidationError",this.details=i;}},g=class extends p{constructor(e="Rate limit exceeded (429 RATE_LIMITED)"){super(e),this.name="RateLimitError";}},c=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 C=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 s=`${this.config.baseURL}${i}`,a={Authorization:`Bearer ${this.config.apiKey}`};n&&(e==="POST"||e==="PUT"||e==="PATCH"||e==="DELETE")&&(a["Content-Type"]="application/json");let o={method:e,headers:a,signal:AbortSignal.timeout(this.config.timeout)};n&&(e==="POST"||e==="PUT"||e==="PATCH"||e==="DELETE")&&(o.body=JSON.stringify(n));try{let t=await fetch(s,o);return t.ok||await this.handleErrorResponse(t),(await t.json()).data}catch(t){throw t instanceof u||t instanceof l||t instanceof P||t instanceof f||t instanceof g||t instanceof c?t:t instanceof Error&&(t.name==="AbortError"||t.name==="TimeoutError")?new m("Request timeout"):new m(t instanceof Error?t.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 u(n);case 403:throw new l(n);case 404:throw new P(n);case 400:case 422:throw new f(n,i.error?.details);case 429:throw new g(n);case 500:case 502:case 503:throw new c(n,e.status);default:throw new c(n,e.status)}}};var x={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}}]}}},T={table:x,markdown:{pin_type:"markdown",summary:"Rich text / markdown body.",required_fields:[],optional_fields:["content","collaboration"],fields:[{path:"content",type:"string",required:false,description:"Markdown source. Server seeds Yjs when set on create."}],example_config:{content:`# Hello
2
+
3
+ Body text.`},example_update:{pin_config:{content:`# Updated
4
+
5
+ New body.`}}},"stat-cards":{pin_type:"stat-cards",summary:"KPI cards grid.",required_fields:["cards"],optional_fields:[],fields:[{path:"cards",type:"StatCardItem[]",required:true,description:"Each card: title, value; optional change, trend (up|down|neutral)."}],example_config:{cards:[{title:"Revenue",value:"1000",change:"+5%",trend:"up"}]},example_update:{pin_config:{cards:[{title:"Revenue",value:"1234",change:"+8%",trend:"up"}]}}}};function h(r){return T[r]}function I(r){let e=h(r);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 "${r}".`,"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{u as AuthenticationError,l as ForbiddenError,m as NetworkError,P as NotFoundError,T as PIN_CONFIG_HINTS,C as PindownClient,p as PindownError,g as RateLimitError,c as ServerError,f as ValidationError,I as formatPinConfigHint,h as getPinConfigHint};//# sourceMappingURL=index.js.map
3
8
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/client/pins/index.ts","../src/errors/index.ts","../src/client/PindownClient.ts"],"names":["PinsMethods","client","request","pinId","options","params","query","endpoint","pinIds","pins","updates","input","content","title","tags","description","pin_layout","is_public","allow_edit","require_sign_in","allow_comments","pending_invites","cards","columns","rows","url","type","additionalMetadata","PindownError","message","AuthenticationError","ForbiddenError","NotFoundError","resource","ValidationError","details","RateLimitError","ServerError","statusCode","NetworkError","PindownClient","config","method","data","headers","requestOptions","response","error","errorData"],"mappings":"AAmBO,IAAMA,CAAAA,CAAN,KAAkB,CACvB,WAAA,CAAoBC,EAAuB,CAAvB,IAAA,CAAA,MAAA,CAAAA,EAAwB,CAG5C,MAAM,OAA4BC,CAAAA,CAA+C,CAC/E,OAAO,IAAA,CAAK,MAAA,CAAO,QAAgB,MAAA,CAAQ,OAAA,CAASA,CAAO,CAC7D,CAEA,MAAM,IAAqCC,CAAAA,CAAgC,CACzE,OAAO,IAAA,CAAK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MAAM,IAAIG,EAAcH,CAAO,CAAA,CACjC,KAAK,GAAA,CACL,KAAK,GAAA,CACH,MAAM,IAAIK,CAAAA,CAAgBL,EAASmB,CAAAA,CAAU,KAAA,EAAO,OAAO,CAAA,CAC7D,KAAK,GAAA,CACH,MAAM,IAAIZ,CAAAA,CAAeP,CAAO,CAAA,CAClC,SACA,KAAK,GAAA,CACL,KAAK,GAAA,CACH,MAAM,IAAIQ,CAAAA,CAAYR,CAAAA,CAASiB,CAAAA,CAAS,MAAM,CAAA,CAChD,QACE,MAAM,IAAIT,CAAAA,CAAYR,EAASiB,CAAAA,CAAS,MAAM,CAClD,CACF,CACF","file":"index.js","sourcesContent":["/**\n * Pins API Methods\n */\n\nimport type { PindownClient } from '../PindownClient'\nimport type {\n Pin,\n PinTypeId,\n CreatePinRequest,\n UpdatePinRequest,\n SharePinRequest,\n ListPinsOptions,\n CreateMarkdownPinInput,\n CreateStatCardsPinInput,\n CreateTablePinInput,\n CreateEmbedPinInput,\n} from '../../types/pins'\nimport type { PaginatedResponse } from '../../types/api'\n\nexport class PinsMethods {\n constructor(private client: PindownClient) {}\n\n /** Create a pin (typed via CreatePinRequest&lt;T&gt;) */\n async create<T extends PinTypeId>(request: CreatePinRequest<T>): Promise<Pin<T>> {\n return this.client.request<Pin<T>>('POST', '/pins', request)\n }\n\n async get<T extends PinTypeId = PinTypeId>(pinId: string): Promise<Pin<T>> {\n return this.client.request<Pin<T>>('GET', `/pins/${pinId}`)\n }\n\n async list(options?: ListPinsOptions): Promise<PaginatedResponse<Pin>> {\n const params = new URLSearchParams()\n if (options?.limit) params.append('limit', options.limit.toString())\n if (options?.offset) params.append('offset', options.offset.toString())\n\n const query = params.toString()\n const endpoint = query ? `/pins?${query}` : '/pins'\n\n return this.client.request<PaginatedResponse<Pin>>('GET', endpoint)\n }\n\n async update<T extends PinTypeId = PinTypeId>(pinId: string, request: UpdatePinRequest<T>): Promise<Pin<T>> {\n return this.client.request<Pin<T>>('PUT', `/pins/${pinId}`, request)\n }\n\n async delete(pinId: string): Promise<void> {\n return this.client.request<void>('DELETE', `/pins/${pinId}`)\n }\n\n async share(pinId: string, request: SharePinRequest): Promise<Pin> {\n return this.client.request<Pin>('POST', `/pins/${pinId}/share`, request)\n }\n\n async batchGet(pinIds: string[]): Promise<{\n found: Pin[]\n not_found: string[]\n permission_denied: string[]\n }> {\n return this.client.request('POST', '/pins/batch/get', { pin_ids: pinIds })\n }\n\n async batchCreate(pins: CreatePinRequest[]): Promise<{\n created: Array<{ id: string; index: number; created_at: number }>\n failed: Array<{ index: number; error: string }>\n }> {\n return this.client.request('POST', '/pins/batch', { pins })\n }\n\n async batchUpdate(updates: Array<{ id: string } & UpdatePinRequest>): Promise<{\n updated: string[]\n failed: Array<{ id: string; error: string }>\n updated_at: number\n }> {\n return this.client.request('PATCH', '/pins/batch', { updates })\n }\n\n async batchDelete(pinIds: string[]): Promise<{\n deleted: string[]\n failed: Array<{ id: string; error: string }>\n }> {\n return this.client.request('DELETE', '/pins/batch', { pin_ids: pinIds })\n }\n\n /** Create a markdown pin with pin_config.content (seeds Yjs on the server). */\n async createMarkdown(input: CreateMarkdownPinInput): Promise<Pin<'markdown'>> {\n const { content, title, tags, description, pin_layout, is_public, allow_edit, require_sign_in, allow_comments, pending_invites } = input\n return this.create({\n pin_type: 'markdown',\n pin_config: { content },\n pin_layout,\n is_public,\n allow_edit,\n require_sign_in,\n allow_comments,\n pending_invites,\n metadata: { title, tags, description },\n })\n }\n\n async createStatCards(input: CreateStatCardsPinInput): Promise<Pin<'stat-cards'>> {\n const { cards, title, tags, description, pin_layout, is_public } = input\n return this.create({\n pin_type: 'stat-cards',\n pin_config: { cards },\n pin_layout,\n is_public,\n metadata: { title, tags, description },\n })\n }\n\n async createTable(input: CreateTablePinInput): Promise<Pin<'table'>> {\n const { columns, rows, title, tags, description, pin_layout, is_public } = input\n return this.create({\n pin_type: 'table',\n pin_config: { columns, rows },\n pin_layout,\n is_public,\n metadata: { title, tags, description },\n })\n }\n\n async createEmbed(input: CreateEmbedPinInput): Promise<Pin<'embed'>> {\n const { url, type, title, tags, description, pin_layout, is_public } = input\n return this.create({\n pin_type: 'embed',\n pin_config: { url, type },\n pin_layout,\n is_public,\n metadata: { title, tags, description },\n })\n }\n\n /**\n * @deprecated Use createMarkdown({ title, content, ... }) — old signature ignored content in title\n */\n async createMarkdownLegacy(title: string, additionalMetadata?: Record<string, unknown>): Promise<Pin<'markdown'>> {\n return this.createMarkdown({\n title,\n content: '',\n ...(additionalMetadata as Partial<CreateMarkdownPinInput>),\n })\n }\n}\n","/**\n * Error classes for the v1 Pins API client\n */\n\nexport class PindownError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'PindownError'\n }\n}\n\nexport class AuthenticationError extends PindownError {\n constructor(message: string = 'Authentication failed') {\n super(message)\n this.name = 'AuthenticationError'\n }\n}\n\nexport class ForbiddenError extends PindownError {\n constructor(message: string = 'Access forbidden') {\n super(message)\n this.name = 'ForbiddenError'\n }\n}\n\nexport class NotFoundError extends PindownError {\n constructor(resource: string) {\n super(`${resource} not found`)\n this.name = 'NotFoundError'\n }\n}\n\nexport class ValidationError extends PindownError {\n public details?: unknown\n\n constructor(message: string, details?: unknown) {\n super(message)\n this.name = 'ValidationError'\n this.details = details\n }\n}\n\nexport class RateLimitError extends PindownError {\n constructor(message: string = 'Rate limit exceeded (429 RATE_LIMITED)') {\n super(message)\n this.name = 'RateLimitError'\n }\n}\n\nexport class ServerError extends PindownError {\n public statusCode: number\n\n constructor(message: string, statusCode: number = 500) {\n super(message)\n this.name = 'ServerError'\n this.statusCode = statusCode\n }\n}\n\nexport class NetworkError extends PindownError {\n constructor(message: string = 'Network request failed') {\n super(message)\n this.name = 'NetworkError'\n }\n}\n","/**\n * Pindown API Client — v1 Pins API only\n */\n\nimport { PinsMethods } from './pins'\nimport type { PindownConfig } from '../types/config'\nimport {\n AuthenticationError,\n ForbiddenError,\n NotFoundError,\n ValidationError,\n RateLimitError,\n ServerError,\n NetworkError,\n} from '../errors'\n\nexport class PindownClient {\n private config: Required<Omit<PindownConfig, 'baseURL'>> & { baseURL: string }\n\n public readonly pins: PinsMethods\n\n constructor(config: PindownConfig) {\n if (!config.apiKey) {\n throw new Error('API key is required')\n }\n\n this.config = {\n apiKey: config.apiKey,\n baseURL: config.baseURL || 'https://api.pindown.ai/v1',\n maxRetries: config.maxRetries ?? 3,\n timeout: config.timeout ?? 30000,\n }\n\n this.pins = new PinsMethods(this)\n }\n\n async request<T = unknown>(method: string, endpoint: string, data?: unknown): Promise<T> {\n const url = `${this.config.baseURL}${endpoint}`\n const headers: Record<string, string> = {\n Authorization: `Bearer ${this.config.apiKey}`,\n }\n\n if (data && (method === 'POST' || method === 'PUT' || method === 'PATCH' || method === 'DELETE')) {\n headers['Content-Type'] = 'application/json'\n }\n\n const requestOptions: RequestInit = {\n method,\n headers,\n signal: AbortSignal.timeout(this.config.timeout),\n }\n\n if (data && (method === 'POST' || method === 'PUT' || method === 'PATCH' || method === 'DELETE')) {\n requestOptions.body = JSON.stringify(data)\n }\n\n try {\n const response = await fetch(url, requestOptions)\n\n if (!response.ok) {\n await this.handleErrorResponse(response)\n }\n\n const result = await response.json()\n return result.data as T\n } catch (error: unknown) {\n if (\n error instanceof AuthenticationError ||\n error instanceof ForbiddenError ||\n error instanceof NotFoundError ||\n error instanceof ValidationError ||\n error instanceof RateLimitError ||\n error instanceof ServerError\n ) {\n throw error\n }\n\n if (error instanceof Error && (error.name === 'AbortError' || error.name === 'TimeoutError')) {\n throw new NetworkError('Request timeout')\n }\n\n throw new NetworkError(error instanceof Error ? error.message : 'Network request failed')\n }\n }\n\n private async handleErrorResponse(response: Response): Promise<never> {\n let errorData: { error?: { code?: string; message?: string; details?: unknown }; message?: string }\n\n try {\n errorData = await response.json()\n } catch {\n errorData = { message: response.statusText }\n }\n\n const message = errorData.error?.message || errorData.message || 'Unknown error'\n\n switch (response.status) {\n case 401:\n throw new AuthenticationError(message)\n case 403:\n throw new ForbiddenError(message)\n case 404:\n throw new NotFoundError(message)\n case 400:\n case 422:\n throw new ValidationError(message, errorData.error?.details)\n case 429:\n throw new RateLimitError(message)\n case 500:\n case 502:\n case 503:\n throw new ServerError(message, response.status)\n default:\n throw new ServerError(message, response.status)\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/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,CAAO,CAAA,MAAA,EAASA,CAAK,CAAA,CAAE,CAC5D,CAEA,MAAM,IAAA,CAAKC,CAAAA,CAA4D,CACrE,IAAMC,CAAAA,CAAS,IAAI,eAAA,CACfD,CAAAA,EAAS,OAAOC,CAAAA,CAAO,MAAA,CAAO,OAAA,CAASD,CAAAA,CAAQ,KAAA,CAAM,QAAA,EAAU,CAAA,CAC/DA,CAAAA,EAAS,MAAA,EAAQC,CAAAA,CAAO,MAAA,CAAO,QAAA,CAAUD,CAAAA,CAAQ,MAAA,CAAO,Q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AASE,CAAAA,CAAsCC,CAAAA,CAA0C,CAC9F,OAAOF,CAAAA,CAAiBE,CAAO,CACjC,CAGO,SAASC,CAAAA,CAAoBD,CAAAA,CAA4B,CAC9D,IAAME,CAAAA,CAAOH,CAAAA,CAAiBC,CAAO,EACrC,OAAKE,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,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&lt;T&gt;) */\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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pindownai/client-js",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "Official TypeScript/JavaScript client for the Pindown v1 Pins API",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",