@configdirector/nextjs-sdk 1.13.1 → 1.14.1

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 (50) hide show
  1. package/dist/client/index.cjs +1 -1
  2. package/dist/client/index.d.cts +2 -2
  3. package/dist/client/index.d.mts +2 -2
  4. package/dist/client/index.mjs +1 -1
  5. package/dist/client/index.mjs.map +1 -1
  6. package/dist/client/installedTestClient-Bam5r_HR.cjs +6 -0
  7. package/dist/client/installedTestClient-CL4AQC58.mjs +7 -0
  8. package/dist/client/installedTestClient-CL4AQC58.mjs.map +1 -0
  9. package/dist/client/testing.cjs +1 -1
  10. package/dist/client/testing.d.cts +12 -3
  11. package/dist/client/testing.d.cts.map +1 -1
  12. package/dist/client/testing.d.mts +12 -3
  13. package/dist/client/testing.d.mts.map +1 -1
  14. package/dist/client/testing.mjs +1 -1
  15. package/dist/client/testing.mjs.map +1 -1
  16. package/dist/client/{types-CRVL6Yi2.d.cts → types-CdyMdj5l.d.mts} +75 -7
  17. package/dist/client/types-CdyMdj5l.d.mts.map +1 -0
  18. package/dist/client/{types-B4kvU3bh.d.mts → types-P8frfCGH.d.cts} +75 -7
  19. package/dist/client/types-P8frfCGH.d.cts.map +1 -0
  20. package/dist/server/DefaultConfigDirectorClient-BylArFbJ.cjs +5 -0
  21. package/dist/server/DefaultConfigDirectorClient-kQ30B5mx.mjs +6 -0
  22. package/dist/server/DefaultConfigDirectorClient-kQ30B5mx.mjs.map +1 -0
  23. package/dist/server/{errors-Do5xWGgb.d.cts → errors-CkxBFyZy.d.cts} +76 -7
  24. package/dist/server/errors-CkxBFyZy.d.cts.map +1 -0
  25. package/dist/server/{errors-CxXHE84y.d.mts → errors-CsEeGYMl.d.mts} +76 -7
  26. package/dist/server/errors-CsEeGYMl.d.mts.map +1 -0
  27. package/dist/server/index.cjs +1 -1
  28. package/dist/server/index.d.cts +2 -2
  29. package/dist/server/index.d.cts.map +1 -1
  30. package/dist/server/index.d.mts +2 -2
  31. package/dist/server/index.d.mts.map +1 -1
  32. package/dist/server/index.mjs +1 -1
  33. package/dist/server/testing.cjs +1 -1
  34. package/dist/server/testing.d.cts +12 -3
  35. package/dist/server/testing.d.cts.map +1 -1
  36. package/dist/server/testing.d.mts +12 -3
  37. package/dist/server/testing.d.mts.map +1 -1
  38. package/dist/server/testing.mjs +1 -1
  39. package/dist/server/testing.mjs.map +1 -1
  40. package/package.json +1 -1
  41. package/dist/client/installedTestClient-BqVnonO8.mjs +0 -7
  42. package/dist/client/installedTestClient-BqVnonO8.mjs.map +0 -1
  43. package/dist/client/installedTestClient-DM_qeRk9.cjs +0 -6
  44. package/dist/client/types-B4kvU3bh.d.mts.map +0 -1
  45. package/dist/client/types-CRVL6Yi2.d.cts.map +0 -1
  46. package/dist/server/DefaultConfigDirectorClient-BfpJX-Ni.mjs +0 -6
  47. package/dist/server/DefaultConfigDirectorClient-BfpJX-Ni.mjs.map +0 -1
  48. package/dist/server/DefaultConfigDirectorClient-C4cOinqO.cjs +0 -5
  49. package/dist/server/errors-CxXHE84y.d.mts.map +0 -1
  50. package/dist/server/errors-Do5xWGgb.d.cts.map +0 -1
@@ -11,6 +11,12 @@ type ConfigState = {
11
11
  type: ConfigType;
12
12
  value: string | undefined | null;
13
13
  valueId?: string | undefined | null;
14
+ variation?: {
15
+ id: string;
16
+ name?: string | undefined | null;
17
+ } | undefined | null;
18
+ ruleId?: string | undefined | null;
19
+ shareId?: string | undefined | null;
14
20
  };
15
21
  type ConfigDirectorLoggingLevel = "debug" | "info" | "warn" | "error" | "off";
