@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,185 +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
- var __param = (this && this.__param) || function (paramIndex, decorator) {
12
- return function (target, key) { decorator(target, key, paramIndex); }
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.SaasTenantSupportController = void 0;
16
- const interface_api_1 = require("@antelopejs/interface-api");
17
- const interface_api_util_1 = require("@antelopejs/interface-api-util");
18
- const interface_database_decorators_1 = require("@antelopejs/interface-database-decorators");
19
- const interface_file_storage_1 = require("@antelopejs/interface-file-storage");
20
- const db_1 = require("@antelopejs/interface-dms/db");
21
- const guards_1 = require("@antelopejs/interface-dms/guards");
22
- const request_tenant_1 = require("@antelopejs/interface-dms/request-tenant");
23
- const tenant_scoped_model_1 = require("@antelopejs/interface-dms/tenant-scoped-model");
24
- const db_2 = require("../../db");
25
- const notifications_1 = require("../../notifications");
26
- const support_1 = require("../../support");
27
- const uploads_1 = require("../../support/uploads");
28
- const HTTP_NOT_FOUND = 404;
29
- const PLATFORM_SUPPORT_PATH = "/modules/saas/support/support";
30
- function supportModels(tickets, messages, events) {
31
- return { tickets, messages, events };
32
- }
33
- async function requireTenant(model, tenantId) {
34
- const tenant = await model.get(tenantId);
35
- (0, interface_api_util_1.assert)(tenant, HTTP_NOT_FOUND, "saas.errors.workspace.not_found");
36
- return tenant;
37
- }
38
- class SaasTenantSupportController extends (0, interface_api_1.Controller)("/api/saas/support") {
39
- async config(_user, ctx, subscriptions) {
40
- const uploadPath = (0, support_1.tenantSupportAttachmentPath)((0, request_tenant_1.getRequestTenantId)(ctx));
41
- return {
42
- policy: await (0, support_1.resolveTenantSupportPolicy)(subscriptions, this.planModel),
43
- uploadPath,
44
- maxAttachmentSize: support_1.SUPPORT_ATTACHMENT_MAX_SIZE,
45
- allowedMimetypes: support_1.SUPPORT_ATTACHMENT_MIMETYPES,
46
- };
47
- }
48
- async upload(_user, ctx, body) {
49
- return (0, uploads_1.createSupportUpload)((0, request_tenant_1.getRequestTenantId)(ctx), (0, uploads_1.parseSupportUpload)(body));
50
- }
51
- async create(user, ctx, body, tickets, messages, subscriptions, events) {
52
- const tenantId = (0, request_tenant_1.getRequestTenantId)(ctx);
53
- const input = (0, support_1.parseSupportTicket)(body);
54
- const tenant = await requireTenant(this.tenantModel, tenantId);
55
- const ticket = await (0, support_1.createSupportTicket)({
56
- tenant,
57
- authorId: user._id,
58
- requestId: (0, support_1.parseSupportRequestId)(body),
59
- input,
60
- models: supportModels(tickets, messages, events),
61
- validateNewRequest: async () => {
62
- const policy = await (0, support_1.resolveTenantSupportPolicy)(subscriptions, this.planModel);
63
- (0, support_1.assertPriorityAllowed)(input.priority, policy);
64
- },
65
- });
66
- await (0, notifications_1.notifyAllPlatformOwners)(notifications_1.supportNewMessageSubject, {
67
- icon: "i-ph-lifebuoy",
68
- title: "$saas.notifications.payload.support_new_ticket.title",
69
- description: input.subject,
70
- linkTo: PLATFORM_SUPPORT_PATH,
71
- });
72
- return ticket;
73
- }
74
- async detail(_user, ticketId, tickets) {
75
- const ticket = await (0, support_1.reconcileSupportTicket)(tickets, ticketId);
76
- return { ticket };
77
- }
78
- async reply(user, ctx, ticketId, body, tickets, messages, events) {
79
- const tenantId = (0, request_tenant_1.getRequestTenantId)(ctx);
80
- const message = await (0, support_1.addSupportMessage)({
81
- tenantId,
82
- ticketId,
83
- authorId: user._id,
84
- authorName: user.name,
85
- authorType: "tenant",
86
- requestId: (0, support_1.parseSupportRequestId)(body),
87
- input: (0, support_1.parseSupportMessage)(body),
88
- models: supportModels(tickets, messages, events),
89
- });
90
- await (0, notifications_1.notifyAllPlatformOwners)(notifications_1.supportNewMessageSubject, {
91
- icon: "i-ph-chat-circle-text",
92
- title: "$saas.notifications.payload.support_tenant_reply.title",
93
- description: "$saas.notifications.payload.support_tenant_reply.description",
94
- linkTo: PLATFORM_SUPPORT_PATH,
95
- }, user._id);
96
- return message;
97
- }
98
- async attachment(_user, ctx, ticketId, resourceKey, tickets, messages) {
99
- await (0, support_1.reconcileSupportTicket)(tickets, ticketId);
100
- (0, interface_api_util_1.assert)(await messages.hasAttachment(ticketId, resourceKey), HTTP_NOT_FOUND, "saas.errors.support.attachment_not_found");
101
- const upload = await (0, uploads_1.getSupportUpload)((0, request_tenant_1.getRequestTenantId)(ctx), (0, interface_file_storage_1.toStagedKey)(resourceKey));
102
- return (0, support_1.getSupportAttachmentMetadata)(resourceKey, upload.storage);
103
- }
104
- }
105
- exports.SaasTenantSupportController = SaasTenantSupportController;
106
- __decorate([
107
- (0, interface_database_decorators_1.Model)(db_1.TenantModel),
108
- __metadata("design:type", db_1.TenantModel)
109
- ], SaasTenantSupportController.prototype, "tenantModel", void 0);
110
- __decorate([
111
- (0, interface_database_decorators_1.Model)(db_2.PlanModel),
112
- __metadata("design:type", db_2.PlanModel)
113
- ], SaasTenantSupportController.prototype, "planModel", void 0);
114
- __decorate([
115
- (0, interface_api_1.Get)("/config"),
116
- __param(0, (0, guards_1.AuthTenantMember)()),
117
- __param(1, (0, interface_api_1.Context)()),
118
- __param(2, (0, tenant_scoped_model_1.TenantScopedModel)(db_2.TenantSubscriptionModel)),
119
- __metadata("design:type", Function),
120
- __metadata("design:paramtypes", [Function, Object, db_2.TenantSubscriptionModel]),
121
- __metadata("design:returntype", Promise)
122
- ], SaasTenantSupportController.prototype, "config", null);
123
- __decorate([
124
- (0, interface_api_1.Post)("/uploads"),
125
- __param(0, (0, guards_1.AuthTenantMember)()),
126
- __param(1, (0, interface_api_1.Context)()),
127
- __param(2, (0, interface_api_1.JSONBody)()),
128
- __metadata("design:type", Function),
129
- __metadata("design:paramtypes", [Function, Object, Object]),
130
- __metadata("design:returntype", Promise)
131
- ], SaasTenantSupportController.prototype, "upload", null);
132
- __decorate([
133
- (0, interface_api_1.Post)("/"),
134
- __param(0, (0, guards_1.AuthTenantMember)()),
135
- __param(1, (0, interface_api_1.Context)()),
136
- __param(2, (0, interface_api_1.JSONBody)()),
137
- __param(3, (0, tenant_scoped_model_1.TenantScopedModel)(db_2.SupportTicketModel)),
138
- __param(4, (0, tenant_scoped_model_1.TenantScopedModel)(db_2.SupportMessageModel)),
139
- __param(5, (0, tenant_scoped_model_1.TenantScopedModel)(db_2.TenantSubscriptionModel)),
140
- __param(6, (0, tenant_scoped_model_1.TenantScopedModel)(db_2.SupportTicketEventModel)),
141
- __metadata("design:type", Function),
142
- __metadata("design:paramtypes", [Function, Object, Object, db_2.SupportTicketModel,
143
- db_2.SupportMessageModel,
144
- db_2.TenantSubscriptionModel,
145
- db_2.SupportTicketEventModel]),
146
- __metadata("design:returntype", Promise)
147
- ], SaasTenantSupportController.prototype, "create", null);
148
- __decorate([
149
- (0, interface_api_1.Get)("/:ticketId"),
150
- __param(0, (0, guards_1.AuthTenantMember)()),
151
- __param(1, (0, interface_api_1.Parameter)("ticketId")),
152
- __param(2, (0, tenant_scoped_model_1.TenantScopedModel)(db_2.SupportTicketModel)),
153
- __metadata("design:type", Function),
154
- __metadata("design:paramtypes", [Function, String, db_2.SupportTicketModel]),
155
- __metadata("design:returntype", Promise)
156
- ], SaasTenantSupportController.prototype, "detail", null);
157
- __decorate([
158
- (0, interface_api_1.Post)("/:ticketId/messages"),
159
- __param(0, (0, guards_1.AuthTenantMember)()),
160
- __param(1, (0, interface_api_1.Context)()),
161
- __param(2, (0, interface_api_1.Parameter)("ticketId")),
162
- __param(3, (0, interface_api_1.JSONBody)()),
163
- __param(4, (0, tenant_scoped_model_1.TenantScopedModel)(db_2.SupportTicketModel)),
164
- __param(5, (0, tenant_scoped_model_1.TenantScopedModel)(db_2.SupportMessageModel)),
165
- __param(6, (0, tenant_scoped_model_1.TenantScopedModel)(db_2.SupportTicketEventModel)),
166
- __metadata("design:type", Function),
167
- __metadata("design:paramtypes", [Function, Object, String, Object, db_2.SupportTicketModel,
168
- db_2.SupportMessageModel,
169
- db_2.SupportTicketEventModel]),
170
- __metadata("design:returntype", Promise)
171
- ], SaasTenantSupportController.prototype, "reply", null);
172
- __decorate([
173
- (0, interface_api_1.Get)("/:ticketId/attachment"),
174
- __param(0, (0, guards_1.AuthTenantMember)()),
175
- __param(1, (0, interface_api_1.Context)()),
176
- __param(2, (0, interface_api_1.Parameter)("ticketId")),
177
- __param(3, (0, interface_api_1.Parameter)("resourceKey", "query")),
178
- __param(4, (0, tenant_scoped_model_1.TenantScopedModel)(db_2.SupportTicketModel)),
179
- __param(5, (0, tenant_scoped_model_1.TenantScopedModel)(db_2.SupportMessageModel)),
180
- __metadata("design:type", Function),
181
- __metadata("design:paramtypes", [Function, Object, String, String, db_2.SupportTicketModel,
182
- db_2.SupportMessageModel]),
183
- __metadata("design:returntype", Promise)
184
- ], SaasTenantSupportController.prototype, "attachment", null);
185
- //# sourceMappingURL=support.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"support.js","sourceRoot":"","sources":["../../../src/routes/tenant/support.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6DAQmC;AACnC,uEAAwD;AACxD,6FAAkE;AAClE,+EAG4C;AAC5C,qDAA2D;AAC3D,6DAAoE;AACpE,6EAA8E;AAC9E,uFAAkF;AAElF,iCAQkB;AAClB,uDAG6B;AAC7B,2CAgBuB;AACvB,mDAI+B;AAE/B,MAAM,cAAc,GAAG,GAAG,CAAC;AAC3B,MAAM,qBAAqB,GAAG,+BAA+B,CAAC;AAa9D,SAAS,aAAa,CACpB,OAA2B,EAC3B,QAA6B,EAC7B,MAA+B;IAE/B,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;AACvC,CAAC;AAED,KAAK,UAAU,aAAa,CAC1B,KAAkB,EAClB,QAAgB;IAEhB,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACzC,IAAA,2BAAM,EAAC,MAAM,EAAE,cAAc,EAAE,iCAAiC,CAAC,CAAC;IAClE,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAa,2BAA4B,SAAQ,IAAA,0BAAU,EACzD,mBAAmB,CACpB;IAQO,AAAN,KAAK,CAAC,MAAM,CACU,KAAW,EACpB,GAAmB,EAE9B,aAAsC;QAEtC,MAAM,UAAU,GAAG,IAAA,qCAA2B,EAAC,IAAA,mCAAkB,EAAC,GAAG,CAAC,CAAC,CAAC;QACxE,OAAO;YACL,MAAM,EAAE,MAAM,IAAA,oCAA0B,EAAC,aAAa,EAAE,IAAI,CAAC,SAAS,CAAC;YACvE,UAAU;YACV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;yDA0B5E;AAGK;IADL,IAAA,mBAAG,EAAC,YAAY,CAAC;IAEf,WAAA,IAAA,yBAAgB,GAAE,CAAA;IAClB,WAAA,IAAA,yBAAS,EAAC,UAAU,CAAC,CAAA;IACrB,WAAA,IAAA,uCAAiB,EAAC,uBAAkB,CAAC,CAAA;;uDAAU,uBAAkB;;yDAInE;AAOK;IALL,IAAA,oBAAI,EAAC,qBAAqB,CAAC;IAMzB,WAAA,IAAA,yBAAgB,GAAE,CAAA;IAClB,WAAA,IAAA,uBAAO,GAAE,CAAA;IACT,WAAA,IAAA,yBAAS,EAAC,UAAU,CAAC,CAAA;IACrB,WAAA,IAAA,wBAAQ,GAAE,CAAA;IACV,WAAA,IAAA,uCAAiB,EAAC,uBAAkB,CAAC,CAAA;IACrC,WAAA,IAAA,uCAAiB,EAAC,wBAAmB,CAAC,CAAA;IACtC,WAAA,IAAA,uCAAiB,EAAC,4BAAuB,CAAC,CAAA;;uEAFK,uBAAkB;QAChB,wBAAmB;QACjB,4BAAuB;;wDAyB5E;AAKK;IAHL,IAAA,mBAAG,EAAC,uBAAuB,CAAC;IAI1B,WAAA,IAAA,yBAAgB,GAAE,CAAA;IAClB,WAAA,IAAA,uBAAO,GAAE,CAAA;IACT,WAAA,IAAA,yBAAS,EAAC,UAAU,CAAC,CAAA;IACrB,WAAA,IAAA,yBAAS,EAAC,aAAa,EAAE,OAAO,CAAC,CAAA;IACjC,WAAA,IAAA,uCAAiB,EAAC,uBAAkB,CAAC,CAAA;IACrC,WAAA,IAAA,uCAAiB,EAAC,wBAAmB,CAAC,CAAA;;uEADS,uBAAkB;QAChB,wBAAmB;;6DAatE"}
@@ -1,36 +0,0 @@
1
- import { Table } from "@antelopejs/interface-database-decorators";
2
- import { type SupportOperation, SupportOperationModel } from "./operations";
3
- export declare class SupportAttachmentAdmission extends Table {
4
- _id: string;
5
- operationId: string;
6
- stagedKey: string;
7
- storage: string;
8
- finalKey: string;
9
- revision: string;
10
- promotionConfirmed: boolean;
11
- }
12
- declare const SupportAttachmentAdmissionModel_base: {
13
- new (database: import("@antelopejs/interface-database").SchemaInstance<any>): {
14
- readonly table: import("@antelopejs/interface-database").Table<SupportAttachmentAdmission>;
15
- readonly database: import("@antelopejs/interface-database").SchemaInstance<any>;
16
- get(id: string): PromiseLike<SupportAttachmentAdmission | undefined>;
17
- getBy(index: keyof SupportAttachmentAdmission, ...keys: any[]): PromiseLike<SupportAttachmentAdmission[]>;
18
- getAll(): PromiseLike<SupportAttachmentAdmission[]>;
19
- insert(obj: import("@antelopejs/interface-database-decorators").DeepPartial<SupportAttachmentAdmission> | import("@antelopejs/interface-database-decorators").DeepPartial<SupportAttachmentAdmission>[], options?: import("@antelopejs/interface-database-decorators").ValidateOptions): Promise<string[]>;
20
- update(id: string, obj: import("@antelopejs/interface-database-decorators").DeepPartial<SupportAttachmentAdmission>, options?: import("@antelopejs/interface-database-decorators").ValidateOptions): Promise<number>;
21
- update(obj: import("@antelopejs/interface-database-decorators").DeepPartial<SupportAttachmentAdmission>, options?: import("@antelopejs/interface-database-decorators").ValidateOptions): Promise<number>;
22
- delete(id: string): Promise<number>;
23
- };
24
- readonly schemaName: string;
25
- fromPlainData(obj: any): SupportAttachmentAdmission;
26
- fromDatabase(obj: any): SupportAttachmentAdmission | undefined;
27
- toDatabase(obj: any): Record<string, any>;
28
- validate(obj: unknown, options?: import("@antelopejs/interface-database-decorators").ValidateInputOptions): import("@antelopejs/interface-database-decorators").ValidationResult;
29
- };
30
- export declare class SupportAttachmentAdmissionModel extends SupportAttachmentAdmissionModel_base {
31
- admit(candidate: SupportAttachmentAdmission): Promise<SupportAttachmentAdmission>;
32
- confirmPromotion(admission: SupportAttachmentAdmission): Promise<void>;
33
- }
34
- export declare function prepareSupportAttachments(operations: SupportOperationModel, operation: SupportOperation, tenantId: string): Promise<void>;
35
- export declare function cancelSupportAttachments(operation: SupportOperation): Promise<void>;
36
- export {};
@@ -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"],"names":[],"mappings":";;;;;;;;;;;;AA2IA,8DAaC;AAGD,4DA4BC;AAvLD,uEAAwD;AACxD,6FAOmD;AACnD,+EAK4C;AAC5C,mEAAuE;AACvE,+CAGuB;AACvB,qCAAuD;AACvD,6CAIsB;AACtB,uCAAiE;AAEjE,MAAM,aAAa,GAAG,GAAG,CAAC;AAC1B,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAC7B,MAAM,wBAAwB,GAAG,+BAA+B,CAAC;AAI1D,IAAM,0BAA0B,GAAhC,MAAM,0BAA2B,SAAQ,qCAAK;CAgBpD,CAAA;AAhBY,gEAA0B;AAE7B;IADP,IAAA,qCAAK,EAAC,QAAQ,CAAC;;uDACI;AAGZ;IAFP,IAAA,qCAAK,GAAE;IACP,IAAA,qCAAK,EAAC,QAAQ,CAAC;;+DACY;AAEpB;IADP,IAAA,qCAAK,EAAC,QAAQ,CAAC;;6DACU;AAElB;IADP,IAAA,qCAAK,EAAC,QAAQ,CAAC;;2DACQ;AAEhB;IADP,IAAA,qCAAK,EAAC,QAAQ,CAAC;;4DACS;AAEjB;IADP,IAAA,qCAAK,EAAC,QAAQ,CAAC;;4DACS;AAEjB;IADP,IAAA,qCAAK,EAAC,SAAS,CAAC;;sEACmB;qCAfzB,0BAA0B;IADtC,IAAA,6CAAa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,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","sourceRoot":"","sources":["../../src/support/attachments.ts"],"names":[],"mappings":";;AAsDA,kEAUC;AAGD,0EAWC;AAED,oEAkBC;AAlGD,uEAAwD;AACxD,+EAM4C;AAC5C,qCAGkB;AAElB,MAAM,gBAAgB,GAAG,GAAG,CAAC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gBAAgB,EAChB,yCAAyC,CAC1C,CAAC;AACJ,CAAC;AAGD,SAAgB,+BAA+B,CAC7C,QAAqC;IAErC,IAAA,2BAAM,EACJ,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC;QACjC,QAAQ,CAAC,IAAI,IAAI,CAAC;QAClB,QAAQ,CAAC,IAAI,IAAI,oCAA2B;QAC5C,iBAAiB,CAAC,QAAQ,CAAC,QAAQ,CAAC,EACtC,gBAAgB,EAChB,yCAAyC,CAC1C,CAAC;AACJ,CAAC;AAEM,KAAK,UAAU,4BAA4B,CAChD,WAAmB,EACnB,OAAe;IAEf,IAAA,2BAAM,EACJ,OAAO,OAAO,KAAK,QAAQ;QACzB,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;QACzB,CAAC,IAAA,oCAAW,EAAC,WAAW,CAAC;QACzB,WAAW,KAAK,IAAA,2CAAkB,EAAC,WAAW,CAAC;QAC/C,iBAAiB,CAAC,WAAW,CAAC,EAChC,gBAAgB,EAChB,wCAAwC,CACzC,CAAC;IACF,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACzC,IAAA,wCAAe,EAAC,WAAW,EAAE,OAAO,CAAC;QACrC,IAAA,sCAAa,EAAC,WAAW,EAAE,SAAS,EAAE,OAAO,CAAC;KAC/C,CAAC,CAAC;IACH,OAAO,EAAE,GAAG,QAAQ,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC;AACnE,CAAC"}
@@ -1,19 +0,0 @@
1
- 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>;
@@ -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 @@
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AAiB,EAAE,KAAK;QACxB,UAAU,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC;KAChD;CACF,CAAC;AAEF,SAAgB,gBAAgB,CAAC,KAAc;IAC7C,MAAM,KAAK,GACT,OAAO,KAAK,KAAK,QAAQ,IAAI,gBAAgB,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"}
@@ -1,6 +0,0 @@
1
- export * from "./attachments";
2
- export * from "./config";
3
- export * from "./publications";
4
- export * from "./service";
5
- export * from "./transitions";
6
- export * from "./validation";
@@ -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"}