@unboundcx/sdk-internal 1.0.1 → 1.0.3

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 +42 -12
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -11,11 +11,47 @@ export class InternalSDK {
11
11
  constructor(sdk, buildMasterApiAuthFn) {
12
12
  this.sdk = sdk;
13
13
  this.buildMasterApiAuthFn = buildMasterApiAuthFn;
14
- this.sip = new InternalSipService(sdk);
15
- this.email = new InternalEmailService(sdk);
16
- this.programmableVoice = new InternalProgrammableVoiceService(sdk);
17
- this.servers = new InternalServersService(sdk);
18
- this.socket = new InternalSocketService(sdk);
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
+
24
+ // Proxy all base SDK properties and methods
25
+ this._proxyBaseSDK();
26
+ }
27
+
28
+ _proxyBaseSDK() {
29
+ // Get all properties from the base SDK
30
+ const baseSdkProto = Object.getPrototypeOf(this.sdk);
31
+ const baseSdkProps = Object.getOwnPropertyNames(this.sdk);
32
+ const baseSdkMethods = Object.getOwnPropertyNames(baseSdkProto);
33
+
34
+ // Proxy all instance properties (services like storage, messaging, etc.)
35
+ baseSdkProps.forEach(prop => {
36
+ if (prop !== 'constructor' && !this.hasOwnProperty(prop)) {
37
+ Object.defineProperty(this, prop, {
38
+ get: () => this.sdk[prop],
39
+ set: (value) => { this.sdk[prop] = value; },
40
+ enumerable: true,
41
+ configurable: true
42
+ });
43
+ }
44
+ });
45
+
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)) {
52
+ this[method] = (...args) => this.sdk[method](...args);
53
+ }
54
+ });
19
55
  }
20
56
 
21
57
  // Master auth method - only available in Node.js
@@ -55,13 +91,7 @@ export function install(sdk, buildMasterApiAuthFn) {
55
91
  sdk.buildMasterAuth = internal.buildMasterAuth.bind(internal);
56
92
 
57
93
  // Add internal services
58
- sdk.internal = {
59
- sip: internal.sip,
60
- email: internal.email,
61
- programmableVoice: internal.programmableVoice,
62
- servers: internal.servers,
63
- socket: internal.socket,
64
- };
94
+ sdk.internal = internal.internal;
65
95
  }
66
96
 
67
97
  // 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.1",
3
+ "version": "1.0.3",
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",