@amboras-dev/aliexpress-dropshipping 1.3.0 → 1.3.1

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 CHANGED
@@ -1,15 +1,35 @@
1
1
  # @amboras-dev/aliexpress-dropshipping
2
2
 
3
- Hybrid package for the Amboras AliExpress Dropshipping integration.
4
- It exports the React admin settings form and optional storefront preflight
5
- hooks/guards. All AliExpress OAuth, signing
6
- (MD5 for `/sync`, HMAC-SHA256 for `/rest/auth/token/*`), category
7
- browsing, product import, and token refresh live in the Medusa backend
8
- module.
9
-
10
- See the plugin admin page for connect / test-connection / disconnect
11
- UI and the merchant OAuth flow.
12
-
13
- Storefront checkout integrations can import `useAliexpressPreflight` from
14
- `@amboras-dev/aliexpress-dropshipping/client` and block payment when the
15
- orchestrator reports a hard fulfillment failure.
3
+ Storefront package for the Amboras AliExpress Dropshipping integration.
4
+ It exports the cart preflight hook and its result types.
5
+
6
+ ## Where things live
7
+
8
+ All AliExpress OAuth, request signing (MD5 for `/sync`, HMAC-SHA256 for `/rest/auth/token/*`), category browsing, product import, order forwarding and token refresh live in amboras-dev-orchestrator, under `backend/src/modules/dropshipping`.
9
+ They are not part of the Medusa backend.
10
+
11
+ The only Medusa Store API route for this integration is `POST /store/aliexpress-dropshipping/preflight-cart`.
12
+
13
+ ## Preflight hook
14
+
15
+ Storefront checkout integrations import `useAliexpressPreflight` from `@amboras-dev/aliexpress-dropshipping/client`.
16
+
17
+ ```ts
18
+ const { mutateAsync, isPending } = useAliexpressPreflight()
19
+ const result = await mutateAsync({ cartId })
20
+ ```
21
+
22
+ The hook returns `{ mutateAsync, isPending }`.
23
+ `mutateAsync` resolves to a `PreflightResult` and rejects if the route responds with a non-2xx status.
24
+ Block payment when `result.ok` is false.
25
+ Price drift is reported in `result.warnings` with code `PRICE_DRIFT` and is never a blocking item error.
26
+
27
+ ## Deprecated exports
28
+
29
+ These are kept to avoid a breaking release and will be removed in the next major version.
30
+ Nothing in the platform consumes them.
31
+
32
+ - `AliExpressDropshippingSettingsForm` and its props.
33
+ It models per-store AppKey/AppSecret, but the real flow is a platform app key plus merchant OAuth.
34
+ - `AliExpressPluginConfig`, `AliExpressCategoryDto`, `AliExpressProductSummaryDto`, `AliExpressProductDto`, `AliExpressProductVariantDto`, `AliExpressImportResultDto`, `AliExpressConnectionStatusDto`, `AliExpressTestConnectionResult`, `AliExpressReauthReason`.
35
+ The routes they described (status, test-connection, product import, config update) do not exist in Medusa.
@@ -1,3 +1,3 @@
1
1
  export { AliExpressDropshippingSettingsForm, AliExpressDropshippingSettingsFormProps } from '../index.mjs';
2
- import '../types-CiA0K7nl.mjs';
2
+ import '../types-Cp-7f9WI.mjs';
3
3
  import 'react';
@@ -1,3 +1,3 @@
1
1
  export { AliExpressDropshippingSettingsForm, AliExpressDropshippingSettingsFormProps } from '../index.js';
