@unchainedshop/plugins 4.6.0 → 4.6.1

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.
@@ -3,17 +3,19 @@ const logger = createLogger('unchained:stripe');
3
3
  const { STRIPE_SECRET, STRIPE_WEBHOOK_ENVIRONMENT, EMAIL_WEBSITE_NAME } = process.env;
4
4
  export let stripe;
5
5
  const environment = STRIPE_WEBHOOK_ENVIRONMENT ?? null;
6
- try {
7
- if (!STRIPE_SECRET) {
8
- logger.warn('STRIPE_SECRET is not set, skipping initialization');
9
- }
10
- const { default: Stripe } = await import('stripe');
11
- stripe = new Stripe(STRIPE_SECRET, {
12
- apiVersion: '2025-12-15.clover',
13
- });
6
+ if (!STRIPE_SECRET) {
7
+ logger.warn('STRIPE_SECRET is not set, skipping initialization');
14
8
  }
15
- catch {
16
- logger.warn(`optional peer npm package 'stripe' not installed, stripe adapter will not work`);
9
+ else {
10
+ try {
11
+ const { default: Stripe } = await import('stripe');
12
+ stripe = new Stripe(STRIPE_SECRET, {
13
+ apiVersion: '2025-12-15.clover',
14
+ });
15
+ }
16
+ catch {
17
+ logger.warn(`optional peer npm package 'stripe' not installed, stripe adapter will not work`);
18
+ }
17
19
  }
18
20
  export const upsertCustomer = async ({ userId, name, email }) => {
19
21
  try {
@@ -20,5 +20,6 @@ import '../worker/http-request.ts';
20
20
  import '../worker/heartbeat.ts';
21
21
  import '../worker/email.ts';
22
22
  import '../worker/error-notifications.ts';
23
+ import '../worker/bulk-export.ts';
23
24
  import gridfsModules from '../files/gridfs/index.ts';
24
25
  export default gridfsModules;
@@ -20,5 +20,6 @@ import "../worker/http-request.js";
20
20
  import "../worker/heartbeat.js";
21
21
  import "../worker/email.js";
22
22
  import "../worker/error-notifications.js";
23
+ import "../worker/bulk-export.js";
23
24
  import gridfsModules from "../files/gridfs/index.js";
24
25
  export default gridfsModules;
@@ -0,0 +1,2 @@
1
+ import { type IWorkerAdapter } from '@unchainedshop/core';
2
+ export declare const BulkExportWorker: IWorkerAdapter<any, any>;
@@ -0,0 +1,64 @@
1
+ import { WorkerDirector, WorkerAdapter } from '@unchainedshop/core';
2
+ import { createLogger } from '@unchainedshop/logger';
3
+ const isSupportedLocale = (locale) => {
4
+ try {
5
+ const dtf = new Intl.DateTimeFormat(locale);
6
+ const resolved = dtf.resolvedOptions().locale;
7
+ return resolved.toLowerCase() === locale.toLowerCase();
8
+ }
9
+ catch (e) {
10
+ console.error(e);
11
+ return false;
12
+ }
13
+ };
14
+ const createLanguageDialectList = (languages, countries) => {
15
+ const result = new Set();
16
+ (languages || []).forEach(({ isoCode: baseIsoCode }) => {
17
+ result.add(baseIsoCode);
18
+ (countries || []).forEach(({ isoCode: countryIsoCode }) => {
19
+ const dialectIsoCode = [baseIsoCode, countryIsoCode.toUpperCase()].join('-');
20
+ if (isSupportedLocale(dialectIsoCode))
21
+ result.add(dialectIsoCode);
22
+ });
23
+ });
24
+ return Array.from(result);
25
+ };
26
+ const logger = createLogger('unchained:bulk-export');
27
+ export const BulkExportWorker = {
28
+ ...WorkerAdapter,
29
+ key: 'shop.unchained.worker-plugin.bulk-export',
30
+ label: 'Bulk Export',
31
+ version: '2.1.0',
32
+ type: 'BULK_EXPORT',
33
+ maxParallelAllocations: 1,
34
+ doWork: async (payload, unchainedAPI) => {
35
+ try {
36
+ const { modules } = unchainedAPI;
37
+ const languages = await modules.languages.findLanguages({ includeInactive: false });
38
+ const countries = await modules.countries.findCountries({ includeInactive: false });
39
+ const bulkExporter = unchainedAPI.bulkExporter.createBulkExporter({ entity: payload.type });
40
+ await bulkExporter.validate(payload);
41
+ const locales = createLanguageDialectList(languages, countries);
42
+ const [result, error] = await bulkExporter.execute(payload, locales, unchainedAPI);
43
+ if (error) {
44
+ return {
45
+ success: false,
46
+ result: result,
47
+ error,
48
+ };
49
+ }
50
+ return {
51
+ success: true,
52
+ result,
53
+ };
54
+ }
55
+ catch (err) {
56
+ logger.error(err);
57
+ return {
58
+ success: false,
59
+ error: { name: err.name, message: err.message, stack: err.stack },
60
+ };
61
+ }
62
+ },
63
+ };
64
+ WorkerDirector.registerAdapter(BulkExportWorker);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unchainedshop/plugins",
3
3
  "description": "Official plugin collection for the Unchained Engine with payment, delivery, and pricing adapters",
4
- "version": "4.6.0",
4
+ "version": "4.6.1",
5
5
  "main": "lib/plugins-index.js",
6
6
  "types": "lib/plugins-index.d.ts",
7
7
  "exports": {