gina 0.3.10 → 0.3.11
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/CHANGELOG.md +25 -0
- package/CONVENTIONS.md +32 -0
- package/README.md +15 -2
- package/ROADMAP.md +6 -5
- package/bin/cli +1 -0
- package/framework/v0.3.11/VERSION +1 -0
- package/framework/{v0.3.10 → v0.3.11}/core/asset/plugin/dist/vendor/gina/js/gina.js +26 -5
- package/framework/{v0.3.10 → v0.3.11}/core/asset/plugin/dist/vendor/gina/js/gina.min.js +5 -5
- package/framework/v0.3.11/core/asset/plugin/dist/vendor/gina/js/gina.min.js.br +0 -0
- package/framework/v0.3.11/core/asset/plugin/dist/vendor/gina/js/gina.min.js.gz +0 -0
- package/framework/{v0.3.10 → v0.3.11}/core/asset/plugin/dist/vendor/gina/js/gina.onload.min.js +1 -1
- package/framework/v0.3.11/core/asset/plugin/dist/vendor/gina/js/gina.onload.min.js.br +0 -0
- package/framework/v0.3.11/core/asset/plugin/dist/vendor/gina/js/gina.onload.min.js.gz +0 -0
- package/framework/v0.3.11/core/connectors/mongodb/index.js +463 -0
- package/framework/v0.3.11/core/connectors/mongodb/lib/connector.js +158 -0
- package/framework/v0.3.11/core/connectors/mongodb/lib/pipeline-loader.js +186 -0
- package/framework/v0.3.11/core/connectors/mongodb/lib/session-store.js +392 -0
- package/framework/v0.3.11/core/connectors/scylladb/index.js +367 -0
- package/framework/v0.3.11/core/connectors/scylladb/lib/connector.js +145 -0
- package/framework/v0.3.11/core/connectors/scylladb/lib/session-store.js +338 -0
- package/framework/{v0.3.10 → v0.3.11}/core/controller/controller.js +146 -10
- package/framework/{v0.3.10 → v0.3.11}/core/gna.js +91 -4
- package/framework/{v0.3.10 → v0.3.11}/core/server.isaac.js +106 -16
- package/framework/{v0.3.10 → v0.3.11}/core/server.js +79 -0
- package/framework/v0.3.11/core/template/boilerplate/bundle/locales/en.json +10 -0
- package/framework/{v0.3.10 → v0.3.11}/core/template/conf/settings.json +20 -0
- package/framework/v0.3.11/helpers/text.js +45 -0
- package/framework/{v0.3.10 → v0.3.11}/lib/cmd/connector/add.js +1 -1
- package/framework/{v0.3.10 → v0.3.11}/lib/cmd/connector/help.txt +2 -2
- package/framework/{v0.3.10 → v0.3.11}/lib/cmd/connector/migrate.js +1 -1
- package/framework/{v0.3.10 → v0.3.11}/lib/cmd/connector/remove.js +2 -2
- package/framework/v0.3.11/lib/cmd/i18n/add.js +372 -0
- package/framework/v0.3.11/lib/cmd/i18n/arguments.json +9 -0
- package/framework/v0.3.11/lib/cmd/i18n/export.js +649 -0
- package/framework/v0.3.11/lib/cmd/i18n/help.js +46 -0
- package/framework/v0.3.11/lib/cmd/i18n/help.txt +94 -0
- package/framework/v0.3.11/lib/cmd/i18n/import.js +1023 -0
- package/framework/v0.3.11/lib/cmd/i18n/scan.js +622 -0
- package/framework/{v0.3.10 → v0.3.11}/lib/connector-registry/src/main.js +14 -11
- package/framework/v0.3.11/lib/i18n/package.json +19 -0
- package/framework/v0.3.11/lib/i18n/src/main.js +1072 -0
- package/framework/{v0.3.10 → v0.3.11}/lib/index.js +13 -0
- package/framework/v0.3.11/lib/metrics/package.json +19 -0
- package/framework/v0.3.11/lib/metrics/src/main.js +421 -0
- package/framework/{v0.3.10 → v0.3.11}/lib/nunjucks-filters/src/main.js +73 -0
- package/framework/{v0.3.10 → v0.3.11}/lib/routing/src/main.js +7 -0
- package/framework/{v0.3.10 → v0.3.11}/lib/swig-filters/src/main.js +73 -0
- package/framework/{v0.3.10 → v0.3.11}/lib/swig-resolver/src/main.js +2 -2
- package/framework/v0.3.11/package.json +9 -0
- package/gna.js +4 -4
- package/llms.txt +16 -80
- package/package.json +2 -2
- package/schema/app.json +33 -0
- package/schema/connectors.json +40 -2
- package/schema/locales.json +38 -0
- package/script/check_def_framework_consistency.js +239 -0
- package/script/post_install.js +28 -1
- package/script/version_compare.js +124 -0
- package/framework/v0.3.10/VERSION +0 -1
- package/framework/v0.3.10/core/asset/plugin/dist/vendor/gina/js/gina.min.js.br +0 -0
- package/framework/v0.3.10/core/asset/plugin/dist/vendor/gina/js/gina.min.js.gz +0 -0
- package/framework/v0.3.10/core/asset/plugin/dist/vendor/gina/js/gina.onload.min.js.br +0 -0
- package/framework/v0.3.10/core/asset/plugin/dist/vendor/gina/js/gina.onload.min.js.gz +0 -0
- package/framework/v0.3.10/helpers/text.js +0 -71
- package/framework/v0.3.10/package.json +0 -8
- /package/framework/{v0.3.10 → v0.3.11}/AUTHORS +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/LICENSE +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/asset/html/nolayout.html +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/asset/html/static.html +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/asset/img/android-chrome-192x192.png +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/asset/img/android-chrome-512x512.png +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/asset/img/apple-touch-icon.png +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/asset/img/favicon-16x16.png +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/asset/img/favicon-32x32.png +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/asset/img/favicon.ico +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/asset/plugin/README.md +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/asset/plugin/dist/vendor/gina/beemaster/beemaster.css +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/asset/plugin/dist/vendor/gina/beemaster/beemaster.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/asset/plugin/dist/vendor/gina/beemaster/index.html +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/asset/plugin/dist/vendor/gina/css/gina.min.css +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/asset/plugin/dist/vendor/gina/css/gina.min.css.br +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/asset/plugin/dist/vendor/gina/css/gina.min.css.gz +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/asset/plugin/dist/vendor/gina/html/statusbar.html +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/asset/plugin/dist/vendor/gina/html/statusbar.html.br +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/asset/plugin/dist/vendor/gina/html/statusbar.html.gz +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/asset/plugin/dist/vendor/gina/inspector/have_heart_one-webfont.woff2 +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/asset/plugin/dist/vendor/gina/inspector/index.html +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/asset/plugin/dist/vendor/gina/inspector/inspector.css +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/asset/plugin/dist/vendor/gina/inspector/inspector.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/asset/plugin/dist/vendor/gina/inspector/logo.svg +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/config.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/connectors/ai/index.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/connectors/ai/lib/connector.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/connectors/couchbase/index.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/connectors/couchbase/lib/connector.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/connectors/couchbase/lib/connector.v2.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/connectors/couchbase/lib/connector.v3.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/connectors/couchbase/lib/connector.v4.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/connectors/couchbase/lib/n1ql.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/connectors/couchbase/lib/session-store.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/connectors/couchbase/lib/session-store.v2.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/connectors/couchbase/lib/session-store.v3.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/connectors/couchbase/lib/session-store.v4.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/connectors/mysql/index.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/connectors/mysql/lib/connector.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/connectors/postgresql/index.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/connectors/postgresql/lib/connector.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/connectors/redis/index.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/connectors/redis/lib/session-store.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/connectors/sql-parser.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/connectors/sqlite/index.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/connectors/sqlite/lib/connector.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/connectors/sqlite/lib/session-store.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/content.encoding +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/controller/controller.framework.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/controller/controller.render-json.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/controller/controller.render-nunjucks.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/controller/controller.render-stream.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/controller/controller.render-swig.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/controller/controller.render-v1.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/controller/index.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/deps/busboy-1.6.0/LICENSE +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/deps/busboy-1.6.0/README.md +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/deps/busboy-1.6.0/lib/index.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/deps/busboy-1.6.0/lib/types/multipart.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/deps/busboy-1.6.0/lib/types/urlencoded.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/deps/busboy-1.6.0/lib/utils.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/deps/busboy-1.6.0/package.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/deps/streamsearch-1.1.0/LICENSE +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/deps/streamsearch-1.1.0/lib/sbmh.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/deps/streamsearch-1.1.0/package.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/dev/index.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/dev/lib/class.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/dev/lib/factory.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/dev/lib/tools.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/locales/README.md +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/locales/currency.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/locales/dist/language/en.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/locales/dist/language/fr.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/locales/dist/region/en.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/locales/dist/region/fr.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/locales/index.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/mime.types +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/model/entity.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/model/index.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/model/template/entityFactory.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/model/template/index.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/plugins/README.md +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/plugins/index.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/plugins/lib/csrf/README.md +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/plugins/lib/csrf/package.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/plugins/lib/csrf/src/main.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/plugins/lib/file/README.md +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/plugins/lib/file/build.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/plugins/lib/file/package.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/plugins/lib/intl/README.md +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/plugins/lib/intl/build.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/plugins/lib/intl/package.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/plugins/lib/intl/src/main.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/plugins/lib/session/README.md +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/plugins/lib/session/package.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/plugins/lib/session/src/main.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/plugins/lib/storage/README.md +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/plugins/lib/storage/build.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/plugins/lib/storage/package.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/plugins/lib/storage/src/main.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/plugins/lib/validator/README.md +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/plugins/lib/validator/build.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/plugins/lib/validator/package.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/plugins/lib/validator/src/form-validator.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/plugins/lib/validator/src/main.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/router.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/server.express.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/status.codes +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/template/_gitignore +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/template/boilerplate/bundle/config/app.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/template/boilerplate/bundle/config/connectors.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/template/boilerplate/bundle/config/routing.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/template/boilerplate/bundle/config/settings.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/template/boilerplate/bundle/config/settings.server.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/template/boilerplate/bundle/config/templates.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/template/boilerplate/bundle/config/watchers.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/template/boilerplate/bundle/controllers/controller.content.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/template/boilerplate/bundle/controllers/controller.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/template/boilerplate/bundle/controllers/setup.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/template/boilerplate/bundle/index.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/template/boilerplate/bundle_namespace/controllers/controller.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/template/boilerplate/bundle_public/css/default.css +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/template/boilerplate/bundle_public/css/home.css +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/template/boilerplate/bundle_public/css/vendor/readme.md +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/template/boilerplate/bundle_public/favicon.ico +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/template/boilerplate/bundle_public/js/vendor/readme.md +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/template/boilerplate/bundle_public/readme.md +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/template/boilerplate/bundle_templates/handlers/main.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/template/boilerplate/bundle_templates/html/content/homepage.html +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/template/boilerplate/bundle_templates/html/includes/error-msg-noscript.html +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/template/boilerplate/bundle_templates/html/includes/error-msg-outdated-browser.html +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/template/boilerplate/bundle_templates/html/layouts/main.html +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/template/command/gina.bat.tpl +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/template/command/gina.tpl +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/template/conf/env.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/template/conf/manifest.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/template/conf/package.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/template/conf/statics.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/template/conf/templates.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/template/error/client/json/401.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/template/error/client/json/403.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/template/error/client/json/404.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/template/error/server/html/50x.html +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/template/error/server/json/500.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/template/error/server/json/503.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/core/template/extensions/logger/config.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/helpers/console.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/helpers/context.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/helpers/data/LICENSE +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/helpers/data/README.md +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/helpers/data/package.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/helpers/data/src/main.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/helpers/dateFormat.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/helpers/index.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/helpers/json/LICENSE +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/helpers/json/README.md +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/helpers/json/package.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/helpers/json/src/main.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/helpers/path.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/helpers/plugins/README.md +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/helpers/plugins/package.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/helpers/plugins/src/api-error.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/helpers/plugins/src/main.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/helpers/prototypes.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/helpers/task.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/archiver/README.md +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/archiver/build.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/archiver/package.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/archiver/src/dep/jszip.min.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/archiver/src/main.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/async/package.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/async/src/main.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cache/README.md +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cache/build.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cache/package.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cache/src/main.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/aliases.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/bundle/add.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/bundle/arguments.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/bundle/build.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/bundle/copy.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/bundle/cp.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/bundle/help.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/bundle/help.txt +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/bundle/list.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/bundle/mcp-start.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/bundle/mcp.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/bundle/oas.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/bundle/openapi.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/bundle/remove.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/bundle/rename.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/bundle/restart.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/bundle/rm.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/bundle/start.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/bundle/status.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/bundle/stop.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/cache/stats.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/connector/arguments.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/connector/help.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/connector/list.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/connector/rm.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/env/add.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/env/get.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/env/help.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/env/help.txt +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/env/link-dev.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/env/list.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/env/remove.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/env/rm.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/env/set.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/env/unset.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/env/use.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/framework/arguments.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/framework/build.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/framework/dot.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/framework/get.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/framework/help.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/framework/help.txt +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/framework/init.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/framework/link-node-modules.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/framework/link.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/framework/msg.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/framework/open.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/framework/restart.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/framework/set.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/framework/start.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/framework/status.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/framework/stop.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/framework/tail.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/framework/update.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/framework/version.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/gina-dev.1.md +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/gina-framework.1.md +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/gina.1.md +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/helper.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/index.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/inspector/help.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/inspector/help.txt +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/inspector/open.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/minion/help.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/minion/help.txt +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/msg.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/port/help.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/port/help.txt +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/port/inc/scan.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/port/list.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/port/reset.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/port/set.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/project/add.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/project/arguments.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/project/build.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/project/help.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/project/help.txt +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/project/import.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/project/list.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/project/move.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/project/remove.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/project/rename.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/project/restart.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/project/rm.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/project/start.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/project/status.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/project/stop.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/protocol/help.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/protocol/help.txt +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/protocol/list.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/protocol/set.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/scope/add.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/scope/help.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/scope/help.txt +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/scope/link-local.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/scope/link-production.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/scope/list.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/scope/remove.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/scope/rm.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/scope/use.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/service/help.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/service/help.txt +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/service/list.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cmd/view/add.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/collection/README.md +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/collection/build.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/collection/package.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/collection/src/main.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/config.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/connector-registry/package.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cron/README.md +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cron/package.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/cron/src/main.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/domain/LICENSE +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/domain/README.md +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/domain/package.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/domain/src/main.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/generator/index.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/inherits/LICENSE +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/inherits/README.md +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/inherits/package.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/inherits/src/main.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/inspector-redact/package.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/inspector-redact/src/main.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/logger/README.md +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/logger/package.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/logger/src/containers/default/index.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/logger/src/containers/file/index.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/logger/src/containers/file/lib/logrotator/README.md +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/logger/src/containers/file/lib/logrotator/index.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/logger/src/containers/mq/index.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/logger/src/containers/mq/listener.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/logger/src/containers/mq/speaker.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/logger/src/helper.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/logger/src/main.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/math/index.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/mcp-dispatch/package.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/mcp-dispatch/src/main.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/mcp-http/package.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/mcp-http/src/main.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/mcp-server/package.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/mcp-server/src/main.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/merge/README.md +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/merge/package.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/merge/src/main.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/model.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/nunjucks-filters/README.md +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/nunjucks-filters/package.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/nunjucks-resolver/package.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/nunjucks-resolver/src/main.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/proc.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/routing/README.md +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/routing/build.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/routing/package.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/routing/src/radix.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/routing-introspect/package.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/routing-introspect/src/main.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/session-store.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/shell.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/state.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/swig-filters/README.md +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/swig-filters/package.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/swig-resolver/package.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/url/README.md +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/url/index.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/url/routing.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/uuid/package.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/uuid/src/main.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/validator.js +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/watcher/package.json +0 -0
- /package/framework/{v0.3.10 → v0.3.11}/lib/watcher/src/main.js +0 -0
|
@@ -0,0 +1,463 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the gina package.
|
|
3
|
+
* Copyright (c) 2009-2026 Rhinostone <contact@gina.io>
|
|
4
|
+
*
|
|
5
|
+
* For the full copyright and license information, please view the LICENSE
|
|
6
|
+
* file that was distributed with this source code.
|
|
7
|
+
*/
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
var fs = require('fs');
|
|
11
|
+
var loader = require('./lib/pipeline-loader');
|
|
12
|
+
var lib = require('./../../../lib') || require.cache[require.resolve('./../../../lib')];
|
|
13
|
+
var inherits = lib.inherits;
|
|
14
|
+
var console = lib.logger;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* MongoDB ORM connector.
|
|
18
|
+
*
|
|
19
|
+
* Wires entity classes with Mongo operations described in pipeline files
|
|
20
|
+
* under the bundle's `pipelines/` directory. Each pipeline file is a JSON
|
|
21
|
+
* document describing one operation; an optional leading JSDoc block
|
|
22
|
+
* carries `@param` / `@return` annotations that the connector uses for
|
|
23
|
+
* argument coercion and result coercion.
|
|
24
|
+
*
|
|
25
|
+
* Bundle model layout:
|
|
26
|
+
* ```
|
|
27
|
+
* models/
|
|
28
|
+
* <database>/
|
|
29
|
+
* entities/
|
|
30
|
+
* user.js ← entity class
|
|
31
|
+
* pipelines/
|
|
32
|
+
* User/
|
|
33
|
+
* findById.json ← {"op":"findOne","filter":{"_id":{"$arg":0}}}
|
|
34
|
+
* findAll.json
|
|
35
|
+
* insert.json
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* Pipeline file format:
|
|
39
|
+
* ```json
|
|
40
|
+
* /*
|
|
41
|
+
* * @param {objectid} arg0 user id
|
|
42
|
+
* * @return {object}
|
|
43
|
+
* */
|
|
44
|
+
* { "op": "findOne", "filter": { "_id": {"$arg": 0}, "_scope": "$scope" } }
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* Supported `op` values map to the official mongodb driver:
|
|
48
|
+
* findOne | find | aggregate | countDocuments
|
|
49
|
+
* insertOne | insertMany
|
|
50
|
+
* updateOne | updateMany | replaceOne
|
|
51
|
+
* deleteOne | deleteMany
|
|
52
|
+
*
|
|
53
|
+
* `@return` annotation controls result shape:
|
|
54
|
+
* {object} → first doc / single result, or null
|
|
55
|
+
* {array} → array of docs
|
|
56
|
+
* {boolean} → for writes: acknowledged + something happened; for reads: rowLength > 0
|
|
57
|
+
* {number} → numeric result (countDocuments, modifiedCount, etc.)
|
|
58
|
+
* (none) → raw driver result
|
|
59
|
+
*
|
|
60
|
+
* Methods return a native Promise with `.onComplete(cb)` for backward
|
|
61
|
+
* compatibility, OR accept a trailing callback in node-style.
|
|
62
|
+
*
|
|
63
|
+
* Argument placeholders inside the pipeline body use `{"$arg": N}`
|
|
64
|
+
* (positional). ObjectId literals use `{"$oid": "<hex>"}`. The literal
|
|
65
|
+
* string `"$scope"` is substituted at load time with the bundle's
|
|
66
|
+
* data isolation scope.
|
|
67
|
+
*
|
|
68
|
+
* @class Mongodb
|
|
69
|
+
* @constructor
|
|
70
|
+
* @param {object} conn - mongodb Db instance from MongodbConnector.onReady
|
|
71
|
+
* @param {object} infos - { model, bundle, database, scope }
|
|
72
|
+
* @returns {object} - Entity class map: { UserEntity: Constructor, … }
|
|
73
|
+
*/
|
|
74
|
+
function Mongodb(conn, infos) {
|
|
75
|
+
var envIsDev = ( /^true$/i.test(process.env.NODE_ENV_IS_DEV) ) ? true : false;
|
|
76
|
+
var isCacheless = (process.env.NODE_ENV_IS_DEV == 'false') ? false : true;
|
|
77
|
+
|
|
78
|
+
// ObjectId from the runtime-loaded mongodb package. require() is cached
|
|
79
|
+
// since connector.js already loaded it during the connect cycle.
|
|
80
|
+
var ObjectId;
|
|
81
|
+
try {
|
|
82
|
+
var driverPath = _(getPath('project') + '/node_modules/mongodb', true);
|
|
83
|
+
ObjectId = require(driverPath).ObjectId;
|
|
84
|
+
} catch (e) {
|
|
85
|
+
// Not fatal here — only matters if a pipeline file uses {$oid}
|
|
86
|
+
// or @param {objectid}. Methods that touch those will throw at
|
|
87
|
+
// query time with a clearer error.
|
|
88
|
+
ObjectId = null;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
var init = function(conn, infos) {
|
|
92
|
+
var EntitySuperClass = null;
|
|
93
|
+
var entitiesPath = getPath('bundle') + '/models/' + infos.database + '/entities';
|
|
94
|
+
var files = [];
|
|
95
|
+
var entities = {};
|
|
96
|
+
var entityName = '';
|
|
97
|
+
var Entity = null;
|
|
98
|
+
var className = null;
|
|
99
|
+
var filename = null;
|
|
100
|
+
|
|
101
|
+
filename = getPath('gina').core + '/model/entity.js';
|
|
102
|
+
if (isCacheless) {
|
|
103
|
+
delete require.cache[require.resolve(_(filename, true))];
|
|
104
|
+
}
|
|
105
|
+
EntitySuperClass = require(_(filename, true));
|
|
106
|
+
|
|
107
|
+
if (!fs.existsSync(entitiesPath)) {
|
|
108
|
+
new _(entitiesPath).mkdirSync();
|
|
109
|
+
}
|
|
110
|
+
files = fs.readdirSync(entitiesPath);
|
|
111
|
+
|
|
112
|
+
for (var f = 0, fLen = files.length; f < fLen; ++f) {
|
|
113
|
+
if ( /^\./.test(files[f]) || !/\.js$/i.test(files[f]) ) continue;
|
|
114
|
+
|
|
115
|
+
if (isCacheless) {
|
|
116
|
+
delete require.cache[require.resolve(_(entitiesPath + '/' + files[f], true))];
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
entityName = files[f].replace(/\.js$/i, '');
|
|
120
|
+
className = entityName.substring(0, 1).toUpperCase() + entityName.substring(1);
|
|
121
|
+
|
|
122
|
+
Entity = require(_(entitiesPath + '/' + files[f], true));
|
|
123
|
+
if (typeof Entity !== 'function') continue;
|
|
124
|
+
|
|
125
|
+
Entity = inherits(Entity, EntitySuperClass);
|
|
126
|
+
|
|
127
|
+
Entity.prototype.name = className;
|
|
128
|
+
Entity.prototype.model = infos.model;
|
|
129
|
+
Entity.prototype.bundle = infos.bundle;
|
|
130
|
+
Entity.prototype.database = infos.database;
|
|
131
|
+
Entity.prototype._collection = entityName;
|
|
132
|
+
Entity.prototype._scope = infos.scope || process.env.NODE_SCOPE;
|
|
133
|
+
Entity.prototype._filename = _(entitiesPath + '/' + files[f], true);
|
|
134
|
+
|
|
135
|
+
entities[className] = Entity;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
var pipelinesDir = _(getPath('bundle') + '/models/' + infos.database + '/pipelines');
|
|
139
|
+
if (fs.existsSync(pipelinesDir)) {
|
|
140
|
+
var entries = fs.readdirSync(pipelinesDir);
|
|
141
|
+
for (var s = 0, sLen = entries.length; s < sLen; s++) {
|
|
142
|
+
if ( /^\./.test(entries[s]) ) continue;
|
|
143
|
+
loadPipelines(entities, conn, _(pipelinesDir + '/' + entries[s]), infos.scope);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return entities;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
var loadPipelines = function(entities, conn, dir, scope) {
|
|
152
|
+
var stat = fs.statSync(dir);
|
|
153
|
+
if (!stat.isDirectory()) return;
|
|
154
|
+
|
|
155
|
+
var arr = dir.split(/\//g);
|
|
156
|
+
var entityName = arr[arr.length - 1];
|
|
157
|
+
entityName = entityName.charAt(0).toUpperCase() + entityName.slice(1);
|
|
158
|
+
|
|
159
|
+
if (!entities[entityName]) return;
|
|
160
|
+
|
|
161
|
+
var pipelineFiles = fs.readdirSync(dir);
|
|
162
|
+
for (var f = 0, fLen = pipelineFiles.length; f < fLen; f++) {
|
|
163
|
+
if ( /^\./.test(pipelineFiles[f]) || !/\.json$/i.test(pipelineFiles[f]) ) continue;
|
|
164
|
+
readPipeline(entities, conn, entityName, _(dir + '/' + pipelineFiles[f], true), scope);
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
var readPipeline = function(entities, conn, entityName, source, scope) {
|
|
170
|
+
var arr = source.split(/\//g);
|
|
171
|
+
var name = arr[arr.length - 1].replace(/\.json$/i, '');
|
|
172
|
+
|
|
173
|
+
if (!entities[entityName]) return;
|
|
174
|
+
if (typeof entities[entityName].prototype[name] !== 'undefined') return;
|
|
175
|
+
|
|
176
|
+
var rawSource = fs.readFileSync(source).toString();
|
|
177
|
+
|
|
178
|
+
var parsed;
|
|
179
|
+
try {
|
|
180
|
+
parsed = loader.parse(rawSource, scope || process.env.NODE_SCOPE);
|
|
181
|
+
} catch (e) {
|
|
182
|
+
console.error('[Mongodb] failed to parse pipeline file: ' + source + '\n' + e.message);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
var paramTypes = parsed.paramTypes;
|
|
187
|
+
var returnType = parsed.returnType;
|
|
188
|
+
var body = parsed.body;
|
|
189
|
+
var op = body.op;
|
|
190
|
+
|
|
191
|
+
if (!op) {
|
|
192
|
+
console.error('[Mongodb] pipeline file missing `op` field: ' + source);
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
var trigger = 'MQL:' + entityName.toLowerCase() + '#' + name;
|
|
197
|
+
var isWriteOp = /^(insert|update|delete|replace|findOneAndUpdate|findOneAndDelete|findOneAndReplace)/i.test(op);
|
|
198
|
+
|
|
199
|
+
// Coerce a Mongo driver result to the annotated return type.
|
|
200
|
+
// Reads (find/findOne/aggregate) return docs or arrays directly;
|
|
201
|
+
// writes return InsertOneResult / UpdateResult / DeleteResult.
|
|
202
|
+
var coerce = function(result, isWrite) {
|
|
203
|
+
if (returnType === 'boolean') {
|
|
204
|
+
if (isWrite) {
|
|
205
|
+
if (!result || result.acknowledged !== true) return false;
|
|
206
|
+
if (typeof result.insertedId !== 'undefined' && result.insertedId !== null) return true;
|
|
207
|
+
if (typeof result.modifiedCount === 'number' && result.modifiedCount > 0) return true;
|
|
208
|
+
if (typeof result.deletedCount === 'number' && result.deletedCount > 0) return true;
|
|
209
|
+
if (typeof result.upsertedCount === 'number' && result.upsertedCount > 0) return true;
|
|
210
|
+
if (typeof result.matchedCount === 'number' && result.matchedCount > 0) return true;
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
return Array.isArray(result) ? result.length > 0 : !!result;
|
|
214
|
+
}
|
|
215
|
+
if (returnType === 'number') {
|
|
216
|
+
if (typeof result === 'number') return result;
|
|
217
|
+
if (Array.isArray(result)) return result.length;
|
|
218
|
+
if (result && typeof result.modifiedCount === 'number') return result.modifiedCount;
|
|
219
|
+
if (result && typeof result.deletedCount === 'number') return result.deletedCount;
|
|
220
|
+
if (result && typeof result.insertedCount === 'number') return result.insertedCount;
|
|
221
|
+
if (result && typeof result.matchedCount === 'number') return result.matchedCount;
|
|
222
|
+
return 0;
|
|
223
|
+
}
|
|
224
|
+
if (returnType === 'object') {
|
|
225
|
+
if (Array.isArray(result)) return result.length > 0 ? result[0] : null;
|
|
226
|
+
return result || null;
|
|
227
|
+
}
|
|
228
|
+
if (returnType === 'array') {
|
|
229
|
+
if (Array.isArray(result)) return result;
|
|
230
|
+
return result ? [result] : [];
|
|
231
|
+
}
|
|
232
|
+
return result;
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
// Pre-execute coercion of arguments based on @param annotations.
|
|
236
|
+
// Mongo BSON shapes: objectid, string, int, long, double, boolean, date.
|
|
237
|
+
// Decimal128 / Binary intentionally deferred to a follow-up.
|
|
238
|
+
var castParam = function(value, type) {
|
|
239
|
+
if (value === null || typeof value === 'undefined') return value;
|
|
240
|
+
switch (type) {
|
|
241
|
+
case 'objectid':
|
|
242
|
+
if (!ObjectId) {
|
|
243
|
+
throw new Error('[Mongodb] @param {objectid} requires the mongodb driver to be installed in your project');
|
|
244
|
+
}
|
|
245
|
+
return (value instanceof ObjectId) ? value : new ObjectId(value);
|
|
246
|
+
case 'int':
|
|
247
|
+
case 'int32':
|
|
248
|
+
return parseInt(value, 10);
|
|
249
|
+
case 'long':
|
|
250
|
+
case 'int64':
|
|
251
|
+
return (typeof value === 'bigint') ? value : parseInt(value, 10);
|
|
252
|
+
case 'double':
|
|
253
|
+
case 'number':
|
|
254
|
+
return (typeof value === 'number') ? value
|
|
255
|
+
: parseFloat(String(value).replace(/,/, '.'));
|
|
256
|
+
case 'boolean':
|
|
257
|
+
return /^true$/i.test(String(value));
|
|
258
|
+
case 'string':
|
|
259
|
+
case 'text':
|
|
260
|
+
return String(value);
|
|
261
|
+
case 'date':
|
|
262
|
+
case 'timestamp':
|
|
263
|
+
return (value instanceof Date) ? value : new Date(value);
|
|
264
|
+
default:
|
|
265
|
+
return value;
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
// Walk the pipeline body, replacing {$arg: N} with args[N] and
|
|
270
|
+
// {$oid: "<hex>"} with new ObjectId(...). Returns a fresh tree —
|
|
271
|
+
// never mutates `body` so the prototype method is reusable.
|
|
272
|
+
var resolveArgs = function(node, args) {
|
|
273
|
+
if (Array.isArray(node)) {
|
|
274
|
+
var arrCopy = [];
|
|
275
|
+
for (var i = 0; i < node.length; i++) {
|
|
276
|
+
arrCopy.push(resolveArgs(node[i], args));
|
|
277
|
+
}
|
|
278
|
+
return arrCopy;
|
|
279
|
+
}
|
|
280
|
+
if (node && typeof node === 'object') {
|
|
281
|
+
var keys = Object.keys(node);
|
|
282
|
+
if (keys.length === 1 && keys[0] === '$arg') {
|
|
283
|
+
var idx = node.$arg;
|
|
284
|
+
return (idx >= 0 && idx < args.length) ? args[idx] : null;
|
|
285
|
+
}
|
|
286
|
+
if (keys.length === 1 && keys[0] === '$oid') {
|
|
287
|
+
if (!ObjectId) {
|
|
288
|
+
throw new Error('[Mongodb] {"$oid": ...} requires the mongodb driver to be installed in your project');
|
|
289
|
+
}
|
|
290
|
+
return new ObjectId(node.$oid);
|
|
291
|
+
}
|
|
292
|
+
var objCopy = {};
|
|
293
|
+
for (var k = 0; k < keys.length; k++) {
|
|
294
|
+
objCopy[keys[k]] = resolveArgs(node[keys[k]], args);
|
|
295
|
+
}
|
|
296
|
+
return objCopy;
|
|
297
|
+
}
|
|
298
|
+
return node;
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
entities[entityName].prototype[name] = function() {
|
|
302
|
+
var self = this;
|
|
303
|
+
var args = Array.prototype.slice.call(arguments);
|
|
304
|
+
var _mainCallback = null;
|
|
305
|
+
|
|
306
|
+
if (typeof args[args.length - 1] === 'function') {
|
|
307
|
+
_mainCallback = args.pop();
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
for (var t = 0, tLen = paramTypes.length; t < tLen && t < args.length; t++) {
|
|
311
|
+
args[t] = castParam(args[t], paramTypes[t]);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
var resolvedBody;
|
|
315
|
+
try {
|
|
316
|
+
resolvedBody = resolveArgs(body, args);
|
|
317
|
+
} catch (e) {
|
|
318
|
+
if (_mainCallback) return _mainCallback(e);
|
|
319
|
+
return Promise.reject(e);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
var coll = conn.collection(self._collection);
|
|
323
|
+
var execPromise;
|
|
324
|
+
try {
|
|
325
|
+
switch (op) {
|
|
326
|
+
case 'findOne':
|
|
327
|
+
execPromise = coll.findOne(resolvedBody.filter || {}, resolvedBody.options || {});
|
|
328
|
+
break;
|
|
329
|
+
case 'find':
|
|
330
|
+
execPromise = coll.find(resolvedBody.filter || {}, resolvedBody.options || {}).toArray();
|
|
331
|
+
break;
|
|
332
|
+
case 'aggregate':
|
|
333
|
+
execPromise = coll.aggregate(resolvedBody.pipeline || [], resolvedBody.options || {}).toArray();
|
|
334
|
+
break;
|
|
335
|
+
case 'countDocuments':
|
|
336
|
+
execPromise = coll.countDocuments(resolvedBody.filter || {}, resolvedBody.options || {});
|
|
337
|
+
break;
|
|
338
|
+
case 'insertOne':
|
|
339
|
+
execPromise = coll.insertOne(resolvedBody.doc || {}, resolvedBody.options || {});
|
|
340
|
+
break;
|
|
341
|
+
case 'insertMany':
|
|
342
|
+
execPromise = coll.insertMany(resolvedBody.docs || [], resolvedBody.options || {});
|
|
343
|
+
break;
|
|
344
|
+
case 'updateOne':
|
|
345
|
+
execPromise = coll.updateOne(resolvedBody.filter || {}, resolvedBody.update || {}, resolvedBody.options || {});
|
|
346
|
+
break;
|
|
347
|
+
case 'updateMany':
|
|
348
|
+
execPromise = coll.updateMany(resolvedBody.filter || {}, resolvedBody.update || {}, resolvedBody.options || {});
|
|
349
|
+
break;
|
|
350
|
+
case 'replaceOne':
|
|
351
|
+
execPromise = coll.replaceOne(resolvedBody.filter || {}, resolvedBody.replacement || {}, resolvedBody.options || {});
|
|
352
|
+
break;
|
|
353
|
+
case 'deleteOne':
|
|
354
|
+
execPromise = coll.deleteOne(resolvedBody.filter || {}, resolvedBody.options || {});
|
|
355
|
+
break;
|
|
356
|
+
case 'deleteMany':
|
|
357
|
+
execPromise = coll.deleteMany(resolvedBody.filter || {}, resolvedBody.options || {});
|
|
358
|
+
break;
|
|
359
|
+
default:
|
|
360
|
+
var unknownErr = new Error('[Mongodb] unknown op `' + op + '` in ' + source);
|
|
361
|
+
if (_mainCallback) return _mainCallback(unknownErr);
|
|
362
|
+
return Promise.reject(unknownErr);
|
|
363
|
+
}
|
|
364
|
+
} catch (e) {
|
|
365
|
+
if (_mainCallback) return _mainCallback(e);
|
|
366
|
+
return Promise.reject(e);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
if (envIsDev) {
|
|
370
|
+
console.debug('[ ' + trigger + ' ] op=' + op + ' body=' + JSON.stringify(resolvedBody));
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
var _devLog = null, _queryEntry = null;
|
|
374
|
+
if (envIsDev) {
|
|
375
|
+
var _alsStore = process.gina && process.gina._queryALS
|
|
376
|
+
? process.gina._queryALS.getStore() : null;
|
|
377
|
+
_devLog = _alsStore ? _alsStore._devQueryLog : null;
|
|
378
|
+
if (_devLog) {
|
|
379
|
+
_queryEntry = {
|
|
380
|
+
type : 'MQL',
|
|
381
|
+
trigger : entityName.toLowerCase() + '#' + name,
|
|
382
|
+
statement : op + ' ' + JSON.stringify(resolvedBody),
|
|
383
|
+
params : args.length > 0 ? args.slice() : [],
|
|
384
|
+
durationMs : 0,
|
|
385
|
+
resultCount : 0,
|
|
386
|
+
resultSize : 0,
|
|
387
|
+
indexes : null,
|
|
388
|
+
error : null,
|
|
389
|
+
source : source || '',
|
|
390
|
+
origin : infos.bundle,
|
|
391
|
+
connector : 'mongodb'
|
|
392
|
+
};
|
|
393
|
+
_queryEntry._startMs = Date.now();
|
|
394
|
+
_devLog.push(_queryEntry);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
if (_mainCallback === null) {
|
|
399
|
+
var _resolve, _reject, _internalData;
|
|
400
|
+
|
|
401
|
+
var _promise = new Promise(function(resolve, reject) {
|
|
402
|
+
_resolve = resolve;
|
|
403
|
+
_reject = reject;
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
_promise.onComplete = function(cb) {
|
|
407
|
+
_promise.then(
|
|
408
|
+
function() { cb(null, _internalData); },
|
|
409
|
+
function(err) { cb(err); }
|
|
410
|
+
);
|
|
411
|
+
return _promise;
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
execPromise.then(function(result) {
|
|
415
|
+
if (_queryEntry) {
|
|
416
|
+
_queryEntry.durationMs = Date.now() - _queryEntry._startMs;
|
|
417
|
+
}
|
|
418
|
+
var raw = coerce(result, isWriteOp);
|
|
419
|
+
if (_queryEntry) {
|
|
420
|
+
_queryEntry.resultCount = raw ? (Array.isArray(raw) ? raw.length : 1) : 0;
|
|
421
|
+
try { _queryEntry.resultSize = raw ? JSON.stringify(raw).length : 0; } catch(_e) { _queryEntry.resultSize = 0; }
|
|
422
|
+
}
|
|
423
|
+
_internalData = raw;
|
|
424
|
+
_resolve(raw);
|
|
425
|
+
}).catch(function(err) {
|
|
426
|
+
if (_queryEntry) {
|
|
427
|
+
_queryEntry.durationMs = Date.now() - _queryEntry._startMs;
|
|
428
|
+
_queryEntry.error = err.message || String(err);
|
|
429
|
+
}
|
|
430
|
+
err.message = '[ ' + source + ' ]\n' + err.message;
|
|
431
|
+
_reject(err);
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
return _promise;
|
|
435
|
+
|
|
436
|
+
} else {
|
|
437
|
+
execPromise.then(function(result) {
|
|
438
|
+
if (_queryEntry) {
|
|
439
|
+
_queryEntry.durationMs = Date.now() - _queryEntry._startMs;
|
|
440
|
+
}
|
|
441
|
+
var raw = coerce(result, isWriteOp);
|
|
442
|
+
if (_queryEntry) {
|
|
443
|
+
_queryEntry.resultCount = raw ? (Array.isArray(raw) ? raw.length : 1) : 0;
|
|
444
|
+
try { _queryEntry.resultSize = raw ? JSON.stringify(raw).length : 0; } catch(_e) { _queryEntry.resultSize = 0; }
|
|
445
|
+
}
|
|
446
|
+
_mainCallback(null, raw);
|
|
447
|
+
}).catch(function(err) {
|
|
448
|
+
if (_queryEntry) {
|
|
449
|
+
_queryEntry.durationMs = Date.now() - _queryEntry._startMs;
|
|
450
|
+
_queryEntry.error = err.message || String(err);
|
|
451
|
+
}
|
|
452
|
+
err.message = '[ ' + source + ' ]\n' + err.message;
|
|
453
|
+
_mainCallback(err);
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
};
|
|
457
|
+
};
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
return init(conn, infos);
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
module.exports = Mongodb;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the gina package.
|
|
3
|
+
* Copyright (c) 2009-2026 Rhinostone <contact@gina.io>
|
|
4
|
+
*
|
|
5
|
+
* For the full copyright and license information, please view the LICENSE
|
|
6
|
+
* file that was distributed with this source code.
|
|
7
|
+
*/
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
var EventEmitter = require('events').EventEmitter;
|
|
11
|
+
var gina = require('../../../../core/gna');
|
|
12
|
+
var lib = gina.lib;
|
|
13
|
+
var console = lib.logger;
|
|
14
|
+
var inherits = lib.inherits;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* MongoDB connector — creates a `mongodb` MongoClient.
|
|
18
|
+
*
|
|
19
|
+
* The `mongodb` driver is loaded from the project's node_modules so the
|
|
20
|
+
* framework has zero hard dependency on it. Install it in your project:
|
|
21
|
+
* npm install mongodb
|
|
22
|
+
*
|
|
23
|
+
* connectors.json entry (URI form, preferred when available):
|
|
24
|
+
* {
|
|
25
|
+
* "mydb": {
|
|
26
|
+
* "connector": "mongodb",
|
|
27
|
+
* "uri": "mongodb://user:pass@localhost:27017/mydb?authSource=admin",
|
|
28
|
+
* "database": "mydb"
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
*
|
|
32
|
+
* connectors.json entry (decomposed fields, schema-parity with other
|
|
33
|
+
* connectors):
|
|
34
|
+
* {
|
|
35
|
+
* "mydb": {
|
|
36
|
+
* "connector": "mongodb",
|
|
37
|
+
* "host": "127.0.0.1",
|
|
38
|
+
* "port": 27017,
|
|
39
|
+
* "username": "admin",
|
|
40
|
+
* "password": "secret",
|
|
41
|
+
* "database": "mydb",
|
|
42
|
+
* "authSource": "admin",
|
|
43
|
+
* "replicaSet": "rs0"
|
|
44
|
+
* }
|
|
45
|
+
* }
|
|
46
|
+
*
|
|
47
|
+
* `database` names both the logical model directory
|
|
48
|
+
* (`models/<database>/entities/`) and the Mongo db name selected via
|
|
49
|
+
* `client.db(database)`. When `uri` is present it takes precedence over
|
|
50
|
+
* the decomposed fields, but `database` is still required and is used
|
|
51
|
+
* to select the db on the client.
|
|
52
|
+
*
|
|
53
|
+
* @class MongodbConnector
|
|
54
|
+
* @constructor
|
|
55
|
+
* @param {object} conf - Connector config from connectors.json
|
|
56
|
+
* @param {string} conf.database - DB name (also the model dir name)
|
|
57
|
+
* @param {string} [conf.uri] - Full mongodb:// or mongodb+srv:// URI
|
|
58
|
+
* @param {string} [conf.host] - Host (used when uri absent)
|
|
59
|
+
* @param {number|string} [conf.port] - Port (default 27017, used when uri absent)
|
|
60
|
+
* @param {string} [conf.username] - Auth username (used when uri absent)
|
|
61
|
+
* @param {string} [conf.password] - Auth password (used when uri absent)
|
|
62
|
+
* @param {string} [conf.authSource] - Authentication db (typically "admin")
|
|
63
|
+
* @param {string} [conf.replicaSet] - Replica set name
|
|
64
|
+
* @param {object|boolean}[conf.ssl] - TLS configuration; `true` enables defaults,
|
|
65
|
+
* an object is merged into client options.
|
|
66
|
+
*/
|
|
67
|
+
function MongodbConnector(conf) {
|
|
68
|
+
var _client = null;
|
|
69
|
+
var _db = null;
|
|
70
|
+
var _dbName = null;
|
|
71
|
+
var _err = null;
|
|
72
|
+
|
|
73
|
+
var init = function(conf) {
|
|
74
|
+
var mongodb;
|
|
75
|
+
try {
|
|
76
|
+
var driverPath = _(getPath('project') + '/node_modules/mongodb', true);
|
|
77
|
+
mongodb = require(driverPath);
|
|
78
|
+
} catch (e) {
|
|
79
|
+
_err = new Error(
|
|
80
|
+
'[MongodbConnector] mongodb is not installed in your project.\n'
|
|
81
|
+
+ 'Run: npm install mongodb\n'
|
|
82
|
+
+ e.message
|
|
83
|
+
);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
_dbName = conf.database;
|
|
88
|
+
if (!_dbName) {
|
|
89
|
+
_err = new Error('[MongodbConnector] missing required `database` field in connectors.json entry');
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
var uri;
|
|
94
|
+
if (conf.uri) {
|
|
95
|
+
uri = conf.uri;
|
|
96
|
+
} else {
|
|
97
|
+
var host = conf.host || '127.0.0.1';
|
|
98
|
+
var port = conf.port || 27017;
|
|
99
|
+
var auth = '';
|
|
100
|
+
if (conf.username) {
|
|
101
|
+
auth = encodeURIComponent(conf.username);
|
|
102
|
+
if (conf.password) {
|
|
103
|
+
auth += ':' + encodeURIComponent(conf.password);
|
|
104
|
+
}
|
|
105
|
+
auth += '@';
|
|
106
|
+
}
|
|
107
|
+
uri = 'mongodb://' + auth + host + ':' + port + '/' + encodeURIComponent(_dbName);
|
|
108
|
+
var qs = [];
|
|
109
|
+
if (conf.authSource) qs.push('authSource=' + encodeURIComponent(conf.authSource));
|
|
110
|
+
if (conf.replicaSet) qs.push('replicaSet=' + encodeURIComponent(conf.replicaSet));
|
|
111
|
+
if (qs.length) uri += '?' + qs.join('&');
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
var clientOptions = {};
|
|
115
|
+
if (conf.ssl === true) {
|
|
116
|
+
clientOptions.tls = true;
|
|
117
|
+
} else if (conf.ssl && typeof conf.ssl === 'object') {
|
|
118
|
+
clientOptions.tls = true;
|
|
119
|
+
for (var k in conf.ssl) {
|
|
120
|
+
if (Object.prototype.hasOwnProperty.call(conf.ssl, k)) {
|
|
121
|
+
clientOptions[k] = conf.ssl[k];
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
try {
|
|
127
|
+
_client = new mongodb.MongoClient(uri, clientOptions);
|
|
128
|
+
_client._name = _dbName;
|
|
129
|
+
console.debug('[MongodbConnector] client created for: ' + _dbName);
|
|
130
|
+
} catch (e) {
|
|
131
|
+
_err = new Error('[MongodbConnector] Failed to create client: ' + e.message);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Register a one-time ready callback. Async — calls `client.connect()`
|
|
137
|
+
* which establishes the TCP connection and verifies authentication.
|
|
138
|
+
*
|
|
139
|
+
* @param {function} fn - `fn(err, conn)` where `conn` is the mongodb Db instance.
|
|
140
|
+
*/
|
|
141
|
+
this.onReady = function(fn) {
|
|
142
|
+
if (_err) return fn(_err, null);
|
|
143
|
+
|
|
144
|
+
_client.connect().then(function() {
|
|
145
|
+
_db = _client.db(_dbName);
|
|
146
|
+
_db._name = _dbName;
|
|
147
|
+
console.debug('[MongodbConnector] connected to: ' + _dbName);
|
|
148
|
+
fn(null, _db);
|
|
149
|
+
}).catch(function(err) {
|
|
150
|
+
fn(new Error('[MongodbConnector] Connection failed: ' + err.message), null);
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
init(conf);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
MongodbConnector = inherits(MongodbConnector, EventEmitter);
|
|
158
|
+
module.exports = MongodbConnector;
|