@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,539 @@
|
|
|
1
|
+
const oracledb = require("oracledb");
|
|
2
|
+
const _ = require("underscore");
|
|
3
|
+
const { h3lp } = require('h3lp');
|
|
4
|
+
// check blzBase location
|
|
5
|
+
const Path = require('path');
|
|
6
|
+
const Fs = require('fs-extra');
|
|
7
|
+
const blzBaseSuite = Path.resolve(__dirname, '../blz-core/sources-dual/index.js');
|
|
8
|
+
let BlzBase = null;
|
|
9
|
+
if (Fs.existsSync(blzBaseSuite)) {
|
|
10
|
+
BlzBase = require('../../blz-core/sources-dual/index.js');
|
|
11
|
+
} else {
|
|
12
|
+
BlzBase = require('../blz-core/index.js');
|
|
13
|
+
}
|
|
14
|
+
oracledb.fetchAsBuffer = [oracledb.BLOB];
|
|
15
|
+
oracledb.fetchAsString = [oracledb.CLOB, oracledb.DATE, oracledb.NUMBER];
|
|
16
|
+
|
|
17
|
+
let poolsByName = Object.create(null);
|
|
18
|
+
|
|
19
|
+
const getPool = async function (connection) {
|
|
20
|
+
try {
|
|
21
|
+
if (!connection.name) {
|
|
22
|
+
throw new Error('You must provide a connnection name');
|
|
23
|
+
}
|
|
24
|
+
let key = connection.name;
|
|
25
|
+
let pool = poolsByName[key];
|
|
26
|
+
if (pool) {
|
|
27
|
+
return pool;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
connection.connectString = connection.dataSource;
|
|
31
|
+
connection = _.omit(connection, "dataSource", "providerName");
|
|
32
|
+
connection.sessionCallback = makeInitSessionCallback({ schema: connection.schema })
|
|
33
|
+
// Enable instant client mode in Node.js
|
|
34
|
+
if (process.env.LD_LIBRARY_PATH){
|
|
35
|
+
oracledb.initOracleClient( { libDir: process.env.LD_LIBRARY_PATH, configDir: '', thin: false} );
|
|
36
|
+
}
|
|
37
|
+
pool = await oracledb.createPool(connection);
|
|
38
|
+
pool.connectionName = connection.name;
|
|
39
|
+
poolsByName[key] = pool;
|
|
40
|
+
return pool;
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
throw new Error('Oracle cannot create pool for ' + connection.name + ': ' + err.message);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const makeInitSessionCallback = ({ schema } = {}) => (oraConnection, requestedTag, callbackFn) => {
|
|
48
|
+
const sessionSets = [
|
|
49
|
+
['NLS_DATE_FORMAT', `'YYYY-MM-DD"T"hh24:mi:ss'`],
|
|
50
|
+
schema ? ['CURRENT_SCHEMA', `${schema}`] : undefined
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
const sessionSetsString = sessionSets
|
|
54
|
+
.filter(Boolean)
|
|
55
|
+
.map(([key, value]) => `${key}=${value}`)
|
|
56
|
+
.join(' ')
|
|
57
|
+
|
|
58
|
+
oraConnection.execute(`ALTER SESSION SET ${sessionSetsString}`, callbackFn)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const tryDatetime = function (value) {
|
|
62
|
+
let strType = toString.call(value);
|
|
63
|
+
if (strType === '[object Date]') {
|
|
64
|
+
return value;
|
|
65
|
+
}
|
|
66
|
+
else if (strType === '[object String]') {
|
|
67
|
+
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);
|
|
68
|
+
if (match) {
|
|
69
|
+
const probableDate = new Date(value);
|
|
70
|
+
if (probableDate.toString() !== 'Invalid Date') {
|
|
71
|
+
return probableDate;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
};
|
|
77
|
+
const convertMilliseconds = function(strMilliseconds) {
|
|
78
|
+
if (strMilliseconds) {
|
|
79
|
+
if (strMilliseconds.length < 3)
|
|
80
|
+
strMilliseconds = strMilliseconds.padEnd(3, '0');
|
|
81
|
+
if (strMilliseconds.length > 3)
|
|
82
|
+
strMilliseconds = strMilliseconds.substr(0, 3);
|
|
83
|
+
return Number(strMilliseconds);
|
|
84
|
+
}
|
|
85
|
+
else
|
|
86
|
+
return 0;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const convertResultSetToArray = function (resultSet, results) {
|
|
90
|
+
return resultSet.getRow()
|
|
91
|
+
.then((row) => {
|
|
92
|
+
if (row) {
|
|
93
|
+
results.push(row);
|
|
94
|
+
return convertResultSetToArray(resultSet, results);
|
|
95
|
+
}
|
|
96
|
+
else
|
|
97
|
+
return resultSet.close()
|
|
98
|
+
.then(() => {
|
|
99
|
+
return results;
|
|
100
|
+
});
|
|
101
|
+
})
|
|
102
|
+
.catch((err) => {
|
|
103
|
+
resultSet.close();
|
|
104
|
+
throw BlzBase.error('ErrorFetchingRowsForConnection', {}, err);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const getParameterType = function (type) {
|
|
109
|
+
switch (type) {
|
|
110
|
+
case 'string':
|
|
111
|
+
return oracledb.STRING
|
|
112
|
+
case 'integer':
|
|
113
|
+
case 'decimal':
|
|
114
|
+
case 'boolean':
|
|
115
|
+
return oracledb.NUMBER
|
|
116
|
+
case 'datetime':
|
|
117
|
+
case 'date':
|
|
118
|
+
case 'time':
|
|
119
|
+
return oracledb.DATE
|
|
120
|
+
case 'binary':
|
|
121
|
+
return oracledb.BUFFER
|
|
122
|
+
case 'CLOB':
|
|
123
|
+
return oracledb.CLOB;
|
|
124
|
+
case 'BLOB':
|
|
125
|
+
return oracledb.CLOB;
|
|
126
|
+
case 'VARCHAR':
|
|
127
|
+
case 'VARCHAR2':
|
|
128
|
+
return oracledb.STRING;
|
|
129
|
+
default:
|
|
130
|
+
return oracledb.STRING
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const getOraParameters = function (parameters,options) {
|
|
135
|
+
let oraParameters = {};
|
|
136
|
+
if (parameters)
|
|
137
|
+
for (let i = 0; i < parameters.length; i++) {
|
|
138
|
+
let parameter = parameters[i];
|
|
139
|
+
let oraParameter = {};
|
|
140
|
+
// checks if i need to convert nodejs to oracle representation (bool -> 0,1) etcs
|
|
141
|
+
if (parameter.direction === 'in' || parameter.direction === 'in/out') {
|
|
142
|
+
if (parameter.value === undefined || parameter.value === null)
|
|
143
|
+
oraParameter.val = null;
|
|
144
|
+
else if (parameter.value === true)
|
|
145
|
+
oraParameter.val = 1;
|
|
146
|
+
else if (parameter.value === false)
|
|
147
|
+
oraParameter.val = 0;
|
|
148
|
+
else {
|
|
149
|
+
if (parameter.columnInfo && parameter.columnInfo.type === 'string') {
|
|
150
|
+
oraParameter.val = parameter.value
|
|
151
|
+
} else {
|
|
152
|
+
let datetime = tryDatetime(parameter.value);
|
|
153
|
+
if (datetime) {
|
|
154
|
+
oraParameter.val = datetime;
|
|
155
|
+
// Old Date management
|
|
156
|
+
// let tmp = datetime.toJSON();
|
|
157
|
+
// if (tmp.length === 24)
|
|
158
|
+
// tmp = tmp.substring(0, 19);
|
|
159
|
+
// oraParameter.val = tmp;
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
oraParameter.val = parameter.value;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
// binds de in out
|
|
168
|
+
if (parameter.direction === 'in')
|
|
169
|
+
oraParameter.dir = oracledb.BIND_IN;
|
|
170
|
+
else if (parameter.direction === 'in/out')
|
|
171
|
+
oraParameter.dir = oracledb.BIND_INOUT;
|
|
172
|
+
else if (parameter.direction === 'out')
|
|
173
|
+
oraParameter.dir = oracledb.BIND_OUT;
|
|
174
|
+
// selects the parameter type
|
|
175
|
+
if (parameter.isResultSet)
|
|
176
|
+
oraParameter.type = oracledb.CURSOR;
|
|
177
|
+
else {
|
|
178
|
+
if (parameter.dbTypes){
|
|
179
|
+
const oracleEntry = parameter.dbTypes.find(entry => entry.providerName === 'Oracle');
|
|
180
|
+
parameter.dbType = getParameterType(oracleEntry.dbType);
|
|
181
|
+
} else if (parameter.type) {
|
|
182
|
+
parameter.dbType = getParameterType(parameter.type);
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
parameter.dbType = inferDbTypeFromValue(parameter.value);
|
|
186
|
+
}
|
|
187
|
+
oraParameter.type = parameter.dbType;
|
|
188
|
+
}
|
|
189
|
+
oraParameters[parameter.name] = oraParameter;
|
|
190
|
+
}
|
|
191
|
+
if (options && options.autoincrementalData)
|
|
192
|
+
oraParameters['ScalarOutput'] = { val: null, dir: oracledb.BIND_OUT, type: oracledb.NUMBER };
|
|
193
|
+
return oraParameters
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const getOraOptions = function (options , bindDefs) {
|
|
197
|
+
let oraOptions = { autoCommit: !options.isTransactionRequest };
|
|
198
|
+
if (options && (options.query || options.queryOne)) {
|
|
199
|
+
oraOptions.resultSet = true;
|
|
200
|
+
}
|
|
201
|
+
if (bindDefs) {
|
|
202
|
+
oraOptions.bindDefs = bindDefs
|
|
203
|
+
}
|
|
204
|
+
return oraOptions;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const convertValueFromType = async function (value, type) {
|
|
208
|
+
switch (type) {
|
|
209
|
+
case 'string': {
|
|
210
|
+
return BlzBase.convertToString(value);
|
|
211
|
+
}
|
|
212
|
+
case 'integer': {
|
|
213
|
+
return BlzBase.convertToInteger(value);
|
|
214
|
+
}
|
|
215
|
+
case 'decimal': {
|
|
216
|
+
return BlzBase.convertToDecimal(value);
|
|
217
|
+
}
|
|
218
|
+
case 'boolean': {
|
|
219
|
+
return BlzBase.convertToBoolean(value);
|
|
220
|
+
}
|
|
221
|
+
case 'datetime': {
|
|
222
|
+
return BlzBase.convertToDatetime(value);
|
|
223
|
+
}
|
|
224
|
+
case 'date': {
|
|
225
|
+
return BlzBase.convertToDate(value);
|
|
226
|
+
}
|
|
227
|
+
case 'time': {
|
|
228
|
+
return BlzBase.convertToTime(value);
|
|
229
|
+
}
|
|
230
|
+
case 'binary': {
|
|
231
|
+
return BlzBase.convertToBinary(value);
|
|
232
|
+
}
|
|
233
|
+
default:{
|
|
234
|
+
// If i have a clob, or special type, the case might not be straightforward
|
|
235
|
+
if (value._type.name === 'DB_TYPE_CLOB' ) {
|
|
236
|
+
return await oraResult.outBinds[parameter.name].getData();
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const getResult = async function (parameters, oraResult, options) {
|
|
243
|
+
let result = {};
|
|
244
|
+
result.rowsAffected = oraResult.rowsAffected;
|
|
245
|
+
result.outParameters = {};
|
|
246
|
+
if (parameters)
|
|
247
|
+
for (let i = 0; i < parameters.length; i++) {
|
|
248
|
+
let parameter = parameters[i];
|
|
249
|
+
if (parameter.direction === 'out' || parameter.direction === 'in/out') {
|
|
250
|
+
let value = oraResult.outBinds[parameter.name];
|
|
251
|
+
if (parameter.isResultSet)
|
|
252
|
+
value = await convertResultSetToArray(value, []);
|
|
253
|
+
else {
|
|
254
|
+
if (value && typeof value.type === 'string') {
|
|
255
|
+
value = await convertValueFromType(value, value.type);
|
|
256
|
+
} else if (value && value._type && typeof value._type.name === 'string' && value._type.name === 'DB_TYPE_CLOB') {
|
|
257
|
+
value = await oraResult.outBinds[parameter.name].getData();
|
|
258
|
+
} else if (parameter && typeof parameter.type === 'string') {
|
|
259
|
+
value = await convertValueFromType(value, parameter.type);
|
|
260
|
+
} else {
|
|
261
|
+
console.warn('Could not resolve out parameter type');
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
result.outParameters[parameter.name] = value;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
if (options && options.autoincrementalData) {
|
|
268
|
+
result.id = null;
|
|
269
|
+
if (oraResult.outBinds && oraResult.outBinds.ScalarOutput) {
|
|
270
|
+
result.id = oraResult.outBinds.ScalarOutput;
|
|
271
|
+
if (Array.isArray(result.id))
|
|
272
|
+
result.id = result.id[0];
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
if (options && (options.query || options.queryOne))
|
|
276
|
+
result.resultSet = oraResult.resultSet;
|
|
277
|
+
return result;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
process.on('exit', async function () {
|
|
281
|
+
let promises = [];
|
|
282
|
+
for (let poolName in poolsByName) {
|
|
283
|
+
let pool = poolsByName[poolName];
|
|
284
|
+
promises.push(pool.close());
|
|
285
|
+
}
|
|
286
|
+
poolsByName = null;
|
|
287
|
+
await Promise.all(promises);
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
const getValue = function (source, type) {
|
|
291
|
+
const _type = type ? type.toLowerCase() : typeof source
|
|
292
|
+
switch (_type.toLowerCase()) {
|
|
293
|
+
case 'boolean':
|
|
294
|
+
return source ? 1 : 0
|
|
295
|
+
case 'string':
|
|
296
|
+
return typeof source === 'string' || source === null || source === undefined ? source : source.toString()
|
|
297
|
+
case 'datetime':
|
|
298
|
+
case 'date':
|
|
299
|
+
case 'time':
|
|
300
|
+
return source ? new Date(source) : null
|
|
301
|
+
default:
|
|
302
|
+
return source
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Infers the Oracle DB type from a JavaScript value.
|
|
308
|
+
* @param {*} value - The value to infer the DB type for.
|
|
309
|
+
* @returns {number} oracledb type constant.
|
|
310
|
+
*/
|
|
311
|
+
const inferDbTypeFromValue = function (value) {
|
|
312
|
+
if (value === null || value === undefined) {
|
|
313
|
+
return oracledb.STRING; // default to STRING for nulls
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
if (Buffer.isBuffer(value)) {
|
|
317
|
+
return getParameterType('binary');
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
const jsType = typeof value;
|
|
321
|
+
|
|
322
|
+
switch (jsType) {
|
|
323
|
+
case 'string':
|
|
324
|
+
return getParameterType('string');
|
|
325
|
+
case 'number':
|
|
326
|
+
// Decide between integer and decimal if needed
|
|
327
|
+
return Number.isInteger(value) ? getParameterType('integer') : getParameterType('decimal');
|
|
328
|
+
case 'boolean':
|
|
329
|
+
return getParameterType('boolean');
|
|
330
|
+
case 'object':
|
|
331
|
+
if (value instanceof Date) {
|
|
332
|
+
return getParameterType('datetime');
|
|
333
|
+
}
|
|
334
|
+
return getParameterType('string'); // fallback for objects
|
|
335
|
+
default:
|
|
336
|
+
return getParameterType('string');
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
const rowsToArray = function (columns, rows) {
|
|
342
|
+
const array = []
|
|
343
|
+
const columnsCount = columns.length
|
|
344
|
+
for (const row of rows) {
|
|
345
|
+
const item = {}
|
|
346
|
+
for(let i=0 ; i < columnsCount ; i++) {
|
|
347
|
+
const column = columns[i]
|
|
348
|
+
const value = row[i]
|
|
349
|
+
item[column.name] = getValue(value,column.type)
|
|
350
|
+
}
|
|
351
|
+
array.push(item)
|
|
352
|
+
}
|
|
353
|
+
return array
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
module.exports = {
|
|
357
|
+
syntaxis: require('./syntaxis.json'),
|
|
358
|
+
createRdsConnection: async function (connection) {
|
|
359
|
+
try {
|
|
360
|
+
let oraPool = await getPool(connection);
|
|
361
|
+
let oraConnection = await oraPool.getConnection();
|
|
362
|
+
return oraConnection;
|
|
363
|
+
}
|
|
364
|
+
catch (err) {
|
|
365
|
+
throw err;
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
executeSql: async function (connection, sql, parameters, options) {
|
|
369
|
+
if(_.has(options, "bulkInsert")) {
|
|
370
|
+
return await this._executeBulkInsert(connection, sql, parameters, options);
|
|
371
|
+
} else if(_.has(options, "bulkMerge")) {
|
|
372
|
+
return await this._executeBulkMerge(connection, sql, parameters, options);
|
|
373
|
+
} else {
|
|
374
|
+
return await this._executeSql(connection, sql, parameters, options);
|
|
375
|
+
}
|
|
376
|
+
},
|
|
377
|
+
_executeSql: async function (connection, sql, parameters, options) {
|
|
378
|
+
try{
|
|
379
|
+
let oraParameters = getOraParameters(parameters,options);
|
|
380
|
+
let oraOptions = getOraOptions(options)
|
|
381
|
+
let oraResult = await connection.execute(sql, oraParameters, oraOptions);
|
|
382
|
+
const result = await getResult(parameters, oraResult, options);
|
|
383
|
+
return result;
|
|
384
|
+
} catch (err) {
|
|
385
|
+
throw err
|
|
386
|
+
}
|
|
387
|
+
},
|
|
388
|
+
_executeBulkInsert: async function (connection, sql, rows, options) {
|
|
389
|
+
let autoincremental = null
|
|
390
|
+
if (options.autoincrementalData && options.autoincrementalData.pkColumnName) {
|
|
391
|
+
autoincremental = { name: options.autoincrementalData.pkColumnName ,
|
|
392
|
+
alias: options.autoincrementalData.pkColumnAlias,
|
|
393
|
+
sequence: options.autoincrementalData.sequenceName,
|
|
394
|
+
type: options.autoincrementalData.pkColumnType
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
const _sql = autoincremental ?
|
|
398
|
+
'INSERT INTO ' + options.rdsTable.tableName +
|
|
399
|
+
' (' + autoincremental.name + ',' + options.setsFields.join(', ') +
|
|
400
|
+
') VALUES ( ' + autoincremental.sequence + '.NEXTVAL, ' + options.setsFields.map((field) => ':' + field).join(', ') + ' ) ' +
|
|
401
|
+
' RETURNING ' + autoincremental.name + ' INTO :' + autoincremental.name
|
|
402
|
+
: sql + '(' +options.setsFields.map((field) => ':' + field).join(', ') + ' ) '
|
|
403
|
+
|
|
404
|
+
// solve max size for string fields
|
|
405
|
+
const columnsCount = options.columns.length
|
|
406
|
+
for(let i=0 ; i < columnsCount ; i++) {
|
|
407
|
+
const column = options.columns[i]
|
|
408
|
+
if (column.type === 'string') {
|
|
409
|
+
column.size = rows.reduce((max, row) => { return !row[i]?0:row[i].length > max ? row[i].length : max }, 0)
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
const bindDefs = {}
|
|
413
|
+
for (const column of options.columns) {
|
|
414
|
+
const bindDef = { type:getDbType(column.type) }
|
|
415
|
+
if (column.type === 'string') {
|
|
416
|
+
bindDef.maxSize = column.size
|
|
417
|
+
}
|
|
418
|
+
bindDefs[column.name] = bindDef
|
|
419
|
+
}
|
|
420
|
+
if (autoincremental) {
|
|
421
|
+
bindDefs[autoincremental.name] = { type: getDbType(autoincremental.type), dir: oracledb.BIND_OUT}
|
|
422
|
+
}
|
|
423
|
+
const oraOptions = getOraOptions(options,bindDefs)
|
|
424
|
+
const data = rowsToArray(options.columns,rows)
|
|
425
|
+
try {
|
|
426
|
+
const result = await connection.executeMany(_sql, data, oraOptions)
|
|
427
|
+
if (autoincremental) {
|
|
428
|
+
const ids = []
|
|
429
|
+
for (const i in result.outBinds) {
|
|
430
|
+
ids.push(result.outBinds[i][autoincremental.name][0])
|
|
431
|
+
}
|
|
432
|
+
return { rowsAffected: result.rowsAffected, ids }
|
|
433
|
+
} else {
|
|
434
|
+
return { rowsAffected: result.rowsAffected }
|
|
435
|
+
}
|
|
436
|
+
} catch (err) {
|
|
437
|
+
console.log(err)
|
|
438
|
+
throw err
|
|
439
|
+
}
|
|
440
|
+
},
|
|
441
|
+
_executeBulkMerge: async function (connection, sql, rows, options) {
|
|
442
|
+
// example: https://stackoverflow.com/questions/67881781/how-to-execute-multiple-merge-into-query-on-oracle-db-from-node-js
|
|
443
|
+
let autoincremental = null
|
|
444
|
+
if (options.autoincrementalData && options.autoincrementalData.pkColumnName) {
|
|
445
|
+
autoincremental = { name: options.autoincrementalData.pkColumnName ,
|
|
446
|
+
alias: options.autoincrementalData.pkColumnAlias,
|
|
447
|
+
sequence: options.autoincrementalData.sequenceName,
|
|
448
|
+
type: options.autoincrementalData.pkColumnType
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
const _sql = []
|
|
452
|
+
_sql.push('MERGE INTO ' + options.rdsTable.tableName + ' t USING (')
|
|
453
|
+
_sql.push('SELECT ')
|
|
454
|
+
let first = true
|
|
455
|
+
for (const column of options.columns) {
|
|
456
|
+
_sql.push((first?'': ', ') + ':' + column.name + ' AS ' + column.name)
|
|
457
|
+
first = false
|
|
458
|
+
}
|
|
459
|
+
_sql.push('FROM DUAL')
|
|
460
|
+
_sql.push(') s ON (')
|
|
461
|
+
first = true
|
|
462
|
+
for(const field of options.mergeFields) {
|
|
463
|
+
_sql.push((first?'': ' AND ') + 't.' + field + ' = s.' + field )
|
|
464
|
+
first = false
|
|
465
|
+
}
|
|
466
|
+
_sql.push(')')
|
|
467
|
+
_sql.push('WHEN MATCHED THEN UPDATE SET ')
|
|
468
|
+
first = true
|
|
469
|
+
for(const column of options.columns) {
|
|
470
|
+
if(options.mergeFields.includes(column.name)) continue
|
|
471
|
+
_sql.push((first?'': ',') + 't.' + column.name + ' = s.' + column.name)
|
|
472
|
+
first = false
|
|
473
|
+
}
|
|
474
|
+
_sql.push('WHEN NOT MATCHED THEN INSERT (')
|
|
475
|
+
if(autoincremental) {
|
|
476
|
+
_sql.push(autoincremental.name)
|
|
477
|
+
for(const column of options.columns) {
|
|
478
|
+
_sql.push(',' + column.name)
|
|
479
|
+
}
|
|
480
|
+
_sql.push(') VALUES (')
|
|
481
|
+
_sql.push(autoincremental.sequence + '.NEXTVAL')
|
|
482
|
+
for(const column of options.columns) {
|
|
483
|
+
_sql.push(',s.' + column.name)
|
|
484
|
+
}
|
|
485
|
+
} else {
|
|
486
|
+
first = true
|
|
487
|
+
for(const column of options.columns) {
|
|
488
|
+
_sql.push((first?'': ',') + column.name)
|
|
489
|
+
first = false
|
|
490
|
+
}
|
|
491
|
+
_sql.push(') VALUES (')
|
|
492
|
+
first = true
|
|
493
|
+
for(const column of options.columns) {
|
|
494
|
+
_sql.push((first?'': ',') + 's.' + column.name)
|
|
495
|
+
first = false
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
_sql.push(')')
|
|
499
|
+
const mergeSql = _sql.join(' ')
|
|
500
|
+
|
|
501
|
+
// solve max size for string fields
|
|
502
|
+
const columnsCount = options.columns.length
|
|
503
|
+
for(let i=0 ; i < columnsCount ; i++) {
|
|
504
|
+
const column = options.columns[i]
|
|
505
|
+
if (column.type === 'string') {
|
|
506
|
+
column.size = rows.reduce((max, row) => { return !row[i]?0:row[i].length > max ? row[i].length : max }, 0)
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
const bindDefs = {}
|
|
510
|
+
for (const column of options.columns) {
|
|
511
|
+
const bindDef = { type:getDbType(column.type) }
|
|
512
|
+
if (column.type === 'string') {
|
|
513
|
+
bindDef.maxSize = column.size
|
|
514
|
+
}
|
|
515
|
+
bindDefs[column.name] = bindDef
|
|
516
|
+
}
|
|
517
|
+
const oraOptions = getOraOptions(options,bindDefs)
|
|
518
|
+
const data = rowsToArray(options.columns,rows)
|
|
519
|
+
try {
|
|
520
|
+
const result = await connection.executeMany(mergeSql, data, oraOptions)
|
|
521
|
+
return { rowsAffected: result.rowsAffected }
|
|
522
|
+
} catch (err) {
|
|
523
|
+
console.log(err)
|
|
524
|
+
throw err
|
|
525
|
+
}
|
|
526
|
+
},
|
|
527
|
+
close(nativeConnection) {
|
|
528
|
+
return nativeConnection.close();
|
|
529
|
+
},
|
|
530
|
+
beginTransaction(nativeConnection) {
|
|
531
|
+
//se utiliza la variable isTransactionRequest
|
|
532
|
+
},
|
|
533
|
+
commitTransaction(nativeConnection) {
|
|
534
|
+
return nativeConnection.commit();
|
|
535
|
+
},
|
|
536
|
+
rollbackTransaction(nativeConnection) {
|
|
537
|
+
return nativeConnection.rollback();
|
|
538
|
+
}
|
|
539
|
+
};
|