@ruiapp/rapid-core 0.3.0 → 0.3.2
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/CHANGELOG.md +7 -7
- package/dist/index.d.ts +2 -0
- package/dist/index.js +359 -134
- package/dist/plugins/license/LicensePlugin.d.ts +23 -0
- package/dist/plugins/license/LicensePluginTypes.d.ts +78 -0
- package/dist/plugins/license/LicenseService.d.ts +22 -0
- package/dist/plugins/license/actionHandlers/getLicense.d.ts +6 -0
- package/dist/plugins/license/actionHandlers/index.d.ts +3 -0
- package/dist/plugins/license/helpers/certHelper.d.ts +2 -0
- package/dist/plugins/license/helpers/cryptoHelper.d.ts +8 -0
- package/dist/plugins/license/models/index.d.ts +2 -0
- package/dist/plugins/license/routes/getLicense.d.ts +12 -0
- package/dist/plugins/license/routes/index.d.ts +12 -0
- package/dist/utilities/typeUtility.d.ts +1 -0
- package/package.json +1 -1
- package/src/bootstrapApplicationConfig.ts +631 -631
- package/src/core/response.ts +76 -76
- package/src/core/routeContext.ts +47 -47
- package/src/core/server.ts +142 -142
- package/src/dataAccess/columnTypeMapper.ts +22 -22
- package/src/dataAccess/dataAccessTypes.ts +163 -163
- package/src/dataAccess/dataAccessor.ts +135 -135
- package/src/dataAccess/entityManager.ts +1718 -1718
- package/src/dataAccess/entityMapper.ts +100 -100
- package/src/dataAccess/propertyMapper.ts +28 -28
- package/src/deno-std/http/cookie.ts +372 -372
- package/src/helpers/entityHelpers.ts +76 -76
- package/src/helpers/filterHelper.ts +148 -148
- package/src/helpers/metaHelper.ts +89 -89
- package/src/helpers/runCollectionEntityActionHandler.ts +27 -27
- package/src/index.ts +57 -54
- package/src/plugins/auth/AuthPlugin.ts +85 -85
- package/src/plugins/auth/actionHandlers/changePassword.ts +54 -54
- package/src/plugins/auth/actionHandlers/createSession.ts +75 -63
- package/src/plugins/auth/actionHandlers/resetPassword.ts +38 -38
- package/src/plugins/cronJob/CronJobPlugin.ts +112 -112
- package/src/plugins/dataManage/DataManagePlugin.ts +163 -163
- package/src/plugins/dataManage/actionHandlers/addEntityRelations.ts +20 -20
- package/src/plugins/dataManage/actionHandlers/countCollectionEntities.ts +16 -16
- package/src/plugins/dataManage/actionHandlers/createCollectionEntitiesBatch.ts +42 -42
- package/src/plugins/dataManage/actionHandlers/createCollectionEntity.ts +24 -24
- package/src/plugins/dataManage/actionHandlers/deleteCollectionEntities.ts +38 -38
- package/src/plugins/dataManage/actionHandlers/deleteCollectionEntityById.ts +22 -22
- package/src/plugins/dataManage/actionHandlers/findCollectionEntities.ts +26 -26
- package/src/plugins/dataManage/actionHandlers/findCollectionEntityById.ts +21 -21
- package/src/plugins/dataManage/actionHandlers/removeEntityRelations.ts +20 -20
- package/src/plugins/dataManage/actionHandlers/updateCollectionEntityById.ts +41 -41
- package/src/plugins/entityAccessControl/EntityAccessControlPlugin.ts +146 -146
- package/src/plugins/fileManage/FileManagePlugin.ts +52 -52
- package/src/plugins/fileManage/actionHandlers/downloadDocument.ts +65 -65
- package/src/plugins/fileManage/actionHandlers/downloadFile.ts +44 -44
- package/src/plugins/license/LicensePlugin.ts +79 -0
- package/src/plugins/license/LicensePluginTypes.ts +95 -0
- package/src/plugins/license/LicenseService.ts +112 -0
- package/src/plugins/license/actionHandlers/getLicense.ts +18 -0
- package/src/plugins/license/actionHandlers/index.ts +4 -0
- package/src/plugins/license/helpers/certHelper.ts +21 -0
- package/src/plugins/license/helpers/cryptoHelper.ts +47 -0
- package/src/plugins/license/models/index.ts +1 -0
- package/src/plugins/license/routes/getLicense.ts +15 -0
- package/src/plugins/license/routes/index.ts +3 -0
- package/src/plugins/mail/MailPlugin.ts +74 -74
- package/src/plugins/mail/MailPluginTypes.ts +27 -27
- package/src/plugins/mail/MailService.ts +38 -38
- package/src/plugins/mail/actionHandlers/index.ts +3 -3
- package/src/plugins/mail/models/index.ts +1 -1
- package/src/plugins/mail/routes/index.ts +1 -1
- package/src/plugins/metaManage/MetaManagePlugin.ts +504 -504
- package/src/plugins/notification/NotificationPlugin.ts +68 -68
- package/src/plugins/notification/NotificationPluginTypes.ts +13 -13
- package/src/plugins/notification/NotificationService.ts +25 -25
- package/src/plugins/notification/actionHandlers/index.ts +3 -3
- package/src/plugins/notification/models/Notification.ts +60 -57
- package/src/plugins/notification/models/index.ts +3 -3
- package/src/plugins/notification/routes/index.ts +1 -1
- package/src/plugins/routeManage/RouteManagePlugin.ts +62 -62
- package/src/plugins/sequence/SequencePlugin.ts +136 -136
- package/src/plugins/sequence/SequencePluginTypes.ts +69 -69
- package/src/plugins/sequence/SequenceService.ts +81 -81
- package/src/plugins/sequence/actionHandlers/generateSn.ts +32 -32
- package/src/plugins/sequence/segments/autoIncrement.ts +78 -78
- package/src/plugins/sequence/segments/dayOfMonth.ts +17 -17
- package/src/plugins/sequence/segments/literal.ts +14 -14
- package/src/plugins/sequence/segments/month.ts +17 -17
- package/src/plugins/sequence/segments/parameter.ts +18 -18
- package/src/plugins/sequence/segments/year.ts +17 -17
- package/src/plugins/setting/SettingPlugin.ts +68 -68
- package/src/plugins/setting/SettingPluginTypes.ts +37 -37
- package/src/plugins/setting/models/SystemSettingItem.ts +48 -42
- package/src/plugins/setting/models/UserSettingItem.ts +55 -49
- package/src/plugins/stateMachine/StateMachinePlugin.ts +186 -186
- package/src/plugins/stateMachine/StateMachinePluginTypes.ts +48 -48
- package/src/plugins/stateMachine/actionHandlers/sendStateMachineEvent.ts +51 -51
- package/src/plugins/webhooks/WebhooksPlugin.ts +148 -148
- package/src/plugins/webhooks/pluginConfig.ts +75 -75
- package/src/queryBuilder/queryBuilder.ts +665 -665
- package/src/server.ts +463 -463
- package/src/types.ts +701 -701
- package/src/utilities/errorUtility.ts +15 -15
- package/src/utilities/pathUtility.ts +14 -14
- package/src/utilities/typeUtility.ts +15 -11
package/dist/index.js
CHANGED
|
@@ -910,6 +910,9 @@ function isNull(val) {
|
|
|
910
910
|
}
|
|
911
911
|
function isNullOrUndefined(val) {
|
|
912
912
|
return isNull(val) || isUndefined(val);
|
|
913
|
+
}
|
|
914
|
+
function isNullOrUndefinedOrEmpty(val) {
|
|
915
|
+
return isNull(val) || isUndefined(val) || val === "";
|
|
913
916
|
}
|
|
914
917
|
|
|
915
918
|
async function buildRoutes(server, applicationConfig) {
|
|
@@ -2801,8 +2804,8 @@ async function findManyRelationLinksViaLinkTable(options) {
|
|
|
2801
2804
|
const command = `SELECT * FROM ${server.queryBuilder.quoteTable({
|
|
2802
2805
|
schema: relationProperty.linkSchema,
|
|
2803
2806
|
tableName: relationProperty.linkTableName,
|
|
2804
|
-
})} WHERE ${server.queryBuilder.quoteObject(relationProperty.selfIdColumnName)} = ANY($1::int[])
|
|
2805
|
-
ORDER BY id
|
|
2807
|
+
})} WHERE ${server.queryBuilder.quoteObject(relationProperty.selfIdColumnName)} = ANY($1::int[])
|
|
2808
|
+
ORDER BY id
|
|
2806
2809
|
`;
|
|
2807
2810
|
const params = [mainEntityIds];
|
|
2808
2811
|
const links = await server.queryDatabaseObject(command, params);
|
|
@@ -3421,7 +3424,7 @@ async function updateEntityById(server, dataAccessor, options, plugin) {
|
|
|
3421
3424
|
await server.queryDatabaseObject(`DELETE FROM ${server.queryBuilder.quoteTable({
|
|
3422
3425
|
schema: property.linkSchema,
|
|
3423
3426
|
tableName: property.linkTableName,
|
|
3424
|
-
})} WHERE ${server.queryBuilder.quoteObject(property.selfIdColumnName)} = $1
|
|
3427
|
+
})} WHERE ${server.queryBuilder.quoteObject(property.selfIdColumnName)} = $1
|
|
3425
3428
|
AND ${server.queryBuilder.quoteObject(property.targetIdColumnName)} <> ALL($2::int[])`, [id, targetIdsToKeep]);
|
|
3426
3429
|
}
|
|
3427
3430
|
else {
|
|
@@ -3731,11 +3734,11 @@ class EntityManager {
|
|
|
3731
3734
|
const command = `INSERT INTO ${queryBuilder.quoteTable({
|
|
3732
3735
|
schema: relationProperty.linkSchema,
|
|
3733
3736
|
tableName: relationProperty.linkTableName,
|
|
3734
|
-
})} (${queryBuilder.quoteObject(relationProperty.selfIdColumnName)}, ${queryBuilder.quoteObject(relationProperty.targetIdColumnName)})
|
|
3735
|
-
SELECT $1, $2 WHERE NOT EXISTS (
|
|
3736
|
-
SELECT ${queryBuilder.quoteObject(relationProperty.selfIdColumnName)}, ${queryBuilder.quoteObject(relationProperty.targetIdColumnName)}
|
|
3737
|
-
FROM ${queryBuilder.quoteTable({ schema: relationProperty.linkSchema, tableName: relationProperty.linkTableName })}
|
|
3738
|
-
WHERE ${queryBuilder.quoteObject(relationProperty.selfIdColumnName)}=$1 AND ${queryBuilder.quoteObject(relationProperty.targetIdColumnName)}=$2
|
|
3737
|
+
})} (${queryBuilder.quoteObject(relationProperty.selfIdColumnName)}, ${queryBuilder.quoteObject(relationProperty.targetIdColumnName)})
|
|
3738
|
+
SELECT $1, $2 WHERE NOT EXISTS (
|
|
3739
|
+
SELECT ${queryBuilder.quoteObject(relationProperty.selfIdColumnName)}, ${queryBuilder.quoteObject(relationProperty.targetIdColumnName)}
|
|
3740
|
+
FROM ${queryBuilder.quoteTable({ schema: relationProperty.linkSchema, tableName: relationProperty.linkTableName })}
|
|
3741
|
+
WHERE ${queryBuilder.quoteObject(relationProperty.selfIdColumnName)}=$1 AND ${queryBuilder.quoteObject(relationProperty.targetIdColumnName)}=$2
|
|
3739
3742
|
)`;
|
|
3740
3743
|
const params = [id, relation.id];
|
|
3741
3744
|
await server.queryDatabaseObject(command, params);
|
|
@@ -3775,7 +3778,7 @@ class EntityManager {
|
|
|
3775
3778
|
const { queryBuilder } = server;
|
|
3776
3779
|
if (relationProperty.linkTableName) {
|
|
3777
3780
|
for (const relation of relations) {
|
|
3778
|
-
const command = `DELETE FROM ${queryBuilder.quoteTable({ schema: relationProperty.linkSchema, tableName: relationProperty.linkTableName })}
|
|
3781
|
+
const command = `DELETE FROM ${queryBuilder.quoteTable({ schema: relationProperty.linkSchema, tableName: relationProperty.linkTableName })}
|
|
3779
3782
|
WHERE ${queryBuilder.quoteObject(relationProperty.selfIdColumnName)}=$1 AND ${queryBuilder.quoteObject(relationProperty.targetIdColumnName)}=$2;`;
|
|
3780
3783
|
const params = [id, relation.id];
|
|
3781
3784
|
await server.queryDatabaseObject(command, params);
|
|
@@ -4315,32 +4318,32 @@ async function generateJwtSecretKey() {
|
|
|
4315
4318
|
return encode(exportedKey);
|
|
4316
4319
|
}
|
|
4317
4320
|
|
|
4318
|
-
const code$
|
|
4319
|
-
async function handler$
|
|
4321
|
+
const code$u = "listMetaModels";
|
|
4322
|
+
async function handler$u(plugin, ctx, options) {
|
|
4320
4323
|
const { applicationConfig } = ctx;
|
|
4321
4324
|
ctx.output = { list: applicationConfig.models };
|
|
4322
4325
|
}
|
|
4323
4326
|
|
|
4324
4327
|
var listMetaModels = /*#__PURE__*/Object.freeze({
|
|
4325
4328
|
__proto__: null,
|
|
4326
|
-
code: code$
|
|
4327
|
-
handler: handler$
|
|
4329
|
+
code: code$u,
|
|
4330
|
+
handler: handler$u
|
|
4328
4331
|
});
|
|
4329
4332
|
|
|
4330
|
-
const code$
|
|
4331
|
-
async function handler$
|
|
4333
|
+
const code$t = "listMetaRoutes";
|
|
4334
|
+
async function handler$t(plugin, ctx, options) {
|
|
4332
4335
|
const { applicationConfig } = ctx;
|
|
4333
4336
|
ctx.output = { list: applicationConfig.routes };
|
|
4334
4337
|
}
|
|
4335
4338
|
|
|
4336
4339
|
var listMetaRoutes = /*#__PURE__*/Object.freeze({
|
|
4337
4340
|
__proto__: null,
|
|
4338
|
-
code: code$
|
|
4339
|
-
handler: handler$
|
|
4341
|
+
code: code$t,
|
|
4342
|
+
handler: handler$t
|
|
4340
4343
|
});
|
|
4341
4344
|
|
|
4342
|
-
const code$
|
|
4343
|
-
async function handler$
|
|
4345
|
+
const code$s = "getMetaModelDetail";
|
|
4346
|
+
async function handler$s(plugin, ctx, options) {
|
|
4344
4347
|
const { server, input } = ctx;
|
|
4345
4348
|
const model = server.getModel(input);
|
|
4346
4349
|
ctx.output = model;
|
|
@@ -4348,8 +4351,8 @@ async function handler$r(plugin, ctx, options) {
|
|
|
4348
4351
|
|
|
4349
4352
|
var getMetaModelDetail = /*#__PURE__*/Object.freeze({
|
|
4350
4353
|
__proto__: null,
|
|
4351
|
-
code: code$
|
|
4352
|
-
handler: handler$
|
|
4354
|
+
code: code$s,
|
|
4355
|
+
handler: handler$s
|
|
4353
4356
|
});
|
|
4354
4357
|
|
|
4355
4358
|
function removeFiltersWithNullValue(filters) {
|
|
@@ -4599,7 +4602,7 @@ async function syncDatabaseSchema(server, applicationConfig) {
|
|
|
4599
4602
|
await server.queryDatabaseObject(`CREATE TABLE IF NOT EXISTS ${queryBuilder.quoteTable(model)} ()`, []);
|
|
4600
4603
|
}
|
|
4601
4604
|
}
|
|
4602
|
-
const sqlQueryColumnInformations = `SELECT table_schema, table_name, column_name, data_type, udt_name, is_nullable, column_default, character_maximum_length, numeric_precision, numeric_scale
|
|
4605
|
+
const sqlQueryColumnInformations = `SELECT table_schema, table_name, column_name, data_type, udt_name, is_nullable, column_default, character_maximum_length, numeric_precision, numeric_scale
|
|
4603
4606
|
FROM information_schema.columns;`;
|
|
4604
4607
|
const columnsInDb = await server.queryDatabaseObject(sqlQueryColumnInformations, []);
|
|
4605
4608
|
for (const model of applicationConfig.models) {
|
|
@@ -4863,9 +4866,9 @@ async function runCollectionEntityActionHandler(ctx, options, code, handleEntity
|
|
|
4863
4866
|
}
|
|
4864
4867
|
}
|
|
4865
4868
|
|
|
4866
|
-
const code$
|
|
4867
|
-
async function handler$
|
|
4868
|
-
await runCollectionEntityActionHandler(ctx, options, code$
|
|
4869
|
+
const code$r = "findCollectionEntities";
|
|
4870
|
+
async function handler$r(plugin, ctx, options) {
|
|
4871
|
+
await runCollectionEntityActionHandler(ctx, options, code$r, async (entityManager, input) => {
|
|
4869
4872
|
input.filters = removeFiltersWithNullValue(input.filters);
|
|
4870
4873
|
input.routeContext = ctx.routerContext;
|
|
4871
4874
|
const entities = await entityManager.findEntities(input);
|
|
@@ -4881,14 +4884,14 @@ async function handler$q(plugin, ctx, options) {
|
|
|
4881
4884
|
|
|
4882
4885
|
var findCollectionEntities = /*#__PURE__*/Object.freeze({
|
|
4883
4886
|
__proto__: null,
|
|
4884
|
-
code: code$
|
|
4885
|
-
handler: handler$
|
|
4887
|
+
code: code$r,
|
|
4888
|
+
handler: handler$r
|
|
4886
4889
|
});
|
|
4887
4890
|
|
|
4888
|
-
const code$
|
|
4889
|
-
async function handler$
|
|
4891
|
+
const code$q = "findCollectionEntityById";
|
|
4892
|
+
async function handler$q(plugin, ctx, options) {
|
|
4890
4893
|
const { logger, server, input } = ctx;
|
|
4891
|
-
logger.debug(`Running ${code$
|
|
4894
|
+
logger.debug(`Running ${code$q} handler...`, { input });
|
|
4892
4895
|
const { id } = input;
|
|
4893
4896
|
const entityManager = server.getEntityManager(options.singularCode);
|
|
4894
4897
|
const entity = await entityManager.findById({
|
|
@@ -4903,13 +4906,13 @@ async function handler$p(plugin, ctx, options) {
|
|
|
4903
4906
|
|
|
4904
4907
|
var findCollectionEntityById = /*#__PURE__*/Object.freeze({
|
|
4905
4908
|
__proto__: null,
|
|
4906
|
-
code: code$
|
|
4907
|
-
handler: handler$
|
|
4909
|
+
code: code$q,
|
|
4910
|
+
handler: handler$q
|
|
4908
4911
|
});
|
|
4909
4912
|
|
|
4910
|
-
const code$
|
|
4911
|
-
async function handler$
|
|
4912
|
-
await runCollectionEntityActionHandler(ctx, options, code$
|
|
4913
|
+
const code$p = "countCollectionEntities";
|
|
4914
|
+
async function handler$p(plugin, ctx, options) {
|
|
4915
|
+
await runCollectionEntityActionHandler(ctx, options, code$p, async (entityManager, input) => {
|
|
4913
4916
|
input.filters = removeFiltersWithNullValue(input.filters);
|
|
4914
4917
|
input.routeContext = ctx.routerContext;
|
|
4915
4918
|
const count = await entityManager.count(input);
|
|
@@ -4919,16 +4922,16 @@ async function handler$o(plugin, ctx, options) {
|
|
|
4919
4922
|
|
|
4920
4923
|
var countCollectionEntities = /*#__PURE__*/Object.freeze({
|
|
4921
4924
|
__proto__: null,
|
|
4922
|
-
code: code$
|
|
4923
|
-
handler: handler$
|
|
4925
|
+
code: code$p,
|
|
4926
|
+
handler: handler$p
|
|
4924
4927
|
});
|
|
4925
4928
|
|
|
4926
|
-
const code$
|
|
4927
|
-
async function handler$
|
|
4929
|
+
const code$o = "createCollectionEntity";
|
|
4930
|
+
async function handler$o(plugin, ctx, options) {
|
|
4928
4931
|
const { logger, server, input } = ctx;
|
|
4929
4932
|
const { defaultInput, fixedInput } = options;
|
|
4930
4933
|
const mergedInput = mergeInput(defaultInput, input, fixedInput);
|
|
4931
|
-
logger.debug(`Running ${code$
|
|
4934
|
+
logger.debug(`Running ${code$o} handler...`, { defaultInput, fixedInput, mergedInput });
|
|
4932
4935
|
const entityManager = server.getEntityManager(options.singularCode);
|
|
4933
4936
|
const output = await entityManager.createEntity({
|
|
4934
4937
|
entity: input,
|
|
@@ -4939,15 +4942,15 @@ async function handler$n(plugin, ctx, options) {
|
|
|
4939
4942
|
|
|
4940
4943
|
var createCollectionEntity = /*#__PURE__*/Object.freeze({
|
|
4941
4944
|
__proto__: null,
|
|
4942
|
-
code: code$
|
|
4943
|
-
handler: handler$
|
|
4945
|
+
code: code$o,
|
|
4946
|
+
handler: handler$o
|
|
4944
4947
|
});
|
|
4945
4948
|
|
|
4946
|
-
const code$
|
|
4947
|
-
async function handler$
|
|
4949
|
+
const code$n = "createCollectionEntitiesBatch";
|
|
4950
|
+
async function handler$n(plugin, ctx, options) {
|
|
4948
4951
|
const { logger, server, input } = ctx;
|
|
4949
4952
|
const { defaultInput, fixedInput } = options;
|
|
4950
|
-
logger.debug(`Running ${code$
|
|
4953
|
+
logger.debug(`Running ${code$n} handler...`, { defaultInput, fixedInput, input });
|
|
4951
4954
|
const { entities } = input;
|
|
4952
4955
|
if (!lodash.isArray(entities)) {
|
|
4953
4956
|
throw new Error("input.entities should be an array.");
|
|
@@ -4971,16 +4974,16 @@ async function handler$m(plugin, ctx, options) {
|
|
|
4971
4974
|
|
|
4972
4975
|
var createCollectionEntitiesBatch = /*#__PURE__*/Object.freeze({
|
|
4973
4976
|
__proto__: null,
|
|
4974
|
-
code: code$
|
|
4975
|
-
handler: handler$
|
|
4977
|
+
code: code$n,
|
|
4978
|
+
handler: handler$n
|
|
4976
4979
|
});
|
|
4977
4980
|
|
|
4978
|
-
const code$
|
|
4979
|
-
async function handler$
|
|
4981
|
+
const code$m = "updateCollectionEntityById";
|
|
4982
|
+
async function handler$m(plugin, ctx, options) {
|
|
4980
4983
|
const { logger, server, input } = ctx;
|
|
4981
4984
|
const { defaultInput, fixedInput } = options;
|
|
4982
4985
|
const mergedInput = mergeInput(defaultInput, input, fixedInput);
|
|
4983
|
-
logger.debug(`Running ${code$
|
|
4986
|
+
logger.debug(`Running ${code$m} handler...`, { defaultInput, fixedInput, mergedInput });
|
|
4984
4987
|
const operation = mergedInput.$operation;
|
|
4985
4988
|
if (operation) {
|
|
4986
4989
|
delete mergedInput.$operation;
|
|
@@ -5008,15 +5011,15 @@ async function handler$l(plugin, ctx, options) {
|
|
|
5008
5011
|
|
|
5009
5012
|
var updateCollectionEntityById = /*#__PURE__*/Object.freeze({
|
|
5010
5013
|
__proto__: null,
|
|
5011
|
-
code: code$
|
|
5012
|
-
handler: handler$
|
|
5014
|
+
code: code$m,
|
|
5015
|
+
handler: handler$m
|
|
5013
5016
|
});
|
|
5014
5017
|
|
|
5015
|
-
const code$
|
|
5016
|
-
async function handler$
|
|
5018
|
+
const code$l = "deleteCollectionEntities";
|
|
5019
|
+
async function handler$l(plugin, ctx, options) {
|
|
5017
5020
|
const { logger, server, routerContext } = ctx;
|
|
5018
5021
|
const input = ctx.input;
|
|
5019
|
-
logger.debug(`Running ${code$
|
|
5022
|
+
logger.debug(`Running ${code$l} handler...`);
|
|
5020
5023
|
if (!input.filters || !input.filters.length) {
|
|
5021
5024
|
throw new Error("Filters are required when deleting entities.");
|
|
5022
5025
|
}
|
|
@@ -5037,14 +5040,14 @@ async function handler$k(plugin, ctx, options) {
|
|
|
5037
5040
|
|
|
5038
5041
|
var deleteCollectionEntities = /*#__PURE__*/Object.freeze({
|
|
5039
5042
|
__proto__: null,
|
|
5040
|
-
code: code$
|
|
5041
|
-
handler: handler$
|
|
5043
|
+
code: code$l,
|
|
5044
|
+
handler: handler$l
|
|
5042
5045
|
});
|
|
5043
5046
|
|
|
5044
|
-
const code$
|
|
5045
|
-
async function handler$
|
|
5047
|
+
const code$k = "deleteCollectionEntityById";
|
|
5048
|
+
async function handler$k(plugin, ctx, options) {
|
|
5046
5049
|
const { logger, server, input } = ctx;
|
|
5047
|
-
logger.debug(`Running ${code$
|
|
5050
|
+
logger.debug(`Running ${code$k} handler...`);
|
|
5048
5051
|
const entityManager = server.getEntityManager(options.singularCode);
|
|
5049
5052
|
await entityManager.deleteById({
|
|
5050
5053
|
id: input.id,
|
|
@@ -5056,16 +5059,16 @@ async function handler$j(plugin, ctx, options) {
|
|
|
5056
5059
|
|
|
5057
5060
|
var deleteCollectionEntityById = /*#__PURE__*/Object.freeze({
|
|
5058
5061
|
__proto__: null,
|
|
5059
|
-
code: code$
|
|
5060
|
-
handler: handler$
|
|
5062
|
+
code: code$k,
|
|
5063
|
+
handler: handler$k
|
|
5061
5064
|
});
|
|
5062
5065
|
|
|
5063
|
-
const code$
|
|
5064
|
-
async function handler$
|
|
5066
|
+
const code$j = "addEntityRelations";
|
|
5067
|
+
async function handler$j(plugin, ctx, options) {
|
|
5065
5068
|
const { logger, server, input } = ctx;
|
|
5066
5069
|
const { defaultInput, fixedInput } = options;
|
|
5067
5070
|
const mergedInput = mergeInput(defaultInput, input, fixedInput);
|
|
5068
|
-
logger.debug(`Running ${code$
|
|
5071
|
+
logger.debug(`Running ${code$j} handler...`, { defaultInput, fixedInput, mergedInput });
|
|
5069
5072
|
const entityManager = server.getEntityManager(options.singularCode);
|
|
5070
5073
|
mergedInput.routeContext = ctx.routerContext;
|
|
5071
5074
|
await entityManager.addRelations(mergedInput, plugin);
|
|
@@ -5074,16 +5077,16 @@ async function handler$i(plugin, ctx, options) {
|
|
|
5074
5077
|
|
|
5075
5078
|
var addEntityRelations = /*#__PURE__*/Object.freeze({
|
|
5076
5079
|
__proto__: null,
|
|
5077
|
-
code: code$
|
|
5078
|
-
handler: handler$
|
|
5080
|
+
code: code$j,
|
|
5081
|
+
handler: handler$j
|
|
5079
5082
|
});
|
|
5080
5083
|
|
|
5081
|
-
const code$
|
|
5082
|
-
async function handler$
|
|
5084
|
+
const code$i = "removeEntityRelations";
|
|
5085
|
+
async function handler$i(plugin, ctx, options) {
|
|
5083
5086
|
const { logger, server, input } = ctx;
|
|
5084
5087
|
const { defaultInput, fixedInput } = options;
|
|
5085
5088
|
const mergedInput = mergeInput(defaultInput, input, fixedInput);
|
|
5086
|
-
logger.debug(`Running ${code$
|
|
5089
|
+
logger.debug(`Running ${code$i} handler...`, { defaultInput, fixedInput, mergedInput });
|
|
5087
5090
|
mergedInput.routeContext = ctx.routerContext;
|
|
5088
5091
|
const entityManager = server.getEntityManager(options.singularCode);
|
|
5089
5092
|
await entityManager.removeRelations(mergedInput, plugin);
|
|
@@ -5092,16 +5095,16 @@ async function handler$h(plugin, ctx, options) {
|
|
|
5092
5095
|
|
|
5093
5096
|
var removeEntityRelations = /*#__PURE__*/Object.freeze({
|
|
5094
5097
|
__proto__: null,
|
|
5095
|
-
code: code$
|
|
5096
|
-
handler: handler$
|
|
5098
|
+
code: code$i,
|
|
5099
|
+
handler: handler$i
|
|
5097
5100
|
});
|
|
5098
5101
|
|
|
5099
|
-
const code$
|
|
5100
|
-
async function handler$
|
|
5102
|
+
const code$h = "queryDatabase";
|
|
5103
|
+
async function handler$h(plugin, ctx, options) {
|
|
5101
5104
|
const { logger, server, input } = ctx;
|
|
5102
5105
|
const { sql, querySingle, defaultInput, fixedInput } = options;
|
|
5103
5106
|
const mergedInput = mergeInput(defaultInput, input, fixedInput);
|
|
5104
|
-
logger.debug(`Running ${code$
|
|
5107
|
+
logger.debug(`Running ${code$h} handler...`, { defaultInput, fixedInput, mergedInput });
|
|
5105
5108
|
const result = await server.queryDatabaseObject(sql, mergedInput);
|
|
5106
5109
|
if (querySingle) {
|
|
5107
5110
|
ctx.output = lodash.first(result);
|
|
@@ -5113,8 +5116,8 @@ async function handler$g(plugin, ctx, options) {
|
|
|
5113
5116
|
|
|
5114
5117
|
var queryDatabase = /*#__PURE__*/Object.freeze({
|
|
5115
5118
|
__proto__: null,
|
|
5116
|
-
code: code$
|
|
5117
|
-
handler: handler$
|
|
5119
|
+
code: code$h,
|
|
5120
|
+
handler: handler$h
|
|
5118
5121
|
});
|
|
5119
5122
|
|
|
5120
5123
|
/**
|
|
@@ -5292,17 +5295,17 @@ async function sendSourceResponse(proxyCtx, targetRes) {
|
|
|
5292
5295
|
srcRes.body = targetRes.body;
|
|
5293
5296
|
}
|
|
5294
5297
|
|
|
5295
|
-
const code$
|
|
5296
|
-
async function handler$
|
|
5298
|
+
const code$g = "httpProxy";
|
|
5299
|
+
async function handler$g(plugin, ctx, options) {
|
|
5297
5300
|
const { logger } = ctx;
|
|
5298
|
-
logger.debug(`Running ${code$
|
|
5301
|
+
logger.debug(`Running ${code$g} handler...`);
|
|
5299
5302
|
await doProxy(ctx.routerContext, options);
|
|
5300
5303
|
}
|
|
5301
5304
|
|
|
5302
5305
|
var httpProxy = /*#__PURE__*/Object.freeze({
|
|
5303
5306
|
__proto__: null,
|
|
5304
|
-
code: code$
|
|
5305
|
-
handler: handler$
|
|
5307
|
+
code: code$g,
|
|
5308
|
+
handler: handler$g
|
|
5306
5309
|
});
|
|
5307
5310
|
|
|
5308
5311
|
/**
|
|
@@ -5349,8 +5352,8 @@ class RouteManager {
|
|
|
5349
5352
|
}
|
|
5350
5353
|
}
|
|
5351
5354
|
|
|
5352
|
-
const code$
|
|
5353
|
-
async function handler$
|
|
5355
|
+
const code$f = "generateSn";
|
|
5356
|
+
async function handler$f(plugin, ctx, options) {
|
|
5354
5357
|
const { server, routerContext } = ctx;
|
|
5355
5358
|
const input = ctx.input;
|
|
5356
5359
|
if (options?.ruleCode) {
|
|
@@ -5368,11 +5371,11 @@ async function handler$e(plugin, ctx, options) {
|
|
|
5368
5371
|
|
|
5369
5372
|
var generateSn$1 = /*#__PURE__*/Object.freeze({
|
|
5370
5373
|
__proto__: null,
|
|
5371
|
-
code: code$
|
|
5372
|
-
handler: handler$
|
|
5374
|
+
code: code$f,
|
|
5375
|
+
handler: handler$f
|
|
5373
5376
|
});
|
|
5374
5377
|
|
|
5375
|
-
var pluginActionHandlers$
|
|
5378
|
+
var pluginActionHandlers$8 = [generateSn$1];
|
|
5376
5379
|
|
|
5377
5380
|
var SequenceRule = {
|
|
5378
5381
|
maintainedBy: "sequencePlugin",
|
|
@@ -5463,7 +5466,7 @@ var SequenceAutoIncrementRecord = {
|
|
|
5463
5466
|
],
|
|
5464
5467
|
};
|
|
5465
5468
|
|
|
5466
|
-
var pluginModels$
|
|
5469
|
+
var pluginModels$6 = [SequenceRule, SequenceAutoIncrementRecord];
|
|
5467
5470
|
|
|
5468
5471
|
var generateSn = {
|
|
5469
5472
|
namespace: "svc",
|
|
@@ -5479,7 +5482,7 @@ var generateSn = {
|
|
|
5479
5482
|
],
|
|
5480
5483
|
};
|
|
5481
5484
|
|
|
5482
|
-
var pluginRoutes$
|
|
5485
|
+
var pluginRoutes$8 = [generateSn];
|
|
5483
5486
|
|
|
5484
5487
|
const segmentType$5 = "literal";
|
|
5485
5488
|
async function resolveSegmentValue$5(server, ruleCode, config, input) {
|
|
@@ -5696,19 +5699,19 @@ class SequencePlugin$1 {
|
|
|
5696
5699
|
return [];
|
|
5697
5700
|
}
|
|
5698
5701
|
async registerActionHandlers(server) {
|
|
5699
|
-
for (const actionHandler of pluginActionHandlers$
|
|
5702
|
+
for (const actionHandler of pluginActionHandlers$8) {
|
|
5700
5703
|
server.registerActionHandler(this, actionHandler);
|
|
5701
5704
|
}
|
|
5702
5705
|
}
|
|
5703
5706
|
async configureModels(server, applicationConfig) {
|
|
5704
|
-
server.appendApplicationConfig({ models: pluginModels$
|
|
5707
|
+
server.appendApplicationConfig({ models: pluginModels$6 });
|
|
5705
5708
|
}
|
|
5706
5709
|
async configureServices(server, applicationConfig) {
|
|
5707
5710
|
this.#sequenceService = new SequenceService(server);
|
|
5708
5711
|
server.registerService("sequenceService", this.#sequenceService);
|
|
5709
5712
|
}
|
|
5710
5713
|
async configureRoutes(server, applicationConfig) {
|
|
5711
|
-
server.appendApplicationConfig({ routes: pluginRoutes$
|
|
5714
|
+
server.appendApplicationConfig({ routes: pluginRoutes$8 });
|
|
5712
5715
|
}
|
|
5713
5716
|
async onApplicationLoaded(server, applicationConfig) {
|
|
5714
5717
|
const models = server.getApplicationConfig().models;
|
|
@@ -5948,8 +5951,8 @@ class WebhooksPlugin {
|
|
|
5948
5951
|
}
|
|
5949
5952
|
}
|
|
5950
5953
|
|
|
5951
|
-
const code$
|
|
5952
|
-
async function handler$
|
|
5954
|
+
const code$e = "changePassword";
|
|
5955
|
+
async function handler$e(plugin, ctx, options) {
|
|
5953
5956
|
const { server, input, routerContext } = ctx;
|
|
5954
5957
|
const { id, oldPassword, newPassword } = input;
|
|
5955
5958
|
const userId = routerContext.state.userId;
|
|
@@ -5991,15 +5994,24 @@ async function handler$d(plugin, ctx, options) {
|
|
|
5991
5994
|
|
|
5992
5995
|
var changePassword$1 = /*#__PURE__*/Object.freeze({
|
|
5993
5996
|
__proto__: null,
|
|
5994
|
-
code: code$
|
|
5995
|
-
handler: handler$
|
|
5997
|
+
code: code$e,
|
|
5998
|
+
handler: handler$e
|
|
5996
5999
|
});
|
|
5997
6000
|
|
|
5998
|
-
const code$
|
|
5999
|
-
async function handler$
|
|
6001
|
+
const code$d = "createSession";
|
|
6002
|
+
async function handler$d(plugin, ctx, options) {
|
|
6000
6003
|
const { server, input, routerContext } = ctx;
|
|
6001
6004
|
const { response } = routerContext;
|
|
6002
6005
|
const { account, password } = input;
|
|
6006
|
+
const licenseService = server.getService("licenseService");
|
|
6007
|
+
const license = licenseService.getLicense();
|
|
6008
|
+
if (!license) {
|
|
6009
|
+
throw new Error(`登录失败,无法获取系统授权信息。`);
|
|
6010
|
+
}
|
|
6011
|
+
if (licenseService.isExpired()) {
|
|
6012
|
+
const expireDate = lodash.get(license.authority, "expireDate");
|
|
6013
|
+
throw new Error(`登录失败,系统授权已于${expireDate}过期。`);
|
|
6014
|
+
}
|
|
6003
6015
|
const userDataAccessor = server.getDataAccessor({
|
|
6004
6016
|
singularCode: "oc_user",
|
|
6005
6017
|
});
|
|
@@ -6039,12 +6051,12 @@ async function handler$c(plugin, ctx, options) {
|
|
|
6039
6051
|
|
|
6040
6052
|
var createSession = /*#__PURE__*/Object.freeze({
|
|
6041
6053
|
__proto__: null,
|
|
6042
|
-
code: code$
|
|
6043
|
-
handler: handler$
|
|
6054
|
+
code: code$d,
|
|
6055
|
+
handler: handler$d
|
|
6044
6056
|
});
|
|
6045
6057
|
|
|
6046
|
-
const code$
|
|
6047
|
-
async function handler$
|
|
6058
|
+
const code$c = "deleteSession";
|
|
6059
|
+
async function handler$c(plugin, ctx, options) {
|
|
6048
6060
|
const { server, input, routerContext } = ctx;
|
|
6049
6061
|
const { response } = routerContext;
|
|
6050
6062
|
setCookie(response.headers, {
|
|
@@ -6057,12 +6069,12 @@ async function handler$b(plugin, ctx, options) {
|
|
|
6057
6069
|
|
|
6058
6070
|
var deleteSession = /*#__PURE__*/Object.freeze({
|
|
6059
6071
|
__proto__: null,
|
|
6060
|
-
code: code$
|
|
6061
|
-
handler: handler$
|
|
6072
|
+
code: code$c,
|
|
6073
|
+
handler: handler$c
|
|
6062
6074
|
});
|
|
6063
6075
|
|
|
6064
|
-
const code$
|
|
6065
|
-
async function handler$
|
|
6076
|
+
const code$b = "getMyProfile";
|
|
6077
|
+
async function handler$b(plugin, ctx, options) {
|
|
6066
6078
|
const { server, input, routerContext } = ctx;
|
|
6067
6079
|
const userId = routerContext.state.userId;
|
|
6068
6080
|
if (!userId) {
|
|
@@ -6092,12 +6104,12 @@ async function handler$a(plugin, ctx, options) {
|
|
|
6092
6104
|
|
|
6093
6105
|
var getMyProfile$2 = /*#__PURE__*/Object.freeze({
|
|
6094
6106
|
__proto__: null,
|
|
6095
|
-
code: code$
|
|
6096
|
-
handler: handler$
|
|
6107
|
+
code: code$b,
|
|
6108
|
+
handler: handler$b
|
|
6097
6109
|
});
|
|
6098
6110
|
|
|
6099
|
-
const code$
|
|
6100
|
-
async function handler$
|
|
6111
|
+
const code$a = "resetPassword";
|
|
6112
|
+
async function handler$a(plugin, ctx, options) {
|
|
6101
6113
|
const { server, input, routerContext } = ctx;
|
|
6102
6114
|
const { userId, password } = input;
|
|
6103
6115
|
const userDataAccessor = server.getDataAccessor({
|
|
@@ -6125,11 +6137,11 @@ async function handler$9(plugin, ctx, options) {
|
|
|
6125
6137
|
|
|
6126
6138
|
var resetPassword$1 = /*#__PURE__*/Object.freeze({
|
|
6127
6139
|
__proto__: null,
|
|
6128
|
-
code: code$
|
|
6129
|
-
handler: handler$
|
|
6140
|
+
code: code$a,
|
|
6141
|
+
handler: handler$a
|
|
6130
6142
|
});
|
|
6131
6143
|
|
|
6132
|
-
var pluginActionHandlers$
|
|
6144
|
+
var pluginActionHandlers$7 = [changePassword$1, createSession, deleteSession, getMyProfile$2, resetPassword$1];
|
|
6133
6145
|
|
|
6134
6146
|
var AccessToken = {
|
|
6135
6147
|
maintainedBy: "authManager",
|
|
@@ -6186,7 +6198,7 @@ var AccessToken = {
|
|
|
6186
6198
|
],
|
|
6187
6199
|
};
|
|
6188
6200
|
|
|
6189
|
-
var pluginModels$
|
|
6201
|
+
var pluginModels$5 = [AccessToken];
|
|
6190
6202
|
|
|
6191
6203
|
var changePassword = {
|
|
6192
6204
|
namespace: "auth",
|
|
@@ -6258,7 +6270,7 @@ var signout$1 = {
|
|
|
6258
6270
|
],
|
|
6259
6271
|
};
|
|
6260
6272
|
|
|
6261
|
-
var pluginRoutes$
|
|
6273
|
+
var pluginRoutes$7 = [changePassword, getMyProfile$1, resetPassword, signin$1, signout$1];
|
|
6262
6274
|
|
|
6263
6275
|
/**
|
|
6264
6276
|
* Auth manager plugin
|
|
@@ -6280,15 +6292,15 @@ class AuthPlugin {
|
|
|
6280
6292
|
return [];
|
|
6281
6293
|
}
|
|
6282
6294
|
async registerActionHandlers(server) {
|
|
6283
|
-
for (const actionHandler of pluginActionHandlers$
|
|
6295
|
+
for (const actionHandler of pluginActionHandlers$7) {
|
|
6284
6296
|
server.registerActionHandler(this, actionHandler);
|
|
6285
6297
|
}
|
|
6286
6298
|
}
|
|
6287
6299
|
async configureModels(server, applicationConfig) {
|
|
6288
|
-
server.appendApplicationConfig({ models: pluginModels$
|
|
6300
|
+
server.appendApplicationConfig({ models: pluginModels$5 });
|
|
6289
6301
|
}
|
|
6290
6302
|
async configureRoutes(server, applicationConfig) {
|
|
6291
|
-
server.appendApplicationConfig({ routes: pluginRoutes$
|
|
6303
|
+
server.appendApplicationConfig({ routes: pluginRoutes$7 });
|
|
6292
6304
|
}
|
|
6293
6305
|
async onPrepareRouteContext(server, routeContext) {
|
|
6294
6306
|
const request = routeContext.request;
|
|
@@ -6349,8 +6361,8 @@ function getFileBaseName(pathname) {
|
|
|
6349
6361
|
return path__default["default"].basename(pathname, extName);
|
|
6350
6362
|
}
|
|
6351
6363
|
|
|
6352
|
-
const code$
|
|
6353
|
-
async function handler$
|
|
6364
|
+
const code$9 = "downloadDocument";
|
|
6365
|
+
async function handler$9(plugin, ctx, options) {
|
|
6354
6366
|
const { server, applicationConfig, routerContext, input } = ctx;
|
|
6355
6367
|
const { request, response } = routerContext;
|
|
6356
6368
|
const documentDataAccessor = ctx.server.getDataAccessor({
|
|
@@ -6406,12 +6418,12 @@ async function handler$8(plugin, ctx, options) {
|
|
|
6406
6418
|
|
|
6407
6419
|
var downloadDocumentActionHandler = /*#__PURE__*/Object.freeze({
|
|
6408
6420
|
__proto__: null,
|
|
6409
|
-
code: code$
|
|
6410
|
-
handler: handler$
|
|
6421
|
+
code: code$9,
|
|
6422
|
+
handler: handler$9
|
|
6411
6423
|
});
|
|
6412
6424
|
|
|
6413
|
-
const code$
|
|
6414
|
-
async function handler$
|
|
6425
|
+
const code$8 = "downloadFile";
|
|
6426
|
+
async function handler$8(plugin, ctx, options) {
|
|
6415
6427
|
const { server, applicationConfig, routerContext } = ctx;
|
|
6416
6428
|
const { request, response } = routerContext;
|
|
6417
6429
|
//TODO: only public files can download by this handler
|
|
@@ -6437,12 +6449,12 @@ async function handler$7(plugin, ctx, options) {
|
|
|
6437
6449
|
|
|
6438
6450
|
var downloadFileActionHandler = /*#__PURE__*/Object.freeze({
|
|
6439
6451
|
__proto__: null,
|
|
6440
|
-
code: code$
|
|
6441
|
-
handler: handler$
|
|
6452
|
+
code: code$8,
|
|
6453
|
+
handler: handler$8
|
|
6442
6454
|
});
|
|
6443
6455
|
|
|
6444
|
-
const code$
|
|
6445
|
-
async function handler$
|
|
6456
|
+
const code$7 = "uploadFile";
|
|
6457
|
+
async function handler$7(plugin, ctx, options) {
|
|
6446
6458
|
const { server, applicationConfig, routerContext, input } = ctx;
|
|
6447
6459
|
let file = input.file || input.files;
|
|
6448
6460
|
if (lodash.isArray(file)) {
|
|
@@ -6463,8 +6475,8 @@ async function handler$6(plugin, ctx, options) {
|
|
|
6463
6475
|
|
|
6464
6476
|
var uploadFileActionHandler = /*#__PURE__*/Object.freeze({
|
|
6465
6477
|
__proto__: null,
|
|
6466
|
-
code: code$
|
|
6467
|
-
handler: handler$
|
|
6478
|
+
code: code$7,
|
|
6479
|
+
handler: handler$7
|
|
6468
6480
|
});
|
|
6469
6481
|
|
|
6470
6482
|
var getMyProfile = {
|
|
@@ -6509,7 +6521,7 @@ var signout = {
|
|
|
6509
6521
|
],
|
|
6510
6522
|
};
|
|
6511
6523
|
|
|
6512
|
-
var pluginRoutes$
|
|
6524
|
+
var pluginRoutes$6 = [getMyProfile, signin, signout];
|
|
6513
6525
|
|
|
6514
6526
|
/**
|
|
6515
6527
|
* File manager plugin
|
|
@@ -6535,9 +6547,206 @@ class FileManager {
|
|
|
6535
6547
|
server.registerActionHandler(this, downloadFileActionHandler);
|
|
6536
6548
|
server.registerActionHandler(this, uploadFileActionHandler);
|
|
6537
6549
|
}
|
|
6550
|
+
async configureRoutes(server, applicationConfig) {
|
|
6551
|
+
server.appendApplicationConfig({ routes: pluginRoutes$6 });
|
|
6552
|
+
}
|
|
6553
|
+
}
|
|
6554
|
+
|
|
6555
|
+
const code$6 = "getLicense";
|
|
6556
|
+
async function handler$6(plugin, ctx, options) {
|
|
6557
|
+
const { server, routerContext } = ctx;
|
|
6558
|
+
const licenseService = server.getService("licenseService");
|
|
6559
|
+
const license = licenseService.getLicense();
|
|
6560
|
+
ctx.output = license;
|
|
6561
|
+
}
|
|
6562
|
+
|
|
6563
|
+
var getLicense$1 = /*#__PURE__*/Object.freeze({
|
|
6564
|
+
__proto__: null,
|
|
6565
|
+
code: code$6,
|
|
6566
|
+
handler: handler$6
|
|
6567
|
+
});
|
|
6568
|
+
|
|
6569
|
+
var pluginActionHandlers$6 = [getLicense$1];
|
|
6570
|
+
|
|
6571
|
+
var pluginModels$4 = [];
|
|
6572
|
+
|
|
6573
|
+
var getLicense = {
|
|
6574
|
+
namespace: "svc",
|
|
6575
|
+
name: "svc.getLicense",
|
|
6576
|
+
code: "svc.getLicense",
|
|
6577
|
+
type: "RESTful",
|
|
6578
|
+
method: "GET",
|
|
6579
|
+
endpoint: "/svc/license",
|
|
6580
|
+
actions: [
|
|
6581
|
+
{
|
|
6582
|
+
code: "getLicense",
|
|
6583
|
+
},
|
|
6584
|
+
],
|
|
6585
|
+
};
|
|
6586
|
+
|
|
6587
|
+
var pluginRoutes$5 = [getLicense];
|
|
6588
|
+
|
|
6589
|
+
function getEncryptionIV(input) {
|
|
6590
|
+
const hash = crypto__default["default"].createHash("sha512").update(input).digest("hex");
|
|
6591
|
+
return hash.substring(0, 12);
|
|
6592
|
+
}
|
|
6593
|
+
function generatePubKeyFileContent(base64EncodedPubKey) {
|
|
6594
|
+
return `-----BEGIN PUBLIC KEY-----\n${base64EncodedPubKey}\n-----END PUBLIC KEY-----`;
|
|
6595
|
+
}
|
|
6596
|
+
const ENC_ALGORITHM = "aes-256-gcm";
|
|
6597
|
+
// Decrypt data
|
|
6598
|
+
function decryptData(encryptedData, encryptedDataEncoding, decryptedDataEncoding, encryptionKey, encryptionIV, authTag) {
|
|
6599
|
+
const decipher = crypto__default["default"].createDecipheriv(ENC_ALGORITHM, Buffer.from(encryptionKey, "base64"), encryptionIV);
|
|
6600
|
+
decipher.setAuthTag(Buffer.from(authTag, "base64"));
|
|
6601
|
+
const buff = Buffer.from(encryptedData, encryptedDataEncoding);
|
|
6602
|
+
return Buffer.concat([decipher.update(buff), decipher.final()]).toString(decryptedDataEncoding); // Decrypts data and converts to utf8
|
|
6603
|
+
}
|
|
6604
|
+
function validateDigitalSignature(data, dataEncoding, signature, signatureEncoding, publicKey) {
|
|
6605
|
+
const verify = crypto__default["default"].createVerify("RSA-SHA256");
|
|
6606
|
+
const buffer = Buffer.from(data, dataEncoding);
|
|
6607
|
+
verify.update(buffer);
|
|
6608
|
+
return verify.verify(publicKey, signature, signatureEncoding);
|
|
6609
|
+
}
|
|
6610
|
+
|
|
6611
|
+
function extractCertLicense(encryptionKey, deployId, cert) {
|
|
6612
|
+
const iv = getEncryptionIV(deployId);
|
|
6613
|
+
const signature = cert.sig;
|
|
6614
|
+
const pub = generatePubKeyFileContent(cert.pub);
|
|
6615
|
+
const valid = validateDigitalSignature(cert.lic, "base64", signature, "base64", pub);
|
|
6616
|
+
if (!valid) {
|
|
6617
|
+
throw new Error("Certification validate failed.");
|
|
6618
|
+
}
|
|
6619
|
+
try {
|
|
6620
|
+
const licenseText = decryptData(cert.lic, "base64", "utf-8", encryptionKey, iv, cert.tag);
|
|
6621
|
+
return JSON.parse(licenseText);
|
|
6622
|
+
}
|
|
6623
|
+
catch (ex) {
|
|
6624
|
+
throw new Error("Certification parse failed.", {
|
|
6625
|
+
cause: ex,
|
|
6626
|
+
});
|
|
6627
|
+
}
|
|
6628
|
+
}
|
|
6629
|
+
|
|
6630
|
+
class LicenseService {
|
|
6631
|
+
#server;
|
|
6632
|
+
#systemSettingItemManager;
|
|
6633
|
+
#encryptionKey;
|
|
6634
|
+
#license;
|
|
6635
|
+
constructor(server, encryptionKey) {
|
|
6636
|
+
this.#server = server;
|
|
6637
|
+
this.#encryptionKey = encryptionKey;
|
|
6638
|
+
this.#systemSettingItemManager = server.getEntityManager("system_setting_item");
|
|
6639
|
+
}
|
|
6640
|
+
async loadLicense() {
|
|
6641
|
+
const settingService = this.#server.getService("settingService");
|
|
6642
|
+
const licenseSettings = await settingService.getSystemSettingValues("license");
|
|
6643
|
+
const { deployId } = licenseSettings;
|
|
6644
|
+
const certText = licenseSettings.cert;
|
|
6645
|
+
const certJSON = Buffer.from(certText, "base64").toString();
|
|
6646
|
+
const cert = JSON.parse(certJSON);
|
|
6647
|
+
try {
|
|
6648
|
+
const license = extractCertLicense(this.#encryptionKey, deployId, cert);
|
|
6649
|
+
this.#license = license;
|
|
6650
|
+
}
|
|
6651
|
+
catch (error) {
|
|
6652
|
+
this.#server.getLogger().error("Loading license failed.", error);
|
|
6653
|
+
throw new Error("Loading license failed.");
|
|
6654
|
+
}
|
|
6655
|
+
}
|
|
6656
|
+
getLicense() {
|
|
6657
|
+
return this.#license;
|
|
6658
|
+
}
|
|
6659
|
+
isExpired() {
|
|
6660
|
+
if (!this.#license) {
|
|
6661
|
+
return true;
|
|
6662
|
+
}
|
|
6663
|
+
const { neverExpire, expireDate } = this.#license.authority;
|
|
6664
|
+
if (neverExpire) {
|
|
6665
|
+
return false;
|
|
6666
|
+
}
|
|
6667
|
+
if (!expireDate) {
|
|
6668
|
+
return true;
|
|
6669
|
+
}
|
|
6670
|
+
const today = dayjs__default["default"](dayjs__default["default"]().format("YYYY-MM-DD"));
|
|
6671
|
+
return today.isAfter(dayjs__default["default"](expireDate));
|
|
6672
|
+
}
|
|
6673
|
+
getQuota(name) {
|
|
6674
|
+
if (!this.#license) {
|
|
6675
|
+
return null;
|
|
6676
|
+
}
|
|
6677
|
+
return lodash.get(this.#license.authority, `quota.${name}`, null);
|
|
6678
|
+
}
|
|
6679
|
+
isOutOfQuota(name, currentAmount) {
|
|
6680
|
+
const quotaLimit = this.getQuota(name);
|
|
6681
|
+
if (isNullOrUndefinedOrEmpty(quotaLimit)) {
|
|
6682
|
+
return true;
|
|
6683
|
+
}
|
|
6684
|
+
let quotaLimitAmount = quotaLimit;
|
|
6685
|
+
if (lodash.isString(quotaLimitAmount)) {
|
|
6686
|
+
quotaLimitAmount = parseInt(quotaLimit, 10);
|
|
6687
|
+
}
|
|
6688
|
+
if (quotaLimitAmount === -1) {
|
|
6689
|
+
return true;
|
|
6690
|
+
}
|
|
6691
|
+
return currentAmount > quotaLimitAmount;
|
|
6692
|
+
}
|
|
6693
|
+
isFunctionAllowed(name) {
|
|
6694
|
+
if (!this.#license) {
|
|
6695
|
+
return false;
|
|
6696
|
+
}
|
|
6697
|
+
const functions = lodash.get(this.#license.authority, "functions", []);
|
|
6698
|
+
return functions.includes(name);
|
|
6699
|
+
}
|
|
6700
|
+
}
|
|
6701
|
+
|
|
6702
|
+
/**
|
|
6703
|
+
* License plugin
|
|
6704
|
+
*/
|
|
6705
|
+
class LicensePlugin {
|
|
6706
|
+
#licenseService;
|
|
6707
|
+
#encryptionKey;
|
|
6708
|
+
constructor(options) {
|
|
6709
|
+
if (!options.encryptionKey) {
|
|
6710
|
+
throw new Error(`"encryptionKey" must be provided.`);
|
|
6711
|
+
}
|
|
6712
|
+
this.#encryptionKey = options.encryptionKey;
|
|
6713
|
+
}
|
|
6714
|
+
get licenseService() {
|
|
6715
|
+
return this.#licenseService;
|
|
6716
|
+
}
|
|
6717
|
+
get code() {
|
|
6718
|
+
return "license";
|
|
6719
|
+
}
|
|
6720
|
+
get description() {
|
|
6721
|
+
return null;
|
|
6722
|
+
}
|
|
6723
|
+
get extendingAbilities() {
|
|
6724
|
+
return [];
|
|
6725
|
+
}
|
|
6726
|
+
get configurableTargets() {
|
|
6727
|
+
return [];
|
|
6728
|
+
}
|
|
6729
|
+
get configurations() {
|
|
6730
|
+
return [];
|
|
6731
|
+
}
|
|
6732
|
+
async registerActionHandlers(server) {
|
|
6733
|
+
for (const actionHandler of pluginActionHandlers$6) {
|
|
6734
|
+
server.registerActionHandler(this, actionHandler);
|
|
6735
|
+
}
|
|
6736
|
+
}
|
|
6737
|
+
async configureModels(server, applicationConfig) {
|
|
6738
|
+
server.appendApplicationConfig({ models: pluginModels$4 });
|
|
6739
|
+
}
|
|
6740
|
+
async configureServices(server, applicationConfig) {
|
|
6741
|
+
this.#licenseService = new LicenseService(server, this.#encryptionKey);
|
|
6742
|
+
server.registerService("licenseService", this.#licenseService);
|
|
6743
|
+
}
|
|
6538
6744
|
async configureRoutes(server, applicationConfig) {
|
|
6539
6745
|
server.appendApplicationConfig({ routes: pluginRoutes$5 });
|
|
6540
6746
|
}
|
|
6747
|
+
async onApplicationLoaded(server, applicationConfig) {
|
|
6748
|
+
await this.#licenseService.loadLicense();
|
|
6749
|
+
}
|
|
6541
6750
|
}
|
|
6542
6751
|
|
|
6543
6752
|
var pluginActionHandlers$5 = [];
|
|
@@ -6667,11 +6876,14 @@ var Notification = {
|
|
|
6667
6876
|
columnName: "details",
|
|
6668
6877
|
description: '{"url": "", "actions": [{"text": "", "url": ""}]}',
|
|
6669
6878
|
type: "json",
|
|
6879
|
+
required: false,
|
|
6670
6880
|
},
|
|
6671
6881
|
{
|
|
6672
6882
|
name: "用户",
|
|
6673
6883
|
code: "user",
|
|
6674
6884
|
type: "relation",
|
|
6885
|
+
required: false,
|
|
6886
|
+
relation: "one",
|
|
6675
6887
|
targetSingularCode: "oc_user",
|
|
6676
6888
|
targetIdColumnName: "user_id",
|
|
6677
6889
|
},
|
|
@@ -6986,6 +7198,12 @@ var SystemSettingItem = {
|
|
|
6986
7198
|
required: false,
|
|
6987
7199
|
},
|
|
6988
7200
|
],
|
|
7201
|
+
indexes: [
|
|
7202
|
+
{
|
|
7203
|
+
unique: true,
|
|
7204
|
+
properties: ["groupCode", "itemCode"],
|
|
7205
|
+
},
|
|
7206
|
+
],
|
|
6989
7207
|
};
|
|
6990
7208
|
|
|
6991
7209
|
var SystemSettingItemSetting = {
|
|
@@ -7162,6 +7380,12 @@ var UserSettingItem = {
|
|
|
7162
7380
|
required: false,
|
|
7163
7381
|
},
|
|
7164
7382
|
],
|
|
7383
|
+
indexes: [
|
|
7384
|
+
{
|
|
7385
|
+
unique: true,
|
|
7386
|
+
properties: ["ownerId", "groupCode", "itemCode"],
|
|
7387
|
+
},
|
|
7388
|
+
],
|
|
7165
7389
|
};
|
|
7166
7390
|
|
|
7167
7391
|
var UserSettingItemSetting = {
|
|
@@ -8009,9 +8233,9 @@ class EntityAccessControlPlugin {
|
|
|
8009
8233
|
if (!userId) {
|
|
8010
8234
|
return;
|
|
8011
8235
|
}
|
|
8012
|
-
const actions = await server.queryDatabaseObject(`select distinct a.* from sys_actions a
|
|
8013
|
-
inner join oc_role_sys_action_links ra on a.id = ra.action_id
|
|
8014
|
-
inner join oc_role_user_links ru on ru.role_id = ra.role_id
|
|
8236
|
+
const actions = await server.queryDatabaseObject(`select distinct a.* from sys_actions a
|
|
8237
|
+
inner join oc_role_sys_action_links ra on a.id = ra.action_id
|
|
8238
|
+
inner join oc_role_user_links ru on ru.role_id = ra.role_id
|
|
8015
8239
|
where ru.user_id = $1;`, [userId]);
|
|
8016
8240
|
routeContext.state.allowedActions = actions.map((item) => item.code);
|
|
8017
8241
|
}
|
|
@@ -8038,6 +8262,7 @@ exports.DataManagePlugin = DataManager;
|
|
|
8038
8262
|
exports.EntityAccessControlPlugin = EntityAccessControlPlugin;
|
|
8039
8263
|
exports.FileManagePlugin = FileManager;
|
|
8040
8264
|
exports.GlobalRequest = GlobalRequest;
|
|
8265
|
+
exports.LicensePlugin = LicensePlugin;
|
|
8041
8266
|
exports.MailPlugin = MailPlugin;
|
|
8042
8267
|
exports.MetaManagePlugin = MetaManager;
|
|
8043
8268
|
exports.NotificationPlugin = SequencePlugin;
|