@ruiapp/rapid-core 0.1.69 → 0.1.70

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.js CHANGED
@@ -6244,12 +6244,14 @@ class SettingService {
6244
6244
  ],
6245
6245
  });
6246
6246
  if (settingItem) {
6247
- await this.#systemSettingItemManager.updateEntityById({
6248
- id: settingItem.id,
6249
- entityToSave: {
6250
- value,
6251
- },
6252
- });
6247
+ if (settingItem.value !== value) {
6248
+ await this.#systemSettingItemManager.updateEntityById({
6249
+ id: settingItem.id,
6250
+ entityToSave: {
6251
+ value,
6252
+ },
6253
+ });
6254
+ }
6253
6255
  }
6254
6256
  else {
6255
6257
  await this.#systemSettingItemManager.createEntity({
@@ -3,6 +3,10 @@ import { SystemSettingItem, UserSettingItem } from "./SettingPluginTypes";
3
3
  export interface GetSystemSettingValuesInput {
4
4
  groupCode: string;
5
5
  }
6
+ export interface SetSystemSettingValuesInput {
7
+ groupCode: string;
8
+ values: Record<string, any>;
9
+ }
6
10
  export interface GetUserSettingValuesInput {
7
11
  groupCode: string;
8
12
  }
@@ -0,0 +1,7 @@
1
+ import { ActionHandlerContext } from "../../../core/actionHandler";
2
+ import { RapidPlugin } from "../../../core/server";
3
+ export interface SetSystemSettingValuesOptions {
4
+ groupCode: string;
5
+ }
6
+ export declare const code = "setSystemSettingValues";
7
+ export declare function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: SetSystemSettingValuesOptions): Promise<void>;
@@ -3,7 +3,7 @@ declare const _default: {
3
3
  name: string;
4
4
  code: string;
5
5
  type: "RESTful";
6
- method: "POST";
6
+ method: "GET";
7
7
  endpoint: string;
8
8
  actions: {
9
9
  code: string;
@@ -0,0 +1,12 @@
1
+ declare const _default: {
2
+ namespace: string;
3
+ name: string;
4
+ code: string;
5
+ type: "RESTful";
6
+ method: "PATCH";
7
+ endpoint: string;
8
+ actions: {
9
+ code: string;
10
+ }[];
11
+ };
12
+ export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ruiapp/rapid-core",
3
- "version": "0.1.69",
3
+ "version": "0.1.70",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -6,6 +6,11 @@ export interface GetSystemSettingValuesInput {
6
6
  groupCode: string;
7
7
  }
8
8
 
9
+ export interface SetSystemSettingValuesInput {
10
+ groupCode: string;
11
+ values: Record<string, any>;
12
+ }
13
+
9
14
  export interface GetUserSettingValuesInput {
10
15
  groupCode: string;
11
16
  }
@@ -80,12 +85,14 @@ export default class SettingService {
80
85
  });
81
86
 
82
87
  if (settingItem) {
83
- await this.#systemSettingItemManager.updateEntityById({
84
- id: settingItem.id,
85
- entityToSave: {
86
- value,
87
- },
88
- });
88
+ if (settingItem.value !== value) {
89
+ await this.#systemSettingItemManager.updateEntityById({
90
+ id: settingItem.id,
91
+ entityToSave: {
92
+ value,
93
+ },
94
+ });
95
+ }
89
96
  } else {
90
97
  await this.#systemSettingItemManager.createEntity({
91
98
  entity: {
@@ -0,0 +1,30 @@
1
+ import { ActionHandlerContext } from "~/core/actionHandler";
2
+ import { RapidPlugin } from "~/core/server";
3
+ import SettingService, { SetSystemSettingValuesInput } from "../SettingService";
4
+
5
+ export interface SetSystemSettingValuesOptions {
6
+ groupCode: string;
7
+ }
8
+
9
+ export const code = "setSystemSettingValues";
10
+
11
+ export async function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: SetSystemSettingValuesOptions) {
12
+ const { server, routerContext } = ctx;
13
+ const { response } = routerContext;
14
+
15
+ const input: SetSystemSettingValuesInput = ctx.input;
16
+
17
+ if (options?.groupCode) {
18
+ input.groupCode = options.groupCode;
19
+ }
20
+
21
+ if (!input.groupCode) {
22
+ throw new Error(`Group code is required when setting system setting values.`);
23
+ }
24
+
25
+ const settingService = server.getService<SettingService>("settingService");
26
+
27
+ await settingService.setSystemSettingValues(input.groupCode, input.values);
28
+
29
+ ctx.output = {};
30
+ }
@@ -0,0 +1,15 @@
1
+ import { RpdRoute } from "~/types";
2
+
3
+ export default {
4
+ namespace: "svc",
5
+ name: "svc.setSystemSettingValues",
6
+ code: "svc.setSystemSettingValues",
7
+ type: "RESTful",
8
+ method: "PATCH",
9
+ endpoint: "/svc/systemSettingValues",
10
+ actions: [
11
+ {
12
+ code: "setSystemSettingValues",
13
+ },
14
+ ],
15
+ } satisfies RpdRoute;