@replohq/sdk 0.1.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 (280) hide show
  1. package/LICENSE +11 -0
  2. package/_vendor/replo-utils/lib/crypto.d.ts +30 -0
  3. package/_vendor/replo-utils/lib/errors.d.ts +83 -0
  4. package/_vendor/replo-utils/lib/json.d.ts +6 -0
  5. package/_vendor/replo-utils/lib/json.mjs +43 -0
  6. package/_vendor/replo-utils/lib/misc.d.ts +145 -0
  7. package/_vendor/replo-utils/lib/object.d.ts +31 -0
  8. package/_vendor/schemas/errors.d.ts +459 -0
  9. package/_vendor/schemas/generated/consent.d.ts +55 -0
  10. package/_vendor/schemas/generated/errors.d.ts +61 -0
  11. package/_vendor/schemas/loaderKeys.d.ts +1 -0
  12. package/_vendor/schemas/loaderKeys.mjs +27 -0
  13. package/_vendor/schemas/money.d.ts +60 -0
  14. package/_vendor/schemas/money.mjs +2051 -0
  15. package/analytics/analytics-provider.d.ts +16 -0
  16. package/analytics/analytics-provider.js +113 -0
  17. package/analytics/analytics-provider.js.map +7 -0
  18. package/analytics/analytics-sink.d.ts +26 -0
  19. package/analytics/analytics-sink.js +1 -0
  20. package/analytics/analytics-sink.js.map +7 -0
  21. package/analytics/get-analytics-sinks.d.ts +27 -0
  22. package/analytics/get-analytics-sinks.js +52 -0
  23. package/analytics/get-analytics-sinks.js.map +7 -0
  24. package/analytics/hooks/use-product-viewed-analytics.d.ts +23 -0
  25. package/analytics/hooks/use-product-viewed-analytics.js +34 -0
  26. package/analytics/hooks/use-product-viewed-analytics.js.map +7 -0
  27. package/analytics/replo-first-party-pixel.d.ts +12 -0
  28. package/analytics/replo-first-party-pixel.js +31 -0
  29. package/analytics/replo-first-party-pixel.js.map +7 -0
  30. package/analytics/replo-pixel-script.d.ts +13 -0
  31. package/analytics/replo-pixel-script.js +30 -0
  32. package/analytics/replo-pixel-script.js.map +7 -0
  33. package/analytics/sinks/ga4-sink.d.ts +15 -0
  34. package/analytics/sinks/ga4-sink.js +60 -0
  35. package/analytics/sinks/ga4-sink.js.map +7 -0
  36. package/analytics/sinks/meta-sink.d.ts +14 -0
  37. package/analytics/sinks/meta-sink.js +56 -0
  38. package/analytics/sinks/meta-sink.js.map +7 -0
  39. package/analytics/sinks/pinterest-sink.d.ts +14 -0
  40. package/analytics/sinks/pinterest-sink.js +76 -0
  41. package/analytics/sinks/pinterest-sink.js.map +7 -0
  42. package/analytics/sinks/reddit-sink.d.ts +14 -0
  43. package/analytics/sinks/reddit-sink.js +80 -0
  44. package/analytics/sinks/reddit-sink.js.map +7 -0
  45. package/analytics/sinks/replo-sink.d.ts +14 -0
  46. package/analytics/sinks/replo-sink.js +57 -0
  47. package/analytics/sinks/replo-sink.js.map +7 -0
  48. package/analytics/sinks/snapchat-sink.d.ts +14 -0
  49. package/analytics/sinks/snapchat-sink.js +67 -0
  50. package/analytics/sinks/snapchat-sink.js.map +7 -0
  51. package/analytics/sinks/tiktok-sink.d.ts +14 -0
  52. package/analytics/sinks/tiktok-sink.js +79 -0
  53. package/analytics/sinks/tiktok-sink.js.map +7 -0
  54. package/analytics/sinks/window-sink.d.ts +18 -0
  55. package/analytics/sinks/window-sink.js +46 -0
  56. package/analytics/sinks/window-sink.js.map +7 -0
  57. package/analytics/utils/analytics-utils.d.ts +7 -0
  58. package/analytics/utils/analytics-utils.js +130 -0
  59. package/analytics/utils/analytics-utils.js.map +7 -0
  60. package/analytics/utils/navigation-tracker.d.ts +16 -0
  61. package/analytics/utils/navigation-tracker.js +44 -0
  62. package/analytics/utils/navigation-tracker.js.map +7 -0
  63. package/analytics/utils/shopify-funnel-gate.d.ts +8 -0
  64. package/analytics/utils/shopify-funnel-gate.js +22 -0
  65. package/analytics/utils/shopify-funnel-gate.js.map +7 -0
  66. package/cart/buy-now-action.d.ts +21 -0
  67. package/cart/buy-now-action.js +104 -0
  68. package/cart/buy-now-action.js.map +7 -0
  69. package/cart/cart-actions.d.ts +63 -0
  70. package/cart/cart-actions.js +90 -0
  71. package/cart/cart-actions.js.map +7 -0
  72. package/cart/cart-loader.d.ts +9 -0
  73. package/cart/cart-loader.js +11 -0
  74. package/cart/cart-loader.js.map +7 -0
  75. package/cart/cart-provider.d.ts +85 -0
  76. package/cart/cart-provider.js +372 -0
  77. package/cart/cart-provider.js.map +7 -0
  78. package/cart/cart-schema.d.ts +74 -0
  79. package/cart/cart-schema.js +69 -0
  80. package/cart/cart-schema.js.map +7 -0
  81. package/cart/cart-types.d.ts +132 -0
  82. package/cart/cart-types.js +8 -0
  83. package/cart/cart-types.js.map +7 -0
  84. package/cart/gateways/cart-constants.d.ts +1 -0
  85. package/cart/gateways/cart-constants.js +5 -0
  86. package/cart/gateways/cart-constants.js.map +7 -0
  87. package/cart/gateways/cart-gateway.d.ts +10 -0
  88. package/cart/gateways/cart-gateway.js +19 -0
  89. package/cart/gateways/cart-gateway.js.map +7 -0
  90. package/cart/gateways/cookie-cart-gateway.d.ts +28 -0
  91. package/cart/gateways/cookie-cart-gateway.js +109 -0
  92. package/cart/gateways/cookie-cart-gateway.js.map +7 -0
  93. package/cart/gateways/default-cart-gateway.d.ts +19 -0
  94. package/cart/gateways/default-cart-gateway.js +30 -0
  95. package/cart/gateways/default-cart-gateway.js.map +7 -0
  96. package/cart/gateways/resolver-cart-gateway.d.ts +2 -0
  97. package/cart/gateways/resolver-cart-gateway.js +109 -0
  98. package/cart/gateways/resolver-cart-gateway.js.map +7 -0
  99. package/cart/gateways/stripe-cart-gateway.d.ts +19 -0
  100. package/cart/gateways/stripe-cart-gateway.js +28 -0
  101. package/cart/gateways/stripe-cart-gateway.js.map +7 -0
  102. package/cart/hooks/use-add-to-cart.d.ts +63 -0
  103. package/cart/hooks/use-add-to-cart.js +124 -0
  104. package/cart/hooks/use-add-to-cart.js.map +7 -0
  105. package/cart/hooks/use-buy-now.d.ts +49 -0
  106. package/cart/hooks/use-buy-now.js +62 -0
  107. package/cart/hooks/use-buy-now.js.map +7 -0
  108. package/cart/utils/cart-utils.d.ts +43 -0
  109. package/cart/utils/cart-utils.js +46 -0
  110. package/cart/utils/cart-utils.js.map +7 -0
  111. package/cart/utils/cookie-cart-persistence.d.ts +55 -0
  112. package/cart/utils/cookie-cart-persistence.js +166 -0
  113. package/cart/utils/cookie-cart-persistence.js.map +7 -0
  114. package/cart/utils/variant-to-cart-line.d.ts +74 -0
  115. package/cart/utils/variant-to-cart-line.js +162 -0
  116. package/cart/utils/variant-to-cart-line.js.map +7 -0
  117. package/chunk-UJCSKKID.mjs +27 -0
  118. package/consent/consent-action.d.ts +9 -0
  119. package/consent/consent-action.js +25 -0
  120. package/consent/consent-action.js.map +7 -0
  121. package/consent/consent-actions.d.ts +28 -0
  122. package/consent/consent-actions.js +36 -0
  123. package/consent/consent-actions.js.map +7 -0
  124. package/consent/consent-store.d.ts +69 -0
  125. package/consent/consent-store.js +194 -0
  126. package/consent/consent-store.js.map +7 -0
  127. package/consent/cookie.d.ts +36 -0
  128. package/consent/cookie.js +82 -0
  129. package/consent/cookie.js.map +7 -0
  130. package/consent/replo-scripts.d.ts +23 -0
  131. package/consent/replo-scripts.js +102 -0
  132. package/consent/replo-scripts.js.map +7 -0
  133. package/consent/script-registration-store.d.ts +25 -0
  134. package/consent/script-registration-store.js +61 -0
  135. package/consent/script-registration-store.js.map +7 -0
  136. package/consent/script-snippets.d.ts +24 -0
  137. package/consent/script-snippets.js +122 -0
  138. package/consent/script-snippets.js.map +7 -0
  139. package/consent/types.d.ts +34 -0
  140. package/consent/types.js +1 -0
  141. package/consent/types.js.map +7 -0
  142. package/consent/window-api.d.ts +41 -0
  143. package/consent/window-api.js +73 -0
  144. package/consent/window-api.js.map +7 -0
  145. package/env.d.ts +9 -0
  146. package/env.js +42 -0
  147. package/env.js.map +7 -0
  148. package/gateways/canopy-api.d.ts +83 -0
  149. package/gateways/canopy-api.js +197 -0
  150. package/gateways/canopy-api.js.map +7 -0
  151. package/hooks/use-client-value.d.ts +10 -0
  152. package/hooks/use-client-value.js +12 -0
  153. package/hooks/use-client-value.js.map +7 -0
  154. package/hooks/use-formatted-price.d.ts +15 -0
  155. package/hooks/use-formatted-price.js +20 -0
  156. package/hooks/use-formatted-price.js.map +7 -0
  157. package/lib/canopy-error.d.ts +25 -0
  158. package/lib/canopy-error.js +24 -0
  159. package/lib/canopy-error.js.map +7 -0
  160. package/lib/get-query-client.d.ts +2 -0
  161. package/lib/get-query-client.js +34 -0
  162. package/lib/get-query-client.js.map +7 -0
  163. package/lib/integration-utils.d.ts +2 -0
  164. package/lib/integration-utils.js +9 -0
  165. package/lib/integration-utils.js.map +7 -0
  166. package/lib/shopify-utils.d.ts +10 -0
  167. package/lib/shopify-utils.js +7 -0
  168. package/lib/shopify-utils.js.map +7 -0
  169. package/lib/url-utils.d.ts +4 -0
  170. package/lib/url-utils.js +8 -0
  171. package/lib/url-utils.js.map +7 -0
  172. package/loaders/collection-loader.d.ts +11 -0
  173. package/loaders/collection-loader.js +55 -0
  174. package/loaders/collection-loader.js.map +7 -0
  175. package/loaders/collection-products-loader.d.ts +12 -0
  176. package/loaders/collection-products-loader.js +58 -0
  177. package/loaders/collection-products-loader.js.map +7 -0
  178. package/loaders/contentful-entries-loader.d.ts +17 -0
  179. package/loaders/contentful-entries-loader.js +78 -0
  180. package/loaders/contentful-entries-loader.js.map +7 -0
  181. package/loaders/contentful-entry-loader.d.ts +14 -0
  182. package/loaders/contentful-entry-loader.js +60 -0
  183. package/loaders/contentful-entry-loader.js.map +7 -0
  184. package/loaders/invoke-loader-action.d.ts +11 -0
  185. package/loaders/invoke-loader-action.js +14 -0
  186. package/loaders/invoke-loader-action.js.map +7 -0
  187. package/loaders/invoke-loader-server.d.ts +18 -0
  188. package/loaders/invoke-loader-server.js +40 -0
  189. package/loaders/invoke-loader-server.js.map +7 -0
  190. package/loaders/invoke-loader.d.ts +16 -0
  191. package/loaders/invoke-loader.js +37 -0
  192. package/loaders/invoke-loader.js.map +7 -0
  193. package/loaders/levanta-product-loader.d.ts +11 -0
  194. package/loaders/levanta-product-loader.js +53 -0
  195. package/loaders/levanta-product-loader.js.map +7 -0
  196. package/loaders/loader-error-boundary.d.ts +25 -0
  197. package/loaders/loader-error-boundary.js +24 -0
  198. package/loaders/loader-error-boundary.js.map +7 -0
  199. package/loaders/loader-keys.d.ts +34 -0
  200. package/loaders/loader-keys.js +26 -0
  201. package/loaders/loader-keys.js.map +7 -0
  202. package/loaders/loader-schemas.d.ts +946 -0
  203. package/loaders/loader-schemas.js +353 -0
  204. package/loaders/loader-schemas.js.map +7 -0
  205. package/loaders/metaobject-loader.d.ts +12 -0
  206. package/loaders/metaobject-loader.js +54 -0
  207. package/loaders/metaobject-loader.js.map +7 -0
  208. package/loaders/metaobjects-loader.d.ts +14 -0
  209. package/loaders/metaobjects-loader.js +60 -0
  210. package/loaders/metaobjects-loader.js.map +7 -0
  211. package/loaders/okendo-review-aggregate-loader.d.ts +17 -0
  212. package/loaders/okendo-review-aggregate-loader.js +56 -0
  213. package/loaders/okendo-review-aggregate-loader.js.map +7 -0
  214. package/loaders/okendo-reviews-loader.d.ts +23 -0
  215. package/loaders/okendo-reviews-loader.js +54 -0
  216. package/loaders/okendo-reviews-loader.js.map +7 -0
  217. package/loaders/prefetch-loaders.d.ts +33 -0
  218. package/loaders/prefetch-loaders.js +46 -0
  219. package/loaders/prefetch-loaders.js.map +7 -0
  220. package/loaders/preview-placeholder.d.ts +25 -0
  221. package/loaders/preview-placeholder.js +222 -0
  222. package/loaders/preview-placeholder.js.map +7 -0
  223. package/loaders/product-loader-args.d.ts +21 -0
  224. package/loaders/product-loader-args.js +17 -0
  225. package/loaders/product-loader-args.js.map +7 -0
  226. package/loaders/product-loader.d.ts +10 -0
  227. package/loaders/product-loader.js +52 -0
  228. package/loaders/product-loader.js.map +7 -0
  229. package/loaders/rebuy-recommendations-loader.d.ts +165 -0
  230. package/loaders/rebuy-recommendations-loader.js +57 -0
  231. package/loaders/rebuy-recommendations-loader.js.map +7 -0
  232. package/loaders/reviews-io-review-aggregate-loader.d.ts +12 -0
  233. package/loaders/reviews-io-review-aggregate-loader.js +43 -0
  234. package/loaders/reviews-io-review-aggregate-loader.js.map +7 -0
  235. package/loaders/reviews-io-reviews-loader.d.ts +14 -0
  236. package/loaders/reviews-io-reviews-loader.js +65 -0
  237. package/loaders/reviews-io-reviews-loader.js.map +7 -0
  238. package/loaders/smile-earning-rules-loader.d.ts +19 -0
  239. package/loaders/smile-earning-rules-loader.js +44 -0
  240. package/loaders/smile-earning-rules-loader.js.map +7 -0
  241. package/loaders/smile-rewards-loader.d.ts +19 -0
  242. package/loaders/smile-rewards-loader.js +44 -0
  243. package/loaders/smile-rewards-loader.js.map +7 -0
  244. package/loaders/smile-vip-tiers-loader.d.ts +18 -0
  245. package/loaders/smile-vip-tiers-loader.js +43 -0
  246. package/loaders/smile-vip-tiers-loader.js.map +7 -0
  247. package/loaders/statsig-experiment-loader.d.ts +20 -0
  248. package/loaders/statsig-experiment-loader.js +81 -0
  249. package/loaders/statsig-experiment-loader.js.map +7 -0
  250. package/loaders/yotpo-review-aggregate-loader.d.ts +12 -0
  251. package/loaders/yotpo-review-aggregate-loader.js +50 -0
  252. package/loaders/yotpo-review-aggregate-loader.js.map +7 -0
  253. package/loaders/yotpo-reviews-loader.d.ts +14 -0
  254. package/loaders/yotpo-reviews-loader.js +65 -0
  255. package/loaders/yotpo-reviews-loader.js.map +7 -0
  256. package/money.d.ts +9 -0
  257. package/money.js +13 -0
  258. package/money.js.map +7 -0
  259. package/next/config.d.ts +4 -0
  260. package/next/config.js +91 -0
  261. package/next/config.js.map +7 -0
  262. package/next/image-loader.d.ts +2 -0
  263. package/next/image-loader.js +52 -0
  264. package/next/image-loader.js.map +7 -0
  265. package/next/open-next.d.ts +2 -0
  266. package/next/open-next.js +24 -0
  267. package/next/open-next.js.map +7 -0
  268. package/orders/order-status-schema.d.ts +161 -0
  269. package/orders/order-status-schema.js +83 -0
  270. package/orders/order-status-schema.js.map +7 -0
  271. package/orders/order-status.d.ts +11 -0
  272. package/orders/order-status.js +41 -0
  273. package/orders/order-status.js.map +7 -0
  274. package/package.json +216 -0
  275. package/providers/query-provider.d.ts +1 -0
  276. package/providers/query-provider.js +12 -0
  277. package/providers/query-provider.js.map +7 -0
  278. package/providers/replo-provider.d.ts +1 -0
  279. package/providers/replo-provider.js +22 -0
  280. package/providers/replo-provider.js.map +7 -0
