@open-mercato/storage-s3 0.6.6-develop.6460.1.f94c74174c → 0.6.6-develop.6471.1.9ab5bdd79a

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.
@@ -6,8 +6,10 @@ import {
6
6
  import { S3StorageDriver } from "./lib/s3-driver.js";
7
7
  import { createStorageService } from "./lib/storage-service.js";
8
8
  import { s3HealthCheck } from "./lib/health.js";
9
+ import { createLogger } from "@open-mercato/shared/lib/logger";
10
+ const logger = createLogger("storage_s3");
9
11
  registerExternalStorageDriver("s3", (config) => {
10
- console.log("[storage-s3] Creating S3StorageDriver with config:", {
12
+ logger.debug("Creating S3StorageDriver", {
11
13
  bucket: config.bucket,
12
14
  region: config.region,
13
15
  endpoint: config.endpoint,
@@ -24,10 +26,10 @@ function register(container) {
24
26
  const credsSvc = container.resolve("integrationCredentialsService");
25
27
  const creds = await credsSvc.resolve("storage_s3", scope);
26
28
  if (!creds) {
27
- console.log("[storage-s3] No marketplace credentials found for scope", scope);
29
+ logger.debug("No marketplace credentials found for scope", { tenantId: scope.tenantId, organizationId: scope.organizationId });
28
30
  return config;
29
31
  }
30
- console.log("[storage-s3] Injecting marketplace credentials into S3 driver config");
32
+ logger.debug("Injecting marketplace credentials into S3 driver config");
31
33
  return {
32
34
  authMode: creds.authMode,
33
35
  bucket: config.bucket ?? (creds.bucket ? String(creds.bucket) : void 0),
@@ -39,7 +41,7 @@ function register(container) {
39
41
  sessionToken: creds.sessionToken ? String(creds.sessionToken) : void 0
40
42
  };
41
43
  } catch (err) {
42
- console.warn("[storage-s3] Credential enhancer failed, using partition config as-is:", err);
44
+ logger.warn("Credential enhancer failed, using partition config as-is", { err });
43
45
  return config;
44
46
  }
45
47
  });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/modules/storage_s3/di.ts"],
4
- "sourcesContent": ["import { asFunction, asValue } from 'awilix'\nimport type { AppContainer } from '@open-mercato/shared/lib/di/container'\nimport {\n registerExternalStorageDriver,\n registerExternalCredentialEnhancer,\n} from '@open-mercato/core/modules/attachments/lib/drivers'\nimport { S3StorageDriver } from './lib/s3-driver'\nimport { createStorageService } from './lib/storage-service'\nimport { s3HealthCheck } from './lib/health'\n\ntype IntegrationCredentialsService = {\n resolve(integrationId: string, scope: { tenantId: string; organizationId: string }): Promise<Record<string, unknown> | null>\n}\n\n// Module-level registration \u2014 runs at import time, before any DI container is built.\n// This avoids the singleton-proxy resolution issue when registering via DI.\nregisterExternalStorageDriver('s3', (config: Record<string, unknown>) => {\n console.log('[storage-s3] Creating S3StorageDriver with config:', {\n bucket: config.bucket,\n region: config.region,\n endpoint: config.endpoint,\n forcePathStyle: config.forcePathStyle,\n hasAccessKey: Boolean(config.accessKeyId),\n hasCredentialsEnvPrefix: Boolean(config.credentialsEnvPrefix),\n })\n return new S3StorageDriver(config)\n})\n\nexport function register(container: AppContainer) {\n // Register the credential enhancer via DI so it can access the request-scoped\n // integrationCredentialsService to inject marketplace credentials at upload time.\n registerExternalCredentialEnhancer('s3', async (config, scope) => {\n if (config.credentialsEnvPrefix || config.accessKeyId || config.authMode) return config\n try {\n const credsSvc = container.resolve('integrationCredentialsService') as IntegrationCredentialsService\n const creds = await credsSvc.resolve('storage_s3', scope)\n if (!creds) {\n console.log('[storage-s3] No marketplace credentials found for scope', scope)\n return config\n }\n console.log('[storage-s3] Injecting marketplace credentials into S3 driver config')\n return {\n authMode: creds.authMode,\n bucket: config.bucket ?? (creds.bucket ? String(creds.bucket) : undefined),\n region: config.region ?? (creds.region ? String(creds.region) : undefined),\n endpoint: config.endpoint ?? (creds.endpoint ? String(creds.endpoint) : undefined),\n forcePathStyle: config.forcePathStyle ?? Boolean(creds.forcePathStyle),\n accessKeyId: creds.accessKeyId ? String(creds.accessKeyId) : undefined,\n secretAccessKey: creds.secretAccessKey ? String(creds.secretAccessKey) : undefined,\n sessionToken: creds.sessionToken ? String(creds.sessionToken) : undefined,\n }\n } catch (err) {\n console.warn('[storage-s3] Credential enhancer failed, using partition config as-is:', err)\n return config\n }\n })\n\n container.register({\n s3HealthCheck: asValue(s3HealthCheck),\n storageService: asFunction(\n ({ integrationCredentialsService }: { integrationCredentialsService: IntegrationCredentialsService }) => {\n // StorageService factory \u2014 builds the service lazily using credentials\n // resolved from the Integration Marketplace per request.\n return {\n async _resolveService(scope: { tenantId: string; organizationId: string }) {\n const creds = await integrationCredentialsService.resolve('storage_s3', scope)\n if (!creds) throw new Error('S3 storage integration is not configured for this tenant.')\n return createStorageService({\n authMode: creds.authMode === 'ambient' || creds.authMode === 'access_keys'\n ? (creds.authMode as 'ambient' | 'access_keys')\n : undefined,\n bucket: String(creds.bucket ?? ''),\n region: creds.region ? String(creds.region) : undefined,\n endpoint: creds.endpoint ? String(creds.endpoint) : undefined,\n forcePathStyle: Boolean(creds.forcePathStyle),\n accessKeyId: creds.accessKeyId ? String(creds.accessKeyId) : undefined,\n secretAccessKey: creds.secretAccessKey ? String(creds.secretAccessKey) : undefined,\n sessionToken: creds.sessionToken ? String(creds.sessionToken) : undefined,\n // Credentials are resolved from the Integration Marketplace (encrypted at rest)\n // and injected directly rather than via env prefix for the standalone service.\n } as Parameters<typeof createStorageService>[0])\n },\n }\n },\n )\n .scoped()\n .proxy(),\n })\n}\n"],
5
- "mappings": "AAAA,SAAS,YAAY,eAAe;AAEpC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,uBAAuB;AAChC,SAAS,4BAA4B;AACrC,SAAS,qBAAqB;AAQ9B,8BAA8B,MAAM,CAAC,WAAoC;AACvE,UAAQ,IAAI,sDAAsD;AAAA,IAChE,QAAQ,OAAO;AAAA,IACf,QAAQ,OAAO;AAAA,IACf,UAAU,OAAO;AAAA,IACjB,gBAAgB,OAAO;AAAA,IACvB,cAAc,QAAQ,OAAO,WAAW;AAAA,IACxC,yBAAyB,QAAQ,OAAO,oBAAoB;AAAA,EAC9D,CAAC;AACD,SAAO,IAAI,gBAAgB,MAAM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,MAAM,aAAa,gBACxD,MAAM,WACP;AAAA,cACJ,QAAQ,OAAO,MAAM,UAAU,EAAE;AAAA,cACjC,QAAQ,MAAM,SAAS,OAAO,MAAM,MAAM,IAAI;AAAA,cAC9C,UAAU,MAAM,WAAW,OAAO,MAAM,QAAQ,IAAI;AAAA,cACpD,gBAAgB,QAAQ,MAAM,cAAc;AAAA,cAC5C,aAAa,MAAM,cAAc,OAAO,MAAM,WAAW,IAAI;AAAA,cAC7D,iBAAiB,MAAM,kBAAkB,OAAO,MAAM,eAAe,IAAI;AAAA,cACzE,cAAc,MAAM,eAAe,OAAO,MAAM,YAAY,IAAI;AAAA;AAAA;AAAA,YAGlE,CAA+C;AAAA,UACjD;AAAA,QACF;AAAA,MACF;AAAA,IACF,EACG,OAAO,EACP,MAAM;AAAA,EACX,CAAC;AACH;",
4
+ "sourcesContent": ["import { asFunction, asValue } from 'awilix'\nimport type { AppContainer } from '@open-mercato/shared/lib/di/container'\nimport {\n registerExternalStorageDriver,\n registerExternalCredentialEnhancer,\n} from '@open-mercato/core/modules/attachments/lib/drivers'\nimport { S3StorageDriver } from './lib/s3-driver'\nimport { createStorageService } from './lib/storage-service'\nimport { s3HealthCheck } from './lib/health'\nimport { createLogger } from '@open-mercato/shared/lib/logger'\n\nconst logger = createLogger('storage_s3')\n\ntype IntegrationCredentialsService = {\n resolve(integrationId: string, scope: { tenantId: string; organizationId: string }): Promise<Record<string, unknown> | null>\n}\n\n// Module-level registration \u2014 runs at import time, before any DI container is built.\n// This avoids the singleton-proxy resolution issue when registering via DI.\nregisterExternalStorageDriver('s3', (config: Record<string, unknown>) => {\n logger.debug('Creating S3StorageDriver', {\n bucket: config.bucket,\n region: config.region,\n endpoint: config.endpoint,\n forcePathStyle: config.forcePathStyle,\n hasAccessKey: Boolean(config.accessKeyId),\n hasCredentialsEnvPrefix: Boolean(config.credentialsEnvPrefix),\n })\n return new S3StorageDriver(config)\n})\n\nexport function register(container: AppContainer) {\n // Register the credential enhancer via DI so it can access the request-scoped\n // integrationCredentialsService to inject marketplace credentials at upload time.\n registerExternalCredentialEnhancer('s3', async (config, scope) => {\n if (config.credentialsEnvPrefix || config.accessKeyId || config.authMode) return config\n try {\n const credsSvc = container.resolve('integrationCredentialsService') as IntegrationCredentialsService\n const creds = await credsSvc.resolve('storage_s3', scope)\n if (!creds) {\n logger.debug('No marketplace credentials found for scope', { tenantId: scope.tenantId, organizationId: scope.organizationId })\n return config\n }\n logger.debug('Injecting marketplace credentials into S3 driver config')\n return {\n authMode: creds.authMode,\n bucket: config.bucket ?? (creds.bucket ? String(creds.bucket) : undefined),\n region: config.region ?? (creds.region ? String(creds.region) : undefined),\n endpoint: config.endpoint ?? (creds.endpoint ? String(creds.endpoint) : undefined),\n forcePathStyle: config.forcePathStyle ?? Boolean(creds.forcePathStyle),\n accessKeyId: creds.accessKeyId ? String(creds.accessKeyId) : undefined,\n secretAccessKey: creds.secretAccessKey ? String(creds.secretAccessKey) : undefined,\n sessionToken: creds.sessionToken ? String(creds.sessionToken) : undefined,\n }\n } catch (err) {\n logger.warn('Credential enhancer failed, using partition config as-is', { err })\n return config\n }\n })\n\n container.register({\n s3HealthCheck: asValue(s3HealthCheck),\n storageService: asFunction(\n ({ integrationCredentialsService }: { integrationCredentialsService: IntegrationCredentialsService }) => {\n // StorageService factory \u2014 builds the service lazily using credentials\n // resolved from the Integration Marketplace per request.\n return {\n async _resolveService(scope: { tenantId: string; organizationId: string }) {\n const creds = await integrationCredentialsService.resolve('storage_s3', scope)\n if (!creds) throw new Error('S3 storage integration is not configured for this tenant.')\n return createStorageService({\n authMode: creds.authMode === 'ambient' || creds.authMode === 'access_keys'\n ? (creds.authMode as 'ambient' | 'access_keys')\n : undefined,\n bucket: String(creds.bucket ?? ''),\n region: creds.region ? String(creds.region) : undefined,\n endpoint: creds.endpoint ? String(creds.endpoint) : undefined,\n forcePathStyle: Boolean(creds.forcePathStyle),\n accessKeyId: creds.accessKeyId ? String(creds.accessKeyId) : undefined,\n secretAccessKey: creds.secretAccessKey ? String(creds.secretAccessKey) : undefined,\n sessionToken: creds.sessionToken ? String(creds.sessionToken) : undefined,\n // Credentials are resolved from the Integration Marketplace (encrypted at rest)\n // and injected directly rather than via env prefix for the standalone service.\n } as Parameters<typeof createStorageService>[0])\n },\n }\n },\n )\n .scoped()\n .proxy(),\n })\n}\n"],
5
+ "mappings": "AAAA,SAAS,YAAY,eAAe;AAEpC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,uBAAuB;AAChC,SAAS,4BAA4B;AACrC,SAAS,qBAAqB;AAC9B,SAAS,oBAAoB;AAE7B,MAAM,SAAS,aAAa,YAAY;AAQxC,8BAA8B,MAAM,CAAC,WAAoC;AACvE,SAAO,MAAM,4BAA4B;AAAA,IACvC,QAAQ,OAAO;AAAA,IACf,QAAQ,OAAO;AAAA,IACf,UAAU,OAAO;AAAA,IACjB,gBAAgB,OAAO;AAAA,IACvB,cAAc,QAAQ,OAAO,WAAW;AAAA,IACxC,yBAAyB,QAAQ,OAAO,oBAAoB;AAAA,EAC9D,CAAC;AACD,SAAO,IAAI,gBAAgB,MAAM;AACnC,CAAC;AAEM,SAAS,SAAS,WAAyB;AAGhD,qCAAmC,MAAM,OAAO,QAAQ,UAAU;AAChE,QAAI,OAAO,wBAAwB,OAAO,eAAe,OAAO,SAAU,QAAO;AACjF,QAAI;AACF,YAAM,WAAW,UAAU,QAAQ,+BAA+B;AAClE,YAAM,QAAQ,MAAM,SAAS,QAAQ,cAAc,KAAK;AACxD,UAAI,CAAC,OAAO;AACV,eAAO,MAAM,8CAA8C,EAAE,UAAU,MAAM,UAAU,gBAAgB,MAAM,eAAe,CAAC;AAC7H,eAAO;AAAA,MACT;AACA,aAAO,MAAM,yDAAyD;AACtE,aAAO;AAAA,QACL,UAAU,MAAM;AAAA,QAChB,QAAQ,OAAO,WAAW,MAAM,SAAS,OAAO,MAAM,MAAM,IAAI;AAAA,QAChE,QAAQ,OAAO,WAAW,MAAM,SAAS,OAAO,M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,MAAM;AAAA,EACX,CAAC;AACH;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,8 @@
1
1
  import { createCredentialsService } from "@open-mercato/core/modules/integrations/lib/credentials-service";
2
2
  import { createIntegrationLogService } from "@open-mercato/core/modules/integrations/lib/log-service";
3
3
  import { applyS3EnvPreset } from "./lib/preset.js";
4
+ import { createLogger } from "@open-mercato/shared/lib/logger";
5
+ const logger = createLogger("storage_s3");
4
6
  const S3_INTEGRATION_ID = "storage_s3";
5
7
  const setup = {
6
8
  defaultRoleFeatures: {
@@ -21,9 +23,10 @@ const setup = {
21
23
  await integrationLogService.scoped(S3_INTEGRATION_ID, { tenantId, organizationId }).error(`Failed to apply S3 env preset during tenant setup: ${message}`);
22
24
  } catch (logError) {
23
25
  const logMessage = logError instanceof Error ? logError.message : "Unknown integration log error";
24
- console.error(
25
- `[storage_s3] Failed to apply env preset during tenant setup: ${message}. Also failed to persist the error to integration logs: ${logMessage}`
26
- );
26
+ logger.error("Failed to apply env preset during tenant setup; persisting to integration logs also failed", {
27
+ presetError: message,
28
+ logError: logMessage
29
+ });
27
30
  }
28
31
  }
29
32
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/modules/storage_s3/setup.ts"],
4
- "sourcesContent": ["import type { ModuleSetupConfig } from '@open-mercato/shared/modules/setup'\nimport { createCredentialsService } from '@open-mercato/core/modules/integrations/lib/credentials-service'\nimport { createIntegrationLogService } from '@open-mercato/core/modules/integrations/lib/log-service'\nimport { applyS3EnvPreset } from './lib/preset'\n\nconst S3_INTEGRATION_ID = 'storage_s3'\n\nexport const setup: ModuleSetupConfig = {\n defaultRoleFeatures: {\n superadmin: ['storage_providers.manage'],\n admin: ['storage_providers.manage'],\n },\n\n async onTenantCreated({ em, organizationId, tenantId }) {\n const integrationLogService = createIntegrationLogService(em)\n try {\n await applyS3EnvPreset({\n credentialsService: createCredentialsService(em),\n integrationLogService,\n scope: { tenantId, organizationId },\n })\n } catch (error) {\n const message = error instanceof Error ? error.message : 'Unknown S3 preset error'\n try {\n await integrationLogService\n .scoped(S3_INTEGRATION_ID, { tenantId, organizationId })\n .error(`Failed to apply S3 env preset during tenant setup: ${message}`)\n } catch (logError) {\n const logMessage = logError instanceof Error ? logError.message : 'Unknown integration log error'\n console.error(\n `[storage_s3] Failed to apply env preset during tenant setup: ${message}. ` +\n `Also failed to persist the error to integration logs: ${logMessage}`,\n )\n }\n }\n },\n}\n\nexport default setup\n"],
5
- "mappings": "AACA,SAAS,gCAAgC;AACzC,SAAS,mCAAmC;AAC5C,SAAS,wBAAwB;AAEjC,MAAM,oBAAoB;AAEnB,MAAM,QAA2B;AAAA,EACtC,qBAAqB;AAAA,IACnB,YAAY,CAAC,0BAA0B;AAAA,IACvC,OAAO,CAAC,0BAA0B;AAAA,EACpC;AAAA,EAEA,MAAM,gBAAgB,EAAE,IAAI,gBAAgB,SAAS,GAAG;AACtD,UAAM,wBAAwB,4BAA4B,EAAE;AAC5D,QAAI;AACF,YAAM,iBAAiB;AAAA,QACrB,oBAAoB,yBAAyB,EAAE;AAAA,QAC/C;AAAA,QACA,OAAO,EAAE,UAAU,eAAe;AAAA,MACpC,CAAC;AAAA,IACH,SAAS,OAAO;AACd,YAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU;AACzD,UAAI;AACF,cAAM,sBACH,OAAO,mBAAmB,EAAE,UAAU,eAAe,CAAC,EACtD,MAAM,sDAAsD,OAAO,EAAE;AAAA,MAC1E,SAAS,UAAU;AACjB,cAAM,aAAa,oBAAoB,QAAQ,SAAS,UAAU;AAClE,gBAAQ;AAAA,UACN,gEAAgE,OAAO,2DACZ,UAAU;AAAA,QACvE;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEA,IAAO,gBAAQ;",
4
+ "sourcesContent": ["import type { ModuleSetupConfig } from '@open-mercato/shared/modules/setup'\nimport { createCredentialsService } from '@open-mercato/core/modules/integrations/lib/credentials-service'\nimport { createIntegrationLogService } from '@open-mercato/core/modules/integrations/lib/log-service'\nimport { applyS3EnvPreset } from './lib/preset'\nimport { createLogger } from '@open-mercato/shared/lib/logger'\n\nconst logger = createLogger('storage_s3')\n\nconst S3_INTEGRATION_ID = 'storage_s3'\n\nexport const setup: ModuleSetupConfig = {\n defaultRoleFeatures: {\n superadmin: ['storage_providers.manage'],\n admin: ['storage_providers.manage'],\n },\n\n async onTenantCreated({ em, organizationId, tenantId }) {\n const integrationLogService = createIntegrationLogService(em)\n try {\n await applyS3EnvPreset({\n credentialsService: createCredentialsService(em),\n integrationLogService,\n scope: { tenantId, organizationId },\n })\n } catch (error) {\n const message = error instanceof Error ? error.message : 'Unknown S3 preset error'\n try {\n await integrationLogService\n .scoped(S3_INTEGRATION_ID, { tenantId, organizationId })\n .error(`Failed to apply S3 env preset during tenant setup: ${message}`)\n } catch (logError) {\n const logMessage = logError instanceof Error ? logError.message : 'Unknown integration log error'\n logger.error('Failed to apply env preset during tenant setup; persisting to integration logs also failed', {\n presetError: message,\n logError: logMessage,\n })\n }\n }\n },\n}\n\nexport default setup\n"],
5
+ "mappings": "AACA,SAAS,gCAAgC;AACzC,SAAS,mCAAmC;AAC5C,SAAS,wBAAwB;AACjC,SAAS,oBAAoB;AAE7B,MAAM,SAAS,aAAa,YAAY;AAExC,MAAM,oBAAoB;AAEnB,MAAM,QAA2B;AAAA,EACtC,qBAAqB;AAAA,IACnB,YAAY,CAAC,0BAA0B;AAAA,IACvC,OAAO,CAAC,0BAA0B;AAAA,EACpC;AAAA,EAEA,MAAM,gBAAgB,EAAE,IAAI,gBAAgB,SAAS,GAAG;AACtD,UAAM,wBAAwB,4BAA4B,EAAE;AAC5D,QAAI;AACF,YAAM,iBAAiB;AAAA,QACrB,oBAAoB,yBAAyB,EAAE;AAAA,QAC/C;AAAA,QACA,OAAO,EAAE,UAAU,eAAe;AAAA,MACpC,CAAC;AAAA,IACH,SAAS,OAAO;AACd,YAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU;AACzD,UAAI;AACF,cAAM,sBACH,OAAO,mBAAmB,EAAE,UAAU,eAAe,CAAC,EACtD,MAAM,sDAAsD,OAAO,EAAE;AAAA,MAC1E,SAAS,UAAU;AACjB,cAAM,aAAa,oBAAoB,QAAQ,SAAS,UAAU;AAClE,eAAO,MAAM,8FAA8F;AAAA,UACzG,aAAa;AAAA,UACb,UAAU;AAAA,QACZ,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF;AAEA,IAAO,gBAAQ;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-mercato/storage-s3",
3
- "version": "0.6.6-develop.6460.1.f94c74174c",
3
+ "version": "0.6.6-develop.6471.1.9ab5bdd79a",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -69,14 +69,14 @@
69
69
  "dependencies": {
70
70
  "@aws-sdk/client-s3": "^3.1075.0",
71
71
  "@aws-sdk/s3-request-presigner": "^3.1075.0",
72
- "@open-mercato/core": "0.6.6-develop.6460.1.f94c74174c"
72
+ "@open-mercato/core": "0.6.6-develop.6471.1.9ab5bdd79a"
73
73
  },
74
74
  "peerDependencies": {
75
75
  "@mikro-orm/postgresql": "^6.6.10",
76
- "@open-mercato/shared": "0.6.6-develop.6460.1.f94c74174c"
76
+ "@open-mercato/shared": "0.6.6-develop.6471.1.9ab5bdd79a"
77
77
  },
78
78
  "devDependencies": {
79
- "@open-mercato/shared": "0.6.6-develop.6460.1.f94c74174c",
79
+ "@open-mercato/shared": "0.6.6-develop.6471.1.9ab5bdd79a",
80
80
  "@types/jest": "^30.0.0",
81
81
  "esbuild": "^0.28.1",
82
82
  "glob": "^13.0.6",
@@ -7,6 +7,9 @@ import {
7
7
  import { S3StorageDriver } from './lib/s3-driver'
8
8
  import { createStorageService } from './lib/storage-service'
9
9
  import { s3HealthCheck } from './lib/health'
10
+ import { createLogger } from '@open-mercato/shared/lib/logger'
11
+
12
+ const logger = createLogger('storage_s3')
10
13
 
11
14
  type IntegrationCredentialsService = {
12
15
  resolve(integrationId: string, scope: { tenantId: string; organizationId: string }): Promise<Record<string, unknown> | null>
@@ -15,7 +18,7 @@ type IntegrationCredentialsService = {
15
18
  // Module-level registration — runs at import time, before any DI container is built.
16
19
  // This avoids the singleton-proxy resolution issue when registering via DI.
17
20
  registerExternalStorageDriver('s3', (config: Record<string, unknown>) => {
18
- console.log('[storage-s3] Creating S3StorageDriver with config:', {
21
+ logger.debug('Creating S3StorageDriver', {
19
22
  bucket: config.bucket,
20
23
  region: config.region,
21
24
  endpoint: config.endpoint,
@@ -35,10 +38,10 @@ export function register(container: AppContainer) {
35
38
  const credsSvc = container.resolve('integrationCredentialsService') as IntegrationCredentialsService
36
39
  const creds = await credsSvc.resolve('storage_s3', scope)
37
40
  if (!creds) {
38
- console.log('[storage-s3] No marketplace credentials found for scope', scope)
41
+ logger.debug('No marketplace credentials found for scope', { tenantId: scope.tenantId, organizationId: scope.organizationId })
39
42
  return config
40
43
  }
41
- console.log('[storage-s3] Injecting marketplace credentials into S3 driver config')
44
+ logger.debug('Injecting marketplace credentials into S3 driver config')
42
45
  return {
43
46
  authMode: creds.authMode,
44
47
  bucket: config.bucket ?? (creds.bucket ? String(creds.bucket) : undefined),
@@ -50,7 +53,7 @@ export function register(container: AppContainer) {
50
53
  sessionToken: creds.sessionToken ? String(creds.sessionToken) : undefined,
51
54
  }
52
55
  } catch (err) {
53
- console.warn('[storage-s3] Credential enhancer failed, using partition config as-is:', err)
56
+ logger.warn('Credential enhancer failed, using partition config as-is', { err })
54
57
  return config
55
58
  }
56
59
  })
@@ -2,6 +2,9 @@ import type { ModuleSetupConfig } from '@open-mercato/shared/modules/setup'
2
2
  import { createCredentialsService } from '@open-mercato/core/modules/integrations/lib/credentials-service'
3
3
  import { createIntegrationLogService } from '@open-mercato/core/modules/integrations/lib/log-service'
4
4
  import { applyS3EnvPreset } from './lib/preset'
5
+ import { createLogger } from '@open-mercato/shared/lib/logger'
6
+
7
+ const logger = createLogger('storage_s3')
5
8
 
6
9
  const S3_INTEGRATION_ID = 'storage_s3'
7
10
 
@@ -27,10 +30,10 @@ export const setup: ModuleSetupConfig = {
27
30
  .error(`Failed to apply S3 env preset during tenant setup: ${message}`)
28
31
  } catch (logError) {
29
32
  const logMessage = logError instanceof Error ? logError.message : 'Unknown integration log error'
30
- console.error(
31
- `[storage_s3] Failed to apply env preset during tenant setup: ${message}. ` +
32
- `Also failed to persist the error to integration logs: ${logMessage}`,
33
- )
33
+ logger.error('Failed to apply env preset during tenant setup; persisting to integration logs also failed', {
34
+ presetError: message,
35
+ logError: logMessage,
36
+ })
34
37
  }
35
38
  }
36
39
  },