@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const _=require("underscore"),{executeNonQuery:executeNonQuery}=require("./execute-non-query"),executeQuery=require("./execute-query"),executeProcedure=require("./stored-procedure"),executeBulkInsert=require("./execute-bulk-insert"),executeBulkMerge=require("./execute-bulk-merge"),{beginTransaction:beginTransaction,close:close,commitTransaction:commitTransaction,createConnection:createRdsConnection,rollbackTransaction:rollbackTransaction,terminate:terminate}=require("./connection-manager");process.on("exit",async function(){await terminate()}),module.exports={syntaxis:require("./syntaxis.json"),executeProcedure:executeProcedure,executeSql:async function(e,r,n,t={}){return-1!=r.indexOf("call")?await executeProcedure(e,r,n):_.has(t,"bulkInsert")?await executeBulkInsert(e,r,n,t):_.has(t,"bulkMerge")?await executeBulkMerge(e,r,n,t):_.has(t,"queryOne")||_.has(t,"query")?await executeQuery(e,r,n,t):await executeNonQuery(e,r,n,t)},beginTransaction:beginTransaction,close:close,createRdsConnection:createRdsConnection,commitTransaction:commitTransaction,rollbackTransaction:rollbackTransaction};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export = executeProcedure;
|
|
2
|
+
/**
|
|
3
|
+
* @param {mysqlx.Session} session
|
|
4
|
+
* @param {string} procedure
|
|
5
|
+
* @param {[Parameter]} [parameters=[]]
|
|
6
|
+
*/
|
|
7
|
+
declare function executeProcedure(session: mysqlx.Session, procedure: string, parameters?: [Parameter]): Promise<{
|
|
8
|
+
outParameters: {};
|
|
9
|
+
}>;
|
|
10
|
+
declare namespace executeProcedure {
|
|
11
|
+
export { Parameter };
|
|
12
|
+
}
|
|
13
|
+
import mysqlx = require("@mysql/xdevapi");
|
|
14
|
+
type Parameter = {
|
|
15
|
+
isResultSet: boolean;
|
|
16
|
+
name: string;
|
|
17
|
+
value: any;
|
|
18
|
+
direction: "in" | "out" | "in/out";
|
|
19
|
+
type: "string" | "integer" | "decimal" | "boolean" | "datetime" | "date" | "time" | "binary";
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const mysqlx=require("@mysql/xdevapi"),_=require("underscore"),BlzBase=require("./base"),toString=Object.prototype.toString;function tryDatetime(e){let t=toString.call(e);if("[object Date]"===t)return e;if("[object String]"===t){let t=/^(\d{4})-(\d{1,2})-(\d{1,2})[T,\s](\d{1,2})\:(\d{1,2})\:(\d{1,2})\.?(\d+)?Z?$/.exec(e);if(t)return new Date(Date.UTC(Number(t[1]),Number(t[2])-1,Number(t[3]),Number(t[4]),Number(t[5]),Number(t[6]||0),(r=t[7])?(r.length<3&&(r=r.padEnd(3,"0")),r.length>3&&(r=r.substr(0,3)),Number(r)):0))}var r;return null}function convertValueToDb(e){if(_.isUndefined(e))return null;if(_.isNull(e))return null;if(!0===e)return 1;if(!1===e)return 0;let t=tryDatetime(e);if(t){let e=t.toJSON();return 24===e.length&&(e=e.substring(0,19)),e}return e}async function parseOutputParameters(e,t,r,a){let n=null,s=null;try{n=await e.sql(`SELECT @${t.name}_${a};`).execute()}catch(e){throw BlzBase.error("RdsMysqlCannotConvertParameters",{parameter:t,result:r,time_stamp:a},e)}if([s]=n.fetchOne(),t.isResultSet)r[t.name]=JSON.parse(s);else switch(t.type){case"string":r[t.name]=BlzBase.convertToString(s);break;case"integer":r[t.name]=BlzBase.convertToInteger(s);break;case"decimal":r[t.name]=BlzBase.convertToDecimal(s);break;case"boolean":r[t.name]=BlzBase.convertToBoolean(s);break;case"datetime":r[t.name]=BlzBase.convertToDatetime(s);break;case"date":r[t.name]=BlzBase.convertToDate(s);break;case"time":r[t.name]=BlzBase.convertToTime(s);break;case"binary":r[t.name]=BlzBase.convertToBinary(s);break;default:throw BlzBase.error("RdsMySqlUnexpectedType",{parameter:t,result:r,value:s})}}async function parseInputParameters(e,t,r,a){for(const n of r)switch(n.direction){case"in":case"in/out":try{await e.sql(`SET @${n.name}_${a} = ?;`).bind(convertValueToDb(n.value)).execute()}catch(e){throw BlzBase.error("RdsMySqlInputParameterType",{parameters:r,time_stamp:a})}t=t.replace(`:${n.name}`,`@${n.name}_${a}`);break;case"out":try{await e.sql(`SET @${n.name}_${a} = NULL;`).execute()}catch(e){throw BlzBase.error("RdsMySqlInputParameterType",{parameters:r,time_stamp:a})}t=t.replace(`:${n.name}`,`@${n.name}_${a}`)}return t}async function executeProcedure(e,t,r){const a=Date.now();_.isArray(r)&&(t=await parseInputParameters(e,t,r,a));try{await e.sql(t).execute()}catch(a){throw BlzBase.error("RdsMysqlCannotExecuteProcedure",{session:e,procedure:t,parameters:r},a)}let n={};for(const t of r)"in"!=t.direction&&await parseOutputParameters(e,t,n,a);return{outParameters:n}}module.exports=executeProcedure;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export let syntaxis: any;
|
|
2
|
+
export function createRdsConnection(connection: any): Promise<any>;
|
|
3
|
+
export function executeSql(connection: any, sql: any, parameters: any, options: any): Promise<{
|
|
4
|
+
rowsAffected: any;
|
|
5
|
+
}>;
|
|
6
|
+
export function _executeSql(connection: any, sql: any, parameters: any, options: any): Promise<{
|
|
7
|
+
rowsAffected: any;
|
|
8
|
+
outParameters: {};
|
|
9
|
+
id: any;
|
|
10
|
+
resultSet: any;
|
|
11
|
+
}>;
|
|
12
|
+
export function _executeBulkInsert(connection: any, sql: any, rows: any, options: any): Promise<{
|
|
13
|
+
rowsAffected: any;
|
|
14
|
+
ids: any[];
|
|
15
|
+
} | {
|
|
16
|
+
rowsAffected: any;
|
|
17
|
+
ids?: undefined;
|
|
18
|
+
}>;
|
|
19
|
+
export function _executeBulkMerge(connection: any, sql: any, rows: any, options: any): Promise<{
|
|
20
|
+
rowsAffected: any;
|
|
21
|
+
}>;
|
|
22
|
+
export function close(nativeConnection: any): any;
|
|
23
|
+
export function beginTransaction(nativeConnection: any): void;
|
|
24
|
+
export function commitTransaction(nativeConnection: any): any;
|
|
25
|
+
export function rollbackTransaction(nativeConnection: any): any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const oracledb=require("oracledb"),_=require("underscore"),{h3lp:h3lp}=require("h3lp"),Path=require("path"),Fs=require("fs-extra"),blzBaseSuite=Path.resolve(__dirname,"../blz-core/sources-dual/index.js");let BlzBase=null;BlzBase=Fs.existsSync(blzBaseSuite)?require("../../blz-core/sources-dual/index.js"):require("../blz-core/index.js"),oracledb.fetchAsBuffer=[oracledb.BLOB],oracledb.fetchAsString=[oracledb.CLOB,oracledb.DATE,oracledb.NUMBER];let poolsByName=Object.create(null);const getPool=async function(e){try{if(!e.name)throw new Error("You must provide a connnection name");let t=e.name,a=poolsByName[t];return a||(e.connectString=e.dataSource,(e=_.omit(e,"dataSource","providerName")).sessionCallback=makeInitSessionCallback({schema:e.schema}),process.env.LD_LIBRARY_PATH&&oracledb.initOracleClient({libDir:process.env.LD_LIBRARY_PATH,configDir:"",thin:!1}),a=await oracledb.createPool(e),a.connectionName=e.name,poolsByName[t]=a,a)}catch(t){throw new Error("Oracle cannot create pool for "+e.name+": "+t.message)}},makeInitSessionCallback=({schema:e}={})=>(t,a,n)=>{const r=[["NLS_DATE_FORMAT","'YYYY-MM-DD\"T\"hh24:mi:ss'"],e?["CURRENT_SCHEMA",`${e}`]:void 0].filter(Boolean).map(([e,t])=>`${e}=${t}`).join(" ");t.execute(`ALTER SESSION SET ${r}`,n)},tryDatetime=function(e){let t=toString.call(e);if("[object Date]"===t)return e;if("[object String]"===t){if(/^(\d{4})-(\d{1,2})-(\d{1,2})[T,\s](\d{1,2})\:(\d{1,2})\:(\d{1,2})\.?(\d+)?Z?$/.exec(e)){const t=new Date(e);if("Invalid Date"!==t.toString())return t}}return null},convertMilliseconds=function(e){return e?(e.length<3&&(e=e.padEnd(3,"0")),e.length>3&&(e=e.substr(0,3)),Number(e)):0},convertResultSetToArray=function(e,t){return e.getRow().then(a=>a?(t.push(a),convertResultSetToArray(e,t)):e.close().then(()=>t)).catch(t=>{throw e.close(),BlzBase.error("ErrorFetchingRowsForConnection",{},t)})},getParameterType=function(e){switch(e){case"string":case"VARCHAR":case"VARCHAR2":default:return oracledb.STRING;case"integer":case"decimal":case"boolean":return oracledb.NUMBER;case"datetime":case"date":case"time":return oracledb.DATE;case"binary":return oracledb.BUFFER;case"CLOB":case"BLOB":return oracledb.CLOB}},getOraParameters=function(e,t){let a={};if(e)for(let t=0;t<e.length;t++){let n=e[t],r={};if("in"===n.direction||"in/out"===n.direction)if(void 0===n.value||null===n.value)r.val=null;else if(!0===n.value)r.val=1;else if(!1===n.value)r.val=0;else if(n.columnInfo&&"string"===n.columnInfo.type)r.val=n.value;else{let e=tryDatetime(n.value);r.val=e||n.value}if("in"===n.direction?r.dir=oracledb.BIND_IN:"in/out"===n.direction?r.dir=oracledb.BIND_INOUT:"out"===n.direction&&(r.dir=oracledb.BIND_OUT),n.isResultSet)r.type=oracledb.CURSOR;else{if(n.dbTypes){const e=n.dbTypes.find(e=>"Oracle"===e.providerName);n.dbType=getParameterType(e.dbType)}else n.type?n.dbType=getParameterType(n.type):n.dbType=inferDbTypeFromValue(n.value);r.type=n.dbType}a[n.name]=r}return t&&t.autoincrementalData&&(a.ScalarOutput={val:null,dir:oracledb.BIND_OUT,type:oracledb.NUMBER}),a},getOraOptions=function(e,t){let a={autoCommit:!e.isTransactionRequest};return e&&(e.query||e.queryOne)&&(a.resultSet=!0),t&&(a.bindDefs=t),a},convertValueFromType=async function(e,t){switch(t){case"string":return BlzBase.convertToString(e);case"integer":return BlzBase.convertToInteger(e);case"decimal":return BlzBase.convertToDecimal(e);case"boolean":return BlzBase.convertToBoolean(e);case"datetime":return BlzBase.convertToDatetime(e);case"date":return BlzBase.convertToDate(e);case"time":return BlzBase.convertToTime(e);case"binary":return BlzBase.convertToBinary(e);default:if("DB_TYPE_CLOB"===e._type.name)return await oraResult.outBinds[parameter.name].getData()}},getResult=async function(e,t,a){let n={};if(n.rowsAffected=t.rowsAffected,n.outParameters={},e)for(let a=0;a<e.length;a++){let r=e[a];if("out"===r.direction||"in/out"===r.direction){let e=t.outBinds[r.name];r.isResultSet?e=await convertResultSetToArray(e,[]):e&&"string"==typeof e.type?e=await convertValueFromType(e,e.type):e&&e._type&&"string"==typeof e._type.name&&"DB_TYPE_CLOB"===e._type.name?e=await t.outBinds[r.name].getData():r&&"string"==typeof r.type?e=await convertValueFromType(e,r.type):console.warn("Could not resolve out parameter type"),n.outParameters[r.name]=e}}return a&&a.autoincrementalData&&(n.id=null,t.outBinds&&t.outBinds.ScalarOutput&&(n.id=t.outBinds.ScalarOutput,Array.isArray(n.id)&&(n.id=n.id[0]))),a&&(a.query||a.queryOne)&&(n.resultSet=t.resultSet),n};process.on("exit",async function(){let e=[];for(let t in poolsByName){let a=poolsByName[t];e.push(a.close())}poolsByName=null,await Promise.all(e)});const getValue=function(e,t){switch((t?t.toLowerCase():typeof e).toLowerCase()){case"boolean":return e?1:0;case"string":return"string"==typeof e||null==e?e:e.toString();case"datetime":case"date":case"time":return e?new Date(e):null;default:return e}},inferDbTypeFromValue=function(e){if(null==e)return oracledb.STRING;if(Buffer.isBuffer(e))return getParameterType("binary");switch(typeof e){case"string":default:return getParameterType("string");case"number":return Number.isInteger(e)?getParameterType("integer"):getParameterType("decimal");case"boolean":return getParameterType("boolean");case"object":return e instanceof Date?getParameterType("datetime"):getParameterType("string")}},rowsToArray=function(e,t){const a=[],n=e.length;for(const r of t){const t={};for(let a=0;a<n;a++){const n=e[a],o=r[a];t[n.name]=getValue(o,n.type)}a.push(t)}return a};module.exports={syntaxis:require("./syntaxis.json"),createRdsConnection:async function(e){try{let t=await getPool(e);return await t.getConnection()}catch(e){throw e}},executeSql:async function(e,t,a,n){return _.has(n,"bulkInsert")?await this._executeBulkInsert(e,t,a,n):_.has(n,"bulkMerge")?await this._executeBulkMerge(e,t,a,n):await this._executeSql(e,t,a,n)},_executeSql:async function(e,t,a,n){try{let r=getOraParameters(a,n),o=getOraOptions(n),s=await e.execute(t,r,o);return await getResult(a,s,n)}catch(e){throw e}},_executeBulkInsert:async function(e,t,a,n){let r=null;n.autoincrementalData&&n.autoincrementalData.pkColumnName&&(r={name:n.autoincrementalData.pkColumnName,alias:n.autoincrementalData.pkColumnAlias,sequence:n.autoincrementalData.sequenceName,type:n.autoincrementalData.pkColumnType});const o=r?"INSERT INTO "+n.rdsTable.tableName+" ("+r.name+","+n.setsFields.join(", ")+") VALUES ( "+r.sequence+".NEXTVAL, "+n.setsFields.map(e=>":"+e).join(", ")+" ) RETURNING "+r.name+" INTO :"+r.name:t+"("+n.setsFields.map(e=>":"+e).join(", ")+" ) ",s=n.columns.length;for(let e=0;e<s;e++){const t=n.columns[e];"string"===t.type&&(t.size=a.reduce((t,a)=>a[e]?a[e].length>t?a[e].length:t:0,0))}const c={};for(const e of n.columns){const t={type:getDbType(e.type)};"string"===e.type&&(t.maxSize=e.size),c[e.name]=t}r&&(c[r.name]={type:getDbType(r.type),dir:oracledb.BIND_OUT});const l=getOraOptions(n,c),i=rowsToArray(n.columns,a);try{const t=await e.executeMany(o,i,l);if(r){const e=[];for(const a in t.outBinds)e.push(t.outBinds[a][r.name][0]);return{rowsAffected:t.rowsAffected,ids:e}}return{rowsAffected:t.rowsAffected}}catch(e){throw console.log(e),e}},_executeBulkMerge:async function(e,t,a,n){let r=null;n.autoincrementalData&&n.autoincrementalData.pkColumnName&&(r={name:n.autoincrementalData.pkColumnName,alias:n.autoincrementalData.pkColumnAlias,sequence:n.autoincrementalData.sequenceName,type:n.autoincrementalData.pkColumnType});const o=[];o.push("MERGE INTO "+n.rdsTable.tableName+" t USING ("),o.push("SELECT ");let s=!0;for(const e of n.columns)o.push((s?"":", ")+":"+e.name+" AS "+e.name),s=!1;o.push("FROM DUAL"),o.push(") s ON ("),s=!0;for(const e of n.mergeFields)o.push((s?"":" AND ")+"t."+e+" = s."+e),s=!1;o.push(")"),o.push("WHEN MATCHED THEN UPDATE SET "),s=!0;for(const e of n.columns)n.mergeFields.includes(e.name)||(o.push((s?"":",")+"t."+e.name+" = s."+e.name),s=!1);if(o.push("WHEN NOT MATCHED THEN INSERT ("),r){o.push(r.name);for(const e of n.columns)o.push(","+e.name);o.push(") VALUES ("),o.push(r.sequence+".NEXTVAL");for(const e of n.columns)o.push(",s."+e.name)}else{s=!0;for(const e of n.columns)o.push((s?"":",")+e.name),s=!1;o.push(") VALUES ("),s=!0;for(const e of n.columns)o.push((s?"":",")+"s."+e.name),s=!1}o.push(")");const c=o.join(" "),l=n.columns.length;for(let e=0;e<l;e++){const t=n.columns[e];"string"===t.type&&(t.size=a.reduce((t,a)=>a[e]?a[e].length>t?a[e].length:t:0,0))}const i={};for(const e of n.columns){const t={type:getDbType(e.type)};"string"===e.type&&(t.maxSize=e.size),i[e.name]=t}const u=getOraOptions(n,i),m=rowsToArray(n.columns,a);try{return{rowsAffected:(await e.executeMany(c,m,u)).rowsAffected}}catch(e){throw console.log(e),e}},close:e=>e.close(),beginTransaction(e){},commitTransaction:e=>e.commit(),rollbackTransaction:e=>e.rollback()};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
export function isArray(value: any): value is any[];
|
|
2
|
+
export function first(array: any): any;
|
|
3
|
+
export function isEmpty(value: any): boolean;
|
|
4
|
+
export function scalarOutput(rs: any): any;
|
|
5
|
+
export function convertValueToDb(value: any): any;
|
|
6
|
+
export function replace(string: any, search: any, replace: any): any;
|
|
7
|
+
export function error(code: any, data: any, innerError?: Error): Error;
|
|
8
|
+
export function convertSqlAndParameters(sql: any, rdsParameters: any, options: any): {
|
|
9
|
+
query: any;
|
|
10
|
+
parameters: any[];
|
|
11
|
+
};
|
|
12
|
+
export function errorUndefinedArgument(argName: any): Error;
|
|
13
|
+
export function tryString(value: any): any;
|
|
14
|
+
export function tryInteger(value: any): any;
|
|
15
|
+
export function tryDecimal(value: any): any;
|
|
16
|
+
export function tryBoolean(value: any): any;
|
|
17
|
+
export function tryDatetime(value: any): any;
|
|
18
|
+
export function tryDate(value: any): any;
|
|
19
|
+
export function tryTime(value: any): any;
|
|
20
|
+
export function tryBinary(value: any): Buffer;
|
|
21
|
+
export function tryObject(value: any): any;
|
|
22
|
+
export function tryArray(value: any): any;
|
|
23
|
+
export function ensureString(value: any): any;
|
|
24
|
+
export function ensureInteger(value: any): any;
|
|
25
|
+
export function ensureDecimal(value: any): any;
|
|
26
|
+
export function ensureBoolean(value: any): any;
|
|
27
|
+
export function ensureDatetime(value: any): any;
|
|
28
|
+
export function ensureDate(value: any): any;
|
|
29
|
+
export function ensureTime(value: any): any;
|
|
30
|
+
export function ensureBinary(value: any): Buffer;
|
|
31
|
+
export function ensureObject(value: any): any;
|
|
32
|
+
export function ensureArray(value: any): any;
|
|
33
|
+
export function convertToString(value: any): any;
|
|
34
|
+
export function convertToInteger(value: any): any;
|
|
35
|
+
export function convertToDecimal(value: any): any;
|
|
36
|
+
export function convertToBoolean(value: any): any;
|
|
37
|
+
export function convertToDatetime(value: any): any;
|
|
38
|
+
export function convertToDate(value: any): any;
|
|
39
|
+
export function convertToTime(value: any): any;
|
|
40
|
+
export function convertToBinary(value: any): Buffer;
|
|
41
|
+
export function convertToListOfStrings(value: any): any[];
|
|
42
|
+
export function convertToListOfIntegers(value: any): any[];
|
|
43
|
+
export function convertToListOfDecimals(value: any): any[];
|
|
44
|
+
export function convertToListOfBooleans(value: any): any[];
|
|
45
|
+
export function convertToListOfDatetimes(value: any): any[];
|
|
46
|
+
export function convertToListOfDates(value: any): any[];
|
|
47
|
+
export function convertToListOfTimes(value: any): any[];
|
|
48
|
+
export function convertToListOfBinaries(value: any): Buffer[];
|
|
49
|
+
export function httpCall(httpRequest: any): Promise<any>;
|
|
50
|
+
export function isNotNull(value: any): boolean;
|
|
51
|
+
export function isNull(value: any): boolean;
|
|
52
|
+
export function isNullOrValue(value: any, valueToCompare: any): boolean;
|
|
53
|
+
export function nvl(value: any, replacementValue: any): any;
|
|
54
|
+
export function get(objOrTuple: any, codePathOrIndex: any): any;
|
|
55
|
+
export function and(value1: any, value2: any): any;
|
|
56
|
+
export function or(value1: any, value2: any): any;
|
|
57
|
+
export function not(value: any): boolean;
|
|
58
|
+
export function compare(value1: any, value2: any): any;
|
|
59
|
+
export function equals(value1: any, value2: any): boolean;
|
|
60
|
+
export function notEquals(value1: any, value2: any): boolean;
|
|
61
|
+
export function greater(value1: any, value2: any): boolean;
|
|
62
|
+
export function less(value1: any, value2: any): boolean;
|
|
63
|
+
export function greaterOrEqual(value1: any, value2: any): boolean;
|
|
64
|
+
export function lessOrEqual(value1: any, value2: any): boolean;
|
|
65
|
+
export function concat(value1: any, value2: any): any;
|
|
66
|
+
export function add(value1: any, value2: any): any;
|
|
67
|
+
export function subtract(value1: any, value2: any): any;
|
|
68
|
+
export function multiply(value1: any, value2: any): number;
|
|
69
|
+
export function divide(value1: any, value2: any): number;
|
|
70
|
+
export function remainder(value1: any, value2: any): number;
|
|
71
|
+
export function lessUnary(value: any): number;
|
|
72
|
+
export function datetimeAdd(value1: any, value2: any): any;
|
|
73
|
+
export function datetimeDiff(value1: any, value2: any): any;
|
|
74
|
+
export function dateAdd(value1: any, value2: any): any;
|
|
75
|
+
export function dateDiff(value1: any, value2: any): any;
|
|
76
|
+
export function timeAdd(value1: any, value2: any): any;
|
|
77
|
+
export function timeDiff(value1: any, value2: any): any;
|
|
78
|
+
export function jsonParse(value: any): any;
|
|
79
|
+
export function jsonStringify(value: any, spaces: any): string;
|
|
80
|
+
export function base64Decode(value: any): Buffer;
|
|
81
|
+
export function base64Encode(value: any): string;
|
|
82
|
+
export function apply(obj1: any, obj2: any): {};
|
|
83
|
+
export function stringFormat(...args: any[]): any;
|
|
84
|
+
export function loadResource(name: any): Promise<any>;
|
|
85
|
+
export function existsPath(sourcePath: any): Promise<any>;
|
|
86
|
+
export function resolvePath(source: any): any;
|
|
87
|
+
export function readFile(filePath: any): Promise<any>;
|
|
88
|
+
export function checkPostgresSQL(sql: any): {
|
|
89
|
+
safe: boolean;
|
|
90
|
+
reason?: undefined;
|
|
91
|
+
} | {
|
|
92
|
+
safe: boolean;
|
|
93
|
+
reason: string;
|
|
94
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const toString=Object.prototype.toString,dayjs=require("dayjs"),utc=require("dayjs/plugin/utc"),_=require("underscore"),scalarProperty=_.property(["scalaroutput"]),Fs=require("fs-extra"),pgsql_ast_parser=require("pgsql-ast-parser");dayjs.extend(utc),module.exports={isArray:function(t){return _.isArray(t)},first:function(t){return _.first(t)},isEmpty:function(t){return _.isEmpty(t)},scalarOutput:function(t){return scalarProperty(_.first(t.rows))},convertValueToDb:function(t){if(_.isUndefined(t))return null;if(_.isNull(t))return null;if(!0===t)return 1;if(!1===t)return 0;let e=this.tryDatetime(t);return e?"1970-01-01"===dayjs(e).utc().format("YYYY-MM-DD")?dayjs(e).utc().format("HH:mm:ss"):e:t},replace:function(t,e,r){return t.split(e).join(r)},error:function(t,e,r=new Error("UndefinedError")){let n=new Error(`${t} ${r.message}`);return n.code=t,n.data=e,n.innerError=r,n},convertSqlAndParameters:function(t,e,r){let n=t;for(let t=e.length;t>0;t--){let{name:r}=e[t-1];n=this.replace(n,`:${r}`,`$${t}`)}const i=[];for(let t=0,r=e.length;r>t;t++){let{name:r,value:n}=e[t];const l=this.convertValueToDb(n);i.push(l)}return{query:n,parameters:i}},errorUndefinedArgument:function(t){return this.error("UndefinedArgument",{argName:t})},tryString:function(t){return"[object String]"===toString.call(t)?t:null},tryInteger:function(t){return"[object Number]"===toString.call(t)&&t===parseInt(t)?t:null},tryDecimal:function(t){return"[object Number]"===toString.call(t)?t:null},tryBoolean:function(t){return"[object Boolean]"===toString.call(t)?t:null},tryDatetime:function(t){let e=toString.call(t);if("[object Date]"===e)return t;if("[object String]"===e){if(/^(\d{4})-(\d{1,2})-(\d{1,2})[T,\s](\d{1,2})\:(\d{1,2})\:(\d{1,2})\.?(\d+)?Z?$/.exec(t)){const e=new Date(t);if("Invalid Date"!==e.toString())return e}}return null},tryDate:function(t){let e=toString.call(t);if("[object Date]"===e)return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),0,0,0,0));if("[object String]"===e){let e=/^(\d{4})-(\d{1,2})-(\d{1,2})$/.exec(t);if(e&&void 0!==e[3])return new Date(Date.UTC(Number(e[1]),Number(e[2])-1,Number(e[3]),0,0,0,0));if("Invalid Date"!==new Date(t).toString())return datetime.toISOString().split("T")[0]}return null},tryTime:function(t){let e=toString.call(t);if("[object Date]"===e)return new Date(Date.UTC(1970,0,1,t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds(),t.getUTCMilliseconds()));if("[object String]"===e){let e=/^(\d{1,2})\:(\d{1,2})\:(\d{1,2})\.?(\d+)?$/.exec(t);if(e&&void 0!==e[3])return new Date(Date.UTC(1970,0,1,Number(e[1]),Number(e[2]),Number(e[3]),(r=e[4])?(r.length<3&&(r=r.padEnd(3,"0")),r.length>3&&(r=r.substr(0,3)),Number(r)):0));if("Invalid Date"!==new Date(t).toString())return datetime.toISOString().split("T")[1]}var r;return null},tryBinary:function(t){return Buffer.isBuffer(t)?t:Array.isArray(t)?Buffer.from(t):null},tryObject:function(t){return"[object Object]"===toString.call(t)?t:null},tryArray:function(t){return"[object Array]"===toString.call(t)?t:null},ensureString:function(t){let e=this.tryString(t);if(null!==e)return e;throw this.error("UnexpectedType",{value:t,expectedType:"string"})},ensureInteger:function(t){let e=this.tryInteger(t);if(null!==e)return e;throw this.error("UnexpectedType",{value:t,expectedType:"integer"})},ensureDecimal:function(t){let e=this.tryDecimal(t);if(null!==e)return e;throw this.error("UnexpectedType",{value:t,expectedType:"decimal"})},ensureBoolean:function(t){let e=this.tryBoolean(t);if(null!==e)return e;throw this.error("UnexpectedType",{value:t,expectedType:"boolean"})},ensureDatetime:function(t){let e=this.tryDatetime(t);if(null!==e)return e;throw this.error("UnexpectedType",{value:t,expectedType:"datetime"})},ensureDate:function(t){let e=this.tryDate(t);if(null!==e)return e;throw this.error("UnexpectedType",{value:t,expectedType:"date"})},ensureTime:function(t){let e=this.tryTime(t);if(null!==e)return e;throw this.error("UnexpectedType",{value:t,expectedType:"time"})},ensureBinary:function(t){let e=this.tryBinary(t);if(null!==e)return e;throw this.error("UnexpectedType",{value:t,expectedType:"binary"})},ensureObject:function(t){let e=this.tryObject(t);if(null!==e)return array;throw this.error("UnexpectedType",{value:e,expectedType:"object"})},ensureArray:function(t){let e=this.tryArray(t);if(null!==e)return e;throw this.error("UnexpectedType",{value:t,expectedType:"array"})},convertToString:function(t){if(null===t)return null;let e=this.tryString(t);if(null!==e)return e;let r=this.tryInteger(t);if(null!==r)return r.toString();let n=this.tryDecimal(t);if(null!==n)return n.toString();let i=this.tryBoolean(t);if(null!==i)return i?"true":"false";let l=this.tryDatetime(t);if(null!==l)return l.toJSON();throw this.error("InvalidConversion",{value:t,targetType:"string"})},convertToInteger:function(t){if(null===t)return null;let e=this.tryInteger(t);if(null!==e)return e;let r=this.tryString(t);if(null!==r&&!isNaN(r))return Math.round(Number(r));let n=this.tryDecimal(t);if(null!==n)return Math.round(n);let i=this.tryBoolean(t);if(null!==i)return i?1:0;throw this.error("InvalidConversion",{value:t,targetType:"integer"})},convertToDecimal:function(t){if(null===t)return null;let e=this.tryDecimal(t);if(null!==e)return e;let r=this.tryString(t);if(null!==r&&!isNaN(r))return Number(r);let n=this.tryInteger(t);if(null!==n)return n;let i=this.tryBoolean(t);if(null!==i)return i?1:0;throw this.error("InvalidConversion",{value:t,targetType:"decimal"})},convertToBoolean:function(t){if(null===t)return null;let e=this.tryBoolean(t);if(null!==e)return e;let r=this.tryString(t);if(null!==r&&("1"===r||"T"===r.toUpperCase()||"TRUE"===r.toUpperCase()||"Y"===r.toUpperCase()||"YES"===r.toUpperCase()))return!0;if(null!==r&&("0"===r||"F"===r.toUpperCase()||"FALSE"===r.toUpperCase()||"N"===r.toUpperCase()||"NO"===r.toUpperCase()))return!1;let n=this.tryInteger(t);if(null!==n&&1===n)return!0;if(null!==n&&0===n)return!1;throw this.error("InvalidConversion",{value:t,targetType:"boolean"})},convertToDatetime:function(t){if(null===t)return null;let e=this.tryDatetime(t);if(null!==e)return e;throw this.error("InvalidConversion",{value:t,targetType:"datetime"})},convertToDate:function(t){if(null===t)return null;let e=this.tryDate(t);if(null!==e)return e;let r=this.tryDatetime(t);if(null!==r)return new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate(),0,0,0,0));throw this.error("InvalidConversion",{value:t,targetType:"date"})},convertToTime:function(t){if(null===t)return null;let e=this.tryTime(t);if(null!==e)return e;let r=this.tryDatetime(t);if(null!==r)return new Date(Date.UTC(1970,0,1,r.getUTCHours(),r.getUTCMinutes(),r.getUTCSeconds(),r.getUTCMilliseconds()));throw this.error("InvalidConversion",{value:t,targetType:"time"})},convertToBinary:function(t){if(null==t)return null;let e=this.tryBinary(t);if(null!==e)return e;throw this.error("InvalidConversion",{value:t,targetType:"binary"})},convertToListOfStrings:function(t){if(Array.isArray(t)){let e=[];for(let r=0;r<t.length;r++)e.push(this.convertToString(t[r]));return e}return[this.convertToString(t)]},convertToListOfIntegers:function(t){if(Array.isArray(t)){let e=[];for(let r=0;r<t.length;r++)e.push(this.convertToInteger(t[r]));return e}return[this.convertToInteger(t)]},convertToListOfDecimals:function(t){if(Array.isArray(t)){let e=[];for(let r=0;r<t.length;r++)e.push(this.convertToDecimal(t[r]));return e}return[this.convertToDecimal(t)]},convertToListOfBooleans:function(t){if(Array.isArray(t)){let e=[];for(let r=0;r<t.length;r++)e.push(this.convertToBoolean(t[r]));return e}return[this.convertToBoolean(t)]},convertToListOfDatetimes:function(t){if(Array.isArray(t)){let e=[];for(let r=0;r<t.length;r++)e.push(this.convertToDatetime(t[r]));return e}return[this.convertToDatetime(t)]},convertToListOfDates:function(t){if(Array.isArray(t)){let e=[];for(let r=0;r<t.length;r++)e.push(this.convertToDate(t[r]));return e}return[this.convertToDate(t)]},convertToListOfTimes:function(t){if(Array.isArray(t)){let e=[];for(let r=0;r<t.length;r++)e.push(this.convertToTime(t[r]));return e}return[this.convertToTime(t)]},convertToListOfBinaries:function(t){if(Array.isArray(t)){let e=[];for(let r=0;r<t.length;r++)e.push(this.convertToBinary(t[r]));return e}return[this.convertToBinary(t)]},httpCall:function(t){return new Promise(function(e,r){let n={method:t.method?t.method.toLowerCase():"get",headers:{},body:t.body};if(t.headers)for(let e=0;e<t.headers.length;e++){let r=t.headers[e];n.headers[r.name]=r.value}})},isNotNull:function(t){return null!==t},isNull:function(t){return null===t},isNullOrValue:function(t,e){return null===t||0===this.compare(t,e)},nvl:function(t,e){return null!==t?t:e},get:function(t,e){if(null===t)return null;{let r=this.tryObject(t);if(r){let t=e.indexOf(".");return-1===t?void 0!==r[e]?r[e]:null:this.get(r[e.substring(0,t)],e.substring(t+1,e.length))}if("[object Error]"===toString.call(t)){let r=t,n=e.indexOf(".");return-1===n?void 0!==r[e]?r[e]:null:this.get(r[e.substring(0,n)],e.substring(n+1,e.length))}let n=this.tryArray(t);return n?n[e]:null}},and:function(t,e){return this.ensureBoolean(t)&&this.ensureBoolean(e)},or:function(t,e){return this.ensureBoolean(t)||this.ensureBoolean(e)},not:function(t){return!this.ensureBoolean(t)},compare:function(t,e){let r=function(t,e){return t===e?0:t<e?-1:t>e?1:null};if(null===t&&null===e)return 0;if(null===t&&null!==e)return-1;if(null!==t&&null===e)return 1;let n=this.tryString(t),i=this.tryString(e);if(null!==n&&null!==i)return r(n,i);let l=this.tryDecimal(t),u=this.tryDecimal(e);if(null!==l&&null!==u)return r(l,u);let o=this.tryBoolean(t),s=this.tryBoolean(e);if(null!==o&&null!==s)return r(o,s);let a=this.tryDatetime(t),f=this.tryDatetime(e);if(null!==a&&null!==f)return r(a.toJSON(),f.toJSON());let c=this.tryDate(t),h=this.tryDate(e);if(null!==c&&null!==h)return r(c.toJSON(),h.toJSON());let y=this.tryTime(t),g=this.tryTime(e);if(null!==y&&null!==g)return r(y.toJSON(),g.toJSON());let d=this.tryArray(t),m=this.tryArray(e);if(null!==d&&null!==m){let t;if(t=r(d.length,m.length),0!==t)return t;for(let e=0;e<d.length;e++)if(0===t){let r=d[e],n=m[e];t=this.compare(r,n)}return t}let p=this.tryBinary(t),T=this.tryBinary(e);if(null!==p&&null!==T)return Buffer.compare(p,T);let v=this.tryObject(t),D=this.tryObject(e);return null!==v&&null!==D?r(JSON.stringify(v),JSON.stringify(D)):null},equals:function(t,e){return 0===this.compare(t,e)},notEquals:function(t,e){return 0!==this.compare(t,e)},greater:function(t,e){return this.compare(t,e)>0},less:function(t,e){return this.compare(t,e)<0},greaterOrEqual:function(t,e){return this.compare(t,e)>=0},lessOrEqual:function(t,e){return this.compare(t,e)<=0},concat:function(t,e){if(null===t)return e;if(null===e)return t;return this.ensureString(t)+this.ensureString(e)},add:function(t,e){if(null===t)return e;if(null===e)return t;let r=this.tryInteger(t),n=this.tryInteger(e);return null!==r&&null!==n?r+n:this.ensureDecimal(t)+this.ensureDecimal(e)},subtract:function(t,e){if(null===t)return null;if(null===e)return t;let r=this.tryInteger(t),n=this.tryInteger(e);return null!==r&&null!==n?r-n:this.ensureDecimal(t)-this.ensureDecimal(e)},multiply:function(t,e){if(null===t)return null;if(null===e)return null;let r=this.tryInteger(t),n=this.tryInteger(e);return null!==r&&null!==n?r*n:this.ensureDecimal(t)*this.ensureDecimal(e)},divide:function(t,e){if(null===t)return null;let r=this.ensureDecimal(t),n=this.ensureDecimal(e);if(0===n)throw this.error("DivisionByZero");return r/n},remainder:function(t,e){if(null===t)return null;let r=this.ensureDecimal(t),n=this.ensureDecimal(e);if(0===n)throw this.error("DivisionByZero");return r%n},lessUnary:function(t){if(null===t)return null;let e=this.tryInteger(t);return null!==e?-e:-this.ensureDecimal(t)},datetimeAdd:function(t,e){if(null===t)return null;if(null===e)return t;let r=this.ensureDatetime(t),n=this.ensureInteger(e);return new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate(),r.getUTCHours(),r.getUTCMinutes(),r.getUTCSeconds(),r.getUTCMilliseconds()+n))},datetimeDiff:function(t,e){if(null===t)return null;if(null===e)return t;return this.ensureDatetime(t)-this.ensureDatetime(e)},dateAdd:function(t,e){if(null===t)return null;if(null===e)return t;let r=this.ensureDate(t),n=this.ensureInteger(e);return new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate()+n,0,0,0,0))},dateDiff:function(t,e){if(null===t)return null;if(null===e)return t;return(this.ensureDate(t)-this.ensureDate(e))/864e5},timeAdd:function(t,e){if(null===t)return null;if(null===e)return t;let r=this.ensureTime(t),n=this.ensureInteger(e);return new Date(Date.UTC(1970,0,1,r.getUTCHours(),r.getUTCMinutes(),r.getUTCSeconds(),r.getUTCMilliseconds()+n))},timeDiff:function(t,e){if(null===t)return null;if(null===e)return t;return this.ensureTime(t)-this.ensureTime(e)},jsonParse:function(t){if(void 0===t)throw this.errorUndefinedArgument("value");if(null===t)return null;return JSON.parse(this.ensureString(t))},jsonStringify:function(t,e){if(void 0===t)throw this.errorUndefinedArgument("value");if(null===t)return null;if(null==e){return JSON.stringify(t)}{let r=this.ensureInteger(e);return JSON.stringify(t,null,r)}},base64Decode:function(t){if(void 0===t)throw this.errorUndefinedArgument("value");if(null===t)return null;let e=this.ensureString(t);return Buffer.from(e,"base64")},base64Encode:function(t){if(void 0===t)throw this.errorUndefinedArgument("value");if(null===t)return null;let e=this.ensureBinary(t);return Buffer.from(e).toString("base64")},apply:function(t,e){let r={};if(null===t)return null;let n=this.tryObject(t);if(null===n)throw fnError("InvalidObject",{value:t});for(let t in n)r[t]=n[t];if(null!==e){let t=this.tryObject(e);if(null===t)throw fnError("InvalidObject",{value:e});for(let e in t)r[e]=t[e]}return r},stringFormat:function(){if(0===arguments.length)return null;if(1===arguments.length)return arguments[0];{let t=arguments[0];for(let e=1;e<arguments.length;e++)t=t.split("%"+e+"$s").join(arguments[e]);return t}},loadResource:function(t){return Promise.resolve().then(function(){if(-1===t.indexOf("."))return require("../resources/main/"+t+".json");{let e=t.split(".");return require("../resources/edges/"+e[0]+"/"+e[1]+".json")}})},existsPath:async function(t){const e=this.resolvePath(t);return new Promise(t=>{Fs.access(e,e=>{t(!e)})})},resolvePath:function(t){const e=t.trim();return e.startsWith(".")?Path.join(process.cwd(),t):e.startsWith("~")?e.replace("~",process.env.HOME):t},readFile:async function(t){const e=this.resolvePath(t);return await this.existsPath(e)?new Promise((t,r)=>{Fs.readFile(e,(e,n)=>e?r(e):t(n.toString("utf8")))}):null},checkPostgresSQL:function(t){try{pgsql_ast_parser.parse(t);return{safe:!0}}catch(t){return{safe:!1,reason:`PostgreSQL parser error: ${t.message}`}}}};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export function beginTransaction(connection: any): Promise<void>;
|
|
2
|
+
export function close(connection: any): Promise<void>;
|
|
3
|
+
export function commitTransaction(connection: any): Promise<void>;
|
|
4
|
+
export function createConnection(config: any): Promise<any>;
|
|
5
|
+
export function rollbackTransaction(connection: any): Promise<void>;
|
|
6
|
+
export function terminate(): Promise<boolean>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const pg=require("pg"),types=require("pg").types,BlzBase=require("./base"),_=require("underscore"),dayjs=require("dayjs");types.setTypeParser(types.builtins.TIMESTAMPTZ,e=>(isUtcOffset(e)&&(e=dayjs(e).format("YYYY-MM-DDTHH:mm:ss")),e)),types.setTypeParser(types.builtins.DATE,e=>dayjs(e).format("YYYY-MM-DDTHH:mm:ss")),types.setTypeParser(types.builtins.TIMESTAMP,e=>dayjs(e).format("YYYY-MM-DDTHH:mm:ss"));let poolsByName=new Map;function getURI(e){let t=["postgresql://"];return e.user&&(t.push(e.user),e.password&&t.push(`:${e.password}`),t.push("@")),e.host&&t.push(e.host),e.port&&t.push(`:${e.port}`),e.database&&t.push(`/${e.database}`),t.join("")}function getCustomURI(e){if(e.url){let t=e.url.indexOf("?schema=");if(-1===t&&(t=e.url.indexOf("&schema=")),t>-1){let s=e.url.indexOf("&",t+1),n=null;n=-1===s?e.url.substring(t+1):e.url.substring(t+1,s);let r=n.split("=");2===r.length&&(e.schema=r[1])}}return`postgresql://${e.url}`}function getParameters(e={}){return _.reduce(e.properties,(e,t)=>e+","+("statementTimeout"===t.key?"statement_timeout":t.key)+"="+t.value,"").slice("1")}function getObjectConfig(e={}){if(!e.name)throw BlzBase.error("RdsPostgresException",{name:e.name});return e.customUrl?getCustomURI(e):getURI(e)}function getConnectionString(e={}){let t=[getObjectConfig(e)],s=getParameters(e);return _.isEmpty(s)||t.push(`?${s}`),t.join("")}async function getPool(e={}){let t,s=e.name,n=poolsByName.get(s);if(n)return n;let r=getConnectionString(e);if(t=_.pick(e,"max","min","connectionTimeoutMillis","idleTimeoutMillis","keepAlive","parseInputDatesAsUTC","ssl","keepAliveInitialDelayMillis"),e.queryTimeout&&(t.query_timeout=e.queryTimeout),e.idleInTransactionSessionTimeout&&(t.idle_in_transaction_session_timeout=e.idleInTransactionSessionTimeout),t.connectionString=r,e.ssl){let s={require:!0,rejectUnauthorized:!1};e.sslCertPath&&(s.cert=await BlzBase.readFile(e.sslCertPath)),e.sslKeyPath&&(s.key=await BlzBase.readFile(e.sslKeyPath)),e.sslPemPath&&(s.ca=await BlzBase.readFile(e.sslPemPath)),t.ssl=s}try{n=new pg.Pool(t),e.schema&&n.on("connect",t=>{let s=`SET search_path TO ${e.schema}`;t.query(s)})}catch(t){throw BlzBase.error("RdsPostgresCannotCreatePool",{config:e,uri:uri},t)}return n.name=e.name,poolsByName.set(s,n),n}async function getConnection(e){let t;try{t=await e.connect()}catch(t){throw BlzBase.error("RdsPostgresCannotConnectToDatabase",{name:e.name},t)}return t.name=e.name,t}async function terminate(){let e=[];for(const[,t]of poolsByName)try{await t.end()}catch(t){e.push(t)}if(poolsByName.clear(),_.isEmpty(e))return!0;throw new Error(e)}const createConnection=async e=>await getConnection(await getPool(e)),beginTransaction=async function(e){try{await e.query("BEGIN")}catch(t){throw BlzBase.error("RdsPostgresBeginTransactionError",{name:e.name},t)}},commitTransaction=async function(e){try{await e.query("COMMIT")}catch(t){throw BlzBase.error("RdsPostgresCommitTransactionError",{name:e.name},t)}},rollbackTransaction=async function(e){try{await e.query("ROLLBACK")}catch(t){throw BlzBase.error("RdsPostgresRollbackTransactionError",{name:e.name},t)}},close=async function(e){try{await e.release(!0)}catch(t){throw BlzBase.error("RdsPostgresCloseError",{name:e.name},t)}};function isUtcOffset(e){if(_.isNull(e)||_.isUndefined(e)||!_.isString(e))return!1;const t=e.match(/^(.*)([+-])(\d{2})?:?(\d{2})$/);return!_.isNull(t)&&(!_.isUndefined(t[3])&&"00"!==t[3]||!_.isUndefined(t[4])&&"00"!==t[4])}module.exports={beginTransaction:beginTransaction,close:close,commitTransaction:commitTransaction,createConnection:createConnection,rollbackTransaction:rollbackTransaction,terminate:terminate};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const SqlString=require("sqlstring"),{DateTime:DateTime}=require("luxon"),Base=require("./base"),dateFormat=function(e,t){const a=new Date(e).toISOString();return"ISO"===t?DateTime.fromISO(a).toISO():DateTime.fromISO(a).toFormat(t)},getValue=function(e,t){if(null==e||void 0===e)return"null";switch(t?t.toLowerCase():typeof e){case"boolean":return e?"true":"false";case"string":return e.includes("'")?`'${Base.replace(e,"'","''")}'`:`'${e}'`;case"datetime":return SqlString.escape(dateFormat(e,"yyyy-LL-dd HH:mm:ss"));case"date":return SqlString.escape(dateFormat(e,"yyyy-LL-dd"));case"time":return SqlString.escape(dateFormat(e,"HH:mm:ss"));default:return e}};async function executeBulkInsert(e,t,a,n){let r=null;n.autoincrementalData&&n.autoincrementalData.pkColumnName&&(r={name:n.autoincrementalData.pkColumnName,alias:n.autoincrementalData.pkColumnAlias,sequence:n.autoincrementalData.sequenceName});const s=[];for(let e=0;e<a.length;e++){const t=a[e],o=[];r&&o.push("nextval('"+r.sequence+"')");for(const e of n.columns){const a=getValue(t[e.alias],e.type);o.push(a)}s.push(`(${o.join(",")})`)}const o=r?"INSERT INTO "+n.rdsTable.tableName+" ("+r.name+","+n.setsFields.join(", ")+") VALUES ":t,u=r?"RETURNING "+r.name+' AS "'+r.alias+'"':"",l=`${o} ${s.join(",")} ${u};`,i=await e.query(l),c=[];if(r)for(const e in i.rows){const t=i.rows[e][r.alias];c.push(t)}return{rowsAffected:i.rowCount,ids:c}}module.exports=executeBulkInsert;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const SqlString=require("sqlstring"),{DateTime:DateTime}=require("luxon"),Base=require("./base"),dateFormat=function(e,t){const a=new Date(e).toISOString();return"ISO"===t?DateTime.fromISO(a).toISO():DateTime.fromISO(a).toFormat(t)},getValue=function(e,t){if(null==e||void 0===e)return"null";switch(t?t.toLowerCase():typeof e){case"boolean":return e?"true":"false";case"string":return e.includes("'")?`'${Base.replace(e,"'","''")}'`:`'${e}'`;case"datetime":return SqlString.escape(dateFormat(e,"yyyy-LL-dd HH:mm:ss"))+":: timestamp";case"date":return SqlString.escape(dateFormat(e,"yyyy-LL-dd"))+":: date";case"time":return SqlString.escape(dateFormat(e,"HH:mm:ss"))+":: time";default:return e}};async function executeBulkMerge(e,t,a,s){let o=null;s.autoincrementalData&&s.autoincrementalData.pkColumnName&&(o={name:s.autoincrementalData.pkColumnName,alias:s.autoincrementalData.pkColumnAlias,sequence:s.autoincrementalData.sequenceName});const n=[];for(let e=0;e<a.length;e++){const t=a[e],o=[];for(let e=0;e<t.length;e++){const a=s.columns[e],n=getValue(t[e],a.type);o.push(n)}n.push(`(${o.join(",")})`)}const r=[];r.push("INSERT INTO "+s.rdsTable.tableName.toLowerCase()+" ("),o&&r.push(o.name.toLowerCase()+","),r.push(s.setsFields.join(", ").toLowerCase()),r.push(") SELECT "),o&&r.push("nextval('"+o.sequence.toLowerCase()+"'), "),r.push(s.setsFields.join(", ").toLowerCase()),r.push(" FROM (VALUES "),r.push(n.join(",")),r.push(") AS data("),r.push(s.setsFields.join(", ").toLowerCase()),r.push(") ON CONFLICT ("),r.push(s.mergeFields.join(", ").toLowerCase()),r.push(") DO UPDATE SET ");let u=!0;for(const e of s.setsFields)r.push((u?" ":", ")+e.toLowerCase()+" = EXCLUDED."+e.toLowerCase()),u=!1;r.push(";");const l=r.join("");return{rowsAffected:(await e.query(l)).rowCount}}module.exports=executeBulkMerge;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {pg.PoolClient} connection
|
|
3
|
+
* @param {string} sql
|
|
4
|
+
* @param {[{name: string, value}]} [rdsParameters = []]
|
|
5
|
+
* @param {boolean} [withGeneratedKey = false]
|
|
6
|
+
* @return {Promise}
|
|
7
|
+
*/
|
|
8
|
+
export function executeNonQuery(connection: pg.PoolClient, sql: string, rdsParameters?: [{
|
|
9
|
+
name: string;
|
|
10
|
+
value: any;
|
|
11
|
+
}], options: any, withGeneratedKey?: boolean): Promise<any>;
|
|
12
|
+
export declare let convertValueToDb: (value: any) => any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const BlzBase=require("./base");async function executeNonQuery(e,t,r=[],a,u=!1){let s;if(BlzBase.isEmpty(r))s=await e.query(t);else{const{query:u,parameters:o}=BlzBase.convertSqlAndParameters(t,r,a);s=await e.query(u,o)}return{rowsAffected:s.rowCount,id:BlzBase.scalarOutput(s)}}module.exports={executeNonQuery:executeNonQuery,convertValueToDb:BlzBase.convertValueToDb};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const Base=require("./base");async function executeQuery(e,t,r=[],a){if(Base.isEmpty(r)){const r=Base.checkPostgresSQL(t);if(!r.safe){const e=new Error("Potential SQL injection");throw e.code="SQLInjection",e.data=r.reason,e}return{data:(await e.query({text:t,rowMode:"array"})).rows}}{const{query:o,parameters:s}=Base.convertSqlAndParameters(t,r,a),n=Base.checkPostgresSQL(o);if(!n.safe){const e=new Error("Potential SQL injection");throw e.code="SQLInjection",e.data=n.reason,e}return{data:(await e.query({text:o,rowMode:"array",values:s})).rows}}}module.exports=executeQuery;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import executeProcedure = require("./stored-procedure");
|
|
2
|
+
import { beginTransaction } from "./connection-manager";
|
|
3
|
+
import { close } from "./connection-manager";
|
|
4
|
+
import { createConnection as createRdsConnection } from "./connection-manager";
|
|
5
|
+
import { commitTransaction } from "./connection-manager";
|
|
6
|
+
import { rollbackTransaction } from "./connection-manager";
|
|
7
|
+
export declare let syntaxis: any;
|
|
8
|
+
export declare function executeSql(connection: any, sql: any, parameters: any, options?: {}): Promise<any>;
|
|
9
|
+
export { executeProcedure, beginTransaction, close, createRdsConnection, commitTransaction, rollbackTransaction };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const _=require("underscore"),{executeNonQuery:executeNonQuery}=require("./execute-non-query"),executeBulkInsert=require("./execute-bulk-insert"),executeBulkMerge=require("./execute-bulk-merge"),executeQuery=require("./execute-query"),executeProcedure=require("./stored-procedure"),{beginTransaction:beginTransaction,close:close,commitTransaction:commitTransaction,createConnection:createRdsConnection,rollbackTransaction:rollbackTransaction,terminate:terminate}=require("./connection-manager");process.on("exit",async function(){await terminate()}),module.exports={syntaxis:require("./syntaxis.json"),executeProcedure:executeProcedure,executeSql:async function(e,r,n,t={}){return-1!=r.indexOf("call")?await executeProcedure(e,r,n):_.has(t,"bulkInsert")?await executeBulkInsert(e,r,n,t):_.has(t,"bulkMerge")?await executeBulkMerge(e,r,n,t):_.has(t,"queryOne")||_.has(t,"query")?await executeQuery(e,r,n,t):await executeNonQuery(e,r,n,t)},beginTransaction:beginTransaction,close:close,createRdsConnection:createRdsConnection,commitTransaction:commitTransaction,rollbackTransaction:rollbackTransaction};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function createResultSet(){let e=[],t=!1,l=[];return{getRow:()=>new Promise((s,n)=>{e.length>0?s(e.shift()):t?s(null):l.push(s)}),close:()=>new Promise((e,s)=>{t?e(null):l.push(e)}),addRow(s){if(t)return;let n=s;if(l.length>0){l.shift()(n)}else e.push(n)},end(){t=!0,l.length>0&&l.forEach(e=>{e(null)})}}}module.exports=createResultSet;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export = executeProcedure;
|
|
2
|
+
/**
|
|
3
|
+
* @param {mysqlx.Session} client
|
|
4
|
+
* @param {string} procedure
|
|
5
|
+
* @param {[Parameter]} [parameters=[]]
|
|
6
|
+
*/
|
|
7
|
+
declare function executeProcedure(client: mysqlx.Session, procedure: string, parameters?: [Parameter]): Promise<{
|
|
8
|
+
outParameters: {};
|
|
9
|
+
}>;
|
|
10
|
+
declare namespace executeProcedure {
|
|
11
|
+
export { Parameter };
|
|
12
|
+
}
|
|
13
|
+
type Parameter = {
|
|
14
|
+
isResultSet: boolean;
|
|
15
|
+
name: string;
|
|
16
|
+
value: any;
|
|
17
|
+
direction: "in" | "out" | "in/out";
|
|
18
|
+
type: "string" | "integer" | "decimal" | "boolean" | "datetime" | "date" | "time" | "binary";
|
|
19
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const BlzBase=require("./base");async function parseOutputParameters(e,a,r,t,s,n){if(a.isResultSet)r[a.name]=s.shift().rows;else{let e=n.indexOf(a.name);if(-1==e)throw BlzBase.error("RdsPosgreSqlIndex",{parameter:a,result:r});let s=BlzBase.first(t.rows)[e];switch(a.type){case"string":r[a.name]=BlzBase.convertToString(s);break;case"integer":r[a.name]=BlzBase.convertToInteger(s);break;case"decimal":r[a.name]=BlzBase.convertToDecimal(s);break;case"boolean":r[a.name]=BlzBase.convertToBoolean(s);break;case"datetime":r[a.name]=BlzBase.convertToDatetime(s);break;case"date":r[a.name]=BlzBase.convertToDate(s);break;case"time":r[a.name]=BlzBase.convertToTime(s);break;case"binary":r[a.name]=BlzBase.convertToBinary(s);break;default:throw BlzBase.error("RdsMySqlUnexpectedType",{parameter:a,result:r,value:s})}}}async function parseInputParameters(e,a,r,t){let s=[],n=Date.now();for(const e of r){if(e.isResultSet&&s.push(`FETCH ALL IN ${e.name.toLowerCase()}_${n}`),"in"===e.direction){let a=-1;for(;-1!=(a=t.indexOf(e.name));)t.splice(a,1)}a="string"===e.type&&e.value?a.replace(`:${e.name}`,`'${BlzBase.convertValueToDb(e.value,e,n)}'`):a.replace(`:${e.name}`,BlzBase.convertValueToDb(e.value,e,n))}return s.unshift(a),s.join(";")}async function executeProcedure(e,a,r){let t,s,n,o={},[,c]=/\(([^\(\)]*)\)/gm.exec(a);BlzBase.isArray(r)&&(c=c.replace(/[:\s]*/g,"").split(","),t=await parseInputParameters(e,a,r,c));try{s=await e.query({text:t,rowMode:"array"})}catch(t){throw BlzBase.error("RdsPostgresCannotExecuteProcedure",{client:e,procedure:a,parameters:r},t)}BlzBase.isArray(s)&&([s,...n]=s);for(const a of r)"in"!=a.direction&&await parseOutputParameters(e,a,o,s,n,c);return{outParameters:o}}module.exports=executeProcedure;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export function redisGet(connection: any, key: any): any;
|
|
2
|
+
export function redisMget(connection: any, keys: any): any;
|
|
3
|
+
export function redisSet(connection: any, key: any, value: any): any;
|
|
4
|
+
export function redisSetex(connection: any, key: any, ttl: any, value: any): any;
|
|
5
|
+
export function redisMset(connection: any, data: any): any;
|
|
6
|
+
export function redisDel(connection: any, key: any): any;
|
|
7
|
+
export function redisExpire(connection: any, key: any, ttl: any): any;
|
|
8
|
+
export function redisTtl(connection: any, key: any): any;
|
|
9
|
+
export function redisExists(connection: any, key: any): any;
|
|
10
|
+
export function redisKeys(connection: any, pattern: any): any;
|
|
11
|
+
export function redisDbsize(connection: any): any;
|
|
12
|
+
export function redisHget(connection: any, key: any, field: any): any;
|
|
13
|
+
export function redisHmget(connection: any, key: any, fields: any): any;
|
|
14
|
+
export function redisHset(connection: any, key: any, field: any, value: any): any;
|
|
15
|
+
export function redisHmset(connection: any, key: any, data: any): any;
|
|
16
|
+
export function redisHdel(connection: any, key: any, field: any): any;
|
|
17
|
+
export function redisHexists(connection: any, key: any, field: any): any;
|
|
18
|
+
export function redisHkeys(connection: any, key: any): any;
|
|
19
|
+
export function redisHvals(connection: any, key: any): any;
|
|
20
|
+
export function redisHgetall(connection: any, key: any): any;
|
|
21
|
+
export function redisHlen(connection: any, key: any): any;
|
|
22
|
+
export function redisLindex(connection: any, key: any, index: any): any;
|
|
23
|
+
export function redisLpop(connection: any, key: any, count: any): any;
|
|
24
|
+
export function redisRpop(connection: any, key: any, count: any): any;
|
|
25
|
+
export function redisLset(connection: any, key: any, index: any, element: any): any;
|
|
26
|
+
export function redisLpush(connection: any, key: any, element: any): any;
|
|
27
|
+
export function redisRpush(connection: any, key: any, element: any): any;
|
|
28
|
+
export function redisLlen(connection: any, key: any): any;
|
|
29
|
+
export function redisFlushdb(connection: any): any;
|
|
30
|
+
export function redisFlushall(connection: any): any;
|
|
31
|
+
export function redisPing(connection: any): any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const redisCache=require("./lib/redisCache.js"),fs=require("fs-extra");let redisClients={};function getOrCreateRedisClient(e){let t=redisClients[e.name];if(t)return t;let n={connectionName:e.name,connectionOptions:{autoPipelining:!0},clusterMode:e.clusterMode,nodes:ensureNodes(e.nodes),pool:!0,poolMin:e.poolMin,poolMax:e.poolMax,poolKeepAlive:e.poolKeepAlive,poolAcquireTimeout:e.poolAcquireTimeout,poolRetryDelay:e.poolRetryDelay};return null!=e.host&&(n.connectionOptions.host=e.host),null!=e.port&&(n.connectionOptions.port=e.port),null!=e.db&&(n.connectionOptions.db=e.db),e.tls&&(n.connectionOptions.tls={},e.key&&(n.connectionOptions.tls.key=fs.readFileSync(e.key)),e.cert&&(n.connectionOptions.tls.cert=fs.readFileSync(e.cert)),e.ca&&(n.connectionOptions.tls.ca=fs.readFileSync(e.ca)),e.servername&&(n.connectionOptions.tls.servername=e.servername),e.rejectUnauthorized||(n.connectionOptions.tls.rejectUnauthorized=!1)),null!=e.user&&(n.connectionOptions.username=e.user),null!=e.password&&(n.connectionOptions.password=e.password),t=redisCache.createRedisClient(n),redisClients[e.name]=t,t}function ensureNodes(e){if(e&&!Array.isArray(e)&&"string"==typeof e){let e=e.split(",");const t=[];for(let n=0;n<e.length;n++){const n={};let r=e.split("@");if(r.length>1){let e=r[0].split(":");e.length>1&&(n.username=e[0]),n.password=n.username?e[1]:e[0]}let i=r.length>1?r[1].split(":"):r[0].split(":");n.host=i[0],n.port=i[1],t.push(n)}return t}return e}module.exports={redisGet:function(e,t){return getOrCreateRedisClient(e).get(t)},redisMget:function(e,t){return getOrCreateRedisClient(e).mget(t)},redisSet:function(e,t,n){return getOrCreateRedisClient(e).set(t,n)},redisSetex:function(e,t,n,r){return getOrCreateRedisClient(e).setex(t,n,r)},redisMset:function(e,t){return getOrCreateRedisClient(e).mset(t)},redisDel:function(e,t){return getOrCreateRedisClient(e).del(t)},redisExpire:function(e,t,n){return getOrCreateRedisClient(e).expire(t,n)},redisTtl:function(e,t){return getOrCreateRedisClient(e).ttl(t)},redisExists:function(e,t){return getOrCreateRedisClient(e).exists(t)},redisKeys:function(e,t){return getOrCreateRedisClient(e).keys(t)},redisDbsize:function(e){return getOrCreateRedisClient(e).dbsize()},redisHget:function(e,t,n){return getOrCreateRedisClient(e).hget(t,n)},redisHmget:function(e,t,n){return getOrCreateRedisClient(e).hmget(t,n)},redisHset:function(e,t,n,r){return getOrCreateRedisClient(e).hset(t,n,r)},redisHmset:function(e,t,n){return getOrCreateRedisClient(e).hmset(t,n)},redisHdel:function(e,t,n){return getOrCreateRedisClient(e).hdel(t,n)},redisHexists:function(e,t,n){return getOrCreateRedisClient(e).hexists(t,n)},redisHkeys:function(e,t){return getOrCreateRedisClient(e).hkeys(t)},redisHvals:function(e,t){return getOrCreateRedisClient(e).hvals(t)},redisHgetall:function(e,t){return getOrCreateRedisClient(e).hgetall(t)},redisHlen:function(e,t){return getOrCreateRedisClient(e).hlen(t)},redisLindex:function(e,t,n){return getOrCreateRedisClient(e).lindex(t,n)},redisLpop:function(e,t,n){return getOrCreateRedisClient(e).lpop(t,n)},redisRpop:function(e,t,n){return getOrCreateRedisClient(e).rpop(t,n)},redisLset:function(e,t,n,r){return getOrCreateRedisClient(e).lset(t,n,r)},redisLpush:function(e,t,n){return getOrCreateRedisClient(e).lpush(t,n)},redisRpush:function(e,t,n){return getOrCreateRedisClient(e).rpush(t,n)},redisLlen:function(e,t){return getOrCreateRedisClient(e).llen(t)},redisFlushdb:function(e){return getOrCreateRedisClient(e).flushdb()},redisFlushall:function(e){return getOrCreateRedisClient(e).flushall()},redisPing:function(e){return getOrCreateRedisClient(e).ping()}};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export function createRedisClient(config: any): {
|
|
2
|
+
get: (key: any) => Promise<any>;
|
|
3
|
+
mget: (keys: any) => Promise<any>;
|
|
4
|
+
set: (key: any, value: any) => Promise<any>;
|
|
5
|
+
setex: (key: any, ttl: any, value: any) => Promise<any>;
|
|
6
|
+
mset: (data: any) => Promise<any>;
|
|
7
|
+
del: (key: any) => Promise<any>;
|
|
8
|
+
expire: (key: any, ttl: any) => Promise<any>;
|
|
9
|
+
ttl: (key: any) => Promise<any>;
|
|
10
|
+
exists: (key: any) => Promise<any>;
|
|
11
|
+
keys: (pattern: any) => Promise<any>;
|
|
12
|
+
dbsize: () => Promise<any>;
|
|
13
|
+
hget: (key: any, field: any) => Promise<any>;
|
|
14
|
+
hmget: (key: any, fields: any) => Promise<any>;
|
|
15
|
+
hset: (key: any, field: any, value: any) => Promise<any>;
|
|
16
|
+
hmset: (key: any, data: any) => Promise<any>;
|
|
17
|
+
hdel: (key: any, field: any) => Promise<any>;
|
|
18
|
+
hexists: (key: any, field: any) => Promise<any>;
|
|
19
|
+
hkeys: (key: any) => Promise<any>;
|
|
20
|
+
hvals: (key: any) => Promise<any>;
|
|
21
|
+
hgetall: (key: any) => Promise<any>;
|
|
22
|
+
hlen: (key: any) => Promise<any>;
|
|
23
|
+
lindex: (key: any, index: any) => Promise<any>;
|
|
24
|
+
lpop: (key: any, count: any) => Promise<any>;
|
|
25
|
+
rpop: (key: any, count: any) => Promise<any>;
|
|
26
|
+
lset: (key: any, index: any, element: any) => Promise<any>;
|
|
27
|
+
lpush: (key: any, element: any) => Promise<any>;
|
|
28
|
+
rpush: (key: any, element: any) => Promise<any>;
|
|
29
|
+
llen: (key: any) => Promise<any>;
|
|
30
|
+
flushdb: () => Promise<void>;
|
|
31
|
+
flushall: () => Promise<void>;
|
|
32
|
+
ping: () => Promise<boolean>;
|
|
33
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const Redis=require("ioredis"),genericPool=require("generic-pool");let poolsByName={};function createRedisClient(e){return{get:function(n){return send(e,"get",n)},mget:function(n){return send(e,"mget",n)},set:function(n,t){return send(e,"set",n,t)},setex:function(n,t,o){return send(e,"setex",n,t,o)},mset:function(n){return send(e,"mset",n)},del:function(n){return send(e,"del",n)},expire:function(n,t){return send(e,"expire",n,t)},ttl:function(n){return send(e,"ttl",n)},exists:function(n){return send(e,"exists",n)},keys:function(n){return send(e,"keys",n)},dbsize:function(){return send(e,"dbsize")},hget:function(n,t){return send(e,"hget",n,t)},hmget:function(n,t){return send(e,"hmget",n,t)},hset:function(n,t,o){return send(e,"hset",n,t,o)},hmset:function(n,t){return send(e,"hmset",n,t)},hdel:function(n,t){return send(e,"hdel",n,t)},hexists:function(n,t){return send(e,"hexists",n,t)},hkeys:function(n){return send(e,"hkeys",n)},hvals:function(n){return send(e,"hvals",n)},hgetall:function(n){return send(e,"hgetall",n)},hlen:function(n){return send(e,"hlen",n)},lindex:function(n,t){return send(e,"lindex",n,t)},lpop:function(n,t){return t?send(e,"lpop",n,t):send(e,"lpop",n)},rpop:function(n,t){return t?send(e,"rpop",n,t):send(e,"rpop",n)},lset:function(n,t,o){return send(e,"lset",n,t,o)},lpush:function(n,t){return send(e,"lpush",n,t)},rpush:function(n,t){return send(e,"rpush",n,t)},llen:function(n){return send(e,"llen",n)},flushdb:async function(){send(e,"flushdb")},flushall:async function(){send(e,"flushall")},ping:async function(){return await send(e,"ping"),!0}}}async function getConnection(e){if(!e.pool)return createConnection(e);try{return await getPool(e).acquire()}catch(n){throw error("RedisPoolAcquireError",{connectionName:e.connectionName},n)}}function createConnection(e){return new Promise(function(n,t){e.connectionOptions.retryStrategy=function(e){return null};let o=e.clusterMode?new Redis.Cluster(e.nodes,{redisOptions:e.connectionOptions}):new Redis(e.connectionOptions);o.pool=e.pool,o.connectionName=e.connectionName,o.on("error",n=>{o.active=!1,t(error("RedisConnectionError",{connectionName:e.connectionName},n))}),o.on("close",()=>{o.active=!1}),o.on("ready",()=>{o.active=!0,n(o)})})}async function send(e,n,...t){let o=null;try{return o=await getConnection(e),await executeCommand(o,n,...t)}catch(e){throw error("RedisError",null,e)}finally{o&&closeConnection(o)}}function executeCommand(e,n,...t){return e[n](...t)}function closeConnection(e){return e.pool?getPool({connectionName:e.connectionName}).release(e):destroyConnection(e)}function destroyConnection(e){return e.disconnect(),e.active=!1,Promise.resolve()}function checkConnection(e){e.ping().catch(n=>{e.active=!1})}function scheduleKeepAliveRun(e,n){e.pool&&(e.scheduledKeepAlive=setTimeout(()=>{checkConnection(e),scheduleKeepAliveRun(e,n)},n))}function descheduleKeepAliveRun(e){e.scheduledKeepAlive&&clearTimeout(e.scheduledKeepAlive),e.scheduledKeepAlive=null}function getPool(e){let n=e.connectionName,t=poolsByName[n];if(t)return t;{const o={create:async function(){try{const n=await createConnection(e);return scheduleKeepAliveRun(n,e.poolKeepAlive),n}catch(n){return await new Promise(function(t,o){setTimeout(()=>{o(n)},e.poolRetryDelay)})}},destroy:async function(e){return await destroyConnection(e),descheduleKeepAliveRun(e),!0},validate:function(e){return Promise.resolve(e.active)}},r={max:e.poolMax,min:e.poolMin,testOnBorrow:!0,acquireTimeoutMillis:e.poolAcquireTimeout||1e4};return t=genericPool.createPool(o,r),t.connectionName=e.connectionName,poolsByName[n]=t,t}}function error(e,n,t){let o=new Error;return o.code=e,n&&(o.data=n),t&&(o.innerError=t),o}module.exports={createRedisClient:createRedisClient};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports={regexReplace:function(e,n,l){return null==e?null:null==n||null==l?e:e.replace(new RegExp(n,"g"),l)},regexSearch:function(e,n){return null==e||null==n?-1:e.search(new RegExp(n,"g"))},regexTest:function(e,n){return null!=e&&(null!=n&&new RegExp(n,"g").test(e))}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const{h3lp:h3lp}=require("h3lp"),Yaml=require("js-yaml"),path=require("path"),AuthorizationService=require("../authorizationService"),_=require("underscore"),logger=require("pino")();let authorizationService=null,config=null;describe("Permission Service",()=>{beforeAll(async()=>{authorizationService=new AuthorizationService(_,logger);const e=await h3lp.fs.read(path.join(__dirname,"/Security.yaml")),t=await Yaml.loadAll(e);config=authorizationService.importSecurityConfig(t[0])}),test("Permissions by Guest",()=>{const e=config.roles.find(e=>"Guest"===e.name).permissions.join(",");expect("guestAccounts,guestMenu,guestView,guestActions").toStrictEqual(e)}),test("Permissions by User",()=>{const e=config.roles.find(e=>"User"===e.name).permissions.join(",");expect("userAccounts,userMenu,userView,userActions,roleView,guestAccounts,guestMenu,guestView,guestActions").toStrictEqual(e)}),test("Permissions by Admin",()=>{const e=config.roles.find(e=>"Admin"===e.name).permissions.join(",");expect("adminAccounts,adminMenu,adminView,adminActions,roleEdit,userAccounts,userMenu,userView,userActions,roleView,guestAccounts,guestMenu,guestView,guestActions").toStrictEqual(e)}),test("authorized by Guest",()=>{expect(!1).toStrictEqual(authorizationService.checkAuthorize("/api/service/account","*",["Guest"])),expect(!1).toStrictEqual(authorizationService.checkAuthorize("/api/service/account/21","*",["Guest"])),expect(!1).toStrictEqual(authorizationService.checkAuthorize("/api/service/account/22","*",["Guest"])),expect(!0).toStrictEqual(authorizationService.checkAuthorize("/menu-security/guest","",["Guest"])),expect(!1).toStrictEqual(authorizationService.checkAuthorize("/menu-security/user","",["Guest"])),expect(!1).toStrictEqual(authorizationService.checkAuthorize("/menu-security/admin","",["Guest"]))}),test("authorized by User",()=>{expect(!0).toStrictEqual(authorizationService.checkAuthorize("/api/service/account","*",["User"])),expect(!0).toStrictEqual(authorizationService.checkAuthorize("/api/service/account/21","*",["User"])),expect(!1).toStrictEqual(authorizationService.checkAuthorize("/api/service/account/22","*",["User"])),expect(!0).toStrictEqual(authorizationService.checkAuthorize("/menu-security/guest","",["User"])),expect(!0).toStrictEqual(authorizationService.checkAuthorize("/menu-security/user","",["User"])),expect(!1).toStrictEqual(authorizationService.checkAuthorize("/menu-security/admin","",["User"]))}),test("authorized by Admin",()=>{expect(!0).toStrictEqual(authorizationService.checkAuthorize("/api/service/account","*",["Admin"])),expect(!0).toStrictEqual(authorizationService.checkAuthorize("/api/service/account/21","*",["Admin"])),expect(!0).toStrictEqual(authorizationService.checkAuthorize("/api/service/account/22","*",["Admin"])),expect(!0).toStrictEqual(authorizationService.checkAuthorize("/menu-security/guest","",["Admin"])),expect(!0).toStrictEqual(authorizationService.checkAuthorize("/menu-security/user","",["Admin"])),expect(!0).toStrictEqual(authorizationService.checkAuthorize("/menu-security/admin","",["Admin"]))}),test("authorized by Guest and User",()=>{expect(!0).toStrictEqual(authorizationService.checkAuthorize("/api/service/account","*",["Guest","User"])),expect(!0).toStrictEqual(authorizationService.checkAuthorize("/api/service/account/21","*",["Guest","User"])),expect(!1).toStrictEqual(authorizationService.checkAuthorize("/api/service/account/22","*",["Guest","User"]))}),test("authorized by User and Admin",()=>{expect(!0).toStrictEqual(authorizationService.checkAuthorize("/api/service/account","*",["User","Admin"])),expect(!0).toStrictEqual(authorizationService.checkAuthorize("/api/service/account/21","*",["User","Admin"])),expect(!0).toStrictEqual(authorizationService.checkAuthorize("/api/service/account/22","*",["User","Admin"]))}),test("Role access to Guest",()=>{expect(!1).toStrictEqual(authorizationService.checkAuthorize("/roles","",["Guest"])),expect(!1).toStrictEqual(authorizationService.checkAuthorize("/roles","View",["Guest"])),expect(!1).toStrictEqual(authorizationService.checkAuthorize("/roles","Add",["Guest"])),expect(!1).toStrictEqual(authorizationService.checkAuthorize("/roles","Edit",["Guest"])),expect(!1).toStrictEqual(authorizationService.checkAuthorize("/roles","Remove",["Guest"])),expect(!1).toStrictEqual(authorizationService.checkAuthorize("/api/service/roles","GET",["Guest"])),expect(!1).toStrictEqual(authorizationService.checkAuthorize("/api/service/roles/merged","POST",["Guest"])),expect(!1).toStrictEqual(authorizationService.checkAuthorize("/api/service/role/1","GET",["Guest"])),expect(!1).toStrictEqual(authorizationService.checkAuthorize("/api/service/role/1","DELETE",["Guest"])),expect(!1).toStrictEqual(authorizationService.checkAuthorize("/api/service/role/1","PATCH",["Guest"]))}),test("Role access to User",()=>{expect(!0).toStrictEqual(authorizationService.checkAuthorize("/roles","",["User"])),expect(!0).toStrictEqual(authorizationService.checkAuthorize("/roles","View",["User"])),expect(!1).toStrictEqual(authorizationService.checkAuthorize("/roles","Add",["User"])),expect(!1).toStrictEqual(authorizationService.checkAuthorize("/roles","Edit",["User"])),expect(!1).toStrictEqual(authorizationService.checkAuthorize("/roles","Remove",["User"])),expect(!0).toStrictEqual(authorizationService.checkAuthorize("/api/service/roles","GET",["User"])),expect(!1).toStrictEqual(authorizationService.checkAuthorize("/api/service/roles/merged","POST",["User"])),expect(!0).toStrictEqual(authorizationService.checkAuthorize("/api/service/role/1","GET",["User"])),expect(!1).toStrictEqual(authorizationService.checkAuthorize("/api/service/role/1","DELETE",["User"])),expect(!1).toStrictEqual(authorizationService.checkAuthorize("/api/service/role/1","PATCH",["User"]))}),test("Role access to Admin",()=>{expect(!0).toStrictEqual(authorizationService.checkAuthorize("/roles","",["Admin"])),expect(!0).toStrictEqual(authorizationService.checkAuthorize("/roles","View",["Admin"])),expect(!0).toStrictEqual(authorizationService.checkAuthorize("/roles","Add",["Admin"])),expect(!0).toStrictEqual(authorizationService.checkAuthorize("/roles","Edit",["Admin"])),expect(!0).toStrictEqual(authorizationService.checkAuthorize("/roles","Remove",["Admin"])),expect(!0).toStrictEqual(authorizationService.checkAuthorize("/api/service/roles","GET",["Admin"])),expect(!0).toStrictEqual(authorizationService.checkAuthorize("/api/service/roles/merged","POST",["Admin"])),expect(!0).toStrictEqual(authorizationService.checkAuthorize("/api/service/role/1","GET",["Admin"])),expect(!0).toStrictEqual(authorizationService.checkAuthorize("/api/service/role/1","DELETE",["Admin"])),expect(!0).toStrictEqual(authorizationService.checkAuthorize("/api/service/role/1","PATCH",["Admin"]))})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const{h3lp:h3lp}=require("h3lp"),Yaml=require("js-yaml"),path=require("path"),AuthorizationService=require("../authorizationService"),_=require("underscore"),logger=require("pino")();let authorizationService=null,config=null;describe("Permission Service",()=>{beforeAll(async()=>{authorizationService=new AuthorizationService(_,logger);const i=await h3lp.fs.read(path.join(__dirname,"/AuthorizationKpn.yaml")),e=await Yaml.loadAll(i);config=authorizationService.importSecurityConfig(e[0])}),test("Permissions by Configuration.Admin",()=>{expect(!0).toStrictEqual(authorizationService.checkAuthorize("/ep-manual-credit/undefined",null,["Configuration.Admin"],["agent"])),expect(!0).toStrictEqual(authorizationService.checkAuthorize("/ep-manual-credit/",null,["Configuration.Admin"],["agent"])),expect(!0).toStrictEqual(authorizationService.checkAuthorize("/ep-manual-debit/undefined",null,["Configuration.Admin"],["agent"])),expect(!0).toStrictEqual(authorizationService.checkAuthorize("/ep-manual-debit/",null,["Configuration.Admin"],["agent"])),expect(!0).toStrictEqual(authorizationService.checkAuthorize("/ep-out-manual-credit/undefined",null,["Configuration.Admin"],["agent"])),expect(!0).toStrictEqual(authorizationService.checkAuthorize("/ep-out-manual-credit/",null,["Configuration.Admin"],["agent"])),expect(!0).toStrictEqual(authorizationService.checkAuthorize("/ep-out-manual-debit/undefined",null,["Configuration.Admin"],["agent"])),expect(!0).toStrictEqual(authorizationService.checkAuthorize("/ep-out-manual-debit/",null,["Configuration.Admin"],["agent"]))}),test("Permissions by Collections.Admin, Collections.Finance, Configuration.Admin",()=>{expect(!0).toStrictEqual(authorizationService.checkAuthorize("/ep-manual-credit/undefined",null,["Collections.Admin","Collections.Finance","Configuration.Admin"],["agent"])),expect(!0).toStrictEqual(authorizationService.checkAuthorize("/ep-manual-credit/",null,["Collections.Admin","Collections.Finance","Configuration.Admin"],["agent"])),expect(!0).toStrictEqual(authorizationService.checkAuthorize("/ep-manual-debit/undefined",null,["Collections.Admin","Collections.Finance","Configuration.Admin"],["agent"])),expect(!0).toStrictEqual(authorizationService.checkAuthorize("/ep-manual-debit/",null,["Collections.Admin","Collections.Finance","Configuration.Admin"],["agent"])),expect(!0).toStrictEqual(authorizationService.checkAuthorize("/ep-out-manual-credit/undefined",null,["Collections.Admin","Collections.Finance","Configuration.Admin"],["agent"])),expect(!0).toStrictEqual(authorizationService.checkAuthorize("/ep-out-manual-credit/",null,["Collections.Admin","Collections.Finance","Configuration.Admin"],["agent"])),expect(!0).toStrictEqual(authorizationService.checkAuthorize("/ep-out-manual-debit/undefined",null,["Collections.Admin","Collections.Finance","Configuration.Admin"],["agent"])),expect(!0).toStrictEqual(authorizationService.checkAuthorize("/ep-out-manual-debit/",null,["Collections.Admin","Collections.Finance","Configuration.Admin"],["agent"]))})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const{h3lp:h3lp}=require("h3lp"),Yaml=require("js-yaml"),path=require("path"),AuthorizationService=require("../authorizationService"),_=require("underscore"),logger=require("pino")();let authorizationService=null;describe("Permission Service",()=>{beforeAll(async()=>{authorizationService=new AuthorizationService(_,logger);const e=await h3lp.fs.read(path.join(__dirname,"/OrderManagement.yaml")),i=await Yaml.loadAll(e);config=authorizationService.importSecurityConfig(i[0])}),test("Paths with query parameters",()=>{expect(!1).toStrictEqual(authorizationService.checkAuthorize("/api/ext-common-business/businessDomains","GET",["OMUserMenu"])),expect(!1).toStrictEqual(authorizationService.checkAuthorize("/api/ext-common-business/businessDomains?offset=0&limit=1","GET",["OMUserMenu"])),expect(!0).toStrictEqual(authorizationService.checkAuthorize("/api/ext-common-business/businessDomains","delete",["OMUserMenu"])),expect(!0).toStrictEqual(authorizationService.checkAuthorize("/api/ext-common-business/businessDomains?offset=0&limit=1","DELETE",["OMUserMenu"]))})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const SecureUrlService=require("../secureUrlService"),logger=require("pino")();let secureUrlService=null;describe("SecureUrlService",()=>{beforeAll(async()=>{secureUrlService=new SecureUrlService(logger)}),test("Front path",()=>{const e="N2ZkZGY4NmItYzVmYi00ZDFkLWI0OGEtMTY1MmM4YmI0ZThm",t="https://case-management-portal-beesion-dev.apps.ocp01.iplan.com.ar/#/tkt-incident/sw-2783/manage",r=secureUrlService.createToken(t,e);expect(()=>secureUrlService.validate(t,r,e,15e3)).not.toThrow(),expect(secureUrlService.validate(t,r,e,15e3)).toBeUndefined()}),test("Front path with params",()=>{const e="N2ZkZGY4NmItYzVmYi00ZDFkLWI0OGEtMTY1MmM4YmI0ZThm",t="https://case-management-portal-beesion-dev.apps.ocp01.iplan.com.ar/#/tkt-incident/sw-2783/manage?param1=1¶m2=a",r=secureUrlService.createToken(t,e);expect(()=>secureUrlService.validate(t,r,e,15e3)).not.toThrow(),expect(secureUrlService.validate(t,r,e,15e3)).toBeUndefined()}),test("Api path",()=>{const e="N2ZkZGY4NmItYzVmYi00ZDFkLWI0OGEtMTY1MmM4YmI0ZThm",t="/api/case-adapter/bpm",r=secureUrlService.createToken(t,e);expect(()=>secureUrlService.validate(t,r,e,15e3)).not.toThrow(),expect(secureUrlService.validate(t,r,e,15e3)).toBeUndefined()}),test("Path with special characters with token expired",()=>{const e="2cd68756-0099-48b4-9f42-57b3553f60c7",t="/api/ms-business/party/%7BpartyId%7D",r=secureUrlService.createToken(t,e);try{secureUrlService.validate(t,r,e,-1),fail("Expected SecureUrlService.validate to throw an error")}catch(e){expect(e.message).toBe("The token has expired."),expect(e.name).toBe("SecureUrlError"),expect(e.code).toBe(410)}}),test("Path with special characters",()=>{const e="2cd68756-0099-48b4-9f42-57b3553f60c7",t="/api/ms-business/party/%7BpartyId%7D",r=secureUrlService.createToken(t,e);expect(()=>secureUrlService.validate(t,r,e,15e3)).not.toThrow(),expect(secureUrlService.validate(t,r,e,15e3)).toBeUndefined()}),test("Path with special characters and session key in base64 with token expired",()=>{const e="N2ZkZGY4NmItYzVmYi00ZDFkLWI0OGEtMTY1MmM4YmI0ZThm",t="/api/case-adapter/bpm/%7BinstanceId%7D/save-and-continue",r=secureUrlService.createToken(t,e);try{secureUrlService.validate(t,r,e,-1),fail("Expected SecureUrlService.validate to throw an error")}catch(e){expect(e.message).toBe("The token has expired."),expect(e.name).toBe("SecureUrlError"),expect(e.code).toBe(410)}}),test("Path with special characters and session key in base64",()=>{const e="N2ZkZGY4NmItYzVmYi00ZDFkLWI0OGEtMTY1MmM4YmI0ZThm",t="/api/case-adapter/bpm/%7BinstanceId%7D/save-and-continue",r=secureUrlService.createToken(t,e);expect(()=>secureUrlService.validate(t,r,e,15e3)).not.toThrow(),expect(secureUrlService.validate(t,r,e,15e3)).toBeUndefined()})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const AuthorizationService=require("../authorizationService"),_=require("underscore"),logger=require("pino")(),authorizationService=new AuthorizationService(_,logger),typesPreviousRules=[{path:"/api/ms-financing-setting/fnc-types",actions:"GET",enable:!0},{path:"/api/ms-financing-setting/fnc-types",actions:"POST",enable:!1}],actionPreviousRules=[{path:"/api/ms-financing-setting/fnc-action",actions:"*",enable:!1}],catalogPreviousRules=[{path:"/api/ms-financing-setting/fnc-catalog",actions:"*",enable:!0}];describe("Types use case",()=>{test("Set disable previous disable",()=>{const e=JSON.stringify(authorizationService._solveMergeRule(typesPreviousRules,{path:"/api/ms-financing-setting/fnc-types",actions:"POST",enable:!1}));expect('[{"path":"/api/ms-financing-setting/fnc-types","actions":"GET","enable":true},{"path":"/api/ms-financing-setting/fnc-types","actions":"POST","enable":false}]').toStrictEqual(e)}),test("Set enable previous disable",()=>{const e=JSON.stringify(authorizationService._solveMergeRule(typesPreviousRules,{path:"/api/ms-financing-setting/fnc-types",actions:"POST",enable:!0}));expect('[{"path":"/api/ms-financing-setting/fnc-types","actions":"GET,POST","enable":true}]').toStrictEqual(e)}),test("Add enable",()=>{const e=JSON.stringify(authorizationService._solveMergeRule(typesPreviousRules,{path:"/api/ms-financing-setting/fnc-types",actions:"PUT",enable:!0}));expect('[{"path":"/api/ms-financing-setting/fnc-types","actions":"GET,PUT","enable":true},{"path":"/api/ms-financing-setting/fnc-types","actions":"POST","enable":false}]').toStrictEqual(e)}),test("disable two actions, one set disable previously and other not exists",()=>{const e=JSON.stringify(authorizationService._solveMergeRule(typesPreviousRules,{path:"/api/ms-financing-setting/fnc-types",actions:"POST,DELETE",enable:!1}));expect('[{"path":"/api/ms-financing-setting/fnc-types","actions":"GET","enable":true},{"path":"/api/ms-financing-setting/fnc-types","actions":"POST,DELETE","enable":false}]').toStrictEqual(e)}),test("Enable two actions, one set disable previously and other not exists",()=>{const e=JSON.stringify(authorizationService._solveMergeRule(typesPreviousRules,{path:"/api/ms-financing-setting/fnc-types",actions:"POST,DELETE",enable:!0}));expect('[{"path":"/api/ms-financing-setting/fnc-types","actions":"GET,POST,DELETE","enable":true}]').toStrictEqual(e)}),test("Add enable all rule",()=>{const e=JSON.stringify(authorizationService._solveMergeRule(typesPreviousRules,{path:"/api/ms-financing-setting/fnc-types",actions:"*",enable:!0}));expect('[{"path":"/api/ms-financing-setting/fnc-types","actions":"*","enable":true}]').toStrictEqual(e)}),test("Add disable all rule",()=>{const e=JSON.stringify(authorizationService._solveMergeRule(typesPreviousRules,{path:"/api/ms-financing-setting/fnc-types",actions:"*",enable:!1}));expect('[{"path":"/api/ms-financing-setting/fnc-types","actions":"GET","enable":true},{"path":"/api/ms-financing-setting/fnc-types","actions":"*","enable":false}]').toStrictEqual(e)})}),describe("Action use case",()=>{test("Set disable previous disable",()=>{const e=JSON.stringify(authorizationService._solveMergeRule(actionPreviousRules,{path:"/api/ms-financing-setting/fnc-action",actions:"POST",enable:!1}));expect('[{"path":"/api/ms-financing-setting/fnc-action","actions":"*","enable":false}]').toStrictEqual(e)}),test("Set enable previous disable",()=>{const e=JSON.stringify(authorizationService._solveMergeRule(actionPreviousRules,{path:"/api/ms-financing-setting/fnc-action",actions:"POST",enable:!0}));expect('[{"path":"/api/ms-financing-setting/fnc-action","actions":"*","enable":false},{"path":"/api/ms-financing-setting/fnc-action","actions":"POST","enable":true}]').toStrictEqual(e)}),test("Add enable",()=>{const e=JSON.stringify(authorizationService._solveMergeRule(actionPreviousRules,{path:"/api/ms-financing-setting/fnc-action",actions:"PUT",enable:!0}));expect('[{"path":"/api/ms-financing-setting/fnc-action","actions":"*","enable":false},{"path":"/api/ms-financing-setting/fnc-action","actions":"PUT","enable":true}]').toStrictEqual(e)}),test("disable two actions, one set disable previously and other not exists",()=>{const e=JSON.stringify(authorizationService._solveMergeRule(actionPreviousRules,{path:"/api/ms-financing-setting/fnc-action",actions:"POST,DELETE",enable:!1}));expect('[{"path":"/api/ms-financing-setting/fnc-action","actions":"*","enable":false}]').toStrictEqual(e)}),test("Enable two actions, one set disable previously and other not exists",()=>{const e=JSON.stringify(authorizationService._solveMergeRule(actionPreviousRules,{path:"/api/ms-financing-setting/fnc-action",actions:"POST,DELETE",enable:!0}));expect('[{"path":"/api/ms-financing-setting/fnc-action","actions":"*","enable":false},{"path":"/api/ms-financing-setting/fnc-action","actions":"POST,DELETE","enable":true}]').toStrictEqual(e)}),test("Add enable all rule",()=>{const e=JSON.stringify(authorizationService._solveMergeRule(actionPreviousRules,{path:"/api/ms-financing-setting/fnc-action",actions:"*",enable:!0}));expect('[{"path":"/api/ms-financing-setting/fnc-action","actions":"*","enable":true}]').toStrictEqual(e)}),test("Add disable all rule",()=>{const e=JSON.stringify(authorizationService._solveMergeRule(actionPreviousRules,{path:"/api/ms-financing-setting/fnc-action",actions:"*",enable:!1}));expect('[{"path":"/api/ms-financing-setting/fnc-action","actions":"*","enable":false}]').toStrictEqual(e)})}),describe("Catalog use case",()=>{test("Set disable previous disable",()=>{const e=JSON.stringify(authorizationService._solveMergeRule(catalogPreviousRules,{path:"/api/ms-financing-setting/fnc-catalog",actions:"POST",enable:!1}));expect('[{"path":"/api/ms-financing-setting/fnc-catalog","actions":"*","enable":true}]').toStrictEqual(e)}),test("Set enable previous disable",()=>{const e=JSON.stringify(authorizationService._solveMergeRule(catalogPreviousRules,{path:"/api/ms-financing-setting/fnc-catalog",actions:"POST",enable:!0}));expect('[{"path":"/api/ms-financing-setting/fnc-catalog","actions":"*","enable":true}]').toStrictEqual(e)}),test("Add enable",()=>{const e=JSON.stringify(authorizationService._solveMergeRule(catalogPreviousRules,{path:"/api/ms-financing-setting/fnc-catalog",actions:"PUT",enable:!0}));expect('[{"path":"/api/ms-financing-setting/fnc-catalog","actions":"*","enable":true}]').toStrictEqual(e)}),test("disable two actions, one set disable previously and other not exists",()=>{const e=JSON.stringify(authorizationService._solveMergeRule(catalogPreviousRules,{path:"/api/ms-financing-setting/fnc-catalog",actions:"POST,DELETE",enable:!1}));expect('[{"path":"/api/ms-financing-setting/fnc-catalog","actions":"*","enable":true}]').toStrictEqual(e)}),test("Enable two actions, one set disable previously and other not exists",()=>{const e=JSON.stringify(authorizationService._solveMergeRule(catalogPreviousRules,{path:"/api/ms-financing-setting/fnc-catalog",actions:"POST,DELETE",enable:!0}));expect('[{"path":"/api/ms-financing-setting/fnc-catalog","actions":"*","enable":true}]').toStrictEqual(e)}),test("Add enable all rule",()=>{const e=JSON.stringify(authorizationService._solveMergeRule(catalogPreviousRules,{path:"/api/ms-financing-setting/fnc-catalog",actions:"*",enable:!0}));expect('[{"path":"/api/ms-financing-setting/fnc-catalog","actions":"*","enable":true}]').toStrictEqual(e)}),test("Add disable all rule",()=>{const e=JSON.stringify(authorizationService._solveMergeRule(catalogPreviousRules,{path:"/api/ms-financing-setting/fnc-catalog",actions:"*",enable:!1}));expect('[{"path":"/api/ms-financing-setting/fnc-catalog","actions":"*","enable":true}]').toStrictEqual(e)})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const SqlInjectionGuard=require("../sqlInjectionGuard"),pino=require("pino");describe("SqlInjectionGuard",()=>{let e;beforeEach(()=>{delete process.env.blz_securityApiSanitizeOnlyLog,delete process.env.blz_securityApiSanitizeAllowedInputRegex,e=new SqlInjectionGuard(pino({level:"silent"}))}),test("accepts safe simple strings",()=>{const t=[{name:"username",value:"john_doe"}];expect(()=>e.validateParamList(t)).not.toThrow()}),test("accepts safe identifiers with dots and dashes",()=>{const t=[{name:"email",value:"test.user-name"}];expect(()=>e.validateParamList(t)).not.toThrow()}),test("blocks basic SQL injection attempt",()=>{const t=[{name:"query",value:"' OR 1=1 --"}];expect(()=>e.validateParamList(t)).toThrow()}),test("blocks semicolon followed by DROP statement",()=>{expect(()=>e.validateRawSql("SELECT * FROM users; DROP TABLE users;")).toThrow()}),test("blocks string with pg_sleep function",()=>{expect(()=>e.validateRawSql("SELECT pg_sleep(10);")).toThrow()}),test("blocks nested object with SQLi",()=>{const t={user:{comment:"'; DROP TABLE users;"}};expect(()=>e.validateObject(t)).toThrow()}),test("blocks deep object traversal with SQLi",()=>{const t={a:{b:{c:"' OR '1'='1"}}};expect(()=>e.validateObject(t)).toThrow()}),test("does not block number values",()=>{const t=[{name:"count",value:12345}];expect(()=>e.validateParamList(t)).not.toThrow()}),test("does not block boolean values",()=>{const t=[{name:"active",value:!0}];expect(()=>e.validateParamList(t)).not.toThrow()}),test("does not block empty string",()=>{const t=[{name:"description",value:""}];expect(()=>e.validateParamList(t)).not.toThrow()}),test("allows <script> input when custom regex allows all characters",()=>{process.env.blz_securityApiSanitizeAllowedInputRegex="^.{1,100}$",e=new SqlInjectionGuard(pino({level:"silent"}));const t=[{name:"comment",value:'<script>alert("x")<\/script>'}];expect(()=>e.validateParamList(t)).not.toThrow()}),test("blocks SQL injection even if allowedInputRegex allows special characters",()=>{process.env.blz_securityApiSanitizeAllowedInputRegex="^.{1,100}$",e=new SqlInjectionGuard(pino({level:"silent"}));const t=[{name:"input",value:"'; DROP TABLE users;"}];expect(()=>e.validateParamList(t)).toThrow()}),test("only logs when onlyLog mode is enabled",()=>{process.env.blz_securityApiSanitizeOnlyLog="true",e=new SqlInjectionGuard(pino({level:"silent"}));const t=[{name:"input",value:"' OR 'x'='x"}];expect(()=>e.validateParamList(t)).not.toThrow()}),test("ignores non-string values in validateObject",()=>{const t={safe:!0,count:42,list:[1,2,3],nested:{values:[!1,null,void 0]}};expect(()=>e.validateObject(t)).not.toThrow()}),test("blocks string containing EXEC",()=>{expect(()=>e.validateRawSql("EXEC('SELECT * FROM users')")).toThrow()}),test("blocks string using dbms_lock.sleep",()=>{expect(()=>e.validateRawSql("SELECT dbms_lock.sleep(10) FROM dual")).toThrow()}),test("does not block special characters like = or &",()=>{const t=[{name:"filter",value:"key=value&x=1"}];expect(()=>e.validateParamList(t)).not.toThrow()}),test("does not block values containing HTML but not SQL",()=>{const t=[{name:"html",value:"<b>bold</b>"}];expect(()=>e.validateParamList(t)).not.toThrow()}),test("throws on invalid JSON pattern in env",()=>{process.env.blz_securityApiSanitizeDangerousParamPatterns="INVALID_JSON",expect(()=>{new SqlInjectionGuard(pino({level:"silent"}))}).not.toThrow()}),test("blocks /* comment pattern in param",()=>{const t=[{name:"q",value:"*/ DROP TABLE"}];expect(()=>e.validateParamList(t)).toThrow()}),test("blocks SELECT-FROM pattern",()=>{const t=[{name:"sql",value:"SELECT * FROM users"}];expect(()=>e.validateParamList(t)).toThrow()}),test("blocks INSERT INTO pattern",()=>{const t=[{name:"payload",value:"INSERT INTO table VALUES (1)"}];expect(()=>e.validateParamList(t)).toThrow()}),test("blocks UPDATE SET = pattern",()=>{const t=[{name:"input",value:'UPDATE table SET name="x"'}];expect(()=>e.validateParamList(t)).toThrow()}),test("blocks DELETE FROM pattern",()=>{const t=[{name:"delete",value:"DELETE FROM users"}];expect(()=>e.validateParamList(t)).toThrow()}),test("allows input with only < at the end",()=>{const t=[{name:"input",value:"allowed<"}];expect(()=>e.validateParamList(t)).not.toThrow()}),test("allows input with only > at the beginning",()=>{const t=[{name:"input",value:">allowed"}];expect(()=>e.validateParamList(t)).not.toThrow()}),test("blocks OR with LIKE pattern",()=>{const t=[{name:"search",value:"' OR name LIKE '%admin%'"}];expect(()=>e.validateParamList(t)).toThrow()}),test("blocks AND with LIKE pattern",()=>{const t=[{name:"search",value:"' AND role LIKE '%user%'"}];expect(()=>e.validateParamList(t)).toThrow()}),test("blocks UNION SELECT statement",()=>{const t=[{name:"payload",value:"' UNION SELECT password FROM users --"}];expect(()=>e.validateParamList(t)).toThrow()}),test("blocks complex obfuscated SQL injection",()=>{const t=[{name:"value",value:"admin'/**/OR/**/'1'='1"}];expect(()=>e.validateParamList(t)).toThrow()}),test("does not block input that looks like markup but is valid by whitelist",()=>{const t=[{name:"input",value:"example>"}];expect(()=>e.validateParamList(t)).not.toThrow()}),test("does not block input with common punctuation",()=>{const t=[{name:"text",value:"Hello, world! How are you?"}];expect(()=>e.validateParamList(t)).not.toThrow()})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const XssGuard=require("../xssGuard"),logger=require("pino");describe("XssGuard",()=>{let t;beforeEach(()=>{t=new XssGuard(logger({level:"silent"}))}),test("sanitizes buffer as String",()=>{const e={zipBinaryString:'PK\0\b\0\b\0ÝîZ\0\0\0\0\0\0\0\0\0\0\0\0:\0\0\0criteria-set-11-exported-2025-07-14T16:38:58.967Z1073.jsoníÝmSi¢à¿bñéLU3E7/B¾ùÆZJ7ÍVÊvg3£fÏLmí?´³Aeiºyë±ÛZáÊs?Ý÷óÏÒåíÕýèöêb0º/½úç×ÿ<ùXzÇQéîþâþË]éU©}º·ßi¢Òõů£Ò«R÷âöê®Ë;.îFwn®w¿Þü}´3ÝÝï4wÊ;ÿuõëçÛûÑǾùG)*}Ý]Þ^}¾¿º¹.½*=þ±ÑoÓ=ÇL*I\\i+É0_ÅÍWIëÇÝVóçhçáx÷J^Õv_%ÕúÏ?Ì>\\«7IåU%~U¯ÿب$3÷Ç^»¯âÆI¥ñó¥E¢Ò«¿üq¾n®\'g«Ö¬D³NáÕÝÞçÏ®./>|·áÙOíRTú|q;º¾?øú\b×_>}ïÞþíòÓ»éÙI÷þp;ºøûÇÿ~kït°w0<é¢ÒßnGÿûet}ùûð÷ÏãÃîtÞ¢ÒèãÃß|ïM¹R)¿)ÿ¹wtôþðaÛá7¿
?HùæoÛïpùåöv|Ì»ñ¯þ§³RTº¹ý%=\\y¼ÇíèãÕýñ§½ËË/×÷éw?>|ÿÍ«»£«Ëû«û«/w7ׯ¦9}µÓ]ÇOþ»m÷·×wão=Ú^úË»ÒôÕ¼+ýµîn¾Ü^fäÃË¿fÿãèÃýÍí`ò~t{óë³;\foÞüËèùÿeôäO]Ýý}üä9ÀÃ.O?Ñ/¿®ï{Ó=<Âáëë«ë_9BºÇ#Üÿ¾Ì>ù£ß>®ïfoKóÏþoöñÈÿÞþÄ/àëþùgöyæY<óKøv§ñܯáÛ]fã«wË3çô»½f=On./^8ÐãfçòËÝýͯãÓ?³-yf[õmµg¶Õ¿Ûvu·ÿÇÁàó§«ñÓÑ^gÐ|@üû>·1yncõ¹µç6Öo¼}>ùÙ7~=ÿ¾Ãg·U\b>û?ü©=ÛV;~þð¨3þ4øÃþl?Í5ü¼ÐÁ:!t`ðøÀ>»a~¸cðÃþðgCýiëÏÑéÁûãÙü]]_\\_^]ÿ²s<ºÝ^]îLY&¯\fE(BÑ:R4~þ©Û¾´lêt8¿HcPÖ¤C \tH@Òw ÕÂ2N2U#áh;8ªÎAhD#mFIØuú{o{GG³=z=øÓNÿâ÷ñe\fÿu?ßHuqûûkÂQúÊ$ ¹Dñò%zx>\vOí\'NËGy0WwëñL¤ÒªT*³@Jjeºé\tÆ´OÒÔÅy:9=|ð®½+íu:½éWý÷íýáäëL~uâÇÂulüþt¼Ñ_·÷:Ã×/oÃvwçätØ>>ÛöΦíÇ£3î=ó©:9i¯-Ͳ0ð>þÛîðýÉa{¯3[Ä«ñ¦Ï¿ßfïB\b\bÇ\'ÿ¤Ó99M#Àçõû÷\v4>ã×϶~|Ö\b·æ!Üp2ï4>éYcF[T¢¨ôH¥f©áY©a³Yb\nSÚàPð +ê[«ÝÐ/¶è½?\ffÕ¹¹¸NÅZK,¦¯G!\f¹èC©C£<¡\bE(Ú\nÂmpèD\'ÓJ[ÈRi¥
£ºÉÇvv®®?Ü|¹þø"OoÞ¼yóļÒÃäÑwNÅøùy¥´:8kL®#}«éKå!\nQBTƸV¯åpåCR+ÿ¹|Þ(4Û§þø9|¼ºÜ9¹þÇÍÕåh§¼3ý]í|¸øtq}9ÚùòùãÅýè.ÃÅñ¦Õ^\fñÇÝR®Î÷\f®kÒMv2¶OßÿqåËÓ½°;×^vmòÖº¹»}üîOð¯÷Î?,Üï?º"+|\tøÀ>ð/(øþtÜ_ðÅàøÀ¾ àöúà˾\nøÀ>ð/(øú!ør¯ÞøÀ>ð_§}\f¾<ák|àøÂãëwÁ\'|»àøÀ¾°àk»¸%WøàøÀ¾ à{}¾¾<á«|àøÂñuÝÇ+|su¬<<BqÝýä#ùÈ·åòEéÐ/J³Ï(üÒ«_¢ôòÏ(½ÿ!Jo\0Öïøtpµ6pfn~I9¬]¬O.Wë\rnrÜ\f¯ù¥EµÇÓ¬Tâ¤Ò¨5«²#ÍÀ&0\tÌÙ`Æqe·^KâFÌZ=&0\tL`s6ÆøC0N`Öê`ÀæºudW\0fL`À¦Höe0À&0\tL`d_sÀ&0¹n«edWfÀ&0\tLìË`Ö\tL`Àɾ\ff\rÀ&0¹në8dW¦¦`À¦Hv05ý\0À&0E²s©éÀ&0ÃsÒ±.\rLM?À&0\tLìË`V5ý\0À&0E²s©éÀ&0kúéwE²!©éÀ&0)LM?À&0\tLì`jú&0\tÌÀÀl[Þ+H05ý\0À&0E²s©éÀ&0)LM?À&0¯Ï÷E²!©éÀ&0)LM?À&0\tLìË`&~\tL`3°9ÌnO$"~\tL`"Ù9ÀÔôL`ÀÉÎæ\\M?0CÌóDLbÄ\\¦Q:¥÷DiP¶³GéÂѻҰ×n?î·ßRÜèÛksâõÌñ£.GãÌ5Bñò¯gå$)ãf³Zq\\©¬=Æ\tÆÑ»Ò1©Lå5SyUºZùxÛ6Gk$ \tHÀ@Ç¥Çæ)`$ \t¦¤ù\t$ Ãp2çHÀü\tH@a\n8¹úù\tX! \tH@®íRÌ `Ü" \tH@®íÊÌ"`$ \t¸¶E«Ì"à.\tH@pm{m\bEÀ ûi@"ÅÕEh>2ù\t½S&É£àFÁÛ&\0Úá&7¹¹y7Ò[tc`Ö\tL`À´èÆË`V\tL`À´èÆË`&.ºALbÄÜêE3rò4¯U3âm9y]"TuMiJSº86ø²äTÕ±aäòÖnl·àø6l(ö¬\0ÌJ\vÀ&0\tLö¼\ffÀ&0\tLö¼\fæ.0\tL`Ó="ÙÁl\0À&0)}Ì:0\tL`"ÙÁ¬À&0sR+\rÌ*0\tL`"ÙÁL\tL`Àɾ\ff\fL`À\f\nÌÉ]"ÙðÀÔôL`Àɾ\bfµ¥éÀ&0)LM?À&0ö±H6D05ý\0À&0E²s©éÀ&0)LM?À&0XÓO¿+\rLM?À&0\tLì`jú&0\tL`dç\0SÓ0\tL`fÛò^A©éÀ&0)LM?À&0\tLìË`65ý\0ÀfX`¾>ßÉ\b¦¦`À¦Hv05ý\0À&0E²s©éÀ&0ÃìöD²!©éÀ&0)LM?À&0\tLì`ÎÕôóð\b3Ä|8OÄ$&1IÌe¥QzIV\0Ei;{.½+\r{ýéöãé~ûý ž±F9\'¾éPoÉÏ8êr4ÎX#\vÆgåj\\ ÆI<UuC1î¦ï©~ïhúÞ{ÛÅ3ñ¼aÚî¢h>Þ¶ÓÌAõZãÒ$1.]
ó½é]¾8Úßë
(\\\'\niºzèkB+\bE(BPºhBw[\bE(BPºÂhB\bE(BÐÐç4-$¡»\bE(BP\nr!´P"¡\bE¨ wBë\bE(BÐÀ\tÜ\v*È\rÐBP"¡ÜE\b"¡\bE(B*È]С\bE(B8¡r?Anxj\'B(BP\nr"T;BP"T»\b¡\ríD\bE(B:¡ÕZ¹áª\b¡\bE(B*È]PíD\bE(BPAîBj\'B(BÐàÛú]Anj\'B(BP\nr"T;BP"T»¡ÚP"4xBÛ;\vPíD\bE(BPAîBj\'B(BP\nr"T;BPNèëó}AnÖµ!¡\bE(B¹\vª\b¡\bE(B*È]PíD\bE(Bü\\h·\'È\rPíD\bE(BPAîBj\'B(BP\nr"t®v¢GaèÃyb(CÊPækhNFé].QZ[¥=ôQº°hô®4ìõ§Û§ûí÷48úvTå§ÃÁ%=ã¨Ëñ9sõQmùCܳr\\-çf³ZÛ\\Úía\fãuÂxLºùxÛ6Lð|à_X£Ðãøò/øÀ>ðß$N_~ðUÀ>ð|AÁ7O_nðÕZàøÀ¾ à\\P¾üàk|àøÖm!Lðeo|àøÀ·n\v/\v|\rð|àߺ/\v|uð|àߺÓ/\v|AÌ|ä#:\\ëd3âüàÌØüS1[5¢Vãúº»Ù99LßjýÞÑô½¶÷¶KRT¹©Ñæhfnë9 ×´.\vͳÁùÁ´Í´×;Ôf\nMhnju©VAhP"¡\bE¨u©!´P"¡\bE¨u© ´ÚB(BP®!¸ w6P"¡\bä.Bè.BP"¡ÜE\bm ¡\bE(B×+Aî*\b#¡\bE(B*È]ÐBP"¡ÜE\b"¡\bE(B×ÁfAî*\bÕNP"¡\bä.D¨v""¡\bE¨ w!Bµ!¡\bEhèN`äGh¢\b¡\bE(B*È]PíD\bE(BPAîBj\'B(BÐàÛú]Anj\'B(BP\nr"T;BP"T»¡ÚP"4xBÛ;\vPíD\bE(BPAîBj\'B(BP\nr"T;BPNèëó}Anj\'B(BP\nr!4ÖNP"¡\bä.D¨v""¡\b\r~.´ÛäH¨v""¡\bE¨ w!Bµ!¡\bE(B¹\v:W;ÑÃ#Ì0ôá<1¡\fe(Có54J\'E£ô.(-Òú(]X4zWöúÓíÇÓýöûA};ªrÎÓáàqÔåø¹ú¨²ü!îYÁ<7Õñg<Ëó¼tEóñ¶mªVQB¢
¡T;(ÌÂ
(D!\nQ8
ùQ£
(D!\n§p2/Âü(¬
(D!\n§pr©\ns£°ÒB!\nQB®ÿ¢(ÌBa
(D!\nQ¸þË 0\v
»(D!\nQÂõ/~Ea\n(D!\nQÂõ¯ÎAa\n¬Àa!\vYÈB\\¥ùÕäGiƶÊäªqùTÜr$í¦oµ~ïhú^Û{Û%iøî\fOÎÛé¯l0|øÓôýöéa{úÿ¢ÃöÃ~/cí<V뺤J9£Øj%{;N%z*zFïùÞ´ F«xÂn]ìb»ØÅ®¿b7Æ.v±]ìb×jaE±[\tsµ0îr»ÜåîFº[ð\na9©ÓaI«àEWg¼Ù/3ÉLf²Ûrà³$
^³ÄS]³\fT Õý´@]Ô¬-KÉn.s³xY &ãÑñí´¦å¨õ®]¿\rþò¿üå/]\\¸¿uþò¿üå/]¤\\¸¿5þò¿üå¯åÏ
û[å/ùË_þòWþ\\¸¿\tùË_þò¿òçÂýùË_þò¿ìïdm!ùsxþVøË_þò¿ü?ío³Å_þò¿üå¯ü¹püå/ùËßMöw²Æ½ü9<õ_ñ¿üå/åÏÅû«ÿ¿üå/ù+.Þ_ýWüå/ù»ÑþvÚÇòçýÕÅ_þò¿ü?ï¯þ+þò¿üå¯ü¹xõ_ñ¿üåïf÷_õ»òçýÕÅ_þò¿ü?ï¯þ+þò¿üå¯ü¹pwõ_ñ¿üåïfûÛ¶þ`þê¿â/ùË_þÊ÷WÿùË_þòWþ\\¼¿ú¯øË_þòw£ý}}¾/Ñ_ýWüå/ùË_ùsñþê¿â/ùË_þÊ÷WÿùË_þnöüo·\'Ñ_ýWüå/ùË_ùsñþê¿â/ùË_þÊ÷w®þ«GðÃy0\f`\0\fpNGé\rIQZ¥\v4DéBÁѻҰ×n?î·ßðèÛñts¼D¬û£.÷FærZí5¶/Ëö#¤#é[Iz@$SþÝ&v±]ìb»¦bw»ØÅ.v±]3ÈE±ÛÀ.v±]ìnâ¼ñ±
d·]ìb»ØÅ®¹(vkØÅ.v±]ì\nb·]ìb»ØÝ@v\'7\tÃc7Á.v±]ìbWÈ\\»1v±]ìb»Bæ¢Ø`»ØÅ.v7ÝI³98vëZª°]ìb»BæÂØÕR
]ìb»Ø2Æ®*ìb»ØÝDv\'Ë(\bÃcWKv±]ìbWÈ\\»Zª°]ìb»BæÂØÕR
]ìb»ÙR5^³WÈ»Zª°]ìb»BæÂØÕR
]ìb»Ø2Æ®*ìb»ØÝHvÛþ\v]-UØÅ.v±]!sQìÖ´Ta»ØÅ.v
Ì
±«¥\n»ØÅ.v7Ý×çûBæÙÕR
]ìb»Ø2Æ®*ìb»ØÅ®¹0vµTa»ØÅîFÎív{BæÙÕR
]ìb»Ø2Æ®*ìb»ØÅ®¹0vçj©zxî>\'îr»ÜånxîFé$oÞQ¥õUQºVB.̽+\r{ýéöãé~ûý ݾ=G9gØé°sɨÏ8êrLÏ\\U]þPú¬`ÒÍj\réHG:Ò7ô9H>è.\níãmÛ8$®àøÄ\'>7qD|ÜÁg|V[øÄ\'>ñÏ\räsã3?>øÄ\'>ñÏ\räs2ÏÏüøÜÅ\'>ñO|n Ëð\r|âøÄçv.ZÏ,|ÖñO|âÛ¹>³ðYÃ\'>ñO|ngÑ0>³ðYÅ\'>ñO|ng
>³ðd?ùÉO~òs\rªò7Ò¢üøÍÜZä2zMè»,}}£w¥c\fcÃê\fcïh
£å(G9ªÇ£:´8ÊQr£\n8º°£Mr£å¨f#.ìè.G9ÊQrTÅGv´ÁQr£ÕuÄÑ
s£å(GqtaGkå(G9ÊQíG]ØÑ*G9ÊQrT\rGv4Ô$¤ ©>¤-èCJ²ö!ÅÚÒÞ/ÇÕ"®îÖã\rn#l·ô¥/}Õ ÍÐsÐýy\nt{¯3|=ýûx;¶»;\'§ÃöñÙÞ°w6ú ½¨³ãÇiV*qRiÔÕÇGÙÆáo»ØÅ.v±Ý<ÙãÊn½Ä»IÜÂ.v±]ìb7OvFe<àmV°ÄMìb»ØÅîvv\vWÁî.v±]ìb»Bæ¢Øm`»ØÅ.v±+d.Ý:v±]ìbw;Ð2¯Ýv±]ìb»Bæ¢Øb»ØÅ.v±+d.Ý»ØÅ.v±»«Ë\nWÁ®*ìb»ØÅ®¹0vµTa»ØÅ.v
ÌE±[ÑR
]ìb»ÈîdÅ!sxìj©Â.v±]ì\n\vcWKv±]ìbWÈ\\»Zª°]ìbw#[ªú]!sìj©Â.v±]ì\n\vcWKv±]ìbWÈ\\»Zª°]ìbw#Ùm[ø/HvµTa»ØÅ.v
Ì
±«¥\n»ØÅ.v±+d.]-UØÅ.v±»ì¾>ß2ÇnÜÒR
]ìb»Ø2Æ®*ìb»ØÅ®¹0vµTa»ØÅîFÎív{BæÙÕR
]ìb»Ø2Æ®*ìb»ØÅ®¹0vçj©zxî>\'îr»ÜånxîFé$oÞQ¥õUQºVB.̽+\r{ýéöãé~ûý ݾ=G9gØé°sɨÏ8êrLÏ\\Õ\\þPú¬`ÒÍj\réHG:Ò7ô9H>è.\níãmÛ8$NðO|â8">îà3O>c|âøÄçò9\tñ|âøÄçò9gÅgn|6[øÄ\'>ñÏ\räsr¹>óã³O|âøÜÎEkñ
Ï]|âøÄçv.ÇÏ,|6ðO|âÛY4Ï,|ÖñO|âÛY¡Ï,|Y
ÄO~òü\\*¤ üͧ´(?~3·ÕyÖ.Kß³ÁùÁätÜëM?oö÷:<æ1õY\0\'Ä 1-³:cÄ 1-³:+ 1A\fbÁ¢éA¼Û1A\fbX4½: 1A\fb¦Wñ.A\fbØú;¢éÕAÜ\x001A\fbX4½:ë 1A\fb¦Wq\rÄ 1Alm[Ñôê Ö¬bÄ M¯bÍZ 1A\fbÑô\n!Ö¬bÄÛñdmÑtxkÖ1A\fb¦WqC³A\fbX4½B5kÄ ñ4kõ»¢é!Ö¬bÄ M¯bÍZ 1A\fbÑô\n!Ö¬bÄ[qÛ2AB¬Y\vÄ 1A,^!ĵ@\fbÄ¢éB¬Y\vÄ 1·â×çû¢é!Ö¬bÄ M¯bÍZ 1A\fbÑôê ®kÖ1A\fâ-#îöDÓ!B¬Y\vÄ 1A,^!ĵ@\fbÄ¢éB<W³ÖÃ#Ìøá<Ä$&1×Aâ(,Òû¢´r+JW
Ò
£w¥a¯?Ý~<Ýo¿¤äÑ·#ì(çä;.ùG]òk»jËn|³YAòü¦#?ÒÝEé}¼mÍ5 ¨@êv;@ÍÔ*P\nT u+@ÄÊ@ÍÔ¨@*Pº Næk¨1P\nT u+@\\\bÔü@\0¨@*P-ê\vÔÌ ÖZ@*P\nTK5;¨M ¨@ªe fu¨@*Pªö\t¨ÙA\r²¾¨D%*QºõMAOÑR~ glZ×ãáÙÞé`ü.ïÎòr¥R~SÌypx¸óáâþò¿w.o®ÿvuûëäOôE}ûí·ßfâûoa¿Ã7®ÄÙñü©µO&mbÞ«3?¯ÿS}¿\'±!;cgäáß<þ=±×¬g«u·%Ïl3`ß§Úò}J÷^x¸ø¦\\ËoþÓábtýñêúÁááFgUESyFó½á·CÃãïtNNÓ/ú½£éÚí馣?¾3PNo»FÔÛÊQßôeîaß×»³p-¬ha«U~Sî¿íßOe{b¤öùâ÷ñû¥ ú¾y¼Ã£ÎL`23Û$B\bZ8-Ü8Ò׳Dò@\0\b@P8@ÿI&¸\r!1A\fÚ$*Å\\3ñ^ÃX˧Köçé
&¤?u±Ä1>3/5y½+ú~Òɲµ:²Z{tqµ tûyH¤t¤#]0Ò¹Ý,_\vQV~U#µ<.!|éAØÁv«Ân;¹\fëaqXÄ"±¸ú1àË+õb±XÄ"±Å³8Çz»X,Å:±E,bqå,αj.a±E,bX\\9s¬}ÅbX¬bXÄ"W?·øò\n¶X,ÅXÄ"±¸zÛ.¹\tÅXÄ"±¸rçXMŰXÁ"±E,ª£ÁâW¨
·z,¹ÈE.n¥ù®ìº¦®®Ù°Iæ¸Ciª>¹ò:U©JUª®CKJ¸,ØíÂv°ìÖ¡ûvY°kÀv°ìÖ¡ÑvY°«Ãv°ìÖ¡§vY°«Áv°ìÖ¡}vY°«Âv°ìÖ¡SvY°K`;ØÁvëл,ØÅ°ì`»uè]ì*°ì`»uhu]ìâ »ZhG;ÚÑNWËÒ»ZÒrÍXâ\r,³¬L÷^Ê7åV«ü¦Ü99¼?\ff[Ù¹¹¸Þ9¹¾»¿øôiüVÛ9¹»ûrq=å`gQY~ÉoÞª\vØøðêÇñð¨3¤ÝèìXîñÅÍÓn!0\rÏöN{ÃÞéÜ:U*tzV§ïÑ¡¨D¥µW©îp©·wú¾÷\fG½Û«_®®\'Së¢Ðä%!±EëhÑãmZBõÀF$2"\b´ýuòÞº¹½}ì?JR/WvËqm7^U¯êÍ[õÊÏ¥ý?PK\bùþ \0\0`]\n\0PK-\0\b\0\b\0ÝîZùþ \0\0`]\n\0:\0\0\0\0\0\0\0\0\0 \0¤\0\0\0\0criteria-set-11-exported-2025-07-14T16:38:58.967Z1073.jsonPK\0\0\0\0\0\0h\0\0\0ú \0\0\0\0',criteriaSetId:null},s=t.sanitizeObject(e);expect(s.zipBinaryString).toBe(e.zipBinaryString)}),test("allows clean string without altering it",()=>{const e=t.sanitizeObject({comment:"This is a safe comment."});expect(e.comment).toBe("This is a safe comment.")}),test("sanitizes basic XSS attempt",()=>{const e=t.sanitizeObject({comment:'<script>alert("xss")<\/script>'});expect(e.comment).toBe("")}),test("sanitizes inline XSS",()=>{const e=t.sanitizeObject({title:"<img src=x onerror=alert(1)>"});expect(e.title).toBe("")}),test("sanitizes encoded XSS attempt",()=>{const e=t.sanitizeObject({encoded:"%3Cscript%3Ealert(1)%3C%2Fscript%3E"});expect(e.encoded).toBe("")}),test("sanitizes nested objects",()=>{const e=t.sanitizeObject({level1:{level2:{content:"<script>evil()<\/script>"}}});expect(e.level1.level2.content).toBe("")}),test("sanitizes arrays inside objects",()=>{const e=t.sanitizeObject({tags:["safe","<img src=x onerror=alert(1)>"]});expect(e.tags[0]).toBe("safe"),expect(e.tags[1]).toBe("")}),test("preserves clean strings in array",()=>{const e=t.sanitizeObject({tags:["tag1","tag2","tag3"]});expect(e.tags).toEqual(["tag1","tag2","tag3"])}),test("sanitizes SVG-based XSS",()=>{const e=t.sanitizeObject({x:"<svg/onload=alert(1)>"});expect(e.x).toBe("")}),test("sanitizes strings and ignores non-string values",()=>{const e={num:123,bool:!0,nullValue:null,undef:void 0,notReplace:"a < b"},s=t.sanitizeObject(e);expect(s.num).toBe(123),expect(s.bool).toBe(!0),expect(s.nullValue).toBeNull(),expect(s.undef).toBeUndefined(),expect(s.notReplace).toBe("a < b")}),test("sanitizes XSS in deep mixed structures",()=>{const e=t.sanitizeObject({items:[{safe:"ok"},{unsafe:'<iframe src="javascript:alert(1)">'}]});expect(e.items[1].unsafe).toBe("")}),test("sanitizes <a> with javascript href",()=>{const e=t.sanitizeObject({link:'<a href="javascript:alert(1)">click</a>'});expect(e.link).toBe("click")}),test("removes unexpected <object> tag",()=>{const e=t.sanitizeObject({embed:'<object data="evil.swf"></object>'});expect(e.embed).toBe("")}),test("removes unexpected <iframe> tag",()=>{const e=t.sanitizeObject({iframe:'<iframe src="http://malicious.com"></iframe>'});expect(e.iframe).toBe("")}),test("removes style attribute with expression()",()=>{const e=t.sanitizeObject({style:'<div style="width:expression(alert(1))">'});expect(e.style).toBe("")}),test("encodes < in string",()=>{const e=t.sanitizeObject({text:"a < b"});expect(e.text).toBe("a < b")}),test("allows > in string without encoding",()=>{const e=t.sanitizeObject({text:"a > b"});expect(e.text).toBe("a > b")}),test("allows & in string without encoding",()=>{const e=t.sanitizeObject({text:"Tom & Jerry"});expect(e.text).toBe("Tom & Jerry")}),test('allows " in string without encoding',()=>{const e=t.sanitizeObject({text:'She said "hello"'});expect(e.text).toBe('She said "hello"')}),test("allows ' in string without encoding",()=>{const e=t.sanitizeObject({text:"It's fine"});expect(e.text).toBe("It's fine")}),test("encodes only special HTML characters like < when needed",()=>{const e=t.sanitizeObject({text:'if (a < b && b > c) { console.log("yes"); }'});expect(e.text).toBe('if (a < b && b > c) { console.log("yes"); }')}),test("sanitizes special chars inside deeply nested object",()=>{const e={user:{profile:{bio:"I'm <strong>bold</strong> & smart"}}},s=t.sanitizeObject(e);expect(s.user.profile.bio).toBe("I'm bold & smart")}),test("sanitizes array of special char strings",()=>{const e=t.sanitizeObject({messages:["Hello & welcome","a < b",'Use "quotes"',"It's fine"]});expect(e.messages).toEqual(["Hello & welcome","a < b",'Use "quotes"',"It's fine"])})});
|