@jskit-ai/database-runtime 0.1.261 → 0.1.263
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/CHANGELOG.md +14 -0
- package/package.json +4 -5
- package/src/server/database.js +7 -7
- package/src/server/databaseSetup.js +3 -3
- package/src/server/knexMigrationConfig.js +7 -2
- package/src/server/testDatabases.js +52 -3
- package/src/server/types.js +1 -2
- package/src/shared/databaseConnection.js +20 -1
- package/src/shared/duplicateEntry.js +10 -1
- package/src/shared/index.js +1 -9
- package/src/shared/repositoryOptions.js +41 -119
- package/test/databaseConnection.postgres.test.js +66 -0
- package/test/databaseConnection.test.js +26 -1
- package/test/duplicateEntry.test.js +16 -0
- package/test/entrypoints.boundary.test.js +18 -2
- package/test/knexMigrationConfig.test.js +39 -8
- package/test/providerRuntime.test.js +2 -2
- package/test/repositoryOptions.test.js +81 -76
- package/test/testDatabases.test.js +37 -0
- package/src/shared/transactionManager.js +0 -31
- package/src/shared/visibility.js +0 -73
- package/test/runtimeCore.test.js +0 -51
- package/test/visibility.test.js +0 -93
package/test/visibility.test.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import test from "node:test";
|
|
3
|
-
import { applyVisibility, applyVisibilityOwners } from "../src/shared/visibility.js";
|
|
4
|
-
|
|
5
|
-
function createQueryBuilderStub() {
|
|
6
|
-
return {
|
|
7
|
-
calls: [],
|
|
8
|
-
where(...args) {
|
|
9
|
-
this.calls.push(["where", ...args]);
|
|
10
|
-
return this;
|
|
11
|
-
},
|
|
12
|
-
whereRaw(sql) {
|
|
13
|
-
this.calls.push(["whereRaw", sql]);
|
|
14
|
-
return this;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
test("applyVisibility appends scope filters to query builders", () => {
|
|
20
|
-
const publicQuery = createQueryBuilderStub();
|
|
21
|
-
applyVisibility(publicQuery, {
|
|
22
|
-
visibility: "public"
|
|
23
|
-
});
|
|
24
|
-
assert.deepEqual(publicQuery.calls, []);
|
|
25
|
-
|
|
26
|
-
const workspaceQuery = createQueryBuilderStub();
|
|
27
|
-
applyVisibility(workspaceQuery, {
|
|
28
|
-
visibility: "workspace",
|
|
29
|
-
scopeOwnerId: 12
|
|
30
|
-
});
|
|
31
|
-
assert.deepEqual(workspaceQuery.calls, [["where", "workspace_id", "12"]]);
|
|
32
|
-
|
|
33
|
-
const userQuery = createQueryBuilderStub();
|
|
34
|
-
applyVisibility(userQuery, {
|
|
35
|
-
visibility: "user",
|
|
36
|
-
userId: 7
|
|
37
|
-
});
|
|
38
|
-
assert.deepEqual(userQuery.calls, [["where", "user_id", "7"]]);
|
|
39
|
-
|
|
40
|
-
const deniedQuery = createQueryBuilderStub();
|
|
41
|
-
applyVisibility(deniedQuery, {
|
|
42
|
-
visibility: "workspace_user",
|
|
43
|
-
scopeOwnerId: 3
|
|
44
|
-
});
|
|
45
|
-
assert.deepEqual(deniedQuery.calls, [["whereRaw", "1 = 0"]]);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
test("applyVisibilityOwners injects owner columns for write payloads", () => {
|
|
49
|
-
assert.deepEqual(
|
|
50
|
-
applyVisibilityOwners(
|
|
51
|
-
{
|
|
52
|
-
name: "Alice"
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
visibility: "public"
|
|
56
|
-
}
|
|
57
|
-
),
|
|
58
|
-
{
|
|
59
|
-
name: "Alice"
|
|
60
|
-
}
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
assert.deepEqual(
|
|
64
|
-
applyVisibilityOwners(
|
|
65
|
-
{
|
|
66
|
-
name: "Alice"
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
visibility: "workspace_user",
|
|
70
|
-
scopeOwnerId: 4,
|
|
71
|
-
userId: 9
|
|
72
|
-
}
|
|
73
|
-
),
|
|
74
|
-
{
|
|
75
|
-
name: "Alice",
|
|
76
|
-
workspace_id: "4",
|
|
77
|
-
user_id: "9"
|
|
78
|
-
}
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
assert.throws(
|
|
82
|
-
() =>
|
|
83
|
-
applyVisibilityOwners(
|
|
84
|
-
{
|
|
85
|
-
name: "Alice"
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
visibility: "user"
|
|
89
|
-
}
|
|
90
|
-
),
|
|
91
|
-
/requires userId/
|
|
92
|
-
);
|
|
93
|
-
});
|