@setgo/sdk 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.
@@ -1,15 +1,12 @@
1
- "use strict";
2
1
  /**
3
2
  * SetGo Client - main SDK entry point
4
3
  */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.SetGoClient = void 0;
7
- const repository_js_1 = require("./repository.js");
8
- const metrics_reporter_js_1 = require("./metrics-reporter.js");
9
- const strategy_evaluator_js_1 = require("./strategy-evaluator.js");
10
- const index_js_1 = require("../errors/index.js");
4
+ import { FeatureRepository } from './repository.js';
5
+ import { MetricsReporter } from './metrics-reporter.js';
6
+ import { StrategyEvaluator } from './strategy-evaluator.js';
7
+ import { ConfigurationError, NetworkError, AuthenticationError, TimeoutError, } from '../errors/index.js';
11
8
  const SDK_VERSION = '1.0.0';
12
- class SetGoClient {
9
+ export class SetGoClient {
13
10
  config;
14
11
  repository;
15
12
  metricsReporter;
@@ -32,9 +29,9 @@ class SetGoClient {
32
29
  timeout: config.timeout ?? 10000,
33
30
  disableMetrics: config.disableMetrics ?? false,
34
31
  };
35
- this.repository = new repository_js_1.FeatureRepository();
36
- this.metricsReporter = new metrics_reporter_js_1.MetricsReporter(this.config);
37
- this.evaluator = new strategy_evaluator_js_1.StrategyEvaluator();
32
+ this.repository = new FeatureRepository();
33
+ this.metricsReporter = new MetricsReporter(this.config);
34
+ this.evaluator = new StrategyEvaluator();
38
35
  // Initialize event maps
39
36
  this.events.set('ready', new Set());
40
37
  this.events.set('update', new Set());
@@ -45,13 +42,13 @@ class SetGoClient {
45
42
  */
46
43
  validateConfig(config) {
47
44
  if (!config.baseUrl) {
48
- throw new index_js_1.ConfigurationError('baseUrl is required');
45
+ throw new ConfigurationError('baseUrl is required');
49
46
  }
50
47
  if (!config.token) {
51
- throw new index_js_1.ConfigurationError('token is required');
48
+ throw new ConfigurationError('token is required');
52
49
  }
53
50
  if (!config.appName) {
54
- throw new index_js_1.ConfigurationError('appName is required');
51
+ throw new ConfigurationError('appName is required');
55
52
  }
56
53
  }
57
54
  /**
@@ -206,23 +203,23 @@ class SetGoClient {
206
203
  return response;
207
204
  }
208
205
  if (response.status === 401 || response.status === 403) {
209
- throw new index_js_1.AuthenticationError();
206
+ throw new AuthenticationError();
210
207
  }
211
208
  if (!response.ok) {
212
- throw new index_js_1.NetworkError(`Request failed: ${response.statusText}`, response.status);
209
+ throw new NetworkError(`Request failed: ${response.statusText}`, response.status);
213
210
  }
214
211
  return response;
215
212
  }
216
213
  catch (error) {
217
214
  if (error instanceof Error && error.name === 'AbortError') {
218
- throw new index_js_1.TimeoutError();
215
+ throw new TimeoutError();
219
216
  }
220
- if (error instanceof index_js_1.NetworkError ||
221
- error instanceof index_js_1.AuthenticationError ||
222
- error instanceof index_js_1.TimeoutError) {
217
+ if (error instanceof NetworkError ||
218
+ error instanceof AuthenticationError ||
219
+ error instanceof TimeoutError) {
223
220
  throw error;
224
221
  }
225
- throw new index_js_1.NetworkError(`Request failed: ${error instanceof Error ? error.message : 'Unknown error'}`, undefined, error instanceof Error ? error : undefined);
222
+ throw new NetworkError(`Request failed: ${error instanceof Error ? error.message : 'Unknown error'}`, undefined, error instanceof Error ? error : undefined);
226
223
  }
227
224
  finally {
228
225
  clearTimeout(timeoutId);
@@ -316,4 +313,3 @@ class SetGoClient {
316
313
  }
317
314
  }
318
315
  }
319
- exports.SetGoClient = SetGoClient;
@@ -1,14 +1,7 @@
1
- "use strict";
2
1
  /**
3
2
  * SetGo SDK Core - Re-exports
4
3
  */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.MetricsReporter = exports.StrategyEvaluator = exports.FeatureRepository = exports.SetGoClient = void 0;
7
- var client_js_1 = require("./client.js");
8
- Object.defineProperty(exports, "SetGoClient", { enumerable: true, get: function () { return client_js_1.SetGoClient; } });
9
- var repository_js_1 = require("./repository.js");
10
- Object.defineProperty(exports, "FeatureRepository", { enumerable: true, get: function () { return repository_js_1.FeatureRepository; } });
11
- var strategy_evaluator_js_1 = require("./strategy-evaluator.js");
12
- Object.defineProperty(exports, "StrategyEvaluator", { enumerable: true, get: function () { return strategy_evaluator_js_1.StrategyEvaluator; } });
13
- var metrics_reporter_js_1 = require("./metrics-reporter.js");
14
- Object.defineProperty(exports, "MetricsReporter", { enumerable: true, get: function () { return metrics_reporter_js_1.MetricsReporter; } });
4
+ export { SetGoClient } from './client.js';
5
+ export { FeatureRepository } from './repository.js';
6
+ export { StrategyEvaluator } from './strategy-evaluator.js';
7
+ export { MetricsReporter } from './metrics-reporter.js';
@@ -1,11 +1,8 @@
1
- "use strict";
2
1
  /**
3
2
  * Metrics Reporter - collects and sends usage metrics
4
3
  */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.MetricsReporter = void 0;
7
- const index_js_1 = require("../errors/index.js");
8
- class MetricsReporter {
4
+ import { NetworkError, TimeoutError } from '../errors/index.js';
5
+ export class MetricsReporter {
9
6
  metrics = new Map();
10
7
  bucketStart;
11
8
  sendInterval;
@@ -126,17 +123,17 @@ class MetricsReporter {
126
123
  signal: controller.signal,
127
124
  });
128
125
  if (!response.ok) {
129
- throw new index_js_1.NetworkError(`Failed to send metrics: ${response.statusText}`, response.status);
126
+ throw new NetworkError(`Failed to send metrics: ${response.statusText}`, response.status);
130
127
  }
131
128
  }
132
129
  catch (error) {
133
130
  if (error instanceof Error && error.name === 'AbortError') {
134
- throw new index_js_1.TimeoutError('Metrics request timed out');
131
+ throw new TimeoutError('Metrics request timed out');
135
132
  }
136
- if (error instanceof index_js_1.NetworkError) {
133
+ if (error instanceof NetworkError) {
137
134
  throw error;
138
135
  }
139
- throw new index_js_1.NetworkError(`Failed to send metrics: ${error instanceof Error ? error.message : 'Unknown error'}`, undefined, error instanceof Error ? error : undefined);
136
+ throw new NetworkError(`Failed to send metrics: ${error instanceof Error ? error.message : 'Unknown error'}`, undefined, error instanceof Error ? error : undefined);
140
137
  }
141
138
  finally {
142
139
  clearTimeout(timeoutId);
@@ -149,4 +146,3 @@ class MetricsReporter {
149
146
  return this.metrics.size;
150
147
  }
151
148
  }
152
- exports.MetricsReporter = MetricsReporter;
@@ -1,10 +1,7 @@
1
- "use strict";
2
1
  /**
3
2
  * In-memory feature repository
4
3
  */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.FeatureRepository = void 0;
7
- class FeatureRepository {
4
+ export class FeatureRepository {
8
5
  features = new Map();
9
6
  version = 0;
10
7
  /**
@@ -55,4 +52,3 @@ class FeatureRepository {
55
52
  this.version = 0;
56
53
  }
57
54
  }
58
- exports.FeatureRepository = FeatureRepository;
@@ -1,12 +1,9 @@
1
- "use strict";
2
1
  /**
3
2
  * Strategy Evaluator - evaluates feature flag strategies locally
4
3
  */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.StrategyEvaluator = void 0;
7
- const murmurhash_js_1 = require("../utils/murmurhash.js");
8
- const ip_matcher_js_1 = require("../utils/ip-matcher.js");
9
- class StrategyEvaluator {
4
+ import { normalizedHash } from '../utils/murmurhash.js';
5
+ import { matchIPList } from '../utils/ip-matcher.js';
6
+ export class StrategyEvaluator {
10
7
  /**
11
8
  * Evaluate a single strategy
12
9
  */
@@ -69,7 +66,7 @@ class StrategyEvaluator {
69
66
  // If no identifier available, use random for this evaluation
70
67
  identifier = Math.random().toString();
71
68
  }
72
- const hash = (0, murmurhash_js_1.normalizedHash)(groupId, identifier, 100);
69
+ const hash = normalizedHash(groupId, identifier, 100);
73
70
  return hash <= percentage;
74
71
  }
75
72
  /**
@@ -113,7 +110,7 @@ class StrategyEvaluator {
113
110
  if (!identifier) {
114
111
  identifier = Math.random().toString();
115
112
  }
116
- const hash = (0, murmurhash_js_1.normalizedHash)(groupId, identifier, 100);
113
+ const hash = normalizedHash(groupId, identifier, 100);
117
114
  return hash <= rollout;
118
115
  }
119
116
  /**
@@ -126,7 +123,7 @@ class StrategyEvaluator {
126
123
  const ips = params?.ips ?? [];
127
124
  if (ips.length === 0)
128
125
  return false;
129
- return (0, ip_matcher_js_1.matchIPList)(context.remoteAddress, ips);
126
+ return matchIPList(context.remoteAddress, ips);
130
127
  }
131
128
  /**
132
129
  * Check if context satisfies all constraints
@@ -206,4 +203,3 @@ class StrategyEvaluator {
206
203
  }
207
204
  }
208
205
  }
209
- exports.StrategyEvaluator = StrategyEvaluator;
@@ -1,10 +1,7 @@
1
- "use strict";
2
1
  /**
3
2
  * SetGo SDK Error Classes
4
3
  */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.TimeoutError = exports.AuthenticationError = exports.ConfigurationError = exports.NetworkError = exports.SetGoError = void 0;
7
- class SetGoError extends Error {
4
+ export class SetGoError extends Error {
8
5
  code;
9
6
  constructor(message, code) {
10
7
  super(message);
@@ -13,8 +10,7 @@ class SetGoError extends Error {
13
10
  Object.setPrototypeOf(this, SetGoError.prototype);
14
11
  }
15
12
  }
16
- exports.SetGoError = SetGoError;
17
- class NetworkError extends SetGoError {
13
+ export class NetworkError extends SetGoError {
18
14
  statusCode;
19
15
  cause;
20
16
  constructor(message, statusCode, cause) {
@@ -25,28 +21,24 @@ class NetworkError extends SetGoError {
25
21
  Object.setPrototypeOf(this, NetworkError.prototype);
26
22
  }
27
23
  }
28
- exports.NetworkError = NetworkError;
29
- class ConfigurationError extends SetGoError {
24
+ export class ConfigurationError extends SetGoError {
30
25
  constructor(message) {
31
26
  super(message, 'CONFIGURATION_ERROR');
32
27
  this.name = 'ConfigurationError';
33
28
  Object.setPrototypeOf(this, ConfigurationError.prototype);
34
29
  }
35
30
  }
36
- exports.ConfigurationError = ConfigurationError;
37
- class AuthenticationError extends SetGoError {
31
+ export class AuthenticationError extends SetGoError {
38
32
  constructor(message = 'Invalid or expired API token') {
39
33
  super(message, 'AUTHENTICATION_ERROR');
40
34
  this.name = 'AuthenticationError';
41
35
  Object.setPrototypeOf(this, AuthenticationError.prototype);
42
36
  }
43
37
  }
44
- exports.AuthenticationError = AuthenticationError;
45
- class TimeoutError extends SetGoError {
38
+ export class TimeoutError extends SetGoError {
46
39
  constructor(message = 'Request timed out') {
47
40
  super(message, 'TIMEOUT_ERROR');
48
41
  this.name = 'TimeoutError';
49
42
  Object.setPrototypeOf(this, TimeoutError.prototype);
50
43
  }
51
44
  }
52
- exports.TimeoutError = TimeoutError;
package/dist/index.d.ts CHANGED
@@ -22,4 +22,5 @@ export { SetGoClient } from './core/index.js';
22
22
  export type { SetGoConfig, ResolvedSetGoConfig, FeatureContext, Feature, Strategy, StrategyType, FeaturesResponse, SetGoEventType, SetGoEventHandler, SetGoReadyEvent, SetGoUpdateEvent, SetGoErrorEvent, SetGoEvent, FeatureMetric, MetricsPayload, RegisterPayload, SetGoModuleAsyncOptions, } from './types/index.js';
23
23
  export { SetGoError, NetworkError, ConfigurationError, AuthenticationError, TimeoutError, } from './errors/index.js';
24
24
  export { FeatureRepository, StrategyEvaluator, MetricsReporter } from './core/index.js';
25
+ export { SetGoModule, SetGoService, SETGO_CONFIG, SETGO_CLIENT } from './nestjs/index.js';
25
26
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9C,YAAY,EACV,WAAW,EACX,mBAAmB,EACnB,cAAc,EACd,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,aAAa,EACb,cAAc,EACd,eAAe,EACf,uBAAuB,GACxB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,UAAU,EACV,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,GACb,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9C,YAAY,EACV,WAAW,EACX,mBAAmB,EACnB,cAAc,EACd,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,aAAa,EACb,cAAc,EACd,eAAe,EACf,uBAAuB,GACxB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,UAAU,EACV,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,GACb,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGxF,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * SetGo SDK - Feature Flag Management
4
3
  *
@@ -19,20 +18,11 @@
19
18
  * }
20
19
  * ```
21
20
  */
22
- Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.MetricsReporter = exports.StrategyEvaluator = exports.FeatureRepository = exports.TimeoutError = exports.AuthenticationError = exports.ConfigurationError = exports.NetworkError = exports.SetGoError = exports.SetGoClient = void 0;
24
21
  // Main client
25
- var index_js_1 = require("./core/index.js");
26
- Object.defineProperty(exports, "SetGoClient", { enumerable: true, get: function () { return index_js_1.SetGoClient; } });
22
+ export { SetGoClient } from './core/index.js';
27
23
  // Errors
28
- var index_js_2 = require("./errors/index.js");
29
- Object.defineProperty(exports, "SetGoError", { enumerable: true, get: function () { return index_js_2.SetGoError; } });
30
- Object.defineProperty(exports, "NetworkError", { enumerable: true, get: function () { return index_js_2.NetworkError; } });
31
- Object.defineProperty(exports, "ConfigurationError", { enumerable: true, get: function () { return index_js_2.ConfigurationError; } });
32
- Object.defineProperty(exports, "AuthenticationError", { enumerable: true, get: function () { return index_js_2.AuthenticationError; } });
33
- Object.defineProperty(exports, "TimeoutError", { enumerable: true, get: function () { return index_js_2.TimeoutError; } });
24
+ export { SetGoError, NetworkError, ConfigurationError, AuthenticationError, TimeoutError, } from './errors/index.js';
34
25
  // Internal (for advanced usage)
35
- var index_js_3 = require("./core/index.js");
36
- Object.defineProperty(exports, "FeatureRepository", { enumerable: true, get: function () { return index_js_3.FeatureRepository; } });
37
- Object.defineProperty(exports, "StrategyEvaluator", { enumerable: true, get: function () { return index_js_3.StrategyEvaluator; } });
38
- Object.defineProperty(exports, "MetricsReporter", { enumerable: true, get: function () { return index_js_3.MetricsReporter; } });
26
+ export { FeatureRepository, StrategyEvaluator, MetricsReporter } from './core/index.js';
27
+ // NestJS Module (optional - only available when @nestjs/common is installed)
28
+ export { SetGoModule, SetGoService, SETGO_CONFIG, SETGO_CLIENT } from './nestjs/index.js';
@@ -1,13 +1,6 @@
1
- "use strict";
2
1
  /**
3
2
  * SetGo NestJS Module Exports
4
3
  */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.SETGO_CLIENT = exports.SETGO_CONFIG = exports.SetGoService = exports.SetGoModule = void 0;
7
- var setgo_module_js_1 = require("./setgo.module.js");
8
- Object.defineProperty(exports, "SetGoModule", { enumerable: true, get: function () { return setgo_module_js_1.SetGoModule; } });
9
- var setgo_service_js_1 = require("./setgo.service.js");
10
- Object.defineProperty(exports, "SetGoService", { enumerable: true, get: function () { return setgo_service_js_1.SetGoService; } });
11
- var setgo_constants_js_1 = require("./setgo.constants.js");
12
- Object.defineProperty(exports, "SETGO_CONFIG", { enumerable: true, get: function () { return setgo_constants_js_1.SETGO_CONFIG; } });
13
- Object.defineProperty(exports, "SETGO_CLIENT", { enumerable: true, get: function () { return setgo_constants_js_1.SETGO_CLIENT; } });
4
+ export { SetGoModule } from './setgo.module.js';
5
+ export { SetGoService } from './setgo.service.js';
6
+ export { SETGO_CONFIG, SETGO_CLIENT } from './setgo.constants.js';
@@ -1,8 +1,5 @@
1
- "use strict";
2
1
  /**
3
2
  * SetGo NestJS Module Constants
4
3
  */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.SETGO_CLIENT = exports.SETGO_CONFIG = void 0;
7
- exports.SETGO_CONFIG = Symbol('SETGO_CONFIG');
8
- exports.SETGO_CLIENT = Symbol('SETGO_CLIENT');
4
+ export const SETGO_CONFIG = Symbol('SETGO_CONFIG');
5
+ export const SETGO_CLIENT = Symbol('SETGO_CLIENT');
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * SetGo NestJS Module
4
3
  */
@@ -9,11 +8,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
9
8
  return c > 3 && r && Object.defineProperty(target, key, r), r;
10
9
  };
11
10
  var SetGoModule_1;
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.SetGoModule = void 0;
14
- const common_1 = require("@nestjs/common");
15
- const setgo_constants_js_1 = require("./setgo.constants.js");
16
- const setgo_service_js_1 = require("./setgo.service.js");
11
+ import { Module } from '@nestjs/common';
12
+ import { SETGO_CONFIG } from './setgo.constants.js';
13
+ import { SetGoService } from './setgo.service.js';
17
14
  let SetGoModule = SetGoModule_1 = class SetGoModule {
18
15
  /**
19
16
  * Register the module with static configuration
@@ -24,12 +21,12 @@ let SetGoModule = SetGoModule_1 = class SetGoModule {
24
21
  global: true,
25
22
  providers: [
26
23
  {
27
- provide: setgo_constants_js_1.SETGO_CONFIG,
24
+ provide: SETGO_CONFIG,
28
25
  useValue: config,
29
26
  },
30
- setgo_service_js_1.SetGoService,
27
+ SetGoService,
31
28
  ],
32
- exports: [setgo_service_js_1.SetGoService],
29
+ exports: [SetGoService],
33
30
  };
34
31
  }
35
32
  /**
@@ -41,8 +38,8 @@ let SetGoModule = SetGoModule_1 = class SetGoModule {
41
38
  module: SetGoModule_1,
42
39
  global: true,
43
40
  imports: options.imports,
44
- providers: [...asyncProviders, setgo_service_js_1.SetGoService],
45
- exports: [setgo_service_js_1.SetGoService],
41
+ providers: [...asyncProviders, SetGoService],
42
+ exports: [SetGoService],
46
43
  };
47
44
  }
48
45
  /**
@@ -51,14 +48,14 @@ let SetGoModule = SetGoModule_1 = class SetGoModule {
51
48
  static createAsyncProviders(options) {
52
49
  return [
53
50
  {
54
- provide: setgo_constants_js_1.SETGO_CONFIG,
51
+ provide: SETGO_CONFIG,
55
52
  useFactory: options.useFactory,
56
53
  inject: options.inject,
57
54
  },
58
55
  ];
59
56
  }
60
57
  };
61
- exports.SetGoModule = SetGoModule;
62
- exports.SetGoModule = SetGoModule = SetGoModule_1 = __decorate([
63
- (0, common_1.Module)({})
58
+ SetGoModule = SetGoModule_1 = __decorate([
59
+ Module({})
64
60
  ], SetGoModule);
61
+ export { SetGoModule };
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * SetGo NestJS Service
4
3
  */
@@ -15,16 +14,14 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
15
14
  return function (target, key) { decorator(target, key, paramIndex); }
16
15
  };
17
16
  var SetGoService_1;
18
- Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.SetGoService = void 0;
20
- const common_1 = require("@nestjs/common");
21
- const index_js_1 = require("../core/index.js");
22
- const setgo_constants_js_1 = require("./setgo.constants.js");
17
+ import { Inject, Injectable, Logger } from '@nestjs/common';
18
+ import { SetGoClient } from '../core/index.js';
19
+ import { SETGO_CONFIG } from './setgo.constants.js';
23
20
  let SetGoService = SetGoService_1 = class SetGoService {
24
21
  client;
25
- logger = new common_1.Logger(SetGoService_1.name);
22
+ logger = new Logger(SetGoService_1.name);
26
23
  constructor(config) {
27
- this.client = new index_js_1.SetGoClient(config);
24
+ this.client = new SetGoClient(config);
28
25
  }
29
26
  async onModuleInit() {
30
27
  try {
@@ -76,9 +73,9 @@ let SetGoService = SetGoService_1 = class SetGoService {
76
73
  return this.client;
77
74
  }
78
75
  };
79
- exports.SetGoService = SetGoService;
80
- exports.SetGoService = SetGoService = SetGoService_1 = __decorate([
81
- (0, common_1.Injectable)(),
82
- __param(0, (0, common_1.Inject)(setgo_constants_js_1.SETGO_CONFIG)),
76
+ SetGoService = SetGoService_1 = __decorate([
77
+ Injectable(),
78
+ __param(0, Inject(SETGO_CONFIG)),
83
79
  __metadata("design:paramtypes", [Object])
84
80
  ], SetGoService);
81
+ export { SetGoService };
@@ -1,5 +1,4 @@
1
- "use strict";
2
1
  /**
3
2
  * SetGo SDK Configuration Types
4
3
  */
5
- Object.defineProperty(exports, "__esModule", { value: true });
4
+ export {};
@@ -1,5 +1,4 @@
1
- "use strict";
2
1
  /**
3
2
  * SetGo SDK Event Types
4
3
  */
5
- Object.defineProperty(exports, "__esModule", { value: true });
4
+ export {};
@@ -1,5 +1,4 @@
1
- "use strict";
2
1
  /**
3
2
  * SetGo SDK Feature Types
4
3
  */
5
- Object.defineProperty(exports, "__esModule", { value: true });
4
+ export {};
@@ -1,5 +1,4 @@
1
- "use strict";
2
1
  /**
3
2
  * SetGo SDK Types - Re-exports
4
3
  */
5
- Object.defineProperty(exports, "__esModule", { value: true });
4
+ export {};
@@ -1,5 +1,4 @@
1
- "use strict";
2
1
  /**
3
2
  * SetGo SDK Metrics Types
4
3
  */
5
- Object.defineProperty(exports, "__esModule", { value: true });
4
+ export {};
@@ -1,12 +1,5 @@
1
- "use strict";
2
1
  /**
3
2
  * Utility functions
4
3
  */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.matchIPList = exports.matchIP = exports.normalizedHash = exports.murmurhash3 = void 0;
7
- var murmurhash_js_1 = require("./murmurhash.js");
8
- Object.defineProperty(exports, "murmurhash3", { enumerable: true, get: function () { return murmurhash_js_1.murmurhash3; } });
9
- Object.defineProperty(exports, "normalizedHash", { enumerable: true, get: function () { return murmurhash_js_1.normalizedHash; } });
10
- var ip_matcher_js_1 = require("./ip-matcher.js");
11
- Object.defineProperty(exports, "matchIP", { enumerable: true, get: function () { return ip_matcher_js_1.matchIP; } });
12
- Object.defineProperty(exports, "matchIPList", { enumerable: true, get: function () { return ip_matcher_js_1.matchIPList; } });
4
+ export { murmurhash3, normalizedHash } from './murmurhash.js';
5
+ export { matchIP, matchIPList } from './ip-matcher.js';
@@ -1,11 +1,7 @@
1
- "use strict";
2
1
  /**
3
2
  * IP Address Matcher Utility
4
3
  * Supports exact IPs, CIDR notation, and wildcards
5
4
  */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.matchIP = matchIP;
8
- exports.matchIPList = matchIPList;
9
5
  function parseIPv4(ip) {
10
6
  const parts = ip.split('.');
11
7
  if (parts.length !== 4)
@@ -131,7 +127,7 @@ function matchExact(ip, pattern) {
131
127
  * Check if an IP address matches a pattern
132
128
  * Supports: exact match, CIDR notation, wildcards (*)
133
129
  */
134
- function matchIP(ip, pattern) {
130
+ export function matchIP(ip, pattern) {
135
131
  const parsedIP = parseIP(ip);
136
132
  if (!parsedIP)
137
133
  return false;
@@ -160,6 +156,6 @@ function matchIP(ip, pattern) {
160
156
  /**
161
157
  * Check if an IP matches any pattern in the list
162
158
  */
163
- function matchIPList(ip, patterns) {
159
+ export function matchIPList(ip, patterns) {
164
160
  return patterns.some((pattern) => matchIP(ip, pattern));
165
161
  }
@@ -1,12 +1,8 @@
1
- "use strict";
2
1
  /**
3
2
  * MurmurHash3 implementation for consistent hashing
4
3
  * Used for gradual rollout percentages
5
4
  */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.murmurhash3 = murmurhash3;
8
- exports.normalizedHash = normalizedHash;
9
- function murmurhash3(key, seed = 0) {
5
+ export function murmurhash3(key, seed = 0) {
10
6
  const remainder = key.length & 3;
11
7
  const bytes = key.length - remainder;
12
8
  let h1 = seed;
@@ -52,7 +48,7 @@ function murmurhash3(key, seed = 0) {
52
48
  /**
53
49
  * Normalize hash to a percentage (0-100)
54
50
  */
55
- function normalizedHash(groupId, identifier, normalizer = 100) {
51
+ export function normalizedHash(groupId, identifier, normalizer = 100) {
56
52
  const key = `${groupId}:${identifier}`;
57
53
  const hash = murmurhash3(key);
58
54
  return (hash % normalizer) + 1;
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@setgo/sdk",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "SDK oficial do SetGo Feature Flags",
5
5
  "license": "UNLICENSED",
6
6
  "author": "Scoder Tech",
7
+ "type": "module",
7
8
  "repository": {
8
9
  "type": "git",
9
10
  "url": "git+https://github.com/Scoder-Tech/SetGo-SDK.git"
@@ -29,11 +30,13 @@
29
30
  "types": "./dist/index.d.ts",
30
31
  "exports": {
31
32
  ".": {
32
- "types": "./src/index.ts",
33
+ "types": "./dist/index.d.ts",
34
+ "import": "./dist/index.js",
33
35
  "default": "./dist/index.js"
34
36
  },
35
37
  "./nestjs": {
36
- "types": "./src/nestjs/index.ts",
38
+ "types": "./dist/nestjs/index.d.ts",
39
+ "import": "./dist/nestjs/index.js",
37
40
  "default": "./dist/nestjs/index.js"
38
41
  }
39
42
  },