@jskit-ai/workspaces-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
|
+
- `workspaces_core_initial-collation`, a migration Knex runs just before `workspaces_core_initial` (run `npm run db:migrate`): on MySQL and MariaDB it creates the workspace tables, where they do not exist yet, in the collation of the existing tables (`workspaces`, 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. It changes nothing where they match.
|
|
5
6
|
- `workspaces.transferOwnership({ workspaceId, toUserId, previousOwnerRoleSid = "admin" }, options)` hands a workspace to another of its active members, in the caller's transaction when `options` carries one and in one of its own otherwise. It locks the workspace's row and reads the workspace through that lock, then locks the new and the previous owner's memberships in one locking read, so two transfers of one workspace take turns and the second moves it on from the owner the first left. `owner_user_id` becomes `toUserId` and `updatedAt` moves; the new owner's membership takes the `owner` role; the previous owner's takes `previousOwnerRoleSid` and stays active, or is created active with it when they had none. A personal workspace stops being personal (`is_personal` false): the new owner's own personal workspace stays theirs, and where personal workspaces are provisioned the previous owner is given a new one at their next provisioning. A `toUserId` who already owns it writes nothing and answers `changed: false`. A missing or deleted workspace is 404 `workspaces.workspace.notFound` and a `toUserId` with no active membership 409 `workspaces.member.newOwnerNotActive` (new, "The new owner must be an active member of the workspace."), with nothing written; ids that are no record ids and a `previousOwnerRoleSid` that is not the text of a role other than `owner` are a TypeError before any statement. It answers the workspace as `findById` answers it, plus `previousOwnerUserId` and `changed`, sends the same statements however many members the workspace has, and publishes no event: an application keeping its own copy of workspace facts updates it from the answer.
|
|
6
7
|
- `createStandaloneRoleContext({ resources, config })` (`@jskit-ai/workspaces-core/server/standaloneRoleContext`) gives code outside a JSKIT server, such as a migration or seed script that owns its tables through `createStandaloneResources`, `workspaces.core`'s `roleContext`: the same function, built by the same code (`createWorkspaceDirectory`, which `createWorkspacesRuntime` now uses too) from the application's runtime config, on the handles of the script's standalone runtime, which owns `ROLE_CONTEXT_TABLES` (the workspaces and users tables, exported beside it) with its own tables: `createStandaloneResources({ knex, feature, owns: [...ROLE_CONTEXT_TABLES, ...seedTables], systemScope })`. It takes the same arguments, answers the same context and refuses the same calls, with the script's own system context; resources that lack one of those tables are a `TypeError` naming them. On a server's Knex client `createStandaloneResources` refuses those tables (`DuplicateOwnerError`): code there takes `workspaces.core`'s.
|
|
7
8
|
- **Breaking:** a provided `workspaces.invite-mailer` sends as `APP_ENV` says (`createAppEnvironmentInviteMailer`, replacing the simulated mailer): production sends each invitation; staging sends it only to `STAGING_EMAIL_TO`, its message marked with the address it was for; development, test and staging without `STAGING_EMAIL_TO` log it and answer `status: "simulated"` (`workspaces.invite.simulated`, "Outside production the invitation email was logged, not sent. Copy the invite link to share it."). A role grant no action requires refuses to start in development and test and is logged in staging and production, by `APP_ENV`, not `NODE_ENV`.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Knex sorts this file just before workspaces_core_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
|
+
// workspaces, or of the next table listed that exists, instead of the database's default, and repairs a table that
|
|
4
|
+
// default left: see migrateInExistingCollation. The released migration then finds its tables in place.
|
|
5
|
+
const released = require("./workspaces_core_initial.cjs");
|
|
6
|
+
|
|
7
|
+
exports.up = async function up(knex) {
|
|
8
|
+
const { migrateInExistingCollation } = await import("@jskit-ai/database-runtime/server/tableCollationMigrations");
|
|
9
|
+
await migrateInExistingCollation(knex, {
|
|
10
|
+
migration: "workspaces_core_initial.cjs",
|
|
11
|
+
up: released.up,
|
|
12
|
+
tables: ["workspaces", "workspace_memberships", "workspace_settings", "workspace_invites"],
|
|
13
|
+
referenceTables: ["workspaces", "users", "auth_local_users"]
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// The released migration's down drops its tables.
|
|
18
|
+
exports.down = async function down() {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jskit-ai/workspaces-core",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.56",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "jskit test"
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@jskit-ai/resource-core": "0.1.219",
|
|
28
28
|
"@jskit-ai/resource-crud-core": "0.1.221",
|
|
29
|
-
"@jskit-ai/users-core": "0.2.
|
|
29
|
+
"@jskit-ai/users-core": "0.2.56",
|
|
30
30
|
"json-rest-schema": "^1.0.20"
|
|
31
31
|
},
|
|
32
32
|
"description": "Workspace tenancy runtime plus HTTP routes, role catalog, and workspace config scaffolding.",
|
|
@@ -217,9 +217,9 @@
|
|
|
217
217
|
},
|
|
218
218
|
"peerDependencies": {
|
|
219
219
|
"@jskit-ai/auth-core": "0.2.32",
|
|
220
|
-
"@jskit-ai/database-runtime": "0.1.
|
|
220
|
+
"@jskit-ai/database-runtime": "0.1.278",
|
|
221
221
|
"@jskit-ai/http-runtime": "0.2.28",
|
|
222
222
|
"@jskit-ai/kernel": "0.2.28",
|
|
223
|
-
"@jskit-ai/resource-runtime": "0.2.
|
|
223
|
+
"@jskit-ai/resource-runtime": "0.2.42"
|
|
224
224
|
}
|
|
225
225
|
}
|