@fluidframework/tree-agent 2.74.0 → 2.81.0-374083

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 (73) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/api-report/tree-agent.alpha.api.md +163 -20
  3. package/dist/alpha.d.ts +26 -1
  4. package/dist/index.d.ts +3 -1
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +5 -1
  7. package/dist/index.js.map +1 -1
  8. package/dist/methodBinding.d.ts +54 -10
  9. package/dist/methodBinding.d.ts.map +1 -1
  10. package/dist/methodBinding.js.map +1 -1
  11. package/dist/propertyBinding.d.ts +52 -2
  12. package/dist/propertyBinding.d.ts.map +1 -1
  13. package/dist/propertyBinding.js +28 -3
  14. package/dist/propertyBinding.js.map +1 -1
  15. package/dist/renderSchemaTypeScript.d.ts.map +1 -1
  16. package/dist/renderSchemaTypeScript.js +17 -8
  17. package/dist/renderSchemaTypeScript.js.map +1 -1
  18. package/dist/renderTypeFactoryTypeScript.d.ts +13 -0
  19. package/dist/renderTypeFactoryTypeScript.d.ts.map +1 -0
  20. package/dist/renderTypeFactoryTypeScript.js +222 -0
  21. package/dist/renderTypeFactoryTypeScript.js.map +1 -0
  22. package/dist/subtree.d.ts.map +1 -1
  23. package/dist/subtree.js +4 -4
  24. package/dist/subtree.js.map +1 -1
  25. package/dist/treeAgentTypes.d.ts +345 -0
  26. package/dist/treeAgentTypes.d.ts.map +1 -0
  27. package/dist/treeAgentTypes.js +190 -0
  28. package/dist/treeAgentTypes.js.map +1 -0
  29. package/dist/utils.d.ts +0 -4
  30. package/dist/utils.d.ts.map +1 -1
  31. package/dist/utils.js +2 -9
  32. package/dist/utils.js.map +1 -1
  33. package/eslint.config.mts +4 -4
  34. package/lib/alpha.d.ts +26 -1
  35. package/lib/index.d.ts +3 -1
  36. package/lib/index.d.ts.map +1 -1
  37. package/lib/index.js +1 -0
  38. package/lib/index.js.map +1 -1
  39. package/lib/methodBinding.d.ts +54 -10
  40. package/lib/methodBinding.d.ts.map +1 -1
  41. package/lib/methodBinding.js.map +1 -1
  42. package/lib/propertyBinding.d.ts +52 -2
  43. package/lib/propertyBinding.d.ts.map +1 -1
  44. package/lib/propertyBinding.js +28 -3
  45. package/lib/propertyBinding.js.map +1 -1
  46. package/lib/renderSchemaTypeScript.d.ts.map +1 -1
  47. package/lib/renderSchemaTypeScript.js +17 -8
  48. package/lib/renderSchemaTypeScript.js.map +1 -1
  49. package/lib/renderTypeFactoryTypeScript.d.ts +13 -0
  50. package/lib/renderTypeFactoryTypeScript.d.ts.map +1 -0
  51. package/lib/renderTypeFactoryTypeScript.js +217 -0
  52. package/lib/renderTypeFactoryTypeScript.js.map +1 -0
  53. package/lib/subtree.d.ts.map +1 -1
  54. package/lib/subtree.js +4 -4
  55. package/lib/subtree.js.map +1 -1
  56. package/lib/treeAgentTypes.d.ts +345 -0
  57. package/lib/treeAgentTypes.d.ts.map +1 -0
  58. package/lib/treeAgentTypes.js +186 -0
  59. package/lib/treeAgentTypes.js.map +1 -0
  60. package/lib/utils.d.ts +0 -4
  61. package/lib/utils.d.ts.map +1 -1
  62. package/lib/utils.js +2 -8
  63. package/lib/utils.js.map +1 -1
  64. package/package.json +17 -17
  65. package/src/index.ts +31 -0
  66. package/src/methodBinding.ts +94 -15
  67. package/src/propertyBinding.ts +66 -9
  68. package/src/renderSchemaTypeScript.ts +25 -9
  69. package/src/renderTypeFactoryTypeScript.ts +259 -0
  70. package/src/subtree.ts +6 -5
  71. package/src/treeAgentTypes.ts +490 -0
  72. package/src/utils.ts +2 -9
  73. package/.eslintrc.cjs +0 -48
