Skip to content

Commit 6ddcad0

Browse files
committed
chore: 🔥 support btn and update patron
1 parent d5afc4b commit 6ddcad0

File tree

7 files changed

+3043
-1593
lines changed

7 files changed

+3043
-1593
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
patreon: chantouch

package-lock.json

Lines changed: 1839 additions & 536 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-api-queries",
3-
"version": "0.0.9",
3+
"version": "0.0.10-alpha.0",
44
"description": "Elegant and simple way to build requests for REST API",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",
@@ -49,27 +49,27 @@
4949
"devDependencies": {
5050
"@commitlint/cli": "^11.0.0",
5151
"@commitlint/config-conventional": "^11.0.0",
52-
"@nuxt/types": "latest",
52+
"@nuxt/types": "^2.14.7",
5353
"@nuxt/typescript-build": "latest",
5454
"@nuxt/typescript-runtime": "latest",
55-
"@nuxtjs/auth-next": "^5.0.0-1595976864.509d9d6",
55+
"@nuxtjs/auth-next": "^5.0.0-1602966760.822bc05",
5656
"@nuxtjs/axios": "^5.12.2",
5757
"@nuxtjs/eslint-config-typescript": "latest",
5858
"@types/escape-string-regexp": "^2.0.1",
5959
"@types/jest": "^26.0.14",
6060
"@types/lodash.merge": "^4.6.6",
61-
"@types/node": "^14.11.8",
62-
"@typescript-eslint/eslint-plugin": "^4.1.1",
63-
"@typescript-eslint/parser": "^4.1.1",
61+
"@types/node": "^14.11.10",
62+
"@typescript-eslint/eslint-plugin": "^4.4.1",
63+
"@typescript-eslint/parser": "^4.4.1",
6464
"axios-mock-adapter": "^1.18.2",
6565
"bootstrap-vue": "^2.17.3",
66-
"eslint": "^7.9.0",
67-
"eslint-config-prettier": "^6.11.0",
66+
"eslint": "^7.11.0",
67+
"eslint-config-prettier": "^6.13.0",
6868
"eslint-plugin-prettier": "^3.1.4",
6969
"husky": "^4.3.0",
70-
"jest": "^26.4.2",
70+
"jest": "^26.5.3",
7171
"nodemon": "^2.0.5",
72-
"nuxt-edge": "latest",
72+
"nuxt-edge": "^2.14.8-26717802.265d0e7a",
7373
"prettier": "^2.1.2",
7474
"rimraf": "^3.0.2",
7575
"semantic-release": "^17.2.1",

src/core/BaseProxy.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,20 @@ class BaseProxy {
8888
__getParameterString(url: string): string {
8989
const keys = Object.keys(this.parameters)
9090
const parameters = keys
91-
.filter((key) => !!this.parameters[key])
92-
.map((key) => `${key}=${this.parameters[key]}`)
91+
.filter((key: string) => !!this.parameters[key])
92+
.map((key: string) => `${key}=${this.parameters[key]}`)
9393
return parameters.length === 0 ? url : `${url}?${parameters.join('&')}`
9494
}
9595

9696
__validateRequestType(requestType: Method): void {
97-
const requestTypes = ['get', 'delete', 'head', 'post', 'put', 'patch']
97+
const requestTypes: Array<string> = [
98+
'get',
99+
'delete',
100+
'head',
101+
'post',
102+
'put',
103+
'patch',
104+
]
98105
if (!requestTypes.includes(requestType)) {
99106
throw new Error(
100107
`\`${requestType}\` is not a valid request type, ` +

src/core/Validator.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Validator {
2727
let hasError = this.errors.hasOwnProperty(field)
2828
if (!hasError) {
2929
const errors = Object.keys(this.errors).filter(
30-
(e) => e.startsWith(`${field}.`) || e.startsWith(`${field}[`),
30+
(e: string) => e.startsWith(`${field}.`) || e.startsWith(`${field}[`),
3131
)
3232
hasError = errors.length > 0
3333
}
@@ -60,14 +60,14 @@ class Validator {
6060
if (!fields.length) {
6161
return {}
6262
}
63-
fields.forEach((key) => (errors[key] = this.get(key)))
63+
fields.forEach((key: string) => (errors[key] = this.get(key)))
6464
return errors
6565
}
6666
if (!fields.length) {
6767
return Object.keys(this.errors).length > 0
6868
}
6969
const errors = {}
70-
fields.forEach((key) => (errors[key] = this.get(key)))
70+
fields.forEach((key: string) => (errors[key] = this.get(key)))
7171
return Object.keys(errors).length > 0
7272
}
7373

@@ -96,22 +96,22 @@ class Validator {
9696
attribute.map((field: string) => {
9797
Object.keys(errors)
9898
.filter(
99-
(e) =>
99+
(e: string) =>
100100
e === field ||
101101
e.startsWith(`${field}.`) ||
102102
e.startsWith(`${field}[`),
103103
)
104-
.forEach((e) => delete errors[e])
104+
.forEach((e: string) => delete errors[e])
105105
})
106106
} else {
107107
Object.keys(errors)
108108
.filter(
109-
(e) =>
109+
(e: string) =>
110110
e === attribute ||
111111
e.startsWith(`${attribute}.`) ||
112112
e.startsWith(`${attribute}[`),
113113
)
114-
.forEach((e) => delete errors[e])
114+
.forEach((e: string) => delete errors[e])
115115
}
116116
this.fill(errors)
117117
}
@@ -129,7 +129,7 @@ class Validator {
129129
}
130130

131131
export interface ErrorOptions {
132-
[key: string]: any
132+
[key: string]: any | any[]
133133
}
134134

135135
export type { Validator as ValidatorType }

src/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { ValidatorType } from './core/Validator'
22
import Validator from './core/Validator'
3+
import _Vue from 'vue'
34

45
// augment typings of Vue.js
56
import './vue'
@@ -8,11 +9,11 @@ export type Errors = ValidatorType
89
export type { ValidatorType }
910

1011
class VueApiQueries {
11-
install(Vue: any) {
12-
Vue.mixin({
13-
beforeCreate() {
12+
install(Vue: typeof _Vue) {
13+
Vue.extend({
14+
beforeCreate(this: any) {
1415
this.$options.$errors = {}
15-
Vue.util.defineReactive(this.$options, '$errors', Validator)
16+
Vue.set(this.$options, '$errors', Validator)
1617
if (!this.$options.computed) {
1718
this.$options.computed = {}
1819
}

0 commit comments

Comments
 (0)