mirror of
https://github.com/strapi/strapi.git
synced 2025-09-26 00:39:49 +00:00
Merge branch 'features/typescript' into typescript/types/schema
This commit is contained in:
commit
004024b58f
4
.github/actions/check-pr-status/package.json
vendored
4
.github/actions/check-pr-status/package.json
vendored
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "check-pr-status",
|
||||
"version": "4.1.11",
|
||||
"version": "4.1.12",
|
||||
"main": "dist/index.js",
|
||||
"license": "MIT",
|
||||
"private": true,
|
||||
@ -11,6 +11,6 @@
|
||||
"devDependencies": {
|
||||
"@actions/core": "1.8.1",
|
||||
"@actions/github": "5.0.0",
|
||||
"@vercel/ncc": "0.33.3"
|
||||
"@vercel/ncc": "0.34.0"
|
||||
}
|
||||
}
|
||||
|
17
.github/workflows/addToProject.yml
vendored
Normal file
17
.github/workflows/addToProject.yml
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
name: Add bugs to bugs project
|
||||
|
||||
on:
|
||||
issues:
|
||||
types:
|
||||
- opened
|
||||
- transferred
|
||||
|
||||
jobs:
|
||||
add-to-project:
|
||||
name: Add issue to Support Team project
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/add-to-project@main
|
||||
with:
|
||||
project-url: https://github.com/orgs/strapi/projects/15
|
||||
github-token: ${{ secrets.PROJECT_TRANSFER_TOKEN }}
|
2
.github/workflows/tests.yml
vendored
2
.github/workflows/tests.yml
vendored
@ -65,7 +65,7 @@ jobs:
|
||||
- name: Build
|
||||
run: yarn build
|
||||
- name: Run test
|
||||
run: yarn run -s test:front && codecov -C -F front
|
||||
run: yarn run -s test:front --coverage && codecov -C -F front
|
||||
|
||||
e2e_ce_pg:
|
||||
runs-on: ubuntu-latest
|
||||
|
2
examples/getstarted/.gitignore
vendored
2
examples/getstarted/.gitignore
vendored
@ -100,7 +100,7 @@ node_modules
|
||||
############################
|
||||
|
||||
testApp
|
||||
coverage
|
||||
/coverage/
|
||||
|
||||
############################
|
||||
# Strapi
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "getstarted",
|
||||
"private": true,
|
||||
"version": "4.1.11",
|
||||
"version": "4.1.12",
|
||||
"description": "A Strapi application.",
|
||||
"scripts": {
|
||||
"develop": "strapi develop",
|
||||
@ -12,17 +12,17 @@
|
||||
"strapi": "strapi"
|
||||
},
|
||||
"dependencies": {
|
||||
"@strapi/admin": "4.1.11",
|
||||
"@strapi/plugin-documentation": "4.1.11",
|
||||
"@strapi/plugin-graphql": "4.1.11",
|
||||
"@strapi/plugin-i18n": "4.1.11",
|
||||
"@strapi/plugin-sentry": "4.1.11",
|
||||
"@strapi/plugin-users-permissions": "4.1.11",
|
||||
"@strapi/provider-email-mailgun": "4.1.11",
|
||||
"@strapi/provider-upload-aws-s3": "4.1.11",
|
||||
"@strapi/provider-upload-cloudinary": "4.1.11",
|
||||
"@strapi/strapi": "4.1.11",
|
||||
"@strapi/utils": "4.1.11",
|
||||
"@strapi/admin": "4.1.12",
|
||||
"@strapi/plugin-documentation": "4.1.12",
|
||||
"@strapi/plugin-graphql": "4.1.12",
|
||||
"@strapi/plugin-i18n": "4.1.12",
|
||||
"@strapi/plugin-sentry": "4.1.12",
|
||||
"@strapi/plugin-users-permissions": "4.1.12",
|
||||
"@strapi/provider-email-mailgun": "4.1.12",
|
||||
"@strapi/provider-upload-aws-s3": "4.1.12",
|
||||
"@strapi/provider-upload-cloudinary": "4.1.12",
|
||||
"@strapi/strapi": "4.1.12",
|
||||
"@strapi/utils": "4.1.12",
|
||||
"@vscode/sqlite3": "5.0.8",
|
||||
"better-sqlite3": "7.4.6",
|
||||
"lodash": "4.17.21",
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "kitchensink",
|
||||
"private": true,
|
||||
"version": "4.1.11",
|
||||
"version": "4.1.12",
|
||||
"description": "A Strapi application.",
|
||||
"scripts": {
|
||||
"develop": "strapi develop",
|
||||
@ -12,12 +12,12 @@
|
||||
"strapi": "strapi"
|
||||
},
|
||||
"dependencies": {
|
||||
"@strapi/admin": "4.1.11",
|
||||
"@strapi/provider-email-mailgun": "4.1.11",
|
||||
"@strapi/provider-upload-aws-s3": "4.1.11",
|
||||
"@strapi/provider-upload-cloudinary": "4.1.11",
|
||||
"@strapi/strapi": "4.1.11",
|
||||
"@strapi/utils": "4.1.11",
|
||||
"@strapi/admin": "4.1.12",
|
||||
"@strapi/provider-email-mailgun": "4.1.12",
|
||||
"@strapi/provider-upload-aws-s3": "4.1.12",
|
||||
"@strapi/provider-upload-cloudinary": "4.1.12",
|
||||
"@strapi/strapi": "4.1.12",
|
||||
"@strapi/utils": "4.1.12",
|
||||
"lodash": "4.17.21",
|
||||
"mysql": "2.18.1",
|
||||
"passport-google-oauth2": "0.2.0",
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "4.1.11",
|
||||
"version": "4.1.12",
|
||||
"packages": [
|
||||
"packages/*",
|
||||
"examples/*"
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strapi/admin-test-utils",
|
||||
"version": "4.1.11",
|
||||
"version": "4.1.12",
|
||||
"private": true,
|
||||
"description": "Test utilities for the Strapi administration panel",
|
||||
"license": "MIT",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "create-strapi-app",
|
||||
"version": "4.1.11",
|
||||
"version": "4.1.12",
|
||||
"description": "Generate a new Strapi application.",
|
||||
"keywords": [
|
||||
"create-strapi-app",
|
||||
@ -38,7 +38,7 @@
|
||||
"test": "echo \"no tests yet\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@strapi/generate-new": "4.1.11",
|
||||
"@strapi/generate-new": "4.1.12",
|
||||
"commander": "6.1.0",
|
||||
"inquirer": "8.2.0"
|
||||
},
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "create-strapi-starter",
|
||||
"version": "4.1.11",
|
||||
"version": "4.1.12",
|
||||
"description": "Generate a new Strapi application.",
|
||||
"keywords": [
|
||||
"create-strapi-starter",
|
||||
@ -38,7 +38,7 @@
|
||||
"test": "echo \"no tests yet\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@strapi/generate-new": "4.1.11",
|
||||
"@strapi/generate-new": "4.1.12",
|
||||
"chalk": "4.1.1",
|
||||
"ci-info": "3.1.1",
|
||||
"commander": "7.1.0",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strapi/admin",
|
||||
"version": "4.1.11",
|
||||
"version": "4.1.12",
|
||||
"description": "Strapi Admin",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -50,12 +50,12 @@
|
||||
"@fortawesome/free-brands-svg-icons": "^5.15.3",
|
||||
"@fortawesome/free-solid-svg-icons": "^5.15.3",
|
||||
"@fortawesome/react-fontawesome": "^0.1.14",
|
||||
"@strapi/babel-plugin-switch-ee-ce": "4.1.11",
|
||||
"@strapi/babel-plugin-switch-ee-ce": "4.1.12",
|
||||
"@strapi/design-system": "1.1.0",
|
||||
"@strapi/helper-plugin": "4.1.11",
|
||||
"@strapi/helper-plugin": "4.1.12",
|
||||
"@strapi/icons": "1.1.0",
|
||||
"@strapi/typescript-utils": "4.1.11",
|
||||
"@strapi/utils": "4.1.11",
|
||||
"@strapi/typescript-utils": "4.1.12",
|
||||
"@strapi/utils": "4.1.12",
|
||||
"axios": "0.24.0",
|
||||
"babel-loader": "8.2.3",
|
||||
"babel-plugin-styled-components": "2.0.2",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strapi/plugin-content-manager",
|
||||
"version": "4.1.11",
|
||||
"version": "4.1.12",
|
||||
"description": "A powerful UI to easily manage your data.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -24,7 +24,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@sindresorhus/slugify": "1.1.0",
|
||||
"@strapi/utils": "4.1.11",
|
||||
"@strapi/utils": "4.1.12",
|
||||
"lodash": "4.17.21"
|
||||
},
|
||||
"engines": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strapi/plugin-content-type-builder",
|
||||
"version": "4.1.11",
|
||||
"version": "4.1.12",
|
||||
"description": "Strapi plugin to create content type",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -28,9 +28,9 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@sindresorhus/slugify": "1.1.0",
|
||||
"@strapi/generators": "4.1.11",
|
||||
"@strapi/helper-plugin": "4.1.11",
|
||||
"@strapi/utils": "4.1.11",
|
||||
"@strapi/generators": "4.1.12",
|
||||
"@strapi/helper-plugin": "4.1.12",
|
||||
"@strapi/utils": "4.1.12",
|
||||
"fs-extra": "10.0.0",
|
||||
"lodash": "4.17.21",
|
||||
"pluralize": "^8.0.0",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strapi/database",
|
||||
"version": "4.1.11",
|
||||
"version": "4.1.12",
|
||||
"description": "Strapi's database layer",
|
||||
"homepage": "https://strapi.io",
|
||||
"bugs": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strapi/plugin-email",
|
||||
"version": "4.1.11",
|
||||
"version": "4.1.12",
|
||||
"description": "Easily configure your Strapi application to send emails.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -26,12 +26,12 @@
|
||||
"test:front:watch:ce": "cross-env IS_EE=false jest --config ./jest.config.front.js --watchAll"
|
||||
},
|
||||
"dependencies": {
|
||||
"@strapi/provider-email-sendmail": "4.1.11",
|
||||
"@strapi/utils": "4.1.11",
|
||||
"@strapi/provider-email-sendmail": "4.1.12",
|
||||
"@strapi/utils": "4.1.12",
|
||||
"lodash": "4.17.21"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@strapi/helper-plugin": "4.1.11"
|
||||
"@strapi/helper-plugin": "4.1.12"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12.22.0 <=16.x.x",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strapi/helper-plugin",
|
||||
"version": "4.1.11",
|
||||
"version": "4.1.12",
|
||||
"description": "Helper for Strapi plugins development",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -75,8 +75,8 @@
|
||||
"@storybook/builder-webpack5": "6.4.10",
|
||||
"@storybook/manager-webpack5": "6.4.10",
|
||||
"@storybook/react": "^6.3.7",
|
||||
"@strapi/design-system": "1.1.0",
|
||||
"@strapi/icons": "1.1.0",
|
||||
"@strapi/design-system": "1.1.1",
|
||||
"@strapi/icons": "1.1.1",
|
||||
"babel-loader": "^8.2.2",
|
||||
"cross-env": "^7.0.3",
|
||||
"date-fns": "2.22.1",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strapi/strapi",
|
||||
"version": "4.1.11",
|
||||
"version": "4.1.12",
|
||||
"description": "An open source headless CMS solution to create and manage your own API. It provides a powerful dashboard and features to make your life easier. Databases supported: MySQL, MariaDB, PostgreSQL, SQLite",
|
||||
"keywords": [
|
||||
"strapi",
|
||||
@ -80,17 +80,17 @@
|
||||
"dependencies": {
|
||||
"@koa/cors": "3.1.0",
|
||||
"@koa/router": "10.1.1",
|
||||
"@strapi/admin": "4.1.11",
|
||||
"@strapi/database": "4.1.11",
|
||||
"@strapi/generate-new": "4.1.11",
|
||||
"@strapi/generators": "4.1.11",
|
||||
"@strapi/logger": "4.1.11",
|
||||
"@strapi/plugin-content-manager": "4.1.11",
|
||||
"@strapi/plugin-content-type-builder": "4.1.11",
|
||||
"@strapi/plugin-email": "4.1.11",
|
||||
"@strapi/plugin-upload": "4.1.11",
|
||||
"@strapi/utils": "4.1.11",
|
||||
"@strapi/typescript-utils": "4.1.11",
|
||||
"@strapi/typescript-utils": "4.1.12",
|
||||
"@strapi/admin": "4.1.12",
|
||||
"@strapi/database": "4.1.12",
|
||||
"@strapi/generate-new": "4.1.12",
|
||||
"@strapi/generators": "4.1.12",
|
||||
"@strapi/logger": "4.1.12",
|
||||
"@strapi/plugin-content-manager": "4.1.12",
|
||||
"@strapi/plugin-content-type-builder": "4.1.12",
|
||||
"@strapi/plugin-email": "4.1.12",
|
||||
"@strapi/plugin-upload": "4.1.12",
|
||||
"@strapi/utils": "4.1.12",
|
||||
"bcryptjs": "2.4.3",
|
||||
"boxen": "5.1.2",
|
||||
"chalk": "4.1.2",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strapi/plugin-upload",
|
||||
"version": "4.1.11",
|
||||
"version": "4.1.12",
|
||||
"description": "Makes it easy to upload images and files to your Strapi Application.",
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"author": {
|
||||
@ -23,9 +23,9 @@
|
||||
"test:front:watch:ce": "cross-env IS_EE=false jest --config ./jest.config.front.js --watchAll"
|
||||
},
|
||||
"dependencies": {
|
||||
"@strapi/helper-plugin": "4.1.11",
|
||||
"@strapi/provider-upload-local": "4.1.11",
|
||||
"@strapi/utils": "4.1.11",
|
||||
"@strapi/helper-plugin": "4.1.12",
|
||||
"@strapi/provider-upload-local": "4.1.12",
|
||||
"@strapi/utils": "4.1.12",
|
||||
"byte-size": "7.0.1",
|
||||
"cropperjs": "1.5.11",
|
||||
"fs-extra": "10.0.0",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strapi/utils",
|
||||
"version": "4.1.11",
|
||||
"version": "4.1.12",
|
||||
"description": "Shared utilities for the Strapi packages",
|
||||
"keywords": [
|
||||
"strapi",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strapi/generate-new",
|
||||
"version": "4.1.11",
|
||||
"version": "4.1.12",
|
||||
"description": "Generate a new Strapi application.",
|
||||
"keywords": [
|
||||
"generate",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strapi/generators",
|
||||
"version": "4.1.11",
|
||||
"version": "4.1.12",
|
||||
"description": "Interactive API generator.",
|
||||
"keywords": [
|
||||
"strapi",
|
||||
@ -29,9 +29,9 @@
|
||||
],
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
"@strapi/typescript-utils": "4.1.11",
|
||||
"@strapi/typescript-utils": "4.1.12",
|
||||
"@sindresorhus/slugify": "1.1.0",
|
||||
"@strapi/utils": "4.1.11",
|
||||
"@strapi/utils": "4.1.12",
|
||||
"chalk": "4.1.2",
|
||||
"fs-extra": "10.0.0",
|
||||
"node-plop": "0.26.3",
|
||||
|
@ -33,6 +33,7 @@ describe('Build Component Schema', () => {
|
||||
const [pluginResponseValue, apiResponseValue] = Object.values(schemas);
|
||||
|
||||
const expectedShape = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
data: {
|
||||
type: 'object',
|
||||
@ -82,6 +83,7 @@ describe('Build Component Schema', () => {
|
||||
const apiListResponseValue = schemas['RestaurantListResponse'];
|
||||
|
||||
const expectedShape = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
data: {
|
||||
type: 'array',
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strapi/plugin-documentation",
|
||||
"version": "4.1.11",
|
||||
"version": "4.1.12",
|
||||
"description": "Create an OpenAPI Document and visualize your API with SWAGGER UI.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -24,8 +24,8 @@
|
||||
"test": "echo \"no tests yet\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@strapi/helper-plugin": "4.1.11",
|
||||
"@strapi/utils": "4.1.11",
|
||||
"@strapi/helper-plugin": "4.1.12",
|
||||
"@strapi/utils": "4.1.12",
|
||||
"bcryptjs": "2.4.3",
|
||||
"cheerio": "^1.0.0-rc.5",
|
||||
"fs-extra": "10.0.0",
|
||||
|
@ -95,6 +95,7 @@ const getAllSchemasForContentType = ({ routeInfo, attributes, uniqueName }) => {
|
||||
schemas = {
|
||||
...schemas,
|
||||
[`${pascalCase(uniqueName)}ListResponse`]: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
data: {
|
||||
type: 'array',
|
||||
@ -128,6 +129,7 @@ const getAllSchemasForContentType = ({ routeInfo, attributes, uniqueName }) => {
|
||||
schemas = {
|
||||
...schemas,
|
||||
[`${pascalCase(uniqueName)}Response`]: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
data: {
|
||||
type: 'object',
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strapi/plugin-graphql",
|
||||
"version": "4.1.11",
|
||||
"version": "4.1.12",
|
||||
"description": "Adds GraphQL endpoint with default API methods.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -30,7 +30,7 @@
|
||||
"@apollo/federation": "^0.28.0",
|
||||
"@graphql-tools/schema": "8.1.2",
|
||||
"@graphql-tools/utils": "^8.0.2",
|
||||
"@strapi/utils": "4.1.11",
|
||||
"@strapi/utils": "4.1.12",
|
||||
"apollo-server-core": "3.1.2",
|
||||
"apollo-server-koa": "3.1.2",
|
||||
"glob": "^7.1.7",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strapi/plugin-i18n",
|
||||
"version": "4.1.11",
|
||||
"version": "4.1.12",
|
||||
"description": "This plugin enables to create, to read and to update content in different languages, both from the Admin Panel and from the API",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -24,7 +24,7 @@
|
||||
"test:unit": "jest --verbose"
|
||||
},
|
||||
"dependencies": {
|
||||
"@strapi/utils": "4.1.11",
|
||||
"@strapi/utils": "4.1.12",
|
||||
"lodash": "4.17.21"
|
||||
},
|
||||
"engines": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strapi/plugin-sentry",
|
||||
"version": "4.1.11",
|
||||
"version": "4.1.12",
|
||||
"description": "Send Strapi error events to Sentry",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strapi/plugin-users-permissions",
|
||||
"version": "4.1.11",
|
||||
"version": "4.1.12",
|
||||
"description": "Protect your API with a full-authentication process based on JWT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -27,8 +27,8 @@
|
||||
"test:front:watch:ce": "cross-env IS_EE=false jest --config ./jest.config.front.js --watchAll"
|
||||
},
|
||||
"dependencies": {
|
||||
"@strapi/helper-plugin": "4.1.11",
|
||||
"@strapi/utils": "4.1.11",
|
||||
"@strapi/helper-plugin": "4.1.12",
|
||||
"@strapi/utils": "4.1.12",
|
||||
"bcryptjs": "2.4.3",
|
||||
"grant-koa": "5.4.8",
|
||||
"jsonwebtoken": "^8.1.0",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strapi/provider-email-amazon-ses",
|
||||
"version": "4.1.11",
|
||||
"version": "4.1.12",
|
||||
"description": "Amazon SES provider for strapi email",
|
||||
"keywords": [
|
||||
"email",
|
||||
@ -36,7 +36,7 @@
|
||||
"test": "echo \"no tests yet\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@strapi/utils": "4.1.11",
|
||||
"@strapi/utils": "4.1.12",
|
||||
"node-ses": "^3.0.3"
|
||||
},
|
||||
"engines": {
|
||||
|
@ -26,13 +26,15 @@ npm install @strapi/provider-email-mailgun --save
|
||||
| Variable | Type | Description | Required | Default |
|
||||
| ----------------------- | ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | -------- | --------- |
|
||||
| provider | string | The name of the provider you use | yes | |
|
||||
| providerOptions | object | Will be directly given to the `require('mailgun-js')`. Please refer to [mailgun-js](https://www.npmjs.com/package/mailgun-js) doc. | yes | |
|
||||
| providerOptions | object | Will be directly given to the `require('mailgun.js')`. Please refer to [mailgun.js](https://www.npmjs.com/package/mailgun.js) doc. | yes | |
|
||||
| settings | object | Settings | no | {} |
|
||||
| settings.defaultFrom | string | Default sender mail address | no | undefined |
|
||||
| settings.defaultReplyTo | string \| array<string> | Default address or addresses the receiver is asked to reply to | no | undefined |
|
||||
|
||||
> :warning: The Shipper Email (or defaultfrom) may also need to be changed in the `Email Templates` tab on the admin panel for emails to send properly
|
||||
|
||||
Since [mailgun-js](https://www.npmjs.com/package/mailgun-js) has been deprecated, this package now uses `mailgun.js` instead. In an effort to avoid breaking changes methods were added to convert existing configuration objects to work with the new package.
|
||||
|
||||
### Example
|
||||
|
||||
**Path -** `config/plugins.js`
|
||||
@ -44,9 +46,9 @@ module.exports = ({ env }) => ({
|
||||
config: {
|
||||
provider: 'mailgun',
|
||||
providerOptions: {
|
||||
apiKey: env('MAILGUN_API_KEY'),
|
||||
domain: env('MAILGUN_DOMAIN'), //Required if you have an account with multiple domains
|
||||
host: env('MAILGUN_HOST', 'api.mailgun.net'), //Optional. If domain region is Europe use 'api.eu.mailgun.net'
|
||||
key: env('MAILGUN_API_KEY'), // Required
|
||||
domain: env('MAILGUN_DOMAIN'), // Required
|
||||
url: env('MAILGUN_URL', 'https://api.mailgun.net'), //Optional. If domain region is Europe use 'https://api.eu.mailgun.net'
|
||||
},
|
||||
settings: {
|
||||
defaultFrom: 'myemail@protonmail.com',
|
||||
|
@ -0,0 +1,90 @@
|
||||
'use strict';
|
||||
|
||||
const formData = require('form-data');
|
||||
const Mailgun = require('mailgun.js');
|
||||
|
||||
const provider = require('../index');
|
||||
|
||||
describe('@strapi/provider-email-mailgun', () => {
|
||||
describe('.convertProviderOptions()', () => {
|
||||
it('returns an empty object', () => {
|
||||
expect(provider.convertProviderOptions({})).toEqual({});
|
||||
});
|
||||
|
||||
it('returns the correct key', () => {
|
||||
expect(
|
||||
provider.convertProviderOptions({
|
||||
apiKey: 'foo',
|
||||
})
|
||||
).toEqual({
|
||||
key: 'foo',
|
||||
});
|
||||
});
|
||||
|
||||
it('passes through unknown options', () => {
|
||||
expect(
|
||||
provider.convertProviderOptions({
|
||||
username: 'foo',
|
||||
})
|
||||
).toEqual({
|
||||
username: 'foo',
|
||||
});
|
||||
});
|
||||
|
||||
it('correctly merges options objects with defaults', () => {
|
||||
const defaults = {
|
||||
username: 'api',
|
||||
};
|
||||
const providerOptions = {
|
||||
key: 'foo',
|
||||
username: 'bar',
|
||||
domain: 'baz.example.com',
|
||||
};
|
||||
expect({ ...defaults, ...provider.convertProviderOptions(providerOptions) }).toEqual(
|
||||
providerOptions
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Mailgun', () => {
|
||||
it('successfully creates a new Mailgun client', () => {
|
||||
const defaults = {
|
||||
username: 'api',
|
||||
};
|
||||
const providerOptions = {
|
||||
key: 'foo',
|
||||
username: 'bar',
|
||||
domain: 'baz.example.com',
|
||||
};
|
||||
const mailgun = new Mailgun(formData);
|
||||
const mg = mailgun.client({
|
||||
...defaults,
|
||||
...provider.convertProviderOptions(providerOptions),
|
||||
});
|
||||
expect(mg).toMatchObject({
|
||||
messages: {
|
||||
request: {
|
||||
headers: {},
|
||||
key: providerOptions.key,
|
||||
url: 'https://api.mailgun.net',
|
||||
username: providerOptions.username,
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('fails to create a new Mailgun client due to missing key', () => {
|
||||
const defaults = {
|
||||
username: 'api',
|
||||
};
|
||||
const providerOptions = {
|
||||
username: 'bar',
|
||||
domain: 'baz.example.com',
|
||||
};
|
||||
const mailgun = new Mailgun(formData);
|
||||
expect(() => {
|
||||
mailgun.client({ ...defaults, ...provider.convertProviderOptions(providerOptions) });
|
||||
}).toThrowError('Parameter "key" is required');
|
||||
});
|
||||
});
|
||||
});
|
@ -1,40 +1,53 @@
|
||||
'use strict';
|
||||
|
||||
const mailgunFactory = require('mailgun-js');
|
||||
const formData = require('form-data');
|
||||
const Mailgun = require('mailgun.js');
|
||||
const { removeUndefined } = require('@strapi/utils');
|
||||
|
||||
const optionsMap = {
|
||||
apiKey: { field: 'key', fn: value => value },
|
||||
host: { field: 'url', fn: value => `https://${value || 'api.mailgun.net'}` },
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
convertProviderOptions(providerOptions = {}) {
|
||||
const newOptions = {};
|
||||
if (typeof providerOptions === 'object') {
|
||||
Object.keys(providerOptions).forEach(key => {
|
||||
if (Object.keys(optionsMap).includes(key)) {
|
||||
newOptions[optionsMap[key].field] = optionsMap[key].fn(providerOptions[key]);
|
||||
} else {
|
||||
newOptions[key] = providerOptions[key];
|
||||
}
|
||||
});
|
||||
}
|
||||
return newOptions;
|
||||
},
|
||||
|
||||
init(providerOptions = {}, settings = {}) {
|
||||
const mailgun = mailgunFactory({
|
||||
mute: false,
|
||||
...providerOptions,
|
||||
});
|
||||
const defaults = {
|
||||
username: 'api',
|
||||
};
|
||||
const mailgun = new Mailgun(formData);
|
||||
const mg = mailgun.client({ ...defaults, ...this.convertProviderOptions(providerOptions) });
|
||||
|
||||
return {
|
||||
send(options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const { from, to, cc, bcc, replyTo, subject, text, html, ...rest } = options;
|
||||
const { from, to, cc, bcc, replyTo, subject, text, html, ...rest } = options;
|
||||
|
||||
let msg = {
|
||||
from: from || settings.defaultFrom,
|
||||
to,
|
||||
cc,
|
||||
bcc,
|
||||
'h:Reply-To': replyTo || settings.defaultReplyTo,
|
||||
subject,
|
||||
text,
|
||||
html,
|
||||
...rest,
|
||||
};
|
||||
let data = {
|
||||
from: from || settings.defaultFrom,
|
||||
to,
|
||||
cc,
|
||||
bcc,
|
||||
'h:Reply-To': replyTo || settings.defaultReplyTo,
|
||||
subject,
|
||||
text,
|
||||
html,
|
||||
...rest,
|
||||
};
|
||||
|
||||
mailgun.messages().send(removeUndefined(msg), function(err) {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
return mg.messages.create(providerOptions.domain, removeUndefined(data));
|
||||
},
|
||||
};
|
||||
},
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strapi/provider-email-mailgun",
|
||||
"version": "4.1.11",
|
||||
"version": "4.1.12",
|
||||
"description": "Mailgun provider for strapi email plugin",
|
||||
"keywords": [
|
||||
"email",
|
||||
@ -36,8 +36,9 @@
|
||||
"test": "echo \"no tests yet\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@strapi/utils": "4.1.11",
|
||||
"mailgun-js": "0.22.0"
|
||||
"@strapi/utils": "4.1.12",
|
||||
"form-data": "^4.0.0",
|
||||
"mailgun.js": "5.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12.22.0 <=16.x.x",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strapi/provider-email-nodemailer",
|
||||
"version": "4.1.11",
|
||||
"version": "4.1.12",
|
||||
"description": "Nodemailer provider for Strapi 3",
|
||||
"keywords": [
|
||||
"strapi",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strapi/provider-email-sendgrid",
|
||||
"version": "4.1.11",
|
||||
"version": "4.1.12",
|
||||
"description": "Sendgrid provider for strapi email",
|
||||
"keywords": [
|
||||
"email",
|
||||
@ -37,7 +37,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@sendgrid/mail": "7.4.7",
|
||||
"@strapi/utils": "4.1.11"
|
||||
"@strapi/utils": "4.1.12"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12.22.0 <=16.x.x",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strapi/provider-email-sendmail",
|
||||
"version": "4.1.11",
|
||||
"version": "4.1.12",
|
||||
"description": "Sendmail provider for strapi email",
|
||||
"keywords": [
|
||||
"email",
|
||||
@ -35,7 +35,7 @@
|
||||
"test": "echo \"no tests yet\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@strapi/utils": "4.1.11",
|
||||
"@strapi/utils": "4.1.12",
|
||||
"sendmail": "^1.6.1"
|
||||
},
|
||||
"engines": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strapi/provider-upload-aws-s3",
|
||||
"version": "4.1.11",
|
||||
"version": "4.1.12",
|
||||
"description": "AWS S3 provider for strapi upload",
|
||||
"keywords": [
|
||||
"upload",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strapi/provider-upload-cloudinary",
|
||||
"version": "4.1.11",
|
||||
"version": "4.1.12",
|
||||
"description": "Cloudinary provider for strapi upload",
|
||||
"keywords": [
|
||||
"upload",
|
||||
@ -36,7 +36,7 @@
|
||||
"test": "echo \"no tests yet\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@strapi/utils": "4.1.11",
|
||||
"@strapi/utils": "4.1.12",
|
||||
"cloudinary": "^1.25.1",
|
||||
"into-stream": "^5.1.0"
|
||||
},
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strapi/provider-upload-local",
|
||||
"version": "4.1.11",
|
||||
"version": "4.1.12",
|
||||
"description": "Local provider for strapi upload",
|
||||
"keywords": [
|
||||
"upload",
|
||||
@ -35,7 +35,7 @@
|
||||
"test": "echo \"no tests yet\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@strapi/utils": "4.1.11",
|
||||
"@strapi/utils": "4.1.12",
|
||||
"fs-extra": "10.0.0"
|
||||
},
|
||||
"engines": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strapi/provider-upload-rackspace",
|
||||
"version": "4.1.11",
|
||||
"version": "4.1.12",
|
||||
"description": "Rackspace provider for strapi upload",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strapi/babel-plugin-switch-ee-ce",
|
||||
"version": "4.1.11",
|
||||
"version": "4.1.12",
|
||||
"private": false,
|
||||
"description": "Babel plugin to switch from CE to EE at runtime",
|
||||
"repository": "git://github.com/strapi/strapi.git",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strapi/logger",
|
||||
"version": "4.1.11",
|
||||
"version": "4.1.12",
|
||||
"description": "Strapi's logger",
|
||||
"homepage": "https://strapi.io",
|
||||
"bugs": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strapi/typescript-utils",
|
||||
"version": "4.1.11",
|
||||
"version": "4.1.12",
|
||||
"description": "Typescript support for Strapi",
|
||||
"keywords": [
|
||||
"strapi",
|
||||
|
@ -63,16 +63,16 @@ const addMissingKeys = async lang => {
|
||||
translationFiles.forEach(addMissingKeyForSingleFile);
|
||||
};
|
||||
|
||||
if (process.argv.length < 3) {
|
||||
console.warn(
|
||||
chalk.yellow(
|
||||
'Please provide a language. For example:\nnode scripts/front/add-missing-keys-to-other-language.js vi'
|
||||
)
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
if (process.argv.length < 3) {
|
||||
console.warn(
|
||||
chalk.yellow(
|
||||
'Please provide a language. For example:\nnode scripts/front/add-missing-keys-to-other-language.js vi'
|
||||
)
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
addMissingKeys(process.argv[2]).catch(err => console.error(err));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user