@backstage/plugin-permission-node 0.8.8 → 0.8.9-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @backstage/plugin-permission-node
|
|
2
2
|
|
|
3
|
+
## 0.8.9-next.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @backstage/plugin-auth-node@0.6.1-next.1
|
|
9
|
+
- @backstage/backend-plugin-api@1.2.1-next.1
|
|
10
|
+
- @backstage/config@1.3.2
|
|
11
|
+
- @backstage/errors@1.2.7
|
|
12
|
+
- @backstage/plugin-permission-common@0.8.4
|
|
13
|
+
|
|
14
|
+
## 0.8.9-next.0
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- 728e3e1: Improved type inference when passing a `PermissionResourceRef` to `createPermissionRule`.
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
- @backstage/plugin-auth-node@0.6.1-next.0
|
|
21
|
+
- @backstage/backend-plugin-api@1.2.1-next.0
|
|
22
|
+
|
|
3
23
|
## 0.8.8
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -360,10 +360,10 @@ declare function createPermissionIntegrationRouter<TResourceType1 extends string
|
|
|
360
360
|
/**
|
|
361
361
|
* @public
|
|
362
362
|
*/
|
|
363
|
-
type CreatePermissionRuleOptions<
|
|
363
|
+
type CreatePermissionRuleOptions<TRef extends PermissionResourceRef, TParams extends PermissionRuleParams> = TRef extends PermissionResourceRef<infer IResource, infer IQuery, any> ? {
|
|
364
364
|
name: string;
|
|
365
365
|
description: string;
|
|
366
|
-
resourceRef:
|
|
366
|
+
resourceRef: TRef;
|
|
367
367
|
/**
|
|
368
368
|
* A ZodSchema that reflects the structure of the parameters that are passed to
|
|
369
369
|
*/
|
|
@@ -373,20 +373,20 @@ type CreatePermissionRuleOptions<TResource, TQuery, TQueryOutput extends TQuery,
|
|
|
373
373
|
* arguments supplied for the rule; for example, a rule could be `isOwner` with entityRefs as the
|
|
374
374
|
* params.
|
|
375
375
|
*/
|
|
376
|
-
apply(resource:
|
|
376
|
+
apply(resource: IResource, params: NoInfer<TParams>): boolean;
|
|
377
377
|
/**
|
|
378
378
|
* Translate this rule to criteria suitable for use in querying a backing data store. The criteria
|
|
379
379
|
* can be used for loading a collection of resources efficiently with conditional criteria already
|
|
380
380
|
* applied.
|
|
381
381
|
*/
|
|
382
|
-
toQuery(params: NoInfer<TParams>): PermissionCriteria<
|
|
383
|
-
};
|
|
382
|
+
toQuery(params: NoInfer<TParams>): PermissionCriteria<IQuery>;
|
|
383
|
+
} : never;
|
|
384
384
|
/**
|
|
385
385
|
* Helper function to create a {@link PermissionRule} for a specific resource type using a {@link PermissionResourceRef}.
|
|
386
386
|
*
|
|
387
387
|
* @public
|
|
388
388
|
*/
|
|
389
|
-
declare function createPermissionRule<
|
|
389
|
+
declare function createPermissionRule<TRef extends PermissionResourceRef, TParams extends PermissionRuleParams = undefined>(rule: CreatePermissionRuleOptions<TRef, TParams>): PermissionRule<TRef['TResource'], TRef['TQuery'], TRef['resourceType'], TParams>;
|
|
390
390
|
/**
|
|
391
391
|
* Helper function to ensure that {@link PermissionRule} definitions are typed correctly.
|
|
392
392
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createPermissionRule.cjs.js","sources":["../../src/integration/createPermissionRule.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n PermissionCriteria,\n PermissionRuleParams,\n} from '@backstage/plugin-permission-common';\nimport { PermissionRule } from '../types';\nimport { z } from 'zod';\nimport { PermissionResourceRef } from './createPermissionResourceRef';\nimport { NoInfer } from './util';\n\n/**\n * @public\n */\nexport type CreatePermissionRuleOptions<\n
|
|
1
|
+
{"version":3,"file":"createPermissionRule.cjs.js","sources":["../../src/integration/createPermissionRule.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n PermissionCriteria,\n PermissionRuleParams,\n} from '@backstage/plugin-permission-common';\nimport { PermissionRule } from '../types';\nimport { z } from 'zod';\nimport { PermissionResourceRef } from './createPermissionResourceRef';\nimport { NoInfer } from './util';\n\n/**\n * @public\n */\nexport type CreatePermissionRuleOptions<\n TRef extends PermissionResourceRef,\n TParams extends PermissionRuleParams,\n> = TRef extends PermissionResourceRef<infer IResource, infer IQuery, any>\n ? {\n name: string;\n description: string;\n\n resourceRef: TRef;\n\n /**\n * A ZodSchema that reflects the structure of the parameters that are passed to\n */\n paramsSchema?: z.ZodSchema<TParams>;\n\n /**\n * Apply this rule to a resource already loaded from a backing data source. The params are\n * arguments supplied for the rule; for example, a rule could be `isOwner` with entityRefs as the\n * params.\n */\n apply(resource: IResource, params: NoInfer<TParams>): boolean;\n\n /**\n * Translate this rule to criteria suitable for use in querying a backing data store. The criteria\n * can be used for loading a collection of resources efficiently with conditional criteria already\n * applied.\n */\n toQuery(params: NoInfer<TParams>): PermissionCriteria<IQuery>;\n }\n : never;\n\n/**\n * Helper function to create a {@link PermissionRule} for a specific resource type using a {@link PermissionResourceRef}.\n *\n * @public\n */\nexport function createPermissionRule<\n TRef extends PermissionResourceRef,\n TParams extends PermissionRuleParams = undefined,\n>(\n rule: CreatePermissionRuleOptions<TRef, TParams>,\n): PermissionRule<\n TRef['TResource'],\n TRef['TQuery'],\n TRef['resourceType'],\n TParams\n>;\n/**\n * Helper function to ensure that {@link PermissionRule} definitions are typed correctly.\n *\n * @deprecated Use the version of `createPermissionRule` that accepts a `resourceRef` option instead.\n * @public\n */\nexport function createPermissionRule<\n TResource,\n TQuery,\n TResourceType extends string,\n TParams extends PermissionRuleParams = undefined,\n>(\n rule: PermissionRule<TResource, TQuery, TResourceType, TParams>,\n): PermissionRule<TResource, TQuery, TResourceType, TParams>;\nexport function createPermissionRule<\n TResource,\n TQuery,\n TResourceType extends string,\n TRef extends PermissionResourceRef,\n TParams extends PermissionRuleParams = undefined,\n>(\n rule:\n | PermissionRule<TResource, TQuery, TResourceType, TParams>\n | CreatePermissionRuleOptions<TRef, TParams>,\n): PermissionRule<TResource, TQuery, TResourceType, TParams> {\n if ('resourceRef' in rule) {\n return {\n ...rule,\n resourceType: rule.resourceRef.resourceType as TResourceType,\n } as PermissionRule<TResource, TQuery, TResourceType, TParams>;\n }\n return rule;\n}\n\n/**\n * Helper for making plugin-specific createPermissionRule functions, that have\n * the TResource and TQuery type parameters populated but infer the params from\n * the supplied rule. This helps ensure that rules created for this plugin use\n * consistent types for the resource and query.\n *\n * @public\n * @deprecated Use {@link (createPermissionRule:1)} directly instead with the resourceRef option.\n */\nexport const makeCreatePermissionRule =\n <TResource, TQuery, TResourceType extends string>() =>\n <TParams extends PermissionRuleParams = undefined>(\n rule: PermissionRule<TResource, TQuery, TResourceType, TParams>,\n ) =>\n createPermissionRule(rule);\n"],"names":[],"mappings":";;AAyFO,SAAS,qBAOd,IAG2D,EAAA;AAC3D,EAAA,IAAI,iBAAiB,IAAM,EAAA;AACzB,IAAO,OAAA;AAAA,MACL,GAAG,IAAA;AAAA,MACH,YAAA,EAAc,KAAK,WAAY,CAAA;AAAA,KACjC;AAAA;AAEF,EAAO,OAAA,IAAA;AACT;AAWO,MAAM,wBACX,GAAA,MACA,CACE,IAAA,KAEA,qBAAqB,IAAI;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-permission-node",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.9-next.1",
|
|
4
4
|
"description": "Common permission and authorization utilities for backend plugins",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "node-library",
|
|
@@ -65,11 +65,11 @@
|
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"@backstage/backend-common": "^0.25.0",
|
|
68
|
-
"@backstage/backend-plugin-api": "
|
|
69
|
-
"@backstage/config": "
|
|
70
|
-
"@backstage/errors": "
|
|
71
|
-
"@backstage/plugin-auth-node": "
|
|
72
|
-
"@backstage/plugin-permission-common": "
|
|
68
|
+
"@backstage/backend-plugin-api": "1.2.1-next.1",
|
|
69
|
+
"@backstage/config": "1.3.2",
|
|
70
|
+
"@backstage/errors": "1.2.7",
|
|
71
|
+
"@backstage/plugin-auth-node": "0.6.1-next.1",
|
|
72
|
+
"@backstage/plugin-permission-common": "0.8.4",
|
|
73
73
|
"@types/express": "^4.17.6",
|
|
74
74
|
"express": "^4.17.1",
|
|
75
75
|
"express-promise-router": "^4.1.0",
|
|
@@ -77,9 +77,9 @@
|
|
|
77
77
|
"zod-to-json-schema": "^3.20.4"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
|
-
"@backstage/backend-defaults": "
|
|
81
|
-
"@backstage/backend-test-utils": "
|
|
82
|
-
"@backstage/cli": "
|
|
80
|
+
"@backstage/backend-defaults": "0.8.2-next.1",
|
|
81
|
+
"@backstage/backend-test-utils": "1.3.1-next.1",
|
|
82
|
+
"@backstage/cli": "0.30.1-next.0",
|
|
83
83
|
"@types/supertest": "^2.0.8",
|
|
84
84
|
"msw": "^1.0.0",
|
|
85
85
|
"supertest": "^7.0.0"
|