@@ -0,0 +1,345 @@
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" | "array" | "object" | "record" | "map" | "tuple" | "union" | "literal" | "optional" | "readonly" | "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 void type in the type factory system.
59
+ * @alpha
60
+ */
61
+ export interface TypeFactoryVoid extends TypeFactoryType {
62
+ /**
63
+ * {@inheritDoc TypeFactoryType._kind}
64
+ */
65
+ readonly _kind: "void";
66
+ }
67
+ /**
68
+ * Represents an undefined type in the type factory system.
69
+ * @alpha
70
+ */
71
+ export interface TypeFactoryUndefined extends TypeFactoryType {
72
+ /**
73
+ * {@inheritDoc TypeFactoryType._kind}
74
+ */
75
+ readonly _kind: "undefined";
76
+ }
77
+ /**
78
+ * Represents a null type in the type factory system.
79
+ * @alpha
80
+ */
81
+ export interface TypeFactoryNull extends TypeFactoryType {
82
+ /**
83
+ * {@inheritDoc TypeFactoryType._kind}
84
+ */
85
+ readonly _kind: "null";
86
+ }
87
+ /**
88
+ * Represents an unknown type in the type factory system.
89
+ * @alpha
90
+ */
91
+ export interface TypeFactoryUnknown extends TypeFactoryType {
92
+ /**
93
+ * {@inheritDoc TypeFactoryType._kind}
94
+ */
95
+ readonly _kind: "unknown";
96
+ }
97
+ /**
98
+ * Represents an array type in the type factory system.
99
+ * @alpha
100
+ */
101
+ export interface TypeFactoryArray extends TypeFactoryType {
102
+ /**
103
+ * {@inheritDoc TypeFactoryType._kind}
104
+ */
105
+ readonly _kind: "array";
106
+ /**
107
+ * The type of elements in the array.
108
+ */
109
+ readonly element: TypeFactoryType;
110
+ }
111
+ /**
112
+ * Represents an object type with a fixed shape in the type factory system.
113
+ * @alpha
114
+ */
115
+ export interface TypeFactoryObject extends TypeFactoryType {
116
+ /**
117
+ * {@inheritDoc TypeFactoryType._kind}
118
+ */
119
+ readonly _kind: "object";
120
+ /**
121
+ * The shape of the object, mapping property names to their types.
122
+ */
123
+ readonly shape: Record<string, TypeFactoryType>;
124
+ }
125
+ /**
126
+ * Represents a record type (index signature) in the type factory system.
127
+ * @alpha
128
+ */
129
+ export interface TypeFactoryRecord extends TypeFactoryType {
130
+ /**
131
+ * {@inheritDoc TypeFactoryType._kind}
132
+ */
133
+ readonly _kind: "record";
134
+ /**
135
+ * The type of the record's keys.
136
+ */
137
+ readonly keyType: TypeFactoryType;
138
+ /**
139
+ * The type of the record's values.
140
+ */
141
+ readonly valueType: TypeFactoryType;
142
+ }
143
+ /**
144
+ * Represents a Map type in the type factory system.
145
+ * @alpha
146
+ */
147
+ export interface TypeFactoryMap extends TypeFactoryType {
148
+ /**
149
+ * {@inheritDoc TypeFactoryType._kind}
150
+ */
151
+ readonly _kind: "map";
152
+ /**
153
+ * The type of the map's keys.
154
+ */
155
+ readonly keyType: TypeFactoryType;
156
+ /**
157
+ * The type of the map's values.
158
+ */
159
+ readonly valueType: TypeFactoryType;
160
+ }
161
+ /**
162
+ * Represents a tuple type with fixed-length items and optional rest elements in the type factory system.
163
+ * @alpha
164
+ */
165
+ export interface TypeFactoryTuple extends TypeFactoryType {
166
+ /**
167
+ * {@inheritDoc TypeFactoryType._kind}
168
+ */
169
+ readonly _kind: "tuple";
170
+ /**
171
+ * The fixed-length items in the tuple.
172
+ */
173
+ readonly items: readonly TypeFactoryType[];
174
+ /**
175
+ * Optional rest element type for variable-length tuples.
176
+ */
177
+ readonly rest?: TypeFactoryType;
178
+ }
179
+ /**
180
+ * Represents a union type in the type factory system.
181
+ * @alpha
182
+ */
183
+ export interface TypeFactoryUnion extends TypeFactoryType {
184
+ /**
185
+ * {@inheritDoc TypeFactoryType._kind}
186
+ */
187
+ readonly _kind: "union";
188
+ /**
189
+ * The possible types in the union.
190
+ */
191
+ readonly options: readonly TypeFactoryType[];
192
+ }
193
+ /**
194
+ * Represents a literal type (specific string, number, or boolean value) in the type factory system.
195
+ * @alpha
196
+ */
197
+ export interface TypeFactoryLiteral extends TypeFactoryType {
198
+ /**
199
+ * {@inheritDoc TypeFactoryType._kind}
200
+ */
201
+ readonly _kind: "literal";
202
+ /**
203
+ * The specific literal value.
204
+ */
205
+ readonly value: string | number | boolean;
206
+ }
207
+ /**
208
+ * Represents an optional type modifier in the type factory system.
209
+ * @alpha
210
+ */
211
+ export interface TypeFactoryOptional extends TypeFactoryType {
212
+ /**
213
+ * {@inheritDoc TypeFactoryType._kind}
214
+ */
215
+ readonly _kind: "optional";
216
+ /**
217
+ * The inner type that is optional.
218
+ */
219
+ readonly innerType: TypeFactoryType;
220
+ }
221
+ /**
222
+ * Represents a readonly type modifier in the type factory system.
223
+ * @alpha
224
+ */
225
+ export interface TypeFactoryReadonly extends TypeFactoryType {
226
+ /**
227
+ * {@inheritDoc TypeFactoryType._kind}
228
+ */
229
+ readonly _kind: "readonly";
230
+ /**
231
+ * The inner type that is readonly.
232
+ */
233
+ readonly innerType: TypeFactoryType;
234
+ }
235
+ /**
236
+ * Represents an instanceof type that references a SharedTree schema class in the type factory system.
237
+ * @alpha
238
+ */
239
+ export interface TypeFactoryInstanceOf extends TypeFactoryType {
240
+ /**
241
+ * {@inheritDoc TypeFactoryType._kind}
242
+ */
243
+ readonly _kind: "instanceof";
244
+ /**
245
+ * The SharedTree schema class to reference.
246
+ */
247
+ readonly schema: ObjectNodeSchema;
248
+ }
249
+ /**
250
+ * Namespace containing type factory functions.
251
+ * @alpha
252
+ */
253
+ export declare const typeFactory: {
254
+ /**
255
+ * Create a string type.
256
+ * @alpha
257
+ */
258
+ string(): TypeFactoryString;
259
+ /**
260
+ * Create a number type.
261
+ * @alpha
262
+ */
263
+ number(): TypeFactoryNumber;
264
+ /**
265
+ * Create a boolean type.
266
+ * @alpha
267
+ */
268
+ boolean(): TypeFactoryBoolean;
269
+ /**
270
+ * Create a void type.
271
+ * @alpha
272
+ */
273
+ void(): TypeFactoryVoid;
274
+ /**
275
+ * Create an undefined type.
276
+ * @alpha
277
+ */
278
+ undefined(): TypeFactoryUndefined;
279
+ /**
280
+ * Create a null type.
281
+ * @alpha
282
+ */
283
+ null(): TypeFactoryNull;
284
+ /**
285
+ * Create an unknown type.
286
+ * @alpha
287
+ */
288
+ unknown(): TypeFactoryUnknown;
289
+ /**
290
+ * Create an array type.
291
+ * @alpha
292
+ */
293
+ array(element: TypeFactoryType): TypeFactoryArray;
294
+ /**
295
+ * Create an object type.
296
+ * @alpha
297
+ */
298
+ object(shape: Record<string, TypeFactoryType>): TypeFactoryObject;
299
+ /**
300
+ * Create a record type.
301
+ * @alpha
302
+ */
303
+ record(keyType: TypeFactoryType, valueType: TypeFactoryType): TypeFactoryRecord;
304
+ /**
305
+ * Create a map type.
306
+ * @alpha
307
+ */
308
+ map(keyType: TypeFactoryType, valueType: TypeFactoryType): TypeFactoryMap;
309
+ /**
310
+ * Create a tuple type.
311
+ * @alpha
312
+ */
313
+ tuple(items: readonly TypeFactoryType[], rest?: TypeFactoryType): TypeFactoryTuple;
314
+ /**
315
+ * Create a union type.
316
+ * @alpha
317
+ */
318
+ union(options: readonly TypeFactoryType[]): TypeFactoryUnion;
319
+ /**
320
+ * Create a literal type.
321
+ * @alpha
322
+ */
323
+ literal(value: string | number | boolean): TypeFactoryLiteral;
324
+ /**
325
+ * Create an optional type.
326
+ * @alpha
327
+ */
328
+ optional(innerType: TypeFactoryType): TypeFactoryOptional;
329
+ /**
330
+ * Create a readonly type.
331
+ * @alpha
332
+ */
333
+ readonly(innerType: TypeFactoryType): TypeFactoryReadonly;
334
+ /**
335
+ * Create an instanceOf type for a SharedTree schema class.
336
+ * @alpha
337
+ */
338
+ instanceOf<T extends TreeNodeSchemaClass>(schema: T): TypeFactoryInstanceOf;
339
+ };
340
+ /**
341
+ * A lookup from type factory instanceOf types to their corresponding ObjectNodeSchema.
342
+ * @alpha
343
+ */
344
+ export declare const instanceOfsTypeFactory: WeakMap<TypeFactoryInstanceOf, ObjectNodeSchema<string, import("@fluidframework/tree/alpha").RestrictiveStringRecord<import("@fluidframework/tree/alpha").ImplicitFieldSchema>, boolean, unknown>>;
345
+ //# 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,OAAO,GACP,QAAQ,GACR,QAAQ,GACR,KAAK,GACL,OAAO,GACP,OAAO,GACP,SAAS,GACT,UAAU,GACV,UAAU,GACV,YAAY,CAAC;AAEhB;;;GAGG;AACH,MAAM,WAAW,eAAe;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AGG;AACH,eAAO,MAAM,sBAAsB,oMAAyD,CAAC"}
@@ -0,0 +1,186 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { UsageError } from "@fluidframework/telemetry-utils/internal";
6
+ import { ObjectNodeSchema } from "@fluidframework/tree/alpha";
7
+ /**
8
+ * Set of valid type factory type kinds for efficient validation.
9
+ * @internal
10
+ */
11
+ const validTypeKinds = new Set([
12
+ "string",
13
+ "number",
14
+ "boolean",
15
+ "void",
16
+ "undefined",
17
+ "null",
18
+ "unknown",
19
+ "array",
20
+ "object",
21
+ "record",
22
+ "map",
23
+ "tuple",
24
+ "union",
25
+ "literal",
26
+ "optional",
27
+ "readonly",
28
+ "instanceof",
29
+ ]);
30
+ /**
31
+ * Type guard to check if a value is a type factory type.
32
+ * @alpha
33
+ */
34
+ export function isTypeFactoryType(value) {
35
+ if (typeof value !== "object" || value === null || !("_kind" in value)) {
36
+ return false;
37
+ }
38
+ const kind = value._kind;
39
+ return typeof kind === "string" && validTypeKinds.has(kind);
40
+ }
41
+ /**
42
+ * Namespace containing type factory functions.
43
+ * @alpha
44
+ */
45
+ export const typeFactory = {
46
+ /**
47
+ * Create a string type.
48
+ * @alpha
49
+ */
50
+ string() {
51
+ return { _kind: "string" };
52
+ },
53
+ /**
54
+ * Create a number type.
55
+ * @alpha
56
+ */
57
+ number() {
58
+ return { _kind: "number" };
59
+ },
60
+ /**
61
+ * Create a boolean type.
62
+ * @alpha
63
+ */
64
+ boolean() {
65
+ return { _kind: "boolean" };
66
+ },
67
+ /**
68
+ * Create a void type.
69
+ * @alpha
70
+ */
71
+ void() {
72
+ return { _kind: "void" };
73
+ },
74
+ /**
75
+ * Create an undefined type.
76
+ * @alpha
77
+ */
78
+ undefined() {
79
+ return { _kind: "undefined" };
80
+ },
81
+ /**
82
+ * Create a null type.
83
+ * @alpha
84
+ */
85
+ null() {
86
+ return { _kind: "null" };
87
+ },
88
+ /**
89
+ * Create an unknown type.
90
+ * @alpha
91
+ */
92
+ unknown() {
93
+ return { _kind: "unknown" };
94
+ },
95
+ /**
96
+ * Create an array type.
97
+ * @alpha
98
+ */
99
+ array(element) {
100
+ return { _kind: "array", element };
101
+ },
102
+ /**
103
+ * Create an object type.
104
+ * @alpha
105
+ */
106
+ object(shape) {
107
+ return { _kind: "object", shape };
108
+ },
109
+ /**
110
+ * Create a record type.
111
+ * @alpha
112
+ */
113
+ record(keyType, valueType) {
114
+ return { _kind: "record", keyType, valueType };
115
+ },
116
+ /**
117
+ * Create a map type.
118
+ * @alpha
119
+ */
120
+ map(keyType, valueType) {
121
+ return { _kind: "map", keyType, valueType };
122
+ },
123
+ /**
124
+ * Create a tuple type.
125
+ * @alpha
126
+ */
127
+ tuple(items, rest) {
128
+ if (items.length === 0 && rest === undefined) {
129
+ throw new UsageError("typeFactory.tuple requires at least one item or a rest type. Empty tuples are not supported.");
130
+ }
131
+ return rest === undefined ? { _kind: "tuple", items } : { _kind: "tuple", items, rest };
132
+ },
133
+ /**
134
+ * Create a union type.
135
+ * @alpha
136
+ */
137
+ union(options) {
138
+ if (options.length === 0) {
139
+ throw new UsageError("typeFactory.union requires at least one option. Empty unions are not valid TypeScript types.");
140
+ }
141
+ return { _kind: "union", options };
142
+ },
143
+ /**
144
+ * Create a literal type.
145
+ * @alpha
146
+ */
147
+ literal(value) {
148
+ return { _kind: "literal", value };
149
+ },
150
+ /**
151
+ * Create an optional type.
152
+ * @alpha
153
+ */
154
+ optional(innerType) {
155
+ return { _kind: "optional", innerType };
156
+ },
157
+ /**
158
+ * Create a readonly type.
159
+ * @alpha
160
+ */
161
+ readonly(innerType) {
162
+ return { _kind: "readonly", innerType };
163
+ },
164
+ /**
165
+ * Create an instanceOf type for a SharedTree schema class.
166
+ * @alpha
167
+ */
168
+ instanceOf(schema) {
169
+ if (!(schema instanceof ObjectNodeSchema)) {
170
+ throw new UsageError(`typeFactory.instanceOf only supports ObjectNodeSchema-based schema classes (created via SchemaFactory.object). ` +
171
+ `Pass a schema class that extends from an object schema (e.g., sf.object(...)), not primitive, array, or map schemas.`);
172
+ }
173
+ const instanceOfType = {
174
+ _kind: "instanceof",
175
+ schema,
176
+ };
177
+ instanceOfsTypeFactory.set(instanceOfType, schema);
178
+ return instanceOfType;
179
+ },
180
+ };
181
+ /**
182
+ * A lookup from type factory instanceOf types to their corresponding ObjectNodeSchema.
183
+ * @alpha
184
+ */
185
+ export const instanceOfsTypeFactory = new WeakMap();
186
+ //# sourceMappingURL=treeAgentTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"treeAgentTypes.js","sourceRoot":"","sources":["../src/treeAgentTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAEtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAoC9D;;;GAGG;AACH,MAAM,cAAc,GAAqC,IAAI,GAAG,CAAsB;IACrF,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,MAAM;IACN,WAAW;IACX,MAAM;IACN,SAAS;IACT,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,KAAK;IACL,OAAO;IACP,OAAO;IACP,SAAS;IACT,UAAU;IACV,UAAU;IACV,YAAY;CACZ,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC/C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,CAAC,OAAO,IAAI,KAAK,CAAC,EAAE,CAAC;QACxE,OAAO,KAAK,CAAC;IACd,CAAC;IACD,MAAM,IAAI,GAAI,KAA4B,CAAC,KAAK,CAAC;IACjD,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,cAAc,CAAC,GAAG,CAAC,IAA2B,CAAC,CAAC;AACpF,CAAC;AAqPD;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IAC1B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n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport type { TreeNodeSchemaClass } from \"@fluidframework/tree/alpha\";\nimport { ObjectNodeSchema } from \"@fluidframework/tree/alpha\";\n\n/**\n * Type kinds for the type factory type system.\n * @alpha\n */\nexport type TypeFactoryTypeKind =\n\t| \"string\"\n\t| \"number\"\n\t| \"boolean\"\n\t| \"void\"\n\t| \"undefined\"\n\t| \"null\"\n\t| \"unknown\"\n\t| \"array\"\n\t| \"object\"\n\t| \"record\"\n\t| \"map\"\n\t| \"tuple\"\n\t| \"union\"\n\t| \"literal\"\n\t| \"optional\"\n\t| \"readonly\"\n\t| \"instanceof\";\n\n/**\n * Base interface for type factory types.\n * @alpha\n */\nexport interface TypeFactoryType {\n\t/**\n\t * The kind of type this represents.\n\t */\n\treadonly _kind: TypeFactoryTypeKind;\n}\n\n/**\n * Set of valid type factory type kinds for efficient validation.\n * @internal\n */\nconst validTypeKinds: ReadonlySet<TypeFactoryTypeKind> = new Set<TypeFactoryTypeKind>([\n\t\"string\",\n\t\"number\",\n\t\"boolean\",\n\t\"void\",\n\t\"undefined\",\n\t\"null\",\n\t\"unknown\",\n\t\"array\",\n\t\"object\",\n\t\"record\",\n\t\"map\",\n\t\"tuple\",\n\t\"union\",\n\t\"literal\",\n\t\"optional\",\n\t\"readonly\",\n\t\"instanceof\",\n]);\n\n/**\n * Type guard to check if a value is a type factory type.\n * @alpha\n */\nexport function isTypeFactoryType(value: unknown): value is TypeFactoryType {\n\tif (typeof value !== \"object\" || value === null || !(\"_kind\" in value)) {\n\t\treturn false;\n\t}\n\tconst kind = (value as { _kind: unknown })._kind;\n\treturn typeof kind === \"string\" && validTypeKinds.has(kind as TypeFactoryTypeKind);\n}\n\n// Primitive type factories\n\n/**\n * Represents a string type in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryString extends TypeFactoryType {\n\t/**\n\t * {@inheritDoc TypeFactoryType._kind}\n\t */\n\treadonly _kind: \"string\";\n}\n\n/**\n * Represents a number type in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryNumber extends TypeFactoryType {\n\t/**\n\t * {@inheritDoc TypeFactoryType._kind}\n\t */\n\treadonly _kind: \"number\";\n}\n\n/**\n * Represents a boolean type in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryBoolean extends TypeFactoryType {\n\t/**\n\t * {@inheritDoc TypeFactoryType._kind}\n\t */\n\treadonly _kind: \"boolean\";\n}\n\n/**\n * Represents a void type in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryVoid extends TypeFactoryType {\n\t/**\n\t * {@inheritDoc TypeFactoryType._kind}\n\t */\n\treadonly _kind: \"void\";\n}\n\n/**\n * Represents an undefined type in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryUndefined extends TypeFactoryType {\n\t/**\n\t * {@inheritDoc TypeFactoryType._kind}\n\t */\n\treadonly _kind: \"undefined\";\n}\n\n/**\n * Represents a null type in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryNull extends TypeFactoryType {\n\t/**\n\t * {@inheritDoc TypeFactoryType._kind}\n\t */\n\treadonly _kind: \"null\";\n}\n\n/**\n * Represents an unknown type in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryUnknown extends TypeFactoryType {\n\t/**\n\t * {@inheritDoc TypeFactoryType._kind}\n\t */\n\treadonly _kind: \"unknown\";\n}\n\n// Complex type interfaces\n\n/**\n * Represents an array type in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryArray extends TypeFactoryType {\n\t/**\n\t * {@inheritDoc TypeFactoryType._kind}\n\t */\n\treadonly _kind: \"array\";\n\t/**\n\t * The type of elements in the array.\n\t */\n\treadonly element: TypeFactoryType;\n}\n\n/**\n * Represents an object type with a fixed shape in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryObject extends TypeFactoryType {\n\t/**\n\t * {@inheritDoc TypeFactoryType._kind}\n\t */\n\treadonly _kind: \"object\";\n\t/**\n\t * The shape of the object, mapping property names to their types.\n\t */\n\treadonly shape: Record<string, TypeFactoryType>;\n}\n\n/**\n * Represents a record type (index signature) in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryRecord extends TypeFactoryType {\n\t/**\n\t * {@inheritDoc TypeFactoryType._kind}\n\t */\n\treadonly _kind: \"record\";\n\t/**\n\t * The type of the record's keys.\n\t */\n\treadonly keyType: TypeFactoryType;\n\t/**\n\t * The type of the record's values.\n\t */\n\treadonly valueType: TypeFactoryType;\n}\n\n/**\n * Represents a Map type in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryMap extends TypeFactoryType {\n\t/**\n\t * {@inheritDoc TypeFactoryType._kind}\n\t */\n\treadonly _kind: \"map\";\n\t/**\n\t * The type of the map's keys.\n\t */\n\treadonly keyType: TypeFactoryType;\n\t/**\n\t * The type of the map's values.\n\t */\n\treadonly valueType: TypeFactoryType;\n}\n\n/**\n * Represents a tuple type with fixed-length items and optional rest elements in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryTuple extends TypeFactoryType {\n\t/**\n\t * {@inheritDoc TypeFactoryType._kind}\n\t */\n\treadonly _kind: \"tuple\";\n\t/**\n\t * The fixed-length items in the tuple.\n\t */\n\treadonly items: readonly TypeFactoryType[];\n\t/**\n\t * Optional rest element type for variable-length tuples.\n\t */\n\treadonly rest?: TypeFactoryType;\n}\n\n/**\n * Represents a union type in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryUnion extends TypeFactoryType {\n\t/**\n\t * {@inheritDoc TypeFactoryType._kind}\n\t */\n\treadonly _kind: \"union\";\n\t/**\n\t * The possible types in the union.\n\t */\n\treadonly options: readonly TypeFactoryType[];\n}\n\n/**\n * Represents a literal type (specific string, number, or boolean value) in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryLiteral extends TypeFactoryType {\n\t/**\n\t * {@inheritDoc TypeFactoryType._kind}\n\t */\n\treadonly _kind: \"literal\";\n\t/**\n\t * The specific literal value.\n\t */\n\treadonly value: string | number | boolean;\n}\n\n/**\n * Represents an optional type modifier in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryOptional extends TypeFactoryType {\n\t/**\n\t * {@inheritDoc TypeFactoryType._kind}\n\t */\n\treadonly _kind: \"optional\";\n\t/**\n\t * The inner type that is optional.\n\t */\n\treadonly innerType: TypeFactoryType;\n}\n\n/**\n * Represents a readonly type modifier in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryReadonly extends TypeFactoryType {\n\t/**\n\t * {@inheritDoc TypeFactoryType._kind}\n\t */\n\treadonly _kind: \"readonly\";\n\t/**\n\t * The inner type that is readonly.\n\t */\n\treadonly innerType: TypeFactoryType;\n}\n\n/**\n * Represents an instanceof type that references a SharedTree schema class in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryInstanceOf extends TypeFactoryType {\n\t/**\n\t * {@inheritDoc TypeFactoryType._kind}\n\t */\n\treadonly _kind: \"instanceof\";\n\t/**\n\t * The SharedTree schema class to reference.\n\t */\n\treadonly schema: ObjectNodeSchema;\n}\n\n/**\n * Namespace containing type factory functions.\n * @alpha\n */\nexport const typeFactory = {\n\t/**\n\t * Create a string type.\n\t * @alpha\n\t */\n\tstring(): TypeFactoryString {\n\t\treturn { _kind: \"string\" };\n\t},\n\n\t/**\n\t * Create a number type.\n\t * @alpha\n\t */\n\tnumber(): TypeFactoryNumber {\n\t\treturn { _kind: \"number\" };\n\t},\n\n\t/**\n\t * Create a boolean type.\n\t * @alpha\n\t */\n\tboolean(): TypeFactoryBoolean {\n\t\treturn { _kind: \"boolean\" };\n\t},\n\n\t/**\n\t * Create a void type.\n\t * @alpha\n\t */\n\tvoid(): TypeFactoryVoid {\n\t\treturn { _kind: \"void\" };\n\t},\n\n\t/**\n\t * Create an undefined type.\n\t * @alpha\n\t */\n\tundefined(): TypeFactoryUndefined {\n\t\treturn { _kind: \"undefined\" };\n\t},\n\n\t/**\n\t * Create a null type.\n\t * @alpha\n\t */\n\tnull(): TypeFactoryNull {\n\t\treturn { _kind: \"null\" };\n\t},\n\n\t/**\n\t * Create an unknown type.\n\t * @alpha\n\t */\n\tunknown(): TypeFactoryUnknown {\n\t\treturn { _kind: \"unknown\" };\n\t},\n\n\t/**\n\t * Create an array type.\n\t * @alpha\n\t */\n\tarray(element: TypeFactoryType): TypeFactoryArray {\n\t\treturn { _kind: \"array\", element };\n\t},\n\n\t/**\n\t * Create an object type.\n\t * @alpha\n\t */\n\tobject(shape: Record<string, TypeFactoryType>): TypeFactoryObject {\n\t\treturn { _kind: \"object\", shape };\n\t},\n\n\t/**\n\t * Create a record type.\n\t * @alpha\n\t */\n\trecord(keyType: TypeFactoryType, valueType: TypeFactoryType): TypeFactoryRecord {\n\t\treturn { _kind: \"record\", keyType, valueType };\n\t},\n\n\t/**\n\t * Create a map type.\n\t * @alpha\n\t */\n\tmap(keyType: TypeFactoryType, valueType: TypeFactoryType): TypeFactoryMap {\n\t\treturn { _kind: \"map\", keyType, valueType };\n\t},\n\n\t/**\n\t * Create a tuple type.\n\t * @alpha\n\t */\n\ttuple(items: readonly TypeFactoryType[], rest?: TypeFactoryType): TypeFactoryTuple {\n\t\tif (items.length === 0 && rest === undefined) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"typeFactory.tuple requires at least one item or a rest type. Empty tuples are not supported.\",\n\t\t\t);\n\t\t}\n\t\treturn rest === undefined ? { _kind: \"tuple\", items } : { _kind: \"tuple\", items, rest };\n\t},\n\n\t/**\n\t * Create a union type.\n\t * @alpha\n\t */\n\tunion(options: readonly TypeFactoryType[]): TypeFactoryUnion {\n\t\tif (options.length === 0) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"typeFactory.union requires at least one option. Empty unions are not valid TypeScript types.\",\n\t\t\t);\n\t\t}\n\t\treturn { _kind: \"union\", options };\n\t},\n\n\t/**\n\t * Create a literal type.\n\t * @alpha\n\t */\n\tliteral(value: string | number | boolean): TypeFactoryLiteral {\n\t\treturn { _kind: \"literal\", value };\n\t},\n\n\t/**\n\t * Create an optional type.\n\t * @alpha\n\t */\n\toptional(innerType: TypeFactoryType): TypeFactoryOptional {\n\t\treturn { _kind: \"optional\", innerType };\n\t},\n\n\t/**\n\t * Create a readonly type.\n\t * @alpha\n\t */\n\treadonly(innerType: TypeFactoryType): TypeFactoryReadonly {\n\t\treturn { _kind: \"readonly\", innerType };\n\t},\n\n\t/**\n\t * Create an instanceOf type for a SharedTree schema class.\n\t * @alpha\n\t */\n\tinstanceOf<T extends TreeNodeSchemaClass>(schema: T): TypeFactoryInstanceOf {\n\t\tif (!(schema instanceof ObjectNodeSchema)) {\n\t\t\tthrow new UsageError(\n\t\t\t\t`typeFactory.instanceOf only supports ObjectNodeSchema-based schema classes (created via SchemaFactory.object). ` +\n\t\t\t\t\t`Pass a schema class that extends from an object schema (e.g., sf.object(...)), not primitive, array, or map schemas.`,\n\t\t\t);\n\t\t}\n\t\tconst instanceOfType: TypeFactoryInstanceOf = {\n\t\t\t_kind: \"instanceof\",\n\t\t\tschema,\n\t\t};\n\t\tinstanceOfsTypeFactory.set(instanceOfType, schema);\n\t\treturn instanceOfType;\n\t},\n};\n\n/**\n * A lookup from type factory instanceOf types to their corresponding ObjectNodeSchema.\n * @alpha\n */\nexport const instanceOfsTypeFactory = new WeakMap<TypeFactoryInstanceOf, ObjectNodeSchema>();\n"]}
package/lib/utils.d.ts CHANGED
@@ -13,10 +13,6 @@ export interface MapGetSet<K, V> {
13
13
  get(key: K): V | undefined;
14
14
  set(key: K, value: V): void;
15
15
  }
