@epilot/document-client 0.1.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/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # `@epilot/document-client`
2
+
3
+ API Client for epilot Document API.
4
+
5
+ Uses [`openapi-client-axios`](https://github.com/anttiviljami/openapi-client-axios)
6
+
7
+ ## Getting Started
8
+
9
+ Install the package:
10
+
11
+ ```bash
12
+ npm install --save-dev @epilot/document-client
13
+ ```
14
+
15
+ Import the package:
16
+
17
+ ```typescript
18
+ import { getClient } from '@epilot/document-client';
19
+ ```
20
+
21
+ Use the client:
22
+ ```typescript
23
+ // get typed client
24
+ const client = await getClient();
25
+
26
+ // call an operation
27
+ const res = await client.generateDocument(null, {});
28
+ ```
29
+
30
+ ## BaseURL & Authorization
31
+
32
+ To pass an authorization header and set up the API url, you can use axios
33
+ defaults:
34
+
35
+ ```typescript
36
+ const client = getClient();
37
+ client.defaults.baseURL = config.API_URL;
38
+ client.defaults.headers['authorization'] = `Bearer ${token}`;
39
+ ```
40
+
41
+ ## API Docs:
42
+
43
+ https://docs.api.epilot.io/document
@@ -0,0 +1 @@
1
+ export declare const getClient: () => import("openapi-client-axios").OpenAPIClient<import("./openapi").OperationMethods, import("./openapi").PathsDictionary>;
package/dist/client.js ADDED
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getClient = void 0;
7
+ var openapi_client_axios_1 = __importDefault(require("openapi-client-axios"));
8
+ var definition_1 = __importDefault(require("./definition"));
9
+ var getClient = function () {
10
+ var api = new openapi_client_axios_1.default({ definition: definition_1.default, quick: true });
11
+ return api.initSync();
12
+ };
13
+ exports.getClient = getClient;
14
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1,3 @@
1
+ import type { Document } from 'openapi-client-axios';
2
+ declare const _default: Document;
3
+ export default _default;
@@ -0,0 +1 @@
1
+ !function(e,t){for(var o in t)e[o]=t[o];t.__esModule&&Object.defineProperty(e,"__esModule",{value:!0})}(exports,(()=>{"use strict";var e={914:function(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(279));t.default=n.default},279:e=>{e.exports=JSON.parse('{"openapi":"3.0.3","info":{"title":"Document API","version":"0.1.0"},"tags":[{"name":"documents","description":"Documents"}],"security":[{"EpilotAuth":[]}],"paths":{"/v1/documents:generate":{"post":{"operationId":"generateDocument","summary":"generateDocument","description":"Generates document using given context entity and document template.\\n\\nUses [Template Variable API](https://docs.api.staging.epilot.io/template-variables) to replace variables in the document\\n","tags":["documents"],"requestBody":{"description":"Document template and context entity","content":{"application/json":{"schema":{"type":"object","properties":{"template_document":{"type":"object","properties":{"s3ref":{"$ref":"#/components/schemas/S3Reference"}}},"context_entity_id":{"type":"string","example":"bcd0aab9-b544-42b0-8bfb-6d449d02eacc"}}}}}},"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.pdf"},"output_document":{"type":"object","properties":{"s3ref":{"$ref":"#/components/schemas/S3Reference"}},"example":{"s3ref":{"bucket":"document-api-preview-prod","key":"preview/my-template.pdf"}}}}}}}}}}}},"components":{"securitySchemes":{"EpilotAuth":{"type":"http","scheme":"bearer","description":"Epilot Bearer Token"}},"schemas":{"S3Reference":{"type":"object","properties":{"bucket":{"type":"string","example":"document-api-prod"},"key":{"type":"string","example":"uploads/my-template.pdf"}},"required":["bucket","key"]}}}}')}},t={};return function o(r){if(t[r])return t[r].exports;var n=t[r]={exports:{}};return e[r].call(n.exports,n,n.exports,o),n.exports}(914)})());
@@ -0,0 +1,3 @@
1
+ export * from './client';
2
+ export type { Client, Components, Paths, PathsDictionary, OperationMethods } from './openapi';
3
+ export type { OpenAPIClient, OpenAPIClientAxios, Document } from 'openapi-client-axios';
package/dist/index.js ADDED
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./client"), exports);
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,97 @@
1
+ /* eslint-disable */
2
+ import {
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 S3Reference {
13
+ /**
14
+ * example:
15
+ * document-api-prod
16
+ */
17
+ bucket: string;
18
+ /**
19
+ * example:
20
+ * uploads/my-template.pdf
21
+ */
22
+ key: string;
23
+ }
24
+ }
25
+ }
26
+ declare namespace Paths {
27
+ namespace GenerateDocument {
28
+ export interface RequestBody {
29
+ template_document?: {
30
+ s3ref?: Components.Schemas.S3Reference;
31
+ };
32
+ /**
33
+ * example:
34
+ * bcd0aab9-b544-42b0-8bfb-6d449d02eacc
35
+ */
36
+ context_entity_id?: string;
37
+ }
38
+ namespace Responses {
39
+ export interface $200 {
40
+ /**
41
+ * Pre-signed S3 GET URL for preview
42
+ * example:
43
+ * https://document-api-prod.s3.eu-central-1.amazonaws.com/preview/my-template.pdf
44
+ */
45
+ preview_url?: string;
46
+ /**
47
+ * example:
48
+ * {
49
+ * "s3ref": {
50
+ * "bucket": "document-api-preview-prod",
51
+ * "key": "preview/my-template.pdf"
52
+ * }
53
+ * }
54
+ */
55
+ output_document?: {
56
+ s3ref?: Components.Schemas.S3Reference;
57
+ };
58
+ }
59
+ }
60
+ }
61
+ }
62
+
63
+ export interface OperationMethods {
64
+ /**
65
+ * generateDocument - generateDocument
66
+ *
67
+ * Generates document using given context entity and document template.
68
+ *
69
+ * Uses [Template Variable API](https://docs.api.staging.epilot.io/template-variables) to replace variables in the document
70
+ *
71
+ */
72
+ 'generateDocument'(
73
+ parameters?: Parameters<UnknownParamsObject> | null,
74
+ data?: Paths.GenerateDocument.RequestBody,
75
+ config?: AxiosRequestConfig
76
+ ): OperationResponse<Paths.GenerateDocument.Responses.$200>
77
+ }
78
+
79
+ export interface PathsDictionary {
80
+ ['/v1/documents:generate']: {
81
+ /**
82
+ * generateDocument - generateDocument
83
+ *
84
+ * Generates document using given context entity and document template.
85
+ *
86
+ * Uses [Template Variable API](https://docs.api.staging.epilot.io/template-variables) to replace variables in the document
87
+ *
88
+ */
89
+ 'post'(
90
+ parameters?: Parameters<UnknownParamsObject> | null,
91
+ data?: Paths.GenerateDocument.RequestBody,
92
+ config?: AxiosRequestConfig
93
+ ): OperationResponse<Paths.GenerateDocument.Responses.$200>
94
+ }
95
+ }
96
+
97
+ export type Client = OpenAPIClient<OperationMethods, PathsDictionary>
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@epilot/document-client",
3
+ "version": "0.1.0",
4
+ "description": "API Client for epilot document API",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "scripts": {
8
+ "test": "jest",
9
+ "typescript": "tsc",
10
+ "bundle-definition": "webpack",
11
+ "openapi": "openapi read --json ../lambda/ApiHandlerFunction/openapi.yml > src/openapi.json",
12
+ "typegen": "echo '/* eslint-disable */' > src/openapi.d.ts && typegen ../lambda/ApiHandlerFunction/openapi.yml >> src/openapi.d.ts",
13
+ "build": "npm run openapi && npm run typegen && npm run typescript && npm run bundle-definition",
14
+ "eslint": "../node_modules/.bin/eslint -c ../.eslintrc.yml",
15
+ "prepublishOnly": "npm run build"
16
+ },
17
+ "files": [
18
+ "*.js",
19
+ "*.d.ts",
20
+ "**/*.js",
21
+ "**/*.d.ts",
22
+ "!*.test.*",
23
+ "!**/*.test.*",
24
+ "!node_modules",
25
+ "!src",
26
+ "!*.config.js"
27
+ ],
28
+ "keywords": [],
29
+ "author": "epilot GmbH",
30
+ "license": "UNLICENSED",
31
+ "peerDependencies": {
32
+ "axios": "^0.21.1"
33
+ },
34
+ "dependencies": {
35
+ "buffer": "^6.0.3",
36
+ "https-browserify": "^1.0.0",
37
+ "openapi-client-axios": "^3.13.1",
38
+ "stream-http": "^3.1.1",
39
+ "url": "^0.11.0",
40
+ "util": "^0.12.3"
41
+ },
42
+ "devDependencies": {
43
+ "@types/jest": "^26.0.20",
44
+ "axios": "^0.21.1",
45
+ "copy-webpack-plugin": "^7.0.0",
46
+ "jest": "^26.6.3",
47
+ "json-loader": "^0.5.7",
48
+ "openapi-client-axios-typegen": "^3.13.1",
49
+ "openapicmd": "^1.6.2",
50
+ "ts-jest": "^26.5.0",
51
+ "ts-loader": "^8.0.14",
52
+ "ts-node": "^9.1.1",
53
+ "typescript": "^4.1.3",
54
+ "webpack": "^5.18.0",
55
+ "webpack-cli": "^4.4.0"
56
+ }
57
+ }
@@ -0,0 +1,97 @@
1
+ /* eslint-disable */
2
+ import {
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 S3Reference {
13
+ /**
14
+ * example:
15
+ * document-api-prod
16
+ */
17
+ bucket: string;
18
+ /**
19
+ * example:
20
+ * uploads/my-template.pdf
21
+ */
22
+ key: string;
23
+ }
24
+ }
25
+ }
26
+ declare namespace Paths {
27
+ namespace GenerateDocument {
28
+ export interface RequestBody {
29
+ template_document?: {
30
+ s3ref?: Components.Schemas.S3Reference;
31
+ };
32
+ /**
33
+ * example:
34
+ * bcd0aab9-b544-42b0-8bfb-6d449d02eacc
35
+ */
36
+ context_entity_id?: string;
37
+ }
38
+ namespace Responses {
39
+ export interface $200 {
40
+ /**
41
+ * Pre-signed S3 GET URL for preview
42
+ * example:
43
+ * https://document-api-prod.s3.eu-central-1.amazonaws.com/preview/my-template.pdf
44
+ */
45
+ preview_url?: string;
46
+ /**
47
+ * example:
48
+ * {
49
+ * "s3ref": {
50
+ * "bucket": "document-api-preview-prod",
51
+ * "key": "preview/my-template.pdf"
52
+ * }
53
+ * }
54
+ */
55
+ output_document?: {
56
+ s3ref?: Components.Schemas.S3Reference;
57
+ };
58
+ }
59
+ }
60
+ }
61
+ }
62
+
63
+ export interface OperationMethods {
64
+ /**
65
+ * generateDocument - generateDocument
66
+ *
67
+ * Generates document using given context entity and document template.
68
+ *
69
+ * Uses [Template Variable API](https://docs.api.staging.epilot.io/template-variables) to replace variables in the document
70
+ *
71
+ */
72
+ 'generateDocument'(
73
+ parameters?: Parameters<UnknownParamsObject> | null,
74
+ data?: Paths.GenerateDocument.RequestBody,
75
+ config?: AxiosRequestConfig
76
+ ): OperationResponse<Paths.GenerateDocument.Responses.$200>
77
+ }
78
+
79
+ export interface PathsDictionary {
80
+ ['/v1/documents:generate']: {
81
+ /**
82
+ * generateDocument - generateDocument
83
+ *
84
+ * Generates document using given context entity and document template.
85
+ *
86
+ * Uses [Template Variable API](https://docs.api.staging.epilot.io/template-variables) to replace variables in the document
87
+ *
88
+ */
89
+ 'post'(
90
+ parameters?: Parameters<UnknownParamsObject> | null,
91
+ data?: Paths.GenerateDocument.RequestBody,
92
+ config?: AxiosRequestConfig
93
+ ): OperationResponse<Paths.GenerateDocument.Responses.$200>
94
+ }
95
+ }
96
+
97
+ export type Client = OpenAPIClient<OperationMethods, PathsDictionary>