16
22
  interface ConfigDirectorLogger {
@@ -24,24 +30,72 @@ interface ConfigDirectorLogMessageDecorator {
24
30
  }
25
31
  /**
26
32
  * Why an evaluation returned the value it did. `found-match` returns a value from ConfigDirector,
27
- * and `cached` a value kept on the device while a client SDK waits for live values. `value-missing`
33
+ * and `cached` a value kept on the device while a client SDK waits for live values.
34
+ * `rollout-skipped-no-identifier` returns the default targeting rule value: a server SDK skipped a
35
+ * percentage rollout because the context has no `id` to place it in a share. `value-missing`
28
36
  * returns the in-code default value because the config has no value. Every other reason returns the
29
37
  * in-code default value because of an error: the config does not exist (`config-state-missing`), no
30
38
  * values have arrived yet (`client-not-ready`), or the value cannot be read as the type of the in-code
31
39
  * default value.
32
40
  */
33
- type EvaluationReason = "found-match" | "config-state-missing" | "client-not-ready" | "type-mismatch" | "value-missing" | "invalid-number" | "invalid-json" | "invalid-boolean" | "cached";
41
+ type EvaluationReason = "found-match" | "rollout-skipped-no-identifier" | "config-state-missing" | "client-not-ready" | "type-mismatch" | "value-missing" | "invalid-number" | "invalid-json" | "invalid-boolean" | "cached";
42
+ /**
43
+ * One of the values a config can serve, such as the control or a treatment of an experiment.
44
+ */
45
+ type Variation = {
46
+ /** The ID ConfigDirector assigned to the variation, which stays the same when it is renamed. */id: string; /** The variation's name, when it has one. */
47
+ name?: string;
48
+ };
34
49
  /**
35
50
  * One evaluation of a config: the value it returned, why, and the context it was evaluated for.
36
51
  */
37
52
  type ConfigEvaluation<T extends ConfigValueType = ConfigValueType> = {
38
53
  /** The config key that was evaluated. */key: string; /** The value returned, which is the in-code default value when {@link isDefaultValue} is `true`. */
39
54
  value: T; /** The ID ConfigDirector assigned to the value returned, when ConfigDirector sent one with it. */
40
- valueId?: string; /** Whether the evaluation returned the in-code default value. */
55
+ valueId?: string;
56
+ /**
57
+ * The variation that was served. It is `undefined` when the config has no variations or the
58
+ * in-code default value is returned.
59
+ */
60
+ variation?: Variation; /** Whether the evaluation returned the in-code default value. */
41
61
  isDefaultValue: boolean; /** Why the evaluation returned this value. */
42
62
  reason: EvaluationReason; /** The context the config was evaluated for, if any. */
43
63
  context?: ConfigDirectorContext;
44
64
  };
65
+ /**
66
+ * A value in the details of a tracked event: a string, a number, a boolean, or an array or object
67
+ * of such values.
68
+ */
69
+ type TrackedEventDetailValue = string | number | boolean | TrackedEventDetailValue[] | {
70
+ [key: string]: TrackedEventDetailValue;
71
+ };
72
+ /**
73
+ * Details of a tracked event, such as the plan a customer chose. Details with more than 20
74
+ * top-level keys, or larger than 1 KB as JSON, are left out and the event is still reported.
75
+ */
76
+ type TrackedEventDetails = {
77
+ [key: string]: TrackedEventDetailValue;
78
+ };
79
+ /**
80
+ * What a tracked event carries besides its name.
81
+ */
82
+ type TrackOptions = {
83
+ /**
84
+ * A number the event measures, such as an amount of money, a count or a duration. A value that
85
+ * is not a finite number is left out and the event is still reported.
86
+ */
87
+ value?: number; /** Details of the event. */
88
+ details?: TrackedEventDetails;
89
+ };
90
+ /**
91
+ * An event the code under test tracked, as a test client recorded it.
92
+ */
93
+ type TrackedEvent = {
94
+ /** The name the event was tracked with. */name: string; /** The context the event was tracked for, if any. */
95
+ context?: ConfigDirectorContext; /** The value the event was tracked with, when it is a finite number. */
96
+ value?: number; /** The details the event was tracked with, when they are within the limits. */
97
+ details?: TrackedEventDetails;
98
+ };
45
99
  /**
46
100
  * The context to be sent to ConfigDirector: the user or other entity, such as a device or an
47
101
  * organization, that configs are evaluated for. This context will be used for targeting rules
@@ -323,8 +377,8 @@ interface ConfigDirectorClient {
323
377
  getValue<T extends ConfigValueType>(configKey: string, defaultValue: T, context?: ConfigDirectorContext): T;
324
378
  /**
325
379
  * Evaluates a config as {@link getValue} does and returns the evaluation: the value, the reason it
326
- * was served and its value ID. Like every read, it fires `configEvaluated` and is counted in
327
- * telemetry.
380
+ * was served, its value ID and its variation. Like every read, it fires `configEvaluated` and is
381
+ * counted in telemetry.
328
382
  *
329
383
  * @returns The evaluation, whose `value` is what {@link getValue} returns
330
384
  * @param configKey The config key to evaluate
@@ -369,6 +423,21 @@ interface ConfigDirectorClient {
369
423
  context?: ConfigDirectorContext;
370
424
  configKeys?: string[];
371
425
  }): Record<string, ConfigState>;
426
+ /**
427
+ * Reports to ConfigDirector that something happened, such as a completed checkout, so it can be
428
+ * counted. The event is sent with the next telemetry batch. `track` never throws, and does nothing
429
+ * in `offline` mode.
430
+ *
431
+ * An event counts for an experiment only when it is tracked for a context with an `id`, the one
432
+ * the experiment's config was evaluated for. Without a context, or for a context without an
433
+ * `id`, the event is still reported.
434
+ *
435
+ * @param eventName The name of the event, 1 to 150 characters. An event with any other name is
436
+ * not reported and a warning is logged.
437
+ * @param context The context the event happened for (optional)
438
+ * @param options The event's {@link TrackOptions.value} and {@link TrackOptions.details} (optional)
439
+ */
440
+ track(eventName: string, context?: ConfigDirectorContext, options?: TrackOptions): void;
372
441
  on<T extends keyof ClientEvents>(eventName: T, handler: (args: ClientEvents[T]) => void): void;
373
442
  off<T extends keyof ClientEvents>(eventName: T, handler?: (args: ClientEvents[T]) => void): void;
374
443
  /**
@@ -395,5 +464,5 @@ declare class ConfigDirectorInitializationError extends Error {
395
464
  constructor(message: string);
396
465
  }
397
466
  //#endregion
398
- export { ConfigEvaluation as _, ConfigDirectorClientOptions as a, ConnectionMode as b, OfflineValues as c, NativeValues as d, ConfigDirectorContext as f, ConfigDirectorMetaContext as g, ConfigDirectorLoggingLevel as h, ConfigDirectorClient as i, NativeJsonValue as l, ConfigDirectorLogger as m, ConfigDirectorInitializationError as n, OfflineClientOptions as o, ConfigDirectorLogMessageDecorator as p, ConfigDirectorValidationError as r, OfflineValue as s, ConfigDirectorConnectionError as t, NativeValue as u, ConfigState as v, EvaluationReason as x, ConfigValueType as y };
399
- //# sourceMappingURL=errors-Do5xWGgb.d.cts.map
467
+ export { TrackedEvent as C, Variation as E, TrackOptions as S, TrackedEventDetails as T, ConfigEvaluation as _, ConfigDirectorClientOptions as a, ConnectionMode as b, OfflineValues as c, NativeValues as d, ConfigDirectorContext as f, ConfigDirectorMetaContext as g, ConfigDirectorLoggingLevel as h, ConfigDirectorClient as i, NativeJsonValue as l, ConfigDirectorLogger as m, ConfigDirectorInitializationError as n, OfflineClientOptions as o, ConfigDirectorLogMessageDecorator as p, ConfigDirectorValidationError as r, OfflineValue as s, ConfigDirectorConnectionError as t, NativeValue as u, ConfigState as v, TrackedEventDetailValue as w, EvaluationReason as x, ConfigValueType as y };
468
+ //# sourceMappingURL=errors-CkxBFyZy.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors-CkxBFyZy.d.cts","names":[],"sources":["../../../shared/src/types.ts","../../../shared/src/native-values.ts","../../../js-server-sdk/src/types.ts","../../../shared/src/errors.ts"],"mappings":";cAAa,cAAA;AAAA,KAUD,UAAA,WAAqB,cAAA;AAAA,KAErB,kBAAA;EAAA,CAAwB,GAAA;AAAA;AAAA,KAExB,eAAA,wCAAuD,kBAAA;AAAA,KAEvD,WAAA;EACV,EAAA;EACA,GAAA;EACA,IAAA,EAAM,UAAA;EACN,KAAA;EACA,OAAA;EACA,SAAA;IAAc,EAAA;IAAY,IAAA;EAAA;EAC1B,MAAA;EACA,OAAA;AAAA;AAAA,KAQU,0BAAA;AAAA,UAEK,oBAAA;EACf,KAAA,CAAM,OAAA,aAAoB,IAAA;EAE1B,IAAA,CAAK,OAAA,aAAoB,IAAA;EAEzB,IAAA,CAAK,OAAA,aAAoB,IAAA;EAEzB,KAAA,CAAM,OAAA,aAAoB,IAAA;AAAA;AAAA,UAGX,iCAAA;EACf,eAAA,CAAgB,OAAA;AAAA;;;;;;AAblB;;;;;KA0BY,gBAAA;;;;KAeA,SAAA;EAtCJ,gGAwCN,EAAA,UAtCA;EAwCA,IAAA;AAAA;;;;KAMU,gBAAA,WAA2B,eAAA,GAAkB,eAAA;EA1CjD,yCA4CN,GAAA,UA5C8B;EA8C9B,KAAA,EAAO,CAAA,EA3CQ;EA6Cf,OAAA;;;;AA/BF;EAoCE,SAAA,GAAY,SAAA;EAEZ,cAAA,WAtC0B;EAwC1B,MAAA,EAAQ,gBAAA,EAzBW;EA2BnB,OAAA,GAAU,qBAAA;AAAA;;AAjBZ;;;KAwBY,uBAAA,+BAIR,uBAAA;EAAA,CACG,GAAA,WAAc,uBAAA;AAAA;;;;;KAMT,mBAAA;EAAA,CAAyB,GAAA,WAAc,uBAAA;AAAA;;;;KAKvC,YAAA;EAlCV;;;;EAuCA,KAAA,WA9B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CAAa,CAAA;;;;EAK9E,UAAA;EAzGkC;;;;;;;EAkHlC,aAAA,CAAc,OAAA;IACZ,OAAA,GAAU,qBAAA;IACV,UAAA;EAAA,IACE,MAAA,SAAe,WAAA;EA/GE;;;;;;;;;;;;;;EA+HrB,KAAA,CAAM,SAAA,UAAmB,OAAA,GAAU,qBAAA,EAAuB,OAAA,GAAU,YAAA;EAEpE,EAAA,iBAAmB,YAAA,EAAc,SAAA,EAAW,CAAA,EAAG,OAAA,GAAU,IAAA,EAAM,YAAA,CAAa,CAAA;EAE5E,GAAA,iBAAoB,YAAA,EAAc,SAAA,EAAW,CAAA,EAAG,OAAA,IAAW,IAAA,EAAM,YAAA,CAAa,CAAA;EAjI7B;;;;;;EAyIjD,OAAA;AAAA;;;cC9UW,6BAAA,SAAsC,KAAA;EAAA,SACxB,IAAA;EAAA,SACT,MAAA;cAEJ,OAAA,UAAiB,MAAA;AAAA;AAAA,cAQlB,6BAAA,SAAsC,KAAA;EAAA,SACxB,IAAA;cAEb,OAAA;AAAA;AAAA,cAOD,iCAAA,SAA0C,KAAA;EAAA,SAC5B,IAAA;cAEb,OAAA;AAAA"}
@@ -11,6 +11,12 @@ type ConfigState = {
11
11
  type: ConfigType;
12
12
  value: string | undefined | null;
13
13
  valueId?: string | undefined | null;
14
+ variation?: {
15
+ id: string;
16
+ name?: string | undefined | null;
17
+ } | undefined | null;
18
+ ruleId?: string | undefined | null;
19
+ shareId?: string | undefined | null;
14
20
  };
15
21
  type ConfigDirectorLoggingLevel = "debug" | "info" | "warn" | "error" | "off";
16
22
  interface ConfigDirectorLogger {
@@ -24,24 +30,72 @@ interface ConfigDirectorLogMessageDecorator {
24
30
  }
25
31
  /**
26
32
  * Why an evaluation returned the value it did. `found-match` returns a value from ConfigDirector,
27
- * and `cached` a value kept on the device while a client SDK waits for live values. `value-missing`
33
+ * and `cached` a value kept on the device while a client SDK waits for live values.
34
+ * `rollout-skipped-no-identifier` returns the default targeting rule value: a server SDK skipped a
35
+ * percentage rollout because the context has no `id` to place it in a share. `value-missing`
28
36
  * returns the in-code default value because the config has no value. Every other reason returns the
29
37
  * in-code default value because of an error: the config does not exist (`config-state-missing`), no
30
38
  * values have arrived yet (`client-not-ready`), or the value cannot be read as the type of the in-code
31
39
  * default value.
32
40
  */
33
- type EvaluationReason = "found-match" | "config-state-missing" | "client-not-ready" | "type-mismatch" | "value-missing" | "invalid-number" | "invalid-json" | "invalid-boolean" | "cached";
41
+ type EvaluationReason = "found-match" | "rollout-skipped-no-identifier" | "config-state-missing" | "client-not-ready" | "type-mismatch" | "value-missing" | "invalid-number" | "invalid-json" | "invalid-boolean" | "cached";
42
+ /**
43
+ * One of the values a config can serve, such as the control or a treatment of an experiment.
44
+ */
45
+ type Variation = {
46
+ /** The ID ConfigDirector assigned to the variation, which stays the same when it is renamed. */id: string; /** The variation's name, when it has one. */
47
+ name?: string;
48
+ };
34
49
  /**
35
50
  * One evaluation of a config: the value it returned, why, and the context it was evaluated for.
36
51
  */
37
52
  type ConfigEvaluation<T extends ConfigValueType = ConfigValueType> = {
38
53
  /** The config key that was evaluated. */key: string; /** The value returned, which is the in-code default value when {@link isDefaultValue} is `true`. */
39
54
  value: T; /** The ID ConfigDirector assigned to the value returned, when ConfigDirector sent one with it. */
40
- valueId?: string; /** Whether the evaluation returned the in-code default value. */
55
+ valueId?: string;
56
+ /**
57
+ * The variation that was served. It is `undefined` when the config has no variations or the
58
+ * in-code default value is returned.
59
+ */
60
+ variation?: Variation; /** Whether the evaluation returned the in-code default value. */
41
61
  isDefaultValue: boolean; /** Why the evaluation returned this value. */
42
62
  reason: EvaluationReason; /** The context the config was evaluated for, if any. */
43
63
  context?: ConfigDirectorContext;
44
64
  };
65
+ /**
66
+ * A value in the details of a tracked event: a string, a number, a boolean, or an array or object
67
+ * of such values.
68
+ */
69
+ type TrackedEventDetailValue = string | number | boolean | TrackedEventDetailValue[] | {
70
+ [key: string]: TrackedEventDetailValue;
71
+ };
72
+ /**
73
+ * Details of a tracked event, such as the plan a customer chose. Details with more than 20
74
+ * top-level keys, or larger than 1 KB as JSON, are left out and the event is still reported.
75
+ */
76
+ type TrackedEventDetails = {
77
+ [key: string]: TrackedEventDetailValue;
78
+ };
79
+ /**
80
+ * What a tracked event carries besides its name.
81
+ */
82
+ type TrackOptions = {
83
+ /**
84
+ * A number the event measures, such as an amount of money, a count or a duration. A value that
85
+ * is not a finite number is left out and the event is still reported.
86
+ */
87
+ value?: number; /** Details of the event. */
88
+ details?: TrackedEventDetails;
89
+ };
90
+ /**
91
+ * An event the code under test tracked, as a test client recorded it.
92
+ */
93
+ type TrackedEvent = {
94
+ /** The name the event was tracked with. */name: string; /** The context the event was tracked for, if any. */
95
+ context?: ConfigDirectorContext; /** The value the event was tracked with, when it is a finite number. */
96
+ value?: number; /** The details the event was tracked with, when they are within the limits. */
97
+ details?: TrackedEventDetails;
98
+ };
45
99
  /**
46
100
  * The context to be sent to ConfigDirector: the user or other entity, such as a device or an
47
101
  * organization, that configs are evaluated for. This context will be used for targeting rules
@@ -323,8 +377,8 @@ interface ConfigDirectorClient {
323
377
  getValue<T extends ConfigValueType>(configKey: string, defaultValue: T, context?: ConfigDirectorContext): T;
324
378
  /**
325
379
  * Evaluates a config as {@link getValue} does and returns the evaluation: the value, the reason it
326
- * was served and its value ID. Like every read, it fires `configEvaluated` and is counted in
327
- * telemetry.
380
+ * was served, its value ID and its variation. Like every read, it fires `configEvaluated` and is
381
+ * counted in telemetry.
328
382
  *
329
383
  * @returns The evaluation, whose `value` is what {@link getValue} returns
330
384
  * @param configKey The config key to evaluate
@@ -369,6 +423,21 @@ interface ConfigDirectorClient {
369
423
  context?: ConfigDirectorContext;
370
424
  configKeys?: string[];
371
425
  }): Record<string, ConfigState>;
426
+ /**
427
+ * Reports to ConfigDirector that something happened, such as a completed checkout, so it can be
428
+ * counted. The event is sent with the next telemetry batch. `track` never throws, and does nothing
429
+ * in `offline` mode.
430
+ *
431
+ * An event counts for an experiment only when it is tracked for a context with an `id`, the one
432
+ * the experiment's config was evaluated for. Without a context, or for a context without an
433
+ * `id`, the event is still reported.
434
+ *
435
+ * @param eventName The name of the event, 1 to 150 characters. An event with any other name is
436
+ * not reported and a warning is logged.
437
+ * @param context The context the event happened for (optional)
438
+ * @param options The event's {@link TrackOptions.value} and {@link TrackOptions.details} (optional)
439
+ */
440
+ track(eventName: string, context?: ConfigDirectorContext, options?: TrackOptions): void;
372
441
  on<T extends keyof ClientEvents>(eventName: T, handler: (args: ClientEvents[T]) => void): void;
373
442
  off<T extends keyof ClientEvents>(eventName: T, handler?: (args: ClientEvents[T]) => void): void;
374
443
  /**
@@ -395,5 +464,5 @@ declare class ConfigDirectorInitializationError extends Error {
395
464
  constructor(message: string);
396
465
  }
397
466
  //#endregion
398
- export { ConfigEvaluation as _, ConfigDirectorClientOptions as a, ConnectionMode as b, OfflineValues as c, NativeValues as d, ConfigDirectorContext as f, ConfigDirectorMetaContext as g, ConfigDirectorLoggingLevel as h, ConfigDirectorClient as i, NativeJsonValue as l, ConfigDirectorLogger as m, ConfigDirectorInitializationError as n, OfflineClientOptions as o, ConfigDirectorLogMessageDecorator as p, ConfigDirectorValidationError as r, OfflineValue as s, ConfigDirectorConnectionError as t, NativeValue as u, ConfigState as v, EvaluationReason as x, ConfigValueType as y };
399
- //# sourceMappingURL=errors-CxXHE84y.d.mts.map
467
+ export { TrackedEvent as C, Variation as E, TrackOptions as S, TrackedEventDetails as T, ConfigEvaluation as _, ConfigDirectorClientOptions as a, ConnectionMode as b, OfflineValues as c, NativeValues as d, ConfigDirectorContext as f, ConfigDirectorMetaContext as g, ConfigDirectorLoggingLevel as h, ConfigDirectorClient as i, NativeJsonValue as l, ConfigDirectorLogger as m, ConfigDirectorInitializationError as n, OfflineClientOptions as o, ConfigDirectorLogMessageDecorator as p, ConfigDirectorValidationError as r, OfflineValue as s, ConfigDirectorConnectionError as t, NativeValue as u, ConfigState as v, TrackedEventDetailValue as w, EvaluationReason as x, ConfigValueType as y };
468
+ //# sourceMappingURL=errors-CsEeGYMl.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors-CsEeGYMl.d.mts","names":[],"sources":["../../../shared/src/types.ts","../../../shared/src/native-values.ts","../../../js-server-sdk/src/types.ts","../../../shared/src/errors.ts"],"mappings":";cAAa,cAAA;AAAA,KAUD,UAAA,WAAqB,cAAA;AAAA,KAErB,kBAAA;EAAA,CAAwB,GAAA;AAAA;AAAA,KAExB,eAAA,wCAAuD,kBAAA;AAAA,KAEvD,WAAA;EACV,EAAA;EACA,GAAA;EACA,IAAA,EAAM,UAAA;EACN,KAAA;EACA,OAAA;EACA,SAAA;IAAc,EAAA;IAAY,IAAA;EAAA;EAC1B,MAAA;EACA,OAAA;AAAA;AAAA,KAQU,0BAAA;AAAA,UAEK,oBAAA;EACf,KAAA,CAAM,OAAA,aAAoB,IAAA;EAE1B,IAAA,CAAK,OAAA,aAAoB,IAAA;EAEzB,IAAA,CAAK,OAAA,aAAoB,IAAA;EAEzB,KAAA,CAAM,OAAA,aAAoB,IAAA;AAAA;AAAA,UAGX,iCAAA;EACf,eAAA,CAAgB,OAAA;AAAA;;;;;;AAblB;;;;;KA0BY,gBAAA;;;;KAeA,SAAA;EAtCJ,gGAwCN,EAAA,UAtCA;EAwCA,IAAA;AAAA;;;;KAMU,gBAAA,WAA2B,eAAA,GAAkB,eAAA;EA1CjD,yCA4CN,GAAA,UA5C8B;EA8C9B,KAAA,EAAO,CAAA,EA3CQ;EA6Cf,OAAA;;;;AA/BF;EAoCE,SAAA,GAAY,SAAA;EAEZ,cAAA,WAtC0B;EAwC1B,MAAA,EAAQ,gBAAA,EAzBW;EA2BnB,OAAA,GAAU,qBAAA;AAAA;;AAjBZ;;;KAwBY,uBAAA,+BAIR,uBAAA;EAAA,CACG,GAAA,WAAc,uBAAA;AAAA;;;;;KAMT,mBAAA;EAAA,CAAyB,GAAA,WAAc,uBAAA;AAAA;;;;KAKvC,YAAA;EAlCV;;;;EAuCA,KAAA,WA9BQ;EAgCR,OAA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;EAK9E,UAAA;EAzGkC;;;;;;;EAkHlC,aAAA,CAAc,OAAA;IACZ,OAAA,GAAU,qBAAA;IACV,UAAA;EAAA,IACE,MAAA,SAAe,WAAA;EA/GE;;;;;;;;;;;;;;EA+HrB,KAAA,CAAM,SAAA,UAAmB,OAAA,GAAU,qBAAA,EAAuB,OAAA,GAAU,YAAA;EAEpE,EAAA,iBAAmB,YAAA,EAAc,SAAA,EAAW,CAAA,EAAG,OAAA,GAAU,IAAA,EAAM,YAAA,CAAa,CAAA;EAE5E,GAAA,iBAAoB,YAAA,EAAc,SAAA,EAAW,CAAA,EAAG,OAAA,IAAW,IAAA,EAAM,YAAA,CAAa,CAAA;EAjI7B;;;;;;EAyIjD,OAAA;AAAA;;;cC9UW,6BAAA,SAAsC,KAAA;EAAA,SACxB,IAAA;EAAA,SACT,MAAA;cAEJ,OAAA,UAAiB,MAAA;AAAA;AAAA,cAQlB,6BAAA,SAAsC,KAAA;EAAA,SACxB,IAAA;cAEb,OAAA;AAAA;AAAA,cAOD,iCAAA,SAA0C,KAAA;EAAA,SAC5B,IAAA;cAEb,OAAA;AAAA"}
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./DefaultConfigDirectorClient-C4cOinqO.cjs`);const e=require(`./native-values-UCK4hh1Z.cjs`);let t=require(`@configdirector/nextjs-sdk/client`),n=require(`react/jsx-runtime`);var r=class{decorateMessage(e){return`[ConfigDirector:nextjs-sdk] ${e}`}};const i=(t,n)=>new e.o(t??`warn`,n??new r),a=(t,n)=>new e.o(t,n??new r);async function o(t){if(process.env.NEXT_RUNTIME===`nodejs`){let n=t.connection?.mode??`streaming`;if(n!==`offline`&&!t.serverSdkKey){let t=`The ConfigDirector serverSdkKey must be provided to register(). You can pass it via process.env.CONFIGDIRECTOR_SERVER_KEY.`;throw i().error(t),new e.i(t)}if(!globalThis.__configDirectorServerClient){let{DefaultConfigDirectorClient:e}=await Promise.resolve().then(()=>require(`./DefaultConfigDirectorClient-C4cOinqO.cjs`)).then(e=>e.n),{serverSdkKey:r,...i}=t;globalThis.__configDirectorAppMeta={appName:t.metadata?.appName,appVersion:t.metadata?.appVersion},globalThis.__configDirectorServerConnectionMode=n;let a=new e(r,{sdkName:`nextjs-sdk`,sdkVersion:`1.13.1`},i);globalThis.__configDirectorServerClient=a;try{await a.initialize()}catch(e){throw globalThis.__configDirectorServerClient=void 0,globalThis.__configDirectorServerConnectionMode=void 0,globalThis.__configDirectorAppMeta=void 0,a.dispose(),e}}}}function s(){return globalThis.__configDirectorAppMeta??{}}function c(){return globalThis.__configDirectorServerConnectionMode}function l(){if(!globalThis.__configDirectorServerClient)throw new e.i(`[ConfigDirector] Server client not initialized. Make sure to call register() in your instrumentation.ts file before using the SDK.`);return globalThis.__configDirectorServerClient}const u=i();function d(e){try{return l().getAllConfigs(e)}catch(e){return u.error(`Error retrieving SSR config set:`,e),{}}}const f=(e,t)=>e.mode!==void 0||e.values!==void 0?`as-given`:t===`offline`?`inherit-offline`:`connect`,p=e=>typeof e.value==`string`,m=t=>Object.fromEntries(Object.values(t).filter(p).map(t=>[t.key,e.t(t.type,t.value)]));async function h({children:e,configKeys:r,...i}){let a=d({context:i.context,configKeys:r}),o=s();return(0,n.jsx)(t.ConfigDirectorProvider,{...i,...g(a,i),appName:i.appName??o.appName,appVersion:i.appVersion??o.appVersion,initialConfigs:a,children:e})}const g=(e,t)=>{switch(f(t,c())){case`as-given`:return{};case`inherit-offline`:return{mode:`offline`,values:m(e)};case`connect`:return{}}};exports.ConfigDirectorInitializationError=e.i,exports.ConfigDirectorProvider=h,exports.createConsoleLogger=a,exports.generateSsrConfigSet=d,exports.getAppMeta=s,exports.getConfigClient=l,exports.register=o;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./DefaultConfigDirectorClient-BylArFbJ.cjs`);const e=require(`./native-values-UCK4hh1Z.cjs`);let t=require(`@configdirector/nextjs-sdk/client`),n=require(`react/jsx-runtime`);var r=class{decorateMessage(e){return`[ConfigDirector:nextjs-sdk] ${e}`}};const i=(t,n)=>new e.o(t??`warn`,n??new r),a=(t,n)=>new e.o(t,n??new r);async function o(t){if(process.env.NEXT_RUNTIME===`nodejs`){let n=t.connection?.mode??`streaming`;if(n!==`offline`&&!t.serverSdkKey){let t=`The ConfigDirector serverSdkKey must be provided to register(). You can pass it via process.env.CONFIGDIRECTOR_SERVER_KEY.`;throw i().error(t),new e.i(t)}if(!globalThis.__configDirectorServerClient){let{DefaultConfigDirectorClient:e}=await Promise.resolve().then(()=>require(`./DefaultConfigDirectorClient-BylArFbJ.cjs`)).then(e=>e.n),{serverSdkKey:r,...i}=t;globalThis.__configDirectorAppMeta={appName:t.metadata?.appName,appVersion:t.metadata?.appVersion},globalThis.__configDirectorServerConnectionMode=n;let a=new e(r,{sdkName:`nextjs-sdk`,sdkVersion:`1.14.1`},i);globalThis.__configDirectorServerClient=a;try{await a.initialize()}catch(e){throw globalThis.__configDirectorServerClient=void 0,globalThis.__configDirectorServerConnectionMode=void 0,globalThis.__configDirectorAppMeta=void 0,a.dispose(),e}}}}function s(){return globalThis.__configDirectorAppMeta??{}}function c(){return globalThis.__configDirectorServerConnectionMode}function l(){if(!globalThis.__configDirectorServerClient)throw new e.i(`[ConfigDirector] Server client not initialized. Make sure to call register() in your instrumentation.ts file before using the SDK.`);return globalThis.__configDirectorServerClient}const u=i();function d(e){try{return l().getAllConfigs(e)}catch(e){return u.error(`Error retrieving SSR config set:`,e),{}}}const f=(e,t)=>e.mode!==void 0||e.values!==void 0?`as-given`:t===`offline`?`inherit-offline`:`connect`,p=e=>typeof e.value==`string`,m=t=>Object.fromEntries(Object.values(t).filter(p).map(t=>[t.key,e.t(t.type,t.value)]));async function h({children:e,configKeys:r,...i}){let a=d({context:i.context,configKeys:r}),o=s();return(0,n.jsx)(t.ConfigDirectorProvider,{...i,...g(a,i),appName:i.appName??o.appName,appVersion:i.appVersion??o.appVersion,initialConfigs:a,children:e})}const g=(e,t)=>{switch(f(t,c())){case`as-given`:return{};case`inherit-offline`:return{mode:`offline`,values:m(e)};case`connect`:return{}}};exports.ConfigDirectorInitializationError=e.i,exports.ConfigDirectorProvider=h,exports.createConsoleLogger=a,exports.generateSsrConfigSet=d,exports.getAppMeta=s,exports.getConfigClient=l,exports.register=o;
@@ -1,4 +1,4 @@
1
- import { _ as ConfigEvaluation, a as ConfigDirectorClientOptions, b as ConnectionMode, c as OfflineValues, d as NativeValues, f as ConfigDirectorContext, g as ConfigDirectorMetaContext, h as ConfigDirectorLoggingLevel, i as ConfigDirectorClient, m as ConfigDirectorLogger, n as ConfigDirectorInitializationError, o as OfflineClientOptions, p as ConfigDirectorLogMessageDecorator, s as OfflineValue, v as ConfigState, x as EvaluationReason, y as ConfigValueType } from "./errors-Do5xWGgb.cjs";
1
+ import { E as Variation, S as TrackOptions, T as TrackedEventDetails, _ as ConfigEvaluation, a as ConfigDirectorClientOptions, b as ConnectionMode, c as OfflineValues, d as NativeValues, f as ConfigDirectorContext, g as ConfigDirectorMetaContext, h as ConfigDirectorLoggingLevel, i as ConfigDirectorClient, m as ConfigDirectorLogger, n as ConfigDirectorInitializationError, o as OfflineClientOptions, p as ConfigDirectorLogMessageDecorator, s as OfflineValue, v as ConfigState, w as TrackedEventDetailValue, x as EvaluationReason, y as ConfigValueType } from "./errors-CkxBFyZy.cjs";
2
2
  import * as _$react_jsx_runtime0 from "react/jsx-runtime";
3
3
  import { PropsWithChildren } from "react";
4
4
 
@@ -273,5 +273,5 @@ declare function ConfigDirectorProvider({
273
273
  //#region src/server/logger.d.ts
274
274
  declare const createConsoleLogger: (level: ConfigDirectorLoggingLevel, messageDecorator?: ConfigDirectorLogMessageDecorator) => DefaultConsoleLogger;
275
275
  //#endregion
276
- export { type ConfigDirectorClient, type ConfigDirectorClientOptions, type ConfigDirectorContext, ConfigDirectorInitializationError, type ConfigDirectorLogger, type ConfigDirectorMetaContext, ConfigDirectorProvider, type ConfigDirectorProviderProps, type ConfigEvaluation, type ConfigValueType, type ConnectionMode, type EvaluationReason, type GenerateSsrConfigSetOptions, type OfflineClientOptions, type OfflineValue, type OfflineValues, type RegisterOptions, createConsoleLogger, generateSsrConfigSet, getAppMeta, getConfigClient, register };
276
+ export { type ConfigDirectorClient, type ConfigDirectorClientOptions, type ConfigDirectorContext, ConfigDirectorInitializationError, type ConfigDirectorLogger, type ConfigDirectorMetaContext, ConfigDirectorProvider, type ConfigDirectorProviderProps, type ConfigEvaluation, type ConfigValueType, type ConnectionMode, type EvaluationReason, type GenerateSsrConfigSetOptions, type OfflineClientOptions, type OfflineValue, type OfflineValues, type RegisterOptions, type TrackOptions, type TrackedEventDetailValue, type TrackedEventDetails, type Variation, createConsoleLogger, generateSsrConfigSet, getAppMeta, getConfigClient, register };
277
277
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/server/singleton.ts","../../src/server/ssr.ts","../../../js-client-core/src/types.ts","../../../shared/src/logger.ts","../../src/client/types.ts","../../src/server/ConfigDirectorProvider.tsx","../../src/server/logger.ts"],"mappings":";;;;;QASQ,MAAA;EAAA,IACF,4BAAA,EAA8B,oBAAA;EAAA,IAC9B,oCAAA,EAAsC,cAAA;EAAA,IACtC,uBAAA;IAA2B,OAAA;IAAkB,UAAA;EAAA;AAAA;;;;;;KAQvC,eAAA;EARuC;;;;EAc7C,YAAA;AAAA,IACE,2BAAA,KACH,oBAAA;EAAyB,YAAA;AAAA;;;;;;;;AAuB9B;;;;;;;;;AAwCA;;;;;iBAxCsB,QAAA,CAAS,OAAA,EAAS,eAAA,GAAkB,OAAA;AAAA,iBAwC1C,UAAA,CAAA;EAAgB,OAAA;EAAkB,UAAA;AAAA;AAAA,iBAQlC,eAAA,CAAA,GAAmB,oBAAA;;;KC7FvB,2BAAA;oDAEV,OAAA,GAAU,qBAAA;;ADHkB;;;ECQ5B,UAAA;AAAA;;;;;;;;;;;iBAac,oBAAA,CAAqB,OAAA,GAAU,2BAAA,GAA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IAE,IAAA,GAAO,cAAA;EJwCO;;;;;AAQhB;EIzCE,MAAA,GAAS,eAAA;;;;;;EAMT,eAAA;EH1DU;;;EG8DV,OAAA,GAAU,qBAAA;EH5DV;;;;;AAkBF;;EGkDE,mBAAA;EHlD6C;;;EGsD7C,QAAA,GAAW,0BAAA;EAEX,KAAA,GAAQ,WAAA;EHxDqC;;;;;;;;;ACmF/C;EEhBE,cAAA,GAAiB,MAAA,SAAe,WAAA;AAAA;;;;;;AJxFJ;KKOlB,2BAAA,GAA8B,IAAA,CAAK,6BAAA;;;;;;EAM7C,UAAA;AAAA;;;;;;;ALEF;;;;;;;;;;AA+BA;;;;;;;;;AAwCA;;;;;AAQA;;;;;;;;AC7FA;;;;;;;;;AAoBA;;;;;;;;;;iBIoDsB,sBAAA,CAAA;EACpB,QAAA;EACA,UAAA;EAAA,GACG;AAAA,GACF,iBAAA,CAAkB,2BAAA,IAA4B,OAAA,CAAA,oBAAA,CAAA,GAAA,CAAA,OAAA;;;cClEpC,mBAAA,GACX,KAAA,EAAO,0BAAA,EACP,gBAAA,GAAmB,iCAAA,KAAiC,oBAAA"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/server/singleton.ts","../../src/server/ssr.ts","../../../js-client-core/src/types.ts","../../../shared/src/logger.ts","../../src/client/types.ts","../../src/server/ConfigDirectorProvider.tsx","../../src/server/logger.ts"],"mappings":";;;;;QASQ,MAAA;EAAA,IACF,4BAAA,EAA8B,oBAAA;EAAA,IAC9B,oCAAA,EAAsC,cAAA;EAAA,IACtC,uBAAA;IAA2B,OAAA;IAAkB,UAAA;EAAA;AAAA;;;;;;KAQvC,eAAA;EARuC;;;;EAc7C,YAAA;AAAA,IACE,2BAAA,KACH,oBAAA;EAAyB,YAAA;AAAA;;;;;;;;AAuB9B;;;;;;;;;AAwCA;;;;;iBAxCsB,QAAA,CAAS,OAAA,EAAS,eAAA,GAAkB,OAAA;AAAA,iBAwC1C,UAAA,CAAA;EAAgB,OAAA;EAA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oB,KAAA,EAAO,0BAAA,EAA4B,OAAA,aAAoB,IAAA;AAAA;;;KC/BnG,6BAAA;EJdN;;;;EImBJ,MAAA;EACA,OAAA;EACA,UAAA;EJZU;;;EIgBV,GAAA;EJVI;;;EIcJ,OAAA;EJZwC;;AAuB1C;;;;;;;;EIAE,IAAA,GAAO,cAAA;EJwCO;;;;;AAQhB;EIzCE,MAAA,GAAS,eAAA;;;;;;EAMT,eAAA;EH1DU;;;EG8DV,OAAA,GAAU,qBAAA;EH5DV;;;;;AAkBF;;EGkDE,mBAAA;EHlD6C;;;EGsD7C,QAAA,GAAW,0BAAA;EAEX,KAAA,GAAQ,WAAA;EHxDqC;;;;;;;;;ACoF/C;EEjBE,cAAA,GAAiB,MAAA,SAAe,WAAA;AAAA;;;;;;AJxFJ;KKOlB,2BAAA,GAA8B,IAAA,CAAK,6BAAA;;;;;;EAM7C,UAAA;AAAA;;;;;;;ALEF;;;;;;;;;;AA+BA;;;;;;;;;AAwCA;;;;;AAQA;;;;;;;;AC7FA;;;;;;;;;AAoBA;;;;;;;;;;iBIoDsB,sBAAA,CAAA;EACpB,QAAA;EACA,UAAA;EAAA,GACG;AAAA,GACF,iBAAA,CAAkB,2BAAA,IAA4B,OAAA,CAAA,oBAAA,CAAA,GAAA,CAAA,OAAA;;;cClEpC,mBAAA,GACX,KAAA,EAAO,0BAAA,EACP,gBAAA,GAAmB,iCAAA,KAAiC,oBAAA"}
@@ -1,4 +1,4 @@
1
- import { _ as ConfigEvaluation, a as ConfigDirectorClientOptions, b as ConnectionMode, c as OfflineValues, d as NativeValues, f as ConfigDirectorContext, g as ConfigDirectorMetaContext, h as ConfigDirectorLoggingLevel, i as ConfigDirectorClient, m as ConfigDirectorLogger, n as ConfigDirectorInitializationError, o as OfflineClientOptions, p as ConfigDirectorLogMessageDecorator, s as OfflineValue, v as ConfigState, x as EvaluationReason, y as ConfigValueType } from "./errors-CxXHE84y.mjs";
1
+ import { E as Variation, S as TrackOptions, T as TrackedEventDetails, _ as ConfigEvaluation, a as ConfigDirectorClientOptions, b as ConnectionMode, c as OfflineValues, d as NativeValues, f as ConfigDirectorContext, g as ConfigDirectorMetaContext, h as ConfigDirectorLoggingLevel, i as ConfigDirectorClient, m as ConfigDirectorLogger, n as ConfigDirectorInitializationError, o as OfflineClientOptions, p as ConfigDirectorLogMessageDecorator, s as OfflineValue, v as ConfigState, w as TrackedEventDetailValue, x as EvaluationReason, y as ConfigValueType } from "./errors-CsEeGYMl.mjs";
2
2
  import * as _$react_jsx_runtime0 from "react/jsx-runtime";
3
3
  import { PropsWithChildren } from "react";
4
4
 
@@ -273,5 +273,5 @@ declare function ConfigDirectorProvider({
273
273
  //#region src/server/logger.d.ts
274
274
  declare const createConsoleLogger: (level: ConfigDirectorLoggingLevel, messageDecorator?: ConfigDirectorLogMessageDecorator) => DefaultConsoleLogger;
275
275
  //#endregion
276
- export { type ConfigDirectorClient, type ConfigDirectorClientOptions, type ConfigDirectorContext, ConfigDirectorInitializationError, type ConfigDirectorLogger, type ConfigDirectorMetaContext, ConfigDirectorProvider, type ConfigDirectorProviderProps, type ConfigEvaluation, type ConfigValueType, type ConnectionMode, type EvaluationReason, type GenerateSsrConfigSetOptions, type OfflineClientOptions, type OfflineValue, type OfflineValues, type RegisterOptions, createConsoleLogger, generateSsrConfigSet, getAppMeta, getConfigClient, register };
276
+ export { type ConfigDirectorClient, type ConfigDirectorClientOptions, type ConfigDirectorContext, ConfigDirectorInitializationError, type ConfigDirectorLogger, type ConfigDirectorMetaContext, ConfigDirectorProvider, type ConfigDirectorProviderProps, type ConfigEvaluation, type ConfigValueType, type ConnectionMode, type EvaluationReason, type GenerateSsrConfigSetOptions, type OfflineClientOptions, type OfflineValue, type OfflineValues, type RegisterOptions, type TrackOptions, type TrackedEventDetailValue, type TrackedEventDetails, type Variation, createConsoleLogger, generateSsrConfigSet, getAppMeta, getConfigClient, register };
277
277
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/server/singleton.ts","../../src/server/ssr.ts","../../../js-client-core/src/types.ts","../../../shared/src/logger.ts","../../src/client/types.ts","../../src/server/ConfigDirectorProvider.tsx","../../src/server/logger.ts"],"mappings":";;;;;QASQ,MAAA;EAAA,IACF,4BAAA,EAA8B,oBAAA;EAAA,IAC9B,oCAAA,EAAsC,cAAA;EAAA,IACtC,uBAAA;IAA2B,OAAA;IAAkB,UAAA;EAAA;AAAA;;;;;;KAQvC,eAAA;EARuC;;;;EAc7C,YAAA;AAAA,IACE,2BAAA,KACH,oBAAA;EAAyB,YAAA;AAAA;;;;;;;;AAuB9B;;;;;;;;;AAwCA;;;;;iBAxCsB,QAAA,CAAS,OAAA,EAAS,eAAA,GAAkB,OAAA;AAAA,iBAwC1C,UAAA,CAAA;EAAgB,OAAA;EAAkB,UAAA;AAAA;AAAA,iBAQlC,eAAA,CAAA,GAAmB,oBAAA;;;KC7FvB,2BAAA;oDAEV,OAAA,GAAU,qBAAA;;ADHkB;;;ECQ5B,UAAA;AAAA;;;;;;;;;;;iBAac,oBAAA,CAAqB,OAAA,GAAU,2BAAA,GAA8B,MAAA,SAAe,WAAA;;;AC+L5F;;;;AAAA,KA5GY,eAAA,GAAgB,YAAA;AAAA,KA4GhB,WAAA;EACV,WAAA,GAAc,WAAA,kBAA6B,WAAA;EAC3C,cAAA,GAAiB,WAAA,qBAAgC,WAAA;EACjD,cAAA,GAAiB,WAAA,qBAAgC,WAAA;EACjD,eAAA,GAAkB,WAAA,sBAAiC,WAAA;EACnD,eAAA,GAAkB,WAAA,sBAAiC,WAAA;EACnD,kBAAA,GAAqB,WAAA,yBAAoC,WAAA;AAAA;AAAA,KAG/C,mBAAA;AAAA,KAEA,WAAA,sBAAiC,YAAA,KAAiB,OAAA,EAAS,YAAA,CAAa,MAAA;AAAA,KAExE,YAAA;EACV,cAAA;IAAkB,IAAA;IAAgB,WAAA;EAAA;EAClC,WAAA;IAAe,MAAA,EAAQ,mBAAA;EAAA;EACv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AA,GACF,iBAAA,CAAkB,2BAAA,IAA4B,OAAA,CAAA,oBAAA,CAAA,GAAA,CAAA,OAAA;;;cClEpC,mBAAA,GACX,KAAA,EAAO,0BAAA,EACP,gBAAA,GAAmB,iCAAA,KAAiC,oBAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/server/singleton.ts","../../src/server/ssr.ts","../../../js-client-core/src/types.ts","../../../shared/src/logger.ts","../../src/client/types.ts","../../src/server/ConfigDirectorProvider.tsx","../../src/server/logger.ts"],"mappings":";;;;;QASQ,MAAA;EAAA,IACF,4BAAA,EAA8B,oBAAA;EAAA,IAC9B,oCAAA,EAAsC,cAAA;EAAA,IACtC,uBAAA;IAA2B,OAAA;IAAkB,UAAA;EAAA;AAAA;;;;;;KAQvC,eAAA;EARuC;;;;EAc7C,YAAA;AAAA,IACE,2BAAA,KACH,oBAAA;EAAyB,YAAA;AAAA;;;;;;;;AAuB9B;;;;;;;;;AAwCA;;;;;iBAxCsB,QAAA,CAAS,OAAA,EAAS,eAAA,GAAkB,OAAA;AAAA,iBAwC1C,UAAA,CAAA;EAAgB,OAAA;EAAkB,UAAA;AAAA;AAAA,iBAQlC,eAAA,CAAA,GAAmB,oBAAA;;;KC7FvB,2BAAA;oDAEV,OAAA,GAAU,qBAAA;;ADHkB;;;ECQ5B,UAAA;AAAA;;;;;;;;;;;iBAac,oBAAA,CAAqB,OAAA,GAAU,2BAAA,GAA8B,MAAA,SAAe,WAAA;;;ACgM5F;;;;AAAA,KA5GY,eAAA,GAAgB,YAAA;AAAA,KA4GhB,WAAA;EACV,WAAA,GAAc,WAAA,kBAA6B,WAAA;EAC3C,cAAA,GAAiB,WAAA,qBAAgC,WAAA;EACjD,cAAA,GAAiB,WAAA,qBAAgC,WAAA;EACjD,eAAA,GAAkB,WAAA,sBAAiC,WAAA;EACnD,eAAA,GAAkB,WAAA,sBAAiC,WAAA;EACnD,kBAAA,GAAqB,WAAA,yBAAoC,WAAA;AAAA;AAAA,KAG/C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;;;;;;EAM7C,UAAA;AAAA;;;;;;;ALEF;;;;;;;;;;AA+BA;;;;;;;;;AAwCA;;;;;AAQA;;;;;;;;AC7FA;;;;;;;;;AAoBA;;;;;;;;;;iBIoDsB,sBAAA,CAAA;EACpB,QAAA;EACA,UAAA;EAAA,GACG;AAAA,GACF,iBAAA,CAAkB,2BAAA,IAA4B,OAAA,CAAA,oBAAA,CAAA,GAAA,CAAA,OAAA;;;cClEpC,mBAAA,GACX,KAAA,EAAO,0BAAA,EACP,gBAAA,GAAmB,iCAAA,KAAiC,oBAAA"}
@@ -1,2 +1,2 @@
1
- import{i as e,o as t,t as n}from"./native-values-CfqV9hAq.mjs";import{ConfigDirectorProvider as r}from"@configdirector/nextjs-sdk/client";import{jsx as i}from"react/jsx-runtime";var a=class{decorateMessage(e){return`[ConfigDirector:nextjs-sdk] ${e}`}};const o=(e,n)=>new t(e??`warn`,n??new a),s=(e,n)=>new t(e,n??new a);async function c(t){if(process.env.NEXT_RUNTIME===`nodejs`){let n=t.connection?.mode??`streaming`;if(n!==`offline`&&!t.serverSdkKey){let t=`The ConfigDirector serverSdkKey must be provided to register(). You can pass it via process.env.CONFIGDIRECTOR_SERVER_KEY.`;throw o().error(t),new e(t)}if(!globalThis.__configDirectorServerClient){let{DefaultConfigDirectorClient:e}=await import(`./DefaultConfigDirectorClient-BfpJX-Ni.mjs`).then(e=>e.n),{serverSdkKey:r,...i}=t;globalThis.__configDirectorAppMeta={appName:t.metadata?.appName,appVersion:t.metadata?.appVersion},globalThis.__configDirectorServerConnectionMode=n;let a=new e(r,{sdkName:`nextjs-sdk`,sdkVersion:`1.13.1`},i);globalThis.__configDirectorServerClient=a;try{await a.initialize()}catch(e){throw globalThis.__configDirectorServerClient=void 0,globalThis.__configDirectorServerConnectionMode=void 0,globalThis.__configDirectorAppMeta=void 0,a.dispose(),e}}}}function l(){return globalThis.__configDirectorAppMeta??{}}function u(){return globalThis.__configDirectorServerConnectionMode}function d(){if(!globalThis.__configDirectorServerClient)throw new e(`[ConfigDirector] Server client not initialized. Make sure to call register() in your instrumentation.ts file before using the SDK.`);return globalThis.__configDirectorServerClient}const f=o();function p(e){try{return d().getAllConfigs(e)}catch(e){return f.error(`Error retrieving SSR config set:`,e),{}}}const m=(e,t)=>e.mode!==void 0||e.values!==void 0?`as-given`:t===`offline`?`inherit-offline`:`connect`,h=e=>typeof e.value==`string`,g=e=>Object.fromEntries(Object.values(e).filter(h).map(e=>[e.key,n(e.type,e.value)]));async function _({children:e,configKeys:t,...n}){let a=p({context:n.context,configKeys:t}),o=l();return i(r,{...n,...v(a,n),appName:n.appName??o.appName,appVersion:n.appVersion??o.appVersion,initialConfigs:a,children:e})}const v=(e,t)=>{switch(m(t,u())){case`as-given`:return{};case`inherit-offline`:return{mode:`offline`,values:g(e)};case`connect`:return{}}};export{e as ConfigDirectorInitializationError,_ as ConfigDirectorProvider,s as createConsoleLogger,p as generateSsrConfigSet,l as getAppMeta,d as getConfigClient,c as register};
1
+ import{i as e,o as t,t as n}from"./native-values-CfqV9hAq.mjs";import{ConfigDirectorProvider as r}from"@configdirector/nextjs-sdk/client";import{jsx as i}from"react/jsx-runtime";var a=class{decorateMessage(e){return`[ConfigDirector:nextjs-sdk] ${e}`}};const o=(e,n)=>new t(e??`warn`,n??new a),s=(e,n)=>new t(e,n??new a);async function c(t){if(process.env.NEXT_RUNTIME===`nodejs`){let n=t.connection?.mode??`streaming`;if(n!==`offline`&&!t.serverSdkKey){let t=`The ConfigDirector serverSdkKey must be provided to register(). You can pass it via process.env.CONFIGDIRECTOR_SERVER_KEY.`;throw o().error(t),new e(t)}if(!globalThis.__configDirectorServerClient){let{DefaultConfigDirectorClient:e}=await import(`./DefaultConfigDirectorClient-kQ30B5mx.mjs`).then(e=>e.n),{serverSdkKey:r,...i}=t;globalThis.__configDirectorAppMeta={appName:t.metadata?.appName,appVersion:t.metadata?.appVersion},globalThis.__configDirectorServerConnectionMode=n;let a=new e(r,{sdkName:`nextjs-sdk`,sdkVersion:`1.14.1`},i);globalThis.__configDirectorServerClient=a;try{await a.initialize()}catch(e){throw globalThis.__configDirectorServerClient=void 0,globalThis.__configDirectorServerConnectionMode=void 0,globalThis.__configDirectorAppMeta=void 0,a.dispose(),e}}}}function l(){return globalThis.__configDirectorAppMeta??{}}function u(){return globalThis.__configDirectorServerConnectionMode}function d(){if(!globalThis.__configDirectorServerClient)throw new e(`[ConfigDirector] Server client not initialized. Make sure to call register() in your instrumentation.ts file before using the SDK.`);return globalThis.__configDirectorServerClient}const f=o();function p(e){try{return d().getAllConfigs(e)}catch(e){return f.error(`Error retrieving SSR config set:`,e),{}}}const m=(e,t)=>e.mode!==void 0||e.values!==void 0?`as-given`:t===`offline`?`inherit-offline`:`connect`,h=e=>typeof e.value==`string`,g=e=>Object.fromEntries(Object.values(e).filter(h).map(e=>[e.key,n(e.type,e.value)]));async function _({children:e,configKeys:t,...n}){let a=p({context:n.context,configKeys:t}),o=l();return i(r,{...n,...v(a,n),appName:n.appName??o.appName,appVersion:n.appVersion??o.appVersion,initialConfigs:a,children:e})}const v=(e,t)=>{switch(m(t,u())){case`as-given`:return{};case`inherit-offline`:return{mode:`offline`,values:g(e)};case`connect`:return{}}};export{e as ConfigDirectorInitializationError,_ as ConfigDirectorProvider,s as createConsoleLogger,p as generateSsrConfigSet,l as getAppMeta,d as getConfigClient,c as register};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./DefaultConfigDirectorClient-C4cOinqO.cjs`),t=require(`./native-values-UCK4hh1Z.cjs`);let n=require(`node:events`);n=e.o(n);const r={environmentId:`test-environment`,projectId:`test-project`};var i=class{constructor(e,t){this.logger=e,this.emitter=new n.default,this.configs=new Map,this.pendingDeliveries=[],this.armed=`nothing`,this.connected=!1,this.delivering=!1,this.encodeAll(t).forEach((e,t)=>this.configs.set(t,e))}setValue(e,t){let n=this.encode(e,t);this.configs.set(e,n),this.deliverIfConnected({...r,kind:`delta`,configs:{[e]:n}})}removeValue(e){this.configs.delete(e),this.deliverIfConnected(this.fullUpdate())}replaceValues(e){let t=this.encodeAll(e);this.configs.clear(),t.forEach((e,t)=>this.configs.set(t,e)),this.armed=`nothing`,this.deliverIfConnected(this.fullUpdate())}hold(){this.armed=`hold`}complete(){this.pendingHold?this.pendingHold.complete():this.armed===`hold`&&(this.armed=`nothing`)}fail(){this.pendingHold?this.pendingHold.fail():this.armed=`failure`}connect(e){this.endAttempt();let t=this.armed;switch(this.armed=`nothing`,t){case`failure`:return this.failNow();case`hold`:return this.holdNow(e);default:return this.connectNow(),Promise.resolve(this)}}get isConnected(){return this.connected}on(e,t){this.emitter.on(e,t)}off(e,t){t?this.emitter.off(e,t):this.emitter.removeAllListeners(e)}close(){this.endAttempt()}dispose(){this.close(),this.emitter.removeAllListeners()}endAttempt(){this.connected=!1,this.pendingHold?.end()}connectNow(){this.connected=!0,this.deliver(this.fullUpdate())}holdNow(e){return new Promise((t,n)=>{let r=setTimeout(()=>this.pendingHold?.end(),e),i=()=>{clearTimeout(r),this.pendingHold=void 0};this.pendingHold={end:()=>{i(),t(this)},complete:()=>{i(),this.connectNow(),t(this)},fail:()=>{i();let e=this.fatalError();this.emitter.emit(`connectionError`,e),n(e)}}})}failNow(){let e=this.fatalError();return this.emitter.emit(`connectionError`,e),Promise.reject(e)}fatalError(){return new t.r(`Connection failed with status: 401. Error: the test client failed this initialization. This is an unrecoverable error, will not attempt to reconnect.`,401)}deliverIfConnected(e){this.connected&&this.deliver(e)}deliver(e){if(this.pendingDeliveries.push(e),!this.delivering){this.delivering=!0;try{let e=this.pendingDeliveries.shift();for(;e;)this.emitCaught(e),e=this.pendingDeliveries.shift()}finally{this.delivering=!1}}}emitCaught(e){try{this.emitter.emit(`configBundleReceived`,e)}catch(e){this.logger.error(`[InMemoryConnection] Error dispatching a config update from the test client: `,e)}}fullUpdate(){return{...r,kind:`full`,configs:Object.fromEntries(this.configs)}}encodeAll(e){let t=new Map;for(let[n,r]of Object.entries(e))t.set(n,this.encode(n,r));return t}encode(t,n){return e.a(`test-config:${t}`,t,n)}},a=class{constructor(e,t){this.client=e,this.connection=t}setValue(e,t){this.connection.setValue(e,t)}removeValue(e){this.connection.removeValue(e)}replaceValues(e){this.connection.replaceValues(e)}holdInitialization(){this.connection.hold()}completeInitialization(){this.connection.complete()}failInitialization(){this.connection.fail()}};const o=(t,n)=>{let r=n?.logger??e.i(),o=new i(r,n?.values??{});return new a(new e.t(`test-client`,t,{logger:r,connection:{timeout:n?.timeout}},{transport:o,telemetry:e.r}),o)},s=e=>o({sdkName:`nextjs-sdk`,sdkVersion:`1.13.1`},e),c=e=>{let t=globalThis.__configDirectorServerClient;return globalThis.__configDirectorServerClient=e.client,()=>{globalThis.__configDirectorServerClient=t}};exports.ConfigDirectorConnectionError=t.r,exports.ConfigDirectorValidationError=t.a,exports.createTestClient=s,exports.installServerTestClient=c;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./DefaultConfigDirectorClient-BylArFbJ.cjs`),t=require(`./native-values-UCK4hh1Z.cjs`);let n=require(`node:events`);n=e.s(n);const r=(e,t)=>({name:e.name,...t===void 0?{}:{context:t},...e.value===void 0?{}:{value:e.value},...e.details===void 0?{}:{details:e.details}});var i=class{constructor(e){this.logger=e,this.events=[]}record(t,n){switch(t.warnings.forEach(t=>this.logger.warn(e.i[t])),t.outcome){case`dropped`:return;case`admitted`:this.events.push(r(t.entry,n));return}}};const a={environmentId:`test-environment`,projectId:`test-project`};var o=class{constructor(e,t){this.logger=e,this.emitter=new n.default,this.configs=new Map,this.pendingDeliveries=[],this.armed=`nothing`,this.connected=!1,this.delivering=!1,this.encodeAll(t).forEach((e,t)=>this.configs.set(t,e))}setValue(e,t){let n=this.encode(e,t);this.configs.set(e,n),this.deliverIfConnected({...a,kind:`delta`,configs:{[e]:n}})}removeValue(e){this.configs.delete(e),this.deliverIfConnected(this.fullUpdate())}replaceValues(e){let t=this.encodeAll(e);this.configs.clear(),t.forEach((e,t)=>this.configs.set(t,e)),this.armed=`nothing`,this.deliverIfConnected(this.fullUpdate())}hold(){this.armed=`hold`}complete(){this.pendingHold?this.pendingHold.complete():this.armed===`hold`&&(this.armed=`nothing`)}fail(){this.pendingHold?this.pendingHold.fail():this.armed=`failure`}connect(e){this.endAttempt();let t=this.armed;switch(this.armed=`nothing`,t){case`failure`:return this.failNow();case`hold`:return this.holdNow(e);default:return this.connectNow(),Promise.resolve(this)}}get isConnected(){return this.connected}on(e,t){this.emitter.on(e,t)}off(e,t){t?this.emitter.off(e,t):this.emitter.removeAllListeners(e)}close(){this.endAttempt()}dispose(){this.close(),this.emitter.removeAllListeners()}endAttempt(){this.connected=!1,this.pendingHold?.end()}connectNow(){this.connected=!0,this.deliver(this.fullUpdate())}holdNow(e){return new Promise((t,n)=>{let r=setTimeout(()=>this.pendingHold?.end(),e),i=()=>{clearTimeout(r),this.pendingHold=void 0};this.pendingHold={end:()=>{i(),t(this)},complete:()=>{i(),this.connectNow(),t(this)},fail:()=>{i();let e=this.fatalError();this.emitter.emit(`connectionError`,e),n(e)}}})}failNow(){let e=this.fatalError();return this.emitter.emit(`connectionError`,e),Promise.reject(e)}fatalError(){return new t.r(`Connection failed with status: 401. Error: the test client failed this initialization. This is an unrecoverable error, will not attempt to reconnect.`,401)}deliverIfConnected(e){this.connected&&this.deliver(e)}deliver(e){if(this.pendingDeliveries.push(e),!this.delivering){this.delivering=!0;try{let e=this.pendingDeliveries.shift();for(;e;)this.emitCaught(e),e=this.pendingDeliveries.shift()}finally{this.delivering=!1}}}emitCaught(e){try{this.emitter.emit(`configBundleReceived`,e)}catch(e){this.logger.error(`[InMemoryConnection] Error dispatching a config update from the test client: `,e)}}fullUpdate(){return{...a,kind:`full`,configs:Object.fromEntries(this.configs)}}encodeAll(e){let t=new Map;for(let[n,r]of Object.entries(e))t.set(n,this.encode(n,r));return t}encode(t,n){return e.o(`test-config:${t}`,t,n)}},s=class{constructor(e,t,n){this.client=e,this.connection=t,this.trackedEvents=n}setValue(e,t){this.connection.setValue(e,t)}removeValue(e){this.connection.removeValue(e)}replaceValues(e){this.connection.replaceValues(e)}holdInitialization(){this.connection.hold()}completeInitialization(){this.connection.complete()}failInitialization(){this.connection.fail()}};const c=(t,n)=>{let r=n?.logger??e.a(),a=new o(r,n?.values??{}),c=new i(r);return new s(new e.t(`test-client`,t,{logger:r,connection:{timeout:n?.timeout}},{transport:a,telemetry:{...e.r,trackedEvent:(e,t)=>c.record(e,t)}}),a,c.events)},l=e=>c({sdkName:`nextjs-sdk`,sdkVersion:`1.14.1`},e),u=e=>{let t=globalThis.__configDirectorServerClient;return globalThis.__configDirectorServerClient=e.client,()=>{globalThis.__configDirectorServerClient=t}};exports.ConfigDirectorConnectionError=t.r,exports.ConfigDirectorValidationError=t.a,exports.createTestClient=l,exports.installServerTestClient=u;
@@ -1,4 +1,4 @@
1
- import { d as NativeValues, i as ConfigDirectorClient, l as NativeJsonValue, m as ConfigDirectorLogger, r as ConfigDirectorValidationError, t as ConfigDirectorConnectionError, u as NativeValue } from "./errors-Do5xWGgb.cjs";
1
+ import { C as TrackedEvent, T as TrackedEventDetails, d as NativeValues, i as ConfigDirectorClient, l as NativeJsonValue, m as ConfigDirectorLogger, r as ConfigDirectorValidationError, t as ConfigDirectorConnectionError, u as NativeValue, w as TrackedEventDetailValue } from "./errors-CkxBFyZy.cjs";
2
2
 
3
3
  //#region ../js-server-sdk/src/testing/TestClient.d.ts
4
4
  /**
@@ -20,7 +20,8 @@ type TestClientOptions = {
20
20
  /**
21
21
  * The logger the SDK client uses. Defaults to the SDK's console logger at `warn` level. Since
22
22
  * the test client sends no telemetry, every read that supplies a context with an invalid kind
23
- * logs an error, rather than each invalid kind once per telemetry interval.
23
+ * logs an error, rather than each invalid kind once per telemetry interval. For the same reason,
24
+ * every tracked event that is not recorded as it was tracked logs a warning.
24
25
  */
25
26
  logger?: ConfigDirectorLogger;
26
27
  };
