@medusajs/dashboard 2.19.0 → 2.19.1-preview-20260813160157

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/app.js CHANGED
@@ -105205,6 +105205,380 @@ var init_permissions_provider2 = __esm({
105205
105205
  }
105206
105206
  });
105207
105207
 
105208
+ // src/lib/search/default-search-entities.ts
105209
+ var DEFAULT_SEARCH_ENTITIES;
105210
+ var init_default_search_entities = __esm({
105211
+ "src/lib/search/default-search-entities.ts"() {
105212
+ "use strict";
105213
+ DEFAULT_SEARCH_ENTITIES = {
105214
+ order: {
105215
+ shortcut: {
105216
+ keys: { Mac: ["G", "O"] },
105217
+ label: (t5) => t5("app.keyboardShortcuts.navigation.goToOrders"),
105218
+ to: "/orders"
105219
+ },
105220
+ transform: (order) => ({
105221
+ id: order.id,
105222
+ title: `#${order.display_id}`,
105223
+ subtitle: order.email ?? void 0,
105224
+ to: `/orders/${order.id}`,
105225
+ value: `order:${order.id}`
105226
+ })
105227
+ },
105228
+ product: {
105229
+ shortcut: {
105230
+ keys: { Mac: ["G", "P"] },
105231
+ label: (t5) => t5("app.keyboardShortcuts.navigation.goToProducts"),
105232
+ to: "/products"
105233
+ },
105234
+ transform: (product) => ({
105235
+ id: product.id,
105236
+ title: product.title,
105237
+ to: `/products/${product.id}`,
105238
+ thumbnail: product.thumbnail ?? void 0,
105239
+ value: `product:${product.id}`
105240
+ })
105241
+ },
105242
+ productVariant: {
105243
+ transform: (variant) => ({
105244
+ id: variant.id,
105245
+ title: variant.title,
105246
+ subtitle: variant.sku ?? void 0,
105247
+ to: `/products/${variant.product_id}/variants/${variant.id}`,
105248
+ value: `variant:${variant.id}`
105249
+ })
105250
+ },
105251
+ category: {
105252
+ shortcut: {
105253
+ keys: { Mac: ["G", "A"] },
105254
+ label: (t5) => t5("app.keyboardShortcuts.navigation.goToCategories"),
105255
+ to: "/categories"
105256
+ },
105257
+ transform: (category) => ({
105258
+ id: category.id,
105259
+ title: category.name,
105260
+ to: `/categories/${category.id}`,
105261
+ value: `category:${category.id}`
105262
+ })
105263
+ },
105264
+ inventory: {
105265
+ shortcut: {
105266
+ keys: { Mac: ["G", "I"] },
105267
+ label: (t5) => t5("app.keyboardShortcuts.navigation.goToInventory"),
105268
+ to: "/inventory"
105269
+ },
105270
+ transform: (inventory) => ({
105271
+ id: inventory.id,
105272
+ title: inventory.title ?? "",
105273
+ subtitle: inventory.sku ?? void 0,
105274
+ to: `/inventory/${inventory.id}`,
105275
+ value: `inventory:${inventory.id}`
105276
+ })
105277
+ },
105278
+ customer: {
105279
+ shortcut: {
105280
+ keys: { Mac: ["G", "U"] },
105281
+ label: (t5) => t5("app.keyboardShortcuts.navigation.goToCustomers"),
105282
+ to: "/customers"
105283
+ },
105284
+ transform: (customer) => {
105285
+ const name = [customer.first_name, customer.last_name].filter(Boolean).join(" ");
105286
+ return {
105287
+ id: customer.id,
105288
+ title: name || customer.email,
105289
+ subtitle: name ? customer.email : void 0,
105290
+ to: `/customers/${customer.id}`,
105291
+ value: `customer:${customer.id}`
105292
+ };
105293
+ }
105294
+ },
105295
+ customerGroup: {
105296
+ shortcut: {
105297
+ keys: { Mac: ["G", "G"] },
105298
+ label: (t5) => t5("app.keyboardShortcuts.navigation.goToCustomerGroups"),
105299
+ to: "/customer-groups"
105300
+ },
105301
+ transform: (customerGroup) => ({
105302
+ id: customerGroup.id,
105303
+ title: customerGroup.name,
105304
+ to: `/customer-groups/${customerGroup.id}`,
105305
+ value: `customerGroup:${customerGroup.id}`
105306
+ })
105307
+ },
105308
+ collection: {
105309
+ shortcut: {
105310
+ keys: { Mac: ["G", "C"] },
105311
+ label: (t5) => t5("app.keyboardShortcuts.navigation.goToCollections"),
105312
+ to: "/collections"
105313
+ },
105314
+ transform: (collection) => ({
105315
+ id: collection.id,
105316
+ title: collection.title,
105317
+ to: `/collections/${collection.id}`,
105318
+ value: `collection:${collection.id}`
105319
+ })
105320
+ },
105321
+ promotion: {
105322
+ shortcut: {
105323
+ keys: { Mac: ["G", "M"] },
105324
+ label: (t5) => t5("app.keyboardShortcuts.navigation.goToPromotions"),
105325
+ to: "/promotions"
105326
+ },
105327
+ transform: (promotion) => ({
105328
+ id: promotion.id,
105329
+ title: promotion.code,
105330
+ to: `/promotions/${promotion.id}`,
105331
+ value: `promotion:${promotion.id}`
105332
+ })
105333
+ },
105334
+ campaign: {
105335
+ shortcut: {
105336
+ keys: { Mac: ["G", "K"] },
105337
+ label: (t5) => t5("app.keyboardShortcuts.navigation.goToCampaigns"),
105338
+ to: "/campaigns"
105339
+ },
105340
+ transform: (campaign) => ({
105341
+ id: campaign.id,
105342
+ title: campaign.name,
105343
+ to: `/campaigns/${campaign.id}`,
105344
+ value: `campaign:${campaign.id}`
105345
+ })
105346
+ },
105347
+ priceList: {
105348
+ shortcut: {
105349
+ keys: { Mac: ["G", "L"] },
105350
+ label: (t5) => t5("app.keyboardShortcuts.navigation.goToPriceLists"),
105351
+ to: "/price-lists"
105352
+ },
105353
+ transform: (priceList) => ({
105354
+ id: priceList.id,
105355
+ title: priceList.title,
105356
+ to: `/price-lists/${priceList.id}`,
105357
+ value: `priceList:${priceList.id}`
105358
+ })
105359
+ },
105360
+ // Navigable, but a reservation is a quantity against an inventory item and a
105361
+ // location, with nothing readable to match on — so no `transform`.
105362
+ reservation: {
105363
+ shortcut: {
105364
+ keys: { Mac: ["G", "R"] },
105365
+ label: (t5) => t5("app.keyboardShortcuts.navigation.goToReservations"),
105366
+ to: "/reservations"
105367
+ }
105368
+ },
105369
+ user: {
105370
+ shortcut: {
105371
+ keys: { Mac: ["G", ",", "U"] },
105372
+ label: (t5) => t5("app.keyboardShortcuts.settings.goToUsers"),
105373
+ type: "settingShortcut",
105374
+ to: "/settings/users"
105375
+ },
105376
+ transform: (user) => ({
105377
+ id: user.id,
105378
+ title: `${user.first_name} ${user.last_name}`,
105379
+ subtitle: user.email,
105380
+ to: `/settings/users/${user.id}`,
105381
+ value: `user:${user.id}`
105382
+ })
105383
+ },
105384
+ region: {
105385
+ shortcut: {
105386
+ keys: { Mac: ["G", ",", "R"] },
105387
+ label: (t5) => t5("app.keyboardShortcuts.settings.goToRegions"),
105388
+ type: "settingShortcut",
105389
+ to: "/settings/regions"
105390
+ },
105391
+ transform: (region) => ({
105392
+ id: region.id,
105393
+ title: region.name,
105394
+ to: `/settings/regions/${region.id}`,
105395
+ value: `region:${region.id}`
105396
+ })
105397
+ },
105398
+ taxRegion: {
105399
+ shortcut: {
105400
+ keys: { Mac: ["G", ",", "T"] },
105401
+ label: (t5) => t5("app.keyboardShortcuts.settings.goToTaxRegions"),
105402
+ type: "settingShortcut",
105403
+ to: "/settings/tax-regions"
105404
+ },
105405
+ transform: (taxRegion) => ({
105406
+ id: taxRegion.id,
105407
+ title: taxRegion.province_code?.toUpperCase() ?? taxRegion.country_code.toUpperCase(),
105408
+ subtitle: taxRegion.province_code ? taxRegion.country_code : void 0,
105409
+ to: `/settings/tax-regions/${taxRegion.id}`,
105410
+ value: `taxRegion:${taxRegion.id}`
105411
+ })
105412
+ },
105413
+ returnReason: {
105414
+ shortcut: {
105415
+ keys: { Mac: ["G", ",", "M"] },
105416
+ label: (t5) => t5("app.keyboardShortcuts.settings.goToReturnReasons"),
105417
+ type: "settingShortcut",
105418
+ to: "/settings/return-reasons"
105419
+ },
105420
+ transform: (returnReason) => ({
105421
+ id: returnReason.id,
105422
+ title: returnReason.label,
105423
+ subtitle: returnReason.value,
105424
+ to: `/settings/return-reasons/${returnReason.id}/edit`,
105425
+ value: `returnReason:${returnReason.id}`
105426
+ })
105427
+ },
105428
+ salesChannel: {
105429
+ shortcut: {
105430
+ keys: { Mac: ["G", ",", "A"] },
105431
+ label: (t5) => t5("app.keyboardShortcuts.settings.goToSalesChannels"),
105432
+ type: "settingShortcut",
105433
+ to: "/settings/sales-channels"
105434
+ },
105435
+ transform: (salesChannel) => ({
105436
+ id: salesChannel.id,
105437
+ title: salesChannel.name,
105438
+ to: `/settings/sales-channels/${salesChannel.id}`,
105439
+ value: `salesChannel:${salesChannel.id}`
105440
+ })
105441
+ },
105442
+ productType: {
105443
+ shortcut: {
105444
+ keys: { Mac: ["G", ",", "P"] },
105445
+ label: (t5) => t5("app.keyboardShortcuts.settings.goToProductTypes"),
105446
+ type: "settingShortcut",
105447
+ to: "/settings/product-types"
105448
+ },
105449
+ transform: (productType) => ({
105450
+ id: productType.id,
105451
+ title: productType.value,
105452
+ to: `/settings/product-types/${productType.id}`,
105453
+ value: `productType:${productType.id}`
105454
+ })
105455
+ },
105456
+ productTag: {
105457
+ transform: (productTag) => ({
105458
+ id: productTag.id,
105459
+ title: productTag.value,
105460
+ to: `/settings/product-tags/${productTag.id}`,
105461
+ value: `productTag:${productTag.id}`
105462
+ })
105463
+ },
105464
+ location: {
105465
+ shortcut: {
105466
+ keys: { Mac: ["G", ",", "L"] },
105467
+ label: (t5) => t5("app.keyboardShortcuts.settings.goToLocations"),
105468
+ type: "settingShortcut",
105469
+ to: "/settings/locations"
105470
+ },
105471
+ transform: (location) => ({
105472
+ id: location.id,
105473
+ title: location.name,
105474
+ to: `/settings/locations/${location.id}`,
105475
+ value: `location:${location.id}`
105476
+ })
105477
+ },
105478
+ shippingProfile: {
105479
+ transform: (shippingProfile) => ({
105480
+ id: shippingProfile.id,
105481
+ title: shippingProfile.name,
105482
+ to: `/settings/locations/shipping-profiles/${shippingProfile.id}`,
105483
+ value: `shippingProfile:${shippingProfile.id}`
105484
+ })
105485
+ },
105486
+ publishableApiKey: {
105487
+ shortcut: {
105488
+ keys: { Mac: ["G", ",", "J"] },
105489
+ label: (t5) => t5("app.keyboardShortcuts.settings.goToPublishableApiKeys"),
105490
+ type: "settingShortcut",
105491
+ to: "/settings/publishable-api-keys"
105492
+ },
105493
+ transform: (apiKey) => ({
105494
+ id: apiKey.id,
105495
+ title: apiKey.title,
105496
+ subtitle: apiKey.redacted,
105497
+ to: `/settings/publishable-api-keys/${apiKey.id}`,
105498
+ value: `publishableApiKey:${apiKey.id}`
105499
+ })
105500
+ },
105501
+ secretApiKey: {
105502
+ shortcut: {
105503
+ keys: { Mac: ["G", ",", "K"] },
105504
+ label: (t5) => t5("app.keyboardShortcuts.settings.goToSecretApiKeys"),
105505
+ type: "settingShortcut",
105506
+ to: "/settings/secret-api-keys"
105507
+ },
105508
+ transform: (apiKey) => ({
105509
+ id: apiKey.id,
105510
+ title: apiKey.title,
105511
+ subtitle: apiKey.redacted,
105512
+ to: `/settings/secret-api-keys/${apiKey.id}`,
105513
+ value: `secretApiKey:${apiKey.id}`
105514
+ })
105515
+ }
105516
+ };
105517
+ }
105518
+ });
105519
+
105520
+ // src/lib/search/search-entities.ts
105521
+ function defineSearchEntity(name, definition) {
105522
+ searchEntities.set(name, definition);
105523
+ customized = true;
105524
+ }
105525
+ function clearSearchEntities() {
105526
+ searchEntities.clear();
105527
+ customized = true;
105528
+ }
105529
+ function isSearchRegistryCustomized() {
105530
+ return customized;
105531
+ }
105532
+ function getSearchEntity(name) {
105533
+ return searchEntities.get(name);
105534
+ }
105535
+ function getSearchEntityNames() {
105536
+ return [...searchEntities.entries()].filter(([, definition]) => !!definition.transform).map(([name]) => name);
105537
+ }
105538
+ function hasSearchEntity(name) {
105539
+ return !!searchEntities.get(name)?.transform;
105540
+ }
105541
+ function resolveSearchEntityGroupLabel(name, t5) {
105542
+ const translate = t5;
105543
+ const definition = searchEntities.get(name);
105544
+ const label = definition?.groupLabel;
105545
+ if (typeof label === "function") {
105546
+ return label(translate);
105547
+ }
105548
+ if (typeof label === "string") {
105549
+ return label;
105550
+ }
105551
+ return translate(`app.search.groups.${name}`, { defaultValue: name });
105552
+ }
105553
+ function getSearchEntityShortcuts() {
105554
+ return [...searchEntities.entries()].filter(([, definition]) => !!definition.shortcut).map(([entity, definition]) => ({
105555
+ entity,
105556
+ shortcut: definition.shortcut
105557
+ }));
105558
+ }
105559
+ function resolveSearchEntityShortcutLabel(name, t5) {
105560
+ const translate = t5;
105561
+ const label = searchEntities.get(name)?.shortcut?.label;
105562
+ if (typeof label === "function") {
105563
+ return label(translate);
105564
+ }
105565
+ if (typeof label === "string") {
105566
+ return label;
105567
+ }
105568
+ return resolveSearchEntityGroupLabel(name, t5);
105569
+ }
105570
+ var searchEntities, customized;
105571
+ var init_search_entities = __esm({
105572
+ "src/lib/search/search-entities.ts"() {
105573
+ "use strict";
105574
+ init_default_search_entities();
105575
+ searchEntities = new Map(
105576
+ Object.entries(DEFAULT_SEARCH_ENTITIES)
105577
+ );
105578
+ customized = false;
105579
+ }
105580
+ });
105581
+
105208
105582
  // src/components/common/skeleton/skeleton.tsx
