@drodil/backstage-plugin-qeta-node 3.27.0 → 3.28.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.
@@ -22,19 +22,26 @@ class DefaultQetaPermissionPolicy {
22
22
  if (request.permission.attributes.action === "update" || request.permission.attributes.action === "delete") {
23
23
  if (pluginPermissionCommon.isResourcePermission(request.permission, backstagePluginQetaCommon.POST_RESOURCE_TYPE)) {
24
24
  return backstagePluginQetaNode.createPostConditionalDecision(request.permission, {
25
- allOf: [
25
+ anyOf: [
26
26
  // Can edit and delete own questions
27
27
  backstagePluginQetaNode.postAuthorConditionFactory({
28
28
  userRef: user.identity.userEntityRef
29
+ }),
30
+ // Can edit and delete if tag expert
31
+ backstagePluginQetaNode.postTagExpertConditionFactory({
32
+ userRef: user.identity.userEntityRef
29
33
  })
30
34
  ]
31
35
  });
32
36
  }
33
37
  if (pluginPermissionCommon.isResourcePermission(request.permission, backstagePluginQetaCommon.ANSWER_RESOURCE_TYPE)) {
34
38
  return backstagePluginQetaNode.createAnswerConditionalDecision(request.permission, {
35
- allOf: [
39
+ anyOf: [
36
40
  backstagePluginQetaNode.answerAuthorConditionFactory({
37
41
  userRef: user.identity.userEntityRef
42
+ }),
43
+ backstagePluginQetaNode.answerTagExpertConditionFactory({
44
+ userRef: user.identity.userEntityRef
38
45
  })
39
46
  ]
40
47
  });
@@ -50,9 +57,14 @@ class DefaultQetaPermissionPolicy {
50
57
  }
51
58
  if (pluginPermissionCommon.isResourcePermission(request.permission, backstagePluginQetaCommon.COLLECTION_RESOUCE_TYPE)) {
52
59
  return backstagePluginQetaNode.createCollectionConditionalDecision(request.permission, {
53
- allOf: [
60
+ anyOf: [
61
+ // Allow deleting and updating only own collections
54
62
  backstagePluginQetaNode.collectionOwnerConditionFactory({
55
63
  userRef: user.identity.userEntityRef
64
+ }),
65
+ // Allow deleting and updating if tag expert
66
+ backstagePluginQetaNode.collectionTagExpertConditionFactory({
67
+ userRef: user.identity.userEntityRef
56
68
  })
57
69
  ]
58
70
  });
@@ -1 +1 @@
1
- {"version":3,"file":"defaultPermissionPolicy.cjs.js","sources":["../src/defaultPermissionPolicy.ts"],"sourcesContent":["/*\n * SPDX-FileCopyrightText: Copyright 2024 OP Financial Group (https://op.fi). All Rights Reserved.\n * SPDX-License-Identifier: LicenseRef-OpAllRightsReserved\n */\nimport { BackstageIdentityResponse } from '@backstage/plugin-auth-node';\nimport {\n AuthorizeResult,\n isPermission,\n isResourcePermission,\n isUpdatePermission,\n PolicyDecision,\n} from '@backstage/plugin-permission-common';\nimport {\n PermissionPolicy,\n PolicyQuery,\n} from '@backstage/plugin-permission-node';\nimport {\n ANSWER_RESOURCE_TYPE,\n COLLECTION_RESOUCE_TYPE,\n COMMENT_RESOURCE_TYPE,\n POST_RESOURCE_TYPE,\n qetaModeratePermission,\n TAG_RESOURCE_TYPE,\n} from '@drodil/backstage-plugin-qeta-common';\nimport {\n answerAuthorConditionFactory,\n collectionOwnerConditionFactory,\n commentAuthorConditionFactory,\n createAnswerConditionalDecision,\n createCollectionConditionalDecision,\n createCommentConditionalDecision,\n createPostConditionalDecision,\n postAuthorConditionFactory,\n} from '@drodil/backstage-plugin-qeta-node';\nimport { Config } from '@backstage/config';\n\nexport class DefaultQetaPermissionPolicy implements PermissionPolicy {\n constructor(private readonly config?: Config) {}\n\n async handle(\n request: PolicyQuery,\n user?: BackstageIdentityResponse,\n ): Promise<PolicyDecision> {\n // We cannot do anything without a user\n if (!user) {\n return { result: AuthorizeResult.DENY };\n }\n\n // Moderators can modify anything\n const moderators =\n this.config?.getOptionalStringArray('qeta.moderators') ?? [];\n if (\n isPermission(request.permission, qetaModeratePermission) &&\n (moderators.includes(user.identity.userEntityRef) ||\n user.identity.ownershipEntityRefs.some(ref => moderators.includes(ref)))\n ) {\n return { result: AuthorizeResult.ALLOW };\n }\n\n if (\n request.permission.attributes.action === 'create' ||\n request.permission.attributes.action === 'read'\n ) {\n return { result: AuthorizeResult.ALLOW };\n }\n\n // Allow updating and deleting only own posts/answers/comments\n if (\n request.permission.attributes.action === 'update' ||\n request.permission.attributes.action === 'delete'\n ) {\n if (isResourcePermission(request.permission, POST_RESOURCE_TYPE)) {\n return createPostConditionalDecision(request.permission, {\n allOf: [\n // Can edit and delete own questions\n postAuthorConditionFactory({\n userRef: user.identity.userEntityRef,\n }),\n ],\n });\n }\n\n if (isResourcePermission(request.permission, ANSWER_RESOURCE_TYPE)) {\n return createAnswerConditionalDecision(request.permission, {\n allOf: [\n answerAuthorConditionFactory({\n userRef: user.identity.userEntityRef,\n }),\n ],\n });\n }\n\n // Allow deleting and updating only own comments\n if (isResourcePermission(request.permission, COMMENT_RESOURCE_TYPE)) {\n return createCommentConditionalDecision(request.permission, {\n allOf: [\n commentAuthorConditionFactory({\n userRef: user.identity.userEntityRef,\n }),\n ],\n });\n }\n\n // Allow deleting and updating only own collections\n if (isResourcePermission(request.permission, COLLECTION_RESOUCE_TYPE)) {\n return createCollectionConditionalDecision(request.permission, {\n allOf: [\n collectionOwnerConditionFactory({\n userRef: user.identity.userEntityRef,\n }),\n ],\n });\n }\n\n // Allow updating any tag by anyone\n if (\n isResourcePermission(request.permission, TAG_RESOURCE_TYPE) &&\n isUpdatePermission(request.permission)\n ) {\n return { result: AuthorizeResult.ALLOW };\n }\n }\n\n return { result: AuthorizeResult.DENY };\n }\n}\n"],"names":["AuthorizeResult","isPermission","qetaModeratePermission","isResourcePermission","POST_RESOURCE_TYPE","createPostConditionalDecision","postAuthorConditionFactory","ANSWER_RESOURCE_TYPE","createAnswerConditionalDecision","answerAuthorConditionFactory","COMMENT_RESOURCE_TYPE","createCommentConditionalDecision","commentAuthorConditionFactory","COLLECTION_RESOUCE_TYPE","createCollectionConditionalDecision","collectionOwnerConditionFactory","TAG_RESOURCE_TYPE","isUpdatePermission"],"mappings":";;;;;;AAoCO,MAAM,2BAAwD,CAAA;AAAA,EACnE,YAA6B,MAAiB,EAAA;AAAjB,IAAA,IAAA,CAAA,M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8CAAoB,CAAG,EAAA;AAClE,QAAO,OAAAC,uDAAA,CAAgC,QAAQ,UAAY,EAAA;AAAA,UACzD,KAAO,EAAA;AAAA,YACLC,oDAA6B,CAAA;AAAA,cAC3B,OAAA,EAAS,KAAK,QAAS,CAAA;AAAA,aACxB;AAAA;AACH,SACD,CAAA;AAAA;AAIH,MAAA,IAAIN,2CAAqB,CAAA,OAAA,CAAQ,UAAY,EAAAO,+CAAqB,CAAG,EAAA;AACnE,QAAO,OAAAC,wDAAA,CAAiC,QAAQ,UAAY,EAAA;AAAA,UAC1D,KAAO,EAAA;AAAA,YACLC,qDAA8B,CAAA;AAAA,cAC5B,OAAA,EAAS,KAAK,QAAS,CAAA;AAAA,aACxB;AAAA;AACH,SACD,CAAA;AAAA;AAIH,MAAA,IAAIT,2CAAqB,CAAA,OAAA,CAAQ,UAAY,EAAAU,iDAAuB,CAAG,EAAA;AACrE,QAAO,OAAAC,2DAAA,CAAoC,QAAQ,UAAY,EAAA;AAAA,UAC7D,KAAO,EAAA;AAAA,YACLC,uDAAgC,CAAA;AAAA,cAC9B,OAAA,EAAS,KAAK,QAAS,CAAA;AAAA,aACxB;AAAA;AACH,SACD,CAAA;AAAA;AAIH,MACE,IAAAZ,2CAAA,CAAqB,QAAQ,UAAY,EAAAa,2CAAiB,KAC1DC,yCAAmB,CAAA,OAAA,CAAQ,UAAU,CACrC,EAAA;AACA,QAAO,OAAA,EAAE,MAAQ,EAAAjB,sCAAA,CAAgB,KAAM,EAAA;AAAA;AACzC;AAGF,IAAO,OAAA,EAAE,MAAQ,EAAAA,sCAAA,CAAgB,IAAK,EAAA;AAAA;AAE1C;;;;"}
1
+ {"version":3,"file":"defaultPermissionPolicy.cjs.js","sources":["../src/defaultPermissionPolicy.ts"],"sourcesContent":["/*\n * SPDX-FileCopyrightText: Copyright 2024 OP Financial Group (https://op.fi). All Rights Reserved.\n * SPDX-License-Identifier: LicenseRef-OpAllRightsReserved\n */\nimport { BackstageIdentityResponse } from '@backstage/plugin-auth-node';\nimport {\n AuthorizeResult,\n isPermission,\n isResourcePermission,\n isUpdatePermission,\n PolicyDecision,\n} from '@backstage/plugin-permission-common';\nimport {\n PermissionPolicy,\n PolicyQuery,\n} from '@backstage/plugin-permission-node';\nimport {\n ANSWER_RESOURCE_TYPE,\n COLLECTION_RESOUCE_TYPE,\n COMMENT_RESOURCE_TYPE,\n POST_RESOURCE_TYPE,\n qetaModeratePermission,\n TAG_RESOURCE_TYPE,\n} from '@drodil/backstage-plugin-qeta-common';\nimport {\n answerAuthorConditionFactory,\n answerTagExpertConditionFactory,\n collectionOwnerConditionFactory,\n collectionTagExpertConditionFactory,\n commentAuthorConditionFactory,\n createAnswerConditionalDecision,\n createCollectionConditionalDecision,\n createCommentConditionalDecision,\n createPostConditionalDecision,\n postAuthorConditionFactory,\n postTagExpertConditionFactory,\n} from '@drodil/backstage-plugin-qeta-node';\nimport { Config } from '@backstage/config';\n\nexport class DefaultQetaPermissionPolicy implements PermissionPolicy {\n constructor(private readonly config?: Config) {}\n\n async handle(\n request: PolicyQuery,\n user?: BackstageIdentityResponse,\n ): Promise<PolicyDecision> {\n // We cannot do anything without a user\n if (!user) {\n return { result: AuthorizeResult.DENY };\n }\n\n // Moderators can modify anything\n const moderators =\n this.config?.getOptionalStringArray('qeta.moderators') ?? [];\n if (\n isPermission(request.permission, qetaModeratePermission) &&\n (moderators.includes(user.identity.userEntityRef) ||\n user.identity.ownershipEntityRefs.some(ref => moderators.includes(ref)))\n ) {\n return { result: AuthorizeResult.ALLOW };\n }\n\n if (\n request.permission.attributes.action === 'create' ||\n request.permission.attributes.action === 'read'\n ) {\n return { result: AuthorizeResult.ALLOW };\n }\n\n if (\n request.permission.attributes.action === 'update' ||\n request.permission.attributes.action === 'delete'\n ) {\n if (isResourcePermission(request.permission, POST_RESOURCE_TYPE)) {\n return createPostConditionalDecision(request.permission, {\n anyOf: [\n // Can edit and delete own questions\n postAuthorConditionFactory({\n userRef: user.identity.userEntityRef,\n }),\n // Can edit and delete if tag expert\n postTagExpertConditionFactory({\n userRef: user.identity.userEntityRef,\n }),\n ],\n });\n }\n\n if (isResourcePermission(request.permission, ANSWER_RESOURCE_TYPE)) {\n return createAnswerConditionalDecision(request.permission, {\n anyOf: [\n answerAuthorConditionFactory({\n userRef: user.identity.userEntityRef,\n }),\n answerTagExpertConditionFactory({\n userRef: user.identity.userEntityRef,\n }),\n ],\n });\n }\n\n // Allow deleting and updating only own comments\n if (isResourcePermission(request.permission, COMMENT_RESOURCE_TYPE)) {\n return createCommentConditionalDecision(request.permission, {\n allOf: [\n commentAuthorConditionFactory({\n userRef: user.identity.userEntityRef,\n }),\n ],\n });\n }\n\n if (isResourcePermission(request.permission, COLLECTION_RESOUCE_TYPE)) {\n return createCollectionConditionalDecision(request.permission, {\n anyOf: [\n // Allow deleting and updating only own collections\n collectionOwnerConditionFactory({\n userRef: user.identity.userEntityRef,\n }),\n // Allow deleting and updating if tag expert\n collectionTagExpertConditionFactory({\n userRef: user.identity.userEntityRef,\n }),\n ],\n });\n }\n\n // Allow updating any tag by anyone\n if (\n isResourcePermission(request.permission, TAG_RESOURCE_TYPE) &&\n isUpdatePermission(request.permission)\n ) {\n return { result: AuthorizeResult.ALLOW };\n }\n }\n\n return { result: AuthorizeResult.DENY };\n }\n}\n"],"names":["AuthorizeResult","isPermission","qetaModeratePermission","isResourcePermission","POST_RESOURCE_TYPE","createPostConditionalDecision","postAuthorConditionFactory","postTagExpertConditionFactory","ANSWER_RESOURCE_TYPE","createAnswerConditionalDecision","answerAuthorConditionFactory","answerTagExpertConditionFactory","COMMENT_RESOURCE_TYPE","createCommentConditionalDecision","commentAuthorConditionFactory","COLLECTION_RESOUCE_TYPE","createCollectionConditionalDecision","collectionOwnerConditionFactory","collectionTagExpertConditionFactory","TAG_RESOURCE_TYPE","isUpdatePermission"],"mappings":";;;;;;AAuCO,MAAM,2BAAwD,CAAA;AAAA,EACnE,YAA6B,MAAiB,EAAA;AAAjB,IAAA,IAAA,CAAA,MAA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AA,EAAE,MAAQ,EAAAA,sCAAA,CAAgB,IAAK,EAAA;AAAA;AAE1C;;;;"}
package/dist/index.cjs.js CHANGED
@@ -16,18 +16,23 @@ exports.answerQuestionHasEntityRefs = permissionRules.answerQuestionHasEntityRef
16
16
  exports.answerQuestionHasTags = permissionRules.answerQuestionHasTags;
17
17
  exports.answerQuestionTagsConditionFactory = permissionRules.answerQuestionTagsConditionFactory;
18
18
  exports.answerRules = permissionRules.answerRules;
19
+ exports.answerTagExpertConditionFactory = permissionRules.answerTagExpertConditionFactory;
19
20
  exports.collectionHasEntities = permissionRules.collectionHasEntities;
20
21
  exports.collectionHasEntitiesConditionFactory = permissionRules.collectionHasEntitiesConditionFactory;
21
22
  exports.collectionHasTags = permissionRules.collectionHasTags;
22
23
  exports.collectionHasTagsConditionFactory = permissionRules.collectionHasTagsConditionFactory;
23
24
  exports.collectionOwnerConditionFactory = permissionRules.collectionOwnerConditionFactory;
24
25
  exports.collectionRules = permissionRules.collectionRules;
26
+ exports.collectionTagExpertConditionFactory = permissionRules.collectionTagExpertConditionFactory;
25
27
  exports.commentAuthorConditionFactory = permissionRules.commentAuthorConditionFactory;
26
28
  exports.commentRules = permissionRules.commentRules;
27
29
  exports.isAnswerAuthor = permissionRules.isAnswerAuthor;
30
+ exports.isAnswerTagExpert = permissionRules.isAnswerTagExpert;
28
31
  exports.isCollectionOwner = permissionRules.isCollectionOwner;
32
+ exports.isCollectionTagExpert = permissionRules.isCollectionTagExpert;
29
33
  exports.isCommentAuthor = permissionRules.isCommentAuthor;
30
34
  exports.isPostAuthor = permissionRules.isPostAuthor;
35
+ exports.isPostTagExpert = permissionRules.isPostTagExpert;
31
36
  exports.isTag = permissionRules.isTag;
32
37
  exports.isTagExpert = permissionRules.isTagExpert;
33
38
  exports.postAuthorConditionFactory = permissionRules.postAuthorConditionFactory;
@@ -38,6 +43,7 @@ exports.postHasTagsConditionFactory = permissionRules.postHasTagsConditionFactor
38
43
  exports.postHasType = permissionRules.postHasType;
39
44
  exports.postHasTypeConditionFactory = permissionRules.postHasTypeConditionFactory;
40
45
  exports.postRules = permissionRules.postRules;
46
+ exports.postTagExpertConditionFactory = permissionRules.postTagExpertConditionFactory;
41
47
  exports.rules = permissionRules.rules;
42
48
  exports.tagConditionFactory = permissionRules.tagConditionFactory;
43
49
  exports.tagExpertConditionFactory = permissionRules.tagExpertConditionFactory;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.d.ts CHANGED
@@ -101,6 +101,17 @@ declare const postHasTypeConditionFactory: (params: {
101
101
  }) => _backstage_plugin_permission_common.PermissionCondition<"post", {
102
102
  type: string;
103
103
  }>;
104
+ declare const isPostTagExpert: _backstage_plugin_permission_node.PermissionRule<Post, PostFilter, "post", {
105
+ userRef?: string | undefined;
106
+ claims?: string[] | undefined;
107
+ }>;
108
+ declare const postTagExpertConditionFactory: (params: {
109
+ userRef?: string | undefined;
110
+ claims?: string[] | undefined;
111
+ }) => _backstage_plugin_permission_common.PermissionCondition<"post", {
112
+ userRef?: string | undefined;
113
+ claims?: string[] | undefined;
114
+ }>;
104
115
  declare const postRules: {
105
116
  isPostAuthor: _backstage_plugin_permission_node.PermissionRule<Post, PostFilter, "post", {
106
117
  userRef?: string | undefined;
@@ -115,6 +126,10 @@ declare const postRules: {
115
126
  postHasType: _backstage_plugin_permission_node.PermissionRule<Post, PostFilter, "post", {
116
127
  type: string;
117
128
  }>;
129
+ isPostTagExpert: _backstage_plugin_permission_node.PermissionRule<Post, PostFilter, "post", {
130
+ userRef?: string | undefined;
131
+ claims?: string[] | undefined;
132
+ }>;
118
133
  };
119
134
  declare const isAnswerAuthor: _backstage_plugin_permission_node.PermissionRule<Answer, AnswerFilter, "answer", {
120
135
  userRef?: string | undefined;
@@ -143,6 +158,17 @@ declare const answerQuestionEntitiesConditionFactory: (params: {
143
158
  }) => _backstage_plugin_permission_common.PermissionCondition<"answer", {
144
159
  entityRefs: string[];
145
160
  }>;
161
+ declare const isAnswerTagExpert: _backstage_plugin_permission_node.PermissionRule<Answer, AnswerFilter, "answer", {
162
+ userRef?: string | undefined;
163
+ claims?: string[] | undefined;
164
+ }>;
165
+ declare const answerTagExpertConditionFactory: (params: {
166
+ userRef?: string | undefined;
167
+ claims?: string[] | undefined;
168
+ }) => _backstage_plugin_permission_common.PermissionCondition<"answer", {
169
+ userRef?: string | undefined;
170
+ claims?: string[] | undefined;
171
+ }>;
146
172
  declare const answerRules: {
147
173
  isAnswerAuthor: _backstage_plugin_permission_node.PermissionRule<Answer, AnswerFilter, "answer", {
148
174
  userRef?: string | undefined;
@@ -154,6 +180,10 @@ declare const answerRules: {
154
180
  answerQuestionHasEntityRefs: _backstage_plugin_permission_node.PermissionRule<Answer, AnswerFilter, "answer", {
155
181
  entityRefs: string[];
156
182
  }>;
183
+ isAnswerTagExpert: _backstage_plugin_permission_node.PermissionRule<Answer, AnswerFilter, "answer", {
184
+ userRef?: string | undefined;
185
+ claims?: string[] | undefined;
186
+ }>;
157
187
  };
158
188
  declare const isCommentAuthor: _backstage_plugin_permission_node.PermissionRule<Comment, CommentFilter, "comment", {
159
189
  userRef?: string | undefined;
@@ -227,6 +257,17 @@ declare const collectionHasEntitiesConditionFactory: (params: {
227
257
  }) => _backstage_plugin_permission_common.PermissionCondition<"collection", {
228
258
  entityRefs: string[];
229
259
  }>;
260
+ declare const isCollectionTagExpert: _backstage_plugin_permission_node.PermissionRule<Collection, CollectionFilter, "collection", {
261
+ userRef?: string | undefined;
262
+ claims?: string[] | undefined;
263
+ }>;
264
+ declare const collectionTagExpertConditionFactory: (params: {
265
+ userRef?: string | undefined;
266
+ claims?: string[] | undefined;
267
+ }) => _backstage_plugin_permission_common.PermissionCondition<"collection", {
268
+ userRef?: string | undefined;
269
+ claims?: string[] | undefined;
270
+ }>;
230
271
  declare const collectionRules: {
231
272
  isCollectionOwner: _backstage_plugin_permission_node.PermissionRule<Collection, CollectionFilter, "collection", {
232
273
  userRef?: string | undefined;
@@ -238,6 +279,10 @@ declare const collectionRules: {
238
279
  collectionHasEntities: _backstage_plugin_permission_node.PermissionRule<Collection, CollectionFilter, "collection", {
239
280
  entityRefs: string[];
240
281
  }>;
282
+ isCollectionTagExpert: _backstage_plugin_permission_node.PermissionRule<Collection, CollectionFilter, "collection", {
283
+ userRef?: string | undefined;
284
+ claims?: string[] | undefined;
285
+ }>;
241
286
  };
242
287
  declare const rules: {
243
288
  isCollectionOwner: _backstage_plugin_permission_node.PermissionRule<Collection, CollectionFilter, "collection", {
@@ -250,6 +295,10 @@ declare const rules: {
250
295
  collectionHasEntities: _backstage_plugin_permission_node.PermissionRule<Collection, CollectionFilter, "collection", {
251
296
  entityRefs: string[];
252
297
  }>;
298
+ isCollectionTagExpert: _backstage_plugin_permission_node.PermissionRule<Collection, CollectionFilter, "collection", {
299
+ userRef?: string | undefined;
300
+ claims?: string[] | undefined;
301
+ }>;
253
302
  isTag: _backstage_plugin_permission_node.PermissionRule<TagResponse, TagFilter, "tag", {
254
303
  tag: string;
255
304
  }>;
@@ -270,6 +319,10 @@ declare const rules: {
270
319
  postHasType: _backstage_plugin_permission_node.PermissionRule<Post, PostFilter, "post", {
271
320
  type: string;
272
321
  }>;
322
+ isPostTagExpert: _backstage_plugin_permission_node.PermissionRule<Post, PostFilter, "post", {
323
+ userRef?: string | undefined;
324
+ claims?: string[] | undefined;
325
+ }>;
273
326
  isAnswerAuthor: _backstage_plugin_permission_node.PermissionRule<Answer, AnswerFilter, "answer", {
274
327
  userRef?: string | undefined;
275
328
  claims?: string[] | undefined;
@@ -280,6 +333,10 @@ declare const rules: {
280
333
  answerQuestionHasEntityRefs: _backstage_plugin_permission_node.PermissionRule<Answer, AnswerFilter, "answer", {
281
334
  entityRefs: string[];
282
335
  }>;
336
+ isAnswerTagExpert: _backstage_plugin_permission_node.PermissionRule<Answer, AnswerFilter, "answer", {
337
+ userRef?: string | undefined;
338
+ claims?: string[] | undefined;
339
+ }>;
283
340
  isCommentAuthor: _backstage_plugin_permission_node.PermissionRule<Comment, CommentFilter, "comment", {
284
341
  userRef?: string | undefined;
285
342
  claims?: string[] | undefined;
@@ -300,6 +357,10 @@ declare const questionConditions: _backstage_plugin_permission_node.Conditions<{
300
357
  postHasType: _backstage_plugin_permission_node.PermissionRule<_drodil_backstage_plugin_qeta_common.Post, _drodil_backstage_plugin_qeta_common.PostFilter, "post", {
301
358
  type: string;
302
359
  }>;
360
+ isPostTagExpert: _backstage_plugin_permission_node.PermissionRule<_drodil_backstage_plugin_qeta_common.Post, _drodil_backstage_plugin_qeta_common.PostFilter, "post", {
361
+ userRef?: string | undefined;
362
+ claims?: string[] | undefined;
363
+ }>;
303
364
  }>;
304
365
  declare const createPostConditionalDecision: (permission: _backstage_plugin_permission_common.ResourcePermission<"post">, conditions: _backstage_plugin_permission_common.PermissionCriteria<_backstage_plugin_permission_common.PermissionCondition<"post">>) => _backstage_plugin_permission_common.ConditionalPolicyDecision;
305
366
  declare const answerConditions: _backstage_plugin_permission_node.Conditions<{
@@ -313,6 +374,10 @@ declare const answerConditions: _backstage_plugin_permission_node.Conditions<{
313
374
  answerQuestionHasEntityRefs: _backstage_plugin_permission_node.PermissionRule<_drodil_backstage_plugin_qeta_common.Answer, _drodil_backstage_plugin_qeta_common.AnswerFilter, "answer", {
314
375
  entityRefs: string[];
315
376
  }>;
377
+ isAnswerTagExpert: _backstage_plugin_permission_node.PermissionRule<_drodil_backstage_plugin_qeta_common.Answer, _drodil_backstage_plugin_qeta_common.AnswerFilter, "answer", {
378
+ userRef?: string | undefined;
379
+ claims?: string[] | undefined;
380
+ }>;
316
381
  }>;
317
382
  declare const createAnswerConditionalDecision: (permission: _backstage_plugin_permission_common.ResourcePermission<"answer">, conditions: _backstage_plugin_permission_common.PermissionCriteria<_backstage_plugin_permission_common.PermissionCondition<"answer">>) => _backstage_plugin_permission_common.ConditionalPolicyDecision;
318
383
  declare const commentConditions: _backstage_plugin_permission_node.Conditions<{
@@ -343,6 +408,10 @@ declare const collectionConditions: _backstage_plugin_permission_node.Conditions
343
408
  collectionHasEntities: _backstage_plugin_permission_node.PermissionRule<_drodil_backstage_plugin_qeta_common.Collection, _drodil_backstage_plugin_qeta_common.CollectionFilter, "collection", {
344
409
  entityRefs: string[];
345
410
  }>;
411
+ isCollectionTagExpert: _backstage_plugin_permission_node.PermissionRule<_drodil_backstage_plugin_qeta_common.Collection, _drodil_backstage_plugin_qeta_common.CollectionFilter, "collection", {
412
+ userRef?: string | undefined;
413
+ claims?: string[] | undefined;
414
+ }>;
346
415
  }>;
347
416
  declare const createCollectionConditionalDecision: (permission: _backstage_plugin_permission_common.ResourcePermission<"collection">, conditions: _backstage_plugin_permission_common.PermissionCriteria<_backstage_plugin_permission_common.PermissionCondition<"collection">>) => _backstage_plugin_permission_common.ConditionalPolicyDecision;
348
417
 
@@ -358,4 +427,4 @@ declare class DefaultQetaPermissionPolicy implements PermissionPolicy {
358
427
  handle(request: PolicyQuery, user?: BackstageIdentityResponse): Promise<PolicyDecision>;
359
428
  }
360
429
 
361
- export { type AIHandler, DefaultQetaPermissionPolicy, type QetaAIExtensionPoint, type QetaTagDatabaseExtensionPoint, type TagDatabase, answerAuthorConditionFactory, answerConditions, answerPermissionResourceRef, answerQuestionEntitiesConditionFactory, answerQuestionHasEntityRefs, answerQuestionHasTags, answerQuestionTagsConditionFactory, answerRules, collectionConditions, collectionHasEntities, collectionHasEntitiesConditionFactory, collectionHasTags, collectionHasTagsConditionFactory, collectionOwnerConditionFactory, collectionPermissionResourceRef, collectionRules, commentAuthorConditionFactory, commentConditions, commentPermissionResourceRef, commentRules, createAnswerConditionalDecision, createCollectionConditionalDecision, createCommentConditionalDecision, createPostConditionalDecision, createTagConditionalDecision, isAnswerAuthor, isCollectionOwner, isCommentAuthor, isPostAuthor, isTag, isTagExpert, postAuthorConditionFactory, postHasEntities, postHasEntitiesConditionFactory, postHasTags, postHasTagsConditionFactory, postHasType, postHasTypeConditionFactory, postPermissionResourceRef, postRules, qetaAIExtensionPoint, qetaTagDatabaseExtensionPoint, questionConditions, rules, tagConditionFactory, tagConditions, tagExpertConditionFactory, tagPermissionResourceRef, tagRules };
430
+ export { type AIHandler, DefaultQetaPermissionPolicy, type QetaAIExtensionPoint, type QetaTagDatabaseExtensionPoint, type TagDatabase, answerAuthorConditionFactory, answerConditions, answerPermissionResourceRef, answerQuestionEntitiesConditionFactory, answerQuestionHasEntityRefs, answerQuestionHasTags, answerQuestionTagsConditionFactory, answerRules, answerTagExpertConditionFactory, collectionConditions, collectionHasEntities, collectionHasEntitiesConditionFactory, collectionHasTags, collectionHasTagsConditionFactory, collectionOwnerConditionFactory, collectionPermissionResourceRef, collectionRules, collectionTagExpertConditionFactory, commentAuthorConditionFactory, commentConditions, commentPermissionResourceRef, commentRules, createAnswerConditionalDecision, createCollectionConditionalDecision, createCommentConditionalDecision, createPostConditionalDecision, createTagConditionalDecision, isAnswerAuthor, isAnswerTagExpert, isCollectionOwner, isCollectionTagExpert, isCommentAuthor, isPostAuthor, isPostTagExpert, isTag, isTagExpert, postAuthorConditionFactory, postHasEntities, postHasEntitiesConditionFactory, postHasTags, postHasTagsConditionFactory, postHasType, postHasTypeConditionFactory, postPermissionResourceRef, postRules, postTagExpertConditionFactory, qetaAIExtensionPoint, qetaTagDatabaseExtensionPoint, questionConditions, rules, tagConditionFactory, tagConditions, tagExpertConditionFactory, tagPermissionResourceRef, tagRules };
@@ -77,11 +77,33 @@ const postHasType = pluginPermissionNode.createPermissionRule({
77
77
  }
78
78
  });
79
79
  const postHasTypeConditionFactory = pluginPermissionNode.createConditionFactory(postHasType);
80
+ const isPostTagExpert = pluginPermissionNode.createPermissionRule({
81
+ name: "IS_POST_TAG_EXPERT",
82
+ description: "Allows if post has tags the user is expert of",
83
+ resourceRef: permissionResources.postPermissionResourceRef,
84
+ paramsSchema: zod.z.object({
85
+ userRef: zod.z.string().describe("User ID to match on the tag expert").optional(),
86
+ claims: zod.z.array(zod.z.string()).optional().describe("List of claims to match at least one on within tag expert")
87
+ }),
88
+ apply: (resource, { userRef, claims }) => {
89
+ return Boolean(
90
+ resource?.experts?.some((e) => e === userRef || claims?.includes(e))
91
+ );
92
+ },
93
+ toQuery: ({ claims = [], userRef }) => {
94
+ return {
95
+ property: "tag.experts",
96
+ values: [userRef, ...claims].filter(Boolean)
97
+ };
98
+ }
99
+ });
100
+ const postTagExpertConditionFactory = pluginPermissionNode.createConditionFactory(isPostTagExpert);
80
101
  const postRules = {
81
102
  isPostAuthor,
82
103
  postHasTags,
83
104
  postHasEntities,
84
- postHasType
105
+ postHasType,
106
+ isPostTagExpert
85
107
  };
86
108
  const isAnswerAuthor = pluginPermissionNode.createPermissionRule({
87
109
  name: "IS_AUTHOR",
@@ -142,10 +164,32 @@ const answerQuestionHasEntityRefs = pluginPermissionNode.createPermissionRule({
142
164
  const answerQuestionEntitiesConditionFactory = pluginPermissionNode.createConditionFactory(
143
165
  answerQuestionHasEntityRefs
144
166
  );
167
+ const isAnswerTagExpert = pluginPermissionNode.createPermissionRule({
168
+ name: "IS_ANSWER_TAG_EXPERT",
169
+ description: "Allows if answers post has tags the user is expert of",
170
+ resourceRef: permissionResources.answerPermissionResourceRef,
171
+ paramsSchema: zod.z.object({
172
+ userRef: zod.z.string().describe("User ID to match on the tag expert").optional(),
173
+ claims: zod.z.array(zod.z.string()).optional().describe("List of claims to match at least one on within tag expert")
174
+ }),
175
+ apply: (resource, { userRef, claims }) => {
176
+ return Boolean(
177
+ resource?.experts?.some((e) => e === userRef || claims?.includes(e))
178
+ );
179
+ },
180
+ toQuery: ({ claims = [], userRef }) => {
181
+ return {
182
+ property: "tag.experts",
183
+ values: [userRef, ...claims].filter(Boolean)
184
+ };
185
+ }
186
+ });
187
+ const answerTagExpertConditionFactory = pluginPermissionNode.createConditionFactory(isAnswerTagExpert);
145
188
  const answerRules = {
146
189
  isAnswerAuthor,
147
190
  answerQuestionHasTags,
148
- answerQuestionHasEntityRefs
191
+ answerQuestionHasEntityRefs,
192
+ isAnswerTagExpert
149
193
  };
150
194
  const isCommentAuthor = pluginPermissionNode.createPermissionRule({
151
195
  name: "IS_AUTHOR",
@@ -264,10 +308,34 @@ const collectionHasEntities = pluginPermissionNode.createPermissionRule({
264
308
  const collectionHasEntitiesConditionFactory = pluginPermissionNode.createConditionFactory(
265
309
  collectionHasEntities
266
310
  );
311
+ const isCollectionTagExpert = pluginPermissionNode.createPermissionRule({
312
+ name: "IS_COLLECTION_TAG_EXPERT",
313
+ description: "Allows if collection has tags the user is expert of",
314
+ resourceRef: permissionResources.collectionPermissionResourceRef,
315
+ paramsSchema: zod.z.object({
316
+ userRef: zod.z.string().describe("User ID to match on the tag expert").optional(),
317
+ claims: zod.z.array(zod.z.string()).optional().describe("List of claims to match at least one on within tag expert")
318
+ }),
319
+ apply: (resource, { userRef, claims }) => {
320
+ return Boolean(
321
+ resource?.experts?.some((e) => e === userRef || claims?.includes(e))
322
+ );
323
+ },
324
+ toQuery: ({ claims = [], userRef }) => {
325
+ return {
326
+ property: "tag.experts",
327
+ values: [userRef, ...claims].filter(Boolean)
328
+ };
329
+ }
330
+ });
331
+ const collectionTagExpertConditionFactory = pluginPermissionNode.createConditionFactory(
332
+ isCollectionTagExpert
333
+ );
267
334
  const collectionRules = {
268
335
  isCollectionOwner,
269
336
  collectionHasTags,
270
- collectionHasEntities
337
+ collectionHasEntities,
338
+ isCollectionTagExpert
271
339
  };
272
340
  const rules = {
273
341
  ...commentRules,
@@ -283,18 +351,23 @@ exports.answerQuestionHasEntityRefs = answerQuestionHasEntityRefs;
283
351
  exports.answerQuestionHasTags = answerQuestionHasTags;
284
352
  exports.answerQuestionTagsConditionFactory = answerQuestionTagsConditionFactory;
285
353
  exports.answerRules = answerRules;
354
+ exports.answerTagExpertConditionFactory = answerTagExpertConditionFactory;
286
355
  exports.collectionHasEntities = collectionHasEntities;
287
356
  exports.collectionHasEntitiesConditionFactory = collectionHasEntitiesConditionFactory;
288
357
  exports.collectionHasTags = collectionHasTags;
289
358
  exports.collectionHasTagsConditionFactory = collectionHasTagsConditionFactory;
290
359
  exports.collectionOwnerConditionFactory = collectionOwnerConditionFactory;
291
360
  exports.collectionRules = collectionRules;
361
+ exports.collectionTagExpertConditionFactory = collectionTagExpertConditionFactory;
292
362
  exports.commentAuthorConditionFactory = commentAuthorConditionFactory;
293
363
  exports.commentRules = commentRules;
294
364
  exports.isAnswerAuthor = isAnswerAuthor;
365
+ exports.isAnswerTagExpert = isAnswerTagExpert;
295
366
  exports.isCollectionOwner = isCollectionOwner;
367
+ exports.isCollectionTagExpert = isCollectionTagExpert;
296
368
  exports.isCommentAuthor = isCommentAuthor;
297
369
  exports.isPostAuthor = isPostAuthor;
370
+ exports.isPostTagExpert = isPostTagExpert;
298
371
  exports.isTag = isTag;
299
372
  exports.isTagExpert = isTagExpert;
300
373
  exports.postAuthorConditionFactory = postAuthorConditionFactory;
@@ -305,6 +378,7 @@ exports.postHasTagsConditionFactory = postHasTagsConditionFactory;
305
378
  exports.postHasType = postHasType;
306
379
  exports.postHasTypeConditionFactory = postHasTypeConditionFactory;
307
380
  exports.postRules = postRules;
381
+ exports.postTagExpertConditionFactory = postTagExpertConditionFactory;
308
382
  exports.rules = rules;
309
383
  exports.tagConditionFactory = tagConditionFactory;
310
384
  exports.tagExpertConditionFactory = tagExpertConditionFactory;
@@ -1 +1 @@
1
- {"version":3,"file":"permissionRules.cjs.js","sources":["../src/permissionRules.ts"],"sourcesContent":["import {\n createConditionFactory,\n createPermissionRule,\n} from '@backstage/plugin-permission-node';\nimport { z } from 'zod';\nimport {\n Answer,\n AnswerFilter,\n Collection,\n CollectionFilter,\n Comment,\n CommentFilter,\n Post,\n PostFilter,\n TagFilter,\n TagResponse,\n} from '@drodil/backstage-plugin-qeta-common';\nimport {\n answerPermissionResourceRef,\n collectionPermissionResourceRef,\n commentPermissionResourceRef,\n postPermissionResourceRef,\n tagPermissionResourceRef,\n} from './permissionResources';\n\nexport const isPostAuthor = createPermissionRule({\n name: 'IS_AUTHOR',\n description: 'Should allow only if the post is created by the user',\n resourceRef: postPermissionResourceRef,\n paramsSchema: z.object({\n userRef: z.string().describe('User ID to match on the author').optional(),\n claims: z\n .array(z.string())\n .optional()\n .describe('List of claims to match at least one on within author'),\n }),\n apply: (resource: Post, { userRef, claims = [] }) => {\n return resource?.author === userRef || claims.includes(resource?.author);\n },\n toQuery: ({ userRef, claims = [] }) => {\n return {\n property: 'posts.author' as PostFilter['property'],\n values: [userRef, ...claims].filter(Boolean),\n };\n },\n});\n\nexport const postAuthorConditionFactory = createConditionFactory(isPostAuthor);\n\nexport const postHasTags = createPermissionRule({\n name: 'HAS_TAGS',\n description: 'Should allow only if the post has all the specific tags',\n resourceRef: postPermissionResourceRef,\n paramsSchema: z.object({\n tags: z.array(z.string()).describe('Tag to match the post'),\n }),\n apply: (resource: Post, { tags }) => {\n return tags.every(t => resource?.tags?.includes(t));\n },\n toQuery: ({ tags }) => {\n return {\n property: 'tags' as PostFilter['property'],\n values: tags,\n };\n },\n});\n\nexport const postHasTagsConditionFactory = createConditionFactory(postHasTags);\n\nexport const postHasEntities = createPermissionRule({\n name: 'HAS_ENTITIES',\n description: 'Should allow only if the post has all the specific entities',\n resourceRef: postPermissionResourceRef,\n paramsSchema: z.object({\n entityRefs: z.array(z.string()).describe('Entity refs to match the post'),\n }),\n apply: (resource: Post, { entityRefs }) => {\n return entityRefs.every(t => resource?.entities?.includes(t));\n },\n toQuery: ({ entityRefs }) => {\n return {\n property: 'entityRefs' as PostFilter['property'],\n values: entityRefs,\n };\n },\n});\n\nexport const postHasEntitiesConditionFactory =\n createConditionFactory(postHasEntities);\n\nexport const postHasType = createPermissionRule({\n name: 'HAS_TYPE',\n description: 'Should allow only if the post has the specific type',\n resourceRef: postPermissionResourceRef,\n paramsSchema: z.object({\n type: z.string().describe('Type to match the post'),\n }),\n apply: (resource: Post, { type }) => {\n return resource?.type === type;\n },\n toQuery: ({ type }) => {\n return {\n property: 'posts.type' as PostFilter['property'],\n values: [type],\n };\n },\n});\n\nexport const postHasTypeConditionFactory = createConditionFactory(postHasType);\n\nexport const postRules = {\n isPostAuthor,\n postHasTags,\n postHasEntities,\n postHasType,\n};\n\nexport const isAnswerAuthor = createPermissionRule({\n name: 'IS_AUTHOR',\n description: 'Should allow only if the answer is created by the user',\n resourceRef: answerPermissionResourceRef,\n paramsSchema: z.object({\n userRef: z.string().describe('User ID to match on the author').optional(),\n claims: z\n .array(z.string())\n .optional()\n .describe('List of claims to match at least one on within author'),\n }),\n apply: (resource: Answer, { userRef, claims = [] }) => {\n return resource?.author === userRef || claims.includes(resource?.author);\n },\n toQuery: ({ userRef, claims = [] }) => {\n return {\n property: 'answers.author' as AnswerFilter['property'],\n values: [userRef, ...claims].filter(Boolean),\n };\n },\n});\n\nexport const answerAuthorConditionFactory =\n createConditionFactory(isAnswerAuthor);\n\nexport const answerQuestionHasTags = createPermissionRule({\n name: 'HAS_TAGS',\n description:\n 'Should allow only if the answers question has all the specific tags',\n resourceRef: answerPermissionResourceRef,\n paramsSchema: z.object({\n tags: z.array(z.string()).describe('Tag to match the question'),\n }),\n apply: (resource: Answer, { tags }) => {\n return tags.every(t => resource?.post?.tags?.includes(t));\n },\n toQuery: ({ tags }) => {\n return {\n property: 'tags' as AnswerFilter['property'],\n values: tags,\n };\n },\n});\n\nexport const answerQuestionTagsConditionFactory = createConditionFactory(\n answerQuestionHasTags,\n);\n\nexport const answerQuestionHasEntityRefs = createPermissionRule({\n name: 'HAS_ENTITIES',\n description:\n 'Should allow only if the answers question has all the specific entities',\n resourceRef: answerPermissionResourceRef,\n paramsSchema: z.object({\n entityRefs: z.array(z.string()).describe('Tag to match the question'),\n }),\n apply: (resource: Answer, { entityRefs }) => {\n return entityRefs.every(t => resource?.post?.entities?.includes(t));\n },\n toQuery: ({ entityRefs }) => {\n return {\n property: 'entityRefs' as AnswerFilter['property'],\n values: entityRefs,\n };\n },\n});\n\nexport const answerQuestionEntitiesConditionFactory = createConditionFactory(\n answerQuestionHasEntityRefs,\n);\n\nexport const answerRules = {\n isAnswerAuthor,\n answerQuestionHasTags,\n answerQuestionHasEntityRefs,\n};\n\nexport const isCommentAuthor = createPermissionRule({\n name: 'IS_AUTHOR',\n description: 'Should allow only if the comment is created by the user',\n resourceRef: commentPermissionResourceRef,\n paramsSchema: z.object({\n userRef: z.string().describe('User ID to match on the author').optional(),\n claims: z\n .array(z.string())\n .optional()\n .describe('List of claims to match at least one on within author'),\n }),\n apply: (resource: Comment, { userRef, claims = [] }) => {\n return resource?.author === userRef || claims.includes(resource?.author);\n },\n toQuery: ({ userRef, claims = [] }) => {\n return {\n property: 'comments.author' as CommentFilter['property'],\n values: [userRef, ...claims].filter(Boolean),\n };\n },\n});\n\nexport const commentAuthorConditionFactory =\n createConditionFactory(isCommentAuthor);\n\nexport const commentRules = { isCommentAuthor };\n\nexport const isTag = createPermissionRule({\n name: 'IS_TAG',\n description: 'Should allow only if the tag exists',\n resourceRef: tagPermissionResourceRef,\n paramsSchema: z.object({\n tag: z.string().describe('Tag to match the post'),\n }),\n apply: (resource: TagResponse, { tag }) => {\n return resource?.tag === tag;\n },\n toQuery: ({ tag }) => {\n return {\n property: 'tags.tag' as TagFilter['property'],\n values: [tag],\n };\n },\n});\n\nexport const tagConditionFactory = createConditionFactory(isTag);\n\nexport const isTagExpert = createPermissionRule({\n name: 'IS_TAG_EXPERT',\n description: 'Allows only if user is tag expert',\n resourceRef: tagPermissionResourceRef,\n paramsSchema: z.object({\n userRef: z\n .string()\n .describe('User ID to match on the tag expert')\n .optional(),\n claims: z\n .array(z.string())\n .optional()\n .describe('List of claims to match at least one on within tag expert'),\n }),\n apply: (resource: TagResponse, { userRef, claims }) => {\n return Boolean(\n resource?.experts?.some(e => e === userRef || claims?.includes(e)),\n );\n },\n toQuery: ({ claims = [], userRef }) => {\n return {\n property: 'tag.experts' as TagFilter['property'],\n values: [userRef, ...claims].filter(Boolean),\n };\n },\n});\n\nexport const tagExpertConditionFactory = createConditionFactory(isTagExpert);\n\nexport const tagRules = { isTag, isTagExpert };\n\nexport const isCollectionOwner = createPermissionRule({\n name: 'IS_OWNER',\n description: 'Should allow only if the collection is owned by the user',\n resourceRef: collectionPermissionResourceRef,\n paramsSchema: z.object({\n userRef: z\n .string()\n .describe('User reference to match on the owner')\n .optional(),\n claims: z\n .array(z.string())\n .optional()\n .describe('List of claims to match at least one on within owner'),\n }),\n apply: (resource: Collection, { userRef, claims = [] }) => {\n return resource?.owner === userRef || claims.includes(resource?.owner);\n },\n toQuery: ({ userRef, claims = [] }) => {\n return {\n property: 'collections.owner' as CollectionFilter['property'],\n values: [userRef, ...claims].filter(Boolean),\n };\n },\n});\n\nexport const collectionOwnerConditionFactory =\n createConditionFactory(isCollectionOwner);\n\nexport const collectionHasTags = createPermissionRule({\n name: 'HAS_TAGS',\n description:\n 'Should allow only if the posts in the collection have the specific tags',\n resourceRef: collectionPermissionResourceRef,\n paramsSchema: z.object({\n tags: z.array(z.string()).describe('Tag to match the collection'),\n }),\n apply: (resource: Collection, { tags }) => {\n return tags.every(t => resource?.tags?.includes(t));\n },\n toQuery: ({ tags }) => {\n return {\n property: 'tags' as CollectionFilter['property'],\n values: tags,\n };\n },\n});\n\nexport const collectionHasTagsConditionFactory =\n createConditionFactory(collectionHasTags);\n\nexport const collectionHasEntities = createPermissionRule({\n name: 'HAS_ENTITIES',\n description:\n 'Should allow only if the posts in the collection have the specific entities',\n resourceRef: collectionPermissionResourceRef,\n paramsSchema: z.object({\n entityRefs: z\n .array(z.string())\n .describe('Entity refs to match the collection'),\n }),\n apply: (resource: Collection, { entityRefs }) => {\n return entityRefs.every(t => resource?.entities?.includes(t));\n },\n toQuery: ({ entityRefs }) => {\n return {\n property: 'entityRefs' as CollectionFilter['property'],\n values: entityRefs,\n };\n },\n});\n\nexport const collectionHasEntitiesConditionFactory = createConditionFactory(\n collectionHasEntities,\n);\n\nexport const collectionRules = {\n isCollectionOwner,\n collectionHasTags,\n collectionHasEntities,\n};\n\nexport const rules = {\n ...commentRules,\n ...answerRules,\n ...postRules,\n ...tagRules,\n ...collectionRules,\n};\n"],"names":["createPermissionRule","postPermissionResourceRef","z","createConditionFactory","answerPermissionResourceRef","commentPermissionResourceRef","tagPermissionResourceRef","collectionPermissionResourceRef"],"mappings":";;;;;;AAyBO,MAAM,eAAeA,yCAAqB,CAAA;AAAA,EAC/C,IAAM,EAAA,WAAA;AAAA,EACN,WAAa,EAAA,sDAAA;AAAA,EACb,WAAa,EAAAC,6CAAA;AAAA,EACb,YAAA,EAAcC,MAAE,MAAO,CAAA;AAAA,IACrB,SAASA,KAAE,CAAA,MAAA,GAAS,QAAS,CAAA,gCAAgC,EAAE,QAAS,EAAA;AAAA,IACxE,MAAA,EAAQA,KACL,CAAA,KAAA,CAAMA,KAAE,CAAA,MAAA,EAAQ,CAChB,CAAA,QAAA,EACA,CAAA,QAAA,CAAS,uDAAuD;AAAA,GACpE,CAAA;AAAA,EACD,KAAA,EAAO,CAAC,QAAgB,EAAA,EAAE,SAAS,MAAS,GAAA,IAAS,KAAA;AACnD,IAAA,OAAO,UAAU,MAAW,KAAA,OAAA,IAAW,MAAO,CAAA,QAAA,CAAS,UAAU,MAAM,CAAA;AAAA,GACzE;AAAA,EACA,SAAS,CAAC,EAAE,SAAS,MAAS,GAAA,IAAS,KAAA;AACrC,IAAO,OAAA;AAAA,MACL,QAAU,EAAA,cAAA;AAAA,MACV,QAAQ,CAAC,OAAA,EAAS,GAAG,MAAM,CAAA,CAAE,OAAO,OAAO;AAAA,KAC7C;AAAA;AAEJ,CAAC;AAEY,MAAA,0BAAA,GAA6BC,4CAAuB,YAAY;AAEtE,MAAM,cAAcH,yCAAqB,CAAA;AAAA,EAC9C,IAAM,EAAA,UAAA;A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wC,GAAAC,2CAAA;AAAA,EACnD;AACF;AAEO,MAAM,eAAkB,GAAA;AAAA,EAC7B,iBAAA;AAAA,EACA,iBAAA;AAAA,EACA;AACF;AAEO,MAAM,KAAQ,GAAA;AAAA,EACnB,GAAG,YAAA;AAAA,EACH,GAAG,WAAA;AAAA,EACH,GAAG,SAAA;AAAA,EACH,GAAG,QAAA;AAAA,EACH,GAAG;AACL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"permissionRules.cjs.js","sources":["../src/permissionRules.ts"],"sourcesContent":["import {\n createConditionFactory,\n createPermissionRule,\n} from '@backstage/plugin-permission-node';\nimport { z } from 'zod';\nimport {\n Answer,\n AnswerFilter,\n Collection,\n CollectionFilter,\n Comment,\n CommentFilter,\n Post,\n PostFilter,\n TagFilter,\n TagResponse,\n} from '@drodil/backstage-plugin-qeta-common';\nimport {\n answerPermissionResourceRef,\n collectionPermissionResourceRef,\n commentPermissionResourceRef,\n postPermissionResourceRef,\n tagPermissionResourceRef,\n} from './permissionResources';\n\nexport const isPostAuthor = createPermissionRule({\n name: 'IS_AUTHOR',\n description: 'Should allow only if the post is created by the user',\n resourceRef: postPermissionResourceRef,\n paramsSchema: z.object({\n userRef: z.string().describe('User ID to match on the author').optional(),\n claims: z\n .array(z.string())\n .optional()\n .describe('List of claims to match at least one on within author'),\n }),\n apply: (resource: Post, { userRef, claims = [] }) => {\n return resource?.author === userRef || claims.includes(resource?.author);\n },\n toQuery: ({ userRef, claims = [] }) => {\n return {\n property: 'posts.author' as PostFilter['property'],\n values: [userRef, ...claims].filter(Boolean),\n };\n },\n});\n\nexport const postAuthorConditionFactory = createConditionFactory(isPostAuthor);\n\nexport const postHasTags = createPermissionRule({\n name: 'HAS_TAGS',\n description: 'Should allow only if the post has all the specific tags',\n resourceRef: postPermissionResourceRef,\n paramsSchema: z.object({\n tags: z.array(z.string()).describe('Tag to match the post'),\n }),\n apply: (resource: Post, { tags }) => {\n return tags.every(t => resource?.tags?.includes(t));\n },\n toQuery: ({ tags }) => {\n return {\n property: 'tags' as PostFilter['property'],\n values: tags,\n };\n },\n});\n\nexport const postHasTagsConditionFactory = createConditionFactory(postHasTags);\n\nexport const postHasEntities = createPermissionRule({\n name: 'HAS_ENTITIES',\n description: 'Should allow only if the post has all the specific entities',\n resourceRef: postPermissionResourceRef,\n paramsSchema: z.object({\n entityRefs: z.array(z.string()).describe('Entity refs to match the post'),\n }),\n apply: (resource: Post, { entityRefs }) => {\n return entityRefs.every(t => resource?.entities?.includes(t));\n },\n toQuery: ({ entityRefs }) => {\n return {\n property: 'entityRefs' as PostFilter['property'],\n values: entityRefs,\n };\n },\n});\n\nexport const postHasEntitiesConditionFactory =\n createConditionFactory(postHasEntities);\n\nexport const postHasType = createPermissionRule({\n name: 'HAS_TYPE',\n description: 'Should allow only if the post has the specific type',\n resourceRef: postPermissionResourceRef,\n paramsSchema: z.object({\n type: z.string().describe('Type to match the post'),\n }),\n apply: (resource: Post, { type }) => {\n return resource?.type === type;\n },\n toQuery: ({ type }) => {\n return {\n property: 'posts.type' as PostFilter['property'],\n values: [type],\n };\n },\n});\n\nexport const postHasTypeConditionFactory = createConditionFactory(postHasType);\n\nexport const isPostTagExpert = createPermissionRule({\n name: 'IS_POST_TAG_EXPERT',\n description: 'Allows if post has tags the user is expert of',\n resourceRef: postPermissionResourceRef,\n paramsSchema: z.object({\n userRef: z\n .string()\n .describe('User ID to match on the tag expert')\n .optional(),\n claims: z\n .array(z.string())\n .optional()\n .describe('List of claims to match at least one on within tag expert'),\n }),\n apply: (resource: Post, { userRef, claims }) => {\n return Boolean(\n resource?.experts?.some(e => e === userRef || claims?.includes(e)),\n );\n },\n toQuery: ({ claims = [], userRef }) => {\n return {\n property: 'tag.experts' as PostFilter['property'],\n values: [userRef, ...claims].filter(Boolean),\n };\n },\n});\n\nexport const postTagExpertConditionFactory =\n createConditionFactory(isPostTagExpert);\n\nexport const postRules = {\n isPostAuthor,\n postHasTags,\n postHasEntities,\n postHasType,\n isPostTagExpert,\n};\n\nexport const isAnswerAuthor = createPermissionRule({\n name: 'IS_AUTHOR',\n description: 'Should allow only if the answer is created by the user',\n resourceRef: answerPermissionResourceRef,\n paramsSchema: z.object({\n userRef: z.string().describe('User ID to match on the author').optional(),\n claims: z\n .array(z.string())\n .optional()\n .describe('List of claims to match at least one on within author'),\n }),\n apply: (resource: Answer, { userRef, claims = [] }) => {\n return resource?.author === userRef || claims.includes(resource?.author);\n },\n toQuery: ({ userRef, claims = [] }) => {\n return {\n property: 'answers.author' as AnswerFilter['property'],\n values: [userRef, ...claims].filter(Boolean),\n };\n },\n});\n\nexport const answerAuthorConditionFactory =\n createConditionFactory(isAnswerAuthor);\n\nexport const answerQuestionHasTags = createPermissionRule({\n name: 'HAS_TAGS',\n description:\n 'Should allow only if the answers question has all the specific tags',\n resourceRef: answerPermissionResourceRef,\n paramsSchema: z.object({\n tags: z.array(z.string()).describe('Tag to match the question'),\n }),\n apply: (resource: Answer, { tags }) => {\n return tags.every(t => resource?.post?.tags?.includes(t));\n },\n toQuery: ({ tags }) => {\n return {\n property: 'tags' as AnswerFilter['property'],\n values: tags,\n };\n },\n});\n\nexport const answerQuestionTagsConditionFactory = createConditionFactory(\n answerQuestionHasTags,\n);\n\nexport const answerQuestionHasEntityRefs = createPermissionRule({\n name: 'HAS_ENTITIES',\n description:\n 'Should allow only if the answers question has all the specific entities',\n resourceRef: answerPermissionResourceRef,\n paramsSchema: z.object({\n entityRefs: z.array(z.string()).describe('Tag to match the question'),\n }),\n apply: (resource: Answer, { entityRefs }) => {\n return entityRefs.every(t => resource?.post?.entities?.includes(t));\n },\n toQuery: ({ entityRefs }) => {\n return {\n property: 'entityRefs' as AnswerFilter['property'],\n values: entityRefs,\n };\n },\n});\n\nexport const answerQuestionEntitiesConditionFactory = createConditionFactory(\n answerQuestionHasEntityRefs,\n);\n\nexport const isAnswerTagExpert = createPermissionRule({\n name: 'IS_ANSWER_TAG_EXPERT',\n description: 'Allows if answers post has tags the user is expert of',\n resourceRef: answerPermissionResourceRef,\n paramsSchema: z.object({\n userRef: z\n .string()\n .describe('User ID to match on the tag expert')\n .optional(),\n claims: z\n .array(z.string())\n .optional()\n .describe('List of claims to match at least one on within tag expert'),\n }),\n apply: (resource: Answer, { userRef, claims }) => {\n return Boolean(\n resource?.experts?.some(e => e === userRef || claims?.includes(e)),\n );\n },\n toQuery: ({ claims = [], userRef }) => {\n return {\n property: 'tag.experts' as AnswerFilter['property'],\n values: [userRef, ...claims].filter(Boolean),\n };\n },\n});\n\nexport const answerTagExpertConditionFactory =\n createConditionFactory(isAnswerTagExpert);\n\nexport const answerRules = {\n isAnswerAuthor,\n answerQuestionHasTags,\n answerQuestionHasEntityRefs,\n isAnswerTagExpert,\n};\n\nexport const isCommentAuthor = createPermissionRule({\n name: 'IS_AUTHOR',\n description: 'Should allow only if the comment is created by the user',\n resourceRef: commentPermissionResourceRef,\n paramsSchema: z.object({\n userRef: z.string().describe('User ID to match on the author').optional(),\n claims: z\n .array(z.string())\n .optional()\n .describe('List of claims to match at least one on within author'),\n }),\n apply: (resource: Comment, { userRef, claims = [] }) => {\n return resource?.author === userRef || claims.includes(resource?.author);\n },\n toQuery: ({ userRef, claims = [] }) => {\n return {\n property: 'comments.author' as CommentFilter['property'],\n values: [userRef, ...claims].filter(Boolean),\n };\n },\n});\n\nexport const commentAuthorConditionFactory =\n createConditionFactory(isCommentAuthor);\n\nexport const commentRules = { isCommentAuthor };\n\nexport const isTag = createPermissionRule({\n name: 'IS_TAG',\n description: 'Should allow only if the tag exists',\n resourceRef: tagPermissionResourceRef,\n paramsSchema: z.object({\n tag: z.string().describe('Tag to match the post'),\n }),\n apply: (resource: TagResponse, { tag }) => {\n return resource?.tag === tag;\n },\n toQuery: ({ tag }) => {\n return {\n property: 'tags.tag' as TagFilter['property'],\n values: [tag],\n };\n },\n});\n\nexport const tagConditionFactory = createConditionFactory(isTag);\n\nexport const isTagExpert = createPermissionRule({\n name: 'IS_TAG_EXPERT',\n description: 'Allows only if user is tag expert',\n resourceRef: tagPermissionResourceRef,\n paramsSchema: z.object({\n userRef: z\n .string()\n .describe('User ID to match on the tag expert')\n .optional(),\n claims: z\n .array(z.string())\n .optional()\n .describe('List of claims to match at least one on within tag expert'),\n }),\n apply: (resource: TagResponse, { userRef, claims }) => {\n return Boolean(\n resource?.experts?.some(e => e === userRef || claims?.includes(e)),\n );\n },\n toQuery: ({ claims = [], userRef }) => {\n return {\n property: 'tag.experts' as TagFilter['property'],\n values: [userRef, ...claims].filter(Boolean),\n };\n },\n});\n\nexport const tagExpertConditionFactory = createConditionFactory(isTagExpert);\n\nexport const tagRules = { isTag, isTagExpert };\n\nexport const isCollectionOwner = createPermissionRule({\n name: 'IS_OWNER',\n description: 'Should allow only if the collection is owned by the user',\n resourceRef: collectionPermissionResourceRef,\n paramsSchema: z.object({\n userRef: z\n .string()\n .describe('User reference to match on the owner')\n .optional(),\n claims: z\n .array(z.string())\n .optional()\n .describe('List of claims to match at least one on within owner'),\n }),\n apply: (resource: Collection, { userRef, claims = [] }) => {\n return resource?.owner === userRef || claims.includes(resource?.owner);\n },\n toQuery: ({ userRef, claims = [] }) => {\n return {\n property: 'collections.owner' as CollectionFilter['property'],\n values: [userRef, ...claims].filter(Boolean),\n };\n },\n});\n\nexport const collectionOwnerConditionFactory =\n createConditionFactory(isCollectionOwner);\n\nexport const collectionHasTags = createPermissionRule({\n name: 'HAS_TAGS',\n description:\n 'Should allow only if the posts in the collection have the specific tags',\n resourceRef: collectionPermissionResourceRef,\n paramsSchema: z.object({\n tags: z.array(z.string()).describe('Tag to match the collection'),\n }),\n apply: (resource: Collection, { tags }) => {\n return tags.every(t => resource?.tags?.includes(t));\n },\n toQuery: ({ tags }) => {\n return {\n property: 'tags' as CollectionFilter['property'],\n values: tags,\n };\n },\n});\n\nexport const collectionHasTagsConditionFactory =\n createConditionFactory(collectionHasTags);\n\nexport const collectionHasEntities = createPermissionRule({\n name: 'HAS_ENTITIES',\n description:\n 'Should allow only if the posts in the collection have the specific entities',\n resourceRef: collectionPermissionResourceRef,\n paramsSchema: z.object({\n entityRefs: z\n .array(z.string())\n .describe('Entity refs to match the collection'),\n }),\n apply: (resource: Collection, { entityRefs }) => {\n return entityRefs.every(t => resource?.entities?.includes(t));\n },\n toQuery: ({ entityRefs }) => {\n return {\n property: 'entityRefs' as CollectionFilter['property'],\n values: entityRefs,\n };\n },\n});\n\nexport const collectionHasEntitiesConditionFactory = createConditionFactory(\n collectionHasEntities,\n);\n\nexport const isCollectionTagExpert = createPermissionRule({\n name: 'IS_COLLECTION_TAG_EXPERT',\n description: 'Allows if collection has tags the user is expert of',\n resourceRef: collectionPermissionResourceRef,\n paramsSchema: z.object({\n userRef: z\n .string()\n .describe('User ID to match on the tag expert')\n .optional(),\n claims: z\n .array(z.string())\n .optional()\n .describe('List of claims to match at least one on within tag expert'),\n }),\n apply: (resource: Collection, { userRef, claims }) => {\n return Boolean(\n resource?.experts?.some(e => e === userRef || claims?.includes(e)),\n );\n },\n toQuery: ({ claims = [], userRef }) => {\n return {\n property: 'tag.experts' as CollectionFilter['property'],\n values: [userRef, ...claims].filter(Boolean),\n };\n },\n});\n\nexport const collectionTagExpertConditionFactory = createConditionFactory(\n isCollectionTagExpert,\n);\n\nexport const collectionRules = {\n isCollectionOwner,\n collectionHasTags,\n collectionHasEntities,\n isCollectionTagExpert,\n};\n\nexport const rules = {\n ...commentRules,\n ...answerRules,\n ...postRules,\n ...tagRules,\n ...collectionRules,\n};\n"],"names":["createPermissionRule","postPermissionResourceRef","z","createConditionFactory","answerPermissionResourceRef","commentPermissionResourceRef","tagPermissionResourceRef","collectionPermissionResourceRef"],"mappings":";;;;;;AAyBO,MAAM,eAAeA,yCAAqB,CAAA;AAAA,EAC/C,IAAM,EAAA,WAAA;AAAA,EACN,WAAa,EAAA,sDAAA;AAAA,EACb,WAAa,EAAAC,6CAAA;AAAA,EACb,YAAA,EAAcC,MAAE,MAAO,CAAA;AAAA,IACrB,SAASA,KAAE,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ED
@@ -7,7 +7,7 @@
7
7
  "backstage.io",
8
8
  "node"
9
9
  ],
10
- "version": "3.27.0",
10
+ "version": "3.28.0",
11
11
  "main": "dist/index.cjs.js",
12
12
  "types": "dist/index.d.ts",
13
13
  "prepublishOnly": "yarn tsc && yarn build",
@@ -60,7 +60,7 @@
60
60
  "@backstage/plugin-auth-node": "^0.6.3",
61
61
  "@backstage/plugin-permission-common": "^0.9.0",
62
62
  "@backstage/plugin-permission-node": "^0.10.0",
63
- "@drodil/backstage-plugin-qeta-common": "^3.27.0",
63
+ "@drodil/backstage-plugin-qeta-common": "^3.28.0",
64
64
  "zod": "^3.22.4"
65
65
  },
66
66
  "typesVersions": {