@@ -68,6 +69,14 @@ interface TestClient {
68
69
  * to fail. `initialize` completes promptly with the client not ready and `connectionError` fires.
69
70
  */
70
71
  failInitialization(): void;
72
+ /**
73
+ * Every event the code under test tracked through the client, in call order, as the SDK would
74
+ * report it: an event whose name does not have 1 to 150 characters is not recorded, and a value
75
+ * or details the SDK would leave out are missing from the record. A context whose kind is
76
+ * invalid is not recorded with its event. The limit of 1,000 events per telemetry batch does not
77
+ * apply.
78
+ */
79
+ readonly trackedEvents: TrackedEvent[];
71
80
  }
72
81
  //#endregion
73
82
  //#region src/server/testing.d.ts
@@ -97,5 +106,5 @@ declare const createTestClient: (options?: TestClientOptions) => TestClient;
97
106
  */
98
107
  declare const installServerTestClient: (testClient: TestClient) => (() => void);
99
108
  //#endregion
100
- export { ConfigDirectorConnectionError, ConfigDirectorValidationError, type TestClient, type TestClientOptions, type NativeJsonValue as TestJsonValue, type NativeValue as TestValue, type NativeValues as TestValues, createTestClient, installServerTestClient };
109
+ export { ConfigDirectorConnectionError, ConfigDirectorValidationError, type TestClient, type TestClientOptions, type NativeJsonValue as TestJsonValue, type NativeValue as TestValue, type NativeValues as TestValues, type TrackedEvent, type TrackedEventDetailValue, type TrackedEventDetails, createTestClient, installServerTestClient };
101
110
  //# sourceMappingURL=testing.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"testing.d.cts","names":[],"sources":["../../../js-server-sdk/src/testing/TestClient.ts","../../src/server/testing.ts"],"mappings":";;;;AAYA;;KAAY,iBAAA;EAkBmB;;;;;;EAX7B,MAAA,GAAS,YAAA;EAWoB;AAW/B;;;EAjBE,OAAA;EA4B6B;;;;;EAtB7B,MAAA,GAAS,oBAAA;AAAA;;;;;;;;;UAWM,UAAA;EAmCf;;;;EAAA,SA9BS,MAAA,EAAQ,oBAAA;;;ACxBnB;;ED8BE,QAAA,CAAS,GAAA,UAAa,KAAA,EAAO,WAAA;EC5B9B;;;;EDkCC,WAAA,CAAY,GAAA;EClCb;AAUD;;;ED8BE,aAAA,CAAc,MAAA,EAAQ,YAAA;EC9BsC;;;;EDoC5D,kBAAA;;;;;EAMA,sBAAA;;;;;EAMA,kBAAA;AAAA;;;;;;;;;;;;;AAzCF;;;;;cCnBa,gBAAA,GAAoB,OAAA,GAAU,iBAAA,KAAoB,UAAA;;;;;;;;;cAYlD,uBAAA,GAA2B,UAAA,EAAY,UAAA"}
