@coast/service-common 1.0.13 → 2.0.14

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 (55) hide show
  1. package/README.md +2 -2
  2. package/dist/lib/{modules/logger → logger}/CoastLogger.d.ts +1 -2
  3. package/dist/lib/{modules/logger → logger}/PinoLogger.d.ts +1 -1
  4. package/dist/lib/{modules/logger → logger}/PinoLogger.js +3 -23
  5. package/dist/lib/trace/TraceManager.js +21 -0
  6. package/dist/tsconfig.tsbuildinfo +1 -0
  7. package/package.json +14 -47
  8. package/LICENSE +0 -21
  9. package/dist/lib/models/Constants.d.ts +0 -4
  10. package/dist/lib/models/Constants.js +0 -7
  11. package/dist/lib/models/coast-api/CoastApiModuleAsyncOptions.d.ts +0 -7
  12. package/dist/lib/models/coast-api/CoastApiModuleAsyncOptions.js +0 -2
  13. package/dist/lib/models/coast-api/CoastApiOptions.d.ts +0 -4
  14. package/dist/lib/models/coast-api/CoastApiOptions.js +0 -2
  15. package/dist/lib/models/coast-api/CoastApiRequests.d.ts +0 -70
  16. package/dist/lib/models/coast-api/CoastApiRequests.js +0 -253
  17. package/dist/lib/models/coast-api/WorkflowEntityGqlFields.d.ts +0 -3
  18. package/dist/lib/models/coast-api/WorkflowEntityGqlFields.js +0 -14
  19. package/dist/lib/models/coast-api/WorkflowTemplateGqlFields.d.ts +0 -3
  20. package/dist/lib/models/coast-api/WorkflowTemplateGqlFields.js +0 -129
  21. package/dist/lib/models/logger/LoggerModuleAsyncOptions.d.ts +0 -7
  22. package/dist/lib/models/logger/LoggerModuleAsyncOptions.js +0 -2
  23. package/dist/lib/modules/coast-api/CoastApiClient.d.ts +0 -46
  24. package/dist/lib/modules/coast-api/CoastApiClient.js +0 -124
  25. package/dist/lib/modules/coast-api/CoastApiClientGqlError.d.ts +0 -12
  26. package/dist/lib/modules/coast-api/CoastApiClientGqlError.js +0 -10
  27. package/dist/lib/modules/coast-api/CoastApiModule.d.ts +0 -6
  28. package/dist/lib/modules/coast-api/CoastApiModule.js +0 -42
  29. package/dist/lib/modules/logger/LoggerModule.d.ts +0 -7
  30. package/dist/lib/modules/logger/LoggerModule.js +0 -56
  31. package/dist/lib/modules/trace/TraceInterceptor.d.ts +0 -8
  32. package/dist/lib/modules/trace/TraceInterceptor.js +0 -30
  33. package/dist/lib/modules/trace/TraceManager.js +0 -40
  34. package/dist/lib/modules/trace/TraceModule.d.ts +0 -2
  35. package/dist/lib/modules/trace/TraceModule.js +0 -22
  36. package/dist/lib/modules/utils/graphql/GqlRequestBody.d.ts +0 -8
  37. package/dist/lib/modules/utils/graphql/GqlRequestBody.js +0 -2
  38. package/dist/lib/modules/utils/graphql/GqlResponse.d.ts +0 -14
  39. package/dist/lib/modules/utils/graphql/GqlResponse.js +0 -2
  40. /package/dist/lib/{modules/logger → logger}/CoastLogger.js +0 -0
  41. /package/dist/lib/{models/logger → logger}/LogLevel.d.ts +0 -0
  42. /package/dist/lib/{models/logger → logger}/LogLevel.js +0 -0
  43. /package/dist/lib/{models/logger → logger}/LoggerOptions.d.ts +0 -0
  44. /package/dist/lib/{models/logger → logger}/LoggerOptions.js +0 -0
  45. /package/dist/lib/{modules/logger → logger}/SilentLogger.d.ts +0 -0
  46. /package/dist/lib/{modules/logger → logger}/SilentLogger.js +0 -0
  47. /package/dist/lib/{modules/utils/streams → streams}/Generators.d.ts +0 -0
  48. /package/dist/lib/{modules/utils/streams → streams}/Generators.js +0 -0
  49. /package/dist/lib/{modules/trace → trace}/Trace.d.ts +0 -0
  50. /package/dist/lib/{modules/trace → trace}/Trace.js +0 -0
  51. /package/dist/lib/{modules/trace → trace}/TraceId.d.ts +0 -0
  52. /package/dist/lib/{modules/trace → trace}/TraceId.js +0 -0
  53. /package/dist/lib/{modules/trace → trace}/TraceManager.d.ts +0 -0
  54. /package/dist/lib/{modules/trace → trace}/Traceable.d.ts +0 -0
  55. /package/dist/lib/{modules/trace → trace}/Traceable.js +0 -0
