prostgles-server 4.2.187 → 4.2.189
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/.eslintignore +2 -1
- package/.eslintrc.json +2 -0
- package/dist/Auth/AuthHandler.d.ts +20 -11
- package/dist/Auth/AuthHandler.d.ts.map +1 -1
- package/dist/Auth/AuthHandler.js +98 -120
- package/dist/Auth/AuthHandler.js.map +1 -1
- package/dist/Auth/AuthTypes.d.ts +69 -71
- package/dist/Auth/AuthTypes.d.ts.map +1 -1
- package/dist/Auth/{setEmailProvider.d.ts → authProviders/setEmailProvider.d.ts} +1 -1
- package/dist/Auth/authProviders/setEmailProvider.d.ts.map +1 -0
- package/dist/Auth/authProviders/setEmailProvider.js +27 -0
- package/dist/Auth/authProviders/setEmailProvider.js.map +1 -0
- package/dist/Auth/authProviders/setOAuthProviders.d.ts +5 -0
- package/dist/Auth/authProviders/setOAuthProviders.d.ts.map +1 -0
- package/dist/Auth/authProviders/setOAuthProviders.js +78 -0
- package/dist/Auth/authProviders/setOAuthProviders.js.map +1 -0
- package/dist/Auth/endpoints/getConfirmEmailRequestHandler.d.ts +7 -0
- package/dist/Auth/endpoints/getConfirmEmailRequestHandler.d.ts.map +1 -0
- package/dist/Auth/endpoints/getConfirmEmailRequestHandler.js +29 -0
- package/dist/Auth/endpoints/getConfirmEmailRequestHandler.js.map +1 -0
- package/dist/Auth/endpoints/getRegisterRequestHandler.d.ts +7 -0
- package/dist/Auth/endpoints/getRegisterRequestHandler.d.ts.map +1 -0
- package/dist/Auth/endpoints/getRegisterRequestHandler.js +77 -0
- package/dist/Auth/endpoints/getRegisterRequestHandler.js.map +1 -0
- package/dist/Auth/setAuthProviders.d.ts.map +1 -1
- package/dist/Auth/setAuthProviders.js +4 -74
- package/dist/Auth/setAuthProviders.js.map +1 -1
- package/dist/Auth/setupAuthRoutes.d.ts.map +1 -1
- package/dist/Auth/setupAuthRoutes.js +23 -33
- package/dist/Auth/setupAuthRoutes.js.map +1 -1
- package/dist/Auth/utils/checkDmarc.d.ts +2 -0
- package/dist/Auth/utils/checkDmarc.d.ts.map +1 -0
- package/dist/Auth/utils/checkDmarc.js +22 -0
- package/dist/Auth/utils/checkDmarc.js.map +1 -0
- package/dist/Auth/utils/getClientRequestIPsInfo.d.ts +3 -0
- package/dist/Auth/utils/getClientRequestIPsInfo.d.ts.map +1 -0
- package/dist/Auth/utils/getClientRequestIPsInfo.js +29 -0
- package/dist/Auth/utils/getClientRequestIPsInfo.js.map +1 -0
- package/dist/Auth/utils/getReturnUrl.d.ts +3 -0
- package/dist/Auth/utils/getReturnUrl.d.ts.map +1 -0
- package/dist/Auth/utils/getReturnUrl.js +15 -0
- package/dist/Auth/utils/getReturnUrl.js.map +1 -0
- package/dist/Auth/utils/getSafeReturnURL.d.ts.map +1 -0
- package/dist/Auth/utils/getSafeReturnURL.js.map +1 -0
- package/dist/DBEventsManager.d.ts.map +1 -1
- package/dist/DBEventsManager.js +4 -5
- package/dist/DBEventsManager.js.map +1 -1
- package/dist/DBSchemaBuilder.js +1 -1
- package/dist/DBSchemaBuilder.js.map +1 -1
- package/dist/DboBuilder/DboBuilder.d.ts +0 -1
- package/dist/DboBuilder/DboBuilder.d.ts.map +1 -1
- package/dist/DboBuilder/DboBuilder.js +3 -12
- package/dist/DboBuilder/DboBuilder.js.map +1 -1
- package/dist/DboBuilder/DboBuilderTypes.d.ts +4 -4
- package/dist/DboBuilder/DboBuilderTypes.d.ts.map +1 -1
- package/dist/DboBuilder/DboBuilderTypes.js.map +1 -1
- package/dist/DboBuilder/QueryBuilder/Functions.d.ts.map +1 -1
- package/dist/DboBuilder/QueryBuilder/Functions.js +38 -76
- package/dist/DboBuilder/QueryBuilder/Functions.js.map +1 -1
- package/dist/DboBuilder/QueryBuilder/QueryBuilder.d.ts.map +1 -1
- package/dist/DboBuilder/QueryBuilder/QueryBuilder.js +4 -12
- package/dist/DboBuilder/QueryBuilder/QueryBuilder.js.map +1 -1
- package/dist/DboBuilder/QueryBuilder/getNewQuery.d.ts.map +1 -1
- package/dist/DboBuilder/QueryBuilder/getNewQuery.js +23 -33
- package/dist/DboBuilder/QueryBuilder/getNewQuery.js.map +1 -1
- package/dist/DboBuilder/QueryBuilder/getSelectQuery.d.ts +1 -1
- package/dist/DboBuilder/QueryBuilder/getSelectQuery.d.ts.map +1 -1
- package/dist/DboBuilder/QueryBuilder/getSelectQuery.js +6 -6
- package/dist/DboBuilder/QueryBuilder/getSelectQuery.js.map +1 -1
- package/dist/DboBuilder/QueryStreamer.d.ts.map +1 -1
- package/dist/DboBuilder/QueryStreamer.js +13 -19
- package/dist/DboBuilder/QueryStreamer.js.map +1 -1
- package/dist/DboBuilder/TableHandler/DataValidator.d.ts +1 -1
- package/dist/DboBuilder/TableHandler/DataValidator.d.ts.map +1 -1
- package/dist/DboBuilder/TableHandler/DataValidator.js +7 -16
- package/dist/DboBuilder/TableHandler/DataValidator.js.map +1 -1
- package/dist/DboBuilder/TableHandler/TableHandler.d.ts.map +1 -1
- package/dist/DboBuilder/TableHandler/TableHandler.js +7 -5
- package/dist/DboBuilder/TableHandler/TableHandler.js.map +1 -1
- package/dist/DboBuilder/TableHandler/delete.d.ts.map +1 -1
- package/dist/DboBuilder/TableHandler/delete.js +5 -8
- package/dist/DboBuilder/TableHandler/delete.js.map +1 -1
- package/dist/DboBuilder/TableHandler/insert.d.ts.map +1 -1
- package/dist/DboBuilder/TableHandler/insert.js +10 -15
- package/dist/DboBuilder/TableHandler/insert.js.map +1 -1
- package/dist/DboBuilder/TableHandler/insertTest.js +1 -1
- package/dist/DboBuilder/TableHandler/insertTest.js.map +1 -1
- package/dist/DboBuilder/TableHandler/runInsertUpdateQuery.d.ts.map +1 -1
- package/dist/DboBuilder/TableHandler/runInsertUpdateQuery.js +1 -1
- package/dist/DboBuilder/TableHandler/runInsertUpdateQuery.js.map +1 -1
- package/dist/DboBuilder/TableHandler/update.d.ts.map +1 -1
- package/dist/DboBuilder/TableHandler/update.js +5 -9
- package/dist/DboBuilder/TableHandler/update.js.map +1 -1
- package/dist/DboBuilder/TableHandler/updateFile.d.ts +1 -1
- package/dist/DboBuilder/TableHandler/updateFile.d.ts.map +1 -1
- package/dist/DboBuilder/TableHandler/updateFile.js +7 -9
- package/dist/DboBuilder/TableHandler/updateFile.js.map +1 -1
- package/dist/DboBuilder/TableHandler/upsert.d.ts.map +1 -1
- package/dist/DboBuilder/TableHandler/upsert.js +1 -1
- package/dist/DboBuilder/TableHandler/upsert.js.map +1 -1
- package/dist/DboBuilder/ViewHandler/ViewHandler.d.ts.map +1 -1
- package/dist/DboBuilder/ViewHandler/ViewHandler.js +11 -13
- package/dist/DboBuilder/ViewHandler/ViewHandler.js.map +1 -1
- package/dist/DboBuilder/ViewHandler/count.js +1 -1
- package/dist/DboBuilder/ViewHandler/count.js.map +1 -1
- package/dist/DboBuilder/ViewHandler/find.d.ts.map +1 -1
- package/dist/DboBuilder/ViewHandler/find.js +20 -27
- package/dist/DboBuilder/ViewHandler/find.js.map +1 -1
- package/dist/DboBuilder/ViewHandler/getExistsCondition.d.ts.map +1 -1
- package/dist/DboBuilder/ViewHandler/getExistsCondition.js +4 -10
- package/dist/DboBuilder/ViewHandler/getExistsCondition.js.map +1 -1
- package/dist/DboBuilder/ViewHandler/getInfo.js +2 -2
- package/dist/DboBuilder/ViewHandler/getInfo.js.map +1 -1
- package/dist/DboBuilder/ViewHandler/getTableJoinQuery.d.ts.map +1 -1
- package/dist/DboBuilder/ViewHandler/getTableJoinQuery.js +6 -22
- package/dist/DboBuilder/ViewHandler/getTableJoinQuery.js.map +1 -1
- package/dist/DboBuilder/ViewHandler/parseFieldFilter.d.ts.map +1 -1
- package/dist/DboBuilder/ViewHandler/parseFieldFilter.js +6 -10
- package/dist/DboBuilder/ViewHandler/parseFieldFilter.js.map +1 -1
- package/dist/DboBuilder/ViewHandler/parseJoinPath.d.ts.map +1 -1
- package/dist/DboBuilder/ViewHandler/parseJoinPath.js +8 -11
- package/dist/DboBuilder/ViewHandler/parseJoinPath.js.map +1 -1
- package/dist/DboBuilder/ViewHandler/prepareSortItems.d.ts.map +1 -1
- package/dist/DboBuilder/ViewHandler/prepareSortItems.js +7 -12
- package/dist/DboBuilder/ViewHandler/prepareSortItems.js.map +1 -1
- package/dist/DboBuilder/ViewHandler/prepareWhere.d.ts.map +1 -1
- package/dist/DboBuilder/ViewHandler/prepareWhere.js +6 -10
- package/dist/DboBuilder/ViewHandler/prepareWhere.js.map +1 -1
- package/dist/DboBuilder/dboBuilderUtils.d.ts.map +1 -1
- package/dist/DboBuilder/dboBuilderUtils.js +8 -23
- package/dist/DboBuilder/dboBuilderUtils.js.map +1 -1
- package/dist/DboBuilder/getColumns.d.ts.map +1 -1
- package/dist/DboBuilder/getColumns.js +19 -26
- package/dist/DboBuilder/getColumns.js.map +1 -1
- package/dist/DboBuilder/getCondition.d.ts.map +1 -1
- package/dist/DboBuilder/getCondition.js +7 -9
- package/dist/DboBuilder/getCondition.js.map +1 -1
- package/dist/DboBuilder/getSubscribeRelatedTables.js +2 -2
- package/dist/DboBuilder/getSubscribeRelatedTables.js.map +1 -1
- package/dist/DboBuilder/getTablesForSchemaPostgresSQL.d.ts.map +1 -1
- package/dist/DboBuilder/getTablesForSchemaPostgresSQL.js +14 -15
- package/dist/DboBuilder/getTablesForSchemaPostgresSQL.js.map +1 -1
- package/dist/DboBuilder/insertNestedRecords.d.ts.map +1 -1
- package/dist/DboBuilder/insertNestedRecords.js +26 -40
- package/dist/DboBuilder/insertNestedRecords.js.map +1 -1
- package/dist/DboBuilder/parseUpdateRules.js +1 -1
- package/dist/DboBuilder/parseUpdateRules.js.map +1 -1
- package/dist/DboBuilder/prepareShortestJoinPaths.d.ts.map +1 -1
- package/dist/DboBuilder/prepareShortestJoinPaths.js +12 -18
- package/dist/DboBuilder/prepareShortestJoinPaths.js.map +1 -1
- package/dist/DboBuilder/runSQL.d.ts +1 -1
- package/dist/DboBuilder/runSQL.d.ts.map +1 -1
- package/dist/DboBuilder/runSQL.js +14 -27
- package/dist/DboBuilder/runSQL.js.map +1 -1
- package/dist/DboBuilder/uploadFile.d.ts +1 -1
- package/dist/DboBuilder/uploadFile.d.ts.map +1 -1
- package/dist/DboBuilder/uploadFile.js +4 -11
- package/dist/DboBuilder/uploadFile.js.map +1 -1
- package/dist/FileManager/FileManager.d.ts.map +1 -1
- package/dist/FileManager/FileManager.js +11 -13
- package/dist/FileManager/FileManager.js.map +1 -1
- package/dist/FileManager/initFileManager.d.ts.map +1 -1
- package/dist/FileManager/initFileManager.js +60 -62
- package/dist/FileManager/initFileManager.js.map +1 -1
- package/dist/FileManager/uploadStream.js +2 -2
- package/dist/FileManager/uploadStream.js.map +1 -1
- package/dist/Filtering.d.ts +1 -1
- package/dist/Filtering.d.ts.map +1 -1
- package/dist/Filtering.js +12 -35
- package/dist/Filtering.js.map +1 -1
- package/dist/JSONBValidation/validation.d.ts.map +1 -1
- package/dist/JSONBValidation/validation.js +20 -26
- package/dist/JSONBValidation/validation.js.map +1 -1
- package/dist/Logging.d.ts +1 -0
- package/dist/Logging.d.ts.map +1 -1
- package/dist/PostgresNotifListenManager.d.ts.map +1 -1
- package/dist/PostgresNotifListenManager.js +1 -5
- package/dist/PostgresNotifListenManager.js.map +1 -1
- package/dist/Prostgles.d.ts +1 -1
- package/dist/Prostgles.d.ts.map +1 -1
- package/dist/Prostgles.js +18 -33
- package/dist/Prostgles.js.map +1 -1
- package/dist/PubSubManager/PubSubManager.d.ts.map +1 -1
- package/dist/PubSubManager/PubSubManager.js +8 -13
- package/dist/PubSubManager/PubSubManager.js.map +1 -1
- package/dist/PubSubManager/addSub.d.ts.map +1 -1
- package/dist/PubSubManager/addSub.js +1 -1
- package/dist/PubSubManager/addSub.js.map +1 -1
- package/dist/PubSubManager/addSync.d.ts.map +1 -1
- package/dist/PubSubManager/addSync.js +4 -7
- package/dist/PubSubManager/addSync.js.map +1 -1
- package/dist/PubSubManager/getCreatePubSubManagerError.js +6 -6
- package/dist/PubSubManager/getCreatePubSubManagerError.js.map +1 -1
- package/dist/PubSubManager/initPubSubManager.d.ts.map +1 -1
- package/dist/PubSubManager/initPubSubManager.js +2 -3
- package/dist/PubSubManager/initPubSubManager.js.map +1 -1
- package/dist/PubSubManager/pushSubData.d.ts.map +1 -1
- package/dist/PubSubManager/pushSubData.js +0 -2
- package/dist/PubSubManager/pushSubData.js.map +1 -1
- package/dist/PublishParser/PublishParser.d.ts.map +1 -1
- package/dist/PublishParser/PublishParser.js +8 -13
- package/dist/PublishParser/PublishParser.js.map +1 -1
- package/dist/PublishParser/getFileTableRules.js +1 -1
- package/dist/PublishParser/getFileTableRules.js.map +1 -1
- package/dist/PublishParser/getSchemaFromPublish.d.ts.map +1 -1
- package/dist/PublishParser/getSchemaFromPublish.js +6 -13
- package/dist/PublishParser/getSchemaFromPublish.js.map +1 -1
- package/dist/PublishParser/getTableRulesWithoutFileTable.d.ts.map +1 -1
- package/dist/PublishParser/getTableRulesWithoutFileTable.js +14 -19
- package/dist/PublishParser/getTableRulesWithoutFileTable.js.map +1 -1
- package/dist/RestApi.d.ts +1 -1
- package/dist/RestApi.d.ts.map +1 -1
- package/dist/RestApi.js +2 -2
- package/dist/RestApi.js.map +1 -1
- package/dist/SchemaWatch/SchemaWatch.d.ts.map +1 -1
- package/dist/SchemaWatch/SchemaWatch.js +2 -2
- package/dist/SchemaWatch/SchemaWatch.js.map +1 -1
- package/dist/SyncReplication.d.ts.map +1 -1
- package/dist/SyncReplication.js +31 -41
- package/dist/SyncReplication.js.map +1 -1
- package/dist/TableConfig/TableConfig.d.ts.map +1 -1
- package/dist/TableConfig/TableConfig.js +7 -9
- package/dist/TableConfig/TableConfig.js.map +1 -1
- package/dist/TableConfig/getConstraintDefinitionQueries.d.ts.map +1 -1
- package/dist/TableConfig/getConstraintDefinitionQueries.js +1 -6
- package/dist/TableConfig/getConstraintDefinitionQueries.js.map +1 -1
- package/dist/TableConfig/getFutureTableSchema.d.ts.map +1 -1
- package/dist/TableConfig/getFutureTableSchema.js +16 -28
- package/dist/TableConfig/getFutureTableSchema.js.map +1 -1
- package/dist/TableConfig/getTableColumnQueries.d.ts.map +1 -1
- package/dist/TableConfig/getTableColumnQueries.js +5 -9
- package/dist/TableConfig/getTableColumnQueries.js.map +1 -1
- package/dist/TableConfig/initTableConfig.d.ts.map +1 -1
- package/dist/TableConfig/initTableConfig.js +22 -25
- package/dist/TableConfig/initTableConfig.js.map +1 -1
- package/dist/initProstgles.js +1 -1
- package/dist/initProstgles.js.map +1 -1
- package/dist/onSocketConnected.d.ts.map +1 -1
- package/dist/onSocketConnected.js +2 -4
- package/dist/onSocketConnected.js.map +1 -1
- package/dist/runClientRequest.d.ts.map +1 -1
- package/dist/runClientRequest.js +14 -13
- package/dist/runClientRequest.js.map +1 -1
- package/lib/Auth/AuthHandler.ts +114 -135
- package/lib/Auth/AuthTypes.ts +96 -81
- package/lib/Auth/authProviders/setEmailProvider.ts +29 -0
- package/lib/Auth/authProviders/setOAuthProviders.ts +97 -0
- package/lib/Auth/endpoints/getConfirmEmailRequestHandler.ts +39 -0
- package/lib/Auth/endpoints/getRegisterRequestHandler.ts +88 -0
- package/lib/Auth/setAuthProviders.ts +8 -111
- package/lib/Auth/setupAuthRoutes.ts +105 -148
- package/lib/Auth/utils/checkDmarc.ts +19 -0
- package/lib/Auth/utils/getClientRequestIPsInfo.ts +25 -0
- package/lib/Auth/utils/getReturnUrl.ts +13 -0
- package/lib/DBEventsManager.ts +12 -26
- package/lib/DBSchemaBuilder.ts +1 -1
- package/lib/DboBuilder/DboBuilder.ts +23 -52
- package/lib/DboBuilder/DboBuilderTypes.ts +9 -23
- package/lib/DboBuilder/QueryBuilder/Functions.ts +86 -188
- package/lib/DboBuilder/QueryBuilder/QueryBuilder.ts +11 -36
- package/lib/DboBuilder/QueryBuilder/getNewQuery.ts +102 -129
- package/lib/DboBuilder/QueryBuilder/getSelectQuery.ts +14 -27
- package/lib/DboBuilder/QueryStreamer.ts +26 -57
- package/lib/DboBuilder/TableHandler/DataValidator.ts +58 -90
- package/lib/DboBuilder/TableHandler/TableHandler.ts +19 -45
- package/lib/DboBuilder/TableHandler/delete.ts +9 -18
- package/lib/DboBuilder/TableHandler/insert.ts +18 -31
- package/lib/DboBuilder/TableHandler/insertTest.ts +1 -1
- package/lib/DboBuilder/TableHandler/runInsertUpdateQuery.ts +8 -19
- package/lib/DboBuilder/TableHandler/update.ts +17 -46
- package/lib/DboBuilder/TableHandler/updateFile.ts +18 -21
- package/lib/DboBuilder/TableHandler/upsert.ts +7 -24
- package/lib/DboBuilder/ViewHandler/ViewHandler.ts +13 -15
- package/lib/DboBuilder/ViewHandler/count.ts +1 -1
- package/lib/DboBuilder/ViewHandler/find.ts +28 -35
- package/lib/DboBuilder/ViewHandler/getExistsCondition.ts +8 -30
- package/lib/DboBuilder/ViewHandler/getInfo.ts +2 -2
- package/lib/DboBuilder/ViewHandler/getTableJoinQuery.ts +16 -32
- package/lib/DboBuilder/ViewHandler/parseFieldFilter.ts +9 -16
- package/lib/DboBuilder/ViewHandler/parseJoinPath.ts +26 -44
- package/lib/DboBuilder/ViewHandler/prepareSortItems.ts +58 -82
- package/lib/DboBuilder/ViewHandler/prepareWhere.ts +14 -27
- package/lib/DboBuilder/dboBuilderUtils.ts +19 -46
- package/lib/DboBuilder/getColumns.ts +24 -46
- package/lib/DboBuilder/getCondition.ts +18 -30
- package/lib/DboBuilder/getSubscribeRelatedTables.ts +2 -2
- package/lib/DboBuilder/getTablesForSchemaPostgresSQL.ts +44 -62
- package/lib/DboBuilder/insertNestedRecords.ts +67 -135
- package/lib/DboBuilder/parseUpdateRules.ts +1 -1
- package/lib/DboBuilder/prepareShortestJoinPaths.ts +23 -58
- package/lib/DboBuilder/runSQL.ts +41 -76
- package/lib/DboBuilder/uploadFile.ts +26 -37
- package/lib/FileManager/FileManager.ts +27 -58
- package/lib/FileManager/initFileManager.ts +68 -76
- package/lib/FileManager/uploadStream.ts +2 -2
- package/lib/Filtering.ts +30 -87
- package/lib/JSONBValidation/validation.ts +36 -75
- package/lib/Logging.ts +1 -1
- package/lib/PostgresNotifListenManager.ts +11 -35
- package/lib/Prostgles.ts +42 -100
- package/lib/PubSubManager/PubSubManager.ts +30 -66
- package/lib/PubSubManager/addSub.ts +11 -18
- package/lib/PubSubManager/addSync.ts +5 -12
- package/lib/PubSubManager/getCreatePubSubManagerError.ts +9 -9
- package/lib/PubSubManager/initPubSubManager.ts +7 -13
- package/lib/PubSubManager/pushSubData.ts +1 -7
- package/lib/PublishParser/PublishParser.ts +8 -12
- package/lib/PublishParser/getFileTableRules.ts +1 -1
- package/lib/PublishParser/getSchemaFromPublish.ts +26 -42
- package/lib/PublishParser/getTableRulesWithoutFileTable.ts +22 -37
- package/lib/RestApi.ts +4 -12
- package/lib/SchemaWatch/SchemaWatch.ts +11 -24
- package/lib/SyncReplication.ts +96 -190
- package/lib/TableConfig/TableConfig.ts +16 -38
- package/lib/TableConfig/getConstraintDefinitionQueries.ts +2 -8
- package/lib/TableConfig/getFutureTableSchema.ts +20 -34
- package/lib/TableConfig/getTableColumnQueries.ts +13 -35
- package/lib/TableConfig/initTableConfig.ts +40 -64
- package/lib/initProstgles.ts +1 -1
- package/lib/onSocketConnected.ts +8 -12
- package/lib/runClientRequest.ts +31 -54
- package/package.json +2 -2
- package/dist/Auth/getSafeReturnURL.d.ts.map +0 -1
- package/dist/Auth/getSafeReturnURL.js.map +0 -1
- package/dist/Auth/setEmailProvider.d.ts.map +0 -1
- package/dist/Auth/setEmailProvider.js +0 -133
- package/dist/Auth/setEmailProvider.js.map +0 -1
- package/dist/DboBuilder/runTransaction.d.ts +0 -9
- package/dist/DboBuilder/runTransaction.d.ts.map +0 -1
- package/dist/DboBuilder/runTransaction.js +0 -49
- package/dist/DboBuilder/runTransaction.js.map +0 -1
- package/lib/Auth/setEmailProvider.ts +0 -132
- package/lib/DboBuilder/QueryBuilder/prepareHaving.ts +0 -27
- package/lib/DboBuilder/runTransaction.ts +0 -61
- package/lib/SchemaWatch/createSchemaWatchEventTrigger.ts +0 -3
- /package/dist/Auth/{getSafeReturnURL.d.ts → utils/getSafeReturnURL.d.ts} +0 -0
- /package/dist/Auth/{getSafeReturnURL.js → utils/getSafeReturnURL.js} +0 -0
- /package/lib/Auth/{getSafeReturnURL.ts → utils/getSafeReturnURL.ts} +0 -0
|
@@ -21,13 +21,11 @@ export const find = async function (
|
|
|
21
21
|
selectParams?: SelectParams,
|
|
22
22
|
_?: undefined,
|
|
23
23
|
tableRules?: TableRule,
|
|
24
|
-
localParams?: LocalParams
|
|
24
|
+
localParams?: LocalParams
|
|
25
25
|
): Promise<any[]> {
|
|
26
26
|
const start = Date.now();
|
|
27
27
|
const command =
|
|
28
|
-
selectParams?.limit === 1 && selectParams
|
|
29
|
-
? "findOne"
|
|
30
|
-
: "find";
|
|
28
|
+
selectParams?.limit === 1 && selectParams.returnType === "row" ? "findOne" : "find";
|
|
31
29
|
try {
|
|
32
30
|
filter = filter || {};
|
|
33
31
|
const allowedReturnTypes = Object.keys({
|
|
@@ -59,9 +57,9 @@ export const find = async function (
|
|
|
59
57
|
} satisfies Record<keyof SelectParams, 1>);
|
|
60
58
|
|
|
61
59
|
const invalidParams = Object.keys(selectParams).filter(
|
|
62
|
-
(k) => !validParamNames.includes(k as any)
|
|
60
|
+
(k) => !validParamNames.includes(k as any)
|
|
63
61
|
);
|
|
64
|
-
if (invalidParams
|
|
62
|
+
if (invalidParams.length)
|
|
65
63
|
throw (
|
|
66
64
|
"Invalid params: " +
|
|
67
65
|
invalidParams.join(", ") +
|
|
@@ -88,53 +86,53 @@ export const find = async function (
|
|
|
88
86
|
}
|
|
89
87
|
if (maxLimit && !Number.isInteger(maxLimit)) {
|
|
90
88
|
throw (
|
|
91
|
-
` invalid publish.${this.name}.select.maxLimit -> expecting integer but got ` +
|
|
92
|
-
maxLimit
|
|
89
|
+
` invalid publish.${this.name}.select.maxLimit -> expecting integer but got ` + maxLimit
|
|
93
90
|
);
|
|
94
91
|
}
|
|
95
92
|
}
|
|
96
93
|
|
|
97
94
|
const _selectParams = selectParams ?? {};
|
|
98
95
|
const selectParamsLimitCheck =
|
|
99
|
-
localParams?.bypassLimit && !Number.isFinite(_selectParams.limit)
|
|
100
|
-
|
|
101
|
-
|
|
96
|
+
localParams?.bypassLimit && !Number.isFinite(_selectParams.limit) ?
|
|
97
|
+
{ ..._selectParams, limit: null }
|
|
98
|
+
: { limit: 1000, ..._selectParams };
|
|
102
99
|
const newQuery = await getNewQuery(
|
|
103
100
|
this,
|
|
104
101
|
filter,
|
|
105
102
|
selectParamsLimitCheck,
|
|
106
103
|
_,
|
|
107
104
|
tableRules,
|
|
108
|
-
localParams
|
|
105
|
+
localParams
|
|
109
106
|
);
|
|
110
107
|
|
|
111
108
|
const queryWithoutRLS = getSelectQuery(
|
|
112
109
|
this,
|
|
113
110
|
newQuery,
|
|
114
111
|
undefined,
|
|
115
|
-
!!selectParamsLimitCheck
|
|
112
|
+
!!selectParamsLimitCheck.groupBy
|
|
116
113
|
);
|
|
117
114
|
|
|
118
115
|
const queryWithRLS = withUserRLS(localParams, queryWithoutRLS);
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
116
|
+
// THIS HANGS TESTS
|
|
117
|
+
// if (testRule) {
|
|
118
|
+
// try {
|
|
119
|
+
// await this.db.any(withUserRLS(localParams, "EXPLAIN " + queryWithRLS));
|
|
120
|
+
// return [];
|
|
121
|
+
// } catch (e) {
|
|
122
|
+
// console.error(e);
|
|
123
|
+
// throw `Internal error: publish config is not valid for publish.${this.name}.select `;
|
|
124
|
+
// }
|
|
125
|
+
// }
|
|
128
126
|
|
|
129
127
|
/** Used for subscribe */
|
|
130
128
|
if (localParams?.returnNewQuery) return newQuery as unknown as any;
|
|
131
129
|
if (localParams?.returnQuery) {
|
|
132
|
-
if (localParams
|
|
130
|
+
if (localParams.returnQuery === "where-condition") {
|
|
133
131
|
return newQuery.whereOpts.condition as any;
|
|
134
132
|
}
|
|
135
|
-
return (localParams
|
|
136
|
-
|
|
137
|
-
|
|
133
|
+
return (localParams.returnQuery === "noRLS" ?
|
|
134
|
+
queryWithoutRLS
|
|
135
|
+
: queryWithRLS) as unknown as any[];
|
|
138
136
|
}
|
|
139
137
|
|
|
140
138
|
const result = await runQueryReturnType({
|
|
@@ -187,11 +185,7 @@ export const runQueryReturnType = async ({
|
|
|
187
185
|
returnType,
|
|
188
186
|
}: RunQueryReturnTypeArgs) => {
|
|
189
187
|
const query = queryWithRLS;
|
|
190
|
-
const sqlTypes = [
|
|
191
|
-
"statement",
|
|
192
|
-
"statement-no-rls",
|
|
193
|
-
"statement-where",
|
|
194
|
-
] as const;
|
|
188
|
+
const sqlTypes = ["statement", "statement-no-rls", "statement-where"] as const;
|
|
195
189
|
if (!returnType || returnType === "values") {
|
|
196
190
|
return handler.dbHandler
|
|
197
191
|
.any(query)
|
|
@@ -206,7 +200,7 @@ export const runQueryReturnType = async ({
|
|
|
206
200
|
type: "tableMethod",
|
|
207
201
|
localParams,
|
|
208
202
|
view: handler,
|
|
209
|
-
})
|
|
203
|
+
})
|
|
210
204
|
);
|
|
211
205
|
} else if (sqlTypes.some((v) => v === returnType)) {
|
|
212
206
|
if (!(await canRunSQL(handler.dboBuilder.prostgles, localParams))) {
|
|
@@ -216,8 +210,7 @@ export const runQueryReturnType = async ({
|
|
|
216
210
|
return queryWithoutRLS as any;
|
|
217
211
|
}
|
|
218
212
|
if (returnType === "statement-where") {
|
|
219
|
-
if (!newQuery)
|
|
220
|
-
throw `returnType ${returnType} not possible for this command type`;
|
|
213
|
+
if (!newQuery) throw `returnType ${returnType} not possible for this command type`;
|
|
221
214
|
return newQuery.whereOpts.condition as any;
|
|
222
215
|
}
|
|
223
216
|
return query as unknown as any[];
|
|
@@ -232,7 +225,7 @@ export const runQueryReturnType = async ({
|
|
|
232
225
|
type: "tableMethod",
|
|
233
226
|
localParams,
|
|
234
227
|
view: handler,
|
|
235
|
-
})
|
|
228
|
+
})
|
|
236
229
|
);
|
|
237
230
|
}
|
|
238
231
|
};
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AnyObject,
|
|
3
|
-
EXISTS_KEY,
|
|
4
|
-
EXISTS_KEYS,
|
|
5
|
-
FieldFilter,
|
|
6
|
-
asName,
|
|
7
|
-
} from "prostgles-types";
|
|
1
|
+
import { AnyObject, EXISTS_KEY, EXISTS_KEYS, FieldFilter, asName } from "prostgles-types";
|
|
8
2
|
import { LocalParams, ExistsFilterConfig } from "../DboBuilder";
|
|
9
3
|
import { ViewHandler } from "./ViewHandler";
|
|
10
4
|
import { TableRule } from "../../PublishParser/PublishParser";
|
|
@@ -14,22 +8,15 @@ import { getTableJoinQuery } from "./getTableJoinQuery";
|
|
|
14
8
|
export async function getExistsCondition(
|
|
15
9
|
this: ViewHandler,
|
|
16
10
|
eConfig: ExistsFilterConfig,
|
|
17
|
-
localParams: LocalParams | undefined
|
|
11
|
+
localParams: LocalParams | undefined
|
|
18
12
|
): Promise<string> {
|
|
19
13
|
const thisTable = this.name;
|
|
20
|
-
const isNotExists = ["$notExists", "$notExistsJoined"].includes(
|
|
21
|
-
eConfig.existType,
|
|
22
|
-
);
|
|
14
|
+
const isNotExists = ["$notExists", "$notExistsJoined"].includes(eConfig.existType);
|
|
23
15
|
|
|
24
16
|
const { targetTableFilter } = eConfig;
|
|
25
17
|
|
|
26
18
|
/* Nested $exists is not allowed */
|
|
27
|
-
if (
|
|
28
|
-
targetTableFilter &&
|
|
29
|
-
Object.keys(targetTableFilter).find((fk) =>
|
|
30
|
-
EXISTS_KEYS.includes(fk as EXISTS_KEY),
|
|
31
|
-
)
|
|
32
|
-
) {
|
|
19
|
+
if (Object.keys(targetTableFilter).find((fk) => EXISTS_KEYS.includes(fk as EXISTS_KEY))) {
|
|
33
20
|
throw {
|
|
34
21
|
stack: ["prepareExistCondition()"],
|
|
35
22
|
message: "Nested exists dissallowed",
|
|
@@ -42,25 +29,16 @@ export async function getExistsCondition(
|
|
|
42
29
|
tableAlias;
|
|
43
30
|
|
|
44
31
|
/* Check if allowed to view data - forcedFilters will bypass this check through isForcedFilterBypass */
|
|
45
|
-
if (
|
|
46
|
-
localParams?.isRemoteRequest &&
|
|
47
|
-
!localParams?.socket &&
|
|
48
|
-
!localParams?.httpReq
|
|
49
|
-
) {
|
|
32
|
+
if (localParams?.isRemoteRequest && !localParams.socket && !localParams.httpReq) {
|
|
50
33
|
throw "Unexpected: localParams isRemoteRequest and missing socket/httpReq: ";
|
|
51
34
|
}
|
|
52
|
-
const targetTable = eConfig.isJoined
|
|
53
|
-
|
|
54
|
-
: eConfig.targetTable;
|
|
55
|
-
if (
|
|
56
|
-
(localParams?.socket || localParams?.httpReq) &&
|
|
57
|
-
this.dboBuilder.publishParser
|
|
58
|
-
) {
|
|
35
|
+
const targetTable = eConfig.isJoined ? eConfig.parsedPath.at(-1)!.table : eConfig.targetTable;
|
|
36
|
+
if ((localParams?.socket || localParams?.httpReq) && this.dboBuilder.publishParser) {
|
|
59
37
|
t2Rules = (await this.dboBuilder.publishParser.getValidatedRequestRuleWusr({
|
|
60
38
|
tableName: targetTable,
|
|
61
39
|
command: "find",
|
|
62
40
|
localParams,
|
|
63
|
-
})) as TableRule;
|
|
41
|
+
})) as TableRule | undefined;
|
|
64
42
|
|
|
65
43
|
if (!t2Rules || !t2Rules.select) throw "Dissallowed";
|
|
66
44
|
({ forcedFilter, filterFields } = t2Rules.select);
|
|
@@ -23,7 +23,7 @@ export async function getInfo(
|
|
|
23
23
|
throw "Not allowed";
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
const fileTableName = this.dboBuilder.prostgles
|
|
26
|
+
const fileTableName = this.dboBuilder.prostgles.opts.fileTable?.tableName;
|
|
27
27
|
|
|
28
28
|
await this._log({
|
|
29
29
|
command: "getInfo",
|
|
@@ -37,7 +37,7 @@ export async function getInfo(
|
|
|
37
37
|
return {
|
|
38
38
|
oid: this.tableOrViewInfo.oid,
|
|
39
39
|
comment: this.tableOrViewInfo.comment,
|
|
40
|
-
info: this.dboBuilder.prostgles
|
|
40
|
+
info: this.dboBuilder.prostgles.tableConfigurator?.getTableInfo({
|
|
41
41
|
tableName: this.name,
|
|
42
42
|
lang,
|
|
43
43
|
}),
|
|
@@ -23,11 +23,9 @@ export const getTableJoinQuery = ({
|
|
|
23
23
|
|
|
24
24
|
const query = path
|
|
25
25
|
.map(({ table, on }, i) => {
|
|
26
|
-
if (!on) throw "on missing";
|
|
27
26
|
const tableName = table;
|
|
28
27
|
const tableAlias = getTableAlias(table, i);
|
|
29
|
-
const prevTableAlias =
|
|
30
|
-
i === 0 ? rootTableAlias : getTableAlias(path[i - 1]!.table, i - 1);
|
|
28
|
+
const prevTableAlias = i === 0 ? rootTableAlias : getTableAlias(path[i - 1]!.table, i - 1);
|
|
31
29
|
|
|
32
30
|
const onCondition = getJoinOnCondition({
|
|
33
31
|
on,
|
|
@@ -46,41 +44,27 @@ export const getTableJoinQuery = ({
|
|
|
46
44
|
* first path joins to target table through inner joins
|
|
47
45
|
*/
|
|
48
46
|
const whereJoinCondition =
|
|
49
|
-
isLast && isExists
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
47
|
+
isLast && isExists ?
|
|
48
|
+
`WHERE (${getJoinOnCondition({
|
|
49
|
+
on: firstPath.on,
|
|
50
|
+
leftAlias: rootTableAlias,
|
|
51
|
+
rightAlias: getTableAlias(firstPath.table, 0),
|
|
52
|
+
})})`
|
|
53
|
+
: "";
|
|
56
54
|
|
|
57
55
|
const tableSelect =
|
|
58
|
-
isExists && isLast
|
|
59
|
-
?
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
finalWhere ? ` WHERE ${finalWhere}` : "",
|
|
64
|
-
`)`,
|
|
65
|
-
]
|
|
66
|
-
.filter((v) => v)
|
|
67
|
-
.join("\n")
|
|
68
|
-
: tableName;
|
|
56
|
+
isExists && isLast ?
|
|
57
|
+
[`(`, ` SELECT *`, ` FROM ${tableName}`, finalWhere ? ` WHERE ${finalWhere}` : "", `)`]
|
|
58
|
+
.filter((v) => v)
|
|
59
|
+
.join("\n")
|
|
60
|
+
: tableName;
|
|
69
61
|
if (isExists && isFirst) {
|
|
70
|
-
return [
|
|
71
|
-
`SELECT 1`,
|
|
72
|
-
`FROM ${tableSelect} ${tableAlias}`,
|
|
73
|
-
whereJoinCondition,
|
|
74
|
-
]
|
|
62
|
+
return [`SELECT 1`, `FROM ${tableSelect} ${tableAlias}`, whereJoinCondition]
|
|
75
63
|
.filter((v) => v)
|
|
76
64
|
.join("\n");
|
|
77
65
|
}
|
|
78
66
|
|
|
79
|
-
return [
|
|
80
|
-
`${keyword} ${tableSelect} ${tableAlias}`,
|
|
81
|
-
` ON ${onCondition}`,
|
|
82
|
-
whereJoinCondition,
|
|
83
|
-
]
|
|
67
|
+
return [`${keyword} ${tableSelect} ${tableAlias}`, ` ON ${onCondition}`, whereJoinCondition]
|
|
84
68
|
.filter((v) => v)
|
|
85
69
|
.join("\n");
|
|
86
70
|
})
|
|
@@ -112,7 +96,7 @@ export const getJoinOnCondition = ({
|
|
|
112
96
|
.map(([leftCol, rightCol]) => {
|
|
113
97
|
return `${leftAlias}.${getLeftColName(leftCol)} = ${rightAlias}.${getRightColName(rightCol)}`;
|
|
114
98
|
})
|
|
115
|
-
.join(" AND ")
|
|
99
|
+
.join(" AND ")
|
|
116
100
|
)
|
|
117
101
|
.join(" OR ");
|
|
118
102
|
};
|
|
@@ -9,10 +9,8 @@ import { isPlainObject } from "../DboBuilder";
|
|
|
9
9
|
export const parseFieldFilter = <AllowedKeys extends string[]>(
|
|
10
10
|
fieldParams: FieldFilter<Record<AllowedKeys[number], any>> = "*",
|
|
11
11
|
allow_empty = true,
|
|
12
|
-
all_cols: AllowedKeys
|
|
12
|
+
all_cols: AllowedKeys
|
|
13
13
|
): AllowedKeys | [""] => {
|
|
14
|
-
if (!all_cols) throw "all_cols missing";
|
|
15
|
-
const all_fields = all_cols; // || this.column_names.slice(0);
|
|
16
14
|
let colNames: AllowedKeys = [] as any;
|
|
17
15
|
const initialParams = JSON.stringify(fieldParams);
|
|
18
16
|
|
|
@@ -25,15 +23,12 @@ export const parseFieldFilter = <AllowedKeys extends string[]>(
|
|
|
25
23
|
}
|
|
26
24
|
|
|
27
25
|
/* string[] */
|
|
28
|
-
if (
|
|
29
|
-
Array.isArray(fieldParams) &&
|
|
30
|
-
!fieldParams.find((f) => typeof f !== "string")
|
|
31
|
-
) {
|
|
26
|
+
if (Array.isArray(fieldParams) && !fieldParams.find((f) => typeof f !== "string")) {
|
|
32
27
|
/*
|
|
33
28
|
["*"]
|
|
34
29
|
*/
|
|
35
30
|
if (fieldParams[0] === "*") {
|
|
36
|
-
return
|
|
31
|
+
return all_cols.slice(0) as typeof all_cols;
|
|
37
32
|
|
|
38
33
|
/*
|
|
39
34
|
[""]
|
|
@@ -57,13 +52,13 @@ export const parseFieldFilter = <AllowedKeys extends string[]>(
|
|
|
57
52
|
*/
|
|
58
53
|
} else if (isPlainObject(fieldParams)) {
|
|
59
54
|
if (!getKeys(fieldParams).length) {
|
|
60
|
-
return [] as unknown as typeof
|
|
55
|
+
return [] as unknown as typeof all_cols; //all_fields.slice(0) as typeof all_fields;
|
|
61
56
|
}
|
|
62
57
|
|
|
63
58
|
const keys = getKeys(
|
|
64
59
|
fieldParams as {
|
|
65
60
|
[key: string]: boolean | 0 | 1;
|
|
66
|
-
}
|
|
61
|
+
}
|
|
67
62
|
) as AllowedKeys;
|
|
68
63
|
if (keys[0] === "") {
|
|
69
64
|
if (allow_empty) {
|
|
@@ -84,10 +79,8 @@ export const parseFieldFilter = <AllowedKeys extends string[]>(
|
|
|
84
79
|
const allowed = keys.filter((key) => (fieldParams as any)[key]),
|
|
85
80
|
disallowed = keys.filter((key) => !(fieldParams as any)[key]);
|
|
86
81
|
|
|
87
|
-
if (disallowed
|
|
88
|
-
return
|
|
89
|
-
(col) => !disallowed.includes(col),
|
|
90
|
-
) as typeof all_fields;
|
|
82
|
+
if (disallowed.length) {
|
|
83
|
+
return all_cols.filter((col) => !disallowed.includes(col)) as typeof all_cols;
|
|
91
84
|
} else {
|
|
92
85
|
return [...allowed] as any;
|
|
93
86
|
}
|
|
@@ -103,8 +96,8 @@ export const parseFieldFilter = <AllowedKeys extends string[]>(
|
|
|
103
96
|
return colNames as any;
|
|
104
97
|
|
|
105
98
|
function validate(cols: AllowedKeys) {
|
|
106
|
-
const bad_keys = cols.filter((col) => !
|
|
107
|
-
if (bad_keys
|
|
99
|
+
const bad_keys = cols.filter((col) => !all_cols.includes(col));
|
|
100
|
+
if (bad_keys.length) {
|
|
108
101
|
throw "\nUnrecognised or illegal fields: " + bad_keys.join(", ");
|
|
109
102
|
}
|
|
110
103
|
}
|
|
@@ -61,9 +61,7 @@ export const parseJoinPath = ({
|
|
|
61
61
|
}
|
|
62
62
|
});
|
|
63
63
|
|
|
64
|
-
const missingPath = result.find(
|
|
65
|
-
(r) => !r.on.length || r.on.some((v) => !Object.keys(v).length),
|
|
66
|
-
);
|
|
64
|
+
const missingPath = result.find((r) => !r.on.length || r.on.some((v) => !Object.keys(v).length));
|
|
67
65
|
if (missingPath) {
|
|
68
66
|
throw `Missing join on condition for: ${missingPath.table}`;
|
|
69
67
|
}
|
|
@@ -86,7 +84,7 @@ function getJoins(
|
|
|
86
84
|
viewHandler: ViewHandler,
|
|
87
85
|
source: string,
|
|
88
86
|
path: JoinPath[],
|
|
89
|
-
{ allowMultiOrJoin = true, getShortestJoin }: Opts = {}
|
|
87
|
+
{ allowMultiOrJoin = true, getShortestJoin }: Opts = {}
|
|
90
88
|
): JoinInfo {
|
|
91
89
|
const [lastItem] = path;
|
|
92
90
|
if (!lastItem) {
|
|
@@ -102,13 +100,11 @@ function getJoins(
|
|
|
102
100
|
|
|
103
101
|
/* Self join */
|
|
104
102
|
if (source === target) {
|
|
105
|
-
const tableHandler = viewHandler.dboBuilder.tablesOrViews?.find(
|
|
106
|
-
(t) => t.name === source,
|
|
107
|
-
);
|
|
103
|
+
const tableHandler = viewHandler.dboBuilder.tablesOrViews?.find((t) => t.name === source);
|
|
108
104
|
if (!tableHandler) throw `Table not found for joining ${source}`;
|
|
109
105
|
|
|
110
106
|
const fcols = tableHandler.columns.filter((c) =>
|
|
111
|
-
c.references?.some(({ ftable }) => ftable === viewHandler.name)
|
|
107
|
+
c.references?.some(({ ftable }) => ftable === viewHandler.name)
|
|
112
108
|
);
|
|
113
109
|
if (!fcols.length) {
|
|
114
110
|
throw `There is no self-join foreign key relationship for table ${JSON.stringify(target)}`;
|
|
@@ -116,9 +112,7 @@ function getJoins(
|
|
|
116
112
|
let allOnJoins: [string, string][][] = [];
|
|
117
113
|
fcols.forEach((fc) => {
|
|
118
114
|
fc.references!.forEach(({ fcols, cols }) => {
|
|
119
|
-
const fieldArr = fcols.map(
|
|
120
|
-
(fcol, i) => [fcol, cols[i]!] as [string, string],
|
|
121
|
-
);
|
|
115
|
+
const fieldArr = fcols.map((fcol, i) => [fcol, cols[i]!] as [string, string]);
|
|
122
116
|
allOnJoins.push(fieldArr);
|
|
123
117
|
});
|
|
124
118
|
});
|
|
@@ -126,7 +120,7 @@ function getJoins(
|
|
|
126
120
|
...allOnJoins,
|
|
127
121
|
/** Reverse as well */
|
|
128
122
|
...allOnJoins.map((constraint) =>
|
|
129
|
-
constraint.map(([left, right]) => [right, left] as [string, string])
|
|
123
|
+
constraint.map(([left, right]) => [right, left] as [string, string])
|
|
130
124
|
),
|
|
131
125
|
];
|
|
132
126
|
return {
|
|
@@ -137,7 +131,7 @@ function getJoins(
|
|
|
137
131
|
table: target,
|
|
138
132
|
on: getValidOn(
|
|
139
133
|
lastItem.on,
|
|
140
|
-
allOnJoins.map((v) => Object.fromEntries(v))
|
|
134
|
+
allOnJoins.map((v) => Object.fromEntries(v))
|
|
141
135
|
),
|
|
142
136
|
},
|
|
143
137
|
],
|
|
@@ -146,28 +140,27 @@ function getJoins(
|
|
|
146
140
|
}
|
|
147
141
|
|
|
148
142
|
/* Find the join path between tables */
|
|
149
|
-
const tableConfigJoinInfo =
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
);
|
|
143
|
+
const tableConfigJoinInfo = viewHandler.dboBuilder.prostgles.tableConfigurator?.getJoinInfo(
|
|
144
|
+
source,
|
|
145
|
+
target
|
|
146
|
+
);
|
|
154
147
|
if (tableConfigJoinInfo) return tableConfigJoinInfo;
|
|
155
148
|
|
|
156
|
-
const actualPath =
|
|
157
|
-
?
|
|
149
|
+
const actualPath =
|
|
150
|
+
getShortestJoin ?
|
|
151
|
+
viewHandler.joinPaths
|
|
158
152
|
.find((j) => {
|
|
159
153
|
return j.t1 === source && j.t2 === target;
|
|
160
154
|
})
|
|
161
155
|
?.path.map((table) => ({ table, on: undefined }))
|
|
162
156
|
.slice(1)
|
|
163
|
-
:
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
: undefined;
|
|
157
|
+
: (
|
|
158
|
+
viewHandler.joinPaths.find((j) => {
|
|
159
|
+
return j.path.join() === [{ table: source }, ...path].map((p) => p.table).join();
|
|
160
|
+
})
|
|
161
|
+
) ?
|
|
162
|
+
path
|
|
163
|
+
: undefined;
|
|
171
164
|
|
|
172
165
|
if (getShortestJoin && actualPath?.length && lastItem.on?.length) {
|
|
173
166
|
actualPath[actualPath.length - 1]!.on = lastItem.on;
|
|
@@ -183,11 +176,9 @@ function getJoins(
|
|
|
183
176
|
const prevTable = arr[i - 1]!;
|
|
184
177
|
const t1 = i === 0 ? source : prevTable.table;
|
|
185
178
|
|
|
186
|
-
viewHandler.joins ??= viewHandler.dboBuilder.joins;
|
|
187
|
-
|
|
188
179
|
/* Get join options */
|
|
189
180
|
const join = viewHandler.joins.find(
|
|
190
|
-
(j) => j.tables.includes(t1) && j.tables.includes(tablePath.table)
|
|
181
|
+
(j) => j.tables.includes(t1) && j.tables.includes(tablePath.table)
|
|
191
182
|
);
|
|
192
183
|
if (!join) {
|
|
193
184
|
throw `Joining ${t1} <-> ${tablePath} dissallowed or missing`;
|
|
@@ -226,10 +217,7 @@ function getJoins(
|
|
|
226
217
|
};
|
|
227
218
|
}
|
|
228
219
|
|
|
229
|
-
const getValidOn = (
|
|
230
|
-
requested: JoinPath["on"],
|
|
231
|
-
possible: ParsedJoinPath["on"],
|
|
232
|
-
) => {
|
|
220
|
+
const getValidOn = (requested: JoinPath["on"], possible: ParsedJoinPath["on"]) => {
|
|
233
221
|
if (!requested) {
|
|
234
222
|
return possible.map((v) => Object.entries(v));
|
|
235
223
|
}
|
|
@@ -238,7 +226,7 @@ const getValidOn = (
|
|
|
238
226
|
}
|
|
239
227
|
const isValid = requested.every((requestedConstraint) => {
|
|
240
228
|
return possible.some((possibleConstraint) =>
|
|
241
|
-
conditionsMatch(possibleConstraint, requestedConstraint)
|
|
229
|
+
conditionsMatch(possibleConstraint, requestedConstraint)
|
|
242
230
|
);
|
|
243
231
|
});
|
|
244
232
|
|
|
@@ -249,14 +237,8 @@ const getValidOn = (
|
|
|
249
237
|
return requested.map((v) => Object.entries(v));
|
|
250
238
|
};
|
|
251
239
|
|
|
252
|
-
const conditionsMatch = (
|
|
253
|
-
c1: Record<string, string>,
|
|
254
|
-
c2: Record<string, string>,
|
|
255
|
-
) => {
|
|
240
|
+
const conditionsMatch = (c1: Record<string, string>, c2: Record<string, string>) => {
|
|
256
241
|
const keys1 = Object.keys(c1);
|
|
257
242
|
const keys2 = Object.keys(c2);
|
|
258
|
-
return (
|
|
259
|
-
keys1.sort().join() === keys2.sort().join() &&
|
|
260
|
-
keys1.every((key) => c1[key] === c2[key])
|
|
261
|
-
);
|
|
243
|
+
return keys1.sort().join() === keys2.sort().join() && keys1.every((key) => c1[key] === c2[key]);
|
|
262
244
|
};
|