@fluidframework/tree-agent 2.74.0 → 2.81.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/CHANGELOG.md +99 -0
  2. package/api-report/tree-agent.alpha.api.md +195 -20
  3. package/dist/alpha.d.ts +31 -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 +24 -9
  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 +290 -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 +430 -0
  26. package/dist/treeAgentTypes.d.ts.map +1 -0
  27. package/dist/treeAgentTypes.js +227 -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 +31 -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 +24 -9
  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 +285 -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 +430 -0
  57. package/lib/treeAgentTypes.d.ts.map +1 -0
  58. package/lib/treeAgentTypes.js +223 -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 +36 -0
  66. package/src/methodBinding.ts +94 -15
  67. package/src/propertyBinding.ts +66 -9
  68. package/src/renderSchemaTypeScript.ts +32 -10
  69. package/src/renderTypeFactoryTypeScript.ts +339 -0
  70. package/src/subtree.ts +6 -5
  71. package/src/treeAgentTypes.ts +611 -0
  72. package/src/utils.ts +2 -9
  73. package/.eslintrc.cjs +0 -48
@@ -0,0 +1 @@
1
+ {"version":3,"file":"treeAgentTypes.js","sourceRoot":"","sources":["../src/treeAgentTypes.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,uEAAsE;AAEtE,sDAA8D;AAwC9D;;;GAGG;AACH,MAAM,cAAc,GAAqC,IAAI,GAAG,CAAsB;IACrF,QAAQ;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C;CACD,CAAC;AAEF;;;GAGG;AACU,QAAA,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/dist/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,MAAM,4BAA4B,CAAC;AASpC;;;;GAIG;AACH,MAAM,WAAW,SAAS,CAAC,CAAC,EAAE,CAAC;IAC9B,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;IAC3B,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,CAE3C;AAED;;;;;;;GAOG;AACH,wBAAiB,WAAW,CAAC,CAAC,EAAE,CAAC,EAChC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EACrB,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,GACd,gBAAgB,CAAC,CAAC,CAAC,CAIrB;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,EAC/B,GAAG,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EACp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,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,iBAAiB,GAAG,QAAQ,CAOxF;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAoB9D;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAU/D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,gBAAgB,EAAE,MAAM,GAAG,MAAM,CAehE;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAC1B,MAAM,EAAE,mBAAmB,EAC3B,MAAM,GAAE,CAAC,MAAM,EAAE,cAAc,KAAK,OAAoB,EACxD,OAAO,sBAA4B,GACjC,GAAG,CAAC,cAAc,CAAC,CAUrB;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CASpD"}
package/dist/utils.js CHANGED
@@ -4,19 +4,12 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.toErrorString = exports.communize = exports.findSchemas = exports.unqualifySchema = exports.isNamedSchema = exports.getFriendlyName = exports.constructNode = exports.failUsage = exports.llmDefault = exports.hasAtLeastTwo = exports.tryGetSingleton = exports.getOrCreate = exports.mapIterable = exports.fail = void 0;
7
+ exports.toErrorString = exports.communize = exports.findSchemas = exports.unqualifySchema = exports.isNamedSchema = exports.getFriendlyName = exports.constructNode = exports.failUsage = exports.llmDefault = exports.hasAtLeastTwo = exports.tryGetSingleton = exports.getOrCreate = exports.mapIterable = void 0;
8
8
  const internal_1 = require("@fluidframework/core-utils/internal");
9
9
  const runtime_utils_1 = require("@fluidframework/runtime-utils");
10
10
  const internal_2 = require("@fluidframework/telemetry-utils/internal");
11
11
  const alpha_1 = require("@fluidframework/tree/alpha");
12
12
  const internal_3 = require("@fluidframework/tree/internal");
13
- /**
14
- * TBD
15
- */
16
- function fail(message) {
17
- throw new Error(message);
18
- }
19
- exports.fail = fail;
20
13
  /**
21
14
  * Map one iterable to another by transforming each element one at a time
22
15
  * @param iterable - the iterable to transform
@@ -123,7 +116,7 @@ function getFriendlyName(schema) {
123
116
  ? `Record<string, (${childNames.join(" | ")})>`
124
117
  : `Record<string, ${childNames[0]}>`;
125
118
  }
126
- fail("Unexpected node schema");
119
+ (0, internal_1.fail)(0xcb7 /* Unexpected node schema */);
127
120
  }
128
121
  exports.getFriendlyName = getFriendlyName;
