@unchainedshop/utils 4.8.25 → 4.8.27

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.
@@ -0,0 +1,4 @@
1
+ export declare function executeBulkOperation<T>(ids: readonly T[], operation: (id: T) => Promise<unknown>): Promise<{
2
+ successIds: T[];
3
+ failedIds: T[];
4
+ }>;
@@ -0,0 +1,19 @@
1
+ import { createLogger } from '@unchainedshop/logger';
2
+ const logger = createLogger('unchained:utils:bulk-operation');
3
+ export async function executeBulkOperation(ids, operation) {
4
+ const successIds = [];
5
+ const failedIds = [];
6
+ for (const id of new Set(ids)) {
7
+ try {
8
+ await operation(id);
9
+ successIds.push(id);
10
+ }
11
+ catch (error) {
12
+ failedIds.push(id);
13
+ logger.debug(`Bulk operation failed for entity ${String(id)}`, {
14
+ error: error instanceof Error ? error.message : String(error),
15
+ });
16
+ }
17
+ }
18
+ return { successIds, failedIds };
19
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unchainedshop/utils",
3
3
  "description": "Common utility functions and base classes for the Unchained Engine",
4
- "version": "4.8.25",
4
+ "version": "4.8.27",
5
5
  "main": "lib/utils-index.js",
6
6
  "types": "lib/utils-index.d.ts",
7
7
  "type": "module",
@@ -29,7 +29,7 @@
29
29
  },
30
30
  "homepage": "https://github.com/unchainedshop/unchained#readme",
31
31
  "dependencies": {
32
- "@unchainedshop/logger": "^4.8.12",
32
+ "@unchainedshop/logger": "^4.8.27",
33
33
  "libphonenumber-js": "^1.13.11",
34
34
  "resolve-accept-language": "^3.1.11"
35
35
  },