@open-mercato/cli 0.11.1-develop.8805.1.6357054d1a → 0.11.1-develop.8880.1.3acdbfc734
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.
- package/.turbo/turbo-build.log +8 -2
- package/dist/agentic/guides/module-facts.json +1575 -307
- package/dist/agentic/guides/module-facts.v2.json +1575 -307
- package/dist/agentic/guides/modules/agent_orchestrator/exact-override-targets.md +1 -1
- package/dist/agentic/guides/modules/agent_orchestrator/index.md +1 -1
- package/dist/agentic/guides/modules/agent_orchestrator/workers.md +1 -1
- package/dist/agentic/guides/modules/ai_assistant/index.md +1 -1
- package/dist/agentic/guides/modules/api_docs/index.md +1 -1
- package/dist/agentic/guides/modules/api_keys/index.md +1 -1
- package/dist/agentic/guides/modules/assisted_selling/index.md +1 -1
- package/dist/agentic/guides/modules/attachments/index.md +1 -1
- package/dist/agentic/guides/modules/attachments/umes-hosts.md +1 -0
- package/dist/agentic/guides/modules/audit_logs/index.md +1 -1
- package/dist/agentic/guides/modules/auth/di-registrations-rich.md +2 -1
- package/dist/agentic/guides/modules/auth/di-service-tokens.md +2 -1
- package/dist/agentic/guides/modules/auth/exact-override-targets.md +2 -1
- package/dist/agentic/guides/modules/auth/index.md +2 -2
- package/dist/agentic/guides/modules/availability/index.md +1 -1
- package/dist/agentic/guides/modules/backups/index.md +1 -1
- package/dist/agentic/guides/modules/business_rules/index.md +1 -1
- package/dist/agentic/guides/modules/carrier_inpost/index.md +1 -1
- package/dist/agentic/guides/modules/cart/index.md +1 -1
- package/dist/agentic/guides/modules/catalog/active-extension-bindings.md +1 -1
- package/dist/agentic/guides/modules/catalog/exact-override-targets.md +4 -4
- package/dist/agentic/guides/modules/catalog/index.md +2 -2
- package/dist/agentic/guides/modules/catalog/umes-hosts.md +3 -1
- package/dist/agentic/guides/modules/catalog/workers.md +4 -4
- package/dist/agentic/guides/modules/channel_apns/index.md +1 -1
- package/dist/agentic/guides/modules/channel_discord/index.md +1 -1
- package/dist/agentic/guides/modules/channel_expo/index.md +1 -1
- package/dist/agentic/guides/modules/channel_fcm/index.md +1 -1
- package/dist/agentic/guides/modules/channel_gmail/index.md +1 -1
- package/dist/agentic/guides/modules/channel_imap/index.md +1 -1
- package/dist/agentic/guides/modules/channel_resend/index.md +1 -1
- package/dist/agentic/guides/modules/channel_ses/index.md +1 -1
- package/dist/agentic/guides/modules/channel_smtp/index.md +1 -1
- package/dist/agentic/guides/modules/checkout/index.md +1 -1
- package/dist/agentic/guides/modules/communication_channels/encryption.md +2 -1
- package/dist/agentic/guides/modules/communication_channels/entities.md +1 -0
- package/dist/agentic/guides/modules/communication_channels/events.md +2 -1
- package/dist/agentic/guides/modules/communication_channels/exact-override-targets.md +4 -2
- package/dist/agentic/guides/modules/communication_channels/index.md +3 -3
- package/dist/agentic/guides/modules/communication_channels/umes-hosts.md +2 -0
- package/dist/agentic/guides/modules/communication_channels/workers.md +2 -1
- package/dist/agentic/guides/modules/configs/entities.md +0 -1
- package/dist/agentic/guides/modules/configs/index.md +1 -1
- package/dist/agentic/guides/modules/configs/umes-hosts.md +1 -1
- package/dist/agentic/guides/modules/content/index.md +1 -1
- package/dist/agentic/guides/modules/currencies/index.md +1 -1
- package/dist/agentic/guides/modules/currencies/umes-hosts.md +1 -0
- package/dist/agentic/guides/modules/customer_accounts/active-extension-bindings.md +3 -3
- package/dist/agentic/guides/modules/customer_accounts/index.md +1 -1
- package/dist/agentic/guides/modules/customer_accounts/umes-hosts.md +1 -1
- package/dist/agentic/guides/modules/customer_groups/active-extension-bindings.md +1 -1
- package/dist/agentic/guides/modules/customer_groups/index.md +1 -1
- package/dist/agentic/guides/modules/customer_groups/umes-hosts.md +1 -1
- package/dist/agentic/guides/modules/customers/acl-features.md +2 -1
- package/dist/agentic/guides/modules/customers/active-extension-bindings.md +12 -12
- package/dist/agentic/guides/modules/customers/backend-pages.md +1 -0
- package/dist/agentic/guides/modules/customers/domain-commands.md +1 -1
- package/dist/agentic/guides/modules/customers/exact-override-targets.md +2 -0
- package/dist/agentic/guides/modules/customers/index.md +1 -1
- package/dist/agentic/guides/modules/dashboards/active-extension-bindings.md +3 -3
- package/dist/agentic/guides/modules/dashboards/index.md +1 -1
- package/dist/agentic/guides/modules/data_sync/active-extension-bindings.md +3 -3
- package/dist/agentic/guides/modules/data_sync/index.md +1 -1
- package/dist/agentic/guides/modules/design_system/index.md +1 -1
- package/dist/agentic/guides/modules/devices/active-extension-bindings.md +1 -1
- package/dist/agentic/guides/modules/devices/index.md +1 -1
- package/dist/agentic/guides/modules/devices/owned-contract-module-metadata.md +1 -1
- package/dist/agentic/guides/modules/dictionaries/active-extension-bindings.md +2 -2
- package/dist/agentic/guides/modules/dictionaries/index.md +1 -1
- package/dist/agentic/guides/modules/directory/active-extension-bindings.md +1 -1
- package/dist/agentic/guides/modules/directory/index.md +1 -1
- package/dist/agentic/guides/modules/documents/index.md +1 -1
- package/dist/agentic/guides/modules/ecommerce/index.md +1 -1
- package/dist/agentic/guides/modules/ecommerce/owned-contract-module-metadata.md +1 -1
- package/dist/agentic/guides/modules/entities/active-extension-bindings.md +1 -1
- package/dist/agentic/guides/modules/entities/index.md +1 -1
- package/dist/agentic/guides/modules/eudr/index.md +1 -1
- package/dist/agentic/guides/modules/events/index.md +1 -1
- package/dist/agentic/guides/modules/feature_toggles/active-extension-bindings.md +1 -1
- package/dist/agentic/guides/modules/feature_toggles/index.md +1 -1
- package/dist/agentic/guides/modules/forms/index.md +1 -1
- package/dist/agentic/guides/modules/gateway_autopay/index.md +1 -1
- package/dist/agentic/guides/modules/gateway_stripe/index.md +1 -1
- package/dist/agentic/guides/modules/gateway_tpay/index.md +1 -1
- package/dist/agentic/guides/modules/generators/index.md +1 -1
- package/dist/agentic/guides/modules/inbox_ops/active-extension-bindings.md +3 -3
- package/dist/agentic/guides/modules/inbox_ops/index.md +1 -1
- package/dist/agentic/guides/modules/integrations/index.md +1 -1
- package/dist/agentic/guides/modules/ledger/index.md +2 -2
- package/dist/agentic/guides/modules/ledger/umes-hosts.md +1 -0
- package/dist/agentic/guides/modules/maintenance/contribution-resolutions.md +11 -0
- package/dist/agentic/guides/modules/maintenance/events.md +14 -0
- package/dist/agentic/guides/modules/maintenance/exact-override-targets.md +11 -0
- package/dist/agentic/guides/modules/maintenance/index.md +17 -0
- package/dist/agentic/guides/modules/maintenance/owned-contract-module-metadata.md +11 -0
- package/dist/agentic/guides/modules/maintenance/umes-contributions.md +11 -0
- package/dist/agentic/guides/modules/maintenance/umes-hosts.md +14 -0
- package/dist/agentic/guides/modules/messages/index.md +1 -1
- package/dist/agentic/guides/modules/notifications/index.md +1 -1
- package/dist/agentic/guides/modules/onboarding/index.md +1 -1
- package/dist/agentic/guides/modules/payment_gateways/active-extension-bindings.md +1 -1
- package/dist/agentic/guides/modules/payment_gateways/exact-override-targets.md +3 -3
- package/dist/agentic/guides/modules/payment_gateways/index.md +1 -1
- package/dist/agentic/guides/modules/payment_gateways/setup.md +1 -1
- package/dist/agentic/guides/modules/perspectives/active-extension-bindings.md +2 -2
- package/dist/agentic/guides/modules/perspectives/index.md +1 -1
- package/dist/agentic/guides/modules/phone_calls/index.md +1 -1
- package/dist/agentic/guides/modules/phone_calls/owned-contract-module-metadata.md +1 -1
- package/dist/agentic/guides/modules/planner/active-extension-bindings.md +1 -1
- package/dist/agentic/guides/modules/planner/index.md +1 -1
- package/dist/agentic/guides/modules/portal/index.md +1 -1
- package/dist/agentic/guides/modules/progress/index.md +1 -1
- package/dist/agentic/guides/modules/promotions/domain-commands.md +1 -0
- package/dist/agentic/guides/modules/promotions/index.md +2 -2
- package/dist/agentic/guides/modules/promotions/umes-hosts.md +2 -0
- package/dist/agentic/guides/modules/push_notifications/index.md +2 -2
- package/dist/agentic/guides/modules/push_notifications/umes-hosts.md +1 -0
- package/dist/agentic/guides/modules/query_index/active-extension-bindings.md +1 -1
- package/dist/agentic/guides/modules/query_index/index.md +1 -1
- package/dist/agentic/guides/modules/record_locks/index.md +1 -1
- package/dist/agentic/guides/modules/resources/active-extension-bindings.md +1 -1
- package/dist/agentic/guides/modules/resources/index.md +1 -1
- package/dist/agentic/guides/modules/sales/active-extension-bindings.md +1 -1
- package/dist/agentic/guides/modules/sales/index.md +1 -1
- package/dist/agentic/guides/modules/sales/umes-hosts.md +1 -0
- package/dist/agentic/guides/modules/sales_invoices_gl_posting/acl-features.md +12 -0
- package/dist/agentic/guides/modules/sales_invoices_gl_posting/entities.md +12 -0
- package/dist/agentic/guides/modules/sales_invoices_gl_posting/exact-override-targets.md +13 -0
- package/dist/agentic/guides/modules/sales_invoices_gl_posting/index.md +17 -0
- package/dist/agentic/guides/modules/sales_invoices_gl_posting/owned-contract-module-metadata.md +11 -0
- package/dist/agentic/guides/modules/sales_invoices_gl_posting/setup.md +11 -0
- package/dist/agentic/guides/modules/sales_invoices_gl_posting/umes-hosts.md +12 -0
- package/dist/agentic/guides/modules/scheduler/index.md +1 -1
- package/dist/agentic/guides/modules/search/index.md +1 -1
- package/dist/agentic/guides/modules/security/index.md +1 -1
- package/dist/agentic/guides/modules/seeds/index.md +1 -1
- package/dist/agentic/guides/modules/shipping_carriers/active-extension-bindings.md +1 -1
- package/dist/agentic/guides/modules/shipping_carriers/index.md +1 -1
- package/dist/agentic/guides/modules/sso/index.md +1 -1
- package/dist/agentic/guides/modules/staff/index.md +1 -1
- package/dist/agentic/guides/modules/storage_s3/index.md +1 -1
- package/dist/agentic/guides/modules/sync_akeneo/index.md +1 -1
- package/dist/agentic/guides/modules/sync_excel/index.md +1 -1
- package/dist/agentic/guides/modules/sync_excel/umes-hosts.md +1 -0
- package/dist/agentic/guides/modules/system_status_overlays/index.md +1 -1
- package/dist/agentic/guides/modules/telemetry/index.md +1 -1
- package/dist/agentic/guides/modules/tillio/index.md +1 -1
- package/dist/agentic/guides/modules/translations/active-extension-bindings.md +2 -2
- package/dist/agentic/guides/modules/translations/index.md +1 -1
- package/dist/agentic/guides/modules/upgrade_actions/cli-commands.md +11 -0
- package/dist/agentic/guides/modules/upgrade_actions/entities.md +11 -0
- package/dist/agentic/guides/modules/upgrade_actions/exact-override-targets.md +1 -0
- package/dist/agentic/guides/modules/upgrade_actions/index.md +5 -2
- package/dist/agentic/guides/modules/upgrade_actions/umes-hosts.md +11 -0
- package/dist/agentic/guides/modules/warranty_claims/index.md +1 -1
- package/dist/agentic/guides/modules/webhooks/index.md +1 -1
- package/dist/agentic/guides/modules/wms/active-extension-bindings.md +1 -1
- package/dist/agentic/guides/modules/wms/exact-override-targets.md +2 -2
- package/dist/agentic/guides/modules/wms/index.md +1 -1
- package/dist/agentic/guides/modules/wms/setup.md +1 -1
- package/dist/agentic/guides/modules/workflows/domain-commands.md +3 -0
- package/dist/agentic/guides/modules/workflows/index.md +1 -1
- package/dist/agentic/guides/modules/workflows/umes-hosts.md +2 -0
- package/dist/agentic/guides/production-deployment.md +6 -0
- package/dist/agentic/guides/reference-module-facts.json +12 -13
- package/dist/agentic/guides/reference-modules/example/index.md +1 -1
- package/dist/agentic/guides/reference-modules/example/umes-hosts.md +1 -1
- package/dist/agentic/guides/upstream/AGENTS.md +2 -3
- package/dist/agentic/guides/upstream/BACKWARD_COMPATIBILITY.md +18 -9
- package/dist/agentic/guides/upstream/manifest.json +3 -3
- package/dist/agentic/shared/AGENTS.md.template +1 -1
- package/dist/agentic/shared/ai/harness/cases.json +7 -7
- package/dist/lib/generators/module-extension-facts.js +5 -6
- package/dist/lib/generators/module-extension-facts.js.map +2 -2
- package/dist/lib/generators/module-registry.js +28 -0
- package/dist/lib/generators/module-registry.js.map +2 -2
- package/dist/lib/testing/ephemeral-database-guard.js +89 -0
- package/dist/lib/testing/ephemeral-database-guard.js.map +7 -0
- package/dist/lib/testing/integration.js +4 -0
- package/dist/lib/testing/integration.js.map +2 -2
- package/dist/mercato.js +26 -3
- package/dist/mercato.js.map +2 -2
- package/package.json +7 -7
- package/src/__tests__/init-ephemeral-database.test.ts +112 -0
- package/src/__tests__/mercato.test.ts +15 -0
- package/src/lib/__tests__/modules-config.test.ts +1 -0
- package/src/lib/generators/__tests__/module-extension-facts.test.ts +18 -0
- package/src/lib/generators/__tests__/module-facts.customers.fixture.test.ts +2 -1
- package/src/lib/generators/__tests__/module-registry-requires-enforcement.test.ts +18 -0
- package/src/lib/generators/__tests__/registry-variant-parity.test.ts +95 -19
- package/src/lib/generators/module-extension-facts.ts +5 -10
- package/src/lib/generators/module-registry.ts +44 -0
- package/src/lib/testing/__tests__/ephemeral-database-guard.test.ts +88 -0
- package/src/lib/testing/ephemeral-database-guard.ts +105 -0
- package/src/lib/testing/integration.ts +4 -0
- package/src/mercato.ts +26 -3
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
+
import { lstatSync, readFileSync } from "node:fs";
|
|
3
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
const identityQuery = "SELECT current_database() AS database_name, shobj_description(oid, 'pg_database') AS ownership_marker FROM pg_database WHERE datname = current_database()";
|
|
6
|
+
function connectionTarget(databaseUrl) {
|
|
7
|
+
if (!databaseUrl) throw new Error("[internal] Ephemeral initialization requires an explicit database connection.");
|
|
8
|
+
let parsed;
|
|
9
|
+
try {
|
|
10
|
+
parsed = new URL(databaseUrl);
|
|
11
|
+
} catch {
|
|
12
|
+
throw new Error("[internal] Ephemeral database connection is invalid.");
|
|
13
|
+
}
|
|
14
|
+
if (!["postgres:", "postgresql:"].includes(parsed.protocol) || !parsed.hostname || parsed.pathname.length < 2) {
|
|
15
|
+
throw new Error("[internal] Ephemeral database connection is invalid.");
|
|
16
|
+
}
|
|
17
|
+
const databaseName = decodeURIComponent(parsed.pathname.slice(1));
|
|
18
|
+
const port = parsed.port || "5432";
|
|
19
|
+
return `postgresql://${decodeURIComponent(parsed.username)}@${parsed.hostname.toLowerCase()}:${port}/${databaseName}`;
|
|
20
|
+
}
|
|
21
|
+
function connectionDigest(databaseUrl) {
|
|
22
|
+
return createHash("sha256").update(connectionTarget(databaseUrl)).digest("hex");
|
|
23
|
+
}
|
|
24
|
+
function readEphemeralDatabaseGuard(args) {
|
|
25
|
+
const prefix = "--ephemeral-database-guard=";
|
|
26
|
+
const values = args.filter((argument) => argument === "--ephemeral-database-guard" || argument.startsWith(prefix));
|
|
27
|
+
if (values.length === 0) return null;
|
|
28
|
+
if (values.length !== 1 || !values[0].startsWith(prefix) || !values[0].slice(prefix.length)) {
|
|
29
|
+
throw new Error("[internal] Ephemeral initialization requires one database ownership proof file.");
|
|
30
|
+
}
|
|
31
|
+
const proofPath = values[0].slice(prefix.length);
|
|
32
|
+
const metadata = lstatSync(proofPath);
|
|
33
|
+
if (!metadata.isFile() || metadata.isSymbolicLink() || metadata.size > 4096 || process.platform !== "win32" && ((metadata.mode & 63) !== 0 || metadata.uid !== process.getuid?.())) {
|
|
34
|
+
throw new Error("[internal] Ephemeral database ownership proof must be a private regular file.");
|
|
35
|
+
}
|
|
36
|
+
const value = JSON.parse(readFileSync(proofPath, "utf8"));
|
|
37
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
38
|
+
throw new Error("[internal] Ephemeral database ownership proof is invalid.");
|
|
39
|
+
}
|
|
40
|
+
const record = value;
|
|
41
|
+
if (record.version !== 1 || typeof record.databaseName !== "string" || !record.databaseName || typeof record.connectionDigest !== "string" || !/^[a-f0-9]{64}$/.test(record.connectionDigest) || typeof record.ownershipMarker !== "string" || !/^open-mercato-ephemeral:[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/.test(record.ownershipMarker)) {
|
|
42
|
+
throw new Error("[internal] Ephemeral database ownership proof is invalid.");
|
|
43
|
+
}
|
|
44
|
+
return { version: 1, databaseName: record.databaseName, connectionDigest: record.connectionDigest, ownershipMarker: record.ownershipMarker };
|
|
45
|
+
}
|
|
46
|
+
function assertEphemeralDatabaseConnection(guard, databaseUrl) {
|
|
47
|
+
if (connectionDigest(databaseUrl) !== guard.connectionDigest) {
|
|
48
|
+
throw new Error("[internal] Refusing initialization: the effective database connection is not the owned disposable target.");
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async function assertEphemeralDatabaseOwnership(guard, client) {
|
|
52
|
+
const identity = (await client.query(identityQuery)).rows[0];
|
|
53
|
+
if (identity?.database_name !== guard.databaseName || identity?.ownership_marker !== guard.ownershipMarker) {
|
|
54
|
+
throw new Error("[internal] Refusing initialization: database ownership could not be verified.");
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async function createEphemeralDatabaseGuard(databaseUrl, databaseName, directory) {
|
|
58
|
+
const digest = connectionDigest(databaseUrl);
|
|
59
|
+
if (decodeURIComponent(new URL(databaseUrl).pathname.slice(1)) !== databaseName) {
|
|
60
|
+
throw new Error("[internal] Disposable database identity does not match its allocation.");
|
|
61
|
+
}
|
|
62
|
+
const { Client } = await import("pg");
|
|
63
|
+
const client = new Client({ connectionString: databaseUrl, connectionTimeoutMillis: 5e3 });
|
|
64
|
+
const ownershipMarker = `open-mercato-ephemeral:${randomUUID()}`;
|
|
65
|
+
try {
|
|
66
|
+
await client.connect();
|
|
67
|
+
const identity = (await client.query(identityQuery)).rows[0];
|
|
68
|
+
if (identity?.database_name !== databaseName) {
|
|
69
|
+
throw new Error("[internal] Connected database identity does not match its allocation.");
|
|
70
|
+
}
|
|
71
|
+
const quotedName = `"${databaseName.replace(/"/g, '""')}"`;
|
|
72
|
+
await client.query(`COMMENT ON DATABASE ${quotedName} IS '${ownershipMarker}'`);
|
|
73
|
+
const guard = { version: 1, databaseName, connectionDigest: digest, ownershipMarker };
|
|
74
|
+
await assertEphemeralDatabaseOwnership(guard, client);
|
|
75
|
+
await mkdir(directory, { recursive: true, mode: 448 });
|
|
76
|
+
const proofPath = path.join(directory, `${randomUUID()}.json`);
|
|
77
|
+
await writeFile(proofPath, JSON.stringify(guard), { mode: 384, flag: "wx" });
|
|
78
|
+
return proofPath;
|
|
79
|
+
} finally {
|
|
80
|
+
await client.end();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
export {
|
|
84
|
+
assertEphemeralDatabaseConnection,
|
|
85
|
+
assertEphemeralDatabaseOwnership,
|
|
86
|
+
createEphemeralDatabaseGuard,
|
|
87
|
+
readEphemeralDatabaseGuard
|
|
88
|
+
};
|
|
89
|
+
//# sourceMappingURL=ephemeral-database-guard.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/lib/testing/ephemeral-database-guard.ts"],
|
|
4
|
+
"sourcesContent": ["import { createHash, randomUUID } from 'node:crypto'\nimport { lstatSync, readFileSync } from 'node:fs'\nimport { mkdir, writeFile } from 'node:fs/promises'\nimport path from 'node:path'\n\ntype DatabaseIdentity = { database_name: unknown; ownership_marker: unknown }\n\nexport type EphemeralDatabaseConnection = {\n query: (statement: string) => Promise<{ rows: DatabaseIdentity[] }>\n}\n\nexport type EphemeralDatabaseGuard = {\n version: 1\n databaseName: string\n connectionDigest: string\n ownershipMarker: string\n}\n\nconst identityQuery = \"SELECT current_database() AS database_name, shobj_description(oid, 'pg_database') AS ownership_marker FROM pg_database WHERE datname = current_database()\"\n\nfunction connectionTarget(databaseUrl: string | undefined): string {\n if (!databaseUrl) throw new Error('[internal] Ephemeral initialization requires an explicit database connection.')\n let parsed: URL\n try {\n parsed = new URL(databaseUrl)\n } catch {\n throw new Error('[internal] Ephemeral database connection is invalid.')\n }\n if (!['postgres:', 'postgresql:'].includes(parsed.protocol) || !parsed.hostname || parsed.pathname.length < 2) {\n throw new Error('[internal] Ephemeral database connection is invalid.')\n }\n const databaseName = decodeURIComponent(parsed.pathname.slice(1))\n const port = parsed.port || '5432'\n return `postgresql://${decodeURIComponent(parsed.username)}@${parsed.hostname.toLowerCase()}:${port}/${databaseName}`\n}\n\nfunction connectionDigest(databaseUrl: string | undefined): string {\n return createHash('sha256').update(connectionTarget(databaseUrl)).digest('hex')\n}\n\nexport function readEphemeralDatabaseGuard(args: string[]): EphemeralDatabaseGuard | null {\n const prefix = '--ephemeral-database-guard='\n const values = args.filter((argument) => argument === '--ephemeral-database-guard' || argument.startsWith(prefix))\n if (values.length === 0) return null\n if (values.length !== 1 || !values[0].startsWith(prefix) || !values[0].slice(prefix.length)) {\n throw new Error('[internal] Ephemeral initialization requires one database ownership proof file.')\n }\n const proofPath = values[0].slice(prefix.length)\n const metadata = lstatSync(proofPath)\n if (!metadata.isFile() || metadata.isSymbolicLink() || metadata.size > 4096\n || (process.platform !== 'win32' && ((metadata.mode & 0o077) !== 0 || metadata.uid !== process.getuid?.()))) {\n throw new Error('[internal] Ephemeral database ownership proof must be a private regular file.')\n }\n const value: unknown = JSON.parse(readFileSync(proofPath, 'utf8'))\n if (!value || typeof value !== 'object' || Array.isArray(value)) {\n throw new Error('[internal] Ephemeral database ownership proof is invalid.')\n }\n const record = value as Record<string, unknown>\n if (record.version !== 1 || typeof record.databaseName !== 'string' || !record.databaseName\n || typeof record.connectionDigest !== 'string' || !/^[a-f0-9]{64}$/.test(record.connectionDigest)\n || typeof record.ownershipMarker !== 'string' || !/^open-mercato-ephemeral:[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/.test(record.ownershipMarker)) {\n throw new Error('[internal] Ephemeral database ownership proof is invalid.')\n }\n return { version: 1, databaseName: record.databaseName, connectionDigest: record.connectionDigest, ownershipMarker: record.ownershipMarker }\n}\n\nexport function assertEphemeralDatabaseConnection(guard: EphemeralDatabaseGuard, databaseUrl: string | undefined): void {\n if (connectionDigest(databaseUrl) !== guard.connectionDigest) {\n throw new Error('[internal] Refusing initialization: the effective database connection is not the owned disposable target.')\n }\n}\n\nexport async function assertEphemeralDatabaseOwnership(guard: EphemeralDatabaseGuard, client: EphemeralDatabaseConnection): Promise<void> {\n const identity = (await client.query(identityQuery)).rows[0]\n if (identity?.database_name !== guard.databaseName || identity?.ownership_marker !== guard.ownershipMarker) {\n throw new Error('[internal] Refusing initialization: database ownership could not be verified.')\n }\n}\n\nexport async function createEphemeralDatabaseGuard(databaseUrl: string, databaseName: string, directory: string): Promise<string> {\n const digest = connectionDigest(databaseUrl)\n if (decodeURIComponent(new URL(databaseUrl).pathname.slice(1)) !== databaseName) {\n throw new Error('[internal] Disposable database identity does not match its allocation.')\n }\n const { Client } = await import('pg')\n const client = new Client({ connectionString: databaseUrl, connectionTimeoutMillis: 5000 })\n const ownershipMarker = `open-mercato-ephemeral:${randomUUID()}`\n try {\n await client.connect()\n const identity = (await client.query<DatabaseIdentity>(identityQuery)).rows[0]\n if (identity?.database_name !== databaseName) {\n throw new Error('[internal] Connected database identity does not match its allocation.')\n }\n const quotedName = `\"${databaseName.replace(/\"/g, '\"\"')}\"`\n await client.query(`COMMENT ON DATABASE ${quotedName} IS '${ownershipMarker}'`)\n const guard: EphemeralDatabaseGuard = { version: 1, databaseName, connectionDigest: digest, ownershipMarker }\n await assertEphemeralDatabaseOwnership(guard, client)\n await mkdir(directory, { recursive: true, mode: 0o700 })\n const proofPath = path.join(directory, `${randomUUID()}.json`)\n await writeFile(proofPath, JSON.stringify(guard), { mode: 0o600, flag: 'wx' })\n return proofPath\n } finally {\n await client.end()\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,YAAY,kBAAkB;AACvC,SAAS,WAAW,oBAAoB;AACxC,SAAS,OAAO,iBAAiB;AACjC,OAAO,UAAU;AAejB,MAAM,gBAAgB;AAEtB,SAAS,iBAAiB,aAAyC;AACjE,MAAI,CAAC,YAAa,OAAM,IAAI,MAAM,+EAA+E;AACjH,MAAI;AACJ,MAAI;AACF,aAAS,IAAI,IAAI,WAAW;AAAA,EAC9B,QAAQ;AACN,UAAM,IAAI,MAAM,sDAAsD;AAAA,EACxE;AACA,MAAI,CAAC,CAAC,aAAa,aAAa,EAAE,SAAS,OAAO,QAAQ,KAAK,CAAC,OAAO,YAAY,OAAO,SAAS,SAAS,GAAG;AAC7G,UAAM,IAAI,MAA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AQ,eAAe,GAAG;AAC9E,UAAM,QAAgC,EAAE,SAAS,GAAG,cAAc,kBAAkB,QAAQ,gBAAgB;AAC5G,UAAM,iCAAiC,OAAO,MAAM;AACpD,UAAM,MAAM,WAAW,EAAE,WAAW,MAAM,MAAM,IAAM,CAAC;AACvD,UAAM,YAAY,KAAK,KAAK,WAAW,GAAG,WAAW,CAAC,OAAO;AAC7D,UAAM,UAAU,WAAW,KAAK,UAAU,KAAK,GAAG,EAAE,MAAM,KAAO,MAAM,KAAK,CAAC;AAC7E,WAAO;AAAA,EACT,UAAE;AACA,UAAM,OAAO,IAAI;AAAA,EACnB;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1667,6 +1667,8 @@ function buildReusableEnvironment(baseUrl, databaseUrl, queueBaseDir, captureScr
|
|
|
1667
1667
|
OM_TEST_EMAIL_CAPTURE_ACCESS_TOKEN: TEST_EMAIL_CAPTURE_ACCESS_TOKEN,
|
|
1668
1668
|
OM_TEST_EMAIL_CAPTURE_CORRELATION_TOKEN: TEST_EMAIL_CAPTURE_CORRELATION_TOKEN,
|
|
1669
1669
|
SYSTEM_EMAIL_PROVIDER: "__test_seed__",
|
|
1670
|
+
// Queued system email specs wait on real retries; keep the backoff short.
|
|
1671
|
+
OM_SYSTEM_EMAIL_RETRY_BASE_MS: "500",
|
|
1670
1672
|
EMAIL_FROM: process.env.EMAIL_FROM ?? "system@test-seed.local",
|
|
1671
1673
|
NOTIFICATIONS_EMAIL_FROM: process.env.NOTIFICATIONS_EMAIL_FROM ?? "notifications@test-seed.local",
|
|
1672
1674
|
ADMIN_EMAIL: process.env.ADMIN_EMAIL ?? "admin@test-seed.local",
|
|
@@ -3059,6 +3061,8 @@ async function startEphemeralEnvironment(options) {
|
|
|
3059
3061
|
OM_TEST_EMAIL_CAPTURE_ACCESS_TOKEN: TEST_EMAIL_CAPTURE_ACCESS_TOKEN,
|
|
3060
3062
|
OM_TEST_EMAIL_CAPTURE_CORRELATION_TOKEN: TEST_EMAIL_CAPTURE_CORRELATION_TOKEN,
|
|
3061
3063
|
SYSTEM_EMAIL_PROVIDER: "__test_seed__",
|
|
3064
|
+
// Queued system email specs wait on real retries; keep the backoff short.
|
|
3065
|
+
OM_SYSTEM_EMAIL_RETRY_BASE_MS: "500",
|
|
3062
3066
|
EMAIL_FROM: process.env.EMAIL_FROM ?? "system@test-seed.local",
|
|
3063
3067
|
NOTIFICATIONS_EMAIL_FROM: process.env.NOTIFICATIONS_EMAIL_FROM ?? "notifications@test-seed.local",
|
|
3064
3068
|
ADMIN_EMAIL: process.env.ADMIN_EMAIL ?? "admin@test-seed.local",
|