trustbase-seller-backend 0.1.5
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/.agents/skills/wechatpay-payment-integration/SKILL.md +165 -0
- package/.agents/skills/wechatpay-payment-integration/references/APIv3/346/216/245/345/217/243/345/212/250/346/200/201/346/216/222/351/232/234.md +234 -0
- package/.agents/skills/wechatpay-payment-integration/references/wechatpay-dev-cli/344/275/277/347/224/250/350/257/264/346/230/216.md +74 -0
- package/.agents/skills/wechatpay-payment-integration/references//345/237/272/347/241/200/346/246/202/345/277/265/345/217/212/344/270/232/345/212/241/344/273/213/347/273/215.md +109 -0
- package/.agents/skills/wechatpay-payment-integration/references//345/246/202/344/275/225/347/220/206/350/247/243/347/224/250/346/210/267/351/227/256/351/242/230.md +55 -0
- package/.agents/skills/wechatpay-payment-integration/references//346/216/245/345/205/245/350/264/250/351/207/217/346/243/200/346/237/245/346/270/205/345/215/225.md +70 -0
- package/.agents/skills/wechatpay-payment-integration/references//346/226/207/346/241/243/346/243/200/347/264/242/344/270/216/351/227/256/347/255/224.md +99 -0
- package/.agents/skills/wechatpay-payment-integration/scripts/bash/extract_and_sign.sh +231 -0
- package/.agents/skills/wechatpay-payment-integration/scripts/powershell/extract_and_sign.ps1 +199 -0
- package/.agents/skills/wechatpay-payment-integration/scripts/wechatpay-resource-sync.py +646 -0
- package/.env.example +70 -0
- package/MERCHANT-EDITION.md +56 -0
- package/README.md +99 -0
- package/api/__tests__/test-utils.d.ts +33 -0
- package/api/__tests__/test-utils.d.ts.map +1 -0
- package/api/__tests__/test-utils.js +90 -0
- package/api/__tests__/test-utils.js.map +1 -0
- package/api/db/case-library-types.d.ts +47 -0
- package/api/db/case-library-types.d.ts.map +1 -0
- package/api/db/case-library-types.js +105 -0
- package/api/db/case-library-types.js.map +1 -0
- package/api/db/case-library.db.d.ts +5 -0
- package/api/db/case-library.db.d.ts.map +1 -0
- package/api/db/case-library.db.js +127 -0
- package/api/db/case-library.db.js.map +1 -0
- package/api/email.d.ts +56 -0
- package/api/email.d.ts.map +1 -0
- package/api/email.js +307 -0
- package/api/email.js.map +1 -0
- package/api/index.d.ts +22 -0
- package/api/index.d.ts.map +1 -0
- package/api/index.js +41 -0
- package/api/index.js.map +1 -0
- package/api/integration-helpers.d.ts +153 -0
- package/api/integration-helpers.d.ts.map +1 -0
- package/api/integration-helpers.js +361 -0
- package/api/integration-helpers.js.map +1 -0
- package/api/lib/case-summary.d.ts +10 -0
- package/api/lib/case-summary.d.ts.map +1 -0
- package/api/lib/case-summary.js +30 -0
- package/api/lib/case-summary.js.map +1 -0
- package/api/middleware/p2p-auth.d.ts +140 -0
- package/api/middleware/p2p-auth.d.ts.map +1 -0
- package/api/middleware/p2p-auth.js +510 -0
- package/api/middleware/p2p-auth.js.map +1 -0
- package/api/middleware/tool-policy.d.ts +47 -0
- package/api/middleware/tool-policy.d.ts.map +1 -0
- package/api/middleware/tool-policy.js +156 -0
- package/api/middleware/tool-policy.js.map +1 -0
- package/api/oauth-adapters.d.ts +192 -0
- package/api/oauth-adapters.d.ts.map +1 -0
- package/api/oauth-adapters.js +456 -0
- package/api/oauth-adapters.js.map +1 -0
- package/api/oauth-bridge.d.ts +56 -0
- package/api/oauth-bridge.d.ts.map +1 -0
- package/api/oauth-bridge.js +624 -0
- package/api/oauth-bridge.js.map +1 -0
- package/api/oauth-router.d.ts +36 -0
- package/api/oauth-router.d.ts.map +1 -0
- package/api/oauth-router.js +54 -0
- package/api/oauth-router.js.map +1 -0
- package/api/p2p-mcp.d.ts +69 -0
- package/api/p2p-mcp.d.ts.map +1 -0
- package/api/p2p-mcp.js +286 -0
- package/api/p2p-mcp.js.map +1 -0
- package/api/payment-store.d.ts +56 -0
- package/api/payment-store.d.ts.map +1 -0
- package/api/payment-store.js +163 -0
- package/api/payment-store.js.map +1 -0
- package/api/payment.d.ts +14 -0
- package/api/payment.d.ts.map +1 -0
- package/api/payment.js +216 -0
- package/api/payment.js.map +1 -0
- package/api/pwa-stats.d.ts +67 -0
- package/api/pwa-stats.d.ts.map +1 -0
- package/api/pwa-stats.js +269 -0
- package/api/pwa-stats.js.map +1 -0
- package/api/riskcontrol-adapters.d.ts +114 -0
- package/api/riskcontrol-adapters.d.ts.map +1 -0
- package/api/riskcontrol-adapters.js +210 -0
- package/api/riskcontrol-adapters.js.map +1 -0
- package/api/riskcontrol-event-whitelist.d.ts +81 -0
- package/api/riskcontrol-event-whitelist.d.ts.map +1 -0
- package/api/riskcontrol-event-whitelist.js +181 -0
- package/api/riskcontrol-event-whitelist.js.map +1 -0
- package/api/riskcontrol-rules.d.ts +105 -0
- package/api/riskcontrol-rules.d.ts.map +1 -0
- package/api/riskcontrol-rules.js +399 -0
- package/api/riskcontrol-rules.js.map +1 -0
- package/api/riskcontrol-scoring.d.ts +72 -0
- package/api/riskcontrol-scoring.d.ts.map +1 -0
- package/api/riskcontrol-scoring.js +335 -0
- package/api/riskcontrol-scoring.js.map +1 -0
- package/api/riskcontrol-service.d.ts +60 -0
- package/api/riskcontrol-service.d.ts.map +1 -0
- package/api/riskcontrol-service.js +206 -0
- package/api/riskcontrol-service.js.map +1 -0
- package/api/riskcontrol-stream.d.ts +112 -0
- package/api/riskcontrol-stream.d.ts.map +1 -0
- package/api/riskcontrol-stream.js +230 -0
- package/api/riskcontrol-stream.js.map +1 -0
- package/api/riskcontrol-v5-e2e-test.d.ts +15 -0
- package/api/riskcontrol-v5-e2e-test.d.ts.map +1 -0
- package/api/riskcontrol-v5-e2e-test.js +204 -0
- package/api/riskcontrol-v5-e2e-test.js.map +1 -0
- package/api/riskcontrol-v5-router.d.ts +48 -0
- package/api/riskcontrol-v5-router.d.ts.map +1 -0
- package/api/riskcontrol-v5-router.js +226 -0
- package/api/riskcontrol-v5-router.js.map +1 -0
- package/api/riskcontrol-webhook.d.ts +88 -0
- package/api/riskcontrol-webhook.d.ts.map +1 -0
- package/api/riskcontrol-webhook.js +326 -0
- package/api/riskcontrol-webhook.js.map +1 -0
- package/api/routes/case-library.d.ts +4 -0
- package/api/routes/case-library.d.ts.map +1 -0
- package/api/routes/case-library.js +91 -0
- package/api/routes/case-library.js.map +1 -0
- package/api/seller-earnings.d.ts +23 -0
- package/api/seller-earnings.d.ts.map +1 -0
- package/api/seller-earnings.js +258 -0
- package/api/seller-earnings.js.map +1 -0
- package/api/seller-orders.d.ts +25 -0
- package/api/seller-orders.d.ts.map +1 -0
- package/api/seller-orders.js +398 -0
- package/api/seller-orders.js.map +1 -0
- package/api/seller-products-chain.d.ts +31 -0
- package/api/seller-products-chain.d.ts.map +1 -0
- package/api/seller-products-chain.js +308 -0
- package/api/seller-products-chain.js.map +1 -0
- package/api/seller-products.d.ts +30 -0
- package/api/seller-products.d.ts.map +1 -0
- package/api/seller-products.js +453 -0
- package/api/seller-products.js.map +1 -0
- package/api/seller-reputation.d.ts +21 -0
- package/api/seller-reputation.d.ts.map +1 -0
- package/api/seller-reputation.js +204 -0
- package/api/seller-reputation.js.map +1 -0
- package/api/seller-router.d.ts +33 -0
- package/api/seller-router.d.ts.map +1 -0
- package/api/seller-router.js +53 -0
- package/api/seller-router.js.map +1 -0
- package/api/seller-settings.d.ts +23 -0
- package/api/seller-settings.d.ts.map +1 -0
- package/api/seller-settings.js +279 -0
- package/api/seller-settings.js.map +1 -0
- package/api/shipping-store.d.ts +44 -0
- package/api/shipping-store.d.ts.map +1 -0
- package/api/shipping-store.js +154 -0
- package/api/shipping-store.js.map +1 -0
- package/api/shipping.d.ts +16 -0
- package/api/shipping.d.ts.map +1 -0
- package/api/shipping.js +239 -0
- package/api/shipping.js.map +1 -0
- package/api/social-endpoint-verify.d.ts +8 -0
- package/api/social-endpoint-verify.d.ts.map +1 -0
- package/api/social-endpoint-verify.js +152 -0
- package/api/social-endpoint-verify.js.map +1 -0
- package/api/social-posts.d.ts +65 -0
- package/api/social-posts.d.ts.map +1 -0
- package/api/social-posts.js +534 -0
- package/api/social-posts.js.map +1 -0
- package/api/social-router.d.ts +36 -0
- package/api/social-router.d.ts.map +1 -0
- package/api/social-router.js +56 -0
- package/api/social-router.js.map +1 -0
- package/api/social-shares.d.ts +40 -0
- package/api/social-shares.d.ts.map +1 -0
- package/api/social-shares.js +379 -0
- package/api/social-shares.js.map +1 -0
- package/api/social-whitelist.d.ts +41 -0
- package/api/social-whitelist.d.ts.map +1 -0
- package/api/social-whitelist.js +261 -0
- package/api/social-whitelist.js.map +1 -0
- package/api/storefront-orders.d.ts +23 -0
- package/api/storefront-orders.d.ts.map +1 -0
- package/api/storefront-orders.js +349 -0
- package/api/storefront-orders.js.map +1 -0
- package/api/storefront-products.d.ts +21 -0
- package/api/storefront-products.d.ts.map +1 -0
- package/api/storefront-products.js +181 -0
- package/api/storefront-products.js.map +1 -0
- package/api/storefront-router.d.ts +33 -0
- package/api/storefront-router.d.ts.map +1 -0
- package/api/storefront-router.js +47 -0
- package/api/storefront-router.js.map +1 -0
- package/api/storefront-user.d.ts +23 -0
- package/api/storefront-user.d.ts.map +1 -0
- package/api/storefront-user.js +336 -0
- package/api/storefront-user.js.map +1 -0
- package/api/test-db-helper.d.ts +29 -0
- package/api/test-db-helper.d.ts.map +1 -0
- package/api/test-db-helper.js +107 -0
- package/api/test-db-helper.js.map +1 -0
- package/api/traffic.d.ts +22 -0
- package/api/traffic.d.ts.map +1 -0
- package/api/traffic.js +112 -0
- package/api/traffic.js.map +1 -0
- package/api/wc-credentials.d.ts +34 -0
- package/api/wc-credentials.d.ts.map +1 -0
- package/api/wc-credentials.js +296 -0
- package/api/wc-credentials.js.map +1 -0
- package/api/wc-tracker-receiver.d.ts +47 -0
- package/api/wc-tracker-receiver.d.ts.map +1 -0
- package/api/wc-tracker-receiver.js +264 -0
- package/api/wc-tracker-receiver.js.map +1 -0
- package/api/wc-v3.d.ts +40 -0
- package/api/wc-v3.d.ts.map +1 -0
- package/api/wc-v3.js +694 -0
- package/api/wc-v3.js.map +1 -0
- package/bin/tb-doctor.js +32 -0
- package/bin/tb-seller-backend.js +42 -0
- package/check.d.ts +2 -0
- package/check.d.ts.map +1 -0
- package/check.js +19 -0
- package/check.js.map +1 -0
- package/config/export-import.d.ts +108 -0
- package/config/export-import.d.ts.map +1 -0
- package/config/export-import.js +234 -0
- package/config/export-import.js.map +1 -0
- package/config/manager.d.ts +73 -0
- package/config/manager.d.ts.map +1 -0
- package/config/manager.js +246 -0
- package/config/manager.js.map +1 -0
- package/config/profile.d.ts +42 -0
- package/config/profile.d.ts.map +1 -0
- package/config/profile.js +111 -0
- package/config/profile.js.map +1 -0
- package/core/address.js +23 -0
- package/core/advanced-performance.d.ts +149 -0
- package/core/advanced-performance.d.ts.map +1 -0
- package/core/advanced-performance.js +374 -0
- package/core/advanced-performance.js.map +1 -0
- package/core/alerting.d.ts +91 -0
- package/core/alerting.d.ts.map +1 -0
- package/core/alerting.js +379 -0
- package/core/alerting.js.map +1 -0
- package/core/app-store.d.ts +77 -0
- package/core/app-store.d.ts.map +1 -0
- package/core/app-store.js +207 -0
- package/core/app-store.js.map +1 -0
- package/core/boot-env.js +39 -0
- package/core/business-scope-schema.d.ts +60 -0
- package/core/business-scope-schema.d.ts.map +1 -0
- package/core/business-scope-schema.js +165 -0
- package/core/business-scope-schema.js.map +1 -0
- package/core/cache.d.ts +53 -0
- package/core/cache.d.ts.map +1 -0
- package/core/cache.js +130 -0
- package/core/cache.js.map +1 -0
- package/core/chain-listener.d.ts +47 -0
- package/core/chain-listener.d.ts.map +1 -0
- package/core/chain-listener.js +254 -0
- package/core/chain-listener.js.map +1 -0
- package/core/chain-reject.js +107 -0
- package/core/chain-signer.js +258 -0
- package/core/cleanup.d.ts +42 -0
- package/core/cleanup.d.ts.map +1 -0
- package/core/cleanup.js +144 -0
- package/core/cleanup.js.map +1 -0
- package/core/cluster.d.ts +78 -0
- package/core/cluster.d.ts.map +1 -0
- package/core/cluster.js +215 -0
- package/core/cluster.js.map +1 -0
- package/core/community-review.d.ts +82 -0
- package/core/community-review.d.ts.map +1 -0
- package/core/community-review.js +201 -0
- package/core/community-review.js.map +1 -0
- package/core/connection-pool.d.ts +72 -0
- package/core/connection-pool.d.ts.map +1 -0
- package/core/connection-pool.js +173 -0
- package/core/connection-pool.js.map +1 -0
- package/core/consistency.d.ts +130 -0
- package/core/consistency.d.ts.map +1 -0
- package/core/consistency.js +340 -0
- package/core/consistency.js.map +1 -0
- package/core/content-ai.d.ts +303 -0
- package/core/content-ai.d.ts.map +1 -0
- package/core/content-ai.js +344 -0
- package/core/content-ai.js.map +1 -0
- package/core/content-backfill.d.ts +55 -0
- package/core/content-backfill.d.ts.map +1 -0
- package/core/content-backfill.js +174 -0
- package/core/content-backfill.js.map +1 -0
- package/core/conversion-rate-sync.d.ts +97 -0
- package/core/conversion-rate-sync.d.ts.map +1 -0
- package/core/conversion-rate-sync.js +195 -0
- package/core/conversion-rate-sync.js.map +1 -0
- package/core/coverage-backup.d.ts +87 -0
- package/core/coverage-backup.d.ts.map +1 -0
- package/core/coverage-backup.js +265 -0
- package/core/coverage-backup.js.map +1 -0
- package/core/db-installer.d.ts +108 -0
- package/core/db-installer.d.ts.map +1 -0
- package/core/db-installer.js +414 -0
- package/core/db-installer.js.map +1 -0
- package/core/device-analyzer.d.ts +96 -0
- package/core/device-analyzer.d.ts.map +1 -0
- package/core/device-analyzer.js +235 -0
- package/core/device-analyzer.js.map +1 -0
- package/core/discovery.d.ts +165 -0
- package/core/discovery.d.ts.map +1 -0
- package/core/discovery.js +363 -0
- package/core/discovery.js.map +1 -0
- package/core/distributed.d.ts +172 -0
- package/core/distributed.d.ts.map +1 -0
- package/core/distributed.js +422 -0
- package/core/distributed.js.map +1 -0
- package/core/doctor.js +249 -0
- package/core/enforcement.d.ts +57 -0
- package/core/enforcement.d.ts.map +1 -0
- package/core/enforcement.js +115 -0
- package/core/enforcement.js.map +1 -0
- package/core/error-handler.d.ts +131 -0
- package/core/error-handler.d.ts.map +1 -0
- package/core/error-handler.js +291 -0
- package/core/error-handler.js.map +1 -0
- package/core/federated-learning.d.ts +124 -0
- package/core/federated-learning.d.ts.map +1 -0
- package/core/federated-learning.js +338 -0
- package/core/federated-learning.js.map +1 -0
- package/core/fingerprint.d.ts +95 -0
- package/core/fingerprint.d.ts.map +1 -0
- package/core/fingerprint.js +313 -0
- package/core/fingerprint.js.map +1 -0
- package/core/geoip.d.ts +67 -0
- package/core/geoip.d.ts.map +1 -0
- package/core/geoip.js +174 -0
- package/core/geoip.js.map +1 -0
- package/core/gossip.d.ts +141 -0
- package/core/gossip.d.ts.map +1 -0
- package/core/gossip.js +372 -0
- package/core/gossip.js.map +1 -0
- package/core/governance.d.ts +147 -0
- package/core/governance.d.ts.map +1 -0
- package/core/governance.js +351 -0
- package/core/governance.js.map +1 -0
- package/core/indexer-enhancements.d.ts +164 -0
- package/core/indexer-enhancements.d.ts.map +1 -0
- package/core/indexer-enhancements.js +429 -0
- package/core/indexer-enhancements.js.map +1 -0
- package/core/intrusion-detection.d.ts +79 -0
- package/core/intrusion-detection.d.ts.map +1 -0
- package/core/intrusion-detection.js +322 -0
- package/core/intrusion-detection.js.map +1 -0
- package/core/lifecycle.d.ts +118 -0
- package/core/lifecycle.d.ts.map +1 -0
- package/core/lifecycle.js +310 -0
- package/core/lifecycle.js.map +1 -0
- package/core/location.d.ts +99 -0
- package/core/location.d.ts.map +1 -0
- package/core/location.js +219 -0
- package/core/location.js.map +1 -0
- package/core/maxmind-integration.d.ts +68 -0
- package/core/maxmind-integration.d.ts.map +1 -0
- package/core/maxmind-integration.js +245 -0
- package/core/maxmind-integration.js.map +1 -0
- package/core/migration.d.ts +58 -0
- package/core/migration.d.ts.map +1 -0
- package/core/migration.js +223 -0
- package/core/migration.js.map +1 -0
- package/core/monitoring.d.ts +153 -0
- package/core/monitoring.d.ts.map +1 -0
- package/core/monitoring.js +406 -0
- package/core/monitoring.js.map +1 -0
- package/core/offsite-backup.d.ts +71 -0
- package/core/offsite-backup.d.ts.map +1 -0
- package/core/offsite-backup.js +341 -0
- package/core/offsite-backup.js.map +1 -0
- package/core/order-intent-store.js +83 -0
- package/core/order-intent.js +273 -0
- package/core/paths.js +116 -0
- package/core/performance.d.ts +173 -0
- package/core/performance.d.ts.map +1 -0
- package/core/performance.js +386 -0
- package/core/performance.js.map +1 -0
- package/core/product-flag.d.ts +364 -0
- package/core/product-flag.d.ts.map +1 -0
- package/core/product-flag.js +465 -0
- package/core/product-flag.js.map +1 -0
- package/core/protection.d.ts +139 -0
- package/core/protection.d.ts.map +1 -0
- package/core/protection.js +327 -0
- package/core/protection.js.map +1 -0
- package/core/region-adapter.d.ts +152 -0
- package/core/region-adapter.d.ts.map +1 -0
- package/core/region-adapter.js +505 -0
- package/core/region-adapter.js.map +1 -0
- package/core/region-configs.d.ts +12 -0
- package/core/region-configs.d.ts.map +1 -0
- package/core/region-configs.js +907 -0
- package/core/region-configs.js.map +1 -0
- package/core/review-antifraud.d.ts +80 -0
- package/core/review-antifraud.d.ts.map +1 -0
- package/core/review-antifraud.js +193 -0
- package/core/review-antifraud.js.map +1 -0
- package/core/rules-updater.d.ts +89 -0
- package/core/rules-updater.d.ts.map +1 -0
- package/core/rules-updater.js +261 -0
- package/core/rules-updater.js.map +1 -0
- package/core/runtime-data.js +203 -0
- package/core/security.d.ts +144 -0
- package/core/security.d.ts.map +1 -0
- package/core/security.js +390 -0
- package/core/security.js.map +1 -0
- package/core/seller-identity.js +78 -0
- package/core/session-manager.d.ts +93 -0
- package/core/session-manager.d.ts.map +1 -0
- package/core/session-manager.js +262 -0
- package/core/session-manager.js.map +1 -0
- package/core/state-sync.d.ts +121 -0
- package/core/state-sync.d.ts.map +1 -0
- package/core/state-sync.js +287 -0
- package/core/state-sync.js.map +1 -0
- package/core/testing.d.ts +97 -0
- package/core/testing.d.ts.map +1 -0
- package/core/testing.js +361 -0
- package/core/testing.js.map +1 -0
- package/core/trust-score.d.ts +51 -0
- package/core/trust-score.d.ts.map +1 -0
- package/core/trust-score.js +188 -0
- package/core/trust-score.js.map +1 -0
- package/core/trustworthiness.d.ts +140 -0
- package/core/trustworthiness.d.ts.map +1 -0
- package/core/trustworthiness.js +375 -0
- package/core/trustworthiness.js.map +1 -0
- package/core/types.d.ts +258 -0
- package/core/types.d.ts.map +1 -0
- package/core/types.js +9 -0
- package/core/types.js.map +1 -0
- package/core/upgrade-manager.d.ts +114 -0
- package/core/upgrade-manager.d.ts.map +1 -0
- package/core/upgrade-manager.js +264 -0
- package/core/upgrade-manager.js.map +1 -0
- package/core/upgrader.d.ts +107 -0
- package/core/upgrader.d.ts.map +1 -0
- package/core/upgrader.js +389 -0
- package/core/upgrader.js.map +1 -0
- package/core/websocket.d.ts +78 -0
- package/core/websocket.d.ts.map +1 -0
- package/core/websocket.js +292 -0
- package/core/websocket.js.map +1 -0
- package/council/hidden-weight.d.ts +45 -0
- package/council/hidden-weight.d.ts.map +1 -0
- package/council/hidden-weight.js +135 -0
- package/council/hidden-weight.js.map +1 -0
- package/db/email-migrations.sql +31 -0
- package/db/oauth-migrate.d.ts +39 -0
- package/db/oauth-migrate.d.ts.map +1 -0
- package/db/oauth-migrate.js +201 -0
- package/db/oauth-migrate.js.map +1 -0
- package/db/oauth-migrations.sql +92 -0
- package/db/social-migrate.d.ts +12 -0
- package/db/social-migrate.d.ts.map +1 -0
- package/db/social-migrate.js +102 -0
- package/db/social-migrate.js.map +1 -0
- package/db/social-migrations.sql +94 -0
- package/db/store-migrate.d.ts +33 -0
- package/db/store-migrate.d.ts.map +1 -0
- package/db/store-migrate.js +149 -0
- package/db/store-migrate.js.map +1 -0
- package/db/store-migrations.sql +242 -0
- package/debug.d.ts +2 -0
- package/debug.d.ts.map +1 -0
- package/debug.js +18 -0
- package/debug.js.map +1 -0
- package/event-listener.d.ts +93 -0
- package/event-listener.d.ts.map +1 -0
- package/event-listener.js +321 -0
- package/event-listener.js.map +1 -0
- package/event-whitelist.d.ts +79 -0
- package/event-whitelist.d.ts.map +1 -0
- package/event-whitelist.js +533 -0
- package/event-whitelist.js.map +1 -0
- package/index.d.ts +45 -0
- package/index.d.ts.map +1 -0
- package/index.js +361 -0
- package/index.js.map +1 -0
- package/init-node.d.ts +9 -0
- package/init-node.d.ts.map +1 -0
- package/init-node.js +230 -0
- package/init-node.js.map +1 -0
- package/mcp/ai-tools.d.ts +2 -0
- package/mcp/ai-tools.d.ts.map +1 -0
- package/mcp/ai-tools.js +266 -0
- package/mcp/ai-tools.js.map +1 -0
- package/mcp/auto-dispatch-tools.d.ts +2 -0
- package/mcp/auto-dispatch-tools.d.ts.map +1 -0
- package/mcp/auto-dispatch-tools.js +348 -0
- package/mcp/auto-dispatch-tools.js.map +1 -0
- package/mcp/business-scope-tools.d.ts +11 -0
- package/mcp/business-scope-tools.d.ts.map +1 -0
- package/mcp/business-scope-tools.js +179 -0
- package/mcp/business-scope-tools.js.map +1 -0
- package/mcp/buyer-tools.d.ts +67 -0
- package/mcp/buyer-tools.d.ts.map +1 -0
- package/mcp/buyer-tools.js +445 -0
- package/mcp/buyer-tools.js.map +1 -0
- package/mcp/interfaces.d.ts +1058 -0
- package/mcp/interfaces.d.ts.map +1 -0
- package/mcp/interfaces.js +13 -0
- package/mcp/interfaces.js.map +1 -0
- package/mcp/m2m-chat-tool.d.ts +50 -0
- package/mcp/m2m-chat-tool.d.ts.map +1 -0
- package/mcp/m2m-chat-tool.js +432 -0
- package/mcp/m2m-chat-tool.js.map +1 -0
- package/mcp/migrations.d.ts +30 -0
- package/mcp/migrations.d.ts.map +1 -0
- package/mcp/migrations.js +391 -0
- package/mcp/migrations.js.map +1 -0
- package/mcp/peer-tools.d.ts +163 -0
- package/mcp/peer-tools.d.ts.map +1 -0
- package/mcp/peer-tools.js +532 -0
- package/mcp/peer-tools.js.map +1 -0
- package/mcp/plugin-management-tools.d.ts +2 -0
- package/mcp/plugin-management-tools.d.ts.map +1 -0
- package/mcp/plugin-management-tools.js +327 -0
- package/mcp/plugin-management-tools.js.map +1 -0
- package/mcp/product-type-tools.d.ts +2 -0
- package/mcp/product-type-tools.d.ts.map +1 -0
- package/mcp/product-type-tools.js +470 -0
- package/mcp/product-type-tools.js.map +1 -0
- package/mcp/security-tools.d.ts +2 -0
- package/mcp/security-tools.d.ts.map +1 -0
- package/mcp/security-tools.js +313 -0
- package/mcp/security-tools.js.map +1 -0
- package/mcp/seller-query-tools.d.ts +2 -0
- package/mcp/seller-query-tools.d.ts.map +1 -0
- package/mcp/seller-query-tools.js +179 -0
- package/mcp/seller-query-tools.js.map +1 -0
- package/mcp/server.d.ts +11 -0
- package/mcp/server.d.ts.map +1 -0
- package/mcp/server.js +68 -0
- package/mcp/server.js.map +1 -0
- package/mcp/standalone-server.d.ts +34 -0
- package/mcp/standalone-server.d.ts.map +1 -0
- package/mcp/standalone-server.js +261 -0
- package/mcp/standalone-server.js.map +1 -0
- package/mcp/tools-integration.d.ts +31 -0
- package/mcp/tools-integration.d.ts.map +1 -0
- package/mcp/tools-integration.js +288 -0
- package/mcp/tools-integration.js.map +1 -0
- package/mcp/web-panel.d.ts +18 -0
- package/mcp/web-panel.d.ts.map +1 -0
- package/mcp/web-panel.js +1657 -0
- package/mcp/web-panel.js.map +1 -0
- package/middleware/api-key-auth.d.ts +64 -0
- package/middleware/api-key-auth.d.ts.map +1 -0
- package/middleware/api-key-auth.js +255 -0
- package/middleware/api-key-auth.js.map +1 -0
- package/middleware/scope-auth.d.ts +54 -0
- package/middleware/scope-auth.d.ts.map +1 -0
- package/middleware/scope-auth.js +153 -0
- package/middleware/scope-auth.js.map +1 -0
- package/middleware/security.d.ts +48 -0
- package/middleware/security.d.ts.map +1 -0
- package/middleware/security.js +217 -0
- package/middleware/security.js.map +1 -0
- package/middleware/wallet-auth.d.ts +54 -0
- package/middleware/wallet-auth.d.ts.map +1 -0
- package/middleware/wallet-auth.js +158 -0
- package/middleware/wallet-auth.js.map +1 -0
- package/oauth/chain-revocation-sink.d.ts +24 -0
- package/oauth/chain-revocation-sink.d.ts.map +1 -0
- package/oauth/chain-revocation-sink.js +47 -0
- package/oauth/chain-revocation-sink.js.map +1 -0
- package/oauth/gossip-sync.d.ts +25 -0
- package/oauth/gossip-sync.d.ts.map +1 -0
- package/oauth/gossip-sync.js +62 -0
- package/oauth/gossip-sync.js.map +1 -0
- package/oauth/issuer-keys.d.ts +31 -0
- package/oauth/issuer-keys.d.ts.map +1 -0
- package/oauth/issuer-keys.js +117 -0
- package/oauth/issuer-keys.js.map +1 -0
- package/oauth/peer-resolver.d.ts +25 -0
- package/oauth/peer-resolver.d.ts.map +1 -0
- package/oauth/peer-resolver.js +81 -0
- package/oauth/peer-resolver.js.map +1 -0
- package/oauth/revocation-store.d.ts +58 -0
- package/oauth/revocation-store.d.ts.map +1 -0
- package/oauth/revocation-store.js +86 -0
- package/oauth/revocation-store.js.map +1 -0
- package/oauth/token-v2.d.ts +101 -0
- package/oauth/token-v2.d.ts.map +1 -0
- package/oauth/token-v2.js +167 -0
- package/oauth/token-v2.js.map +1 -0
- package/oracle/c5-glue.js +603 -0
- package/oracle/ops-console.js +623 -0
- package/oracle/oracle-sync.d.ts +29 -0
- package/oracle/oracle-sync.d.ts.map +1 -0
- package/oracle/oracle-sync.js +445 -0
- package/oracle/oracle-sync.js.map +1 -0
- package/oracle/registry.d.ts +30 -0
- package/oracle/registry.d.ts.map +1 -0
- package/oracle/registry.js +62 -0
- package/oracle/registry.js.map +1 -0
- package/p2p/availability.d.ts +188 -0
- package/p2p/availability.d.ts.map +1 -0
- package/p2p/availability.js +574 -0
- package/p2p/availability.js.map +1 -0
- package/p2p/bootstrap.d.ts +42 -0
- package/p2p/bootstrap.d.ts.map +1 -0
- package/p2p/bootstrap.js +146 -0
- package/p2p/bootstrap.js.map +1 -0
- package/p2p/buyer-client.d.ts +98 -0
- package/p2p/buyer-client.d.ts.map +1 -0
- package/p2p/buyer-client.js +199 -0
- package/p2p/buyer-client.js.map +1 -0
- package/p2p/cdn-ddns.d.ts +208 -0
- package/p2p/cdn-ddns.d.ts.map +1 -0
- package/p2p/cdn-ddns.js +500 -0
- package/p2p/cdn-ddns.js.map +1 -0
- package/p2p/cluster-sync.d.ts +115 -0
- package/p2p/cluster-sync.d.ts.map +1 -0
- package/p2p/cluster-sync.js +330 -0
- package/p2p/cluster-sync.js.map +1 -0
- package/p2p/consistency-check.d.ts +30 -0
- package/p2p/consistency-check.d.ts.map +1 -0
- package/p2p/consistency-check.js +168 -0
- package/p2p/consistency-check.js.map +1 -0
- package/p2p/endpoint-registry.d.ts +41 -0
- package/p2p/endpoint-registry.d.ts.map +1 -0
- package/p2p/endpoint-registry.js +128 -0
- package/p2p/endpoint-registry.js.map +1 -0
- package/p2p/ipv6.d.ts +120 -0
- package/p2p/ipv6.d.ts.map +1 -0
- package/p2p/ipv6.js +425 -0
- package/p2p/ipv6.js.map +1 -0
- package/p2p/protocol.d.ts +100 -0
- package/p2p/protocol.d.ts.map +1 -0
- package/p2p/protocol.js +330 -0
- package/p2p/protocol.js.map +1 -0
- package/p2p/reliability.d.ts +56 -0
- package/p2p/reliability.d.ts.map +1 -0
- package/p2p/reliability.js +240 -0
- package/p2p/reliability.js.map +1 -0
- package/p2p/seller-service.d.ts +53 -0
- package/p2p/seller-service.d.ts.map +1 -0
- package/p2p/seller-service.js +276 -0
- package/p2p/seller-service.js.map +1 -0
- package/p2p/signing.d.ts +31 -0
- package/p2p/signing.d.ts.map +1 -0
- package/p2p/signing.js +95 -0
- package/p2p/signing.js.map +1 -0
- package/package.json +73 -0
- package/payment/api.d.ts +9 -0
- package/payment/api.d.ts.map +1 -0
- package/payment/api.js +141 -0
- package/payment/api.js.map +1 -0
- package/payment/gateway.d.ts +114 -0
- package/payment/gateway.d.ts.map +1 -0
- package/payment/gateway.js +231 -0
- package/payment/gateway.js.map +1 -0
- package/payments/alipay/index.d.ts +18 -0
- package/payments/alipay/index.d.ts.map +1 -0
- package/payments/alipay/index.js +55 -0
- package/payments/alipay/index.js.map +1 -0
- package/payments/base.d.ts +13 -0
- package/payments/base.d.ts.map +1 -0
- package/payments/base.js +28 -0
- package/payments/base.js.map +1 -0
- package/payments/index.d.ts +18 -0
- package/payments/index.d.ts.map +1 -0
- package/payments/index.js +66 -0
- package/payments/index.js.map +1 -0
- package/payments/template/index.d.ts +18 -0
- package/payments/template/index.d.ts.map +1 -0
- package/payments/template/index.js +57 -0
- package/payments/template/index.js.map +1 -0
- package/payments/types.d.ts +42 -0
- package/payments/types.d.ts.map +1 -0
- package/payments/types.js +3 -0
- package/payments/types.js.map +1 -0
- package/payments/wechat/index.d.ts +18 -0
- package/payments/wechat/index.d.ts.map +1 -0
- package/payments/wechat/index.js +54 -0
- package/payments/wechat/index.js.map +1 -0
- package/peer/chain-signer.d.ts +74 -0
- package/peer/chain-signer.d.ts.map +1 -0
- package/peer/chain-signer.js +149 -0
- package/peer/chain-signer.js.map +1 -0
- package/peer/config.d.ts +71 -0
- package/peer/config.d.ts.map +1 -0
- package/peer/config.js +61 -0
- package/peer/config.js.map +1 -0
- package/peer/index.d.ts +12 -0
- package/peer/index.d.ts.map +1 -0
- package/peer/index.js +46 -0
- package/peer/index.js.map +1 -0
- package/peer/key-store.d.ts +66 -0
- package/peer/key-store.d.ts.map +1 -0
- package/peer/key-store.js +163 -0
- package/peer/key-store.js.map +1 -0
- package/peer/proto-codec.d.ts +103 -0
- package/peer/proto-codec.d.ts.map +1 -0
- package/peer/proto-codec.js +423 -0
- package/peer/proto-codec.js.map +1 -0
- package/peer/registrar.d.ts +88 -0
- package/peer/registrar.d.ts.map +1 -0
- package/peer/registrar.js +271 -0
- package/peer/registrar.js.map +1 -0
- package/peer/registry.d.ts +31 -0
- package/peer/registry.d.ts.map +1 -0
- package/peer/registry.js +143 -0
- package/peer/registry.js.map +1 -0
- package/plugins/auth.d.ts +193 -0
- package/plugins/auth.d.ts.map +1 -0
- package/plugins/auth.js +923 -0
- package/plugins/auth.js.map +1 -0
- package/plugins/manager.d.ts +37 -0
- package/plugins/manager.d.ts.map +1 -0
- package/plugins/manager.js +83 -0
- package/plugins/manager.js.map +1 -0
- package/plugins/oauth.d.ts +249 -0
- package/plugins/oauth.d.ts.map +1 -0
- package/plugins/oauth.js +979 -0
- package/plugins/oauth.js.map +1 -0
- package/plugins/p2p-message.d.ts +133 -0
- package/plugins/p2p-message.d.ts.map +1 -0
- package/plugins/p2p-message.js +443 -0
- package/plugins/p2p-message.js.map +1 -0
- package/plugins/postgresql.d.ts +54 -0
- package/plugins/postgresql.d.ts.map +1 -0
- package/plugins/postgresql.js +743 -0
- package/plugins/postgresql.js.map +1 -0
- package/plugins/relationship.d.ts +141 -0
- package/plugins/relationship.d.ts.map +1 -0
- package/plugins/relationship.js +395 -0
- package/plugins/relationship.js.map +1 -0
- package/plugins/sqlite.d.ts +200 -0
- package/plugins/sqlite.d.ts.map +1 -0
- package/plugins/sqlite.js +2412 -0
- package/plugins/sqlite.js.map +1 -0
- package/port-manager/disguise/ssh.d.ts +19 -0
- package/port-manager/disguise/ssh.d.ts.map +1 -0
- package/port-manager/disguise/ssh.js +104 -0
- package/port-manager/disguise/ssh.js.map +1 -0
- package/port-manager/port-manager.d.ts +65 -0
- package/port-manager/port-manager.d.ts.map +1 -0
- package/port-manager/port-manager.js +164 -0
- package/port-manager/port-manager.js.map +1 -0
- package/port-manager/port-scanner.d.ts +22 -0
- package/port-manager/port-scanner.d.ts.map +1 -0
- package/port-manager/port-scanner.js +187 -0
- package/port-manager/port-scanner.js.map +1 -0
- package/port-manager/types.d.ts +51 -0
- package/port-manager/types.d.ts.map +1 -0
- package/port-manager/types.js +6 -0
- package/port-manager/types.js.map +1 -0
- package/proto/amino/amino.proto +84 -0
- package/proto/cosmos/base/v1beta1/coin.proto +61 -0
- package/proto/cosmos/msg/v1/msg.proto +30 -0
- package/proto/cosmos_proto/cosmos.proto +112 -0
- package/proto/gogoproto/gogo.proto +145 -0
- package/proto/google/protobuf/descriptor.proto +1218 -0
- package/proto/trustchain/economy/v1/params.proto +133 -0
- package/proto/trustchain/economy/v1/tx.proto +162 -0
- package/proto/trustchain/marketplace/v1/params.proto +64 -0
- package/proto/trustchain/marketplace/v1/product.proto +21 -0
- package/proto/trustchain/marketplace/v1/tx.proto +131 -0
- package/proto/trustchain/order/v1/params.proto +94 -0
- package/proto/trustchain/order/v1/tx.proto +156 -0
- package/proto/trustchain/serviceprovider/v1/paymentfact.proto +32 -0
- package/proto/trustchain/serviceprovider/v1/serviceprovider.proto +38 -0
- package/proto/trustchain/serviceprovider/v1/tx.proto +106 -0
- package/proto/trustchain/subchain/v1/params.proto +26 -0
- package/proto/trustchain/subchain/v1/pool.proto +53 -0
- package/proto/trustchain/subchain/v1/tx.proto +159 -0
- package/proto/trustchain/trustcoin/v1/business_scope.proto +126 -0
- package/proto/trustchain/trustcoin/v1/genesis.proto +33 -0
- package/proto/trustchain/trustcoin/v1/params.proto +86 -0
- package/proto/trustchain/trustcoin/v1/query.proto +95 -0
- package/proto/trustchain/trustcoin/v1/tx.proto +160 -0
- package/proto/trustchain/verification/v1/params.proto +46 -0
- package/proto/trustchain/verification/v1/tx.proto +126 -0
- package/proto/trustchain/verification/v1/verification.proto +105 -0
- package/relationship-chain-api.d.ts +13 -0
- package/relationship-chain-api.d.ts.map +1 -0
- package/relationship-chain-api.js +139 -0
- package/relationship-chain-api.js.map +1 -0
- package/relationship-chain.d.ts +90 -0
- package/relationship-chain.d.ts.map +1 -0
- package/relationship-chain.js +201 -0
- package/relationship-chain.js.map +1 -0
- package/routes/agent-pay.js +419 -0
- package/routes/agent-serviceprovider.js +183 -0
- package/routes/ai.d.ts +54 -0
- package/routes/ai.d.ts.map +1 -0
- package/routes/ai.js +293 -0
- package/routes/ai.js.map +1 -0
- package/routes/api-keys.d.ts +12 -0
- package/routes/api-keys.d.ts.map +1 -0
- package/routes/api-keys.js +163 -0
- package/routes/api-keys.js.map +1 -0
- package/routes/app-store.d.ts +12 -0
- package/routes/app-store.d.ts.map +1 -0
- package/routes/app-store.js +207 -0
- package/routes/app-store.js.map +1 -0
- package/routes/auth-management.d.ts +17 -0
- package/routes/auth-management.d.ts.map +1 -0
- package/routes/auth-management.js +257 -0
- package/routes/auth-management.js.map +1 -0
- package/routes/auth.d.ts +9 -0
- package/routes/auth.d.ts.map +1 -0
- package/routes/auth.js +846 -0
- package/routes/auth.js.map +1 -0
- package/routes/brand.d.ts +3 -0
- package/routes/brand.d.ts.map +1 -0
- package/routes/brand.js +109 -0
- package/routes/brand.js.map +1 -0
- package/routes/chain-registry.d.ts +11 -0
- package/routes/chain-registry.d.ts.map +1 -0
- package/routes/chain-registry.js +51 -0
- package/routes/chain-registry.js.map +1 -0
- package/routes/chain-writes-insurance.d.ts +17 -0
- package/routes/chain-writes-insurance.d.ts.map +1 -0
- package/routes/chain-writes-insurance.js +69 -0
- package/routes/chain-writes-insurance.js.map +1 -0
- package/routes/chain-writes-pledge.d.ts +34 -0
- package/routes/chain-writes-pledge.d.ts.map +1 -0
- package/routes/chain-writes-pledge.js +206 -0
- package/routes/chain-writes-pledge.js.map +1 -0
- package/routes/chain-writes-products.d.ts +66 -0
- package/routes/chain-writes-products.d.ts.map +1 -0
- package/routes/chain-writes-products.js +394 -0
- package/routes/chain-writes-products.js.map +1 -0
- package/routes/chain-writes.d.ts +78 -0
- package/routes/chain-writes.d.ts.map +1 -0
- package/routes/chain-writes.js +658 -0
- package/routes/chain-writes.js.map +1 -0
- package/routes/chain.d.ts +10 -0
- package/routes/chain.d.ts.map +1 -0
- package/routes/chain.js +45 -0
- package/routes/chain.js.map +1 -0
- package/routes/compliance.d.ts +3 -0
- package/routes/compliance.d.ts.map +1 -0
- package/routes/compliance.js +53 -0
- package/routes/compliance.js.map +1 -0
- package/routes/council.d.ts +3 -0
- package/routes/council.d.ts.map +1 -0
- package/routes/council.js +477 -0
- package/routes/council.js.map +1 -0
- package/routes/crosschain.d.ts +11 -0
- package/routes/crosschain.d.ts.map +1 -0
- package/routes/crosschain.js +39 -0
- package/routes/crosschain.js.map +1 -0
- package/routes/device.d.ts +3 -0
- package/routes/device.d.ts.map +1 -0
- package/routes/device.js +73 -0
- package/routes/device.js.map +1 -0
- package/routes/devreward.d.ts +54 -0
- package/routes/devreward.d.ts.map +1 -0
- package/routes/devreward.js +129 -0
- package/routes/devreward.js.map +1 -0
- package/routes/economy.d.ts +50 -0
- package/routes/economy.d.ts.map +1 -0
- package/routes/economy.js +273 -0
- package/routes/economy.js.map +1 -0
- package/routes/flowback.d.ts +32 -0
- package/routes/flowback.d.ts.map +1 -0
- package/routes/flowback.js +97 -0
- package/routes/flowback.js.map +1 -0
- package/routes/insurance.d.ts +10 -0
- package/routes/insurance.d.ts.map +1 -0
- package/routes/insurance.js +70 -0
- package/routes/insurance.js.map +1 -0
- package/routes/m2m-viewer.js +195 -0
- package/routes/m2m.d.ts +10 -0
- package/routes/m2m.d.ts.map +1 -0
- package/routes/m2m.js +31 -0
- package/routes/m2m.js.map +1 -0
- package/routes/marketplace.d.ts +15 -0
- package/routes/marketplace.d.ts.map +1 -0
- package/routes/marketplace.js +396 -0
- package/routes/marketplace.js.map +1 -0
- package/routes/node-config.d.ts +6 -0
- package/routes/node-config.d.ts.map +1 -0
- package/routes/node-config.js +500 -0
- package/routes/node-config.js.map +1 -0
- package/routes/oauth-revocation.d.ts +42 -0
- package/routes/oauth-revocation.d.ts.map +1 -0
- package/routes/oauth-revocation.js +99 -0
- package/routes/oauth-revocation.js.map +1 -0
- package/routes/oauth.d.ts +17 -0
- package/routes/oauth.d.ts.map +1 -0
- package/routes/oauth.js +700 -0
- package/routes/oauth.js.map +1 -0
- package/routes/onboard.html +352 -0
- package/routes/onboard.js +435 -0
- package/routes/order.d.ts +8 -0
- package/routes/order.d.ts.map +1 -0
- package/routes/order.js +607 -0
- package/routes/order.js.map +1 -0
- package/routes/p2p-api.d.ts +33 -0
- package/routes/p2p-api.d.ts.map +1 -0
- package/routes/p2p-api.js +274 -0
- package/routes/p2p-api.js.map +1 -0
- package/routes/p2p-message.d.ts +20 -0
- package/routes/p2p-message.d.ts.map +1 -0
- package/routes/p2p-message.js +237 -0
- package/routes/p2p-message.js.map +1 -0
- package/routes/peer.d.ts +22 -0
- package/routes/peer.d.ts.map +1 -0
- package/routes/peer.js +220 -0
- package/routes/peer.js.map +1 -0
- package/routes/plugins.d.ts +4 -0
- package/routes/plugins.d.ts.map +1 -0
- package/routes/plugins.js +138 -0
- package/routes/plugins.js.map +1 -0
- package/routes/port-manager.d.ts +6 -0
- package/routes/port-manager.d.ts.map +1 -0
- package/routes/port-manager.js +212 -0
- package/routes/port-manager.js.map +1 -0
- package/routes/relationship.d.ts +7 -0
- package/routes/relationship.d.ts.map +1 -0
- package/routes/relationship.js +314 -0
- package/routes/relationship.js.map +1 -0
- package/routes/relay.d.ts +3 -0
- package/routes/relay.d.ts.map +1 -0
- package/routes/relay.js +182 -0
- package/routes/relay.js.map +1 -0
- package/routes/reputation.d.ts +10 -0
- package/routes/reputation.d.ts.map +1 -0
- package/routes/reputation.js +141 -0
- package/routes/reputation.js.map +1 -0
- package/routes/reward.d.ts +3 -0
- package/routes/reward.d.ts.map +1 -0
- package/routes/reward.js +130 -0
- package/routes/reward.js.map +1 -0
- package/routes/security-monitoring.d.ts +12 -0
- package/routes/security-monitoring.d.ts.map +1 -0
- package/routes/security-monitoring.js +373 -0
- package/routes/security-monitoring.js.map +1 -0
- package/routes/shop.d.ts +8 -0
- package/routes/shop.d.ts.map +1 -0
- package/routes/shop.js +164 -0
- package/routes/shop.js.map +1 -0
- package/routes/social.d.ts +22 -0
- package/routes/social.d.ts.map +1 -0
- package/routes/social.js +95 -0
- package/routes/social.js.map +1 -0
- package/routes/subchain.d.ts +18 -0
- package/routes/subchain.d.ts.map +1 -0
- package/routes/subchain.js +106 -0
- package/routes/subchain.js.map +1 -0
- package/routes/trustcoin.d.ts +17 -0
- package/routes/trustcoin.d.ts.map +1 -0
- package/routes/trustcoin.js +149 -0
- package/routes/trustcoin.js.map +1 -0
- package/routes/twofa.d.ts +7 -0
- package/routes/twofa.d.ts.map +1 -0
- package/routes/twofa.js +105 -0
- package/routes/twofa.js.map +1 -0
- package/routes/verification.d.ts +8 -0
- package/routes/verification.d.ts.map +1 -0
- package/routes/verification.js +234 -0
- package/routes/verification.js.map +1 -0
- package/routes/wallet.d.ts +4 -0
- package/routes/wallet.d.ts.map +1 -0
- package/routes/wallet.js +770 -0
- package/routes/wallet.js.map +1 -0
- package/run-auth.d.ts +8 -0
- package/run-auth.d.ts.map +1 -0
- package/run-auth.js +82 -0
- package/run-auth.js.map +1 -0
- package/run-p2p-message.d.ts +8 -0
- package/run-p2p-message.d.ts.map +1 -0
- package/run-p2p-message.js +82 -0
- package/run-p2p-message.js.map +1 -0
- package/run-relationship.d.ts +12 -0
- package/run-relationship.d.ts.map +1 -0
- package/run-relationship.js +182 -0
- package/run-relationship.js.map +1 -0
- package/run-unified.d.ts +13 -0
- package/run-unified.d.ts.map +1 -0
- package/run-unified.js +1067 -0
- package/run-unified.js.map +1 -0
- package/run.d.ts +12 -0
- package/run.d.ts.map +1 -0
- package/run.js +889 -0
- package/run.js.map +1 -0
- package/search/ranking.d.ts +55 -0
- package/search/ranking.d.ts.map +1 -0
- package/search/ranking.js +67 -0
- package/search/ranking.js.map +1 -0
- package/shipping/base.d.ts +15 -0
- package/shipping/base.d.ts.map +1 -0
- package/shipping/base.js +39 -0
- package/shipping/base.js.map +1 -0
- package/shipping/index.d.ts +19 -0
- package/shipping/index.d.ts.map +1 -0
- package/shipping/index.js +72 -0
- package/shipping/index.js.map +1 -0
- package/shipping/sf-express/index.d.ts +23 -0
- package/shipping/sf-express/index.d.ts.map +1 -0
- package/shipping/sf-express/index.js +71 -0
- package/shipping/sf-express/index.js.map +1 -0
- package/shipping/template/index.d.ts +20 -0
- package/shipping/template/index.d.ts.map +1 -0
- package/shipping/template/index.js +74 -0
- package/shipping/template/index.js.map +1 -0
- package/shipping/types.d.ts +71 -0
- package/shipping/types.d.ts.map +1 -0
- package/shipping/types.js +6 -0
- package/shipping/types.js.map +1 -0
- package/shipping/virtual/index.d.ts +19 -0
- package/shipping/virtual/index.d.ts.map +1 -0
- package/shipping/virtual/index.js +54 -0
- package/shipping/virtual/index.js.map +1 -0
- package/shipping/yto/index.d.ts +18 -0
- package/shipping/yto/index.d.ts.map +1 -0
- package/shipping/yto/index.js +59 -0
- package/shipping/yto/index.js.map +1 -0
- package/shipping/zto/index.d.ts +18 -0
- package/shipping/zto/index.d.ts.map +1 -0
- package/shipping/zto/index.js +59 -0
- package/shipping/zto/index.js.map +1 -0
- package/skills-lock.json +11 -0
- package/src/db/email-migrations.sql +31 -0
- package/src/db/oauth-migrations.sql +92 -0
- package/src/db/social-migrations.sql +94 -0
- package/src/db/store-migrations.sql +242 -0
- package/test-api-key-revoke.js +167 -0
- package/test-auth-register-ratelimit.js +132 -0
- package/test-auth-tv2.d.ts +2 -0
- package/test-auth-tv2.d.ts.map +1 -0
- package/test-auth-tv2.js +174 -0
- package/test-auth-tv2.js.map +1 -0
- package/test-canonsign-cross.d.ts +2 -0
- package/test-canonsign-cross.d.ts.map +1 -0
- package/test-canonsign-cross.js +32 -0
- package/test-canonsign-cross.js.map +1 -0
- package/test-chain-signer.js +127 -0
- package/test-env-truthy.js +50 -0
- package/test-onboard-contract.js +94 -0
- package/test-ops-console-boundary.js +147 -0
- package/test-oracle-glue.js +232 -0
- package/test-order-create-v394.js +358 -0
- package/test-order-intent.js +245 -0
- package/test-order-lifecycle-v394.js +528 -0
- package/test-p2p-message.d.ts +13 -0
- package/test-p2p-message.d.ts.map +1 -0
- package/test-p2p-message.js +106 -0
- package/test-p2p-message.js.map +1 -0
- package/test-relationship-chain.d.ts +13 -0
- package/test-relationship-chain.d.ts.map +1 -0
- package/test-relationship-chain.js +103 -0
- package/test-relationship-chain.js.map +1 -0
- package/test-runtime-data-path.js +217 -0
- package/test-seller-identity.js +74 -0
- package/test-signing-paths.js +104 -0
- package/test-token-v2.d.ts +2 -0
- package/test-token-v2.d.ts.map +1 -0
- package/test-token-v2.js +172 -0
- package/test-token-v2.js.map +1 -0
- package/test-wallet-auth-nonce.d.ts +12 -0
- package/test-wallet-auth-nonce.d.ts.map +1 -0
- package/test-wallet-auth-nonce.js +126 -0
- package/test-wallet-auth-nonce.js.map +1 -0
- package/test-wallet-submatch.d.ts +13 -0
- package/test-wallet-submatch.d.ts.map +1 -0
- package/test-wallet-submatch.js +86 -0
- package/test-wallet-submatch.js.map +1 -0
- package/tls/self-signed.d.ts +12 -0
- package/tls/self-signed.d.ts.map +1 -0
- package/tls/self-signed.js +63 -0
- package/tls/self-signed.js.map +1 -0
- package/tools/brand.d.ts +11 -0
- package/tools/brand.d.ts.map +1 -0
- package/tools/brand.js +75 -0
- package/tools/brand.js.map +1 -0
- package/tools/chainregistry.d.ts +18 -0
- package/tools/chainregistry.d.ts.map +1 -0
- package/tools/chainregistry.js +175 -0
- package/tools/chainregistry.js.map +1 -0
- package/tools/compliance.d.ts +14 -0
- package/tools/compliance.d.ts.map +1 -0
- package/tools/compliance.js +45 -0
- package/tools/compliance.js.map +1 -0
- package/tools/council.d.ts +17 -0
- package/tools/council.d.ts.map +1 -0
- package/tools/council.js +75 -0
- package/tools/council.js.map +1 -0
- package/tools/device.d.ts +13 -0
- package/tools/device.d.ts.map +1 -0
- package/tools/device.js +45 -0
- package/tools/device.js.map +1 -0
- package/tools/devreward.d.ts +15 -0
- package/tools/devreward.d.ts.map +1 -0
- package/tools/devreward.js +190 -0
- package/tools/devreward.js.map +1 -0
- package/tools/economy.d.ts +14 -0
- package/tools/economy.d.ts.map +1 -0
- package/tools/economy.js +172 -0
- package/tools/economy.js.map +1 -0
- package/tools/flowback.d.ts +14 -0
- package/tools/flowback.d.ts.map +1 -0
- package/tools/flowback.js +146 -0
- package/tools/flowback.js.map +1 -0
- package/tools/insurance.d.ts +13 -0
- package/tools/insurance.d.ts.map +1 -0
- package/tools/insurance.js +45 -0
- package/tools/insurance.js.map +1 -0
- package/tools/marketplace.d.ts +12 -0
- package/tools/marketplace.d.ts.map +1 -0
- package/tools/marketplace.js +124 -0
- package/tools/marketplace.js.map +1 -0
- package/tools/order.d.ts +12 -0
- package/tools/order.d.ts.map +1 -0
- package/tools/order.js +94 -0
- package/tools/order.js.map +1 -0
- package/tools/recovery.d.ts +14 -0
- package/tools/recovery.d.ts.map +1 -0
- package/tools/recovery.js +158 -0
- package/tools/recovery.js.map +1 -0
- package/tools/relay.d.ts +15 -0
- package/tools/relay.d.ts.map +1 -0
- package/tools/relay.js +152 -0
- package/tools/relay.js.map +1 -0
- package/tools/reputation.d.ts +20 -0
- package/tools/reputation.d.ts.map +1 -0
- package/tools/reputation.js +50 -0
- package/tools/reputation.js.map +1 -0
- package/tools/reputation_seller_credit.d.ts +16 -0
- package/tools/reputation_seller_credit.d.ts.map +1 -0
- package/tools/reputation_seller_credit.js +106 -0
- package/tools/reputation_seller_credit.js.map +1 -0
- package/tools/reward.d.ts +14 -0
- package/tools/reward.d.ts.map +1 -0
- package/tools/reward.js +76 -0
- package/tools/reward.js.map +1 -0
- package/tools/shop.d.ts +14 -0
- package/tools/shop.d.ts.map +1 -0
- package/tools/shop.js +95 -0
- package/tools/shop.js.map +1 -0
- package/tools/verification.d.ts +12 -0
- package/tools/verification.d.ts.map +1 -0
- package/tools/verification.js +89 -0
- package/tools/verification.js.map +1 -0
- package/types/store.d.ts +255 -0
- package/types/store.d.ts.map +1 -0
- package/types/store.js +19 -0
- package/types/store.js.map +1 -0
- package/utils/aes-gcm.d.ts +63 -0
- package/utils/aes-gcm.d.ts.map +1 -0
- package/utils/aes-gcm.js +179 -0
- package/utils/aes-gcm.js.map +1 -0
- package/utils/api-response.d.ts +51 -0
- package/utils/api-response.d.ts.map +1 -0
- package/utils/api-response.js +65 -0
- package/utils/api-response.js.map +1 -0
- package/utils/base32.d.ts +5 -0
- package/utils/base32.d.ts.map +1 -0
- package/utils/base32.js +20 -0
- package/utils/base32.js.map +1 -0
- package/utils/crypto.d.ts +77 -0
- package/utils/crypto.d.ts.map +1 -0
- package/utils/crypto.js +164 -0
- package/utils/crypto.js.map +1 -0
- package/utils/encryption.d.ts +81 -0
- package/utils/encryption.d.ts.map +1 -0
- package/utils/encryption.js +247 -0
- package/utils/encryption.js.map +1 -0
- package/utils/env.js +20 -0
- package/utils/jwt.d.ts +110 -0
- package/utils/jwt.d.ts.map +1 -0
- package/utils/jwt.js +275 -0
- package/utils/jwt.js.map +1 -0
- package/utils/qrcode-reader.d.ts +22 -0
- package/utils/qrcode-reader.d.ts.map +1 -0
- package/utils/qrcode-reader.js +90 -0
- package/utils/qrcode-reader.js.map +1 -0
- package/utils/qrcode.d.ts +26 -0
- package/utils/qrcode.d.ts.map +1 -0
- package/utils/qrcode.js +92 -0
- package/utils/qrcode.js.map +1 -0
- package/utils/totp.d.ts +3 -0
- package/utils/totp.d.ts.map +1 -0
- package/utils/totp.js +58 -0
- package/utils/totp.js.map +1 -0
- package/utils/two-factor-auth.d.ts +16 -0
- package/utils/two-factor-auth.d.ts.map +1 -0
- package/utils/two-factor-auth.js +150 -0
- package/utils/two-factor-auth.js.map +1 -0
- package/verifyer/hsm.d.ts +70 -0
- package/verifyer/hsm.d.ts.map +1 -0
- package/verifyer/hsm.js +482 -0
- package/verifyer/hsm.js.map +1 -0
- package/verifyer/index.d.ts +81 -0
- package/verifyer/index.d.ts.map +1 -0
- package/verifyer/index.js +372 -0
- package/verifyer/index.js.map +1 -0
- package/ws/peer-monitor-broadcaster.d.ts +24 -0
- package/ws/peer-monitor-broadcaster.d.ts.map +1 -0
- package/ws/peer-monitor-broadcaster.js +56 -0
- package/ws/peer-monitor-broadcaster.js.map +1 -0
|
@@ -0,0 +1,743 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* PostgreSQL Indexer Plugin - 第2层区域索引器
|
|
4
|
+
*
|
|
5
|
+
* PRD 16.3: 区域级索引,支持更大容量
|
|
6
|
+
* 覆盖 ≤ 500,000 卖家,PostgreSQL 存储
|
|
7
|
+
*
|
|
8
|
+
* 与 SQLite 相同的表结构,使用 PostgreSQL 语法
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.PostgreSQLPlugin = void 0;
|
|
12
|
+
const trust_score_1 = require("../core/trust-score");
|
|
13
|
+
const pg_1 = require("pg");
|
|
14
|
+
class PostgreSQLPlugin {
|
|
15
|
+
name = 'postgresql';
|
|
16
|
+
displayName = 'PostgreSQL 区域索引';
|
|
17
|
+
tier = 2;
|
|
18
|
+
maxCapacity = 500000;
|
|
19
|
+
pool;
|
|
20
|
+
config;
|
|
21
|
+
startTime = Date.now();
|
|
22
|
+
queryCount = 0;
|
|
23
|
+
syncedHeight = 0;
|
|
24
|
+
async init(config) {
|
|
25
|
+
this.config = config;
|
|
26
|
+
// Build connection config from env or defaults
|
|
27
|
+
const connectionString = process.env.DATABASE_URL ||
|
|
28
|
+
`postgresql://${process.env.PGUSER || 'postgres'}:${process.env.PGPASSWORD || 'postgres'}@${process.env.PGHOST || 'localhost'}:${process.env.PGPORT || '5432'}/${process.env.PGDATABASE || 'trustchain_index'}`;
|
|
29
|
+
this.pool = new pg_1.Pool({ connectionString, max: 10 });
|
|
30
|
+
// Test connection
|
|
31
|
+
try {
|
|
32
|
+
const client = await this.pool.connect();
|
|
33
|
+
client.release();
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
throw new Error(`PostgreSQL connection failed: ${err.message}. ` +
|
|
37
|
+
`Ensure PostgreSQL is running and accessible. ` +
|
|
38
|
+
`Set DATABASE_URL or PGHOST/PGPORT/PGUSER/PGPASSWORD/PGDATABASE env vars.`);
|
|
39
|
+
}
|
|
40
|
+
await this.createTables();
|
|
41
|
+
}
|
|
42
|
+
async createTables() {
|
|
43
|
+
await this.pool.query(`
|
|
44
|
+
CREATE TABLE IF NOT EXISTS products (
|
|
45
|
+
sku_id TEXT PRIMARY KEY,
|
|
46
|
+
seller TEXT NOT NULL,
|
|
47
|
+
title TEXT NOT NULL DEFAULT '',
|
|
48
|
+
description TEXT DEFAULT '',
|
|
49
|
+
content_hash TEXT NOT NULL DEFAULT '',
|
|
50
|
+
price_cny INTEGER DEFAULT 0,
|
|
51
|
+
price_tct INTEGER DEFAULT 0,
|
|
52
|
+
category_l1 TEXT DEFAULT '',
|
|
53
|
+
category_l2 TEXT DEFAULT '',
|
|
54
|
+
category_l3 TEXT DEFAULT '',
|
|
55
|
+
latitude INTEGER DEFAULT 0,
|
|
56
|
+
longitude INTEGER DEFAULT 0,
|
|
57
|
+
city TEXT DEFAULT '',
|
|
58
|
+
stock INTEGER DEFAULT 0,
|
|
59
|
+
stake_per_unit TEXT DEFAULT '0',
|
|
60
|
+
images TEXT DEFAULT '[]',
|
|
61
|
+
shipping_method TEXT DEFAULT '',
|
|
62
|
+
shipping_fee INTEGER DEFAULT 0,
|
|
63
|
+
delivery_days INTEGER DEFAULT 0,
|
|
64
|
+
created_at INTEGER DEFAULT 0,
|
|
65
|
+
updated_at INTEGER DEFAULT 0,
|
|
66
|
+
status TEXT DEFAULT 'active',
|
|
67
|
+
brand_auth_type INTEGER DEFAULT 0,
|
|
68
|
+
insurance_seller TEXT DEFAULT '',
|
|
69
|
+
order_count INTEGER DEFAULT 0,
|
|
70
|
+
last_sale_at INTEGER DEFAULT 0
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
CREATE TABLE IF NOT EXISTS sellers (
|
|
74
|
+
address TEXT PRIMARY KEY,
|
|
75
|
+
moniker TEXT DEFAULT '',
|
|
76
|
+
reputation INTEGER DEFAULT 50,
|
|
77
|
+
total_stake TEXT DEFAULT '0',
|
|
78
|
+
active_orders INTEGER DEFAULT 0,
|
|
79
|
+
completed_orders INTEGER DEFAULT 0,
|
|
80
|
+
dispute_rate REAL DEFAULT 0,
|
|
81
|
+
latitude INTEGER DEFAULT 0,
|
|
82
|
+
longitude INTEGER DEFAULT 0,
|
|
83
|
+
last_online INTEGER DEFAULT 0,
|
|
84
|
+
registered_at INTEGER DEFAULT 0,
|
|
85
|
+
p2p_http_port INTEGER DEFAULT 0,
|
|
86
|
+
p2p_tcp_port INTEGER DEFAULT 0,
|
|
87
|
+
p2p_quic_port INTEGER DEFAULT 0,
|
|
88
|
+
p2p_peer_id TEXT DEFAULT '',
|
|
89
|
+
p2p_ip TEXT DEFAULT ''
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
CREATE TABLE IF NOT EXISTS reviews (
|
|
93
|
+
id TEXT PRIMARY KEY,
|
|
94
|
+
order_id TEXT NOT NULL,
|
|
95
|
+
from_address TEXT NOT NULL,
|
|
96
|
+
to_address TEXT NOT NULL,
|
|
97
|
+
rating INTEGER DEFAULT 5,
|
|
98
|
+
content_hash TEXT DEFAULT '',
|
|
99
|
+
created_at INTEGER DEFAULT 0
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
CREATE TABLE IF NOT EXISTS orders (
|
|
103
|
+
id TEXT PRIMARY KEY,
|
|
104
|
+
buyer TEXT NOT NULL,
|
|
105
|
+
seller TEXT NOT NULL,
|
|
106
|
+
sku_id TEXT NOT NULL,
|
|
107
|
+
quantity INTEGER DEFAULT 1,
|
|
108
|
+
total_price TEXT DEFAULT '0',
|
|
109
|
+
status TEXT DEFAULT 'created',
|
|
110
|
+
created_at INTEGER DEFAULT 0,
|
|
111
|
+
source_chain TEXT DEFAULT ''
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
CREATE TABLE IF NOT EXISTS sync_state (
|
|
115
|
+
key TEXT PRIMARY KEY,
|
|
116
|
+
value TEXT NOT NULL
|
|
117
|
+
);
|
|
118
|
+
`);
|
|
119
|
+
// Create indexes
|
|
120
|
+
await this.pool.query(`
|
|
121
|
+
CREATE INDEX IF NOT EXISTS idx_products_seller ON products(seller);
|
|
122
|
+
CREATE INDEX IF NOT EXISTS idx_products_status ON products(status);
|
|
123
|
+
CREATE INDEX IF NOT EXISTS idx_products_category ON products(category_l1, category_l2);
|
|
124
|
+
CREATE INDEX IF NOT EXISTS idx_products_price ON products(price_cny);
|
|
125
|
+
CREATE INDEX IF NOT EXISTS idx_products_location ON products(latitude, longitude);
|
|
126
|
+
CREATE INDEX IF NOT EXISTS idx_sellers_reputation ON sellers(reputation);
|
|
127
|
+
CREATE INDEX IF NOT EXISTS idx_reviews_to ON reviews(to_address);
|
|
128
|
+
`);
|
|
129
|
+
// Create full-text search using GIN index (PostgreSQL tsvector)
|
|
130
|
+
await this.pool.query(`
|
|
131
|
+
CREATE INDEX IF NOT EXISTS idx_products_fts ON products
|
|
132
|
+
USING GIN (to_tsvector('simple', coalesce(title, '') || ' ' || coalesce(description, '') || ' ' || coalesce(category_l1, '') || ' ' || coalesce(category_l2, '') || ' ' || coalesce(category_l3, '')));
|
|
133
|
+
`);
|
|
134
|
+
// 多链扩展迁移:为旧表添加 source_chain 列
|
|
135
|
+
await this.pool.query(`ALTER TABLE orders ADD COLUMN IF NOT EXISTS source_chain TEXT DEFAULT ''`);
|
|
136
|
+
// 2026-09-07 kimi: marketplace 事件三处一致修复 — 链上 pause/resume/delist/add_stock/
|
|
137
|
+
// reduce_stock 事件只 emit seller+slot_index (无 sku_id), 需要 slot_index 列反查商品
|
|
138
|
+
await this.pool.query(`ALTER TABLE products ADD COLUMN IF NOT EXISTS slot_index INTEGER DEFAULT -1`);
|
|
139
|
+
}
|
|
140
|
+
async start() {
|
|
141
|
+
// Load sync height
|
|
142
|
+
const res = await this.pool.query("SELECT value FROM sync_state WHERE key = 'sync_height'");
|
|
143
|
+
if (res.rows.length > 0) {
|
|
144
|
+
this.syncedHeight = Number(res.rows[0].value);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
async stop() {
|
|
148
|
+
await this.pool.end();
|
|
149
|
+
}
|
|
150
|
+
async destroy() {
|
|
151
|
+
await this.pool.end();
|
|
152
|
+
}
|
|
153
|
+
async clearAll() {
|
|
154
|
+
console.log('[PostgreSQLPlugin] Clearing all data for rebuild...');
|
|
155
|
+
await this.pool.query('TRUNCATE products, sellers, reviews, orders, index_updates RESTART IDENTITY');
|
|
156
|
+
await this.pool.query(`INSERT INTO sync_state (key, value) VALUES ('sync_height', '0') ON CONFLICT (key) DO UPDATE SET value = '0'`);
|
|
157
|
+
this.syncedHeight = 0;
|
|
158
|
+
console.log('[PostgreSQLPlugin] All data cleared, sync_height reset to 0');
|
|
159
|
+
}
|
|
160
|
+
// ---- Data Write ----
|
|
161
|
+
async indexProduct(product) {
|
|
162
|
+
await this.pool.query(`
|
|
163
|
+
INSERT INTO products (
|
|
164
|
+
sku_id, seller, title, description, content_hash,
|
|
165
|
+
price_cny, price_tct, category_l1, category_l2, category_l3,
|
|
166
|
+
latitude, longitude, city, stock, stake_per_unit,
|
|
167
|
+
images, shipping_method, shipping_fee, delivery_days,
|
|
168
|
+
created_at, updated_at, status,
|
|
169
|
+
brand_auth_type, insurance_seller
|
|
170
|
+
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24)
|
|
171
|
+
ON CONFLICT (sku_id) DO UPDATE SET
|
|
172
|
+
seller = EXCLUDED.seller, title = EXCLUDED.title, description = EXCLUDED.description,
|
|
173
|
+
content_hash = EXCLUDED.content_hash, price_cny = EXCLUDED.price_cny, price_tct = EXCLUDED.price_tct,
|
|
174
|
+
category_l1 = EXCLUDED.category_l1, category_l2 = EXCLUDED.category_l2, category_l3 = EXCLUDED.category_l3,
|
|
175
|
+
latitude = EXCLUDED.latitude, longitude = EXCLUDED.longitude, city = EXCLUDED.city,
|
|
176
|
+
stock = EXCLUDED.stock, stake_per_unit = EXCLUDED.stake_per_unit,
|
|
177
|
+
images = EXCLUDED.images, shipping_method = EXCLUDED.shipping_method,
|
|
178
|
+
shipping_fee = EXCLUDED.shipping_fee, delivery_days = EXCLUDED.delivery_days,
|
|
179
|
+
updated_at = EXCLUDED.updated_at, status = EXCLUDED.status,
|
|
180
|
+
brand_auth_type = EXCLUDED.brand_auth_type, insurance_seller = EXCLUDED.insurance_seller
|
|
181
|
+
`, [
|
|
182
|
+
product.skuId, product.seller, product.title, product.description,
|
|
183
|
+
product.contentHash, product.priceCny, product.priceTct || 0,
|
|
184
|
+
product.category.level1, product.category.level2, product.category.level3 || '',
|
|
185
|
+
product.location.latitude, product.location.longitude, product.location.city || '',
|
|
186
|
+
product.stock, product.stakePerUnit,
|
|
187
|
+
JSON.stringify(product.images), product.shipping.method, product.shipping.fee,
|
|
188
|
+
product.shipping.deliveryDays, product.createdAt, product.updatedAt,
|
|
189
|
+
product.status, product.brand?.authType || 0, product.insurance?.insurer || ''
|
|
190
|
+
]);
|
|
191
|
+
}
|
|
192
|
+
async updateProduct(product) {
|
|
193
|
+
await this.indexProduct(product);
|
|
194
|
+
}
|
|
195
|
+
async removeProduct(skuId) {
|
|
196
|
+
await this.pool.query('DELETE FROM products WHERE sku_id = $1', [skuId]);
|
|
197
|
+
}
|
|
198
|
+
async indexSeller(seller) {
|
|
199
|
+
await this.pool.query(`
|
|
200
|
+
INSERT INTO sellers (
|
|
201
|
+
address, moniker, reputation, total_stake, active_orders,
|
|
202
|
+
completed_orders, dispute_rate, latitude, longitude,
|
|
203
|
+
last_online, registered_at
|
|
204
|
+
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)
|
|
205
|
+
ON CONFLICT (address) DO UPDATE SET
|
|
206
|
+
moniker = EXCLUDED.moniker, reputation = EXCLUDED.reputation,
|
|
207
|
+
total_stake = EXCLUDED.total_stake, active_orders = EXCLUDED.active_orders,
|
|
208
|
+
completed_orders = EXCLUDED.completed_orders, dispute_rate = EXCLUDED.dispute_rate,
|
|
209
|
+
latitude = EXCLUDED.latitude, longitude = EXCLUDED.longitude,
|
|
210
|
+
last_online = EXCLUDED.last_online, registered_at = EXCLUDED.registered_at
|
|
211
|
+
`, [
|
|
212
|
+
seller.address, seller.moniker || '', seller.reputation,
|
|
213
|
+
seller.totalStake, seller.activeOrders, seller.completedOrders,
|
|
214
|
+
seller.disputeRate, seller.location.latitude, seller.location.longitude,
|
|
215
|
+
seller.lastOnline, seller.registeredAt
|
|
216
|
+
]);
|
|
217
|
+
}
|
|
218
|
+
async updateSeller(seller) {
|
|
219
|
+
await this.indexSeller(seller);
|
|
220
|
+
}
|
|
221
|
+
async indexReview(review) {
|
|
222
|
+
await this.pool.query(`
|
|
223
|
+
INSERT INTO reviews (id, order_id, from_address, to_address, rating, content_hash, created_at)
|
|
224
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7)
|
|
225
|
+
ON CONFLICT (id) DO UPDATE SET
|
|
226
|
+
order_id = EXCLUDED.order_id, from_address = EXCLUDED.from_address,
|
|
227
|
+
to_address = EXCLUDED.to_address, rating = EXCLUDED.rating,
|
|
228
|
+
content_hash = EXCLUDED.content_hash, created_at = EXCLUDED.created_at
|
|
229
|
+
`, [review.id, review.orderId, review.fromAddress, review.toAddress,
|
|
230
|
+
review.rating, review.contentHash, review.createdAt]);
|
|
231
|
+
}
|
|
232
|
+
async getReviews(address, limit = 20, offset = 0) {
|
|
233
|
+
const result = await this.pool.query(`SELECT * FROM reviews WHERE to_address = $1 ORDER BY created_at DESC LIMIT $2 OFFSET $3`, [address, limit, offset]);
|
|
234
|
+
return result.rows.map((row) => ({
|
|
235
|
+
id: row.id,
|
|
236
|
+
orderId: row.order_id,
|
|
237
|
+
fromAddress: row.from_address,
|
|
238
|
+
toAddress: row.to_address,
|
|
239
|
+
rating: row.rating,
|
|
240
|
+
content: row.content || '',
|
|
241
|
+
contentHash: row.content_hash || '',
|
|
242
|
+
createdAt: row.created_at,
|
|
243
|
+
}));
|
|
244
|
+
}
|
|
245
|
+
async addReview(review) {
|
|
246
|
+
await this.indexReview(review);
|
|
247
|
+
const delta = review.rating >= 4 ? 1 : -5;
|
|
248
|
+
await this.pool.query('UPDATE sellers SET reputation = GREATEST(0, LEAST(100, reputation + $1)) WHERE address = $2', [delta, review.toAddress]);
|
|
249
|
+
const stats = await this.pool.query(`SELECT COUNT(*) as total, SUM(CASE WHEN rating >= 4 THEN 1 ELSE 0 END) as good FROM reviews WHERE to_address = $1`, [review.toAddress]);
|
|
250
|
+
if (stats.rows.length > 0 && Number(stats.rows[0].total) > 0) {
|
|
251
|
+
const goodRate = Number(stats.rows[0].good || 0) / Number(stats.rows[0].total);
|
|
252
|
+
await this.pool.query('UPDATE sellers SET dispute_rate = $1 WHERE address = $2', [1 - goodRate, review.toAddress]);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
async indexOrder(order) {
|
|
256
|
+
await this.pool.query(`
|
|
257
|
+
INSERT INTO orders (id, buyer, seller, sku_id, quantity, total_price, status, created_at)
|
|
258
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
|
259
|
+
ON CONFLICT (id) DO UPDATE SET
|
|
260
|
+
buyer = EXCLUDED.buyer, seller = EXCLUDED.seller, sku_id = EXCLUDED.sku_id,
|
|
261
|
+
quantity = EXCLUDED.quantity, total_price = EXCLUDED.total_price,
|
|
262
|
+
status = EXCLUDED.status, created_at = EXCLUDED.created_at
|
|
263
|
+
`, [order.id, order.buyer, order.seller, order.skuId,
|
|
264
|
+
order.quantity, order.totalPrice, order.status, order.createdAt]);
|
|
265
|
+
}
|
|
266
|
+
// ---- Search (Core) ----
|
|
267
|
+
async search(query) {
|
|
268
|
+
const startTime = Date.now();
|
|
269
|
+
this.queryCount++;
|
|
270
|
+
const pageSize = query.pageSize || 20;
|
|
271
|
+
const page = query.page || 1;
|
|
272
|
+
const offset = (page - 1) * pageSize;
|
|
273
|
+
// Build WHERE clause
|
|
274
|
+
const conditions = ["p.status = 'active'"];
|
|
275
|
+
// 质押可见性硬规则 (xiaomu 2026-09-18 拍板, 与 sqlite.ts 同款):
|
|
276
|
+
// 必须质押上链的商品才能搜索可见; 零质押/无 slot 对买家不可见。
|
|
277
|
+
conditions.push("CAST(COALESCE(NULLIF(p.slot_index::text, ''), '-1') AS INTEGER) >= 0 " +
|
|
278
|
+
"AND CAST(COALESCE(NULLIF(p.stake_per_unit, ''), '0') AS BIGINT) > 0");
|
|
279
|
+
const params = [];
|
|
280
|
+
let paramIdx = 1;
|
|
281
|
+
if (query.keyword) {
|
|
282
|
+
conditions.push(`to_tsvector('simple', coalesce(p.title, '') || ' ' || coalesce(p.description, '') || ' ' || coalesce(p.category_l1, '') || ' ' || coalesce(p.category_l2, '') || ' ' || coalesce(p.category_l3, '')) @@ plainto_tsquery('simple', $${paramIdx})`);
|
|
283
|
+
params.push(query.keyword);
|
|
284
|
+
paramIdx++;
|
|
285
|
+
}
|
|
286
|
+
if (query.category) {
|
|
287
|
+
conditions.push(`($${paramIdx} = p.category_l1 OR $${paramIdx} = p.category_l2 OR $${paramIdx} = p.category_l3)`);
|
|
288
|
+
params.push(query.category);
|
|
289
|
+
paramIdx++;
|
|
290
|
+
}
|
|
291
|
+
if (query.priceMin !== undefined) {
|
|
292
|
+
conditions.push(`p.price_cny >= $${paramIdx}`);
|
|
293
|
+
params.push(query.priceMin);
|
|
294
|
+
paramIdx++;
|
|
295
|
+
}
|
|
296
|
+
if (query.priceMax !== undefined) {
|
|
297
|
+
conditions.push(`p.price_cny <= $${paramIdx}`);
|
|
298
|
+
params.push(query.priceMax);
|
|
299
|
+
paramIdx++;
|
|
300
|
+
}
|
|
301
|
+
if (query.sellerMinCredit) {
|
|
302
|
+
conditions.push(`s.reputation >= $${paramIdx}`);
|
|
303
|
+
params.push(query.sellerMinCredit);
|
|
304
|
+
paramIdx++;
|
|
305
|
+
}
|
|
306
|
+
if (query.hasBrand) {
|
|
307
|
+
conditions.push('p.brand_auth_type > 0');
|
|
308
|
+
}
|
|
309
|
+
if (query.hasInsurance) {
|
|
310
|
+
conditions.push("p.insurance_seller != ''");
|
|
311
|
+
}
|
|
312
|
+
if (query.location) {
|
|
313
|
+
const lat = query.location.latitude;
|
|
314
|
+
const lon = query.location.longitude;
|
|
315
|
+
const radiusDeg = query.location.radiusKm / 111;
|
|
316
|
+
conditions.push(`p.latitude BETWEEN $${paramIdx} AND $${paramIdx + 1}`);
|
|
317
|
+
params.push(lat - radiusDeg * 1e6, lat + radiusDeg * 1e6);
|
|
318
|
+
paramIdx += 2;
|
|
319
|
+
conditions.push(`p.longitude BETWEEN $${paramIdx} AND $${paramIdx + 1}`);
|
|
320
|
+
params.push(lon - radiusDeg * 1e6, lon + radiusDeg * 1e6);
|
|
321
|
+
paramIdx += 2;
|
|
322
|
+
}
|
|
323
|
+
const whereClause = conditions.join(' AND ');
|
|
324
|
+
// Determine ORDER BY clause
|
|
325
|
+
let orderBy = 's.reputation DESC, p.created_at DESC';
|
|
326
|
+
switch (query.sortBy) {
|
|
327
|
+
case 'price_asc':
|
|
328
|
+
orderBy = 'p.price_cny ASC';
|
|
329
|
+
break;
|
|
330
|
+
case 'price_desc':
|
|
331
|
+
orderBy = 'p.price_cny DESC';
|
|
332
|
+
break;
|
|
333
|
+
case 'newest':
|
|
334
|
+
orderBy = 'p.created_at DESC';
|
|
335
|
+
break;
|
|
336
|
+
case 'distance':
|
|
337
|
+
if (query.location) {
|
|
338
|
+
orderBy = `ABS(p.latitude - ${query.location.latitude}) + ABS(p.longitude - ${query.location.longitude}) ASC`;
|
|
339
|
+
}
|
|
340
|
+
break;
|
|
341
|
+
case 'credit':
|
|
342
|
+
orderBy = 's.reputation DESC';
|
|
343
|
+
break;
|
|
344
|
+
}
|
|
345
|
+
// Count total
|
|
346
|
+
const countRes = await this.pool.query(`SELECT COUNT(*) as cnt FROM products p JOIN sellers s ON p.seller = s.address WHERE ${whereClause}`, params);
|
|
347
|
+
// Fetch results
|
|
348
|
+
const rows = (await this.pool.query(`
|
|
349
|
+
SELECT p.*, s.moniker, s.reputation, s.total_stake, s.active_orders,
|
|
350
|
+
s.completed_orders, s.dispute_rate, s.latitude as s_lat, s.longitude as s_lon,
|
|
351
|
+
s.last_online, s.registered_at,
|
|
352
|
+
(SELECT COUNT(*) FROM reviews r WHERE r.to_address = p.seller) as review_count,
|
|
353
|
+
(SELECT AVG(CASE WHEN r.rating >= 4 THEN 1 ELSE 0 END) FROM reviews r WHERE r.to_address = p.seller) as good_rate
|
|
354
|
+
FROM products p
|
|
355
|
+
JOIN sellers s ON p.seller = s.address
|
|
356
|
+
WHERE ${whereClause}
|
|
357
|
+
ORDER BY ${orderBy}
|
|
358
|
+
LIMIT $${paramIdx} OFFSET $${paramIdx + 1}
|
|
359
|
+
`, [...params, pageSize, offset])).rows;
|
|
360
|
+
const results = rows.map((row) => {
|
|
361
|
+
const product = this.rowToProduct(row);
|
|
362
|
+
const seller = this.rowToSeller(row);
|
|
363
|
+
const trustResult = (0, trust_score_1.calculateTrustScore)({
|
|
364
|
+
seller,
|
|
365
|
+
product,
|
|
366
|
+
reviewCount: row.review_count || 0,
|
|
367
|
+
goodRate: row.good_rate || 0,
|
|
368
|
+
buyerLocation: query.location ? {
|
|
369
|
+
latitude: query.location.latitude,
|
|
370
|
+
longitude: query.location.longitude,
|
|
371
|
+
} : undefined,
|
|
372
|
+
});
|
|
373
|
+
const seedParts = [
|
|
374
|
+
query.keyword || '',
|
|
375
|
+
query.location ? `${query.location.latitude},${query.location.longitude}` : '',
|
|
376
|
+
String(new Date().toISOString().slice(0, 10)),
|
|
377
|
+
product.seller,
|
|
378
|
+
];
|
|
379
|
+
const finalScore = (0, trust_score_1.applyRandomization)(trustResult.score, seedParts.join('|'));
|
|
380
|
+
return {
|
|
381
|
+
product,
|
|
382
|
+
seller,
|
|
383
|
+
trustScore: Math.round(finalScore),
|
|
384
|
+
trustLevel: trustResult.trustLevel,
|
|
385
|
+
stakeCoverage: trustResult.stakeCoverage,
|
|
386
|
+
distanceKm: trustResult.distanceKm,
|
|
387
|
+
reviewCount: row.review_count || 0,
|
|
388
|
+
goodRate: row.good_rate || 0,
|
|
389
|
+
};
|
|
390
|
+
});
|
|
391
|
+
if (!query.sortBy || query.sortBy === 'relevance') {
|
|
392
|
+
results.sort((a, b) => b.trustScore - a.trustScore);
|
|
393
|
+
}
|
|
394
|
+
return {
|
|
395
|
+
total: Number(countRes.rows[0]?.cnt || 0),
|
|
396
|
+
results,
|
|
397
|
+
meta: {
|
|
398
|
+
queryTimeMs: Date.now() - startTime,
|
|
399
|
+
indexerName: this.displayName,
|
|
400
|
+
coverage: this.config.coverageMode === 'local' ? '同城' :
|
|
401
|
+
this.config.coverageMode === 'regional' ? '区域' : '全网',
|
|
402
|
+
},
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
async getSeller(address) {
|
|
406
|
+
const res = await this.pool.query('SELECT * FROM sellers WHERE address = $1', [address]);
|
|
407
|
+
return res.rows.length > 0 ? this.rowToSeller(res.rows[0]) : null;
|
|
408
|
+
}
|
|
409
|
+
async getProduct(skuId) {
|
|
410
|
+
const res = await this.pool.query('SELECT * FROM products WHERE sku_id = $1', [skuId]);
|
|
411
|
+
return res.rows.length > 0 ? this.rowToProduct(res.rows[0]) : null;
|
|
412
|
+
}
|
|
413
|
+
async getStats() {
|
|
414
|
+
const [pc, sc, rc, oc] = await Promise.all([
|
|
415
|
+
this.pool.query('SELECT COUNT(*) as c FROM products'),
|
|
416
|
+
this.pool.query('SELECT COUNT(*) as c FROM sellers'),
|
|
417
|
+
this.pool.query('SELECT COUNT(*) as c FROM reviews'),
|
|
418
|
+
this.pool.query('SELECT COUNT(*) as c FROM orders'),
|
|
419
|
+
]);
|
|
420
|
+
return {
|
|
421
|
+
totalProducts: Number(pc.rows[0].c),
|
|
422
|
+
totalSellers: Number(sc.rows[0].c),
|
|
423
|
+
totalReviews: Number(rc.rows[0].c),
|
|
424
|
+
totalOrders: Number(oc.rows[0].c),
|
|
425
|
+
syncedHeight: this.syncedHeight,
|
|
426
|
+
indexerTier: this.tier,
|
|
427
|
+
dbSizeBytes: 0,
|
|
428
|
+
uptimeSeconds: Math.floor((Date.now() - this.startTime) / 1000),
|
|
429
|
+
queriesPerSecond: this.queryCount / Math.max(1, (Date.now() - this.startTime) / 1000),
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
// ---- Sync ----
|
|
433
|
+
getSyncHeight() {
|
|
434
|
+
return this.syncedHeight;
|
|
435
|
+
}
|
|
436
|
+
async syncFromBlock(height, events) {
|
|
437
|
+
const client = await this.pool.connect();
|
|
438
|
+
try {
|
|
439
|
+
await client.query('BEGIN');
|
|
440
|
+
for (const event of events) {
|
|
441
|
+
try {
|
|
442
|
+
await this.processEvent(client, event);
|
|
443
|
+
}
|
|
444
|
+
catch (err) {
|
|
445
|
+
console.error(`[PG-Indexer] processEvent error at block ${height}, type=${event.type}:`, err.message);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
this.syncedHeight = height;
|
|
449
|
+
await client.query("INSERT INTO sync_state (key, value) VALUES ('sync_height', $1) ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value", [String(height)]);
|
|
450
|
+
await client.query('COMMIT');
|
|
451
|
+
}
|
|
452
|
+
catch (err) {
|
|
453
|
+
await client.query('ROLLBACK');
|
|
454
|
+
console.error(`[PG-Indexer] syncFromBlock transaction failed at height ${height}:`, err.message);
|
|
455
|
+
}
|
|
456
|
+
finally {
|
|
457
|
+
client.release();
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* marketplace 事件 sku 解析 (2026-09-07 kimi 三处一致修复):
|
|
462
|
+
* 链上 pause_sku/resume_sku/delist_sku/add_stock/reduce_stock 事件只 emit
|
|
463
|
+
* seller+slot_index (无 sku_id)。优先直接用 a.sku_id (list_sku 有), 否则
|
|
464
|
+
* 按 seller+slot_index 反查 products.slot_index 列。查不到返回 null。
|
|
465
|
+
*/
|
|
466
|
+
async resolveSkuId(client, a) {
|
|
467
|
+
if (a.sku_id)
|
|
468
|
+
return a.sku_id;
|
|
469
|
+
const slotIndex = Number(a.slot_index);
|
|
470
|
+
if (!a.seller || !Number.isFinite(slotIndex) || slotIndex < 0)
|
|
471
|
+
return null;
|
|
472
|
+
const res = await client.query('SELECT sku_id FROM products WHERE seller = $1 AND slot_index = $2', [a.seller, slotIndex]);
|
|
473
|
+
return res.rows[0]?.sku_id ?? null;
|
|
474
|
+
}
|
|
475
|
+
async processEvent(client, event) {
|
|
476
|
+
const a = event.attributes;
|
|
477
|
+
switch (event.type) {
|
|
478
|
+
case 'list_sku': {
|
|
479
|
+
const seller = a.seller;
|
|
480
|
+
const skuId = a.sku_id;
|
|
481
|
+
// Ensure seller exists
|
|
482
|
+
const sellerCheck = await client.query('SELECT address FROM sellers WHERE address = $1', [seller]);
|
|
483
|
+
if (sellerCheck.rows.length === 0) {
|
|
484
|
+
await client.query(`
|
|
485
|
+
INSERT INTO sellers (address, reputation, total_stake, active_orders, completed_orders, dispute_rate, latitude, longitude, last_online, registered_at)
|
|
486
|
+
VALUES ($1, 50, $2, 0, 0, 0, 0, 0, $3, $3)
|
|
487
|
+
ON CONFLICT (address) DO NOTHING
|
|
488
|
+
`, [seller, a.total_stake || '0', Date.now()]);
|
|
489
|
+
}
|
|
490
|
+
const existing = (await client.query('SELECT * FROM products WHERE sku_id = $1', [skuId])).rows[0];
|
|
491
|
+
await this.indexProduct({
|
|
492
|
+
skuId,
|
|
493
|
+
seller,
|
|
494
|
+
title: existing?.title || skuId,
|
|
495
|
+
description: existing?.description || '',
|
|
496
|
+
contentHash: a.content_hash || '',
|
|
497
|
+
priceCny: existing?.price_cny || 0,
|
|
498
|
+
priceTct: existing?.price_tct || undefined,
|
|
499
|
+
category: {
|
|
500
|
+
level1: existing?.category_l1 || '',
|
|
501
|
+
level2: existing?.category_l2 || '',
|
|
502
|
+
level3: existing?.category_l3 || '',
|
|
503
|
+
},
|
|
504
|
+
location: {
|
|
505
|
+
latitude: existing?.latitude || 0,
|
|
506
|
+
longitude: existing?.longitude || 0,
|
|
507
|
+
city: existing?.city || '',
|
|
508
|
+
},
|
|
509
|
+
stock: Number(a.stock) || 0,
|
|
510
|
+
// 2026-09-07 kimi: 链上 list_sku 事件 emit 的是 adjusted_stake_per_unit, 不是 stake_per_unit
|
|
511
|
+
stakePerUnit: a.stake_per_unit || a.adjusted_stake_per_unit || '0',
|
|
512
|
+
images: existing?.images ? JSON.parse(existing.images) : [],
|
|
513
|
+
shipping: existing ? {
|
|
514
|
+
method: existing.shipping_method, fee: existing.shipping_fee, deliveryDays: existing.delivery_days,
|
|
515
|
+
} : { method: 'standard', fee: 0, deliveryDays: 3 },
|
|
516
|
+
createdAt: existing?.created_at || Date.now(),
|
|
517
|
+
updatedAt: Date.now(),
|
|
518
|
+
status: 'active',
|
|
519
|
+
});
|
|
520
|
+
// 2026-09-07 kimi: 持久化 slot_index — pause/resume/delist/add_stock/reduce_stock
|
|
521
|
+
// 事件只带 seller+slot_index (无 sku_id), 后续事件靠它反查
|
|
522
|
+
await client.query('UPDATE products SET slot_index = $1 WHERE sku_id = $2', [Number(a.slot_index ?? -1), skuId]);
|
|
523
|
+
break;
|
|
524
|
+
}
|
|
525
|
+
case 'pause_sku': {
|
|
526
|
+
const skuId = await this.resolveSkuId(client, a);
|
|
527
|
+
if (skuId)
|
|
528
|
+
await client.query("UPDATE products SET status = 'paused', updated_at = $1 WHERE sku_id = $2", [Date.now(), skuId]);
|
|
529
|
+
break;
|
|
530
|
+
}
|
|
531
|
+
case 'resume_sku': {
|
|
532
|
+
const skuId = await this.resolveSkuId(client, a);
|
|
533
|
+
if (skuId)
|
|
534
|
+
await client.query("UPDATE products SET status = 'active', updated_at = $1 WHERE sku_id = $2", [Date.now(), skuId]);
|
|
535
|
+
break;
|
|
536
|
+
}
|
|
537
|
+
case 'delist_sku': {
|
|
538
|
+
const skuId = await this.resolveSkuId(client, a);
|
|
539
|
+
if (skuId)
|
|
540
|
+
await client.query("UPDATE products SET status = 'delisted', updated_at = $1 WHERE sku_id = $2", [Date.now(), skuId]);
|
|
541
|
+
break;
|
|
542
|
+
}
|
|
543
|
+
case 'add_stock':
|
|
544
|
+
case 'reduce_stock': {
|
|
545
|
+
// 2026-09-07 kimi: 链上事件只带 seller+slot_index+quantity (无 sku_id, 无新 stock 总量),
|
|
546
|
+
// 正确语义 = 按 slot_index 反查商品后 stock ±= quantity
|
|
547
|
+
const skuId = await this.resolveSkuId(client, a);
|
|
548
|
+
if (!skuId)
|
|
549
|
+
break;
|
|
550
|
+
const delta = Number(a.quantity) || 0;
|
|
551
|
+
if (event.type === 'add_stock') {
|
|
552
|
+
await client.query('UPDATE products SET stock = stock + $1, updated_at = $2 WHERE sku_id = $3', [delta, Date.now(), skuId]);
|
|
553
|
+
}
|
|
554
|
+
else {
|
|
555
|
+
await client.query('UPDATE products SET stock = GREATEST(0, stock - $1), updated_at = $2 WHERE sku_id = $3', [delta, Date.now(), skuId]);
|
|
556
|
+
}
|
|
557
|
+
break;
|
|
558
|
+
}
|
|
559
|
+
case 'register_account': {
|
|
560
|
+
await this.indexSeller({
|
|
561
|
+
address: a.address,
|
|
562
|
+
reputation: 50,
|
|
563
|
+
totalStake: '0',
|
|
564
|
+
activeOrders: 0, completedOrders: 0, disputeRate: 0,
|
|
565
|
+
location: {
|
|
566
|
+
latitude: Number(a.latitude) || 0,
|
|
567
|
+
longitude: Number(a.longitude) || 0,
|
|
568
|
+
},
|
|
569
|
+
lastOnline: Date.now(),
|
|
570
|
+
registeredAt: Date.now(),
|
|
571
|
+
});
|
|
572
|
+
break;
|
|
573
|
+
}
|
|
574
|
+
case 'create_order': {
|
|
575
|
+
await this.indexOrder({
|
|
576
|
+
id: a.order_id,
|
|
577
|
+
buyer: a.buyer,
|
|
578
|
+
seller: a.seller,
|
|
579
|
+
skuId: a.sku_id,
|
|
580
|
+
quantity: 1,
|
|
581
|
+
totalPrice: a.total_amount || '0',
|
|
582
|
+
status: 'pending',
|
|
583
|
+
createdAt: Date.now(),
|
|
584
|
+
});
|
|
585
|
+
await client.query('UPDATE sellers SET active_orders = active_orders + 1 WHERE address = $1', [a.seller]);
|
|
586
|
+
if (a.sku_id) {
|
|
587
|
+
await client.query('UPDATE products SET order_count = order_count + 1, last_sale_at = $1 WHERE sku_id = $2', [Date.now(), a.sku_id]);
|
|
588
|
+
}
|
|
589
|
+
break;
|
|
590
|
+
}
|
|
591
|
+
case 'ship_order': {
|
|
592
|
+
await client.query("UPDATE orders SET status = 'shipped' WHERE id = $1", [a.order_id]);
|
|
593
|
+
break;
|
|
594
|
+
}
|
|
595
|
+
case 'confirm_order': {
|
|
596
|
+
await client.query("UPDATE orders SET status = 'confirmed' WHERE id = $1", [a.order_id]);
|
|
597
|
+
await client.query('UPDATE sellers SET active_orders = GREATEST(0, active_orders - 1), completed_orders = completed_orders + 1 WHERE address = $1', [a.seller]);
|
|
598
|
+
break;
|
|
599
|
+
}
|
|
600
|
+
case 'cancel_order': {
|
|
601
|
+
await client.query("UPDATE orders SET status = 'cancelled' WHERE id = $1", [a.order_id]);
|
|
602
|
+
await client.query('UPDATE sellers SET active_orders = GREATEST(0, active_orders - 1) WHERE address = $1', [a.seller]);
|
|
603
|
+
break;
|
|
604
|
+
}
|
|
605
|
+
case 'dispute_order': {
|
|
606
|
+
await client.query("UPDATE orders SET status = 'disputed' WHERE id = $1", [a.order_id]);
|
|
607
|
+
if (a.seller) {
|
|
608
|
+
const stats = (await client.query(`SELECT COUNT(*) as total, SUM(CASE WHEN status = 'disputed' THEN 1 ELSE 0 END) as disputed FROM orders WHERE seller = $1`, [a.seller])).rows[0];
|
|
609
|
+
if (stats && Number(stats.total) > 0) {
|
|
610
|
+
await client.query('UPDATE sellers SET dispute_rate = $1 WHERE address = $2', [(Number(stats.disputed) || 0) / Number(stats.total), a.seller]);
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
break;
|
|
614
|
+
}
|
|
615
|
+
case 'resolve_dispute': {
|
|
616
|
+
await client.query("UPDATE orders SET status = 'resolved' WHERE id = $1", [a.order_id]);
|
|
617
|
+
if (a.seller) {
|
|
618
|
+
const stats = (await client.query(`SELECT COUNT(*) as total, SUM(CASE WHEN status = 'disputed' THEN 1 ELSE 0 END) as disputed FROM orders WHERE seller = $1`, [a.seller])).rows[0];
|
|
619
|
+
if (stats && Number(stats.total) > 0) {
|
|
620
|
+
await client.query('UPDATE sellers SET dispute_rate = $1 WHERE address = $2', [(Number(stats.disputed) || 0) / Number(stats.total), a.seller]);
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
break;
|
|
624
|
+
}
|
|
625
|
+
case 'submit_review': {
|
|
626
|
+
await this.indexReview({
|
|
627
|
+
id: `${a.order_id}_${a.reviewer}`,
|
|
628
|
+
orderId: a.order_id || '',
|
|
629
|
+
fromAddress: a.reviewer || '',
|
|
630
|
+
toAddress: a.reviewed || '',
|
|
631
|
+
rating: (Number(a.rating) || 5),
|
|
632
|
+
content: a.content || '',
|
|
633
|
+
contentHash: a.content_hash || '',
|
|
634
|
+
createdAt: Date.now(),
|
|
635
|
+
});
|
|
636
|
+
if (a.reviewed) {
|
|
637
|
+
const delta = Number(a.rating) >= 4 ? 1 : -5;
|
|
638
|
+
await client.query('UPDATE sellers SET reputation = GREATEST(0, LEAST(100, reputation + $1)) WHERE address = $2', [delta, a.reviewed]);
|
|
639
|
+
}
|
|
640
|
+
break;
|
|
641
|
+
}
|
|
642
|
+
case 'register_brand': {
|
|
643
|
+
await client.query('UPDATE sellers SET moniker = $1 WHERE address = $2', [a.brand_name || '', a.owner || '']);
|
|
644
|
+
break;
|
|
645
|
+
}
|
|
646
|
+
case 'verify_brand': {
|
|
647
|
+
const brandOwner = a.owner || a.brand_owner;
|
|
648
|
+
if (brandOwner) {
|
|
649
|
+
await client.query('UPDATE products SET brand_auth_type = $1, updated_at = $2 WHERE seller = $3', [Number(a.auth_type) || 1, Date.now(), brandOwner]);
|
|
650
|
+
}
|
|
651
|
+
break;
|
|
652
|
+
}
|
|
653
|
+
case 'revoke_brand': {
|
|
654
|
+
const brandOwner2 = a.owner || a.brand_owner;
|
|
655
|
+
if (brandOwner2) {
|
|
656
|
+
await client.query('UPDATE products SET brand_auth_type = 0, updated_at = $1 WHERE seller = $2', [Date.now(), brandOwner2]);
|
|
657
|
+
}
|
|
658
|
+
break;
|
|
659
|
+
}
|
|
660
|
+
case 'verify_identity': {
|
|
661
|
+
if (a.address) {
|
|
662
|
+
await client.query('UPDATE sellers SET reputation = LEAST(100, reputation + 5) WHERE address = $1', [a.address]);
|
|
663
|
+
}
|
|
664
|
+
break;
|
|
665
|
+
}
|
|
666
|
+
case 'transfer_tct': {
|
|
667
|
+
if (a.recipient) {
|
|
668
|
+
await client.query("UPDATE sellers SET total_stake = CAST(CAST(total_stake AS INTEGER) + $1 AS TEXT) WHERE address = $2", [a.amount || '0', a.recipient]);
|
|
669
|
+
}
|
|
670
|
+
break;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
// ---- Public Service ----
|
|
675
|
+
async handleQuery(query) {
|
|
676
|
+
return this.search(query);
|
|
677
|
+
}
|
|
678
|
+
getStatus() {
|
|
679
|
+
return {
|
|
680
|
+
totalProducts: 0,
|
|
681
|
+
totalSellers: 0,
|
|
682
|
+
totalReviews: 0,
|
|
683
|
+
totalOrders: 0,
|
|
684
|
+
syncedHeight: this.syncedHeight,
|
|
685
|
+
indexerTier: this.tier,
|
|
686
|
+
dbSizeBytes: 0,
|
|
687
|
+
uptimeSeconds: Math.floor((Date.now() - this.startTime) / 1000),
|
|
688
|
+
queriesPerSecond: 0,
|
|
689
|
+
};
|
|
690
|
+
}
|
|
691
|
+
// ---- Helpers ----
|
|
692
|
+
rowToProduct(row) {
|
|
693
|
+
return {
|
|
694
|
+
skuId: row.sku_id,
|
|
695
|
+
seller: row.seller,
|
|
696
|
+
title: row.title,
|
|
697
|
+
description: row.description,
|
|
698
|
+
contentHash: row.content_hash,
|
|
699
|
+
priceCny: row.price_cny,
|
|
700
|
+
priceTct: row.price_tct || undefined,
|
|
701
|
+
category: {
|
|
702
|
+
level1: row.category_l1,
|
|
703
|
+
level2: row.category_l2,
|
|
704
|
+
level3: row.category_l3 || undefined,
|
|
705
|
+
},
|
|
706
|
+
location: {
|
|
707
|
+
latitude: row.latitude,
|
|
708
|
+
longitude: row.longitude,
|
|
709
|
+
city: row.city || undefined,
|
|
710
|
+
},
|
|
711
|
+
stock: row.stock,
|
|
712
|
+
stakePerUnit: row.stake_per_unit,
|
|
713
|
+
images: JSON.parse(row.images || '[]'),
|
|
714
|
+
shipping: {
|
|
715
|
+
method: row.shipping_method,
|
|
716
|
+
fee: row.shipping_fee,
|
|
717
|
+
deliveryDays: row.delivery_days,
|
|
718
|
+
},
|
|
719
|
+
createdAt: row.created_at,
|
|
720
|
+
updatedAt: row.updated_at,
|
|
721
|
+
status: row.status,
|
|
722
|
+
};
|
|
723
|
+
}
|
|
724
|
+
rowToSeller(row) {
|
|
725
|
+
return {
|
|
726
|
+
address: row.address || row.seller,
|
|
727
|
+
moniker: row.moniker,
|
|
728
|
+
reputation: row.reputation,
|
|
729
|
+
totalStake: row.total_stake,
|
|
730
|
+
activeOrders: row.active_orders,
|
|
731
|
+
completedOrders: row.completed_orders,
|
|
732
|
+
disputeRate: row.dispute_rate,
|
|
733
|
+
location: {
|
|
734
|
+
latitude: row.s_lat || row.latitude || 0,
|
|
735
|
+
longitude: row.s_lon || row.longitude || 0,
|
|
736
|
+
},
|
|
737
|
+
lastOnline: row.last_online,
|
|
738
|
+
registeredAt: row.registered_at,
|
|
739
|
+
};
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
exports.PostgreSQLPlugin = PostgreSQLPlugin;
|
|
743
|
+
//# sourceMappingURL=postgresql.js.map
|