@thorprovider/medusa-extended 1.0.0

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/dist/index.mjs ADDED
@@ -0,0 +1,288 @@
1
+ // src/admin.ts
2
+ import { createLogger, ProviderAPIError } from "@thorprovider/adapters";
3
+ var MedusaAdminClient = class {
4
+ baseUrl;
5
+ apiKey;
6
+ logger;
7
+ constructor(config) {
8
+ this.baseUrl = config.baseUrl.replace(/\/$/, "");
9
+ this.apiKey = config.apiKey;
10
+ this.logger = createLogger("MedusaAdminClient", config.debug);
11
+ }
12
+ // -----------------------------------------------------------------------
13
+ // Private — HTTP helper
14
+ // -----------------------------------------------------------------------
15
+ async request(method, path, body) {
16
+ const url = `${this.baseUrl}${path}`;
17
+ this.logger.debug(`[admin] ${method} ${path}`);
18
+ const headers = {
19
+ "x-medusa-access-token": this.apiKey,
20
+ "Content-Type": "application/json"
21
+ };
22
+ const init = {
23
+ method,
24
+ headers,
25
+ ...body !== void 0 ? { body: JSON.stringify(body) } : {}
26
+ };
27
+ let response;
28
+ try {
29
+ response = await fetch(url, init);
30
+ } catch (networkError) {
31
+ throw new ProviderAPIError(
32
+ `[admin] Network error on ${method} ${path}: ${networkError.message}`,
33
+ "NETWORK_ERROR",
34
+ networkError
35
+ );
36
+ }
37
+ if (!response.ok) {
38
+ let message = `HTTP ${response.status}`;
39
+ try {
40
+ const json = await response.json();
41
+ message = json?.message ?? message;
42
+ } catch {
43
+ }
44
+ throw new ProviderAPIError(
45
+ `[admin] ${method} ${path} failed: ${message}`,
46
+ `ADMIN_API_${response.status}`,
47
+ response.status
48
+ );
49
+ }
50
+ return response.json();
51
+ }
52
+ // -----------------------------------------------------------------------
53
+ // 3.1 — Sales Channel: Customers
54
+ // -----------------------------------------------------------------------
55
+ /**
56
+ * Paginated list of customers linked to a sales channel.
57
+ *
58
+ * `GET /admin/thor/sales-channels/:id/customers`
59
+ */
60
+ async getChannelCustomers(salesChannelId, options = {}) {
61
+ const { limit = 20, offset = 0 } = options;
62
+ return this.request(
63
+ "GET",
64
+ `/admin/thor/sales-channels/${salesChannelId}/customers?limit=${limit}&offset=${offset}`
65
+ );
66
+ }
67
+ // -----------------------------------------------------------------------
68
+ // 3.2 — Sales Channel: API Keys
69
+ // -----------------------------------------------------------------------
70
+ /**
71
+ * Publishable API keys associated with a sales channel.
72
+ *
73
+ * `GET /admin/thor/sales-channels/:id/api-keys`
74
+ */
75
+ async getChannelApiKeys(salesChannelId) {
76
+ return this.request(
77
+ "GET",
78
+ `/admin/thor/sales-channels/${salesChannelId}/api-keys`
79
+ );
80
+ }
81
+ // -----------------------------------------------------------------------
82
+ // 3.3 — Sales Channel: Categories
83
+ // -----------------------------------------------------------------------
84
+ /**
85
+ * Product categories assigned to a sales channel.
86
+ *
87
+ * `GET /admin/thor/sales-channels/:id/categories`
88
+ */
89
+ async getChannelCategories(salesChannelId, options = {}) {
90
+ const { limit = 20, offset = 0, include_descendants = false } = options;
91
+ const qs = new URLSearchParams({
92
+ limit: String(limit),
93
+ offset: String(offset),
94
+ include_descendants: String(include_descendants)
95
+ });
96
+ return this.request(
97
+ "GET",
98
+ `/admin/thor/sales-channels/${salesChannelId}/categories?${qs}`
99
+ );
100
+ }
101
+ // -----------------------------------------------------------------------
102
+ // 3.4 — Category: Sales Channels
103
+ // -----------------------------------------------------------------------
104
+ /**
105
+ * Sales channels to which a category is assigned.
106
+ *
107
+ * `GET /admin/thor/categories/:id/sales-channels`
108
+ */
109
+ async getCategorySalesChannels(categoryId) {
110
+ return this.request(
111
+ "GET",
112
+ `/admin/thor/categories/${categoryId}/sales-channels`
113
+ );
114
+ }
115
+ // -----------------------------------------------------------------------
116
+ // 3.5 — Category: Assign to Sales Channels
117
+ // -----------------------------------------------------------------------
118
+ /**
119
+ * Assign a category to one or more sales channels (idempotent).
120
+ *
121
+ * `POST /admin/thor/categories/:id/sales-channels`
122
+ */
123
+ async assignCategoryToChannels(categoryId, body) {
124
+ return this.request(
125
+ "POST",
126
+ `/admin/thor/categories/${categoryId}/sales-channels`,
127
+ body
128
+ );
129
+ }
130
+ // -----------------------------------------------------------------------
131
+ // 3.6 — Category: Unassign from Sales Channels
132
+ // -----------------------------------------------------------------------
133
+ /**
134
+ * Remove category assignment from one or more sales channels (idempotent).
135
+ *
136
+ * `DELETE /admin/thor/categories/:id/sales-channels`
137
+ */
138
+ async unassignCategoryFromChannels(categoryId, body) {
139
+ return this.request(
140
+ "DELETE",
141
+ `/admin/thor/categories/${categoryId}/sales-channels`,
142
+ body
143
+ );
144
+ }
145
+ // -----------------------------------------------------------------------
146
+ // 3.7 — Collection: Sales Channels
147
+ // -----------------------------------------------------------------------
148
+ /**
149
+ * Sales channels to which a collection is assigned.
150
+ *
151
+ * `GET /admin/thor/collections/:id/sales-channels`
152
+ */
153
+ async getCollectionSalesChannels(collectionId) {
154
+ return this.request(
155
+ "GET",
156
+ `/admin/thor/collections/${collectionId}/sales-channels`
157
+ );
158
+ }
159
+ // -----------------------------------------------------------------------
160
+ // 3.8 — Collection: Assign to Sales Channels
161
+ // -----------------------------------------------------------------------
162
+ /**
163
+ * Assign a collection to one or more sales channels (idempotent).
164
+ *
165
+ * `POST /admin/thor/collections/:id/sales-channels`
166
+ */
167
+ async assignCollectionToChannels(collectionId, body) {
168
+ return this.request(
169
+ "POST",
170
+ `/admin/thor/collections/${collectionId}/sales-channels`,
171
+ body
172
+ );
173
+ }
174
+ // -----------------------------------------------------------------------
175
+ // 3.9 — Collection: Unassign from Sales Channels
176
+ // -----------------------------------------------------------------------
177
+ /**
178
+ * Remove collection assignment from one or more sales channels (idempotent).
179
+ *
180
+ * `DELETE /admin/thor/collections/:id/sales-channels`
181
+ */
182
+ async unassignCollectionFromChannels(collectionId, body) {
183
+ return this.request(
184
+ "DELETE",
185
+ `/admin/thor/collections/${collectionId}/sales-channels`,
186
+ body
187
+ );
188
+ }
189
+ // -----------------------------------------------------------------------
190
+ // 3.10 — Storefront Config: Read
191
+ // -----------------------------------------------------------------------
192
+ /**
193
+ * Read the visual storefront configuration for a channel.
194
+ * `:id` is the `sales_channel_id`.
195
+ *
196
+ * `GET /admin/thor/storefront-config/:id`
197
+ */
198
+ async getStorefrontConfig(salesChannelId) {
199
+ return this.request(
200
+ "GET",
201
+ `/admin/thor/storefront-config/${salesChannelId}`
202
+ );
203
+ }
204
+ // -----------------------------------------------------------------------
205
+ // 3.11 — Storefront Config: Update
206
+ // -----------------------------------------------------------------------
207
+ /**
208
+ * Update the visual storefront configuration for a channel.
209
+ * Triggers the `storefront_config.updated` event → ISR webhook.
210
+ *
211
+ * `PUT /admin/thor/storefront-config/:id`
212
+ */
213
+ async updateStorefrontConfig(salesChannelId, body) {
214
+ return this.request(
215
+ "PUT",
216
+ `/admin/thor/storefront-config/${salesChannelId}`,
217
+ body
218
+ );
219
+ }
220
+ // -----------------------------------------------------------------------
221
+ // 3.12 — Site Designer Config: Read
222
+ // -----------------------------------------------------------------------
223
+ /**
224
+ * Read the active Site Designer configuration for a channel, including the
225
+ * last 10 history entries.
226
+ *
227
+ * `GET /admin/thor/site-config/:sales_channel_id`
228
+ */
229
+ async getSiteConfig(salesChannelId) {
230
+ return this.request(
231
+ "GET",
232
+ `/admin/thor/site-config/${salesChannelId}`
233
+ );
234
+ }
235
+ // -----------------------------------------------------------------------
236
+ // 3.13 — Site Designer Config: Update
237
+ // -----------------------------------------------------------------------
238
+ /**
239
+ * Update the Site Designer configuration for a channel.
240
+ * Creates a new history entry on every PUT.
241
+ *
242
+ * `PUT /admin/thor/site-config/:sales_channel_id`
243
+ */
244
+ async updateSiteConfig(salesChannelId, body) {
245
+ return this.request(
246
+ "PUT",
247
+ `/admin/thor/site-config/${salesChannelId}`,
248
+ body
249
+ );
250
+ }
251
+ // -----------------------------------------------------------------------
252
+ // 3.14 — Site Designer Config: History
253
+ // -----------------------------------------------------------------------
254
+ /**
255
+ * Full paginated history of Site Designer versions for a channel.
256
+ * Entries are immutable — they are never deleted.
257
+ *
258
+ * `GET /admin/thor/site-config/:sales_channel_id/history`
259
+ */
260
+ async getSiteConfigHistory(salesChannelId, options = {}) {
261
+ const { limit = 20, offset = 0 } = options;
262
+ return this.request(
263
+ "GET",
264
+ `/admin/thor/site-config/${salesChannelId}/history?limit=${limit}&offset=${offset}`
265
+ );
266
+ }
267
+ // -----------------------------------------------------------------------
268
+ // 3.15 — Site Designer Config: Restore
269
+ // -----------------------------------------------------------------------
270
+ /**
271
+ * Restore a previous Site Designer version.
272
+ * Internally runs the update workflow with the stored config of the target
273
+ * version — this creates a **new** history entry and does NOT mutate past
274
+ * entries.
275
+ *
276
+ * `POST /admin/thor/site-config/:sales_channel_id/restore/:version`
277
+ */
278
+ async restoreSiteConfig(salesChannelId, version) {
279
+ return this.request(
280
+ "POST",
281
+ `/admin/thor/site-config/${salesChannelId}/restore/${encodeURIComponent(version)}`
282
+ );
283
+ }
284
+ };
285
+ export {
286
+ MedusaAdminClient
287
+ };
288
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/admin.ts"],"sourcesContent":["/**\n * @fileoverview Medusa Multi-Tenant Admin Client\n * @module @thorprovider/adapters/providers/medusa/admin\n *\n * Wrapper methods for all `/admin/thor/` endpoints defined in the Thor Commerce\n * multi-tenant API contract. Requires an admin API key (`adminConfig.apiKey`)\n * to be provided when creating the Medusa provider.\n *\n * Every method performs a raw `fetch` against the Medusa backend using the\n * admin API key (`x-medusa-access-token`) — the Medusa JS-SDK's admin client\n * does not expose these custom Thor plugin routes, so we use direct HTTP calls.\n *\n * Endpoint reference: `multitenant-api-contract.md`\n */\n\nimport type {\n GetChannelCustomersOptions,\n GetChannelCustomersResponse,\n GetChannelApiKeysResponse,\n GetChannelCategoriesOptions,\n GetChannelCategoriesResponse,\n GetCategorySalesChannelsResponse,\n AssignCategoriesToChannelsBody,\n AssignCategoriesToChannelsResponse,\n UnassignCategoriesFromChannelsBody,\n UnassignCategoriesFromChannelsResponse,\n GetCollectionSalesChannelsResponse,\n AssignCollectionsToChannelsBody,\n AssignCollectionsToChannelsResponse,\n UnassignCollectionsFromChannelsBody,\n UnassignCollectionsFromChannelsResponse,\n GetAdminStorefrontConfigResponse,\n UpdateStorefrontConfigBody,\n UpdateStorefrontConfigResponse,\n GetAdminSiteConfigResponse,\n UpdateSiteConfigBody,\n UpdateSiteConfigResponse,\n GetAdminSiteConfigHistoryOptions,\n GetAdminSiteConfigHistoryResponse,\n RestoreSiteConfigResponse,\n} from '@thorprovider/types';\nimport { createLogger, ProviderAPIError } from '@thorprovider/adapters';\n\n// ---------------------------------------------------------------------------\n// Internal helpers\n// ---------------------------------------------------------------------------\n\ntype FetchMethod = 'GET' | 'POST' | 'PUT' | 'DELETE';\n\n/**\n * Configuration required to instantiate the admin client.\n */\nexport interface MedusaAdminClientConfig {\n /** Medusa backend base URL */\n baseUrl: string;\n /** Secret admin API key (x-medusa-access-token) */\n apiKey: string;\n /** Enable debug logging */\n debug?: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// MedusaAdminClient\n// ---------------------------------------------------------------------------\n\n/**\n * HTTP client for Thor Commerce multi-tenant admin endpoints (`/admin/thor/`).\n *\n * All methods throw `ProviderAPIError` on non-2xx responses.\n *\n * @example\n * ```typescript\n * const admin = new MedusaAdminClient({\n * baseUrl: process.env.MEDUSA_BACKEND_URL!,\n * apiKey: process.env.MEDUSA_ADMIN_API_KEY!,\n * });\n *\n * const { customers } = await admin.getChannelCustomers('sc_01JXXXXX');\n * ```\n */\nexport class MedusaAdminClient {\n private baseUrl: string;\n private apiKey: string;\n private logger: ReturnType<typeof createLogger>;\n\n constructor(config: MedusaAdminClientConfig) {\n this.baseUrl = config.baseUrl.replace(/\\/$/, '');\n this.apiKey = config.apiKey;\n this.logger = createLogger('MedusaAdminClient', config.debug);\n }\n\n // -----------------------------------------------------------------------\n // Private — HTTP helper\n // -----------------------------------------------------------------------\n\n private async request<T>(\n method: FetchMethod,\n path: string,\n body?: unknown,\n ): Promise<T> {\n const url = `${this.baseUrl}${path}`;\n this.logger.debug(`[admin] ${method} ${path}`);\n\n const headers: Record<string, string> = {\n 'x-medusa-access-token': this.apiKey,\n 'Content-Type': 'application/json',\n };\n\n const init: RequestInit = {\n method,\n headers,\n ...(body !== undefined ? { body: JSON.stringify(body) } : {}),\n };\n\n let response: Response;\n try {\n response = await fetch(url, init);\n } catch (networkError: any) {\n throw new ProviderAPIError(\n `[admin] Network error on ${method} ${path}: ${networkError.message}`,\n 'NETWORK_ERROR',\n networkError,\n );\n }\n\n if (!response.ok) {\n let message = `HTTP ${response.status}`;\n try {\n const json = await response.json();\n message = json?.message ?? message;\n } catch {\n // ignore parse errors\n }\n throw new ProviderAPIError(\n `[admin] ${method} ${path} failed: ${message}`,\n `ADMIN_API_${response.status}`,\n response.status,\n );\n }\n\n return response.json() as Promise<T>;\n }\n\n // -----------------------------------------------------------------------\n // 3.1 — Sales Channel: Customers\n // -----------------------------------------------------------------------\n\n /**\n * Paginated list of customers linked to a sales channel.\n *\n * `GET /admin/thor/sales-channels/:id/customers`\n */\n async getChannelCustomers(\n salesChannelId: string,\n options: GetChannelCustomersOptions = {},\n ): Promise<GetChannelCustomersResponse> {\n const { limit = 20, offset = 0 } = options;\n return this.request<GetChannelCustomersResponse>(\n 'GET',\n `/admin/thor/sales-channels/${salesChannelId}/customers?limit=${limit}&offset=${offset}`,\n );\n }\n\n // -----------------------------------------------------------------------\n // 3.2 — Sales Channel: API Keys\n // -----------------------------------------------------------------------\n\n /**\n * Publishable API keys associated with a sales channel.\n *\n * `GET /admin/thor/sales-channels/:id/api-keys`\n */\n async getChannelApiKeys(salesChannelId: string): Promise<GetChannelApiKeysResponse> {\n return this.request<GetChannelApiKeysResponse>(\n 'GET',\n `/admin/thor/sales-channels/${salesChannelId}/api-keys`,\n );\n }\n\n // -----------------------------------------------------------------------\n // 3.3 — Sales Channel: Categories\n // -----------------------------------------------------------------------\n\n /**\n * Product categories assigned to a sales channel.\n *\n * `GET /admin/thor/sales-channels/:id/categories`\n */\n async getChannelCategories(\n salesChannelId: string,\n options: GetChannelCategoriesOptions = {},\n ): Promise<GetChannelCategoriesResponse> {\n const { limit = 20, offset = 0, include_descendants = false } = options;\n const qs = new URLSearchParams({\n limit: String(limit),\n offset: String(offset),\n include_descendants: String(include_descendants),\n });\n return this.request<GetChannelCategoriesResponse>(\n 'GET',\n `/admin/thor/sales-channels/${salesChannelId}/categories?${qs}`,\n );\n }\n\n // -----------------------------------------------------------------------\n // 3.4 — Category: Sales Channels\n // -----------------------------------------------------------------------\n\n /**\n * Sales channels to which a category is assigned.\n *\n * `GET /admin/thor/categories/:id/sales-channels`\n */\n async getCategorySalesChannels(\n categoryId: string,\n ): Promise<GetCategorySalesChannelsResponse> {\n return this.request<GetCategorySalesChannelsResponse>(\n 'GET',\n `/admin/thor/categories/${categoryId}/sales-channels`,\n );\n }\n\n // -----------------------------------------------------------------------\n // 3.5 — Category: Assign to Sales Channels\n // -----------------------------------------------------------------------\n\n /**\n * Assign a category to one or more sales channels (idempotent).\n *\n * `POST /admin/thor/categories/:id/sales-channels`\n */\n async assignCategoryToChannels(\n categoryId: string,\n body: AssignCategoriesToChannelsBody,\n ): Promise<AssignCategoriesToChannelsResponse> {\n return this.request<AssignCategoriesToChannelsResponse>(\n 'POST',\n `/admin/thor/categories/${categoryId}/sales-channels`,\n body,\n );\n }\n\n // -----------------------------------------------------------------------\n // 3.6 — Category: Unassign from Sales Channels\n // -----------------------------------------------------------------------\n\n /**\n * Remove category assignment from one or more sales channels (idempotent).\n *\n * `DELETE /admin/thor/categories/:id/sales-channels`\n */\n async unassignCategoryFromChannels(\n categoryId: string,\n body: UnassignCategoriesFromChannelsBody,\n ): Promise<UnassignCategoriesFromChannelsResponse> {\n return this.request<UnassignCategoriesFromChannelsResponse>(\n 'DELETE',\n `/admin/thor/categories/${categoryId}/sales-channels`,\n body,\n );\n }\n\n // -----------------------------------------------------------------------\n // 3.7 — Collection: Sales Channels\n // -----------------------------------------------------------------------\n\n /**\n * Sales channels to which a collection is assigned.\n *\n * `GET /admin/thor/collections/:id/sales-channels`\n */\n async getCollectionSalesChannels(\n collectionId: string,\n ): Promise<GetCollectionSalesChannelsResponse> {\n return this.request<GetCollectionSalesChannelsResponse>(\n 'GET',\n `/admin/thor/collections/${collectionId}/sales-channels`,\n );\n }\n\n // -----------------------------------------------------------------------\n // 3.8 — Collection: Assign to Sales Channels\n // -----------------------------------------------------------------------\n\n /**\n * Assign a collection to one or more sales channels (idempotent).\n *\n * `POST /admin/thor/collections/:id/sales-channels`\n */\n async assignCollectionToChannels(\n collectionId: string,\n body: AssignCollectionsToChannelsBody,\n ): Promise<AssignCollectionsToChannelsResponse> {\n return this.request<AssignCollectionsToChannelsResponse>(\n 'POST',\n `/admin/thor/collections/${collectionId}/sales-channels`,\n body,\n );\n }\n\n // -----------------------------------------------------------------------\n // 3.9 — Collection: Unassign from Sales Channels\n // -----------------------------------------------------------------------\n\n /**\n * Remove collection assignment from one or more sales channels (idempotent).\n *\n * `DELETE /admin/thor/collections/:id/sales-channels`\n */\n async unassignCollectionFromChannels(\n collectionId: string,\n body: UnassignCollectionsFromChannelsBody,\n ): Promise<UnassignCollectionsFromChannelsResponse> {\n return this.request<UnassignCollectionsFromChannelsResponse>(\n 'DELETE',\n `/admin/thor/collections/${collectionId}/sales-channels`,\n body,\n );\n }\n\n // -----------------------------------------------------------------------\n // 3.10 — Storefront Config: Read\n // -----------------------------------------------------------------------\n\n /**\n * Read the visual storefront configuration for a channel.\n * `:id` is the `sales_channel_id`.\n *\n * `GET /admin/thor/storefront-config/:id`\n */\n async getStorefrontConfig(\n salesChannelId: string,\n ): Promise<GetAdminStorefrontConfigResponse> {\n return this.request<GetAdminStorefrontConfigResponse>(\n 'GET',\n `/admin/thor/storefront-config/${salesChannelId}`,\n );\n }\n\n // -----------------------------------------------------------------------\n // 3.11 — Storefront Config: Update\n // -----------------------------------------------------------------------\n\n /**\n * Update the visual storefront configuration for a channel.\n * Triggers the `storefront_config.updated` event → ISR webhook.\n *\n * `PUT /admin/thor/storefront-config/:id`\n */\n async updateStorefrontConfig(\n salesChannelId: string,\n body: UpdateStorefrontConfigBody,\n ): Promise<UpdateStorefrontConfigResponse> {\n return this.request<UpdateStorefrontConfigResponse>(\n 'PUT',\n `/admin/thor/storefront-config/${salesChannelId}`,\n body,\n );\n }\n\n // -----------------------------------------------------------------------\n // 3.12 — Site Designer Config: Read\n // -----------------------------------------------------------------------\n\n /**\n * Read the active Site Designer configuration for a channel, including the\n * last 10 history entries.\n *\n * `GET /admin/thor/site-config/:sales_channel_id`\n */\n async getSiteConfig(salesChannelId: string): Promise<GetAdminSiteConfigResponse> {\n return this.request<GetAdminSiteConfigResponse>(\n 'GET',\n `/admin/thor/site-config/${salesChannelId}`,\n );\n }\n\n // -----------------------------------------------------------------------\n // 3.13 — Site Designer Config: Update\n // -----------------------------------------------------------------------\n\n /**\n * Update the Site Designer configuration for a channel.\n * Creates a new history entry on every PUT.\n *\n * `PUT /admin/thor/site-config/:sales_channel_id`\n */\n async updateSiteConfig(\n salesChannelId: string,\n body: UpdateSiteConfigBody,\n ): Promise<UpdateSiteConfigResponse> {\n return this.request<UpdateSiteConfigResponse>(\n 'PUT',\n `/admin/thor/site-config/${salesChannelId}`,\n body,\n );\n }\n\n // -----------------------------------------------------------------------\n // 3.14 — Site Designer Config: History\n // -----------------------------------------------------------------------\n\n /**\n * Full paginated history of Site Designer versions for a channel.\n * Entries are immutable — they are never deleted.\n *\n * `GET /admin/thor/site-config/:sales_channel_id/history`\n */\n async getSiteConfigHistory(\n salesChannelId: string,\n options: GetAdminSiteConfigHistoryOptions = {},\n ): Promise<GetAdminSiteConfigHistoryResponse> {\n const { limit = 20, offset = 0 } = options;\n return this.request<GetAdminSiteConfigHistoryResponse>(\n 'GET',\n `/admin/thor/site-config/${salesChannelId}/history?limit=${limit}&offset=${offset}`,\n );\n }\n\n // -----------------------------------------------------------------------\n // 3.15 — Site Designer Config: Restore\n // -----------------------------------------------------------------------\n\n /**\n * Restore a previous Site Designer version.\n * Internally runs the update workflow with the stored config of the target\n * version — this creates a **new** history entry and does NOT mutate past\n * entries.\n *\n * `POST /admin/thor/site-config/:sales_channel_id/restore/:version`\n */\n async restoreSiteConfig(\n salesChannelId: string,\n version: string,\n ): Promise<RestoreSiteConfigResponse> {\n return this.request<RestoreSiteConfigResponse>(\n 'POST',\n `/admin/thor/site-config/${salesChannelId}/restore/${encodeURIComponent(version)}`,\n );\n }\n}\n"],"mappings":";AAyCA,SAAS,cAAc,wBAAwB;AAuCxC,IAAM,oBAAN,MAAwB;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EAER,YAAY,QAAiC;AAC3C,SAAK,UAAU,OAAO,QAAQ,QAAQ,OAAO,EAAE;AAC/C,SAAK,SAAS,OAAO;AACrB,SAAK,SAAS,aAAa,qBAAqB,OAAO,KAAK;AAAA,EAC9D;AAAA;AAAA;AAAA;AAAA,EAMA,MAAc,QACZ,QACA,MACA,MACY;AACZ,UAAM,MAAM,GAAG,KAAK,OAAO,GAAG,IAAI;AAClC,SAAK,OAAO,MAAM,WAAW,MAAM,IAAI,IAAI,EAAE;AAE7C,UAAM,UAAkC;AAAA,MACtC,yBAAyB,KAAK;AAAA,MAC9B,gBAAgB;AAAA,IAClB;AAEA,UAAM,OAAoB;AAAA,MACxB;AAAA,MACA;AAAA,MACA,GAAI,SAAS,SAAY,EAAE,MAAM,KAAK,UAAU,IAAI,EAAE,IAAI,CAAC;AAAA,IAC7D;AAEA,QAAI;AACJ,QAAI;AACF,iBAAW,MAAM,MAAM,KAAK,IAAI;AAAA,IAClC,SAAS,cAAmB;AAC1B,YAAM,IAAI;AAAA,QACR,4BAA4B,MAAM,IAAI,IAAI,KAAK,aAAa,OAAO;AAAA,QACnE;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,QAAI,CAAC,SAAS,IAAI;AAChB,UAAI,UAAU,QAAQ,SAAS,MAAM;AACrC,UAAI;AACF,cAAM,OAAO,MAAM,SAAS,KAAK;AACjC,kBA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gBAA6D;AAC/E,WAAO,KAAK;AAAA,MACV;AAAA,MACA,2BAA2B,cAAc;AAAA,IAC3C;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA,MAAM,iBACJ,gBACA,MACmC;AACnC,WAAO,KAAK;AAAA,MACV;AAAA,MACA,2BAA2B,cAAc;AAAA,MACzC;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA,MAAM,qBACJ,gBACA,UAA4C,CAAC,GACD;AAC5C,UAAM,EAAE,QAAQ,IAAI,SAAS,EAAE,IAAI;AACnC,WAAO,KAAK;AAAA,MACV;AAAA,MACA,2BAA2B,cAAc,kBAAkB,KAAK,WAAW,MAAM;AAAA,IACnF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcA,MAAM,kBACJ,gBACA,SACoC;AACpC,WAAO,KAAK;AAAA,MACV;AAAA,MACA,2BAA2B,cAAc,YAAY,mBAAmB,OAAO,CAAC;AAAA,IAClF;AAAA,EACF;AACF;","names":[]}
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@thorprovider/medusa-extended",
3
+ "version": "1.0.0",
4
+ "description": "Thor Commerce multi-tenant admin extensions for Medusa v2",
5
+ "publishConfig": {
6
+ "registry": "https://registry.npmjs.org",
7
+ "access": "public"
8
+ },
9
+ "main": "dist/index.js",
10
+ "types": "dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "development": "./dist/index.mjs",
15
+ "import": "./dist/index.mjs",
16
+ "require": "./dist/index.js",
17
+ "default": "./dist/index.mjs"
18
+ }
19
+ },
20
+ "scripts": {
21
+ "build": "tsup",
22
+ "dev": "tsup --watch",
23
+ "type-check": "tsc --noEmit",
24
+ "test": "vitest run --config vitest.config.ts"
25
+ },
26
+ "dependencies": {
27
+ "@thorprovider/adapters": "workspace:*",
28
+ "@thorprovider/types": "workspace:*"
29
+ },
30
+ "devDependencies": {
31
+ "msw": "^2.12.3",
32
+ "tsup": "^8.0.0",
33
+ "typescript": "^5.0.0",
34
+ "vitest": "^3.2.4"
35
+ },
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "https://github.com/thorprovider/thor-commerce",
39
+ "directory": "packages/medusa-extended"
40
+ },
41
+ "license": "MIT"
42
+ }