@epilot/document-client 0.19.2 → 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.
@@ -1 +1 @@
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":{"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":{"content":{"application/json":{}}},"responses":{}}},"/v2/documents:convert":{"post":{"operationId":"convertDocument","requestBody":{"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})})();
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,
@@ -306,9 +304,10 @@ declare namespace Components {
306
304
  * - DOC_TO_PDF_CONVERT_ERROR - Error while converting the document to PDF. Normally related with a ConvertAPI failure.
307
305
  * - INTERNAL_ERROR - Internal error. Please contact support.
308
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.
309
308
  *
310
309
  */
311
- 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";
312
311
  export interface ErrorOutput {
313
312
  /**
314
313
  * Error message
@@ -320,6 +319,7 @@ declare namespace Components {
320
319
  * - DOC_TO_PDF_CONVERT_ERROR - Error while converting the document to PDF. Normally related with a ConvertAPI failure.
321
320
  * - INTERNAL_ERROR - Internal error. Please contact support.
322
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.
323
323
  *
324
324
  */
325
325
  ErrorCode;
@@ -398,6 +398,75 @@ declare namespace Components {
398
398
  */
399
399
  key: string;
400
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
+ }
401
470
  /**
402
471
  * Template Settings for document generation
403
472
  */
@@ -469,10 +538,81 @@ declare namespace Components {
469
538
  /**
470
539
  * The file entity id, used when persisting a new template version with updated settings
471
540
  * example:
472
- * 1a2b3c4d-5e6f-7g8h-9i0j-1k2l3m4n5o6p
541
+ * 123e4567-e89b-12d3-a456-426614174000
473
542
  */
474
543
  file_entity_id?: string; // uuid
475
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
+ }
476
616
  }
477
617
  }
478
618
  declare namespace Paths {
@@ -485,13 +625,33 @@ declare namespace Paths {
485
625
  namespace GenerateDocumentV2 {
486
626
  namespace Parameters {
487
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
+ */
488
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
+ */
489
639
  export type PreviewMode = "open" | "download";
490
640
  }
491
641
  export interface QueryParameters {
492
642
  job_id?: Parameters.JobId;
493
- mode?: Parameters.Mode;
494
- preview_mode?: Parameters.PreviewMode;
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;
495
655
  }
496
656
  export type RequestBody = Components.Schemas.DocumentGenerationV2Request;
497
657
  namespace Responses {
@@ -507,6 +667,15 @@ declare namespace Paths {
507
667
  export type $415 = Components.Schemas.ErrorOutput;
508
668
  }
509
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
+ }
510
679
  }
511
680
 
512
681
 
@@ -564,6 +733,33 @@ export interface OperationMethods {
564
733
  data?: Paths.ConvertDocument.RequestBody,
565
734
  config?: AxiosRequestConfig
566
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>
567
763
  }
568
764
 
569
765
  export interface PathsDictionary {
@@ -626,6 +822,35 @@ export interface PathsDictionary {
626
822
  config?: AxiosRequestConfig
627
823
  ): OperationResponse<Paths.ConvertDocument.Responses.$200>
628
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
+ }
629
854
  }
630
855
 
631
856
  export type Client = OpenAPIClient<OperationMethods, PathsDictionary>
@@ -646,4 +871,7 @@ export type InternalErrorDetails = Components.Schemas.InternalErrorDetails;
646
871
  export type InvalidCustomVariableErrorDetail = Components.Schemas.InvalidCustomVariableErrorDetail;
647
872
  export type InvalidCustomVariableErrorDetails = Components.Schemas.InvalidCustomVariableErrorDetails;
648
873
  export type S3Reference = Components.Schemas.S3Reference;
874
+ export type TemplateIssue = Components.Schemas.TemplateIssue;
649
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.19.2",
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",
@@ -40,18 +53,5 @@
40
53
  "typescript": "^4.1.3",
41
54
  "webpack": "^5.18.0",
42
55
  "webpack-cli": "^4.4.0"
43
- },
44
- "scripts": {
45
- "test": "vitest",
46
- "typescript": "tsc",
47
- "bundle-definition": "webpack",
48
- "openapi": "node ../../scripts/update-openapi.js https://docs.api.epilot.io/document.yaml",
49
- "openapi:local": "node ../../scripts/update-openapi.js ../../../document-api/lambda/ApiHandlerFunction/openapi.yml",
50
- "typegen": "openapi typegen src/openapi.json --client > src/openapi.d.ts",
51
- "build": "tsc && npm run build:patch && npm run bundle-definition",
52
- "build:patch": "sed -i'' -e '/^__exportStar.*openapi.*$/d' dist/index.js",
53
- "build:watch": "npm run build && tsc -w",
54
- "release-alpha": "npm version prerelease --preid alpha",
55
- "lint": "biome check src"
56
56
  }
57
- }
57
+ }