@ruiapp/rapid-core 0.1.9 → 0.1.11

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.
@@ -12,7 +12,7 @@ export interface IRpdServer {
12
12
  registerActionHandler(plugin: RapidPlugin, options: IPluginActionHandler): void;
13
13
  getActionHandlerByCode(code: string): ActionHandler | undefined;
14
14
  getDataAccessor<T = any>(options: GetDataAccessorOptions): IRpdDataAccessor<T>;
15
- getEntityManager(singularCode: string): EntityManager;
15
+ getEntityManager<TEntity = any>(singularCode: string): EntityManager<TEntity>;
16
16
  getApplicationConfig(): RpdApplicationConfig;
17
17
  appendApplicationConfig(config: Partial<RpdApplicationConfig>): any;
18
18
  getModel(options: GetModelOptions): RpdDataModel | undefined;
package/dist/index.js CHANGED
@@ -3836,7 +3836,7 @@ async function handler$3(plugin, ctx, options) {
3836
3836
  };
3837
3837
  }
3838
3838
 
3839
- var getMyProfile$1 = /*#__PURE__*/Object.freeze({
3839
+ var getMyProfile$2 = /*#__PURE__*/Object.freeze({
3840
3840
  __proto__: null,
3841
3841
  code: code$3,
3842
3842
  handler: handler$3
@@ -3845,7 +3845,7 @@ var getMyProfile$1 = /*#__PURE__*/Object.freeze({
3845
3845
  var pluginActionHandlers = [
3846
3846
  createSession,
3847
3847
  deleteSession,
3848
- getMyProfile$1,
3848
+ getMyProfile$2,
3849
3849
  ];
3850
3850
 
3851
3851
  var AccessToken = {
@@ -3907,10 +3907,10 @@ var pluginModels = [
3907
3907
  AccessToken,
3908
3908
  ];
3909
3909
 
3910
- var getMyProfile = {
3910
+ var getMyProfile$1 = {
3911
3911
  namespace: "auth",
3912
3912
  name: "auth.getMyProfile",
3913
- code: "",
3913
+ code: "auth.getMyProfile",
3914
3914
  type: "RESTful",
3915
3915
  method: "GET",
3916
3916
  endpoint: "/me",
@@ -3921,10 +3921,10 @@ var getMyProfile = {
3921
3921
  ],
3922
3922
  };
3923
3923
 
3924
- var signin = {
3924
+ var signin$1 = {
3925
3925
  namespace: "auth",
3926
3926
  name: "auth.signin",
3927
- code: "",
3927
+ code: "auth.signin",
3928
3928
  type: "RESTful",
3929
3929
  method: "POST",
3930
3930
  endpoint: "/signin",
@@ -3935,10 +3935,10 @@ var signin = {
3935
3935
  ],
3936
3936
  };
3937
3937
 
3938
- var signout = {
3938
+ var signout$1 = {
3939
3939
  namespace: "auth",
3940
3940
  name: "auth.signout",
3941
- code: "",
3941
+ code: "auth.signout",
3942
3942
  type: "RESTful",
3943
3943
  method: "GET",
3944
3944
  endpoint: "/signout",
@@ -3949,10 +3949,10 @@ var signout = {
3949
3949
  ],
3950
3950
  };
3951
3951
 
3952
- var pluginRoutes = [
3953
- getMyProfile,
3954
- signin,
3955
- signout,
3952
+ var pluginRoutes$1 = [
3953
+ getMyProfile$1,
3954
+ signin$1,
3955
+ signout$1,
3956
3956
  ];
3957
3957
 
3958
3958
  /**
@@ -3997,7 +3997,7 @@ class AuthPlugin {
3997
3997
  async configureModelProperties(server, applicationConfig) {
3998
3998
  }
3999
3999
  async configureRoutes(server, applicationConfig) {
4000
- server.appendApplicationConfig({ routes: pluginRoutes });
4000
+ server.appendApplicationConfig({ routes: pluginRoutes$1 });
4001
4001
  }
4002
4002
  async onApplicationLoaded(server, applicationConfig) {
4003
4003
  console.log("authManager.onApplicationLoaded");
@@ -4021,7 +4021,8 @@ class AuthPlugin {
4021
4021
  token = request.cookies[server.config.sessionCookieName];
4022
4022
  }
4023
4023
  try {
4024
- const tokenPayload = verifyJwt(token, server.config.jwtKey);
4024
+ const secretKey = Buffer.from(server.config.jwtKey, "base64");
4025
+ const tokenPayload = verifyJwt(token, secretKey);
4025
4026
  routeContext.state.userId = tokenPayload.aud;
4026
4027
  routeContext.state.userLogin = tokenPayload.act;
4027
4028
  }
@@ -4140,6 +4141,54 @@ var uploadFileActionHandler = /*#__PURE__*/Object.freeze({
4140
4141
  handler: handler
4141
4142
  });
4142
4143
 
4144
+ var getMyProfile = {
4145
+ namespace: "ecm",
4146
+ name: "ecm.uploadFile",
4147
+ code: "ecm.uploadFile",
4148
+ type: "RESTful",
4149
+ method: "POST",
4150
+ endpoint: "/upload",
4151
+ actions: [
4152
+ {
4153
+ code: "uploadFile",
4154
+ },
4155
+ ],
4156
+ };
4157
+
4158
+ var signin = {
4159
+ namespace: "ecm",
4160
+ name: "ecm.downloadFile",
4161
+ code: "ecm.downloadFile",
4162
+ type: "RESTful",
4163
+ method: "GET",
4164
+ endpoint: "/download/file",
4165
+ actions: [
4166
+ {
4167
+ code: "downloadFile",
4168
+ },
4169
+ ],
4170
+ };
4171
+
4172
+ var signout = {
4173
+ namespace: "ecm",
4174
+ name: "ecm.downloadDocument",
4175
+ code: "ecm.downloadDocument",
4176
+ type: "RESTful",
4177
+ method: "GET",
4178
+ endpoint: "/download/document",
4179
+ actions: [
4180
+ {
4181
+ code: "downloadDocument",
4182
+ },
4183
+ ],
4184
+ };
4185
+
4186
+ var pluginRoutes = [
4187
+ getMyProfile,
4188
+ signin,
4189
+ signout,
4190
+ ];
4191
+
4143
4192
  /**
4144
4193
  * File manager plugin
4145
4194
  */
@@ -4181,6 +4230,7 @@ class FileManager {
4181
4230
  async configureModelProperties(server, applicationConfig) {
4182
4231
  }
4183
4232
  async configureRoutes(server, applicationConfig) {
4233
+ server.appendApplicationConfig({ routes: pluginRoutes });
4184
4234
  }
4185
4235
  async onApplicationLoaded(server, applicationConfig) {
4186
4236
  console.log("fileManager.onApplicationLoaded");
@@ -0,0 +1,12 @@
1
+ declare const _default: {
2
+ namespace: string;
3
+ name: string;
4
+ code: string;
5
+ type: "RESTful";
6
+ method: "GET";
7
+ endpoint: string;
8
+ actions: {
9
+ code: string;
10
+ }[];
11
+ };
12
+ export default _default;
@@ -0,0 +1,12 @@
1
+ declare const _default: {
2
+ namespace: string;
3
+ name: string;
4
+ code: string;
5
+ type: "RESTful";
6
+ method: "GET";
7
+ endpoint: string;
8
+ actions: {
9
+ code: string;
10
+ }[];
11
+ };
12
+ export default _default;
@@ -0,0 +1,22 @@
1
+ declare const _default: ({
2
+ namespace: string;
3
+ name: string;
4
+ code: string;
5
+ type: "RESTful";
6
+ method: "POST";
7
+ endpoint: string;
8
+ actions: {
9
+ code: string;
10
+ }[];
11
+ } | {
12
+ namespace: string;
13
+ name: string;
14
+ code: string;
15
+ type: "RESTful";
16
+ method: "GET";
17
+ endpoint: string;
18
+ actions: {
19
+ code: string;
20
+ }[];
21
+ })[];
22
+ export default _default;
@@ -0,0 +1,12 @@
1
+ declare const _default: {
2
+ namespace: string;
3
+ name: string;
4
+ code: string;
5
+ type: "RESTful";
6
+ method: "POST";
7
+ endpoint: string;
8
+ actions: {
9
+ code: string;
10
+ }[];
11
+ };
12
+ export default _default;
package/dist/server.d.ts CHANGED
@@ -23,7 +23,7 @@ export declare class RapidServer implements IRpdServer {
23
23
  registerMiddleware(middleware: any): void;
24
24
  getDataAccessor<T = any>(options: GetDataAccessorOptions): IRpdDataAccessor<T>;
25
25
  getModel(options: GetModelOptions): RpdDataModel | undefined;
26
- getEntityManager(singularCode: string): EntityManager;
26
+ getEntityManager<TEntity = any>(singularCode: string): EntityManager<TEntity>;
27
27
  registerEventHandler<K extends keyof RpdServerEventTypes>(eventName: K, listener: (...args: RpdServerEventTypes[K]) => void): this;
28
28
  emitEvent<K extends keyof RpdServerEventTypes>(eventName: K, sender: RapidPlugin, payload: RpdServerEventTypes[K][1]): Promise<void>;
29
29
  start(): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ruiapp/rapid-core",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "keywords": [],
@@ -97,7 +97,8 @@ class AuthPlugin implements RapidPlugin {
97
97
  }
98
98
 
99
99
  try {
100
- const tokenPayload = verifyJwt(token, server.config.jwtKey);
100
+ const secretKey = Buffer.from(server.config.jwtKey, "base64");
101
+ const tokenPayload = verifyJwt(token, secretKey);
101
102
  routeContext.state.userId = tokenPayload.aud as string;
102
103
  routeContext.state.userLogin = tokenPayload.act as string;
103
104
  } catch (err) {
@@ -3,7 +3,7 @@ import { RpdRoute } from "~/types";
3
3
  export default {
4
4
  namespace: "auth",
5
5
  name: "auth.getMyProfile",
6
- code: "",
6
+ code: "auth.getMyProfile",
7
7
  type: "RESTful",
8
8
  method: "GET",
9
9
  endpoint: "/me",
@@ -3,7 +3,7 @@ import { RpdRoute } from "~/types";
3
3
  export default {
4
4
  namespace: "auth",
5
5
  name: "auth.signin",
6
- code: "",
6
+ code: "auth.signin",
7
7
  type: "RESTful",
8
8
  method: "POST",
9
9
  endpoint: "/signin",
@@ -3,7 +3,7 @@ import { RpdRoute } from "~/types";
3
3
  export default {
4
4
  namespace: "auth",
5
5
  name: "auth.signout",
6
- code: "",
6
+ code: "auth.signout",
7
7
  type: "RESTful",
8
8
  method: "GET",
9
9
  endpoint: "/signout",
@@ -11,6 +11,7 @@ import * as downloadFileActionHandler from "./actionHandlers/downloadFile";
11
11
  import * as uploadFileActionHandler from "./actionHandlers/uploadFile";
12
12
  import { IRpdServer, RapidPlugin, RpdConfigurationItemOptions, RpdServerPluginConfigurableTargetOptions, RpdServerPluginExtendingAbilities } from "~/core/server";
13
13
 
14
+ import pluginRoutes from "./routes";
14
15
 
15
16
  class FileManager implements RapidPlugin {
16
17
  get code(): string {
@@ -64,6 +65,7 @@ class FileManager implements RapidPlugin {
64
65
  }
65
66
 
66
67
  async configureRoutes(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any> {
68
+ server.appendApplicationConfig({ routes: pluginRoutes });
67
69
  }
68
70
 
69
71
  async onApplicationLoaded(server: IRpdServer, applicationConfig: RpdApplicationConfig): Promise<any> {
@@ -0,0 +1,15 @@
1
+ import { RpdRoute } from "~/types";
2
+
3
+ export default {
4
+ namespace: "ecm",
5
+ name: "ecm.downloadDocument",
6
+ code: "ecm.downloadDocument",
7
+ type: "RESTful",
8
+ method: "GET",
9
+ endpoint: "/download/document",
10
+ actions: [
11
+ {
12
+ code: "downloadDocument",
13
+ },
14
+ ],
15
+ } satisfies RpdRoute;
@@ -0,0 +1,15 @@
1
+ import { RpdRoute } from "~/types";
2
+
3
+ export default {
4
+ namespace: "ecm",
5
+ name: "ecm.downloadFile",
6
+ code: "ecm.downloadFile",
7
+ type: "RESTful",
8
+ method: "GET",
9
+ endpoint: "/download/file",
10
+ actions: [
11
+ {
12
+ code: "downloadFile",
13
+ },
14
+ ],
15
+ } satisfies RpdRoute;
@@ -0,0 +1,9 @@
1
+ import getMyProfile from "./uploadFile";
2
+ import signin from "./downloadFile";
3
+ import signout from "./downloadDocument";
4
+
5
+ export default [
6
+ getMyProfile,
7
+ signin,
8
+ signout,
9
+ ]
@@ -0,0 +1,15 @@
1
+ import { RpdRoute } from "~/types";
2
+
3
+ export default {
4
+ namespace: "ecm",
5
+ name: "ecm.uploadFile",
6
+ code: "ecm.uploadFile",
7
+ type: "RESTful",
8
+ method: "POST",
9
+ endpoint: "/upload",
10
+ actions: [
11
+ {
12
+ code: "uploadFile",
13
+ },
14
+ ],
15
+ } satisfies RpdRoute;