@proteinjs/user 1.0.20 → 1.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Columns, Record, Table } from '@proteinjs/db';
|
|
1
|
+
import { Columns, Record, Table, Db } from '@proteinjs/db';
|
|
2
2
|
export interface ScopedRecord extends Record {
|
|
3
3
|
scope: string;
|
|
4
4
|
}
|
|
5
|
-
export declare const getScopedDb: () =>
|
|
5
|
+
export declare const getScopedDb: () => Db<ScopedRecord>;
|
|
6
|
+
export declare const getScopedDbAsSystem: <R extends ScopedRecord = ScopedRecord>() => Db<R>;
|
|
6
7
|
export declare function getScopedTables(): Table<ScopedRecord>[];
|
|
7
8
|
export declare function isScopedTable(table: Table<any>): boolean;
|
|
8
9
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScopedRecord.d.ts","sourceRoot":"","sources":["../../src/ScopedRecord.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAEP,MAAM,EAGN,KAAK,
|
|
1
|
+
{"version":3,"file":"ScopedRecord.d.ts","sourceRoot":"","sources":["../../src/ScopedRecord.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAEP,MAAM,EAGN,KAAK,EAGL,EAAE,EACH,MAAM,eAAe,CAAC;AAGvB,MAAM,WAAW,YAAa,SAAQ,MAAM;IAC1C,KAAK,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,WAAW,wBAAsB,CAAC;AAE/C,eAAO,MAAM,mBAAmB,oDAAqF,CAAC;AAkBtH,wBAAgB,eAAe,0BAE9B;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,WAG9C;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,YAAY,EAC5D,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,YAAY,CAAC,CAAC,GAC5C,OAAO,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,YAAY,CAAC,CAAC,CAE9D"}
|
package/dist/src/ScopedRecord.js
CHANGED
|
@@ -36,22 +36,26 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.withScopedRecordColumns = exports.isScopedTable = exports.getScopedTables = exports.getScopedDb = void 0;
|
|
39
|
+
exports.withScopedRecordColumns = exports.isScopedTable = exports.getScopedTables = exports.getScopedDbAsSystem = exports.getScopedDb = void 0;
|
|
40
40
|
var db_1 = require("@proteinjs/db");
|
|
41
41
|
var UserRepo_1 = require("./UserRepo");
|
|
42
42
|
exports.getScopedDb = (db_1.getDb);
|
|
43
|
+
var getScopedDbAsSystem = function () { return new db_1.Db(undefined, undefined, true); };
|
|
44
|
+
exports.getScopedDbAsSystem = getScopedDbAsSystem;
|
|
43
45
|
var scopedRecordColumns = {
|
|
44
46
|
scope: new db_1.StringColumn('scope', {
|
|
45
47
|
defaultValue: function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
46
48
|
return [2 /*return*/, new UserRepo_1.UserRepo().getUser().id];
|
|
47
49
|
}); }); },
|
|
48
|
-
addToQuery: function (qb) { return __awaiter(void 0, void 0, void 0, function () {
|
|
50
|
+
addToQuery: function (qb, runAsSystem) { return __awaiter(void 0, void 0, void 0, function () {
|
|
49
51
|
return __generator(this, function (_a) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
if (!runAsSystem) {
|
|
53
|
+
qb.condition({
|
|
54
|
+
field: 'scope',
|
|
55
|
+
operator: 'IN',
|
|
56
|
+
value: [new UserRepo_1.UserRepo().getUser().id],
|
|
57
|
+
});
|
|
58
|
+
}
|
|
55
59
|
return [2 /*return*/];
|
|
56
60
|
});
|
|
57
61
|
}); },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScopedRecord.js","sourceRoot":"","sources":["../../src/ScopedRecord.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"ScopedRecord.js","sourceRoot":"","sources":["../../src/ScopedRecord.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oCAUuB;AACvB,uCAAsC;AAMzB,QAAA,WAAW,GAAG,CAAA,UAAmB,CAAA,CAAC;AAExC,IAAM,mBAAmB,GAAG,cAA6C,OAAA,IAAI,OAAE,CAAI,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,EAArC,CAAqC,CAAC;AAAzG,QAAA,mBAAmB,uBAAsF;AAEtH,IAAM,mBAAmB,GAAG;IAC1B,KAAK,EAAE,IAAI,iBAAY,CAAC,OAAO,EAAE;QAC/B,YAAY,EAAE;YAAY,sBAAA,IAAI,mBAAQ,EAAE,CAAC,OAAO,EAAE,CAAC,EAAE,EAAA;iBAAA;QACrD,UAAU,EAAE,UAAO,EAAE,EAAE,WAAW;;gBAChC,IAAI,CAAC,WAAW,EAAE;oBAChB,EAAE,CAAC,SAAS,CAAC;wBACX,KAAK,EAAE,OAAO;wBACd,QAAQ,EAAE,IAAI;wBACd,KAAK,EAAE,CAAC,IAAI,mBAAQ,EAAE,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;qBACrC,CAAC,CAAC;iBACJ;;;aACF;QACD,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;KACrB,CAAC;CACH,CAAC;AAEF,SAAgB,eAAe;IAC7B,OAAO,IAAA,cAAS,GAAgB,CAAC,MAAM,CAAC,UAAC,KAAK,IAAK,OAAA,aAAa,CAAC,KAAK,CAAC,EAApB,CAAoB,CAAC,CAAC;AAC3E,CAAC;AAFD,0CAEC;AAED,SAAgB,aAAa,CAAC,KAAiB;IAC7C,IAAM,WAAW,GAAG,IAAA,oBAAe,EAAC,KAAK,EAAE,mBAAmB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC3E,OAAO,CAAC,CAAC,WAAW,CAAC;AACvB,CAAC;AAHD,sCAGC;AAED;;;;;;;GAOG;AACH,SAAgB,uBAAuB,CACrC,OAA6C;IAE7C,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,mBAAmB,CAAC,EAAE,IAAA,sBAAiB,EAAS,OAAO,CAAQ,CAAC,CAAC;AAC1G,CAAC;AAJD,0DAIC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proteinjs/user",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.21",
|
|
4
4
|
"description": "User management",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"test": "jest"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@proteinjs/db": "1.0.
|
|
25
|
+
"@proteinjs/db": "1.0.25",
|
|
26
26
|
"@proteinjs/reflection": "1.1.5",
|
|
27
27
|
"@proteinjs/server-api": "1.3.0",
|
|
28
28
|
"@proteinjs/service": "1.0.18",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"moment": "2.29.4"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@proteinjs/db-driver-knex": "1.0.
|
|
33
|
+
"@proteinjs/db-driver-knex": "1.0.24",
|
|
34
34
|
"@proteinjs/reflection-build": "1.0.19",
|
|
35
35
|
"@types/jest": "29.5.5",
|
|
36
36
|
"@types/node": "14.0.13",
|
package/src/ScopedRecord.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
Table,
|
|
8
8
|
getColumnByName,
|
|
9
9
|
getTables,
|
|
10
|
+
Db,
|
|
10
11
|
} from '@proteinjs/db';
|
|
11
12
|
import { UserRepo } from './UserRepo';
|
|
12
13
|
|
|
@@ -16,15 +17,19 @@ export interface ScopedRecord extends Record {
|
|
|
16
17
|
|
|
17
18
|
export const getScopedDb = getDb<ScopedRecord>;
|
|
18
19
|
|
|
20
|
+
export const getScopedDbAsSystem = <R extends ScopedRecord = ScopedRecord>() => new Db<R>(undefined, undefined, true);
|
|
21
|
+
|
|
19
22
|
const scopedRecordColumns = {
|
|
20
23
|
scope: new StringColumn('scope', {
|
|
21
24
|
defaultValue: async () => new UserRepo().getUser().id,
|
|
22
|
-
addToQuery: async (qb) => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
addToQuery: async (qb, runAsSystem) => {
|
|
26
|
+
if (!runAsSystem) {
|
|
27
|
+
qb.condition({
|
|
28
|
+
field: 'scope',
|
|
29
|
+
operator: 'IN',
|
|
30
|
+
value: [new UserRepo().getUser().id],
|
|
31
|
+
});
|
|
32
|
+
}
|
|
28
33
|
},
|
|
29
34
|
ui: { hidden: true },
|
|
30
35
|
}),
|