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

Commit

Permalink
chore: update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
climba03003 committed Dec 12, 2023
1 parent 36309ba commit a9c47ea
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 38 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,5 @@ dist
pnpm-lock.yaml
yarn.lock
!jest.config.js
!rollup.config.js
!rollup.config.js
.tap
11 changes: 2 additions & 9 deletions .taprc
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
ts: true
jsx: false
flow: false
check-coverage: true
coverage: true
branches: 70
functions: 70
lines: 70
statements: 70
show-full-coverage: true
allow-incomplete-coverage: true
14 changes: 7 additions & 7 deletions lib/controller/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class Controller<TSchema extends Document = Document> extends EventEmitte
this.postMatchKeywords = options?.postMatchKeywords ?? []
if (!this[kSkipIndex]) this[kCreateIndex]()

this.emit('initialized').finally(noop)
this.emit('initialized').catch(noop)
this.logger.debug({ func: 'constructor', meta: { options } }, 'created')
}

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

Expand Down Expand Up @@ -293,7 +293,7 @@ export class Controller<TSchema extends Document = Document> extends EventEmitte
return result as TSchema
}

appendBasicSchema (docs: TSchema): TSchema {
appendBasicSchema = (docs: TSchema): TSchema => {
return docs
}

Expand All @@ -305,7 +305,7 @@ export class Controller<TSchema extends Document = Document> extends EventEmitte
const arr: any[] = []
const builder = new AggregateBuilder()
if ((isString(search) || isObject(search)) && isExist(search) && (this.searchFields.length > 0)) {
if (this.autoRegExpSearch) { search = transformRegExpSearch(search as any) }
if (this.autoRegExpSearch) { search = transformRegExpSearch(search as string) }
const sub: any[] = []
const value = normalize(search)
for (const field of this.searchFields) {
Expand Down Expand Up @@ -337,7 +337,7 @@ export class Controller<TSchema extends Document = Document> extends EventEmitte
}
}
if (typeof filter === 'object') {
for (const key of Object.keys(filter)) {
for (const key of Object.keys(filter as Record<string, any>)) {
let shouldAdd = true
for (let j = 0; j < this.postMatchKeywords.length; j++) {
if (!shouldAdd) break
Expand All @@ -361,7 +361,7 @@ export class Controller<TSchema extends Document = Document> extends EventEmitte
const arr: any[] = []
const builder = new AggregateBuilder()
if ((isString(search) || isObject(search)) && isExist(search) && (this.searchFields.length > 0)) {
if (this.autoRegExpSearch) { search = transformRegExpSearch(search as any) }
if (this.autoRegExpSearch) { search = transformRegExpSearch(search as string) }
const sub: any[] = []
const value = normalize(search)
for (const field of this.searchFields) {
Expand Down Expand Up @@ -393,7 +393,7 @@ export class Controller<TSchema extends Document = Document> extends EventEmitte
}
}
if (typeof filter === 'object') {
for (const key of Object.keys(filter)) {
for (const key of Object.keys(filter as Record<string, any>)) {
let shouldAdd = false
for (let j = 0; j < this.postMatchKeywords.length; j++) {
if (shouldAdd) break
Expand Down
2 changes: 1 addition & 1 deletion lib/controller/multi-language.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class MultiLanguageController<TSchema extends Document = Document> extend
// ensure it is atomic operation
const doc: any = appendUpdateSchema(retrieveUpdateQueryData(docs), this.appendBasicSchema)
// update if language is exist
operations.push({ updateOne: { filter: { ...filter, language }, update: normalizeQueryDate(doc) } })
operations.push({ updateOne: { filter: { ...filter, language }, update: normalizeQueryDate(doc as UpdateFilter<TSchema>) } })
}

// perform all operations in once
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export function normalize (text: any): unknown {
// we normalize each pair of key-value
if (!isNumber(text) && !isString(text) && !isArray(text) && isJSON(text)) {
const o = JSON.parse(tmp)
for (const k of Object.keys(o)) {
for (const k of Object.keys(o as Record<string, unknown>)) {
// keep $expr $dateFromString work as before
// $regex must be string
if (k === 'dateString' || k === '$regex') {
Expand Down
30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,26 @@
"author": "KaKa",
"license": "GPL-3.0",
"devDependencies": {
"@types/node": "^20.4.2",
"@types/tap": "^15.0.8",
"@typescript-eslint/eslint-plugin": "5.62.0",
"@typescript-eslint/parser": "5.62.0",
"eslint": "^8.44.0",
"eslint-config-standard-with-typescript": "^37.0.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-n": "^16.0.1",
"@types/node": "^20.10.4",
"@types/tap": "^15.0.11",
"@typescript-eslint/eslint-plugin": "6.14.0",
"@typescript-eslint/parser": "6.14.0",
"eslint": "^8.55.0",
"eslint-config-standard-with-typescript": "^42.0.0",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-n": "^16.4.0",
"eslint-plugin-promise": "^6.1.1",
"mongodb": "^6.0.0",
"mongodb-memory-server": "^9.0.0",
"tap": "^16.3.7",
"ts-node": "^10.9.1",
"tsc-alias": "^1.8.7",
"typescript": "~5.1.0"
"mongodb": "^6.3.0",
"mongodb-memory-server": "^9.1.1",
"tap": "^18.6.1",
"ts-node": "^10.9.2",
"tsc-alias": "^1.8.8",
"typescript": "~5.3.3"
},
"dependencies": {
"@kakang/eventemitter": "^0.2.1",
"@kakang/mongodb-aggregate-builder": "^0.2.2",
"@kakang/validator": "^0.1.4",
"pino": "~8.16.0"
"pino": "~8.16.2"
}
}
2 changes: 1 addition & 1 deletion test/controller/deleteById.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ t.test('deleteById', async function (t) {
const ctr = new Controller(collection, { logger: { level: 'silent' } })
const inserted = await ctr.insertMany([{ foo: 'bar' }, { foo: 'bar' }, { foo: 'bar' }])

const result = await ctr.deleteById(inserted[0].id)
const result = await ctr.deleteById(inserted[0].id as string)
t.ok(result)
if (result !== null) {
t.equal('id' in result, true)
Expand Down
2 changes: 1 addition & 1 deletion test/controller/findById.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ t.test('findById', async function (t) {
const ctr = new Controller(collection, { logger: { level: 'silent' } })
const inserted = await ctr.insertMany([{ foo: 'bar' }, { foo: 'bar' }, { foo: 'bar' }])

let result = await ctr.findById(inserted[0].id)
let result = await ctr.findById(inserted[0].id as string)
t.ok(result)
if (result !== null) {
t.equal(result.id, inserted[0].id)
Expand Down
4 changes: 2 additions & 2 deletions test/controller/updateById.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ t.test('updateById', async function (t) {
const ctr = new Controller(collection, { logger: { level: 'silent' } })
const inserted = await ctr.insertMany([{ foo: 'bar' }, { foo: 'bar' }, { foo: 'bar' }])

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

result = await ctr.updateById(inserted[1].id, { $set: { foo: 'foo' } })
result = await ctr.updateById(inserted[1].id as string, { $set: { foo: 'foo' } })
t.ok(result)
if (result !== null) {
t.equal('id' in result, true)
Expand Down

0 comments on commit a9c47ea

Please sign in to comment.