@@ -1,253 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CoastApiRequests = void 0;
4
- const WorkflowEntityGqlFields_1 = require("./WorkflowEntityGqlFields");
5
- const WorkflowTemplateGqlFields_1 = require("./WorkflowTemplateGqlFields");
6
- class CoastApiRequests {
7
- static aggregateRelatedCardQuantityStats(filter) {
8
- return {
9
- query: `
10
- query ($input: AggregateRelatedCardQuantity!) {
11
- aggregateRelatedCardQuantityStats(input: $input)
12
- }
13
- `,
14
- variables: { input: filter },
15
- };
16
- }
17
- static createEntityAuditTrailEvent(createEntityAuditTrailEvent) {
18
- return {
19
- query: `
20
- mutation ($input: CreateEntityAuditTrailEvent!) {
21
- createEntityAuditTrailEvent(input: $input) { id }
22
- }
23
- `,
24
- variables: { input: createEntityAuditTrailEvent },
25
- };
26
- }
27
- static createUsers(createUsers) {
28
- return {
29
- query: `
30
- mutation ($input: [CreateUserV2!]!) {
31
- createUsersV2(input: $input) {
32
- id
33
- firstName
34
- lastName
35
- email
36
- phoneNumber
37
- createdAt
38
- updatedAt
39
- }
40
- }
41
- `,
42
- variables: { input: createUsers },
43
- };
44
- }
45
- static createWorkflowAutomationEvent(createWorkflowAutomationEvent) {
46
- return {
47
- query: `
48
- mutation ($input: CreateWorkflowAutomationEvent!) {
49
- createWorkflowAutomationEvent(input: $input)
50
- }
51
- `,
52
- variables: { input: createWorkflowAutomationEvent },
53
- };
54
- }
55
- static createWorkflowEntity(createWorkflowEntity) {
56
- return {
57
- query: `
58
- mutation ($input: CreateWorkflowEntity!) {
59
- createWorkflowEntity(input: $input) {
60
- entity {
61
- id
62
- workflowTemplateId
63
- fields
64
- }
65
- refs {
66
- workflowEntityRefs {
67
- id
68
- }
69
- personRefs {
70
- id
71
- }
72
- workflowTemplateRefs {
73
- id
74
- }
75
- }
76
- }
77
- }
78
- `,
79
- variables: { input: createWorkflowEntity },
80
- };
81
- }
82
- static getCard(cardId) {
83
- return {
84
- query: `
85
- query ($id: UUID!) {
86
- getCard(id: $id) {
87
- id
88
- fields
89
- }
90
- }
91
- `,
92
- variables: { id: cardId },
93
- };
94
- }
95
- static getChannel(channelId) {
96
- return {
97
- query: `
98
- query ($id: Int!) {
99
- getChannel(id: $id) {
100
- id
101
- name
102
- slug
103
- }
104
- }
105
- `,
106
- variables: { id: channelId },
107
- };
108
- }
109
- static getSamlUser(email, samlOrganizationId) {
110
- return {
111
- query: `
112
- query ($input: GetSamlUser!) {
113
- getSamlUser(input: $input) {
114
- id
115
- email
116
- businessId
117
- }
118
- }
119
- `,
120
- variables: { input: { email, samlOrganizationId } },
121
- };
122
- }
123
- static getWorkflowEntity(workflowEntityId) {
124
- return {
125
- query: `
126
- query ($id: UUID!) {
127
- getWorkflowEntity(id: $id) {
128
- ${WorkflowEntityGqlFields_1.WorkflowEntityGqlFields.fields}
129
- }
130
- }
131
- `,
132
- variables: { id: workflowEntityId },
133
- };
134
- }
135
- static getWorkflowTemplate(workflowTemplateId) {
136
- return {
137
- query: `
138
- query ($id: UUID!) {
139
- getWorkflowTemplate(id: $id) {
140
- components {
141
- ${WorkflowTemplateGqlFields_1.WorkflowTemplateGqlFields.componentFields}
142
- }
143
- }
144
- }
145
- `,
146
- variables: { id: workflowTemplateId },
147
- };
148
- }
149
- static listWorkflowEntitiesFormData(filter) {
150
- return {
151
- query: `
152
- query ($input: ListEntitiesFormData!) {
153
- listEntitiesFormData(input: $input) {
154
- hasMore
155
- totalResults
156
- exports {
157
- type
158
- title
159
- targetFormat
160
- data {
161
- ... on ComponentDataExport {
162
- label
163
- value
164
- imageUrls
165
- type
166
- }
167
- ... on SubformDataExport {
168
- type
169
- title
170
- businessName
171
- data {
172
- ... on ComponentDataExport {
173
- label
174
- value
175
- imageUrls
176
- type
177
- }
178
- }
179
- }
180
- }
181
- businessName
182
- url
183
- }
184
- }
185
- }
186
- `,
187
- variables: { input: filter },
188
- };
189
- }
190
- static updateCard(card) {
191
- return {
192
- query: `
193
- mutation ($input: UpdateCard!) {
194
- updateCard(input: $input) {
195
- id
196
- }
197
- }
198
- `,
199
- variables: { input: card },
200
- };
201
- }
202
- static updateUser(updateUser) {
203
- return {
204
- query: `
205
- mutation ($input: UpdateUser!) {
206
- updateUserV2(input: $input) {
207
- id
208
- }
209
- }
210
- `,
211
- variables: { input: updateUser },
212
- };
213
- }
214
- static updateWorkflowEntity(updateWorkflowEntity) {
215
- return {
216
- query: `
217
- mutation ($input: UpdateWorkflowEntity!) {
218
- updateWorkflowEntity(input: $input) {
219
- entity {
220
- id
221
- fields
222
- }
223
- refs {
224
- workflowEntityRefs {
225
- id
226
- }
227
- personRefs {
228
- id
229
- }
230
- workflowTemplateRefs {
231
- id
232
- }
233
- }
234
- }
235
- }
236
- `,
237
- variables: { input: updateWorkflowEntity },
238
- };
239
- }
240
- static updateWorkflowTemplate(updateWorkflowTemplate) {
241
- return {
242
- query: `
243
- mutation ($input: UpdateWorkflowTemplate!) {
244
- updateWorkflowTemplate(input: $input) {
245
- id
246
- }
247
- }
248
- `,
249
- variables: { input: updateWorkflowTemplate },
250
- };
251
- }
252
- }
253
- exports.CoastApiRequests = CoastApiRequests;
@@ -1,3 +0,0 @@
1
- export declare const WorkflowEntityGqlFields: {
2
- fields: string;
3
- };
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WorkflowEntityGqlFields = void 0;
4
- const WorkflowTemplateGqlFields_1 = require("./WorkflowTemplateGqlFields");
5
- exports.WorkflowEntityGqlFields = {
6
- fields: `
7
- entity { id workflowTemplateId fields }
8
- refs {
9
- workflowEntityRefs { id workflowTemplateId fields }
10
- personRefs { id }
11
- workflowTemplateRefs { id components { ${WorkflowTemplateGqlFields_1.WorkflowTemplateGqlFields.componentFields} } }
12
- }
13
- `,
14
- };
@@ -1,3 +0,0 @@
1
- export declare const WorkflowTemplateGqlFields: {
2
- componentFields: string;
3
- };
@@ -1,129 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WorkflowTemplateGqlFields = void 0;
4
- const inputComponentFields = [
5
- 'id',
6
- 'type',
7
- 'label',
8
- 'placeholder',
9
- 'readonly',
10
- 'required',
11
- 'isFilterable',
12
- 'isSortable',
13
- 'isServerManaged',
14
- ];
15
- exports.WorkflowTemplateGqlFields = {
16
- componentFields: `
17
- ... on AddressComponent {
18
- ${inputComponentFields.join(' ')}
19
- }
20
- ... on AuditCheckboxComponent {
21
- ${inputComponentFields.join(' ')}
22
- }
23
- ... on AuditTagComponent {
24
- ${inputComponentFields.join(' ')}
25
- multiselect
26
- options { label value archived }
27
- }
28
- ... on AuditTextComponent {
29
- ${inputComponentFields.join(' ')}
30
- maxlength
31
- multiline
32
- }
33
- ... on CombinedTagsComponent {
34
- id
35
- type
36
- label
37
- icon
38
- locked
39
- isServerManaged
40
- componentIds
41
- }
42
- ... on DateComponent {
43
- ${inputComponentFields.join(' ')}
44
- }
45
- ... on EmailComponent {
46
- ${inputComponentFields.join(' ')}
47
- default { value }
48
- }
49
- ... on FileComponent {
50
- ${inputComponentFields.join(' ')}
51
- acceptedContentTypes
52
- }
53
- ... on GeolocationComponent {
54
- ${inputComponentFields.join(' ')}
55
- }
56
- ... on InputButtonComponent {
57
- id
58
- type
59
- locked
60
- isServerManaged
61
- buttonText
62
- inputComponentId
63
- }
64
- ... on NumberComponent {
65
- ${inputComponentFields.join(' ')}
66
- format
67
- }
68
- ... on PersonComponent {
69
- ${inputComponentFields.join(' ')}
70
- default { token userIds }
71
- }
72
- ... on RelatedCardComponent {
73
- ${inputComponentFields.join(' ')}
74
- workflowTemplateId
75
- default { cardIds }
76
- listDefault {
77
- sortByComponents { componentId direction }
78
- filterByComponents {
79
- componentId
80
- value {
81
- containsCurrentUser { value }
82
- containsNumber { values }
83
- containsString { values }
84
- dateRange { before after }
85
- dateTokenIs { value }
86
- isEmpty { value }
87
- numberIs { value }
88
- stringWildcard { value }
89
- }
90
- }
91
- omniSearchQuery
92
- limit
93
- offset
94
- }
95
- }
96
- ... on RelatedCardLookupComponent {
97
- ${inputComponentFields.join(' ')}
98
- relatedCardComponentId
99
- lookupWorkflowTemplateId
100
- lookupComponentId
101
- }
102
- ... on SignatureComponent {
103
- ${inputComponentFields.join(' ')}
104
- }
105
- ... on StaticTextComponent {
106
- id type text
107
- }
108
- ... on SubformComponent {
109
- ${inputComponentFields.join(' ')}
110
- workflowTemplateIds
111
- default { workflowTemplateId }
112
- }
113
- ... on TagComponent {
114
- ${inputComponentFields.join(' ')}
115
- multiselect
116
- options { label value archived }
117
- default { value }
118
- }
119
- ... on TextComponent {
120
- ${inputComponentFields.join(' ')}
121
- maxlength
122
- multiline
123
- default { text }
124
- }
125
- ... on TodoComponent {
126
- ${inputComponentFields.join(' ')}
127
- }
128
- `,
129
- };
@@ -1,7 +0,0 @@
1
- import { InjectionToken, ModuleMetadata, OptionalFactoryDependency } from '@nestjs/common';
2
- import { LoggerOptions } from './LoggerOptions';
3
- export interface LoggerModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
4
- name?: string;
5
- useFactory: (...args: any[]) => LoggerOptions | Promise<LoggerOptions>;
6
- inject?: Array<InjectionToken | OptionalFactoryDependency>;
7
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,46 +0,0 @@
1
- import { SamlUser } from '@coast/core-api-types/auth/SamlUser';
2
- import { AutomationId } from '@coast/core-api-types/automations/AutomationId';
3
- import { BusinessId } from '@coast/core-api-types/business/BusinessId';
4
- import { Card } from '@coast/core-api-types/card/Card';
5
- import { UpdateCard } from '@coast/core-api-types/card/UpdateCard';
6
- import { Channel } from '@coast/core-api-types/channel/Channel';
7
- import { ListEntitiesFormData } from '@coast/core-api-types/export/ListEntitiesFormData';
8
- import { ListEntitiesFormDataResult } from '@coast/core-api-types/export/ListEntitiesFormDataResult';
9
- import { FileDetails } from '@coast/core-api-types/file-upload/FileDetails';
10
- import { CreateUserV2 } from '@coast/core-api-types/user/CreateUserV2';
11
- import { UpdateUser } from '@coast/core-api-types/user/UpdateUser';
12
- import { User } from '@coast/core-api-types/user/User';
13
- import { CreateWorkflowAutomationEvent } from '@coast/core-api-types/workflow-automation/CreateWorkflowAutomationEvent';
14
- import { AggregateNumberStats } from '@coast/core-api-types/workflow-template/entities/AggregateNumberStats';
15
- import { AggregateRelatedCardQuantity } from '@coast/core-api-types/workflow-template/entities/AggregateRelatedCardQuantity';
16
- import { CreateEntityAuditTrailEvent } from '@coast/core-api-types/workflow-template/entities/audit-trail/CreateEntityAuditTrailEvent';
17
- import { EntityAuditTrailEvent } from '@coast/core-api-types/workflow-template/entities/audit-trail/EntityAuditTrailEvent';
18
- import { CreateWorkflowEntity } from '@coast/core-api-types/workflow-template/entities/CreateWorkflowEntity';
19
- import { GetWorkflowEntityResult } from '@coast/core-api-types/workflow-template/entities/GetWorkflowEntityResult';
20
- import { UpdateWorkflowEntity } from '@coast/core-api-types/workflow-template/entities/UpdateWorkflowEntity';
21
- import { UpdateWorkflowTemplate } from '@coast/core-api-types/workflow-template/UpdateWorkflowTemplate';
22
- import { WorkflowTemplate } from '@coast/core-api-types/workflow-template/WorkflowTemplate';
23
- import { CoastApiOptions } from '../../models/coast-api/CoastApiOptions';
24
- import { CoastLogger } from '../logger/CoastLogger';
25
- export declare class CoastApiClient {
26
- private readonly logger;
27
- private readonly options;
28
- constructor(logger: CoastLogger, options: CoastApiOptions);
29
- aggregateRelatedCardQuantityStats(businessId: BusinessId, aggregate: AggregateRelatedCardQuantity): Promise<AggregateNumberStats>;
30
- createEntityAuditTrailEvent(businessId: BusinessId, createEntityAuditTrailEvent: CreateEntityAuditTrailEvent): Promise<EntityAuditTrailEvent>;
31
- createUsers(createUsers: CreateUserV2[], businessId: BusinessId): Promise<User[] | undefined>;
32
- createWorkflowAutomationEvent(businessId: BusinessId, createWorkflowAutomationEvent: CreateWorkflowAutomationEvent): Promise<boolean>;
33
- createWorkflowEntity(businessId: BusinessId, sourceAutomationId: AutomationId, createWorkflowEntity: CreateWorkflowEntity): Promise<GetWorkflowEntityResult>;
34
- getCard(businessId: BusinessId, cardId: string): Promise<Card | null>;
35
- getChannel(businessId: BusinessId, channelId: number): Promise<Channel>;
36
- getFileDetails(): Promise<FileDetails>;
37
- getSamlUser(businessId: BusinessId, email: string, samlOrganizationId: string): Promise<SamlUser>;
38
- getWorkflowEntity(businessId: BusinessId, id: string): Promise<GetWorkflowEntityResult>;
39
- getWorkflowTemplate(businessId: BusinessId, workflowTemplateId: string): Promise<WorkflowTemplate>;
40
- listWorkflowEntitiesFormData(businessId: BusinessId, filter: ListEntitiesFormData): Promise<ListEntitiesFormDataResult>;
41
- updateCard(businessId: BusinessId, updateCard: UpdateCard): Promise<Card>;
42
- updateUser(businessId: BusinessId, updateUser: UpdateUser): Promise<User>;
43
- updateWorkflowEntity(businessId: BusinessId, sourceAutomationId: AutomationId, updateWorkflowEntity: UpdateWorkflowEntity): Promise<GetWorkflowEntityResult>;
44
- updateWorkflowTemplate(businessId: BusinessId, updateWorkflowTemplate: UpdateWorkflowTemplate): Promise<WorkflowTemplate>;
45
- private execute;
46
- }
@@ -1,124 +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
- var __importDefault = (this && this.__importDefault) || function (mod) {
15
- return (mod && mod.__esModule) ? mod : { "default": mod };
16
- };
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.CoastApiClient = void 0;
19
- const HeaderKeys_1 = require("@coast/core-api-types/application/HeaderKeys");
20
- const common_1 = require("@nestjs/common");
21
- const lodash_1 = __importDefault(require("lodash"));
22
- const superagent_1 = __importDefault(require("superagent"));
23
- const CoastApiRequests_1 = require("../../models/coast-api/CoastApiRequests");
24
- const Constants_1 = require("../../models/Constants");
25
- const CoastLogger_1 = require("../logger/CoastLogger");
26
- const CoastApiClientGqlError_1 = require("./CoastApiClientGqlError");
27
- let CoastApiClient = class CoastApiClient {
28
- constructor(logger, options) {
29
- this.logger = logger;
30
- this.options = options;
31
- }
32
- async aggregateRelatedCardQuantityStats(businessId, aggregate) {
33
- const response = await this.execute(businessId, CoastApiRequests_1.CoastApiRequests.aggregateRelatedCardQuantityStats(aggregate));
34
- return response.body.data.aggregateRelatedCardQuantityStats;
35
- }
36
- async createEntityAuditTrailEvent(businessId, createEntityAuditTrailEvent) {
37
- const response = await this.execute(businessId, CoastApiRequests_1.CoastApiRequests.createEntityAuditTrailEvent(createEntityAuditTrailEvent));
38
- return response.body.data.createEntityAuditTrailEvent;
39
- }
40
- async createUsers(createUsers, businessId) {
41
- const response = await this.execute(businessId, CoastApiRequests_1.CoastApiRequests.createUsers(createUsers));
42
- return response.body.data.createUserV2;
43
- }
44
- async createWorkflowAutomationEvent(businessId, createWorkflowAutomationEvent) {
45
- const response = await this.execute(businessId, CoastApiRequests_1.CoastApiRequests.createWorkflowAutomationEvent(createWorkflowAutomationEvent), {
46
- sourceAutomationId: createWorkflowAutomationEvent.context?.sourceAutomationId,
47
- });
48
- return response.body.data.createWorkflowAutomationEvent;
49
- }
50
- async createWorkflowEntity(businessId, sourceAutomationId, createWorkflowEntity) {
51
- const response = await this.execute(businessId, CoastApiRequests_1.CoastApiRequests.createWorkflowEntity(createWorkflowEntity), {
52
- sourceAutomationId,
53
- });
54
- return response.body.data.createWorkflowEntity;
55
- }
56
- async getCard(businessId, cardId) {
57
- try {
58
- const response = await this.execute(businessId, CoastApiRequests_1.CoastApiRequests.getCard(cardId));
59
- return response.body.data.getCard;
60
- }
61
- catch {
62
- return null;
63
- }
64
- }
65
- async getChannel(businessId, channelId) {
66
- const response = await this.execute(businessId, CoastApiRequests_1.CoastApiRequests.getChannel(channelId));
67
- return response.body.data.getChannel;
68
- }
69
- async getFileDetails() {
70
- throw new common_1.NotImplementedException();
71
- }
72
- async getSamlUser(businessId, email, samlOrganizationId) {
73
- const response = await this.execute(businessId, CoastApiRequests_1.CoastApiRequests.getSamlUser(email, samlOrganizationId));
74
- return response.body.data.getSamlUser;
75
- }
76
- async getWorkflowEntity(businessId, id) {
77
- const response = await this.execute(businessId, CoastApiRequests_1.CoastApiRequests.getWorkflowEntity(id));
78
- return response.body.data.getWorkflowEntity;
79
- }
80
- async getWorkflowTemplate(businessId, workflowTemplateId) {
81
- const response = await this.execute(businessId, CoastApiRequests_1.CoastApiRequests.getWorkflowTemplate(workflowTemplateId));
82
- return response.body.data.getWorkflowTemplate;
83
- }
84
- async listWorkflowEntitiesFormData(businessId, filter) {
85
- const response = await this.execute(businessId, CoastApiRequests_1.CoastApiRequests.listWorkflowEntitiesFormData(filter));
86
- return response.body.data.listEntitiesFormData;
87
- }
88
- async updateCard(businessId, updateCard) {
89
- const response = await this.execute(businessId, CoastApiRequests_1.CoastApiRequests.updateCard(updateCard));
90
- return response.body.data.updateCard;
91
- }
92
- async updateUser(businessId, updateUser) {
93
- const response = await this.execute(businessId, CoastApiRequests_1.CoastApiRequests.updateUser(updateUser));
94
- return response.body.data.updateUserV2;
95
- }
96
- async updateWorkflowEntity(businessId, sourceAutomationId, updateWorkflowEntity) {
97
- const response = await this.execute(businessId, CoastApiRequests_1.CoastApiRequests.updateWorkflowEntity(updateWorkflowEntity), {
98
- sourceAutomationId,
99
- });
100
- return response.body.data.updateWorkflowEntity;
101
- }
102
- async updateWorkflowTemplate(businessId, updateWorkflowTemplate) {
103
- const response = await this.execute(businessId, CoastApiRequests_1.CoastApiRequests.updateWorkflowTemplate(updateWorkflowTemplate));
104
- return response.body.data.updateWorkflowTemplate;
105
- }
106
- async execute(businessId, query, options = {}) {
107
- const request = superagent_1.default.post(this.options.endpoint).set(HeaderKeys_1.HeaderKeys.AUTHORIZATION, this.options.authToken);
108
- request.set(HeaderKeys_1.HeaderKeys.BUSINESS_ID, businessId.toString());
109
- if (!lodash_1.default.isNil(options?.sourceAutomationId)) {
110
- request.set(HeaderKeys_1.HeaderKeys.SOURCE_AUTOMATION_ID, options.sourceAutomationId);
111
- }
112
- const response = await request.send(query).retry();
113
- if (!lodash_1.default.isNil(response.body.errors)) {
114
- this.logger.error({ errors: response.body.errors, firstError: response.body.errors[0] });
115
- throw new CoastApiClientGqlError_1.CoastClientGqlError('Error in CoastClient', response.body.errors);
116
- }
117
- return response;
118
- }
119
- };
120
- exports.CoastApiClient = CoastApiClient;
121
- exports.CoastApiClient = CoastApiClient = __decorate([
122
- __param(1, (0, common_1.Inject)(Constants_1.Constants.COAST_API_OPTIONS)),
123
- __metadata("design:paramtypes", [CoastLogger_1.CoastLogger, Object])
124
- ], CoastApiClient);
@@ -1,12 +0,0 @@
1
- interface GqlError {
2
- extensions: {
3
- code: number;
4
- };
5
- message: string;
6
- path: string[];
7
- }
8
- export declare class CoastClientGqlError extends Error {
9
- readonly details: GqlError[];
10
- constructor(message: string, details: GqlError[]);
11
- }
12
- export {};
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CoastClientGqlError = void 0;
4
- class CoastClientGqlError extends Error {
5
- constructor(message, details) {
6
- super(message);
7
- this.details = details;
8
- }
9
- }
10
- exports.CoastClientGqlError = CoastClientGqlError;
@@ -1,6 +0,0 @@
1
- import { DynamicModule } from '@nestjs/common';
2
- import { CoastApiModuleAsyncOptions } from '../../models/coast-api/CoastApiModuleAsyncOptions';
3
- export declare class CoastApiModule {
4
- static forRootAsync(options: CoastApiModuleAsyncOptions): DynamicModule;
5
- private static createAsyncOptionsProvider;
6
- }
@@ -1,42 +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 CoastApiModule_1;
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.CoastApiModule = void 0;
11
- const common_1 = require("@nestjs/common");
12
- const Constants_1 = require("../../models/Constants");
13
- const CoastLogger_1 = require("../logger/CoastLogger");
14
- const LoggerModule_1 = require("../logger/LoggerModule");
15
- const CoastApiClient_1 = require("./CoastApiClient");
16
- let CoastApiModule = CoastApiModule_1 = class CoastApiModule {
17
- static forRootAsync(options) {
18
- const asyncProvider = CoastApiModule_1.createAsyncOptionsProvider(options);
19
- const coastClient = {
20
- inject: [CoastLogger_1.CoastLogger, Constants_1.Constants.COAST_API_OPTIONS],
21
- provide: CoastApiClient_1.CoastApiClient,
22
- useFactory: (logger, options) => new CoastApiClient_1.CoastApiClient(logger, options),
23
- };
24
- return {
25
- exports: [coastClient],
26
- imports: [LoggerModule_1.LoggerModule, ...(options.imports ?? [])],
27
- module: CoastApiModule_1,
28
- providers: [coastClient, asyncProvider],
29
- };
30
- }
31
- static createAsyncOptionsProvider(options) {
32
- return {
33
- provide: Constants_1.Constants.COAST_API_OPTIONS,
34
- useFactory: options.useFactory,
35
- inject: options.inject ?? [],
36
- };
37
- }
38
- };
39
- exports.CoastApiModule = CoastApiModule;
40
- exports.CoastApiModule = CoastApiModule = CoastApiModule_1 = __decorate([
41
- (0, common_1.Module)({})
42
- ], CoastApiModule);
@@ -1,7 +0,0 @@
1
- import { DynamicModule } from '@nestjs/common';
2
- import { LoggerModuleAsyncOptions } from '../../models/logger/LoggerModuleAsyncOptions';
3
- export declare class LoggerModule {
4
- static disabled(): DynamicModule;
5
- static forRootAsync(options: LoggerModuleAsyncOptions): DynamicModule;
6
- private static createAsyncOptionsProvider;
7
- }