@xeplr/ui-jobs 1.6.2 → 1.6.4
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/package.json +2 -2
- package/src/api/jobs.js +14 -40
- package/src/lib/jobChainModel.js +5 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xeplr/ui-jobs",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.4",
|
|
4
4
|
"description": "The screens for @xeplr/jobs — schedule, run, pause and watch jobs — as routes a host app registers, or a standalone app",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.jsx",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@vitejs/plugin-react": "^5.2.0",
|
|
49
49
|
"@xeplr/ui-account": "^1.0.2",
|
|
50
|
-
"@xeplr/ui-utils": "^1.
|
|
50
|
+
"@xeplr/ui-utils": "^1.1.3",
|
|
51
51
|
"react": "^19.2.4",
|
|
52
52
|
"react-dom": "^19.2.4",
|
|
53
53
|
"react-router-dom": "^7.13.2",
|
package/src/api/jobs.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createOptionSources } from '@xeplr/ui-utils'
|
|
1
2
|
import { authFetch } from '@xeplr/ui-account'
|
|
2
3
|
|
|
3
4
|
// WHERE THE JOBS API LIVES, set once by the host at registration.
|
|
@@ -73,53 +74,26 @@ export async function listOccurrences(jobId) {
|
|
|
73
74
|
// Nothing configured for a kind → the field falls back to a plain text input.
|
|
74
75
|
// That is what keeps standalone jobs honest: an empty dropdown looks broken,
|
|
75
76
|
// while a text box is simply what you have when there is no catalogue.
|
|
76
|
-
|
|
77
|
+
// One copy, in @xeplr/ui-utils (createOptionSources), shared with X-Flow's
|
|
78
|
+
// step editor. These names stay, so nothing that imports them changes.
|
|
79
|
+
let _optionSources = createOptionSources({}, (p) => authFetch(url(p)))
|
|
77
80
|
|
|
78
81
|
export function configureOptionSources(sources) {
|
|
79
|
-
_optionSources = sources
|
|
82
|
+
_optionSources = createOptionSources(sources, (p) => authFetch(url(p)))
|
|
80
83
|
}
|
|
81
84
|
|
|
82
85
|
export function hasOptionSource(kind) {
|
|
83
|
-
return
|
|
86
|
+
return _optionSources.has(kind)
|
|
84
87
|
}
|
|
85
88
|
|
|
86
|
-
/**
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
* Fetch suggestions from an option source, asked with several values at once
|
|
95
|
-
* — `query` is { param: value }. Answers the list of values (strings), empty
|
|
96
|
-
* when the source is not configured or something it needs is not chosen yet.
|
|
97
|
-
*/
|
|
98
|
-
export async function fetchSuggestions(kind, query) {
|
|
99
|
-
const src = _optionSources[kind]
|
|
100
|
-
if (!src) return []
|
|
101
|
-
const pairs = Object.entries(query || {})
|
|
102
|
-
if (pairs.some(([, v]) => v === undefined || v === null || v === '')) return []
|
|
103
|
-
const q = pairs.map(([k, v]) => `&${encodeURIComponent(k)}=${encodeURIComponent(v)}`).join('')
|
|
104
|
-
const res = await authFetch(url(`${src.url}?limit=0${q}`))
|
|
105
|
-
const list = (res && res[src.key || 'dataArray']) || []
|
|
106
|
-
return list.map((o) => String(o[src.value || 'value'])).filter(Boolean)
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export async function fetchOptions(kind, filter) {
|
|
110
|
-
const src = _optionSources[kind]
|
|
111
|
-
if (!src) return []
|
|
112
|
-
const q = filter && filter.value ? `&${encodeURIComponent(filter.name)}=${encodeURIComponent(filter.value)}` : ''
|
|
113
|
-
const res = await authFetch(url(`${src.url}?limit=0${q}`))
|
|
114
|
-
// `dataArray` is what genericRoute returns, so it is the default — but a
|
|
115
|
-
// hand-written endpoint answers with whatever it likes (BI's
|
|
116
|
-
// /warehouse/tables says `tables`). The host names the key rather than this
|
|
117
|
-
// package guessing, because guessing wrong yields an empty dropdown and no
|
|
118
|
-
// error, which reads as "you have none of these".
|
|
119
|
-
const rows = res[src.key || 'dataArray'] || []
|
|
120
|
-
return rows
|
|
121
|
-
.filter((r) => (filter && filter.clientKey ? r[filter.clientKey] === filter.value : true))
|
|
122
|
-
.map((r) => ({ value: r[src.value || 'id'], label: r[src.label] || r[src.value || 'id'] }))
|
|
89
|
+
/** Suggestions from an option source, asked with several values at once. */
|
|
90
|
+
export function fetchSuggestions(kind, query) {
|
|
91
|
+
return _optionSources.fetchSuggestions(kind, query)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** One option list; `filter` narrows a dependent one. */
|
|
95
|
+
export function fetchOptions(kind, filter) {
|
|
96
|
+
return _optionSources.fetchOptions(kind, filter)
|
|
123
97
|
}
|
|
124
98
|
|
|
125
99
|
/**
|
package/src/lib/jobChainModel.js
CHANGED
|
@@ -246,11 +246,13 @@ export function workflowToRules(workflow) {
|
|
|
246
246
|
const arrows = Array.isArray(decide.transitions) ? decide.transitions : []
|
|
247
247
|
const rules = []
|
|
248
248
|
for (const a of arrows) {
|
|
249
|
-
|
|
249
|
+
// An arrow with no condition at all is "otherwise", however it was written.
|
|
250
|
+
const when = a.when !== undefined ? a.when : (a.condition == null ? null : undefined)
|
|
251
|
+
if (a.target === 'end_success' && !when) continue
|
|
250
252
|
const step = byKey[a.target]
|
|
251
|
-
if (!step ||
|
|
253
|
+
if (!step || when === undefined) return { editedElsewhere: true, rules: [] }
|
|
252
254
|
rules.push({
|
|
253
|
-
when: mapWhen(
|
|
255
|
+
when: mapWhen(when, fromTriggerField),
|
|
254
256
|
run: step.values.jobId,
|
|
255
257
|
inputs: mapBindings(step.values.inputs || {}, fromTriggerBindings),
|
|
256
258
|
carry: mapBindings(step.values.carry || {}, fromTriggerBindings)
|