@harrylabsj/kiwi 0.12.26 → 0.12.28
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/README.md +9 -2
- package/contracts/kiwi-catalog/1.0/agent-record.schema.json +29 -0
- package/contracts/kiwi-contracts.lock.json +2 -2
- package/contracts/manifest.json +2 -2
- package/dist/a2a/admission.d.ts +35 -0
- package/dist/a2a/admission.js +75 -0
- package/dist/a2a/admission.js.map +1 -0
- package/dist/a2a/node.d.ts +11 -8
- package/dist/a2a/node.js +78 -35
- package/dist/a2a/node.js.map +1 -1
- package/dist/a2a/reception/agent-runtime.js +9 -3
- package/dist/a2a/reception/agent-runtime.js.map +1 -1
- package/dist/a2a/reception/engine.js +6 -1
- package/dist/a2a/reception/engine.js.map +1 -1
- package/dist/a2a/reception/reply-outbox.d.ts +6 -0
- package/dist/a2a/reception/reply-outbox.js +13 -0
- package/dist/a2a/reception/reply-outbox.js.map +1 -1
- package/dist/a2a/reception/retention.d.ts +1 -0
- package/dist/a2a/reception/retention.js +9 -1
- package/dist/a2a/reception/retention.js.map +1 -1
- package/dist/a2a/server/auth.js +22 -3
- package/dist/a2a/server/auth.js.map +1 -1
- package/dist/a2a/server/identity.d.ts +23 -0
- package/dist/a2a/server/identity.js +27 -0
- package/dist/a2a/server/identity.js.map +1 -0
- package/dist/a2a/server/merchant-handler.d.ts +0 -11
- package/dist/a2a/server/merchant-handler.js +34 -12
- package/dist/a2a/server/merchant-handler.js.map +1 -1
- package/dist/a2a/server/negotiation-advisor.js +3 -1
- package/dist/a2a/server/negotiation-advisor.js.map +1 -1
- package/dist/a2a/server/pipeline.d.ts +7 -1
- package/dist/a2a/server/pipeline.js +65 -35
- package/dist/a2a/server/pipeline.js.map +1 -1
- package/dist/a2a/server/server.d.ts +0 -17
- package/dist/a2a/server/server.js +23 -4
- package/dist/a2a/server/server.js.map +1 -1
- package/dist/a2a/server/task-registry.d.ts +3 -0
- package/dist/a2a/server/task-registry.js +33 -1
- package/dist/a2a/server/task-registry.js.map +1 -1
- package/dist/a2a/throttle-config.d.ts +24 -0
- package/dist/a2a/throttle-config.js +33 -0
- package/dist/a2a/throttle-config.js.map +1 -0
- package/dist/agent/buyer/buyer-tools.js +33 -19
- package/dist/agent/buyer/buyer-tools.js.map +1 -1
- package/dist/agent/buyer/ranker.js +32 -14
- package/dist/agent/buyer/ranker.js.map +1 -1
- package/dist/agent/buyer/scheduler.js +12 -3
- package/dist/agent/buyer/scheduler.js.map +1 -1
- package/dist/agent/buyer/types.d.ts +2 -1
- package/dist/agent/buyer/types.js.map +1 -1
- package/dist/agent/connector/types.d.ts +4 -2
- package/dist/agent/connector/types.js +8 -2
- package/dist/agent/connector/types.js.map +1 -1
- package/dist/agent/host/events.js +1 -1
- package/dist/agent/host/events.js.map +1 -1
- package/dist/agent/kernel-builder.d.ts +7 -1
- package/dist/agent/kernel-builder.js +8 -6
- package/dist/agent/kernel-builder.js.map +1 -1
- package/dist/agent/kernel.d.ts +10 -0
- package/dist/agent/kernel.js +27 -15
- package/dist/agent/kernel.js.map +1 -1
- package/dist/agent/merchant/merchant-tools.d.ts +5 -0
- package/dist/agent/merchant/merchant-tools.js +6 -2
- package/dist/agent/merchant/merchant-tools.js.map +1 -1
- package/dist/agent/merchant/read-only-tools.d.ts +17 -0
- package/dist/agent/merchant/read-only-tools.js +27 -0
- package/dist/agent/merchant/read-only-tools.js.map +1 -0
- package/dist/agent/negotiation-chat.js +6 -4
- package/dist/agent/negotiation-chat.js.map +1 -1
- package/dist/agent/presentation/sanitize.js +1 -1
- package/dist/agent/presentation/sanitize.js.map +1 -1
- package/dist/agent/supplier/scheduler.js.map +1 -1
- package/dist/auth/merchant-oauth.d.ts +10 -0
- package/dist/auth/merchant-oauth.js +53 -4
- package/dist/auth/merchant-oauth.js.map +1 -1
- package/dist/auth/merchant-pairing.js +5 -0
- package/dist/auth/merchant-pairing.js.map +1 -1
- package/dist/auth/merchant-scopes.d.ts +33 -0
- package/dist/auth/merchant-scopes.js +39 -0
- package/dist/auth/merchant-scopes.js.map +1 -0
- package/dist/auth/merchant-sessions.js +19 -4
- package/dist/auth/merchant-sessions.js.map +1 -1
- package/dist/buyer-core/a2a-negotiator.d.ts +7 -0
- package/dist/buyer-core/a2a-negotiator.js +17 -3
- package/dist/buyer-core/a2a-negotiator.js.map +1 -1
- package/dist/buyer-core/a2a-quote-fetcher.d.ts +22 -0
- package/dist/buyer-core/a2a-quote-fetcher.js +71 -3
- package/dist/buyer-core/a2a-quote-fetcher.js.map +1 -1
- package/dist/buyer-core/build-service.d.ts +7 -0
- package/dist/buyer-core/build-service.js +249 -22
- package/dist/buyer-core/build-service.js.map +1 -1
- package/dist/buyer-core/buyer-route-hint-store.d.ts +21 -0
- package/dist/buyer-core/buyer-route-hint-store.js +119 -0
- package/dist/buyer-core/buyer-route-hint-store.js.map +1 -0
- package/dist/buyer-core/merchant-index.js +7 -2
- package/dist/buyer-core/merchant-index.js.map +1 -1
- package/dist/buyer-core/service.d.ts +15 -0
- package/dist/buyer-core/service.js +34 -9
- package/dist/buyer-core/service.js.map +1 -1
- package/dist/buyer-core/stale-merchant-wake.d.ts +27 -0
- package/dist/buyer-core/stale-merchant-wake.js +117 -0
- package/dist/buyer-core/stale-merchant-wake.js.map +1 -0
- package/dist/buyer-core/store.d.ts +11 -0
- package/dist/buyer-core/store.js +68 -0
- package/dist/buyer-core/store.js.map +1 -1
- package/dist/cli.js +61 -8
- package/dist/cli.js.map +1 -1
- package/dist/cloud/access/access-mode.d.ts +56 -0
- package/dist/cloud/access/access-mode.js +129 -0
- package/dist/cloud/access/access-mode.js.map +1 -0
- package/dist/cloud/binding/enrollment-challenge.js +3 -2
- package/dist/cloud/binding/enrollment-challenge.js.map +1 -1
- package/dist/cloud/binding/runtime-challenge.js +3 -2
- package/dist/cloud/binding/runtime-challenge.js.map +1 -1
- package/dist/cloud/binding/store-lock.js +16 -7
- package/dist/cloud/binding/store-lock.js.map +1 -1
- package/dist/cloud/bootstrap.d.ts +1 -1
- package/dist/cloud/bootstrap.js +62 -8
- package/dist/cloud/bootstrap.js.map +1 -1
- package/dist/cloud/catalog-client.d.ts +25 -1
- package/dist/cloud/catalog-client.js +163 -4
- package/dist/cloud/catalog-client.js.map +1 -1
- package/dist/cloud/config.d.ts +14 -0
- package/dist/cloud/config.js +30 -0
- package/dist/cloud/config.js.map +1 -1
- package/dist/cloud/connect-service.d.ts +69 -0
- package/dist/cloud/connect-service.js +418 -50
- package/dist/cloud/connect-service.js.map +1 -1
- package/dist/cloud/file-listing-publication.d.ts +3 -0
- package/dist/cloud/file-listing-publication.js +2 -2
- package/dist/cloud/file-listing-publication.js.map +1 -1
- package/dist/cloud/owned-runtime.js +21 -2
- package/dist/cloud/owned-runtime.js.map +1 -1
- package/dist/cloud/product-import-tabular.d.ts +6 -2
- package/dist/cloud/product-import-tabular.js +57 -41
- package/dist/cloud/product-import-tabular.js.map +1 -1
- package/dist/cloud/product-source.d.ts +6 -3
- package/dist/cloud/product-source.js +8 -8
- package/dist/cloud/product-source.js.map +1 -1
- package/dist/cloud/trade-platforms-client.d.ts +8 -0
- package/dist/cloud/trade-platforms-client.js +28 -0
- package/dist/cloud/trade-platforms-client.js.map +1 -0
- package/dist/commerce/types.d.ts +6 -2
- package/dist/commerce/types.js +10 -3
- package/dist/commerce/types.js.map +1 -1
- package/dist/config/profile.d.ts +24 -0
- package/dist/config/profile.js +45 -3
- package/dist/config/profile.js.map +1 -1
- package/dist/counterparty/shopping-cli-hosted/index.js +20 -12
- package/dist/counterparty/shopping-cli-hosted/index.js.map +1 -1
- package/dist/discovery/catalog-source/kiwi-record.d.ts +23 -0
- package/dist/discovery/catalog-source/kiwi-record.js.map +1 -1
- package/dist/discovery/catalog-source/kiwi-source.js +4 -1
- package/dist/discovery/catalog-source/kiwi-source.js.map +1 -1
- package/dist/discovery/merchant-subscriptions.js +9 -0
- package/dist/discovery/merchant-subscriptions.js.map +1 -1
- package/dist/handoff/channel.js +3 -1
- package/dist/handoff/channel.js.map +1 -1
- package/dist/handoff/idempotency.d.ts +6 -0
- package/dist/handoff/idempotency.js +71 -18
- package/dist/handoff/idempotency.js.map +1 -1
- package/dist/handoff/launch-marketplace-policy.d.ts +1 -1
- package/dist/handoff/launch-marketplace-policy.js +9 -1
- package/dist/handoff/launch-marketplace-policy.js.map +1 -1
- package/dist/handoff/ledger.d.ts +6 -1
- package/dist/handoff/ledger.js +13 -2
- package/dist/handoff/ledger.js.map +1 -1
- package/dist/handoff/marketplace-product-link.d.ts +17 -6
- package/dist/handoff/marketplace-product-link.js +27 -37
- package/dist/handoff/marketplace-product-link.js.map +1 -1
- package/dist/handoff/operator-approval.d.ts +3 -0
- package/dist/handoff/operator-approval.js +34 -1
- package/dist/handoff/operator-approval.js.map +1 -1
- package/dist/handoff/trade-platform-rules.d.ts +26 -0
- package/dist/handoff/trade-platform-rules.js +95 -0
- package/dist/handoff/trade-platform-rules.js.map +1 -0
- package/dist/handoff/transaction.d.ts +5 -0
- package/dist/handoff/transaction.js +7 -1
- package/dist/handoff/transaction.js.map +1 -1
- package/dist/handoff/ucp-checkout/channel.d.ts +14 -0
- package/dist/handoff/ucp-checkout/channel.js +87 -1
- package/dist/handoff/ucp-checkout/channel.js.map +1 -1
- package/dist/handoff/ucp-checkout/types.d.ts +1 -1
- package/dist/handoff/ucp-checkout/types.js +3 -0
- package/dist/handoff/ucp-checkout/types.js.map +1 -1
- package/dist/handoff/url-safety.js +8 -1
- package/dist/handoff/url-safety.js.map +1 -1
- package/dist/http/bounded-ip-rate-limit.js +16 -2
- package/dist/http/bounded-ip-rate-limit.js.map +1 -1
- package/dist/http/merchant-management/api.d.ts +23 -0
- package/dist/http/merchant-management/api.js +132 -5
- package/dist/http/merchant-management/api.js.map +1 -1
- package/dist/http/merchant-management/page.js +274 -39
- package/dist/http/merchant-management/page.js.map +1 -1
- package/dist/http/merchant-management/trusted-page.js +5 -3
- package/dist/http/merchant-management/trusted-page.js.map +1 -1
- package/dist/http/merchant-privacy-api.js +24 -0
- package/dist/http/merchant-privacy-api.js.map +1 -1
- package/dist/http/merchant-server.js +13 -4
- package/dist/http/merchant-server.js.map +1 -1
- package/dist/http/server.js +25 -5
- package/dist/http/server.js.map +1 -1
- package/dist/mcp/cli.d.ts +2 -0
- package/dist/mcp/cli.js +11 -0
- package/dist/mcp/cli.js.map +1 -1
- package/dist/mcp/merchant-auth.d.ts +30 -0
- package/dist/mcp/merchant-auth.js +72 -0
- package/dist/mcp/merchant-auth.js.map +1 -1
- package/dist/mcp/merchant-conversation.d.ts +91 -0
- package/dist/mcp/merchant-conversation.js +207 -0
- package/dist/mcp/merchant-conversation.js.map +1 -0
- package/dist/mcp/merchant-runtime-assembly.d.ts +3 -1
- package/dist/mcp/merchant-runtime-assembly.js +74 -7
- package/dist/mcp/merchant-runtime-assembly.js.map +1 -1
- package/dist/mcp/merchant-server.d.ts +22 -2
- package/dist/mcp/merchant-server.js +53 -10
- package/dist/mcp/merchant-server.js.map +1 -1
- package/dist/mcp/merchant-tools.d.ts +6 -12
- package/dist/mcp/merchant-tools.js +129 -8
- package/dist/mcp/merchant-tools.js.map +1 -1
- package/dist/mcp/read-audit.d.ts +63 -0
- package/dist/mcp/read-audit.js +111 -0
- package/dist/mcp/read-audit.js.map +1 -0
- package/dist/merchant/ai-runtime/owner-sdk-tools.d.ts +1 -1
- package/dist/merchant/ai-runtime/owner-storage-admission.js +11 -7
- package/dist/merchant/ai-runtime/owner-storage-admission.js.map +1 -1
- package/dist/merchant/application/service.d.ts +2 -1
- package/dist/merchant/application/service.js.map +1 -1
- package/dist/merchant/decision-backend.js +24 -2
- package/dist/merchant/decision-backend.js.map +1 -1
- package/dist/merchant/negotiation-observer.js +12 -2
- package/dist/merchant/negotiation-observer.js.map +1 -1
- package/dist/merchant/operations-report.d.ts +12 -0
- package/dist/merchant/operations-report.js +17 -0
- package/dist/merchant/operations-report.js.map +1 -1
- package/dist/merchant/watch/detect.js +14 -0
- package/dist/merchant/watch/detect.js.map +1 -1
- package/dist/merchant/watch/weixin.js +7 -1
- package/dist/merchant/watch/weixin.js.map +1 -1
- package/dist/merchant/workbench-service.d.ts +45 -3
- package/dist/merchant/workbench-service.js +119 -4
- package/dist/merchant/workbench-service.js.map +1 -1
- package/dist/merchant-core/commands.d.ts +5 -0
- package/dist/merchant-core/commands.js +19 -0
- package/dist/merchant-core/commands.js.map +1 -1
- package/dist/merchant-core/executor.js +3 -2
- package/dist/merchant-core/executor.js.map +1 -1
- package/dist/merchant-core/operating/service.js +9 -0
- package/dist/merchant-core/operating/service.js.map +1 -1
- package/dist/merchant-core/operations.js +18 -4
- package/dist/merchant-core/operations.js.map +1 -1
- package/dist/merchant-core/opportunity/service.js +9 -0
- package/dist/merchant-core/opportunity/service.js.map +1 -1
- package/dist/merchant-core/orders/repository.js +8 -0
- package/dist/merchant-core/orders/repository.js.map +1 -1
- package/dist/merchant-core/product-import.d.ts +9 -0
- package/dist/merchant-core/product-import.js +17 -3
- package/dist/merchant-core/product-import.js.map +1 -1
- package/dist/merchant-core/proposal/service.js +9 -0
- package/dist/merchant-core/proposal/service.js.map +1 -1
- package/dist/merchant-core/rfq/delivery.js +1 -1
- package/dist/merchant-core/rfq/delivery.js.map +1 -1
- package/dist/merchant-core/rfq/handoff.js +2 -3
- package/dist/merchant-core/rfq/handoff.js.map +1 -1
- package/dist/merchant-core/rfq/policy.d.ts +0 -8
- package/dist/merchant-core/rfq/policy.js +6 -1
- package/dist/merchant-core/rfq/policy.js.map +1 -1
- package/dist/merchant-core/rfq/repository.d.ts +2 -0
- package/dist/merchant-core/rfq/repository.js +10 -1
- package/dist/merchant-core/rfq/repository.js.map +1 -1
- package/dist/merchant-core/service.d.ts +7 -0
- package/dist/merchant-core/service.js +33 -3
- package/dist/merchant-core/service.js.map +1 -1
- package/dist/merchant-core/storage/redact.js +3 -0
- package/dist/merchant-core/storage/redact.js.map +1 -1
- package/dist/merchant-gateway/cli.js +9 -1
- package/dist/merchant-gateway/cli.js.map +1 -1
- package/dist/merchant-gateway/credential-vault.d.ts +3 -0
- package/dist/merchant-gateway/credential-vault.js +54 -10
- package/dist/merchant-gateway/credential-vault.js.map +1 -1
- package/dist/merchant-gateway/entry-server.js +15 -4
- package/dist/merchant-gateway/entry-server.js.map +1 -1
- package/dist/merchant-gateway/instance-tool-policy.d.ts +23 -0
- package/dist/merchant-gateway/instance-tool-policy.js +26 -0
- package/dist/merchant-gateway/instance-tool-policy.js.map +1 -0
- package/dist/merchant-runtime/manager.d.ts +2 -0
- package/dist/merchant-runtime/manager.js +49 -1
- package/dist/merchant-runtime/manager.js.map +1 -1
- package/dist/negotiation/ledger/store.js +6 -3
- package/dist/negotiation/ledger/store.js.map +1 -1
- package/dist/net/client-ip.d.ts +29 -0
- package/dist/net/client-ip.js +39 -0
- package/dist/net/client-ip.js.map +1 -0
- package/dist/net/safe-http.d.ts +1 -1
- package/dist/net/safe-http.js +8 -0
- package/dist/net/safe-http.js.map +1 -1
- package/dist/operator/controller.js +3 -1
- package/dist/operator/controller.js.map +1 -1
- package/dist/operator/runner.js +1 -1
- package/dist/operator/runner.js.map +1 -1
- package/dist/operator/tui.js +10 -3
- package/dist/operator/tui.js.map +1 -1
- package/dist/product-buyer.js +1 -0
- package/dist/product-buyer.js.map +1 -1
- package/dist/product-cli.js +2 -1
- package/dist/product-cli.js.map +1 -1
- package/dist/protocol/legacy-shopping-negotiation/adapter.js +9 -0
- package/dist/protocol/legacy-shopping-negotiation/adapter.js.map +1 -1
- package/dist/runtime/bounded-memory.d.ts +25 -0
- package/dist/runtime/bounded-memory.js +60 -0
- package/dist/runtime/bounded-memory.js.map +1 -0
- package/dist/runtime/fake-model.js +7 -1
- package/dist/runtime/fake-model.js.map +1 -1
- package/dist/runtime/lock-owner.d.ts +36 -0
- package/dist/runtime/lock-owner.js +98 -0
- package/dist/runtime/lock-owner.js.map +1 -0
- package/dist/runtime/locks-cli.d.ts +21 -0
- package/dist/runtime/locks-cli.js +94 -0
- package/dist/runtime/locks-cli.js.map +1 -0
- package/dist/runtime/locks.d.ts +60 -0
- package/dist/runtime/locks.js +202 -0
- package/dist/runtime/locks.js.map +1 -0
- package/dist/runtime/negotiation-turn.js +1 -1
- package/dist/runtime/negotiation-turn.js.map +1 -1
- package/dist/runtime/tools.d.ts +1 -1
- package/dist/trust/identity/auth-verifier.d.ts +23 -21
- package/dist/trust/identity/auth-verifier.js +65 -1
- package/dist/trust/identity/auth-verifier.js.map +1 -1
- package/dist/trust/identity/jwk.d.ts +1 -0
- package/dist/trust/identity/signature-base.js +3 -1
- package/dist/trust/identity/signature-base.js.map +1 -1
- package/dist/trust/records/store.d.ts +7 -1
- package/dist/trust/records/store.js +44 -14
- package/dist/trust/records/store.js.map +1 -1
- package/dist/weixin/brand.d.ts +19 -0
- package/dist/weixin/brand.js +28 -0
- package/dist/weixin/brand.js.map +1 -0
- package/dist/weixin/channel.js +11 -1
- package/dist/weixin/channel.js.map +1 -1
- package/dist/weixin/ilink-client.d.ts +16 -3
- package/dist/weixin/ilink-client.js +39 -6
- package/dist/weixin/ilink-client.js.map +1 -1
- package/dist/weixin/login.d.ts +3 -1
- package/dist/weixin/login.js +82 -46
- package/dist/weixin/login.js.map +1 -1
- package/dist/weixin/types.d.ts +16 -1
- package/dist/weixin/types.js.map +1 -1
- package/dist/workbuddy-adapter/binding.d.ts +19 -0
- package/dist/workbuddy-adapter/binding.js +66 -0
- package/dist/workbuddy-adapter/binding.js.map +1 -0
- package/dist/workbuddy-adapter/cli.d.ts +31 -0
- package/dist/workbuddy-adapter/cli.js +754 -0
- package/dist/workbuddy-adapter/cli.js.map +1 -0
- package/dist/workbuddy-adapter/client-cache.d.ts +11 -0
- package/dist/workbuddy-adapter/client-cache.js +17 -0
- package/dist/workbuddy-adapter/client-cache.js.map +1 -0
- package/dist/workbuddy-adapter/index.d.ts +7 -0
- package/dist/workbuddy-adapter/index.js +8 -0
- package/dist/workbuddy-adapter/index.js.map +1 -0
- package/dist/workbuddy-adapter/mcp-client.d.ts +34 -0
- package/dist/workbuddy-adapter/mcp-client.js +167 -0
- package/dist/workbuddy-adapter/mcp-client.js.map +1 -0
- package/dist/workbuddy-adapter/oauth.d.ts +84 -0
- package/dist/workbuddy-adapter/oauth.js +327 -0
- package/dist/workbuddy-adapter/oauth.js.map +1 -0
- package/dist/workbuddy-adapter/token-store.d.ts +35 -0
- package/dist/workbuddy-adapter/token-store.js +137 -0
- package/dist/workbuddy-adapter/token-store.js.map +1 -0
- package/dist/workbuddy-adapter/write-lock.d.ts +19 -0
- package/dist/workbuddy-adapter/write-lock.js +90 -0
- package/dist/workbuddy-adapter/write-lock.js.map +1 -0
- package/package.json +21 -15
- package/skills/kiwi-buyer/SKILL.md +10 -2
|
@@ -43,13 +43,15 @@ import { ADMIN_SESSION_COOKIE } from "../../auth/merchant-sessions.js";
|
|
|
43
43
|
import { FileListingPublicationError, } from "../../cloud/file-listing-publication.js";
|
|
44
44
|
import { parseProductTable, ProductTableError, productTableDigest, } from "../../cloud/product-source.js";
|
|
45
45
|
import { convertTabularImport, renderImportTemplateCsv, renderImportTemplateXlsx, TABULAR_IMPORT_MAX_BYTES, } from "../../cloud/product-import-tabular.js";
|
|
46
|
+
import { normalizeTradePlatformRules, } from "../../handoff/trade-platform-rules.js";
|
|
46
47
|
import { MerchantImportDraftStore } from "./draft-store.js";
|
|
47
48
|
import { ActorContextError, assertVerifiedActor, createVerifiedActorContext, hasPermission, } from "../../merchant/application/actor.js";
|
|
48
49
|
import { MANAGEMENT_API_MAJOR, MANAGEMENT_ERROR_STATUS, ManagementError, MerchantApplicationService, } from "../../merchant/application/service.js";
|
|
49
50
|
import { managementRequestDigest, MerchantManagementOperationStore } from "./operation-store.js";
|
|
50
51
|
import { OnboardingStore } from "../../cloud/onboarding/store.js";
|
|
51
52
|
import { readEnrollmentStore } from "../../cloud/binding/enrollment-challenge.js";
|
|
52
|
-
import { MerchantConnectError } from "../../cloud/connect-service.js";
|
|
53
|
+
import { MerchantConnectError, } from "../../cloud/connect-service.js";
|
|
54
|
+
import { isMerchantAccessMode, } from "../../cloud/access/access-mode.js";
|
|
53
55
|
import { requestsDisabledLocalImplementation } from "../../cloud/onboarding/local-fallback.js";
|
|
54
56
|
import { checkStepSubmission, planWizard, WIZARD_STEPS } from "../../cloud/onboarding/steps.js";
|
|
55
57
|
import { createWorkbenchProblem } from "./problem.js";
|
|
@@ -94,12 +96,23 @@ const CATALOG_CONNECTION_SAFE_CODES = new Set([
|
|
|
94
96
|
*/
|
|
95
97
|
const CONNECT_BEGIN_PRE_EFFECT_CODES = new Set([
|
|
96
98
|
"CATALOG_MISMATCH", "STATE_INVALID", "PREVIEW_CHANGED", "RUNTIME_CARD_CHANGED",
|
|
99
|
+
// 接入方式/公开名片读取发生在本机,且在任何 create enrollment 之前:
|
|
100
|
+
// 失败没有不确定的远端副作用,商家修正后可用同一幂等键重试。
|
|
101
|
+
"ACCESS_SHARE_LINK_REQUIRED", "ACCESS_MODE_UNCERTAIN",
|
|
97
102
|
]);
|
|
98
103
|
const MAX_BODY_BYTES = 1_048_576;
|
|
99
104
|
/** 非候选写命令确认引用的有效期(BD §7.3:短时、单次)。 */
|
|
100
105
|
const CONFIRMATION_TTL_MS = 5 * 60 * 1000;
|
|
101
106
|
class BodyTooLarge {
|
|
102
107
|
}
|
|
108
|
+
async function resolvePlatformRules(options) {
|
|
109
|
+
try {
|
|
110
|
+
return normalizeTradePlatformRules(await options.marketplacePlatforms?.());
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
return normalizeTradePlatformRules(undefined);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
103
116
|
export function createMerchantManagementApiHandler(options) {
|
|
104
117
|
const log = options.log ??
|
|
105
118
|
((line) => {
|
|
@@ -244,6 +257,17 @@ export function createMerchantManagementApiHandler(options) {
|
|
|
244
257
|
await runAccessRoute(res, requestId, () => channel.getAccess());
|
|
245
258
|
return;
|
|
246
259
|
}
|
|
260
|
+
if (rest === "/catalog/bound-account") {
|
|
261
|
+
const auth = requireActor(req);
|
|
262
|
+
authorizeOrThrow(auth.ctx, "onboarding:manage");
|
|
263
|
+
if (auth.ctx.role !== "owner")
|
|
264
|
+
throw new ManagementError("forbidden", "only owner can view the bound account");
|
|
265
|
+
const read = options.catalogConnection?.readBoundAccount;
|
|
266
|
+
if (read === undefined)
|
|
267
|
+
throw new ManagementError("unavailable", "目录账户信息不可用");
|
|
268
|
+
writeJson(res, 200, { email: await read() }, { "x-request-id": requestId, "cache-control": "no-store" });
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
247
271
|
if (rest === "/catalog/connect" || rest === "/catalog/connect/pairing") {
|
|
248
272
|
const auth = requireActor(req);
|
|
249
273
|
authorizeOrThrow(auth.ctx, "onboarding:manage");
|
|
@@ -332,6 +356,13 @@ export function createMerchantManagementApiHandler(options) {
|
|
|
332
356
|
}, { "x-request-id": requestId });
|
|
333
357
|
return;
|
|
334
358
|
}
|
|
359
|
+
if (rest === "/policy") {
|
|
360
|
+
// Workbench 页面(v1)与旧 v0 页面读取同一份脱敏策略投影;
|
|
361
|
+
// 此前 v1 缺少该路由,商家后台「报价规则」报 API 路由不存在。
|
|
362
|
+
const auth = requireActor(req);
|
|
363
|
+
writeJson(res, 200, await readService.getPolicy(auth.ctx), { "x-request-id": requestId });
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
335
366
|
if (rest === "/runtime/status") {
|
|
336
367
|
const auth = requireActor(req);
|
|
337
368
|
writeJson(res, 200, {
|
|
@@ -373,8 +404,9 @@ export function createMerchantManagementApiHandler(options) {
|
|
|
373
404
|
res.end();
|
|
374
405
|
return;
|
|
375
406
|
}
|
|
407
|
+
const platforms = await resolvePlatformRules(options);
|
|
376
408
|
if (format === "csv") {
|
|
377
|
-
const body = renderImportTemplateCsv();
|
|
409
|
+
const body = renderImportTemplateCsv(platforms);
|
|
378
410
|
res.writeHead(200, {
|
|
379
411
|
"content-type": "text/csv; charset=utf-8",
|
|
380
412
|
"content-disposition": 'attachment; filename="kiwi-product-import-template.csv"',
|
|
@@ -384,7 +416,7 @@ export function createMerchantManagementApiHandler(options) {
|
|
|
384
416
|
res.end(body);
|
|
385
417
|
return;
|
|
386
418
|
}
|
|
387
|
-
const bytes = renderImportTemplateXlsx();
|
|
419
|
+
const bytes = renderImportTemplateXlsx(platforms);
|
|
388
420
|
res.writeHead(200, {
|
|
389
421
|
"content-type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
390
422
|
"content-disposition": 'attachment; filename="kiwi-product-import-template.xlsx"',
|
|
@@ -878,13 +910,47 @@ export function createMerchantManagementApiHandler(options) {
|
|
|
878
910
|
}
|
|
879
911
|
if (rest === "/catalog/access/refresh" ||
|
|
880
912
|
rest === "/catalog/access/share-link" ||
|
|
881
|
-
rest === "/catalog/access/revoke"
|
|
913
|
+
rest === "/catalog/access/revoke" ||
|
|
914
|
+
rest === "/catalog/access/mode" ||
|
|
915
|
+
rest === "/catalog/access/detect") {
|
|
882
916
|
const auth = requireActor(req);
|
|
883
917
|
assertWriteGuards(req, auth.sessionId);
|
|
884
918
|
authorizeOrThrow(auth.ctx, "onboarding:manage");
|
|
885
919
|
if (auth.ctx.role !== "owner")
|
|
886
920
|
throw new ManagementError("forbidden", "only owner can manage Catalog access");
|
|
887
921
|
const channel = options.catalogConnection;
|
|
922
|
+
if (rest === "/catalog/access/mode") {
|
|
923
|
+
if (channel?.setAccessMode === undefined) {
|
|
924
|
+
throw new ManagementError("unavailable", "Catalog access configuration is not configured");
|
|
925
|
+
}
|
|
926
|
+
const fields = objectFields(await readJsonBody(req), ["mode"]);
|
|
927
|
+
const mode = fields["mode"];
|
|
928
|
+
if (!isMerchantAccessMode(mode)) {
|
|
929
|
+
throw new ManagementError("invalid_input", "接入方式必须是 auto、share_code 或 no_share_code");
|
|
930
|
+
}
|
|
931
|
+
await runAccessRoute(res, requestId, () => channel.setAccessMode(mode));
|
|
932
|
+
return;
|
|
933
|
+
}
|
|
934
|
+
if (rest === "/catalog/access/detect") {
|
|
935
|
+
if (channel?.detectAccess === undefined) {
|
|
936
|
+
throw new ManagementError("unavailable", "Catalog access configuration is not configured");
|
|
937
|
+
}
|
|
938
|
+
// 探测目标固定为运行时已验证的 publicOrigin;请求体不允许携带 URL、
|
|
939
|
+
// 分享码或任何目标,避免把公开探测变成任意 SSRF/凭据试探入口。
|
|
940
|
+
objectFields(await readJsonBody(req), []);
|
|
941
|
+
let detection;
|
|
942
|
+
try {
|
|
943
|
+
detection = await channel.detectAccess();
|
|
944
|
+
}
|
|
945
|
+
catch {
|
|
946
|
+
throw new ManagementError("unavailable", "接入方式检测未完成,请稍后重试。");
|
|
947
|
+
}
|
|
948
|
+
writeJson(res, 200, { detection }, {
|
|
949
|
+
"x-request-id": requestId,
|
|
950
|
+
"cache-control": "no-store",
|
|
951
|
+
});
|
|
952
|
+
return;
|
|
953
|
+
}
|
|
888
954
|
if (rest === "/catalog/access/refresh") {
|
|
889
955
|
if (channel?.refreshAccess === undefined) {
|
|
890
956
|
throw new ManagementError("unavailable", "Catalog access configuration is not configured");
|
|
@@ -2885,7 +2951,11 @@ export function createMerchantManagementApiHandler(options) {
|
|
|
2885
2951
|
const buffer = Buffer.concat(chunks);
|
|
2886
2952
|
const result = convertTabularImport(format === "csv"
|
|
2887
2953
|
? { kind: "csv", text: buffer.toString("utf8") }
|
|
2888
|
-
: { kind: "xlsx", bytes: new Uint8Array(buffer) }, {
|
|
2954
|
+
: { kind: "xlsx", bytes: new Uint8Array(buffer) }, {
|
|
2955
|
+
merchantId: options.merchantId,
|
|
2956
|
+
platformRules: await resolvePlatformRules(options),
|
|
2957
|
+
now: () => now(),
|
|
2958
|
+
});
|
|
2889
2959
|
writeJson(res, 200, {
|
|
2890
2960
|
ok: result.ok,
|
|
2891
2961
|
...(result.table !== undefined ? { table: result.table } : {}),
|
|
@@ -3045,6 +3115,7 @@ export function createMerchantManagementApiHandler(options) {
|
|
|
3045
3115
|
"lead_days",
|
|
3046
3116
|
"ttl_seconds",
|
|
3047
3117
|
"human_review",
|
|
3118
|
+
"sku_rules",
|
|
3048
3119
|
]);
|
|
3049
3120
|
const patch = {};
|
|
3050
3121
|
if (fields["auto"] !== undefined) {
|
|
@@ -3078,6 +3149,60 @@ export function createMerchantManagementApiHandler(options) {
|
|
|
3078
3149
|
}
|
|
3079
3150
|
patch["human_review_on"] = triggers;
|
|
3080
3151
|
}
|
|
3152
|
+
if (fields["sku_rules"] !== undefined) {
|
|
3153
|
+
const rules = fields["sku_rules"];
|
|
3154
|
+
if (!Array.isArray(rules)) {
|
|
3155
|
+
throw new ManagementError("invalid_input", "sku_rules must be an array");
|
|
3156
|
+
}
|
|
3157
|
+
if (options.policyCurrent === undefined) {
|
|
3158
|
+
throw new ManagementError("unavailable", "per-SKU rules require a readable current policy");
|
|
3159
|
+
}
|
|
3160
|
+
const current = options.policyCurrent();
|
|
3161
|
+
const floors = { ...(current?.price_floors ?? {}) };
|
|
3162
|
+
const discounts = {
|
|
3163
|
+
...(current?.sku_max_discount_percent ?? {}),
|
|
3164
|
+
};
|
|
3165
|
+
const seen = new Set();
|
|
3166
|
+
for (const raw of rules) {
|
|
3167
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
3168
|
+
throw new ManagementError("invalid_input", "sku_rules entries must be objects");
|
|
3169
|
+
}
|
|
3170
|
+
const entry = raw;
|
|
3171
|
+
const sku = typeof entry["sku"] === "string" ? entry["sku"].trim() : "";
|
|
3172
|
+
if (sku === "" || sku.length > 128) {
|
|
3173
|
+
throw new ManagementError("invalid_input", "sku_rules.sku must be a non-empty string (<=128)");
|
|
3174
|
+
}
|
|
3175
|
+
if (seen.has(sku)) {
|
|
3176
|
+
throw new ManagementError("invalid_input", `duplicate SKU in sku_rules: ${sku}`);
|
|
3177
|
+
}
|
|
3178
|
+
seen.add(sku);
|
|
3179
|
+
let touched = false;
|
|
3180
|
+
if (entry["floor"] !== undefined) {
|
|
3181
|
+
touched = true;
|
|
3182
|
+
if (entry["floor"] === null)
|
|
3183
|
+
delete floors[sku];
|
|
3184
|
+
else
|
|
3185
|
+
floors[sku] = requireNonNegativeNumber(entry["floor"], `sku_rules.${sku}.floor`);
|
|
3186
|
+
}
|
|
3187
|
+
if (entry["discount"] !== undefined) {
|
|
3188
|
+
touched = true;
|
|
3189
|
+
if (entry["discount"] === null)
|
|
3190
|
+
delete discounts[sku];
|
|
3191
|
+
else {
|
|
3192
|
+
const discount = requireNonNegativeNumber(entry["discount"], `sku_rules.${sku}.discount`);
|
|
3193
|
+
if (discount > 100) {
|
|
3194
|
+
throw new ManagementError("invalid_input", `sku_rules.${sku}.discount must be 0-100`);
|
|
3195
|
+
}
|
|
3196
|
+
discounts[sku] = discount;
|
|
3197
|
+
}
|
|
3198
|
+
}
|
|
3199
|
+
if (!touched) {
|
|
3200
|
+
throw new ManagementError("invalid_input", `sku_rules.${sku} must include floor or discount`);
|
|
3201
|
+
}
|
|
3202
|
+
}
|
|
3203
|
+
patch["price_floors"] = floors;
|
|
3204
|
+
patch["sku_max_discount_percent"] = discounts;
|
|
3205
|
+
}
|
|
3081
3206
|
if (Object.keys(patch).length === 0) {
|
|
3082
3207
|
throw new ManagementError("invalid_input", "form submitted no changes");
|
|
3083
3208
|
}
|
|
@@ -3549,6 +3674,8 @@ async function runAccessRoute(res, requestId, run) {
|
|
|
3549
3674
|
ACCESS_NOT_CONFIGURED: "VALIDATION_ERROR",
|
|
3550
3675
|
ACCESS_NOT_FOUND: "RESOURCE_NOT_FOUND",
|
|
3551
3676
|
ACCESS_UNAVAILABLE: "DEPENDENCY_UNAVAILABLE",
|
|
3677
|
+
ACCESS_MODE_UNCERTAIN: "DEPENDENCY_UNAVAILABLE",
|
|
3678
|
+
ACCESS_STATE_UNAVAILABLE: "DEPENDENCY_UNAVAILABLE",
|
|
3552
3679
|
STATE_INVALID: "VALIDATION_ERROR",
|
|
3553
3680
|
MALFORMED_URL: "VALIDATION_ERROR",
|
|
3554
3681
|
NOT_HTTPS: "VALIDATION_ERROR",
|