Skip to content
This repository was archived by the owner on Jul 18, 2024. It is now read-only.

Commit a9c47ea

Browse files
committed
chore: update deps
1 parent 36309ba commit a9c47ea

File tree

9 files changed

+32
-38
lines changed

9 files changed

+32
-38
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,5 @@ dist
125125
pnpm-lock.yaml
126126
yarn.lock
127127
!jest.config.js
128-
!rollup.config.js
128+
!rollup.config.js
129+
.tap

.taprc

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,2 @@
1-
ts: true
2-
jsx: false
3-
flow: false
4-
check-coverage: true
5-
coverage: true
6-
branches: 70
7-
functions: 70
8-
lines: 70
9-
statements: 70
1+
show-full-coverage: true
2+
allow-incomplete-coverage: true

lib/controller/default.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export class Controller<TSchema extends Document = Document> extends EventEmitte
7979
this.postMatchKeywords = options?.postMatchKeywords ?? []
8080
if (!this[kSkipIndex]) this[kCreateIndex]()
8181

82-
this.emit('initialized').finally(noop)
82+
this.emit('initialized').catch(noop)
8383
this.logger.debug({ func: 'constructor', meta: { options } }, 'created')
8484
}
8585

@@ -93,7 +93,7 @@ export class Controller<TSchema extends Document = Document> extends EventEmitte
9393
this.collection.createIndex(index.indexSpec, index.options ?? {}).catch(noop)
9494
this.logger.trace({ func: 'Symbol("createIndex")', meta: { index } }, 'index %j is created', index.indexSpec)
9595
}
96-
this.createIndex().finally(noop)
96+
this.createIndex().catch(noop)
9797
this.logger.debug({ func: 'Symbol("createIndex")', meta: { indexes: this[kIndexes] } }, 'ended')
9898
}
9999

@@ -293,7 +293,7 @@ export class Controller<TSchema extends Document = Document> extends EventEmitte
293293
return result as TSchema
294294
}
295295

