@01.software/sdk 0.49.0 → 0.51.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.
Files changed (74) hide show
  1. package/CHANGELOG.md +130 -1
  2. package/MIGRATION.md +56 -0
  3. package/README.md +215 -45
  4. package/dist/client.cjs +188 -137
  5. package/dist/client.cjs.map +1 -1
  6. package/dist/client.d.cts +6 -6
  7. package/dist/client.d.ts +6 -6
  8. package/dist/client.js +188 -137
  9. package/dist/client.js.map +1 -1
  10. package/dist/{collection-client-XfGLPuTf.d.cts → collection-client-CWAeuzV4.d.cts} +6 -4
  11. package/dist/{collection-client-DnDt6EQz.d.ts → collection-client-hYvVfHIm.d.ts} +6 -4
  12. package/dist/{const-DCNV5Kq7.d.ts → const-D8LixhAJ.d.cts} +5 -5
  13. package/dist/{const-CBba4lDo.d.cts → const-JD8obaKg.d.ts} +5 -5
  14. package/dist/embedded-admin/server.cjs +306 -0
  15. package/dist/embedded-admin/server.cjs.map +1 -0
  16. package/dist/embedded-admin/server.d.cts +33 -0
  17. package/dist/embedded-admin/server.d.ts +33 -0
  18. package/dist/embedded-admin/server.js +288 -0
  19. package/dist/embedded-admin/server.js.map +1 -0
  20. package/dist/embedded-admin.cjs +400 -0
  21. package/dist/embedded-admin.cjs.map +1 -0
  22. package/dist/embedded-admin.d.cts +61 -0
  23. package/dist/embedded-admin.d.ts +61 -0
  24. package/dist/embedded-admin.js +377 -0
  25. package/dist/embedded-admin.js.map +1 -0
  26. package/dist/errors.cjs +1 -0
  27. package/dist/errors.cjs.map +1 -1
  28. package/dist/errors.d.cts +3 -3
  29. package/dist/errors.d.ts +3 -3
  30. package/dist/errors.js +1 -0
  31. package/dist/errors.js.map +1 -1
  32. package/dist/{index-CbKyoEzy.d.cts → index-B0Hjh3Ey.d.ts} +72 -10
  33. package/dist/{index-DUuIqUS8.d.ts → index-Bu0kCc6o.d.cts} +72 -10
  34. package/dist/index.cjs +320 -383
  35. package/dist/index.cjs.map +1 -1
  36. package/dist/index.d.cts +8 -66
  37. package/dist/index.d.ts +8 -66
  38. package/dist/index.js +320 -383
  39. package/dist/index.js.map +1 -1
  40. package/dist/{payload-types-MKbx5MuJ.d.cts → payload-types-BOsckg8B.d.cts} +263 -54
  41. package/dist/{payload-types-MKbx5MuJ.d.ts → payload-types-BOsckg8B.d.ts} +263 -54
  42. package/dist/query.cjs +94 -70
  43. package/dist/query.cjs.map +1 -1
  44. package/dist/query.d.cts +5 -5
  45. package/dist/query.d.ts +5 -5
  46. package/dist/query.js +94 -70
  47. package/dist/query.js.map +1 -1
  48. package/dist/realtime.d.cts +2 -2
  49. package/dist/realtime.d.ts +2 -2
  50. package/dist/server.cjs +404 -162
  51. package/dist/server.cjs.map +1 -1
  52. package/dist/server.d.cts +7 -7
  53. package/dist/server.d.ts +7 -7
  54. package/dist/server.js +404 -162
  55. package/dist/server.js.map +1 -1
  56. package/dist/storefront-cache.cjs +1 -0
  57. package/dist/storefront-cache.cjs.map +1 -1
  58. package/dist/storefront-cache.js +1 -0
  59. package/dist/storefront-cache.js.map +1 -1
  60. package/dist/{types-L_nh-ED7.d.ts → types-5ZlcAFuU.d.ts} +2 -2
  61. package/dist/{types-BKr_2avj.d.cts → types-B14sEt1z.d.cts} +2 -2
  62. package/dist/{types-1UeOk1Uy.d.cts → types-Bj8j7VHU.d.ts} +79 -23
  63. package/dist/{types-Du4s5anw.d.ts → types-CM5qiR2k.d.cts} +79 -23
  64. package/dist/ui/form.d.cts +1 -1
  65. package/dist/ui/form.d.ts +1 -1
  66. package/dist/ui/video.d.cts +1 -1
  67. package/dist/ui/video.d.ts +1 -1
  68. package/dist/webhook.cjs +124 -80
  69. package/dist/webhook.cjs.map +1 -1
  70. package/dist/webhook.d.cts +21 -5
  71. package/dist/webhook.d.ts +21 -5
  72. package/dist/webhook.js +124 -80
  73. package/dist/webhook.js.map +1 -1
  74. package/package.json +23 -2
