@jskit-ai/workspaces-core 0.2.36 → 0.2.38
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
|
+
- An invitation's response carries whatever delivery status its invite mailer answers, such as `held` for an email the application keeps until its email is set up. The create-invite output's `inviteDelivery.status` and the invite assistant tool's `deliveryStatus` allowed only `sent`, `simulated`, `failed` and `mailer_unconfigured`, so an invitation the assistant made through a mailer answering another status was saved and then failed with "Assistant tool output validation failed.", and the API contract did not describe the status it sent. Both are now any non-empty string. `WorkspaceInviteMailer`'s documentation names the statuses the members panel words itself and says it shows the result's `message` for any other.
|
|
5
6
|
- `GET .../members` and `GET .../invites` (`workspace.members.list` and `workspace.invites.list`) answer a request that leaves out `page[cursor]` or `page[limit]` again, such as every first page the members screen reads (`page[limit]=20`). Since 0.2.25 those answered 400 `ACTION_VALIDATION_FAILED`, "Value could not be cast to the required type." at `/data/attributes/cursor` (and at `/data/attributes/limit` when no limit was named), so the members screen showed no members and no invitations in any workspace. The routes handed their action `cursor` and `limit` by name, undefined when the query left one out, and an action's input refuses a field that is present but undefined; they now hand on only the fields the query sends. A route test reads both lists, first and next pages, through Fastify, the auth policy, the list actions and the JSON:API transport and serializer.
|
|
6
7
|
|
|
7
8
|
- A workspace route whose auth policy and action context differ in requiring membership (`contextPolicy: "optional"` on a route with `visibility: "workspace"`) reads its workspace context once per request instead of twice. The per-request cache keyed its reads by the membership requirement as well as the user and slug, so the two callers read the workspace, the membership and the settings each. Reads are now cached per user and slug, and each caller checks membership against the shared result: 401 `workspaces.auth.required` signed out, 403 `workspaces.workspace.accessDenied` for a non-member where membership is required, as before.
|
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.38",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "jskit test"
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@jskit-ai/resource-core": "0.1.213",
|
|
27
27
|
"@jskit-ai/resource-crud-core": "0.1.215",
|
|
28
|
-
"@jskit-ai/users-core": "0.2.
|
|
28
|
+
"@jskit-ai/users-core": "0.2.38",
|
|
29
29
|
"json-rest-schema": "^1.0.20"
|
|
30
30
|
},
|
|
31
31
|
"description": "Workspace tenancy runtime plus HTTP routes, role catalog, and workspace config scaffolding.",
|
|
@@ -211,7 +211,7 @@
|
|
|
211
211
|
}
|
|
212
212
|
},
|
|
213
213
|
"peerDependencies": {
|
|
214
|
-
"@jskit-ai/auth-core": "0.2.
|
|
214
|
+
"@jskit-ai/auth-core": "0.2.23",
|
|
215
215
|
"@jskit-ai/database-runtime": "0.1.271",
|
|
216
216
|
"@jskit-ai/http-runtime": "0.2.22",
|
|
217
217
|
"@jskit-ai/kernel": "0.2.22",
|
package/src/server/types.js
CHANGED
|
@@ -32,7 +32,11 @@
|
|
|
32
32
|
* The `workspaces.invite-mailer` capability: a feature that provides it sends
|
|
33
33
|
* workspace invitation email. It is told which saved invitation it sends
|
|
34
34
|
* (`inviteId`, its `workspace_invites` row, in `workspace.id`'s workspace).
|
|
35
|
-
* Its result is the delivery outcome; the status defaults to "sent".
|
|
35
|
+
* Its result is the delivery outcome; the status defaults to "sent". The
|
|
36
|
+
* members panel words its own notice for `sent`, `simulated` (a test copy),
|
|
37
|
+
* `held` (an email the mailer keeps until the application's email is set up,
|
|
38
|
+
* and sends then) and `failed`; for any other status it shows the result's
|
|
39
|
+
* `message` (translated by `messageCode` when given), else a neutral notice.
|
|
36
40
|
* @typedef {object} WorkspaceInviteMailer
|
|
37
41
|
* @property {(message: { inviteId: string, email: string, inviteUrl: string, workspace: { id: string, slug: string, name: string, ownerUserId: string, avatarUrl: string }, inviter: object | null, roleSid: string, expiresAt: string, locale: string, message: object }, options?: object) => Promise<{ status?: string, message?: string, messageCode?: string, messageParams?: object, providerMessageId?: string } | void>} sendWorkspaceInvite
|
|
38
42
|
*/
|
|
@@ -14,7 +14,7 @@ const workspaceInviteAssistantOutput = createSchemaDefinition(createSchema({
|
|
|
14
14
|
expiresAt: { type: "string", required: true }
|
|
15
15
|
})
|
|
16
16
|
},
|
|
17
|
-
deliveryStatus: { type: "string", required: true,
|
|
17
|
+
deliveryStatus: { type: "string", required: true, minLength: 1 }
|
|
18
18
|
}), "replace");
|
|
19
19
|
|
|
20
20
|
const pendingInvitationsAssistantOutput = createSchemaDefinition(createSchema({
|
|
@@ -117,10 +117,12 @@ const workspaceInviteCreateOutputSchema = createSchema({
|
|
|
117
117
|
type: "object",
|
|
118
118
|
required: true,
|
|
119
119
|
schema: createSchema({
|
|
120
|
+
// The invite mailer's own status: the members panel words sent, simulated, mailer_unconfigured, held and failed
|
|
121
|
+
// itself, and shows the message of any other.
|
|
120
122
|
status: {
|
|
121
123
|
type: "string",
|
|
122
124
|
required: true,
|
|
123
|
-
|
|
125
|
+
minLength: 1
|
|
124
126
|
},
|
|
125
127
|
message: {
|
|
126
128
|
type: "string",
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import test from "node:test";
|
|
2
2
|
import assert from "node:assert/strict";
|
|
3
|
-
import { resolveSchemaTransportSchemaDefinition } from "@jskit-ai/kernel/shared/validators";
|
|
3
|
+
import { resolveSchemaTransportSchemaDefinition, validateSchemaPayload } from "@jskit-ai/kernel/shared/validators";
|
|
4
|
+
import { workspaceInviteAssistantOutput } from "../src/shared/resources/workspaceAssistantOutputs.js";
|
|
4
5
|
import { workspaceMembersContract } from "../src/shared/resources/workspaceMembersResource.js";
|
|
6
|
+
import { createWorkspaceRoleCatalog } from "../src/shared/roles.js";
|
|
5
7
|
|
|
6
8
|
function resolveOutputSchema(operationName) {
|
|
7
9
|
return resolveSchemaTransportSchemaDefinition(workspaceMembersContract.operations[operationName].output, {
|
|
@@ -33,11 +35,41 @@ test("workspace members invite mutation outputs expose their tracking ids explic
|
|
|
33
35
|
const inviteDeliverySchemaName = createOutputSchema.properties.inviteDelivery.allOf[0].$ref.replace(/^#\/definitions\//, "");
|
|
34
36
|
const inviteDeliverySchema = createOutputSchema.definitions[inviteDeliverySchemaName];
|
|
35
37
|
assert.deepEqual(inviteDeliverySchema.required, ["status", "message", "providerMessageId"]);
|
|
38
|
+
// Any status the invite mailer answers, not only the ones the members panel words itself.
|
|
36
39
|
assert.deepEqual(
|
|
37
|
-
inviteDeliverySchema.properties.status.enum,
|
|
38
|
-
["
|
|
40
|
+
[inviteDeliverySchema.properties.status.type, inviteDeliverySchema.properties.status.minLength, inviteDeliverySchema.properties.status.enum],
|
|
41
|
+
["string", 1, undefined]
|
|
39
42
|
);
|
|
40
43
|
assert.equal(revokeOutputSchema.properties.revokedInviteId.type, "string");
|
|
41
44
|
assert.equal(revokeOutputSchema.properties.roleCatalog["x-json-rest-schema"]?.castType, "object");
|
|
42
45
|
assert.equal(Array.isArray(revokeOutputSchema.properties.roleCatalog.allOf), true);
|
|
43
46
|
});
|
|
47
|
+
|
|
48
|
+
// Before, both outputs allowed only sent, simulated, failed and mailer_unconfigured: an invitation the assistant made
|
|
49
|
+
// whose mailer answered `held` (or a status of its own) was saved and then failed, "Assistant tool output validation
|
|
50
|
+
// failed.", and the API's contract did not describe the status it sent.
|
|
51
|
+
test("an invitation's response carries any delivery status its mailer answers, with the mailer's message", () => {
|
|
52
|
+
const created = (inviteDelivery) => validateSchemaPayload(workspaceMembersContract.operations.createInvite.output, {
|
|
53
|
+
workspace: { id: "7", slug: "acme", name: "Acme", ownerUserId: "9", avatarUrl: "" },
|
|
54
|
+
invites: [],
|
|
55
|
+
roleCatalog: createWorkspaceRoleCatalog({}),
|
|
56
|
+
inviteTokenPreview: "token",
|
|
57
|
+
inviteUrl: "/invite/token",
|
|
58
|
+
inviteDelivery: { message: "", providerMessageId: "", ...inviteDelivery },
|
|
59
|
+
createdInviteId: "88"
|
|
60
|
+
}, { phase: "output" });
|
|
61
|
+
const told = (deliveryStatus) => validateSchemaPayload(workspaceInviteAssistantOutput, {
|
|
62
|
+
createdInviteId: "88",
|
|
63
|
+
invites: [],
|
|
64
|
+
deliveryStatus
|
|
65
|
+
}, { phase: "output" });
|
|
66
|
+
|
|
67
|
+
for (const status of ["sent", "held", "queued"]) {
|
|
68
|
+
assert.equal(created({ status }).inviteDelivery.status, status);
|
|
69
|
+
assert.equal(told(status).deliveryStatus, status);
|
|
70
|
+
}
|
|
71
|
+
assert.equal(created({ status: "queued", message: "Invite queued: it goes out within the hour." }).inviteDelivery.message,
|
|
72
|
+
"Invite queued: it goes out within the hour.");
|
|
73
|
+
assert.throws(() => created({ status: "" }), /Schema validation failed\./u);
|
|
74
|
+
assert.throws(() => told(""), /Schema validation failed\./u);
|
|
75
|
+
});
|