Skip to content

Commit

Permalink
remove js-api core
Browse files Browse the repository at this point in the history
  • Loading branch information
eromano authored and BSekula committed Feb 27, 2024
1 parent bec773b commit 99c56ee
Show file tree
Hide file tree
Showing 12 changed files with 225 additions and 5 deletions.
1 change: 0 additions & 1 deletion lib/core/api/src/lib/adf-http-client.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* limitations under the License.
*/

import { Emitters, RequestOptions, ResultListDataRepresentationTaskRepresentation, SecurityOptions } from '@alfresco/js-api';
import { HttpParams } from '@angular/common/http';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { TestBed } from '@angular/core/testing';
Expand Down
3 changes: 2 additions & 1 deletion lib/core/api/src/lib/adf-http-client.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
*/

import { SHOULD_ADD_AUTH_TOKEN } from '@alfresco/adf-core/auth';
import { Emitters as JsApiEmitters, HttpClient as JsApiHttpClient } from '@alfresco/js-api';
import { Emitters as JsApiEmitters } from '../../../src/lib/models/http-client.interface';
import { HttpClient as JsApiHttpClient } from './interfaces';
import {
HttpClient,
HttpContext,
Expand Down
10 changes: 10 additions & 0 deletions lib/core/api/src/lib/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
* limitations under the License.
*/

import { Emitters } from '../../../src/lib/models/http-client.interface';

export interface SecurityOptions {
readonly withCredentials?: boolean;
readonly authentications?: Authentication;
Expand Down Expand Up @@ -53,3 +55,11 @@ export interface RequestOptions {
readonly accept?: string;
readonly contentType?: string;
}

export interface HttpClient {
request<T = any>(url: string, options: RequestOptions, security: SecurityOptions, emitters: Emitters): Promise<T>;
post<T = any>(url: string, options: RequestOptions, security: SecurityOptions, emitters: Emitters): Promise<T>;
put<T = any>(url: string, options: RequestOptions, security: SecurityOptions, emitters: Emitters): Promise<T>;
get<T = any>(url: string, options: RequestOptions, security: SecurityOptions, emitters: Emitters): Promise<T>;
delete<T = void>(url: string, options: RequestOptions, security: SecurityOptions, emitters: Emitters): Promise<T>;
}
1 change: 0 additions & 1 deletion lib/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"@angular/material": ">=14.1.2",
"@angular/router": ">=14.1.3",
"@mat-datetimepicker/core": "^10.1.1",
"@alfresco/js-api": ">=7.5.0",
"@alfresco/adf-extensions": ">=6.6.0",
"@ngx-translate/core": ">=14.0.0",
"minimatch-browser": ">=1.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { ChangeDetectionStrategy, Component, Input, OnInit, ViewEncapsulation }
import { DataTableCellComponent } from '../datatable-cell/datatable-cell.component';
import { AsyncPipe } from '@angular/common';
import { RouterModule } from '@angular/router';
import { PathInfo } from '@alfresco/js-api';
import { PathInfo } from '../../../models/path.model';

@Component({
standalone: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { PathInfo } from '@alfresco/js-api';
import { PathInfo } from '../../../models/path.model';
import { DataColumn } from '../../data/data-column.model';

export const mockCarsData: any = [
Expand Down
26 changes: 26 additions & 0 deletions lib/core/src/lib/models/authentication.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*!
* @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 { BasicAuth } from './basicAuth';
import { Oauth2 } from './oauth2';

export interface Authentication {
basicAuth?: BasicAuth;
oauth2?: Oauth2;
cookie?: string;
type?: string;
}
22 changes: 22 additions & 0 deletions lib/core/src/lib/models/basicAuth.ts
Original file line number Diff line number Diff line change
@@ -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 BasicAuth {
username?: string;
password?: string;
ticket?: string;
}
106 changes: 106 additions & 0 deletions lib/core/src/lib/models/http-client.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/*!
* @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 { Authentication } from './authentication';
import { Emitter } from 'event-emitter';

export interface RequestOptions {
path: string;
httpMethod?: string;
pathParams?: any;
queryParams?: any;
headerParams?: any;
formParams?: any;
bodyParam?: any;
contentTypes?: string[];
accepts?: string[];
returnType?: any;
contextRoot?: string;
responseType?: string;
url?: string;
readonly accept?: string;
readonly contentType?: string;
}

export interface HttpClientConfig {
contextRoot?: string;
host?: string; // Should be mandatory but can't make it because of AlfrescoApiConfig incompatibility 😕
servicePath?: string; // Should be mandatory but can't make it because of AlfrescoApiConfig incompatibility 😕
}

export interface LegacyHttpClient {
basePath: string;
config: HttpClientConfig;

request<T = any>(options: RequestOptions): Promise<T>;
post<T = any>(options: RequestOptions): Promise<T>;
put<T = any>(options: RequestOptions): Promise<T>;
get<T = any>(options: RequestOptions): Promise<T>;
delete<T = void>(options: RequestOptions): Promise<T>;
/** @deprecated */
callApi(
path: string,
httpMethod: string,
pathParams?: any,
queryParams?: any,
headerParams?: any,
formParams?: any,
bodyParam?: any,
contentTypes?: string[],
accepts?: string[],
returnType?: any,
contextRoot?: string,
responseType?: string,
url?: string
): Promise<any>;
/** @deprecated */
callCustomApi(
path: string,
httpMethod: string,
pathParams?: any,
queryParams?: any,
headerParams?: any,
formParams?: any,
bodyParam?: any,
contentTypes?: string[],
accepts?: string[],
returnType?: any,
contextRoot?: string,
responseType?: string
): Promise<any>;
}

export interface SecurityOptions {
readonly isBpmRequest: boolean;
readonly enableCsrf?: boolean;
readonly withCredentials?: boolean;
readonly authentications: Authentication;
readonly defaultHeaders: Record<string, string>;
}

export interface Emitters {
readonly eventEmitter: Emitter;
readonly apiClientEmitter: Emitter;
}

export interface HttpClient {
request<T = any>(url: string, options: RequestOptions, security: SecurityOptions, emitters: Emitters): Promise<T>;
post<T = any>(url: string, options: RequestOptions, security: SecurityOptions, emitters: Emitters): Promise<T>;
put<T = any>(url: string, options: RequestOptions, security: SecurityOptions, emitters: Emitters): Promise<T>;
get<T = any>(url: string, options: RequestOptions, security: SecurityOptions, emitters: Emitters): Promise<T>;
delete<T = void>(url: string, options: RequestOptions, security: SecurityOptions, emitters: Emitters): Promise<T>;
}
21 changes: 21 additions & 0 deletions lib/core/src/lib/models/oauth2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*!
* @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 Oauth2 {
refreshToken?: string;
accessToken?: string;
}
35 changes: 35 additions & 0 deletions lib/core/src/lib/models/path.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*!
* @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 class PathInfo {
elements?: PathElement[];
name?: string;
isComplete?: boolean;

constructor(input?: Partial<PathInfo>) {
if (input) {
Object.assign(this, input);
}
}
}

export interface PathElement {
id?: string;
name?: string;
nodeType?: string;
aspectNames?: string[];
}
1 change: 1 addition & 0 deletions lib/core/src/lib/models/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ export * from './pagination.model';
export * from './request-pagination.model';
export * from './decimal-number.model';
export * from './general-user.model';
export * from './path.model';

0 comments on commit 99c56ee

Please sign in to comment.