@ruiapp/rapid-core 0.8.2 → 0.8.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/dist/index.d.ts CHANGED
@@ -7,6 +7,10 @@ export * from "./core/routeContext";
7
7
  export * from "./core/server";
8
8
  export * from "./core/http-types";
9
9
  export * from "./core/actionHandler";
10
+ export { default as DataAccessor } from "./dataAccess/dataAccessor";
11
+ export * from "./dataAccess/dataAccessor";
12
+ export { default as EntityManager } from "./dataAccess/entityManager";
13
+ export * from "./dataAccess/entityManager";
10
14
  export * from "./utilities/accessControlUtility";
11
15
  export * from "./utilities/entityUtility";
12
16
  export * from "./utilities/jwtUtility";
package/dist/index.js CHANGED
@@ -8562,8 +8562,7 @@ class CronJobPlugin {
8562
8562
  ...(job.jobOptions || {}),
8563
8563
  cronTime: job.cronTime,
8564
8564
  onTick: async () => {
8565
- server.getLogger().info(`Executing cron job '${job.code}'...`);
8566
- await this.executeJob(server, job);
8565
+ await this.tryExecuteJob(server, job);
8567
8566
  },
8568
8567
  });
8569
8568
  jobInstance.start();
@@ -8572,30 +8571,36 @@ class CronJobPlugin {
8572
8571
  getJobConfigurationByCode(code) {
8573
8572
  return lodash.find(this.#server.listCronJobs(), (job) => job.code === code);
8574
8573
  }
8575
- async executeJob(server, job) {
8574
+ async tryExecuteJob(server, job) {
8576
8575
  const logger = server.getLogger();
8576
+ logger.info(`Executing cron job '${job.code}'...`);
8577
8577
  try {
8578
- validateLicense(server);
8579
- let handlerContext = {
8580
- logger,
8581
- routerContext: RouteContext.newSystemOperationContext(server),
8582
- next: null,
8583
- server,
8584
- applicationConfig: null,
8585
- input: null,
8586
- };
8587
- if (job.actionHandlerCode) {
8588
- const actionHandler = server.getActionHandlerByCode(job.code);
8589
- await actionHandler(handlerContext, job.handleOptions);
8590
- }
8591
- else {
8592
- await job.handler(handlerContext, job.handleOptions);
8593
- }
8578
+ await this.executeJob(server, job);
8579
+ logger.info(`Completed cron job '${job.code}'...`);
8594
8580
  }
8595
8581
  catch (ex) {
8596
8582
  logger.error('Cron job "%s" execution error: %s', job.code, ex.message, { cronJobCode: job.code });
8597
8583
  }
8598
8584
  }
8585
+ async executeJob(server, job) {
8586
+ const logger = server.getLogger();
8587
+ validateLicense(server);
8588
+ let handlerContext = {
8589
+ logger,
8590
+ routerContext: RouteContext.newSystemOperationContext(server),
8591
+ next: null,
8592
+ server,
8593
+ applicationConfig: null,
8594
+ input: null,
8595
+ };
8596
+ if (job.actionHandlerCode) {
8597
+ const actionHandler = server.getActionHandlerByCode(job.code);
8598
+ await actionHandler(handlerContext, job.handleOptions);
8599
+ }
8600
+ else {
8601
+ await job.handler(handlerContext, job.handleOptions);
8602
+ }
8603
+ }
8599
8604
  }
8600
8605
 
8601
8606
  async function getStateMachineNextSnapshot(options) {
@@ -8986,8 +8991,10 @@ fixBigIntJSONSerialize();
8986
8991
  exports.AuthPlugin = AuthPlugin;
8987
8992
  exports.CacheFactory = CacheFactory;
8988
8993
  exports.CronJobPlugin = CronJobPlugin;
8994
+ exports.DataAccessor = DataAccessor;
8989
8995
  exports.DataManagePlugin = DataManager;
8990
8996
  exports.EntityAccessControlPlugin = EntityAccessControlPlugin;
8997
+ exports.EntityManager = EntityManager;
8991
8998
  exports.FileManagePlugin = FileManager;
8992
8999
  exports.GlobalRequest = GlobalRequest;
8993
9000
  exports.LicensePlugin = LicensePlugin;
@@ -22,6 +22,7 @@ declare class CronJobPlugin implements RapidPlugin {
22
22
  onApplicationLoaded(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
23
23
  onApplicationReady(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any>;
24
24
  getJobConfigurationByCode(code: string): CronJobConfiguration;
25
+ tryExecuteJob(server: IRpdServer, job: CronJobConfiguration): Promise<void>;
25
26
  executeJob(server: IRpdServer, job: CronJobConfiguration): Promise<void>;
26
27
  }
27
28
  export default CronJobPlugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ruiapp/rapid-core",
3
- "version": "0.8.2",
3
+ "version": "0.8.4",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -12,6 +12,12 @@ export * from "./core/server";
12
12
  export * from "./core/http-types";
13
13
  export * from "./core/actionHandler";
14
14
 
15
+ export { default as DataAccessor } from "./dataAccess/dataAccessor";
16
+ export * from "./dataAccess/dataAccessor";
17
+
18
+ export { default as EntityManager } from "./dataAccess/entityManager";
19
+ export * from "./dataAccess/entityManager";
20
+
15
21
  export * from "./utilities/accessControlUtility";
16
22
  export * from "./utilities/entityUtility";
17
23
  export * from "./utilities/jwtUtility";
@@ -77,8 +77,7 @@ class CronJobPlugin implements RapidPlugin {
77
77
  ...(job.jobOptions || {}),
78
78
  cronTime: job.cronTime,
79
79
  onTick: async () => {
80
- server.getLogger().info(`Executing cron job '${job.code}'...`);
81
- await this.executeJob(server, job);
80
+ await this.tryExecuteJob(server, job);
82
81
  },
83
82
  });
84
83
  jobInstance.start();
@@ -89,30 +88,38 @@ class CronJobPlugin implements RapidPlugin {
89
88
  return find(this.#server.listCronJobs(), (job) => job.code === code);
90
89
  }
91
90
 
92
- async executeJob(server: IRpdServer, job: CronJobConfiguration) {
91
+ async tryExecuteJob(server: IRpdServer, job: CronJobConfiguration) {
93
92
  const logger = server.getLogger();
93
+ logger.info(`Executing cron job '${job.code}'...`);
94
+
94
95
  try {
95
- validateLicense(server);
96
-
97
- let handlerContext: ActionHandlerContext = {
98
- logger,
99
- routerContext: RouteContext.newSystemOperationContext(server),
100
- next: null,
101
- server,
102
- applicationConfig: null,
103
- input: null,
104
- };
105
-
106
- if (job.actionHandlerCode) {
107
- const actionHandler = server.getActionHandlerByCode(job.code);
108
- await actionHandler(handlerContext, job.handleOptions);
109
- } else {
110
- await job.handler(handlerContext, job.handleOptions);
111
- }
112
- } catch (ex) {
96
+ await this.executeJob(server, job);
97
+ logger.info(`Completed cron job '${job.code}'...`);
98
+ } catch (ex: any) {
113
99
  logger.error('Cron job "%s" execution error: %s', job.code, ex.message, { cronJobCode: job.code });
114
100
  }
115
101
  }
102
+
103
+ async executeJob(server: IRpdServer, job: CronJobConfiguration) {
104
+ const logger = server.getLogger();
105
+ validateLicense(server);
106
+
107
+ let handlerContext: ActionHandlerContext = {
108
+ logger,
109
+ routerContext: RouteContext.newSystemOperationContext(server),
110
+ next: null,
111
+ server,
112
+ applicationConfig: null,
113
+ input: null,
114
+ };
115
+
116
+ if (job.actionHandlerCode) {
117
+ const actionHandler = server.getActionHandlerByCode(job.code);
118
+ await actionHandler(handlerContext, job.handleOptions);
119
+ } else {
120
+ await job.handler(handlerContext, job.handleOptions);
121
+ }
122
+ }
116
123
  }
117
124
 
118
125
  export default CronJobPlugin;