@fluidframework/tree-agent 2.74.0 → 2.81.0
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/CHANGELOG.md +99 -0
- package/api-report/tree-agent.alpha.api.md +195 -20
- package/dist/alpha.d.ts +31 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/methodBinding.d.ts +54 -10
- package/dist/methodBinding.d.ts.map +1 -1
- package/dist/methodBinding.js.map +1 -1
- package/dist/propertyBinding.d.ts +52 -2
- package/dist/propertyBinding.d.ts.map +1 -1
- package/dist/propertyBinding.js +28 -3
- package/dist/propertyBinding.js.map +1 -1
- package/dist/renderSchemaTypeScript.d.ts.map +1 -1
- package/dist/renderSchemaTypeScript.js +24 -9
- package/dist/renderSchemaTypeScript.js.map +1 -1
- package/dist/renderTypeFactoryTypeScript.d.ts +13 -0
- package/dist/renderTypeFactoryTypeScript.d.ts.map +1 -0
- package/dist/renderTypeFactoryTypeScript.js +290 -0
- package/dist/renderTypeFactoryTypeScript.js.map +1 -0
- package/dist/subtree.d.ts.map +1 -1
- package/dist/subtree.js +4 -4
- package/dist/subtree.js.map +1 -1
- package/dist/treeAgentTypes.d.ts +430 -0
- package/dist/treeAgentTypes.d.ts.map +1 -0
- package/dist/treeAgentTypes.js +227 -0
- package/dist/treeAgentTypes.js.map +1 -0
- package/dist/utils.d.ts +0 -4
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +2 -9
- package/dist/utils.js.map +1 -1
- package/eslint.config.mts +4 -4
- package/lib/alpha.d.ts +31 -1
- package/lib/index.d.ts +3 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/methodBinding.d.ts +54 -10
- package/lib/methodBinding.d.ts.map +1 -1
- package/lib/methodBinding.js.map +1 -1
- package/lib/propertyBinding.d.ts +52 -2
- package/lib/propertyBinding.d.ts.map +1 -1
- package/lib/propertyBinding.js +28 -3
- package/lib/propertyBinding.js.map +1 -1
- package/lib/renderSchemaTypeScript.d.ts.map +1 -1
- package/lib/renderSchemaTypeScript.js +24 -9
- package/lib/renderSchemaTypeScript.js.map +1 -1
- package/lib/renderTypeFactoryTypeScript.d.ts +13 -0
- package/lib/renderTypeFactoryTypeScript.d.ts.map +1 -0
- package/lib/renderTypeFactoryTypeScript.js +285 -0
- package/lib/renderTypeFactoryTypeScript.js.map +1 -0
- package/lib/subtree.d.ts.map +1 -1
- package/lib/subtree.js +4 -4
- package/lib/subtree.js.map +1 -1
- package/lib/treeAgentTypes.d.ts +430 -0
- package/lib/treeAgentTypes.d.ts.map +1 -0
- package/lib/treeAgentTypes.js +223 -0
- package/lib/treeAgentTypes.js.map +1 -0
- package/lib/utils.d.ts +0 -4
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +2 -8
- package/lib/utils.js.map +1 -1
- package/package.json +17 -17
- package/src/index.ts +36 -0
- package/src/methodBinding.ts +94 -15
- package/src/propertyBinding.ts +66 -9
- package/src/renderSchemaTypeScript.ts +32 -10
- package/src/renderTypeFactoryTypeScript.ts +339 -0
- package/src/subtree.ts +6 -5
- package/src/treeAgentTypes.ts +611 -0
- package/src/utils.ts +2 -9
- package/.eslintrc.cjs +0 -48
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import type { TreeNodeSchemaClass } from "@fluidframework/tree/alpha";
|
|
6
|
+
import { ObjectNodeSchema } from "@fluidframework/tree/alpha";
|
|
7
|
+
/**
|
|
8
|
+
* Type kinds for the type factory type system.
|
|
9
|
+
* @alpha
|
|
10
|
+
*/
|
|
11
|
+
export type TypeFactoryTypeKind = "string" | "number" | "boolean" | "void" | "undefined" | "null" | "unknown" | "date" | "promise" | "array" | "object" | "record" | "map" | "tuple" | "union" | "intersection" | "literal" | "optional" | "readonly" | "function" | "instanceof";
|
|
12
|
+
/**
|
|
13
|
+
* Base interface for type factory types.
|
|
14
|
+
* @alpha
|
|
15
|
+
*/
|
|
16
|
+
export interface TypeFactoryType {
|
|
17
|
+
/**
|
|
18
|
+
* The kind of type this represents.
|
|
19
|
+
*/
|
|
20
|
+
readonly _kind: TypeFactoryTypeKind;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Type guard to check if a value is a type factory type.
|
|
24
|
+
* @alpha
|
|
25
|
+
*/
|
|
26
|
+
export declare function isTypeFactoryType(value: unknown): value is TypeFactoryType;
|
|
27
|
+
/**
|
|
28
|
+
* Represents a string type in the type factory system.
|
|
29
|
+
* @alpha
|
|
30
|
+
*/
|
|
31
|
+
export interface TypeFactoryString extends TypeFactoryType {
|
|
32
|
+
/**
|
|
33
|
+
* {@inheritDoc TypeFactoryType._kind}
|
|
34
|
+
*/
|
|
35
|
+
readonly _kind: "string";
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Represents a number type in the type factory system.
|
|
39
|
+
* @alpha
|
|
40
|
+
*/
|
|
41
|
+
export interface TypeFactoryNumber extends TypeFactoryType {
|
|
42
|
+
/**
|
|
43
|
+
* {@inheritDoc TypeFactoryType._kind}
|
|
44
|
+
*/
|
|
45
|
+
readonly _kind: "number";
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Represents a boolean type in the type factory system.
|
|
49
|
+
* @alpha
|
|
50
|
+
*/
|
|
51
|
+
export interface TypeFactoryBoolean extends TypeFactoryType {
|
|
52
|
+
/**
|
|
53
|
+
* {@inheritDoc TypeFactoryType._kind}
|
|
54
|
+
*/
|
|
55
|
+
readonly _kind: "boolean";
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Represents a Date type in the type factory system.
|
|
59
|
+
* @alpha
|
|
60
|
+
*/
|
|
61
|
+
export interface TypeFactoryDate extends TypeFactoryType {
|
|
62
|
+
/**
|
|
63
|
+
* {@inheritDoc TypeFactoryType._kind}
|
|
64
|
+
*/
|
|
65
|
+
readonly _kind: "date";
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Represents a void type in the type factory system.
|
|
69
|
+
* @alpha
|
|
70
|
+
*/
|
|
71
|
+
export interface TypeFactoryVoid extends TypeFactoryType {
|
|
72
|
+
/**
|
|
73
|
+
* {@inheritDoc TypeFactoryType._kind}
|
|
74
|
+
*/
|
|
75
|
+
readonly _kind: "void";
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Represents an undefined type in the type factory system.
|
|
79
|
+
* @alpha
|
|
80
|
+
*/
|
|
81
|
+
export interface TypeFactoryUndefined extends TypeFactoryType {
|
|
82
|
+
/**
|
|
83
|
+
* {@inheritDoc TypeFactoryType._kind}
|
|
84
|
+
*/
|
|
85
|
+
readonly _kind: "undefined";
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Represents a null type in the type factory system.
|
|
89
|
+
* @alpha
|
|
90
|
+
*/
|
|
91
|
+
export interface TypeFactoryNull extends TypeFactoryType {
|
|
92
|
+
/**
|
|
93
|
+
* {@inheritDoc TypeFactoryType._kind}
|
|
94
|
+
*/
|
|
95
|
+
readonly _kind: "null";
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Represents an unknown type in the type factory system.
|
|
99
|
+
* @alpha
|
|
100
|
+
*/
|
|
101
|
+
export interface TypeFactoryUnknown extends TypeFactoryType {
|
|
102
|
+
/**
|
|
103
|
+
* {@inheritDoc TypeFactoryType._kind}
|
|
104
|
+
*/
|
|
105
|
+
readonly _kind: "unknown";
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Represents an array type in the type factory system.
|
|
109
|
+
* @alpha
|
|
110
|
+
*/
|
|
111
|
+
export interface TypeFactoryArray extends TypeFactoryType {
|
|
112
|
+
/**
|
|
113
|
+
* {@inheritDoc TypeFactoryType._kind}
|
|
114
|
+
*/
|
|
115
|
+
readonly _kind: "array";
|
|
116
|
+
/**
|
|
117
|
+
* The type of elements in the array.
|
|
118
|
+
*/
|
|
119
|
+
readonly element: TypeFactoryType;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Represents a Promise type in the type factory system.
|
|
123
|
+
* @alpha
|
|
124
|
+
*/
|
|
125
|
+
export interface TypeFactoryPromise extends TypeFactoryType {
|
|
126
|
+
/**
|
|
127
|
+
* {@inheritDoc TypeFactoryType._kind}
|
|
128
|
+
*/
|
|
129
|
+
readonly _kind: "promise";
|
|
130
|
+
/**
|
|
131
|
+
* The type that the Promise resolves to.
|
|
132
|
+
*/
|
|
133
|
+
readonly innerType: TypeFactoryType;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Represents an object type with a fixed shape in the type factory system.
|
|
137
|
+
* @alpha
|
|
138
|
+
*/
|
|
139
|
+
export interface TypeFactoryObject extends TypeFactoryType {
|
|
140
|
+
/**
|
|
141
|
+
* {@inheritDoc TypeFactoryType._kind}
|
|
142
|
+
*/
|
|
143
|
+
readonly _kind: "object";
|
|
144
|
+
/**
|
|
145
|
+
* The shape of the object, mapping property names to their types.
|
|
146
|
+
*/
|
|
147
|
+
readonly shape: Record<string, TypeFactoryType>;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Represents a record type (index signature) in the type factory system.
|
|
151
|
+
* @alpha
|
|
152
|
+
*/
|
|
153
|
+
export interface TypeFactoryRecord extends TypeFactoryType {
|
|
154
|
+
/**
|
|
155
|
+
* {@inheritDoc TypeFactoryType._kind}
|
|
156
|
+
*/
|
|
157
|
+
readonly _kind: "record";
|
|
158
|
+
/**
|
|
159
|
+
* The type of the record's keys.
|
|
160
|
+
*/
|
|
161
|
+
readonly keyType: TypeFactoryType;
|
|
162
|
+
/**
|
|
163
|
+
* The type of the record's values.
|
|
164
|
+
*/
|
|
165
|
+
readonly valueType: TypeFactoryType;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Represents a Map type in the type factory system.
|
|
169
|
+
* @alpha
|
|
170
|
+
*/
|
|
171
|
+
export interface TypeFactoryMap extends TypeFactoryType {
|
|
172
|
+
/**
|
|
173
|
+
* {@inheritDoc TypeFactoryType._kind}
|
|
174
|
+
*/
|
|
175
|
+
readonly _kind: "map";
|
|
176
|
+
/**
|
|
177
|
+
* The type of the map's keys.
|
|
178
|
+
*/
|
|
179
|
+
readonly keyType: TypeFactoryType;
|
|
180
|
+
/**
|
|
181
|
+
* The type of the map's values.
|
|
182
|
+
*/
|
|
183
|
+
readonly valueType: TypeFactoryType;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Represents a tuple type with fixed-length items and optional rest elements in the type factory system.
|
|
187
|
+
* @alpha
|
|
188
|
+
*/
|
|
189
|
+
export interface TypeFactoryTuple extends TypeFactoryType {
|
|
190
|
+
/**
|
|
191
|
+
* {@inheritDoc TypeFactoryType._kind}
|
|
192
|
+
*/
|
|
193
|
+
readonly _kind: "tuple";
|
|
194
|
+
/**
|
|
195
|
+
* The fixed-length items in the tuple.
|
|
196
|
+
*/
|
|
197
|
+
readonly items: readonly TypeFactoryType[];
|
|
198
|
+
/**
|
|
199
|
+
* Optional rest element type for variable-length tuples.
|
|
200
|
+
*/
|
|
201
|
+
readonly rest?: TypeFactoryType;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Represents a union type in the type factory system.
|
|
205
|
+
* @alpha
|
|
206
|
+
*/
|
|
207
|
+
export interface TypeFactoryUnion extends TypeFactoryType {
|
|
208
|
+
/**
|
|
209
|
+
* {@inheritDoc TypeFactoryType._kind}
|
|
210
|
+
*/
|
|
211
|
+
readonly _kind: "union";
|
|
212
|
+
/**
|
|
213
|
+
* The possible types in the union.
|
|
214
|
+
*/
|
|
215
|
+
readonly options: readonly TypeFactoryType[];
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Represents an intersection type in the type factory system.
|
|
219
|
+
* @alpha
|
|
220
|
+
*/
|
|
221
|
+
export interface TypeFactoryIntersection extends TypeFactoryType {
|
|
222
|
+
/**
|
|
223
|
+
* {@inheritDoc TypeFactoryType._kind}
|
|
224
|
+
*/
|
|
225
|
+
readonly _kind: "intersection";
|
|
226
|
+
/**
|
|
227
|
+
* The types to intersect.
|
|
228
|
+
*/
|
|
229
|
+
readonly types: readonly TypeFactoryType[];
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Represents a literal type (specific string, number, or boolean value) in the type factory system.
|
|
233
|
+
* @alpha
|
|
234
|
+
*/
|
|
235
|
+
export interface TypeFactoryLiteral extends TypeFactoryType {
|
|
236
|
+
/**
|
|
237
|
+
* {@inheritDoc TypeFactoryType._kind}
|
|
238
|
+
*/
|
|
239
|
+
readonly _kind: "literal";
|
|
240
|
+
/**
|
|
241
|
+
* The specific literal value.
|
|
242
|
+
*/
|
|
243
|
+
readonly value: string | number | boolean;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Represents an optional type modifier in the type factory system.
|
|
247
|
+
* @alpha
|
|
248
|
+
*/
|
|
249
|
+
export interface TypeFactoryOptional extends TypeFactoryType {
|
|
250
|
+
/**
|
|
251
|
+
* {@inheritDoc TypeFactoryType._kind}
|
|
252
|
+
*/
|
|
253
|
+
readonly _kind: "optional";
|
|
254
|
+
/**
|
|
255
|
+
* The inner type that is optional.
|
|
256
|
+
*/
|
|
257
|
+
readonly innerType: TypeFactoryType;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Represents a readonly type modifier in the type factory system.
|
|
261
|
+
* @alpha
|
|
262
|
+
*/
|
|
263
|
+
export interface TypeFactoryReadonly extends TypeFactoryType {
|
|
264
|
+
/**
|
|
265
|
+
* {@inheritDoc TypeFactoryType._kind}
|
|
266
|
+
*/
|
|
267
|
+
readonly _kind: "readonly";
|
|
268
|
+
/**
|
|
269
|
+
* The inner type that is readonly.
|
|
270
|
+
*/
|
|
271
|
+
readonly innerType: TypeFactoryType;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Represents a function parameter as a tuple of [name, type].
|
|
275
|
+
* @alpha
|
|
276
|
+
*/
|
|
277
|
+
export type TypeFactoryFunctionParameter = readonly [name: string, type: TypeFactoryType];
|
|
278
|
+
/**
|
|
279
|
+
* Represents a function type in the type factory system.
|
|
280
|
+
* @alpha
|
|
281
|
+
*/
|
|
282
|
+
export interface TypeFactoryFunction extends TypeFactoryType {
|
|
283
|
+
/**
|
|
284
|
+
* {@inheritDoc TypeFactoryType._kind}
|
|
285
|
+
*/
|
|
286
|
+
readonly _kind: "function";
|
|
287
|
+
/**
|
|
288
|
+
* The function parameters.
|
|
289
|
+
*/
|
|
290
|
+
readonly parameters: readonly TypeFactoryFunctionParameter[];
|
|
291
|
+
/**
|
|
292
|
+
* The function return type.
|
|
293
|
+
*/
|
|
294
|
+
readonly returnType: TypeFactoryType;
|
|
295
|
+
/**
|
|
296
|
+
* Optional rest parameter for variable-length argument lists.
|
|
297
|
+
*/
|
|
298
|
+
readonly restParameter?: TypeFactoryFunctionParameter;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Represents an instanceof type that references a SharedTree schema class in the type factory system.
|
|
302
|
+
* @alpha
|
|
303
|
+
*/
|
|
304
|
+
export interface TypeFactoryInstanceOf extends TypeFactoryType {
|
|
305
|
+
/**
|
|
306
|
+
* {@inheritDoc TypeFactoryType._kind}
|
|
307
|
+
*/
|
|
308
|
+
readonly _kind: "instanceof";
|
|
309
|
+
/**
|
|
310
|
+
* The SharedTree schema class to reference.
|
|
311
|
+
*/
|
|
312
|
+
readonly schema: ObjectNodeSchema;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Namespace containing type factory functions.
|
|
316
|
+
* @alpha
|
|
317
|
+
*/
|
|
318
|
+
export declare const typeFactory: {
|
|
319
|
+
/**
|
|
320
|
+
* Create a string type.
|
|
321
|
+
* @alpha
|
|
322
|
+
*/
|
|
323
|
+
string(): TypeFactoryString;
|
|
324
|
+
/**
|
|
325
|
+
* Create a number type.
|
|
326
|
+
* @alpha
|
|
327
|
+
*/
|
|
328
|
+
number(): TypeFactoryNumber;
|
|
329
|
+
/**
|
|
330
|
+
* Create a boolean type.
|
|
331
|
+
* @alpha
|
|
332
|
+
*/
|
|
333
|
+
boolean(): TypeFactoryBoolean;
|
|
334
|
+
/**
|
|
335
|
+
* Create a Date type.
|
|
336
|
+
* @alpha
|
|
337
|
+
*/
|
|
338
|
+
date(): TypeFactoryDate;
|
|
339
|
+
/**
|
|
340
|
+
* Create a void type.
|
|
341
|
+
* @alpha
|
|
342
|
+
*/
|
|
343
|
+
void(): TypeFactoryVoid;
|
|
344
|
+
/**
|
|
345
|
+
* Create an undefined type.
|
|
346
|
+
* @alpha
|
|
347
|
+
*/
|
|
348
|
+
undefined(): TypeFactoryUndefined;
|
|
349
|
+
/**
|
|
350
|
+
* Create a null type.
|
|
351
|
+
* @alpha
|
|
352
|
+
*/
|
|
353
|
+
null(): TypeFactoryNull;
|
|
354
|
+
/**
|
|
355
|
+
* Create an unknown type.
|
|
356
|
+
* @alpha
|
|
357
|
+
*/
|
|
358
|
+
unknown(): TypeFactoryUnknown;
|
|
359
|
+
/**
|
|
360
|
+
* Create an array type.
|
|
361
|
+
* @alpha
|
|
362
|
+
*/
|
|
363
|
+
array(element: TypeFactoryType): TypeFactoryArray;
|
|
364
|
+
/**
|
|
365
|
+
* Create a Promise type.
|
|
366
|
+
* @alpha
|
|
367
|
+
*/
|
|
368
|
+
promise(innerType: TypeFactoryType): TypeFactoryPromise;
|
|
369
|
+
/**
|
|
370
|
+
* Create an object type.
|
|
371
|
+
* @alpha
|
|
372
|
+
*/
|
|
373
|
+
object(shape: Record<string, TypeFactoryType>): TypeFactoryObject;
|
|
374
|
+
/**
|
|
375
|
+
* Create a record type.
|
|
376
|
+
* @alpha
|
|
377
|
+
*/
|
|
378
|
+
record(keyType: TypeFactoryType, valueType: TypeFactoryType): TypeFactoryRecord;
|
|
379
|
+
/**
|
|
380
|
+
* Create a map type.
|
|
381
|
+
* @alpha
|
|
382
|
+
*/
|
|
383
|
+
map(keyType: TypeFactoryType, valueType: TypeFactoryType): TypeFactoryMap;
|
|
384
|
+
/**
|
|
385
|
+
* Create a tuple type.
|
|
386
|
+
* @alpha
|
|
387
|
+
*/
|
|
388
|
+
tuple(items: readonly TypeFactoryType[], rest?: TypeFactoryType): TypeFactoryTuple;
|
|
389
|
+
/**
|
|
390
|
+
* Create a union type.
|
|
391
|
+
* @alpha
|
|
392
|
+
*/
|
|
393
|
+
union(options: readonly TypeFactoryType[]): TypeFactoryUnion;
|
|
394
|
+
/**
|
|
395
|
+
* Create an intersection type.
|
|
396
|
+
* @alpha
|
|
397
|
+
*/
|
|
398
|
+
intersection(types: readonly TypeFactoryType[]): TypeFactoryIntersection;
|
|
399
|
+
/**
|
|
400
|
+
* Create a literal type.
|
|
401
|
+
* @alpha
|
|
402
|
+
*/
|
|
403
|
+
literal(value: string | number | boolean): TypeFactoryLiteral;
|
|
404
|
+
/**
|
|
405
|
+
* Create an optional type.
|
|
406
|
+
* @alpha
|
|
407
|
+
*/
|
|
408
|
+
optional(innerType: TypeFactoryType): TypeFactoryOptional;
|
|
409
|
+
/**
|
|
410
|
+
* Create a readonly type.
|
|
411
|
+
* @alpha
|
|
412
|
+
*/
|
|
413
|
+
readonly(innerType: TypeFactoryType): TypeFactoryReadonly;
|
|
414
|
+
/**
|
|
415
|
+
* Create a function type.
|
|
416
|
+
* @alpha
|
|
417
|
+
*/
|
|
418
|
+
function(parameters: readonly TypeFactoryFunctionParameter[], returnType: TypeFactoryType, restParameter?: TypeFactoryFunctionParameter): TypeFactoryFunction;
|
|
419
|
+
/**
|
|
420
|
+
* Create an instanceOf type for a SharedTree schema class.
|
|
421
|
+
* @alpha
|
|
422
|
+
*/
|
|
423
|
+
instanceOf<T extends TreeNodeSchemaClass>(schema: T): TypeFactoryInstanceOf;
|
|
424
|
+
};
|
|
425
|
+
/**
|
|
426
|
+
* A lookup from type factory instanceOf types to their corresponding ObjectNodeSchema.
|
|
427
|
+
* @alpha
|
|
428
|
+
*/
|
|
429
|
+
export declare const instanceOfsTypeFactory: WeakMap<TypeFactoryInstanceOf, ObjectNodeSchema<string, import("@fluidframework/tree/alpha").RestrictiveStringRecord<import("@fluidframework/tree/alpha").ImplicitFieldSchema>, boolean, unknown>>;
|
|
430
|
+
//# sourceMappingURL=treeAgentTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"treeAgentTypes.d.ts","sourceRoot":"","sources":["../src/treeAgentTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE9D;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAC5B,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,MAAM,GACN,WAAW,GACX,MAAM,GACN,SAAS,GACT,MAAM,GACN,SAAS,GACT,OAAO,GACP,QAAQ,GACR,QAAQ,GACR,KAAK,GACL,OAAO,GACP,OAAO,GACP,cAAc,GACd,SAAS,GACT,UAAU,GACV,UAAU,GACV,UAAU,GACV,YAAY,CAAC;AAEhB;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC/B;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,mBAAmB,CAAC;CACpC;AA8BD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe,CAM1E;AAID;;;GAGG;AACH,MAAM,WAAW,iBAAkB,SAAQ,eAAe;IACzD;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;CACzB;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAkB,SAAQ,eAAe;IACzD;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;CACzB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,GAAG,gBAAgB;IAIjD;;;OAGG;uBACgB,eAAe,GAAG,kBAAkB;IAIvD;;;OAGG;kBACW,OAAO,MAAM,EAAE,eAAe,CAAC,GAAG,iBAAiB;IAIjE;;;OAGG;oBACa,eAAe,aAAa,eAAe,GAAG,iBAAiB;IAI/E;;;OAGG;iBACU,eAAe,aAAa,eAAe,GAAG,cAAc;IAIzE;;;OAGG;iBACU,SAAS,eAAe,EAAE,SAAS,eAAe,GAAG,gBAAgB;IASlF;;;OAGG;mBACY,SAAS,eAAe,EAAE,GAAG,gBAAgB;IAS5D;;;OAGG;wBACiB,SAAS,eAAe,EAAE,GAAG,uBAAuB;IASxE;;;OAGG;mBACY,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,kBAAkB;IAI7D;;;OAGG;wBACiB,eAAe,GAAG,mBAAmB;IAIzD;;;OAGG;wBACiB,eAAe,GAAG,mBAAmB;IAIzD;;;OAGG;yBAEU,SAAS,4BAA4B,EAAE,cACvC,eAAe,kBACX,4BAA4B,GAC1C,mBAAmB;IAMtB;;;OAGG;sDAC+C,CAAC,GAAG,qBAAqB;CAc3E,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,sBAAsB,oMAAyD,CAAC"}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.instanceOfsTypeFactory = exports.typeFactory = exports.isTypeFactoryType = void 0;
|
|
8
|
+
const internal_1 = require("@fluidframework/telemetry-utils/internal");
|
|
9
|
+
const alpha_1 = require("@fluidframework/tree/alpha");
|
|
10
|
+
/**
|
|
11
|
+
* Set of valid type factory type kinds for efficient validation.
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
const validTypeKinds = new Set([
|
|
15
|
+
"string",
|
|
16
|
+
"number",
|
|
17
|
+
"boolean",
|
|
18
|
+
"void",
|
|
19
|
+
"undefined",
|
|
20
|
+
"null",
|
|
21
|
+
"unknown",
|
|
22
|
+
"date",
|
|
23
|
+
"promise",
|
|
24
|
+
"array",
|
|
25
|
+
"object",
|
|
26
|
+
"record",
|
|
27
|
+
"map",
|
|
28
|
+
"tuple",
|
|
29
|
+
"union",
|
|
30
|
+
"intersection",
|
|
31
|
+
"literal",
|
|
32
|
+
"optional",
|
|
33
|
+
"readonly",
|
|
34
|
+
"function",
|
|
35
|
+
"instanceof",
|
|
36
|
+
]);
|
|
37
|
+
/**
|
|
38
|
+
* Type guard to check if a value is a type factory type.
|
|
39
|
+
* @alpha
|
|
40
|
+
*/
|
|
41
|
+
function isTypeFactoryType(value) {
|
|
42
|
+
if (typeof value !== "object" || value === null || !("_kind" in value)) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
const kind = value._kind;
|
|
46
|
+
return typeof kind === "string" && validTypeKinds.has(kind);
|
|
47
|
+
}
|
|
48
|
+
exports.isTypeFactoryType = isTypeFactoryType;
|
|
49
|
+
/**
|
|
50
|
+
* Namespace containing type factory functions.
|
|
51
|
+
* @alpha
|
|
52
|
+
*/
|
|
53
|
+
exports.typeFactory = {
|
|
54
|
+
/**
|
|
55
|
+
* Create a string type.
|
|
56
|
+
* @alpha
|
|
57
|
+
*/
|
|
58
|
+
string() {
|
|
59
|
+
return { _kind: "string" };
|
|
60
|
+
},
|
|
61
|
+
/**
|
|
62
|
+
* Create a number type.
|
|
63
|
+
* @alpha
|
|
64
|
+
*/
|
|
65
|
+
number() {
|
|
66
|
+
return { _kind: "number" };
|
|
67
|
+
},
|
|
68
|
+
/**
|
|
69
|
+
* Create a boolean type.
|
|
70
|
+
* @alpha
|
|
71
|
+
*/
|
|
72
|
+
boolean() {
|
|
73
|
+
return { _kind: "boolean" };
|
|
74
|
+
},
|
|
75
|
+
/**
|
|
76
|
+
* Create a Date type.
|
|
77
|
+
* @alpha
|
|
78
|
+
*/
|
|
79
|
+
date() {
|
|
80
|
+
return { _kind: "date" };
|
|
81
|
+
},
|
|
82
|
+
/**
|
|
83
|
+
* Create a void type.
|
|
84
|
+
* @alpha
|
|
85
|
+
*/
|
|
86
|
+
void() {
|
|
87
|
+
return { _kind: "void" };
|
|
88
|
+
},
|
|
89
|
+
/**
|
|
90
|
+
* Create an undefined type.
|
|
91
|
+
* @alpha
|
|
92
|
+
*/
|
|
93
|
+
undefined() {
|
|
94
|
+
return { _kind: "undefined" };
|
|
95
|
+
},
|
|
96
|
+
/**
|
|
97
|
+
* Create a null type.
|
|
98
|
+
* @alpha
|
|
99
|
+
*/
|
|
100
|
+
null() {
|
|
101
|
+
return { _kind: "null" };
|
|
102
|
+
},
|
|
103
|
+
/**
|
|
104
|
+
* Create an unknown type.
|
|
105
|
+
* @alpha
|
|
106
|
+
*/
|
|
107
|
+
unknown() {
|
|
108
|
+
return { _kind: "unknown" };
|
|
109
|
+
},
|
|
110
|
+
/**
|
|
111
|
+
* Create an array type.
|
|
112
|
+
* @alpha
|
|
113
|
+
*/
|
|
114
|
+
array(element) {
|
|
115
|
+
return { _kind: "array", element };
|
|
116
|
+
},
|
|
117
|
+
/**
|
|
118
|
+
* Create a Promise type.
|
|
119
|
+
* @alpha
|
|
120
|
+
*/
|
|
121
|
+
promise(innerType) {
|
|
122
|
+
return { _kind: "promise", innerType };
|
|
123
|
+
},
|
|
124
|
+
/**
|
|
125
|
+
* Create an object type.
|
|
126
|
+
* @alpha
|
|
127
|
+
*/
|
|
128
|
+
object(shape) {
|
|
129
|
+
return { _kind: "object", shape };
|
|
130
|
+
},
|
|
131
|
+
/**
|
|
132
|
+
* Create a record type.
|
|
133
|
+
* @alpha
|
|
134
|
+
*/
|
|
135
|
+
record(keyType, valueType) {
|
|
136
|
+
return { _kind: "record", keyType, valueType };
|
|
137
|
+
},
|
|
138
|
+
/**
|
|
139
|
+
* Create a map type.
|
|
140
|
+
* @alpha
|
|
141
|
+
*/
|
|
142
|
+
map(keyType, valueType) {
|
|
143
|
+
return { _kind: "map", keyType, valueType };
|
|
144
|
+
},
|
|
145
|
+
/**
|
|
146
|
+
* Create a tuple type.
|
|
147
|
+
* @alpha
|
|
148
|
+
*/
|
|
149
|
+
tuple(items, rest) {
|
|
150
|
+
if (items.length === 0 && rest === undefined) {
|
|
151
|
+
throw new internal_1.UsageError("typeFactory.tuple requires at least one item or a rest type. Empty tuples are not supported.");
|
|
152
|
+
}
|
|
153
|
+
return rest === undefined ? { _kind: "tuple", items } : { _kind: "tuple", items, rest };
|
|
154
|
+
},
|
|
155
|
+
/**
|
|
156
|
+
* Create a union type.
|
|
157
|
+
* @alpha
|
|
158
|
+
*/
|
|
159
|
+
union(options) {
|
|
160
|
+
if (options.length === 0) {
|
|
161
|
+
throw new internal_1.UsageError("typeFactory.union requires at least one option. Empty unions are not valid TypeScript types.");
|
|
162
|
+
}
|
|
163
|
+
return { _kind: "union", options };
|
|
164
|
+
},
|
|
165
|
+
/**
|
|
166
|
+
* Create an intersection type.
|
|
167
|
+
* @alpha
|
|
168
|
+
*/
|
|
169
|
+
intersection(types) {
|
|
170
|
+
if (types.length === 0) {
|
|
171
|
+
throw new internal_1.UsageError("typeFactory.intersection requires at least one type. Empty intersections are not valid TypeScript types.");
|
|
172
|
+
}
|
|
173
|
+
return { _kind: "intersection", types };
|
|
174
|
+
},
|
|
175
|
+
/**
|
|
176
|
+
* Create a literal type.
|
|
177
|
+
* @alpha
|
|
178
|
+
*/
|
|
179
|
+
literal(value) {
|
|
180
|
+
return { _kind: "literal", value };
|
|
181
|
+
},
|
|
182
|
+
/**
|
|
183
|
+
* Create an optional type.
|
|
184
|
+
* @alpha
|
|
185
|
+
*/
|
|
186
|
+
optional(innerType) {
|
|
187
|
+
return { _kind: "optional", innerType };
|
|
188
|
+
},
|
|
189
|
+
/**
|
|
190
|
+
* Create a readonly type.
|
|
191
|
+
* @alpha
|
|
192
|
+
*/
|
|
193
|
+
readonly(innerType) {
|
|
194
|
+
return { _kind: "readonly", innerType };
|
|
195
|
+
},
|
|
196
|
+
/**
|
|
197
|
+
* Create a function type.
|
|
198
|
+
* @alpha
|
|
199
|
+
*/
|
|
200
|
+
function(parameters, returnType, restParameter) {
|
|
201
|
+
return restParameter === undefined
|
|
202
|
+
? { _kind: "function", parameters, returnType }
|
|
203
|
+
: { _kind: "function", parameters, returnType, restParameter };
|
|
204
|
+
},
|
|
205
|
+
/**
|
|
206
|
+
* Create an instanceOf type for a SharedTree schema class.
|
|
207
|
+
* @alpha
|
|
208
|
+
*/
|
|
209
|
+
instanceOf(schema) {
|
|
210
|
+
if (!(schema instanceof alpha_1.ObjectNodeSchema)) {
|
|
211
|
+
throw new internal_1.UsageError(`typeFactory.instanceOf only supports ObjectNodeSchema-based schema classes (created via SchemaFactory.object). ` +
|
|
212
|
+
`Pass a schema class that extends from an object schema (e.g., sf.object(...)), not primitive, array, or map schemas.`);
|
|
213
|
+
}
|
|
214
|
+
const instanceOfType = {
|
|
215
|
+
_kind: "instanceof",
|
|
216
|
+
schema,
|
|
217
|
+
};
|
|
218
|
+
exports.instanceOfsTypeFactory.set(instanceOfType, schema);
|
|
219
|
+
return instanceOfType;
|
|
220
|
+
},
|
|
221
|
+
};
|
|
222
|
+
/**
|
|
223
|
+
* A lookup from type factory instanceOf types to their corresponding ObjectNodeSchema.
|
|
224
|
+
* @alpha
|
|
225
|
+
*/
|
|
226
|
+
exports.instanceOfsTypeFactory = new WeakMap();
|
|
227
|
+
//# sourceMappingURL=treeAgentTypes.js.map
|