@things-factory/scheduler-client 7.1.33 → 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.
@@ -1,6 +1,8 @@
1
1
  export * from './types';
2
+ export * from './schedule';
2
3
  export * from './schedules';
3
4
  export * from './register-schedule';
5
+ export * from './update-schedule';
4
6
  export * from './unregister-schedule';
5
7
  export * from './unregister-schedules';
6
8
  export * from './config';
@@ -2,8 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./types"), exports);
5
+ tslib_1.__exportStar(require("./schedule"), exports);
5
6
  tslib_1.__exportStar(require("./schedules"), exports);
6
7
  tslib_1.__exportStar(require("./register-schedule"), exports);
8
+ tslib_1.__exportStar(require("./update-schedule"), exports);
7
9
  tslib_1.__exportStar(require("./unregister-schedule"), exports);
8
10
  tslib_1.__exportStar(require("./unregister-schedules"), exports);
9
11
  tslib_1.__exportStar(require("./config"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/controllers/scheduler-api/index.ts"],"names":[],"mappings":";;;AAAA,kDAAuB;AACvB,sDAA2B;AAC3B,8DAAmC;AACnC,gEAAqC;AACrC,iEAAsC;AAEtC,mDAAwB","sourcesContent":["export * from './types'\nexport * from './schedules'\nexport * from './register-schedule'\nexport * from './unregister-schedule'\nexport * from './unregister-schedules'\n\nexport * from './config'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/controllers/scheduler-api/index.ts"],"names":[],"mappings":";;;AAAA,kDAAuB;AACvB,qDAA0B;AAC1B,sDAA2B;AAC3B,8DAAmC;AACnC,4DAAiC;AACjC,gEAAqC;AACrC,iEAAsC;AAEtC,mDAAwB","sourcesContent":["export * from './types'\nexport * from './schedule'\nexport * from './schedules'\nexport * from './register-schedule'\nexport * from './update-schedule'\nexport * from './unregister-schedule'\nexport * from './unregister-schedules'\n\nexport * from './config'\n"]}
@@ -0,0 +1 @@
1
+ export declare function getSchedule(id: string): Promise<any>;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSchedule = getSchedule;
4
+ const tslib_1 = require("tslib");
5
+ const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
6
+ const config_1 = require("./config");
7
+ async function getSchedule(id) {
8
+ const response = await (0, node_fetch_1.default)(`${config_1.SchedulerEndpoint}/schedules/${id}`, {
9
+ method: 'get',
10
+ headers: {
11
+ accept: 'application/json',
12
+ 'Content-Type': 'application/json'
13
+ }
14
+ });
15
+ if (!response.ok) {
16
+ throw new Error(`Failed to fetch schedule with id ${id}: ${response.statusText}`);
17
+ }
18
+ const schedules = await response.json();
19
+ return schedules && schedules[0];
20
+ }
21
+ //# sourceMappingURL=schedule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schedule.js","sourceRoot":"","sources":["../../../server/controllers/scheduler-api/schedule.ts"],"names":[],"mappings":";;AAGA,kCAeC;;AAlBD,oEAA8B;AAC9B,qCAA4C;AAErC,KAAK,UAAU,WAAW,CAAC,EAAU;IAC1C,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAK,EAAC,GAAG,0BAAiB,cAAc,EAAE,EAAE,EAAE;QACnE,MAAM,EAAE,KAAK;QACb,OAAO,EAAE;YACP,MAAM,EAAE,kBAAkB;YAC1B,cAAc,EAAE,kBAAkB;SACnC;KACF,CAAC,CAAA;IAEF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,oCAAoC,EAAE,KAAK,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAA;IACnF,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;IACvC,OAAO,SAAS,IAAI,SAAS,CAAC,CAAC,CAAC,CAAA;AAClC,CAAC","sourcesContent":["import fetch from 'node-fetch'\nimport { SchedulerEndpoint } from './config'\n\nexport async function getSchedule(id: string) {\n const response = await fetch(`${SchedulerEndpoint}/schedules/${id}`, {\n method: 'get',\n headers: {\n accept: 'application/json',\n 'Content-Type': 'application/json'\n }\n })\n\n if (!response.ok) {\n throw new Error(`Failed to fetch schedule with id ${id}: ${response.statusText}`)\n }\n\n const schedules = await response.json()\n return schedules && schedules[0]\n}\n"]}
@@ -1 +1,7 @@
1
- export declare function getSchedules(name: string, group: string, dlq: boolean): Promise<any>;
1
+ export declare function getSchedules(params: {
2
+ application?: string;
3
+ group?: string;
4
+ type?: string;
5
+ key?: string;
6
+ operation?: string;
7
+ }): Promise<any>;
@@ -4,16 +4,23 @@ exports.getSchedules = getSchedules;
4
4
  const tslib_1 = require("tslib");
5
5
  const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
6
6
  const config_1 = require("./config");
7
- async function getSchedules(name, group, dlq) {
8
- var body = JSON.stringify({ name, group, dlq });
9
- const response = await (0, node_fetch_1.default)(config_1.SchedulerEndpoint + '/schedules', {
10
- method: 'get',
7
+ async function getSchedules(params) {
8
+ const url = new URL('/schedules', config_1.SchedulerEndpoint);
9
+ const { application, group, type, key, operation } = params || {};
10
+ application && url.searchParams.append('application', application);
11
+ group && url.searchParams.append('group', group);
12
+ type && url.searchParams.append('type', type);
13
+ key && url.searchParams.append('key', key);
14
+ operation && url.searchParams.append('operation', operation);
15
+ const response = await (0, node_fetch_1.default)(url, {
16
+ method: 'GET',
11
17
  headers: {
12
- accept: 'application/json',
13
- 'Content-Type': 'application/json'
14
- },
15
- body
18
+ accept: 'application/json'
19
+ }
16
20
  });
21
+ if (!response.ok) {
22
+ throw new Error(`Failed to fetch schedules: ${response.statusText}`);
23
+ }
17
24
  return await response.json();
18
25
  }
19
26
  //# sourceMappingURL=schedules.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"schedules.js","sourceRoot":"","sources":["../../../server/controllers/scheduler-api/schedules.ts"],"names":[],"mappings":";;AAGA,oCAaC;;AAhBD,oEAA8B;AAC9B,qCAA4C;AAErC,KAAK,UAAU,YAAY,CAAC,IAAY,EAAE,KAAa,EAAE,GAAY;IAC1E,IAAI,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;IAE/C,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAK,EAAC,0BAAiB,GAAG,YAAY,EAAE;QAC7D,MAAM,EAAE,KAAK;QACb,OAAO,EAAE;YACP,MAAM,EAAE,kBAAkB;YAC1B,cAAc,EAAE,kBAAkB;SACnC;QACD,IAAI;KACL,CAAC,CAAA;IAEF,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;AAC9B,CAAC","sourcesContent":["import fetch from 'node-fetch'\nimport { SchedulerEndpoint } from './config'\n\nexport async function getSchedules(name: string, group: string, dlq: boolean) {\n var body = JSON.stringify({ name, group, dlq })\n\n const response = await fetch(SchedulerEndpoint + '/schedules', {\n method: 'get',\n headers: {\n accept: 'application/json',\n 'Content-Type': 'application/json'\n },\n body\n })\n\n return await response.json()\n}\n"]}
1
+ {"version":3,"file":"schedules.js","sourceRoot":"","sources":["../../../server/controllers/scheduler-api/schedules.ts"],"names":[],"mappings":";;AAGA,oCA4BC;;AA/BD,oEAA8B;AAC9B,qCAA4C;AAErC,KAAK,UAAU,YAAY,CAAC,MAMlC;IACC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,YAAY,EAAE,0BAAiB,CAAC,CAAA;IACpD,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,MAAM,IAAI,EAAE,CAAA;IAEjE,WAAW,IAAI,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,aAAa,EAAE,WAAW,CAAC,CAAA;IAClE,KAAK,IAAI,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IAChD,IAAI,IAAI,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IAC7C,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;IAC1C,SAAS,IAAI,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,WAAW,EAAE,SAAS,CAAC,CAAA;IAE5D,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAK,EAAC,GAAG,EAAE;QAChC,MAAM,EAAE,KAAK;QACb,OAAO,EAAE;YACP,MAAM,EAAE,kBAAkB;SAC3B;KACF,CAAC,CAAA;IAEF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,8BAA8B,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAA;IACtE,CAAC;IAED,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;AAC9B,CAAC","sourcesContent":["import fetch from 'node-fetch'\nimport { SchedulerEndpoint } from './config'\n\nexport async function getSchedules(params: {\n application?: string\n group?: string\n type?: string\n key?: string\n operation?: string\n}) {\n const url = new URL('/schedules', SchedulerEndpoint)\n const { application, group, type, key, operation } = params || {}\n\n application && url.searchParams.append('application', application)\n group && url.searchParams.append('group', group)\n type && url.searchParams.append('type', type)\n key && url.searchParams.append('key', key)\n operation && url.searchParams.append('operation', operation)\n\n const response = await fetch(url, {\n method: 'GET',\n headers: {\n accept: 'application/json'\n }\n })\n\n if (!response.ok) {\n throw new Error(`Failed to fetch schedules: ${response.statusText}`)\n }\n\n return await response.json()\n}\n"]}
@@ -22,3 +22,12 @@ export type ScheduleRegisterRequest = {
22
22
  timezone: string;
23
23
  task: ScheduleTask;
24
24
  };
25
+ export type ScheduleUpdateRequest = {
26
+ id: string;
27
+ name?: string;
28
+ client: ScheduleClient;
29
+ type: 'now' | 'date' | 'delay' | 'cron' | 'delay-recur';
30
+ schedule: string;
31
+ timezone: string;
32
+ task: ScheduleTask;
33
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../server/controllers/scheduler-api/types.ts"],"names":[],"mappings":"","sourcesContent":["export type ScheduleClient = {\n application: string\n group: string\n type?: string\n key?: string\n operation?: string\n}\n\nexport type ScheduleTask = {\n type: 'rest' | 'kafka' | 'redis'\n connection: any // callback endpoint\n data: any // callback context\n history_check?: boolean //\n failed_policy?: 'ignore' | 'retry' | 'retry_dlq'\n max_retry_count?: number // max_retries (default: -1 (unlimited),\n retry_period?: 60\n}\n\nexport type ScheduleRegisterRequest = {\n name?: string\n client: ScheduleClient\n type: 'now' | 'date' | 'delay' | 'cron' | 'delay-recur'\n schedule: string\n timezone: string\n task: ScheduleTask\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../server/controllers/scheduler-api/types.ts"],"names":[],"mappings":"","sourcesContent":["export type ScheduleClient = {\n application: string\n group: string\n type?: string\n key?: string\n operation?: string\n}\n\nexport type ScheduleTask = {\n type: 'rest' | 'kafka' | 'redis'\n connection: any // callback endpoint\n data: any // callback context\n history_check?: boolean //\n failed_policy?: 'ignore' | 'retry' | 'retry_dlq'\n max_retry_count?: number // max_retries (default: -1 (unlimited),\n retry_period?: 60\n}\n\nexport type ScheduleRegisterRequest = {\n name?: string\n client: ScheduleClient\n type: 'now' | 'date' | 'delay' | 'cron' | 'delay-recur'\n schedule: string\n timezone: string\n task: ScheduleTask\n}\n\nexport type ScheduleUpdateRequest = {\n id: string\n name?: string\n client: ScheduleClient\n type: 'now' | 'date' | 'delay' | 'cron' | 'delay-recur'\n schedule: string\n timezone: string\n task: ScheduleTask\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import { ScheduleUpdateRequest } from './types';
2
+ export declare function updateSchedule(schedule: ScheduleUpdateRequest): Promise<any>;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateSchedule = updateSchedule;
4
+ const tslib_1 = require("tslib");
5
+ const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
6
+ const config_1 = require("./config");
7
+ async function updateSchedule(schedule) {
8
+ var body = JSON.stringify(schedule);
9
+ try {
10
+ const response = await (0, node_fetch_1.default)(config_1.SchedulerEndpoint + `/schedules/${schedule === null || schedule === void 0 ? void 0 : schedule.id}/update`, {
11
+ method: 'POST',
12
+ headers: {
13
+ accept: 'application/json',
14
+ 'Content-Type': 'application/json'
15
+ },
16
+ body
17
+ });
18
+ const { id } = await response.json();
19
+ return id;
20
+ }
21
+ catch (err) {
22
+ console.error(err);
23
+ }
24
+ }
25
+ //# sourceMappingURL=update-schedule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-schedule.js","sourceRoot":"","sources":["../../../server/controllers/scheduler-api/update-schedule.ts"],"names":[],"mappings":";;AAKA,wCAmBC;;AAxBD,oEAA8B;AAE9B,qCAA4C;AAGrC,KAAK,UAAU,cAAc,CAAC,QAA+B;IAClE,IAAI,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAA;IAEnC,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAK,EAAC,0BAAiB,GAAG,cAAc,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,EAAE,SAAS,EAAE;YACpF,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,MAAM,EAAE,kBAAkB;gBAC1B,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI;SACL,CAAC,CAAA;QAEF,MAAM,EAAE,EAAE,EAAE,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;QAEpC,OAAO,EAAE,CAAA;IACX,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACpB,CAAC;AACH,CAAC","sourcesContent":["import fetch from 'node-fetch'\n\nimport { SchedulerEndpoint } from './config'\nimport { ScheduleUpdateRequest } from './types'\n\nexport async function updateSchedule(schedule: ScheduleUpdateRequest) {\n var body = JSON.stringify(schedule)\n\n try {\n const response = await fetch(SchedulerEndpoint + `/schedules/${schedule?.id}/update`, {\n method: 'POST',\n headers: {\n accept: 'application/json',\n 'Content-Type': 'application/json'\n },\n body\n })\n\n const { id } = await response.json()\n\n return id\n } catch (err) {\n console.error(err)\n }\n}\n"]}