129
122
  /**
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAC7D,iEAA8D;AAC9D,uEAAsE;AAQtE,sDAKoC;AACpC,4DAA+E;AAY/E;;GAEG;AACH,SAAgB,IAAI,CAAC,OAAe;IACnC,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;AAC1B,CAAC;AAFD,oBAEC;AAED;;;;;;;GAOG;AACH,QAAe,CAAC,CAAC,WAAW,CAC3B,QAAqB,EACrB,GAAgB;IAEhB,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;QAC1B,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;IACd,CAAC;AACF,CAAC;AAPD,kCAOC;AAED;;;;;;;;GAQG;AACH,SAAgB,WAAW,CAC1B,GAAoB,EACpB,GAAM,EACN,YAA2B;IAE3B,IAAI,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACzB,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACzB,KAAK,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;QAC1B,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAX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AC3C,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAC,OAAO,CAAC;IACtB,CAAC;IACD,IAAI,CAAC;QACJ,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;AACF,CAAC;AATD,sCASC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { isFluidHandle } from \"@fluidframework/runtime-utils\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport type { ImplicitFieldSchema } from \"@fluidframework/tree\";\nimport type {\n\tInsertableContent,\n\tTreeNode,\n\tTreeNodeSchema,\n\tUnsafeUnknownSchema,\n} from \"@fluidframework/tree/alpha\";\nimport {\n\tArrayNodeSchema,\n\tMapNodeSchema,\n\tRecordNodeSchema,\n\tTreeAlpha,\n} from \"@fluidframework/tree/alpha\";\nimport { NodeKind, normalizeFieldSchema } from \"@fluidframework/tree/internal\";\n\n/**\n * Subset of Map interface.\n *\n * @remarks originally from tree/src/util/utils.ts\n */\nexport interface MapGetSet<K, V> {\n\tget(key: K): V | undefined;\n\tset(key: K, value: V): void;\n}\n\n/**\n * TBD\n */\nexport function fail(message: string): never {\n\tthrow new Error(message);\n}\n\n/**\n * Map one iterable to another by transforming each element one at a time\n * @param iterable - the iterable to transform\n * @param map - the transformation function to run on each element of the iterable\n * @returns a new iterable of elements which have been transformed by the `map` function\n *\n * @remarks originally from tree/src/util/utils.ts\n */\nexport function* mapIterable<T, U>(\n\titerable: Iterable<T>,\n\tmap: (t: T) => U,\n): IterableIterator<U> {\n\tfor (const t of iterable) {\n\t\tyield map(t);\n\t}\n}\n\n/**\n * Retrieve a value from a map with the given key, or create a new entry if the key is not in the map.\n * @param map - The map to query/update\n * @param key - The key to lookup in the map\n * @param defaultValue - a function which returns a default value. This is called and used to set an initial value for the given key in the map if none exists\n * @returns either the existing value for the given key, or the newly-created value (the result of `defaultValue`)\n *\n * @remarks originally from tree/src/util/utils.ts\n */\nexport function getOrCreate<K, V>(\n\tmap: MapGetSet<K, V>,\n\tkey: K,\n\tdefaultValue: (key: K) => V,\n): V {\n\tlet value = map.get(key);\n\tif (value === undefined) {\n\t\tvalue = defaultValue(key);\n\t\tmap.set(key, value);\n\t}\n\treturn value;\n}\n\n/**\n * TODO\n */\nexport function tryGetSingleton<T>(set: ReadonlySet<T>): T | undefined {\n\tif (set.size === 1) {\n\t\tfor (const item of set) {\n\t\t\treturn item;\n\t\t}\n\t}\n}\n\n/**\n * Does it have at least two elements?\n */\nexport function hasAtLeastTwo<T>(array: T[]): array is [T, T, ...T[]] {\n\treturn array.length >= 2;\n}\n\n/**\n * Include this property in a field's schema metadata to indicate that the field's value should be generated via a provided function rather than by the LLM.\n * @example\n * ```ts\n * class Object extends schemaFactory.object(\"Object\", {\n * created: sf.required(sf.number, {\n * custom: {\n * // The LLM will ignore this field, and instead it will be populated with the result of the function\n * [llmDefault]: () => Date.now(),\n * },\n * }),\n * }) {};\n * ```\n * @alpha\n */\nexport const llmDefault = Symbol(\"tree-agent/llmDefault\");\n// TODO: make this a wrapper function instead, and hide the symbol.\n// function llmDefault<T extends FieldSchemaMetadata>(metadata: T): T { ... }\n\n/**\n * Usage fail\n */\nexport function failUsage(message: string): never {\n\tthrow new UsageError(message);\n}\n\n/**\n * Construct an object node from a schema and value.\n */\nexport function constructNode(schema: TreeNodeSchema, value: InsertableContent): TreeNode {\n\tconst node = TreeAlpha.create<UnsafeUnknownSchema>(schema, value);\n\tassert(\n\t\tnode !== undefined && node !== null && typeof node === \"object\" && !isFluidHandle(node),\n\t\t0xc1e /* Expected a constructed node to be an object */,\n\t);\n\treturn node;\n}\n\n/**\n * Returns the unqualified name of a tree value's schema (e.g. a node with schema identifier `\"my.scope.MyNode\"` returns `\"MyNode\"`).\n * @remarks If the schema is an inlined array, map, or record type, then it has no name and this function will return a string representation of the type (e.g., `\"MyNode[]\"` or `\"Map<string, MyNode>\"`).\n */\nexport function getFriendlyName(schema: TreeNodeSchema): string {\n\tif (schema.kind === NodeKind.Leaf || isNamedSchema(schema.identifier)) {\n\t\treturn unqualifySchema(schema.identifier);\n\t}\n\n\tconst childNames = Array.from(schema.childTypes, (t) => getFriendlyName(t));\n\tif (schema instanceof ArrayNodeSchema) {\n\t\treturn childNames.length > 1 ? `(${childNames.join(\" | \")})[]` : `${childNames[0]}[]`;\n\t}\n\tif (schema instanceof MapNodeSchema) {\n\t\treturn childNames.length > 1\n\t\t\t? `Map<string, (${childNames.join(\" | \")})>`\n\t\t\t: `Map<string, ${childNames[0]}>`;\n\t}\n\tif (schema instanceof RecordNodeSchema) {\n\t\treturn childNames.length > 1\n\t\t\t? `Record<string, (${childNames.join(\" | \")})>`\n\t\t\t: `Record<string, ${childNames[0]}>`;\n\t}\n\tfail(\"Unexpected node schema\");\n}\n\n/**\n * Returns true if the schema identifier represents a named schema (object, named array, named map, or named record).\n * @remarks This does not include primitive schemas or inlined array/map/record schemas.\n */\nexport function isNamedSchema(schemaIdentifier: string): boolean {\n\tif (\n\t\t[\"string\", \"number\", \"boolean\", \"null\", \"handle\"].includes(\n\t\t\tunqualifySchema(schemaIdentifier),\n\t\t)\n\t) {\n\t\treturn false;\n\t}\n\n\treturn /(?:Array|Map|Record)<\\[\"(.*)\"]>/.exec(schemaIdentifier) === null;\n}\n\n/**\n * Returns the unqualified, sanitized Typescript-safe name of a schema\n * Examples:\n * - `\"my.scope.MyNode\"` returns `\"MyNode\"`\n * - `\"my.scope.MyNode-2\"` returns `\"MyNode_2\"`\n * - `\"my.scope.MyNode!\"` returns `\"MyNode_\"`\n * @remarks\n * - Removes all characters before the last dot in the schema name.\n * - Sanitizes the remainder into a valid Typescript identifier\n * - If there is a dot in a user's schema name, this might produce unexpected results.\n */\nexport function unqualifySchema(schemaIdentifier: string): string {\n\t// Get the unqualified name by removing the scope (everything before the last dot).\n\tconst matches = /[^.]+$/.exec(schemaIdentifier);\n\tconst unqualifiedName = matches === null ? schemaIdentifier : matches[0];\n\n\tlet sanitizedName = unqualifiedName;\n\n\t// Replace invalid characters with \"_\".\n\tsanitizedName = sanitizedName.replace(/[^\\w$]/g, \"_\");\n\n\t// If the first character is a number, prefix it with \"_\".\n\tif (!/^[$A-Z_a-z]/.test(sanitizedName)) {\n\t\tsanitizedName = `_${sanitizedName}`;\n\t}\n\treturn sanitizedName;\n}\n\n/**\n * Adds all (optionally filtered) schemas reachable from the given schema to the given set.\n * @returns The set of schemas added (same as the `schemas` parameter, if supplied).\n */\nexport function findSchemas(\n\tschema: ImplicitFieldSchema,\n\tfilter: (schema: TreeNodeSchema) => boolean = () => true,\n\tschemas = new Set<TreeNodeSchema>(),\n): Set<TreeNodeSchema> {\n\tfor (const nodeSchema of normalizeFieldSchema(schema).allowedTypeSet) {\n\t\tif (!schemas.has(nodeSchema)) {\n\t\t\tif (filter(nodeSchema)) {\n\t\t\t\tschemas.add(nodeSchema);\n\t\t\t}\n\t\t\tfindSchemas([...nodeSchema.childTypes], filter, schemas);\n\t\t}\n\t}\n\treturn schemas;\n}\n\n/**\n * De-capitalize (the first letter of) a string.\n */\nexport function communize(str: string): string {\n\treturn str.charAt(0).toLowerCase() + str.slice(1);\n}\n\n/**\n * Stringify an unknown error value\n */\nexport function toErrorString(error: unknown): string {\n\tif (error instanceof Error) {\n\t\treturn error.message;\n\t}\n\ttry {\n\t\treturn JSON.stringify(error);\n\t} catch {\n\t\treturn String(error);\n\t}\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAmE;AACnE,iEAA8D;AAC9D,uEAAsE;AAQtE,sDAKoC;AACpC,4DAA+E;AAY/E;;;;;;;GAOG;AACH,QAAe,CAAC,CAAC,WAAW,CAC3B,QAAqB,EACrB,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C;YAC9B,IAAI,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;gBACxB,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YACzB,CAAC;YACD,WAAW,CAAC,CAAC,GAAG,UAAU,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QAC1D,CAAC;IACF,CAAC;IACD,OAAO,OAAO,CAAC;AAChB,CAAC;AAdD,kCAcC;AAED;;GAEG;AACH,SAAgB,SAAS,CAAC,GAAW;IACpC,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACnD,CAAC;AAFD,8BAEC;AAED;;GAEG;AACH,SAAgB,aAAa,CAAC,KAAc;IAC3C,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAC,OAAO,CAAC;IACtB,CAAC;IACD,IAAI,CAAC;QACJ,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;AACF,CAAC;AATD,sCASC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\nimport { isFluidHandle } from \"@fluidframework/runtime-utils\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport type { ImplicitFieldSchema } from \"@fluidframework/tree\";\nimport type {\n\tInsertableContent,\n\tTreeNode,\n\tTreeNodeSchema,\n\tUnsafeUnknownSchema,\n} from \"@fluidframework/tree/alpha\";\nimport {\n\tArrayNodeSchema,\n\tMapNodeSchema,\n\tRecordNodeSchema,\n\tTreeAlpha,\n} from \"@fluidframework/tree/alpha\";\nimport { NodeKind, normalizeFieldSchema } from \"@fluidframework/tree/internal\";\n\n/**\n * Subset of Map interface.\n *\n * @remarks originally from tree/src/util/utils.ts\n */\nexport interface MapGetSet<K, V> {\n\tget(key: K): V | undefined;\n\tset(key: K, value: V): void;\n}\n\n/**\n * Map one iterable to another by transforming each element one at a time\n * @param iterable - the iterable to transform\n * @param map - the transformation function to run on each element of the iterable\n * @returns a new iterable of elements which have been transformed by the `map` function\n *\n * @remarks originally from tree/src/util/utils.ts\n */\nexport function* mapIterable<T, U>(\n\titerable: Iterable<T>,\n\tmap: (t: T) => U,\n): IterableIterator<U> {\n\tfor (const t of iterable) {\n\t\tyield map(t);\n\t}\n}\n\n/**\n * Retrieve a value from a map with the given key, or create a new entry if the key is not in the map.\n * @param map - The map to query/update\n * @param key - The key to lookup in the map\n * @param defaultValue - a function which returns a default value. This is called and used to set an initial value for the given key in the map if none exists\n * @returns either the existing value for the given key, or the newly-created value (the result of `defaultValue`)\n *\n * @remarks originally from tree/src/util/utils.ts\n */\nexport function getOrCreate<K, V>(\n\tmap: MapGetSet<K, V>,\n\tkey: K,\n\tdefaultValue: (key: K) => V,\n): V {\n\tlet value = map.get(key);\n\tif (value === undefined) {\n\t\tvalue = defaultValue(key);\n\t\tmap.set(key, value);\n\t}\n\treturn value;\n}\n\n/**\n * TODO\n */\nexport function tryGetSingleton<T>(set: ReadonlySet<T>): T | undefined {\n\tif (set.size === 1) {\n\t\tfor (const item of set) {\n\t\t\treturn item;\n\t\t}\n\t}\n}\n\n/**\n * Does it have at least two elements?\n */\nexport function hasAtLeastTwo<T>(array: T[]): array is [T, T, ...T[]] {\n\treturn array.length >= 2;\n}\n\n/**\n * Include this property in a field's schema metadata to indicate that the field's value should be generated via a provided function rather than by the LLM.\n * @example\n * ```ts\n * class Object extends schemaFactory.object(\"Object\", {\n * created: sf.required(sf.number, {\n * custom: {\n * // The LLM will ignore this field, and instead it will be populated with the result of the function\n * [llmDefault]: () => Date.now(),\n * },\n * }),\n * }) {};\n * ```\n * @alpha\n */\nexport const llmDefault = Symbol(\"tree-agent/llmDefault\");\n// TODO: make this a wrapper function instead, and hide the symbol.\n// function llmDefault<T extends FieldSchemaMetadata>(metadata: T): T { ... }\n\n/**\n * Usage fail\n */\nexport function failUsage(message: string): never {\n\tthrow new UsageError(message);\n}\n\n/**\n * Construct an object node from a schema and value.\n */\nexport function constructNode(schema: TreeNodeSchema, value: InsertableContent): TreeNode {\n\tconst node = TreeAlpha.create<UnsafeUnknownSchema>(schema, value);\n\tassert(\n\t\tnode !== undefined && node !== null && typeof node === \"object\" && !isFluidHandle(node),\n\t\t0xc1e /* Expected a constructed node to be an object */,\n\t);\n\treturn node;\n}\n\n/**\n * Returns the unqualified name of a tree value's schema (e.g. a node with schema identifier `\"my.scope.MyNode\"` returns `\"MyNode\"`).\n * @remarks If the schema is an inlined array, map, or record type, then it has no name and this function will return a string representation of the type (e.g., `\"MyNode[]\"` or `\"Map<string, MyNode>\"`).\n */\nexport function getFriendlyName(schema: TreeNodeSchema): string {\n\tif (schema.kind === NodeKind.Leaf || isNamedSchema(schema.identifier)) {\n\t\treturn unqualifySchema(schema.identifier);\n\t}\n\n\tconst childNames = Array.from(schema.childTypes, (t) => getFriendlyName(t));\n\tif (schema instanceof ArrayNodeSchema) {\n\t\treturn childNames.length > 1 ? `(${childNames.join(\" | \")})[]` : `${childNames[0]}[]`;\n\t}\n\tif (schema instanceof MapNodeSchema) {\n\t\treturn childNames.length > 1\n\t\t\t? `Map<string, (${childNames.join(\" | \")})>`\n\t\t\t: `Map<string, ${childNames[0]}>`;\n\t}\n\tif (schema instanceof RecordNodeSchema) {\n\t\treturn childNames.length > 1\n\t\t\t? `Record<string, (${childNames.join(\" | \")})>`\n\t\t\t: `Record<string, ${childNames[0]}>`;\n\t}\n\tfail(0xcb7 /* Unexpected node schema */);\n}\n\n/**\n * Returns true if the schema identifier represents a named schema (object, named array, named map, or named record).\n * @remarks This does not include primitive schemas or inlined array/map/record schemas.\n */\nexport function isNamedSchema(schemaIdentifier: string): boolean {\n\tif (\n\t\t[\"string\", \"number\", \"boolean\", \"null\", \"handle\"].includes(\n\t\t\tunqualifySchema(schemaIdentifier),\n\t\t)\n\t) {\n\t\treturn false;\n\t}\n\n\treturn /(?:Array|Map|Record)<\\[\"(.*)\"]>/.exec(schemaIdentifier) === null;\n}\n\n/**\n * Returns the unqualified, sanitized Typescript-safe name of a schema\n * Examples:\n * - `\"my.scope.MyNode\"` returns `\"MyNode\"`\n * - `\"my.scope.MyNode-2\"` returns `\"MyNode_2\"`\n * - `\"my.scope.MyNode!\"` returns `\"MyNode_\"`\n * @remarks\n * - Removes all characters before the last dot in the schema name.\n * - Sanitizes the remainder into a valid Typescript identifier\n * - If there is a dot in a user's schema name, this might produce unexpected results.\n */\nexport function unqualifySchema(schemaIdentifier: string): string {\n\t// Get the unqualified name by removing the scope (everything before the last dot).\n\tconst matches = /[^.]+$/.exec(schemaIdentifier);\n\tconst unqualifiedName = matches === null ? schemaIdentifier : matches[0];\n\n\tlet sanitizedName = unqualifiedName;\n\n\t// Replace invalid characters with \"_\".\n\tsanitizedName = sanitizedName.replace(/[^\\w$]/g, \"_\");\n\n\t// If the first character is a number, prefix it with \"_\".\n\tif (!/^[$A-Z_a-z]/.test(sanitizedName)) {\n\t\tsanitizedName = `_${sanitizedName}`;\n\t}\n\treturn sanitizedName;\n}\n\n/**\n * Adds all (optionally filtered) schemas reachable from the given schema to the given set.\n * @returns The set of schemas added (same as the `schemas` parameter, if supplied).\n */\nexport function findSchemas(\n\tschema: ImplicitFieldSchema,\n\tfilter: (schema: TreeNodeSchema) => boolean = () => true,\n\tschemas = new Set<TreeNodeSchema>(),\n): Set<TreeNodeSchema> {\n\tfor (const nodeSchema of normalizeFieldSchema(schema).allowedTypeSet) {\n\t\tif (!schemas.has(nodeSchema)) {\n\t\t\tif (filter(nodeSchema)) {\n\t\t\t\tschemas.add(nodeSchema);\n\t\t\t}\n\t\t\tfindSchemas([...nodeSchema.childTypes], filter, schemas);\n\t\t}\n\t}\n\treturn schemas;\n}\n\n/**\n * De-capitalize (the first letter of) a string.\n */\nexport function communize(str: string): string {\n\treturn str.charAt(0).toLowerCase() + str.slice(1);\n}\n\n/**\n * Stringify an unknown error value\n */\nexport function toErrorString(error: unknown): string {\n\tif (error instanceof Error) {\n\t\treturn error.message;\n\t}\n\ttry {\n\t\treturn JSON.stringify(error);\n\t} catch {\n\t\treturn String(error);\n\t}\n}\n"]}
package/eslint.config.mts CHANGED
@@ -1,8 +1,8 @@
1
- /* eslint-disable */
2
- /**
3
- * GENERATED FILE - DO NOT EDIT DIRECTLY.
4
- * To regenerate: pnpm tsx scripts/generate-flat-eslint-configs.ts --typescript
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
5
4
  */
