@kaapi/kaapi 0.0.16 → 0.0.18

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/lib/baseApp.d.ts DELETED
@@ -1,23 +0,0 @@
1
- import { HandlerDecorations, Lifecycle, ReqRef, ReqRefDefaults } from '@hapi/hapi';
2
- import { KaapiServerRoute, KaapiServer, KaapiServerOptions } from '@kaapi/server';
3
- import { ILogger } from './services/log';
4
- import { IMessaging, IMessagingSender, IMessagingSubscribeConfig, IPublishMethod, ISubscribeMethod } from './services/messaging';
5
- export interface IKaapiApp extends IMessaging {
6
- log: ILogger;
7
- emit: IPublishMethod;
8
- on: ISubscribeMethod;
9
- server(): KaapiServer;
10
- route<Refs extends ReqRef = ReqRefDefaults>(serverRoute: KaapiServerRoute<Refs>, handler?: HandlerDecorations | Lifecycle.Method<Refs, Lifecycle.ReturnValue<Refs>>): this;
11
- }
12
- export declare abstract class KaapiBaseApp implements IKaapiApp {
13
- abstract log: ILogger;
14
- abstract emit<T = unknown>(topic: string, message: T): Promise<void>;
15
- abstract on<T = unknown>(topic: string, handler: (message: T, sender: IMessagingSender) => void | Promise<void>, conf?: IMessagingSubscribeConfig | undefined): Promise<void>;
16
- abstract publish<T = unknown>(topic: string, message: T): Promise<void>;
17
- abstract subscribe<T = unknown>(topic: string, handler: (message: T, sender: IMessagingSender) => void | Promise<void>, conf?: IMessagingSubscribeConfig | undefined): Promise<void>;
18
- abstract server(opts?: KaapiServerOptions): KaapiServer;
19
- protected version?: string;
20
- protected kaapiServer?: KaapiServer;
21
- route<Refs extends ReqRef = ReqRefDefaults>(serverRoute: KaapiServerRoute<Refs>, handler?: HandlerDecorations | Lifecycle.Method<Refs, Lifecycle.ReturnValue<Refs>>): this;
22
- toString(): string;
23
- }
package/lib/baseApp.js DELETED
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.KaapiBaseApp = void 0;
4
- class KaapiBaseApp {
5
- route(serverRoute, handler) {
6
- this.server().route(serverRoute, handler);
7
- return this;
8
- }
9
- toString() {
10
- var _a, _b, _c;
11
- let result = `${this.version || '0.0.0'}`;
12
- if (this.kaapiServer) {
13
- result += `, server: ${(_a = this.kaapiServer) === null || _a === void 0 ? void 0 : _a.server.info.uri}, `;
14
- result += `state: ${((_b = this.kaapiServer) === null || _b === void 0 ? void 0 : _b.server.info.started) ? new Date((_c = this.kaapiServer) === null || _c === void 0 ? void 0 : _c.server.info.started) : 'STOPPED'}`;
15
- }
16
- return result;
17
- }
18
- [Symbol.for('nodejs.util.inspect.custom')]() {
19
- return `${this.constructor.name} <${this.toString()}>`;
20
- }
21
- }
22
- exports.KaapiBaseApp = KaapiBaseApp;
23
- //# sourceMappingURL=baseApp.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"baseApp.js","sourceRoot":"","sources":["../src/baseApp.ts"],"names":[],"mappings":";;;AAoBA,MAAsB,YAAY;IAY9B,KAAK,CACD,WAAmC,EACnC,OAAkF;QAClF,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,CAAO,WAAW,EAAE,OAAO,CAAC,CAAA;QAC/C,OAAO,IAAI,CAAA;IACf,CAAC;IAED,QAAQ;;QACJ,IAAI,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,IAAI,OAAO,EAAE,CAAA;QACzC,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACnB,MAAM,IAAI,aAAa,MAAA,IAAI,CAAC,WAAW,0CAAE,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;YAC5D,MAAM,IAAI,UAAU,CAAA,MAAA,IAAI,CAAC,WAAW,0CAAE,MAAM,CAAC,IAAI,CAAC,OAAO,EAAC,CAAC,CAAC,IAAI,IAAI,CAAC,MAAA,IAAI,CAAC,WAAW,0CAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAA;QAC7H,CAAC;QACD,OAAO,MAAM,CAAA;IACjB,CAAC;IAED,CAAC,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;QACtC,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,KAAK,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC;IAC3D,CAAC;CACJ;AA/BD,oCA+BC"}
@@ -1,19 +0,0 @@
1
- export interface SwaggerUiOptions {
2
- swaggerOptions?: any;
3
- customCss?: string | string[];
4
- customJs?: string | string[];
5
- customJsStr?: string | string[];
6
- customfavIcon?: string;
7
- customRobots?: string;
8
- swaggerUrl?: any;
9
- swaggerUrls?: any;
10
- explorer?: boolean;
11
- customSiteTitle?: string;
12
- customCssUrl?: string | string[];
13
- }
14
- export declare class SwaggerUiGenerator {
15
- #private;
16
- get swaggerInit(): string;
17
- getAbsoluteSwaggerFsPath(): string;
18
- generateHTML(swaggerDoc: any, opts: any, options?: any, customCss?: any, customfavIcon?: any, swaggerUrl?: any, customSiteTitle?: any, _htmlTplString?: any, _jsTplString?: any): any;
19
- }
@@ -1,245 +0,0 @@
1
- "use strict";
2
- var _SwaggerUiGenerator_swaggerInit;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.SwaggerUiGenerator = void 0;
5
- const tslib_1 = require("tslib");
6
- /* eslint-disable @typescript-eslint/no-explicit-any */
7
- const absolute_path_1 = tslib_1.__importDefault(require("swagger-ui-dist/absolute-path"));
8
- const favIconHtml = '<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />' +
9
- '<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />';
10
- const stringify = function (obj) {
11
- const placeholder = '____FUNCTIONPLACEHOLDER____';
12
- const fns = [];
13
- let json = JSON.stringify(obj, function (_key, value) {
14
- if (typeof value === 'function') {
15
- fns.push(value);
16
- return placeholder;
17
- }
18
- return value;
19
- }, 2);
20
- json = json.replace(new RegExp('"' + placeholder + '"', 'g'), function () {
21
- return fns.shift();
22
- });
23
- return 'var options = ' + json + ';';
24
- };
25
- const htmlTplString = `
26
- <!-- HTML for static distribution bundle build -->
27
- <!DOCTYPE html>
28
- <html lang="en">
29
- <head>
30
- <meta charset="UTF-8">
31
- <% robotsMetaString %>
32
- <title><% title %></title>
33
- <link rel="stylesheet" type="text/css" href="./swagger-ui.css" >
34
- <% favIconString %>
35
- <style>
36
- html
37
- {
38
- box-sizing: border-box;
39
- overflow: -moz-scrollbars-vertical;
40
- overflow-y: scroll;
41
- }
42
- *,
43
- *:before,
44
- *:after
45
- {
46
- box-sizing: inherit;
47
- }
48
-
49
- body {
50
- margin:0;
51
- background: #fafafa;
52
- }
53
- </style>
54
- </head>
55
-
56
- <body>
57
-
58
- <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="position:absolute;width:0;height:0">
59
- <defs>
60
- <symbol viewBox="0 0 20 20" id="unlocked">
61
- <path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V6h2v-.801C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8z"></path>
62
- </symbol>
63
-
64
- <symbol viewBox="0 0 20 20" id="locked">
65
- <path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8zM12 8H8V5.199C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8z"/>
66
- </symbol>
67
-
68
- <symbol viewBox="0 0 20 20" id="close">
69
- <path d="M14.348 14.849c-.469.469-1.229.469-1.697 0L10 11.819l-2.651 3.029c-.469.469-1.229.469-1.697 0-.469-.469-.469-1.229 0-1.697l2.758-3.15-2.759-3.152c-.469-.469-.469-1.228 0-1.697.469-.469 1.228-.469 1.697 0L10 8.183l2.651-3.031c.469-.469 1.228-.469 1.697 0 .469.469.469 1.229 0 1.697l-2.758 3.152 2.758 3.15c.469.469.469 1.229 0 1.698z"/>
70
- </symbol>
71
-
72
- <symbol viewBox="0 0 20 20" id="large-arrow">
73
- <path d="M13.25 10L6.109 2.58c-.268-.27-.268-.707 0-.979.268-.27.701-.27.969 0l7.83 7.908c.268.271.268.709 0 .979l-7.83 7.908c-.268.271-.701.27-.969 0-.268-.269-.268-.707 0-.979L13.25 10z"/>
74
- </symbol>
75
-
76
- <symbol viewBox="0 0 20 20" id="large-arrow-down">
77
- <path d="M17.418 6.109c.272-.268.709-.268.979 0s.271.701 0 .969l-7.908 7.83c-.27.268-.707.268-.979 0l-7.908-7.83c-.27-.268-.27-.701 0-.969.271-.268.709-.268.979 0L10 13.25l7.418-7.141z"/>
78
- </symbol>
79
-
80
-
81
- <symbol viewBox="0 0 24 24" id="jump-to">
82
- <path d="M19 7v4H5.83l3.58-3.59L8 6l-6 6 6 6 1.41-1.41L5.83 13H21V7z"/>
83
- </symbol>
84
-
85
- <symbol viewBox="0 0 24 24" id="expand">
86
- <path d="M10 18h4v-2h-4v2zM3 6v2h18V6H3zm3 7h12v-2H6v2z"/>
87
- </symbol>
88
-
89
- </defs>
90
- </svg>
91
-
92
- <div id="swagger-ui"></div>
93
-
94
- <script src="./swagger-ui-bundle.js"> </script>
95
- <script src="./swagger-ui-standalone-preset.js"> </script>
96
- <script src="./swagger-ui-init.js"> </script>
97
- <% customJs %>
98
- <% customJsStr %>
99
- <% customCssUrl %>
100
- <style>
101
- <% customCss %>
102
- </style>
103
- </body>
104
-
105
- </html>
106
- `;
107
- const jsTplString = `
108
- window.onload = function() {
109
- // Build a system
110
- var url = window.location.search.match(/url=([^&]+)/);
111
- if (url && url.length > 1) {
112
- url = decodeURIComponent(url[1]);
113
- } else {
114
- url = window.location.origin;
115
- }
116
- <% swaggerOptions %>
117
- url = options.swaggerUrl || url
118
- var urls = options.swaggerUrls
119
- var customOptions = options.customOptions
120
- var spec1 = options.swaggerDoc
121
- var swaggerOptions = {
122
- spec: spec1,
123
- url: url,
124
- urls: urls,
125
- dom_id: '#swagger-ui',
126
- deepLinking: true,
127
- presets: [
128
- SwaggerUIBundle.presets.apis,
129
- SwaggerUIStandalonePreset
130
- ],
131
- plugins: [
132
- SwaggerUIBundle.plugins.DownloadUrl
133
- ],
134
- layout: "StandaloneLayout"
135
- }
136
- for (var attrname in customOptions) {
137
- swaggerOptions[attrname] = customOptions[attrname];
138
- }
139
- var ui = SwaggerUIBundle(swaggerOptions)
140
-
141
- if (customOptions.oauth) {
142
- ui.initOAuth(customOptions.oauth)
143
- }
144
-
145
- if (customOptions.preauthorizeApiKey) {
146
- const key = customOptions.preauthorizeApiKey.authDefinitionKey;
147
- const value = customOptions.preauthorizeApiKey.apiKeyValue;
148
- if (!!key && !!value) {
149
- const pid = setInterval(() => {
150
- const authorized = ui.preauthorizeApiKey(key, value);
151
- if(!!authorized) clearInterval(pid);
152
- }, 500)
153
-
154
- }
155
- }
156
-
157
- if (customOptions.authAction) {
158
- ui.authActions.authorize(customOptions.authAction)
159
- }
160
-
161
- window.ui = ui
162
- }
163
- `;
164
- function toExternalScriptTag(url) {
165
- return `<script src='${url}'></script>`;
166
- }
167
- function toInlineScriptTag(jsCode) {
168
- return `<script>${jsCode}</script>`;
169
- }
170
- function toExternalStylesheetTag(url) {
171
- return `<link href='${url}' rel='stylesheet'>`;
172
- }
173
- function toTags(customCode, toScript) {
174
- if (typeof customCode === 'string') {
175
- return toScript(customCode);
176
- }
177
- else if (Array.isArray(customCode)) {
178
- return customCode.map(toScript).join('\n');
179
- }
180
- else {
181
- return '';
182
- }
183
- }
184
- class SwaggerUiGenerator {
185
- constructor() {
186
- _SwaggerUiGenerator_swaggerInit.set(this, '');
187
- }
188
- get swaggerInit() {
189
- return tslib_1.__classPrivateFieldGet(this, _SwaggerUiGenerator_swaggerInit, "f");
190
- }
191
- getAbsoluteSwaggerFsPath() {
192
- return (0, absolute_path_1.default)();
193
- }
194
- generateHTML(swaggerDoc, opts, options, customCss, customfavIcon, swaggerUrl, customSiteTitle, _htmlTplString, _jsTplString) {
195
- let isExplorer;
196
- let customJs;
197
- let customJsStr;
198
- let swaggerUrls;
199
- let customCssUrl;
200
- let customRobots;
201
- if (opts && typeof opts === 'object') {
202
- options = opts.swaggerOptions;
203
- customCss = opts.customCss;
204
- customJs = opts.customJs;
205
- customJsStr = opts.customJsStr;
206
- customfavIcon = opts.customfavIcon;
207
- customRobots = opts.customRobots;
208
- swaggerUrl = opts.swaggerUrl;
209
- swaggerUrls = opts.swaggerUrls;
210
- isExplorer = opts.explorer || !!swaggerUrls;
211
- customSiteTitle = opts.customSiteTitle;
212
- customCssUrl = opts.customCssUrl;
213
- }
214
- else {
215
- //support legacy params based function
216
- isExplorer = opts;
217
- }
218
- options = options || {};
219
- const explorerString = isExplorer ? '' : '.swagger-ui .topbar .download-url-wrapper { display: none }';
220
- customCss = explorerString + ' ' + customCss || explorerString;
221
- customfavIcon = customfavIcon || false;
222
- customSiteTitle = customSiteTitle || 'Swagger UI';
223
- _htmlTplString = _htmlTplString || htmlTplString;
224
- _jsTplString = _jsTplString || jsTplString;
225
- const robotsMetaString = customRobots ? '<meta name="robots" content="' + customRobots + '" />' : '';
226
- const favIconString = customfavIcon ? '<link rel="icon" href="' + customfavIcon + '" />' : favIconHtml;
227
- const htmlWithCustomCss = _htmlTplString.toString().replace('<% customCss %>', customCss);
228
- const htmlWithCustomRobots = htmlWithCustomCss.replace('<% robotsMetaString %>', robotsMetaString);
229
- const htmlWithFavIcon = htmlWithCustomRobots.replace('<% favIconString %>', favIconString);
230
- const htmlWithCustomJsUrl = htmlWithFavIcon.replace('<% customJs %>', toTags(customJs, toExternalScriptTag));
231
- const htmlWithCustomJs = htmlWithCustomJsUrl.replace('<% customJsStr %>', toTags(customJsStr, toInlineScriptTag));
232
- const htmlWithCustomCssUrl = htmlWithCustomJs.replace('<% customCssUrl %>', toTags(customCssUrl, toExternalStylesheetTag));
233
- const initOptions = {
234
- swaggerDoc: swaggerDoc || undefined,
235
- customOptions: options,
236
- swaggerUrl: swaggerUrl || undefined,
237
- swaggerUrls: swaggerUrls || undefined
238
- };
239
- tslib_1.__classPrivateFieldSet(this, _SwaggerUiGenerator_swaggerInit, _jsTplString.toString().replace('<% swaggerOptions %>', stringify(initOptions)), "f");
240
- return htmlWithCustomCssUrl.replace('<% title %>', customSiteTitle);
241
- }
242
- }
243
- exports.SwaggerUiGenerator = SwaggerUiGenerator;
244
- _SwaggerUiGenerator_swaggerInit = new WeakMap();
245
- //# sourceMappingURL=SwaggerUiGenerator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SwaggerUiGenerator.js","sourceRoot":"","sources":["../../../src/services/docs/SwaggerUiGenerator.ts"],"names":[],"mappings":";;;;;AAAA,uDAAuD;AACvD,0FAAoE;AAEpE,MAAM,WAAW,GAAG,+EAA+E;IAC/F,+EAA+E,CAAA;AAEnF,MAAM,SAAS,GAAG,UAAU,GAAQ;IAChC,MAAM,WAAW,GAAG,6BAA6B,CAAA;IACjD,MAAM,GAAG,GAAU,EAAE,CAAA;IACrB,IAAI,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,UAAU,IAAI,EAAE,KAAK;QAChD,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;YAC9B,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YACf,OAAO,WAAW,CAAA;QACtB,CAAC;QACD,OAAO,KAAK,CAAA;IAChB,CAAC,EAAE,CAAC,CAAC,CAAA;IACL,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,GAAG,GAAG,WAAW,GAAG,GAAG,EAAE,GAAG,CAAC,E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,gDAyEC"}
@@ -1,21 +0,0 @@
1
- export interface SwaggerUiOptions {
2
- swaggerOptions: any;
3
- customCss: string | string[];
4
- customJs: string | string[];
5
- customJsStr: string | string[];
6
- customfavIcon: string;
7
- customRobots: string;
8
- swaggerUrl: any;
9
- swaggerUrls: any;
10
- explorer: boolean;
11
- customSiteTitle: string;
12
- customCssUrl: string | string[];
13
- }
14
- export declare let swaggerInit: string;
15
- export declare function trimQuery(q: string): string;
16
- export declare const generateHTML: (swaggerDoc: any, opts: any, options?: any, customCss?: any, customfavIcon?: any, swaggerUrl?: any, customSiteTitle?: any, _htmlTplString?: any, _jsTplString?: any) => any;
17
- export declare const swaggerUi: {
18
- createHandler: (path: string, generateSchema: (req?: any) => any, opts?: SwaggerUiOptions) => (req: any, res: any) => void;
19
- handle: (req: any, res: any, config?: any) => boolean;
20
- setup: (swaggerDoc: any, opts?: any, options?: any, customCss?: any, customfavIcon?: any, swaggerUrl?: any, customSiteTitle?: any) => (req: any, res: any) => void;
21
- };
@@ -1,321 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.swaggerUi = exports.generateHTML = exports.swaggerInit = void 0;
4
- exports.trimQuery = trimQuery;
5
- const tslib_1 = require("tslib");
6
- /* eslint-disable @typescript-eslint/no-explicit-any */
7
- const absolute_path_1 = tslib_1.__importDefault(require("swagger-ui-dist/absolute-path"));
8
- const boom_1 = tslib_1.__importDefault(require("@hapi/boom"));
9
- const fs_1 = tslib_1.__importDefault(require("fs"));
10
- const favIconHtml = '<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />' +
11
- '<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />';
12
- exports.swaggerInit = '';
13
- const bootTime = Date.now();
14
- function trimQuery(q) {
15
- return q && q.split('?')[0];
16
- }
17
- const stringify = function (obj) {
18
- const placeholder = '____FUNCTIONPLACEHOLDER____';
19
- const fns = [];
20
- let json = JSON.stringify(obj, function (_key, value) {
21
- if (typeof value === 'function') {
22
- fns.push(value);
23
- return placeholder;
24
- }
25
- return value;
26
- }, 2);
27
- json = json.replace(new RegExp('"' + placeholder + '"', 'g'), function () {
28
- return fns.shift();
29
- });
30
- return 'var options = ' + json + ';';
31
- };
32
- const htmlTplString = `
33
- <!-- HTML for static distribution bundle build -->
34
- <!DOCTYPE html>
35
- <html lang="en">
36
- <head>
37
- <meta charset="UTF-8">
38
- <% robotsMetaString %>
39
- <title><% title %></title>
40
- <link rel="stylesheet" type="text/css" href="./swagger-ui.css" >
41
- <% favIconString %>
42
- <style>
43
- html
44
- {
45
- box-sizing: border-box;
46
- overflow: -moz-scrollbars-vertical;
47
- overflow-y: scroll;
48
- }
49
- *,
50
- *:before,
51
- *:after
52
- {
53
- box-sizing: inherit;
54
- }
55
-
56
- body {
57
- margin:0;
58
- background: #fafafa;
59
- }
60
- </style>
61
- </head>
62
-
63
- <body>
64
-
65
- <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="position:absolute;width:0;height:0">
66
- <defs>
67
- <symbol viewBox="0 0 20 20" id="unlocked">
68
- <path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V6h2v-.801C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8z"></path>
69
- </symbol>
70
-
71
- <symbol viewBox="0 0 20 20" id="locked">
72
- <path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8zM12 8H8V5.199C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8z"/>
73
- </symbol>
74
-
75
- <symbol viewBox="0 0 20 20" id="close">
76
- <path d="M14.348 14.849c-.469.469-1.229.469-1.697 0L10 11.819l-2.651 3.029c-.469.469-1.229.469-1.697 0-.469-.469-.469-1.229 0-1.697l2.758-3.15-2.759-3.152c-.469-.469-.469-1.228 0-1.697.469-.469 1.228-.469 1.697 0L10 8.183l2.651-3.031c.469-.469 1.228-.469 1.697 0 .469.469.469 1.229 0 1.697l-2.758 3.152 2.758 3.15c.469.469.469 1.229 0 1.698z"/>
77
- </symbol>
78
-
79
- <symbol viewBox="0 0 20 20" id="large-arrow">
80
- <path d="M13.25 10L6.109 2.58c-.268-.27-.268-.707 0-.979.268-.27.701-.27.969 0l7.83 7.908c.268.271.268.709 0 .979l-7.83 7.908c-.268.271-.701.27-.969 0-.268-.269-.268-.707 0-.979L13.25 10z"/>
81
- </symbol>
82
-
83
- <symbol viewBox="0 0 20 20" id="large-arrow-down">
84
- <path d="M17.418 6.109c.272-.268.709-.268.979 0s.271.701 0 .969l-7.908 7.83c-.27.268-.707.268-.979 0l-7.908-7.83c-.27-.268-.27-.701 0-.969.271-.268.709-.268.979 0L10 13.25l7.418-7.141z"/>
85
- </symbol>
86
-
87
-
88
- <symbol viewBox="0 0 24 24" id="jump-to">
89
- <path d="M19 7v4H5.83l3.58-3.59L8 6l-6 6 6 6 1.41-1.41L5.83 13H21V7z"/>
90
- </symbol>
91
-
92
- <symbol viewBox="0 0 24 24" id="expand">
93
- <path d="M10 18h4v-2h-4v2zM3 6v2h18V6H3zm3 7h12v-2H6v2z"/>
94
- </symbol>
95
-
96
- </defs>
97
- </svg>
98
-
99
- <div id="swagger-ui"></div>
100
-
101
- <script src="./swagger-ui-bundle.js"> </script>
102
- <script src="./swagger-ui-standalone-preset.js"> </script>
103
- <script src="./swagger-ui-init.js"> </script>
104
- <% customJs %>
105
- <% customJsStr %>
106
- <% customCssUrl %>
107
- <style>
108
- <% customCss %>
109
- </style>
110
- </body>
111
-
112
- </html>
113
- `;
114
- const jsTplString = `
115
- window.onload = function() {
116
- // Build a system
117
- var url = window.location.search.match(/url=([^&]+)/);
118
- if (url && url.length > 1) {
119
- url = decodeURIComponent(url[1]);
120
- } else {
121
- url = window.location.origin;
122
- }
123
- <% swaggerOptions %>
124
- url = options.swaggerUrl || url
125
- var urls = options.swaggerUrls
126
- var customOptions = options.customOptions
127
- var spec1 = options.swaggerDoc
128
- var swaggerOptions = {
129
- spec: spec1,
130
- url: url,
131
- urls: urls,
132
- dom_id: '#swagger-ui',
133
- deepLinking: true,
134
- presets: [
135
- SwaggerUIBundle.presets.apis,
136
- SwaggerUIStandalonePreset
137
- ],
138
- plugins: [
139
- SwaggerUIBundle.plugins.DownloadUrl
140
- ],
141
- layout: "StandaloneLayout"
142
- }
143
- for (var attrname in customOptions) {
144
- swaggerOptions[attrname] = customOptions[attrname];
145
- }
146
- var ui = SwaggerUIBundle(swaggerOptions)
147
-
148
- if (customOptions.oauth) {
149
- ui.initOAuth(customOptions.oauth)
150
- }
151
-
152
- if (customOptions.preauthorizeApiKey) {
153
- const key = customOptions.preauthorizeApiKey.authDefinitionKey;
154
- const value = customOptions.preauthorizeApiKey.apiKeyValue;
155
- if (!!key && !!value) {
156
- const pid = setInterval(() => {
157
- const authorized = ui.preauthorizeApiKey(key, value);
158
- if(!!authorized) clearInterval(pid);
159
- }, 500)
160
-
161
- }
162
- }
163
-
164
- if (customOptions.authAction) {
165
- ui.authActions.authorize(customOptions.authAction)
166
- }
167
-
168
- window.ui = ui
169
- }
170
- `;
171
- function toExternalScriptTag(url) {
172
- return `<script src='${url}'></script>`;
173
- }
174
- function toInlineScriptTag(jsCode) {
175
- return `<script>${jsCode}</script>`;
176
- }
177
- function toExternalStylesheetTag(url) {
178
- return `<link href='${url}' rel='stylesheet'>`;
179
- }
180
- function toTags(customCode, toScript) {
181
- if (typeof customCode === 'string') {
182
- return toScript(customCode);
183
- }
184
- else if (Array.isArray(customCode)) {
185
- return customCode.map(toScript).join('\n');
186
- }
187
- else {
188
- return '';
189
- }
190
- }
191
- const generateHTML = function (swaggerDoc, opts, options, customCss, customfavIcon, swaggerUrl, customSiteTitle, _htmlTplString, _jsTplString) {
192
- let isExplorer;
193
- let customJs;
194
- let customJsStr;
195
- let swaggerUrls;
196
- let customCssUrl;
197
- let customRobots;
198
- if (opts && typeof opts === 'object') {
199
- options = opts.swaggerOptions;
200
- customCss = opts.customCss;
201
- customJs = opts.customJs;
202
- customJsStr = opts.customJsStr;
203
- customfavIcon = opts.customfavIcon;
204
- customRobots = opts.customRobots;
205
- swaggerUrl = opts.swaggerUrl;
206
- swaggerUrls = opts.swaggerUrls;
207
- isExplorer = opts.explorer || !!swaggerUrls;
208
- customSiteTitle = opts.customSiteTitle;
209
- customCssUrl = opts.customCssUrl;
210
- }
211
- else {
212
- //support legacy params based function
213
- isExplorer = opts;
214
- }
215
- options = options || {};
216
- const explorerString = isExplorer ? '' : '.swagger-ui .topbar .download-url-wrapper { display: none }';
217
- customCss = explorerString + ' ' + customCss || explorerString;
218
- customfavIcon = customfavIcon || false;
219
- customSiteTitle = customSiteTitle || 'Swagger UI';
220
- _htmlTplString = _htmlTplString || htmlTplString;
221
- _jsTplString = _jsTplString || jsTplString;
222
- const robotsMetaString = customRobots ? '<meta name="robots" content="' + customRobots + '" />' : '';
223
- const favIconString = customfavIcon ? '<link rel="icon" href="' + customfavIcon + '" />' : favIconHtml;
224
- const htmlWithCustomCss = _htmlTplString.toString().replace('<% customCss %>', customCss);
225
- const htmlWithCustomRobots = htmlWithCustomCss.replace('<% robotsMetaString %>', robotsMetaString);
226
- const htmlWithFavIcon = htmlWithCustomRobots.replace('<% favIconString %>', favIconString);
227
- const htmlWithCustomJsUrl = htmlWithFavIcon.replace('<% customJs %>', toTags(customJs, toExternalScriptTag));
228
- const htmlWithCustomJs = htmlWithCustomJsUrl.replace('<% customJsStr %>', toTags(customJsStr, toInlineScriptTag));
229
- const htmlWithCustomCssUrl = htmlWithCustomJs.replace('<% customCssUrl %>', toTags(customCssUrl, toExternalStylesheetTag));
230
- const initOptions = {
231
- swaggerDoc: swaggerDoc || undefined,
232
- customOptions: options,
233
- swaggerUrl: swaggerUrl || undefined,
234
- swaggerUrls: swaggerUrls || undefined
235
- };
236
- exports.swaggerInit = _jsTplString.toString().replace('<% swaggerOptions %>', stringify(initOptions));
237
- return htmlWithCustomCssUrl.replace('<% title %>', customSiteTitle);
238
- };
239
- exports.generateHTML = generateHTML;
240
- const setup = function (swaggerDoc, opts, options, customCss, customfavIcon, swaggerUrl, customSiteTitle) {
241
- const html = (0, exports.generateHTML)(swaggerDoc, opts, options, customCss, customfavIcon, swaggerUrl, customSiteTitle, htmlTplString, jsTplString);
242
- return function (req, res) {
243
- if (req.swaggerDoc) {
244
- const reqHtml = (0, exports.generateHTML)(req.swaggerDoc, opts, options, customCss, customfavIcon, swaggerUrl, customSiteTitle, htmlTplString, jsTplString);
245
- res(reqHtml);
246
- }
247
- else {
248
- res(html);
249
- }
250
- };
251
- };
252
- const handle = function (req, res, config) {
253
- if (trimQuery(req.url.pathname).endsWith('/package.json')) {
254
- res(boom_1.default.notFound());
255
- return true;
256
- }
257
- else if (trimQuery(req.url.pathname).endsWith('/swagger-ui-init.js')) {
258
- res(exports.swaggerInit).header('Content-Type', 'application/javascript');
259
- return true;
260
- }
261
- try {
262
- const cacheDuration = 24 * 60 * 60 * 1000; // ms
263
- const assetsPath = (config === null || config === void 0 ? void 0 : config.assetsPath) && typeof config.assetsPath == 'string' &&
264
- trimQuery(req.url.pathname).indexOf(config.assetsPath) == 0 ? config.assetsPath : '';
265
- const posFileName = trimQuery(req.url.pathname).lastIndexOf('/');
266
- let filepath = '';
267
- const assetFile = __dirname + '/../../assets'
268
- + trimQuery(req.url.pathname).substring(assetsPath.length);
269
- const swaggerUiFile = (0, absolute_path_1.default)()
270
- + trimQuery(req.url.pathname).substring(posFileName > -1 ? posFileName : 0);
271
- //const projectFiles = process.cwd() + trimQuery(req.url.pathname)
272
- if (fs_1.default.existsSync(assetFile)) {
273
- filepath = assetFile;
274
- }
275
- else if (fs_1.default.existsSync(swaggerUiFile)) {
276
- filepath = swaggerUiFile;
277
- }
278
- if (filepath) {
279
- let readStreamOptions = { encoding: 'utf-8' };
280
- let cT = 'application/octet-stream';
281
- if (filepath.endsWith('.js')) {
282
- cT = 'application/javascript';
283
- }
284
- else if (filepath.endsWith('.css')) {
285
- cT = 'text/css';
286
- }
287
- else if (filepath.endsWith('.png')) {
288
- readStreamOptions = {};
289
- cT = 'image/png';
290
- }
291
- res(fs_1.default.createReadStream(filepath, readStreamOptions))
292
- .ttl(cacheDuration).header('Last-Modified', (new Date(bootTime)).toUTCString()).header('Content-Type', cT);
293
- return true;
294
- }
295
- }
296
- catch (e) {
297
- console.error(e);
298
- }
299
- return false;
300
- };
301
- const createHandler = function (path, generateSchema, opts) {
302
- // set assets at same path than html
303
- const assetsPath = path.lastIndexOf('/') > 0 ? path.substring(0, path.lastIndexOf('/')) : '';
304
- return (req, res) => {
305
- if (req.url.pathname == path) {
306
- setup(generateSchema(), opts)(req, res);
307
- }
308
- else if (req.url.pathname == `${path}${path.endsWith('/') ? '' : '/'}schema`) {
309
- res(generateSchema(req));
310
- }
311
- else if (!handle(req, res, { assetsPath })) {
312
- res(boom_1.default.notFound());
313
- }
314
- };
315
- };
316
- exports.swaggerUi = {
317
- createHandler: createHandler,
318
- handle: handle,
319
- setup: setup
320
- };
321
- //# sourceMappingURL=swagger-ui.js.map