@smplkit/sdk 1.5.5 → 1.5.7
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/dist/index.cjs +97 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +153 -0
- package/dist/index.d.ts +153 -0
- package/dist/index.js +97 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -308,6 +308,7 @@ interface components {
|
|
|
308
308
|
* "rules": []
|
|
309
309
|
* }
|
|
310
310
|
* },
|
|
311
|
+
* "managed": true,
|
|
311
312
|
* "name": "Dark Mode",
|
|
312
313
|
* "type": "BOOLEAN",
|
|
313
314
|
* "updated_at": "2026-03-27T10:00:00Z",
|
|
@@ -350,11 +351,92 @@ interface components {
|
|
|
350
351
|
environments?: {
|
|
351
352
|
[key: string]: components["schemas"]["FlagEnvironment"];
|
|
352
353
|
};
|
|
354
|
+
/**
|
|
355
|
+
* Managed
|
|
356
|
+
* @description True if admin-managed, false if auto-discovered
|
|
357
|
+
*/
|
|
358
|
+
managed?: boolean | null;
|
|
359
|
+
/** Sources */
|
|
360
|
+
readonly sources?: {
|
|
361
|
+
[key: string]: unknown;
|
|
362
|
+
}[] | null;
|
|
353
363
|
/** Created At */
|
|
354
364
|
readonly created_at?: string | null;
|
|
355
365
|
/** Updated At */
|
|
356
366
|
readonly updated_at?: string | null;
|
|
357
367
|
};
|
|
368
|
+
/**
|
|
369
|
+
* FlagBulkItem
|
|
370
|
+
* @example {
|
|
371
|
+
* "default": false,
|
|
372
|
+
* "environment": "production",
|
|
373
|
+
* "id": "dark-mode",
|
|
374
|
+
* "service": "api-gateway",
|
|
375
|
+
* "type": "BOOLEAN"
|
|
376
|
+
* }
|
|
377
|
+
*/
|
|
378
|
+
FlagBulkItem: {
|
|
379
|
+
/**
|
|
380
|
+
* Id
|
|
381
|
+
* @description Flag key as declared in code
|
|
382
|
+
*/
|
|
383
|
+
id: string;
|
|
384
|
+
/**
|
|
385
|
+
* Type
|
|
386
|
+
* @description Flag type: BOOLEAN, STRING, NUMERIC, or JSON
|
|
387
|
+
*/
|
|
388
|
+
type: string;
|
|
389
|
+
/**
|
|
390
|
+
* Default
|
|
391
|
+
* @description Default value declared in code
|
|
392
|
+
*/
|
|
393
|
+
default: unknown;
|
|
394
|
+
/**
|
|
395
|
+
* Service
|
|
396
|
+
* @description Service that declared this flag
|
|
397
|
+
*/
|
|
398
|
+
service?: string | null;
|
|
399
|
+
/**
|
|
400
|
+
* Environment
|
|
401
|
+
* @description Environment where observed
|
|
402
|
+
*/
|
|
403
|
+
environment?: string | null;
|
|
404
|
+
};
|
|
405
|
+
/**
|
|
406
|
+
* FlagBulkRequest
|
|
407
|
+
* @example {
|
|
408
|
+
* "flags": [
|
|
409
|
+
* {
|
|
410
|
+
* "default": false,
|
|
411
|
+
* "environment": "production",
|
|
412
|
+
* "id": "dark-mode",
|
|
413
|
+
* "service": "api-gateway",
|
|
414
|
+
* "type": "BOOLEAN"
|
|
415
|
+
* },
|
|
416
|
+
* {
|
|
417
|
+
* "default": 3,
|
|
418
|
+
* "environment": "production",
|
|
419
|
+
* "id": "max-retries",
|
|
420
|
+
* "service": "api-gateway",
|
|
421
|
+
* "type": "NUMERIC"
|
|
422
|
+
* }
|
|
423
|
+
* ]
|
|
424
|
+
* }
|
|
425
|
+
*/
|
|
426
|
+
FlagBulkRequest: {
|
|
427
|
+
/** Flags */
|
|
428
|
+
flags: components["schemas"]["FlagBulkItem"][];
|
|
429
|
+
};
|
|
430
|
+
/**
|
|
431
|
+
* FlagBulkResponse
|
|
432
|
+
* @example {
|
|
433
|
+
* "registered": 5
|
|
434
|
+
* }
|
|
435
|
+
*/
|
|
436
|
+
FlagBulkResponse: {
|
|
437
|
+
/** Registered */
|
|
438
|
+
registered: number;
|
|
439
|
+
};
|
|
358
440
|
/** FlagEnvironment */
|
|
359
441
|
FlagEnvironment: {
|
|
360
442
|
/**
|
|
@@ -396,6 +478,7 @@ interface components {
|
|
|
396
478
|
* ]
|
|
397
479
|
* }
|
|
398
480
|
* },
|
|
481
|
+
* "managed": true,
|
|
399
482
|
* "name": "Dark Mode",
|
|
400
483
|
* "type": "BOOLEAN",
|
|
401
484
|
* "updated_at": "2026-03-27T10:00:00Z",
|
|
@@ -439,6 +522,73 @@ interface components {
|
|
|
439
522
|
/** Value */
|
|
440
523
|
value: unknown;
|
|
441
524
|
};
|
|
525
|
+
/**
|
|
526
|
+
* FlagSource
|
|
527
|
+
* @example {
|
|
528
|
+
* "created_at": "2026-04-17T10:00:00Z",
|
|
529
|
+
* "data": {
|
|
530
|
+
* "default": true,
|
|
531
|
+
* "type": "BOOLEAN"
|
|
532
|
+
* },
|
|
533
|
+
* "environment": "production",
|
|
534
|
+
* "first_observed": "2026-04-17T10:00:00Z",
|
|
535
|
+
* "last_seen": "2026-04-17T15:30:00Z",
|
|
536
|
+
* "service": "api-gateway",
|
|
537
|
+
* "updated_at": "2026-04-17T15:30:00Z"
|
|
538
|
+
* }
|
|
539
|
+
*/
|
|
540
|
+
FlagSource: {
|
|
541
|
+
/** Service */
|
|
542
|
+
readonly service?: string;
|
|
543
|
+
/** Environment */
|
|
544
|
+
readonly environment?: string;
|
|
545
|
+
/** First Observed */
|
|
546
|
+
readonly first_observed?: string | null;
|
|
547
|
+
/** Last Seen */
|
|
548
|
+
readonly last_seen?: string | null;
|
|
549
|
+
/** Data */
|
|
550
|
+
readonly data?: {
|
|
551
|
+
[key: string]: unknown;
|
|
552
|
+
} | null;
|
|
553
|
+
/** Created At */
|
|
554
|
+
readonly created_at?: string | null;
|
|
555
|
+
/** Updated At */
|
|
556
|
+
readonly updated_at?: string | null;
|
|
557
|
+
};
|
|
558
|
+
/** FlagSourceListResponse */
|
|
559
|
+
FlagSourceListResponse: {
|
|
560
|
+
/** Data */
|
|
561
|
+
data: components["schemas"]["FlagSourceResource"][];
|
|
562
|
+
};
|
|
563
|
+
/**
|
|
564
|
+
* FlagSourceResource
|
|
565
|
+
* @example {
|
|
566
|
+
* "attributes": {
|
|
567
|
+
* "created_at": "2026-04-17T10:00:00Z",
|
|
568
|
+
* "data": {
|
|
569
|
+
* "default": true,
|
|
570
|
+
* "type": "BOOLEAN"
|
|
571
|
+
* },
|
|
572
|
+
* "environment": "production",
|
|
573
|
+
* "first_observed": "2026-04-17T10:00:00Z",
|
|
574
|
+
* "last_seen": "2026-04-17T15:30:00Z",
|
|
575
|
+
* "service": "api-gateway",
|
|
576
|
+
* "updated_at": "2026-04-17T15:30:00Z"
|
|
577
|
+
* },
|
|
578
|
+
* "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
|
|
579
|
+
* "type": "flag_source"
|
|
580
|
+
* }
|
|
581
|
+
*/
|
|
582
|
+
FlagSourceResource: {
|
|
583
|
+
/** Id */
|
|
584
|
+
id?: string | null;
|
|
585
|
+
/**
|
|
586
|
+
* Type
|
|
587
|
+
* @constant
|
|
588
|
+
*/
|
|
589
|
+
type: "flag_source";
|
|
590
|
+
attributes: components["schemas"]["FlagSource"];
|
|
591
|
+
};
|
|
442
592
|
/** FlagValue */
|
|
443
593
|
FlagValue: {
|
|
444
594
|
/** Name */
|
|
@@ -756,6 +906,8 @@ declare class FlagsClient {
|
|
|
756
906
|
private _cache;
|
|
757
907
|
private _contextProvider;
|
|
758
908
|
private _contextBuffer;
|
|
909
|
+
private _flagBuffer;
|
|
910
|
+
private _flagFlushTimer;
|
|
759
911
|
private _handles;
|
|
760
912
|
private _globalListeners;
|
|
761
913
|
private _keyListeners;
|
|
@@ -882,6 +1034,7 @@ declare class FlagsClient {
|
|
|
882
1034
|
private _fetchFlagsList;
|
|
883
1035
|
private _fireChangeListeners;
|
|
884
1036
|
private _fireChangeListenersAll;
|
|
1037
|
+
private _flushFlags;
|
|
885
1038
|
private _flushContexts;
|
|
886
1039
|
/** @internal */
|
|
887
1040
|
_resourceToModel(resource: FlagResource): Flag;
|
package/dist/index.d.ts
CHANGED
|
@@ -308,6 +308,7 @@ interface components {
|
|
|
308
308
|
* "rules": []
|
|
309
309
|
* }
|
|
310
310
|
* },
|
|
311
|
+
* "managed": true,
|
|
311
312
|
* "name": "Dark Mode",
|
|
312
313
|
* "type": "BOOLEAN",
|
|
313
314
|
* "updated_at": "2026-03-27T10:00:00Z",
|
|
@@ -350,11 +351,92 @@ interface components {
|
|
|
350
351
|
environments?: {
|
|
351
352
|
[key: string]: components["schemas"]["FlagEnvironment"];
|
|
352
353
|
};
|
|
354
|
+
/**
|
|
355
|
+
* Managed
|
|
356
|
+
* @description True if admin-managed, false if auto-discovered
|
|
357
|
+
*/
|
|
358
|
+
managed?: boolean | null;
|
|
359
|
+
/** Sources */
|
|
360
|
+
readonly sources?: {
|
|
361
|
+
[key: string]: unknown;
|
|
362
|
+
}[] | null;
|
|
353
363
|
/** Created At */
|
|
354
364
|
readonly created_at?: string | null;
|
|
355
365
|
/** Updated At */
|
|
356
366
|
readonly updated_at?: string | null;
|
|
357
367
|
};
|
|
368
|
+
/**
|
|
369
|
+
* FlagBulkItem
|
|
370
|
+
* @example {
|
|
371
|
+
* "default": false,
|
|
372
|
+
* "environment": "production",
|
|
373
|
+
* "id": "dark-mode",
|
|
374
|
+
* "service": "api-gateway",
|
|
375
|
+
* "type": "BOOLEAN"
|
|
376
|
+
* }
|
|
377
|
+
*/
|
|
378
|
+
FlagBulkItem: {
|
|
379
|
+
/**
|
|
380
|
+
* Id
|
|
381
|
+
* @description Flag key as declared in code
|
|
382
|
+
*/
|
|
383
|
+
id: string;
|
|
384
|
+
/**
|
|
385
|
+
* Type
|
|
386
|
+
* @description Flag type: BOOLEAN, STRING, NUMERIC, or JSON
|
|
387
|
+
*/
|
|
388
|
+
type: string;
|
|
389
|
+
/**
|
|
390
|
+
* Default
|
|
391
|
+
* @description Default value declared in code
|
|
392
|
+
*/
|
|
393
|
+
default: unknown;
|
|
394
|
+
/**
|
|
395
|
+
* Service
|
|
396
|
+
* @description Service that declared this flag
|
|
397
|
+
*/
|
|
398
|
+
service?: string | null;
|
|
399
|
+
/**
|
|
400
|
+
* Environment
|
|
401
|
+
* @description Environment where observed
|
|
402
|
+
*/
|
|
403
|
+
environment?: string | null;
|
|
404
|
+
};
|
|
405
|
+
/**
|
|
406
|
+
* FlagBulkRequest
|
|
407
|
+
* @example {
|
|
408
|
+
* "flags": [
|
|
409
|
+
* {
|
|
410
|
+
* "default": false,
|
|
411
|
+
* "environment": "production",
|
|
412
|
+
* "id": "dark-mode",
|
|
413
|
+
* "service": "api-gateway",
|
|
414
|
+
* "type": "BOOLEAN"
|
|
415
|
+
* },
|
|
416
|
+
* {
|
|
417
|
+
* "default": 3,
|
|
418
|
+
* "environment": "production",
|
|
419
|
+
* "id": "max-retries",
|
|
420
|
+
* "service": "api-gateway",
|
|
421
|
+
* "type": "NUMERIC"
|
|
422
|
+
* }
|
|
423
|
+
* ]
|
|
424
|
+
* }
|
|
425
|
+
*/
|
|
426
|
+
FlagBulkRequest: {
|
|
427
|
+
/** Flags */
|
|
428
|
+
flags: components["schemas"]["FlagBulkItem"][];
|
|
429
|
+
};
|
|
430
|
+
/**
|
|
431
|
+
* FlagBulkResponse
|
|
432
|
+
* @example {
|
|
433
|
+
* "registered": 5
|
|
434
|
+
* }
|
|
435
|
+
*/
|
|
436
|
+
FlagBulkResponse: {
|
|
437
|
+
/** Registered */
|
|
438
|
+
registered: number;
|
|
439
|
+
};
|
|
358
440
|
/** FlagEnvironment */
|
|
359
441
|
FlagEnvironment: {
|
|
360
442
|
/**
|
|
@@ -396,6 +478,7 @@ interface components {
|
|
|
396
478
|
* ]
|
|
397
479
|
* }
|
|
398
480
|
* },
|
|
481
|
+
* "managed": true,
|
|
399
482
|
* "name": "Dark Mode",
|
|
400
483
|
* "type": "BOOLEAN",
|
|
401
484
|
* "updated_at": "2026-03-27T10:00:00Z",
|
|
@@ -439,6 +522,73 @@ interface components {
|
|
|
439
522
|
/** Value */
|
|
440
523
|
value: unknown;
|
|
441
524
|
};
|
|
525
|
+
/**
|
|
526
|
+
* FlagSource
|
|
527
|
+
* @example {
|
|
528
|
+
* "created_at": "2026-04-17T10:00:00Z",
|
|
529
|
+
* "data": {
|
|
530
|
+
* "default": true,
|
|
531
|
+
* "type": "BOOLEAN"
|
|
532
|
+
* },
|
|
533
|
+
* "environment": "production",
|
|
534
|
+
* "first_observed": "2026-04-17T10:00:00Z",
|
|
535
|
+
* "last_seen": "2026-04-17T15:30:00Z",
|
|
536
|
+
* "service": "api-gateway",
|
|
537
|
+
* "updated_at": "2026-04-17T15:30:00Z"
|
|
538
|
+
* }
|
|
539
|
+
*/
|
|
540
|
+
FlagSource: {
|
|
541
|
+
/** Service */
|
|
542
|
+
readonly service?: string;
|
|
543
|
+
/** Environment */
|
|
544
|
+
readonly environment?: string;
|
|
545
|
+
/** First Observed */
|
|
546
|
+
readonly first_observed?: string | null;
|
|
547
|
+
/** Last Seen */
|
|
548
|
+
readonly last_seen?: string | null;
|
|
549
|
+
/** Data */
|
|
550
|
+
readonly data?: {
|
|
551
|
+
[key: string]: unknown;
|
|
552
|
+
} | null;
|
|
553
|
+
/** Created At */
|
|
554
|
+
readonly created_at?: string | null;
|
|
555
|
+
/** Updated At */
|
|
556
|
+
readonly updated_at?: string | null;
|
|
557
|
+
};
|
|
558
|
+
/** FlagSourceListResponse */
|
|
559
|
+
FlagSourceListResponse: {
|
|
560
|
+
/** Data */
|
|
561
|
+
data: components["schemas"]["FlagSourceResource"][];
|
|
562
|
+
};
|
|
563
|
+
/**
|
|
564
|
+
* FlagSourceResource
|
|
565
|
+
* @example {
|
|
566
|
+
* "attributes": {
|
|
567
|
+
* "created_at": "2026-04-17T10:00:00Z",
|
|
568
|
+
* "data": {
|
|
569
|
+
* "default": true,
|
|
570
|
+
* "type": "BOOLEAN"
|
|
571
|
+
* },
|
|
572
|
+
* "environment": "production",
|
|
573
|
+
* "first_observed": "2026-04-17T10:00:00Z",
|
|
574
|
+
* "last_seen": "2026-04-17T15:30:00Z",
|
|
575
|
+
* "service": "api-gateway",
|
|
576
|
+
* "updated_at": "2026-04-17T15:30:00Z"
|
|
577
|
+
* },
|
|
578
|
+
* "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
|
|
579
|
+
* "type": "flag_source"
|
|
580
|
+
* }
|
|
581
|
+
*/
|
|
582
|
+
FlagSourceResource: {
|
|
583
|
+
/** Id */
|
|
584
|
+
id?: string | null;
|
|
585
|
+
/**
|
|
586
|
+
* Type
|
|
587
|
+
* @constant
|
|
588
|
+
*/
|
|
589
|
+
type: "flag_source";
|
|
590
|
+
attributes: components["schemas"]["FlagSource"];
|
|
591
|
+
};
|
|
442
592
|
/** FlagValue */
|
|
443
593
|
FlagValue: {
|
|
444
594
|
/** Name */
|
|
@@ -756,6 +906,8 @@ declare class FlagsClient {
|
|
|
756
906
|
private _cache;
|
|
757
907
|
private _contextProvider;
|
|
758
908
|
private _contextBuffer;
|
|
909
|
+
private _flagBuffer;
|
|
910
|
+
private _flagFlushTimer;
|
|
759
911
|
private _handles;
|
|
760
912
|
private _globalListeners;
|
|
761
913
|
private _keyListeners;
|
|
@@ -882,6 +1034,7 @@ declare class FlagsClient {
|
|
|
882
1034
|
private _fetchFlagsList;
|
|
883
1035
|
private _fireChangeListeners;
|
|
884
1036
|
private _fireChangeListenersAll;
|
|
1037
|
+
private _flushFlags;
|
|
885
1038
|
private _flushContexts;
|
|
886
1039
|
/** @internal */
|
|
887
1040
|
_resourceToModel(resource: FlagResource): Flag;
|
package/dist/index.js
CHANGED
|
@@ -17538,6 +17538,8 @@ var APP_BASE_URL = "https://app.smplkit.com";
|
|
|
17538
17538
|
var CACHE_MAX_SIZE = 1e4;
|
|
17539
17539
|
var CONTEXT_REGISTRATION_LRU_SIZE = 1e4;
|
|
17540
17540
|
var CONTEXT_BATCH_FLUSH_SIZE = 100;
|
|
17541
|
+
var FLAG_REGISTRATION_FLUSH_SIZE = 50;
|
|
17542
|
+
var FLAG_REGISTRATION_FLUSH_INTERVAL_MS = 3e4;
|
|
17541
17543
|
async function checkError2(response, _context) {
|
|
17542
17544
|
const body = await response.text().catch(() => "");
|
|
17543
17545
|
throwForStatus(response.status, body);
|
|
@@ -17687,6 +17689,30 @@ var ContextRegistrationBuffer = class {
|
|
|
17687
17689
|
return this._pending.length;
|
|
17688
17690
|
}
|
|
17689
17691
|
};
|
|
17692
|
+
var FlagRegistrationBuffer = class {
|
|
17693
|
+
_seen = /* @__PURE__ */ new Set();
|
|
17694
|
+
_pending = [];
|
|
17695
|
+
add(id, type, defaultValue, service, environment) {
|
|
17696
|
+
if (!this._seen.has(id)) {
|
|
17697
|
+
this._seen.add(id);
|
|
17698
|
+
this._pending.push({
|
|
17699
|
+
id,
|
|
17700
|
+
type,
|
|
17701
|
+
default: defaultValue,
|
|
17702
|
+
service: service ?? void 0,
|
|
17703
|
+
environment: environment ?? void 0
|
|
17704
|
+
});
|
|
17705
|
+
}
|
|
17706
|
+
}
|
|
17707
|
+
drain() {
|
|
17708
|
+
const batch = this._pending;
|
|
17709
|
+
this._pending = [];
|
|
17710
|
+
return batch;
|
|
17711
|
+
}
|
|
17712
|
+
get pendingCount() {
|
|
17713
|
+
return this._pending.length;
|
|
17714
|
+
}
|
|
17715
|
+
};
|
|
17690
17716
|
var FlagsManagement = class {
|
|
17691
17717
|
constructor(_client) {
|
|
17692
17718
|
this._client = _client;
|
|
@@ -17736,6 +17762,8 @@ var FlagsClient = class {
|
|
|
17736
17762
|
_cache = new ResolutionCache();
|
|
17737
17763
|
_contextProvider = null;
|
|
17738
17764
|
_contextBuffer = new ContextRegistrationBuffer();
|
|
17765
|
+
_flagBuffer = new FlagRegistrationBuffer();
|
|
17766
|
+
_flagFlushTimer = null;
|
|
17739
17767
|
_handles = {};
|
|
17740
17768
|
_globalListeners = [];
|
|
17741
17769
|
_keyListeners = /* @__PURE__ */ new Map();
|
|
@@ -17963,6 +17991,16 @@ var FlagsClient = class {
|
|
|
17963
17991
|
updatedAt: null
|
|
17964
17992
|
});
|
|
17965
17993
|
this._handles[id] = handle;
|
|
17994
|
+
this._flagBuffer.add(
|
|
17995
|
+
id,
|
|
17996
|
+
"BOOLEAN",
|
|
17997
|
+
defaultValue,
|
|
17998
|
+
this._parent?._service ?? null,
|
|
17999
|
+
this._parent?._environment ?? null
|
|
18000
|
+
);
|
|
18001
|
+
if (this._flagBuffer.pendingCount >= FLAG_REGISTRATION_FLUSH_SIZE) {
|
|
18002
|
+
void this._flushFlags();
|
|
18003
|
+
}
|
|
17966
18004
|
return handle;
|
|
17967
18005
|
}
|
|
17968
18006
|
/** Declare a string flag handle for runtime evaluation. */
|
|
@@ -17979,6 +18017,16 @@ var FlagsClient = class {
|
|
|
17979
18017
|
updatedAt: null
|
|
17980
18018
|
});
|
|
17981
18019
|
this._handles[id] = handle;
|
|
18020
|
+
this._flagBuffer.add(
|
|
18021
|
+
id,
|
|
18022
|
+
"STRING",
|
|
18023
|
+
defaultValue,
|
|
18024
|
+
this._parent?._service ?? null,
|
|
18025
|
+
this._parent?._environment ?? null
|
|
18026
|
+
);
|
|
18027
|
+
if (this._flagBuffer.pendingCount >= FLAG_REGISTRATION_FLUSH_SIZE) {
|
|
18028
|
+
void this._flushFlags();
|
|
18029
|
+
}
|
|
17982
18030
|
return handle;
|
|
17983
18031
|
}
|
|
17984
18032
|
/** Declare a numeric flag handle for runtime evaluation. */
|
|
@@ -17995,6 +18043,16 @@ var FlagsClient = class {
|
|
|
17995
18043
|
updatedAt: null
|
|
17996
18044
|
});
|
|
17997
18045
|
this._handles[id] = handle;
|
|
18046
|
+
this._flagBuffer.add(
|
|
18047
|
+
id,
|
|
18048
|
+
"NUMERIC",
|
|
18049
|
+
defaultValue,
|
|
18050
|
+
this._parent?._service ?? null,
|
|
18051
|
+
this._parent?._environment ?? null
|
|
18052
|
+
);
|
|
18053
|
+
if (this._flagBuffer.pendingCount >= FLAG_REGISTRATION_FLUSH_SIZE) {
|
|
18054
|
+
void this._flushFlags();
|
|
18055
|
+
}
|
|
17998
18056
|
return handle;
|
|
17999
18057
|
}
|
|
18000
18058
|
/** Declare a JSON flag handle for runtime evaluation. */
|
|
@@ -18011,6 +18069,16 @@ var FlagsClient = class {
|
|
|
18011
18069
|
updatedAt: null
|
|
18012
18070
|
});
|
|
18013
18071
|
this._handles[id] = handle;
|
|
18072
|
+
this._flagBuffer.add(
|
|
18073
|
+
id,
|
|
18074
|
+
"JSON",
|
|
18075
|
+
defaultValue,
|
|
18076
|
+
this._parent?._service ?? null,
|
|
18077
|
+
this._parent?._environment ?? null
|
|
18078
|
+
);
|
|
18079
|
+
if (this._flagBuffer.pendingCount >= FLAG_REGISTRATION_FLUSH_SIZE) {
|
|
18080
|
+
void this._flushFlags();
|
|
18081
|
+
}
|
|
18014
18082
|
return handle;
|
|
18015
18083
|
}
|
|
18016
18084
|
// ------------------------------------------------------------------
|
|
@@ -18044,12 +18112,16 @@ var FlagsClient = class {
|
|
|
18044
18112
|
if (this._initialized) return;
|
|
18045
18113
|
debug("lifecycle", "FlagsClient.initialize() called");
|
|
18046
18114
|
this._environment = this._parent?._environment ?? null;
|
|
18115
|
+
await this._flushFlags();
|
|
18047
18116
|
await this._fetchAllFlags();
|
|
18048
18117
|
this._initialized = true;
|
|
18049
18118
|
this._cache.clear();
|
|
18050
18119
|
this._wsManager = this._ensureWs();
|
|
18051
18120
|
this._wsManager.on("flag_changed", this._handleFlagChanged);
|
|
18052
18121
|
this._wsManager.on("flag_deleted", this._handleFlagDeleted);
|
|
18122
|
+
this._flagFlushTimer = setInterval(() => {
|
|
18123
|
+
void this._flushFlags();
|
|
18124
|
+
}, FLAG_REGISTRATION_FLUSH_INTERVAL_MS);
|
|
18053
18125
|
}
|
|
18054
18126
|
/** Disconnect the flags runtime and release resources. */
|
|
18055
18127
|
async disconnect() {
|
|
@@ -18058,6 +18130,10 @@ var FlagsClient = class {
|
|
|
18058
18130
|
this._wsManager.off("flag_deleted", this._handleFlagDeleted);
|
|
18059
18131
|
this._wsManager = null;
|
|
18060
18132
|
}
|
|
18133
|
+
if (this._flagFlushTimer !== null) {
|
|
18134
|
+
clearInterval(this._flagFlushTimer);
|
|
18135
|
+
this._flagFlushTimer = null;
|
|
18136
|
+
}
|
|
18061
18137
|
await this._flushContexts();
|
|
18062
18138
|
this._flagStore = {};
|
|
18063
18139
|
this._cache.clear();
|
|
@@ -18209,12 +18285,16 @@ var FlagsClient = class {
|
|
|
18209
18285
|
/** @internal — called by SmplClient constructor / lazy init. */
|
|
18210
18286
|
async _connectInternal(environment) {
|
|
18211
18287
|
this._environment = environment;
|
|
18288
|
+
await this._flushFlags();
|
|
18212
18289
|
await this._fetchAllFlags();
|
|
18213
18290
|
this._initialized = true;
|
|
18214
18291
|
this._cache.clear();
|
|
18215
18292
|
this._wsManager = this._ensureWs();
|
|
18216
18293
|
this._wsManager.on("flag_changed", this._handleFlagChanged);
|
|
18217
18294
|
this._wsManager.on("flag_deleted", this._handleFlagDeleted);
|
|
18295
|
+
this._flagFlushTimer = setInterval(() => {
|
|
18296
|
+
void this._flushFlags();
|
|
18297
|
+
}, FLAG_REGISTRATION_FLUSH_INTERVAL_MS);
|
|
18218
18298
|
}
|
|
18219
18299
|
// ------------------------------------------------------------------
|
|
18220
18300
|
// Internal: event handlers (called by SharedWebSocket)
|
|
@@ -18290,6 +18370,23 @@ var FlagsClient = class {
|
|
|
18290
18370
|
}
|
|
18291
18371
|
}
|
|
18292
18372
|
// ------------------------------------------------------------------
|
|
18373
|
+
// Internal: flag registration flush
|
|
18374
|
+
// ------------------------------------------------------------------
|
|
18375
|
+
async _flushFlags() {
|
|
18376
|
+
const batch = this._flagBuffer.drain();
|
|
18377
|
+
if (batch.length === 0) return;
|
|
18378
|
+
debug("registration", `flushing ${batch.length} flag(s) to bulk-register endpoint`);
|
|
18379
|
+
try {
|
|
18380
|
+
await this._http.POST("/api/v1/flags/bulk", {
|
|
18381
|
+
body: { flags: batch }
|
|
18382
|
+
});
|
|
18383
|
+
} catch (err) {
|
|
18384
|
+
console.warn(
|
|
18385
|
+
`[smplkit] Failed to bulk-register flags: ${err instanceof Error ? err.message : String(err)}`
|
|
18386
|
+
);
|
|
18387
|
+
}
|
|
18388
|
+
}
|
|
18389
|
+
// ------------------------------------------------------------------
|
|
18293
18390
|
// Internal: context flush
|
|
18294
18391
|
// ------------------------------------------------------------------
|
|
18295
18392
|
async _flushContexts() {
|