1
+ {"version":3,"file":"testing.d.cts","names":[],"sources":["../../../js-server-sdk/src/testing/TestClient.ts","../../src/server/testing.ts"],"mappings":";;;AAcA;;;AAAA,KAAY,iBAAA;EAOV;;;;;;EAAA,MAAA,GAAS,YAAA;EAuBM;;;;EAlBf,OAAA;EAyCsB;;;;;;EAlCtB,MAAA,GAAS,oBAAA;AAAA;;;;;;;;;UAWM,UAAA;EAyCf;;;;EAAA,SApCS,MAAA,EAAQ,oBAAA;;;;AC1BnB;EDgCE,QAAA,CAAS,GAAA,UAAa,KAAA,EAAO,WAAA;;;;;EAM7B,WAAA,CAAY,GAAA;ECpCb;;AAUD;;EDgCE,aAAA,CAAc,MAAA,EAAQ,YAAA;EChC4B;;;;EDsClD,kBAAA;;;;;EAMA,sBAAA;;;;;EAMA,kBAAA;;;;;;;;WASS,aAAA,EAAe,YAAA;AAAA;;;;;;;;;;;;AAlD1B;;;;;;cCrBa,gBAAA,GAAoB,OAAA,GAAU,iBAAA,KAAoB,UAAA;;;;;;;;;cAYlD,uBAAA,GAA2B,UAAA,EAAY,UAAA"}
@@ -1,4 +1,4 @@
1
- import { d as NativeValues, i as ConfigDirectorClient, l as NativeJsonValue, m as ConfigDirectorLogger, r as ConfigDirectorValidationError, t as ConfigDirectorConnectionError, u as NativeValue } from "./errors-CxXHE84y.mjs";
1
+ import { C as TrackedEvent, T as TrackedEventDetails, d as NativeValues, i as ConfigDirectorClient, l as NativeJsonValue, m as ConfigDirectorLogger, r as ConfigDirectorValidationError, t as ConfigDirectorConnectionError, u as NativeValue, w as TrackedEventDetailValue } from "./errors-CsEeGYMl.mjs";
2
2
 
