@open-mercato/storage-s3 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 { applyS3EnvPreset, readS3EnvPreset } from "./preset.js";
|
|
2
3
|
async function runConfigureFromEnv(deps, options) {
|
|
3
4
|
try {
|
|
@@ -45,25 +46,7 @@ async function runConfigureFromEnvForScopes(deps, scopes, options = {}) {
|
|
|
45
46
|
return { code, configured, skipped, errored, perScope };
|
|
46
47
|
}
|
|
47
48
|
function parseCliArgs(args) {
|
|
48
|
-
|
|
49
|
-
for (let i = 0; i < args.length; i++) {
|
|
50
|
-
const arg = args[i];
|
|
51
|
-
if (!arg.startsWith("--")) continue;
|
|
52
|
-
const key = arg.slice(2);
|
|
53
|
-
if (key.includes("=")) {
|
|
54
|
-
const [name, value] = key.split("=");
|
|
55
|
-
result[name] = value;
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
const next = args[i + 1];
|
|
59
|
-
if (next && !next.startsWith("--")) {
|
|
60
|
-
result[key] = next;
|
|
61
|
-
i += 1;
|
|
62
|
-
continue;
|
|
63
|
-
}
|
|
64
|
-
result[key] = true;
|
|
65
|
-
}
|
|
66
|
-
return result;
|
|
49
|
+
return parseModuleCliOptions(args);
|
|
67
50
|
}
|
|
68
51
|
function resolveCliMode(args) {
|
|
69
52
|
const allTenants = args["all-tenants"] === true || args.allTenants === true;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/modules/storage_s3/lib/configure-from-env.ts"],
|
|
4
|
-
"sourcesContent": ["import 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 { IntegrationScope } from '@open-mercato/shared/modules/integrations/types'\nimport { applyS3EnvPreset, readS3EnvPreset } from './preset'\n\nexport type ConfigureFromEnvDeps = {\n credentialsService: CredentialsService\n integrationLogService: IntegrationLogService\n env?: NodeJS.ProcessEnv\n}\n\nexport type ConfigureFromEnvOptions = {\n tenantId: string\n organizationId: string\n force?: boolean\n}\n\nexport type ConfigureFromEnvOutcome =\n | { code: 0; status: 'configured' | 'skipped'; message: string }\n | { code: 1; status: 'error'; message: string }\n\nexport async function runConfigureFromEnv(\n deps: ConfigureFromEnvDeps,\n options: ConfigureFromEnvOptions,\n): Promise<ConfigureFromEnvOutcome> {\n try {\n const preset = readS3EnvPreset(deps.env ?? process.env)\n if (!preset) {\n return {\n code: 0,\n status: 'skipped',\n message: 'No S3 env preset was found. Set OM_INTEGRATION_STORAGE_S3_* variables to enable preconfiguration.',\n }\n }\n\n const result = await applyS3EnvPreset({\n credentialsService: deps.credentialsService,\n integrationLogService: deps.integrationLogService,\n scope: { tenantId: options.tenantId, organizationId: options.organizationId },\n force: options.force,\n env: deps.env ?? process.env,\n })\n\n if (result.status === 'skipped') {\n return { code: 0, status: 'skipped', message: result.reason }\n }\n\n return { code: 0, status: 'configured', message: 'S3 credentials were configured from env.' }\n } catch (error) {\n const message = error instanceof Error ? error.message : 'Unknown S3 preset error'\n return { code: 1, status: 'error', message }\n }\n}\n\nexport type ConfigureFromEnvScopeOutcome = {\n scope: IntegrationScope\n outcome: ConfigureFromEnvOutcome\n}\n\nexport type ConfigureFromEnvAllOutcome = {\n code: 0 | 1\n configured: number\n skipped: number\n errored: number\n perScope: ConfigureFromEnvScopeOutcome[]\n}\n\nexport async function runConfigureFromEnvForScopes(\n deps: ConfigureFromEnvDeps,\n scopes: IntegrationScope[],\n options: { force?: boolean } = {},\n): Promise<ConfigureFromEnvAllOutcome> {\n const perScope: ConfigureFromEnvScopeOutcome[] = []\n let configured = 0\n let skipped = 0\n let errored = 0\n\n for (const scope of scopes) {\n const outcome = await runConfigureFromEnv(deps, {\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n force: options.force,\n })\n perScope.push({ scope, outcome })\n if (outcome.code === 1) errored += 1\n else if (outcome.status === 'configured') configured += 1\n else skipped += 1\n }\n\n const code: 0 | 1 = errored > 0 ? 1 : 0\n return { code, configured, skipped, errored, perScope }\n}\n\nexport function parseCliArgs(args: string[]): Record<string, string | boolean> {\n
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { parseModuleCliOptions } from '@open-mercato/shared/lib/cli/parseModuleCliOptions'\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 { IntegrationScope } from '@open-mercato/shared/modules/integrations/types'\nimport { applyS3EnvPreset, readS3EnvPreset } from './preset'\n\nexport type ConfigureFromEnvDeps = {\n credentialsService: CredentialsService\n integrationLogService: IntegrationLogService\n env?: NodeJS.ProcessEnv\n}\n\nexport type ConfigureFromEnvOptions = {\n tenantId: string\n organizationId: string\n force?: boolean\n}\n\nexport type ConfigureFromEnvOutcome =\n | { code: 0; status: 'configured' | 'skipped'; message: string }\n | { code: 1; status: 'error'; message: string }\n\nexport async function runConfigureFromEnv(\n deps: ConfigureFromEnvDeps,\n options: ConfigureFromEnvOptions,\n): Promise<ConfigureFromEnvOutcome> {\n try {\n const preset = readS3EnvPreset(deps.env ?? process.env)\n if (!preset) {\n return {\n code: 0,\n status: 'skipped',\n message: 'No S3 env preset was found. Set OM_INTEGRATION_STORAGE_S3_* variables to enable preconfiguration.',\n }\n }\n\n const result = await applyS3EnvPreset({\n credentialsService: deps.credentialsService,\n integrationLogService: deps.integrationLogService,\n scope: { tenantId: options.tenantId, organizationId: options.organizationId },\n force: options.force,\n env: deps.env ?? process.env,\n })\n\n if (result.status === 'skipped') {\n return { code: 0, status: 'skipped', message: result.reason }\n }\n\n return { code: 0, status: 'configured', message: 'S3 credentials were configured from env.' }\n } catch (error) {\n const message = error instanceof Error ? error.message : 'Unknown S3 preset error'\n return { code: 1, status: 'error', message }\n }\n}\n\nexport type ConfigureFromEnvScopeOutcome = {\n scope: IntegrationScope\n outcome: ConfigureFromEnvOutcome\n}\n\nexport type ConfigureFromEnvAllOutcome = {\n code: 0 | 1\n configured: number\n skipped: number\n errored: number\n perScope: ConfigureFromEnvScopeOutcome[]\n}\n\nexport async function runConfigureFromEnvForScopes(\n deps: ConfigureFromEnvDeps,\n scopes: IntegrationScope[],\n options: { force?: boolean } = {},\n): Promise<ConfigureFromEnvAllOutcome> {\n const perScope: ConfigureFromEnvScopeOutcome[] = []\n let configured = 0\n let skipped = 0\n let errored = 0\n\n for (const scope of scopes) {\n const outcome = await runConfigureFromEnv(deps, {\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n force: options.force,\n })\n perScope.push({ scope, outcome })\n if (outcome.code === 1) errored += 1\n else if (outcome.status === 'configured') configured += 1\n else skipped += 1\n }\n\n const code: 0 | 1 = errored > 0 ? 1 : 0\n return { code, configured, skipped, errored, perScope }\n}\n\nexport function parseCliArgs(args: string[]): Record<string, string | boolean> {\n return parseModuleCliOptions(args)\n}\n\nexport type ConfigureFromEnvCliMode =\n | { kind: 'help' }\n | { kind: 'conflict'; message: string }\n | { kind: 'all'; force?: boolean }\n | { kind: 'single'; tenantId: string; organizationId: string; force?: boolean }\n\nexport function resolveCliMode(args: Record<string, string | boolean>): ConfigureFromEnvCliMode {\n const allTenants = args['all-tenants'] === true || args.allTenants === true\n const tenantId = String(args.tenantId ?? args.tenant ?? '')\n const organizationId = String(args.organizationId ?? args.orgId ?? args.org ?? '')\n const force = args.force === true ? true : undefined\n\n if (allTenants && (tenantId || organizationId)) {\n return {\n kind: 'conflict',\n message: '--all-tenants cannot be combined with --tenant or --org. Pick one mode.',\n }\n }\n\n if (allTenants) {\n return { kind: 'all', force }\n }\n\n if (!tenantId || !organizationId) {\n return { kind: 'help' }\n }\n\n return { kind: 'single', tenantId, organizationId, force }\n}\n\ntype OrganizationRow = {\n id: string\n tenant?: { id?: string | null } | null\n}\n\nexport function mapOrganizationsToScopes(organizations: OrganizationRow[]): IntegrationScope[] {\n const scopes: IntegrationScope[] = []\n for (const organization of organizations) {\n const tenantId = organization.tenant?.id\n if (!tenantId) continue\n scopes.push({ tenantId, organizationId: organization.id })\n }\n return scopes\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,6BAA6B;AAItC,SAAS,kBAAkB,uBAAuB;AAkBlD,eAAsB,oBACpB,MACA,SACkC;AAClC,MAAI;AACF,UAAM,SAAS,gBAAgB,KAAK,OAAO,QAAQ,GAAG;AACtD,QAAI,CAAC,QAAQ;AACX,aAAO;AAAA,QACL,MAAM;AAAA,QACN,QAAQ;AAAA,QACR,SAAS;AAAA,MACX;AAAA,IACF;AAEA,UAAM,SAAS,MAAM,iBAAiB;AAAA,MACpC,oBAAoB,KAAK;AAAA,MACzB,uBAAuB,KAAK;AAAA,MAC5B,OAAO,EAAE,UAAU,QAAQ,UAAU,gBAAgB,QAAQ,eAAe;AAAA,MAC5E,OAAO,QAAQ;AAAA,MACf,KAAK,KAAK,OAAO,QAAQ;AAAA,IAC3B,CAAC;AAED,QAAI,OAAO,WAAW,WAAW;AAC/B,aAAO,EAAE,MAAM,GAAG,QAAQ,WAAW,SAAS,OAAO,OAAO;AAAA,IAC9D;AAEA,WAAO,EAAE,MAAM,GAAG,QAAQ,cAAc,SAAS,2CAA2C;AAAA,EAC9F,SAAS,OAAO;AACd,UAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU;AACzD,WAAO,EAAE,MAAM,GAAG,QAAQ,SAAS,QAAQ;AAAA,EAC7C;AACF;AAeA,eAAsB,6BACpB,MACA,QACA,UAA+B,CAAC,GACK;AACrC,QAAM,WAA2C,CAAC;AAClD,MAAI,aAAa;AACjB,MAAI,UAAU;AACd,MAAI,UAAU;AAEd,aAAW,SAAS,QAAQ;AAC1B,UAAM,UA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package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-mercato/storage-s3",
|
|
3
|
-
"version": "0.10.1-develop.
|
|
3
|
+
"version": "0.10.1-develop.8258.1.62a94b74a2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -74,21 +74,21 @@
|
|
|
74
74
|
"dependencies": {
|
|
75
75
|
"@aws-sdk/client-s3": "^3.1085.0",
|
|
76
76
|
"@aws-sdk/s3-request-presigner": "^3.1085.0",
|
|
77
|
-
"@open-mercato/core": "0.10.1-develop.
|
|
78
|
-
"@open-mercato/queue": "0.10.1-develop.
|
|
77
|
+
"@open-mercato/core": "0.10.1-develop.8258.1.62a94b74a2",
|
|
78
|
+
"@open-mercato/queue": "0.10.1-develop.8258.1.62a94b74a2"
|
|
79
79
|
},
|
|
80
80
|
"peerDependencies": {
|
|
81
81
|
"@mikro-orm/postgresql": "^7.0.14",
|
|
82
|
-
"@open-mercato/ai-assistant": "0.10.1-develop.
|
|
83
|
-
"@open-mercato/shared": "0.10.1-develop.
|
|
84
|
-
"@open-mercato/ui": "0.10.1-develop.
|
|
82
|
+
"@open-mercato/ai-assistant": "0.10.1-develop.8258.1.62a94b74a2",
|
|
83
|
+
"@open-mercato/shared": "0.10.1-develop.8258.1.62a94b74a2",
|
|
84
|
+
"@open-mercato/ui": "0.10.1-develop.8258.1.62a94b74a2",
|
|
85
85
|
"react": "^19.0.0",
|
|
86
86
|
"react-dom": "^19.0.0"
|
|
87
87
|
},
|
|
88
88
|
"devDependencies": {
|
|
89
|
-
"@open-mercato/ai-assistant": "0.10.1-develop.
|
|
90
|
-
"@open-mercato/shared": "0.10.1-develop.
|
|
91
|
-
"@open-mercato/ui": "0.10.1-develop.
|
|
89
|
+
"@open-mercato/ai-assistant": "0.10.1-develop.8258.1.62a94b74a2",
|
|
90
|
+
"@open-mercato/shared": "0.10.1-develop.8258.1.62a94b74a2",
|
|
91
|
+
"@open-mercato/ui": "0.10.1-develop.8258.1.62a94b74a2",
|
|
92
92
|
"@types/jest": "^30.0.0",
|
|
93
93
|
"esbuild": "^0.28.2",
|
|
94
94
|
"glob": "^14.0.6",
|
|
@@ -265,6 +265,14 @@ describe('storage_s3 configure-from-env --all-tenants helper', () => {
|
|
|
265
265
|
})
|
|
266
266
|
|
|
267
267
|
describe('storage_s3 parseCliArgs', () => {
|
|
268
|
+
it('preserves embedded equals signs and explicit empty option values', () => {
|
|
269
|
+
expect(parseCliArgs(['--tenant=a=b', '--org=encoded==', '--empty='])).toEqual({
|
|
270
|
+
tenant: 'a=b',
|
|
271
|
+
org: 'encoded==',
|
|
272
|
+
empty: '',
|
|
273
|
+
})
|
|
274
|
+
})
|
|
275
|
+
|
|
268
276
|
it('parses standalone flags as boolean true', () => {
|
|
269
277
|
expect(parseCliArgs(['--all-tenants'])).toEqual({ 'all-tenants': true })
|
|
270
278
|
expect(parseCliArgs(['--force'])).toEqual({ force: true })
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { parseModuleCliOptions } from '@open-mercato/shared/lib/cli/parseModuleCliOptions'
|
|
1
2
|
import type { CredentialsService } from '@open-mercato/core/modules/integrations/lib/credentials-service'
|
|
2
3
|
import type { IntegrationLogService } from '@open-mercato/core/modules/integrations/lib/log-service'
|
|
3
4
|
import type { IntegrationScope } from '@open-mercato/shared/modules/integrations/types'
|
|
@@ -92,30 +93,7 @@ export async function runConfigureFromEnvForScopes(
|
|
|
92
93
|
}
|
|
93
94
|
|
|
94
95
|
export function parseCliArgs(args: string[]): Record<string, string | boolean> {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
for (let i = 0; i < args.length; i++) {
|
|
98
|
-
const arg = args[i]
|
|
99
|
-
if (!arg.startsWith('--')) continue
|
|
100
|
-
|
|
101
|
-
const key = arg.slice(2)
|
|
102
|
-
if (key.includes('=')) {
|
|
103
|
-
const [name, value] = key.split('=')
|
|
104
|
-
result[name] = value
|
|
105
|
-
continue
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const next = args[i + 1]
|
|
109
|
-
if (next && !next.startsWith('--')) {
|
|
110
|
-
result[key] = next
|
|
111
|
-
i += 1
|
|
112
|
-
continue
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
result[key] = true
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
return result
|
|
96
|
+
return parseModuleCliOptions(args)
|
|
119
97
|
}
|
|
120
98
|
|
|
121
99
|
export type ConfigureFromEnvCliMode =
|