@epilot/document-client 0.11.7 → 0.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- (()=>{"use strict";var e={914:function(e,t,r){var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var n=o(r(534));t.default=n.default},534:e=>{e.exports=JSON.parse('{"openapi":"3.0.2","info":{"title":"Document API","version":"1.0.0","description":"Generate documents with epilot data\\n\\n[Feature Documentation](https://docs.epilot.io/docs/files/document-generation)\\n"},"tags":[{"name":"Documents","description":"Document Generation"}],"security":[{"EpilotAuth":[]}],"paths":{"/v1/documents:generate":{"post":{"operationId":"generateDocument","summary":"generateDocument","description":"Builds document generated from input document with variables.\\n\\nSupported input document types:\\n- .docx\\n\\nSupported output document types:\\n- .pdf\\n\\nUses [Template Variables API](https://docs.epilot.io/api/template-variables) to replace variables in the document.\\n","tags":["Documents"],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"language":{"type":"string","default":"en","example":"de","description":"Language to use"},"template_document":{"description":"Input template document","type":"object","properties":{"filename":{"type":"string","description":"Document original filename","example":"my-template-{{order.order_number}}.docx"},"s3ref":{"$ref":"#/components/schemas/S3Reference"}}},"context_entity_id":{"type":"string","description":"Entity to use for variable context","example":"bcd0aab9-b544-42b0-8bfb-6d449d02eacc"},"user_id":{"type":"string","description":"User Id for variable context","example":100321}},"required":["template_document"]}}}},"responses":{"200":{"description":"Generated document output","content":{"application/json":{"schema":{"type":"object","properties":{"preview_url":{"description":"Pre-signed S3 GET URL for preview","type":"string","example":"https://document-api-prod.s3.eu-central-1.amazonaws.com/preview/my-template-OR-001.pdf"},"output_document":{"type":"object","properties":{"filename":{"description":"Generated document filename","type":"string","example":"my-template-OR-001.pdf"},"s3ref":{"$ref":"#/components/schemas/S3Reference"}},"example":{"s3ref":{"bucket":"document-api-preview-prod","key":"preview/my-template.pdf"}}}}}}}}}}},"/v2/documents:generate":{"post":{"operationId":"generateDocumentV2","summary":"generateDocumentV2","description":"Builds document generated from input document with variables.\\n\\nSupported input document types:\\n- .docx\\n\\nSupported output document types:\\n- .pdf\\n- .docx but limited to only text based variables\\n\\nUses [Template Variables API](https://docs.epilot.io/api/template-variables) to replace variables in the document.\\n","parameters":[{"in":"query","name":"job_id","description":"Job ID for tracking the status of document generation action","schema":{"type":"string"}},{"in":"query","name":"mode","description":"Type of mode used for document generation flow.\\nPartial - Will have a intermediate step for users to validate and replace the variable values before generating the final document.\\nFull - Goes through all the steps for the full generation of final document\\n","schema":{"type":"string","enum":["partial_generation","full_generation"],"default":"automatic"}}],"tags":["Documents"],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DocumentGenerationV2Request"}}}},"responses":{"200":{"description":"Generated document output","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DocumentGenerationV2Response"}}}}}}}},"components":{"securitySchemes":{"EpilotAuth":{"type":"http","scheme":"bearer","description":"Authorization header with epilot OAuth2 bearer token","bearerFormat":"JWT"}},"schemas":{"S3Reference":{"type":"object","properties":{"bucket":{"type":"string","example":"document-api-prod"},"key":{"type":"string","example":"uploads/my-template.pdf"}},"required":["bucket","key"]},"ErrorOutput":{"type":"object","properties":{"error_message":{"description":"Error message","type":"string"},"error_code":{"$ref":"#/components/schemas/ErrorCode"},"error_details":{"anyOf":[{"$ref":"#/components/schemas/InvalidCustomVariableErrorDetails"},{"$ref":"#/components/schemas/InternalErrorDetails"},{"$ref":"#/components/schemas/DocxTemplaterErrorDetails"}]}}},"InvalidCustomVariableErrorDetails":{"description":"Error details for invalid custom variables. This error will appear under \'PARSE_ERROR\' error code.","type":"array","items":[{"$ref":"#/components/schemas/InvalidCustomVariableErrorDetail"}]},"InvalidCustomVariableErrorDetail":{"type":"object","additionalProperties":true,"properties":{"explanation":{"description":"Explanation for the error","type":"string"},"context":{"description":"Context for the error","type":"object","properties":{"invalid_variables":{"description":"List of invalid variables","type":"array","items":{"type":"object","description":"Invalid variable","properties":{"variable":{"description":"Variable name","type":"string"},"error":{"description":"Explanation for the error","type":"string"}}}}}}}},"InternalErrorDetails":{"description":"Error details for internal error. This error will appear under \'INTERNAL_ERROR\' error code.","type":"array","items":{"type":"object","properties":{"items":[{"$ref":"#/components/schemas/InternalErrorDetail"}]}}},"InternalErrorDetail":{"type":"object","description":"Internal error detail","properties":{"name":{"description":"Name of the error","type":"string"},"message":{"description":"Error message","type":"string"},"stack":{"description":"Stack trace","type":"string"},"cause":{"description":"Cause of the error","type":"string"}}},"DocxTemplaterErrorDetails":{"description":"Error details for DocxTemplater error. This error will appear under \'PARSE_ERROR\' error code.\\nSee https://docxtemplater.com/docs/errors/#error-schema for more details.\\n","type":"array","items":[{"$ref":"#/components/schemas/DocxTemplaterErrorDetail"}]},"DocxTemplaterErrorDetail":{"type":"object","description":"DocxTemplater error detail","properties":{"id":{"description":"Id of the error","type":"string"},"context":{"description":"Context of the error","type":"string"},"explanation":{"description":"Explanation of the error","type":"string"}}},"ErrorCode":{"description":"Error codes for document generation:\\n- PARSE_ERROR - Error while parsing the document. Normally related with a bad template using the wrong DocxTemplater syntax.\\n- DOC_TO_PDF_CONVERT_ERROR - Error while converting the document to PDF. Normally related with a ConvertAPI failure.\\n- INTERNAL_ERROR - Internal error. Please contact support.\\n- INVALID_TEMPLATE_FORMAT - Invalid template format (only .docx is supported). This can happen due to a bad word file or an unsupported file extension.\\n","type":"string","enum":["PARSE_ERROR","DOC_TO_PDF_CONVERT_ERROR","INTERNAL_ERROR","INVALID_TEMPLATE_FORMAT"]},"TemplateSettings":{"type":"object","description":"Template Settings for document generation","properties":{"custom_margins":{"description":"Custom margins for the document","type":"object","properties":{"top":{"description":"Top margin in cm","type":"number","example":2.54},"bottom":{"description":"Bottom margin in cm","type":"number","example":2.54}}},"display_margin_guidelines":{"description":"Display margin guidelines (applicable to partial generation only)","type":"boolean","example":true},"enable_data_table_margin_autofix":{"description":"Enable data table margin autofix","type":"boolean","example":false},"template_with_datatable":{"description":"A flag that indicates whether the template has 1 or more data tables in it","type":"boolean","example":false},"enabled_template_settings_persistence":{"description":"Enables the persistance of template settings","type":"boolean","example":false},"misconfigured_margins":{"description":"An indication that the page margins are misconfigured","type":"boolean","example":false},"file_entity_id":{"description":"The file entity id, used when persisting a new template version with updated settings","type":"string","format":"uuid","example":"1a2b3c4d-5e6f-7g8h-9i0j-1k2l3m4n5o6p"}}},"DocumentGenerationV2Request":{"type":"object","properties":{"language":{"type":"string","default":"de","description":"Language to use for variables"},"template_document":{"description":"Input template document","type":"object","properties":{"filename":{"type":"string","description":"Document original filename","example":"my-template-{{order.order_number}}.docx"},"s3ref":{"$ref":"#/components/schemas/S3Reference"}}},"context_entity_id":{"type":"string","format":"uuid","description":"Entity to use for variable context","example":"bcd0aab9-b544-42b0-8bfb-6d449d02eacc"},"user_id":{"type":"string","description":"User Id for variable context","example":100321},"variable_payload":{"description":"Custom values for variables in the template. Takes the higher precedence than others.","type":"object","properties":{"additionalProperties":{"type":"string"}}},"template_settings":{"$ref":"#/components/schemas/TemplateSettings"}},"required":["template_document"]},"DocumentGenerationV2Response":{"type":"object","properties":{"job_id":{"type":"string","format":"uuid"},"job_status":{"description":"Status of the job","type":"string","enum":["STARTED","PROCESSING","SUCCESS","FAILED"]},"message":{"description":"A message explaining the progress","type":"string"},"pdf_output":{"type":"object","properties":{"preview_url":{"description":"Pre-signed S3 GET URL for PDF preview","type":"string","example":"https://document-api-prod.s3.eu-central-1.amazonaws.com/preview/my-template-OR-001.pdf"},"output_document":{"type":"object","properties":{"filename":{"description":"Generated document filename for PDF","type":"string","example":"my-template-OR-001.pdf"},"s3ref":{"$ref":"#/components/schemas/S3Reference"}},"example":{"s3ref":{"bucket":"document-api-preview-prod","key":"preview/my-template.pdf"}}}}},"docx_output":{"type":"object","properties":{"preview_url":{"description":"Pre-signed S3 GET URL for DOCX preview","type":"string","example":"https://document-api-prod.s3.eu-central-1.amazonaws.com/preview/my-template-OR-001.docx"},"output_document":{"type":"object","properties":{"filename":{"description":"Generated document filename for DOCX","type":"string","example":"my-template-OR-001.docx"},"s3ref":{"$ref":"#/components/schemas/S3Reference"}},"example":{"s3ref":{"bucket":"document-api-preview-prod","key":"preview/my-template.docx"}}}}},"error_output":{"$ref":"#/components/schemas/ErrorOutput"},"variable_payload":{"description":"List of variables and its corresponding replaced values from the document template","type":"object","properties":{"additionalProperties":{"type":"string"}}},"template_settings":{"$ref":"#/components/schemas/TemplateSettings"}}}}},"servers":[{"url":"https://document.sls.epilot.io"}]}')}},t={},r=function r(o){var n=t[o];if(void 0!==n)return n.exports;var i=t[o]={exports:{}};return e[o].call(i.exports,i,i.exports,r),i.exports}(914),o=exports;for(var n in r)o[n]=r[n];r.__esModule&&Object.defineProperty(o,"__esModule",{value:!0})})();
1
+ (()=>{"use strict";var e={914:function(e,t,r){var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var n=o(r(534));t.default=n.default},534:e=>{e.exports=JSON.parse('{"openapi":"3.0.2","info":{"title":"Document API","version":"1.0.0","description":"A document generation API that allows you to generate documents from templates with variables.\\n\\n[Feature Documentation](https://docs.epilot.io/docs/files/document-generation)\\n"},"tags":[{"name":"Documents","description":"Document Generation"}],"security":[{"EpilotAuth":[]}],"paths":{"/v2/documents:generate":{"post":{"operationId":"generateDocumentV2","summary":"generateDocumentV2","description":"Builds document generated from input document with variables.\\n\\nSupported input document types:\\n- .docx\\n\\nSupported output document types:\\n- .pdf\\n- .docx but limited to only text based variables\\n\\nUses [Template Variables API](https://docs.epilot.io/api/template-variables) to replace variables in the document.\\n","parameters":[{"in":"query","name":"job_id","description":"Job ID for tracking the status of document generation action","schema":{"type":"string"}},{"in":"query","name":"mode","description":"Type of mode used for document generation flow:\\n- partial_generation will have a intermediate step for users to validate and replace the variable values before generating the final document.\\n- full_generation, goes through all the steps for the full generation of final document\\n","schema":{"type":"string","enum":["partial_generation","full_generation"],"default":"full_generation"}}],"tags":["Documents"],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DocumentGenerationV2Request"}}}},"responses":{"200":{"description":"Generated document output","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DocumentGenerationV2Response"}}}}}}},"/v2/documents:convert":{"post":{"operationId":"convertDocument","summary":"convertDocument","description":"Converts a document to a different format.\\n\\nSupported input document types:\\n- .docx\\n\\nSupported output document types:\\n- .pdf\\n","tags":["Documents"],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConvertDocumentRequest"}}}},"responses":{"200":{"description":"Conversion job output","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConvertDocumentResponse"}}}}}}}},"components":{"securitySchemes":{"EpilotAuth":{"type":"http","scheme":"bearer","description":"Authorization header with epilot OAuth2 bearer token","bearerFormat":"JWT"}},"schemas":{"S3Reference":{"type":"object","properties":{"bucket":{"type":"string","example":"document-api-prod"},"key":{"type":"string","example":"uploads/my-template.pdf"}},"required":["bucket","key"]},"ErrorOutput":{"type":"object","properties":{"error_message":{"description":"Error message","type":"string"},"error_code":{"$ref":"#/components/schemas/ErrorCode"},"error_details":{"anyOf":[{"$ref":"#/components/schemas/InvalidCustomVariableErrorDetails"},{"$ref":"#/components/schemas/InternalErrorDetails"},{"$ref":"#/components/schemas/DocxTemplaterErrorDetails"}]}}},"InvalidCustomVariableErrorDetails":{"description":"Error details for invalid custom variables. This error will appear under \'PARSE_ERROR\' error code.","type":"array","items":{"$ref":"#/components/schemas/InvalidCustomVariableErrorDetail"}},"InvalidCustomVariableErrorDetail":{"type":"object","additionalProperties":true,"properties":{"explanation":{"description":"Explanation for the error","type":"string"},"context":{"description":"Context for the error","type":"object","properties":{"invalid_variables":{"description":"List of invalid variables","type":"array","items":{"type":"object","description":"Invalid variable","properties":{"variable":{"description":"Variable name","type":"string"},"error":{"description":"Explanation for the error","type":"string"}}}}}}}},"InternalErrorDetails":{"description":"Error details for internal error. This error will appear under \'INTERNAL_ERROR\' error code.","type":"array","items":{"type":"object","properties":{"items":{"$ref":"#/components/schemas/InternalErrorDetail"}}}},"InternalErrorDetail":{"type":"object","description":"Internal error detail","properties":{"name":{"description":"Name of the error","type":"string"},"message":{"description":"Error message","type":"string"},"stack":{"description":"Stack trace","type":"string"},"cause":{"description":"Cause of the error","type":"string"}}},"DocxTemplaterErrorDetails":{"description":"Error details for DocxTemplater error. This error will appear under \'PARSE_ERROR\' error code.\\nSee https://docxtemplater.com/docs/errors/#error-schema for more details.\\n","type":"array","items":{"$ref":"#/components/schemas/DocxTemplaterErrorDetail"}},"DocxTemplaterErrorDetail":{"type":"object","description":"DocxTemplater error detail","properties":{"id":{"description":"Id of the error","type":"string"},"context":{"description":"Context of the error","type":"string"},"explanation":{"description":"Explanation of the error","type":"string"}}},"ErrorCode":{"description":"Error codes for document generation:\\n- PARSE_ERROR - Error while parsing the document. Normally related with a bad template using the wrong DocxTemplater syntax.\\n- DOC_TO_PDF_CONVERT_ERROR - Error while converting the document to PDF. Normally related with a ConvertAPI failure.\\n- INTERNAL_ERROR - Internal error. Please contact support.\\n- INVALID_TEMPLATE_FORMAT - Invalid template format (only .docx is supported). This can happen due to a bad word file or an unsupported file extension.\\n","type":"string","enum":["PARSE_ERROR","DOC_TO_PDF_CONVERT_ERROR","INTERNAL_ERROR","INVALID_TEMPLATE_FORMAT"]},"TemplateSettings":{"type":"object","description":"Template Settings for document generation","properties":{"custom_margins":{"description":"Custom margins for the document","type":"object","properties":{"top":{"description":"Top margin in cm","type":"number","example":2.54},"bottom":{"description":"Bottom margin in cm","type":"number","example":2.54}}},"suggested_margins":{"description":"Suggested margins for the document","type":"object","properties":{"top":{"description":"Top margin in cm","type":"number","example":2.54},"bottom":{"description":"Bottom margin in cm","type":"number","example":2.54}}},"display_margin_guidelines":{"description":"Display margin guidelines (applicable to partial generation only)","type":"boolean","example":true},"enable_data_table_margin_autofix":{"description":"Enable data table margin autofix","type":"boolean","example":false},"template_with_datatable":{"description":"A flag that indicates whether the template has 1 or more data tables in it","type":"boolean","example":false},"enabled_template_settings_persistence":{"description":"Enables the persistance of template settings","type":"boolean","example":false},"misconfigured_margins":{"description":"An indication that the page margins are misconfigured","type":"boolean","example":false},"file_entity_id":{"description":"The file entity id, used when persisting a new template version with updated settings","type":"string","format":"uuid","example":"1a2b3c4d-5e6f-7g8h-9i0j-1k2l3m4n5o6p"}}},"DocumentGenerationV2Request":{"type":"object","properties":{"template_document":{"description":"Input template document","type":"object","properties":{"filename":{"type":"string","description":"Document original filename","example":"my-template-{{order.order_number}}.docx"},"s3ref":{"$ref":"#/components/schemas/S3Reference"}}},"context_entity_id":{"type":"string","format":"uuid","description":"Entity to use for variable context","example":"bcd0aab9-b544-42b0-8bfb-6d449d02eacc"},"user_id":{"type":"string","description":"User Id for variable context","example":100321},"language":{"type":"string","description":"Language","example":"en"},"variable_payload":{"description":"Custom values for variables in the template. Takes the higher precedence than others.","type":"object","properties":{"additionalProperties":{"type":"string"}}},"context_data":{"description":"Custom values for variables in the template. Takes the higher precedence than others.","type":"object","properties":{"additionalProperties":{"type":"string"}}},"template_settings":{"$ref":"#/components/schemas/TemplateSettings"}},"required":["template_document"]},"DocumentGenerationV2Response":{"type":"object","properties":{"job_id":{"type":"string","format":"uuid"},"job_status":{"description":"Status of the job","type":"string","enum":["STARTED","PROCESSING","SUCCESS","FAILED"]},"message":{"description":"A message explaining the progress","type":"string"},"pdf_output":{"type":"object","properties":{"preview_url":{"description":"Pre-signed S3 GET URL for PDF preview","type":"string","example":"https://document-api-prod.s3.eu-central-1.amazonaws.com/preview/my-template-OR-001.pdf"},"output_document":{"type":"object","properties":{"filename":{"description":"Generated document filename for PDF","type":"string","example":"my-template-OR-001.pdf"},"s3ref":{"$ref":"#/components/schemas/S3Reference"}},"example":{"s3ref":{"bucket":"document-api-preview-prod","key":"preview/my-template.pdf"}}}}},"docx_output":{"type":"object","properties":{"preview_url":{"description":"Pre-signed S3 GET URL for DOCX preview","type":"string","example":"https://document-api-prod.s3.eu-central-1.amazonaws.com/preview/my-template-OR-001.docx"},"output_document":{"type":"object","properties":{"filename":{"description":"Generated document filename for DOCX","type":"string","example":"my-template-OR-001.docx"},"s3ref":{"$ref":"#/components/schemas/S3Reference"}},"example":{"s3ref":{"bucket":"document-api-preview-prod","key":"preview/my-template.docx"}}}}},"error_output":{"$ref":"#/components/schemas/ErrorOutput"},"variable_payload":{"description":"List of variables and its corresponding replaced values from the document template","type":"object","properties":{"additionalProperties":{"type":"string"}}},"template_settings":{"$ref":"#/components/schemas/TemplateSettings"}}},"ConvertDocumentRequest":{"type":"object","properties":{"input_document":{"description":"Input document","type":"object","properties":{"s3ref":{"$ref":"#/components/schemas/S3Reference"}},"required":["s3ref"]},"output_format":{"description":"Output format of the document","type":"string","enum":["pdf"]},"output_filename":{"description":"Filename of the output document (optional)","type":"string","example":"converted.pdf"}},"required":["input_document","output_format"]},"ConvertDocumentResponse":{"type":"object","properties":{"output_document":{"type":"object","properties":{"preview_url":{"description":"Pre-signed URL for the converted document","type":"string","example":"https://document-api-prod.s3.eu-central-1.amazonaws.com/preview/converted.pdf"},"s3ref":{"$ref":"#/components/schemas/S3Reference"}}}}}}},"servers":[{"url":"https://document.sls.epilot.io"},{"url":"https://document.sls.epilot.io"}]}')}},t={},r=function r(o){var n=t[o];if(void 0!==n)return n.exports;var i=t[o]={exports:{}};return e[o].call(i.exports,i,i.exports,r),i.exports}(914),o=exports;for(var n in r)o[n]=r[n];r.__esModule&&Object.defineProperty(o,"__esModule",{value:!0})})();
package/dist/openapi.d.ts CHANGED
@@ -9,11 +9,36 @@ import type {
9
9
 
10
10
  declare namespace Components {
11
11
  namespace Schemas {
12
- export interface DocumentGenerationV2Request {
12
+ export interface ConvertDocumentRequest {
13
13
  /**
14
- * Language to use for variables
14
+ * Input document
15
15
  */
16
- language?: string;
16
+ input_document: {
17
+ s3ref: S3Reference;
18
+ };
19
+ /**
20
+ * Output format of the document
21
+ */
22
+ output_format: "pdf";
23
+ /**
24
+ * Filename of the output document (optional)
25
+ * example:
26
+ * converted.pdf
27
+ */
28
+ output_filename?: string;
29
+ }
30
+ export interface ConvertDocumentResponse {
31
+ output_document?: {
32
+ /**
33
+ * Pre-signed URL for the converted document
34
+ * example:
35
+ * https://document-api-prod.s3.eu-central-1.amazonaws.com/preview/converted.pdf
36
+ */
37
+ preview_url?: string;
38
+ s3ref?: S3Reference;
39
+ };
40
+ }
41
+ export interface DocumentGenerationV2Request {
17
42
  /**
18
43
  * Input template document
19
44
  */
@@ -38,12 +63,24 @@ declare namespace Components {
38
63
  * 100321
39
64
  */
40
65
  user_id?: string;
66
+ /**
67
+ * Language
68
+ * example:
69
+ * en
70
+ */
71
+ language?: string;
41
72
  /**
42
73
  * Custom values for variables in the template. Takes the higher precedence than others.
43
74
  */
44
75
  variable_payload?: {
45
76
  additionalProperties?: string;
46
77
  };
78
+ /**
79
+ * Custom values for variables in the template. Takes the higher precedence than others.
80
+ */
81
+ context_data?: {
82
+ additionalProperties?: string;
83
+ };
47
84
  template_settings?: /* Template Settings for document generation */ TemplateSettings;
48
85
  }
49
86
  export interface DocumentGenerationV2Response {
@@ -139,10 +176,7 @@ declare namespace Components {
139
176
  * See https://docxtemplater.com/docs/errors/#error-schema for more details.
140
177
  *
141
178
  */
142
- export type DocxTemplaterErrorDetails = [
143
- /* DocxTemplater error detail */ DocxTemplaterErrorDetail?,
144
- ...any[]
145
- ];
179
+ export type DocxTemplaterErrorDetails = /* DocxTemplater error detail */ DocxTemplaterErrorDetail[];
146
180
  /**
147
181
  * Error codes for document generation:
148
182
  * - PARSE_ERROR - Error while parsing the document. Normally related with a bad template using the wrong DocxTemplater syntax.
@@ -198,7 +232,7 @@ declare namespace Components {
198
232
  * Error details for internal error. This error will appear under 'INTERNAL_ERROR' error code.
199
233
  */
200
234
  export type InternalErrorDetails = {
201
- items?: any;
235
+ items?: /* Internal error detail */ InternalErrorDetail;
202
236
  }[];
203
237
  export interface InvalidCustomVariableErrorDetail {
204
238
  [name: string]: any;
@@ -228,10 +262,7 @@ declare namespace Components {
228
262
  /**
229
263
  * Error details for invalid custom variables. This error will appear under 'PARSE_ERROR' error code.
230
264
  */
231
- export type InvalidCustomVariableErrorDetails = [
232
- InvalidCustomVariableErrorDetail?,
233
- ...any[]
234
- ];
265
+ export type InvalidCustomVariableErrorDetails = InvalidCustomVariableErrorDetail[];
235
266
  export interface S3Reference {
236
267
  /**
237
268
  * example:
@@ -265,6 +296,23 @@ declare namespace Components {
265
296
  */
266
297
  bottom?: number;
267
298
  };
299
+ /**
300
+ * Suggested margins for the document
301
+ */
302
+ suggested_margins?: {
303
+ /**
304
+ * Top margin in cm
305
+ * example:
306
+ * 2.54
307
+ */
308
+ top?: number;
309
+ /**
310
+ * Bottom margin in cm
311
+ * example:
312
+ * 2.54
313
+ */
314
+ bottom?: number;
315
+ };
268
316
  /**
269
317
  * Display margin guidelines (applicable to partial generation only)
270
318
  * example:
@@ -305,66 +353,10 @@ declare namespace Components {
305
353
  }
306
354
  }
307
355
  declare namespace Paths {
308
- namespace GenerateDocument {
309
- export interface RequestBody {
310
- /**
311
- * Language to use
312
- * example:
313
- * de
314
- */
315
- language?: string;
316
- /**
317
- * Input template document
318
- */
319
- template_document: {
320
- /**
321
- * Document original filename
322
- * example:
323
- * my-template-{{order.order_number}}.docx
324
- */
325
- filename?: string;
326
- s3ref?: Components.Schemas.S3Reference;
327
- };
328
- /**
329
- * Entity to use for variable context
330
- * example:
331
- * bcd0aab9-b544-42b0-8bfb-6d449d02eacc
332
- */
333
- context_entity_id?: string;
334
- /**
335
- * User Id for variable context
336
- * example:
337
- * 100321
338
- */
339
- user_id?: string;
340
- }
356
+ namespace ConvertDocument {
357
+ export type RequestBody = Components.Schemas.ConvertDocumentRequest;
341
358
  namespace Responses {
342
- export interface $200 {
343
- /**
344
- * Pre-signed S3 GET URL for preview
345
- * example:
346
- * https://document-api-prod.s3.eu-central-1.amazonaws.com/preview/my-template-OR-001.pdf
347
- */
348
- preview_url?: string;
349
- /**
350
- * example:
351
- * {
352
- * "s3ref": {
353
- * "bucket": "document-api-preview-prod",
354
- * "key": "preview/my-template.pdf"
355
- * }
356
- * }
357
- */
358
- output_document?: {
359
- /**
360
- * Generated document filename
361
- * example:
362
- * my-template-OR-001.pdf
363
- */
364
- filename?: string;
365
- s3ref?: Components.Schemas.S3Reference;
366
- };
367
- }
359
+ export type $200 = Components.Schemas.ConvertDocumentResponse;
368
360
  }
369
361
  }
370
362
  namespace GenerateDocumentV2 {
@@ -385,7 +377,7 @@ declare namespace Paths {
385
377
 
386
378
  export interface OperationMethods {
387
379
  /**
388
- * generateDocument - generateDocument
380
+ * generateDocumentV2 - generateDocumentV2
389
381
  *
390
382
  * Builds document generated from input document with variables.
391
383
  *
@@ -394,41 +386,39 @@ export interface OperationMethods {
394
386
  *
395
387
  * Supported output document types:
396
388
  * - .pdf
389
+ * - .docx but limited to only text based variables
397
390
  *
398
391
  * Uses [Template Variables API](https://docs.epilot.io/api/template-variables) to replace variables in the document.
399
392
  *
400
393
  */
401
- 'generateDocument'(
402
- parameters?: Parameters<UnknownParamsObject> | null,
403
- data?: Paths.GenerateDocument.RequestBody,
394
+ 'generateDocumentV2'(
395
+ parameters?: Parameters<Paths.GenerateDocumentV2.QueryParameters> | null,
396
+ data?: Paths.GenerateDocumentV2.RequestBody,
404
397
  config?: AxiosRequestConfig
405
- ): OperationResponse<Paths.GenerateDocument.Responses.$200>
398
+ ): OperationResponse<Paths.GenerateDocumentV2.Responses.$200>
406
399
  /**
407
- * generateDocumentV2 - generateDocumentV2
400
+ * convertDocument - convertDocument
408
401
  *
409
- * Builds document generated from input document with variables.
402
+ * Converts a document to a different format.
410
403
  *
411
404
  * Supported input document types:
412
405
  * - .docx
413
406
  *
414
407
  * Supported output document types:
415
408
  * - .pdf
416
- * - .docx but limited to only text based variables
417
- *
418
- * Uses [Template Variables API](https://docs.epilot.io/api/template-variables) to replace variables in the document.
419
409
  *
420
410
  */
421
- 'generateDocumentV2'(
422
- parameters?: Parameters<Paths.GenerateDocumentV2.QueryParameters> | null,
423
- data?: Paths.GenerateDocumentV2.RequestBody,
411
+ 'convertDocument'(
412
+ parameters?: Parameters<UnknownParamsObject> | null,
413
+ data?: Paths.ConvertDocument.RequestBody,
424
414
  config?: AxiosRequestConfig
425
- ): OperationResponse<Paths.GenerateDocumentV2.Responses.$200>
415
+ ): OperationResponse<Paths.ConvertDocument.Responses.$200>
426
416
  }
427
417
 
428
418
  export interface PathsDictionary {
429
- ['/v1/documents:generate']: {
419
+ ['/v2/documents:generate']: {
430
420
  /**
431
- * generateDocument - generateDocument
421
+ * generateDocumentV2 - generateDocumentV2
432
422
  *
433
423
  * Builds document generated from input document with variables.
434
424
  *
@@ -437,37 +427,35 @@ export interface PathsDictionary {
437
427
  *
438
428
  * Supported output document types:
439
429
  * - .pdf
430
+ * - .docx but limited to only text based variables
440
431
  *
441
432
  * Uses [Template Variables API](https://docs.epilot.io/api/template-variables) to replace variables in the document.
442
433
  *
443
434
  */
444
435
  'post'(
445
- parameters?: Parameters<UnknownParamsObject> | null,
446
- data?: Paths.GenerateDocument.RequestBody,
436
+ parameters?: Parameters<Paths.GenerateDocumentV2.QueryParameters> | null,
437
+ data?: Paths.GenerateDocumentV2.RequestBody,
447
438
  config?: AxiosRequestConfig
448
- ): OperationResponse<Paths.GenerateDocument.Responses.$200>
439
+ ): OperationResponse<Paths.GenerateDocumentV2.Responses.$200>
449
440
  }
450
- ['/v2/documents:generate']: {
441
+ ['/v2/documents:convert']: {
451
442
  /**
452
- * generateDocumentV2 - generateDocumentV2
443
+ * convertDocument - convertDocument
453
444
  *
454
- * Builds document generated from input document with variables.
445
+ * Converts a document to a different format.
455
446
  *
456
447
  * Supported input document types:
457
448
  * - .docx
458
449
  *
459
450
  * Supported output document types:
460
451
  * - .pdf
461
- * - .docx but limited to only text based variables
462
- *
463
- * Uses [Template Variables API](https://docs.epilot.io/api/template-variables) to replace variables in the document.
464
452
  *
465
453
  */
466
454
  'post'(
467
- parameters?: Parameters<Paths.GenerateDocumentV2.QueryParameters> | null,
468
- data?: Paths.GenerateDocumentV2.RequestBody,
455
+ parameters?: Parameters<UnknownParamsObject> | null,
456
+ data?: Paths.ConvertDocument.RequestBody,
469
457
  config?: AxiosRequestConfig
470
- ): OperationResponse<Paths.GenerateDocumentV2.Responses.$200>
458
+ ): OperationResponse<Paths.ConvertDocument.Responses.$200>
471
459
  }
472
460
  }
473
461
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epilot/document-client",
3
- "version": "0.11.7",
3
+ "version": "0.12.1",
4
4
  "description": "API Client for epilot document API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -0,0 +1,462 @@
1
+ /* eslint-disable */
2
+ import type {
3
+ OpenAPIClient,
4
+ Parameters,
5
+ UnknownParamsObject,
6
+ OperationResponse,
7
+ AxiosRequestConfig,
8
+ } from 'openapi-client-axios';
9
+
10
+ declare namespace Components {
11
+ namespace Schemas {
12
+ export interface ConvertDocumentRequest {
13
+ /**
14
+ * Input document
15
+ */
16
+ input_document: {
17
+ s3ref: S3Reference;
18
+ };
19
+ /**
20
+ * Output format of the document
21
+ */
22
+ output_format: "pdf";
23
+ /**
24
+ * Filename of the output document (optional)
25
+ * example:
26
+ * converted.pdf
27
+ */
28
+ output_filename?: string;
29
+ }
30
+ export interface ConvertDocumentResponse {
31
+ output_document?: {
32
+ /**
33
+ * Pre-signed URL for the converted document
34
+ * example:
35
+ * https://document-api-prod.s3.eu-central-1.amazonaws.com/preview/converted.pdf
36
+ */
37
+ preview_url?: string;
38
+ s3ref?: S3Reference;
39
+ };
40
+ }
41
+ export interface DocumentGenerationV2Request {
42
+ /**
43
+ * Input template document
44
+ */
45
+ template_document: {
46
+ /**
47
+ * Document original filename
48
+ * example:
49
+ * my-template-{{order.order_number}}.docx
50
+ */
51
+ filename?: string;
52
+ s3ref?: S3Reference;
53
+ };
54
+ /**
55
+ * Entity to use for variable context
56
+ * example:
57
+ * bcd0aab9-b544-42b0-8bfb-6d449d02eacc
58
+ */
59
+ context_entity_id?: string; // uuid
60
+ /**
61
+ * User Id for variable context
62
+ * example:
63
+ * 100321
64
+ */
65
+ user_id?: string;
66
+ /**
67
+ * Language
68
+ * example:
69
+ * en
70
+ */
71
+ language?: string;
72
+ /**
73
+ * Custom values for variables in the template. Takes the higher precedence than others.
74
+ */
75
+ variable_payload?: {
76
+ additionalProperties?: string;
77
+ };
78
+ /**
79
+ * Custom values for variables in the template. Takes the higher precedence than others.
80
+ */
81
+ context_data?: {
82
+ additionalProperties?: string;
83
+ };
84
+ template_settings?: /* Template Settings for document generation */ TemplateSettings;
85
+ }
86
+ export interface DocumentGenerationV2Response {
87
+ job_id?: string; // uuid
88
+ /**
89
+ * Status of the job
90
+ */
91
+ job_status?: "STARTED" | "PROCESSING" | "SUCCESS" | "FAILED";
92
+ /**
93
+ * A message explaining the progress
94
+ */
95
+ message?: string;
96
+ pdf_output?: {
97
+ /**
98
+ * Pre-signed S3 GET URL for PDF preview
99
+ * example:
100
+ * https://document-api-prod.s3.eu-central-1.amazonaws.com/preview/my-template-OR-001.pdf
101
+ */
102
+ preview_url?: string;
103
+ /**
104
+ * example:
105
+ * {
106
+ * "s3ref": {
107
+ * "bucket": "document-api-preview-prod",
108
+ * "key": "preview/my-template.pdf"
109
+ * }
110
+ * }
111
+ */
112
+ output_document?: {
113
+ /**
114
+ * Generated document filename for PDF
115
+ * example:
116
+ * my-template-OR-001.pdf
117
+ */
118
+ filename?: string;
119
+ s3ref?: S3Reference;
120
+ };
121
+ };
122
+ docx_output?: {
123
+ /**
124
+ * Pre-signed S3 GET URL for DOCX preview
125
+ * example:
126
+ * https://document-api-prod.s3.eu-central-1.amazonaws.com/preview/my-template-OR-001.docx
127
+ */
128
+ preview_url?: string;
129
+ /**
130
+ * example:
131
+ * {
132
+ * "s3ref": {
133
+ * "bucket": "document-api-preview-prod",
134
+ * "key": "preview/my-template.docx"
135
+ * }
136
+ * }
137
+ */
138
+ output_document?: {
139
+ /**
140
+ * Generated document filename for DOCX
141
+ * example:
142
+ * my-template-OR-001.docx
143
+ */
144
+ filename?: string;
145
+ s3ref?: S3Reference;
146
+ };
147
+ };
148
+ error_output?: ErrorOutput;
149
+ /**
150
+ * List of variables and its corresponding replaced values from the document template
151
+ */
152
+ variable_payload?: {
153
+ additionalProperties?: string;
154
+ };
155
+ template_settings?: /* Template Settings for document generation */ TemplateSettings;
156
+ }
157
+ /**
158
+ * DocxTemplater error detail
159
+ */
160
+ export interface DocxTemplaterErrorDetail {
161
+ /**
162
+ * Id of the error
163
+ */
164
+ id?: string;
165
+ /**
166
+ * Context of the error
167
+ */
168
+ context?: string;
169
+ /**
170
+ * Explanation of the error
171
+ */
172
+ explanation?: string;
173
+ }
174
+ /**
175
+ * Error details for DocxTemplater error. This error will appear under 'PARSE_ERROR' error code.
176
+ * See https://docxtemplater.com/docs/errors/#error-schema for more details.
177
+ *
178
+ */
179
+ export type DocxTemplaterErrorDetails = /* DocxTemplater error detail */ DocxTemplaterErrorDetail[];
180
+ /**
181
+ * Error codes for document generation:
182
+ * - PARSE_ERROR - Error while parsing the document. Normally related with a bad template using the wrong DocxTemplater syntax.
183
+ * - DOC_TO_PDF_CONVERT_ERROR - Error while converting the document to PDF. Normally related with a ConvertAPI failure.
184
+ * - INTERNAL_ERROR - Internal error. Please contact support.
185
+ * - INVALID_TEMPLATE_FORMAT - Invalid template format (only .docx is supported). This can happen due to a bad word file or an unsupported file extension.
186
+ *
187
+ */
188
+ export type ErrorCode = "PARSE_ERROR" | "DOC_TO_PDF_CONVERT_ERROR" | "INTERNAL_ERROR" | "INVALID_TEMPLATE_FORMAT";
189
+ export interface ErrorOutput {
190
+ /**
191
+ * Error message
192
+ */
193
+ error_message?: string;
194
+ error_code?: /**
195
+ * Error codes for document generation:
196
+ * - PARSE_ERROR - Error while parsing the document. Normally related with a bad template using the wrong DocxTemplater syntax.
197
+ * - DOC_TO_PDF_CONVERT_ERROR - Error while converting the document to PDF. Normally related with a ConvertAPI failure.
198
+ * - INTERNAL_ERROR - Internal error. Please contact support.
199
+ * - INVALID_TEMPLATE_FORMAT - Invalid template format (only .docx is supported). This can happen due to a bad word file or an unsupported file extension.
200
+ *
201
+ */
202
+ ErrorCode;
203
+ error_details?: /* Error details for invalid custom variables. This error will appear under 'PARSE_ERROR' error code. */ InvalidCustomVariableErrorDetails | /* Error details for internal error. This error will appear under 'INTERNAL_ERROR' error code. */ InternalErrorDetails | /**
204
+ * Error details for DocxTemplater error. This error will appear under 'PARSE_ERROR' error code.
205
+ * See https://docxtemplater.com/docs/errors/#error-schema for more details.
206
+ *
207
+ */
208
+ DocxTemplaterErrorDetails;
209
+ }
210
+ /**
211
+ * Internal error detail
212
+ */
213
+ export interface InternalErrorDetail {
214
+ /**
215
+ * Name of the error
216
+ */
217
+ name?: string;
218
+ /**
219
+ * Error message
220
+ */
221
+ message?: string;
222
+ /**
223
+ * Stack trace
224
+ */
225
+ stack?: string;
226
+ /**
227
+ * Cause of the error
228
+ */
229
+ cause?: string;
230
+ }
231
+ /**
232
+ * Error details for internal error. This error will appear under 'INTERNAL_ERROR' error code.
233
+ */
234
+ export type InternalErrorDetails = {
235
+ items?: /* Internal error detail */ InternalErrorDetail;
236
+ }[];
237
+ export interface InvalidCustomVariableErrorDetail {
238
+ [name: string]: any;
239
+ /**
240
+ * Explanation for the error
241
+ */
242
+ explanation?: string;
243
+ /**
244
+ * Context for the error
245
+ */
246
+ context?: {
247
+ /**
248
+ * List of invalid variables
249
+ */
250
+ invalid_variables?: {
251
+ /**
252
+ * Variable name
253
+ */
254
+ variable?: string;
255
+ /**
256
+ * Explanation for the error
257
+ */
258
+ error?: string;
259
+ }[];
260
+ };
261
+ }
262
+ /**
263
+ * Error details for invalid custom variables. This error will appear under 'PARSE_ERROR' error code.
264
+ */
265
+ export type InvalidCustomVariableErrorDetails = InvalidCustomVariableErrorDetail[];
266
+ export interface S3Reference {
267
+ /**
268
+ * example:
269
+ * document-api-prod
270
+ */
271
+ bucket: string;
272
+ /**
273
+ * example:
274
+ * uploads/my-template.pdf
275
+ */
276
+ key: string;
277
+ }
278
+ /**
279
+ * Template Settings for document generation
280
+ */
281
+ export interface TemplateSettings {
282
+ /**
283
+ * Custom margins for the document
284
+ */
285
+ custom_margins?: {
286
+ /**
287
+ * Top margin in cm
288
+ * example:
289
+ * 2.54
290
+ */
291
+ top?: number;
292
+ /**
293
+ * Bottom margin in cm
294
+ * example:
295
+ * 2.54
296
+ */
297
+ bottom?: number;
298
+ };
299
+ /**
300
+ * Suggested margins for the document
301
+ */
302
+ suggested_margins?: {
303
+ /**
304
+ * Top margin in cm
305
+ * example:
306
+ * 2.54
307
+ */
308
+ top?: number;
309
+ /**
310
+ * Bottom margin in cm
311
+ * example:
312
+ * 2.54
313
+ */
314
+ bottom?: number;
315
+ };
316
+ /**
317
+ * Display margin guidelines (applicable to partial generation only)
318
+ * example:
319
+ * true
320
+ */
321
+ display_margin_guidelines?: boolean;
322
+ /**
323
+ * Enable data table margin autofix
324
+ * example:
325
+ * false
326
+ */
327
+ enable_data_table_margin_autofix?: boolean;
328
+ /**
329
+ * A flag that indicates whether the template has 1 or more data tables in it
330
+ * example:
331
+ * false
332
+ */
333
+ template_with_datatable?: boolean;
334
+ /**
335
+ * Enables the persistance of template settings
336
+ * example:
337
+ * false
338
+ */
339
+ enabled_template_settings_persistence?: boolean;
340
+ /**
341
+ * An indication that the page margins are misconfigured
342
+ * example:
343
+ * false
344
+ */
345
+ misconfigured_margins?: boolean;
346
+ /**
347
+ * The file entity id, used when persisting a new template version with updated settings
348
+ * example:
349
+ * 1a2b3c4d-5e6f-7g8h-9i0j-1k2l3m4n5o6p
350
+ */
351
+ file_entity_id?: string; // uuid
352
+ }
353
+ }
354
+ }
355
+ declare namespace Paths {
356
+ namespace ConvertDocument {
357
+ export type RequestBody = Components.Schemas.ConvertDocumentRequest;
358
+ namespace Responses {
359
+ export type $200 = Components.Schemas.ConvertDocumentResponse;
360
+ }
361
+ }
362
+ namespace GenerateDocumentV2 {
363
+ namespace Parameters {
364
+ export type JobId = string;
365
+ export type Mode = "partial_generation" | "full_generation";
366
+ }
367
+ export interface QueryParameters {
368
+ job_id?: Parameters.JobId;
369
+ mode?: Parameters.Mode;
370
+ }
371
+ export type RequestBody = Components.Schemas.DocumentGenerationV2Request;
372
+ namespace Responses {
373
+ export type $200 = Components.Schemas.DocumentGenerationV2Response;
374
+ }
375
+ }
376
+ }
377
+
378
+ export interface OperationMethods {
379
+ /**
380
+ * generateDocumentV2 - generateDocumentV2
381
+ *
382
+ * Builds document generated from input document with variables.
383
+ *
384
+ * Supported input document types:
385
+ * - .docx
386
+ *
387
+ * Supported output document types:
388
+ * - .pdf
389
+ * - .docx but limited to only text based variables
390
+ *
391
+ * Uses [Template Variables API](https://docs.epilot.io/api/template-variables) to replace variables in the document.
392
+ *
393
+ */
394
+ 'generateDocumentV2'(
395
+ parameters?: Parameters<Paths.GenerateDocumentV2.QueryParameters> | null,
396
+ data?: Paths.GenerateDocumentV2.RequestBody,
397
+ config?: AxiosRequestConfig
398
+ ): OperationResponse<Paths.GenerateDocumentV2.Responses.$200>
399
+ /**
400
+ * convertDocument - convertDocument
401
+ *
402
+ * Converts a document to a different format.
403
+ *
404
+ * Supported input document types:
405
+ * - .docx
406
+ *
407
+ * Supported output document types:
408
+ * - .pdf
409
+ *
410
+ */
411
+ 'convertDocument'(
412
+ parameters?: Parameters<UnknownParamsObject> | null,
413
+ data?: Paths.ConvertDocument.RequestBody,
414
+ config?: AxiosRequestConfig
415
+ ): OperationResponse<Paths.ConvertDocument.Responses.$200>
416
+ }
417
+
418
+ export interface PathsDictionary {
419
+ ['/v2/documents:generate']: {
420
+ /**
421
+ * generateDocumentV2 - generateDocumentV2
422
+ *
423
+ * Builds document generated from input document with variables.
424
+ *
425
+ * Supported input document types:
426
+ * - .docx
427
+ *
428
+ * Supported output document types:
429
+ * - .pdf
430
+ * - .docx but limited to only text based variables
431
+ *
432
+ * Uses [Template Variables API](https://docs.epilot.io/api/template-variables) to replace variables in the document.
433
+ *
434
+ */
435
+ 'post'(
436
+ parameters?: Parameters<Paths.GenerateDocumentV2.QueryParameters> | null,
437
+ data?: Paths.GenerateDocumentV2.RequestBody,
438
+ config?: AxiosRequestConfig
439
+ ): OperationResponse<Paths.GenerateDocumentV2.Responses.$200>
440
+ }
441
+ ['/v2/documents:convert']: {
442
+ /**
443
+ * convertDocument - convertDocument
444
+ *
445
+ * Converts a document to a different format.
446
+ *
447
+ * Supported input document types:
448
+ * - .docx
449
+ *
450
+ * Supported output document types:
451
+ * - .pdf
452
+ *
453
+ */
454
+ 'post'(
455
+ parameters?: Parameters<UnknownParamsObject> | null,
456
+ data?: Paths.ConvertDocument.RequestBody,
457
+ config?: AxiosRequestConfig
458
+ ): OperationResponse<Paths.ConvertDocument.Responses.$200>
459
+ }
460
+ }
461
+
462
+ export type Client = OpenAPIClient<OperationMethods, PathsDictionary>