@configdirector/openfeature-server-provider 1.12.0 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/configdirector-openfeature-server-provider.cjs +1 -1
- package/dist/configdirector-openfeature-server-provider.d.cts +67 -6
- package/dist/configdirector-openfeature-server-provider.d.cts.map +1 -1
- package/dist/configdirector-openfeature-server-provider.d.mts +67 -6
- package/dist/configdirector-openfeature-server-provider.d.mts.map +1 -1
- package/dist/configdirector-openfeature-server-provider.mjs +1 -1
- package/dist/configdirector-openfeature-server-provider.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EvaluationContext, JsonValue, OpenFeatureEventEmitter, Paradigm, Provider, ProviderMetadata, ResolutionDetails } from "@openfeature/server-sdk";
|
|
1
|
+
import { EvaluationContext, JsonValue, OpenFeatureEventEmitter, Paradigm, Provider, ProviderMetadata, ResolutionDetails, TrackingEventDetails } from "@openfeature/server-sdk";
|
|
2
2
|
|
|
3
3
|
//#region ../shared/src/types.d.ts
|
|
4
4
|
declare const ConfigTypeList: readonly ["custom", "boolean", "string", "integer", "float", "enum", "url", "json"];
|
|
@@ -13,6 +13,12 @@ type ConfigState = {
|
|
|
13
13
|
type: ConfigType;
|
|
14
14
|
value: string | undefined | null;
|
|
15
15
|
valueId?: string | undefined | null;
|
|
16
|
+
variation?: {
|
|
17
|
+
id: string;
|
|
18
|
+
name?: string | undefined | null;
|
|
19
|
+
} | undefined | null;
|
|
20
|
+
ruleId?: string | undefined | null;
|
|
21
|
+
shareId?: string | undefined | null;
|
|
16
22
|
};
|
|
17
23
|
type ConfigDirectorLoggingLevel = "debug" | "info" | "warn" | "error" | "off";
|
|
18
24
|
interface ConfigDirectorLogger {
|
|
@@ -26,24 +32,63 @@ interface ConfigDirectorLogMessageDecorator {
|
|
|
26
32
|
}
|
|
27
33
|
/**
|
|
28
34
|
* Why an evaluation returned the value it did. `found-match` returns a value from ConfigDirector,
|
|
29
|
-
* and `cached` a value kept on the device while a client SDK waits for live values.
|
|
35
|
+
* and `cached` a value kept on the device while a client SDK waits for live values.
|
|
36
|
+
* `rollout-skipped-no-identifier` returns the default targeting rule value: a server SDK skipped a
|
|
37
|
+
* percentage rollout because the context has no `id` to place it in a share. `value-missing`
|
|
30
38
|
* returns the in-code default value because the config has no value. Every other reason returns the
|
|
31
39
|
* in-code default value because of an error: the config does not exist (`config-state-missing`), no
|
|
32
40
|
* values have arrived yet (`client-not-ready`), or the value cannot be read as the type of the in-code
|
|
33
41
|
* default value.
|
|
34
42
|
*/
|
|
35
|
-
type EvaluationReason = "found-match" | "config-state-missing" | "client-not-ready" | "type-mismatch" | "value-missing" | "invalid-number" | "invalid-json" | "invalid-boolean" | "cached";
|
|
43
|
+
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";
|
|
44
|
+
/**
|
|
45
|
+
* One of the values a config can serve, such as the control or a treatment of an experiment.
|
|
46
|
+
*/
|
|
47
|
+
type Variation = {
|
|
48
|
+
/** 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. */
|
|
49
|
+
name?: string;
|
|
50
|
+
};
|
|
36
51
|
/**
|
|
37
52
|
* One evaluation of a config: the value it returned, why, and the context it was evaluated for.
|
|
38
53
|
*/
|
|
39
54
|
type ConfigEvaluation<T extends ConfigValueType = ConfigValueType> = {
|
|
40
55
|
/** The config key that was evaluated. */key: string; /** The value returned, which is the in-code default value when {@link isDefaultValue} is `true`. */
|
|
41
56
|
value: T; /** The ID ConfigDirector assigned to the value returned, when ConfigDirector sent one with it. */
|
|
42
|
-
valueId?: string;
|
|
57
|
+
valueId?: string;
|
|
58
|
+
/**
|
|
59
|
+
* The variation that was served. It is `undefined` when the config has no variations or the
|
|
60
|
+
* in-code default value is returned.
|
|
61
|
+
*/
|
|
62
|
+
variation?: Variation; /** Whether the evaluation returned the in-code default value. */
|
|
43
63
|
isDefaultValue: boolean; /** Why the evaluation returned this value. */
|
|
44
64
|
reason: EvaluationReason; /** The context the config was evaluated for, if any. */
|
|
45
65
|
context?: ConfigDirectorContext;
|
|
46
66
|
};
|
|
67
|
+
/**
|
|
68
|
+
* A value in the details of a tracked event: a string, a number, a boolean, or an array or object
|
|
69
|
+
* of such values.
|
|
70
|
+
*/
|
|
71
|
+
type TrackedEventDetailValue = string | number | boolean | TrackedEventDetailValue[] | {
|
|
72
|
+
[key: string]: TrackedEventDetailValue;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Details of a tracked event, such as the plan a customer chose. Details with more than 20
|
|
76
|
+
* top-level keys, or larger than 1 KB as JSON, are left out and the event is still reported.
|
|
77
|
+
*/
|
|
78
|
+
type TrackedEventDetails = {
|
|
79
|
+
[key: string]: TrackedEventDetailValue;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* What a tracked event carries besides its name.
|
|
83
|
+
*/
|
|
84
|
+
type TrackOptions = {
|
|
85
|
+
/**
|
|
86
|
+
* A number the event measures, such as an amount of money, a count or a duration. A value that
|
|
87
|
+
* is not a finite number is left out and the event is still reported.
|
|
88
|
+
*/
|
|
89
|
+
value?: number; /** Details of the event. */
|
|
90
|
+
details?: TrackedEventDetails;
|
|
91
|
+
};
|
|
47
92
|
/**
|
|
48
93
|
* The context to be sent to ConfigDirector: the user or other entity, such as a device or an
|
|
49
94
|
* organization, that configs are evaluated for. This context will be used for targeting rules
|
|
@@ -325,8 +370,8 @@ interface ConfigDirectorClient {
|
|
|
325
370
|
getValue<T extends ConfigValueType>(configKey: string, defaultValue: T, context?: ConfigDirectorContext): T;
|
|
326
371
|
/**
|
|
327
372
|
* Evaluates a config as {@link getValue} does and returns the evaluation: the value, the reason it
|
|
328
|
-
* was served
|
|
329
|
-
* telemetry.
|
|
373
|
+
* was served, its value ID and its variation. Like every read, it fires `configEvaluated` and is
|
|
374
|
+
* counted in telemetry.
|
|
330
375
|
*
|
|
331
376
|
* @returns The evaluation, whose `value` is what {@link getValue} returns
|
|
332
377
|
* @param configKey The config key to evaluate
|
|
@@ -371,6 +416,21 @@ interface ConfigDirectorClient {
|
|
|
371
416
|
context?: ConfigDirectorContext;
|
|
372
417
|
configKeys?: string[];
|
|
373
418
|
}): Record<string, ConfigState>;
|
|
419
|
+
/**
|
|
420
|
+
* Reports to ConfigDirector that something happened, such as a completed checkout, so it can be
|
|
421
|
+
* counted. The event is sent with the next telemetry batch. `track` never throws, and does nothing
|
|
422
|
+
* in `offline` mode.
|
|
423
|
+
*
|
|
424
|
+
* An event counts for an experiment only when it is tracked for a context with an `id`, the one
|
|
425
|
+
* the experiment's config was evaluated for. Without a context, or for a context without an
|
|
426
|
+
* `id`, the event is still reported.
|
|
427
|
+
*
|
|
428
|
+
* @param eventName The name of the event, 1 to 150 characters. An event with any other name is
|
|
429
|
+
* not reported and a warning is logged.
|
|
430
|
+
* @param context The context the event happened for (optional)
|
|
431
|
+
* @param options The event's {@link TrackOptions.value} and {@link TrackOptions.details} (optional)
|
|
432
|
+
*/
|
|
433
|
+
track(eventName: string, context?: ConfigDirectorContext, options?: TrackOptions): void;
|
|
374
434
|
on<T extends keyof ClientEvents>(eventName: T, handler: (args: ClientEvents[T]) => void): void;
|
|
375
435
|
off<T extends keyof ClientEvents>(eventName: T, handler?: (args: ClientEvents[T]) => void): void;
|
|
376
436
|
/**
|
|
@@ -408,6 +468,7 @@ declare class ConfigDirectorProvider implements Provider {
|
|
|
408
468
|
resolveStringEvaluation(flagKey: string, defaultValue: string, context: EvaluationContext): Promise<ResolutionDetails<string>>;
|
|
409
469
|
resolveNumberEvaluation(flagKey: string, defaultValue: number, context: EvaluationContext): Promise<ResolutionDetails<number>>;
|
|
410
470
|
resolveObjectEvaluation<T extends JsonValue>(flagKey: string, defaultValue: T, context: EvaluationContext): Promise<ResolutionDetails<T>>;
|
|
471
|
+
track(trackingEventName: string, context: EvaluationContext, trackingEventDetails: TrackingEventDetails): void;
|
|
411
472
|
onClose?(): Promise<void>;
|
|
412
473
|
private mapContext;
|
|
413
474
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configdirector-openfeature-server-provider.d.cts","names":[],"sources":["../../shared/src/types.ts","../../shared/src/native-values.ts","../../js-server-sdk/src/types.ts","../../shared/src/errors.ts","../src/ConfigDirectorProvider.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;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
|
|
1
|
+
{"version":3,"file":"configdirector-openfeature-server-provider.d.cts","names":[],"sources":["../../shared/src/types.ts","../../shared/src/native-values.ts","../../js-server-sdk/src/types.ts","../../shared/src/errors.ts","../src/ConfigDirectorProvider.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,CA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AA;EAAA,SACR,MAAA,EAAM,uBAAA;EJdL;;;cImBS,YAAA,UAAsB,aAAA,GAAgB,2BAAA;EJnBZ;AAE/C;;;cIsBqB,aAAA,EAAe,oBAAA;EAW5B,UAAA,CAAA,GAAU,OAAA;EAYhB,wBAAA,CACE,OAAA,UACA,YAAA,WACA,OAAA,EAAS,iBAAA,GACR,OAAA,CAAQ,iBAAA;EAMX,uBAAA,CACE,OAAA,UACA,YAAA,UACA,OAAA,EAAS,iBAAA,GACR,OAAA,CAAQ,iBAAA;EAMX,uBAAA,CACE,OAAA,UACA,YAAA,UACA,OAAA,EAAS,iBAAA,GACR,OAAA,CAAQ,iBAAA;EAMX,uBAAA,WAAkC,SAAA,CAAA,CAChC,OAAA,UACA,YAAA,EAAc,CAAA,EACd,OAAA,EAAS,iBAAA,GACR,OAAA,CAAQ,iBAAA,CAAkB,CAAA;EAQ7B,KAAA,CAAM,iBAAA,UAA2B,OAAA,EAAS,iBAAA,EAAmB,oBAAA,EAAsB,oBAAA;EASnF,OAAA,CAAA,CAAA,GAAY,OAAA;EAAA,QAKJ,UAAA;AAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EvaluationContext, JsonValue, OpenFeatureEventEmitter, Paradigm, Provider, ProviderMetadata, ResolutionDetails } from "@openfeature/server-sdk";
|
|
1
|
+
import { EvaluationContext, JsonValue, OpenFeatureEventEmitter, Paradigm, Provider, ProviderMetadata, ResolutionDetails, TrackingEventDetails } from "@openfeature/server-sdk";
|
|
2
2
|
|
|
3
3
|
//#region ../shared/src/types.d.ts
|
|
4
4
|
declare const ConfigTypeList: readonly ["custom", "boolean", "string", "integer", "float", "enum", "url", "json"];
|
|
@@ -13,6 +13,12 @@ type ConfigState = {
|
|
|
13
13
|
type: ConfigType;
|
|
14
14
|
value: string | undefined | null;
|
|
15
15
|
valueId?: string | undefined | null;
|
|
16
|
+
variation?: {
|
|
17
|
+
id: string;
|
|
18
|
+
name?: string | undefined | null;
|
|
19
|
+
} | undefined | null;
|
|
20
|
+
ruleId?: string | undefined | null;
|
|
21
|
+
shareId?: string | undefined | null;
|
|
16
22
|
};
|
|
17
23
|
type ConfigDirectorLoggingLevel = "debug" | "info" | "warn" | "error" | "off";
|
|
18
24
|
interface ConfigDirectorLogger {
|
|
@@ -26,24 +32,63 @@ interface ConfigDirectorLogMessageDecorator {
|
|
|
26
32
|
}
|
|
27
33
|
/**
|
|
28
34
|
* Why an evaluation returned the value it did. `found-match` returns a value from ConfigDirector,
|
|
29
|
-
* and `cached` a value kept on the device while a client SDK waits for live values.
|
|
35
|
+
* and `cached` a value kept on the device while a client SDK waits for live values.
|
|
36
|
+
* `rollout-skipped-no-identifier` returns the default targeting rule value: a server SDK skipped a
|
|
37
|
+
* percentage rollout because the context has no `id` to place it in a share. `value-missing`
|
|
30
38
|
* returns the in-code default value because the config has no value. Every other reason returns the
|
|
31
39
|
* in-code default value because of an error: the config does not exist (`config-state-missing`), no
|
|
32
40
|
* values have arrived yet (`client-not-ready`), or the value cannot be read as the type of the in-code
|
|
33
41
|
* default value.
|
|
34
42
|
*/
|
|
35
|
-
type EvaluationReason = "found-match" | "config-state-missing" | "client-not-ready" | "type-mismatch" | "value-missing" | "invalid-number" | "invalid-json" | "invalid-boolean" | "cached";
|
|
43
|
+
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";
|
|
44
|
+
/**
|
|
45
|
+
* One of the values a config can serve, such as the control or a treatment of an experiment.
|
|
46
|
+
*/
|
|
47
|
+
type Variation = {
|
|
48
|
+
/** 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. */
|
|
49
|
+
name?: string;
|
|
50
|
+
};
|
|
36
51
|
/**
|
|
37
52
|
* One evaluation of a config: the value it returned, why, and the context it was evaluated for.
|
|
38
53
|
*/
|
|
39
54
|
type ConfigEvaluation<T extends ConfigValueType = ConfigValueType> = {
|
|
40
55
|
/** The config key that was evaluated. */key: string; /** The value returned, which is the in-code default value when {@link isDefaultValue} is `true`. */
|
|
41
56
|
value: T; /** The ID ConfigDirector assigned to the value returned, when ConfigDirector sent one with it. */
|
|
42
|
-
valueId?: string;
|
|
57
|
+
valueId?: string;
|
|
58
|
+
/**
|
|
59
|
+
* The variation that was served. It is `undefined` when the config has no variations or the
|
|
60
|
+
* in-code default value is returned.
|
|
61
|
+
*/
|
|
62
|
+
variation?: Variation; /** Whether the evaluation returned the in-code default value. */
|
|
43
63
|
isDefaultValue: boolean; /** Why the evaluation returned this value. */
|
|
44
64
|
reason: EvaluationReason; /** The context the config was evaluated for, if any. */
|
|
45
65
|
context?: ConfigDirectorContext;
|
|
46
66
|
};
|
|
67
|
+
/**
|
|
68
|
+
* A value in the details of a tracked event: a string, a number, a boolean, or an array or object
|
|
69
|
+
* of such values.
|
|
70
|
+
*/
|
|
71
|
+
type TrackedEventDetailValue = string | number | boolean | TrackedEventDetailValue[] | {
|
|
72
|
+
[key: string]: TrackedEventDetailValue;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Details of a tracked event, such as the plan a customer chose. Details with more than 20
|
|
76
|
+
* top-level keys, or larger than 1 KB as JSON, are left out and the event is still reported.
|
|
77
|
+
*/
|
|
78
|
+
type TrackedEventDetails = {
|
|
79
|
+
[key: string]: TrackedEventDetailValue;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* What a tracked event carries besides its name.
|
|
83
|
+
*/
|
|
84
|
+
type TrackOptions = {
|
|
85
|
+
/**
|
|
86
|
+
* A number the event measures, such as an amount of money, a count or a duration. A value that
|
|
87
|
+
* is not a finite number is left out and the event is still reported.
|
|
88
|
+
*/
|
|
89
|
+
value?: number; /** Details of the event. */
|
|
90
|
+
details?: TrackedEventDetails;
|
|
91
|
+
};
|
|
47
92
|
/**
|
|
48
93
|
* The context to be sent to ConfigDirector: the user or other entity, such as a device or an
|
|
49
94
|
* organization, that configs are evaluated for. This context will be used for targeting rules
|
|
@@ -325,8 +370,8 @@ interface ConfigDirectorClient {
|
|
|
325
370
|
getValue<T extends ConfigValueType>(configKey: string, defaultValue: T, context?: ConfigDirectorContext): T;
|
|
326
371
|
/**
|
|
327
372
|
* Evaluates a config as {@link getValue} does and returns the evaluation: the value, the reason it
|
|
328
|
-
* was served
|
|
329
|
-
* telemetry.
|
|
373
|
+
* was served, its value ID and its variation. Like every read, it fires `configEvaluated` and is
|
|
374
|
+
* counted in telemetry.
|
|
330
375
|
*
|
|
331
376
|
* @returns The evaluation, whose `value` is what {@link getValue} returns
|
|
332
377
|
* @param configKey The config key to evaluate
|
|
@@ -371,6 +416,21 @@ interface ConfigDirectorClient {
|
|
|
371
416
|
context?: ConfigDirectorContext;
|
|
372
417
|
configKeys?: string[];
|
|
373
418
|
}): Record<string, ConfigState>;
|
|
419
|
+
/**
|
|
420
|
+
* Reports to ConfigDirector that something happened, such as a completed checkout, so it can be
|
|
421
|
+
* counted. The event is sent with the next telemetry batch. `track` never throws, and does nothing
|
|
422
|
+
* in `offline` mode.
|
|
423
|
+
*
|
|
424
|
+
* An event counts for an experiment only when it is tracked for a context with an `id`, the one
|
|
425
|
+
* the experiment's config was evaluated for. Without a context, or for a context without an
|
|
426
|
+
* `id`, the event is still reported.
|
|
427
|
+
*
|
|
428
|
+
* @param eventName The name of the event, 1 to 150 characters. An event with any other name is
|
|
429
|
+
* not reported and a warning is logged.
|
|
430
|
+
* @param context The context the event happened for (optional)
|
|
431
|
+
* @param options The event's {@link TrackOptions.value} and {@link TrackOptions.details} (optional)
|
|
432
|
+
*/
|
|
433
|
+
track(eventName: string, context?: ConfigDirectorContext, options?: TrackOptions): void;
|
|
374
434
|
on<T extends keyof ClientEvents>(eventName: T, handler: (args: ClientEvents[T]) => void): void;
|
|
375
435
|
off<T extends keyof ClientEvents>(eventName: T, handler?: (args: ClientEvents[T]) => void): void;
|
|
376
436
|
/**
|
|
@@ -408,6 +468,7 @@ declare class ConfigDirectorProvider implements Provider {
|
|
|
408
468
|
resolveStringEvaluation(flagKey: string, defaultValue: string, context: EvaluationContext): Promise<ResolutionDetails<string>>;
|
|
409
469
|
resolveNumberEvaluation(flagKey: string, defaultValue: number, context: EvaluationContext): Promise<ResolutionDetails<number>>;
|
|
410
470
|
resolveObjectEvaluation<T extends JsonValue>(flagKey: string, defaultValue: T, context: EvaluationContext): Promise<ResolutionDetails<T>>;
|
|
471
|
+
track(trackingEventName: string, context: EvaluationContext, trackingEventDetails: TrackingEventDetails): void;
|
|
411
472
|
onClose?(): Promise<void>;
|
|
412
473
|
private mapContext;
|
|
413
474
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configdirector-openfeature-server-provider.d.mts","names":[],"sources":["../../shared/src/types.ts","../../shared/src/native-values.ts","../../js-server-sdk/src/types.ts","../../shared/src/errors.ts","../src/ConfigDirectorProvider.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;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
|
|
1
|
+
{"version":3,"file":"configdirector-openfeature-server-provider.d.mts","names":[],"sources":["../../shared/src/types.ts","../../shared/src/native-values.ts","../../js-server-sdk/src/types.ts","../../shared/src/errors.ts","../src/ConfigDirectorProvider.ts"],"mappings":";;;cAAa,cAAA;AAAA,KAUD,UAAA,WAAqB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