[ACS-6630] Added models, APIs and docs to js-api for extension-manager feature

This commit is contained in:
swapnil.verma
2024-04-04 12:47:50 +05:30
parent e25fddf178
commit 35b6c05aae
20 changed files with 340 additions and 34 deletions

View File

@@ -47,9 +47,3 @@ export interface ContentActionRef extends ExtensionElement {
visible?: string;
};
}
export interface ActionRef {
id: string;
type: string;
payload?: any;
}

View File

@@ -15,9 +15,7 @@
* limitations under the License.
*/
import { RouteRef } from './routing.extensions';
import { RuleRef } from './rule.extensions';
import { ActionRef } from './action.extensions';
import { ActionRef, RouteRef, RuleRef } from '@alfresco/js-api';
export interface ExtensionRef {
$id: string;

View File

@@ -33,15 +33,3 @@ 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>;
}

View File

@@ -15,7 +15,8 @@
* limitations under the License.
*/
import { RuleContext, RuleParameter } from '../config/rule.extensions';
import { RuleContext } from '../config/rule.extensions';
import { RuleParameter } from '@alfresco/js-api';
export const not = (context: RuleContext, ...args: RuleParameter[]): boolean => {
if (!args || args.length === 0) {

View File

@@ -17,12 +17,11 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { ActionRef, ContentActionRef, ContentActionType } from '../config/action.extensions';
import { 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 { RouteRef } from '../config/routing.extensions';
import { RuleRef } from '../config/rule.extensions';
import { ActionRef, RouteRef, RuleRef } from '@alfresco/js-api';
@Injectable({
providedIn: 'root'

View File

@@ -18,9 +18,7 @@
import { ExtensionService } from './extension.service';
import { ExtensionLoaderService } from './extension-loader.service';
import { ExtensionConfig } from '../config/extension.config';
import { RuleRef } from '../config/rule.extensions';
import { RouteRef } from '../config/routing.extensions';
import { ActionRef } from '../config/action.extensions';
import { ActionRef, RouteRef, RuleRef } from '@alfresco/js-api';
import { ComponentRegisterService } from './component-register.service';
import { RuleService } from './rule.service';

View File

@@ -16,17 +16,16 @@
*/
import { Injectable, Type, InjectionToken, Inject } from '@angular/core';
import { RuleEvaluator, RuleRef, RuleContext } from '../config/rule.extensions';
import { RuleEvaluator, 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, RouteRef, RuleRef } from '@alfresco/js-api';
/**
* The default extensions factory

View File

@@ -16,9 +16,10 @@
*/
import { Injectable } from '@angular/core';
import { RuleRef, RuleContext, RuleEvaluator, RuleParameter } from '../config/rule.extensions';
import { RuleContext, RuleEvaluator } 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'

View File

@@ -23,7 +23,6 @@ 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';

View File

@@ -26,6 +26,7 @@ https://localhost/alfresco/api/-default-/public/alfresco/versions/1
- [RatingsApi](docs/RatingsApi.md)
- [RenditionsApi](docs/RenditionsApi.md)
- [SharedlinksApi](docs/SharedlinksApi.md)
- [SettingsApi](docs/SettingsApi.md)
- [SitesApi](docs/SitesApi.md)
- [TagsApi](docs/TagsApi.md)
- [TrashcanApi](docs/TrashcanApi.md)

View File

@@ -34,6 +34,7 @@ export * from './queries.api';
export * from './ratings.api';
export * from './renditions.api';
export * from './search-ai.api';
export * from './settings.api';
export * from './sharedlinks.api';
export * from './sites.api';
export * from './tags.api';

View File

@@ -0,0 +1,67 @@
/*!
* @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.
*/
import { BaseApi } from './base.api';
import { throwIfNotDefined } from '../../../assert';
import { ExtensionConfig } from '../model/extensionConfig';
import { ExtensionConfigEntry } from '../model/extensionConfigEntry';
export class SettingsApi extends BaseApi {
/**
* Gets the published extension configuration from
* the database
*
* @param instanceId Unique ID for a running instance of ADW
* for which configuration is to be fetched
*/
getSavedExtensionState(instanceId: string): Promise<ExtensionConfigEntry> {
throwIfNotDefined(instanceId, 'instanceId');
const pathParams = {
instanceId
};
return this.get({
path: '/settings/{instanceId}',
pathParams
});
}
/**
* Publish the extension configuration for an ADW instance
* in the database
*
* @param instanceId Unique ID for a running instance of ADW
* for which configuration is to be published
* @param extensionConfig Extension configuration that is to
* be saved
*/
publishExtensionConfig(instanceId: string, extensionConfig: ExtensionConfig): Promise<void> {
throwIfNotDefined(instanceId, 'instanceId');
throwIfNotDefined(extensionConfig, 'extensionConfig');
const pathParams = {
instanceId
};
return this.put({
path: '/settings/{instanceId}',
pathParams,
bodyParam: extensionConfig
});
}
}

View File

@@ -0,0 +1,129 @@
# SitesApi
All URIs are relative to *https://localhost/alfresco/api/-default-/public/alfresco/versions/1/*
| Method | HTTP request | Description |
|---------------------------------------------------|--------------------------------|-------------------------------------------------------------------------------------|
| [getSavedExtensionState](#getSavedExtensionState) | **GET** /settings/{instanceId} | Gets the extension configuration saved for a running instance of ADW on the backend |
| [publishExtensionConfig](#publishExtensionConfig) | **PUT** /settings/{instanceId} | Saves an extension configuration for a running instance of ADW on the backend |
## getSavedExtensionState
Gets the extension configuration saved on the backend
> this endpoint is available in <GET VERSION INFO HERE>**Alfresco 7.0.0** and newer versions.
**Parameters**
| Name | Type | Description | Notes |
|----------------|--------|----------------------------------------------|-------|
| **instanceId** | string | The identifier of a running instance of ADW. | |
**Return type**: [ExtensionConfigEntry](#ExtensionConfigEntry)
## publishExtensionConfig
Saves an extension configuration on the backend
**Parameters**
| Name | Type | Description |
|---------------------|-------------------------------------|----------------------------------------------|
| **instanceId** | string | The identifier of a running instance of ADW. |
| **extensionConfig** | [ExtensionConfig](#ExtensionConfig) | The extension configuration to be saved. |
**Example**
```javascript
import {AlfrescoApi, SitesApi} from '@alfresco/js-api';
const alfrescoApi = new AlfrescoApi(/*..*/);
const settingsApi = new SettingsApi(alfrescoApi);
const extensionConfig = new ExtensionConfig();
extensionConfig = {
appConfig: {},
features: {},
actions: [],
rules: [],
routes: []
}
settingsApi.publishExtensionConfig(`<instanceId>`, extensionConfig).then(() => {
console.log('API called successfully.');
});
```
# Models
## ExtensionConfigEntry
**Properties**
| Name | Type |
|-----------|-------------------------------------|
| **entry** | [ExtensionConfig](#ExtensionConfig) |
## ExtensionConfig
**Properties**
| Name | Type |
|---------------|-------------------------------------------|
| **appConfig** | [AppConfigPluginRef](#AppConfigPluginRef) |
| **rules** | [RuleRef[]](#RuleRef) |
| **routes** | [RouteRef[]](#RouteRef) |
| **actions** | [ActionRef[]](#ActionRef) |
| **features** | [key: string]: any |
## AppConfigPluginRef
**Properties**
| Name | Type |
|-------------|----------------------------|
| **plugins** | { [key: string]: boolean } |
## RouteRef
**Properties**
| Name | Type |
|---------------|---------------------------|
| **id** | string |
| **path** | string |
| **component** | string |
| parentRoute | string |
| layout | string |
| auth | string[] |
| data | { [key: string]: string } |
## RuleRef
**Properties**
| Name | Type |
|------------|-----------------------------------|
| **type** | string |
| id | string |
| parameters | [RuleParameter[]](#RuleParameter) |
## RuleParameter
**Properties**
| Name | Type |
|------------|-----------------------------------|
| **type** | string |
| **value** | any |
| parameters | [RuleParameter[]](#RuleParameter) |
## ActionRef
**Properties**
| Name | Type |
|-------------|--------|
| **id** | string |
| **type** | string |
| **payload** | any |

View File

@@ -0,0 +1,22 @@
/*!
* @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?: any;
}

View File

@@ -0,0 +1,22 @@
/*!
* @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 AppConfigPluginRef {
plugins: {
[key: string]: boolean;
};
}

View File

@@ -0,0 +1,31 @@
/*!
* @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.
*/
import { AppConfigPluginRef } from './appConfigPluginRef';
import { RuleRef } from './ruleRef';
import { RouteRef } from './routeRef';
import { ActionRef } from './actionRef';
export class ExtensionConfig {
appConfig: AppConfigPluginRef;
rules?: Array<RuleRef>;
routes?: Array<RouteRef>;
actions?: Array<ActionRef>;
features?: {
[key: string]: any;
};
}

View File

@@ -0,0 +1,22 @@
/*!
* @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.
*/
import { ExtensionConfig } from './extensionConfig';
export class ExtensionConfigEntry {
entry: ExtensionConfig;
}

View File

@@ -23,10 +23,12 @@ export * from './actionDefinitionListList';
export * from './actionExecResult';
export * from './actionExecResultEntry';
export * from './actionParameterDefinition';
export * from './actionRef';
export * from './activity';
export * from './activityEntry';
export * from './activityPaging';
export * from './activityPagingList';
export * from './appConfigPluginRef';
export * from './agent';
export * from './agentEntry';
export * from './agentPaging';
@@ -79,6 +81,8 @@ export * from './download-status';
export * from './downloadBodyCreate';
export * from './downloadEntry';
export * from './errorError';
export * from './extensionConfig';
export * from './extensionConfigEntry';
export * from './favorite';
export * from './favoriteBodyCreate';
export * from './favoriteEntry';
@@ -156,6 +160,8 @@ 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';

View File

@@ -0,0 +1,28 @@
/*!
* @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: any;
parameters?: Array<RuleParameter>;
}
export class RuleRef {
type: string;
id?: string;
parameters?: Array<RuleParameter>;
}