105209
105583
  var import_ui3, import_jsx_runtime9, Skeleton, TextSkeleton, TableFooterSkeleton, TableSkeleton, SingleColumnPageSkeleton, TwoColumnPageSkeleton;
105210
105584
  var init_skeleton = __esm({
@@ -105436,37 +105810,15 @@ var init_thumbnail2 = __esm({
105436
105810
  });
105437
105811
 
105438
105812
  // src/components/search/constants.ts
105439
- var SEARCH_AREAS, DEFAULT_SEARCH_LIMIT, SEARCH_LIMIT_INCREMENT;
105813
+ function getSearchAreas() {
105814
+ const entities = getSearchEntityNames();
105815
+ return ["all", ...entities, "command", "navigation"];
105816
+ }
105817
+ var DEFAULT_SEARCH_LIMIT, SEARCH_LIMIT_INCREMENT;
105440
105818
  var init_constants2 = __esm({
105441
105819
  "src/components/search/constants.ts"() {
105442
105820
  "use strict";
105443
- SEARCH_AREAS = [
105444
- "all",
105445
- "order",
105446
- "product",
105447
- "productVariant",
105448
- "collection",
105449
- "category",
105450
- "inventory",
105451
- "customer",
105452
- "customerGroup",
105453
- "promotion",
105454
- "campaign",
105455
- "priceList",
105456
- "user",
105457
- "region",
105458
- "taxRegion",
105459
- "returnReason",
105460
- "salesChannel",
105461
- "productType",
105462
- "productTag",
105463
- "location",
105464
- "shippingProfile",
105465
- "publishableApiKey",
105466
- "secretApiKey",
105467
- "command",
105468
- "navigation"
105469
- ];
105821
+ init_search_entities();
105470
105822
  DEFAULT_SEARCH_LIMIT = 3;
105471
105823
  SEARCH_LIMIT_INCREMENT = 20;
105472
105824
  }
@@ -109315,6 +109667,7 @@ var init_hooks = __esm({
109315
109667
  import_react_router_dom = require("react-router-dom");
109316
109668
  init_auth();
109317
109669
  init_query_client();
109670
+ init_search_entities();
109318
109671
  init_keybind_context();
109319
109672
  init_utils2();
109320
109673
  useShortcuts = ({
@@ -109378,96 +109731,17 @@ var init_hooks = __esm({
109378
109731
  });
109379
109732
  };
109380
109733
  const globalShortcuts = [
109381
- // Pages
109382
- {
109383
- keys: {
109384
- Mac: ["G", "O"]
109385
- },
109386
- label: t5("app.keyboardShortcuts.navigation.goToOrders"),
109387
- type: "pageShortcut",
109388
- to: "/orders"
109389
- },
109390
- {
109391
- keys: {
109392
- Mac: ["G", "P"]
109393
- },
109394
- label: t5("app.keyboardShortcuts.navigation.goToProducts"),
109395
- type: "pageShortcut",
109396
- to: "/products"
109397
- },
109398
- {
109399
- keys: {
109400
- Mac: ["G", "C"]
109401
- },
109402
- label: t5("app.keyboardShortcuts.navigation.goToCollections"),
109403
- type: "pageShortcut",
109404
- to: "/collections"
109405
- },
109406
- {
109407
- keys: {
109408
- Mac: ["G", "A"]
109409
- },
109410
- label: t5("app.keyboardShortcuts.navigation.goToCategories"),
109411
- type: "pageShortcut",
109412
- to: "/categories"
109413
- },
109414
- {
109415
- keys: {
109416
- Mac: ["G", "U"]
109417
- },
109418
- label: t5("app.keyboardShortcuts.navigation.goToCustomers"),
109419
- type: "pageShortcut",
109420
- to: "/customers"
109421
- },
109422
- {
109423
- keys: {
109424
- Mac: ["G", "G"]
109425
- },
109426
- label: t5("app.keyboardShortcuts.navigation.goToCustomerGroups"),
109427
- type: "pageShortcut",
109428
- to: "/customer-groups"
109429
- },
109430
- {
109431
- keys: {
109432
- Mac: ["G", "I"]
109433
- },
109434
- label: t5("app.keyboardShortcuts.navigation.goToInventory"),
109435
- type: "pageShortcut",
109436
- to: "/inventory"
109437
- },
109438
- {
109439
- keys: {
109440
- Mac: ["G", "R"]
109441
- },
109442
- label: t5("app.keyboardShortcuts.navigation.goToReservations"),
109443
- type: "pageShortcut",
109444
- to: "/reservations"
109445
- },
109446
- {
109447
- keys: {
109448
- Mac: ["G", "L"]
109449
- },
109450
- label: t5("app.keyboardShortcuts.navigation.goToPriceLists"),
109451
- type: "pageShortcut",
109452
- to: "/price-lists"
109453
- },
109454
- {
109455
- keys: {
109456
- Mac: ["G", "M"]
109457
- },
109458
- label: t5("app.keyboardShortcuts.navigation.goToPromotions"),
109459
- type: "pageShortcut",
109460
- to: "/promotions"
109461
- },
109462
- {
109463
- keys: {
109464
- Mac: ["G", "K"]
109465
- },
109466
- label: t5("app.keyboardShortcuts.navigation.goToCampaigns"),
109467
- type: "pageShortcut",
109468
- to: "/campaigns"
109469
- },
109470
- // Settings
109734
+ // "Jump to" entries come from the search entity registry, so apps and
109735
+ // plugins customize them through their `search-entities.tsx` definitions.
109736
+ ...getSearchEntityShortcuts().map(
109737
+ ({ entity, shortcut }) => ({
109738
+ keys: shortcut.keys,
109739
+ label: resolveSearchEntityShortcutLabel(entity, t5),
109740
+ type: shortcut.type ?? "pageShortcut",
109741
+ to: shortcut.to
109742
+ })
109743
+ ),
109744
+ // The admin shell's own destinations, which belong to no entity.
109471
109745
  {
109472
109746
  keys: {
109473
109747
  Mac: ["G", ","]
@@ -109484,78 +109758,6 @@ var init_hooks = __esm({
109484
109758
  type: "settingShortcut",
109485
109759
  to: "/settings/store"
109486
109760
  },
109487
- {
109488
- keys: {
109489
- Mac: ["G", ",", "U"]
109490
- },
109491
- label: t5("app.keyboardShortcuts.settings.goToUsers"),
109492
- type: "settingShortcut",
109493
- to: "/settings/users"
109494
- },
109495
- {
109496
- keys: {
109497
- Mac: ["G", ",", "R"]
109498
- },
109499
- label: t5("app.keyboardShortcuts.settings.goToRegions"),
109500
- type: "settingShortcut",
109501
- to: "/settings/regions"
109502
- },
109503
- {
109504
- keys: {
109505
- Mac: ["G", ",", "T"]
109506
- },
109507
- label: t5("app.keyboardShortcuts.settings.goToTaxRegions"),
109508
- type: "settingShortcut",
109509
- to: "/settings/tax-regions"
109510
- },
109511
- {
109512
- keys: {
109513
- Mac: ["G", ",", "A"]
109514
- },
109515
- label: t5("app.keyboardShortcuts.settings.goToSalesChannels"),
109516
- type: "settingShortcut",
109517
- to: "/settings/sales-channels"
109518
- },
109519
- {
109520
- keys: {
109521
- Mac: ["G", ",", "P"]
109522
- },
109523
- label: t5("app.keyboardShortcuts.settings.goToProductTypes"),
109524
- type: "settingShortcut",
109525
- to: "/settings/product-types"
109526
- },
109527
- {
109528
- keys: {
109529
- Mac: ["G", ",", "L"]
109530
- },
109531
- label: t5("app.keyboardShortcuts.settings.goToLocations"),
109532
- type: "settingShortcut",
109533
- to: "/settings/locations"
109534
- },
109535
- {
109536
- keys: {
109537
- Mac: ["G", ",", "M"]
109538
- },
109539
- label: t5("app.keyboardShortcuts.settings.goToReturnReasons"),
109540
- type: "settingShortcut",
109541
- to: "/settings/return-reasons"
109542
- },
109543
- {
109544
- keys: {
109545
- Mac: ["G", ",", "J"]
109546
- },
109547
- label: t5("app.keyboardShortcuts.settings.goToPublishableApiKeys"),
109548
- type: "settingShortcut",
109549
- to: "/settings/publishable-api-keys"
109550
- },
109551
- {
109552
- keys: {
109553
- Mac: ["G", ",", "K"]
109554
- },
109555
- label: t5("app.keyboardShortcuts.settings.goToSecretApiKeys"),
109556
- type: "settingShortcut",
109557
- to: "/settings/secret-api-keys"
109558
- },
109559
109761
  {
109560
109762
  keys: {
109561
109763
  Mac: ["G", ",", "W"]
@@ -109572,7 +109774,7 @@ var init_hooks = __esm({
109572
109774
  type: "settingShortcut",
109573
109775
  to: "/settings/profile"
109574
109776
  },
109575
- // Commands
109777
+ // Commands that need app hooks stay built in.
109576
109778
  {
109577
109779
  keys: {
109578
109780
  Mac: ["B", "Y", "E"]
@@ -109588,58 +109790,28 @@ var init_hooks = __esm({
109588
109790
  });
109589
109791
 
109590
109792
  // src/components/search/use-search-results.tsx
109591
- function isDynamicSearchEntity(area) {
109592
- return DYNAMIC_SEARCH_ENTITIES.includes(area);
109593
- }
109594
109793
  function transformSearchResultGroup(group, limit, t5) {
109595
- if (!isDynamicSearchEntity(group.entity)) {
109596
- return void 0;
109597
- }
109598
- const area = group.entity;
109599
- const transform = transformMap[area]?.transform;
109794
+ const transform = getSearchEntity(group.entity)?.transform;
109600
109795
  if (!transform || !Array.isArray(group.data)) {
109601
109796
  return void 0;
109602
109797
  }
109603
109798
  return {
109604
- title: t5(`app.search.groups.${area}`),
109605
- area,
109799
+ title: resolveSearchEntityGroupLabel(group.entity, t5),
109800
+ area: group.entity,
109606
109801
  hasMore: group.count > limit,
109607
109802
  count: group.count,
109608
109803
  items: group.data.map(transform)
109609
109804
  };
109610
109805
  }
109611
- var import_react17, import_react_i18next4, DYNAMIC_SEARCH_ENTITIES, useSearchResults, useStaticSearchResults, useDynamicSearchResults, useDebouncedSearch, transformMap;
109806
+ var import_react17, import_react_i18next4, useSearchResults, useStaticSearchResults, useDynamicSearchResults, useDebouncedSearch;
109612
109807
  var init_use_search_results = __esm({
109613
109808
  "src/components/search/use-search-results.tsx"() {
109614
109809
  "use strict";
109615
109810
  import_react17 = require("react");
109616
109811
  import_react_i18next4 = require("react-i18next");
109617
109812
  init_api();
109813
+ init_search_entities();
109618
109814
  init_hooks();
109619
- DYNAMIC_SEARCH_ENTITIES = [
109620
- "order",
109621
- "product",
109622
- "productVariant",
109623
- "category",
109624
- "collection",
109625
- "customer",
109626
- "customerGroup",
109627
- "inventory",
109628
- "promotion",
109629
- "campaign",
109630
- "priceList",
109631
- "user",
109632
- "region",
109633
- "taxRegion",
109634
- "returnReason",
109635
- "salesChannel",
109636
- "productType",
109637
- "productTag",
109638
- "location",
109639
- "shippingProfile",
109640
- "publishableApiKey",
109641
- "secretApiKey"
109642
- ];
109643
109815
  useSearchResults = ({
109644
109816
  q,
109645
109817
  limit,
@@ -109690,16 +109862,18 @@ var init_use_search_results = __esm({
109690
109862
  useDynamicSearchResults = (currentArea, limit, q) => {
109691
109863
  const { t: t5 } = (0, import_react_i18next4.useTranslation)();
109692
109864
  const debouncedSearch = useDebouncedSearch(q, 300);
109865
+ const registeredEntities = (0, import_react17.useMemo)(() => getSearchEntityNames(), []);
109693
109866
  const entity = (0, import_react17.useMemo)(() => {
109694
109867
  if (currentArea === "all") {
109695
- return void 0;
109868
+ return isSearchRegistryCustomized() && registeredEntities.length ? registeredEntities : void 0;
109696
109869
  }
109697
- if (isDynamicSearchEntity(currentArea)) {
109870
+ if (hasSearchEntity(currentArea)) {
109698
109871
  return [currentArea];
109699
109872
  }
109700
109873
  return void 0;
109701
- }, [currentArea]);
109702
- const isDynamicArea = currentArea === "all" || isDynamicSearchEntity(currentArea);
109874
+ }, [currentArea, registeredEntities]);
109875
+ const isDynamicArea = hasSearchEntity(currentArea) || // "all" with a registry customized down to nothing has nothing to fetch.
109876
+ currentArea === "all" && (!isSearchRegistryCustomized() || registeredEntities.length > 0);
109703
109877
  const { results, isFetching } = useAdminSearch(
109704
109878
  {
109705
109879
  q: debouncedSearch,
@@ -109718,9 +109892,10 @@ var init_use_search_results = __esm({
109718
109892
  (group) => !!group && group.items.length > 0
109719
109893
  );
109720
109894
  }, [q, results, limit, t5]);
109895
+ const isWaitingForDebounce = Boolean(q) && q !== debouncedSearch;
109721
109896
  return {
109722
109897
  dynamicResults,
109723
- isFetching: Boolean(debouncedSearch) && isDynamicArea && isFetching
109898
+ isFetching: isDynamicArea && (isWaitingForDebounce || Boolean(debouncedSearch) && isFetching)
109724
109899
  };
109725
109900
  };
109726
109901
  useDebouncedSearch = (value, delay) => {
@@ -109735,197 +109910,6 @@ var init_use_search_results = __esm({
109735
109910
  }, [value, delay]);
109736
109911
  return debouncedValue;
109737
109912
  };
109738
- transformMap = {
109739
- order: {
109740
- transform: (order) => ({
109741
- id: order.id,
109742
- title: `#${order.display_id}`,
109743
- subtitle: order.email ?? void 0,
109744
- to: `/orders/${order.id}`,
109745
- value: `order:${order.id}`
109746
- })
109747
- },
109748
- product: {
109749
- transform: (product) => ({
109750
- id: product.id,
109751
- title: product.title,
109752
- to: `/products/${product.id}`,
109753
- thumbnail: product.thumbnail ?? void 0,
109754
- value: `product:${product.id}`
109755
- })
109756
- },
109757
- productVariant: {
109758
- transform: (variant) => ({
109759
- id: variant.id,
109760
- title: variant.title,
109761
- subtitle: variant.sku ?? void 0,
109762
- to: `/products/${variant.product_id}/variants/${variant.id}`,
109763
- value: `variant:${variant.id}`
109764
- })
109765
- },
109766
- category: {
109767
- transform: (category) => ({
109768
- id: category.id,
109769
- title: category.name,
109770
- to: `/categories/${category.id}`,
109771
- value: `category:${category.id}`
109772
- })
109773
- },
109774
- inventory: {
109775
- transform: (inventory) => ({
109776
- id: inventory.id,
109777
- title: inventory.title ?? "",
109778
- subtitle: inventory.sku ?? void 0,
109779
- to: `/inventory/${inventory.id}`,
109780
- value: `inventory:${inventory.id}`
109781
- })
109782
- },
109783
- customer: {
109784
- transform: (customer) => {
109785
- const name = [customer.first_name, customer.last_name].filter(Boolean).join(" ");
109786
- return {
109787
- id: customer.id,
109788
- title: name || customer.email,
109789
- subtitle: name ? customer.email : void 0,
109790
- to: `/customers/${customer.id}`,
109791
- value: `customer:${customer.id}`
109792
- };
109793
- }
109794
- },
109795
- customerGroup: {
109796
- transform: (customerGroup) => ({
109797
- id: customerGroup.id,
109798
- title: customerGroup.name,
109799
- to: `/customer-groups/${customerGroup.id}`,
109800
- value: `customerGroup:${customerGroup.id}`
109801
- })
109802
- },
109803
- collection: {
109804
- transform: (collection) => ({
109805
- id: collection.id,
109806
- title: collection.title,
109807
- to: `/collections/${collection.id}`,
109808
- value: `collection:${collection.id}`
109809
- })
109810
- },
109811
- promotion: {
109812
- transform: (promotion) => ({
109813
- id: promotion.id,
109814
- title: promotion.code,
109815
- to: `/promotions/${promotion.id}`,
109816
- value: `promotion:${promotion.id}`
109817
- })
109818
- },
109819
- campaign: {
109820
- transform: (campaign) => ({
109821
- id: campaign.id,
109822
- title: campaign.name,
109823
- to: `/campaigns/${campaign.id}`,
109824
- value: `campaign:${campaign.id}`
109825
- })
109826
- },
109827
- priceList: {
109828
- transform: (priceList) => ({
109829
- id: priceList.id,
109830
- title: priceList.title,
109831
- to: `/price-lists/${priceList.id}`,
109832
- value: `priceList:${priceList.id}`
109833
- })
109834
- },
109835
- user: {
109836
- transform: (user) => ({
109837
- id: user.id,
109838
- title: `${user.first_name} ${user.last_name}`,
109839
- subtitle: user.email,
109840
- to: `/settings/users/${user.id}`,
109841
- value: `user:${user.id}`
109842
- })
109843
- },
109844
- region: {
109845
- transform: (region) => ({
109846
- id: region.id,
109847
- title: region.name,
109848
- to: `/settings/regions/${region.id}`,
109849
- value: `region:${region.id}`
109850
- })
109851
- },
109852
- taxRegion: {
109853
- transform: (taxRegion) => ({
109854
- id: taxRegion.id,
109855
- title: taxRegion.province_code?.toUpperCase() ?? taxRegion.country_code.toUpperCase(),
109856
- subtitle: taxRegion.province_code ? taxRegion.country_code : void 0,
109857
- to: `/settings/tax-regions/${taxRegion.id}`,
109858
- value: `taxRegion:${taxRegion.id}`
109859
- })
109860
- },
109861
- returnReason: {
109862
- transform: (returnReason) => ({
109863
- id: returnReason.id,
109864
- title: returnReason.label,
109865
- subtitle: returnReason.value,
109866
- to: `/settings/return-reasons/${returnReason.id}/edit`,
109867
- value: `returnReason:${returnReason.id}`
109868
- })
109869
- },
109870
- salesChannel: {
109871
- transform: (salesChannel) => ({
109872
- id: salesChannel.id,
109873
- title: salesChannel.name,
109874
- to: `/settings/sales-channels/${salesChannel.id}`,
109875
- value: `salesChannel:${salesChannel.id}`
109876
- })
109877
- },
109878
- productType: {
109879
- transform: (productType) => ({
109880
- id: productType.id,
109881
- title: productType.value,
109882
- to: `/settings/product-types/${productType.id}`,
109883
- value: `productType:${productType.id}`
109884
- })
109885
- },
109886
- productTag: {
109887
- transform: (productTag) => ({
109888
- id: productTag.id,
109889
- title: productTag.value,
109890
- to: `/settings/product-tags/${productTag.id}`,
109891
- value: `productTag:${productTag.id}`
109892
- })
109893
- },
109894
- location: {
109895
- transform: (location) => ({
109896
- id: location.id,
109897
- title: location.name,
109898
- to: `/settings/locations/${location.id}`,
109899
- value: `location:${location.id}`
109900
- })
109901
- },
109902
- shippingProfile: {
109903
- transform: (shippingProfile) => ({
109904
- id: shippingProfile.id,
109905
- title: shippingProfile.name,
109906
- to: `/settings/locations/shipping-profiles/${shippingProfile.id}`,
109907
- value: `shippingProfile:${shippingProfile.id}`
109908
- })
109909
- },
109910
- publishableApiKey: {
109911
- transform: (apiKey) => ({
109912
- id: apiKey.id,
109913
- title: apiKey.title,
109914
- subtitle: apiKey.redacted,
109915
- to: `/settings/publishable-api-keys/${apiKey.id}`,
109916
- value: `publishableApiKey:${apiKey.id}`
109917
- })
109918
- },
109919
- secretApiKey: {
109920
- transform: (apiKey) => ({
109921
- id: apiKey.id,
109922
- title: apiKey.title,
109923
- subtitle: apiKey.redacted,
109924
- to: `/settings/secret-api-keys/${apiKey.id}`,
109925
- value: `secretApiKey:${apiKey.id}`
109926
- })
109927
- }
109928
- };
109929
109913
  }
109930
109914
  });
109931
109915
 
@@ -109980,6 +109964,7 @@ var init_search2 = __esm({
109980
109964
  import_react_router_dom2 = require("react-router-dom");
109981
109965
  import_icons2 = require("@medusajs/icons");
109982
109966
  import_match_sorter = require("match-sorter");
109967
+ init_search_entities();
109983
109968
  init_search_provider2();
109984
109969
  init_skeleton2();
109985
109970
  init_thumbnail2();
@@ -110259,7 +110244,7 @@ var init_search2 = __esm({
110259
110244
  size: "2xsmall",
110260
110245
  className: "hover:bg-ui-bg-base-pressed transition-fg cursor-pointer",
110261
110246
  children: [
110262
- t5(`app.search.groups.${area}`),
110247
+ resolveSearchEntityGroupLabel(area, t5),
110263
110248
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_icons2.TriangleDownMini, { className: "text-ui-fg-muted" })
110264
110249
  ]
110265
110250
  }
@@ -110278,11 +110263,11 @@ var init_search2 = __esm({
110278
110263
  {
110279
110264
  value: area,
110280
110265
  onValueChange: (v) => setArea(v),
110281
- children: SEARCH_AREAS.map((area2) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_react19.Fragment, { children: [
110282
- area2 === "command" && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_ui5.DropdownMenu.Separator, {}),
110283
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_ui5.DropdownMenu.RadioItem, { value: area2, children: t5(`app.search.groups.${area2}`) }),
110284
- area2 === "all" && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_ui5.DropdownMenu.Separator, {})
110285
- ] }, area2))
110266
+ children: getSearchAreas().map((searchArea) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_react19.Fragment, { children: [
110267
+ searchArea === "command" && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_ui5.DropdownMenu.Separator, {}),
110268
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_ui5.DropdownMenu.RadioItem, { value: searchArea, children: resolveSearchEntityGroupLabel(searchArea, t5) }),
110269
+ searchArea === "all" && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_ui5.DropdownMenu.Separator, {})
110270
+ ] }, searchArea))
110286
110271
  }
110287
110272
  )
110288
110273
  }
@@ -221575,8 +221560,10 @@ var init_dashboard_app2 = __esm({
221575
221560
  // src/app.tsx
221576
221561
  var app_exports = {};
221577
221562
  __export(app_exports, {
221563
+ clearSearchEntities: () => clearSearchEntities,
221578
221564
  default: () => app_default,
221579
- defineCellRenderer: () => defineCellRenderer
221565
+ defineCellRenderer: () => defineCellRenderer,
221566
+ defineSearchEntity: () => defineSearchEntity
221580
221567
  });
221581
221568
  module.exports = __toCommonJS(app_exports);
221582
221569
  init_dashboard_app2();
@@ -221588,7 +221575,9 @@ var import_menu_items = __toESM(require("virtual:medusa/menu-items"));
221588
221575
  var import_routes = __toESM(require("virtual:medusa/routes"));
221589
221576
  var import_widgets = __toESM(require("virtual:medusa/widgets"));
221590
221577
  var import_cell_renderers9 = require("virtual:medusa/cell-renderers");
221578
+ var import_search_entities5 = require("virtual:medusa/search-entities");
221591
221579
  init_cell_renderers();
221580
+ init_search_entities();
221592
221581
  var import_jsx_runtime873 = require("react/jsx-runtime");
221593
221582
  var localPlugin = {
221594
221583
  widgetModule: import_widgets.default,
@@ -221608,5 +221597,7 @@ function App({ plugins = [] }) {
221608
221597
  var app_default = App;
221609
221598
  // Annotate the CommonJS export names for ESM import in node:
221610
221599
  0 && (module.exports = {
221611
- defineCellRenderer
221600
+ clearSearchEntities,
221601
+ defineCellRenderer,
221602
+ defineSearchEntity
221612
221603
  });