3
3
  //#region ../js-server-sdk/src/testing/TestClient.d.ts
4
4
  /**
@@ -20,7 +20,8 @@ type TestClientOptions = {
20
20
  /**
21
21
  * The logger the SDK client uses. Defaults to the SDK's console logger at `warn` level. Since
22
22
  * the test client sends no telemetry, every read that supplies a context with an invalid kind
23
- * logs an error, rather than each invalid kind once per telemetry interval.
23
+ * logs an error, rather than each invalid kind once per telemetry interval. For the same reason,
24
+ * every tracked event that is not recorded as it was tracked logs a warning.
24
25
  */
25
26
  logger?: ConfigDirectorLogger;
26
27
  };
@@ -68,6 +69,14 @@ interface TestClient {
68
69
  * to fail. `initialize` completes promptly with the client not ready and `connectionError` fires.
69
70
  */
70
71
  failInitialization(): void;
72
+ /**
73
+ * Every event the code under test tracked through the client, in call order, as the SDK would
74
+ * report it: an event whose name does not have 1 to 150 characters is not recorded, and a value
75
+ * or details the SDK would leave out are missing from the record. A context whose kind is
76
+ * invalid is not recorded with its event. The limit of 1,000 events per telemetry batch does not
77
+ * apply.
78
+ */
79
+ readonly trackedEvents: TrackedEvent[];
71
80
  }
