@sap-ux/store
Advanced tools
@@ -59,7 +59,3 @@ "use strict"; | ||
| } | ||
| const systemList = Object.values(systems); | ||
| if (!backendSystemFilter) { | ||
| return systemList; | ||
| } | ||
| return this.applyFilters(systemList, backendSystemFilter); | ||
| return this.applyFilters(Object.values(systems), backendSystemFilter); | ||
| } | ||
@@ -85,2 +81,6 @@ /** | ||
| applyFilters(systems, filters = {}) { | ||
| if (!filters.connectionType) { | ||
| // unless a filter for connectionType is explicitly provided, default to filtering by the ABAP Catalog type as this is what existing consumers expect | ||
| filters.connectionType = 'abap_catalog'; | ||
| } | ||
| return systems.filter((system) => (0, utils_1.isMatch)(system, filters)); | ||
@@ -87,0 +87,0 @@ } |
@@ -7,5 +7,6 @@ import type { Logger } from '@sap-ux/logger'; | ||
| * The backend system keys and their values to filter backend systems by. | ||
| * Each filter value can be either a single value or an array of values. | ||
| */ | ||
| export type BackendSystemFilter = Partial<{ | ||
| [K in BackendSerializableKeys]: BackendSystem[K]; | ||
| [K in BackendSerializableKeys]: BackendSystem[K] | BackendSystem[K][]; | ||
| }>; | ||
@@ -12,0 +13,0 @@ /** |
@@ -31,2 +31,9 @@ import type { Logger } from '@sap-ux/logger'; | ||
| delete(entity: BackendSystem): Promise<boolean>; | ||
| /** | ||
| * Retrieves all backend systems from the store. Can be filtered by providing retrieval options. | ||
| * N.B. if no `connectionType` is provided in the options, only systems with `abap_catalog` connection type will be returned. | ||
| * | ||
| * @param options - backend service retrieval options | ||
| * @returns - list of backend systems | ||
| */ | ||
| getAll(options?: BackendServiceRetrievalOptions): Promise<BackendSystem[] | []>; | ||
@@ -33,0 +40,0 @@ } |
@@ -75,2 +75,9 @@ "use strict"; | ||
| } | ||
| /** | ||
| * Retrieves all backend systems from the store. Can be filtered by providing retrieval options. | ||
| * N.B. if no `connectionType` is provided in the options, only systems with `abap_catalog` connection type will be returned. | ||
| * | ||
| * @param options - backend service retrieval options | ||
| * @returns - list of backend systems | ||
| */ | ||
| async getAll(options) { | ||
@@ -77,0 +84,0 @@ return this.dataProvider.getAll(options); |
@@ -7,3 +7,3 @@ import type { BackendSystem } from '../entities/backend-system'; | ||
| export type BackendSystemFilter = Partial<{ | ||
| [K in BackendSerializableKeys]: BackendSystem[K]; | ||
| [K in BackendSerializableKeys]: BackendSystem[K] | BackendSystem[K][]; | ||
| }>; | ||
@@ -10,0 +10,0 @@ /** |
@@ -36,8 +36,8 @@ /** Pick the properties listed and return a new object with a shallow-copy */ | ||
| * @param obj - object to inspect | ||
| * @param attrs - object of property values to match | ||
| * @param filter - properties and values used for filtering the object. | ||
| * @returns - true if the `obj` has equivalent property values to `attrs` | ||
| */ | ||
| export declare function isMatch(obj: any, attrs: any): boolean; | ||
| export declare function isMatch(obj: any, filter: any): boolean; | ||
| export * from './app-studio'; | ||
| export * from './backend'; | ||
| //# sourceMappingURL=index.d.ts.map |
@@ -101,7 +101,10 @@ "use strict"; | ||
| * @param obj - object to inspect | ||
| * @param attrs - object of property values to match | ||
| * @param filter - properties and values used for filtering the object. | ||
| * @returns - true if the `obj` has equivalent property values to `attrs` | ||
| */ | ||
| function isMatch(obj, attrs) { | ||
| return Object.entries(attrs).every(([key, val]) => { | ||
| function isMatch(obj, filter) { | ||
| return Object.entries(filter).every(([key, val]) => { | ||
| if (Array.isArray(val)) { | ||
| return val.includes(obj[key]); | ||
| } | ||
| if (val && typeof val === 'object') { | ||
@@ -108,0 +111,0 @@ return isMatch(obj[key], val); |
+1
-1
| { | ||
| "name": "@sap-ux/store", | ||
| "version": "1.5.5", | ||
| "version": "1.5.6", | ||
| "description": "NPM module for storing persistent data", | ||
@@ -5,0 +5,0 @@ "repository": { |
+105
-1
@@ -90,2 +90,106 @@ [](https://github.com/SAP/open-ux-tools/blob/main/packages/store/CHANGELOG.md) [](https://github.com/SAP/open-ux-tools/tree/main/packages/store) | ||
| } | ||
| ``` | ||
| ``` | ||
| #### Special handling for BackendSystem getAll() | ||
| The `BackendSystem` service supports filtering and retrieval options when calling `getAll()`. This allows you to retrieve only the backend systems that match specific criteria. | ||
| ##### BackendServiceRetrievalOptions | ||
| The `getAll()` method accepts an optional `BackendServiceRetrievalOptions` parameter with the following properties: | ||
| - `includeSensitiveData?: boolean` - Whether to include sensitive data (username, password, etc.) in the returned systems | ||
| - `backendSystemFilter?: BackendSystemFilter` - Filter criteria to match specific backend systems | ||
| ##### BackendSystemFilter | ||
| The `BackendSystemFilter` allows filtering by any serializable property of a `BackendSystem`. The following properties can be used for filtering: | ||
| - `name` - System name | ||
| - `url` - System URL | ||
| - `client` - SAP client number | ||
| - `systemType` - Type of system (e.g., `SystemType.AbapOnPrem`, `SystemType.AbapCloud`, `SystemType.Generic`) | ||
| - `authenticationType` - Authentication method (e.g., `AuthenticationType.Basic`, `AuthenticationType.OAuth2RefreshToken`) | ||
| - `connectionType` - Connection type (e.g., `'abap_catalog'`, `'odata_service'`, `'generic_host'`) | ||
| - `systemInfo` - Nested object with `systemId` and `client` properties | ||
| ##### Filter Value Types | ||
| Each filter property supports three types of values: | ||
| 1. **Single value** - Match systems where the property equals the specified value | ||
| 2. **Array of values** - Match systems where the property equals any value in the array | ||
| 3. **Object value** (for `systemInfo`) - Match systems where nested properties match | ||
| ##### Usage Examples | ||
| **Filter by single value:** | ||
| ```typescript | ||
| import { getService } from '@sap-ux/store'; | ||
| import { SystemType } from '@sap-ux/store/types'; | ||
| const systemService = await getService('system'); | ||
| // Get only OnPrem systems | ||
| const onPremSystems = await systemService.getAll({ | ||
| backendSystemFilter: { systemType: SystemType.AbapOnPrem } | ||
| }); | ||
| ``` | ||
| **Filter by array of values:** | ||
| ```typescript | ||
| // Get systems with either 'abap_catalog' or 'odata_service' connection types | ||
| const catalogOrServiceSystems = await systemService.getAll({ | ||
| backendSystemFilter: { | ||
| connectionType: ['abap_catalog', 'odata_service'] | ||
| } | ||
| }); | ||
| ``` | ||
| **Filter by nested object (systemInfo):** | ||
| ```typescript | ||
| // Get systems matching specific systemId and client | ||
| const specificSystems = await systemService.getAll({ | ||
| backendSystemFilter: { | ||
| systemInfo: { systemId: 'ID123', client: '999' } | ||
| } | ||
| }); | ||
| ``` | ||
| **Combine multiple filters:** | ||
| ```typescript | ||
| // Get OnPrem systems with abap_catalog connection and specific client | ||
| const filteredSystems = await systemService.getAll({ | ||
| backendSystemFilter: { | ||
| systemType: SystemType.AbapOnPrem, | ||
| connectionType: 'abap_catalog', | ||
| client: '100' | ||
| } | ||
| }); | ||
| ``` | ||
| **Include sensitive data:** | ||
| ```typescript | ||
| // Get all systems with sensitive data included | ||
| const systemsWithCredentials = await systemService.getAll({ | ||
| includeSensitiveData: true, | ||
| backendSystemFilter: { systemType: SystemType.AbapCloud } | ||
| }); | ||
| ``` | ||
| ##### Default Behavior | ||
| **IMPORTANT:** If no `connectionType` filter is specified, the `getAll()` method automatically filters by `connectionType: 'abap_catalog'` for backwards compatibility. To retrieve systems with other connection types, you must explicitly specify the `connectionType` filter: | ||
| ```typescript | ||
| // Returns only 'abap_catalog' systems (default behavior) | ||
| const defaultSystems = await systemService.getAll(); | ||
| // Returns all systems regardless of connection type | ||
| const allSystems = await systemService.getAll({ | ||
| backendSystemFilter: { | ||
| connectionType: ['abap_catalog', 'odata_service', 'generic_host'] | ||
| } | ||
| }); | ||
| ``` | ||
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
118516
4.23%2352
0.77%195
116.67%