@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.
Files changed (98) hide show
  1. package/README.md +0 -86
  2. package/dist/config/runtime.d.ts +0 -1
  3. package/dist/config/runtime.js +0 -7
  4. package/dist/config/runtime.js.map +1 -1
  5. package/dist/data-api/platformOwner/index.d.ts +0 -1
  6. package/dist/data-api/platformOwner/index.js +0 -1
  7. package/dist/data-api/platformOwner/index.js.map +1 -1
  8. package/dist/data-api/tenant/index.d.ts +0 -1
  9. package/dist/data-api/tenant/index.js +0 -1
  10. package/dist/data-api/tenant/index.js.map +1 -1
  11. package/dist/notifications/subjects.d.ts +0 -2
  12. package/dist/notifications/subjects.js +1 -13
  13. package/dist/notifications/subjects.js.map +1 -1
  14. package/dist/pages/platform/categories.d.ts +0 -1
  15. package/dist/pages/platform/categories.js +1 -8
  16. package/dist/pages/platform/categories.js.map +1 -1
  17. package/dist/pages/platform/index.d.ts +0 -1
  18. package/dist/pages/platform/index.js +0 -1
  19. package/dist/pages/platform/index.js.map +1 -1
  20. package/dist/pages/tenant/index.d.ts +0 -1
  21. package/dist/pages/tenant/index.js +0 -1
  22. package/dist/pages/tenant/index.js.map +1 -1
  23. package/dist/routes/platformOwner/index.d.ts +0 -1
  24. package/dist/routes/platformOwner/index.js +0 -1
  25. package/dist/routes/platformOwner/index.js.map +1 -1
  26. package/dist/routes/tenant/index.d.ts +0 -1
  27. package/dist/routes/tenant/index.js +0 -1
  28. package/dist/routes/tenant/index.js.map +1 -1
  29. package/dist/types/config.d.ts +0 -1
  30. package/frontend-vue/i18n/locales/saas-en-GB.json +1 -142
  31. package/frontend-vue/i18n/locales/saas-fr-FR.json +1 -142
  32. package/package.json +2 -4
  33. package/dist/data-api/platformOwner/support.d.ts +0 -58
  34. package/dist/data-api/platformOwner/support.js +0 -111
  35. package/dist/data-api/platformOwner/support.js.map +0 -1
  36. package/dist/data-api/support-fields.d.ts +0 -49
  37. package/dist/data-api/support-fields.js +0 -166
  38. package/dist/data-api/support-fields.js.map +0 -1
  39. package/dist/data-api/support-routes.d.ts +0 -10
  40. package/dist/data-api/support-routes.js +0 -71
  41. package/dist/data-api/support-routes.js.map +0 -1
  42. package/dist/data-api/tenant/support.d.ts +0 -39
  43. package/dist/data-api/tenant/support.js +0 -53
  44. package/dist/data-api/tenant/support.js.map +0 -1
  45. package/dist/pages/platform/support.d.ts +0 -9
  46. package/dist/pages/platform/support.js +0 -29
  47. package/dist/pages/platform/support.js.map +0 -1
  48. package/dist/pages/tenant/support.d.ts +0 -9
  49. package/dist/pages/tenant/support.js +0 -27
  50. package/dist/pages/tenant/support.js.map +0 -1
  51. package/dist/routes/platformOwner/support.d.ts +0 -21
  52. package/dist/routes/platformOwner/support.js +0 -180
  53. package/dist/routes/platformOwner/support.js.map +0 -1
  54. package/dist/routes/tenant/support.d.ts +0 -27
  55. package/dist/routes/tenant/support.js +0 -185
  56. package/dist/routes/tenant/support.js.map +0 -1
  57. package/dist/support/admissions.d.ts +0 -36
  58. package/dist/support/admissions.js +0 -136
  59. package/dist/support/admissions.js.map +0 -1
  60. package/dist/support/attachments.d.ts +0 -12
  61. package/dist/support/attachments.js +0 -56
  62. package/dist/support/attachments.js.map +0 -1
  63. package/dist/support/config.d.ts +0 -19
  64. package/dist/support/config.js +0 -75
  65. package/dist/support/config.js.map +0 -1
  66. package/dist/support/index.d.ts +0 -6
  67. package/dist/support/index.js +0 -23
  68. package/dist/support/index.js.map +0 -1
  69. package/dist/support/operations.d.ts +0 -51
  70. package/dist/support/operations.js +0 -109
  71. package/dist/support/operations.js.map +0 -1
  72. package/dist/support/plans.d.ts +0 -6
  73. package/dist/support/plans.js +0 -130
  74. package/dist/support/plans.js.map +0 -1
  75. package/dist/support/publications.d.ts +0 -8
  76. package/dist/support/publications.js +0 -106
  77. package/dist/support/publications.js.map +0 -1
  78. package/dist/support/recovery.d.ts +0 -7
  79. package/dist/support/recovery.js +0 -43
  80. package/dist/support/recovery.js.map +0 -1
  81. package/dist/support/service.d.ts +0 -51
  82. package/dist/support/service.js +0 -143
  83. package/dist/support/service.js.map +0 -1
  84. package/dist/support/transitions.d.ts +0 -4
  85. package/dist/support/transitions.js +0 -29
  86. package/dist/support/transitions.js.map +0 -1
  87. package/dist/support/uploads.d.ts +0 -39
  88. package/dist/support/uploads.js +0 -115
  89. package/dist/support/uploads.js.map +0 -1
  90. package/dist/support/validation.d.ts +0 -15
  91. package/dist/support/validation.js +0 -54
  92. package/dist/support/validation.js.map +0 -1
  93. package/frontend-vue/app/components/PlatformSupport.vue +0 -461
  94. package/frontend-vue/app/components/SupportAttachmentUpload.vue +0 -140
  95. package/frontend-vue/app/components/SupportThreadHistory.vue +0 -139
  96. package/frontend-vue/app/components/TenantSupport.vue +0 -415
  97. package/frontend-vue/app/composables/useSupportRequest.ts +0 -74
  98. package/frontend-vue/app/types/support.ts +0 -123