72
81
  //#endregion
73
82
  //#region src/server/testing.d.ts
@@ -97,5 +106,5 @@ declare const createTestClient: (options?: TestClientOptions) => TestClient;
97
106
  */
98
107
  declare const installServerTestClient: (testClient: TestClient) => (() => void);
99
108
  //#endregion
100
- export { ConfigDirectorConnectionError, ConfigDirectorValidationError, type TestClient, type TestClientOptions, type NativeJsonValue as TestJsonValue, type NativeValue as TestValue, type NativeValues as TestValues, createTestClient, installServerTestClient };
109
+ export { ConfigDirectorConnectionError, ConfigDirectorValidationError, type TestClient, type TestClientOptions, type NativeJsonValue as TestJsonValue, type NativeValue as TestValue, type NativeValues as TestValues, type TrackedEvent, type TrackedEventDetailValue, type TrackedEventDetails, createTestClient, installServerTestClient };
101
110
  //# sourceMappingURL=testing.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"testing.d.mts","names":[],"sources":["../../../js-server-sdk/src/testing/TestClient.ts","../../src/server/testing.ts"],"mappings":";;;;AAYA;;KAAY,iBAAA;EAkBmB;;;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as n,t as r}from"./DefaultConfigDirectorClient-BfpJX-Ni.mjs";import{a as i,r as a}from"./native-values-CfqV9hAq.mjs";import o from"node:events";const s={environmentId:`test-environment`,projectId:`test-project`};var c=class{constructor(e,t){this.logger=e,this.emitter=new o,this.configs=new Map,this.pendingDeliveries=[],this.armed=`nothing`,this.connected=!1,this.delivering=!1,this.encodeAll(t).forEach((e,t)=>this.configs.set(t,e))}setValue(e,t){let n=this.encode(e,t);this.configs.set(e,n),this.deliverIfConnected({...s,kind:`delta`,configs:{[e]:n}})}removeValue(e){this.configs.delete(e),this.deliverIfConnected(this.fullUpdate())}replaceValues(e){let t=this.encodeAll(e);this.configs.clear(),t.forEach((e,t)=>this.configs.set(t,e)),this.armed=`nothing`,this.deliverIfConnected(this.fullUpdate())}hold(){this.armed=`hold`}complete(){this.pendingHold?this.pendingHold.complete():this.armed===`hold`&&(this.armed=`nothing`)}fail(){this.pendingHold?this.pendingHold.fail():this.armed=`failure`}connect(e){this.endAttempt();let t=this.armed;switch(this.armed=`nothing`,t){case`failure`:return this.failNow();case`hold`:return this.holdNow(e);default:return this.connectNow(),Promise.resolve(this)}}get isConnected(){return this.connected}on(e,t){this.emitter.on(e,t)}off(e,t){t?this.emitter.off(e,t):this.emitter.removeAllListeners(e)}close(){this.endAttempt()}dispose(){this.close(),this.emitter.removeAllListeners()}endAttempt(){this.connected=!1,this.pendingHold?.end()}connectNow(){this.connected=!0,this.deliver(this.fullUpdate())}holdNow(e){return new Promise((t,n)=>{let r=setTimeout(()=>this.pendingHold?.end(),e),i=()=>{clearTimeout(r),this.pendingHold=void 0};this.pendingHold={end:()=>{i(),t(this)},complete:()=>{i(),this.connectNow(),t(this)},fail:()=>{i();let e=this.fatalError();this.emitter.emit(`connectionError`,e),n(e)}}})}failNow(){let e=this.fatalError();return this.emitter.emit(`connectionError`,e),Promise.reject(e)}fatalError(){return new a(`Connection failed with status: 401. Error: the test client failed this initialization. This is an unrecoverable error, will not attempt to reconnect.`,401)}deliverIfConnected(e){this.connected&&this.deliver(e)}deliver(e){if(this.pendingDeliveries.push(e),!this.delivering){this.delivering=!0;try{let e=this.pendingDeliveries.shift();for(;e;)this.emitCaught(e),e=this.pendingDeliveries.shift()}finally{this.delivering=!1}}}emitCaught(e){try{this.emitter.emit(`configBundleReceived`,e)}catch(e){this.logger.error(`[InMemoryConnection] Error dispatching a config update from the test client: `,e)}}fullUpdate(){return{...s,kind:`full`,configs:Object.fromEntries(this.configs)}}encodeAll(e){let t=new Map;for(let[n,r]of Object.entries(e))t.set(n,this.encode(n,r));return t}encode(t,n){return e(`test-config:${t}`,t,n)}},l=class{constructor(e,t){this.client=e,this.connection=t}setValue(e,t){this.connection.setValue(e,t)}removeValue(e){this.connection.removeValue(e)}replaceValues(e){this.connection.replaceValues(e)}holdInitialization(){this.connection.hold()}completeInitialization(){this.connection.complete()}failInitialization(){this.connection.fail()}};const u=(e,i)=>{let a=i?.logger??t(),o=new c(a,i?.values??{});return new l(new r(`test-client`,e,{logger:a,connection:{timeout:i?.timeout}},{transport:o,telemetry:n}),o)},d=e=>u({sdkName:`nextjs-sdk`,sdkVersion:`1.13.1`},e),f=e=>{let t=globalThis.__configDirectorServerClient;return globalThis.__configDirectorServerClient=e.client,()=>{globalThis.__configDirectorServerClient=t}};export{a as ConfigDirectorConnectionError,i as ConfigDirectorValidationError,d as createTestClient,f as installServerTestClient};
