diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index eeda5718dd..1f7ab54906 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -15,7 +15,7 @@ - [ ] Plugin -**Manual testing done on the follow databases:** +**Manual testing done on the following databases:** - [ ] Not applicable - [ ] MongoDB - [ ] MySQL diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7b1dda35ae..8f3afba92c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -74,7 +74,7 @@ npm run setup:build You can open a new terminal window and go into any folder you want for the next steps. ```bash -cd /.../workspace/ +cd ../workspace/ ``` The command to generate a project is the same, except you have to add the `--dev` argument at the end of line. diff --git a/docs/3.x.x/configurations/configurations.md b/docs/3.x.x/configurations/configurations.md index f5ace10db1..088db392cb 100644 --- a/docs/3.x.x/configurations/configurations.md +++ b/docs/3.x.x/configurations/configurations.md @@ -202,6 +202,14 @@ You can access the config of the current environment through `strapi.config.curr - `ssl` (boolean): For ssl database connection. - `debug` (boolean): Show database exchanges and errors. - `autoMigration` (boolean): To disable auto tables/columns creation for SQL database. + - `pool` Options used for database connection pooling. For more information look at [Knex's pool config documentation](https://knexjs.org/#Installation-pooling). + - `min` (integer): Minimum number of connections to keep in the pool. Default value: `0`. + - `max` (integer): Maximum number of connections to keep in the pool. Default value: `10`. + - `acquireTimeoutMillis` (integer): Maximum time in milliseconds to wait for acquiring a connection from the pool. Default value: `2000` (2 seconds). + - `createTimeoutMillis` (integer): Maximum time in milliseconds to wait for creating a connection to be added to the pool. Default value: `2000` (2 seconds). + - `idleTimeoutMillis` (integer): Number of milliseconds to wait before destroying idle connections. Default value: `30000` (30 seconds). + - `reapIntervalMillis` (integer): How often to check for idle connections in milliseconds. Default value: `1000` (1 second). + - `createRetryIntervalMillis` (integer): How long to idle after a failed create before trying again in milliseconds. Default value: `200`. #### Example diff --git a/docs/3.x.x/guides/controllers.md b/docs/3.x.x/guides/controllers.md index 94644bf6ac..3677baad81 100644 --- a/docs/3.x.x/guides/controllers.md +++ b/docs/3.x.x/guides/controllers.md @@ -14,7 +14,7 @@ Each controller’s action must be an `async` function and receives the `context #### Example -In this example, we are defining a specific route in `./api/hello/config/routes.json` that takes `Hello.index` as handler. It means that every time a web browser is pointed to the `/hello` URL, the server will called the `index` action in the `Hello.js` controller. Our `index` action will return `Hello World!`. You can also return a JSON object. +In this example, we are defining a specific route in `./api/hello/config/routes.json` that takes `Hello.index` as handler. It means that every time a web browser is pointed to the `/hello` URL, the server will call the `index` action in the `Hello.js` controller. Our `index` action will return `Hello World!`. You can also return a JSON object. **Path —** `./api/hello/config/routes.json`. ```json diff --git a/docs/3.x.x/guides/deployment.md b/docs/3.x.x/guides/deployment.md index eaf8a6da34..50ad9673b7 100644 --- a/docs/3.x.x/guides/deployment.md +++ b/docs/3.x.x/guides/deployment.md @@ -1,5 +1,13 @@ # Deployment +### Docker + +::: tip +You can also deploy using [Docker](https://hub.docker.com/r/strapi/strapi]) +::: + +The method below describes regular deployment using the built-in mechanisms. + #### #1 - Configure Update the `production` settings with the IP and domain name where the project will be running. diff --git a/docs/3.x.x/guides/filters.md b/docs/3.x.x/guides/filters.md index 315401fd59..c4760cfc01 100644 --- a/docs/3.x.x/guides/filters.md +++ b/docs/3.x.x/guides/filters.md @@ -24,6 +24,7 @@ Easily filter results according to fields values. - `_gt`: Greater than - `_lte`: Lower than or equal to - `_gte`: Greater than or equal to + - `_in`: Include in array - `_contains`: Contains - `_containss`: Contains case sensitive @@ -37,6 +38,9 @@ Find products having a price equal or greater than `3`. `GET /products?price_gte=3` +Find multiple product with id 3, 6, 8 +`GET /products?id_in=3&id_in=6&id_in=8` + ::: note You can't use filter to have specific results inside relation, like "Find users and only their posts older than yesterday" as example. If you need it, you can modify or create your own service or use [GraphQL](./graphql.md#query-api). ::: diff --git a/docs/3.x.x/migration-guide/README.md b/docs/3.x.x/migration-guide/README.md index c46bbaed4d..d3b9e3ebdd 100644 --- a/docs/3.x.x/migration-guide/README.md +++ b/docs/3.x.x/migration-guide/README.md @@ -25,3 +25,5 @@ - [Migration guide from alpha.16 to alpha.17](migration-guide-alpha.16-to-alpha.17.md) - [Migration guide from alpha.17 to alpha.18](migration-guide-alpha.17-to-alpha.18.md) - [Migration guide from alpha.18 to alpha.19](migration-guide-alpha.18-to-alpha.19.md) +- [Migration guide from alpha.19 to alpha.20](migration-guide-alpha.19-to-alpha.20.md) +- [Migration guide from alpha.20 to alpha.21](migration-guide-alpha.20-to-alpha.21.md) diff --git a/docs/3.x.x/migration-guide/migration-guide-alpha.19-to-alpha.20.md b/docs/3.x.x/migration-guide/migration-guide-alpha.19-to-alpha.20.md new file mode 100644 index 0000000000..f4afb99ad6 --- /dev/null +++ b/docs/3.x.x/migration-guide/migration-guide-alpha.19-to-alpha.20.md @@ -0,0 +1,67 @@ +# Migration guide from alpha.19 to alpha.20 + +**Here are the major changes:** + +- Fix email issue on user update +- Improve GraphQL performances + +**Useful links:** +- Changelog: [https://github.com/strapi/strapi/releases/tag/v3.0.0-alpha.20](https://github.com/strapi/strapi/releases/tag/v3.0.0-alpha.20) +- GitHub diff: [https://github.com/strapi/strapi/compare/v3.0.0-alpha.19...v3.0.0-alpha.20](https://github.com/strapi/strapi/compare/v3.0.0-alpha.19...v3.0.0-alpha.20) + +
+ +::: note +Feel free to [join us on Slack](http://slack.strapi.io) and ask questions about the migration process. +::: + +
+ +## Getting started + +Install Strapi `alpha.20` globally on your computer. To do so run `npm install strapi@3.0.0-alpha.20 -g`. + +When it's done, generate a new empty project `strapi new myNewProject` (don't pay attention to the database configuration). + +
+ +## Update node modules + +Update the Strapi's dependencies version (move Strapi's dependencies to `3.0.0-alpha.20` version) of your project. + +Run `npm install strapi@3.0.0-alpha.20 --save` to update your strapi version. + +
+ +## Update the Admin + +::: note +If you performed updates in the Admin, you will have to manually migrate your changes. +::: + +Delete your old admin folder and replace it with the new one. + +
+ +## Update the Plugins + +::: note +If you did a custom update on one of the plugins, you will have to manually migrate your update. +::: + +Copy the fields and relations you had in your `/plugins/users-permissions/models/User.settings.json` and `/plugins/users-permissions/config/jwt.json` file in the new one. + +Then, delete your old `plugins` folder and replace it with the new one. + +## Update services + +For both bookshelf and mongoose, you will have to update all services of your generated API. + +You will have to update one line of the `fetchAll` function. + +**Mongoose** replace `.populate(populate);` by `.populate(filters.populate || populate);`. +**Bookshelf**: replace `withRelated: populate` by `withRelated: filters.populate || populate`. + +
+ +That's all, you have now upgraded to Strapi `alpha.20`. diff --git a/docs/3.x.x/migration-guide/migration-guide-alpha.20-to-alpha.21.md b/docs/3.x.x/migration-guide/migration-guide-alpha.20-to-alpha.21.md new file mode 100644 index 0000000000..a8629de4ee --- /dev/null +++ b/docs/3.x.x/migration-guide/migration-guide-alpha.20-to-alpha.21.md @@ -0,0 +1,58 @@ +# Migration guide from alpha.20 to alpha.21 + +**Here are the major changes:** + +- Fix timestamps issue about update data in MySQL +- Fix production start + +**Useful links:** +- Changelog: [https://github.com/strapi/strapi/releases/tag/v3.0.0-alpha.21](https://github.com/strapi/strapi/releases/tag/v3.0.0-alpha.21) +- GitHub diff: [https://github.com/strapi/strapi/compare/v3.0.0-alpha.20...v3.0.0-alpha.21](https://github.com/strapi/strapi/compare/v3.0.0-alpha.20...v3.0.0-alpha.21) + +
+ +::: note +Feel free to [join us on Slack](http://slack.strapi.io) and ask questions about the migration process. +::: + +
+ +## Getting started + +Install Strapi `alpha.21` globally on your computer. To do so run `npm install strapi@3.0.0-alpha.21 -g`. + +When it's done, generate a new empty project `strapi new myNewProject` (don't pay attention to the database configuration). + +
+ +## Update node modules + +Update the Strapi's dependencies version (move Strapi's dependencies to `3.0.0-alpha.21` version) of your project. + +Run `npm install strapi@3.0.0-alpha.21 --save` to update your strapi version. + +
+ +## Update the Admin + +::: note +If you performed updates in the Admin, you will have to manually migrate your changes. +::: + +Delete your old admin folder and replace it with the new one. + +
+ +## Update the Plugins + +::: note +If you did a custom update on one of the plugins, you will have to manually migrate your update. +::: + +Copy the fields and relations you had in your `/plugins/users-permissions/models/User.settings.json` and `/plugins/users-permissions/config/jwt.json` file in the new one. + +Then, delete your old `plugins` folder and replace it with the new one. + +
+ +That's all, you have now upgraded to Strapi `alpha.21`. diff --git a/package.json b/package.json index 42d22a2447..e14809713c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "private": true, - "version": "3.0.0-alpha.19", + "version": "3.0.0-alpha.21", "dependencies": {}, "devDependencies": { "assert": "~1.3.0", diff --git a/packages/strapi-admin/package.json b/packages/strapi-admin/package.json index 2299547e38..2146cdefe3 100644 --- a/packages/strapi-admin/package.json +++ b/packages/strapi-admin/package.json @@ -1,6 +1,6 @@ { "name": "strapi-admin", - "version": "3.0.0-alpha.19", + "version": "3.0.0-alpha.21", "description": "Strapi Admin", "repository": { "type": "git", @@ -31,8 +31,8 @@ }, "devDependencies": { "sanitize.css": "^4.1.0", - "strapi-helper-plugin": "3.0.0-alpha.19", - "strapi-utils": "3.0.0-alpha.19" + "strapi-helper-plugin": "3.0.0-alpha.21", + "strapi-utils": "3.0.0-alpha.21" }, "author": { "name": "Strapi", diff --git a/packages/strapi-generate-admin/package.json b/packages/strapi-generate-admin/package.json index 54de357e79..a8c2f09f62 100644 --- a/packages/strapi-generate-admin/package.json +++ b/packages/strapi-generate-admin/package.json @@ -1,6 +1,6 @@ { "name": "strapi-generate-admin", - "version": "3.0.0-alpha.19", + "version": "3.0.0-alpha.21", "description": "Generate the default admin panel for a Strapi application.", "homepage": "http://strapi.io", "keywords": [ @@ -15,8 +15,8 @@ "dependencies": { "fs-extra": "^4.0.1", "lodash": "^4.17.5", - "strapi-admin": "3.0.0-alpha.19", - "strapi-utils": "3.0.0-alpha.19" + "strapi-admin": "3.0.0-alpha.21", + "strapi-utils": "3.0.0-alpha.21" }, "author": { "email": "hi@strapi.io", diff --git a/packages/strapi-generate-api/package.json b/packages/strapi-generate-api/package.json index 80b73c7237..cfcf46c462 100644 --- a/packages/strapi-generate-api/package.json +++ b/packages/strapi-generate-api/package.json @@ -1,6 +1,6 @@ { "name": "strapi-generate-api", - "version": "3.0.0-alpha.19", + "version": "3.0.0-alpha.21", "description": "Generate an API for a Strapi application.", "homepage": "http://strapi.io", "keywords": [ diff --git a/packages/strapi-generate-api/templates/mongoose/service.template b/packages/strapi-generate-api/templates/mongoose/service.template index bf41c3a199..afe2c1dffd 100644 --- a/packages/strapi-generate-api/templates/mongoose/service.template +++ b/packages/strapi-generate-api/templates/mongoose/service.template @@ -64,7 +64,7 @@ module.exports = { const filters = strapi.utils.models.convertParams('<%= globalID.toLowerCase() %>', params); return <%= globalID %> - .count() + .countDocuments() .where(filters.where); }, @@ -98,7 +98,7 @@ module.exports = { const data = _.omit(values, <%= globalID %>.associations.map(a => a.alias)); // Update entry with no-relational data. - const entry = await <%= globalID %>.update(params, data, { multi: true }); + const entry = await <%= globalID %>.updateOne(params, data, { multi: true }); // Update relational data and return the entry. return <%= globalID %>.updateRelations(Object.assign(params, { values: relations })); diff --git a/packages/strapi-generate-controller/package.json b/packages/strapi-generate-controller/package.json index c9cb06ab00..034e02fddd 100644 --- a/packages/strapi-generate-controller/package.json +++ b/packages/strapi-generate-controller/package.json @@ -1,6 +1,6 @@ { "name": "strapi-generate-controller", - "version": "3.0.0-alpha.19", + "version": "3.0.0-alpha.21", "description": "Generate a controller for a Strapi API.", "homepage": "http://strapi.io", "keywords": [ diff --git a/packages/strapi-generate-model/package.json b/packages/strapi-generate-model/package.json index 10b26801a3..e6e4f57392 100644 --- a/packages/strapi-generate-model/package.json +++ b/packages/strapi-generate-model/package.json @@ -1,6 +1,6 @@ { "name": "strapi-generate-model", - "version": "3.0.0-alpha.19", + "version": "3.0.0-alpha.21", "description": "Generate a model for a Strapi API.", "homepage": "http://strapi.io", "keywords": [ diff --git a/packages/strapi-generate-new/files/config/environments/production/database.json b/packages/strapi-generate-new/files/config/environments/production/database.json deleted file mode 100644 index 3075fabf91..0000000000 --- a/packages/strapi-generate-new/files/config/environments/production/database.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "defaultConnection": "default", - "connections": { - "default": { - "connector": "strapi-hook-mongoose", - "settings": { - "client": "mongo", - "uri": "${process.env.DATABASE_URI || ''}", - "host": "${process.env.DATABASE_HOST || '127.0.0.1'}", - "port": "${process.env.DATABASE_PORT || 27017}", - "database": "${process.env.DATABASE_NAME || 'strapi-production'}", - "username": "${process.env.DATABASE_USERNAME || ''}", - "password": "${process.env.DATABASE_PASSWORD || ''}" - }, - "options": { - "ssl": "${process.env.DATABASE_SSL || false}", - "authenticationDatabase": "${process.env.DATABASE_AUTHENTICATION_DATABASE || ''}" - } - } - } -} diff --git a/packages/strapi-generate-new/files/config/environments/staging/database.json b/packages/strapi-generate-new/files/config/environments/staging/database.json deleted file mode 100644 index 43edf2421d..0000000000 --- a/packages/strapi-generate-new/files/config/environments/staging/database.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "defaultConnection": "default", - "connections": { - "default": { - "connector": "strapi-hook-mongoose", - "settings": { - "client": "mongo", - "uri": "${process.env.DATABASE_URI || ''}", - "host": "${process.env.DATABASE_HOST || '127.0.0.1'}", - "port": "${process.env.DATABASE_PORT || 27017}", - "database": "${process.env.DATABASE_NAME || 'strapi-staging'}", - "username": "${process.env.DATABASE_USERNAME || ''}", - "password": "${process.env.DATABASE_PASSWORD || ''}" - }, - "options": { - "ssl": "${process.env.DATABASE_SSL || false}", - "authenticationDatabase": "${process.env.DATABASE_AUTHENTICATION_DATABASE || ''}" - } - } - } -} diff --git a/packages/strapi-generate-new/json/database.json.js b/packages/strapi-generate-new/json/database.json.js index 93434f6dd4..ba1df27e7d 100644 --- a/packages/strapi-generate-new/json/database.json.js +++ b/packages/strapi-generate-new/json/database.json.js @@ -1,8 +1,48 @@ 'use strict'; module.exports = scope => { + // Production/Staging Template + if (['production', 'staging'].includes(scope.keyPath.split('/')[2])) { + // All available settings (bookshelf and mongoose) + const settingsBase = { + client: scope.client.database, + host: '${process.env.DATABASE_HOST || \'127.0.0.1\' }', + port: '${process.env.DATABASE_PORT || 27017 }', + srv: '${process.env.DATABASE_SRV || false }', + database: '${process.env.DATABASE_NAME || strapi }', + username: '${process.env.DATABASE_USERNAME || \'\' }', + password: '${process.env.DATABASE_PASSWORD || \'\' }', + ssl: '${process.env.DATABASE_SSL || false }' + }; + + // Apply only settings set during the configuration + Object.keys(scope.database.settings).forEach((key) => { + scope.database.settings[key] = settingsBase[key]; + }); + + // All available options (bookshelf and mongoose) + const optionsBase = { + ssl: '${process.env.DATABASE_SSL || false }', + authenticationDatabase: '${process.env.DATABASE_AUTHENTICATION_DATABASE || \'\' }' + }; + + // Apply only options set during the configuration + Object.keys(scope.database.options).forEach((key) => { + scope.database.options[key] = optionsBase[key]; + }); + + return { + defaultConnection: 'default', + connections: { + default: { + connector: scope.client.connector, + settings: scope.database.settings, + options: scope.database.options + } + } + }; + } - // Finally, return the JSON. return { defaultConnection: 'default', connections: { diff --git a/packages/strapi-generate-new/lib/before.js b/packages/strapi-generate-new/lib/before.js index e71301fa13..b02796d73c 100644 --- a/packages/strapi-generate-new/lib/before.js +++ b/packages/strapi-generate-new/lib/before.js @@ -205,12 +205,16 @@ module.exports = (scope, cb) => { } scope.database.settings.host = answers.host; - scope.database.settings.srv = _.toString(answers.srv) === 'true'; scope.database.settings.port = answers.port; scope.database.settings.database = answers.database; scope.database.settings.username = answers.username; scope.database.settings.password = answers.password; - scope.database.options.authenticationDatabase = answers.authenticationDatabase; + if (answers.srv) { + scope.database.settings.srv = _.toString(answers.srv) === 'true'; + } + if (answers.authenticationDatabase) { + scope.database.options.authenticationDatabase = answers.authenticationDatabase; + } if (scope.client.database === 'mongo') { scope.database.options.ssl = _.toString(answers.ssl) === 'true'; } else { diff --git a/packages/strapi-generate-new/lib/index.js b/packages/strapi-generate-new/lib/index.js index 7aacf6329b..f96ba44cde 100644 --- a/packages/strapi-generate-new/lib/index.js +++ b/packages/strapi-generate-new/lib/index.js @@ -34,6 +34,14 @@ module.exports = { jsonfile: database }, + 'config/environments/production/database.json': { + jsonfile: database + }, + + 'config/environments/staging/database.json': { + jsonfile: database + }, + // Copy dot files. '.editorconfig': { copy: 'editorconfig' diff --git a/packages/strapi-generate-new/package.json b/packages/strapi-generate-new/package.json index 09457e33a1..a231e8943d 100644 --- a/packages/strapi-generate-new/package.json +++ b/packages/strapi-generate-new/package.json @@ -1,6 +1,6 @@ { "name": "strapi-generate-new", - "version": "3.0.0-alpha.19", + "version": "3.0.0-alpha.21", "description": "Generate a new Strapi application.", "homepage": "http://strapi.io", "keywords": [ @@ -20,7 +20,7 @@ "lodash": "^4.17.5", "ora": "^2.1.0", "request": "^2.88.0", - "strapi-utils": "3.0.0-alpha.19", + "strapi-utils": "3.0.0-alpha.21", "uuid": "^3.1.0" }, "scripts": { diff --git a/packages/strapi-generate-plugin/package.json b/packages/strapi-generate-plugin/package.json index 5860f2306a..5ea99d8413 100644 --- a/packages/strapi-generate-plugin/package.json +++ b/packages/strapi-generate-plugin/package.json @@ -1,6 +1,6 @@ { "name": "strapi-generate-plugin", - "version": "3.0.0-alpha.19", + "version": "3.0.0-alpha.21", "description": "Generate an plugin for a Strapi application.", "homepage": "http://strapi.io", "keywords": [ diff --git a/packages/strapi-generate-policy/package.json b/packages/strapi-generate-policy/package.json index cea23c27da..0dc5a57f15 100644 --- a/packages/strapi-generate-policy/package.json +++ b/packages/strapi-generate-policy/package.json @@ -1,6 +1,6 @@ { "name": "strapi-generate-policy", - "version": "3.0.0-alpha.19", + "version": "3.0.0-alpha.21", "description": "Generate a policy for a Strapi API.", "homepage": "http://strapi.io", "keywords": [ diff --git a/packages/strapi-generate-service/package.json b/packages/strapi-generate-service/package.json index fc5a10e61d..d4da4b5a8e 100644 --- a/packages/strapi-generate-service/package.json +++ b/packages/strapi-generate-service/package.json @@ -1,6 +1,6 @@ { "name": "strapi-generate-service", - "version": "3.0.0-alpha.19", + "version": "3.0.0-alpha.21", "description": "Generate a service for a Strapi API.", "homepage": "http://strapi.io", "keywords": [ diff --git a/packages/strapi-generate/package.json b/packages/strapi-generate/package.json index ff5c256d16..15a42cd28e 100644 --- a/packages/strapi-generate/package.json +++ b/packages/strapi-generate/package.json @@ -1,6 +1,6 @@ { "name": "strapi-generate", - "version": "3.0.0-alpha.19", + "version": "3.0.0-alpha.21", "description": "Master of ceremonies for the Strapi generators.", "homepage": "http://strapi.io", "keywords": [ @@ -17,7 +17,7 @@ "fs-extra": "^4.0.0", "lodash": "^4.17.5", "reportback": "^2.0.1", - "strapi-utils": "3.0.0-alpha.19" + "strapi-utils": "3.0.0-alpha.21" }, "author": { "name": "Strapi team", diff --git a/packages/strapi-helper-plugin/package.json b/packages/strapi-helper-plugin/package.json index 25ac5263e7..47afd44fe0 100644 --- a/packages/strapi-helper-plugin/package.json +++ b/packages/strapi-helper-plugin/package.json @@ -1,6 +1,6 @@ { "name": "strapi-helper-plugin", - "version": "3.0.0-alpha.19", + "version": "3.0.0-alpha.21", "description": "Helper for Strapi plugins development", "engines": { "node": ">= 10.0.0", diff --git a/packages/strapi-hook-bookshelf/lib/index.js b/packages/strapi-hook-bookshelf/lib/index.js index 794f82eb87..8643b4781e 100644 --- a/packages/strapi-hook-bookshelf/lib/index.js +++ b/packages/strapi-hook-bookshelf/lib/index.js @@ -86,6 +86,16 @@ module.exports = function(strapi) { primaryKey: 'id', primaryKeyType: _.get(definition, 'options.idAttributeType', 'integer') }); + + // Use default timestamp column names if value is `true` + if (_.get(definition, 'options.timestamps', false) === true) { + _.set(definition, 'options.timestamps', ['created_at', 'updated_at']); + } + // Use false for values other than `Boolean` or `Array` + if (!_.isArray(_.get(definition, 'options.timestamps')) && !_.isBoolean(_.get(definition, 'options.timestamps'))) { + _.set(definition, 'options.timestamps', false); + } + // Register the final model for Bookshelf. const loadedModel = _.assign({ tableName: definition.collectionName, @@ -100,14 +110,7 @@ module.exports = function(strapi) { return acc; }, {}) }, definition.options); - // Use default timestamp column names if value is `true` - if (_.get(loadedModel, 'hasTimestamps') === true) { - _.set(loadedModel, 'hasTimestamps', ['created_at', 'updated_at']); - } - // Use false for values other than `Boolean` or `Array` - if (!_.isArray(_.get(loadedModel, 'hasTimestamps')) && !_.isBoolean(_.get(loadedModel, 'hasTimestamps'))) { - _.set(loadedModel, 'hasTimestamps', false); - } + if (_.isString(_.get(connection, 'options.pivot_prefix'))) { loadedModel.toJSON = function(options = {}) { const { shallow = false, omitPivot = false } = options; diff --git a/packages/strapi-hook-bookshelf/package.json b/packages/strapi-hook-bookshelf/package.json index e22975a8e6..cc88d3e9bf 100644 --- a/packages/strapi-hook-bookshelf/package.json +++ b/packages/strapi-hook-bookshelf/package.json @@ -1,6 +1,6 @@ { "name": "strapi-hook-bookshelf", - "version": "3.0.0-alpha.19", + "version": "3.0.0-alpha.21", "description": "Bookshelf hook for the Strapi framework", "homepage": "http://strapi.io", "keywords": [ @@ -21,8 +21,8 @@ "lodash": "^4.17.5", "pluralize": "^6.0.0", "rimraf": "^2.6.2", - "strapi-hook-knex": "3.0.0-alpha.19", - "strapi-utils": "3.0.0-alpha.19" + "strapi-hook-knex": "3.0.0-alpha.21", + "strapi-utils": "3.0.0-alpha.21" }, "strapi": { "dependencies": [ diff --git a/packages/strapi-hook-ejs/package.json b/packages/strapi-hook-ejs/package.json index 2c2c9f1886..8e6f07809c 100644 --- a/packages/strapi-hook-ejs/package.json +++ b/packages/strapi-hook-ejs/package.json @@ -1,6 +1,6 @@ { "name": "strapi-hook-ejs", - "version": "3.0.0-alpha.19", + "version": "3.0.0-alpha.21", "description": "EJS hook for the Strapi framework", "homepage": "http://strapi.io", "keywords": [ diff --git a/packages/strapi-hook-knex/lib/index.js b/packages/strapi-hook-knex/lib/index.js index ceacd92131..4fca4e6398 100644 --- a/packages/strapi-hook-knex/lib/index.js +++ b/packages/strapi-hook-knex/lib/index.js @@ -18,8 +18,7 @@ const CLIENTS = [ 'sqlite3', 'mariasql', 'oracle', 'strong-oracle', - 'mssql', - 'websql' + 'mssql' ]; /** @@ -65,9 +64,6 @@ module.exports = strapi => { case 'ms': connection.settings.client = 'mssql'; break; - case 'web': - connection.settings.client = 'websql'; - break; } // Make sure the client is supported. @@ -95,26 +91,35 @@ module.exports = strapi => { password: _.get(connection.settings, 'password'), database: _.get(connection.settings, 'database'), charset: _.get(connection.settings, 'charset'), - schema: _.get(connection.settings, 'schema') || 'public', + schema: _.get(connection.settings, 'schema', 'public'), port: _.get(connection.settings, 'port'), socket: _.get(connection.settings, 'socketPath'), - ssl: _.get(connection.settings, 'ssl') || false, - timezone: _.get(connection.settings, 'timezone') || 'utc', + ssl: _.get(connection.settings, 'ssl', false), + timezone: _.get(connection.settings, 'timezone', 'utc'), }, - debug: _.get(connection.options, 'debug') || false, + debug: _.get(connection.options, 'debug', false), acquireConnectionTimeout: _.get(connection.options, 'acquireConnectionTimeout'), migrations: _.get(connection.options, 'migrations') }, strapi.config.hook.settings.knex); + options.pool = { + min: _.get(connection.options, 'pool.min', 0), + max: _.get(connection.options, 'pool.max', 10), + acquireTimeoutMillis: _.get(connection.options, 'pool.acquireTimeoutMillis', 2000), + createTimeoutMillis: _.get(connection.options, 'pool.createTimeoutMillis', 2000), + idleTimeoutMillis: _.get(connection.options, 'pool.idleTimeoutMillis', 30000), + reapIntervalMillis: _.get(connection.options, 'pool.reapIntervalMillis', 1000), + createRetryIntervalMillis: _.get(connection.options, 'pool.createRetryIntervalMillis', 200), + }; + if (options.client === 'pg') { client.types.setTypeParser(1700, 'text', parseFloat); if (_.isString(_.get(options.connection, 'schema'))) { options.pool = { - min: _.get(connection.options, 'pool.min') || 0, - max: _.get(connection.options, 'pool.max') || 10, afterCreate: (conn, cb) => { - conn.query(`SET SESSION SCHEMA '${options.connection.schema}';`, (err) => { + // conn.query(`SET SESSION SCHEMA '${options.connection.schema}';`, (err) => { // It seems the right way is the one below + conn.query(`SET search_path TO '${options.connection.schema}';`, (err) => { cb(err, conn); }); } diff --git a/packages/strapi-hook-knex/package.json b/packages/strapi-hook-knex/package.json index c6afce30e5..3c51922bd6 100644 --- a/packages/strapi-hook-knex/package.json +++ b/packages/strapi-hook-knex/package.json @@ -1,6 +1,6 @@ { "name": "strapi-hook-knex", - "version": "3.0.0-alpha.19", + "version": "3.0.0-alpha.21", "description": "Knex hook for the Strapi framework", "homepage": "http://strapi.io", "keywords": [ @@ -16,7 +16,7 @@ }, "main": "./lib", "dependencies": { - "knex": "^0.13.0", + "knex": "^0.16.3", "lodash": "^4.17.5" }, "author": { diff --git a/packages/strapi-hook-mongoose/lib/index.js b/packages/strapi-hook-mongoose/lib/index.js index 972990cf0c..4daf8faa68 100644 --- a/packages/strapi-hook-mongoose/lib/index.js +++ b/packages/strapi-hook-mongoose/lib/index.js @@ -60,7 +60,9 @@ module.exports = function (strapi) { // Connect to mongo database const connectOptions = {}; - const options = {}; + const options = { + useFindAndModify: false + }; if (!_.isEmpty(username)) { connectOptions.user = username; @@ -77,6 +79,7 @@ module.exports = function (strapi) { connectOptions.ssl = ssl === true || ssl === 'true'; connectOptions.useNewUrlParser = true; connectOptions.dbName = database; + connectOptions.useCreateIndex = true; options.debug = debug === true || debug === 'true'; @@ -157,6 +160,28 @@ module.exports = function (strapi) { } else { this._mongooseOptions.populate[association.alias].path = `${association.alias}.ref`; } + } else { + if (!this._mongooseOptions.populate) { + this._mongooseOptions.populate = {}; + } + + // Images are not displayed in populated data. + // We automatically populate morph relations. + if (association.nature === 'oneToManyMorph' || association.nature === 'manyToManyMorph') { + this._mongooseOptions.populate[association.alias] = { + path: association.alias, + match: { + [`${association.via}.${association.filter}`]: association.alias, + [`${association.via}.kind`]: definition.globalId + }, + options: { + sort: '-createdAt' + }, + select: undefined, + model: undefined, + _docs: {} + }; + } } next(); }); @@ -216,6 +241,7 @@ module.exports = function (strapi) { collection.schema.set('timestamps', timestamps); } else { collection.schema.set('timestamps', _.get(definition, 'options.timestamps') === true); + _.set(definition, 'options.timestamps', _.get(definition, 'options.timestamps') === true ? ['createdAt', 'updatedAt'] : false); } collection.schema.set('minimize', _.get(definition, 'options.minimize', false) === true); @@ -550,4 +576,4 @@ module.exports = function (strapi) { }, relations); return hook; -}; \ No newline at end of file +}; diff --git a/packages/strapi-hook-mongoose/lib/relations.js b/packages/strapi-hook-mongoose/lib/relations.js index a2db86576c..4cdd4429f1 100644 --- a/packages/strapi-hook-mongoose/lib/relations.js +++ b/packages/strapi-hook-mongoose/lib/relations.js @@ -239,7 +239,7 @@ module.exports = { virtualFields.push( this - .update({ + .updateOne({ [this.primaryKey]: getValuePrimaryKey(params, this.primaryKey) }, values, { strict: false diff --git a/packages/strapi-hook-mongoose/package.json b/packages/strapi-hook-mongoose/package.json index f8678381c7..ee6d19100d 100644 --- a/packages/strapi-hook-mongoose/package.json +++ b/packages/strapi-hook-mongoose/package.json @@ -1,6 +1,6 @@ { "name": "strapi-hook-mongoose", - "version": "3.0.0-alpha.19", + "version": "3.0.0-alpha.21", "description": "Mongoose hook for the Strapi framework", "homepage": "http://strapi.io", "keywords": [ @@ -20,7 +20,7 @@ "mongoose-float": "^1.0.3", "pluralize": "^6.0.0", "rimraf": "^2.6.2", - "strapi-utils": "3.0.0-alpha.19" + "strapi-utils": "3.0.0-alpha.21" }, "author": { "email": "hi@strapi.io", diff --git a/packages/strapi-hook-redis/package.json b/packages/strapi-hook-redis/package.json index 964ca648c5..5f207293a1 100644 --- a/packages/strapi-hook-redis/package.json +++ b/packages/strapi-hook-redis/package.json @@ -1,6 +1,6 @@ { "name": "strapi-hook-redis", - "version": "3.0.0-alpha.19", + "version": "3.0.0-alpha.21", "description": "Redis hook for the Strapi framework", "homepage": "http://strapi.io", "keywords": [ @@ -19,7 +19,7 @@ "lodash": "^4.17.5", "rimraf": "^2.6.2", "stack-trace": "0.0.10", - "strapi-utils": "3.0.0-alpha.19" + "strapi-utils": "3.0.0-alpha.21" }, "author": { "email": "hi@strapi.io", diff --git a/packages/strapi-lint/package.json b/packages/strapi-lint/package.json index 9cbc4a447f..8674a03c36 100644 --- a/packages/strapi-lint/package.json +++ b/packages/strapi-lint/package.json @@ -1,6 +1,6 @@ { "name": "strapi-lint", - "version": "3.0.0-alpha.19", + "version": "3.0.0-alpha.21", "description": "Strapi eslint and prettier configurations", "directories": { "lib": "lib" diff --git a/packages/strapi-middleware-views/package.json b/packages/strapi-middleware-views/package.json index 11fa8372bf..8326cdbc26 100644 --- a/packages/strapi-middleware-views/package.json +++ b/packages/strapi-middleware-views/package.json @@ -1,6 +1,6 @@ { "name": "strapi-middleware-views", - "version": "3.0.0-alpha.19", + "version": "3.0.0-alpha.21", "description": "Views middleware to enable server-side rendering for the Strapi framework", "homepage": "http://strapi.io", "keywords": [ diff --git a/packages/strapi-plugin-content-manager/config/functions/bootstrap.js b/packages/strapi-plugin-content-manager/config/functions/bootstrap.js index 3886c5b8cc..bdeb7759f2 100644 --- a/packages/strapi-plugin-content-manager/config/functions/bootstrap.js +++ b/packages/strapi-plugin-content-manager/config/functions/bootstrap.js @@ -17,7 +17,7 @@ const pickData = (model) => _.pick(model, [ 'globalId', 'globalName', 'orm', - 'options.timestamps', + 'options', 'loadedModel', 'primaryKey', 'associations' @@ -383,6 +383,12 @@ module.exports = async cb => { _.set(prevSchema.models, fieldsPath, currentFields); }); + schemaApis.map((model) => { + const isPlugin = model.includes('plugins.'); + _.set(prevSchema.models[model], 'info', _.get(!isPlugin ? strapi.models[model] : strapi[model], 'info')); + _.set(prevSchema.models[model], 'options', _.get(!isPlugin ? strapi.models[model] : strapi[model], 'options')); + }); + await pluginStore.set({ key: 'schema', value: prevSchema }); } catch(err) { diff --git a/packages/strapi-plugin-content-manager/config/queries/mongoose.js b/packages/strapi-plugin-content-manager/config/queries/mongoose.js index 27a4ca6ad8..a3dabbdb35 100644 --- a/packages/strapi-plugin-content-manager/config/queries/mongoose.js +++ b/packages/strapi-plugin-content-manager/config/queries/mongoose.js @@ -15,7 +15,7 @@ module.exports = { count: async function (params) { return Number(await this .where(params.where) - .count()); + .countDocuments()); }, search: async function (params, populate) { // eslint-disable-line no-unused-vars @@ -81,7 +81,7 @@ module.exports = { return this .find({ $or }) - .count(); + .countDocuments(); }, findOne: async function (params, populate, raw = true) { @@ -150,7 +150,7 @@ module.exports = { deleteMany: async function (params) { return this - .remove({ + .deleteMany({ [this.primaryKey]: { $in: params[this.primaryKey] || params.id } diff --git a/packages/strapi-plugin-content-manager/controllers/ContentManager.js b/packages/strapi-plugin-content-manager/controllers/ContentManager.js index 7a580cf982..c5700c8696 100644 --- a/packages/strapi-plugin-content-manager/controllers/ContentManager.js +++ b/packages/strapi-plugin-content-manager/controllers/ContentManager.js @@ -64,6 +64,8 @@ module.exports = { try { // Create an entry using `queries` system ctx.body = await strapi.plugins['content-manager'].services['contentmanager'].add(ctx.params, ctx.request.body, source); + + strapi.emit('didCreateFirstContentTypeEntry', ctx.params, source); } catch(error) { strapi.log.error(error); ctx.badRequest(null, ctx.request.admin ? [{ messages: [{ id: error.message, field: error.field }] }] : error.message); diff --git a/packages/strapi-plugin-content-manager/package.json b/packages/strapi-plugin-content-manager/package.json index 00b77c04e3..04e197902f 100644 --- a/packages/strapi-plugin-content-manager/package.json +++ b/packages/strapi-plugin-content-manager/package.json @@ -1,6 +1,6 @@ { "name": "strapi-plugin-content-manager", - "version": "3.0.0-alpha.19", + "version": "3.0.0-alpha.21", "description": "A powerful UI to easily manage your data.", "strapi": { "name": "Content Manager", @@ -26,7 +26,7 @@ "draft-js": "^0.10.5", "react-select": "^1.2.1", "showdown": "^1.8.6", - "strapi-helper-plugin": "3.0.0-alpha.19" + "strapi-helper-plugin": "3.0.0-alpha.21" }, "dependencies": { "pluralize": "^7.0.0" diff --git a/packages/strapi-plugin-content-manager/services/ContentManager.js b/packages/strapi-plugin-content-manager/services/ContentManager.js index d3bfd7ae44..60fd2c1934 100644 --- a/packages/strapi-plugin-content-manager/services/ContentManager.js +++ b/packages/strapi-plugin-content-manager/services/ContentManager.js @@ -10,7 +10,7 @@ module.exports = { fetchAll: async (params, query) => { const { limit, skip, sort, query : request, queryAttribute, source, populate = [] } = query; const filters = strapi.utils.models.convertParams(params.model, query); - const where = !_.isEmpty(request) ? request : filters.where; + const { where = {} } = !_.isEmpty(request) ? strapi.utils.models.convertParams(params.model, request) : filters; // Find entries using `queries` system return await strapi.query(params.model, source).find({ diff --git a/packages/strapi-plugin-content-type-builder/controllers/ContentTypeBuilder.js b/packages/strapi-plugin-content-type-builder/controllers/ContentTypeBuilder.js index 907caf2a25..ded45f0277 100644 --- a/packages/strapi-plugin-content-type-builder/controllers/ContentTypeBuilder.js +++ b/packages/strapi-plugin-content-type-builder/controllers/ContentTypeBuilder.js @@ -78,6 +78,10 @@ module.exports = { try { fs.writeFileSync(modelFilePath, JSON.stringify(modelJSON, null, 2), 'utf8'); + if (_.isEmpty(strapi.api)) { + strapi.emit('didCreateFirstContentType'); + } + ctx.send({ ok: true }); strapi.reload(); diff --git a/packages/strapi-plugin-content-type-builder/package.json b/packages/strapi-plugin-content-type-builder/package.json index 9e4fc78981..8cdebb552a 100644 --- a/packages/strapi-plugin-content-type-builder/package.json +++ b/packages/strapi-plugin-content-type-builder/package.json @@ -1,6 +1,6 @@ { "name": "strapi-plugin-content-type-builder", - "version": "3.0.0-alpha.19", + "version": "3.0.0-alpha.21", "description": "Strapi plugin to create content type (API).", "strapi": { "name": "Content Type Builder", @@ -24,11 +24,11 @@ "dependencies": { "immutable": "^3.8.2", "pluralize": "^7.0.0", - "strapi-generate": "3.0.0-alpha.19", - "strapi-generate-api": "3.0.0-alpha.19" + "strapi-generate": "3.0.0-alpha.21", + "strapi-generate-api": "3.0.0-alpha.21" }, "devDependencies": { - "strapi-helper-plugin": "3.0.0-alpha.19" + "strapi-helper-plugin": "3.0.0-alpha.21" }, "author": { "name": "Strapi team", diff --git a/packages/strapi-plugin-documentation/package.json b/packages/strapi-plugin-documentation/package.json index 9573370bc6..6bda71f8b7 100755 --- a/packages/strapi-plugin-documentation/package.json +++ b/packages/strapi-plugin-documentation/package.json @@ -1,6 +1,6 @@ { "name": "strapi-plugin-documentation", - "version": "3.0.0-alpha.19", + "version": "3.0.0-alpha.21", "description": "This is the description of the plugin.", "strapi": { "name": "Documentation", @@ -29,7 +29,7 @@ "swagger-ui-dist": "^3.18.3-republish2" }, "devDependencies": { - "strapi-helper-plugin": "3.0.0-alpha.19" + "strapi-helper-plugin": "3.0.0-alpha.21" }, "author": { "name": "soupette", diff --git a/packages/strapi-plugin-email/config/queries/mongoose.js b/packages/strapi-plugin-email/config/queries/mongoose.js index 8f7ebbebd6..620cd2cf1b 100644 --- a/packages/strapi-plugin-email/config/queries/mongoose.js +++ b/packages/strapi-plugin-email/config/queries/mongoose.js @@ -13,7 +13,7 @@ module.exports = { count: async function (params = {}) { return Number(await this - .count(params)); + .countDocuments(params)); }, findOne: async function (params, populate) { @@ -68,7 +68,7 @@ module.exports = { }; } - return this.update(search, params, { + return this.updateOne(search, params, { strict: false }) .catch((error) => { @@ -82,7 +82,7 @@ module.exports = { delete: async function (params) { // Delete entry. return this - .remove({ + .deleteOne({ [this.primaryKey]: params[this.primaryKey] || params.id }); }, diff --git a/packages/strapi-plugin-email/package.json b/packages/strapi-plugin-email/package.json index 1049aa8d64..23b94c30f4 100644 --- a/packages/strapi-plugin-email/package.json +++ b/packages/strapi-plugin-email/package.json @@ -1,6 +1,6 @@ { "name": "strapi-plugin-email", - "version": "3.0.0-alpha.19", + "version": "3.0.0-alpha.21", "description": "This is the description of the plugin.", "strapi": { "name": "Email", @@ -22,11 +22,11 @@ "prepublishOnly": "IS_MONOREPO=true npm run build" }, "dependencies": { - "strapi-provider-email-sendmail": "3.0.0-alpha.19" + "strapi-provider-email-sendmail": "3.0.0-alpha.21" }, "devDependencies": { "react-copy-to-clipboard": "5.0.1", - "strapi-helper-plugin": "3.0.0-alpha.19" + "strapi-helper-plugin": "3.0.0-alpha.21" }, "author": { "name": "Strapi team", diff --git a/packages/strapi-plugin-graphql/hooks/graphql/index.js b/packages/strapi-plugin-graphql/hooks/graphql/index.js index 8f36e33166..cd6dfbeb8b 100644 --- a/packages/strapi-plugin-graphql/hooks/graphql/index.js +++ b/packages/strapi-plugin-graphql/hooks/graphql/index.js @@ -174,6 +174,8 @@ module.exports = strapi => { serverParams.playground = { endpoint: strapi.plugins.graphql.config.endpoint, }; + + serverParams.introspection = true; } const server = new ApolloServer(serverParams); diff --git a/packages/strapi-plugin-graphql/package.json b/packages/strapi-plugin-graphql/package.json index 86927489bf..6641fa7cc9 100644 --- a/packages/strapi-plugin-graphql/package.json +++ b/packages/strapi-plugin-graphql/package.json @@ -1,6 +1,6 @@ { "name": "strapi-plugin-graphql", - "version": "3.0.0-alpha.19", + "version": "3.0.0-alpha.21", "description": "This is the description of the plugin.", "strapi": { "name": "graphql", @@ -31,7 +31,7 @@ "graphql-type-datetime": "^0.2.2", "graphql-type-json": "^0.2.1", "pluralize": "^7.0.0", - "strapi-utils": "3.0.0-alpha.19" + "strapi-utils": "3.0.0-alpha.21" }, "author": { "name": "A Strapi developer", diff --git a/packages/strapi-plugin-graphql/services/Loaders.js b/packages/strapi-plugin-graphql/services/Loaders.js index 5f391c935c..3976f36926 100644 --- a/packages/strapi-plugin-graphql/services/Loaders.js +++ b/packages/strapi-plugin-graphql/services/Loaders.js @@ -143,7 +143,7 @@ module.exports = { limit: 100, }; - params.query[query.alias] = _.uniq(query.ids.filter(x => !_.isEmpty(x)).map(x => x.toString())); + params.query[query.alias] = _.uniq(query.ids.filter(x => !_.isEmpty(x) || _.isInteger(x)).map(x => x.toString())); if (['id', '_id'].includes(query.alias)) { // However, we're applying a limit based on the number of entries we've to fetch. diff --git a/packages/strapi-plugin-settings-manager/package.json b/packages/strapi-plugin-settings-manager/package.json index 0890a67353..4b4f23c09d 100644 --- a/packages/strapi-plugin-settings-manager/package.json +++ b/packages/strapi-plugin-settings-manager/package.json @@ -1,6 +1,6 @@ { "name": "strapi-plugin-settings-manager", - "version": "3.0.0-alpha.19", + "version": "3.0.0-alpha.21", "description": "Strapi plugin to manage settings.", "strapi": { "name": "Settings Manager", @@ -25,7 +25,7 @@ "devDependencies": { "flag-icon-css": "^2.8.0", "react-select": "^1.0.0-rc.5", - "strapi-helper-plugin": "3.0.0-alpha.19" + "strapi-helper-plugin": "3.0.0-alpha.21" }, "author": { "name": "Strapi team", diff --git a/packages/strapi-plugin-upload/config/queries/mongoose.js b/packages/strapi-plugin-upload/config/queries/mongoose.js index 8f7ebbebd6..003d54269a 100644 --- a/packages/strapi-plugin-upload/config/queries/mongoose.js +++ b/packages/strapi-plugin-upload/config/queries/mongoose.js @@ -13,7 +13,7 @@ module.exports = { count: async function (params = {}) { return Number(await this - .count(params)); + .countDocuments(params)); }, findOne: async function (params, populate) { @@ -68,7 +68,7 @@ module.exports = { }; } - return this.update(search, params, { + return this.updateOne(search, params, { strict: false }) .catch((error) => { diff --git a/packages/strapi-plugin-upload/package.json b/packages/strapi-plugin-upload/package.json index 9b209cb4c7..cd15c9cebc 100644 --- a/packages/strapi-plugin-upload/package.json +++ b/packages/strapi-plugin-upload/package.json @@ -1,6 +1,6 @@ { "name": "strapi-plugin-upload", - "version": "3.0.0-alpha.19", + "version": "3.0.0-alpha.21", "description": "This is the description of the plugin.", "strapi": { "name": "Files Upload", @@ -22,12 +22,12 @@ "prepublishOnly": "IS_MONOREPO=true npm run build" }, "dependencies": { - "strapi-provider-upload-local": "3.0.0-alpha.19", + "strapi-provider-upload-local": "3.0.0-alpha.21", "stream-to-array": "^2.3.0", "uuid": "^3.2.1" }, "devDependencies": { - "strapi-helper-plugin": "3.0.0-alpha.19" + "strapi-helper-plugin": "3.0.0-alpha.21" }, "author": { "name": "A Strapi developer", diff --git a/packages/strapi-plugin-users-permissions/admin/src/containers/EditPage/index.js b/packages/strapi-plugin-users-permissions/admin/src/containers/EditPage/index.js index 72f57a17e9..894027dc90 100644 --- a/packages/strapi-plugin-users-permissions/admin/src/containers/EditPage/index.js +++ b/packages/strapi-plugin-users-permissions/admin/src/containers/EditPage/index.js @@ -110,7 +110,7 @@ export class EditPage extends React.Component { // eslint-disable-line react/pre showLoaderForm = () => { const { editPage: { modifiedData }, match: { params: { actionType } } } = this.props; - return actionType !== 'create' && get(modifiedData, ['name'], '') === ''; + return actionType !== 'create' && isEmpty(modifiedData); } showLoaderPermissions = () => { diff --git a/packages/strapi-plugin-users-permissions/config/queries/mongoose.js b/packages/strapi-plugin-users-permissions/config/queries/mongoose.js index 53ce2cd17a..8c74435b9b 100644 --- a/packages/strapi-plugin-users-permissions/config/queries/mongoose.js +++ b/packages/strapi-plugin-users-permissions/config/queries/mongoose.js @@ -13,7 +13,7 @@ module.exports = { count: async function (params = {}) { return Number(await this - .count(params)); + .countDocuments(params)); }, findOne: async function (params, populate) { @@ -65,7 +65,7 @@ module.exports = { }; } - return this.update(search, params, { + return this.updateOne(search, params, { strict: false }) .catch((error) => { @@ -79,7 +79,7 @@ module.exports = { delete: async function (params) { // Delete entry. return this - .remove({ + .deleteOne({ [this.primaryKey]: params[this.primaryKey] || params.id }); }, @@ -87,7 +87,7 @@ module.exports = { deleteMany: async function (params) { // Delete entry. return this - .remove({ + .deleteMany({ [this.primaryKey]: { $in: params[this.primaryKey] || params.id } diff --git a/packages/strapi-plugin-users-permissions/controllers/UsersPermissions.js b/packages/strapi-plugin-users-permissions/controllers/UsersPermissions.js index d3a13ebfa0..0596df5e31 100644 --- a/packages/strapi-plugin-users-permissions/controllers/UsersPermissions.js +++ b/packages/strapi-plugin-users-permissions/controllers/UsersPermissions.js @@ -160,9 +160,11 @@ module.exports = { try { await strapi.plugins['users-permissions'].services.userspermissions.updateRole(roleID, ctx.request.body); + + strapi.emit('didOpenAccessToFetchContentTypeEntries', ctx.request.body); ctx.send({ ok: true }); - } catch(error) { + } catch (error) { ctx.badRequest(null, [{ messages: [{ id: 'An error occurred' }] }]); } }, diff --git a/packages/strapi-plugin-users-permissions/package.json b/packages/strapi-plugin-users-permissions/package.json index 4b47e26de9..0976092150 100644 --- a/packages/strapi-plugin-users-permissions/package.json +++ b/packages/strapi-plugin-users-permissions/package.json @@ -1,6 +1,6 @@ { "name": "strapi-plugin-users-permissions", - "version": "3.0.0-alpha.19", + "version": "3.0.0-alpha.21", "description": "Protect your API with a full-authentication process based on JWT", "strapi": { "name": "Roles & Permissions", @@ -29,11 +29,11 @@ "koa2-ratelimit": "^0.6.1", "purest": "^2.0.1", "request": "^2.83.0", - "strapi-utils": "3.0.0-alpha.19", + "strapi-utils": "3.0.0-alpha.21", "uuid": "^3.1.0" }, "devDependencies": { - "strapi-helper-plugin": "3.0.0-alpha.19" + "strapi-helper-plugin": "3.0.0-alpha.21" }, "author": { "name": "Strapi team", diff --git a/packages/strapi-plugin-users-permissions/services/UsersPermissions.js b/packages/strapi-plugin-users-permissions/services/UsersPermissions.js index 6df284bd8e..d3b4d6ec1d 100644 --- a/packages/strapi-plugin-users-permissions/services/UsersPermissions.js +++ b/packages/strapi-plugin-users-permissions/services/UsersPermissions.js @@ -420,7 +420,6 @@ module.exports = { arrayOfPromises.push(this.updateUserRole(user, authenticated._id || authenticated.id)); }); - return Promise.all(arrayOfPromises); }, diff --git a/packages/strapi-provider-email-amazon-ses/package.json b/packages/strapi-provider-email-amazon-ses/package.json index 50a34dcebd..0098b45b23 100644 --- a/packages/strapi-provider-email-amazon-ses/package.json +++ b/packages/strapi-provider-email-amazon-ses/package.json @@ -1,6 +1,6 @@ { "name": "strapi-provider-email-amazon-ses", - "version": "3.0.0-alpha.19", + "version": "3.0.0-alpha.21", "description": "Amazon SES provider for strapi email", "homepage": "http://strapi.io", "keywords": [ diff --git a/packages/strapi-provider-email-mailgun/package.json b/packages/strapi-provider-email-mailgun/package.json index 3a50c7f4ae..929fbfc309 100644 --- a/packages/strapi-provider-email-mailgun/package.json +++ b/packages/strapi-provider-email-mailgun/package.json @@ -1,6 +1,6 @@ { "name": "strapi-provider-email-mailgun", - "version": "3.0.0-alpha.19", + "version": "3.0.0-alpha.21", "description": "Mailgun provider for strapi email plugin", "homepage": "http://strapi.io", "keywords": [ diff --git a/packages/strapi-provider-email-sendgrid/package.json b/packages/strapi-provider-email-sendgrid/package.json index 3ee4e4004b..79cfa053cd 100644 --- a/packages/strapi-provider-email-sendgrid/package.json +++ b/packages/strapi-provider-email-sendgrid/package.json @@ -1,6 +1,6 @@ { "name": "strapi-provider-email-sendgrid", - "version": "3.0.0-alpha.19", + "version": "3.0.0-alpha.21", "description": "Sendgrid provider for strapi email", "homepage": "http://strapi.io", "keywords": [ diff --git a/packages/strapi-provider-email-sendmail/package.json b/packages/strapi-provider-email-sendmail/package.json index ff825739be..b7e1379087 100644 --- a/packages/strapi-provider-email-sendmail/package.json +++ b/packages/strapi-provider-email-sendmail/package.json @@ -1,6 +1,6 @@ { "name": "strapi-provider-email-sendmail", - "version": "3.0.0-alpha.19", + "version": "3.0.0-alpha.21", "description": "Sendmail provider for strapi email", "homepage": "http://strapi.io", "keywords": [ diff --git a/packages/strapi-provider-upload-aws-s3/package.json b/packages/strapi-provider-upload-aws-s3/package.json index 0706ad7bf9..43a74aa6a7 100644 --- a/packages/strapi-provider-upload-aws-s3/package.json +++ b/packages/strapi-provider-upload-aws-s3/package.json @@ -1,6 +1,6 @@ { "name": "strapi-provider-upload-aws-s3", - "version": "3.0.0-alpha.19", + "version": "3.0.0-alpha.21", "description": "AWS S3 provider for strapi upload", "homepage": "http://strapi.io", "keywords": [ diff --git a/packages/strapi-provider-upload-cloudinary/package.json b/packages/strapi-provider-upload-cloudinary/package.json index adcd163f5e..20465e1c61 100644 --- a/packages/strapi-provider-upload-cloudinary/package.json +++ b/packages/strapi-provider-upload-cloudinary/package.json @@ -1,6 +1,6 @@ { "name": "strapi-provider-upload-cloudinary", - "version": "3.0.0-alpha.19", + "version": "3.0.0-alpha.21", "description": "Cloudinary provider for strapi upload", "homepage": "http://strapi.io", "keywords": [ diff --git a/packages/strapi-provider-upload-local/package.json b/packages/strapi-provider-upload-local/package.json index 63a302eea9..85a26e1db9 100644 --- a/packages/strapi-provider-upload-local/package.json +++ b/packages/strapi-provider-upload-local/package.json @@ -1,6 +1,6 @@ { "name": "strapi-provider-upload-local", - "version": "3.0.0-alpha.19", + "version": "3.0.0-alpha.21", "description": "Local provider for strapi upload", "homepage": "http://strapi.io", "keywords": [ diff --git a/packages/strapi-provider-upload-rackspace/package.json b/packages/strapi-provider-upload-rackspace/package.json index 12e751a8e4..4c60218b97 100644 --- a/packages/strapi-provider-upload-rackspace/package.json +++ b/packages/strapi-provider-upload-rackspace/package.json @@ -1,6 +1,6 @@ { "name": "strapi-provider-upload-rackspace", - "version": "3.0.0-alpha.19", + "version": "3.0.0-alpha.21", "description": "Rackspace provider for strapi upload", "main": "./lib", "scripts": { diff --git a/packages/strapi-utils/lib/models.js b/packages/strapi-utils/lib/models.js index 73fa91c995..349628459d 100644 --- a/packages/strapi-utils/lib/models.js +++ b/packages/strapi-utils/lib/models.js @@ -486,7 +486,7 @@ module.exports = { const suffix = key.split('_'); // Mysql stores boolean as 1 or 0 if (client === 'mysql' && _.get(models, [model, 'attributes', suffix, 'type']) === 'boolean') { - formattedValue = value === 'true' ? '1' : '0'; + formattedValue = value.toString() === 'true' ? '1' : '0'; } let type; diff --git a/packages/strapi-utils/package.json b/packages/strapi-utils/package.json index a7185fd8e9..c47a7c1ad8 100644 --- a/packages/strapi-utils/package.json +++ b/packages/strapi-utils/package.json @@ -1,6 +1,6 @@ { "name": "strapi-utils", - "version": "3.0.0-alpha.19", + "version": "3.0.0-alpha.21", "description": "Shared utilities for the Strapi packages", "homepage": "http://strapi.io", "keywords": [ @@ -20,7 +20,7 @@ "dependencies": { "commander": "^2.11.0", "joi-json": "^2.0.1", - "knex": "^0.13.0", + "knex": "^0.16.3", "lodash": "^4.17.5", "pino": "^4.7.1", "shelljs": "^0.7.7" diff --git a/packages/strapi/bin/strapi-new.js b/packages/strapi/bin/strapi-new.js index 707a7bbe35..87a11ce1b4 100644 --- a/packages/strapi/bin/strapi-new.js +++ b/packages/strapi/bin/strapi-new.js @@ -61,6 +61,7 @@ module.exports = function (name, cliArguments) { settings: { client: cliArguments.dbclient, host: cliArguments.dbhost, + srv: cliArguments.dbsrv, port: cliArguments.dbport, database: cliArguments.dbname, username: cliArguments.dbusername, diff --git a/packages/strapi/bin/strapi.js b/packages/strapi/bin/strapi.js index 4aa5d87cdd..03dad62503 100755 --- a/packages/strapi/bin/strapi.js +++ b/packages/strapi/bin/strapi.js @@ -56,6 +56,7 @@ program .option('--debug', 'Display database connection error') .option('--dbclient ', 'Database client') .option('--dbhost ', 'Database host') + .option('--dbsrv ', 'Database srv') .option('--dbport ', 'Database port') .option('--dbname ', 'Database name') .option('--dbusername ', 'Database username') diff --git a/packages/strapi/lib/core/admin.js b/packages/strapi/lib/core/admin.js index 1e2f91aca1..57f0b17fc9 100644 --- a/packages/strapi/lib/core/admin.js +++ b/packages/strapi/lib/core/admin.js @@ -66,6 +66,8 @@ module.exports = function() { resolve(); }); + } else { + resolve(); } }); }); diff --git a/packages/strapi/lib/core/store.js b/packages/strapi/lib/core/store.js index 04fe05c0ea..6d95c00860 100644 --- a/packages/strapi/lib/core/store.js +++ b/packages/strapi/lib/core/store.js @@ -110,7 +110,7 @@ module.exports = function () { }); strapi.models['core_store'].orm === 'mongoose' - ? await strapi.models['core_store'].update({ _id: data._id }, data, { strict: false }) + ? await strapi.models['core_store'].updateOne({ _id: data._id }, data, { strict: false }) : await strapi.models['core_store'].forge({ id: data.id }).save(data, { patch: true }); } else { Object.assign(where, { diff --git a/packages/strapi/package.json b/packages/strapi/package.json index 45977dddba..e3c641a254 100644 --- a/packages/strapi/package.json +++ b/packages/strapi/package.json @@ -1,6 +1,6 @@ { "name": "strapi", - "version": "3.0.0-alpha.19", + "version": "3.0.0-alpha.21", "description": "An open source solution to create and manage your own API. It provides a powerful dashboard and features to make your life easier.", "homepage": "http://strapi.io", "keywords": [ @@ -60,16 +60,16 @@ "rimraf": "^2.6.2", "semver": "^5.4.1", "stack-trace": "0.0.10", - "strapi-generate": "3.0.0-alpha.19", - "strapi-generate-admin": "3.0.0-alpha.19", - "strapi-generate-api": "3.0.0-alpha.19", - "strapi-generate-controller": "3.0.0-alpha.19", - "strapi-generate-model": "3.0.0-alpha.19", - "strapi-generate-new": "3.0.0-alpha.19", - "strapi-generate-plugin": "3.0.0-alpha.19", - "strapi-generate-policy": "3.0.0-alpha.19", - "strapi-generate-service": "3.0.0-alpha.19", - "strapi-utils": "3.0.0-alpha.19" + "strapi-generate": "3.0.0-alpha.21", + "strapi-generate-admin": "3.0.0-alpha.21", + "strapi-generate-api": "3.0.0-alpha.21", + "strapi-generate-controller": "3.0.0-alpha.21", + "strapi-generate-model": "3.0.0-alpha.21", + "strapi-generate-new": "3.0.0-alpha.21", + "strapi-generate-plugin": "3.0.0-alpha.21", + "strapi-generate-policy": "3.0.0-alpha.21", + "strapi-generate-service": "3.0.0-alpha.21", + "strapi-utils": "3.0.0-alpha.21" }, "author": { "email": "hi@strapi.io",