@c8y/ngx-components 1018.503.23 → 1018.503.26
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/api/services.d.ts +1 -1
- package/core/forms/validation-pattern.d.ts +4 -0
- package/esm2020/api/services.mjs +2 -2
- package/esm2020/core/forms/validation-pattern.mjs +5 -1
- package/esm2020/trusted-certificates/crl/crl-check-settings.component.mjs +39 -0
- package/esm2020/trusted-certificates/crl/crl-settings.component.mjs +109 -0
- package/esm2020/trusted-certificates/crl/crl-settings.module.mjs +46 -0
- package/esm2020/trusted-certificates/factories/tabs.factory.mjs +36 -0
- package/esm2020/trusted-certificates/factories/trusted-certificates-navigation.factory.mjs +26 -0
- package/esm2020/trusted-certificates/index.mjs +4 -4
- package/esm2020/trusted-certificates/{add-trusted-certificate.component.mjs → list/add-trusted-certificate.component.mjs} +1 -1
- package/esm2020/trusted-certificates/list/trusted-certificate-list.component.mjs +184 -0
- package/esm2020/trusted-certificates/list/trusted-certificate-list.module.mjs +54 -0
- package/esm2020/trusted-certificates/list/trusted-certificate.model.mjs +36 -0
- package/esm2020/trusted-certificates/trusted-certificates.module.mjs +24 -35
- package/fesm2015/c8y-ngx-components-api.mjs +3 -2
- package/fesm2015/c8y-ngx-components-api.mjs.map +1 -1
- package/fesm2015/c8y-ngx-components-trusted-certificates.mjs +329 -86
- package/fesm2015/c8y-ngx-components-trusted-certificates.mjs.map +1 -1
- package/fesm2015/c8y-ngx-components.mjs +4 -0
- package/fesm2015/c8y-ngx-components.mjs.map +1 -1
- package/fesm2020/c8y-ngx-components-api.mjs +3 -2
- package/fesm2020/c8y-ngx-components-api.mjs.map +1 -1
- package/fesm2020/c8y-ngx-components-trusted-certificates.mjs +314 -85
- package/fesm2020/c8y-ngx-components-trusted-certificates.mjs.map +1 -1
- package/fesm2020/c8y-ngx-components.mjs +4 -0
- package/fesm2020/c8y-ngx-components.mjs.map +1 -1
- package/locales/locales.pot +48 -0
- package/package.json +1 -1
- package/trusted-certificates/crl/crl-check-settings.component.d.ts +18 -0
- package/trusted-certificates/crl/crl-settings.component.d.ts +28 -0
- package/trusted-certificates/crl/crl-settings.module.d.ts +13 -0
- package/trusted-certificates/factories/tabs.factory.d.ts +10 -0
- package/trusted-certificates/index.d.ts +3 -3
- package/trusted-certificates/{trusted-certificates.component.d.ts → list/trusted-certificate-list.component.d.ts} +4 -4
- package/trusted-certificates/list/trusted-certificate-list.module.d.ts +15 -0
- package/trusted-certificates/trusted-certificates.module.d.ts +4 -10
- package/esm2020/trusted-certificates/trusted-certificate.model.mjs +0 -36
- package/esm2020/trusted-certificates/trusted-certificates-navigation.factory.mjs +0 -26
- package/esm2020/trusted-certificates/trusted-certificates.component.mjs +0 -184
- /package/trusted-certificates/{trusted-certificates-navigation.factory.d.ts → factories/trusted-certificates-navigation.factory.d.ts} +0 -0
- /package/trusted-certificates/{add-trusted-certificate.component.d.ts → list/add-trusted-certificate.component.d.ts} +0 -0
- /package/trusted-certificates/{trusted-certificate.model.d.ts → list/trusted-certificate.model.d.ts} +0 -0
|
@@ -1,57 +1,46 @@
|
|
|
1
1
|
import { NgModule } from '@angular/core';
|
|
2
2
|
import { RouterModule } from '@angular/router';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { BsDropdownModule } from 'ngx-bootstrap/dropdown';
|
|
6
|
-
import { PopoverModule } from 'ngx-bootstrap/popover';
|
|
7
|
-
import { TooltipModule } from 'ngx-bootstrap/tooltip';
|
|
8
|
-
import { AddTrustedCertificateComponent } from './add-trusted-certificate.component';
|
|
9
|
-
import { ButtonsModule } from 'ngx-bootstrap/buttons';
|
|
10
|
-
import { ReactiveFormsModule } from '@angular/forms';
|
|
11
|
-
import { TrustedCertificatesNavigationFactory } from './trusted-certificates-navigation.factory';
|
|
3
|
+
import { hookNavigator, hookPatternMessages, hookTab } from '@c8y/ngx-components';
|
|
4
|
+
import { TrustedCertificatesNavigationFactory } from './factories/trusted-certificates-navigation.factory';
|
|
12
5
|
import { MESSAGES } from './pattern-messages.data';
|
|
6
|
+
import { TabsFactory } from './factories/tabs.factory';
|
|
7
|
+
import { CrlSettingsModule } from './crl/crl-settings.module';
|
|
8
|
+
import { TrustedCertificateListModule } from './list/trusted-certificate-list.module';
|
|
13
9
|
import * as i0 from "@angular/core";
|
|
14
10
|
import * as i1 from "@angular/router";
|
|
15
|
-
import * as i2 from "ngx-bootstrap/dropdown";
|
|
16
11
|
const trustedCertificatesRoutes = [
|
|
17
12
|
{
|
|
18
13
|
path: 'trusted-certificates',
|
|
19
|
-
|
|
14
|
+
pathMatch: 'full',
|
|
15
|
+
redirectTo: 'trusted-certificates/certificates'
|
|
20
16
|
}
|
|
21
17
|
];
|
|
22
18
|
export class TrustedCertificatesModule {
|
|
23
19
|
}
|
|
24
20
|
TrustedCertificatesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: TrustedCertificatesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
25
|
-
TrustedCertificatesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.7", ngImport: i0, type: TrustedCertificatesModule,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
TooltipModule,
|
|
35
|
-
ReactiveFormsModule,
|
|
36
|
-
ButtonsModule,
|
|
37
|
-
PopoverModule] });
|
|
21
|
+
TrustedCertificatesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.7", ngImport: i0, type: TrustedCertificatesModule, imports: [i1.RouterModule, CrlSettingsModule,
|
|
22
|
+
TrustedCertificateListModule] });
|
|
23
|
+
TrustedCertificatesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: TrustedCertificatesModule, providers: [
|
|
24
|
+
hookNavigator(TrustedCertificatesNavigationFactory),
|
|
25
|
+
hookPatternMessages(MESSAGES),
|
|
26
|
+
hookTab(TabsFactory)
|
|
27
|
+
], imports: [RouterModule.forChild(trustedCertificatesRoutes),
|
|
28
|
+
CrlSettingsModule,
|
|
29
|
+
TrustedCertificateListModule] });
|
|
38
30
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: TrustedCertificatesModule, decorators: [{
|
|
39
31
|
type: NgModule,
|
|
40
32
|
args: [{
|
|
41
|
-
declarations: [TrustedCertificatesComponent, AddTrustedCertificateComponent],
|
|
42
33
|
exports: [],
|
|
43
34
|
imports: [
|
|
44
|
-
CoreModule,
|
|
45
|
-
CommonModule,
|
|
46
35
|
RouterModule.forChild(trustedCertificatesRoutes),
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
ReactiveFormsModule,
|
|
50
|
-
ButtonsModule,
|
|
51
|
-
PopoverModule
|
|
36
|
+
CrlSettingsModule,
|
|
37
|
+
TrustedCertificateListModule
|
|
52
38
|
],
|
|
53
|
-
|
|
54
|
-
|
|
39
|
+
providers: [
|
|
40
|
+
hookNavigator(TrustedCertificatesNavigationFactory),
|
|
41
|
+
hookPatternMessages(MESSAGES),
|
|
42
|
+
hookTab(TabsFactory)
|
|
43
|
+
]
|
|
55
44
|
}]
|
|
56
45
|
}] });
|
|
57
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
46
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHJ1c3RlZC1jZXJ0aWZpY2F0ZXMubW9kdWxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vdHJ1c3RlZC1jZXJ0aWZpY2F0ZXMvdHJ1c3RlZC1jZXJ0aWZpY2F0ZXMubW9kdWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxRQUFRLEVBQUUsTUFBTSxlQ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Age1xuICAgIHBhdGg6ICd0cnVzdGVkLWNlcnRpZmljYXRlcycsXG4gICAgcGF0aE1hdGNoOiAnZnVsbCcsXG4gICAgcmVkaXJlY3RUbzogJ3RydXN0ZWQtY2VydGlmaWNhdGVzL2NlcnRpZmljYXRlcydcbiAgfVxuXTtcblxuQE5nTW9kdWxlKHtcbiAgZXhwb3J0czogW10sXG4gIGltcG9ydHM6IFtcbiAgICBSb3V0ZXJNb2R1bGUuZm9yQ2hpbGQodHJ1c3RlZENlcnRpZmljYXRlc1JvdXRlcyksXG4gICAgQ3JsU2V0dGluZ3NNb2R1bGUsXG4gICAgVHJ1c3RlZENlcnRpZmljYXRlTGlzdE1vZHVsZVxuICBdLFxuICBwcm92aWRlcnM6IFtcbiAgICBob29rTmF2aWdhdG9yKFRydXN0ZWRDZXJ0aWZpY2F0ZXNOYXZpZ2F0aW9uRmFjdG9yeSksXG4gICAgaG9va1BhdHRlcm5NZXNzYWdlcyhNRVNTQUdFUyksXG4gICAgaG9va1RhYihUYWJzRmFjdG9yeSlcbiAgXVxufSlcbmV4cG9ydCBjbGFzcyBUcnVzdGVkQ2VydGlmaWNhdGVzTW9kdWxlIHt9XG4iXX0=
|
|
@@ -4,8 +4,8 @@ import { Injectable, NgModule } from '@angular/core';
|
|
|
4
4
|
import { from, Subject, pipe } from 'rxjs';
|
|
5
5
|
import { filter } from 'rxjs/operators';
|
|
6
6
|
import * as i1 from '@c8y/client';
|
|
7
|
-
import { AlarmService, ApplicationService, AuditService, BasicAuth, CookieAuth, DeviceRegistrationBulkService, DeviceRegistrationService, EventBinaryService, EventService, FetchClient, IdentityService, InventoryBinaryService, InventoryRoleService, InventoryService, MeasurementService, OperationBulkService, OperationService, Realtime, SmartGroupsService, SmartRulesService, SystemOptionsService, TenantLoginOptionsService, TenantOptionsService, TenantSecurityOptionsService, TenantService, TrustedCertificateService, UserGroupService, UserRoleService, UserService } from '@c8y/client';
|
|
8
|
-
export { AlarmService, ApplicationService, AuditService, BasicAuth, CookieAuth, DeviceRegistrationBulkService, DeviceRegistrationService, EventBinaryService, EventService, FetchClient, IdentityService, InventoryBinaryService, InventoryRoleService, InventoryService, MeasurementService, OperationBulkService, OperationService, Realtime, SmartGroupsService, SmartRulesService, SystemOptionsService, TenantLoginOptionsService, TenantOptionsService, TenantSecurityOptionsService, TenantService, TrustedCertificateService, UserGroupService, UserRoleService, UserService } from '@c8y/client';
|
|
7
|
+
import { AlarmService, ApplicationService, AuditService, BasicAuth, CookieAuth, CrlService, DeviceRegistrationBulkService, DeviceRegistrationService, EventBinaryService, EventService, FetchClient, IdentityService, InventoryBinaryService, InventoryRoleService, InventoryService, MeasurementService, OperationBulkService, OperationService, Realtime, SmartGroupsService, SmartRulesService, SystemOptionsService, TenantLoginOptionsService, TenantOptionsService, TenantSecurityOptionsService, TenantService, TrustedCertificateService, UserGroupService, UserRoleService, UserService } from '@c8y/client';
|
|
8
|
+
export { AlarmService, ApplicationService, AuditService, BasicAuth, CookieAuth, CrlService, DeviceRegistrationBulkService, DeviceRegistrationService, EventBinaryService, EventService, FetchClient, IdentityService, InventoryBinaryService, InventoryRoleService, InventoryService, MeasurementService, OperationBulkService, OperationService, Realtime, SmartGroupsService, SmartRulesService, SystemOptionsService, TenantLoginOptionsService, TenantOptionsService, TenantSecurityOptionsService, TenantService, TrustedCertificateService, UserGroupService, UserRoleService, UserService } from '@c8y/client';
|
|
9
9
|
|
|
10
10
|
class HttpHandler {
|
|
11
11
|
}
|
|
@@ -165,6 +165,7 @@ var services = /*#__PURE__*/Object.freeze({
|
|
|
165
165
|
AuditService: AuditService,
|
|
166
166
|
BasicAuth: BasicAuth,
|
|
167
167
|
CookieAuth: CookieAuth,
|
|
168
|
+
CrlService: CrlService,
|
|
168
169
|
DeviceRegistrationBulkService: DeviceRegistrationBulkService,
|
|
169
170
|
DeviceRegistrationService: DeviceRegistrationService,
|
|
170
171
|
EventBinaryService: EventBinaryService,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"c8y-ngx-components-api.mjs","sources":["../../api/interceptor.model.ts","../../api/http-handler.model.ts","../../api/api.service.ts","../../api/data.module.ts","../../api/index.ts","../../api/c8y-ngx-components-api.ts"],"sourcesContent":["import { ApiCall } from './api.model';\nimport { Observable } from 'rxjs';\nimport { IFetchResponse } from '@c8y/client';\n\nexport interface HttpInterceptor {\n intercept(req: ApiCall, next: HttpHandler): Observable<IFetchResponse>;\n}\n\nexport abstract class HttpHandler {\n abstract handle(req: ApiCall): Observable<IFetchResponse>;\n}\n","import { ApiCall } from './api.model';\nimport { Observable, from } from 'rxjs';\nimport { FetchClient, IFetchResponse } from '@c8y/client';\nimport { HttpHandler, HttpInterceptor } from './interceptor.model';\n\nexport class HttpInterceptHandler extends HttpHandler {\n constructor(protected interceptor: HttpInterceptor, protected nextHandler: HttpHandler) {\n super();\n }\n\n handle(req: ApiCall): Observable<IFetchResponse> {\n return this.interceptor.intercept(req, this.nextHandler);\n }\n}\n\nexport interface RequestStartAndFinish {\n onStart(req: ApiCall): void;\n onFinish(res: ApiCall): void;\n}\n\nexport class HttpRequestHandler extends HttpHandler {\n constructor(protected fetch: FetchClient['fetch'], protected apiService?: RequestStartAndFinish) {\n super();\n }\n\n handle(req: ApiCall): Observable<IFetchResponse> {\n const { options, url } = req;\n const { method } = options;\n this.apiService?.onStart({ method, options, url });\n let fetchPromise = this.fetch(url, options);\n if (typeof options.responseInterceptor === 'function') {\n fetchPromise = fetchPromise.then(options.responseInterceptor);\n }\n fetchPromise.then(\n (response: IFetchResponse) => this.apiService?.onFinish({ method, options, url, response }),\n (response: IFetchResponse) => this.apiService?.onFinish({ method, options, url, response })\n );\n return from(fetchPromise);\n }\n}\n","import { Injectable } from '@angular/core';\nimport { FetchClient, IFetchOptions, IFetchResponse } from '@c8y/client';\nimport { MonoTypeOperatorFunction, Observable, Subject, pipe } from 'rxjs';\nimport { filter } from 'rxjs/operators';\nimport { ApiCall, ApiCallOptions } from './api.model';\nimport {\n HttpInterceptHandler,\n HttpRequestHandler,\n RequestStartAndFinish\n} from './http-handler.model';\nimport { HttpHandler, HttpInterceptor } from './interceptor.model';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class ApiService implements RequestStartAndFinish {\n calls: Observable<ApiCall>;\n private callsSubject = new Subject<ApiCall>();\n private interceptors = new Map<string, HttpInterceptor>();\n private interceptorCounter = 0;\n\n constructor(private client: FetchClient) {\n this.calls = this.callsSubject.asObservable();\n this.hookIntoClientFetch();\n }\n\n /**\n * Allows to hook into the responses received by the FetchClient.\n * This is meant to be used to react on the responses, not for manipulation of the responses.\n * @param hookFilter A filter function to filter for specific responses.\n * @returns An Observable of the filtered responses.\n */\n hookResponse(hookFilter: (call: ApiCall) => boolean) {\n return this.callsSubject.pipe(\n filter(({ phase }) => phase === 'finish'),\n filter(hookFilter)\n );\n }\n\n /**\n * Allows to hook into the requests performed by the FetchClient.\n * This is meant to be used to react on the requests, not for manipulation of the requests.\n * @param hookFilter A filter function to filter for specific requests.\n * @returns An Observable of the filtered requests.\n */\n hookRequest(hookFilter: (call: ApiCall) => boolean) {\n return this.callsSubject.pipe(\n filter(({ phase }) => phase === 'start'),\n filter(hookFilter)\n );\n }\n\n onFinish(call: ApiCall) {\n this.callsSubject.next({ phase: 'finish', ...call });\n }\n\n onStart(call: ApiCall) {\n this.callsSubject.next({ phase: 'start', ...call });\n }\n\n resolveData<T = unknown>(call: ApiCall): Promise<{ data: T; method: string; url: string }> {\n const { response, method, url } = call;\n if ('data' in response) {\n return Promise.resolve({ data: response.data, method, url });\n } else {\n // No Content success status, for example DELETE request.\n if ((response as Response)?.status === 204) {\n return Promise.resolve({ data: null, method, url });\n }\n const cb = data => ({ data, method, url });\n return (response as Response).clone().json().then(cb, cb);\n }\n }\n\n /**\n * Can be added to a pipe to exclude any permission call. Permission calls are PUT\n * request with only an id in it, to verify if the user has access to this managed object.\n * @returns The operator to be added to a pipe.\n */\n excludePermissionCall(): MonoTypeOperatorFunction<ApiCall> {\n return pipe(\n filter(({ method, options }) => {\n if (method === 'PUT' && options.body && typeof options.body === 'string') {\n const parsedBody = JSON.parse(options.body as string);\n const bodyKeys = Object.keys(parsedBody);\n return !(bodyKeys.length === 1 && bodyKeys[0] === 'id');\n }\n return true;\n })\n );\n }\n\n /**\n * Allows to intercept requests performed via the FetchClient requests.\n * @param interceptor The interceptor to be added.\n * @param id An optional unique identifier for the interceptor. The chain of interceptors is ordered by this id. And it can be used to remove the interceptor later on.\n * @returns The id of the interceptor (same as provided id if one was provided, otherwise an id will be generated).\n */\n addInterceptor(interceptor: HttpInterceptor, id?: string): string {\n if (!id) {\n id = `${++this.interceptorCounter}`;\n }\n this.interceptors.set(id, interceptor);\n return id;\n }\n\n /**\n * Allows to remove a previously added interceptor by it's id.\n * @param id The id of the interceptor that should be removed.\n * @returns true if an interceptor existed and has been removed, or false if id does not exist.\n */\n removeInterceptor(id: string): boolean {\n return this.interceptors.delete(id);\n }\n\n /**\n * Checks if an interceptor with a given id exists.\n * @param id The id of the interceptor.\n * @returns - Returns true if an interceptor with the given id exists, otherwise false.\n */\n hasInterceptor(id: string): boolean {\n return this.interceptors.has(id);\n }\n\n private hookIntoClientFetch() {\n const fetch: FetchClient['fetch'] = this.client.fetch.bind(this.client);\n const requestHandler = new HttpRequestHandler(fetch, this);\n this.client.fetch = async (\n url,\n options: ApiCallOptions & IFetchOptions = { method: 'GET' }\n ) => {\n const { method } = options;\n return this.createInterceptorChain({ url, options, method }, requestHandler).toPromise();\n };\n }\n\n private createInterceptorChain(\n call: ApiCall,\n requestHandler: HttpRequestHandler\n ): Observable<IFetchResponse> {\n let handler: HttpHandler = requestHandler;\n // Do some sorting to always apply the interceptors in the specific order\n const sortedInterceptorIds = Array.from(this.interceptors.keys()).sort((a, b) =>\n b.localeCompare(a)\n );\n for (const interceptorId of sortedInterceptorIds) {\n handler = new HttpInterceptHandler(this.interceptors.get(interceptorId), handler);\n }\n return handler.handle(call);\n }\n}\n","import { ModuleWithProviders, NgModule, Provider, Type } from '@angular/core';\nimport { BasicAuth, FetchClient, Realtime, CookieAuth } from '@c8y/client';\nimport { ApiService } from './api.service';\nimport * as services from './services';\n\nfunction toProvider(provide: Type<unknown>): Provider {\n let deps: Array<Type<FetchClient | Realtime | CookieAuth>> = [FetchClient, Realtime];\n if (provide === FetchClient) {\n deps = [CookieAuth];\n }\n if (provide === BasicAuth || provide === CookieAuth) {\n deps = [];\n }\n if (provide === Realtime) {\n deps = [FetchClient];\n }\n return { provide, useClass: provide, deps };\n}\n\nconst providers: Provider[] = Object.keys(services)\n .map(k => toProvider(services[k]))\n .concat([{ provide: ApiService, useClass: ApiService, deps: [FetchClient] }]);\n// @dynamic\n@NgModule({\n providers\n})\nexport class DataModule {\n static providers(): Provider[] {\n return providers;\n }\n static forRoot(): ModuleWithProviders<DataModule> {\n return {\n ngModule: DataModule,\n providers\n };\n }\n}\n","export * from './api.service';\nexport * from './api.model';\nexport * from './data.module';\nexport * from './services';\nexport * from './interceptor.model';\n// do not expose as it might confuse people on what to implement\n// export * from './http-handler.model';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;MAQsB,WAAW,CAAA;AAEhC;;ACLK,MAAO,oBAAqB,SAAQ,WAAW,CAAA;IACnD,WAAsB,CAAA,WAA4B,EAAY,WAAwB,EAAA;AACpF,QAAA,KAAK,EAAE,CAAC;AADY,QAAA,IAAW,CAAA,WAAA,GAAX,WAAW,CAAiB;AAAY,QAAA,IAAW,CAAA,WAAA,GAAX,WAAW,CAAa;KAErF;AAED,IAAA,MAAM,CAAC,GAAY,EAAA;AACjB,QAAA,OAAO,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;KAC1D;AACF,CAAA;AAOK,MAAO,kBAAmB,SAAQ,WAAW,CAAA;IACjD,WAAsB,CAAA,KAA2B,EAAY,UAAkC,EAAA;AAC7F,QAAA,KAAK,EAAE,CAAC;AADY,QAAA,IAAK,CAAA,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s","sources":["../../api/interceptor.model.ts","../../api/http-handler.model.ts","../../api/api.service.ts","../../api/data.module.ts","../../api/index.ts","../../api/c8y-ngx-components-api.ts"],"sourcesContent":["import { ApiCall } from './api.model';\nimport { Observable } from 'rxjs';\nimport { IFetchResponse } from '@c8y/client';\n\nexport interface HttpInterceptor {\n intercept(req: ApiCall, next: HttpHandler): Observable<IFetchResponse>;\n}\n\nexport abstract class HttpHandler {\n abstract handle(req: ApiCall): Observable<IFetchResponse>;\n}\n","import { ApiCall } from './api.model';\nimport { Observable, from } from 'rxjs';\nimport { FetchClient, IFetchResponse } from '@c8y/client';\nimport { HttpHandler, HttpInterceptor } from './interceptor.model';\n\nexport class HttpInterceptHandler extends HttpHandler {\n constructor(protected interceptor: HttpInterceptor, protected nextHandler: HttpHandler) {\n super();\n }\n\n handle(req: ApiCall): Observable<IFetchResponse> {\n return this.interceptor.intercept(req, this.nextHandler);\n }\n}\n\nexport interface RequestStartAndFinish {\n onStart(req: ApiCall): void;\n onFinish(res: ApiCall): void;\n}\n\nexport class HttpRequestHandler extends HttpHandler {\n constructor(protected fetch: FetchClient['fetch'], protected apiService?: RequestStartAndFinish) {\n super();\n }\n\n handle(req: ApiCall): Observable<IFetchResponse> {\n const { options, url } = req;\n const { method } = options;\n this.apiService?.onStart({ method, options, url });\n let fetchPromise = this.fetch(url, options);\n if (typeof options.responseInterceptor === 'function') {\n fetchPromise = fetchPromise.then(options.responseInterceptor);\n }\n fetchPromise.then(\n (response: IFetchResponse) => this.apiService?.onFinish({ method, options, url, response }),\n (response: IFetchResponse) => this.apiService?.onFinish({ method, options, url, response })\n );\n return from(fetchPromise);\n }\n}\n","import { Injectable } from '@angular/core';\nimport { FetchClient, IFetchOptions, IFetchResponse } from '@c8y/client';\nimport { MonoTypeOperatorFunction, Observable, Subject, pipe } from 'rxjs';\nimport { filter } from 'rxjs/operators';\nimport { ApiCall, ApiCallOptions } from './api.model';\nimport {\n HttpInterceptHandler,\n HttpRequestHandler,\n RequestStartAndFinish\n} from './http-handler.model';\nimport { HttpHandler, HttpInterceptor } from './interceptor.model';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class ApiService implements RequestStartAndFinish {\n calls: Observable<ApiCall>;\n private callsSubject = new Subject<ApiCall>();\n private interceptors = new Map<string, HttpInterceptor>();\n private interceptorCounter = 0;\n\n constructor(private client: FetchClient) {\n this.calls = this.callsSubject.asObservable();\n this.hookIntoClientFetch();\n }\n\n /**\n * Allows to hook into the responses received by the FetchClient.\n * This is meant to be used to react on the responses, not for manipulation of the responses.\n * @param hookFilter A filter function to filter for specific responses.\n * @returns An Observable of the filtered responses.\n */\n hookResponse(hookFilter: (call: ApiCall) => boolean) {\n return this.callsSubject.pipe(\n filter(({ phase }) => phase === 'finish'),\n filter(hookFilter)\n );\n }\n\n /**\n * Allows to hook into the requests performed by the FetchClient.\n * This is meant to be used to react on the requests, not for manipulation of the requests.\n * @param hookFilter A filter function to filter for specific requests.\n * @returns An Observable of the filtered requests.\n */\n hookRequest(hookFilter: (call: ApiCall) => boolean) {\n return this.callsSubject.pipe(\n filter(({ phase }) => phase === 'start'),\n filter(hookFilter)\n );\n }\n\n onFinish(call: ApiCall) {\n this.callsSubject.next({ phase: 'finish', ...call });\n }\n\n onStart(call: ApiCall) {\n this.callsSubject.next({ phase: 'start', ...call });\n }\n\n resolveData<T = unknown>(call: ApiCall): Promise<{ data: T; method: string; url: string }> {\n const { response, method, url } = call;\n if ('data' in response) {\n return Promise.resolve({ data: response.data, method, url });\n } else {\n // No Content success status, for example DELETE request.\n if ((response as Response)?.status === 204) {\n return Promise.resolve({ data: null, method, url });\n }\n const cb = data => ({ data, method, url });\n return (response as Response).clone().json().then(cb, cb);\n }\n }\n\n /**\n * Can be added to a pipe to exclude any permission call. Permission calls are PUT\n * request with only an id in it, to verify if the user has access to this managed object.\n * @returns The operator to be added to a pipe.\n */\n excludePermissionCall(): MonoTypeOperatorFunction<ApiCall> {\n return pipe(\n filter(({ method, options }) => {\n if (method === 'PUT' && options.body && typeof options.body === 'string') {\n const parsedBody = JSON.parse(options.body as string);\n const bodyKeys = Object.keys(parsedBody);\n return !(bodyKeys.length === 1 && bodyKeys[0] === 'id');\n }\n return true;\n })\n );\n }\n\n /**\n * Allows to intercept requests performed via the FetchClient requests.\n * @param interceptor The interceptor to be added.\n * @param id An optional unique identifier for the interceptor. The chain of interceptors is ordered by this id. And it can be used to remove the interceptor later on.\n * @returns The id of the interceptor (same as provided id if one was provided, otherwise an id will be generated).\n */\n addInterceptor(interceptor: HttpInterceptor, id?: string): string {\n if (!id) {\n id = `${++this.interceptorCounter}`;\n }\n this.interceptors.set(id, interceptor);\n return id;\n }\n\n /**\n * Allows to remove a previously added interceptor by it's id.\n * @param id The id of the interceptor that should be removed.\n * @returns true if an interceptor existed and has been removed, or false if id does not exist.\n */\n removeInterceptor(id: string): boolean {\n return this.interceptors.delete(id);\n }\n\n /**\n * Checks if an interceptor with a given id exists.\n * @param id The id of the interceptor.\n * @returns - Returns true if an interceptor with the given id exists, otherwise false.\n */\n hasInterceptor(id: string): boolean {\n return this.interceptors.has(id);\n }\n\n private hookIntoClientFetch() {\n const fetch: FetchClient['fetch'] = this.client.fetch.bind(this.client);\n const requestHandler = new HttpRequestHandler(fetch, this);\n this.client.fetch = async (\n url,\n options: ApiCallOptions & IFetchOptions = { method: 'GET' }\n ) => {\n const { method } = options;\n return this.createInterceptorChain({ url, options, method }, requestHandler).toPromise();\n };\n }\n\n private createInterceptorChain(\n call: ApiCall,\n requestHandler: HttpRequestHandler\n ): Observable<IFetchResponse> {\n let handler: HttpHandler = requestHandler;\n // Do some sorting to always apply the interceptors in the specific order\n const sortedInterceptorIds = Array.from(this.interceptors.keys()).sort((a, b) =>\n b.localeCompare(a)\n );\n for (const interceptorId of sortedInterceptorIds) {\n handler = new HttpInterceptHandler(this.interceptors.get(interceptorId), handler);\n }\n return handler.handle(call);\n }\n}\n","import { ModuleWithProviders, NgModule, Provider, Type } from '@angular/core';\nimport { BasicAuth, FetchClient, Realtime, CookieAuth } from '@c8y/client';\nimport { ApiService } from './api.service';\nimport * as services from './services';\n\nfunction toProvider(provide: Type<unknown>): Provider {\n let deps: Array<Type<FetchClient | Realtime | CookieAuth>> = [FetchClient, Realtime];\n if (provide === FetchClient) {\n deps = [CookieAuth];\n }\n if (provide === BasicAuth || provide === CookieAuth) {\n deps = [];\n }\n if (provide === Realtime) {\n deps = [FetchClient];\n }\n return { provide, useClass: provide, deps };\n}\n\nconst providers: Provider[] = Object.keys(services)\n .map(k => toProvider(services[k]))\n .concat([{ provide: ApiService, useClass: ApiService, deps: [FetchClient] }]);\n// @dynamic\n@NgModule({\n providers\n})\nexport class DataModule {\n static providers(): Provider[] {\n return providers;\n }\n static forRoot(): ModuleWithProviders<DataModule> {\n return {\n ngModule: DataModule,\n providers\n };\n }\n}\n","export * from './api.service';\nexport * from './api.model';\nexport * from './data.module';\nexport * from './services';\nexport * from './interceptor.model';\n// do not expose as it might confuse people on what to implement\n// export * from './http-handler.model';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;MAQsB,WAAW,CAAA;AAEhC;;ACLK,MAAO,oBAAqB,SAAQ,WAAW,CAAA;IACnD,WAAsB,CAAA,WAA4B,EAAY,WAAwB,EAAA;AACpF,QAAA,KAAK,EAAE,CAAC;AADY,QAAA,IAAW,CAAA,WAAA,GAAX,WAAW,CAAiB;AAAY,QAAA,IAAW,CAAA,WAAA,GAAX,WAAW,CAAa;KAErF;AAED,IAAA,MAAM,CAAC,GAAY,EAAA;AACjB,QAAA,OAAO,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;KAC1D;AACF,CAAA;AAOK,MAAO,kBAAmB,SAAQ,WAAW,CAAA;IACjD,WAAsB,CAAA,KAA2B,EAAY,UAAkC,EAAA;AAC7F,QAAA,KAAK,EAAE,CAAC;AADY,QAAA,IAAK,CAAA,KAAA,GAAL,KAAK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