296-
appendBasicSchema (docs: TSchema): TSchema {
296+
appendBasicSchema = (docs: TSchema): TSchema => {
297297
return docs
298298
}
299299

@@ -305,7 +305,7 @@ export class Controller<TSchema extends Document = Document> extends EventEmitte
305305
const arr: any[] = []
306306
const builder = new AggregateBuilder()
307307
if ((isString(search) || isObject(search)) && isExist(search) && (this.searchFields.length > 0)) {
308-
if (this.autoRegExpSearch) { search = transformRegExpSearch(search as any) }
308+
if (this.autoRegExpSearch) { search = transformRegExpSearch(search as string) }
309309
const sub: any[] = []
310310
const value = normalize(search)
311311
for (const field of this.searchFields) {
@@ -337,7 +337,7 @@ export class Controller<TSchema extends Document = Document> extends EventEmitte
337337
}
338338
}
339339
if (typeof filter === 'object') {
340-
for (const key of Object.keys(filter)) {
340+
for (const key of Object.keys(filter as Record<string, any>)) {
341341
let shouldAdd = true
342342
for (let j = 0; j < this.postMatchKeywords.length; j++) {
343343
if (!shouldAdd) break
@@ -361,7 +361,7 @@ export class Controller<TSchema extends Document = Document> extends EventEmitte
361361
const arr: any[] = []
362362
const builder = new AggregateBuilder()
363363
if ((isString(search) || isObject(search)) && isExist(search) && (this.searchFields.length > 0)) {
364-
if (this.autoRegExpSearch) { search = transformRegExpSearch(search as any) }
364+
if (this.autoRegExpSearch) { search = transformRegExpSearch(search as string) }
365365
const sub: any[] = []
366366
const value = normalize(search)
367367
for (const field of this.searchFields) {
@@ -393,7 +393,7 @@ export class Controller<TSchema extends Document = Document> extends EventEmitte
393393
}
394394
}
395395
if (typeof filter === 'object') {
396-
for (const key of Object.keys(filter)) {
396+
for (const key of Object.keys(filter as Record<string, any>)) {
397397
let shouldAdd = false
398398
for (let j = 0; j < this.postMatchKeywords.length; j++) {
399399
if (shouldAdd) break

lib/controller/multi-language.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export class MultiLanguageController<TSchema extends Document = Document> extend
7474
// ensure it is atomic operation
7575
const doc: any = appendUpdateSchema(retrieveUpdateQueryData(docs), this.appendBasicSchema)
7676
// update if language is exist
77-
operations.push({ updateOne: { filter: { ...filter, language }, update: normalizeQueryDate(doc) } })
77+
operations.push({ updateOne: { filter: { ...filter, language }, update: normalizeQueryDate(doc as UpdateFilter<TSchema>) } })
7878
}
7979

8080
// perform all operations in once

lib/utils/query.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export function normalize (text: any): unknown {
6464
// we normalize each pair of key-value
6565
if (!isNumber(text) && !isString(text) && !isArray(text) && isJSON(text)) {
6666
const o = JSON.parse(tmp)
67-
for (const k of Object.keys(o)) {
67+
for (const k of Object.keys(o as Record<string, unknown>)) {
6868
// keep $expr $dateFromString work as before
6969
// $regex must be string
7070
if (k === 'dateString' || k === '$regex') {

package.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,26 +38,26 @@
3838
"author": "KaKa",
3939
"license": "GPL-3.0",
4040
"devDependencies": {
41-
"@types/node": "^20.4.2",
42-
"@types/tap": "^15.0.8",
43-
"@typescript-eslint/eslint-plugin": "5.62.0",
44-
"@typescript-eslint/parser": "5.62.0",
45-
"eslint": "^8.44.0",
46-
"eslint-config-standard-with-typescript": "^37.0.0",
47-
"eslint-plugin-import": "^2.27.5",
48-
"eslint-plugin-n": "^16.0.1",
41+
"@types/node": "^20.10.4",
42+
"@types/tap": "^15.0.11",
43+
"@typescript-eslint/eslint-plugin": "6.14.0",
44+
"@typescript-eslint/parser": "6.14.0",
45+
"eslint": "^8.55.0",
46+
"eslint-config-standard-with-typescript": "^42.0.0",
47+
"eslint-plugin-import": "^2.29.0",
48+
"eslint-plugin-n": "^16.4.0",
4949
"eslint-plugin-promise": "^6.1.1",
50-
"mongodb": "^6.0.0",
51-
"mongodb-memory-server": "^9.0.0",
52-
"tap": "^16.3.7",
53-
"ts-node": "^10.9.1",
54-
"tsc-alias": "^1.8.7",
55-
"typescript": "~5.1.0"
50+
"mongodb": "^6.3.0",
51+
"mongodb-memory-server": "^9.1.1",
52+
"tap": "^18.6.1",
53+
"ts-node": "^10.9.2",
54+
"tsc-alias": "^1.8.8",
55+
"typescript": "~5.3.3"
5656
},
5757
"dependencies": {
5858
"@kakang/eventemitter": "^0.2.1",
5959
"@kakang/mongodb-aggregate-builder": "^0.2.2",
6060
"@kakang/validator": "^0.1.4",
61-
"pino": "~8.16.0"
61+
"pino": "~8.16.2"
6262
}
6363
}

test/controller/deleteById.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ t.test('deleteById', async function (t) {
1010
const ctr = new Controller(collection, { logger: { level: 'silent' } })
1111
const inserted = await ctr.insertMany([{ foo: 'bar' }, { foo: 'bar' }, { foo: 'bar' }])
1212

13-
const result = await ctr.deleteById(inserted[0].id)
13+
const result = await ctr.deleteById(inserted[0].id as string)
1414
t.ok(result)
1515
if (result !== null) {
1616
t.equal('id' in result, true)

test/controller/findById.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ t.test('findById', async function (t) {
1010
const ctr = new Controller(collection, { logger: { level: 'silent' } })
1111
const inserted = await ctr.insertMany([{ foo: 'bar' }, { foo: 'bar' }, { foo: 'bar' }])
1212

13-
let result = await ctr.findById(inserted[0].id)
13+
let result = await ctr.findById(inserted[0].id as string)
1414
t.ok(result)
1515
if (result !== null) {
1616
t.equal(result.id, inserted[0].id)

test/controller/updateById.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ t.test('updateById', async function (t) {
1010
const ctr = new Controller(collection, { logger: { level: 'silent' } })
1111
const inserted = await ctr.insertMany([{ foo: 'bar' }, { foo: 'bar' }, { foo: 'bar' }])
1212

13-
let result = await ctr.updateById(inserted[0].id, { foo: 'baz' })
13+
let result = await ctr.updateById(inserted[0].id as string, { foo: 'baz' })
1414
t.ok(result)
1515
if (result !== null) {
1616
t.equal('id' in result, true)
@@ -21,7 +21,7 @@ t.test('updateById', async function (t) {
2121
t.equal('updatedAt' in result, true)
2222
}
2323

24-
result = await ctr.updateById(inserted[1].id, { $set: { foo: 'foo' } })
24+
result = await ctr.updateById(inserted[1].id as string, { $set: { foo: 'foo' } })
2525
t.ok(result)
2626
if (result !== null) {
2727
t.equal('id' in result, true)

0 commit comments

Comments
 (0)