package/dist/query.d.cts CHANGED
@@ -1,10 +1,10 @@
1
1
  import * as _tanstack_react_query from '@tanstack/react-query';
2
2
  import { QueryClient, UseQueryResult, UseSuspenseQueryResult, InfiniteData, UseInfiniteQueryResult, UseSuspenseInfiniteQueryResult } from '@tanstack/react-query';
3
- import { i as ApiQueryOptions, P as PayloadFindResponse, bX as PublicReadQueryOptions, L as PayloadMutationResponse, bY as CustomerAuth, bZ as CustomerProfile, b_ as CustomerAuthResponse, b$ as CustomerLoginData, c0 as CustomerRegisterResponse, c1 as CustomerRegisterData, c2 as CustomerRefreshResponse, c3 as UpdateProfileData, c4 as ProductListingPageParams, c5 as ProductListingPageBaseParams, c6 as ProductDetailParams, c7 as ProductDetailCatalogResult, c8 as ProductListingPageCatalogParams, c9 as ProductListingPageResult, ca as ProductListingGroupsCatalogItem, cb as ProductListingPageFullParams, cc as ProductListingGroupsItem, al as RootClient, bD as RootServerClient } from './types-1UeOk1Uy.cjs';
4
- import './payload-types-MKbx5MuJ.cjs';
5
- import { S as ServerCollection, P as PublicCollection } from './const-CBba4lDo.cjs';
6
- import { C as CollectionClient } from './collection-client-XfGLPuTf.cjs';
7
- import { C as CollectionType } from './types-BKr_2avj.cjs';
3
+ import { i as ApiQueryOptions, P as PayloadFindResponse, c4 as PublicReadQueryOptions, L as PayloadMutationResponse, c5 as CustomerAuth, c6 as CustomerProfile, c7 as CustomerAuthResponse, c8 as CustomerLoginData, c9 as CustomerRegisterResponse, ca as CustomerRegisterData, cb as CustomerRefreshResponse, cc as UpdateProfileData, cd as ProductListingPageParams, ce as ProductListingPageBaseParams, cf as ProductDetailParams, cg as ProductDetailCatalogResult, ch as ProductListingPageCatalogParams, ci as ProductListingPageResult, cj as ProductListingGroupsCatalogItem, ck as ProductListingPageFullParams, cl as ProductListingGroupsItem, al as RootClient, bL as RootServerClient } from './types-CM5qiR2k.cjs';
4
+ import './payload-types-BOsckg8B.cjs';
5
+ import { S as ServerCollection, P as PublicCollection } from './const-D8LixhAJ.cjs';
6
+ import { C as CollectionClient } from './collection-client-CWAeuzV4.cjs';
7
+ import { C as CollectionType } from './types-B14sEt1z.cjs';
8
8
  import { SDKError } from './errors.cjs';
9
9
  export { a as RealtimeConnection, R as RealtimeEvent, b as RealtimeListener } from './realtime-D7HtUpqt.cjs';
10
10
  import './metadata.cjs';
package/dist/query.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import * as _tanstack_react_query from '@tanstack/react-query';
2
2
  import { QueryClient, UseQueryResult, UseSuspenseQueryResult, InfiniteData, UseInfiniteQueryResult, UseSuspenseInfiniteQueryResult } from '@tanstack/react-query';
