@blazedpath/commons 0.2.1 → 0.3.1
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 +4 -1
- package/dist/blz-base/health/index.d.ts +1 -0
- package/dist/blz-base/health/index.js +1 -0
- package/dist/blz-base/index.d.ts +108 -0
- package/dist/blz-base/index.js +1 -0
- package/dist/blz-cache/LruCache.d.ts +31 -0
- package/dist/blz-cache/LruCache.js +1 -0
- package/dist/blz-cache/index.d.ts +2 -0
- package/dist/blz-cache/index.js +1 -0
- package/dist/blz-config/index.d.ts +16 -0
- package/dist/blz-config/index.js +1 -0
- package/dist/blz-core/index.d.ts +32 -0
- package/dist/blz-core/index.js +1 -0
- package/dist/blz-cryptography/index.d.ts +2 -0
- package/dist/blz-cryptography/index.js +1 -0
- package/dist/blz-datetimes/index.d.ts +35 -0
- package/dist/blz-datetimes/index.js +1 -0
- package/dist/blz-file/fileService.d.ts +25 -0
- package/dist/blz-file/fileService.js +1 -0
- package/dist/blz-file/index.d.ts +2 -0
- package/dist/blz-file/index.js +1 -0
- package/dist/blz-file/index.test.js +1 -0
- package/dist/blz-file/lab.js +1 -0
- package/dist/blz-hazelcast/index.d.ts +25 -0
- package/dist/blz-hazelcast/index.js +1 -0
- package/dist/blz-hazelcast/lib/credentials.d.ts +10 -0
- package/dist/blz-hazelcast/lib/credentials.js +1 -0
- package/dist/blz-hazelcast/lib/credentialsFactory.d.ts +1 -0
- package/dist/blz-hazelcast/lib/credentialsFactory.js +1 -0
- package/dist/blz-hazelcast/lib/hazelcastCache.d.ts +27 -0
- package/dist/blz-hazelcast/lib/hazelcastCache.js +1 -0
- package/dist/blz-iterable/index.d.ts +49 -0
- package/dist/blz-iterable/index.js +1 -0
- package/dist/blz-json-schema/index.d.ts +1 -0
- package/dist/blz-json-schema/index.js +1 -0
- package/dist/blz-jwt/index.d.ts +12 -0
- package/dist/blz-jwt/index.js +1 -0
- package/dist/blz-kafka/index.d.ts +9 -0
- package/dist/blz-kafka/index.js +1 -0
- package/dist/blz-math/index.d.ts +22 -0
- package/dist/blz-math/index.js +1 -0
- package/dist/blz-mongodb/index.d.ts +28 -0
- package/dist/blz-mongodb/index.js +1 -0
- package/dist/blz-rds/__test__/scape.test.js +1 -0
- package/dist/blz-rds/blz-rds-executor.d.ts +4 -0
- package/dist/blz-rds/blz-rds-executor.js +1 -0
- package/dist/blz-rds/blz-rds-helper.d.ts +5 -0
- package/dist/blz-rds/blz-rds-helper.js +1 -0
- package/dist/blz-rds/commands/core/add.d.ts +2 -0
- package/dist/blz-rds/commands/core/add.js +1 -0
- package/dist/blz-rds/commands/core/and.d.ts +3 -0
- package/dist/blz-rds/commands/core/and.js +1 -0
- package/dist/blz-rds/commands/core/asc.d.ts +2 -0
- package/dist/blz-rds/commands/core/asc.js +1 -0
- package/dist/blz-rds/commands/core/avg.d.ts +2 -0
- package/dist/blz-rds/commands/core/avg.js +1 -0
- package/dist/blz-rds/commands/core/column-ref.d.ts +2 -0
- package/dist/blz-rds/commands/core/column-ref.js +1 -0
- package/dist/blz-rds/commands/core/count-distinct.d.ts +2 -0
- package/dist/blz-rds/commands/core/count-distinct.js +1 -0
- package/dist/blz-rds/commands/core/count.d.ts +2 -0
- package/dist/blz-rds/commands/core/count.js +1 -0
- package/dist/blz-rds/commands/core/decimal.d.ts +2 -0
- package/dist/blz-rds/commands/core/decimal.js +1 -0
- package/dist/blz-rds/commands/core/desc.d.ts +2 -0
- package/dist/blz-rds/commands/core/desc.js +1 -0
- package/dist/blz-rds/commands/core/distinct.d.ts +2 -0
- package/dist/blz-rds/commands/core/distinct.js +1 -0
- package/dist/blz-rds/commands/core/divide.d.ts +2 -0
- package/dist/blz-rds/commands/core/divide.js +1 -0
- package/dist/blz-rds/commands/core/embedded-exists.d.ts +3 -0
- package/dist/blz-rds/commands/core/embedded-exists.js +1 -0
- package/dist/blz-rds/commands/core/embedded-select.d.ts +2 -0
- package/dist/blz-rds/commands/core/embedded-select.js +1 -0
- package/dist/blz-rds/commands/core/equals.d.ts +3 -0
- package/dist/blz-rds/commands/core/equals.js +1 -0
- package/dist/blz-rds/commands/core/false.d.ts +2 -0
- package/dist/blz-rds/commands/core/false.js +1 -0
- package/dist/blz-rds/commands/core/greater-or-equal.d.ts +3 -0
- package/dist/blz-rds/commands/core/greater-or-equal.js +1 -0
- package/dist/blz-rds/commands/core/greater.d.ts +3 -0
- package/dist/blz-rds/commands/core/greater.js +1 -0
- package/dist/blz-rds/commands/core/in.d.ts +3 -0
- package/dist/blz-rds/commands/core/in.js +1 -0
- package/dist/blz-rds/commands/core/integer.d.ts +2 -0
- package/dist/blz-rds/commands/core/integer.js +1 -0
- package/dist/blz-rds/commands/core/is-not-null.d.ts +3 -0
- package/dist/blz-rds/commands/core/is-not-null.js +1 -0
- package/dist/blz-rds/commands/core/is-null-or-value.d.ts +3 -0
- package/dist/blz-rds/commands/core/is-null-or-value.js +1 -0
- package/dist/blz-rds/commands/core/is-null.d.ts +3 -0
- package/dist/blz-rds/commands/core/is-null.js +1 -0
- package/dist/blz-rds/commands/core/less-or-equal.d.ts +3 -0
- package/dist/blz-rds/commands/core/less-or-equal.js +1 -0
- package/dist/blz-rds/commands/core/less-unary.d.ts +2 -0
- package/dist/blz-rds/commands/core/less-unary.js +1 -0
- package/dist/blz-rds/commands/core/less.d.ts +3 -0
- package/dist/blz-rds/commands/core/less.js +1 -0
- package/dist/blz-rds/commands/core/like.d.ts +3 -0
- package/dist/blz-rds/commands/core/like.js +1 -0
- package/dist/blz-rds/commands/core/max.d.ts +2 -0
- package/dist/blz-rds/commands/core/max.js +1 -0
- package/dist/blz-rds/commands/core/min.d.ts +2 -0
- package/dist/blz-rds/commands/core/min.js +1 -0
- package/dist/blz-rds/commands/core/multiply.d.ts +2 -0
- package/dist/blz-rds/commands/core/multiply.js +1 -0
- package/dist/blz-rds/commands/core/not-equals.d.ts +3 -0
- package/dist/blz-rds/commands/core/not-equals.js +1 -0
- package/dist/blz-rds/commands/core/not-in.d.ts +3 -0
- package/dist/blz-rds/commands/core/not-in.js +1 -0
- package/dist/blz-rds/commands/core/not.d.ts +3 -0
- package/dist/blz-rds/commands/core/not.js +1 -0
- package/dist/blz-rds/commands/core/null.d.ts +2 -0
- package/dist/blz-rds/commands/core/null.js +1 -0
- package/dist/blz-rds/commands/core/nvl.d.ts +2 -0
- package/dist/blz-rds/commands/core/nvl.js +1 -0
- package/dist/blz-rds/commands/core/or.d.ts +3 -0
- package/dist/blz-rds/commands/core/or.js +1 -0
- package/dist/blz-rds/commands/core/parameter.d.ts +2 -0
- package/dist/blz-rds/commands/core/parameter.js +1 -0
- package/dist/blz-rds/commands/core/remainder.d.ts +2 -0
- package/dist/blz-rds/commands/core/remainder.js +1 -0
- package/dist/blz-rds/commands/core/string.d.ts +2 -0
- package/dist/blz-rds/commands/core/string.js +1 -0
- package/dist/blz-rds/commands/core/subtract.d.ts +2 -0
- package/dist/blz-rds/commands/core/subtract.js +1 -0
- package/dist/blz-rds/commands/core/sum.d.ts +2 -0
- package/dist/blz-rds/commands/core/sum.js +1 -0
- package/dist/blz-rds/commands/core/true.d.ts +2 -0
- package/dist/blz-rds/commands/core/true.js +1 -0
- package/dist/blz-rds/commands/core/tuple.d.ts +2 -0
- package/dist/blz-rds/commands/core/tuple.js +1 -0
- package/dist/blz-rds/commands/datetimes/add-days.d.ts +2 -0
- package/dist/blz-rds/commands/datetimes/add-days.js +1 -0
- package/dist/blz-rds/commands/datetimes/add-hours.d.ts +2 -0
- package/dist/blz-rds/commands/datetimes/add-hours.js +1 -0
- package/dist/blz-rds/commands/datetimes/add-milliseconds.d.ts +2 -0
- package/dist/blz-rds/commands/datetimes/add-milliseconds.js +1 -0
- package/dist/blz-rds/commands/datetimes/add-minutes.d.ts +2 -0
- package/dist/blz-rds/commands/datetimes/add-minutes.js +1 -0
- package/dist/blz-rds/commands/datetimes/add-months.d.ts +2 -0
- package/dist/blz-rds/commands/datetimes/add-months.js +1 -0
- package/dist/blz-rds/commands/datetimes/add-seconds.d.ts +2 -0
- package/dist/blz-rds/commands/datetimes/add-seconds.js +1 -0
- package/dist/blz-rds/commands/datetimes/add-years.d.ts +2 -0
- package/dist/blz-rds/commands/datetimes/add-years.js +1 -0
- package/dist/blz-rds/commands/datetimes/date-diff.d.ts +2 -0
- package/dist/blz-rds/commands/datetimes/date-diff.js +1 -0
- package/dist/blz-rds/commands/datetimes/date.d.ts +2 -0
- package/dist/blz-rds/commands/datetimes/date.js +1 -0
- package/dist/blz-rds/commands/datetimes/datetime-diff.d.ts +2 -0
- package/dist/blz-rds/commands/datetimes/datetime-diff.js +1 -0
- package/dist/blz-rds/commands/datetimes/datetime.d.ts +2 -0
- package/dist/blz-rds/commands/datetimes/datetime.js +1 -0
- package/dist/blz-rds/commands/datetimes/day.d.ts +2 -0
- package/dist/blz-rds/commands/datetimes/day.js +1 -0
- package/dist/blz-rds/commands/datetimes/hour.d.ts +2 -0
- package/dist/blz-rds/commands/datetimes/hour.js +1 -0
- package/dist/blz-rds/commands/datetimes/millisecond.d.ts +2 -0
- package/dist/blz-rds/commands/datetimes/millisecond.js +1 -0
- package/dist/blz-rds/commands/datetimes/minute.d.ts +2 -0
- package/dist/blz-rds/commands/datetimes/minute.js +1 -0
- package/dist/blz-rds/commands/datetimes/month-text.d.ts +2 -0
- package/dist/blz-rds/commands/datetimes/month-text.js +1 -0
- package/dist/blz-rds/commands/datetimes/month.d.ts +2 -0
- package/dist/blz-rds/commands/datetimes/month.js +1 -0
- package/dist/blz-rds/commands/datetimes/now.d.ts +2 -0
- package/dist/blz-rds/commands/datetimes/now.js +1 -0
- package/dist/blz-rds/commands/datetimes/second.d.ts +2 -0
- package/dist/blz-rds/commands/datetimes/second.js +1 -0
- package/dist/blz-rds/commands/datetimes/subtract-days.d.ts +2 -0
- package/dist/blz-rds/commands/datetimes/subtract-days.js +1 -0
- package/dist/blz-rds/commands/datetimes/subtract-hours.d.ts +2 -0
- package/dist/blz-rds/commands/datetimes/subtract-hours.js +1 -0
- package/dist/blz-rds/commands/datetimes/subtract-milliseconds.d.ts +2 -0
- package/dist/blz-rds/commands/datetimes/subtract-milliseconds.js +1 -0
- package/dist/blz-rds/commands/datetimes/subtract-minutes.d.ts +2 -0
- package/dist/blz-rds/commands/datetimes/subtract-minutes.js +1 -0
- package/dist/blz-rds/commands/datetimes/subtract-seconds.d.ts +2 -0
- package/dist/blz-rds/commands/datetimes/subtract-seconds.js +1 -0
- package/dist/blz-rds/commands/datetimes/time-diff.d.ts +2 -0
- package/dist/blz-rds/commands/datetimes/time-diff.js +1 -0
- package/dist/blz-rds/commands/datetimes/time.d.ts +2 -0
- package/dist/blz-rds/commands/datetimes/time.js +1 -0
- package/dist/blz-rds/commands/datetimes/today.d.ts +2 -0
- package/dist/blz-rds/commands/datetimes/today.js +1 -0
- package/dist/blz-rds/commands/datetimes/week-day-text.d.ts +2 -0
- package/dist/blz-rds/commands/datetimes/week-day-text.js +1 -0
- package/dist/blz-rds/commands/datetimes/week-day.d.ts +2 -0
- package/dist/blz-rds/commands/datetimes/week-day.js +1 -0
- package/dist/blz-rds/commands/datetimes/week.d.ts +2 -0
- package/dist/blz-rds/commands/datetimes/week.js +1 -0
- package/dist/blz-rds/commands/datetimes/year.d.ts +2 -0
- package/dist/blz-rds/commands/datetimes/year.js +1 -0
- package/dist/blz-rds/commands/math/abs.d.ts +2 -0
- package/dist/blz-rds/commands/math/abs.js +1 -0
- package/dist/blz-rds/commands/math/acos.d.ts +2 -0
- package/dist/blz-rds/commands/math/acos.js +1 -0
- package/dist/blz-rds/commands/math/asin.d.ts +2 -0
- package/dist/blz-rds/commands/math/asin.js +1 -0
- package/dist/blz-rds/commands/math/atan.d.ts +2 -0
- package/dist/blz-rds/commands/math/atan.js +1 -0
- package/dist/blz-rds/commands/math/atan2.d.ts +2 -0
- package/dist/blz-rds/commands/math/atan2.js +1 -0
- package/dist/blz-rds/commands/math/ceil.d.ts +2 -0
- package/dist/blz-rds/commands/math/ceil.js +1 -0
- package/dist/blz-rds/commands/math/cos.d.ts +2 -0
- package/dist/blz-rds/commands/math/cos.js +1 -0
- package/dist/blz-rds/commands/math/cosh.d.ts +2 -0
- package/dist/blz-rds/commands/math/cosh.js +1 -0
- package/dist/blz-rds/commands/math/exp.d.ts +2 -0
- package/dist/blz-rds/commands/math/exp.js +1 -0
- package/dist/blz-rds/commands/math/floor.d.ts +2 -0
- package/dist/blz-rds/commands/math/floor.js +1 -0
- package/dist/blz-rds/commands/math/log.d.ts +2 -0
- package/dist/blz-rds/commands/math/log.js +1 -0
- package/dist/blz-rds/commands/math/log10.d.ts +2 -0
- package/dist/blz-rds/commands/math/log10.js +1 -0
- package/dist/blz-rds/commands/math/pow.d.ts +2 -0
- package/dist/blz-rds/commands/math/pow.js +1 -0
- package/dist/blz-rds/commands/math/random.d.ts +2 -0
- package/dist/blz-rds/commands/math/random.js +1 -0
- package/dist/blz-rds/commands/math/round.d.ts +2 -0
- package/dist/blz-rds/commands/math/round.js +1 -0
- package/dist/blz-rds/commands/math/sign.d.ts +2 -0
- package/dist/blz-rds/commands/math/sign.js +1 -0
- package/dist/blz-rds/commands/math/sin.d.ts +2 -0
- package/dist/blz-rds/commands/math/sin.js +1 -0
- package/dist/blz-rds/commands/math/sinh.d.ts +2 -0
- package/dist/blz-rds/commands/math/sinh.js +1 -0
- package/dist/blz-rds/commands/math/sqrt.d.ts +2 -0
- package/dist/blz-rds/commands/math/sqrt.js +1 -0
- package/dist/blz-rds/commands/math/tan.d.ts +2 -0
- package/dist/blz-rds/commands/math/tan.js +1 -0
- package/dist/blz-rds/commands/math/tanh.d.ts +2 -0
- package/dist/blz-rds/commands/math/tanh.js +1 -0
- package/dist/blz-rds/commands/math/trunc.d.ts +2 -0
- package/dist/blz-rds/commands/math/trunc.js +1 -0
- package/dist/blz-rds/commands/strings/concat.d.ts +2 -0
- package/dist/blz-rds/commands/strings/concat.js +1 -0
- package/dist/blz-rds/commands/strings/contains.d.ts +3 -0
- package/dist/blz-rds/commands/strings/contains.js +1 -0
- package/dist/blz-rds/commands/strings/ends-with.d.ts +3 -0
- package/dist/blz-rds/commands/strings/ends-with.js +1 -0
- package/dist/blz-rds/commands/strings/index-of.d.ts +2 -0
- package/dist/blz-rds/commands/strings/index-of.js +1 -0
- package/dist/blz-rds/commands/strings/is-null-or-empty.d.ts +3 -0
- package/dist/blz-rds/commands/strings/is-null-or-empty.js +1 -0
- package/dist/blz-rds/commands/strings/is-null-or-white-space.d.ts +3 -0
- package/dist/blz-rds/commands/strings/is-null-or-white-space.js +1 -0
- package/dist/blz-rds/commands/strings/join.d.ts +2 -0
- package/dist/blz-rds/commands/strings/join.js +1 -0
- package/dist/blz-rds/commands/strings/last-index-of.d.ts +2 -0
- package/dist/blz-rds/commands/strings/last-index-of.js +1 -0
- package/dist/blz-rds/commands/strings/length.d.ts +2 -0
- package/dist/blz-rds/commands/strings/length.js +1 -0
- package/dist/blz-rds/commands/strings/pad-left.d.ts +2 -0
- package/dist/blz-rds/commands/strings/pad-left.js +1 -0
- package/dist/blz-rds/commands/strings/pad-right.d.ts +2 -0
- package/dist/blz-rds/commands/strings/pad-right.js +1 -0
- package/dist/blz-rds/commands/strings/replace.d.ts +2 -0
- package/dist/blz-rds/commands/strings/replace.js +1 -0
- package/dist/blz-rds/commands/strings/starts-with.d.ts +3 -0
- package/dist/blz-rds/commands/strings/starts-with.js +1 -0
- package/dist/blz-rds/commands/strings/substring.d.ts +2 -0
- package/dist/blz-rds/commands/strings/substring.js +1 -0
- package/dist/blz-rds/commands/strings/to-lower.d.ts +2 -0
- package/dist/blz-rds/commands/strings/to-lower.js +1 -0
- package/dist/blz-rds/commands/strings/to-upper.d.ts +2 -0
- package/dist/blz-rds/commands/strings/to-upper.js +1 -0
- package/dist/blz-rds/commands/strings/trim-end.d.ts +2 -0
- package/dist/blz-rds/commands/strings/trim-end.js +1 -0
- package/dist/blz-rds/commands/strings/trim-start.d.ts +2 -0
- package/dist/blz-rds/commands/strings/trim-start.js +1 -0
- package/dist/blz-rds/commands/strings/trim.d.ts +2 -0
- package/dist/blz-rds/commands/strings/trim.js +1 -0
- package/dist/blz-rds/index.d.ts +53 -0
- package/dist/blz-rds/index.js +1 -0
- package/dist/blz-rds-mysql/base.d.ts +83 -0
- package/dist/blz-rds-mysql/base.js +1 -0
- package/dist/blz-rds-mysql/connection-manager.d.ts +8 -0
- package/dist/blz-rds-mysql/connection-manager.js +1 -0
- package/dist/blz-rds-mysql/execute-bulk-insert.d.ts +2 -0
- package/dist/blz-rds-mysql/execute-bulk-insert.js +1 -0
- package/dist/blz-rds-mysql/execute-bulk-merge.d.ts +2 -0
- package/dist/blz-rds-mysql/execute-bulk-merge.js +1 -0
- package/dist/blz-rds-mysql/execute-non-query.d.ts +14 -0
- package/dist/blz-rds-mysql/execute-non-query.js +1 -0
- package/dist/blz-rds-mysql/execute-query.d.ts +11 -0
- package/dist/blz-rds-mysql/execute-query.js +1 -0
- package/dist/blz-rds-mysql/index.d.ts +9 -0
- package/dist/blz-rds-mysql/index.js +1 -0
- package/dist/blz-rds-mysql/stored-procedure.d.ts +19 -0
- package/dist/blz-rds-mysql/stored-procedure.js +1 -0
- package/dist/blz-rds-mysqlx/base.d.ts +83 -0
- package/dist/blz-rds-mysqlx/base.js +1 -0
- package/dist/blz-rds-mysqlx/connection-manager.d.ts +6 -0
- package/dist/blz-rds-mysqlx/connection-manager.js +1 -0
- package/dist/blz-rds-mysqlx/execute-bulk-insert.d.ts +2 -0
- package/dist/blz-rds-mysqlx/execute-bulk-insert.js +1 -0
- package/dist/blz-rds-mysqlx/execute-bulk-merge.d.ts +2 -0
- package/dist/blz-rds-mysqlx/execute-bulk-merge.js +1 -0
- package/dist/blz-rds-mysqlx/execute-non-query.d.ts +4 -0
- package/dist/blz-rds-mysqlx/execute-non-query.js +1 -0
- package/dist/blz-rds-mysqlx/execute-query.d.ts +7 -0
- package/dist/blz-rds-mysqlx/execute-query.js +1 -0
- package/dist/blz-rds-mysqlx/index.d.ts +9 -0
- package/dist/blz-rds-mysqlx/index.js +1 -0
- package/dist/blz-rds-mysqlx/stored-procedure.d.ts +20 -0
- package/dist/blz-rds-mysqlx/stored-procedure.js +1 -0
- package/dist/blz-rds-oracle/index.d.ts +25 -0
- package/dist/blz-rds-oracle/index.js +1 -0
- package/dist/blz-rds-postgres/base.d.ts +94 -0
- package/dist/blz-rds-postgres/base.js +1 -0
- package/dist/blz-rds-postgres/connection-manager.d.ts +6 -0
- package/dist/blz-rds-postgres/connection-manager.js +1 -0
- package/dist/blz-rds-postgres/execute-bulk-insert.d.ts +5 -0
- package/dist/blz-rds-postgres/execute-bulk-insert.js +1 -0
- package/dist/blz-rds-postgres/execute-bulk-merge.d.ts +4 -0
- package/dist/blz-rds-postgres/execute-bulk-merge.js +1 -0
- package/dist/blz-rds-postgres/execute-non-query.d.ts +12 -0
- package/dist/blz-rds-postgres/execute-non-query.js +1 -0
- package/dist/blz-rds-postgres/execute-query.d.ts +4 -0
- package/dist/blz-rds-postgres/execute-query.js +1 -0
- package/dist/blz-rds-postgres/index.d.ts +9 -0
- package/dist/blz-rds-postgres/index.js +1 -0
- package/dist/blz-rds-postgres/result-set.js +1 -0
- package/dist/blz-rds-postgres/stored-procedure.d.ts +19 -0
- package/dist/blz-rds-postgres/stored-procedure.js +1 -0
- package/dist/blz-redis/index.d.ts +31 -0
- package/dist/blz-redis/index.js +1 -0
- package/dist/blz-redis/lib/redisCache.d.ts +33 -0
- package/dist/blz-redis/lib/redisCache.js +1 -0
- package/dist/blz-regex/index.d.ts +3 -0
- package/dist/blz-regex/index.js +1 -0
- package/dist/blz-security/__test__/autorization.test.js +1 -0
- package/dist/blz-security/__test__/autorizationKpn.test.js +1 -0
- package/dist/blz-security/__test__/orderManagement.test.js +1 -0
- package/dist/blz-security/__test__/secureUrl.test.js +1 -0
- package/dist/blz-security/__test__/solveMergeRule.test.js +1 -0
- package/dist/blz-security/__test__/sqlInjectionGuard.test.js +1 -0
- package/dist/blz-security/__test__/xssGuard.test.js +1 -0
- package/dist/blz-security/authorizationService.d.ts +42 -0
- package/dist/blz-security/authorizationService.js +2 -0
- package/dist/blz-security/config/global.js +1 -0
- package/dist/blz-security/filescanner/index.d.ts +24 -0
- package/dist/blz-security/filescanner/index.js +1 -0
- package/dist/blz-security/helpers/consts.d.ts +28 -0
- package/dist/blz-security/helpers/consts.js +1 -0
- package/dist/blz-security/helpers/utils.d.ts +82 -0
- package/dist/blz-security/helpers/utils.js +1 -0
- package/dist/blz-security/implementations/cache.d.ts +58 -0
- package/dist/blz-security/implementations/cache.js +1 -0
- package/dist/blz-security/implementations/oidc.d.ts +100 -0
- package/dist/blz-security/implementations/oidc.js +1 -0
- package/dist/blz-security/implementations/pkceCacheStore.d.ts +2 -0
- package/dist/blz-security/implementations/pkceCacheStore.js +1 -0
- package/dist/blz-security/implementations/saml.js +1 -0
- package/dist/blz-security/implementations/uma.d.ts +31 -0
- package/dist/blz-security/implementations/uma.js +1 -0
- package/dist/blz-security/implementations/webAuthn.js +1 -0
- package/dist/blz-security/implementations/wstg.js +1 -0
- package/dist/blz-security/index.d.ts +4 -0
- package/dist/blz-security/index.js +2 -0
- package/dist/blz-security/lab/index.js +1 -0
- package/dist/blz-security/middleware/HapiServerAzureAd.d.ts +26 -0
- package/dist/blz-security/middleware/HapiServerAzureAd.js +1 -0
- package/dist/blz-security/middleware/HapiServerKeycloak.d.ts +47 -0
- package/dist/blz-security/middleware/HapiServerKeycloak.js +1 -0
- package/dist/blz-security/middleware/HapiServerSimToken.d.ts +13 -0
- package/dist/blz-security/middleware/HapiServerSimToken.js +1 -0
- package/dist/blz-security/middleware/hapi.d.ts +14 -0
- package/dist/blz-security/middleware/hapi.js +1 -0
- package/dist/blz-security/middleware/hapiServer.js +1 -0
- package/dist/blz-security/navigationMemoryRepository.d.ts +6 -0
- package/dist/blz-security/navigationMemoryRepository.js +1 -0
- package/dist/blz-security/navigationMongoDbRepository.d.ts +15 -0
- package/dist/blz-security/navigationMongoDbRepository.js +1 -0
- package/dist/blz-security/secureUrlService.d.ts +7 -0
- package/dist/blz-security/secureUrlService.js +1 -0
- package/dist/blz-security/securityService.d.ts +72 -0
- package/dist/blz-security/securityService.js +1 -0
- package/dist/blz-security/sqlInjectionGuard.d.ts +37 -0
- package/dist/blz-security/sqlInjectionGuard.js +1 -0
- package/dist/blz-security/xssGuard.d.ts +14 -0
- package/dist/blz-security/xssGuard.js +1 -0
- package/dist/blz-strings/index.d.ts +42 -0
- package/dist/blz-strings/index.js +1 -0
- package/dist/blz-uuid/index.d.ts +1 -0
- package/dist/blz-uuid/index.js +1 -0
- package/dist/blz-yaml/index.d.ts +2 -0
- package/dist/blz-yaml/index.js +1 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +1 -0
- package/dist/process-managers/index.d.ts +25 -0
- package/dist/process-managers/index.js +1 -0
- package/package.json +53 -42
- package/blz-base/health/index.js +0 -215
- package/blz-base/index.js +0 -1466
- package/blz-cache/LruCache.js +0 -44
- package/blz-cache/index.js +0 -29
- package/blz-config/index.js +0 -434
- package/blz-core/index.js +0 -364
- package/blz-cryptography/index.js +0 -54
- package/blz-datetimes/index.js +0 -356
- package/blz-file/example.dat +0 -2545
- package/blz-file/fileService.js +0 -205
- package/blz-file/index.js +0 -94
- package/blz-file/index.test.js +0 -31
- package/blz-file/lab.js +0 -33
- package/blz-hazelcast/index.js +0 -189
- package/blz-hazelcast/lib/credentials.js +0 -25
- package/blz-hazelcast/lib/credentialsFactory.js +0 -12
- package/blz-hazelcast/lib/hazelcastCache.js +0 -234
- package/blz-iterable/index.js +0 -446
- package/blz-json-schema/index.js +0 -11
- package/blz-jwt/index.js +0 -121
- package/blz-kafka/index.js +0 -522
- package/blz-math/index.js +0 -131
- package/blz-mongodb/index.js +0 -326
- package/blz-rds/__test__/scape.test.js +0 -58
- package/blz-rds/blz-rds-executor.js +0 -578
- package/blz-rds/blz-rds-helper.js +0 -310
- package/blz-rds/commands/core/add.js +0 -13
- package/blz-rds/commands/core/and.js +0 -18
- package/blz-rds/commands/core/asc.js +0 -10
- package/blz-rds/commands/core/avg.js +0 -10
- package/blz-rds/commands/core/column-ref.js +0 -8
- package/blz-rds/commands/core/count-distinct.js +0 -10
- package/blz-rds/commands/core/count.js +0 -10
- package/blz-rds/commands/core/decimal.js +0 -8
- package/blz-rds/commands/core/desc.js +0 -10
- package/blz-rds/commands/core/distinct.js +0 -10
- package/blz-rds/commands/core/divide.js +0 -11
- package/blz-rds/commands/core/embedded-exists.js +0 -17
- package/blz-rds/commands/core/embedded-select.js +0 -17
- package/blz-rds/commands/core/equals.js +0 -9
- package/blz-rds/commands/core/false.js +0 -8
- package/blz-rds/commands/core/greater-or-equal.js +0 -9
- package/blz-rds/commands/core/greater.js +0 -9
- package/blz-rds/commands/core/in.js +0 -9
- package/blz-rds/commands/core/integer.js +0 -8
- package/blz-rds/commands/core/is-not-null.js +0 -11
- package/blz-rds/commands/core/is-null-or-value.js +0 -10
- package/blz-rds/commands/core/is-null.js +0 -11
- package/blz-rds/commands/core/less-or-equal.js +0 -9
- package/blz-rds/commands/core/less-unary.js +0 -12
- package/blz-rds/commands/core/less.js +0 -9
- package/blz-rds/commands/core/like.js +0 -12
- package/blz-rds/commands/core/max.js +0 -10
- package/blz-rds/commands/core/min.js +0 -10
- package/blz-rds/commands/core/multiply.js +0 -13
- package/blz-rds/commands/core/not-equals.js +0 -9
- package/blz-rds/commands/core/not-in.js +0 -9
- package/blz-rds/commands/core/not.js +0 -13
- package/blz-rds/commands/core/null.js +0 -8
- package/blz-rds/commands/core/nvl.js +0 -11
- package/blz-rds/commands/core/or.js +0 -13
- package/blz-rds/commands/core/parameter.js +0 -34
- package/blz-rds/commands/core/remainder.js +0 -16
- package/blz-rds/commands/core/string.js +0 -8
- package/blz-rds/commands/core/subtract.js +0 -13
- package/blz-rds/commands/core/sum.js +0 -10
- package/blz-rds/commands/core/true.js +0 -8
- package/blz-rds/commands/core/tuple.js +0 -13
- package/blz-rds/commands/datetimes/add-days.js +0 -11
- package/blz-rds/commands/datetimes/add-hours.js +0 -11
- package/blz-rds/commands/datetimes/add-milliseconds.js +0 -11
- package/blz-rds/commands/datetimes/add-minutes.js +0 -11
- package/blz-rds/commands/datetimes/add-months.js +0 -11
- package/blz-rds/commands/datetimes/add-seconds.js +0 -11
- package/blz-rds/commands/datetimes/add-years.js +0 -11
- package/blz-rds/commands/datetimes/date-diff.js +0 -11
- package/blz-rds/commands/datetimes/date.js +0 -12
- package/blz-rds/commands/datetimes/datetime-diff.js +0 -11
- package/blz-rds/commands/datetimes/datetime.js +0 -15
- package/blz-rds/commands/datetimes/day.js +0 -10
- package/blz-rds/commands/datetimes/hour.js +0 -10
- package/blz-rds/commands/datetimes/millisecond.js +0 -10
- package/blz-rds/commands/datetimes/minute.js +0 -10
- package/blz-rds/commands/datetimes/month-text.js +0 -10
- package/blz-rds/commands/datetimes/month.js +0 -10
- package/blz-rds/commands/datetimes/now.js +0 -9
- package/blz-rds/commands/datetimes/second.js +0 -10
- package/blz-rds/commands/datetimes/subtract-days.js +0 -11
- package/blz-rds/commands/datetimes/subtract-hours.js +0 -11
- package/blz-rds/commands/datetimes/subtract-milliseconds.js +0 -11
- package/blz-rds/commands/datetimes/subtract-minutes.js +0 -11
- package/blz-rds/commands/datetimes/subtract-seconds.js +0 -11
- package/blz-rds/commands/datetimes/time-diff.js +0 -11
- package/blz-rds/commands/datetimes/time.js +0 -13
- package/blz-rds/commands/datetimes/today.js +0 -9
- package/blz-rds/commands/datetimes/week-day-text.js +0 -10
- package/blz-rds/commands/datetimes/week-day.js +0 -10
- package/blz-rds/commands/datetimes/week.js +0 -10
- package/blz-rds/commands/datetimes/year.js +0 -10
- package/blz-rds/commands/math/abs.js +0 -10
- package/blz-rds/commands/math/acos.js +0 -10
- package/blz-rds/commands/math/asin.js +0 -10
- package/blz-rds/commands/math/atan.js +0 -10
- package/blz-rds/commands/math/atan2.js +0 -11
- package/blz-rds/commands/math/ceil.js +0 -10
- package/blz-rds/commands/math/cos.js +0 -10
- package/blz-rds/commands/math/cosh.js +0 -10
- package/blz-rds/commands/math/exp.js +0 -10
- package/blz-rds/commands/math/floor.js +0 -10
- package/blz-rds/commands/math/log.js +0 -18
- package/blz-rds/commands/math/log10.js +0 -10
- package/blz-rds/commands/math/pow.js +0 -11
- package/blz-rds/commands/math/random.js +0 -9
- package/blz-rds/commands/math/round.js +0 -18
- package/blz-rds/commands/math/sign.js +0 -10
- package/blz-rds/commands/math/sin.js +0 -10
- package/blz-rds/commands/math/sinh.js +0 -10
- package/blz-rds/commands/math/sqrt.js +0 -10
- package/blz-rds/commands/math/tan.js +0 -10
- package/blz-rds/commands/math/tanh.js +0 -10
- package/blz-rds/commands/math/trunc.js +0 -18
- package/blz-rds/commands/strings/concat.js +0 -20
- package/blz-rds/commands/strings/contains.js +0 -12
- package/blz-rds/commands/strings/ends-with.js +0 -12
- package/blz-rds/commands/strings/index-of.js +0 -11
- package/blz-rds/commands/strings/is-null-or-empty.js +0 -11
- package/blz-rds/commands/strings/is-null-or-white-space.js +0 -11
- package/blz-rds/commands/strings/join.js +0 -22
- package/blz-rds/commands/strings/last-index-of.js +0 -11
- package/blz-rds/commands/strings/length.js +0 -10
- package/blz-rds/commands/strings/pad-left.js +0 -20
- package/blz-rds/commands/strings/pad-right.js +0 -20
- package/blz-rds/commands/strings/replace.js +0 -12
- package/blz-rds/commands/strings/starts-with.js +0 -12
- package/blz-rds/commands/strings/substring.js +0 -12
- package/blz-rds/commands/strings/to-lower.js +0 -10
- package/blz-rds/commands/strings/to-upper.js +0 -10
- package/blz-rds/commands/strings/trim-end.js +0 -10
- package/blz-rds/commands/strings/trim-start.js +0 -10
- package/blz-rds/commands/strings/trim.js +0 -10
- package/blz-rds/index.js +0 -744
- package/blz-rds-mysql/base.js +0 -857
- package/blz-rds-mysql/connection-manager.js +0 -129
- package/blz-rds-mysql/execute-bulk-insert.js +0 -35
- package/blz-rds-mysql/execute-bulk-merge.js +0 -45
- package/blz-rds-mysql/execute-non-query.js +0 -34
- package/blz-rds-mysql/execute-query.js +0 -50
- package/blz-rds-mysql/index.js +0 -41
- package/blz-rds-mysql/stored-procedure.js +0 -207
- package/blz-rds-mysqlx/base.js +0 -846
- package/blz-rds-mysqlx/connection-manager.js +0 -141
- package/blz-rds-mysqlx/execute-bulk-insert.js +0 -35
- package/blz-rds-mysqlx/execute-bulk-merge.js +0 -45
- package/blz-rds-mysqlx/execute-non-query.js +0 -29
- package/blz-rds-mysqlx/execute-query.js +0 -39
- package/blz-rds-mysqlx/index.js +0 -41
- package/blz-rds-mysqlx/stored-procedure.js +0 -179
- package/blz-rds-oracle/index.js +0 -539
- package/blz-rds-postgres/base.js +0 -861
- package/blz-rds-postgres/connection-manager.js +0 -225
- package/blz-rds-postgres/execute-bulk-insert.js +0 -81
- package/blz-rds-postgres/execute-bulk-merge.js +0 -93
- package/blz-rds-postgres/execute-non-query.js +0 -23
- package/blz-rds-postgres/execute-query.js +0 -37
- package/blz-rds-postgres/index.js +0 -41
- package/blz-rds-postgres/result-set.js +0 -51
- package/blz-rds-postgres/stored-procedure.js +0 -116
- package/blz-redis/index.js +0 -217
- package/blz-redis/lib/redisCache.js +0 -265
- package/blz-regex/index.js +0 -25
- package/blz-security/.eslintrc.js +0 -15
- package/blz-security/__test__/AuthorizationKpn.yaml +0 -1149
- package/blz-security/__test__/FinancingSetting.yaml +0 -177
- package/blz-security/__test__/KpnConfigPortal.yaml +0 -330
- package/blz-security/__test__/OrderManagement.yaml +0 -5190
- package/blz-security/__test__/Security.yaml +0 -128
- package/blz-security/__test__/autorization.test.js +0 -105
- package/blz-security/__test__/autorizationKpn.test.js +0 -42
- package/blz-security/__test__/orderManagement.test.js +0 -26
- package/blz-security/__test__/secureUrl.test.js +0 -79
- package/blz-security/__test__/solveMergeRule.test.js +0 -109
- package/blz-security/__test__/sqlInjectionGuard.test.js +0 -203
- package/blz-security/__test__/xssGuard.test.js +0 -204
- package/blz-security/authorizationService.js +0 -537
- package/blz-security/config/global.js +0 -8
- package/blz-security/config/welcome +0 -8
- package/blz-security/doc/README.md +0 -75
- package/blz-security/filescanner/index.js +0 -46
- package/blz-security/helpers/consts.js +0 -229
- package/blz-security/helpers/utils.js +0 -267
- package/blz-security/implementations/cache.js +0 -90
- package/blz-security/implementations/oidc.js +0 -404
- package/blz-security/implementations/pkceCacheStore.js +0 -23
- package/blz-security/implementations/saml.js +0 -10
- package/blz-security/implementations/uma.js +0 -63
- package/blz-security/implementations/webAuthn.js +0 -9
- package/blz-security/implementations/wstg.js +0 -72
- package/blz-security/index.js +0 -77
- package/blz-security/lab/index.js +0 -43
- package/blz-security/middleware/HapiServerAzureAd.js +0 -681
- package/blz-security/middleware/HapiServerKeycloak.js +0 -876
- package/blz-security/middleware/HapiServerSimToken.js +0 -286
- package/blz-security/middleware/hapi.js +0 -555
- package/blz-security/middleware/hapiServer.js +0 -1008
- package/blz-security/navigationMemoryRepository.js +0 -15
- package/blz-security/navigationMongoDbRepository.js +0 -73
- package/blz-security/secureUrlService.js +0 -47
- package/blz-security/securityService.js +0 -413
- package/blz-security/sqlInjectionGuard.js +0 -162
- package/blz-security/templates/forbidden.html +0 -0
- package/blz-security/templates/session-iframe-azure-ad.html +0 -7
- package/blz-security/templates/session-iframe.html +0 -73
- package/blz-security/templates/unauthorized.html +0 -1
- package/blz-security/xssGuard.js +0 -87
- package/blz-strings/index.js +0 -167
- package/blz-uuid/index.js +0 -7
- package/blz-yaml/index.js +0 -19
- package/index.js +0 -84
- package/process-managers/index.js +0 -422
- /package/{blz-rds-mysql → dist/blz-rds-mysql}/syntaxis.json +0 -0
- /package/{blz-rds-mysqlx → dist/blz-rds-mysqlx}/syntaxis.json +0 -0
- /package/{blz-rds-oracle → dist/blz-rds-oracle}/syntaxis.json +0 -0
- /package/{blz-rds-postgres → dist/blz-rds-postgres}/syntaxis.json +0 -0
- /package/{blz-security → dist/blz-security}/lab/ConfigurationAdmin.agent.json +0 -0
- /package/{blz-security → dist/blz-security}/lab/frontend.json +0 -0
- /package/{blz-security → dist/blz-security}/lab/result.json +0 -0
- /package/{blz-security → dist/blz-security}/lab/resultOnWeb.json +0 -0
- /package/{blz-security → dist/blz-security}/lab/rules.json +0 -0
- /package/{blz-security → dist/blz-security}/lab/securityRules.json +0 -0
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const pg = require("pg");
|
|
3
|
-
const types = require('pg').types
|
|
4
|
-
const BlzBase = require("./base");
|
|
5
|
-
const _ = require("underscore");
|
|
6
|
-
const dayjs = require("dayjs");
|
|
7
|
-
//https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING
|
|
8
|
-
|
|
9
|
-
types.setTypeParser(types.builtins.TIMESTAMPTZ, (value) => {
|
|
10
|
-
if (isUtcOffset(value)) {
|
|
11
|
-
value = dayjs(value).format("YYYY-MM-DDTHH:mm:ss");
|
|
12
|
-
}
|
|
13
|
-
return value;
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
types.setTypeParser(types.builtins.DATE, (value) => {
|
|
17
|
-
return dayjs(value).format("YYYY-MM-DDTHH:mm:ss");
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
types.setTypeParser(types.builtins.TIMESTAMP, (value) => {
|
|
21
|
-
return dayjs(value).format("YYYY-MM-DDTHH:mm:ss");
|
|
22
|
-
})
|
|
23
|
-
/*
|
|
24
|
-
types.setTypeParser(types.builtins.TIME, (value) => {
|
|
25
|
-
})
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
let poolsByName = new Map();
|
|
29
|
-
|
|
30
|
-
function getURI(config) {
|
|
31
|
-
//postgresql://[user[:password]@][netloc][:port][,...][/dbname][?param1=value1&...]
|
|
32
|
-
let uri = ["postgresql://"];
|
|
33
|
-
if(config.user) {
|
|
34
|
-
uri.push(config.user);
|
|
35
|
-
if(config.password) {
|
|
36
|
-
uri.push(`:${config.password}`)
|
|
37
|
-
}
|
|
38
|
-
uri.push("@")
|
|
39
|
-
}
|
|
40
|
-
if(config.host) {
|
|
41
|
-
uri.push(config.host);
|
|
42
|
-
}
|
|
43
|
-
if(config.port) {
|
|
44
|
-
uri.push(`:${config.port}`);
|
|
45
|
-
}
|
|
46
|
-
if(config.database) {
|
|
47
|
-
uri.push(`/${config.database}`);
|
|
48
|
-
}
|
|
49
|
-
// if(config.ssl) {
|
|
50
|
-
// uri.push(`?ssl=${config.ssl}`);
|
|
51
|
-
// }
|
|
52
|
-
return uri.join("");
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function getCustomURI(config) {
|
|
56
|
-
if (config.url) {
|
|
57
|
-
let indexStart = config.url.indexOf('?schema=');
|
|
58
|
-
if (indexStart === -1) {
|
|
59
|
-
indexStart = config.url.indexOf('&schema=');
|
|
60
|
-
}
|
|
61
|
-
if (indexStart > -1) {
|
|
62
|
-
let indexEnd = config.url.indexOf('&', indexStart + 1);
|
|
63
|
-
let schemaAttribute = null;
|
|
64
|
-
if (indexEnd === -1) {
|
|
65
|
-
schemaAttribute = config.url.substring(indexStart + 1);
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
schemaAttribute = config.url.substring(indexStart + 1, indexEnd);
|
|
69
|
-
}
|
|
70
|
-
let schemaAttributeParts = schemaAttribute.split('=');
|
|
71
|
-
if (schemaAttributeParts.length === 2) {
|
|
72
|
-
config.schema = schemaAttributeParts[1];
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return `postgresql://${config.url}`
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function getParameters(config = {}) {
|
|
80
|
-
let properties = _.reduce(config.properties, (memo, value) => {
|
|
81
|
-
return memo + "," + (value.key === 'statementTimeout' ? 'statement_timeout' : value.key) + "=" + value.value;
|
|
82
|
-
}, '');
|
|
83
|
-
return properties.slice("1");
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function getObjectConfig(config = {}) {
|
|
87
|
-
if(!config.name) {
|
|
88
|
-
throw BlzBase.error('RdsPostgresException', { name: config.name });
|
|
89
|
-
}
|
|
90
|
-
if(config.customUrl) {
|
|
91
|
-
return getCustomURI(config);
|
|
92
|
-
}
|
|
93
|
-
return getURI(config);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function getConnectionString(config = {}) {
|
|
97
|
-
let connectionString = [ getObjectConfig(config) ];
|
|
98
|
-
let parameters = getParameters(config);
|
|
99
|
-
if(!_.isEmpty(parameters)) {
|
|
100
|
-
connectionString.push(`?${parameters}`);
|
|
101
|
-
}
|
|
102
|
-
return connectionString.join("");
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
async function getPool(config = {}) {
|
|
106
|
-
let key = config.name, poolConfig;
|
|
107
|
-
let pool = poolsByName.get(key);
|
|
108
|
-
if(pool) {
|
|
109
|
-
return pool;
|
|
110
|
-
}
|
|
111
|
-
let connectionString = getConnectionString(config);
|
|
112
|
-
poolConfig = _.pick(config, "max", "min", "connectionTimeoutMillis", "idleTimeoutMillis", "keepAlive", "parseInputDatesAsUTC", "ssl", "keepAliveInitialDelayMillis")
|
|
113
|
-
if (config.queryTimeout)
|
|
114
|
-
poolConfig.query_timeout = config.queryTimeout;
|
|
115
|
-
if (config.idleInTransactionSessionTimeout)
|
|
116
|
-
poolConfig.idle_in_transaction_session_timeout = config.idleInTransactionSessionTimeout;
|
|
117
|
-
poolConfig.connectionString = connectionString;
|
|
118
|
-
if(config.ssl) {
|
|
119
|
-
let ssl = { require: true, rejectUnauthorized: false } // Set to false if self-signed certificate is used
|
|
120
|
-
if(config.sslCertPath) {
|
|
121
|
-
ssl.cert = await BlzBase.readFile(config.sslCertPath);
|
|
122
|
-
}
|
|
123
|
-
if(config.sslKeyPath) {
|
|
124
|
-
ssl.key = await BlzBase.readFile(config.sslKeyPath);
|
|
125
|
-
}
|
|
126
|
-
if(config.sslPemPath) {
|
|
127
|
-
ssl.ca = await BlzBase.readFile(config.sslPemPath);
|
|
128
|
-
}
|
|
129
|
-
poolConfig.ssl = ssl;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
try {
|
|
133
|
-
pool = new pg.Pool(poolConfig);
|
|
134
|
-
if (config.schema) {
|
|
135
|
-
pool.on('connect', (client) => {
|
|
136
|
-
let sqlSet = `SET search_path TO ${config.schema}`;
|
|
137
|
-
client.query(sqlSet);
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
} catch(error) {
|
|
141
|
-
throw BlzBase.error('RdsPostgresCannotCreatePool', { config, uri }, error);
|
|
142
|
-
}
|
|
143
|
-
pool.name = config.name;
|
|
144
|
-
poolsByName.set(key, pool);
|
|
145
|
-
return pool;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
async function getConnection(pool) {
|
|
149
|
-
let session;
|
|
150
|
-
try {
|
|
151
|
-
session = await pool.connect();
|
|
152
|
-
} catch(error) {
|
|
153
|
-
throw BlzBase.error('RdsPostgresCannotConnectToDatabase', { name: pool.name }, error);
|
|
154
|
-
}
|
|
155
|
-
session.name = pool.name;
|
|
156
|
-
return session;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
async function terminate() {
|
|
160
|
-
let reject = [];
|
|
161
|
-
for (const [, pool] of poolsByName) {
|
|
162
|
-
try {
|
|
163
|
-
await pool.end();
|
|
164
|
-
} catch(error) {
|
|
165
|
-
reject.push(error);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
poolsByName.clear();
|
|
169
|
-
if(_.isEmpty(reject)) {
|
|
170
|
-
return true;
|
|
171
|
-
}
|
|
172
|
-
throw new Error(reject);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
const createConnection = async (config) => await getConnection(await getPool(config));
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
const beginTransaction = async function(connection) {
|
|
179
|
-
try {
|
|
180
|
-
await connection.query('BEGIN');
|
|
181
|
-
} catch(error) {
|
|
182
|
-
throw BlzBase.error('RdsPostgresBeginTransactionError', { name: connection.name }, error);
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
const commitTransaction = async function(connection) {
|
|
187
|
-
try {
|
|
188
|
-
await connection.query('COMMIT');
|
|
189
|
-
} catch(error) {
|
|
190
|
-
throw BlzBase.error('RdsPostgresCommitTransactionError', { name: connection.name }, error);
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
const rollbackTransaction = async function(connection) {
|
|
195
|
-
try {
|
|
196
|
-
await connection.query('ROLLBACK');
|
|
197
|
-
} catch(error) {
|
|
198
|
-
throw BlzBase.error('RdsPostgresRollbackTransactionError', { name: connection.name }, error);
|
|
199
|
-
}
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
const close = async function(connection) {
|
|
203
|
-
try {
|
|
204
|
-
await connection.release(true);
|
|
205
|
-
} catch(error) {
|
|
206
|
-
throw BlzBase.error('RdsPostgresCloseError', { name: connection.name }, error);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
function isUtcOffset(date) {
|
|
211
|
-
if (_.isNull(date) || _.isUndefined(date) || !_.isString(date)) {
|
|
212
|
-
return false;
|
|
213
|
-
}
|
|
214
|
-
const match = date.match(/^(.*)([+-])(\d{2})?:?(\d{2})$/);
|
|
215
|
-
return (!_.isNull(match)) && ((!_.isUndefined(match[3]) && (match[3] !== '00')) || (!_.isUndefined(match[4]) && (match[4] !== '00')));
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
module.exports = {
|
|
219
|
-
beginTransaction,
|
|
220
|
-
close,
|
|
221
|
-
commitTransaction,
|
|
222
|
-
createConnection,
|
|
223
|
-
rollbackTransaction,
|
|
224
|
-
terminate
|
|
225
|
-
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const SqlString = require('sqlstring')
|
|
3
|
-
const { DateTime } = require('luxon')
|
|
4
|
-
const Base = require('./base');
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const dateFormat = function (value, format) {
|
|
9
|
-
const iso = new Date(value).toISOString()
|
|
10
|
-
if (format === 'ISO') {
|
|
11
|
-
return DateTime.fromISO(iso).toISO()
|
|
12
|
-
} else {
|
|
13
|
-
return DateTime.fromISO(iso).toFormat(format)
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const getValue = function (source, type) {
|
|
19
|
-
if (source == null || source === undefined) {
|
|
20
|
-
return 'null'
|
|
21
|
-
} else {
|
|
22
|
-
const _type = type ? type.toLowerCase() : typeof source
|
|
23
|
-
switch (_type) {
|
|
24
|
-
case 'boolean':
|
|
25
|
-
return source ? 'true' : 'false'
|
|
26
|
-
case 'string':
|
|
27
|
-
if (source.includes('\'')) {
|
|
28
|
-
return `'${Base.replace(source, '\'', '\'\'')}'`
|
|
29
|
-
} else {
|
|
30
|
-
return `'${source}'`
|
|
31
|
-
}
|
|
32
|
-
case 'datetime':
|
|
33
|
-
return SqlString.escape(dateFormat(source, 'yyyy-LL-dd HH:mm:ss'))
|
|
34
|
-
case 'date':
|
|
35
|
-
return SqlString.escape(dateFormat(source,'yyyy-LL-dd'))
|
|
36
|
-
case 'time':
|
|
37
|
-
return SqlString.escape(dateFormat(source, 'HH:mm:ss' ))
|
|
38
|
-
default:
|
|
39
|
-
return source
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
async function executeBulkInsert(connection, sql, rows, options) {
|
|
45
|
-
let autoincremental = null
|
|
46
|
-
if (options.autoincrementalData && options.autoincrementalData.pkColumnName) {
|
|
47
|
-
autoincremental = { name: options.autoincrementalData.pkColumnName ,
|
|
48
|
-
alias: options.autoincrementalData.pkColumnAlias,
|
|
49
|
-
sequence: options.autoincrementalData.sequenceName
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
const list = []
|
|
53
|
-
for(let i = 0; i < rows.length; i++) {
|
|
54
|
-
const row = rows[i]
|
|
55
|
-
const values = []
|
|
56
|
-
if (autoincremental) {
|
|
57
|
-
values.push('nextval(\''+autoincremental.sequence+'\')' )
|
|
58
|
-
}
|
|
59
|
-
for(const column of options.columns) {
|
|
60
|
-
const value = getValue(row[column.alias], column.type)
|
|
61
|
-
values.push(value)
|
|
62
|
-
}
|
|
63
|
-
list.push(`(${values.join(',')})`)
|
|
64
|
-
}
|
|
65
|
-
const _sql = autoincremental ? 'INSERT INTO ' + options.rdsTable.tableName + ' (' + autoincremental.name + ',' + options.setsFields.join(', ') + ') VALUES ' : sql
|
|
66
|
-
const returning = autoincremental ? 'RETURNING ' + autoincremental.name + ' AS "' + autoincremental.alias + '"' : ''
|
|
67
|
-
const query = `${_sql} ${list.join(',')} ${returning};`
|
|
68
|
-
const result = await connection.query(query);
|
|
69
|
-
const ids = []
|
|
70
|
-
if (autoincremental) {
|
|
71
|
-
for (const p in result.rows) {
|
|
72
|
-
const id = result.rows[p][autoincremental.alias]
|
|
73
|
-
ids.push(id)
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return {
|
|
77
|
-
rowsAffected: result.rowCount,
|
|
78
|
-
ids
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
module.exports = executeBulkInsert;
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const SqlString = require('sqlstring')
|
|
3
|
-
const { DateTime } = require('luxon')
|
|
4
|
-
const Base = require('./base');
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const dateFormat = function (value, format) {
|
|
9
|
-
const iso = new Date(value).toISOString()
|
|
10
|
-
if (format === 'ISO') {
|
|
11
|
-
return DateTime.fromISO(iso).toISO()
|
|
12
|
-
} else {
|
|
13
|
-
return DateTime.fromISO(iso).toFormat(format)
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const getValue = function (source, type) {
|
|
19
|
-
if (source == null || source === undefined) {
|
|
20
|
-
return 'null'
|
|
21
|
-
} else {
|
|
22
|
-
const _type = type ? type.toLowerCase() : typeof source
|
|
23
|
-
switch (_type) {
|
|
24
|
-
case 'boolean':
|
|
25
|
-
return source ? 'true' : 'false'
|
|
26
|
-
case 'string':
|
|
27
|
-
if (source.includes('\'')) {
|
|
28
|
-
return `'${Base.replace(source, '\'', '\'\'')}'`
|
|
29
|
-
} else {
|
|
30
|
-
return `'${source}'`
|
|
31
|
-
}
|
|
32
|
-
case 'datetime':
|
|
33
|
-
return SqlString.escape(dateFormat(source, 'yyyy-LL-dd HH:mm:ss')) + ':: timestamp'
|
|
34
|
-
case 'date':
|
|
35
|
-
return SqlString.escape(dateFormat(source,'yyyy-LL-dd')) + ':: date'
|
|
36
|
-
case 'time':
|
|
37
|
-
return SqlString.escape(dateFormat(source, 'HH:mm:ss' )) + ':: time'
|
|
38
|
-
default:
|
|
39
|
-
return source
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
async function executeBulkMerge(connection, sql, rows, options) {
|
|
45
|
-
let autoincremental = null
|
|
46
|
-
if (options.autoincrementalData && options.autoincrementalData.pkColumnName) {
|
|
47
|
-
autoincremental = { name: options.autoincrementalData.pkColumnName ,
|
|
48
|
-
alias: options.autoincrementalData.pkColumnAlias,
|
|
49
|
-
sequence: options.autoincrementalData.sequenceName
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const list = []
|
|
54
|
-
for(let i = 0; i < rows.length; i++) {
|
|
55
|
-
const row = rows[i]
|
|
56
|
-
const values = []
|
|
57
|
-
for(let j = 0; j < row.length; j++) {
|
|
58
|
-
const column = options.columns[j]
|
|
59
|
-
const value = getValue(row[j],column.type)
|
|
60
|
-
values.push(value)
|
|
61
|
-
}
|
|
62
|
-
list.push(`(${values.join(',')})`)
|
|
63
|
-
}
|
|
64
|
-
const _sql = []
|
|
65
|
-
_sql.push('INSERT INTO ' + options.rdsTable.tableName.toLowerCase() + ' (')
|
|
66
|
-
if (autoincremental) {
|
|
67
|
-
_sql.push(autoincremental.name.toLowerCase() + ',')
|
|
68
|
-
}
|
|
69
|
-
_sql.push(options.setsFields.join(', ').toLowerCase())
|
|
70
|
-
_sql.push(') SELECT ')
|
|
71
|
-
if (autoincremental) {
|
|
72
|
-
_sql.push('nextval(\''+autoincremental.sequence.toLowerCase()+'\'), ' )
|
|
73
|
-
}
|
|
74
|
-
_sql.push(options.setsFields.join(', ').toLowerCase())
|
|
75
|
-
_sql.push(' FROM (VALUES ')
|
|
76
|
-
_sql.push(list.join(','))
|
|
77
|
-
_sql.push(') AS data(')
|
|
78
|
-
_sql.push(options.setsFields.join(', ').toLowerCase())
|
|
79
|
-
_sql.push(') ON CONFLICT (')
|
|
80
|
-
_sql.push(options.mergeFields.join(', ').toLowerCase())
|
|
81
|
-
_sql.push(') DO UPDATE SET ')
|
|
82
|
-
let first = true
|
|
83
|
-
for( const field of options.setsFields) {
|
|
84
|
-
_sql.push((first? ' ': ', ') + field.toLowerCase() + ' = EXCLUDED.' + field.toLowerCase())
|
|
85
|
-
first = false
|
|
86
|
-
}
|
|
87
|
-
_sql.push(';')
|
|
88
|
-
const query = _sql.join('')
|
|
89
|
-
const result = await connection.query(query);
|
|
90
|
-
return { rowsAffected: result.rowCount };
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
module.exports = executeBulkMerge;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const BlzBase = require('./base');
|
|
3
|
-
/**
|
|
4
|
-
* @param {pg.PoolClient} connection
|
|
5
|
-
* @param {string} sql
|
|
6
|
-
* @param {[{name: string, value}]} [rdsParameters = []]
|
|
7
|
-
* @param {boolean} [withGeneratedKey = false]
|
|
8
|
-
* @return {Promise}
|
|
9
|
-
*/
|
|
10
|
-
async function executeNonQuery(connection, sql, rdsParameters = [], options , withGeneratedKey = false) {
|
|
11
|
-
let result;
|
|
12
|
-
if(!BlzBase.isEmpty(rdsParameters)) {
|
|
13
|
-
const { query, parameters } = BlzBase.convertSqlAndParameters(sql, rdsParameters, options);
|
|
14
|
-
result = await connection.query(query, parameters);
|
|
15
|
-
} else {
|
|
16
|
-
result = await connection.query(sql);
|
|
17
|
-
}
|
|
18
|
-
return {
|
|
19
|
-
rowsAffected: result.rowCount,
|
|
20
|
-
id: BlzBase.scalarOutput(result)
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
module.exports = { executeNonQuery, convertValueToDb: BlzBase.convertValueToDb }
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const Base = require('./base');
|
|
3
|
-
|
|
4
|
-
async function executeQuery(connection, sql, rdsParameters = [], options) {
|
|
5
|
-
if(Base.isEmpty(rdsParameters)) {
|
|
6
|
-
const checked = Base.checkPostgresSQL(sql)
|
|
7
|
-
if (!checked.safe) {
|
|
8
|
-
const err = new Error('Potential SQL injection');
|
|
9
|
-
err.code = 'SQLInjection';
|
|
10
|
-
err.data = checked.reason;
|
|
11
|
-
throw err;
|
|
12
|
-
}
|
|
13
|
-
let data = await connection.query({
|
|
14
|
-
text : sql,
|
|
15
|
-
rowMode : 'array'
|
|
16
|
-
});
|
|
17
|
-
return { data : data.rows }
|
|
18
|
-
} else {
|
|
19
|
-
const { query, parameters } = Base.convertSqlAndParameters(sql, rdsParameters, options);
|
|
20
|
-
const checked = Base.checkPostgresSQL(query)
|
|
21
|
-
if (!checked.safe) {
|
|
22
|
-
const err = new Error('Potential SQL injection');
|
|
23
|
-
err.code = 'SQLInjection';
|
|
24
|
-
err.data = checked.reason;
|
|
25
|
-
throw err;
|
|
26
|
-
}
|
|
27
|
-
let data = await connection.query({
|
|
28
|
-
text : query,
|
|
29
|
-
rowMode : 'array',
|
|
30
|
-
values : parameters
|
|
31
|
-
});
|
|
32
|
-
return {
|
|
33
|
-
data: data.rows
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
module.exports = executeQuery;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
const _ = require("underscore");
|
|
2
|
-
const { executeNonQuery } = require("./execute-non-query");
|
|
3
|
-
const executeBulkInsert = require("./execute-bulk-insert");
|
|
4
|
-
const executeBulkMerge = require("./execute-bulk-merge");
|
|
5
|
-
const executeQuery = require("./execute-query");
|
|
6
|
-
const executeProcedure = require("./stored-procedure");
|
|
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
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function createResultSet() {
|
|
4
|
-
let buffer = [];
|
|
5
|
-
let isFinished = false;
|
|
6
|
-
let pendingResolves = [];
|
|
7
|
-
return {
|
|
8
|
-
getRow() {
|
|
9
|
-
return new Promise((resolve, reject) => {
|
|
10
|
-
if (buffer.length > 0) {
|
|
11
|
-
resolve(buffer.shift());
|
|
12
|
-
} else if (isFinished) {
|
|
13
|
-
resolve(null);
|
|
14
|
-
} else {
|
|
15
|
-
pendingResolves.push(resolve);
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
},
|
|
19
|
-
close() {
|
|
20
|
-
return new Promise((resolve, reject) => {
|
|
21
|
-
if (isFinished) {
|
|
22
|
-
resolve(null);
|
|
23
|
-
} else {
|
|
24
|
-
pendingResolves.push(resolve);
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
},
|
|
28
|
-
addRow(rowObj) {
|
|
29
|
-
if (isFinished) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
let row = rowObj;// convertToArray(queryFields, rowObj);
|
|
33
|
-
if (pendingResolves.length > 0) {
|
|
34
|
-
let resolve = pendingResolves.shift();
|
|
35
|
-
resolve(row);
|
|
36
|
-
} else {
|
|
37
|
-
buffer.push(row);
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
end() {
|
|
41
|
-
isFinished = true;
|
|
42
|
-
if (pendingResolves.length > 0) {
|
|
43
|
-
pendingResolves.forEach(resolve => {
|
|
44
|
-
resolve(null);
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
module.exports = createResultSet;
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const BlzBase = require("./base");
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @typedef {Object} Parameter
|
|
6
|
-
* @property {boolean} isResultSet
|
|
7
|
-
* @property {string} name
|
|
8
|
-
* @property {*} value
|
|
9
|
-
* @property { 'in' | 'out' | 'in/out' } direction
|
|
10
|
-
* @property {'string' | 'integer' | 'decimal' | 'boolean' | 'datetime' | 'date' | 'time' | 'binary'} type
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
*
|
|
15
|
-
* @param {mysqlx.Session} session
|
|
16
|
-
* @param {Parameter} parameter
|
|
17
|
-
* @param {*} result
|
|
18
|
-
*/
|
|
19
|
-
async function parseOutputParameters(session, parameter, result, resultSet, cursors, ordinalParameter) {
|
|
20
|
-
if(parameter.isResultSet) {
|
|
21
|
-
result[parameter.name] = cursors.shift().rows;
|
|
22
|
-
} else {
|
|
23
|
-
let index = ordinalParameter.indexOf(parameter.name);
|
|
24
|
-
if(index == -1) {
|
|
25
|
-
throw BlzBase.error('RdsPosgreSqlIndex', { parameter, result });
|
|
26
|
-
}
|
|
27
|
-
let value = BlzBase.first(resultSet.rows)[index];
|
|
28
|
-
switch (parameter.type) {
|
|
29
|
-
case 'string':
|
|
30
|
-
result[parameter.name] = BlzBase.convertToString(value);
|
|
31
|
-
break;
|
|
32
|
-
case 'integer':
|
|
33
|
-
result[parameter.name] = BlzBase.convertToInteger(value);
|
|
34
|
-
break;
|
|
35
|
-
case 'decimal':
|
|
36
|
-
result[parameter.name] = BlzBase.convertToDecimal(value);
|
|
37
|
-
break;
|
|
38
|
-
case 'boolean':
|
|
39
|
-
result[parameter.name] = BlzBase.convertToBoolean(value);
|
|
40
|
-
break;
|
|
41
|
-
case 'datetime':
|
|
42
|
-
result[parameter.name] = BlzBase.convertToDatetime(value);
|
|
43
|
-
break;
|
|
44
|
-
case 'date':
|
|
45
|
-
result[parameter.name] = BlzBase.convertToDate(value);
|
|
46
|
-
break;
|
|
47
|
-
case 'time':
|
|
48
|
-
result[parameter.name] = BlzBase.convertToTime(value);
|
|
49
|
-
break;
|
|
50
|
-
case 'binary':
|
|
51
|
-
result[parameter.name] = BlzBase.convertToBinary(value);
|
|
52
|
-
break;
|
|
53
|
-
default:
|
|
54
|
-
throw BlzBase.error('RdsMySqlUnexpectedType', { parameter, result, value });
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* @param {mysqlx.Session} session
|
|
60
|
-
* @param {string} procedure
|
|
61
|
-
* @param {[Parameter]} [parameters=[]]
|
|
62
|
-
* @param {number} time_stamp
|
|
63
|
-
* @returns {string}
|
|
64
|
-
*/
|
|
65
|
-
async function parseInputParameters(session, procedure, parameters, list) {
|
|
66
|
-
let procedureParameters = [], timestamp = Date.now();
|
|
67
|
-
for(const parameter of parameters) {
|
|
68
|
-
if(parameter.isResultSet) {
|
|
69
|
-
procedureParameters.push(`FETCH ALL IN ${parameter.name.toLowerCase()}_${timestamp}`);
|
|
70
|
-
}
|
|
71
|
-
if (parameter.direction === 'in') {
|
|
72
|
-
let index = -1;
|
|
73
|
-
while((index = list.indexOf(parameter.name)) != -1) {
|
|
74
|
-
list.splice(index, 1);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
if(parameter.type === 'string' && parameter.value)
|
|
78
|
-
procedure = procedure.replace(`:${parameter.name}`, `'${BlzBase.convertValueToDb(parameter.value, parameter, timestamp)}'`);
|
|
79
|
-
else
|
|
80
|
-
procedure = procedure.replace(`:${parameter.name}`, BlzBase.convertValueToDb(parameter.value, parameter, timestamp));
|
|
81
|
-
}
|
|
82
|
-
procedureParameters.unshift(procedure);
|
|
83
|
-
return procedureParameters.join(";");
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* @param {mysqlx.Session} client
|
|
87
|
-
* @param {string} procedure
|
|
88
|
-
* @param {[Parameter]} [parameters=[]]
|
|
89
|
-
*/
|
|
90
|
-
async function executeProcedure(client, procedure, parameters) {
|
|
91
|
-
let outParameters = {}, sql, resultSet, cursors, [, ordinalParameter ] = /\(([^\(\)]*)\)/mg.exec(procedure);
|
|
92
|
-
if(BlzBase.isArray(parameters)) {
|
|
93
|
-
ordinalParameter = ordinalParameter.replace(/[:\s]*/g, "").split(",");
|
|
94
|
-
sql = await parseInputParameters(client, procedure, parameters, ordinalParameter);
|
|
95
|
-
}
|
|
96
|
-
try {
|
|
97
|
-
resultSet = await client.query({
|
|
98
|
-
text : sql,
|
|
99
|
-
rowMode : 'array'
|
|
100
|
-
});
|
|
101
|
-
} catch (error) {
|
|
102
|
-
throw BlzBase.error('RdsPostgresCannotExecuteProcedure', { client, procedure, parameters }, error);
|
|
103
|
-
}
|
|
104
|
-
if(BlzBase.isArray(resultSet)) {
|
|
105
|
-
[resultSet, ... cursors] = resultSet;
|
|
106
|
-
}
|
|
107
|
-
for(const parameter of parameters) {
|
|
108
|
-
if(parameter.direction == "in") {
|
|
109
|
-
continue;
|
|
110
|
-
}
|
|
111
|
-
await parseOutputParameters(client, parameter, outParameters, resultSet, cursors, ordinalParameter);
|
|
112
|
-
}
|
|
113
|
-
return { outParameters };
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
module.exports = executeProcedure;
|