package/LICENSE ADDED
@@ -0,0 +1,11 @@
1
+ Replo SDK — proprietary software of Replo. All rights reserved.
2
+
3
+ This software is licensed, not sold. Subject to the Replo Terms of Service
4
+ (https://replo.app/terms), Replo grants you a limited, non-exclusive,
5
+ non-transferable, revocable license to install and use this software solely to
6
+ build, preview, and operate sites on the Replo platform. You may not
7
+ redistribute, resell, sublicense, or use this software to build or operate any
8
+ product or service independent of or competing with Replo.
9
+
10
+ Full terms: https://replo.app/terms
11
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Web Crypto helpers shared across runtime targets (Cloudflare Workers, Node
3
+ * 19+, browsers). Built on `crypto.subtle` so the same implementation runs
4
+ * inside Workers without a Node-only `node:crypto` import.
5
+ */
6
+ export declare function bytesToBase64Url(bytes: Uint8Array): string;
7
+ export declare function base64UrlToBytes(input: string): Uint8Array;
8
+ export declare function randomBase64Url(byteLength: number): string;
9
+ /**
10
+ * Prefer this over the global `crypto.randomUUID()`, which is secure-context-only
11
+ * and therefore undefined over plain `http://`. `uuid`'s v4 is backed by
12
+ * `crypto.getRandomValues`, which carries no such restriction.
13
+ */
14
+ export declare function randomUUID(): string;
15
+ /**
16
+ * Returns the SHA-256 of `input` as a 64-char lowercase hex string.
17
+ *
18
+ * Used for storing opaque secrets (e.g. public API tokens) where we want
19
+ * constant-length hex output suitable for a `VARCHAR(64)` column with a
20
+ * unique index.
21
+ */
22
+ export declare function sha256Hex(input: string): Promise<string>;
23
+ export declare function constantTimeEqual({ left, right, }: {
24
+ left: Uint8Array;
25
+ right: Uint8Array;
26
+ }): boolean;
27
+ export declare function getHmacSha256Hex({ rawBody, signingKey, }: {
28
+ rawBody: string;
29
+ signingKey: string;
30
+ }): Promise<string>;
@@ -0,0 +1,83 @@
1
+ type ValueOfType<ObjectType> = ObjectType[keyof ObjectType];
2
+ /**
3
+ * Mostly taken from
4
+ * https://gist.githubusercontent.com/scokmen/f813c904ef79022e84ab2409574d1b45/raw/cd8709a2fccb005bb53e9bfb2461e07d40b4e8d8/HttpStatusCode.ts
5
+ */
6
+ export declare const HTTP_STATUS_CODES: {
7
+ readonly CONTINUE: 100;
8
+ readonly SWITCHING_PROTOCOLS: 101;
9
+ readonly PROCESSING: 102;
10
+ readonly OK: 200;
11
+ readonly CREATED: 201;
12
+ readonly ACCEPTED: 202;
13
+ readonly NON_AUTHORITATIVE_INFORMATION: 203;
14
+ readonly NO_CONTENT: 204;
15
+ readonly RESET_CONTENT: 205;
16
+ readonly PARTIAL_CONTENT: 206;
17
+ readonly MULTI_STATUS: 207;
18
+ readonly ALREADY_REPORTED: 208;
19
+ readonly IM_USED: 226;
20
+ readonly MULTIPLE_CHOICES: 300;
21
+ readonly MOVED_PERMANENTLY: 301;
22
+ readonly FOUND: 302;
23
+ readonly SEE_OTHER: 303;
24
+ readonly NOT_MODIFIED: 304;
25
+ readonly USE_PROXY: 305;
26
+ readonly SWITCH_PROXY: 306;
27
+ readonly TEMPORARY_REDIRECT: 307;
28
+ readonly PERMANENT_REDIRECT: 308;
29
+ readonly BAD_REQUEST: 400;
30
+ readonly UNAUTHORIZED: 401;
31
+ readonly PAYMENT_REQUIRED: 402;
32
+ readonly FORBIDDEN: 403;
33
+ readonly NOT_FOUND: 404;
34
+ readonly METHOD_NOT_ALLOWED: 405;
35
+ readonly NOT_ACCEPTABLE: 406;
36
+ readonly PROXY_AUTHENTICATION_REQUIRED: 407;
37
+ readonly REQUEST_TIMEOUT: 408;
38
+ readonly CONFLICT: 409;
39
+ readonly GONE: 410;
40
+ readonly LENGTH_REQUIRED: 411;
41
+ readonly PRECONDITION_FAILED: 412;
42
+ readonly PAYLOAD_TOO_LARGE: 413;
43
+ readonly URI_TOO_LONG: 414;
44
+ readonly UNSUPPORTED_MEDIA_TYPE: 415;
45
+ readonly RANGE_NOT_SATISFIABLE: 416;
46
+ readonly EXPECTATION_FAILED: 417;
47
+ readonly I_AM_A_TEAPOT: 418;
48
+ readonly MISDIRECTED_REQUEST: 421;
49
+ readonly UNPROCESSABLE_ENTITY: 422;
50
+ readonly LOCKED: 423;
51
+ readonly FAILED_DEPENDENCY: 424;
52
+ readonly UPGRADE_REQUIRED: 426;
53
+ readonly PRECONDITION_REQUIRED: 428;
54
+ readonly TOO_MANY_REQUESTS: 429;
55
+ readonly REQUEST_HEADER_FIELDS_TOO_LARGE: 431;
56
+ readonly UNAVAILABLE_FOR_LEGAL_REASONS: 451;
57
+ readonly INTERNAL_SERVER_ERROR: 500;
58
+ readonly NOT_IMPLEMENTED: 501;
59
+ readonly BAD_GATEWAY: 502;
60
+ readonly SERVICE_UNAVAILABLE: 503;
61
+ readonly GATEWAY_TIMEOUT: 504;
62
+ readonly HTTP_VERSION_NOT_SUPPORTED: 505;
63
+ readonly VARIANT_ALSO_NEGOTIATES: 506;
64
+ readonly INSUFFICIENT_STORAGE: 507;
65
+ readonly LOOP_DETECTED: 508;
66
+ readonly NOT_EXTENDED: 510;
67
+ readonly NETWORK_AUTHENTICATION_REQUIRED: 511;
68
+ readonly UPSTREAM_WEBSERVER_ERROR: 520;
69
+ };
70
+ export type HttpStatusCode = ValueOfType<typeof HTTP_STATUS_CODES>;
71
+ /**
72
+ * Checks if an error message indicates a network error (e.g., connectivity issues,
73
+ * request timeouts, DNS failures). These errors typically don't need to be tracked
74
+ * in error monitoring systems like Sentry since they're user-side connectivity issues.
75
+ */
76
+ export declare function isNetworkErrorMessage(message: string): boolean;
77
+ /**
78
+ * Extracts a human-readable message from an unknown caught value. If the value
79
+ * is an Error, returns its message; otherwise falls back to the provided
80
+ * fallback string or `String(error)`.
81
+ */
82
+ export declare function getErrorMessage(error: unknown, fallback?: string): string;
83
+ export {};
@@ -0,0 +1,6 @@
1
+ export declare function parseJsonOrNull(json: string): unknown | null;
2
+ export declare function omitJsonObjectFieldsOrNull({ json, fields, }: {
3
+ json: string;
4
+ fields: string[];
5
+ }): string | null;
6
+ export declare function jsonStringifyOrNull(value: unknown): string | null;
@@ -0,0 +1,43 @@
1
+ import '../../../chunk-UJCSKKID.mjs';
2
+
3
+ // ../replo-utils/lib/object.ts
4
+ function omit(obj, keysToOmit) {
5
+ const result = { ...obj };
6
+ for (const key of keysToOmit) {
7
+ delete result[key];
8
+ }
9
+ return result;
10
+ }
11
+
12
+ // ../replo-utils/lib/json.ts
13
+ function parseJsonOrNull(json) {
14
+ try {
15
+ return JSON.parse(json);
16
+ } catch {
17
+ return null;
18
+ }
19
+ }
20
+ function omitJsonObjectFieldsOrNull({
21
+ json,
22
+ fields
23
+ }) {
24
+ const parsedJson = parseJsonOrNull(json);
25
+ if (typeof parsedJson !== "object" || parsedJson === null || Array.isArray(parsedJson)) {
26
+ return null;
27
+ }
28
+ return jsonStringifyOrNull(
29
+ omit(Object.fromEntries(Object.entries(parsedJson)), fields)
30
+ );
31
+ }
32
+ function jsonStringifyOrNull(value) {
33
+ if (value === null || value === void 0) {
34
+ return null;
35
+ }
36
+ try {
37
+ return JSON.stringify(value);
38
+ } catch {
39
+ return null;
40
+ }
41
+ }
42
+
43
+ export { jsonStringifyOrNull, omitJsonObjectFieldsOrNull, parseJsonOrNull };
@@ -0,0 +1,145 @@
1
+ import isFunction from "lodash-es/isFunction";
2
+ import isNumber from "lodash-es/isNumber";
3
+ import isString from "lodash-es/isString";
4
+ export { isFunction, isNumber, isString };
5
+ /**
6
+ * Checks if a value is neither `null` nor `undefined`.
7
+ */
8
+ export declare function isNotNullish<ValueType>(value: ValueType): value is Exclude<ValueType, null | undefined>;
9
+ /**
10
+ * Checks if a value is either `null` or `undefined`.
11
+ */
12
+ export declare function isNullish(value: unknown): value is null | undefined;
13
+ export declare function getFromRecordOrNull<RecordKey extends PropertyKey, RecordValue>(record: Record<RecordKey, RecordValue> | null | undefined, key: RecordKey | undefined | null): NonNullable<Record<RecordKey, RecordValue>[RecordKey]> | null;
14
+ export declare function isPrimitive(value: unknown): value is string | number | boolean;
15
+ type StructureRecord<UnionType extends {
16
+ type: string;
17
+ }, ResultType> = {
18
+ [MemberType in UnionType as MemberType["type"]]: ResultType | ((value: MemberType) => ResultType);
19
+ };
20
+ type StructureRecordBareString<UnionType extends string, ResultType> = {
21
+ [MemberType in UnionType]: ResultType | ((value: MemberType) => ResultType);
22
+ };
23
+ type StructureRecordGeneric<UnionType extends Record<KeyType, string>, ResultType, KeyType extends keyof UnionType> = {
24
+ [MemberType in UnionType as MemberType[KeyType]]: ResultType | ((value: MemberType) => ResultType);
25
+ };
26
+ /**
27
+ * @returns A function which can be used to create an exhaustive switch over all
28
+ * types of a discriminated union, based on a given key, or over all members of
29
+ * a bare string union.
30
+ *
31
+ * When no key is provided, it defaults to using "type" as the discriminant.
32
+ * When the value is a bare string union, the value is its own discriminant.
33
+ *
34
+ * Examples:
35
+ *
36
+ * With default "type" discriminant:
37
+ * ```
38
+ * type OneOrTwo = { type: "one", numberValue: number } |
39
+ * { type: "two", stringValue: string }
40
+ *
41
+ * let oneOrTwo = ...
42
+ * let result = exhaustiveSwitch(oneOrTwo)({
43
+ * one: (op) => `${op.numberValue + 1}`, // Typescript knows numberValue is a number
44
+ * two: (op) => op.stringValue + "hello", // Typescript knows stringValue is a string
45
+ * }) // type of result is inferred to be string
46
+ * ```
47
+ *
48
+ * With custom discriminant key:
49
+ * ```
50
+ * type OneOrTwo = { variant: "one", numberValue: number } |
51
+ * { variant: "two", stringValue: string }
52
+ *
53
+ * let oneOrTwo = ...
54
+ * let result = exhaustiveSwitch(oneOrTwo, "variant")({
55
+ * one: (op) => `${op.numberValue + 1}`, // Typescript knows numberValue is a number
56
+ * two: (op) => op.stringValue + "hello", // Typescript knows stringValue is a string
57
+ * }) // type of result is inferred to be string
58
+ * ```
59
+ *
60
+ * With a bare string union:
61
+ * ```
62
+ * type OneOrTwo = "one" | "two"
63
+ *
64
+ * let oneOrTwo = ...
65
+ * let result = exhaustiveSwitch(oneOrTwo)({
66
+ * one: 1, // cases can be plain values...
67
+ * two: () => 1 + 1, // ...or functions, evaluated lazily
68
+ * }) // type of result is inferred to be number
69
+ * ```
70
+ *
71
+ * Typescript will error if you forget a case, or if you assume the wrong type
72
+ * for a case value. The switch also returns the value you return from the
73
+ * function mapping, so it works well for "extension" methods where you want to
74
+ * map over all discriminated union cases and do a different thing for each.
75
+ *
76
+ * Works well for many of our types, like ComponentActionType, Action, etc
77
+ */
78
+ export declare function exhaustiveSwitch<UnionType extends string>(value: UnionType): <ResultType>(cases: StructureRecordBareString<UnionType, ResultType>) => ResultType;
79
+ export declare function exhaustiveSwitch<UnionType extends {
80
+ type: string;
81
+ }>(value: UnionType): <ResultType>(cases: StructureRecord<UnionType, ResultType>) => ResultType;
82
+ export declare function exhaustiveSwitch<UnionType extends Record<KeyType, string>, KeyType extends keyof UnionType>(value: UnionType, key: KeyType): <ResultType>(cases: StructureRecordGeneric<UnionType, ResultType, KeyType>) => ResultType;
83
+ type EmptyObject<ValueType> = {
84
+ [KeyType in keyof ValueType]?: never;
85
+ };
86
+ type EmptyObjectOf<ValueType> = EmptyObject<ValueType> extends ValueType ? EmptyObject<ValueType> : never;
87
+ /**
88
+ * The same as `isEmpty` from lodash, but with a few additional overloads for
89
+ * stronger type-checking on empty arrays.
90
+ */
91
+ export declare function isEmpty(value: string): value is "";
92
+ export declare function isEmpty<ValueType extends any[]>(value: ValueType | null | undefined): value is (ValueType & []) | null | undefined;
93
+ export declare function isEmpty<ValueType extends ArrayLike<any>>(value: ValueType | null | undefined): value is (ValueType & {
94
+ length: 0;
95
+ }) | null | undefined;
96
+ export declare function isEmpty(value: Map<any, any> | Set<any> | ArrayLike<any> | null | undefined): boolean;
97
+ export declare function isEmpty(value: object): boolean;
98
+ export declare function isEmpty<ValueType extends object>(value: ValueType | null | undefined): value is EmptyObjectOf<ValueType> | null | undefined;
99
+ export declare function isEmpty(value?: any): boolean;
100
+ export declare function noop(): void;
101
+ export declare function preventDefault(event: {
102
+ preventDefault(): void;
103
+ }): void;
104
+ /**
105
+ * Copyright (c) 2019 Alexander Reardon
106
+ * https://github.com/alexreardon/tiny-warning/blob/master/src/index.js
107
+ */
108
+ export declare function warning(condition: unknown, message: string | (() => string), options?: {
109
+ severity: "log" | "warn" | "error";
110
+ }): void;
111
+ /**
112
+ *
113
+ * Copyright (c) 2019 Alexander Reardon
114
+ * https://github.com/alexreardon/tiny-warning/blob/master/src/index.js
115
+ */
116
+ export declare function invariant(condition: unknown, message: string | (() => string), opts?: {
117
+ stripErrorMessage: unknown;
118
+ }): asserts condition;
119
+ export declare const mergeReplacingObjects: (first: Object, second: Object) => void;
120
+ export declare const mergeReplacingArrays: (first: Object, second: Object) => void;
121
+ export declare const deepCloneAndMergeReplacingArrays: <ValueType>(source: ValueType, ...toMerge: Object[]) => ValueType;
122
+ /**
123
+ * hasOwnProperty with a type assertion. If this returns true, typescript knows that `obj`
124
+ * has a property called `prop` from that point forward
125
+ * https://fettblog.eu/typescript-hasownproperty/
126
+ */
127
+ export declare function hasOwnProperty<ObjectType extends {} | null | undefined, KeyType extends PropertyKey>(obj: ObjectType, prop: KeyType): obj is ObjectType & Record<KeyType, unknown>;
128
+ /**
129
+ * Given a string | number param, converts it to a string, unless it's nullish
130
+ * in which case it just returns it. Useful for times when you have string | number
131
+ * | nullish types, like when selecting the current value of a CSS property in a right
132
+ * bar modifier
133
+ */
134
+ export declare function coerceNumberToString(value: string | number): string;
135
+ export declare function coerceNumberToString(value: string | number | null | undefined): string | null | undefined;
136
+ export declare function coerceNumberToString(value: string | number | undefined): string | undefined;
137
+ export declare function coerceNumberToString(value: string | number | null): string | null;
138
+ /**
139
+ * Formats a file size in bytes to a human readable string with appropriate
140
+ * units. Rounds to 0 decimal places unless otherwise specified and uses
141
+ * standard binary units (KB, MB, etc).
142
+ */
143
+ export declare function formatFileSize(byteCount: number, decimalPlaces?: number): string;
144
+ export declare const sleep: (ms: number) => Promise<unknown>;
145
+ export declare function errorMessage(error: unknown): string;
@@ -0,0 +1,31 @@
1
+ import { dequal as dequalLite } from "dequal/lite";
2
+ interface ForEachPrimitiveValueArgs {
3
+ target: Record<string, any> | unknown[] | null;
4
+ fn: (value: unknown, key: string, newTarget: Record<string, any>) => void;
5
+ valueConversionFunction?: (transformValue: Record<string, any> | unknown[]) => Record<string, any> | unknown[];
6
+ }
7
+ /** There's probably a bug somewhere here since it assumes target is initially an object */
8
+ export declare function forEachPrimitiveValue({ target, fn, valueConversionFunction, }: ForEachPrimitiveValueArgs): void;
9
+ export declare function shallowEqual(objA: unknown, objB: unknown): boolean;
10
+ /**
11
+ * Internally we use `dequal` for deep equality checks. It benchmarks faster
12
+ * than lodash and most other libraries.
13
+ *
14
+ * This function is an alias for `dequal`'s "lite" module. It does not check
15
+ * equality for `Map` or `Set` values. If you need to compare those, use
16
+ * `deepEqualHeavy`.
17
+ *
18
+ * @see https://github.com/lukeed/dequal#modes
19
+ */
20
+ export declare const deepEqual: typeof dequalLite;
21
+ /**
22
+ * Creates a new object with specified keys omitted.
23
+ *
24
+ * @param obj - The source object
25
+ * @param keysToOmit - Array of keys to omit from the result
26
+ * @returns A new object without the specified keys
27
+ */
28
+ export declare function omit<ObjectType extends Record<string, any>, KeyType extends keyof ObjectType>(obj: ObjectType, keysToOmit: KeyType[]): Omit<ObjectType, KeyType>;
29
+ export declare function filterUndefined<ObjectType extends Record<string, unknown>>(data: ObjectType): Partial<ObjectType>;
30
+ export declare function toNullableIfDefined<ValueType>(value: ValueType | undefined): ValueType | null | undefined;
31
+ export {};