@croct/sdk 0.10.0 → 0.11.0-alpha.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.
- package/.src/activeRecord.ts +150 -0
- package/.src/base64Url.ts +18 -0
- package/.src/cache/cache.ts +15 -0
- package/.src/cache/fallbackCache.ts +29 -0
- package/.src/cache/inMemoryCache.ts +21 -0
- package/.src/cache/index.ts +4 -0
- package/.src/cache/localStorageCache.ts +85 -0
- package/.src/channel/beaconSocketChannel.ts +153 -0
- package/.src/channel/channel.ts +20 -0
- package/.src/channel/encodedChannel.ts +21 -0
- package/.src/channel/guaranteedChannel.ts +131 -0
- package/.src/channel/index.ts +8 -0
- package/.src/channel/queuedChannel.ts +112 -0
- package/.src/channel/retryChannel.ts +90 -0
- package/.src/channel/sandboxChannel.ts +43 -0
- package/.src/channel/socketChannel.ts +217 -0
- package/.src/cid/assigner.ts +3 -0
- package/.src/cid/cachedAssigner.ts +35 -0
- package/.src/cid/fixedAssigner.ts +13 -0
- package/.src/cid/index.ts +4 -0
- package/.src/cid/remoteAssigner.ts +47 -0
- package/.src/constants.ts +6 -0
- package/.src/container.ts +388 -0
- package/.src/contentFetcher.ts +226 -0
- package/.src/context.ts +137 -0
- package/.src/error.ts +31 -0
- package/.src/evaluator.ts +251 -0
- package/.src/eventManager.ts +53 -0
- package/.src/facade/contentFetcherFacade.ts +69 -0
- package/.src/facade/evaluatorFacade.ts +152 -0
- package/.src/facade/index.ts +7 -0
- package/.src/facade/sdkFacade.ts +291 -0
- package/.src/facade/sessionFacade.ts +14 -0
- package/.src/facade/sessionPatch.ts +32 -0
- package/.src/facade/trackerFacade.ts +98 -0
- package/.src/facade/userFacade.ts +26 -0
- package/.src/facade/userPatch.ts +32 -0
- package/.src/index.ts +4 -0
- package/.src/logging/consoleLogger.ts +37 -0
- package/.src/logging/index.ts +4 -0
- package/.src/logging/logger.ts +13 -0
- package/.src/logging/namespacedLogger.ts +32 -0
- package/.src/logging/nullLogger.ts +19 -0
- package/.src/namespacedStorage.ts +69 -0
- package/.src/patch.ts +64 -0
- package/.src/queue/capacityRestrictedQueue.ts +44 -0
- package/.src/queue/inMemoryQueue.ts +43 -0
- package/.src/queue/index.ts +5 -0
- package/.src/queue/monitoredQueue.ts +168 -0
- package/.src/queue/persistentQueue.ts +84 -0
- package/.src/queue/queue.ts +15 -0
- package/.src/retry/arbitraryPolicy.ts +21 -0
- package/.src/retry/backoffPolicy.ts +84 -0
- package/.src/retry/index.ts +5 -0
- package/.src/retry/maxAttemptsPolicy.ts +28 -0
- package/.src/retry/neverPolicy.ts +11 -0
- package/.src/retry/policy.ts +5 -0
- package/.src/schema/attributeSchema.ts +6 -0
- package/.src/schema/contentFetcherSchemas.ts +23 -0
- package/.src/schema/contentSchemas.ts +44 -0
- package/.src/schema/contextSchemas.ts +5 -0
- package/.src/schema/ecommerceSchemas.ts +179 -0
- package/.src/schema/evaluatorSchemas.ts +11 -0
- package/.src/schema/eventSchemas.ts +150 -0
- package/.src/schema/index.ts +11 -0
- package/.src/schema/loggerSchema.ts +12 -0
- package/.src/schema/operationSchemas.ts +102 -0
- package/.src/schema/sdkFacadeSchemas.ts +44 -0
- package/.src/schema/sdkSchemas.ts +49 -0
- package/.src/schema/tokenSchema.ts +42 -0
- package/.src/schema/userSchema.ts +184 -0
- package/.src/sdk.ts +174 -0
- package/.src/sdkEvents.ts +15 -0
- package/.src/sourceLocation.ts +85 -0
- package/.src/tab.ts +148 -0
- package/.src/token/cachedTokenStore.ts +34 -0
- package/.src/token/inMemoryTokenStore.ts +13 -0
- package/.src/token/index.ts +4 -0
- package/.src/token/replicatedTokenStore.ts +21 -0
- package/.src/token/token.ts +164 -0
- package/.src/tracker.ts +460 -0
- package/.src/trackingEvents.ts +456 -0
- package/.src/transformer.ts +7 -0
- package/.src/utilityTypes.ts +3 -0
- package/.src/uuid.ts +43 -0
- package/.src/validation/arrayType.ts +71 -0
- package/.src/validation/booleanType.ts +22 -0
- package/.src/validation/functionType.ts +22 -0
- package/.src/validation/index.ts +12 -0
- package/.src/validation/jsonType.ts +157 -0
- package/.src/validation/mixedSchema.ts +7 -0
- package/.src/validation/nullType.ts +22 -0
- package/.src/validation/numberType.ts +59 -0
- package/.src/validation/objectType.ts +138 -0
- package/.src/validation/schema.ts +21 -0
- package/.src/validation/stringType.ts +118 -0
- package/.src/validation/unionType.ts +53 -0
- package/.src/validation/violation.ts +23 -0
- package/activeRecord.js +33 -36
- package/base64Url.js +1 -0
- package/cache/cache.js +1 -0
- package/cache/fallbackCache.js +16 -32
- package/cache/inMemoryCache.js +10 -10
- package/cache/index.js +2 -1
- package/cache/localStorageCache.js +25 -25
- package/channel/beaconSocketChannel.d.ts +1 -1
- package/channel/beaconSocketChannel.js +50 -79
- package/channel/channel.d.ts +1 -1
- package/channel/channel.js +1 -0
- package/channel/encodedChannel.js +9 -10
- package/channel/guaranteedChannel.d.ts +4 -4
- package/channel/guaranteedChannel.js +42 -43
- package/channel/index.js +2 -1
- package/channel/queuedChannel.js +36 -64
- package/channel/retryChannel.d.ts +1 -1
- package/channel/retryChannel.js +45 -77
- package/channel/sandboxChannel.js +18 -18
- package/channel/socketChannel.d.ts +4 -4
- package/channel/socketChannel.js +78 -79
- package/cid/assigner.js +1 -0
- package/cid/cachedAssigner.js +16 -27
- package/cid/fixedAssigner.js +6 -6
- package/cid/index.js +2 -1
- package/cid/remoteAssigner.js +24 -36
- package/constants.d.ts +6 -5
- package/constants.js +7 -5
- package/container.d.ts +13 -6
- package/container.js +153 -168
- package/contentFetcher.d.ts +59 -0
- package/contentFetcher.js +130 -0
- package/context.d.ts +3 -3
- package/context.js +37 -38
- package/error.js +3 -2
- package/evaluator.d.ts +33 -24
- package/evaluator.js +127 -117
- package/eventManager.d.ts +1 -1
- package/eventManager.js +15 -15
- package/facade/contentFetcherFacade.d.ts +27 -0
- package/facade/contentFetcherFacade.js +41 -0
- package/facade/evaluatorFacade.d.ts +13 -3
- package/facade/evaluatorFacade.js +58 -72
- package/facade/index.js +1 -0
- package/facade/sdkFacade.d.ts +10 -3
- package/facade/sdkFacade.js +130 -141
- package/facade/sessionFacade.js +7 -7
- package/facade/sessionPatch.js +10 -13
- package/facade/trackerFacade.js +33 -38
- package/facade/userFacade.js +11 -11
- package/facade/userPatch.js +10 -13
- package/index.js +3 -2
- package/logging/consoleLogger.js +19 -35
- package/logging/index.js +2 -1
- package/logging/logger.js +1 -0
- package/logging/namespacedLogger.js +15 -15
- package/logging/nullLogger.js +11 -13
- package/namespacedStorage.js +31 -47
- package/package.json +13 -16
- package/patch.d.ts +1 -1
- package/patch.js +1 -0
- package/queue/capacityRestrictedQueue.js +18 -18
- package/queue/inMemoryQueue.js +23 -28
- package/queue/index.js +2 -1
- package/queue/monitoredQueue.d.ts +2 -2
- package/queue/monitoredQueue.js +40 -40
- package/queue/persistentQueue.js +34 -38
- package/queue/queue.js +1 -0
- package/retry/arbitraryPolicy.js +9 -10
- package/retry/backoffPolicy.d.ts +1 -1
- package/retry/backoffPolicy.js +12 -13
- package/retry/index.js +2 -1
- package/retry/maxAttemptsPolicy.js +8 -8
- package/retry/neverPolicy.js +7 -9
- package/retry/policy.js +1 -0
- package/schema/attributeSchema.js +2 -1
- package/schema/contentFetcherSchemas.d.ts +2 -0
- package/schema/contentFetcherSchemas.js +23 -0
- package/schema/contentSchemas.js +2 -1
- package/schema/contextSchemas.js +2 -1
- package/schema/ecommerceSchemas.js +2 -1
- package/schema/evaluatorSchemas.d.ts +2 -0
- package/schema/{evaluationSchemas.js → evaluatorSchemas.js} +4 -3
- package/schema/eventSchemas.js +6 -7
- package/schema/index.d.ts +2 -1
- package/schema/index.js +4 -2
- package/schema/loggerSchema.js +2 -1
- package/schema/operationSchemas.js +9 -8
- package/schema/sdkFacadeSchemas.js +10 -6
- package/schema/sdkSchemas.js +9 -5
- package/schema/tokenSchema.js +6 -4
- package/schema/userSchema.js +3 -2
- package/sdk.d.ts +9 -3
- package/sdk.js +82 -127
- package/sdkEvents.d.ts +3 -3
- package/sdkEvents.js +1 -0
- package/sourceLocation.d.ts +3 -3
- package/sourceLocation.js +14 -14
- package/tab.d.ts +5 -5
- package/tab.js +51 -80
- package/token/cachedTokenStore.js +10 -10
- package/token/inMemoryTokenStore.js +8 -8
- package/token/index.js +2 -1
- package/token/replicatedTokenStore.js +8 -8
- package/token/token.d.ts +9 -5
- package/token/token.js +64 -57
- package/tracker.d.ts +4 -4
- package/tracker.js +146 -122
- package/trackingEvents.d.ts +36 -36
- package/trackingEvents.js +13 -6
- package/transformer.js +2 -1
- package/utilityTypes.d.ts +2 -2
- package/utilityTypes.js +1 -0
- package/uuid.js +10 -7
- package/validation/arrayType.d.ts +2 -2
- package/validation/arrayType.js +30 -27
- package/validation/booleanType.js +12 -15
- package/validation/functionType.js +12 -15
- package/validation/index.js +2 -1
- package/validation/jsonType.d.ts +2 -2
- package/validation/jsonType.js +62 -80
- package/validation/mixedSchema.js +5 -7
- package/validation/nullType.js +12 -15
- package/validation/numberType.d.ts +1 -1
- package/validation/numberType.js +24 -22
- package/validation/objectType.d.ts +1 -1
- package/validation/objectType.js +62 -72
- package/validation/schema.js +7 -10
- package/validation/stringType.d.ts +1 -1
- package/validation/stringType.js +37 -47
- package/validation/unionType.js +28 -77
- package/validation/violation.js +2 -2
- package/schema/evaluationSchemas.d.ts +0 -2
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import {ObjectType, StringType, NumberType, ArrayType} from '../validation';
|
|
2
|
+
|
|
3
|
+
export const productDetails = new ObjectType({
|
|
4
|
+
required: ['productId', 'name', 'displayPrice'],
|
|
5
|
+
properties: {
|
|
6
|
+
productId: new StringType({
|
|
7
|
+
minLength: 1,
|
|
8
|
+
maxLength: 50,
|
|
9
|
+
}),
|
|
10
|
+
sku: new StringType({
|
|
11
|
+
minLength: 1,
|
|
12
|
+
maxLength: 50,
|
|
13
|
+
}),
|
|
14
|
+
name: new StringType({
|
|
15
|
+
minLength: 1,
|
|
16
|
+
maxLength: 200,
|
|
17
|
+
}),
|
|
18
|
+
category: new StringType({
|
|
19
|
+
minLength: 1,
|
|
20
|
+
maxLength: 100,
|
|
21
|
+
}),
|
|
22
|
+
brand: new StringType({
|
|
23
|
+
minLength: 1,
|
|
24
|
+
maxLength: 100,
|
|
25
|
+
}),
|
|
26
|
+
variant: new StringType({
|
|
27
|
+
minLength: 1,
|
|
28
|
+
maxLength: 50,
|
|
29
|
+
}),
|
|
30
|
+
displayPrice: new NumberType({
|
|
31
|
+
minimum: 0,
|
|
32
|
+
}),
|
|
33
|
+
originalPrice: new NumberType({
|
|
34
|
+
minimum: 0,
|
|
35
|
+
}),
|
|
36
|
+
url: new StringType({
|
|
37
|
+
format: 'url',
|
|
38
|
+
}),
|
|
39
|
+
imageUrl: new StringType({
|
|
40
|
+
format: 'url',
|
|
41
|
+
}),
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export const cartItem = new ObjectType({
|
|
46
|
+
required: ['index', 'product', 'quantity', 'total'],
|
|
47
|
+
properties: {
|
|
48
|
+
index: new NumberType({
|
|
49
|
+
minimum: 0,
|
|
50
|
+
}),
|
|
51
|
+
product: productDetails,
|
|
52
|
+
quantity: new NumberType({
|
|
53
|
+
minimum: 1,
|
|
54
|
+
}),
|
|
55
|
+
total: new NumberType({
|
|
56
|
+
minimum: 0,
|
|
57
|
+
}),
|
|
58
|
+
discount: new NumberType({
|
|
59
|
+
minimum: 0,
|
|
60
|
+
}),
|
|
61
|
+
coupon: new StringType({
|
|
62
|
+
minLength: 1,
|
|
63
|
+
maxLength: 50,
|
|
64
|
+
}),
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
export const cart = new ObjectType({
|
|
69
|
+
required: ['currency', 'items', 'total'],
|
|
70
|
+
properties: {
|
|
71
|
+
currency: new StringType({
|
|
72
|
+
maxLength: 10,
|
|
73
|
+
minLength: 1,
|
|
74
|
+
}),
|
|
75
|
+
items: new ArrayType({
|
|
76
|
+
items: cartItem,
|
|
77
|
+
}),
|
|
78
|
+
subtotal: new NumberType({
|
|
79
|
+
minimum: 0,
|
|
80
|
+
}),
|
|
81
|
+
shippingPrice: new NumberType({
|
|
82
|
+
minimum: 0,
|
|
83
|
+
}),
|
|
84
|
+
taxes: new ObjectType({
|
|
85
|
+
additionalProperties: new NumberType(),
|
|
86
|
+
minProperties: 1,
|
|
87
|
+
}),
|
|
88
|
+
costs: new ObjectType({
|
|
89
|
+
additionalProperties: new NumberType(),
|
|
90
|
+
minProperties: 1,
|
|
91
|
+
}),
|
|
92
|
+
discount: new NumberType({
|
|
93
|
+
minimum: 0,
|
|
94
|
+
}),
|
|
95
|
+
total: new NumberType({
|
|
96
|
+
minimum: 0,
|
|
97
|
+
}),
|
|
98
|
+
coupon: new StringType({
|
|
99
|
+
minLength: 1,
|
|
100
|
+
maxLength: 50,
|
|
101
|
+
}),
|
|
102
|
+
lastUpdateTime: new NumberType(),
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
export const orderItem = new ObjectType({
|
|
107
|
+
required: ['index', 'product', 'quantity', 'total'],
|
|
108
|
+
properties: {
|
|
109
|
+
index: new NumberType({
|
|
110
|
+
minimum: 0,
|
|
111
|
+
}),
|
|
112
|
+
product: productDetails,
|
|
113
|
+
quantity: new NumberType({
|
|
114
|
+
minimum: 1,
|
|
115
|
+
}),
|
|
116
|
+
total: new NumberType({
|
|
117
|
+
minimum: 0,
|
|
118
|
+
}),
|
|
119
|
+
discount: new NumberType({
|
|
120
|
+
minimum: 0,
|
|
121
|
+
}),
|
|
122
|
+
coupon: new StringType({
|
|
123
|
+
minLength: 1,
|
|
124
|
+
maxLength: 50,
|
|
125
|
+
}),
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
export const order = new ObjectType({
|
|
130
|
+
required: ['orderId', 'currency', 'items', 'total'],
|
|
131
|
+
properties: {
|
|
132
|
+
orderId: new StringType({
|
|
133
|
+
minLength: 1,
|
|
134
|
+
maxLength: 50,
|
|
135
|
+
}),
|
|
136
|
+
currency: new StringType({
|
|
137
|
+
maxLength: 10,
|
|
138
|
+
minLength: 1,
|
|
139
|
+
}),
|
|
140
|
+
items: new ArrayType({
|
|
141
|
+
items: orderItem,
|
|
142
|
+
minItems: 1,
|
|
143
|
+
}),
|
|
144
|
+
subtotal: new NumberType({
|
|
145
|
+
minimum: 0,
|
|
146
|
+
}),
|
|
147
|
+
shippingPrice: new NumberType({
|
|
148
|
+
minimum: 0,
|
|
149
|
+
}),
|
|
150
|
+
taxes: new ObjectType({
|
|
151
|
+
additionalProperties: new NumberType(),
|
|
152
|
+
minProperties: 1,
|
|
153
|
+
}),
|
|
154
|
+
costs: new ObjectType({
|
|
155
|
+
additionalProperties: new NumberType(),
|
|
156
|
+
minProperties: 1,
|
|
157
|
+
}),
|
|
158
|
+
discount: new NumberType({
|
|
159
|
+
minimum: 0,
|
|
160
|
+
}),
|
|
161
|
+
total: new NumberType({
|
|
162
|
+
minimum: 0,
|
|
163
|
+
}),
|
|
164
|
+
coupon: new StringType({
|
|
165
|
+
minLength: 1,
|
|
166
|
+
maxLength: 50,
|
|
167
|
+
}),
|
|
168
|
+
paymentMethod: new StringType({
|
|
169
|
+
minLength: 1,
|
|
170
|
+
maxLength: 50,
|
|
171
|
+
}),
|
|
172
|
+
installments: new NumberType({
|
|
173
|
+
minimum: 1,
|
|
174
|
+
}),
|
|
175
|
+
status: new StringType({
|
|
176
|
+
enumeration: ['placed', 'paid', 'complete'],
|
|
177
|
+
}),
|
|
178
|
+
},
|
|
179
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {ObjectType, NumberType, JsonObjectType} from '../validation';
|
|
2
|
+
|
|
3
|
+
export const evaluationOptionsSchema = new ObjectType({
|
|
4
|
+
properties: {
|
|
5
|
+
timeout: new NumberType({
|
|
6
|
+
integer: true,
|
|
7
|
+
minimum: 0,
|
|
8
|
+
}),
|
|
9
|
+
attributes: new JsonObjectType(),
|
|
10
|
+
},
|
|
11
|
+
});
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ObjectType,
|
|
3
|
+
StringType,
|
|
4
|
+
NumberType,
|
|
5
|
+
UnionType,
|
|
6
|
+
NullType,
|
|
7
|
+
BooleanType,
|
|
8
|
+
ArrayType,
|
|
9
|
+
} from '../validation';
|
|
10
|
+
import {cart, order, productDetails} from './ecommerceSchemas';
|
|
11
|
+
import {userProfileSchema} from './userSchema';
|
|
12
|
+
import {postDetails} from './contentSchemas';
|
|
13
|
+
|
|
14
|
+
export const cartModified = new ObjectType({
|
|
15
|
+
required: ['cart'],
|
|
16
|
+
properties: {
|
|
17
|
+
cart: cart,
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export const cartViewed = new ObjectType({
|
|
22
|
+
required: ['cart'],
|
|
23
|
+
properties: {
|
|
24
|
+
cart: cart,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export const checkoutStarted = new ObjectType({
|
|
29
|
+
required: ['cart'],
|
|
30
|
+
properties: {
|
|
31
|
+
cart: cart,
|
|
32
|
+
orderId: new StringType({
|
|
33
|
+
minLength: 1,
|
|
34
|
+
maxLength: 50,
|
|
35
|
+
}),
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export const orderPlaced = new ObjectType({
|
|
40
|
+
required: ['order'],
|
|
41
|
+
properties: {
|
|
42
|
+
order: order,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
export const productViewed = new ObjectType({
|
|
47
|
+
required: ['product'],
|
|
48
|
+
properties: {
|
|
49
|
+
product: productDetails,
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
export const userSignedUp = new ObjectType({
|
|
54
|
+
required: ['userId'],
|
|
55
|
+
properties: {
|
|
56
|
+
userId: new StringType({
|
|
57
|
+
minLength: 1,
|
|
58
|
+
maxLength: 254,
|
|
59
|
+
}),
|
|
60
|
+
profile: userProfileSchema,
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
export const goalCompleted = new ObjectType({
|
|
65
|
+
required: ['goalId'],
|
|
66
|
+
properties: {
|
|
67
|
+
goalId: new StringType({
|
|
68
|
+
minLength: 3,
|
|
69
|
+
maxLength: 100,
|
|
70
|
+
pattern: /^[a-z0-9][a-z0-9:_-]+[a-z0-9]$/i,
|
|
71
|
+
}),
|
|
72
|
+
value: new NumberType({
|
|
73
|
+
minimum: 0,
|
|
74
|
+
}),
|
|
75
|
+
currency: new StringType({
|
|
76
|
+
minLength: 1,
|
|
77
|
+
maxLength: 10,
|
|
78
|
+
}),
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
export const interestShown = new ObjectType({
|
|
83
|
+
required: ['interests'],
|
|
84
|
+
properties: {
|
|
85
|
+
interests: new ArrayType({
|
|
86
|
+
items: new StringType({
|
|
87
|
+
minLength: 1,
|
|
88
|
+
maxLength: 50,
|
|
89
|
+
}),
|
|
90
|
+
minItems: 1,
|
|
91
|
+
maxItems: 10,
|
|
92
|
+
}),
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
export const postViewed = new ObjectType({
|
|
97
|
+
required: ['post'],
|
|
98
|
+
properties: {
|
|
99
|
+
post: postDetails,
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
export const linkOpened = new ObjectType({
|
|
104
|
+
required: ['link'],
|
|
105
|
+
properties: {
|
|
106
|
+
link: new StringType(),
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
export const eventOccurred = new ObjectType({
|
|
111
|
+
required: ['name'],
|
|
112
|
+
properties: {
|
|
113
|
+
name: new StringType({
|
|
114
|
+
minLength: 1,
|
|
115
|
+
maxLength: 50,
|
|
116
|
+
}),
|
|
117
|
+
testId: new StringType({
|
|
118
|
+
minLength: 1,
|
|
119
|
+
maxLength: 50,
|
|
120
|
+
}),
|
|
121
|
+
groupId: new StringType({
|
|
122
|
+
minLength: 1,
|
|
123
|
+
maxLength: 50,
|
|
124
|
+
}),
|
|
125
|
+
personalizationId: new StringType({
|
|
126
|
+
minLength: 1,
|
|
127
|
+
maxLength: 50,
|
|
128
|
+
}),
|
|
129
|
+
audience: new StringType({
|
|
130
|
+
minLength: 1,
|
|
131
|
+
maxLength: 50,
|
|
132
|
+
}),
|
|
133
|
+
details: new ObjectType({
|
|
134
|
+
additionalProperties: new UnionType(
|
|
135
|
+
new NullType(),
|
|
136
|
+
new BooleanType(),
|
|
137
|
+
new NumberType(),
|
|
138
|
+
new StringType({
|
|
139
|
+
maxLength: 300,
|
|
140
|
+
}),
|
|
141
|
+
),
|
|
142
|
+
propertyNames: new StringType({
|
|
143
|
+
minLength: 1,
|
|
144
|
+
maxLength: 20,
|
|
145
|
+
format: 'identifier',
|
|
146
|
+
}),
|
|
147
|
+
maxProperties: 10,
|
|
148
|
+
}),
|
|
149
|
+
},
|
|
150
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './contextSchemas';
|
|
2
|
+
export * from './ecommerceSchemas';
|
|
3
|
+
export * from './evaluatorSchemas';
|
|
4
|
+
export * from './contentFetcherSchemas';
|
|
5
|
+
export * from './eventSchemas';
|
|
6
|
+
export * from './loggerSchema';
|
|
7
|
+
export * from './operationSchemas';
|
|
8
|
+
export * from './sdkFacadeSchemas';
|
|
9
|
+
export * from './sdkSchemas';
|
|
10
|
+
export * from './tokenSchema';
|
|
11
|
+
export * from './userSchema';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {ObjectType, FunctionType} from '../validation';
|
|
2
|
+
|
|
3
|
+
export const loggerSchema = new ObjectType({
|
|
4
|
+
required: ['debug', 'info', 'warn', 'error'],
|
|
5
|
+
additionalProperties: true,
|
|
6
|
+
properties: {
|
|
7
|
+
debug: new FunctionType(),
|
|
8
|
+
info: new FunctionType(),
|
|
9
|
+
warn: new FunctionType(),
|
|
10
|
+
error: new FunctionType(),
|
|
11
|
+
},
|
|
12
|
+
});
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ObjectType,
|
|
3
|
+
StringType,
|
|
4
|
+
NumberType,
|
|
5
|
+
JsonArrayType,
|
|
6
|
+
JsonObjectType,
|
|
7
|
+
JsonPrimitiveType,
|
|
8
|
+
UnionType,
|
|
9
|
+
} from '../validation';
|
|
10
|
+
import {attributeNameSchema} from './attributeSchema';
|
|
11
|
+
|
|
12
|
+
const pointer = new StringType({
|
|
13
|
+
format: 'pointer',
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const simpleArray = new JsonArrayType({
|
|
17
|
+
items: new JsonPrimitiveType(),
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const simpleMap = new JsonObjectType({
|
|
21
|
+
properties: new JsonPrimitiveType(),
|
|
22
|
+
propertyNames: attributeNameSchema,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const complexMap = new JsonObjectType({
|
|
26
|
+
properties: new UnionType(new JsonPrimitiveType(), simpleArray, simpleMap),
|
|
27
|
+
propertyNames: attributeNameSchema,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const collectionValue = new UnionType(simpleArray, complexMap);
|
|
31
|
+
|
|
32
|
+
const mixedValue = new UnionType(new JsonPrimitiveType(), simpleArray, complexMap);
|
|
33
|
+
|
|
34
|
+
export const addOperation = new ObjectType({
|
|
35
|
+
required: ['path', 'value'],
|
|
36
|
+
properties: {
|
|
37
|
+
path: pointer,
|
|
38
|
+
value: mixedValue,
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
export const setOperation = new ObjectType({
|
|
43
|
+
required: ['path', 'value'],
|
|
44
|
+
properties: {
|
|
45
|
+
path: pointer,
|
|
46
|
+
value: mixedValue,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export const combineOperation = new ObjectType({
|
|
51
|
+
required: ['path', 'value'],
|
|
52
|
+
properties: {
|
|
53
|
+
path: pointer,
|
|
54
|
+
value: mixedValue,
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
export const mergeOperation = new ObjectType({
|
|
59
|
+
required: ['path', 'value'],
|
|
60
|
+
properties: {
|
|
61
|
+
path: pointer,
|
|
62
|
+
value: collectionValue,
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
export const decrementOperation = new ObjectType({
|
|
67
|
+
required: ['path', 'value'],
|
|
68
|
+
properties: {
|
|
69
|
+
path: pointer,
|
|
70
|
+
value: new NumberType(),
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
export const incrementOperation = new ObjectType({
|
|
75
|
+
required: ['path', 'value'],
|
|
76
|
+
properties: {
|
|
77
|
+
path: pointer,
|
|
78
|
+
value: new NumberType(),
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
export const clearOperation = new ObjectType({
|
|
83
|
+
required: ['path'],
|
|
84
|
+
properties: {
|
|
85
|
+
path: pointer,
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
export const unsetOperation = new ObjectType({
|
|
90
|
+
required: ['path'],
|
|
91
|
+
properties: {
|
|
92
|
+
path: pointer,
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
export const removeOperation = new ObjectType({
|
|
97
|
+
required: ['path', 'value'],
|
|
98
|
+
properties: {
|
|
99
|
+
path: pointer,
|
|
100
|
+
value: mixedValue,
|
|
101
|
+
},
|
|
102
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import {ObjectType, StringType, BooleanType, UnionType, NullType, FunctionType} from '../validation';
|
|
2
|
+
import {tokenScopeSchema} from './contextSchemas';
|
|
3
|
+
import {eventMetadataSchema} from './sdkSchemas';
|
|
4
|
+
import {loggerSchema} from './loggerSchema';
|
|
5
|
+
|
|
6
|
+
export const sdkFacadeConfigurationSchema = new ObjectType({
|
|
7
|
+
required: ['appId'],
|
|
8
|
+
properties: {
|
|
9
|
+
appId: new StringType({
|
|
10
|
+
format: 'uuid',
|
|
11
|
+
}),
|
|
12
|
+
clientId: new StringType({
|
|
13
|
+
pattern: /^[0-9a-f]{32}$/i,
|
|
14
|
+
}),
|
|
15
|
+
tokenScope: tokenScopeSchema,
|
|
16
|
+
debug: new BooleanType(),
|
|
17
|
+
test: new BooleanType(),
|
|
18
|
+
track: new BooleanType(),
|
|
19
|
+
logger: loggerSchema,
|
|
20
|
+
urlSanitizer: new FunctionType(),
|
|
21
|
+
eventMetadata: eventMetadataSchema,
|
|
22
|
+
userId: new StringType({
|
|
23
|
+
minLength: 1,
|
|
24
|
+
}),
|
|
25
|
+
token: new UnionType(
|
|
26
|
+
new StringType({
|
|
27
|
+
pattern: /^[A-Za-z0-9-_=]+\.[A-Za-z0-9-_=]+\.?[A-Za-z0-9-_.+/=]*$/,
|
|
28
|
+
}),
|
|
29
|
+
new NullType(),
|
|
30
|
+
),
|
|
31
|
+
trackerEndpointUrl: new StringType({
|
|
32
|
+
format: 'url',
|
|
33
|
+
}),
|
|
34
|
+
evaluationEndpointUrl: new StringType({
|
|
35
|
+
format: 'url',
|
|
36
|
+
}),
|
|
37
|
+
contentEndpointUrl: new StringType({
|
|
38
|
+
format: 'url',
|
|
39
|
+
}),
|
|
40
|
+
cidAssignerEndpointUrl: new StringType({
|
|
41
|
+
format: 'url',
|
|
42
|
+
}),
|
|
43
|
+
},
|
|
44
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {ObjectType, StringType, BooleanType, NumberType, FunctionType} from '../validation';
|
|
2
|
+
import {tokenScopeSchema} from './contextSchemas';
|
|
3
|
+
import {loggerSchema} from './loggerSchema';
|
|
4
|
+
|
|
5
|
+
export const eventMetadataSchema = new ObjectType({
|
|
6
|
+
maxProperties: 5,
|
|
7
|
+
propertyNames: new StringType({
|
|
8
|
+
minLength: 1,
|
|
9
|
+
maxLength: 20,
|
|
10
|
+
format: 'identifier',
|
|
11
|
+
}),
|
|
12
|
+
additionalProperties: new StringType({
|
|
13
|
+
maxLength: 300,
|
|
14
|
+
}),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export const sdkConfigurationSchema = new ObjectType({
|
|
18
|
+
required: ['appId'],
|
|
19
|
+
properties: {
|
|
20
|
+
appId: new StringType({
|
|
21
|
+
format: 'uuid',
|
|
22
|
+
}),
|
|
23
|
+
clientId: new StringType({
|
|
24
|
+
pattern: /^[0-9a-f]{32}$/i,
|
|
25
|
+
}),
|
|
26
|
+
tokenScope: tokenScopeSchema,
|
|
27
|
+
trackerEndpointUrl: new StringType({
|
|
28
|
+
format: 'url',
|
|
29
|
+
}),
|
|
30
|
+
evaluationEndpointUrl: new StringType({
|
|
31
|
+
format: 'url',
|
|
32
|
+
}),
|
|
33
|
+
contentEndpointUrl: new StringType({
|
|
34
|
+
format: 'url',
|
|
35
|
+
}),
|
|
36
|
+
cidAssignerEndpointUrl: new StringType({
|
|
37
|
+
format: 'url',
|
|
38
|
+
}),
|
|
39
|
+
beaconQueueSize: new NumberType({
|
|
40
|
+
minimum: 0,
|
|
41
|
+
integer: true,
|
|
42
|
+
}),
|
|
43
|
+
debug: new BooleanType(),
|
|
44
|
+
test: new BooleanType(),
|
|
45
|
+
logger: loggerSchema,
|
|
46
|
+
urlSanitizer: new FunctionType(),
|
|
47
|
+
eventMetadata: eventMetadataSchema,
|
|
48
|
+
},
|
|
49
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {ObjectType, StringType, NumberType, UnionType, ArrayType} from '../validation';
|
|
2
|
+
|
|
3
|
+
export const tokenSchema = new ObjectType({
|
|
4
|
+
required: ['headers', 'payload'],
|
|
5
|
+
properties: {
|
|
6
|
+
headers: new ObjectType({
|
|
7
|
+
required: ['typ', 'alg'],
|
|
8
|
+
properties: {
|
|
9
|
+
typ: new StringType(),
|
|
10
|
+
alg: new StringType(),
|
|
11
|
+
kid: new StringType(),
|
|
12
|
+
appId: new StringType({
|
|
13
|
+
format: 'uuid',
|
|
14
|
+
}),
|
|
15
|
+
},
|
|
16
|
+
}),
|
|
17
|
+
payload: new ObjectType({
|
|
18
|
+
required: ['iss', 'aud', 'iat'],
|
|
19
|
+
properties: {
|
|
20
|
+
iss: new StringType(),
|
|
21
|
+
aud: new UnionType(
|
|
22
|
+
new StringType(),
|
|
23
|
+
new ArrayType({items: new StringType()}),
|
|
24
|
+
),
|
|
25
|
+
iat: new NumberType({
|
|
26
|
+
minimum: 0,
|
|
27
|
+
}),
|
|
28
|
+
sub: new StringType({
|
|
29
|
+
minLength: 1,
|
|
30
|
+
}),
|
|
31
|
+
exp: new NumberType({
|
|
32
|
+
minimum: 0,
|
|
33
|
+
}),
|
|
34
|
+
jti: new StringType({
|
|
35
|
+
format: 'uuid',
|
|
36
|
+
}),
|
|
37
|
+
},
|
|
38
|
+
additionalProperties: true,
|
|
39
|
+
}),
|
|
40
|
+
signature: new StringType(),
|
|
41
|
+
},
|
|
42
|
+
});
|