Skip to content

Commit

Permalink
feat(db-proxy): remove deprecated api: ruler, rulerv1, tests, entry;
Browse files Browse the repository at this point in the history
  • Loading branch information
maslow committed Oct 19, 2021
1 parent 03e6ed4 commit 4be2479
Show file tree
Hide file tree
Showing 59 changed files with 69 additions and 2,367 deletions.
2 changes: 1 addition & 1 deletion packages/database-proxy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "./dist",
"scripts": {
"test-all": "mocha tests/**/*test.js",
"test-units": "mocha tests/units/*",
"test-units": "mocha tests/units/**",
"test": "npm run test-units",
"build": "tsc -p tsconfig.json",
"watch": "tsc -w",
Expand Down
12 changes: 8 additions & 4 deletions packages/database-proxy/src/dbi/request.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { ActionType } from "../types"

import { Proxy } from "../proxy"
import { RequestInterface } from 'database-ql'
import { AccessorInterface } from ".."
import { QueryParam, ResponseStruct } from "database-ql/dist/commonjs/interface"
import { ActionType } from "database-ql/dist/commonjs/constant"

export class Request implements RequestInterface {

Expand All @@ -11,14 +13,16 @@ export class Request implements RequestInterface {
this.accessor = accessor
}

async send(action: ActionType, data: any): Promise<any> {
async send(action: ActionType, data: QueryParam): Promise<ResponseStruct> {
const accessor = this.accessor
const params = Proxy.parse(action, data)
const params = Proxy.parse(action as any, data)
const ret = await accessor.execute(params)

return {
code: 0,
data: ret
data: ret,
error: undefined,
requestId: undefined
}
}
}
1 change: 0 additions & 1 deletion packages/database-proxy/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

export * from './proxy'
export * from './policy'
export * from './ruler'
export * from './accessor'
export * from './types'
export * from './processor'
Expand Down
10 changes: 9 additions & 1 deletion packages/database-proxy/src/policy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,12 @@ import { Policy } from './policy'

export * from './interface'

export { Policy }

export {
Policy,

/**
* Ruler 为别名,为了兼容老版本命名
*/
Policy as Ruler
}
12 changes: 10 additions & 2 deletions packages/database-proxy/src/policy/policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import * as BUILT_IN_VALIDATORS from '../validators'
import { AccessorInterface } from '../accessor'
import { DefaultLogger, LoggerInterface } from '../logger'
import { PermissionRule, PolicyInterface, ValidateError, ValidateResult } from './interface'
import { PermissionType as PermissionTypeV1 } from '../ruler/ruler_v1'

/**
* 访问规则结构:
Expand All @@ -20,6 +19,15 @@ import { PermissionType as PermissionTypeV1 } from '../ruler/ruler_v1'
* -> watch: PermissionRule[]
*/


export enum PermissionTypeV1 {
READ = '.read',
UPDATE = '.update',
ADD = '.add',
REMOVE = '.remove',
COUNT = '.count'
}

export enum PermissionType {
READ = 'read',
UPDATE = 'update',
Expand Down Expand Up @@ -99,7 +107,7 @@ export class Policy implements PolicyInterface {
}

/**
* 加载 rules in josn
* 加载 rules in json
* @param rules any
* @returns
*/
Expand Down
10 changes: 0 additions & 10 deletions packages/database-proxy/src/ruler/index.ts

This file was deleted.

Loading

0 comments on commit 4be2479

Please sign in to comment.