@entity-access/entity-access 1.0.377 → 1.0.379
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.
- package/dist/compiler/postgres/PostgreSqlMethodTransformer.d.ts.map +1 -1
- package/dist/compiler/postgres/PostgreSqlMethodTransformer.js +27 -1
- package/dist/compiler/postgres/PostgreSqlMethodTransformer.js.map +1 -1
- package/dist/compiler/sql-server/SqlServerSqlMethodTransformer.d.ts.map +1 -1
- package/dist/compiler/sql-server/SqlServerSqlMethodTransformer.js +26 -0
- package/dist/compiler/sql-server/SqlServerSqlMethodTransformer.js.map +1 -1
- package/dist/drivers/postgres/PostgreSqlDriver.d.ts.map +1 -1
- package/dist/drivers/postgres/PostgreSqlDriver.js +1 -0
- package/dist/drivers/postgres/PostgreSqlDriver.js.map +1 -1
- package/dist/model/EntityQuery.d.ts.map +1 -1
- package/dist/model/EntityQuery.js +10 -0
- package/dist/model/EntityQuery.js.map +1 -1
- package/dist/model/IFilterWithParameter.d.ts +5 -5
- package/dist/model/IFilterWithParameter.d.ts.map +1 -1
- package/dist/sql/ISql.d.ts +10 -0
- package/dist/sql/ISql.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/compiler/postgres/PostgreSqlMethodTransformer.ts +27 -1
- package/src/compiler/sql-server/SqlServerSqlMethodTransformer.ts +26 -0
- package/src/drivers/postgres/PostgreSqlDriver.ts +1 -0
- package/src/model/EntityQuery.ts +11 -1
- package/src/model/IFilterWithParameter.ts +5 -5
- package/src/sql/ISql.ts +11 -0
- package/dist/tests/TestConfig.d.ts +0 -6
- package/dist/tests/TestConfig.d.ts.map +0 -1
- package/dist/tests/TestConfig.js +0 -3
- package/dist/tests/TestConfig.js.map +0 -1
- package/dist/tests/db-tests/tests/check-constraint-test.d.ts +0 -3
- package/dist/tests/db-tests/tests/check-constraint-test.d.ts.map +0 -1
- package/dist/tests/db-tests/tests/check-constraint-test.js +0 -25
- package/dist/tests/db-tests/tests/check-constraint-test.js.map +0 -1
- package/dist/tests/db-tests/tests/delete-items.d.ts +0 -3
- package/dist/tests/db-tests/tests/delete-items.d.ts.map +0 -1
- package/dist/tests/db-tests/tests/delete-items.js +0 -25
- package/dist/tests/db-tests/tests/delete-items.js.map +0 -1
- package/dist/tests/db-tests/tests/filtered-include-items.d.ts +0 -3
- package/dist/tests/db-tests/tests/filtered-include-items.d.ts.map +0 -1
- package/dist/tests/db-tests/tests/filtered-include-items.js +0 -19
- package/dist/tests/db-tests/tests/filtered-include-items.js.map +0 -1
- package/dist/tests/db-tests/tests/insert-into.d.ts +0 -3
- package/dist/tests/db-tests/tests/insert-into.d.ts.map +0 -1
- package/dist/tests/db-tests/tests/insert-into.js +0 -17
- package/dist/tests/db-tests/tests/insert-into.js.map +0 -1
- package/dist/tests/db-tests/tests/multi-fk-tests.d.ts +0 -3
- package/dist/tests/db-tests/tests/multi-fk-tests.d.ts.map +0 -1
- package/dist/tests/db-tests/tests/multi-fk-tests.js +0 -29
- package/dist/tests/db-tests/tests/multi-fk-tests.js.map +0 -1
- package/dist/tests/db-tests/tests/select-identity.d.ts +0 -3
- package/dist/tests/db-tests/tests/select-identity.d.ts.map +0 -1
- package/dist/tests/db-tests/tests/select-identity.js +0 -16
- package/dist/tests/db-tests/tests/select-identity.js.map +0 -1
- package/dist/tests/db-tests/tests/select-inverse-one-to-one.d.ts +0 -3
- package/dist/tests/db-tests/tests/select-inverse-one-to-one.d.ts.map +0 -1
- package/dist/tests/db-tests/tests/select-inverse-one-to-one.js +0 -27
- package/dist/tests/db-tests/tests/select-inverse-one-to-one.js.map +0 -1
- package/dist/tests/db-tests/tests/select-items-map.d.ts +0 -3
- package/dist/tests/db-tests/tests/select-items-map.d.ts.map +0 -1
- package/dist/tests/db-tests/tests/select-items-map.js +0 -28
- package/dist/tests/db-tests/tests/select-items-map.js.map +0 -1
- package/dist/tests/db-tests/tests/select-items-sum.d.ts +0 -3
- package/dist/tests/db-tests/tests/select-items-sum.d.ts.map +0 -1
- package/dist/tests/db-tests/tests/select-items-sum.js +0 -46
- package/dist/tests/db-tests/tests/select-items-sum.js.map +0 -1
- package/dist/tests/db-tests/tests/select-items.d.ts +0 -3
- package/dist/tests/db-tests/tests/select-items.d.ts.map +0 -1
- package/dist/tests/db-tests/tests/select-items.js +0 -30
- package/dist/tests/db-tests/tests/select-items.js.map +0 -1
- package/dist/tests/db-tests/tests/select-map.d.ts +0 -3
- package/dist/tests/db-tests/tests/select-map.d.ts.map +0 -1
- package/dist/tests/db-tests/tests/select-map.js +0 -12
- package/dist/tests/db-tests/tests/select-map.js.map +0 -1
- package/dist/tests/db-tests/tests/select-nested.d.ts +0 -3
- package/dist/tests/db-tests/tests/select-nested.d.ts.map +0 -1
- package/dist/tests/db-tests/tests/select-nested.js +0 -25
- package/dist/tests/db-tests/tests/select-nested.js.map +0 -1
- package/dist/tests/db-tests/tests/select-parent.d.ts +0 -3
- package/dist/tests/db-tests/tests/select-parent.d.ts.map +0 -1
- package/dist/tests/db-tests/tests/select-parent.js +0 -17
- package/dist/tests/db-tests/tests/select-parent.js.map +0 -1
- package/dist/tests/db-tests/tests/select-related.d.ts +0 -3
- package/dist/tests/db-tests/tests/select-related.d.ts.map +0 -1
- package/dist/tests/db-tests/tests/select-related.js +0 -20
- package/dist/tests/db-tests/tests/select-related.js.map +0 -1
- package/dist/tests/db-tests/tests/update-items.d.ts +0 -3
- package/dist/tests/db-tests/tests/update-items.d.ts.map +0 -1
- package/dist/tests/db-tests/tests/update-items.js +0 -31
- package/dist/tests/db-tests/tests/update-items.js.map +0 -1
- package/dist/tests/db-tests/tests/update-select.d.ts +0 -3
- package/dist/tests/db-tests/tests/update-select.d.ts.map +0 -1
- package/dist/tests/db-tests/tests/update-select.js +0 -19
- package/dist/tests/db-tests/tests/update-select.js.map +0 -1
- package/dist/tests/db-tests/tests/upsert-test.d.ts +0 -3
- package/dist/tests/db-tests/tests/upsert-test.d.ts.map +0 -1
- package/dist/tests/db-tests/tests/upsert-test.js +0 -31
- package/dist/tests/db-tests/tests/upsert-test.js.map +0 -1
- package/dist/tests/db-tests/tests/version-history.d.ts +0 -3
- package/dist/tests/db-tests/tests/version-history.d.ts.map +0 -1
- package/dist/tests/db-tests/tests/version-history.js +0 -16
- package/dist/tests/db-tests/tests/version-history.js.map +0 -1
- package/dist/tests/db-tests/transaction-save-point/transaction-save-point.d.ts +0 -3
- package/dist/tests/db-tests/transaction-save-point/transaction-save-point.d.ts.map +0 -1
- package/dist/tests/db-tests/transaction-save-point/transaction-save-point.js +0 -58
- package/dist/tests/db-tests/transaction-save-point/transaction-save-point.js.map +0 -1
- package/dist/tests/drivers/postgres/connection-test.d.ts +0 -3
- package/dist/tests/drivers/postgres/connection-test.d.ts.map +0 -1
- package/dist/tests/drivers/postgres/connection-test.js +0 -40
- package/dist/tests/drivers/postgres/connection-test.js.map +0 -1
- package/dist/tests/drivers/sql-server/sql-server-test.d.ts +0 -2
- package/dist/tests/drivers/sql-server/sql-server-test.d.ts.map +0 -1
- package/dist/tests/drivers/sql-server/sql-server-test.js +0 -6
- package/dist/tests/drivers/sql-server/sql-server-test.js.map +0 -1
- package/dist/tests/eternity/child-tests.d.ts +0 -3
- package/dist/tests/eternity/child-tests.d.ts.map +0 -1
- package/dist/tests/eternity/child-tests.js +0 -97
- package/dist/tests/eternity/child-tests.js.map +0 -1
- package/dist/tests/eternity/eternity-tests.d.ts +0 -3
- package/dist/tests/eternity/eternity-tests.d.ts.map +0 -1
- package/dist/tests/eternity/eternity-tests.js +0 -85
- package/dist/tests/eternity/eternity-tests.js.map +0 -1
- package/dist/tests/eternity/external-event-tests.d.ts +0 -3
- package/dist/tests/eternity/external-event-tests.d.ts.map +0 -1
- package/dist/tests/eternity/external-event-tests.js +0 -108
- package/dist/tests/eternity/external-event-tests.js.map +0 -1
- package/dist/tests/eternity/throttle-tests.d.ts +0 -3
- package/dist/tests/eternity/throttle-tests.d.ts.map +0 -1
- package/dist/tests/eternity/throttle-tests.js +0 -86
- package/dist/tests/eternity/throttle-tests.js.map +0 -1
- package/dist/tests/expressions/left-joins/child-joins.d.ts +0 -2
- package/dist/tests/expressions/left-joins/child-joins.d.ts.map +0 -1
- package/dist/tests/expressions/left-joins/child-joins.js +0 -114
- package/dist/tests/expressions/left-joins/child-joins.js.map +0 -1
- package/dist/tests/expressions/sanitize/sanitize-test.d.ts +0 -2
- package/dist/tests/expressions/sanitize/sanitize-test.d.ts.map +0 -1
- package/dist/tests/expressions/sanitize/sanitize-test.js +0 -8
- package/dist/tests/expressions/sanitize/sanitize-test.js.map +0 -1
- package/dist/tests/expressions/select/select.d.ts +0 -2
- package/dist/tests/expressions/select/select.d.ts.map +0 -1
- package/dist/tests/expressions/select/select.js +0 -11
- package/dist/tests/expressions/select/select.js.map +0 -1
- package/dist/tests/expressions/self-joins/self-joins.d.ts +0 -2
- package/dist/tests/expressions/self-joins/self-joins.d.ts.map +0 -1
- package/dist/tests/expressions/self-joins/self-joins.js +0 -14
- package/dist/tests/expressions/self-joins/self-joins.js.map +0 -1
- package/dist/tests/expressions/simple/parse-array.d.ts +0 -2
- package/dist/tests/expressions/simple/parse-array.d.ts.map +0 -1
- package/dist/tests/expressions/simple/parse-array.js +0 -21
- package/dist/tests/expressions/simple/parse-array.js.map +0 -1
- package/dist/tests/expressions/simple/parse-arrow.d.ts +0 -2
- package/dist/tests/expressions/simple/parse-arrow.d.ts.map +0 -1
- package/dist/tests/expressions/simple/parse-arrow.js +0 -36
- package/dist/tests/expressions/simple/parse-arrow.js.map +0 -1
- package/dist/tests/expressions/simple/parse-complex.d.ts +0 -2
- package/dist/tests/expressions/simple/parse-complex.d.ts.map +0 -1
- package/dist/tests/expressions/simple/parse-complex.js +0 -11
- package/dist/tests/expressions/simple/parse-complex.js.map +0 -1
- package/dist/tests/expressions/trimInternal.d.ts +0 -3
- package/dist/tests/expressions/trimInternal.d.ts.map +0 -1
- package/dist/tests/expressions/trimInternal.js +0 -24
- package/dist/tests/expressions/trimInternal.js.map +0 -1
- package/dist/tests/model/ShoppingContext.d.ts +0 -140
- package/dist/tests/model/ShoppingContext.d.ts.map +0 -1
- package/dist/tests/model/ShoppingContext.js +0 -440
- package/dist/tests/model/ShoppingContext.js.map +0 -1
- package/dist/tests/model/UseFile.d.ts +0 -8
- package/dist/tests/model/UseFile.d.ts.map +0 -1
- package/dist/tests/model/UseFile.js +0 -25
- package/dist/tests/model/UseFile.js.map +0 -1
- package/dist/tests/model/createContext.d.ts +0 -6
- package/dist/tests/model/createContext.d.ts.map +0 -1
- package/dist/tests/model/createContext.js +0 -327
- package/dist/tests/model/createContext.js.map +0 -1
- package/dist/tests/pool/pool-test.d.ts +0 -2
- package/dist/tests/pool/pool-test.d.ts.map +0 -1
- package/dist/tests/pool/pool-test.js +0 -66
- package/dist/tests/pool/pool-test.js.map +0 -1
- package/dist/tests/query/combine.d.ts +0 -2
- package/dist/tests/query/combine.d.ts.map +0 -1
- package/dist/tests/query/combine.js +0 -20
- package/dist/tests/query/combine.js.map +0 -1
- package/dist/tests/security/ShoppingContextEvents.d.ts +0 -5
- package/dist/tests/security/ShoppingContextEvents.d.ts.map +0 -1
- package/dist/tests/security/ShoppingContextEvents.js +0 -20
- package/dist/tests/security/ShoppingContextEvents.js.map +0 -1
- package/dist/tests/security/events/OrderEvents.d.ts +0 -17
- package/dist/tests/security/events/OrderEvents.d.ts.map +0 -1
- package/dist/tests/security/events/OrderEvents.js +0 -62
- package/dist/tests/security/events/OrderEvents.js.map +0 -1
- package/dist/tests/security/events/ProductEvents.d.ts +0 -23
- package/dist/tests/security/events/ProductEvents.d.ts.map +0 -1
- package/dist/tests/security/events/ProductEvents.js +0 -79
- package/dist/tests/security/events/ProductEvents.js.map +0 -1
- package/dist/tests/security/events/UserEvents.d.ts +0 -10
- package/dist/tests/security/events/UserEvents.d.ts.map +0 -1
- package/dist/tests/security/events/UserEvents.js +0 -26
- package/dist/tests/security/events/UserEvents.js.map +0 -1
- package/dist/tests/security/events/UserFileEvents.d.ts +0 -7
- package/dist/tests/security/events/UserFileEvents.d.ts.map +0 -1
- package/dist/tests/security/events/UserFileEvents.js +0 -7
- package/dist/tests/security/events/UserFileEvents.js.map +0 -1
- package/dist/tests/security/events/UserInfo.d.ts +0 -5
- package/dist/tests/security/events/UserInfo.d.ts.map +0 -1
- package/dist/tests/security/events/UserInfo.js +0 -9
- package/dist/tests/security/events/UserInfo.js.map +0 -1
- package/dist/tests/security/tests/include-items.d.ts +0 -3
- package/dist/tests/security/tests/include-items.d.ts.map +0 -1
- package/dist/tests/security/tests/include-items.js +0 -15
- package/dist/tests/security/tests/include-items.js.map +0 -1
- package/dist/tests/security/tests/place-order.d.ts +0 -3
- package/dist/tests/security/tests/place-order.d.ts.map +0 -1
- package/dist/tests/security/tests/place-order.js +0 -139
- package/dist/tests/security/tests/place-order.js.map +0 -1
- package/dist/tests/security/tests/test-events.d.ts +0 -3
- package/dist/tests/security/tests/test-events.d.ts.map +0 -1
- package/dist/tests/security/tests/test-events.js +0 -54
- package/dist/tests/security/tests/test-events.js.map +0 -1
- package/src/tests/TestConfig.ts +0 -6
- package/src/tests/db-tests/tests/check-constraint-test.ts +0 -32
- package/src/tests/db-tests/tests/delete-items.ts +0 -42
- package/src/tests/db-tests/tests/filtered-include-items.ts +0 -28
- package/src/tests/db-tests/tests/insert-into.ts +0 -24
- package/src/tests/db-tests/tests/multi-fk-tests.ts +0 -37
- package/src/tests/db-tests/tests/select-identity.ts +0 -23
- package/src/tests/db-tests/tests/select-inverse-one-to-one.ts +0 -39
- package/src/tests/db-tests/tests/select-items-map.ts +0 -38
- package/src/tests/db-tests/tests/select-items-sum.ts +0 -60
- package/src/tests/db-tests/tests/select-items.ts +0 -49
- package/src/tests/db-tests/tests/select-map.ts +0 -19
- package/src/tests/db-tests/tests/select-nested.ts +0 -36
- package/src/tests/db-tests/tests/select-parent.ts +0 -25
- package/src/tests/db-tests/tests/select-related.ts +0 -35
- package/src/tests/db-tests/tests/update-items.ts +0 -44
- package/src/tests/db-tests/tests/update-select.ts +0 -28
- package/src/tests/db-tests/tests/upsert-test.ts +0 -48
- package/src/tests/db-tests/tests/version-history.ts +0 -24
- package/src/tests/db-tests/transaction-save-point/transaction-save-point.ts +0 -48
- package/src/tests/drivers/postgres/connection-test.ts +0 -39
- package/src/tests/drivers/sql-server/sql-server-test.ts +0 -9
- package/src/tests/eternity/child-tests.ts +0 -119
- package/src/tests/eternity/eternity-tests.ts +0 -108
- package/src/tests/eternity/external-event-tests.ts +0 -133
- package/src/tests/eternity/throttle-tests.ts +0 -100
- package/src/tests/expressions/left-joins/child-joins.ts +0 -131
- package/src/tests/expressions/sanitize/sanitize-test.ts +0 -17
- package/src/tests/expressions/select/select.ts +0 -21
- package/src/tests/expressions/self-joins/self-joins.ts +0 -23
- package/src/tests/expressions/simple/parse-array.ts +0 -31
- package/src/tests/expressions/simple/parse-arrow.ts +0 -65
- package/src/tests/expressions/simple/parse-complex.ts +0 -20
- package/src/tests/expressions/trimInternal.ts +0 -25
- package/src/tests/model/ShoppingContext.ts +0 -435
- package/src/tests/model/UseFile.ts +0 -24
- package/src/tests/model/createContext.ts +0 -367
- package/src/tests/pool/pool-test.ts +0 -79
- package/src/tests/query/combine.ts +0 -28
- package/src/tests/security/ShoppingContextEvents.ts +0 -23
- package/src/tests/security/events/OrderEvents.ts +0 -72
- package/src/tests/security/events/ProductEvents.ts +0 -102
- package/src/tests/security/events/UserEvents.ts +0 -28
- package/src/tests/security/events/UserFileEvents.ts +0 -11
- package/src/tests/security/events/UserInfo.ts +0 -7
- package/src/tests/security/tests/include-items.ts +0 -20
- package/src/tests/security/tests/place-order.ts +0 -138
- package/src/tests/security/tests/test-events.ts +0 -55
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { __decorate, __metadata } from "tslib";
|
|
2
|
-
import EntityAccessError from "../../../common/EntityAccessError.js";
|
|
3
|
-
import Inject from "../../../di/di.js";
|
|
4
|
-
import EntityEvents from "../../../model/events/EntityEvents.js";
|
|
5
|
-
import { UserInfo } from "./UserInfo.js";
|
|
6
|
-
const statusPublished = "published";
|
|
7
|
-
export class ProductEvents extends EntityEvents {
|
|
8
|
-
filter(query) {
|
|
9
|
-
const { userID } = this.user;
|
|
10
|
-
// admin can access everything so return null
|
|
11
|
-
if (this.user.admin) {
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
14
|
-
// everyone can read published or own products
|
|
15
|
-
return query.where({ userID, statusPublished }, (p) => (x) => x.ownerID === p.userID || x.status === p.statusPublished);
|
|
16
|
-
}
|
|
17
|
-
modify(query) {
|
|
18
|
-
const { userID } = this.user;
|
|
19
|
-
// admin can access everything so return null
|
|
20
|
-
if (this.user.admin) {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
// customer can modify its own products
|
|
24
|
-
return query.where({ userID }, (p) => (x) => x.ownerID === p.userID);
|
|
25
|
-
}
|
|
26
|
-
afterUpdate(entity, entry) {
|
|
27
|
-
entity.updated = Array.from(entry.updated.keys()).map((x) => x.name);
|
|
28
|
-
entity.nameUpdated = entry.isUpdated("name");
|
|
29
|
-
}
|
|
30
|
-
afterInsert(entity, entry) {
|
|
31
|
-
entity.afterInsertInvoked = true;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
__decorate([
|
|
35
|
-
Inject,
|
|
36
|
-
__metadata("design:type", UserInfo)
|
|
37
|
-
], ProductEvents.prototype, "user", void 0);
|
|
38
|
-
export class ProductCategoryEvents extends EntityEvents {
|
|
39
|
-
filter(query) {
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
modify(query) {
|
|
43
|
-
const { userID } = this.user;
|
|
44
|
-
// admin can access everything so return null
|
|
45
|
-
if (this.user.admin) {
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
EntityAccessError.throw("Access denied");
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
__decorate([
|
|
52
|
-
Inject,
|
|
53
|
-
__metadata("design:type", UserInfo)
|
|
54
|
-
], ProductCategoryEvents.prototype, "user", void 0);
|
|
55
|
-
export class ProductPriceEvents extends EntityEvents {
|
|
56
|
-
filter(query) {
|
|
57
|
-
const { userID } = this.user;
|
|
58
|
-
// admin can access everything so return null
|
|
59
|
-
if (this.user.admin) {
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
// user can view prices of only published or own products
|
|
63
|
-
return query.where({ userID, statusPublished }, (p) => (x) => x.product.status === p.statusPublished || x.product.ownerID === p.userID);
|
|
64
|
-
}
|
|
65
|
-
modify(query) {
|
|
66
|
-
const { userID } = this.user;
|
|
67
|
-
// admin can access everything so return null
|
|
68
|
-
if (this.user.admin) {
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
// user can only edit its own prices
|
|
72
|
-
return query.where({ userID }, (p) => (x) => x.product.ownerID === p.userID);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
__decorate([
|
|
76
|
-
Inject,
|
|
77
|
-
__metadata("design:type", UserInfo)
|
|
78
|
-
], ProductPriceEvents.prototype, "user", void 0);
|
|
79
|
-
//# sourceMappingURL=ProductEvents.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ProductEvents.js","sourceRoot":"","sources":["../../../../src/tests/security/events/ProductEvents.ts"],"names":[],"mappings":";AAAA,OAAO,iBAAiB,MAAM,sCAAsC,CAAC;AACrE,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAGvC,OAAO,YAAY,MAAM,uCAAuC,CAAC;AAEjE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,MAAM,eAAe,GAAG,WAAW,CAAC;AAEpC,MAAM,OAAO,aAAc,SAAQ,YAAqB;IAKpD,MAAM,CAAC,KAA4B;QAC/B,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC;QAE7B,6CAA6C;QAC7C,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YAClB,OAAO,IAAI,CAAC;QAChB,C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DAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { IEntityQuery } from "../../../model/IFilterWithParameter.js";
|
|
2
|
-
import EntityEvents from "../../../model/events/EntityEvents.js";
|
|
3
|
-
import { User } from "../../model/ShoppingContext.js";
|
|
4
|
-
import { UserInfo } from "./UserInfo.js";
|
|
5
|
-
export declare class UserEvents extends EntityEvents<User> {
|
|
6
|
-
user: UserInfo;
|
|
7
|
-
filter(query: IEntityQuery<User>): IEntityQuery<User>;
|
|
8
|
-
modify(query: IEntityQuery<User>): IEntityQuery<User>;
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=UserEvents.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UserEvents.d.ts","sourceRoot":"","sources":["../../../../src/tests/security/events/UserEvents.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AACtE,OAAO,YAAY,MAAM,uCAAuC,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,gCAAgC,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,qBAAa,UAAW,SAAQ,YAAY,CAAC,IAAI,CAAC;IAG9C,IAAI,EAAE,QAAQ,CAAC;IAEf,MAAM,CAAC,KAAK,EAAE,YAAY,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,IAAI,CAAC;IAUrD,MAAM,CAAC,KAAK,EAAE,YAAY,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,IAAI,CAAC;CAOxD"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { __decorate, __metadata } from "tslib";
|
|
2
|
-
import Inject from "../../../di/di.js";
|
|
3
|
-
import EntityEvents from "../../../model/events/EntityEvents.js";
|
|
4
|
-
import { UserInfo } from "./UserInfo.js";
|
|
5
|
-
export class UserEvents extends EntityEvents {
|
|
6
|
-
filter(query) {
|
|
7
|
-
if (this.user.admin) {
|
|
8
|
-
return null;
|
|
9
|
-
}
|
|
10
|
-
const { userID } = this.user;
|
|
11
|
-
return query.where({ userID }, (p) => (x) => x.userID === p.userID
|
|
12
|
-
|| x.orders.some((op) => op.orderItems.some((oi) => oi.product.ownerID === p.userID)));
|
|
13
|
-
}
|
|
14
|
-
modify(query) {
|
|
15
|
-
if (this.user.admin) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
const { userID } = this.user;
|
|
19
|
-
return query.where({ userID }, (p) => (x) => x.userID === p.userID);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
__decorate([
|
|
23
|
-
Inject,
|
|
24
|
-
__metadata("design:type", UserInfo)
|
|
25
|
-
], UserEvents.prototype, "user", void 0);
|
|
26
|
-
//# sourceMappingURL=UserEvents.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UserEvents.js","sourceRoot":"","sources":["../../../../src/tests/security/events/UserEvents.ts"],"names":[],"mappings":";AAAA,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,YAAY,MAAM,uCAAuC,CAAC;AAEjE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,MAAM,OAAO,UAAW,SAAQ,YAAkB;IAK9C,MAAM,CAAC,KAAyB;QAC5B,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YAClB,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC;QAC7B,OAAO,KAAK,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM;eAC3D,CAAC,CAAC,MAAM,CAAC,IAAI,CACZ,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAClF,CAAC;IAED,MAAM,CAAC,KAAyB;QAC5B,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YAClB,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC;QAC7B,OAAO,KAAK,CAAC,KAAK,CAAC,EAAE,MAAM,EAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC;IACvE,CAAC;CACJ;AAnBG;IADC,MAAM;8BACD,QAAQ;wCAAC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { IEntityQuery } from "../../../index.js";
|
|
2
|
-
import EntityEvents from "../../../model/events/EntityEvents.js";
|
|
3
|
-
import { UserFile } from "../../model/UseFile.js";
|
|
4
|
-
export declare class UserFileEvents extends EntityEvents<UserFile> {
|
|
5
|
-
filter(query: IEntityQuery<UserFile>): IEntityQuery<UserFile>;
|
|
6
|
-
}
|
|
7
|
-
//# sourceMappingURL=UserFileEvents.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UserFileEvents.d.ts","sourceRoot":"","sources":["../../../../src/tests/security/events/UserFileEvents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,YAAY,MAAM,uCAAuC,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAElD,qBAAa,cAAe,SAAQ,YAAY,CAAC,QAAQ,CAAC;IAEtD,MAAM,CAAC,KAAK,EAAE,YAAY,CAAC,QAAQ,CAAC,GAAG,YAAY,CAAC,QAAQ,CAAC;CAIhE"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import EntityEvents from "../../../model/events/EntityEvents.js";
|
|
2
|
-
export class UserFileEvents extends EntityEvents {
|
|
3
|
-
filter(query) {
|
|
4
|
-
return query.where({}, (p) => (x) => x.photoUsers.some((p1) => p1.orders.some((o1) => true === true)));
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
//# sourceMappingURL=UserFileEvents.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UserFileEvents.js","sourceRoot":"","sources":["../../../../src/tests/security/events/UserFileEvents.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,MAAM,uCAAuC,CAAC;AAGjE,MAAM,OAAO,cAAe,SAAQ,YAAsB;IAEtD,MAAM,CAAC,KAA6B;QAChC,OAAO,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC;IAC3G,CAAC;CAEJ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UserInfo.d.ts","sourceRoot":"","sources":["../../../../src/tests/security/events/UserInfo.ts"],"names":[],"mappings":"AAEA,qBACa,QAAQ;IACV,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;CACzB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UserInfo.js","sourceRoot":"","sources":["../../../../src/tests/security/events/UserInfo.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAG5C,IAAM,QAAQ,GAAd,MAAM,QAAQ;CAGpB,CAAA;AAHY,QAAQ;IADpB,cAAc;GACF,QAAQ,CAGpB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"include-items.d.ts","sourceRoot":"","sources":["../../../../src/tests/security/tests/include-items.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAKjD,yBAA+B,IAAI,EAAE,UAAU,iBAa9C"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import assert from "assert";
|
|
2
|
-
import { createContext } from "../../model/createContext.js";
|
|
3
|
-
import { ShoppingContext } from "../../model/ShoppingContext.js";
|
|
4
|
-
import Logger from "../../../common/Logger.js";
|
|
5
|
-
export default async function () {
|
|
6
|
-
const old = await createContext(this.driver);
|
|
7
|
-
const context = new ShoppingContext(old.driver, void 0, Logger.instance);
|
|
8
|
-
const order = await context.orders.all()
|
|
9
|
-
.where({ id: 0 }, (p) => (x) => x.orderID > p.id)
|
|
10
|
-
.include((x) => x.orderItems.forEach((oi) => oi.productPrice.product))
|
|
11
|
-
.first();
|
|
12
|
-
assert.notEqual(null, order);
|
|
13
|
-
assert.notEqual(undefined, order.orderItems);
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=include-items.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"include-items.js","sourceRoot":"","sources":["../../../../src/tests/security/tests/include-items.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAE/C,MAAM,CAAC,OAAO,CAAC,KAAK;IAEhB,MAAM,GAAG,GAAG,MAAM,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAE7C,MAAM,OAAO,GAAG,IAAI,eAAe,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IACzE,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE;SACnC,KAAK,CAAC,EAAC,EAAE,EAAE,CAAC,EAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,EAAE,CAAC;SAC9C,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;SACrE,KAAK,EAAE,CAAC;IAEb,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC7B,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;AAEjD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"place-order.d.ts","sourceRoot":"","sources":["../../../../src/tests/security/tests/place-order.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAOjD,yBAA8B,IAAI,EAAE,UAAU,iBAgB7C"}
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import { __addDisposableResource, __disposeResources } from "tslib";
|
|
2
|
-
import assert from "assert";
|
|
3
|
-
import Logger from "../../../common/Logger.js";
|
|
4
|
-
import { ServiceCollection, ServiceProvider } from "../../../di/di.js";
|
|
5
|
-
import { BaseDriver } from "../../../drivers/base/BaseDriver.js";
|
|
6
|
-
import ContextEvents from "../../../model/events/ContextEvents.js";
|
|
7
|
-
import { ShoppingContext } from "../../model/ShoppingContext.js";
|
|
8
|
-
import { createContext } from "../../model/createContext.js";
|
|
9
|
-
import { ShoppingContextEvents } from "../ShoppingContextEvents.js";
|
|
10
|
-
import { UserInfo } from "../events/UserInfo.js";
|
|
11
|
-
import DateTime from "../../../types/DateTime.js";
|
|
12
|
-
export default async function () {
|
|
13
|
-
const customer = await createUser(this);
|
|
14
|
-
await addNewOrder.call(this, customer);
|
|
15
|
-
try {
|
|
16
|
-
await addNewOrder.call(this, customer, 1);
|
|
17
|
-
assert.fail("No error thrown");
|
|
18
|
-
}
|
|
19
|
-
catch (error) {
|
|
20
|
-
// do nothing
|
|
21
|
-
}
|
|
22
|
-
await getNewOrders.call(this);
|
|
23
|
-
await createInterests.call(this);
|
|
24
|
-
}
|
|
25
|
-
async function createInterests() {
|
|
26
|
-
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
27
|
-
try {
|
|
28
|
-
const global = new ServiceProvider();
|
|
29
|
-
global.add(BaseDriver, this.driver);
|
|
30
|
-
const scope = __addDisposableResource(env_1, global.createScope(), false);
|
|
31
|
-
const userID = 2;
|
|
32
|
-
const user = new UserInfo();
|
|
33
|
-
user.userID = userID;
|
|
34
|
-
ServiceCollection.register("Singleton", Logger, () => Logger.instance);
|
|
35
|
-
scope.add(BaseDriver, this.driver);
|
|
36
|
-
scope.add(UserInfo, user);
|
|
37
|
-
ServiceCollection.register("Singleton", ContextEvents, () => new ShoppingContextEvents());
|
|
38
|
-
const context = scope.create(ShoppingContext);
|
|
39
|
-
context.verifyFilters = false;
|
|
40
|
-
context.raiseEvents = false;
|
|
41
|
-
const headPhone = await context.products.all().include((x) => x.categories).firstOrFail();
|
|
42
|
-
const category = headPhone.categories[0];
|
|
43
|
-
context.userCategories.add({
|
|
44
|
-
userID,
|
|
45
|
-
categoryID: category.categoryID,
|
|
46
|
-
lastUpdated: DateTime.now
|
|
47
|
-
});
|
|
48
|
-
await context.saveChanges();
|
|
49
|
-
const userCategories = await context.userCategories.where({ userID }, (p) => (x) => x.userID === p.userID).count();
|
|
50
|
-
assert.equal(1, userCategories);
|
|
51
|
-
}
|
|
52
|
-
catch (e_1) {
|
|
53
|
-
env_1.error = e_1;
|
|
54
|
-
env_1.hasError = true;
|
|
55
|
-
}
|
|
56
|
-
finally {
|
|
57
|
-
__disposeResources(env_1);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
async function getNewOrders() {
|
|
61
|
-
const env_2 = { stack: [], error: void 0, hasError: false };
|
|
62
|
-
try {
|
|
63
|
-
const global = new ServiceProvider();
|
|
64
|
-
global.add(BaseDriver, this.driver);
|
|
65
|
-
const scope = __addDisposableResource(env_2, global.createScope(), false);
|
|
66
|
-
const user = new UserInfo();
|
|
67
|
-
user.userID = 2;
|
|
68
|
-
ServiceCollection.register("Singleton", Logger, () => Logger.instance);
|
|
69
|
-
scope.add(BaseDriver, this.driver);
|
|
70
|
-
scope.add(UserInfo, user);
|
|
71
|
-
ServiceCollection.register("Singleton", ContextEvents, () => new ShoppingContextEvents());
|
|
72
|
-
const context = scope.create(ShoppingContext);
|
|
73
|
-
context.verifyFilters = true;
|
|
74
|
-
const order = await context.orders.all().first();
|
|
75
|
-
order.orderDate = new Date();
|
|
76
|
-
await context.saveChanges();
|
|
77
|
-
}
|
|
78
|
-
catch (e_2) {
|
|
79
|
-
env_2.error = e_2;
|
|
80
|
-
env_2.hasError = true;
|
|
81
|
-
}
|
|
82
|
-
finally {
|
|
83
|
-
__disposeResources(env_2);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
async function addNewOrder(customer, userID) {
|
|
87
|
-
const env_3 = { stack: [], error: void 0, hasError: false };
|
|
88
|
-
try {
|
|
89
|
-
const global = new ServiceProvider();
|
|
90
|
-
global.add(BaseDriver, this.driver);
|
|
91
|
-
const scope = __addDisposableResource(env_3, global.createScope(), false);
|
|
92
|
-
const user = new UserInfo();
|
|
93
|
-
user.userID = userID ?? customer.userID;
|
|
94
|
-
ServiceCollection.register("Singleton", Logger, () => Logger.instance);
|
|
95
|
-
scope.add(BaseDriver, this.driver);
|
|
96
|
-
scope.add(UserInfo, user);
|
|
97
|
-
ServiceCollection.register("Singleton", ContextEvents, () => new ShoppingContextEvents());
|
|
98
|
-
const context = scope.create(ShoppingContext);
|
|
99
|
-
context.verifyFilters = true;
|
|
100
|
-
// get first headphone...
|
|
101
|
-
const headPhone = await context.products.all().firstOrFail();
|
|
102
|
-
const headPhonePrice = await context.productPrices.where({ id: headPhone.productID }, (p) => (x) => x.productID === p.id).firstOrFail();
|
|
103
|
-
context.orders.add({
|
|
104
|
-
customer,
|
|
105
|
-
orderDate: new Date(),
|
|
106
|
-
orderItems: [
|
|
107
|
-
context.orderItems.add({
|
|
108
|
-
product: headPhone,
|
|
109
|
-
productPrice: headPhonePrice,
|
|
110
|
-
amount: headPhonePrice.amount,
|
|
111
|
-
})
|
|
112
|
-
]
|
|
113
|
-
});
|
|
114
|
-
await context.saveChanges();
|
|
115
|
-
// lets filter the orders
|
|
116
|
-
const f = context.orders.filtered();
|
|
117
|
-
const myOrders = await f.count();
|
|
118
|
-
assert.equal(1, myOrders);
|
|
119
|
-
const all = await context.orders.all().count();
|
|
120
|
-
assert.notEqual(all, myOrders);
|
|
121
|
-
}
|
|
122
|
-
catch (e_3) {
|
|
123
|
-
env_3.error = e_3;
|
|
124
|
-
env_3.hasError = true;
|
|
125
|
-
}
|
|
126
|
-
finally {
|
|
127
|
-
__disposeResources(env_3);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
async function createUser(config) {
|
|
131
|
-
const context = await createContext(config.driver);
|
|
132
|
-
const user = context.users.add({
|
|
133
|
-
userName: "customer",
|
|
134
|
-
dateCreated: new Date()
|
|
135
|
-
});
|
|
136
|
-
await context.saveChanges();
|
|
137
|
-
return { ...user };
|
|
138
|
-
}
|
|
139
|
-
//# sourceMappingURL=place-order.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"place-order.js","sourceRoot":"","sources":["../../../../src/tests/security/tests/place-order.ts"],"names":[],"mappings":";AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAC/C,OAAO,EAAE,iBAAiB,E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,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;QACpC,MAAM,QAAQ,GAAG,MAAM,CAAC,CAAC,KAAK,EAAE,CAAC;QACjC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;QAE1B,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC;QAC/C,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;;;;;;;;;CAClC;AAED,KAAK,UAAU,UAAU,CAAC,MAAkB;IACxC,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACnD,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC;QAC3B,QAAQ,EAAE,UAAU;QACpB,WAAW,EAAE,IAAI,IAAI,EAAE;KAC1B,CAAC,CAAC;IACH,MAAM,OAAO,CAAC,WAAW,EAAE,CAAC;IAC5B,OAAO,EAAE,GAAI,IAAI,EAAE,CAAC;AACxB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test-events.d.ts","sourceRoot":"","sources":["../../../../src/tests/security/tests/test-events.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAMjD,yBAA+B,IAAI,EAAE,UAAU,iBA2C9C"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { __addDisposableResource, __disposeResources } from "tslib";
|
|
2
|
-
import assert from "assert";
|
|
3
|
-
import Logger from "../../../common/Logger.js";
|
|
4
|
-
import { ServiceProvider } from "../../../di/di.js";
|
|
5
|
-
import { BaseDriver } from "../../../drivers/base/BaseDriver.js";
|
|
6
|
-
import ContextEvents from "../../../model/events/ContextEvents.js";
|
|
7
|
-
import { ShoppingContext, statusPublished } from "../../model/ShoppingContext.js";
|
|
8
|
-
import { createContext } from "../../model/createContext.js";
|
|
9
|
-
import { ShoppingContextEvents } from "../ShoppingContextEvents.js";
|
|
10
|
-
import { UserInfo } from "../events/UserInfo.js";
|
|
11
|
-
export default async function () {
|
|
12
|
-
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
13
|
-
try {
|
|
14
|
-
await createContext(this.driver);
|
|
15
|
-
const global = new ServiceProvider();
|
|
16
|
-
global.add(BaseDriver, this.driver);
|
|
17
|
-
const scope = __addDisposableResource(env_1, global.createScope(), false);
|
|
18
|
-
const userID = 1;
|
|
19
|
-
const user = new UserInfo();
|
|
20
|
-
user.userID = userID;
|
|
21
|
-
scope.add(Logger, Logger.instance);
|
|
22
|
-
scope.add(BaseDriver, this.driver);
|
|
23
|
-
scope.add(UserInfo, user);
|
|
24
|
-
scope.add(ContextEvents, new ShoppingContextEvents());
|
|
25
|
-
const context = scope.create(ShoppingContext);
|
|
26
|
-
const first = await context.products.all().first();
|
|
27
|
-
first.name = "First Product";
|
|
28
|
-
const fe = context.changeSet.getEntry(first);
|
|
29
|
-
await context.saveChanges();
|
|
30
|
-
assert.notStrictEqual(undefined, first.nameUpdated);
|
|
31
|
-
assert.equal(true, first.nameUpdated);
|
|
32
|
-
assert.equal(false, fe.isUpdated("name"));
|
|
33
|
-
const status = statusPublished;
|
|
34
|
-
// create new product...
|
|
35
|
-
const p = context.products.add({
|
|
36
|
-
name: "A",
|
|
37
|
-
status,
|
|
38
|
-
ownerID: userID
|
|
39
|
-
});
|
|
40
|
-
assert.equal(void 0, p.afterInsertInvoked);
|
|
41
|
-
await context.saveChanges();
|
|
42
|
-
assert.equal(true, p.afterInsertInvoked);
|
|
43
|
-
await context.userFiles.filtered("read").where({}, (_) => (x) => x.photoUsers.some((p1) => true === true))
|
|
44
|
-
.include((x) => x.user.profile).toArray();
|
|
45
|
-
}
|
|
46
|
-
catch (e_1) {
|
|
47
|
-
env_1.error = e_1;
|
|
48
|
-
env_1.hasError = true;
|
|
49
|
-
}
|
|
50
|
-
finally {
|
|
51
|
-
__disposeResources(env_1);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
//# sourceMappingURL=test-events.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test-events.js","sourceRoot":"","sources":["../../../../src/tests/security/tests/test-events.ts"],"names":[],"mappings":";AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAC/C,OAAO,EAAqB,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,aAAa,MAAM,wCAAwC,CAAC;AAEnE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAClF,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,MAAM,CAAC,OAAO,CAAC,KAAK;;;QAEhB,MAAM,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAGjC,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;QACrC,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAEpC,MAAM,KAAK,kCAAG,MAAM,CAAC,WAAW,EAAE,QAAA,CAAC;QAEnC,MAAM,MAAM,GAAG,CAAC,CAAC;QACjB,MAAM,IAAI,GAAG,IAAI,QAAQ,EAAE,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;QACnC,KAAK,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QACnC,KAAK,CAAC,GAAG,CAAC,QAA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AAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;aACrG,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,CAAC;;;;;;;;;CAGjD"}
|
package/src/tests/TestConfig.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import assert from "assert";
|
|
2
|
-
import { Sql } from "../../../index.js";
|
|
3
|
-
import { TestConfig } from "../../TestConfig.js";
|
|
4
|
-
import { createContext } from "../../model/createContext.js";
|
|
5
|
-
|
|
6
|
-
export default async function(this: TestConfig) {
|
|
7
|
-
|
|
8
|
-
if (!this.db) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const context = await createContext(this.driver);
|
|
13
|
-
|
|
14
|
-
const first = await context.products.all().first();
|
|
15
|
-
|
|
16
|
-
first.name = "First product";
|
|
17
|
-
|
|
18
|
-
try {
|
|
19
|
-
|
|
20
|
-
// try direct save...
|
|
21
|
-
await context.productPrices.statements.insert({
|
|
22
|
-
productID: first.productID,
|
|
23
|
-
active: true,
|
|
24
|
-
amount: -1,
|
|
25
|
-
startDate: new Date(),
|
|
26
|
-
});
|
|
27
|
-
} catch (error) {
|
|
28
|
-
// expcted...
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
assert.fail();
|
|
32
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import assert from "assert";
|
|
2
|
-
import { Sql } from "../../../index.js";
|
|
3
|
-
import { TestConfig } from "../../TestConfig.js";
|
|
4
|
-
import { createContext } from "../../model/createContext.js";
|
|
5
|
-
|
|
6
|
-
export default async function(this: TestConfig) {
|
|
7
|
-
|
|
8
|
-
if (!this.db) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const context = await createContext(this.driver);
|
|
13
|
-
|
|
14
|
-
const first = await context.products.all().first();
|
|
15
|
-
|
|
16
|
-
first.name = "First product";
|
|
17
|
-
|
|
18
|
-
await context.saveChanges();
|
|
19
|
-
|
|
20
|
-
let total = await context.products.all().count();
|
|
21
|
-
|
|
22
|
-
let n = await context.products.all()
|
|
23
|
-
.delete(void 0, (p) => (x) => x.productID === 1);
|
|
24
|
-
|
|
25
|
-
assert.equal(n, 1);
|
|
26
|
-
|
|
27
|
-
let after = await context.products.all().count();
|
|
28
|
-
|
|
29
|
-
assert.equal(total - 1, after);
|
|
30
|
-
|
|
31
|
-
total = await context.products.all().count();
|
|
32
|
-
n = await context.products.all()
|
|
33
|
-
.limit(1)
|
|
34
|
-
.delete(void 0, (p) => (x) => true === true);
|
|
35
|
-
|
|
36
|
-
assert.equal(n, 1);
|
|
37
|
-
|
|
38
|
-
after = await context.products.all().count();
|
|
39
|
-
|
|
40
|
-
assert.equal(total - 1, after);
|
|
41
|
-
|
|
42
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import assert from "assert";
|
|
2
|
-
import { TestConfig } from "../../TestConfig.js";
|
|
3
|
-
import { createContext, headPhoneCategory } from "../../model/createContext.js";
|
|
4
|
-
|
|
5
|
-
export default async function(this: TestConfig) {
|
|
6
|
-
|
|
7
|
-
if (!this.db) {
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const context = await createContext(this.driver);
|
|
12
|
-
|
|
13
|
-
const category = await context.categories
|
|
14
|
-
.where({ headPhoneCategory }, (p) => (x) => x.categoryID === p.headPhoneCategory && x.productCategories.some((pc) => pc.productID > 0))
|
|
15
|
-
.include((x) => x.productCategories.forEach((pc) => pc.product.prices))
|
|
16
|
-
.first();
|
|
17
|
-
|
|
18
|
-
const first = category.productCategories[0];
|
|
19
|
-
assert.notEqual(0, first.product.prices.length);
|
|
20
|
-
|
|
21
|
-
const count = await context.categories
|
|
22
|
-
.where({ headPhoneCategory }, (p) => (x) => x.categoryID === p.headPhoneCategory && x.productCategories.some((pc) => pc.productID > 0))
|
|
23
|
-
.count();
|
|
24
|
-
|
|
25
|
-
assert.notEqual(0, count);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import assert from "assert";
|
|
2
|
-
import { TestConfig } from "../../TestConfig.js";
|
|
3
|
-
import { createContext } from "../../model/createContext.js";
|
|
4
|
-
import Sql from "../../../sql/Sql.js";
|
|
5
|
-
|
|
6
|
-
export default async function(this: TestConfig) {
|
|
7
|
-
|
|
8
|
-
if (!this.db) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const context = await createContext(this.driver);
|
|
13
|
-
|
|
14
|
-
await context.messages.asQuery()
|
|
15
|
-
.where(void 0, (p) => (x) => x.messageID > 100)
|
|
16
|
-
.select(void 0, (p) => (x) => ({
|
|
17
|
-
fromID: x.fromID,
|
|
18
|
-
toID: x.toID,
|
|
19
|
-
message: x.message
|
|
20
|
-
}))
|
|
21
|
-
.trace(console.log)
|
|
22
|
-
.insertInTo(context.archivedMessages);
|
|
23
|
-
|
|
24
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import assert from "assert";
|
|
2
|
-
import { TestConfig } from "../../TestConfig.js";
|
|
3
|
-
import { createContext } from "../../model/createContext.js";
|
|
4
|
-
|
|
5
|
-
export default async function(this: TestConfig) {
|
|
6
|
-
|
|
7
|
-
if (!this.db) {
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const context = await createContext(this.driver);
|
|
12
|
-
|
|
13
|
-
const { userID } = await context.users.asQuery().first();
|
|
14
|
-
const { categoryID } = await context.categories.asQuery().first();
|
|
15
|
-
|
|
16
|
-
await context.userCategories.statements.insert({
|
|
17
|
-
userID,
|
|
18
|
-
categoryID
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
await context.userCategoryTags.statements.insert({
|
|
22
|
-
categoryID,
|
|
23
|
-
userID,
|
|
24
|
-
tag: "A"
|
|
25
|
-
});
|
|
26
|
-
await context.userCategoryTags.statements.insert({
|
|
27
|
-
categoryID,
|
|
28
|
-
userID,
|
|
29
|
-
tag: "B"
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
const first = await context.userCategories.asQuery()
|
|
33
|
-
.include((x) => x.tags)
|
|
34
|
-
.first();
|
|
35
|
-
|
|
36
|
-
assert.notEqual(void 0, first.tags);
|
|
37
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import assert from "assert";
|
|
2
|
-
import { TestConfig } from "../../TestConfig.js";
|
|
3
|
-
import { createContext, headPhoneCategory } from "../../model/createContext.js";
|
|
4
|
-
import IdentityService from "../../../model/identity/IdentityService.js";
|
|
5
|
-
import { User } from "../../model/ShoppingContext.js";
|
|
6
|
-
|
|
7
|
-
export default async function(this: TestConfig) {
|
|
8
|
-
|
|
9
|
-
if (!this.db) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const context = await createContext(this.driver);
|
|
14
|
-
|
|
15
|
-
const key = IdentityService.getIdentity(context.model.getEntityType(User), { userID: 1 });
|
|
16
|
-
const notFound = context.changeSet.getByIdentity(key);
|
|
17
|
-
|
|
18
|
-
assert.equal(undefined, notFound);
|
|
19
|
-
|
|
20
|
-
const found = await context.users.loadByKeys({ userID: 1});
|
|
21
|
-
|
|
22
|
-
assert.notEqual(undefined, found);
|
|
23
|
-
}
|