@nu-art/bug-report-backend 0.401.8 → 0.500.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,5 +1,5 @@
1
1
  import { Module } from '@nu-art/ts-common';
2
- import { DB_BugReport, Paths } from '@nu-art/bug-report-shared/api';
2
+ import { API_AdminBugReport, DB_BugReport, Paths } from '@nu-art/bug-report-shared/api';
3
3
  type Config = {
4
4
  projectId: string;
5
5
  bucket?: string;
@@ -9,6 +9,8 @@ export declare class ModuleBE_AdminBR_Class extends Module<Config> {
9
9
  private storage;
10
10
  constructor();
11
11
  protected init(): void;
12
+ retrieveLogs(_params?: API_AdminBugReport['retrieveLogs']['Params']): Promise<API_AdminBugReport['retrieveLogs']['Response']>;
13
+ downloadLogs(body: API_AdminBugReport['downloadLogs']['Body']): Promise<API_AdminBugReport['downloadLogs']['Response']>;
12
14
  getFilesFirebase: () => Promise<DB_BugReport[]>;
13
15
  downloadFiles: (path: Paths) => Promise<{
14
16
  fileName: string;
@@ -16,32 +16,83 @@
16
16
  * See the License for the specific language governing permissions and
17
17
  * limitations under the License.
18
18
  */
19
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
20
+ var useValue = arguments.length > 2;
21
+ for (var i = 0; i < initializers.length; i++) {
22
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
23
+ }
24
+ return useValue ? value : void 0;
25
+ };
26
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
27
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
28
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
29
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
30
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
31
+ var _, done = false;
32
+ for (var i = decorators.length - 1; i >= 0; i--) {
33
+ var context = {};
34
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
35
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
36
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
37
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
38
+ if (kind === "accessor") {
39
+ if (result === void 0) continue;
40
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
41
+ if (_ = accept(result.get)) descriptor.get = _;
42
+ if (_ = accept(result.set)) descriptor.set = _;
43
+ if (_ = accept(result.init)) initializers.unshift(_);
44
+ }
45
+ else if (_ = accept(result)) {
46
+ if (kind === "field") initializers.unshift(_);
47
+ else descriptor[key] = _;
48
+ }
49
+ }
50
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
51
+ done = true;
52
+ };
19
53
  import { Module } from '@nu-art/ts-common';
20
54
  import { ApiDef_AdminBugReport } from '@nu-art/bug-report-shared/api';
21
55
  import { ModuleBE_Firebase } from '@nu-art/firebase-backend/v1';
22
- import { addRoutes, createBodyServerApi, createQueryServerApi } from '@nu-art/thunderstorm-backend';
23
- export class ModuleBE_AdminBR_Class extends Module {
24
- bugReport;
25
- storage;
26
- constructor() {
27
- super();
28
- }
29
- init() {
30
- super.init();
31
- const sessAdmin = ModuleBE_Firebase.createAdminSession();
32
- const firestore = sessAdmin.getFirestore();
33
- this.bugReport = firestore.getCollection('bug-report', ['_id']);
34
- this.storage = sessAdmin.getStorage();
35
- addRoutes([
36
- createBodyServerApi(ApiDef_AdminBugReport.v1.downloadLogs, ModuleBE_AdminBR.downloadFiles),
37
- createQueryServerApi(ApiDef_AdminBugReport.v1.retrieveLogs, ModuleBE_AdminBR.getFilesFirebase),
38
- ]);
39
- }
40
- getFilesFirebase = async () => this.bugReport.getAll();
41
- downloadFiles = async (path) => {
42
- const bucket = await this.storage.getOrCreateBucket(this.config?.bucket);
43
- const file = await bucket.getFile(path.path);
44
- return file.getReadSignedUrl(600000, 'application/zip');
56
+ import { ApiHandler } from '@nu-art/http-server';
57
+ let ModuleBE_AdminBR_Class = (() => {
58
+ let _classSuper = Module;
59
+ let _instanceExtraInitializers = [];
60
+ let _retrieveLogs_decorators;
61
+ let _downloadLogs_decorators;
62
+ return class ModuleBE_AdminBR_Class extends _classSuper {
63
+ static {
64
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
65
+ _retrieveLogs_decorators = [ApiHandler(ApiDef_AdminBugReport.retrieveLogs)];
66
+ _downloadLogs_decorators = [ApiHandler(ApiDef_AdminBugReport.downloadLogs)];
67
+ __esDecorate(this, null, _retrieveLogs_decorators, { kind: "method", name: "retrieveLogs", static: false, private: false, access: { has: obj => "retrieveLogs" in obj, get: obj => obj.retrieveLogs }, metadata: _metadata }, null, _instanceExtraInitializers);
68
+ __esDecorate(this, null, _downloadLogs_decorators, { kind: "method", name: "downloadLogs", static: false, private: false, access: { has: obj => "downloadLogs" in obj, get: obj => obj.downloadLogs }, metadata: _metadata }, null, _instanceExtraInitializers);
69
+ if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
70
+ }
71
+ bugReport = __runInitializers(this, _instanceExtraInitializers);
72
+ storage;
73
+ constructor() {
74
+ super();
75
+ }
76
+ init() {
77
+ super.init();
78
+ const sessAdmin = ModuleBE_Firebase.createAdminSession();
79
+ const firestore = sessAdmin.getFirestore();
80
+ this.bugReport = firestore.getCollection('bug-report', ['_id']);
81
+ this.storage = sessAdmin.getStorage();
82
+ }
83
+ async retrieveLogs(_params) {
84
+ return this.bugReport.getAll();
85
+ }
86
+ async downloadLogs(body) {
87
+ return ModuleBE_AdminBR.downloadFiles(body);
88
+ }
89
+ getFilesFirebase = async () => this.bugReport.getAll();
90
+ downloadFiles = async (path) => {
91
+ const bucket = await this.storage.getOrCreateBucket(this.config?.bucket);
92
+ const file = await bucket.getFile(path.path);
93
+ return file.getReadSignedUrl(600000, 'application/zip');
94
+ };
45
95
  };
46
- }
96
+ })();
97
+ export { ModuleBE_AdminBR_Class };
47
98
  export const ModuleBE_AdminBR = new ModuleBE_AdminBR_Class();
@@ -1,5 +1,5 @@
1
1
  import { Module } from '@nu-art/ts-common';
2
- import { BugReport, ReportLogFile, Request_BugReport, TicketDetails } from '@nu-art/bug-report-shared';
2
+ import { API_BugReport, BugReport, ReportLogFile, Request_BugReport, TicketDetails } from '@nu-art/bug-report-shared';
3
3
  type Config = {
4
4
  projectId?: string;
5
5
  bucket?: string;
@@ -11,7 +11,7 @@ export declare class ModuleBE_BugReport_Class extends Module<Config> {
11
11
  private ticketCreatorApis;
12
12
  constructor();
13
13
  protected init(): void;
14
- private sendBugReport;
14
+ sendBugReport(body: API_BugReport['sendBugReport']['Body']): Promise<API_BugReport['sendBugReport']['Response']>;
15
15
  addTicketCreator(ticketCreator: TicketCreatorApi): void;
16
16
  saveLog: (report: BugReport, id: string) => Promise<ReportLogFile>;
17
17
  saveFile: (bugReport: Request_BugReport, email?: string) => Promise<TicketDetails[]>;
@@ -16,66 +16,109 @@
16
16
  * See the License for the specific language governing permissions and
17
17
  * limitations under the License.
18
18
  */
19
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
20
+ var useValue = arguments.length > 2;
21
+ for (var i = 0; i < initializers.length; i++) {
22
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
23
+ }
24
+ return useValue ? value : void 0;
25
+ };
26
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
27
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
28
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
29
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
30
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
31
+ var _, done = false;
32
+ for (var i = decorators.length - 1; i >= 0; i--) {
33
+ var context = {};
34
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
35
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
36
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
37
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
38
+ if (kind === "accessor") {
39
+ if (result === void 0) continue;
40
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
41
+ if (_ = accept(result.get)) descriptor.get = _;
42
+ if (_ = accept(result.set)) descriptor.set = _;
43
+ if (_ = accept(result.init)) initializers.unshift(_);
44
+ }
45
+ else if (_ = accept(result)) {
46
+ if (kind === "field") initializers.unshift(_);
47
+ else descriptor[key] = _;
48
+ }
49
+ }
50
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
51
+ done = true;
52
+ };
19
53
  import { addItemToArray, auditBy, currentTimeMillis, filterInstances, generateHex, Module, padNumber } from '@nu-art/ts-common';
20
54
  import { ModuleBE_Firebase } from '@nu-art/firebase-backend/v1';
21
- import { addRoutes, createBodyServerApi } from '@nu-art/thunderstorm-backend';
55
+ import { ApiHandler } from '@nu-art/http-server';
22
56
  import JSZip from 'jszip';
23
57
  import { ApiDef_BugReport } from '@nu-art/bug-report-shared';
24
- import { MemKey_AccountId } from '@nu-art/user-account-backend/_entity/session/index';
25
- export class ModuleBE_BugReport_Class extends Module {
26
- bugReport;
27
- storage;
28
- ticketCreatorApis = [];
29
- constructor() {
30
- super();
31
- }
32
- init() {
33
- const sessionAdmin = ModuleBE_Firebase.createAdminSession();
34
- const firestore = sessionAdmin.getFirestore();
35
- this.bugReport = firestore.getCollection('bug-report', ['_id']);
36
- this.storage = sessionAdmin.getStorage();
37
- addRoutes([
38
- createBodyServerApi(ApiDef_BugReport.v1.sendBugReport, (body) => this.sendBugReport(body)),
39
- ]);
40
- }
41
- sendBugReport = async (body) => {
42
- return await ModuleBE_BugReport.saveFile(body, MemKey_AccountId.get());
43
- };
44
- addTicketCreator(ticketCreator) {
45
- addItemToArray(this.ticketCreatorApis, ticketCreator);
46
- }
47
- saveLog = async (report, id) => {
48
- const zip = new JSZip();
49
- report.log.forEach((message, i) => zip.file(`${report.name}_${padNumber(i, 2)}.txt`, message));
50
- const buffer = await zip.generateAsync({ type: 'nodebuffer' });
51
- const bucket = await this.storage.getOrCreateBucket(this.config?.bucket);
52
- const fileName = `${id}-${report.name}.zip`;
53
- const file = await bucket.getFile(fileName);
54
- await file.write(buffer);
55
- return {
56
- path: `https://storage.cloud.google.com/${file.file.metadata.bucket}/${file.file.metadata.name}`,
57
- name: fileName
58
+ import { MemKey_AccountId } from '@nu-art/user-account-backend';
59
+ let ModuleBE_BugReport_Class = (() => {
60
+ let _classSuper = Module;
61
+ let _instanceExtraInitializers = [];
62
+ let _sendBugReport_decorators;
63
+ return class ModuleBE_BugReport_Class extends _classSuper {
64
+ static {
65
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
66
+ _sendBugReport_decorators = [ApiHandler(ApiDef_BugReport.sendBugReport)];
67
+ __esDecorate(this, null, _sendBugReport_decorators, { kind: "method", name: "sendBugReport", static: false, private: false, access: { has: obj => "sendBugReport" in obj, get: obj => obj.sendBugReport }, metadata: _metadata }, null, _instanceExtraInitializers);
68
+ if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
69
+ }
70
+ bugReport = __runInitializers(this, _instanceExtraInitializers);
71
+ storage;
72
+ ticketCreatorApis = [];
73
+ constructor() {
74
+ super();
75
+ }
76
+ init() {
77
+ const sessionAdmin = ModuleBE_Firebase.createAdminSession();
78
+ const firestore = sessionAdmin.getFirestore();
79
+ this.bugReport = firestore.getCollection('bug-report', ['_id']);
80
+ this.storage = sessionAdmin.getStorage();
81
+ }
82
+ async sendBugReport(body) {
83
+ return await ModuleBE_BugReport.saveFile(body, MemKey_AccountId.get());
84
+ }
85
+ addTicketCreator(ticketCreator) {
86
+ addItemToArray(this.ticketCreatorApis, ticketCreator);
87
+ }
88
+ saveLog = async (report, id) => {
89
+ const zip = new JSZip();
90
+ report.log.forEach((message, i) => zip.file(`${report.name}_${padNumber(i, 2)}.txt`, message));
91
+ const buffer = await zip.generateAsync({ type: 'nodebuffer' });
92
+ const bucket = await this.storage.getOrCreateBucket(this.config?.bucket);
93
+ const fileName = `${id}-${report.name}.zip`;
94
+ const file = await bucket.getFile(fileName);
95
+ await file.write(buffer);
96
+ return {
97
+ path: `https://storage.cloud.google.com/${file.file.metadata.bucket}/${file.file.metadata.name}`,
98
+ name: fileName
99
+ };
58
100
  };
59
- };
60
- saveFile = async (bugReport, email) => {
61
- const _id = generateHex(16);
62
- const logs = await Promise.all(bugReport.reports.map(report => this.saveLog(report, _id)));
63
- const now = currentTimeMillis();
64
- const instance = {
65
- _id,
66
- __created: now,
67
- __updated: now,
68
- subject: bugReport.subject,
69
- description: bugReport.description,
70
- reports: logs,
71
- _audit: auditBy(email || 'bug-report'),
101
+ saveFile = async (bugReport, email) => {
102
+ const _id = generateHex(16);
103
+ const logs = await Promise.all(bugReport.reports.map(report => this.saveLog(report, _id)));
104
+ const now = currentTimeMillis();
105
+ const instance = {
106
+ _id,
107
+ __created: now,
108
+ __updated: now,
109
+ subject: bugReport.subject,
110
+ description: bugReport.description,
111
+ reports: logs,
112
+ _audit: auditBy(email || 'bug-report'),
113
+ };
114
+ if (this.config?.bucket)
115
+ instance.bucket = this.config.bucket;
116
+ const tickets = await Promise.all(this.ticketCreatorApis.map(api => api(bugReport, logs, email)));
117
+ instance.tickets = filterInstances(tickets);
118
+ await this.bugReport.insert(instance);
119
+ return instance.tickets;
72
120
  };
73
- if (this.config?.bucket)
74
- instance.bucket = this.config.bucket;
75
- const tickets = await Promise.all(this.ticketCreatorApis.map(api => api(bugReport, logs, email)));
76
- instance.tickets = filterInstances(tickets);
77
- await this.bugReport.insert(instance);
78
- return instance.tickets;
79
121
  };
80
- }
122
+ })();
123
+ export { ModuleBE_BugReport_Class };
81
124
  export const ModuleBE_BugReport = new ModuleBE_BugReport_Class();
@@ -30,7 +30,7 @@ export class SlackBugReportIntegrator_Class extends Module {
30
30
  }, bugReport.subject + '\n' + bugReport.description);
31
31
  if (reporter)
32
32
  description += '\nReported by: ' + reporter;
33
- await ModuleBE_Slack.postMessage(description, this.config.channel);
33
+ await ModuleBE_Slack.sendText(description, this.config.channel);
34
34
  return { platform: Platform_Slack, issueId: generateHex(32) };
35
35
  };
36
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nu-art/bug-report-backend",
3
- "version": "0.401.8",
3
+ "version": "0.500.0",
4
4
  "description": "Bug Report Backend",
5
5
  "keywords": [
6
6
  "TacB0sS",
@@ -29,18 +29,16 @@
29
29
  "build": "tsc"
30
30
  },
31
31
  "dependencies": {
32
- "@nu-art/bug-report-shared": "0.401.8",
33
- "@nu-art/firebase-backend": "0.401.8",
34
- "@nu-art/firebase-shared": "0.401.8",
35
- "@nu-art/jira-backend": "0.401.8",
36
- "@nu-art/jira-shared": "0.401.8",
37
- "@nu-art/slack-backend": "0.401.8",
38
- "@nu-art/slack-shared": "0.401.8",
39
- "@nu-art/thunderstorm-backend": "0.401.8",
40
- "@nu-art/thunderstorm-shared": "0.401.8",
41
- "@nu-art/ts-common": "0.401.8",
42
- "@nu-art/user-account-backend": "0.401.8",
43
- "@nu-art/user-account-shared": "0.401.8",
32
+ "@nu-art/bug-report-shared": "0.500.0",
33
+ "@nu-art/firebase-backend": "0.500.0",
34
+ "@nu-art/firebase-shared": "0.500.0",
35
+ "@nu-art/jira-backend": "0.500.0",
36
+ "@nu-art/jira-shared": "0.500.0",
37
+ "@nu-art/slack-backend": "0.500.0",
38
+ "@nu-art/slack-shared": "0.500.0",
39
+ "@nu-art/ts-common": "0.500.0",
40
+ "@nu-art/user-account-backend": "0.500.0",
41
+ "@nu-art/user-account-shared": "0.500.0",
44
42
  "express": "^4.18.2",
45
43
  "firebase": "^11.9.0",
46
44
  "firebase-admin": "13.4.0",
@@ -48,7 +46,9 @@
48
46
  "moment": "^2.29.4",
49
47
  "react": "^18.0.0",
50
48
  "react-dom": "^18.0.0",
51
- "react-router-dom": "^6.9.0"
49
+ "react-router-dom": "^6.9.0",
50
+ "@nu-art/http-server": "{{THUNDERSTORM_VERSION}}",
51
+ "@nu-art/api-types": "{{THUNDERSTORM_VERSION}}"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@types/express": "^4.17.17",