@open-mercato/gateway-autopay 0.10.1-develop.8231.1.ae76b1d2c5 → 0.10.1-develop.8258.1.62a94b74a2

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.
@@ -1,3 +1,4 @@
1
+ import { parseModuleCliOptions } from "@open-mercato/shared/lib/cli/parseModuleCliOptions";
1
2
  import { createRequestContainer } from "@open-mercato/shared/lib/di/container";
2
3
  import { parseBooleanToken } from "@open-mercato/shared/lib/boolean";
3
4
  import { reportAutopayError } from "./lib/error-reporting.js";
@@ -8,25 +9,7 @@ function resolveForceFlag(rawForce) {
8
9
  return parseBooleanToken(rawForce) ?? void 0;
9
10
  }
10
11
  function parseArgs(args) {
11
- const result = {};
12
- for (let i = 0; i < args.length; i++) {
13
- const arg = args[i];
14
- if (!arg.startsWith("--")) continue;
15
- const key = arg.slice(2);
16
- if (key.includes("=")) {
17
- const [name, value] = key.split("=");
18
- result[name] = value;
19
- continue;
20
- }
21
- const next = args[i + 1];
22
- if (next && !next.startsWith("--")) {
23
- result[key] = next;
24
- i += 1;
25
- continue;
26
- }
27
- result[key] = true;
28
- }
29
- return result;
12
+ return parseModuleCliOptions(args);
30
13
  }