3
- import { i as ApiQueryOptions, P as PayloadFindResponse, bX as PublicReadQueryOptions, L as PayloadMutationResponse, bY as CustomerAuth, bZ as CustomerProfile, b_ as CustomerAuthResponse, b$ as CustomerLoginData, c0 as CustomerRegisterResponse, c1 as CustomerRegisterData, c2 as CustomerRefreshResponse, c3 as UpdateProfileData, c4 as ProductListingPageParams, c5 as ProductListingPageBaseParams, c6 as ProductDetailParams, c7 as ProductDetailCatalogResult, c8 as ProductListingPageCatalogParams, c9 as ProductListingPageResult, ca as ProductListingGroupsCatalogItem, cb as ProductListingPageFullParams, cc as ProductListingGroupsItem, al as RootClient, bD as RootServerClient } from './types-Du4s5anw.js';
4
- import './payload-types-MKbx5MuJ.js';
5
- import { S as ServerCollection, P as PublicCollection } from './const-DCNV5Kq7.js';
6
- import { C as CollectionClient } from './collection-client-DnDt6EQz.js';
7
- import { C as CollectionType } from './types-L_nh-ED7.js';
3
+ import { i as ApiQueryOptions, P as PayloadFindResponse, c4 as PublicReadQueryOptions, L as PayloadMutationResponse, c5 as CustomerAuth, c6 as CustomerProfile, c7 as CustomerAuthResponse, c8 as CustomerLoginData, c9 as CustomerRegisterResponse, ca as CustomerRegisterData, cb as CustomerRefreshResponse, cc as UpdateProfileData, cd as ProductListingPageParams, ce as ProductListingPageBaseParams, cf as ProductDetailParams, cg as ProductDetailCatalogResult, ch as ProductListingPageCatalogParams, ci as ProductListingPageResult, cj as ProductListingGroupsCatalogItem, ck as ProductListingPageFullParams, cl as ProductListingGroupsItem, al as RootClient, bL as RootServerClient } from './types-Bj8j7VHU.js';
4
+ import './payload-types-BOsckg8B.js';
5
+ import { S as ServerCollection, P as PublicCollection } from './const-JD8obaKg.js';
6
+ import { C as CollectionClient } from './collection-client-hYvVfHIm.js';
7
+ import { C as CollectionType } from './types-5ZlcAFuU.js';
8
8
  import { SDKError } from './errors.js';
9
9
  export { a as RealtimeConnection, R as RealtimeEvent, b as RealtimeListener } from './realtime-D7HtUpqt.js';
10
10
  import './metadata.js';