2
- import '../types-CiA0K7nl.js';
2
+ import '../types-Cp-7f9WI.js';
3
3
  import 'react';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/admin/index.ts","../../src/settings-form.tsx","../../src/types.ts"],"sourcesContent":["export {\n AliExpressDropshippingSettingsForm,\n type AliExpressDropshippingSettingsFormProps,\n} from '../settings-form'\n","'use client'\n\n/**\n * Admin settings form for the AliExpress Dropshipping integration.\n *\n * Class B: this component owns the UI and talks to the Medusa Store API\n * under `/store/aliexpress-dropshipping/*`. It does NOT embed any\n * AliExpress SDK, does not sign requests, and does not touch OAuth\n * tokens directly - the backend does all of that.\n *\n * The component is intentionally dependency-light (no external UI kit,\n * no @tanstack/react-query peer) so the admin bundle can drop it in\n * without extra peer dep resolution.\n */\n\nimport * as React from 'react'\nimport type {\n AliExpressPluginConfig,\n AliExpressConnectionStatusDto,\n AliExpressTestConnectionResult,\n} from './types'\nimport { SECRET_SET_SENTINEL } from './types'\n\nexport interface AliExpressDropshippingSettingsFormProps {\n /** Current config for this store (fetched by the parent server component). */\n initialConfig: AliExpressPluginConfig\n /** Current connection status (from `GET /status`). */\n initialStatus: AliExpressConnectionStatusDto\n /**\n * Persist non-secret + optionally new secret values. The parent maps\n * this onto `PATCH /store/aliexpress-dropshipping/config` (or\n * equivalent) and then re-fetches config on success.\n *\n * `appSecret` is only sent when the merchant actually typed a new\n * value; if they leave the field untouched, this method receives\n * `undefined` for that key so the backend keeps the existing secret.\n */\n onSaveConfig: (patch: {\n appKey?: string\n appSecret?: string\n enabled?: boolean\n }) => Promise<void>\n /** Kick off `POST /oauth/start` and redirect to the returned URL. */\n onConnect: () => Promise<void>\n /** Kick off `POST /oauth/disconnect` and clear merchant credentials. */\n onDisconnect: () => Promise<void>\n /** Call `POST /test-connection` and return the result. */\n onTestConnection: () => Promise<AliExpressTestConnectionResult>\n}\n\ntype SaveState = 'idle' | 'saving' | 'saved' | 'error'\ntype TestState =\n | { kind: 'idle' }\n | { kind: 'running' }\n | { kind: 'ok'; categoryCount: number }\n | { kind: 'err'; code: string; msg: string }\n\n/**\n * Amboras admin settings surface for AliExpress Dropshipping.\n * Renders AppKey + AppSecret inputs, Test / Connect / Disconnect\n * buttons, status card, and a \"Coming soon\" order-forwarding block.\n */\nexport function AliExpressDropshippingSettingsForm(\n props: AliExpressDropshippingSettingsFormProps,\n): React.ReactElement {\n const {\n initialConfig,\n initialStatus,\n onSaveConfig,\n onConnect,\n onDisconnect,\n onTestConnection,\n } = props\n\n const [appKey, setAppKey] = React.useState<string>(\n initialConfig.appKey ?? '',\n )\n const secretPreset =\n initialConfig.appSecret === SECRET_SET_SENTINEL ||\n (typeof initialConfig.appSecret === 'string' &&\n initialConfig.appSecret.length > 0)\n const [appSecret, setAppSecret] = React.useState<string>('')\n const [secretDirty, setSecretDirty] = React.useState<boolean>(false)\n\n const [saveState, setSaveState] = React.useState<SaveState>('idle')\n const [saveError, setSaveError] = React.useState<string | null>(null)\n\n const [testState, setTestState] = React.useState<TestState>({ kind: 'idle' })\n const [testEverSucceeded, setTestEverSucceeded] = React.useState<boolean>(\n initialStatus.connected,\n )\n\n const [busyOAuth, setBusyOAuth] = React.useState<boolean>(false)\n\n const hasStoredSecret = secretPreset || secretDirty\n const canTest = appKey.trim().length > 0 && hasStoredSecret\n const canConnect = testEverSucceeded && !initialStatus.connected\n const canDisconnect = initialStatus.connected\n\n const handleSave = React.useCallback(async () => {\n setSaveState('saving')\n setSaveError(null)\n try {\n const patch: {\n appKey?: string\n appSecret?: string\n enabled?: boolean\n } = {}\n if (appKey.trim() !== (initialConfig.appKey ?? '')) {\n patch.appKey = appKey.trim()\n }\n if (secretDirty && appSecret.length > 0) {\n patch.appSecret = appSecret\n }\n await onSaveConfig(patch)\n setSaveState('saved')\n setSecretDirty(false)\n setAppSecret('')\n } catch (err) {\n setSaveState('error')\n setSaveError(err instanceof Error ? err.message : 'Save failed')\n }\n }, [appKey, appSecret, secretDirty, initialConfig.appKey, onSaveConfig])\n\n const handleTest = React.useCallback(async () => {\n setTestState({ kind: 'running' })\n try {\n const result = await onTestConnection()\n if (result.ok) {\n setTestState({ kind: 'ok', categoryCount: result.categoryCount })\n setTestEverSucceeded(true)\n } else {\n setTestState({ kind: 'err', code: result.code, msg: result.msg })\n }\n } catch (err) {\n setTestState({\n kind: 'err',\n code: 'UNKNOWN',\n msg: err instanceof Error ? err.message : 'Test failed',\n })\n }\n }, [onTestConnection])\n\n const handleConnect = React.useCallback(async () => {\n setBusyOAuth(true)\n try {\n await onConnect()\n } finally {\n setBusyOAuth(false)\n }\n }, [onConnect])\n\n const handleDisconnect = React.useCallback(async () => {\n setBusyOAuth(true)\n try {\n await onDisconnect()\n } finally {\n setBusyOAuth(false)\n }\n }, [onDisconnect])\n\n return (\n <div className=\"aliexpress-dropshipping-settings\">\n <section aria-labelledby=\"ae-credentials-heading\">\n <h2 id=\"ae-credentials-heading\">Developer app credentials</h2>\n <p>\n Enter your AliExpress Open Platform app credentials. These are\n stored encrypted at rest and used to sign every AliExpress API\n call for this store.\n </p>\n\n <label>\n <span>App Key</span>\n <input\n type=\"text\"\n value={appKey}\n onChange={(e) => setAppKey(e.target.value)}\n autoComplete=\"off\"\n spellCheck={false}\n />\n </label>\n\n <label>\n <span>App Secret</span>\n <input\n type=\"password\"\n value={appSecret}\n placeholder={secretPreset ? '(secret set - leave blank to keep)' : ''}\n onChange={(e) => {\n setAppSecret(e.target.value)\n setSecretDirty(true)\n }}\n autoComplete=\"off\"\n spellCheck={false}\n />\n </label>\n\n <div className=\"actions\">\n <button\n type=\"button\"\n onClick={handleSave}\n disabled={saveState === 'saving' || appKey.trim().length === 0}\n >\n {saveState === 'saving' ? 'Saving...' : 'Save credentials'}\n </button>\n <button\n type=\"button\"\n onClick={handleTest}\n disabled={!canTest || testState.kind === 'running'}\n >\n {testState.kind === 'running' ? 'Testing...' : 'Test connection'}\n </button>\n </div>\n\n {saveState === 'saved' ? <p role=\"status\">Saved.</p> : null}\n {saveState === 'error' && saveError ? (\n <p role=\"alert\">Save failed: {saveError}</p>\n ) : null}\n\n {testState.kind === 'ok' ? (\n <p role=\"status\">\n Connected to AliExpress. Found {testState.categoryCount} categories.\n </p>\n ) : null}\n {testState.kind === 'err' ? (\n <p role=\"alert\">\n Test failed ({testState.code}): {testState.msg}\n </p>\n ) : null}\n </section>\n\n <section aria-labelledby=\"ae-oauth-heading\">\n <h2 id=\"ae-oauth-heading\">Merchant account connection</h2>\n <p>\n Connect a specific AliExpress seller account to enable product\n import into this store. This is separate from the developer app\n credentials above.\n </p>\n\n {initialStatus.needsReauth ? (\n <p role=\"alert\" className=\"reauth-banner\">\n Re-authentication required. Please reconnect your AliExpress account.\n </p>\n ) : null}\n\n <div className=\"status-card\">\n <div>\n <strong>Status:</strong>{' '}\n {initialStatus.connected ? 'Connected' : 'Not connected'}\n </div>\n {initialStatus.sellerId ? (\n <div>\n <strong>Seller ID:</strong> {initialStatus.sellerId}\n </div>\n ) : null}\n {initialStatus.lastSuccessfulCallAt ? (\n <div>\n <strong>Last successful call:</strong>{' '}\n {initialStatus.lastSuccessfulCallAt}\n </div>\n ) : null}\n </div>\n\n <div className=\"actions\">\n <button\n type=\"button\"\n onClick={handleConnect}\n disabled={!canConnect || busyOAuth}\n >\n {busyOAuth ? 'Working...' : 'Connect merchant AliExpress account'}\n </button>\n <button\n type=\"button\"\n onClick={handleDisconnect}\n disabled={!canDisconnect || busyOAuth}\n >\n Disconnect\n </button>\n </div>\n\n {!testEverSucceeded ? (\n <p>\n Run <em>Test connection</em> once with your AppKey/AppSecret before\n connecting a merchant account.\n </p>\n ) : null}\n </section>\n\n <section aria-labelledby=\"ae-coming-soon-heading\">\n <h2 id=\"ae-coming-soon-heading\">Order forwarding</h2>\n <p>\n Coming soon. Automatic order forwarding to AliExpress requires\n our app to be approved out of Test status by AliExpress. Product\n import and browsing work today.\n </p>\n </section>\n </div>\n )\n}\n\nexport default AliExpressDropshippingSettingsForm\n","/**\n * Public types for @amboras-dev/aliexpress-dropshipping.\n *\n * These are the single source of truth for the wire shape between the\n * Amboras admin settings form and the medusa-backend-orchestrator\n * Store API routes under `/store/aliexpress-dropshipping/*`. The DTO\n * files on the medusa side must stay byte-compatible with these.\n */\n\n/**\n * Sentinel returned in place of a stored secret when the settings form\n * reads back current config. Matches the pattern used by meta-ads and\n * pinterest so the admin never sees the plaintext secret after write.\n */\nexport const SECRET_SET_SENTINEL = '__SECRET_SET__' as const\nexport type SecretSetSentinel = typeof SECRET_SET_SENTINEL\n\n/**\n * Per-store AliExpress plugin configuration.\n *\n * - `appKey` / `appSecret` are per-store developer app credentials\n * supplied by the merchant. The admin form receives\n * `SECRET_SET_SENTINEL` for `appSecret` on read, and only sends a\n * real value on user edit.\n * - `connectedSellerId` is populated after the merchant completes the\n * OAuth flow to `/rest/auth/token/create`.\n * - `needsReauth` is flipped by the backend runtime detector when it\n * sees `MissingParameter access_token` or `IllegalAccessToken`\n * sub-codes on any envelope.\n * - `lastSuccessfulCallAt` is an ISO-8601 timestamp for the status card.\n */\nexport interface AliExpressPluginConfig {\n enabled: boolean\n appKey: string | null\n appSecret: string | SecretSetSentinel | null\n connectedSellerId: string | null\n needsReauth: boolean\n lastSuccessfulCallAt: string | null\n}\n\n/**\n * Reasons the backend surfaces when a merchant token becomes invalid.\n * Kept narrow so the admin banner can render a specific message.\n */\nexport enum AliExpressReauthReason {\n MissingAccessToken = 'missing_access_token',\n IllegalAccessToken = 'illegal_access_token',\n RefreshFailed = 'refresh_failed',\n Disconnected = 'disconnected',\n}\n\n/**\n * Category node returned by `aliexpress.ds.category.get`. The API\n * returns a flat list; the admin renders it as a tree by walking\n * `parentCategoryId`.\n */\nexport interface AliExpressCategoryDto {\n categoryId: string\n categoryName: string\n parentCategoryId: string | null\n}\n\n/**\n * Product summary shape returned by `aliexpress.ds.recommend.feed.get`.\n * Used by the \"browse products\" admin surface.\n */\nexport interface AliExpressProductSummaryDto {\n productId: string\n title: string\n imageUrl: string | null\n minPrice: number | null\n maxPrice: number | null\n currency: string | null\n productDetailUrl: string | null\n}\n\n/**\n * Full product shape returned by `aliexpress.ds.product.get`. Consumed\n * by the medusa-side mapper `aliexpressProductToMedusaDraft`.\n */\nexport interface AliExpressProductDto {\n productId: string\n title: string\n description: string | null\n images: string[]\n variants: AliExpressProductVariantDto[]\n weightGrams: number | null\n sourceUrl: string | null\n}\n\nexport interface AliExpressProductVariantDto {\n skuId: string\n title: string | null\n price: number\n currency: string\n stock: number | null\n attributes: Record<string, string>\n}\n\n/**\n * Return shape from `POST /store/aliexpress-dropshipping/products/:id/import`.\n */\nexport interface AliExpressImportResultDto {\n medusaProductId: string\n sourceProductId: string\n importedVariants: number\n}\n\n/**\n * Return shape from `GET /store/aliexpress-dropshipping/status` - drives\n * the admin status card.\n */\nexport interface AliExpressConnectionStatusDto {\n connected: boolean\n sellerId: string | null\n needsReauth: boolean\n reauthReason: AliExpressReauthReason | null\n lastSuccessfulCallAt: string | null\n}\n\n/**\n * Return shape from `POST /store/aliexpress-dropshipping/test-connection`.\n */\nexport type AliExpressTestConnectionResult =\n | { ok: true; categoryCount: number }\n | { ok: false; code: string; msg: string }\n\nexport interface PreflightMerchantError {\n code: string\n message: string\n}\n\nexport interface PreflightAddressError {\n code: string\n message: string\n field: string\n}\n\nexport interface PreflightItemError {\n variantId: string\n productTitle: string\n code: 'CORRUPT_METADATA' | 'PRODUCT_OFFLINE' | 'OUT_OF_STOCK' | 'CANNOT_SHIP' | 'PRICE_DRIFT'\n message: string\n removable: boolean\n}\n\nexport interface PreflightResult {\n ok: boolean\n merchantErrors: PreflightMerchantError[]\n addressErrors: PreflightAddressError[]\n itemErrors: PreflightItemError[]\n warnings: Array<{ code: string; message: string }>\n degraded?: boolean\n warning?: string\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACeA,YAAuB;;;ACDhB,IAAM,sBAAsB;;;ADsJ3B;AAtGD,SAAS,mCACd,OACoB;AACpB,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,QAAM,CAAC,QAAQ,SAAS,IAAU;AAAA,IAChC,cAAc,UAAU;AAAA,EAC1B;AACA,QAAM,eACJ,cAAc,cAAc,uBAC3B,OAAO,cAAc,cAAc,YAClC,cAAc,UAAU,SAAS;AACrC,QAAM,CAAC,WAAW,YAAY,IAAU,eAAiB,EAAE;AAC3D,QAAM,CAAC,aAAa,cAAc,IAAU,eAAkB,KAAK;AAEnE,QAAM,CAAC,WAAW,YAAY,IAAU,eAAoB,MAAM;AAClE,QAAM,CAAC,WAAW,YAAY,IAAU,eAAwB,IAAI;AAEpE,QAAM,CAAC,WAAW,YAAY,IAAU,eAAoB,EAAE,MAAM,OAAO,CAAC;AAC5E,QAAM,CAAC,mBAAmB,oBAAoB,IAAU;AAAA,IACtD,cAAc;AAAA,EAChB;AAEA,QAAM,CAAC,WAAW,YAAY,IAAU,eAAkB,KAAK;AAE/D,QAAM,kBAAkB,gBAAgB;AACxC,QAAM,UAAU,OAAO,KAAK,EAAE,SAAS,KAAK;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,QAED;AAAA,SACF;AAAA,MAEC,CAAC,oBACA,6CAAC,OAAE;AAAA;AAAA,QACG,4CAAC,QAAG,6BAAe;AAAA,QAAK;AAAA,SAE9B,IACE;AAAA,OACN;AAAA,IAEA,6CAAC,aAAQ,mBAAgB,0BACvB;AAAA,kDAAC,QAAG,IAAG,0BAAyB,8BAAgB;AAAA,MAChD,4CAAC,OAAE,6KAIH;AAAA,OACF;AAAA,KACF;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../src/admin/index.ts","../../src/settings-form.tsx","../../src/types.ts"],"sourcesContent":["export {\n AliExpressDropshippingSettingsForm,\n type AliExpressDropshippingSettingsFormProps,\n} from '../settings-form'\n","'use client'\n\n/**\n * Admin settings form for the AliExpress Dropshipping integration.\n *\n * @deprecated Not used by any consumer. It models per-store AppKey/AppSecret,\n * but the real flow is a platform app key plus merchant OAuth, owned by\n * amboras-dev-orchestrator (`backend/src/modules/dropshipping`). The Medusa\n * Store API has no config, status or test-connection routes for it to call.\n *\n * The component is intentionally dependency-light (no external UI kit,\n * no @tanstack/react-query peer) so the admin bundle can drop it in\n * without extra peer dep resolution.\n */\n\nimport * as React from 'react'\nimport type {\n AliExpressPluginConfig,\n AliExpressConnectionStatusDto,\n AliExpressTestConnectionResult,\n} from './types'\nimport { SECRET_SET_SENTINEL } from './types'\n\n/** @deprecated See {@link AliExpressDropshippingSettingsForm}. */\nexport interface AliExpressDropshippingSettingsFormProps {\n /** Current config for this store (fetched by the parent server component). */\n initialConfig: AliExpressPluginConfig\n /** Current connection status (from `GET /status`). */\n initialStatus: AliExpressConnectionStatusDto\n /**\n * Persist non-secret + optionally new secret values. The parent maps\n * this onto `PATCH /store/aliexpress-dropshipping/config` (or\n * equivalent) and then re-fetches config on success.\n *\n * `appSecret` is only sent when the merchant actually typed a new\n * value; if they leave the field untouched, this method receives\n * `undefined` for that key so the backend keeps the existing secret.\n */\n onSaveConfig: (patch: {\n appKey?: string\n appSecret?: string\n enabled?: boolean\n }) => Promise<void>\n /** Kick off `POST /oauth/start` and redirect to the returned URL. */\n onConnect: () => Promise<void>\n /** Kick off `POST /oauth/disconnect` and clear merchant credentials. */\n onDisconnect: () => Promise<void>\n /** Call `POST /test-connection` and return the result. */\n onTestConnection: () => Promise<AliExpressTestConnectionResult>\n}\n\ntype SaveState = 'idle' | 'saving' | 'saved' | 'error'\ntype TestState =\n | { kind: 'idle' }\n | { kind: 'running' }\n | { kind: 'ok'; categoryCount: number }\n | { kind: 'err'; code: string; msg: string }\n\n/**\n * Amboras admin settings surface for AliExpress Dropshipping.\n * Renders AppKey + AppSecret inputs, Test / Connect / Disconnect\n * buttons, status card, and a \"Coming soon\" order-forwarding block.\n */\n/** @deprecated Not used by any consumer; see the file header. */\nexport function AliExpressDropshippingSettingsForm(\n props: AliExpressDropshippingSettingsFormProps,\n): React.ReactElement {\n const {\n initialConfig,\n initialStatus,\n onSaveConfig,\n onConnect,\n onDisconnect,\n onTestConnection,\n } = props\n\n const [appKey, setAppKey] = React.useState<string>(\n initialConfig.appKey ?? '',\n )\n const secretPreset =\n initialConfig.appSecret === SECRET_SET_SENTINEL ||\n (typeof initialConfig.appSecret === 'string' &&\n initialConfig.appSecret.length > 0)\n const [appSecret, setAppSecret] = React.useState<string>('')\n const [secretDirty, setSecretDirty] = React.useState<boolean>(false)\n\n const [saveState, setSaveState] = React.useState<SaveState>('idle')\n const [saveError, setSaveError] = React.useState<string | null>(null)\n\n const [testState, setTestState] = React.useState<TestState>({ kind: 'idle' })\n const [testEverSucceeded, setTestEverSucceeded] = React.useState<boolean>(\n initialStatus.connected,\n )\n\n const [busyOAuth, setBusyOAuth] = React.useState<boolean>(false)\n\n const hasStoredSecret = secretPreset || secretDirty\n const canTest = appKey.trim().length > 0 && hasStoredSecret\n const canConnect = testEverSucceeded && !initialStatus.connected\n const canDisconnect = initialStatus.connected\n\n const handleSave = React.useCallback(async () => {\n setSaveState('saving')\n setSaveError(null)\n try {\n const patch: {\n appKey?: string\n appSecret?: string\n enabled?: boolean\n } = {}\n if (appKey.trim() !== (initialConfig.appKey ?? '')) {\n patch.appKey = appKey.trim()\n }\n if (secretDirty && appSecret.length > 0) {\n patch.appSecret = appSecret\n }\n await onSaveConfig(patch)\n setSaveState('saved')\n setSecretDirty(false)\n setAppSecret('')\n } catch (err) {\n setSaveState('error')\n setSaveError(err instanceof Error ? err.message : 'Save failed')\n }\n }, [appKey, appSecret, secretDirty, initialConfig.appKey, onSaveConfig])\n\n const handleTest = React.useCallback(async () => {\n setTestState({ kind: 'running' })\n try {\n const result = await onTestConnection()\n if (result.ok) {\n setTestState({ kind: 'ok', categoryCount: result.categoryCount })\n setTestEverSucceeded(true)\n } else {\n setTestState({ kind: 'err', code: result.code, msg: result.msg })\n }\n } catch (err) {\n setTestState({\n kind: 'err',\n code: 'UNKNOWN',\n msg: err instanceof Error ? err.message : 'Test failed',\n })\n }\n }, [onTestConnection])\n\n const handleConnect = React.useCallback(async () => {\n setBusyOAuth(true)\n try {\n await onConnect()\n } finally {\n setBusyOAuth(false)\n }\n }, [onConnect])\n\n const handleDisconnect = React.useCallback(async () => {\n setBusyOAuth(true)\n try {\n await onDisconnect()\n } finally {\n setBusyOAuth(false)\n }\n }, [onDisconnect])\n\n return (\n <div className=\"aliexpress-dropshipping-settings\">\n <section aria-labelledby=\"ae-credentials-heading\">\n <h2 id=\"ae-credentials-heading\">Developer app credentials</h2>\n <p>\n Enter your AliExpress Open Platform app credentials. These are\n stored encrypted at rest and used to sign every AliExpress API\n call for this store.\n </p>\n\n <label>\n <span>App Key</span>\n <input\n type=\"text\"\n value={appKey}\n onChange={(e) => setAppKey(e.target.value)}\n autoComplete=\"off\"\n spellCheck={false}\n />\n </label>\n\n <label>\n <span>App Secret</span>\n <input\n type=\"password\"\n value={appSecret}\n placeholder={secretPreset ? '(secret set - leave blank to keep)' : ''}\n onChange={(e) => {\n setAppSecret(e.target.value)\n setSecretDirty(true)\n }}\n autoComplete=\"off\"\n spellCheck={false}\n />\n </label>\n\n <div className=\"actions\">\n <button\n type=\"button\"\n onClick={handleSave}\n disabled={saveState === 'saving' || appKey.trim().length === 0}\n >\n {saveState === 'saving' ? 'Saving...' : 'Save credentials'}\n </button>\n <button\n type=\"button\"\n onClick={handleTest}\n disabled={!canTest || testState.kind === 'running'}\n >\n {testState.kind === 'running' ? 'Testing...' : 'Test connection'}\n </button>\n </div>\n\n {saveState === 'saved' ? <p role=\"status\">Saved.</p> : null}\n {saveState === 'error' && saveError ? (\n <p role=\"alert\">Save failed: {saveError}</p>\n ) : null}\n\n {testState.kind === 'ok' ? (\n <p role=\"status\">\n Connected to AliExpress. Found {testState.categoryCount} categories.\n </p>\n ) : null}\n {testState.kind === 'err' ? (\n <p role=\"alert\">\n Test failed ({testState.code}): {testState.msg}\n </p>\n ) : null}\n </section>\n\n <section aria-labelledby=\"ae-oauth-heading\">\n <h2 id=\"ae-oauth-heading\">Merchant account connection</h2>\n <p>\n Connect a specific AliExpress seller account to enable product\n import into this store. This is separate from the developer app\n credentials above.\n </p>\n\n {initialStatus.needsReauth ? (\n <p role=\"alert\" className=\"reauth-banner\">\n Re-authentication required. Please reconnect your AliExpress account.\n </p>\n ) : null}\n\n <div className=\"status-card\">\n <div>\n <strong>Status:</strong>{' '}\n {initialStatus.connected ? 'Connected' : 'Not connected'}\n </div>\n {initialStatus.sellerId ? (\n <div>\n <strong>Seller ID:</strong> {initialStatus.sellerId}\n </div>\n ) : null}\n {initialStatus.lastSuccessfulCallAt ? (\n <div>\n <strong>Last successful call:</strong>{' '}\n {initialStatus.lastSuccessfulCallAt}\n </div>\n ) : null}\n </div>\n\n <div className=\"actions\">\n <button\n type=\"button\"\n onClick={handleConnect}\n disabled={!canConnect || busyOAuth}\n >\n {busyOAuth ? 'Working...' : 'Connect merchant AliExpress account'}\n </button>\n <button\n type=\"button\"\n onClick={handleDisconnect}\n disabled={!canDisconnect || busyOAuth}\n >\n Disconnect\n </button>\n </div>\n\n {!testEverSucceeded ? (\n <p>\n Run <em>Test connection</em> once with your AppKey/AppSecret before\n connecting a merchant account.\n </p>\n ) : null}\n </section>\n\n <section aria-labelledby=\"ae-coming-soon-heading\">\n <h2 id=\"ae-coming-soon-heading\">Order forwarding</h2>\n <p>\n Coming soon. Automatic order forwarding to AliExpress requires\n our app to be approved out of Test status by AliExpress. Product\n import and browsing work today.\n </p>\n </section>\n </div>\n )\n}\n\nexport default AliExpressDropshippingSettingsForm\n","/**\n * Public types for @amboras-dev/aliexpress-dropshipping.\n *\n * Only the preflight types (`PreflightResult` and friends) describe a live\n * contract: the Medusa Store API exposes exactly one route,\n * `POST /store/aliexpress-dropshipping/preflight-cart`.\n *\n * OAuth, request signing, category browsing, product import and token\n * refresh all live in amboras-dev-orchestrator\n * (`backend/src/modules/dropshipping`), not in the Medusa backend. The\n * connection/config/product DTOs below are kept only for backward\n * compatibility and are deprecated.\n */\n\n/**\n * Sentinel returned in place of a stored secret when the settings form\n * reads back current config. Matches the pattern used by meta-ads and\n * pinterest so the admin never sees the plaintext secret after write.\n */\nexport const SECRET_SET_SENTINEL = '__SECRET_SET__' as const\nexport type SecretSetSentinel = typeof SECRET_SET_SENTINEL\n\n/**\n * Per-store AliExpress plugin configuration.\n *\n * @deprecated Models per-store developer credentials, but the real flow\n * uses a platform app key plus merchant OAuth handled by\n * amboras-dev-orchestrator. No Medusa route reads or writes this shape.\n *\n * - `appKey` / `appSecret` are per-store developer app credentials\n * supplied by the merchant. The admin form receives\n * `SECRET_SET_SENTINEL` for `appSecret` on read, and only sends a\n * real value on user edit.\n * - `connectedSellerId` is populated after the merchant completes the\n * OAuth flow to `/rest/auth/token/create`.\n * - `needsReauth` is flipped by the backend runtime detector when it\n * sees `MissingParameter access_token` or `IllegalAccessToken`\n * sub-codes on any envelope.\n * - `lastSuccessfulCallAt` is an ISO-8601 timestamp for the status card.\n */\nexport interface AliExpressPluginConfig {\n enabled: boolean\n appKey: string | null\n appSecret: string | SecretSetSentinel | null\n connectedSellerId: string | null\n needsReauth: boolean\n lastSuccessfulCallAt: string | null\n}\n\n/**\n * @deprecated Reauth state is owned by amboras-dev-orchestrator.\n *\n * Reasons the backend surfaces when a merchant token becomes invalid.\n * Kept narrow so the admin banner can render a specific message.\n */\nexport enum AliExpressReauthReason {\n MissingAccessToken = 'missing_access_token',\n IllegalAccessToken = 'illegal_access_token',\n RefreshFailed = 'refresh_failed',\n Disconnected = 'disconnected',\n}\n\n/**\n * @deprecated No Medusa route returns this; category browsing lives in\n * amboras-dev-orchestrator.\n *\n * Category node returned by `aliexpress.ds.category.get`. The API\n * returns a flat list; the admin renders it as a tree by walking\n * `parentCategoryId`.\n */\nexport interface AliExpressCategoryDto {\n categoryId: string\n categoryName: string\n parentCategoryId: string | null\n}\n\n/**\n * @deprecated No Medusa route returns this; browsing lives in\n * amboras-dev-orchestrator.\n *\n * Product summary shape returned by `aliexpress.ds.recommend.feed.get`.\n */\nexport interface AliExpressProductSummaryDto {\n productId: string\n title: string\n imageUrl: string | null\n minPrice: number | null\n maxPrice: number | null\n currency: string | null\n productDetailUrl: string | null\n}\n\n/**\n * @deprecated No Medusa route or mapper uses this; product import lives in\n * amboras-dev-orchestrator.\n *\n * Full product shape returned by `aliexpress.ds.product.get`.\n */\nexport interface AliExpressProductDto {\n productId: string\n title: string\n description: string | null\n images: string[]\n variants: AliExpressProductVariantDto[]\n weightGrams: number | null\n sourceUrl: string | null\n}\n\n/** @deprecated See {@link AliExpressProductDto}. */\nexport interface AliExpressProductVariantDto {\n skuId: string\n title: string | null\n price: number\n currency: string\n stock: number | null\n attributes: Record<string, string>\n}\n\n/**\n * @deprecated The route `POST /store/aliexpress-dropshipping/products/:id/import`\n * does not exist; import is done by amboras-dev-orchestrator.\n */\nexport interface AliExpressImportResultDto {\n medusaProductId: string\n sourceProductId: string\n importedVariants: number\n}\n\n/**\n * @deprecated The route `GET /store/aliexpress-dropshipping/status` does not\n * exist; connection status is served by amboras-dev-orchestrator.\n */\nexport interface AliExpressConnectionStatusDto {\n connected: boolean\n sellerId: string | null\n needsReauth: boolean\n reauthReason: AliExpressReauthReason | null\n lastSuccessfulCallAt: string | null\n}\n\n/**\n * @deprecated The route `POST /store/aliexpress-dropshipping/test-connection`\n * does not exist; it is served by amboras-dev-orchestrator.\n */\nexport type AliExpressTestConnectionResult =\n | { ok: true; categoryCount: number }\n | { ok: false; code: string; msg: string }\n\n/** Known merchant-level codes; the server may add others. */\nexport type PreflightMerchantErrorCode =\n | 'MERCHANT_DISCONNECTED'\n | 'MERCHANT_UNAVAILABLE'\n | 'MERCHANT_REAUTH_REQUIRED'\n | 'SHIPPING_VERIFICATION_FAILED'\n\n/** Known address codes; the server may add others. */\nexport type PreflightAddressErrorCode =\n | 'ADDRESS_REQUIRED'\n | 'CITY_UNKNOWN'\n | 'ADDRESS_NOT_LATIN'\n | 'ADDRESS_FIELD_LENGTH'\n | 'PHONE_INVALID'\n | 'PROVINCE_REQUIRED'\n | 'COUNTRY_INVALID'\n | 'POSTAL_CODE_INVALID'\n | 'ADDRESS_INVALID'\n\nexport interface PreflightMerchantError {\n code: PreflightMerchantErrorCode | (string & {})\n message: string\n}\n\nexport interface PreflightAddressError {\n code: PreflightAddressErrorCode | (string & {})\n message: string\n field: string\n}\n\nexport interface PreflightItemError {\n variantId: string\n productTitle: string\n code:\n | 'CORRUPT_METADATA'\n | 'PRODUCT_OFFLINE'\n | 'OUT_OF_STOCK'\n | 'CANNOT_SHIP'\n /** @deprecated Price drift is only ever reported as a warning ({@link PreflightWarningCode}), never as an item error. Kept for backward compatibility. */\n | 'PRICE_DRIFT'\n | 'SHIPPING_VERIFICATION_FAILED'\n message: string\n removable: boolean\n}\n\n/** Codes that appear in `PreflightResult.warnings`. Non-blocking. */\nexport type PreflightWarningCode = 'PRICE_DRIFT' | 'STOCK_UNKNOWN' | 'FREIGHT_EXPENSIVE'\n\nexport interface PreflightWarning {\n /** Known codes are listed in {@link PreflightWarningCode}; other strings may be added by the server. */\n code: PreflightWarningCode | (string & {})\n message: string\n}\n\nexport interface PreflightResult {\n ok: boolean\n merchantErrors: PreflightMerchantError[]\n addressErrors: PreflightAddressError[]\n itemErrors: PreflightItemError[]\n warnings: PreflightWarning[]\n degraded?: boolean\n warning?: string\n}\n\n/**\n * Body of the 429 the preflight route returns when a cart or IP is checked too often.\n * `Retry-After` carries the same number of seconds as `retryAfter`.\n */\nexport interface PreflightRateLimitedResponse {\n error: string\n code: 'rate_limited'\n retryAfter: number\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACeA,YAAuB;;;ACIhB,IAAM,sBAAsB;;;ADmJ3B;AAtGD,SAAS,mCACd,OACoB;AACpB,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,QAAM,CAAC,QAAQ,SAAS,IAAU;AAAA,IAChC,cAAc,UAAU;AAAA,EAC1B;AACA,QAAM,eACJ,cAAc,cAAc,uBAC3B,OAAO,cAAc,cAAc,YAClC,cAAc,UAAU,SAAS;AACrC,QAAM,CAAC,WAAW,YAAY,IAAU,eAAiB,EAAE;AAC3D,QAAM,CAAC,aAAa,cAAc,IAAU,eAAkB,KAAK;AAEnE,QAAM,CAAC,WAAW,YAAY,IAAU,eAAoB,MAAM;AAClE,QAAM,CAAC,WAAW,YAAY,IAAU,eAAwB,IAAI;AAEpE,QAAM,CAAC,WAAW,YAAY,IAAU,eAAoB,EAAE,MAAM,OAAO,CAAC;AAC5E,QAAM,CAAC,mBAAmB,oBAAoB,IAAU;AAAA,IACtD,cAAc;AAAA,EAChB;AAEA,QAAM,CAAC,WAAW,YAAY,IAAU,eAAkB,KAAK;AAE/D,QAAM,kBAAkB,gBAAgB;AACxC,QAAM,UAAU,OAAO,KAAK,EAAE,SAAS,KAAK;AAC5C,QAAM,aAAa,qBAAqB,CAAC,cAAc;AACvD,QAAM,gBAAgB,cAAc;AAEpC,QAAM,aAAmB,kBAAY,YAAY;AAC/C,iBAAa,QAA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ACE;AAAA,OACN;AAAA,IAEA,6CAAC,aAAQ,mBAAgB,0BACvB;AAAA,kDAAC,QAAG,IAAG,0BAAyB,8BAAgB;AAAA,MAChD,4CAAC,OAAE,6KAIH;AAAA,OACF;AAAA,KACF;AAEJ;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  AliExpressDropshippingSettingsForm
3
- } from "../chunk-65TJ4JF6.mjs";
3
+ } from "../chunk-XSSYR25X.mjs";
4
4
  export {
5
5
  AliExpressDropshippingSettingsForm
6
6
  };