31
14
  function printHelp() {
32
15
  console.log("Usage: yarn mercato gateway_autopay configure-from-env --tenant <tenantId> --org <organizationId> [--force]");
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/modules/gateway_autopay/cli.ts"],
4
- "sourcesContent": ["import { createRequestContainer } from '@open-mercato/shared/lib/di/container'\nimport type { ModuleCli } from '@open-mercato/shared/modules/registry'\nimport type { CredentialsService } from '@open-mercato/core/modules/integrations/lib/credentials-service'\nimport type { IntegrationLogService } from '@open-mercato/core/modules/integrations/lib/log-service'\nimport type { IntegrationStateService } from '@open-mercato/core/modules/integrations/lib/state-service'\nimport { parseBooleanToken } from '@open-mercato/shared/lib/boolean'\nimport { reportAutopayError } from './lib/error-reporting'\nimport { applyAutopayEnvPreset, readAutopayEnvPreset } from './lib/preset'\n\n/**\n * `undefined` (flag never passed) must stay `undefined`, not coerce to\n * `false` \u2014 `applyAutopayEnvPreset` does `params.force ?? preset.force`, so a\n * coerced `false` here would silently override\n * `OM_INTEGRATION_AUTOPAY_FORCE_PRECONFIGURE=true` from the env preset every\n * time the CLI is run without an explicit `--force` flag.\n */\nexport function resolveForceFlag(rawForce: string | boolean | undefined): boolean | undefined {\n if (rawForce === undefined) return undefined\n if (typeof rawForce === 'boolean') return rawForce\n return parseBooleanToken(rawForce) ?? undefined\n}\n\nfunction parseArgs(args: string[]): Record<string, string | boolean> {\n const result: Record<string, string | boolean> = {}\n\n for (let i = 0; i < args.length; i++) {\n const arg = args[i]\n if (!arg.startsWith('--')) continue\n\n const key = arg.slice(2)\n if (key.includes('=')) {\n const [name, value] = key.split('=')\n result[name] = value\n continue\n }\n\n const next = args[i + 1]\n if (next && !next.startsWith('--')) {\n result[key] = next\n i += 1\n continue\n }\n\n result[key] = true\n }\n\n return result\n}\n\nfunction printHelp(): void {\n console.log('Usage: yarn mercato gateway_autopay configure-from-env --tenant <tenantId> --org <organizationId> [--force]')\n console.log('')\n console.log('Required env vars:')\n console.log(' OM_INTEGRATION_AUTOPAY_SERVICE_ID')\n console.log(' OM_INTEGRATION_AUTOPAY_SHARED_KEY')\n console.log(' OM_INTEGRATION_AUTOPAY_GATEWAY_URL')\n console.log('')\n console.log('Optional env vars:')\n console.log(' OM_INTEGRATION_AUTOPAY_HASH_ALGORITHM (sha256 default, or sha512)')\n console.log(' OM_INTEGRATION_AUTOPAY_ENABLED')\n console.log(' OM_INTEGRATION_AUTOPAY_FORCE_PRECONFIGURE')\n}\n\nconst configureFromEnvCommand: ModuleCli = {\n command: 'configure-from-env',\n async run(rest) {\n const args = parseArgs(rest)\n const tenantId = String(args.tenantId ?? args.tenant ?? '')\n const organizationId = String(args.organizationId ?? args.orgId ?? args.org ?? '')\n const force = resolveForceFlag(args.force)\n\n if (!tenantId || !organizationId) {\n printHelp()\n return\n }\n\n const preset = readAutopayEnvPreset()\n if (!preset) {\n console.error('[gateway_autopay] No Autopay env preset was found.')\n printHelp()\n process.exitCode = 1\n return\n }\n\n const container = await createRequestContainer()\n try {\n const credentialsService = container.resolve('integrationCredentialsService') as CredentialsService\n const integrationStateService = container.resolve('integrationStateService') as IntegrationStateService\n const integrationLogService = container.resolve('integrationLogService') as IntegrationLogService\n\n const result = await applyAutopayEnvPreset({\n credentialsService,\n integrationStateService,\n integrationLogService,\n scope: { tenantId, organizationId },\n force,\n })\n\n if (result.status === 'skipped') {\n console.log(`[gateway_autopay] Skipped: ${result.reason}`)\n return\n }\n\n console.log(`[gateway_autopay] Autopay credentials were configured from env. enabled=${String(result.enabled)}`)\n } catch (error) {\n const message = error instanceof Error ? error.message : 'Unknown Autopay preset error'\n console.error(`[gateway_autopay] ${message}`)\n reportAutopayError(error, 'gateway_autopay.cli_configure_failed')\n process.exitCode = 1\n } finally {\n const disposable = container as unknown as { dispose?: () => Promise<void> }\n if (typeof disposable.dispose === 'function') {\n await disposable.dispose()\n }\n }\n },\n}\n\nconst helpCommand: ModuleCli = {\n command: 'help',\n async run() {\n printHelp()\n },\n}\n\nexport default [configureFromEnvCommand, helpCommand]\n"],
5
- "mappings": "AAAA,SAAS,8BAA8B;AAKvC,SAAS,yBAAyB;AAClC,SAAS,0BAA0B;AACnC,SAAS,uBAAuB,4BAA4B;AASrD,SAAS,iBAAiB,UAA6D;AAC5F,MAAI,aAAa,OAAW,QAAO;AACnC,MAAI,OAAO,aAAa,UAAW,QAAO;AAC1C,SAAO,kBAAkB,QAAQ,KAAK;AACxC;AAEA,SAAS,UAAU,MAAkD;AACnE,QAAM,SAA2C,CAAC;AAElD,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,UAAM,MAAM,KAAK,CAAC;AAClB,QAAI,CAAC,IAAI,WAAW,IAAI,EAAG;AAE3B,UAAM,MAAM,IAAI,MAAM,CAAC;AACvB,QA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AAM,wBAAwB,UAAU,QAAQ,uBAAuB;AAEvE,YAAM,SAAS,MAAM,sBAAsB;AAAA,QACzC;AAAA,QACA;AAAA,QACA;AAAA,QACA,OAAO,EAAE,UAAU,eAAe;AAAA,QAClC;AAAA,MACF,CAAC;AAED,UAAI,OAAO,WAAW,WAAW;AAC/B,gBAAQ,IAAI,8BAA8B,OAAO,MAAM,EAAE;AACzD;AAAA,MACF;AAEA,cAAQ,IAAI,2EAA2E,OAAO,OAAO,OAAO,CAAC,EAAE;AAAA,IACjH,SAAS,OAAO;AACd,YAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU;AACzD,cAAQ,MAAM,qBAAqB,OAAO,EAAE;AAC5C,yBAAmB,OAAO,sCAAsC;AAChE,cAAQ,WAAW;AAAA,IACrB,UAAE;AACA,YAAM,aAAa;AACnB,UAAI,OAAO,WAAW,YAAY,YAAY;AAC5C,cAAM,WAAW,QAAQ;AAAA,MAC3B;AAAA,IACF;AAAA,EACF;AACF;AAEA,MAAM,cAAyB;AAAA,EAC7B,SAAS;AAAA,EACT,MAAM,MAAM;AACV,cAAU;AAAA,EACZ;AACF;AAEA,IAAO,cAAQ,CAAC,yBAAyB,WAAW;",
4
+ "sourcesContent": ["import { parseModuleCliOptions } from '@open-mercato/shared/lib/cli/parseModuleCliOptions'\nimport { createRequestContainer } from '@open-mercato/shared/lib/di/container'\nimport type { ModuleCli } from '@open-mercato/shared/modules/registry'\nimport type { CredentialsService } from '@open-mercato/core/modules/integrations/lib/credentials-service'\nimport type { IntegrationLogService } from '@open-mercato/core/modules/integrations/lib/log-service'\nimport type { IntegrationStateService } from '@open-mercato/core/modules/integrations/lib/state-service'\nimport { parseBooleanToken } from '@open-mercato/shared/lib/boolean'\nimport { reportAutopayError } from './lib/error-reporting'\nimport { applyAutopayEnvPreset, readAutopayEnvPreset } from './lib/preset'\n\n/**\n * `undefined` (flag never passed) must stay `undefined`, not coerce to\n * `false` \u2014 `applyAutopayEnvPreset` does `params.force ?? preset.force`, so a\n * coerced `false` here would silently override\n * `OM_INTEGRATION_AUTOPAY_FORCE_PRECONFIGURE=true` from the env preset every\n * time the CLI is run without an explicit `--force` flag.\n */\nexport function resolveForceFlag(rawForce: string | boolean | undefined): boolean | undefined {\n if (rawForce === undefined) return undefined\n if (typeof rawForce === 'boolean') return rawForce\n return parseBooleanToken(rawForce) ?? undefined\n}\n\nfunction parseArgs(args: string[]): Record<string, string | boolean> {\n return parseModuleCliOptions(args)\n}\n\nfunction printHelp(): void {\n console.log('Usage: yarn mercato gateway_autopay configure-from-env --tenant <tenantId> --org <organizationId> [--force]')\n console.log('')\n console.log('Required env vars:')\n console.log(' OM_INTEGRATION_AUTOPAY_SERVICE_ID')\n console.log(' OM_INTEGRATION_AUTOPAY_SHARED_KEY')\n console.log(' OM_INTEGRATION_AUTOPAY_GATEWAY_URL')\n console.log('')\n console.log('Optional env vars:')\n console.log(' OM_INTEGRATION_AUTOPAY_HASH_ALGORITHM (sha256 default, or sha512)')\n console.log(' OM_INTEGRATION_AUTOPAY_ENABLED')\n console.log(' OM_INTEGRATION_AUTOPAY_FORCE_PRECONFIGURE')\n}\n\nconst configureFromEnvCommand: ModuleCli = {\n command: 'configure-from-env',\n async run(rest) {\n const args = parseArgs(rest)\n const tenantId = String(args.tenantId ?? args.tenant ?? '')\n const organizationId = String(args.organizationId ?? args.orgId ?? args.org ?? '')\n const force = resolveForceFlag(args.force)\n\n if (!tenantId || !organizationId) {\n printHelp()\n return\n }\n\n const preset = readAutopayEnvPreset()\n if (!preset) {\n console.error('[gateway_autopay] No Autopay env preset was found.')\n printHelp()\n process.exitCode = 1\n return\n }\n\n const container = await createRequestContainer()\n try {\n const credentialsService = container.resolve('integrationCredentialsService') as CredentialsService\n const integrationStateService = container.resolve('integrationStateService') as IntegrationStateService\n const integrationLogService = container.resolve('integrationLogService') as IntegrationLogService\n\n const result = await applyAutopayEnvPreset({\n credentialsService,\n integrationStateService,\n integrationLogService,\n scope: { tenantId, organizationId },\n force,\n })\n\n if (result.status === 'skipped') {\n console.log(`[gateway_autopay] Skipped: ${result.reason}`)\n return\n }\n\n console.log(`[gateway_autopay] Autopay credentials were configured from env. enabled=${String(result.enabled)}`)\n } catch (error) {\n const message = error instanceof Error ? error.message : 'Unknown Autopay preset error'\n console.error(`[gateway_autopay] ${message}`)\n reportAutopayError(error, 'gateway_autopay.cli_configure_failed')\n process.exitCode = 1\n } finally {\n const disposable = container as unknown as { dispose?: () => Promise<void> }\n if (typeof disposable.dispose === 'function') {\n await disposable.dispose()\n }\n }\n },\n}\n\nconst helpCommand: ModuleCli = {\n command: 'help',\n async run() {\n printHelp()\n },\n}\n\nexport default [configureFromEnvCommand, helpCommand]\n"],
5
+ "mappings": "AAAA,SAAS,6BAA6B;AACtC,SAAS,8BAA8B;AAKvC,SAAS,yBAAyB;AAClC,SAAS,0BAA0B;AACnC,SAAS,uBAAuB,4BAA4B;AASrD,SAAS,iBAAiB,UAA6D;AAC5F,MAAI,aAAa,OAAW,QAAO;AACnC,MAAI,OAAO,aAAa,UAAW,QAAO;AAC1C,SAAO,kBAAkB,QAAQ,KAAK;AACxC;AAEA,SAAS,UAAU,MAAkD;AACnE,SAAO,sBAAsB,IAAI;AACnC;AAEA,SAAS,YAAkB;AACzB,UAAQ,IAAI,6GAA6G;AACzH,UAAQ,IAAI,EAAE;AACd,UAAQ,IAAI,oBAAoB;AAChC,UAAQ,IAAI,qCAAqC;AACjD,UAAQ,IAAI,qCAAqC;AACjD,UAAQ,IAAI,sCAAsC;AAClD,UAAQ,IAAI,EAAE;AACd,UAAQ,IAAI,oBAAoB;AAChC,UAAQ,IAAI,qEAAqE;AACjF,UAAQ,IAAI,kCAAkC;AAC9C,UAAQ,IAAI,6CAA6C;AAC3D;AAEA,MAAM,0BAAqC;AAAA,EACzC,SAAS;AAAA,EACT,MAAM,IAAI,MAAM;AACd,UAAM,OAAO,UAAU,IAAI;AAC3B,UAAM,WAAW,OAAO,KAAK,YAAY,KAAK,UAAU,EAAE;AAC1D,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@
1
1
  {
2
2
  "name": "@open-mercato/gateway-autopay",
3
- "version": "0.10.1-develop.8231.1.ae76b1d2c5",
3
+ "version": "0.10.1-develop.8258.1.62a94b74a2",
4
4
  "license": "MIT",
5
5
  "description": "Autopay Online v1.1 hosted PLN payment gateway provider for Open Mercato",
6
6
  "type": "module",
@@ -63,19 +63,19 @@
63
63
  }
64
64
  },
