@kaapi/kaapi 0.0.2

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.
@@ -0,0 +1,321 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swagger-ui.js","sourceRoot":"","sources":["../../../../src/services/docs/ui/swagger-ui.ts"],"names":[],"mappings":";;;AAyBA,8BAEC;;AA3BD,uDAAuD;AACvD,0FAAoE;AACpE,8DAA6B;AAC7B,oDAAmB;AAgBnB,MAAM,WAAW,GAAG,+EAA+E;IAC/F,+EAA+E,CAAA;AACxE,QAAA,WAAW,GAAG,EAAE,CAAA;AAE3B,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;AAE5B,SAAgB,SAAS,CAAC,CAAS;IAC/B,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,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AAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAE;IAC9F,OAAO,CAAC,GAAQ,EAAE,GAAQ,EAAE,EAAE;QAC1B,IAAI,GAAG,CAAC,GAAG,CAAC,QAAQ,IAAI,IAAI,EAAE,CAAC;YAC3B,KAAK,CAAC,cAAc,EAAE,EAAE,IAAI,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;QAC3C,CAAC;aAAM,IAAI,GAAG,CAAC,GAAG,CAAC,QAAQ,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,QAAQ,EAAE,CAAC;YAC7E,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAA;QAC5B,CAAC;aAAM,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC;YAC3C,GAAG,CAAC,cAAI,CAAC,QAAQ,EAAE,CAAC,CAAA;QACxB,CAAC;IACL,CAAC,CAAA;AACL,CAAC,CAAA;AAEY,QAAA,SAAS,GAAG;IACrB,aAAa,EAAE,aAAa;IAC5B,MAAM,EAAE,MAAM;IACd,KAAK,EAAE,KAAK;CACf,CAAA"}
@@ -0,0 +1,13 @@
1
+ import winston from 'winston';
2
+ export interface ILogger {
3
+ (...args: unknown[]): void;
4
+ silly: (...args: unknown[]) => void;
5
+ debug: (...args: unknown[]) => void;
6
+ verbose: (...args: unknown[]) => void;
7
+ info: (...args: unknown[]) => void;
8
+ warn: (...args: unknown[]) => void;
9
+ warning: (...args: unknown[]) => void;
10
+ err: (...args: unknown[]) => void;
11
+ error: (...args: unknown[]) => void;
12
+ }
13
+ export declare function createLogger(options?: winston.LoggerOptions): ILogger;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createLogger = createLogger;
4
+ const tslib_1 = require("tslib");
5
+ const winston_1 = tslib_1.__importDefault(require("winston"));
6
+ function wrap(loggerFn) {
7
+ return (...args) => {
8
+ loggerFn(args.map(a => {
9
+ if (a instanceof Error)
10
+ return a.stack;
11
+ try {
12
+ if (typeof a != 'string')
13
+ a = JSON.stringify(a);
14
+ }
15
+ catch (_e) {
16
+ try {
17
+ if (typeof a != 'string')
18
+ a = a === null || a === void 0 ? void 0 : a.toString();
19
+ }
20
+ catch (_e) {
21
+ //
22
+ }
23
+ }
24
+ return a;
25
+ }).join(' '));
26
+ };
27
+ }
28
+ function createLogger(options) {
29
+ const wlogger = winston_1.default.createLogger(options);
30
+ return Object.assign(wrap(wlogger.debug), {
31
+ silly: wrap(wlogger.silly),
32
+ debug: wrap(wlogger.debug),
33
+ verbose: wrap(wlogger.verbose),
34
+ info: wrap(wlogger.info),
35
+ warn: wrap(wlogger.warn),
36
+ warning: wrap(wlogger.warn),
37
+ err: wrap(wlogger.error),
38
+ error: wrap(wlogger.error)
39
+ });
40
+ }
41
+ //# sourceMappingURL=log.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.js","sourceRoot":"","sources":["../../src/services/log.ts"],"names":[],"mappings":";;AAgCA,oCAgBC;;AAhDD,8DAA8B;AAc9B,SAAS,IAAI,CAAC,QAAkC;IAC5C,OAAO,CAAC,GAAG,IAAe,EAAE,EAAE;QAC1B,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;YAClB,IAAI,CAAC,YAAY,KAAK;gBAAE,OAAO,CAAC,CAAC,KAAK,CAAC;YACvC,IAAI,CAAC;gBACD,IAAI,OAAO,CAAC,IAAI,QAAQ;oBAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YACpD,CAAC;YAAC,OAAO,EAAE,EAAE,CAAC;gBACV,IAAI,CAAC;oBACD,IAAI,OAAO,CAAC,IAAI,QAAQ;wBAAE,CAAC,GAAG,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,QAAQ,EAAE,CAAC;gBAChD,CAAC;gBAAC,OAAO,EAAE,EAAE,CAAC;oBACV,EAAE;gBACN,CAAC;YACL,CAAC;YACD,OAAO,CAAC,CAAC;QACb,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAClB,CAAC,CAAA;AACL,CAAC;AAED,SAAgB,YAAY,CAAC,OAA+B;IACxD,MAAM,OAAO,GAAG,iBAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAE9C,OAAO,MAAM,CAAC,MAAM,CAChB,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EACnB;QACI,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;QAC1B,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;QAC1B,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QAC9B,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;QACxB,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;QACxB,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;QAC3B,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;QACxB,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;KAC7B,CACJ,CAAA;AACL,CAAC"}
@@ -0,0 +1,17 @@
1
+ export interface IMessagingSender {
2
+ id?: string;
3
+ name?: string;
4
+ timestamp?: string;
5
+ [x: string]: string | undefined;
6
+ }
7
+ export type IMessagingSubscribeConfig = object;
8
+ export interface IPublishMethod {
9
+ <T = unknown>(topic: string, message: T): Promise<void>;
10
+ }
11
+ export interface ISubscribeMethod {
12
+ <T = unknown>(topic: string, handler: (message: T, sender: IMessagingSender) => Promise<void> | void, conf?: IMessagingSubscribeConfig): Promise<void>;
13
+ }
14
+ export interface IMessaging {
15
+ publish<T = unknown>(topic: string, message: T): Promise<void>;
16
+ subscribe<T = unknown>(topic: string, handler: (message: T, sender: IMessagingSender) => Promise<void> | void, conf?: IMessagingSubscribeConfig): Promise<void>;
17
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=messaging.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messaging.js","sourceRoot":"","sources":["../../src/services/messaging.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@kaapi/kaapi",
3
+ "version": "0.0.2",
4
+ "private": false,
5
+ "description": "kaapi",
6
+ "main": "lib/index.js",
7
+ "author": "demingongo",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/demingongo/kaapi.git",
11
+ "directory": "packages/kaapi"
12
+ },
13
+ "license": "MIT",
14
+ "devDependencies": {
15
+ "@eslint/eslintrc": "^3.3.1",
16
+ "@eslint/js": "^9.30.0",
17
+ "@stylistic/eslint-plugin": "^5.0.0",
18
+ "@types/node": "^24.0.7",
19
+ "@types/qs": "^6.14.0",
20
+ "@types/swagger-ui-dist": "^3.30.6",
21
+ "@typescript-eslint/eslint-plugin": "^8.35.0",
22
+ "@typescript-eslint/parser": "^8.35.0",
23
+ "eslint": "^9.30.0",
24
+ "globals": "^16.2.0",
25
+ "nodemon": "^3.1.10",
26
+ "ts-node": "^10.9.2",
27
+ "typescript": "^5.8.3",
28
+ "typescript-eslint": "^8.35.0"
29
+ },
30
+ "dependencies": {
31
+ "@hapi/boom": "^10.0.1",
32
+ "@hapi/hapi": "^21.4.0",
33
+ "@hapi/hoek": "^11.0.7",
34
+ "@hapi/inert": "^7.1.0",
35
+ "@kaapi/server": "^0.0.2",
36
+ "@novice1/api-doc-generator": "^1.0.2",
37
+ "@novice1/routing": "^2.0.2",
38
+ "qs": "^6.14.0",
39
+ "swagger-ui-dist": "^5.25.3",
40
+ "tslib": "^2.8.1",
41
+ "winston": "^3.17.0"
42
+ },
43
+ "scripts": {
44
+ "lint": "eslint .",
45
+ "build": "tsc && node ./scripts/buildDT.mjs",
46
+ "test": "echo \"Error: no test specified\" && exit 1"
47
+ }
48
+ }
@@ -0,0 +1,11 @@
1
+ declare module '@hapi/hapi' {
2
+ interface PluginSpecificConfiguration {
3
+ kaapi?: {
4
+ docs?: {
5
+ disabled?: boolean;
6
+ } | false
7
+ };
8
+ }
9
+ }
10
+
11
+ export {}