Skip to content

Commit 3525e3c

Browse files
Merge pull request #44 from SoftwareBrothers/beta
Beta
2 parents 00ba8be + 367524e commit 3525e3c

File tree

10 files changed

+1262
-878
lines changed

10 files changed

+1262
-878
lines changed

.github/workflows/push.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ jobs:
9090
fields: repo,message,commit,author,action,eventName,ref,workflow # selectable (default: repo,message)
9191
env:
9292
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
93-
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
94-
if: always()
93+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
94+
if: failure()
9595

9696
publish:
9797
name: Publish
@@ -120,6 +120,7 @@ jobs:
120120
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
121121
JIRA_TOKEN: ${{ secrets.JIRA_TOKEN }}
122122
JIRA_EMAIL: ${{ secrets.JIRA_EMAIL }}
123+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
123124
run: yarn release
124125

125126

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
access=public

.releaserc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@
2222
"ticketPrefixes": [ "AB" ],
2323
"released": true,
2424
"setReleaseDate": true
25-
}]
25+
}],
26+
[
27+
"semantic-release-slack-bot",
28+
{
29+
"notifyOnSuccess": true,
30+
"notifyOnFail": true
31+
}
32+
]
2633
]
2734
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The plugin can be registered using standard `AdminBro.registerAdapter` method.
88

99
```javascript
1010
const AdminBro = require('admin-bro')
11-
const AdminBroSequelize = require('admin-bro-sequelizejs')
11+
const AdminBroSequelize = require('@admin-bro/sequelize')
1212

1313
AdminBro.registerAdapter(AdminBroSequelize)
1414
```

index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @module admin-bro-sequelizejs
2+
* @module @admin-bro/sequelize
33
*
44
* @description
55
* ### A Sequelize database adapter for AdminBro.
@@ -9,7 +9,7 @@
99
* To install the adapter run
1010
*
1111
* ```
12-
* yarn add admin-bro-sequelizejs
12+
* yarn add @admin-bro/sequelize
1313
* ```
1414
*
1515
* ### Usage
@@ -18,7 +18,7 @@
1818
*
1919
* ```javascript
2020
* const AdminBro = require('admin-bro')
21-
* const AdminBroSequelize = require('admin-bro-sequelizejs')
21+
* const AdminBroSequelize = require('@admin-bro/sequelize')
2222
*
2323
* AdminBro.registerAdapter(AdminBroSequelize)
2424
* ```
@@ -72,6 +72,7 @@
7272
/**
7373
* Implementation of {@link BaseDatabase} for Sequelize Adapter
7474
*
75+
* @memberof module:@admin-bro/sequelize
7576
* @type {typeof BaseDatabase}
7677
* @static
7778
*/
@@ -80,6 +81,7 @@ const Database = require('./src/database')
8081
/**
8182
* Implementation of {@link BaseResource} for Sequelize Adapter
8283
*
84+
* @memberof module:@admin-bro/sequelize
8385
* @type {typeof BaseResource}
8486
* @static
8587
*/

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "admin-bro-sequelizejs",
3-
"version": "0.5.1",
2+
"name": "@admin-bro/sequelize",
3+
"version": "1.0.0-beta.3",
44
"description": "Sequelize adapter for AdminBro",
55
"main": "index.js",
66
"scripts": {
@@ -17,7 +17,7 @@
1717
"author": "Wojciech Krysiak",
1818
"license": "MIT",
1919
"peerDependencies": {
20-
"admin-bro": ">=2.2.0",
20+
"admin-bro": ">=3.0.0",
2121
"sequelize": ">=4"
2222
},
2323
"husky": {
@@ -30,7 +30,7 @@
3030
"@commitlint/config-conventional": "^8.3.4",
3131
"@semantic-release/git": "^9.0.0",
3232
"@types/mocha": "^7.0.2",
33-
"admin-bro": "^2.2.0",
33+
"admin-bro": "^3.0.0",
3434
"chai": "^4.2.0",
3535
"eslint": "^5.10.0",
3636
"eslint-config-airbnb-base": "^13.1.0",
@@ -44,6 +44,7 @@
4444
"pg": "^7.7.1",
4545
"semantic-release": "^17.0.7",
4646
"semantic-release-jira-releases-sb": "^0.7.2",
47+
"semantic-release-slack-bot": "^1.6.2",
4748
"sequelize": "^4.42.0",
4849
"sequelize-cli": "^5.4.0",
4950
"sinon": "^7.1.1",

src/property.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
const { BaseProperty } = require('admin-bro')
22

3-
/**
4-
* @type {Array<[string, import('admin-bro').PropertyType]>}
5-
*
6-
* @var {[type]}
7-
*/
3+
/** @typedef {import('admin-bro').PropertyType} PropertyType */
4+
85
const TYPES_MAPPING = [
96
['STRING', 'string'],
107
['TEXT', 'string'],
@@ -68,7 +65,7 @@ class Property extends BaseProperty {
6865
}
6966

7067
/**
71-
* @returns {import('admin-bro').PropertyType}
68+
* @returns {PropertyType}
7269
*/
7370
type() {
7471
let sequelizeType = this.sequelizePath.type

src/resource.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const convertFilter = require('./utils/convert-filter')
88
const createValidationError = require('./utils/create-validation-error')
99

1010
const SEQUELIZE_VALIDATION_ERROR = 'SequelizeValidationError'
11+
const SEQUELIZE_UNIQUE_ERROR = 'SequelizeUniqueConstraintError'
1112

1213
class Resource extends BaseResource {
1314
static isAdapterFor(rawResource) {
@@ -134,6 +135,9 @@ class Resource extends BaseResource {
134135
if (error.name === SEQUELIZE_VALIDATION_ERROR) {
135136
throw createValidationError(error)
136137
}
138+
if (error.name === SEQUELIZE_UNIQUE_ERROR) {
139+
throw createValidationError(error)
140+
}
137141
throw error
138142
}
139143
}
@@ -153,6 +157,9 @@ class Resource extends BaseResource {
153157
if (error.name === SEQUELIZE_VALIDATION_ERROR) {
154158
throw createValidationError(error)
155159
}
160+
if (error.name === SEQUELIZE_UNIQUE_ERROR) {
161+
throw createValidationError(error)
162+
}
156163
throw error
157164
}
158165
}

src/utils/convert-filter.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ const convertFilter = (filter) => {
2121
[Op.and]: [
2222
...(memo[Op.and] || []),
2323
where(
24-
fn('LOWER', col(`${property.sequelizePath.Model.name}.${property.name()}`)),
25-
Op.like,
26-
fn('LOWER', `%${escape(value)}%`),
24+
fn('LOWER', col(`${property.sequelizePath.Model.name}.${property.name()}`)), {
25+
[Op.like]: fn('LOWER', `%${escape(value)}%`),
26+
},
2727
),
2828
],
2929
...memo,

0 commit comments

Comments
 (0)