gina 0.0.9-p91c → 0.1.1-alpha.3
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/INSTALL.md +46 -0
- package/{core/asset/html/static.html → Icon/r} +0 -0
- package/LICENSE +1 -1
- package/README-4Contributors.md +96 -0
- package/README.md +296 -104
- package/bin/cli +287 -0
- package/bin/cli-debug +60 -0
- package/bin/cmd +184 -0
- package/bin/gina +180 -0
- package/config/logger.json +17 -0
- package/doc/framework/cli/doc.json +9 -0
- package/doc/framework/index.md +60 -0
- package/framework/v0.1.1-alpha.3/AUTHORS +7 -0
- package/{core/utils/lib/inherits → framework/v0.1.1-alpha.3}/LICENSE +1 -1
- package/framework/v0.1.1-alpha.3/VERSION +1 -0
- package/{core/locales/dist/language/en.json → framework/v0.1.1-alpha.3/core/asset/html/nolayout.html} +0 -0
- package/{core/locales/dist/language/fr.json → framework/v0.1.1-alpha.3/core/asset/html/static.html} +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/asset/img/android-chrome-192x192.png +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/asset/img/android-chrome-512x512.png +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/asset/img/apple-touch-icon.png +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/asset/img/favicon-16x16.png +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/asset/img/favicon-32x32.png +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/asset/img/favicon.ico +0 -0
- package/framework/v0.1.1-alpha.3/core/asset/js/plugin/dist/gina.js +20904 -0
- package/framework/v0.1.1-alpha.3/core/asset/js/plugin/dist/gina.js.map +56 -0
- package/framework/v0.1.1-alpha.3/core/asset/js/plugin/dist/gina.min.css +1 -0
- package/framework/v0.1.1-alpha.3/core/asset/js/plugin/dist/gina.min.css.map +1 -0
- package/framework/v0.1.1-alpha.3/core/asset/js/plugin/dist/gina.min.js +736 -0
- package/framework/v0.1.1-alpha.3/core/asset/js/plugin/dist/gina.min.js.map +56 -0
- package/framework/v0.1.1-alpha.3/core/asset/js/plugin/dist/gina.onload.min.js +5 -0
- package/framework/v0.1.1-alpha.3/core/asset/js/plugin/dist/gina.onload.min.js.map +8 -0
- package/framework/v0.1.1-alpha.3/core/asset/js/plugin/readme.md +192 -0
- package/framework/v0.1.1-alpha.3/core/asset/js/plugin/uuid.json +23 -0
- package/framework/v0.1.1-alpha.3/core/config.js +2308 -0
- package/framework/v0.1.1-alpha.3/core/connectors/couchbase/index.js +757 -0
- package/framework/v0.1.1-alpha.3/core/connectors/couchbase/lib/connector.js +20 -0
- package/framework/v0.1.1-alpha.3/core/connectors/couchbase/lib/connector.v2.js +429 -0
- package/framework/v0.1.1-alpha.3/core/connectors/couchbase/lib/connector.v3.js +432 -0
- package/framework/v0.1.1-alpha.3/core/connectors/couchbase/lib/n1ql.js +14 -0
- package/framework/v0.1.1-alpha.3/core/connectors/couchbase/lib/session-store.js +21 -0
- package/framework/v0.1.1-alpha.3/core/connectors/couchbase/lib/session-store.v2.js +258 -0
- package/framework/v0.1.1-alpha.3/core/connectors/couchbase/lib/session-store.v3.js +341 -0
- package/{core → framework/v0.1.1-alpha.3/core}/controller/controller.framework.js +3 -2
- package/framework/v0.1.1-alpha.3/core/controller/controller.js +3990 -0
- package/{core → framework/v0.1.1-alpha.3/core}/controller/index.js +5 -5
- package/framework/v0.1.1-alpha.3/core/deps/busboy/.travis.yml +17 -0
- package/framework/v0.1.1-alpha.3/core/deps/busboy/LICENSE +19 -0
- package/framework/v0.1.1-alpha.3/core/deps/busboy/README.md +225 -0
- package/framework/v0.1.1-alpha.3/core/deps/busboy/deps/encoding/encoding-indexes.js +73 -0
- package/framework/v0.1.1-alpha.3/core/deps/busboy/deps/encoding/encoding.js +2391 -0
- package/framework/v0.1.1-alpha.3/core/deps/busboy/lib/main.js +89 -0
- package/framework/v0.1.1-alpha.3/core/deps/busboy/lib/types/multipart.js +328 -0
- package/framework/v0.1.1-alpha.3/core/deps/busboy/lib/types/urlencoded.js +214 -0
- package/framework/v0.1.1-alpha.3/core/deps/busboy/lib/utils.js +191 -0
- package/framework/v0.1.1-alpha.3/core/deps/busboy/package.json +69 -0
- package/framework/v0.1.1-alpha.3/core/deps/swig-client/swig-2.0.0.min.js +5 -0
- package/{core → framework/v0.1.1-alpha.3/core}/dev/index.js +5 -5
- package/{core → framework/v0.1.1-alpha.3/core}/dev/lib/class.js +1 -1
- package/{core → framework/v0.1.1-alpha.3/core}/dev/lib/factory.js +1 -1
- package/{core → framework/v0.1.1-alpha.3/core}/dev/lib/tools.js +0 -0
- package/framework/v0.1.1-alpha.3/core/gna.js +1070 -0
- package/{core → framework/v0.1.1-alpha.3/core}/locales/README.md +41 -2
- package/{core → framework/v0.1.1-alpha.3/core}/locales/currency.json +0 -0
- package/{core/plugins/README.md → framework/v0.1.1-alpha.3/core/locales/dist/language/en.json} +0 -0
- package/{core/plugins/lib/intl/README.md → framework/v0.1.1-alpha.3/core/locales/dist/language/fr.json} +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/locales/dist/region/en.json +0 -0
- package/framework/v0.1.1-alpha.3/core/locales/dist/region/fr.json +9492 -0
- package/{core → framework/v0.1.1-alpha.3/core}/locales/index.js +5 -4
- package/{core → framework/v0.1.1-alpha.3/core}/locales/src/make.js +15 -12
- package/{core → framework/v0.1.1-alpha.3/core}/locales/src/resources/currency.csv +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/locales/src/resources/region.csv +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/locales/src/resources/region.mapping.json +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/mime.types +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/model/entity.js +156 -196
- package/{core → framework/v0.1.1-alpha.3/core}/model/index.js +67 -48
- package/{core → framework/v0.1.1-alpha.3/core}/model/template/entityFactory.js +2 -2
- package/{core → framework/v0.1.1-alpha.3/core}/model/template/index.js +8 -10
- package/{core/plugins/lib/storage → framework/v0.1.1-alpha.3/core/plugins}/README.md +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/plugins/index.js +3 -3
- package/{core/plugins/lib/validator → framework/v0.1.1-alpha.3/core/plugins/lib/file}/README.md +0 -0
- package/{core/plugins/lib/intl → framework/v0.1.1-alpha.3/core/plugins/lib/file}/build.json +0 -0
- package/framework/v0.1.1-alpha.3/core/plugins/lib/file/package.json +25 -0
- package/{core/utils/lib/collection → framework/v0.1.1-alpha.3/core/plugins/lib/intl}/README.md +0 -0
- package/{core/plugins/lib/storage → framework/v0.1.1-alpha.3/core/plugins/lib/intl}/build.json +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/plugins/lib/intl/package.json +3 -3
- package/{core → framework/v0.1.1-alpha.3/core}/plugins/lib/intl/src/main.js +17 -1
- package/{core/utils/lib/routing → framework/v0.1.1-alpha.3/core/plugins/lib/storage}/README.md +0 -0
- package/{core/plugins/lib/validator → framework/v0.1.1-alpha.3/core/plugins/lib/storage}/build.json +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/plugins/lib/storage/package.json +2 -2
- package/{core → framework/v0.1.1-alpha.3/core}/plugins/lib/storage/src/main.js +91 -85
- package/{core/utils/lib/url → framework/v0.1.1-alpha.3/core/plugins/lib/validator}/README.md +0 -0
- package/{core/utils/lib/collection → framework/v0.1.1-alpha.3/core/plugins/lib/validator}/build.json +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/plugins/lib/validator/package.json +3 -3
- package/framework/v0.1.1-alpha.3/core/plugins/lib/validator/src/form-validator.js +1762 -0
- package/framework/v0.1.1-alpha.3/core/plugins/lib/validator/src/main.js +6917 -0
- package/framework/v0.1.1-alpha.3/core/router.js +664 -0
- package/framework/v0.1.1-alpha.3/core/server.express.js +213 -0
- package/framework/v0.1.1-alpha.3/core/server.isaac.js +386 -0
- package/framework/v0.1.1-alpha.3/core/server.js +3010 -0
- package/{core → framework/v0.1.1-alpha.3/core}/status.codes +8 -0
- package/framework/v0.1.1-alpha.3/core/template/boilerplate/bundle/config/app.json +6 -0
- package/framework/v0.1.1-alpha.3/core/template/boilerplate/bundle/config/routing.json +11 -0
- package/framework/v0.1.1-alpha.3/core/template/boilerplate/bundle/config/settings.json +9 -0
- package/framework/v0.1.1-alpha.3/core/template/boilerplate/bundle/config/settings.server.json +30 -0
- package/framework/v0.1.1-alpha.3/core/template/boilerplate/bundle/config/templates.json +42 -0
- package/framework/v0.1.1-alpha.3/core/template/boilerplate/bundle/controllers/controller.content.js +39 -0
- package/framework/v0.1.1-alpha.3/core/template/boilerplate/bundle/controllers/controller.js +30 -0
- package/framework/v0.1.1-alpha.3/core/template/boilerplate/bundle/controllers/setup.js +111 -0
- package/{core/template/samples → framework/v0.1.1-alpha.3/core/template/boilerplate}/bundle/index.js +0 -0
- package/{core/template/samples/bundle → framework/v0.1.1-alpha.3/core/template/boilerplate/bundle_namespace}/controllers/controller.js +9 -7
- package/{core/template/views → framework/v0.1.1-alpha.3/core/template/boilerplate/bundle_public}/css/default.css +0 -0
- package/{core/template/views → framework/v0.1.1-alpha.3/core/template/boilerplate/bundle_public}/css/vendor/readme.md +0 -0
- package/{core/template/views → framework/v0.1.1-alpha.3/core/template/boilerplate/bundle_public}/favicon.ico +0 -0
- package/framework/v0.1.1-alpha.3/core/template/boilerplate/bundle_public/js/vendor/readme.md +1 -0
- package/framework/v0.1.1-alpha.3/core/template/boilerplate/bundle_public/readme.md +1 -0
- package/framework/v0.1.1-alpha.3/core/template/boilerplate/bundle_templates/handlers/main.js +24 -0
- package/{core/template/views/html/default.html → framework/v0.1.1-alpha.3/core/template/boilerplate/bundle_templates/html/homepage.html} +0 -0
- package/{core/template/views/html/layout.html → framework/v0.1.1-alpha.3/core/template/boilerplate/bundle_templates/html/layout/main.html} +2 -2
- package/{core → framework/v0.1.1-alpha.3/core}/template/command/gina.bat.tpl +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/template/command/gina.tpl +1 -1
- package/framework/v0.1.1-alpha.3/core/template/conf/env.json +76 -0
- package/{core/template/conf/project.json → framework/v0.1.1-alpha.3/core/template/conf/manifest.json} +1 -0
- package/{core → framework/v0.1.1-alpha.3/core}/template/conf/package.json +2 -2
- package/framework/v0.1.1-alpha.3/core/template/conf/settings.json +92 -0
- package/framework/v0.1.1-alpha.3/core/template/conf/statics.json +10 -0
- package/framework/v0.1.1-alpha.3/core/template/conf/templates.json +37 -0
- package/{core → framework/v0.1.1-alpha.3/core}/template/error/client/json/401.json +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/template/error/client/json/403.json +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/template/error/client/json/404.json +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/template/error/server/html/50x.html +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/template/error/server/json/500.json +0 -0
- package/{core → framework/v0.1.1-alpha.3/core}/template/error/server/json/503.json +0 -0
- package/{core/utils/lib/routing/build.json → framework/v0.1.1-alpha.3/core/template/extensions/logger/config.json} +0 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/helpers/console.js +3 -3
- package/{core/utils → framework/v0.1.1-alpha.3}/helpers/context.js +240 -49
- package/framework/v0.1.1-alpha.3/helpers/dateFormat.js +528 -0
- package/framework/v0.1.1-alpha.3/helpers/index.js +79 -0
- package/framework/v0.1.1-alpha.3/helpers/json/README.md +0 -0
- package/framework/v0.1.1-alpha.3/helpers/json/package.json +20 -0
- package/framework/v0.1.1-alpha.3/helpers/json/src/main.js +97 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/helpers/path.js +342 -140
- package/framework/v0.1.1-alpha.3/helpers/plugins/README.md +4 -0
- package/framework/v0.1.1-alpha.3/helpers/plugins/package.json +20 -0
- package/framework/v0.1.1-alpha.3/helpers/plugins/src/api-error.js +160 -0
- package/framework/v0.1.1-alpha.3/helpers/plugins/src/main.js +32 -0
- package/framework/v0.1.1-alpha.3/helpers/prototypes.js +218 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/helpers/task.js +49 -29
- package/{core/utils → framework/v0.1.1-alpha.3}/helpers/text.js +7 -7
- package/framework/v0.1.1-alpha.3/lib/archiver/README.md +0 -0
- package/framework/v0.1.1-alpha.3/lib/archiver/build.json +0 -0
- package/framework/v0.1.1-alpha.3/lib/archiver/package.json +20 -0
- package/framework/v0.1.1-alpha.3/lib/archiver/src/dep/jszip.min.js +15 -0
- package/framework/v0.1.1-alpha.3/lib/archiver/src/main.js +499 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/aliases.json +13 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/bundle/add.js +507 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/bundle/arguments.json +4 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/bundle/copy.js +15 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/bundle/cp.js +2 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/bundle/help.js +28 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/bundle/help.txt +67 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/bundle/list.js +129 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/bundle/remove.js +229 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/bundle/rename.js +4 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/bundle/restart.js +235 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/bundle/rm.js +2 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/bundle/start.js +394 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/bundle/status.js +3 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/bundle/stop.js +232 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/env/add.js +436 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/env/get.js +62 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/env/help.js +28 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/env/help.txt +33 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/env/link-dev.js +80 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/env/list.js +111 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/env/remove.js +150 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/env/rm.js +2 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/env/set.js +57 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/env/unset.js +44 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/env/use.js +79 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/framework/dot.js +70 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/framework/get.js +0 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/framework/help.js +39 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/framework/help.txt +31 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/framework/init.js +514 -0
- package/{core/utils/lib/cmd → framework/v0.1.1-alpha.3/lib/cmd/framework}/msg.json +3 -3
- package/framework/v0.1.1-alpha.3/lib/cmd/framework/open.js +50 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/framework/restart.js +124 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/framework/set.js +161 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/framework/start.js +96 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/framework/status.js +72 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/framework/stop.js +159 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/framework/tail.js +183 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/framework/update.js +0 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/framework/version.js +44 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/gina-dev.1.md +66 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/gina-framework.1.md +100 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/gina.1.md +79 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/helper.js +1147 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/index.js +170 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/msg.json +20 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/port/help.js +28 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/port/help.txt +31 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/port/inc/scan.js +108 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/port/list.js +176 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/port/set.js +0 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/project/add.js +528 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/project/arguments.json +9 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/project/build.js +115 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/project/help.js +28 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/project/help.txt +76 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/project/import.js +2 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/project/list.js +55 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/project/move.js +0 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/project/remove.js +144 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/project/rename.js +162 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/project/restart.js +0 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/project/rm.js +2 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/project/start.js +0 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/project/status.js +3 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/project/stop.js +0 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/protocol/help.js +27 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/protocol/help.txt +57 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/protocol/list.js +239 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/protocol/set.js +631 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/scope/help.js +28 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/scope/help.txt +33 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/scope/link-local.js +80 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/scope/list.js +116 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/scope/remove.js +150 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/scope/rm.js +2 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/scope/set.js +57 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/scope/unset.js +44 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/scope/use.js +79 -0
- package/framework/v0.1.1-alpha.3/lib/cmd/view/add.js +311 -0
- package/framework/v0.1.1-alpha.3/lib/collection/README.md +5 -0
- package/framework/v0.1.1-alpha.3/lib/collection/build.json +0 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/collection/package.json +2 -2
- package/framework/v0.1.1-alpha.3/lib/collection/src/main.js +1459 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/config.js +49 -34
- package/framework/v0.1.1-alpha.3/lib/cron/README.md +7 -0
- package/framework/v0.1.1-alpha.3/lib/cron/package.json +20 -0
- package/framework/v0.1.1-alpha.3/lib/cron/src/main.js +176 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/generator/index.js +8 -4
- package/framework/v0.1.1-alpha.3/lib/index.js +116 -0
- package/framework/v0.1.1-alpha.3/lib/inherits/LICENSE +19 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/inherits/README.md +0 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/inherits/example/inheriting_eventemitter.js +0 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/inherits/example/protected_inheritance.js +0 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/inherits/example/simple_inheritance.js +0 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/inherits/example/super_attribute_overridden_by_child_on_init.js +0 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/inherits/package.json +2 -2
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/inherits/src/main.js +18 -19
- package/framework/v0.1.1-alpha.3/lib/logger/README.md +7 -0
- package/framework/v0.1.1-alpha.3/lib/logger/package.json +20 -0
- package/framework/v0.1.1-alpha.3/lib/logger/src/containers/default/index.js +55 -0
- package/framework/v0.1.1-alpha.3/lib/logger/src/containers/file/index.js +251 -0
- package/framework/v0.1.1-alpha.3/lib/logger/src/containers/file/lib/logrotator/README.md +100 -0
- package/framework/v0.1.1-alpha.3/lib/logger/src/containers/file/lib/logrotator/index.js +274 -0
- package/framework/v0.1.1-alpha.3/lib/logger/src/containers/mq/index.js +52 -0
- package/framework/v0.1.1-alpha.3/lib/logger/src/containers/mq/listener.js +302 -0
- package/framework/v0.1.1-alpha.3/lib/logger/src/containers/mq/speaker.js +118 -0
- package/framework/v0.1.1-alpha.3/lib/logger/src/helper.js +131 -0
- package/framework/v0.1.1-alpha.3/lib/logger/src/main.js +739 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/math/index.js +58 -35
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/merge/README.md +5 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/merge/example/merge.js +1 -1
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/merge/example/merge_2_literal objects.js +0 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/merge/example/merge_and_preserve_first.js +2 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/merge/package.json +2 -2
- package/framework/v0.1.1-alpha.3/lib/merge/src/main.js +531 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/model.js +42 -19
- package/framework/v0.1.1-alpha.3/lib/proc.js +518 -0
- package/framework/v0.1.1-alpha.3/lib/routing/README.md +0 -0
- package/framework/v0.1.1-alpha.3/lib/routing/build.json +0 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/routing/package.json +2 -2
- package/framework/v0.1.1-alpha.3/lib/routing/src/main.js +1492 -0
- package/framework/v0.1.1-alpha.3/lib/session-store.js +33 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/shell.js +43 -30
- package/framework/v0.1.1-alpha.3/lib/swig-filters/README.md +0 -0
- package/framework/v0.1.1-alpha.3/lib/swig-filters/package.json +20 -0
- package/framework/v0.1.1-alpha.3/lib/swig-filters/src/main.js +322 -0
- package/framework/v0.1.1-alpha.3/lib/url/README.md +0 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/url/index.js +2 -1
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/url/mocks.json +0 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/url/routing.json +9 -9
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/url/test.js +0 -0
- package/{core/utils → framework/v0.1.1-alpha.3}/lib/validator.js +7 -7
- package/framework/v0.1.1-alpha.3/package.json +14 -0
- package/package.json +35 -33
- package/resources/etc/init.d/debian/gina +117 -0
- package/resources/home/framework/env.json +34 -0
- package/resources/home/framework/locals.json +14 -0
- package/resources/home/framework/project.json +48 -0
- package/resources/home/framework/projects.json +6 -0
- package/resources/home/main.json +47 -0
- package/resources/home/settings.json +22 -0
- package/resources/home/user/extensions/logger/default/config.json +77 -0
- package/resources/home/user/extensions/logger/file/config.json +11 -0
- package/resources/img/android-chrome-192x192.png +0 -0
- package/resources/img/android-chrome-512x512.png +0 -0
- package/resources/img/apple-touch-icon.png +0 -0
- package/resources/img/favicon-16x16.png +0 -0
- package/resources/img/favicon-32x32.png +0 -0
- package/resources/img/favicon.ico +0 -0
- package/resources/package.json.template +50 -0
- package/script/lib.js +24 -0
- package/script/post_install.js +449 -157
- package/script/pre_install.js +277 -36
- package/script/prepare_version.js +425 -0
- package/utils/helper.js +438 -0
- package/utils/prototypes.js +239 -0
- package/utils/prototypes.json_clone.js +175 -0
- package/.npmignore +0 -6
- package/MIDDLEWARE +0 -1
- package/SUCCESS +0 -1
- package/VERSION +0 -1
- package/core/asset/html/nolayout.html +0 -1
- package/core/asset/js/plugin/build.dev.json +0 -28
- package/core/asset/js/plugin/build.json +0 -31
- package/core/asset/js/plugin/dist/gina.min.css +0 -1
- package/core/asset/js/plugin/dist/gina.min.css.map +0 -1
- package/core/asset/js/plugin/dist/gina.min.js +0 -13732
- package/core/asset/js/plugin/dist/gina.min.js.map +0 -42
- package/core/asset/js/plugin/dist/gina.onload.min.js +0 -3
- package/core/asset/js/plugin/dist/gina.onload.min.js.map +0 -8
- package/core/asset/js/plugin/readme.md +0 -152
- package/core/asset/js/plugin/src/gina/main.js +0 -132
- package/core/asset/js/plugin/src/gina/popin/css/design.css +0 -23
- package/core/asset/js/plugin/src/gina/popin/css/main.css +0 -1112
- package/core/asset/js/plugin/src/gina/popin/css/popin.css +0 -3
- package/core/asset/js/plugin/src/gina/popin/css/popin.css.map +0 -1
- package/core/asset/js/plugin/src/gina/popin/doc/TOC.md +0 -29
- package/core/asset/js/plugin/src/gina/popin/doc/css.md +0 -162
- package/core/asset/js/plugin/src/gina/popin/doc/extend.md +0 -663
- package/core/asset/js/plugin/src/gina/popin/doc/faq.md +0 -46
- package/core/asset/js/plugin/src/gina/popin/doc/html.md +0 -227
- package/core/asset/js/plugin/src/gina/popin/doc/js.md +0 -37
- package/core/asset/js/plugin/src/gina/popin/doc/misc.md +0 -178
- package/core/asset/js/plugin/src/gina/popin/doc/usage.md +0 -130
- package/core/asset/js/plugin/src/gina/popin/main.js +0 -783
- package/core/asset/js/plugin/src/gina/popin/sass/config.sass +0 -37
- package/core/asset/js/plugin/src/gina/popin/sass/gina-design.sass +0 -622
- package/core/asset/js/plugin/src/gina/popin/sass/gina-popin.sass +0 -54
- package/core/asset/js/plugin/src/gina/popin/sass/helper.scss +0 -73
- package/core/asset/js/plugin/src/gina/toolbar/.npmignore +0 -19
- package/core/asset/js/plugin/src/gina/toolbar/css/toolbar.css +0 -433
- package/core/asset/js/plugin/src/gina/toolbar/css/toolbar.css.map +0 -1
- package/core/asset/js/plugin/src/gina/toolbar/index.html +0 -285
- package/core/asset/js/plugin/src/gina/toolbar/index.kit +0 -120
- package/core/asset/js/plugin/src/gina/toolbar/jquery-3.1.0.min.js +0 -4
- package/core/asset/js/plugin/src/gina/toolbar/main.js +0 -693
- package/core/asset/js/plugin/src/gina/toolbar/mock.gina.json +0 -1
- package/core/asset/js/plugin/src/gina/toolbar/mock.user.json +0 -1
- package/core/asset/js/plugin/src/gina/toolbar/readme.md +0 -7
- package/core/asset/js/plugin/src/gina/toolbar/sass/toolbar.sass +0 -563
- package/core/asset/js/plugin/src/gina/toolbar/svg-src/Info-color.svg +0 -1
- package/core/asset/js/plugin/src/gina/toolbar/svg-src/Info-grey.svg +0 -1
- package/core/asset/js/plugin/src/gina/toolbar/svg-src/error-color.svg +0 -1
- package/core/asset/js/plugin/src/gina/toolbar/svg-src/error-grey.svg +0 -1
- package/core/asset/js/plugin/src/gina/toolbar/svg-src/info-optim.svg +0 -13
- package/core/asset/js/plugin/src/gina/toolbar/svg-src/logo-gina.svg +0 -1
- package/core/asset/js/plugin/src/gina/toolbar/svg-src/settings-big.svg +0 -1
- package/core/asset/js/plugin/src/gina/toolbar/svg-src/settings.afdesign +0 -0
- package/core/asset/js/plugin/src/gina/toolbar/svg-src/settings.svg +0 -1
- package/core/asset/js/plugin/src/gina/toolbar/svg-src/stripe-calendar-optim.svg +0 -1
- package/core/asset/js/plugin/src/gina/toolbar/svg-src/stripe-calendar.svg +0 -1
- package/core/asset/js/plugin/src/gina/toolbar/svg-src/stripe-card-optim.svg +0 -1
- package/core/asset/js/plugin/src/gina/toolbar/svg-src/stripe-card.svg +0 -1
- package/core/asset/js/plugin/src/gina/toolbar/svg-src/stripe-lock-optim.svg +0 -1
- package/core/asset/js/plugin/src/gina/toolbar/svg-src/stripe-lock.svg +0 -1
- package/core/asset/js/plugin/src/gina/toolbar/svg-src/warning-color.svg +0 -1
- package/core/asset/js/plugin/src/gina/toolbar/svg-src/warning-grey.svg +0 -1
- package/core/asset/js/plugin/src/gina/toolbar/test.jpg +0 -0
- package/core/asset/js/plugin/src/gina/toolbar/toolbar.html +0 -104
- package/core/asset/js/plugin/src/gina/utils/dom.js +0 -24
- package/core/asset/js/plugin/src/gina/utils/events.js +0 -201
- package/core/asset/js/plugin/src/gina/utils/loader.js +0 -57
- package/core/asset/js/plugin/src/main.js +0 -235
- package/core/asset/js/plugin/src/vendor/jquery/1.11.1-css-event_alias.min.js +0 -5
- package/core/asset/js/plugin/src/vendor/jquery/1.12.4.min.js +0 -5
- package/core/asset/js/plugin/src/vendor/jquery/2.1.1-css-event_alias-sizzle.min.js +0 -4
- package/core/asset/js/plugin/src/vendor/jquery/README.md +0 -14
- package/core/asset/js/plugin/src/vendor/jquery/slim-3.1.1.min.js +0 -4
- package/core/config.js +0 -1225
- package/core/controller/controller.js +0 -1860
- package/core/gna.js +0 -908
- package/core/plugins/lib/validator/src/form-validator.js +0 -789
- package/core/plugins/lib/validator/src/main.js +0 -2056
- package/core/router.js +0 -717
- package/core/server.js +0 -1363
- package/core/template/conf/env.json +0 -70
- package/core/template/conf/settings.json +0 -48
- package/core/template/conf/statics.json +0 -6
- package/core/template/conf/views.json +0 -16
- package/core/template/samples/bundle/config/app.json +0 -4
- package/core/template/samples/bundle/config/routing.json +0 -9
- package/core/template/samples/bundle/controllers/setup.js +0 -33
- package/core/template/views/js/vendor/readme.md +0 -1
- package/core/template/views/readme.md +0 -1
- package/core/utils/helpers/dateFormat.js +0 -264
- package/core/utils/helpers/index.js +0 -202
- package/core/utils/index.js +0 -75
- package/core/utils/lib/cmd/app.js +0 -686
- package/core/utils/lib/cmd/basic.help.txt +0 -40
- package/core/utils/lib/cmd/basic.js +0 -141
- package/core/utils/lib/cmd/gina-add-bundle.js +0 -328
- package/core/utils/lib/cmd/gina-add-views.js +0 -99
- package/core/utils/lib/cmd/gina-build.js +0 -218
- package/core/utils/lib/cmd/gina-clean.js +0 -26
- package/core/utils/lib/cmd/gina-connect.js +0 -176
- package/core/utils/lib/cmd/gina-delete-bundle.js +0 -176
- package/core/utils/lib/cmd/gina-deploy.js +0 -452
- package/core/utils/lib/cmd/gina-init-project.js +0 -83
- package/core/utils/lib/cmd/gina-start-bundle.js +0 -3
- package/core/utils/lib/cmd/gina-start.js +0 -3
- package/core/utils/lib/cmd/index.js +0 -157
- package/core/utils/lib/cmd/project.js +0 -14
- package/core/utils/lib/collection/src/main.js +0 -650
- package/core/utils/lib/logger/containers/file.js +0 -11
- package/core/utils/lib/logger/index.js +0 -260
- package/core/utils/lib/merge/src/main.js +0 -344
- package/core/utils/lib/proc.js +0 -416
- package/core/utils/lib/routing/src/main.js +0 -165
- package/documentation/css/default.css +0 -3
- package/documentation/html/home.html +0 -6
- package/documentation/html/inc/_footer.html +0 -5
- package/documentation/html/layout.html +0 -21
- package/documentation/img/debug-conf1.png +0 -0
- package/documentation/img/debug-conf2.png +0 -0
- package/documentation/img/debug-conf3.png +0 -0
- package/documentation/img/debug-conf4.png +0 -0
- package/documentation/img/debug-conf5.png +0 -0
- package/documentation/img/debug-conf6.png +0 -0
- package/documentation/img/debug-conf7.png +0 -0
- package/documentation/img/debug-new1.png +0 -0
- package/documentation/img/debug-new2.png +0 -0
- package/documentation/img/debug-start.png +0 -0
- package/documentation/md/api/controller/main.md +0 -74
- package/migration_note.md +0 -7
- package/package-lock.json +0 -611
- package/script/pre_publish.js +0 -207
- package/tutorial/Commands/README.md +0 -56
- package/tutorial/Commands/add-bundle-result.png +0 -0
- package/tutorial/Commands/add-bundle.png +0 -0
- package/tutorial/Commands/delete-bundle.png +0 -0
- package/tutorial/Commands/help.png +0 -0
- package/tutorial/Commands/init-project.png +0 -0
- package/tutorial/Commands/start-bundle-result.png +0 -0
- package/tutorial/Commands/start-bundle-stop.png +0 -0
- package/tutorial/Commands/start-bundle.png +0 -0
- package/tutorial/Commands/version.png +0 -0
- package/tutorial/ETC/README.md +0 -74
- package/tutorial/ETC/add-bundle-result.png +0 -0
- package/tutorial/ETC/add-bundle.png +0 -0
- package/tutorial/ETC/init-project.png +0 -0
- package/tutorial/Install/README.md +0 -54
- package/tutorial/Install/git-get.png +0 -0
- package/tutorial/Install/git-install-end.png +0 -0
- package/tutorial/Install/git-install-result.png +0 -0
- package/tutorial/Install/git-install-start.png +0 -0
- package/tutorial/Install/install-end.png +0 -0
- package/tutorial/Install/install-result.png +0 -0
- package/tutorial/Install/install-start.png +0 -0
- package/tutorial/WebStorm/README.md +0 -30
- package/tutorial/WebStorm/closure-compiler.png +0 -0
- package/tutorial/WebStorm/sass.png +0 -0
|
@@ -0,0 +1,757 @@
|
|
|
1
|
+
//"use strict";
|
|
2
|
+
// Imports.
|
|
3
|
+
var fs = require('fs');
|
|
4
|
+
//var util = require('util');
|
|
5
|
+
//var promisify = require('util').promisify;
|
|
6
|
+
// Use couchbase module from the user's project dependencies if not found
|
|
7
|
+
var couchbasePath = _(getPath('project') +'/node_modules/couchbase');
|
|
8
|
+
var couchbase = require(couchbasePath);
|
|
9
|
+
|
|
10
|
+
var lib = require('./../../../lib') || require.cache[require.resolve('./../../../lib')];
|
|
11
|
+
var inherits = lib.inherits;
|
|
12
|
+
var merge = lib.merge;
|
|
13
|
+
var console = lib.logger;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Couchbase Class
|
|
17
|
+
*
|
|
18
|
+
* @package Freelancer.CoreAPI
|
|
19
|
+
* @author Rhinostone
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
function Couchbase(conn, infos) {
|
|
23
|
+
var EntitySuperClass = null, EntityN1qlClass = null;
|
|
24
|
+
var envIsDev = ( /^true$/i.test(process.env.NODE_ENV_IS_DEV) ) ? true : false;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Init
|
|
28
|
+
* @constructor
|
|
29
|
+
* */
|
|
30
|
+
var init = function(conn, infos) {
|
|
31
|
+
// load on startup
|
|
32
|
+
var cacheless = (process.env.NODE_ENV_IS_DEV == 'false') ? false : true;
|
|
33
|
+
var path = getPath('bundle') + '/models/'+ infos.database +'/entities'
|
|
34
|
+
, n1qlDefault = __dirname + '/lib'
|
|
35
|
+
, files = fs.readdirSync(path)
|
|
36
|
+
, entities = {}
|
|
37
|
+
, entityName = ''
|
|
38
|
+
, Entity = null
|
|
39
|
+
, className = null
|
|
40
|
+
, filename = null
|
|
41
|
+
;
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
// superEntity
|
|
45
|
+
filename = getPath('gina').core + '/model/entity.js';
|
|
46
|
+
if (cacheless)
|
|
47
|
+
delete require.cache[require.resolve(_(filename, true))]; //EntitySuperClass
|
|
48
|
+
|
|
49
|
+
EntitySuperClass = require(_(filename, true));
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
// first one for the N1QL queries without entity ( check `/lib/n1ql.js` )
|
|
53
|
+
files.unshift('n1ql.js');
|
|
54
|
+
for (var f = 0, len = files.length; f < len; ++f) {
|
|
55
|
+
|
|
56
|
+
if ( ! /^\./.test(files[f]) || f == len-1 ) {
|
|
57
|
+
|
|
58
|
+
if (cacheless && files[f] != 'n1ql.js') {
|
|
59
|
+
delete require.cache[require.resolve(_(path + '/' +files[f], true))];//child
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
entityName = files[f].replace(/.js/, '');
|
|
63
|
+
className = entityName.substr(0,1).toUpperCase() + entityName.substr(1);
|
|
64
|
+
|
|
65
|
+
if ( files[f] == 'n1ql.js' ) {
|
|
66
|
+
Entity = require(_(n1qlDefault + '/' +files[f], true));
|
|
67
|
+
EntityN1qlClass = Entity
|
|
68
|
+
} else {
|
|
69
|
+
Entity = require(_(path + '/' +files[f], true));
|
|
70
|
+
|
|
71
|
+
Entity = inherits(Entity, EntitySuperClass);
|
|
72
|
+
|
|
73
|
+
Entity.prototype.name = className;
|
|
74
|
+
Entity.prototype.model = infos.model;
|
|
75
|
+
Entity.prototype.bundle = infos.bundle;
|
|
76
|
+
Entity.prototype.database = infos.database;
|
|
77
|
+
Entity.prototype._collection = entityName;
|
|
78
|
+
Entity.prototype._filename = _(path + '/' +files[f], true);
|
|
79
|
+
|
|
80
|
+
// extra CRUD methods
|
|
81
|
+
Entity.prototype.bulkInsert = bulkInsert;
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
entities[className] = Entity
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
// loading N1QL
|
|
91
|
+
var dir = _( getPath('bundle') + '/models/'+ infos.database +'/n1ql' );
|
|
92
|
+
if ( fs.existsSync(dir) ) {
|
|
93
|
+
f = 0;
|
|
94
|
+
files = fs.readdirSync(dir);
|
|
95
|
+
filename = null;
|
|
96
|
+
len = files.length;
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
for (; f<files.length; ++f) {
|
|
100
|
+
// ignoring filename starting with .
|
|
101
|
+
if ( /^\./.test(files[f]) ) {
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
filename = _(dir +'/'+ files[f]);
|
|
106
|
+
loadN1QL(entities, filename)
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return entities
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
var loadN1QL = function(entities, filename) {
|
|
114
|
+
|
|
115
|
+
if ( fs.statSync(filename).isDirectory() ) {
|
|
116
|
+
var files = fs.readdirSync(filename)
|
|
117
|
+
, f = 0
|
|
118
|
+
, arr = filename.split(/\//g)
|
|
119
|
+
, entityName = arr[arr.length-1];
|
|
120
|
+
|
|
121
|
+
entityName = entityName.charAt(0).toUpperCase() + entityName.slice(1);
|
|
122
|
+
|
|
123
|
+
for (; f < files.length; ++f) {
|
|
124
|
+
// ignoring filename starting with . & sub folders
|
|
125
|
+
if (
|
|
126
|
+
/^\./.test(files[f])
|
|
127
|
+
||
|
|
128
|
+
!/\.sql$/i.test(files[f])
|
|
129
|
+
||
|
|
130
|
+
fs.statSync( _(filename + '/' + files[f], true) ).isDirectory()
|
|
131
|
+
) {
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
readSource(entities, entityName, filename + '/' + files[f])
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
} else {
|
|
138
|
+
var arr = filename.split(/\//g)
|
|
139
|
+
, entityName = arr[arr.length-1].replace(/\.sql/, '').split(/\_/)[0];
|
|
140
|
+
|
|
141
|
+
entityName = entityName.charAt(0).toUpperCase() + entityName.slice(1);
|
|
142
|
+
nbbnnb
|
|
143
|
+
readSource(entities, entityName, filename)
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
var readSource = function (entities, entityName, source) {
|
|
148
|
+
var arr = source.split(/\//g)
|
|
149
|
+
, name = arr[arr.length-1].replace(/\.sql/, '') || null
|
|
150
|
+
, comments = ''
|
|
151
|
+
, queryString = null
|
|
152
|
+
, includes = null
|
|
153
|
+
, queryStatement= null // this is the usable queryString
|
|
154
|
+
, params = []
|
|
155
|
+
, inlineParams = [] // order of use inside the query
|
|
156
|
+
, returnType = null // Array or Object : Array by default
|
|
157
|
+
, returnVariable= null // return variable
|
|
158
|
+
;
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
if (! /^\./.test(source) && name && typeof(conn[name]) == 'undefined' ) {
|
|
162
|
+
// N.B: because of the cache, if replacement of placeholders is done, it will affect the statement
|
|
163
|
+
queryString = fs.readFileSync( source ).toString();
|
|
164
|
+
// handle includes
|
|
165
|
+
includes = queryString.match(/\@include(.*)\;/g) || null;
|
|
166
|
+
if ( includes && includes.length > 0 ) {
|
|
167
|
+
for (let i = 0, len = includes.length; i < len; i++) {
|
|
168
|
+
let filename = includes[i].replace(/\"|\'|\;|(\@include\s+|\@include)/g, '');
|
|
169
|
+
if (
|
|
170
|
+
/^\./.test(filename)
|
|
171
|
+
||
|
|
172
|
+
// windows style location
|
|
173
|
+
/^[a-z]:(\\|\/\/)/i.test(filename)
|
|
174
|
+
||
|
|
175
|
+
// not unix absolut
|
|
176
|
+
!/^\//.test(filename)
|
|
177
|
+
&& !/^[a-z]:(\\|\/\/)/i.test(filename)
|
|
178
|
+
|
|
179
|
+
) {
|
|
180
|
+
let dir = new _(source).toUnixStyle();
|
|
181
|
+
dir = dir.substr(0, dir.lastIndexOf('/')) + '/'
|
|
182
|
+
filename = _(dir + filename.replace(/^\.\//, ''), true);
|
|
183
|
+
}
|
|
184
|
+
// remove @include calls
|
|
185
|
+
//console.debug('including .....'+ filename);
|
|
186
|
+
queryString = queryString.replace(includes[i], fs.readFileSync( filename ).toString() );
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
queryString = queryString.replace(/\n/g, ' ');
|
|
190
|
+
|
|
191
|
+
// extract comments
|
|
192
|
+
comments = queryString.match(/(\/\*([^*]|[\r\n]|(\*+([^*\/]|[\r\n])))*\*+\/)|(\/\/.*)/g);
|
|
193
|
+
// extract return type
|
|
194
|
+
returnType = queryString.match(/\@return\s+\{(.*)\}/);
|
|
195
|
+
if ( Array.isArray(returnType) ) {
|
|
196
|
+
returnType = returnType[1]
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (comments) {
|
|
200
|
+
params = comments[0].match(/\$\w+/g); // param list from comments
|
|
201
|
+
queryString = queryString.replace(comments[0], '');
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
inlineParams = queryString.match(/\$\w+/g);
|
|
205
|
+
|
|
206
|
+
// getting rid of duplicated
|
|
207
|
+
if ( typeof(Set) == 'function' ) { // ES6
|
|
208
|
+
inlineParams = Array.from(new Set(inlineParams))
|
|
209
|
+
} else { // ES5 + gina
|
|
210
|
+
inlineParams = Array.from(inlineParams)
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
try {
|
|
214
|
+
|
|
215
|
+
if ( typeof(entities[entityName]) == 'undefined' ) {
|
|
216
|
+
|
|
217
|
+
entities[entityName] = inherits(EntityN1qlClass, EntitySuperClass);
|
|
218
|
+
|
|
219
|
+
entities[entityName].prototype.name = entityName.substr(0,1).toUpperCase() + entityName.substr(1);
|
|
220
|
+
entities[entityName].prototype.model = infos.model;
|
|
221
|
+
entities[entityName].prototype.bundle = infos.bundle;
|
|
222
|
+
entities[entityName].prototype._collection = entityName;
|
|
223
|
+
entities[entityName].prototype._filename = _( __dirname + '/lib/n1ql.js', true );
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
entities[entityName].prototype[name] = function() {
|
|
228
|
+
var self = this;
|
|
229
|
+
var key = null
|
|
230
|
+
, index = null
|
|
231
|
+
, i = null
|
|
232
|
+
, len = null
|
|
233
|
+
, args = Array.prototype.slice.call(arguments)
|
|
234
|
+
, _mainCallback = null;
|
|
235
|
+
|
|
236
|
+
if ( params && params.length != args.length && !/function/.test(typeof(args[args.length-1])) ) {
|
|
237
|
+
throw new Error('[ N1QL:' + entityName+'#'+name+'() ] arguments must match parameters length. Please refer to [ '+ source +' ]\nFound in param list: ('+ params.join(', ') +') !')
|
|
238
|
+
} else if ( /function/.test( typeof(args[args.length-1]) ) ) {
|
|
239
|
+
// to hande Nodejs Util.promisify
|
|
240
|
+
_mainCallback = args[args.length-1]
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
var sdkVersion = conn.sdk.version || 2;
|
|
244
|
+
var queryParams = [];
|
|
245
|
+
queryStatement = queryString.slice(0);
|
|
246
|
+
if (params) {
|
|
247
|
+
// BO - patch prepared statement case when placeholder is used as a cursor
|
|
248
|
+
var p = []
|
|
249
|
+
// cloning queryString
|
|
250
|
+
, qStr = queryString.slice(0)
|
|
251
|
+
, inl = inlineParams.slice()
|
|
252
|
+
, re = null
|
|
253
|
+
, foundSpecialLeftCase = /\w+\.(\$|\%)/.test(qStr)
|
|
254
|
+
// rightCase already handled by default
|
|
255
|
+
//, foundSpecialRightCase = /(\$|\%)\d+\.\w+/.test(qStr)
|
|
256
|
+
;
|
|
257
|
+
|
|
258
|
+
// e.g.: c.documentNextId.$2 = $3
|
|
259
|
+
// e.g.: n.alertedOn.$1 = true
|
|
260
|
+
if (foundSpecialLeftCase) {
|
|
261
|
+
i = 0; len = args.length;
|
|
262
|
+
for (; i < len; ++i) {
|
|
263
|
+
key = inl.indexOf(params[i]);
|
|
264
|
+
if (key > -1) {
|
|
265
|
+
p[key] = args[key];
|
|
266
|
+
|
|
267
|
+
re = new RegExp('(.*)\\.'+ inl[key].replace(/([$%]+)/, '\\$1'));
|
|
268
|
+
if ( re.test(qStr) ) {
|
|
269
|
+
p[key] = args[key];
|
|
270
|
+
qStr = qStr.replace( new RegExp('(.*)\\.'+ params[i].replace(/([$%]+)/, '\\$1')), '$1\.'+args[i]);
|
|
271
|
+
inl.splice(key, 1);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
queryStatement = qStr;
|
|
277
|
+
if ( sdkVersion > 2 ) { // starting from SDK v3
|
|
278
|
+
queryParams = {};
|
|
279
|
+
index = 0; i = 0; len = inlineParams.length;
|
|
280
|
+
var matched = null;
|
|
281
|
+
for (; i < len; ++i) {
|
|
282
|
+
//matched = params.indexOf( inlineParams[i] );
|
|
283
|
+
matched = params.indexOf( inl[i] );
|
|
284
|
+
if ( matched > -1 && typeof(p[matched]) != 'undefined' ) {
|
|
285
|
+
// e.g.: queryParams[ $3 ] = 1
|
|
286
|
+
queryParams[ inl[i] ] = p[matched]
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
} else {
|
|
290
|
+
// Novemeber 2020 patch
|
|
291
|
+
index = 0; i = 0; len = params.length;
|
|
292
|
+
for (; i < len; ++i) {
|
|
293
|
+
if ( typeof(p[i]) != 'undefined' ) {
|
|
294
|
+
queryParams[i] = p[i];
|
|
295
|
+
} else { // means that placeholder has been replaced
|
|
296
|
+
// But we still need to keep the reference in the list
|
|
297
|
+
queryParams[i] = null
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// e.g.: c.id = $1.id
|
|
305
|
+
// if (foundSpecialRightCase) {
|
|
306
|
+
// console.debug('foundSpecialRightCase...')
|
|
307
|
+
// }
|
|
308
|
+
|
|
309
|
+
// normal case
|
|
310
|
+
if (
|
|
311
|
+
!foundSpecialLeftCase /**&& !foundSpecialRightCase*/
|
|
312
|
+
|| Array.isArray(queryParams) && queryParams.length == 0
|
|
313
|
+
) {
|
|
314
|
+
queryParams = args;
|
|
315
|
+
}
|
|
316
|
+
// EO - patch
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
var query = null, execQuery = null, _collection = null;
|
|
320
|
+
// values by default
|
|
321
|
+
var queryOptions = {
|
|
322
|
+
// Do not turn off the adhoc flag for each query since
|
|
323
|
+
// only a finite number of query plans (currently 5000) can be stored in the SDK
|
|
324
|
+
adhoc: false, // false to use plan optimization, but need a statement `name param` or `num param`
|
|
325
|
+
consistency: 1 // NOT_BOUNDED, but STATEMENT_PLUS is set by default for insert & update
|
|
326
|
+
};
|
|
327
|
+
if ( sdkVersion > 2 ) { // starting from SDK v3
|
|
328
|
+
_collection = queryStatement.match(/\_collection(\s+\=|=)(.*)(\'|\")/);
|
|
329
|
+
if (_collection.length > 0) {
|
|
330
|
+
_collection = _collection[0];
|
|
331
|
+
if ( /\_collection/.test(_collection) ) {
|
|
332
|
+
_collection = _collection.replace(/\_collection|\W+/ig, '');
|
|
333
|
+
} else {
|
|
334
|
+
_collection = null
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
//var bucket = conn._cluster.bucket(conn._name);
|
|
339
|
+
//var scope = conn.scope(conn._name);
|
|
340
|
+
//var coll = (_collection) ? scope.collection(_collection) : scope.defaultCollection();
|
|
341
|
+
//execQuery = conn._cluster.query;
|
|
342
|
+
execQuery = inherits(conn, conn._cluster.query);
|
|
343
|
+
|
|
344
|
+
query = queryStatement;
|
|
345
|
+
queryOptions.parameters = queryParams;
|
|
346
|
+
|
|
347
|
+
} else { // version 2
|
|
348
|
+
// prepared statement
|
|
349
|
+
query = N1qlQuery.fromString(queryStatement.replace(/^\s+/, ''));
|
|
350
|
+
// query options
|
|
351
|
+
// @param {object} options
|
|
352
|
+
// @param {string} options.sample
|
|
353
|
+
|
|
354
|
+
// adhoc option: @param {boolean} options.adhoc [ true | false ]
|
|
355
|
+
// default is set to false
|
|
356
|
+
//queryOptions.adhoc = false;
|
|
357
|
+
|
|
358
|
+
// scan consistency level: @param {number} options.consistency [ 1 | 2 | 3 ]
|
|
359
|
+
// Default is set to 1
|
|
360
|
+
//
|
|
361
|
+
// Default
|
|
362
|
+
// code : NOT_BOUNDED
|
|
363
|
+
// number : 1
|
|
364
|
+
// description : This is the default (for single-statement requests).
|
|
365
|
+
//
|
|
366
|
+
// Request plus
|
|
367
|
+
// code : REQUEST_PLUS
|
|
368
|
+
// number : 2
|
|
369
|
+
// description : This implements strong consistency per request.
|
|
370
|
+
//
|
|
371
|
+
// Statement plus
|
|
372
|
+
// code : STATEMENT_PLUS
|
|
373
|
+
// number : 3
|
|
374
|
+
// description : This implements strong consistency per statement.
|
|
375
|
+
//
|
|
376
|
+
//
|
|
377
|
+
// For more, visit :
|
|
378
|
+
// - https://blog.couchbase.com/high-performance-consistency/
|
|
379
|
+
// - https://developer.couchbase.com/documentation/server/current/architecture/querying-data-with-n1ql.html
|
|
380
|
+
// queryOptions.consistency = 2; // 3
|
|
381
|
+
// .adhoc(queryOptions.adhoc)
|
|
382
|
+
// .consistency(queryOptions.consistency)
|
|
383
|
+
//if ( /^(insert|update)/i.test(statement) ) {
|
|
384
|
+
queryOptions.adhoc = true;
|
|
385
|
+
queryOptions.consistency = 3; // NOT_BOUNDED
|
|
386
|
+
query.consistency(3); // NOT_BOUNDED
|
|
387
|
+
//}
|
|
388
|
+
// merge options
|
|
389
|
+
for (var qOpt in queryOptions) {
|
|
390
|
+
if ( typeof(query[ qOpt ]) == 'undefined' ) {
|
|
391
|
+
console.warn('N1QL:'+entityName.toLowerCase()+ '#'+ name + ': `'+ qOpt +'` is not a valid queryOption. Ignorig...');
|
|
392
|
+
continue;
|
|
393
|
+
}
|
|
394
|
+
query[ qOpt ]( queryOptions[ qOpt ] );
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
// trick to set event on the fly
|
|
403
|
+
var trigger = 'N1QL:'+entityName.toLowerCase()+ '#'+ name;
|
|
404
|
+
var statement = (sdkVersion <= 2) ? query.options.statement : query;
|
|
405
|
+
|
|
406
|
+
if (envIsDev) {
|
|
407
|
+
//var statement = (sdkVersion <= 2) ? query.options.statement : query;
|
|
408
|
+
console.debug('[ ' + trigger +' ] '+ statement);
|
|
409
|
+
//console.debug('[ ' + trigger +' ] options: '+ JSON.stringify(queryOptions, null, 2));
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
var onQueryCallback = function(err, data, meta) {
|
|
415
|
+
// if (/^company#getDocumentNextId$/.test(trigger)) {
|
|
416
|
+
// console.log('[ ' + trigger + '] onQueryCallback => ', err, data, meta);
|
|
417
|
+
// }
|
|
418
|
+
|
|
419
|
+
if (!data || data.length == 0) {
|
|
420
|
+
data = null
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
if (!err && meta && typeof(meta.errors) != 'undefined' ) {
|
|
424
|
+
err = new Error('[ '+source+' ]\n'+meta.errors[0].msg);
|
|
425
|
+
err.status = 403;
|
|
426
|
+
} else if (err) {
|
|
427
|
+
err.status = 500;
|
|
428
|
+
err.message = '[ '+source+' ]\n'+ err.message;
|
|
429
|
+
err.stack = '[ '+source+' ]\n'+ err.stack;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
// handle return type
|
|
433
|
+
if ( returnType && returnType == 'boolean' ) {
|
|
434
|
+
// CASE #1
|
|
435
|
+
// SELECT COUNT(a) AS someField <- means that keyword `COUNT(` is found in queryString
|
|
436
|
+
// [ { someField: 1 }] <- a collection with only one object which has prop: <number>
|
|
437
|
+
if (
|
|
438
|
+
/count\(|count\s+\(/i.test(queryString)
|
|
439
|
+
&& Array.isArray(data)
|
|
440
|
+
&& /object/i.test(typeof(data[0]))
|
|
441
|
+
&& Object.keys(data[0]).length == 1
|
|
442
|
+
&& /number/i.test( typeof(data[0][Object.keys(data[0])]) )
|
|
443
|
+
) {
|
|
444
|
+
data = ( data[0][Object.keys(data[0])] > 0 ) ? true : false
|
|
445
|
+
}
|
|
446
|
+
// CASE #2
|
|
447
|
+
// regular query, just counting result
|
|
448
|
+
else {
|
|
449
|
+
data = ( typeof(data.length) != 'undefined' && data.length > 0 ) ? true : false
|
|
450
|
+
}
|
|
451
|
+
} else if ( returnType && returnType == 'object' ) {
|
|
452
|
+
|
|
453
|
+
data = (data) ? data[0] : data
|
|
454
|
+
|
|
455
|
+
} else if ( returnType && returnType == 'number' && /count\(|count\s+\(/i.test(queryString) ) {
|
|
456
|
+
|
|
457
|
+
var re = /(?:(?:COUNT\(\S+\)|COUNT\s+\(\S+\))\s+AS\s+)(\w+)/i;
|
|
458
|
+
re.lastIndex = 1; // defining last index
|
|
459
|
+
returnVariable = queryString.match(re)[re.lastIndex];
|
|
460
|
+
|
|
461
|
+
data = ( typeof(returnVariable) != 'undefined' ) ? data[0][returnVariable] : data[0];
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
try {
|
|
465
|
+
if ( _mainCallback != null ) {
|
|
466
|
+
_mainCallback(err, data, meta)
|
|
467
|
+
} else {
|
|
468
|
+
//console.debug('self.emit ? ', typeof(self), typeof(self.emit));
|
|
469
|
+
if (err) {
|
|
470
|
+
if ( typeof(self.emit) != 'undefined' ) {
|
|
471
|
+
self.emit(trigger, err);
|
|
472
|
+
} else { // Promise case
|
|
473
|
+
throw err
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
} else {
|
|
477
|
+
if ( typeof(self.emit) != 'undefined' ) {
|
|
478
|
+
self.emit(trigger, err, data, meta);
|
|
479
|
+
} else { // Promise case
|
|
480
|
+
return data
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
return
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
} catch (_err) {
|
|
487
|
+
if ( _mainCallback != null ) {
|
|
488
|
+
_mainCallback(err, data, meta)
|
|
489
|
+
} else {
|
|
490
|
+
if ( typeof(self.emit) != 'undefined' ) {
|
|
491
|
+
self.emit(trigger, _err);
|
|
492
|
+
} else {
|
|
493
|
+
throw new Error('[ Couchbase ][ Core Entity Exception] '+ trigger + '\n'+ _err.stack)
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
}; // EO onQueryCallback
|
|
498
|
+
|
|
499
|
+
self._isRegisteredFromProto = false;
|
|
500
|
+
var register = function (trigger, queryParams, onQueryCallback, cb) {
|
|
501
|
+
// JUNE 2021 patch
|
|
502
|
+
// Adding support for FTS since it is not implemented in sdkVersion 2:
|
|
503
|
+
// variables not replaced by value
|
|
504
|
+
// looking for FTS (Full Text Search)
|
|
505
|
+
var ftsClause = query.options.statement.match(/(search\(|search\s+\().*\)/i);
|
|
506
|
+
if (ftsClause && Array.isArray(queryParams) ) {
|
|
507
|
+
var originalFtsClauses = JSON.clone(ftsClause);
|
|
508
|
+
for (let s = 0, sLen = ftsClause.length; s < sLen; s++) {
|
|
509
|
+
if ( !/\)$/.test(ftsClause[s]) ) continue;
|
|
510
|
+
for (let p = 0, pLen = queryParams.length; p < pLen; p++) {
|
|
511
|
+
if ( typeof(queryParams[p]) == 'function' ) continue;
|
|
512
|
+
let searchValue = ( /^(true|false)$/i.test(queryParams[p]) ) ? queryParams[p] : '"'+queryParams[p]+'"';
|
|
513
|
+
ftsClause[s] = ftsClause[s].replace( new RegExp('\\$'+ (p+1),'g'), searchValue)
|
|
514
|
+
}
|
|
515
|
+
query.options.statement = query.options.statement.replace(originalFtsClauses[s], ftsClause[s]);
|
|
516
|
+
}
|
|
517
|
+
originalFtsClauses = null;
|
|
518
|
+
}
|
|
519
|
+
ftsClause = null;
|
|
520
|
+
|
|
521
|
+
if ( typeof(self.once) != 'undefined' && typeof(cb) != 'undefined' ) {
|
|
522
|
+
self._isRegisteredFromProto = true;
|
|
523
|
+
//console.debug('registered trigger: ', trigger, self._isRegisteredFromProto);
|
|
524
|
+
self.once(trigger, function onComplete(err, data, meta){
|
|
525
|
+
//console.debug('received ', trigger, meta, err);
|
|
526
|
+
try {
|
|
527
|
+
cb(err, data, meta)
|
|
528
|
+
} catch (onCompleteError) {
|
|
529
|
+
cb(onCompleteError)
|
|
530
|
+
}
|
|
531
|
+
});
|
|
532
|
+
// if (/triggerToDebug/.test(trigger)) {
|
|
533
|
+
// console.log('[ ' + trigger + '] onQuery => ', query, queryParams);
|
|
534
|
+
// }
|
|
535
|
+
conn.query(query, queryParams, onQueryCallback);
|
|
536
|
+
} // else promise case
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
if (!self._isRegisteredFromProto) {
|
|
540
|
+
//console.debug('regular trigger: ', trigger, self._isRegisteredFromProto);
|
|
541
|
+
// if (/triggerToDebug/.test(trigger)) {
|
|
542
|
+
// console.log('[ ' + trigger + '] onQuery => ', query, queryParams);
|
|
543
|
+
// }
|
|
544
|
+
conn.query(query, queryParams, onQueryCallback);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
var _proto = {
|
|
549
|
+
onComplete : function(cb) {
|
|
550
|
+
//console.debug('onComplete trigger: ', trigger, self._isRegisteredFromProto);
|
|
551
|
+
register(trigger, queryParams, onQueryCallback, cb)
|
|
552
|
+
}
|
|
553
|
+
};
|
|
554
|
+
|
|
555
|
+
|
|
556
|
+
if ( sdkVersion > 2 ) {
|
|
557
|
+
var qErr = false, qData = null, qMeta = null;
|
|
558
|
+
|
|
559
|
+
if ( _mainCallback == null ) {
|
|
560
|
+
return {
|
|
561
|
+
onComplete : function(cb) {
|
|
562
|
+
//console.debug('registered trigger: ', trigger);
|
|
563
|
+
self.once(trigger, function onComplete(err, data, meta){
|
|
564
|
+
//console.debug('received ', trigger);
|
|
565
|
+
try {
|
|
566
|
+
cb(err, data, meta)
|
|
567
|
+
} catch (onCompleteError) {
|
|
568
|
+
cb(onCompleteError)
|
|
569
|
+
}
|
|
570
|
+
});
|
|
571
|
+
|
|
572
|
+
conn._cluster.query(query, queryOptions)
|
|
573
|
+
.catch( function onError(err) {
|
|
574
|
+
qErr = err;
|
|
575
|
+
})
|
|
576
|
+
.then( function onResult(data, meta) {
|
|
577
|
+
qData = data;
|
|
578
|
+
qMeta = meta;
|
|
579
|
+
});
|
|
580
|
+
|
|
581
|
+
try {
|
|
582
|
+
if ( qErr ) {
|
|
583
|
+
onQueryCallback(qErr);
|
|
584
|
+
} else {
|
|
585
|
+
onQueryCallback(false, qData, qMeta);
|
|
586
|
+
}
|
|
587
|
+
} catch (_err) {
|
|
588
|
+
console.error(_err.stack);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
} else {
|
|
593
|
+
conn._cluster.query(query, queryOptions)
|
|
594
|
+
.catch( function onError(err) {
|
|
595
|
+
qErr = err;
|
|
596
|
+
})
|
|
597
|
+
.then( function onResult(data, meta) {
|
|
598
|
+
qData = data;
|
|
599
|
+
qMeta = meta;
|
|
600
|
+
});
|
|
601
|
+
|
|
602
|
+
try {
|
|
603
|
+
if ( qErr ) {
|
|
604
|
+
onQueryCallback(qErr);
|
|
605
|
+
} else {
|
|
606
|
+
onQueryCallback(false, qData, qMeta);
|
|
607
|
+
}
|
|
608
|
+
} catch (_err) {
|
|
609
|
+
console.error(_err.stack);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
|
|
614
|
+
} else {
|
|
615
|
+
|
|
616
|
+
if ( _mainCallback == null ) {
|
|
617
|
+
setTimeout((trigger, queryParams, onQueryCallback) => {
|
|
618
|
+
if (!self._isRegisteredFromProto) {
|
|
619
|
+
// needed when used as a synchrone method
|
|
620
|
+
register(trigger, queryParams, onQueryCallback);
|
|
621
|
+
}
|
|
622
|
+
}, 0, trigger, queryParams, onQueryCallback);
|
|
623
|
+
return _proto
|
|
624
|
+
|
|
625
|
+
} else {
|
|
626
|
+
register(trigger, queryParams, onQueryCallback, _mainCallback)
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
} catch (err) {
|
|
632
|
+
console.error(err.stack);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* bulkInsert
|
|
640
|
+
*
|
|
641
|
+
* Supported options
|
|
642
|
+
* - adhoc : [ true | false ]
|
|
643
|
+
* // scan consistency level - default is 1
|
|
644
|
+
* - consistency : [ 1 | 2 | 3 ] where 1 = NOT_BOUNDED, 2 = REQUEST_PLUS, 3 = STATEMENT_PLUS
|
|
645
|
+
*
|
|
646
|
+
* @param {array} rec collection
|
|
647
|
+
* @param {object} [options] e.g: { consistency: 3 }
|
|
648
|
+
*
|
|
649
|
+
*/
|
|
650
|
+
var bulkInsert = function(rec, options) {
|
|
651
|
+
|
|
652
|
+
try {
|
|
653
|
+
var conn = this.getConnection();
|
|
654
|
+
var sdkVersion = conn.sdk.version || 2;
|
|
655
|
+
// by default
|
|
656
|
+
var queryOptions = {
|
|
657
|
+
adhoc: true,
|
|
658
|
+
consistency: 3
|
|
659
|
+
};
|
|
660
|
+
|
|
661
|
+
if ( typeof(options) != 'undefined' ) {
|
|
662
|
+
queryOptions = merge(options, queryOptions)
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
var name = 'bulkInsert';
|
|
666
|
+
|
|
667
|
+
if ( typeof(rec) == 'undefined' || !rec) {
|
|
668
|
+
throw new Error('[ '+ this._collection +'::'+name+'(rec) ] : `rec` argument cannot be left empty !')
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
|
|
672
|
+
var queryString = 'INSERT INTO '+ this.database +' (KEY, VALUE)';
|
|
673
|
+
for (var id in rec) {
|
|
674
|
+
if ( typeof(rec[id].values) == 'undefined' )
|
|
675
|
+
throw new Error('rec["'+ id +'"].values not found ! Please inspect your record root: type must be an Array.');
|
|
676
|
+
|
|
677
|
+
if ( typeof(rec[id].values.id) == 'undefined' )
|
|
678
|
+
rec[id].values.id = id;
|
|
679
|
+
|
|
680
|
+
rec[id].values._collection = this._collection;
|
|
681
|
+
|
|
682
|
+
queryString += '\t\nVALUES ("'+ id +'", '+ JSON.stringify(rec[id].values) +'),';
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
queryString = queryString.substr(0, queryString.length-1);
|
|
686
|
+
queryString += '\nRETURNING '+ this.database +'.*;';
|
|
687
|
+
|
|
688
|
+
|
|
689
|
+
var query = null;
|
|
690
|
+
if ( sdkVersion > 2) { // starting SDK v3
|
|
691
|
+
var scope = conn.scope(conn._name);
|
|
692
|
+
var coll = (_collection) ? scope.collection(_collection) : scope.defaultCollection();
|
|
693
|
+
query = merge(queryString, queryOptions);
|
|
694
|
+
} else {
|
|
695
|
+
// prepared statement
|
|
696
|
+
query = N1qlQuery.fromString(queryString);
|
|
697
|
+
// merge options
|
|
698
|
+
for (var qOpt in queryOptions) {
|
|
699
|
+
if ( typeof(query[ qOpt ]) == 'undefined' ) {
|
|
700
|
+
console.warn('N1QL:'+entityName.toLowerCase()+ '#'+ name + ': `'+ qOpt +'` is not a valid queryOption. Ignorig...');
|
|
701
|
+
continue;
|
|
702
|
+
}
|
|
703
|
+
query[ qOpt ]( queryOptions[ qOpt ] )
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
|
|
708
|
+
// trick to set event on the fly
|
|
709
|
+
var trigger = 'N1QL:'+ this.name.toLowerCase()+ '#'+ name;
|
|
710
|
+
// trick to set event on the fly
|
|
711
|
+
var statement = (sdkVersion <= 2) ? query.options.statement : query;
|
|
712
|
+
|
|
713
|
+
if (envIsDev) {
|
|
714
|
+
console.debug('[ ' + trigger +' ] '+statement);
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
var self = this;
|
|
718
|
+
conn.query(query, rec, function(err, data, meta) {
|
|
719
|
+
if (!data || data.length == 0) {
|
|
720
|
+
data = null
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
if (!err && meta && typeof(meta.errors) != 'undefined' ) {
|
|
724
|
+
err = new Error('`GenericN1QLError::bulkInsert`\n'+meta.errors[0].msg);
|
|
725
|
+
err.status = 403;
|
|
726
|
+
} else if (err) {
|
|
727
|
+
err.status = 500;
|
|
728
|
+
err.message = '`GenericN1QLError::bulkInsert`\n'+ err.message;
|
|
729
|
+
err.stack = '`GenericN1QLError::bulkInsert`\n'+ err.stack;
|
|
730
|
+
}
|
|
731
|
+
if (envIsDev) {
|
|
732
|
+
console.debug('[ bulkInsert response ] : err ? '+ err + ', meta : \n'+ JSON.stringify(meta) +'\n data :\n'+ JSON.stringify(data) );
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
self.emit(trigger, err, data, meta);
|
|
736
|
+
});
|
|
737
|
+
|
|
738
|
+
return {
|
|
739
|
+
onComplete : function(cb) {
|
|
740
|
+
self.once(trigger, function(err, data, meta){
|
|
741
|
+
if (envIsDev) {
|
|
742
|
+
console.debug('[ bulkInsert triggerd ] '+ trigger);
|
|
743
|
+
}
|
|
744
|
+
cb(err, data, meta)
|
|
745
|
+
})
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
} catch (err) {
|
|
750
|
+
console.error(err.stack);
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
return init(conn, infos)
|
|
755
|
+
};
|
|
756
|
+
|
|
757
|
+
module.exports = Couchbase
|