@epilot/document-client 0.11.7 → 0.12.0

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},"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
+ /**
14
+ * Input document
15
+ */
16
+ input_document: {
17
+ s3ref: S3Reference;
18
+ };
13
19
  /**
14
- * Language to use for variables
20
+ * Output format of the document
15
21
  */
16
- language?: string;
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
  */
@@ -44,6 +69,12 @@ declare namespace Components {
44
69
  variable_payload?: {
45
70
  additionalProperties?: string;
46
71
  };
72
+ /**
73
+ * Custom values for variables in the template. Takes the higher precedence than others.
74
+ */
75
+ context_data?: {
76
+ additionalProperties?: string;
77
+ };
47
78
  template_settings?: /* Template Settings for document generation */ TemplateSettings;
48
79
  }
49
80
  export interface DocumentGenerationV2Response {
@@ -139,10 +170,7 @@ declare namespace Components {
139
170
  * See https://docxtemplater.com/docs/errors/#error-schema for more details.
140
171
  *
141
172
  */
142
- export type DocxTemplaterErrorDetails = [
143
- /* DocxTemplater error detail */ DocxTemplaterErrorDetail?,
144
- ...any[]
145
- ];
173
+ export type DocxTemplaterErrorDetails = /* DocxTemplater error detail */ DocxTemplaterErrorDetail[];
146
174
  /**
147
175
  * Error codes for document generation:
148
176
  * - PARSE_ERROR - Error while parsing the document. Normally related with a bad template using the wrong DocxTemplater syntax.
@@ -198,7 +226,7 @@ declare namespace Components {
198
226
  * Error details for internal error. This error will appear under 'INTERNAL_ERROR' error code.
199
227
  */
200
228
  export type InternalErrorDetails = {
201
- items?: any;
229
+ items?: /* Internal error detail */ InternalErrorDetail;
202
230
  }[];
203
231
  export interface InvalidCustomVariableErrorDetail {
204
232
  [name: string]: any;
@@ -228,10 +256,7 @@ declare namespace Components {
228
256
  /**
229
257
  * Error details for invalid custom variables. This error will appear under 'PARSE_ERROR' error code.
230
258
  */
231
- export type InvalidCustomVariableErrorDetails = [
232
- InvalidCustomVariableErrorDetail?,
233
- ...any[]
234
- ];
259
+ export type InvalidCustomVariableErrorDetails = InvalidCustomVariableErrorDetail[];
235
260
  export interface S3Reference {
236
261
  /**
237
262
  * example:
@@ -265,6 +290,23 @@ declare namespace Components {
265
290
  */
266
291
  bottom?: number;
267
292
  };
293
+ /**
294
+ * Suggested margins for the document
295
+ */
296
+ suggested_margins?: {
297
+ /**
298
+ * Top margin in cm
299
+ * example:
300
+ * 2.54
301
+ */
302
+ top?: number;
303
+ /**
304
+ * Bottom margin in cm
305
+ * example:
306
+ * 2.54
307
+ */
308
+ bottom?: number;
309
+ };
268
310
  /**
269
311
  * Display margin guidelines (applicable to partial generation only)
270
312
  * example:
@@ -305,66 +347,10 @@ declare namespace Components {
305
347
  }
306
348
  }
307
349
  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
- }
350
+ namespace ConvertDocument {
351
+ export type RequestBody = Components.Schemas.ConvertDocumentRequest;
341
352
  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
- }
353
+ export type $200 = Components.Schemas.ConvertDocumentResponse;
368
354
  }
369
355
  }
370
356
  namespace GenerateDocumentV2 {
@@ -385,7 +371,7 @@ declare namespace Paths {
385
371
 
386
372
  export interface OperationMethods {
387
373
  /**
388
- * generateDocument - generateDocument
374
+ * generateDocumentV2 - generateDocumentV2
389
375
  *
390
376
  * Builds document generated from input document with variables.
391
377
  *
@@ -394,41 +380,39 @@ export interface OperationMethods {
394
380
  *
395
381
  * Supported output document types:
396
382
  * - .pdf
383
+ * - .docx but limited to only text based variables
397
384
  *
398
385
  * Uses [Template Variables API](https://docs.epilot.io/api/template-variables) to replace variables in the document.
399
386
  *
400
387
  */
401
- 'generateDocument'(
402
- parameters?: Parameters<UnknownParamsObject> | null,
403
- data?: Paths.GenerateDocument.RequestBody,
388
+ 'generateDocumentV2'(
389
+ parameters?: Parameters<Paths.GenerateDocumentV2.QueryParameters> | null,
390
+ data?: Paths.GenerateDocumentV2.RequestBody,
404
391
  config?: AxiosRequestConfig
405
- ): OperationResponse<Paths.GenerateDocument.Responses.$200>
392
+ ): OperationResponse<Paths.GenerateDocumentV2.Responses.$200>
406
393
  /**
407
- * generateDocumentV2 - generateDocumentV2
394
+ * convertDocument - convertDocument
408
395
  *
409
- * Builds document generated from input document with variables.
396
+ * Converts a document to a different format.
410
397
  *
411
398
  * Supported input document types:
412
399
  * - .docx
413
400
  *
414
401
  * Supported output document types:
415
402
  * - .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
403
  *
420
404
  */
421
- 'generateDocumentV2'(
422
- parameters?: Parameters<Paths.GenerateDocumentV2.QueryParameters> | null,
423
- data?: Paths.GenerateDocumentV2.RequestBody,
405
+ 'convertDocument'(
406
+ parameters?: Parameters<UnknownParamsObject> | null,
407
+ data?: Paths.ConvertDocument.RequestBody,
424
408
  config?: AxiosRequestConfig
425
- ): OperationResponse<Paths.GenerateDocumentV2.Responses.$200>
409
+ ): OperationResponse<Paths.ConvertDocument.Responses.$200>
426
410
  }
427
411
 
428
412
  export interface PathsDictionary {
429
- ['/v1/documents:generate']: {
413
+ ['/v2/documents:generate']: {
430
414
  /**
431
- * generateDocument - generateDocument
415
+ * generateDocumentV2 - generateDocumentV2
432
416
  *
433
417
  * Builds document generated from input document with variables.
434
418
  *
@@ -437,37 +421,35 @@ export interface PathsDictionary {
437
421
  *
438
422
  * Supported output document types:
439
423
  * - .pdf
424
+ * - .docx but limited to only text based variables
440
425
  *
441
426
  * Uses [Template Variables API](https://docs.epilot.io/api/template-variables) to replace variables in the document.
442
427
  *
443
428
  */
444
429
  'post'(
445
- parameters?: Parameters<UnknownParamsObject> | null,
446
- data?: Paths.GenerateDocument.RequestBody,
430
+ parameters?: Parameters<Paths.GenerateDocumentV2.QueryParameters> | null,
431
+ data?: Paths.GenerateDocumentV2.RequestBody,
447
432
  config?: AxiosRequestConfig
448
- ): OperationResponse<Paths.GenerateDocument.Responses.$200>
433
+ ): OperationResponse<Paths.GenerateDocumentV2.Responses.$200>
449
434
  }
450
- ['/v2/documents:generate']: {
435
+ ['/v2/documents:convert']: {
451
436
  /**
452
- * generateDocumentV2 - generateDocumentV2
437
+ * convertDocument - convertDocument
453
438
  *
454
- * Builds document generated from input document with variables.
439
+ * Converts a document to a different format.
455
440
  *
456
441
  * Supported input document types:
457
442
  * - .docx
458
443
  *
459
444
  * Supported output document types:
460
445
  * - .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
446
  *
465
447
  */
466
448
  'post'(
467
- parameters?: Parameters<Paths.GenerateDocumentV2.QueryParameters> | null,
468
- data?: Paths.GenerateDocumentV2.RequestBody,
449
+ parameters?: Parameters<UnknownParamsObject> | null,
450
+ data?: Paths.ConvertDocument.RequestBody,
469
451
  config?: AxiosRequestConfig
470
- ): OperationResponse<Paths.GenerateDocumentV2.Responses.$200>
452
+ ): OperationResponse<Paths.ConvertDocument.Responses.$200>
471
453
  }
472
454
  }
473
455
 
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.0",
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,456 @@
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
+ * Custom values for variables in the template. Takes the higher precedence than others.
68
+ */
69
+ variable_payload?: {
70
+ additionalProperties?: string;
71
+ };
72
+ /**
73
+ * Custom values for variables in the template. Takes the higher precedence than others.
74
+ */
75
+ context_data?: {
76
+ additionalProperties?: string;
77
+ };
78
+ template_settings?: /* Template Settings for document generation */ TemplateSettings;
79
+ }
80
+ export interface DocumentGenerationV2Response {
81
+ job_id?: string; // uuid
82
+ /**
83
+ * Status of the job
84
+ */
85
+ job_status?: "STARTED" | "PROCESSING" | "SUCCESS" | "FAILED";
86
+ /**
87
+ * A message explaining the progress
88
+ */
89
+ message?: string;
90
+ pdf_output?: {
91
+ /**
92
+ * Pre-signed S3 GET URL for PDF preview
93
+ * example:
94
+ * https://document-api-prod.s3.eu-central-1.amazonaws.com/preview/my-template-OR-001.pdf
95
+ */
96
+ preview_url?: string;
97
+ /**
98
+ * example:
99
+ * {
100
+ * "s3ref": {
101
+ * "bucket": "document-api-preview-prod",
102
+ * "key": "preview/my-template.pdf"
103
+ * }
104
+ * }
105
+ */
106
+ output_document?: {
107
+ /**
108
+ * Generated document filename for PDF
109
+ * example:
110
+ * my-template-OR-001.pdf
111
+ */
112
+ filename?: string;
113
+ s3ref?: S3Reference;
114
+ };
115
+ };
116
+ docx_output?: {
117
+ /**
118
+ * Pre-signed S3 GET URL for DOCX preview
119
+ * example:
120
+ * https://document-api-prod.s3.eu-central-1.amazonaws.com/preview/my-template-OR-001.docx
121
+ */
122
+ preview_url?: string;
123
+ /**
124
+ * example:
125
+ * {
126
+ * "s3ref": {
127
+ * "bucket": "document-api-preview-prod",
128
+ * "key": "preview/my-template.docx"
129
+ * }
130
+ * }
131
+ */
132
+ output_document?: {
133
+ /**
134
+ * Generated document filename for DOCX
135
+ * example:
136
+ * my-template-OR-001.docx
137
+ */
138
+ filename?: string;
139
+ s3ref?: S3Reference;
140
+ };
141
+ };
142
+ error_output?: ErrorOutput;
143
+ /**
144
+ * List of variables and its corresponding replaced values from the document template
145
+ */
146
+ variable_payload?: {
147
+ additionalProperties?: string;
148
+ };
149
+ template_settings?: /* Template Settings for document generation */ TemplateSettings;
150
+ }
151
+ /**
152
+ * DocxTemplater error detail
153
+ */
154
+ export interface DocxTemplaterErrorDetail {
155
+ /**
156
+ * Id of the error
157
+ */
158
+ id?: string;
159
+ /**
160
+ * Context of the error
161
+ */
162
+ context?: string;
163
+ /**
164
+ * Explanation of the error
165
+ */
166
+ explanation?: string;
167
+ }
168
+ /**
169
+ * Error details for DocxTemplater error. This error will appear under 'PARSE_ERROR' error code.
170
+ * See https://docxtemplater.com/docs/errors/#error-schema for more details.
171
+ *
172
+ */
173
+ export type DocxTemplaterErrorDetails = /* DocxTemplater error detail */ DocxTemplaterErrorDetail[];
174
+ /**
175
+ * Error codes for document generation:
176
+ * - PARSE_ERROR - Error while parsing the document. Normally related with a bad template using the wrong DocxTemplater syntax.
177
+ * - DOC_TO_PDF_CONVERT_ERROR - Error while converting the document to PDF. Normally related with a ConvertAPI failure.
178
+ * - INTERNAL_ERROR - Internal error. Please contact support.
179
+ * - INVALID_TEMPLATE_FORMAT - Invalid template format (only .docx is supported). This can happen due to a bad word file or an unsupported file extension.
180
+ *
181
+ */
182
+ export type ErrorCode = "PARSE_ERROR" | "DOC_TO_PDF_CONVERT_ERROR" | "INTERNAL_ERROR" | "INVALID_TEMPLATE_FORMAT";
183
+ export interface ErrorOutput {
184
+ /**
185
+ * Error message
186
+ */
187
+ error_message?: string;
188
+ error_code?: /**
189
+ * Error codes for document generation:
190
+ * - PARSE_ERROR - Error while parsing the document. Normally related with a bad template using the wrong DocxTemplater syntax.
191
+ * - DOC_TO_PDF_CONVERT_ERROR - Error while converting the document to PDF. Normally related with a ConvertAPI failure.
192
+ * - INTERNAL_ERROR - Internal error. Please contact support.
193
+ * - INVALID_TEMPLATE_FORMAT - Invalid template format (only .docx is supported). This can happen due to a bad word file or an unsupported file extension.
194
+ *
195
+ */
196
+ ErrorCode;
197
+ 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 | /**
198
+ * Error details for DocxTemplater error. This error will appear under 'PARSE_ERROR' error code.
199
+ * See https://docxtemplater.com/docs/errors/#error-schema for more details.
200
+ *
201
+ */
202
+ DocxTemplaterErrorDetails;
203
+ }
204
+ /**
205
+ * Internal error detail
206
+ */
207
+ export interface InternalErrorDetail {
208
+ /**
209
+ * Name of the error
210
+ */
211
+ name?: string;
212
+ /**
213
+ * Error message
214
+ */
215
+ message?: string;
216
+ /**
217
+ * Stack trace
218
+ */
219
+ stack?: string;
220
+ /**
221
+ * Cause of the error
222
+ */
223
+ cause?: string;
224
+ }
225
+ /**
226
+ * Error details for internal error. This error will appear under 'INTERNAL_ERROR' error code.
227
+ */
228
+ export type InternalErrorDetails = {
229
+ items?: /* Internal error detail */ InternalErrorDetail;
230
+ }[];
231
+ export interface InvalidCustomVariableErrorDetail {
232
+ [name: string]: any;
233
+ /**
234
+ * Explanation for the error
235
+ */
236
+ explanation?: string;
237
+ /**
238
+ * Context for the error
239
+ */
240
+ context?: {
241
+ /**
242
+ * List of invalid variables
243
+ */
244
+ invalid_variables?: {
245
+ /**
246
+ * Variable name
247
+ */
248
+ variable?: string;
249
+ /**
250
+ * Explanation for the error
251
+ */
252
+ error?: string;
253
+ }[];
254
+ };
255
+ }
256
+ /**
257
+ * Error details for invalid custom variables. This error will appear under 'PARSE_ERROR' error code.
258
+ */
259
+ export type InvalidCustomVariableErrorDetails = InvalidCustomVariableErrorDetail[];
260
+ export interface S3Reference {
261
+ /**
262
+ * example:
263
+ * document-api-prod
264
+ */
265
+ bucket: string;
266
+ /**
267
+ * example:
268
+ * uploads/my-template.pdf
269
+ */
270
+ key: string;
271
+ }
272
+ /**
273
+ * Template Settings for document generation
274
+ */
275
+ export interface TemplateSettings {
276
+ /**
277
+ * Custom margins for the document
278
+ */
279
+ custom_margins?: {
280
+ /**
281
+ * Top margin in cm
282
+ * example:
283
+ * 2.54
284
+ */
285
+ top?: number;
286
+ /**
287
+ * Bottom margin in cm
288
+ * example:
289
+ * 2.54
290
+ */
291
+ bottom?: number;
292
+ };
293
+ /**
294
+ * Suggested margins for the document
295
+ */
296
+ suggested_margins?: {
297
+ /**
298
+ * Top margin in cm
299
+ * example:
300
+ * 2.54
301
+ */
302
+ top?: number;
303
+ /**
304
+ * Bottom margin in cm
305
+ * example:
306
+ * 2.54
307
+ */
308
+ bottom?: number;
309
+ };
310
+ /**
311
+ * Display margin guidelines (applicable to partial generation only)
312
+ * example:
313
+ * true
314
+ */
315
+ display_margin_guidelines?: boolean;
316
+ /**
317
+ * Enable data table margin autofix
318
+ * example:
319
+ * false
320
+ */
321
+ enable_data_table_margin_autofix?: boolean;
322
+ /**
323
+ * A flag that indicates whether the template has 1 or more data tables in it
324
+ * example:
325
+ * false
326
+ */
327
+ template_with_datatable?: boolean;
328
+ /**
329
+ * Enables the persistance of template settings
330
+ * example:
331
+ * false
332
+ */
333
+ enabled_template_settings_persistence?: boolean;
334
+ /**
335
+ * An indication that the page margins are misconfigured
336
+ * example:
337
+ * false
338
+ */
339
+ misconfigured_margins?: boolean;
340
+ /**
341
+ * The file entity id, used when persisting a new template version with updated settings
342
+ * example:
343
+ * 1a2b3c4d-5e6f-7g8h-9i0j-1k2l3m4n5o6p
344
+ */
345
+ file_entity_id?: string; // uuid
346
+ }
347
+ }
348
+ }
349
+ declare namespace Paths {
350
+ namespace ConvertDocument {
351
+ export type RequestBody = Components.Schemas.ConvertDocumentRequest;
352
+ namespace Responses {
353
+ export type $200 = Components.Schemas.ConvertDocumentResponse;
354
+ }
355
+ }
356
+ namespace GenerateDocumentV2 {
357
+ namespace Parameters {
358
+ export type JobId = string;
359
+ export type Mode = "partial_generation" | "full_generation";
360
+ }
361
+ export interface QueryParameters {
362
+ job_id?: Parameters.JobId;
363
+ mode?: Parameters.Mode;
364
+ }
365
+ export type RequestBody = Components.Schemas.DocumentGenerationV2Request;
366
+ namespace Responses {
367
+ export type $200 = Components.Schemas.DocumentGenerationV2Response;
368
+ }
369
+ }
370
+ }
371
+
372
+ export interface OperationMethods {
373
+ /**
374
+ * generateDocumentV2 - generateDocumentV2
375
+ *
376
+ * Builds document generated from input document with variables.
377
+ *
378
+ * Supported input document types:
379
+ * - .docx
380
+ *
381
+ * Supported output document types:
382
+ * - .pdf
383
+ * - .docx but limited to only text based variables
384
+ *
385
+ * Uses [Template Variables API](https://docs.epilot.io/api/template-variables) to replace variables in the document.
386
+ *
387
+ */
388
+ 'generateDocumentV2'(
389
+ parameters?: Parameters<Paths.GenerateDocumentV2.QueryParameters> | null,
390
+ data?: Paths.GenerateDocumentV2.RequestBody,
391
+ config?: AxiosRequestConfig
392
+ ): OperationResponse<Paths.GenerateDocumentV2.Responses.$200>
393
+ /**
394
+ * convertDocument - convertDocument
395
+ *
396
+ * Converts a document to a different format.
397
+ *
398
+ * Supported input document types:
399
+ * - .docx
400
+ *
401
+ * Supported output document types:
402
+ * - .pdf
403
+ *
404
+ */
405
+ 'convertDocument'(
406
+ parameters?: Parameters<UnknownParamsObject> | null,
407
+ data?: Paths.ConvertDocument.RequestBody,
408
+ config?: AxiosRequestConfig
409
+ ): OperationResponse<Paths.ConvertDocument.Responses.$200>
410
+ }
411
+
412
+ export interface PathsDictionary {
413
+ ['/v2/documents:generate']: {
414
+ /**
415
+ * generateDocumentV2 - generateDocumentV2
416
+ *
417
+ * Builds document generated from input document with variables.
418
+ *
419
+ * Supported input document types:
420
+ * - .docx
421
+ *
422
+ * Supported output document types:
423
+ * - .pdf
424
+ * - .docx but limited to only text based variables
425
+ *
426
+ * Uses [Template Variables API](https://docs.epilot.io/api/template-variables) to replace variables in the document.
427
+ *
428
+ */
429
+ 'post'(
430
+ parameters?: Parameters<Paths.GenerateDocumentV2.QueryParameters> | null,
431
+ data?: Paths.GenerateDocumentV2.RequestBody,
432
+ config?: AxiosRequestConfig
433
+ ): OperationResponse<Paths.GenerateDocumentV2.Responses.$200>
434
+ }
435
+ ['/v2/documents:convert']: {
436
+ /**
437
+ * convertDocument - convertDocument
438
+ *
439
+ * Converts a document to a different format.
440
+ *
441
+ * Supported input document types:
442
+ * - .docx
443
+ *
444
+ * Supported output document types:
445
+ * - .pdf
446
+ *
447
+ */
448
+ 'post'(
449
+ parameters?: Parameters<UnknownParamsObject> | null,
450
+ data?: Paths.ConvertDocument.RequestBody,
451
+ config?: AxiosRequestConfig
452
+ ): OperationResponse<Paths.ConvertDocument.Responses.$200>
453
+ }
454
+ }
455
+
456
+ export type Client = OpenAPIClient<OperationMethods, PathsDictionary>