@relyio/sdk 0.2.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 (45) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/LICENSE +201 -0
  3. package/README.md +314 -0
  4. package/dist/.tsbuildinfo +1 -0
  5. package/dist/chunk-2QUK2ZGD.js +738 -0
  6. package/dist/chunk-7W4MJXQ4.cjs +4429 -0
  7. package/dist/chunk-FJK7ZWKK.cjs +776 -0
  8. package/dist/chunk-HT6NFRM2.cjs +196 -0
  9. package/dist/chunk-I3ESNANB.js +177 -0
  10. package/dist/chunk-IY5LSKXU.js +3 -0
  11. package/dist/chunk-MWMSFIWN.cjs +17 -0
  12. package/dist/chunk-PPA2WWOH.cjs +4 -0
  13. package/dist/chunk-RJBIJ2ZK.js +4375 -0
  14. package/dist/chunk-XQ4QHWZE.js +13 -0
  15. package/dist/client/index.cjs +17 -0
  16. package/dist/client/index.d.cts +3 -0
  17. package/dist/client/index.d.ts +3 -0
  18. package/dist/client/index.js +4 -0
  19. package/dist/define-schema-DHvUCKwj.d.cts +2101 -0
  20. package/dist/define-schema-DHvUCKwj.d.ts +2101 -0
  21. package/dist/index-B-KiFHbx.d.ts +2708 -0
  22. package/dist/index-BsUqCAu8.d.cts +7855 -0
  23. package/dist/index-BsUqCAu8.d.ts +7855 -0
  24. package/dist/index-DGWaawHt.d.cts +2708 -0
  25. package/dist/index.cjs +499 -0
  26. package/dist/index.d.cts +523 -0
  27. package/dist/index.d.ts +523 -0
  28. package/dist/index.js +148 -0
  29. package/dist/react/index.cjs +4 -0
  30. package/dist/react/index.d.cts +2 -0
  31. package/dist/react/index.d.ts +2 -0
  32. package/dist/react/index.js +3 -0
  33. package/dist/schema/index.cjs +157 -0
  34. package/dist/schema/index.d.cts +223 -0
  35. package/dist/schema/index.d.ts +223 -0
  36. package/dist/schema/index.js +4 -0
  37. package/dist/types/index.cjs +6 -0
  38. package/dist/types/index.d.cts +1 -0
  39. package/dist/types/index.d.ts +1 -0
  40. package/dist/types/index.js +3 -0
  41. package/dist/utils/index.cjs +81 -0
  42. package/dist/utils/index.d.cts +87 -0
  43. package/dist/utils/index.d.ts +87 -0
  44. package/dist/utils/index.js +4 -0
  45. package/package.json +159 -0
