@unleash/proxy-client-vue 0.0.7-beta.5 → 0.0.8
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 +18 -20
- package/dist/FlagProvider.vue.d.ts +65 -0
- package/dist/env.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.es.js +154 -120
- package/dist/index.umd.js +2 -3
- package/dist/plugin.d.ts +2 -3
- package/dist/useFlag.d.ts +1 -1
- package/dist/useFlagsStatus.d.ts +1 -1
- package/dist/useUnleashProvide.d.ts +1 -1
- package/dist/useVariant.d.ts +1 -1
- package/package.json +5 -14
- package/dist/FlagProvider.d.ts +0 -35
- package/dist/index.es.js.map +0 -1
- package/dist/index.umd.js.map +0 -1
package/README.md
CHANGED
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
PoC for a Vue SDK for [Unleash](https://www.getunleash.io/) based on the official [proxy-client-react](https://github.com/Unleash/proxy-client-react).
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Usage note
|
|
6
6
|
|
|
7
|
-
This library is meant to be used with
|
|
7
|
+
This library is meant to be used with [Unleash Edge](https://github.com/Unleash/unleash-edge/), the [Unleash front-end API](https://docs.getunleash.io/reference/front-end-api) , or the [Unleash proxy](https://github.com/Unleash/unleash-proxy).
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
It is **not** compatible with the Unleash client API.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
10
12
|
|
|
11
13
|
```bash
|
|
12
14
|
npm install @unleash/proxy-client-vue
|
|
@@ -14,9 +16,9 @@ npm install @unleash/proxy-client-vue
|
|
|
14
16
|
yarn add @unleash/proxy-client-vue
|
|
15
17
|
```
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
## Initialization
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
### Using config:
|
|
20
22
|
|
|
21
23
|
```jsx
|
|
22
24
|
import { createApp } from 'vue'
|
|
@@ -29,7 +31,6 @@ const config = {
|
|
|
29
31
|
clientKey: 'PROXYKEY',
|
|
30
32
|
refreshInterval: 15,
|
|
31
33
|
appName: 'your-app-name',
|
|
32
|
-
environment: 'dev'
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
const app = createApp(App)
|
|
@@ -43,11 +44,10 @@ Or use the FlagProvider component like this in your entrypoint file (typically A
|
|
|
43
44
|
import { FlagProvider } from '@unleash/proxy-client-vue'
|
|
44
45
|
|
|
45
46
|
const config = {
|
|
46
|
-
url: 'https://
|
|
47
|
-
clientKey: '
|
|
47
|
+
url: 'https://UNLEASH-INSTANCE/api/frontend',
|
|
48
|
+
clientKey: 'CLIENT—SIDE—API—TOKEN',
|
|
48
49
|
refreshInterval: 15,
|
|
49
50
|
appName: 'your-app-name',
|
|
50
|
-
environment: 'dev'
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
<template>
|
|
@@ -57,7 +57,7 @@ const config = {
|
|
|
57
57
|
</template>
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
### Initializing your own client
|
|
61
61
|
|
|
62
62
|
```jsx
|
|
63
63
|
import { createApp } from 'vue'
|
|
@@ -70,7 +70,6 @@ const config = {
|
|
|
70
70
|
clientKey: 'PROXYKEY',
|
|
71
71
|
refreshInterval: 15,
|
|
72
72
|
appName: 'your-app-name',
|
|
73
|
-
environment: 'dev'
|
|
74
73
|
}
|
|
75
74
|
|
|
76
75
|
const client = new UnleashClient(config)
|
|
@@ -86,11 +85,10 @@ Or, using FlagProvider:
|
|
|
86
85
|
import { FlagProvider, UnleashClient } from '@unleash/proxy-client-vue'
|
|
87
86
|
|
|
88
87
|
const config = {
|
|
89
|
-
url: 'https://
|
|
90
|
-
clientKey: '
|
|
88
|
+
url: 'https://UNLEASH-INSTANCE/api/frontend',
|
|
89
|
+
clientKey: 'CLIENT—SIDE—API—TOKEN',
|
|
91
90
|
refreshInterval: 15,
|
|
92
91
|
appName: 'your-app-name',
|
|
93
|
-
environment: 'dev'
|
|
94
92
|
}
|
|
95
93
|
|
|
96
94
|
const client = new UnleashClient(config)
|
|
@@ -102,7 +100,7 @@ const client = new UnleashClient(config)
|
|
|
102
100
|
</template>
|
|
103
101
|
```
|
|
104
102
|
|
|
105
|
-
|
|
103
|
+
### Deferring client start
|
|
106
104
|
|
|
107
105
|
By default, the Unleash client will start polling the Proxy for toggles immediately when the `FlagProvider` component renders. You can delay the polling by:
|
|
108
106
|
|
|
@@ -141,9 +139,9 @@ onMounted(() => {
|
|
|
141
139
|
</template>
|
|
142
140
|
```
|
|
143
141
|
|
|
144
|
-
|
|
142
|
+
## Usage
|
|
145
143
|
|
|
146
|
-
|
|
144
|
+
### Check feature toggle status
|
|
147
145
|
|
|
148
146
|
To check if a feature is enabled:
|
|
149
147
|
|
|
@@ -160,7 +158,7 @@ const enabled = useFlag('travel.landing')
|
|
|
160
158
|
</template>
|
|
161
159
|
```
|
|
162
160
|
|
|
163
|
-
|
|
161
|
+
### Check variants
|
|
164
162
|
|
|
165
163
|
To check variants:
|
|
166
164
|
|
|
@@ -178,7 +176,7 @@ const variant = useVariant('travel.landing')
|
|
|
178
176
|
</template>
|
|
179
177
|
```
|
|
180
178
|
|
|
181
|
-
|
|
179
|
+
### Defer rendering until flags fetched
|
|
182
180
|
|
|
183
181
|
useFlagsStatus retrieves the ready state and error events.
|
|
184
182
|
Follow the following steps in order to delay rendering until the flags have been fetched.
|
|
@@ -192,7 +190,7 @@ const { flagsReady, flagsError } = useFlagsStatus()
|
|
|
192
190
|
<MyComponent v-else error={flagsError} />
|
|
193
191
|
```
|
|
194
192
|
|
|
195
|
-
|
|
193
|
+
### Updating context
|
|
196
194
|
|
|
197
195
|
Follow the following steps in order to update the unleash context:
|
|
198
196
|
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { UnleashClient } from 'unleash-proxy-client';
|
|
2
|
+
declare const _sfc_main: import("vue").DefineComponent<{
|
|
3
|
+
config: {
|
|
4
|
+
type: null;
|
|
5
|
+
required: false;
|
|
6
|
+
};
|
|
7
|
+
unleashClient: {
|
|
8
|
+
type: null;
|
|
9
|
+
required: false;
|
|
10
|
+
};
|
|
11
|
+
startClient: {
|
|
12
|
+
type: BooleanConstructor;
|
|
13
|
+
required: false;
|
|
14
|
+
};
|
|
15
|
+
}, {
|
|
16
|
+
context: import("vue").ToRefs<{
|
|
17
|
+
on: (event: string, args_0: Function, args_1: any) => UnleashClient | undefined;
|
|
18
|
+
updateContext: (context: import("unleash-proxy-client").IContext) => Promise<void>;
|
|
19
|
+
isEnabled: (name: string) => boolean | undefined;
|
|
20
|
+
getVariant: (name: string) => import("unleash-proxy-client").IVariant | undefined;
|
|
21
|
+
client: {
|
|
22
|
+
getAllToggles: () => import("unleash-proxy-client").IToggle[];
|
|
23
|
+
isEnabled: (toggleName: string) => boolean;
|
|
24
|
+
getVariant: (toggleName: string) => import("unleash-proxy-client").IVariant;
|
|
25
|
+
updateContext: (context: import("unleash-proxy-client").IMutableContext) => Promise<void>;
|
|
26
|
+
getContext: () => {
|
|
27
|
+
appName: string;
|
|
28
|
+
environment?: string | undefined;
|
|
29
|
+
userId?: string | undefined;
|
|
30
|
+
sessionId?: string | undefined;
|
|
31
|
+
remoteAddress?: string | undefined;
|
|
32
|
+
properties?: {
|
|
33
|
+
[key: string]: string;
|
|
34
|
+
} | undefined;
|
|
35
|
+
};
|
|
36
|
+
setContextField: (field: string, value: string) => void;
|
|
37
|
+
start: () => Promise<void>;
|
|
38
|
+
stop: () => void;
|
|
39
|
+
on: (event: string, callback: Function, ctx?: any) => UnleashClient;
|
|
40
|
+
once: (event: string, callback: Function, ctx?: any) => UnleashClient;
|
|
41
|
+
emit: (event: string, ...args: any[]) => UnleashClient;
|
|
42
|
+
off: (event: string, callback?: Function | undefined) => UnleashClient;
|
|
43
|
+
} | undefined;
|
|
44
|
+
flagsReady: boolean;
|
|
45
|
+
flagsError: null;
|
|
46
|
+
}>;
|
|
47
|
+
start: () => void;
|
|
48
|
+
update: (property: string, value: any) => void;
|
|
49
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
50
|
+
config: {
|
|
51
|
+
type: null;
|
|
52
|
+
required: false;
|
|
53
|
+
};
|
|
54
|
+
unleashClient: {
|
|
55
|
+
type: null;
|
|
56
|
+
required: false;
|
|
57
|
+
};
|
|
58
|
+
startClient: {
|
|
59
|
+
type: BooleanConstructor;
|
|
60
|
+
required: false;
|
|
61
|
+
};
|
|
62
|
+
}>>, {
|
|
63
|
+
startClient: boolean;
|
|
64
|
+
}>;
|
|
65
|
+
export default _sfc_main;
|
package/dist/env.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="vite/client" />
|
|
2
2
|
|
|
3
3
|
declare module '*.vue' {
|
|
4
|
-
import type { DefineComponent } from 'vue
|
|
4
|
+
import type { DefineComponent } from 'vue'
|
|
5
5
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
|
|
6
6
|
const component: DefineComponent<{}, {}, any>
|
|
7
7
|
export default component
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type { IConfig, IContext, IMutableContext, IVariant, IToggle, IStorageProvider } from 'unleash-proxy-client';
|
|
2
2
|
export { UnleashClient, LocalStorageProvider, InMemoryStorageProvider } from 'unleash-proxy-client';
|
|
3
3
|
import { ContextStateSymbol, ContextUpdateSymbol } from './context';
|
|
4
|
-
import FlagProvider from './FlagProvider';
|
|
4
|
+
import FlagProvider from './FlagProvider.vue';
|
|
5
5
|
import useFlag from './useFlag';
|
|
6
6
|
import useFlagsStatus from './useFlagsStatus';
|
|
7
7
|
import useVariant from './useVariant';
|