Skip to content

Commit ab23171

Browse files
authored
feat: switch dependency to our own package: @casbin/expression-eval 5.2.0 (#488)
* feat: update to @casbin/expression-eval 5.2.0 * fix: the lint error
1 parent 980ef14 commit ab23171

File tree

6 files changed

+4239
-3138
lines changed

6 files changed

+4239
-3138
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"await-lock": "^2.0.1",
5353
"buffer": "^6.0.3",
5454
"csv-parse": "^5.3.5",
55-
"expression-eval": "^5.0.0",
55+
"@casbin/expression-eval": "^5.2.0",
5656
"minimatch": "^7.4.2"
5757
},
5858
"files": [

src/coreEnforcer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
import { compile, compileAsync, addBinaryOp } from 'expression-eval';
15+
import { compile, compileAsync, addBinaryOp } from '@casbin/expression-eval';
1616

1717
import { DefaultEffector, Effect, Effector } from './effect';
1818
import { FunctionMap, Model, newModelFromFile, PolicyOp } from './model';

src/util/util.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,9 @@ function deepCopy(obj: Array<any> | any): any {
179179

180180
function customIn(a: number | string, b: number | string): number {
181181
if ((b as any) instanceof Array) {
182-
return (((b as any) as Array<any>).includes(a) as unknown) as number;
182+
return (b as any as Array<any>).includes(a) as unknown as number;
183183
}
184-
return ((a in (b as any)) as unknown) as number;
184+
return (a in (b as any)) as unknown as number;
185185
}
186186

187187
function bracketCompatible(exp: string): string {

test/enforcer.test.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -597,9 +597,9 @@ test('test ABAC multiple eval()', async () => {
597597
);
598598

599599
const e = await newEnforcer(m, policy);
600-
await testEnforce(e, 56, (98 as unknown) as string, 'read', true);
601-
await testEnforce(e, 23, (67 as unknown) as string, 'read', false);
602-
await testEnforce(e, 78, (34 as unknown) as string, 'read', false);
600+
await testEnforce(e, 56, 98 as unknown as string, 'read', true);
601+
await testEnforce(e, 23, 67 as unknown as string, 'read', false);
602+
await testEnforce(e, 78, 34 as unknown as string, 'read', false);
603603
});
604604

605605
// https://github.com/casbin/node-casbin/issues/438
@@ -617,10 +617,10 @@ test('test ABAC single eval() with r. in unexpected places', async () => {
617617
);
618618

619619
const e = await newEnforcer(m, policy);
620-
await testEnforce(e, { id: 3 }, ({ owner: { id: 3 } } as unknown) as string, 'read', true);
621-
await testEnforce(e, {}, ({ owner: {} } as unknown) as string, 'read', false);
622-
await testEnforce(e, { id: 3 }, ({ owner: {} } as unknown) as string, 'read', false);
623-
await testEnforce(e, { id: 3 }, ({ owner: { id: 2 } } as unknown) as string, 'read', false);
620+
await testEnforce(e, { id: 3 }, { owner: { id: 3 } } as unknown as string, 'read', true);
621+
await testEnforce(e, {}, { owner: {} } as unknown as string, 'read', false);
622+
await testEnforce(e, { id: 3 }, { owner: {} } as unknown as string, 'read', false);
623+
await testEnforce(e, { id: 3 }, { owner: { id: 2 } } as unknown as string, 'read', false);
624624
});
625625

626626
test('TestEnforceSync', async () => {

test/util.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
import { getLogger, logPrint, Util as util } from '../src';
16-
import { compile } from 'expression-eval';
16+
import { compile } from '@casbin/expression-eval';
1717

1818
test('test enableLog success', () => {
1919
getLogger().enableLog(true);

0 commit comments

Comments
 (0)