@ruiapp/rapid-core 0.1.69 → 0.1.71

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
@@ -3670,32 +3670,32 @@ async function generateJwtSecretKey() {
3670
3670
  return encode(exportedKey);
3671
3671
  }
3672
3672
 
3673
- const code$r = "listMetaModels";
3674
- async function handler$r(plugin, ctx, options) {
3673
+ const code$s = "listMetaModels";
3674
+ async function handler$s(plugin, ctx, options) {
3675
3675
  const { applicationConfig } = ctx;
3676
3676
  ctx.output = { list: applicationConfig.models };
3677
3677
  }
3678
3678
 
3679
3679
  var listMetaModels = /*#__PURE__*/Object.freeze({
3680
3680
  __proto__: null,
3681
- code: code$r,
3682
- handler: handler$r
3681
+ code: code$s,
3682
+ handler: handler$s
3683
3683
  });
3684
3684
 
3685
- const code$q = "listMetaRoutes";
3686
- async function handler$q(plugin, ctx, options) {
3685
+ const code$r = "listMetaRoutes";
3686
+ async function handler$r(plugin, ctx, options) {
3687
3687
  const { applicationConfig } = ctx;
3688
3688
  ctx.output = { list: applicationConfig.routes };
3689
3689
  }
3690
3690
 
3691
3691
  var listMetaRoutes = /*#__PURE__*/Object.freeze({
3692
3692
  __proto__: null,
3693
- code: code$q,
3694
- handler: handler$q
3693
+ code: code$r,
3694
+ handler: handler$r
3695
3695
  });
3696
3696
 
3697
- const code$p = "getMetaModelDetail";
3698
- async function handler$p(plugin, ctx, options) {
3697
+ const code$q = "getMetaModelDetail";
3698
+ async function handler$q(plugin, ctx, options) {
3699
3699
  const { server, input } = ctx;
3700
3700
  const model = server.getModel(input);
3701
3701
  ctx.output = model;
@@ -3703,8 +3703,8 @@ async function handler$p(plugin, ctx, options) {
3703
3703
 
3704
3704
  var getMetaModelDetail = /*#__PURE__*/Object.freeze({
3705
3705
  __proto__: null,
3706
- code: code$p,
3707
- handler: handler$p
3706
+ code: code$q,
3707
+ handler: handler$q
3708
3708
  });
3709
3709
 
3710
3710
  /**
@@ -4083,9 +4083,9 @@ function transformFilterWithSubFilters(filter) {
4083
4083
  return filter;
4084
4084
  }
4085
4085
 
4086
- const code$o = "findCollectionEntities";
4087
- async function handler$o(plugin, ctx, options) {
4088
- await runCollectionEntityActionHandler(ctx, options, code$o, async (entityManager, input) => {
4086
+ const code$p = "findCollectionEntities";
4087
+ async function handler$p(plugin, ctx, options) {
4088
+ await runCollectionEntityActionHandler(ctx, options, code$p, async (entityManager, input) => {
4089
4089
  input.filters = removeFiltersWithNullValue(input.filters);
4090
4090
  input.routeContext = ctx.routerContext;
4091
4091
  const entities = await entityManager.findEntities(input);
@@ -4101,14 +4101,14 @@ async function handler$o(plugin, ctx, options) {
4101
4101
 
4102
4102
  var findCollectionEntities = /*#__PURE__*/Object.freeze({
4103
4103
  __proto__: null,
4104
- code: code$o,
4105
- handler: handler$o
4104
+ code: code$p,
4105
+ handler: handler$p
4106
4106
  });
4107
4107
 
4108
- const code$n = "findCollectionEntityById";
4109
- async function handler$n(plugin, ctx, options) {
4108
+ const code$o = "findCollectionEntityById";
4109
+ async function handler$o(plugin, ctx, options) {
4110
4110
  const { logger, server, input } = ctx;
4111
- logger.debug(`Running ${code$n} handler...`, { input });
4111
+ logger.debug(`Running ${code$o} handler...`, { input });
4112
4112
  const { id } = input;
4113
4113
  const entityManager = server.getEntityManager(options.singularCode);
4114
4114
  const entity = await entityManager.findById({
@@ -4123,13 +4123,13 @@ async function handler$n(plugin, ctx, options) {
4123
4123
 
4124
4124
  var findCollectionEntityById = /*#__PURE__*/Object.freeze({
4125
4125
  __proto__: null,
4126
- code: code$n,
4127
- handler: handler$n
4126
+ code: code$o,
4127
+ handler: handler$o
4128
4128
  });
4129
4129
 
4130
- const code$m = "countCollectionEntities";
4131
- async function handler$m(plugin, ctx, options) {
4132
- await runCollectionEntityActionHandler(ctx, options, code$m, (entityManager, input) => {
4130
+ const code$n = "countCollectionEntities";
4131
+ async function handler$n(plugin, ctx, options) {
4132
+ await runCollectionEntityActionHandler(ctx, options, code$n, (entityManager, input) => {
4133
4133
  input.filters = removeFiltersWithNullValue(input.filters);
4134
4134
  input.routeContext = ctx.routerContext;
4135
4135
  return entityManager.count(input);
@@ -4138,16 +4138,16 @@ async function handler$m(plugin, ctx, options) {
4138
4138
 
4139
4139
  var countCollectionEntities = /*#__PURE__*/Object.freeze({
4140
4140
  __proto__: null,
4141
- code: code$m,
4142
- handler: handler$m
4141
+ code: code$n,
4142
+ handler: handler$n
4143
4143
  });
4144
4144
 
4145
- const code$l = "createCollectionEntity";
4146
- async function handler$l(plugin, ctx, options) {
4145
+ const code$m = "createCollectionEntity";
4146
+ async function handler$m(plugin, ctx, options) {
4147
4147
  const { logger, server, input } = ctx;
4148
4148
  const { defaultInput, fixedInput } = options;
4149
4149
  const mergedInput = mergeInput(defaultInput, input, fixedInput);
4150
- logger.debug(`Running ${code$l} handler...`, { defaultInput, fixedInput, mergedInput });
4150
+ logger.debug(`Running ${code$m} handler...`, { defaultInput, fixedInput, mergedInput });
4151
4151
  const entityManager = server.getEntityManager(options.singularCode);
4152
4152
  const output = await entityManager.createEntity({
4153
4153
  entity: input,
@@ -4158,15 +4158,15 @@ async function handler$l(plugin, ctx, options) {
4158
4158
 
4159
4159
  var createCollectionEntity = /*#__PURE__*/Object.freeze({
4160
4160
  __proto__: null,
4161
- code: code$l,
4162
- handler: handler$l
4161
+ code: code$m,
4162
+ handler: handler$m
4163
4163
  });
4164
4164
 
4165
- const code$k = "createCollectionEntitiesBatch";
4166
- async function handler$k(plugin, ctx, options) {
4165
+ const code$l = "createCollectionEntitiesBatch";
4166
+ async function handler$l(plugin, ctx, options) {
4167
4167
  const { logger, server, input } = ctx;
4168
4168
  const { defaultInput, fixedInput } = options;
4169
- logger.debug(`Running ${code$k} handler...`, { defaultInput, fixedInput, input });
4169
+ logger.debug(`Running ${code$l} handler...`, { defaultInput, fixedInput, input });
4170
4170
  const { entities } = input;
4171
4171
  if (!lodash.isArray(entities)) {
4172
4172
  throw new Error("input.entities should be an array.");
@@ -4190,16 +4190,16 @@ async function handler$k(plugin, ctx, options) {
4190
4190
 
4191
4191
  var createCollectionEntitiesBatch = /*#__PURE__*/Object.freeze({
4192
4192
  __proto__: null,
4193
- code: code$k,
4194
- handler: handler$k
4193
+ code: code$l,
4194
+ handler: handler$l
4195
4195
  });
4196
4196
 
4197
- const code$j = "updateCollectionEntityById";
4198
- async function handler$j(plugin, ctx, options) {
4197
+ const code$k = "updateCollectionEntityById";
4198
+ async function handler$k(plugin, ctx, options) {
4199
4199
  const { logger, server, input } = ctx;
4200
4200
  const { defaultInput, fixedInput } = options;
4201
4201
  const mergedInput = mergeInput(defaultInput, input, fixedInput);
4202
- logger.debug(`Running ${code$j} handler...`, { defaultInput, fixedInput, mergedInput });
4202
+ logger.debug(`Running ${code$k} handler...`, { defaultInput, fixedInput, mergedInput });
4203
4203
  const operation = mergedInput.$operation;
4204
4204
  if (operation) {
4205
4205
  delete mergedInput.$operation;
@@ -4222,14 +4222,14 @@ async function handler$j(plugin, ctx, options) {
4222
4222
 
4223
4223
  var updateCollectionEntityById = /*#__PURE__*/Object.freeze({
4224
4224
  __proto__: null,
4225
- code: code$j,
4226
- handler: handler$j
4225
+ code: code$k,
4226
+ handler: handler$k
4227
4227
  });
4228
4228
 
4229
- const code$i = "deleteCollectionEntityById";
4230
- async function handler$i(plugin, ctx, options) {
4229
+ const code$j = "deleteCollectionEntityById";
4230
+ async function handler$j(plugin, ctx, options) {
4231
4231
  const { logger, server, input } = ctx;
4232
- logger.debug(`Running ${code$i} handler...`);
4232
+ logger.debug(`Running ${code$j} handler...`);
4233
4233
  const entityManager = server.getEntityManager(options.singularCode);
4234
4234
  await entityManager.deleteById({
4235
4235
  id: input.id,
@@ -4241,16 +4241,16 @@ async function handler$i(plugin, ctx, options) {
4241
4241
 
4242
4242
  var deleteCollectionEntityById = /*#__PURE__*/Object.freeze({
4243
4243
  __proto__: null,
4244
- code: code$i,
4245
- handler: handler$i
4244
+ code: code$j,
4245
+ handler: handler$j
4246
4246
  });
4247
4247
 
4248
- const code$h = "addEntityRelations";
4249
- async function handler$h(plugin, ctx, options) {
4248
+ const code$i = "addEntityRelations";
4249
+ async function handler$i(plugin, ctx, options) {
4250
4250
  const { logger, server, input } = ctx;
4251
4251
  const { defaultInput, fixedInput } = options;
4252
4252
  const mergedInput = mergeInput(defaultInput, input, fixedInput);
4253
- logger.debug(`Running ${code$h} handler...`, { defaultInput, fixedInput, mergedInput });
4253
+ logger.debug(`Running ${code$i} handler...`, { defaultInput, fixedInput, mergedInput });
4254
4254
  const entityManager = server.getEntityManager(options.singularCode);
4255
4255
  mergedInput.routeContext = ctx.routerContext;
4256
4256
  await entityManager.addRelations(mergedInput, plugin);
@@ -4259,16 +4259,16 @@ async function handler$h(plugin, ctx, options) {
4259
4259
 
4260
4260
  var addEntityRelations = /*#__PURE__*/Object.freeze({
4261
4261
  __proto__: null,
4262
- code: code$h,
4263
- handler: handler$h
4262
+ code: code$i,
4263
+ handler: handler$i
4264
4264
  });
4265
4265
 
4266
- const code$g = "removeEntityRelations";
4267
- async function handler$g(plugin, ctx, options) {
4266
+ const code$h = "removeEntityRelations";
4267
+ async function handler$h(plugin, ctx, options) {
4268
4268
  const { logger, server, input } = ctx;
4269
4269
  const { defaultInput, fixedInput } = options;
4270
4270
  const mergedInput = mergeInput(defaultInput, input, fixedInput);
4271
- logger.debug(`Running ${code$g} handler...`, { defaultInput, fixedInput, mergedInput });
4271
+ logger.debug(`Running ${code$h} handler...`, { defaultInput, fixedInput, mergedInput });
4272
4272
  mergedInput.routeContext = ctx.routerContext;
4273
4273
  const entityManager = server.getEntityManager(options.singularCode);
4274
4274
  await entityManager.removeRelations(mergedInput, plugin);
@@ -4277,16 +4277,16 @@ async function handler$g(plugin, ctx, options) {
4277
4277
 
4278
4278
  var removeEntityRelations = /*#__PURE__*/Object.freeze({
4279
4279
  __proto__: null,
4280
- code: code$g,
4281
- handler: handler$g
4280
+ code: code$h,
4281
+ handler: handler$h
4282
4282
  });
4283
4283
 
4284
- const code$f = "queryDatabase";
4285
- async function handler$f(plugin, ctx, options) {
4284
+ const code$g = "queryDatabase";
4285
+ async function handler$g(plugin, ctx, options) {
4286
4286
  const { logger, server, input } = ctx;
4287
4287
  const { sql, querySingle, defaultInput, fixedInput } = options;
4288
4288
  const mergedInput = mergeInput(defaultInput, input, fixedInput);
4289
- logger.debug(`Running ${code$f} handler...`, { defaultInput, fixedInput, mergedInput });
4289
+ logger.debug(`Running ${code$g} handler...`, { defaultInput, fixedInput, mergedInput });
4290
4290
  const result = await server.queryDatabaseObject(sql, mergedInput);
4291
4291
  if (querySingle) {
4292
4292
  ctx.output = lodash.first(result);
@@ -4298,8 +4298,8 @@ async function handler$f(plugin, ctx, options) {
4298
4298
 
4299
4299
  var queryDatabase = /*#__PURE__*/Object.freeze({
4300
4300
  __proto__: null,
4301
- code: code$f,
4302
- handler: handler$f
4301
+ code: code$g,
4302
+ handler: handler$g
4303
4303
  });
4304
4304
 
4305
4305
  /**
@@ -4470,17 +4470,17 @@ async function sendSourceResponse(proxyCtx, targetRes) {
4470
4470
  srcRes.body = targetRes.body;
4471
4471
  }
4472
4472
 
4473
- const code$e = "httpProxy";
4474
- async function handler$e(plugin, ctx, options) {
4473
+ const code$f = "httpProxy";
4474
+ async function handler$f(plugin, ctx, options) {
4475
4475
  const { logger } = ctx;
4476
- logger.debug(`Running ${code$e} handler...`);
4476
+ logger.debug(`Running ${code$f} handler...`);
4477
4477
  await doProxy(ctx.routerContext, options);
4478
4478
  }
4479
4479
 
4480
4480
  var httpProxy = /*#__PURE__*/Object.freeze({
4481
4481
  __proto__: null,
4482
- code: code$e,
4483
- handler: handler$e
4482
+ code: code$f,
4483
+ handler: handler$f
4484
4484
  });
4485
4485
 
4486
4486
  /**
@@ -4527,8 +4527,8 @@ class RouteManager {
4527
4527
  }
4528
4528
  }
4529
4529
 
4530
- const code$d = "generateSn";
4531
- async function handler$d(plugin, ctx, options) {
4530
+ const code$e = "generateSn";
4531
+ async function handler$e(plugin, ctx, options) {
4532
4532
  const { server, routerContext } = ctx;
4533
4533
  const input = ctx.input;
4534
4534
  if (options?.ruleCode) {
@@ -4546,8 +4546,8 @@ async function handler$d(plugin, ctx, options) {
4546
4546
 
4547
4547
  var generateSn$1 = /*#__PURE__*/Object.freeze({
4548
4548
  __proto__: null,
4549
- code: code$d,
4550
- handler: handler$d
4549
+ code: code$e,
4550
+ handler: handler$e
4551
4551
  });
4552
4552
 
4553
4553
  var pluginActionHandlers$5 = [generateSn$1];
@@ -5125,8 +5125,8 @@ class WebhooksPlugin {
5125
5125
  }
5126
5126
  }
5127
5127
 
5128
- const code$c = "changePassword";
5129
- async function handler$c(plugin, ctx, options) {
5128
+ const code$d = "changePassword";
5129
+ async function handler$d(plugin, ctx, options) {
5130
5130
  const { server, input, routerContext } = ctx;
5131
5131
  const { id, oldPassword, newPassword } = input;
5132
5132
  const userId = routerContext.state.userId;
@@ -5168,12 +5168,12 @@ async function handler$c(plugin, ctx, options) {
5168
5168
 
5169
5169
  var changePassword$1 = /*#__PURE__*/Object.freeze({
5170
5170
  __proto__: null,
5171
- code: code$c,
5172
- handler: handler$c
5171
+ code: code$d,
5172
+ handler: handler$d
5173
5173
  });
5174
5174
 
5175
- const code$b = "createSession";
5176
- async function handler$b(plugin, ctx, options) {
5175
+ const code$c = "createSession";
5176
+ async function handler$c(plugin, ctx, options) {
5177
5177
  const { server, input, routerContext } = ctx;
5178
5178
  const { response } = routerContext;
5179
5179
  const { account, password } = input;
@@ -5216,12 +5216,12 @@ async function handler$b(plugin, ctx, options) {
5216
5216
 
5217
5217
  var createSession = /*#__PURE__*/Object.freeze({
5218
5218
  __proto__: null,
5219
- code: code$b,
5220
- handler: handler$b
5219
+ code: code$c,
5220
+ handler: handler$c
5221
5221
  });
5222
5222
 
5223
- const code$a = "deleteSession";
5224
- async function handler$a(plugin, ctx, options) {
5223
+ const code$b = "deleteSession";
5224
+ async function handler$b(plugin, ctx, options) {
5225
5225
  const { server, input, routerContext } = ctx;
5226
5226
  const { response } = routerContext;
5227
5227
  setCookie(response.headers, {
@@ -5234,12 +5234,12 @@ async function handler$a(plugin, ctx, options) {
5234
5234
 
5235
5235
  var deleteSession = /*#__PURE__*/Object.freeze({
5236
5236
  __proto__: null,
5237
- code: code$a,
5238
- handler: handler$a
5237
+ code: code$b,
5238
+ handler: handler$b
5239
5239
  });
5240
5240
 
5241
- const code$9 = "getMyProfile";
5242
- async function handler$9(plugin, ctx, options) {
5241
+ const code$a = "getMyProfile";
5242
+ async function handler$a(plugin, ctx, options) {
5243
5243
  const { server, input, routerContext } = ctx;
5244
5244
  const userId = routerContext.state.userId;
5245
5245
  if (!userId) {
@@ -5269,12 +5269,12 @@ async function handler$9(plugin, ctx, options) {
5269
5269
 
5270
5270
  var getMyProfile$2 = /*#__PURE__*/Object.freeze({
5271
5271
  __proto__: null,
5272
- code: code$9,
5273
- handler: handler$9
5272
+ code: code$a,
5273
+ handler: handler$a
5274
5274
  });
5275
5275
 
5276
- const code$8 = "resetPassword";
5277
- async function handler$8(plugin, ctx, options) {
5276
+ const code$9 = "resetPassword";
5277
+ async function handler$9(plugin, ctx, options) {
5278
5278
  const { server, input, routerContext } = ctx;
5279
5279
  const { userId, password } = input;
5280
5280
  const userDataAccessor = server.getDataAccessor({
@@ -5302,8 +5302,8 @@ async function handler$8(plugin, ctx, options) {
5302
5302
 
5303
5303
  var resetPassword$1 = /*#__PURE__*/Object.freeze({
5304
5304
  __proto__: null,
5305
- code: code$8,
5306
- handler: handler$8
5305
+ code: code$9,
5306
+ handler: handler$9
5307
5307
  });
5308
5308
 
5309
5309
  var pluginActionHandlers$4 = [changePassword$1, createSession, deleteSession, getMyProfile$2, resetPassword$1];
@@ -5521,8 +5521,8 @@ async function appendFile(path, data) {
5521
5521
  });
5522
5522
  }
5523
5523
 
5524
- const code$7 = "downloadDocument";
5525
- async function handler$7(plugin, ctx, options) {
5524
+ const code$8 = "downloadDocument";
5525
+ async function handler$8(plugin, ctx, options) {
5526
5526
  const { server, applicationConfig, routerContext, input } = ctx;
5527
5527
  const { request, response } = routerContext;
5528
5528
  const documentDataAccessor = ctx.server.getDataAccessor({
@@ -5550,12 +5550,12 @@ async function handler$7(plugin, ctx, options) {
5550
5550
 
5551
5551
  var downloadDocumentActionHandler = /*#__PURE__*/Object.freeze({
5552
5552
  __proto__: null,
5553
- code: code$7,
5554
- handler: handler$7
5553
+ code: code$8,
5554
+ handler: handler$8
5555
5555
  });
5556
5556
 
5557
- const code$6 = "downloadFile";
5558
- async function handler$6(plugin, ctx, options) {
5557
+ const code$7 = "downloadFile";
5558
+ async function handler$7(plugin, ctx, options) {
5559
5559
  const { server, applicationConfig, routerContext, input } = ctx;
5560
5560
  const { request, response } = routerContext;
5561
5561
  const dataAccessor = ctx.server.getDataAccessor({
@@ -5575,12 +5575,12 @@ async function handler$6(plugin, ctx, options) {
5575
5575
 
5576
5576
  var downloadFileActionHandler = /*#__PURE__*/Object.freeze({
5577
5577
  __proto__: null,
5578
- code: code$6,
5579
- handler: handler$6
5578
+ code: code$7,
5579
+ handler: handler$7
5580
5580
  });
5581
5581
 
5582
- const code$5 = "uploadFile";
5583
- async function handler$5(plugin, ctx, options) {
5582
+ const code$6 = "uploadFile";
5583
+ async function handler$6(plugin, ctx, options) {
5584
5584
  const { server, applicationConfig, routerContext, input } = ctx;
5585
5585
  let file = input.file || input.files;
5586
5586
  if (lodash.isArray(file)) {
@@ -5601,8 +5601,8 @@ async function handler$5(plugin, ctx, options) {
5601
5601
 
5602
5602
  var uploadFileActionHandler = /*#__PURE__*/Object.freeze({
5603
5603
  __proto__: null,
5604
- code: code$5,
5605
- handler: handler$5
5604
+ code: code$6,
5605
+ handler: handler$6
5606
5606
  });
5607
5607
 
5608
5608
  var getMyProfile = {
@@ -5678,16 +5678,16 @@ class FileManager {
5678
5678
  }
5679
5679
  }
5680
5680
 
5681
- const code$4 = "runServerOperation";
5682
- async function handler$4(plugin, ctx, options) {
5681
+ const code$5 = "runServerOperation";
5682
+ async function handler$5(plugin, ctx, options) {
5683
5683
  const { operation } = options;
5684
5684
  await operation(ctx);
5685
5685
  }
5686
5686
 
5687
5687
  var runServerOperation = /*#__PURE__*/Object.freeze({
5688
5688
  __proto__: null,
5689
- code: code$4,
5690
- handler: handler$4
5689
+ code: code$5,
5690
+ handler: handler$5
5691
5691
  });
5692
5692
 
5693
5693
  var pluginActionHandlers$3 = [runServerOperation];
@@ -5752,8 +5752,8 @@ class ServerOperationPlugin {
5752
5752
  async onApplicationReady(server, applicationConfig) { }
5753
5753
  }
5754
5754
 
5755
- const code$3 = "getUserSettingValues";
5756
- async function handler$3(plugin, ctx, options) {
5755
+ const code$4 = "getUserSettingValues";
5756
+ async function handler$4(plugin, ctx, options) {
5757
5757
  const { server, routerContext } = ctx;
5758
5758
  const userId = routerContext.state.userId;
5759
5759
  if (!userId) {
@@ -5779,12 +5779,12 @@ async function handler$3(plugin, ctx, options) {
5779
5779
 
5780
5780
  var getUserSettingValues$1 = /*#__PURE__*/Object.freeze({
5781
5781
  __proto__: null,
5782
- code: code$3,
5783
- handler: handler$3
5782
+ code: code$4,
5783
+ handler: handler$4
5784
5784
  });
5785
5785
 
5786
- const code$2 = "getSystemSettingValues";
5787
- async function handler$2(plugin, ctx, options) {
5786
+ const code$3 = "getSystemSettingValues";
5787
+ async function handler$3(plugin, ctx, options) {
5788
5788
  const { server, routerContext } = ctx;
5789
5789
  const input = ctx.input;
5790
5790
  if (options?.groupCode) {
@@ -5799,12 +5799,33 @@ async function handler$2(plugin, ctx, options) {
5799
5799
  }
5800
5800
 
5801
5801
  var getSystemSettingValues$1 = /*#__PURE__*/Object.freeze({
5802
+ __proto__: null,
5803
+ code: code$3,
5804
+ handler: handler$3
5805
+ });
5806
+
5807
+ const code$2 = "setSystemSettingValues";
5808
+ async function handler$2(plugin, ctx, options) {
5809
+ const { server, routerContext } = ctx;
5810
+ const input = ctx.input;
5811
+ if (options?.groupCode) {
5812
+ input.groupCode = options.groupCode;
5813
+ }
5814
+ if (!input.groupCode) {
5815
+ throw new Error(`Group code is required when setting system setting values.`);
5816
+ }
5817
+ const settingService = server.getService("settingService");
5818
+ await settingService.setSystemSettingValues(input.groupCode, input.values);
5819
+ ctx.output = {};
5820
+ }
5821
+
5822
+ var setSystemSettingValues$1 = /*#__PURE__*/Object.freeze({
5802
5823
  __proto__: null,
5803
5824
  code: code$2,
5804
5825
  handler: handler$2
5805
5826
  });
5806
5827
 
5807
- var pluginActionHandlers$2 = [getUserSettingValues$1, getSystemSettingValues$1];
5828
+ var pluginActionHandlers$2 = [getUserSettingValues$1, getSystemSettingValues$1, setSystemSettingValues$1];
5808
5829
 
5809
5830
  var SystemSettingGroupSetting = {
5810
5831
  maintainedBy: "settingPlugin",
@@ -6181,7 +6202,21 @@ var getSystemSettingValues = {
6181
6202
  ],
6182
6203
  };
6183
6204
 
6184
- var pluginRoutes$2 = [getUserSettingValues, getSystemSettingValues];
6205
+ var setSystemSettingValues = {
6206
+ namespace: "svc",
6207
+ name: "svc.setSystemSettingValues",
6208
+ code: "svc.setSystemSettingValues",
6209
+ type: "RESTful",
6210
+ method: "PATCH",
6211
+ endpoint: "/svc/systemSettingValues",
6212
+ actions: [
6213
+ {
6214
+ code: "setSystemSettingValues",
6215
+ },
6216
+ ],
6217
+ };
6218
+
6219
+ var pluginRoutes$2 = [getUserSettingValues, getSystemSettingValues, setSystemSettingValues];
6185
6220
 
6186
6221
  class SettingService {
6187
6222
  #server;
@@ -6244,12 +6279,14 @@ class SettingService {
6244
6279
  ],
6245
6280
  });
6246
6281
  if (settingItem) {
6247
- await this.#systemSettingItemManager.updateEntityById({
6248
- id: settingItem.id,
6249
- entityToSave: {
6250
- value,
6251
- },
6252
- });
6282
+ if (settingItem.value !== value) {
6283
+ await this.#systemSettingItemManager.updateEntityById({
6284
+ id: settingItem.id,
6285
+ entityToSave: {
6286
+ value,
6287
+ },
6288
+ });
6289
+ }
6253
6290
  }
6254
6291
  else {
6255
6292
  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
  }
@@ -1,4 +1,5 @@
1
1
  import * as getUserSettingValues from "./getUserSettingValues";
2
2
  import * as getSystemSettingValues from "./getSystemSettingValues";
3
- declare const _default: (typeof getUserSettingValues | typeof getSystemSettingValues)[];
3
+ import * as setSystemSettingValues from "./setSystemSettingValues";
4
+ declare const _default: (typeof getUserSettingValues | typeof getSystemSettingValues | typeof setSystemSettingValues)[];
4
5
  export default _default;
@@ -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>;
@@ -1,12 +1,22 @@
1
- declare const _default: {
1
+ declare const _default: ({
2
2
  namespace: string;
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;
10
10
  }[];
11
- }[];
11
+ } | {
12
+ namespace: string;
13
+ name: string;
14
+ code: string;
15
+ type: "RESTful";
16
+ method: "PATCH";
17
+ endpoint: string;
18
+ actions: {
19
+ code: string;
20
+ }[];
21
+ })[];
12
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: "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.71",
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: {
@@ -1,5 +1,6 @@
1
1
  import { IPluginActionHandler } from "~/core/actionHandler";
2
2
  import * as getUserSettingValues from "./getUserSettingValues";
3
3
  import * as getSystemSettingValues from "./getSystemSettingValues";
4
+ import * as setSystemSettingValues from "./setSystemSettingValues";
4
5
 
5
- export default [getUserSettingValues, getSystemSettingValues] satisfies IPluginActionHandler[];
6
+ export default [getUserSettingValues, getSystemSettingValues, setSystemSettingValues] satisfies IPluginActionHandler[];
@@ -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
+ }
@@ -1,4 +1,5 @@
1
1
  import getUserSettingValues from "./getUserSettingValues";
2
2
  import getSystemSettingValues from "./getSystemSettingValues";
3
+ import setSystemSettingValues from "./setSystemSettingValues";
3
4
 
4
- export default [getUserSettingValues, getSystemSettingValues];
5
+ export default [getUserSettingValues, getSystemSettingValues, setSystemSettingValues];
@@ -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;