@amboras-dev/aliexpress-dropshipping 1.1.0 → 1.2.2
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 +7 -3
- package/dist/admin/index.d.mts +50 -0
- package/dist/admin/index.d.ts +50 -0
- package/dist/admin/index.js +253 -0
- package/dist/admin/index.js.map +1 -0
- package/dist/admin/index.mjs +7 -0
- package/dist/admin/index.mjs.map +1 -0
- package/dist/chunk-65TJ4JF6.mjs +224 -0
- package/dist/chunk-65TJ4JF6.mjs.map +1 -0
- package/dist/chunk-FPBGH4MH.mjs +89 -0
- package/dist/chunk-FPBGH4MH.mjs.map +1 -0
- package/dist/client/index.d.mts +46 -0
- package/dist/client/index.d.ts +46 -0
- package/dist/client/index.js +116 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/index.mjs +9 -0
- package/dist/client/index.mjs.map +1 -0
- package/dist/index.d.mts +5 -171
- package/dist/index.d.ts +5 -171
- package/dist/index.js +90 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -222
- package/dist/index.mjs.map +1 -1
- package/dist/types-CLTkhq_u.d.mts +151 -0
- package/dist/types-CLTkhq_u.d.ts +151 -0
- package/package.json +12 -3
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/settings-form.tsx","../src/types.ts"],"sourcesContent":["/**\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"],"mappings":";;;AAaA,YAAY,WAAW;;;ACChB,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;;;ADsHJ,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;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,QAAQ;AACrB,iBAAa,IAAI;AACjB,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AAC,aAAQ,mBAAgB,0BACvB;AAAA,0BAAC,QAAG,IAAG,0BAAyB,8BAAgB;AAAA,MAChD,oBAAC,OAAE,6KAIH;AAAA,OACF;AAAA,KACF;AAEJ;","names":["AliExpressReauthReason"]}
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public types for @amboras-dev/aliexpress-dropshipping.
|
|
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.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Sentinel returned in place of a stored secret when the settings form
|
|
11
|
+
* reads back current config. Matches the pattern used by meta-ads and
|
|
12
|
+
* pinterest so the admin never sees the plaintext secret after write.
|
|
13
|
+
*/
|
|
14
|
+
declare const SECRET_SET_SENTINEL: "__SECRET_SET__";
|
|
15
|
+
type SecretSetSentinel = typeof SECRET_SET_SENTINEL;
|
|
16
|
+
/**
|
|
17
|
+
* Per-store AliExpress plugin configuration.
|
|
18
|
+
*
|
|
19
|
+
* - `appKey` / `appSecret` are per-store developer app credentials
|
|
20
|
+
* supplied by the merchant. The admin form receives
|
|
21
|
+
* `SECRET_SET_SENTINEL` for `appSecret` on read, and only sends a
|
|
22
|
+
* real value on user edit.
|
|
23
|
+
* - `connectedSellerId` is populated after the merchant completes the
|
|
24
|
+
* OAuth flow to `/rest/auth/token/create`.
|
|
25
|
+
* - `needsReauth` is flipped by the backend runtime detector when it
|
|
26
|
+
* sees `MissingParameter access_token` or `IllegalAccessToken`
|
|
27
|
+
* sub-codes on any envelope.
|
|
28
|
+
* - `lastSuccessfulCallAt` is an ISO-8601 timestamp for the status card.
|
|
29
|
+
*/
|
|
30
|
+
interface AliExpressPluginConfig {
|
|
31
|
+
enabled: boolean;
|
|
32
|
+
appKey: string | null;
|
|
33
|
+
appSecret: string | SecretSetSentinel | null;
|
|
34
|
+
connectedSellerId: string | null;
|
|
35
|
+
needsReauth: boolean;
|
|
36
|
+
lastSuccessfulCallAt: string | null;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Reasons the backend surfaces when a merchant token becomes invalid.
|
|
40
|
+
* Kept narrow so the admin banner can render a specific message.
|
|
41
|
+
*/
|
|
42
|
+
declare enum AliExpressReauthReason {
|
|
43
|
+
MissingAccessToken = "missing_access_token",
|
|
44
|
+
IllegalAccessToken = "illegal_access_token",
|
|
45
|
+
RefreshFailed = "refresh_failed",
|
|
46
|
+
Disconnected = "disconnected"
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Category node returned by `aliexpress.ds.category.get`. The API
|
|
50
|
+
* returns a flat list; the admin renders it as a tree by walking
|
|
51
|
+
* `parentCategoryId`.
|
|
52
|
+
*/
|
|
53
|
+
interface AliExpressCategoryDto {
|
|
54
|
+
categoryId: string;
|
|
55
|
+
categoryName: string;
|
|
56
|
+
parentCategoryId: string | null;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Product summary shape returned by `aliexpress.ds.recommend.feed.get`.
|
|
60
|
+
* Used by the "browse products" admin surface.
|
|
61
|
+
*/
|
|
62
|
+
interface AliExpressProductSummaryDto {
|
|
63
|
+
productId: string;
|
|
64
|
+
title: string;
|
|
65
|
+
imageUrl: string | null;
|
|
66
|
+
minPrice: number | null;
|
|
67
|
+
maxPrice: number | null;
|
|
68
|
+
currency: string | null;
|
|
69
|
+
productDetailUrl: string | null;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Full product shape returned by `aliexpress.ds.product.get`. Consumed
|
|
73
|
+
* by the medusa-side mapper `aliexpressProductToMedusaDraft`.
|
|
74
|
+
*/
|
|
75
|
+
interface AliExpressProductDto {
|
|
76
|
+
productId: string;
|
|
77
|
+
title: string;
|
|
78
|
+
description: string | null;
|
|
79
|
+
images: string[];
|
|
80
|
+
variants: AliExpressProductVariantDto[];
|
|
81
|
+
weightGrams: number | null;
|
|
82
|
+
sourceUrl: string | null;
|
|
83
|
+
}
|
|
84
|
+
interface AliExpressProductVariantDto {
|
|
85
|
+
skuId: string;
|
|
86
|
+
title: string | null;
|
|
87
|
+
price: number;
|
|
88
|
+
currency: string;
|
|
89
|
+
stock: number | null;
|
|
90
|
+
attributes: Record<string, string>;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Return shape from `POST /store/aliexpress-dropshipping/products/:id/import`.
|
|
94
|
+
*/
|
|
95
|
+
interface AliExpressImportResultDto {
|
|
96
|
+
medusaProductId: string;
|
|
97
|
+
sourceProductId: string;
|
|
98
|
+
importedVariants: number;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Return shape from `GET /store/aliexpress-dropshipping/status` - drives
|
|
102
|
+
* the admin status card.
|
|
103
|
+
*/
|
|
104
|
+
interface AliExpressConnectionStatusDto {
|
|
105
|
+
connected: boolean;
|
|
106
|
+
sellerId: string | null;
|
|
107
|
+
needsReauth: boolean;
|
|
108
|
+
reauthReason: AliExpressReauthReason | null;
|
|
109
|
+
lastSuccessfulCallAt: string | null;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Return shape from `POST /store/aliexpress-dropshipping/test-connection`.
|
|
113
|
+
*/
|
|
114
|
+
type AliExpressTestConnectionResult = {
|
|
115
|
+
ok: true;
|
|
116
|
+
categoryCount: number;
|
|
117
|
+
} | {
|
|
118
|
+
ok: false;
|
|
119
|
+
code: string;
|
|
120
|
+
msg: string;
|
|
121
|
+
};
|
|
122
|
+
interface PreflightMerchantError {
|
|
123
|
+
code: string;
|
|
124
|
+
message: string;
|
|
125
|
+
}
|
|
126
|
+
interface PreflightAddressError {
|
|
127
|
+
code: string;
|
|
128
|
+
message: string;
|
|
129
|
+
field: string;
|
|
130
|
+
}
|
|
131
|
+
interface PreflightItemError {
|
|
132
|
+
variantId: string;
|
|
133
|
+
productTitle: string;
|
|
134
|
+
code: 'CORRUPT_METADATA' | 'PRODUCT_OFFLINE' | 'OUT_OF_STOCK' | 'CANNOT_SHIP' | 'PRICE_DRIFT';
|
|
135
|
+
message: string;
|
|
136
|
+
removable: boolean;
|
|
137
|
+
}
|
|
138
|
+
interface PreflightResult {
|
|
139
|
+
ok: boolean;
|
|
140
|
+
merchantErrors: PreflightMerchantError[];
|
|
141
|
+
addressErrors: PreflightAddressError[];
|
|
142
|
+
itemErrors: PreflightItemError[];
|
|
143
|
+
warnings: Array<{
|
|
144
|
+
code: string;
|
|
145
|
+
message: string;
|
|
146
|
+
}>;
|
|
147
|
+
degraded?: boolean;
|
|
148
|
+
warning?: string;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export { type AliExpressCategoryDto as A, type PreflightResult as P, SECRET_SET_SENTINEL as S, type AliExpressConnectionStatusDto as a, type AliExpressImportResultDto as b, type AliExpressPluginConfig as c, type AliExpressProductDto as d, type AliExpressProductSummaryDto as e, type AliExpressProductVariantDto as f, AliExpressReauthReason as g, type AliExpressTestConnectionResult as h, type SecretSetSentinel as i, type PreflightAddressError as j, type PreflightItemError as k, type PreflightMerchantError as l };
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public types for @amboras-dev/aliexpress-dropshipping.
|
|
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.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Sentinel returned in place of a stored secret when the settings form
|
|
11
|
+
* reads back current config. Matches the pattern used by meta-ads and
|
|
12
|
+
* pinterest so the admin never sees the plaintext secret after write.
|
|
13
|
+
*/
|
|
14
|
+
declare const SECRET_SET_SENTINEL: "__SECRET_SET__";
|
|
15
|
+
type SecretSetSentinel = typeof SECRET_SET_SENTINEL;
|
|
16
|
+
/**
|
|
17
|
+
* Per-store AliExpress plugin configuration.
|
|
18
|
+
*
|
|
19
|
+
* - `appKey` / `appSecret` are per-store developer app credentials
|
|
20
|
+
* supplied by the merchant. The admin form receives
|
|
21
|
+
* `SECRET_SET_SENTINEL` for `appSecret` on read, and only sends a
|
|
22
|
+
* real value on user edit.
|
|
23
|
+
* - `connectedSellerId` is populated after the merchant completes the
|
|
24
|
+
* OAuth flow to `/rest/auth/token/create`.
|
|
25
|
+
* - `needsReauth` is flipped by the backend runtime detector when it
|
|
26
|
+
* sees `MissingParameter access_token` or `IllegalAccessToken`
|
|
27
|
+
* sub-codes on any envelope.
|
|
28
|
+
* - `lastSuccessfulCallAt` is an ISO-8601 timestamp for the status card.
|
|
29
|
+
*/
|
|
30
|
+
interface AliExpressPluginConfig {
|
|
31
|
+
enabled: boolean;
|
|
32
|
+
appKey: string | null;
|
|
33
|
+
appSecret: string | SecretSetSentinel | null;
|
|
34
|
+
connectedSellerId: string | null;
|
|
35
|
+
needsReauth: boolean;
|
|
36
|
+
lastSuccessfulCallAt: string | null;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Reasons the backend surfaces when a merchant token becomes invalid.
|
|
40
|
+
* Kept narrow so the admin banner can render a specific message.
|
|
41
|
+
*/
|
|
42
|
+
declare enum AliExpressReauthReason {
|
|
43
|
+
MissingAccessToken = "missing_access_token",
|
|
44
|
+
IllegalAccessToken = "illegal_access_token",
|
|
45
|
+
RefreshFailed = "refresh_failed",
|
|
46
|
+
Disconnected = "disconnected"
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Category node returned by `aliexpress.ds.category.get`. The API
|
|
50
|
+
* returns a flat list; the admin renders it as a tree by walking
|
|
51
|
+
* `parentCategoryId`.
|
|
52
|
+
*/
|
|
53
|
+
interface AliExpressCategoryDto {
|
|
54
|
+
categoryId: string;
|
|
55
|
+
categoryName: string;
|
|
56
|
+
parentCategoryId: string | null;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Product summary shape returned by `aliexpress.ds.recommend.feed.get`.
|
|
60
|
+
* Used by the "browse products" admin surface.
|
|
61
|
+
*/
|
|
62
|
+
interface AliExpressProductSummaryDto {
|
|
63
|
+
productId: string;
|
|
64
|
+
title: string;
|
|
65
|
+
imageUrl: string | null;
|
|
66
|
+
minPrice: number | null;
|
|
67
|
+
maxPrice: number | null;
|
|
68
|
+
currency: string | null;
|
|
69
|
+
productDetailUrl: string | null;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Full product shape returned by `aliexpress.ds.product.get`. Consumed
|
|
73
|
+
* by the medusa-side mapper `aliexpressProductToMedusaDraft`.
|
|
74
|
+
*/
|
|
75
|
+
interface AliExpressProductDto {
|
|
76
|
+
productId: string;
|
|
77
|
+
title: string;
|
|
78
|
+
description: string | null;
|
|
79
|
+
images: string[];
|
|
80
|
+
variants: AliExpressProductVariantDto[];
|
|
81
|
+
weightGrams: number | null;
|
|
82
|
+
sourceUrl: string | null;
|
|
83
|
+
}
|
|
84
|
+
interface AliExpressProductVariantDto {
|
|
85
|
+
skuId: string;
|
|
86
|
+
title: string | null;
|
|
87
|
+
price: number;
|
|
88
|
+
currency: string;
|
|
89
|
+
stock: number | null;
|
|
90
|
+
attributes: Record<string, string>;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Return shape from `POST /store/aliexpress-dropshipping/products/:id/import`.
|
|
94
|
+
*/
|
|
95
|
+
interface AliExpressImportResultDto {
|
|
96
|
+
medusaProductId: string;
|
|
97
|
+
sourceProductId: string;
|
|
98
|
+
importedVariants: number;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Return shape from `GET /store/aliexpress-dropshipping/status` - drives
|
|
102
|
+
* the admin status card.
|
|
103
|
+
*/
|
|
104
|
+
interface AliExpressConnectionStatusDto {
|
|
105
|
+
connected: boolean;
|
|
106
|
+
sellerId: string | null;
|
|
107
|
+
needsReauth: boolean;
|
|
108
|
+
reauthReason: AliExpressReauthReason | null;
|
|
109
|
+
lastSuccessfulCallAt: string | null;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Return shape from `POST /store/aliexpress-dropshipping/test-connection`.
|
|
113
|
+
*/
|
|
114
|
+
type AliExpressTestConnectionResult = {
|
|
115
|
+
ok: true;
|
|
116
|
+
categoryCount: number;
|
|
117
|
+
} | {
|
|
118
|
+
ok: false;
|
|
119
|
+
code: string;
|
|
120
|
+
msg: string;
|
|
121
|
+
};
|
|
122
|
+
interface PreflightMerchantError {
|
|
123
|
+
code: string;
|
|
124
|
+
message: string;
|
|
125
|
+
}
|
|
126
|
+
interface PreflightAddressError {
|
|
127
|
+
code: string;
|
|
128
|
+
message: string;
|
|
129
|
+
field: string;
|
|
130
|
+
}
|
|
131
|
+
interface PreflightItemError {
|
|
132
|
+
variantId: string;
|
|
133
|
+
productTitle: string;
|
|
134
|
+
code: 'CORRUPT_METADATA' | 'PRODUCT_OFFLINE' | 'OUT_OF_STOCK' | 'CANNOT_SHIP' | 'PRICE_DRIFT';
|
|
135
|
+
message: string;
|
|
136
|
+
removable: boolean;
|
|
137
|
+
}
|
|
138
|
+
interface PreflightResult {
|
|
139
|
+
ok: boolean;
|
|
140
|
+
merchantErrors: PreflightMerchantError[];
|
|
141
|
+
addressErrors: PreflightAddressError[];
|
|
142
|
+
itemErrors: PreflightItemError[];
|
|
143
|
+
warnings: Array<{
|
|
144
|
+
code: string;
|
|
145
|
+
message: string;
|
|
146
|
+
}>;
|
|
147
|
+
degraded?: boolean;
|
|
148
|
+
warning?: string;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export { type AliExpressCategoryDto as A, type PreflightResult as P, SECRET_SET_SENTINEL as S, type AliExpressConnectionStatusDto as a, type AliExpressImportResultDto as b, type AliExpressPluginConfig as c, type AliExpressProductDto as d, type AliExpressProductSummaryDto as e, type AliExpressProductVariantDto as f, AliExpressReauthReason as g, type AliExpressTestConnectionResult as h, type SecretSetSentinel as i, type PreflightAddressError as j, type PreflightItemError as k, type PreflightMerchantError as l };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amboras-dev/aliexpress-dropshipping",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "AliExpress Dropshipping integration
|
|
3
|
+
"version": "1.2.2",
|
|
4
|
+
"description": "AliExpress Dropshipping integration for Amboras - storefront preflight and admin settings",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -11,6 +11,16 @@
|
|
|
11
11
|
"import": "./dist/index.mjs",
|
|
12
12
|
"require": "./dist/index.js"
|
|
13
13
|
},
|
|
14
|
+
"./client": {
|
|
15
|
+
"types": "./dist/client/index.d.ts",
|
|
16
|
+
"import": "./dist/client/index.mjs",
|
|
17
|
+
"require": "./dist/client/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./admin": {
|
|
20
|
+
"types": "./dist/admin/index.d.ts",
|
|
21
|
+
"import": "./dist/admin/index.mjs",
|
|
22
|
+
"require": "./dist/admin/index.js"
|
|
23
|
+
},
|
|
14
24
|
"./package.json": "./package.json"
|
|
15
25
|
},
|
|
16
26
|
"files": [
|
|
@@ -20,7 +30,6 @@
|
|
|
20
30
|
"react": ">=18",
|
|
21
31
|
"next": ">=15"
|
|
22
32
|
},
|
|
23
|
-
"dependencies": {},
|
|
24
33
|
"devDependencies": {
|
|
25
34
|
"@types/node": "^20.0.0",
|
|
26
35
|
"@types/react": "^19.0.0",
|