65
65
  "dependencies": {
66
- "@open-mercato/core": "0.10.1-develop.8231.1.ae76b1d2c5"
66
+ "@open-mercato/core": "0.10.1-develop.8258.1.62a94b74a2"
67
67
  },
68
68
  "peerDependencies": {
69
69
  "@mikro-orm/postgresql": "^7.0.14",
70
- "@open-mercato/ai-assistant": "0.10.1-develop.8231.1.ae76b1d2c5",
71
- "@open-mercato/shared": "0.10.1-develop.8231.1.ae76b1d2c5",
72
- "@open-mercato/ui": "0.10.1-develop.8231.1.ae76b1d2c5",
70
+ "@open-mercato/ai-assistant": "0.10.1-develop.8258.1.62a94b74a2",
71
+ "@open-mercato/shared": "0.10.1-develop.8258.1.62a94b74a2",
72
+ "@open-mercato/ui": "0.10.1-develop.8258.1.62a94b74a2",
73
73
  "react": "^19.0.0",
74
74
  "react-dom": "^19.0.0"
75
75
  },
76
76
  "devDependencies": {
77
- "@open-mercato/ai-assistant": "0.10.1-develop.8231.1.ae76b1d2c5",
78
- "@open-mercato/shared": "0.10.1-develop.8231.1.ae76b1d2c5",
77
+ "@open-mercato/ai-assistant": "0.10.1-develop.8258.1.62a94b74a2",
78
+ "@open-mercato/shared": "0.10.1-develop.8258.1.62a94b74a2",
79
79
  "@types/jest": "^30.0.0",
80
80
  "esbuild": "^0.28.1",
81
81
  "glob": "^14.0.6",
@@ -1,3 +1,4 @@
1
+ import { parseModuleCliOptions } from '@open-mercato/shared/lib/cli/parseModuleCliOptions'
1
2
  import { createRequestContainer } from '@open-mercato/shared/lib/di/container'
2
3
  import type { ModuleCli } from '@open-mercato/shared/modules/registry'
3
4
  import type { CredentialsService } from '@open-mercato/core/modules/integrations/lib/credentials-service'
@@ -21,30 +22,7 @@ export function resolveForceFlag(rawForce: string | boolean | undefined): boolea
21
22
  }
22
23
 
23
24
  function parseArgs(args: string[]): Record<string, string | boolean> {
24
- const result: Record<string, string | boolean> = {}
25
-
26
- for (let i = 0; i < args.length; i++) {
27
- const arg = args[i]
28
- if (!arg.startsWith('--')) continue
29
-
30
- const key = arg.slice(2)
31
- if (key.includes('=')) {
32
- const [name, value] = key.split('=')
33
- result[name] = value
34
- continue
35
- }
36
-
37
- const next = args[i + 1]
38
- if (next && !next.startsWith('--')) {
39
- result[key] = next
40
- i += 1
41
- continue
42
- }
43
-
44
- result[key] = true
45
- }
46
-
47
- return result
25
+ return parseModuleCliOptions(args)
48
26
  }
49
27
 
50
28
  function printHelp(): void {