package/dist/query.js CHANGED
@@ -570,6 +570,7 @@ var COMMERCE_ERROR_CODES = [
570
570
  "payment_session_not_cancelable",
571
571
  "payment_session_conflict",
572
572
  "provider_identity_mismatch",
573
+ "managed_refund_attestation_forbidden",
573
574
  "payment_method_unavailable",
574
575
  "provider_unavailable",
575
576
  "lock_timeout",
@@ -811,6 +812,10 @@ var operation = (collection, method, path, errorFamily) => Object.freeze({
811
812
  ...errorFamily && { errorFamily }
812
813
  });
813
814
  var strictCommerceOperation = (collection, method, path) => operation(collection, method, path, "commerce");
815
+ var selectiveCommerceOperation = (collection, method, path, typedCommerceErrorReasons) => Object.freeze({
816
+ ...operation(collection, method, path),
817
+ typedCommerceErrorReasons: Object.freeze([...typedCommerceErrorReasons])
818
+ });
814
819
  var COMMERCE_ENDPOINT_OPERATIONS = {
815
820
  products: {
816
821
  detail: operation("products", "get", "/detail"),
@@ -842,7 +847,12 @@ var COMMERCE_ENDPOINT_OPERATIONS = {
842
847
  confirmPayment: operation("orders", "post", "/confirm-payment"),
843
848
  byPayment: operation("orders", "get", "/by-payment"),
844
849
  cancel: operation("orders", "post", "/cancel"),
845
- resolveCancelRefund: operation("orders", "post", "/resolve-cancel-refund"),
850
+ resolveCancelRefund: selectiveCommerceOperation(
851
+ "orders",
852
+ "post",
853
+ "/resolve-cancel-refund",
854
+ ["managed_refund_attestation_forbidden"]
855
+ ),
846
856
  checkout: strictCommerceOperation("orders", "post", "/checkout"),
847
857
  createFulfillment: operation("orders", "post", "/create-fulfillment"),
848
858
  updateFulfillment: operation("orders", "post", "/update-fulfillment")
@@ -913,6 +923,16 @@ var COMMERCE_ENDPOINT_OPERATIONS = {
913
923
  "payment-sessions",
914
924
  "post",
915
925
  "/server/confirm"
926
+ ),
927
+ findPortOne: strictCommerceOperation(
928
+ "payment-sessions",
929
+ "post",
930
+ "/server/portone/find"
931
+ ),
932
+ reconcilePortOne: strictCommerceOperation(
933
+ "payment-sessions",
934
+ "post",
935
+ "/server/portone/reconcile"
916
936
  )
917
937
  },
918
938
  custom: {
@@ -932,12 +952,26 @@ var COMMERCE_ENDPOINT_OPERATIONS = {
932
952
  validate: operation("discounts", "post", "/validate")
933
953
  }
934
954
  };
955
+ var portOneStandardActionCapabilityOperations = /* @__PURE__ */ new Set([
956
+ COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.create,
957
+ COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.retrieve,
958
+ COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.create,
959
+ COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.retrieve
960
+ ]);
935
961
  var MEMBERSHIP_ENDPOINT_OPERATIONS = {
936
962
  subscribe: operation(null, "post", "/memberships/subscribe"),
937
963
  cancel: operation(null, "post", "/memberships/:id/cancel"),
938
964
  me: operation(null, "get", "/memberships/me")
939
965
  };
966
+ var EMBEDDED_ADMIN_ENDPOINT_OPERATIONS = {
967
+ show: operation("tenants", "get", "/embedded-admin-app"),
968
+ configure: operation("tenants", "patch", "/embedded-admin-app"),
969
+ disable: operation("tenants", "delete", "/embedded-admin-app")
970
+ };
940
971
  var EVENTS_ENDPOINT_OPERATIONS = {
972
+ events: {
973
+ convertSchedule: operation("events", "post", "/:id/schedule")
974
+ },
941
975
  occurrences: {
942
976
  range: operation("event-occurrences", "get", "/range"),
943
977
  admissionAvailability: operation(
@@ -975,40 +1009,48 @@ function resolveOperationPath(descriptor, options) {
975
1009
  }
976
1010
 
977
1011
  // src/core/api/endpoints.ts
978
- var endpoint = (method, path) => ({ method, path });
979
1012
  var sharedEndpoint = (descriptor) => descriptor;
980
- function resolveOperationPath2(descriptor, options) {
981
- if ("collection" in descriptor) {
982
- return resolveOperationPath(descriptor, options);
983
- }
984
- const query = options?.query?.toString().replace(/^\?/, "");
985
- return query ? `${descriptor.path}?${query}` : descriptor.path;
986
- }
987
1013
  var COMMERCE_ENDPOINTS = {
988
1014
  products: {
989
- detail: endpoint("GET", "/api/products/detail"),
990
- detailCatalog: endpoint("GET", "/api/products/detail/catalog"),
991
- listingGroups: endpoint("GET", "/api/products/listing-groups"),
992
- listingGroupsCatalog: endpoint(
993
- "GET",
994
- "/api/products/listing-groups/catalog"
1015
+ detail: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.products.detail),
1016
+ detailCatalog: sharedEndpoint(
1017
+ COMMERCE_ENDPOINT_OPERATIONS.products.detailCatalog
1018
+ ),
1019
+ listingGroups: sharedEndpoint(
1020
+ COMMERCE_ENDPOINT_OPERATIONS.products.listingGroups
1021
+ ),
1022
+ listingGroupsCatalog: sharedEndpoint(
1023
+ COMMERCE_ENDPOINT_OPERATIONS.products.listingGroupsCatalog
995
1024
  ),
996
- listingGroupsQuery: endpoint("GET", "/api/products/listing-groups/query"),
997
- listingGroupsQueryCatalog: endpoint(
998
- "GET",
999
- "/api/products/listing-groups/query/catalog"
1025
+ // The manifest keeps the GET read and the POST body-query apart; this
1026
+ // semantic name has always resolved to the GET one.
1027
+ listingGroupsQuery: sharedEndpoint(
1028
+ COMMERCE_ENDPOINT_OPERATIONS.products.listingGroupsQueryGet
1000
1029
  ),
1001
- stockCheck: endpoint("POST", "/api/products/stock-check"),
1002
- stockSnapshot: endpoint("GET", "/api/products/stock"),
1003
- upsert: endpoint("POST", "/api/products/upsert")
1030
+ listingGroupsQueryCatalog: sharedEndpoint(
1031
+ COMMERCE_ENDPOINT_OPERATIONS.products.listingGroupsQueryCatalog
1032
+ ),
1033
+ stockCheck: sharedEndpoint(
1034
+ COMMERCE_ENDPOINT_OPERATIONS.products.stockCheck
1035
+ ),
1036
+ stockSnapshot: sharedEndpoint(
1037
+ COMMERCE_ENDPOINT_OPERATIONS.products.stockSnapshot
1038
+ ),
1039
+ upsert: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.products.upsert)
1004
1040
  },
1005
1041
  orders: {
1006
- update: endpoint("POST", "/api/orders/update"),
1007
- byPayment: endpoint("GET", "/api/orders/by-payment"),
1008
- cancel: endpoint("POST", "/api/orders/cancel"),
1009
- resolveCancelRefund: endpoint("POST", "/api/orders/resolve-cancel-refund"),
1010
- createFulfillment: endpoint("POST", "/api/orders/create-fulfillment"),
1011
- updateFulfillment: endpoint("POST", "/api/orders/update-fulfillment")
1042
+ update: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.orders.update),
1043
+ byPayment: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.orders.byPayment),
1044
+ cancel: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.orders.cancel),
1045
+ resolveCancelRefund: sharedEndpoint(
1046
+ COMMERCE_ENDPOINT_OPERATIONS.orders.resolveCancelRefund
1047
+ ),
1048
+ createFulfillment: sharedEndpoint(
1049
+ COMMERCE_ENDPOINT_OPERATIONS.orders.createFulfillment
1050
+ ),
1051
+ updateFulfillment: sharedEndpoint(
1052
+ COMMERCE_ENDPOINT_OPERATIONS.orders.updateFulfillment
1053
+ )
1012
1054
  },
1013
1055
  checkouts: {
1014
1056
  create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.orders.checkout),
@@ -1020,18 +1062,21 @@ var COMMERCE_ENDPOINTS = {
1020
1062
  }
1021
1063
  },
1022
1064
  returns: {
1023
- create: endpoint("POST", "/api/returns/create"),
1024
- update: endpoint("POST", "/api/returns/update"),
1025
- returnRefund: endpoint("POST", "/api/returns/return-refund")
1065
+ create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.returns.create),
1066
+ update: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.returns.update),
1067
+ returnRefund: sharedEndpoint(
1068
+ COMMERCE_ENDPOINT_OPERATIONS.returns.returnRefund
1069
+ )
1026
1070
  },
1027
1071
  fulfillmentOrders: {
1028
- prepare: endpoint(
1029
- "POST",
1030
- "/api/fulfillment-orders/prepare-fulfillment-order"
1072
+ prepare: sharedEndpoint(
1073
+ COMMERCE_ENDPOINT_OPERATIONS.fulfillmentOrders.prepare
1031
1074
  )
1032
1075
  },
1033
1076
  fulfillments: {
1034
- bulkImport: endpoint("POST", "/api/fulfillments/bulk-import")
1077
+ bulkImport: sharedEndpoint(
1078
+ COMMERCE_ENDPOINT_OPERATIONS.fulfillments.bulkImport
1079
+ )
1035
1080
  },
1036
1081
  carts: {
1037
1082
  create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.create),
@@ -1096,57 +1141,36 @@ var COMMERCE_ENDPOINTS = {
1096
1141
  ),
1097
1142
  confirm: sharedEndpoint(
1098
1143
  COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.confirm
1144
+ ),
1145
+ findPortOne: sharedEndpoint(
1146
+ COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.findPortOne
1147
+ ),
1148
+ reconcilePortOne: sharedEndpoint(
1149
+ COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.reconcilePortOne
1099
1150
  )
1100
1151
  }
1101
1152
  },
