@croct/sdk 0.17.9 → 0.17.11

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.
Files changed (209) hide show
  1. package/activeRecord.cjs +135 -0
  2. package/apiKey.cjs +178 -0
  3. package/base64Url.cjs +41 -0
  4. package/cache/cache.cjs +34 -0
  5. package/cache/cookieCache.cjs +85 -0
  6. package/cache/fallbackCache.cjs +47 -0
  7. package/cache/inMemoryCache.cjs +41 -0
  8. package/cache/index.cjs +37 -0
  9. package/cache/localStorageCache.cjs +81 -0
  10. package/channel/channel.cjs +48 -0
  11. package/channel/encodedChannel.cjs +39 -0
  12. package/channel/guaranteedChannel.cjs +105 -0
  13. package/channel/httpBeaconChannel.cjs +111 -0
  14. package/channel/index.cjs +46 -0
  15. package/channel/queuedChannel.cjs +122 -0
  16. package/channel/retryChannel.cjs +87 -0
  17. package/channel/sandboxChannel.cjs +63 -0
  18. package/cid/assigner.cjs +16 -0
  19. package/cid/cachedAssigner.cjs +66 -0
  20. package/cid/fixedAssigner.cjs +35 -0
  21. package/cid/index.cjs +37 -0
  22. package/cid/remoteAssigner.cjs +65 -0
  23. package/constants.cjs +37 -0
  24. package/constants.cjs.map +1 -1
  25. package/constants.d.ts +2 -2
  26. package/constants.js +1 -1
  27. package/constants.js.map +1 -1
  28. package/container.cjs +305 -0
  29. package/contentFetcher.cjs +193 -0
  30. package/context.cjs +114 -0
  31. package/error.cjs +52 -0
  32. package/evaluator.cjs +219 -0
  33. package/eventManager.cjs +53 -0
  34. package/eventSubjectProcessor.cjs +84 -0
  35. package/facade/contentFetcherFacade.cjs +61 -0
  36. package/facade/evaluatorFacade.cjs +94 -0
  37. package/facade/index.cjs +52 -0
  38. package/facade/sdkFacade.cjs +229 -0
  39. package/facade/sessionFacade.cjs +36 -0
  40. package/facade/sessionPatch.cjs +48 -0
  41. package/facade/trackerFacade.cjs +87 -0
  42. package/facade/userFacade.cjs +43 -0
  43. package/facade/userPatch.cjs +48 -0
  44. package/help.cjs +45 -0
  45. package/index.cjs +33 -0
  46. package/logging/consoleLogger.cjs +50 -0
  47. package/logging/filteredLogger.cjs +62 -0
  48. package/logging/index.cjs +40 -0
  49. package/logging/logger.cjs +16 -0
  50. package/logging/namespacedLogger.cjs +48 -0
  51. package/logging/nullLogger.cjs +37 -0
  52. package/namespacedStorage.cjs +77 -0
  53. package/package.json +7 -6
  54. package/patch.cjs +16 -0
  55. package/queue/capacityRestrictedQueue.cjs +57 -0
  56. package/queue/inMemoryQueue.cjs +58 -0
  57. package/queue/index.cjs +40 -0
  58. package/queue/monitoredQueue.cjs +141 -0
  59. package/queue/persistentQueue.cjs +78 -0
  60. package/queue/queue.cjs +16 -0
  61. package/retry/arbitraryPolicy.cjs +41 -0
  62. package/retry/backoffPolicy.cjs +81 -0
  63. package/retry/index.cjs +40 -0
  64. package/retry/maxAttemptsPolicy.cjs +45 -0
  65. package/retry/neverPolicy.cjs +35 -0
  66. package/retry/policy.cjs +16 -0
  67. package/schema/attributeSchema.cjs +32 -0
  68. package/schema/contentFetcherSchemas.cjs +49 -0
  69. package/schema/contentSchemas.cjs +70 -0
  70. package/schema/contextSchemas.cjs +31 -0
  71. package/schema/ecommerceSchemas.cjs +209 -0
  72. package/schema/evaluatorSchemas.cjs +64 -0
  73. package/schema/eventSchemas.cjs +162 -0
  74. package/schema/index.cjs +42 -0
  75. package/schema/loggerSchema.cjs +38 -0
  76. package/schema/operationSchemas.cjs +122 -0
  77. package/schema/sdkFacadeSchemas.cjs +82 -0
  78. package/schema/sdkSchemas.cjs +110 -0
  79. package/schema/tokenSchema.cjs +68 -0
  80. package/schema/userSchema.cjs +202 -0
  81. package/sdk.cjs +134 -0
  82. package/sdkEvents.cjs +16 -0
  83. package/sourceLocation.cjs +92 -0
  84. package/tab.cjs +122 -0
  85. package/token/cachedTokenStore.cjs +51 -0
  86. package/token/inMemoryTokenStore.cjs +38 -0
  87. package/token/index.cjs +37 -0
  88. package/token/replicatedTokenStore.cjs +40 -0
  89. package/token/token.cjs +239 -0
  90. package/tracker.cjs +358 -0
  91. package/trackingEvents.cjs +94 -0
  92. package/transformer.cjs +30 -0
  93. package/utilityTypes.cjs +16 -0
  94. package/uuid.cjs +55 -0
  95. package/validation/arrayType.cjs +75 -0
  96. package/validation/booleanType.cjs +46 -0
  97. package/validation/functionType.cjs +46 -0
  98. package/validation/index.cjs +66 -0
  99. package/validation/jsonType.cjs +142 -0
  100. package/validation/mixedSchema.cjs +31 -0
  101. package/validation/nullType.cjs +46 -0
  102. package/validation/numberType.cjs +69 -0
  103. package/validation/objectType.cjs +114 -0
  104. package/validation/schema.cjs +34 -0
  105. package/validation/stringType.cjs +106 -0
  106. package/validation/unionType.cjs +67 -0
  107. package/validation/violation.cjs +47 -0
  108. package/src/activeRecord.ts +0 -150
  109. package/src/apiKey.ts +0 -208
  110. package/src/base64Url.ts +0 -22
  111. package/src/cache/cache.ts +0 -22
  112. package/src/cache/cookieCache.ts +0 -88
  113. package/src/cache/fallbackCache.ts +0 -29
  114. package/src/cache/inMemoryCache.ts +0 -21
  115. package/src/cache/index.ts +0 -4
  116. package/src/cache/localStorageCache.ts +0 -85
  117. package/src/channel/channel.ts +0 -52
  118. package/src/channel/encodedChannel.ts +0 -21
  119. package/src/channel/guaranteedChannel.ts +0 -131
  120. package/src/channel/httpBeaconChannel.ts +0 -128
  121. package/src/channel/index.ts +0 -7
  122. package/src/channel/queuedChannel.ts +0 -143
  123. package/src/channel/retryChannel.ts +0 -94
  124. package/src/channel/sandboxChannel.ts +0 -47
  125. package/src/cid/assigner.ts +0 -3
  126. package/src/cid/cachedAssigner.ts +0 -68
  127. package/src/cid/fixedAssigner.ts +0 -13
  128. package/src/cid/index.ts +0 -4
  129. package/src/cid/remoteAssigner.ts +0 -57
  130. package/src/constants.ts +0 -4
  131. package/src/container.ts +0 -410
  132. package/src/contentFetcher.ts +0 -290
  133. package/src/context.ts +0 -139
  134. package/src/error.ts +0 -31
  135. package/src/evaluator.ts +0 -314
  136. package/src/eventManager.ts +0 -53
  137. package/src/eventSubjectProcessor.ts +0 -85
  138. package/src/facade/contentFetcherFacade.ts +0 -69
  139. package/src/facade/evaluatorFacade.ts +0 -111
  140. package/src/facade/index.ts +0 -7
  141. package/src/facade/sdkFacade.ts +0 -310
  142. package/src/facade/sessionFacade.ts +0 -14
  143. package/src/facade/sessionPatch.ts +0 -32
  144. package/src/facade/trackerFacade.ts +0 -98
  145. package/src/facade/userFacade.ts +0 -26
  146. package/src/facade/userPatch.ts +0 -32
  147. package/src/help.ts +0 -24
  148. package/src/index.ts +0 -4
  149. package/src/logging/consoleLogger.ts +0 -38
  150. package/src/logging/filteredLogger.ts +0 -57
  151. package/src/logging/index.ts +0 -5
  152. package/src/logging/logger.ts +0 -13
  153. package/src/logging/namespacedLogger.ts +0 -32
  154. package/src/logging/nullLogger.ts +0 -19
  155. package/src/namespacedStorage.ts +0 -69
  156. package/src/patch.ts +0 -64
  157. package/src/queue/capacityRestrictedQueue.ts +0 -44
  158. package/src/queue/inMemoryQueue.ts +0 -43
  159. package/src/queue/index.ts +0 -5
  160. package/src/queue/monitoredQueue.ts +0 -168
  161. package/src/queue/persistentQueue.ts +0 -73
  162. package/src/queue/queue.ts +0 -15
  163. package/src/retry/arbitraryPolicy.ts +0 -21
  164. package/src/retry/backoffPolicy.ts +0 -84
  165. package/src/retry/index.ts +0 -5
  166. package/src/retry/maxAttemptsPolicy.ts +0 -28
  167. package/src/retry/neverPolicy.ts +0 -11
  168. package/src/retry/policy.ts +0 -5
  169. package/src/schema/attributeSchema.ts +0 -6
  170. package/src/schema/contentFetcherSchemas.ts +0 -23
  171. package/src/schema/contentSchemas.ts +0 -44
  172. package/src/schema/contextSchemas.ts +0 -5
  173. package/src/schema/ecommerceSchemas.ts +0 -179
  174. package/src/schema/evaluatorSchemas.ts +0 -52
  175. package/src/schema/eventSchemas.ts +0 -134
  176. package/src/schema/index.ts +0 -11
  177. package/src/schema/loggerSchema.ts +0 -12
  178. package/src/schema/operationSchemas.ts +0 -102
  179. package/src/schema/sdkFacadeSchemas.ts +0 -64
  180. package/src/schema/sdkSchemas.ts +0 -82
  181. package/src/schema/tokenSchema.ts +0 -42
  182. package/src/schema/userSchema.ts +0 -184
  183. package/src/sdk.ts +0 -183
  184. package/src/sdkEvents.ts +0 -15
  185. package/src/sourceLocation.ts +0 -85
  186. package/src/tab.ts +0 -148
  187. package/src/token/cachedTokenStore.ts +0 -34
  188. package/src/token/inMemoryTokenStore.ts +0 -13
  189. package/src/token/index.ts +0 -4
  190. package/src/token/replicatedTokenStore.ts +0 -21
  191. package/src/token/token.ts +0 -301
  192. package/src/tracker.ts +0 -504
  193. package/src/trackingEvents.ts +0 -452
  194. package/src/transformer.ts +0 -7
  195. package/src/utilityTypes.ts +0 -3
  196. package/src/uuid.ts +0 -43
  197. package/src/validation/arrayType.ts +0 -71
  198. package/src/validation/booleanType.ts +0 -22
  199. package/src/validation/functionType.ts +0 -22
  200. package/src/validation/index.ts +0 -12
  201. package/src/validation/jsonType.ts +0 -156
  202. package/src/validation/mixedSchema.ts +0 -7
  203. package/src/validation/nullType.ts +0 -22
  204. package/src/validation/numberType.ts +0 -59
  205. package/src/validation/objectType.ts +0 -138
  206. package/src/validation/schema.ts +0 -21
  207. package/src/validation/stringType.ts +0 -118
  208. package/src/validation/unionType.ts +0 -53
  209. package/src/validation/violation.ts +0 -23
