@coast/service-common 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/models/coast-api/CoastApiRequests.d.ts +70 -0
- package/dist/models/coast-api/CoastApiRequests.js +254 -0
- package/dist/models/coast-api/WorkflowEntityGqlFields.d.ts +3 -0
- package/dist/models/coast-api/WorkflowEntityGqlFields.js +14 -0
- package/dist/models/coast-api/WorkflowTemplateGqlFields.d.ts +3 -0
- package/dist/models/coast-api/WorkflowTemplateGqlFields.js +129 -0
- package/dist/modules/coast-api/CoastApiClient.d.ts +46 -0
- package/dist/modules/coast-api/CoastApiClient.js +107 -0
- package/dist/modules/coast-api/CoastApiClientGqlError.d.ts +12 -0
- package/dist/modules/coast-api/CoastApiClientGqlError.js +10 -0
- package/dist/modules/coast-api/CoastApiModule.d.ts +2 -0
- package/dist/modules/coast-api/CoastApiModule.js +28 -0
- package/dist/modules/coast-api/coastApiClientFactory.d.ts +4 -0
- package/dist/modules/coast-api/coastApiClientFactory.js +8 -0
- package/dist/modules/logger/CoastLogger.d.ts +2 -2
- package/dist/modules/logger/LoggerModule.d.ts +1 -1
- package/dist/modules/logger/LoggerModule.js +14 -12
- package/dist/modules/logger/PinoLogger.d.ts +5 -3
- package/dist/modules/logger/PinoLogger.js +13 -9
- package/dist/modules/logger/SilentLogger.d.ts +3 -3
- package/dist/modules/logger/SilentLogger.js +4 -4
- package/dist/modules/trace/Trace.d.ts +1 -1
- package/dist/modules/trace/TraceManager.js +2 -2
- package/dist/modules/trace/TraceModule.js +3 -3
- package/dist/modules/utils/graphql/GqlRequestBody.d.ts +8 -0
- package/dist/modules/utils/graphql/GqlRequestBody.js +2 -0
- package/dist/modules/utils/graphql/GqlResponse.d.ts +14 -0
- package/dist/modules/utils/graphql/GqlResponse.js +2 -0
- package/dist/modules/utils/streams/Generators.d.ts +1 -1
- package/dist/modules/utils/streams/Generators.js +5 -5
- package/dist/modules/utils/streams/test/GeneratorsTest.js +1 -1
- package/package.json +9 -2
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { SamlUser } from '@coast/core-api-types/auth/SamlUser';
|
|
2
|
+
import { Card } from '@coast/core-api-types/card/Card';
|
|
3
|
+
import { UpdateCard } from '@coast/core-api-types/card/UpdateCard';
|
|
4
|
+
import { Channel } from '@coast/core-api-types/channel/Channel';
|
|
5
|
+
import { ListEntitiesFormData } from '@coast/core-api-types/export/ListEntitiesFormData';
|
|
6
|
+
import { ListEntitiesFormDataResult } from '@coast/core-api-types/export/ListEntitiesFormDataResult';
|
|
7
|
+
import { CreateUserV2 } from '@coast/core-api-types/user/CreateUserV2';
|
|
8
|
+
import { UpdateUser } from '@coast/core-api-types/user/UpdateUser';
|
|
9
|
+
import { User } from '@coast/core-api-types/user/User';
|
|
10
|
+
import { CreateWorkflowAutomationEvent } from '@coast/core-api-types/workflow-automation/CreateWorkflowAutomationEvent';
|
|
11
|
+
import { AggregateNumberStats } from '@coast/core-api-types/workflow-template/entities/AggregateNumberStats';
|
|
12
|
+
import { AggregateRelatedCardQuantity } from '@coast/core-api-types/workflow-template/entities/AggregateRelatedCardQuantity';
|
|
13
|
+
import { CreateEntityAuditTrailEvent } from '@coast/core-api-types/workflow-template/entities/audit-trail/CreateEntityAuditTrailEvent';
|
|
14
|
+
import { EntityAuditTrailEvent } from '@coast/core-api-types/workflow-template/entities/audit-trail/EntityAuditTrailEvent';
|
|
15
|
+
import { CreateWorkflowEntity } from '@coast/core-api-types/workflow-template/entities/CreateWorkflowEntity';
|
|
16
|
+
import { GetWorkflowEntityResult } from '@coast/core-api-types/workflow-template/entities/GetWorkflowEntityResult';
|
|
17
|
+
import { UpdateWorkflowEntity } from '@coast/core-api-types/workflow-template/entities/UpdateWorkflowEntity';
|
|
18
|
+
import { UpdateWorkflowTemplate } from '@coast/core-api-types/workflow-template/UpdateWorkflowTemplate';
|
|
19
|
+
import { WorkflowTemplate } from '@coast/core-api-types/workflow-template/WorkflowTemplate';
|
|
20
|
+
import { GqlRequestBody } from '../../modules/utils/graphql/GqlRequestBody';
|
|
21
|
+
export declare class CoastApiRequests {
|
|
22
|
+
static aggregateRelatedCardQuantityStats(filter: AggregateRelatedCardQuantity): GqlRequestBody<AggregateRelatedCardQuantity, {
|
|
23
|
+
aggregateRelatedCardQuantityStats: AggregateNumberStats;
|
|
24
|
+
}>;
|
|
25
|
+
static createEntityAuditTrailEvent(createEntityAuditTrailEvent: CreateEntityAuditTrailEvent): GqlRequestBody<CreateEntityAuditTrailEvent, {
|
|
26
|
+
createEntityAuditTrailEvent: EntityAuditTrailEvent;
|
|
27
|
+
}>;
|
|
28
|
+
static createUsers(createUsers: CreateUserV2[]): GqlRequestBody<CreateUserV2[], {
|
|
29
|
+
createUserV2: User[];
|
|
30
|
+
}>;
|
|
31
|
+
static createWorkflowAutomationEvent(createWorkflowAutomationEvent: CreateWorkflowAutomationEvent): GqlRequestBody<CreateWorkflowAutomationEvent, {
|
|
32
|
+
createWorkflowAutomationEvent: boolean;
|
|
33
|
+
}>;
|
|
34
|
+
static createWorkflowEntity(createWorkflowEntity: CreateWorkflowEntity): GqlRequestBody<CreateWorkflowEntity, {
|
|
35
|
+
createWorkflowEntity: GetWorkflowEntityResult;
|
|
36
|
+
}>;
|
|
37
|
+
static getCard(cardId: string): GqlRequestBody<string, {
|
|
38
|
+
getCard: Card;
|
|
39
|
+
}>;
|
|
40
|
+
static getChannel(channelId: number): GqlRequestBody<number, {
|
|
41
|
+
getChannel: Channel;
|
|
42
|
+
}>;
|
|
43
|
+
static getSamlUser(email: string, samlOrganizationId: string): GqlRequestBody<{
|
|
44
|
+
email: string;
|
|
45
|
+
samlOrganizationId: string;
|
|
46
|
+
}, {
|
|
47
|
+
getSamlUser: SamlUser;
|
|
48
|
+
}>;
|
|
49
|
+
static getWorkflowEntity(workflowEntityId: string): GqlRequestBody<string, {
|
|
50
|
+
getWorkflowEntity: GetWorkflowEntityResult;
|
|
51
|
+
}>;
|
|
52
|
+
static getWorkflowTemplate(workflowTemplateId: string): GqlRequestBody<string, {
|
|
53
|
+
getWorkflowTemplate: WorkflowTemplate;
|
|
54
|
+
}>;
|
|
55
|
+
static listWorkflowEntitiesFormData(filter: ListEntitiesFormData): GqlRequestBody<ListEntitiesFormData, {
|
|
56
|
+
listEntitiesFormData: ListEntitiesFormDataResult;
|
|
57
|
+
}>;
|
|
58
|
+
static updateCard(card: UpdateCard): GqlRequestBody<UpdateCard, {
|
|
59
|
+
updateCard: Card;
|
|
60
|
+
}>;
|
|
61
|
+
static updateUser(updateUser: UpdateUser): GqlRequestBody<UpdateUser, {
|
|
62
|
+
updateUserV2: User;
|
|
63
|
+
}>;
|
|
64
|
+
static updateWorkflowEntity(updateWorkflowEntity: UpdateWorkflowEntity): GqlRequestBody<UpdateWorkflowEntity, {
|
|
65
|
+
updateWorkflowEntity: GetWorkflowEntityResult;
|
|
66
|
+
}>;
|
|
67
|
+
static updateWorkflowTemplate(updateWorkflowTemplate: UpdateWorkflowTemplate): GqlRequestBody<UpdateWorkflowTemplate, {
|
|
68
|
+
updateWorkflowTemplate: WorkflowTemplate;
|
|
69
|
+
}>;
|
|
70
|
+
}
|
|
@@ -0,0 +1,254 @@
|
|
|
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
|
+
role
|
|
38
|
+
createdAt
|
|
39
|
+
updatedAt
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
`,
|
|
43
|
+
variables: { input: createUsers },
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
static createWorkflowAutomationEvent(createWorkflowAutomationEvent) {
|
|
47
|
+
return {
|
|
48
|
+
query: `
|
|
49
|
+
mutation ($input: CreateWorkflowAutomationEvent!) {
|
|
50
|
+
createWorkflowAutomationEvent(input: $input)
|
|
51
|
+
}
|
|
52
|
+
`,
|
|
53
|
+
variables: { input: createWorkflowAutomationEvent },
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
static createWorkflowEntity(createWorkflowEntity) {
|
|
57
|
+
return {
|
|
58
|
+
query: `
|
|
59
|
+
mutation ($input: CreateWorkflowEntity!) {
|
|
60
|
+
createWorkflowEntity(input: $input) {
|
|
61
|
+
entity {
|
|
62
|
+
id
|
|
63
|
+
workflowTemplateId
|
|
64
|
+
fields
|
|
65
|
+
}
|
|
66
|
+
refs {
|
|
67
|
+
workflowEntityRefs {
|
|
68
|
+
id
|
|
69
|
+
}
|
|
70
|
+
personRefs {
|
|
71
|
+
id
|
|
72
|
+
}
|
|
73
|
+
workflowTemplateRefs {
|
|
74
|
+
id
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
`,
|
|
80
|
+
variables: { input: createWorkflowEntity },
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
static getCard(cardId) {
|
|
84
|
+
return {
|
|
85
|
+
query: `
|
|
86
|
+
query ($id: UUID!) {
|
|
87
|
+
getCard(id: $id) {
|
|
88
|
+
id
|
|
89
|
+
fields
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
`,
|
|
93
|
+
variables: { id: cardId },
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
static getChannel(channelId) {
|
|
97
|
+
return {
|
|
98
|
+
query: `
|
|
99
|
+
query ($id: Int!) {
|
|
100
|
+
getChannel(id: $id) {
|
|
101
|
+
id
|
|
102
|
+
name
|
|
103
|
+
slug
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
`,
|
|
107
|
+
variables: { id: channelId },
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
static getSamlUser(email, samlOrganizationId) {
|
|
111
|
+
return {
|
|
112
|
+
query: `
|
|
113
|
+
query ($input: GetSamlUser!) {
|
|
114
|
+
getSamlUser(input: $input) {
|
|
115
|
+
id
|
|
116
|
+
email
|
|
117
|
+
businessId
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
`,
|
|
121
|
+
variables: { input: { email, samlOrganizationId } },
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
static getWorkflowEntity(workflowEntityId) {
|
|
125
|
+
return {
|
|
126
|
+
query: `
|
|
127
|
+
query ($id: UUID!) {
|
|
128
|
+
getWorkflowEntity(id: $id) {
|
|
129
|
+
${WorkflowEntityGqlFields_1.WorkflowEntityGqlFields.fields}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
`,
|
|
133
|
+
variables: { id: workflowEntityId },
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
static getWorkflowTemplate(workflowTemplateId) {
|
|
137
|
+
return {
|
|
138
|
+
query: `
|
|
139
|
+
query ($id: UUID!) {
|
|
140
|
+
getWorkflowTemplate(id: $id) {
|
|
141
|
+
components {
|
|
142
|
+
${WorkflowTemplateGqlFields_1.WorkflowTemplateGqlFields.componentFields}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
`,
|
|
147
|
+
variables: { id: workflowTemplateId },
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
static listWorkflowEntitiesFormData(filter) {
|
|
151
|
+
return {
|
|
152
|
+
query: `
|
|
153
|
+
query ($input: ListEntitiesFormData!) {
|
|
154
|
+
listEntitiesFormData(input: $input) {
|
|
155
|
+
hasMore
|
|
156
|
+
totalResults
|
|
157
|
+
exports {
|
|
158
|
+
type
|
|
159
|
+
title
|
|
160
|
+
targetFormat
|
|
161
|
+
data {
|
|
162
|
+
... on ComponentDataExport {
|
|
163
|
+
label
|
|
164
|
+
value
|
|
165
|
+
imageUrls
|
|
166
|
+
type
|
|
167
|
+
}
|
|
168
|
+
... on SubformDataExport {
|
|
169
|
+
type
|
|
170
|
+
title
|
|
171
|
+
businessName
|
|
172
|
+
data {
|
|
173
|
+
... on ComponentDataExport {
|
|
174
|
+
label
|
|
175
|
+
value
|
|
176
|
+
imageUrls
|
|
177
|
+
type
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
businessName
|
|
183
|
+
url
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
`,
|
|
188
|
+
variables: { input: filter },
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
static updateCard(card) {
|
|
192
|
+
return {
|
|
193
|
+
query: `
|
|
194
|
+
mutation ($input: UpdateCard!) {
|
|
195
|
+
updateCard(input: $input) {
|
|
196
|
+
id
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
`,
|
|
200
|
+
variables: { input: card },
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
static updateUser(updateUser) {
|
|
204
|
+
return {
|
|
205
|
+
query: `
|
|
206
|
+
mutation ($input: UpdateUser!) {
|
|
207
|
+
updateUserV2(input: $input) {
|
|
208
|
+
id
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
`,
|
|
212
|
+
variables: { input: updateUser },
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
static updateWorkflowEntity(updateWorkflowEntity) {
|
|
216
|
+
return {
|
|
217
|
+
query: `
|
|
218
|
+
mutation ($input: UpdateWorkflowEntity!) {
|
|
219
|
+
updateWorkflowEntity(input: $input) {
|
|
220
|
+
entity {
|
|
221
|
+
id
|
|
222
|
+
fields
|
|
223
|
+
}
|
|
224
|
+
refs {
|
|
225
|
+
workflowEntityRefs {
|
|
226
|
+
id
|
|
227
|
+
}
|
|
228
|
+
personRefs {
|
|
229
|
+
id
|
|
230
|
+
}
|
|
231
|
+
workflowTemplateRefs {
|
|
232
|
+
id
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
`,
|
|
238
|
+
variables: { input: updateWorkflowEntity },
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
static updateWorkflowTemplate(updateWorkflowTemplate) {
|
|
242
|
+
return {
|
|
243
|
+
query: `
|
|
244
|
+
mutation ($input: UpdateWorkflowTemplate!) {
|
|
245
|
+
updateWorkflowTemplate(input: $input) {
|
|
246
|
+
id
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
`,
|
|
250
|
+
variables: { input: updateWorkflowTemplate },
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
exports.CoastApiRequests = CoastApiRequests;
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,129 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
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 { CoastLogger } from '../logger/CoastLogger';
|
|
24
|
+
export declare class CoastApiClient {
|
|
25
|
+
private readonly coastApiEndpoint;
|
|
26
|
+
private readonly coastApiAuthToken;
|
|
27
|
+
private readonly logger;
|
|
28
|
+
constructor(coastApiEndpoint: string, coastApiAuthToken: string, logger: CoastLogger);
|
|
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
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.CoastApiClient = void 0;
|
|
7
|
+
const HeaderKeys_1 = require("@coast/core-api-types/application/HeaderKeys");
|
|
8
|
+
const common_1 = require("@nestjs/common");
|
|
9
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
10
|
+
const superagent_1 = __importDefault(require("superagent"));
|
|
11
|
+
const CoastApiRequests_1 = require("../../models/coast-api/CoastApiRequests");
|
|
12
|
+
const CoastApiClientGqlError_1 = require("./CoastApiClientGqlError");
|
|
13
|
+
class CoastApiClient {
|
|
14
|
+
constructor(coastApiEndpoint, coastApiAuthToken, logger) {
|
|
15
|
+
this.coastApiEndpoint = coastApiEndpoint;
|
|
16
|
+
this.coastApiAuthToken = coastApiAuthToken;
|
|
17
|
+
this.logger = logger;
|
|
18
|
+
}
|
|
19
|
+
async aggregateRelatedCardQuantityStats(businessId, aggregate) {
|
|
20
|
+
const response = await this.execute(businessId, CoastApiRequests_1.CoastApiRequests.aggregateRelatedCardQuantityStats(aggregate));
|
|
21
|
+
return response.body.data.aggregateRelatedCardQuantityStats;
|
|
22
|
+
}
|
|
23
|
+
async createEntityAuditTrailEvent(businessId, createEntityAuditTrailEvent) {
|
|
24
|
+
const response = await this.execute(businessId, CoastApiRequests_1.CoastApiRequests.createEntityAuditTrailEvent(createEntityAuditTrailEvent));
|
|
25
|
+
return response.body.data.createEntityAuditTrailEvent;
|
|
26
|
+
}
|
|
27
|
+
async createUsers(createUsers, businessId) {
|
|
28
|
+
const response = await this.execute(businessId, CoastApiRequests_1.CoastApiRequests.createUsers(createUsers));
|
|
29
|
+
return response.body.data.createUserV2;
|
|
30
|
+
}
|
|
31
|
+
async createWorkflowAutomationEvent(businessId, createWorkflowAutomationEvent) {
|
|
32
|
+
const response = await this.execute(businessId, CoastApiRequests_1.CoastApiRequests.createWorkflowAutomationEvent(createWorkflowAutomationEvent), {
|
|
33
|
+
sourceAutomationId: createWorkflowAutomationEvent.context?.sourceAutomationId,
|
|
34
|
+
});
|
|
35
|
+
return response.body.data.createWorkflowAutomationEvent;
|
|
36
|
+
}
|
|
37
|
+
async createWorkflowEntity(businessId, sourceAutomationId, createWorkflowEntity) {
|
|
38
|
+
const response = await this.execute(businessId, CoastApiRequests_1.CoastApiRequests.createWorkflowEntity(createWorkflowEntity), {
|
|
39
|
+
sourceAutomationId,
|
|
40
|
+
});
|
|
41
|
+
return response.body.data.createWorkflowEntity;
|
|
42
|
+
}
|
|
43
|
+
async getCard(businessId, cardId) {
|
|
44
|
+
try {
|
|
45
|
+
const response = await this.execute(businessId, CoastApiRequests_1.CoastApiRequests.getCard(cardId));
|
|
46
|
+
return response.body.data.getCard;
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
async getChannel(businessId, channelId) {
|
|
53
|
+
const response = await this.execute(businessId, CoastApiRequests_1.CoastApiRequests.getChannel(channelId));
|
|
54
|
+
return response.body.data.getChannel;
|
|
55
|
+
}
|
|
56
|
+
async getFileDetails() {
|
|
57
|
+
throw new common_1.NotImplementedException();
|
|
58
|
+
}
|
|
59
|
+
async getSamlUser(businessId, email, samlOrganizationId) {
|
|
60
|
+
const response = await this.execute(businessId, CoastApiRequests_1.CoastApiRequests.getSamlUser(email, samlOrganizationId));
|
|
61
|
+
return response.body.data.getSamlUser;
|
|
62
|
+
}
|
|
63
|
+
async getWorkflowEntity(businessId, id) {
|
|
64
|
+
const response = await this.execute(businessId, CoastApiRequests_1.CoastApiRequests.getWorkflowEntity(id));
|
|
65
|
+
return response.body.data.getWorkflowEntity;
|
|
66
|
+
}
|
|
67
|
+
async getWorkflowTemplate(businessId, workflowTemplateId) {
|
|
68
|
+
const response = await this.execute(businessId, CoastApiRequests_1.CoastApiRequests.getWorkflowTemplate(workflowTemplateId));
|
|
69
|
+
return response.body.data.getWorkflowTemplate;
|
|
70
|
+
}
|
|
71
|
+
async listWorkflowEntitiesFormData(businessId, filter) {
|
|
72
|
+
const response = await this.execute(businessId, CoastApiRequests_1.CoastApiRequests.listWorkflowEntitiesFormData(filter));
|
|
73
|
+
return response.body.data.listEntitiesFormData;
|
|
74
|
+
}
|
|
75
|
+
async updateCard(businessId, updateCard) {
|
|
76
|
+
const response = await this.execute(businessId, CoastApiRequests_1.CoastApiRequests.updateCard(updateCard));
|
|
77
|
+
return response.body.data.updateCard;
|
|
78
|
+
}
|
|
79
|
+
async updateUser(businessId, updateUser) {
|
|
80
|
+
const response = await this.execute(businessId, CoastApiRequests_1.CoastApiRequests.updateUser(updateUser));
|
|
81
|
+
return response.body.data.updateUserV2;
|
|
82
|
+
}
|
|
83
|
+
async updateWorkflowEntity(businessId, sourceAutomationId, updateWorkflowEntity) {
|
|
84
|
+
const response = await this.execute(businessId, CoastApiRequests_1.CoastApiRequests.updateWorkflowEntity(updateWorkflowEntity), {
|
|
85
|
+
sourceAutomationId,
|
|
86
|
+
});
|
|
87
|
+
return response.body.data.updateWorkflowEntity;
|
|
88
|
+
}
|
|
89
|
+
async updateWorkflowTemplate(businessId, updateWorkflowTemplate) {
|
|
90
|
+
const response = await this.execute(businessId, CoastApiRequests_1.CoastApiRequests.updateWorkflowTemplate(updateWorkflowTemplate));
|
|
91
|
+
return response.body.data.updateWorkflowTemplate;
|
|
92
|
+
}
|
|
93
|
+
async execute(businessId, query, options = {}) {
|
|
94
|
+
const request = superagent_1.default.post(this.coastApiEndpoint).set(HeaderKeys_1.HeaderKeys.AUTHORIZATION, this.coastApiAuthToken);
|
|
95
|
+
request.set(HeaderKeys_1.HeaderKeys.BUSINESS_ID, businessId.toString());
|
|
96
|
+
if (!lodash_1.default.isNil(options?.sourceAutomationId)) {
|
|
97
|
+
request.set(HeaderKeys_1.HeaderKeys.SOURCE_AUTOMATION_ID, options.sourceAutomationId);
|
|
98
|
+
}
|
|
99
|
+
const response = await request.send(query).retry();
|
|
100
|
+
if (!lodash_1.default.isNil(response.body.errors)) {
|
|
101
|
+
this.logger.error({ errors: response.body.errors, firstError: response.body.errors[0] });
|
|
102
|
+
throw new CoastApiClientGqlError_1.CoastClientGqlError('Error in CoastClient', response.body.errors);
|
|
103
|
+
}
|
|
104
|
+
return response;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
exports.CoastApiClient = CoastApiClient;
|
|
@@ -0,0 +1,12 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,10 @@
|
|
|
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;
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.CoastApiModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const config_1 = require("@nestjs/config");
|
|
12
|
+
const CoastLogger_1 = require("../logger/CoastLogger");
|
|
13
|
+
const CoastApiClient_1 = require("./CoastApiClient");
|
|
14
|
+
const coastApiClientFactory_1 = require("./coastApiClientFactory");
|
|
15
|
+
const coastApiProvider = {
|
|
16
|
+
inject: [config_1.ConfigService, CoastLogger_1.CoastLogger],
|
|
17
|
+
provide: CoastApiClient_1.CoastApiClient,
|
|
18
|
+
useFactory: coastApiClientFactory_1.coastApiClientFactory,
|
|
19
|
+
};
|
|
20
|
+
let CoastApiModule = class CoastApiModule {
|
|
21
|
+
};
|
|
22
|
+
exports.CoastApiModule = CoastApiModule;
|
|
23
|
+
exports.CoastApiModule = CoastApiModule = __decorate([
|
|
24
|
+
(0, common_1.Module)({
|
|
25
|
+
exports: [CoastApiClient_1.CoastApiClient],
|
|
26
|
+
providers: [coastApiProvider],
|
|
27
|
+
})
|
|
28
|
+
], CoastApiModule);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.coastApiClientFactory = void 0;
|
|
4
|
+
const CoastApiClient_1 = require("./CoastApiClient");
|
|
5
|
+
const coastApiClientFactory = (configService, logger) => {
|
|
6
|
+
return new CoastApiClient_1.CoastApiClient(configService.getOrThrow('COAST_API_ENDPOINT'), configService.getOrThrow('COAST_API_AUTH_TOKEN'), logger);
|
|
7
|
+
};
|
|
8
|
+
exports.coastApiClientFactory = coastApiClientFactory;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { LoggerService } from '@nestjs/common';
|
|
2
2
|
export declare abstract class CoastLogger implements LoggerService {
|
|
3
|
+
abstract debug(message: unknown): void;
|
|
3
4
|
abstract error(message: unknown, trace?: string): void;
|
|
4
5
|
abstract log(message: unknown): void;
|
|
5
|
-
abstract warn(message: unknown): void;
|
|
6
|
-
abstract debug(message: unknown): void;
|
|
7
6
|
abstract verbose(message: unknown): void;
|
|
7
|
+
abstract warn(message: unknown): void;
|
|
8
8
|
}
|
|
@@ -10,38 +10,40 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
exports.LoggerModule = void 0;
|
|
11
11
|
const common_1 = require("@nestjs/common");
|
|
12
12
|
const config_1 = require("@nestjs/config");
|
|
13
|
+
const TraceManager_1 = require("../trace/TraceManager");
|
|
14
|
+
const TraceModule_1 = require("../trace/TraceModule");
|
|
15
|
+
const CoastLogger_1 = require("./CoastLogger");
|
|
13
16
|
const PinoLogger_1 = require("./PinoLogger");
|
|
14
17
|
const SilentLogger_1 = require("./SilentLogger");
|
|
15
|
-
const CoastLogger_1 = require("./CoastLogger");
|
|
16
18
|
let LoggerModule = LoggerModule_1 = class LoggerModule {
|
|
17
|
-
static
|
|
19
|
+
static disabled() {
|
|
18
20
|
const coastLogger = {
|
|
19
|
-
inject: [config_1.ConfigService],
|
|
20
21
|
provide: CoastLogger_1.CoastLogger,
|
|
21
|
-
|
|
22
|
+
useValue: new SilentLogger_1.SilentLogger(),
|
|
22
23
|
};
|
|
23
24
|
return {
|
|
24
|
-
|
|
25
|
+
exports: [coastLogger],
|
|
25
26
|
imports: [config_1.ConfigModule],
|
|
27
|
+
module: LoggerModule_1,
|
|
26
28
|
providers: [coastLogger],
|
|
27
|
-
exports: [coastLogger],
|
|
28
29
|
};
|
|
29
30
|
}
|
|
30
|
-
static
|
|
31
|
+
static forRootAsync() {
|
|
31
32
|
const coastLogger = {
|
|
33
|
+
inject: [config_1.ConfigService, TraceManager_1.TraceManager],
|
|
32
34
|
provide: CoastLogger_1.CoastLogger,
|
|
33
|
-
|
|
35
|
+
useFactory: (configService, traceManager) => new PinoLogger_1.PinoLogger(configService, traceManager),
|
|
34
36
|
};
|
|
35
37
|
return {
|
|
38
|
+
exports: [coastLogger],
|
|
39
|
+
imports: [config_1.ConfigModule, TraceModule_1.TraceModule],
|
|
36
40
|
module: LoggerModule_1,
|
|
37
|
-
imports: [config_1.ConfigModule],
|
|
38
41
|
providers: [coastLogger],
|
|
39
|
-
exports: [coastLogger],
|
|
40
42
|
};
|
|
41
43
|
}
|
|
42
44
|
};
|
|
43
45
|
exports.LoggerModule = LoggerModule;
|
|
44
46
|
exports.LoggerModule = LoggerModule = LoggerModule_1 = __decorate([
|
|
45
|
-
(0, common_1.
|
|
46
|
-
(0, common_1.
|
|
47
|
+
(0, common_1.Global)(),
|
|
48
|
+
(0, common_1.Module)({})
|
|
47
49
|
], LoggerModule);
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { ConfigService } from '@nestjs/config';
|
|
2
|
+
import { TraceManager } from '../trace/TraceManager';
|
|
2
3
|
import { CoastLogger } from './CoastLogger';
|
|
3
4
|
export declare class PinoLogger extends CoastLogger {
|
|
4
5
|
private readonly instance;
|
|
5
|
-
|
|
6
|
+
private readonly traceManager?;
|
|
7
|
+
constructor(configService: ConfigService, traceManager: TraceManager);
|
|
8
|
+
debug(message: unknown): void;
|
|
6
9
|
error(message: unknown, trace?: string): void;
|
|
7
10
|
log(message: unknown): void;
|
|
8
|
-
warn(message: unknown): void;
|
|
9
|
-
debug(message: unknown): void;
|
|
10
11
|
verbose(message: unknown): void;
|
|
12
|
+
warn(message: unknown): void;
|
|
11
13
|
}
|
|
@@ -16,9 +16,10 @@ exports.PinoLogger = void 0;
|
|
|
16
16
|
const common_1 = require("@nestjs/common");
|
|
17
17
|
const config_1 = require("@nestjs/config");
|
|
18
18
|
const pino_1 = __importDefault(require("pino"));
|
|
19
|
+
const TraceManager_1 = require("../trace/TraceManager");
|
|
19
20
|
const CoastLogger_1 = require("./CoastLogger");
|
|
20
21
|
let PinoLogger = class PinoLogger extends CoastLogger_1.CoastLogger {
|
|
21
|
-
constructor(configService) {
|
|
22
|
+
constructor(configService, traceManager) {
|
|
22
23
|
super();
|
|
23
24
|
const level = configService.get('LOG_LEVEL');
|
|
24
25
|
const redact = [
|
|
@@ -34,20 +35,26 @@ let PinoLogger = class PinoLogger extends CoastLogger_1.CoastLogger {
|
|
|
34
35
|
const pino = configService.get('LOG_PRETTY')
|
|
35
36
|
? (0, pino_1.default)({
|
|
36
37
|
level,
|
|
38
|
+
mixin: () => this.traceManager?.getTrace() ?? {},
|
|
37
39
|
redact,
|
|
38
40
|
transport: {
|
|
39
|
-
target: 'pino-pretty',
|
|
40
41
|
options: {
|
|
41
42
|
colorize: true,
|
|
42
43
|
translateTime: true,
|
|
43
44
|
},
|
|
45
|
+
target: 'pino-pretty',
|
|
44
46
|
},
|
|
45
47
|
})
|
|
46
48
|
: (0, pino_1.default)({
|
|
47
49
|
level,
|
|
50
|
+
mixin: () => this.traceManager?.getTrace() ?? {},
|
|
48
51
|
redact,
|
|
49
52
|
});
|
|
50
53
|
this.instance = pino;
|
|
54
|
+
this.traceManager = traceManager;
|
|
55
|
+
}
|
|
56
|
+
debug(message) {
|
|
57
|
+
this.instance.debug(message);
|
|
51
58
|
}
|
|
52
59
|
error(message, trace = '') {
|
|
53
60
|
this.instance.error(message, trace);
|
|
@@ -55,18 +62,15 @@ let PinoLogger = class PinoLogger extends CoastLogger_1.CoastLogger {
|
|
|
55
62
|
log(message) {
|
|
56
63
|
this.instance.info(message);
|
|
57
64
|
}
|
|
58
|
-
warn(message) {
|
|
59
|
-
this.instance.warn(message);
|
|
60
|
-
}
|
|
61
|
-
debug(message) {
|
|
62
|
-
this.instance.debug(message);
|
|
63
|
-
}
|
|
64
65
|
verbose(message) {
|
|
65
66
|
this.instance.trace(message);
|
|
66
67
|
}
|
|
68
|
+
warn(message) {
|
|
69
|
+
this.instance.warn(message);
|
|
70
|
+
}
|
|
67
71
|
};
|
|
68
72
|
exports.PinoLogger = PinoLogger;
|
|
69
73
|
exports.PinoLogger = PinoLogger = __decorate([
|
|
70
74
|
(0, common_1.Injectable)(),
|
|
71
|
-
__metadata("design:paramtypes", [config_1.ConfigService])
|
|
75
|
+
__metadata("design:paramtypes", [config_1.ConfigService, TraceManager_1.TraceManager])
|
|
72
76
|
], PinoLogger);
|
|
@@ -3,19 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SilentLogger = void 0;
|
|
4
4
|
const CoastLogger_1 = require("./CoastLogger");
|
|
5
5
|
class SilentLogger extends CoastLogger_1.CoastLogger {
|
|
6
|
-
|
|
6
|
+
debug() {
|
|
7
7
|
return;
|
|
8
8
|
}
|
|
9
9
|
error() {
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
log() {
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
verbose() {
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
warn() {
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
21
|
}
|
|
@@ -13,8 +13,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.TraceManager = void 0;
|
|
16
|
-
const node_async_hooks_1 = require("node:async_hooks");
|
|
17
16
|
const common_1 = require("@nestjs/common");
|
|
17
|
+
const node_async_hooks_1 = require("node:async_hooks");
|
|
18
18
|
const uuid_1 = require("uuid");
|
|
19
19
|
const TraceId_1 = require("./TraceId");
|
|
20
20
|
let TraceManager = class TraceManager {
|
|
@@ -26,8 +26,8 @@ let TraceManager = class TraceManager {
|
|
|
26
26
|
}
|
|
27
27
|
withNewTrace(fn, traceId) {
|
|
28
28
|
const trace = {
|
|
29
|
-
traceId: traceId ?? (0, TraceId_1.TraceId)((0, uuid_1.v4)()),
|
|
30
29
|
subtraceId: (0, TraceId_1.TraceId)((0, uuid_1.v4)()),
|
|
30
|
+
traceId: traceId ?? (0, TraceId_1.TraceId)((0, uuid_1.v4)()),
|
|
31
31
|
};
|
|
32
32
|
return this.asyncLocalStorage.run(trace, fn);
|
|
33
33
|
}
|
|
@@ -8,15 +8,15 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.TraceModule = void 0;
|
|
10
10
|
const common_1 = require("@nestjs/common");
|
|
11
|
-
const TraceManager_1 = require("./TraceManager");
|
|
12
|
-
const TraceInterceptor_1 = require("./TraceInterceptor");
|
|
13
11
|
const node_async_hooks_1 = require("node:async_hooks");
|
|
12
|
+
const TraceInterceptor_1 = require("./TraceInterceptor");
|
|
13
|
+
const TraceManager_1 = require("./TraceManager");
|
|
14
14
|
let TraceModule = class TraceModule {
|
|
15
15
|
};
|
|
16
16
|
exports.TraceModule = TraceModule;
|
|
17
17
|
exports.TraceModule = TraceModule = __decorate([
|
|
18
18
|
(0, common_1.Module)({
|
|
19
|
-
providers: [(node_async_hooks_1.AsyncLocalStorage), TraceManager_1.TraceManager, TraceInterceptor_1.TraceInterceptor],
|
|
20
19
|
exports: [TraceManager_1.TraceManager, TraceInterceptor_1.TraceInterceptor],
|
|
20
|
+
providers: [(node_async_hooks_1.AsyncLocalStorage), TraceManager_1.TraceManager, TraceInterceptor_1.TraceInterceptor],
|
|
21
21
|
})
|
|
22
22
|
], TraceModule);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Response } from 'superagent';
|
|
2
|
+
export type GqlResponse<T> = Omit<Response, 'body'> & {
|
|
3
|
+
body: TypedBody<T>;
|
|
4
|
+
};
|
|
5
|
+
interface TypedBody<T> {
|
|
6
|
+
data: T;
|
|
7
|
+
errors?: {
|
|
8
|
+
extensions?: {
|
|
9
|
+
code: number;
|
|
10
|
+
};
|
|
11
|
+
message: string;
|
|
12
|
+
}[];
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare class Generators {
|
|
2
2
|
static chunked<T>(iterator: AsyncGenerator<T>, size: number): AsyncGenerator<T[]>;
|
|
3
|
-
static take<T>(iterator: AsyncGenerator<T>, size: number): AsyncGenerator<T>;
|
|
4
3
|
static map<T, Y>(iterator: AsyncGenerator<T>, mapper: (data: T) => Y): AsyncGenerator<Y>;
|
|
4
|
+
static take<T>(iterator: AsyncGenerator<T>, size: number): AsyncGenerator<T>;
|
|
5
5
|
}
|
|
@@ -13,6 +13,11 @@ class Generators {
|
|
|
13
13
|
}
|
|
14
14
|
yield chunk;
|
|
15
15
|
}
|
|
16
|
+
static async *map(iterator, mapper) {
|
|
17
|
+
for await (const item of iterator) {
|
|
18
|
+
yield mapper(item);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
16
21
|
static async *take(iterator, size) {
|
|
17
22
|
let count = 0;
|
|
18
23
|
for await (const item of iterator) {
|
|
@@ -25,10 +30,5 @@ class Generators {
|
|
|
25
30
|
}
|
|
26
31
|
}
|
|
27
32
|
}
|
|
28
|
-
static async *map(iterator, mapper) {
|
|
29
|
-
for await (const item of iterator) {
|
|
30
|
-
yield mapper(item);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
33
|
}
|
|
34
34
|
exports.Generators = Generators;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const Generators_1 = require("../Generators");
|
|
4
3
|
const common_test_1 = require("@paradoxical-io/common-test");
|
|
4
|
+
const Generators_1 = require("../Generators");
|
|
5
5
|
test('take async', async () => {
|
|
6
6
|
const data = [];
|
|
7
7
|
for await (const i of Generators_1.Generators.take(infinityAsync(), 10)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coast/service-common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "Common service package",
|
|
5
5
|
"main": "./modules",
|
|
6
6
|
"types": "./modules",
|
|
@@ -25,14 +25,18 @@
|
|
|
25
25
|
"scripts": {
|
|
26
26
|
"prebuild": "rimraf dist",
|
|
27
27
|
"build": "yarn prebuild && yarn dlx @nestjs/cli build",
|
|
28
|
-
"lint": "eslint
|
|
28
|
+
"lint": "eslint",
|
|
29
|
+
"lint:fix": "eslint --fix"
|
|
29
30
|
},
|
|
30
31
|
"dependencies": {
|
|
31
32
|
"@paradoxical-io/types": "^1.0.7",
|
|
33
|
+
"lodash": "^4.17.21",
|
|
32
34
|
"pino": "^9.6.0",
|
|
35
|
+
"superagent": "^10.1.1",
|
|
33
36
|
"uuid": "^11.0.5"
|
|
34
37
|
},
|
|
35
38
|
"devDependencies": {
|
|
39
|
+
"@coast/core-api-types": "^1.2.24",
|
|
36
40
|
"@faker-js/faker": "^9.4.0",
|
|
37
41
|
"@nestjs/cli": "^10.4.4",
|
|
38
42
|
"@nestjs/common": "^10.4.1",
|
|
@@ -40,13 +44,16 @@
|
|
|
40
44
|
"@nestjs/schematics": "^10.1.4",
|
|
41
45
|
"@paradoxical-io/common-test": "^1.0.7",
|
|
42
46
|
"@types/jest": "^29.5.12",
|
|
47
|
+
"@types/lodash": "^4",
|
|
43
48
|
"@types/node": "^22.5.0",
|
|
49
|
+
"@types/superagent": "^8.1.9",
|
|
44
50
|
"@types/supertest": "^6.0.2",
|
|
45
51
|
"@typescript-eslint/eslint-plugin": "^8.3.0",
|
|
46
52
|
"@typescript-eslint/parser": "^8.3.0",
|
|
47
53
|
"dotenv": "^16.4.7",
|
|
48
54
|
"eslint": "^9.9.1",
|
|
49
55
|
"eslint-config-prettier": "^9.1.0",
|
|
56
|
+
"eslint-plugin-perfectionist": "^4.8.0",
|
|
50
57
|
"eslint-plugin-prettier": "^5.2.1",
|
|
51
58
|
"husky": "^9.1.7",
|
|
52
59
|
"jest": "^29.7.0",
|