@things-factory/scheduler-client 8.0.0-beta.1 → 8.0.0-beta.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/scheduler-client",
3
- "version": "8.0.0-beta.1",
3
+ "version": "8.0.0-beta.2",
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": "^8.0.0-beta",
31
31
  "@operato/shell": "^8.0.0-beta",
32
- "@things-factory/auth-base": "^8.0.0-beta.1",
33
- "@things-factory/env": "^8.0.0-beta.1",
34
- "@things-factory/shell": "^8.0.0-beta.1",
32
+ "@things-factory/auth-base": "^8.0.0-beta.2",
33
+ "@things-factory/env": "^8.0.0-beta.2",
34
+ "@things-factory/shell": "^8.0.0-beta.2",
35
35
  "node-fetch": "^2.6.0"
36
36
  },
37
- "gitHead": "36c494e587640c1490318ef7b95adab02606e0c2"
37
+ "gitHead": "f03431a09435511b2595515658f9cb8f78ba4ebb"
38
38
  }
package/client/index.ts DELETED
File without changes
@@ -1,67 +0,0 @@
1
- /**
2
- * @license Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- import { css, html, LitElement, PropertyValues } from 'lit'
6
- import { customElement, property, query, state } from 'lit/decorators.js'
7
- import { asyncReplace } from 'lit/directives/async-replace.js'
8
-
9
- import { sleep } from '@operato/utils'
10
- import { i18next } from '@operato/i18n'
11
-
12
- const MIN = 60
13
- const HOUR = 60 * MIN
14
- const DAY = 24 * HOUR
15
-
16
- @customElement('ox-countdown-timer')
17
- export class OxInputScheduler extends LitElement {
18
- @property({ type: Number }) nextSchedule?: number
19
- @property({ type: String, attribute: 'resolution' }) resolution: 'minute' | 'second' = 'minute'
20
-
21
- @state() active: boolean = false
22
-
23
- render() {
24
- if (this.nextSchedule) {
25
- return html` <span>${asyncReplace(this.dueTimer(this.nextSchedule!))}</span> `
26
- } else {
27
- return html``
28
- }
29
- }
30
-
31
- connectedCallback(): void {
32
- this.active = !!this.nextSchedule
33
- }
34
-
35
- disconnectedCallback(): void {
36
- this.active = false
37
- }
38
-
39
- updated(changes: PropertyValues<this>) {
40
- if (changes.has('nextSchedule')) {
41
- this.active = !!this.nextSchedule
42
- }
43
- }
44
-
45
- async *dueTimer(exp: number) {
46
- while (exp && this.active) {
47
- var secs = Math.round((Number(exp) - Date.now()) / 1000)
48
- var positive = secs >= 0
49
-
50
- secs = Math.abs(secs)
51
- const days = Math.floor(secs / DAY)
52
- secs -= days * DAY
53
- const hours = Math.floor(secs / HOUR)
54
- secs -= hours * HOUR
55
- const minutes = Math.floor(secs / MIN)
56
- const seconds = secs - minutes * MIN
57
-
58
- yield `${positive ? '' : '('}${days ? `${days}${i18next.t('label.days')}` : ''}${
59
- hours ? ` ${hours}${i18next.t('label.hours')}` : ''
60
- }${minutes ? ` ${minutes}${i18next.t('label.minutes')}` : ''}${
61
- this.resolution == 'second' && seconds ? ` ${seconds}${i18next.t('label.seconds')}` : ''
62
- }${positive ? '' : ')'}`
63
-
64
- await sleep(this.resolution == 'second' ? 1000 : 60 * 1000)
65
- }
66
- }
67
- }
@@ -1,13 +0,0 @@
1
- {
2
- "extends": "../../tsconfig-base.json",
3
- "compilerOptions": {
4
- "experimentalDecorators": true,
5
- "skipLibCheck": true,
6
- "strict": true,
7
- "declaration": true,
8
- "module": "esnext",
9
- "outDir": "../dist-client",
10
- "baseUrl": "./"
11
- },
12
- "include": ["./**/*"]
13
- }
@@ -1 +0,0 @@
1
- export * from './scheduler-api'
@@ -1,11 +0,0 @@
1
- import { Domain } from '@things-factory/shell'
2
- import { config } from '@things-factory/env'
3
- const isPathBaseDomain = !config.get('subdomain') && !config.get('useVirtualHostBasedDomain')
4
-
5
- export const SchedulerEndpoint: string = config.get('scheduler/endpoint', 'http://127.0.0.1:9902')
6
- export const CallbackBase: string = config.get('scheduler/callbackBase', 'http://localhost:3000')
7
- export const Application: string = config.get('scheduler/application')
8
-
9
- export function getCallbackBaseWithDomainContext(domain: Domain) {
10
- return isPathBaseDomain ? CallbackBase + `/domain/${domain.subdomain}` : CallbackBase
11
- }
@@ -1,9 +0,0 @@
1
- export * from './types'
2
- export * from './schedule'
3
- export * from './schedules'
4
- export * from './register-schedule'
5
- export * from './update-schedule'
6
- export * from './unregister-schedule'
7
- export * from './unregister-schedules'
8
-
9
- export * from './config'
@@ -1,24 +0,0 @@
1
- import fetch from 'node-fetch'
2
-
3
- import { SchedulerEndpoint } from './config'
4
- import { ScheduleRegisterRequest } from './types'
5
-
6
- export async function registerSchedule(schedule: ScheduleRegisterRequest) {
7
- var body = JSON.stringify(schedule)
8
-
9
- try {
10
- const response = await fetch(SchedulerEndpoint + '/schedules', {
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
- return id
21
- } catch (err) {
22
- console.error(err)
23
- }
24
- }
@@ -1,19 +0,0 @@
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,32 +0,0 @@
1
- import fetch from 'node-fetch'
2
- import { SchedulerEndpoint } from './config'
3
-
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 || {}
13
-
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',
22
- headers: {
23
- accept: 'application/json'
24
- }
25
- })
26
-
27
- if (!response.ok) {
28
- throw new Error(`Failed to fetch schedules: ${response.statusText}`)
29
- }
30
-
31
- return await response.json()
32
- }
@@ -1,36 +0,0 @@
1
- export type ScheduleClient = {
2
- application: string
3
- group: string
4
- type?: string
5
- key?: string
6
- operation?: string
7
- }
8
-
9
- export type ScheduleTask = {
10
- type: 'rest' | 'kafka' | 'redis'
11
- connection: any // callback endpoint
12
- data: any // callback context
13
- history_check?: boolean //
14
- failed_policy?: 'ignore' | 'retry' | 'retry_dlq'
15
- max_retry_count?: number // max_retries (default: -1 (unlimited),
16
- retry_period?: 60
17
- }
18
-
19
- export type ScheduleRegisterRequest = {
20
- name?: string
21
- client: ScheduleClient
22
- type: 'now' | 'date' | 'delay' | 'cron' | 'delay-recur'
23
- schedule: string
24
- timezone: string
25
- task: ScheduleTask
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
- }
@@ -1,14 +0,0 @@
1
- import fetch from 'node-fetch'
2
- import { SchedulerEndpoint } from './config'
3
-
4
- export async function unregisterSchedule(handle: string) {
5
- const response = await fetch(SchedulerEndpoint + '/schedules/' + handle, {
6
- method: 'delete',
7
- headers: {
8
- accept: 'application/json',
9
- 'Content-Type': 'application/json'
10
- }
11
- })
12
-
13
- return await response.json()
14
- }
@@ -1,25 +0,0 @@
1
- import fetch from 'node-fetch'
2
-
3
- import { SchedulerEndpoint } from './config'
4
- import { ScheduleClient } from './types'
5
-
6
- export async function unregisterSchedules(client: ScheduleClient) {
7
- const response = await fetch(
8
- SchedulerEndpoint +
9
- '/schedules?' +
10
- new URLSearchParams({
11
- operation: client?.operation || '',
12
- application: client?.application || '',
13
- group: client?.group || '',
14
- key: client?.key || ''
15
- }),
16
- {
17
- method: 'delete',
18
- headers: {
19
- accept: 'application/json'
20
- }
21
- }
22
- )
23
-
24
- return await response.json()
25
- }
@@ -1,25 +0,0 @@
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
- }
package/server/index.ts DELETED
@@ -1 +0,0 @@
1
- export * from './controllers'
@@ -1,10 +0,0 @@
1
- {
2
- "extends": "../../tsconfig-base.json",
3
- "compilerOptions": {
4
- "strict": false,
5
- "module": "commonjs",
6
- "outDir": "../dist-server",
7
- "baseUrl": "./"
8
- },
9
- "include": ["./**/*"]
10
- }