@@ -221,4 +221,4 @@ export {
221
221
  AliExpressReauthReason,
222
222
  AliExpressDropshippingSettingsForm
223
223
  };
224
- //# sourceMappingURL=chunk-65TJ4JF6.mjs.map
224
+ //# sourceMappingURL=chunk-XSSYR25X.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types.ts","../src/settings-form.tsx"],"sourcesContent":["/**\n * Public types for @amboras-dev/aliexpress-dropshipping.\n *\n * Only the preflight types (`PreflightResult` and friends) describe a live\n * contract: the Medusa Store API exposes exactly one route,\n * `POST /store/aliexpress-dropshipping/preflight-cart`.\n *\n * OAuth, request signing, category browsing, product import and token\n * refresh all live in amboras-dev-orchestrator\n * (`backend/src/modules/dropshipping`), not in the Medusa backend. The\n * connection/config/product DTOs below are kept only for backward\n * compatibility and are deprecated.\n */\n\n/**\n * Sentinel returned in place of a stored secret when the settings form\n * reads back current config. Matches the pattern used by meta-ads and\n * pinterest so the admin never sees the plaintext secret after write.\n */\nexport const SECRET_SET_SENTINEL = '__SECRET_SET__' as const\nexport type SecretSetSentinel = typeof SECRET_SET_SENTINEL\n\n/**\n * Per-store AliExpress plugin configuration.\n *\n * @deprecated Models per-store developer credentials, but the real flow\n * uses a platform app key plus merchant OAuth handled by\n * amboras-dev-orchestrator. No Medusa route reads or writes this shape.\n *\n * - `appKey` / `appSecret` are per-store developer app credentials\n * supplied by the merchant. The admin form receives\n * `SECRET_SET_SENTINEL` for `appSecret` on read, and only sends a\n * real value on user edit.\n * - `connectedSellerId` is populated after the merchant completes the\n * OAuth flow to `/rest/auth/token/create`.\n * - `needsReauth` is flipped by the backend runtime detector when it\n * sees `MissingParameter access_token` or `IllegalAccessToken`\n * sub-codes on any envelope.\n * - `lastSuccessfulCallAt` is an ISO-8601 timestamp for the status card.\n */\nexport interface AliExpressPluginConfig {\n enabled: boolean\n appKey: string | null\n appSecret: string | SecretSetSentinel | null\n connectedSellerId: string | null\n needsReauth: boolean\n lastSuccessfulCallAt: string | null\n}\n\n/**\n * @deprecated Reauth state is owned by amboras-dev-orchestrator.\n *\n * Reasons the backend surfaces when a merchant token becomes invalid.\n * Kept narrow so the admin banner can render a specific message.\n */\nexport enum AliExpressReauthReason {\n MissingAccessToken = 'missing_access_token',\n IllegalAccessToken = 'illegal_access_token',\n RefreshFailed = 'refresh_failed',\n Disconnected = 'disconnected',\n}\n\n/**\n * @deprecated No Medusa route returns this; category browsing lives in\n * amboras-dev-orchestrator.\n *\n * Category node returned by `aliexpress.ds.category.get`. The API\n * returns a flat list; the admin renders it as a tree by walking\n * `parentCategoryId`.\n */\nexport interface AliExpressCategoryDto {\n categoryId: string\n categoryName: string\n parentCategoryId: string | null\n}\n\n/**\n * @deprecated No Medusa route returns this; browsing lives in\n * amboras-dev-orchestrator.\n *\n * Product summary shape returned by `aliexpress.ds.recommend.feed.get`.\n */\nexport interface AliExpressProductSummaryDto {\n productId: string\n title: string\n imageUrl: string | null\n minPrice: number | null\n maxPrice: number | null\n currency: string | null\n productDetailUrl: string | null\n}\n\n/**\n * @deprecated No Medusa route or mapper uses this; product import lives in\n * amboras-dev-orchestrator.\n *\n * Full product shape returned by `aliexpress.ds.product.get`.\n */\nexport interface AliExpressProductDto {\n productId: string\n title: string\n description: string | null\n images: string[]\n variants: AliExpressProductVariantDto[]\n weightGrams: number | null\n sourceUrl: string | null\n}\n\n/** @deprecated See {@link AliExpressProductDto}. */\nexport interface AliExpressProductVariantDto {\n skuId: string\n title: string | null\n price: number\n currency: string\n stock: number | null\n attributes: Record<string, string>\n}\n\n/**\n * @deprecated The route `POST /store/aliexpress-dropshipping/products/:id/import`\n * does not exist; import is done by amboras-dev-orchestrator.\n */\nexport interface AliExpressImportResultDto {\n medusaProductId: string\n sourceProductId: string\n importedVariants: number\n}\n\n/**\n * @deprecated The route `GET /store/aliexpress-dropshipping/status` does not\n * exist; connection status is served by amboras-dev-orchestrator.\n */\nexport interface AliExpressConnectionStatusDto {\n connected: boolean\n sellerId: string | null\n needsReauth: boolean\n reauthReason: AliExpressReauthReason | null\n lastSuccessfulCallAt: string | null\n}\n\n/**\n * @deprecated The route `POST /store/aliexpress-dropshipping/test-connection`\n * does not exist; it is served by amboras-dev-orchestrator.\n */\nexport type AliExpressTestConnectionResult =\n | { ok: true; categoryCount: number }\n | { ok: false; code: string; msg: string }\n\n/** Known merchant-level codes; the server may add others. */\nexport type PreflightMerchantErrorCode =\n | 'MERCHANT_DISCONNECTED'\n | 'MERCHANT_UNAVAILABLE'\n | 'MERCHANT_REAUTH_REQUIRED'\n | 'SHIPPING_VERIFICATION_FAILED'\n\n/** Known address codes; the server may add others. */\nexport type PreflightAddressErrorCode =\n | 'ADDRESS_REQUIRED'\n | 'CITY_UNKNOWN'\n | 'ADDRESS_NOT_LATIN'\n | 'ADDRESS_FIELD_LENGTH'\n | 'PHONE_INVALID'\n | 'PROVINCE_REQUIRED'\n | 'COUNTRY_INVALID'\n | 'POSTAL_CODE_INVALID'\n | 'ADDRESS_INVALID'\n\nexport interface PreflightMerchantError {\n code: PreflightMerchantErrorCode | (string & {})\n message: string\n}\n\nexport interface PreflightAddressError {\n code: PreflightAddressErrorCode | (string & {})\n message: string\n field: string\n}\n\nexport interface PreflightItemError {\n variantId: string\n productTitle: string\n code:\n | 'CORRUPT_METADATA'\n | 'PRODUCT_OFFLINE'\n | 'OUT_OF_STOCK'\n | 'CANNOT_SHIP'\n /** @deprecated Price drift is only ever reported as a warning ({@link PreflightWarningCode}), never as an item error. Kept for backward compatibility. */\n | 'PRICE_DRIFT'\n | 'SHIPPING_VERIFICATION_FAILED'\n message: string\n removable: boolean\n}\n\n/** Codes that appear in `PreflightResult.warnings`. Non-blocking. */\nexport type PreflightWarningCode = 'PRICE_DRIFT' | 'STOCK_UNKNOWN' | 'FREIGHT_EXPENSIVE'\n\nexport interface PreflightWarning {\n /** Known codes are listed in {@link PreflightWarningCode}; other strings may be added by the server. */\n code: PreflightWarningCode | (string & {})\n message: string\n}\n\nexport interface PreflightResult {\n ok: boolean\n merchantErrors: PreflightMerchantError[]\n addressErrors: PreflightAddressError[]\n itemErrors: PreflightItemError[]\n warnings: PreflightWarning[]\n degraded?: boolean\n warning?: string\n}\n\n/**\n * Body of the 429 the preflight route returns when a cart or IP is checked too often.\n * `Retry-After` carries the same number of seconds as `retryAfter`.\n */\nexport interface PreflightRateLimitedResponse {\n error: string\n code: 'rate_limited'\n retryAfter: number\n}\n","'use client'\n\n/**\n * Admin settings form for the AliExpress Dropshipping integration.\n *\n * @deprecated Not used by any consumer. It models per-store AppKey/AppSecret,\n * but the real flow is a platform app key plus merchant OAuth, owned by\n * amboras-dev-orchestrator (`backend/src/modules/dropshipping`). The Medusa\n * Store API has no config, status or test-connection routes for it to call.\n *\n * The component is intentionally dependency-light (no external UI kit,\n * no @tanstack/react-query peer) so the admin bundle can drop it in\n * without extra peer dep resolution.\n */\n\nimport * as React from 'react'\nimport type {\n AliExpressPluginConfig,\n AliExpressConnectionStatusDto,\n AliExpressTestConnectionResult,\n} from './types'\nimport { SECRET_SET_SENTINEL } from './types'\n\n/** @deprecated See {@link AliExpressDropshippingSettingsForm}. */\nexport interface AliExpressDropshippingSettingsFormProps {\n /** Current config for this store (fetched by the parent server component). */\n initialConfig: AliExpressPluginConfig\n /** Current connection status (from `GET /status`). */\n initialStatus: AliExpressConnectionStatusDto\n /**\n * Persist non-secret + optionally new secret values. The parent maps\n * this onto `PATCH /store/aliexpress-dropshipping/config` (or\n * equivalent) and then re-fetches config on success.\n *\n * `appSecret` is only sent when the merchant actually typed a new\n * value; if they leave the field untouched, this method receives\n * `undefined` for that key so the backend keeps the existing secret.\n */\n onSaveConfig: (patch: {\n appKey?: string\n appSecret?: string\n enabled?: boolean\n }) => Promise<void>\n /** Kick off `POST /oauth/start` and redirect to the returned URL. */\n onConnect: () => Promise<void>\n /** Kick off `POST /oauth/disconnect` and clear merchant credentials. */\n onDisconnect: () => Promise<void>\n /** Call `POST /test-connection` and return the result. */\n onTestConnection: () => Promise<AliExpressTestConnectionResult>\n}\n\ntype SaveState = 'idle' | 'saving' | 'saved' | 'error'\ntype TestState =\n | { kind: 'idle' }\n | { kind: 'running' }\n | { kind: 'ok'; categoryCount: number }\n | { kind: 'err'; code: string; msg: string }\n\n/**\n * Amboras admin settings surface for AliExpress Dropshipping.\n * Renders AppKey + AppSecret inputs, Test / Connect / Disconnect\n * buttons, status card, and a \"Coming soon\" order-forwarding block.\n */\n/** @deprecated Not used by any consumer; see the file header. */\nexport function AliExpressDropshippingSettingsForm(\n props: AliExpressDropshippingSettingsFormProps,\n): React.ReactElement {\n const {\n initialConfig,\n initialStatus,\n onSaveConfig,\n onConnect,\n onDisconnect,\n onTestConnection,\n } = props\n\n const [appKey, setAppKey] = React.useState<string>(\n initialConfig.appKey ?? '',\n )\n const secretPreset =\n initialConfig.appSecret === SECRET_SET_SENTINEL ||\n (typeof initialConfig.appSecret === 'string' &&\n initialConfig.appSecret.length > 0)\n const [appSecret, setAppSecret] = React.useState<string>('')\n const [secretDirty, setSecretDirty] = React.useState<boolean>(false)\n\n const [saveState, setSaveState] = React.useState<SaveState>('idle')\n const [saveError, setSaveError] = React.useState<string | null>(null)\n\n const [testState, setTestState] = React.useState<TestState>({ kind: 'idle' })\n const [testEverSucceeded, setTestEverSucceeded] = React.useState<boolean>(\n initialStatus.connected,\n )\n\n const [busyOAuth, setBusyOAuth] = React.useState<boolean>(false)\n\n const hasStoredSecret = secretPreset || secretDirty\n const canTest = appKey.trim().length > 0 && hasStoredSecret\n const canConnect = testEverSucceeded && !initialStatus.connected\n const canDisconnect = initialStatus.connected\n\n const handleSave = React.useCallback(async () => {\n setSaveState('saving')\n setSaveError(null)\n try {\n const patch: {\n appKey?: string\n appSecret?: string\n enabled?: boolean\n } = {}\n if (appKey.trim() !== (initialConfig.appKey ?? '')) {\n patch.appKey = appKey.trim()\n }\n if (secretDirty && appSecret.length > 0) {\n patch.appSecret = appSecret\n }\n await onSaveConfig(patch)\n setSaveState('saved')\n setSecretDirty(false)\n setAppSecret('')\n } catch (err) {\n setSaveState('error')\n setSaveError(err instanceof Error ? err.message : 'Save failed')\n }\n }, [appKey, appSecret, secretDirty, initialConfig.appKey, onSaveConfig])\n\n const handleTest = React.useCallback(async () => {\n setTestState({ kind: 'running' })\n try {\n const result = await onTestConnection()\n if (result.ok) {\n setTestState({ kind: 'ok', categoryCount: result.categoryCount })\n setTestEverSucceeded(true)\n } else {\n setTestState({ kind: 'err', code: result.code, msg: result.msg })\n }\n } catch (err) {\n setTestState({\n kind: 'err',\n code: 'UNKNOWN',\n msg: err instanceof Error ? err.message : 'Test failed',\n })\n }\n }, [onTestConnection])\n\n const handleConnect = React.useCallback(async () => {\n setBusyOAuth(true)\n try {\n await onConnect()\n } finally {\n setBusyOAuth(false)\n }\n }, [onConnect])\n\n const handleDisconnect = React.useCallback(async () => {\n setBusyOAuth(true)\n try {\n await onDisconnect()\n } finally {\n setBusyOAuth(false)\n }\n }, [onDisconnect])\n\n return (\n <div className=\"aliexpress-dropshipping-settings\">\n <section aria-labelledby=\"ae-credentials-heading\">\n <h2 id=\"ae-credentials-heading\">Developer app credentials</h2>\n <p>\n Enter your AliExpress Open Platform app credentials. These are\n stored encrypted at rest and used to sign every AliExpress API\n call for this store.\n </p>\n\n <label>\n <span>App Key</span>\n <input\n type=\"text\"\n value={appKey}\n onChange={(e) => setAppKey(e.target.value)}\n autoComplete=\"off\"\n spellCheck={false}\n />\n </label>\n\n <label>\n <span>App Secret</span>\n <input\n type=\"password\"\n value={appSecret}\n placeholder={secretPreset ? '(secret set - leave blank to keep)' : ''}\n onChange={(e) => {\n setAppSecret(e.target.value)\n setSecretDirty(true)\n }}\n autoComplete=\"off\"\n spellCheck={false}\n />\n </label>\n\n <div className=\"actions\">\n <button\n type=\"button\"\n onClick={handleSave}\n disabled={saveState === 'saving' || appKey.trim().length === 0}\n >\n {saveState === 'saving' ? 'Saving...' : 'Save credentials'}\n </button>\n <button\n type=\"button\"\n onClick={handleTest}\n disabled={!canTest || testState.kind === 'running'}\n >\n {testState.kind === 'running' ? 'Testing...' : 'Test connection'}\n </button>\n </div>\n\n {saveState === 'saved' ? <p role=\"status\">Saved.</p> : null}\n {saveState === 'error' && saveError ? (\n <p role=\"alert\">Save failed: {saveError}</p>\n ) : null}\n\n {testState.kind === 'ok' ? (\n <p role=\"status\">\n Connected to AliExpress. Found {testState.categoryCount} categories.\n </p>\n ) : null}\n {testState.kind === 'err' ? (\n <p role=\"alert\">\n Test failed ({testState.code}): {testState.msg}\n </p>\n ) : null}\n </section>\n\n <section aria-labelledby=\"ae-oauth-heading\">\n <h2 id=\"ae-oauth-heading\">Merchant account connection</h2>\n <p>\n Connect a specific AliExpress seller account to enable product\n import into this store. This is separate from the developer app\n credentials above.\n </p>\n\n {initialStatus.needsReauth ? (\n <p role=\"alert\" className=\"reauth-banner\">\n Re-authentication required. Please reconnect your AliExpress account.\n </p>\n ) : null}\n\n <div className=\"status-card\">\n <div>\n <strong>Status:</strong>{' '}\n {initialStatus.connected ? 'Connected' : 'Not connected'}\n </div>\n {initialStatus.sellerId ? (\n <div>\n <strong>Seller ID:</strong> {initialStatus.sellerId}\n </div>\n ) : null}\n {initialStatus.lastSuccessfulCallAt ? (\n <div>\n <strong>Last successful call:</strong>{' '}\n {initialStatus.lastSuccessfulCallAt}\n </div>\n ) : null}\n </div>\n\n <div className=\"actions\">\n <button\n type=\"button\"\n onClick={handleConnect}\n disabled={!canConnect || busyOAuth}\n >\n {busyOAuth ? 'Working...' : 'Connect merchant AliExpress account'}\n </button>\n <button\n type=\"button\"\n onClick={handleDisconnect}\n disabled={!canDisconnect || busyOAuth}\n >\n Disconnect\n </button>\n </div>\n\n {!testEverSucceeded ? (\n <p>\n Run <em>Test connection</em> once with your AppKey/AppSecret before\n connecting a merchant account.\n </p>\n ) : null}\n </section>\n\n <section aria-labelledby=\"ae-coming-soon-heading\">\n <h2 id=\"ae-coming-soon-heading\">Order forwarding</h2>\n <p>\n Coming soon. Automatic order forwarding to AliExpress requires\n our app to be approved out of Test status by AliExpress. Product\n import and browsing work today.\n </p>\n </section>\n </div>\n )\n}\n\nexport default AliExpressDropshippingSettingsForm\n"],"mappings":";AAmBO,IAAM,sBAAsB;AAoC5B,IAAK,yBAAL,kBAAKA,4BAAL;AACL,EAAAA,wBAAA,wBAAqB;AACrB,EAAAA,wBAAA,wBAAqB;AACrB,EAAAA,wBAAA,mBAAgB;AAChB,EAAAA,wBAAA,kBAAe;AAJL,SAAAA;AAAA,GAAA;;;ACxCZ,YAAY,WAAW;AAuJf,cAOA,YAPA;AAtGD,SAAS,mCACd,OACoB;AACpB,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,QAAM,CAAC,QAAQ,SAAS,IAAU;AAAA,IAChC,cAAc,UAAU;AAAA,EAC1B;AACA,QAAM,eACJ,cAAc,cAAc,uBAC3B,OAAO,cAAc,cAAc,YAClC,cAAc,UAAU,SAAS;AACrC,QAAM,CAAC,WAAW,YAAY,IAAU,eAAiB,EAAE;AAC3D,QAAM,CAAC,aAAa,cAAc,IAAU,eAAkB,KAAK;AAEnE,QAAM,CAAC,WAAW,YAAY,IAAU,eAAoB,MAAM;AAClE,QAAM,CAAC,WAAW,YAAY,IAAU,eAAwB,IAAI;AAEpE,QAAM,CAAC,WAAW,YAAY,IAAU,eAAoB,EAAE,MAAM,OAAO,CAAC;AAC5E,QAAM,CAAC,mBAAmB,oBAAoB,IAAU;AAAA,IACtD,cAAc;AAA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AAA;AAAA,QAC9B;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,MAAK;AAAA,YACL,SAAS;AAAA,YACT,UAAU,CAAC,iBAAiB;AAAA,YAC7B;AAAA;AAAA,QAED;AAAA,SACF;AAAA,MAEC,CAAC,oBACA,qBAAC,OAAE;AAAA;AAAA,QACG,oBAAC,QAAG,6BAAe;AAAA,QAAK;AAAA,SAE9B,IACE;AAAA,OACN;AAAA,IAEA,qBAAC,aAAQ,mBAAgB,0BACvB;AAAA,0BAAC,QAAG,IAAG,0BAAyB,8BAAgB;AAAA,MAChD,oBAAC,OAAE,6KAIH;AAAA,OACF;AAAA,KACF;AAEJ;","names":["AliExpressReauthReason"]}
@@ -1,10 +1,17 @@
1
- import { P as PreflightResult } from '../types-CiA0K7nl.mjs';
2
- export { a as PreflightAddressError, b as PreflightItemError, c as PreflightMerchantError } from '../types-CiA0K7nl.mjs';
1
+ import { P as PreflightResult } from '../types-Cp-7f9WI.mjs';
2
+ export { a as PreflightAddressError, b as PreflightAddressErrorCode, c as PreflightItemError, d as PreflightMerchantError, e as PreflightMerchantErrorCode, f as PreflightRateLimitedResponse } from '../types-Cp-7f9WI.mjs';
3
3
 
