@open-mercato/cli 0.11.1-develop.8589.1.db1a76ea60 → 0.11.1-develop.8665.1.2455b2503c
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 +4 -2
- package/AGENTS.md +3 -0
- package/dist/agentic/guides/architecture.md +2 -2
- package/dist/agentic/guides/extensions.md +7 -2
- package/dist/agentic/guides/framework-extension-points.md +1 -0
- package/dist/agentic/guides/infrastructure-providers.md +20 -0
- package/dist/agentic/guides/integrations.md +2 -2
- package/dist/agentic/guides/module-facts.json +2564 -265
- package/dist/agentic/guides/module-facts.v2.json +2580 -265
- package/dist/agentic/guides/modules/agent_orchestrator/index.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/acl-features.md +16 -0
- package/dist/agentic/guides/modules/assisted_selling/contribution-resolutions.md +21 -0
- package/dist/agentic/guides/modules/assisted_selling/domain-commands.md +11 -0
- package/dist/agentic/guides/modules/assisted_selling/entities.md +11 -0
- package/dist/agentic/guides/modules/assisted_selling/events.md +22 -0
- package/dist/agentic/guides/modules/assisted_selling/exact-override-targets.md +17 -0
- package/dist/agentic/guides/modules/assisted_selling/index.md +21 -0
- package/dist/agentic/guides/modules/assisted_selling/owned-contract-module-metadata.md +11 -0
- package/dist/agentic/guides/modules/assisted_selling/setup.md +11 -0
- package/dist/agentic/guides/modules/assisted_selling/umes-contributions.md +21 -0
- package/dist/agentic/guides/modules/assisted_selling/umes-hosts.md +23 -0
- package/dist/agentic/guides/modules/attachments/exact-override-targets.md +1 -1
- package/dist/agentic/guides/modules/attachments/index.md +1 -1
- package/dist/agentic/guides/modules/attachments/workers.md +1 -1
- package/dist/agentic/guides/modules/audit_logs/index.md +1 -1
- package/dist/agentic/guides/modules/auth/index.md +1 -1
- package/dist/agentic/guides/modules/availability/index.md +1 -1
- package/dist/agentic/guides/modules/backups/di-registrations-rich.md +11 -0
- package/dist/agentic/guides/modules/backups/di-service-tokens.md +11 -0
- package/dist/agentic/guides/modules/backups/exact-override-targets.md +11 -0
- package/dist/agentic/guides/modules/backups/index.md +5 -2
- 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/acl-features.md +2 -1
- package/dist/agentic/guides/modules/catalog/active-extension-bindings.md +2 -0
- package/dist/agentic/guides/modules/catalog/backend-pages.md +1 -0
- package/dist/agentic/guides/modules/catalog/contribution-resolutions.md +5 -0
- package/dist/agentic/guides/modules/catalog/di-registrations-rich.md +8 -7
- package/dist/agentic/guides/modules/catalog/di-service-tokens.md +5 -4
- package/dist/agentic/guides/modules/catalog/domain-commands.md +2 -0
- package/dist/agentic/guides/modules/catalog/entities.md +1 -0
- package/dist/agentic/guides/modules/catalog/events.md +4 -1
- package/dist/agentic/guides/modules/catalog/exact-override-targets.md +13 -7
- package/dist/agentic/guides/modules/catalog/index.md +9 -9
- package/dist/agentic/guides/modules/catalog/umes-contributions.md +5 -0
- package/dist/agentic/guides/modules/catalog/umes-hosts.md +4 -0
- package/dist/agentic/guides/modules/catalog/workers.md +1 -0
- 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/index.md +1 -1
- package/dist/agentic/guides/modules/configs/index.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/customer_accounts/active-extension-bindings.md +1 -1
- package/dist/agentic/guides/modules/customer_accounts/exact-override-targets.md +2 -0
- package/dist/agentic/guides/modules/customer_accounts/index.md +2 -2
- package/dist/agentic/guides/modules/customer_accounts/workers.md +2 -0
- package/dist/agentic/guides/modules/customer_groups/index.md +1 -1
- package/dist/agentic/guides/modules/customers/active-extension-bindings.md +2 -1
- package/dist/agentic/guides/modules/customers/incoming-installed-contributions.md +1 -0
- package/dist/agentic/guides/modules/customers/index.md +3 -3
- package/dist/agentic/guides/modules/customers/umes-hosts.md +1 -0
- package/dist/agentic/guides/modules/dashboards/active-extension-bindings.md +0 -1
- package/dist/agentic/guides/modules/dashboards/cli-commands.md +1 -0
- package/dist/agentic/guides/modules/dashboards/exact-override-targets.md +1 -0
- package/dist/agentic/guides/modules/dashboards/index.md +2 -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/index.md +1 -1
- package/dist/agentic/guides/modules/dictionaries/index.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/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/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/index.md +1 -1
- package/dist/agentic/guides/modules/integrations/di-registrations-rich.md +8 -8
- package/dist/agentic/guides/modules/integrations/di-service-tokens.md +4 -4
- package/dist/agentic/guides/modules/integrations/exact-override-targets.md +14 -12
- package/dist/agentic/guides/modules/integrations/index.md +2 -2
- package/dist/agentic/guides/modules/integrations/setup.md +1 -1
- package/dist/agentic/guides/modules/integrations/workers.md +3 -1
- 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/index.md +1 -1
- 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/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/index.md +1 -1
- package/dist/agentic/guides/modules/push_notifications/index.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/exact-override-targets.md +3 -3
- package/dist/agentic/guides/modules/resources/index.md +1 -1
- package/dist/agentic/guides/modules/resources/owned-contract-module-metadata.md +1 -1
- package/dist/agentic/guides/modules/resources/setup.md +1 -1
- package/dist/agentic/guides/modules/sales/contribution-resolutions.md +1 -0
- package/dist/agentic/guides/modules/sales/exact-override-targets.md +1 -0
- package/dist/agentic/guides/modules/sales/index.md +3 -3
- package/dist/agentic/guides/modules/sales/umes-contributions.md +1 -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/index.md +1 -1
- package/dist/agentic/guides/modules/sso/index.md +1 -1
- package/dist/agentic/guides/modules/staff/contribution-resolutions.md +1 -1
- package/dist/agentic/guides/modules/staff/exact-override-targets.md +1 -1
- package/dist/agentic/guides/modules/staff/index.md +1 -1
- package/dist/agentic/guides/modules/staff/workers.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/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/index.md +1 -1
- 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/index.md +1 -1
- package/dist/agentic/guides/modules/workflows/index.md +1 -1
- package/dist/agentic/guides/reference-module-facts.json +811 -21
- package/dist/agentic/guides/reference-modules/example/active-extension-bindings.md +1 -0
- package/dist/agentic/guides/reference-modules/example/backend-pages.md +2 -0
- package/dist/agentic/guides/reference-modules/example/contribution-resolutions.md +3 -1
- package/dist/agentic/guides/reference-modules/example/di-registrations-rich.md +3 -3
- package/dist/agentic/guides/reference-modules/example/di-service-tokens.md +1 -1
- package/dist/agentic/guides/reference-modules/example/entities.md +2 -0
- package/dist/agentic/guides/reference-modules/example/events.md +2 -1
- package/dist/agentic/guides/reference-modules/example/exact-override-targets.md +25 -8
- package/dist/agentic/guides/reference-modules/example/index.md +7 -7
- package/dist/agentic/guides/reference-modules/example/notifications.md +1 -0
- package/dist/agentic/guides/reference-modules/example/setup.md +1 -1
- package/dist/agentic/guides/reference-modules/example/umes-contributions.md +3 -1
- package/dist/agentic/guides/reference-modules/example/umes-hosts.md +4 -0
- package/dist/agentic/guides/upstream/AGENTS.md +5 -4
- package/dist/agentic/guides/upstream/BACKWARD_COMPATIBILITY.md +37 -20
- package/dist/agentic/guides/upstream/manifest.json +3 -3
- package/dist/agentic/shared/AGENTS.md.template +11 -15
- package/dist/agentic/shared/ai/harness/README.md +4 -2
- package/dist/agentic/shared/ai/harness/RELEASE.md +4 -4
- package/dist/agentic/shared/ai/harness/cases.json +1420 -41
- package/dist/agentic/shared/ai/harness/cases.schema.json +4 -4
- package/dist/agentic/shared/ai/harness/design-system-inventory.json +640 -142
- package/dist/agentic/shared/ai/harness/source-link-inventory.json +223 -16
- package/dist/agentic/shared/ai/harness/validators.json +1 -1
- package/dist/agentic/shared/ai/skills/om-system-extension/SKILL.md +1 -1
- package/dist/agentic/shared/ai/skills/om-system-extension/references/extension-branches.md +25 -0
- package/dist/agentic/shared/ai/skills/om-system-extension/references/mechanism-selector.md +1 -0
- package/dist/agentic/shared/ai/skills/om-system-extension/references/unified-overrides.md +2 -0
- package/dist/agentic/shared/scripts/run-agent-harness-release.mjs +21 -1
- package/dist/lib/cache-provider-manifest.js +9 -0
- package/dist/lib/cache-provider-manifest.js.map +7 -0
- package/dist/lib/generate-child-process.js +21 -3
- package/dist/lib/generate-child-process.js.map +2 -2
- package/dist/lib/generate-watch-events.js +135 -19
- package/dist/lib/generate-watch-events.js.map +2 -2
- package/dist/lib/generate-watch-plan.js +170 -0
- package/dist/lib/generate-watch-plan.js.map +7 -0
- package/dist/lib/generate-watch-runner.js +54 -0
- package/dist/lib/generate-watch-runner.js.map +7 -0
- package/dist/lib/generate-watch-structure.js +578 -203
- package/dist/lib/generate-watch-structure.js.map +3 -3
- package/dist/lib/generators/ast/writers.js +5 -1
- package/dist/lib/generators/ast/writers.js.map +2 -2
- package/dist/lib/generators/cache-providers.js +80 -0
- package/dist/lib/generators/cache-providers.js.map +7 -0
- package/dist/lib/generators/extensions/agent-files.js +1 -0
- package/dist/lib/generators/extensions/agent-files.js.map +2 -2
- package/dist/lib/generators/form-section-ast.js +156 -0
- package/dist/lib/generators/form-section-ast.js.map +7 -0
- package/dist/lib/generators/form-section-extension-compiler.js +568 -0
- package/dist/lib/generators/form-section-extension-compiler.js.map +7 -0
- package/dist/lib/generators/form-section-extension-source.js +245 -0
- package/dist/lib/generators/form-section-extension-source.js.map +7 -0
- package/dist/lib/generators/form-section-runtime-revisions.js +184 -0
- package/dist/lib/generators/form-section-runtime-revisions.js.map +7 -0
- package/dist/lib/generators/form-sections.js +773 -0
- package/dist/lib/generators/form-sections.js.map +7 -0
- package/dist/lib/generators/index.js +2 -0
- package/dist/lib/generators/index.js.map +2 -2
- package/dist/lib/generators/module-entities.js +21 -2
- package/dist/lib/generators/module-entities.js.map +2 -2
- package/dist/lib/generators/module-extension-facts.js +2 -1
- package/dist/lib/generators/module-extension-facts.js.map +2 -2
- package/dist/lib/generators/module-facts.js +30 -1
- package/dist/lib/generators/module-facts.js.map +2 -2
- package/dist/lib/generators/module-override-targets.js +24 -2
- package/dist/lib/generators/module-override-targets.js.map +2 -2
- package/dist/lib/generators/module-registry.js +223 -194
- package/dist/lib/generators/module-registry.js.map +3 -3
- package/dist/lib/generators/openapi.js +51 -18
- package/dist/lib/generators/openapi.js.map +2 -2
- package/dist/lib/generators/web-research-adapters.js +54 -22
- package/dist/lib/generators/web-research-adapters.js.map +2 -2
- package/dist/lib/in-process-generate-watcher.js +98 -75
- package/dist/lib/in-process-generate-watcher.js.map +2 -2
- package/dist/lib/post-generate-invalidation.js +20 -1
- package/dist/lib/post-generate-invalidation.js.map +2 -2
- package/dist/lib/resolver.js +195 -1
- package/dist/lib/resolver.js.map +3 -3
- package/dist/lib/single-instance-strategy-guard.js +26 -3
- package/dist/lib/single-instance-strategy-guard.js.map +2 -2
- package/dist/mercato.js +106 -50
- package/dist/mercato.js.map +2 -2
- package/jest.config.cjs +2 -0
- package/package.json +7 -7
- package/src/__tests__/mercato.test.ts +18 -0
- package/src/__tests__/rotation-json-output.test.ts +52 -0
- package/src/lib/__tests__/cache-provider-manifest.test.ts +76 -0
- package/src/lib/__tests__/generate-child-process.test.ts +30 -0
- package/src/lib/__tests__/generate-watch-events.test.ts +377 -8
- package/src/lib/__tests__/generate-watch-plan.test.ts +99 -0
- package/src/lib/__tests__/generate-watch-runner.test.ts +138 -0
- package/src/lib/__tests__/generate-watch-structure.test.ts +556 -1
- package/src/lib/__tests__/in-process-generate-watcher.test.ts +393 -6
- package/src/lib/__tests__/module-inspection.test.ts +17 -11
- package/src/lib/__tests__/post-generate-invalidation.test.ts +108 -0
- package/src/lib/__tests__/resolver.form-section-gates.test.ts +82 -0
- package/src/lib/__tests__/single-instance-strategy-guard.test.ts +129 -0
- package/src/lib/cache-provider-manifest.ts +8 -0
- package/src/lib/generate-child-process.ts +26 -3
- package/src/lib/generate-watch-events.ts +189 -17
- package/src/lib/generate-watch-plan.ts +180 -0
- package/src/lib/generate-watch-runner.ts +63 -0
- package/src/lib/generate-watch-structure.ts +670 -227
- package/src/lib/generators/__tests__/cache-providers.test.ts +102 -0
- package/src/lib/generators/__tests__/derived-crud-route-collisions.test.ts +85 -0
- package/src/lib/generators/__tests__/form-section-outbox.test.ts +53 -0
- package/src/lib/generators/__tests__/form-sections.test.ts +896 -0
- package/src/lib/generators/__tests__/incremental-registry.test.ts +262 -0
- package/src/lib/generators/__tests__/module-extension-facts.test.ts +1 -0
- package/src/lib/generators/__tests__/module-facts.bc-guard.test.ts +8 -6
- package/src/lib/generators/__tests__/module-facts.example-fact-coverage.test.ts +37 -13
- package/src/lib/generators/__tests__/module-facts.local-reference.test.ts +13 -0
- package/src/lib/generators/__tests__/module-override-targets.test.ts +2 -3
- package/src/lib/generators/__tests__/module-subset.test.ts +1 -1
- package/src/lib/generators/__tests__/openapi.test.ts +147 -10
- package/src/lib/generators/__tests__/structural-contracts.test.ts +2 -2
- package/src/lib/generators/__tests__/web-research-adapters.test.ts +298 -87
- package/src/lib/generators/ast/writers.ts +6 -1
- package/src/lib/generators/cache-providers.ts +111 -0
- package/src/lib/generators/extension.ts +2 -0
- package/src/lib/generators/extensions/agent-files.ts +1 -0
- package/src/lib/generators/form-section-ast.ts +166 -0
- package/src/lib/generators/form-section-extension-compiler.ts +632 -0
- package/src/lib/generators/form-section-extension-source.ts +308 -0
- package/src/lib/generators/form-section-runtime-revisions.ts +211 -0
- package/src/lib/generators/form-sections.ts +896 -0
- package/src/lib/generators/index.ts +1 -0
- package/src/lib/generators/module-entities.ts +22 -4
- package/src/lib/generators/module-extension-facts.ts +1 -0
- package/src/lib/generators/module-facts.ts +40 -0
- package/src/lib/generators/module-override-targets.ts +19 -0
- package/src/lib/generators/module-registry.ts +246 -202
- package/src/lib/generators/openapi.ts +65 -20
- package/src/lib/generators/web-research-adapters.ts +76 -21
- package/src/lib/in-process-generate-watcher.ts +151 -96
- package/src/lib/post-generate-invalidation.ts +28 -1
- package/src/lib/resolver.ts +218 -0
- package/src/lib/single-instance-strategy-guard.ts +51 -1
- package/src/mercato.ts +117 -57
- package/dist/agentic/guides/modules/dashboards/incoming-installed-contributions.md +0 -11
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import crypto from "node:crypto";
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
|
+
import ts from "typescript-js";
|
|
4
5
|
import {
|
|
5
6
|
MODULE_CODE_EXTENSIONS,
|
|
6
7
|
SCAN_CONFIGS,
|
|
@@ -8,241 +9,615 @@ import {
|
|
|
8
9
|
scanModuleDir,
|
|
9
10
|
stripModuleCodeExtension
|
|
10
11
|
} from "./generators/scanner.js";
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"ai-agents.ts",
|
|
29
|
-
"analytics.ts",
|
|
30
|
-
"workflows.ts",
|
|
31
|
-
"inbox-actions.ts",
|
|
32
|
-
"message-types.ts",
|
|
33
|
-
"message-objects.ts",
|
|
34
|
-
"integration.ts",
|
|
35
|
-
"security.mfa-providers.ts",
|
|
36
|
-
"security.sudo.ts",
|
|
37
|
-
"data/entities.ts",
|
|
38
|
-
"data/extensions.ts",
|
|
39
|
-
"data/fields.ts",
|
|
40
|
-
"data/enrichers.ts",
|
|
41
|
-
"data/guards.ts",
|
|
42
|
-
"api/interceptors.ts",
|
|
43
|
-
"commands/interceptors.ts",
|
|
44
|
-
"widgets/components.ts",
|
|
45
|
-
"widgets/injection-table.ts",
|
|
46
|
-
"frontend/middleware.ts",
|
|
47
|
-
"backend/middleware.ts"
|
|
48
|
-
];
|
|
49
|
-
const CONTENT_SENSITIVE_SCAN_CONFIGS = [
|
|
50
|
-
SCAN_CONFIGS.apiRoutes,
|
|
51
|
-
SCAN_CONFIGS.apiPlainFiles,
|
|
52
|
-
SCAN_CONFIGS.subscribers,
|
|
53
|
-
SCAN_CONFIGS.workers,
|
|
54
|
-
SCAN_CONFIGS.dashboardWidgets,
|
|
55
|
-
SCAN_CONFIGS.injectionWidgets
|
|
56
|
-
];
|
|
57
|
-
const ROUTE_SHAPE_SCAN_CONFIGS = [
|
|
58
|
-
SCAN_CONFIGS.frontendPages,
|
|
59
|
-
SCAN_CONFIGS.backendPages
|
|
12
|
+
const cacheStates = /* @__PURE__ */ new WeakMap();
|
|
13
|
+
function createGenerateWatchStructureCache() {
|
|
14
|
+
const cache = {};
|
|
15
|
+
cacheStates.set(cache, { files: /* @__PURE__ */ new Map() });
|
|
16
|
+
return cache;
|
|
17
|
+
}
|
|
18
|
+
const REGISTRY_CONVENTIONS = [
|
|
19
|
+
"index",
|
|
20
|
+
"acl",
|
|
21
|
+
"setup",
|
|
22
|
+
"runtime",
|
|
23
|
+
"encryption",
|
|
24
|
+
"ce",
|
|
25
|
+
"integration",
|
|
26
|
+
"vector",
|
|
27
|
+
"data/extensions",
|
|
28
|
+
"data/fields"
|
|
60
29
|
];
|
|
30
|
+
const EXTENSION_CONVENTIONS = {
|
|
31
|
+
notifications: "registry.notifications",
|
|
32
|
+
"notifications.client": "registry.notifications",
|
|
33
|
+
"notifications.handlers": "registry.notifications",
|
|
34
|
+
"message-types": "registry.messages",
|
|
35
|
+
"message-objects": "registry.messages",
|
|
36
|
+
"ai-tools": "registry.ai-tools",
|
|
37
|
+
"ai-agents": "registry.ai-agents",
|
|
38
|
+
analytics: "registry.analytics",
|
|
39
|
+
translations: "registry.translatable-fields",
|
|
40
|
+
workflows: "registry.workflows",
|
|
41
|
+
"inbox-actions": "registry.inbox-actions",
|
|
42
|
+
"data/enrichers": "registry.enrichers",
|
|
43
|
+
"data/guards": "registry.guards",
|
|
44
|
+
"api/interceptors": "registry.interceptors",
|
|
45
|
+
"commands/interceptors": "registry.command-interceptors",
|
|
46
|
+
"widgets/components": "registry.component-overrides",
|
|
47
|
+
"frontend/middleware": "registry.page-middleware",
|
|
48
|
+
"backend/middleware": "registry.page-middleware"
|
|
49
|
+
};
|
|
50
|
+
const COMMAND_SCAN_CONFIG = {
|
|
51
|
+
folder: "commands",
|
|
52
|
+
include: (name) => MODULE_CODE_EXTENSIONS.some((extension) => name.endsWith(extension)) && !name.endsWith(".d.ts") && !/\.(test|spec)\.[jt]sx?$/.test(name) && !["index", "shared", "factory"].includes(stripModuleCodeExtension(name))
|
|
53
|
+
};
|
|
54
|
+
const LEGACY_API_SCAN_CONFIGS = ["get", "post", "put", "patch", "delete"].map((method) => ({
|
|
55
|
+
folder: `api/${method}`,
|
|
56
|
+
include: (name) => /\.[jt]s$/.test(name) && !/\.(test|spec)\.[jt]s$/.test(name)
|
|
57
|
+
}));
|
|
61
58
|
function checksum(value) {
|
|
62
59
|
return crypto.createHash("md5").update(value).digest("hex");
|
|
63
60
|
}
|
|
64
|
-
function
|
|
65
|
-
return
|
|
66
|
-
roots.pkgBase.replace(/\\/g, "/"),
|
|
67
|
-
roots.appBase.replace(/\\/g, "/")
|
|
68
|
-
]);
|
|
61
|
+
function isMissing(error) {
|
|
62
|
+
return typeof error === "object" && error !== null && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
69
63
|
}
|
|
70
|
-
function
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
64
|
+
function unwrap(node) {
|
|
65
|
+
while (ts.isParenthesizedExpression(node) || ts.isAsExpression(node) || ts.isTypeAssertionExpression(node) || ts.isSatisfiesExpression(node)) node = node.expression;
|
|
66
|
+
return node;
|
|
67
|
+
}
|
|
68
|
+
function pluginConventions(file) {
|
|
69
|
+
const declarations = /* @__PURE__ */ new Map();
|
|
70
|
+
let exported;
|
|
71
|
+
for (const statement of file.statements) {
|
|
72
|
+
if (ts.isVariableStatement(statement)) {
|
|
73
|
+
for (const declaration of statement.declarationList.declarations) {
|
|
74
|
+
if (ts.isIdentifier(declaration.name) && declaration.initializer) {
|
|
75
|
+
declarations.set(declaration.name.text, declaration.initializer);
|
|
76
|
+
if (declaration.name.text === "generatorPlugins" && statement.modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword)) {
|
|
77
|
+
exported = declaration.initializer;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
} else if (ts.isExportAssignment(statement)) {
|
|
82
|
+
exported ??= statement.expression;
|
|
83
|
+
} else if (ts.isImportDeclaration(statement)) {
|
|
84
|
+
if (!statement.importClause?.isTypeOnly) return null;
|
|
85
|
+
} else if (!ts.isFunctionDeclaration(statement) && !ts.isInterfaceDeclaration(statement) && !ts.isTypeAliasDeclaration(statement) && !ts.isEmptyStatement(statement)) return null;
|
|
82
86
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
return
|
|
87
|
+
if (!exported) return null;
|
|
88
|
+
const resolve = (expression, seen = /* @__PURE__ */ new Set()) => {
|
|
89
|
+
const node = unwrap(expression);
|
|
90
|
+
if (!ts.isIdentifier(node)) return node;
|
|
91
|
+
if (seen.has(node.text)) return null;
|
|
92
|
+
seen.add(node.text);
|
|
93
|
+
const value = declarations.get(node.text);
|
|
94
|
+
return value ? resolve(value, seen) : null;
|
|
95
|
+
};
|
|
96
|
+
const plugins = resolve(exported);
|
|
97
|
+
if (!plugins || !ts.isArrayLiteralExpression(plugins)) return null;
|
|
98
|
+
const conventions = [];
|
|
99
|
+
for (const element of plugins.elements) {
|
|
100
|
+
const plugin = resolve(element);
|
|
101
|
+
if (!plugin || !ts.isObjectLiteralExpression(plugin)) return null;
|
|
102
|
+
let convention;
|
|
103
|
+
for (const property of plugin.properties) {
|
|
104
|
+
if (ts.isSpreadAssignment(property) || ts.isComputedPropertyName(property.name)) return null;
|
|
105
|
+
if (property.name.getText(file).replace(/^['"]|['"]$/g, "") !== "conventionFile") continue;
|
|
106
|
+
const value = ts.isPropertyAssignment(property) ? resolve(property.initializer) : null;
|
|
107
|
+
if (!value || !ts.isStringLiteralLike(value)) return null;
|
|
108
|
+
convention = value.text;
|
|
109
|
+
}
|
|
110
|
+
if (!convention) return null;
|
|
111
|
+
conventions.push(convention);
|
|
87
112
|
}
|
|
113
|
+
return conventions;
|
|
88
114
|
}
|
|
89
|
-
function
|
|
90
|
-
const
|
|
91
|
-
|
|
115
|
+
function pageFingerprint(parsed) {
|
|
116
|
+
const metadata = parsed.statements.some((statement) => {
|
|
117
|
+
if (ts.isExportDeclaration(statement)) {
|
|
118
|
+
return !statement.exportClause || ts.isNamedExports(statement.exportClause) && statement.exportClause.elements.some((element) => element.name.text === "metadata");
|
|
119
|
+
}
|
|
120
|
+
if (!ts.canHaveModifiers(statement) || !ts.getModifiers(statement)?.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword)) return false;
|
|
121
|
+
if (ts.isVariableStatement(statement)) {
|
|
122
|
+
return statement.declarationList.declarations.some((declaration) => /\bmetadata\b/.test(declaration.name.getText(parsed)));
|
|
123
|
+
}
|
|
124
|
+
return (ts.isFunctionDeclaration(statement) || ts.isClassDeclaration(statement)) && statement.name?.text === "metadata";
|
|
125
|
+
});
|
|
126
|
+
if (metadata) return null;
|
|
127
|
+
const hasDefault = parsed.statements.some(
|
|
128
|
+
(statement) => ts.isExportAssignment(statement) && !statement.isExportEquals || ts.canHaveModifiers(statement) && ts.getModifiers(statement)?.some((modifier) => modifier.kind === ts.SyntaxKind.DefaultKeyword) || ts.isExportDeclaration(statement) && statement.exportClause && ts.isNamedExports(statement.exportClause) && statement.exportClause.elements.some((element) => element.name.text === "default")
|
|
129
|
+
);
|
|
130
|
+
return `page:default:${hasDefault}`;
|
|
92
131
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if (
|
|
99
|
-
|
|
100
|
-
|
|
132
|
+
const SUPERVISOR_OVERRIDE_CALLS = ["applyWorkerOverrides", "applyCliOverrides"];
|
|
133
|
+
function declaresSupervisorOverride(parsed) {
|
|
134
|
+
const direct = /* @__PURE__ */ new Set();
|
|
135
|
+
const namespaces = /* @__PURE__ */ new Set();
|
|
136
|
+
for (const statement of parsed.statements) {
|
|
137
|
+
if (!ts.isImportDeclaration(statement) || !ts.isStringLiteralLike(statement.moduleSpecifier) || statement.moduleSpecifier.text !== "@open-mercato/shared/modules/overrides") continue;
|
|
138
|
+
const bindings = statement.importClause?.namedBindings;
|
|
139
|
+
if (bindings && ts.isNamespaceImport(bindings)) namespaces.add(bindings.name.text);
|
|
140
|
+
if (bindings && ts.isNamedImports(bindings)) {
|
|
141
|
+
for (const element of bindings.elements) {
|
|
142
|
+
if (SUPERVISOR_OVERRIDE_CALLS.includes(element.propertyName?.text ?? element.name.text)) direct.add(element.name.text);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
let found = false;
|
|
147
|
+
const visit = (node) => {
|
|
148
|
+
if (ts.isCallExpression(node)) {
|
|
149
|
+
const expression = node.expression;
|
|
150
|
+
if (ts.isIdentifier(expression) && direct.has(expression.text)) found = true;
|
|
151
|
+
if (ts.isPropertyAccessExpression(expression) && ts.isIdentifier(expression.expression) && namespaces.has(expression.expression.text) && SUPERVISOR_OVERRIDE_CALLS.includes(expression.name.text)) found = true;
|
|
152
|
+
}
|
|
153
|
+
if (!found) ts.forEachChild(node, visit);
|
|
154
|
+
};
|
|
155
|
+
visit(parsed);
|
|
156
|
+
return found;
|
|
101
157
|
}
|
|
102
|
-
function
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
158
|
+
function staticImports(parsed) {
|
|
159
|
+
const specifiers = [];
|
|
160
|
+
let uncertain = false;
|
|
161
|
+
const visit = (node) => {
|
|
162
|
+
if (ts.isFunctionLike(node)) return;
|
|
163
|
+
if (ts.isImportDeclaration(node)) {
|
|
164
|
+
if (node.importClause?.isTypeOnly) return;
|
|
165
|
+
const bindings = node.importClause?.namedBindings;
|
|
166
|
+
if (!node.importClause?.name && bindings && ts.isNamedImports(bindings) && bindings.elements.length > 0 && bindings.elements.every((element) => element.isTypeOnly)) return;
|
|
167
|
+
if (ts.isStringLiteralLike(node.moduleSpecifier)) specifiers.push(node.moduleSpecifier.text);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
if (ts.isExportDeclaration(node) && !node.isTypeOnly && node.moduleSpecifier && ts.isStringLiteralLike(node.moduleSpecifier)) specifiers.push(node.moduleSpecifier.text);
|
|
171
|
+
if (ts.isCallExpression(node) && (node.expression.kind === ts.SyntaxKind.ImportKeyword || ts.isIdentifier(node.expression) && node.expression.text === "require")) {
|
|
172
|
+
const argument = node.arguments[0];
|
|
173
|
+
if (argument && ts.isStringLiteralLike(argument)) specifiers.push(argument.text);
|
|
174
|
+
else uncertain = true;
|
|
175
|
+
}
|
|
176
|
+
ts.forEachChild(node, visit);
|
|
177
|
+
};
|
|
178
|
+
visit(parsed);
|
|
179
|
+
return { specifiers, uncertain };
|
|
106
180
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
181
|
+
class SnapshotCollector {
|
|
182
|
+
constructor(cache) {
|
|
183
|
+
this.cache = cache;
|
|
184
|
+
this.records = /* @__PURE__ */ new Map();
|
|
185
|
+
this.fullReasons = /* @__PURE__ */ new Set();
|
|
186
|
+
this.stats = /* @__PURE__ */ new Map();
|
|
187
|
+
this.identities = /* @__PURE__ */ new Map();
|
|
188
|
+
this.uncertainDependencies = /* @__PURE__ */ new Set();
|
|
189
|
+
this.uncertainPluginDescriptors = /* @__PURE__ */ new Set();
|
|
190
|
+
this.dependencySeeds = /* @__PURE__ */ new Map();
|
|
191
|
+
this.inspectedCachePaths = /* @__PURE__ */ new Set();
|
|
192
|
+
this.sources = /* @__PURE__ */ new Map();
|
|
193
|
+
this.parsedFiles = /* @__PURE__ */ new Map();
|
|
113
194
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
for (const base of [roots.pkgBase, roots.appBase]) {
|
|
118
|
-
records.push(`module-root:${base}:${fs.existsSync(base) ? "present" : "missing"}`);
|
|
119
|
-
}
|
|
120
|
-
if (packageSourceBase !== roots.pkgBase) {
|
|
121
|
-
records.push(
|
|
122
|
-
`module-root:${packageSourceBase}:${fs.existsSync(packageSourceBase) ? "present" : "missing"}`
|
|
123
|
-
);
|
|
195
|
+
identity(file) {
|
|
196
|
+
if (!this.identities.has(file)) this.stat(file);
|
|
197
|
+
return this.identities.get(file) ?? null;
|
|
124
198
|
}
|
|
125
|
-
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
if (
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
199
|
+
seedDependency(file, kind) {
|
|
200
|
+
const identity = `${kind.category}:${kind.extensionId ?? ""}`;
|
|
201
|
+
const kinds = this.dependencySeeds.get(file) ?? /* @__PURE__ */ new Map();
|
|
202
|
+
kinds.set(identity, kind);
|
|
203
|
+
this.dependencySeeds.set(file, kinds);
|
|
204
|
+
}
|
|
205
|
+
stat(file) {
|
|
206
|
+
if (this.stats.has(file)) return this.stats.get(file) ?? null;
|
|
207
|
+
try {
|
|
208
|
+
const stat = fs.statSync(file);
|
|
209
|
+
const identity = [stat.dev, stat.ino, stat.size, stat.mtimeMs, stat.ctimeMs].join(":");
|
|
210
|
+
this.stats.set(file, stat);
|
|
211
|
+
this.identities.set(file, identity);
|
|
212
|
+
return stat;
|
|
213
|
+
} catch (error) {
|
|
214
|
+
if (!isMissing(error)) this.fullReasons.add(`Cannot inspect generator input: ${file}`);
|
|
215
|
+
this.stats.set(file, null);
|
|
216
|
+
this.identities.set(file, null);
|
|
217
|
+
return null;
|
|
140
218
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
219
|
+
}
|
|
220
|
+
/** Stat-keyed cache entry for a readable file; unchanged identities are never re-read. */
|
|
221
|
+
entry(file) {
|
|
222
|
+
const stat = this.stat(file);
|
|
223
|
+
const identity = this.identity(file);
|
|
224
|
+
if (!stat?.isFile() || !identity) {
|
|
225
|
+
this.fullReasons.add(`Cannot read generator input: ${file}`);
|
|
226
|
+
return null;
|
|
148
227
|
}
|
|
228
|
+
this.inspectedCachePaths.add(file);
|
|
229
|
+
const cached = this.cache.files.get(file);
|
|
230
|
+
if (cached?.identity === identity) return cached;
|
|
231
|
+
const source = this.readSource(file);
|
|
232
|
+
if (source === null) return null;
|
|
233
|
+
const entry = { identity, fingerprint: checksum(source) };
|
|
234
|
+
this.cache.files.set(file, entry);
|
|
235
|
+
return entry;
|
|
149
236
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
237
|
+
readSource(file) {
|
|
238
|
+
const known = this.sources.get(file);
|
|
239
|
+
if (known !== void 0) return known;
|
|
240
|
+
try {
|
|
241
|
+
const source = fs.readFileSync(file, "utf8");
|
|
242
|
+
this.sources.set(file, source);
|
|
243
|
+
return source;
|
|
244
|
+
} catch {
|
|
245
|
+
this.fullReasons.add(`Cannot read generator input: ${file}`);
|
|
246
|
+
return null;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
/** Capture-local AST for a file whose cached facts are missing; parse failures are cached per identity. */
|
|
250
|
+
parsed(file, entry) {
|
|
251
|
+
if (entry.parseFailed) {
|
|
252
|
+
this.fullReasons.add(`Cannot parse generator input: ${file}`);
|
|
253
|
+
return null;
|
|
254
|
+
}
|
|
255
|
+
const known = this.parsedFiles.get(file);
|
|
256
|
+
if (known) return known;
|
|
257
|
+
const source = this.readSource(file);
|
|
258
|
+
if (source === null) return null;
|
|
259
|
+
let parsed;
|
|
260
|
+
try {
|
|
261
|
+
parsed = ts.createSourceFile(file, source, ts.ScriptTarget.Latest, true);
|
|
262
|
+
} catch {
|
|
263
|
+
this.fullReasons.add(`Cannot parse generator input: ${file}`);
|
|
264
|
+
return null;
|
|
265
|
+
}
|
|
266
|
+
const diagnostics = parsed.parseDiagnostics;
|
|
267
|
+
if (diagnostics?.length) {
|
|
268
|
+
entry.parseFailed = true;
|
|
269
|
+
this.fullReasons.add(`Cannot parse generator input: ${file}`);
|
|
270
|
+
return null;
|
|
271
|
+
}
|
|
272
|
+
this.parsedFiles.set(file, parsed);
|
|
273
|
+
return parsed;
|
|
274
|
+
}
|
|
275
|
+
record(key, file, kind, fingerprint) {
|
|
276
|
+
this.records.set(key, { key, path: file, ...kind, fingerprint });
|
|
277
|
+
}
|
|
278
|
+
file(key, file, kind, mode = "content") {
|
|
279
|
+
if (!this.stat(file)?.isFile()) return;
|
|
280
|
+
if (mode === "membership") {
|
|
281
|
+
this.record(key, file, kind, "present");
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
if (mode === "stat") {
|
|
285
|
+
this.record(key, file, kind, this.identity(file) ?? "present");
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
const entry = this.entry(file);
|
|
289
|
+
if (!entry) {
|
|
290
|
+
this.record(key, file, kind, "unreadable");
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
if (mode === "page") {
|
|
294
|
+
if (entry.pageFingerprint === void 0) {
|
|
295
|
+
const parsed = this.parsed(file, entry);
|
|
296
|
+
if (!parsed) {
|
|
297
|
+
this.record(key, file, kind, "unparseable");
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
entry.pageFingerprint = pageFingerprint(parsed);
|
|
160
301
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
302
|
+
if (entry.pageFingerprint !== null) {
|
|
303
|
+
this.record(key, file, kind, entry.pageFingerprint);
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
this.record(key, file, kind, entry.fingerprint);
|
|
308
|
+
if (/\.[cm]?[jt]sx?$/.test(file)) this.seedDependency(file, kind);
|
|
309
|
+
}
|
|
310
|
+
codeFile(base, relativePath) {
|
|
311
|
+
const stripped = stripModuleCodeExtension(relativePath);
|
|
312
|
+
const candidates = [relativePath, ...MODULE_CODE_EXTENSIONS.map((extension) => `${stripped}${extension}`)];
|
|
313
|
+
for (const candidate of candidates) {
|
|
314
|
+
const file = path.join(base, candidate);
|
|
315
|
+
if (this.stat(file)?.isFile()) return file;
|
|
316
|
+
}
|
|
317
|
+
return null;
|
|
318
|
+
}
|
|
319
|
+
scan(roots, config) {
|
|
320
|
+
try {
|
|
321
|
+
return scanModuleDir(roots, config);
|
|
322
|
+
} catch {
|
|
323
|
+
this.fullReasons.add(`Cannot scan generator inputs: ${roots.appBase}, ${roots.pkgBase}/${config.folder}`);
|
|
324
|
+
return [];
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
entries(directory) {
|
|
328
|
+
if (!this.stat(directory)?.isDirectory()) return [];
|
|
329
|
+
try {
|
|
330
|
+
return fs.readdirSync(directory, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name));
|
|
331
|
+
} catch {
|
|
332
|
+
this.fullReasons.add(`Cannot scan generator inputs: ${directory}`);
|
|
333
|
+
return [];
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
pair(identity, roots, relativePath, kind, mode = "content") {
|
|
337
|
+
const sourceBase = resolveStandaloneSourceMirrorBase(roots.pkgBase) ?? roots.pkgBase;
|
|
338
|
+
const app = this.codeFile(roots.appBase, relativePath);
|
|
339
|
+
const source = app ?? this.codeFile(sourceBase, relativePath);
|
|
340
|
+
const runtime = !app && sourceBase !== roots.pkgBase ? this.codeFile(roots.pkgBase, stripModuleCodeExtension(relativePath)) : source;
|
|
341
|
+
const primary = source ?? runtime;
|
|
342
|
+
if (!primary) return [];
|
|
343
|
+
const logical = stripModuleCodeExtension(relativePath).replace(/\\/g, "/");
|
|
344
|
+
const key = `${identity}:${kind.category}:${kind.extensionId ?? ""}:${logical}`;
|
|
345
|
+
if (source) this.file(`${key}:source`, source, kind, mode);
|
|
346
|
+
if (runtime && runtime !== source) this.file(`${key}:runtime`, runtime, kind, mode);
|
|
347
|
+
this.record(`${key}:authority`, primary, kind, JSON.stringify([source, runtime]));
|
|
348
|
+
return source && runtime && runtime !== source ? [source, runtime] : [primary];
|
|
349
|
+
}
|
|
350
|
+
tree(identity, directory, kind, skipTests = true) {
|
|
351
|
+
for (const entry of this.entries(directory)) {
|
|
352
|
+
if (skipTests && (entry.name === "__tests__" || entry.name === "__mocks__")) continue;
|
|
353
|
+
const file = path.join(directory, entry.name);
|
|
354
|
+
if (entry.isDirectory()) this.tree(identity, file, kind, skipTests);
|
|
355
|
+
else if (entry.isFile()) this.file(`${identity}:${file}`, file, kind);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
supervisor(appSource) {
|
|
359
|
+
const pending = [appSource];
|
|
360
|
+
let found = false;
|
|
361
|
+
while (pending.length > 0 && !found) {
|
|
362
|
+
const directory = pending.pop();
|
|
363
|
+
for (const entry of this.entries(directory)) {
|
|
364
|
+
const file = path.join(directory, entry.name);
|
|
365
|
+
if (entry.isDirectory()) {
|
|
366
|
+
if (entry.name !== "__tests__" && entry.name !== "node_modules") pending.push(file);
|
|
367
|
+
continue;
|
|
368
|
+
}
|
|
369
|
+
if (!/\.[cm]?tsx?$/.test(entry.name) || /(?:^|\.)test\.[cm]?tsx?$/.test(entry.name)) continue;
|
|
370
|
+
const cached = this.entry(file);
|
|
371
|
+
if (!cached) continue;
|
|
372
|
+
if (cached.supervisorOverride === void 0) {
|
|
373
|
+
if (!this.readSource(file)?.includes("@open-mercato/shared/modules/overrides")) {
|
|
374
|
+
cached.supervisorOverride = false;
|
|
375
|
+
continue;
|
|
376
|
+
}
|
|
377
|
+
const parsed = this.parsed(file, cached);
|
|
378
|
+
if (!parsed) continue;
|
|
379
|
+
cached.supervisorOverride = declaresSupervisorOverride(parsed);
|
|
380
|
+
}
|
|
381
|
+
if (cached.supervisorOverride) {
|
|
382
|
+
found = true;
|
|
383
|
+
break;
|
|
174
384
|
}
|
|
175
385
|
}
|
|
176
386
|
}
|
|
387
|
+
this.record("supervisor-overrides", appSource, { category: "registry-convention", extensionId: "supervisor" }, String(found));
|
|
177
388
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
if (
|
|
185
|
-
|
|
389
|
+
dependencies(appSource) {
|
|
390
|
+
const visited = /* @__PURE__ */ new Set();
|
|
391
|
+
const pending = [...this.dependencySeeds].flatMap(([file, kinds]) => [...kinds.entries()].map(([identity, kind]) => ({ file, identity, kind }))).sort((left, right) => right.file.localeCompare(left.file) || right.identity.localeCompare(left.identity));
|
|
392
|
+
while (pending.length > 0) {
|
|
393
|
+
const { file, identity, kind } = pending.pop();
|
|
394
|
+
const visitKey = `${identity}:${file}`;
|
|
395
|
+
if (visited.has(visitKey)) continue;
|
|
396
|
+
visited.add(visitKey);
|
|
397
|
+
const cached = this.entry(file);
|
|
398
|
+
if (!cached) continue;
|
|
399
|
+
if (!cached.imports) {
|
|
400
|
+
const parsed = this.parsed(file, cached);
|
|
401
|
+
if (!parsed) continue;
|
|
402
|
+
cached.imports = staticImports(parsed);
|
|
186
403
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
if (runtimeFile) {
|
|
198
|
-
addFileRecord(
|
|
199
|
-
records,
|
|
200
|
-
`${config.folder}:package-runtime`,
|
|
201
|
-
runtimeFile,
|
|
202
|
-
roots.pkgBase,
|
|
203
|
-
hasInlinePageMetadata(runtimeFile) ? "content" : "shape"
|
|
204
|
-
);
|
|
205
|
-
} else {
|
|
206
|
-
records.push(`${config.folder}:package-runtime:missing:${scanned.relPath}`);
|
|
404
|
+
if (cached.imports.uncertain) this.uncertainDependencies.add(file);
|
|
405
|
+
const imports = cached.imports.specifiers;
|
|
406
|
+
for (const specifier of imports) {
|
|
407
|
+
if (!specifier.startsWith(".") && !specifier.startsWith("@/")) continue;
|
|
408
|
+
const target = specifier.startsWith("@/") ? path.join(appSource, specifier.slice(2)) : path.resolve(path.dirname(file), specifier);
|
|
409
|
+
const resolved = this.codeFile(path.dirname(target), path.basename(target)) ?? this.codeFile(target, "index");
|
|
410
|
+
const dependencyKey = `dependency:${identity}:${file}:${target}`;
|
|
411
|
+
if (!resolved) {
|
|
412
|
+
this.record(dependencyKey, target, kind, "missing");
|
|
413
|
+
continue;
|
|
207
414
|
}
|
|
415
|
+
if (resolved.includes(`${path.sep}.mercato${path.sep}`) || resolved.includes(`${path.sep}generated${path.sep}`)) continue;
|
|
416
|
+
const fingerprint = this.entry(resolved)?.fingerprint ?? "unreadable";
|
|
417
|
+
this.record(dependencyKey, resolved, kind, `${resolved}:${fingerprint}`);
|
|
418
|
+
if (/\.[cm]?[jt]sx?$/.test(resolved)) pending.push({ file: resolved, identity, kind });
|
|
208
419
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
function addModule(collector, roots, index, plugins) {
|
|
424
|
+
const distMarker = `${path.sep}dist${path.sep}modules${path.sep}`;
|
|
425
|
+
const distIndex = roots.pkgBase.lastIndexOf(distMarker);
|
|
426
|
+
if (distIndex >= 0) {
|
|
427
|
+
const packageRoot = roots.pkgBase.slice(0, distIndex);
|
|
428
|
+
collector.stat(path.join(packageRoot, "src", "modules", roots.pkgBase.slice(distIndex + distMarker.length)));
|
|
429
|
+
}
|
|
430
|
+
const sourceBase = resolveStandaloneSourceMirrorBase(roots.pkgBase) ?? roots.pkgBase;
|
|
431
|
+
const identity = `module:${index}:${roots.moduleId ?? path.basename(roots.appBase)}:${roots.appBase}:${roots.pkgBase}`;
|
|
432
|
+
collector.record(`${identity}:roots`, roots.appBase, { category: "configuration" }, JSON.stringify([
|
|
433
|
+
Object.entries(roots).sort(([left], [right]) => left.localeCompare(right)),
|
|
434
|
+
sourceBase,
|
|
435
|
+
collector.stat(roots.appBase)?.isDirectory() ?? false,
|
|
436
|
+
collector.stat(roots.pkgBase)?.isDirectory() ?? false
|
|
437
|
+
]));
|
|
438
|
+
const convention = (relativePath, kind) => collector.pair(identity, roots, `${relativePath}.ts`, kind);
|
|
439
|
+
for (const relativePath of REGISTRY_CONVENTIONS) convention(relativePath, { category: "registry-convention" });
|
|
440
|
+
convention("form-sections", { category: "configuration" });
|
|
441
|
+
for (const [relativePath, extensionId] of Object.entries(EXTENSION_CONVENTIONS)) {
|
|
442
|
+
convention(relativePath, { category: "extension", extensionId });
|
|
443
|
+
}
|
|
444
|
+
collector.pair(identity, roots, "widgets/payments/client.tsx", { category: "extension", extensionId: "registry.notifications" });
|
|
445
|
+
for (const category of ["cli", "di", "search", "events"]) convention(category, { category });
|
|
446
|
+
convention("widgets/injection-table", { category: "injection-widgets" });
|
|
447
|
+
for (const descriptor of convention("generators", { category: "generator-plugin" })) {
|
|
448
|
+
const cached = collector.entry(descriptor);
|
|
449
|
+
if (cached && cached.pluginConventions === void 0) {
|
|
450
|
+
const parsed = collector.parsed(descriptor, cached);
|
|
451
|
+
if (parsed) cached.pluginConventions = pluginConventions(parsed);
|
|
452
|
+
}
|
|
453
|
+
const discovered = cached?.pluginConventions ?? null;
|
|
454
|
+
if (discovered === null) collector.uncertainPluginDescriptors.add(descriptor);
|
|
455
|
+
else for (const file of discovered) plugins.add(file);
|
|
456
|
+
}
|
|
457
|
+
for (const base of /* @__PURE__ */ new Set([roots.appBase, roots.pkgBase, sourceBase])) {
|
|
458
|
+
for (const directory of ["data", "db"]) {
|
|
459
|
+
for (const stem of ["entities.override", "entities", "schema"]) {
|
|
460
|
+
for (const extension of MODULE_CODE_EXTENSIONS) {
|
|
461
|
+
const file = path.join(base, directory, `${stem}${extension}`);
|
|
462
|
+
collector.file(`${identity}:entities:${file}`, file, { category: "entities" });
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
if (distIndex >= 0) {
|
|
468
|
+
const packageRoot = roots.pkgBase.slice(0, distIndex);
|
|
469
|
+
const direct = path.join(packageRoot, "generated");
|
|
470
|
+
collector.record(
|
|
471
|
+
`${identity}:package-entities-direct-root`,
|
|
472
|
+
direct,
|
|
473
|
+
{ category: "entities" },
|
|
474
|
+
collector.stat(direct)?.isDirectory() ? "directory" : "missing"
|
|
475
|
+
);
|
|
476
|
+
const generated = collector.stat(direct)?.isDirectory() ? direct : path.join(packageRoot, "dist", "generated");
|
|
477
|
+
collector.record(`${identity}:package-entities-root`, generated, { category: "entities" }, generated);
|
|
478
|
+
for (const extension of [".ts", ".js"]) {
|
|
479
|
+
const ids = path.join(generated, `entities.ids.generated${extension}`);
|
|
480
|
+
collector.file(`${identity}:package-entities:${ids}`, ids, { category: "entities" });
|
|
481
|
+
for (const entry of collector.entries(path.join(generated, "entities"))) {
|
|
482
|
+
if (!entry.isDirectory()) continue;
|
|
483
|
+
const fields = path.join(generated, "entities", entry.name, `index${extension}`);
|
|
484
|
+
collector.file(`${identity}:package-entities:${fields}`, fields, { category: "entities" });
|
|
215
485
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
const scans = [
|
|
489
|
+
[SCAN_CONFIGS.apiRoutes, "api-route"],
|
|
490
|
+
[SCAN_CONFIGS.apiPlainFiles, "api-route"],
|
|
491
|
+
...LEGACY_API_SCAN_CONFIGS.map((config) => [config, "api-route"]),
|
|
492
|
+
[COMMAND_SCAN_CONFIG, "commands"],
|
|
493
|
+
[SCAN_CONFIGS.subscribers, "subscribers"],
|
|
494
|
+
[SCAN_CONFIGS.workers, "workers"],
|
|
495
|
+
[SCAN_CONFIGS.dashboardWidgets, "dashboard-widgets"],
|
|
496
|
+
[SCAN_CONFIGS.injectionWidgets, "injection-widgets"],
|
|
497
|
+
[SCAN_CONFIGS.frontendPages, "frontend-page"],
|
|
498
|
+
[SCAN_CONFIGS.backendPages, "backend-page"]
|
|
499
|
+
];
|
|
500
|
+
for (const [config, category] of scans) {
|
|
501
|
+
for (const scanned of collector.scan(roots, config)) {
|
|
502
|
+
const relativePath = `${config.folder}/${scanned.relPath}`;
|
|
503
|
+
if (EXTENSION_CONVENTIONS[stripModuleCodeExtension(relativePath)]) continue;
|
|
504
|
+
const page = category === "frontend-page" || category === "backend-page";
|
|
505
|
+
const files = collector.pair(identity, roots, relativePath, { category }, page ? "page" : "content");
|
|
506
|
+
if (!page) continue;
|
|
507
|
+
for (const file of files) {
|
|
508
|
+
const stem = stripModuleCodeExtension(path.basename(file));
|
|
509
|
+
for (const candidate of [stem === "page" ? "page.meta" : `${stem}.meta`, "meta"]) {
|
|
510
|
+
const metadata = collector.codeFile(path.dirname(file), candidate);
|
|
511
|
+
if (metadata) collector.file(`${identity}:${category}:metadata:${metadata}`, metadata, { category });
|
|
227
512
|
}
|
|
228
513
|
}
|
|
229
514
|
}
|
|
230
515
|
}
|
|
516
|
+
for (const base of /* @__PURE__ */ new Set([sourceBase, roots.appBase])) {
|
|
517
|
+
const directory = path.join(base, "i18n");
|
|
518
|
+
for (const entry of collector.entries(directory)) {
|
|
519
|
+
if (!entry.isFile() || !/^[a-zA-Z0-9][a-zA-Z0-9_-]*\.json$/.test(entry.name)) continue;
|
|
520
|
+
const file = path.join(directory, entry.name);
|
|
521
|
+
collector.file(`${identity}:i18n:${file}`, file, { category: "i18n" }, "membership");
|
|
522
|
+
if (base === sourceBase && sourceBase !== roots.pkgBase) {
|
|
523
|
+
const runtime = path.join(roots.pkgBase, "i18n", entry.name);
|
|
524
|
+
collector.file(`${identity}:i18n:runtime:${runtime}`, runtime, { category: "i18n" }, "membership");
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
collector.tree(`${identity}:agents`, path.join(base, "agents"), { category: "extension", extensionId: "registry.agent-files" });
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
function collectGenerateWatchStructureSnapshot(options, cache) {
|
|
531
|
+
const cacheState = cache ? cacheStates.get(cache) : { files: /* @__PURE__ */ new Map() };
|
|
532
|
+
if (!cacheState) throw new TypeError("Invalid generate watch structure cache");
|
|
533
|
+
const collector = new SnapshotCollector(cacheState);
|
|
534
|
+
for (const reason of options.webResearchAdapterFullReasons ?? []) collector.fullReasons.add(reason);
|
|
535
|
+
collector.file(`configuration:${options.modulesFile}`, options.modulesFile, { category: "configuration" });
|
|
536
|
+
const plugins = /* @__PURE__ */ new Set();
|
|
537
|
+
options.moduleRoots.forEach((roots, index) => addModule(collector, roots, index, plugins));
|
|
538
|
+
options.moduleRoots.forEach((roots, index) => {
|
|
539
|
+
const identity = `module:${index}:${roots.moduleId ?? path.basename(roots.appBase)}:${roots.appBase}:${roots.pkgBase}`;
|
|
540
|
+
for (const relativePath of plugins) collector.pair(identity, roots, relativePath, { category: "generator-plugin" });
|
|
541
|
+
});
|
|
542
|
+
const knownInputs = /* @__PURE__ */ new Map();
|
|
543
|
+
for (const record of collector.records.values()) {
|
|
544
|
+
if (record.category !== "configuration") knownInputs.set(record.path, record);
|
|
545
|
+
}
|
|
546
|
+
const ordered = (inputs) => [...new Set(inputs ?? [])].sort((left, right) => left < right ? -1 : left > right ? 1 : 0);
|
|
547
|
+
for (const input of ordered(options.additionalInputs)) {
|
|
548
|
+
if (knownInputs.has(input)) continue;
|
|
549
|
+
const stat = collector.stat(input);
|
|
550
|
+
if (stat?.isFile()) collector.file(`configuration:${input}`, input, { category: "configuration" });
|
|
551
|
+
else collector.record(`configuration:${input}`, input, { category: "configuration" }, stat?.isDirectory() ? "directory" : "missing");
|
|
552
|
+
}
|
|
553
|
+
const addSpecializedInputs = (inputs, kind, keyPrefix, mode = "content") => {
|
|
554
|
+
for (const input of ordered(inputs)) {
|
|
555
|
+
const stat = collector.stat(input);
|
|
556
|
+
if (stat?.isFile()) collector.file(`${keyPrefix}:${input}`, input, kind, mode);
|
|
557
|
+
else collector.record(`${keyPrefix}:${input}`, input, kind, stat?.isDirectory() ? "directory" : "missing");
|
|
558
|
+
}
|
|
559
|
+
};
|
|
560
|
+
addSpecializedInputs(options.openapiInputs, { category: "openapi" }, "openapi-input");
|
|
561
|
+
addSpecializedInputs(
|
|
562
|
+
options.webResearchAdapterInputs,
|
|
563
|
+
{ category: "web-research-adapters" },
|
|
564
|
+
"web-research-adapter-input",
|
|
565
|
+
"stat"
|
|
566
|
+
);
|
|
567
|
+
addSpecializedInputs(options.cacheProviderInputs, { category: "cache-providers" }, "cache-provider-input", "membership");
|
|
568
|
+
collector.supervisor(path.dirname(options.modulesFile));
|
|
569
|
+
collector.dependencies(path.dirname(options.modulesFile));
|
|
570
|
+
if (collector.uncertainPluginDescriptors.size > 0 || collector.uncertainDependencies.size > 0) {
|
|
571
|
+
const category = collector.uncertainPluginDescriptors.size > 0 ? "generator-plugin" : "unknown";
|
|
572
|
+
for (const roots of options.moduleRoots) {
|
|
573
|
+
for (const base of /* @__PURE__ */ new Set([roots.appBase, roots.pkgBase, resolveStandaloneSourceMirrorBase(roots.pkgBase)])) {
|
|
574
|
+
if (base) collector.tree(`uncertain-dependencies:${base}`, base, { category }, false);
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
for (const descriptor of collector.uncertainPluginDescriptors) {
|
|
578
|
+
collector.record(`uncertain-plugin:${descriptor}`, descriptor, { category: "generator-plugin" }, "unresolved-conventions");
|
|
579
|
+
}
|
|
580
|
+
for (const dependency of collector.uncertainDependencies) {
|
|
581
|
+
collector.record(`uncertain-dependency:${dependency}`, dependency, { category: "unknown" }, "unresolved-import");
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
const records = new Map([...collector.records].sort(([left], [right]) => left.localeCompare(right)));
|
|
585
|
+
const fullReasons = [...collector.fullReasons].sort((left, right) => left < right ? -1 : left > right ? 1 : 0);
|
|
586
|
+
if (fullReasons.length === 0) {
|
|
587
|
+
for (const cachedPath of cacheState.files.keys()) {
|
|
588
|
+
if (!collector.inspectedCachePaths.has(cachedPath)) cacheState.files.delete(cachedPath);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
return {
|
|
592
|
+
checksum: checksum(JSON.stringify([[...records.values()], fullReasons])),
|
|
593
|
+
records,
|
|
594
|
+
fullReasons
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
function diffGenerateWatchStructureSnapshots(previous, next) {
|
|
598
|
+
const changes = [];
|
|
599
|
+
for (const key of [.../* @__PURE__ */ new Set([...previous.records.keys(), ...next.records.keys()])].sort((left, right) => left < right ? -1 : left > right ? 1 : 0)) {
|
|
600
|
+
const before = previous.records.get(key);
|
|
601
|
+
const after = next.records.get(key);
|
|
602
|
+
if (before && after && before.fingerprint === after.fingerprint && before.path === after.path && before.category === after.category && before.extensionId === after.extensionId) continue;
|
|
603
|
+
const record = after ?? before;
|
|
604
|
+
changes.push({
|
|
605
|
+
key,
|
|
606
|
+
kind: !before ? "add" : !after ? "delete" : "change",
|
|
607
|
+
category: record.category,
|
|
608
|
+
path: record.path,
|
|
609
|
+
...record.extensionId ? { extensionId: record.extensionId } : {}
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
return changes;
|
|
231
613
|
}
|
|
232
614
|
function calculateGenerateWatchStructureChecksum(options) {
|
|
233
|
-
|
|
234
|
-
const modulesRecord = fileRecord(options.modulesFile, path.dirname(options.modulesFile), "content");
|
|
235
|
-
records.push(modulesRecord ?? `missing:${options.modulesFile}`);
|
|
236
|
-
for (const roots of options.moduleRoots) {
|
|
237
|
-
const moduleRecords = [];
|
|
238
|
-
addConventionRecords(moduleRecords, roots);
|
|
239
|
-
addScannedRecords(moduleRecords, roots);
|
|
240
|
-
const rootIdentity = moduleRootIdentity(roots);
|
|
241
|
-
records.push(...moduleRecords.map((record) => `${rootIdentity}:${record}`));
|
|
242
|
-
}
|
|
243
|
-
return checksum(records.sort((a, b) => a.localeCompare(b)).join("\n"));
|
|
615
|
+
return collectGenerateWatchStructureSnapshot(options).checksum;
|
|
244
616
|
}
|
|
245
617
|
export {
|
|
246
|
-
calculateGenerateWatchStructureChecksum
|
|
618
|
+
calculateGenerateWatchStructureChecksum,
|
|
619
|
+
collectGenerateWatchStructureSnapshot,
|
|
620
|
+
createGenerateWatchStructureCache,
|
|
621
|
+
diffGenerateWatchStructureSnapshots
|
|
247
622
|
};
|
|
248
623
|
//# sourceMappingURL=generate-watch-structure.js.map
|