weave-typescript 0.38.0 → 0.40.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/dist/weaveapi/consolidation/v1/consolidation.pb.d.ts +1 -0
- package/dist/weaveapi/consolidation/v1/consolidation.pb.js +6 -0
- package/dist/weaveapi/ingestion/v1/ingestion.pb.d.ts +92 -0
- package/dist/weaveapi/ingestion/v1/ingestion.pb.js +1512 -127
- package/dist/weaveapi/ingestion/v1/service.pb.d.ts +71 -1
- package/dist/weaveapi/ingestion/v1/service.pb.js +407 -0
- package/dist/weaveapi/retrieval/v1/retrieval.pb.d.ts +3 -1
- package/dist/weaveapi/retrieval/v1/retrieval.pb.js +62 -16
- package/dist/weavesql/weavedb/consolidation_sql.d.ts +2 -2
- package/dist/weavesql/weavedb/consolidation_sql.js +15 -5
- package/dist/weavesql/weavedb/document_security_sql.d.ts +197 -46
- package/dist/weavesql/weavedb/document_security_sql.js +432 -134
- package/dist/weavesql/weavedb/ingestion_sql.d.ts +9 -18
- package/dist/weavesql/weavedb/ingestion_sql.js +124 -101
- package/dist/weavesql/weavedb/retrieval_sql.d.ts +6 -7
- package/dist/weavesql/weavedb/retrieval_sql.js +136 -51
- package/package.json +2 -2
|
@@ -1,21 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.listDocumentIDsByRestrictedGroupQuery = exports.addDocumentRestrictedGroupsForDocumentsQuery = exports.addDocumentRestrictedGroupQuery = exports.deleteDocumentRestrictedGroupsByGroupQuery = exports.deleteDocumentRestrictedGroupsQuery = exports.listDocumentRestrictedGroupsByDocumentIDsQuery = exports.listDocumentRestrictedGroupsQuery = exports.addRestrictedGroupTeamMembershipQuery = exports.deleteRestrictedGroupTeamMembershipsQuery = exports.listRestrictedGroupTeamMembershipsQuery = exports.addRestrictedGroupUserMembershipQuery = exports.deleteRestrictedGroupUserMembershipsQuery = exports.listRestrictedGroupUserMembershipsQuery = exports.countRestrictedGroupTeamsQuery = exports.countRestrictedGroupUsersQuery = exports.countRestrictedGroupDocumentsQuery = exports.deleteRestrictedGroupQuery = exports.updateRestrictedGroupQuery = exports.upsertRestrictedGroupQuery = exports.getRestrictedGroupBySlugQuery = exports.getRestrictedGroupQuery = exports.listRestrictedGroupsQuery = exports.setDocumentSecurityQuery = void 0;
|
|
4
4
|
exports.setDocumentSecurity = setDocumentSecurity;
|
|
5
|
-
exports.
|
|
6
|
-
exports.
|
|
7
|
-
exports.
|
|
8
|
-
exports.
|
|
9
|
-
exports.
|
|
10
|
-
exports.
|
|
5
|
+
exports.listRestrictedGroups = listRestrictedGroups;
|
|
6
|
+
exports.getRestrictedGroup = getRestrictedGroup;
|
|
7
|
+
exports.getRestrictedGroupBySlug = getRestrictedGroupBySlug;
|
|
8
|
+
exports.upsertRestrictedGroup = upsertRestrictedGroup;
|
|
9
|
+
exports.updateRestrictedGroup = updateRestrictedGroup;
|
|
10
|
+
exports.countRestrictedGroupDocuments = countRestrictedGroupDocuments;
|
|
11
|
+
exports.countRestrictedGroupUsers = countRestrictedGroupUsers;
|
|
12
|
+
exports.countRestrictedGroupTeams = countRestrictedGroupTeams;
|
|
13
|
+
exports.listRestrictedGroupUserMemberships = listRestrictedGroupUserMemberships;
|
|
14
|
+
exports.addRestrictedGroupUserMembership = addRestrictedGroupUserMembership;
|
|
15
|
+
exports.listRestrictedGroupTeamMemberships = listRestrictedGroupTeamMemberships;
|
|
16
|
+
exports.addRestrictedGroupTeamMembership = addRestrictedGroupTeamMembership;
|
|
17
|
+
exports.listDocumentRestrictedGroups = listDocumentRestrictedGroups;
|
|
18
|
+
exports.listDocumentRestrictedGroupsByDocumentIDs = listDocumentRestrictedGroupsByDocumentIDs;
|
|
19
|
+
exports.addDocumentRestrictedGroup = addDocumentRestrictedGroup;
|
|
20
|
+
exports.listDocumentIDsByRestrictedGroup = listDocumentIDsByRestrictedGroup;
|
|
11
21
|
exports.setDocumentSecurityQuery = `-- name: SetDocumentSecurity :one
|
|
12
22
|
UPDATE weave.documents
|
|
13
23
|
SET
|
|
14
24
|
scope = $1,
|
|
15
|
-
sensitivity_tags = $2,
|
|
16
25
|
updated_at = now()
|
|
17
|
-
WHERE organization_id = $
|
|
18
|
-
AND id = $
|
|
26
|
+
WHERE organization_id = $2
|
|
27
|
+
AND id = $3
|
|
19
28
|
RETURNING
|
|
20
29
|
id,
|
|
21
30
|
organization_id,
|
|
@@ -26,7 +35,6 @@ RETURNING
|
|
|
26
35
|
storage_ref,
|
|
27
36
|
status,
|
|
28
37
|
scope,
|
|
29
|
-
sensitivity_tags,
|
|
30
38
|
uploaded_by_user_id,
|
|
31
39
|
uploaded_at,
|
|
32
40
|
updated_at,
|
|
@@ -36,7 +44,7 @@ RETURNING
|
|
|
36
44
|
async function setDocumentSecurity(client, args) {
|
|
37
45
|
const result = await client.query({
|
|
38
46
|
text: exports.setDocumentSecurityQuery,
|
|
39
|
-
values: [args.scope, args.
|
|
47
|
+
values: [args.scope, args.organizationId, args.documentId],
|
|
40
48
|
rowMode: "array"
|
|
41
49
|
});
|
|
42
50
|
if (result.rows.length !== 1) {
|
|
@@ -53,22 +61,121 @@ async function setDocumentSecurity(client, args) {
|
|
|
53
61
|
storageRef: row[6],
|
|
54
62
|
status: row[7],
|
|
55
63
|
scope: row[8],
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
metadata: row[15]
|
|
64
|
+
uploadedByUserId: row[9],
|
|
65
|
+
uploadedAt: row[10],
|
|
66
|
+
updatedAt: row[11],
|
|
67
|
+
pageCount: row[12],
|
|
68
|
+
charCount: row[13],
|
|
69
|
+
metadata: row[14]
|
|
63
70
|
};
|
|
64
71
|
}
|
|
65
|
-
exports.
|
|
66
|
-
|
|
72
|
+
exports.listRestrictedGroupsQuery = `-- name: ListRestrictedGroups :many
|
|
73
|
+
SELECT
|
|
74
|
+
id,
|
|
67
75
|
organization_id,
|
|
68
76
|
slug,
|
|
69
|
-
|
|
77
|
+
name,
|
|
78
|
+
description,
|
|
79
|
+
active,
|
|
80
|
+
created_at,
|
|
81
|
+
updated_at
|
|
82
|
+
FROM weave.restricted_groups
|
|
83
|
+
WHERE organization_id = $1
|
|
84
|
+
ORDER BY name ASC, slug ASC`;
|
|
85
|
+
async function listRestrictedGroups(client, args) {
|
|
86
|
+
const result = await client.query({
|
|
87
|
+
text: exports.listRestrictedGroupsQuery,
|
|
88
|
+
values: [args.organizationId],
|
|
89
|
+
rowMode: "array"
|
|
90
|
+
});
|
|
91
|
+
return result.rows.map(row => {
|
|
92
|
+
return {
|
|
93
|
+
id: row[0],
|
|
94
|
+
organizationId: row[1],
|
|
95
|
+
slug: row[2],
|
|
96
|
+
name: row[3],
|
|
97
|
+
description: row[4],
|
|
98
|
+
active: row[5],
|
|
99
|
+
createdAt: row[6],
|
|
100
|
+
updatedAt: row[7]
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
exports.getRestrictedGroupQuery = `-- name: GetRestrictedGroup :one
|
|
105
|
+
SELECT
|
|
106
|
+
id,
|
|
107
|
+
organization_id,
|
|
108
|
+
slug,
|
|
109
|
+
name,
|
|
110
|
+
description,
|
|
111
|
+
active,
|
|
112
|
+
created_at,
|
|
113
|
+
updated_at
|
|
114
|
+
FROM weave.restricted_groups
|
|
115
|
+
WHERE organization_id = $1
|
|
116
|
+
AND id = $2`;
|
|
117
|
+
async function getRestrictedGroup(client, args) {
|
|
118
|
+
const result = await client.query({
|
|
119
|
+
text: exports.getRestrictedGroupQuery,
|
|
120
|
+
values: [args.organizationId, args.restrictedGroupId],
|
|
121
|
+
rowMode: "array"
|
|
122
|
+
});
|
|
123
|
+
if (result.rows.length !== 1) {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
const row = result.rows[0];
|
|
127
|
+
return {
|
|
128
|
+
id: row[0],
|
|
129
|
+
organizationId: row[1],
|
|
130
|
+
slug: row[2],
|
|
131
|
+
name: row[3],
|
|
132
|
+
description: row[4],
|
|
133
|
+
active: row[5],
|
|
134
|
+
createdAt: row[6],
|
|
135
|
+
updatedAt: row[7]
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
exports.getRestrictedGroupBySlugQuery = `-- name: GetRestrictedGroupBySlug :one
|
|
139
|
+
SELECT
|
|
140
|
+
id,
|
|
141
|
+
organization_id,
|
|
142
|
+
slug,
|
|
143
|
+
name,
|
|
144
|
+
description,
|
|
145
|
+
active,
|
|
146
|
+
created_at,
|
|
147
|
+
updated_at
|
|
148
|
+
FROM weave.restricted_groups
|
|
149
|
+
WHERE organization_id = $1
|
|
150
|
+
AND slug = $2`;
|
|
151
|
+
async function getRestrictedGroupBySlug(client, args) {
|
|
152
|
+
const result = await client.query({
|
|
153
|
+
text: exports.getRestrictedGroupBySlugQuery,
|
|
154
|
+
values: [args.organizationId, args.slug],
|
|
155
|
+
rowMode: "array"
|
|
156
|
+
});
|
|
157
|
+
if (result.rows.length !== 1) {
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
const row = result.rows[0];
|
|
161
|
+
return {
|
|
162
|
+
id: row[0],
|
|
163
|
+
organizationId: row[1],
|
|
164
|
+
slug: row[2],
|
|
165
|
+
name: row[3],
|
|
166
|
+
description: row[4],
|
|
167
|
+
active: row[5],
|
|
168
|
+
createdAt: row[6],
|
|
169
|
+
updatedAt: row[7]
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
exports.upsertRestrictedGroupQuery = `-- name: UpsertRestrictedGroup :one
|
|
173
|
+
INSERT INTO weave.restricted_groups (
|
|
174
|
+
id,
|
|
175
|
+
organization_id,
|
|
176
|
+
slug,
|
|
177
|
+
name,
|
|
70
178
|
description,
|
|
71
|
-
extraction_hint,
|
|
72
179
|
active
|
|
73
180
|
) VALUES (
|
|
74
181
|
$1,
|
|
@@ -80,24 +187,23 @@ INSERT INTO weave.org_sensitivity_tags (
|
|
|
80
187
|
)
|
|
81
188
|
ON CONFLICT (organization_id, slug) DO UPDATE
|
|
82
189
|
SET
|
|
83
|
-
|
|
190
|
+
name = EXCLUDED.name,
|
|
84
191
|
description = EXCLUDED.description,
|
|
85
|
-
extraction_hint = EXCLUDED.extraction_hint,
|
|
86
192
|
active = EXCLUDED.active,
|
|
87
193
|
updated_at = now()
|
|
88
194
|
RETURNING
|
|
195
|
+
id,
|
|
89
196
|
organization_id,
|
|
90
197
|
slug,
|
|
91
|
-
|
|
198
|
+
name,
|
|
92
199
|
description,
|
|
93
|
-
extraction_hint,
|
|
94
200
|
active,
|
|
95
201
|
created_at,
|
|
96
202
|
updated_at`;
|
|
97
|
-
async function
|
|
203
|
+
async function upsertRestrictedGroup(client, args) {
|
|
98
204
|
const result = await client.query({
|
|
99
|
-
text: exports.
|
|
100
|
-
values: [args.
|
|
205
|
+
text: exports.upsertRestrictedGroupQuery,
|
|
206
|
+
values: [args.id, args.organizationId, args.slug, args.name, args.description, args.active],
|
|
101
207
|
rowMode: "array"
|
|
102
208
|
});
|
|
103
209
|
if (result.rows.length !== 1) {
|
|
@@ -105,101 +211,220 @@ async function upsertOrganizationSensitivityTag(client, args) {
|
|
|
105
211
|
}
|
|
106
212
|
const row = result.rows[0];
|
|
107
213
|
return {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
214
|
+
id: row[0],
|
|
215
|
+
organizationId: row[1],
|
|
216
|
+
slug: row[2],
|
|
217
|
+
name: row[3],
|
|
218
|
+
description: row[4],
|
|
113
219
|
active: row[5],
|
|
114
220
|
createdAt: row[6],
|
|
115
221
|
updatedAt: row[7]
|
|
116
222
|
};
|
|
117
223
|
}
|
|
118
|
-
exports.
|
|
119
|
-
|
|
224
|
+
exports.updateRestrictedGroupQuery = `-- name: UpdateRestrictedGroup :one
|
|
225
|
+
UPDATE weave.restricted_groups
|
|
226
|
+
SET
|
|
227
|
+
slug = $1,
|
|
228
|
+
name = $2,
|
|
229
|
+
description = $3,
|
|
230
|
+
active = $4,
|
|
231
|
+
updated_at = now()
|
|
232
|
+
WHERE organization_id = $5
|
|
233
|
+
AND id = $6
|
|
234
|
+
RETURNING
|
|
235
|
+
id,
|
|
120
236
|
organization_id,
|
|
121
237
|
slug,
|
|
122
|
-
|
|
238
|
+
name,
|
|
123
239
|
description,
|
|
124
|
-
extraction_hint,
|
|
125
240
|
active,
|
|
126
241
|
created_at,
|
|
127
|
-
updated_at
|
|
128
|
-
|
|
242
|
+
updated_at`;
|
|
243
|
+
async function updateRestrictedGroup(client, args) {
|
|
244
|
+
const result = await client.query({
|
|
245
|
+
text: exports.updateRestrictedGroupQuery,
|
|
246
|
+
values: [args.slug, args.name, args.description, args.active, args.organizationId, args.restrictedGroupId],
|
|
247
|
+
rowMode: "array"
|
|
248
|
+
});
|
|
249
|
+
if (result.rows.length !== 1) {
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
const row = result.rows[0];
|
|
253
|
+
return {
|
|
254
|
+
id: row[0],
|
|
255
|
+
organizationId: row[1],
|
|
256
|
+
slug: row[2],
|
|
257
|
+
name: row[3],
|
|
258
|
+
description: row[4],
|
|
259
|
+
active: row[5],
|
|
260
|
+
createdAt: row[6],
|
|
261
|
+
updatedAt: row[7]
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
exports.deleteRestrictedGroupQuery = `-- name: DeleteRestrictedGroup :execrows
|
|
265
|
+
DELETE FROM weave.restricted_groups
|
|
266
|
+
WHERE organization_id = $1
|
|
267
|
+
AND id = $2`;
|
|
268
|
+
exports.countRestrictedGroupDocumentsQuery = `-- name: CountRestrictedGroupDocuments :one
|
|
269
|
+
SELECT COUNT(DISTINCT document_id)::int AS document_count
|
|
270
|
+
FROM weave.document_restricted_groups
|
|
129
271
|
WHERE organization_id = $1
|
|
130
|
-
|
|
131
|
-
async function
|
|
272
|
+
AND restricted_group_id = $2`;
|
|
273
|
+
async function countRestrictedGroupDocuments(client, args) {
|
|
132
274
|
const result = await client.query({
|
|
133
|
-
text: exports.
|
|
134
|
-
values: [args.organizationId],
|
|
275
|
+
text: exports.countRestrictedGroupDocumentsQuery,
|
|
276
|
+
values: [args.organizationId, args.restrictedGroupId],
|
|
277
|
+
rowMode: "array"
|
|
278
|
+
});
|
|
279
|
+
if (result.rows.length !== 1) {
|
|
280
|
+
return null;
|
|
281
|
+
}
|
|
282
|
+
const row = result.rows[0];
|
|
283
|
+
return {
|
|
284
|
+
documentCount: row[0]
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
exports.countRestrictedGroupUsersQuery = `-- name: CountRestrictedGroupUsers :one
|
|
288
|
+
SELECT COUNT(*)::int AS user_count
|
|
289
|
+
FROM weave.restricted_group_user_memberships
|
|
290
|
+
WHERE organization_id = $1
|
|
291
|
+
AND restricted_group_id = $2`;
|
|
292
|
+
async function countRestrictedGroupUsers(client, args) {
|
|
293
|
+
const result = await client.query({
|
|
294
|
+
text: exports.countRestrictedGroupUsersQuery,
|
|
295
|
+
values: [args.organizationId, args.restrictedGroupId],
|
|
296
|
+
rowMode: "array"
|
|
297
|
+
});
|
|
298
|
+
if (result.rows.length !== 1) {
|
|
299
|
+
return null;
|
|
300
|
+
}
|
|
301
|
+
const row = result.rows[0];
|
|
302
|
+
return {
|
|
303
|
+
userCount: row[0]
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
exports.countRestrictedGroupTeamsQuery = `-- name: CountRestrictedGroupTeams :one
|
|
307
|
+
SELECT COUNT(*)::int AS team_count
|
|
308
|
+
FROM weave.restricted_group_team_memberships
|
|
309
|
+
WHERE organization_id = $1
|
|
310
|
+
AND restricted_group_id = $2`;
|
|
311
|
+
async function countRestrictedGroupTeams(client, args) {
|
|
312
|
+
const result = await client.query({
|
|
313
|
+
text: exports.countRestrictedGroupTeamsQuery,
|
|
314
|
+
values: [args.organizationId, args.restrictedGroupId],
|
|
315
|
+
rowMode: "array"
|
|
316
|
+
});
|
|
317
|
+
if (result.rows.length !== 1) {
|
|
318
|
+
return null;
|
|
319
|
+
}
|
|
320
|
+
const row = result.rows[0];
|
|
321
|
+
return {
|
|
322
|
+
teamCount: row[0]
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
exports.listRestrictedGroupUserMembershipsQuery = `-- name: ListRestrictedGroupUserMemberships :many
|
|
326
|
+
SELECT
|
|
327
|
+
organization_id,
|
|
328
|
+
restricted_group_id,
|
|
329
|
+
user_id,
|
|
330
|
+
created_at
|
|
331
|
+
FROM weave.restricted_group_user_memberships
|
|
332
|
+
WHERE organization_id = $1
|
|
333
|
+
AND restricted_group_id = $2
|
|
334
|
+
ORDER BY created_at ASC, user_id ASC`;
|
|
335
|
+
async function listRestrictedGroupUserMemberships(client, args) {
|
|
336
|
+
const result = await client.query({
|
|
337
|
+
text: exports.listRestrictedGroupUserMembershipsQuery,
|
|
338
|
+
values: [args.organizationId, args.restrictedGroupId],
|
|
135
339
|
rowMode: "array"
|
|
136
340
|
});
|
|
137
341
|
return result.rows.map(row => {
|
|
138
342
|
return {
|
|
139
343
|
organizationId: row[0],
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
extractionHint: row[4],
|
|
144
|
-
active: row[5],
|
|
145
|
-
createdAt: row[6],
|
|
146
|
-
updatedAt: row[7]
|
|
344
|
+
restrictedGroupId: row[1],
|
|
345
|
+
userId: row[2],
|
|
346
|
+
createdAt: row[3]
|
|
147
347
|
};
|
|
148
348
|
});
|
|
149
349
|
}
|
|
150
|
-
exports.
|
|
350
|
+
exports.deleteRestrictedGroupUserMembershipsQuery = `-- name: DeleteRestrictedGroupUserMemberships :execrows
|
|
351
|
+
DELETE FROM weave.restricted_group_user_memberships
|
|
352
|
+
WHERE organization_id = $1
|
|
353
|
+
AND restricted_group_id = $2`;
|
|
354
|
+
exports.addRestrictedGroupUserMembershipQuery = `-- name: AddRestrictedGroupUserMembership :one
|
|
355
|
+
INSERT INTO weave.restricted_group_user_memberships (
|
|
356
|
+
organization_id,
|
|
357
|
+
restricted_group_id,
|
|
358
|
+
user_id
|
|
359
|
+
) VALUES (
|
|
360
|
+
$1,
|
|
361
|
+
$2,
|
|
362
|
+
$3
|
|
363
|
+
)
|
|
364
|
+
ON CONFLICT DO NOTHING
|
|
365
|
+
RETURNING organization_id, restricted_group_id, user_id, created_at`;
|
|
366
|
+
async function addRestrictedGroupUserMembership(client, args) {
|
|
367
|
+
const result = await client.query({
|
|
368
|
+
text: exports.addRestrictedGroupUserMembershipQuery,
|
|
369
|
+
values: [args.organizationId, args.restrictedGroupId, args.userId],
|
|
370
|
+
rowMode: "array"
|
|
371
|
+
});
|
|
372
|
+
if (result.rows.length !== 1) {
|
|
373
|
+
return null;
|
|
374
|
+
}
|
|
375
|
+
const row = result.rows[0];
|
|
376
|
+
return {
|
|
377
|
+
organizationId: row[0],
|
|
378
|
+
restrictedGroupId: row[1],
|
|
379
|
+
userId: row[2],
|
|
380
|
+
createdAt: row[3]
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
exports.listRestrictedGroupTeamMembershipsQuery = `-- name: ListRestrictedGroupTeamMemberships :many
|
|
151
384
|
SELECT
|
|
152
385
|
organization_id,
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
active,
|
|
158
|
-
created_at,
|
|
159
|
-
updated_at
|
|
160
|
-
FROM weave.org_sensitivity_tags
|
|
386
|
+
restricted_group_id,
|
|
387
|
+
org_team_id,
|
|
388
|
+
created_at
|
|
389
|
+
FROM weave.restricted_group_team_memberships
|
|
161
390
|
WHERE organization_id = $1
|
|
162
|
-
AND
|
|
163
|
-
ORDER BY
|
|
164
|
-
async function
|
|
391
|
+
AND restricted_group_id = $2
|
|
392
|
+
ORDER BY created_at ASC, org_team_id ASC`;
|
|
393
|
+
async function listRestrictedGroupTeamMemberships(client, args) {
|
|
165
394
|
const result = await client.query({
|
|
166
|
-
text: exports.
|
|
167
|
-
values: [args.organizationId],
|
|
395
|
+
text: exports.listRestrictedGroupTeamMembershipsQuery,
|
|
396
|
+
values: [args.organizationId, args.restrictedGroupId],
|
|
168
397
|
rowMode: "array"
|
|
169
398
|
});
|
|
170
399
|
return result.rows.map(row => {
|
|
171
400
|
return {
|
|
172
401
|
organizationId: row[0],
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
extractionHint: row[4],
|
|
177
|
-
active: row[5],
|
|
178
|
-
createdAt: row[6],
|
|
179
|
-
updatedAt: row[7]
|
|
402
|
+
restrictedGroupId: row[1],
|
|
403
|
+
orgTeamId: row[2],
|
|
404
|
+
createdAt: row[3]
|
|
180
405
|
};
|
|
181
406
|
});
|
|
182
407
|
}
|
|
183
|
-
exports.
|
|
184
|
-
|
|
185
|
-
SET
|
|
186
|
-
active = FALSE,
|
|
187
|
-
updated_at = now()
|
|
408
|
+
exports.deleteRestrictedGroupTeamMembershipsQuery = `-- name: DeleteRestrictedGroupTeamMemberships :execrows
|
|
409
|
+
DELETE FROM weave.restricted_group_team_memberships
|
|
188
410
|
WHERE organization_id = $1
|
|
189
|
-
AND
|
|
190
|
-
|
|
411
|
+
AND restricted_group_id = $2`;
|
|
412
|
+
exports.addRestrictedGroupTeamMembershipQuery = `-- name: AddRestrictedGroupTeamMembership :one
|
|
413
|
+
INSERT INTO weave.restricted_group_team_memberships (
|
|
191
414
|
organization_id,
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
415
|
+
restricted_group_id,
|
|
416
|
+
org_team_id
|
|
417
|
+
) VALUES (
|
|
418
|
+
$1,
|
|
419
|
+
$2,
|
|
420
|
+
$3
|
|
421
|
+
)
|
|
422
|
+
ON CONFLICT DO NOTHING
|
|
423
|
+
RETURNING organization_id, restricted_group_id, org_team_id, created_at`;
|
|
424
|
+
async function addRestrictedGroupTeamMembership(client, args) {
|
|
200
425
|
const result = await client.query({
|
|
201
|
-
text: exports.
|
|
202
|
-
values: [args.organizationId, args.
|
|
426
|
+
text: exports.addRestrictedGroupTeamMembershipQuery,
|
|
427
|
+
values: [args.organizationId, args.restrictedGroupId, args.orgTeamId],
|
|
203
428
|
rowMode: "array"
|
|
204
429
|
});
|
|
205
430
|
if (result.rows.length !== 1) {
|
|
@@ -208,37 +433,109 @@ async function deactivateOrganizationSensitivityTag(client, args) {
|
|
|
208
433
|
const row = result.rows[0];
|
|
209
434
|
return {
|
|
210
435
|
organizationId: row[0],
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
extractionHint: row[4],
|
|
215
|
-
active: row[5],
|
|
216
|
-
createdAt: row[6],
|
|
217
|
-
updatedAt: row[7]
|
|
436
|
+
restrictedGroupId: row[1],
|
|
437
|
+
orgTeamId: row[2],
|
|
438
|
+
createdAt: row[3]
|
|
218
439
|
};
|
|
219
440
|
}
|
|
220
|
-
exports.
|
|
221
|
-
|
|
441
|
+
exports.listDocumentRestrictedGroupsQuery = `-- name: ListDocumentRestrictedGroups :many
|
|
442
|
+
SELECT
|
|
443
|
+
rg.id,
|
|
444
|
+
rg.organization_id,
|
|
445
|
+
rg.slug,
|
|
446
|
+
rg.name,
|
|
447
|
+
rg.description,
|
|
448
|
+
rg.active,
|
|
449
|
+
rg.created_at,
|
|
450
|
+
rg.updated_at
|
|
451
|
+
FROM weave.document_restricted_groups drg
|
|
452
|
+
JOIN weave.restricted_groups rg
|
|
453
|
+
ON rg.organization_id = drg.organization_id
|
|
454
|
+
AND rg.id = drg.restricted_group_id
|
|
455
|
+
WHERE drg.organization_id = $1
|
|
456
|
+
AND drg.document_id = $2
|
|
457
|
+
ORDER BY rg.name ASC, rg.slug ASC`;
|
|
458
|
+
async function listDocumentRestrictedGroups(client, args) {
|
|
459
|
+
const result = await client.query({
|
|
460
|
+
text: exports.listDocumentRestrictedGroupsQuery,
|
|
461
|
+
values: [args.organizationId, args.documentId],
|
|
462
|
+
rowMode: "array"
|
|
463
|
+
});
|
|
464
|
+
return result.rows.map(row => {
|
|
465
|
+
return {
|
|
466
|
+
id: row[0],
|
|
467
|
+
organizationId: row[1],
|
|
468
|
+
slug: row[2],
|
|
469
|
+
name: row[3],
|
|
470
|
+
description: row[4],
|
|
471
|
+
active: row[5],
|
|
472
|
+
createdAt: row[6],
|
|
473
|
+
updatedAt: row[7]
|
|
474
|
+
};
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
exports.listDocumentRestrictedGroupsByDocumentIDsQuery = `-- name: ListDocumentRestrictedGroupsByDocumentIDs :many
|
|
478
|
+
SELECT
|
|
479
|
+
drg.document_id,
|
|
480
|
+
rg.id,
|
|
481
|
+
rg.organization_id,
|
|
482
|
+
rg.slug,
|
|
483
|
+
rg.name,
|
|
484
|
+
rg.description,
|
|
485
|
+
rg.active,
|
|
486
|
+
rg.created_at,
|
|
487
|
+
rg.updated_at
|
|
488
|
+
FROM weave.document_restricted_groups drg
|
|
489
|
+
JOIN weave.restricted_groups rg
|
|
490
|
+
ON rg.organization_id = drg.organization_id
|
|
491
|
+
AND rg.id = drg.restricted_group_id
|
|
492
|
+
WHERE drg.organization_id = $1
|
|
493
|
+
AND drg.document_id = ANY($2::uuid[])
|
|
494
|
+
ORDER BY drg.document_id ASC, rg.name ASC, rg.slug ASC`;
|
|
495
|
+
async function listDocumentRestrictedGroupsByDocumentIDs(client, args) {
|
|
496
|
+
const result = await client.query({
|
|
497
|
+
text: exports.listDocumentRestrictedGroupsByDocumentIDsQuery,
|
|
498
|
+
values: [args.organizationId, args.documentIds],
|
|
499
|
+
rowMode: "array"
|
|
500
|
+
});
|
|
501
|
+
return result.rows.map(row => {
|
|
502
|
+
return {
|
|
503
|
+
documentId: row[0],
|
|
504
|
+
id: row[1],
|
|
505
|
+
organizationId: row[2],
|
|
506
|
+
slug: row[3],
|
|
507
|
+
name: row[4],
|
|
508
|
+
description: row[5],
|
|
509
|
+
active: row[6],
|
|
510
|
+
createdAt: row[7],
|
|
511
|
+
updatedAt: row[8]
|
|
512
|
+
};
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
exports.deleteDocumentRestrictedGroupsQuery = `-- name: DeleteDocumentRestrictedGroups :execrows
|
|
516
|
+
DELETE FROM weave.document_restricted_groups
|
|
517
|
+
WHERE organization_id = $1
|
|
518
|
+
AND document_id = $2`;
|
|
519
|
+
exports.deleteDocumentRestrictedGroupsByGroupQuery = `-- name: DeleteDocumentRestrictedGroupsByGroup :execrows
|
|
520
|
+
DELETE FROM weave.document_restricted_groups
|
|
521
|
+
WHERE organization_id = $1
|
|
522
|
+
AND restricted_group_id = $2`;
|
|
523
|
+
exports.addDocumentRestrictedGroupQuery = `-- name: AddDocumentRestrictedGroup :one
|
|
524
|
+
INSERT INTO weave.document_restricted_groups (
|
|
222
525
|
organization_id,
|
|
223
|
-
|
|
224
|
-
|
|
526
|
+
document_id,
|
|
527
|
+
restricted_group_id
|
|
225
528
|
) VALUES (
|
|
226
529
|
$1,
|
|
227
530
|
$2,
|
|
228
531
|
$3
|
|
229
532
|
)
|
|
230
|
-
ON CONFLICT
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
RETURNING
|
|
234
|
-
organization_id,
|
|
235
|
-
user_id,
|
|
236
|
-
sensitivity_tag_slug,
|
|
237
|
-
created_at`;
|
|
238
|
-
async function grantUserSensitivityClearance(client, args) {
|
|
533
|
+
ON CONFLICT DO NOTHING
|
|
534
|
+
RETURNING organization_id, document_id, restricted_group_id, created_at`;
|
|
535
|
+
async function addDocumentRestrictedGroup(client, args) {
|
|
239
536
|
const result = await client.query({
|
|
240
|
-
text: exports.
|
|
241
|
-
values: [args.organizationId, args.
|
|
537
|
+
text: exports.addDocumentRestrictedGroupQuery,
|
|
538
|
+
values: [args.organizationId, args.documentId, args.restrictedGroupId],
|
|
242
539
|
rowMode: "array"
|
|
243
540
|
});
|
|
244
541
|
if (result.rows.length !== 1) {
|
|
@@ -247,38 +544,39 @@ async function grantUserSensitivityClearance(client, args) {
|
|
|
247
544
|
const row = result.rows[0];
|
|
248
545
|
return {
|
|
249
546
|
organizationId: row[0],
|
|
250
|
-
|
|
251
|
-
|
|
547
|
+
documentId: row[1],
|
|
548
|
+
restrictedGroupId: row[2],
|
|
252
549
|
createdAt: row[3]
|
|
253
550
|
};
|
|
254
551
|
}
|
|
255
|
-
exports.
|
|
256
|
-
|
|
257
|
-
WHERE organization_id = $1
|
|
258
|
-
AND user_id = $2
|
|
259
|
-
AND sensitivity_tag_slug = $3`;
|
|
260
|
-
exports.listUserSensitivityClearancesQuery = `-- name: ListUserSensitivityClearances :many
|
|
261
|
-
SELECT
|
|
552
|
+
exports.addDocumentRestrictedGroupsForDocumentsQuery = `-- name: AddDocumentRestrictedGroupsForDocuments :execrows
|
|
553
|
+
INSERT INTO weave.document_restricted_groups (
|
|
262
554
|
organization_id,
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
555
|
+
document_id,
|
|
556
|
+
restricted_group_id
|
|
557
|
+
)
|
|
558
|
+
SELECT
|
|
559
|
+
$1,
|
|
560
|
+
document_id,
|
|
561
|
+
restricted_group_id
|
|
562
|
+
FROM unnest($2::uuid[]) AS document_id
|
|
563
|
+
CROSS JOIN unnest($3::uuid[]) AS restricted_group_id
|
|
564
|
+
ON CONFLICT DO NOTHING`;
|
|
565
|
+
exports.listDocumentIDsByRestrictedGroupQuery = `-- name: ListDocumentIDsByRestrictedGroup :many
|
|
566
|
+
SELECT DISTINCT document_id
|
|
567
|
+
FROM weave.document_restricted_groups
|
|
267
568
|
WHERE organization_id = $1
|
|
268
|
-
AND
|
|
269
|
-
ORDER BY
|
|
270
|
-
async function
|
|
569
|
+
AND restricted_group_id = $2
|
|
570
|
+
ORDER BY document_id ASC`;
|
|
571
|
+
async function listDocumentIDsByRestrictedGroup(client, args) {
|
|
271
572
|
const result = await client.query({
|
|
272
|
-
text: exports.
|
|
273
|
-
values: [args.organizationId, args.
|
|
573
|
+
text: exports.listDocumentIDsByRestrictedGroupQuery,
|
|
574
|
+
values: [args.organizationId, args.restrictedGroupId],
|
|
274
575
|
rowMode: "array"
|
|
275
576
|
});
|
|
276
577
|
return result.rows.map(row => {
|
|
277
578
|
return {
|
|
278
|
-
|
|
279
|
-
userId: row[1],
|
|
280
|
-
sensitivityTagSlug: row[2],
|
|
281
|
-
createdAt: row[3]
|
|
579
|
+
documentId: row[0]
|
|
282
580
|
};
|
|
283
581
|
});
|
|
284
582
|
}
|