@red-hat-developer-hub/backstage-plugin-orchestrator-backend 5.1.1 → 5.2.1
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/CHANGELOG.md +30 -0
- package/dist/helpers/errorBuilder.cjs.js.map +1 -1
- package/dist/helpers/filterBuilder.cjs.js +41 -31
- package/dist/helpers/filterBuilder.cjs.js.map +1 -1
- package/dist/helpers/queryBuilder.cjs.js.map +1 -1
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/routerWrapper/index.cjs.js.map +1 -1
- package/dist/service/DataIndexService.cjs.js +48 -71
- package/dist/service/DataIndexService.cjs.js.map +1 -1
- package/dist/service/DataInputSchemaService.cjs.js.map +1 -1
- package/dist/service/DevModeService.cjs.js +40 -8
- package/dist/service/DevModeService.cjs.js.map +1 -1
- package/dist/service/GitService.cjs.js.map +1 -1
- package/dist/service/GitWrapper/git.cjs.js.map +1 -1
- package/dist/service/Helper.cjs.js.map +1 -1
- package/dist/service/OrchestratorService.cjs.js +13 -5
- package/dist/service/OrchestratorService.cjs.js.map +1 -1
- package/dist/service/ScaffolderService.cjs.js +4 -1
- package/dist/service/ScaffolderService.cjs.js.map +1 -1
- package/dist/service/SonataFlowService.cjs.js +46 -10
- package/dist/service/SonataFlowService.cjs.js.map +1 -1
- package/dist/service/WorkflowCacheService.cjs.js +13 -2
- package/dist/service/WorkflowCacheService.cjs.js.map +1 -1
- package/dist/service/api/mapping/V2Mappings.cjs.js +2 -1
- package/dist/service/api/mapping/V2Mappings.cjs.js.map +1 -1
- package/dist/service/api/v2.cjs.js +13 -1
- package/dist/service/api/v2.cjs.js.map +1 -1
- package/dist/service/constants.cjs.js.map +1 -1
- package/dist/service/router.cjs.js +7 -3
- package/dist/service/router.cjs.js.map +1 -1
- package/dist/types/pagination.cjs.js.map +1 -1
- package/package.json +26 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
### Dependencies
|
|
2
2
|
|
|
3
|
+
## 5.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- bad7cb0: updated dev mode to remove git configuration from the workflow repo, added checks for cloning path
|
|
8
|
+
|
|
9
|
+
## 5.2.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 967c377: Fixed unsupported filter operators
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- e3ebb0c: replace abort mutation with call to delete
|
|
18
|
+
- 665947d: fix bug in error handling of execute API
|
|
19
|
+
- 4e3ccc2: Add retrigger option to UI using v2 API
|
|
20
|
+
- d1010f9: improve logging of router
|
|
21
|
+
- bee24dc: add unavailable workflows to cache and overview
|
|
22
|
+
- b0e3ede: improve data index network error
|
|
23
|
+
- 10f17e3: Fixed a typo in FilterBuilder error message
|
|
24
|
+
- aebd2b0: improved devMode, added podman and macos support
|
|
25
|
+
- Updated dependencies [967c377]
|
|
26
|
+
- Updated dependencies [05a1ce0]
|
|
27
|
+
- Updated dependencies [816d8bc]
|
|
28
|
+
- Updated dependencies [c7de094]
|
|
29
|
+
- Updated dependencies [bee24dc]
|
|
30
|
+
- Updated dependencies [d4fa6bf]
|
|
31
|
+
- @red-hat-developer-hub/backstage-plugin-orchestrator-common@1.26.0
|
|
32
|
+
|
|
3
33
|
## 5.1.1
|
|
4
34
|
|
|
5
35
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorBuilder.cjs.js","sources":["../../src/helpers/errorBuilder.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nexport const NO_DATA_INDEX_URL = 'NO_DATA_INDEX_URL';\nexport const NO_BACKEND_EXEC_CTX = 'NO_BACKEND_EXEC_CTX';\nexport const NO_CLIENT_PROVIDED = 'NO_CLIENT_PROVIDED';\nexport const NO_LOGGER = 'NO_LOGGER';\nexport const SWF_BACKEND_NOT_INITED = 'SWF_BACKEND_NOT_INITED';\n\nexport class ErrorBuilder {\n public static NewBackendError(name: string, message: string): Error {\n const e = new Error(message);\n e.name = name;\n return e;\n }\n\n public static GET_NO_DATA_INDEX_URL_ERR(): Error {\n return this.NewBackendError(\n NO_DATA_INDEX_URL,\n 'No data index url specified or found',\n );\n }\n\n public static GET_NO_CLIENT_PROVIDED_ERR(): Error {\n return this.NewBackendError(\n NO_CLIENT_PROVIDED,\n 'No or null graphql client',\n );\n }\n\n public static GET_SWF_BACKEND_NOT_INITED(): Error {\n return this.NewBackendError(\n SWF_BACKEND_NOT_INITED,\n 'The SonataFlow backend is not initialized, call initialize() method before trying to get the workflows.',\n );\n }\n}\n"],"names":[],"mappings":";;AAeO,MAAM,iBAAoB,GAAA
|
|
1
|
+
{"version":3,"file":"errorBuilder.cjs.js","sources":["../../src/helpers/errorBuilder.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nexport const NO_DATA_INDEX_URL = 'NO_DATA_INDEX_URL';\nexport const NO_BACKEND_EXEC_CTX = 'NO_BACKEND_EXEC_CTX';\nexport const NO_CLIENT_PROVIDED = 'NO_CLIENT_PROVIDED';\nexport const NO_LOGGER = 'NO_LOGGER';\nexport const SWF_BACKEND_NOT_INITED = 'SWF_BACKEND_NOT_INITED';\n\nexport class ErrorBuilder {\n public static NewBackendError(name: string, message: string): Error {\n const e = new Error(message);\n e.name = name;\n return e;\n }\n\n public static GET_NO_DATA_INDEX_URL_ERR(): Error {\n return this.NewBackendError(\n NO_DATA_INDEX_URL,\n 'No data index url specified or found',\n );\n }\n\n public static GET_NO_CLIENT_PROVIDED_ERR(): Error {\n return this.NewBackendError(\n NO_CLIENT_PROVIDED,\n 'No or null graphql client',\n );\n }\n\n public static GET_SWF_BACKEND_NOT_INITED(): Error {\n return this.NewBackendError(\n SWF_BACKEND_NOT_INITED,\n 'The SonataFlow backend is not initialized, call initialize() method before trying to get the workflows.',\n );\n }\n}\n"],"names":[],"mappings":";;AAeO,MAAM,iBAAoB,GAAA;AAE1B,MAAM,kBAAqB,GAAA;AAE3B,MAAM,sBAAyB,GAAA;AAE/B,MAAM,YAAa,CAAA;AAAA,EACxB,OAAc,eAAgB,CAAA,IAAA,EAAc,OAAwB,EAAA;AAClE,IAAM,MAAA,CAAA,GAAI,IAAI,KAAA,CAAM,OAAO,CAAA;AAC3B,IAAA,CAAA,CAAE,IAAO,GAAA,IAAA;AACT,IAAO,OAAA,CAAA;AAAA;AACT,EAEA,OAAc,yBAAmC,GAAA;AAC/C,IAAA,OAAO,IAAK,CAAA,eAAA;AAAA,MACV,iBAAA;AAAA,MACA;AAAA,KACF;AAAA;AACF,EAEA,OAAc,0BAAoC,GAAA;AAChD,IAAA,OAAO,IAAK,CAAA,eAAA;AAAA,MACV,kBAAA;AAAA,MACA;AAAA,KACF;AAAA;AACF,EAEA,OAAc,0BAAoC,GAAA;AAChD,IAAA,OAAO,IAAK,CAAA,eAAA;AAAA,MACV,sBAAA;AAAA,MACA;AAAA,KACF;AAAA;AAEJ;;;;;;;"}
|
|
@@ -2,6 +2,39 @@
|
|
|
2
2
|
|
|
3
3
|
var backstagePluginOrchestratorCommon = require('@red-hat-developer-hub/backstage-plugin-orchestrator-common');
|
|
4
4
|
|
|
5
|
+
const supportedOperators = [
|
|
6
|
+
backstagePluginOrchestratorCommon.FieldFilterOperatorEnum.Eq,
|
|
7
|
+
backstagePluginOrchestratorCommon.FieldFilterOperatorEnum.Like,
|
|
8
|
+
backstagePluginOrchestratorCommon.FieldFilterOperatorEnum.In,
|
|
9
|
+
backstagePluginOrchestratorCommon.FieldFilterOperatorEnum.IsNull,
|
|
10
|
+
backstagePluginOrchestratorCommon.FieldFilterOperatorEnum.Gt,
|
|
11
|
+
backstagePluginOrchestratorCommon.FieldFilterOperatorEnum.Gte,
|
|
12
|
+
backstagePluginOrchestratorCommon.FieldFilterOperatorEnum.Lt,
|
|
13
|
+
backstagePluginOrchestratorCommon.FieldFilterOperatorEnum.Lte,
|
|
14
|
+
backstagePluginOrchestratorCommon.FieldFilterOperatorEnum.Between
|
|
15
|
+
];
|
|
16
|
+
const supportedOperatorsByType = {
|
|
17
|
+
[backstagePluginOrchestratorCommon.TypeName.String]: [
|
|
18
|
+
backstagePluginOrchestratorCommon.FieldFilterOperatorEnum.In,
|
|
19
|
+
backstagePluginOrchestratorCommon.FieldFilterOperatorEnum.Like,
|
|
20
|
+
backstagePluginOrchestratorCommon.FieldFilterOperatorEnum.IsNull,
|
|
21
|
+
backstagePluginOrchestratorCommon.FieldFilterOperatorEnum.Eq
|
|
22
|
+
],
|
|
23
|
+
[backstagePluginOrchestratorCommon.TypeName.Id]: [
|
|
24
|
+
backstagePluginOrchestratorCommon.FieldFilterOperatorEnum.In,
|
|
25
|
+
backstagePluginOrchestratorCommon.FieldFilterOperatorEnum.IsNull,
|
|
26
|
+
backstagePluginOrchestratorCommon.FieldFilterOperatorEnum.Eq
|
|
27
|
+
],
|
|
28
|
+
[backstagePluginOrchestratorCommon.TypeName.Date]: [
|
|
29
|
+
backstagePluginOrchestratorCommon.FieldFilterOperatorEnum.IsNull,
|
|
30
|
+
backstagePluginOrchestratorCommon.FieldFilterOperatorEnum.Eq,
|
|
31
|
+
backstagePluginOrchestratorCommon.FieldFilterOperatorEnum.Gt,
|
|
32
|
+
backstagePluginOrchestratorCommon.FieldFilterOperatorEnum.Gte,
|
|
33
|
+
backstagePluginOrchestratorCommon.FieldFilterOperatorEnum.Lt,
|
|
34
|
+
backstagePluginOrchestratorCommon.FieldFilterOperatorEnum.Lte,
|
|
35
|
+
backstagePluginOrchestratorCommon.FieldFilterOperatorEnum.Between
|
|
36
|
+
]
|
|
37
|
+
};
|
|
5
38
|
function isLogicalFilter(filter) {
|
|
6
39
|
return filter.filters !== void 0;
|
|
7
40
|
}
|
|
@@ -57,15 +90,18 @@ function buildFilterCondition(introspection, type, filters) {
|
|
|
57
90
|
return handleLogicalFilter(introspection, type, filters);
|
|
58
91
|
}
|
|
59
92
|
if (!isOperatorSupported(filters.operator)) {
|
|
60
|
-
throw new Error(
|
|
93
|
+
throw new Error(
|
|
94
|
+
`Unsupported operator ${filters.operator}. Supported operators are: ${supportedOperators.join(", ")}`
|
|
95
|
+
);
|
|
61
96
|
}
|
|
62
97
|
const fieldDef = introspection.find((f) => f.name === filters.field);
|
|
63
98
|
if (!fieldDef) {
|
|
64
99
|
throw new Error(`Can't find field "${filters.field}" definition`);
|
|
65
100
|
}
|
|
66
101
|
if (!isOperatorAllowedForField(filters.operator, fieldDef, type)) {
|
|
102
|
+
const allowedOperators = supportedOperatorsByType[fieldDef.type.name] || [];
|
|
67
103
|
throw new Error(
|
|
68
|
-
`Unsupported operator ${filters.operator} for field "${fieldDef.name}" of type "${fieldDef.type.name}"`
|
|
104
|
+
`Unsupported operator ${filters.operator} for field "${fieldDef.name}" of type "${fieldDef.type.name}". Allowed operators are: ${allowedOperators.join(", ")}`
|
|
69
105
|
);
|
|
70
106
|
}
|
|
71
107
|
switch (filters.operator) {
|
|
@@ -86,7 +122,7 @@ function buildFilterCondition(introspection, type, filters) {
|
|
|
86
122
|
}
|
|
87
123
|
}
|
|
88
124
|
function isOperatorSupported(operator) {
|
|
89
|
-
return
|
|
125
|
+
return supportedOperators.includes(operator);
|
|
90
126
|
}
|
|
91
127
|
function isFieldFilterSupported(fieldDef) {
|
|
92
128
|
return fieldDef?.type.name === backstagePluginOrchestratorCommon.TypeName.String;
|
|
@@ -95,30 +131,7 @@ function isOperatorAllowedForField(operator, fieldDef, type) {
|
|
|
95
131
|
if (isEnumFilter(fieldDef.name, type) && isValidEnumOperator(operator)) {
|
|
96
132
|
return true;
|
|
97
133
|
}
|
|
98
|
-
const
|
|
99
|
-
[backstagePluginOrchestratorCommon.TypeName.String]: [
|
|
100
|
-
backstagePluginOrchestratorCommon.FieldFilterOperatorEnum.In,
|
|
101
|
-
backstagePluginOrchestratorCommon.FieldFilterOperatorEnum.Like,
|
|
102
|
-
backstagePluginOrchestratorCommon.FieldFilterOperatorEnum.IsNull,
|
|
103
|
-
backstagePluginOrchestratorCommon.FieldFilterOperatorEnum.Eq
|
|
104
|
-
],
|
|
105
|
-
[backstagePluginOrchestratorCommon.TypeName.Id]: [
|
|
106
|
-
backstagePluginOrchestratorCommon.FieldFilterOperatorEnum.In,
|
|
107
|
-
backstagePluginOrchestratorCommon.FieldFilterOperatorEnum.IsNull,
|
|
108
|
-
backstagePluginOrchestratorCommon.FieldFilterOperatorEnum.Eq
|
|
109
|
-
],
|
|
110
|
-
[backstagePluginOrchestratorCommon.TypeName.Date]: [
|
|
111
|
-
backstagePluginOrchestratorCommon.FieldFilterOperatorEnum.IsNull,
|
|
112
|
-
backstagePluginOrchestratorCommon.FieldFilterOperatorEnum.Eq,
|
|
113
|
-
backstagePluginOrchestratorCommon.FieldFilterOperatorEnum.Gt,
|
|
114
|
-
backstagePluginOrchestratorCommon.FieldFilterOperatorEnum.Gte,
|
|
115
|
-
backstagePluginOrchestratorCommon.FieldFilterOperatorEnum.Lt,
|
|
116
|
-
backstagePluginOrchestratorCommon.FieldFilterOperatorEnum.Lte,
|
|
117
|
-
backstagePluginOrchestratorCommon.FieldFilterOperatorEnum.Between
|
|
118
|
-
],
|
|
119
|
-
[backstagePluginOrchestratorCommon.TypeName.StringArray]: []
|
|
120
|
-
};
|
|
121
|
-
const allowedForType = allowedOperators[fieldDef.type.name];
|
|
134
|
+
const allowedForType = supportedOperatorsByType[fieldDef.type.name];
|
|
122
135
|
return allowedForType ? allowedForType.includes(operator) : false;
|
|
123
136
|
}
|
|
124
137
|
function convertToBoolean(value) {
|
|
@@ -165,10 +178,6 @@ function getGraphQLOperator(operator) {
|
|
|
165
178
|
return "lessThan";
|
|
166
179
|
case "LTE":
|
|
167
180
|
return "lessThanEqual";
|
|
168
|
-
// case 'CONTAINS':
|
|
169
|
-
// return "contains"
|
|
170
|
-
// case 'CONTAINS_ALL':
|
|
171
|
-
// case 'CONTAINS_ANY':
|
|
172
181
|
case "BETWEEN":
|
|
173
182
|
return "between";
|
|
174
183
|
default:
|
|
@@ -177,4 +186,5 @@ function getGraphQLOperator(operator) {
|
|
|
177
186
|
}
|
|
178
187
|
|
|
179
188
|
exports.buildFilterCondition = buildFilterCondition;
|
|
189
|
+
exports.isOperatorAllowedForField = isOperatorAllowedForField;
|
|
180
190
|
//# sourceMappingURL=filterBuilder.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filterBuilder.cjs.js","sources":["../../src/helpers/filterBuilder.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n FieldFilter,\n FieldFilterOperatorEnum,\n Filter,\n IntrospectionField,\n LogicalFilter,\n TypeName,\n} from '@red-hat-developer-hub/backstage-plugin-orchestrator-common';\n\ntype ProcessType = 'ProcessDefinition' | 'ProcessInstance';\n\nfunction isLogicalFilter(filter: Filter): filter is LogicalFilter {\n return (filter as LogicalFilter).filters !== undefined;\n}\n\nfunction handleLogicalFilter(\n introspection: IntrospectionField[],\n type: ProcessType,\n filter: LogicalFilter,\n): string {\n if (!filter.operator) return '';\n\n const subClauses = filter.filters.map(f =>\n buildFilterCondition(introspection, type, f),\n );\n\n return `${filter.operator.toLowerCase()}: {${subClauses.join(', ')}}`;\n}\n\nfunction handleBetweenOperator(filter: FieldFilter): string {\n if (!Array.isArray(filter.value) || filter.value.length !== 2) {\n throw new Error('Between operator requires an array of two elements');\n }\n return `${filter.field}: {${getGraphQLOperator(\n FieldFilterOperatorEnum.Between,\n )}: {from: \"${filter.value[0]}\", to: \"${filter.value[1]}\"}}`;\n}\n\nfunction handleIsNullOperator(filter: FieldFilter): string {\n return `${filter.field}: {${getGraphQLOperator(\n FieldFilterOperatorEnum.IsNull,\n )}: ${convertToBoolean(filter.value)}}`;\n}\n\nfunction isEnumFilter(\n fieldName: string,\n type: 'ProcessDefinition' | 'ProcessInstance',\n): boolean {\n if (type === 'ProcessInstance') {\n if (fieldName === 'state') {\n return true;\n }\n }\n return false;\n}\n\nfunction isValidEnumOperator(operator: FieldFilterOperatorEnum): boolean {\n return (\n operator === FieldFilterOperatorEnum.In ||\n operator === FieldFilterOperatorEnum.Eq\n );\n}\n\nfunction handleBinaryOperator(\n binaryFilter: FieldFilter,\n fieldDef: IntrospectionField,\n type: 'ProcessDefinition' | 'ProcessInstance',\n): string {\n if (isEnumFilter(binaryFilter.field, type)) {\n if (!isValidEnumOperator(binaryFilter.operator)) {\n throw new Error(\n `Invalid operator ${binaryFilter.operator} for enum field ${binaryFilter.field} filter`,\n );\n }\n }\n const formattedValue = Array.isArray(binaryFilter.value)\n ? `[${binaryFilter.value\n .map(v => formatValue(binaryFilter.field, v, fieldDef, type))\n .join(', ')}]`\n : formatValue(binaryFilter.field, binaryFilter.value, fieldDef, type);\n return `${binaryFilter.field}: {${getGraphQLOperator(\n binaryFilter.operator,\n )}: ${formattedValue}}`;\n}\n\nexport function buildFilterCondition(\n introspection: IntrospectionField[],\n type: ProcessType,\n filters?: Filter,\n): string {\n if (!filters) {\n return '';\n }\n\n if (isLogicalFilter(filters)) {\n return handleLogicalFilter(introspection, type, filters);\n }\n\n if (!isOperatorSupported(filters.operator)) {\n throw new Error(`Unsopported operator ${filters.operator}`);\n }\n\n const fieldDef = introspection.find(f => f.name === filters.field);\n if (!fieldDef) {\n throw new Error(`Can't find field \"${filters.field}\" definition`);\n }\n\n if (!isOperatorAllowedForField(filters.operator, fieldDef, type)) {\n throw new Error(\n `Unsupported operator ${filters.operator} for field \"${fieldDef.name}\" of type \"${fieldDef.type.name}\"`,\n );\n }\n\n switch (filters.operator) {\n case FieldFilterOperatorEnum.IsNull:\n return handleIsNullOperator(filters);\n case FieldFilterOperatorEnum.Between:\n return handleBetweenOperator(filters);\n case FieldFilterOperatorEnum.Eq:\n case FieldFilterOperatorEnum.Like:\n case FieldFilterOperatorEnum.In:\n case FieldFilterOperatorEnum.Gt:\n case FieldFilterOperatorEnum.Gte:\n case FieldFilterOperatorEnum.Lt:\n case FieldFilterOperatorEnum.Lte:\n return handleBinaryOperator(filters, fieldDef, type);\n\n default:\n throw new Error(`Can't build filter condition`);\n }\n}\n\nfunction isOperatorSupported(operator: FieldFilterOperatorEnum): boolean {\n return (\n operator === FieldFilterOperatorEnum.Eq ||\n operator === FieldFilterOperatorEnum.Like ||\n operator === FieldFilterOperatorEnum.In ||\n operator === FieldFilterOperatorEnum.IsNull ||\n operator === FieldFilterOperatorEnum.Gt ||\n operator === FieldFilterOperatorEnum.Gte ||\n operator === FieldFilterOperatorEnum.Lt ||\n operator === FieldFilterOperatorEnum.Lte ||\n operator === FieldFilterOperatorEnum.Between\n );\n}\n\nfunction isFieldFilterSupported(fieldDef: IntrospectionField): boolean {\n return fieldDef?.type.name === TypeName.String;\n}\n\nfunction isOperatorAllowedForField(\n operator: FieldFilterOperatorEnum,\n fieldDef: IntrospectionField,\n type: ProcessType,\n): boolean {\n if (isEnumFilter(fieldDef.name, type) && isValidEnumOperator(operator)) {\n return true;\n }\n const allowedOperators: Record<TypeName, FieldFilterOperatorEnum[]> = {\n [TypeName.String]: [\n FieldFilterOperatorEnum.In,\n FieldFilterOperatorEnum.Like,\n FieldFilterOperatorEnum.IsNull,\n FieldFilterOperatorEnum.Eq,\n ],\n [TypeName.Id]: [\n FieldFilterOperatorEnum.In,\n FieldFilterOperatorEnum.IsNull,\n FieldFilterOperatorEnum.Eq,\n ],\n [TypeName.Date]: [\n FieldFilterOperatorEnum.IsNull,\n FieldFilterOperatorEnum.Eq,\n FieldFilterOperatorEnum.Gt,\n FieldFilterOperatorEnum.Gte,\n FieldFilterOperatorEnum.Lt,\n FieldFilterOperatorEnum.Lte,\n FieldFilterOperatorEnum.Between,\n ],\n [TypeName.StringArray]: [],\n };\n const allowedForType = allowedOperators[fieldDef.type.name];\n return allowedForType ? allowedForType.includes(operator) : false;\n}\n\nfunction convertToBoolean(value: any): boolean {\n if (typeof value === 'boolean') {\n return value;\n }\n if (typeof value === 'string') {\n return value.toLowerCase() === 'true';\n }\n if (typeof value === 'number') {\n return value === 1;\n }\n return false; // Default to false for unsupported types\n}\n\nfunction formatValue(\n fieldName: string,\n fieldValue: any,\n fieldDef: IntrospectionField,\n type: ProcessType,\n): string {\n if (!isFieldFilterSupported) {\n throw new Error(`Unsupported field type ${fieldDef.type.name}`);\n }\n\n if (isEnumFilter(fieldName, type)) {\n return `${fieldValue}`;\n }\n if (\n fieldDef.type.name === TypeName.String ||\n fieldDef.type.name === TypeName.Id ||\n fieldDef.type.name === TypeName.Date\n ) {\n return `\"${fieldValue}\"`;\n }\n throw new Error(\n `Failed to format value for ${fieldName} ${fieldValue} with type ${fieldDef.type.name}`,\n );\n}\n\nfunction getGraphQLOperator(operator: FieldFilterOperatorEnum): string {\n switch (operator) {\n case 'EQ':\n return 'equal';\n case 'LIKE':\n return 'like';\n case 'IN':\n return 'in';\n case 'IS_NULL':\n return 'isNull';\n case 'GT':\n return 'greaterThan';\n case 'GTE':\n return 'greaterThanEqual';\n case 'LT':\n return 'lessThan';\n case 'LTE':\n return 'lessThanEqual';\n // case 'CONTAINS':\n // return \"contains\"\n // case 'CONTAINS_ALL':\n // case 'CONTAINS_ANY':\n case 'BETWEEN':\n return 'between';\n default:\n throw new Error(`Operation \"${operator}\" not supported`);\n }\n}\n"],"names":["FieldFilterOperatorEnum","TypeName"],"mappings":";;;;AA0BA,SAAS,gBAAgB,MAAyC,EAAA;AAChE,EAAA,OAAQ,OAAyB,OAAY,KAAA,KAAA,CAAA,CAAA;AAC/C,CAAA;AAEA,SAAS,mBAAA,CACP,aACA,EAAA,IAAA,EACA,MACQ,EAAA;AACR,EAAI,IAAA,CAAC,MAAO,CAAA,QAAA,EAAiB,OAAA,EAAA,CAAA;AAE7B,EAAM,MAAA,UAAA,GAAa,OAAO,OAAQ,CAAA,GAAA;AAAA,IAAI,CACpC,CAAA,KAAA,oBAAA,CAAqB,aAAe,EAAA,IAAA,EAAM,CAAC,CAAA;AAAA,GAC7C,CAAA;AAEA,EAAO,OAAA,CAAA,EAAG,OAAO,QAAS,CAAA,WAAA,EAAa,CAAM,GAAA,EAAA,UAAA,CAAW,IAAK,CAAA,IAAI,CAAC,CAAA,CAAA,CAAA,CAAA;AACpE,CAAA;AAEA,SAAS,sBAAsB,MAA6B,EAAA;AAC1D,EAAI,IAAA,CAAC,MAAM,OAAQ,CAAA,MAAA,CAAO,KAAK,CAAK,IAAA,MAAA,CAAO,KAAM,CAAA,MAAA,KAAW,CAAG,EAAA;AAC7D,IAAM,MAAA,IAAI,MAAM,oDAAoD,CAAA,CAAA;AAAA,GACtE;AACA,EAAO,OAAA,CAAA,EAAG,MAAO,CAAA,KAAK,CAAM,GAAA,EAAA,kBAAA;AAAA,IAC1BA,yDAAwB,CAAA,OAAA;AAAA,GACzB,CAAa,UAAA,EAAA,MAAA,CAAO,KAAM,CAAA,CA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B,KAAK,IAAA;AACH,MAAO,OAAA,OAAA,CAAA;AAAA,IACT,KAAK,MAAA;AACH,MAAO,OAAA,MAAA,CAAA;AAAA,IACT,KAAK,IAAA;AACH,MAAO,OAAA,IAAA,CAAA;AAAA,IACT,KAAK,SAAA;AACH,MAAO,OAAA,QAAA,CAAA;AAAA,IACT,KAAK,IAAA;AACH,MAAO,OAAA,aAAA,CAAA;AAAA,IACT,KAAK,KAAA;AACH,MAAO,OAAA,kBAAA,CAAA;AAAA,IACT,KAAK,IAAA;AACH,MAAO,OAAA,UAAA,CAAA;AAAA,IACT,KAAK,KAAA;AACH,MAAO,OAAA,eAAA,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAKT,KAAK,SAAA;AACH,MAAO,OAAA,SAAA,CAAA;AAAA,IACT;AACE,MAAA,MAAM,IAAI,KAAA,CAAM,CAAc,WAAA,EAAA,QAAQ,CAAiB,eAAA,CAAA,CAAA,CAAA;AAAA,GAC3D;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"filterBuilder.cjs.js","sources":["../../src/helpers/filterBuilder.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n FieldFilter,\n FieldFilterOperatorEnum,\n Filter,\n IntrospectionField,\n LogicalFilter,\n TypeName,\n} from '@red-hat-developer-hub/backstage-plugin-orchestrator-common';\n\ntype ProcessType = 'ProcessDefinition' | 'ProcessInstance';\n\nconst supportedOperators = [\n FieldFilterOperatorEnum.Eq,\n FieldFilterOperatorEnum.Like,\n FieldFilterOperatorEnum.In,\n FieldFilterOperatorEnum.IsNull,\n FieldFilterOperatorEnum.Gt,\n FieldFilterOperatorEnum.Gte,\n FieldFilterOperatorEnum.Lt,\n FieldFilterOperatorEnum.Lte,\n FieldFilterOperatorEnum.Between,\n];\n\nconst supportedOperatorsByType: Record<TypeName, FieldFilterOperatorEnum[]> = {\n [TypeName.String]: [\n FieldFilterOperatorEnum.In,\n FieldFilterOperatorEnum.Like,\n FieldFilterOperatorEnum.IsNull,\n FieldFilterOperatorEnum.Eq,\n ],\n [TypeName.Id]: [\n FieldFilterOperatorEnum.In,\n FieldFilterOperatorEnum.IsNull,\n FieldFilterOperatorEnum.Eq,\n ],\n [TypeName.Date]: [\n FieldFilterOperatorEnum.IsNull,\n FieldFilterOperatorEnum.Eq,\n FieldFilterOperatorEnum.Gt,\n FieldFilterOperatorEnum.Gte,\n FieldFilterOperatorEnum.Lt,\n FieldFilterOperatorEnum.Lte,\n FieldFilterOperatorEnum.Between,\n ],\n};\n\nfunction isLogicalFilter(filter: Filter): filter is LogicalFilter {\n return (filter as LogicalFilter).filters !== undefined;\n}\n\nfunction handleLogicalFilter(\n introspection: IntrospectionField[],\n type: ProcessType,\n filter: LogicalFilter,\n): string {\n if (!filter.operator) return '';\n\n const subClauses = filter.filters.map(f =>\n buildFilterCondition(introspection, type, f),\n );\n\n return `${filter.operator.toLowerCase()}: {${subClauses.join(', ')}}`;\n}\n\nfunction handleBetweenOperator(filter: FieldFilter): string {\n if (!Array.isArray(filter.value) || filter.value.length !== 2) {\n throw new Error('Between operator requires an array of two elements');\n }\n return `${filter.field}: {${getGraphQLOperator(\n FieldFilterOperatorEnum.Between,\n )}: {from: \"${filter.value[0]}\", to: \"${filter.value[1]}\"}}`;\n}\n\nfunction handleIsNullOperator(filter: FieldFilter): string {\n return `${filter.field}: {${getGraphQLOperator(\n FieldFilterOperatorEnum.IsNull,\n )}: ${convertToBoolean(filter.value)}}`;\n}\n\nfunction isEnumFilter(\n fieldName: string,\n type: 'ProcessDefinition' | 'ProcessInstance',\n): boolean {\n if (type === 'ProcessInstance') {\n if (fieldName === 'state') {\n return true;\n }\n }\n return false;\n}\n\nfunction isValidEnumOperator(operator: FieldFilterOperatorEnum): boolean {\n return (\n operator === FieldFilterOperatorEnum.In ||\n operator === FieldFilterOperatorEnum.Eq\n );\n}\n\nfunction handleBinaryOperator(\n binaryFilter: FieldFilter,\n fieldDef: IntrospectionField,\n type: 'ProcessDefinition' | 'ProcessInstance',\n): string {\n if (isEnumFilter(binaryFilter.field, type)) {\n if (!isValidEnumOperator(binaryFilter.operator)) {\n throw new Error(\n `Invalid operator ${binaryFilter.operator} for enum field ${binaryFilter.field} filter`,\n );\n }\n }\n const formattedValue = Array.isArray(binaryFilter.value)\n ? `[${binaryFilter.value\n .map(v => formatValue(binaryFilter.field, v, fieldDef, type))\n .join(', ')}]`\n : formatValue(binaryFilter.field, binaryFilter.value, fieldDef, type);\n return `${binaryFilter.field}: {${getGraphQLOperator(\n binaryFilter.operator,\n )}: ${formattedValue}}`;\n}\n\nexport function buildFilterCondition(\n introspection: IntrospectionField[],\n type: ProcessType,\n filters?: Filter,\n): string {\n if (!filters) {\n return '';\n }\n\n if (isLogicalFilter(filters)) {\n return handleLogicalFilter(introspection, type, filters);\n }\n\n if (!isOperatorSupported(filters.operator)) {\n throw new Error(\n `Unsupported operator ${filters.operator}. Supported operators are: ${supportedOperators.join(', ')}`,\n );\n }\n\n const fieldDef = introspection.find(f => f.name === filters.field);\n if (!fieldDef) {\n throw new Error(`Can't find field \"${filters.field}\" definition`);\n }\n\n if (!isOperatorAllowedForField(filters.operator, fieldDef, type)) {\n const allowedOperators = supportedOperatorsByType[fieldDef.type.name] || [];\n throw new Error(\n `Unsupported operator ${filters.operator} for field \"${fieldDef.name}\" of type \"${fieldDef.type.name}\". Allowed operators are: ${allowedOperators.join(', ')}`,\n );\n }\n\n switch (filters.operator) {\n case FieldFilterOperatorEnum.IsNull:\n return handleIsNullOperator(filters);\n case FieldFilterOperatorEnum.Between:\n return handleBetweenOperator(filters);\n case FieldFilterOperatorEnum.Eq:\n case FieldFilterOperatorEnum.Like:\n case FieldFilterOperatorEnum.In:\n case FieldFilterOperatorEnum.Gt:\n case FieldFilterOperatorEnum.Gte:\n case FieldFilterOperatorEnum.Lt:\n case FieldFilterOperatorEnum.Lte:\n return handleBinaryOperator(filters, fieldDef, type);\n\n default:\n throw new Error(`Can't build filter condition`);\n }\n}\n\nfunction isOperatorSupported(operator: FieldFilterOperatorEnum): boolean {\n return supportedOperators.includes(operator);\n}\n\nfunction isFieldFilterSupported(fieldDef: IntrospectionField): boolean {\n return fieldDef?.type.name === TypeName.String;\n}\n\nexport function isOperatorAllowedForField(\n operator: FieldFilterOperatorEnum,\n fieldDef: IntrospectionField,\n type: ProcessType,\n): boolean {\n if (isEnumFilter(fieldDef.name, type) && isValidEnumOperator(operator)) {\n return true;\n }\n\n const allowedForType = supportedOperatorsByType[fieldDef.type.name];\n return allowedForType ? allowedForType.includes(operator) : false;\n}\n\nfunction convertToBoolean(value: any): boolean {\n if (typeof value === 'boolean') {\n return value;\n }\n if (typeof value === 'string') {\n return value.toLowerCase() === 'true';\n }\n if (typeof value === 'number') {\n return value === 1;\n }\n return false; // Default to false for unsupported types\n}\n\nfunction formatValue(\n fieldName: string,\n fieldValue: any,\n fieldDef: IntrospectionField,\n type: ProcessType,\n): string {\n if (!isFieldFilterSupported) {\n throw new Error(`Unsupported field type ${fieldDef.type.name}`);\n }\n\n if (isEnumFilter(fieldName, type)) {\n return `${fieldValue}`;\n }\n if (\n fieldDef.type.name === TypeName.String ||\n fieldDef.type.name === TypeName.Id ||\n fieldDef.type.name === TypeName.Date\n ) {\n return `\"${fieldValue}\"`;\n }\n throw new Error(\n `Failed to format value for ${fieldName} ${fieldValue} with type ${fieldDef.type.name}`,\n );\n}\n\nfunction getGraphQLOperator(operator: FieldFilterOperatorEnum): string {\n switch (operator) {\n case 'EQ':\n return 'equal';\n case 'LIKE':\n return 'like';\n case 'IN':\n return 'in';\n case 'IS_NULL':\n return 'isNull';\n case 'GT':\n return 'greaterThan';\n case 'GTE':\n return 'greaterThanEqual';\n case 'LT':\n return 'lessThan';\n case 'LTE':\n return 'lessThanEqual';\n case 'BETWEEN':\n return 'between';\n default:\n throw new Error(`Operation \"${operator}\" not supported`);\n }\n}\n"],"names":["FieldFilterOperatorEnum","TypeName"],"mappings":";;;;AA2BA,MAAM,kBAAqB,GAAA;AAAA,EACzBA,yDAAwB,CAAA,EAAA;AAAA,EACxBA,yDAAwB,CAAA,IAAA;AAAA,EACxBA,yDAAwB,CAAA,EAAA;AAAA,EACxBA,yDAAwB,CAAA,MAAA;AAAA,EACxBA,yDAAwB,CAAA,EAAA;AAAA,EACxBA,yDAAwB,CAAA,GAAA;AAAA,EACxBA,yDAAwB,CAAA,EAAA;AAAA,EACxBA,yDAAwB,CAAA,GAAA;AAAA,EACxBA,yDAAwB,CAAA;AAC1B,CAAA;AAEA,MAAM,wBAAwE,GAAA;AAAA,EAC5E,CAACC,0CAAS,CAAA,MAAM,GAAG;AAAA,IACjBD,yDAAwB,CAAA,EAAA;AAAA,IACxBA,yDAAwB,CAAA,IAAA;AAAA,IACxBA,yDAAwB,CAAA,MAAA;AAAA,IACxBA,yDAAwB,CAAA;AAAA,GAC1B;AAAA,EACA,CAACC,0CAAS,CAAA,EAAE,GAAG;AAAA,IACbD,yDAAwB,CAAA,EAAA;AAAA,IACxBA,yDAAwB,CAAA,MAAA;AAAA,IACxBA,yDAAwB,CAAA;AAAA,GAC1B;AAAA,EACA,CAACC,0CAAS,CAAA,IAAI,GAAG;AAAA,IACfD,yDAAwB,CAAA,MAAA;AAAA,IACxBA,yDAAwB,CAAA,EAAA;AAAA,IACxBA,yDAAwB,CAAA,EAAA;AAAA,IACxBA,yDAAwB,CAAA,GAAA;AAAA,IACxBA,yDAAwB,CAAA,EAAA;AAAA,IACxBA,yDAAwB,CAAA,GAAA;AAAA,IACxBA,yDAAwB,CAAA;AAAA;AAE5B,CAAA;AAEA,SAAS,gBAAgB,MAAyC,EAAA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M,IAAI,KAAA,CAAM,CAAc,WAAA,EAAA,QAAQ,CAAiB,eAAA,CAAA,CAAA;AAAA;AAE7D;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queryBuilder.cjs.js","sources":["../../src/helpers/queryBuilder.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { Pagination } from '../types/pagination';\n\nexport function buildGraphQlQuery(args: {\n type: 'ProcessDefinitions' | 'ProcessInstances' | 'Jobs';\n queryBody: string;\n whereClause?: string;\n pagination?: Pagination;\n}): string {\n let query = `{${args.type}`;\n\n const whereClause = buildWhereClause(args.whereClause);\n const paginationClause = buildPaginationClause(args.pagination);\n\n if (whereClause || paginationClause) {\n query += ' (';\n query += [whereClause, paginationClause].filter(Boolean).join(', ');\n query += ') ';\n }\n\n query += ` {${args.queryBody} } }`;\n\n return query.replace(/\\s+/g, ' ').trim();\n}\n\nfunction buildWhereClause(whereClause?: string): string {\n return whereClause ? `where: {${whereClause}}` : '';\n}\n\nfunction buildPaginationClause(pagination?: Pagination): string {\n if (!pagination) return '';\n\n const parts = [];\n\n if (pagination.sortField !== undefined) {\n parts.push(\n `orderBy: {${pagination.sortField}: ${\n pagination.order !== undefined ? pagination.order?.toUpperCase() : 'ASC'\n }}`,\n );\n }\n\n const paginationParts = [];\n if (pagination.limit !== undefined) {\n paginationParts.push(`limit: ${pagination.limit}`);\n }\n if (pagination.offset !== undefined) {\n paginationParts.push(`offset: ${pagination.offset}`);\n }\n if (paginationParts.length) {\n parts.push(`pagination: {${paginationParts.join(', ')}}`);\n }\n\n return parts.join(', ');\n}\n"],"names":[],"mappings":";;AAiBO,SAAS,kBAAkB,IAKvB,EAAA;AACT,EAAI,IAAA,KAAA,GAAQ,CAAI,CAAA,EAAA,IAAA,CAAK,IAAI,CAAA,CAAA
|
|
1
|
+
{"version":3,"file":"queryBuilder.cjs.js","sources":["../../src/helpers/queryBuilder.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { Pagination } from '../types/pagination';\n\nexport function buildGraphQlQuery(args: {\n type: 'ProcessDefinitions' | 'ProcessInstances' | 'Jobs';\n queryBody: string;\n whereClause?: string;\n pagination?: Pagination;\n}): string {\n let query = `{${args.type}`;\n\n const whereClause = buildWhereClause(args.whereClause);\n const paginationClause = buildPaginationClause(args.pagination);\n\n if (whereClause || paginationClause) {\n query += ' (';\n query += [whereClause, paginationClause].filter(Boolean).join(', ');\n query += ') ';\n }\n\n query += ` {${args.queryBody} } }`;\n\n return query.replace(/\\s+/g, ' ').trim();\n}\n\nfunction buildWhereClause(whereClause?: string): string {\n return whereClause ? `where: {${whereClause}}` : '';\n}\n\nfunction buildPaginationClause(pagination?: Pagination): string {\n if (!pagination) return '';\n\n const parts = [];\n\n if (pagination.sortField !== undefined) {\n parts.push(\n `orderBy: {${pagination.sortField}: ${\n pagination.order !== undefined ? pagination.order?.toUpperCase() : 'ASC'\n }}`,\n );\n }\n\n const paginationParts = [];\n if (pagination.limit !== undefined) {\n paginationParts.push(`limit: ${pagination.limit}`);\n }\n if (pagination.offset !== undefined) {\n paginationParts.push(`offset: ${pagination.offset}`);\n }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C;AACzB,EAAI,IAAA,UAAA,CAAW,UAAU,MAAW,EAAA;AAClC,IAAA,eAAA,CAAgB,IAAK,CAAA,CAAA,OAAA,EAAU,UAAW,CAAA,KAAK,CAAE,CAAA,CAAA;AAAA;AAEnD,EAAI,IAAA,UAAA,CAAW,WAAW,MAAW,EAAA;AACnC,IAAA,eAAA,CAAgB,IAAK,CAAA,CAAA,QAAA,EAAW,UAAW,CAAA,MAAM,CAAE,CAAA,CAAA;AAAA;AAErD,EAAA,IAAI,gBAAgB,MAAQ,EAAA;AAC1B,IAAA,KAAA,CAAM,KAAK,CAAgB,aAAA,EAAA,eAAA,CAAgB,IAAK,CAAA,IAAI,CAAC,CAAG,CAAA,CAAA,CAAA;AAAA;AAG1D,EAAO,OAAA,KAAA,CAAM,KAAK,IAAI,CAAA;AACxB;;;;"}
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["../src/plugin.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n coreServices,\n createBackendPlugin,\n} from '@backstage/backend-plugin-api';\nimport { catalogServiceRef } from '@backstage/plugin-catalog-node/alpha';\n\nimport { createRouter } from './routerWrapper';\n\n/**\n * @public\n * Orchestrator Backend Plugin\n */\nexport const orchestratorPlugin = createBackendPlugin({\n pluginId: 'orchestrator',\n register(env) {\n env.registerInit({\n deps: {\n logger: coreServices.logger,\n config: coreServices.rootConfig,\n discovery: coreServices.discovery,\n catalogApi: catalogServiceRef,\n urlReader: coreServices.urlReader,\n permissions: coreServices.permissions,\n scheduler: coreServices.scheduler,\n auth: coreServices.auth,\n httpAuth: coreServices.httpAuth,\n http: coreServices.httpRouter,\n },\n async init(props) {\n const { http } = props;\n const router = await createRouter(props);\n http.use(router);\n http.addAuthPolicy({\n path: '/health',\n allow: 'unauthenticated',\n });\n http.addAuthPolicy({\n path: '/static',\n allow: 'unauthenticated',\n });\n http.addAuthPolicy({\n path: '/docs',\n allow: 'unauthenticated',\n });\n },\n });\n },\n});\n"],"names":["createBackendPlugin","coreServices","catalogServiceRef","createRouter"],"mappings":";;;;;;AA2BO,MAAM,qBAAqBA,oCAAoB,CAAA;AAAA,EACpD,QAAU,EAAA,cAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,QAAQC,6BAAa,CAAA,MAAA;AAAA,QACrB,QAAQA,6BAAa,CAAA,UAAA;AAAA,QACrB,WAAWA,6BAAa,CAAA,SAAA;AAAA,QACxB,UAAY,EAAAC,uBAAA;AAAA,QACZ,WAAWD,6BAAa,CAAA,SAAA;AAAA,QACxB,aAAaA,6BAAa,CAAA,WAAA;AAAA,QAC1B,WAAWA,6BAAa,CAAA,SAAA;AAAA,QACxB,MAAMA,6BAAa,CAAA,IAAA;AAAA,QACnB,UAAUA,6BAAa,CAAA,QAAA;AAAA,QACvB,MAAMA,6BAAa,CAAA
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["../src/plugin.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n coreServices,\n createBackendPlugin,\n} from '@backstage/backend-plugin-api';\nimport { catalogServiceRef } from '@backstage/plugin-catalog-node/alpha';\n\nimport { createRouter } from './routerWrapper';\n\n/**\n * @public\n * Orchestrator Backend Plugin\n */\nexport const orchestratorPlugin = createBackendPlugin({\n pluginId: 'orchestrator',\n register(env) {\n env.registerInit({\n deps: {\n logger: coreServices.logger,\n config: coreServices.rootConfig,\n discovery: coreServices.discovery,\n catalogApi: catalogServiceRef,\n urlReader: coreServices.urlReader,\n permissions: coreServices.permissions,\n scheduler: coreServices.scheduler,\n auth: coreServices.auth,\n httpAuth: coreServices.httpAuth,\n http: coreServices.httpRouter,\n },\n async init(props) {\n const { http } = props;\n const router = await createRouter(props);\n http.use(router);\n http.addAuthPolicy({\n path: '/health',\n allow: 'unauthenticated',\n });\n http.addAuthPolicy({\n path: '/static',\n allow: 'unauthenticated',\n });\n http.addAuthPolicy({\n path: '/docs',\n allow: 'unauthenticated',\n });\n },\n });\n },\n});\n"],"names":["createBackendPlugin","coreServices","catalogServiceRef","createRouter"],"mappings":";;;;;;AA2BO,MAAM,qBAAqBA,oCAAoB,CAAA;AAAA,EACpD,QAAU,EAAA,cAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,QAAQC,6BAAa,CAAA,MAAA;AAAA,QACrB,QAAQA,6BAAa,CAAA,UAAA;AAAA,QACrB,WAAWA,6BAAa,CAAA,SAAA;AAAA,QACxB,UAAY,EAAAC,uBAAA;AAAA,QACZ,WAAWD,6BAAa,CAAA,SAAA;AAAA,QACxB,aAAaA,6BAAa,CAAA,WAAA;AAAA,QAC1B,WAAWA,6BAAa,CAAA,SAAA;AAAA,QACxB,MAAMA,6BAAa,CAAA,IAAA;AAAA,QACnB,UAAUA,6BAAa,CAAA,QAAA;AAAA,QACvB,MAAMA,6BAAa,CAAA;AAAA,OACrB;AAAA,MACA,MAAM,KAAK,KAAO,EAAA;AAChB,QAAM,MAAA,EAAE,MAAS,GAAA,KAAA;AACjB,QAAM,MAAA,MAAA,GAAS,MAAME,kBAAA,CAAa,KAAK,CAAA;AACvC,QAAA,IAAA,CAAK,IAAI,MAAM,CAAA;AACf,QAAA,IAAA,CAAK,aAAc,CAAA;AAAA,UACjB,IAAM,EAAA,SAAA;AAAA,UACN,KAAO,EAAA;AAAA,SACR,CAAA;AACD,QAAA,IAAA,CAAK,aAAc,CAAA;AAAA,UACjB,IAAM,EAAA,SAAA;AAAA,UACN,KAAO,EAAA;AAAA,SACR,CAAA;AACD,QAAA,IAAA,CAAK,aAAc,CAAA;AAAA,UACjB,IAAM,EAAA,OAAA;AAAA,UACN,KAAO,EAAA;AAAA,SACR,CAAA;AAAA;AACH,KACD,CAAA;AAAA;AAEL,CAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../../src/routerWrapper/index.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport type {\n AuthService,\n DiscoveryService,\n HttpAuthService,\n LoggerService,\n PermissionsService,\n SchedulerService,\n UrlReaderService,\n} from '@backstage/backend-plugin-api';\nimport type { CatalogApi } from '@backstage/catalog-client';\nimport type { Config } from '@backstage/config';\n\nimport express from 'express';\n\nimport { DevModeService } from '../service/DevModeService';\nimport { createBackendRouter } from '../service/router';\n\nexport interface RouterOptions {\n config: Config;\n logger: LoggerService;\n discovery: DiscoveryService;\n catalogApi: CatalogApi;\n urlReader: UrlReaderService;\n scheduler: SchedulerService;\n permissions: PermissionsService;\n httpAuth: HttpAuthService;\n auth: AuthService;\n}\n\nexport async function createRouter(\n args: RouterOptions,\n): Promise<express.Router> {\n const autoStartDevMode =\n args.config.getOptionalBoolean(\n 'orchestrator.sonataFlowService.autoStart',\n ) ?? false;\n\n if (autoStartDevMode) {\n const devModeService = new DevModeService(args.config, args.logger);\n\n const isSonataFlowUp = await devModeService.launchDevMode();\n\n if (!isSonataFlowUp) {\n args.logger.error('SonataFlow is not up. Check your configuration.');\n }\n }\n\n return await createBackendRouter({\n config: args.config,\n logger: args.logger,\n discovery: args.discovery,\n catalogApi: args.catalogApi,\n urlReader: args.urlReader,\n scheduler: args.scheduler,\n permissions: args.permissions,\n httpAuth: args.httpAuth,\n auth: args.auth,\n });\n}\n"],"names":["DevModeService","createBackendRouter"],"mappings":";;;;;AA4CA,eAAsB,aACpB,IACyB,EAAA;AACzB,EAAM,MAAA,gBAAA,GACJ,KAAK,MAAO,CAAA,kBAAA;AAAA,IACV
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../../src/routerWrapper/index.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport type {\n AuthService,\n DiscoveryService,\n HttpAuthService,\n LoggerService,\n PermissionsService,\n SchedulerService,\n UrlReaderService,\n} from '@backstage/backend-plugin-api';\nimport type { CatalogApi } from '@backstage/catalog-client';\nimport type { Config } from '@backstage/config';\n\nimport express from 'express';\n\nimport { DevModeService } from '../service/DevModeService';\nimport { createBackendRouter } from '../service/router';\n\nexport interface RouterOptions {\n config: Config;\n logger: LoggerService;\n discovery: DiscoveryService;\n catalogApi: CatalogApi;\n urlReader: UrlReaderService;\n scheduler: SchedulerService;\n permissions: PermissionsService;\n httpAuth: HttpAuthService;\n auth: AuthService;\n}\n\nexport async function createRouter(\n args: RouterOptions,\n): Promise<express.Router> {\n const autoStartDevMode =\n args.config.getOptionalBoolean(\n 'orchestrator.sonataFlowService.autoStart',\n ) ?? false;\n\n if (autoStartDevMode) {\n const devModeService = new DevModeService(args.config, args.logger);\n\n const isSonataFlowUp = await devModeService.launchDevMode();\n\n if (!isSonataFlowUp) {\n args.logger.error('SonataFlow is not up. Check your configuration.');\n }\n }\n\n return await createBackendRouter({\n config: args.config,\n logger: args.logger,\n discovery: args.discovery,\n catalogApi: args.catalogApi,\n urlReader: args.urlReader,\n scheduler: args.scheduler,\n permissions: args.permissions,\n httpAuth: args.httpAuth,\n auth: args.auth,\n });\n}\n"],"names":["DevModeService","createBackendRouter"],"mappings":";;;;;AA4CA,eAAsB,aACpB,IACyB,EAAA;AACzB,EAAM,MAAA,gBAAA,GACJ,KAAK,MAAO,CAAA,kBAAA;AAAA,IACV;AAAA,GACG,IAAA,KAAA;AAEP,EAAA,IAAI,gBAAkB,EAAA;AACpB,IAAA,MAAM,iBAAiB,IAAIA,6BAAA,CAAe,IAAK,CAAA,MAAA,EAAQ,KAAK,MAAM,CAAA;AAElE,IAAM,MAAA,cAAA,GAAiB,MAAM,cAAA,CAAe,aAAc,EAAA;AAE1D,IAAA,IAAI,CAAC,cAAgB,EAAA;AACnB,MAAK,IAAA,CAAA,MAAA,CAAO,MAAM,iDAAiD,CAAA;AAAA;AACrE;AAGF,EAAA,OAAO,MAAMC,0BAAoB,CAAA;AAAA,IAC/B,QAAQ,IAAK,CAAA,MAAA;AAAA,IACb,QAAQ,IAAK,CAAA,MAAA;AAAA,IACb,WAAW,IAAK,CAAA,SAAA;AAAA,IAChB,YAAY,IAAK,CAAA,UAAA;AAAA,IACjB,WAAW,IAAK,CAAA,SAAA;AAAA,IAChB,WAAW,IAAK,CAAA,SAAA;AAAA,IAChB,aAAa,IAAK,CAAA,WAAA;AAAA,IAClB,UAAU,IAAK,CAAA,QAAA;AAAA,IACf,MAAM,IAAK,CAAA;AAAA,GACZ,CAAA;AACH;;;;"}
|
|
@@ -62,10 +62,10 @@ class DataIndexService {
|
|
|
62
62
|
async inspectInputArgument(type) {
|
|
63
63
|
const result = await this.client.query(this.graphQLArgumentQuery(type), {});
|
|
64
64
|
this.logger.debug(`Introspection query result: ${JSON.stringify(result)}`);
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
this.handleGraphqlClientError(
|
|
66
|
+
"Error executing introspection query",
|
|
67
|
+
result
|
|
68
|
+
);
|
|
69
69
|
const pairs = [];
|
|
70
70
|
if (result?.data?.__type?.inputFields) {
|
|
71
71
|
for (const field of result.data.__type.inputFields) {
|
|
@@ -83,37 +83,13 @@ class DataIndexService {
|
|
|
83
83
|
}
|
|
84
84
|
return pairs;
|
|
85
85
|
}
|
|
86
|
-
async abortWorkflowInstance(instanceId) {
|
|
87
|
-
this.logger.info(`Aborting workflow instance ${instanceId}`);
|
|
88
|
-
const ProcessInstanceAbortMutationDocument = core.gql`
|
|
89
|
-
mutation ProcessInstanceAbortMutation($id: String) {
|
|
90
|
-
ProcessInstanceAbort(id: $id)
|
|
91
|
-
}
|
|
92
|
-
`;
|
|
93
|
-
const result = await this.client.mutation(
|
|
94
|
-
ProcessInstanceAbortMutationDocument,
|
|
95
|
-
{ id: instanceId }
|
|
96
|
-
);
|
|
97
|
-
this.logger.debug(
|
|
98
|
-
`Abort workflow instance result: ${JSON.stringify(result)}`
|
|
99
|
-
);
|
|
100
|
-
if (result.error) {
|
|
101
|
-
throw new Error(
|
|
102
|
-
`Error aborting workflow instance ${instanceId}: ${result.error}`
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
this.logger.debug(`Successfully aborted workflow instance ${instanceId}`);
|
|
106
|
-
}
|
|
107
86
|
async fetchWorkflowInfo(definitionId) {
|
|
108
87
|
const graphQlQuery = `{ ProcessDefinitions ( where: {id: {equal: "${definitionId}" } } ) { id, name, version, type, endpoint, serviceUrl, source } }`;
|
|
109
88
|
const result = await this.client.query(graphQlQuery, {});
|
|
110
89
|
this.logger.debug(
|
|
111
90
|
`Get workflow definition result: ${JSON.stringify(result)}`
|
|
112
91
|
);
|
|
113
|
-
|
|
114
|
-
this.logger.error(`Error fetching workflow definition ${result.error}`);
|
|
115
|
-
throw result.error;
|
|
116
|
-
}
|
|
92
|
+
this.handleGraphqlClientError("Error fetching workflow definition", result);
|
|
117
93
|
const processDefinitions = result.data.ProcessDefinitions;
|
|
118
94
|
if (processDefinitions.length === 0) {
|
|
119
95
|
this.logger.info(`No workflow definition found for ${definitionId}`);
|
|
@@ -127,10 +103,10 @@ class DataIndexService {
|
|
|
127
103
|
this.logger.debug(
|
|
128
104
|
`Get workflow service urls result: ${JSON.stringify(result)}`
|
|
129
105
|
);
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
106
|
+
this.handleGraphqlClientError(
|
|
107
|
+
"Error fetching workflow service urls",
|
|
108
|
+
result
|
|
109
|
+
);
|
|
134
110
|
const processDefinitions = result.data.ProcessDefinitions;
|
|
135
111
|
return processDefinitions.filter((definition) => definition.serviceUrl).map((definition) => ({ [definition.id]: definition.serviceUrl })).reduce((acc, curr) => ({ ...acc, ...curr }), {});
|
|
136
112
|
}
|
|
@@ -162,12 +138,10 @@ class DataIndexService {
|
|
|
162
138
|
this.logger.debug(
|
|
163
139
|
`Get workflow definitions result: ${JSON.stringify(result)}`
|
|
164
140
|
);
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
throw result.error;
|
|
170
|
-
}
|
|
141
|
+
this.handleGraphqlClientError(
|
|
142
|
+
"Error fetching data index swf results",
|
|
143
|
+
result
|
|
144
|
+
);
|
|
171
145
|
return result.data.ProcessDefinitions;
|
|
172
146
|
}
|
|
173
147
|
async fetchInstances(args) {
|
|
@@ -210,10 +184,7 @@ class DataIndexService {
|
|
|
210
184
|
this.logger.debug(
|
|
211
185
|
`Fetch process instances result: ${JSON.stringify(result)}`
|
|
212
186
|
);
|
|
213
|
-
|
|
214
|
-
this.logger.error(`Error when fetching instances: ${result.error}`);
|
|
215
|
-
throw result.error;
|
|
216
|
-
}
|
|
187
|
+
this.handleGraphqlClientError("Error when fetching instances", result);
|
|
217
188
|
const processInstancesSrc = result.data ? result.data.ProcessInstances : [];
|
|
218
189
|
const processInstances = await Promise.all(
|
|
219
190
|
processInstancesSrc.map(async (instance) => {
|
|
@@ -244,10 +215,10 @@ class DataIndexService {
|
|
|
244
215
|
this.logger.debug(
|
|
245
216
|
`Fetch workflow source result: ${JSON.stringify(result)}`
|
|
246
217
|
);
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
218
|
+
this.handleGraphqlClientError(
|
|
219
|
+
"Error when fetching workflow source",
|
|
220
|
+
result
|
|
221
|
+
);
|
|
251
222
|
const processDefinitions = result.data.ProcessDefinitions;
|
|
252
223
|
if (processDefinitions.length === 0) {
|
|
253
224
|
this.logger.info(`No workflow source found for ${definitionId}`);
|
|
@@ -261,12 +232,10 @@ class DataIndexService {
|
|
|
261
232
|
this.logger.debug(
|
|
262
233
|
`Fetch workflow instances result: ${JSON.stringify(result)}`
|
|
263
234
|
);
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
throw result.error;
|
|
269
|
-
}
|
|
235
|
+
this.handleGraphqlClientError(
|
|
236
|
+
"Error when fetching workflow instances",
|
|
237
|
+
result
|
|
238
|
+
);
|
|
270
239
|
return result.data.ProcessInstances;
|
|
271
240
|
}
|
|
272
241
|
async fetchInstanceVariables(instanceId) {
|
|
@@ -275,12 +244,10 @@ class DataIndexService {
|
|
|
275
244
|
this.logger.debug(
|
|
276
245
|
`Fetch process instance variables result: ${JSON.stringify(result)}`
|
|
277
246
|
);
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
throw result.error;
|
|
283
|
-
}
|
|
247
|
+
this.handleGraphqlClientError(
|
|
248
|
+
"Error when fetching process instance variables",
|
|
249
|
+
result
|
|
250
|
+
);
|
|
284
251
|
const processInstances = result.data.ProcessInstances;
|
|
285
252
|
if (processInstances.length === 0) {
|
|
286
253
|
return void 0;
|
|
@@ -293,12 +260,10 @@ class DataIndexService {
|
|
|
293
260
|
this.logger.debug(
|
|
294
261
|
`Fetch process id from instance result: ${JSON.stringify(result)}`
|
|
295
262
|
);
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
throw result.error;
|
|
301
|
-
}
|
|
263
|
+
this.handleGraphqlClientError(
|
|
264
|
+
"Error when fetching process id from instance",
|
|
265
|
+
result
|
|
266
|
+
);
|
|
302
267
|
const processInstances = result.data.ProcessInstances;
|
|
303
268
|
if (processInstances.length === 0) {
|
|
304
269
|
return void 0;
|
|
@@ -345,12 +310,10 @@ class DataIndexService {
|
|
|
345
310
|
this.logger.debug(
|
|
346
311
|
`Fetch process instance result: ${JSON.stringify(result)}`
|
|
347
312
|
);
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
throw result.error;
|
|
353
|
-
}
|
|
313
|
+
this.handleGraphqlClientError(
|
|
314
|
+
"Error when fetching process instances",
|
|
315
|
+
result
|
|
316
|
+
);
|
|
354
317
|
const processInstances = result.data.ProcessInstances;
|
|
355
318
|
if (processInstances.length === 0) {
|
|
356
319
|
return void 0;
|
|
@@ -371,6 +334,20 @@ class DataIndexService {
|
|
|
371
334
|
}
|
|
372
335
|
return instance;
|
|
373
336
|
}
|
|
337
|
+
handleGraphqlClientError(scenario, result) {
|
|
338
|
+
if (!result?.error) {
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
this.logger.error(`${scenario} ${result}`);
|
|
342
|
+
const networkError = result.error.networkError?.cause?.message;
|
|
343
|
+
if (networkError) {
|
|
344
|
+
const toThrow = new Error(`${result.error.message}. ${networkError}`);
|
|
345
|
+
toThrow.name = "Network Error";
|
|
346
|
+
throw toThrow;
|
|
347
|
+
} else {
|
|
348
|
+
throw result.error;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
374
351
|
}
|
|
375
352
|
|
|
376
353
|
exports.DataIndexService = DataIndexService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataIndexService.cjs.js","sources":["../../src/service/DataIndexService.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { LoggerService } from '@backstage/backend-plugin-api';\n\nimport { Client, fetchExchange, gql } from '@urql/core';\n\nimport {\n Filter,\n fromWorkflowSource,\n getWorkflowCategory,\n IntrospectionField,\n parseWorkflowVariables,\n ProcessInstance,\n WorkflowDefinition,\n WorkflowInfo,\n} from '@red-hat-developer-hub/backstage-plugin-orchestrator-common';\n\nimport { ErrorBuilder } from '../helpers/errorBuilder';\nimport { buildFilterCondition } from '../helpers/filterBuilder';\nimport { buildGraphQlQuery } from '../helpers/queryBuilder';\nimport { Pagination } from '../types/pagination';\nimport { FETCH_PROCESS_INSTANCES_SORT_FIELD } from './constants';\n\nexport class DataIndexService {\n private readonly client: Client;\n public processDefinitionArguments: IntrospectionField[] = [];\n public processInstanceArguments: IntrospectionField[] = [];\n\n public constructor(\n private readonly dataIndexUrl: string,\n private readonly logger: LoggerService,\n ) {\n if (!dataIndexUrl.length) {\n throw ErrorBuilder.GET_NO_DATA_INDEX_URL_ERR();\n }\n\n this.client = this.getNewGraphQLClient();\n }\n\n private getNewGraphQLClient(): Client {\n const diURL = `${this.dataIndexUrl}/graphql`;\n return new Client({\n url: diURL,\n exchanges: [fetchExchange],\n });\n }\n\n public async initInputProcessDefinitionArgs(): Promise<IntrospectionField[]> {\n if (this.processDefinitionArguments.length === 0) {\n this.processDefinitionArguments =\n await this.inspectInputArgument('ProcessDefinition');\n }\n return this.processDefinitionArguments; // For testing purposes\n }\n\n public graphQLArgumentQuery(type: string): string {\n return `query ${type}Argument {\n __type(name: \"${type}Argument\") {\n kind\n name\n inputFields {\n name\n type {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n }\n }\n }\n }\n }\n }\n }`;\n }\n\n public async inspectInputArgument(\n type: string,\n ): Promise<IntrospectionField[]> {\n const result = await this.client.query(this.graphQLArgumentQuery(type), {});\n\n this.logger.debug(`Introspection query result: ${JSON.stringify(result)}`);\n\n if (result?.error) {\n this.logger.error(`Error executing introspection query ${result.error}`);\n throw result.error;\n }\n\n const pairs: IntrospectionField[] = [];\n if (result?.data?.__type?.inputFields) {\n for (const field of result.data.__type.inputFields) {\n if (\n field.name !== 'and' &&\n field.name !== 'or' &&\n field.name !== 'not'\n ) {\n pairs.push({\n name: field.name,\n type: {\n name: field.type.name,\n kind: field.type.kind,\n ofType: field.type.ofType,\n },\n });\n }\n }\n }\n return pairs;\n }\n\n public async abortWorkflowInstance(instanceId: string): Promise<void> {\n this.logger.info(`Aborting workflow instance ${instanceId}`);\n const ProcessInstanceAbortMutationDocument = gql`\n mutation ProcessInstanceAbortMutation($id: String) {\n ProcessInstanceAbort(id: $id)\n }\n `;\n\n const result = await this.client.mutation(\n ProcessInstanceAbortMutationDocument,\n { id: instanceId },\n );\n\n this.logger.debug(\n `Abort workflow instance result: ${JSON.stringify(result)}`,\n );\n\n if (result.error) {\n throw new Error(\n `Error aborting workflow instance ${instanceId}: ${result.error}`,\n );\n }\n this.logger.debug(`Successfully aborted workflow instance ${instanceId}`);\n }\n\n public async fetchWorkflowInfo(\n definitionId: string,\n ): Promise<WorkflowInfo | undefined> {\n const graphQlQuery = `{ ProcessDefinitions ( where: {id: {equal: \"${definitionId}\" } } ) { id, name, version, type, endpoint, serviceUrl, source } }`;\n\n const result = await this.client.query(graphQlQuery, {});\n\n this.logger.debug(\n `Get workflow definition result: ${JSON.stringify(result)}`,\n );\n\n if (result.error) {\n this.logger.error(`Error fetching workflow definition ${result.error}`);\n throw result.error;\n }\n\n const processDefinitions = result.data.ProcessDefinitions as WorkflowInfo[];\n\n if (processDefinitions.length === 0) {\n this.logger.info(`No workflow definition found for ${definitionId}`);\n return undefined;\n }\n\n return processDefinitions[0];\n }\n\n public async fetchWorkflowServiceUrls(): Promise<Record<string, string>> {\n const graphQlQuery = `{ ProcessDefinitions { id, serviceUrl } }`;\n\n const result = await this.client.query(graphQlQuery, {});\n\n this.logger.debug(\n `Get workflow service urls result: ${JSON.stringify(result)}`,\n );\n\n if (result.error) {\n this.logger.error(`Error fetching workflow service urls ${result.error}`);\n throw result.error;\n }\n\n const processDefinitions = result.data.ProcessDefinitions as WorkflowInfo[];\n return processDefinitions\n .filter(definition => definition.serviceUrl)\n .map(definition => ({ [definition.id]: definition.serviceUrl! }))\n .reduce((acc, curr) => ({ ...acc, ...curr }), {});\n }\n\n public async fetchWorkflowInfos(args: {\n definitionIds?: string[];\n pagination?: Pagination;\n filter?: Filter;\n }): Promise<WorkflowInfo[]> {\n this.logger.info(`fetchWorkflowInfos() called: ${this.dataIndexUrl}`);\n const { definitionIds, pagination, filter } = args;\n\n const definitionIdsCondition =\n definitionIds !== undefined && definitionIds.length > 0\n ? `id: {in: ${JSON.stringify(definitionIds)}}`\n : undefined;\n\n const filterCondition = filter\n ? buildFilterCondition(\n await this.initInputProcessDefinitionArgs(),\n 'ProcessDefinition',\n filter,\n )\n : undefined;\n\n let whereClause: string | undefined;\n if (definitionIds && filter) {\n whereClause = `and: [{${definitionIdsCondition}}, {${filterCondition}}]`;\n } else if (definitionIdsCondition || filterCondition) {\n whereClause = definitionIdsCondition ?? filterCondition;\n } else {\n whereClause = undefined;\n }\n\n const graphQlQuery = buildGraphQlQuery({\n type: 'ProcessDefinitions',\n queryBody: 'id, name, version, type, endpoint, serviceUrl, source',\n whereClause,\n pagination,\n });\n this.logger.debug(`GraphQL query: ${graphQlQuery}`);\n const result = await this.client.query(graphQlQuery, {});\n this.logger.debug(\n `Get workflow definitions result: ${JSON.stringify(result)}`,\n );\n\n if (result.error) {\n this.logger.error(\n `Error fetching data index swf results ${result.error}`,\n );\n throw result.error;\n }\n\n return result.data.ProcessDefinitions;\n }\n\n public async fetchInstances(args: {\n definitionIds?: string[];\n pagination?: Pagination;\n filter?: Filter;\n }): Promise<ProcessInstance[]> {\n const { pagination, definitionIds, filter } = args;\n if (pagination) pagination.sortField ??= FETCH_PROCESS_INSTANCES_SORT_FIELD;\n\n const processIdNotNullCondition = 'processId: {isNull: false}';\n const definitionIdsCondition = definitionIds\n ? `processId: {in: ${JSON.stringify(definitionIds)}}`\n : undefined;\n const type = 'ProcessInstance';\n const filterCondition = filter\n ? buildFilterCondition(\n await this.inspectInputArgument(type),\n type,\n filter,\n )\n : '';\n\n let whereClause = '';\n const conditions = [];\n\n if (processIdNotNullCondition) {\n conditions.push(`{${processIdNotNullCondition}}`);\n }\n\n if (definitionIdsCondition) {\n conditions.push(`{${definitionIdsCondition}}`);\n }\n\n if (filter) {\n conditions.push(`{${filterCondition}}`);\n }\n\n if (conditions.length === 0) {\n whereClause = processIdNotNullCondition;\n } else if (conditions.length === 1) {\n whereClause = conditions[0].slice(1, -1); // Remove the outer braces\n } else if (conditions.length > 1) {\n whereClause = `and: [${conditions.join(', ')}]`;\n }\n\n const graphQlQuery = buildGraphQlQuery({\n type: 'ProcessInstances',\n queryBody:\n 'id, processName, processId, businessKey, state, start, end, nodes { id }, variables, parentProcessInstance {id, processName, businessKey}',\n whereClause,\n pagination,\n });\n\n this.logger.debug(`GraphQL query: ${graphQlQuery}`);\n\n const result = await this.client.query<{\n ProcessInstances: ProcessInstance[];\n }>(graphQlQuery, {});\n this.logger.debug(\n `Fetch process instances result: ${JSON.stringify(result)}`,\n );\n if (result.error) {\n this.logger.error(`Error when fetching instances: ${result.error}`);\n throw result.error;\n }\n const processInstancesSrc = result.data ? result.data.ProcessInstances : [];\n\n const processInstances = await Promise.all(\n processInstancesSrc.map(async instance => {\n return await this.getWorkflowDefinitionFromInstance(instance);\n }),\n );\n return processInstances;\n }\n\n private async getWorkflowDefinitionFromInstance(instance: ProcessInstance) {\n const workflowInfo = await this.fetchWorkflowInfo(instance.processId);\n if (!workflowInfo?.source) {\n throw new Error(\n `Workflow defintion is required to fetch instance ${instance.id}`,\n );\n }\n const workflowDefinitionSrc: WorkflowDefinition = fromWorkflowSource(\n workflowInfo.source,\n );\n if (workflowInfo) {\n instance.category = getWorkflowCategory(workflowDefinitionSrc);\n instance.description = workflowInfo.description;\n }\n return instance;\n }\n\n public async fetchWorkflowSource(\n definitionId: string,\n ): Promise<string | undefined> {\n const graphQlQuery = `{ ProcessDefinitions ( where: {id: {equal: \"${definitionId}\" } } ) { id, source } }`;\n\n const result = await this.client.query(graphQlQuery, {});\n\n this.logger.debug(\n `Fetch workflow source result: ${JSON.stringify(result)}`,\n );\n\n if (result.error) {\n this.logger.error(`Error when fetching workflow source: ${result.error}`);\n return undefined;\n }\n\n const processDefinitions = result.data.ProcessDefinitions as WorkflowInfo[];\n\n if (processDefinitions.length === 0) {\n this.logger.info(`No workflow source found for ${definitionId}`);\n return undefined;\n }\n\n return processDefinitions[0].source;\n }\n\n public async fetchInstancesByDefinitionId(args: {\n definitionId: string;\n limit: number;\n offset: number;\n }): Promise<ProcessInstance[]> {\n const graphQlQuery = `{ ProcessInstances(where: {processId: {equal: \"${args.definitionId}\" } }, orderBy: {start:DESC}, pagination: {limit: ${args.limit}, offset: ${args.offset}}) { id, processName, state, start, end } }`;\n\n const result = await this.client.query(graphQlQuery, {});\n\n this.logger.debug(\n `Fetch workflow instances result: ${JSON.stringify(result)}`,\n );\n\n if (result.error) {\n this.logger.error(\n `Error when fetching workflow instances: ${result.error}`,\n );\n throw result.error;\n }\n\n return result.data.ProcessInstances;\n }\n\n public async fetchInstanceVariables(\n instanceId: string,\n ): Promise<object | undefined> {\n const graphQlQuery = `{ ProcessInstances (where: { id: {equal: \"${instanceId}\" } } ) { variables } }`;\n\n const result = await this.client.query(graphQlQuery, {});\n\n this.logger.debug(\n `Fetch process instance variables result: ${JSON.stringify(result)}`,\n );\n\n if (result.error) {\n this.logger.error(\n `Error when fetching process instance variables: ${result.error}`,\n );\n throw result.error;\n }\n\n const processInstances = result.data.ProcessInstances as ProcessInstance[];\n\n if (processInstances.length === 0) {\n return undefined;\n }\n\n return parseWorkflowVariables(processInstances[0].variables as object);\n }\n\n public async fetchDefinitionIdByInstanceId(\n instanceId: string,\n ): Promise<string | undefined> {\n const graphQlQuery = `{ ProcessInstances (where: { id: {equal: \"${instanceId}\" } } ) { processId } }`;\n\n const result = await this.client.query(graphQlQuery, {});\n\n this.logger.debug(\n `Fetch process id from instance result: ${JSON.stringify(result)}`,\n );\n\n if (result.error) {\n this.logger.error(\n `Error when fetching process id from instance: ${result.error}`,\n );\n throw result.error;\n }\n\n const processInstances = result.data.ProcessInstances as ProcessInstance[];\n\n if (processInstances.length === 0) {\n return undefined;\n }\n\n return processInstances[0].processId;\n }\n\n public async fetchInstance(\n instanceId: string,\n ): Promise<ProcessInstance | undefined> {\n const FindProcessInstanceQuery = gql`\n query FindProcessInstanceQuery($instanceId: String!) {\n ProcessInstances(where: { id: { equal: $instanceId } }) {\n id\n processName\n processId\n serviceUrl\n businessKey\n state\n start\n end\n nodes {\n id\n nodeId\n definitionId\n type\n name\n enter\n exit\n }\n variables\n parentProcessInstance {\n id\n processName\n businessKey\n }\n error {\n nodeDefinitionId\n message\n }\n }\n }\n `;\n\n const result = await this.client.query(FindProcessInstanceQuery, {\n instanceId,\n });\n\n this.logger.debug(\n `Fetch process instance result: ${JSON.stringify(result)}`,\n );\n\n if (result.error) {\n this.logger.error(\n `Error when fetching process instances: ${result.error}`,\n );\n throw result.error;\n }\n\n const processInstances = result.data.ProcessInstances as ProcessInstance[];\n\n if (processInstances.length === 0) {\n return undefined;\n }\n\n const instance = processInstances[0];\n\n const workflowInfo = await this.fetchWorkflowInfo(instance.processId);\n if (!workflowInfo?.source) {\n throw new Error(\n `Workflow defintion is required to fetch instance ${instance.id}`,\n );\n }\n const workflowDefinitionSrc: WorkflowDefinition = fromWorkflowSource(\n workflowInfo.source,\n );\n if (workflowInfo) {\n instance.category = getWorkflowCategory(workflowDefinitionSrc);\n instance.description = workflowDefinitionSrc.description;\n }\n return instance;\n }\n}\n"],"names":["ErrorBuilder","Client","fetchExchange","gql","buildFilterCondition","buildGraphQlQuery","FETCH_PROCESS_INSTANCES_SORT_FIELD","fromWorkflowSource","getWorkflowCategory","parseWorkflowVariables"],"mappings":";;;;;;;;;AAoCO,MAAM,gBAAiB,CAAA;AAAA,EAKrB,WAAA,CACY,cACA,MACjB,EAAA;AAFiB,IAAA,IAAA,CAAA,YAAA,GAAA,YAAA,CAAA;AACA,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA,CAAA;AAEjB,IAAI,IAAA,CAAC,aAAa,MAAQ,EAAA;AACxB,MAAA,MAAMA,0BAAa,yBAA0B,EAAA,CAAA;AAAA,KAC/C;AAEA,IAAK,IAAA,CAAA,MAAA,GAAS,KAAK,mBAAoB,EAAA,CAAA;AAAA,GACzC;AAAA,EAbiB,MAAA,CAAA;AAAA,EACV,6BAAmD,EAAC,CAAA;AAAA,EACpD,2BAAiD,EAAC,CAAA;AAAA,EAajD,mBAA8B,GAAA;AACpC,IAAM,MAAA,KAAA,GAAQ,CAAG,EAAA,IAAA,CAAK,YAAY,CAAA,QAAA,CAAA,CAAA;AAClC,IAAA,OAAO,IAAIC,WAAO,CAAA;AAAA,MAChB,GAAK,EAAA,KAAA;AAAA,MACL,SAAA,EAAW,CAACC,kBAA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7D,MAAA,QAAA,CAAS,cAAc,qBAAsB,CAAA,WAAA,CAAA;AAAA,KAC/C;AACA,IAAO,OAAA,QAAA,CAAA;AAAA,GACT;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"DataIndexService.cjs.js","sources":["../../src/service/DataIndexService.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { LoggerService } from '@backstage/backend-plugin-api';\n\nimport { Client, fetchExchange, gql } from '@urql/core';\n\nimport {\n Filter,\n fromWorkflowSource,\n getWorkflowCategory,\n IntrospectionField,\n parseWorkflowVariables,\n ProcessInstance,\n WorkflowDefinition,\n WorkflowInfo,\n} from '@red-hat-developer-hub/backstage-plugin-orchestrator-common';\n\nimport { ErrorBuilder } from '../helpers/errorBuilder';\nimport { buildFilterCondition } from '../helpers/filterBuilder';\nimport { buildGraphQlQuery } from '../helpers/queryBuilder';\nimport { Pagination } from '../types/pagination';\nimport { FETCH_PROCESS_INSTANCES_SORT_FIELD } from './constants';\n\nexport class DataIndexService {\n private readonly client: Client;\n public processDefinitionArguments: IntrospectionField[] = [];\n public processInstanceArguments: IntrospectionField[] = [];\n\n public constructor(\n private readonly dataIndexUrl: string,\n private readonly logger: LoggerService,\n ) {\n if (!dataIndexUrl.length) {\n throw ErrorBuilder.GET_NO_DATA_INDEX_URL_ERR();\n }\n\n this.client = this.getNewGraphQLClient();\n }\n\n private getNewGraphQLClient(): Client {\n const diURL = `${this.dataIndexUrl}/graphql`;\n return new Client({\n url: diURL,\n exchanges: [fetchExchange],\n });\n }\n\n public async initInputProcessDefinitionArgs(): Promise<IntrospectionField[]> {\n if (this.processDefinitionArguments.length === 0) {\n this.processDefinitionArguments =\n await this.inspectInputArgument('ProcessDefinition');\n }\n return this.processDefinitionArguments; // For testing purposes\n }\n\n public graphQLArgumentQuery(type: string): string {\n return `query ${type}Argument {\n __type(name: \"${type}Argument\") {\n kind\n name\n inputFields {\n name\n type {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n }\n }\n }\n }\n }\n }\n }`;\n }\n\n public async inspectInputArgument(\n type: string,\n ): Promise<IntrospectionField[]> {\n const result = await this.client.query(this.graphQLArgumentQuery(type), {});\n\n this.logger.debug(`Introspection query result: ${JSON.stringify(result)}`);\n\n this.handleGraphqlClientError(\n 'Error executing introspection query',\n result,\n );\n\n const pairs: IntrospectionField[] = [];\n if (result?.data?.__type?.inputFields) {\n for (const field of result.data.__type.inputFields) {\n if (\n field.name !== 'and' &&\n field.name !== 'or' &&\n field.name !== 'not'\n ) {\n pairs.push({\n name: field.name,\n type: {\n name: field.type.name,\n kind: field.type.kind,\n ofType: field.type.ofType,\n },\n });\n }\n }\n }\n return pairs;\n }\n\n public async fetchWorkflowInfo(\n definitionId: string,\n ): Promise<WorkflowInfo | undefined> {\n const graphQlQuery = `{ ProcessDefinitions ( where: {id: {equal: \"${definitionId}\" } } ) { id, name, version, type, endpoint, serviceUrl, source } }`;\n\n const result = await this.client.query(graphQlQuery, {});\n\n this.logger.debug(\n `Get workflow definition result: ${JSON.stringify(result)}`,\n );\n\n this.handleGraphqlClientError('Error fetching workflow definition', result);\n\n const processDefinitions = result.data.ProcessDefinitions as WorkflowInfo[];\n\n if (processDefinitions.length === 0) {\n this.logger.info(`No workflow definition found for ${definitionId}`);\n return undefined;\n }\n\n return processDefinitions[0];\n }\n\n public async fetchWorkflowServiceUrls(): Promise<Record<string, string>> {\n const graphQlQuery = `{ ProcessDefinitions { id, serviceUrl } }`;\n\n const result = await this.client.query(graphQlQuery, {});\n\n this.logger.debug(\n `Get workflow service urls result: ${JSON.stringify(result)}`,\n );\n\n this.handleGraphqlClientError(\n 'Error fetching workflow service urls',\n result,\n );\n\n const processDefinitions = result.data.ProcessDefinitions as WorkflowInfo[];\n return processDefinitions\n .filter(definition => definition.serviceUrl)\n .map(definition => ({ [definition.id]: definition.serviceUrl! }))\n .reduce((acc, curr) => ({ ...acc, ...curr }), {});\n }\n\n public async fetchWorkflowInfos(args: {\n definitionIds?: string[];\n pagination?: Pagination;\n filter?: Filter;\n }): Promise<WorkflowInfo[]> {\n this.logger.info(`fetchWorkflowInfos() called: ${this.dataIndexUrl}`);\n const { definitionIds, pagination, filter } = args;\n\n const definitionIdsCondition =\n definitionIds !== undefined && definitionIds.length > 0\n ? `id: {in: ${JSON.stringify(definitionIds)}}`\n : undefined;\n\n const filterCondition = filter\n ? buildFilterCondition(\n await this.initInputProcessDefinitionArgs(),\n 'ProcessDefinition',\n filter,\n )\n : undefined;\n\n let whereClause: string | undefined;\n if (definitionIds && filter) {\n whereClause = `and: [{${definitionIdsCondition}}, {${filterCondition}}]`;\n } else if (definitionIdsCondition || filterCondition) {\n whereClause = definitionIdsCondition ?? filterCondition;\n } else {\n whereClause = undefined;\n }\n\n const graphQlQuery = buildGraphQlQuery({\n type: 'ProcessDefinitions',\n queryBody: 'id, name, version, type, endpoint, serviceUrl, source',\n whereClause,\n pagination,\n });\n this.logger.debug(`GraphQL query: ${graphQlQuery}`);\n const result = await this.client.query(graphQlQuery, {});\n this.logger.debug(\n `Get workflow definitions result: ${JSON.stringify(result)}`,\n );\n\n this.handleGraphqlClientError(\n 'Error fetching data index swf results',\n result,\n );\n\n return result.data.ProcessDefinitions;\n }\n\n public async fetchInstances(args: {\n definitionIds?: string[];\n pagination?: Pagination;\n filter?: Filter;\n }): Promise<ProcessInstance[]> {\n const { pagination, definitionIds, filter } = args;\n if (pagination) pagination.sortField ??= FETCH_PROCESS_INSTANCES_SORT_FIELD;\n\n const processIdNotNullCondition = 'processId: {isNull: false}';\n const definitionIdsCondition = definitionIds\n ? `processId: {in: ${JSON.stringify(definitionIds)}}`\n : undefined;\n const type = 'ProcessInstance';\n const filterCondition = filter\n ? buildFilterCondition(\n await this.inspectInputArgument(type),\n type,\n filter,\n )\n : '';\n\n let whereClause = '';\n const conditions = [];\n\n if (processIdNotNullCondition) {\n conditions.push(`{${processIdNotNullCondition}}`);\n }\n\n if (definitionIdsCondition) {\n conditions.push(`{${definitionIdsCondition}}`);\n }\n\n if (filter) {\n conditions.push(`{${filterCondition}}`);\n }\n\n if (conditions.length === 0) {\n whereClause = processIdNotNullCondition;\n } else if (conditions.length === 1) {\n whereClause = conditions[0].slice(1, -1); // Remove the outer braces\n } else if (conditions.length > 1) {\n whereClause = `and: [${conditions.join(', ')}]`;\n }\n\n const graphQlQuery = buildGraphQlQuery({\n type: 'ProcessInstances',\n queryBody:\n 'id, processName, processId, businessKey, state, start, end, nodes { id }, variables, parentProcessInstance {id, processName, businessKey}',\n whereClause,\n pagination,\n });\n\n this.logger.debug(`GraphQL query: ${graphQlQuery}`);\n\n const result = await this.client.query<{\n ProcessInstances: ProcessInstance[];\n }>(graphQlQuery, {});\n this.logger.debug(\n `Fetch process instances result: ${JSON.stringify(result)}`,\n );\n\n this.handleGraphqlClientError('Error when fetching instances', result);\n\n const processInstancesSrc = result.data ? result.data.ProcessInstances : [];\n\n const processInstances = await Promise.all(\n processInstancesSrc.map(async instance => {\n return await this.getWorkflowDefinitionFromInstance(instance);\n }),\n );\n return processInstances;\n }\n\n private async getWorkflowDefinitionFromInstance(instance: ProcessInstance) {\n const workflowInfo = await this.fetchWorkflowInfo(instance.processId);\n if (!workflowInfo?.source) {\n throw new Error(\n `Workflow defintion is required to fetch instance ${instance.id}`,\n );\n }\n const workflowDefinitionSrc: WorkflowDefinition = fromWorkflowSource(\n workflowInfo.source,\n );\n if (workflowInfo) {\n instance.category = getWorkflowCategory(workflowDefinitionSrc);\n instance.description = workflowInfo.description;\n }\n return instance;\n }\n\n public async fetchWorkflowSource(\n definitionId: string,\n ): Promise<string | undefined> {\n const graphQlQuery = `{ ProcessDefinitions ( where: {id: {equal: \"${definitionId}\" } } ) { id, source } }`;\n\n const result = await this.client.query(graphQlQuery, {});\n\n this.logger.debug(\n `Fetch workflow source result: ${JSON.stringify(result)}`,\n );\n\n this.handleGraphqlClientError(\n 'Error when fetching workflow source',\n result,\n );\n\n const processDefinitions = result.data.ProcessDefinitions as WorkflowInfo[];\n\n if (processDefinitions.length === 0) {\n this.logger.info(`No workflow source found for ${definitionId}`);\n return undefined;\n }\n\n return processDefinitions[0].source;\n }\n\n public async fetchInstancesByDefinitionId(args: {\n definitionId: string;\n limit: number;\n offset: number;\n }): Promise<ProcessInstance[]> {\n const graphQlQuery = `{ ProcessInstances(where: {processId: {equal: \"${args.definitionId}\" } }, orderBy: {start:DESC}, pagination: {limit: ${args.limit}, offset: ${args.offset}}) { id, processName, state, start, end } }`;\n\n const result = await this.client.query(graphQlQuery, {});\n\n this.logger.debug(\n `Fetch workflow instances result: ${JSON.stringify(result)}`,\n );\n\n this.handleGraphqlClientError(\n 'Error when fetching workflow instances',\n result,\n );\n\n return result.data.ProcessInstances;\n }\n\n public async fetchInstanceVariables(\n instanceId: string,\n ): Promise<object | undefined> {\n const graphQlQuery = `{ ProcessInstances (where: { id: {equal: \"${instanceId}\" } } ) { variables } }`;\n\n const result = await this.client.query(graphQlQuery, {});\n\n this.logger.debug(\n `Fetch process instance variables result: ${JSON.stringify(result)}`,\n );\n\n this.handleGraphqlClientError(\n 'Error when fetching process instance variables',\n result,\n );\n\n const processInstances = result.data.ProcessInstances as ProcessInstance[];\n\n if (processInstances.length === 0) {\n return undefined;\n }\n\n return parseWorkflowVariables(processInstances[0].variables as object);\n }\n\n public async fetchDefinitionIdByInstanceId(\n instanceId: string,\n ): Promise<string | undefined> {\n const graphQlQuery = `{ ProcessInstances (where: { id: {equal: \"${instanceId}\" } } ) { processId } }`;\n\n const result = await this.client.query(graphQlQuery, {});\n\n this.logger.debug(\n `Fetch process id from instance result: ${JSON.stringify(result)}`,\n );\n\n this.handleGraphqlClientError(\n 'Error when fetching process id from instance',\n result,\n );\n\n const processInstances = result.data.ProcessInstances as ProcessInstance[];\n\n if (processInstances.length === 0) {\n return undefined;\n }\n\n return processInstances[0].processId;\n }\n\n public async fetchInstance(\n instanceId: string,\n ): Promise<ProcessInstance | undefined> {\n const FindProcessInstanceQuery = gql`\n query FindProcessInstanceQuery($instanceId: String!) {\n ProcessInstances(where: { id: { equal: $instanceId } }) {\n id\n processName\n processId\n serviceUrl\n businessKey\n state\n start\n end\n nodes {\n id\n nodeId\n definitionId\n type\n name\n enter\n exit\n }\n variables\n parentProcessInstance {\n id\n processName\n businessKey\n }\n error {\n nodeDefinitionId\n message\n }\n }\n }\n `;\n\n const result = await this.client.query(FindProcessInstanceQuery, {\n instanceId,\n });\n\n this.logger.debug(\n `Fetch process instance result: ${JSON.stringify(result)}`,\n );\n\n this.handleGraphqlClientError(\n 'Error when fetching process instances',\n result,\n );\n\n const processInstances = result.data.ProcessInstances as ProcessInstance[];\n\n if (processInstances.length === 0) {\n return undefined;\n }\n\n const instance = processInstances[0];\n\n const workflowInfo = await this.fetchWorkflowInfo(instance.processId);\n if (!workflowInfo?.source) {\n throw new Error(\n `Workflow defintion is required to fetch instance ${instance.id}`,\n );\n }\n const workflowDefinitionSrc: WorkflowDefinition = fromWorkflowSource(\n workflowInfo.source,\n );\n if (workflowInfo) {\n instance.category = getWorkflowCategory(workflowDefinitionSrc);\n instance.description = workflowDefinitionSrc.description;\n }\n return instance;\n }\n\n private handleGraphqlClientError(scenario: string, result: any) {\n if (!result?.error) {\n return;\n }\n this.logger.error(`${scenario} ${result}`);\n const networkError = result.error.networkError?.cause?.message;\n if (networkError) {\n const toThrow = new Error(`${result.error.message}. ${networkError}`);\n toThrow.name = 'Network Error';\n throw toThrow;\n } else {\n throw result.error;\n }\n }\n}\n"],"names":["ErrorBuilder","Client","fetchExchange","buildFilterCondition","buildGraphQlQuery","FETCH_PROCESS_INSTANCES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