@fluidframework/tree-agent 2.81.0-374083 → 2.81.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/CHANGELOG.md +95 -0
  2. package/api-report/tree-agent.alpha.api.md +33 -1
  3. package/dist/alpha.d.ts +5 -0
  4. package/dist/index.d.ts +1 -1
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js.map +1 -1
  7. package/dist/prompt.d.ts +4 -0
  8. package/dist/prompt.d.ts.map +1 -1
  9. package/dist/prompt.js +20 -2
  10. package/dist/prompt.js.map +1 -1
  11. package/dist/renderSchemaTypeScript.d.ts.map +1 -1
  12. package/dist/renderSchemaTypeScript.js +18 -8
  13. package/dist/renderSchemaTypeScript.js.map +1 -1
  14. package/dist/renderTypeFactoryTypeScript.d.ts +1 -1
  15. package/dist/renderTypeFactoryTypeScript.d.ts.map +1 -1
  16. package/dist/renderTypeFactoryTypeScript.js +71 -3
  17. package/dist/renderTypeFactoryTypeScript.js.map +1 -1
  18. package/dist/treeAgentTypes.d.ts +86 -1
  19. package/dist/treeAgentTypes.d.ts.map +1 -1
  20. package/dist/treeAgentTypes.js +37 -0
  21. package/dist/treeAgentTypes.js.map +1 -1
  22. package/lib/alpha.d.ts +5 -0
  23. package/lib/index.d.ts +1 -1
  24. package/lib/index.d.ts.map +1 -1
  25. package/lib/index.js.map +1 -1
  26. package/lib/prompt.d.ts +4 -0
  27. package/lib/prompt.d.ts.map +1 -1
  28. package/lib/prompt.js +20 -2
  29. package/lib/prompt.js.map +1 -1
  30. package/lib/renderSchemaTypeScript.d.ts.map +1 -1
  31. package/lib/renderSchemaTypeScript.js +18 -8
  32. package/lib/renderSchemaTypeScript.js.map +1 -1
  33. package/lib/renderTypeFactoryTypeScript.d.ts +1 -1
  34. package/lib/renderTypeFactoryTypeScript.d.ts.map +1 -1
  35. package/lib/renderTypeFactoryTypeScript.js +71 -3
  36. package/lib/renderTypeFactoryTypeScript.js.map +1 -1
  37. package/lib/treeAgentTypes.d.ts +86 -1
  38. package/lib/treeAgentTypes.d.ts.map +1 -1
  39. package/lib/treeAgentTypes.js +37 -0
  40. package/lib/treeAgentTypes.js.map +1 -1
  41. package/package.json +10 -10
  42. package/src/index.ts +5 -0
  43. package/src/prompt.ts +21 -2
  44. package/src/renderSchemaTypeScript.ts +18 -8
  45. package/src/renderTypeFactoryTypeScript.ts +82 -2
  46. package/src/treeAgentTypes.ts +121 -0
@@ -9,5 +9,5 @@ export { instanceOfsTypeFactory } from "./treeAgentTypes.js";
9
9
  * Converts type factory type definitions into TypeScript declaration text.
10
10
  * @alpha
11
11
  */
12
- export declare function renderTypeFactoryTypeScript(typeFactoryType: TypeFactoryType, getFriendlyName: (schema: TreeNodeSchema) => string, instanceOfLookup: WeakMap<TypeFactoryType, ObjectNodeSchema>): string;
12
+ export declare function renderTypeFactoryTypeScript(typeFactoryType: TypeFactoryType, getFriendlyName: (schema: TreeNodeSchema) => string, instanceOfLookup: WeakMap<TypeFactoryType, ObjectNodeSchema>, initialIndent?: number): string;
13
13
  //# sourceMappingURL=renderTypeFactoryTypeScript.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"renderTypeFactoryTypeScript.d.ts","sourceRoot":"","sources":["../src/renderTypeFactoryTypeScript.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEnF,OAAO,KAAK,EACX,eAAe,EAUf,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D;;;GAGG;AACH,wBAAgB,2BAA2B,CAC1C,eAAe,EAAE,eAAe,EAChC,eAAe,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,MAAM,EACnD,gBAAgB,EAAE,OAAO,CAAC,eAAe,EAAE,gBAAgB,CAAC,GAC1D,MAAM,CAkNR"}