1
+ import{a as e,i as t,o as n,r,t as i}from"./DefaultConfigDirectorClient-kQ30B5mx.mjs";import{a,r as o}from"./native-values-CfqV9hAq.mjs";import s from"node:events";const c=(e,t)=>({name:e.name,...t===void 0?{}:{context:t},...e.value===void 0?{}:{value:e.value},...e.details===void 0?{}:{details:e.details}});var l=class{constructor(e){this.logger=e,this.events=[]}record(e,n){switch(e.warnings.forEach(e=>this.logger.warn(t[e])),e.outcome){case`dropped`:return;case`admitted`:this.events.push(c(e.entry,n));return}}};const u={environmentId:`test-environment`,projectId:`test-project`};var d=class{constructor(e,t){this.logger=e,this.emitter=new s,this.configs=new Map,this.pendingDeliveries=[],this.armed=`nothing`,this.connected=!1,this.delivering=!1,this.encodeAll(t).forEach((e,t)=>this.configs.set(t,e))}setValue(e,t){let n=this.encode(e,t);this.configs.set(e,n),this.deliverIfConnected({...u,kind:`delta`,configs:{[e]:n}})}removeValue(e){this.configs.delete(e),this.deliverIfConnected(this.fullUpdate())}replaceValues(e){let t=this.encodeAll(e);this.configs.clear(),t.forEach((e,t)=>this.configs.set(t,e)),this.armed=`nothing`,this.deliverIfConnected(this.fullUpdate())}hold(){this.armed=`hold`}complete(){this.pendingHold?this.pendingHold.complete():this.armed===`hold`&&(this.armed=`nothing`)}fail(){this.pendingHold?this.pendingHold.fail():this.armed=`failure`}connect(e){this.endAttempt();let t=this.armed;switch(this.armed=`nothing`,t){case`failure`:return this.failNow();case`hold`:return this.holdNow(e);default:return this.connectNow(),Promise.resolve(this)}}get isConnected(){return this.connected}on(e,t){this.emitter.on(e,t)}off(e,t){t?this.emitter.off(e,t):this.emitter.removeAllListeners(e)}close(){this.endAttempt()}dispose(){this.close(),this.emitter.removeAllListeners()}endAttempt(){this.connected=!1,this.pendingHold?.end()}connectNow(){this.connected=!0,this.deliver(this.fullUpdate())}holdNow(e){return new Promise((t,n)=>{let r=setTimeout(()=>this.pendingHold?.end(),e),i=()=>{clearTimeout(r),this.pendingHold=void 0};this.pendingHold={end:()=>{i(),t(this)},complete:()=>{i(),this.connectNow(),t(this)},fail:()=>{i();let e=this.fatalError();this.emitter.emit(`connectionError`,e),n(e)}}})}failNow(){let e=this.fatalError();return this.emitter.emit(`connectionError`,e),Promise.reject(e)}fatalError(){return new o(`Connection failed with status: 401. Error: the test client failed this initialization. This is an unrecoverable error, will not attempt to reconnect.`,401)}deliverIfConnected(e){this.connected&&this.deliver(e)}deliver(e){if(this.pendingDeliveries.push(e),!this.delivering){this.delivering=!0;try{let e=this.pendingDeliveries.shift();for(;e;)this.emitCaught(e),e=this.pendingDeliveries.shift()}finally{this.delivering=!1}}}emitCaught(e){try{this.emitter.emit(`configBundleReceived`,e)}catch(e){this.logger.error(`[InMemoryConnection] Error dispatching a config update from the test client: `,e)}}fullUpdate(){return{...u,kind:`full`,configs:Object.fromEntries(this.configs)}}encodeAll(e){let t=new Map;for(let[n,r]of Object.entries(e))t.set(n,this.encode(n,r));return t}encode(e,t){return n(`test-config:${e}`,e,t)}},f=class{constructor(e,t,n){this.client=e,this.connection=t,this.trackedEvents=n}setValue(e,t){this.connection.setValue(e,t)}removeValue(e){this.connection.removeValue(e)}replaceValues(e){this.connection.replaceValues(e)}holdInitialization(){this.connection.hold()}completeInitialization(){this.connection.complete()}failInitialization(){this.connection.fail()}};const p=(t,n)=>{let a=n?.logger??e(),o=new d(a,n?.values??{}),s=new l(a);return new f(new i(`test-client`,t,{logger:a,connection:{timeout:n?.timeout}},{transport:o,telemetry:{...r,trackedEvent:(e,t)=>s.record(e,t)}}),o,s.events)},m=e=>p({sdkName:`nextjs-sdk`,sdkVersion:`1.14.1`},e),h=e=>{let t=globalThis.__configDirectorServerClient;return globalThis.__configDirectorServerClient=e.client,()=>{globalThis.__configDirectorServerClient=t}};export{o as ConfigDirectorConnectionError,a as ConfigDirectorValidationError,m as createTestClient,h as installServerTestClient};
2
2
  //# sourceMappingURL=testing.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"testing.mjs","names":["createTestClient"],"sources":["../../../js-server-sdk/src/testing/InMemoryConnection.ts","../../../js-server-sdk/src/testing/TestClient.ts","../../src/server/testing.ts"],"sourcesContent":["import EventEmitter from \"node:events\";\nimport type { ConfigBundle, ConfigDefinition, ConfigDirectorLogger, Transport, TransportEvents } from \"../types\";\nimport { ConfigDirectorConnectionError } from \"@shared/errors\";\nimport type { TestValue, TestValues } from \"./values\";\nimport { unconditionalConfig } from \"../native-values\";\n\ntype Armed = \"nothing\" | \"hold\" | \"failure\";\n\ntype PendingHold = {\n end: () => void;\n complete: () => void;\n fail: () => void;\n};\n\nconst TEST_ENVIRONMENT = { environmentId: \"test-environment\", projectId: \"test-project\" };\n\nexport class InMemoryConnection implements Transport {\n private readonly emitter = new EventEmitter();\n private readonly configs = new Map<string, ConfigDefinition>();\n private readonly pendingDeliveries: ConfigBundle[] = [];\n private armed: Armed = \"nothing\";\n private pendingHold: PendingHold | undefined;\n private connected = false;\n private delivering = false;\n\n constructor(\n private readonly logger: ConfigDirectorLogger,\n values: TestValues,\n ) {\n this.encodeAll(values).forEach((definition, key) => this.configs.set(key, definition));\n }\n\n public setValue(key: string, value: TestValue) {\n const definition = this.encode(key, value);\n this.configs.set(key, definition);\n this.deliverIfConnected({ ...TEST_ENVIRONMENT, kind: \"delta\", configs: { [key]: definition } });\n }\n\n public removeValue(key: string) {\n this.configs.delete(key);\n this.deliverIfConnected(this.fullUpdate());\n }\n\n public replaceValues(values: TestValues) {\n const encoded = this.encodeAll(values);\n this.configs.clear();\n encoded.forEach((definition, key) => this.configs.set(key, definition));\n this.armed = \"nothing\";\n this.deliverIfConnected(this.fullUpdate());\n }\n\n public hold() {\n this.armed = \"hold\";\n }\n\n public complete() {\n if (this.pendingHold) {\n this.pendingHold.complete();\n } else if (this.armed === \"hold\") {\n this.armed = \"nothing\";\n }\n }\n\n public fail() {\n if (this.pendingHold) {\n this.pendingHold.fail();\n } else {\n this.armed = \"failure\";\n }\n }\n\n public connect(timeout: number): Promise<this> {\n this.endAttempt();\n const armed = this.armed;\n this.armed = \"nothing\";\n switch (armed) {\n case \"failure\":\n return this.failNow();\n case \"hold\":\n return this.holdNow(timeout);\n default:\n this.connectNow();\n return Promise.resolve(this);\n }\n }\n\n public get isConnected(): boolean {\n return this.connected;\n }\n\n public on<TName extends keyof TransportEvents>(name: TName, handler: (payload: TransportEvents[TName]) => void) {\n this.emitter.on(name, handler);\n }\n\n public off<TName extends keyof TransportEvents>(name: TName, handler?: (payload: TransportEvents[TName]) => void) {\n if (handler) {\n this.emitter.off(name, handler);\n } else {\n this.emitter.removeAllListeners(name);\n }\n }\n\n public close() {\n this.endAttempt();\n }\n\n public dispose() {\n this.close();\n this.emitter.removeAllListeners();\n }\n\n private endAttempt() {\n this.connected = false;\n this.pendingHold?.end();\n }\n\n private connectNow() {\n this.connected = true;\n this.deliver(this.fullUpdate());\n }\n\n private holdNow(timeout: number): Promise<this> {\n return new Promise<this>((resolve, reject) => {\n const timer = setTimeout(() => this.pendingHold?.end(), timeout);\n const release = () => {\n clearTimeout(timer);\n this.pendingHold = undefined;\n };\n this.pendingHold = {\n end: () => {\n release();\n resolve(this);\n },\n complete: () => {\n release();\n this.connectNow();\n resolve(this);\n },\n fail: () => {\n release();\n const error = this.fatalError();\n this.emitter.emit(\"connectionError\", error);\n reject(error);\n },\n };\n });\n }\n\n private failNow(): Promise<this> {\n const error = this.fatalError();\n this.emitter.emit(\"connectionError\", error);\n return Promise.reject(error);\n }\n\n private fatalError() {\n return new ConfigDirectorConnectionError(\n \"Connection failed with status: 401. Error: the test client failed this initialization. This is an unrecoverable error, will not attempt to reconnect.\",\n 401,\n );\n }\n\n private deliverIfConnected(configBundle: ConfigBundle) {\n if (this.connected) {\n this.deliver(configBundle);\n }\n }\n\n private deliver(configBundle: ConfigBundle) {\n this.pendingDeliveries.push(configBundle);\n if (this.delivering) {\n return;\n }\n this.delivering = true;\n try {\n let next = this.pendingDeliveries.shift();\n while (next) {\n this.emitCaught(next);\n next = this.pendingDeliveries.shift();\n }\n } finally {\n this.delivering = false;\n }\n }\n\n private emitCaught(configBundle: ConfigBundle) {\n try {\n this.emitter.emit(\"configBundleReceived\", configBundle);\n } catch (error) {\n this.logger.error(\"[InMemoryConnection] Error dispatching a config update from the test client: \", error);\n }\n }\n\n private fullUpdate(): ConfigBundle {\n return { ...TEST_ENVIRONMENT, kind: \"full\", configs: Object.fromEntries(this.configs) };\n }\n\n private encodeAll(values: TestValues): Map<string, ConfigDefinition> {\n const encoded = new Map<string, ConfigDefinition>();\n for (const [key, value] of Object.entries(values)) {\n encoded.set(key, this.encode(key, value));\n }\n return encoded;\n }\n\n private encode(key: string, value: TestValue): ConfigDefinition {\n return unconditionalConfig(`test-config:${key}`, key, value);\n }\n}\n","import { DefaultConfigDirectorClient } from \"../DefaultConfigDirectorClient\";\nimport { createDefaultLogger } from \"../logger\";\nimport type { ConfigDirectorClient, ConfigDirectorLogger, IdentifyingSdkOptions } from \"../types\";\nimport { discardingTelemetryClient } from \"../telemetry/discarding\";\nimport { InMemoryConnection } from \"./InMemoryConnection\";\nimport type { TestValue, TestValues } from \"./values\";\n\nconst TEST_CLIENT_SDK_KEY = \"test-client\";\n\n/**\n * Options for {@link createTestClient}. Every option is optional.\n */\nexport type TestClientOptions = {\n /**\n * The config values the test client serves once its client connects, keyed by config key. The\n * config type follows from each value: a boolean, an integral number (`integer`), any other\n * number (`float`), a string, or a plain object or array (`json`). Every context receives the\n * same value.\n */\n values?: TestValues;\n /**\n * The connection timeout of the SDK client, in milliseconds. It bounds how long a held\n * `initialize` waits. Defaults to the SDK's production timeout.\n */\n timeout?: number;\n /**\n * The logger the SDK client uses. Defaults to the SDK's console logger at `warn` level. Since\n * the test client sends no telemetry, every read that supplies a context with an invalid kind\n * logs an error, rather than each invalid kind once per telemetry interval.\n */\n logger?: ConfigDirectorLogger;\n};\n\n/**\n * A real ConfigDirector client connected to an in-memory server that the test controls.\n *\n * The client under {@link TestClient.client} is the SDK's production client: value parsing,\n * targeting evaluation, watchers, events, and readiness behave as they do against ConfigDirector.\n * Only the network connection and telemetry are replaced, so no request is ever made and nothing\n * is left running after the client is disposed.\n */\nexport interface TestClient {\n /**\n * The SDK client to hand to the code under test. It starts uninitialized, like a production\n * client; `initialize` completes at once with the seeded values unless initialization is held.\n */\n readonly client: ConfigDirectorClient;\n\n /**\n * Stores `value` under `key` and, when the client is connected, delivers it as an update, so\n * reads, watchers, and `configsUpdated` handlers see it.\n */\n setValue(key: string, value: TestValue): void;\n\n /**\n * Removes `key` and, when the client is connected, delivers a full update without it, so reads\n * fall back to the in-code default value and watchers of `key` receive that default.\n */\n removeValue(key: string): void;\n\n /**\n * Replaces every stored value with `values`, disarms any armed hold or failure, and, when the\n * client is connected, delivers the new values as a full update.\n */\n replaceValues(values: TestValues): void;\n\n /**\n * Makes the next `initialize` wait until {@link completeInitialization} or\n * {@link failInitialization} is called, or until the client's timeout elapses.\n */\n holdInitialization(): void;\n\n /**\n * Delivers the stored values to a held `initialize`, so it completes with the client ready. When\n * a hold is armed but no `initialize` has started, it disarms the hold instead.\n */\n completeInitialization(): void;\n\n /**\n * Fails a held `initialize` with an unrecoverable connection error, or arms the next `initialize`\n * to fail. `initialize` completes promptly with the client not ready and `connectionError` fires.\n */\n failInitialization(): void;\n}\n\nclass InMemoryTestClient implements TestClient {\n constructor(\n public readonly client: ConfigDirectorClient,\n private readonly connection: InMemoryConnection,\n ) {}\n\n public setValue(key: string, value: TestValue) {\n this.connection.setValue(key, value);\n }\n\n public removeValue(key: string) {\n this.connection.removeValue(key);\n }\n\n public replaceValues(values: TestValues) {\n this.connection.replaceValues(values);\n }\n\n public holdInitialization() {\n this.connection.hold();\n }\n\n public completeInitialization() {\n this.connection.complete();\n }\n\n public failInitialization() {\n this.connection.fail();\n }\n}\n\nexport const createTestClient = (sdkOptions: IdentifyingSdkOptions, options?: TestClientOptions): TestClient => {\n const logger = options?.logger ?? createDefaultLogger();\n const connection = new InMemoryConnection(logger, options?.values ?? {});\n const client = new DefaultConfigDirectorClient(\n TEST_CLIENT_SDK_KEY,\n sdkOptions,\n { logger, connection: { timeout: options?.timeout } },\n { transport: connection, telemetry: discardingTelemetryClient },\n );\n return new InMemoryTestClient(client, connection);\n};\n","import { createTestClient as createServerTestClient } from \"@js-server-sdk/testing/TestClient\";\nimport type { TestClient, TestClientOptions } from \"@js-server-sdk/testing/TestClient\";\n\nexport type { TestClient, TestClientOptions } from \"@js-server-sdk/testing/TestClient\";\nexport type { TestValue, TestValues, TestJsonValue } from \"@js-server-sdk/testing/values\";\nexport { ConfigDirectorConnectionError, ConfigDirectorValidationError } from \"@shared/errors\";\n\n/**\n * Creates a {@link TestClient}: a real server `ConfigDirectorClient` connected to an in-memory\n * server that the test controls. No network connection is opened and no telemetry is sent. Put it\n * where `register()` would put the server singleton with {@link installServerTestClient}.\n *\n * @param options {@link TestClientOptions}: the initial values, the client's timeout, and its logger\n * @returns A {@link TestClient} whose `client` is passed to the code under test\n *\n * @example\n * import { createTestClient, installServerTestClient } from \"@configdirector/nextjs-sdk/server/testing\";\n *\n * const testClient = createTestClient({ values: { \"new-checkout\": true } });\n * const uninstall = installServerTestClient(testClient);\n * await testClient.client.initialize();\n */\nexport const createTestClient = (options?: TestClientOptions): TestClient => {\n return createServerTestClient({ sdkName: \"nextjs-sdk\", sdkVersion: \"__VERSION__\" }, options);\n};\n\n/**\n * Puts `testClient.client` where `register()` puts the server singleton, so `getConfigClient()`,\n * `generateSsrConfigSet()`, and the server `ConfigDirectorProvider` serve its values. It does not\n * initialize the client: call `await testClient.client.initialize()`, as `register()` would.\n *\n * @param testClient The server test client whose `client` to install\n * @returns A function that restores the client installed before\n */\nexport const installServerTestClient = (testClient: TestClient): (() => void) => {\n const previous = globalThis.__configDirectorServerClient;\n globalThis.__configDirectorServerClient = testClient.client;\n return () => {\n globalThis.__configDirectorServerClient = previous;\n };\n};\n"],"mappings":"uKAcA,MAAM,EAAmB,CAAE,cAAe,mBAAoB,UAAW,eAAgB,CAEzF,IAAa,EAAb,KAAqD,CASnD,YACE,EACA,EACA,CAFiB,KAAA,OAAA,EATnB,KAAiB,QAAU,IAAI,EAC/B,KAAiB,QAAU,IAAI,IAC/B,KAAiB,kBAAoC,EAAE,CACvD,KAAQ,MAAe,UAEvB,KAAQ,UAAY,GACpB,KAAQ,WAAa,GAMnB,KAAK,UAAU,EAAO,CAAC,SAAS,EAAY,IAAQ,KAAK,QAAQ,IAAI,EAAK,EAAW,CAAC,CAGxF,SAAgB,EAAa,EAAkB,CAC7C,IAAM,EAAa,KAAK,OAAO,EAAK,EAAM,CAC1C,KAAK,QAAQ,IAAI,EAAK,EAAW,CACjC,KAAK,mBAAmB,CAAE,GAAG,E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OAAe,EAAa,EAAoC,CAC9D,OAAO,EAAoB,eAAe,IAAO,EAAK,EAAM,GCxH1D,EAAN,KAA+C,CAC7C,YACE,EACA,EACA,CAFgB,KAAA,OAAA,EACC,KAAA,WAAA,EAGnB,SAAgB,EAAa,EAAkB,CAC7C,KAAK,WAAW,SAAS,EAAK,EAAM,CAGtC,YAAmB,EAAa,CAC9B,KAAK,WAAW,YAAY,EAAI,CAGlC,cAAqB,EAAoB,CACvC,KAAK,WAAW,cAAc,EAAO,CAGvC,oBAA4B,CAC1B,KAAK,WAAW,MAAM,CAGxB,wBAAgC,CAC9B,KAAK,WAAW,UAAU,CAG5B,oBAA4B,CAC1B,KAAK,WAAW,MAAM,GAI1B,MAAaA,GAAoB,EAAmC,IAA4C,CAC9G,IAAM,EAAS,GAAS,QAAU,GAAqB,CACjD,EAAa,IAAI,EAAmB,EAAQ,GAAS,QAAU,EAAE,CAAC,CAOxE,OAAO,IAAI,EANI,IAAI,EACjB,cACA,EACA,CAAE,SAAQ,WAAY,CAAE,QAAS,GAAS,QAAS,CAAE,CACrD,CAAE,UAAW,EAAY,UAAW,EAA2B,CAChE,CACqC,EAAW,ECvGtC,EAAoB,GACxB,EAAuB,CAAE,QAAS,aAAc,WAAY,SAAe,CAAE,EAAQ,CAWjF,EAA2B,GAAyC,CAC/E,IAAM,EAAW,WAAW,6BAE5B,MADA,YAAW,6BAA+B,EAAW,WACxC,CACX,WAAW,6BAA+B"}
