@unboundcx/sdk-internal 1.0.3 → 1.0.6

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 (2) hide show
  1. package/index.js +31 -24
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -11,44 +11,54 @@ export class InternalSDK {
11
11
  constructor(sdk, buildMasterApiAuthFn) {
12
12
  this.sdk = sdk;
13
13
  this.buildMasterApiAuthFn = buildMasterApiAuthFn;
14
-
15
- // Internal services under 'internal' namespace to avoid conflicts
16
- this.internal = {
17
- sip: new InternalSipService(sdk),
18
- email: new InternalEmailService(sdk),
19
- programmableVoice: new InternalProgrammableVoiceService(sdk),
20
- servers: new InternalServersService(sdk),
21
- socket: new InternalSocketService(sdk),
22
- };
23
-
14
+
15
+ // Internal services as direct properties for your setup
16
+ this.sip = new InternalSipService(sdk);
17
+ this.email = new InternalEmailService(sdk);
18
+ this.programmableVoice = new InternalProgrammableVoiceService(sdk);
19
+ this.servers = new InternalServersService(sdk);
20
+ this.socket = new InternalSocketService(sdk);
21
+
24
22
  // Proxy all base SDK properties and methods
25
23
  this._proxyBaseSDK();
26
24
  }
27
-
25
+
28
26
  _proxyBaseSDK() {
29
27
  // Get all properties from the base SDK
30
28
  const baseSdkProto = Object.getPrototypeOf(this.sdk);
31
29
  const baseSdkProps = Object.getOwnPropertyNames(this.sdk);
32
30
  const baseSdkMethods = Object.getOwnPropertyNames(baseSdkProto);
33
-
31
+
34
32
  // Proxy all instance properties (services like storage, messaging, etc.)
35
- baseSdkProps.forEach(prop => {
33
+ baseSdkProps.forEach((prop) => {
36
34
  if (prop !== 'constructor' && !this.hasOwnProperty(prop)) {
37
35
  Object.defineProperty(this, prop, {
38
36
  get: () => this.sdk[prop],
39
- set: (value) => { this.sdk[prop] = value; },
37
+ set: (value) => {
38
+ this.sdk[prop] = value;
39
+ },
40
40
  enumerable: true,
41
- configurable: true
41
+ configurable: true,
42
42
  });
43
43
  }
44
44
  });
45
-
45
+
46
46
  // Proxy all prototype methods, but don't override methods that already exist in InternalSDK
47
- baseSdkMethods.forEach(method => {
48
- if (method !== 'constructor' &&
49
- typeof this.sdk[method] === 'function' &&
50
- !this.hasOwnProperty(method) &&
51
- !InternalSDK.prototype.hasOwnProperty(method)) {
47
+ baseSdkMethods.forEach((method) => {
48
+ if (
49
+ method !== 'constructor' &&
50
+ typeof this.sdk[method] === 'function' &&
51
+ !this.hasOwnProperty(method) &&
52
+ !InternalSDK.prototype.hasOwnProperty(method)
53
+ ) {
54
+ this[method] = (...args) => this.sdk[method](...args);
55
+ }
56
+ });
57
+
58
+ // Explicitly proxy critical methods that might be missed
59
+ const criticalMethods = ['setToken', 'setNamespace', 'use', 'extend'];
60
+ criticalMethods.forEach((method) => {
61
+ if (typeof this.sdk[method] === 'function' && !this[method]) {
52
62
  this[method] = (...args) => this.sdk[method](...args);
53
63
  }
54
64
  });
@@ -89,9 +99,6 @@ export function install(sdk, buildMasterApiAuthFn) {
89
99
 
90
100
  // Add buildMasterAuth to the main SDK instance
91
101
  sdk.buildMasterAuth = internal.buildMasterAuth.bind(internal);
92
-
93
- // Add internal services
94
- sdk.internal = internal.internal;
95
102
  }
96
103
 
97
104
  // Default export for ease of use
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unboundcx/sdk-internal",
3
- "version": "1.0.3",
3
+ "version": "1.0.6",
4
4
  "description": "Internal SDK extension for Unbound - Provides access to internal APIs and administrative functions",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -60,4 +60,4 @@
60
60
  "registry": "https://registry.npmjs.org/",
61
61
  "access": "restricted"
62
62
  }
63
- }
63
+ }