@configdirector/nuxt-sdk 0.1.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/README.md +136 -0
- package/dist/module.d.mts +85 -0
- package/dist/module.json +8 -0
- package/dist/module.mjs +66 -0
- package/dist/runtime/app/composables/useConfigDirectorClient.d.mts +8 -0
- package/dist/runtime/app/composables/useConfigDirectorClient.d.ts +8 -0
- package/dist/runtime/app/composables/useConfigDirectorClient.mjs +8 -0
- package/dist/runtime/app/composables/useConfigDirectorContext.d.mts +12 -0
- package/dist/runtime/app/composables/useConfigDirectorContext.d.ts +12 -0
- package/dist/runtime/app/composables/useConfigDirectorContext.mjs +30 -0
- package/dist/runtime/app/composables/useConfigDirectorStatus.d.mts +10 -0
- package/dist/runtime/app/composables/useConfigDirectorStatus.d.ts +10 -0
- package/dist/runtime/app/composables/useConfigDirectorStatus.mjs +13 -0
- package/dist/runtime/app/composables/useConfigDirectorValue.d.mts +12 -0
- package/dist/runtime/app/composables/useConfigDirectorValue.d.ts +12 -0
- package/dist/runtime/app/composables/useConfigDirectorValue.mjs +19 -0
- package/dist/runtime/nitro/middleware.d.mts +130 -0
- package/dist/runtime/nitro/middleware.d.ts +130 -0
- package/dist/runtime/nitro/middleware.mjs +8 -0
- package/dist/runtime/nitro/plugin.d.mts +12 -0
- package/dist/runtime/nitro/plugin.d.ts +12 -0
- package/dist/runtime/nitro/plugin.mjs +1397 -0
- package/dist/runtime/plugin.client.d.mts +4 -0
- package/dist/runtime/plugin.client.mjs +1162 -0
- package/dist/runtime/plugin.server.d.mts +4 -0
- package/dist/runtime/plugin.server.mjs +106 -0
- package/dist/runtime/server/composables/useConfigDirectorClient.d.mts +6 -0
- package/dist/runtime/server/composables/useConfigDirectorClient.d.ts +6 -0
- package/dist/runtime/server/composables/useConfigDirectorClient.mjs +9 -0
- package/dist/runtime/types-CQWNx-gI.d.mts +34 -0
- package/dist/runtime/types-CkzBXJwA.d.mts +4 -0
- package/dist/runtime/types-D9MFb76Q.d.mts +85 -0
- package/dist/runtime/types-KSnINlzh.d.mts +135 -0
- package/package.json +76 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import * as _$h3 from "h3";
|
|
2
|
+
|
|
3
|
+
//#region ../js-server-sdk/dist/configdirector-server.d.cts
|
|
4
|
+
//#region ../shared/src/types.d.ts
|
|
5
|
+
type ConfigEnumLikeType = {
|
|
6
|
+
[key: string]: string | number;
|
|
7
|
+
};
|
|
8
|
+
type ConfigValueType = string | number | boolean | object | ConfigEnumLikeType;
|
|
9
|
+
/**
|
|
10
|
+
* The user's context to be sent to ConfigDirector. This context will be used for targeting
|
|
11
|
+
* rules evaluation.
|
|
12
|
+
*/
|
|
13
|
+
type ConfigDirectorContext = {
|
|
14
|
+
/**
|
|
15
|
+
* The user's identifier. This should be a value that uniquely identifies an application
|
|
16
|
+
* user.
|
|
17
|
+
* In the case of anonymous users, you could generate a UUID or alternatively not provide
|
|
18
|
+
* the {@link id} and the SDK will generate a random UUID. However, keep in mind that this
|
|
19
|
+
* value is used for segmenting users in percentage rollouts, and changes to the {@link id}
|
|
20
|
+
* could result in the user being assigned to a different percentile.
|
|
21
|
+
*/
|
|
22
|
+
id?: string;
|
|
23
|
+
/**
|
|
24
|
+
* The user's display name. This will be shown in the ConfigDirector dashboard and may be
|
|
25
|
+
* used for targeting rules.
|
|
26
|
+
*/
|
|
27
|
+
name?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Any arbitrary traits for the current user. They will be shown in the ConfigDirector
|
|
30
|
+
* dashboard and may be used for targeting rules.
|
|
31
|
+
*/
|
|
32
|
+
traits?: {
|
|
33
|
+
[key: string]: unknown;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Metadata about your application. It is recommended you include these values when configuring
|
|
38
|
+
* a ConfigDirector client so that you can use them in targeting rules.
|
|
39
|
+
*/
|
|
40
|
+
type ClientEvents = {
|
|
41
|
+
configsUpdated: {
|
|
42
|
+
keys: string[];
|
|
43
|
+
};
|
|
44
|
+
clientReady: undefined;
|
|
45
|
+
};
|
|
46
|
+
type WatchHandler<T extends ConfigValueType> = (message: T) => void;
|
|
47
|
+
/**
|
|
48
|
+
* The ConfigDirector SDK client object.
|
|
49
|
+
*
|
|
50
|
+
* Applications should create a single instance of `ConfigDirectorClient`, and call
|
|
51
|
+
* {@link initialize} during application initialization.
|
|
52
|
+
*/
|
|
53
|
+
interface ConfigDirectorClient {
|
|
54
|
+
/**
|
|
55
|
+
* Initializes the connection to ConfigDirector to retrieve config definitions. Until
|
|
56
|
+
* initialization is successful, all flags will return their default value provided to
|
|
57
|
+
* {@link watch} or {@link getValue}.
|
|
58
|
+
*
|
|
59
|
+
* If the connection fails or is interrupted with a transient error (network error,
|
|
60
|
+
* internal server error, etc) the client will continue to attempt to connect. However,
|
|
61
|
+
* if the connection fails with a persistent error, like an invalid SDK key, the client will
|
|
62
|
+
* not attempt to re-connect and an error will be logged to the console or the provided
|
|
63
|
+
* logger.
|
|
64
|
+
*/
|
|
65
|
+
initialize(): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Returns whether or not the client is ready after calling {@link initialize}
|
|
68
|
+
*
|
|
69
|
+
* The definition of ready is that the connection to the server was successful, and config definitions
|
|
70
|
+
* were received.
|
|
71
|
+
*/
|
|
72
|
+
get isReady(): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Evaluates a config and returns its value based on the current context and targeting rules
|
|
75
|
+
*
|
|
76
|
+
* @returns The evaluated config value, or the `defaultValue` if the config state was unavailable
|
|
77
|
+
* @param configKey The config key to evaluate
|
|
78
|
+
* @param defaultValue The default value to be returned if the config state is unavailable. For
|
|
79
|
+
* example, if the client cannot connect to the server due to network conditions, or if getValue
|
|
80
|
+
* is called before initialization is done.
|
|
81
|
+
* @param context The user's context to be used for targeting rules evaluation (optional)
|
|
82
|
+
*/
|
|
83
|
+
getValue<T extends ConfigValueType>(configKey: string, defaultValue: T, context?: ConfigDirectorContext): T;
|
|
84
|
+
/**
|
|
85
|
+
* Watches for changes to a a config evaluation value. Whenever the config value changes, the
|
|
86
|
+
* provided callback function will be called with the new value. Changes can happen due to updates
|
|
87
|
+
* to the config in the ConfigDirector dashboard, or if the context is updated via {@link updateContext}.
|
|
88
|
+
*
|
|
89
|
+
* @returns An 'unwatch' function that can be called to remove the subscriber
|
|
90
|
+
*
|
|
91
|
+
* @param configKey The config key to watch
|
|
92
|
+
* @param defaultValue The default value to be referenced if the config state is unavailable
|
|
93
|
+
* @param callback The callback function to be called whenever the config value is updated
|
|
94
|
+
* @param context The user's context to be used for targeting rules evaluation (optional)
|
|
95
|
+
*/
|
|
96
|
+
watch<T extends ConfigValueType>(configKey: string, defaultValue: T, callback: WatchHandler<T>, context?: ConfigDirectorContext): () => void;
|
|
97
|
+
/**
|
|
98
|
+
* Removes a particular subscriber to the given `configKey`, or all subscribers if no callback
|
|
99
|
+
* is provided.
|
|
100
|
+
*
|
|
101
|
+
* @param configKey The config key to remove subscribers from
|
|
102
|
+
* @param callback The subscriber to be removed. If not provided, all subscribers are removed for
|
|
103
|
+
* the given `configKey`.
|
|
104
|
+
*/
|
|
105
|
+
unwatch<T extends ConfigValueType>(configKey: string, callback?: WatchHandler<T>): void;
|
|
106
|
+
/**
|
|
107
|
+
* Removes all subscribers from all config keys
|
|
108
|
+
*/
|
|
109
|
+
unwatchAll(): void;
|
|
110
|
+
on<T extends keyof ClientEvents>(eventName: T, handler: (args: ClientEvents[T]) => void): void;
|
|
111
|
+
off<T extends keyof ClientEvents>(eventName: T, handler?: (args: ClientEvents[T]) => void): void;
|
|
112
|
+
/**
|
|
113
|
+
* Disposes of the client. All connections are closed, and all event and config key subscribers
|
|
114
|
+
* are removed.
|
|
115
|
+
*
|
|
116
|
+
* Intended to be called when your application shuts down
|
|
117
|
+
*/
|
|
118
|
+
dispose(): void;
|
|
119
|
+
} //#endregion
|
|
120
|
+
//#region ../shared/src/logger.d.ts
|
|
121
|
+
//#endregion
|
|
122
|
+
//#region src/runtime/nitro/middleware.d.ts
|
|
123
|
+
declare const _default: _$h3.EventHandler<_$h3.EventHandlerRequest, void>;
|
|
124
|
+
declare module "h3" {
|
|
125
|
+
interface H3EventContext {
|
|
126
|
+
configDirectorClient: ConfigDirectorClient;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
//#endregion
|
|
130
|
+
export { _default as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { useNitroApp } from "nitropack/runtime";
|
|
2
|
+
import { defineEventHandler } from "h3";
|
|
3
|
+
//#region src/runtime/nitro/middleware.ts
|
|
4
|
+
var middleware_default = defineEventHandler((event) => {
|
|
5
|
+
event.context.configDirectorClient = useNitroApp().configDirectorClient;
|
|
6
|
+
});
|
|
7
|
+
//#endregion
|
|
8
|
+
export { middleware_default as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { t as ConfigDirectorClient } from "../types-D9MFb76Q.mjs";
|
|
2
|
+
import * as _$nitropack from "nitropack";
|
|
3
|
+
|
|
4
|
+
//#region src/runtime/nitro/plugin.d.ts
|
|
5
|
+
declare const _default: _$nitropack.NitroAppPlugin;
|
|
6
|
+
declare module "nitropack" {
|
|
7
|
+
interface NitroApp {
|
|
8
|
+
configDirectorClient: ConfigDirectorClient;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { _default as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { t as ConfigDirectorClient } from "../types-D9MFb76Q.mjs";
|
|
2
|
+
import * as _$nitropack from "nitropack";
|
|
3
|
+
|
|
4
|
+
//#region src/runtime/nitro/plugin.d.ts
|
|
5
|
+
declare const _default: _$nitropack.NitroAppPlugin;
|
|
6
|
+
declare module "nitropack" {
|
|
7
|
+
interface NitroApp {
|
|
8
|
+
configDirectorClient: ConfigDirectorClient;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { _default as default };
|