16
- /**
17
- * TBD
18
- */
19
- export declare function fail(message: string): never;
20
16
  /**
21
17
  * Map one iterable to another by transforming each element one at a time
22
18
  * @param iterable - the iterable to transform
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,KAAK,EACX,iBAAiB,EACjB,QAAQ,EACR,cAAc,EAEd,MA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E,OAAO,GAAG,MAAM,CASpD"}
package/lib/utils.js CHANGED
@@ -2,17 +2,11 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { assert } from "@fluidframework/core-utils/internal";
5
+ import { assert, fail } from "@fluidframework/core-utils/internal";
6
6
  import { isFluidHandle } from "@fluidframework/runtime-utils";
7
7
  import { UsageError } from "@fluidframework/telemetry-utils/internal";
8
8
  import { ArrayNodeSchema, MapNodeSchema, RecordNodeSchema, TreeAlpha, } from "@fluidframework/tree/alpha";
9
9
  import { NodeKind, normalizeFieldSchema } from "@fluidframework/tree/internal";
10
- /**
11
- * TBD
12
- */
13
- export function fail(message) {
14
- throw new Error(message);
15
- }
16
10
  /**
17
11
  * Map one iterable to another by transforming each element one at a time
18
12
  * @param iterable - the iterable to transform
@@ -113,7 +107,7 @@ export function getFriendlyName(schema) {
113
107
  ? `Record<string, (${childNames.join(" | ")})>`
114
108
  : `Record<string, ${childNames[0]}>`;
115
109
  }
116
- fail("Unexpected node schema");
110
+ fail(0xcb7 /* Unexpected node schema */);
117
111
  }
118
112
  /**
119
113
  * Returns true if the schema identifier represents a named schema (object, named array, named map, or named record).