mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
[ACS-6630] Revert move of ActionRef, RuleRef and RouteRef from extensions library to js-api library
This commit is contained in:
parent
d855328efc
commit
6d201b108f
@ -18,10 +18,10 @@ Manages and runs basic extension functionality.
|
||||
- _ruleId:_ `string` - ID of the rule to evaluate
|
||||
- _context:_ [`RuleContext`](../../../lib/extensions/src/lib/config/rule.extensions.ts) - (Optional) Custom rule execution context.
|
||||
- **Returns** `boolean` - True if the rule passed, false otherwise
|
||||
- **getActionById**(id: `string`): [`ActionRef`](../../../lib/js-api/src/api/content-rest-api/model/actionRef.ts)<br/>
|
||||
- **getActionById**(id: `string`): [`ActionRef`](../../../lib/extensions/src/lib/config/action.extensions.ts)<br/>
|
||||
Retrieves an action using its ID value.
|
||||
- _id:_ `string` - The ID value to look for
|
||||
- **Returns** [`ActionRef`](../../../lib/js-api/src/api/content-rest-api/model/actionRef.ts) - Action or null if not found
|
||||
- **Returns** [`ActionRef`](../../../lib/extensions/src/lib/config/action.extensions.ts) - Action or null if not found
|
||||
- **getAuthGuards**(ids: `string[]`): `Array<Type<any>>`<br/>
|
||||
Retrieves one or more auth guards using an array of ID values.
|
||||
- _ids:_ `string[]` - Array of ID value to look for
|
||||
@ -44,14 +44,14 @@ Manages and runs basic extension functionality.
|
||||
Gets features by key.
|
||||
- _key:_ `string|string[]` - Key string using dot notation or array of strings
|
||||
- _defaultValue:_ `any` - Default value returned if feature is not found, default is empty array
|
||||
- **getRouteById**(id: `string`): [`RouteRef`](../../../lib/js-api/src/api/content-rest-api/model/routeRef.ts)<br/>
|
||||
- **getRouteById**(id: `string`): [`RouteRef`](../../../lib/extensions/src/lib/config/routing.extensions.ts)<br/>
|
||||
Retrieves a route using its ID value.
|
||||
- _id:_ `string` - The ID value to look for
|
||||
- **Returns** [`RouteRef`](../../../lib/js-api/src/api/content-rest-api/model/routeRef.ts) - The route or null if not found
|
||||
- **getRuleById**(id: `string`): [`RuleRef`](../../../lib/js-api/src/api/content-rest-api/model/ruleRef.ts)<br/>
|
||||
- **Returns** [`RouteRef`](../../../lib/extensions/src/lib/config/routing.extensions.ts) - The route or null if not found
|
||||
- **getRuleById**(id: `string`): [`RuleRef`](../../../lib/extensions/src/lib/config/rule.extensions.ts)<br/>
|
||||
Retrieves a rule using its ID value.
|
||||
- _id:_ `string` - The ID value to look for
|
||||
- **Returns** [`RuleRef`](../../../lib/js-api/src/api/content-rest-api/model/ruleRef.ts) - The rule or null if not found
|
||||
- **Returns** [`RuleRef`](../../../lib/extensions/src/lib/config/rule.extensions.ts) - The rule or null if not found
|
||||
- **load**(): [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises)`<`[`ExtensionConfig`](../../../lib/extensions/src/lib/config/extension.config.ts)`>`<br/>
|
||||
Loads and registers an extension config file and plugins (specified by path properties).
|
||||
- **Returns** [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises)`<`[`ExtensionConfig`](../../../lib/extensions/src/lib/config/extension.config.ts)`>` - The loaded config data
|
||||
|
@ -215,7 +215,7 @@ following example:
|
||||
```
|
||||
|
||||
You can access routes from the config using the `getRouteById` method of the
|
||||
[Extension service,](../extensions/services/extension.service.md) which returns a [`RouteRef`](../../lib/js-api/src/api/content-rest-api/model/routeRef.ts) object. Note that the references
|
||||
[Extension service,](../extensions/services/extension.service.md) which returns a [`RouteRef`](../../lib/extensions/src/lib/config/routing.extensions.ts) object. Note that the references
|
||||
to the component and auth guards are extension IDs,
|
||||
[as described above](#extension-points).
|
||||
|
||||
|
@ -47,3 +47,9 @@ export interface ContentActionRef extends ExtensionElement {
|
||||
visible?: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface ActionRef {
|
||||
id: string;
|
||||
type: string;
|
||||
payload?: string;
|
||||
}
|
||||
|
@ -15,7 +15,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ActionRef, RouteRef, RuleRef } from '@alfresco/js-api';
|
||||
import { RouteRef } from './routing.extensions';
|
||||
import { RuleRef } from './rule.extensions';
|
||||
import { ActionRef } from './action.extensions';
|
||||
|
||||
export interface ExtensionRef {
|
||||
$id: string;
|
||||
|
@ -33,3 +33,15 @@ export interface RuleContext {
|
||||
|
||||
getEvaluator(key: string): RuleEvaluator;
|
||||
}
|
||||
|
||||
export class RuleRef {
|
||||
type: string;
|
||||
id?: string;
|
||||
parameters?: Array<RuleParameter>;
|
||||
}
|
||||
|
||||
export interface RuleParameter {
|
||||
type: string;
|
||||
value: any;
|
||||
parameters?: Array<RuleParameter>;
|
||||
}
|
||||
|
@ -16,10 +16,9 @@
|
||||
*/
|
||||
|
||||
import { every, not, some } from './core.evaluators';
|
||||
import { RuleParameter } from '@alfresco/js-api';
|
||||
import { RuleParameter } from '../config/rule.extensions';
|
||||
|
||||
describe('Core Evaluators', () => {
|
||||
|
||||
const context: any = {
|
||||
getEvaluator: (key: string) => {
|
||||
switch (key) {
|
||||
|
@ -15,23 +15,21 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { RuleContext } from '../config/rule.extensions';
|
||||
import { RuleParameter } from '@alfresco/js-api';
|
||||
import { RuleContext, RuleParameter } from '../config/rule.extensions';
|
||||
|
||||
export const not = (context: RuleContext, ...args: RuleParameter[]): boolean => {
|
||||
if (!args || args.length === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return args
|
||||
.every((arg) => {
|
||||
const evaluator = context.getEvaluator(arg.value);
|
||||
if (!evaluator) {
|
||||
console.warn('evaluator not found: ' + arg.value);
|
||||
return false;
|
||||
}
|
||||
return !evaluator(context, ...(arg.parameters || []));
|
||||
});
|
||||
return args.every((arg) => {
|
||||
const evaluator = context.getEvaluator(arg.value);
|
||||
if (!evaluator) {
|
||||
console.warn('evaluator not found: ' + arg.value);
|
||||
return false;
|
||||
}
|
||||
return !evaluator(context, ...(arg.parameters || []));
|
||||
});
|
||||
};
|
||||
|
||||
export const every = (context: RuleContext, ...args: RuleParameter[]): boolean => {
|
||||
@ -39,15 +37,14 @@ export const every = (context: RuleContext, ...args: RuleParameter[]): boolean =
|
||||
return false;
|
||||
}
|
||||
|
||||
return args
|
||||
.every((arg) => {
|
||||
const evaluator = context.getEvaluator(arg.value);
|
||||
if (!evaluator) {
|
||||
console.warn('evaluator not found: ' + arg.value);
|
||||
return false;
|
||||
}
|
||||
return evaluator(context, ...(arg.parameters || []));
|
||||
});
|
||||
return args.every((arg) => {
|
||||
const evaluator = context.getEvaluator(arg.value);
|
||||
if (!evaluator) {
|
||||
console.warn('evaluator not found: ' + arg.value);
|
||||
return false;
|
||||
}
|
||||
return evaluator(context, ...(arg.parameters || []));
|
||||
});
|
||||
};
|
||||
|
||||
export const some = (context: RuleContext, ...args: RuleParameter[]): boolean => {
|
||||
@ -55,13 +52,12 @@ export const some = (context: RuleContext, ...args: RuleParameter[]): boolean =>
|
||||
return false;
|
||||
}
|
||||
|
||||
return args
|
||||
.some((arg) => {
|
||||
const evaluator = context.getEvaluator(arg.value);
|
||||
if (!evaluator) {
|
||||
console.warn('evaluator not found: ' + arg.value);
|
||||
return false;
|
||||
}
|
||||
return evaluator(context, ...(arg.parameters || []));
|
||||
});
|
||||
return args.some((arg) => {
|
||||
const evaluator = context.getEvaluator(arg.value);
|
||||
if (!evaluator) {
|
||||
console.warn('evaluator not found: ' + arg.value);
|
||||
return false;
|
||||
}
|
||||
return evaluator(context, ...(arg.parameters || []));
|
||||
});
|
||||
};
|
||||
|
@ -17,11 +17,12 @@
|
||||
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ContentActionRef, ContentActionType } from '../config/action.extensions';
|
||||
import { ActionRef, ContentActionRef, ContentActionType } from '../config/action.extensions';
|
||||
import { ExtensionElement } from '../config/extension-element';
|
||||
import { filterEnabled, getValue, mergeObjects, sortByOrder } from '../config/extension-utils';
|
||||
import { ExtensionConfig, ExtensionRef } from '../config/extension.config';
|
||||
import { ActionRef, RouteRef, RuleRef } from '@alfresco/js-api';
|
||||
import { RouteRef } from '../config/routing.extensions';
|
||||
import { RuleRef } from '../config/rule.extensions';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
|
@ -18,9 +18,11 @@
|
||||
import { ExtensionService } from './extension.service';
|
||||
import { ExtensionLoaderService } from './extension-loader.service';
|
||||
import { ExtensionConfig } from '../config/extension.config';
|
||||
import { ActionRef, RouteRef, RuleRef } from '@alfresco/js-api';
|
||||
import { ComponentRegisterService } from './component-register.service';
|
||||
import { RuleService } from './rule.service';
|
||||
import { RuleRef } from '../config/rule.extensions';
|
||||
import { RouteRef } from '../config/routing.extensions';
|
||||
import { ActionRef } from '../config/action.extensions';
|
||||
|
||||
describe('ExtensionService', () => {
|
||||
const blankConfig: ExtensionConfig = {
|
||||
|
@ -16,16 +16,18 @@
|
||||
*/
|
||||
|
||||
import { Injectable, Type, InjectionToken, Inject } from '@angular/core';
|
||||
import { RuleEvaluator, RuleContext } from '../config/rule.extensions';
|
||||
import { RuleEvaluator, RuleRef, RuleContext } from '../config/rule.extensions';
|
||||
import { ExtensionConfig } from '../config/extension.config';
|
||||
import { ExtensionLoaderService } from './extension-loader.service';
|
||||
import { RouteRef } from '../config/routing.extensions';
|
||||
import { ActionRef } from '../config/action.extensions';
|
||||
import * as core from '../evaluators/core.evaluators';
|
||||
import { ComponentRegisterService } from './component-register.service';
|
||||
import { RuleService } from './rule.service';
|
||||
import { ExtensionElement } from '../config/extension-element';
|
||||
import { BehaviorSubject, Observable } from 'rxjs';
|
||||
import { mergeArrays, mergeObjects } from '../config/extension-utils';
|
||||
import { ActionRef, ExtensionComposition, RouteRef, RuleRef } from '@alfresco/js-api';
|
||||
import { ExtensionComposition } from '@alfresco/js-api';
|
||||
|
||||
/**
|
||||
* The default extensions factory
|
||||
@ -110,15 +112,14 @@ export class ExtensionService {
|
||||
}
|
||||
|
||||
appendConfig(partialConfig: ExtensionComposition) {
|
||||
this.config = {
|
||||
this.setup({
|
||||
...this.config,
|
||||
rules: mergeArrays(this.config.rules, partialConfig.rules),
|
||||
features: mergeObjects(this.config.features, partialConfig.features),
|
||||
features: this.config.features ? mergeObjects(this.config.features, partialConfig.features) : partialConfig.features,
|
||||
routes: mergeArrays(this.config.routes, partialConfig.routes),
|
||||
actions: mergeArrays(this.config.actions, partialConfig.actions),
|
||||
appConfig: mergeObjects(this.config.appConfig, partialConfig.appConfig)
|
||||
};
|
||||
this.setup(this.config);
|
||||
appConfig: this.config.appConfig ? mergeObjects(this.config.appConfig, partialConfig.appConfig) : partialConfig.appConfig
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -16,10 +16,9 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { RuleContext, RuleEvaluator } from '../config/rule.extensions';
|
||||
import { RuleRef, RuleContext, RuleEvaluator, RuleParameter } from '../config/rule.extensions';
|
||||
import { ExtensionConfig } from '../config/extension.config';
|
||||
import { ExtensionLoaderService } from './extension-loader.service';
|
||||
import { RuleParameter, RuleRef } from '@alfresco/js-api';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
|
@ -23,6 +23,7 @@ export * from './lib/config/extension.config';
|
||||
export * from './lib/config/icon.extensions';
|
||||
export * from './lib/config/navbar.extensions';
|
||||
export * from './lib/config/permission.extensions';
|
||||
export * from './lib/config/routing.extensions';
|
||||
export * from './lib/config/rule.extensions';
|
||||
export * from './lib/config/sidebar.extensions';
|
||||
export * from './lib/config/viewer.extensions';
|
||||
|
@ -1,22 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export interface ActionRef {
|
||||
id: string;
|
||||
type: string;
|
||||
payload?: string;
|
||||
}
|
@ -23,7 +23,6 @@ export * from './actionDefinitionListList';
|
||||
export * from './actionExecResult';
|
||||
export * from './actionExecResultEntry';
|
||||
export * from './actionParameterDefinition';
|
||||
export * from './actionRef';
|
||||
export * from './activity';
|
||||
export * from './activityEntry';
|
||||
export * from './activityPaging';
|
||||
@ -160,8 +159,6 @@ export * from './renditionEntry';
|
||||
export * from './renditionPaging';
|
||||
export * from './renditionPagingList';
|
||||
export * from './revertBody';
|
||||
export * from './routeRef';
|
||||
export * from './ruleRef';
|
||||
export * from './sharedLink';
|
||||
export * from './sharedLinkBodyCreate';
|
||||
export * from './sharedLinkBodyEmail';
|
||||
|
@ -1,28 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export interface RuleParameter {
|
||||
type: string;
|
||||
value: string;
|
||||
parameters?: Array<RuleParameter>;
|
||||
}
|
||||
|
||||
export class RuleRef {
|
||||
type: string;
|
||||
id?: string;
|
||||
parameters?: Array<RuleParameter>;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user