@interval/sdk
Advanced tools
Comparing version 0.25.1 to 0.25.2
@@ -19,3 +19,3 @@ /// <reference types="node" /> | ||
get isConnected(): boolean; | ||
handleActionsChange(config: InternalConfig): void; | ||
handleActionsChange(config?: InternalConfig): void; | ||
listen(): Promise<void>; | ||
@@ -22,0 +22,0 @@ private initializeConnection; |
@@ -39,3 +39,3 @@ "use strict"; | ||
}; | ||
var _IntervalClient_instances, _IntervalClient_interval, _IntervalClient_ghostOrgId, _IntervalClient_apiKey, _IntervalClient_endpoint, _IntervalClient_httpEndpoint, _IntervalClient_logger, _IntervalClient_retryIntervalMs, _IntervalClient_pingIntervalMs, _IntervalClient_closeUnresponsiveConnectionTimeoutMs, _IntervalClient_reinitializeBatchTimeoutMs, _IntervalClient_pingIntervalHandle, _IntervalClient_intentionallyClosed, _IntervalClient_actionDefinitions, _IntervalClient_groupDefinitions, _IntervalClient_actionHandlers, _IntervalClient_walkActions, _IntervalClient_log_get, _IntervalClient_ioResponseHandlers, _IntervalClient_pendingIOCalls, _IntervalClient_transactionLoadingStates, _IntervalClient_transactionCompleteCallbacks, _IntervalClient_ws, _IntervalClient_serverRpc, _IntervalClient_isConnected, _IntervalClient_isInitialized, _IntervalClient_reinitializeTimeout, _IntervalClient_resendPendingIOCalls, _IntervalClient_resendTransactionLoadingStates, _IntervalClient_findOrCreateGhostModeAccount, _IntervalClient_createSocketConnection, _IntervalClient_createRPCClient, _IntervalClient_initializeHost, _IntervalClient_send, _IntervalClient_sendLog; | ||
var _IntervalClient_instances, _IntervalClient_interval, _IntervalClient_ghostOrgId, _IntervalClient_apiKey, _IntervalClient_endpoint, _IntervalClient_httpEndpoint, _IntervalClient_logger, _IntervalClient_retryIntervalMs, _IntervalClient_pingIntervalMs, _IntervalClient_closeUnresponsiveConnectionTimeoutMs, _IntervalClient_reinitializeBatchTimeoutMs, _IntervalClient_pingIntervalHandle, _IntervalClient_intentionallyClosed, _IntervalClient_config, _IntervalClient_actionDefinitions, _IntervalClient_groupDefinitions, _IntervalClient_actionHandlers, _IntervalClient_walkActions, _IntervalClient_log_get, _IntervalClient_ioResponseHandlers, _IntervalClient_pendingIOCalls, _IntervalClient_transactionLoadingStates, _IntervalClient_transactionCompleteCallbacks, _IntervalClient_ws, _IntervalClient_serverRpc, _IntervalClient_isConnected, _IntervalClient_isInitialized, _IntervalClient_reinitializeTimeout, _IntervalClient_resendPendingIOCalls, _IntervalClient_resendTransactionLoadingStates, _IntervalClient_findOrCreateGhostModeAccount, _IntervalClient_createSocketConnection, _IntervalClient_createRPCClient, _IntervalClient_initializeHost, _IntervalClient_send, _IntervalClient_sendLog; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -88,2 +88,3 @@ exports.actionLocalStorage = exports.sleep = exports.getHttpEndpoint = exports.DEFAULT_WEBSOCKET_ENDPOINT = void 0; | ||
_IntervalClient_intentionallyClosed.set(this, false); | ||
_IntervalClient_config.set(this, void 0); | ||
_IntervalClient_actionDefinitions.set(this, []); | ||
@@ -104,6 +105,6 @@ _IntervalClient_groupDefinitions.set(this, []); | ||
__classPrivateFieldSet(this, _IntervalClient_logger, new Logger_1.default(config.logLevel), "f"); | ||
__classPrivateFieldSet(this, _IntervalClient_config, config, "f"); | ||
if (config.endpoint) { | ||
__classPrivateFieldSet(this, _IntervalClient_endpoint, config.endpoint, "f"); | ||
} | ||
__classPrivateFieldGet(this, _IntervalClient_instances, "m", _IntervalClient_walkActions).call(this, config); | ||
if (config.retryIntervalMs && config.retryIntervalMs > 0) { | ||
@@ -129,5 +130,7 @@ __classPrivateFieldSet(this, _IntervalClient_retryIntervalMs, config.retryIntervalMs, "f"); | ||
handleActionsChange(config) { | ||
if (config !== undefined) { | ||
__classPrivateFieldSet(this, _IntervalClient_config, config, "f"); | ||
} | ||
if (__classPrivateFieldGet(this, _IntervalClient_isInitialized, "f") && !__classPrivateFieldGet(this, _IntervalClient_reinitializeTimeout, "f")) { | ||
__classPrivateFieldSet(this, _IntervalClient_reinitializeTimeout, setTimeout(async () => { | ||
__classPrivateFieldGet(this, _IntervalClient_instances, "m", _IntervalClient_walkActions).call(this, config); | ||
await __classPrivateFieldGet(this, _IntervalClient_instances, "m", _IntervalClient_initializeHost).call(this); | ||
@@ -139,6 +142,2 @@ __classPrivateFieldSet(this, _IntervalClient_reinitializeTimeout, null, "f"); | ||
async listen() { | ||
if (__classPrivateFieldGet(this, _IntervalClient_actionDefinitions, "f").length === 0) { | ||
__classPrivateFieldGet(this, _IntervalClient_instances, "a", _IntervalClient_log_get).prod('Calling listen() with no defined actions is a no-op, skipping'); | ||
return; | ||
} | ||
await this.initializeConnection(); | ||
@@ -237,8 +236,8 @@ await __classPrivateFieldGet(this, _IntervalClient_instances, "m", _IntervalClient_initializeHost).call(this); | ||
exports.default = IntervalClient; | ||
_IntervalClient_interval = new WeakMap(), _IntervalClient_ghostOrgId = new WeakMap(), _IntervalClient_apiKey = new WeakMap(), _IntervalClient_endpoint = new WeakMap(), _IntervalClient_httpEndpoint = new WeakMap(), _IntervalClient_logger = new WeakMap(), _IntervalClient_retryIntervalMs = new WeakMap(), _IntervalClient_pingIntervalMs = new WeakMap(), _IntervalClient_closeUnresponsiveConnectionTimeoutMs = new WeakMap(), _IntervalClient_reinitializeBatchTimeoutMs = new WeakMap(), _IntervalClient_pingIntervalHandle = new WeakMap(), _IntervalClient_intentionallyClosed = new WeakMap(), _IntervalClient_actionDefinitions = new WeakMap(), _IntervalClient_groupDefinitions = new WeakMap(), _IntervalClient_actionHandlers = new WeakMap(), _IntervalClient_ioResponseHandlers = new WeakMap(), _IntervalClient_pendingIOCalls = new WeakMap(), _IntervalClient_transactionLoadingStates = new WeakMap(), _IntervalClient_transactionCompleteCallbacks = new WeakMap(), _IntervalClient_ws = new WeakMap(), _IntervalClient_serverRpc = new WeakMap(), _IntervalClient_isConnected = new WeakMap(), _IntervalClient_isInitialized = new WeakMap(), _IntervalClient_reinitializeTimeout = new WeakMap(), _IntervalClient_instances = new WeakSet(), _IntervalClient_walkActions = function _IntervalClient_walkActions(config) { | ||
_IntervalClient_interval = new WeakMap(), _IntervalClient_ghostOrgId = new WeakMap(), _IntervalClient_apiKey = new WeakMap(), _IntervalClient_endpoint = new WeakMap(), _IntervalClient_httpEndpoint = new WeakMap(), _IntervalClient_logger = new WeakMap(), _IntervalClient_retryIntervalMs = new WeakMap(), _IntervalClient_pingIntervalMs = new WeakMap(), _IntervalClient_closeUnresponsiveConnectionTimeoutMs = new WeakMap(), _IntervalClient_reinitializeBatchTimeoutMs = new WeakMap(), _IntervalClient_pingIntervalHandle = new WeakMap(), _IntervalClient_intentionallyClosed = new WeakMap(), _IntervalClient_config = new WeakMap(), _IntervalClient_actionDefinitions = new WeakMap(), _IntervalClient_groupDefinitions = new WeakMap(), _IntervalClient_actionHandlers = new WeakMap(), _IntervalClient_ioResponseHandlers = new WeakMap(), _IntervalClient_pendingIOCalls = new WeakMap(), _IntervalClient_transactionLoadingStates = new WeakMap(), _IntervalClient_transactionCompleteCallbacks = new WeakMap(), _IntervalClient_ws = new WeakMap(), _IntervalClient_serverRpc = new WeakMap(), _IntervalClient_isConnected = new WeakMap(), _IntervalClient_isInitialized = new WeakMap(), _IntervalClient_reinitializeTimeout = new WeakMap(), _IntervalClient_instances = new WeakSet(), _IntervalClient_walkActions = function _IntervalClient_walkActions() { | ||
const groupDefinitions = []; | ||
const actionDefinitions = []; | ||
const actionHandlers = {}; | ||
if (config.actions) { | ||
for (const [slug, def] of Object.entries(config.actions)) { | ||
if (__classPrivateFieldGet(this, _IntervalClient_config, "f").actions) { | ||
for (const [slug, def] of Object.entries(__classPrivateFieldGet(this, _IntervalClient_config, "f").actions)) { | ||
actionDefinitions.push({ | ||
@@ -252,3 +251,3 @@ slug, | ||
} | ||
if (config.groups) { | ||
if (__classPrivateFieldGet(this, _IntervalClient_config, "f").groups) { | ||
function walkActionGroup(groupSlug, group) { | ||
@@ -273,3 +272,3 @@ groupDefinitions.push({ | ||
} | ||
for (const [groupSlug, group] of Object.entries(config.groups)) { | ||
for (const [groupSlug, group] of Object.entries(__classPrivateFieldGet(this, _IntervalClient_config, "f").groups)) { | ||
walkActionGroup(groupSlug, group); | ||
@@ -650,10 +649,8 @@ } | ||
} | ||
const actions = __classPrivateFieldGet(this, _IntervalClient_actionDefinitions, "f"); | ||
if (actions.length === 0) { | ||
__classPrivateFieldGet(this, _IntervalClient_instances, "a", _IntervalClient_log_get).prod('No actions defined, skipping host initialization'); | ||
return; | ||
} | ||
const isInitialInitialization = !__classPrivateFieldGet(this, _IntervalClient_isInitialized, "f"); | ||
__classPrivateFieldSet(this, _IntervalClient_isInitialized, true, "f"); | ||
__classPrivateFieldGet(this, _IntervalClient_instances, "m", _IntervalClient_walkActions).call(this); | ||
const response = await __classPrivateFieldGet(this, _IntervalClient_instances, "m", _IntervalClient_send).call(this, 'INITIALIZE_HOST', { | ||
apiKey: __classPrivateFieldGet(this, _IntervalClient_apiKey, "f"), | ||
actions, | ||
actions: __classPrivateFieldGet(this, _IntervalClient_actionDefinitions, "f"), | ||
groups: __classPrivateFieldGet(this, _IntervalClient_groupDefinitions, "f"), | ||
@@ -680,12 +677,8 @@ sdkName: pkg.name, | ||
__classPrivateFieldGet(this, _IntervalClient_instances, "a", _IntervalClient_log_get).warn('\nAction slugs must contain only letters, numbers, underscores, periods, and hyphens.'); | ||
if (response.invalidSlugs.length === actions.length) { | ||
throw new __1.IntervalError('No valid slugs provided'); | ||
} | ||
} | ||
this.organization = response.organization; | ||
this.environment = response.environment; | ||
if (!__classPrivateFieldGet(this, _IntervalClient_isInitialized, "f")) { | ||
if (isInitialInitialization) { | ||
__classPrivateFieldGet(this, _IntervalClient_instances, "a", _IntervalClient_log_get).prod(`🔗 Connected! Access your actions at: ${response.dashboardUrl}`); | ||
__classPrivateFieldGet(this, _IntervalClient_instances, "a", _IntervalClient_log_get).debug('Host ID:', __classPrivateFieldGet(this, _IntervalClient_ws, "f").id); | ||
__classPrivateFieldSet(this, _IntervalClient_isInitialized, true, "f"); | ||
} | ||
@@ -692,0 +685,0 @@ } |
{ | ||
"name": "@interval/sdk", | ||
"version": "0.25.1", | ||
"version": "0.25.2", | ||
"homepage": "https://interval.com", | ||
@@ -5,0 +5,0 @@ "repository": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
513326
11811