mirror of
https://github.com/strapi/strapi.git
synced 2025-08-29 19:22:24 +00:00
chore: build strapi permissions with pack-up (#18309)
This commit is contained in:
parent
3a1cb32f56
commit
82035f18c9
2
.github/workflows/tests.yml
vendored
2
.github/workflows/tests.yml
vendored
@ -121,7 +121,7 @@ jobs:
|
||||
- uses: nrwl/nx-set-shas@v3
|
||||
- name: Monorepo install
|
||||
uses: ./.github/actions/yarn-nm-install
|
||||
- name: Run build for admin-test-utils
|
||||
- name: Run build:ts for admin-test-utils & helper-plugin
|
||||
run: yarn build --projects=@strapi/admin-test-utils,@strapi/helper-plugin --skip-nx-cache
|
||||
- name: Run test
|
||||
run: yarn nx affected --target=test:front --nx-ignore-cycles
|
||||
|
@ -1,6 +0,0 @@
|
||||
export interface Permission {
|
||||
action: string;
|
||||
subject?: string | object | null;
|
||||
properties?: object;
|
||||
conditions?: string[];
|
||||
}
|
@ -8,7 +8,9 @@ import { hasPermissions } from '../utils/hasPermissions';
|
||||
|
||||
import { LoadingIndicatorPage } from './LoadingIndicatorPage';
|
||||
|
||||
import type { Permission } from '@strapi/permissions';
|
||||
import type { domain } from '@strapi/permissions';
|
||||
|
||||
type Permission = domain.permission.Permission;
|
||||
|
||||
export interface CheckPagePermissions {
|
||||
children: React.ReactNode;
|
||||
|
@ -4,7 +4,9 @@ import { useNotification } from '../features/Notifications';
|
||||
import { useRBACProvider } from '../features/RBAC';
|
||||
import { hasPermissions } from '../utils/hasPermissions';
|
||||
|
||||
import type { Permission } from '@strapi/permissions';
|
||||
import type { domain } from '@strapi/permissions';
|
||||
|
||||
type Permission = domain.permission.Permission;
|
||||
|
||||
// NOTE: this component is very similar to the CheckPagePermissions
|
||||
// except that it does not handle redirections nor loading state
|
||||
|
@ -1,8 +1,10 @@
|
||||
import * as React from 'react';
|
||||
|
||||
import type { Permission } from '@strapi/permissions';
|
||||
import type { domain } from '@strapi/permissions';
|
||||
import type { QueryObserverBaseResult } from 'react-query';
|
||||
|
||||
type Permission = domain.permission.Permission;
|
||||
|
||||
/* -------------------------------------------------------------------------------------------------
|
||||
* Context
|
||||
* -----------------------------------------------------------------------------------------------*/
|
||||
|
@ -2,7 +2,9 @@ import * as React from 'react';
|
||||
|
||||
import { TranslationMessage } from '../types';
|
||||
|
||||
import type { Permission } from '@strapi/permissions';
|
||||
import type { domain } from '@strapi/permissions';
|
||||
|
||||
type Permission = domain.permission.Permission;
|
||||
|
||||
interface MenuItem {
|
||||
to: string;
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { useCallback, useMemo } from 'react';
|
||||
|
||||
import { parse, ParsedQs, stringify } from 'qs';
|
||||
import { parse, stringify } from 'qs';
|
||||
import { useHistory, useLocation } from 'react-router-dom';
|
||||
|
||||
const useQueryParams = <TQuery extends Record<string, unknown>>(initialParams?: TQuery) => {
|
||||
|
@ -6,9 +6,11 @@ import { useRBACProvider } from '../features/RBAC';
|
||||
|
||||
import { useFetchClient } from './useFetchClient';
|
||||
|
||||
import type { Permission } from '@strapi/permissions';
|
||||
import type { domain } from '@strapi/permissions';
|
||||
import type { AxiosResponse } from 'axios';
|
||||
|
||||
type Permission = domain.permission.Permission;
|
||||
|
||||
type AllowedActions = Record<string, boolean>;
|
||||
|
||||
export const useRBAC = (
|
||||
|
@ -1,8 +1,10 @@
|
||||
import { getFetchClient } from './getFetchClient';
|
||||
|
||||
import type { Permission } from '@strapi/permissions';
|
||||
import type { domain } from '@strapi/permissions';
|
||||
import type { GenericAbortSignal } from 'axios';
|
||||
|
||||
type Permission = domain.permission.Permission;
|
||||
|
||||
const findMatchingPermissions = (userPermissions: Permission[], permissions: Permission[]) =>
|
||||
userPermissions.reduce<Permission[]>((acc, curr) => {
|
||||
const associatedPermission = permissions.find(
|
||||
|
@ -1,5 +1,3 @@
|
||||
import { Permission } from '@strapi/permissions';
|
||||
|
||||
import {
|
||||
hasPermissions,
|
||||
findMatchingPermissions,
|
||||
@ -7,6 +5,10 @@ import {
|
||||
shouldCheckPermissions,
|
||||
} from '../hasPermissions';
|
||||
|
||||
import type { domain } from '@strapi/permissions';
|
||||
|
||||
type Permission = domain.permission.Permission;
|
||||
|
||||
const hasPermissionsTestData: Record<string, Record<string, Permission[]>> = {
|
||||
userPermissions: {
|
||||
user1: [
|
||||
|
@ -19,20 +19,22 @@
|
||||
"url": "https://strapi.io"
|
||||
}
|
||||
],
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.mjs",
|
||||
"source": "./src/index.ts",
|
||||
"types": "./dist/index.d.ts",
|
||||
"files": [
|
||||
"./dist"
|
||||
],
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "run -T tsc",
|
||||
"build:ts": "run build",
|
||||
"watch": "run -T tsc -w --preserveWatchOutput",
|
||||
"build": "pack-up build",
|
||||
"clean": "run -T rimraf ./dist",
|
||||
"lint": "run -T eslint .",
|
||||
"prepublishOnly": "yarn clean && yarn build",
|
||||
"test:ts": "run -T tsc --noEmit",
|
||||
"test:unit": "run -T jest",
|
||||
"test:unit:watch": "run -T jest --watch",
|
||||
"lint": "run -T eslint ."
|
||||
"watch": "pack-up watch"
|
||||
},
|
||||
"dependencies": {
|
||||
"@casl/ability": "6.5.0",
|
||||
@ -42,6 +44,7 @@
|
||||
"sift": "16.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@strapi/pack-up": "workspace:*",
|
||||
"eslint-config-custom": "4.14.3",
|
||||
"tsconfig": "4.14.3"
|
||||
},
|
||||
|
6
packages/core/permissions/packup.config.ts
Normal file
6
packages/core/permissions/packup.config.ts
Normal file
@ -0,0 +1,6 @@
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
import { defineConfig } from '@strapi/pack-up';
|
||||
|
||||
export default defineConfig({
|
||||
runtime: 'node',
|
||||
});
|
@ -1,7 +1,7 @@
|
||||
import _ from 'lodash';
|
||||
import { subject } from '@casl/ability';
|
||||
import { providerFactory } from '@strapi/utils';
|
||||
import permissions from '..';
|
||||
import * as permissions from '../index';
|
||||
import type { HookName } from '../engine/hooks';
|
||||
import type { Permission } from '../domain/permission';
|
||||
|
||||
|
@ -1,7 +1,4 @@
|
||||
import * as domain from './domain';
|
||||
import * as engine from './engine';
|
||||
|
||||
export = {
|
||||
domain,
|
||||
engine,
|
||||
};
|
||||
export { domain, engine };
|
||||
|
9
packages/core/permissions/tsconfig.build.json
Normal file
9
packages/core/permissions/tsconfig.build.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "./src",
|
||||
"outDir": "./dist"
|
||||
},
|
||||
"include": ["src"],
|
||||
"exclude": ["**/__tests__/**"]
|
||||
}
|
@ -3,6 +3,6 @@
|
||||
"compilerOptions": {
|
||||
"noEmit": true
|
||||
},
|
||||
"include": ["src"],
|
||||
"include": ["src", "packup.config.ts"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
|
@ -39,6 +39,7 @@
|
||||
"clean": "run -T rimraf ./dist",
|
||||
"lint": "run -T eslint .",
|
||||
"prepublishOnly": "yarn clean && yarn build",
|
||||
"test:ts": "run -T tsc --noEmit",
|
||||
"test:unit": "run -T jest",
|
||||
"test:unit:watch": "run -T jest --watch",
|
||||
"watch": "run -T pack-up watch"
|
||||
|
Loading…
x
Reference in New Issue
Block a user