@@ -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,8BAAkB,CAAC;GAC/C,gBAAgB,CAqB5B;AAGD,MAAa,qBAAsB,SAAQ,IAAA,8CAAc,EAAC,gBAAgB,CAAC;IAEzE,KAAK,CAAC,OAAO,CAAC,SAA2B;QACvC,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAC/B,CAAC;QAAC,MAAM,CAAC;QAET,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QAC7C,IAAA,2BAAM,EAAC,M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Ae;IACvD,OAAO,IAAA,wBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC3E,CAAC;AAGD,SAAgB,kBAAkB,CAChC,SAA2B;IAE3B,MAAM,WAAW,GAAuB,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACtE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,WAAW,CAAC;IAChD,MAAM,CAAC,SAAS,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAC9C,MAAM,CAAC,SAAS,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAC9C,MAAM,CAAC,aAAa,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IACtD,IAAI,OAAO;QAAE,OAAO,CAAC,SAAS,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC7D,KAAK,MAAM,KAAK,IAAI,MAAM;QAAE,KAAK,CAAC,SAAS,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACxE,OAAO,WAAW,CAAC;AACrB,CAAC"}
@@ -1,6 +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;
@@ -1,130 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createSupportPlan = createSupportPlan;
4
- exports.replySupportPlan = replySupportPlan;
5
- exports.updateSupportPlan = updateSupportPlan;
6
- const transitions_1 = require("./transitions");
7
- function ticketEvents(ticket, next, actorId, actorName) {
8
- return [
9
- {
10
- type: "status_changed",
11
- previousValue: ticket.status,
12
- newValue: next.status,
13
- },
14
- {
15
- type: "assignment_changed",
16
- previousValue: ticket.assignedTo,
17
- newValue: next.assignedTo,
18
- },
19
- ]
20
- .filter((change) => change.previousValue !== change.newValue)
21
- .map((change) => ({
22
- ...change,
23
- _id: `${next.mutationId}:${change.type}`,
24
- ticketId: ticket._id,
25
- actorId,
26
- actorName,
27
- createdAt: next.updatedAt,
28
- }));
29
- }
30
- function nextTicket(ticket, operationId, update) {
31
- return {
32
- _id: ticket._id,
33
- subject: ticket.subject,
34
- category: ticket.category,
35
- priority: ticket.priority,
36
- createdBy: ticket.createdBy,
37
- createdAt: ticket.createdAt,
38
- status: update.status,
39
- assignedTo: update.assignedTo,
40
- lastMessageAt: update.lastMessageAt ?? ticket.lastMessageAt,
41
- updatedAt: update.updatedAt,
42
- revision: ticket.revision + 1,
43
- mutationId: operationId,
44
- publicationId: operationId,
45
- };
46
- }
47
- function createSupportPlan(options, id) {
48
- const now = new Date();
49
- const ticket = {
50
- _id: id,
51
- subject: options.input.subject,
52
- category: options.input.category,
53
- priority: options.input.priority,
54
- status: "open",
55
- assignedTo: null,
56
- createdBy: options.authorId,
57
- createdAt: now,
58
- updatedAt: now,
59
- lastMessageAt: now,
60
- revision: 0,
61
- mutationId: id,
62
- publicationId: id,
63
- };
64
- const message = {
65
- _id: `${id}:message`,
66
- ticketId: id,
67
- authorId: options.authorId,
68
- authorType: "tenant",
69
- body: options.input.body,
70
- attachments: [],
71
- createdAt: now,
72
- };
73
- return {
74
- expectedMutationId: null,
75
- ticket,
76
- message,
77
- events: [],
78
- stagedKeys: options.input.attachments,
79
- };
80
- }
81
- function replySupportPlan(options, ticket, id) {
82
- const now = new Date();
83
- const status = options.authorType === "tenant"
84
- ? (0, transitions_1.statusAfterTenantMessage)(ticket.status)
85
- : (0, transitions_1.statusAfterPlatformReply)(ticket.status);
86
- const next = nextTicket(ticket, id, {
87
- status,
88
- assignedTo: ticket.assignedTo,
89
- updatedAt: now,
90
- lastMessageAt: now,
91
- });
92
- const message = {
93
- _id: `${id}:message`,
94
- ticketId: ticket._id,
95
- authorId: options.authorId,
96
- authorType: options.authorType,
97
- body: options.input.body,
98
- attachments: [],
99
- createdAt: now,
100
- };
101
- return {
102
- expectedMutationId: ticket.mutationId,
103
- ticket: next,
104
- message,
105
- events: ticketEvents(ticket, next, options.authorId, options.authorName || options.authorId),
106
- stagedKeys: options.input.attachments,
107
- };
108
- }
109
- function updateSupportPlan(options, ticket, id) {
110
- const status = options.input.status ?? ticket.status;
111
- (0, transitions_1.assertSupportStatusTransition)(ticket.status, status);
112
- const assignedTo = options.input.assignedTo === undefined
113
- ? ticket.assignedTo
114
- : options.input.assignedTo;
115
- const next = nextTicket(ticket, id, {
116
- status,
117
- assignedTo,
118
- updatedAt: new Date(),
119
- });
120
- const events = ticketEvents(ticket, next, options.actorId, options.actorName);
121
- return {
122
- expectedMutationId: ticket.mutationId,
123
- unchanged: events.length === 0,
124
- ticket: events.length ? next : ticket,
125
- message: null,
126
- events,
127
- stagedKeys: [],
128
- };
129
- }
130
- //# sourceMappingURL=plans.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plans.js","sourceRoot":"","sources":["../../src/support/plans.ts"],"names":[],"mappings":";;AAkEA,8CAoCC;AAGD,4CAqCC;AAGD,8CAyBC;AAlKD,+CAIuB;AAEvB,SAAS,YAAY,CACnB,MAAqB,EACrB,IAAmB,EACnB,OAAe,EACf,SAAiB;IAEjB,OAAO;QACL;YACE,IAAI,EAAE,gBAAyB;YAC/B,aAAa,EAAE,MAAM,CAAC,MAAM;YAC5B,QAAQ,EAAE,IAAI,CAAC,MAAM;SACtB;QACD;YACE,IAAI,EAAE,oBAA6B;YACnC,aAAa,EAAE,MAAM,CAAC,UAAU;YACh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CAAC;QAC9B,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM;QACrC,OAAO,EAAE,IAAI;QACb,MAAM;QACN,UAAU,EAAE,EAAE;KACf,CAAC;AACJ,CAAC"}
@@ -1,8 +0,0 @@
1
- import { type SupportTicket, type SupportTicketModel } from "../db";
2
- import { type SupportOperation } from "./operations";
3
- import type { SupportModels } from "./service";
4
- export declare function reconcileSupportTicket(tickets: SupportTicketModel, ticketId: string): Promise<SupportTicket>;
5
- export declare function reconcileSupportPublication(models: SupportModels, ticket: SupportTicket): Promise<void>;
6
- export declare function readSupportTicket(models: SupportModels, ticketId: string): Promise<SupportTicket>;
7
- export declare function publishSupportOperation(models: SupportModels, operation: SupportOperation): Promise<SupportOperation>;
8
- export declare function committedSupportPublication(operation: SupportOperation): import("./operations").SupportPublication;
@@ -1,106 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.reconcileSupportTicket = reconcileSupportTicket;
4
- exports.reconcileSupportPublication = reconcileSupportPublication;
5
- exports.readSupportTicket = readSupportTicket;
6
- exports.publishSupportOperation = publishSupportOperation;
7
- exports.committedSupportPublication = committedSupportPublication;
8
- const node_util_1 = require("node:util");
9
- const interface_api_util_1 = require("@antelopejs/interface-api-util");
10
- const db_1 = require("../db");
11
- const operations_1 = require("./operations");
12
- const HTTP_NOT_FOUND = 404;
13
- const HTTP_CONFLICT = 409;
14
- const HTTP_UNAVAILABLE = 503;
15
- const MAX_PUBLICATIONS_PER_READ = 8;
16
- async function reconcileSupportTicket(tickets, ticketId) {
17
- const ticket = await tickets.get(ticketId);
18
- (0, interface_api_util_1.assert)(ticket, HTTP_NOT_FOUND, "saas.errors.support.ticket_not_found");
19
- if (!ticket.publicationId)
20
- return ticket;
21
- return readSupportTicket({
22
- tickets,
23
- messages: new db_1.SupportMessageModel(tickets.database),
24
- events: new db_1.SupportTicketEventModel(tickets.database),
25
- }, ticketId);
26
- }
27
- async function insertProjection(model, row) {
28
- try {
29
- await model.insert([row]);
30
- }
31
- catch {
32
- }
33
- const stored = await model.get(row._id);
34
- (0, interface_api_util_1.assert)(stored &&
35
- Object.entries(row).every(([key, value]) => (0, node_util_1.isDeepStrictEqual)(stored[key], value)), HTTP_UNAVAILABLE, "saas.errors.support.projection_pending");
36
- }
37
- async function reconcileSupportPublication(models, ticket) {
38
- if (!ticket.publicationId)
39
- return;
40
- const operations = new operations_1.SupportOperationModel(models.tickets.database);
41
- const operation = await operations.get(ticket.publicationId);
42
- (0, interface_api_util_1.assert)(operation && operation.status !== "rejected", HTTP_UNAVAILABLE, "saas.errors.support.operation_pending");
43
- const publication = (0, operations_1.supportPublication)(operation);
44
- (0, interface_api_util_1.assert)(publication.ticket._id === ticket._id, HTTP_UNAVAILABLE, "saas.errors.support.operation_pending");
45
- if (publication.message)
46
- await insertProjection(models.messages, publication.message);
47
- for (const event of publication.events)
48
- await insertProjection(models.events, event);
49
- await operations.finish(operation, "committed");
50
- await models.tickets.settlePublication(ticket._id, operation._id);
51
- }
52
- async function readSupportTicket(models, ticketId) {
53
- for (let attempt = 0; attempt < MAX_PUBLICATIONS_PER_READ; attempt += 1) {
54
- const ticket = await models.tickets.get(ticketId);
55
- (0, interface_api_util_1.assert)(ticket, HTTP_NOT_FOUND, "saas.errors.support.ticket_not_found");
56
- if (!ticket.publicationId)
57
- return ticket;
58
- await reconcileSupportPublication(models, ticket);
59
- }
60
- throw new Error("Support publication did not settle within the read budget");
61
- }
62
- async function publishTicket(models, operation) {
63
- const publication = (0, operations_1.supportPublication)(operation);
64
- if (publication.expectedMutationId !== null) {
65
- await models.tickets.publish(publication.ticket, publication.expectedMutationId);
66
- return;
67
- }
68
- try {
69
- await models.tickets.insert([publication.ticket]);
70
- }
71
- catch {
72
- }
73
- }
74
- async function publishSupportOperation(models, operation) {
75
- const operations = new operations_1.SupportOperationModel(models.tickets.database);
76
- const current = await operations.get(operation._id);
77
- (0, interface_api_util_1.assert)(current, HTTP_UNAVAILABLE, "saas.errors.support.operation_pending");
78
- if (current.status !== "ready")
79
- return current;
80
- operation = current;
81
- if ((0, operations_1.supportPublication)(operation).unchanged) {
82
- return operations.finish(operation, "committed");
83
- }
84
- await publishTicket(models, operation);
85
- const publication = (0, operations_1.supportPublication)(operation);
86
- const ticket = await models.tickets.get(publication.ticket._id);
87
- if (ticket?.publicationId === operation._id) {
88
- await reconcileSupportPublication(models, ticket);
89
- }
90
- const stored = await operations.get(operation._id);
91
- (0, interface_api_util_1.assert)(stored, HTTP_UNAVAILABLE, "saas.errors.support.operation_pending");
92
- if (stored.status !== "ready")
93
- return stored;
94
- if (ticket &&
95
- ticket.mutationId !== publication.expectedMutationId &&
96
- ticket.mutationId !== operation._id) {
97
- return operations.finish(stored, "rejected");
98
- }
99
- (0, interface_api_util_1.assert)(false, HTTP_UNAVAILABLE, "saas.errors.support.operation_unknown");
100
- }
101
- function committedSupportPublication(operation) {
102
- (0, interface_api_util_1.assert)(operation.status !== "rejected", operation.failure?.status ?? HTTP_CONFLICT, operation.failure?.code ?? "saas.errors.support.tenant_busy");
103
- (0, interface_api_util_1.assert)(operation.status === "committed", HTTP_UNAVAILABLE, "saas.errors.support.operation_pending");
104
- return (0, operations_1.supportPublication)(operation);
105
- }
106
- //# sourceMappingURL=publications.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"publications.js","sourceRoot":"","sources":["../../src/support/publications.ts"],"names":[],"mappings":";;AAqBA,wDAeC;AAgCD,kEAwBC;AAGD,8CAWC;AAsBD,0DA6BC;AAGD,kEAYC;AA5KD,yCAA8C;AAC9C,uEAAwD;AACxD,8BAKe;AACf,6CAIsB;AAGtB,MAAM,cAAc,GAAG,GAAG,CAAC;AAC3B,MAAM,aAAa,GAAG,GAAG,CAAC;AAC1B,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAC7B,MAAM,yBAAyB,GAAG,CAAC,CAAC;AAG7B,KAAK,UAAU,sBAAsB,CAC1C,OAA2B,E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AAS,CAAC,GAAG,EAAE,CAAC;QAC5C,MAAM,2BAA2B,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpD,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IACnD,IAAA,2BAAM,EAAC,MAAM,EAAE,gBAAgB,EAAE,uCAAuC,CAAC,CAAC;IAC1E,IAAI,MAAM,CAAC,MAAM,KAAK,OAAO;QAAE,OAAO,MAAM,CAAC;IAC7C,IACE,MAAM;QACN,MAAM,CAAC,UAAU,KAAK,WAAW,CAAC,kBAAkB;QACpD,MAAM,CAAC,UAAU,KAAK,SAAS,CAAC,GAAG,EACnC,CAAC;QACD,OAAO,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAC/C,CAAC;IACD,IAAA,2BAAM,EAAC,KAAK,EAAE,gBAAgB,EAAE,uCAAuC,CAAC,CAAC;AAC3E,CAAC;AAGD,SAAgB,2BAA2B,CAAC,SAA2B;IACrE,IAAA,2BAAM,EACJ,SAAS,CAAC,MAAM,KAAK,UAAU,EAC/B,SAAS,CAAC,OAAO,EAAE,MAAM,IAAI,aAAa,EAC1C,SAAS,CAAC,OAAO,EAAE,IAAI,IAAI,iCAAiC,CAC7D,CAAC;IACF,IAAA,2BAAM,EACJ,SAAS,CAAC,MAAM,KAAK,WAAW,EAChC,gBAAgB,EAChB,uCAAuC,CACxC,CAAC;IACF,OAAO,IAAA,+BAAkB,EAAC,SAAS,CAAC,CAAC;AACvC,CAAC"}
@@ -1,7 +0,0 @@
1
- import { type SupportModels } from "./service";
2
- export interface SupportRecoveryPage {
3
- nextCursor: string | null;
4
- processed: string[];
5
- pending: string[];
6
- }
7
- export declare function recoverSupportOperations(tenantId: string, models: SupportModels, after?: string): Promise<SupportRecoveryPage>;
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.recoverSupportOperations = recoverSupportOperations;
4
- const interface_api_util_1 = require("@antelopejs/interface-api-util");
5
- const operations_1 = require("./operations");
6
- const publications_1 = require("./publications");
7
- const service_1 = require("./service");
8
- const RECOVERY_PAGE_SIZE = 20;
9
- const HTTP_BAD_REQUEST = 400;
10
- const HTTP_UNAVAILABLE = 503;
11
- const RECEIPT_ID = /^[a-f0-9]{64}$/;
12
- async function recoverOperation(tenantId, models, operation) {
13
- const result = await (0, service_1.resumeSupportOperation)(tenantId, models, operation);
14
- (0, interface_api_util_1.assert)(result.status === "committed" || result.status === "rejected", HTTP_UNAVAILABLE, "saas.errors.support.operation_pending");
15
- const ticket = await models.tickets.get((0, operations_1.supportPublication)(operation).ticket._id);
16
- if (ticket?.publicationId === operation._id)
17
- await (0, publications_1.reconcileSupportPublication)(models, ticket);
18
- }
19
- async function recoverSupportOperations(tenantId, models, after = "") {
20
- (0, interface_api_util_1.assert)(after === "" || RECEIPT_ID.test(after), HTTP_BAD_REQUEST, "saas.errors.support.invalid_cursor");
21
- const operations = new operations_1.SupportOperationModel(models.tickets.database);
22
- const rows = await operations.table
23
- .filter((row) => row.key("_id").gt(after))
24
- .orderBy("_id", "asc")
25
- .slice(0, RECOVERY_PAGE_SIZE)
26
- .run();
27
- const page = {
28
- nextCursor: rows.length === RECOVERY_PAGE_SIZE ? rows.at(-1)._id : null,
29
- processed: [],
30
- pending: [],
31
- };
32
- for (const row of rows) {
33
- try {
34
- await recoverOperation(tenantId, models, row);
35
- page.processed.push(row._id);
36
- }
37
- catch {
38
- page.pending.push(row._id);
39
- }
40
- }
41
- return page;
42
- }
43
- //# sourceMappingURL=recovery.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"recovery.js","sourceRoot":"","sources":["../../src/support/recovery.ts"],"names":[],"mappings":";;AAuCA,4DA8BC;AArED,uEAAwD;AACxD,6CAIsB;AACtB,iDAA6D;AAC7D,uCAAuE;AAEvE,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B,MAAM,gBAAgB,GA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AM,IAAI,GAAwB;QAChC,UAAU,EAAE,IAAI,CAAC,MAAM,KAAK,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAE,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI;QACxE,SAAS,EAAE,EAAE;QACb,OAAO,EAAE,EAAE;KACZ,CAAC;IACF,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,CAAC;YACH,MAAM,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;YAC9C,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC/B,CAAC;QAAC,MAAM,CAAC;YACP,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -1,51 +0,0 @@
1
- import type { Tenant } from "@antelopejs/interface-dms/db";
2
- import type { SupportMessage, SupportMessageAuthorType, SupportMessageModel, SupportTicket, SupportTicketEventModel, SupportTicketModel, SupportTicketStatus } from "../db";
3
- import { type SupportOperation } from "./operations";
4
- import { type SupportMessageInput, type SupportTicketInput } from "./validation";
5
- export interface SupportModels {
6
- tickets: SupportTicketModel;
7
- messages: SupportMessageModel;
8
- events: SupportTicketEventModel;
9
- }
10
- export interface CreateSupportTicketOptions {
11
- tenant: Tenant;
12
- authorId: string;
13
- requestId: string;
14
- input: SupportTicketInput;
15
- models: SupportModels;
16
- validateNewRequest?: () => Promise<void>;
17
- }
18
- export interface AddSupportMessageOptions {
19
- tenantId: string;
20
- ticketId: string;
21
- authorId: string;
22
- authorName?: string;
23
- authorType: SupportMessageAuthorType;
24
- requestId: string;
25
- input: SupportMessageInput;
26
- models: SupportModels;
27
- }
28
- export interface SupportTicketUpdate {
29
- status: SupportTicketStatus;
30
- assignedTo: string | null;
31
- updatedAt: Date;
32
- lastMessageAt?: Date;
33
- }
34
- export interface SupportTicketPatch {
35
- status?: SupportTicketStatus;
36
- assignedTo?: string | null;
37
- }
38
- export interface UpdateSupportTicketOptions {
39
- tenantId: string;
40
- ticketId: string;
41
- requestId: string;
42
- input: SupportTicketPatch;
43
- actorId: string;
44
- actorName: string;
45
- models: SupportModels;
46
- validateNewRequest?: () => Promise<void>;
47
- }
48
- export declare function resumeSupportOperation(tenantId: string, models: SupportModels, operation: SupportOperation): Promise<SupportOperation>;
49
- export declare function createSupportTicket(options: CreateSupportTicketOptions): Promise<SupportTicket>;
50
- export declare function addSupportMessage(options: AddSupportMessageOptions): Promise<SupportMessage>;
51
- export declare function updateSupportTicket(options: UpdateSupportTicketOptions): Promise<SupportTicket>;