prostgles-server 4.2.187 → 4.2.188
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 +18 -11
- package/dist/Auth/AuthHandler.d.ts.map +1 -1
- package/dist/Auth/AuthHandler.js +94 -120
- package/dist/Auth/AuthHandler.js.map +1 -1
- package/dist/Auth/AuthTypes.d.ts +78 -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 +74 -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 +117 -137
- package/lib/Auth/AuthTypes.ts +97 -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 +83 -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
|
@@ -36,16 +36,13 @@ export const parseFunction = (funcData: {
|
|
|
36
36
|
|
|
37
37
|
if (!funcDef) {
|
|
38
38
|
const sf = functions
|
|
39
|
-
.filter((f) =>
|
|
40
|
-
f.name.toLowerCase().slice(1).startsWith(funcName.toLowerCase()),
|
|
41
|
-
)
|
|
39
|
+
.filter((f) => f.name.toLowerCase().slice(1).startsWith(funcName.toLowerCase()))
|
|
42
40
|
.sort((a, b) => a.name.length - b.name.length);
|
|
43
|
-
const hint =
|
|
44
|
-
|
|
41
|
+
const hint =
|
|
42
|
+
sf.length ?
|
|
43
|
+
`. \n Maybe you meant: \n | ${sf.map((s) => s.name + " " + (s.description || "")).join(" \n | ")} ?`
|
|
45
44
|
: "";
|
|
46
|
-
throw
|
|
47
|
-
"\n Function " + funcName + " does not exist or is not allowed " + hint
|
|
48
|
-
);
|
|
45
|
+
throw "\n Function " + funcName + " does not exist or is not allowed " + hint;
|
|
49
46
|
}
|
|
50
47
|
|
|
51
48
|
/* Validate fields */
|
|
@@ -54,14 +51,12 @@ export const parseFunction = (funcData: {
|
|
|
54
51
|
fields.forEach((fieldKey) => {
|
|
55
52
|
if (typeof fieldKey !== "string" || !allowedFields.includes(fieldKey)) {
|
|
56
53
|
throw makeErr(
|
|
57
|
-
`getFields() => field name ${JSON.stringify(fieldKey)} is invalid or disallowed
|
|
54
|
+
`getFields() => field name ${JSON.stringify(fieldKey)} is invalid or disallowed`
|
|
58
55
|
);
|
|
59
56
|
}
|
|
60
57
|
});
|
|
61
58
|
if ((funcDef.minCols ?? 0) > fields.length) {
|
|
62
|
-
throw makeErr(
|
|
63
|
-
`Less columns provided than necessary (minCols=${funcDef.minCols})`,
|
|
64
|
-
);
|
|
59
|
+
throw makeErr(`Less columns provided than necessary (minCols=${funcDef.minCols})`);
|
|
65
60
|
}
|
|
66
61
|
}
|
|
67
62
|
|
|
@@ -147,16 +142,12 @@ const parseUnix = (
|
|
|
147
142
|
colName: string,
|
|
148
143
|
tableAlias: string | undefined,
|
|
149
144
|
allColumns: ColumnInfo[],
|
|
150
|
-
opts: { timeZone: boolean | string } | undefined
|
|
145
|
+
opts: { timeZone: boolean | string } | undefined
|
|
151
146
|
) => {
|
|
152
147
|
let tz = "";
|
|
153
148
|
if (opts) {
|
|
154
|
-
const { timeZone } = opts
|
|
155
|
-
if (
|
|
156
|
-
timeZone &&
|
|
157
|
-
typeof timeZone !== "string" &&
|
|
158
|
-
typeof timeZone !== "boolean"
|
|
159
|
-
) {
|
|
149
|
+
const { timeZone } = opts;
|
|
150
|
+
if (timeZone && typeof timeZone !== "string" && typeof timeZone !== "boolean") {
|
|
160
151
|
throw `Bad timeZone value. timeZone can be boolean or string`;
|
|
161
152
|
}
|
|
162
153
|
if (timeZone === true) {
|
|
@@ -213,11 +204,7 @@ const JSON_Funcs: FunctionSpec[] = [
|
|
|
213
204
|
numArgs: 4,
|
|
214
205
|
type: "function",
|
|
215
206
|
getFields: ([column]) => column,
|
|
216
|
-
getQuery: ({
|
|
217
|
-
args: [colName, jsonPath, ...otherArgs],
|
|
218
|
-
tableAlias,
|
|
219
|
-
allowedFields,
|
|
220
|
-
}) => {
|
|
207
|
+
getQuery: ({ args: [colName, jsonPath, ...otherArgs], tableAlias, allowedFields }) => {
|
|
221
208
|
if (!allowedFields.includes(colName)) {
|
|
222
209
|
throw `Unexpected: column ${colName} not found`;
|
|
223
210
|
}
|
|
@@ -232,14 +219,8 @@ const JSON_Funcs: FunctionSpec[] = [
|
|
|
232
219
|
|
|
233
220
|
...(
|
|
234
221
|
[
|
|
235
|
-
[
|
|
236
|
-
|
|
237
|
-
"Returns the number of elements in the outermost JSON array",
|
|
238
|
-
],
|
|
239
|
-
[
|
|
240
|
-
"jsonb_each",
|
|
241
|
-
"Expands the outermost JSON object into a set of key/value pairs",
|
|
242
|
-
],
|
|
222
|
+
["jsonb_array_length", "Returns the number of elements in the outermost JSON array"],
|
|
223
|
+
["jsonb_each", "Expands the outermost JSON object into a set of key/value pairs"],
|
|
243
224
|
[
|
|
244
225
|
"jsonb_each_text",
|
|
245
226
|
"Expands the outermost JSON object into a set of key/value pairs. The returned values will be of type text",
|
|
@@ -252,10 +233,7 @@ const JSON_Funcs: FunctionSpec[] = [
|
|
|
252
233
|
["jsonb_pretty", "Returns from_json as indented JSON text "],
|
|
253
234
|
["jsonb_to_record", "Builds an arbitrary record from a JSON object"],
|
|
254
235
|
["jsonb_array_elements", "Expands a JSON array to a set of JSON values"],
|
|
255
|
-
[
|
|
256
|
-
"jsonb_array_elements_text",
|
|
257
|
-
"Expands a JSON array to a set of text values ",
|
|
258
|
-
],
|
|
236
|
+
["jsonb_array_elements_text", "Expands a JSON array to a set of text values "],
|
|
259
237
|
[
|
|
260
238
|
"jsonb_typeof",
|
|
261
239
|
"Returns the type of the outermost JSON value as a text string. Possible types are object, array, string, number, boolean, and null ",
|
|
@@ -274,7 +252,7 @@ const JSON_Funcs: FunctionSpec[] = [
|
|
|
274
252
|
const escapedName = asNameAlias(colName, tableAlias);
|
|
275
253
|
return `${name}(${escapedName})`;
|
|
276
254
|
},
|
|
277
|
-
}) as FunctionSpec
|
|
255
|
+
}) as FunctionSpec
|
|
278
256
|
),
|
|
279
257
|
];
|
|
280
258
|
|
|
@@ -309,18 +287,14 @@ const FTS_Funcs: FunctionSpec[] =
|
|
|
309
287
|
const keys = Object.keys(qVal);
|
|
310
288
|
if (!keys.length) throw "Bad arg";
|
|
311
289
|
if (keys.length !== 1 || !searchTypes.includes(keys[0] as any))
|
|
312
|
-
throw (
|
|
313
|
-
"Expecting a an object with a single key named one of: " +
|
|
314
|
-
searchTypes.join(", ")
|
|
315
|
-
);
|
|
290
|
+
throw "Expecting a an object with a single key named one of: " + searchTypes.join(", ");
|
|
316
291
|
qType = keys[0]!;
|
|
317
292
|
qVal = asValue(qVal[qType]);
|
|
318
293
|
|
|
319
294
|
/* 'search term' */
|
|
320
295
|
} else if (typeof qVal === "string") {
|
|
321
296
|
qVal = pgp.as.format(qType + "($1)", [qVal]);
|
|
322
|
-
} else
|
|
323
|
-
throw "Bad second arg. Exepcting search string or { to_tsquery: 'search string' }";
|
|
297
|
+
} else throw "Bad second arg. Exepcting search string or { to_tsquery: 'search string' }";
|
|
324
298
|
|
|
325
299
|
const res = `ts_headline(${_type} ${col}::text, ${qVal}, 'ShortWord=1 ' )`;
|
|
326
300
|
// console.log(res)
|
|
@@ -449,8 +423,7 @@ let PostGIS_Funcs: FunctionSpec[] = (
|
|
|
449
423
|
} else if (fname === "ST_DistanceSpheroid") {
|
|
450
424
|
colCast = "::geometry";
|
|
451
425
|
geomQCast = "::geometry";
|
|
452
|
-
if (typeof spheroid !== "string")
|
|
453
|
-
throw `ST_DistanceSpheroid: spheroid param must be string`;
|
|
426
|
+
if (typeof spheroid !== "string") throw `ST_DistanceSpheroid: spheroid param must be string`;
|
|
454
427
|
extraParams = `, ${asValue(spheroid)}`;
|
|
455
428
|
|
|
456
429
|
/**
|
|
@@ -465,18 +438,18 @@ let PostGIS_Funcs: FunctionSpec[] = (
|
|
|
465
438
|
* double precision <->( geometry A , geometry B );
|
|
466
439
|
* double precision <->( geography A , geography B );
|
|
467
440
|
*/
|
|
468
|
-
} else if (fname === "<->") {
|
|
441
|
+
} else if ((fname as string) === "<->") {
|
|
469
442
|
colCast = colIsGeog ? "::geography" : "::geometry";
|
|
470
443
|
geomQCast = colIsGeog ? "::geography" : "::geometry";
|
|
471
444
|
const q = pgp.as.format(
|
|
472
|
-
`${asNameAlias(columnName, tableAlias)}${colCast} <-> ${geomQ}${geomQCast}
|
|
445
|
+
`${asNameAlias(columnName, tableAlias)}${colCast} <-> ${geomQ}${geomQCast}`
|
|
473
446
|
);
|
|
474
447
|
if (debug) throw q;
|
|
475
448
|
return q;
|
|
476
449
|
}
|
|
477
450
|
|
|
478
451
|
const query = pgp.as.format(
|
|
479
|
-
`${fname}(${asNameAlias(columnName, tableAlias)}${colCast} , ${geomQ}${geomQCast} ${extraParams})
|
|
452
|
+
`${fname}(${asNameAlias(columnName, tableAlias)}${colCast} , ${geomQ}${geomQCast} ${extraParams})`
|
|
480
453
|
);
|
|
481
454
|
if (debug) {
|
|
482
455
|
throw query;
|
|
@@ -508,15 +481,10 @@ PostGIS_Funcs = PostGIS_Funcs.concat(
|
|
|
508
481
|
getFields: (args: any[]) => [args[0]],
|
|
509
482
|
getQuery: ({ args: [colName, ...otherArgs], tableAlias }) => {
|
|
510
483
|
let secondArg = "";
|
|
511
|
-
if (otherArgs.length)
|
|
512
|
-
secondArg = ", " + otherArgs.map((arg) => asValue(arg)).join(", ");
|
|
484
|
+
if (otherArgs.length) secondArg = ", " + otherArgs.map((arg) => asValue(arg)).join(", ");
|
|
513
485
|
const escTabelName = asNameAlias(colName, tableAlias) + "::geometry";
|
|
514
486
|
const result = pgp.as.format(
|
|
515
|
-
fname +
|
|
516
|
-
"(" +
|
|
517
|
-
escTabelName +
|
|
518
|
-
secondArg +
|
|
519
|
-
(fname === "ST_AsGeoJSON" ? ")::jsonb" : ")"),
|
|
487
|
+
fname + "(" + escTabelName + secondArg + (fname === "ST_AsGeoJSON" ? ")::jsonb" : ")")
|
|
520
488
|
);
|
|
521
489
|
if (["ST_Centroid", "ST_SnapToGrid", "ST_Simplify"].includes(fname)) {
|
|
522
490
|
const r = `ST_AsGeoJSON(${result})::jsonb`;
|
|
@@ -526,7 +494,7 @@ PostGIS_Funcs = PostGIS_Funcs.concat(
|
|
|
526
494
|
},
|
|
527
495
|
};
|
|
528
496
|
return res;
|
|
529
|
-
})
|
|
497
|
+
})
|
|
530
498
|
);
|
|
531
499
|
|
|
532
500
|
PostGIS_Funcs = PostGIS_Funcs.concat(
|
|
@@ -558,7 +526,7 @@ PostGIS_Funcs = PostGIS_Funcs.concat(
|
|
|
558
526
|
},
|
|
559
527
|
};
|
|
560
528
|
return res;
|
|
561
|
-
})
|
|
529
|
+
})
|
|
562
530
|
);
|
|
563
531
|
|
|
564
532
|
PostGIS_Funcs = PostGIS_Funcs.concat(
|
|
@@ -576,7 +544,7 @@ PostGIS_Funcs = PostGIS_Funcs.concat(
|
|
|
576
544
|
|
|
577
545
|
return `${fname}(${escapedColName})`;
|
|
578
546
|
},
|
|
579
|
-
}))
|
|
547
|
+
}))
|
|
580
548
|
);
|
|
581
549
|
|
|
582
550
|
/**
|
|
@@ -595,12 +563,9 @@ export const FUNCTIONS: FunctionSpec[] = [
|
|
|
595
563
|
const q = pgp.as.format(
|
|
596
564
|
"md5(" +
|
|
597
565
|
args
|
|
598
|
-
.map(
|
|
599
|
-
(fname) =>
|
|
600
|
-
"COALESCE( " + asNameAlias(fname, tableAlias) + "::text, '' )",
|
|
601
|
-
)
|
|
566
|
+
.map((fname) => "COALESCE( " + asNameAlias(fname, tableAlias) + "::text, '' )")
|
|
602
567
|
.join(" || ") +
|
|
603
|
-
")"
|
|
568
|
+
")"
|
|
604
569
|
);
|
|
605
570
|
return q;
|
|
606
571
|
},
|
|
@@ -616,12 +581,9 @@ export const FUNCTIONS: FunctionSpec[] = [
|
|
|
616
581
|
const q = pgp.as.format(
|
|
617
582
|
"md5(string_agg(" +
|
|
618
583
|
args
|
|
619
|
-
.map(
|
|
620
|
-
(fname) =>
|
|
621
|
-
"COALESCE( " + asNameAlias(fname, tableAlias) + "::text, '' )",
|
|
622
|
-
)
|
|
584
|
+
.map((fname) => "COALESCE( " + asNameAlias(fname, tableAlias) + "::text, '' )")
|
|
623
585
|
.join(" || ") +
|
|
624
|
-
", ','))"
|
|
586
|
+
", ','))"
|
|
625
587
|
);
|
|
626
588
|
return q;
|
|
627
589
|
},
|
|
@@ -638,12 +600,9 @@ export const FUNCTIONS: FunctionSpec[] = [
|
|
|
638
600
|
const q = pgp.as.format(
|
|
639
601
|
"encode(sha256((" +
|
|
640
602
|
args
|
|
641
|
-
.map(
|
|
642
|
-
(fname) =>
|
|
643
|
-
"COALESCE( " + asNameAlias(fname, tableAlias) + ", '' )",
|
|
644
|
-
)
|
|
603
|
+
.map((fname) => "COALESCE( " + asNameAlias(fname, tableAlias) + ", '' )")
|
|
645
604
|
.join(" || ") +
|
|
646
|
-
")::text::bytea), 'hex')"
|
|
605
|
+
")::text::bytea), 'hex')"
|
|
647
606
|
);
|
|
648
607
|
return q;
|
|
649
608
|
},
|
|
@@ -659,12 +618,9 @@ export const FUNCTIONS: FunctionSpec[] = [
|
|
|
659
618
|
const q = pgp.as.format(
|
|
660
619
|
"encode(sha256(string_agg(" +
|
|
661
620
|
args
|
|
662
|
-
.map(
|
|
663
|
-
(fname) =>
|
|
664
|
-
"COALESCE( " + asNameAlias(fname, tableAlias) + ", '' )",
|
|
665
|
-
)
|
|
621
|
+
.map((fname) => "COALESCE( " + asNameAlias(fname, tableAlias) + ", '' )")
|
|
666
622
|
.join(" || ") +
|
|
667
|
-
", ',')::text::bytea), 'hex')"
|
|
623
|
+
", ',')::text::bytea), 'hex')"
|
|
668
624
|
);
|
|
669
625
|
return q;
|
|
670
626
|
},
|
|
@@ -680,12 +636,9 @@ export const FUNCTIONS: FunctionSpec[] = [
|
|
|
680
636
|
const q = pgp.as.format(
|
|
681
637
|
"encode(sha512((" +
|
|
682
638
|
args
|
|
683
|
-
.map(
|
|
684
|
-
(fname) =>
|
|
685
|
-
"COALESCE( " + asNameAlias(fname, tableAlias) + ", '' )",
|
|
686
|
-
)
|
|
639
|
+
.map((fname) => "COALESCE( " + asNameAlias(fname, tableAlias) + ", '' )")
|
|
687
640
|
.join(" || ") +
|
|
688
|
-
")::text::bytea), 'hex')"
|
|
641
|
+
")::text::bytea), 'hex')"
|
|
689
642
|
);
|
|
690
643
|
return q;
|
|
691
644
|
},
|
|
@@ -701,12 +654,9 @@ export const FUNCTIONS: FunctionSpec[] = [
|
|
|
701
654
|
const q = pgp.as.format(
|
|
702
655
|
"encode(sha512(string_agg(" +
|
|
703
656
|
args
|
|
704
|
-
.map(
|
|
705
|
-
(fname) =>
|
|
706
|
-
"COALESCE( " + asNameAlias(fname, tableAlias) + ", '' )",
|
|
707
|
-
)
|
|
657
|
+
.map((fname) => "COALESCE( " + asNameAlias(fname, tableAlias) + ", '' )")
|
|
708
658
|
.join(" || ") +
|
|
709
|
-
", ',')::text::bytea), 'hex')"
|
|
659
|
+
", ',')::text::bytea), 'hex')"
|
|
710
660
|
);
|
|
711
661
|
return q;
|
|
712
662
|
},
|
|
@@ -726,10 +676,7 @@ export const FUNCTIONS: FunctionSpec[] = [
|
|
|
726
676
|
singleColArg: false,
|
|
727
677
|
getFields: (args: any[]) => [args[0]],
|
|
728
678
|
getQuery: ({ allowedFields, args, tableAlias }) => {
|
|
729
|
-
return pgp.as.format(
|
|
730
|
-
"LEFT(" + asNameAlias(args[0], tableAlias) + ", $1)",
|
|
731
|
-
[args[1]],
|
|
732
|
-
);
|
|
679
|
+
return pgp.as.format("LEFT(" + asNameAlias(args[0], tableAlias) + ", $1)", [args[1]]);
|
|
733
680
|
},
|
|
734
681
|
},
|
|
735
682
|
{
|
|
@@ -741,9 +688,7 @@ export const FUNCTIONS: FunctionSpec[] = [
|
|
|
741
688
|
getFields: (args: any[]) => [args[0]],
|
|
742
689
|
getQuery: ({ allowedFields, args, tableAlias }) => {
|
|
743
690
|
return pgp.as.format(
|
|
744
|
-
"unnest(string_to_array(" +
|
|
745
|
-
asNameAlias(args[0], tableAlias) +
|
|
746
|
-
"::TEXT , ' '))",
|
|
691
|
+
"unnest(string_to_array(" + asNameAlias(args[0], tableAlias) + "::TEXT , ' '))"
|
|
747
692
|
); //, [args[1]]
|
|
748
693
|
},
|
|
749
694
|
},
|
|
@@ -755,10 +700,7 @@ export const FUNCTIONS: FunctionSpec[] = [
|
|
|
755
700
|
singleColArg: false,
|
|
756
701
|
getFields: (args: any[]) => [args[0]],
|
|
757
702
|
getQuery: ({ allowedFields, args, tableAlias }) => {
|
|
758
|
-
return pgp.as.format(
|
|
759
|
-
"RIGHT(" + asNameAlias(args[0], tableAlias) + ", $1)",
|
|
760
|
-
[args[1]],
|
|
761
|
-
);
|
|
703
|
+
return pgp.as.format("RIGHT(" + asNameAlias(args[0], tableAlias) + ", $1)", [args[1]]);
|
|
762
704
|
},
|
|
763
705
|
},
|
|
764
706
|
|
|
@@ -771,15 +713,16 @@ export const FUNCTIONS: FunctionSpec[] = [
|
|
|
771
713
|
getFields: (args: any[]) => [args[0]],
|
|
772
714
|
getQuery: ({ allowedFields, args, tableAlias }) => {
|
|
773
715
|
if (args.length === 3) {
|
|
774
|
-
return pgp.as.format(
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
716
|
+
return pgp.as.format("to_char(" + asNameAlias(args[0], tableAlias) + ", $2, $3)", [
|
|
717
|
+
args[0],
|
|
718
|
+
args[1],
|
|
719
|
+
args[2],
|
|
720
|
+
]);
|
|
778
721
|
}
|
|
779
|
-
return pgp.as.format(
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
);
|
|
722
|
+
return pgp.as.format("to_char(" + asNameAlias(args[0], tableAlias) + ", $2)", [
|
|
723
|
+
args[0],
|
|
724
|
+
args[1],
|
|
725
|
+
]);
|
|
783
726
|
},
|
|
784
727
|
},
|
|
785
728
|
|
|
@@ -871,7 +814,7 @@ export const FUNCTIONS: FunctionSpec[] = [
|
|
|
871
814
|
// console.log(res);
|
|
872
815
|
return res;
|
|
873
816
|
},
|
|
874
|
-
}) as FunctionSpec
|
|
817
|
+
}) as FunctionSpec
|
|
875
818
|
),
|
|
876
819
|
|
|
877
820
|
/* Date funcs date_part */
|
|
@@ -883,16 +826,16 @@ export const FUNCTIONS: FunctionSpec[] = [
|
|
|
883
826
|
numArgs: 3,
|
|
884
827
|
description:
|
|
885
828
|
` :[unit<string>, column_name, opts?: { timeZone: true | string }] -> ` +
|
|
886
|
-
(funcName === "date_trunc"
|
|
887
|
-
|
|
888
|
-
|
|
829
|
+
(funcName === "date_trunc" ?
|
|
830
|
+
` round down timestamp to closest unit value. `
|
|
831
|
+
: ` extract date unit as float8. `) +
|
|
889
832
|
` E.g. ['hour', col] `,
|
|
890
833
|
singleColArg: false,
|
|
891
834
|
getFields: (args: any[]) => [args[1]],
|
|
892
835
|
getQuery: ({ allColumns, args, tableAlias }) => {
|
|
893
836
|
return `${funcName}(${asValue(args[0])}, ${parseUnix(args[1], tableAlias, allColumns, args[2])})`;
|
|
894
837
|
},
|
|
895
|
-
}) as FunctionSpec
|
|
838
|
+
}) as FunctionSpec
|
|
896
839
|
),
|
|
897
840
|
|
|
898
841
|
/* Handy date funcs */
|
|
@@ -937,34 +880,32 @@ export const FUNCTIONS: FunctionSpec[] = [
|
|
|
937
880
|
name: "$" + funcName,
|
|
938
881
|
type: "function",
|
|
939
882
|
description:
|
|
940
|
-
` :[column_name, opts?: { timeZone: true | string }] -> get timestamp formated as ` +
|
|
941
|
-
txt,
|
|
883
|
+
` :[column_name, opts?: { timeZone: true | string }] -> get timestamp formated as ` + txt,
|
|
942
884
|
singleColArg: true,
|
|
943
885
|
numArgs: 1,
|
|
944
886
|
getFields: (args: any[]) => [args[0]],
|
|
945
887
|
getQuery: ({ allColumns, args, tableAlias }) => {
|
|
946
888
|
return pgp.as.format(
|
|
947
|
-
"trim(to_char(" +
|
|
948
|
-
|
|
949
|
-
", $2))",
|
|
950
|
-
[args[0], txt],
|
|
889
|
+
"trim(to_char(" + parseUnix(args[0], tableAlias, allColumns, args[1]) + ", $2))",
|
|
890
|
+
[args[0], txt]
|
|
951
891
|
);
|
|
952
892
|
},
|
|
953
|
-
}) as FunctionSpec
|
|
893
|
+
}) as FunctionSpec
|
|
954
894
|
),
|
|
955
895
|
|
|
956
896
|
/* Basic 1 arg col funcs */
|
|
957
897
|
...[
|
|
958
898
|
...["TEXT"].flatMap((cast) =>
|
|
959
|
-
["upper", "lower", "length", "reverse", "trim", "initcap"].map(
|
|
960
|
-
|
|
961
|
-
|
|
899
|
+
["upper", "lower", "length", "reverse", "trim", "initcap"].map((funcName) => ({
|
|
900
|
+
cast,
|
|
901
|
+
funcName,
|
|
902
|
+
}))
|
|
962
903
|
),
|
|
963
904
|
...[""].flatMap((cast) =>
|
|
964
905
|
["round", "ceil", "floor", "sign", "md5"].map((funcName) => ({
|
|
965
906
|
cast,
|
|
966
907
|
funcName,
|
|
967
|
-
}))
|
|
908
|
+
}))
|
|
968
909
|
),
|
|
969
910
|
].map(
|
|
970
911
|
({ funcName, cast }) =>
|
|
@@ -977,7 +918,7 @@ export const FUNCTIONS: FunctionSpec[] = [
|
|
|
977
918
|
getQuery: ({ args, tableAlias }) => {
|
|
978
919
|
return `${funcName}(${asNameAlias(args[0], tableAlias)}${cast ? `::${cast}` : ""})`;
|
|
979
920
|
},
|
|
980
|
-
}) as FunctionSpec
|
|
921
|
+
}) as FunctionSpec
|
|
981
922
|
),
|
|
982
923
|
|
|
983
924
|
/**
|
|
@@ -991,35 +932,20 @@ export const FUNCTIONS: FunctionSpec[] = [
|
|
|
991
932
|
type: "function",
|
|
992
933
|
numArgs: 2,
|
|
993
934
|
singleColArg: true,
|
|
994
|
-
getFields: (args: any[]) =>
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
const validColCount = args
|
|
998
|
-
.slice(0, 2)
|
|
999
|
-
.filter((a) => typeof a === "string").length;
|
|
935
|
+
getFields: (args: any[]) => args.slice(0, 2).filter((a) => typeof a === "string"), // Filtered because the second arg is optional
|
|
936
|
+
getQuery: ({ args, tableAlias, allColumns }) => {
|
|
937
|
+
const validColCount = args.slice(0, 2).filter((a) => typeof a === "string").length;
|
|
1000
938
|
const trunc = args[2];
|
|
1001
|
-
const allowedTruncs = [
|
|
1002
|
-
"second",
|
|
1003
|
-
"minute",
|
|
1004
|
-
"hour",
|
|
1005
|
-
"day",
|
|
1006
|
-
"month",
|
|
1007
|
-
"year",
|
|
1008
|
-
];
|
|
939
|
+
const allowedTruncs = ["second", "minute", "hour", "day", "month", "year"];
|
|
1009
940
|
if (trunc && !allowedTruncs.includes(trunc))
|
|
1010
|
-
throw new Error(
|
|
1011
|
-
"Incorrect trunc provided. Allowed values: " + allowedTruncs,
|
|
1012
|
-
);
|
|
941
|
+
throw new Error("Incorrect trunc provided. Allowed values: " + allowedTruncs);
|
|
1013
942
|
if (funcName === "difference" && validColCount !== 2)
|
|
1014
943
|
throw new Error("Must have two column names");
|
|
1015
|
-
if (![1, 2].includes(validColCount))
|
|
1016
|
-
throw new Error("Must have one or two column names");
|
|
944
|
+
if (![1, 2].includes(validColCount)) throw new Error("Must have one or two column names");
|
|
1017
945
|
const [leftField, rightField] = args as [string, string];
|
|
1018
946
|
const tzOpts = args[2];
|
|
1019
947
|
const leftQ = parseUnix(leftField, tableAlias, allColumns, tzOpts);
|
|
1020
|
-
let rightQ = rightField
|
|
1021
|
-
? parseUnix(rightField, tableAlias, allColumns, tzOpts)
|
|
1022
|
-
: "";
|
|
948
|
+
let rightQ = rightField ? parseUnix(rightField, tableAlias, allColumns, tzOpts) : "";
|
|
1023
949
|
let query = "";
|
|
1024
950
|
if (funcName === "ageNow" && validColCount === 1) {
|
|
1025
951
|
query = `age(now(), ${leftQ})`;
|
|
@@ -1031,7 +957,7 @@ export const FUNCTIONS: FunctionSpec[] = [
|
|
|
1031
957
|
}
|
|
1032
958
|
return trunc ? `date_trunc(${asValue(trunc)}, ${query})` : query;
|
|
1033
959
|
},
|
|
1034
|
-
}) as FunctionSpec
|
|
960
|
+
}) as FunctionSpec
|
|
1035
961
|
),
|
|
1036
962
|
|
|
1037
963
|
/* pgcrypto funcs */
|
|
@@ -1049,7 +975,7 @@ export const FUNCTIONS: FunctionSpec[] = [
|
|
|
1049
975
|
|
|
1050
976
|
return `crypt(${value}, ${seedColumnName}::text)`;
|
|
1051
977
|
},
|
|
1052
|
-
}) as FunctionSpec
|
|
978
|
+
}) as FunctionSpec
|
|
1053
979
|
),
|
|
1054
980
|
|
|
1055
981
|
/* Text col and value funcs */
|
|
@@ -1070,7 +996,7 @@ export const FUNCTIONS: FunctionSpec[] = [
|
|
|
1070
996
|
}
|
|
1071
997
|
return `position( ${a1} IN ${a2} )`;
|
|
1072
998
|
},
|
|
1073
|
-
}) as FunctionSpec
|
|
999
|
+
}) as FunctionSpec
|
|
1074
1000
|
),
|
|
1075
1001
|
...["template_string"].map(
|
|
1076
1002
|
(funcName) =>
|
|
@@ -1087,9 +1013,7 @@ export const FUNCTIONS: FunctionSpec[] = [
|
|
|
1087
1013
|
|
|
1088
1014
|
const rawValue = args[0];
|
|
1089
1015
|
let finalValue = rawValue;
|
|
1090
|
-
const usedColumns = allowedFields.filter((fName) =>
|
|
1091
|
-
rawValue.includes(`{${fName}}`),
|
|
1092
|
-
);
|
|
1016
|
+
const usedColumns = allowedFields.filter((fName) => rawValue.includes(`{${fName}}`));
|
|
1093
1017
|
usedColumns.forEach((colName, idx) => {
|
|
1094
1018
|
finalValue = finalValue.split(`{${colName}}`).join(`%${idx + 1}$s`);
|
|
1095
1019
|
});
|
|
@@ -1101,7 +1025,7 @@ export const FUNCTIONS: FunctionSpec[] = [
|
|
|
1101
1025
|
|
|
1102
1026
|
return `format(${finalValue})`;
|
|
1103
1027
|
},
|
|
1104
|
-
}) as FunctionSpec
|
|
1028
|
+
}) as FunctionSpec
|
|
1105
1029
|
),
|
|
1106
1030
|
|
|
1107
1031
|
/** Custom highlight -> myterm => ['some text and', ['myterm'], ' and some other text']
|
|
@@ -1121,20 +1045,10 @@ export const FUNCTIONS: FunctionSpec[] = [
|
|
|
1121
1045
|
const cols = parseFieldFilter(args[0], false, allowedFields);
|
|
1122
1046
|
let term = args[1];
|
|
1123
1047
|
const rawTerm = args[1];
|
|
1124
|
-
const {
|
|
1125
|
-
edgeTruncate,
|
|
1126
|
-
noFields = false,
|
|
1127
|
-
returnType,
|
|
1128
|
-
matchCase = false,
|
|
1129
|
-
} = args[2] || {};
|
|
1048
|
+
const { edgeTruncate, noFields = false, returnType, matchCase = false } = args[2] || {};
|
|
1130
1049
|
if (!isEmpty(args[2])) {
|
|
1131
1050
|
const keys = Object.keys(args[2]);
|
|
1132
|
-
const validKeys = [
|
|
1133
|
-
"edgeTruncate",
|
|
1134
|
-
"noFields",
|
|
1135
|
-
"returnType",
|
|
1136
|
-
"matchCase",
|
|
1137
|
-
];
|
|
1051
|
+
const validKeys = ["edgeTruncate", "noFields", "returnType", "matchCase"];
|
|
1138
1052
|
const bad_keys = keys.filter((k) => !validKeys.includes(k));
|
|
1139
1053
|
if (bad_keys.length)
|
|
1140
1054
|
throw (
|
|
@@ -1144,13 +1058,9 @@ export const FUNCTIONS: FunctionSpec[] = [
|
|
|
1144
1058
|
}
|
|
1145
1059
|
if (!cols.length) throw "Cols are empty/invalid";
|
|
1146
1060
|
if (typeof term !== "string") throw "Non string term provided: " + term;
|
|
1147
|
-
if (
|
|
1148
|
-
edgeTruncate !== undefined &&
|
|
1149
|
-
(!Number.isInteger(edgeTruncate) || edgeTruncate < -1)
|
|
1150
|
-
)
|
|
1061
|
+
if (edgeTruncate !== undefined && (!Number.isInteger(edgeTruncate) || edgeTruncate < -1))
|
|
1151
1062
|
throw "Invalid edgeTruncate. expecting a positive integer";
|
|
1152
|
-
if (typeof noFields !== "boolean")
|
|
1153
|
-
throw "Invalid noFields. expecting boolean";
|
|
1063
|
+
if (typeof noFields !== "boolean") throw "Invalid noFields. expecting boolean";
|
|
1154
1064
|
const RETURN_TYPES = ["index", "boolean", "object"];
|
|
1155
1065
|
if (returnType && !RETURN_TYPES.includes(returnType)) {
|
|
1156
1066
|
throw `returnType can only be one of: ${RETURN_TYPES}`;
|
|
@@ -1189,7 +1099,7 @@ export const FUNCTIONS: FunctionSpec[] = [
|
|
|
1189
1099
|
cols
|
|
1190
1100
|
.map(
|
|
1191
1101
|
(c) =>
|
|
1192
|
-
`${noFields ? "" : asValue(c + ": ") + " || "} COALESCE(${asNameAlias(c, tableAlias)}::TEXT, '')
|
|
1102
|
+
`${noFields ? "" : asValue(c + ": ") + " || "} COALESCE(${asNameAlias(c, tableAlias)}::TEXT, '')`
|
|
1193
1103
|
)
|
|
1194
1104
|
.join(" || ', ' || ") +
|
|
1195
1105
|
" )";
|
|
@@ -1229,7 +1139,7 @@ export const FUNCTIONS: FunctionSpec[] = [
|
|
|
1229
1139
|
const _cols = validCols.filter(
|
|
1230
1140
|
(c) =>
|
|
1231
1141
|
/** Exclude numeric columns when the search tern contains a character */
|
|
1232
|
-
!hasChars || postgresToTsType(c.colInfo!.udt_name) !== "number"
|
|
1142
|
+
!hasChars || postgresToTsType(c.colInfo!.udt_name) !== "number"
|
|
1233
1143
|
);
|
|
1234
1144
|
|
|
1235
1145
|
/** This will break GROUP BY (non-integer constant in GROUP BY) */
|
|
@@ -1290,17 +1200,7 @@ export const FUNCTIONS: FunctionSpec[] = [
|
|
|
1290
1200
|
},
|
|
1291
1201
|
|
|
1292
1202
|
/* Aggs */
|
|
1293
|
-
...[
|
|
1294
|
-
"max",
|
|
1295
|
-
"min",
|
|
1296
|
-
"count",
|
|
1297
|
-
"avg",
|
|
1298
|
-
"json_agg",
|
|
1299
|
-
"jsonb_agg",
|
|
1300
|
-
"string_agg",
|
|
1301
|
-
"array_agg",
|
|
1302
|
-
"sum",
|
|
1303
|
-
].map(
|
|
1203
|
+
...["max", "min", "count", "avg", "json_agg", "jsonb_agg", "string_agg", "array_agg", "sum"].map(
|
|
1304
1204
|
(aggName) =>
|
|
1305
1205
|
({
|
|
1306
1206
|
name: "$" + aggName,
|
|
@@ -1313,11 +1213,9 @@ export const FUNCTIONS: FunctionSpec[] = [
|
|
|
1313
1213
|
if (args.length > 1) {
|
|
1314
1214
|
extraArgs = pgp.as.format(", $1:csv", args.slice(1));
|
|
1315
1215
|
}
|
|
1316
|
-
return (
|
|
1317
|
-
aggName + "(" + asNameAlias(args[0], tableAlias) + `${extraArgs})`
|
|
1318
|
-
);
|
|
1216
|
+
return aggName + "(" + asNameAlias(args[0], tableAlias) + `${extraArgs})`;
|
|
1319
1217
|
},
|
|
1320
|
-
}) satisfies FunctionSpec
|
|
1218
|
+
}) satisfies FunctionSpec
|
|
1321
1219
|
),
|
|
1322
1220
|
|
|
1323
1221
|
{
|