@things-factory/scheduler-client 7.1.24 → 7.1.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/controllers/scheduler-api/index.d.ts +2 -0
- package/dist-server/controllers/scheduler-api/index.js +2 -0
- package/dist-server/controllers/scheduler-api/index.js.map +1 -1
- package/dist-server/controllers/scheduler-api/schedule.d.ts +1 -0
- package/dist-server/controllers/scheduler-api/schedule.js +21 -0
- package/dist-server/controllers/scheduler-api/schedule.js.map +1 -0
- package/dist-server/controllers/scheduler-api/schedules.d.ts +7 -1
- package/dist-server/controllers/scheduler-api/schedules.js +15 -8
- package/dist-server/controllers/scheduler-api/schedules.js.map +1 -1
- package/dist-server/controllers/scheduler-api/types.d.ts +9 -0
- package/dist-server/controllers/scheduler-api/types.js.map +1 -1
- package/dist-server/controllers/scheduler-api/update-schedule.d.ts +2 -0
- package/dist-server/controllers/scheduler-api/update-schedule.js +25 -0
- package/dist-server/controllers/scheduler-api/update-schedule.js.map +1 -0
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/server/controllers/scheduler-api/index.ts +2 -0
- package/server/controllers/scheduler-api/schedule.ts +19 -0
- package/server/controllers/scheduler-api/schedules.ts +23 -8
- package/server/controllers/scheduler-api/types.ts +10 -0
- package/server/controllers/scheduler-api/update-schedule.ts +25 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/scheduler-client",
|
|
3
|
-
"version": "7.1.
|
|
3
|
+
"version": "7.1.34",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "dist-client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@operato/graphql": "^7.0.0",
|
|
31
31
|
"@operato/shell": "^7.0.0",
|
|
32
|
-
"@things-factory/auth-base": "^7.1.
|
|
32
|
+
"@things-factory/auth-base": "^7.1.33",
|
|
33
33
|
"@things-factory/env": "^7.1.16",
|
|
34
34
|
"@things-factory/shell": "^7.1.24",
|
|
35
35
|
"node-fetch": "^2.6.0"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "22830c9e51c9fffb3c95d1d1f8cacc7706f7d2d1"
|
|
38
38
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import fetch from 'node-fetch'
|
|
2
|
+
import { SchedulerEndpoint } from './config'
|
|
3
|
+
|
|
4
|
+
export async function getSchedule(id: string) {
|
|
5
|
+
const response = await fetch(`${SchedulerEndpoint}/schedules/${id}`, {
|
|
6
|
+
method: 'get',
|
|
7
|
+
headers: {
|
|
8
|
+
accept: 'application/json',
|
|
9
|
+
'Content-Type': 'application/json'
|
|
10
|
+
}
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
if (!response.ok) {
|
|
14
|
+
throw new Error(`Failed to fetch schedule with id ${id}: ${response.statusText}`)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const schedules = await response.json()
|
|
18
|
+
return schedules && schedules[0]
|
|
19
|
+
}
|
|
@@ -1,17 +1,32 @@
|
|
|
1
1
|
import fetch from 'node-fetch'
|
|
2
2
|
import { SchedulerEndpoint } from './config'
|
|
3
3
|
|
|
4
|
-
export async function getSchedules(
|
|
5
|
-
|
|
4
|
+
export async function getSchedules(params: {
|
|
5
|
+
application?: string
|
|
6
|
+
group?: string
|
|
7
|
+
type?: string
|
|
8
|
+
key?: string
|
|
9
|
+
operation?: string
|
|
10
|
+
}) {
|
|
11
|
+
const url = new URL('/schedules', SchedulerEndpoint)
|
|
12
|
+
const { application, group, type, key, operation } = params || {}
|
|
6
13
|
|
|
7
|
-
|
|
8
|
-
|
|
14
|
+
application && url.searchParams.append('application', application)
|
|
15
|
+
group && url.searchParams.append('group', group)
|
|
16
|
+
type && url.searchParams.append('type', type)
|
|
17
|
+
key && url.searchParams.append('key', key)
|
|
18
|
+
operation && url.searchParams.append('operation', operation)
|
|
19
|
+
|
|
20
|
+
const response = await fetch(url, {
|
|
21
|
+
method: 'GET',
|
|
9
22
|
headers: {
|
|
10
|
-
accept: 'application/json'
|
|
11
|
-
|
|
12
|
-
},
|
|
13
|
-
body
|
|
23
|
+
accept: 'application/json'
|
|
24
|
+
}
|
|
14
25
|
})
|
|
15
26
|
|
|
27
|
+
if (!response.ok) {
|
|
28
|
+
throw new Error(`Failed to fetch schedules: ${response.statusText}`)
|
|
29
|
+
}
|
|
30
|
+
|
|
16
31
|
return await response.json()
|
|
17
32
|
}
|
|
@@ -24,3 +24,13 @@ export type ScheduleRegisterRequest = {
|
|
|
24
24
|
timezone: string
|
|
25
25
|
task: ScheduleTask
|
|
26
26
|
}
|
|
27
|
+
|
|
28
|
+
export type ScheduleUpdateRequest = {
|
|
29
|
+
id: string
|
|
30
|
+
name?: string
|
|
31
|
+
client: ScheduleClient
|
|
32
|
+
type: 'now' | 'date' | 'delay' | 'cron' | 'delay-recur'
|
|
33
|
+
schedule: string
|
|
34
|
+
timezone: string
|
|
35
|
+
task: ScheduleTask
|
|
36
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import fetch from 'node-fetch'
|
|
2
|
+
|
|
3
|
+
import { SchedulerEndpoint } from './config'
|
|
4
|
+
import { ScheduleUpdateRequest } from './types'
|
|
5
|
+
|
|
6
|
+
export async function updateSchedule(schedule: ScheduleUpdateRequest) {
|
|
7
|
+
var body = JSON.stringify(schedule)
|
|
8
|
+
|
|
9
|
+
try {
|
|
10
|
+
const response = await fetch(SchedulerEndpoint + `/schedules/${schedule?.id}/update`, {
|
|
11
|
+
method: 'POST',
|
|
12
|
+
headers: {
|
|
13
|
+
accept: 'application/json',
|
|
14
|
+
'Content-Type': 'application/json'
|
|
15
|
+
},
|
|
16
|
+
body
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
const { id } = await response.json()
|
|
20
|
+
|
|
21
|
+
return id
|
|
22
|
+
} catch (err) {
|
|
23
|
+
console.error(err)
|
|
24
|
+
}
|
|
25
|
+
}
|