@jskit-ai/rewarded-core 0.2.16 → 0.2.17
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 +1 -0
- package/package.json +11 -11
- package/src/shared/rewardedProviderConfigResource.js +1 -0
- package/src/shared/rewardedRuleResource.js +1 -0
- package/src/shared/rewardedUnlockReceiptResource.js +6 -0
- package/src/shared/rewardedWatchSessionResource.js +5 -0
- package/test/foreignKeysMigration.integration.test.js +8 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
- Its table resources declare the foreign keys their migrations create (`foreignKeys`), so json-rest-api 3.1.0 can skip the visibility query a system-context read makes for a record such a key guarantees exists. `jskit test --databases` checks each against an app's test database: each table's workspace_id to workspaces, the unlock receipts' and watch sessions' user_id to users and provider_config_id to rewarded_provider_configs, and rewarded_unlock_receipts.watch_session_id to rewarded_watch_sessions. `foreignKeysMigration.integration.test.js` proves the declarations match the migrations on MySQL.
|
|
5
6
|
- `@jskit-ai/database-runtime` and `@jskit-ai/resource-runtime` are peer dependencies, required and at the same versions, where they were dependencies: its rules, provider settings, watch sessions and unlock receipts are table resources, and the app holds one copy of the table runtime that every package shares, as it does the kernel. npm installs a required peer as it installed the dependency, so an app installs the same packages and versions; a release whose versions disagree now fails the install with ERESOLVE instead of nesting a second copy.
|
|
6
7
|
- `@jskit-ai/database-runtime` is a dependency again: the foreign-key migration (`migrations/constraints/rewarded_foreign_keys.cjs`) imports its `server/foreignKeyMigrations` in `up` and `down`, which resolved only through hoisting since the CRUD features moved to the resource runtime.
|
|
7
8
|
- The rewarded table resources no longer declare their own `id` search entry: their handles' `id` filter takes one id or a list.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jskit-ai/rewarded-core",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.17",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "jskit test"
|
|
@@ -125,18 +125,18 @@
|
|
|
125
125
|
}
|
|
126
126
|
},
|
|
127
127
|
"dependencies": {
|
|
128
|
-
"@jskit-ai/crud-core": "0.2.
|
|
129
|
-
"@jskit-ai/resource-core": "0.1.
|
|
130
|
-
"@jskit-ai/resource-crud-core": "0.1.
|
|
131
|
-
"@jskit-ai/users-core": "0.2.
|
|
132
|
-
"@jskit-ai/workspaces-core": "0.2.
|
|
128
|
+
"@jskit-ai/crud-core": "0.2.16",
|
|
129
|
+
"@jskit-ai/resource-core": "0.1.206",
|
|
130
|
+
"@jskit-ai/resource-crud-core": "0.1.206",
|
|
131
|
+
"@jskit-ai/users-core": "0.2.17",
|
|
132
|
+
"@jskit-ai/workspaces-core": "0.2.17",
|
|
133
133
|
"json-rest-schema": "^1.0.17"
|
|
134
134
|
},
|
|
135
135
|
"peerDependencies": {
|
|
136
|
-
"@jskit-ai/auth-core": "0.2.
|
|
137
|
-
"@jskit-ai/database-runtime": "0.1.
|
|
138
|
-
"@jskit-ai/http-runtime": "0.2.
|
|
139
|
-
"@jskit-ai/kernel": "0.2.
|
|
140
|
-
"@jskit-ai/resource-runtime": "0.2.
|
|
136
|
+
"@jskit-ai/auth-core": "0.2.15",
|
|
137
|
+
"@jskit-ai/database-runtime": "0.1.264",
|
|
138
|
+
"@jskit-ai/http-runtime": "0.2.15",
|
|
139
|
+
"@jskit-ai/kernel": "0.2.15",
|
|
140
|
+
"@jskit-ai/resource-runtime": "0.2.13"
|
|
141
141
|
}
|
|
142
142
|
}
|
|
@@ -5,6 +5,7 @@ const rewardedProviderConfigTableResource = defineTableResource({
|
|
|
5
5
|
name: "rewardedProviderConfigs",
|
|
6
6
|
tableName: "rewarded_provider_configs",
|
|
7
7
|
ownership: "workspace",
|
|
8
|
+
foreignKeys: [{ columns: ["workspaceId"], referencedTableName: "workspaces" }],
|
|
8
9
|
schema: {
|
|
9
10
|
workspaceId: {
|
|
10
11
|
type: "id",
|
|
@@ -5,6 +5,12 @@ const rewardedUnlockReceiptTableResource = defineTableResource({
|
|
|
5
5
|
name: "rewardedUnlockReceipts",
|
|
6
6
|
tableName: "rewarded_unlock_receipts",
|
|
7
7
|
ownership: "workspace_user",
|
|
8
|
+
foreignKeys: [
|
|
9
|
+
{ columns: ["workspaceId"], referencedTableName: "workspaces" },
|
|
10
|
+
{ columns: ["userId"], referencedTableName: "users" },
|
|
11
|
+
{ columns: ["providerConfigId"], referencedTableName: "rewarded_provider_configs" },
|
|
12
|
+
{ columns: ["watchSessionId"], referencedTableName: "rewarded_watch_sessions" }
|
|
13
|
+
],
|
|
8
14
|
schema: {
|
|
9
15
|
workspaceId: {
|
|
10
16
|
type: "id",
|
|
@@ -5,6 +5,11 @@ const rewardedWatchSessionTableResource = defineTableResource({
|
|
|
5
5
|
name: "rewardedWatchSessions",
|
|
6
6
|
tableName: "rewarded_watch_sessions",
|
|
7
7
|
ownership: "workspace_user",
|
|
8
|
+
foreignKeys: [
|
|
9
|
+
{ columns: ["workspaceId"], referencedTableName: "workspaces" },
|
|
10
|
+
{ columns: ["userId"], referencedTableName: "users" },
|
|
11
|
+
{ columns: ["providerConfigId"], referencedTableName: "rewarded_provider_configs" }
|
|
12
|
+
],
|
|
8
13
|
schema: {
|
|
9
14
|
workspaceId: {
|
|
10
15
|
type: "id",
|
|
@@ -5,6 +5,11 @@ import rulesMigration from "../migrations/rewarded_rules_initial.cjs";
|
|
|
5
5
|
import unlockReceiptsMigration from "../migrations/rewarded_unlock_receipts_initial.cjs";
|
|
6
6
|
import watchSessionsMigration from "../migrations/rewarded_watch_sessions_initial.cjs";
|
|
7
7
|
import foreignKeysMigration from "../migrations/constraints/rewarded_foreign_keys.cjs";
|
|
8
|
+
import { checkForeignKeys } from "@jskit-ai/resource-runtime/server";
|
|
9
|
+
import { rewardedProviderConfigTableResource } from "../src/shared/rewardedProviderConfigResource.js";
|
|
10
|
+
import { rewardedRuleTableResource } from "../src/shared/rewardedRuleResource.js";
|
|
11
|
+
import { rewardedUnlockReceiptTableResource } from "../src/shared/rewardedUnlockReceiptResource.js";
|
|
12
|
+
import { rewardedWatchSessionTableResource } from "../src/shared/rewardedWatchSessionResource.js";
|
|
8
13
|
import { openOwnDatabase } from "./mysqlDatabase.js";
|
|
9
14
|
|
|
10
15
|
// Knex's filename order within rewarded-core's migrations/ directory.
|
|
@@ -68,6 +73,9 @@ test("a fresh MySQL database migrates rewarded-core before users and workspaces
|
|
|
68
73
|
}
|
|
69
74
|
await foreignKeysMigration.up(knex);
|
|
70
75
|
assert.deepEqual(await foreignKeys(knex), ALL_KEYS);
|
|
76
|
+
// The table resources declare exactly those keys.
|
|
77
|
+
const resources = [rewardedProviderConfigTableResource, rewardedRuleTableResource, rewardedUnlockReceiptTableResource, rewardedWatchSessionTableResource];
|
|
78
|
+
assert.deepEqual(await checkForeignKeys({ knex, resources, tables: TABLES }), { missing: [], undeclared: [] });
|
|
71
79
|
|
|
72
80
|
// Keys that already exist are left as they are.
|
|
73
81
|
await foreignKeysMigration.up(knex);
|