@@ -1,84 +0,0 @@
1
- import {RetryPolicy} from './policy';
2
-
3
- type Options = {
4
- minRetryDelay: number, // min retry delay in ms (used in exp. backoff calcs)
5
- maxRetryDelay: number, // max retry delay in ms (used in exp. backoff calcs)
6
- backoffFactor: number, // exponential backoff factor (attempts^n)
7
- backoffJitter: number, // jitter factor for backoff calcs (0 is usually fine)
8
- maxAttempts: number,
9
- };
10
-
11
- export class BackoffPolicy<T> implements RetryPolicy<T> {
12
- private readonly minRetryDelay: number = 1000;
13
-
14
- private readonly maxRetryDelay: number = 30000;
15
-
16
- private readonly backoffFactor: number = 2;
17
-
18
- private readonly backoffJitter: number = 1;
19
-
20
- private readonly maxAttempts: number = Infinity;
21
-
22
- public constructor(options: Partial<Options> = {}) {
23
- const {
24
- minRetryDelay = this.minRetryDelay,
25
- maxRetryDelay = this.maxRetryDelay,
26
- backoffFactor = this.backoffFactor,
27
- backoffJitter = this.backoffJitter,
28
- maxAttempts = this.maxAttempts,
29
- } = options;
30
-
31
- if (minRetryDelay < 0) {
32
- throw new Error('The minimum retry delay must be non-negative.');
33
- }
34
-
35
- if (maxRetryDelay < minRetryDelay) {
36
- throw new Error('The maximum retry delay must be greater than the minimum.');
37
- }
38
-
39
- if (backoffFactor < 1) {
40
- throw new Error('The backoff factor must be greater than zero.');
41
- }
42
-
43
- if (backoffJitter < 0) {
44
- throw new Error('The backoff jitter must be non-negative.');
45
- }
46
-
47
- if (maxAttempts < 0) {
48
- throw new Error('The maximum attempts must be non-negative.');
49
- }
50
-
51
- this.minRetryDelay = minRetryDelay;
52
- this.maxRetryDelay = maxRetryDelay;
53
- this.backoffFactor = backoffFactor;
54
- this.backoffJitter = backoffJitter;
55
- this.maxAttempts = maxAttempts;
56
- }
57
-
58
- /**
59
- * Full Jitter algorithm
60
- *
61
- * @see https://www.awsarchitectureblog.com/2015/03/backoff.html
62
- */
63
- public getDelay(attempt: number): number {
64
- let delay = Math.min(Math.max(this.backoffFactor ** attempt, this.minRetryDelay), this.maxRetryDelay);
65
-
66
- if (this.backoffJitter > 0) {
67
- // Jitter will result in a random value between the minimum and
68
- // calculated delay for a given attempt.
69
- const min = Math.ceil(this.minRetryDelay);
70
- const max = Math.floor(delay);
71
-
72
- delay = Math.floor(Math.random() * (max - min + 1)) + min;
73
- }
74
-
75
- // Removing any fractional digits
76
- delay -= delay % 1;
77
-
78
- return delay;
79
- }
80
-
81
- public shouldRetry(attempt: number): boolean {
82
- return attempt < this.maxAttempts;
83
- }
84
- }
@@ -1,5 +0,0 @@
1
- export * from './policy';
2
- export {ArbitraryPolicy} from './arbitraryPolicy';
3
- export {BackoffPolicy} from './backoffPolicy';
4
- export {MaxAttemptsPolicy} from './maxAttemptsPolicy';
5
- export {NeverPolicy} from './neverPolicy';
@@ -1,28 +0,0 @@
1
- import {RetryPolicy} from './policy';
2
-
3
- export class MaxAttemptsPolicy<T> implements RetryPolicy<T> {
4
- private readonly maxAttempts: number;
5
-
6
- private readonly delay: number;
7
-
8
- public constructor(delay: number, maxAttempts: number) {
9
- if (delay < 0) {
10
- throw new Error('Delay must be non-negative.');
11
- }
12
-
13
- if (maxAttempts < 0) {
14
- throw new Error('Max attempts must be non-negative.');
15
- }
16
-
17
- this.maxAttempts = maxAttempts;
18
- this.delay = delay;
19
- }
20
-
21
- public getDelay(): number {
22
- return this.delay;
23
- }
24
-
25
- public shouldRetry(attempt: number): boolean {
26
- return attempt < this.maxAttempts;
27
- }
28
- }
@@ -1,11 +0,0 @@
1
- import {RetryPolicy} from './policy';
2
-
3
- export class NeverPolicy<T> implements RetryPolicy<T> {
4
- public getDelay(): number {
5
- return Infinity;
6
- }
7
-
8
- public shouldRetry(): boolean {
9
- return false;
10
- }
11
- }
@@ -1,5 +0,0 @@
1
- export interface RetryPolicy<T> {
2
- shouldRetry(attempt: number, subject?: T, failure?: any): boolean;
3
-
4
- getDelay(attempt: number): number;
5
- }
@@ -1,6 +0,0 @@
1
- import {StringType} from '../validation';
2
-
3
- export const attributeNameSchema = new StringType({
4
- maxLength: 50,
5
- format: 'identifier',
6
- });
@@ -1,23 +0,0 @@
1
- import {ObjectType, NumberType, JsonObjectType, StringType, UnionType} from '../validation';
2
-
3
- export const fetchOptionsSchema = new ObjectType({
4
- properties: {
5
- timeout: new NumberType({
6
- integer: true,
7
- minimum: 0,
8
- }),
9
- version: new UnionType(
10
- new StringType({
11
- pattern: /^\d+$/,
12
- }),
13
- new NumberType({
14
- integer: true,
15
- minimum: 1,
16
- }),
17
- ),
18
- preferredLocale: new StringType({
19
- pattern: /^[a-z]{2,3}([-_][a-z]{2,3})?$/i,
20
- }),
21
- attributes: new JsonObjectType(),
22
- },
23
- });
@@ -1,44 +0,0 @@
1
- import {ArrayType, StringType, ObjectType, NumberType} from '../validation';
2
-
3
- export const postDetails = new ObjectType({
4
- required: ['postId', 'title', 'publishTime'],
5
- properties: {
6
- postId: new StringType({
7
- minLength: 1,
8
- maxLength: 200,
9
- }),
10
- url: new StringType({
11
- format: 'url',
12
- }),
13
- title: new StringType({
14
- minLength: 1,
15
- maxLength: 200,
16
- }),
17
- tags: new ArrayType({
18
- items: new StringType({
19
- minLength: 1,
20
- maxLength: 50,
21
- }),
22
- minItems: 1,
23
- maxItems: 10,
24
- }),
25
- categories: new ArrayType({
26
- items: new StringType({
27
- minLength: 1,
28
- maxLength: 50,
29
- }),
30
- minItems: 1,
31
- maxItems: 10,
32
- }),
33
- authors: new ArrayType({
34
- items: new StringType({
35
- minLength: 1,
36
- maxLength: 50,
37
- }),
38
- minItems: 1,
39
- maxItems: 10,
40
- }),
41
- publishTime: new NumberType(),
42
- updateTime: new NumberType(),
43
- },
44
- });
@@ -1,5 +0,0 @@
1
- import {StringType} from '../validation';
2
-
3
- export const tokenScopeSchema = new StringType({
4
- enumeration: ['global', 'contextual', 'isolated'],
5
- });
@@ -1,179 +0,0 @@
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
- });
@@ -1,52 +0,0 @@
1
- import {
2
- ObjectType,
3
- NumberType,
4
- JsonObjectType,
5
- UnionType,
6
- StringType,
7
- NullType,
8
- BooleanType,
9
- TypeSchema,
10
- ArrayType,
11
- } from '../validation';
12
-
13
- function createJsonSchema(maximumDepth: number): TypeSchema {
14
- return new UnionType(
15
- new NullType(),
16
- new NumberType(),
17
- new BooleanType(),
18
- new StringType({maxLength: 255}),
19
- ...(maximumDepth > 1
20
- ? [
21
- new JsonObjectType({
22
- propertyNames: new UnionType(
23
- new NumberType(),
24
- new StringType({
25
- minLength: 1,
26
- maxLength: 50,
27
- }),
28
- ),
29
- properties: createJsonSchema(maximumDepth - 1),
30
- }),
31
- new ArrayType({items: createJsonSchema(maximumDepth - 1)}),
32
- ]
33
- : []
34
- ),
35
- );
36
- }
37
-
38
- export const evaluationOptionsSchema = new ObjectType({
39
- properties: {
40
- timeout: new NumberType({
41
- integer: true,
42
- minimum: 0,
43
- }),
44
- attributes: new JsonObjectType({
45
- propertyNames: new StringType({
46
- minLength: 1,
47
- maxLength: 50,
48
- }),
49
- properties: createJsonSchema(5),
50
- }),
51
- },
52
- });
@@ -1,134 +0,0 @@
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
- details: new ObjectType({
118
- additionalProperties: new UnionType(
119
- new NullType(),
120
- new BooleanType(),
121
- new NumberType(),
122
- new StringType({
123
- maxLength: 300,
124
- }),
125
- ),
126
- propertyNames: new StringType({
127
- minLength: 1,
128
- maxLength: 20,
129
- format: 'identifier',
130
- }),
131
- maxProperties: 10,
132
- }),
133
- },
134
- });
@@ -1,11 +0,0 @@
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';
@@ -1,12 +0,0 @@
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
- });