@jskit-ai/rewarded-core 0.2.55 → 0.2.56

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 CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ - A companion migration that Knex runs just before each table migration (`rewarded_*_initial-collation`; run `npm run db:migrate`): on MySQL and MariaDB it creates the table, where it does not exist yet, in the collation of the existing tables (`rewarded_provider_configs`, then `users`, then `auth_local_users`) rather than the database's default, and converts one recorded in another collation when no character can be lost. They change nothing where the tables match.
5
6
  - A gate check reads the one receipt that still unlocks the gate (a new server-only `unlockedAfter` receipt filter, `unlockedUntil > now`), and the latest receipt only when the rule has a cooldown, instead of the gate's 25 newest receipts. A gate unlocked before 25 newer receipts that have since expired stayed locked; it now unlocks.
6
7
  - 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.
7
8
  - `@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.
@@ -0,0 +1,19 @@
1
+ // Knex sorts this file just before rewarded_provider_configs_initial.cjs ("-" sorts before "."), so it runs first
2
+ // on every database that has not run it. It runs that released migration with each table it creates in the
3
+ // collation of rewarded_provider_configs, or of the next table listed that exists, instead of the database's
4
+ // default, and repairs a table that default left: see migrateInExistingCollation. The released migration then finds
5
+ // its tables in place.
6
+ const released = require("./rewarded_provider_configs_initial.cjs");
7
+
8
+ exports.up = async function up(knex) {
9
+ const { migrateInExistingCollation } = await import("@jskit-ai/database-runtime/server/tableCollationMigrations");
10
+ await migrateInExistingCollation(knex, {
11
+ migration: "rewarded_provider_configs_initial.cjs",
12
+ up: released.up,
13
+ tables: ["rewarded_provider_configs"],
14
+ referenceTables: ["rewarded_provider_configs", "users", "auth_local_users"]
15
+ });
16
+ };
17
+
18
+ // The released migration's down drops its tables.
19
+ exports.down = async function down() {};
@@ -0,0 +1,19 @@
1
+ // Knex sorts this file just before rewarded_rules_initial.cjs ("-" sorts before "."), so it runs first on every
2
+ // database that has not run it. It runs that released migration with each table it creates in the collation of
3
+ // rewarded_provider_configs, or of the next table listed that exists, instead of the database's default, and
4
+ // repairs a table that default left: see migrateInExistingCollation. The released migration then finds its tables
5
+ // in place.
6
+ const released = require("./rewarded_rules_initial.cjs");
7
+
8
+ exports.up = async function up(knex) {
9
+ const { migrateInExistingCollation } = await import("@jskit-ai/database-runtime/server/tableCollationMigrations");
10
+ await migrateInExistingCollation(knex, {
11
+ migration: "rewarded_rules_initial.cjs",
12
+ up: released.up,
13
+ tables: ["rewarded_rules"],
14
+ referenceTables: ["rewarded_provider_configs", "users", "auth_local_users"]
15
+ });
16
+ };
17
+
18
+ // The released migration's down drops its tables.
19
+ exports.down = async function down() {};
@@ -0,0 +1,19 @@
1
+ // Knex sorts this file just before rewarded_unlock_receipts_initial.cjs ("-" sorts before "."), so it runs first on
2
+ // every database that has not run it. It runs that released migration with each table it creates in the collation
3
+ // of rewarded_provider_configs, or of the next table listed that exists, instead of the database's default, and
4
+ // repairs a table that default left: see migrateInExistingCollation. The released migration then finds its tables
5
+ // in place.
6
+ const released = require("./rewarded_unlock_receipts_initial.cjs");
7
+
8
+ exports.up = async function up(knex) {
9
+ const { migrateInExistingCollation } = await import("@jskit-ai/database-runtime/server/tableCollationMigrations");
10
+ await migrateInExistingCollation(knex, {
11
+ migration: "rewarded_unlock_receipts_initial.cjs",
12
+ up: released.up,
13
+ tables: ["rewarded_unlock_receipts"],
14
+ referenceTables: ["rewarded_provider_configs", "users", "auth_local_users"]
15
+ });
16
+ };
17
+
18
+ // The released migration's down drops its tables.
19
+ exports.down = async function down() {};
@@ -0,0 +1,19 @@
1
+ // Knex sorts this file just before rewarded_watch_sessions_initial.cjs ("-" sorts before "."), so it runs first on
2
+ // every database that has not run it. It runs that released migration with each table it creates in the collation
3
+ // of rewarded_provider_configs, or of the next table listed that exists, instead of the database's default, and
4
+ // repairs a table that default left: see migrateInExistingCollation. The released migration then finds its tables
5
+ // in place.
6
+ const released = require("./rewarded_watch_sessions_initial.cjs");
7
+
8
+ exports.up = async function up(knex) {
9
+ const { migrateInExistingCollation } = await import("@jskit-ai/database-runtime/server/tableCollationMigrations");
10
+ await migrateInExistingCollation(knex, {
11
+ migration: "rewarded_watch_sessions_initial.cjs",
12
+ up: released.up,
13
+ tables: ["rewarded_watch_sessions"],
14
+ referenceTables: ["rewarded_provider_configs", "users", "auth_local_users"]
15
+ });
16
+ };
17
+
18
+ // The released migration's down drops its tables.
19
+ exports.down = async function down() {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/rewarded-core",
3
- "version": "0.2.55",
3
+ "version": "0.2.56",
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.45",
128
+ "@jskit-ai/crud-core": "0.2.46",
129
129
  "@jskit-ai/resource-core": "0.1.219",
130
130
  "@jskit-ai/resource-crud-core": "0.1.221",
131
- "@jskit-ai/users-core": "0.2.55",
132
- "@jskit-ai/workspaces-core": "0.2.55",
131
+ "@jskit-ai/users-core": "0.2.56",
132
+ "@jskit-ai/workspaces-core": "0.2.56",
133
133
  "json-rest-schema": "^1.0.20"
134
134
  },
135
135
  "peerDependencies": {
136
136
  "@jskit-ai/auth-core": "0.2.32",
137
- "@jskit-ai/database-runtime": "0.1.277",
137
+ "@jskit-ai/database-runtime": "0.1.278",
138
138
  "@jskit-ai/http-runtime": "0.2.28",
139
139
  "@jskit-ai/kernel": "0.2.28",
140
- "@jskit-ai/resource-runtime": "0.2.41"
140
+ "@jskit-ai/resource-runtime": "0.2.42"
141
141
  }
142
142
  }