1102
1153
  shippingPolicies: {
1103
- calculate: endpoint("POST", "/api/shipping-policies/calculate")
1154
+ calculate: sharedEndpoint(
1155
+ COMMERCE_ENDPOINT_OPERATIONS.shippingPolicies.calculate
1156
+ )
1104
1157
  }
1105
1158
  };
1106
- function isCommerceEndpointDescriptor(value) {
1107
- if (!value || typeof value !== "object") return false;
1108
- const candidate = value;
1109
- return typeof candidate.method === "string" && typeof candidate.path === "string";
1110
- }
1111
- function flattenEndpointPaths(value) {
1112
- if (isCommerceEndpointDescriptor(value)) return [resolveOperationPath2(value)];
1113
- if (!value || typeof value !== "object") return [];
1114
- return Object.values(value).flatMap((entry) => flattenEndpointPaths(entry));
1115
- }
1116
- function flattenEndpointDescriptors(value) {
1117
- if (isCommerceEndpointDescriptor(value)) return [value];
1118
- if (!value || typeof value !== "object") return [];
1119
- return Object.values(value).flatMap(
1120
- (entry) => flattenEndpointDescriptors(entry)
1121
- );
1122
- }
1123
- var COMMERCE_ENDPOINT_PATHS = flattenEndpointPaths(COMMERCE_ENDPOINTS);
1124
- var COMMERCE_ENDPOINT_DESCRIPTORS = flattenEndpointDescriptors(COMMERCE_ENDPOINTS);
1125
- var MEMBERSHIP_ENDPOINTS = {
1126
- subscribe: "/api/memberships/subscribe",
1127
- cancel: (id) => `/api/memberships/${id}/cancel`,
1128
- me: "/api/memberships/me"
1129
- };
1130
- var MEMBERSHIP_ENDPOINT_PATHS = [
1131
- MEMBERSHIP_ENDPOINTS.subscribe,
1132
- MEMBERSHIP_ENDPOINTS.cancel(":id"),
1133
- MEMBERSHIP_ENDPOINTS.me
1134
- ];
1135
1159
 
1136
1160
  // src/core/query/query-hooks.ts
1137
1161
  function normalizeMarket(market) {
1138
1162
  const normalized = market?.trim();
1139
1163
  return normalized || void 0;
1140
1164
  }
1141
- function requestCommerceFindEndpoint(collectionClient, endpoint2, options) {
1142
- const path = resolveOperationPath2(endpoint2, { query: options?.query });
1143
- if (endpoint2.method === "get") {
1165
+ function requestCommerceFindEndpoint(collectionClient, endpoint, options) {
1166
+ const path = resolveOperationPath(endpoint, { query: options?.query });
1167
+ if (endpoint.method === "get") {
1144
1168
  return collectionClient.requestFindEndpointGet(path);
1145
1169
  }
1146
- if (endpoint2.method === "post") {
1170
+ if (endpoint.method === "post") {
1147
1171
  return collectionClient.requestFindEndpoint(path, options?.data);
1148
1172
  }
1149
- throw new TypeError(`Unsupported find endpoint method: ${endpoint2.method}`);
1173
+ throw new TypeError(`Unsupported find endpoint method: ${endpoint.method}`);
1150
1174
  }
1151
1175
  function withDefaultMarket(params, market) {
1152
1176
  const defaultMarket = normalizeMarket(market);