@croct/sdk 0.11.0-alpha → 0.11.0-alpha.2
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/activeRecord.js +1 -0
- package/activeRecord.js.map +1 -0
- package/base64Url.js +1 -0
- package/base64Url.js.map +1 -0
- package/cache/cache.js +1 -0
- package/cache/cache.js.map +1 -0
- package/cache/fallbackCache.js +1 -0
- package/cache/fallbackCache.js.map +1 -0
- package/cache/inMemoryCache.js +1 -0
- package/cache/inMemoryCache.js.map +1 -0
- package/cache/index.js +1 -0
- package/cache/index.js.map +1 -0
- package/cache/localStorageCache.js +1 -0
- package/cache/localStorageCache.js.map +1 -0
- package/channel/beaconSocketChannel.js +1 -0
- package/channel/beaconSocketChannel.js.map +1 -0
- package/channel/channel.js +1 -0
- package/channel/channel.js.map +1 -0
- package/channel/encodedChannel.js +1 -0
- package/channel/encodedChannel.js.map +1 -0
- package/channel/guaranteedChannel.js +1 -0
- package/channel/guaranteedChannel.js.map +1 -0
- package/channel/index.js +1 -0
- package/channel/index.js.map +1 -0
- package/channel/queuedChannel.js +1 -0
- package/channel/queuedChannel.js.map +1 -0
- package/channel/retryChannel.js +1 -0
- package/channel/retryChannel.js.map +1 -0
- package/channel/sandboxChannel.js +1 -0
- package/channel/sandboxChannel.js.map +1 -0
- package/channel/socketChannel.js +1 -0
- package/channel/socketChannel.js.map +1 -0
- package/cid/assigner.js +1 -0
- package/cid/assigner.js.map +1 -0
- package/cid/cachedAssigner.js +1 -0
- package/cid/cachedAssigner.js.map +1 -0
- package/cid/fixedAssigner.js +1 -0
- package/cid/fixedAssigner.js.map +1 -0
- package/cid/index.js +1 -0
- package/cid/index.js.map +1 -0
- package/cid/remoteAssigner.js +1 -0
- package/cid/remoteAssigner.js.map +1 -0
- package/constants.d.ts +5 -5
- package/constants.js +2 -1
- package/constants.js.map +1 -0
- package/container.js +1 -0
- package/container.js.map +1 -0
- package/contentFetcher.js +1 -0
- package/contentFetcher.js.map +1 -0
- package/context.js +1 -0
- package/context.js.map +1 -0
- package/error.js +1 -0
- package/error.js.map +1 -0
- package/evaluator.js +1 -0
- package/evaluator.js.map +1 -0
- package/eventManager.js +1 -0
- package/eventManager.js.map +1 -0
- package/facade/contentFetcherFacade.js +1 -0
- package/facade/contentFetcherFacade.js.map +1 -0
- package/facade/evaluatorFacade.js +1 -0
- package/facade/evaluatorFacade.js.map +1 -0
- package/facade/index.js +1 -0
- package/facade/index.js.map +1 -0
- package/facade/sdkFacade.js +1 -0
- package/facade/sdkFacade.js.map +1 -0
- package/facade/sessionFacade.js +1 -0
- package/facade/sessionFacade.js.map +1 -0
- package/facade/sessionPatch.js +1 -0
- package/facade/sessionPatch.js.map +1 -0
- package/facade/trackerFacade.js +1 -0
- package/facade/trackerFacade.js.map +1 -0
- package/facade/userFacade.js +1 -0
- package/facade/userFacade.js.map +1 -0
- package/facade/userPatch.js +1 -0
- package/facade/userPatch.js.map +1 -0
- package/index.js +1 -0
- package/index.js.map +1 -0
- package/logging/consoleLogger.js +1 -0
- package/logging/consoleLogger.js.map +1 -0
- package/logging/index.js +1 -0
- package/logging/index.js.map +1 -0
- package/logging/logger.js +1 -0
- package/logging/logger.js.map +1 -0
- package/logging/namespacedLogger.js +1 -0
- package/logging/namespacedLogger.js.map +1 -0
- package/logging/nullLogger.js +1 -0
- package/logging/nullLogger.js.map +1 -0
- package/namespacedStorage.js +1 -0
- package/namespacedStorage.js.map +1 -0
- package/package.json +3 -2
- package/patch.js +1 -0
- package/patch.js.map +1 -0
- package/queue/capacityRestrictedQueue.js +1 -0
- package/queue/capacityRestrictedQueue.js.map +1 -0
- package/queue/inMemoryQueue.js +1 -0
- package/queue/inMemoryQueue.js.map +1 -0
- package/queue/index.js +1 -0
- package/queue/index.js.map +1 -0
- package/queue/monitoredQueue.js +1 -0
- package/queue/monitoredQueue.js.map +1 -0
- package/queue/persistentQueue.js +1 -0
- package/queue/persistentQueue.js.map +1 -0
- package/queue/queue.js +1 -0
- package/queue/queue.js.map +1 -0
- package/retry/arbitraryPolicy.js +1 -0
- package/retry/arbitraryPolicy.js.map +1 -0
- package/retry/backoffPolicy.js +1 -0
- package/retry/backoffPolicy.js.map +1 -0
- package/retry/index.js +1 -0
- package/retry/index.js.map +1 -0
- package/retry/maxAttemptsPolicy.js +1 -0
- package/retry/maxAttemptsPolicy.js.map +1 -0
- package/retry/neverPolicy.js +1 -0
- package/retry/neverPolicy.js.map +1 -0
- package/retry/policy.js +1 -0
- package/retry/policy.js.map +1 -0
- package/schema/attributeSchema.js +1 -0
- package/schema/attributeSchema.js.map +1 -0
- package/schema/contentFetcherSchemas.js +1 -0
- package/schema/contentFetcherSchemas.js.map +1 -0
- package/schema/contentSchemas.js +1 -0
- package/schema/contentSchemas.js.map +1 -0
- package/schema/contextSchemas.js +1 -0
- package/schema/contextSchemas.js.map +1 -0
- package/schema/ecommerceSchemas.js +1 -0
- package/schema/ecommerceSchemas.js.map +1 -0
- package/schema/evaluatorSchemas.js +1 -0
- package/schema/evaluatorSchemas.js.map +1 -0
- package/schema/eventSchemas.js +1 -0
- package/schema/eventSchemas.js.map +1 -0
- package/schema/index.js +1 -0
- package/schema/index.js.map +1 -0
- package/schema/loggerSchema.js +1 -0
- package/schema/loggerSchema.js.map +1 -0
- package/schema/operationSchemas.js +1 -0
- package/schema/operationSchemas.js.map +1 -0
- package/schema/sdkFacadeSchemas.js +1 -0
- package/schema/sdkFacadeSchemas.js.map +1 -0
- package/schema/sdkSchemas.js +1 -0
- package/schema/sdkSchemas.js.map +1 -0
- package/schema/tokenSchema.js +1 -0
- package/schema/tokenSchema.js.map +1 -0
- package/schema/userSchema.js +1 -0
- package/schema/userSchema.js.map +1 -0
- package/sdk.js +1 -0
- package/sdk.js.map +1 -0
- package/sdkEvents.js +1 -0
- package/sdkEvents.js.map +1 -0
- package/sourceLocation.js +1 -0
- package/sourceLocation.js.map +1 -0
- 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/tab.js +1 -0
- package/tab.js.map +1 -0
- package/token/cachedTokenStore.js +1 -0
- package/token/cachedTokenStore.js.map +1 -0
- package/token/inMemoryTokenStore.js +1 -0
- package/token/inMemoryTokenStore.js.map +1 -0
- package/token/index.js +1 -0
- package/token/index.js.map +1 -0
- package/token/replicatedTokenStore.js +1 -0
- package/token/replicatedTokenStore.js.map +1 -0
- package/token/token.js +1 -0
- package/token/token.js.map +1 -0
- package/tracker.js +1 -0
- package/tracker.js.map +1 -0
- package/trackingEvents.js +1 -0
- package/trackingEvents.js.map +1 -0
- package/transformer.js +1 -0
- package/transformer.js.map +1 -0
- package/utilityTypes.js +1 -0
- package/utilityTypes.js.map +1 -0
- package/uuid.js +1 -0
- package/uuid.js.map +1 -0
- package/validation/arrayType.js +1 -0
- package/validation/arrayType.js.map +1 -0
- package/validation/booleanType.js +1 -0
- package/validation/booleanType.js.map +1 -0
- package/validation/functionType.js +1 -0
- package/validation/functionType.js.map +1 -0
- package/validation/index.js +1 -0
- package/validation/index.js.map +1 -0
- package/validation/jsonType.js +1 -0
- package/validation/jsonType.js.map +1 -0
- package/validation/mixedSchema.js +1 -0
- package/validation/mixedSchema.js.map +1 -0
- package/validation/nullType.js +1 -0
- package/validation/nullType.js.map +1 -0
- package/validation/numberType.js +1 -0
- package/validation/numberType.js.map +1 -0
- package/validation/objectType.js +1 -0
- package/validation/objectType.js.map +1 -0
- package/validation/schema.js +1 -0
- package/validation/schema.js.map +1 -0
- package/validation/stringType.js +1 -0
- package/validation/stringType.js.map +1 -0
- package/validation/unionType.js +1 -0
- package/validation/unionType.js.map +1 -0
- package/validation/violation.js +1 -0
- package/validation/violation.js.map +1 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-use-before-define -- Mutual dependency */
|
|
2
|
+
import {JsonArray, JsonObject, JsonPrimitive, JsonValue} from '@croct/json';
|
|
3
|
+
import {Schema, TypeSchema, Violation} from './schema';
|
|
4
|
+
import {describe, formatPath} from './violation';
|
|
5
|
+
|
|
6
|
+
function isJsonPrimitive(value: unknown): value is JsonPrimitive {
|
|
7
|
+
return value === null || typeof value === 'string' || typeof value === 'boolean' || typeof value === 'number';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function isPlainObject(value: unknown): value is object {
|
|
11
|
+
return Object.prototype
|
|
12
|
+
.toString
|
|
13
|
+
.call(value) === '[object Object]';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function isJsonArray(value: unknown): value is JsonArray {
|
|
17
|
+
return Array.isArray(value) && value.every(isJsonValue);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function isJsonObject(value: unknown): value is JsonObject {
|
|
21
|
+
return isPlainObject(value) && Object.values(value).every(isJsonValue);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function isJsonValue(value: unknown): value is JsonValue {
|
|
25
|
+
return isJsonPrimitive(value) || isJsonArray(value) || isJsonObject(value);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
type JsonObjectDefinition = {
|
|
29
|
+
properties?: Schema,
|
|
30
|
+
propertyNames?: Schema,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export class JsonObjectType implements TypeSchema {
|
|
34
|
+
private readonly definition: JsonObjectDefinition;
|
|
35
|
+
|
|
36
|
+
public constructor(definition: JsonObjectDefinition = {}) {
|
|
37
|
+
this.definition = definition;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public getTypes(): string[] {
|
|
41
|
+
return ['object'];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public isValidType(value: unknown): boolean {
|
|
45
|
+
return isPlainObject(value);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public validate(value: unknown, path: string[] = []): void {
|
|
49
|
+
if (!isJsonObject(value)) {
|
|
50
|
+
throw new Violation(
|
|
51
|
+
`Expected a JSON object at path '${formatPath(path)}', actual ${describe(value)}.`,
|
|
52
|
+
path,
|
|
53
|
+
{type: 'object'},
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (this.definition.properties === undefined && this.definition.propertyNames === undefined) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
for (const [entryName, entryValue] of Object.entries(value)) {
|
|
62
|
+
const propertyPath = path.concat([entryName]);
|
|
63
|
+
|
|
64
|
+
if (this.definition.propertyNames !== undefined) {
|
|
65
|
+
this.definition
|
|
66
|
+
.propertyNames
|
|
67
|
+
.validate(entryName, propertyPath);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (this.definition.properties !== undefined) {
|
|
71
|
+
this.definition
|
|
72
|
+
.properties
|
|
73
|
+
.validate(entryValue, path.concat([entryName]));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
type JsonArrayDefinition = {
|
|
80
|
+
items?: Schema,
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export class JsonArrayType implements TypeSchema {
|
|
84
|
+
private readonly definition: JsonArrayDefinition;
|
|
85
|
+
|
|
86
|
+
public constructor(definition: JsonArrayDefinition = {}) {
|
|
87
|
+
this.definition = definition;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
public getTypes(): string[] {
|
|
91
|
+
return ['array'];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
public isValidType(value: unknown): boolean {
|
|
95
|
+
return Array.isArray(value);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
public validate(value: unknown, path: string[] = []): void {
|
|
99
|
+
if (!isJsonArray(value)) {
|
|
100
|
+
throw new Violation(
|
|
101
|
+
`Expected a JSON array at path '${formatPath(path)}', actual ${describe(value)}.`,
|
|
102
|
+
path,
|
|
103
|
+
{type: 'array'},
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (this.definition.items === undefined) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
for (let index = 0; index < value.length; index++) {
|
|
112
|
+
this.definition
|
|
113
|
+
.items
|
|
114
|
+
.validate(value[index], path.concat([index.toString()]));
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export class JsonPrimitiveType implements TypeSchema {
|
|
120
|
+
public getTypes(): string[] {
|
|
121
|
+
return ['null', 'number', 'string', 'boolean'];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
public isValidType(value: unknown): boolean {
|
|
125
|
+
return isJsonPrimitive(value);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
public validate(value: unknown, path: string[] = []): void {
|
|
129
|
+
if (!this.isValidType(value)) {
|
|
130
|
+
throw new Violation(
|
|
131
|
+
`Expected a JSON primitive at path '${formatPath(path)}', actual ${describe(value)}.`,
|
|
132
|
+
path,
|
|
133
|
+
{type: this.getTypes().join('|')},
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export class JsonType implements TypeSchema {
|
|
140
|
+
public getTypes(): string[] {
|
|
141
|
+
return ['null', 'number', 'string', 'boolean', 'array', 'object'];
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
public isValidType(value: unknown): boolean {
|
|
145
|
+
return isJsonPrimitive(value) || Array.isArray(value) || isPlainObject(value);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
public validate(value: unknown, path: string[] = []): void {
|
|
149
|
+
if (!isJsonValue(value)) {
|
|
150
|
+
throw new Violation(
|
|
151
|
+
`Expected a JSON value at path '${formatPath(path)}', actual ${describe(value)}.`,
|
|
152
|
+
path,
|
|
153
|
+
{type: this.getTypes().join('|')},
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {TypeSchema, Violation} from './schema';
|
|
2
|
+
import {describe, formatPath} from './violation';
|
|
3
|
+
|
|
4
|
+
export class NullType implements TypeSchema {
|
|
5
|
+
public getTypes(): string[] {
|
|
6
|
+
return ['null'];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
public isValidType(value: unknown): value is null {
|
|
10
|
+
return value === null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
public validate(value: unknown, path: string[] = []): void {
|
|
14
|
+
if (!this.isValidType(value)) {
|
|
15
|
+
throw new Violation(
|
|
16
|
+
`Expected value of type null at path '${formatPath(path)}', actual ${describe(value)}.`,
|
|
17
|
+
path,
|
|
18
|
+
{type: 'null'},
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {TypeSchema, Violation} from './schema';
|
|
2
|
+
import {describe, formatPath} from './violation';
|
|
3
|
+
|
|
4
|
+
type NumberDefinition = {
|
|
5
|
+
integer: boolean,
|
|
6
|
+
minimum: number,
|
|
7
|
+
maximum: number,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export class NumberType implements TypeSchema {
|
|
11
|
+
private readonly definition: NumberDefinition;
|
|
12
|
+
|
|
13
|
+
public constructor(definition: Partial<NumberDefinition> = {}) {
|
|
14
|
+
this.definition = {
|
|
15
|
+
...definition,
|
|
16
|
+
integer: definition.integer ?? false,
|
|
17
|
+
minimum: definition.minimum ?? Number.NEGATIVE_INFINITY,
|
|
18
|
+
maximum: definition.maximum ?? Number.POSITIVE_INFINITY,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public getTypes(): string[] {
|
|
23
|
+
return [this.definition.integer ? 'integer' : 'number'];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public isValidType(value: unknown): value is number {
|
|
27
|
+
return typeof value === 'number' && (!this.definition.integer || Number.isInteger(value));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public validate(value: unknown, path: string[] = []): void {
|
|
31
|
+
if (!this.isValidType(value)) {
|
|
32
|
+
const type = this.getTypes()[0];
|
|
33
|
+
|
|
34
|
+
throw new Violation(
|
|
35
|
+
`Expected value of type ${type} at path '${formatPath(path)}', actual ${describe(value)}.`,
|
|
36
|
+
path,
|
|
37
|
+
{type: type},
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (value < this.definition.minimum) {
|
|
42
|
+
throw new Violation(
|
|
43
|
+
`Expected a value greater than or equal to ${this.definition.minimum} `
|
|
44
|
+
+ `at path '${formatPath(path)}', actual ${value}.`,
|
|
45
|
+
path,
|
|
46
|
+
{limit: this.definition.minimum},
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (value > this.definition.maximum) {
|
|
51
|
+
throw new Violation(
|
|
52
|
+
`Expected a value less than or equal to ${this.definition.maximum} `
|
|
53
|
+
+ `at path '${formatPath(path)}', actual ${value}.`,
|
|
54
|
+
path,
|
|
55
|
+
{limit: this.definition.maximum},
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import {Schema, TypeSchema, Violation} from './schema';
|
|
2
|
+
import {MixedSchema} from './mixedSchema';
|
|
3
|
+
import {describe, formatPath} from './violation';
|
|
4
|
+
|
|
5
|
+
type ObjectDefinition = {
|
|
6
|
+
type?: {new (...args: any): any},
|
|
7
|
+
properties: {[key: string]: Schema},
|
|
8
|
+
additionalProperties: boolean | Schema,
|
|
9
|
+
subtypes?: {
|
|
10
|
+
discriminator: string,
|
|
11
|
+
schemas: {[key: string]: ObjectType},
|
|
12
|
+
},
|
|
13
|
+
propertyNames: Schema,
|
|
14
|
+
required: string[],
|
|
15
|
+
minProperties: number,
|
|
16
|
+
maxProperties: number,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export class ObjectType implements TypeSchema {
|
|
20
|
+
private readonly definition: ObjectDefinition;
|
|
21
|
+
|
|
22
|
+
public constructor(schema: Partial<ObjectDefinition> = {}) {
|
|
23
|
+
this.definition = {
|
|
24
|
+
...schema,
|
|
25
|
+
properties: schema.properties ?? {},
|
|
26
|
+
required: schema.required ?? [],
|
|
27
|
+
additionalProperties: schema.additionalProperties ?? false,
|
|
28
|
+
propertyNames: schema.propertyNames ?? new MixedSchema(),
|
|
29
|
+
minProperties: schema.minProperties ?? -1,
|
|
30
|
+
maxProperties: schema.maxProperties ?? -1,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public getTypes(): string[] {
|
|
35
|
+
if (this.definition.type !== undefined) {
|
|
36
|
+
return [this.definition.type.name];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return ['object'];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public isValidType(value: unknown): value is object {
|
|
43
|
+
if (this.definition.type !== undefined) {
|
|
44
|
+
return value instanceof this.definition.type;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return Object.prototype
|
|
48
|
+
.toString
|
|
49
|
+
.call(value) === '[object Object]';
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public validate(value: unknown, path: string[] = []): void {
|
|
53
|
+
if (!this.isValidType(value)) {
|
|
54
|
+
const [type] = this.getTypes();
|
|
55
|
+
|
|
56
|
+
throw new Violation(
|
|
57
|
+
`Expected value of type ${type} at path '${formatPath(path)}', `
|
|
58
|
+
+ `actual ${describe(value)}.`,
|
|
59
|
+
path,
|
|
60
|
+
{type: type},
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const entries = Object.entries(value);
|
|
65
|
+
|
|
66
|
+
const {minProperties, maxProperties} = this.definition;
|
|
67
|
+
|
|
68
|
+
if (minProperties >= 0 && minProperties > entries.length) {
|
|
69
|
+
throw new Violation(
|
|
70
|
+
`Expected ${minProperties === maxProperties ? 'exactly' : 'at least'} `
|
|
71
|
+
+ `${minProperties} ${minProperties === 1 ? 'entry' : 'entries'} `
|
|
72
|
+
+ `at path '${formatPath(path)}', actual ${entries.length}.`,
|
|
73
|
+
path,
|
|
74
|
+
{limit: minProperties},
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (maxProperties >= 0 && maxProperties < entries.length) {
|
|
79
|
+
throw new Violation(
|
|
80
|
+
`Expected ${minProperties === maxProperties ? 'exactly' : 'at most'} `
|
|
81
|
+
+ `${maxProperties} ${maxProperties === 1 ? 'entry' : 'entries'} `
|
|
82
|
+
+ `at path '${formatPath(path)}', actual ${entries.length}.`,
|
|
83
|
+
path,
|
|
84
|
+
{limit: maxProperties},
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const additionalProperties: {[key: string]: any} = {...value};
|
|
89
|
+
|
|
90
|
+
for (const property of this.definition.required) {
|
|
91
|
+
if (!(property in value)) {
|
|
92
|
+
throw new Violation(`Missing property '${formatPath(path.concat([property]))}'.`, path, {
|
|
93
|
+
required: property,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
for (const [entryName, entryValue] of entries) {
|
|
99
|
+
const propertyPath = path.concat([entryName]);
|
|
100
|
+
|
|
101
|
+
this.definition
|
|
102
|
+
.propertyNames
|
|
103
|
+
.validate(entryName, propertyPath);
|
|
104
|
+
|
|
105
|
+
const propertyRule = this.definition.properties[entryName];
|
|
106
|
+
|
|
107
|
+
if (propertyRule !== undefined) {
|
|
108
|
+
propertyRule.validate(entryValue, propertyPath);
|
|
109
|
+
|
|
110
|
+
delete additionalProperties[entryName];
|
|
111
|
+
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (this.definition.additionalProperties === false) {
|
|
116
|
+
throw new Violation(`Unknown property '${formatPath(propertyPath)}'.`, propertyPath, {
|
|
117
|
+
additionalProperty: entryName,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (this.definition.additionalProperties !== true) {
|
|
122
|
+
this.definition
|
|
123
|
+
.additionalProperties
|
|
124
|
+
.validate(entryValue, propertyPath);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const {subtypes} = this.definition;
|
|
129
|
+
|
|
130
|
+
if (subtypes !== undefined) {
|
|
131
|
+
const type = (value as any)[subtypes.discriminator];
|
|
132
|
+
|
|
133
|
+
if (type !== undefined && subtypes.schemas[type] !== undefined) {
|
|
134
|
+
subtypes.schemas[type].validate(additionalProperties, path);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface Schema {
|
|
2
|
+
validate(value: unknown, path?: string[]): void;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export interface TypeSchema extends Schema {
|
|
6
|
+
getTypes(): string[];
|
|
7
|
+
|
|
8
|
+
isValidType(value: unknown): boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class Violation extends Error {
|
|
12
|
+
public readonly path: string[];
|
|
13
|
+
|
|
14
|
+
public readonly params: {[key: string]: unknown};
|
|
15
|
+
|
|
16
|
+
public constructor(message: string, path: string[], params: {[p: string]: unknown}) {
|
|
17
|
+
super(message);
|
|
18
|
+
this.path = path;
|
|
19
|
+
this.params = params;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import {TypeSchema, Violation} from './schema';
|
|
2
|
+
import {describe, formatPath} from './violation';
|
|
3
|
+
|
|
4
|
+
interface Format {
|
|
5
|
+
(value: string): boolean;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const FORMAT: {[key: string]: Format} = {
|
|
9
|
+
pointer: function pointer(value: string): boolean {
|
|
10
|
+
return /^(\.|([a-zA-Z_][a-zA-Z0-9_]*|\[[0-9]+])(\.[a-zA-Z_][a-zA-Z0-9_]*|\[[0-9]+])*)$/.test(value);
|
|
11
|
+
},
|
|
12
|
+
identifier: function identifier(value: string): boolean {
|
|
13
|
+
return /^[a-zA-Z_][a-zA-Z0-9_]*$/.test(value);
|
|
14
|
+
},
|
|
15
|
+
uuid: function uuid(value: string): boolean {
|
|
16
|
+
return /^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/.test(value);
|
|
17
|
+
},
|
|
18
|
+
date: function date(value: string): boolean {
|
|
19
|
+
return /^(\d\d\d\d)-(\d\d)-(\d\d)$/.test(value);
|
|
20
|
+
},
|
|
21
|
+
url: function url(value: string): boolean {
|
|
22
|
+
try {
|
|
23
|
+
// eslint-disable-next-line no-new -- Easier way to validate a URL
|
|
24
|
+
new URL(value);
|
|
25
|
+
} catch {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return true;
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
type StringDefinition = {
|
|
34
|
+
minLength: number,
|
|
35
|
+
maxLength: number,
|
|
36
|
+
enumeration: string[],
|
|
37
|
+
pattern?: RegExp,
|
|
38
|
+
format?: keyof typeof FORMAT,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export class StringType implements TypeSchema {
|
|
42
|
+
private readonly definition: StringDefinition;
|
|
43
|
+
|
|
44
|
+
public constructor(definition: Partial<StringDefinition> = {}) {
|
|
45
|
+
this.definition = {
|
|
46
|
+
...definition,
|
|
47
|
+
minLength: definition.minLength ?? -1,
|
|
48
|
+
maxLength: definition.maxLength ?? -1,
|
|
49
|
+
enumeration: definition.enumeration ?? [],
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
public getTypes(): string[] {
|
|
54
|
+
return ['string'];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public isValidType(value: unknown): value is string {
|
|
58
|
+
return typeof value === 'string';
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public validate(value: unknown, path: string[] = []): void {
|
|
62
|
+
if (!this.isValidType(value)) {
|
|
63
|
+
throw new Violation(
|
|
64
|
+
`Expected value of type string at path '${formatPath(path)}', actual ${describe(value)}.`,
|
|
65
|
+
path,
|
|
66
|
+
{type: 'string'},
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const {minLength, maxLength} = this.definition;
|
|
71
|
+
|
|
72
|
+
if (minLength >= 0 && minLength > value.length) {
|
|
73
|
+
throw new Violation(
|
|
74
|
+
`Expected ${minLength === maxLength ? 'exactly' : 'at least'} `
|
|
75
|
+
+ `${minLength} ${minLength === 1 ? 'character' : 'characters'} `
|
|
76
|
+
+ `at path '${formatPath(path)}', actual ${value.length}.`,
|
|
77
|
+
path,
|
|
78
|
+
{limit: minLength},
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (maxLength >= 0 && maxLength < value.length) {
|
|
83
|
+
throw new Violation(
|
|
84
|
+
`Expected ${minLength === maxLength ? 'exactly' : 'at most'} `
|
|
85
|
+
+ `${maxLength} ${maxLength === 1 ? 'character' : 'characters'} `
|
|
86
|
+
+ `at path '${formatPath(path)}', actual ${value.length}.`,
|
|
87
|
+
path,
|
|
88
|
+
{limit: maxLength},
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const {enumeration} = this.definition;
|
|
93
|
+
|
|
94
|
+
if (enumeration.length > 0 && enumeration.indexOf(value) < 0) {
|
|
95
|
+
throw new Violation(
|
|
96
|
+
`Unexpected value at path '${formatPath(path)}', expecting `
|
|
97
|
+
+ `'${
|
|
98
|
+
enumeration.length === 1
|
|
99
|
+
? enumeration[0]
|
|
100
|
+
: `${enumeration.slice(0, -1).join('\', \'')}' or '${enumeration.slice(-1)}`
|
|
101
|
+
}', `
|
|
102
|
+
+ `found '${value}'.`,
|
|
103
|
+
path,
|
|
104
|
+
{enumeration: enumeration},
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const {format, pattern} = this.definition;
|
|
109
|
+
|
|
110
|
+
if (format !== undefined && !FORMAT[format](value)) {
|
|
111
|
+
throw new Violation(`Invalid ${format} format at path '${formatPath(path)}'.`, path, {format: format});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (pattern !== undefined && !pattern.test(value)) {
|
|
115
|
+
throw new Violation(`Invalid format at path '${formatPath(path)}'.`, path, {pattern: pattern});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import {TypeSchema, Violation} from './schema';
|
|
2
|
+
import {describe, formatPath} from './violation';
|
|
3
|
+
|
|
4
|
+
export class UnionType implements TypeSchema {
|
|
5
|
+
private readonly schemas: TypeSchema[];
|
|
6
|
+
|
|
7
|
+
public constructor(first: TypeSchema, second: TypeSchema, ...others: TypeSchema[]) {
|
|
8
|
+
this.schemas = [first, second, ...others];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
public getTypes(): string[] {
|
|
12
|
+
const types = [];
|
|
13
|
+
|
|
14
|
+
for (const schema of this.schemas) {
|
|
15
|
+
for (const type of schema.getTypes()) {
|
|
16
|
+
if (types.indexOf(type) < 0) {
|
|
17
|
+
types.push(type);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return types;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public isValidType(value: unknown): boolean {
|
|
26
|
+
for (const schema of this.schemas) {
|
|
27
|
+
if (schema.isValidType(value)) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public validate(value: unknown, path: string[] = []): void {
|
|
36
|
+
for (const schema of this.schemas) {
|
|
37
|
+
if (schema.isValidType(value)) {
|
|
38
|
+
schema.validate(value, path);
|
|
39
|
+
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const types = this.getTypes();
|
|
45
|
+
|
|
46
|
+
throw new Violation(
|
|
47
|
+
`Expected value of type ${types.slice(0, -1).join(', ')} or ${types[types.length - 1]} `
|
|
48
|
+
+ `at path '${formatPath(path)}', actual ${describe(value)}.`,
|
|
49
|
+
path,
|
|
50
|
+
{type: types.join('|')},
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function describe(value: unknown): string {
|
|
2
|
+
if (value === null) {
|
|
3
|
+
return 'null';
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
if (Array.isArray(value)) {
|
|
7
|
+
return 'array';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
if (typeof value === 'number') {
|
|
11
|
+
return Number.isInteger(value) ? 'integer' : 'number';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (typeof value === 'object') {
|
|
15
|
+
return (value as object).constructor.name;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return typeof value;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function formatPath(path: string[]): string {
|
|
22
|
+
return `/${path.join('/')}`;
|
|
23
|
+
}
|
package/tab.js
CHANGED
package/tab.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tab.js","sourceRoot":"","sources":["src/tab.ts"],"names":[],"mappings":";;;AAAA,iDAAsE;AAiBtE,MAAM,QAAQ,GAAuC;IACjD,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,YAAY,EAAE,QAAQ;IACtB,gBAAgB,EAAE,MAAM;IACxB,gBAAgB,EAAE,kBAAkB;CACvC,CAAC;AAEF,MAAa,GAAG;IASZ,YAAmB,EAAU,EAAE,KAAc,EAAE,YAA2B;QAFzD,iBAAY,GAAG,IAAI,sCAAuB,EAAe,CAAC;QAGvE,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,YAAY,GAAG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AC;QAE7C,IAAI,IAAI,KAAK,IAAI,EAAE;YACf,OAAO,IAAI,CAAC;SACf;QAED,IAAI;YACA,OAAO,aAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SAC5B;QAAC,OAAO,KAAK,EAAE;YACZ,OAAO,IAAI,CAAC;SACf;IACL,CAAC;IAEM,QAAQ,CAAC,KAAmB;QAC/B,IAAI,KAAK,KAAK,IAAI,EAAE;YAChB,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YAEnB,OAAO;SACV;QAED,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;IACrC,CAAC;CACJ;AA9BD,4CA8BC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inMemoryTokenStore.js","sourceRoot":"","sources":["../src/token/inMemoryTokenStore.ts"],"names":[],"mappings":";;;AAEA,MAAa,kBAAkB;IAA/B;QACY,UAAK,GAAiB,IAAI,CAAC;IASvC,CAAC;IAPU,QAAQ;QACX,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAEM,QAAQ,CAAC,KAAmB;QAC/B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;CACJ;AAVD,gDAUC"}
|
package/token/index.js
CHANGED
|
@@ -9,3 +9,4 @@ var inMemoryTokenStore_1 = require("./inMemoryTokenStore");
|
|
|
9
9
|
Object.defineProperty(exports, "InMemoryTokenStore", { enumerable: true, get: function () { return inMemoryTokenStore_1.InMemoryTokenStore; } });
|
|
10
10
|
var replicatedTokenStore_1 = require("./replicatedTokenStore");
|
|
11
11
|
Object.defineProperty(exports, "ReplicatedTokenStore", { enumerable: true, get: function () { return replicatedTokenStore_1.ReplicatedTokenStore; } });
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/token/index.ts"],"names":[],"mappings":";;;;AAAA,kDAAwB;AACxB,uDAAoD;AAA5C,oHAAA,gBAAgB,OAAA;AACxB,2DAAwD;AAAhD,wHAAA,kBAAkB,OAAA;AAC1B,+DAA4D;AAApD,4HAAA,oBAAoB,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replicatedTokenStore.js","sourceRoot":"","sources":["../src/token/replicatedTokenStore.ts"],"names":[],"mappings":";;;AAEA,MAAa,oBAAoB;IAK7B,YAAmB,OAAmB,EAAE,SAAqB;QACzD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC/B,CAAC;IAEM,QAAQ;QACX,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;IACnC,CAAC;IAEM,QAAQ,CAAC,KAAmB;QAC/B,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC7B,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;CACJ;AAlBD,oDAkBC"}
|
package/token/token.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token.js","sourceRoot":"","sources":["../src/token/token.ts"],"names":[],"mappings":";;;AACA,4CAA8D;AAC9D,sCAAsC;AACtC,oCAAqC;AAoBrC,MAAa,KAAK;IAOd,YAAoB,OAAgB,EAAE,OAAqB,EAAE,SAAS,GAAG,EAAE;QACvE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC/B,CAAC;IAEM,MAAM,CAAC,KAAK,CACf,KAAa,EACb,UAAuB,IAAI,EAC3B,YAAoB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;QAEjD,IAAI,SAAS,GAAG,CAAC,EA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