@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.
- package/LICENSE +11 -0
- package/_vendor/replo-utils/lib/crypto.d.ts +30 -0
- package/_vendor/replo-utils/lib/errors.d.ts +83 -0
- package/_vendor/replo-utils/lib/json.d.ts +6 -0
- package/_vendor/replo-utils/lib/json.mjs +43 -0
- package/_vendor/replo-utils/lib/misc.d.ts +145 -0
- package/_vendor/replo-utils/lib/object.d.ts +31 -0
- package/_vendor/schemas/errors.d.ts +459 -0
- package/_vendor/schemas/generated/consent.d.ts +55 -0
- package/_vendor/schemas/generated/errors.d.ts +61 -0
- package/_vendor/schemas/loaderKeys.d.ts +1 -0
- package/_vendor/schemas/loaderKeys.mjs +27 -0
- package/_vendor/schemas/money.d.ts +60 -0
- package/_vendor/schemas/money.mjs +2051 -0
- package/analytics/analytics-provider.d.ts +16 -0
- package/analytics/analytics-provider.js +113 -0
- package/analytics/analytics-provider.js.map +7 -0
- package/analytics/analytics-sink.d.ts +26 -0
- package/analytics/analytics-sink.js +1 -0
- package/analytics/analytics-sink.js.map +7 -0
- package/analytics/get-analytics-sinks.d.ts +27 -0
- package/analytics/get-analytics-sinks.js +52 -0
- package/analytics/get-analytics-sinks.js.map +7 -0
- package/analytics/hooks/use-product-viewed-analytics.d.ts +23 -0
- package/analytics/hooks/use-product-viewed-analytics.js +34 -0
- package/analytics/hooks/use-product-viewed-analytics.js.map +7 -0
- package/analytics/replo-first-party-pixel.d.ts +12 -0
- package/analytics/replo-first-party-pixel.js +31 -0
- package/analytics/replo-first-party-pixel.js.map +7 -0
- package/analytics/replo-pixel-script.d.ts +13 -0
- package/analytics/replo-pixel-script.js +30 -0
- package/analytics/replo-pixel-script.js.map +7 -0
- package/analytics/sinks/ga4-sink.d.ts +15 -0
- package/analytics/sinks/ga4-sink.js +60 -0
- package/analytics/sinks/ga4-sink.js.map +7 -0
- package/analytics/sinks/meta-sink.d.ts +14 -0
- package/analytics/sinks/meta-sink.js +56 -0
- package/analytics/sinks/meta-sink.js.map +7 -0
- package/analytics/sinks/pinterest-sink.d.ts +14 -0
- package/analytics/sinks/pinterest-sink.js +76 -0
- package/analytics/sinks/pinterest-sink.js.map +7 -0
- package/analytics/sinks/reddit-sink.d.ts +14 -0
- package/analytics/sinks/reddit-sink.js +80 -0
- package/analytics/sinks/reddit-sink.js.map +7 -0
- package/analytics/sinks/replo-sink.d.ts +14 -0
- package/analytics/sinks/replo-sink.js +57 -0
- package/analytics/sinks/replo-sink.js.map +7 -0
- package/analytics/sinks/snapchat-sink.d.ts +14 -0
- package/analytics/sinks/snapchat-sink.js +67 -0
- package/analytics/sinks/snapchat-sink.js.map +7 -0
- package/analytics/sinks/tiktok-sink.d.ts +14 -0
- package/analytics/sinks/tiktok-sink.js +79 -0
- package/analytics/sinks/tiktok-sink.js.map +7 -0
- package/analytics/sinks/window-sink.d.ts +18 -0
- package/analytics/sinks/window-sink.js +46 -0
- package/analytics/sinks/window-sink.js.map +7 -0
- package/analytics/utils/analytics-utils.d.ts +7 -0
- package/analytics/utils/analytics-utils.js +130 -0
- package/analytics/utils/analytics-utils.js.map +7 -0
- package/analytics/utils/navigation-tracker.d.ts +16 -0
- package/analytics/utils/navigation-tracker.js +44 -0
- package/analytics/utils/navigation-tracker.js.map +7 -0
- package/analytics/utils/shopify-funnel-gate.d.ts +8 -0
- package/analytics/utils/shopify-funnel-gate.js +22 -0
- package/analytics/utils/shopify-funnel-gate.js.map +7 -0
- package/cart/buy-now-action.d.ts +21 -0
- package/cart/buy-now-action.js +104 -0
- package/cart/buy-now-action.js.map +7 -0
- package/cart/cart-actions.d.ts +63 -0
- package/cart/cart-actions.js +90 -0
- package/cart/cart-actions.js.map +7 -0
- package/cart/cart-loader.d.ts +9 -0
- package/cart/cart-loader.js +11 -0
- package/cart/cart-loader.js.map +7 -0
- package/cart/cart-provider.d.ts +85 -0
- package/cart/cart-provider.js +372 -0
- package/cart/cart-provider.js.map +7 -0
- package/cart/cart-schema.d.ts +74 -0
- package/cart/cart-schema.js +69 -0
- package/cart/cart-schema.js.map +7 -0
- package/cart/cart-types.d.ts +132 -0
- package/cart/cart-types.js +8 -0
- package/cart/cart-types.js.map +7 -0
- package/cart/gateways/cart-constants.d.ts +1 -0
- package/cart/gateways/cart-constants.js +5 -0
- package/cart/gateways/cart-constants.js.map +7 -0
- package/cart/gateways/cart-gateway.d.ts +10 -0
- package/cart/gateways/cart-gateway.js +19 -0
- package/cart/gateways/cart-gateway.js.map +7 -0
- package/cart/gateways/cookie-cart-gateway.d.ts +28 -0
- package/cart/gateways/cookie-cart-gateway.js +109 -0
- package/cart/gateways/cookie-cart-gateway.js.map +7 -0
- package/cart/gateways/default-cart-gateway.d.ts +19 -0
- package/cart/gateways/default-cart-gateway.js +30 -0
- package/cart/gateways/default-cart-gateway.js.map +7 -0
- package/cart/gateways/resolver-cart-gateway.d.ts +2 -0
- package/cart/gateways/resolver-cart-gateway.js +109 -0
- package/cart/gateways/resolver-cart-gateway.js.map +7 -0
- package/cart/gateways/stripe-cart-gateway.d.ts +19 -0
- package/cart/gateways/stripe-cart-gateway.js +28 -0
- package/cart/gateways/stripe-cart-gateway.js.map +7 -0
- package/cart/hooks/use-add-to-cart.d.ts +63 -0
- package/cart/hooks/use-add-to-cart.js +124 -0
- package/cart/hooks/use-add-to-cart.js.map +7 -0
- package/cart/hooks/use-buy-now.d.ts +49 -0
- package/cart/hooks/use-buy-now.js +62 -0
- package/cart/hooks/use-buy-now.js.map +7 -0
- package/cart/utils/cart-utils.d.ts +43 -0
- package/cart/utils/cart-utils.js +46 -0
- package/cart/utils/cart-utils.js.map +7 -0
- package/cart/utils/cookie-cart-persistence.d.ts +55 -0
- package/cart/utils/cookie-cart-persistence.js +166 -0
- package/cart/utils/cookie-cart-persistence.js.map +7 -0
- package/cart/utils/variant-to-cart-line.d.ts +74 -0
- package/cart/utils/variant-to-cart-line.js +162 -0
- package/cart/utils/variant-to-cart-line.js.map +7 -0
- package/chunk-UJCSKKID.mjs +27 -0
- package/consent/consent-action.d.ts +9 -0
- package/consent/consent-action.js +25 -0
- package/consent/consent-action.js.map +7 -0
- package/consent/consent-actions.d.ts +28 -0
- package/consent/consent-actions.js +36 -0
- package/consent/consent-actions.js.map +7 -0
- package/consent/consent-store.d.ts +69 -0
- package/consent/consent-store.js +194 -0
- package/consent/consent-store.js.map +7 -0
- package/consent/cookie.d.ts +36 -0
- package/consent/cookie.js +82 -0
- package/consent/cookie.js.map +7 -0
- package/consent/replo-scripts.d.ts +23 -0
- package/consent/replo-scripts.js +102 -0
- package/consent/replo-scripts.js.map +7 -0
- package/consent/script-registration-store.d.ts +25 -0
- package/consent/script-registration-store.js +61 -0
- package/consent/script-registration-store.js.map +7 -0
- package/consent/script-snippets.d.ts +24 -0
- package/consent/script-snippets.js +122 -0
- package/consent/script-snippets.js.map +7 -0
- package/consent/types.d.ts +34 -0
- package/consent/types.js +1 -0
- package/consent/types.js.map +7 -0
- package/consent/window-api.d.ts +41 -0
- package/consent/window-api.js +73 -0
- package/consent/window-api.js.map +7 -0
- package/env.d.ts +9 -0
- package/env.js +42 -0
- package/env.js.map +7 -0
- package/gateways/canopy-api.d.ts +83 -0
- package/gateways/canopy-api.js +197 -0
- package/gateways/canopy-api.js.map +7 -0
- package/hooks/use-client-value.d.ts +10 -0
- package/hooks/use-client-value.js +12 -0
- package/hooks/use-client-value.js.map +7 -0
- package/hooks/use-formatted-price.d.ts +15 -0
- package/hooks/use-formatted-price.js +20 -0
- package/hooks/use-formatted-price.js.map +7 -0
- package/lib/canopy-error.d.ts +25 -0
- package/lib/canopy-error.js +24 -0
- package/lib/canopy-error.js.map +7 -0
- package/lib/get-query-client.d.ts +2 -0
- package/lib/get-query-client.js +34 -0
- package/lib/get-query-client.js.map +7 -0
- package/lib/integration-utils.d.ts +2 -0
- package/lib/integration-utils.js +9 -0
- package/lib/integration-utils.js.map +7 -0
- package/lib/shopify-utils.d.ts +10 -0
- package/lib/shopify-utils.js +7 -0
- package/lib/shopify-utils.js.map +7 -0
- package/lib/url-utils.d.ts +4 -0
- package/lib/url-utils.js +8 -0
- package/lib/url-utils.js.map +7 -0
- package/loaders/collection-loader.d.ts +11 -0
- package/loaders/collection-loader.js +55 -0
- package/loaders/collection-loader.js.map +7 -0
- package/loaders/collection-products-loader.d.ts +12 -0
- package/loaders/collection-products-loader.js +58 -0
- package/loaders/collection-products-loader.js.map +7 -0
- package/loaders/contentful-entries-loader.d.ts +17 -0
- package/loaders/contentful-entries-loader.js +78 -0
- package/loaders/contentful-entries-loader.js.map +7 -0
- package/loaders/contentful-entry-loader.d.ts +14 -0
- package/loaders/contentful-entry-loader.js +60 -0
- package/loaders/contentful-entry-loader.js.map +7 -0
- package/loaders/invoke-loader-action.d.ts +11 -0
- package/loaders/invoke-loader-action.js +14 -0
- package/loaders/invoke-loader-action.js.map +7 -0
- package/loaders/invoke-loader-server.d.ts +18 -0
- package/loaders/invoke-loader-server.js +40 -0
- package/loaders/invoke-loader-server.js.map +7 -0
- package/loaders/invoke-loader.d.ts +16 -0
- package/loaders/invoke-loader.js +37 -0
- package/loaders/invoke-loader.js.map +7 -0
- package/loaders/levanta-product-loader.d.ts +11 -0
- package/loaders/levanta-product-loader.js +53 -0
- package/loaders/levanta-product-loader.js.map +7 -0
- package/loaders/loader-error-boundary.d.ts +25 -0
- package/loaders/loader-error-boundary.js +24 -0
- package/loaders/loader-error-boundary.js.map +7 -0
- package/loaders/loader-keys.d.ts +34 -0
- package/loaders/loader-keys.js +26 -0
- package/loaders/loader-keys.js.map +7 -0
- package/loaders/loader-schemas.d.ts +946 -0
- package/loaders/loader-schemas.js +353 -0
- package/loaders/loader-schemas.js.map +7 -0
- package/loaders/metaobject-loader.d.ts +12 -0
- package/loaders/metaobject-loader.js +54 -0
- package/loaders/metaobject-loader.js.map +7 -0
- package/loaders/metaobjects-loader.d.ts +14 -0
- package/loaders/metaobjects-loader.js +60 -0
- package/loaders/metaobjects-loader.js.map +7 -0
- package/loaders/okendo-review-aggregate-loader.d.ts +17 -0
- package/loaders/okendo-review-aggregate-loader.js +56 -0
- package/loaders/okendo-review-aggregate-loader.js.map +7 -0
- package/loaders/okendo-reviews-loader.d.ts +23 -0
- package/loaders/okendo-reviews-loader.js +54 -0
- package/loaders/okendo-reviews-loader.js.map +7 -0
- package/loaders/prefetch-loaders.d.ts +33 -0
- package/loaders/prefetch-loaders.js +46 -0
- package/loaders/prefetch-loaders.js.map +7 -0
- package/loaders/preview-placeholder.d.ts +25 -0
- package/loaders/preview-placeholder.js +222 -0
- package/loaders/preview-placeholder.js.map +7 -0
- package/loaders/product-loader-args.d.ts +21 -0
- package/loaders/product-loader-args.js +17 -0
- package/loaders/product-loader-args.js.map +7 -0
- package/loaders/product-loader.d.ts +10 -0
- package/loaders/product-loader.js +52 -0
- package/loaders/product-loader.js.map +7 -0
- package/loaders/rebuy-recommendations-loader.d.ts +165 -0
- package/loaders/rebuy-recommendations-loader.js +57 -0
- package/loaders/rebuy-recommendations-loader.js.map +7 -0
- package/loaders/reviews-io-review-aggregate-loader.d.ts +12 -0
- package/loaders/reviews-io-review-aggregate-loader.js +43 -0
- package/loaders/reviews-io-review-aggregate-loader.js.map +7 -0
- package/loaders/reviews-io-reviews-loader.d.ts +14 -0
- package/loaders/reviews-io-reviews-loader.js +65 -0
- package/loaders/reviews-io-reviews-loader.js.map +7 -0
- package/loaders/smile-earning-rules-loader.d.ts +19 -0
- package/loaders/smile-earning-rules-loader.js +44 -0
- package/loaders/smile-earning-rules-loader.js.map +7 -0
- package/loaders/smile-rewards-loader.d.ts +19 -0
- package/loaders/smile-rewards-loader.js +44 -0
- package/loaders/smile-rewards-loader.js.map +7 -0
- package/loaders/smile-vip-tiers-loader.d.ts +18 -0
- package/loaders/smile-vip-tiers-loader.js +43 -0
- package/loaders/smile-vip-tiers-loader.js.map +7 -0
- package/loaders/statsig-experiment-loader.d.ts +20 -0
- package/loaders/statsig-experiment-loader.js +81 -0
- package/loaders/statsig-experiment-loader.js.map +7 -0
- package/loaders/yotpo-review-aggregate-loader.d.ts +12 -0
- package/loaders/yotpo-review-aggregate-loader.js +50 -0
- package/loaders/yotpo-review-aggregate-loader.js.map +7 -0
- package/loaders/yotpo-reviews-loader.d.ts +14 -0
- package/loaders/yotpo-reviews-loader.js +65 -0
- package/loaders/yotpo-reviews-loader.js.map +7 -0
- package/money.d.ts +9 -0
- package/money.js +13 -0
- package/money.js.map +7 -0
- package/next/config.d.ts +4 -0
- package/next/config.js +91 -0
- package/next/config.js.map +7 -0
- package/next/image-loader.d.ts +2 -0
- package/next/image-loader.js +52 -0
- package/next/image-loader.js.map +7 -0
- package/next/open-next.d.ts +2 -0
- package/next/open-next.js +24 -0
- package/next/open-next.js.map +7 -0
- package/orders/order-status-schema.d.ts +161 -0
- package/orders/order-status-schema.js +83 -0
- package/orders/order-status-schema.js.map +7 -0
- package/orders/order-status.d.ts +11 -0
- package/orders/order-status.js +41 -0
- package/orders/order-status.js.map +7 -0
- package/package.json +216 -0
- package/providers/query-provider.d.ts +1 -0
- package/providers/query-provider.js +12 -0
- package/providers/query-provider.js.map +7 -0
- package/providers/replo-provider.d.ts +1 -0
- package/providers/replo-provider.js +22 -0
- 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 {};
|