@antelopejs/dms-saas 0.3.1 → 0.3.3
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/public/register.js +1 -3
- package/dist/routes/public/register.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/routes/tenant/tenant-billing.d.ts +2 -1
- package/dist/routes/tenant/tenant-billing.js +14 -11
- package/dist/routes/tenant/tenant-billing.js.map +1 -1
- package/dist/stripe/webhook-handlers.js +19 -20
- package/dist/stripe/webhook-handlers.js.map +1 -1
- package/dist/stripe/webhook-shared.js +9 -11
- package/dist/stripe/webhook-shared.js.map +1 -1
- package/dist/types/config.d.ts +0 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/keyed-insert.d.ts +7 -0
- package/dist/utils/keyed-insert.js +14 -0
- package/dist/utils/keyed-insert.js.map +1 -0
- package/dist/workspaces/provisioning.js +22 -27
- package/dist/workspaces/provisioning.js.map +1 -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 +7 -9
- 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
|
@@ -1,136 +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.SupportAttachmentAdmissionModel = exports.SupportAttachmentAdmission = void 0;
|
|
13
|
-
exports.prepareSupportAttachments = prepareSupportAttachments;
|
|
14
|
-
exports.cancelSupportAttachments = cancelSupportAttachments;
|
|
15
|
-
const interface_api_util_1 = require("@antelopejs/interface-api-util");
|
|
16
|
-
const interface_database_decorators_1 = require("@antelopejs/interface-database-decorators");
|
|
17
|
-
const interface_file_storage_1 = require("@antelopejs/interface-file-storage");
|
|
18
|
-
const constants_1 = require("@antelopejs/interface-dms/constants");
|
|
19
|
-
const attachments_1 = require("./attachments");
|
|
20
|
-
const config_1 = require("./config");
|
|
21
|
-
const operations_1 = require("./operations");
|
|
22
|
-
const uploads_1 = require("./uploads");
|
|
23
|
-
const HTTP_CONFLICT = 409;
|
|
24
|
-
const HTTP_UNAVAILABLE = 503;
|
|
25
|
-
const SUPPORT_ADMISSIONS_TABLE = "support_attachment_admissions";
|
|
26
|
-
let SupportAttachmentAdmission = class SupportAttachmentAdmission extends interface_database_decorators_1.Table {
|
|
27
|
-
};
|
|
28
|
-
exports.SupportAttachmentAdmission = SupportAttachmentAdmission;
|
|
29
|
-
__decorate([
|
|
30
|
-
(0, interface_database_decorators_1.Field)("string"),
|
|
31
|
-
__metadata("design:type", String)
|
|
32
|
-
], SupportAttachmentAdmission.prototype, "_id", void 0);
|
|
33
|
-
__decorate([
|
|
34
|
-
(0, interface_database_decorators_1.Index)(),
|
|
35
|
-
(0, interface_database_decorators_1.Field)("string"),
|
|
36
|
-
__metadata("design:type", String)
|
|
37
|
-
], SupportAttachmentAdmission.prototype, "operationId", void 0);
|
|
38
|
-
__decorate([
|
|
39
|
-
(0, interface_database_decorators_1.Field)("string"),
|
|
40
|
-
__metadata("design:type", String)
|
|
41
|
-
], SupportAttachmentAdmission.prototype, "stagedKey", void 0);
|
|
42
|
-
__decorate([
|
|
43
|
-
(0, interface_database_decorators_1.Field)("string"),
|
|
44
|
-
__metadata("design:type", String)
|
|
45
|
-
], SupportAttachmentAdmission.prototype, "storage", void 0);
|
|
46
|
-
__decorate([
|
|
47
|
-
(0, interface_database_decorators_1.Field)("string"),
|
|
48
|
-
__metadata("design:type", String)
|
|
49
|
-
], SupportAttachmentAdmission.prototype, "finalKey", void 0);
|
|
50
|
-
__decorate([
|
|
51
|
-
(0, interface_database_decorators_1.Field)("string"),
|
|
52
|
-
__metadata("design:type", String)
|
|
53
|
-
], SupportAttachmentAdmission.prototype, "revision", void 0);
|
|
54
|
-
__decorate([
|
|
55
|
-
(0, interface_database_decorators_1.Field)("boolean"),
|
|
56
|
-
__metadata("design:type", Boolean)
|
|
57
|
-
], SupportAttachmentAdmission.prototype, "promotionConfirmed", void 0);
|
|
58
|
-
exports.SupportAttachmentAdmission = SupportAttachmentAdmission = __decorate([
|
|
59
|
-
(0, interface_database_decorators_1.RegisterTable)(SUPPORT_ADMISSIONS_TABLE, constants_1.CORE_SCHEMA_NAME)
|
|
60
|
-
], SupportAttachmentAdmission);
|
|
61
|
-
class SupportAttachmentAdmissionModel extends (0, interface_database_decorators_1.BasicDataModel)(SupportAttachmentAdmission) {
|
|
62
|
-
async admit(candidate) {
|
|
63
|
-
try {
|
|
64
|
-
await this.insert(candidate);
|
|
65
|
-
}
|
|
66
|
-
catch {
|
|
67
|
-
}
|
|
68
|
-
const admitted = await this.get(candidate._id);
|
|
69
|
-
(0, interface_api_util_1.assert)(admitted, HTTP_UNAVAILABLE, "saas.errors.support.attachment_pending");
|
|
70
|
-
(0, interface_api_util_1.assert)(admitted.operationId === candidate.operationId, HTTP_CONFLICT, "saas.errors.support.attachment_already_admitted");
|
|
71
|
-
return admitted;
|
|
72
|
-
}
|
|
73
|
-
async confirmPromotion(admission) {
|
|
74
|
-
if (admission.promotionConfirmed)
|
|
75
|
-
return;
|
|
76
|
-
await this.table
|
|
77
|
-
.atomicMutation(admission._id, {
|
|
78
|
-
type: "update",
|
|
79
|
-
revisionField: "revision",
|
|
80
|
-
expectedRevision: `${admission._id}:admitted`,
|
|
81
|
-
nextRevision: `${admission._id}:promoted`,
|
|
82
|
-
patch: { promotionConfirmed: true },
|
|
83
|
-
})
|
|
84
|
-
.run();
|
|
85
|
-
const stored = await this.get(admission._id);
|
|
86
|
-
(0, interface_api_util_1.assert)(stored?.promotionConfirmed, HTTP_UNAVAILABLE, "saas.errors.support.attachment_pending");
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
exports.SupportAttachmentAdmissionModel = SupportAttachmentAdmissionModel;
|
|
90
|
-
async function admitAttachment(operationId, upload) {
|
|
91
|
-
return (0, interface_database_decorators_1.GetModel)(SupportAttachmentAdmissionModel).admit({
|
|
92
|
-
_id: upload._id,
|
|
93
|
-
operationId,
|
|
94
|
-
stagedKey: upload.stagedKey,
|
|
95
|
-
storage: upload.storage,
|
|
96
|
-
finalKey: (0, interface_file_storage_1.stripStagingPrefix)(upload.stagedKey),
|
|
97
|
-
revision: `${upload._id}:admitted`,
|
|
98
|
-
promotionConfirmed: false,
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
async function prepareAdmission(operations, admission) {
|
|
102
|
-
const operation = await operations.get(admission.operationId);
|
|
103
|
-
(0, interface_api_util_1.assert)(operation, HTTP_UNAVAILABLE, "saas.errors.support.operation_pending");
|
|
104
|
-
(0, interface_api_util_1.assert)(operation.status !== "rejected", HTTP_CONFLICT, "saas.errors.support.tenant_busy");
|
|
105
|
-
if (operation.status !== "prepared")
|
|
106
|
-
return;
|
|
107
|
-
const promoted = await (0, interface_file_storage_1.PromoteFile)(admission.stagedKey, admission.storage);
|
|
108
|
-
(0, interface_api_util_1.assert)(promoted.resourceKey === admission.finalKey, HTTP_UNAVAILABLE, "saas.errors.support.attachment_pending");
|
|
109
|
-
await (0, interface_database_decorators_1.GetModel)(SupportAttachmentAdmissionModel).confirmPromotion(admission);
|
|
110
|
-
const metadata = await (0, interface_file_storage_1.GetFileMetadata)(admission.finalKey, admission.storage);
|
|
111
|
-
(0, attachments_1.assertSupportAttachmentMetadata)(metadata);
|
|
112
|
-
}
|
|
113
|
-
async function prepareSupportAttachments(operations, operation, tenantId) {
|
|
114
|
-
const { stagedKeys } = (0, operations_1.supportPublication)(operation);
|
|
115
|
-
for (const key of stagedKeys)
|
|
116
|
-
(0, attachments_1.assertSupportAttachmentPath)(key, (0, config_1.tenantSupportAttachmentPath)(tenantId));
|
|
117
|
-
for (const key of stagedKeys) {
|
|
118
|
-
const upload = await (0, uploads_1.getSupportUpload)(tenantId, key);
|
|
119
|
-
const admission = await admitAttachment(operation._id, upload);
|
|
120
|
-
await prepareAdmission(operations, admission);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
async function cancelSupportAttachments(operation) {
|
|
124
|
-
(0, interface_api_util_1.assert)(operation.status === "rejected", HTTP_UNAVAILABLE, "saas.errors.support.operation_pending");
|
|
125
|
-
const admissions = await (0, interface_database_decorators_1.GetModel)(SupportAttachmentAdmissionModel).getBy("operationId", operation._id);
|
|
126
|
-
const outcomes = await Promise.allSettled(admissions.flatMap((admission) => {
|
|
127
|
-
const keys = admission.promotionConfirmed
|
|
128
|
-
? [admission.finalKey, admission.stagedKey]
|
|
129
|
-
: [admission.stagedKey];
|
|
130
|
-
return keys.map((key) => (0, interface_file_storage_1.DeleteFile)(key, admission.storage));
|
|
131
|
-
}));
|
|
132
|
-
const failures = outcomes.flatMap((outcome) => outcome.status === "rejected" ? [outcome.reason] : []);
|
|
133
|
-
if (failures.length)
|
|
134
|
-
throw new AggregateError(failures, "Support attachment cancellation pending");
|
|
135
|
-
}
|
|
136
|
-
//# sourceMappingURL=admissions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"admissions.js","sourceRoot":"","sources":["../../src/support/admissions.ts"],"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M,gBAAgB,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;IAChD,CAAC;AACH,CAAC;AAGM,KAAK,UAAU,wBAAwB,CAC5C,SAA2B;IAE3B,IAAA,2BAAM,EACJ,SAAS,CAAC,MAAM,KAAK,UAAU,EAC/B,gBAAgB,EAChB,uCAAuC,CACxC,CAAC;IACF,MAAM,UAAU,GAAG,MAAM,IAAA,wCAAQ,EAAC,+BAA+B,CAAC,CAAC,KAAK,CACtE,aAAa,EACb,SAAS,CAAC,GAAG,CACd,CAAC;IACF,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,UAAU,CACvC,UAAU,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;QAC/B,MAAM,IAAI,GAAG,SAAS,CAAC,kBAAkB;YACvC,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,EAAE,SAAS,CAAC,SAAS,CAAC;YAC3C,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC1B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAA,mCAAU,EAAC,GAAG,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;IAC/D,CAAC,CAAC,CACH,CAAC;IACF,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAC5C,OAAO,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CACtD,CAAC;IACF,IAAI,QAAQ,CAAC,MAAM;QACjB,MAAM,IAAI,cAAc,CACtB,QAAQ,EACR,yCAAyC,CAC1C,CAAC;AACN,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { type FileMetadata } from "@antelopejs/interface-file-storage";
|
|
2
|
-
export interface SupportAttachmentMetadata extends FileMetadata {
|
|
3
|
-
url: string;
|
|
4
|
-
expiresAt?: number;
|
|
5
|
-
}
|
|
6
|
-
export interface SupportAttachmentValidation {
|
|
7
|
-
size: number;
|
|
8
|
-
mimetype: string;
|
|
9
|
-
}
|
|
10
|
-
export declare function assertSupportAttachmentPath(key: string, path: string): void;
|
|
11
|
-
export declare function assertSupportAttachmentMetadata(metadata: SupportAttachmentValidation): void;
|
|
12
|
-
export declare function getSupportAttachmentMetadata(resourceKey: string, storage: string): Promise<SupportAttachmentMetadata>;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assertSupportAttachmentPath = assertSupportAttachmentPath;
|
|
4
|
-
exports.assertSupportAttachmentMetadata = assertSupportAttachmentMetadata;
|
|
5
|
-
exports.getSupportAttachmentMetadata = getSupportAttachmentMetadata;
|
|
6
|
-
const interface_api_util_1 = require("@antelopejs/interface-api-util");
|
|
7
|
-
const interface_file_storage_1 = require("@antelopejs/interface-file-storage");
|
|
8
|
-
const config_1 = require("./config");
|
|
9
|
-
const HTTP_BAD_REQUEST = 400;
|
|
10
|
-
const CONTROL_CHARACTER_MAX = 0x1f;
|
|
11
|
-
const DELETE_CHARACTER = 0x7f;
|
|
12
|
-
function isAllowedMimetype(mimetype) {
|
|
13
|
-
return config_1.SUPPORT_ATTACHMENT_MIMETYPES.some((allowed) => {
|
|
14
|
-
if (!allowed.endsWith("/*"))
|
|
15
|
-
return mimetype === allowed;
|
|
16
|
-
return mimetype.startsWith(allowed.slice(0, -1));
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
function hasControlCharacters(value) {
|
|
20
|
-
return [...value].some((character) => {
|
|
21
|
-
const code = character.charCodeAt(0);
|
|
22
|
-
return code <= CONTROL_CHARACTER_MAX || code === DELETE_CHARACTER;
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
function isSafeStoragePath(value) {
|
|
26
|
-
return (!value.includes("..") &&
|
|
27
|
-
!value.startsWith("/") &&
|
|
28
|
-
!value.includes("\\") &&
|
|
29
|
-
!hasControlCharacters(value));
|
|
30
|
-
}
|
|
31
|
-
function assertSupportAttachmentPath(key, path) {
|
|
32
|
-
const pathPrefix = `${path}/`;
|
|
33
|
-
const resourceKey = (0, interface_file_storage_1.stripStagingPrefix)(key);
|
|
34
|
-
(0, interface_api_util_1.assert)((0, interface_file_storage_1.isStagedKey)(key) &&
|
|
35
|
-
isSafeStoragePath(key) &&
|
|
36
|
-
resourceKey.startsWith(pathPrefix), HTTP_BAD_REQUEST, "saas.errors.support.invalid_attachments");
|
|
37
|
-
}
|
|
38
|
-
function assertSupportAttachmentMetadata(metadata) {
|
|
39
|
-
(0, interface_api_util_1.assert)(Number.isSafeInteger(metadata.size) &&
|
|
40
|
-
metadata.size >= 0 &&
|
|
41
|
-
metadata.size <= config_1.SUPPORT_ATTACHMENT_MAX_SIZE &&
|
|
42
|
-
isAllowedMimetype(metadata.mimetype), HTTP_BAD_REQUEST, "saas.errors.support.invalid_attachments");
|
|
43
|
-
}
|
|
44
|
-
async function getSupportAttachmentMetadata(resourceKey, storage) {
|
|
45
|
-
(0, interface_api_util_1.assert)(typeof storage === "string" &&
|
|
46
|
-
storage.trim().length > 0 &&
|
|
47
|
-
!(0, interface_file_storage_1.isStagedKey)(resourceKey) &&
|
|
48
|
-
resourceKey === (0, interface_file_storage_1.stripStagingPrefix)(resourceKey) &&
|
|
49
|
-
isSafeStoragePath(resourceKey), HTTP_BAD_REQUEST, "saas.errors.support.invalid_attachment");
|
|
50
|
-
const [metadata, read] = await Promise.all([
|
|
51
|
-
(0, interface_file_storage_1.GetFileMetadata)(resourceKey, storage),
|
|
52
|
-
(0, interface_file_storage_1.CreateReadUrl)(resourceKey, undefined, storage),
|
|
53
|
-
]);
|
|
54
|
-
return { ...metadata, url: read.url, expiresAt: read.expiresAt };
|
|
55
|
-
}
|
|
56
|
-
//# sourceMappingURL=attachments.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"attachments.js","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import type { PlanModel, SupportTicketPriority, TenantSubscriptionModel } from "../db";
|
|
2
|
-
export declare const SUPPORT_SLA_FEATURE_ID = "support-sla";
|
|
3
|
-
export declare const SUPPORT_ATTACHMENT_PATH = "support-attachments";
|
|
4
|
-
export declare const SUPPORT_ATTACHMENT_LIMIT = 5;
|
|
5
|
-
export declare const SUPPORT_ATTACHMENT_MAX_SIZE: number;
|
|
6
|
-
export declare const SUPPORT_ATTACHMENT_MIMETYPES: readonly ["image/*", "application/pdf", "text/plain"];
|
|
7
|
-
export declare const SUPPORT_SLA_LEVELS: readonly ["community", "email", "priority", "dedicated"];
|
|
8
|
-
export type SupportSlaLevel = (typeof SUPPORT_SLA_LEVELS)[number];
|
|
9
|
-
export interface SupportSlaPolicy {
|
|
10
|
-
level: SupportSlaLevel;
|
|
11
|
-
responseTargetHours: number | null;
|
|
12
|
-
businessHoursOnly: boolean;
|
|
13
|
-
priorities: SupportTicketPriority[];
|
|
14
|
-
}
|
|
15
|
-
export declare function tenantSupportAttachmentPath(tenantId: string): string;
|
|
16
|
-
export declare const SUPPORT_SLA_POLICIES: Record<SupportSlaLevel, SupportSlaPolicy>;
|
|
17
|
-
export declare function supportSlaPolicy(value: unknown): SupportSlaPolicy;
|
|
18
|
-
export declare function assertPriorityAllowed(priority: SupportTicketPriority, policy: SupportSlaPolicy): void;
|
|
19
|
-
export declare function resolveTenantSupportPolicy(subscriptions: TenantSubscriptionModel, plans: PlanModel): Promise<SupportSlaPolicy>;
|
package/dist/support/config.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SUPPORT_SLA_POLICIES = exports.SUPPORT_SLA_LEVELS = exports.SUPPORT_ATTACHMENT_MIMETYPES = exports.SUPPORT_ATTACHMENT_MAX_SIZE = exports.SUPPORT_ATTACHMENT_LIMIT = exports.SUPPORT_ATTACHMENT_PATH = exports.SUPPORT_SLA_FEATURE_ID = void 0;
|
|
4
|
-
exports.tenantSupportAttachmentPath = tenantSupportAttachmentPath;
|
|
5
|
-
exports.supportSlaPolicy = supportSlaPolicy;
|
|
6
|
-
exports.assertPriorityAllowed = assertPriorityAllowed;
|
|
7
|
-
exports.resolveTenantSupportPolicy = resolveTenantSupportPolicy;
|
|
8
|
-
const interface_api_util_1 = require("@antelopejs/interface-api-util");
|
|
9
|
-
exports.SUPPORT_SLA_FEATURE_ID = "support-sla";
|
|
10
|
-
exports.SUPPORT_ATTACHMENT_PATH = "support-attachments";
|
|
11
|
-
exports.SUPPORT_ATTACHMENT_LIMIT = 5;
|
|
12
|
-
exports.SUPPORT_ATTACHMENT_MAX_SIZE = 10 * 1024 * 1024;
|
|
13
|
-
exports.SUPPORT_ATTACHMENT_MIMETYPES = [
|
|
14
|
-
"image/*",
|
|
15
|
-
"application/pdf",
|
|
16
|
-
"text/plain",
|
|
17
|
-
];
|
|
18
|
-
exports.SUPPORT_SLA_LEVELS = [
|
|
19
|
-
"community",
|
|
20
|
-
"email",
|
|
21
|
-
"priority",
|
|
22
|
-
"dedicated",
|
|
23
|
-
];
|
|
24
|
-
const HTTP_BAD_REQUEST = 400;
|
|
25
|
-
const VALID_SLA_LEVELS = new Set(exports.SUPPORT_SLA_LEVELS);
|
|
26
|
-
function tenantSupportAttachmentPath(tenantId) {
|
|
27
|
-
return `${exports.SUPPORT_ATTACHMENT_PATH}/${tenantId}`;
|
|
28
|
-
}
|
|
29
|
-
exports.SUPPORT_SLA_POLICIES = {
|
|
30
|
-
community: {
|
|
31
|
-
level: "community",
|
|
32
|
-
responseTargetHours: null,
|
|
33
|
-
businessHoursOnly: false,
|
|
34
|
-
priorities: ["normal"],
|
|
35
|
-
},
|
|
36
|
-
email: {
|
|
37
|
-
level: "email",
|
|
38
|
-
responseTargetHours: 48,
|
|
39
|
-
businessHoursOnly: true,
|
|
40
|
-
priorities: ["low", "normal"],
|
|
41
|
-
},
|
|
42
|
-
priority: {
|
|
43
|
-
level: "priority",
|
|
44
|
-
responseTargetHours: 8,
|
|
45
|
-
businessHoursOnly: true,
|
|
46
|
-
priorities: ["low", "normal", "high"],
|
|
47
|
-
},
|
|
48
|
-
dedicated: {
|
|
49
|
-
level: "dedicated",
|
|
50
|
-
responseTargetHours: 2,
|
|
51
|
-
businessHoursOnly: false,
|
|
52
|
-
priorities: ["low", "normal", "high", "urgent"],
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
function supportSlaPolicy(value) {
|
|
56
|
-
const level = typeof value === "string" && VALID_SLA_LEVELS.has(value)
|
|
57
|
-
? value
|
|
58
|
-
: "community";
|
|
59
|
-
return exports.SUPPORT_SLA_POLICIES[level];
|
|
60
|
-
}
|
|
61
|
-
function assertPriorityAllowed(priority, policy) {
|
|
62
|
-
(0, interface_api_util_1.assert)(policy.priorities.includes(priority), HTTP_BAD_REQUEST, "saas.errors.support.priority_not_available");
|
|
63
|
-
}
|
|
64
|
-
async function resolveTenantSupportPolicy(subscriptions, plans) {
|
|
65
|
-
const subscription = await subscriptions.findOne();
|
|
66
|
-
if (!subscription?.planId)
|
|
67
|
-
return exports.SUPPORT_SLA_POLICIES.community;
|
|
68
|
-
const plan = await plans.get(subscription.planId);
|
|
69
|
-
if (!plan)
|
|
70
|
-
return exports.SUPPORT_SLA_POLICIES.community;
|
|
71
|
-
const inherited = await plans.resolveInheritance(plan);
|
|
72
|
-
const feature = inherited.features.find((candidate) => candidate.featureId === exports.SUPPORT_SLA_FEATURE_ID);
|
|
73
|
-
return supportSlaPolicy(feature?.value);
|
|
74
|
-
}
|
|
75
|
-
//# sourceMappingURL=config.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/support/config.ts"],"names":[],"mappings":";;;AAmCA,kEAEC;AA6BD,4CAMC;AAED,sDASC;AAED,gEAaC;AAlGD,uEAAwD;AAO3C,QAAA,sBAAsB,GAAG,aAAa,CAAC;AACvC,QAAA,uBAAuB,GAAG,q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AAgB,CAAC,GAAG,CAAC,KAAK,CAAC;QACtD,CAAC,CAAE,KAAyB;QAC5B,CAAC,CAAC,WAAW,CAAC;IAClB,OAAO,4BAAoB,CAAC,KAAK,CAAC,CAAC;AACrC,CAAC;AAED,SAAgB,qBAAqB,CACnC,QAA+B,EAC/B,MAAwB;IAExB,IAAA,2BAAM,EACJ,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,EACpC,gBAAgB,EAChB,4CAA4C,CAC7C,CAAC;AACJ,CAAC;AAEM,KAAK,UAAU,0BAA0B,CAC9C,aAAsC,EACtC,KAAgB;IAEhB,MAAM,YAAY,GAAG,MAAM,aAAa,CAAC,OAAO,EAAE,CAAC;IACnD,IAAI,CAAC,YAAY,EAAE,MAAM;QAAE,OAAO,4BAAoB,CAAC,SAAS,CAAC;IACjE,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IAClD,IAAI,CAAC,IAAI;QAAE,OAAO,4BAAoB,CAAC,SAAS,CAAC;IACjD,MAAM,SAAS,GAAG,MAAM,KAAK,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACvD,MAAM,OAAO,GAAG,SAAS,CAAC,QAAQ,CAAC,IAAI,CACrC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,SAAS,KAAK,8BAAsB,CAC9D,CAAC;IACF,OAAO,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AAC1C,CAAC"}
|
package/dist/support/index.d.ts
DELETED
package/dist/support/index.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./attachments"), exports);
|
|
18
|
-
__exportStar(require("./config"), exports);
|
|
19
|
-
__exportStar(require("./publications"), exports);
|
|
20
|
-
__exportStar(require("./service"), exports);
|
|
21
|
-
__exportStar(require("./transitions"), exports);
|
|
22
|
-
__exportStar(require("./validation"), exports);
|
|
23
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/support/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,2CAAyB;AACzB,iDAA+B;AAC/B,4CAA0B;AAC1B,gDAA8B;AAC9B,+CAA6B"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { Table } from "@antelopejs/interface-database-decorators";
|
|
2
|
-
import type { SupportMessage, SupportTicket, SupportTicketEvent } from "../db";
|
|
3
|
-
export type SupportOperationStatus = "prepared" | "ready" | "committed" | "rejected";
|
|
4
|
-
export type SupportOperationKind = "create" | "reply" | "update";
|
|
5
|
-
export interface SupportOperationFailure {
|
|
6
|
-
status: number;
|
|
7
|
-
code: string;
|
|
8
|
-
}
|
|
9
|
-
export interface SupportPublication {
|
|
10
|
-
expectedMutationId: string | null;
|
|
11
|
-
unchanged?: boolean;
|
|
12
|
-
ticket: SupportTicket;
|
|
13
|
-
message: SupportMessage | null;
|
|
14
|
-
events: SupportTicketEvent[];
|
|
15
|
-
stagedKeys: string[];
|
|
16
|
-
}
|
|
17
|
-
export declare class SupportOperation extends Table {
|
|
18
|
-
_id: string;
|
|
19
|
-
revision: string;
|
|
20
|
-
status: SupportOperationStatus;
|
|
21
|
-
fingerprint: string;
|
|
22
|
-
kind: SupportOperationKind;
|
|
23
|
-
payload: string;
|
|
24
|
-
failure?: SupportOperationFailure | null;
|
|
25
|
-
}
|
|
26
|
-
declare const SupportOperationModel_base: {
|
|
27
|
-
new (database: import("@antelopejs/interface-database").SchemaInstance<any>): {
|
|
28
|
-
readonly table: import("@antelopejs/interface-database").Table<SupportOperation>;
|
|
29
|
-
readonly database: import("@antelopejs/interface-database").SchemaInstance<any>;
|
|
30
|
-
get(id: string): PromiseLike<SupportOperation | undefined>;
|
|
31
|
-
getBy(index: keyof SupportOperation, ...keys: any[]): PromiseLike<SupportOperation[]>;
|
|
32
|
-
getAll(): PromiseLike<SupportOperation[]>;
|
|
33
|
-
insert(obj: import("@antelopejs/interface-database-decorators").DeepPartial<SupportOperation> | import("@antelopejs/interface-database-decorators").DeepPartial<SupportOperation>[], options?: import("@antelopejs/interface-database-decorators").ValidateOptions): Promise<string[]>;
|
|
34
|
-
update(id: string, obj: import("@antelopejs/interface-database-decorators").DeepPartial<SupportOperation>, options?: import("@antelopejs/interface-database-decorators").ValidateOptions): Promise<number>;
|
|
35
|
-
update(obj: import("@antelopejs/interface-database-decorators").DeepPartial<SupportOperation>, options?: import("@antelopejs/interface-database-decorators").ValidateOptions): Promise<number>;
|
|
36
|
-
delete(id: string): Promise<number>;
|
|
37
|
-
};
|
|
38
|
-
readonly schemaName: string;
|
|
39
|
-
fromPlainData(obj: any): SupportOperation;
|
|
40
|
-
fromDatabase(obj: any): SupportOperation | undefined;
|
|
41
|
-
toDatabase(obj: any): Record<string, any>;
|
|
42
|
-
validate(obj: unknown, options?: import("@antelopejs/interface-database-decorators").ValidateInputOptions): import("@antelopejs/interface-database-decorators").ValidationResult;
|
|
43
|
-
};
|
|
44
|
-
export declare class SupportOperationModel extends SupportOperationModel_base {
|
|
45
|
-
prepare(candidate: SupportOperation): Promise<SupportOperation>;
|
|
46
|
-
finish(operation: SupportOperation, status: SupportOperationStatus, failure?: SupportOperationFailure | null): Promise<SupportOperation>;
|
|
47
|
-
}
|
|
48
|
-
export declare function supportOperationId(tenantId: string, actorId: string, requestId: string): string;
|
|
49
|
-
export declare function supportRequestFingerprint(intent: unknown): string;
|
|
50
|
-
export declare function supportPublication(operation: SupportOperation): SupportPublication;
|
|
51
|
-
export {};
|
|
@@ -1,109 +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.SupportOperationModel = exports.SupportOperation = void 0;
|
|
13
|
-
exports.supportOperationId = supportOperationId;
|
|
14
|
-
exports.supportRequestFingerprint = supportRequestFingerprint;
|
|
15
|
-
exports.supportPublication = supportPublication;
|
|
16
|
-
const node_crypto_1 = require("node:crypto");
|
|
17
|
-
const interface_api_util_1 = require("@antelopejs/interface-api-util");
|
|
18
|
-
const interface_database_decorators_1 = require("@antelopejs/interface-database-decorators");
|
|
19
|
-
const constants_1 = require("@antelopejs/interface-dms/constants");
|
|
20
|
-
const HTTP_CONFLICT = 409;
|
|
21
|
-
const HTTP_UNAVAILABLE = 503;
|
|
22
|
-
const SUPPORT_OPERATIONS_TABLE = "support_operations";
|
|
23
|
-
let SupportOperation = class SupportOperation extends interface_database_decorators_1.Table {
|
|
24
|
-
};
|
|
25
|
-
exports.SupportOperation = SupportOperation;
|
|
26
|
-
__decorate([
|
|
27
|
-
(0, interface_database_decorators_1.Field)("string"),
|
|
28
|
-
__metadata("design:type", String)
|
|
29
|
-
], SupportOperation.prototype, "_id", void 0);
|
|
30
|
-
__decorate([
|
|
31
|
-
(0, interface_database_decorators_1.Field)("string"),
|
|
32
|
-
__metadata("design:type", String)
|
|
33
|
-
], SupportOperation.prototype, "revision", void 0);
|
|
34
|
-
__decorate([
|
|
35
|
-
(0, interface_database_decorators_1.Field)("string"),
|
|
36
|
-
__metadata("design:type", String)
|
|
37
|
-
], SupportOperation.prototype, "status", void 0);
|
|
38
|
-
__decorate([
|
|
39
|
-
(0, interface_database_decorators_1.Field)("string"),
|
|
40
|
-
__metadata("design:type", String)
|
|
41
|
-
], SupportOperation.prototype, "fingerprint", void 0);
|
|
42
|
-
__decorate([
|
|
43
|
-
(0, interface_database_decorators_1.Field)("string"),
|
|
44
|
-
__metadata("design:type", String)
|
|
45
|
-
], SupportOperation.prototype, "kind", void 0);
|
|
46
|
-
__decorate([
|
|
47
|
-
(0, interface_database_decorators_1.Field)("string"),
|
|
48
|
-
__metadata("design:type", String)
|
|
49
|
-
], SupportOperation.prototype, "payload", void 0);
|
|
50
|
-
__decorate([
|
|
51
|
-
(0, interface_database_decorators_1.Field)("any"),
|
|
52
|
-
__metadata("design:type", Object)
|
|
53
|
-
], SupportOperation.prototype, "failure", void 0);
|
|
54
|
-
exports.SupportOperation = SupportOperation = __decorate([
|
|
55
|
-
(0, interface_database_decorators_1.RegisterTable)(SUPPORT_OPERATIONS_TABLE, constants_1.TENANT_SCHEMA_NAME)
|
|
56
|
-
], SupportOperation);
|
|
57
|
-
class SupportOperationModel extends (0, interface_database_decorators_1.BasicDataModel)(SupportOperation) {
|
|
58
|
-
async prepare(candidate) {
|
|
59
|
-
try {
|
|
60
|
-
await this.insert(candidate);
|
|
61
|
-
}
|
|
62
|
-
catch {
|
|
63
|
-
}
|
|
64
|
-
const stored = await this.get(candidate._id);
|
|
65
|
-
(0, interface_api_util_1.assert)(stored, HTTP_UNAVAILABLE, "saas.errors.support.operation_pending");
|
|
66
|
-
(0, interface_api_util_1.assert)(stored.fingerprint === candidate.fingerprint, HTTP_CONFLICT, "saas.errors.support.request_reused");
|
|
67
|
-
return stored;
|
|
68
|
-
}
|
|
69
|
-
async finish(operation, status, failure = null) {
|
|
70
|
-
if (operation.status === status)
|
|
71
|
-
return operation;
|
|
72
|
-
const outcome = await this.table
|
|
73
|
-
.atomicMutation(operation._id, {
|
|
74
|
-
type: "update",
|
|
75
|
-
revisionField: "revision",
|
|
76
|
-
expectedRevision: operation.revision,
|
|
77
|
-
nextRevision: `${operation._id}:${status}`,
|
|
78
|
-
patch: { status, failure },
|
|
79
|
-
})
|
|
80
|
-
.run();
|
|
81
|
-
const stored = await this.get(operation._id);
|
|
82
|
-
(0, interface_api_util_1.assert)(stored?.status === status, HTTP_UNAVAILABLE, outcome === "unknown"
|
|
83
|
-
? "saas.errors.support.operation_unknown"
|
|
84
|
-
: "saas.errors.support.operation_pending");
|
|
85
|
-
return stored;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
exports.SupportOperationModel = SupportOperationModel;
|
|
89
|
-
function supportOperationId(tenantId, actorId, requestId) {
|
|
90
|
-
return (0, node_crypto_1.createHash)("sha256")
|
|
91
|
-
.update(JSON.stringify([tenantId, actorId, requestId]))
|
|
92
|
-
.digest("hex");
|
|
93
|
-
}
|
|
94
|
-
function supportRequestFingerprint(intent) {
|
|
95
|
-
return (0, node_crypto_1.createHash)("sha256").update(JSON.stringify(intent)).digest("hex");
|
|
96
|
-
}
|
|
97
|
-
function supportPublication(operation) {
|
|
98
|
-
const publication = JSON.parse(operation.payload);
|
|
99
|
-
const { ticket, message, events } = publication;
|
|
100
|
-
ticket.createdAt = new Date(ticket.createdAt);
|
|
101
|
-
ticket.updatedAt = new Date(ticket.updatedAt);
|
|
102
|
-
ticket.lastMessageAt = new Date(ticket.lastMessageAt);
|
|
103
|
-
if (message)
|
|
104
|
-
message.createdAt = new Date(message.createdAt);
|
|
105
|
-
for (const event of events)
|
|
106
|
-
event.createdAt = new Date(event.createdAt);
|
|
107
|
-
return publication;
|
|
108
|
-
}
|
|
109
|
-
//# sourceMappingURL=operations.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"operations.js","sourceRoot":"","sources":["../../src/support/operations.ts"],"names":[],"mappings":";;;;;;;;;;;;AA6GA,gDAQC;AAGD,8DAEC;AAGD,gDAWC;AAxID,6CAAyC;AACzC,uEAAwD;AACxD,6FAKmD;AACnD,mEAAyE;AAGzE,MAAM,aAAa,GAAG,GAAG,CAAC;AAC1B,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAC7B,MAAM,wBAAwB,GAAG,oBAAoB,CAAC;AAyB/C,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,qCAAK;CAqB1C,CAAA;AArBY,4CAAgB;AAEnB;IADP,IAAA,qCAAK,EAAC,QAAQ,CAAC;;6CACI;AAGZ;IADP,IAAA,qCAAK,EAAC,QAAQ,CAAC;;kDACS;AAGjB;IADP,IAAA,qCAAK,EAAC,QAAQ,CAAC;;gDACuB;AAG/B;IADP,IAAA,qCAAK,EAAC,QAAQ,CAAC;;qDACY;AAGpB;IADP,IAAA,qCAAK,EAAC,QAAQ,CAAC;;8CACmB;AAG3B;IADP,IAAA,qCAAK,EAAC,QAAQ,CAAC;;iDACQ;AAGhB;IADP,IAAA,qCAAK,EAAC,KAAK,CAAC;;iDACoC;2BApBtC,gBAAgB;IAD5B,IAAA,6CAAa,EAAC,wBAAwB,EAAE,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 +0,0 @@
|
|
|
1
|
-
import type { SupportTicket } from "../db";
|
|
2
|
-
import type { SupportPublication } from "./operations";
|
|
3
|
-
import type { AddSupportMessageOptions, CreateSupportTicketOptions, UpdateSupportTicketOptions } from "./service";
|
|
4
|
-
export declare function createSupportPlan(options: CreateSupportTicketOptions, id: string): SupportPublication;
|
|
5
|
-
export declare function replySupportPlan(options: AddSupportMessageOptions, ticket: SupportTicket, id: string): SupportPublication;
|
|
6
|
-
export declare function updateSupportPlan(options: UpdateSupportTicketOptions, ticket: SupportTicket, id: string): SupportPublication;
|