@superleapai/flow-ui 2.5.14 → 2.5.15
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/core/superleapClient.js +3 -77
- package/dist/superleap-flow.min.js +2 -2
- package/index.js +5 -14
- package/package.json +1 -1
package/core/superleapClient.js
CHANGED
|
@@ -13,79 +13,15 @@
|
|
|
13
13
|
var _config = null;
|
|
14
14
|
var _sdkInstance = null;
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* Default config merged with user config when calling init().
|
|
18
|
-
* Matches SuperLeapSDK constructor defaults (sdk.js).
|
|
19
|
-
*/
|
|
20
|
-
var DEFAULT_CONFIG = {
|
|
21
|
-
apiKey: "NWM2MGEZMDMTYME2YI0ZYZDHLTLKNWQTNDM3NDNIZDU3YTQ1",
|
|
22
|
-
baseUrl: "https://razorpay-sandbox.superleap.dev/api/v1",
|
|
23
|
-
clientId: "",
|
|
24
|
-
clientSecret: "",
|
|
25
|
-
cache: {
|
|
26
|
-
enabled: true,
|
|
27
|
-
maxSize: 1000,
|
|
28
|
-
defaultTTL: 5 * 60 * 1000,
|
|
29
|
-
ttl: {
|
|
30
|
-
schema: 30 * 60 * 1000,
|
|
31
|
-
records: 2 * 60 * 1000,
|
|
32
|
-
count: 60 * 1000,
|
|
33
|
-
user: 10 * 60 * 1000,
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Deep-merge source into target (only own enumerable properties; arrays replaced, not merged).
|
|
40
|
-
*/
|
|
41
|
-
function mergeConfig(target, source) {
|
|
42
|
-
if (!source || typeof source !== "object") return target;
|
|
43
|
-
var result = {};
|
|
44
|
-
var key;
|
|
45
|
-
for (key in target) {
|
|
46
|
-
if (Object.prototype.hasOwnProperty.call(target, key)) {
|
|
47
|
-
result[key] = target[key];
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
for (key in source) {
|
|
51
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
52
|
-
var s = source[key];
|
|
53
|
-
var t = result[key];
|
|
54
|
-
if (
|
|
55
|
-
t &&
|
|
56
|
-
s &&
|
|
57
|
-
typeof t === "object" &&
|
|
58
|
-
typeof s === "object" &&
|
|
59
|
-
!Array.isArray(t) &&
|
|
60
|
-
!Array.isArray(s)
|
|
61
|
-
) {
|
|
62
|
-
result[key] = mergeConfig(t, s);
|
|
63
|
-
} else {
|
|
64
|
-
result[key] = s;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return result;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
16
|
/**
|
|
72
17
|
* Initialize the client with API config. Call this before using record-select or other SDK-dependent components.
|
|
73
|
-
* Config is merged with defaults; you can pass only baseUrl and apiKey.
|
|
74
18
|
*
|
|
75
19
|
* @param {Object} config - Options passed to createSuperLeapSDK (same as SuperLeapSDK constructor in sdk.js)
|
|
76
|
-
* @param {string}
|
|
77
|
-
* @param {string}
|
|
20
|
+
* @param {string} config.apiKey - Bearer token for authentication
|
|
21
|
+
* @param {string} config.baseUrl - Base URL for API
|
|
78
22
|
* @param {string} [config.clientId] - Client ID (if using client credentials)
|
|
79
23
|
* @param {string} [config.clientSecret] - Client secret (if using client credentials)
|
|
80
24
|
* @param {Object} [config.cache] - Cache configuration
|
|
81
|
-
* @param {boolean} [config.cache.enabled] - Enable caching (default: true)
|
|
82
|
-
* @param {number} [config.cache.maxSize] - Max cache entries (default: 1000)
|
|
83
|
-
* @param {number} [config.cache.defaultTTL] - Default TTL in ms (default: 5 minutes)
|
|
84
|
-
* @param {Object} [config.cache.ttl] - TTL per operation
|
|
85
|
-
* @param {number} [config.cache.ttl.schema] - Schema cache TTL (default: 30 min)
|
|
86
|
-
* @param {number} [config.cache.ttl.records] - Record query cache TTL (default: 2 min)
|
|
87
|
-
* @param {number} [config.cache.ttl.count] - Count query cache TTL (default: 1 min)
|
|
88
|
-
* @param {number} [config.cache.ttl.user] - User/me cache TTL (default: 10 min)
|
|
89
25
|
*/
|
|
90
26
|
function init(config) {
|
|
91
27
|
if (config == null) {
|
|
@@ -94,7 +30,7 @@
|
|
|
94
30
|
return;
|
|
95
31
|
}
|
|
96
32
|
|
|
97
|
-
_config =
|
|
33
|
+
_config = config;
|
|
98
34
|
|
|
99
35
|
// Create SDK instance using the SDK factory if available
|
|
100
36
|
if (typeof global.createSuperLeapSDK === "function") {
|
|
@@ -128,15 +64,6 @@
|
|
|
128
64
|
return _config != null && _sdkInstance != null;
|
|
129
65
|
}
|
|
130
66
|
|
|
131
|
-
/**
|
|
132
|
-
* Return the default config object (for reference or to override specific keys).
|
|
133
|
-
*
|
|
134
|
-
* @returns {Object}
|
|
135
|
-
*/
|
|
136
|
-
function getDefaultConfig() {
|
|
137
|
-
return mergeConfig({}, DEFAULT_CONFIG);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
67
|
/**
|
|
141
68
|
* Return the current base URL (from merged config after init).
|
|
142
69
|
* Used by file-input and other components that build API URLs.
|
|
@@ -152,7 +79,6 @@
|
|
|
152
79
|
init: init,
|
|
153
80
|
getSdk: getSdk,
|
|
154
81
|
isAvailable: isAvailable,
|
|
155
|
-
getDefaultConfig: getDefaultConfig,
|
|
156
82
|
getBaseUrl: getBaseUrl,
|
|
157
83
|
};
|
|
158
84
|
|