-
Notifications
You must be signed in to change notification settings - Fork 12
/
LDMultiKindContext.ts
47 lines (45 loc) · 1.29 KB
/
LDMultiKindContext.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { LDContextCommon } from './LDContextCommon';
/**
* A context which represents multiple kinds. Each kind having its own key and attributes.
*
* A multi-context must contain `kind: 'multi'` at the root.
*
* ```
* const myMultiContext = {
* // Multi-contexts must be of kind 'multi'.
* kind: 'multi',
* // The context is namespaced by its kind. This is an 'org' kind context.
* org: {
* // Each component context has its own key and attributes.
* key: 'my-org-key',
* someAttribute: 'my-attribute-value',
* },
* user: {
* key: 'my-user-key',
* firstName: 'Bob',
* lastName: 'Bobberson',
* _meta: {
* // Each component context has its own _meta attributes. This will only apply the this
* // 'user' context.
* privateAttributes: ['firstName']
* }
* }
* };
* ```
*
* The above multi-context contains both an 'org' and a 'user'. Each with their own key,
* attributes, and _meta attributes.
*/
export interface LDMultiKindContext {
/**
* The kind of the context.
*/
kind: 'multi';
/**
* The contexts which compose this multi-kind context.
*
* These should be of type LDContextCommon. "multi" is to allow
* for the top level "kind" attribute.
*/
[kind: string]: 'multi' | LDContextCommon;
}