@powerhousedao/reactor-api 6.2.0-dev.21 → 6.2.0-dev.23
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/index.d.mts +13 -225
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +108 -407
- package/dist/index.mjs.map +1 -1
- package/dist/src/packages/vite-loader.mjs +1 -1
- package/dist/{utils-Dh9tl892.mjs → utils-BMmk8cu0.mjs} +7 -12
- package/dist/utils-BMmk8cu0.mjs.map +1 -0
- package/package.json +28 -16
- package/dist/utils-Dh9tl892.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
3
|
-
import { a as isSubgraphClass, c as loadDocumentModels, d as BaseSubgraph, f as AuthorizationPolicy, i as buildGraphqlOperations, l as loadProcessors, m as createAuthorizationService, n as buildGraphQlDriveDocument, o as debounce, p as AuthorizedDocumentHandle, r as buildGraphqlOperation, t as buildGraphQlDocument, u as loadSubgraphs } from "./utils-
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="907dd002-0f18-5e7a-aa9e-ad649cd5d408")}catch(e){}}();
|
|
3
|
+
import { a as isSubgraphClass, c as loadDocumentModels, d as BaseSubgraph, f as AuthorizationPolicy, i as buildGraphqlOperations, l as loadProcessors, m as createAuthorizationService, n as buildGraphQlDriveDocument, o as debounce, p as AuthorizedDocumentHandle, r as buildGraphqlOperation, t as buildGraphQlDocument, u as loadSubgraphs } from "./utils-BMmk8cu0.mjs";
|
|
4
4
|
import { AnalyticsQueryEngine } from "@powerhousedao/analytics-engine-core";
|
|
5
5
|
import { AnalyticsModel, AnalyticsResolvers, typedefs } from "@powerhousedao/analytics-engine-graphql";
|
|
6
6
|
import { gql } from "graphql-tag";
|
|
@@ -70,16 +70,16 @@ var AnalyticsSubgraph = class extends BaseSubgraph {
|
|
|
70
70
|
};
|
|
71
71
|
//#endregion
|
|
72
72
|
//#region src/graphql/auth/schema.graphql
|
|
73
|
-
var schema_default$2 = "# Auth Subgraph Schema\n# Contains all document permission and authorization related types\n\nscalar DateTime\n\n# Permission levels for documents\nenum DocumentPermissionLevel {\n # Can fetch and read the document\n READ\n # Can push updates and modify the document\n WRITE\n # Can manage document permissions and settings\n ADMIN\n}\n\n# Document permission entry\ntype DocumentPermissionEntry {\n documentId: String!\n userAddress: String!\n permission: DocumentPermissionLevel!\n grantedBy: String!\n createdAt: DateTime!\n updatedAt: DateTime!\n}\n\n#
|
|
73
|
+
var schema_default$2 = "# Auth Subgraph Schema\n# Contains all document permission and authorization related types\n\nscalar DateTime\n\n# Permission levels for documents\nenum DocumentPermissionLevel {\n # Can fetch and read the document\n READ\n # Can push updates and modify the document\n WRITE\n # Can manage document permissions and settings\n ADMIN\n}\n\n# Document permission entry\ntype DocumentPermissionEntry {\n documentId: String!\n userAddress: String!\n permission: DocumentPermissionLevel!\n grantedBy: String!\n createdAt: DateTime!\n updatedAt: DateTime!\n}\n\n# Operation user permission entry\ntype OperationUserPermission {\n documentId: String!\n operationType: String!\n userAddress: String!\n grantedBy: String!\n createdAt: DateTime!\n}\n\n# Combined document access info\ntype DocumentAccessInfo {\n documentId: String!\n permissions: [DocumentPermissionEntry!]!\n}\n\n# Operation permissions info\ntype OperationPermissionsInfo {\n documentId: String!\n operationType: String!\n userPermissions: [OperationUserPermission!]!\n}\n\n# Document protection info\ntype DocumentProtectionInfo {\n documentId: String!\n protected: Boolean!\n ownerAddress: String\n}\n\ntype Query {\n # Get permissions for a document (requires ADMIN permission or global admin)\n documentAccess(documentId: String!): DocumentAccessInfo!\n\n # Get protection status for a document (requires ADMIN permission or global admin)\n documentProtection(documentId: String!): DocumentProtectionInfo!\n\n # Get all documents the current user has explicit access to\n userDocumentPermissions: [DocumentPermissionEntry!]!\n\n # Get operation permissions for a document and operation type\n # (requires ADMIN permission or global admin)\n operationPermissions(\n documentId: String!\n operationType: String!\n ): OperationPermissionsInfo!\n\n # Check if the current user can execute a specific operation on a document\n canExecuteOperation(documentId: String!, operationType: String!): Boolean!\n}\n\ntype Mutation {\n # Set document protection status (requires ADMIN permission or global admin)\n setDocumentProtection(\n documentId: String!\n protected: Boolean!\n ): DocumentProtectionInfo!\n\n # Transfer document ownership (requires ADMIN permission or global admin)\n transferDocumentOwnership(\n documentId: String!\n newOwnerAddress: String!\n ): DocumentProtectionInfo!\n\n # Grant a user permission on a document (requires ADMIN permission or global admin)\n grantDocumentPermission(\n documentId: String!\n userAddress: String!\n permission: DocumentPermissionLevel!\n ): DocumentPermissionEntry!\n\n # Revoke a user's permission on a document (requires ADMIN permission or global admin)\n revokeDocumentPermission(documentId: String!, userAddress: String!): Boolean!\n\n # --- Operation Permissions ---\n\n # Grant a user permission to execute an operation on a document\n grantOperationPermission(\n documentId: String!\n operationType: String!\n userAddress: String!\n ): OperationUserPermission!\n\n # Revoke a user's permission to execute an operation\n revokeOperationPermission(\n documentId: String!\n operationType: String!\n userAddress: String!\n ): Boolean!\n}\n";
|
|
74
74
|
//#endregion
|
|
75
75
|
//#region src/graphql/auth/resolvers.ts
|
|
76
|
-
async function documentAccess(service, args) {
|
|
76
|
+
async function documentAccess(service, authorizationService, args, userAddress) {
|
|
77
|
+
if (!userAddress) throw new GraphQLError("Authentication required");
|
|
78
|
+
if (!await authorizationService.canManage(args.documentId, userAddress)) throw new GraphQLError("Forbidden: You must be an admin of this document to view its permissions");
|
|
77
79
|
const permissions = await service.getDocumentPermissions(args.documentId);
|
|
78
|
-
const groupPermissions = await service.getDocumentGroupPermissions(args.documentId);
|
|
79
80
|
return {
|
|
80
81
|
documentId: args.documentId,
|
|
81
|
-
permissions
|
|
82
|
-
groupPermissions
|
|
82
|
+
permissions
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
85
|
async function userDocumentPermissions(service, userAddress) {
|
|
@@ -96,52 +96,14 @@ async function revokeDocumentPermission(service, authorizationService, args, rev
|
|
|
96
96
|
await service.revokePermission(args.documentId, args.userAddress);
|
|
97
97
|
return true;
|
|
98
98
|
}
|
|
99
|
-
async function
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
async function group(service, args) {
|
|
103
|
-
return service.getGroup(args.id);
|
|
104
|
-
}
|
|
105
|
-
async function userGroups(service, args) {
|
|
106
|
-
return service.getUserGroups(args.userAddress);
|
|
107
|
-
}
|
|
108
|
-
async function createGroup(service, args) {
|
|
109
|
-
return service.createGroup(args.name, args.description ?? void 0);
|
|
110
|
-
}
|
|
111
|
-
async function deleteGroup(service, args) {
|
|
112
|
-
await service.deleteGroup(args.id);
|
|
113
|
-
return true;
|
|
114
|
-
}
|
|
115
|
-
async function addUserToGroup(service, args) {
|
|
116
|
-
await service.addUserToGroup(args.userAddress, args.groupId);
|
|
117
|
-
return true;
|
|
118
|
-
}
|
|
119
|
-
async function removeUserFromGroup(service, args) {
|
|
120
|
-
await service.removeUserFromGroup(args.userAddress, args.groupId);
|
|
121
|
-
return true;
|
|
122
|
-
}
|
|
123
|
-
async function getGroupMembers(service, groupId) {
|
|
124
|
-
return service.getGroupMembers(groupId);
|
|
125
|
-
}
|
|
126
|
-
async function grantGroupPermission(service, authorizationService, args, grantedByAddress) {
|
|
127
|
-
if (!grantedByAddress) throw new GraphQLError("Authentication required");
|
|
128
|
-
if (!await authorizationService.canManage(args.documentId, grantedByAddress)) throw new GraphQLError("Forbidden: You must be an admin of this document to grant permissions");
|
|
129
|
-
return service.grantGroupPermission(args.documentId, args.groupId, args.permission, grantedByAddress);
|
|
130
|
-
}
|
|
131
|
-
async function revokeGroupPermission(service, authorizationService, args, revokedByAddress) {
|
|
132
|
-
if (!revokedByAddress) throw new GraphQLError("Authentication required");
|
|
133
|
-
if (!await authorizationService.canManage(args.documentId, revokedByAddress)) throw new GraphQLError("Forbidden: You must be an admin of this document to revoke permissions");
|
|
134
|
-
await service.revokeGroupPermission(args.documentId, args.groupId);
|
|
135
|
-
return true;
|
|
136
|
-
}
|
|
137
|
-
async function operationPermissions(service, args) {
|
|
99
|
+
async function operationPermissions(service, authorizationService, args, userAddress) {
|
|
100
|
+
if (!userAddress) throw new GraphQLError("Authentication required");
|
|
101
|
+
if (!await authorizationService.canManage(args.documentId, userAddress)) throw new GraphQLError("Forbidden: You must be an admin of this document to view its operation permissions");
|
|
138
102
|
const userPermissions = await service.getOperationUserPermissions(args.documentId, args.operationType);
|
|
139
|
-
const groupPermissions = await service.getOperationGroupPermissions(args.documentId, args.operationType);
|
|
140
103
|
return {
|
|
141
104
|
documentId: args.documentId,
|
|
142
105
|
operationType: args.operationType,
|
|
143
|
-
userPermissions
|
|
144
|
-
groupPermissions
|
|
106
|
+
userPermissions
|
|
145
107
|
};
|
|
146
108
|
}
|
|
147
109
|
async function canExecuteOperation(authorizationService, args, userAddress) {
|
|
@@ -158,18 +120,9 @@ async function revokeOperationPermission(service, authorizationService, args, re
|
|
|
158
120
|
await service.revokeOperationPermission(args.documentId, args.operationType, args.userAddress);
|
|
159
121
|
return true;
|
|
160
122
|
}
|
|
161
|
-
async function
|
|
162
|
-
if (!
|
|
163
|
-
if (!await authorizationService.canManage(args.documentId,
|
|
164
|
-
return service.grantGroupOperationPermission(args.documentId, args.operationType, args.groupId, grantedByAddress);
|
|
165
|
-
}
|
|
166
|
-
async function revokeGroupOperationPermission(service, authorizationService, args, revokedByAddress) {
|
|
167
|
-
if (!revokedByAddress) throw new GraphQLError("Authentication required");
|
|
168
|
-
if (!await authorizationService.canManage(args.documentId, revokedByAddress)) throw new GraphQLError("Forbidden: You must be an admin of this document to revoke operation permissions");
|
|
169
|
-
await service.revokeGroupOperationPermission(args.documentId, args.operationType, args.groupId);
|
|
170
|
-
return true;
|
|
171
|
-
}
|
|
172
|
-
async function documentProtection(service, args) {
|
|
123
|
+
async function documentProtection(service, authorizationService, args, userAddress) {
|
|
124
|
+
if (!userAddress) throw new GraphQLError("Authentication required");
|
|
125
|
+
if (!await authorizationService.canManage(args.documentId, userAddress)) throw new GraphQLError("Forbidden: You must be an admin of this document to view its protection info");
|
|
173
126
|
return service.getDocumentProtection(args.documentId);
|
|
174
127
|
}
|
|
175
128
|
async function setDocumentProtection(service, authorizationService, args, userAddress) {
|
|
@@ -195,8 +148,7 @@ async function transferDocumentOwnership(service, authorizationService, args, us
|
|
|
195
148
|
* This subgraph is conditionally registered based on the DOCUMENT_PERMISSIONS_ENABLED
|
|
196
149
|
* feature flag. When enabled, it provides GraphQL operations for:
|
|
197
150
|
* - Document permissions (grant/revoke user access)
|
|
198
|
-
* -
|
|
199
|
-
* - Group document permissions (grant/revoke group access)
|
|
151
|
+
* - Document protection and ownership
|
|
200
152
|
* - Operation-level permissions (fine-grained operation control)
|
|
201
153
|
*/
|
|
202
154
|
var AuthSubgraph = class extends BaseSubgraph {
|
|
@@ -210,11 +162,11 @@ var AuthSubgraph = class extends BaseSubgraph {
|
|
|
210
162
|
typeDefs = gql(schema_default$2);
|
|
211
163
|
resolvers = {
|
|
212
164
|
Query: {
|
|
213
|
-
documentAccess: async (_parent, args) => {
|
|
165
|
+
documentAccess: async (_parent, args, ctx) => {
|
|
214
166
|
this.logger.debug("documentAccess(@args)", args);
|
|
215
167
|
if (!this.documentPermissionService) throw new GraphQLError("DocumentPermissionService not available");
|
|
216
168
|
try {
|
|
217
|
-
return await documentAccess(this.documentPermissionService, args);
|
|
169
|
+
return await documentAccess(this.documentPermissionService, this.authorizationService, await this.withCanonicalDocumentId(args, ctx), ctx.user?.address);
|
|
218
170
|
} catch (error) {
|
|
219
171
|
this.logger.error("Error in documentAccess: @error", error);
|
|
220
172
|
throw error;
|
|
@@ -231,41 +183,11 @@ var AuthSubgraph = class extends BaseSubgraph {
|
|
|
231
183
|
throw error;
|
|
232
184
|
}
|
|
233
185
|
},
|
|
234
|
-
|
|
235
|
-
this.logger.debug("groups");
|
|
236
|
-
if (!this.documentPermissionService) throw new GraphQLError("DocumentPermissionService not available");
|
|
237
|
-
try {
|
|
238
|
-
return await groups(this.documentPermissionService);
|
|
239
|
-
} catch (error) {
|
|
240
|
-
this.logger.error("Error in groups: @error", error);
|
|
241
|
-
throw error;
|
|
242
|
-
}
|
|
243
|
-
},
|
|
244
|
-
group: async (_parent, args) => {
|
|
245
|
-
this.logger.debug("group(@args)", args);
|
|
246
|
-
if (!this.documentPermissionService) throw new GraphQLError("DocumentPermissionService not available");
|
|
247
|
-
try {
|
|
248
|
-
return await group(this.documentPermissionService, args);
|
|
249
|
-
} catch (error) {
|
|
250
|
-
this.logger.error("Error in group: @error", error);
|
|
251
|
-
throw error;
|
|
252
|
-
}
|
|
253
|
-
},
|
|
254
|
-
userGroups: async (_parent, args) => {
|
|
255
|
-
this.logger.debug("userGroups(@args)", args);
|
|
256
|
-
if (!this.documentPermissionService) throw new GraphQLError("DocumentPermissionService not available");
|
|
257
|
-
try {
|
|
258
|
-
return await userGroups(this.documentPermissionService, args);
|
|
259
|
-
} catch (error) {
|
|
260
|
-
this.logger.error("Error in userGroups: @error", error);
|
|
261
|
-
throw error;
|
|
262
|
-
}
|
|
263
|
-
},
|
|
264
|
-
operationPermissions: async (_parent, args) => {
|
|
186
|
+
operationPermissions: async (_parent, args, ctx) => {
|
|
265
187
|
this.logger.debug("operationPermissions(@args)", args);
|
|
266
188
|
if (!this.documentPermissionService) throw new GraphQLError("DocumentPermissionService not available");
|
|
267
189
|
try {
|
|
268
|
-
return await operationPermissions(this.documentPermissionService, args);
|
|
190
|
+
return await operationPermissions(this.documentPermissionService, this.authorizationService, await this.withCanonicalDocumentId(args, ctx), ctx.user?.address);
|
|
269
191
|
} catch (error) {
|
|
270
192
|
this.logger.error("Error in operationPermissions: @error", error);
|
|
271
193
|
throw error;
|
|
@@ -283,9 +205,8 @@ var AuthSubgraph = class extends BaseSubgraph {
|
|
|
283
205
|
documentProtection: async (_parent, args, ctx) => {
|
|
284
206
|
this.logger.debug("documentProtection(@args)", args);
|
|
285
207
|
if (!this.documentPermissionService) throw new GraphQLError("DocumentPermissionService not available");
|
|
286
|
-
if (!ctx.user?.address) throw new GraphQLError("Authentication required to view document protection info");
|
|
287
208
|
try {
|
|
288
|
-
return await documentProtection(this.documentPermissionService, args);
|
|
209
|
+
return await documentProtection(this.documentPermissionService, this.authorizationService, await this.withCanonicalDocumentId(args, ctx), ctx.user?.address);
|
|
289
210
|
} catch (error) {
|
|
290
211
|
this.logger.error("Error in documentProtection: @error", error);
|
|
291
212
|
throw error;
|
|
@@ -337,70 +258,6 @@ var AuthSubgraph = class extends BaseSubgraph {
|
|
|
337
258
|
throw error;
|
|
338
259
|
}
|
|
339
260
|
},
|
|
340
|
-
createGroup: async (_parent, args) => {
|
|
341
|
-
this.logger.debug("createGroup(@args)", args);
|
|
342
|
-
if (!this.documentPermissionService) throw new GraphQLError("DocumentPermissionService not available");
|
|
343
|
-
try {
|
|
344
|
-
return await createGroup(this.documentPermissionService, args);
|
|
345
|
-
} catch (error) {
|
|
346
|
-
this.logger.error("Error in createGroup: @error", error);
|
|
347
|
-
throw error;
|
|
348
|
-
}
|
|
349
|
-
},
|
|
350
|
-
deleteGroup: async (_parent, args) => {
|
|
351
|
-
this.logger.debug("deleteGroup(@args)", args);
|
|
352
|
-
if (!this.documentPermissionService) throw new GraphQLError("DocumentPermissionService not available");
|
|
353
|
-
try {
|
|
354
|
-
return await deleteGroup(this.documentPermissionService, args);
|
|
355
|
-
} catch (error) {
|
|
356
|
-
this.logger.error("Error in deleteGroup: @error", error);
|
|
357
|
-
throw error;
|
|
358
|
-
}
|
|
359
|
-
},
|
|
360
|
-
addUserToGroup: async (_parent, args) => {
|
|
361
|
-
this.logger.debug("addUserToGroup(@args)", args);
|
|
362
|
-
if (!this.documentPermissionService) throw new GraphQLError("DocumentPermissionService not available");
|
|
363
|
-
try {
|
|
364
|
-
return await addUserToGroup(this.documentPermissionService, args);
|
|
365
|
-
} catch (error) {
|
|
366
|
-
this.logger.error("Error in addUserToGroup: @error", error);
|
|
367
|
-
throw error;
|
|
368
|
-
}
|
|
369
|
-
},
|
|
370
|
-
removeUserFromGroup: async (_parent, args) => {
|
|
371
|
-
this.logger.debug("removeUserFromGroup(@args)", args);
|
|
372
|
-
if (!this.documentPermissionService) throw new GraphQLError("DocumentPermissionService not available");
|
|
373
|
-
try {
|
|
374
|
-
return await removeUserFromGroup(this.documentPermissionService, args);
|
|
375
|
-
} catch (error) {
|
|
376
|
-
this.logger.error("Error in removeUserFromGroup: @error", error);
|
|
377
|
-
throw error;
|
|
378
|
-
}
|
|
379
|
-
},
|
|
380
|
-
grantGroupPermission: async (_parent, args, ctx) => {
|
|
381
|
-
this.logger.debug("grantGroupPermission(@args)", args);
|
|
382
|
-
if (!this.documentPermissionService) throw new GraphQLError("DocumentPermissionService not available");
|
|
383
|
-
try {
|
|
384
|
-
const resolved = await this.withCanonicalDocumentId(args, ctx);
|
|
385
|
-
return await grantGroupPermission(this.documentPermissionService, this.authorizationService, {
|
|
386
|
-
...resolved,
|
|
387
|
-
permission: resolved.permission
|
|
388
|
-
}, ctx.user?.address);
|
|
389
|
-
} catch (error) {
|
|
390
|
-
this.logger.error("Error in grantGroupPermission: @error", error);
|
|
391
|
-
throw error;
|
|
392
|
-
}
|
|
393
|
-
},
|
|
394
|
-
revokeGroupPermission: async (_parent, args, ctx) => {
|
|
395
|
-
this.logger.debug("revokeGroupPermission(@args)", args);
|
|
396
|
-
if (!this.documentPermissionService) throw new GraphQLError("DocumentPermissionService not available");
|
|
397
|
-
try {
|
|
398
|
-
return await revokeGroupPermission(this.documentPermissionService, this.authorizationService, await this.withCanonicalDocumentId(args, ctx), ctx.user?.address);
|
|
399
|
-
} catch (error) {
|
|
400
|
-
this.logger.error("Error in revokeGroupPermission: @error", error);
|
|
401
|
-
throw error;
|
|
402
|
-
}
|
|
403
|
-
},
|
|
404
261
|
grantOperationPermission: async (_parent, args, ctx) => {
|
|
405
262
|
this.logger.debug("grantOperationPermission(@args)", args);
|
|
406
263
|
if (!this.documentPermissionService) throw new GraphQLError("DocumentPermissionService not available");
|
|
@@ -420,44 +277,8 @@ var AuthSubgraph = class extends BaseSubgraph {
|
|
|
420
277
|
this.logger.error("Error in revokeOperationPermission: @error", error);
|
|
421
278
|
throw error;
|
|
422
279
|
}
|
|
423
|
-
},
|
|
424
|
-
grantGroupOperationPermission: async (_parent, args, ctx) => {
|
|
425
|
-
this.logger.debug("grantGroupOperationPermission(@args)", args);
|
|
426
|
-
if (!this.documentPermissionService) throw new GraphQLError("DocumentPermissionService not available");
|
|
427
|
-
try {
|
|
428
|
-
return await grantGroupOperationPermission(this.documentPermissionService, this.authorizationService, await this.withCanonicalDocumentId(args, ctx), ctx.user?.address);
|
|
429
|
-
} catch (error) {
|
|
430
|
-
this.logger.error("Error in grantGroupOperationPermission: @error", error);
|
|
431
|
-
throw error;
|
|
432
|
-
}
|
|
433
|
-
},
|
|
434
|
-
revokeGroupOperationPermission: async (_parent, args, ctx) => {
|
|
435
|
-
this.logger.debug("revokeGroupOperationPermission(@args)", args);
|
|
436
|
-
if (!this.documentPermissionService) throw new GraphQLError("DocumentPermissionService not available");
|
|
437
|
-
try {
|
|
438
|
-
return await revokeGroupOperationPermission(this.documentPermissionService, this.authorizationService, await this.withCanonicalDocumentId(args, ctx), ctx.user?.address);
|
|
439
|
-
} catch (error) {
|
|
440
|
-
this.logger.error("Error in revokeGroupOperationPermission: @error", error);
|
|
441
|
-
throw error;
|
|
442
|
-
}
|
|
443
280
|
}
|
|
444
|
-
}
|
|
445
|
-
Group: { members: async (parent) => {
|
|
446
|
-
if (!this.documentPermissionService) throw new GraphQLError("DocumentPermissionService not available");
|
|
447
|
-
return getGroupMembers(this.documentPermissionService, parent.id);
|
|
448
|
-
} },
|
|
449
|
-
DocumentGroupPermission: { group: async (parent) => {
|
|
450
|
-
if (!this.documentPermissionService) throw new GraphQLError("DocumentPermissionService not available");
|
|
451
|
-
const grp = await group(this.documentPermissionService, { id: parent.groupId });
|
|
452
|
-
if (!grp) throw new GraphQLError(`Group not found: ${parent.groupId}`);
|
|
453
|
-
return grp;
|
|
454
|
-
} },
|
|
455
|
-
OperationGroupPermission: { group: async (parent) => {
|
|
456
|
-
if (!this.documentPermissionService) throw new GraphQLError("DocumentPermissionService not available");
|
|
457
|
-
const grp = await group(this.documentPermissionService, { id: parent.groupId });
|
|
458
|
-
if (!grp) throw new GraphQLError(`Group not found: ${parent.groupId}`);
|
|
459
|
-
return grp;
|
|
460
|
-
} }
|
|
281
|
+
}
|
|
461
282
|
};
|
|
462
283
|
onSetup() {
|
|
463
284
|
this.logger.debug("Setting up AuthSubgraph");
|
|
@@ -4341,10 +4162,10 @@ const ADMIN_USERS = getAdminUsers();
|
|
|
4341
4162
|
//#endregion
|
|
4342
4163
|
//#region src/graphql/system/version.ts
|
|
4343
4164
|
function getVersion() {
|
|
4344
|
-
return "6.2.0-dev.
|
|
4165
|
+
return "6.2.0-dev.23";
|
|
4345
4166
|
}
|
|
4346
4167
|
function getGitHash() {
|
|
4347
|
-
return "
|
|
4168
|
+
return "7601d1b00b40cfb1088bc72bb08dbde9a425c0e5";
|
|
4348
4169
|
}
|
|
4349
4170
|
function getGitUrl() {
|
|
4350
4171
|
return buildTreeUrl(getGitHash());
|
|
@@ -4827,10 +4648,10 @@ const DefaultCoreSubgraphs = [AnalyticsSubgraph, SystemSubgraph];
|
|
|
4827
4648
|
//#endregion
|
|
4828
4649
|
//#region src/migrations/001_create_document_permissions.ts
|
|
4829
4650
|
var _001_create_document_permissions_exports = /* @__PURE__ */ __exportAll({
|
|
4830
|
-
down: () => down$
|
|
4831
|
-
up: () => up$
|
|
4651
|
+
down: () => down$2,
|
|
4652
|
+
up: () => up$2
|
|
4832
4653
|
});
|
|
4833
|
-
async function up$
|
|
4654
|
+
async function up$2(db) {
|
|
4834
4655
|
await sql`
|
|
4835
4656
|
CREATE TABLE IF NOT EXISTS "DocumentPermission" (
|
|
4836
4657
|
"id" SERIAL PRIMARY KEY,
|
|
@@ -4904,7 +4725,7 @@ async function up$1(db) {
|
|
|
4904
4725
|
await sql`CREATE INDEX IF NOT EXISTS "operationgrouppermission_documentid_index" ON "OperationGroupPermission" ("documentId")`.execute(db);
|
|
4905
4726
|
await sql`CREATE INDEX IF NOT EXISTS "operationgrouppermission_groupid_index" ON "OperationGroupPermission" ("groupId")`.execute(db);
|
|
4906
4727
|
}
|
|
4907
|
-
async function down$
|
|
4728
|
+
async function down$2(db) {
|
|
4908
4729
|
await sql`DROP TABLE IF EXISTS "OperationGroupPermission"`.execute(db);
|
|
4909
4730
|
await sql`DROP TABLE IF EXISTS "OperationUserPermission"`.execute(db);
|
|
4910
4731
|
await sql`DROP TABLE IF EXISTS "DocumentGroupPermission"`.execute(db);
|
|
@@ -4915,10 +4736,10 @@ async function down$1(db) {
|
|
|
4915
4736
|
//#endregion
|
|
4916
4737
|
//#region src/migrations/002_add_document_protection.ts
|
|
4917
4738
|
var _002_add_document_protection_exports = /* @__PURE__ */ __exportAll({
|
|
4918
|
-
down: () => down,
|
|
4919
|
-
up: () => up
|
|
4739
|
+
down: () => down$1,
|
|
4740
|
+
up: () => up$1
|
|
4920
4741
|
});
|
|
4921
|
-
async function up(db) {
|
|
4742
|
+
async function up$1(db) {
|
|
4922
4743
|
await sql`
|
|
4923
4744
|
CREATE TABLE IF NOT EXISTS "DocumentProtection" (
|
|
4924
4745
|
"documentId" VARCHAR(255) PRIMARY KEY,
|
|
@@ -4931,10 +4752,80 @@ async function up(db) {
|
|
|
4931
4752
|
await sql`CREATE INDEX IF NOT EXISTS "documentprotection_owneraddress_index" ON "DocumentProtection" ("ownerAddress")`.execute(db);
|
|
4932
4753
|
await sql`CREATE INDEX IF NOT EXISTS "documentprotection_protected_index" ON "DocumentProtection" ("protected")`.execute(db);
|
|
4933
4754
|
}
|
|
4934
|
-
async function down(db) {
|
|
4755
|
+
async function down$1(db) {
|
|
4935
4756
|
await sql`DROP TABLE IF EXISTS "DocumentProtection"`.execute(db);
|
|
4936
4757
|
}
|
|
4937
4758
|
//#endregion
|
|
4759
|
+
//#region src/migrations/003_remove_group_tables.ts
|
|
4760
|
+
var _003_remove_group_tables_exports = /* @__PURE__ */ __exportAll({
|
|
4761
|
+
down: () => down,
|
|
4762
|
+
up: () => up
|
|
4763
|
+
});
|
|
4764
|
+
/**
|
|
4765
|
+
* Removes the group-permission feature: the Group, UserGroup,
|
|
4766
|
+
* DocumentGroupPermission, and OperationGroupPermission tables. The feature had
|
|
4767
|
+
* no consumers and disclosed ACL/membership metadata (AUTH_REVIEW S-H3/S-H5);
|
|
4768
|
+
* it is retired in favor of direct user grants, ownership, and protection.
|
|
4769
|
+
*
|
|
4770
|
+
* Tables are dropped in reverse dependency order. There are no DB-enforced
|
|
4771
|
+
* foreign keys, so the drops cannot violate referential integrity and do not
|
|
4772
|
+
* touch the surviving DocumentPermission / OperationUserPermission /
|
|
4773
|
+
* DocumentProtection tables.
|
|
4774
|
+
*/
|
|
4775
|
+
async function up(db) {
|
|
4776
|
+
await sql`DROP TABLE IF EXISTS "OperationGroupPermission"`.execute(db);
|
|
4777
|
+
await sql`DROP TABLE IF EXISTS "DocumentGroupPermission"`.execute(db);
|
|
4778
|
+
await sql`DROP TABLE IF EXISTS "UserGroup"`.execute(db);
|
|
4779
|
+
await sql`DROP TABLE IF EXISTS "Group"`.execute(db);
|
|
4780
|
+
}
|
|
4781
|
+
async function down(db) {
|
|
4782
|
+
await sql`
|
|
4783
|
+
CREATE TABLE IF NOT EXISTS "Group" (
|
|
4784
|
+
"id" SERIAL PRIMARY KEY,
|
|
4785
|
+
"name" VARCHAR(255) NOT NULL UNIQUE,
|
|
4786
|
+
"description" TEXT,
|
|
4787
|
+
"createdAt" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
4788
|
+
"updatedAt" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
4789
|
+
)
|
|
4790
|
+
`.execute(db);
|
|
4791
|
+
await sql`
|
|
4792
|
+
CREATE TABLE IF NOT EXISTS "UserGroup" (
|
|
4793
|
+
"userAddress" VARCHAR(255) NOT NULL,
|
|
4794
|
+
"groupId" INTEGER NOT NULL,
|
|
4795
|
+
"createdAt" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
4796
|
+
PRIMARY KEY ("userAddress", "groupId")
|
|
4797
|
+
)
|
|
4798
|
+
`.execute(db);
|
|
4799
|
+
await sql`CREATE INDEX IF NOT EXISTS "usergroup_groupid_index" ON "UserGroup" ("groupId")`.execute(db);
|
|
4800
|
+
await sql`
|
|
4801
|
+
CREATE TABLE IF NOT EXISTS "DocumentGroupPermission" (
|
|
4802
|
+
"id" SERIAL PRIMARY KEY,
|
|
4803
|
+
"documentId" VARCHAR(255) NOT NULL,
|
|
4804
|
+
"groupId" INTEGER NOT NULL,
|
|
4805
|
+
"permission" VARCHAR(20) NOT NULL CHECK ("permission" IN ('READ', 'WRITE', 'ADMIN')),
|
|
4806
|
+
"grantedBy" VARCHAR(255) NOT NULL,
|
|
4807
|
+
"createdAt" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
4808
|
+
"updatedAt" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
4809
|
+
UNIQUE ("documentId", "groupId")
|
|
4810
|
+
)
|
|
4811
|
+
`.execute(db);
|
|
4812
|
+
await sql`CREATE INDEX IF NOT EXISTS "documentgrouppermission_documentid_index" ON "DocumentGroupPermission" ("documentId")`.execute(db);
|
|
4813
|
+
await sql`CREATE INDEX IF NOT EXISTS "documentgrouppermission_groupid_index" ON "DocumentGroupPermission" ("groupId")`.execute(db);
|
|
4814
|
+
await sql`
|
|
4815
|
+
CREATE TABLE IF NOT EXISTS "OperationGroupPermission" (
|
|
4816
|
+
"id" SERIAL PRIMARY KEY,
|
|
4817
|
+
"documentId" VARCHAR(255) NOT NULL,
|
|
4818
|
+
"operationType" VARCHAR(255) NOT NULL,
|
|
4819
|
+
"groupId" INTEGER NOT NULL,
|
|
4820
|
+
"grantedBy" VARCHAR(255) NOT NULL,
|
|
4821
|
+
"createdAt" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
4822
|
+
UNIQUE ("documentId", "operationType", "groupId")
|
|
4823
|
+
)
|
|
4824
|
+
`.execute(db);
|
|
4825
|
+
await sql`CREATE INDEX IF NOT EXISTS "operationgrouppermission_documentid_index" ON "OperationGroupPermission" ("documentId")`.execute(db);
|
|
4826
|
+
await sql`CREATE INDEX IF NOT EXISTS "operationgrouppermission_groupid_index" ON "OperationGroupPermission" ("groupId")`.execute(db);
|
|
4827
|
+
}
|
|
4828
|
+
//#endregion
|
|
4938
4829
|
//#region src/migrations/index.ts
|
|
4939
4830
|
/**
|
|
4940
4831
|
* Custom migration provider that loads migrations from imported modules
|
|
@@ -4943,7 +4834,8 @@ var StaticMigrationProvider = class {
|
|
|
4943
4834
|
getMigrations() {
|
|
4944
4835
|
return Promise.resolve({
|
|
4945
4836
|
"001_create_document_permissions": _001_create_document_permissions_exports,
|
|
4946
|
-
"002_add_document_protection": _002_add_document_protection_exports
|
|
4837
|
+
"002_add_document_protection": _002_add_document_protection_exports,
|
|
4838
|
+
"003_remove_group_tables": _003_remove_group_tables_exports
|
|
4947
4839
|
});
|
|
4948
4840
|
}
|
|
4949
4841
|
};
|
|
@@ -5131,7 +5023,7 @@ var AuthService = class {
|
|
|
5131
5023
|
* - ADMIN: Can manage document permissions and settings
|
|
5132
5024
|
*
|
|
5133
5025
|
* Operation permissions:
|
|
5134
|
-
* - Users
|
|
5026
|
+
* - Users can be granted permission to execute specific operations
|
|
5135
5027
|
*/
|
|
5136
5028
|
var DocumentPermissionService = class {
|
|
5137
5029
|
config;
|
|
@@ -5210,152 +5102,7 @@ var DocumentPermissionService = class {
|
|
|
5210
5102
|
*/
|
|
5211
5103
|
async deleteAllDocumentPermissions(documentId) {
|
|
5212
5104
|
await this.db.deleteFrom("DocumentPermission").where("documentId", "=", documentId).execute();
|
|
5213
|
-
await this.db.deleteFrom("DocumentGroupPermission").where("documentId", "=", documentId).execute();
|
|
5214
5105
|
await this.db.deleteFrom("OperationUserPermission").where("documentId", "=", documentId).execute();
|
|
5215
|
-
await this.db.deleteFrom("OperationGroupPermission").where("documentId", "=", documentId).execute();
|
|
5216
|
-
}
|
|
5217
|
-
/**
|
|
5218
|
-
* Create a new group
|
|
5219
|
-
*/
|
|
5220
|
-
async createGroup(name, description) {
|
|
5221
|
-
const now = /* @__PURE__ */ new Date();
|
|
5222
|
-
await this.db.insertInto("Group").values({
|
|
5223
|
-
name,
|
|
5224
|
-
description: description ?? null,
|
|
5225
|
-
createdAt: now,
|
|
5226
|
-
updatedAt: now
|
|
5227
|
-
}).execute();
|
|
5228
|
-
return await this.db.selectFrom("Group").select([
|
|
5229
|
-
"id",
|
|
5230
|
-
"name",
|
|
5231
|
-
"description",
|
|
5232
|
-
"createdAt",
|
|
5233
|
-
"updatedAt"
|
|
5234
|
-
]).where("name", "=", name).executeTakeFirstOrThrow();
|
|
5235
|
-
}
|
|
5236
|
-
/**
|
|
5237
|
-
* Delete a group and all its associations
|
|
5238
|
-
*/
|
|
5239
|
-
async deleteGroup(groupId) {
|
|
5240
|
-
await this.db.deleteFrom("OperationGroupPermission").where("groupId", "=", groupId).execute();
|
|
5241
|
-
await this.db.deleteFrom("DocumentGroupPermission").where("groupId", "=", groupId).execute();
|
|
5242
|
-
await this.db.deleteFrom("UserGroup").where("groupId", "=", groupId).execute();
|
|
5243
|
-
await this.db.deleteFrom("Group").where("id", "=", groupId).execute();
|
|
5244
|
-
}
|
|
5245
|
-
/**
|
|
5246
|
-
* Get a group by ID
|
|
5247
|
-
*/
|
|
5248
|
-
async getGroup(groupId) {
|
|
5249
|
-
return await this.db.selectFrom("Group").select([
|
|
5250
|
-
"id",
|
|
5251
|
-
"name",
|
|
5252
|
-
"description",
|
|
5253
|
-
"createdAt",
|
|
5254
|
-
"updatedAt"
|
|
5255
|
-
]).where("id", "=", groupId).executeTakeFirst() ?? null;
|
|
5256
|
-
}
|
|
5257
|
-
/**
|
|
5258
|
-
* List all groups
|
|
5259
|
-
*/
|
|
5260
|
-
async listGroups() {
|
|
5261
|
-
return this.db.selectFrom("Group").select([
|
|
5262
|
-
"id",
|
|
5263
|
-
"name",
|
|
5264
|
-
"description",
|
|
5265
|
-
"createdAt",
|
|
5266
|
-
"updatedAt"
|
|
5267
|
-
]).execute();
|
|
5268
|
-
}
|
|
5269
|
-
/**
|
|
5270
|
-
* Add a user to a group
|
|
5271
|
-
*/
|
|
5272
|
-
async addUserToGroup(userAddress, groupId) {
|
|
5273
|
-
const now = /* @__PURE__ */ new Date();
|
|
5274
|
-
const normalizedAddress = userAddress.toLowerCase();
|
|
5275
|
-
await this.db.insertInto("UserGroup").values({
|
|
5276
|
-
userAddress: normalizedAddress,
|
|
5277
|
-
groupId,
|
|
5278
|
-
createdAt: now
|
|
5279
|
-
}).onConflict((oc) => oc.columns(["userAddress", "groupId"]).doNothing()).execute();
|
|
5280
|
-
}
|
|
5281
|
-
/**
|
|
5282
|
-
* Remove a user from a group
|
|
5283
|
-
*/
|
|
5284
|
-
async removeUserFromGroup(userAddress, groupId) {
|
|
5285
|
-
await this.db.deleteFrom("UserGroup").where("userAddress", "=", userAddress.toLowerCase()).where("groupId", "=", groupId).execute();
|
|
5286
|
-
}
|
|
5287
|
-
/**
|
|
5288
|
-
* Get all groups a user belongs to
|
|
5289
|
-
*/
|
|
5290
|
-
async getUserGroups(userAddress) {
|
|
5291
|
-
return this.db.selectFrom("UserGroup").innerJoin("Group", "Group.id", "UserGroup.groupId").select([
|
|
5292
|
-
"Group.id",
|
|
5293
|
-
"Group.name",
|
|
5294
|
-
"Group.description",
|
|
5295
|
-
"Group.createdAt",
|
|
5296
|
-
"Group.updatedAt"
|
|
5297
|
-
]).where("UserGroup.userAddress", "=", userAddress.toLowerCase()).execute();
|
|
5298
|
-
}
|
|
5299
|
-
/**
|
|
5300
|
-
* Get all members of a group
|
|
5301
|
-
*/
|
|
5302
|
-
async getGroupMembers(groupId) {
|
|
5303
|
-
return (await this.db.selectFrom("UserGroup").select("userAddress").where("groupId", "=", groupId).execute()).map((r) => r.userAddress);
|
|
5304
|
-
}
|
|
5305
|
-
/**
|
|
5306
|
-
* Grant a group permission on a document
|
|
5307
|
-
*/
|
|
5308
|
-
async grantGroupPermission(documentId, groupId, permission, grantedBy) {
|
|
5309
|
-
const now = /* @__PURE__ */ new Date();
|
|
5310
|
-
await this.db.insertInto("DocumentGroupPermission").values({
|
|
5311
|
-
documentId,
|
|
5312
|
-
groupId,
|
|
5313
|
-
permission,
|
|
5314
|
-
grantedBy: grantedBy.toLowerCase(),
|
|
5315
|
-
createdAt: now,
|
|
5316
|
-
updatedAt: now
|
|
5317
|
-
}).onConflict((oc) => oc.columns(["documentId", "groupId"]).doUpdateSet({
|
|
5318
|
-
permission,
|
|
5319
|
-
grantedBy: grantedBy.toLowerCase(),
|
|
5320
|
-
updatedAt: now
|
|
5321
|
-
})).execute();
|
|
5322
|
-
return await this.db.selectFrom("DocumentGroupPermission").select([
|
|
5323
|
-
"documentId",
|
|
5324
|
-
"groupId",
|
|
5325
|
-
"permission",
|
|
5326
|
-
"grantedBy",
|
|
5327
|
-
"createdAt",
|
|
5328
|
-
"updatedAt"
|
|
5329
|
-
]).where("documentId", "=", documentId).where("groupId", "=", groupId).executeTakeFirstOrThrow();
|
|
5330
|
-
}
|
|
5331
|
-
/**
|
|
5332
|
-
* Revoke a group's permission on a document
|
|
5333
|
-
*/
|
|
5334
|
-
async revokeGroupPermission(documentId, groupId) {
|
|
5335
|
-
await this.db.deleteFrom("DocumentGroupPermission").where("documentId", "=", documentId).where("groupId", "=", groupId).execute();
|
|
5336
|
-
}
|
|
5337
|
-
/**
|
|
5338
|
-
* Get all group permissions for a document
|
|
5339
|
-
*/
|
|
5340
|
-
async getDocumentGroupPermissions(documentId) {
|
|
5341
|
-
return this.db.selectFrom("DocumentGroupPermission").select([
|
|
5342
|
-
"documentId",
|
|
5343
|
-
"groupId",
|
|
5344
|
-
"permission",
|
|
5345
|
-
"grantedBy",
|
|
5346
|
-
"createdAt",
|
|
5347
|
-
"updatedAt"
|
|
5348
|
-
]).where("documentId", "=", documentId).execute();
|
|
5349
|
-
}
|
|
5350
|
-
/**
|
|
5351
|
-
* Get best permission level a user has on a document via groups
|
|
5352
|
-
*/
|
|
5353
|
-
async getUserGroupPermission(documentId, userAddress) {
|
|
5354
|
-
const result = await this.db.selectFrom("DocumentGroupPermission").innerJoin("UserGroup", "UserGroup.groupId", "DocumentGroupPermission.groupId").select("DocumentGroupPermission.permission").where("DocumentGroupPermission.documentId", "=", documentId).where("UserGroup.userAddress", "=", userAddress.toLowerCase()).execute();
|
|
5355
|
-
if (result.length === 0) return null;
|
|
5356
|
-
if (result.some((r) => r.permission === "ADMIN")) return "ADMIN";
|
|
5357
|
-
if (result.some((r) => r.permission === "WRITE")) return "WRITE";
|
|
5358
|
-
return "READ";
|
|
5359
5106
|
}
|
|
5360
5107
|
/**
|
|
5361
5108
|
* Grant a user permission to execute an operation on a document
|
|
@@ -5389,36 +5136,6 @@ var DocumentPermissionService = class {
|
|
|
5389
5136
|
await this.db.deleteFrom("OperationUserPermission").where("documentId", "=", documentId).where("operationType", "=", operationType).where("userAddress", "=", userAddress.toLowerCase()).execute();
|
|
5390
5137
|
}
|
|
5391
5138
|
/**
|
|
5392
|
-
* Grant a group permission to execute an operation on a document
|
|
5393
|
-
*/
|
|
5394
|
-
async grantGroupOperationPermission(documentId, operationType, groupId, grantedBy) {
|
|
5395
|
-
const now = /* @__PURE__ */ new Date();
|
|
5396
|
-
await this.db.insertInto("OperationGroupPermission").values({
|
|
5397
|
-
documentId,
|
|
5398
|
-
operationType,
|
|
5399
|
-
groupId,
|
|
5400
|
-
grantedBy: grantedBy.toLowerCase(),
|
|
5401
|
-
createdAt: now
|
|
5402
|
-
}).onConflict((oc) => oc.columns([
|
|
5403
|
-
"documentId",
|
|
5404
|
-
"operationType",
|
|
5405
|
-
"groupId"
|
|
5406
|
-
]).doNothing()).execute();
|
|
5407
|
-
return await this.db.selectFrom("OperationGroupPermission").select([
|
|
5408
|
-
"documentId",
|
|
5409
|
-
"operationType",
|
|
5410
|
-
"groupId",
|
|
5411
|
-
"grantedBy",
|
|
5412
|
-
"createdAt"
|
|
5413
|
-
]).where("documentId", "=", documentId).where("operationType", "=", operationType).where("groupId", "=", groupId).executeTakeFirstOrThrow();
|
|
5414
|
-
}
|
|
5415
|
-
/**
|
|
5416
|
-
* Revoke a group's permission to execute an operation
|
|
5417
|
-
*/
|
|
5418
|
-
async revokeGroupOperationPermission(documentId, operationType, groupId) {
|
|
5419
|
-
await this.db.deleteFrom("OperationGroupPermission").where("documentId", "=", documentId).where("operationType", "=", operationType).where("groupId", "=", groupId).execute();
|
|
5420
|
-
}
|
|
5421
|
-
/**
|
|
5422
5139
|
* Get all users with permission to execute an operation
|
|
5423
5140
|
*/
|
|
5424
5141
|
async getOperationUserPermissions(documentId, operationType) {
|
|
@@ -5431,34 +5148,18 @@ var DocumentPermissionService = class {
|
|
|
5431
5148
|
]).where("documentId", "=", documentId).where("operationType", "=", operationType).execute();
|
|
5432
5149
|
}
|
|
5433
5150
|
/**
|
|
5434
|
-
*
|
|
5435
|
-
*/
|
|
5436
|
-
async getOperationGroupPermissions(documentId, operationType) {
|
|
5437
|
-
return this.db.selectFrom("OperationGroupPermission").select([
|
|
5438
|
-
"documentId",
|
|
5439
|
-
"operationType",
|
|
5440
|
-
"groupId",
|
|
5441
|
-
"grantedBy",
|
|
5442
|
-
"createdAt"
|
|
5443
|
-
]).where("documentId", "=", documentId).where("operationType", "=", operationType).execute();
|
|
5444
|
-
}
|
|
5445
|
-
/**
|
|
5446
|
-
* Whether an operation-permission row exists for the user on this
|
|
5447
|
-
* operation, either directly or via a group the user belongs to.
|
|
5151
|
+
* Whether an operation-permission row exists for the user on this operation.
|
|
5448
5152
|
*/
|
|
5449
5153
|
async hasOperationGrant(documentId, operationType, userAddress) {
|
|
5450
5154
|
const normalizedAddress = userAddress.toLowerCase();
|
|
5451
|
-
|
|
5452
|
-
return !!await this.db.selectFrom("OperationGroupPermission").innerJoin("UserGroup", "UserGroup.groupId", "OperationGroupPermission.groupId").select("OperationGroupPermission.groupId").where("OperationGroupPermission.documentId", "=", documentId).where("OperationGroupPermission.operationType", "=", operationType).where("UserGroup.userAddress", "=", normalizedAddress).executeTakeFirst();
|
|
5155
|
+
return !!await this.db.selectFrom("OperationUserPermission").select("userAddress").where("documentId", "=", documentId).where("operationType", "=", operationType).where("userAddress", "=", normalizedAddress).executeTakeFirst();
|
|
5453
5156
|
}
|
|
5454
5157
|
/**
|
|
5455
5158
|
* Check if an operation has any permissions set (is restricted)
|
|
5456
5159
|
*/
|
|
5457
5160
|
async isOperationRestricted(documentId, operationType) {
|
|
5458
5161
|
const userPermCount = await this.db.selectFrom("OperationUserPermission").select(sql`count(*)`.as("count")).where("documentId", "=", documentId).where("operationType", "=", operationType).executeTakeFirst();
|
|
5459
|
-
|
|
5460
|
-
const groupPermCount = await this.db.selectFrom("OperationGroupPermission").select(sql`count(*)`.as("count")).where("documentId", "=", documentId).where("operationType", "=", operationType).executeTakeFirst();
|
|
5461
|
-
return groupPermCount !== void 0 && Number(groupPermCount.count) > 0;
|
|
5162
|
+
return userPermCount !== void 0 && Number(userPermCount.count) > 0;
|
|
5462
5163
|
}
|
|
5463
5164
|
/**
|
|
5464
5165
|
* Check if a specific document has a protection row set to true.
|
|
@@ -6234,4 +5935,4 @@ var PackageManagementService = class {
|
|
|
6234
5935
|
export { ADMIN_USERS, ActionContextInputSchema, ActionInputSchema, AddRelationshipDocument, AnalyticsSubgraph, AuthService, AuthSubgraph, AuthorizationPolicy, AuthorizedDocumentHandle, BaseSubgraph, ChannelMetaInputSchema, CreateDocumentDocument, CreateEmptyDocumentDocument, DeleteDocumentDocument, DeleteDocumentsDocument, DocumentChangeType, DocumentChangeTypeSchema, DocumentChangesDocument, DocumentOperationsFilterInputSchema, DocumentPermissionService, FindDocumentsDocument, GetDocumentDocument, GetDocumentIncomingRelationshipsDocument, GetDocumentModelsDocument, GetDocumentOperationsDocument, GetDocumentOutgoingRelationshipsDocument, GetDocumentWithOperationsDocument, GetJobStatusDocument, GraphQLManager, HttpDocumentModelLoader, HttpPackageLoader, ImportPackageLoader, InMemoryPackageStorage, JobChangesDocument, MoveRelationshipDocument, MutateDocumentAsyncDocument, MutateDocumentDocument, OperationContextInputSchema, OperationInputSchema, OperationWithContextInputSchema, OperationsFilterInputSchema, PackageManagementService, PackageManager, PackagesSubgraph, PagingInputSchema, PhDocumentFieldsFragmentDoc, PollSyncEnvelopesDocument, PropagationMode, PropagationModeSchema, PushSyncEnvelopesDocument, ReactorSignerAppInputSchema, ReactorSignerInputSchema, ReactorSignerUserInputSchema, ReactorSubgraph, RemoteCursorInputSchema, RemoteFilterInputSchema, RemoveRelationshipDocument, RenameDocumentDocument, SearchFilterInputSchema, SetPreferredEditorDocument, SyncEnvelopeInputSchema, SyncEnvelopeType, SyncEnvelopeTypeSchema, SystemSubgraph, TouchChannelDocument, TouchChannelInputSchema, ViewFilterInputSchema, assertAuthRequiredForDocumentPermissions, assertSkipCredentialVerificationAllowed, buildGraphQlDocument, buildGraphQlDriveDocument, buildGraphqlOperation, buildGraphqlOperations, buildSubgraphSchemaModule, createAuthFetchMiddleware, createGatewayAdapter, createHttpAdapter, createMergedSchema, createReactorGraphQLClient, createSchema, definedNonNullAnySchema, driveIdFromUrl, extractSubgraphsFromModule, generateDocumentModelSchema, getAuthContext, getDbClient, getDocumentModelSchemaName, getDocumentModelTypeDefs, getGitHash, getGitUrl, getSdk, getUniqueDocumentModels, getVersion, initAnalyticsStoreSql, initializeAndStartAPI, isDefinedNonNullAny, isExpectedLoaderMiss, isSubgraphClass, parseDriveUrl, renderGraphqlPlayground };
|
|
6235
5936
|
|
|
6236
5937
|
//# sourceMappingURL=index.mjs.map
|
|
6237
|
-
//# debugId=
|
|
5938
|
+
//# debugId=907dd002-0f18-5e7a-aa9e-ad649cd5d408
|