4
4
  interface UseAliexpressPreflightOptions {
5
5
  baseUrl?: string;
6
6
  publishableKey?: string;
7
7
  }
8
+ /**
9
+ * Calls `POST /store/aliexpress-dropshipping/preflight-cart`.
10
+ *
11
+ * Returns `{ mutateAsync, isPending }`, not a `PreflightResult`.
12
+ * `mutateAsync({ cartId })` resolves to the `PreflightResult` and rejects on a
13
+ * non-2xx response.
14
+ */
8
15
  declare function useAliexpressPreflight(options?: UseAliexpressPreflightOptions): {
9
16
  mutateAsync: ({ cartId }: {
10
17
  cartId: string;
@@ -1,10 +1,17 @@
1
- import { P as PreflightResult } from '../types-CiA0K7nl.js';
2
- export { a as PreflightAddressError, b as PreflightItemError, c as PreflightMerchantError } from '../types-CiA0K7nl.js';
1
+ import { P as PreflightResult } from '../types-Cp-7f9WI.js';
2
+ export { a as PreflightAddressError, b as PreflightAddressErrorCode, c as PreflightItemError, d as PreflightMerchantError, e as PreflightMerchantErrorCode, f as PreflightRateLimitedResponse } from '../types-Cp-7f9WI.js';
3
3
 
4
4
  interface UseAliexpressPreflightOptions {
5
5
  baseUrl?: string;
6
6
  publishableKey?: string;
7
7
  }
8
+ /**
9
+ * Calls `POST /store/aliexpress-dropshipping/preflight-cart`.
10
+ *
11
+ * Returns `{ mutateAsync, isPending }`, not a `PreflightResult`.
12
+ * `mutateAsync({ cartId })` resolves to the `PreflightResult` and rejects on a
13
+ * non-2xx response.
14
+ */
8
15
  declare function useAliexpressPreflight(options?: UseAliexpressPreflightOptions): {
9
16
  mutateAsync: ({ cartId }: {
10
17
  cartId: string;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/client/index.ts","../../src/client/use-preflight.ts"],"sourcesContent":["export { useAliexpressPreflight, type UseAliexpressPreflightOptions } from './use-preflight'\nexport type {\n PreflightResult,\n PreflightMerchantError,\n PreflightAddressError,\n PreflightItemError,\n} from '../types'","'use client'\n\nimport { useCallback, useState } from 'react'\nimport type { PreflightResult } from '../types'\n\nexport interface UseAliexpressPreflightOptions {\n baseUrl?: string\n publishableKey?: string\n}\n\nexport function useAliexpressPreflight(options: UseAliexpressPreflightOptions = {}) {\n const [isPending, setIsPending] = useState(false)\n const mutateAsync = useCallback(async ({ cartId }: { cartId: string }): Promise<PreflightResult> => {\n setIsPending(true)\n try {\n const baseUrl = options.baseUrl ?? process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL ?? ''\n const publishableKey = options.publishableKey ?? process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY ?? ''\n const response = await fetch(`${baseUrl.replace(/\\/$/, '')}/store/aliexpress-dropshipping/preflight-cart`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n ...(publishableKey ? { 'x-publishable-api-key': publishableKey } : {}),\n },\n body: JSON.stringify({ cart_id: cartId }),\n })\n if (!response.ok) throw new Error(`Preflight check failed: ${response.status}`)\n return await response.json() as PreflightResult\n } finally {\n setIsPending(false)\n }\n }, [options.baseUrl, options.publishableKey])\n\n return { mutateAsync, isPending }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,mBAAsC;AAQ/B,SAAS,uBAAuB,UAAyC,CAAC,GAAG;AAClF,QAAM,CAAC,WAAW,YAAY,QAAI,uBAAS,KAAK;AAChD,QAAM,kBAAc,0BAAY,OAAO,EAAE,OAAO,MAAoD;AAClG,iBAAa,IAAI;AACjB,QAAI;AACF,YAAM,UAAU,QAAQ,WAAW,QAAQ,IAAI,kCAAkC;AACjF,YAAM,iBAAiB,QAAQ,kBAAkB,QAAQ,IAAI,sCAAsC;AACnG,YAAM,WAAW,MAAM,MAAM,GAAG,QAAQ,QAAQ,OAAO,EAAE,CAAC,iDAAiD;AAAA,QACzG,QAAQ;AAAA,QACR,SAAS;AAAA,UACP,gBAAgB;AAAA,UAChB,GAAI,iBAAiB,EAAE,yBAAyB,eAAe,IAAI,CAAC;AAAA,QACtE;AAAA,QACA,MAAM,KAAK,UAAU,EAAE,SAAS,OAAO,CAAC;AAAA,MAC1C,CAAC;AACD,UAAI,CAAC,SAAS,GAAI,OAAM,IAAI,MAAM,2BAA2B,SAAS,MAAM,EAAE;AAC9E,aAAO,MAAM,SAAS,KAAK;AAAA,IAC7B,UAAE;AACA,mBAAa,KAAK;AAAA,IACpB;AAAA,EACF,GAAG,CAAC,QAAQ,SAAS,QAAQ,cAAc,CAAC;AAE5C,SAAO,EAAE,aAAa,UAAU;AAClC;","names":[]}
1
+ {"version":3,"sources":["../../src/client/index.ts","../../src/client/use-preflight.ts"],"sourcesContent":["export { useAliexpressPreflight, type UseAliexpressPreflightOptions } from './use-preflight'\nexport type {\n PreflightResult,\n PreflightMerchantError,\n PreflightMerchantErrorCode,\n PreflightAddressErrorCode,\n PreflightRateLimitedResponse,\n PreflightAddressError,\n PreflightItemError,\n} from '../types'","'use client'\n\nimport { useCallback, useState } from 'react'\nimport type { PreflightResult } from '../types'\n\nexport interface UseAliexpressPreflightOptions {\n baseUrl?: string\n publishableKey?: string\n}\n\n/**\n * Calls `POST /store/aliexpress-dropshipping/preflight-cart`.\n *\n * Returns `{ mutateAsync, isPending }`, not a `PreflightResult`.\n * `mutateAsync({ cartId })` resolves to the `PreflightResult` and rejects on a\n * non-2xx response.\n */\nexport function useAliexpressPreflight(options: UseAliexpressPreflightOptions = {}) {\n const [isPending, setIsPending] = useState(false)\n const mutateAsync = useCallback(async ({ cartId }: { cartId: string }): Promise<PreflightResult> => {\n setIsPending(true)\n try {\n const baseUrl = options.baseUrl ?? process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL ?? ''\n const publishableKey = options.publishableKey ?? process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY ?? ''\n const response = await fetch(`${baseUrl.replace(/\\/$/, '')}/store/aliexpress-dropshipping/preflight-cart`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n ...(publishableKey ? { 'x-publishable-api-key': publishableKey } : {}),\n },\n body: JSON.stringify({ cart_id: cartId }),\n })\n if (!response.ok) throw new Error(`Preflight check failed: ${response.status}`)\n return await response.json() as PreflightResult\n } finally {\n setIsPending(false)\n }\n }, [options.baseUrl, options.publishableKey])\n\n return { mutateAsync, isPending }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,mBAAsC;AAe/B,SAAS,uBAAuB,UAAyC,CAAC,GAAG;AAClF,QAAM,CAAC,WAAW,YAAY,QAAI,uBAAS,KAAK;AAChD,QAAM,kBAAc,0BAAY,OAAO,EAAE,OAAO,MAAoD;AAClG,iBAAa,IAAI;AACjB,QAAI;AACF,YAAM,UAAU,QAAQ,WAAW,QAAQ,IAAI,kCAAkC;AACjF,YAAM,iBAAiB,QAAQ,kBAAkB,QAAQ,IAAI,sCAAsC;AACnG,YAAM,WAAW,MAAM,MAAM,GAAG,QAAQ,QAAQ,OAAO,EAAE,CAAC,iDAAiD;AAAA,QACzG,QAAQ;AAAA,QACR,SAAS;AAAA,UACP,gBAAgB;AAAA,UAChB,GAAI,iBAAiB,EAAE,yBAAyB,eAAe,IAAI,CAAC;AAAA,QACtE;AAAA,QACA,MAAM,KAAK,UAAU,EAAE,SAAS,OAAO,CAAC;AAAA,MAC1C,CAAC;AACD,UAAI,CAAC,SAAS,GAAI,OAAM,IAAI,MAAM,2BAA2B,SAAS,MAAM,EAAE;AAC9E,aAAO,MAAM,SAAS,KAAK;AAAA,IAC7B,UAAE;AACA,mBAAa,KAAK;AAAA,IACpB;AAAA,EACF,GAAG,CAAC,QAAQ,SAAS,QAAQ,cAAc,CAAC;AAE5C,SAAO,EAAE,aAAa,UAAU;AAClC;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/client/use-preflight.ts"],"sourcesContent":["'use client'\n\nimport { useCallback, useState } from 'react'\nimport type { PreflightResult } from '../types'\n\nexport interface UseAliexpressPreflightOptions {\n baseUrl?: string\n publishableKey?: string\n}\n\nexport function useAliexpressPreflight(options: UseAliexpressPreflightOptions = {}) {\n const [isPending, setIsPending] = useState(false)\n const mutateAsync = useCallback(async ({ cartId }: { cartId: string }): Promise<PreflightResult> => {\n setIsPending(true)\n try {\n const baseUrl = options.baseUrl ?? process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL ?? ''\n const publishableKey = options.publishableKey ?? process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY ?? ''\n const response = await fetch(`${baseUrl.replace(/\\/$/, '')}/store/aliexpress-dropshipping/preflight-cart`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n ...(publishableKey ? { 'x-publishable-api-key': publishableKey } : {}),\n },\n body: JSON.stringify({ cart_id: cartId }),\n })\n if (!response.ok) throw new Error(`Preflight check failed: ${response.status}`)\n return await response.json() as PreflightResult\n } finally {\n setIsPending(false)\n }\n }, [options.baseUrl, options.publishableKey])\n\n return { mutateAsync, isPending }\n}\n"],"mappings":";AAEA,SAAS,aAAa,gBAAgB;AAQ/B,SAAS,uBAAuB,UAAyC,CAAC,GAAG;AAClF,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAChD,QAAM,cAAc,YAAY,OAAO,EAAE,OAAO,MAAoD;AAClG,iBAAa,IAAI;AACjB,QAAI;AACF,YAAM,UAAU,QAAQ,WAAW,QAAQ,IAAI,kCAAkC;AACjF,YAAM,iBAAiB,QAAQ,kBAAkB,QAAQ,IAAI,sCAAsC;AACnG,YAAM,WAAW,MAAM,MAAM,GAAG,QAAQ,QAAQ,OAAO,EAAE,CAAC,iDAAiD;AAAA,QACzG,QAAQ;AAAA,QACR,SAAS;AAAA,UACP,gBAAgB;AAAA,UAChB,GAAI,iBAAiB,EAAE,yBAAyB,eAAe,IAAI,CAAC;AAAA,QACtE;AAAA,QACA,MAAM,KAAK,UAAU,EAAE,SAAS,OAAO,CAAC;AAAA,MAC1C,CAAC;AACD,UAAI,CAAC,SAAS,GAAI,OAAM,IAAI,MAAM,2BAA2B,SAAS,MAAM,EAAE;AAC9E,aAAO,MAAM,SAAS,KAAK;AAAA,IAC7B,UAAE;AACA,mBAAa,KAAK;AAAA,IACpB;AAAA,EACF,GAAG,CAAC,QAAQ,SAAS,QAAQ,cAAc,CAAC;AAE5C,SAAO,EAAE,aAAa,UAAU;AAClC;","names":[]}
1
+ {"version":3,"sources":["../../src/client/use-preflight.ts"],"sourcesContent":["'use client'\n\nimport { useCallback, useState } from 'react'\nimport type { PreflightResult } from '../types'\n\nexport interface UseAliexpressPreflightOptions {\n baseUrl?: string\n publishableKey?: string\n}\n\n/**\n * Calls `POST /store/aliexpress-dropshipping/preflight-cart`.\n *\n * Returns `{ mutateAsync, isPending }`, not a `PreflightResult`.\n * `mutateAsync({ cartId })` resolves to the `PreflightResult` and rejects on a\n * non-2xx response.\n */\nexport function useAliexpressPreflight(options: UseAliexpressPreflightOptions = {}) {\n const [isPending, setIsPending] = useState(false)\n const mutateAsync = useCallback(async ({ cartId }: { cartId: string }): Promise<PreflightResult> => {\n setIsPending(true)\n try {\n const baseUrl = options.baseUrl ?? process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL ?? ''\n const publishableKey = options.publishableKey ?? process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY ?? ''\n const response = await fetch(`${baseUrl.replace(/\\/$/, '')}/store/aliexpress-dropshipping/preflight-cart`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n ...(publishableKey ? { 'x-publishable-api-key': publishableKey } : {}),\n },\n body: JSON.stringify({ cart_id: cartId }),\n })\n if (!response.ok) throw new Error(`Preflight check failed: ${response.status}`)\n return await response.json() as PreflightResult\n } finally {\n setIsPending(false)\n }\n }, [options.baseUrl, options.publishableKey])\n\n return { mutateAsync, isPending }\n}\n"],"mappings":";AAEA,SAAS,aAAa,gBAAgB;AAe/B,SAAS,uBAAuB,UAAyC,CAAC,GAAG;AAClF,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAChD,QAAM,cAAc,YAAY,OAAO,EAAE,OAAO,MAAoD;AAClG,iBAAa,IAAI;AACjB,QAAI;AACF,YAAM,UAAU,QAAQ,WAAW,QAAQ,IAAI,kCAAkC;AACjF,YAAM,iBAAiB,QAAQ,kBAAkB,QAAQ,IAAI,sCAAsC;AACnG,YAAM,WAAW,MAAM,MAAM,GAAG,QAAQ,QAAQ,OAAO,EAAE,CAAC,iDAAiD;AAAA,QACzG,QAAQ;AAAA,QACR,SAAS;AAAA,UACP,gBAAgB;AAAA,UAChB,GAAI,iBAAiB,EAAE,yBAAyB,eAAe,IAAI,CAAC;AAAA,QACtE;AAAA,QACA,MAAM,KAAK,UAAU,EAAE,SAAS,OAAO,CAAC;AAAA,MAC1C,CAAC;AACD,UAAI,CAAC,SAAS,GAAI,OAAM,IAAI,MAAM,2BAA2B,SAAS,MAAM,EAAE;AAC9E,aAAO,MAAM,SAAS,KAAK;AAAA,IAC7B,UAAE;AACA,mBAAa,KAAK;AAAA,IACpB;AAAA,EACF,GAAG,CAAC,QAAQ,SAAS,QAAQ,cAAc,CAAC;AAE5C,SAAO,EAAE,aAAa,UAAU;AAClC;","names":[]}
package/dist/index.d.mts CHANGED
@@ -1,20 +1,21 @@
1
- import { A as AliExpressPluginConfig, d as AliExpressConnectionStatusDto, e as AliExpressTestConnectionResult } from './types-CiA0K7nl.mjs';
2
- export { f as AliExpressCategoryDto, g as AliExpressImportResultDto, h as AliExpressProductDto, i as AliExpressProductSummaryDto, j as AliExpressProductVariantDto, k as AliExpressReauthReason, S as SECRET_SET_SENTINEL, l as SecretSetSentinel } from './types-CiA0K7nl.mjs';
1
+ import { A as AliExpressPluginConfig, g as AliExpressConnectionStatusDto, h as AliExpressTestConnectionResult } from './types-Cp-7f9WI.mjs';
2
+ export { i as AliExpressCategoryDto, j as AliExpressImportResultDto, k as AliExpressProductDto, l as AliExpressProductSummaryDto, m as AliExpressProductVariantDto, n as AliExpressReauthReason, a as PreflightAddressError, b as PreflightAddressErrorCode, c as PreflightItemError, d as PreflightMerchantError, e as PreflightMerchantErrorCode, f as PreflightRateLimitedResponse, P as PreflightResult, o as PreflightWarning, p as PreflightWarningCode, S as SECRET_SET_SENTINEL, q as SecretSetSentinel } from './types-Cp-7f9WI.mjs';
3
3
  import * as React from 'react';
4
4
 
5
5
  /**
6
6
  * Admin settings form for the AliExpress Dropshipping integration.
7
7
  *
8
- * Class B: this component owns the UI and talks to the Medusa Store API
9
- * under `/store/aliexpress-dropshipping/*`. It does NOT embed any
10
- * AliExpress SDK, does not sign requests, and does not touch OAuth
11
- * tokens directly - the backend does all of that.
8
+ * @deprecated Not used by any consumer. It models per-store AppKey/AppSecret,
9
+ * but the real flow is a platform app key plus merchant OAuth, owned by
10
+ * amboras-dev-orchestrator (`backend/src/modules/dropshipping`). The Medusa
11
+ * Store API has no config, status or test-connection routes for it to call.
12
12
  *
13
13
  * The component is intentionally dependency-light (no external UI kit,
14
14
  * no @tanstack/react-query peer) so the admin bundle can drop it in
15
15
  * without extra peer dep resolution.
16
16
  */
17
17
 
18
+ /** @deprecated See {@link AliExpressDropshippingSettingsForm}. */
18
19
  interface AliExpressDropshippingSettingsFormProps {
19
20
  /** Current config for this store (fetched by the parent server component). */
20
21
  initialConfig: AliExpressPluginConfig;
@@ -46,6 +47,7 @@ interface AliExpressDropshippingSettingsFormProps {
46
47
  * Renders AppKey + AppSecret inputs, Test / Connect / Disconnect
47
48
  * buttons, status card, and a "Coming soon" order-forwarding block.
48
49
  */
50
+ /** @deprecated Not used by any consumer; see the file header. */
49
51
  declare function AliExpressDropshippingSettingsForm(props: AliExpressDropshippingSettingsFormProps): React.ReactElement;
50
52
 
51
53
  export { AliExpressConnectionStatusDto, AliExpressDropshippingSettingsForm, type AliExpressDropshippingSettingsFormProps, AliExpressPluginConfig, AliExpressTestConnectionResult };
package/dist/index.d.ts CHANGED
@@ -1,20 +1,21 @@
1
- import { A as AliExpressPluginConfig, d as AliExpressConnectionStatusDto, e as AliExpressTestConnectionResult } from './types-CiA0K7nl.js';
2
- export { f as AliExpressCategoryDto, g as AliExpressImportResultDto, h as AliExpressProductDto, i as AliExpressProductSummaryDto, j as AliExpressProductVariantDto, k as AliExpressReauthReason, S as SECRET_SET_SENTINEL, l as SecretSetSentinel } from './types-CiA0K7nl.js';
1
+ import { A as AliExpressPluginConfig, g as AliExpressConnectionStatusDto, h as AliExpressTestConnectionResult } from './types-Cp-7f9WI.js';
2
+ export { i as AliExpressCategoryDto, j as AliExpressImportResultDto, k as AliExpressProductDto, l as AliExpressProductSummaryDto, m as AliExpressProductVariantDto, n as AliExpressReauthReason, a as PreflightAddressError, b as PreflightAddressErrorCode, c as PreflightItemError, d as PreflightMerchantError, e as PreflightMerchantErrorCode, f as PreflightRateLimitedResponse, P as PreflightResult, o as PreflightWarning, p as PreflightWarningCode, S as SECRET_SET_SENTINEL, q as SecretSetSentinel } from './types-Cp-7f9WI.js';
3
3
  import * as React from 'react';
4
4
 
5
5
  /**
6
6
  * Admin settings form for the AliExpress Dropshipping integration.
7
7
  *
8
- * Class B: this component owns the UI and talks to the Medusa Store API
9
- * under `/store/aliexpress-dropshipping/*`. It does NOT embed any
10
- * AliExpress SDK, does not sign requests, and does not touch OAuth
11
- * tokens directly - the backend does all of that.
8
+ * @deprecated Not used by any consumer. It models per-store AppKey/AppSecret,
9
+ * but the real flow is a platform app key plus merchant OAuth, owned by
10
+ * amboras-dev-orchestrator (`backend/src/modules/dropshipping`). The Medusa
11
+ * Store API has no config, status or test-connection routes for it to call.
12
12
  *
13
13
  * The component is intentionally dependency-light (no external UI kit,
14
14
  * no @tanstack/react-query peer) so the admin bundle can drop it in
15
15
  * without extra peer dep resolution.
16
16
  */
17
17
 
18
+ /** @deprecated See {@link AliExpressDropshippingSettingsForm}. */
18
19
  interface AliExpressDropshippingSettingsFormProps {
19
20
  /** Current config for this store (fetched by the parent server component). */
20
21
  initialConfig: AliExpressPluginConfig;
@@ -46,6 +47,7 @@ interface AliExpressDropshippingSettingsFormProps {
46
47
  * Renders AppKey + AppSecret inputs, Test / Connect / Disconnect
47
48
  * buttons, status card, and a "Coming soon" order-forwarding block.
48
49
  */
50
+ /** @deprecated Not used by any consumer; see the file header. */
49
51
  declare function AliExpressDropshippingSettingsForm(props: AliExpressDropshippingSettingsFormProps): React.ReactElement;
50
52
 
51
53
  export { AliExpressConnectionStatusDto, AliExpressDropshippingSettingsForm, type AliExpressDropshippingSettingsFormProps, AliExpressPluginConfig, AliExpressTestConnectionResult };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/settings-form.tsx","../src/types.ts"],"sourcesContent":["// Admin settings form (Class B - the only React surface).\nexport {\n AliExpressDropshippingSettingsForm,\n type AliExpressDropshippingSettingsFormProps,\n} from './settings-form'\n\n// Shared wire types - kept in sync with the medusa-backend-orchestrator DTOs.\nexport {\n SECRET_SET_SENTINEL,\n AliExpressReauthReason,\n} from './types'\nexport type {\n SecretSetSentinel,\n AliExpressPluginConfig,\n AliExpressCategoryDto,\n AliExpressProductSummaryDto,\n AliExpressProductDto,\n AliExpressProductVariantDto,\n AliExpressImportResultDto,\n AliExpressConnectionStatusDto,\n AliExpressTestConnectionResult,\n} from './types'\n\n","'use client'\n\n/**\n * Admin settings form for the AliExpress Dropshipping integration.\n *\n * Class B: this component owns the UI and talks to the Medusa Store API\n * under `/store/aliexpress-dropshipping/*`. It does NOT embed any\n * AliExpress SDK, does not sign requests, and does not touch OAuth\n * tokens directly - the backend does all of that.\n *\n * The component is intentionally dependency-light (no external UI kit,\n * no @tanstack/react-query peer) so the admin bundle can drop it in\n * without extra peer dep resolution.\n */\n\nimport * as React from 'react'\nimport type {\n AliExpressPluginConfig,\n AliExpressConnectionStatusDto,\n AliExpressTestConnectionResult,\n} from './types'\nimport { SECRET_SET_SENTINEL } from './types'\n\nexport interface AliExpressDropshippingSettingsFormProps {\n /** Current config for this store (fetched by the parent server component). */\n initialConfig: AliExpressPluginConfig\n /** Current connection status (from `GET /status`). */\n initialStatus: AliExpressConnectionStatusDto\n /**\n * Persist non-secret + optionally new secret values. The parent maps\n * this onto `PATCH /store/aliexpress-dropshipping/config` (or\n * equivalent) and then re-fetches config on success.\n *\n * `appSecret` is only sent when the merchant actually typed a new\n * value; if they leave the field untouched, this method receives\n * `undefined` for that key so the backend keeps the existing secret.\n */\n onSaveConfig: (patch: {\n appKey?: string\n appSecret?: string\n enabled?: boolean\n }) => Promise<void>\n /** Kick off `POST /oauth/start` and redirect to the returned URL. */\n onConnect: () => Promise<void>\n /** Kick off `POST /oauth/disconnect` and clear merchant credentials. */\n onDisconnect: () => Promise<void>\n /** Call `POST /test-connection` and return the result. */\n onTestConnection: () => Promise<AliExpressTestConnectionResult>\n}\n\ntype SaveState = 'idle' | 'saving' | 'saved' | 'error'\ntype TestState =\n | { kind: 'idle' }\n | { kind: 'running' }\n | { kind: 'ok'; categoryCount: number }\n | { kind: 'err'; code: string; msg: string }\n\n/**\n * Amboras admin settings surface for AliExpress Dropshipping.\n * Renders AppKey + AppSecret inputs, Test / Connect / Disconnect\n * buttons, status card, and a \"Coming soon\" order-forwarding block.\n */\nexport function AliExpressDropshippingSettingsForm(\n props: AliExpressDropshippingSettingsFormProps,\n): React.ReactElement {\n const {\n initialConfig,\n initialStatus,\n onSaveConfig,\n onConnect,\n onDisconnect,\n onTestConnection,\n } = props\n\n const [appKey, setAppKey] = React.useState<string>(\n initialConfig.appKey ?? '',\n )\n const secretPreset =\n initialConfig.appSecret === SECRET_SET_SENTINEL ||\n (typeof initialConfig.appSecret === 'string' &&\n initialConfig.appSecret.length > 0)\n const [appSecret, setAppSecret] = React.useState<string>('')\n const [secretDirty, setSecretDirty] = React.useState<boolean>(false)\n\n const [saveState, setSaveState] = React.useState<SaveState>('idle')\n const [saveError, setSaveError] = React.useState<string | null>(null)\n\n const [testState, setTestState] = React.useState<TestState>({ kind: 'idle' })\n const [testEverSucceeded, setTestEverSucceeded] = React.useState<boolean>(\n initialStatus.connected,\n )\n\n const [busyOAuth, setBusyOAuth] = React.useState<boolean>(false)\n\n const hasStoredSecret = secretPreset || secretDirty\n const canTest = appKey.trim().length > 0 && hasStoredSecret\n const canConnect = testEverSucceeded && !initialStatus.connected\n const canDisconnect = initialStatus.connected\n\n const handleSave = React.useCallback(async () => {\n setSaveState('saving')\n setSaveError(null)\n try {\n const patch: {\n appKey?: string\n appSecret?: string\n enabled?: boolean\n } = {}\n if (appKey.trim() !== (initialConfig.appKey ?? '')) {\n patch.appKey = appKey.trim()\n }\n if (secretDirty && appSecret.length > 0) {\n patch.appSecret = appSecret\n }\n await onSaveConfig(patch)\n setSaveState('saved')\n setSecretDirty(false)\n setAppSecret('')\n } catch (err) {\n setSaveState('error')\n setSaveError(err instanceof Error ? err.message : 'Save failed')\n }\n }, [appKey, appSecret, secretDirty, initialConfig.appKey, onSaveConfig])\n\n const handleTest = React.useCallback(async () => {\n setTestState({ kind: 'running' })\n try {\n const result = await onTestConnection()\n if (result.ok) {\n setTestState({ kind: 'ok', categoryCount: result.categoryCount })\n setTestEverSucceeded(true)\n } else {\n setTestState({ kind: 'err', code: result.code, msg: result.msg })\n }\n } catch (err) {\n setTestState({\n kind: 'err',\n code: 'UNKNOWN',\n msg: err instanceof Error ? err.message : 'Test failed',\n })\n }\n }, [onTestConnection])\n\n const handleConnect = React.useCallback(async () => {\n setBusyOAuth(true)\n try {\n await onConnect()\n } finally {\n setBusyOAuth(false)\n }\n }, [onConnect])\n\n const handleDisconnect = React.useCallback(async () => {\n setBusyOAuth(true)\n try {\n await onDisconnect()\n } finally {\n setBusyOAuth(false)\n }\n }, [onDisconnect])\n\n return (\n <div className=\"aliexpress-dropshipping-settings\">\n <section aria-labelledby=\"ae-credentials-heading\">\n <h2 id=\"ae-credentials-heading\">Developer app credentials</h2>\n <p>\n Enter your AliExpress Open Platform app credentials. These are\n stored encrypted at rest and used to sign every AliExpress API\n call for this store.\n </p>\n\n <label>\n <span>App Key</span>\n <input\n type=\"text\"\n value={appKey}\n onChange={(e) => setAppKey(e.target.value)}\n autoComplete=\"off\"\n spellCheck={false}\n />\n </label>\n\n <label>\n <span>App Secret</span>\n <input\n type=\"password\"\n value={appSecret}\n placeholder={secretPreset ? '(secret set - leave blank to keep)' : ''}\n onChange={(e) => {\n setAppSecret(e.target.value)\n setSecretDirty(true)\n }}\n autoComplete=\"off\"\n spellCheck={false}\n />\n </label>\n\n <div className=\"actions\">\n <button\n type=\"button\"\n onClick={handleSave}\n disabled={saveState === 'saving' || appKey.trim().length === 0}\n >\n {saveState === 'saving' ? 'Saving...' : 'Save credentials'}\n </button>\n <button\n type=\"button\"\n onClick={handleTest}\n disabled={!canTest || testState.kind === 'running'}\n >\n {testState.kind === 'running' ? 'Testing...' : 'Test connection'}\n </button>\n </div>\n\n {saveState === 'saved' ? <p role=\"status\">Saved.</p> : null}\n {saveState === 'error' && saveError ? (\n <p role=\"alert\">Save failed: {saveError}</p>\n ) : null}\n\n {testState.kind === 'ok' ? (\n <p role=\"status\">\n Connected to AliExpress. Found {testState.categoryCount} categories.\n </p>\n ) : null}\n {testState.kind === 'err' ? (\n <p role=\"alert\">\n Test failed ({testState.code}): {testState.msg}\n </p>\n ) : null}\n </section>\n\n <section aria-labelledby=\"ae-oauth-heading\">\n <h2 id=\"ae-oauth-heading\">Merchant account connection</h2>\n <p>\n Connect a specific AliExpress seller account to enable product\n import into this store. This is separate from the developer app\n credentials above.\n </p>\n\n {initialStatus.needsReauth ? (\n <p role=\"alert\" className=\"reauth-banner\">\n Re-authentication required. Please reconnect your AliExpress account.\n </p>\n ) : null}\n\n <div className=\"status-card\">\n <div>\n <strong>Status:</strong>{' '}\n {initialStatus.connected ? 'Connected' : 'Not connected'}\n </div>\n {initialStatus.sellerId ? (\n <div>\n <strong>Seller ID:</strong> {initialStatus.sellerId}\n </div>\n ) : null}\n {initialStatus.lastSuccessfulCallAt ? (\n <div>\n <strong>Last successful call:</strong>{' '}\n {initialStatus.lastSuccessfulCallAt}\n </div>\n ) : null}\n </div>\n\n <div className=\"actions\">\n <button\n type=\"button\"\n onClick={handleConnect}\n disabled={!canConnect || busyOAuth}\n >\n {busyOAuth ? 'Working...' : 'Connect merchant AliExpress account'}\n </button>\n <button\n type=\"button\"\n onClick={handleDisconnect}\n disabled={!canDisconnect || busyOAuth}\n >\n Disconnect\n </button>\n </div>\n\n {!testEverSucceeded ? (\n <p>\n Run <em>Test connection</em> once with your AppKey/AppSecret before\n connecting a merchant account.\n </p>\n ) : null}\n </section>\n\n <section aria-labelledby=\"ae-coming-soon-heading\">\n <h2 id=\"ae-coming-soon-heading\">Order forwarding</h2>\n <p>\n Coming soon. Automatic order forwarding to AliExpress requires\n our app to be approved out of Test status by AliExpress. Product\n import and browsing work today.\n </p>\n </section>\n </div>\n )\n}\n\nexport default AliExpressDropshippingSettingsForm\n","/**\n * Public types for @amboras-dev/aliexpress-dropshipping.\n *\n * These are the single source of truth for the wire shape between the\n * Amboras admin settings form and the medusa-backend-orchestrator\n * Store API routes under `/store/aliexpress-dropshipping/*`. The DTO\n * files on the medusa side must stay byte-compatible with these.\n */\n\n/**\n * Sentinel returned in place of a stored secret when the settings form\n * reads back current config. Matches the pattern used by meta-ads and\n * pinterest so the admin never sees the plaintext secret after write.\n */\nexport const SECRET_SET_SENTINEL = '__SECRET_SET__' as const\nexport type SecretSetSentinel = typeof SECRET_SET_SENTINEL\n\n/**\n * Per-store AliExpress plugin configuration.\n *\n * - `appKey` / `appSecret` are per-store developer app credentials\n * supplied by the merchant. The admin form receives\n * `SECRET_SET_SENTINEL` for `appSecret` on read, and only sends a\n * real value on user edit.\n * - `connectedSellerId` is populated after the merchant completes the\n * OAuth flow to `/rest/auth/token/create`.\n * - `needsReauth` is flipped by the backend runtime detector when it\n * sees `MissingParameter access_token` or `IllegalAccessToken`\n * sub-codes on any envelope.\n * - `lastSuccessfulCallAt` is an ISO-8601 timestamp for the status card.\n */\nexport interface AliExpressPluginConfig {\n enabled: boolean\n appKey: string | null\n appSecret: string | SecretSetSentinel | null\n connectedSellerId: string | null\n needsReauth: boolean\n lastSuccessfulCallAt: string | null\n}\n\n/**\n * Reasons the backend surfaces when a merchant token becomes invalid.\n * Kept narrow so the admin banner can render a specific message.\n */\nexport enum AliExpressReauthReason {\n MissingAccessToken = 'missing_access_token',\n IllegalAccessToken = 'illegal_access_token',\n RefreshFailed = 'refresh_failed',\n Disconnected = 'disconnected',\n}\n\n/**\n * Category node returned by `aliexpress.ds.category.get`. The API\n * returns a flat list; the admin renders it as a tree by walking\n * `parentCategoryId`.\n */\nexport interface AliExpressCategoryDto {\n categoryId: string\n categoryName: string\n parentCategoryId: string | null\n}\n\n/**\n * Product summary shape returned by `aliexpress.ds.recommend.feed.get`.\n * Used by the \"browse products\" admin surface.\n */\nexport interface AliExpressProductSummaryDto {\n productId: string\n title: string\n imageUrl: string | null\n minPrice: number | null\n maxPrice: number | null\n currency: string | null\n productDetailUrl: string | null\n}\n\n/**\n * Full product shape returned by `aliexpress.ds.product.get`. Consumed\n * by the medusa-side mapper `aliexpressProductToMedusaDraft`.\n */\nexport interface AliExpressProductDto {\n productId: string\n title: string\n description: string | null\n images: string[]\n variants: AliExpressProductVariantDto[]\n weightGrams: number | null\n sourceUrl: string | null\n}\n\nexport interface AliExpressProductVariantDto {\n skuId: string\n title: string | null\n price: number\n currency: string\n stock: number | null\n attributes: Record<string, string>\n}\n\n/**\n * Return shape from `POST /store/aliexpress-dropshipping/products/:id/import`.\n */\nexport interface AliExpressImportResultDto {\n medusaProductId: string\n sourceProductId: string\n importedVariants: number\n}\n\n/**\n * Return shape from `GET /store/aliexpress-dropshipping/status` - drives\n * the admin status card.\n */\nexport interface AliExpressConnectionStatusDto {\n connected: boolean\n sellerId: string | null\n needsReauth: boolean\n reauthReason: AliExpressReauthReason | null\n lastSuccessfulCallAt: string | null\n}\n\n/**\n * Return shape from `POST /store/aliexpress-dropshipping/test-connection`.\n */\nexport type AliExpressTestConnectionResult =\n | { ok: true; categoryCount: number }\n | { ok: false; code: string; msg: string }\n\nexport interface PreflightMerchantError {\n code: string\n message: string\n}\n\nexport interface PreflightAddressError {\n code: string\n message: string\n field: string\n}\n\nexport interface PreflightItemError {\n variantId: string\n productTitle: string\n code: 'CORRUPT_METADATA' | 'PRODUCT_OFFLINE' | 'OUT_OF_STOCK' | 'CANNOT_SHIP' | 'PRICE_DRIFT'\n message: string\n removable: boolean\n}\n\nexport interface PreflightResult {\n ok: boolean\n merchantErrors: PreflightMerchantError[]\n addressErrors: PreflightAddressError[]\n itemErrors: PreflightItemError[]\n warnings: Array<{ code: string; message: string }>\n degraded?: boolean\n warning?: string\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACeA,YAAuB;;;ACDhB,IAAM,sBAAsB;AA8B5B,IAAK,yBAAL,kBAAKA,4BAAL;AACL,EAAAA,wBAAA,wBAAqB;AACrB,EAAAA,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A,OACN;AAAA,IAEA,6CAAC,aAAQ,mBAAgB,oBACvB;AAAA,kDAAC,QAAG,IAAG,oBAAmB,yCAA2B;AAAA,MACrD,4CAAC,OAAE,+JAIH;AAAA,MAEC,cAAc,cACb,4CAAC,OAAE,MAAK,SAAQ,WAAU,iBAAgB,mFAE1C,IACE;AAAA,MAEJ,6CAAC,SAAI,WAAU,eACb;AAAA,qDAAC,SACC;AAAA,sDAAC,YAAO,qBAAO;AAAA,UAAU;AAAA,UACxB,cAAc,YAAY,cAAc;AAAA,WAC3C;AAAA,QACC,cAAc,WACb,6CAAC,SACC;AAAA,sDAAC,YAAO,wBAAU;AAAA,UAAS;AAAA,UAAE,cAAc;AAAA,WAC7C,IACE;AAAA,QACH,cAAc,uBACb,6CAAC,SACC;AAAA,sDAAC,YAAO,mCAAqB;AAAA,UAAU;AAAA,UACtC,cAAc;AAAA,WACjB,IACE;AAAA,SACN;AAAA,MAEA,6CAAC,SAAI,WAAU,WACb;AAAA;AAAA,UAAC;AAAA;AAAA,YACC,MAAK;AAAA,YACL,SAAS;AAAA,YACT,UAAU,CAAC,cAAc;AAAA,YAExB,sBAAY,eAAe;AAAA;AAAA,QAC9B;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,MAAK;AAAA,YACL,SAAS;AAAA,YACT,UAAU,CAAC,iBAAiB;AAAA,YAC7B;AAAA;AAAA,QAED;AAAA,SACF;AAAA,MAEC,CAAC,oBACA,6CAAC,OAAE;AAAA;AAAA,QACG,4CAAC,QAAG,6BAAe;AAAA,QAAK;AAAA,SAE9B,IACE;AAAA,OACN;AAAA,IAEA,6CAAC,aAAQ,mBAAgB,0BACvB;AAAA,kDAAC,QAAG,IAAG,0BAAyB,8BAAgB;AAAA,MAChD,4CAAC,OAAE,6KAIH;AAAA,OACF;AAAA,KACF;AAEJ;","names":["AliExpressReauthReason"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/settings-form.tsx","../src/types.ts"],"sourcesContent":["// Deprecated: no consumer imports the settings form; see its JSDoc.\nexport {\n AliExpressDropshippingSettingsForm,\n type AliExpressDropshippingSettingsFormProps,\n} from './settings-form'\n\n// Preflight types are live; the connection/config/product DTOs are deprecated.\nexport {\n SECRET_SET_SENTINEL,\n AliExpressReauthReason,\n} from './types'\nexport type {\n SecretSetSentinel,\n AliExpressPluginConfig,\n AliExpressCategoryDto,\n AliExpressProductSummaryDto,\n AliExpressProductDto,\n AliExpressProductVariantDto,\n AliExpressImportResultDto,\n AliExpressConnectionStatusDto,\n AliExpressTestConnectionResult,\n PreflightMerchantError,\n PreflightMerchantErrorCode,\n PreflightAddressErrorCode,\n PreflightRateLimitedResponse,\n PreflightAddressError,\n PreflightItemError,\n PreflightWarningCode,\n PreflightWarning,\n PreflightResult,\n} from './types'\n\n","'use client'\n\n/**\n * Admin settings form for the AliExpress Dropshipping integration.\n *\n * @deprecated Not used by any consumer. It models per-store AppKey/AppSecret,\n * but the real flow is a platform app key plus merchant OAuth, owned by\n * amboras-dev-orchestrator (`backend/src/modules/dropshipping`). The Medusa\n * Store API has no config, status or test-connection routes for it to call.\n *\n * The component is intentionally dependency-light (no external UI kit,\n * no @tanstack/react-query peer) so the admin bundle can drop it in\n * without extra peer dep resolution.\n */\n\nimport * as React from 'react'\nimport type {\n AliExpressPluginConfig,\n AliExpressConnectionStatusDto,\n AliExpressTestConnectionResult,\n} from './types'\nimport { SECRET_SET_SENTINEL } from './types'\n\n/** @deprecated See {@link AliExpressDropshippingSettingsForm}. */\nexport interface AliExpressDropshippingSettingsFormProps {\n /** Current config for this store (fetched by the parent server component). */\n initialConfig: AliExpressPluginConfig\n /** Current connection status (from `GET /status`). */\n initialStatus: AliExpressConnectionStatusDto\n /**\n * Persist non-secret + optionally new secret values. The parent maps\n * this onto `PATCH /store/aliexpress-dropshipping/config` (or\n * equivalent) and then re-fetches config on success.\n *\n * `appSecret` is only sent when the merchant actually typed a new\n * value; if they leave the field untouched, this method receives\n * `undefined` for that key so the backend keeps the existing secret.\n */\n onSaveConfig: (patch: {\n appKey?: string\n appSecret?: string\n enabled?: boolean\n }) => Promise<void>\n /** Kick off `POST /oauth/start` and redirect to the returned URL. */\n onConnect: () => Promise<void>\n /** Kick off `POST /oauth/disconnect` and clear merchant credentials. */\n onDisconnect: () => Promise<void>\n /** Call `POST /test-connection` and return the result. */\n onTestConnection: () => Promise<AliExpressTestConnectionResult>\n}\n\ntype SaveState = 'idle' | 'saving' | 'saved' | 'error'\ntype TestState =\n | { kind: 'idle' }\n | { kind: 'running' }\n | { kind: 'ok'; categoryCount: number }\n | { kind: 'err'; code: string; msg: string }\n\n/**\n * Amboras admin settings surface for AliExpress Dropshipping.\n * Renders AppKey + AppSecret inputs, Test / Connect / Disconnect\n * buttons, status card, and a \"Coming soon\" order-forwarding block.\n */\n/** @deprecated Not used by any consumer; see the file header. */\nexport function AliExpressDropshippingSettingsForm(\n props: AliExpressDropshippingSettingsFormProps,\n): React.ReactElement {\n const {\n initialConfig,\n initialStatus,\n onSaveConfig,\n onConnect,\n onDisconnect,\n onTestConnection,\n } = props\n\n const [appKey, setAppKey] = React.useState<string>(\n initialConfig.appKey ?? '',\n )\n const secretPreset =\n initialConfig.appSecret === SECRET_SET_SENTINEL ||\n (typeof initialConfig.appSecret === 'string' &&\n initialConfig.appSecret.length > 0)\n const [appSecret, setAppSecret] = React.useState<string>('')\n const [secretDirty, setSecretDirty] = React.useState<boolean>(false)\n\n const [saveState, setSaveState] = React.useState<SaveState>('idle')\n const [saveError, setSaveError] = React.useState<string | null>(null)\n\n const [testState, setTestState] = React.useState<TestState>({ kind: 'idle' })\n const [testEverSucceeded, setTestEverSucceeded] = React.useState<boolean>(\n initialStatus.connected,\n )\n\n const [busyOAuth, setBusyOAuth] = React.useState<boolean>(false)\n\n const hasStoredSecret = secretPreset || secretDirty\n const canTest = appKey.trim().length > 0 && hasStoredSecret\n const canConnect = testEverSucceeded && !initialStatus.connected\n const canDisconnect = initialStatus.connected\n\n const handleSave = React.useCallback(async () => {\n setSaveState('saving')\n setSaveError(null)\n try {\n const patch: {\n appKey?: string\n appSecret?: string\n enabled?: boolean\n } = {}\n if (appKey.trim() !== (initialConfig.appKey ?? '')) {\n patch.appKey = appKey.trim()\n }\n if (secretDirty && appSecret.length > 0) {\n patch.appSecret = appSecret\n }\n await onSaveConfig(patch)\n setSaveState('saved')\n setSecretDirty(false)\n setAppSecret('')\n } catch (err) {\n setSaveState('error')\n setSaveError(err instanceof Error ? err.message : 'Save failed')\n }\n }, [appKey, appSecret, secretDirty, initialConfig.appKey, onSaveConfig])\n\n const handleTest = React.useCallback(async () => {\n setTestState({ kind: 'running' })\n try {\n const result = await onTestConnection()\n if (result.ok) {\n setTestState({ kind: 'ok', categoryCount: result.categoryCount })\n setTestEverSucceeded(true)\n } else {\n setTestState({ kind: 'err', code: result.code, msg: result.msg })\n }\n } catch (err) {\n setTestState({\n kind: 'err',\n code: 'UNKNOWN',\n msg: err instanceof Error ? err.message : 'Test failed',\n })\n }\n }, [onTestConnection])\n\n const handleConnect = React.useCallback(async () => {\n setBusyOAuth(true)\n try {\n await onConnect()\n } finally {\n setBusyOAuth(false)\n }\n }, [onConnect])\n\n const handleDisconnect = React.useCallback(async () => {\n setBusyOAuth(true)\n try {\n await onDisconnect()\n } finally {\n setBusyOAuth(false)\n }\n }, [onDisconnect])\n\n return (\n <div className=\"aliexpress-dropshipping-settings\">\n <section aria-labelledby=\"ae-credentials-heading\">\n <h2 id=\"ae-credentials-heading\">Developer app credentials</h2>\n <p>\n Enter your AliExpress Open Platform app credentials. These are\n stored encrypted at rest and used to sign every AliExpress API\n call for this store.\n </p>\n\n <label>\n <span>App Key</span>\n <input\n type=\"text\"\n value={appKey}\n onChange={(e) => setAppKey(e.target.value)}\n autoComplete=\"off\"\n spellCheck={false}\n />\n </label>\n\n <label>\n <span>App Secret</span>\n <input\n type=\"password\"\n value={appSecret}\n placeholder={secretPreset ? '(secret set - leave blank to keep)' : ''}\n onChange={(e) => {\n setAppSecret(e.target.value)\n setSecretDirty(true)\n }}\n autoComplete=\"off\"\n spellCheck={false}\n />\n </label>\n\n <div className=\"actions\">\n <button\n type=\"button\"\n onClick={handleSave}\n disabled={saveState === 'saving' || appKey.trim().length === 0}\n >\n {saveState === 'saving' ? 'Saving...' : 'Save credentials'}\n </button>\n <button\n type=\"button\"\n onClick={handleTest}\n disabled={!canTest || testState.kind === 'running'}\n >\n {testState.kind === 'running' ? 'Testing...' : 'Test connection'}\n </button>\n </div>\n\n {saveState === 'saved' ? <p role=\"status\">Saved.</p> : null}\n {saveState === 'error' && saveError ? (\n <p role=\"alert\">Save failed: {saveError}</p>\n ) : null}\n\n {testState.kind === 'ok' ? (\n <p role=\"status\">\n Connected to AliExpress. Found {testState.categoryCount} categories.\n </p>\n ) : null}\n {testState.kind === 'err' ? (\n <p role=\"alert\">\n Test failed ({testState.code}): {testState.msg}\n </p>\n ) : null}\n </section>\n\n <section aria-labelledby=\"ae-oauth-heading\">\n <h2 id=\"ae-oauth-heading\">Merchant account connection</h2>\n <p>\n Connect a specific AliExpress seller account to enable product\n import into this store. This is separate from the developer app\n credentials above.\n </p>\n\n {initialStatus.needsReauth ? (\n <p role=\"alert\" className=\"reauth-banner\">\n Re-authentication required. Please reconnect your AliExpress account.\n </p>\n ) : null}\n\n <div className=\"status-card\">\n <div>\n <strong>Status:</strong>{' '}\n {initialStatus.connected ? 'Connected' : 'Not connected'}\n </div>\n {initialStatus.sellerId ? (\n <div>\n <strong>Seller ID:</strong> {initialStatus.sellerId}\n </div>\n ) : null}\n {initialStatus.lastSuccessfulCallAt ? (\n <div>\n <strong>Last successful call:</strong>{' '}\n {initialStatus.lastSuccessfulCallAt}\n </div>\n ) : null}\n </div>\n\n <div className=\"actions\">\n <button\n type=\"button\"\n onClick={handleConnect}\n disabled={!canConnect || busyOAuth}\n >\n {busyOAuth ? 'Working...' : 'Connect merchant AliExpress account'}\n </button>\n <button\n type=\"button\"\n onClick={handleDisconnect}\n disabled={!canDisconnect || busyOAuth}\n >\n Disconnect\n </button>\n </div>\n\n {!testEverSucceeded ? (\n <p>\n Run <em>Test connection</em> once with your AppKey/AppSecret before\n connecting a merchant account.\n </p>\n ) : null}\n </section>\n\n <section aria-labelledby=\"ae-coming-soon-heading\">\n <h2 id=\"ae-coming-soon-heading\">Order forwarding</h2>\n <p>\n Coming soon. Automatic order forwarding to AliExpress requires\n our app to be approved out of Test status by AliExpress. Product\n import and browsing work today.\n </p>\n </section>\n </div>\n )\n}\n\nexport default AliExpressDropshippingSettingsForm\n","/**\n * Public types for @amboras-dev/aliexpress-dropshipping.\n *\n * Only the preflight types (`PreflightResult` and friends) describe a live\n * contract: the Medusa Store API exposes exactly one route,\n * `POST /store/aliexpress-dropshipping/preflight-cart`.\n *\n * OAuth, request signing, category browsing, product import and token\n * refresh all live in amboras-dev-orchestrator\n * (`backend/src/modules/dropshipping`), not in the Medusa backend. The\n * connection/config/product DTOs below are kept only for backward\n * compatibility and are deprecated.\n */\n\n/**\n * Sentinel returned in place of a stored secret when the settings form\n * reads back current config. Matches the pattern used by meta-ads and\n * pinterest so the admin never sees the plaintext secret after write.\n */\nexport const SECRET_SET_SENTINEL = '__SECRET_SET__' as const\nexport type SecretSetSentinel = typeof SECRET_SET_SENTINEL\n\n/**\n * Per-store AliExpress plugin configuration.\n *\n * @deprecated Models per-store developer credentials, but the real flow\n * uses a platform app key plus merchant OAuth handled by\n * amboras-dev-orchestrator. No Medusa route reads or writes this shape.\n *\n * - `appKey` / `appSecret` are per-store developer app credentials\n * supplied by the merchant. The admin form receives\n * `SECRET_SET_SENTINEL` for `appSecret` on read, and only sends a\n * real value on user edit.\n * - `connectedSellerId` is populated after the merchant completes the\n * OAuth flow to `/rest/auth/token/create`.\n * - `needsReauth` is flipped by the backend runtime detector when it\n * sees `MissingParameter access_token` or `IllegalAccessToken`\n * sub-codes on any envelope.\n * - `lastSuccessfulCallAt` is an ISO-8601 timestamp for the status card.\n */\nexport interface AliExpressPluginConfig {\n enabled: boolean\n appKey: string | null\n appSecret: string | SecretSetSentinel | null\n connectedSellerId: string | null\n needsReauth: boolean\n lastSuccessfulCallAt: string | null\n}\n\n/**\n * @deprecated Reauth state is owned by amboras-dev-orchestrator.\n *\n * Reasons the backend surfaces when a merchant token becomes invalid.\n * Kept narrow so the admin banner can render a specific message.\n */\nexport enum AliExpressReauthReason {\n MissingAccessToken = 'missing_access_token',\n IllegalAccessToken = 'illegal_access_token',\n RefreshFailed = 'refresh_failed',\n Disconnected = 'disconnected',\n}\n\n/**\n * @deprecated No Medusa route returns this; category browsing lives in\n * amboras-dev-orchestrator.\n *\n * Category node returned by `aliexpress.ds.category.get`. The API\n * returns a flat list; the admin renders it as a tree by walking\n * `parentCategoryId`.\n */\nexport interface AliExpressCategoryDto {\n categoryId: string\n categoryName: string\n parentCategoryId: string | null\n}\n\n/**\n * @deprecated No Medusa route returns this; browsing lives in\n * amboras-dev-orchestrator.\n *\n * Product summary shape returned by `aliexpress.ds.recommend.feed.get`.\n */\nexport interface AliExpressProductSummaryDto {\n productId: string\n title: string\n imageUrl: string | null\n minPrice: number | null\n maxPrice: number | null\n currency: string | null\n productDetailUrl: string | null\n}\n\n/**\n * @deprecated No Medusa route or mapper uses this; product import lives in\n * amboras-dev-orchestrator.\n *\n * Full product shape returned by `aliexpress.ds.product.get`.\n */\nexport interface AliExpressProductDto {\n productId: string\n title: string\n description: string | null\n images: string[]\n variants: AliExpressProductVariantDto[]\n weightGrams: number | null\n sourceUrl: string | null\n}\n\n/** @deprecated See {@link AliExpressProductDto}. */\nexport interface AliExpressProductVariantDto {\n skuId: string\n title: string | null\n price: number\n currency: string\n stock: number | null\n attributes: Record<string, string>\n}\n\n/**\n * @deprecated The route `POST /store/aliexpress-dropshipping/products/:id/import`\n * does not exist; import is done by amboras-dev-orchestrator.\n */\nexport interface AliExpressImportResultDto {\n medusaProductId: string\n sourceProductId: string\n importedVariants: number\n}\n\n/**\n * @deprecated The route `GET /store/aliexpress-dropshipping/status` does not\n * exist; connection status is served by amboras-dev-orchestrator.\n */\nexport interface AliExpressConnectionStatusDto {\n connected: boolean\n sellerId: string | null\n needsReauth: boolean\n reauthReason: AliExpressReauthReason | null\n lastSuccessfulCallAt: string | null\n}\n\n/**\n * @deprecated The route `POST /store/aliexpress-dropshipping/test-connection`\n * does not exist; it is served by amboras-dev-orchestrator.\n */\nexport type AliExpressTestConnectionResult =\n | { ok: true; categoryCount: number }\n | { ok: false; code: string; msg: string }\n\n/** Known merchant-level codes; the server may add others. */\nexport type PreflightMerchantErrorCode =\n | 'MERCHANT_DISCONNECTED'\n | 'MERCHANT_UNAVAILABLE'\n | 'MERCHANT_REAUTH_REQUIRED'\n | 'SHIPPING_VERIFICATION_FAILED'\n\n/** Known address codes; the server may add others. */\nexport type PreflightAddressErrorCode =\n | 'ADDRESS_REQUIRED'\n | 'CITY_UNKNOWN'\n | 'ADDRESS_NOT_LATIN'\n | 'ADDRESS_FIELD_LENGTH'\n | 'PHONE_INVALID'\n | 'PROVINCE_REQUIRED'\n | 'COUNTRY_INVALID'\n | 'POSTAL_CODE_INVALID'\n | 'ADDRESS_INVALID'\n\nexport interface PreflightMerchantError {\n code: PreflightMerchantErrorCode | (string & {})\n message: string\n}\n\nexport interface PreflightAddressError {\n code: PreflightAddressErrorCode | (string & {})\n message: string\n field: string\n}\n\nexport interface PreflightItemError {\n variantId: string\n productTitle: string\n code:\n | 'CORRUPT_METADATA'\n | 'PRODUCT_OFFLINE'\n | 'OUT_OF_STOCK'\n | 'CANNOT_SHIP'\n /** @deprecated Price drift is only ever reported as a warning ({@link PreflightWarningCode}), never as an item error. Kept for backward compatibility. */\n | 'PRICE_DRIFT'\n | 'SHIPPING_VERIFICATION_FAILED'\n message: string\n removable: boolean\n}\n\n/** Codes that appear in `PreflightResult.warnings`. Non-blocking. */\nexport type PreflightWarningCode = 'PRICE_DRIFT' | 'STOCK_UNKNOWN' | 'FREIGHT_EXPENSIVE'\n\nexport interface PreflightWarning {\n /** Known codes are listed in {@link PreflightWarningCode}; other strings may be added by the server. */\n code: PreflightWarningCode | (string & {})\n message: string\n}\n\nexport interface PreflightResult {\n ok: boolean\n merchantErrors: PreflightMerchantError[]\n addressErrors: PreflightAddressError[]\n itemErrors: PreflightItemError[]\n warnings: PreflightWarning[]\n degraded?: boolean\n warning?: string\n}\n\n/**\n * Body of the 429 the preflight route returns when a cart or IP is checked too often.\n * `Retry-After` carries the same number of seconds as `retryAfter`.\n */\nexport interface PreflightRateLimitedResponse {\n error: string\n code: 'rate_limited'\n retryAfter: number\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACeA,YAAuB;;;ACIhB,IAAM,sBAAsB;AAoC5B,IAAK,yBAAL,kBAAKA,4BAAL;AACL,EAAAA,wBAAA,wBAAqB;AACrB,EAAAA,wBAAA,wBAAqB;AACrB,EAAAA,wBAAA,mBAAgB;AAChB,EAAAA,wBAAA,kBAAe;AAJL,SAAAA;AAAA,GAAA;;;AD+GJ;AAtGD,SAAS,mCACd,OACoB;AACpB,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,QAAM,CAAC,QAAQ,SAAS,IAAU;AAAA,IAChC,cAAc,UAAU;AAAA,EAC1B;AACA,QAAM,eACJ,cAAc,cAAc,uBAC3B,OAAO,cAAc,cAAc,YAClC,cAAc,UAAU,SAAS;AACrC,QAAM,CAAC,WAAW,YAAY,IAAU,eAAiB,EAAE;AAC3D,QAAM,CAAC,aAAa,cAAc,IAAU,eAAkB,KAAK;AAEnE,QAAM,CAAC,WAAW,YAAY,IAAU,eAAoB,MAAM;AAClE,QAAM,CAAC,WAAW,YAAY,IAAU,eAAwB,IAAI;AAEpE,QAAM,CAAC,WAAW,YAAY,IAAU,eAAoB,EAAE,MAAM,OAAO,CAAC;AAC5E,QAAM,CAAC,mBAAmB,oBAAoB,IAAU;AAAA,IACtD,cAAc;AAAA,EAChB;AAEA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C9B;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,MAAK;AAAA,YACL,SAAS;AAAA,YACT,UAAU,CAAC,iBAAiB;AAAA,YAC7B;AAAA;AAAA,QAED;AAAA,SACF;AAAA,MAEC,CAAC,oBACA,6CAAC,OAAE;AAAA;AAAA,QACG,4CAAC,QAAG,6BAAe;AAAA,QAAK;AAAA,SAE9B,IACE;AAAA,OACN;AAAA,IAEA,6CAAC,aAAQ,mBAAgB,0BACvB;AAAA,kDAAC,QAAG,IAAG,0BAAyB,8BAAgB;AAAA,MAChD,4CAAC,OAAE,6KAIH;AAAA,OACF;AAAA,KACF;AAEJ;","names":["AliExpressReauthReason"]}
package/dist/index.mjs CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  AliExpressDropshippingSettingsForm,
3
3
  AliExpressReauthReason,
4
4
  SECRET_SET_SENTINEL
5
- } from "./chunk-65TJ4JF6.mjs";
5
+ } from "./chunk-XSSYR25X.mjs";
6
6
  export {
7
7
  AliExpressDropshippingSettingsForm,
8
8
  AliExpressReauthReason,
@@ -1,10 +1,15 @@
1
1
  /**
2
2
  * Public types for @amboras-dev/aliexpress-dropshipping.
3
3
  *
4
- * These are the single source of truth for the wire shape between the
5
- * Amboras admin settings form and the medusa-backend-orchestrator
6
- * Store API routes under `/store/aliexpress-dropshipping/*`. The DTO
7
- * files on the medusa side must stay byte-compatible with these.
4
+ * Only the preflight types (`PreflightResult` and friends) describe a live
5
+ * contract: the Medusa Store API exposes exactly one route,
6
+ * `POST /store/aliexpress-dropshipping/preflight-cart`.
7
+ *
8
+ * OAuth, request signing, category browsing, product import and token
9
+ * refresh all live in amboras-dev-orchestrator
10
+ * (`backend/src/modules/dropshipping`), not in the Medusa backend. The
11
+ * connection/config/product DTOs below are kept only for backward
12
+ * compatibility and are deprecated.
8
13
  */
9
14
  /**
10
15
  * Sentinel returned in place of a stored secret when the settings form
@@ -16,6 +21,10 @@ type SecretSetSentinel = typeof SECRET_SET_SENTINEL;
16
21
  /**
17
22
  * Per-store AliExpress plugin configuration.
18
23
  *
24
+ * @deprecated Models per-store developer credentials, but the real flow
25
+ * uses a platform app key plus merchant OAuth handled by
26
+ * amboras-dev-orchestrator. No Medusa route reads or writes this shape.
27
+ *
19
28
  * - `appKey` / `appSecret` are per-store developer app credentials
20
29
  * supplied by the merchant. The admin form receives
21
30
  * `SECRET_SET_SENTINEL` for `appSecret` on read, and only sends a
@@ -36,6 +45,8 @@ interface AliExpressPluginConfig {
36
45
  lastSuccessfulCallAt: string | null;
37
46
  }
38
47
  /**
48
+ * @deprecated Reauth state is owned by amboras-dev-orchestrator.
49
+ *
39
50
  * Reasons the backend surfaces when a merchant token becomes invalid.
40
51
  * Kept narrow so the admin banner can render a specific message.
41
52
  */
@@ -46,6 +57,9 @@ declare enum AliExpressReauthReason {
46
57
  Disconnected = "disconnected"
47
58
  }
48
59
  /**
60
+ * @deprecated No Medusa route returns this; category browsing lives in
61
+ * amboras-dev-orchestrator.
62
+ *
49
63
  * Category node returned by `aliexpress.ds.category.get`. The API
50
64
  * returns a flat list; the admin renders it as a tree by walking
51
65
  * `parentCategoryId`.
@@ -56,8 +70,10 @@ interface AliExpressCategoryDto {
56
70
  parentCategoryId: string | null;
57
71
  }
58
72
  /**
73
+ * @deprecated No Medusa route returns this; browsing lives in
74
+ * amboras-dev-orchestrator.
75
+ *
59
76
  * Product summary shape returned by `aliexpress.ds.recommend.feed.get`.
60
- * Used by the "browse products" admin surface.
61
77
  */
62
78
  interface AliExpressProductSummaryDto {
63
79
  productId: string;
@@ -69,8 +85,10 @@ interface AliExpressProductSummaryDto {
69
85
  productDetailUrl: string | null;
70
86
  }
71
87
  /**
72
- * Full product shape returned by `aliexpress.ds.product.get`. Consumed
73
- * by the medusa-side mapper `aliexpressProductToMedusaDraft`.
88
+ * @deprecated No Medusa route or mapper uses this; product import lives in
89
+ * amboras-dev-orchestrator.
90
+ *
91
+ * Full product shape returned by `aliexpress.ds.product.get`.
74
92
  */
75
93
  interface AliExpressProductDto {
76
94
  productId: string;
@@ -81,6 +99,7 @@ interface AliExpressProductDto {
81
99
  weightGrams: number | null;
82
100
  sourceUrl: string | null;
83
101
  }
102
+ /** @deprecated See {@link AliExpressProductDto}. */
84
103
  interface AliExpressProductVariantDto {
85
104
  skuId: string;
86
105
  title: string | null;
@@ -90,7 +109,8 @@ interface AliExpressProductVariantDto {
90
109
  attributes: Record<string, string>;
91
110
  }
92
111
  /**
93
- * Return shape from `POST /store/aliexpress-dropshipping/products/:id/import`.
112
+ * @deprecated The route `POST /store/aliexpress-dropshipping/products/:id/import`
113
+ * does not exist; import is done by amboras-dev-orchestrator.
94
114
  */
95
115
  interface AliExpressImportResultDto {
96
116
  medusaProductId: string;
@@ -98,8 +118,8 @@ interface AliExpressImportResultDto {
98
118
  importedVariants: number;
99
119
  }
100
120
  /**
101
- * Return shape from `GET /store/aliexpress-dropshipping/status` - drives
102
- * the admin status card.
121
+ * @deprecated The route `GET /store/aliexpress-dropshipping/status` does not
122
+ * exist; connection status is served by amboras-dev-orchestrator.
103
123
  */
104
124
  interface AliExpressConnectionStatusDto {
105
125
  connected: boolean;
@@ -109,7 +129,8 @@ interface AliExpressConnectionStatusDto {
109
129
  lastSuccessfulCallAt: string | null;
110
130
  }
111
131
  /**
112
- * Return shape from `POST /store/aliexpress-dropshipping/test-connection`.
132
+ * @deprecated The route `POST /store/aliexpress-dropshipping/test-connection`
133
+ * does not exist; it is served by amboras-dev-orchestrator.
113
134
  */
114
135
  type AliExpressTestConnectionResult = {
115
136
  ok: true;
@@ -119,33 +140,52 @@ type AliExpressTestConnectionResult = {
119
140
  code: string;
120
141
  msg: string;
121
142
  };
143
+ /** Known merchant-level codes; the server may add others. */
144
+ type PreflightMerchantErrorCode = 'MERCHANT_DISCONNECTED' | 'MERCHANT_UNAVAILABLE' | 'MERCHANT_REAUTH_REQUIRED' | 'SHIPPING_VERIFICATION_FAILED';
145
+ /** Known address codes; the server may add others. */
146
+ type PreflightAddressErrorCode = 'ADDRESS_REQUIRED' | 'CITY_UNKNOWN' | 'ADDRESS_NOT_LATIN' | 'ADDRESS_FIELD_LENGTH' | 'PHONE_INVALID' | 'PROVINCE_REQUIRED' | 'COUNTRY_INVALID' | 'POSTAL_CODE_INVALID' | 'ADDRESS_INVALID';
122
147
  interface PreflightMerchantError {
123
- code: string;
148
+ code: PreflightMerchantErrorCode | (string & {});
124
149
  message: string;
125
150
  }
126
151
  interface PreflightAddressError {
127
- code: string;
152
+ code: PreflightAddressErrorCode | (string & {});
128
153
  message: string;
129
154
  field: string;
130
155
  }
131
156
  interface PreflightItemError {
132
157
  variantId: string;
133
158
  productTitle: string;
134
- code: 'CORRUPT_METADATA' | 'PRODUCT_OFFLINE' | 'OUT_OF_STOCK' | 'CANNOT_SHIP' | 'PRICE_DRIFT';
159
+ code: 'CORRUPT_METADATA' | 'PRODUCT_OFFLINE' | 'OUT_OF_STOCK' | 'CANNOT_SHIP'
160
+ /** @deprecated Price drift is only ever reported as a warning ({@link PreflightWarningCode}), never as an item error. Kept for backward compatibility. */
161
+ | 'PRICE_DRIFT' | 'SHIPPING_VERIFICATION_FAILED';
135
162
  message: string;
136
163
  removable: boolean;
137
164
  }
165
+ /** Codes that appear in `PreflightResult.warnings`. Non-blocking. */
166
+ type PreflightWarningCode = 'PRICE_DRIFT' | 'STOCK_UNKNOWN' | 'FREIGHT_EXPENSIVE';
167
+ interface PreflightWarning {
168
+ /** Known codes are listed in {@link PreflightWarningCode}; other strings may be added by the server. */
169
+ code: PreflightWarningCode | (string & {});
170
+ message: string;
171
+ }
138
172
  interface PreflightResult {
139
173
  ok: boolean;
140
174
  merchantErrors: PreflightMerchantError[];
141
175
  addressErrors: PreflightAddressError[];
142
176
  itemErrors: PreflightItemError[];
143
- warnings: Array<{
144
- code: string;
145
- message: string;
146
- }>;
177
+ warnings: PreflightWarning[];
147
178
  degraded?: boolean;
148
179
  warning?: string;
149
180
  }
181
+ /**
182
+ * Body of the 429 the preflight route returns when a cart or IP is checked too often.
183
+ * `Retry-After` carries the same number of seconds as `retryAfter`.
184
+ */
185
+ interface PreflightRateLimitedResponse {
186
+ error: string;
187
+ code: 'rate_limited';
188
+ retryAfter: number;
189
+ }
150
190
 
151
- export { type AliExpressPluginConfig as A, type PreflightResult as P, SECRET_SET_SENTINEL as S, type PreflightAddressError as a, type PreflightItemError as b, type PreflightMerchantError as c, type AliExpressConnectionStatusDto as d, type AliExpressTestConnectionResult as e, type AliExpressCategoryDto as f, type AliExpressImportResultDto as g, type AliExpressProductDto as h, type AliExpressProductSummaryDto as i, type AliExpressProductVariantDto as j, AliExpressReauthReason as k, type SecretSetSentinel as l };
191
+ export { type AliExpressPluginConfig as A, type PreflightResult as P, SECRET_SET_SENTINEL as S, type PreflightAddressError as a, type PreflightAddressErrorCode as b, type PreflightItemError as c, type PreflightMerchantError as d, type PreflightMerchantErrorCode as e, type PreflightRateLimitedResponse as f, type AliExpressConnectionStatusDto as g, type AliExpressTestConnectionResult as h, type AliExpressCategoryDto as i, type AliExpressImportResultDto as j, type AliExpressProductDto as k, type AliExpressProductSummaryDto as l, type AliExpressProductVariantDto as m, AliExpressReauthReason as n, type PreflightWarning as o, type PreflightWarningCode as p, type SecretSetSentinel as q };
@@ -1,10 +1,15 @@
1
1
  /**
2
2
  * Public types for @amboras-dev/aliexpress-dropshipping.
3
3
  *
4
- * These are the single source of truth for the wire shape between the
5
- * Amboras admin settings form and the medusa-backend-orchestrator
6
- * Store API routes under `/store/aliexpress-dropshipping/*`. The DTO
7
- * files on the medusa side must stay byte-compatible with these.
4
+ * Only the preflight types (`PreflightResult` and friends) describe a live
5
+ * contract: the Medusa Store API exposes exactly one route,
6
+ * `POST /store/aliexpress-dropshipping/preflight-cart`.
7
+ *
8
+ * OAuth, request signing, category browsing, product import and token
9
+ * refresh all live in amboras-dev-orchestrator
10
+ * (`backend/src/modules/dropshipping`), not in the Medusa backend. The
11
+ * connection/config/product DTOs below are kept only for backward
12
+ * compatibility and are deprecated.
8
13
  */
9
14
  /**
10
15
  * Sentinel returned in place of a stored secret when the settings form
@@ -16,6 +21,10 @@ type SecretSetSentinel = typeof SECRET_SET_SENTINEL;
16
21
  /**
17
22
  * Per-store AliExpress plugin configuration.
18
23
  *
24
+ * @deprecated Models per-store developer credentials, but the real flow
25
+ * uses a platform app key plus merchant OAuth handled by
26
+ * amboras-dev-orchestrator. No Medusa route reads or writes this shape.
27
+ *
19
28
  * - `appKey` / `appSecret` are per-store developer app credentials
20
29
  * supplied by the merchant. The admin form receives
21
30
  * `SECRET_SET_SENTINEL` for `appSecret` on read, and only sends a
@@ -36,6 +45,8 @@ interface AliExpressPluginConfig {
36
45
  lastSuccessfulCallAt: string | null;
37
46
  }
38
47
  /**
48
+ * @deprecated Reauth state is owned by amboras-dev-orchestrator.
49
+ *
39
50
  * Reasons the backend surfaces when a merchant token becomes invalid.
40
51
  * Kept narrow so the admin banner can render a specific message.
41
52
  */
@@ -46,6 +57,9 @@ declare enum AliExpressReauthReason {
46
57
  Disconnected = "disconnected"
47
58
  }
48
59
  /**
60
+ * @deprecated No Medusa route returns this; category browsing lives in
61
+ * amboras-dev-orchestrator.
62
+ *
49
63
  * Category node returned by `aliexpress.ds.category.get`. The API
50
64
  * returns a flat list; the admin renders it as a tree by walking
51
65
  * `parentCategoryId`.
@@ -56,8 +70,10 @@ interface AliExpressCategoryDto {
56
70
  parentCategoryId: string | null;
57
71
  }
58
72
  /**
73
+ * @deprecated No Medusa route returns this; browsing lives in
74
+ * amboras-dev-orchestrator.
75
+ *
59
76
  * Product summary shape returned by `aliexpress.ds.recommend.feed.get`.
60
- * Used by the "browse products" admin surface.
61
77
  */
62
78
  interface AliExpressProductSummaryDto {
63
79
  productId: string;
@@ -69,8 +85,10 @@ interface AliExpressProductSummaryDto {
69
85
  productDetailUrl: string | null;
70
86
  }
71
87
  /**
72
- * Full product shape returned by `aliexpress.ds.product.get`. Consumed
73
- * by the medusa-side mapper `aliexpressProductToMedusaDraft`.
88
+ * @deprecated No Medusa route or mapper uses this; product import lives in
89
+ * amboras-dev-orchestrator.
90
+ *
91
+ * Full product shape returned by `aliexpress.ds.product.get`.
74
92
  */
75
93
  interface AliExpressProductDto {
76
94
  productId: string;
@@ -81,6 +99,7 @@ interface AliExpressProductDto {
81
99
  weightGrams: number | null;
82
100
  sourceUrl: string | null;
83
101
  }
102
+ /** @deprecated See {@link AliExpressProductDto}. */
84
103
  interface AliExpressProductVariantDto {
85
104
  skuId: string;
86
105
  title: string | null;
@@ -90,7 +109,8 @@ interface AliExpressProductVariantDto {
90
109
  attributes: Record<string, string>;
91
110
  }
92
111
  /**
93
- * Return shape from `POST /store/aliexpress-dropshipping/products/:id/import`.
112
+ * @deprecated The route `POST /store/aliexpress-dropshipping/products/:id/import`
113
+ * does not exist; import is done by amboras-dev-orchestrator.
94
114
  */
95
115
  interface AliExpressImportResultDto {
96
116
  medusaProductId: string;
@@ -98,8 +118,8 @@ interface AliExpressImportResultDto {
98
118
  importedVariants: number;
99
119
  }
100
120
  /**
101
- * Return shape from `GET /store/aliexpress-dropshipping/status` - drives
102
- * the admin status card.
121
+ * @deprecated The route `GET /store/aliexpress-dropshipping/status` does not
122
+ * exist; connection status is served by amboras-dev-orchestrator.
103
123
  */
104
124
  interface AliExpressConnectionStatusDto {
105
125
  connected: boolean;
@@ -109,7 +129,8 @@ interface AliExpressConnectionStatusDto {
109
129
  lastSuccessfulCallAt: string | null;
110
130
  }
111
131
  /**
112
- * Return shape from `POST /store/aliexpress-dropshipping/test-connection`.
132
+ * @deprecated The route `POST /store/aliexpress-dropshipping/test-connection`
133
+ * does not exist; it is served by amboras-dev-orchestrator.
113
134
  */
114
135
  type AliExpressTestConnectionResult = {
115
136
  ok: true;
@@ -119,33 +140,52 @@ type AliExpressTestConnectionResult = {
119
140
  code: string;
120
141
  msg: string;
121
142
  };
143
+ /** Known merchant-level codes; the server may add others. */
144
+ type PreflightMerchantErrorCode = 'MERCHANT_DISCONNECTED' | 'MERCHANT_UNAVAILABLE' | 'MERCHANT_REAUTH_REQUIRED' | 'SHIPPING_VERIFICATION_FAILED';
145
+ /** Known address codes; the server may add others. */
146
+ type PreflightAddressErrorCode = 'ADDRESS_REQUIRED' | 'CITY_UNKNOWN' | 'ADDRESS_NOT_LATIN' | 'ADDRESS_FIELD_LENGTH' | 'PHONE_INVALID' | 'PROVINCE_REQUIRED' | 'COUNTRY_INVALID' | 'POSTAL_CODE_INVALID' | 'ADDRESS_INVALID';
122
147
  interface PreflightMerchantError {
123
- code: string;
148
+ code: PreflightMerchantErrorCode | (string & {});
124
149
  message: string;
125
150
  }
126
151
  interface PreflightAddressError {
127
- code: string;
152
+ code: PreflightAddressErrorCode | (string & {});
128
153
  message: string;
129
154
  field: string;
130
155
  }
131
156
  interface PreflightItemError {
132
157
  variantId: string;
133
158
  productTitle: string;
134
- code: 'CORRUPT_METADATA' | 'PRODUCT_OFFLINE' | 'OUT_OF_STOCK' | 'CANNOT_SHIP' | 'PRICE_DRIFT';
159
+ code: 'CORRUPT_METADATA' | 'PRODUCT_OFFLINE' | 'OUT_OF_STOCK' | 'CANNOT_SHIP'
160
+ /** @deprecated Price drift is only ever reported as a warning ({@link PreflightWarningCode}), never as an item error. Kept for backward compatibility. */
161
+ | 'PRICE_DRIFT' | 'SHIPPING_VERIFICATION_FAILED';
135
162
  message: string;
136
163
  removable: boolean;
137
164
  }
165
+ /** Codes that appear in `PreflightResult.warnings`. Non-blocking. */
166
+ type PreflightWarningCode = 'PRICE_DRIFT' | 'STOCK_UNKNOWN' | 'FREIGHT_EXPENSIVE';
167
+ interface PreflightWarning {
168
+ /** Known codes are listed in {@link PreflightWarningCode}; other strings may be added by the server. */
169
+ code: PreflightWarningCode | (string & {});
170
+ message: string;
171
+ }
138
172
  interface PreflightResult {
139
173
  ok: boolean;
140
174
  merchantErrors: PreflightMerchantError[];
141
175
  addressErrors: PreflightAddressError[];
142
176
  itemErrors: PreflightItemError[];
143
- warnings: Array<{
144
- code: string;
145
- message: string;
146
- }>;
177
+ warnings: PreflightWarning[];
147
178
  degraded?: boolean;
148
179
  warning?: string;
149
180
  }
181
+ /**
182
+ * Body of the 429 the preflight route returns when a cart or IP is checked too often.
183
+ * `Retry-After` carries the same number of seconds as `retryAfter`.
184
+ */
185
+ interface PreflightRateLimitedResponse {
186
+ error: string;
187
+ code: 'rate_limited';
188
+ retryAfter: number;
189
+ }
150
190
 
151
- export { type AliExpressPluginConfig as A, type PreflightResult as P, SECRET_SET_SENTINEL as S, type PreflightAddressError as a, type PreflightItemError as b, type PreflightMerchantError as c, type AliExpressConnectionStatusDto as d, type AliExpressTestConnectionResult as e, type AliExpressCategoryDto as f, type AliExpressImportResultDto as g, type AliExpressProductDto as h, type AliExpressProductSummaryDto as i, type AliExpressProductVariantDto as j, AliExpressReauthReason as k, type SecretSetSentinel as l };
191
+ export { type AliExpressPluginConfig as A, type PreflightResult as P, SECRET_SET_SENTINEL as S, type PreflightAddressError as a, type PreflightAddressErrorCode as b, type PreflightItemError as c, type PreflightMerchantError as d, type PreflightMerchantErrorCode as e, type PreflightRateLimitedResponse as f, type AliExpressConnectionStatusDto as g, type AliExpressTestConnectionResult as h, type AliExpressCategoryDto as i, type AliExpressImportResultDto as j, type AliExpressProductDto as k, type AliExpressProductSummaryDto as l, type AliExpressProductVariantDto as m, AliExpressReauthReason as n, type PreflightWarning as o, type PreflightWarningCode as p, type SecretSetSentinel as q };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amboras-dev/aliexpress-dropshipping",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "AliExpress Dropshipping integration for Amboras - storefront preflight and admin settings",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/types.ts","../src/settings-form.tsx"],"sourcesContent":["/**\n * Public types for @amboras-dev/aliexpress-dropshipping.\n *\n * These are the single source of truth for the wire shape between the\n * Amboras admin settings form and the medusa-backend-orchestrator\n * Store API routes under `/store/aliexpress-dropshipping/*`. The DTO\n * files on the medusa side must stay byte-compatible with these.\n */\n\n/**\n * Sentinel returned in place of a stored secret when the settings form\n * reads back current config. Matches the pattern used by meta-ads and\n * pinterest so the admin never sees the plaintext secret after write.\n */\nexport const SECRET_SET_SENTINEL = '__SECRET_SET__' as const\nexport type SecretSetSentinel = typeof SECRET_SET_SENTINEL\n\n/**\n * Per-store AliExpress plugin configuration.\n *\n * - `appKey` / `appSecret` are per-store developer app credentials\n * supplied by the merchant. The admin form receives\n * `SECRET_SET_SENTINEL` for `appSecret` on read, and only sends a\n * real value on user edit.\n * - `connectedSellerId` is populated after the merchant completes the\n * OAuth flow to `/rest/auth/token/create`.\n * - `needsReauth` is flipped by the backend runtime detector when it\n * sees `MissingParameter access_token` or `IllegalAccessToken`\n * sub-codes on any envelope.\n * - `lastSuccessfulCallAt` is an ISO-8601 timestamp for the status card.\n */\nexport interface AliExpressPluginConfig {\n enabled: boolean\n appKey: string | null\n appSecret: string | SecretSetSentinel | null\n connectedSellerId: string | null\n needsReauth: boolean\n lastSuccessfulCallAt: string | null\n}\n\n/**\n * Reasons the backend surfaces when a merchant token becomes invalid.\n * Kept narrow so the admin banner can render a specific message.\n */\nexport enum AliExpressReauthReason {\n MissingAccessToken = 'missing_access_token',\n IllegalAccessToken = 'illegal_access_token',\n RefreshFailed = 'refresh_failed',\n Disconnected = 'disconnected',\n}\n\n/**\n * Category node returned by `aliexpress.ds.category.get`. The API\n * returns a flat list; the admin renders it as a tree by walking\n * `parentCategoryId`.\n */\nexport interface AliExpressCategoryDto {\n categoryId: string\n categoryName: string\n parentCategoryId: string | null\n}\n\n/**\n * Product summary shape returned by `aliexpress.ds.recommend.feed.get`.\n * Used by the \"browse products\" admin surface.\n */\nexport interface AliExpressProductSummaryDto {\n productId: string\n title: string\n imageUrl: string | null\n minPrice: number | null\n maxPrice: number | null\n currency: string | null\n productDetailUrl: string | null\n}\n\n/**\n * Full product shape returned by `aliexpress.ds.product.get`. Consumed\n * by the medusa-side mapper `aliexpressProductToMedusaDraft`.\n */\nexport interface AliExpressProductDto {\n productId: string\n title: string\n description: string | null\n images: string[]\n variants: AliExpressProductVariantDto[]\n weightGrams: number | null\n sourceUrl: string | null\n}\n\nexport interface AliExpressProductVariantDto {\n skuId: string\n title: string | null\n price: number\n currency: string\n stock: number | null\n attributes: Record<string, string>\n}\n\n/**\n * Return shape from `POST /store/aliexpress-dropshipping/products/:id/import`.\n */\nexport interface AliExpressImportResultDto {\n medusaProductId: string\n sourceProductId: string\n importedVariants: number\n}\n\n/**\n * Return shape from `GET /store/aliexpress-dropshipping/status` - drives\n * the admin status card.\n */\nexport interface AliExpressConnectionStatusDto {\n connected: boolean\n sellerId: string | null\n needsReauth: boolean\n reauthReason: AliExpressReauthReason | null\n lastSuccessfulCallAt: string | null\n}\n\n/**\n * Return shape from `POST /store/aliexpress-dropshipping/test-connection`.\n */\nexport type AliExpressTestConnectionResult =\n | { ok: true; categoryCount: number }\n | { ok: false; code: string; msg: string }\n\nexport interface PreflightMerchantError {\n code: string\n message: string\n}\n\nexport interface PreflightAddressError {\n code: string\n message: string\n field: string\n}\n\nexport interface PreflightItemError {\n variantId: string\n productTitle: string\n code: 'CORRUPT_METADATA' | 'PRODUCT_OFFLINE' | 'OUT_OF_STOCK' | 'CANNOT_SHIP' | 'PRICE_DRIFT'\n message: string\n removable: boolean\n}\n\nexport interface PreflightResult {\n ok: boolean\n merchantErrors: PreflightMerchantError[]\n addressErrors: PreflightAddressError[]\n itemErrors: PreflightItemError[]\n warnings: Array<{ code: string; message: string }>\n degraded?: boolean\n warning?: string\n}\n","'use client'\n\n/**\n * Admin settings form for the AliExpress Dropshipping integration.\n *\n * Class B: this component owns the UI and talks to the Medusa Store API\n * under `/store/aliexpress-dropshipping/*`. It does NOT embed any\n * AliExpress SDK, does not sign requests, and does not touch OAuth\n * tokens directly - the backend does all of that.\n *\n * The component is intentionally dependency-light (no external UI kit,\n * no @tanstack/react-query peer) so the admin bundle can drop it in\n * without extra peer dep resolution.\n */\n\nimport * as React from 'react'\nimport type {\n AliExpressPluginConfig,\n AliExpressConnectionStatusDto,\n AliExpressTestConnectionResult,\n} from './types'\nimport { SECRET_SET_SENTINEL } from './types'\n\nexport interface AliExpressDropshippingSettingsFormProps {\n /** Current config for this store (fetched by the parent server component). */\n initialConfig: AliExpressPluginConfig\n /** Current connection status (from `GET /status`). */\n initialStatus: AliExpressConnectionStatusDto\n /**\n * Persist non-secret + optionally new secret values. The parent maps\n * this onto `PATCH /store/aliexpress-dropshipping/config` (or\n * equivalent) and then re-fetches config on success.\n *\n * `appSecret` is only sent when the merchant actually typed a new\n * value; if they leave the field untouched, this method receives\n * `undefined` for that key so the backend keeps the existing secret.\n */\n onSaveConfig: (patch: {\n appKey?: string\n appSecret?: string\n enabled?: boolean\n }) => Promise<void>\n /** Kick off `POST /oauth/start` and redirect to the returned URL. */\n onConnect: () => Promise<void>\n /** Kick off `POST /oauth/disconnect` and clear merchant credentials. */\n onDisconnect: () => Promise<void>\n /** Call `POST /test-connection` and return the result. */\n onTestConnection: () => Promise<AliExpressTestConnectionResult>\n}\n\ntype SaveState = 'idle' | 'saving' | 'saved' | 'error'\ntype TestState =\n | { kind: 'idle' }\n | { kind: 'running' }\n | { kind: 'ok'; categoryCount: number }\n | { kind: 'err'; code: string; msg: string }\n\n/**\n * Amboras admin settings surface for AliExpress Dropshipping.\n * Renders AppKey + AppSecret inputs, Test / Connect / Disconnect\n * buttons, status card, and a \"Coming soon\" order-forwarding block.\n */\nexport function AliExpressDropshippingSettingsForm(\n props: AliExpressDropshippingSettingsFormProps,\n): React.ReactElement {\n const {\n initialConfig,\n initialStatus,\n onSaveConfig,\n onConnect,\n onDisconnect,\n onTestConnection,\n } = props\n\n const [appKey, setAppKey] = React.useState<string>(\n initialConfig.appKey ?? '',\n )\n const secretPreset =\n initialConfig.appSecret === SECRET_SET_SENTINEL ||\n (typeof initialConfig.appSecret === 'string' &&\n initialConfig.appSecret.length > 0)\n const [appSecret, setAppSecret] = React.useState<string>('')\n const [secretDirty, setSecretDirty] = React.useState<boolean>(false)\n\n const [saveState, setSaveState] = React.useState<SaveState>('idle')\n const [saveError, setSaveError] = React.useState<string | null>(null)\n\n const [testState, setTestState] = React.useState<TestState>({ kind: 'idle' })\n const [testEverSucceeded, setTestEverSucceeded] = React.useState<boolean>(\n initialStatus.connected,\n )\n\n const [busyOAuth, setBusyOAuth] = React.useState<boolean>(false)\n\n const hasStoredSecret = secretPreset || secretDirty\n const canTest = appKey.trim().length > 0 && hasStoredSecret\n const canConnect = testEverSucceeded && !initialStatus.connected\n const canDisconnect = initialStatus.connected\n\n const handleSave = React.useCallback(async () => {\n setSaveState('saving')\n setSaveError(null)\n try {\n const patch: {\n appKey?: string\n appSecret?: string\n enabled?: boolean\n } = {}\n if (appKey.trim() !== (initialConfig.appKey ?? '')) {\n patch.appKey = appKey.trim()\n }\n if (secretDirty && appSecret.length > 0) {\n patch.appSecret = appSecret\n }\n await onSaveConfig(patch)\n setSaveState('saved')\n setSecretDirty(false)\n setAppSecret('')\n } catch (err) {\n setSaveState('error')\n setSaveError(err instanceof Error ? err.message : 'Save failed')\n }\n }, [appKey, appSecret, secretDirty, initialConfig.appKey, onSaveConfig])\n\n const handleTest = React.useCallback(async () => {\n setTestState({ kind: 'running' })\n try {\n const result = await onTestConnection()\n if (result.ok) {\n setTestState({ kind: 'ok', categoryCount: result.categoryCount })\n setTestEverSucceeded(true)\n } else {\n setTestState({ kind: 'err', code: result.code, msg: result.msg })\n }\n } catch (err) {\n setTestState({\n kind: 'err',\n code: 'UNKNOWN',\n msg: err instanceof Error ? err.message : 'Test failed',\n })\n }\n }, [onTestConnection])\n\n const handleConnect = React.useCallback(async () => {\n setBusyOAuth(true)\n try {\n await onConnect()\n } finally {\n setBusyOAuth(false)\n }\n }, [onConnect])\n\n const handleDisconnect = React.useCallback(async () => {\n setBusyOAuth(true)\n try {\n await onDisconnect()\n } finally {\n setBusyOAuth(false)\n }\n }, [onDisconnect])\n\n return (\n <div className=\"aliexpress-dropshipping-settings\">\n <section aria-labelledby=\"ae-credentials-heading\">\n <h2 id=\"ae-credentials-heading\">Developer app credentials</h2>\n <p>\n Enter your AliExpress Open Platform app credentials. These are\n stored encrypted at rest and used to sign every AliExpress API\n call for this store.\n </p>\n\n <label>\n <span>App Key</span>\n <input\n type=\"text\"\n value={appKey}\n onChange={(e) => setAppKey(e.target.value)}\n autoComplete=\"off\"\n spellCheck={false}\n />\n </label>\n\n <label>\n <span>App Secret</span>\n <input\n type=\"password\"\n value={appSecret}\n placeholder={secretPreset ? '(secret set - leave blank to keep)' : ''}\n onChange={(e) => {\n setAppSecret(e.target.value)\n setSecretDirty(true)\n }}\n autoComplete=\"off\"\n spellCheck={false}\n />\n </label>\n\n <div className=\"actions\">\n <button\n type=\"button\"\n onClick={handleSave}\n disabled={saveState === 'saving' || appKey.trim().length === 0}\n >\n {saveState === 'saving' ? 'Saving...' : 'Save credentials'}\n </button>\n <button\n type=\"button\"\n onClick={handleTest}\n disabled={!canTest || testState.kind === 'running'}\n >\n {testState.kind === 'running' ? 'Testing...' : 'Test connection'}\n </button>\n </div>\n\n {saveState === 'saved' ? <p role=\"status\">Saved.</p> : null}\n {saveState === 'error' && saveError ? (\n <p role=\"alert\">Save failed: {saveError}</p>\n ) : null}\n\n {testState.kind === 'ok' ? (\n <p role=\"status\">\n Connected to AliExpress. Found {testState.categoryCount} categories.\n </p>\n ) : null}\n {testState.kind === 'err' ? (\n <p role=\"alert\">\n Test failed ({testState.code}): {testState.msg}\n </p>\n ) : null}\n </section>\n\n <section aria-labelledby=\"ae-oauth-heading\">\n <h2 id=\"ae-oauth-heading\">Merchant account connection</h2>\n <p>\n Connect a specific AliExpress seller account to enable product\n import into this store. This is separate from the developer app\n credentials above.\n </p>\n\n {initialStatus.needsReauth ? (\n <p role=\"alert\" className=\"reauth-banner\">\n Re-authentication required. Please reconnect your AliExpress account.\n </p>\n ) : null}\n\n <div className=\"status-card\">\n <div>\n <strong>Status:</strong>{' '}\n {initialStatus.connected ? 'Connected' : 'Not connected'}\n </div>\n {initialStatus.sellerId ? (\n <div>\n <strong>Seller ID:</strong> {initialStatus.sellerId}\n </div>\n ) : null}\n {initialStatus.lastSuccessfulCallAt ? (\n <div>\n <strong>Last successful call:</strong>{' '}\n {initialStatus.lastSuccessfulCallAt}\n </div>\n ) : null}\n </div>\n\n <div className=\"actions\">\n <button\n type=\"button\"\n onClick={handleConnect}\n disabled={!canConnect || busyOAuth}\n >\n {busyOAuth ? 'Working...' : 'Connect merchant AliExpress account'}\n </button>\n <button\n type=\"button\"\n onClick={handleDisconnect}\n disabled={!canDisconnect || busyOAuth}\n >\n Disconnect\n </button>\n </div>\n\n {!testEverSucceeded ? (\n <p>\n Run <em>Test connection</em> once with your AppKey/AppSecret before\n connecting a merchant account.\n </p>\n ) : null}\n </section>\n\n <section aria-labelledby=\"ae-coming-soon-heading\">\n <h2 id=\"ae-coming-soon-heading\">Order forwarding</h2>\n <p>\n Coming soon. Automatic order forwarding to AliExpress requires\n our app to be approved out of Test status by AliExpress. Product\n import and browsing work today.\n </p>\n </section>\n </div>\n )\n}\n\nexport default AliExpressDropshippingSettingsForm\n"],"mappings":";AAcO,IAAM,sBAAsB;AA8B5B,IAAK,yBAAL,kBAAKA,4BAAL;AACL,EAAAA,wBAAA,wBAAqB;AACrB,EAAAA,wBAAA,wBAAqB;AACrB,EAAAA,wBAAA,mBAAgB;AAChB,EAAAA,wBAAA,kBAAe;AAJL,SAAAA;AAAA,GAAA;;;AC7BZ,YAAY,WAAW;AAqJf,cAOA,YAPA;AAtGD,SAAS,mCACd,OACoB;AACpB,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,QAAM,CAAC,QAAQ,SAAS,IAAU;AAAA,IAChC,cAAc,UAAU;AAAA,EAC1B;AACA,QAAM,eACJ,cAAc,cAAc,uBAC3B,OAAO,cAAc,cAAc,YAClC,cAAc,UAAU,SAAS;AAC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