@antelopejs/dms-saas 0.3.1 → 0.3.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.
- package/README.md +0 -86
- package/dist/config/runtime.d.ts +0 -1
- package/dist/config/runtime.js +0 -7
- package/dist/config/runtime.js.map +1 -1
- package/dist/data-api/platformOwner/index.d.ts +0 -1
- package/dist/data-api/platformOwner/index.js +0 -1
- package/dist/data-api/platformOwner/index.js.map +1 -1
- package/dist/data-api/tenant/index.d.ts +0 -1
- package/dist/data-api/tenant/index.js +0 -1
- package/dist/data-api/tenant/index.js.map +1 -1
- package/dist/notifications/subjects.d.ts +0 -2
- package/dist/notifications/subjects.js +1 -13
- package/dist/notifications/subjects.js.map +1 -1
- package/dist/pages/platform/categories.d.ts +0 -1
- package/dist/pages/platform/categories.js +1 -8
- package/dist/pages/platform/categories.js.map +1 -1
- package/dist/pages/platform/index.d.ts +0 -1
- package/dist/pages/platform/index.js +0 -1
- package/dist/pages/platform/index.js.map +1 -1
- package/dist/pages/tenant/index.d.ts +0 -1
- package/dist/pages/tenant/index.js +0 -1
- package/dist/pages/tenant/index.js.map +1 -1
- package/dist/routes/platformOwner/index.d.ts +0 -1
- package/dist/routes/platformOwner/index.js +0 -1
- package/dist/routes/platformOwner/index.js.map +1 -1
- package/dist/routes/tenant/index.d.ts +0 -1
- package/dist/routes/tenant/index.js +0 -1
- package/dist/routes/tenant/index.js.map +1 -1
- package/dist/types/config.d.ts +0 -1
- package/frontend-vue/i18n/locales/saas-en-GB.json +1 -142
- package/frontend-vue/i18n/locales/saas-fr-FR.json +1 -142
- package/package.json +2 -4
- package/dist/data-api/platformOwner/support.d.ts +0 -58
- package/dist/data-api/platformOwner/support.js +0 -111
- package/dist/data-api/platformOwner/support.js.map +0 -1
- package/dist/data-api/support-fields.d.ts +0 -49
- package/dist/data-api/support-fields.js +0 -166
- package/dist/data-api/support-fields.js.map +0 -1
- package/dist/data-api/support-routes.d.ts +0 -10
- package/dist/data-api/support-routes.js +0 -71
- package/dist/data-api/support-routes.js.map +0 -1
- package/dist/data-api/tenant/support.d.ts +0 -39
- package/dist/data-api/tenant/support.js +0 -53
- package/dist/data-api/tenant/support.js.map +0 -1
- package/dist/pages/platform/support.d.ts +0 -9
- package/dist/pages/platform/support.js +0 -29
- package/dist/pages/platform/support.js.map +0 -1
- package/dist/pages/tenant/support.d.ts +0 -9
- package/dist/pages/tenant/support.js +0 -27
- package/dist/pages/tenant/support.js.map +0 -1
- package/dist/routes/platformOwner/support.d.ts +0 -21
- package/dist/routes/platformOwner/support.js +0 -180
- package/dist/routes/platformOwner/support.js.map +0 -1
- package/dist/routes/tenant/support.d.ts +0 -27
- package/dist/routes/tenant/support.js +0 -185
- package/dist/routes/tenant/support.js.map +0 -1
- package/dist/support/admissions.d.ts +0 -36
- package/dist/support/admissions.js +0 -136
- package/dist/support/admissions.js.map +0 -1
- package/dist/support/attachments.d.ts +0 -12
- package/dist/support/attachments.js +0 -56
- package/dist/support/attachments.js.map +0 -1
- package/dist/support/config.d.ts +0 -19
- package/dist/support/config.js +0 -75
- package/dist/support/config.js.map +0 -1
- package/dist/support/index.d.ts +0 -6
- package/dist/support/index.js +0 -23
- package/dist/support/index.js.map +0 -1
- package/dist/support/operations.d.ts +0 -51
- package/dist/support/operations.js +0 -109
- package/dist/support/operations.js.map +0 -1
- package/dist/support/plans.d.ts +0 -6
- package/dist/support/plans.js +0 -130
- package/dist/support/plans.js.map +0 -1
- package/dist/support/publications.d.ts +0 -8
- package/dist/support/publications.js +0 -106
- package/dist/support/publications.js.map +0 -1
- package/dist/support/recovery.d.ts +0 -7
- package/dist/support/recovery.js +0 -43
- package/dist/support/recovery.js.map +0 -1
- package/dist/support/service.d.ts +0 -51
- package/dist/support/service.js +0 -143
- package/dist/support/service.js.map +0 -1
- package/dist/support/transitions.d.ts +0 -4
- package/dist/support/transitions.js +0 -29
- package/dist/support/transitions.js.map +0 -1
- package/dist/support/uploads.d.ts +0 -39
- package/dist/support/uploads.js +0 -115
- package/dist/support/uploads.js.map +0 -1
- package/dist/support/validation.d.ts +0 -15
- package/dist/support/validation.js +0 -54
- package/dist/support/validation.js.map +0 -1
- package/frontend-vue/app/components/PlatformSupport.vue +0 -461
- package/frontend-vue/app/components/SupportAttachmentUpload.vue +0 -140
- package/frontend-vue/app/components/SupportThreadHistory.vue +0 -139
- package/frontend-vue/app/components/TenantSupport.vue +0 -415
- package/frontend-vue/app/composables/useSupportRequest.ts +0 -74
- package/frontend-vue/app/types/support.ts +0 -123
package/dist/support/service.js
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resumeSupportOperation = resumeSupportOperation;
|
|
4
|
-
exports.createSupportTicket = createSupportTicket;
|
|
5
|
-
exports.addSupportMessage = addSupportMessage;
|
|
6
|
-
exports.updateSupportTicket = updateSupportTicket;
|
|
7
|
-
const interface_api_1 = require("@antelopejs/interface-api");
|
|
8
|
-
const interface_api_util_1 = require("@antelopejs/interface-api-util");
|
|
9
|
-
const interface_file_storage_1 = require("@antelopejs/interface-file-storage");
|
|
10
|
-
const admissions_1 = require("./admissions");
|
|
11
|
-
const operations_1 = require("./operations");
|
|
12
|
-
const plans_1 = require("./plans");
|
|
13
|
-
const publications_1 = require("./publications");
|
|
14
|
-
const validation_1 = require("./validation");
|
|
15
|
-
const HTTP_CONFLICT = 409;
|
|
16
|
-
const HTTP_BAD_REQUEST = 400;
|
|
17
|
-
const HTTP_UNAVAILABLE = 503;
|
|
18
|
-
async function prepareOperation(request) {
|
|
19
|
-
(0, validation_1.assertSupportRequestId)(request.requestId);
|
|
20
|
-
const id = (0, operations_1.supportOperationId)(request.tenantId, request.actorId, request.requestId);
|
|
21
|
-
const fingerprint = (0, operations_1.supportRequestFingerprint)([request.kind, request.intent]);
|
|
22
|
-
const operations = new operations_1.SupportOperationModel(request.models.tickets.database);
|
|
23
|
-
const existing = await operations.get(id);
|
|
24
|
-
if (existing) {
|
|
25
|
-
(0, interface_api_util_1.assert)(existing.fingerprint === fingerprint, HTTP_CONFLICT, "saas.errors.support.request_reused");
|
|
26
|
-
return existing;
|
|
27
|
-
}
|
|
28
|
-
const publication = await request.plan(id);
|
|
29
|
-
if (publication.message)
|
|
30
|
-
publication.message.attachments =
|
|
31
|
-
publication.stagedKeys.map(interface_file_storage_1.stripStagingPrefix);
|
|
32
|
-
return operations.prepare({
|
|
33
|
-
_id: id,
|
|
34
|
-
revision: `${id}:prepared`,
|
|
35
|
-
status: "prepared",
|
|
36
|
-
kind: request.kind,
|
|
37
|
-
fingerprint,
|
|
38
|
-
payload: JSON.stringify(publication),
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
function isTerminalPreparationError(error) {
|
|
42
|
-
if (error instanceof interface_api_1.HTTPResult)
|
|
43
|
-
return (error.getStatus() === HTTP_BAD_REQUEST ||
|
|
44
|
-
error.getStatus() === HTTP_CONFLICT);
|
|
45
|
-
return (error instanceof interface_file_storage_1.FileNotFoundError || error instanceof interface_file_storage_1.FileConflictError);
|
|
46
|
-
}
|
|
47
|
-
async function recoverPreparationFailure(operations, operation, error) {
|
|
48
|
-
if (isTerminalPreparationError(error)) {
|
|
49
|
-
const failure = error instanceof interface_api_1.HTTPResult && typeof error.getBody() === "string"
|
|
50
|
-
? { status: error.getStatus(), code: String(error.getBody()) }
|
|
51
|
-
: {
|
|
52
|
-
status: HTTP_CONFLICT,
|
|
53
|
-
code: "saas.errors.support.invalid_attachments",
|
|
54
|
-
};
|
|
55
|
-
await operations
|
|
56
|
-
.finish(operation, "rejected", failure)
|
|
57
|
-
.catch(() => undefined);
|
|
58
|
-
}
|
|
59
|
-
const current = await operations.get(operation._id);
|
|
60
|
-
if (current?.status === "rejected")
|
|
61
|
-
await (0, admissions_1.cancelSupportAttachments)(current);
|
|
62
|
-
if (!current || current.status === "prepared")
|
|
63
|
-
throw error;
|
|
64
|
-
return current;
|
|
65
|
-
}
|
|
66
|
-
async function readyOperation(tenantId, models, operation) {
|
|
67
|
-
const operations = new operations_1.SupportOperationModel(models.tickets.database);
|
|
68
|
-
if (operation.status !== "prepared")
|
|
69
|
-
return operation;
|
|
70
|
-
try {
|
|
71
|
-
await (0, admissions_1.prepareSupportAttachments)(operations, operation, tenantId);
|
|
72
|
-
await operations.finish(operation, "ready");
|
|
73
|
-
}
|
|
74
|
-
catch (error) {
|
|
75
|
-
return recoverPreparationFailure(operations, operation, error);
|
|
76
|
-
}
|
|
77
|
-
const current = await operations.get(operation._id);
|
|
78
|
-
(0, interface_api_util_1.assert)(current, HTTP_UNAVAILABLE, "saas.errors.support.operation_pending");
|
|
79
|
-
return current;
|
|
80
|
-
}
|
|
81
|
-
async function runSupportOperation(request) {
|
|
82
|
-
const prepared = await prepareOperation(request);
|
|
83
|
-
const result = await resumeSupportOperation(request.tenantId, request.models, prepared);
|
|
84
|
-
return (0, publications_1.committedSupportPublication)(result);
|
|
85
|
-
}
|
|
86
|
-
async function resumeSupportOperation(tenantId, models, operation) {
|
|
87
|
-
const ready = await readyOperation(tenantId, models, operation);
|
|
88
|
-
const result = await (0, publications_1.publishSupportOperation)(models, ready);
|
|
89
|
-
if (result.status === "rejected")
|
|
90
|
-
await (0, admissions_1.cancelSupportAttachments)(result);
|
|
91
|
-
return result;
|
|
92
|
-
}
|
|
93
|
-
function ticketResult(publication) {
|
|
94
|
-
if (publication.unchanged)
|
|
95
|
-
return publication.ticket;
|
|
96
|
-
publication.ticket.publicationId = null;
|
|
97
|
-
publication.ticket.mutationId = `${publication.ticket.mutationId}:settled`;
|
|
98
|
-
return publication.ticket;
|
|
99
|
-
}
|
|
100
|
-
async function createSupportTicket(options) {
|
|
101
|
-
const publication = await runSupportOperation({
|
|
102
|
-
tenantId: options.tenant._id,
|
|
103
|
-
actorId: options.authorId,
|
|
104
|
-
requestId: options.requestId,
|
|
105
|
-
kind: "create",
|
|
106
|
-
intent: options.input,
|
|
107
|
-
models: options.models,
|
|
108
|
-
plan: async (id) => {
|
|
109
|
-
await options.validateNewRequest?.();
|
|
110
|
-
return (0, plans_1.createSupportPlan)(options, id);
|
|
111
|
-
},
|
|
112
|
-
});
|
|
113
|
-
return ticketResult(publication);
|
|
114
|
-
}
|
|
115
|
-
async function addSupportMessage(options) {
|
|
116
|
-
const publication = await runSupportOperation({
|
|
117
|
-
tenantId: options.tenantId,
|
|
118
|
-
actorId: options.authorId,
|
|
119
|
-
requestId: options.requestId,
|
|
120
|
-
kind: "reply",
|
|
121
|
-
intent: [options.ticketId, options.authorType, options.input],
|
|
122
|
-
models: options.models,
|
|
123
|
-
plan: async (id) => (0, plans_1.replySupportPlan)(options, await (0, publications_1.readSupportTicket)(options.models, options.ticketId), id),
|
|
124
|
-
});
|
|
125
|
-
(0, interface_api_util_1.assert)(publication.message, HTTP_UNAVAILABLE, "saas.errors.support.operation_pending");
|
|
126
|
-
return publication.message;
|
|
127
|
-
}
|
|
128
|
-
async function updateSupportTicket(options) {
|
|
129
|
-
const publication = await runSupportOperation({
|
|
130
|
-
tenantId: options.tenantId,
|
|
131
|
-
actorId: options.actorId,
|
|
132
|
-
requestId: options.requestId,
|
|
133
|
-
kind: "update",
|
|
134
|
-
intent: [options.ticketId, options.input],
|
|
135
|
-
models: options.models,
|
|
136
|
-
plan: async (id) => {
|
|
137
|
-
await options.validateNewRequest?.();
|
|
138
|
-
return (0, plans_1.updateSupportPlan)(options, await (0, publications_1.readSupportTicket)(options.models, options.ticketId), id);
|
|
139
|
-
},
|
|
140
|
-
});
|
|
141
|
-
return ticketResult(publication);
|
|
142
|
-
}
|
|
143
|
-
//# sourceMappingURL=service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/support/service.ts"],"names":[],"mappings":";;AA+MA,wDASC;AAUD,kDAgBC;AAGD,8CAuBC;AAGD,kDAoBC;AAnSD,6DAAuD;AACvD,uEAAwD;AACxD,+EAI4C;AAW5C,6CAGsB;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E,OAAO,CAAC,MAAM;QACtB,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,CACjB,IAAA,wBAAgB,EACd,OAAO,EACP,MAAM,IAAA,gCAAiB,EAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,EACzD,EAAE,CACH;KACJ,CAAC,CAAC;IACH,IAAA,2BAAM,EACJ,WAAW,CAAC,OAAO,EACnB,gBAAgB,EAChB,uCAAuC,CACxC,CAAC;IACF,OAAO,WAAW,CAAC,OAAO,CAAC;AAC7B,CAAC;AAGM,KAAK,UAAU,mBAAmB,CACvC,OAAmC;IAEnC,MAAM,WAAW,GAAG,MAAM,mBAAmB,CAAC;QAC5C,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,KAAK,CAAC;QACzC,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE;YACjB,MAAM,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC;YACrC,OAAO,IAAA,yBAAiB,EACtB,OAAO,EACP,MAAM,IAAA,gCAAiB,EAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,EACzD,EAAE,CACH,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;IACH,OAAO,YAAY,CAAC,WAAW,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { SupportTicketStatus } from "../db";
|
|
2
|
-
export declare function assertSupportStatusTransition(current: SupportTicketStatus, next: SupportTicketStatus): void;
|
|
3
|
-
export declare function statusAfterTenantMessage(current: SupportTicketStatus): SupportTicketStatus;
|
|
4
|
-
export declare function statusAfterPlatformReply(current: SupportTicketStatus): SupportTicketStatus;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assertSupportStatusTransition = assertSupportStatusTransition;
|
|
4
|
-
exports.statusAfterTenantMessage = statusAfterTenantMessage;
|
|
5
|
-
exports.statusAfterPlatformReply = statusAfterPlatformReply;
|
|
6
|
-
const interface_api_util_1 = require("@antelopejs/interface-api-util");
|
|
7
|
-
const HTTP_BAD_REQUEST = 400;
|
|
8
|
-
const STATUS_TRANSITIONS = {
|
|
9
|
-
open: ["in_progress", "resolved", "closed"],
|
|
10
|
-
in_progress: ["waiting_customer", "resolved", "closed"],
|
|
11
|
-
waiting_customer: ["in_progress", "resolved", "closed"],
|
|
12
|
-
resolved: ["open", "closed"],
|
|
13
|
-
closed: ["open"],
|
|
14
|
-
};
|
|
15
|
-
function assertSupportStatusTransition(current, next) {
|
|
16
|
-
if (current === next)
|
|
17
|
-
return;
|
|
18
|
-
(0, interface_api_util_1.assert)(STATUS_TRANSITIONS[current].includes(next), HTTP_BAD_REQUEST, "saas.errors.support.invalid_status_transition");
|
|
19
|
-
}
|
|
20
|
-
function statusAfterTenantMessage(current) {
|
|
21
|
-
if (current === "waiting_customer")
|
|
22
|
-
return "in_progress";
|
|
23
|
-
return current === "resolved" || current === "closed" ? "open" : current;
|
|
24
|
-
}
|
|
25
|
-
function statusAfterPlatformReply(current) {
|
|
26
|
-
(0, interface_api_util_1.assert)(current !== "closed", HTTP_BAD_REQUEST, "saas.errors.support.closed_ticket_reply");
|
|
27
|
-
return "waiting_customer";
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=transitions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transitions.js","sourceRoot":"","sources":["../../src/support/transitions.ts"],"names":[],"mappings":";;AAaA,sEAUC;AAED,4DAKC;AAED,4DASC;AAzCD,uEAAwD;AAGxD,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAE7B,MAAM,kBAAkB,GAAuD;IAC7E,IAAI,EAAE,CAAC,aAAa,EAAE,UAAU,EAAE,QAAQ,CAAC;IAC3C,WAAW,EAAE,CAAC,kBAAkB,EAAE,UAAU,EAAE,QAAQ,CAAC;IACvD,gBAAgB,EAAE,CAAC,aAAa,EAAE,UAAU,EAAE,QAAQ,CAAC;IACvD,QAAQ,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC;IAC5B,MAAM,EAAE,CAAC,MAAM,CAAC;CACjB,CAAC;AAEF,SAAgB,6BAA6B,CAC3C,OAA4B,EAC5B,IAAyB;IAEzB,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO;IAC7B,IAAA,2BAAM,EACJ,kBAAkB,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,EAC1C,gBAAgB,EAChB,+CAA+C,CAChD,CAAC;AACJ,CAAC;AAED,SAAgB,wBAAwB,CACtC,OAA4B;IAE5B,IAAI,OAAO,KAAK,kBAAkB;QAAE,OAAO,aAAa,CAAC;IACzD,OAAO,OAAO,KAAK,UAAU,IAAI,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;AAC3E,CAAC;AAED,SAAgB,wBAAwB,CACtC,OAA4B;IAE5B,IAAA,2BAAM,EACJ,OAAO,KAAK,QAAQ,EACpB,gBAAgB,EAChB,yCAAyC,CAC1C,CAAC;IACF,OAAO,kBAAkB,CAAC;AAC5B,CAAC"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { Table } from "@antelopejs/interface-database-decorators";
|
|
2
|
-
import { type PresignedUploadResponse } from "@antelopejs/interface-file-storage";
|
|
3
|
-
export interface SupportUploadInput {
|
|
4
|
-
filename: string;
|
|
5
|
-
size: number;
|
|
6
|
-
mimetype: string;
|
|
7
|
-
}
|
|
8
|
-
export declare class SupportUpload extends Table {
|
|
9
|
-
_id: string;
|
|
10
|
-
stagedKey: string;
|
|
11
|
-
storage: string;
|
|
12
|
-
tenantId: string;
|
|
13
|
-
}
|
|
14
|
-
declare const SupportUploadModel_base: {
|
|
15
|
-
new (database: import("@antelopejs/interface-database").SchemaInstance<any>): {
|
|
16
|
-
readonly table: import("@antelopejs/interface-database").Table<SupportUpload>;
|
|
17
|
-
readonly database: import("@antelopejs/interface-database").SchemaInstance<any>;
|
|
18
|
-
get(id: string): PromiseLike<SupportUpload | undefined>;
|
|
19
|
-
getBy(index: keyof SupportUpload, ...keys: any[]): PromiseLike<SupportUpload[]>;
|
|
20
|
-
getAll(): PromiseLike<SupportUpload[]>;
|
|
21
|
-
insert(obj: import("@antelopejs/interface-database-decorators").DeepPartial<SupportUpload> | import("@antelopejs/interface-database-decorators").DeepPartial<SupportUpload>[], options?: import("@antelopejs/interface-database-decorators").ValidateOptions): Promise<string[]>;
|
|
22
|
-
update(id: string, obj: import("@antelopejs/interface-database-decorators").DeepPartial<SupportUpload>, options?: import("@antelopejs/interface-database-decorators").ValidateOptions): Promise<number>;
|
|
23
|
-
update(obj: import("@antelopejs/interface-database-decorators").DeepPartial<SupportUpload>, options?: import("@antelopejs/interface-database-decorators").ValidateOptions): Promise<number>;
|
|
24
|
-
delete(id: string): Promise<number>;
|
|
25
|
-
};
|
|
26
|
-
readonly schemaName: string;
|
|
27
|
-
fromPlainData(obj: any): SupportUpload;
|
|
28
|
-
fromDatabase(obj: any): SupportUpload | undefined;
|
|
29
|
-
toDatabase(obj: any): Record<string, any>;
|
|
30
|
-
validate(obj: unknown, options?: import("@antelopejs/interface-database-decorators").ValidateInputOptions): import("@antelopejs/interface-database-decorators").ValidationResult;
|
|
31
|
-
};
|
|
32
|
-
export declare class SupportUploadModel extends SupportUploadModel_base {
|
|
33
|
-
record(candidate: SupportUpload): Promise<void>;
|
|
34
|
-
}
|
|
35
|
-
export declare function supportUploadId(storage: string, stagedKey: string): string;
|
|
36
|
-
export declare function parseSupportUpload(body: unknown): SupportUploadInput;
|
|
37
|
-
export declare function createSupportUpload(tenantId: string, input: SupportUploadInput): Promise<PresignedUploadResponse>;
|
|
38
|
-
export declare function getSupportUpload(tenantId: string, stagedKey: string): Promise<SupportUpload>;
|
|
39
|
-
export {};
|
package/dist/support/uploads.js
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.SupportUploadModel = exports.SupportUpload = void 0;
|
|
13
|
-
exports.supportUploadId = supportUploadId;
|
|
14
|
-
exports.parseSupportUpload = parseSupportUpload;
|
|
15
|
-
exports.createSupportUpload = createSupportUpload;
|
|
16
|
-
exports.getSupportUpload = getSupportUpload;
|
|
17
|
-
const node_crypto_1 = require("node:crypto");
|
|
18
|
-
const interface_api_util_1 = require("@antelopejs/interface-api-util");
|
|
19
|
-
const interface_database_decorators_1 = require("@antelopejs/interface-database-decorators");
|
|
20
|
-
const interface_file_storage_1 = require("@antelopejs/interface-file-storage");
|
|
21
|
-
const constants_1 = require("@antelopejs/interface-dms/constants");
|
|
22
|
-
const config_1 = require("../config");
|
|
23
|
-
const attachments_1 = require("./attachments");
|
|
24
|
-
const config_2 = require("./config");
|
|
25
|
-
const HTTP_BAD_REQUEST = 400;
|
|
26
|
-
const HTTP_UNAVAILABLE = 503;
|
|
27
|
-
const MAX_FILENAME_LENGTH = 255;
|
|
28
|
-
let SupportUpload = class SupportUpload extends interface_database_decorators_1.Table {
|
|
29
|
-
};
|
|
30
|
-
exports.SupportUpload = SupportUpload;
|
|
31
|
-
__decorate([
|
|
32
|
-
(0, interface_database_decorators_1.Field)("string"),
|
|
33
|
-
__metadata("design:type", String)
|
|
34
|
-
], SupportUpload.prototype, "_id", void 0);
|
|
35
|
-
__decorate([
|
|
36
|
-
(0, interface_database_decorators_1.Index)(),
|
|
37
|
-
(0, interface_database_decorators_1.Field)("string"),
|
|
38
|
-
__metadata("design:type", String)
|
|
39
|
-
], SupportUpload.prototype, "stagedKey", void 0);
|
|
40
|
-
__decorate([
|
|
41
|
-
(0, interface_database_decorators_1.Field)("string"),
|
|
42
|
-
__metadata("design:type", String)
|
|
43
|
-
], SupportUpload.prototype, "storage", void 0);
|
|
44
|
-
__decorate([
|
|
45
|
-
(0, interface_database_decorators_1.Field)("string"),
|
|
46
|
-
__metadata("design:type", String)
|
|
47
|
-
], SupportUpload.prototype, "tenantId", void 0);
|
|
48
|
-
exports.SupportUpload = SupportUpload = __decorate([
|
|
49
|
-
(0, interface_database_decorators_1.RegisterTable)("support_uploads", constants_1.CORE_SCHEMA_NAME)
|
|
50
|
-
], SupportUpload);
|
|
51
|
-
class SupportUploadModel extends (0, interface_database_decorators_1.BasicDataModel)(SupportUpload) {
|
|
52
|
-
async record(candidate) {
|
|
53
|
-
try {
|
|
54
|
-
await this.insert(candidate);
|
|
55
|
-
}
|
|
56
|
-
catch {
|
|
57
|
-
}
|
|
58
|
-
const stored = await this.get(candidate._id);
|
|
59
|
-
(0, interface_api_util_1.assert)(stored?.storage === candidate.storage &&
|
|
60
|
-
stored.stagedKey === candidate.stagedKey &&
|
|
61
|
-
stored.tenantId === candidate.tenantId, HTTP_UNAVAILABLE, "saas.errors.support.attachment_pending");
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
exports.SupportUploadModel = SupportUploadModel;
|
|
65
|
-
function supportUploadId(storage, stagedKey) {
|
|
66
|
-
return (0, node_crypto_1.createHash)("sha256")
|
|
67
|
-
.update(JSON.stringify([storage, stagedKey]))
|
|
68
|
-
.digest("hex");
|
|
69
|
-
}
|
|
70
|
-
function parseSupportUpload(body) {
|
|
71
|
-
const value = body && typeof body === "object" ? body : {};
|
|
72
|
-
(0, interface_api_util_1.assert)(typeof value.filename === "string" &&
|
|
73
|
-
value.filename.length > 0 &&
|
|
74
|
-
value.filename.length <= MAX_FILENAME_LENGTH &&
|
|
75
|
-
!/[\\/\x00-\x1f\x7f]/u.test(value.filename), HTTP_BAD_REQUEST, "saas.errors.support.invalid_attachment");
|
|
76
|
-
(0, interface_api_util_1.assert)(typeof value.size === "number" &&
|
|
77
|
-
Number.isSafeInteger(value.size) &&
|
|
78
|
-
value.size >= 0 &&
|
|
79
|
-
typeof value.mimetype === "string", HTTP_BAD_REQUEST, "saas.errors.support.invalid_attachment");
|
|
80
|
-
const input = {
|
|
81
|
-
filename: value.filename,
|
|
82
|
-
size: value.size,
|
|
83
|
-
mimetype: value.mimetype,
|
|
84
|
-
};
|
|
85
|
-
(0, attachments_1.assertSupportAttachmentMetadata)(input);
|
|
86
|
-
return input;
|
|
87
|
-
}
|
|
88
|
-
async function createSupportUpload(tenantId, input) {
|
|
89
|
-
const storage = (0, config_1.getSupportStorage)();
|
|
90
|
-
const path = (0, config_2.tenantSupportAttachmentPath)(tenantId);
|
|
91
|
-
const response = await (0, interface_file_storage_1.CreateUploadUrl)({
|
|
92
|
-
...input,
|
|
93
|
-
path,
|
|
94
|
-
staging: true,
|
|
95
|
-
visibility: "private",
|
|
96
|
-
metadata: { filename: input.filename },
|
|
97
|
-
}, {
|
|
98
|
-
maxSize: config_2.SUPPORT_ATTACHMENT_MAX_SIZE,
|
|
99
|
-
allowedMimetypes: [...config_2.SUPPORT_ATTACHMENT_MIMETYPES],
|
|
100
|
-
}, storage);
|
|
101
|
-
(0, attachments_1.assertSupportAttachmentPath)(response.resourceKey, path);
|
|
102
|
-
await (0, interface_database_decorators_1.GetModel)(SupportUploadModel).record({
|
|
103
|
-
_id: supportUploadId(storage, response.resourceKey),
|
|
104
|
-
stagedKey: response.resourceKey,
|
|
105
|
-
storage,
|
|
106
|
-
tenantId,
|
|
107
|
-
});
|
|
108
|
-
return response;
|
|
109
|
-
}
|
|
110
|
-
async function getSupportUpload(tenantId, stagedKey) {
|
|
111
|
-
const uploads = await (0, interface_database_decorators_1.GetModel)(SupportUploadModel).getBy("stagedKey", stagedKey);
|
|
112
|
-
(0, interface_api_util_1.assert)(uploads.length === 1 && uploads[0].tenantId === tenantId, HTTP_BAD_REQUEST, "saas.errors.support.invalid_attachments");
|
|
113
|
-
return uploads[0];
|
|
114
|
-
}
|
|
115
|
-
//# sourceMappingURL=uploads.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"uploads.js","sourceRoot":"","sources":["../../src/support/uploads.ts"],"names":[],"mappings":";;;;;;;;;;;;AA6EA,0CAIC;AAGD,gDA2BC;AAGD,kDA4BC;AAGD,4CAcC;AA/JD,6CAAyC;AACzC,uEAAwD;AACxD,6FAOmD;AACnD,+EAG4C;AAC5C,mEAAuE;AACvE,sCAA8C;AAC9C,+CAGuB;AACvB,qCAIkB;AAElB,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAC7B,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAC7B,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAgBzB,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,qCAAK;CAUvC,CAAA;AAVY,sCAAa;AAEhB;IADP,IAAA,qCAAK,EAAC,QAAQ,CAAC;;0CACI;AAGZ;IAFP,IAAA,qCAAK,GAAE;IACP,IAAA,qCAAK,EAAC,QAAQ,CAAC;;gDACU;AAElB;IADP,IAAA,qCAAK,EAAC,QAAQ,CAAC;;8CACQ;A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AE,QAAQ,CAAC,WAAW;QAC/B,OAAO;QACP,QAAQ;KACT,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC;AAClB,CAAC;AAGM,KAAK,UAAU,gBAAgB,CACpC,QAAgB,EAChB,SAAiB;IAEjB,MAAM,OAAO,GAAG,MAAM,IAAA,wCAAQ,EAAC,kBAAkB,CAAC,CAAC,KAAK,CACtD,WAAW,EACX,SAAS,CACV,CAAC;IACF,IAAA,2BAAM,EACJ,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,KAAK,QAAQ,EACxD,gBAAgB,EAChB,yCAAyC,CAC1C,CAAC;IACF,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { type SupportTicketCategory, type SupportTicketPriority, type SupportTicketStatus } from "../db";
|
|
2
|
-
export declare function assertSupportRequestId(value: unknown): asserts value is string;
|
|
3
|
-
export declare function parseSupportRequestId(body: unknown): string;
|
|
4
|
-
export interface SupportMessageInput {
|
|
5
|
-
body: string;
|
|
6
|
-
attachments: string[];
|
|
7
|
-
}
|
|
8
|
-
export interface SupportTicketInput extends SupportMessageInput {
|
|
9
|
-
subject: string;
|
|
10
|
-
category: SupportTicketCategory;
|
|
11
|
-
priority: SupportTicketPriority;
|
|
12
|
-
}
|
|
13
|
-
export declare function parseSupportMessage(body: unknown): SupportMessageInput;
|
|
14
|
-
export declare function parseSupportTicket(body: unknown): SupportTicketInput;
|
|
15
|
-
export declare function parseSupportStatus(value: unknown): SupportTicketStatus;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assertSupportRequestId = assertSupportRequestId;
|
|
4
|
-
exports.parseSupportRequestId = parseSupportRequestId;
|
|
5
|
-
exports.parseSupportMessage = parseSupportMessage;
|
|
6
|
-
exports.parseSupportTicket = parseSupportTicket;
|
|
7
|
-
exports.parseSupportStatus = parseSupportStatus;
|
|
8
|
-
const interface_api_util_1 = require("@antelopejs/interface-api-util");
|
|
9
|
-
const db_1 = require("../db");
|
|
10
|
-
const config_1 = require("./config");
|
|
11
|
-
const HTTP_BAD_REQUEST = 400;
|
|
12
|
-
const MAX_SUBJECT_LENGTH = 200;
|
|
13
|
-
const MAX_MESSAGE_LENGTH = 10_000;
|
|
14
|
-
const CATEGORY_SET = new Set(db_1.SUPPORT_TICKET_CATEGORIES);
|
|
15
|
-
const PRIORITY_SET = new Set(db_1.SUPPORT_TICKET_PRIORITIES);
|
|
16
|
-
const STATUS_SET = new Set(db_1.SUPPORT_TICKET_STATUSES);
|
|
17
|
-
const REQUEST_ID = /^[a-zA-Z0-9_-]{16,128}$/;
|
|
18
|
-
function assertSupportRequestId(value) {
|
|
19
|
-
(0, interface_api_util_1.assert)(typeof value === "string" && REQUEST_ID.test(value), HTTP_BAD_REQUEST, "saas.errors.support.invalid_request_id");
|
|
20
|
-
}
|
|
21
|
-
function parseSupportRequestId(body) {
|
|
22
|
-
const request = body;
|
|
23
|
-
assertSupportRequestId(request?.requestId);
|
|
24
|
-
return request.requestId;
|
|
25
|
-
}
|
|
26
|
-
function parseSupportMessage(body) {
|
|
27
|
-
const value = body;
|
|
28
|
-
const message = typeof value?.body === "string" ? value.body.trim() : "";
|
|
29
|
-
const attachments = Array.isArray(value?.attachments)
|
|
30
|
-
? value.attachments.filter((attachment) => typeof attachment === "string" && attachment.length > 0)
|
|
31
|
-
: [];
|
|
32
|
-
(0, interface_api_util_1.assert)(message.length > 0 && message.length <= MAX_MESSAGE_LENGTH, HTTP_BAD_REQUEST, "saas.errors.support.invalid_message");
|
|
33
|
-
(0, interface_api_util_1.assert)(attachments.length <= config_1.SUPPORT_ATTACHMENT_LIMIT, HTTP_BAD_REQUEST, "saas.errors.support.too_many_attachments");
|
|
34
|
-
(0, interface_api_util_1.assert)(new Set(attachments).size === attachments.length, HTTP_BAD_REQUEST, "saas.errors.support.invalid_attachments");
|
|
35
|
-
return { body: message, attachments };
|
|
36
|
-
}
|
|
37
|
-
function parseSupportTicket(body) {
|
|
38
|
-
const value = body;
|
|
39
|
-
const subject = typeof value?.subject === "string" ? value.subject.trim() : "";
|
|
40
|
-
(0, interface_api_util_1.assert)(subject.length > 0 && subject.length <= MAX_SUBJECT_LENGTH, HTTP_BAD_REQUEST, "saas.errors.support.invalid_subject");
|
|
41
|
-
(0, interface_api_util_1.assert)(CATEGORY_SET.has(value?.category ?? ""), HTTP_BAD_REQUEST, "saas.errors.support.invalid_category");
|
|
42
|
-
(0, interface_api_util_1.assert)(PRIORITY_SET.has(value?.priority ?? ""), HTTP_BAD_REQUEST, "saas.errors.support.invalid_priority");
|
|
43
|
-
return {
|
|
44
|
-
subject,
|
|
45
|
-
category: value?.category,
|
|
46
|
-
priority: value?.priority,
|
|
47
|
-
...parseSupportMessage(value),
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
function parseSupportStatus(value) {
|
|
51
|
-
(0, interface_api_util_1.assert)(typeof value === "string" && STATUS_SET.has(value), HTTP_BAD_REQUEST, "saas.errors.support.invalid_status");
|
|
52
|
-
return value;
|
|
53
|
-
}
|
|
54
|
-
//# sourceMappingURL=validation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/support/validation.ts"],"names":[],"mappings":";;AAwBA,wDAQC;AAGD,sDAIC;AAaD,kDAyBC;AAED,gDAyBC;AAED,gDAOC;AAjHD,uEAAwD;AACxD,8BAOe;AACf,qCAAoD;AAEpD,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAC7B,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAC/B,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAClC,MAAM,YAAY,GAAG,IAAI,GAAG,CAAS,8BAAyB,CAAC,CAAC;AAChE,MAAM,YAAY,GAAG,IAAI,GAAG,CAAS,8BAAyB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