1
+ {"version":3,"file":"renderTypeFactoryTypeScript.d.ts","sourceRoot":"","sources":["../src/renderTypeFactoryTypeScript.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEnF,OAAO,KAAK,EACX,eAAe,EAaf,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D;;;GAGG;AACH,wBAAgB,2BAA2B,CAC1C,eAAe,EAAE,eAAe,EAChC,eAAe,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,MAAM,EACnD,gBAAgB,EAAE,OAAO,CAAC,eAAe,EAAE,gBAAgB,CAAC,EAC5D,aAAa,GAAE,MAAU,GACvB,MAAM,CA2RR"}
@@ -8,10 +8,10 @@ export { instanceOfsTypeFactory } from "./treeAgentTypes.js";
8
8
  * Converts type factory type definitions into TypeScript declaration text.
9
9
  * @alpha
10
10
  */
11
- export function renderTypeFactoryTypeScript(typeFactoryType, getFriendlyName, instanceOfLookup) {
11
+ export function renderTypeFactoryTypeScript(typeFactoryType, getFriendlyName, instanceOfLookup, initialIndent = 0) {
12
12
  let result = "";
13
- let startOfLine = true;
14
- let indent = 0;
13
+ let startOfLine = false;
14
+ let indent = initialIndent;
15
15
  appendType(typeFactoryType, 0 /* TypePrecedence.Union */);
16
16
  return result;
17
17
  function appendType(type, minPrecedence = 2 /* TypePrecedence.Object */) {
@@ -49,6 +49,10 @@ export function renderTypeFactoryTypeScript(typeFactoryType, getFriendlyName, in
49
49
  append("boolean");
50
50
  return;
51
51
  }
52
+ case "date": {
53
+ append("Date");
54
+ return;
55
+ }
52
56
  case "void": {
53
57
  append("void");
54
58
  return;
@@ -69,6 +73,10 @@ export function renderTypeFactoryTypeScript(typeFactoryType, getFriendlyName, in
69
73
  appendArrayType(type);
70
74
  return;
71
75
  }
76
+ case "promise": {
77
+ appendPromiseType(type);
78
+ return;
79
+ }
72
80
  case "object": {
73
81
  appendObjectType(type);
74
82
  return;
@@ -77,6 +85,10 @@ export function renderTypeFactoryTypeScript(typeFactoryType, getFriendlyName, in
77
85
  appendUnionTypes(type.options, 0 /* TypePrecedence.Union */);
78
86
  return;
79
87
  }
88
+ case "intersection": {
89
+ appendIntersectionTypes(type.types, 1 /* TypePrecedence.Intersection */);
90
+ return;
91
+ }
80
92
  case "tuple": {
81
93
  appendTupleType(type);
82
94
  return;
@@ -101,6 +113,10 @@ export function renderTypeFactoryTypeScript(typeFactoryType, getFriendlyName, in
101
113
  appendReadonlyType(type);
102
114
  return;
103
115
  }
116
+ case "function": {
117
+ appendFunctionType(type);
118
+ return;
119
+ }
104
120
  case "instanceof": {
105
121
  const schema = instanceOfLookup.get(type);
106
122
  if (schema === undefined) {
@@ -118,6 +134,11 @@ export function renderTypeFactoryTypeScript(typeFactoryType, getFriendlyName, in
118
134
  appendType(arrayType.element, 2 /* TypePrecedence.Object */);
119
135
  append("[]");
120
136
  }
137
+ function appendPromiseType(promiseType) {
138
+ append("Promise<");
139
+ appendType(promiseType.innerType, 0 /* TypePrecedence.Union */);
140
+ append(">");
141
+ }
121
142
  function appendObjectType(objectType) {
122
143
  append("{");
123
144
  appendNewLine();
@@ -149,6 +170,16 @@ export function renderTypeFactoryTypeScript(typeFactoryType, getFriendlyName, in
149
170
  first = false;
150
171
  }
151
172
  }
173
+ function appendIntersectionTypes(types, minPrecedence) {
174
+ let first = true;
175
+ for (const innerType of types) {
176
+ if (!first) {
177
+ append(" & ");
178
+ }
179
+ appendType(innerType, minPrecedence);
180
+ first = false;
181
+ }
182
+ }
152
183
  function appendTupleType(tupleType) {
153
184
  append("[");
154
185
  let first = true;
@@ -197,6 +228,40 @@ export function renderTypeFactoryTypeScript(typeFactoryType, getFriendlyName, in
197
228
  appendType(readonlyType.innerType);
198
229
  append(">");
199
230
  }
231
+ function appendFunctionType(functionType) {
232
+ append("(");
233
+ let first = true;
234
+ for (const param of functionType.parameters) {
235
+ if (!first) {
236
+ append(", ");
237
+ }
238
+ const [name, type] = param;
239
+ append(name);
240
+ if (type._kind === "optional") {
241
+ append("?");
242
+ append(": ");
243
+ appendType(type.innerType, 0 /* TypePrecedence.Union */);
244
+ }
245
+ else {
246
+ append(": ");
247
+ appendType(type, 0 /* TypePrecedence.Union */);
248
+ }
249
+ first = false;
250
+ }
251
+ if (functionType.restParameter !== undefined) {
252
+ if (!first) {
253
+ append(", ");
254
+ }
255
+ const [name, type] = functionType.restParameter;
256
+ append("...");
257
+ append(name);
258
+ append(": ");
259
+ appendType(type, 2 /* TypePrecedence.Object */);
260
+ append("[]");
261
+ }
262
+ append(") => ");
263
+ appendType(functionType.returnType, 0 /* TypePrecedence.Union */);
264
+ }
200
265
  }
201
266
  var TypePrecedence;
202
267
  (function (TypePrecedence) {
@@ -209,6 +274,9 @@ function getTypePrecedence(type) {
209
274
  case "union": {
210
275
  return 0 /* TypePrecedence.Union */;
211
276
  }
277
+ case "intersection": {
278
+ return 1 /* TypePrecedence.Intersection */;
279
+ }
212
280
  default: {
213
281
  return 2 /* TypePrecedence.Object */;
214
282
  }
@@ -1 +1 @@
1
- {"version":3,"file":"renderTypeFactoryTypeScript.js","sourceRoot":"","sources":["../src/renderTypeFactoryTypeScript.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAgBtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D;;;GAGG;AACH,MAAM,UAAU,2BAA2B,CAC1C,eAAgC,EAChC,eAAmD,EACnD,gBAA4D;IAE5D,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,WAAW,GAAG,IAAI,CAAC;IACvB,IAAI,MAAM,GAAG,CAAC,CAAC;IAEf,UAAU,CAAC,eAAe,+BAAuB,CAAC;IAClD,OAAO,MAAM,CAAC;IAEd,SAAS,UAAU,CAAC,IAAqB,EAAE,aAAa,gCAAwB;QAC/E,MAAM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AG,CAAC,CAAC;IACb,CAAC;IAED,SAAS,aAAa,CAAC,OAAuB;QAC7C,MAAM,CAAC,MAAM,CAAC,CAAC;QACf,UAAU,CAAC,OAAO,CAAC,OAAO,+BAAuB,CAAC;QAClD,MAAM,CAAC,IAAI,CAAC,CAAC;QACb,UAAU,CAAC,OAAO,CAAC,SAAS,+BAAuB,CAAC;QACpD,MAAM,CAAC,GAAG,CAAC,CAAC;IACb,CAAC;IAED,SAAS,aAAa,CAAC,KAAgC;QACtD,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/B,CAAC;IAED,SAAS,kBAAkB,CAAC,YAAiC;QAC5D,MAAM,CAAC,WAAW,CAAC,CAAC;QACpB,UAAU,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QACnC,MAAM,CAAC,GAAG,CAAC,CAAC;IACb,CAAC;AACF,CAAC;AAED,IAAW,cAIV;AAJD,WAAW,cAAc;IACxB,qDAAS,CAAA;IACT,mEAAgB,CAAA;IAChB,uDAAU,CAAA;AACX,CAAC,EAJU,cAAc,KAAd,cAAc,QAIxB;AAED,SAAS,iBAAiB,CAAC,IAAqB;IAC/C,QAAQ,IAAI,CAAC,KAAK,EAAE,CAAC;QACpB,KAAK,OAAO,CAAC,CAAC,CAAC;YACd,oCAA4B;QAC7B,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACT,qCAA6B;QAC9B,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["/*!\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 { ObjectNodeSchema, TreeNodeSchema } from \"@fluidframework/tree/alpha\";\n\nimport type {\n\tTypeFactoryType,\n\tTypeFactoryArray,\n\tTypeFactoryObject,\n\tTypeFactoryTuple,\n\tTypeFactoryRecord,\n\tTypeFactoryMap,\n\tTypeFactoryLiteral,\n\tTypeFactoryOptional,\n\tTypeFactoryReadonly,\n\tTypeFactoryUnion,\n} from \"./treeAgentTypes.js\";\n\nexport { instanceOfsTypeFactory } from \"./treeAgentTypes.js\";\n\n/**\n * Converts type factory type definitions into TypeScript declaration text.\n * @alpha\n */\nexport function renderTypeFactoryTypeScript(\n\ttypeFactoryType: TypeFactoryType,\n\tgetFriendlyName: (schema: TreeNodeSchema) => string,\n\tinstanceOfLookup: WeakMap<TypeFactoryType, ObjectNodeSchema>,\n): string {\n\tlet result = \"\";\n\tlet startOfLine = true;\n\tlet indent = 0;\n\n\tappendType(typeFactoryType, TypePrecedence.Union);\n\treturn result;\n\n\tfunction appendType(type: TypeFactoryType, minPrecedence = TypePrecedence.Object): void {\n\t\tconst shouldParenthesize = getTypePrecedence(type) < minPrecedence;\n\t\tif (shouldParenthesize) {\n\t\t\tappend(\"(\");\n\t\t}\n\t\tappendTypeDefinition(type);\n\t\tif (shouldParenthesize) {\n\t\t\tappend(\")\");\n\t\t}\n\t}\n\n\tfunction append(s: string): void {\n\t\tif (startOfLine) {\n\t\t\tresult += \" \".repeat(indent);\n\t\t\tstartOfLine = false;\n\t\t}\n\t\tresult += s;\n\t}\n\n\tfunction appendNewLine(): void {\n\t\tappend(\"\\n\");\n\t\tstartOfLine = true;\n\t}\n\n\tfunction appendTypeDefinition(type: TypeFactoryType): void {\n\t\tswitch (type._kind) {\n\t\t\tcase \"string\": {\n\t\t\t\tappend(\"string\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"number\": {\n\t\t\t\tappend(\"number\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"boolean\": {\n\t\t\t\tappend(\"boolean\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"void\": {\n\t\t\t\tappend(\"void\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"undefined\": {\n\t\t\t\tappend(\"undefined\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"null\": {\n\t\t\t\tappend(\"null\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"unknown\": {\n\t\t\t\tappend(\"unknown\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"array\": {\n\t\t\t\tappendArrayType(type as TypeFactoryArray);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"object\": {\n\t\t\t\tappendObjectType(type as TypeFactoryObject);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"union\": {\n\t\t\t\tappendUnionTypes((type as TypeFactoryUnion).options, TypePrecedence.Union);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"tuple\": {\n\t\t\t\tappendTupleType(type as TypeFactoryTuple);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"record\": {\n\t\t\t\tappendRecordType(type as TypeFactoryRecord);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"map\": {\n\t\t\t\tappendMapType(type as TypeFactoryMap);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"literal\": {\n\t\t\t\tappendLiteral((type as TypeFactoryLiteral).value);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"optional\": {\n\t\t\t\tappendUnionTypes(\n\t\t\t\t\t[(type as TypeFactoryOptional).innerType, { _kind: \"undefined\" }],\n\t\t\t\t\tTypePrecedence.Union,\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"readonly\": {\n\t\t\t\tappendReadonlyType(type as TypeFactoryReadonly);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"instanceof\": {\n\t\t\t\tconst schema = instanceOfLookup.get(type);\n\t\t\t\tif (schema === undefined) {\n\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\"instanceof type not found in lookup - this typically indicates the type was not created via typeFactory.instanceOf\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tappend(getFriendlyName(schema));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new UsageError(\n\t\t\t\t\t`Unsupported type when formatting helper types: ${String(type._kind ?? \"unknown\")}. Expected one of: string, number, boolean, void, undefined, null, unknown, array, object, union, tuple, record, map, literal, optional, readonly, instanceof.`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction appendArrayType(arrayType: TypeFactoryArray): void {\n\t\tappendType(arrayType.element, TypePrecedence.Object);\n\t\tappend(\"[]\");\n\t}\n\n\tfunction appendObjectType(objectType: TypeFactoryObject): void {\n\t\tappend(\"{\");\n\t\tappendNewLine();\n\t\tindent++;\n\t\tfor (const [name, propertyType] of Object.entries(objectType.shape)) {\n\t\t\tappend(name);\n\t\t\tif (propertyType._kind === \"optional\") {\n\t\t\t\tappend(\"?\");\n\t\t\t\tappend(\": \");\n\t\t\t\tappendType((propertyType as TypeFactoryOptional).innerType);\n\t\t\t} else {\n\t\t\t\tappend(\": \");\n\t\t\t\tappendType(propertyType);\n\t\t\t}\n\t\t\tappend(\";\");\n\t\t\tappendNewLine();\n\t\t}\n\t\tindent--;\n\t\tappend(\"}\");\n\t}\n\n\tfunction appendUnionTypes(\n\t\ttypes: readonly TypeFactoryType[],\n\t\tminPrecedence: TypePrecedence,\n\t): void {\n\t\tlet first = true;\n\t\tfor (const innerType of types) {\n\t\t\tif (!first) {\n\t\t\t\tappend(\" | \");\n\t\t\t}\n\t\t\tappendType(innerType, minPrecedence);\n\t\t\tfirst = false;\n\t\t}\n\t}\n\n\tfunction appendTupleType(tupleType: TypeFactoryTuple): void {\n\t\tappend(\"[\");\n\t\tlet first = true;\n\t\tfor (const innerType of tupleType.items) {\n\t\t\tif (!first) {\n\t\t\t\tappend(\", \");\n\t\t\t}\n\t\t\tif (innerType._kind === \"optional\") {\n\t\t\t\tappendType((innerType as TypeFactoryOptional).innerType, TypePrecedence.Object);\n\t\t\t\tappend(\"?\");\n\t\t\t} else {\n\t\t\t\tappendType(innerType);\n\t\t\t}\n\t\t\tfirst = false;\n\t\t}\n\t\tif (tupleType.rest !== undefined) {\n\t\t\tif (!first) {\n\t\t\t\tappend(\", \");\n\t\t\t}\n\t\t\tappend(\"...\");\n\t\t\tappendType(tupleType.rest, TypePrecedence.Object);\n\t\t\tappend(\"[]\");\n\t\t}\n\t\tappend(\"]\");\n\t}\n\n\tfunction appendRecordType(recordType: TypeFactoryRecord): void {\n\t\tappend(\"Record<\");\n\t\tappendType(recordType.keyType, TypePrecedence.Union);\n\t\tappend(\", \");\n\t\tappendType(recordType.valueType, TypePrecedence.Union);\n\t\tappend(\">\");\n\t}\n\n\tfunction appendMapType(mapType: TypeFactoryMap): void {\n\t\tappend(\"Map<\");\n\t\tappendType(mapType.keyType, TypePrecedence.Union);\n\t\tappend(\", \");\n\t\tappendType(mapType.valueType, TypePrecedence.Union);\n\t\tappend(\">\");\n\t}\n\n\tfunction appendLiteral(value: string | number | boolean): void {\n\t\tappend(JSON.stringify(value));\n\t}\n\n\tfunction appendReadonlyType(readonlyType: TypeFactoryReadonly): void {\n\t\tappend(\"Readonly<\");\n\t\tappendType(readonlyType.innerType);\n\t\tappend(\">\");\n\t}\n}\n\nconst enum TypePrecedence {\n\tUnion = 0,\n\tIntersection = 1,\n\tObject = 2,\n}\n\nfunction getTypePrecedence(type: TypeFactoryType): TypePrecedence {\n\tswitch (type._kind) {\n\t\tcase \"union\": {\n\t\t\treturn TypePrecedence.Union;\n\t\t}\n\t\tdefault: {\n\t\t\treturn TypePrecedence.Object;\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"renderTypeFactoryTypeScript.js","sourceRoot":"","sources":["../src/renderTypeFactoryTypeScript.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAmBtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D;;;GAGG;AACH,MAAM,UAAU,2BAA2B,CAC1C,eAAgC,EAChC,eAAmD,EACnD,gBAA4D,EAC5D,gBAAwB,CAAC;IAEzB,IAAI,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C,CAAC;YACd,CAAC;YACD,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,YAAY,CAAC,aAAa,CAAC;YAChD,MAAM,CAAC,KAAK,CAAC,CAAC;YACd,MAAM,CAAC,IAAI,CAAC,CAAC;YACb,MAAM,CAAC,IAAI,CAAC,CAAC;YACb,UAAU,CAAC,IAAI,gCAAwB,CAAC;YACxC,MAAM,CAAC,IAAI,CAAC,CAAC;QACd,CAAC;QACD,MAAM,CAAC,OAAO,CAAC,CAAC;QAChB,UAAU,CAAC,YAAY,CAAC,UAAU,+BAAuB,CAAC;IAC3D,CAAC;AACF,CAAC;AAED,IAAW,cAIV;AAJD,WAAW,cAAc;IACxB,qDAAS,CAAA;IACT,mEAAgB,CAAA;IAChB,uDAAU,CAAA;AACX,CAAC,EAJU,cAAc,KAAd,cAAc,QAIxB;AAED,SAAS,iBAAiB,CAAC,IAAqB;IAC/C,QAAQ,IAAI,CAAC,KAAK,EAAE,CAAC;QACpB,KAAK,OAAO,CAAC,CAAC,CAAC;YACd,oCAA4B;QAC7B,CAAC;QACD,KAAK,cAAc,CAAC,CAAC,CAAC;YACrB,2CAAmC;QACpC,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACT,qCAA6B;QAC9B,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["/*!\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 { ObjectNodeSchema, TreeNodeSchema } from \"@fluidframework/tree/alpha\";\n\nimport type {\n\tTypeFactoryType,\n\tTypeFactoryArray,\n\tTypeFactoryPromise,\n\tTypeFactoryObject,\n\tTypeFactoryTuple,\n\tTypeFactoryRecord,\n\tTypeFactoryMap,\n\tTypeFactoryLiteral,\n\tTypeFactoryOptional,\n\tTypeFactoryReadonly,\n\tTypeFactoryUnion,\n\tTypeFactoryIntersection,\n\tTypeFactoryFunction,\n} from \"./treeAgentTypes.js\";\n\nexport { instanceOfsTypeFactory } from \"./treeAgentTypes.js\";\n\n/**\n * Converts type factory type definitions into TypeScript declaration text.\n * @alpha\n */\nexport function renderTypeFactoryTypeScript(\n\ttypeFactoryType: TypeFactoryType,\n\tgetFriendlyName: (schema: TreeNodeSchema) => string,\n\tinstanceOfLookup: WeakMap<TypeFactoryType, ObjectNodeSchema>,\n\tinitialIndent: number = 0,\n): string {\n\tlet result = \"\";\n\tlet startOfLine = false;\n\tlet indent = initialIndent;\n\n\tappendType(typeFactoryType, TypePrecedence.Union);\n\treturn result;\n\n\tfunction appendType(type: TypeFactoryType, minPrecedence = TypePrecedence.Object): void {\n\t\tconst shouldParenthesize = getTypePrecedence(type) < minPrecedence;\n\t\tif (shouldParenthesize) {\n\t\t\tappend(\"(\");\n\t\t}\n\t\tappendTypeDefinition(type);\n\t\tif (shouldParenthesize) {\n\t\t\tappend(\")\");\n\t\t}\n\t}\n\n\tfunction append(s: string): void {\n\t\tif (startOfLine) {\n\t\t\tresult += \" \".repeat(indent);\n\t\t\tstartOfLine = false;\n\t\t}\n\t\tresult += s;\n\t}\n\n\tfunction appendNewLine(): void {\n\t\tappend(\"\\n\");\n\t\tstartOfLine = true;\n\t}\n\n\tfunction appendTypeDefinition(type: TypeFactoryType): void {\n\t\tswitch (type._kind) {\n\t\t\tcase \"string\": {\n\t\t\t\tappend(\"string\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"number\": {\n\t\t\t\tappend(\"number\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"boolean\": {\n\t\t\t\tappend(\"boolean\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"date\": {\n\t\t\t\tappend(\"Date\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"void\": {\n\t\t\t\tappend(\"void\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"undefined\": {\n\t\t\t\tappend(\"undefined\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"null\": {\n\t\t\t\tappend(\"null\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"unknown\": {\n\t\t\t\tappend(\"unknown\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"array\": {\n\t\t\t\tappendArrayType(type as TypeFactoryArray);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"promise\": {\n\t\t\t\tappendPromiseType(type as TypeFactoryPromise);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"object\": {\n\t\t\t\tappendObjectType(type as TypeFactoryObject);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"union\": {\n\t\t\t\tappendUnionTypes((type as TypeFactoryUnion).options, TypePrecedence.Union);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"intersection\": {\n\t\t\t\tappendIntersectionTypes(\n\t\t\t\t\t(type as TypeFactoryIntersection).types,\n\t\t\t\t\tTypePrecedence.Intersection,\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"tuple\": {\n\t\t\t\tappendTupleType(type as TypeFactoryTuple);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"record\": {\n\t\t\t\tappendRecordType(type as TypeFactoryRecord);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"map\": {\n\t\t\t\tappendMapType(type as TypeFactoryMap);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"literal\": {\n\t\t\t\tappendLiteral((type as TypeFactoryLiteral).value);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"optional\": {\n\t\t\t\tappendUnionTypes(\n\t\t\t\t\t[(type as TypeFactoryOptional).innerType, { _kind: \"undefined\" }],\n\t\t\t\t\tTypePrecedence.Union,\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"readonly\": {\n\t\t\t\tappendReadonlyType(type as TypeFactoryReadonly);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"function\": {\n\t\t\t\tappendFunctionType(type as TypeFactoryFunction);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"instanceof\": {\n\t\t\t\tconst schema = instanceOfLookup.get(type);\n\t\t\t\tif (schema === undefined) {\n\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\"instanceof type not found in lookup - this typically indicates the type was not created via typeFactory.instanceOf\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tappend(getFriendlyName(schema));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new UsageError(\n\t\t\t\t\t`Unsupported type when formatting helper types: ${String(type._kind ?? \"unknown\")}. Expected one of: string, number, boolean, void, undefined, null, unknown, array, object, union, tuple, record, map, literal, optional, readonly, instanceof.`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction appendArrayType(arrayType: TypeFactoryArray): void {\n\t\tappendType(arrayType.element, TypePrecedence.Object);\n\t\tappend(\"[]\");\n\t}\n\n\tfunction appendPromiseType(promiseType: TypeFactoryPromise): void {\n\t\tappend(\"Promise<\");\n\t\tappendType(promiseType.innerType, TypePrecedence.Union);\n\t\tappend(\">\");\n\t}\n\n\tfunction appendObjectType(objectType: TypeFactoryObject): void {\n\t\tappend(\"{\");\n\t\tappendNewLine();\n\t\tindent++;\n\t\tfor (const [name, propertyType] of Object.entries(objectType.shape)) {\n\t\t\tappend(name);\n\t\t\tif (propertyType._kind === \"optional\") {\n\t\t\t\tappend(\"?\");\n\t\t\t\tappend(\": \");\n\t\t\t\tappendType((propertyType as TypeFactoryOptional).innerType);\n\t\t\t} else {\n\t\t\t\tappend(\": \");\n\t\t\t\tappendType(propertyType);\n\t\t\t}\n\t\t\tappend(\";\");\n\t\t\tappendNewLine();\n\t\t}\n\t\tindent--;\n\t\tappend(\"}\");\n\t}\n\n\tfunction appendUnionTypes(\n\t\ttypes: readonly TypeFactoryType[],\n\t\tminPrecedence: TypePrecedence,\n\t): void {\n\t\tlet first = true;\n\t\tfor (const innerType of types) {\n\t\t\tif (!first) {\n\t\t\t\tappend(\" | \");\n\t\t\t}\n\t\t\tappendType(innerType, minPrecedence);\n\t\t\tfirst = false;\n\t\t}\n\t}\n\n\tfunction appendIntersectionTypes(\n\t\ttypes: readonly TypeFactoryType[],\n\t\tminPrecedence: TypePrecedence,\n\t): void {\n\t\tlet first = true;\n\t\tfor (const innerType of types) {\n\t\t\tif (!first) {\n\t\t\t\tappend(\" & \");\n\t\t\t}\n\t\t\tappendType(innerType, minPrecedence);\n\t\t\tfirst = false;\n\t\t}\n\t}\n\n\tfunction appendTupleType(tupleType: TypeFactoryTuple): void {\n\t\tappend(\"[\");\n\t\tlet first = true;\n\t\tfor (const innerType of tupleType.items) {\n\t\t\tif (!first) {\n\t\t\t\tappend(\", \");\n\t\t\t}\n\t\t\tif (innerType._kind === \"optional\") {\n\t\t\t\tappendType((innerType as TypeFactoryOptional).innerType, TypePrecedence.Object);\n\t\t\t\tappend(\"?\");\n\t\t\t} else {\n\t\t\t\tappendType(innerType);\n\t\t\t}\n\t\t\tfirst = false;\n\t\t}\n\t\tif (tupleType.rest !== undefined) {\n\t\t\tif (!first) {\n\t\t\t\tappend(\", \");\n\t\t\t}\n\t\t\tappend(\"...\");\n\t\t\tappendType(tupleType.rest, TypePrecedence.Object);\n\t\t\tappend(\"[]\");\n\t\t}\n\t\tappend(\"]\");\n\t}\n\n\tfunction appendRecordType(recordType: TypeFactoryRecord): void {\n\t\tappend(\"Record<\");\n\t\tappendType(recordType.keyType, TypePrecedence.Union);\n\t\tappend(\", \");\n\t\tappendType(recordType.valueType, TypePrecedence.Union);\n\t\tappend(\">\");\n\t}\n\n\tfunction appendMapType(mapType: TypeFactoryMap): void {\n\t\tappend(\"Map<\");\n\t\tappendType(mapType.keyType, TypePrecedence.Union);\n\t\tappend(\", \");\n\t\tappendType(mapType.valueType, TypePrecedence.Union);\n\t\tappend(\">\");\n\t}\n\n\tfunction appendLiteral(value: string | number | boolean): void {\n\t\tappend(JSON.stringify(value));\n\t}\n\n\tfunction appendReadonlyType(readonlyType: TypeFactoryReadonly): void {\n\t\tappend(\"Readonly<\");\n\t\tappendType(readonlyType.innerType);\n\t\tappend(\">\");\n\t}\n\n\tfunction appendFunctionType(functionType: TypeFactoryFunction): void {\n\t\tappend(\"(\");\n\t\tlet first = true;\n\t\tfor (const param of functionType.parameters) {\n\t\t\tif (!first) {\n\t\t\t\tappend(\", \");\n\t\t\t}\n\t\t\tconst [name, type] = param;\n\t\t\tappend(name);\n\t\t\tif (type._kind === \"optional\") {\n\t\t\t\tappend(\"?\");\n\t\t\t\tappend(\": \");\n\t\t\t\tappendType((type as TypeFactoryOptional).innerType, TypePrecedence.Union);\n\t\t\t} else {\n\t\t\t\tappend(\": \");\n\t\t\t\tappendType(type, TypePrecedence.Union);\n\t\t\t}\n\t\t\tfirst = false;\n\t\t}\n\t\tif (functionType.restParameter !== undefined) {\n\t\t\tif (!first) {\n\t\t\t\tappend(\", \");\n\t\t\t}\n\t\t\tconst [name, type] = functionType.restParameter;\n\t\t\tappend(\"...\");\n\t\t\tappend(name);\n\t\t\tappend(\": \");\n\t\t\tappendType(type, TypePrecedence.Object);\n\t\t\tappend(\"[]\");\n\t\t}\n\t\tappend(\") => \");\n\t\tappendType(functionType.returnType, TypePrecedence.Union);\n\t}\n}\n\nconst enum TypePrecedence {\n\tUnion = 0,\n\tIntersection = 1,\n\tObject = 2,\n}\n\nfunction getTypePrecedence(type: TypeFactoryType): TypePrecedence {\n\tswitch (type._kind) {\n\t\tcase \"union\": {\n\t\t\treturn TypePrecedence.Union;\n\t\t}\n\t\tcase \"intersection\": {\n\t\t\treturn TypePrecedence.Intersection;\n\t\t}\n\t\tdefault: {\n\t\t\treturn TypePrecedence.Object;\n\t\t}\n\t}\n}\n"]}
@@ -8,7 +8,7 @@ import { ObjectNodeSchema } from "@fluidframework/tree/alpha";
8
8
  * Type kinds for the type factory type system.
9
9
  * @alpha
10
10
  */
11
- export type TypeFactoryTypeKind = "string" | "number" | "boolean" | "void" | "undefined" | "null" | "unknown" | "array" | "object" | "record" | "map" | "tuple" | "union" | "literal" | "optional" | "readonly" | "instanceof";
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
12
  /**
13
13
  * Base interface for type factory types.
14
14
  * @alpha
@@ -54,6 +54,16 @@ export interface TypeFactoryBoolean extends TypeFactoryType {
54
54
  */
55
55
  readonly _kind: "boolean";
56
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
+ }
57
67
  /**
58
68
  * Represents a void type in the type factory system.
59
69
  * @alpha
@@ -108,6 +118,20 @@ export interface TypeFactoryArray extends TypeFactoryType {
108
118
  */
109
119
  readonly element: TypeFactoryType;
110
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
+ }
111
135
  /**
112
136
  * Represents an object type with a fixed shape in the type factory system.
113
137
  * @alpha
@@ -190,6 +214,20 @@ export interface TypeFactoryUnion extends TypeFactoryType {
190
214
  */
191
215
  readonly options: readonly TypeFactoryType[];
192
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
+ }
193
231
  /**
194
232
  * Represents a literal type (specific string, number, or boolean value) in the type factory system.
195
233
  * @alpha
@@ -232,6 +270,33 @@ export interface TypeFactoryReadonly extends TypeFactoryType {
232
270
  */
233
271
  readonly innerType: TypeFactoryType;
234
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
+ }
235
300
  /**
236
301
  * Represents an instanceof type that references a SharedTree schema class in the type factory system.
237
302
  * @alpha
@@ -266,6 +331,11 @@ export declare const typeFactory: {
266
331
  * @alpha
267
332
  */
268
333
  boolean(): TypeFactoryBoolean;
334
+ /**
335
+ * Create a Date type.
336
+ * @alpha
337
+ */
338
+ date(): TypeFactoryDate;
269
339
  /**
270
340
  * Create a void type.
271
341
  * @alpha
@@ -291,6 +361,11 @@ export declare const typeFactory: {
291
361
  * @alpha
292
362
  */
293
363
  array(element: TypeFactoryType): TypeFactoryArray;
364
+ /**
365
+ * Create a Promise type.
366
+ * @alpha
367
+ */
368
+ promise(innerType: TypeFactoryType): TypeFactoryPromise;
294
369
  /**
295
370
  * Create an object type.
296
371
  * @alpha
@@ -316,6 +391,11 @@ export declare const typeFactory: {
316
391
  * @alpha
317
392
  */
318
393
  union(options: readonly TypeFactoryType[]): TypeFactoryUnion;
394
+ /**
395
+ * Create an intersection type.
396
+ * @alpha
397
+ */
398
+ intersection(types: readonly TypeFactoryType[]): TypeFactoryIntersection;
319
399
  /**
320
400
  * Create a literal type.
321
401
  * @alpha
@@ -331,6 +411,11 @@ export declare const typeFactory: {
331
411
  * @alpha
332
412
  */
333
413
  readonly(innerType: TypeFactoryType): TypeFactoryReadonly;
414
+ /**
415
+ * Create a function type.
416
+ * @alpha
417
+ */
418
+ function(parameters: readonly TypeFactoryFunctionParameter[], returnType: TypeFactoryType, restParameter?: TypeFactoryFunctionParameter): TypeFactoryFunction;
334
419
  /**
335
420
  * Create an instanceOf type for a SharedTree schema class.
336
421
  * @alpha
@@ -1 +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;IAC/B;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,mBAAmB,CAAC;CACpC;AA0BD;;;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;;OA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,eAAe,kBACX,4BAA4B,GAC1C,mBAAmB;IAMtB;;;OAGG;sDAC+C,CAAC,GAAG,qBAAqB;CAc3E,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,sBAAsB,oMAAyD,CAAC"}
@@ -16,15 +16,19 @@ const validTypeKinds = new Set([
16
16
  "undefined",
17
17
  "null",
18
18
  "unknown",
19
+ "date",
20
+ "promise",
19
21
  "array",
20
22
  "object",
21
23
  "record",
22
24
  "map",
23
25
  "tuple",
24
26
  "union",
27
+ "intersection",
25
28
  "literal",
26
29
  "optional",
27
30
  "readonly",
31
+ "function",
28
32
  "instanceof",
29
33
  ]);
30
34
  /**
@@ -64,6 +68,13 @@ export const typeFactory = {
64
68
  boolean() {
65
69
  return { _kind: "boolean" };
66
70
  },
71
+ /**
72
+ * Create a Date type.
73
+ * @alpha
74
+ */
75
+ date() {
76
+ return { _kind: "date" };
77
+ },
67
78
  /**
68
79
  * Create a void type.
69
80
  * @alpha
@@ -99,6 +110,13 @@ export const typeFactory = {
99
110
  array(element) {
100
111
  return { _kind: "array", element };
101
112
  },
113
+ /**
114
+ * Create a Promise type.
115
+ * @alpha
116
+ */
117
+ promise(innerType) {
118
+ return { _kind: "promise", innerType };
119
+ },
102
120
  /**
103
121
  * Create an object type.
104
122
  * @alpha
@@ -140,6 +158,16 @@ export const typeFactory = {
140
158
  }
141
159
  return { _kind: "union", options };
142
160
  },
161
+ /**
162
+ * Create an intersection type.
163
+ * @alpha
164
+ */
165
+ intersection(types) {
166
+ if (types.length === 0) {
167
+ throw new UsageError("typeFactory.intersection requires at least one type. Empty intersections are not valid TypeScript types.");
168
+ }
169
+ return { _kind: "intersection", types };
170
+ },
143
171
  /**
144
172
  * Create a literal type.
145
173
  * @alpha
@@ -161,6 +189,15 @@ export const typeFactory = {
161
189
  readonly(innerType) {
162
190
  return { _kind: "readonly", innerType };
163
191
  },
192
+ /**
193
+ * Create a function type.
194
+ * @alpha
195
+ */
196
+ function(parameters, returnType, restParameter) {
197
+ return restParameter === undefined
198
+ ? { _kind: "function", parameters, returnType }
199
+ : { _kind: "function", parameters, returnType, restParameter };
200
+ },
164
201
  /**
165
202
  * Create an instanceOf type for a SharedTree schema class.
166
203
  * @alpha
@@ -1 +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;;;OAGG;IACH,MAAM;QACL,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACH,MAAM;QACL,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACH,OAAO;QACN,OAAO,EAAE,KA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C;IACzF,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,OAAmC;QACxC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC1B,MAAM,IAAI,UAAU,CACnB,8FAA8F,CAC9F,CAAC;QACH,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;IACpC,CAAC;IAED;;;OAGG;IACH,OAAO,CAAC,KAAgC;QACvC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;IACpC,CAAC;IAED;;;OAGG;IACH,QAAQ,CAAC,SAA0B;QAClC,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;IACzC,CAAC;IAED;;;OAGG;IACH,QAAQ,CAAC,SAA0B;QAClC,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;IACzC,CAAC;IAED;;;OAGG;IACH,UAAU,CAAgC,MAAS;QAClD,IAAI,CAAC,CAAC,MAAM,YAAY,gBAAgB,CAAC,EAAE,CAAC;YAC3C,MAAM,IAAI,UAAU,CACnB,iHAAiH;gBAChH,sHAAsH,CACvH,CAAC;QACH,CAAC;QACD,MAAM,cAAc,GAA0B;YAC7C,KAAK,EAAE,YAAY;YACnB,MAAM;SACN,CAAC;QACF,sBAAsB,CAAC,GAAG,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;QACnD,OAAO,cAAc,CAAC;IACvB,CAAC;CACD,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,OAAO,EAA2C,CAAC","sourcesContent":["/*!\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"]}
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;AAwC9D;;;GAGG;AACH,MAAM,cAAc,GAAqC,IAAI,GAAG,CAAsB;IACrF,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,MAAM;IACN,WAAW;IACX,MAAM;IACN,SAAS;IACT,MAAM;IACN,SAAS;IACT,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,KAAK;IACL,OAAO;IACP,OAAO;IACP,cAAc;IACd,SAAS;IACT,UAAU;IACV,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,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AAC;IACpC,CAAC;IAED;;;OAGG;IACH,QAAQ,CAAC,SAA0B;QAClC,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;IACzC,CAAC;IAED;;;OAGG;IACH,QAAQ,CAAC,SAA0B;QAClC,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;IACzC,CAAC;IAED;;;OAGG;IACH,QAAQ,CACP,UAAmD,EACnD,UAA2B,EAC3B,aAA4C;QAE5C,OAAO,aAAa,KAAK,SAAS;YACjC,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE;YAC/C,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC;IACjE,CAAC;IAED;;;OAGG;IACH,UAAU,CAAgC,MAAS;QAClD,IAAI,CAAC,CAAC,MAAM,YAAY,gBAAgB,CAAC,EAAE,CAAC;YAC3C,MAAM,IAAI,UAAU,CACnB,iHAAiH;gBAChH,sHAAsH,CACvH,CAAC;QACH,CAAC;QACD,MAAM,cAAc,GAA0B;YAC7C,KAAK,EAAE,YAAY;YACnB,MAAM;SACN,CAAC;QACF,sBAAsB,CAAC,GAAG,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;QACnD,OAAO,cAAc,CAAC;IACvB,CAAC;CACD,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,OAAO,EAA2C,CAAC","sourcesContent":["/*!\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| \"date\"\n\t| \"promise\"\n\t| \"array\"\n\t| \"object\"\n\t| \"record\"\n\t| \"map\"\n\t| \"tuple\"\n\t| \"union\"\n\t| \"intersection\"\n\t| \"literal\"\n\t| \"optional\"\n\t| \"readonly\"\n\t| \"function\"\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\"date\",\n\t\"promise\",\n\t\"array\",\n\t\"object\",\n\t\"record\",\n\t\"map\",\n\t\"tuple\",\n\t\"union\",\n\t\"intersection\",\n\t\"literal\",\n\t\"optional\",\n\t\"readonly\",\n\t\"function\",\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 Date type in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryDate extends TypeFactoryType {\n\t/**\n\t * {@inheritDoc TypeFactoryType._kind}\n\t */\n\treadonly _kind: \"date\";\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 a Promise type in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryPromise extends TypeFactoryType {\n\t/**\n\t * {@inheritDoc TypeFactoryType._kind}\n\t */\n\treadonly _kind: \"promise\";\n\t/**\n\t * The type that the Promise resolves to.\n\t */\n\treadonly innerType: 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 an intersection type in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryIntersection extends TypeFactoryType {\n\t/**\n\t * {@inheritDoc TypeFactoryType._kind}\n\t */\n\treadonly _kind: \"intersection\";\n\t/**\n\t * The types to intersect.\n\t */\n\treadonly types: 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 a function parameter as a tuple of [name, type].\n * @alpha\n */\nexport type TypeFactoryFunctionParameter = readonly [name: string, type: TypeFactoryType];\n\n/**\n * Represents a function type in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryFunction extends TypeFactoryType {\n\t/**\n\t * {@inheritDoc TypeFactoryType._kind}\n\t */\n\treadonly _kind: \"function\";\n\t/**\n\t * The function parameters.\n\t */\n\treadonly parameters: readonly TypeFactoryFunctionParameter[];\n\t/**\n\t * The function return type.\n\t */\n\treadonly returnType: TypeFactoryType;\n\t/**\n\t * Optional rest parameter for variable-length argument lists.\n\t */\n\treadonly restParameter?: TypeFactoryFunctionParameter;\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 Date type.\n\t * @alpha\n\t */\n\tdate(): TypeFactoryDate {\n\t\treturn { _kind: \"date\" };\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 a Promise type.\n\t * @alpha\n\t */\n\tpromise(innerType: TypeFactoryType): TypeFactoryPromise {\n\t\treturn { _kind: \"promise\", innerType };\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 an intersection type.\n\t * @alpha\n\t */\n\tintersection(types: readonly TypeFactoryType[]): TypeFactoryIntersection {\n\t\tif (types.length === 0) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"typeFactory.intersection requires at least one type. Empty intersections are not valid TypeScript types.\",\n\t\t\t);\n\t\t}\n\t\treturn { _kind: \"intersection\", types };\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 a function type.\n\t * @alpha\n\t */\n\tfunction(\n\t\tparameters: readonly TypeFactoryFunctionParameter[],\n\t\treturnType: TypeFactoryType,\n\t\trestParameter?: TypeFactoryFunctionParameter,\n\t): TypeFactoryFunction {\n\t\treturn restParameter === undefined\n\t\t\t? { _kind: \"function\", parameters, returnType }\n\t\t\t: { _kind: \"function\", parameters, returnType, restParameter };\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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/tree-agent",
3
- "version": "2.81.0-374083",
3
+ "version": "2.81.1",
4
4
  "description": "Experimental package to simplify integrating AI into Fluid-based applications",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -70,24 +70,24 @@
70
70
  },
71
71
  "dependencies": {
72
72
  "@anthropic-ai/sdk": "^0.39.0",
73
- "@fluidframework/core-utils": "2.81.0-374083",
74
- "@fluidframework/runtime-utils": "2.81.0-374083",
75
- "@fluidframework/telemetry-utils": "2.81.0-374083",
76
- "@fluidframework/tree": "2.81.0-374083",
73
+ "@fluidframework/core-utils": "~2.81.1",
74
+ "@fluidframework/runtime-utils": "~2.81.1",
75
+ "@fluidframework/telemetry-utils": "~2.81.1",
76
+ "@fluidframework/tree": "~2.81.1",
77
77
  "uuid": "^11.1.0",
78
78
  "zod": "^3.25.32"
79
79
  },
80
80
  "devDependencies": {
81
81
  "@arethetypeswrong/cli": "^0.18.2",
82
82
  "@biomejs/biome": "~1.9.3",
83
- "@fluid-internal/mocha-test-setup": "2.81.0-374083",
83
+ "@fluid-internal/mocha-test-setup": "~2.81.1",
84
84
  "@fluid-tools/build-cli": "^0.63.0",
85
85
  "@fluidframework/build-common": "^2.0.3",
86
86
  "@fluidframework/build-tools": "^0.63.0",
87
- "@fluidframework/eslint-config-fluid": "2.81.0-374083",
88
- "@fluidframework/id-compressor": "2.81.0-374083",
89
- "@fluidframework/runtime-utils": "2.81.0-374083",
90
- "@fluidframework/test-runtime-utils": "2.81.0-374083",
87
+ "@fluidframework/eslint-config-fluid": "~2.81.1",
88
+ "@fluidframework/id-compressor": "~2.81.1",
89
+ "@fluidframework/runtime-utils": "~2.81.1",
90
+ "@fluidframework/test-runtime-utils": "~2.81.1",
91
91
  "@langchain/anthropic": "^0.3.24",
92
92
  "@langchain/core": "^0.3.78",
93
93
  "@langchain/google-genai": "^0.2.16",
package/src/index.ts CHANGED
@@ -66,18 +66,23 @@ export type {
66
66
  TypeFactoryString,
67
67
  TypeFactoryNumber,
68
68
  TypeFactoryBoolean,
69
+ TypeFactoryDate,
69
70
  TypeFactoryVoid,
70
71
  TypeFactoryUndefined,
71
72
  TypeFactoryNull,
72
73
  TypeFactoryUnknown,
73
74
  TypeFactoryArray,
75
+ TypeFactoryPromise,
74
76
  TypeFactoryObject,
75
77
  TypeFactoryRecord,
76
78
  TypeFactoryMap,
77
79
  TypeFactoryTuple,
78
80
  TypeFactoryUnion,
81
+ TypeFactoryIntersection,
79
82
  TypeFactoryLiteral,
80
83
  TypeFactoryOptional,
81
84
  TypeFactoryReadonly,
85
+ TypeFactoryFunction,
86
+ TypeFactoryFunctionParameter,
82
87
  TypeFactoryInstanceOf,
83
88
  } from "./treeAgentTypes.js";