@epilot/document-client 0.19.1 → 0.20.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.
- package/LICENSE +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/definition.js +1 -1
- package/dist/openapi.d.ts +271 -9
- package/package.json +17 -20
- package/src/openapi.d.ts +0 -649
package/LICENSE
CHANGED
package/dist/client.d.ts
CHANGED
package/dist/definition.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{"use strict";var e={757: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(871));t.default=n.default},871: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:meta":{"post":{"operationId":"getTemplateMeta","summary":"getTemplateMeta","description":"Get metadata for a document template\\n\\nSupported input document types:\\n- .docx\\n","tags":["Documents"],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DocumentMetaRequest"}}}},"responses":{"200":{"description":"Document metadata","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DocumentMetaResponse"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOutput"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOutput"}}}},"415":{"description":"Unsupported media type","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorOutput"}}}}}}},"/v2/documents:generate":{"post":{"operationId":"generateDocumentV2","summary":"generateDocumentV2","description":"Generates documents from templates with variables.\\n\\nSupported document types as input:\\n- .docx\\n- .ics\\n\\nSupported document types as output:\\n- .pdf\\n- .docx but limited to only text based variables\\n- .ics\\n\\nUses [Template Variable API](https://docs.epilot.io/api/template-variables) to replace variables in the input 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"}},{"in":"query","name":"preview_mode","description":"Type of mode used for document generation preview:\\n- open - preview_url provides a link to open the file in a browser\\n- download - preview_url provides a link to download the file\\n","schema":{"type":"string","enum":["open","download"],"default":"open"}}],"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"}}},"DocumentMetaRequest":{"type":"object","properties":{"template_document":{"description":"Input template document","type":"object","properties":{"s3ref":{"$ref":"#/components/schemas/S3Reference"}}}}},"DocumentMetaResponse":{"type":"object","properties":{"page_margins":{"description":"Page 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},"left":{"description":"Left margin in cm","type":"number","example":2.54},"right":{"description":"Right margin in cm","type":"number","example":2.54},"header":{"description":"Header margin in cm","type":"number","example":2.54},"footer":{"description":"Footer margin in cm","type":"number","example":2.54}}},"variables":{"description":"List of variables in the document","type":"array","items":{"type":"string"},"example":["order.billing_contact.0.salutation","order.billing_contact.0.title","order_table","stayHardStatic","opportunity[attribute_name]","opportunity[\\"attribute_name\\"]","opportunity.[attribute_name]","attribute_name","opportunities.0.attribute_name","opportunities[0].attribute_name","contact.opportunities[0].attribute_name","opportunities[Primary].attribute_name"]}}},"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"},"ics_output":{"type":"object","properties":{"output_document":{"type":"object","properties":{"filename":{"description":"Generated document filename for ICS","type":"string","example":"my-appointment-OR-001.ics"},"s3ref":{"$ref":"#/components/schemas/S3Reference"}},"example":{"s3ref":{"bucket":"document-api-preview-prod","key":"preview/my-appointment.ics"}}}}},"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"}]}')}},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}(757),o=exports;for(var n in r)o[n]=r[n];r.__esModule&&Object.defineProperty(o,"__esModule",{value:!0})})();
|
|
1
|
+
(()=>{"use strict";var e={438(e,t,o){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var n=r(o(466));t.default=n.default},466(e){e.exports=JSON.parse('{"openapi":"3.0.2","info":{"title":"","version":""},"paths":{"/v2/documents:meta":{"post":{"operationId":"getTemplateMeta","requestBody":{"required":true,"content":{"application/json":{}}},"responses":{}}},"/v2/documents:generate":{"post":{"operationId":"generateDocumentV2","parameters":[{"in":"query","name":"job_id"},{"in":"query","name":"mode"},{"in":"query","name":"preview_mode"}],"requestBody":{"required":true,"content":{"application/json":{}}},"responses":{}}},"/v2/documents:convert":{"post":{"operationId":"convertDocument","requestBody":{"required":true,"content":{"application/json":{}}},"responses":{}}},"/v2/templates:validate":{"post":{"operationId":"validateTemplate","requestBody":{"required":true,"content":{"application/json":{}}},"responses":{}}}},"components":{},"servers":[{"url":"https://document.sls.epilot.io"}]}')}},t={},o=function o(r){var n=t[r];if(void 0!==n)return n.exports;var s=t[r]={exports:{}};return e[r].call(s.exports,s,s.exports,o),s.exports}(438),r=exports;for(var n in o)r[n]=o[n];o.__esModule&&Object.defineProperty(r,"__esModule",{value:!0})})();
|
package/dist/openapi.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
|
|
3
1
|
import type {
|
|
4
2
|
OpenAPIClient,
|
|
5
3
|
Parameters,
|
|
@@ -11,6 +9,12 @@ import type {
|
|
|
11
9
|
declare namespace Components {
|
|
12
10
|
namespace Schemas {
|
|
13
11
|
export interface ConvertDocumentRequest {
|
|
12
|
+
/**
|
|
13
|
+
* Language
|
|
14
|
+
* example:
|
|
15
|
+
* de
|
|
16
|
+
*/
|
|
17
|
+
language?: string;
|
|
14
18
|
/**
|
|
15
19
|
* Input document
|
|
16
20
|
*/
|
|
@@ -67,7 +71,7 @@ declare namespace Components {
|
|
|
67
71
|
/**
|
|
68
72
|
* Language
|
|
69
73
|
* example:
|
|
70
|
-
*
|
|
74
|
+
* de
|
|
71
75
|
*/
|
|
72
76
|
language?: string;
|
|
73
77
|
/**
|
|
@@ -166,6 +170,32 @@ declare namespace Components {
|
|
|
166
170
|
s3ref?: S3Reference;
|
|
167
171
|
};
|
|
168
172
|
};
|
|
173
|
+
xlsx_output?: {
|
|
174
|
+
/**
|
|
175
|
+
* Pre-signed S3 GET URL for XLSX preview
|
|
176
|
+
* example:
|
|
177
|
+
* https://document-api-prod.s3.eu-central-1.amazonaws.com/preview/my-template-OR-001.xlsx
|
|
178
|
+
*/
|
|
179
|
+
preview_url?: string;
|
|
180
|
+
/**
|
|
181
|
+
* example:
|
|
182
|
+
* {
|
|
183
|
+
* "s3ref": {
|
|
184
|
+
* "bucket": "document-api-preview-prod",
|
|
185
|
+
* "key": "preview/my-template.xlsx"
|
|
186
|
+
* }
|
|
187
|
+
* }
|
|
188
|
+
*/
|
|
189
|
+
output_document?: {
|
|
190
|
+
/**
|
|
191
|
+
* Generated document filename for XLSX
|
|
192
|
+
* example:
|
|
193
|
+
* my-template-OR-001.xlsx
|
|
194
|
+
*/
|
|
195
|
+
filename?: string;
|
|
196
|
+
s3ref?: S3Reference;
|
|
197
|
+
};
|
|
198
|
+
};
|
|
169
199
|
error_output?: ErrorOutput;
|
|
170
200
|
/**
|
|
171
201
|
* List of variables and its corresponding replaced values from the document template
|
|
@@ -274,9 +304,10 @@ declare namespace Components {
|
|
|
274
304
|
* - DOC_TO_PDF_CONVERT_ERROR - Error while converting the document to PDF. Normally related with a ConvertAPI failure.
|
|
275
305
|
* - INTERNAL_ERROR - Internal error. Please contact support.
|
|
276
306
|
* - INVALID_TEMPLATE_FORMAT - Invalid template format (only .docx is supported). This can happen due to a bad word file or an unsupported file extension.
|
|
307
|
+
* - TEMPLATE_NOT_FOUND - Template file was not found in S3. This indicates the template was likely deleted.
|
|
277
308
|
*
|
|
278
309
|
*/
|
|
279
|
-
export type ErrorCode = "PARSE_ERROR" | "DOC_TO_PDF_CONVERT_ERROR" | "INTERNAL_ERROR" | "INVALID_TEMPLATE_FORMAT";
|
|
310
|
+
export type ErrorCode = "PARSE_ERROR" | "DOC_TO_PDF_CONVERT_ERROR" | "INTERNAL_ERROR" | "INVALID_TEMPLATE_FORMAT" | "TEMPLATE_NOT_FOUND";
|
|
280
311
|
export interface ErrorOutput {
|
|
281
312
|
/**
|
|
282
313
|
* Error message
|
|
@@ -288,6 +319,7 @@ declare namespace Components {
|
|
|
288
319
|
* - DOC_TO_PDF_CONVERT_ERROR - Error while converting the document to PDF. Normally related with a ConvertAPI failure.
|
|
289
320
|
* - INTERNAL_ERROR - Internal error. Please contact support.
|
|
290
321
|
* - INVALID_TEMPLATE_FORMAT - Invalid template format (only .docx is supported). This can happen due to a bad word file or an unsupported file extension.
|
|
322
|
+
* - TEMPLATE_NOT_FOUND - Template file was not found in S3. This indicates the template was likely deleted.
|
|
291
323
|
*
|
|
292
324
|
*/
|
|
293
325
|
ErrorCode;
|
|
@@ -366,6 +398,75 @@ declare namespace Components {
|
|
|
366
398
|
*/
|
|
367
399
|
key: string;
|
|
368
400
|
}
|
|
401
|
+
/**
|
|
402
|
+
* A single template syntax problem, and the repair proposed for it
|
|
403
|
+
*/
|
|
404
|
+
export interface TemplateIssue {
|
|
405
|
+
/**
|
|
406
|
+
* Problem kind. Reuses docxtemplater's error vocabulary where one exists
|
|
407
|
+
* (`unopened_tag`, `unclosed_tag`, `duplicate_open_tag`, `duplicate_close_tag`), plus
|
|
408
|
+
* `malformed_tag` for single-brace placeholders and `typographic_characters` for
|
|
409
|
+
* editor-substituted characters inside an otherwise valid tag.
|
|
410
|
+
*
|
|
411
|
+
* example:
|
|
412
|
+
* unopened_tag
|
|
413
|
+
*/
|
|
414
|
+
id?: string;
|
|
415
|
+
/**
|
|
416
|
+
* Zip part the problem was found in
|
|
417
|
+
* example:
|
|
418
|
+
* xl/sharedStrings.xml
|
|
419
|
+
*/
|
|
420
|
+
file?: string;
|
|
421
|
+
/**
|
|
422
|
+
* Where the user can find it — a cell reference for spreadsheets, a part label
|
|
423
|
+
* (`Document body`, `Header 1`, `Slide 3`) otherwise.
|
|
424
|
+
*
|
|
425
|
+
* example:
|
|
426
|
+
* Tabelle1!N4
|
|
427
|
+
*/
|
|
428
|
+
location?: string;
|
|
429
|
+
/**
|
|
430
|
+
* The offending text with surrounding context
|
|
431
|
+
* example:
|
|
432
|
+
* …Datum: {system.date}} Unterschrift…
|
|
433
|
+
*/
|
|
434
|
+
context?: string;
|
|
435
|
+
/**
|
|
436
|
+
* Why the template parser rejects it
|
|
437
|
+
* example:
|
|
438
|
+
* The tag is missing an opening brace.
|
|
439
|
+
*/
|
|
440
|
+
explanation?: string;
|
|
441
|
+
/**
|
|
442
|
+
* Whether the proposed repair was applied to the fixed copy
|
|
443
|
+
* example:
|
|
444
|
+
* true
|
|
445
|
+
*/
|
|
446
|
+
fixable?: boolean;
|
|
447
|
+
/**
|
|
448
|
+
* How sure we are that the repair is what the author meant
|
|
449
|
+
*/
|
|
450
|
+
confidence?: "high" | "medium" | "low";
|
|
451
|
+
/**
|
|
452
|
+
* The repair rule that produced `after`
|
|
453
|
+
* example:
|
|
454
|
+
* balance_opening_delimiter
|
|
455
|
+
*/
|
|
456
|
+
rule?: string;
|
|
457
|
+
/**
|
|
458
|
+
* The text as it is in the template
|
|
459
|
+
* example:
|
|
460
|
+
* {system.date}}
|
|
461
|
+
*/
|
|
462
|
+
before?: string;
|
|
463
|
+
/**
|
|
464
|
+
* The text as it would be in the fixed copy
|
|
465
|
+
* example:
|
|
466
|
+
* {{system.date}}
|
|
467
|
+
*/
|
|
468
|
+
after?: string;
|
|
469
|
+
}
|
|
369
470
|
/**
|
|
370
471
|
* Template Settings for document generation
|
|
371
472
|
*/
|
|
@@ -437,10 +538,81 @@ declare namespace Components {
|
|
|
437
538
|
/**
|
|
438
539
|
* The file entity id, used when persisting a new template version with updated settings
|
|
439
540
|
* example:
|
|
440
|
-
*
|
|
541
|
+
* 123e4567-e89b-12d3-a456-426614174000
|
|
441
542
|
*/
|
|
442
543
|
file_entity_id?: string; // uuid
|
|
443
544
|
}
|
|
545
|
+
export interface TemplateValidationRequest {
|
|
546
|
+
/**
|
|
547
|
+
* Input template document
|
|
548
|
+
*/
|
|
549
|
+
template_document: {
|
|
550
|
+
/**
|
|
551
|
+
* Document original filename, used to name the fixed copy
|
|
552
|
+
* example:
|
|
553
|
+
* Umzugsmeldung.xlsx
|
|
554
|
+
*/
|
|
555
|
+
filename?: string;
|
|
556
|
+
s3ref: S3Reference;
|
|
557
|
+
};
|
|
558
|
+
/**
|
|
559
|
+
* Attempt to produce a hotfixed copy of the template. When false, the template is only
|
|
560
|
+
* inspected and no file is written.
|
|
561
|
+
*
|
|
562
|
+
*/
|
|
563
|
+
fix?: boolean;
|
|
564
|
+
/**
|
|
565
|
+
* How far the hotfix may go:
|
|
566
|
+
* - safe - only repairs where the author's intent is unambiguous from the syntax
|
|
567
|
+
* (unbalanced or duplicated braces, editor-substituted characters inside a tag).
|
|
568
|
+
* - aggressive - additionally promotes single-brace placeholders such as `{contact.name}`
|
|
569
|
+
* to `{{contact.name}}`. These are common in customer templates but indistinguishable
|
|
570
|
+
* from prose that uses braces, so they are reported with `confidence: low`.
|
|
571
|
+
*
|
|
572
|
+
*/
|
|
573
|
+
fix_level?: "safe" | "aggressive";
|
|
574
|
+
}
|
|
575
|
+
export interface TemplateValidationResponse {
|
|
576
|
+
/**
|
|
577
|
+
* Whether the template compiled cleanly before any repair was attempted
|
|
578
|
+
* example:
|
|
579
|
+
* false
|
|
580
|
+
*/
|
|
581
|
+
valid?: boolean;
|
|
582
|
+
/**
|
|
583
|
+
* Whether a corrected copy of the template could be produced
|
|
584
|
+
* example:
|
|
585
|
+
* true
|
|
586
|
+
*/
|
|
587
|
+
fixed?: boolean;
|
|
588
|
+
/**
|
|
589
|
+
* Everything found in the template, whether or not it could be repaired
|
|
590
|
+
*/
|
|
591
|
+
issues?: /* A single template syntax problem, and the repair proposed for it */ TemplateIssue[];
|
|
592
|
+
/**
|
|
593
|
+
* Parser errors that remain after the hotfix (or the original errors when nothing was
|
|
594
|
+
* fixed). Empty when the template is valid.
|
|
595
|
+
*
|
|
596
|
+
*/
|
|
597
|
+
unresolved_errors?: /* DocxTemplater error detail */ DocxTemplaterErrorDetail[];
|
|
598
|
+
/**
|
|
599
|
+
* The corrected copy, for the user to review and accept. Absent when no repair was
|
|
600
|
+
* applied. The original template is left untouched.
|
|
601
|
+
*
|
|
602
|
+
*/
|
|
603
|
+
fixed_document?: {
|
|
604
|
+
s3ref?: S3Reference;
|
|
605
|
+
/**
|
|
606
|
+
* example:
|
|
607
|
+
* Umzugsmeldung (fixed).xlsx
|
|
608
|
+
*/
|
|
609
|
+
filename?: string;
|
|
610
|
+
/**
|
|
611
|
+
* Short-lived download link for the corrected copy
|
|
612
|
+
*/
|
|
613
|
+
preview_url?: string; // uri
|
|
614
|
+
};
|
|
615
|
+
}
|
|
444
616
|
}
|
|
445
617
|
}
|
|
446
618
|
declare namespace Paths {
|
|
@@ -453,13 +625,33 @@ declare namespace Paths {
|
|
|
453
625
|
namespace GenerateDocumentV2 {
|
|
454
626
|
namespace Parameters {
|
|
455
627
|
export type JobId = string;
|
|
628
|
+
/**
|
|
629
|
+
* - partial_generation: Generates a partial document for user validation before final generation
|
|
630
|
+
* - full_generation: Completes the entire document generation process in one step
|
|
631
|
+
*
|
|
632
|
+
*/
|
|
456
633
|
export type Mode = "partial_generation" | "full_generation";
|
|
634
|
+
/**
|
|
635
|
+
* - open: Preview URL opens the file directly in browser
|
|
636
|
+
* - download: Preview URL triggers a download of the file
|
|
637
|
+
*
|
|
638
|
+
*/
|
|
457
639
|
export type PreviewMode = "open" | "download";
|
|
458
640
|
}
|
|
459
641
|
export interface QueryParameters {
|
|
460
642
|
job_id?: Parameters.JobId;
|
|
461
|
-
mode?:
|
|
462
|
-
|
|
643
|
+
mode?: /**
|
|
644
|
+
* - partial_generation: Generates a partial document for user validation before final generation
|
|
645
|
+
* - full_generation: Completes the entire document generation process in one step
|
|
646
|
+
*
|
|
647
|
+
*/
|
|
648
|
+
Parameters.Mode;
|
|
649
|
+
preview_mode?: /**
|
|
650
|
+
* - open: Preview URL opens the file directly in browser
|
|
651
|
+
* - download: Preview URL triggers a download of the file
|
|
652
|
+
*
|
|
653
|
+
*/
|
|
654
|
+
Parameters.PreviewMode;
|
|
463
655
|
}
|
|
464
656
|
export type RequestBody = Components.Schemas.DocumentGenerationV2Request;
|
|
465
657
|
namespace Responses {
|
|
@@ -475,8 +667,18 @@ declare namespace Paths {
|
|
|
475
667
|
export type $415 = Components.Schemas.ErrorOutput;
|
|
476
668
|
}
|
|
477
669
|
}
|
|
670
|
+
namespace ValidateTemplate {
|
|
671
|
+
export type RequestBody = Components.Schemas.TemplateValidationRequest;
|
|
672
|
+
namespace Responses {
|
|
673
|
+
export type $200 = Components.Schemas.TemplateValidationResponse;
|
|
674
|
+
export type $403 = Components.Schemas.ErrorOutput;
|
|
675
|
+
export type $413 = Components.Schemas.ErrorOutput;
|
|
676
|
+
export type $415 = Components.Schemas.ErrorOutput;
|
|
677
|
+
}
|
|
678
|
+
}
|
|
478
679
|
}
|
|
479
680
|
|
|
681
|
+
|
|
480
682
|
export interface OperationMethods {
|
|
481
683
|
/**
|
|
482
684
|
* getTemplateMeta - getTemplateMeta
|
|
@@ -506,7 +708,7 @@ export interface OperationMethods {
|
|
|
506
708
|
* - .docx but limited to only text based variables
|
|
507
709
|
* - .ics
|
|
508
710
|
*
|
|
509
|
-
* Uses [Template
|
|
711
|
+
* Uses [Template Variables API](https://docs.epilot.io/api/template-variables) to replace variables in the input document.
|
|
510
712
|
*
|
|
511
713
|
*/
|
|
512
714
|
'generateDocumentV2'(
|
|
@@ -531,6 +733,33 @@ export interface OperationMethods {
|
|
|
531
733
|
data?: Paths.ConvertDocument.RequestBody,
|
|
532
734
|
config?: AxiosRequestConfig
|
|
533
735
|
): OperationResponse<Paths.ConvertDocument.Responses.$200>
|
|
736
|
+
/**
|
|
737
|
+
* validateTemplate - validateTemplate
|
|
738
|
+
*
|
|
739
|
+
* Validates a document template's variable syntax and, optionally, proposes a hotfixed copy of it.
|
|
740
|
+
*
|
|
741
|
+
* The endpoint compiles the template with docxtemplater's core parser (the xlsx module for
|
|
742
|
+
* spreadsheets), so a delimiter or tag error reported here is one generation would fail on.
|
|
743
|
+
* Failures specific to the image or HTML modules are not covered. Every problem it can repair
|
|
744
|
+
* unambiguously — a missing brace, an extra brace, a smart quote or a non-breaking space that
|
|
745
|
+
* Word substituted inside a tag — is applied to a **copy** of the template, which is uploaded
|
|
746
|
+
* and returned as `fixed_document`.
|
|
747
|
+
*
|
|
748
|
+
* The original template is never modified. Accepting the fix is an explicit, separate step:
|
|
749
|
+
* the caller shows the user `issues` (each with its `before`/`after`), lets them download
|
|
750
|
+
* `fixed_document.preview_url`, and only then replaces the template.
|
|
751
|
+
*
|
|
752
|
+
* Supported input document types:
|
|
753
|
+
* - .docx, .docm, .dotx
|
|
754
|
+
* - .xlsx, .xlsm
|
|
755
|
+
* - .pptx
|
|
756
|
+
*
|
|
757
|
+
*/
|
|
758
|
+
'validateTemplate'(
|
|
759
|
+
parameters?: Parameters<UnknownParamsObject> | null,
|
|
760
|
+
data?: Paths.ValidateTemplate.RequestBody,
|
|
761
|
+
config?: AxiosRequestConfig
|
|
762
|
+
): OperationResponse<Paths.ValidateTemplate.Responses.$200>
|
|
534
763
|
}
|
|
535
764
|
|
|
536
765
|
export interface PathsDictionary {
|
|
@@ -565,7 +794,7 @@ export interface PathsDictionary {
|
|
|
565
794
|
* - .docx but limited to only text based variables
|
|
566
795
|
* - .ics
|
|
567
796
|
*
|
|
568
|
-
* Uses [Template
|
|
797
|
+
* Uses [Template Variables API](https://docs.epilot.io/api/template-variables) to replace variables in the input document.
|
|
569
798
|
*
|
|
570
799
|
*/
|
|
571
800
|
'post'(
|
|
@@ -593,10 +822,40 @@ export interface PathsDictionary {
|
|
|
593
822
|
config?: AxiosRequestConfig
|
|
594
823
|
): OperationResponse<Paths.ConvertDocument.Responses.$200>
|
|
595
824
|
}
|
|
825
|
+
['/v2/templates:validate']: {
|
|
826
|
+
/**
|
|
827
|
+
* validateTemplate - validateTemplate
|
|
828
|
+
*
|
|
829
|
+
* Validates a document template's variable syntax and, optionally, proposes a hotfixed copy of it.
|
|
830
|
+
*
|
|
831
|
+
* The endpoint compiles the template with docxtemplater's core parser (the xlsx module for
|
|
832
|
+
* spreadsheets), so a delimiter or tag error reported here is one generation would fail on.
|
|
833
|
+
* Failures specific to the image or HTML modules are not covered. Every problem it can repair
|
|
834
|
+
* unambiguously — a missing brace, an extra brace, a smart quote or a non-breaking space that
|
|
835
|
+
* Word substituted inside a tag — is applied to a **copy** of the template, which is uploaded
|
|
836
|
+
* and returned as `fixed_document`.
|
|
837
|
+
*
|
|
838
|
+
* The original template is never modified. Accepting the fix is an explicit, separate step:
|
|
839
|
+
* the caller shows the user `issues` (each with its `before`/`after`), lets them download
|
|
840
|
+
* `fixed_document.preview_url`, and only then replaces the template.
|
|
841
|
+
*
|
|
842
|
+
* Supported input document types:
|
|
843
|
+
* - .docx, .docm, .dotx
|
|
844
|
+
* - .xlsx, .xlsm
|
|
845
|
+
* - .pptx
|
|
846
|
+
*
|
|
847
|
+
*/
|
|
848
|
+
'post'(
|
|
849
|
+
parameters?: Parameters<UnknownParamsObject> | null,
|
|
850
|
+
data?: Paths.ValidateTemplate.RequestBody,
|
|
851
|
+
config?: AxiosRequestConfig
|
|
852
|
+
): OperationResponse<Paths.ValidateTemplate.Responses.$200>
|
|
853
|
+
}
|
|
596
854
|
}
|
|
597
855
|
|
|
598
856
|
export type Client = OpenAPIClient<OperationMethods, PathsDictionary>
|
|
599
857
|
|
|
858
|
+
|
|
600
859
|
export type ConvertDocumentRequest = Components.Schemas.ConvertDocumentRequest;
|
|
601
860
|
export type ConvertDocumentResponse = Components.Schemas.ConvertDocumentResponse;
|
|
602
861
|
export type DocumentGenerationV2Request = Components.Schemas.DocumentGenerationV2Request;
|
|
@@ -612,4 +871,7 @@ export type InternalErrorDetails = Components.Schemas.InternalErrorDetails;
|
|
|
612
871
|
export type InvalidCustomVariableErrorDetail = Components.Schemas.InvalidCustomVariableErrorDetail;
|
|
613
872
|
export type InvalidCustomVariableErrorDetails = Components.Schemas.InvalidCustomVariableErrorDetails;
|
|
614
873
|
export type S3Reference = Components.Schemas.S3Reference;
|
|
874
|
+
export type TemplateIssue = Components.Schemas.TemplateIssue;
|
|
615
875
|
export type TemplateSettings = Components.Schemas.TemplateSettings;
|
|
876
|
+
export type TemplateValidationRequest = Components.Schemas.TemplateValidationRequest;
|
|
877
|
+
export type TemplateValidationResponse = Components.Schemas.TemplateValidationResponse;
|
package/package.json
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@epilot/document-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "API Client for epilot document API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "vitest",
|
|
9
|
+
"typescript": "tsc",
|
|
10
|
+
"bundle-definition": "webpack",
|
|
11
|
+
"openapi": "node ../../scripts/update-openapi.js https://docs.api.epilot.io/document.yaml",
|
|
12
|
+
"openapi:local": "node ../../scripts/update-openapi.js ../../../document-api/lambda/ApiHandlerFunction/openapi.yml",
|
|
13
|
+
"typegen": "openapi typegen src/openapi.json --client > src/openapi.d.ts",
|
|
14
|
+
"build": "tsc && npm run build:patch && npm run bundle-definition",
|
|
15
|
+
"build:patch": "sed -i'' -e '/^__exportStar.*openapi.*$/d' dist/index.js",
|
|
16
|
+
"build:watch": "npm run build && tsc -w",
|
|
17
|
+
"release-alpha": "npm version prerelease --preid alpha",
|
|
18
|
+
"lint": "biome check src"
|
|
19
|
+
},
|
|
7
20
|
"files": [
|
|
8
21
|
"*.js",
|
|
9
22
|
"*.d.ts",
|
|
@@ -17,7 +30,7 @@
|
|
|
17
30
|
],
|
|
18
31
|
"keywords": [],
|
|
19
32
|
"author": "epilot GmbH",
|
|
20
|
-
"license": "
|
|
33
|
+
"license": "MIT",
|
|
21
34
|
"private": false,
|
|
22
35
|
"peerDependencies": {
|
|
23
36
|
"axios": "^1.0.0 || >=0.25.0 <1.0.0"
|
|
@@ -31,30 +44,14 @@
|
|
|
31
44
|
"util": "^0.12.3"
|
|
32
45
|
},
|
|
33
46
|
"devDependencies": {
|
|
34
|
-
"@types/jest": "^26.0.20",
|
|
35
47
|
"axios": "^1.11.0",
|
|
36
48
|
"copy-webpack-plugin": "^7.0.0",
|
|
37
|
-
"jest": "^29.6.2",
|
|
38
49
|
"json-loader": "^0.5.7",
|
|
39
|
-
"openapicmd": "^2.
|
|
40
|
-
"ts-jest": "^29.4.1",
|
|
50
|
+
"openapicmd": "^2.9.2",
|
|
41
51
|
"ts-loader": "^8.0.14",
|
|
42
52
|
"ts-node": "^10.9.1",
|
|
43
53
|
"typescript": "^4.1.3",
|
|
44
54
|
"webpack": "^5.18.0",
|
|
45
55
|
"webpack-cli": "^4.4.0"
|
|
46
|
-
},
|
|
47
|
-
"scripts": {
|
|
48
|
-
"test": "jest",
|
|
49
|
-
"typescript": "tsc",
|
|
50
|
-
"bundle-definition": "webpack",
|
|
51
|
-
"openapi": "node ../../scripts/update-openapi.js https://docs.api.epilot.io/document.yaml",
|
|
52
|
-
"openapi:local": "node ../../scripts/update-openapi.js ../../../document-api/lambda/ApiHandlerFunction/openapi.yml",
|
|
53
|
-
"typegen": "openapi typegen src/openapi.json --client -b '/* eslint-disable */' > src/openapi.d.ts",
|
|
54
|
-
"build": "tsc && npm run build:patch && npm run bundle-definition",
|
|
55
|
-
"build:patch": "sed -i'' -e '/^__exportStar.*openapi.*$/d' dist/index.js",
|
|
56
|
-
"build:watch": "npm run build && tsc -w",
|
|
57
|
-
"release-alpha": "npm version prerelease --preid alpha",
|
|
58
|
-
"lint": "pnpm exec eslint src"
|
|
59
56
|
}
|
|
60
|
-
}
|
|
57
|
+
}
|
package/src/openapi.d.ts
DELETED
|
@@ -1,649 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
|
|
3
|
-
import type {
|
|
4
|
-
OpenAPIClient,
|
|
5
|
-
Parameters,
|
|
6
|
-
UnknownParamsObject,
|
|
7
|
-
OperationResponse,
|
|
8
|
-
AxiosRequestConfig,
|
|
9
|
-
} from 'openapi-client-axios';
|
|
10
|
-
|
|
11
|
-
declare namespace Components {
|
|
12
|
-
namespace Schemas {
|
|
13
|
-
export interface ConvertDocumentRequest {
|
|
14
|
-
/**
|
|
15
|
-
* Language
|
|
16
|
-
* example:
|
|
17
|
-
* de
|
|
18
|
-
*/
|
|
19
|
-
language?: string;
|
|
20
|
-
/**
|
|
21
|
-
* Input document
|
|
22
|
-
*/
|
|
23
|
-
input_document: {
|
|
24
|
-
s3ref: S3Reference;
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Output format of the document
|
|
28
|
-
*/
|
|
29
|
-
output_format: "pdf";
|
|
30
|
-
/**
|
|
31
|
-
* Filename of the output document (optional)
|
|
32
|
-
* example:
|
|
33
|
-
* converted.pdf
|
|
34
|
-
*/
|
|
35
|
-
output_filename?: string;
|
|
36
|
-
}
|
|
37
|
-
export interface ConvertDocumentResponse {
|
|
38
|
-
output_document?: {
|
|
39
|
-
/**
|
|
40
|
-
* Pre-signed URL for the converted document
|
|
41
|
-
* example:
|
|
42
|
-
* https://document-api-prod.s3.eu-central-1.amazonaws.com/preview/converted.pdf
|
|
43
|
-
*/
|
|
44
|
-
preview_url?: string;
|
|
45
|
-
s3ref?: S3Reference;
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
export interface DocumentGenerationV2Request {
|
|
49
|
-
/**
|
|
50
|
-
* Input template document
|
|
51
|
-
*/
|
|
52
|
-
template_document: {
|
|
53
|
-
/**
|
|
54
|
-
* Document original filename
|
|
55
|
-
* example:
|
|
56
|
-
* my-template-{{order.order_number}}.docx
|
|
57
|
-
*/
|
|
58
|
-
filename?: string;
|
|
59
|
-
s3ref?: S3Reference;
|
|
60
|
-
};
|
|
61
|
-
/**
|
|
62
|
-
* Entity to use for variable context
|
|
63
|
-
* example:
|
|
64
|
-
* bcd0aab9-b544-42b0-8bfb-6d449d02eacc
|
|
65
|
-
*/
|
|
66
|
-
context_entity_id?: string; // uuid
|
|
67
|
-
/**
|
|
68
|
-
* User Id for variable context
|
|
69
|
-
* example:
|
|
70
|
-
* 100321
|
|
71
|
-
*/
|
|
72
|
-
user_id?: string;
|
|
73
|
-
/**
|
|
74
|
-
* Language
|
|
75
|
-
* example:
|
|
76
|
-
* de
|
|
77
|
-
*/
|
|
78
|
-
language?: string;
|
|
79
|
-
/**
|
|
80
|
-
* Custom values for variables in the template. Takes the higher precedence than others.
|
|
81
|
-
*/
|
|
82
|
-
variable_payload?: {
|
|
83
|
-
additionalProperties?: string;
|
|
84
|
-
};
|
|
85
|
-
/**
|
|
86
|
-
* Custom values for variables in the template. Takes the higher precedence than others.
|
|
87
|
-
*/
|
|
88
|
-
context_data?: {
|
|
89
|
-
additionalProperties?: string;
|
|
90
|
-
};
|
|
91
|
-
template_settings?: /* Template Settings for document generation */ TemplateSettings;
|
|
92
|
-
}
|
|
93
|
-
export interface DocumentGenerationV2Response {
|
|
94
|
-
job_id?: string; // uuid
|
|
95
|
-
/**
|
|
96
|
-
* Status of the job
|
|
97
|
-
*/
|
|
98
|
-
job_status?: "STARTED" | "PROCESSING" | "SUCCESS" | "FAILED";
|
|
99
|
-
/**
|
|
100
|
-
* A message explaining the progress
|
|
101
|
-
*/
|
|
102
|
-
message?: string;
|
|
103
|
-
ics_output?: {
|
|
104
|
-
/**
|
|
105
|
-
* example:
|
|
106
|
-
* {
|
|
107
|
-
* "s3ref": {
|
|
108
|
-
* "bucket": "document-api-preview-prod",
|
|
109
|
-
* "key": "preview/my-appointment.ics"
|
|
110
|
-
* }
|
|
111
|
-
* }
|
|
112
|
-
*/
|
|
113
|
-
output_document?: {
|
|
114
|
-
/**
|
|
115
|
-
* Generated document filename for ICS
|
|
116
|
-
* example:
|
|
117
|
-
* my-appointment-OR-001.ics
|
|
118
|
-
*/
|
|
119
|
-
filename?: string;
|
|
120
|
-
s3ref?: S3Reference;
|
|
121
|
-
};
|
|
122
|
-
};
|
|
123
|
-
pdf_output?: {
|
|
124
|
-
/**
|
|
125
|
-
* Pre-signed S3 GET URL for PDF preview
|
|
126
|
-
* example:
|
|
127
|
-
* https://document-api-prod.s3.eu-central-1.amazonaws.com/preview/my-template-OR-001.pdf
|
|
128
|
-
*/
|
|
129
|
-
preview_url?: string;
|
|
130
|
-
/**
|
|
131
|
-
* example:
|
|
132
|
-
* {
|
|
133
|
-
* "s3ref": {
|
|
134
|
-
* "bucket": "document-api-preview-prod",
|
|
135
|
-
* "key": "preview/my-template.pdf"
|
|
136
|
-
* }
|
|
137
|
-
* }
|
|
138
|
-
*/
|
|
139
|
-
output_document?: {
|
|
140
|
-
/**
|
|
141
|
-
* Generated document filename for PDF
|
|
142
|
-
* example:
|
|
143
|
-
* my-template-OR-001.pdf
|
|
144
|
-
*/
|
|
145
|
-
filename?: string;
|
|
146
|
-
s3ref?: S3Reference;
|
|
147
|
-
};
|
|
148
|
-
};
|
|
149
|
-
docx_output?: {
|
|
150
|
-
/**
|
|
151
|
-
* Pre-signed S3 GET URL for DOCX preview
|
|
152
|
-
* example:
|
|
153
|
-
* https://document-api-prod.s3.eu-central-1.amazonaws.com/preview/my-template-OR-001.docx
|
|
154
|
-
*/
|
|
155
|
-
preview_url?: string;
|
|
156
|
-
/**
|
|
157
|
-
* example:
|
|
158
|
-
* {
|
|
159
|
-
* "s3ref": {
|
|
160
|
-
* "bucket": "document-api-preview-prod",
|
|
161
|
-
* "key": "preview/my-template.docx"
|
|
162
|
-
* }
|
|
163
|
-
* }
|
|
164
|
-
*/
|
|
165
|
-
output_document?: {
|
|
166
|
-
/**
|
|
167
|
-
* Generated document filename for DOCX
|
|
168
|
-
* example:
|
|
169
|
-
* my-template-OR-001.docx
|
|
170
|
-
*/
|
|
171
|
-
filename?: string;
|
|
172
|
-
s3ref?: S3Reference;
|
|
173
|
-
};
|
|
174
|
-
};
|
|
175
|
-
xlsx_output?: {
|
|
176
|
-
/**
|
|
177
|
-
* Pre-signed S3 GET URL for XLSX preview
|
|
178
|
-
* example:
|
|
179
|
-
* https://document-api-prod.s3.eu-central-1.amazonaws.com/preview/my-template-OR-001.xlsx
|
|
180
|
-
*/
|
|
181
|
-
preview_url?: string;
|
|
182
|
-
/**
|
|
183
|
-
* example:
|
|
184
|
-
* {
|
|
185
|
-
* "s3ref": {
|
|
186
|
-
* "bucket": "document-api-preview-prod",
|
|
187
|
-
* "key": "preview/my-template.xlsx"
|
|
188
|
-
* }
|
|
189
|
-
* }
|
|
190
|
-
*/
|
|
191
|
-
output_document?: {
|
|
192
|
-
/**
|
|
193
|
-
* Generated document filename for XLSX
|
|
194
|
-
* example:
|
|
195
|
-
* my-template-OR-001.xlsx
|
|
196
|
-
*/
|
|
197
|
-
filename?: string;
|
|
198
|
-
s3ref?: S3Reference;
|
|
199
|
-
};
|
|
200
|
-
};
|
|
201
|
-
error_output?: ErrorOutput;
|
|
202
|
-
/**
|
|
203
|
-
* List of variables and its corresponding replaced values from the document template
|
|
204
|
-
*/
|
|
205
|
-
variable_payload?: {
|
|
206
|
-
additionalProperties?: string;
|
|
207
|
-
};
|
|
208
|
-
template_settings?: /* Template Settings for document generation */ TemplateSettings;
|
|
209
|
-
}
|
|
210
|
-
export interface DocumentMetaRequest {
|
|
211
|
-
/**
|
|
212
|
-
* Input template document
|
|
213
|
-
*/
|
|
214
|
-
template_document?: {
|
|
215
|
-
s3ref?: S3Reference;
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
export interface DocumentMetaResponse {
|
|
219
|
-
/**
|
|
220
|
-
* Page margins for the document
|
|
221
|
-
*/
|
|
222
|
-
page_margins?: {
|
|
223
|
-
/**
|
|
224
|
-
* Top margin in cm
|
|
225
|
-
* example:
|
|
226
|
-
* 2.54
|
|
227
|
-
*/
|
|
228
|
-
top?: number;
|
|
229
|
-
/**
|
|
230
|
-
* Bottom margin in cm
|
|
231
|
-
* example:
|
|
232
|
-
* 2.54
|
|
233
|
-
*/
|
|
234
|
-
bottom?: number;
|
|
235
|
-
/**
|
|
236
|
-
* Left margin in cm
|
|
237
|
-
* example:
|
|
238
|
-
* 2.54
|
|
239
|
-
*/
|
|
240
|
-
left?: number;
|
|
241
|
-
/**
|
|
242
|
-
* Right margin in cm
|
|
243
|
-
* example:
|
|
244
|
-
* 2.54
|
|
245
|
-
*/
|
|
246
|
-
right?: number;
|
|
247
|
-
/**
|
|
248
|
-
* Header margin in cm
|
|
249
|
-
* example:
|
|
250
|
-
* 2.54
|
|
251
|
-
*/
|
|
252
|
-
header?: number;
|
|
253
|
-
/**
|
|
254
|
-
* Footer margin in cm
|
|
255
|
-
* example:
|
|
256
|
-
* 2.54
|
|
257
|
-
*/
|
|
258
|
-
footer?: number;
|
|
259
|
-
};
|
|
260
|
-
/**
|
|
261
|
-
* List of variables in the document
|
|
262
|
-
* example:
|
|
263
|
-
* [
|
|
264
|
-
* "order.billing_contact.0.salutation",
|
|
265
|
-
* "order.billing_contact.0.title",
|
|
266
|
-
* "order_table",
|
|
267
|
-
* "stayHardStatic",
|
|
268
|
-
* "opportunity[attribute_name]",
|
|
269
|
-
* "opportunity[\"attribute_name\"]",
|
|
270
|
-
* "opportunity.[attribute_name]",
|
|
271
|
-
* "attribute_name",
|
|
272
|
-
* "opportunities.0.attribute_name",
|
|
273
|
-
* "opportunities[0].attribute_name",
|
|
274
|
-
* "contact.opportunities[0].attribute_name",
|
|
275
|
-
* "opportunities[Primary].attribute_name"
|
|
276
|
-
* ]
|
|
277
|
-
*/
|
|
278
|
-
variables?: string[];
|
|
279
|
-
}
|
|
280
|
-
/**
|
|
281
|
-
* DocxTemplater error detail
|
|
282
|
-
*/
|
|
283
|
-
export interface DocxTemplaterErrorDetail {
|
|
284
|
-
/**
|
|
285
|
-
* Id of the error
|
|
286
|
-
*/
|
|
287
|
-
id?: string;
|
|
288
|
-
/**
|
|
289
|
-
* Context of the error
|
|
290
|
-
*/
|
|
291
|
-
context?: string;
|
|
292
|
-
/**
|
|
293
|
-
* Explanation of the error
|
|
294
|
-
*/
|
|
295
|
-
explanation?: string;
|
|
296
|
-
}
|
|
297
|
-
/**
|
|
298
|
-
* Error details for DocxTemplater error. This error will appear under 'PARSE_ERROR' error code.
|
|
299
|
-
* See https://docxtemplater.com/docs/errors/#error-schema for more details.
|
|
300
|
-
*
|
|
301
|
-
*/
|
|
302
|
-
export type DocxTemplaterErrorDetails = /* DocxTemplater error detail */ DocxTemplaterErrorDetail[];
|
|
303
|
-
/**
|
|
304
|
-
* Error codes for document generation:
|
|
305
|
-
* - PARSE_ERROR - Error while parsing the document. Normally related with a bad template using the wrong DocxTemplater syntax.
|
|
306
|
-
* - DOC_TO_PDF_CONVERT_ERROR - Error while converting the document to PDF. Normally related with a ConvertAPI failure.
|
|
307
|
-
* - INTERNAL_ERROR - Internal error. Please contact support.
|
|
308
|
-
* - INVALID_TEMPLATE_FORMAT - Invalid template format (only .docx is supported). This can happen due to a bad word file or an unsupported file extension.
|
|
309
|
-
*
|
|
310
|
-
*/
|
|
311
|
-
export type ErrorCode = "PARSE_ERROR" | "DOC_TO_PDF_CONVERT_ERROR" | "INTERNAL_ERROR" | "INVALID_TEMPLATE_FORMAT";
|
|
312
|
-
export interface ErrorOutput {
|
|
313
|
-
/**
|
|
314
|
-
* Error message
|
|
315
|
-
*/
|
|
316
|
-
error_message?: string;
|
|
317
|
-
error_code?: /**
|
|
318
|
-
* Error codes for document generation:
|
|
319
|
-
* - PARSE_ERROR - Error while parsing the document. Normally related with a bad template using the wrong DocxTemplater syntax.
|
|
320
|
-
* - DOC_TO_PDF_CONVERT_ERROR - Error while converting the document to PDF. Normally related with a ConvertAPI failure.
|
|
321
|
-
* - INTERNAL_ERROR - Internal error. Please contact support.
|
|
322
|
-
* - INVALID_TEMPLATE_FORMAT - Invalid template format (only .docx is supported). This can happen due to a bad word file or an unsupported file extension.
|
|
323
|
-
*
|
|
324
|
-
*/
|
|
325
|
-
ErrorCode;
|
|
326
|
-
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 | /**
|
|
327
|
-
* Error details for DocxTemplater error. This error will appear under 'PARSE_ERROR' error code.
|
|
328
|
-
* See https://docxtemplater.com/docs/errors/#error-schema for more details.
|
|
329
|
-
*
|
|
330
|
-
*/
|
|
331
|
-
DocxTemplaterErrorDetails;
|
|
332
|
-
}
|
|
333
|
-
/**
|
|
334
|
-
* Internal error detail
|
|
335
|
-
*/
|
|
336
|
-
export interface InternalErrorDetail {
|
|
337
|
-
/**
|
|
338
|
-
* Name of the error
|
|
339
|
-
*/
|
|
340
|
-
name?: string;
|
|
341
|
-
/**
|
|
342
|
-
* Error message
|
|
343
|
-
*/
|
|
344
|
-
message?: string;
|
|
345
|
-
/**
|
|
346
|
-
* Stack trace
|
|
347
|
-
*/
|
|
348
|
-
stack?: string;
|
|
349
|
-
/**
|
|
350
|
-
* Cause of the error
|
|
351
|
-
*/
|
|
352
|
-
cause?: string;
|
|
353
|
-
}
|
|
354
|
-
/**
|
|
355
|
-
* Error details for internal error. This error will appear under 'INTERNAL_ERROR' error code.
|
|
356
|
-
*/
|
|
357
|
-
export type InternalErrorDetails = {
|
|
358
|
-
items?: /* Internal error detail */ InternalErrorDetail;
|
|
359
|
-
}[];
|
|
360
|
-
export interface InvalidCustomVariableErrorDetail {
|
|
361
|
-
[name: string]: any;
|
|
362
|
-
/**
|
|
363
|
-
* Explanation for the error
|
|
364
|
-
*/
|
|
365
|
-
explanation?: string;
|
|
366
|
-
/**
|
|
367
|
-
* Context for the error
|
|
368
|
-
*/
|
|
369
|
-
context?: {
|
|
370
|
-
/**
|
|
371
|
-
* List of invalid variables
|
|
372
|
-
*/
|
|
373
|
-
invalid_variables?: {
|
|
374
|
-
/**
|
|
375
|
-
* Variable name
|
|
376
|
-
*/
|
|
377
|
-
variable?: string;
|
|
378
|
-
/**
|
|
379
|
-
* Explanation for the error
|
|
380
|
-
*/
|
|
381
|
-
error?: string;
|
|
382
|
-
}[];
|
|
383
|
-
};
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* Error details for invalid custom variables. This error will appear under 'PARSE_ERROR' error code.
|
|
387
|
-
*/
|
|
388
|
-
export type InvalidCustomVariableErrorDetails = InvalidCustomVariableErrorDetail[];
|
|
389
|
-
export interface S3Reference {
|
|
390
|
-
/**
|
|
391
|
-
* example:
|
|
392
|
-
* document-api-prod
|
|
393
|
-
*/
|
|
394
|
-
bucket: string;
|
|
395
|
-
/**
|
|
396
|
-
* example:
|
|
397
|
-
* uploads/my-template.pdf
|
|
398
|
-
*/
|
|
399
|
-
key: string;
|
|
400
|
-
}
|
|
401
|
-
/**
|
|
402
|
-
* Template Settings for document generation
|
|
403
|
-
*/
|
|
404
|
-
export interface TemplateSettings {
|
|
405
|
-
/**
|
|
406
|
-
* Custom margins for the document
|
|
407
|
-
*/
|
|
408
|
-
custom_margins?: {
|
|
409
|
-
/**
|
|
410
|
-
* Top margin in cm
|
|
411
|
-
* example:
|
|
412
|
-
* 2.54
|
|
413
|
-
*/
|
|
414
|
-
top?: number;
|
|
415
|
-
/**
|
|
416
|
-
* Bottom margin in cm
|
|
417
|
-
* example:
|
|
418
|
-
* 2.54
|
|
419
|
-
*/
|
|
420
|
-
bottom?: number;
|
|
421
|
-
};
|
|
422
|
-
/**
|
|
423
|
-
* Suggested margins for the document
|
|
424
|
-
*/
|
|
425
|
-
suggested_margins?: {
|
|
426
|
-
/**
|
|
427
|
-
* Top margin in cm
|
|
428
|
-
* example:
|
|
429
|
-
* 2.54
|
|
430
|
-
*/
|
|
431
|
-
top?: number;
|
|
432
|
-
/**
|
|
433
|
-
* Bottom margin in cm
|
|
434
|
-
* example:
|
|
435
|
-
* 2.54
|
|
436
|
-
*/
|
|
437
|
-
bottom?: number;
|
|
438
|
-
};
|
|
439
|
-
/**
|
|
440
|
-
* Display margin guidelines (applicable to partial generation only)
|
|
441
|
-
* example:
|
|
442
|
-
* true
|
|
443
|
-
*/
|
|
444
|
-
display_margin_guidelines?: boolean;
|
|
445
|
-
/**
|
|
446
|
-
* Enable data table margin autofix
|
|
447
|
-
* example:
|
|
448
|
-
* false
|
|
449
|
-
*/
|
|
450
|
-
enable_data_table_margin_autofix?: boolean;
|
|
451
|
-
/**
|
|
452
|
-
* A flag that indicates whether the template has 1 or more data tables in it
|
|
453
|
-
* example:
|
|
454
|
-
* false
|
|
455
|
-
*/
|
|
456
|
-
template_with_datatable?: boolean;
|
|
457
|
-
/**
|
|
458
|
-
* Enables the persistance of template settings
|
|
459
|
-
* example:
|
|
460
|
-
* false
|
|
461
|
-
*/
|
|
462
|
-
enabled_template_settings_persistence?: boolean;
|
|
463
|
-
/**
|
|
464
|
-
* An indication that the page margins are misconfigured
|
|
465
|
-
* example:
|
|
466
|
-
* false
|
|
467
|
-
*/
|
|
468
|
-
misconfigured_margins?: boolean;
|
|
469
|
-
/**
|
|
470
|
-
* The file entity id, used when persisting a new template version with updated settings
|
|
471
|
-
* example:
|
|
472
|
-
* 1a2b3c4d-5e6f-7g8h-9i0j-1k2l3m4n5o6p
|
|
473
|
-
*/
|
|
474
|
-
file_entity_id?: string; // uuid
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
declare namespace Paths {
|
|
479
|
-
namespace ConvertDocument {
|
|
480
|
-
export type RequestBody = Components.Schemas.ConvertDocumentRequest;
|
|
481
|
-
namespace Responses {
|
|
482
|
-
export type $200 = Components.Schemas.ConvertDocumentResponse;
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
namespace GenerateDocumentV2 {
|
|
486
|
-
namespace Parameters {
|
|
487
|
-
export type JobId = string;
|
|
488
|
-
export type Mode = "partial_generation" | "full_generation";
|
|
489
|
-
export type PreviewMode = "open" | "download";
|
|
490
|
-
}
|
|
491
|
-
export interface QueryParameters {
|
|
492
|
-
job_id?: Parameters.JobId;
|
|
493
|
-
mode?: Parameters.Mode;
|
|
494
|
-
preview_mode?: Parameters.PreviewMode;
|
|
495
|
-
}
|
|
496
|
-
export type RequestBody = Components.Schemas.DocumentGenerationV2Request;
|
|
497
|
-
namespace Responses {
|
|
498
|
-
export type $200 = Components.Schemas.DocumentGenerationV2Response;
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
namespace GetTemplateMeta {
|
|
502
|
-
export type RequestBody = Components.Schemas.DocumentMetaRequest;
|
|
503
|
-
namespace Responses {
|
|
504
|
-
export type $200 = Components.Schemas.DocumentMetaResponse;
|
|
505
|
-
export type $400 = Components.Schemas.ErrorOutput;
|
|
506
|
-
export type $403 = Components.Schemas.ErrorOutput;
|
|
507
|
-
export type $415 = Components.Schemas.ErrorOutput;
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
export interface OperationMethods {
|
|
514
|
-
/**
|
|
515
|
-
* getTemplateMeta - getTemplateMeta
|
|
516
|
-
*
|
|
517
|
-
* Get metadata for a document template
|
|
518
|
-
*
|
|
519
|
-
* Supported input document types:
|
|
520
|
-
* - .docx
|
|
521
|
-
*
|
|
522
|
-
*/
|
|
523
|
-
'getTemplateMeta'(
|
|
524
|
-
parameters?: Parameters<UnknownParamsObject> | null,
|
|
525
|
-
data?: Paths.GetTemplateMeta.RequestBody,
|
|
526
|
-
config?: AxiosRequestConfig
|
|
527
|
-
): OperationResponse<Paths.GetTemplateMeta.Responses.$200>
|
|
528
|
-
/**
|
|
529
|
-
* generateDocumentV2 - generateDocumentV2
|
|
530
|
-
*
|
|
531
|
-
* Generates documents from templates with variables.
|
|
532
|
-
*
|
|
533
|
-
* Supported document types as input:
|
|
534
|
-
* - .docx
|
|
535
|
-
* - .ics
|
|
536
|
-
*
|
|
537
|
-
* Supported document types as output:
|
|
538
|
-
* - .pdf
|
|
539
|
-
* - .docx but limited to only text based variables
|
|
540
|
-
* - .ics
|
|
541
|
-
*
|
|
542
|
-
* Uses [Template Variables API](https://docs.epilot.io/api/template-variables) to replace variables in the input document.
|
|
543
|
-
*
|
|
544
|
-
*/
|
|
545
|
-
'generateDocumentV2'(
|
|
546
|
-
parameters?: Parameters<Paths.GenerateDocumentV2.QueryParameters> | null,
|
|
547
|
-
data?: Paths.GenerateDocumentV2.RequestBody,
|
|
548
|
-
config?: AxiosRequestConfig
|
|
549
|
-
): OperationResponse<Paths.GenerateDocumentV2.Responses.$200>
|
|
550
|
-
/**
|
|
551
|
-
* convertDocument - convertDocument
|
|
552
|
-
*
|
|
553
|
-
* Converts a document to a different format.
|
|
554
|
-
*
|
|
555
|
-
* Supported input document types:
|
|
556
|
-
* - .docx
|
|
557
|
-
*
|
|
558
|
-
* Supported output document types:
|
|
559
|
-
* - .pdf
|
|
560
|
-
*
|
|
561
|
-
*/
|
|
562
|
-
'convertDocument'(
|
|
563
|
-
parameters?: Parameters<UnknownParamsObject> | null,
|
|
564
|
-
data?: Paths.ConvertDocument.RequestBody,
|
|
565
|
-
config?: AxiosRequestConfig
|
|
566
|
-
): OperationResponse<Paths.ConvertDocument.Responses.$200>
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
export interface PathsDictionary {
|
|
570
|
-
['/v2/documents:meta']: {
|
|
571
|
-
/**
|
|
572
|
-
* getTemplateMeta - getTemplateMeta
|
|
573
|
-
*
|
|
574
|
-
* Get metadata for a document template
|
|
575
|
-
*
|
|
576
|
-
* Supported input document types:
|
|
577
|
-
* - .docx
|
|
578
|
-
*
|
|
579
|
-
*/
|
|
580
|
-
'post'(
|
|
581
|
-
parameters?: Parameters<UnknownParamsObject> | null,
|
|
582
|
-
data?: Paths.GetTemplateMeta.RequestBody,
|
|
583
|
-
config?: AxiosRequestConfig
|
|
584
|
-
): OperationResponse<Paths.GetTemplateMeta.Responses.$200>
|
|
585
|
-
}
|
|
586
|
-
['/v2/documents:generate']: {
|
|
587
|
-
/**
|
|
588
|
-
* generateDocumentV2 - generateDocumentV2
|
|
589
|
-
*
|
|
590
|
-
* Generates documents from templates with variables.
|
|
591
|
-
*
|
|
592
|
-
* Supported document types as input:
|
|
593
|
-
* - .docx
|
|
594
|
-
* - .ics
|
|
595
|
-
*
|
|
596
|
-
* Supported document types as output:
|
|
597
|
-
* - .pdf
|
|
598
|
-
* - .docx but limited to only text based variables
|
|
599
|
-
* - .ics
|
|
600
|
-
*
|
|
601
|
-
* Uses [Template Variables API](https://docs.epilot.io/api/template-variables) to replace variables in the input document.
|
|
602
|
-
*
|
|
603
|
-
*/
|
|
604
|
-
'post'(
|
|
605
|
-
parameters?: Parameters<Paths.GenerateDocumentV2.QueryParameters> | null,
|
|
606
|
-
data?: Paths.GenerateDocumentV2.RequestBody,
|
|
607
|
-
config?: AxiosRequestConfig
|
|
608
|
-
): OperationResponse<Paths.GenerateDocumentV2.Responses.$200>
|
|
609
|
-
}
|
|
610
|
-
['/v2/documents:convert']: {
|
|
611
|
-
/**
|
|
612
|
-
* convertDocument - convertDocument
|
|
613
|
-
*
|
|
614
|
-
* Converts a document to a different format.
|
|
615
|
-
*
|
|
616
|
-
* Supported input document types:
|
|
617
|
-
* - .docx
|
|
618
|
-
*
|
|
619
|
-
* Supported output document types:
|
|
620
|
-
* - .pdf
|
|
621
|
-
*
|
|
622
|
-
*/
|
|
623
|
-
'post'(
|
|
624
|
-
parameters?: Parameters<UnknownParamsObject> | null,
|
|
625
|
-
data?: Paths.ConvertDocument.RequestBody,
|
|
626
|
-
config?: AxiosRequestConfig
|
|
627
|
-
): OperationResponse<Paths.ConvertDocument.Responses.$200>
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
export type Client = OpenAPIClient<OperationMethods, PathsDictionary>
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
export type ConvertDocumentRequest = Components.Schemas.ConvertDocumentRequest;
|
|
635
|
-
export type ConvertDocumentResponse = Components.Schemas.ConvertDocumentResponse;
|
|
636
|
-
export type DocumentGenerationV2Request = Components.Schemas.DocumentGenerationV2Request;
|
|
637
|
-
export type DocumentGenerationV2Response = Components.Schemas.DocumentGenerationV2Response;
|
|
638
|
-
export type DocumentMetaRequest = Components.Schemas.DocumentMetaRequest;
|
|
639
|
-
export type DocumentMetaResponse = Components.Schemas.DocumentMetaResponse;
|
|
640
|
-
export type DocxTemplaterErrorDetail = Components.Schemas.DocxTemplaterErrorDetail;
|
|
641
|
-
export type DocxTemplaterErrorDetails = Components.Schemas.DocxTemplaterErrorDetails;
|
|
642
|
-
export type ErrorCode = Components.Schemas.ErrorCode;
|
|
643
|
-
export type ErrorOutput = Components.Schemas.ErrorOutput;
|
|
644
|
-
export type InternalErrorDetail = Components.Schemas.InternalErrorDetail;
|
|
645
|
-
export type InternalErrorDetails = Components.Schemas.InternalErrorDetails;
|
|
646
|
-
export type InvalidCustomVariableErrorDetail = Components.Schemas.InvalidCustomVariableErrorDetail;
|
|
647
|
-
export type InvalidCustomVariableErrorDetails = Components.Schemas.InvalidCustomVariableErrorDetails;
|
|
648
|
-
export type S3Reference = Components.Schemas.S3Reference;
|
|
649
|
-
export type TemplateSettings = Components.Schemas.TemplateSettings;
|