1
+ {"version":3,"file":"testing.mjs","names":["createTestClient"],"sources":["../../../shared/src/telemetry/RecordedTrackedEvents.ts","../../../js-server-sdk/src/testing/InMemoryConnection.ts","../../../js-server-sdk/src/testing/TestClient.ts","../../src/server/testing.ts"],"sourcesContent":["import type { ConfigDirectorContext, ConfigDirectorLogger, TrackedEvent } from \"../types\";\nimport { trackedEventWarningMessages } from \"./tracked-events\";\nimport type { TrackedEventAdmission, TrackedEventEntry } from \"./tracked-events\";\n\nconst recordedEventOf = (entry: TrackedEventEntry, context: ConfigDirectorContext | undefined): TrackedEvent => ({\n name: entry.name,\n ...(context === undefined ? {} : { context }),\n ...(entry.value === undefined ? {} : { value: entry.value }),\n ...(entry.details === undefined ? {} : { details: entry.details }),\n});\n\nexport class RecordedTrackedEvents {\n public readonly events: TrackedEvent[] = [];\n\n constructor(private readonly logger: ConfigDirectorLogger) {}\n\n public record(admission: TrackedEventAdmission, context: ConfigDirectorContext | undefined): void {\n admission.warnings.forEach((warning) => this.logger.warn(trackedEventWarningMessages[warning]));\n switch (admission.outcome) {\n case \"dropped\":\n return;\n case \"admitted\":\n this.events.push(recordedEventOf(admission.entry, context));\n return;\n }\n }\n}\n","import EventEmitter from \"node:events\";\nimport type { ConfigBundle, ConfigDefinition, ConfigDirectorLogger, Transport, TransportEvents } from \"../types\";\nimport { ConfigDirectorConnectionError } from \"@shared/errors\";\nimport type { TestValue, TestValues } from \"./values\";\nimport { unconditionalConfig } from \"../native-values\";\n\ntype Armed = \"nothing\" | \"hold\" | \"failure\";\n\ntype PendingHold = {\n end: () => void;\n complete: () => void;\n fail: () => void;\n};\n\nconst TEST_ENVIRONMENT = { environmentId: \"test-environment\", projectId: \"test-project\" };\n\nexport class InMemoryConnection implements Transport {\n private readonly emitter = new EventEmitter();\n private readonly configs = new Map<string, ConfigDefinition>();\n private readonly pendingDeliveries: ConfigBundle[] = [];\n private armed: Armed = \"nothing\";\n private pendingHold: PendingHold | undefined;\n private connected = false;\n private delivering = false;\n\n constructor(\n private readonly logger: ConfigDirectorLogger,\n values: TestValues,\n ) {\n this.encodeAll(values).forEach((definition, key) => this.configs.set(key, definition));\n }\n\n public setValue(key: string, value: TestValue) {\n const definition = this.encode(key, value);\n this.configs.set(key, definition);\n this.deliverIfConnected({ ...TEST_ENVIRONMENT, kind: \"delta\", configs: { [key]: definition } });\n }\n\n public removeValue(key: string) {\n this.configs.delete(key);\n this.deliverIfConnected(this.fullUpdate());\n }\n\n public replaceValues(values: TestValues) {\n const encoded = this.encodeAll(values);\n this.configs.clear();\n encoded.forEach((definition, key) => this.configs.set(key, definition));\n this.armed = \"nothing\";\n this.deliverIfConnected(this.fullUpdate());\n }\n\n public hold() {\n this.armed = \"hold\";\n }\n\n public complete() {\n if (this.pendingHold) {\n this.pendingHold.complete();\n } else if (this.armed === \"hold\") {\n this.armed = \"nothing\";\n }\n }\n\n public fail() {\n if (this.pendingHold) {\n this.pendingHold.fail();\n } else {\n this.armed = \"failure\";\n }\n }\n\n public connect(timeout: number): Promise<this> {\n this.endAttempt();\n const armed = this.armed;\n this.armed = \"nothing\";\n switch (armed) {\n case \"failure\":\n return this.failNow();\n case \"hold\":\n return this.holdNow(timeout);\n default:\n this.connectNow();\n return Promise.resolve(this);\n }\n }\n\n public get isConnected(): boolean {\n return this.connected;\n }\n\n public on<TName extends keyof TransportEvents>(name: TName, handler: (payload: TransportEvents[TName]) => void) {\n this.emitter.on(name, handler);\n }\n\n public off<TName extends keyof TransportEvents>(name: TName, handler?: (payload: TransportEvents[TName]) => void) {\n if (handler) {\n this.emitter.off(name, handler);\n } else {\n this.emitter.removeAllListeners(name);\n }\n }\n\n public close() {\n this.endAttempt();\n }\n\n public dispose() {\n this.close();\n this.emitter.removeAllListeners();\n }\n\n private endAttempt() {\n this.connected = false;\n this.pendingHold?.end();\n }\n\n private connectNow() {\n this.connected = true;\n this.deliver(this.fullUpdate());\n }\n\n private holdNow(timeout: number): Promise<this> {\n return new Promise<this>((resolve, reject) => {\n const timer = setTimeout(() => this.pendingHold?.end(), timeout);\n const release = () => {\n clearTimeout(timer);\n this.pendingHold = undefined;\n };\n this.pendingHold = {\n end: () => {\n release();\n resolve(this);\n },\n complete: () => {\n release();\n this.connectNow();\n resolve(this);\n },\n fail: () => {\n release();\n const error = this.fatalError();\n this.emitter.emit(\"connectionError\", error);\n reject(error);\n },\n };\n });\n }\n\n private failNow(): Promise<this> {\n const error = this.fatalError();\n this.emitter.emit(\"connectionError\", error);\n return Promise.reject(error);\n }\n\n private fatalError() {\n return new ConfigDirectorConnectionError(\n \"Connection failed with status: 401. Error: the test client failed this initialization. This is an unrecoverable error, will not attempt to reconnect.\",\n 401,\n );\n }\n\n private deliverIfConnected(configBundle: ConfigBundle) {\n if (this.connected) {\n this.deliver(configBundle);\n }\n }\n\n private deliver(configBundle: ConfigBundle) {\n this.pendingDeliveries.push(configBundle);\n if (this.delivering) {\n return;\n }\n this.delivering = true;\n try {\n let next = this.pendingDeliveries.shift();\n while (next) {\n this.emitCaught(next);\n next = this.pendingDeliveries.shift();\n }\n } finally {\n this.delivering = false;\n }\n }\n\n private emitCaught(configBundle: ConfigBundle) {\n try {\n this.emitter.emit(\"configBundleReceived\", configBundle);\n } catch (error) {\n this.logger.error(\"[InMemoryConnection] Error dispatching a config update from the test client: \", error);\n }\n }\n\n private fullUpdate(): ConfigBundle {\n return { ...TEST_ENVIRONMENT, kind: \"full\", configs: Object.fromEntries(this.configs) };\n }\n\n private encodeAll(values: TestValues): Map<string, ConfigDefinition> {\n const encoded = new Map<string, ConfigDefinition>();\n for (const [key, value] of Object.entries(values)) {\n encoded.set(key, this.encode(key, value));\n }\n return encoded;\n }\n\n private encode(key: string, value: TestValue): ConfigDefinition {\n return unconditionalConfig(`test-config:${key}`, key, value);\n }\n}\n","import { DefaultConfigDirectorClient } from \"../DefaultConfigDirectorClient\";\nimport { createDefaultLogger } from \"../logger\";\nimport type { ConfigDirectorClient, ConfigDirectorLogger, IdentifyingSdkOptions } from \"../types\";\nimport type { TrackedEvent } from \"@shared/types\";\nimport { RecordedTrackedEvents } from \"@shared/telemetry/RecordedTrackedEvents\";\nimport { discardingTelemetryClient } from \"../telemetry/discarding\";\nimport { InMemoryConnection } from \"./InMemoryConnection\";\nimport type { TestValue, TestValues } from \"./values\";\n\nconst TEST_CLIENT_SDK_KEY = \"test-client\";\n\n/**\n * Options for {@link createTestClient}. Every option is optional.\n */\nexport type TestClientOptions = {\n /**\n * The config values the test client serves once its client connects, keyed by config key. The\n * config type follows from each value: a boolean, an integral number (`integer`), any other\n * number (`float`), a string, or a plain object or array (`json`). Every context receives the\n * same value.\n */\n values?: TestValues;\n /**\n * The connection timeout of the SDK client, in milliseconds. It bounds how long a held\n * `initialize` waits. Defaults to the SDK's production timeout.\n */\n timeout?: number;\n /**\n * The logger the SDK client uses. Defaults to the SDK's console logger at `warn` level. Since\n * the test client sends no telemetry, every read that supplies a context with an invalid kind\n * logs an error, rather than each invalid kind once per telemetry interval. For the same reason,\n * every tracked event that is not recorded as it was tracked logs a warning.\n */\n logger?: ConfigDirectorLogger;\n};\n\n/**\n * A real ConfigDirector client connected to an in-memory server that the test controls.\n *\n * The client under {@link TestClient.client} is the SDK's production client: value parsing,\n * targeting evaluation, watchers, events, and readiness behave as they do against ConfigDirector.\n * Only the network connection and telemetry are replaced, so no request is ever made and nothing\n * is left running after the client is disposed.\n */\nexport interface TestClient {\n /**\n * The SDK client to hand to the code under test. It starts uninitialized, like a production\n * client; `initialize` completes at once with the seeded values unless initialization is held.\n */\n readonly client: ConfigDirectorClient;\n\n /**\n * Stores `value` under `key` and, when the client is connected, delivers it as an update, so\n * reads, watchers, and `configsUpdated` handlers see it.\n */\n setValue(key: string, value: TestValue): void;\n\n /**\n * Removes `key` and, when the client is connected, delivers a full update without it, so reads\n * fall back to the in-code default value and watchers of `key` receive that default.\n */\n removeValue(key: string): void;\n\n /**\n * Replaces every stored value with `values`, disarms any armed hold or failure, and, when the\n * client is connected, delivers the new values as a full update.\n */\n replaceValues(values: TestValues): void;\n\n /**\n * Makes the next `initialize` wait until {@link completeInitialization} or\n * {@link failInitialization} is called, or until the client's timeout elapses.\n */\n holdInitialization(): void;\n\n /**\n * Delivers the stored values to a held `initialize`, so it completes with the client ready. When\n * a hold is armed but no `initialize` has started, it disarms the hold instead.\n */\n completeInitialization(): void;\n\n /**\n * Fails a held `initialize` with an unrecoverable connection error, or arms the next `initialize`\n * to fail. `initialize` completes promptly with the client not ready and `connectionError` fires.\n */\n failInitialization(): void;\n\n /**\n * Every event the code under test tracked through the client, in call order, as the SDK would\n * report it: an event whose name does not have 1 to 150 characters is not recorded, and a value\n * or details the SDK would leave out are missing from the record. A context whose kind is\n * invalid is not recorded with its event. The limit of 1,000 events per telemetry batch does not\n * apply.\n */\n readonly trackedEvents: TrackedEvent[];\n}\n\nclass InMemoryTestClient implements TestClient {\n constructor(\n public readonly client: ConfigDirectorClient,\n private readonly connection: InMemoryConnection,\n public readonly trackedEvents: TrackedEvent[],\n ) {}\n\n public setValue(key: string, value: TestValue) {\n this.connection.setValue(key, value);\n }\n\n public removeValue(key: string) {\n this.connection.removeValue(key);\n }\n\n public replaceValues(values: TestValues) {\n this.connection.replaceValues(values);\n }\n\n public holdInitialization() {\n this.connection.hold();\n }\n\n public completeInitialization() {\n this.connection.complete();\n }\n\n public failInitialization() {\n this.connection.fail();\n }\n}\n\nexport const createTestClient = (sdkOptions: IdentifyingSdkOptions, options?: TestClientOptions): TestClient => {\n const logger = options?.logger ?? createDefaultLogger();\n const connection = new InMemoryConnection(logger, options?.values ?? {});\n const recordedTrackedEvents = new RecordedTrackedEvents(logger);\n const client = new DefaultConfigDirectorClient(\n TEST_CLIENT_SDK_KEY,\n sdkOptions,\n { logger, connection: { timeout: options?.timeout } },\n {\n transport: connection,\n telemetry: {\n ...discardingTelemetryClient,\n trackedEvent: (admission, context) => recordedTrackedEvents.record(admission, context),\n },\n },\n );\n return new InMemoryTestClient(client, connection, recordedTrackedEvents.events);\n};\n","import { createTestClient as createServerTestClient } from \"@js-server-sdk/testing/TestClient\";\nimport type { TestClient, TestClientOptions } from \"@js-server-sdk/testing/TestClient\";\n\nexport type { TestClient, TestClientOptions } from \"@js-server-sdk/testing/TestClient\";\nexport type { TestValue, TestValues, TestJsonValue } from \"@js-server-sdk/testing/values\";\nexport type { TrackedEvent, TrackedEventDetails, TrackedEventDetailValue } from \"@shared/types\";\nexport { ConfigDirectorConnectionError, ConfigDirectorValidationError } from \"@shared/errors\";\n\n/**\n * Creates a {@link TestClient}: a real server `ConfigDirectorClient` connected to an in-memory\n * server that the test controls. No network connection is opened and no telemetry is sent. Put it\n * where `register()` would put the server singleton with {@link installServerTestClient}.\n *\n * @param options {@link TestClientOptions}: the initial values, the client's timeout, and its logger\n * @returns A {@link TestClient} whose `client` is passed to the code under test\n *\n * @example\n * import { createTestClient, installServerTestClient } from \"@configdirector/nextjs-sdk/server/testing\";\n *\n * const testClient = createTestClient({ values: { \"new-checkout\": true } });\n * const uninstall = installServerTestClient(testClient);\n * await testClient.client.initialize();\n */\nexport const createTestClient = (options?: TestClientOptions): TestClient => {\n return createServerTestClient({ sdkName: \"nextjs-sdk\", sdkVersion: \"__VERSION__\" }, options);\n};\n\n/**\n * Puts `testClient.client` where `register()` puts the server singleton, so `getConfigClient()`,\n * `generateSsrConfigSet()`, and the server `ConfigDirectorProvider` serve its values. It does not\n * initialize the client: call `await testClient.client.initialize()`, as `register()` would.\n *\n * @param testClient The server test client whose `client` to install\n * @returns A function that restores the client installed before\n */\nexport const installServerTestClient = (testClient: TestClient): (() => void) => {\n const previous = globalThis.__configDirectorServerClient;\n globalThis.__configDirectorServerClient = testClient.client;\n return () => {\n globalThis.__configDirectorServerClient = previous;\n };\n};\n"],"mappings":"oKAIA,MAAM,GAAmB,EAA0B,KAA8D,CAC/G,KAAM,EAAM,KACZ,GAAI,IAAY,IAAA,GAAY,EAAE,CAAG,CAAE,UAAS,CAC5C,GAAI,EAAM,QAAU,IAAA,GAAY,EAAE,CAAG,CAAE,MAAO,EAAM,MAAO,CAC3D,GAAI,EAAM,UAAY,IAAA,GAAY,EAAE,CAAG,CAAE,QAAS,EAAM,QAAS,CAClE,EAED,IAAa,EAAb,KAAmC,CAGjC,YAAY,EAA+C,CAA9B,KAAA,OAAA,EAF7B,KAAgB,OAAyB,EAAE,CAI3C,OAAc,EAAkC,EAAkD,CAEhG,OADA,EAAU,SAAS,QAAS,GAAY,KAAK,OAAO,KAAK,EAA4B,GAAS,CAAC,CACvF,EAAU,QAAlB,CACE,IAAK,UACH,OACF,IAAK,WACH,KAAK,OAAO,KA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