@blazedpath/commons 0.3.1 → 0.4.0
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/README.md +1 -4
- package/blz-base/health/index.js +215 -0
- package/blz-base/index.js +1466 -0
- package/blz-cache/LruCache.js +44 -0
- package/blz-cache/index.js +29 -0
- package/blz-config/index.js +434 -0
- package/blz-core/index.js +364 -0
- package/blz-cryptography/index.js +54 -0
- package/blz-datetimes/index.js +356 -0
- package/blz-file/example.dat +2545 -0
- package/blz-file/fileService.js +205 -0
- package/blz-file/index.js +94 -0
- package/blz-file/index.test.js +31 -0
- package/blz-file/lab.js +33 -0
- package/blz-hazelcast/index.js +189 -0
- package/blz-hazelcast/lib/credentials.js +25 -0
- package/blz-hazelcast/lib/credentialsFactory.js +12 -0
- package/blz-hazelcast/lib/hazelcastCache.js +234 -0
- package/blz-iterable/index.js +446 -0
- package/blz-json-schema/index.js +11 -0
- package/blz-jwt/index.js +121 -0
- package/blz-kafka/index.js +522 -0
- package/blz-math/index.js +131 -0
- package/blz-mongodb/index.js +326 -0
- package/blz-rds/__test__/scape.test.js +58 -0
- package/blz-rds/blz-rds-executor.js +578 -0
- package/blz-rds/blz-rds-helper.js +310 -0
- package/blz-rds/commands/core/add.js +13 -0
- package/blz-rds/commands/core/and.js +18 -0
- package/blz-rds/commands/core/asc.js +10 -0
- package/blz-rds/commands/core/avg.js +10 -0
- package/blz-rds/commands/core/column-ref.js +8 -0
- package/blz-rds/commands/core/count-distinct.js +10 -0
- package/blz-rds/commands/core/count.js +10 -0
- package/blz-rds/commands/core/decimal.js +8 -0
- package/blz-rds/commands/core/desc.js +10 -0
- package/blz-rds/commands/core/distinct.js +10 -0
- package/blz-rds/commands/core/divide.js +11 -0
- package/blz-rds/commands/core/embedded-exists.js +17 -0
- package/blz-rds/commands/core/embedded-select.js +17 -0
- package/blz-rds/commands/core/equals.js +9 -0
- package/blz-rds/commands/core/false.js +8 -0
- package/blz-rds/commands/core/greater-or-equal.js +9 -0
- package/blz-rds/commands/core/greater.js +9 -0
- package/blz-rds/commands/core/in.js +9 -0
- package/blz-rds/commands/core/integer.js +8 -0
- package/blz-rds/commands/core/is-not-null.js +11 -0
- package/blz-rds/commands/core/is-null-or-value.js +10 -0
- package/blz-rds/commands/core/is-null.js +11 -0
- package/blz-rds/commands/core/less-or-equal.js +9 -0
- package/blz-rds/commands/core/less-unary.js +12 -0
- package/blz-rds/commands/core/less.js +9 -0
- package/blz-rds/commands/core/like.js +12 -0
- package/blz-rds/commands/core/max.js +10 -0
- package/blz-rds/commands/core/min.js +10 -0
- package/blz-rds/commands/core/multiply.js +13 -0
- package/blz-rds/commands/core/not-equals.js +9 -0
- package/blz-rds/commands/core/not-in.js +9 -0
- package/blz-rds/commands/core/not.js +13 -0
- package/blz-rds/commands/core/null.js +8 -0
- package/blz-rds/commands/core/nvl.js +11 -0
- package/blz-rds/commands/core/or.js +13 -0
- package/blz-rds/commands/core/parameter.js +34 -0
- package/blz-rds/commands/core/remainder.js +16 -0
- package/blz-rds/commands/core/string.js +8 -0
- package/blz-rds/commands/core/subtract.js +13 -0
- package/blz-rds/commands/core/sum.js +10 -0
- package/blz-rds/commands/core/true.js +8 -0
- package/blz-rds/commands/core/tuple.js +13 -0
- package/blz-rds/commands/datetimes/add-days.js +11 -0
- package/blz-rds/commands/datetimes/add-hours.js +11 -0
- package/blz-rds/commands/datetimes/add-milliseconds.js +11 -0
- package/blz-rds/commands/datetimes/add-minutes.js +11 -0
- package/blz-rds/commands/datetimes/add-months.js +11 -0
- package/blz-rds/commands/datetimes/add-seconds.js +11 -0
- package/blz-rds/commands/datetimes/add-years.js +11 -0
- package/blz-rds/commands/datetimes/date-diff.js +11 -0
- package/blz-rds/commands/datetimes/date.js +12 -0
- package/blz-rds/commands/datetimes/datetime-diff.js +11 -0
- package/blz-rds/commands/datetimes/datetime.js +15 -0
- package/blz-rds/commands/datetimes/day.js +10 -0
- package/blz-rds/commands/datetimes/hour.js +10 -0
- package/blz-rds/commands/datetimes/millisecond.js +10 -0
- package/blz-rds/commands/datetimes/minute.js +10 -0
- package/blz-rds/commands/datetimes/month-text.js +10 -0
- package/blz-rds/commands/datetimes/month.js +10 -0
- package/blz-rds/commands/datetimes/now.js +9 -0
- package/blz-rds/commands/datetimes/second.js +10 -0
- package/blz-rds/commands/datetimes/subtract-days.js +11 -0
- package/blz-rds/commands/datetimes/subtract-hours.js +11 -0
- package/blz-rds/commands/datetimes/subtract-milliseconds.js +11 -0
- package/blz-rds/commands/datetimes/subtract-minutes.js +11 -0
- package/blz-rds/commands/datetimes/subtract-seconds.js +11 -0
- package/blz-rds/commands/datetimes/time-diff.js +11 -0
- package/blz-rds/commands/datetimes/time.js +13 -0
- package/blz-rds/commands/datetimes/today.js +9 -0
- package/blz-rds/commands/datetimes/week-day-text.js +10 -0
- package/blz-rds/commands/datetimes/week-day.js +10 -0
- package/blz-rds/commands/datetimes/week.js +10 -0
- package/blz-rds/commands/datetimes/year.js +10 -0
- package/blz-rds/commands/math/abs.js +10 -0
- package/blz-rds/commands/math/acos.js +10 -0
- package/blz-rds/commands/math/asin.js +10 -0
- package/blz-rds/commands/math/atan.js +10 -0
- package/blz-rds/commands/math/atan2.js +11 -0
- package/blz-rds/commands/math/ceil.js +10 -0
- package/blz-rds/commands/math/cos.js +10 -0
- package/blz-rds/commands/math/cosh.js +10 -0
- package/blz-rds/commands/math/exp.js +10 -0
- package/blz-rds/commands/math/floor.js +10 -0
- package/blz-rds/commands/math/log.js +18 -0
- package/blz-rds/commands/math/log10.js +10 -0
- package/blz-rds/commands/math/pow.js +11 -0
- package/blz-rds/commands/math/random.js +9 -0
- package/blz-rds/commands/math/round.js +18 -0
- package/blz-rds/commands/math/sign.js +10 -0
- package/blz-rds/commands/math/sin.js +10 -0
- package/blz-rds/commands/math/sinh.js +10 -0
- package/blz-rds/commands/math/sqrt.js +10 -0
- package/blz-rds/commands/math/tan.js +10 -0
- package/blz-rds/commands/math/tanh.js +10 -0
- package/blz-rds/commands/math/trunc.js +18 -0
- package/blz-rds/commands/strings/concat.js +20 -0
- package/blz-rds/commands/strings/contains.js +12 -0
- package/blz-rds/commands/strings/ends-with.js +12 -0
- package/blz-rds/commands/strings/index-of.js +11 -0
- package/blz-rds/commands/strings/is-null-or-empty.js +11 -0
- package/blz-rds/commands/strings/is-null-or-white-space.js +11 -0
- package/blz-rds/commands/strings/join.js +22 -0
- package/blz-rds/commands/strings/last-index-of.js +11 -0
- package/blz-rds/commands/strings/length.js +10 -0
- package/blz-rds/commands/strings/pad-left.js +20 -0
- package/blz-rds/commands/strings/pad-right.js +20 -0
- package/blz-rds/commands/strings/replace.js +12 -0
- package/blz-rds/commands/strings/starts-with.js +12 -0
- package/blz-rds/commands/strings/substring.js +12 -0
- package/blz-rds/commands/strings/to-lower.js +10 -0
- package/blz-rds/commands/strings/to-upper.js +10 -0
- package/blz-rds/commands/strings/trim-end.js +10 -0
- package/blz-rds/commands/strings/trim-start.js +10 -0
- package/blz-rds/commands/strings/trim.js +10 -0
- package/blz-rds/index.js +744 -0
- package/blz-rds-mysql/base.js +857 -0
- package/blz-rds-mysql/connection-manager.js +129 -0
- package/blz-rds-mysql/execute-bulk-insert.js +35 -0
- package/blz-rds-mysql/execute-bulk-merge.js +45 -0
- package/blz-rds-mysql/execute-non-query.js +34 -0
- package/blz-rds-mysql/execute-query.js +50 -0
- package/blz-rds-mysql/index.js +41 -0
- package/blz-rds-mysql/stored-procedure.js +207 -0
- package/blz-rds-mysqlx/base.js +846 -0
- package/blz-rds-mysqlx/connection-manager.js +141 -0
- package/blz-rds-mysqlx/execute-bulk-insert.js +35 -0
- package/blz-rds-mysqlx/execute-bulk-merge.js +45 -0
- package/blz-rds-mysqlx/execute-non-query.js +29 -0
- package/blz-rds-mysqlx/execute-query.js +39 -0
- package/blz-rds-mysqlx/index.js +41 -0
- package/blz-rds-mysqlx/stored-procedure.js +179 -0
- package/blz-rds-oracle/index.js +539 -0
- package/blz-rds-postgres/base.js +861 -0
- package/blz-rds-postgres/connection-manager.js +225 -0
- package/blz-rds-postgres/execute-bulk-insert.js +81 -0
- package/blz-rds-postgres/execute-bulk-merge.js +93 -0
- package/blz-rds-postgres/execute-non-query.js +23 -0
- package/blz-rds-postgres/execute-query.js +37 -0
- package/blz-rds-postgres/index.js +41 -0
- package/blz-rds-postgres/result-set.js +51 -0
- package/blz-rds-postgres/stored-procedure.js +116 -0
- package/blz-redis/index.js +217 -0
- package/blz-redis/lib/redisCache.js +265 -0
- package/blz-regex/index.js +25 -0
- package/blz-security/.eslintrc.js +15 -0
- package/blz-security/__test__/AuthorizationKpn.yaml +1149 -0
- package/blz-security/__test__/FinancingSetting.yaml +177 -0
- package/blz-security/__test__/KpnConfigPortal.yaml +330 -0
- package/blz-security/__test__/OrderManagement.yaml +5190 -0
- package/blz-security/__test__/Security.yaml +128 -0
- package/blz-security/__test__/autorization.test.js +105 -0
- package/blz-security/__test__/autorizationKpn.test.js +42 -0
- package/blz-security/__test__/orderManagement.test.js +26 -0
- package/blz-security/__test__/secureUrl.test.js +79 -0
- package/blz-security/__test__/solveMergeRule.test.js +109 -0
- package/blz-security/__test__/sqlInjectionGuard.test.js +203 -0
- package/blz-security/__test__/xssGuard.test.js +204 -0
- package/blz-security/authorizationService.js +537 -0
- package/blz-security/config/global.js +8 -0
- package/blz-security/config/welcome +8 -0
- package/blz-security/doc/README.md +75 -0
- package/blz-security/filescanner/index.js +46 -0
- package/blz-security/helpers/consts.js +229 -0
- package/blz-security/helpers/utils.js +267 -0
- package/blz-security/implementations/cache.js +90 -0
- package/blz-security/implementations/oidc.js +404 -0
- package/blz-security/implementations/pkceCacheStore.js +23 -0
- package/blz-security/implementations/saml.js +10 -0
- package/blz-security/implementations/uma.js +63 -0
- package/blz-security/implementations/webAuthn.js +9 -0
- package/blz-security/implementations/wstg.js +72 -0
- package/blz-security/index.js +77 -0
- package/blz-security/lab/index.js +43 -0
- package/blz-security/middleware/HapiServerAzureAd.js +681 -0
- package/blz-security/middleware/HapiServerKeycloak.js +876 -0
- package/blz-security/middleware/HapiServerSimToken.js +286 -0
- package/blz-security/middleware/hapi.js +555 -0
- package/blz-security/middleware/hapiServer.js +1008 -0
- package/blz-security/navigationMemoryRepository.js +15 -0
- package/blz-security/navigationMongoDbRepository.js +73 -0
- package/blz-security/secureUrlService.js +47 -0
- package/blz-security/securityService.js +413 -0
- package/blz-security/sqlInjectionGuard.js +162 -0
- package/blz-security/templates/forbidden.html +0 -0
- package/blz-security/templates/session-iframe-azure-ad.html +7 -0
- package/blz-security/templates/session-iframe.html +73 -0
- package/blz-security/templates/unauthorized.html +1 -0
- package/blz-security/xssGuard.js +87 -0
- package/blz-strings/index.js +167 -0
- package/blz-uuid/index.js +7 -0
- package/blz-yaml/index.js +19 -0
- package/index.js +84 -0
- package/package.json +40 -53
- package/process-managers/index.js +422 -0
- package/dist/blz-base/health/index.d.ts +0 -1
- package/dist/blz-base/health/index.js +0 -1
- package/dist/blz-base/index.d.ts +0 -108
- package/dist/blz-base/index.js +0 -1
- package/dist/blz-cache/LruCache.d.ts +0 -31
- package/dist/blz-cache/LruCache.js +0 -1
- package/dist/blz-cache/index.d.ts +0 -2
- package/dist/blz-cache/index.js +0 -1
- package/dist/blz-config/index.d.ts +0 -16
- package/dist/blz-config/index.js +0 -1
- package/dist/blz-core/index.d.ts +0 -32
- package/dist/blz-core/index.js +0 -1
- package/dist/blz-cryptography/index.d.ts +0 -2
- package/dist/blz-cryptography/index.js +0 -1
- package/dist/blz-datetimes/index.d.ts +0 -35
- package/dist/blz-datetimes/index.js +0 -1
- package/dist/blz-file/fileService.d.ts +0 -25
- package/dist/blz-file/fileService.js +0 -1
- package/dist/blz-file/index.d.ts +0 -2
- package/dist/blz-file/index.js +0 -1
- package/dist/blz-file/index.test.js +0 -1
- package/dist/blz-file/lab.js +0 -1
- package/dist/blz-hazelcast/index.d.ts +0 -25
- package/dist/blz-hazelcast/index.js +0 -1
- package/dist/blz-hazelcast/lib/credentials.d.ts +0 -10
- package/dist/blz-hazelcast/lib/credentials.js +0 -1
- package/dist/blz-hazelcast/lib/credentialsFactory.d.ts +0 -1
- package/dist/blz-hazelcast/lib/credentialsFactory.js +0 -1
- package/dist/blz-hazelcast/lib/hazelcastCache.d.ts +0 -27
- package/dist/blz-hazelcast/lib/hazelcastCache.js +0 -1
- package/dist/blz-iterable/index.d.ts +0 -49
- package/dist/blz-iterable/index.js +0 -1
- package/dist/blz-json-schema/index.d.ts +0 -1
- package/dist/blz-json-schema/index.js +0 -1
- package/dist/blz-jwt/index.d.ts +0 -12
- package/dist/blz-jwt/index.js +0 -1
- package/dist/blz-kafka/index.d.ts +0 -9
- package/dist/blz-kafka/index.js +0 -1
- package/dist/blz-math/index.d.ts +0 -22
- package/dist/blz-math/index.js +0 -1
- package/dist/blz-mongodb/index.d.ts +0 -28
- package/dist/blz-mongodb/index.js +0 -1
- package/dist/blz-rds/__test__/scape.test.js +0 -1
- package/dist/blz-rds/blz-rds-executor.d.ts +0 -4
- package/dist/blz-rds/blz-rds-executor.js +0 -1
- package/dist/blz-rds/blz-rds-helper.d.ts +0 -5
- package/dist/blz-rds/blz-rds-helper.js +0 -1
- package/dist/blz-rds/commands/core/add.d.ts +0 -2
- package/dist/blz-rds/commands/core/add.js +0 -1
- package/dist/blz-rds/commands/core/and.d.ts +0 -3
- package/dist/blz-rds/commands/core/and.js +0 -1
- package/dist/blz-rds/commands/core/asc.d.ts +0 -2
- package/dist/blz-rds/commands/core/asc.js +0 -1
- package/dist/blz-rds/commands/core/avg.d.ts +0 -2
- package/dist/blz-rds/commands/core/avg.js +0 -1
- package/dist/blz-rds/commands/core/column-ref.d.ts +0 -2
- package/dist/blz-rds/commands/core/column-ref.js +0 -1
- package/dist/blz-rds/commands/core/count-distinct.d.ts +0 -2
- package/dist/blz-rds/commands/core/count-distinct.js +0 -1
- package/dist/blz-rds/commands/core/count.d.ts +0 -2
- package/dist/blz-rds/commands/core/count.js +0 -1
- package/dist/blz-rds/commands/core/decimal.d.ts +0 -2
- package/dist/blz-rds/commands/core/decimal.js +0 -1
- package/dist/blz-rds/commands/core/desc.d.ts +0 -2
- package/dist/blz-rds/commands/core/desc.js +0 -1
- package/dist/blz-rds/commands/core/distinct.d.ts +0 -2
- package/dist/blz-rds/commands/core/distinct.js +0 -1
- package/dist/blz-rds/commands/core/divide.d.ts +0 -2
- package/dist/blz-rds/commands/core/divide.js +0 -1
- package/dist/blz-rds/commands/core/embedded-exists.d.ts +0 -3
- package/dist/blz-rds/commands/core/embedded-exists.js +0 -1
- package/dist/blz-rds/commands/core/embedded-select.d.ts +0 -2
- package/dist/blz-rds/commands/core/embedded-select.js +0 -1
- package/dist/blz-rds/commands/core/equals.d.ts +0 -3
- package/dist/blz-rds/commands/core/equals.js +0 -1
- package/dist/blz-rds/commands/core/false.d.ts +0 -2
- package/dist/blz-rds/commands/core/false.js +0 -1
- package/dist/blz-rds/commands/core/greater-or-equal.d.ts +0 -3
- package/dist/blz-rds/commands/core/greater-or-equal.js +0 -1
- package/dist/blz-rds/commands/core/greater.d.ts +0 -3
- package/dist/blz-rds/commands/core/greater.js +0 -1
- package/dist/blz-rds/commands/core/in.d.ts +0 -3
- package/dist/blz-rds/commands/core/in.js +0 -1
- package/dist/blz-rds/commands/core/integer.d.ts +0 -2
- package/dist/blz-rds/commands/core/integer.js +0 -1
- package/dist/blz-rds/commands/core/is-not-null.d.ts +0 -3
- package/dist/blz-rds/commands/core/is-not-null.js +0 -1
- package/dist/blz-rds/commands/core/is-null-or-value.d.ts +0 -3
- package/dist/blz-rds/commands/core/is-null-or-value.js +0 -1
- package/dist/blz-rds/commands/core/is-null.d.ts +0 -3
- package/dist/blz-rds/commands/core/is-null.js +0 -1
- package/dist/blz-rds/commands/core/less-or-equal.d.ts +0 -3
- package/dist/blz-rds/commands/core/less-or-equal.js +0 -1
- package/dist/blz-rds/commands/core/less-unary.d.ts +0 -2
- package/dist/blz-rds/commands/core/less-unary.js +0 -1
- package/dist/blz-rds/commands/core/less.d.ts +0 -3
- package/dist/blz-rds/commands/core/less.js +0 -1
- package/dist/blz-rds/commands/core/like.d.ts +0 -3
- package/dist/blz-rds/commands/core/like.js +0 -1
- package/dist/blz-rds/commands/core/max.d.ts +0 -2
- package/dist/blz-rds/commands/core/max.js +0 -1
- package/dist/blz-rds/commands/core/min.d.ts +0 -2
- package/dist/blz-rds/commands/core/min.js +0 -1
- package/dist/blz-rds/commands/core/multiply.d.ts +0 -2
- package/dist/blz-rds/commands/core/multiply.js +0 -1
- package/dist/blz-rds/commands/core/not-equals.d.ts +0 -3
- package/dist/blz-rds/commands/core/not-equals.js +0 -1
- package/dist/blz-rds/commands/core/not-in.d.ts +0 -3
- package/dist/blz-rds/commands/core/not-in.js +0 -1
- package/dist/blz-rds/commands/core/not.d.ts +0 -3
- package/dist/blz-rds/commands/core/not.js +0 -1
- package/dist/blz-rds/commands/core/null.d.ts +0 -2
- package/dist/blz-rds/commands/core/null.js +0 -1
- package/dist/blz-rds/commands/core/nvl.d.ts +0 -2
- package/dist/blz-rds/commands/core/nvl.js +0 -1
- package/dist/blz-rds/commands/core/or.d.ts +0 -3
- package/dist/blz-rds/commands/core/or.js +0 -1
- package/dist/blz-rds/commands/core/parameter.d.ts +0 -2
- package/dist/blz-rds/commands/core/parameter.js +0 -1
- package/dist/blz-rds/commands/core/remainder.d.ts +0 -2
- package/dist/blz-rds/commands/core/remainder.js +0 -1
- package/dist/blz-rds/commands/core/string.d.ts +0 -2
- package/dist/blz-rds/commands/core/string.js +0 -1
- package/dist/blz-rds/commands/core/subtract.d.ts +0 -2
- package/dist/blz-rds/commands/core/subtract.js +0 -1
- package/dist/blz-rds/commands/core/sum.d.ts +0 -2
- package/dist/blz-rds/commands/core/sum.js +0 -1
- package/dist/blz-rds/commands/core/true.d.ts +0 -2
- package/dist/blz-rds/commands/core/true.js +0 -1
- package/dist/blz-rds/commands/core/tuple.d.ts +0 -2
- package/dist/blz-rds/commands/core/tuple.js +0 -1
- package/dist/blz-rds/commands/datetimes/add-days.d.ts +0 -2
- package/dist/blz-rds/commands/datetimes/add-days.js +0 -1
- package/dist/blz-rds/commands/datetimes/add-hours.d.ts +0 -2
- package/dist/blz-rds/commands/datetimes/add-hours.js +0 -1
- package/dist/blz-rds/commands/datetimes/add-milliseconds.d.ts +0 -2
- package/dist/blz-rds/commands/datetimes/add-milliseconds.js +0 -1
- package/dist/blz-rds/commands/datetimes/add-minutes.d.ts +0 -2
- package/dist/blz-rds/commands/datetimes/add-minutes.js +0 -1
- package/dist/blz-rds/commands/datetimes/add-months.d.ts +0 -2
- package/dist/blz-rds/commands/datetimes/add-months.js +0 -1
- package/dist/blz-rds/commands/datetimes/add-seconds.d.ts +0 -2
- package/dist/blz-rds/commands/datetimes/add-seconds.js +0 -1
- package/dist/blz-rds/commands/datetimes/add-years.d.ts +0 -2
- package/dist/blz-rds/commands/datetimes/add-years.js +0 -1
- package/dist/blz-rds/commands/datetimes/date-diff.d.ts +0 -2
- package/dist/blz-rds/commands/datetimes/date-diff.js +0 -1
- package/dist/blz-rds/commands/datetimes/date.d.ts +0 -2
- package/dist/blz-rds/commands/datetimes/date.js +0 -1
- package/dist/blz-rds/commands/datetimes/datetime-diff.d.ts +0 -2
- package/dist/blz-rds/commands/datetimes/datetime-diff.js +0 -1
- package/dist/blz-rds/commands/datetimes/datetime.d.ts +0 -2
- package/dist/blz-rds/commands/datetimes/datetime.js +0 -1
- package/dist/blz-rds/commands/datetimes/day.d.ts +0 -2
- package/dist/blz-rds/commands/datetimes/day.js +0 -1
- package/dist/blz-rds/commands/datetimes/hour.d.ts +0 -2
- package/dist/blz-rds/commands/datetimes/hour.js +0 -1
- package/dist/blz-rds/commands/datetimes/millisecond.d.ts +0 -2
- package/dist/blz-rds/commands/datetimes/millisecond.js +0 -1
- package/dist/blz-rds/commands/datetimes/minute.d.ts +0 -2
- package/dist/blz-rds/commands/datetimes/minute.js +0 -1
- package/dist/blz-rds/commands/datetimes/month-text.d.ts +0 -2
- package/dist/blz-rds/commands/datetimes/month-text.js +0 -1
- package/dist/blz-rds/commands/datetimes/month.d.ts +0 -2
- package/dist/blz-rds/commands/datetimes/month.js +0 -1
- package/dist/blz-rds/commands/datetimes/now.d.ts +0 -2
- package/dist/blz-rds/commands/datetimes/now.js +0 -1
- package/dist/blz-rds/commands/datetimes/second.d.ts +0 -2
- package/dist/blz-rds/commands/datetimes/second.js +0 -1
- package/dist/blz-rds/commands/datetimes/subtract-days.d.ts +0 -2
- package/dist/blz-rds/commands/datetimes/subtract-days.js +0 -1
- package/dist/blz-rds/commands/datetimes/subtract-hours.d.ts +0 -2
- package/dist/blz-rds/commands/datetimes/subtract-hours.js +0 -1
- package/dist/blz-rds/commands/datetimes/subtract-milliseconds.d.ts +0 -2
- package/dist/blz-rds/commands/datetimes/subtract-milliseconds.js +0 -1
- package/dist/blz-rds/commands/datetimes/subtract-minutes.d.ts +0 -2
- package/dist/blz-rds/commands/datetimes/subtract-minutes.js +0 -1
- package/dist/blz-rds/commands/datetimes/subtract-seconds.d.ts +0 -2
- package/dist/blz-rds/commands/datetimes/subtract-seconds.js +0 -1
- package/dist/blz-rds/commands/datetimes/time-diff.d.ts +0 -2
- package/dist/blz-rds/commands/datetimes/time-diff.js +0 -1
- package/dist/blz-rds/commands/datetimes/time.d.ts +0 -2
- package/dist/blz-rds/commands/datetimes/time.js +0 -1
- package/dist/blz-rds/commands/datetimes/today.d.ts +0 -2
- package/dist/blz-rds/commands/datetimes/today.js +0 -1
- package/dist/blz-rds/commands/datetimes/week-day-text.d.ts +0 -2
- package/dist/blz-rds/commands/datetimes/week-day-text.js +0 -1
- package/dist/blz-rds/commands/datetimes/week-day.d.ts +0 -2
- package/dist/blz-rds/commands/datetimes/week-day.js +0 -1
- package/dist/blz-rds/commands/datetimes/week.d.ts +0 -2
- package/dist/blz-rds/commands/datetimes/week.js +0 -1
- package/dist/blz-rds/commands/datetimes/year.d.ts +0 -2
- package/dist/blz-rds/commands/datetimes/year.js +0 -1
- package/dist/blz-rds/commands/math/abs.d.ts +0 -2
- package/dist/blz-rds/commands/math/abs.js +0 -1
- package/dist/blz-rds/commands/math/acos.d.ts +0 -2
- package/dist/blz-rds/commands/math/acos.js +0 -1
- package/dist/blz-rds/commands/math/asin.d.ts +0 -2
- package/dist/blz-rds/commands/math/asin.js +0 -1
- package/dist/blz-rds/commands/math/atan.d.ts +0 -2
- package/dist/blz-rds/commands/math/atan.js +0 -1
- package/dist/blz-rds/commands/math/atan2.d.ts +0 -2
- package/dist/blz-rds/commands/math/atan2.js +0 -1
- package/dist/blz-rds/commands/math/ceil.d.ts +0 -2
- package/dist/blz-rds/commands/math/ceil.js +0 -1
- package/dist/blz-rds/commands/math/cos.d.ts +0 -2
- package/dist/blz-rds/commands/math/cos.js +0 -1
- package/dist/blz-rds/commands/math/cosh.d.ts +0 -2
- package/dist/blz-rds/commands/math/cosh.js +0 -1
- package/dist/blz-rds/commands/math/exp.d.ts +0 -2
- package/dist/blz-rds/commands/math/exp.js +0 -1
- package/dist/blz-rds/commands/math/floor.d.ts +0 -2
- package/dist/blz-rds/commands/math/floor.js +0 -1
- package/dist/blz-rds/commands/math/log.d.ts +0 -2
- package/dist/blz-rds/commands/math/log.js +0 -1
- package/dist/blz-rds/commands/math/log10.d.ts +0 -2
- package/dist/blz-rds/commands/math/log10.js +0 -1
- package/dist/blz-rds/commands/math/pow.d.ts +0 -2
- package/dist/blz-rds/commands/math/pow.js +0 -1
- package/dist/blz-rds/commands/math/random.d.ts +0 -2
- package/dist/blz-rds/commands/math/random.js +0 -1
- package/dist/blz-rds/commands/math/round.d.ts +0 -2
- package/dist/blz-rds/commands/math/round.js +0 -1
- package/dist/blz-rds/commands/math/sign.d.ts +0 -2
- package/dist/blz-rds/commands/math/sign.js +0 -1
- package/dist/blz-rds/commands/math/sin.d.ts +0 -2
- package/dist/blz-rds/commands/math/sin.js +0 -1
- package/dist/blz-rds/commands/math/sinh.d.ts +0 -2
- package/dist/blz-rds/commands/math/sinh.js +0 -1
- package/dist/blz-rds/commands/math/sqrt.d.ts +0 -2
- package/dist/blz-rds/commands/math/sqrt.js +0 -1
- package/dist/blz-rds/commands/math/tan.d.ts +0 -2
- package/dist/blz-rds/commands/math/tan.js +0 -1
- package/dist/blz-rds/commands/math/tanh.d.ts +0 -2
- package/dist/blz-rds/commands/math/tanh.js +0 -1
- package/dist/blz-rds/commands/math/trunc.d.ts +0 -2
- package/dist/blz-rds/commands/math/trunc.js +0 -1
- package/dist/blz-rds/commands/strings/concat.d.ts +0 -2
- package/dist/blz-rds/commands/strings/concat.js +0 -1
- package/dist/blz-rds/commands/strings/contains.d.ts +0 -3
- package/dist/blz-rds/commands/strings/contains.js +0 -1
- package/dist/blz-rds/commands/strings/ends-with.d.ts +0 -3
- package/dist/blz-rds/commands/strings/ends-with.js +0 -1
- package/dist/blz-rds/commands/strings/index-of.d.ts +0 -2
- package/dist/blz-rds/commands/strings/index-of.js +0 -1
- package/dist/blz-rds/commands/strings/is-null-or-empty.d.ts +0 -3
- package/dist/blz-rds/commands/strings/is-null-or-empty.js +0 -1
- package/dist/blz-rds/commands/strings/is-null-or-white-space.d.ts +0 -3
- package/dist/blz-rds/commands/strings/is-null-or-white-space.js +0 -1
- package/dist/blz-rds/commands/strings/join.d.ts +0 -2
- package/dist/blz-rds/commands/strings/join.js +0 -1
- package/dist/blz-rds/commands/strings/last-index-of.d.ts +0 -2
- package/dist/blz-rds/commands/strings/last-index-of.js +0 -1
- package/dist/blz-rds/commands/strings/length.d.ts +0 -2
- package/dist/blz-rds/commands/strings/length.js +0 -1
- package/dist/blz-rds/commands/strings/pad-left.d.ts +0 -2
- package/dist/blz-rds/commands/strings/pad-left.js +0 -1
- package/dist/blz-rds/commands/strings/pad-right.d.ts +0 -2
- package/dist/blz-rds/commands/strings/pad-right.js +0 -1
- package/dist/blz-rds/commands/strings/replace.d.ts +0 -2
- package/dist/blz-rds/commands/strings/replace.js +0 -1
- package/dist/blz-rds/commands/strings/starts-with.d.ts +0 -3
- package/dist/blz-rds/commands/strings/starts-with.js +0 -1
- package/dist/blz-rds/commands/strings/substring.d.ts +0 -2
- package/dist/blz-rds/commands/strings/substring.js +0 -1
- package/dist/blz-rds/commands/strings/to-lower.d.ts +0 -2
- package/dist/blz-rds/commands/strings/to-lower.js +0 -1
- package/dist/blz-rds/commands/strings/to-upper.d.ts +0 -2
- package/dist/blz-rds/commands/strings/to-upper.js +0 -1
- package/dist/blz-rds/commands/strings/trim-end.d.ts +0 -2
- package/dist/blz-rds/commands/strings/trim-end.js +0 -1
- package/dist/blz-rds/commands/strings/trim-start.d.ts +0 -2
- package/dist/blz-rds/commands/strings/trim-start.js +0 -1
- package/dist/blz-rds/commands/strings/trim.d.ts +0 -2
- package/dist/blz-rds/commands/strings/trim.js +0 -1
- package/dist/blz-rds/index.d.ts +0 -53
- package/dist/blz-rds/index.js +0 -1
- package/dist/blz-rds-mysql/base.d.ts +0 -83
- package/dist/blz-rds-mysql/base.js +0 -1
- package/dist/blz-rds-mysql/connection-manager.d.ts +0 -8
- package/dist/blz-rds-mysql/connection-manager.js +0 -1
- package/dist/blz-rds-mysql/execute-bulk-insert.d.ts +0 -2
- package/dist/blz-rds-mysql/execute-bulk-insert.js +0 -1
- package/dist/blz-rds-mysql/execute-bulk-merge.d.ts +0 -2
- package/dist/blz-rds-mysql/execute-bulk-merge.js +0 -1
- package/dist/blz-rds-mysql/execute-non-query.d.ts +0 -14
- package/dist/blz-rds-mysql/execute-non-query.js +0 -1
- package/dist/blz-rds-mysql/execute-query.d.ts +0 -11
- package/dist/blz-rds-mysql/execute-query.js +0 -1
- package/dist/blz-rds-mysql/index.d.ts +0 -9
- package/dist/blz-rds-mysql/index.js +0 -1
- package/dist/blz-rds-mysql/stored-procedure.d.ts +0 -19
- package/dist/blz-rds-mysql/stored-procedure.js +0 -1
- package/dist/blz-rds-mysqlx/base.d.ts +0 -83
- package/dist/blz-rds-mysqlx/base.js +0 -1
- package/dist/blz-rds-mysqlx/connection-manager.d.ts +0 -6
- package/dist/blz-rds-mysqlx/connection-manager.js +0 -1
- package/dist/blz-rds-mysqlx/execute-bulk-insert.d.ts +0 -2
- package/dist/blz-rds-mysqlx/execute-bulk-insert.js +0 -1
- package/dist/blz-rds-mysqlx/execute-bulk-merge.d.ts +0 -2
- package/dist/blz-rds-mysqlx/execute-bulk-merge.js +0 -1
- package/dist/blz-rds-mysqlx/execute-non-query.d.ts +0 -4
- package/dist/blz-rds-mysqlx/execute-non-query.js +0 -1
- package/dist/blz-rds-mysqlx/execute-query.d.ts +0 -7
- package/dist/blz-rds-mysqlx/execute-query.js +0 -1
- package/dist/blz-rds-mysqlx/index.d.ts +0 -9
- package/dist/blz-rds-mysqlx/index.js +0 -1
- package/dist/blz-rds-mysqlx/stored-procedure.d.ts +0 -20
- package/dist/blz-rds-mysqlx/stored-procedure.js +0 -1
- package/dist/blz-rds-oracle/index.d.ts +0 -25
- package/dist/blz-rds-oracle/index.js +0 -1
- package/dist/blz-rds-postgres/base.d.ts +0 -94
- package/dist/blz-rds-postgres/base.js +0 -1
- package/dist/blz-rds-postgres/connection-manager.d.ts +0 -6
- package/dist/blz-rds-postgres/connection-manager.js +0 -1
- package/dist/blz-rds-postgres/execute-bulk-insert.d.ts +0 -5
- package/dist/blz-rds-postgres/execute-bulk-insert.js +0 -1
- package/dist/blz-rds-postgres/execute-bulk-merge.d.ts +0 -4
- package/dist/blz-rds-postgres/execute-bulk-merge.js +0 -1
- package/dist/blz-rds-postgres/execute-non-query.d.ts +0 -12
- package/dist/blz-rds-postgres/execute-non-query.js +0 -1
- package/dist/blz-rds-postgres/execute-query.d.ts +0 -4
- package/dist/blz-rds-postgres/execute-query.js +0 -1
- package/dist/blz-rds-postgres/index.d.ts +0 -9
- package/dist/blz-rds-postgres/index.js +0 -1
- package/dist/blz-rds-postgres/result-set.js +0 -1
- package/dist/blz-rds-postgres/stored-procedure.d.ts +0 -19
- package/dist/blz-rds-postgres/stored-procedure.js +0 -1
- package/dist/blz-redis/index.d.ts +0 -31
- package/dist/blz-redis/index.js +0 -1
- package/dist/blz-redis/lib/redisCache.d.ts +0 -33
- package/dist/blz-redis/lib/redisCache.js +0 -1
- package/dist/blz-regex/index.d.ts +0 -3
- package/dist/blz-regex/index.js +0 -1
- package/dist/blz-security/__test__/autorization.test.js +0 -1
- package/dist/blz-security/__test__/autorizationKpn.test.js +0 -1
- package/dist/blz-security/__test__/orderManagement.test.js +0 -1
- package/dist/blz-security/__test__/secureUrl.test.js +0 -1
- package/dist/blz-security/__test__/solveMergeRule.test.js +0 -1
- package/dist/blz-security/__test__/sqlInjectionGuard.test.js +0 -1
- package/dist/blz-security/__test__/xssGuard.test.js +0 -1
- package/dist/blz-security/authorizationService.d.ts +0 -42
- package/dist/blz-security/authorizationService.js +0 -2
- package/dist/blz-security/config/global.js +0 -1
- package/dist/blz-security/filescanner/index.d.ts +0 -24
- package/dist/blz-security/filescanner/index.js +0 -1
- package/dist/blz-security/helpers/consts.d.ts +0 -28
- package/dist/blz-security/helpers/consts.js +0 -1
- package/dist/blz-security/helpers/utils.d.ts +0 -82
- package/dist/blz-security/helpers/utils.js +0 -1
- package/dist/blz-security/implementations/cache.d.ts +0 -58
- package/dist/blz-security/implementations/cache.js +0 -1
- package/dist/blz-security/implementations/oidc.d.ts +0 -100
- package/dist/blz-security/implementations/oidc.js +0 -1
- package/dist/blz-security/implementations/pkceCacheStore.d.ts +0 -2
- package/dist/blz-security/implementations/pkceCacheStore.js +0 -1
- package/dist/blz-security/implementations/saml.js +0 -1
- package/dist/blz-security/implementations/uma.d.ts +0 -31
- package/dist/blz-security/implementations/uma.js +0 -1
- package/dist/blz-security/implementations/webAuthn.js +0 -1
- package/dist/blz-security/implementations/wstg.js +0 -1
- package/dist/blz-security/index.d.ts +0 -4
- package/dist/blz-security/index.js +0 -2
- package/dist/blz-security/lab/index.js +0 -1
- package/dist/blz-security/middleware/HapiServerAzureAd.d.ts +0 -26
- package/dist/blz-security/middleware/HapiServerAzureAd.js +0 -1
- package/dist/blz-security/middleware/HapiServerKeycloak.d.ts +0 -47
- package/dist/blz-security/middleware/HapiServerKeycloak.js +0 -1
- package/dist/blz-security/middleware/HapiServerSimToken.d.ts +0 -13
- package/dist/blz-security/middleware/HapiServerSimToken.js +0 -1
- package/dist/blz-security/middleware/hapi.d.ts +0 -14
- package/dist/blz-security/middleware/hapi.js +0 -1
- package/dist/blz-security/middleware/hapiServer.js +0 -1
- package/dist/blz-security/navigationMemoryRepository.d.ts +0 -6
- package/dist/blz-security/navigationMemoryRepository.js +0 -1
- package/dist/blz-security/navigationMongoDbRepository.d.ts +0 -15
- package/dist/blz-security/navigationMongoDbRepository.js +0 -1
- package/dist/blz-security/secureUrlService.d.ts +0 -7
- package/dist/blz-security/secureUrlService.js +0 -1
- package/dist/blz-security/securityService.d.ts +0 -72
- package/dist/blz-security/securityService.js +0 -1
- package/dist/blz-security/sqlInjectionGuard.d.ts +0 -37
- package/dist/blz-security/sqlInjectionGuard.js +0 -1
- package/dist/blz-security/xssGuard.d.ts +0 -14
- package/dist/blz-security/xssGuard.js +0 -1
- package/dist/blz-strings/index.d.ts +0 -42
- package/dist/blz-strings/index.js +0 -1
- package/dist/blz-uuid/index.d.ts +0 -1
- package/dist/blz-uuid/index.js +0 -1
- package/dist/blz-yaml/index.d.ts +0 -2
- package/dist/blz-yaml/index.js +0 -1
- package/dist/index.d.ts +0 -34
- package/dist/index.js +0 -1
- package/dist/process-managers/index.d.ts +0 -25
- package/dist/process-managers/index.js +0 -1
- /package/{dist/blz-rds-mysql → blz-rds-mysql}/syntaxis.json +0 -0
- /package/{dist/blz-rds-mysqlx → blz-rds-mysqlx}/syntaxis.json +0 -0
- /package/{dist/blz-rds-oracle → blz-rds-oracle}/syntaxis.json +0 -0
- /package/{dist/blz-rds-postgres → blz-rds-postgres}/syntaxis.json +0 -0
- /package/{dist/blz-security → blz-security}/lab/ConfigurationAdmin.agent.json +0 -0
- /package/{dist/blz-security → blz-security}/lab/frontend.json +0 -0
- /package/{dist/blz-security → blz-security}/lab/result.json +0 -0
- /package/{dist/blz-security → blz-security}/lab/resultOnWeb.json +0 -0
- /package/{dist/blz-security → blz-security}/lab/rules.json +0 -0
- /package/{dist/blz-security → blz-security}/lab/securityRules.json +0 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const mysqlx = require('@mysql/xdevapi');
|
|
3
|
+
const BlzBase = require("./base");
|
|
4
|
+
const _ = require("underscore");
|
|
5
|
+
|
|
6
|
+
//https://dev.mysql.com/doc/dev/connector-nodejs/8.0/tutorial-Connecting_to_a_Server.html
|
|
7
|
+
//https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference-jdbc-url-format.html
|
|
8
|
+
//https://dev.mysql.com/doc/refman/8.0/en/connecting-using-uri-or-key-value-pairs.html
|
|
9
|
+
|
|
10
|
+
let poolsByName = new Map();
|
|
11
|
+
|
|
12
|
+
function getParameters(config = {}) {
|
|
13
|
+
let properties = _.reduce(config.properties, (memo, value) => {
|
|
14
|
+
return memo + "," + value.key + "=" + value.value;
|
|
15
|
+
}, '');
|
|
16
|
+
return properties.slice("1");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function getObjectConfig(config = {}) {
|
|
20
|
+
if(!config.name) {
|
|
21
|
+
throw BlzBase.error('RdsMySqlException', { name: config.name });
|
|
22
|
+
}
|
|
23
|
+
let url = '';
|
|
24
|
+
if(config.customUrl) {
|
|
25
|
+
url = getCustomURL(config);
|
|
26
|
+
} else {
|
|
27
|
+
url = getURL(config);
|
|
28
|
+
}
|
|
29
|
+
let parameters = getParameters(config);
|
|
30
|
+
if(!_.isEmpty(parameters)) {
|
|
31
|
+
parameters = `?${parameters}`
|
|
32
|
+
}
|
|
33
|
+
return `${url}${parameters}`
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function getURL(config = {}) {
|
|
37
|
+
return `mysqlx://${config.user}:${config.password}@${config.host}:${config.port || 33060}/${config.database}`
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function getCustomURL(config = {}) {
|
|
41
|
+
return `${config.protocol}://${config.url}`
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function getPoolConfig(config = {}) {
|
|
45
|
+
let poolConfig = _.pick(config, "maxSize", "maxIdleTime", "queueTimeout");
|
|
46
|
+
return _.defaults(poolConfig, {
|
|
47
|
+
enabled: true,
|
|
48
|
+
maxSize: 25,
|
|
49
|
+
maxIdleTime: 0,
|
|
50
|
+
queueTimeout: 0
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async function getPool(config = {}) {
|
|
55
|
+
let key = config.name;
|
|
56
|
+
let pool = poolsByName.get(key);
|
|
57
|
+
if(pool) {
|
|
58
|
+
return pool;
|
|
59
|
+
}
|
|
60
|
+
let uri = getObjectConfig(config);
|
|
61
|
+
try {
|
|
62
|
+
pool = await mysqlx.getClient(uri, { pooling: getPoolConfig(config) });
|
|
63
|
+
} catch(error) {
|
|
64
|
+
throw BlzBase.error('RdsMysqlCannotCreatePool', { config, uri }, error);
|
|
65
|
+
}
|
|
66
|
+
pool.name = config.name;
|
|
67
|
+
poolsByName.set(key, pool);
|
|
68
|
+
return pool;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async function getConnection(pool) {
|
|
72
|
+
let session;
|
|
73
|
+
try {
|
|
74
|
+
session = await pool.getSession();
|
|
75
|
+
} catch(error) {
|
|
76
|
+
throw BlzBase.error('RdsMysqlCannotConnectToDatabase', { name: pool.name }, error);
|
|
77
|
+
}
|
|
78
|
+
session.name = pool.name;
|
|
79
|
+
return session;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async function terminate() {
|
|
83
|
+
let reject = [];
|
|
84
|
+
for (const [, pool] of poolsByName) {
|
|
85
|
+
try {
|
|
86
|
+
await pool.close();
|
|
87
|
+
} catch(error) {
|
|
88
|
+
reject.push(error);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
poolsByName.clear();
|
|
92
|
+
if(_.isEmpty(reject)) {
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
throw new Error(reject);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const createConnection = async (config) => await getConnection(await getPool(config));
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
const beginTransaction = async function(connection) {
|
|
102
|
+
try {
|
|
103
|
+
await connection.startTransaction();
|
|
104
|
+
} catch(error) {
|
|
105
|
+
throw BlzBase.error('RdsMySqlBeginTransactionError', { name: connection.name }, error);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const commitTransaction = async function(connection) {
|
|
110
|
+
try {
|
|
111
|
+
await connection.commit();
|
|
112
|
+
} catch(error) {
|
|
113
|
+
throw BlzBase.error('RdsMySqlCommitTransactionError', { name: connection.name }, error);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const rollbackTransaction = async function(connection) {
|
|
118
|
+
try {
|
|
119
|
+
await connection.rollback();
|
|
120
|
+
} catch(error) {
|
|
121
|
+
throw BlzBase.error('RdsMySqlRollbackTransactionError', { name: connection.name }, error);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const close = async function(connection) {
|
|
126
|
+
try {
|
|
127
|
+
await connection.close();
|
|
128
|
+
} catch(error) {
|
|
129
|
+
throw BlzBase.error('RdsMySqlCloseError', { name: connection.name }, error);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
module.exports = {
|
|
135
|
+
beginTransaction,
|
|
136
|
+
close,
|
|
137
|
+
commitTransaction,
|
|
138
|
+
createConnection,
|
|
139
|
+
rollbackTransaction,
|
|
140
|
+
terminate
|
|
141
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const {convertValueToDb } = require("./execute-non-query");
|
|
3
|
+
const BlzBase = require("./base");
|
|
4
|
+
|
|
5
|
+
async function executeBulkInsert(connection, sql, rows, options) {
|
|
6
|
+
const query = sql + ' ?'
|
|
7
|
+
const list = []
|
|
8
|
+
for(let i = 0; i < rows.length; i++) {
|
|
9
|
+
const row = rows[i]
|
|
10
|
+
const values = []
|
|
11
|
+
for(let j = 0; j < row.length; j++) {
|
|
12
|
+
const value = convertValueToDb(row[j])
|
|
13
|
+
values.push(value)
|
|
14
|
+
}
|
|
15
|
+
list.push(values)
|
|
16
|
+
}
|
|
17
|
+
return new Promise(function(resolve, reject){
|
|
18
|
+
connection.query(query, [list], function(error, result, fields) {
|
|
19
|
+
if(error) {
|
|
20
|
+
reject(BlzBase.error('RdsMySqlExecuteError', { name: connection.name, query, rows }, error));
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (options.autoincrementalData) {
|
|
24
|
+
const start = result.insertId
|
|
25
|
+
const end = result.insertId + (result.affectedRows - 1)
|
|
26
|
+
const ids= []
|
|
27
|
+
for (let i = start; i <= end; i++)ids.push(i)
|
|
28
|
+
resolve({ ids, affectedRows: result.affectedRows });
|
|
29
|
+
} else {
|
|
30
|
+
resolve({affectedRows: result.affectedRows});
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
module.exports = executeBulkInsert;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const {convertValueToDb } = require("./execute-non-query");
|
|
3
|
+
const BlzBase = require("./base");
|
|
4
|
+
const SqlString = require('sqlstring')
|
|
5
|
+
|
|
6
|
+
async function executeBulkMerge(connection, sql, rows, options) {
|
|
7
|
+
const list = []
|
|
8
|
+
for(let i = 0; i < rows.length; i++) {
|
|
9
|
+
const row = rows[i]
|
|
10
|
+
const values = []
|
|
11
|
+
for(let j = 0; j < row.length; j++) {
|
|
12
|
+
const column = options.columns[j]
|
|
13
|
+
let value = convertValueToDb(row[j])
|
|
14
|
+
if ( ['string','date','datetime','time'].includes(column.type)) {
|
|
15
|
+
value = SqlString.escape(value)
|
|
16
|
+
}
|
|
17
|
+
values.push(value)
|
|
18
|
+
}
|
|
19
|
+
list.push(`(${values.join(',')})`)
|
|
20
|
+
}
|
|
21
|
+
const _sql = []
|
|
22
|
+
_sql.push('INSERT INTO ' + options.rdsTable.tableName + ' (')
|
|
23
|
+
_sql.push(options.setsFields.map(p=> '`'+p+'`').join(', '))
|
|
24
|
+
_sql.push(')\n\rVALUES\n\r')
|
|
25
|
+
_sql.push(list.join(','))
|
|
26
|
+
_sql.push('\n\rON DUPLICATE KEY UPDATE\n\r')
|
|
27
|
+
let first = true
|
|
28
|
+
for( const field of options.setsFields.map(p=> '`'+p+'`')) {
|
|
29
|
+
_sql.push((first? ' ': ',\n\r ') + field + ' = VALUES(' + field + ')')
|
|
30
|
+
first = false
|
|
31
|
+
}
|
|
32
|
+
_sql.push(';')
|
|
33
|
+
const query = _sql.join('')
|
|
34
|
+
|
|
35
|
+
return new Promise(function(resolve, reject){
|
|
36
|
+
connection.query(query, null, function(error, result, fields) {
|
|
37
|
+
if(error) {
|
|
38
|
+
reject(BlzBase.error('RdsMySqlExecuteError', { name: connection.name, query, rows }, error));
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
resolve({affectedRows: result.affectedRows});
|
|
42
|
+
})
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
module.exports = executeBulkMerge;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const _ = require('underscore');
|
|
3
|
+
const toUnnamed = require('named-placeholders')();
|
|
4
|
+
const BlzBase = require("./base");
|
|
5
|
+
|
|
6
|
+
async function executeNonQuery(connection, sql, rdsParameters, withGeneratedKey) {
|
|
7
|
+
let query = sql, parameters = [], rs = null;
|
|
8
|
+
try {
|
|
9
|
+
if(!_.isEmpty(rdsParameters)) {
|
|
10
|
+
[query, parameters] = toUnnamed(sql, BlzBase.reduceParameters(rdsParameters));
|
|
11
|
+
}
|
|
12
|
+
} catch(error) {
|
|
13
|
+
throw BlzBase.error('RdsMySqlExecuteError', { name: connection.name, sql, parameters }, error);
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
rs = await connection
|
|
17
|
+
.sql(query)
|
|
18
|
+
.bind(parameters)
|
|
19
|
+
.execute();
|
|
20
|
+
} catch(error) {
|
|
21
|
+
throw BlzBase.error('RdsMySqlExecuteError', { name: connection.name, sql, parameters }, error);
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
rowsAffected: rs.getAffectedItemsCount(),
|
|
25
|
+
id: rs.getAutoIncrementValue()
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
module.exports = { executeNonQuery }
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const _ = require('underscore');
|
|
3
|
+
const toUnnamed = require('named-placeholders')();
|
|
4
|
+
const BlzBase = require("./base");
|
|
5
|
+
|
|
6
|
+
async function executeQuery(connection, sql, rdsParameters = [], options = {}) {
|
|
7
|
+
let query = sql, parameters = [], resultSet;
|
|
8
|
+
try {
|
|
9
|
+
if(!_.isEmpty(rdsParameters)) {
|
|
10
|
+
[query, parameters] = toUnnamed(sql, BlzBase.reduceParameters(rdsParameters, options));
|
|
11
|
+
}
|
|
12
|
+
} catch(error) {
|
|
13
|
+
throw BlzBase.error('RdsMySqlExecuteError', { name: connection.name, sql, parameters }, error);
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
resultSet = ResultSet(await connection
|
|
17
|
+
.sql(query)
|
|
18
|
+
.bind(parameters)
|
|
19
|
+
.execute());
|
|
20
|
+
} catch(error) {
|
|
21
|
+
throw BlzBase.error('RdsMySqlExecuteError', { name: connection.name, sql, parameters }, error);
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
resultSet
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function ResultSet(rowResult) {
|
|
29
|
+
return {
|
|
30
|
+
getRow: async function() {
|
|
31
|
+
return rowResult.fetchOne();
|
|
32
|
+
},
|
|
33
|
+
close: async function() {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
module.exports = executeQuery;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const _ = require("underscore");
|
|
2
|
+
const { executeNonQuery } = require("./execute-non-query");
|
|
3
|
+
const executeQuery = require("./execute-query");
|
|
4
|
+
const executeProcedure = require("./stored-procedure");
|
|
5
|
+
const executeBulkInsert = require("./execute-bulk-insert");
|
|
6
|
+
const executeBulkMerge = require("./execute-bulk-merge");
|
|
7
|
+
const {
|
|
8
|
+
beginTransaction,
|
|
9
|
+
close,
|
|
10
|
+
commitTransaction,
|
|
11
|
+
createConnection: createRdsConnection,
|
|
12
|
+
rollbackTransaction,
|
|
13
|
+
terminate
|
|
14
|
+
} = require("./connection-manager");
|
|
15
|
+
|
|
16
|
+
process.on('exit', async function () {
|
|
17
|
+
await terminate();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
module.exports = {
|
|
21
|
+
syntaxis: require("./syntaxis.json"),
|
|
22
|
+
executeProcedure,
|
|
23
|
+
executeSql: async function (connection, sql, parameters, options = {}) {
|
|
24
|
+
if(sql.indexOf("call") != -1 ) {
|
|
25
|
+
return await executeProcedure(connection, sql, parameters);
|
|
26
|
+
} else if(_.has(options, "bulkInsert")) {
|
|
27
|
+
return await executeBulkInsert(connection, sql, parameters, options);
|
|
28
|
+
} else if(_.has(options, "bulkMerge")) {
|
|
29
|
+
return await executeBulkMerge(connection, sql, parameters, options);
|
|
30
|
+
} else if(_.has(options, "queryOne") || _.has(options, "query")) {
|
|
31
|
+
return await executeQuery(connection, sql, parameters, options);
|
|
32
|
+
} else {
|
|
33
|
+
return await executeNonQuery(connection, sql, parameters, options);
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
beginTransaction,
|
|
37
|
+
close,
|
|
38
|
+
createRdsConnection,
|
|
39
|
+
commitTransaction,
|
|
40
|
+
rollbackTransaction,
|
|
41
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const mysqlx = require('@mysql/xdevapi');
|
|
3
|
+
const _ = require('underscore');
|
|
4
|
+
const BlzBase = require("./base");
|
|
5
|
+
const toString = Object.prototype.toString;
|
|
6
|
+
//https://dev.mysql.com/doc/dev/connector-nodejs/8.0/tutorial-Getting_Started.html
|
|
7
|
+
//https://dev.mysql.com/doc/x-devapi-userguide/en/using-sql.html
|
|
8
|
+
//https://dev.mysql.com/doc/refman/8.0/en/faqs-stored-procs.html#faq-mysql-can-pass-cursor-in
|
|
9
|
+
|
|
10
|
+
function tryDatetime(value) {
|
|
11
|
+
let convertMilliseconds = function(strMilliseconds) {
|
|
12
|
+
if (strMilliseconds) {
|
|
13
|
+
if (strMilliseconds.length < 3)
|
|
14
|
+
strMilliseconds = strMilliseconds.padEnd(3, '0');
|
|
15
|
+
if (strMilliseconds.length > 3)
|
|
16
|
+
strMilliseconds = strMilliseconds.substr(0, 3);
|
|
17
|
+
return Number(strMilliseconds);
|
|
18
|
+
}
|
|
19
|
+
else
|
|
20
|
+
return 0;
|
|
21
|
+
};
|
|
22
|
+
let strType = toString.call(value);
|
|
23
|
+
if (strType === '[object Date]') {
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
else if (strType === '[object String]') {
|
|
27
|
+
let match = /^(\d{4})-(\d{1,2})-(\d{1,2})[T,\s](\d{1,2})\:(\d{1,2})\:(\d{1,2})\.?(\d+)?Z?$/.exec(value);
|
|
28
|
+
if (match)
|
|
29
|
+
return new Date(Date.UTC(Number(match[1]), Number(match[2]) - 1, Number(match[3]), Number(match[4]), Number(match[5]), Number(match[6] || 0), convertMilliseconds(match[7])));
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function convertValueToDb (value) {
|
|
35
|
+
if (_.isUndefined(value)) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
if(_.isNull(value)) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
if (value === true) {
|
|
42
|
+
return 1;
|
|
43
|
+
}
|
|
44
|
+
if (value === false) {
|
|
45
|
+
return 0;
|
|
46
|
+
}
|
|
47
|
+
let datetime = tryDatetime(value);
|
|
48
|
+
if (datetime) {
|
|
49
|
+
let result = datetime.toJSON();
|
|
50
|
+
if (result.length === 24) {
|
|
51
|
+
result = result.substring(0, 19);
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
return value;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* @typedef {Object} Parameter
|
|
59
|
+
* @property {boolean} isResultSet
|
|
60
|
+
* @property {string} name
|
|
61
|
+
* @property {*} value
|
|
62
|
+
* @property { 'in' | 'out' | 'in/out' } direction
|
|
63
|
+
* @property {'string' | 'integer' | 'decimal' | 'boolean' | 'datetime' | 'date' | 'time' | 'binary'} type
|
|
64
|
+
*/
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
*
|
|
68
|
+
* @param {mysqlx.Session} session
|
|
69
|
+
* @param {Parameter} parameter
|
|
70
|
+
* @param {*} result
|
|
71
|
+
*/
|
|
72
|
+
async function parseOutputParameters(session, parameter, result, time_stamp) {
|
|
73
|
+
let resultSet = null, value = null;
|
|
74
|
+
try {
|
|
75
|
+
resultSet = await session.sql(`SELECT @${parameter.name}_${time_stamp};`).execute();
|
|
76
|
+
} catch(error) {
|
|
77
|
+
throw BlzBase.error('RdsMysqlCannotConvertParameters', { parameter, result, time_stamp }, error);
|
|
78
|
+
}
|
|
79
|
+
[ value ] = resultSet.fetchOne();
|
|
80
|
+
if(parameter.isResultSet) {
|
|
81
|
+
result[parameter.name] = JSON.parse(value);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
switch (parameter.type) {
|
|
85
|
+
case 'string':
|
|
86
|
+
result[parameter.name] = BlzBase.convertToString(value);
|
|
87
|
+
break;
|
|
88
|
+
case 'integer':
|
|
89
|
+
result[parameter.name] = BlzBase.convertToInteger(value);
|
|
90
|
+
break;
|
|
91
|
+
case 'decimal':
|
|
92
|
+
result[parameter.name] = BlzBase.convertToDecimal(value);
|
|
93
|
+
break;
|
|
94
|
+
case 'boolean':
|
|
95
|
+
result[parameter.name] = BlzBase.convertToBoolean(value);
|
|
96
|
+
break;
|
|
97
|
+
case 'datetime':
|
|
98
|
+
result[parameter.name] = BlzBase.convertToDatetime(value);
|
|
99
|
+
break;
|
|
100
|
+
case 'date':
|
|
101
|
+
result[parameter.name] = BlzBase.convertToDate(value);
|
|
102
|
+
break;
|
|
103
|
+
case 'time':
|
|
104
|
+
result[parameter.name] = BlzBase.convertToTime(value);
|
|
105
|
+
break;
|
|
106
|
+
case 'binary':
|
|
107
|
+
result[parameter.name] = BlzBase.convertToBinary(value);
|
|
108
|
+
break;
|
|
109
|
+
default:
|
|
110
|
+
throw BlzBase.error('RdsMySqlUnexpectedType', { parameter, result, value });
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* @param {mysqlx.Session} session
|
|
116
|
+
* @param {string} procedure
|
|
117
|
+
* @param {[Parameter]} [parameters=[]]
|
|
118
|
+
* @param {number} time_stamp
|
|
119
|
+
* @returns {string}
|
|
120
|
+
*/
|
|
121
|
+
async function parseInputParameters(session, procedure, parameters, time_stamp) {
|
|
122
|
+
for(const parameter of parameters) {
|
|
123
|
+
switch(parameter.direction) {
|
|
124
|
+
case "in":
|
|
125
|
+
case "in/out":
|
|
126
|
+
try {
|
|
127
|
+
await session
|
|
128
|
+
.sql(`SET @${parameter.name}_${time_stamp} = ?;`)
|
|
129
|
+
.bind(convertValueToDb(parameter.value))
|
|
130
|
+
.execute();
|
|
131
|
+
} catch (error) {
|
|
132
|
+
throw BlzBase.error('RdsMySqlInputParameterType', { parameters, time_stamp });
|
|
133
|
+
}
|
|
134
|
+
procedure = procedure
|
|
135
|
+
.replace(`:${parameter.name}`, `@${parameter.name}_${time_stamp}`);
|
|
136
|
+
break;
|
|
137
|
+
case "out":
|
|
138
|
+
try {
|
|
139
|
+
await session
|
|
140
|
+
.sql(`SET @${parameter.name}_${time_stamp} = NULL;`)
|
|
141
|
+
.execute();
|
|
142
|
+
} catch(error) {
|
|
143
|
+
throw BlzBase.error('RdsMySqlInputParameterType', { parameters, time_stamp });
|
|
144
|
+
}
|
|
145
|
+
procedure = procedure
|
|
146
|
+
.replace(`:${parameter.name}`, `@${parameter.name}_${time_stamp}`);
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return procedure;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* @param {mysqlx.Session} session
|
|
154
|
+
* @param {string} procedure
|
|
155
|
+
* @param {[Parameter]} [parameters=[]]
|
|
156
|
+
*/
|
|
157
|
+
async function executeProcedure(session, procedure, parameters) {
|
|
158
|
+
const time_stamp = Date.now();
|
|
159
|
+
if(_.isArray(parameters)) {
|
|
160
|
+
procedure = await parseInputParameters(session, procedure, parameters, time_stamp);
|
|
161
|
+
}
|
|
162
|
+
try {
|
|
163
|
+
await session
|
|
164
|
+
.sql(procedure)
|
|
165
|
+
.execute();
|
|
166
|
+
} catch (error) {
|
|
167
|
+
throw BlzBase.error('RdsMysqlCannotExecuteProcedure', { session, procedure, parameters }, error);
|
|
168
|
+
}
|
|
169
|
+
let outParameters = {};
|
|
170
|
+
for(const parameter of parameters) {
|
|
171
|
+
if(parameter.direction == "in") {
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
await parseOutputParameters(session, parameter, outParameters, time_stamp);
|
|
175
|
+
}
|
|
176
|
+
return { outParameters };
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
module.exports = executeProcedure;
|