@synnaxlabs/client 0.47.0 → 0.49.0
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/.turbo/turbo-build.log +7 -7
- package/dist/client.cjs +35 -35
- package/dist/client.js +6264 -5984
- package/dist/eslint.config.d.ts +3 -2
- package/dist/eslint.config.d.ts.map +1 -1
- package/dist/src/access/client.d.ts +3 -1
- package/dist/src/access/client.d.ts.map +1 -1
- package/dist/src/access/enforce.d.ts +35 -0
- package/dist/src/access/enforce.d.ts.map +1 -0
- package/dist/src/access/enforce.spec.d.ts +2 -0
- package/dist/src/access/enforce.spec.d.ts.map +1 -0
- package/dist/src/access/external.d.ts +3 -0
- package/dist/src/access/external.d.ts.map +1 -1
- package/dist/src/access/payload.d.ts +0 -6
- package/dist/src/access/payload.d.ts.map +1 -1
- package/dist/src/access/policy/access.spec.d.ts +2 -0
- package/dist/src/access/policy/access.spec.d.ts.map +1 -0
- package/dist/src/access/policy/client.d.ts +485 -31
- package/dist/src/access/policy/client.d.ts.map +1 -1
- package/dist/src/access/policy/payload.d.ts +36 -113
- package/dist/src/access/policy/payload.d.ts.map +1 -1
- package/dist/src/access/role/client.d.ts +135 -0
- package/dist/src/access/role/client.d.ts.map +1 -0
- package/dist/src/access/role/external.d.ts.map +1 -0
- package/dist/src/access/role/index.d.ts +2 -0
- package/dist/src/access/role/index.d.ts.map +1 -0
- package/dist/src/access/role/payload.d.ts +27 -0
- package/dist/src/access/role/payload.d.ts.map +1 -0
- package/dist/src/access/role/role.spec.d.ts +2 -0
- package/dist/src/access/role/role.spec.d.ts.map +1 -0
- package/dist/src/arc/access.spec.d.ts +2 -0
- package/dist/src/arc/access.spec.d.ts.map +1 -0
- package/dist/src/arc/client.d.ts +5 -14
- package/dist/src/arc/client.d.ts.map +1 -1
- package/dist/src/arc/payload.d.ts +11 -2
- package/dist/src/arc/payload.d.ts.map +1 -1
- package/dist/src/auth/auth.d.ts +5 -3
- package/dist/src/auth/auth.d.ts.map +1 -1
- package/dist/src/channel/access.spec.d.ts +2 -0
- package/dist/src/channel/access.spec.d.ts.map +1 -0
- package/dist/src/channel/client.d.ts +0 -1
- package/dist/src/channel/client.d.ts.map +1 -1
- package/dist/src/channel/payload.d.ts +19 -8
- package/dist/src/channel/payload.d.ts.map +1 -1
- package/dist/src/channel/payload.spec.d.ts +2 -0
- package/dist/src/channel/payload.spec.d.ts.map +1 -0
- package/dist/src/channel/retriever.d.ts +4 -6
- package/dist/src/channel/retriever.d.ts.map +1 -1
- package/dist/src/channel/writer.d.ts.map +1 -1
- package/dist/src/client.d.ts +18 -10
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/connection/checker.d.ts +2 -3
- package/dist/src/connection/checker.d.ts.map +1 -1
- package/dist/src/connection.spec.d.ts +2 -0
- package/dist/src/connection.spec.d.ts.map +1 -0
- package/dist/src/device/access.spec.d.ts +2 -0
- package/dist/src/device/access.spec.d.ts.map +1 -0
- package/dist/src/{hardware/device → device}/client.d.ts +14 -7
- package/dist/src/device/client.d.ts.map +1 -0
- package/dist/src/device/device.spec.d.ts.map +1 -0
- package/dist/src/device/external.d.ts.map +1 -0
- package/dist/src/device/index.d.ts.map +1 -0
- package/dist/src/{hardware/device → device}/payload.d.ts +1 -1
- package/dist/src/device/payload.d.ts.map +1 -0
- package/dist/src/errors.d.ts +3 -0
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/framer/adapter.d.ts +2 -2
- package/dist/src/framer/adapter.d.ts.map +1 -1
- package/dist/src/framer/client.d.ts +8 -1
- package/dist/src/framer/client.d.ts.map +1 -1
- package/dist/src/framer/frame.d.ts +11 -5
- package/dist/src/framer/frame.d.ts.map +1 -1
- package/dist/src/framer/iterator.d.ts +3 -3
- package/dist/src/framer/streamer.d.ts +24 -21
- package/dist/src/framer/streamer.d.ts.map +1 -1
- package/dist/src/framer/writer.d.ts +13 -13
- package/dist/src/index.d.ts +6 -7
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/label/access.spec.d.ts +2 -0
- package/dist/src/label/access.spec.d.ts.map +1 -0
- package/dist/src/label/client.d.ts +20 -11
- package/dist/src/label/client.d.ts.map +1 -1
- package/dist/src/ontology/client.d.ts +6 -6
- package/dist/src/ontology/client.d.ts.map +1 -1
- package/dist/src/ontology/group/access.spec.d.ts +2 -0
- package/dist/src/ontology/group/access.spec.d.ts.map +1 -0
- package/dist/src/ontology/group/client.d.ts +2 -2
- package/dist/src/ontology/group/client.d.ts.map +1 -1
- package/dist/src/ontology/group/payload.d.ts +1 -2
- package/dist/src/ontology/group/payload.d.ts.map +1 -1
- package/dist/src/ontology/payload.d.ts +23 -17
- package/dist/src/ontology/payload.d.ts.map +1 -1
- package/dist/src/ontology/writer.d.ts +10 -10
- package/dist/src/ontology/writer.d.ts.map +1 -1
- package/dist/src/rack/access.spec.d.ts +2 -0
- package/dist/src/rack/access.spec.d.ts.map +1 -0
- package/dist/src/{hardware/rack → rack}/client.d.ts +15 -8
- package/dist/src/rack/client.d.ts.map +1 -0
- package/dist/src/rack/external.d.ts.map +1 -0
- package/dist/src/rack/index.d.ts.map +1 -0
- package/dist/src/{hardware/rack → rack}/payload.d.ts +1 -1
- package/dist/src/rack/payload.d.ts.map +1 -0
- package/dist/src/rack/rack.spec.d.ts.map +1 -0
- package/dist/src/ranger/access.spec.d.ts +2 -0
- package/dist/src/ranger/access.spec.d.ts.map +1 -0
- package/dist/src/ranger/alias.d.ts +1 -8
- package/dist/src/ranger/alias.d.ts.map +1 -1
- package/dist/src/ranger/client.d.ts +12 -5
- package/dist/src/ranger/client.d.ts.map +1 -1
- package/dist/src/ranger/kv.d.ts +0 -3
- package/dist/src/ranger/kv.d.ts.map +1 -1
- package/dist/src/ranger/writer.d.ts +2 -2
- package/dist/src/ranger/writer.d.ts.map +1 -1
- package/dist/src/status/access.spec.d.ts +2 -0
- package/dist/src/status/access.spec.d.ts.map +1 -0
- package/dist/src/status/client.d.ts +4 -4
- package/dist/src/status/client.d.ts.map +1 -1
- package/dist/src/status/payload.d.ts +9 -2
- package/dist/src/status/payload.d.ts.map +1 -1
- package/dist/src/task/access.spec.d.ts +2 -0
- package/dist/src/task/access.spec.d.ts.map +1 -0
- package/dist/src/{hardware/task → task}/client.d.ts +26 -15
- package/dist/src/task/client.d.ts.map +1 -0
- package/dist/src/task/external.d.ts +3 -0
- package/dist/src/task/external.d.ts.map +1 -0
- package/dist/src/task/index.d.ts.map +1 -0
- package/dist/src/{hardware/task → task}/payload.d.ts +45 -6
- package/dist/src/task/payload.d.ts.map +1 -0
- package/dist/src/task/task.spec.d.ts.map +1 -0
- package/dist/src/testutil/access.d.ts +4 -0
- package/dist/src/testutil/access.d.ts.map +1 -0
- package/dist/src/testutil/client.d.ts +3 -3
- package/dist/src/testutil/client.d.ts.map +1 -1
- package/dist/src/transport.d.ts.map +1 -1
- package/dist/src/user/access.spec.d.ts +2 -0
- package/dist/src/user/access.spec.d.ts.map +1 -0
- package/dist/src/user/client.d.ts +10 -1
- package/dist/src/user/client.d.ts.map +1 -1
- package/dist/src/user/external.d.ts +1 -1
- package/dist/src/user/external.d.ts.map +1 -1
- package/dist/src/user/payload.d.ts.map +1 -1
- package/dist/src/workspace/access.spec.d.ts +2 -0
- package/dist/src/workspace/access.spec.d.ts.map +1 -0
- package/dist/src/workspace/client.d.ts +10 -5
- package/dist/src/workspace/client.d.ts.map +1 -1
- package/dist/src/workspace/lineplot/access.spec.d.ts +2 -0
- package/dist/src/workspace/lineplot/access.spec.d.ts.map +1 -0
- package/dist/src/workspace/lineplot/client.d.ts +8 -1
- package/dist/src/workspace/lineplot/client.d.ts.map +1 -1
- package/dist/src/workspace/log/access.spec.d.ts +2 -0
- package/dist/src/workspace/log/access.spec.d.ts.map +1 -0
- package/dist/src/workspace/log/client.d.ts +8 -1
- package/dist/src/workspace/log/client.d.ts.map +1 -1
- package/dist/src/workspace/schematic/access.spec.d.ts +2 -0
- package/dist/src/workspace/schematic/access.spec.d.ts.map +1 -0
- package/dist/src/workspace/schematic/client.d.ts +8 -1
- package/dist/src/workspace/schematic/client.d.ts.map +1 -1
- package/dist/src/workspace/schematic/symbol/access.spec.d.ts +2 -0
- package/dist/src/workspace/schematic/symbol/access.spec.d.ts.map +1 -0
- package/dist/src/workspace/schematic/symbol/client.d.ts +1 -5
- package/dist/src/workspace/schematic/symbol/client.d.ts.map +1 -1
- package/dist/src/workspace/schematic/symbol/payload.d.ts +2 -2
- package/dist/src/workspace/table/access.spec.d.ts +2 -0
- package/dist/src/workspace/table/access.spec.d.ts.map +1 -0
- package/dist/src/workspace/table/client.d.ts +8 -1
- package/dist/src/workspace/table/client.d.ts.map +1 -1
- package/eslint.config.ts +3 -1
- package/package.json +8 -8
- package/src/access/client.ts +5 -2
- package/src/access/enforce.spec.ts +189 -0
- package/src/access/enforce.ts +84 -0
- package/src/access/external.ts +3 -0
- package/src/access/payload.ts +1 -13
- package/src/access/policy/access.spec.ts +147 -0
- package/src/access/policy/client.ts +21 -25
- package/src/access/policy/payload.ts +9 -5
- package/src/access/role/client.ts +135 -0
- package/src/access/role/external.ts +11 -0
- package/src/{hardware → access/role}/index.ts +1 -1
- package/src/access/role/payload.ts +32 -0
- package/src/access/role/role.spec.ts +95 -0
- package/src/arc/access.spec.ts +143 -0
- package/src/arc/client.ts +7 -31
- package/src/arc/payload.ts +4 -0
- package/src/auth/auth.spec.ts +13 -13
- package/src/auth/auth.ts +33 -11
- package/src/channel/access.spec.ts +116 -0
- package/src/channel/channel.spec.ts +63 -73
- package/src/channel/client.ts +2 -8
- package/src/channel/payload.spec.ts +171 -0
- package/src/channel/payload.ts +37 -8
- package/src/channel/retriever.ts +10 -11
- package/src/channel/writer.ts +3 -7
- package/src/client.ts +38 -28
- package/src/connection/checker.ts +10 -10
- package/src/connection/connection.spec.ts +13 -13
- package/src/connection.spec.ts +145 -0
- package/src/device/access.spec.ts +159 -0
- package/src/{hardware/device → device}/client.ts +12 -21
- package/src/{hardware/device → device}/device.spec.ts +70 -34
- package/src/device/external.ts +11 -0
- package/src/{hardware/rack → device}/index.ts +1 -1
- package/src/{hardware/device → device}/payload.ts +3 -3
- package/src/errors.ts +2 -0
- package/src/framer/adapter.spec.ts +351 -13
- package/src/framer/adapter.ts +23 -13
- package/src/framer/client.spec.ts +14 -20
- package/src/framer/client.ts +3 -5
- package/src/framer/deleter.spec.ts +1 -1
- package/src/framer/frame.spec.ts +427 -0
- package/src/framer/frame.ts +30 -3
- package/src/framer/iterator.ts +4 -4
- package/src/framer/streamer.spec.ts +155 -10
- package/src/framer/streamer.ts +35 -12
- package/src/framer/writer.spec.ts +5 -5
- package/src/index.ts +13 -7
- package/src/label/access.spec.ts +109 -0
- package/src/label/client.ts +10 -14
- package/src/ontology/client.ts +4 -6
- package/src/ontology/group/access.spec.ts +77 -0
- package/src/ontology/group/client.ts +3 -7
- package/src/ontology/group/group.spec.ts +18 -0
- package/src/ontology/group/payload.ts +2 -2
- package/src/ontology/ontology.spec.ts +2 -0
- package/src/ontology/payload.ts +18 -2
- package/src/ontology/writer.ts +3 -7
- package/src/rack/access.spec.ts +102 -0
- package/src/{hardware/rack → rack}/client.ts +14 -19
- package/src/{hardware/device/index.ts → rack/external.ts} +2 -1
- package/src/{hardware/external.ts → rack/index.ts} +1 -1
- package/src/{hardware/rack → rack}/payload.ts +2 -2
- package/src/{hardware/rack → rack}/rack.spec.ts +43 -17
- package/src/ranger/access.spec.ts +115 -0
- package/src/ranger/alias.ts +6 -14
- package/src/ranger/client.ts +13 -14
- package/src/ranger/kv.ts +7 -9
- package/src/ranger/ranger.spec.ts +4 -4
- package/src/ranger/writer.ts +3 -7
- package/src/status/access.spec.ts +129 -0
- package/src/status/client.ts +5 -9
- package/src/status/payload.ts +3 -2
- package/src/task/access.spec.ts +131 -0
- package/src/{hardware/task → task}/client.ts +50 -25
- package/src/task/external.ts +11 -0
- package/src/{hardware/task → task}/index.ts +1 -1
- package/src/{hardware/task → task}/payload.ts +22 -3
- package/src/{hardware/task → task}/task.spec.ts +197 -34
- package/src/testutil/access.ts +34 -0
- package/src/testutil/channels.ts +3 -3
- package/src/testutil/client.ts +4 -4
- package/src/transport.ts +1 -3
- package/src/user/access.spec.ts +107 -0
- package/src/user/client.ts +10 -12
- package/src/user/external.ts +12 -1
- package/src/user/payload.ts +3 -5
- package/src/workspace/access.spec.ts +108 -0
- package/src/workspace/client.ts +11 -27
- package/src/workspace/lineplot/access.spec.ts +134 -0
- package/src/workspace/lineplot/client.ts +8 -13
- package/src/workspace/log/access.spec.ts +134 -0
- package/src/workspace/log/client.ts +8 -13
- package/src/workspace/schematic/access.spec.ts +134 -0
- package/src/workspace/schematic/client.ts +9 -18
- package/src/workspace/schematic/symbol/access.spec.ts +172 -0
- package/src/workspace/schematic/symbol/client.ts +6 -17
- package/src/workspace/schematic/symbol/payload.ts +1 -1
- package/src/workspace/table/access.spec.ts +134 -0
- package/src/workspace/table/client.ts +8 -13
- package/dist/src/access/policy/policy.spec.d.ts +0 -2
- package/dist/src/access/policy/policy.spec.d.ts.map +0 -1
- package/dist/src/hardware/client.d.ts +0 -10
- package/dist/src/hardware/client.d.ts.map +0 -1
- package/dist/src/hardware/device/client.d.ts.map +0 -1
- package/dist/src/hardware/device/device.spec.d.ts.map +0 -1
- package/dist/src/hardware/device/external.d.ts.map +0 -1
- package/dist/src/hardware/device/index.d.ts.map +0 -1
- package/dist/src/hardware/device/payload.d.ts.map +0 -1
- package/dist/src/hardware/external.d.ts +0 -2
- package/dist/src/hardware/external.d.ts.map +0 -1
- package/dist/src/hardware/index.d.ts +0 -2
- package/dist/src/hardware/index.d.ts.map +0 -1
- package/dist/src/hardware/rack/client.d.ts.map +0 -1
- package/dist/src/hardware/rack/external.d.ts.map +0 -1
- package/dist/src/hardware/rack/index.d.ts.map +0 -1
- package/dist/src/hardware/rack/payload.d.ts.map +0 -1
- package/dist/src/hardware/rack/rack.spec.d.ts.map +0 -1
- package/dist/src/hardware/task/client.d.ts.map +0 -1
- package/dist/src/hardware/task/external.d.ts.map +0 -1
- package/dist/src/hardware/task/index.d.ts.map +0 -1
- package/dist/src/hardware/task/payload.d.ts.map +0 -1
- package/dist/src/hardware/task/task.spec.d.ts.map +0 -1
- package/dist/src/user/retriever.d.ts +0 -16
- package/dist/src/user/retriever.d.ts.map +0 -1
- package/dist/src/user/writer.d.ts +0 -11
- package/dist/src/user/writer.d.ts.map +0 -1
- package/src/access/policy/policy.spec.ts +0 -329
- package/src/hardware/client.ts +0 -24
- package/src/hardware/device/external.ts +0 -11
- package/src/hardware/rack/external.ts +0 -11
- package/src/hardware/task/external.ts +0 -11
- package/src/user/retriever.ts +0 -41
- package/src/user/writer.ts +0 -84
- /package/dist/src/{hardware/device → access/role}/external.d.ts +0 -0
- /package/dist/src/{hardware/device → device}/device.spec.d.ts +0 -0
- /package/dist/src/{hardware/rack → device}/external.d.ts +0 -0
- /package/dist/src/{hardware/device → device}/index.d.ts +0 -0
- /package/dist/src/{hardware/task → rack}/external.d.ts +0 -0
- /package/dist/src/{hardware/rack → rack}/index.d.ts +0 -0
- /package/dist/src/{hardware/rack → rack}/rack.spec.d.ts +0 -0
- /package/dist/src/{hardware/task → task}/index.d.ts +0 -0
- /package/dist/src/{hardware/task → task}/task.spec.d.ts +0 -0
package/src/user/client.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { array } from "@synnaxlabs/x";
|
|
|
12
12
|
import { z } from "zod";
|
|
13
13
|
|
|
14
14
|
import { MultipleFoundError, NotFoundError } from "@/errors";
|
|
15
|
-
import {
|
|
15
|
+
import { ontology } from "@/ontology";
|
|
16
16
|
import { type Key, keyZ, type New, newZ, type User, userZ } from "@/user/payload";
|
|
17
17
|
|
|
18
18
|
const retrieveRequestZ = z.object({
|
|
@@ -68,11 +68,8 @@ const renameResZ = z.object({});
|
|
|
68
68
|
const deleteReqZ = z.object({ keys: keyZ.array() });
|
|
69
69
|
const deleteResZ = z.object({});
|
|
70
70
|
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
const CHANGE_USERNAME_ENDPOINT = "/user/change-username";
|
|
74
|
-
const RENAME_ENDPOINT = "/user/rename";
|
|
75
|
-
const DELETE_ENDPOINT = "/user/delete";
|
|
71
|
+
export const SET_CHANNEL_NAME = "sy_user_set";
|
|
72
|
+
export const DELETE_CHANNEL_NAME = "sy_user_delete";
|
|
76
73
|
|
|
77
74
|
export class Client {
|
|
78
75
|
private readonly client: UnaryClient;
|
|
@@ -87,7 +84,7 @@ export class Client {
|
|
|
87
84
|
const isMany = Array.isArray(users);
|
|
88
85
|
const res = await sendRequired<typeof createReqZ, typeof createResZ>(
|
|
89
86
|
this.client,
|
|
90
|
-
|
|
87
|
+
"/user/create",
|
|
91
88
|
{ users: array.toArray(users) },
|
|
92
89
|
createReqZ,
|
|
93
90
|
createResZ,
|
|
@@ -98,7 +95,7 @@ export class Client {
|
|
|
98
95
|
async changeUsername(key: Key, newUsername: string): Promise<void> {
|
|
99
96
|
await sendRequired<typeof changeUsernameReqZ, typeof changeUsernameResZ>(
|
|
100
97
|
this.client,
|
|
101
|
-
|
|
98
|
+
"/user/change-username",
|
|
102
99
|
{ key, username: newUsername },
|
|
103
100
|
changeUsernameReqZ,
|
|
104
101
|
changeUsernameResZ,
|
|
@@ -112,7 +109,7 @@ export class Client {
|
|
|
112
109
|
const isSingle = "key" in args || "username" in args;
|
|
113
110
|
const res = await sendRequired<typeof retrieveArgsZ, typeof retrieveResZ>(
|
|
114
111
|
this.client,
|
|
115
|
-
|
|
112
|
+
"/user/retrieve",
|
|
116
113
|
args,
|
|
117
114
|
retrieveArgsZ,
|
|
118
115
|
retrieveResZ,
|
|
@@ -136,7 +133,7 @@ export class Client {
|
|
|
136
133
|
async rename(key: Key, firstName?: string, lastName?: string): Promise<void> {
|
|
137
134
|
await sendRequired<typeof renameReqZ, typeof renameResZ>(
|
|
138
135
|
this.client,
|
|
139
|
-
|
|
136
|
+
"/user/rename",
|
|
140
137
|
{ key, firstName, lastName },
|
|
141
138
|
renameReqZ,
|
|
142
139
|
renameResZ,
|
|
@@ -148,7 +145,7 @@ export class Client {
|
|
|
148
145
|
async delete(keys: Key | Key[]): Promise<void> {
|
|
149
146
|
await sendRequired<typeof deleteReqZ, typeof deleteResZ>(
|
|
150
147
|
this.client,
|
|
151
|
-
|
|
148
|
+
"/user/delete",
|
|
152
149
|
{ keys: array.toArray(keys) },
|
|
153
150
|
deleteReqZ,
|
|
154
151
|
deleteResZ,
|
|
@@ -156,4 +153,5 @@ export class Client {
|
|
|
156
153
|
}
|
|
157
154
|
}
|
|
158
155
|
|
|
159
|
-
export const ontologyID =
|
|
156
|
+
export const ontologyID = ontology.createIDFactory<Key>("user");
|
|
157
|
+
export const TYPE_ONTOLOGY_ID = ontologyID("");
|
package/src/user/external.ts
CHANGED
|
@@ -7,5 +7,16 @@
|
|
|
7
7
|
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
8
|
// included in the file licenses/APL.txt.
|
|
9
9
|
|
|
10
|
-
export
|
|
10
|
+
export {
|
|
11
|
+
Client,
|
|
12
|
+
DELETE_CHANNEL_NAME,
|
|
13
|
+
type KeyRetrieveRequest,
|
|
14
|
+
ontologyID,
|
|
15
|
+
type RetrieveArgs,
|
|
16
|
+
type RetrieveRequest,
|
|
17
|
+
SET_CHANNEL_NAME,
|
|
18
|
+
TYPE_ONTOLOGY_ID,
|
|
19
|
+
type UsernameRetrieveRequest,
|
|
20
|
+
type UsernamesRetrieveRequest,
|
|
21
|
+
} from "@/user/client";
|
|
11
22
|
export * from "@/user/payload";
|
package/src/user/payload.ts
CHANGED
|
@@ -15,17 +15,15 @@ export type Key = z.infer<typeof keyZ>;
|
|
|
15
15
|
export const userZ = z.object({
|
|
16
16
|
key: keyZ,
|
|
17
17
|
username: z.string().min(1, "Username is required"),
|
|
18
|
-
// defaults for firstName, lastName, and rootUser are done to give compatibility with
|
|
19
|
-
// servers running v0.30.x and earlier. These defaults should be removed in a future
|
|
20
|
-
// release.
|
|
21
18
|
firstName: z.string().default(""),
|
|
22
19
|
lastName: z.string().default(""),
|
|
23
|
-
rootUser: z.boolean().default(
|
|
20
|
+
rootUser: z.boolean().default(false),
|
|
24
21
|
});
|
|
22
|
+
|
|
25
23
|
export interface User extends z.infer<typeof userZ> {}
|
|
26
24
|
|
|
27
25
|
export const newZ = userZ
|
|
28
|
-
.partial({ key: true, firstName: true, lastName: true })
|
|
29
26
|
.omit({ rootUser: true })
|
|
27
|
+
.partial({ key: true, firstName: true, lastName: true })
|
|
30
28
|
.extend({ password: z.string().min(1) });
|
|
31
29
|
export interface New extends z.infer<typeof newZ> {}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// Copyright 2025 Synnax Labs, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Use of this software is governed by the Business Source License included in the file
|
|
4
|
+
// licenses/BSL.txt.
|
|
5
|
+
//
|
|
6
|
+
// As of the Change Date specified in that file, in accordance with the Business Source
|
|
7
|
+
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
|
+
// included in the file licenses/APL.txt.
|
|
9
|
+
|
|
10
|
+
import { describe, expect, it } from "vitest";
|
|
11
|
+
|
|
12
|
+
import { AuthError, NotFoundError } from "@/errors";
|
|
13
|
+
import { createTestClientWithPolicy } from "@/testutil/access";
|
|
14
|
+
import { createTestClient } from "@/testutil/client";
|
|
15
|
+
import { workspace } from "@/workspace";
|
|
16
|
+
|
|
17
|
+
const client = createTestClient();
|
|
18
|
+
|
|
19
|
+
describe("workspace", () => {
|
|
20
|
+
describe("access control", () => {
|
|
21
|
+
it("should deny access when no retrieve policy exists", async () => {
|
|
22
|
+
const userClient = await createTestClientWithPolicy(client, {
|
|
23
|
+
name: "test",
|
|
24
|
+
objects: [],
|
|
25
|
+
actions: [],
|
|
26
|
+
});
|
|
27
|
+
const randomWorkspace = await client.workspaces.create({
|
|
28
|
+
name: "test",
|
|
29
|
+
layout: {},
|
|
30
|
+
});
|
|
31
|
+
await expect(userClient.workspaces.retrieve(randomWorkspace.key)).rejects.toThrow(
|
|
32
|
+
AuthError,
|
|
33
|
+
);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("should allow the caller to retrieve workspaces with the correct policy", async () => {
|
|
37
|
+
const userClient = await createTestClientWithPolicy(client, {
|
|
38
|
+
name: "test",
|
|
39
|
+
objects: [workspace.ontologyID("")],
|
|
40
|
+
actions: ["retrieve"],
|
|
41
|
+
});
|
|
42
|
+
const randomWorkspace = await client.workspaces.create({
|
|
43
|
+
name: "test",
|
|
44
|
+
layout: {},
|
|
45
|
+
});
|
|
46
|
+
const retrieved = await userClient.workspaces.retrieve(randomWorkspace.key);
|
|
47
|
+
expect(retrieved.key).toBe(randomWorkspace.key);
|
|
48
|
+
expect(retrieved.name).toBe(randomWorkspace.name);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("should allow the caller to create workspaces with the correct policy", async () => {
|
|
52
|
+
const userClient = await createTestClientWithPolicy(client, {
|
|
53
|
+
name: "test",
|
|
54
|
+
objects: [workspace.ontologyID("")],
|
|
55
|
+
actions: ["create"],
|
|
56
|
+
});
|
|
57
|
+
await userClient.workspaces.create({
|
|
58
|
+
name: "test",
|
|
59
|
+
layout: {},
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("should deny access when no create policy exists", async () => {
|
|
64
|
+
const userClient = await createTestClientWithPolicy(client, {
|
|
65
|
+
name: "test",
|
|
66
|
+
objects: [workspace.ontologyID("")],
|
|
67
|
+
actions: [],
|
|
68
|
+
});
|
|
69
|
+
await expect(
|
|
70
|
+
userClient.workspaces.create({
|
|
71
|
+
name: "test",
|
|
72
|
+
layout: {},
|
|
73
|
+
}),
|
|
74
|
+
).rejects.toThrow(AuthError);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("should allow the caller to delete workspaces with the correct policy", async () => {
|
|
78
|
+
const userClient = await createTestClientWithPolicy(client, {
|
|
79
|
+
name: "test",
|
|
80
|
+
objects: [workspace.ontologyID("")],
|
|
81
|
+
actions: ["delete"],
|
|
82
|
+
});
|
|
83
|
+
const randomWorkspace = await client.workspaces.create({
|
|
84
|
+
name: "test",
|
|
85
|
+
layout: {},
|
|
86
|
+
});
|
|
87
|
+
await userClient.workspaces.delete(randomWorkspace.key);
|
|
88
|
+
await expect(userClient.workspaces.retrieve(randomWorkspace.key)).rejects.toThrow(
|
|
89
|
+
NotFoundError,
|
|
90
|
+
);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("should deny access when no delete policy exists", async () => {
|
|
94
|
+
const userClient = await createTestClientWithPolicy(client, {
|
|
95
|
+
name: "test",
|
|
96
|
+
objects: [workspace.ontologyID("")],
|
|
97
|
+
actions: [],
|
|
98
|
+
});
|
|
99
|
+
const randomWorkspace = await client.workspaces.create({
|
|
100
|
+
name: "test",
|
|
101
|
+
layout: {},
|
|
102
|
+
});
|
|
103
|
+
await expect(userClient.workspaces.delete(randomWorkspace.key)).rejects.toThrow(
|
|
104
|
+
AuthError,
|
|
105
|
+
);
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
});
|
package/src/workspace/client.ts
CHANGED
|
@@ -11,8 +11,8 @@ import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
|
|
|
11
11
|
import { array, record } from "@synnaxlabs/x";
|
|
12
12
|
import { z } from "zod";
|
|
13
13
|
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
14
|
+
import { ontology } from "@/ontology";
|
|
15
|
+
import { keyZ as userKeyZ } from "@/user/payload";
|
|
16
16
|
import { lineplot } from "@/workspace/lineplot";
|
|
17
17
|
import { log } from "@/workspace/log";
|
|
18
18
|
import {
|
|
@@ -28,18 +28,12 @@ import {
|
|
|
28
28
|
import { schematic } from "@/workspace/schematic";
|
|
29
29
|
import { table } from "@/workspace/table";
|
|
30
30
|
|
|
31
|
-
const RETRIEVE_ENDPOINT = "/workspace/retrieve";
|
|
32
|
-
const CREATE_ENDPOINT = "/workspace/create";
|
|
33
|
-
const RENAME_ENDPOINT = "/workspace/rename";
|
|
34
|
-
const SET_LAYOUT_ENDPOINT = "/workspace/set-layout";
|
|
35
|
-
const DELETE_ENDPOINT = "/workspace/delete";
|
|
36
|
-
|
|
37
31
|
const retrieveReqZ = z.object({
|
|
38
32
|
keys: keyZ.array().optional(),
|
|
39
33
|
searchTerm: z.string().optional(),
|
|
40
34
|
author: userKeyZ.optional(),
|
|
41
|
-
offset: z.
|
|
42
|
-
limit: z.
|
|
35
|
+
offset: z.int().optional(),
|
|
36
|
+
limit: z.int().optional(),
|
|
43
37
|
});
|
|
44
38
|
export interface RetrieveRequest extends z.infer<typeof retrieveReqZ> {}
|
|
45
39
|
const createReqZ = z.object({ workspaces: newZ.array() });
|
|
@@ -80,7 +74,7 @@ export class Client {
|
|
|
80
74
|
const isMany = Array.isArray(workspaces);
|
|
81
75
|
const res = await sendRequired(
|
|
82
76
|
this.client,
|
|
83
|
-
|
|
77
|
+
"/workspace/create",
|
|
84
78
|
{ workspaces: array.toArray(workspaces) },
|
|
85
79
|
createReqZ,
|
|
86
80
|
createResZ,
|
|
@@ -91,7 +85,7 @@ export class Client {
|
|
|
91
85
|
async rename(key: Key, name: string): Promise<void> {
|
|
92
86
|
await sendRequired(
|
|
93
87
|
this.client,
|
|
94
|
-
|
|
88
|
+
"/workspace/rename",
|
|
95
89
|
{ key, name },
|
|
96
90
|
renameReqZ,
|
|
97
91
|
emptyResZ,
|
|
@@ -101,7 +95,7 @@ export class Client {
|
|
|
101
95
|
async setLayout(key: Key, layout: record.Unknown): Promise<void> {
|
|
102
96
|
await sendRequired(
|
|
103
97
|
this.client,
|
|
104
|
-
|
|
98
|
+
"/workspace/set-layout",
|
|
105
99
|
{ key, layout },
|
|
106
100
|
setLayoutReqZ,
|
|
107
101
|
emptyResZ,
|
|
@@ -119,7 +113,7 @@ export class Client {
|
|
|
119
113
|
else req = keys;
|
|
120
114
|
const res = await sendRequired(
|
|
121
115
|
this.client,
|
|
122
|
-
|
|
116
|
+
"/workspace/retrieve",
|
|
123
117
|
req,
|
|
124
118
|
retrieveReqZ,
|
|
125
119
|
retrieveResZ,
|
|
@@ -127,23 +121,12 @@ export class Client {
|
|
|
127
121
|
return isMany ? res.workspaces : res.workspaces[0];
|
|
128
122
|
}
|
|
129
123
|
|
|
130
|
-
async retrieveByAuthor(author: UserKey): Promise<Workspace[]> {
|
|
131
|
-
const res = await sendRequired(
|
|
132
|
-
this.client,
|
|
133
|
-
RETRIEVE_ENDPOINT,
|
|
134
|
-
{ author },
|
|
135
|
-
retrieveReqZ,
|
|
136
|
-
retrieveResZ,
|
|
137
|
-
);
|
|
138
|
-
return res.workspaces;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
124
|
async delete(key: Key): Promise<void>;
|
|
142
125
|
async delete(keys: Key[]): Promise<void>;
|
|
143
126
|
async delete(keys: Params): Promise<void> {
|
|
144
127
|
await sendRequired(
|
|
145
128
|
this.client,
|
|
146
|
-
|
|
129
|
+
"/workspace/delete",
|
|
147
130
|
{ keys: array.toArray(keys) },
|
|
148
131
|
deleteReqZ,
|
|
149
132
|
emptyResZ,
|
|
@@ -151,4 +134,5 @@ export class Client {
|
|
|
151
134
|
}
|
|
152
135
|
}
|
|
153
136
|
|
|
154
|
-
export const ontologyID =
|
|
137
|
+
export const ontologyID = ontology.createIDFactory<Key>("workspace");
|
|
138
|
+
export const TYPE_ONTOLOGY_ID = ontologyID("");
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// Copyright 2025 Synnax Labs, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Use of this software is governed by the Business Source License included in the file
|
|
4
|
+
// licenses/BSL.txt.
|
|
5
|
+
//
|
|
6
|
+
// As of the Change Date specified in that file, in accordance with the Business Source
|
|
7
|
+
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
|
+
// included in the file licenses/APL.txt.
|
|
9
|
+
|
|
10
|
+
import { describe, expect, it } from "vitest";
|
|
11
|
+
|
|
12
|
+
import { AuthError, NotFoundError } from "@/errors";
|
|
13
|
+
import { createTestClientWithPolicy } from "@/testutil/access";
|
|
14
|
+
import { createTestClient } from "@/testutil/client";
|
|
15
|
+
import { lineplot } from "@/workspace/lineplot";
|
|
16
|
+
|
|
17
|
+
const client = createTestClient();
|
|
18
|
+
|
|
19
|
+
describe("lineplot", () => {
|
|
20
|
+
describe("access control", () => {
|
|
21
|
+
it("should deny access when no retrieve policy exists", async () => {
|
|
22
|
+
const userClient = await createTestClientWithPolicy(client, {
|
|
23
|
+
name: "test",
|
|
24
|
+
objects: [],
|
|
25
|
+
actions: [],
|
|
26
|
+
});
|
|
27
|
+
const ws = await client.workspaces.create({
|
|
28
|
+
name: "test",
|
|
29
|
+
layout: {},
|
|
30
|
+
});
|
|
31
|
+
const randomLinePlot = await client.workspaces.lineplots.create(ws.key, {
|
|
32
|
+
name: "test",
|
|
33
|
+
data: {},
|
|
34
|
+
});
|
|
35
|
+
await expect(
|
|
36
|
+
userClient.workspaces.lineplots.retrieve({ key: randomLinePlot.key }),
|
|
37
|
+
).rejects.toThrow(AuthError);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("should allow the caller to retrieve lineplots with the correct policy", async () => {
|
|
41
|
+
const userClient = await createTestClientWithPolicy(client, {
|
|
42
|
+
name: "test",
|
|
43
|
+
objects: [lineplot.ontologyID("")],
|
|
44
|
+
actions: ["retrieve"],
|
|
45
|
+
});
|
|
46
|
+
const ws = await client.workspaces.create({
|
|
47
|
+
name: "test",
|
|
48
|
+
layout: {},
|
|
49
|
+
});
|
|
50
|
+
const randomLinePlot = await client.workspaces.lineplots.create(ws.key, {
|
|
51
|
+
name: "test",
|
|
52
|
+
data: {},
|
|
53
|
+
});
|
|
54
|
+
const retrieved = await userClient.workspaces.lineplots.retrieve({
|
|
55
|
+
key: randomLinePlot.key,
|
|
56
|
+
});
|
|
57
|
+
expect(retrieved.key).toBe(randomLinePlot.key);
|
|
58
|
+
expect(retrieved.name).toBe(randomLinePlot.name);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("should allow the caller to create lineplots with the correct policy", async () => {
|
|
62
|
+
const userClient = await createTestClientWithPolicy(client, {
|
|
63
|
+
name: "test",
|
|
64
|
+
objects: [lineplot.ontologyID("")],
|
|
65
|
+
actions: ["create"],
|
|
66
|
+
});
|
|
67
|
+
const ws = await client.workspaces.create({
|
|
68
|
+
name: "test",
|
|
69
|
+
layout: {},
|
|
70
|
+
});
|
|
71
|
+
await userClient.workspaces.lineplots.create(ws.key, {
|
|
72
|
+
name: "test",
|
|
73
|
+
data: {},
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("should deny access when no create policy exists", async () => {
|
|
78
|
+
const userClient = await createTestClientWithPolicy(client, {
|
|
79
|
+
name: "test",
|
|
80
|
+
objects: [lineplot.ontologyID("")],
|
|
81
|
+
actions: [],
|
|
82
|
+
});
|
|
83
|
+
const ws = await client.workspaces.create({
|
|
84
|
+
name: "test",
|
|
85
|
+
layout: {},
|
|
86
|
+
});
|
|
87
|
+
await expect(
|
|
88
|
+
userClient.workspaces.lineplots.create(ws.key, {
|
|
89
|
+
name: "test",
|
|
90
|
+
data: {},
|
|
91
|
+
}),
|
|
92
|
+
).rejects.toThrow(AuthError);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("should allow the caller to delete lineplots with the correct policy", async () => {
|
|
96
|
+
const userClient = await createTestClientWithPolicy(client, {
|
|
97
|
+
name: "test",
|
|
98
|
+
objects: [lineplot.ontologyID("")],
|
|
99
|
+
actions: ["delete", "retrieve"],
|
|
100
|
+
});
|
|
101
|
+
const ws = await client.workspaces.create({
|
|
102
|
+
name: "test",
|
|
103
|
+
layout: {},
|
|
104
|
+
});
|
|
105
|
+
const randomLinePlot = await client.workspaces.lineplots.create(ws.key, {
|
|
106
|
+
name: "test",
|
|
107
|
+
data: {},
|
|
108
|
+
});
|
|
109
|
+
await userClient.workspaces.lineplots.delete(randomLinePlot.key);
|
|
110
|
+
await expect(
|
|
111
|
+
userClient.workspaces.lineplots.retrieve({ key: randomLinePlot.key }),
|
|
112
|
+
).rejects.toThrow(NotFoundError);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it("should deny access when no delete policy exists", async () => {
|
|
116
|
+
const userClient = await createTestClientWithPolicy(client, {
|
|
117
|
+
name: "test",
|
|
118
|
+
objects: [lineplot.ontologyID("")],
|
|
119
|
+
actions: [],
|
|
120
|
+
});
|
|
121
|
+
const ws = await client.workspaces.create({
|
|
122
|
+
name: "test",
|
|
123
|
+
layout: {},
|
|
124
|
+
});
|
|
125
|
+
const randomLinePlot = await client.workspaces.lineplots.create(ws.key, {
|
|
126
|
+
name: "test",
|
|
127
|
+
data: {},
|
|
128
|
+
});
|
|
129
|
+
await expect(
|
|
130
|
+
userClient.workspaces.lineplots.delete(randomLinePlot.key),
|
|
131
|
+
).rejects.toThrow(AuthError);
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
});
|
|
@@ -11,7 +11,7 @@ import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
|
|
|
11
11
|
import { array, type record } from "@synnaxlabs/x";
|
|
12
12
|
import { z } from "zod";
|
|
13
13
|
|
|
14
|
-
import {
|
|
14
|
+
import { ontology } from "@/ontology";
|
|
15
15
|
import { checkForMultipleOrNoResults } from "@/util/retrieve";
|
|
16
16
|
import {
|
|
17
17
|
type Key,
|
|
@@ -24,12 +24,6 @@ import {
|
|
|
24
24
|
} from "@/workspace/lineplot/payload";
|
|
25
25
|
import { type Key as WorkspaceKey, keyZ as workspaceKeyZ } from "@/workspace/payload";
|
|
26
26
|
|
|
27
|
-
const RETRIEVE_ENDPOINT = "/workspace/lineplot/retrieve";
|
|
28
|
-
const CREATE_ENDPOINT = "/workspace/lineplot/create";
|
|
29
|
-
const RENAME_ENDPOINT = "/workspace/lineplot/rename";
|
|
30
|
-
const SET_DATA_ENDPOINT = "/workspace/lineplot/set-data";
|
|
31
|
-
const DELETE_ENDPOINT = "/workspace/lineplot/delete";
|
|
32
|
-
|
|
33
27
|
const renameReqZ = z.object({ key: keyZ, name: z.string() });
|
|
34
28
|
|
|
35
29
|
const setDataReqZ = z.object({ key: keyZ, data: z.string() });
|
|
@@ -68,7 +62,7 @@ export class Client {
|
|
|
68
62
|
const isMany = Array.isArray(linePlots);
|
|
69
63
|
const res = await sendRequired(
|
|
70
64
|
this.client,
|
|
71
|
-
|
|
65
|
+
"/workspace/lineplot/create",
|
|
72
66
|
{ workspace, linePlots: array.toArray(linePlots) },
|
|
73
67
|
createReqZ,
|
|
74
68
|
createResZ,
|
|
@@ -79,7 +73,7 @@ export class Client {
|
|
|
79
73
|
async rename(key: Key, name: string): Promise<void> {
|
|
80
74
|
await sendRequired(
|
|
81
75
|
this.client,
|
|
82
|
-
|
|
76
|
+
"/workspace/lineplot/rename",
|
|
83
77
|
{ key, name },
|
|
84
78
|
renameReqZ,
|
|
85
79
|
emptyResZ,
|
|
@@ -89,7 +83,7 @@ export class Client {
|
|
|
89
83
|
async setData(key: Key, data: record.Unknown): Promise<void> {
|
|
90
84
|
await sendRequired(
|
|
91
85
|
this.client,
|
|
92
|
-
|
|
86
|
+
"/workspace/lineplot/set-data",
|
|
93
87
|
{ key, data: JSON.stringify(data) },
|
|
94
88
|
setDataReqZ,
|
|
95
89
|
emptyResZ,
|
|
@@ -104,7 +98,7 @@ export class Client {
|
|
|
104
98
|
const isSingle = singleRetrieveArgsZ.safeParse(args).success;
|
|
105
99
|
const res = await sendRequired(
|
|
106
100
|
this.client,
|
|
107
|
-
|
|
101
|
+
"/workspace/lineplot/retrieve",
|
|
108
102
|
args,
|
|
109
103
|
retrieveArgsZ,
|
|
110
104
|
retrieveResZ,
|
|
@@ -116,7 +110,7 @@ export class Client {
|
|
|
116
110
|
async delete(keys: Params): Promise<void> {
|
|
117
111
|
await sendRequired(
|
|
118
112
|
this.client,
|
|
119
|
-
|
|
113
|
+
"/workspace/lineplot/delete",
|
|
120
114
|
{ keys: array.toArray(keys) },
|
|
121
115
|
deleteReqZ,
|
|
122
116
|
emptyResZ,
|
|
@@ -124,4 +118,5 @@ export class Client {
|
|
|
124
118
|
}
|
|
125
119
|
}
|
|
126
120
|
|
|
127
|
-
export const ontologyID =
|
|
121
|
+
export const ontologyID = ontology.createIDFactory<Key>("lineplot");
|
|
122
|
+
export const TYPE_ONTOLOGY_ID = ontologyID("");
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// Copyright 2025 Synnax Labs, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Use of this software is governed by the Business Source License included in the file
|
|
4
|
+
// licenses/BSL.txt.
|
|
5
|
+
//
|
|
6
|
+
// As of the Change Date specified in that file, in accordance with the Business Source
|
|
7
|
+
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
|
+
// included in the file licenses/APL.txt.
|
|
9
|
+
|
|
10
|
+
import { describe, expect, it } from "vitest";
|
|
11
|
+
|
|
12
|
+
import { AuthError, NotFoundError } from "@/errors";
|
|
13
|
+
import { createTestClientWithPolicy } from "@/testutil/access";
|
|
14
|
+
import { createTestClient } from "@/testutil/client";
|
|
15
|
+
import { log } from "@/workspace/log";
|
|
16
|
+
|
|
17
|
+
const client = createTestClient();
|
|
18
|
+
|
|
19
|
+
describe("log", () => {
|
|
20
|
+
describe("access control", () => {
|
|
21
|
+
it("should deny access when no retrieve policy exists", async () => {
|
|
22
|
+
const userClient = await createTestClientWithPolicy(client, {
|
|
23
|
+
name: "test",
|
|
24
|
+
objects: [],
|
|
25
|
+
actions: [],
|
|
26
|
+
});
|
|
27
|
+
const ws = await client.workspaces.create({
|
|
28
|
+
name: "test",
|
|
29
|
+
layout: {},
|
|
30
|
+
});
|
|
31
|
+
const randomLog = await client.workspaces.logs.create(ws.key, {
|
|
32
|
+
name: "test",
|
|
33
|
+
data: {},
|
|
34
|
+
});
|
|
35
|
+
await expect(
|
|
36
|
+
userClient.workspaces.logs.retrieve({ key: randomLog.key }),
|
|
37
|
+
).rejects.toThrow(AuthError);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("should allow the caller to retrieve logs with the correct policy", async () => {
|
|
41
|
+
const userClient = await createTestClientWithPolicy(client, {
|
|
42
|
+
name: "test",
|
|
43
|
+
objects: [log.ontologyID("")],
|
|
44
|
+
actions: ["retrieve"],
|
|
45
|
+
});
|
|
46
|
+
const ws = await client.workspaces.create({
|
|
47
|
+
name: "test",
|
|
48
|
+
layout: {},
|
|
49
|
+
});
|
|
50
|
+
const randomLog = await client.workspaces.logs.create(ws.key, {
|
|
51
|
+
name: "test",
|
|
52
|
+
data: {},
|
|
53
|
+
});
|
|
54
|
+
const retrieved = await userClient.workspaces.logs.retrieve({
|
|
55
|
+
key: randomLog.key,
|
|
56
|
+
});
|
|
57
|
+
expect(retrieved.key).toBe(randomLog.key);
|
|
58
|
+
expect(retrieved.name).toBe(randomLog.name);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("should allow the caller to create logs with the correct policy", async () => {
|
|
62
|
+
const userClient = await createTestClientWithPolicy(client, {
|
|
63
|
+
name: "test",
|
|
64
|
+
objects: [log.ontologyID("")],
|
|
65
|
+
actions: ["create"],
|
|
66
|
+
});
|
|
67
|
+
const ws = await client.workspaces.create({
|
|
68
|
+
name: "test",
|
|
69
|
+
layout: {},
|
|
70
|
+
});
|
|
71
|
+
await userClient.workspaces.logs.create(ws.key, {
|
|
72
|
+
name: "test",
|
|
73
|
+
data: {},
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("should deny access when no create policy exists", async () => {
|
|
78
|
+
const userClient = await createTestClientWithPolicy(client, {
|
|
79
|
+
name: "test",
|
|
80
|
+
objects: [log.ontologyID("")],
|
|
81
|
+
actions: [],
|
|
82
|
+
});
|
|
83
|
+
const ws = await client.workspaces.create({
|
|
84
|
+
name: "test",
|
|
85
|
+
layout: {},
|
|
86
|
+
});
|
|
87
|
+
await expect(
|
|
88
|
+
userClient.workspaces.logs.create(ws.key, {
|
|
89
|
+
name: "test",
|
|
90
|
+
data: {},
|
|
91
|
+
}),
|
|
92
|
+
).rejects.toThrow(AuthError);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("should allow the caller to delete logs with the correct policy", async () => {
|
|
96
|
+
const userClient = await createTestClientWithPolicy(client, {
|
|
97
|
+
name: "test",
|
|
98
|
+
objects: [log.ontologyID("")],
|
|
99
|
+
actions: ["delete", "retrieve"],
|
|
100
|
+
});
|
|
101
|
+
const ws = await client.workspaces.create({
|
|
102
|
+
name: "test",
|
|
103
|
+
layout: {},
|
|
104
|
+
});
|
|
105
|
+
const randomLog = await client.workspaces.logs.create(ws.key, {
|
|
106
|
+
name: "test",
|
|
107
|
+
data: {},
|
|
108
|
+
});
|
|
109
|
+
await userClient.workspaces.logs.delete(randomLog.key);
|
|
110
|
+
await expect(
|
|
111
|
+
userClient.workspaces.logs.retrieve({ key: randomLog.key }),
|
|
112
|
+
).rejects.toThrow(NotFoundError);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it("should deny access when no delete policy exists", async () => {
|
|
116
|
+
const userClient = await createTestClientWithPolicy(client, {
|
|
117
|
+
name: "test",
|
|
118
|
+
objects: [log.ontologyID("")],
|
|
119
|
+
actions: [],
|
|
120
|
+
});
|
|
121
|
+
const ws = await client.workspaces.create({
|
|
122
|
+
name: "test",
|
|
123
|
+
layout: {},
|
|
124
|
+
});
|
|
125
|
+
const randomLog = await client.workspaces.logs.create(ws.key, {
|
|
126
|
+
name: "test",
|
|
127
|
+
data: {},
|
|
128
|
+
});
|
|
129
|
+
await expect(userClient.workspaces.logs.delete(randomLog.key)).rejects.toThrow(
|
|
130
|
+
AuthError,
|
|
131
|
+
);
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
});
|