@chaindoc_io/server-sdk
Advanced tools
+33
-0
@@ -8,2 +8,35 @@ # Changelog | ||
| ## [2.1.0] - 2026-05-18 | ||
| Additive release — extends the public API surface across templates, contracts, | ||
| documents, signatures, invoices and transactions. No breaking changes. | ||
| ### Added | ||
| - **Templates module** — full CRUD (`create`, `update`, `publish`, `archive`, | ||
| `restore`, `delete`), reads (`list`, `get`, `getVersions`), and previews | ||
| (`previewPdf`, `previewHtml`, `previewUnsavedPdf`). | ||
| - **Contracts** — core lifecycle (`update`, `delete`, `createEmpty`, `createMinimal`, | ||
| `import`, `attachDocument`, `getStats`); recurring billing (`recurringSetup`, | ||
| `resendRecurringApproval`, `cancelRecurringApproval`); signing-request inspection | ||
| (`listSigningRequests`, `getSigningRequest`) and actions (`resendSigningRequest`, | ||
| `cancelSigningRequest`, `businessSign`). New submodules: `contracts.termination`, | ||
| `contracts.paymentTerms`, `contracts.agreements`. | ||
| - **Documents** — read surface (`get`, `getVersions`, `download`, `preview`); | ||
| analytics (`listShared`, `search`, `getActivity`, `getDownloads`); | ||
| `documents.comments` submodule (`add`, `list`); `sendPublicLink`. | ||
| - **Signatures** — `editRequest`, `getMyRequests` status filter, `createSignature`, | ||
| `validatePdfSignatures` (DSS validation of an uploaded PDF). | ||
| - **Invoices module** — `update`, `cancel`, `downloadPdf`, `listAll` (business-wide). | ||
| - **Transactions module** — `getPaymentMix` and `getFeeEstimate` analytics. | ||
| - **`HttpClient`** — `patch()` verb, `download()` now supports `POST` bodies, | ||
| exported `DownloadResult` type. | ||
| ### Changed | ||
| - `DocumentStatusForCreate` narrowed to `"draft" | "published"` — the backend rejects | ||
| server-derived statuses on create/update. | ||
| --- | ||
| ## [2.0.1] - 2026-04-27 | ||
@@ -10,0 +43,0 @@ |
+1
-1
@@ -1,2 +0,2 @@ | ||
| "use strict";var A=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var N=(n,e)=>{for(var t in e)A(n,t,{get:e[t],enumerable:!0})},k=(n,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of U(e))!L.call(n,i)&&i!==t&&A(n,i,{get:()=>e[i],enumerable:!(s=M(e,i))||s.enumerable});return n};var H=n=>k(A({},"__esModule",{value:!0}),n);var j={};N(j,{Chaindoc:()=>D,ChaindocError:()=>p});module.exports=H(j);var p=class extends Error{constructor(t,s,i,c=!1){super(t);this.statusCode=s;this.response=i;this.isRetryable=c;this.name="ChaindocError"}},O={production:"https://api.chaindoc.io",staging:"https://api.chaindoc.io",development:"https://api.chaindoc.io"},z="production",F=3e4,_=3,K=1e3,V=1e4,y=class{baseUrl;secretKey;timeout;defaultHeaders;retryConfig;constructor(e){if(!e.secretKey)throw new p("secretKey is required");if(!e.secretKey.startsWith("sk_"))throw new p('secretKey must start with "sk_"');let t=e.environment??z;this.baseUrl=e.baseUrl??O[t],this.secretKey=e.secretKey,this.timeout=e.timeout??F,this.defaultHeaders={"Content-Type":"application/json",Authorization:`Bearer ${this.secretKey}`,...e.headers},this.retryConfig={maxRetries:e.retry?.maxRetries??_,baseDelayMs:e.retry?.baseDelayMs??K,maxDelayMs:e.retry?.maxDelayMs??V}}getRetryDelay(e){let t=this.retryConfig.baseDelayMs*Math.pow(2,e),s=Math.min(t,this.retryConfig.maxDelayMs),i=s*.25*(Math.random()*2-1);return Math.round(s+i)}isRetryableError(e,t){return t&&t>=500||t===429?!0:e instanceof Error?["ECONNRESET","ECONNREFUSED","ETIMEDOUT","ENOTFOUND","EAI_AGAIN"].some(i=>e.message.includes(i))||e.name==="AbortError":!1}sleep(e){return new Promise(t=>setTimeout(t,e))}async request(e,t={}){let s=`${this.baseUrl}${e}`,i=t.noRetry?1:this.retryConfig.maxRetries+1,c;for(let a=0;a<i;a++){let u=new AbortController,g=setTimeout(()=>u.abort(),t.timeout??this.timeout);try{let o=await fetch(s,{method:t.method??"GET",headers:{...this.defaultHeaders,...t.headers},body:t.body?JSON.stringify(t.body):void 0,signal:u.signal});if(clearTimeout(g),o.status===204||o.headers.get("content-length")==="0")return;let m=o.headers.get("content-type")?.includes("application/json")?await o.json().catch(()=>{}):void 0;if(!o.ok){let l=m&&typeof m=="object"&&"message"in m&&typeof m.message=="string"?m.message:`Request failed with status ${o.status}`,h=this.isRetryableError(null,o.status);if(c=new p(l,o.status,m,h),h&&a<i-1){await this.sleep(this.getRetryDelay(a));continue}throw c}return m}catch(o){if(clearTimeout(g),o instanceof p){if(!o.isRetryable||a>=i-1)throw o;c=o,await this.sleep(this.getRetryDelay(a));continue}let r=this.isRetryableError(o);if(o instanceof Error){let m=o.name==="AbortError"?"Request timeout":o.message;if(c=new p(m,void 0,void 0,r),r&&a<i-1){await this.sleep(this.getRetryDelay(a));continue}throw c}throw new p("Unknown error occurred")}}throw c??new p("Request failed after retries")}async get(e,t){return this.request(e,{...t,method:"GET"})}async post(e,t,s){return this.request(e,{...s,method:"POST",body:t})}async put(e,t,s){return this.request(e,{...s,method:"PUT",body:t})}async delete(e,t){return this.request(e,{...t,method:"DELETE"})}async uploadFiles(e,t,s="media"){let i=this.retryConfig.maxRetries+1,c;for(let a=0;a<i;a++){let u=new FormData;t.forEach(r=>{u.append(s,r)});let g=new AbortController,o=setTimeout(()=>g.abort(),this.timeout*2);try{let r=await fetch(`${this.baseUrl}${e}`,{method:"POST",headers:{Authorization:`Bearer ${this.secretKey}`},body:u,signal:g.signal});if(clearTimeout(o),r.status===204||r.headers.get("content-length")==="0")return;let l=r.headers.get("content-type")?.includes("application/json")?await r.json().catch(()=>{}):void 0;if(!r.ok){let h=l&&typeof l=="object"&&"message"in l&&typeof l.message=="string"?l.message:`Upload failed with status ${r.status}`,q=this.isRetryableError(null,r.status);if(c=new p(h,r.status,l,q),q&&a<i-1){await this.sleep(this.getRetryDelay(a));continue}throw c}return l}catch(r){if(clearTimeout(o),r instanceof p){if(!r.isRetryable||a>=i-1)throw r;c=r,await this.sleep(this.getRetryDelay(a));continue}let m=this.isRetryableError(r);if(r instanceof Error){let l=r.name==="AbortError"?"Upload timeout":r.message;if(c=new p(l,void 0,void 0,m),m&&a<i-1){await this.sleep(this.getRetryDelay(a));continue}throw c}throw new p("Unknown error occurred")}}throw c??new p("Upload failed after retries")}};function $(n){return typeof n!="string"?n:n.trim().toLowerCase()}function d(n){return typeof n.email!="string"?{...n}:{...n,email:n.email.trim().toLowerCase()}}function x(n){return typeof n.signerEmail!="string"?{...n}:{...n,signerEmail:n.signerEmail.trim().toLowerCase()}}function I(n){return n?.map(d)}var f=class{constructor(e){this.client=e}async create(e){return this.client.post("/api/v1/documents",{...e,accessEmails:I(e.accessEmails)})}async update(e,t){return this.client.put(`/api/v1/documents/${e}`,t)}async updateRights(e,t){return this.client.put(`/api/v1/documents/${e}/rights`,{...t,accessEmails:I(t.accessEmails)})}async verify(e){return this.client.post("/api/v1/documents/verify",e)}async getVerificationStatus(e){return this.client.get(`/api/v1/documents/versions/${e}/verification`)}};var R=class{constructor(e){this.client=e}async createRequest(e){return this.client.post("/api/v1/signatures/requests",{...e,recipients:e.recipients.map(d),fields:e.fields?.map(x),deadline:e.deadline.toISOString()})}async getRequestStatus(e){return this.client.get(`/api/v1/signatures/requests/${e}/status`)}async getMyRequests(e){let t=new URLSearchParams;e?.pageNumber&&t.set("pageNumber",String(e.pageNumber)),e?.pageSize&&t.set("pageSize",String(e.pageSize));let s=t.toString();return this.client.get(`/api/v1/signatures/requests${s?`?${s}`:""}`)}async sign(e){return this.client.post("/api/v1/signatures/sign",e)}async getSignatures(e){let t=new URLSearchParams;e?.pageNumber&&t.set("pageNumber",String(e.pageNumber)),e?.pageSize&&t.set("pageSize",String(e.pageSize));let s=t.toString();return this.client.get(`/api/v1/signatures${s?`?${s}`:""}`)}};var v=class{constructor(e){this.client=e}async create(e){return this.client.post("/api/v1/contracts",{...e,contragent:d(e.contragent)})}async list(e){let t=new URLSearchParams;e?.page&&t.set("page",String(e.page)),e?.limit&&t.set("limit",String(e.limit)),e?.status&&t.set("status",e.status),e?.search&&t.set("search",e.search);let s=t.toString();return this.client.get(`/api/v1/contracts${s?`?${s}`:""}`)}async get(e){return this.client.get(`/api/v1/contracts/${e}`)}async getStatus(e){return this.client.get(`/api/v1/contracts/${e}/status`)}async getActivities(e,t){let s=new URLSearchParams;t?.page&&s.set("page",String(t.page)),t?.limit&&s.set("limit",String(t.limit));let i=s.toString();return this.client.get(`/api/v1/contracts/${e}/activities${i?`?${i}`:""}`)}async addPaymentSetup(e,t){return this.client.post(`/api/v1/contracts/${e}/payment-setup`,t)}async send(e,t){return this.client.post(`/api/v1/contracts/${e}/send`,{...t,deadline:t?.deadline?.toISOString()})}async cancel(e){return this.client.post(`/api/v1/contracts/${e}/cancel`,{})}async terminate(e,t){return this.client.post(`/api/v1/contracts/${e}/terminate`,t??{})}};var P=class{constructor(e){this.client=e}async createDocument(e,t){return this.client.post(`/api/v1/templates/${e}/documents`,t)}async sendForSigning(e,t){return this.client.post(`/api/v1/templates/${e}/signature-requests`,{...t,slotAssignments:t.slotAssignments.map(d)})}async createContract(e,t){return this.client.post(`/api/v1/templates/${e}/contracts`,{...t,contragent:d(t.contragent)})}};var C=class{constructor(e){this.client=e}async create(e,t){return this.client.post(`/api/v1/contracts/${e}/invoices`,t)}async list(e,t){let s=new URLSearchParams;t?.page&&s.set("page",String(t.page)),t?.limit&&s.set("limit",String(t.limit)),t?.status&&s.set("status",t.status),t?.type&&s.set("type",t.type),typeof t?.overdue=="boolean"&&s.set("overdue",String(t.overdue)),t?.dueDateFrom&&s.set("dueDateFrom",t.dueDateFrom),t?.dueDateTo&&s.set("dueDateTo",t.dueDateTo);let i=s.toString();return this.client.get(`/api/v1/contracts/${e}/invoices${i?`?${i}`:""}`)}async get(e,t){return this.client.get(`/api/v1/contracts/${e}/invoices/${t}`)}async send(e,t,s){return this.client.post(`/api/v1/contracts/${e}/invoices/${t}/send`,s??{})}async charge(e,t){return this.client.post(`/api/v1/contracts/${e}/invoices/${t}/charge`,{})}async markPaid(e,t,s){return this.client.post(`/api/v1/contracts/${e}/invoices/${t}/mark-paid`,s??{})}};var T=class{constructor(e){this.client=e}async listByContract(e){return this.client.get(`/api/v1/contracts/${e}/transactions`)}async get(e){return this.client.get(`/api/v1/transactions/${e}`)}};var S=class{constructor(e){this.client=e}async createSession(e){return this.client.post("/api/v1/embedded/sessions",{...e,email:$(e.email)})}};var E=class{constructor(e){this.client=e}async upload(e){return this.client.uploadFiles("/api/v1/media/upload",e)}};var w=require("crypto"),G=300*1e3,b=class{static verify(e,t,s,i){if(!e||!t||!s||!i)return{valid:!1};let c=new Date(s).getTime();if(isNaN(c))return{valid:!1};if(Math.abs(Date.now()-c)>G)return{valid:!1};let u=t.match(/^v1=([a-f0-9]+)$/i);if(!u||!u[1])return{valid:!1};let g=u[1],o=`${s}.${e}`,r=(0,w.createHmac)("sha256",i).update(o).digest("hex");if(g.length!==r.length)return{valid:!1};let m=Buffer.from(g,"hex"),l=Buffer.from(r,"hex");if(m.length!==l.length)return{valid:!1};if(!(0,w.timingSafeEqual)(m,l))return{valid:!1};try{return{valid:!0,envelope:JSON.parse(e)}}catch{return{valid:!1}}}static parse(e){return JSON.parse(e)}};var D=class{client;static webhooks=b;documents;signatures;contracts;templates;invoices;transactions;embedded;media;constructor(e){this.client=new y(e),this.documents=new f(this.client),this.signatures=new R(this.client),this.contracts=new v(this.client),this.templates=new P(this.client),this.invoices=new C(this.client),this.transactions=new T(this.client),this.embedded=new S(this.client),this.media=new E(this.client)}async getApiKeyInfo(){return this.client.get("/api/v1/me")}async healthCheck(){return this.client.get("/api/v1/health")}};0&&(module.exports={Chaindoc,ChaindocError}); | ||
| "use strict";var M=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var V=Object.prototype.hasOwnProperty;var G=(s,e)=>{for(var t in e)M(s,t,{get:e[t],enumerable:!0})},_=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of F(e))!V.call(s,i)&&i!==t&&M(s,i,{get:()=>e[i],enumerable:!(n=O(e,i))||n.enumerable});return s};var j=s=>_(M({},"__esModule",{value:!0}),s);var ne={};G(ne,{Chaindoc:()=>U,ChaindocError:()=>c});module.exports=j(ne);var c=class extends Error{constructor(t,n,i,m=!1){super(t);this.statusCode=n;this.response=i;this.isRetryable=m;this.name="ChaindocError"}};function B(s){if(!s)return;let t=s.match(/filename\*\s*=\s*[^']*'[^']*'([^;]+)/i)?.[1];if(t)try{return decodeURIComponent(t.trim())}catch{}let i=s.match(/filename\s*=\s*"?([^";]+)"?/i)?.[1];return i?i.trim():void 0}var K={production:"https://api.chaindoc.io",staging:"https://api.chaindoc.io",development:"https://api.chaindoc.io"},Z="production",W=3e4,J=3,X=1e3,Y=1e4,P=class{baseUrl;secretKey;timeout;defaultHeaders;retryConfig;constructor(e){if(!e.secretKey)throw new c("secretKey is required");if(!e.secretKey.startsWith("sk_"))throw new c('secretKey must start with "sk_"');let t=e.environment??Z;this.baseUrl=e.baseUrl??K[t],this.secretKey=e.secretKey,this.timeout=e.timeout??W,this.defaultHeaders={"Content-Type":"application/json",Authorization:`Bearer ${this.secretKey}`,...e.headers},this.retryConfig={maxRetries:e.retry?.maxRetries??J,baseDelayMs:e.retry?.baseDelayMs??X,maxDelayMs:e.retry?.maxDelayMs??Y}}getRetryDelay(e){let t=this.retryConfig.baseDelayMs*Math.pow(2,e),n=Math.min(t,this.retryConfig.maxDelayMs),i=n*.25*(Math.random()*2-1);return Math.round(n+i)}isRetryableError(e,t){return t&&t>=500||t===429?!0:e instanceof Error?["ECONNRESET","ECONNREFUSED","ETIMEDOUT","ENOTFOUND","EAI_AGAIN"].some(i=>e.message.includes(i))||e.name==="AbortError":!1}sleep(e){return new Promise(t=>setTimeout(t,e))}async request(e,t={}){let n=`${this.baseUrl}${e}`,i=t.noRetry?1:this.retryConfig.maxRetries+1,m;for(let l=0;l<i;l++){let d=new AbortController,g=setTimeout(()=>d.abort(),t.timeout??this.timeout);try{let a=await fetch(n,{method:t.method??"GET",headers:{...this.defaultHeaders,...t.headers},body:t.body?JSON.stringify(t.body):void 0,signal:d.signal});if(clearTimeout(g),a.status===204||a.headers.get("content-length")==="0")return;let r=a.headers.get("content-type")?.includes("application/json")?await a.json().catch(()=>{}):void 0;if(!a.ok){let p=r&&typeof r=="object"&&"message"in r&&typeof r.message=="string"?r.message:`Request failed with status ${a.status}`,h=this.isRetryableError(null,a.status);if(m=new c(p,a.status,r,h),h&&l<i-1){await this.sleep(this.getRetryDelay(l));continue}throw m}return r}catch(a){if(clearTimeout(g),a instanceof c){if(!a.isRetryable||l>=i-1)throw a;m=a,await this.sleep(this.getRetryDelay(l));continue}let o=this.isRetryableError(a);if(a instanceof Error){let r=a.name==="AbortError"?"Request timeout":a.message;if(m=new c(r,void 0,void 0,o),o&&l<i-1){await this.sleep(this.getRetryDelay(l));continue}throw m}throw new c("Unknown error occurred")}}throw m??new c("Request failed after retries")}async get(e,t){return this.request(e,{...t,method:"GET"})}async post(e,t,n){return this.request(e,{...n,method:"POST",body:t})}async put(e,t,n){return this.request(e,{...n,method:"PUT",body:t})}async patch(e,t,n){return this.request(e,{...n,method:"PATCH",body:t})}async delete(e,t){return this.request(e,{...t,method:"DELETE"})}async download(e,t){let n=`${this.baseUrl}${e}`,i=t?.noRetry?1:this.retryConfig.maxRetries+1,m=t?.method??"GET",l=t?.body!==void 0,d;for(let g=0;g<i;g++){let a=new AbortController,o=setTimeout(()=>a.abort(),t?.timeout??this.timeout);try{let r=await fetch(n,{method:m,headers:{...this.defaultHeaders,...l?{"Content-Type":"application/json"}:{},...t?.headers},body:l?JSON.stringify(t?.body):void 0,signal:a.signal});if(clearTimeout(o),!r.ok){let h=`Download failed with status ${r.status}`,R;(r.headers.get("content-type")??"").includes("application/json")&&(R=await r.json().catch(()=>{}),R&&typeof R=="object"&&"message"in R&&typeof R.message=="string"&&(h=R.message));let k=this.isRetryableError(null,r.status);if(d=new c(h,r.status,R,k),k&&g<i-1){await this.sleep(this.getRetryDelay(g));continue}throw d}return{data:await r.arrayBuffer(),contentType:r.headers.get("content-type")??"application/octet-stream",fileName:B(r.headers.get("content-disposition"))}}catch(r){if(clearTimeout(o),r instanceof c){if(!r.isRetryable||g>=i-1)throw r;d=r,await this.sleep(this.getRetryDelay(g));continue}let p=this.isRetryableError(r);if(r instanceof Error){let h=r.name==="AbortError"?"Download timeout":r.message;if(d=new c(h,void 0,void 0,p),p&&g<i-1){await this.sleep(this.getRetryDelay(g));continue}throw d}throw new c("Unknown error occurred")}}throw d??new c("Download failed after retries")}async uploadFiles(e,t,n="media"){let i=this.retryConfig.maxRetries+1,m;for(let l=0;l<i;l++){let d=new FormData;t.forEach(o=>{d.append(n,o)});let g=new AbortController,a=setTimeout(()=>g.abort(),this.timeout*2);try{let o=await fetch(`${this.baseUrl}${e}`,{method:"POST",headers:{Authorization:`Bearer ${this.secretKey}`},body:d,signal:g.signal});if(clearTimeout(a),o.status===204||o.headers.get("content-length")==="0")return;let p=o.headers.get("content-type")?.includes("application/json")?await o.json().catch(()=>{}):void 0;if(!o.ok){let h=p&&typeof p=="object"&&"message"in p&&typeof p.message=="string"?p.message:`Upload failed with status ${o.status}`,R=this.isRetryableError(null,o.status);if(m=new c(h,o.status,p,R),R&&l<i-1){await this.sleep(this.getRetryDelay(l));continue}throw m}return p}catch(o){if(clearTimeout(a),o instanceof c){if(!o.isRetryable||l>=i-1)throw o;m=o,await this.sleep(this.getRetryDelay(l));continue}let r=this.isRetryableError(o);if(o instanceof Error){let p=o.name==="AbortError"?"Upload timeout":o.message;if(m=new c(p,void 0,void 0,r),r&&l<i-1){await this.sleep(this.getRetryDelay(l));continue}throw m}throw new c("Unknown error occurred")}}throw m??new c("Upload failed after retries")}};function y(s){return typeof s!="string"?s:s.trim().toLowerCase()}function f(s){return typeof s.email!="string"?{...s}:{...s,email:s.email.trim().toLowerCase()}}function H(s){return typeof s.signerEmail!="string"?{...s}:{...s,signerEmail:s.signerEmail.trim().toLowerCase()}}var Q=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+$/;function ee(s){return typeof s!="string"?!1:Q.test(s.trim())}function u(s,e){if(!ee(s))throw new c(`Invalid email address at ${e}: ${JSON.stringify(s)}`)}var v=class{constructor(e){this.client=e}async add(e,t){return this.client.post(`/api/v1/documents/${e}/comments`,t)}async list(e,t){let n=new URLSearchParams;t?.pageNumber!==void 0&&n.set("pageNumber",String(t.pageNumber)),t?.pageSize!==void 0&&n.set("pageSize",String(t.pageSize));let i=n.toString();return this.client.get(`/api/v1/documents/${e}/comments${i?`?${i}`:""}`)}};function N(s){return s?.map(f)}var S=class{constructor(e){this.client=e;this.comments=new v(e)}comments;async create(e){return this.client.post("/api/v1/documents",{...e,accessEmails:N(e.accessEmails)})}async update(e,t){return this.client.put(`/api/v1/documents/${e}`,t)}async updateRights(e,t){return this.client.put(`/api/v1/documents/${e}/rights`,{...t,accessEmails:N(t.accessEmails)})}async verify(e){return this.client.post("/api/v1/documents/verify",e)}async getVerificationStatus(e){return this.client.get(`/api/v1/documents/versions/${e}/verification`)}async get(e){return this.client.get(`/api/v1/documents/${e}`)}async getVersions(e,t){let n=new URLSearchParams;t?.pageNumber!==void 0&&n.set("pageNumber",String(t.pageNumber)),t?.pageSize!==void 0&&n.set("pageSize",String(t.pageSize));let i=n.toString();return this.client.get(`/api/v1/documents/${e}/versions${i?`?${i}`:""}`)}async download(e){return this.client.download(`/api/v1/documents/versions/${e}/download`)}async preview(e){return this.client.download(`/api/v1/documents/versions/${e}/preview`)}async listShared(e){return this.client.get(`/api/v1/documents/shared${z(e)}`)}async search(e){return this.client.get(`/api/v1/documents/search${z(e)}`)}async getActivity(e){return this.client.get(`/api/v1/documents/${e}/activity`)}async getDownloads(e){return this.client.get(`/api/v1/documents/${e}/downloads`)}async sendPublicLink(e,t){return u(t.email,"email"),this.client.post(`/api/v1/documents/${e}/send-public-link`,{...t,email:y(t.email)})}};function z(s){if(!s)return"";let e=new URLSearchParams;s.pageNumber!==void 0&&e.set("pageNumber",String(s.pageNumber)),s.pageSize!==void 0&&e.set("pageSize",String(s.pageSize)),s.search!==void 0&&e.set("search",s.search),s.status!==void 0&&e.set("status",s.status);let t=e.toString();return t?`?${t}`:""}var C=class{constructor(e){this.client=e}async createRequest(e){return e.recipients.forEach((t,n)=>u(t?.email,`recipients[${n}].email`)),e.fields?.forEach((t,n)=>u(t?.signerEmail,`fields[${n}].signerEmail`)),this.client.post("/api/v1/signatures/requests",{...e,recipients:e.recipients.map(f),fields:e.fields?.map(H),deadline:e.deadline.toISOString()})}async getRequestStatus(e){return this.client.get(`/api/v1/signatures/requests/${e}/status`)}async getMyRequests(e){let t=new URLSearchParams;e?.pageNumber&&t.set("pageNumber",String(e.pageNumber)),e?.pageSize&&t.set("pageSize",String(e.pageSize)),e?.status&&t.set("status",e.status);let n=t.toString();return this.client.get(`/api/v1/signatures/requests${n?`?${n}`:""}`)}async editRequest(e,t){return u(t.recipient,"recipient"),this.client.post(`/api/v1/signatures/requests/${e}/edit`,{...t,recipient:y(t.recipient)})}async sign(e){return this.client.post("/api/v1/signatures/sign",e)}async getSignatures(e){let t=new URLSearchParams;e?.pageNumber&&t.set("pageNumber",String(e.pageNumber)),e?.pageSize&&t.set("pageSize",String(e.pageSize));let n=t.toString();return this.client.get(`/api/v1/signatures${n?`?${n}`:""}`)}async createSignature(e){return this.client.post("/api/v1/signatures",e)}async validatePdfSignatures(e){return this.client.uploadFiles("/api/v1/signatures/validate-pdf",[e],"file")}async cancel(e){return this.client.post(`/api/v1/signatures/requests/${e}/cancel`,{})}async remind(e,t){let n={};if(t?.signerEmails!==void 0){if(t.signerEmails.length===0)throw new c("signerEmails must contain at least one email when provided");t.signerEmails.forEach((i,m)=>u(i,`signerEmails[${m}]`)),n.signerEmails=t.signerEmails.map(i=>y(i))}return this.client.post(`/api/v1/signatures/requests/${e}/remind`,n)}async downloadCertificate(e){return this.client.download(`/api/v1/signatures/versions/${e}/certificate`)}async downloadSignedDocument(e){return this.client.download(`/api/v1/signatures/versions/${e}/signed-document`)}};var E=class{constructor(e){this.client=e}async get(e){return this.client.get(`/api/v1/contracts/${e}/termination`)}async getStatus(e){return this.client.get(`/api/v1/contracts/${e}/termination/status`)}async getHistory(e){return this.client.get(`/api/v1/contracts/${e}/termination/history`)}async approve(e,t){return this.client.post(`/api/v1/contracts/${e}/termination/approve`,t??{})}async reject(e,t){return this.client.post(`/api/v1/contracts/${e}/termination/reject`,t)}async cancel(e){return this.client.delete(`/api/v1/contracts/${e}/termination`)}};var T=class{constructor(e){this.client=e}async list(e){return this.client.get(`/api/v1/contracts/${e}/payment-terms`)}async create(e,t){return this.client.post(`/api/v1/contracts/${e}/payment-terms`,t)}async update(e,t,n){return this.client.patch(`/api/v1/contracts/${e}/payment-terms/${t}`,n)}async delete(e,t){return this.client.delete(`/api/v1/contracts/${e}/payment-terms/${t}`)}};var w=class{constructor(e){this.client=e}async create(e,t){return this.client.post(`/api/v1/contracts/${e}/agreements`,t)}async list(e){return this.client.get(`/api/v1/contracts/${e}/agreements`)}async get(e,t){return this.client.get(`/api/v1/contracts/${e}/agreements/${t}`)}async initiateSigning(e,t,n){let i=n?{...n,deadline:n.deadline?.toISOString()}:{};return this.client.post(`/api/v1/contracts/${e}/agreements/${t}/initiate-signing`,i)}async delete(e,t){return this.client.delete(`/api/v1/contracts/${e}/agreements/${t}`)}};var $=class{constructor(e){this.client=e;this.termination=new E(e),this.paymentTerms=new T(e),this.agreements=new w(e)}termination;paymentTerms;agreements;async create(e){return u(e.contragent?.email,"contragent.email"),this.client.post("/api/v1/contracts",{...e,contragent:f(e.contragent)})}async list(e){let t=new URLSearchParams;e?.page&&t.set("page",String(e.page)),e?.limit&&t.set("limit",String(e.limit)),e?.status&&t.set("status",e.status),e?.search&&t.set("search",e.search);let n=t.toString();return this.client.get(`/api/v1/contracts${n?`?${n}`:""}`)}async get(e){return this.client.get(`/api/v1/contracts/${e}`)}async getStatus(e){return this.client.get(`/api/v1/contracts/${e}/status`)}async getActivities(e,t){let n=new URLSearchParams;t?.page&&n.set("page",String(t.page)),t?.limit&&n.set("limit",String(t.limit));let i=n.toString();return this.client.get(`/api/v1/contracts/${e}/activities${i?`?${i}`:""}`)}async addPaymentSetup(e,t){return this.client.post(`/api/v1/contracts/${e}/payment-setup`,t)}async send(e,t){return this.client.post(`/api/v1/contracts/${e}/send`,{...t,deadline:t?.deadline?.toISOString()})}async cancel(e){return this.client.post(`/api/v1/contracts/${e}/cancel`,{})}async terminate(e,t){return this.client.post(`/api/v1/contracts/${e}/terminate`,t??{})}async update(e,t){return t.contragent!==void 0&&u(t.contragent.email,"contragent.email"),this.client.patch(`/api/v1/contracts/${e}`,{...t,contragent:t.contragent?f(t.contragent):void 0})}async delete(e){return this.client.delete(`/api/v1/contracts/${e}`)}async createEmpty(e){return u(e.contragentEmail,"contragentEmail"),this.client.post("/api/v1/contracts/empty",{...e,contragentEmail:y(e.contragentEmail)})}async createMinimal(e){return u(e.contragentEmail,"contragentEmail"),this.client.post("/api/v1/contracts/minimal",{...e,contragentEmail:y(e.contragentEmail)})}async import(e){return u(e.contragentEmail,"contragentEmail"),this.client.post("/api/v1/contracts/import",{...e,contragentEmail:y(e.contragentEmail)})}async attachDocument(e,t){return this.client.patch(`/api/v1/contracts/${e}/document`,t)}async getStats(e){return this.client.get(`/api/v1/contracts/${e}/stats`)}async setupRecurring(e,t){return this.client.post(`/api/v1/contracts/${e}/recurring-setup`,t)}async resendRecurringApproval(e){return this.client.post(`/api/v1/contracts/${e}/recurring-approval/resend`,{})}async cancelRecurringApproval(e){return this.client.delete(`/api/v1/contracts/${e}/recurring-approval`)}async listSigningRequests(e){return this.client.get(`/api/v1/contracts/${e}/signing-requests`)}async getSigningRequest(e,t){return this.client.get(`/api/v1/contracts/${e}/signing-requests/${t}`)}async resendSigningRequest(e,t){return this.client.post(`/api/v1/contracts/${e}/signing-requests/${t}/resend`,{})}async cancelSigningRequest(e,t){return this.client.delete(`/api/v1/contracts/${e}/signing-requests/${t}`)}async businessSign(e,t,n){return this.client.post(`/api/v1/contracts/${e}/signing-requests/${t}/business-sign`,n)}};var D=class{constructor(e){this.client=e}async list(e){let t=new URLSearchParams;e?.page!==void 0&&t.set("page",String(e.page)),e?.limit!==void 0&&t.set("limit",String(e.limit)),e?.status&&t.set("status",e.status),e?.search&&t.set("search",e.search);let n=t.toString();return this.client.get(`/api/v1/templates${n?`?${n}`:""}`)}async get(e){return this.client.get(`/api/v1/templates/${e}`)}async getVersions(e){return this.client.get(`/api/v1/templates/${e}/versions`)}async createDocument(e,t){return this.client.post(`/api/v1/templates/${e}/documents`,t)}async sendForSigning(e,t){return t.slotAssignments.forEach((n,i)=>u(n?.email,`slotAssignments[${i}].email`)),this.client.post(`/api/v1/templates/${e}/signature-requests`,{...t,slotAssignments:t.slotAssignments.map(f)})}async createContract(e,t){return u(t.contragent?.email,"contragent.email"),this.client.post(`/api/v1/templates/${e}/contracts`,{...t,contragent:f(t.contragent)})}async create(e){return this.client.post("/api/v1/templates",e)}async update(e,t){return this.client.patch(`/api/v1/templates/${e}`,t)}async publish(e,t){return this.client.post(`/api/v1/templates/${e}/publish`,t??{})}async archive(e){return this.client.post(`/api/v1/templates/${e}/archive`,{})}async restore(e){return this.client.post(`/api/v1/templates/${e}/restore`,{})}async delete(e){return this.client.delete(`/api/v1/templates/${e}`)}async previewPdf(e,t){return this.client.download(`/api/v1/templates/${e}/preview-pdf`,{method:"POST",body:t??{}})}async previewHtml(e,t){return this.client.post(`/api/v1/templates/${e}/preview-html`,t??{})}async previewUnsavedPdf(e){return this.client.download("/api/v1/templates/preview-unsaved-pdf",{method:"POST",body:e})}};var b=class{constructor(e){this.client=e}async create(e,t){return this.client.post(`/api/v1/contracts/${e}/invoices`,t)}async list(e,t){let n=new URLSearchParams;t?.page&&n.set("page",String(t.page)),t?.limit&&n.set("limit",String(t.limit)),t?.status&&n.set("status",t.status),t?.type&&n.set("type",t.type),typeof t?.overdue=="boolean"&&n.set("overdue",String(t.overdue)),t?.dueDateFrom&&n.set("dueDateFrom",t.dueDateFrom),t?.dueDateTo&&n.set("dueDateTo",t.dueDateTo);let i=n.toString();return this.client.get(`/api/v1/contracts/${e}/invoices${i?`?${i}`:""}`)}async listAll(e){let t=new URLSearchParams;e?.page&&t.set("page",String(e.page)),e?.limit&&t.set("limit",String(e.limit)),e?.status&&t.set("status",e.status),e?.type&&t.set("type",e.type),typeof e?.overdue=="boolean"&&t.set("overdue",String(e.overdue)),e?.dueDateFrom&&t.set("dueDateFrom",e.dueDateFrom),e?.dueDateTo&&t.set("dueDateTo",e.dueDateTo),e?.search&&t.set("search",e.search);let n=t.toString();return this.client.get(`/api/v1/invoices${n?`?${n}`:""}`)}async get(e,t){return this.client.get(`/api/v1/contracts/${e}/invoices/${t}`)}async send(e,t,n){return this.client.post(`/api/v1/contracts/${e}/invoices/${t}/send`,n??{})}async charge(e,t){return this.client.post(`/api/v1/contracts/${e}/invoices/${t}/charge`,{})}async markPaid(e,t,n){return this.client.post(`/api/v1/contracts/${e}/invoices/${t}/mark-paid`,n??{})}async update(e,t,n){return this.client.patch(`/api/v1/contracts/${e}/invoices/${t}`,n)}async cancel(e,t){return this.client.post(`/api/v1/contracts/${e}/invoices/${t}/cancel`,{})}async downloadPdf(e,t){return this.client.download(`/api/v1/contracts/${e}/invoices/${t}/pdf`)}};var A=class{constructor(e){this.client=e}async listByContract(e){return this.client.get(`/api/v1/contracts/${e}/transactions`)}async get(e){return this.client.get(`/api/v1/transactions/${e}`)}async getPaymentMix(e){let t=new URLSearchParams;return t.set("from",e.from),t.set("to",e.to),e.status!==void 0&&t.set("status",e.status),e.contractUuid!==void 0&&t.set("contractUuid",e.contractUuid),e.currencyCode!==void 0&&t.set("currencyCode",e.currencyCode),this.client.get(`/api/v1/transactions/payment-mix?${t.toString()}`)}async getFeeEstimate(e){let t=new URLSearchParams;return t.set("amount",String(e.amount)),t.set("currency",e.currency),e.platformFeePercent!==void 0&&t.set("platformFeePercent",String(e.platformFeePercent)),this.client.get(`/api/v1/transactions/fee-estimate?${t.toString()}`)}};var q=class{constructor(e){this.client=e}async createSession(e){return u(e.email,"email"),this.client.post("/api/v1/embedded/sessions",{...e,email:y(e.email)})}};var L=class{constructor(e){this.client=e}async upload(e){return this.client.uploadFiles("/api/v1/media/upload",e)}};var x=require("crypto"),te=300*1e3,I=class{static verify(e,t,n,i){if(!e||!t||!n||!i)return{valid:!1};let m=new Date(n).getTime();if(isNaN(m))return{valid:!1};if(Math.abs(Date.now()-m)>te)return{valid:!1};let d=t.match(/^v1=([a-f0-9]+)$/i);if(!d||!d[1])return{valid:!1};let g=d[1],a=`${n}.${e}`,o=(0,x.createHmac)("sha256",i).update(a).digest("hex");if(g.length!==o.length)return{valid:!1};let r=Buffer.from(g,"hex"),p=Buffer.from(o,"hex");if(r.length!==p.length)return{valid:!1};if(!(0,x.timingSafeEqual)(r,p))return{valid:!1};try{return{valid:!0,envelope:JSON.parse(e)}}catch{return{valid:!1}}}static parse(e){return JSON.parse(e)}};var U=class{client;static webhooks=I;documents;signatures;contracts;templates;invoices;transactions;embedded;media;constructor(e){this.client=new P(e),this.documents=new S(this.client),this.signatures=new C(this.client),this.contracts=new $(this.client),this.templates=new D(this.client),this.invoices=new b(this.client),this.transactions=new A(this.client),this.embedded=new q(this.client),this.media=new L(this.client)}async getApiKeyInfo(){return this.client.get("/api/v1/me")}async healthCheck(){return this.client.get("/api/v1/health")}};0&&(module.exports={Chaindoc,ChaindocError}); | ||
| //# sourceMappingURL=index.cjs.map |
+821
-5
@@ -54,2 +54,3 @@ interface RetryConfig { | ||
| type DocumentStatus = "draft" | "published" | "archived" | "pending_signature" | "signed"; | ||
| type DocumentStatusForCreate = "draft" | "published"; | ||
| type AccessType = "private" | "public" | "restricted" | "team"; | ||
@@ -70,3 +71,3 @@ interface AccessEmail { | ||
| hashtags: string[]; | ||
| status: DocumentStatus; | ||
| status: DocumentStatusForCreate; | ||
| isForSigning?: boolean; | ||
@@ -83,3 +84,3 @@ accessType?: AccessType; | ||
| hashtags: string[]; | ||
| status: DocumentStatus; | ||
| status: DocumentStatusForCreate; | ||
| isForSigning?: boolean; | ||
@@ -126,2 +127,135 @@ } | ||
| } | ||
| interface PublicDocumentMediaSummary { | ||
| name: string | null; | ||
| hash: string | null; | ||
| size: number | null; | ||
| } | ||
| interface PublicDocumentVersion { | ||
| id: string; | ||
| documentVersion: string; | ||
| name?: string | null; | ||
| description?: string | null; | ||
| status: DocumentStatus; | ||
| versionHash?: string | null; | ||
| isForSigning: boolean; | ||
| media: PublicDocumentMediaSummary | null; | ||
| meta: MetaTag[]; | ||
| tags: string[]; | ||
| createdAt: string; | ||
| updatedAt: string; | ||
| } | ||
| interface PublicDocumentDetail { | ||
| id: string; | ||
| txtId: string; | ||
| accessType: AccessType; | ||
| currentVersion: PublicDocumentVersion | null; | ||
| createdAt: string; | ||
| updatedAt: string; | ||
| } | ||
| interface GetDocumentResponse { | ||
| success: boolean; | ||
| document: PublicDocumentDetail; | ||
| } | ||
| interface ListDocumentVersionsParams { | ||
| pageNumber?: number; | ||
| pageSize?: number; | ||
| } | ||
| interface GetDocumentVersionsResponse { | ||
| success: boolean; | ||
| versions: PublicDocumentVersion[]; | ||
| pagination: { | ||
| pageNumber: number; | ||
| pageSize: number; | ||
| total: number; | ||
| totalPages: number; | ||
| }; | ||
| } | ||
| type DocumentSearchStatus = "draft" | "published" | "published_not_signed"; | ||
| interface DocumentSearchParams { | ||
| pageNumber?: number; | ||
| pageSize?: number; | ||
| search?: string; | ||
| status?: DocumentSearchStatus; | ||
| } | ||
| interface DocumentListResponse { | ||
| success: boolean; | ||
| documents: PublicDocumentDetail[]; | ||
| totalPublished: number; | ||
| totalDraft: number; | ||
| pagination: { | ||
| pageNumber: number; | ||
| pageSize: number; | ||
| total: number; | ||
| totalPages: number; | ||
| }; | ||
| } | ||
| interface DocumentActorRef { | ||
| username: string; | ||
| email: string; | ||
| } | ||
| interface DocumentActivityItem { | ||
| type: string; | ||
| timestamp: string; | ||
| document: { | ||
| id: string; | ||
| name: string; | ||
| version: string; | ||
| }; | ||
| user: DocumentActorRef | null; | ||
| } | ||
| interface DocumentActivityResponse { | ||
| success: boolean; | ||
| activity: DocumentActivityItem[]; | ||
| } | ||
| interface DocumentDownloadItem { | ||
| versionName: string; | ||
| documentVersion: string; | ||
| downloadedAt: string; | ||
| user: DocumentActorRef; | ||
| } | ||
| interface DocumentDownloadsResponse { | ||
| success: boolean; | ||
| downloads: DocumentDownloadItem[]; | ||
| } | ||
| interface CreateCommentParams { | ||
| content: string; | ||
| } | ||
| interface CommentListParams { | ||
| pageNumber?: number; | ||
| pageSize?: number; | ||
| } | ||
| interface PublicComment { | ||
| content: string; | ||
| createdAt: string; | ||
| updatedAt: string; | ||
| author: DocumentActorRef | null; | ||
| replyCount: number; | ||
| replies: PublicComment[]; | ||
| } | ||
| interface AddCommentResponse { | ||
| success: boolean; | ||
| comment: { | ||
| content: string; | ||
| createdAt: string; | ||
| updatedAt: string; | ||
| }; | ||
| message: string; | ||
| } | ||
| interface CommentListResponse { | ||
| success: boolean; | ||
| totalComments: number; | ||
| comments: PublicComment[]; | ||
| pagination: { | ||
| pageNumber: number; | ||
| pageSize: number; | ||
| }; | ||
| } | ||
| interface SendPublicLinkParams { | ||
| email: string; | ||
| text?: string; | ||
| } | ||
| interface SendPublicLinkResponse { | ||
| success: boolean; | ||
| message: string; | ||
| } | ||
| interface VerifyDocumentParams { | ||
@@ -184,2 +318,21 @@ versionHash: string; | ||
| } | ||
| interface CancelSignatureRequestResponse { | ||
| success: boolean; | ||
| requestId: string; | ||
| status: string; | ||
| message: string; | ||
| } | ||
| interface RemindSignatureRequestParams { | ||
| signerEmails?: string[]; | ||
| } | ||
| interface RemindSignatureRequestResponse { | ||
| success: boolean; | ||
| requestId: string; | ||
| remindedEmails: string[]; | ||
| skipped: { | ||
| email: string; | ||
| reason: string; | ||
| }[]; | ||
| message: string; | ||
| } | ||
| interface SignDocumentParams { | ||
@@ -238,2 +391,18 @@ requestId: string; | ||
| } | ||
| type SignatureRequestStatusFilter = 'all' | 'pending' | 'completed' | 'declined'; | ||
| interface GetMyRequestsParams { | ||
| pageNumber?: number; | ||
| pageSize?: number; | ||
| status?: SignatureRequestStatusFilter; | ||
| } | ||
| interface EditSignatureRequestParams { | ||
| signerId: string; | ||
| recipient: string; | ||
| } | ||
| interface EditSignatureRequestResponse { | ||
| success: boolean; | ||
| requestId: string; | ||
| request: SignatureRequest | null; | ||
| message: string; | ||
| } | ||
| interface SavedSignature { | ||
@@ -251,2 +420,28 @@ hash: string; | ||
| } | ||
| interface CreateSignatureParams { | ||
| media: Media$1 & { | ||
| type: 'image'; | ||
| }; | ||
| } | ||
| interface CreateSignatureResponse { | ||
| success: boolean; | ||
| signature: SavedSignature; | ||
| message: string; | ||
| } | ||
| interface ValidatePdfSignaturesResponse { | ||
| success: boolean; | ||
| valid: boolean; | ||
| signatureCount: number; | ||
| details: Record<string, unknown>; | ||
| } | ||
| interface BusinessSignParams { | ||
| signatureHash: string; | ||
| meta?: MetaTag[]; | ||
| } | ||
| interface BusinessSignResponse { | ||
| success: boolean; | ||
| contractId: string; | ||
| signingRequestId: string; | ||
| message: string; | ||
| } | ||
| interface CreateEmbeddedSessionParams { | ||
@@ -305,2 +500,5 @@ email: string; | ||
| type ContractSignerSource = 'embedded' | 'delegated_api'; | ||
| type ContractSigningRequestStatus = 'pending' | 'completed' | 'expired' | 'cancelled'; | ||
| type ContractSigningRequestPurpose = 'signature' | 'recurring_approval'; | ||
| type ContractSignerStatus = 'pending' | 'accepted' | 'rejected' | 'declined'; | ||
| interface BillingAddress { | ||
@@ -334,2 +532,8 @@ line1: string; | ||
| } | ||
| interface RecurringPaymentTermInput extends Omit<PaymentTermInput, 'type' | 'frequency' | 'dayOfPeriod' | 'startDate' | 'dueDate'> { | ||
| type: 'recurring'; | ||
| frequency: PaymentFrequency; | ||
| dayOfPeriod: number; | ||
| startDate: string; | ||
| } | ||
| interface PaymentTermResponse { | ||
@@ -515,2 +719,295 @@ id: string; | ||
| } | ||
| interface UpdateContractParams { | ||
| title?: string; | ||
| description?: string; | ||
| contragent?: ContragentInfo; | ||
| startDate?: string; | ||
| endDate?: string; | ||
| autoRenew?: boolean; | ||
| terminationType?: TerminationType; | ||
| noticePeriodDays?: number; | ||
| paymentMethodRequired?: boolean; | ||
| preferredPaymentMethodType?: ContractPreferredPaymentMethodType | null; | ||
| } | ||
| interface CreateEmptyContractParams { | ||
| title: string; | ||
| description?: string; | ||
| contragentEmail: string; | ||
| contragentName?: string; | ||
| currencyCode?: string; | ||
| } | ||
| interface CreateMinimalContractParams { | ||
| documentId: string; | ||
| title: string; | ||
| description?: string; | ||
| contragentEmail: string; | ||
| contragentName?: string; | ||
| skipPaymentSetup?: boolean; | ||
| } | ||
| interface CreateImportContractParams { | ||
| documentId: string; | ||
| title: string; | ||
| description?: string; | ||
| contragentEmail: string; | ||
| contragentName?: string; | ||
| currencyCode?: string; | ||
| startDate?: string; | ||
| endDate?: string; | ||
| } | ||
| interface AttachDocumentParams { | ||
| documentId: string; | ||
| } | ||
| interface ContractStats { | ||
| contractValue: number | null; | ||
| hasPaymentTerms: boolean; | ||
| paidAmount: number; | ||
| pendingAmount: number; | ||
| remainingAmount: number | null; | ||
| invoiceCount: number; | ||
| isOverpaid: boolean; | ||
| showPaymentStats: boolean; | ||
| } | ||
| interface ContractStatsResponse { | ||
| success: boolean; | ||
| contractId: string; | ||
| stats: ContractStats; | ||
| } | ||
| interface RecurringSetupParams { | ||
| paymentTerms: RecurringPaymentTermInput[]; | ||
| paymentMethodRequired?: boolean; | ||
| messageToContragent?: string; | ||
| expiresInDays?: number; | ||
| } | ||
| type TerminationRequestStatus = 'pending' | 'approved' | 'rejected' | 'executed'; | ||
| interface TerminationApproval { | ||
| approved: boolean; | ||
| approvedAt?: string; | ||
| } | ||
| interface TerminationApprovals { | ||
| business: TerminationApproval; | ||
| contragent: TerminationApproval; | ||
| } | ||
| interface TerminationRejection { | ||
| reason: string; | ||
| rejectedBy: { | ||
| email: string; | ||
| role: SignerRole; | ||
| }; | ||
| rejectedAt: string; | ||
| } | ||
| interface TerminationRequest { | ||
| id: string; | ||
| status: TerminationRequestStatus; | ||
| contract: { | ||
| id: string; | ||
| title: string; | ||
| terminationType: TerminationType; | ||
| noticePeriodDays: number; | ||
| }; | ||
| initiatedBy: { | ||
| email: string; | ||
| name: string | null; | ||
| role: SignerRole; | ||
| }; | ||
| reason: string; | ||
| requestDate: string; | ||
| effectiveDate: string; | ||
| approvals?: TerminationApprovals; | ||
| rejection?: TerminationRejection; | ||
| outstandingAmount?: string; | ||
| allInvoicesSettled: boolean; | ||
| daysUntilEffective: number; | ||
| canCancel: boolean; | ||
| canApprove: boolean; | ||
| canReject: boolean; | ||
| createdAt: string; | ||
| } | ||
| interface OutstandingInvoiceSummary { | ||
| uuid: string; | ||
| invoiceNumber: string; | ||
| amount: string; | ||
| dueDate: string; | ||
| } | ||
| interface TerminationStatus { | ||
| hasActiveRequest: boolean; | ||
| currentRequest?: { | ||
| uuid: string; | ||
| status: TerminationRequestStatus; | ||
| effectiveDate: string; | ||
| daysRemaining: number; | ||
| }; | ||
| outstandingInvoices: { | ||
| count: number; | ||
| totalAmount: string; | ||
| invoices: OutstandingInvoiceSummary[]; | ||
| }; | ||
| upcomingPayments: { | ||
| count: number; | ||
| totalAmount: string; | ||
| }; | ||
| canInitiateTermination: boolean; | ||
| terminationType: TerminationType; | ||
| noticePeriodDays: number; | ||
| earliestEffectiveDate: string; | ||
| } | ||
| interface ApproveTerminationParams { | ||
| comment?: string; | ||
| } | ||
| interface RejectTerminationParams { | ||
| reason: string; | ||
| } | ||
| interface TerminationRequestEnvelope { | ||
| success: boolean; | ||
| terminationRequest: TerminationRequest | null; | ||
| } | ||
| interface TerminationStatusEnvelope { | ||
| success: boolean; | ||
| contractId: string; | ||
| status: TerminationStatus; | ||
| } | ||
| interface TerminationHistoryEnvelope { | ||
| success: boolean; | ||
| items: TerminationRequest[]; | ||
| total: number; | ||
| } | ||
| interface TerminationApproveEnvelope { | ||
| success: boolean; | ||
| terminationRequest: TerminationRequest; | ||
| message: string; | ||
| } | ||
| interface UpdatePaymentTermParams { | ||
| name?: string; | ||
| amount?: string; | ||
| description?: string; | ||
| frequency?: PaymentFrequency; | ||
| dayOfPeriod?: number; | ||
| startDate?: string; | ||
| endDate?: string; | ||
| totalPayments?: number; | ||
| dueDate?: string; | ||
| autoCharge?: boolean; | ||
| isActive?: boolean; | ||
| } | ||
| interface PaymentTermListResponse { | ||
| success: boolean; | ||
| contractId: string; | ||
| paymentTerms: PaymentTermResponse[]; | ||
| } | ||
| interface PaymentTermEnvelope { | ||
| success: boolean; | ||
| contractId: string; | ||
| paymentTerm: PaymentTermResponse; | ||
| message: string; | ||
| } | ||
| interface PaymentTermDeleteResponse { | ||
| success: boolean; | ||
| contractId: string; | ||
| paymentTermId: string; | ||
| message: string; | ||
| } | ||
| interface SigningRequestActionResponse { | ||
| success: boolean; | ||
| contractId: string; | ||
| signingRequestId: string; | ||
| message: string; | ||
| } | ||
| interface SigningRequestSummary { | ||
| id: string; | ||
| status: ContractSigningRequestStatus; | ||
| purpose: ContractSigningRequestPurpose; | ||
| termsChanged: boolean; | ||
| expiresAt: string; | ||
| messageToSigners: string | null; | ||
| createdAt: string; | ||
| updatedAt: string; | ||
| } | ||
| interface SigningRequestSigner { | ||
| email: string; | ||
| role: SignerRole; | ||
| status: ContractSignerStatus; | ||
| signed: boolean; | ||
| signedAt: string | null; | ||
| signingSource: ContractSignerSource; | ||
| } | ||
| interface SigningRequestDetail extends SigningRequestSummary { | ||
| signers: SigningRequestSigner[]; | ||
| } | ||
| interface SigningRequestListResponse { | ||
| success: boolean; | ||
| contractId: string; | ||
| signingRequests: SigningRequestSummary[]; | ||
| } | ||
| interface SigningRequestGetResponse { | ||
| success: boolean; | ||
| contractId: string; | ||
| signingRequest: SigningRequestDetail; | ||
| } | ||
| type PaymentTermModificationAction = 'add' | 'update' | 'deactivate'; | ||
| interface PaymentTermModificationInput { | ||
| action: PaymentTermModificationAction; | ||
| paymentTermId?: string; | ||
| type?: PaymentTermType; | ||
| name?: string; | ||
| description?: string; | ||
| amount?: string; | ||
| frequency?: PaymentFrequency; | ||
| dayOfPeriod?: number; | ||
| startDate?: string; | ||
| endDate?: string; | ||
| totalPayments?: number; | ||
| dueDate?: string; | ||
| autoCharge?: boolean; | ||
| } | ||
| interface CreateAgreementParams { | ||
| documentId: string; | ||
| title: string; | ||
| description?: string; | ||
| effectiveDate?: string; | ||
| modifiesPaymentTerms?: boolean; | ||
| paymentTermModifications?: PaymentTermModificationInput[]; | ||
| } | ||
| interface InitiateAgreementSigningParams { | ||
| messageToSigners?: string; | ||
| deadline?: Date; | ||
| isKycRequired?: boolean; | ||
| notifyContragent?: boolean; | ||
| } | ||
| interface AdditionalAgreement { | ||
| id: string; | ||
| document: { | ||
| id: string; | ||
| } | null; | ||
| title: string; | ||
| description?: string; | ||
| status: ContractStatus; | ||
| effectiveDate?: string; | ||
| modifiesPaymentTerms: boolean; | ||
| createdAt: string; | ||
| updatedAt: string; | ||
| } | ||
| interface AgreementEnvelope { | ||
| success: boolean; | ||
| contractId: string; | ||
| agreement: AdditionalAgreement; | ||
| message?: string; | ||
| } | ||
| interface AgreementListResponse { | ||
| success: boolean; | ||
| contractId: string; | ||
| agreements: AdditionalAgreement[]; | ||
| } | ||
| interface AgreementSigningResponse { | ||
| success: boolean; | ||
| contractId: string; | ||
| agreementId: string; | ||
| signingRequestId: string; | ||
| status: string; | ||
| message: string; | ||
| } | ||
| interface AgreementDeleteResponse { | ||
| success: boolean; | ||
| contractId: string; | ||
| agreementId: string; | ||
| message: string; | ||
| } | ||
| type ContractWebhookEventType = Extract<WebhookEventType, 'contract.created' | 'contract.status_changed' | 'contract.signed' | 'contract.cancelled' | 'contract.terminated'>; | ||
@@ -600,2 +1097,163 @@ type TemplateVariables = Record<string, string | number | boolean>; | ||
| } | ||
| type TemplateStatus = "draft" | "published" | "archived"; | ||
| type TemplateVariableDataType = "text" | "long_text" | "date" | "number" | "boolean"; | ||
| type TemplateVariableScope = "document" | "signer"; | ||
| interface TemplateVariable { | ||
| key: string; | ||
| label: string; | ||
| dataType: TemplateVariableDataType; | ||
| scope: TemplateVariableScope; | ||
| signerKey?: string; | ||
| systemKey?: string; | ||
| required: boolean; | ||
| defaultValue?: string | number | boolean; | ||
| description?: string; | ||
| } | ||
| interface TemplatePlacedField { | ||
| fieldType: "signature" | "initials" | "date_signed" | "text" | "checkbox"; | ||
| pageIndex: number; | ||
| xPct: number; | ||
| yPct: number; | ||
| wPct: number; | ||
| hPct: number; | ||
| required: boolean; | ||
| systemKey?: string; | ||
| label?: string; | ||
| } | ||
| interface TemplateSignerSlot { | ||
| signerKey: string; | ||
| signerLabel: string; | ||
| fields: TemplatePlacedField[]; | ||
| } | ||
| interface TemplateSignatureRequirement { | ||
| signerKey: string; | ||
| signerLabel: string; | ||
| fieldType: "signature" | "initials" | "date_signed" | "text" | "checkbox"; | ||
| required: boolean; | ||
| label?: string; | ||
| } | ||
| interface TemplateRenderConfig { | ||
| format?: string; | ||
| marginTop?: number; | ||
| marginBottom?: number; | ||
| marginLeft?: number; | ||
| marginRight?: number; | ||
| } | ||
| interface ListTemplatesParams { | ||
| page?: number; | ||
| limit?: number; | ||
| status?: TemplateStatus; | ||
| search?: string; | ||
| } | ||
| interface TemplateVersionRef { | ||
| versionNumber: number; | ||
| } | ||
| interface TemplateVersionDetail { | ||
| versionNumber: number; | ||
| variablesSchema: TemplateVariable[]; | ||
| signerSlots: TemplateSignerSlot[]; | ||
| signatureRequirements: TemplateSignatureRequirement[]; | ||
| renderConfig?: TemplateRenderConfig; | ||
| changelog?: string; | ||
| createdAt: string; | ||
| updatedAt: string; | ||
| } | ||
| interface TemplateSummary { | ||
| id: string; | ||
| name?: string; | ||
| description?: string; | ||
| status: TemplateStatus; | ||
| category: string; | ||
| currentVersion: TemplateVersionRef | null; | ||
| lastPublishedVersion: TemplateVersionRef | null; | ||
| createdAt: string; | ||
| updatedAt: string; | ||
| } | ||
| interface TemplateDetail { | ||
| id: string; | ||
| name?: string; | ||
| description?: string; | ||
| status: TemplateStatus; | ||
| category: string; | ||
| currentVersion: TemplateVersionDetail | null; | ||
| lastPublishedVersion: TemplateVersionDetail | null; | ||
| createdAt: string; | ||
| updatedAt: string; | ||
| } | ||
| interface TemplateListResponse { | ||
| success: boolean; | ||
| templates: TemplateSummary[]; | ||
| pagination: { | ||
| page: number; | ||
| limit: number; | ||
| total: number; | ||
| totalPages: number; | ||
| }; | ||
| } | ||
| interface TemplateGetResponse { | ||
| success: boolean; | ||
| template: TemplateDetail; | ||
| } | ||
| interface TemplateVersionsResponse { | ||
| success: boolean; | ||
| versions: TemplateVersionDetail[]; | ||
| } | ||
| type TemplateCategory = "contract" | "agreement" | "invoice" | "nda" | "proposal" | "letter" | "other"; | ||
| interface TemplateVariableInput { | ||
| key: string; | ||
| label: string; | ||
| dataType: TemplateVariableDataType; | ||
| scope?: TemplateVariableScope; | ||
| signerKey?: string; | ||
| systemKey?: string; | ||
| required: boolean; | ||
| defaultValue?: string | number | boolean; | ||
| description?: string; | ||
| } | ||
| interface CreateTemplateParams { | ||
| name: string; | ||
| description?: string; | ||
| category: TemplateCategory; | ||
| contentJson: Record<string, unknown>; | ||
| variablesSchema?: TemplateVariableInput[]; | ||
| signatureRequirements?: TemplateSignatureRequirement[]; | ||
| signerSlots?: TemplateSignerSlot[]; | ||
| renderConfig?: TemplateRenderConfig; | ||
| meta?: MetaTag[]; | ||
| } | ||
| interface UpdateTemplateParams { | ||
| name?: string; | ||
| description?: string; | ||
| category?: TemplateCategory; | ||
| contentJson?: Record<string, unknown>; | ||
| variablesSchema?: TemplateVariableInput[]; | ||
| signatureRequirements?: TemplateSignatureRequirement[]; | ||
| signerSlots?: TemplateSignerSlot[]; | ||
| renderConfig?: TemplateRenderConfig; | ||
| } | ||
| interface PublishTemplateParams { | ||
| changelog?: string; | ||
| } | ||
| interface PreviewTemplateParams { | ||
| variables?: Record<string, string | number | boolean>; | ||
| } | ||
| interface PreviewTemplateHtmlResponse { | ||
| success: boolean; | ||
| html: string; | ||
| } | ||
| interface PreviewUnsavedPdfParams { | ||
| contentJson: Record<string, unknown>; | ||
| renderConfig?: TemplateRenderConfig; | ||
| variables?: Record<string, string | number | boolean>; | ||
| } | ||
| interface TemplateEnvelope { | ||
| success: boolean; | ||
| template: TemplateDetail; | ||
| message: string; | ||
| } | ||
| interface TemplateDeleteResponse { | ||
| success: boolean; | ||
| templateId: string; | ||
| message: string; | ||
| } | ||
| type InvoiceStatus = 'draft' | 'pending' | 'unpaid' | 'paid' | 'partially_paid' | 'overdue' | 'cancelled' | 'refunded'; | ||
@@ -672,5 +1330,14 @@ type InvoiceType = 'automatic' | 'manual'; | ||
| } | ||
| interface InvoiceListAllParams extends InvoiceListParams { | ||
| search?: string; | ||
| } | ||
| interface SendInvoiceParams { | ||
| autoCharge?: boolean; | ||
| } | ||
| interface UpdateInvoiceParams { | ||
| title?: string; | ||
| description?: string; | ||
| dueDate?: string; | ||
| lineItems?: InvoiceLineItemInput[]; | ||
| } | ||
| interface MarkInvoicePaidParams { | ||
@@ -745,2 +1412,52 @@ note?: string; | ||
| } | ||
| interface PaymentMixParams { | ||
| from: string; | ||
| to: string; | ||
| status?: TransactionStatus; | ||
| contractUuid?: string; | ||
| currencyCode?: string; | ||
| } | ||
| interface PaymentMixMethod { | ||
| paymentMethodType: string; | ||
| count: number; | ||
| totalAmount: string; | ||
| totalStripeFee: string; | ||
| totalPlatformFee: string; | ||
| avgStripeFeePercent: number; | ||
| } | ||
| interface PaymentMixResponse { | ||
| success: boolean; | ||
| dateRange: { | ||
| from: string; | ||
| to: string; | ||
| }; | ||
| totalTransactions: number; | ||
| byMethod: PaymentMixMethod[]; | ||
| estimatedSavingsIfAllBankTransfer?: string; | ||
| } | ||
| interface FeeEstimateParams { | ||
| amount: number; | ||
| currency: string; | ||
| platformFeePercent?: number; | ||
| } | ||
| interface FeeEstimateMethod { | ||
| paymentMethodType: string; | ||
| stripeFeePercent: number; | ||
| stripeFeeFixed: number; | ||
| estimatedStripeFee: string; | ||
| platformFeePercent: number; | ||
| estimatedPlatformFee: string; | ||
| estimatedTotalFee: string; | ||
| totalFeePercent: number; | ||
| isApproximate: boolean; | ||
| } | ||
| interface FeeEstimateResponse { | ||
| success: boolean; | ||
| amount: number; | ||
| currency: string; | ||
| methods: FeeEstimateMethod[]; | ||
| } | ||
| interface InvoiceListAllResponse extends InvoiceListResponse { | ||
| statusCounts: Record<string, number>; | ||
| } | ||
| type InvoiceWebhookEventType = Extract<WebhookEventType, 'invoice.created' | 'invoice.sent' | 'invoice.paid' | 'invoice.cancelled'>; | ||
@@ -756,3 +1473,3 @@ type TransactionWebhookEventType = Extract<WebhookEventType, 'transaction.created' | 'transaction.updated'>; | ||
| interface RequestOptions { | ||
| method?: "GET" | "POST" | "PUT" | "DELETE"; | ||
| method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE"; | ||
| body?: unknown; | ||
@@ -763,2 +1480,7 @@ headers?: Record<string, string>; | ||
| } | ||
| interface DownloadResult { | ||
| data: ArrayBuffer; | ||
| contentType: string; | ||
| fileName?: string; | ||
| } | ||
| declare class HttpClient { | ||
@@ -778,8 +1500,20 @@ private baseUrl; | ||
| put<T>(endpoint: string, body?: unknown, options?: Omit<RequestOptions, "method" | "body">): Promise<T>; | ||
| patch<T>(endpoint: string, body?: unknown, options?: Omit<RequestOptions, "method" | "body">): Promise<T>; | ||
| delete<T>(endpoint: string, options?: Omit<RequestOptions, "method" | "body">): Promise<T>; | ||
| download(endpoint: string, options?: Omit<RequestOptions, "method"> & { | ||
| method?: "GET" | "POST"; | ||
| }): Promise<DownloadResult>; | ||
| uploadFiles<T>(endpoint: string, files: File[] | Blob[], fieldName?: string): Promise<T>; | ||
| } | ||
| declare class DocumentComments { | ||
| private client; | ||
| constructor(client: HttpClient); | ||
| add(documentId: string, params: CreateCommentParams): Promise<AddCommentResponse>; | ||
| list(documentId: string, params?: CommentListParams): Promise<CommentListResponse>; | ||
| } | ||
| declare class Documents { | ||
| private client; | ||
| readonly comments: DocumentComments; | ||
| constructor(client: HttpClient); | ||
@@ -791,2 +1525,11 @@ create(params: CreateDocumentParams): Promise<DocumentResponse>; | ||
| getVerificationStatus(versionId: string): Promise<VerifyDocumentResponse>; | ||
| get(documentId: string): Promise<GetDocumentResponse>; | ||
| getVersions(documentId: string, params?: ListDocumentVersionsParams): Promise<GetDocumentVersionsResponse>; | ||
| download(versionId: string): Promise<DownloadResult>; | ||
| preview(versionId: string): Promise<DownloadResult>; | ||
| listShared(params?: DocumentSearchParams): Promise<DocumentListResponse>; | ||
| search(params?: DocumentSearchParams): Promise<DocumentListResponse>; | ||
| getActivity(documentId: string): Promise<DocumentActivityResponse>; | ||
| getDownloads(documentId: string): Promise<DocumentDownloadsResponse>; | ||
| sendPublicLink(documentId: string, params: SendPublicLinkParams): Promise<SendPublicLinkResponse>; | ||
| } | ||
@@ -799,3 +1542,4 @@ | ||
| getRequestStatus(requestId: string): Promise<SignatureRequestStatus>; | ||
| getMyRequests(pagination?: PaginationParams): Promise<GetMyRequestsResponse>; | ||
| getMyRequests(params?: GetMyRequestsParams): Promise<GetMyRequestsResponse>; | ||
| editRequest(requestId: string, params: EditSignatureRequestParams): Promise<EditSignatureRequestResponse>; | ||
| sign(params: SignDocumentParams): Promise<{ | ||
@@ -808,6 +1552,45 @@ success: boolean; | ||
| getSignatures(pagination?: PaginationParams): Promise<GetSignaturesResponse>; | ||
| createSignature(params: CreateSignatureParams): Promise<CreateSignatureResponse>; | ||
| validatePdfSignatures(file: File | Blob): Promise<ValidatePdfSignaturesResponse>; | ||
| cancel(requestId: string): Promise<CancelSignatureRequestResponse>; | ||
| remind(requestId: string, params?: RemindSignatureRequestParams): Promise<RemindSignatureRequestResponse>; | ||
| downloadCertificate(versionId: string): Promise<DownloadResult>; | ||
| downloadSignedDocument(versionId: string): Promise<DownloadResult>; | ||
| } | ||
| declare class ContractTermination { | ||
| private client; | ||
| constructor(client: HttpClient); | ||
| get(contractId: string): Promise<TerminationRequestEnvelope>; | ||
| getStatus(contractId: string): Promise<TerminationStatusEnvelope>; | ||
| getHistory(contractId: string): Promise<TerminationHistoryEnvelope>; | ||
| approve(contractId: string, params?: ApproveTerminationParams): Promise<TerminationApproveEnvelope>; | ||
| reject(contractId: string, params: RejectTerminationParams): Promise<ContractActionResponse>; | ||
| cancel(contractId: string): Promise<ContractActionResponse>; | ||
| } | ||
| declare class ContractPaymentTerms { | ||
| private client; | ||
| constructor(client: HttpClient); | ||
| list(contractId: string): Promise<PaymentTermListResponse>; | ||
| create(contractId: string, params: PaymentTermInput): Promise<PaymentTermEnvelope>; | ||
| update(contractId: string, termId: string, params: UpdatePaymentTermParams): Promise<PaymentTermEnvelope>; | ||
| delete(contractId: string, termId: string): Promise<PaymentTermDeleteResponse>; | ||
| } | ||
| declare class ContractAgreements { | ||
| private client; | ||
| constructor(client: HttpClient); | ||
| create(contractId: string, params: CreateAgreementParams): Promise<AgreementEnvelope>; | ||
| list(contractId: string): Promise<AgreementListResponse>; | ||
| get(contractId: string, agreementId: string): Promise<AgreementEnvelope>; | ||
| initiateSigning(contractId: string, agreementId: string, params?: InitiateAgreementSigningParams): Promise<AgreementSigningResponse>; | ||
| delete(contractId: string, agreementId: string): Promise<AgreementDeleteResponse>; | ||
| } | ||
| declare class Contracts { | ||
| private client; | ||
| readonly termination: ContractTermination; | ||
| readonly paymentTerms: ContractPaymentTerms; | ||
| readonly agreements: ContractAgreements; | ||
| constructor(client: HttpClient); | ||
@@ -823,2 +1606,17 @@ create(params: CreateContractParams): Promise<ContractResponse>; | ||
| terminate(contractId: string, params?: TerminateContractParams): Promise<ContractActionResponse>; | ||
| update(contractId: string, params: UpdateContractParams): Promise<ContractResponse>; | ||
| delete(contractId: string): Promise<ContractActionResponse>; | ||
| createEmpty(params: CreateEmptyContractParams): Promise<ContractResponse>; | ||
| createMinimal(params: CreateMinimalContractParams): Promise<ContractResponse>; | ||
| import(params: CreateImportContractParams): Promise<ContractResponse>; | ||
| attachDocument(contractId: string, params: AttachDocumentParams): Promise<ContractResponse>; | ||
| getStats(contractId: string): Promise<ContractStatsResponse>; | ||
| setupRecurring(contractId: string, params: RecurringSetupParams): Promise<ContractResponse>; | ||
| resendRecurringApproval(contractId: string): Promise<ContractActionResponse>; | ||
| cancelRecurringApproval(contractId: string): Promise<ContractActionResponse>; | ||
| listSigningRequests(contractId: string): Promise<SigningRequestListResponse>; | ||
| getSigningRequest(contractId: string, requestId: string): Promise<SigningRequestGetResponse>; | ||
| resendSigningRequest(contractId: string, requestId: string): Promise<SigningRequestActionResponse>; | ||
| cancelSigningRequest(contractId: string, requestId: string): Promise<SigningRequestActionResponse>; | ||
| businessSign(contractId: string, requestId: string, params: BusinessSignParams): Promise<BusinessSignResponse>; | ||
| } | ||
@@ -829,5 +1627,17 @@ | ||
| constructor(client: HttpClient); | ||
| list(params?: ListTemplatesParams): Promise<TemplateListResponse>; | ||
| get(templateId: string): Promise<TemplateGetResponse>; | ||
| getVersions(templateId: string): Promise<TemplateVersionsResponse>; | ||
| createDocument(templateId: string, params: CreateDocumentFromTemplateParams): Promise<TemplateDocumentResponse>; | ||
| sendForSigning(templateId: string, params: CreateTemplateSignatureRequestParams): Promise<TemplateSignatureRequestResponse>; | ||
| createContract(templateId: string, params: CreateContractFromTemplateParams): Promise<TemplateContractResponse>; | ||
| create(params: CreateTemplateParams): Promise<TemplateEnvelope>; | ||
| update(templateId: string, params: UpdateTemplateParams): Promise<TemplateEnvelope>; | ||
| publish(templateId: string, params?: PublishTemplateParams): Promise<TemplateEnvelope>; | ||
| archive(templateId: string): Promise<TemplateEnvelope>; | ||
| restore(templateId: string): Promise<TemplateEnvelope>; | ||
| delete(templateId: string): Promise<TemplateDeleteResponse>; | ||
| previewPdf(templateId: string, params?: PreviewTemplateParams): Promise<DownloadResult>; | ||
| previewHtml(templateId: string, params?: PreviewTemplateParams): Promise<PreviewTemplateHtmlResponse>; | ||
| previewUnsavedPdf(params: PreviewUnsavedPdfParams): Promise<DownloadResult>; | ||
| } | ||
@@ -840,2 +1650,3 @@ | ||
| list(contractId: string, params?: InvoiceListParams): Promise<InvoiceListResponse>; | ||
| listAll(params?: InvoiceListAllParams): Promise<InvoiceListAllResponse>; | ||
| get(contractId: string, invoiceId: string): Promise<InvoiceResponse>; | ||
@@ -845,2 +1656,5 @@ send(contractId: string, invoiceId: string, params?: SendInvoiceParams): Promise<InvoiceActionResponse>; | ||
| markPaid(contractId: string, invoiceId: string, params?: MarkInvoicePaidParams): Promise<InvoiceResponse>; | ||
| update(contractId: string, invoiceId: string, params: UpdateInvoiceParams): Promise<InvoiceResponse>; | ||
| cancel(contractId: string, invoiceId: string): Promise<InvoiceActionResponse>; | ||
| downloadPdf(contractId: string, invoiceId: string): Promise<DownloadResult>; | ||
| } | ||
@@ -853,2 +1667,4 @@ | ||
| get(transactionId: string): Promise<TransactionResponse>; | ||
| getPaymentMix(params: PaymentMixParams): Promise<PaymentMixResponse>; | ||
| getFeeEstimate(params: FeeEstimateParams): Promise<FeeEstimateResponse>; | ||
| } | ||
@@ -889,2 +1705,2 @@ | ||
| export { type AccessEmail, type AccessRole, type AccessType, type ApiKeyInfo, type ApiResponse, type BillingAddress, Chaindoc, type ChaindocConfig, type ChaindocEnvironment, ChaindocError, type Contract, type ContractActionResponse, type ContractActivitiesResponse, type ContractContragent, type ContractDocument, type ContractListParams, type ContractListResponse, type ContractOrigin, type ContractPreferredPaymentMethodType, type ContractResponse, type ContractSendParams, type ContractSendResponse, type ContractSigner, type ContractSignerSource, type ContractSigningMethod, type ContractSigningPolicy, type ContractSigningRequest, type ContractStatus, type ContractStatusResponse, type ContractWebhookEventType, type ContragentInfo, type CreateContractFromTemplateParams, type CreateContractParams, type CreateDocumentFromTemplateParams, type CreateDocumentParams, type CreateEmbeddedSessionParams, type CreateInvoiceParams, type CreateSignatureRequestParams, type CreateTemplateSignatureRequestParams, type Document, type DocumentResponse, type DocumentSigningMethod, type DocumentStatus, type DocumentTag, type DocumentVersion, type EmbeddedSessionResponse, type GetMyRequestsResponse, type GetSignaturesResponse, type HealthCheckResponse, type Invoice, type InvoiceActionResponse, type InvoiceContractSummary, type InvoiceLineItem, type InvoiceLineItemInput, type InvoiceListParams, type InvoiceListResponse, type InvoiceResponse, type InvoiceStatus, type InvoiceTransactionSummary, type InvoiceType, type InvoiceWebhookEventType, type MarkInvoicePaidParams, type Media$1 as Media, type MediaType, type MediaUploadResponse, type MetaTag, type PaginatedResponse, type PaginationParams, type PaymentFrequency, type PaymentSetupParams, type PaymentTermApprovalStatus, type PaymentTermInput, type PaymentTermResponse, type PaymentTermType, type Recipient, type RetryConfig, type SavedSignature, type SendInvoiceParams, type SignDocumentParams, type SignRequestStatus, type SignatureRequest, type SignatureRequestField, type SignatureRequestFieldType, type SignatureRequestResponse, type SignatureRequestStatus, type Signer, type SignerRole, type SignerUser, type TemplateContractResponse, type TemplateContractSlotAssignment, type TemplateDocument, type TemplateDocumentResponse, type TemplateDocumentVersion, type TemplateSignatureRequestResponse, type TemplateSlotAssignment, type TemplateSlotSigningMethod, type TemplateVariables, type TerminateContractParams, type TerminationType, type Transaction, type TransactionContractSummary, type TransactionInvoiceSummary, type TransactionListResponse, type TransactionResponse, type TransactionStatus, type TransactionWebhookEventType, type UpdateDocumentParams, type UpdateDocumentRightsParams, type VerificationStatus, type VerificationTxStatus, type VerifyDocumentParams, type VerifyDocumentResponse, type WebhookEnvelope, type WebhookEventType, type WebhookVerificationResult }; | ||
| export { type AccessEmail, type AccessRole, type AccessType, type AddCommentResponse, type AdditionalAgreement, type AgreementDeleteResponse, type AgreementEnvelope, type AgreementListResponse, type AgreementSigningResponse, type ApiKeyInfo, type ApiResponse, type ApproveTerminationParams, type AttachDocumentParams, type BillingAddress, type BusinessSignParams, type BusinessSignResponse, type CancelSignatureRequestResponse, Chaindoc, type ChaindocConfig, type ChaindocEnvironment, ChaindocError, type CommentListParams, type CommentListResponse, type Contract, type ContractActionResponse, type ContractActivitiesResponse, type ContractContragent, type ContractDocument, type ContractListParams, type ContractListResponse, type ContractOrigin, type ContractPreferredPaymentMethodType, type ContractResponse, type ContractSendParams, type ContractSendResponse, type ContractSigner, type ContractSignerSource, type ContractSignerStatus, type ContractSigningMethod, type ContractSigningPolicy, type ContractSigningRequest, type ContractSigningRequestPurpose, type ContractSigningRequestStatus, type ContractStats, type ContractStatsResponse, type ContractStatus, type ContractStatusResponse, type ContractWebhookEventType, type ContragentInfo, type CreateAgreementParams, type CreateCommentParams, type CreateContractFromTemplateParams, type CreateContractParams, type CreateDocumentFromTemplateParams, type CreateDocumentParams, type CreateEmbeddedSessionParams, type CreateEmptyContractParams, type CreateImportContractParams, type CreateInvoiceParams, type CreateMinimalContractParams, type CreateSignatureParams, type CreateSignatureRequestParams, type CreateSignatureResponse, type CreateTemplateParams, type CreateTemplateSignatureRequestParams, type Document, type DocumentActivityItem, type DocumentActivityResponse, type DocumentActorRef, type DocumentDownloadItem, type DocumentDownloadsResponse, type DocumentListResponse, type DocumentResponse, type DocumentSearchParams, type DocumentSearchStatus, type DocumentSigningMethod, type DocumentStatus, type DocumentStatusForCreate, type DocumentTag, type DocumentVersion, type DownloadResult, type EditSignatureRequestParams, type EditSignatureRequestResponse, type EmbeddedSessionResponse, type FeeEstimateMethod, type FeeEstimateParams, type FeeEstimateResponse, type GetDocumentResponse, type GetDocumentVersionsResponse, type GetMyRequestsParams, type GetMyRequestsResponse, type GetSignaturesResponse, type HealthCheckResponse, type InitiateAgreementSigningParams, type Invoice, type InvoiceActionResponse, type InvoiceContractSummary, type InvoiceLineItem, type InvoiceLineItemInput, type InvoiceListAllParams, type InvoiceListAllResponse, type InvoiceListParams, type InvoiceListResponse, type InvoiceResponse, type InvoiceStatus, type InvoiceTransactionSummary, type InvoiceType, type InvoiceWebhookEventType, type ListDocumentVersionsParams, type ListTemplatesParams, type MarkInvoicePaidParams, type Media$1 as Media, type MediaType, type MediaUploadResponse, type MetaTag, type OutstandingInvoiceSummary, type PaginatedResponse, type PaginationParams, type PaymentFrequency, type PaymentMixMethod, type PaymentMixParams, type PaymentMixResponse, type PaymentSetupParams, type PaymentTermApprovalStatus, type PaymentTermDeleteResponse, type PaymentTermEnvelope, type PaymentTermInput, type PaymentTermListResponse, type PaymentTermModificationAction, type PaymentTermModificationInput, type PaymentTermResponse, type PaymentTermType, type PreviewTemplateHtmlResponse, type PreviewTemplateParams, type PreviewUnsavedPdfParams, type PublicComment, type PublicDocumentDetail, type PublicDocumentMediaSummary, type PublicDocumentVersion, type PublishTemplateParams, type Recipient, type RecurringPaymentTermInput, type RecurringSetupParams, type RejectTerminationParams, type RemindSignatureRequestParams, type RemindSignatureRequestResponse, type RetryConfig, type SavedSignature, type SendInvoiceParams, type SendPublicLinkParams, type SendPublicLinkResponse, type SignDocumentParams, type SignRequestStatus, type SignatureRequest, type SignatureRequestField, type SignatureRequestFieldType, type SignatureRequestResponse, type SignatureRequestStatus, type SignatureRequestStatusFilter, type Signer, type SignerRole, type SignerUser, type SigningRequestActionResponse, type SigningRequestDetail, type SigningRequestGetResponse, type SigningRequestListResponse, type SigningRequestSigner, type SigningRequestSummary, type TemplateCategory, type TemplateContractResponse, type TemplateContractSlotAssignment, type TemplateDeleteResponse, type TemplateDetail, type TemplateDocument, type TemplateDocumentResponse, type TemplateDocumentVersion, type TemplateEnvelope, type TemplateGetResponse, type TemplateListResponse, type TemplatePlacedField, type TemplateRenderConfig, type TemplateSignatureRequestResponse, type TemplateSignatureRequirement, type TemplateSignerSlot, type TemplateSlotAssignment, type TemplateSlotSigningMethod, type TemplateStatus, type TemplateSummary, type TemplateVariable, type TemplateVariableDataType, type TemplateVariableInput, type TemplateVariableScope, type TemplateVariables, type TemplateVersionDetail, type TemplateVersionRef, type TemplateVersionsResponse, type TerminateContractParams, type TerminationApproval, type TerminationApprovals, type TerminationApproveEnvelope, type TerminationHistoryEnvelope, type TerminationRejection, type TerminationRequest, type TerminationRequestEnvelope, type TerminationRequestStatus, type TerminationStatus, type TerminationStatusEnvelope, type TerminationType, type Transaction, type TransactionContractSummary, type TransactionInvoiceSummary, type TransactionListResponse, type TransactionResponse, type TransactionStatus, type TransactionWebhookEventType, type UpdateContractParams, type UpdateDocumentParams, type UpdateDocumentRightsParams, type UpdateInvoiceParams, type UpdatePaymentTermParams, type UpdateTemplateParams, type ValidatePdfSignaturesResponse, type VerificationStatus, type VerificationTxStatus, type VerifyDocumentParams, type VerifyDocumentResponse, type WebhookEnvelope, type WebhookEventType, type WebhookVerificationResult }; |
+821
-5
@@ -54,2 +54,3 @@ interface RetryConfig { | ||
| type DocumentStatus = "draft" | "published" | "archived" | "pending_signature" | "signed"; | ||
| type DocumentStatusForCreate = "draft" | "published"; | ||
| type AccessType = "private" | "public" | "restricted" | "team"; | ||
@@ -70,3 +71,3 @@ interface AccessEmail { | ||
| hashtags: string[]; | ||
| status: DocumentStatus; | ||
| status: DocumentStatusForCreate; | ||
| isForSigning?: boolean; | ||
@@ -83,3 +84,3 @@ accessType?: AccessType; | ||
| hashtags: string[]; | ||
| status: DocumentStatus; | ||
| status: DocumentStatusForCreate; | ||
| isForSigning?: boolean; | ||
@@ -126,2 +127,135 @@ } | ||
| } | ||
| interface PublicDocumentMediaSummary { | ||
| name: string | null; | ||
| hash: string | null; | ||
| size: number | null; | ||
| } | ||
| interface PublicDocumentVersion { | ||
| id: string; | ||
| documentVersion: string; | ||
| name?: string | null; | ||
| description?: string | null; | ||
| status: DocumentStatus; | ||
| versionHash?: string | null; | ||
| isForSigning: boolean; | ||
| media: PublicDocumentMediaSummary | null; | ||
| meta: MetaTag[]; | ||
| tags: string[]; | ||
| createdAt: string; | ||
| updatedAt: string; | ||
| } | ||
| interface PublicDocumentDetail { | ||
| id: string; | ||
| txtId: string; | ||
| accessType: AccessType; | ||
| currentVersion: PublicDocumentVersion | null; | ||
| createdAt: string; | ||
| updatedAt: string; | ||
| } | ||
| interface GetDocumentResponse { | ||
| success: boolean; | ||
| document: PublicDocumentDetail; | ||
| } | ||
| interface ListDocumentVersionsParams { | ||
| pageNumber?: number; | ||
| pageSize?: number; | ||
| } | ||
| interface GetDocumentVersionsResponse { | ||
| success: boolean; | ||
| versions: PublicDocumentVersion[]; | ||
| pagination: { | ||
| pageNumber: number; | ||
| pageSize: number; | ||
| total: number; | ||
| totalPages: number; | ||
| }; | ||
| } | ||
| type DocumentSearchStatus = "draft" | "published" | "published_not_signed"; | ||
| interface DocumentSearchParams { | ||
| pageNumber?: number; | ||
| pageSize?: number; | ||
| search?: string; | ||
| status?: DocumentSearchStatus; | ||
| } | ||
| interface DocumentListResponse { | ||
| success: boolean; | ||
| documents: PublicDocumentDetail[]; | ||
| totalPublished: number; | ||
| totalDraft: number; | ||
| pagination: { | ||
| pageNumber: number; | ||
| pageSize: number; | ||
| total: number; | ||
| totalPages: number; | ||
| }; | ||
| } | ||
| interface DocumentActorRef { | ||
| username: string; | ||
| email: string; | ||
| } | ||
| interface DocumentActivityItem { | ||
| type: string; | ||
| timestamp: string; | ||
| document: { | ||
| id: string; | ||
| name: string; | ||
| version: string; | ||
| }; | ||
| user: DocumentActorRef | null; | ||
| } | ||
| interface DocumentActivityResponse { | ||
| success: boolean; | ||
| activity: DocumentActivityItem[]; | ||
| } | ||
| interface DocumentDownloadItem { | ||
| versionName: string; | ||
| documentVersion: string; | ||
| downloadedAt: string; | ||
| user: DocumentActorRef; | ||
| } | ||
| interface DocumentDownloadsResponse { | ||
| success: boolean; | ||
| downloads: DocumentDownloadItem[]; | ||
| } | ||
| interface CreateCommentParams { | ||
| content: string; | ||
| } | ||
| interface CommentListParams { | ||
| pageNumber?: number; | ||
| pageSize?: number; | ||
| } | ||
| interface PublicComment { | ||
| content: string; | ||
| createdAt: string; | ||
| updatedAt: string; | ||
| author: DocumentActorRef | null; | ||
| replyCount: number; | ||
| replies: PublicComment[]; | ||
| } | ||
| interface AddCommentResponse { | ||
| success: boolean; | ||
| comment: { | ||
| content: string; | ||
| createdAt: string; | ||
| updatedAt: string; | ||
| }; | ||
| message: string; | ||
| } | ||
| interface CommentListResponse { | ||
| success: boolean; | ||
| totalComments: number; | ||
| comments: PublicComment[]; | ||
| pagination: { | ||
| pageNumber: number; | ||
| pageSize: number; | ||
| }; | ||
| } | ||
| interface SendPublicLinkParams { | ||
| email: string; | ||
| text?: string; | ||
| } | ||
| interface SendPublicLinkResponse { | ||
| success: boolean; | ||
| message: string; | ||
| } | ||
| interface VerifyDocumentParams { | ||
@@ -184,2 +318,21 @@ versionHash: string; | ||
| } | ||
| interface CancelSignatureRequestResponse { | ||
| success: boolean; | ||
| requestId: string; | ||
| status: string; | ||
| message: string; | ||
| } | ||
| interface RemindSignatureRequestParams { | ||
| signerEmails?: string[]; | ||
| } | ||
| interface RemindSignatureRequestResponse { | ||
| success: boolean; | ||
| requestId: string; | ||
| remindedEmails: string[]; | ||
| skipped: { | ||
| email: string; | ||
| reason: string; | ||
| }[]; | ||
| message: string; | ||
| } | ||
| interface SignDocumentParams { | ||
@@ -238,2 +391,18 @@ requestId: string; | ||
| } | ||
| type SignatureRequestStatusFilter = 'all' | 'pending' | 'completed' | 'declined'; | ||
| interface GetMyRequestsParams { | ||
| pageNumber?: number; | ||
| pageSize?: number; | ||
| status?: SignatureRequestStatusFilter; | ||
| } | ||
| interface EditSignatureRequestParams { | ||
| signerId: string; | ||
| recipient: string; | ||
| } | ||
| interface EditSignatureRequestResponse { | ||
| success: boolean; | ||
| requestId: string; | ||
| request: SignatureRequest | null; | ||
| message: string; | ||
| } | ||
| interface SavedSignature { | ||
@@ -251,2 +420,28 @@ hash: string; | ||
| } | ||
| interface CreateSignatureParams { | ||
| media: Media$1 & { | ||
| type: 'image'; | ||
| }; | ||
| } | ||
| interface CreateSignatureResponse { | ||
| success: boolean; | ||
| signature: SavedSignature; | ||
| message: string; | ||
| } | ||
| interface ValidatePdfSignaturesResponse { | ||
| success: boolean; | ||
| valid: boolean; | ||
| signatureCount: number; | ||
| details: Record<string, unknown>; | ||
| } | ||
| interface BusinessSignParams { | ||
| signatureHash: string; | ||
| meta?: MetaTag[]; | ||
| } | ||
| interface BusinessSignResponse { | ||
| success: boolean; | ||
| contractId: string; | ||
| signingRequestId: string; | ||
| message: string; | ||
| } | ||
| interface CreateEmbeddedSessionParams { | ||
@@ -305,2 +500,5 @@ email: string; | ||
| type ContractSignerSource = 'embedded' | 'delegated_api'; | ||
| type ContractSigningRequestStatus = 'pending' | 'completed' | 'expired' | 'cancelled'; | ||
| type ContractSigningRequestPurpose = 'signature' | 'recurring_approval'; | ||
| type ContractSignerStatus = 'pending' | 'accepted' | 'rejected' | 'declined'; | ||
| interface BillingAddress { | ||
@@ -334,2 +532,8 @@ line1: string; | ||
| } | ||
| interface RecurringPaymentTermInput extends Omit<PaymentTermInput, 'type' | 'frequency' | 'dayOfPeriod' | 'startDate' | 'dueDate'> { | ||
| type: 'recurring'; | ||
| frequency: PaymentFrequency; | ||
| dayOfPeriod: number; | ||
| startDate: string; | ||
| } | ||
| interface PaymentTermResponse { | ||
@@ -515,2 +719,295 @@ id: string; | ||
| } | ||
| interface UpdateContractParams { | ||
| title?: string; | ||
| description?: string; | ||
| contragent?: ContragentInfo; | ||
| startDate?: string; | ||
| endDate?: string; | ||
| autoRenew?: boolean; | ||
| terminationType?: TerminationType; | ||
| noticePeriodDays?: number; | ||
| paymentMethodRequired?: boolean; | ||
| preferredPaymentMethodType?: ContractPreferredPaymentMethodType | null; | ||
| } | ||
| interface CreateEmptyContractParams { | ||
| title: string; | ||
| description?: string; | ||
| contragentEmail: string; | ||
| contragentName?: string; | ||
| currencyCode?: string; | ||
| } | ||
| interface CreateMinimalContractParams { | ||
| documentId: string; | ||
| title: string; | ||
| description?: string; | ||
| contragentEmail: string; | ||
| contragentName?: string; | ||
| skipPaymentSetup?: boolean; | ||
| } | ||
| interface CreateImportContractParams { | ||
| documentId: string; | ||
| title: string; | ||
| description?: string; | ||
| contragentEmail: string; | ||
| contragentName?: string; | ||
| currencyCode?: string; | ||
| startDate?: string; | ||
| endDate?: string; | ||
| } | ||
| interface AttachDocumentParams { | ||
| documentId: string; | ||
| } | ||
| interface ContractStats { | ||
| contractValue: number | null; | ||
| hasPaymentTerms: boolean; | ||
| paidAmount: number; | ||
| pendingAmount: number; | ||
| remainingAmount: number | null; | ||
| invoiceCount: number; | ||
| isOverpaid: boolean; | ||
| showPaymentStats: boolean; | ||
| } | ||
| interface ContractStatsResponse { | ||
| success: boolean; | ||
| contractId: string; | ||
| stats: ContractStats; | ||
| } | ||
| interface RecurringSetupParams { | ||
| paymentTerms: RecurringPaymentTermInput[]; | ||
| paymentMethodRequired?: boolean; | ||
| messageToContragent?: string; | ||
| expiresInDays?: number; | ||
| } | ||
| type TerminationRequestStatus = 'pending' | 'approved' | 'rejected' | 'executed'; | ||
| interface TerminationApproval { | ||
| approved: boolean; | ||
| approvedAt?: string; | ||
| } | ||
| interface TerminationApprovals { | ||
| business: TerminationApproval; | ||
| contragent: TerminationApproval; | ||
| } | ||
| interface TerminationRejection { | ||
| reason: string; | ||
| rejectedBy: { | ||
| email: string; | ||
| role: SignerRole; | ||
| }; | ||
| rejectedAt: string; | ||
| } | ||
| interface TerminationRequest { | ||
| id: string; | ||
| status: TerminationRequestStatus; | ||
| contract: { | ||
| id: string; | ||
| title: string; | ||
| terminationType: TerminationType; | ||
| noticePeriodDays: number; | ||
| }; | ||
| initiatedBy: { | ||
| email: string; | ||
| name: string | null; | ||
| role: SignerRole; | ||
| }; | ||
| reason: string; | ||
| requestDate: string; | ||
| effectiveDate: string; | ||
| approvals?: TerminationApprovals; | ||
| rejection?: TerminationRejection; | ||
| outstandingAmount?: string; | ||
| allInvoicesSettled: boolean; | ||
| daysUntilEffective: number; | ||
| canCancel: boolean; | ||
| canApprove: boolean; | ||
| canReject: boolean; | ||
| createdAt: string; | ||
| } | ||
| interface OutstandingInvoiceSummary { | ||
| uuid: string; | ||
| invoiceNumber: string; | ||
| amount: string; | ||
| dueDate: string; | ||
| } | ||
| interface TerminationStatus { | ||
| hasActiveRequest: boolean; | ||
| currentRequest?: { | ||
| uuid: string; | ||
| status: TerminationRequestStatus; | ||
| effectiveDate: string; | ||
| daysRemaining: number; | ||
| }; | ||
| outstandingInvoices: { | ||
| count: number; | ||
| totalAmount: string; | ||
| invoices: OutstandingInvoiceSummary[]; | ||
| }; | ||
| upcomingPayments: { | ||
| count: number; | ||
| totalAmount: string; | ||
| }; | ||
| canInitiateTermination: boolean; | ||
| terminationType: TerminationType; | ||
| noticePeriodDays: number; | ||
| earliestEffectiveDate: string; | ||
| } | ||
| interface ApproveTerminationParams { | ||
| comment?: string; | ||
| } | ||
| interface RejectTerminationParams { | ||
| reason: string; | ||
| } | ||
| interface TerminationRequestEnvelope { | ||
| success: boolean; | ||
| terminationRequest: TerminationRequest | null; | ||
| } | ||
| interface TerminationStatusEnvelope { | ||
| success: boolean; | ||
| contractId: string; | ||
| status: TerminationStatus; | ||
| } | ||
| interface TerminationHistoryEnvelope { | ||
| success: boolean; | ||
| items: TerminationRequest[]; | ||
| total: number; | ||
| } | ||
| interface TerminationApproveEnvelope { | ||
| success: boolean; | ||
| terminationRequest: TerminationRequest; | ||
| message: string; | ||
| } | ||
| interface UpdatePaymentTermParams { | ||
| name?: string; | ||
| amount?: string; | ||
| description?: string; | ||
| frequency?: PaymentFrequency; | ||
| dayOfPeriod?: number; | ||
| startDate?: string; | ||
| endDate?: string; | ||
| totalPayments?: number; | ||
| dueDate?: string; | ||
| autoCharge?: boolean; | ||
| isActive?: boolean; | ||
| } | ||
| interface PaymentTermListResponse { | ||
| success: boolean; | ||
| contractId: string; | ||
| paymentTerms: PaymentTermResponse[]; | ||
| } | ||
| interface PaymentTermEnvelope { | ||
| success: boolean; | ||
| contractId: string; | ||
| paymentTerm: PaymentTermResponse; | ||
| message: string; | ||
| } | ||
| interface PaymentTermDeleteResponse { | ||
| success: boolean; | ||
| contractId: string; | ||
| paymentTermId: string; | ||
| message: string; | ||
| } | ||
| interface SigningRequestActionResponse { | ||
| success: boolean; | ||
| contractId: string; | ||
| signingRequestId: string; | ||
| message: string; | ||
| } | ||
| interface SigningRequestSummary { | ||
| id: string; | ||
| status: ContractSigningRequestStatus; | ||
| purpose: ContractSigningRequestPurpose; | ||
| termsChanged: boolean; | ||
| expiresAt: string; | ||
| messageToSigners: string | null; | ||
| createdAt: string; | ||
| updatedAt: string; | ||
| } | ||
| interface SigningRequestSigner { | ||
| email: string; | ||
| role: SignerRole; | ||
| status: ContractSignerStatus; | ||
| signed: boolean; | ||
| signedAt: string | null; | ||
| signingSource: ContractSignerSource; | ||
| } | ||
| interface SigningRequestDetail extends SigningRequestSummary { | ||
| signers: SigningRequestSigner[]; | ||
| } | ||
| interface SigningRequestListResponse { | ||
| success: boolean; | ||
| contractId: string; | ||
| signingRequests: SigningRequestSummary[]; | ||
| } | ||
| interface SigningRequestGetResponse { | ||
| success: boolean; | ||
| contractId: string; | ||
| signingRequest: SigningRequestDetail; | ||
| } | ||
| type PaymentTermModificationAction = 'add' | 'update' | 'deactivate'; | ||
| interface PaymentTermModificationInput { | ||
| action: PaymentTermModificationAction; | ||
| paymentTermId?: string; | ||
| type?: PaymentTermType; | ||
| name?: string; | ||
| description?: string; | ||
| amount?: string; | ||
| frequency?: PaymentFrequency; | ||
| dayOfPeriod?: number; | ||
| startDate?: string; | ||
| endDate?: string; | ||
| totalPayments?: number; | ||
| dueDate?: string; | ||
| autoCharge?: boolean; | ||
| } | ||
| interface CreateAgreementParams { | ||
| documentId: string; | ||
| title: string; | ||
| description?: string; | ||
| effectiveDate?: string; | ||
| modifiesPaymentTerms?: boolean; | ||
| paymentTermModifications?: PaymentTermModificationInput[]; | ||
| } | ||
| interface InitiateAgreementSigningParams { | ||
| messageToSigners?: string; | ||
| deadline?: Date; | ||
| isKycRequired?: boolean; | ||
| notifyContragent?: boolean; | ||
| } | ||
| interface AdditionalAgreement { | ||
| id: string; | ||
| document: { | ||
| id: string; | ||
| } | null; | ||
| title: string; | ||
| description?: string; | ||
| status: ContractStatus; | ||
| effectiveDate?: string; | ||
| modifiesPaymentTerms: boolean; | ||
| createdAt: string; | ||
| updatedAt: string; | ||
| } | ||
| interface AgreementEnvelope { | ||
| success: boolean; | ||
| contractId: string; | ||
| agreement: AdditionalAgreement; | ||
| message?: string; | ||
| } | ||
| interface AgreementListResponse { | ||
| success: boolean; | ||
| contractId: string; | ||
| agreements: AdditionalAgreement[]; | ||
| } | ||
| interface AgreementSigningResponse { | ||
| success: boolean; | ||
| contractId: string; | ||
| agreementId: string; | ||
| signingRequestId: string; | ||
| status: string; | ||
| message: string; | ||
| } | ||
| interface AgreementDeleteResponse { | ||
| success: boolean; | ||
| contractId: string; | ||
| agreementId: string; | ||
| message: string; | ||
| } | ||
| type ContractWebhookEventType = Extract<WebhookEventType, 'contract.created' | 'contract.status_changed' | 'contract.signed' | 'contract.cancelled' | 'contract.terminated'>; | ||
@@ -600,2 +1097,163 @@ type TemplateVariables = Record<string, string | number | boolean>; | ||
| } | ||
| type TemplateStatus = "draft" | "published" | "archived"; | ||
| type TemplateVariableDataType = "text" | "long_text" | "date" | "number" | "boolean"; | ||
| type TemplateVariableScope = "document" | "signer"; | ||
| interface TemplateVariable { | ||
| key: string; | ||
| label: string; | ||
| dataType: TemplateVariableDataType; | ||
| scope: TemplateVariableScope; | ||
| signerKey?: string; | ||
| systemKey?: string; | ||
| required: boolean; | ||
| defaultValue?: string | number | boolean; | ||
| description?: string; | ||
| } | ||
| interface TemplatePlacedField { | ||
| fieldType: "signature" | "initials" | "date_signed" | "text" | "checkbox"; | ||
| pageIndex: number; | ||
| xPct: number; | ||
| yPct: number; | ||
| wPct: number; | ||
| hPct: number; | ||
| required: boolean; | ||
| systemKey?: string; | ||
| label?: string; | ||
| } | ||
| interface TemplateSignerSlot { | ||
| signerKey: string; | ||
| signerLabel: string; | ||
| fields: TemplatePlacedField[]; | ||
| } | ||
| interface TemplateSignatureRequirement { | ||
| signerKey: string; | ||
| signerLabel: string; | ||
| fieldType: "signature" | "initials" | "date_signed" | "text" | "checkbox"; | ||
| required: boolean; | ||
| label?: string; | ||
| } | ||
| interface TemplateRenderConfig { | ||
| format?: string; | ||
| marginTop?: number; | ||
| marginBottom?: number; | ||
| marginLeft?: number; | ||
| marginRight?: number; | ||
| } | ||
| interface ListTemplatesParams { | ||
| page?: number; | ||
| limit?: number; | ||
| status?: TemplateStatus; | ||
| search?: string; | ||
| } | ||
| interface TemplateVersionRef { | ||
| versionNumber: number; | ||
| } | ||
| interface TemplateVersionDetail { | ||
| versionNumber: number; | ||
| variablesSchema: TemplateVariable[]; | ||
| signerSlots: TemplateSignerSlot[]; | ||
| signatureRequirements: TemplateSignatureRequirement[]; | ||
| renderConfig?: TemplateRenderConfig; | ||
| changelog?: string; | ||
| createdAt: string; | ||
| updatedAt: string; | ||
| } | ||
| interface TemplateSummary { | ||
| id: string; | ||
| name?: string; | ||
| description?: string; | ||
| status: TemplateStatus; | ||
| category: string; | ||
| currentVersion: TemplateVersionRef | null; | ||
| lastPublishedVersion: TemplateVersionRef | null; | ||
| createdAt: string; | ||
| updatedAt: string; | ||
| } | ||
| interface TemplateDetail { | ||
| id: string; | ||
| name?: string; | ||
| description?: string; | ||
| status: TemplateStatus; | ||
| category: string; | ||
| currentVersion: TemplateVersionDetail | null; | ||
| lastPublishedVersion: TemplateVersionDetail | null; | ||
| createdAt: string; | ||
| updatedAt: string; | ||
| } | ||
| interface TemplateListResponse { | ||
| success: boolean; | ||
| templates: TemplateSummary[]; | ||
| pagination: { | ||
| page: number; | ||
| limit: number; | ||
| total: number; | ||
| totalPages: number; | ||
| }; | ||
| } | ||
| interface TemplateGetResponse { | ||
| success: boolean; | ||
| template: TemplateDetail; | ||
| } | ||
| interface TemplateVersionsResponse { | ||
| success: boolean; | ||
| versions: TemplateVersionDetail[]; | ||
| } | ||
| type TemplateCategory = "contract" | "agreement" | "invoice" | "nda" | "proposal" | "letter" | "other"; | ||
| interface TemplateVariableInput { | ||
| key: string; | ||
| label: string; | ||
| dataType: TemplateVariableDataType; | ||
| scope?: TemplateVariableScope; | ||
| signerKey?: string; | ||
| systemKey?: string; | ||
| required: boolean; | ||
| defaultValue?: string | number | boolean; | ||
| description?: string; | ||
| } | ||
| interface CreateTemplateParams { | ||
| name: string; | ||
| description?: string; | ||
| category: TemplateCategory; | ||
| contentJson: Record<string, unknown>; | ||
| variablesSchema?: TemplateVariableInput[]; | ||
| signatureRequirements?: TemplateSignatureRequirement[]; | ||
| signerSlots?: TemplateSignerSlot[]; | ||
| renderConfig?: TemplateRenderConfig; | ||
| meta?: MetaTag[]; | ||
| } | ||
| interface UpdateTemplateParams { | ||
| name?: string; | ||
| description?: string; | ||
| category?: TemplateCategory; | ||
| contentJson?: Record<string, unknown>; | ||
| variablesSchema?: TemplateVariableInput[]; | ||
| signatureRequirements?: TemplateSignatureRequirement[]; | ||
| signerSlots?: TemplateSignerSlot[]; | ||
| renderConfig?: TemplateRenderConfig; | ||
| } | ||
| interface PublishTemplateParams { | ||
| changelog?: string; | ||
| } | ||
| interface PreviewTemplateParams { | ||
| variables?: Record<string, string | number | boolean>; | ||
| } | ||
| interface PreviewTemplateHtmlResponse { | ||
| success: boolean; | ||
| html: string; | ||
| } | ||
| interface PreviewUnsavedPdfParams { | ||
| contentJson: Record<string, unknown>; | ||
| renderConfig?: TemplateRenderConfig; | ||
| variables?: Record<string, string | number | boolean>; | ||
| } | ||
| interface TemplateEnvelope { | ||
| success: boolean; | ||
| template: TemplateDetail; | ||
| message: string; | ||
| } | ||
| interface TemplateDeleteResponse { | ||
| success: boolean; | ||
| templateId: string; | ||
| message: string; | ||
| } | ||
| type InvoiceStatus = 'draft' | 'pending' | 'unpaid' | 'paid' | 'partially_paid' | 'overdue' | 'cancelled' | 'refunded'; | ||
@@ -672,5 +1330,14 @@ type InvoiceType = 'automatic' | 'manual'; | ||
| } | ||
| interface InvoiceListAllParams extends InvoiceListParams { | ||
| search?: string; | ||
| } | ||
| interface SendInvoiceParams { | ||
| autoCharge?: boolean; | ||
| } | ||
| interface UpdateInvoiceParams { | ||
| title?: string; | ||
| description?: string; | ||
| dueDate?: string; | ||
| lineItems?: InvoiceLineItemInput[]; | ||
| } | ||
| interface MarkInvoicePaidParams { | ||
@@ -745,2 +1412,52 @@ note?: string; | ||
| } | ||
| interface PaymentMixParams { | ||
| from: string; | ||
| to: string; | ||
| status?: TransactionStatus; | ||
| contractUuid?: string; | ||
| currencyCode?: string; | ||
| } | ||
| interface PaymentMixMethod { | ||
| paymentMethodType: string; | ||
| count: number; | ||
| totalAmount: string; | ||
| totalStripeFee: string; | ||
| totalPlatformFee: string; | ||
| avgStripeFeePercent: number; | ||
| } | ||
| interface PaymentMixResponse { | ||
| success: boolean; | ||
| dateRange: { | ||
| from: string; | ||
| to: string; | ||
| }; | ||
| totalTransactions: number; | ||
| byMethod: PaymentMixMethod[]; | ||
| estimatedSavingsIfAllBankTransfer?: string; | ||
| } | ||
| interface FeeEstimateParams { | ||
| amount: number; | ||
| currency: string; | ||
| platformFeePercent?: number; | ||
| } | ||
| interface FeeEstimateMethod { | ||
| paymentMethodType: string; | ||
| stripeFeePercent: number; | ||
| stripeFeeFixed: number; | ||
| estimatedStripeFee: string; | ||
| platformFeePercent: number; | ||
| estimatedPlatformFee: string; | ||
| estimatedTotalFee: string; | ||
| totalFeePercent: number; | ||
| isApproximate: boolean; | ||
| } | ||
| interface FeeEstimateResponse { | ||
| success: boolean; | ||
| amount: number; | ||
| currency: string; | ||
| methods: FeeEstimateMethod[]; | ||
| } | ||
| interface InvoiceListAllResponse extends InvoiceListResponse { | ||
| statusCounts: Record<string, number>; | ||
| } | ||
| type InvoiceWebhookEventType = Extract<WebhookEventType, 'invoice.created' | 'invoice.sent' | 'invoice.paid' | 'invoice.cancelled'>; | ||
@@ -756,3 +1473,3 @@ type TransactionWebhookEventType = Extract<WebhookEventType, 'transaction.created' | 'transaction.updated'>; | ||
| interface RequestOptions { | ||
| method?: "GET" | "POST" | "PUT" | "DELETE"; | ||
| method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE"; | ||
| body?: unknown; | ||
@@ -763,2 +1480,7 @@ headers?: Record<string, string>; | ||
| } | ||
| interface DownloadResult { | ||
| data: ArrayBuffer; | ||
| contentType: string; | ||
| fileName?: string; | ||
| } | ||
| declare class HttpClient { | ||
@@ -778,8 +1500,20 @@ private baseUrl; | ||
| put<T>(endpoint: string, body?: unknown, options?: Omit<RequestOptions, "method" | "body">): Promise<T>; | ||
| patch<T>(endpoint: string, body?: unknown, options?: Omit<RequestOptions, "method" | "body">): Promise<T>; | ||
| delete<T>(endpoint: string, options?: Omit<RequestOptions, "method" | "body">): Promise<T>; | ||
| download(endpoint: string, options?: Omit<RequestOptions, "method"> & { | ||
| method?: "GET" | "POST"; | ||
| }): Promise<DownloadResult>; | ||
| uploadFiles<T>(endpoint: string, files: File[] | Blob[], fieldName?: string): Promise<T>; | ||
| } | ||
| declare class DocumentComments { | ||
| private client; | ||
| constructor(client: HttpClient); | ||
| add(documentId: string, params: CreateCommentParams): Promise<AddCommentResponse>; | ||
| list(documentId: string, params?: CommentListParams): Promise<CommentListResponse>; | ||
| } | ||
| declare class Documents { | ||
| private client; | ||
| readonly comments: DocumentComments; | ||
| constructor(client: HttpClient); | ||
@@ -791,2 +1525,11 @@ create(params: CreateDocumentParams): Promise<DocumentResponse>; | ||
| getVerificationStatus(versionId: string): Promise<VerifyDocumentResponse>; | ||
| get(documentId: string): Promise<GetDocumentResponse>; | ||
| getVersions(documentId: string, params?: ListDocumentVersionsParams): Promise<GetDocumentVersionsResponse>; | ||
| download(versionId: string): Promise<DownloadResult>; | ||
| preview(versionId: string): Promise<DownloadResult>; | ||
| listShared(params?: DocumentSearchParams): Promise<DocumentListResponse>; | ||
| search(params?: DocumentSearchParams): Promise<DocumentListResponse>; | ||
| getActivity(documentId: string): Promise<DocumentActivityResponse>; | ||
| getDownloads(documentId: string): Promise<DocumentDownloadsResponse>; | ||
| sendPublicLink(documentId: string, params: SendPublicLinkParams): Promise<SendPublicLinkResponse>; | ||
| } | ||
@@ -799,3 +1542,4 @@ | ||
| getRequestStatus(requestId: string): Promise<SignatureRequestStatus>; | ||
| getMyRequests(pagination?: PaginationParams): Promise<GetMyRequestsResponse>; | ||
| getMyRequests(params?: GetMyRequestsParams): Promise<GetMyRequestsResponse>; | ||
| editRequest(requestId: string, params: EditSignatureRequestParams): Promise<EditSignatureRequestResponse>; | ||
| sign(params: SignDocumentParams): Promise<{ | ||
@@ -808,6 +1552,45 @@ success: boolean; | ||
| getSignatures(pagination?: PaginationParams): Promise<GetSignaturesResponse>; | ||
| createSignature(params: CreateSignatureParams): Promise<CreateSignatureResponse>; | ||
| validatePdfSignatures(file: File | Blob): Promise<ValidatePdfSignaturesResponse>; | ||
| cancel(requestId: string): Promise<CancelSignatureRequestResponse>; | ||
| remind(requestId: string, params?: RemindSignatureRequestParams): Promise<RemindSignatureRequestResponse>; | ||
| downloadCertificate(versionId: string): Promise<DownloadResult>; | ||
| downloadSignedDocument(versionId: string): Promise<DownloadResult>; | ||
| } | ||
| declare class ContractTermination { | ||
| private client; | ||
| constructor(client: HttpClient); | ||
| get(contractId: string): Promise<TerminationRequestEnvelope>; | ||
| getStatus(contractId: string): Promise<TerminationStatusEnvelope>; | ||
| getHistory(contractId: string): Promise<TerminationHistoryEnvelope>; | ||
| approve(contractId: string, params?: ApproveTerminationParams): Promise<TerminationApproveEnvelope>; | ||
| reject(contractId: string, params: RejectTerminationParams): Promise<ContractActionResponse>; | ||
| cancel(contractId: string): Promise<ContractActionResponse>; | ||
| } | ||
| declare class ContractPaymentTerms { | ||
| private client; | ||
| constructor(client: HttpClient); | ||
| list(contractId: string): Promise<PaymentTermListResponse>; | ||
| create(contractId: string, params: PaymentTermInput): Promise<PaymentTermEnvelope>; | ||
| update(contractId: string, termId: string, params: UpdatePaymentTermParams): Promise<PaymentTermEnvelope>; | ||
| delete(contractId: string, termId: string): Promise<PaymentTermDeleteResponse>; | ||
| } | ||
| declare class ContractAgreements { | ||
| private client; | ||
| constructor(client: HttpClient); | ||
| create(contractId: string, params: CreateAgreementParams): Promise<AgreementEnvelope>; | ||
| list(contractId: string): Promise<AgreementListResponse>; | ||
| get(contractId: string, agreementId: string): Promise<AgreementEnvelope>; | ||
| initiateSigning(contractId: string, agreementId: string, params?: InitiateAgreementSigningParams): Promise<AgreementSigningResponse>; | ||
| delete(contractId: string, agreementId: string): Promise<AgreementDeleteResponse>; | ||
| } | ||
| declare class Contracts { | ||
| private client; | ||
| readonly termination: ContractTermination; | ||
| readonly paymentTerms: ContractPaymentTerms; | ||
| readonly agreements: ContractAgreements; | ||
| constructor(client: HttpClient); | ||
@@ -823,2 +1606,17 @@ create(params: CreateContractParams): Promise<ContractResponse>; | ||
| terminate(contractId: string, params?: TerminateContractParams): Promise<ContractActionResponse>; | ||
| update(contractId: string, params: UpdateContractParams): Promise<ContractResponse>; | ||
| delete(contractId: string): Promise<ContractActionResponse>; | ||
| createEmpty(params: CreateEmptyContractParams): Promise<ContractResponse>; | ||
| createMinimal(params: CreateMinimalContractParams): Promise<ContractResponse>; | ||
| import(params: CreateImportContractParams): Promise<ContractResponse>; | ||
| attachDocument(contractId: string, params: AttachDocumentParams): Promise<ContractResponse>; | ||
| getStats(contractId: string): Promise<ContractStatsResponse>; | ||
| setupRecurring(contractId: string, params: RecurringSetupParams): Promise<ContractResponse>; | ||
| resendRecurringApproval(contractId: string): Promise<ContractActionResponse>; | ||
| cancelRecurringApproval(contractId: string): Promise<ContractActionResponse>; | ||
| listSigningRequests(contractId: string): Promise<SigningRequestListResponse>; | ||
| getSigningRequest(contractId: string, requestId: string): Promise<SigningRequestGetResponse>; | ||
| resendSigningRequest(contractId: string, requestId: string): Promise<SigningRequestActionResponse>; | ||
| cancelSigningRequest(contractId: string, requestId: string): Promise<SigningRequestActionResponse>; | ||
| businessSign(contractId: string, requestId: string, params: BusinessSignParams): Promise<BusinessSignResponse>; | ||
| } | ||
@@ -829,5 +1627,17 @@ | ||
| constructor(client: HttpClient); | ||
| list(params?: ListTemplatesParams): Promise<TemplateListResponse>; | ||
| get(templateId: string): Promise<TemplateGetResponse>; | ||
| getVersions(templateId: string): Promise<TemplateVersionsResponse>; | ||
| createDocument(templateId: string, params: CreateDocumentFromTemplateParams): Promise<TemplateDocumentResponse>; | ||
| sendForSigning(templateId: string, params: CreateTemplateSignatureRequestParams): Promise<TemplateSignatureRequestResponse>; | ||
| createContract(templateId: string, params: CreateContractFromTemplateParams): Promise<TemplateContractResponse>; | ||
| create(params: CreateTemplateParams): Promise<TemplateEnvelope>; | ||
| update(templateId: string, params: UpdateTemplateParams): Promise<TemplateEnvelope>; | ||
| publish(templateId: string, params?: PublishTemplateParams): Promise<TemplateEnvelope>; | ||
| archive(templateId: string): Promise<TemplateEnvelope>; | ||
| restore(templateId: string): Promise<TemplateEnvelope>; | ||
| delete(templateId: string): Promise<TemplateDeleteResponse>; | ||
| previewPdf(templateId: string, params?: PreviewTemplateParams): Promise<DownloadResult>; | ||
| previewHtml(templateId: string, params?: PreviewTemplateParams): Promise<PreviewTemplateHtmlResponse>; | ||
| previewUnsavedPdf(params: PreviewUnsavedPdfParams): Promise<DownloadResult>; | ||
| } | ||
@@ -840,2 +1650,3 @@ | ||
| list(contractId: string, params?: InvoiceListParams): Promise<InvoiceListResponse>; | ||
| listAll(params?: InvoiceListAllParams): Promise<InvoiceListAllResponse>; | ||
| get(contractId: string, invoiceId: string): Promise<InvoiceResponse>; | ||
@@ -845,2 +1656,5 @@ send(contractId: string, invoiceId: string, params?: SendInvoiceParams): Promise<InvoiceActionResponse>; | ||
| markPaid(contractId: string, invoiceId: string, params?: MarkInvoicePaidParams): Promise<InvoiceResponse>; | ||
| update(contractId: string, invoiceId: string, params: UpdateInvoiceParams): Promise<InvoiceResponse>; | ||
| cancel(contractId: string, invoiceId: string): Promise<InvoiceActionResponse>; | ||
| downloadPdf(contractId: string, invoiceId: string): Promise<DownloadResult>; | ||
| } | ||
@@ -853,2 +1667,4 @@ | ||
| get(transactionId: string): Promise<TransactionResponse>; | ||
| getPaymentMix(params: PaymentMixParams): Promise<PaymentMixResponse>; | ||
| getFeeEstimate(params: FeeEstimateParams): Promise<FeeEstimateResponse>; | ||
| } | ||
@@ -889,2 +1705,2 @@ | ||
| export { type AccessEmail, type AccessRole, type AccessType, type ApiKeyInfo, type ApiResponse, type BillingAddress, Chaindoc, type ChaindocConfig, type ChaindocEnvironment, ChaindocError, type Contract, type ContractActionResponse, type ContractActivitiesResponse, type ContractContragent, type ContractDocument, type ContractListParams, type ContractListResponse, type ContractOrigin, type ContractPreferredPaymentMethodType, type ContractResponse, type ContractSendParams, type ContractSendResponse, type ContractSigner, type ContractSignerSource, type ContractSigningMethod, type ContractSigningPolicy, type ContractSigningRequest, type ContractStatus, type ContractStatusResponse, type ContractWebhookEventType, type ContragentInfo, type CreateContractFromTemplateParams, type CreateContractParams, type CreateDocumentFromTemplateParams, type CreateDocumentParams, type CreateEmbeddedSessionParams, type CreateInvoiceParams, type CreateSignatureRequestParams, type CreateTemplateSignatureRequestParams, type Document, type DocumentResponse, type DocumentSigningMethod, type DocumentStatus, type DocumentTag, type DocumentVersion, type EmbeddedSessionResponse, type GetMyRequestsResponse, type GetSignaturesResponse, type HealthCheckResponse, type Invoice, type InvoiceActionResponse, type InvoiceContractSummary, type InvoiceLineItem, type InvoiceLineItemInput, type InvoiceListParams, type InvoiceListResponse, type InvoiceResponse, type InvoiceStatus, type InvoiceTransactionSummary, type InvoiceType, type InvoiceWebhookEventType, type MarkInvoicePaidParams, type Media$1 as Media, type MediaType, type MediaUploadResponse, type MetaTag, type PaginatedResponse, type PaginationParams, type PaymentFrequency, type PaymentSetupParams, type PaymentTermApprovalStatus, type PaymentTermInput, type PaymentTermResponse, type PaymentTermType, type Recipient, type RetryConfig, type SavedSignature, type SendInvoiceParams, type SignDocumentParams, type SignRequestStatus, type SignatureRequest, type SignatureRequestField, type SignatureRequestFieldType, type SignatureRequestResponse, type SignatureRequestStatus, type Signer, type SignerRole, type SignerUser, type TemplateContractResponse, type TemplateContractSlotAssignment, type TemplateDocument, type TemplateDocumentResponse, type TemplateDocumentVersion, type TemplateSignatureRequestResponse, type TemplateSlotAssignment, type TemplateSlotSigningMethod, type TemplateVariables, type TerminateContractParams, type TerminationType, type Transaction, type TransactionContractSummary, type TransactionInvoiceSummary, type TransactionListResponse, type TransactionResponse, type TransactionStatus, type TransactionWebhookEventType, type UpdateDocumentParams, type UpdateDocumentRightsParams, type VerificationStatus, type VerificationTxStatus, type VerifyDocumentParams, type VerifyDocumentResponse, type WebhookEnvelope, type WebhookEventType, type WebhookVerificationResult }; | ||
| export { type AccessEmail, type AccessRole, type AccessType, type AddCommentResponse, type AdditionalAgreement, type AgreementDeleteResponse, type AgreementEnvelope, type AgreementListResponse, type AgreementSigningResponse, type ApiKeyInfo, type ApiResponse, type ApproveTerminationParams, type AttachDocumentParams, type BillingAddress, type BusinessSignParams, type BusinessSignResponse, type CancelSignatureRequestResponse, Chaindoc, type ChaindocConfig, type ChaindocEnvironment, ChaindocError, type CommentListParams, type CommentListResponse, type Contract, type ContractActionResponse, type ContractActivitiesResponse, type ContractContragent, type ContractDocument, type ContractListParams, type ContractListResponse, type ContractOrigin, type ContractPreferredPaymentMethodType, type ContractResponse, type ContractSendParams, type ContractSendResponse, type ContractSigner, type ContractSignerSource, type ContractSignerStatus, type ContractSigningMethod, type ContractSigningPolicy, type ContractSigningRequest, type ContractSigningRequestPurpose, type ContractSigningRequestStatus, type ContractStats, type ContractStatsResponse, type ContractStatus, type ContractStatusResponse, type ContractWebhookEventType, type ContragentInfo, type CreateAgreementParams, type CreateCommentParams, type CreateContractFromTemplateParams, type CreateContractParams, type CreateDocumentFromTemplateParams, type CreateDocumentParams, type CreateEmbeddedSessionParams, type CreateEmptyContractParams, type CreateImportContractParams, type CreateInvoiceParams, type CreateMinimalContractParams, type CreateSignatureParams, type CreateSignatureRequestParams, type CreateSignatureResponse, type CreateTemplateParams, type CreateTemplateSignatureRequestParams, type Document, type DocumentActivityItem, type DocumentActivityResponse, type DocumentActorRef, type DocumentDownloadItem, type DocumentDownloadsResponse, type DocumentListResponse, type DocumentResponse, type DocumentSearchParams, type DocumentSearchStatus, type DocumentSigningMethod, type DocumentStatus, type DocumentStatusForCreate, type DocumentTag, type DocumentVersion, type DownloadResult, type EditSignatureRequestParams, type EditSignatureRequestResponse, type EmbeddedSessionResponse, type FeeEstimateMethod, type FeeEstimateParams, type FeeEstimateResponse, type GetDocumentResponse, type GetDocumentVersionsResponse, type GetMyRequestsParams, type GetMyRequestsResponse, type GetSignaturesResponse, type HealthCheckResponse, type InitiateAgreementSigningParams, type Invoice, type InvoiceActionResponse, type InvoiceContractSummary, type InvoiceLineItem, type InvoiceLineItemInput, type InvoiceListAllParams, type InvoiceListAllResponse, type InvoiceListParams, type InvoiceListResponse, type InvoiceResponse, type InvoiceStatus, type InvoiceTransactionSummary, type InvoiceType, type InvoiceWebhookEventType, type ListDocumentVersionsParams, type ListTemplatesParams, type MarkInvoicePaidParams, type Media$1 as Media, type MediaType, type MediaUploadResponse, type MetaTag, type OutstandingInvoiceSummary, type PaginatedResponse, type PaginationParams, type PaymentFrequency, type PaymentMixMethod, type PaymentMixParams, type PaymentMixResponse, type PaymentSetupParams, type PaymentTermApprovalStatus, type PaymentTermDeleteResponse, type PaymentTermEnvelope, type PaymentTermInput, type PaymentTermListResponse, type PaymentTermModificationAction, type PaymentTermModificationInput, type PaymentTermResponse, type PaymentTermType, type PreviewTemplateHtmlResponse, type PreviewTemplateParams, type PreviewUnsavedPdfParams, type PublicComment, type PublicDocumentDetail, type PublicDocumentMediaSummary, type PublicDocumentVersion, type PublishTemplateParams, type Recipient, type RecurringPaymentTermInput, type RecurringSetupParams, type RejectTerminationParams, type RemindSignatureRequestParams, type RemindSignatureRequestResponse, type RetryConfig, type SavedSignature, type SendInvoiceParams, type SendPublicLinkParams, type SendPublicLinkResponse, type SignDocumentParams, type SignRequestStatus, type SignatureRequest, type SignatureRequestField, type SignatureRequestFieldType, type SignatureRequestResponse, type SignatureRequestStatus, type SignatureRequestStatusFilter, type Signer, type SignerRole, type SignerUser, type SigningRequestActionResponse, type SigningRequestDetail, type SigningRequestGetResponse, type SigningRequestListResponse, type SigningRequestSigner, type SigningRequestSummary, type TemplateCategory, type TemplateContractResponse, type TemplateContractSlotAssignment, type TemplateDeleteResponse, type TemplateDetail, type TemplateDocument, type TemplateDocumentResponse, type TemplateDocumentVersion, type TemplateEnvelope, type TemplateGetResponse, type TemplateListResponse, type TemplatePlacedField, type TemplateRenderConfig, type TemplateSignatureRequestResponse, type TemplateSignatureRequirement, type TemplateSignerSlot, type TemplateSlotAssignment, type TemplateSlotSigningMethod, type TemplateStatus, type TemplateSummary, type TemplateVariable, type TemplateVariableDataType, type TemplateVariableInput, type TemplateVariableScope, type TemplateVariables, type TemplateVersionDetail, type TemplateVersionRef, type TemplateVersionsResponse, type TerminateContractParams, type TerminationApproval, type TerminationApprovals, type TerminationApproveEnvelope, type TerminationHistoryEnvelope, type TerminationRejection, type TerminationRequest, type TerminationRequestEnvelope, type TerminationRequestStatus, type TerminationStatus, type TerminationStatusEnvelope, type TerminationType, type Transaction, type TransactionContractSummary, type TransactionInvoiceSummary, type TransactionListResponse, type TransactionResponse, type TransactionStatus, type TransactionWebhookEventType, type UpdateContractParams, type UpdateDocumentParams, type UpdateDocumentRightsParams, type UpdateInvoiceParams, type UpdatePaymentTermParams, type UpdateTemplateParams, type ValidatePdfSignaturesResponse, type VerificationStatus, type VerificationTxStatus, type VerifyDocumentParams, type VerifyDocumentResponse, type WebhookEnvelope, type WebhookEventType, type WebhookVerificationResult }; |
+1
-1
@@ -1,2 +0,2 @@ | ||
| var p=class extends Error{constructor(t,s,r,c=!1){super(t);this.statusCode=s;this.response=r;this.isRetryable=c;this.name="ChaindocError"}},x={production:"https://api.chaindoc.io",staging:"https://api.chaindoc.io",development:"https://api.chaindoc.io"},I="production",M=3e4,U=3,L=1e3,N=1e4,y=class{baseUrl;secretKey;timeout;defaultHeaders;retryConfig;constructor(e){if(!e.secretKey)throw new p("secretKey is required");if(!e.secretKey.startsWith("sk_"))throw new p('secretKey must start with "sk_"');let t=e.environment??I;this.baseUrl=e.baseUrl??x[t],this.secretKey=e.secretKey,this.timeout=e.timeout??M,this.defaultHeaders={"Content-Type":"application/json",Authorization:`Bearer ${this.secretKey}`,...e.headers},this.retryConfig={maxRetries:e.retry?.maxRetries??U,baseDelayMs:e.retry?.baseDelayMs??L,maxDelayMs:e.retry?.maxDelayMs??N}}getRetryDelay(e){let t=this.retryConfig.baseDelayMs*Math.pow(2,e),s=Math.min(t,this.retryConfig.maxDelayMs),r=s*.25*(Math.random()*2-1);return Math.round(s+r)}isRetryableError(e,t){return t&&t>=500||t===429?!0:e instanceof Error?["ECONNRESET","ECONNREFUSED","ETIMEDOUT","ENOTFOUND","EAI_AGAIN"].some(r=>e.message.includes(r))||e.name==="AbortError":!1}sleep(e){return new Promise(t=>setTimeout(t,e))}async request(e,t={}){let s=`${this.baseUrl}${e}`,r=t.noRetry?1:this.retryConfig.maxRetries+1,c;for(let a=0;a<r;a++){let u=new AbortController,g=setTimeout(()=>u.abort(),t.timeout??this.timeout);try{let o=await fetch(s,{method:t.method??"GET",headers:{...this.defaultHeaders,...t.headers},body:t.body?JSON.stringify(t.body):void 0,signal:u.signal});if(clearTimeout(g),o.status===204||o.headers.get("content-length")==="0")return;let m=o.headers.get("content-type")?.includes("application/json")?await o.json().catch(()=>{}):void 0;if(!o.ok){let l=m&&typeof m=="object"&&"message"in m&&typeof m.message=="string"?m.message:`Request failed with status ${o.status}`,h=this.isRetryableError(null,o.status);if(c=new p(l,o.status,m,h),h&&a<r-1){await this.sleep(this.getRetryDelay(a));continue}throw c}return m}catch(o){if(clearTimeout(g),o instanceof p){if(!o.isRetryable||a>=r-1)throw o;c=o,await this.sleep(this.getRetryDelay(a));continue}let i=this.isRetryableError(o);if(o instanceof Error){let m=o.name==="AbortError"?"Request timeout":o.message;if(c=new p(m,void 0,void 0,i),i&&a<r-1){await this.sleep(this.getRetryDelay(a));continue}throw c}throw new p("Unknown error occurred")}}throw c??new p("Request failed after retries")}async get(e,t){return this.request(e,{...t,method:"GET"})}async post(e,t,s){return this.request(e,{...s,method:"POST",body:t})}async put(e,t,s){return this.request(e,{...s,method:"PUT",body:t})}async delete(e,t){return this.request(e,{...t,method:"DELETE"})}async uploadFiles(e,t,s="media"){let r=this.retryConfig.maxRetries+1,c;for(let a=0;a<r;a++){let u=new FormData;t.forEach(i=>{u.append(s,i)});let g=new AbortController,o=setTimeout(()=>g.abort(),this.timeout*2);try{let i=await fetch(`${this.baseUrl}${e}`,{method:"POST",headers:{Authorization:`Bearer ${this.secretKey}`},body:u,signal:g.signal});if(clearTimeout(o),i.status===204||i.headers.get("content-length")==="0")return;let l=i.headers.get("content-type")?.includes("application/json")?await i.json().catch(()=>{}):void 0;if(!i.ok){let h=l&&typeof l=="object"&&"message"in l&&typeof l.message=="string"?l.message:`Upload failed with status ${i.status}`,D=this.isRetryableError(null,i.status);if(c=new p(h,i.status,l,D),D&&a<r-1){await this.sleep(this.getRetryDelay(a));continue}throw c}return l}catch(i){if(clearTimeout(o),i instanceof p){if(!i.isRetryable||a>=r-1)throw i;c=i,await this.sleep(this.getRetryDelay(a));continue}let m=this.isRetryableError(i);if(i instanceof Error){let l=i.name==="AbortError"?"Upload timeout":i.message;if(c=new p(l,void 0,void 0,m),m&&a<r-1){await this.sleep(this.getRetryDelay(a));continue}throw c}throw new p("Unknown error occurred")}}throw c??new p("Upload failed after retries")}};function A(n){return typeof n!="string"?n:n.trim().toLowerCase()}function d(n){return typeof n.email!="string"?{...n}:{...n,email:n.email.trim().toLowerCase()}}function q(n){return typeof n.signerEmail!="string"?{...n}:{...n,signerEmail:n.signerEmail.trim().toLowerCase()}}function $(n){return n?.map(d)}var f=class{constructor(e){this.client=e}async create(e){return this.client.post("/api/v1/documents",{...e,accessEmails:$(e.accessEmails)})}async update(e,t){return this.client.put(`/api/v1/documents/${e}`,t)}async updateRights(e,t){return this.client.put(`/api/v1/documents/${e}/rights`,{...t,accessEmails:$(t.accessEmails)})}async verify(e){return this.client.post("/api/v1/documents/verify",e)}async getVerificationStatus(e){return this.client.get(`/api/v1/documents/versions/${e}/verification`)}};var R=class{constructor(e){this.client=e}async createRequest(e){return this.client.post("/api/v1/signatures/requests",{...e,recipients:e.recipients.map(d),fields:e.fields?.map(q),deadline:e.deadline.toISOString()})}async getRequestStatus(e){return this.client.get(`/api/v1/signatures/requests/${e}/status`)}async getMyRequests(e){let t=new URLSearchParams;e?.pageNumber&&t.set("pageNumber",String(e.pageNumber)),e?.pageSize&&t.set("pageSize",String(e.pageSize));let s=t.toString();return this.client.get(`/api/v1/signatures/requests${s?`?${s}`:""}`)}async sign(e){return this.client.post("/api/v1/signatures/sign",e)}async getSignatures(e){let t=new URLSearchParams;e?.pageNumber&&t.set("pageNumber",String(e.pageNumber)),e?.pageSize&&t.set("pageSize",String(e.pageSize));let s=t.toString();return this.client.get(`/api/v1/signatures${s?`?${s}`:""}`)}};var v=class{constructor(e){this.client=e}async create(e){return this.client.post("/api/v1/contracts",{...e,contragent:d(e.contragent)})}async list(e){let t=new URLSearchParams;e?.page&&t.set("page",String(e.page)),e?.limit&&t.set("limit",String(e.limit)),e?.status&&t.set("status",e.status),e?.search&&t.set("search",e.search);let s=t.toString();return this.client.get(`/api/v1/contracts${s?`?${s}`:""}`)}async get(e){return this.client.get(`/api/v1/contracts/${e}`)}async getStatus(e){return this.client.get(`/api/v1/contracts/${e}/status`)}async getActivities(e,t){let s=new URLSearchParams;t?.page&&s.set("page",String(t.page)),t?.limit&&s.set("limit",String(t.limit));let r=s.toString();return this.client.get(`/api/v1/contracts/${e}/activities${r?`?${r}`:""}`)}async addPaymentSetup(e,t){return this.client.post(`/api/v1/contracts/${e}/payment-setup`,t)}async send(e,t){return this.client.post(`/api/v1/contracts/${e}/send`,{...t,deadline:t?.deadline?.toISOString()})}async cancel(e){return this.client.post(`/api/v1/contracts/${e}/cancel`,{})}async terminate(e,t){return this.client.post(`/api/v1/contracts/${e}/terminate`,t??{})}};var P=class{constructor(e){this.client=e}async createDocument(e,t){return this.client.post(`/api/v1/templates/${e}/documents`,t)}async sendForSigning(e,t){return this.client.post(`/api/v1/templates/${e}/signature-requests`,{...t,slotAssignments:t.slotAssignments.map(d)})}async createContract(e,t){return this.client.post(`/api/v1/templates/${e}/contracts`,{...t,contragent:d(t.contragent)})}};var C=class{constructor(e){this.client=e}async create(e,t){return this.client.post(`/api/v1/contracts/${e}/invoices`,t)}async list(e,t){let s=new URLSearchParams;t?.page&&s.set("page",String(t.page)),t?.limit&&s.set("limit",String(t.limit)),t?.status&&s.set("status",t.status),t?.type&&s.set("type",t.type),typeof t?.overdue=="boolean"&&s.set("overdue",String(t.overdue)),t?.dueDateFrom&&s.set("dueDateFrom",t.dueDateFrom),t?.dueDateTo&&s.set("dueDateTo",t.dueDateTo);let r=s.toString();return this.client.get(`/api/v1/contracts/${e}/invoices${r?`?${r}`:""}`)}async get(e,t){return this.client.get(`/api/v1/contracts/${e}/invoices/${t}`)}async send(e,t,s){return this.client.post(`/api/v1/contracts/${e}/invoices/${t}/send`,s??{})}async charge(e,t){return this.client.post(`/api/v1/contracts/${e}/invoices/${t}/charge`,{})}async markPaid(e,t,s){return this.client.post(`/api/v1/contracts/${e}/invoices/${t}/mark-paid`,s??{})}};var T=class{constructor(e){this.client=e}async listByContract(e){return this.client.get(`/api/v1/contracts/${e}/transactions`)}async get(e){return this.client.get(`/api/v1/transactions/${e}`)}};var S=class{constructor(e){this.client=e}async createSession(e){return this.client.post("/api/v1/embedded/sessions",{...e,email:A(e.email)})}};var E=class{constructor(e){this.client=e}async upload(e){return this.client.uploadFiles("/api/v1/media/upload",e)}};import{createHmac as k,timingSafeEqual as H}from"crypto";var O=300*1e3,b=class{static verify(e,t,s,r){if(!e||!t||!s||!r)return{valid:!1};let c=new Date(s).getTime();if(isNaN(c))return{valid:!1};if(Math.abs(Date.now()-c)>O)return{valid:!1};let u=t.match(/^v1=([a-f0-9]+)$/i);if(!u||!u[1])return{valid:!1};let g=u[1],o=`${s}.${e}`,i=k("sha256",r).update(o).digest("hex");if(g.length!==i.length)return{valid:!1};let m=Buffer.from(g,"hex"),l=Buffer.from(i,"hex");if(m.length!==l.length)return{valid:!1};if(!H(m,l))return{valid:!1};try{return{valid:!0,envelope:JSON.parse(e)}}catch{return{valid:!1}}}static parse(e){return JSON.parse(e)}};var w=class{client;static webhooks=b;documents;signatures;contracts;templates;invoices;transactions;embedded;media;constructor(e){this.client=new y(e),this.documents=new f(this.client),this.signatures=new R(this.client),this.contracts=new v(this.client),this.templates=new P(this.client),this.invoices=new C(this.client),this.transactions=new T(this.client),this.embedded=new S(this.client),this.media=new E(this.client)}async getApiKeyInfo(){return this.client.get("/api/v1/me")}async healthCheck(){return this.client.get("/api/v1/health")}};export{w as Chaindoc,p as ChaindocError}; | ||
| var c=class extends Error{constructor(t,n,i,m=!1){super(t);this.statusCode=n;this.response=i;this.isRetryable=m;this.name="ChaindocError"}};function N(s){if(!s)return;let t=s.match(/filename\*\s*=\s*[^']*'[^']*'([^;]+)/i)?.[1];if(t)try{return decodeURIComponent(t.trim())}catch{}let i=s.match(/filename\s*=\s*"?([^";]+)"?/i)?.[1];return i?i.trim():void 0}var z={production:"https://api.chaindoc.io",staging:"https://api.chaindoc.io",development:"https://api.chaindoc.io"},O="production",F=3e4,V=3,G=1e3,_=1e4,P=class{baseUrl;secretKey;timeout;defaultHeaders;retryConfig;constructor(e){if(!e.secretKey)throw new c("secretKey is required");if(!e.secretKey.startsWith("sk_"))throw new c('secretKey must start with "sk_"');let t=e.environment??O;this.baseUrl=e.baseUrl??z[t],this.secretKey=e.secretKey,this.timeout=e.timeout??F,this.defaultHeaders={"Content-Type":"application/json",Authorization:`Bearer ${this.secretKey}`,...e.headers},this.retryConfig={maxRetries:e.retry?.maxRetries??V,baseDelayMs:e.retry?.baseDelayMs??G,maxDelayMs:e.retry?.maxDelayMs??_}}getRetryDelay(e){let t=this.retryConfig.baseDelayMs*Math.pow(2,e),n=Math.min(t,this.retryConfig.maxDelayMs),i=n*.25*(Math.random()*2-1);return Math.round(n+i)}isRetryableError(e,t){return t&&t>=500||t===429?!0:e instanceof Error?["ECONNRESET","ECONNREFUSED","ETIMEDOUT","ENOTFOUND","EAI_AGAIN"].some(i=>e.message.includes(i))||e.name==="AbortError":!1}sleep(e){return new Promise(t=>setTimeout(t,e))}async request(e,t={}){let n=`${this.baseUrl}${e}`,i=t.noRetry?1:this.retryConfig.maxRetries+1,m;for(let l=0;l<i;l++){let d=new AbortController,g=setTimeout(()=>d.abort(),t.timeout??this.timeout);try{let a=await fetch(n,{method:t.method??"GET",headers:{...this.defaultHeaders,...t.headers},body:t.body?JSON.stringify(t.body):void 0,signal:d.signal});if(clearTimeout(g),a.status===204||a.headers.get("content-length")==="0")return;let r=a.headers.get("content-type")?.includes("application/json")?await a.json().catch(()=>{}):void 0;if(!a.ok){let p=r&&typeof r=="object"&&"message"in r&&typeof r.message=="string"?r.message:`Request failed with status ${a.status}`,h=this.isRetryableError(null,a.status);if(m=new c(p,a.status,r,h),h&&l<i-1){await this.sleep(this.getRetryDelay(l));continue}throw m}return r}catch(a){if(clearTimeout(g),a instanceof c){if(!a.isRetryable||l>=i-1)throw a;m=a,await this.sleep(this.getRetryDelay(l));continue}let o=this.isRetryableError(a);if(a instanceof Error){let r=a.name==="AbortError"?"Request timeout":a.message;if(m=new c(r,void 0,void 0,o),o&&l<i-1){await this.sleep(this.getRetryDelay(l));continue}throw m}throw new c("Unknown error occurred")}}throw m??new c("Request failed after retries")}async get(e,t){return this.request(e,{...t,method:"GET"})}async post(e,t,n){return this.request(e,{...n,method:"POST",body:t})}async put(e,t,n){return this.request(e,{...n,method:"PUT",body:t})}async patch(e,t,n){return this.request(e,{...n,method:"PATCH",body:t})}async delete(e,t){return this.request(e,{...t,method:"DELETE"})}async download(e,t){let n=`${this.baseUrl}${e}`,i=t?.noRetry?1:this.retryConfig.maxRetries+1,m=t?.method??"GET",l=t?.body!==void 0,d;for(let g=0;g<i;g++){let a=new AbortController,o=setTimeout(()=>a.abort(),t?.timeout??this.timeout);try{let r=await fetch(n,{method:m,headers:{...this.defaultHeaders,...l?{"Content-Type":"application/json"}:{},...t?.headers},body:l?JSON.stringify(t?.body):void 0,signal:a.signal});if(clearTimeout(o),!r.ok){let h=`Download failed with status ${r.status}`,R;(r.headers.get("content-type")??"").includes("application/json")&&(R=await r.json().catch(()=>{}),R&&typeof R=="object"&&"message"in R&&typeof R.message=="string"&&(h=R.message));let U=this.isRetryableError(null,r.status);if(d=new c(h,r.status,R,U),U&&g<i-1){await this.sleep(this.getRetryDelay(g));continue}throw d}return{data:await r.arrayBuffer(),contentType:r.headers.get("content-type")??"application/octet-stream",fileName:N(r.headers.get("content-disposition"))}}catch(r){if(clearTimeout(o),r instanceof c){if(!r.isRetryable||g>=i-1)throw r;d=r,await this.sleep(this.getRetryDelay(g));continue}let p=this.isRetryableError(r);if(r instanceof Error){let h=r.name==="AbortError"?"Download timeout":r.message;if(d=new c(h,void 0,void 0,p),p&&g<i-1){await this.sleep(this.getRetryDelay(g));continue}throw d}throw new c("Unknown error occurred")}}throw d??new c("Download failed after retries")}async uploadFiles(e,t,n="media"){let i=this.retryConfig.maxRetries+1,m;for(let l=0;l<i;l++){let d=new FormData;t.forEach(o=>{d.append(n,o)});let g=new AbortController,a=setTimeout(()=>g.abort(),this.timeout*2);try{let o=await fetch(`${this.baseUrl}${e}`,{method:"POST",headers:{Authorization:`Bearer ${this.secretKey}`},body:d,signal:g.signal});if(clearTimeout(a),o.status===204||o.headers.get("content-length")==="0")return;let p=o.headers.get("content-type")?.includes("application/json")?await o.json().catch(()=>{}):void 0;if(!o.ok){let h=p&&typeof p=="object"&&"message"in p&&typeof p.message=="string"?p.message:`Upload failed with status ${o.status}`,R=this.isRetryableError(null,o.status);if(m=new c(h,o.status,p,R),R&&l<i-1){await this.sleep(this.getRetryDelay(l));continue}throw m}return p}catch(o){if(clearTimeout(a),o instanceof c){if(!o.isRetryable||l>=i-1)throw o;m=o,await this.sleep(this.getRetryDelay(l));continue}let r=this.isRetryableError(o);if(o instanceof Error){let p=o.name==="AbortError"?"Upload timeout":o.message;if(m=new c(p,void 0,void 0,r),r&&l<i-1){await this.sleep(this.getRetryDelay(l));continue}throw m}throw new c("Unknown error occurred")}}throw m??new c("Upload failed after retries")}};function y(s){return typeof s!="string"?s:s.trim().toLowerCase()}function f(s){return typeof s.email!="string"?{...s}:{...s,email:s.email.trim().toLowerCase()}}function M(s){return typeof s.signerEmail!="string"?{...s}:{...s,signerEmail:s.signerEmail.trim().toLowerCase()}}var j=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+$/;function B(s){return typeof s!="string"?!1:j.test(s.trim())}function u(s,e){if(!B(s))throw new c(`Invalid email address at ${e}: ${JSON.stringify(s)}`)}var v=class{constructor(e){this.client=e}async add(e,t){return this.client.post(`/api/v1/documents/${e}/comments`,t)}async list(e,t){let n=new URLSearchParams;t?.pageNumber!==void 0&&n.set("pageNumber",String(t.pageNumber)),t?.pageSize!==void 0&&n.set("pageSize",String(t.pageSize));let i=n.toString();return this.client.get(`/api/v1/documents/${e}/comments${i?`?${i}`:""}`)}};function k(s){return s?.map(f)}var S=class{constructor(e){this.client=e;this.comments=new v(e)}comments;async create(e){return this.client.post("/api/v1/documents",{...e,accessEmails:k(e.accessEmails)})}async update(e,t){return this.client.put(`/api/v1/documents/${e}`,t)}async updateRights(e,t){return this.client.put(`/api/v1/documents/${e}/rights`,{...t,accessEmails:k(t.accessEmails)})}async verify(e){return this.client.post("/api/v1/documents/verify",e)}async getVerificationStatus(e){return this.client.get(`/api/v1/documents/versions/${e}/verification`)}async get(e){return this.client.get(`/api/v1/documents/${e}`)}async getVersions(e,t){let n=new URLSearchParams;t?.pageNumber!==void 0&&n.set("pageNumber",String(t.pageNumber)),t?.pageSize!==void 0&&n.set("pageSize",String(t.pageSize));let i=n.toString();return this.client.get(`/api/v1/documents/${e}/versions${i?`?${i}`:""}`)}async download(e){return this.client.download(`/api/v1/documents/versions/${e}/download`)}async preview(e){return this.client.download(`/api/v1/documents/versions/${e}/preview`)}async listShared(e){return this.client.get(`/api/v1/documents/shared${H(e)}`)}async search(e){return this.client.get(`/api/v1/documents/search${H(e)}`)}async getActivity(e){return this.client.get(`/api/v1/documents/${e}/activity`)}async getDownloads(e){return this.client.get(`/api/v1/documents/${e}/downloads`)}async sendPublicLink(e,t){return u(t.email,"email"),this.client.post(`/api/v1/documents/${e}/send-public-link`,{...t,email:y(t.email)})}};function H(s){if(!s)return"";let e=new URLSearchParams;s.pageNumber!==void 0&&e.set("pageNumber",String(s.pageNumber)),s.pageSize!==void 0&&e.set("pageSize",String(s.pageSize)),s.search!==void 0&&e.set("search",s.search),s.status!==void 0&&e.set("status",s.status);let t=e.toString();return t?`?${t}`:""}var C=class{constructor(e){this.client=e}async createRequest(e){return e.recipients.forEach((t,n)=>u(t?.email,`recipients[${n}].email`)),e.fields?.forEach((t,n)=>u(t?.signerEmail,`fields[${n}].signerEmail`)),this.client.post("/api/v1/signatures/requests",{...e,recipients:e.recipients.map(f),fields:e.fields?.map(M),deadline:e.deadline.toISOString()})}async getRequestStatus(e){return this.client.get(`/api/v1/signatures/requests/${e}/status`)}async getMyRequests(e){let t=new URLSearchParams;e?.pageNumber&&t.set("pageNumber",String(e.pageNumber)),e?.pageSize&&t.set("pageSize",String(e.pageSize)),e?.status&&t.set("status",e.status);let n=t.toString();return this.client.get(`/api/v1/signatures/requests${n?`?${n}`:""}`)}async editRequest(e,t){return u(t.recipient,"recipient"),this.client.post(`/api/v1/signatures/requests/${e}/edit`,{...t,recipient:y(t.recipient)})}async sign(e){return this.client.post("/api/v1/signatures/sign",e)}async getSignatures(e){let t=new URLSearchParams;e?.pageNumber&&t.set("pageNumber",String(e.pageNumber)),e?.pageSize&&t.set("pageSize",String(e.pageSize));let n=t.toString();return this.client.get(`/api/v1/signatures${n?`?${n}`:""}`)}async createSignature(e){return this.client.post("/api/v1/signatures",e)}async validatePdfSignatures(e){return this.client.uploadFiles("/api/v1/signatures/validate-pdf",[e],"file")}async cancel(e){return this.client.post(`/api/v1/signatures/requests/${e}/cancel`,{})}async remind(e,t){let n={};if(t?.signerEmails!==void 0){if(t.signerEmails.length===0)throw new c("signerEmails must contain at least one email when provided");t.signerEmails.forEach((i,m)=>u(i,`signerEmails[${m}]`)),n.signerEmails=t.signerEmails.map(i=>y(i))}return this.client.post(`/api/v1/signatures/requests/${e}/remind`,n)}async downloadCertificate(e){return this.client.download(`/api/v1/signatures/versions/${e}/certificate`)}async downloadSignedDocument(e){return this.client.download(`/api/v1/signatures/versions/${e}/signed-document`)}};var E=class{constructor(e){this.client=e}async get(e){return this.client.get(`/api/v1/contracts/${e}/termination`)}async getStatus(e){return this.client.get(`/api/v1/contracts/${e}/termination/status`)}async getHistory(e){return this.client.get(`/api/v1/contracts/${e}/termination/history`)}async approve(e,t){return this.client.post(`/api/v1/contracts/${e}/termination/approve`,t??{})}async reject(e,t){return this.client.post(`/api/v1/contracts/${e}/termination/reject`,t)}async cancel(e){return this.client.delete(`/api/v1/contracts/${e}/termination`)}};var T=class{constructor(e){this.client=e}async list(e){return this.client.get(`/api/v1/contracts/${e}/payment-terms`)}async create(e,t){return this.client.post(`/api/v1/contracts/${e}/payment-terms`,t)}async update(e,t,n){return this.client.patch(`/api/v1/contracts/${e}/payment-terms/${t}`,n)}async delete(e,t){return this.client.delete(`/api/v1/contracts/${e}/payment-terms/${t}`)}};var w=class{constructor(e){this.client=e}async create(e,t){return this.client.post(`/api/v1/contracts/${e}/agreements`,t)}async list(e){return this.client.get(`/api/v1/contracts/${e}/agreements`)}async get(e,t){return this.client.get(`/api/v1/contracts/${e}/agreements/${t}`)}async initiateSigning(e,t,n){let i=n?{...n,deadline:n.deadline?.toISOString()}:{};return this.client.post(`/api/v1/contracts/${e}/agreements/${t}/initiate-signing`,i)}async delete(e,t){return this.client.delete(`/api/v1/contracts/${e}/agreements/${t}`)}};var $=class{constructor(e){this.client=e;this.termination=new E(e),this.paymentTerms=new T(e),this.agreements=new w(e)}termination;paymentTerms;agreements;async create(e){return u(e.contragent?.email,"contragent.email"),this.client.post("/api/v1/contracts",{...e,contragent:f(e.contragent)})}async list(e){let t=new URLSearchParams;e?.page&&t.set("page",String(e.page)),e?.limit&&t.set("limit",String(e.limit)),e?.status&&t.set("status",e.status),e?.search&&t.set("search",e.search);let n=t.toString();return this.client.get(`/api/v1/contracts${n?`?${n}`:""}`)}async get(e){return this.client.get(`/api/v1/contracts/${e}`)}async getStatus(e){return this.client.get(`/api/v1/contracts/${e}/status`)}async getActivities(e,t){let n=new URLSearchParams;t?.page&&n.set("page",String(t.page)),t?.limit&&n.set("limit",String(t.limit));let i=n.toString();return this.client.get(`/api/v1/contracts/${e}/activities${i?`?${i}`:""}`)}async addPaymentSetup(e,t){return this.client.post(`/api/v1/contracts/${e}/payment-setup`,t)}async send(e,t){return this.client.post(`/api/v1/contracts/${e}/send`,{...t,deadline:t?.deadline?.toISOString()})}async cancel(e){return this.client.post(`/api/v1/contracts/${e}/cancel`,{})}async terminate(e,t){return this.client.post(`/api/v1/contracts/${e}/terminate`,t??{})}async update(e,t){return t.contragent!==void 0&&u(t.contragent.email,"contragent.email"),this.client.patch(`/api/v1/contracts/${e}`,{...t,contragent:t.contragent?f(t.contragent):void 0})}async delete(e){return this.client.delete(`/api/v1/contracts/${e}`)}async createEmpty(e){return u(e.contragentEmail,"contragentEmail"),this.client.post("/api/v1/contracts/empty",{...e,contragentEmail:y(e.contragentEmail)})}async createMinimal(e){return u(e.contragentEmail,"contragentEmail"),this.client.post("/api/v1/contracts/minimal",{...e,contragentEmail:y(e.contragentEmail)})}async import(e){return u(e.contragentEmail,"contragentEmail"),this.client.post("/api/v1/contracts/import",{...e,contragentEmail:y(e.contragentEmail)})}async attachDocument(e,t){return this.client.patch(`/api/v1/contracts/${e}/document`,t)}async getStats(e){return this.client.get(`/api/v1/contracts/${e}/stats`)}async setupRecurring(e,t){return this.client.post(`/api/v1/contracts/${e}/recurring-setup`,t)}async resendRecurringApproval(e){return this.client.post(`/api/v1/contracts/${e}/recurring-approval/resend`,{})}async cancelRecurringApproval(e){return this.client.delete(`/api/v1/contracts/${e}/recurring-approval`)}async listSigningRequests(e){return this.client.get(`/api/v1/contracts/${e}/signing-requests`)}async getSigningRequest(e,t){return this.client.get(`/api/v1/contracts/${e}/signing-requests/${t}`)}async resendSigningRequest(e,t){return this.client.post(`/api/v1/contracts/${e}/signing-requests/${t}/resend`,{})}async cancelSigningRequest(e,t){return this.client.delete(`/api/v1/contracts/${e}/signing-requests/${t}`)}async businessSign(e,t,n){return this.client.post(`/api/v1/contracts/${e}/signing-requests/${t}/business-sign`,n)}};var D=class{constructor(e){this.client=e}async list(e){let t=new URLSearchParams;e?.page!==void 0&&t.set("page",String(e.page)),e?.limit!==void 0&&t.set("limit",String(e.limit)),e?.status&&t.set("status",e.status),e?.search&&t.set("search",e.search);let n=t.toString();return this.client.get(`/api/v1/templates${n?`?${n}`:""}`)}async get(e){return this.client.get(`/api/v1/templates/${e}`)}async getVersions(e){return this.client.get(`/api/v1/templates/${e}/versions`)}async createDocument(e,t){return this.client.post(`/api/v1/templates/${e}/documents`,t)}async sendForSigning(e,t){return t.slotAssignments.forEach((n,i)=>u(n?.email,`slotAssignments[${i}].email`)),this.client.post(`/api/v1/templates/${e}/signature-requests`,{...t,slotAssignments:t.slotAssignments.map(f)})}async createContract(e,t){return u(t.contragent?.email,"contragent.email"),this.client.post(`/api/v1/templates/${e}/contracts`,{...t,contragent:f(t.contragent)})}async create(e){return this.client.post("/api/v1/templates",e)}async update(e,t){return this.client.patch(`/api/v1/templates/${e}`,t)}async publish(e,t){return this.client.post(`/api/v1/templates/${e}/publish`,t??{})}async archive(e){return this.client.post(`/api/v1/templates/${e}/archive`,{})}async restore(e){return this.client.post(`/api/v1/templates/${e}/restore`,{})}async delete(e){return this.client.delete(`/api/v1/templates/${e}`)}async previewPdf(e,t){return this.client.download(`/api/v1/templates/${e}/preview-pdf`,{method:"POST",body:t??{}})}async previewHtml(e,t){return this.client.post(`/api/v1/templates/${e}/preview-html`,t??{})}async previewUnsavedPdf(e){return this.client.download("/api/v1/templates/preview-unsaved-pdf",{method:"POST",body:e})}};var b=class{constructor(e){this.client=e}async create(e,t){return this.client.post(`/api/v1/contracts/${e}/invoices`,t)}async list(e,t){let n=new URLSearchParams;t?.page&&n.set("page",String(t.page)),t?.limit&&n.set("limit",String(t.limit)),t?.status&&n.set("status",t.status),t?.type&&n.set("type",t.type),typeof t?.overdue=="boolean"&&n.set("overdue",String(t.overdue)),t?.dueDateFrom&&n.set("dueDateFrom",t.dueDateFrom),t?.dueDateTo&&n.set("dueDateTo",t.dueDateTo);let i=n.toString();return this.client.get(`/api/v1/contracts/${e}/invoices${i?`?${i}`:""}`)}async listAll(e){let t=new URLSearchParams;e?.page&&t.set("page",String(e.page)),e?.limit&&t.set("limit",String(e.limit)),e?.status&&t.set("status",e.status),e?.type&&t.set("type",e.type),typeof e?.overdue=="boolean"&&t.set("overdue",String(e.overdue)),e?.dueDateFrom&&t.set("dueDateFrom",e.dueDateFrom),e?.dueDateTo&&t.set("dueDateTo",e.dueDateTo),e?.search&&t.set("search",e.search);let n=t.toString();return this.client.get(`/api/v1/invoices${n?`?${n}`:""}`)}async get(e,t){return this.client.get(`/api/v1/contracts/${e}/invoices/${t}`)}async send(e,t,n){return this.client.post(`/api/v1/contracts/${e}/invoices/${t}/send`,n??{})}async charge(e,t){return this.client.post(`/api/v1/contracts/${e}/invoices/${t}/charge`,{})}async markPaid(e,t,n){return this.client.post(`/api/v1/contracts/${e}/invoices/${t}/mark-paid`,n??{})}async update(e,t,n){return this.client.patch(`/api/v1/contracts/${e}/invoices/${t}`,n)}async cancel(e,t){return this.client.post(`/api/v1/contracts/${e}/invoices/${t}/cancel`,{})}async downloadPdf(e,t){return this.client.download(`/api/v1/contracts/${e}/invoices/${t}/pdf`)}};var A=class{constructor(e){this.client=e}async listByContract(e){return this.client.get(`/api/v1/contracts/${e}/transactions`)}async get(e){return this.client.get(`/api/v1/transactions/${e}`)}async getPaymentMix(e){let t=new URLSearchParams;return t.set("from",e.from),t.set("to",e.to),e.status!==void 0&&t.set("status",e.status),e.contractUuid!==void 0&&t.set("contractUuid",e.contractUuid),e.currencyCode!==void 0&&t.set("currencyCode",e.currencyCode),this.client.get(`/api/v1/transactions/payment-mix?${t.toString()}`)}async getFeeEstimate(e){let t=new URLSearchParams;return t.set("amount",String(e.amount)),t.set("currency",e.currency),e.platformFeePercent!==void 0&&t.set("platformFeePercent",String(e.platformFeePercent)),this.client.get(`/api/v1/transactions/fee-estimate?${t.toString()}`)}};var q=class{constructor(e){this.client=e}async createSession(e){return u(e.email,"email"),this.client.post("/api/v1/embedded/sessions",{...e,email:y(e.email)})}};var L=class{constructor(e){this.client=e}async upload(e){return this.client.uploadFiles("/api/v1/media/upload",e)}};import{createHmac as K,timingSafeEqual as Z}from"crypto";var W=300*1e3,I=class{static verify(e,t,n,i){if(!e||!t||!n||!i)return{valid:!1};let m=new Date(n).getTime();if(isNaN(m))return{valid:!1};if(Math.abs(Date.now()-m)>W)return{valid:!1};let d=t.match(/^v1=([a-f0-9]+)$/i);if(!d||!d[1])return{valid:!1};let g=d[1],a=`${n}.${e}`,o=K("sha256",i).update(a).digest("hex");if(g.length!==o.length)return{valid:!1};let r=Buffer.from(g,"hex"),p=Buffer.from(o,"hex");if(r.length!==p.length)return{valid:!1};if(!Z(r,p))return{valid:!1};try{return{valid:!0,envelope:JSON.parse(e)}}catch{return{valid:!1}}}static parse(e){return JSON.parse(e)}};var x=class{client;static webhooks=I;documents;signatures;contracts;templates;invoices;transactions;embedded;media;constructor(e){this.client=new P(e),this.documents=new S(this.client),this.signatures=new C(this.client),this.contracts=new $(this.client),this.templates=new D(this.client),this.invoices=new b(this.client),this.transactions=new A(this.client),this.embedded=new q(this.client),this.media=new L(this.client)}async getApiKeyInfo(){return this.client.get("/api/v1/me")}async healthCheck(){return this.client.get("/api/v1/health")}};export{x as Chaindoc,c as ChaindocError}; | ||
| //# sourceMappingURL=index.mjs.map |
+1
-1
| { | ||
| "name": "@chaindoc_io/server-sdk", | ||
| "version": "2.0.1", | ||
| "version": "2.1.0", | ||
| "description": "Server-side SDK for Chaindoc API - document management, signatures, and embedded sessions", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.cjs", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
382254
93.71%1848
96.39%6
50%