@manyos/smileconnect-api 1.46.3 → 1.47.0
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/conf/clients.json +1 -1
- package/controller/scriptController.js +2 -0
- package/controller/taskController.js +49 -3
- package/docs/openapi.json +295 -1
- package/docs/releases.md +9 -0
- package/package.json +2 -1
package/conf/clients.json
CHANGED
|
@@ -7,6 +7,7 @@ const basePath = 'conf';
|
|
|
7
7
|
const basePathGlobalScripts = basePath + '/scripts';
|
|
8
8
|
|
|
9
9
|
const fetch = require('node-fetch');
|
|
10
|
+
const xmlParser = require('fast-xml-parser')
|
|
10
11
|
|
|
11
12
|
const {getClients} = require('../util/config');
|
|
12
13
|
|
|
@@ -79,6 +80,7 @@ async function executeCode(code, requestData, params, logStream, executedByScrip
|
|
|
79
80
|
adapter,
|
|
80
81
|
log,
|
|
81
82
|
clientId,
|
|
83
|
+
xmlParser,
|
|
82
84
|
script:executeScriptByScript,
|
|
83
85
|
globalScriptParams,
|
|
84
86
|
env: process.env,
|
|
@@ -133,10 +133,55 @@ async function updateTaskFlow(clientConfig, rootForm, rootRequestId, rootRequest
|
|
|
133
133
|
|
|
134
134
|
flowBuilderRequest = mappingUtil.applyMapping2Remedy(flowBuilderRequest, mappingflow, clientConfig.flowBuilder.constants);
|
|
135
135
|
const taskFlowResult = await arquery.createEntry('TMS:FlowBuilder', flowBuilderRequest, clientConfig.options)
|
|
136
|
-
await activateTaskFlow(clientConfig, rootRequestInstanceId)
|
|
136
|
+
//await activateTaskFlow(clientConfig, rootRequestInstanceId)
|
|
137
|
+
await checkFlowActivation(clientConfig, rootRequestInstanceId, rootRequestId, rootForm)
|
|
137
138
|
}
|
|
138
139
|
|
|
139
|
-
async function
|
|
140
|
+
async function checkFlowActivation(clientConfig, rootRequestInstanceId, rootRequestId, rootForm) {
|
|
141
|
+
let subQuery = "'1' = \"rootRequestId\"";
|
|
142
|
+
let statusField = '7'
|
|
143
|
+
let statusReasonField = ''
|
|
144
|
+
let companyField = 'Location Company'
|
|
145
|
+
if (rootForm === CONSTANTS.FORM_WORKORDER) {
|
|
146
|
+
subQuery = `'Work Order ID'=\"${rootRequestId}\"`;
|
|
147
|
+
} else if (rootForm === CONSTANTS.FORM_INCIDENT) {
|
|
148
|
+
subQuery = `'Incident Number'=\"${rootRequestId}\"`;
|
|
149
|
+
} else if (rootForm === CONSTANTS.FORM_PROBLEM) {
|
|
150
|
+
subQuery = `'Problem Investigation ID'=\"${rootRequestId}\"`;
|
|
151
|
+
} else if (rootForm === CONSTANTS.FORM_CHANGE) {
|
|
152
|
+
subQuery = `'Infrastructure Change ID'=\"${rootRequestId}\"`;
|
|
153
|
+
statusField = 'Change Request Status'
|
|
154
|
+
statusReasonField = 'Status Reason'
|
|
155
|
+
}
|
|
156
|
+
//Read instanceId from Root request
|
|
157
|
+
log.debug('Query root request for current status')
|
|
158
|
+
const rootRequest = await arquery.executeARQuery(rootForm, null, subQuery, [statusField, statusReasonField, companyField], clientConfig.options)
|
|
159
|
+
if (rootRequest && rootRequest.data && rootRequest.data.length > 0) {
|
|
160
|
+
const rootRecord = rootRequest.data[0]
|
|
161
|
+
const form = 'TMS:ConfigPhaseManagement'
|
|
162
|
+
log.debug('Query phase config for current phase')
|
|
163
|
+
|
|
164
|
+
let configQuery = `'Activation Status*'="${rootRecord[statusField]}" AND ('Company' = "${rootRecord[companyField]}" OR 'Company' = "- Global -") AND 'AppInstanceFormName' = "${rootForm}" AND 'Status' = "Active"`
|
|
165
|
+
if (rootRecord[statusReasonField]) {
|
|
166
|
+
configQuery = configQuery + ` AND 'Status Reason' = "${rootRecord[statusReasonField]}"`
|
|
167
|
+
} else {
|
|
168
|
+
configQuery = configQuery + ` AND 'Status Reason' = $NULL$`
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
const phaseRecords = await arquery.executeARQuery(form, undefined,
|
|
173
|
+
configQuery, 'InstanceId')
|
|
174
|
+
if (phaseRecords && phaseRecords.data && phaseRecords.data.length > 0) {
|
|
175
|
+
const phaseRecord = phaseRecords.data[0]
|
|
176
|
+
const phaseGuid = phaseRecord['InstanceId']
|
|
177
|
+
await activateTaskFlow(clientConfig, rootRequestInstanceId, phaseGuid)
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
async function activateTaskFlow(clientConfig, rootRequestInstanceId, phaseGuid) {
|
|
184
|
+
// Activate flow from here
|
|
140
185
|
const form = 'TMS:Flow'
|
|
141
186
|
const idField = 'Flow ID'
|
|
142
187
|
const flowRequest = {
|
|
@@ -145,8 +190,9 @@ async function activateTaskFlow(clientConfig, rootRequestInstanceId) {
|
|
|
145
190
|
"zTmpInternalCommand": "EVALUATE",
|
|
146
191
|
"zTmpInternal" : "True"
|
|
147
192
|
};
|
|
193
|
+
|
|
148
194
|
const records = await arquery.executeARQuery(form, undefined,
|
|
149
|
-
`'RootRequestInstanceID'="${rootRequestInstanceId}" AND 'ParentID' = "${rootRequestInstanceId}" AND 'Predecessor Link' = "Start" AND 'Status' = "Pending" AND 'Sequence Mode' = "Yes"`, idField)
|
|
195
|
+
`'RootRequestInstanceID'="${rootRequestInstanceId}" AND 'ParentID' = "${rootRequestInstanceId}" AND 'Predecessor Link' = "Start" AND 'Status' = "Pending" AND 'Sequence Mode' = "Yes" AND 'Phase GUID' = "${phaseGuid}"`, idField)
|
|
150
196
|
if (records && records.data) {
|
|
151
197
|
for (let x=0; x<records.data.length; x++) {
|
|
152
198
|
const record = records.data[x]
|
package/docs/openapi.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"openapi": "3.0.2",
|
|
3
3
|
"info": {
|
|
4
4
|
"title": "SMILEconnect",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.47.0",
|
|
6
6
|
"contact": {
|
|
7
7
|
"name": "manyos technology GmbH",
|
|
8
8
|
"url": "https://manyos.it",
|
|
@@ -4330,6 +4330,208 @@
|
|
|
4330
4330
|
"required": false
|
|
4331
4331
|
}
|
|
4332
4332
|
]
|
|
4333
|
+
},
|
|
4334
|
+
"/customForms/{formAlias}": {
|
|
4335
|
+
"get": {
|
|
4336
|
+
"tags": [
|
|
4337
|
+
"CustomForms"
|
|
4338
|
+
],
|
|
4339
|
+
"parameters": [
|
|
4340
|
+
{
|
|
4341
|
+
"name": "limit",
|
|
4342
|
+
"description": "limit the number of results returned",
|
|
4343
|
+
"schema": {
|
|
4344
|
+
"type": "integer"
|
|
4345
|
+
},
|
|
4346
|
+
"in": "query",
|
|
4347
|
+
"required": false
|
|
4348
|
+
},
|
|
4349
|
+
{
|
|
4350
|
+
"name": "offset",
|
|
4351
|
+
"description": "offset used for pagination together with limit",
|
|
4352
|
+
"schema": {
|
|
4353
|
+
"type": "integer"
|
|
4354
|
+
},
|
|
4355
|
+
"in": "query",
|
|
4356
|
+
"required": false
|
|
4357
|
+
}
|
|
4358
|
+
],
|
|
4359
|
+
"responses": {
|
|
4360
|
+
"200": {
|
|
4361
|
+
"$ref": "#/components/responses/CustomFormResponseArray"
|
|
4362
|
+
}
|
|
4363
|
+
},
|
|
4364
|
+
"security": [
|
|
4365
|
+
{
|
|
4366
|
+
"OIDC": [
|
|
4367
|
+
]
|
|
4368
|
+
}
|
|
4369
|
+
],
|
|
4370
|
+
"summary": "Receive all records of the custom from",
|
|
4371
|
+
"description": "Will return all records that are found based on the defined base query and the set limits"
|
|
4372
|
+
},
|
|
4373
|
+
"post": {
|
|
4374
|
+
"requestBody": {
|
|
4375
|
+
"content": {
|
|
4376
|
+
"application/json": {
|
|
4377
|
+
"schema": {
|
|
4378
|
+
"$ref": "#/components/schemas/CustomFormRequest"
|
|
4379
|
+
}
|
|
4380
|
+
}
|
|
4381
|
+
},
|
|
4382
|
+
"required": true
|
|
4383
|
+
},
|
|
4384
|
+
"tags": [
|
|
4385
|
+
"CustomForms"
|
|
4386
|
+
],
|
|
4387
|
+
"responses": {
|
|
4388
|
+
"200": {
|
|
4389
|
+
"$ref": "#/components/responses/CustomFormResponseSingle"
|
|
4390
|
+
}
|
|
4391
|
+
},
|
|
4392
|
+
"security": [
|
|
4393
|
+
{
|
|
4394
|
+
"OIDC": [
|
|
4395
|
+
]
|
|
4396
|
+
}
|
|
4397
|
+
],
|
|
4398
|
+
"summary": "Create a new record",
|
|
4399
|
+
"description": "Create a new record in the custom form"
|
|
4400
|
+
},
|
|
4401
|
+
"parameters": [
|
|
4402
|
+
{
|
|
4403
|
+
"name": "formAlias",
|
|
4404
|
+
"description": "The configured alias name of the custom form.",
|
|
4405
|
+
"schema": {
|
|
4406
|
+
"type": "string"
|
|
4407
|
+
},
|
|
4408
|
+
"in": "path",
|
|
4409
|
+
"required": true
|
|
4410
|
+
}
|
|
4411
|
+
]
|
|
4412
|
+
},
|
|
4413
|
+
"/customForms/{formAlias}/search": {
|
|
4414
|
+
"post": {
|
|
4415
|
+
"requestBody": {
|
|
4416
|
+
"content": {
|
|
4417
|
+
"application/json": {
|
|
4418
|
+
"schema": {
|
|
4419
|
+
"$ref": "#/components/schemas/SearchRequest"
|
|
4420
|
+
}
|
|
4421
|
+
}
|
|
4422
|
+
},
|
|
4423
|
+
"required": true
|
|
4424
|
+
},
|
|
4425
|
+
"tags": [
|
|
4426
|
+
"CustomForms"
|
|
4427
|
+
],
|
|
4428
|
+
"responses": {
|
|
4429
|
+
"200": {
|
|
4430
|
+
"$ref": "#/components/responses/CustomFormResponseArray"
|
|
4431
|
+
}
|
|
4432
|
+
},
|
|
4433
|
+
"security": [
|
|
4434
|
+
{
|
|
4435
|
+
"OIDC": [
|
|
4436
|
+
]
|
|
4437
|
+
}
|
|
4438
|
+
],
|
|
4439
|
+
"summary": "Execute a search in a custom form"
|
|
4440
|
+
},
|
|
4441
|
+
"parameters": [
|
|
4442
|
+
{
|
|
4443
|
+
"examples": {
|
|
4444
|
+
"sample": {
|
|
4445
|
+
"value": "abc123"
|
|
4446
|
+
}
|
|
4447
|
+
},
|
|
4448
|
+
"name": "impersonateUser",
|
|
4449
|
+
"description": "If the clientConfig has the option allowDynamicImpersonate set to *true* then the URL Parameter *impersonateUser* can be used to determine the used Remedy User.",
|
|
4450
|
+
"schema": {
|
|
4451
|
+
"type": "string"
|
|
4452
|
+
},
|
|
4453
|
+
"in": "query",
|
|
4454
|
+
"required": false
|
|
4455
|
+
},
|
|
4456
|
+
{
|
|
4457
|
+
"name": "formAlias",
|
|
4458
|
+
"description": "The configured alias name of the custom form.",
|
|
4459
|
+
"schema": {
|
|
4460
|
+
"type": "string"
|
|
4461
|
+
},
|
|
4462
|
+
"in": "path",
|
|
4463
|
+
"required": true
|
|
4464
|
+
}
|
|
4465
|
+
]
|
|
4466
|
+
},
|
|
4467
|
+
"/customForms/{formAlias}/{id}": {
|
|
4468
|
+
"get": {
|
|
4469
|
+
"tags": [
|
|
4470
|
+
"CustomForms"
|
|
4471
|
+
],
|
|
4472
|
+
"responses": {
|
|
4473
|
+
"200": {
|
|
4474
|
+
"$ref": "#/components/responses/CustomFormResponseSingle"
|
|
4475
|
+
}
|
|
4476
|
+
},
|
|
4477
|
+
"security": [
|
|
4478
|
+
{
|
|
4479
|
+
"OIDC": [
|
|
4480
|
+
]
|
|
4481
|
+
}
|
|
4482
|
+
]
|
|
4483
|
+
},
|
|
4484
|
+
"put": {
|
|
4485
|
+
"requestBody": {
|
|
4486
|
+
"content": {
|
|
4487
|
+
"application/json": {
|
|
4488
|
+
"schema": {
|
|
4489
|
+
"$ref": "#/components/schemas/CustomFormRequest"
|
|
4490
|
+
}
|
|
4491
|
+
}
|
|
4492
|
+
},
|
|
4493
|
+
"required": true
|
|
4494
|
+
},
|
|
4495
|
+
"tags": [
|
|
4496
|
+
"CustomForms"
|
|
4497
|
+
],
|
|
4498
|
+
"responses": {
|
|
4499
|
+
"200": {
|
|
4500
|
+
"$ref": "#/components/responses/CustomFormResponseSingle"
|
|
4501
|
+
}
|
|
4502
|
+
},
|
|
4503
|
+
"security": [
|
|
4504
|
+
{
|
|
4505
|
+
"OIDC": [
|
|
4506
|
+
]
|
|
4507
|
+
}
|
|
4508
|
+
]
|
|
4509
|
+
},
|
|
4510
|
+
"parameters": [
|
|
4511
|
+
{
|
|
4512
|
+
"name": "formAlias",
|
|
4513
|
+
"description": "The configured alias name of the custom form.",
|
|
4514
|
+
"schema": {
|
|
4515
|
+
"type": "string"
|
|
4516
|
+
},
|
|
4517
|
+
"in": "path",
|
|
4518
|
+
"required": true
|
|
4519
|
+
},
|
|
4520
|
+
{
|
|
4521
|
+
"examples": {
|
|
4522
|
+
"id": {
|
|
4523
|
+
"value": "ENV12345"
|
|
4524
|
+
}
|
|
4525
|
+
},
|
|
4526
|
+
"name": "id",
|
|
4527
|
+
"description": "The id record",
|
|
4528
|
+
"schema": {
|
|
4529
|
+
"type": "string"
|
|
4530
|
+
},
|
|
4531
|
+
"in": "path",
|
|
4532
|
+
"required": true
|
|
4533
|
+
}
|
|
4534
|
+
]
|
|
4333
4535
|
}
|
|
4334
4536
|
},
|
|
4335
4537
|
"components": {
|
|
@@ -16078,6 +16280,61 @@
|
|
|
16078
16280
|
"text": "Status Marked: Resolved by Allen",
|
|
16079
16281
|
"isPublic": true
|
|
16080
16282
|
}
|
|
16283
|
+
},
|
|
16284
|
+
"CustomFormRecord": {
|
|
16285
|
+
"title": "Root Type for customFormRecord",
|
|
16286
|
+
"description": "A record stored in a custom form. The fields (besides id) are samples and will depend on the config.",
|
|
16287
|
+
"type": "object",
|
|
16288
|
+
"properties": {
|
|
16289
|
+
"id": {
|
|
16290
|
+
"type": "string"
|
|
16291
|
+
},
|
|
16292
|
+
"userId": {
|
|
16293
|
+
"type": "string"
|
|
16294
|
+
},
|
|
16295
|
+
"classId": {
|
|
16296
|
+
"type": "string"
|
|
16297
|
+
},
|
|
16298
|
+
"classTitle": {
|
|
16299
|
+
"type": "string"
|
|
16300
|
+
},
|
|
16301
|
+
"location": {
|
|
16302
|
+
"type": "string"
|
|
16303
|
+
},
|
|
16304
|
+
"startDate": {
|
|
16305
|
+
"type": "string"
|
|
16306
|
+
},
|
|
16307
|
+
"cost": {
|
|
16308
|
+
"format": "int32",
|
|
16309
|
+
"type": "integer"
|
|
16310
|
+
},
|
|
16311
|
+
"department": {
|
|
16312
|
+
"type": "string"
|
|
16313
|
+
}
|
|
16314
|
+
},
|
|
16315
|
+
"example": {
|
|
16316
|
+
"id": "00001",
|
|
16317
|
+
"userId": "Demo",
|
|
16318
|
+
"classId": "00001",
|
|
16319
|
+
"classTitle": "Managing Within the Law",
|
|
16320
|
+
"location": "Munich, Germany",
|
|
16321
|
+
"startDate": "Mon Nov 07 16:00:00 GMT 2005",
|
|
16322
|
+
"cost": 100,
|
|
16323
|
+
"department": "Sales"
|
|
16324
|
+
}
|
|
16325
|
+
},
|
|
16326
|
+
"CustomFormRequest": {
|
|
16327
|
+
"description": "Creates a new Record in a custum form",
|
|
16328
|
+
"required": [
|
|
16329
|
+
"data"
|
|
16330
|
+
],
|
|
16331
|
+
"type": "object",
|
|
16332
|
+
"properties": {
|
|
16333
|
+
"data": {
|
|
16334
|
+
"$ref": "#/components/schemas/CustomFormRecord",
|
|
16335
|
+
"description": ""
|
|
16336
|
+
}
|
|
16337
|
+
}
|
|
16081
16338
|
}
|
|
16082
16339
|
},
|
|
16083
16340
|
"responses": {
|
|
@@ -16169,6 +16426,39 @@
|
|
|
16169
16426
|
}
|
|
16170
16427
|
},
|
|
16171
16428
|
"description": "Returns deletion confirmation for the requested item"
|
|
16429
|
+
},
|
|
16430
|
+
"CustomFormResponseSingle": {
|
|
16431
|
+
"content": {
|
|
16432
|
+
"application/json": {
|
|
16433
|
+
"schema": {
|
|
16434
|
+
"type": "object",
|
|
16435
|
+
"properties": {
|
|
16436
|
+
"data": {
|
|
16437
|
+
"$ref": "#/components/schemas/CustomFormRecord"
|
|
16438
|
+
}
|
|
16439
|
+
}
|
|
16440
|
+
}
|
|
16441
|
+
}
|
|
16442
|
+
},
|
|
16443
|
+
"description": "Returns a single custom form record"
|
|
16444
|
+
},
|
|
16445
|
+
"CustomFormResponseArray": {
|
|
16446
|
+
"content": {
|
|
16447
|
+
"application/json": {
|
|
16448
|
+
"schema": {
|
|
16449
|
+
"type": "object",
|
|
16450
|
+
"properties": {
|
|
16451
|
+
"data": {
|
|
16452
|
+
"type": "array",
|
|
16453
|
+
"items": {
|
|
16454
|
+
"$ref": "#/components/schemas/CustomFormRecord"
|
|
16455
|
+
}
|
|
16456
|
+
}
|
|
16457
|
+
}
|
|
16458
|
+
}
|
|
16459
|
+
}
|
|
16460
|
+
},
|
|
16461
|
+
"description": "Returns an array of Custom Form Records"
|
|
16172
16462
|
}
|
|
16173
16463
|
},
|
|
16174
16464
|
"securitySchemes": {
|
|
@@ -16214,6 +16504,10 @@
|
|
|
16214
16504
|
"name": "CMDBObjects",
|
|
16215
16505
|
"description": ""
|
|
16216
16506
|
},
|
|
16507
|
+
{
|
|
16508
|
+
"name": "CustomForms",
|
|
16509
|
+
"description": "All custom form requests"
|
|
16510
|
+
},
|
|
16217
16511
|
{
|
|
16218
16512
|
"name": "AppConfig",
|
|
16219
16513
|
"description": "Application Configuration"
|
package/docs/releases.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
## API
|
|
4
4
|
|
|
5
|
+
### 1.47.0 - 22.10.21
|
|
6
|
+
Add xmlParser to scripts.
|
|
7
|
+
See https://www.npmjs.com/package/fast-xml-parser
|
|
8
|
+
|
|
9
|
+
Add customForms
|
|
10
|
+
|
|
11
|
+
### 1.46.4 - 20.10.21
|
|
12
|
+
Fix known issue: Check for activation Task Phase and activate if reached
|
|
13
|
+
|
|
5
14
|
### 1.46.3 - 18.10.21
|
|
6
15
|
Fix issue: Task not activated when phase already active
|
|
7
16
|
Known issues: Tasks might get activated early
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manyos/smileconnect-api",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.47.0",
|
|
4
4
|
"description": "A proxy and abstraction layer for BMCs IT Service Management Suite",
|
|
5
5
|
"main": "app.js",
|
|
6
6
|
"scripts": {
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"express-rate-limit": "^5.2.6",
|
|
24
24
|
"express-request-id": "^1.4.1",
|
|
25
25
|
"express-validator": "^6.10.1",
|
|
26
|
+
"fast-xml-parser": "^3.20.3",
|
|
26
27
|
"moment": "^2.29.1",
|
|
27
28
|
"mongoose": "^5.12.5",
|
|
28
29
|
"node-cache": "^4.2.1",
|