Merge branch 'master' into master

This commit is contained in:
Jim LAURIE 2019-01-29 16:27:04 +01:00 committed by GitHub
commit 4ce2da5dc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
74 changed files with 375 additions and 165 deletions

View File

@ -15,7 +15,7 @@
- [ ] Plugin
<!-- Please note that all databases should be tested and confirmed to be working prior to the PR being merged. -->
**Manual testing done on the follow databases:**
**Manual testing done on the following databases:**
- [ ] Not applicable
- [ ] MongoDB
- [ ] MySQL

View File

@ -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.

View File

@ -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

View File

@ -14,7 +14,7 @@ Each controllers 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

View File

@ -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.

View File

@ -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).
:::

View File

@ -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)

View File

@ -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)
<br>
::: note
Feel free to [join us on Slack](http://slack.strapi.io) and ask questions about the migration process.
:::
<br>
## 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).
<br>
## 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.
<br>
## 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.
<br>
## 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`.
<br>
That's all, you have now upgraded to Strapi `alpha.20`.

View File

@ -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)
<br>
::: note
Feel free to [join us on Slack](http://slack.strapi.io) and ask questions about the migration process.
:::
<br>
## 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).
<br>
## 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.
<br>
## 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.
<br>
## 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.
<br>
That's all, you have now upgraded to Strapi `alpha.21`.

View File

@ -1,6 +1,6 @@
{
"private": true,
"version": "3.0.0-alpha.19",
"version": "3.0.0-alpha.21",
"dependencies": {},
"devDependencies": {
"assert": "~1.3.0",

View File

@ -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",

View File

@ -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",

View File

@ -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": [

View File

@ -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 }));

View File

@ -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": [

View File

@ -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": [

View File

@ -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 || ''}"
}
}
}
}

View File

@ -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 || ''}"
}
}
}
}

View File

@ -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: {

View File

@ -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 {

View File

@ -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'

View File

@ -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": {

View File

@ -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": [

View File

@ -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": [

View File

@ -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": [

View File

@ -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",

View File

@ -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",

View File

@ -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;

View File

@ -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": [

View File

@ -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": [

View File

@ -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);
});
}

View File

@ -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": {

View File

@ -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;
};
};

View File

@ -239,7 +239,7 @@ module.exports = {
virtualFields.push(
this
.update({
.updateOne({
[this.primaryKey]: getValuePrimaryKey(params, this.primaryKey)
}, values, {
strict: false

View File

@ -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",

View File

@ -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",

View File

@ -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"

View File

@ -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": [

View File

@ -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) {

View File

@ -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
}

View File

@ -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);

View File

@ -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"

View File

@ -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({

View File

@ -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();

View File

@ -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",

View File

@ -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",

View File

@ -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
});
},

View File

@ -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",

View File

@ -174,6 +174,8 @@ module.exports = strapi => {
serverParams.playground = {
endpoint: strapi.plugins.graphql.config.endpoint,
};
serverParams.introspection = true;
}
const server = new ApolloServer(serverParams);

View File

@ -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",

View File

@ -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.

View File

@ -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",

View File

@ -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) => {

View File

@ -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",

View File

@ -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 = () => {

View File

@ -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
}

View File

@ -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' }] }]);
}
},

View File

@ -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",

View File

@ -420,7 +420,6 @@ module.exports = {
arrayOfPromises.push(this.updateUserRole(user, authenticated._id || authenticated.id));
});
return Promise.all(arrayOfPromises);
},

View File

@ -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": [

View File

@ -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": [

View File

@ -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": [

View File

@ -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": [

View File

@ -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": [

View File

@ -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": [

View File

@ -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": [

View File

@ -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": {

View File

@ -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;

View File

@ -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"

View File

@ -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,

View File

@ -56,6 +56,7 @@ program
.option('--debug', 'Display database connection error')
.option('--dbclient <dbclient>', 'Database client')
.option('--dbhost <dbhost>', 'Database host')
.option('--dbsrv <dbsrv>', 'Database srv')
.option('--dbport <dbport>', 'Database port')
.option('--dbname <dbname>', 'Database name')
.option('--dbusername <dbusername>', 'Database username')

View File

@ -66,6 +66,8 @@ module.exports = function() {
resolve();
});
} else {
resolve();
}
});
});

View File

@ -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, {

View File

@ -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",