diff --git a/acl/acl-mongodbBackend-tests.ts b/acl/acl-mongodbBackend-tests.ts index 080bfbf42..31411b65c 100644 --- a/acl/acl-mongodbBackend-tests.ts +++ b/acl/acl-mongodbBackend-tests.ts @@ -14,3 +14,4 @@ acl.allow('guest', 'blogs', 'view'); // allow function accepts arrays as any parameter acl.allow('member', 'blogs', ['edit','view', 'delete']); + diff --git a/acl/acl-mongodbBackend.d.ts b/acl/acl-mongodbBackend.d.ts index 48fe6f135..8dbfb7e90 100644 --- a/acl/acl-mongodbBackend.d.ts +++ b/acl/acl-mongodbBackend.d.ts @@ -13,7 +13,7 @@ declare module "acl" { mongodbBackend: MongodbBackendStatic; } - interface MongodbBackend extends Backend { } + interface MongodbBackend extends Backend { } interface MongodbBackendStatic { new(db: mongo.Db, prefix: string, useSingle: boolean): MongodbBackend; new(db: mongo.Db, prefix: string): MongodbBackend; diff --git a/acl/acl-redisBackend-test.ts b/acl/acl-redisBackend-test.ts index ce1036528..e1bf29af4 100644 --- a/acl/acl-redisBackend-test.ts +++ b/acl/acl-redisBackend-test.ts @@ -1,4 +1,4 @@ -/// +/// // https://github.com/OptimalBits/node_acl/blob/master/Readme.md import Acl = require('acl'); diff --git a/acl/acl.d.ts b/acl/acl.d.ts index f98bcb1ae..5d0498fed 100644 --- a/acl/acl.d.ts +++ b/acl/acl.d.ts @@ -10,14 +10,14 @@ declare module "acl" { import http = require('http'); import Promise = require("bluebird"); - type Func = ()=>any; + type strings = string|string[]; type Value = string|number; type Values = Value|Value[]; - type strings = string|string[]; - type ErrCallback = (err: Error) => any; + type Action = () => any; + type Callback = (err: Error) => any; type AnyCallback = (err: Error, obj: any) => any; type AllowedCallback = (err: Error, allowed: boolean) => any; - type GetUserId = (req: http.ServerRequest, res: http.ServerResponse) => any; + type GetUserId = (req: http.ServerRequest, res: http.ServerResponse) => Value; interface AclStatic { new (backend: Backend, logger: Logger, options: Option): Acl; @@ -31,19 +31,19 @@ declare module "acl" { } interface Acl { - addUserRoles: (userId: Value, roles: strings, cb?: ErrCallback) => Promise; - removeUserRoles: (userId: Value, roles: strings, cb?: ErrCallback) => Promise; + addUserRoles: (userId: Value, roles: strings, cb?: Callback) => Promise; + removeUserRoles: (userId: Value, roles: strings, cb?: Callback) => Promise; userRoles: (userId: Value, cb?: (err: Error, roles: string[])=>any) => Promise; roleUsers: (role: Value, cb?: (err: Error, users: Values)=>any) => Promise; hasRole: (userId: Value, role: string, cb?: (err: Error, isInRole: boolean)=>any) => Promise; - addRoleParents: (role: string, parents: Values, cb?: ErrCallback) => Promise; - removeRole: (role: string, cb?: ErrCallback) => Promise; - removeResource: (resource: string, cb?: ErrCallback) => Promise; + addRoleParents: (role: string, parents: Values, cb?: Callback) => Promise; + removeRole: (role: string, cb?: Callback) => Promise; + removeResource: (resource: string, cb?: Callback) => Promise; allow: { - (roles: Values, resources: strings, permissions: strings, cb?: ErrCallback): Promise; + (roles: Values, resources: strings, permissions: strings, cb?: Callback): Promise; (aclSets: AclSet|AclSet[]): Promise; } - removeAllow: (role: string, resources: strings, permissions: strings, cb?: ErrCallback) => Promise; + removeAllow: (role: string, resources: strings, permissions: strings, cb?: Callback) => Promise; removePermissions: (role: string, resources: strings, permissions: strings, cb?: Function) => Promise; allowedPermissions: (userId: Value, resources: strings, cb?: AnyCallback) => Promise; isAllowed: (userId: Value, resources: strings, permissions: strings, cb?: AllowedCallback) => Promise; @@ -76,15 +76,23 @@ declare module "acl" { permissions: strings; } + interface MemoryBackend extends Backend { } + interface MemoryBackendStatic { + new(): MemoryBackend; + } + + // + // For internal use + // interface Backend { begin: () => T; - end: (transaction: T, cb?: Func) => void; - clean: (cb?: Func) => void; - get: (bucket: string, key: Value, cb?: Func) => void; - union: (bucket: string, keys: Value[], cb?: Func) => void; - add: (transaction: T, bucket: string, key: Value, values: Value|Value[]) => void; + end: (transaction: T, cb?: Action) => void; + clean: (cb?: Action) => void; + get: (bucket: string, key: Value, cb?: Action) => void; + union: (bucket: string, keys: Value[], cb?: Action) => void; + add: (transaction: T, bucket: string, key: Value, values: Values) => void; del: (transaction: T, bucket: string, keys: Value[]) => void; - remove: (transaction: T, bucket: string, key: Value, values: Value|Value[]) => void; + remove: (transaction: T, bucket: string, key: Value, values: Values) => void; endAsync: Function; //TODO: Give more specific function signature getAsync: Function; @@ -92,11 +100,6 @@ declare module "acl" { unionAsync: Function; } - interface MemoryBackend extends Backend { } - interface MemoryBackendStatic { - new(): MemoryBackend; - } - interface Contract { (args: IArguments): Contract|NoOp; debug: boolean;