5
+
6
6
  import type { Linter } from "eslint";
7
7
  import { strict } from "../../../common/build/eslint-config-fluid/flat.mts";
8
8
 
package/lib/alpha.d.ts CHANGED
@@ -31,6 +31,9 @@ export {
31
31
  IExposedProperties,
32
32
  IfEquals,
33
33
  Infer,
34
+ InferArgsZod,
35
+ InferTypeFactory,
36
+ InferZod,
34
37
  Logger,
35
38
  MethodKeys,
36
39
  PropertyDef,
@@ -42,12 +45,39 @@ export {
42
45
  SharedTreeSemanticAgent,
43
46
  SynchronousEditor,
44
47
  TreeView,
48
+ TypeFactoryArray,
49
+ TypeFactoryBoolean,
50
+ TypeFactoryDate,
51
+ TypeFactoryFunction,
52
+ TypeFactoryFunctionParameter,
53
+ TypeFactoryInstanceOf,
54
+ TypeFactoryIntersection,
55
+ TypeFactoryLiteral,
56
+ TypeFactoryMap,
57
+ TypeFactoryNull,
58
+ TypeFactoryNumber,
59
+ TypeFactoryObject,
60
+ TypeFactoryOptional,
61
+ TypeFactoryPromise,
62
+ TypeFactoryReadonly,
63
+ TypeFactoryRecord,
64
+ TypeFactoryString,
65
+ TypeFactoryTuple,
66
+ TypeFactoryType,
67
+ TypeFactoryTypeKind,
68
+ TypeFactoryUndefined,
69
+ TypeFactoryUnion,
70
+ TypeFactoryUnknown,
71
+ TypeFactoryVoid,
45
72
  TypeMatchOrError,
46
73
  ViewOrTree,
47
74
  buildFunc,
48
75
  createContext,
49
76
  exposeMethodsSymbol,
50
77
  exposePropertiesSymbol,
51
- llmDefault
78
+ instanceOfsTypeFactory,
79
+ isTypeFactoryType,
80
+ llmDefault,
81
+ typeFactory
52
82
  // #endregion
53
83
  } from "./index.js";
package/lib/index.d.ts CHANGED
@@ -10,6 +10,8 @@
10
10
  export { SharedTreeSemanticAgent, createContext, } from "./agent.js";
11
11
  export type { EditResult, SharedTreeChatModel, SharedTreeChatQuery, Logger, SemanticAgentOptions, SynchronousEditor, AsynchronousEditor, TreeView, ViewOrTree, Context, } from "./api.js";
12
12
  export { llmDefault } from "./utils.js";
13
- export { buildFunc, exposeMethodsSymbol, type ArgsTuple, type ExposedMethods, type Arg, type FunctionDef, type MethodKeys, type BindableSchema, type Ctor, type Infer, type IExposedMethods, } from "./methodBinding.js";
13
+ export { buildFunc, exposeMethodsSymbol, type ArgsTuple, type ExposedMethods, type Arg, type FunctionDef, type MethodKeys, type BindableSchema, type Ctor, type Infer, type InferZod, type InferArgsZod, type InferTypeFactory, type IExposedMethods, } from "./methodBinding.js";
14
14
  export type { exposePropertiesSymbol, PropertyDef, ExposedProperties, IExposedProperties, ExposableKeys, ReadOnlyRequirement, ReadonlyKeys, TypeMatchOrError, IfEquals, } from "./propertyBinding.js";
15
+ export { typeFactory, isTypeFactoryType, instanceOfsTypeFactory, } from "./treeAgentTypes.js";
16
+ export type { TypeFactoryType, TypeFactoryTypeKind, TypeFactoryString, TypeFactoryNumber, TypeFactoryBoolean, TypeFactoryDate, TypeFactoryVoid, TypeFactoryUndefined, TypeFactoryNull, TypeFactoryUnknown, TypeFactoryArray, TypeFactoryPromise, TypeFactoryObject, TypeFactoryRecord, TypeFactoryMap, TypeFactoryTuple, TypeFactoryUnion, TypeFactoryIntersection, TypeFactoryLiteral, TypeFactoryOptional, TypeFactoryReadonly, TypeFactoryFunction, TypeFactoryFunctionParameter, TypeFactoryInstanceOf, } from "./treeAgentTypes.js";
15
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EACN,uBAAuB,EACvB,aAAa,GACb,MAAM,YAAY,CAAC;AACpB,YAAY,EACX,UAAU,EACV,mBAAmB,EACnB,mBAAmB,EACnB,MAAM,EACN,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EAClB,QAAQ,EACR,UAAU,EACV,OAAO,GACP,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EACN,SAAS,EACT,mBAAmB,EACnB,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,GAAG,EACR,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,IAAI,EACT,KAAK,KAAK,EACV,KAAK,eAAe,GACpB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACX,sBAAsB,EACtB,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,mBAAmB,EACnB,YAAY,EACZ,gBAAgB,EAChB,QAAQ,GACR,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EACN,uBAAuB,EACvB,aAAa,GACb,MAAM,YAAY,CAAC;AACpB,YAAY,EACX,UAAU,EACV,mBAAmB,EACnB,mBAAmB,EACnB,MAAM,EACN,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EAClB,QAAQ,EACR,UAAU,EACV,OAAO,GACP,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EACN,SAAS,EACT,mBAAmB,EACnB,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,GAAG,EACR,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,IAAI,EACT,KAAK,KAAK,EACV,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,eAAe,GACpB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACX,sBAAsB,EACtB,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,mBAAmB,EACnB,YAAY,EACZ,gBAAgB,EAChB,QAAQ,GACR,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACN,WAAW,EACX,iBAAiB,EACjB,sBAAsB,GACtB,MAAM,qBAAqB,CAAC;AAE7B,YAAY,EACX,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,4BAA4B,EAC5B,qBAAqB,GACrB,MAAM,qBAAqB,CAAC"}
package/lib/index.js CHANGED
@@ -10,4 +10,5 @@
10
10
  export { SharedTreeSemanticAgent, createContext, } from "./agent.js";
11
11
  export { llmDefault } from "./utils.js";
12
12
  export { buildFunc, exposeMethodsSymbol, } from "./methodBinding.js";
13
+ export { typeFactory, isTypeFactoryType, instanceOfsTypeFactory, } from "./treeAgentTypes.js";
13
14
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EACN,uBAAuB,EACvB,aAAa,GACb,MAAM,YAAY,CAAC;AAapB,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EACN,SAAS,EACT,mBAAmB,GAUnB,MAAM,oBAAoB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * A library for creating AI agents to interact with a {@link SharedTree | https://fluidframework.com/docs/data-structures/tree/}.\n *\n * @packageDocumentation\n */\n\nexport {\n\tSharedTreeSemanticAgent,\n\tcreateContext,\n} from \"./agent.js\";\nexport type {\n\tEditResult,\n\tSharedTreeChatModel,\n\tSharedTreeChatQuery,\n\tLogger,\n\tSemanticAgentOptions,\n\tSynchronousEditor,\n\tAsynchronousEditor,\n\tTreeView,\n\tViewOrTree,\n\tContext,\n} from \"./api.js\";\nexport { llmDefault } from \"./utils.js\";\nexport {\n\tbuildFunc,\n\texposeMethodsSymbol,\n\ttype ArgsTuple,\n\ttype ExposedMethods,\n\ttype Arg,\n\ttype FunctionDef,\n\ttype MethodKeys,\n\ttype BindableSchema,\n\ttype Ctor,\n\ttype Infer,\n\ttype IExposedMethods,\n} from \"./methodBinding.js\";\nexport type {\n\texposePropertiesSymbol,\n\tPropertyDef,\n\tExposedProperties,\n\tIExposedProperties,\n\tExposableKeys,\n\tReadOnlyRequirement,\n\tReadonlyKeys,\n\tTypeMatchOrError,\n\tIfEquals,\n} from \"./propertyBinding.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EACN,uBAAuB,EACvB,aAAa,GACb,MAAM,YAAY,CAAC;AAapB,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EACN,SAAS,EACT,mBAAmB,GAanB,MAAM,oBAAoB,CAAC;AAa5B,OAAO,EACN,WAAW,EACX,iBAAiB,EACjB,sBAAsB,GACtB,MAAM,qBAAqB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * A library for creating AI agents to interact with a {@link SharedTree | https://fluidframework.com/docs/data-structures/tree/}.\n *\n * @packageDocumentation\n */\n\nexport {\n\tSharedTreeSemanticAgent,\n\tcreateContext,\n} from \"./agent.js\";\nexport type {\n\tEditResult,\n\tSharedTreeChatModel,\n\tSharedTreeChatQuery,\n\tLogger,\n\tSemanticAgentOptions,\n\tSynchronousEditor,\n\tAsynchronousEditor,\n\tTreeView,\n\tViewOrTree,\n\tContext,\n} from \"./api.js\";\nexport { llmDefault } from \"./utils.js\";\nexport {\n\tbuildFunc,\n\texposeMethodsSymbol,\n\ttype ArgsTuple,\n\ttype ExposedMethods,\n\ttype Arg,\n\ttype FunctionDef,\n\ttype MethodKeys,\n\ttype BindableSchema,\n\ttype Ctor,\n\ttype Infer,\n\ttype InferZod,\n\ttype InferArgsZod,\n\ttype InferTypeFactory,\n\ttype IExposedMethods,\n} from \"./methodBinding.js\";\nexport type {\n\texposePropertiesSymbol,\n\tPropertyDef,\n\tExposedProperties,\n\tIExposedProperties,\n\tExposableKeys,\n\tReadOnlyRequirement,\n\tReadonlyKeys,\n\tTypeMatchOrError,\n\tIfEquals,\n} from \"./propertyBinding.js\";\n\nexport {\n\ttypeFactory,\n\tisTypeFactoryType,\n\tinstanceOfsTypeFactory,\n} from \"./treeAgentTypes.js\";\n\nexport type {\n\tTypeFactoryType,\n\tTypeFactoryTypeKind,\n\tTypeFactoryString,\n\tTypeFactoryNumber,\n\tTypeFactoryBoolean,\n\tTypeFactoryDate,\n\tTypeFactoryVoid,\n\tTypeFactoryUndefined,\n\tTypeFactoryNull,\n\tTypeFactoryUnknown,\n\tTypeFactoryArray,\n\tTypeFactoryPromise,\n\tTypeFactoryObject,\n\tTypeFactoryRecord,\n\tTypeFactoryMap,\n\tTypeFactoryTuple,\n\tTypeFactoryUnion,\n\tTypeFactoryIntersection,\n\tTypeFactoryLiteral,\n\tTypeFactoryOptional,\n\tTypeFactoryReadonly,\n\tTypeFactoryFunction,\n\tTypeFactoryFunctionParameter,\n\tTypeFactoryInstanceOf,\n} from \"./treeAgentTypes.js\";\n"]}
@@ -5,6 +5,7 @@
5
5
  import type { TreeNodeSchema, TreeNodeSchemaClass } from "@fluidframework/tree";
6
6
  import { NodeKind } from "@fluidframework/tree";
7
7
  import type { z } from "zod";
8
+ import type { TypeFactoryType } from "./treeAgentTypes.js";
8
9
  /**
9
10
  * A utility type that extracts the method keys from a given type.
10
11
  * @alpha
@@ -39,27 +40,39 @@ export declare function getExposedMethods(schemaClass: BindableSchema): {
39
40
  * A type that represents a function argument.
40
41
  * @alpha
41
42
  */
42
- export type Arg<T extends z.ZodTypeAny = z.ZodTypeAny> = readonly [name: string, type: T];
43
+ export type Arg<T extends z.ZodTypeAny | TypeFactoryType = z.ZodTypeAny | TypeFactoryType> = readonly [name: string, type: T];
43
44
  /**
44
45
  * A function definition interface that describes the structure of a function.
45
46
  * @alpha
46
47
  */
47
- export interface FunctionDef<Args extends readonly Arg[], Return extends z.ZodTypeAny, Rest extends z.ZodTypeAny | null = null> {
48
+ export interface FunctionDef<Args extends readonly Arg[], Return extends z.ZodTypeAny | TypeFactoryType, Rest extends z.ZodTypeAny | TypeFactoryType | null = null> {
49
+ /**
50
+ * Optional description of the function.
51
+ */
48
52
  description?: string;
53
+ /**
54
+ * The function's parameters.
55
+ */
49
56
  args: Args;
57
+ /**
58
+ * Optional rest parameter type.
59
+ */
50
60
  rest?: Rest;
61
+ /**
62
+ * The function's return type.
63
+ */
51
64
  returns: Return;
52
65
  }
53
66
  /**
54
67
  * A class that implements the FunctionDef interface.
55
68
  */
56
- export declare class FunctionWrapper implements FunctionDef<readonly Arg[], z.ZodTypeAny, z.ZodTypeAny | null> {
69
+ export declare class FunctionWrapper implements FunctionDef<readonly Arg[], z.ZodTypeAny | TypeFactoryType, z.ZodTypeAny | TypeFactoryType | null> {
57
70
  readonly name: string;
58
71
  readonly description: string | undefined;
59
72
  readonly args: readonly Arg[];
60
- readonly rest: z.ZodTypeAny | null;
61
- readonly returns: z.ZodTypeAny;
62
- constructor(name: string, description: string | undefined, args: readonly Arg[], rest: z.ZodTypeAny | null, returns: z.ZodTypeAny);
73
+ readonly rest: z.ZodTypeAny | TypeFactoryType | null;
74
+ readonly returns: z.ZodTypeAny | TypeFactoryType;
75
+ constructor(name: string, description: string | undefined, args: readonly Arg[], rest: z.ZodTypeAny | TypeFactoryType | null, returns: z.ZodTypeAny | TypeFactoryType);
63
76
  }
64
77
  /**
65
78
  * A utility type that extracts the argument types from a function definition.
@@ -70,26 +83,54 @@ export type ArgsTuple<T extends readonly Arg[]> = T extends readonly [infer Sing
70
83
  * A utility function to build a function definition.
71
84
  * @alpha
72
85
  */
73
- export declare function buildFunc<const Return extends z.ZodTypeAny, const Args extends readonly Arg[], const Rest extends z.ZodTypeAny | null = null>(def: {
86
+ export declare function buildFunc<const Return extends z.ZodTypeAny | TypeFactoryType, const Args extends readonly Arg[], const Rest extends z.ZodTypeAny | TypeFactoryType | null = null>(def: {
74
87
  description?: string;
75
88
  returns: Return;
76
89
  rest?: Rest;
77
90
  }, ...args: Args): FunctionDef<Args, Return, Rest>;
91
+ /**
92
+ * A utility type that extracts inferred parameter types from Zod args.
93
+ * @alpha
94
+ */
95
+ export type InferArgsZod<Args extends readonly Arg<z.ZodTypeAny>[]> = Args extends readonly [
96
+ infer Head extends Arg<z.ZodTypeAny>,
97
+ ...infer Tail extends readonly Arg<z.ZodTypeAny>[]
98
+ ] ? [z.infer<Head[1]>, ...InferArgsZod<Tail>] : [];
99
+ /**
100
+ * A utility type that infers the function signature from a Zod function definition with strict type checking.
101
+ * @alpha
102
+ */
103
+ export type InferZod<T> = T extends FunctionDef<infer Args extends readonly Arg<z.ZodTypeAny>[], infer Return extends z.ZodTypeAny, any> ? (...args: InferArgsZod<Args>) => z.infer<Return> : never;
104
+ /**
105
+ * A utility type that infers the function signature from a type factory function definition with relaxed type checking.
106
+ * @alpha
107
+ */
108
+ export type InferTypeFactory<T> = T extends FunctionDef<readonly Arg[], infer Return, any> ? (...args: any[]) => any : never;
78
109
  /**
79
110
  * A utility type that infers the return type of a function definition.
80
111
  * @alpha
112
+ * @remarks
113
+ * For Zod types, provides strict compile-time type checking. For type factory types, returns `any`.
114
+ * @deprecated Use InferZod or InferTypeFactory directly for better type safety.
81
115
  */
82
- export type Infer<T> = T extends FunctionDef<infer Args, infer Return, infer Rest> ? z.infer<z.ZodFunction<z.ZodTuple<ArgsTuple<Args>, Rest>, Return>> : never;
116
+ export type Infer<T> = T extends FunctionDef<readonly Arg[], infer Return, any> ? Return extends z.ZodTypeAny ? InferZod<T> : InferTypeFactory<T> : never;
83
117
  /**
84
118
  * An interface for exposing methods of schema classes to an agent.
85
119
  * @alpha
86
120
  */
87
121
  export interface ExposedMethods {
88
- expose<const K extends string & keyof MethodKeys<InstanceType<S>>, S extends BindableSchema & Ctor<Record<K, Infer<Z>>> & IExposedMethods, Z extends FunctionDef<any, any, any>>(schema: S, methodName: K, zodFunction: Z): void;
122
+ /**
123
+ * Expose a method with Zod types (strict compile-time type checking).
124
+ */
125
+ expose<const K extends string & keyof MethodKeys<InstanceType<S>>, S extends BindableSchema & Ctor<Record<K, InferZod<Z>>> & IExposedMethods, Z extends FunctionDef<readonly Arg<z.ZodTypeAny>[], z.ZodTypeAny, z.ZodTypeAny | null>>(schema: S, methodName: K, zodFunction: Z): void;
126
+ /**
127
+ * Expose a method with type factory types (relaxed compile-time type checking).
128
+ */
129
+ expose<const K extends string & keyof MethodKeys<InstanceType<S>>, S extends BindableSchema & Ctor & IExposedMethods, Z extends FunctionDef<readonly Arg<TypeFactoryType>[], TypeFactoryType, TypeFactoryType | null>>(schema: S, methodName: K, tfFunction: Z): void;
89
130
  /**
90
131
  * Create a Zod schema for a SharedTree schema class.
91
132
  * @remarks
92
- * Use it to "wrap" schema types that are referenced as arguments or return types when exposing methods (with {@link ExposedMethods.expose}).
133
+ * Use it to "wrap" schema types that are referenced as arguments or return types when exposing methods with {@link ExposedMethods}.
93
134
  */
94
135
  instanceOf<T extends TreeNodeSchemaClass>(schema: T): z.ZodType<InstanceType<T>, z.ZodTypeDef, InstanceType<T>>;
95
136
  }
@@ -113,6 +154,9 @@ export declare const exposeMethodsSymbol: unique symbol;
113
154
  * @alpha
114
155
  */
115
156
  export interface IExposedMethods {
157
+ /**
158
+ * Static method that exposes methods of this schema class to an agent.
159
+ */
116
160
  [exposeMethodsSymbol](methods: ExposedMethods): void;
117
161
  }
118
162
  //# sourceMappingURL=methodBinding.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"methodBinding.d.ts","sourceRoot":"","sources":["../src/methodBinding.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAG7B;;;GAGG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI;KAC1B,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,GAAG,CAAC,GAAG,KAAK;CAChE,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,IAAI,CAAC,CAAC,GAAG,GAAG,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;AAEtD;;;GAGG;AACH,MAAM,MAAM,cAAc,GACvB,cAAc,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,GACvC,cAAc,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,GACvC,cAAc,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,GACtC,cAAc,CAAC,MAAM,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E,cAAc,CAAC,eAAe;SAC/C,CAAC;IACH,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { TreeNodeSchema, TreeNodeSchemaClass } from \"@fluidframework/tree\";\nimport { NodeKind } from \"@fluidframework/tree\";\nimport type { z } from \"zod\";\nimport { instanceOf } from \"./renderZodTypeScript.js\";\n\n/**\n * A utility type that extracts the method keys from a given type.\n * @alpha\n */\nexport type MethodKeys<T> = {\n\t[K in keyof T]: T[K] extends (...args: any[]) => any ? K : never;\n};\n\n/**\n * A type that represents a constructor function.\n * @alpha\n */\nexport type Ctor<T = any> = new (...args: any[]) => T;\n\n/**\n * A type that represents an object schema class.\n * @alpha\n */\nexport type BindableSchema =\n\t| TreeNodeSchema<string, NodeKind.Object>\n\t| TreeNodeSchema<string, NodeKind.Record>\n\t| TreeNodeSchema<string, NodeKind.Array>\n\t| TreeNodeSchema<string, NodeKind.Map>;\n\n/**\n * A type guard to check if a schema is {@link BindableSchema | bindable}.\n */\nexport function isBindableSchema(schema: TreeNodeSchema): schema is BindableSchema {\n\treturn (\n\t\tschema.kind === NodeKind.Object ||\n\t\tschema.kind === NodeKind.Record ||\n\t\tschema.kind === NodeKind.Array ||\n\t\tschema.kind === NodeKind.Map\n\t);\n}\n\n/**\n * Get the exposed methods of a schema class.\n * @param schemaClass - The schema class to extract methods from.\n * @returns A record of method names and their corresponding Zod types.\n */\nexport function getExposedMethods(schemaClass: BindableSchema): {\n\tmethods: Record<string, FunctionWrapper>;\n\treferencedTypes: Set<TreeNodeSchema>;\n} {\n\treturn ExposedMethodsI.getExposedMethods(schemaClass);\n}\n\n/**\n * A type that represents a function argument.\n * @alpha\n */\nexport type Arg<T extends z.ZodTypeAny = z.ZodTypeAny> = readonly [name: string, type: T];\n\n/**\n * A function definition interface that describes the structure of a function.\n * @alpha\n */\nexport interface FunctionDef<\n\tArgs extends readonly Arg[],\n\tReturn extends z.ZodTypeAny,\n\tRest extends z.ZodTypeAny | null = null,\n> {\n\tdescription?: string;\n\targs: Args;\n\trest?: Rest;\n\treturns: Return;\n}\n\n/**\n * A class that implements the FunctionDef interface.\n */\nexport class FunctionWrapper\n\timplements FunctionDef<readonly Arg[], z.ZodTypeAny, z.ZodTypeAny | null>\n{\n\tpublic constructor(\n\t\tpublic readonly name: string,\n\t\tpublic readonly description: string | undefined,\n\t\tpublic readonly args: readonly Arg[],\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t\tpublic readonly rest: z.ZodTypeAny | null,\n\t\tpublic readonly returns: z.ZodTypeAny,\n\t) {}\n}\n\n/**\n * A utility type that extracts the argument types from a function definition.\n * @alpha\n */\nexport type ArgsTuple<T extends readonly Arg[]> = T extends readonly [infer Single extends Arg]\n\t? [Single[1]]\n\t: T extends readonly [infer Head extends Arg, ...infer Tail extends readonly Arg[]]\n\t\t? [Head[1], ...ArgsTuple<Tail>]\n\t\t: never;\n\n/**\n * A utility function to build a function definition.\n * @alpha\n */\nexport function buildFunc<\n\tconst Return extends z.ZodTypeAny,\n\tconst Args extends readonly Arg[],\n\tconst Rest extends z.ZodTypeAny | null = null,\n>(\n\tdef: { description?: string; returns: Return; rest?: Rest },\n\t...args: Args\n): FunctionDef<Args, Return, Rest> {\n\treturn {\n\t\tdescription: def.description,\n\t\treturns: def.returns,\n\t\targs,\n\t\trest: def.rest,\n\t};\n}\n\n/**\n * A utility type that infers the return type of a function definition.\n * @alpha\n */\nexport type Infer<T> = T extends FunctionDef<infer Args, infer Return, infer Rest>\n\t? z.infer<z.ZodFunction<z.ZodTuple<ArgsTuple<Args>, Rest>, Return>>\n\t: never;\n\n/**\n * An interface for exposing methods of schema classes to an agent.\n * @alpha\n */\nexport interface ExposedMethods {\n\texpose<\n\t\tconst K extends string & keyof MethodKeys<InstanceType<S>>,\n\t\tS extends BindableSchema & Ctor<Record<K, Infer<Z>>> & IExposedMethods,\n\t\tZ extends FunctionDef<any, any, any>,\n\t>(schema: S, methodName: K, zodFunction: Z): void;\n\n\t/**\n\t * Create a Zod schema for a SharedTree schema class.\n\t * @remarks\n\t * Use it to \"wrap\" schema types that are referenced as arguments or return types when exposing methods (with {@link ExposedMethods.expose}).\n\t */\n\tinstanceOf<T extends TreeNodeSchemaClass>(\n\t\tschema: T,\n\t): z.ZodType<InstanceType<T>, z.ZodTypeDef, InstanceType<T>>;\n}\n\n/**\n * A symbol used to expose methods to the LLM.\n * @alpha\n */\nexport const exposeMethodsSymbol: unique symbol = Symbol(\"run\");\n\n/**\n * An interface that SharedTree schema classes should implement to expose their methods to the LLM.\n *\n * @remarks\n * The `getExposedMethods` free function will cause the method here to be called on the class passed to it.\n *\n * @privateremarks\n * Implementing this interface correctly seems tricky?\n * To actually implement it in a way that satisfies TypeScript,\n * classes need to declare both a static version and an instance version of the method\n * (the instance one can just delegate to the static one).\n *\n * @alpha\n */\nexport interface IExposedMethods {\n\t[exposeMethodsSymbol](methods: ExposedMethods): void;\n}\n\nclass ExposedMethodsI implements ExposedMethods {\n\tprivate readonly methods: Record<string, FunctionWrapper> = {};\n\tprivate readonly referencedTypes = new Set<TreeNodeSchema>();\n\n\tpublic constructor(private readonly schemaClass: BindableSchema) {}\n\n\tpublic expose<\n\t\tconst K extends string & keyof MethodKeys<InstanceType<S>>,\n\t\tS extends BindableSchema & Ctor<Record<K, Infer<Z>>> & IExposedMethods,\n\t\tZ extends FunctionDef<readonly Arg[], z.ZodTypeAny, z.ZodTypeAny | null>,\n\t>(schema: S, methodName: K, functionDef: Z): void {\n\t\tif (schema !== this.schemaClass) {\n\t\t\tthrow new Error('Must expose methods on the \"this\" object');\n\t\t}\n\t\tthis.methods[methodName] = new FunctionWrapper(\n\t\t\tmethodName,\n\t\t\tfunctionDef.description,\n\t\t\tfunctionDef.args,\n\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\tfunctionDef.rest ?? null,\n\t\t\tfunctionDef.returns,\n\t\t);\n\t}\n\n\tpublic instanceOf<T extends TreeNodeSchemaClass>(\n\t\tschema: T,\n\t): z.ZodType<InstanceType<T>, z.ZodTypeDef, InstanceType<T>> {\n\t\tthis.referencedTypes.add(schema);\n\t\treturn instanceOf(schema);\n\t}\n\n\tpublic static getExposedMethods(schemaClass: BindableSchema): {\n\t\tmethods: Record<string, FunctionWrapper>;\n\t\treferencedTypes: Set<TreeNodeSchema>;\n\t} {\n\t\tconst exposedMethods = new ExposedMethodsI(schemaClass);\n\t\tconst extractable = schemaClass as unknown as IExposedMethods;\n\t\tif (extractable[exposeMethodsSymbol] !== undefined) {\n\t\t\textractable[exposeMethodsSymbol](exposedMethods);\n\t\t}\n\t\treturn {\n\t\t\tmethods: exposedMethods.methods,\n\t\t\treferencedTypes: exposedMethods.referencedTypes,\n\t\t};\n\t}\n}\n"]}
1
+ {"version":3,"file":"methodBinding.js","sourceRoot":"","sources":["../src/methodBinding.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGhD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AA2BtD;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAsB;IACtD,OAAO,CACN,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC,MAAM;QAC/B,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC,MAAM;QAC/B,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC,KAAK;QAC9B,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC,GAAG,CAC5B,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,WAA2B;IAI5D,OAAO,eAAe,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;AACvD,CAAC;AAoCD;;GAEG;AACH,MAAM,OAAO,eAAe;IAQ3B,YACiB,IAAY,EACZ,WAA+B,EAC/B,IAAoB;IACpC,kDAAkD;IAClC,IAA2C,EAC3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AI1D,MAAM,cAAc,GAAG,IAAI,eAAe,CAAC,WAAW,CAAC,CAAC;QACxD,MAAM,WAAW,GAAG,WAAyC,CAAC;QAC9D,IAAI,WAAW,CAAC,mBAAmB,CAAC,KAAK,SAAS,EAAE,CAAC;YACpD,WAAW,CAAC,mBAAmB,CAAC,CAAC,cAAc,CAAC,CAAC;QAClD,CAAC;QACD,OAAO;YACN,OAAO,EAAE,cAAc,CAAC,OAAO;YAC/B,eAAe,EAAE,cAAc,CAAC,eAAe;SAC/C,CAAC;IACH,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { TreeNodeSchema, TreeNodeSchemaClass } from \"@fluidframework/tree\";\nimport { NodeKind } from \"@fluidframework/tree\";\nimport type { z } from \"zod\";\n\nimport { instanceOf } from \"./renderZodTypeScript.js\";\nimport type { TypeFactoryType } from \"./treeAgentTypes.js\";\n\n/**\n * A utility type that extracts the method keys from a given type.\n * @alpha\n */\nexport type MethodKeys<T> = {\n\t[K in keyof T]: T[K] extends (...args: any[]) => any ? K : never;\n};\n\n/**\n * A type that represents a constructor function.\n * @alpha\n */\nexport type Ctor<T = any> = new (...args: any[]) => T;\n\n/**\n * A type that represents an object schema class.\n * @alpha\n */\nexport type BindableSchema =\n\t| TreeNodeSchema<string, NodeKind.Object>\n\t| TreeNodeSchema<string, NodeKind.Record>\n\t| TreeNodeSchema<string, NodeKind.Array>\n\t| TreeNodeSchema<string, NodeKind.Map>;\n\n/**\n * A type guard to check if a schema is {@link BindableSchema | bindable}.\n */\nexport function isBindableSchema(schema: TreeNodeSchema): schema is BindableSchema {\n\treturn (\n\t\tschema.kind === NodeKind.Object ||\n\t\tschema.kind === NodeKind.Record ||\n\t\tschema.kind === NodeKind.Array ||\n\t\tschema.kind === NodeKind.Map\n\t);\n}\n\n/**\n * Get the exposed methods of a schema class.\n * @param schemaClass - The schema class to extract methods from.\n * @returns A record of method names and their corresponding Zod types.\n */\nexport function getExposedMethods(schemaClass: BindableSchema): {\n\tmethods: Record<string, FunctionWrapper>;\n\treferencedTypes: Set<TreeNodeSchema>;\n} {\n\treturn ExposedMethodsI.getExposedMethods(schemaClass);\n}\n\n/**\n * A type that represents a function argument.\n * @alpha\n */\nexport type Arg<T extends z.ZodTypeAny | TypeFactoryType = z.ZodTypeAny | TypeFactoryType> =\n\treadonly [name: string, type: T];\n\n/**\n * A function definition interface that describes the structure of a function.\n * @alpha\n */\nexport interface FunctionDef<\n\tArgs extends readonly Arg[],\n\tReturn extends z.ZodTypeAny | TypeFactoryType,\n\tRest extends z.ZodTypeAny | TypeFactoryType | null = null,\n> {\n\t/**\n\t * Optional description of the function.\n\t */\n\tdescription?: string;\n\t/**\n\t * The function's parameters.\n\t */\n\targs: Args;\n\t/**\n\t * Optional rest parameter type.\n\t */\n\trest?: Rest;\n\t/**\n\t * The function's return type.\n\t */\n\treturns: Return;\n}\n\n/**\n * A class that implements the FunctionDef interface.\n */\nexport class FunctionWrapper\n\timplements\n\t\tFunctionDef<\n\t\t\treadonly Arg[],\n\t\t\tz.ZodTypeAny | TypeFactoryType,\n\t\t\tz.ZodTypeAny | TypeFactoryType | null\n\t\t>\n{\n\tpublic constructor(\n\t\tpublic readonly name: string,\n\t\tpublic readonly description: string | undefined,\n\t\tpublic readonly args: readonly Arg[],\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t\tpublic readonly rest: z.ZodTypeAny | TypeFactoryType | null,\n\t\tpublic readonly returns: z.ZodTypeAny | TypeFactoryType,\n\t) {}\n}\n\n/**\n * A utility type that extracts the argument types from a function definition.\n * @alpha\n */\nexport type ArgsTuple<T extends readonly Arg[]> = T extends readonly [infer Single extends Arg]\n\t? [Single[1]]\n\t: T extends readonly [infer Head extends Arg, ...infer Tail extends readonly Arg[]]\n\t\t? [Head[1], ...ArgsTuple<Tail>]\n\t\t: never;\n\n/**\n * A utility function to build a function definition.\n * @alpha\n */\nexport function buildFunc<\n\tconst Return extends z.ZodTypeAny | TypeFactoryType,\n\tconst Args extends readonly Arg[],\n\tconst Rest extends z.ZodTypeAny | TypeFactoryType | null = null,\n>(\n\tdef: { description?: string; returns: Return; rest?: Rest },\n\t...args: Args\n): FunctionDef<Args, Return, Rest> {\n\treturn {\n\t\tdescription: def.description,\n\t\treturns: def.returns,\n\t\targs,\n\t\trest: def.rest,\n\t};\n}\n\n/**\n * A utility type that extracts inferred parameter types from Zod args.\n * @alpha\n */\nexport type InferArgsZod<Args extends readonly Arg<z.ZodTypeAny>[]> = Args extends readonly [\n\tinfer Head extends Arg<z.ZodTypeAny>,\n\t...infer Tail extends readonly Arg<z.ZodTypeAny>[],\n]\n\t? [z.infer<Head[1]>, ...InferArgsZod<Tail>]\n\t: [];\n\n/**\n * A utility type that infers the function signature from a Zod function definition with strict type checking.\n * @alpha\n */\nexport type InferZod<T> = T extends FunctionDef<\n\tinfer Args extends readonly Arg<z.ZodTypeAny>[],\n\tinfer Return extends z.ZodTypeAny,\n\tany\n>\n\t? (...args: InferArgsZod<Args>) => z.infer<Return>\n\t: never;\n\n/**\n * A utility type that infers the function signature from a type factory function definition with relaxed type checking.\n * @alpha\n */\nexport type InferTypeFactory<T> = T extends FunctionDef<readonly Arg[], infer Return, any>\n\t? (...args: any[]) => any\n\t: never;\n\n/**\n * A utility type that infers the return type of a function definition.\n * @alpha\n * @remarks\n * For Zod types, provides strict compile-time type checking. For type factory types, returns `any`.\n * @deprecated Use InferZod or InferTypeFactory directly for better type safety.\n */\nexport type Infer<T> = T extends FunctionDef<readonly Arg[], infer Return, any>\n\t? Return extends z.ZodTypeAny\n\t\t? InferZod<T>\n\t\t: InferTypeFactory<T>\n\t: never;\n\n/**\n * An interface for exposing methods of schema classes to an agent.\n * @alpha\n */\nexport interface ExposedMethods {\n\t/**\n\t * Expose a method with Zod types (strict compile-time type checking).\n\t */\n\texpose<\n\t\tconst K extends string & keyof MethodKeys<InstanceType<S>>,\n\t\tS extends BindableSchema & Ctor<Record<K, InferZod<Z>>> & IExposedMethods,\n\t\tZ extends FunctionDef<readonly Arg<z.ZodTypeAny>[], z.ZodTypeAny, z.ZodTypeAny | null>,\n\t>(schema: S, methodName: K, zodFunction: Z): void;\n\n\t/**\n\t * Expose a method with type factory types (relaxed compile-time type checking).\n\t */\n\texpose<\n\t\tconst K extends string & keyof MethodKeys<InstanceType<S>>,\n\t\tS extends BindableSchema & Ctor & IExposedMethods,\n\t\tZ extends FunctionDef<\n\t\t\treadonly Arg<TypeFactoryType>[],\n\t\t\tTypeFactoryType,\n\t\t\tTypeFactoryType | null\n\t\t>,\n\t>(schema: S, methodName: K, tfFunction: Z): void;\n\n\t/**\n\t * Create a Zod schema for a SharedTree schema class.\n\t * @remarks\n\t * Use it to \"wrap\" schema types that are referenced as arguments or return types when exposing methods with {@link ExposedMethods}.\n\t */\n\tinstanceOf<T extends TreeNodeSchemaClass>(\n\t\tschema: T,\n\t): z.ZodType<InstanceType<T>, z.ZodTypeDef, InstanceType<T>>;\n}\n\n/**\n * A symbol used to expose methods to the LLM.\n * @alpha\n */\nexport const exposeMethodsSymbol: unique symbol = Symbol(\"run\");\n\n/**\n * An interface that SharedTree schema classes should implement to expose their methods to the LLM.\n *\n * @remarks\n * The `getExposedMethods` free function will cause the method here to be called on the class passed to it.\n *\n * @privateremarks\n * Implementing this interface correctly seems tricky?\n * To actually implement it in a way that satisfies TypeScript,\n * classes need to declare both a static version and an instance version of the method\n * (the instance one can just delegate to the static one).\n *\n * @alpha\n */\nexport interface IExposedMethods {\n\t/**\n\t * Static method that exposes methods of this schema class to an agent.\n\t */\n\t[exposeMethodsSymbol](methods: ExposedMethods): void;\n}\n\nclass ExposedMethodsI implements ExposedMethods {\n\tprivate readonly methods: Record<string, FunctionWrapper> = {};\n\tprivate readonly referencedTypes = new Set<TreeNodeSchema>();\n\n\tpublic constructor(private readonly schemaClass: BindableSchema) {}\n\n\tpublic expose<\n\t\tconst K extends string & keyof MethodKeys<InstanceType<S>>,\n\t\tS extends BindableSchema & Ctor & IExposedMethods,\n\t\tZ extends FunctionDef<\n\t\t\treadonly Arg[],\n\t\t\tz.ZodTypeAny | TypeFactoryType,\n\t\t\tz.ZodTypeAny | TypeFactoryType | null\n\t\t>,\n\t>(schema: S, methodName: K, functionDef: Z): void {\n\t\tif (schema !== this.schemaClass) {\n\t\t\tthrow new Error('Must expose methods on the \"this\" object');\n\t\t}\n\t\tthis.methods[methodName] = new FunctionWrapper(\n\t\t\tmethodName,\n\t\t\tfunctionDef.description,\n\t\t\tfunctionDef.args,\n\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\tfunctionDef.rest ?? null,\n\t\t\tfunctionDef.returns,\n\t\t);\n\t}\n\n\tpublic instanceOf<T extends TreeNodeSchemaClass>(\n\t\tschema: T,\n\t): z.ZodType<InstanceType<T>, z.ZodTypeDef, InstanceType<T>> {\n\t\tthis.referencedTypes.add(schema);\n\t\treturn instanceOf(schema);\n\t}\n\n\tpublic static getExposedMethods(schemaClass: BindableSchema): {\n\t\tmethods: Record<string, FunctionWrapper>;\n\t\treferencedTypes: Set<TreeNodeSchema>;\n\t} {\n\t\tconst exposedMethods = new ExposedMethodsI(schemaClass);\n\t\tconst extractable = schemaClass as unknown as IExposedMethods;\n\t\tif (extractable[exposeMethodsSymbol] !== undefined) {\n\t\t\textractable[exposeMethodsSymbol](exposedMethods);\n\t\t}\n\t\treturn {\n\t\t\tmethods: exposedMethods.methods,\n\t\t\treferencedTypes: exposedMethods.referencedTypes,\n\t\t};\n\t}\n}\n"]}
@@ -5,6 +5,7 @@
5
5
  import type { TreeNodeSchema, TreeNodeSchemaClass } from "@fluidframework/tree";
6
6
  import type { ZodType, ZodTypeAny, ZodTypeDef, infer as ZodInfer } from "zod";
7
7
  import type { BindableSchema, Ctor } from "./methodBinding.js";
8
+ import type { TypeFactoryType } from "./treeAgentTypes.js";
8
9
  /**
9
10
  * A symbol used to expose properties to the LLM.
10
11
  * @alpha
@@ -60,21 +61,67 @@ export type TypeMatchOrError<Expected, Received> = [Received] extends [Expected]
60
61
  * @alpha
61
62
  */
62
63
  export declare class PropertyDef {
64
+ /**
65
+ * The name of the property.
66
+ */
63
67
  readonly name: string;
68
+ /**
69
+ * Optional description of the property.
70
+ */
64
71
  readonly description: string | undefined;
65
- readonly schema: ZodTypeAny;
72
+ /**
73
+ * The schema defining the property's type (either Zod or TypeFactory).
74
+ */
75
+ readonly schema: ZodTypeAny | TypeFactoryType;
76
+ /**
77
+ * Whether the property is readonly.
78
+ */
66
79
  readonly readOnly: boolean;
67
- constructor(name: string, description: string | undefined, schema: ZodTypeAny, readOnly: boolean);
80
+ constructor(
81
+ /**
82
+ * The name of the property.
83
+ */
84
+ name: string,
85
+ /**
86
+ * Optional description of the property.
87
+ */
88
+ description: string | undefined,
89
+ /**
90
+ * The schema defining the property's type (either Zod or TypeFactory).
91
+ */
92
+ schema: ZodTypeAny | TypeFactoryType,
93
+ /**
94
+ * Whether the property is readonly.
95
+ */
96
+ readOnly: boolean);
68
97
  }
69
98
  /**
70
99
  * An interface for exposing properties of schema classes to an agent.
71
100
  * @alpha
72
101
  */
73
102
  export interface ExposedProperties {
103
+ /**
104
+ * Expose a property with Zod type checking.
105
+ */
74
106
  exposeProperty<S extends BindableSchema & Ctor, K extends string & ExposableKeys<InstanceType<S>>, TZ extends ZodTypeAny>(schema: S, name: K, def: {
75
107
  schema: TZ;
76
108
  description?: string;
77
109
  } & ReadOnlyRequirement<InstanceType<S>, K> & TypeMatchOrError<InstanceType<S>[K], ZodInfer<TZ>>): void;
110
+ /**
111
+ * Expose a property with type factory type and metadata.
112
+ */
113
+ exposeProperty<S extends BindableSchema & Ctor, K extends string & ExposableKeys<InstanceType<S>>>(schema: S, name: K, def: {
114
+ schema: TypeFactoryType;
115
+ description?: string;
116
+ readOnly?: boolean;
117
+ }): void;
118
+ /**
119
+ * Expose a property with type factory type (simple form).
120
+ */
121
+ exposeProperty<S extends BindableSchema & Ctor, K extends string & ExposableKeys<InstanceType<S>>>(schema: S, name: K, tfType: TypeFactoryType): void;
122
+ /**
123
+ * Create a Zod type that references a SharedTree schema class.
124
+ */
78
125
  instanceOf<T extends TreeNodeSchemaClass>(schema: T): ZodType<InstanceType<T>, ZodTypeDef, InstanceType<T>>;
79
126
  }
80
127
  /**
@@ -92,6 +139,9 @@ export interface ExposedProperties {
92
139
  * @alpha
93
140
  */
94
141
  export interface IExposedProperties {
142
+ /**
143
+ * Static method that exposes properties of this schema class to an agent.
144
+ */
95
145
  [exposePropertiesSymbol]?(properties: ExposedProperties): void;
96
146
  }
97
147
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"propertyBinding.d.ts","sourceRoot":"","sources":["../src/propertyBinding.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,IAAI,QAAQ,EAAE,MAAM,KAAK,CAAC;AAE9E,OAAO,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAG/D;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,OAAO,MAE3C,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI;KAC7B,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,GAAG,KAAK,GAAG,CAAC;CACjE,CAAC,MAAM,CAAC,CAAC,CAAC;AAEX;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,SAAS,CACxF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