@@ -0,0 +1,196 @@
1
+ 'use strict';
2
+
3
+ var chunkMWMSFIWN_cjs = require('./chunk-MWMSFIWN.cjs');
4
+
5
+ /* RelyIO SDK - Built with ❤️ by the RelyIO Team */
6
+
7
+ // src/utils/index.ts
8
+ function isBrowser() {
9
+ return typeof window !== "undefined" && typeof window.document !== "undefined";
10
+ }
11
+ chunkMWMSFIWN_cjs.__name(isBrowser, "isBrowser");
12
+ function isNode() {
13
+ return typeof process !== "undefined" && process.versions?.node != null;
14
+ }
15
+ chunkMWMSFIWN_cjs.__name(isNode, "isNode");
16
+ function deepClone(obj) {
17
+ if (obj === null || typeof obj !== "object") return obj;
18
+ if (obj instanceof Date) return new Date(obj.getTime());
19
+ if (obj instanceof Array) return obj.map((item) => deepClone(item));
20
+ if (typeof obj === "object") {
21
+ const clonedObj = {};
22
+ for (const key in obj) {
23
+ clonedObj[key] = deepClone(obj[key]);
24
+ }
25
+ return clonedObj;
26
+ }
27
+ return obj;
28
+ }
29
+ chunkMWMSFIWN_cjs.__name(deepClone, "deepClone");
30
+ function debounce(func, wait) {
31
+ let timeout;
32
+ return (...args) => {
33
+ clearTimeout(timeout);
34
+ timeout = setTimeout(() => func(...args), wait);
35
+ };
36
+ }
37
+ chunkMWMSFIWN_cjs.__name(debounce, "debounce");
38
+ function throttle(func, limit) {
39
+ let inThrottle;
40
+ return (...args) => {
41
+ if (!inThrottle) {
42
+ func(...args);
43
+ inThrottle = true;
44
+ setTimeout(() => inThrottle = false, limit);
45
+ }
46
+ };
47
+ }
48
+ chunkMWMSFIWN_cjs.__name(throttle, "throttle");
49
+ function createDeferred() {
50
+ let resolve;
51
+ let reject;
52
+ const promise = new Promise((_value, _reason) => {
53
+ resolve = _value;
54
+ reject = _reason;
55
+ });
56
+ return { promise, resolve, reject };
57
+ }
58
+ chunkMWMSFIWN_cjs.__name(createDeferred, "createDeferred");
59
+ function sleep(ms) {
60
+ return new Promise((resolve) => setTimeout(resolve, ms));
61
+ }
62
+ chunkMWMSFIWN_cjs.__name(sleep, "sleep");
63
+ async function retry(fn, options = {}) {
64
+ const {
65
+ maxAttempts = 3,
66
+ baseDelay = 1e3,
67
+ maxDelay = 1e4,
68
+ backoffFactor = 2,
69
+ jitter = true
70
+ } = options;
71
+ let lastError;
72
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
73
+ try {
74
+ return await fn();
75
+ } catch (error) {
76
+ lastError = error;
77
+ if (attempt === maxAttempts) {
78
+ throw lastError;
79
+ }
80
+ const exponentialDelay = baseDelay * Math.pow(backoffFactor, attempt - 1);
81
+ const delay = Math.min(exponentialDelay, maxDelay);
82
+ const finalDelay = jitter ? delay * (0.5 + Math.random() * 0.5) : delay;
83
+ await sleep(finalDelay);
84
+ }
85
+ }
86
+ throw lastError;
87
+ }
88
+ chunkMWMSFIWN_cjs.__name(retry, "retry");
89
+ function toSafeString(value) {
90
+ if (value === null) return "null";
91
+ if (value === void 0) return "undefined";
92
+ if (typeof value === "string") return value;
93
+ if (typeof value === "number" || typeof value === "boolean") return String(value);
94
+ try {
95
+ return JSON.stringify(value);
96
+ } catch {
97
+ return "[object Object]";
98
+ }
99
+ }
100
+ chunkMWMSFIWN_cjs.__name(toSafeString, "toSafeString");
101
+ function generateId() {
102
+ return Math.random().toString(36).substring(2) + Date.now().toString(36);
103
+ }
104
+ chunkMWMSFIWN_cjs.__name(generateId, "generateId");
105
+ function isPlainObject(value) {
106
+ if (typeof value !== "object" || value === null) return false;
107
+ if (Object.prototype.toString.call(value) !== "[object Object]") return false;
108
+ if (Object.getPrototypeOf(value) === null) return true;
109
+ let proto = value;
110
+ while (Object.getPrototypeOf(proto) !== null) {
111
+ proto = Object.getPrototypeOf(proto);
112
+ }
113
+ return Object.getPrototypeOf(value) === proto;
114
+ }
115
+ chunkMWMSFIWN_cjs.__name(isPlainObject, "isPlainObject");
116
+ function mergeDeep(target, ...sources) {
117
+ if (!sources.length) return target;
118
+ const source = sources.shift();
119
+ if (isPlainObject(target) && isPlainObject(source)) {
120
+ for (const key in source) {
121
+ const sourceValue = source[key];
122
+ if (isPlainObject(sourceValue)) {
123
+ if (target[key] == null) Object.assign(target, { [key]: {} });
124
+ const targetValue = target[key];
125
+ if (isPlainObject(targetValue)) {
126
+ mergeDeep(targetValue, sourceValue);
127
+ }
128
+ } else {
129
+ Object.assign(target, { [key]: sourceValue });
130
+ }
131
+ }
132
+ }
133
+ return mergeDeep(target, ...sources);
134
+ }
135
+ chunkMWMSFIWN_cjs.__name(mergeDeep, "mergeDeep");
136
+ function pick(obj, keys) {
137
+ const result = {};
138
+ for (const key of keys) {
139
+ if (key in obj) {
140
+ result[key] = obj[key];
141
+ }
142
+ }
143
+ return result;
144
+ }
145
+ chunkMWMSFIWN_cjs.__name(pick, "pick");
146
+ function omit(obj, keys) {
147
+ const result = { ...obj };
148
+ for (const key of keys) {
149
+ delete result[key];
150
+ }
151
+ return result;
152
+ }
153
+ chunkMWMSFIWN_cjs.__name(omit, "omit");
154
+ function camelToSnake(str) {
155
+ return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
156
+ }
157
+ chunkMWMSFIWN_cjs.__name(camelToSnake, "camelToSnake");
158
+ function snakeToCamel(str) {
159
+ return str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
160
+ }
161
+ chunkMWMSFIWN_cjs.__name(snakeToCamel, "snakeToCamel");
162
+ function isValidEmail(email) {
163
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
164
+ return emailRegex.test(email);
165
+ }
166
+ chunkMWMSFIWN_cjs.__name(isValidEmail, "isValidEmail");
167
+ function isValidUrl(url) {
168
+ try {
169
+ new URL(url);
170
+ return true;
171
+ } catch {
172
+ return false;
173
+ }
174
+ }
175
+ chunkMWMSFIWN_cjs.__name(isValidUrl, "isValidUrl");
176
+
177
+ exports.camelToSnake = camelToSnake;
178
+ exports.createDeferred = createDeferred;
179
+ exports.debounce = debounce;
180
+ exports.deepClone = deepClone;
181
+ exports.generateId = generateId;
182
+ exports.isBrowser = isBrowser;
183
+ exports.isNode = isNode;
184
+ exports.isPlainObject = isPlainObject;
185
+ exports.isValidEmail = isValidEmail;
186
+ exports.isValidUrl = isValidUrl;
187
+ exports.mergeDeep = mergeDeep;
188
+ exports.omit = omit;
189
+ exports.pick = pick;
190
+ exports.retry = retry;
191
+ exports.sleep = sleep;
192
+ exports.snakeToCamel = snakeToCamel;
193
+ exports.throttle = throttle;
194
+ exports.toSafeString = toSafeString;
195
+ //# sourceMappingURL=chunk-HT6NFRM2.cjs.map
196
+ //# sourceMappingURL=chunk-HT6NFRM2.cjs.map
@@ -0,0 +1,177 @@
1
+ import { __name } from './chunk-XQ4QHWZE.js';
2
+
3
+ /* RelyIO SDK - Built with ❤️ by the RelyIO Team */
4
+
5
+ // src/utils/index.ts
6
+ function isBrowser() {
7
+ return typeof window !== "undefined" && typeof window.document !== "undefined";
8
+ }
9
+ __name(isBrowser, "isBrowser");
10
+ function isNode() {
11
+ return typeof process !== "undefined" && process.versions?.node != null;
12
+ }
13
+ __name(isNode, "isNode");
14
+ function deepClone(obj) {
15
+ if (obj === null || typeof obj !== "object") return obj;
16
+ if (obj instanceof Date) return new Date(obj.getTime());
17
+ if (obj instanceof Array) return obj.map((item) => deepClone(item));
18
+ if (typeof obj === "object") {
19
+ const clonedObj = {};
20
+ for (const key in obj) {
21
+ clonedObj[key] = deepClone(obj[key]);
22
+ }
23
+ return clonedObj;
24
+ }
25
+ return obj;
26
+ }
27
+ __name(deepClone, "deepClone");
28
+ function debounce(func, wait) {
29
+ let timeout;
30
+ return (...args) => {
31
+ clearTimeout(timeout);
32
+ timeout = setTimeout(() => func(...args), wait);
33
+ };
34
+ }
35
+ __name(debounce, "debounce");
36
+ function throttle(func, limit) {
37
+ let inThrottle;
38
+ return (...args) => {
39
+ if (!inThrottle) {
40
+ func(...args);
41
+ inThrottle = true;
42
+ setTimeout(() => inThrottle = false, limit);
43
+ }
44
+ };
45
+ }
46
+ __name(throttle, "throttle");
47
+ function createDeferred() {
48
+ let resolve;
49
+ let reject;
50
+ const promise = new Promise((_value, _reason) => {
51
+ resolve = _value;
52
+ reject = _reason;
53
+ });
54
+ return { promise, resolve, reject };
55
+ }
56
+ __name(createDeferred, "createDeferred");
57
+ function sleep(ms) {
58
+ return new Promise((resolve) => setTimeout(resolve, ms));
59
+ }
60
+ __name(sleep, "sleep");
61
+ async function retry(fn, options = {}) {
62
+ const {
63
+ maxAttempts = 3,
64
+ baseDelay = 1e3,
65
+ maxDelay = 1e4,
66
+ backoffFactor = 2,
67
+ jitter = true
68
+ } = options;
69
+ let lastError;
70
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
71
+ try {
72
+ return await fn();
73
+ } catch (error) {
74
+ lastError = error;
75
+ if (attempt === maxAttempts) {
76
+ throw lastError;
77
+ }
78
+ const exponentialDelay = baseDelay * Math.pow(backoffFactor, attempt - 1);
79
+ const delay = Math.min(exponentialDelay, maxDelay);
80
+ const finalDelay = jitter ? delay * (0.5 + Math.random() * 0.5) : delay;
81
+ await sleep(finalDelay);
82
+ }
83
+ }
84
+ throw lastError;
85
+ }
86
+ __name(retry, "retry");
87
+ function toSafeString(value) {
88
+ if (value === null) return "null";
89
+ if (value === void 0) return "undefined";
90
+ if (typeof value === "string") return value;
91
+ if (typeof value === "number" || typeof value === "boolean") return String(value);
92
+ try {
93
+ return JSON.stringify(value);
94
+ } catch {
95
+ return "[object Object]";
96
+ }
97
+ }
98
+ __name(toSafeString, "toSafeString");
99
+ function generateId() {
100
+ return Math.random().toString(36).substring(2) + Date.now().toString(36);
101
+ }
102
+ __name(generateId, "generateId");
103
+ function isPlainObject(value) {
104
+ if (typeof value !== "object" || value === null) return false;
105
+ if (Object.prototype.toString.call(value) !== "[object Object]") return false;
106
+ if (Object.getPrototypeOf(value) === null) return true;
107
+ let proto = value;
108
+ while (Object.getPrototypeOf(proto) !== null) {
109
+ proto = Object.getPrototypeOf(proto);
110
+ }
111
+ return Object.getPrototypeOf(value) === proto;
112
+ }
113
+ __name(isPlainObject, "isPlainObject");
114
+ function mergeDeep(target, ...sources) {
115
+ if (!sources.length) return target;
116
+ const source = sources.shift();
117
+ if (isPlainObject(target) && isPlainObject(source)) {
118
+ for (const key in source) {
119
+ const sourceValue = source[key];
120
+ if (isPlainObject(sourceValue)) {
121
+ if (target[key] == null) Object.assign(target, { [key]: {} });
122
+ const targetValue = target[key];
123
+ if (isPlainObject(targetValue)) {
124
+ mergeDeep(targetValue, sourceValue);
125
+ }
126
+ } else {
127
+ Object.assign(target, { [key]: sourceValue });
128
+ }
129
+ }
130
+ }
131
+ return mergeDeep(target, ...sources);
132
+ }
133
+ __name(mergeDeep, "mergeDeep");
134
+ function pick(obj, keys) {
135
+ const result = {};
136
+ for (const key of keys) {
137
+ if (key in obj) {
138
+ result[key] = obj[key];
139
+ }
140
+ }
141
+ return result;
142
+ }
143
+ __name(pick, "pick");
144
+ function omit(obj, keys) {
145
+ const result = { ...obj };
146
+ for (const key of keys) {
147
+ delete result[key];
148
+ }
149
+ return result;
150
+ }
151
+ __name(omit, "omit");
152
+ function camelToSnake(str) {
153
+ return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
154
+ }
155
+ __name(camelToSnake, "camelToSnake");
156
+ function snakeToCamel(str) {
157
+ return str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
158
+ }
159
+ __name(snakeToCamel, "snakeToCamel");
160
+ function isValidEmail(email) {
161
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
162
+ return emailRegex.test(email);
163
+ }
164
+ __name(isValidEmail, "isValidEmail");
165
+ function isValidUrl(url) {
166
+ try {
167
+ new URL(url);
168
+ return true;
169
+ } catch {
170
+ return false;
171
+ }
172
+ }
173
+ __name(isValidUrl, "isValidUrl");
174
+
175
+ export { camelToSnake, createDeferred, debounce, deepClone, generateId, isBrowser, isNode, isPlainObject, isValidEmail, isValidUrl, mergeDeep, omit, pick, retry, sleep, snakeToCamel, throttle, toSafeString };
176
+ //# sourceMappingURL=chunk-I3ESNANB.js.map
177
+ //# sourceMappingURL=chunk-I3ESNANB.js.map
@@ -0,0 +1,3 @@
1
+
2
+ //# sourceMappingURL=chunk-IY5LSKXU.js.map
3
+ //# sourceMappingURL=chunk-IY5LSKXU.js.map
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ /* RelyIO SDK - Built with ❤️ by the RelyIO Team */
4
+ var __defProp = Object.defineProperty;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
12
+
13
+ exports.__export = __export;
14
+ exports.__name = __name;
15
+ exports.__publicField = __publicField;
16
+ //# sourceMappingURL=chunk-MWMSFIWN.cjs.map
17
+ //# sourceMappingURL=chunk-MWMSFIWN.cjs.map
@@ -0,0 +1,4 @@
1
+ 'use strict';
2
+
3
+ //# sourceMappingURL=chunk-PPA2WWOH.cjs.map
4
+ //# sourceMappingURL=chunk-PPA2WWOH.cjs.map