@fluidframework/tree 2.31.0 → 2.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/settings.json +1 -1
- package/CHANGELOG.md +44 -0
- package/api-extractor/api-extractor.current.json +5 -1
- package/api-report/tree.alpha.api.md +44 -20
- package/dist/alpha.d.ts +6 -2
- package/dist/feature-libraries/flex-tree/context.d.ts +1 -1
- package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/context.js +1 -2
- package/dist/feature-libraries/flex-tree/context.js.map +1 -1
- package/dist/feature-libraries/flex-tree/index.d.ts +1 -1
- package/dist/feature-libraries/flex-tree/index.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/index.js +1 -2
- package/dist/feature-libraries/flex-tree/index.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyEntity.d.ts +6 -15
- package/dist/feature-libraries/flex-tree/lazyEntity.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyEntity.js +9 -18
- package/dist/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.d.ts +3 -3
- package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.js +14 -14
- package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyNode.d.ts +4 -4
- package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyNode.js +12 -12
- package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
- package/dist/feature-libraries/index.d.ts +1 -1
- package/dist/feature-libraries/index.d.ts.map +1 -1
- package/dist/feature-libraries/index.js +1 -2
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/shared-tree/sharedTree.js +2 -2
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/treeApiAlpha.d.ts +6 -6
- package/dist/shared-tree/treeApiAlpha.d.ts.map +1 -1
- package/dist/shared-tree/treeApiAlpha.js.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.d.ts +0 -6
- package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js +0 -17
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/dist/simple-tree/api/conciseTree.d.ts +2 -2
- package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
- package/dist/simple-tree/api/conciseTree.js.map +1 -1
- package/dist/simple-tree/api/customTree.d.ts +14 -12
- package/dist/simple-tree/api/customTree.d.ts.map +1 -1
- package/dist/simple-tree/api/customTree.js.map +1 -1
- package/dist/simple-tree/api/getJsonSchema.d.ts +21 -7
- package/dist/simple-tree/api/getJsonSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/getJsonSchema.js +8 -16
- package/dist/simple-tree/api/getJsonSchema.js.map +1 -1
- package/dist/simple-tree/api/getSimpleSchema.d.ts +3 -10
- package/dist/simple-tree/api/getSimpleSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/getSimpleSchema.js +4 -16
- package/dist/simple-tree/api/getSimpleSchema.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +4 -3
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +2 -1
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +17 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.js +4 -0
- package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/dist/simple-tree/api/schemaFromSimple.d.ts +5 -2
- package/dist/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFromSimple.js +24 -8
- package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts +11 -3
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +40 -28
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
- package/dist/simple-tree/api/tree.d.ts +32 -5
- package/dist/simple-tree/api/tree.d.ts.map +1 -1
- package/dist/simple-tree/api/tree.js +17 -1
- package/dist/simple-tree/api/tree.js.map +1 -1
- package/dist/simple-tree/api/verboseTree.d.ts +4 -28
- package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
- package/dist/simple-tree/api/verboseTree.js.map +1 -1
- package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/viewSchemaToSimpleSchema.js +7 -3
- package/dist/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.js +7 -6
- package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.js +12 -1
- package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/dist/simple-tree/index.d.ts +1 -1
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +3 -2
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/simpleSchema.d.ts +4 -11
- package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
- package/dist/simple-tree/simpleSchema.js.map +1 -1
- package/dist/tableSchema.d.ts +227 -0
- package/dist/tableSchema.d.ts.map +1 -0
- package/dist/tableSchema.js +234 -0
- package/dist/tableSchema.js.map +1 -0
- package/dist/treeFactory.d.ts +4 -4
- package/dist/treeFactory.d.ts.map +1 -1
- package/dist/treeFactory.js.map +1 -1
- package/dist/util/breakable.d.ts.map +1 -1
- package/dist/util/breakable.js +9 -7
- package/dist/util/breakable.js.map +1 -1
- package/lib/alpha.d.ts +6 -2
- package/lib/feature-libraries/flex-tree/context.d.ts +1 -1
- package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/context.js +1 -2
- package/lib/feature-libraries/flex-tree/context.js.map +1 -1
- package/lib/feature-libraries/flex-tree/index.d.ts +1 -1
- package/lib/feature-libraries/flex-tree/index.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/index.js +1 -1
- package/lib/feature-libraries/flex-tree/index.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyEntity.d.ts +6 -15
- package/lib/feature-libraries/flex-tree/lazyEntity.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyEntity.js +8 -17
- package/lib/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.d.ts +3 -3
- package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.js +15 -15
- package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyNode.d.ts +4 -4
- package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyNode.js +13 -13
- package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
- package/lib/feature-libraries/index.d.ts +1 -1
- package/lib/feature-libraries/index.d.ts.map +1 -1
- package/lib/feature-libraries/index.js +1 -1
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/shared-tree/sharedTree.js +2 -2
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/treeApiAlpha.d.ts +6 -6
- package/lib/shared-tree/treeApiAlpha.d.ts.map +1 -1
- package/lib/shared-tree/treeApiAlpha.js.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.d.ts +0 -6
- package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js +0 -17
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/simple-tree/api/conciseTree.d.ts +2 -2
- package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
- package/lib/simple-tree/api/conciseTree.js.map +1 -1
- package/lib/simple-tree/api/customTree.d.ts +14 -12
- package/lib/simple-tree/api/customTree.d.ts.map +1 -1
- package/lib/simple-tree/api/customTree.js.map +1 -1
- package/lib/simple-tree/api/getJsonSchema.d.ts +21 -7
- package/lib/simple-tree/api/getJsonSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/getJsonSchema.js +8 -16
- package/lib/simple-tree/api/getJsonSchema.js.map +1 -1
- package/lib/simple-tree/api/getSimpleSchema.d.ts +3 -10
- package/lib/simple-tree/api/getSimpleSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/getSimpleSchema.js +4 -16
- package/lib/simple-tree/api/getSimpleSchema.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +4 -3
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js +1 -1
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +17 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.js +4 -0
- package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/lib/simple-tree/api/schemaFromSimple.d.ts +5 -2
- package/lib/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFromSimple.js +24 -8
- package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts +11 -3
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +41 -29
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
- package/lib/simple-tree/api/tree.d.ts +32 -5
- package/lib/simple-tree/api/tree.d.ts.map +1 -1
- package/lib/simple-tree/api/tree.js +16 -1
- package/lib/simple-tree/api/tree.js.map +1 -1
- package/lib/simple-tree/api/verboseTree.d.ts +4 -28
- package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
- package/lib/simple-tree/api/verboseTree.js.map +1 -1
- package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/viewSchemaToSimpleSchema.js +7 -3
- package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.js +8 -7
- package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.js +12 -1
- package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/lib/simple-tree/index.d.ts +1 -1
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +1 -1
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/simpleSchema.d.ts +4 -11
- package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
- package/lib/simple-tree/simpleSchema.js.map +1 -1
- package/lib/tableSchema.d.ts +227 -0
- package/lib/tableSchema.d.ts.map +1 -0
- package/lib/tableSchema.js +231 -0
- package/lib/tableSchema.js.map +1 -0
- package/lib/treeFactory.d.ts +4 -4
- package/lib/treeFactory.d.ts.map +1 -1
- package/lib/treeFactory.js.map +1 -1
- package/lib/util/breakable.d.ts.map +1 -1
- package/lib/util/breakable.js +9 -7
- package/lib/util/breakable.js.map +1 -1
- package/package.json +25 -37
- package/src/feature-libraries/flex-tree/context.ts +2 -2
- package/src/feature-libraries/flex-tree/index.ts +0 -1
- package/src/feature-libraries/flex-tree/lazyEntity.ts +11 -21
- package/src/feature-libraries/flex-tree/lazyField.ts +17 -26
- package/src/feature-libraries/flex-tree/lazyNode.ts +13 -19
- package/src/feature-libraries/index.ts +0 -1
- package/src/index.ts +6 -2
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/sharedTree.ts +2 -2
- package/src/shared-tree/treeApiAlpha.ts +17 -15
- package/src/shared-tree-core/sharedTreeCore.ts +0 -23
- package/src/simple-tree/api/conciseTree.ts +4 -4
- package/src/simple-tree/api/customTree.ts +16 -14
- package/src/simple-tree/api/getJsonSchema.ts +25 -16
- package/src/simple-tree/api/getSimpleSchema.ts +4 -18
- package/src/simple-tree/api/index.ts +4 -2
- package/src/simple-tree/api/schemaFactoryAlpha.ts +18 -1
- package/src/simple-tree/api/schemaFromSimple.ts +45 -16
- package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +53 -34
- package/src/simple-tree/api/tree.ts +51 -4
- package/src/simple-tree/api/verboseTree.ts +7 -32
- package/src/simple-tree/api/viewSchemaToSimpleSchema.ts +8 -3
- package/src/simple-tree/core/treeNodeKernel.ts +11 -7
- package/src/simple-tree/core/unhydratedFlexTree.ts +17 -4
- package/src/simple-tree/index.ts +4 -2
- package/src/simple-tree/simpleSchema.ts +4 -12
- package/src/tableSchema.ts +609 -0
- package/src/treeFactory.ts +4 -3
- package/src/util/breakable.ts +9 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/simple-tree/api/index.ts"],"names":[],"mappings":";AAAA;;;GAG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A,QAAQ,OAAA;AAGT,6DAAuE;AAA9D,qIAAA,8BAA8B,OAAA;AACvC,6EAAmE;AAA1D,iIAAA,kBAAkB,OAAA;AAE3B,6FAA6F;AAC7F,4IAA4I;AAC5I,mEAIkC;AAHjC,8HAAA,eAAe,OAAwB;AACvC,mIAAA,IAAI,OAA6B;AACjC,sIAAA,uBAAuB,OAAgC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\ttype ITree,\n\ttype TreeView,\n\ttype ViewableTree,\n\ttype TreeViewEvents,\n\tTreeViewConfiguration,\n\tTreeViewConfigurationAlpha,\n\ttype TreeSchema,\n\ttype ITreeViewConfiguration,\n\ttype SchemaCompatibilityStatus,\n\ttype ITreeConfigurationOptions,\n\ttype TreeViewAlpha,\n\ttype TreeBranch,\n\ttype TreeBranchEvents,\n\ttype ITreeAlpha,\n\tasTreeViewAlpha,\n} from \"./tree.js\";\nexport {\n\tSchemaFactory,\n\ttype ScopedSchemaName,\n\ttype SchemaFactoryObjectOptions,\n\ttype SchemaStatics,\n} from \"./schemaFactory.js\";\nexport { SchemaFactoryAlpha } from \"./schemaFactoryAlpha.js\";\nexport type {\n\tValidateRecursiveSchema,\n\tFixRecursiveArraySchema,\n} from \"./schemaFactoryRecursive.js\";\nexport {\n\tadaptEnum,\n\tenumFromStrings,\n\tsingletonSchema,\n} from \"./schemaCreationUtilities.js\";\nexport { treeNodeApi, type TreeNodeApi, tryGetSchema } from \"./treeNodeApi.js\";\nexport { createFromInsertable, cursorFromInsertable, createFromCursor } from \"./create.js\";\nexport {\n\ttype JsonSchemaId,\n\ttype JsonSchemaType,\n\ttype JsonObjectNodeSchema,\n\ttype JsonArrayNodeSchema,\n\ttype JsonMapNodeSchema,\n\ttype JsonLeafNodeSchema,\n\ttype JsonSchemaRef,\n\ttype JsonRefPath,\n\ttype JsonNodeSchema,\n\ttype JsonNodeSchemaBase,\n\ttype JsonTreeSchema,\n\ttype JsonFieldSchema,\n\ttype JsonLeafSchemaType,\n} from \"./jsonSchema.js\";\nexport type { TreeSchemaEncodingOptions } from \"./getJsonSchema.js\";\nexport { getJsonSchema } from \"./getJsonSchema.js\";\nexport { getSimpleSchema } from \"./getSimpleSchema.js\";\nexport { ViewSchema } from \"./view.js\";\nexport type {\n\tUnenforced,\n\tFieldHasDefaultUnsafe,\n\tObjectFromSchemaRecordUnsafe,\n\tTreeObjectNodeUnsafe,\n\tTreeFieldFromImplicitFieldUnsafe,\n\tTreeNodeFromImplicitAllowedTypesUnsafe,\n\tFieldSchemaUnsafe,\n\tInsertableTreeNodeFromImplicitAllowedTypesUnsafe,\n\tTreeArrayNodeUnsafe,\n\tTreeMapNodeUnsafe,\n\tInsertableObjectFromSchemaRecordUnsafe,\n\tInsertableTreeFieldFromImplicitFieldUnsafe,\n\tInsertableTypedNodeUnsafe,\n\tNodeBuilderDataUnsafe,\n\tNodeFromSchemaUnsafe,\n\tReadonlyMapInlined,\n\tTreeNodeSchemaClassUnsafe,\n\tTreeNodeSchemaUnsafe,\n\tAllowedTypesUnsafe,\n\tImplicitAllowedTypesUnsafe,\n\tImplicitFieldSchemaUnsafe,\n\tTreeNodeSchemaNonClassUnsafe,\n\tInsertableTreeNodeFromAllowedTypesUnsafe,\n\tFieldSchemaAlphaUnsafe,\n\tArrayNodeCustomizableSchemaUnsafe,\n\tMapNodeCustomizableSchemaUnsafe,\n} from \"./typesUnsafe.js\";\n\nexport {\n\ttype VerboseTreeNode,\n\ttype VerboseTree,\n\tapplySchemaToParserOptions,\n\tcursorFromVerbose,\n\tverboseFromCursor,\n\treplaceVerboseTreeHandles,\n} from \"./verboseTree.js\";\n\nexport {\n\ttype TreeEncodingOptions,\n\tcustomFromCursorStored,\n\ttype CustomTreeNode,\n\ttype CustomTreeValue,\n\ttryStoredSchemaAsArray,\n\treplaceHandles,\n\ttype HandleConverter,\n} from \"./customTree.js\";\n\nexport {\n\ttype ConciseTree,\n\tconciseFromCursor,\n\treplaceConciseTreeHandles,\n} from \"./conciseTree.js\";\n\nexport { TreeBeta, type NodeChangedData, type TreeChangeEventsBeta } from \"./treeApiBeta.js\";\nexport { createSimpleTreeIndex, type SimpleTreeIndex } from \"./simpleTreeIndex.js\";\nexport {\n\tcreateIdentifierIndex,\n\ttype IdentifierIndex,\n} from \"./identifierIndex.js\";\n\nexport {\n\textractPersistedSchema,\n\tcomparePersistedSchemaInternal,\n\tcomparePersistedSchema,\n} from \"./storedSchema.js\";\n\nexport {\n\ttype TransactionConstraint,\n\ttype NodeInDocumentConstraint,\n\ttype RunTransactionParams,\n\ttype VoidTransactionCallbackStatus,\n\ttype TransactionCallbackStatus,\n\ttype TransactionResult,\n\ttype TransactionResultExt,\n\ttype TransactionResultSuccess,\n\ttype TransactionResultFailed,\n\trollback,\n} from \"./transactionTypes.js\";\n\nexport { generateSchemaFromSimpleSchema } from \"./schemaFromSimple.js\";\nexport { toSimpleTreeSchema } from \"./viewSchemaToSimpleSchema.js\";\n\n// Exporting the schema (RecursiveObject) to test that recursive types are working correctly.\n// These are `@internal` so they can't be included in the `InternalClassTreeTypes` due to https://github.com/microsoft/rushstack/issues/3639\nexport {\n\tRecursiveObject as test_RecursiveObject,\n\tbase as test_RecursiveObject_base,\n\tRecursiveObjectPojoMode as test_RecursiveObjectPojoMode,\n} from \"./testRecursiveDomain.js\";\n"]}
|
|
@@ -30,11 +30,27 @@ export declare class SchemaFactoryAlpha<out TScope extends string | undefined =
|
|
|
30
30
|
* @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.
|
|
31
31
|
* @param options - Additional options for the schema.
|
|
32
32
|
*/
|
|
33
|
-
object<const Name extends TName, const T extends RestrictiveStringRecord<ImplicitFieldSchema>, const TCustomMetadata = unknown>(name: Name, fields: T, options?: SchemaFactoryObjectOptions<TCustomMetadata>): ObjectNodeSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata
|
|
33
|
+
object<const Name extends TName, const T extends RestrictiveStringRecord<ImplicitFieldSchema>, const TCustomMetadata = unknown>(name: Name, fields: T, options?: SchemaFactoryObjectOptions<TCustomMetadata>): ObjectNodeSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> & {
|
|
34
|
+
/**
|
|
35
|
+
* Typing checking workaround: not for for actual use.
|
|
36
|
+
* @remarks
|
|
37
|
+
* This API collides with {@link TreeNodeSchemaCore.createFromInsertable} to disable a type checking optimization which produces different and undesired results.
|
|
38
|
+
* See {@link https://github.com/microsoft/TypeScript/issues/59049#issuecomment-2773459693} for more details.
|
|
39
|
+
* @privateRemarks
|
|
40
|
+
* The specific issue here is non-empty POJO mode object schema not being assignable to `ObjectNodeSchema`,
|
|
41
|
+
* See the above link and the tests in objectNode.spec.ts which reference it.
|
|
42
|
+
* @system
|
|
43
|
+
*/
|
|
44
|
+
readonly createFromInsertable: unknown;
|
|
45
|
+
};
|
|
34
46
|
/**
|
|
35
47
|
* {@inheritdoc SchemaFactory.objectRecursive}
|
|
36
48
|
*/
|
|
37
49
|
objectRecursive<const Name extends TName, const T extends RestrictiveStringRecord<ImplicitFieldSchemaUnsafe>, const TCustomMetadata = unknown>(name: Name, t: T, options?: SchemaFactoryObjectOptions<TCustomMetadata>): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Object, TreeObjectNodeUnsafe<T, ScopedSchemaName<TScope, Name>>, object & InsertableObjectFromSchemaRecordUnsafe<T>, false, T, never, TCustomMetadata> & SimpleObjectNodeSchema<TCustomMetadata> & Pick<ObjectNodeSchema, "fields">;
|
|
50
|
+
/**
|
|
51
|
+
* {@inheritDoc SchemaStatics.optional}
|
|
52
|
+
*/
|
|
53
|
+
static readonly leaves: readonly [import("../leafNodeSchema.js").LeafSchema<"string", string> & import("../simpleSchema.js").SimpleLeafNodeSchema, import("../leafNodeSchema.js").LeafSchema<"number", number> & import("../simpleSchema.js").SimpleLeafNodeSchema, import("../leafNodeSchema.js").LeafSchema<"boolean", boolean> & import("../simpleSchema.js").SimpleLeafNodeSchema, import("../leafNodeSchema.js").LeafSchema<"null", null> & import("../simpleSchema.js").SimpleLeafNodeSchema, import("../leafNodeSchema.js").LeafSchema<"handle", import("@fluidframework/core-interfaces").IFluidHandle<unknown>> & import("../simpleSchema.js").SimpleLeafNodeSchema];
|
|
38
54
|
/**
|
|
39
55
|
* {@inheritDoc SchemaStatics.optional}
|
|
40
56
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemaFactoryAlpha.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaFactoryAlpha.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,gBAAgB,EAChB,oBAAoB,EACpB,sCAAsC,EACtC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAEN,aAAa,EAEb,KAAK,0BAA0B,EAC/B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EACX,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EACjB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,KAAK,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,KAAK,EACX,0BAA0B,EAC1B,yBAAyB,EACzB,iCAAiC,EACjC,+BAA+B,EAC/B,MAAM,kBAAkB,CAAC;AAG1B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAEpE;;;;;;;;GAQG;AACH,qBAAa,kBAAkB,CAC9B,GAAG,CAAC,MAAM,SAAS,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,EAC1D,KAAK,SAAS,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;IAIxF;;OAEG;IAEa,cAAc,CAC7B,KAAK,CAAC,IAAI,SAAS,KAAK,EACxB,KAAK,CAAC,CAAC,SAAS,0BAA0B,EAC1C,KAAK,CAAC,eAAe,GAAG,OAAO,EAC9B,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,iBAAiB,CAAC,eAAe,CAAC;IAY3E;;;;;OAKG;IACI,aAAa,CAAC,KAAK,CAAC,CAAC,SAAS,KAAK,EAAE,UAAU,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,EACtF,IAAI,EAAE,CAAC,GACL,kBAAkB,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,UAAU,CAAC;CAG9D"}
|
|
@@ -96,6 +96,10 @@ class SchemaFactoryAlpha extends schemaFactory_js_1.SchemaFactory {
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
exports.SchemaFactoryAlpha = SchemaFactoryAlpha;
|
|
99
|
+
/**
|
|
100
|
+
* {@inheritDoc SchemaStatics.optional}
|
|
101
|
+
*/
|
|
102
|
+
SchemaFactoryAlpha.leaves = schemaFactory_js_1.schemaStatics.leaves;
|
|
99
103
|
/**
|
|
100
104
|
* {@inheritDoc SchemaStatics.optional}
|
|
101
105
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemaFactoryAlpha.js","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaFactoryAlpha.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH,yDAK4B;AAM5B,oDAAgD;AAShD,8CAA0C;AAC1C,kDAA8C;AAM9C;;;;;;;;GAQG;AACH,MAAa,kBAGX,SAAQ,gCAA4B;IAC7B,OAAO,CAA8B,IAAU;QACtD,OAAO,CACN,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,EAA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IAED;;;;;OAKG;IACI,aAAa,CACnB,IAAO;QAEP,OAAO,IAAI,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IACnD,CAAC;;AApNF,gDAqNC;AAzHA;;GAEG;AAC6B,2BAAQ,GAAG,gCAAa,CAAC,QAAQ,CAAC;AAElE;;GAEG;AAC6B,2BAAQ,GAAG,gCAAa,CAAC,QAAQ,CAAC;AAElE;;GAEG;AAC6B,oCAAiB,GAAG,gCAAa,CAAC,iBAAiB,CAAC;AAEpF;;GAEG;AACoB,6BAAU,GAAG,gCAAa,CAAC,UAAU,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tScopedSchemaName,\n\tTreeObjectNodeUnsafe,\n\tInsertableObjectFromSchemaRecordUnsafe,\n} from \"../../internalTypes.js\";\nimport {\n\tdefaultSchemaFactoryObjectOptions,\n\tSchemaFactory,\n\tschemaStatics,\n\ttype SchemaFactoryObjectOptions,\n} from \"./schemaFactory.js\";\nimport type {\n\tImplicitAllowedTypes,\n\tImplicitFieldSchema,\n\tNodeSchemaOptions,\n} from \"../schemaTypes.js\";\nimport { objectSchema } from \"../objectNode.js\";\nimport type { RestrictiveStringRecord } from \"../../util/index.js\";\nimport type { NodeKind, TreeNodeSchemaClass } from \"../core/index.js\";\nimport type {\n\tImplicitAllowedTypesUnsafe,\n\tImplicitFieldSchemaUnsafe,\n\tArrayNodeCustomizableSchemaUnsafe,\n\tMapNodeCustomizableSchemaUnsafe,\n} from \"./typesUnsafe.js\";\nimport { mapSchema } from \"../mapNode.js\";\nimport { arraySchema } from \"../arrayNode.js\";\nimport type { ObjectNodeSchema } from \"../objectNodeTypes.js\";\nimport type { SimpleObjectNodeSchema } from \"../simpleSchema.js\";\nimport type { ArrayNodeCustomizableSchema } from \"../arrayNodeTypes.js\";\nimport type { MapNodeCustomizableSchema } from \"../mapNodeTypes.js\";\n\n/**\n * {@link SchemaFactory} with additional alpha APIs.\n *\n * @alpha\n * @privateRemarks\n *\n * Some private methods on `SchemaFactory` are intentionally duplicated here to avoid increasing their exposure to `protected`.\n * If we were to do so, they would be exposed on the public API surface of `SchemaFactory`.\n */\nexport class SchemaFactoryAlpha<\n\tout TScope extends string | undefined = string | undefined,\n\tTName extends number | string = string,\n> extends SchemaFactory<TScope, TName> {\n\tprivate scoped2<Name extends TName | string>(name: Name): ScopedSchemaName<TScope, Name> {\n\t\treturn (\n\t\t\tthis.scope === undefined ? `${name}` : `${this.scope}.${name}`\n\t\t) as ScopedSchemaName<TScope, Name>;\n\t}\n\n\t/**\n\t * Define a {@link TreeNodeSchemaClass} for a {@link TreeObjectNode}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.\n\t * @param options - Additional options for the schema.\n\t */\n\tpublic override object<\n\t\tconst Name extends TName,\n\t\tconst T extends RestrictiveStringRecord<ImplicitFieldSchema>,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tfields: T,\n\t\toptions?: SchemaFactoryObjectOptions<TCustomMetadata>,\n\t): ObjectNodeSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> {\n\t\treturn objectSchema(\n\t\t\tthis.scoped2(name),\n\t\t\tfields,\n\t\t\ttrue,\n\t\t\toptions?.allowUnknownOptionalFields ??\n\t\t\t\tdefaultSchemaFactoryObjectOptions.allowUnknownOptionalFields,\n\t\t\toptions?.metadata,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritdoc SchemaFactory.objectRecursive}\n\t */\n\tpublic override objectRecursive<\n\t\tconst Name extends TName,\n\t\tconst T extends RestrictiveStringRecord<ImplicitFieldSchemaUnsafe>,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tt: T,\n\t\toptions?: SchemaFactoryObjectOptions<TCustomMetadata>,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Object,\n\t\tTreeObjectNodeUnsafe<T, ScopedSchemaName<TScope, Name>>,\n\t\tobject & InsertableObjectFromSchemaRecordUnsafe<T>,\n\t\tfalse,\n\t\tT,\n\t\tnever,\n\t\tTCustomMetadata\n\t> &\n\t\tSimpleObjectNodeSchema<TCustomMetadata> &\n\t\t// We can't just use non generic `ObjectNodeSchema` here since \"Base constructors must all have the same return type\".\n\t\t// We also can't just use generic `ObjectNodeSchema` here and not `TreeNodeSchemaClass` since that doesn't work with unsafe recursive types.\n\t\t// ObjectNodeSchema<\n\t\t// \tScopedSchemaName<TScope, Name>,\n\t\t// \t// T & RestrictiveStringRecord<ImplicitFieldSchema> would be nice to use here, but it breaks the recursive type self references.\n\t\t// \tRestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t// \tfalse,\n\t\t// \tTCustomMetadata\n\t\t// >\n\t\tPick<ObjectNodeSchema, \"fields\"> {\n\t\t// TODO: syntax highting is vs code is broken here. Don't trust it. Use the compiler instead.\n\t\ttype TScopedName = ScopedSchemaName<TScope, Name>;\n\t\treturn this.object(\n\t\t\tname,\n\t\t\tt as T & RestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t\toptions,\n\t\t) as unknown as TreeNodeSchemaClass<\n\t\t\tTScopedName,\n\t\t\tNodeKind.Object,\n\t\t\tTreeObjectNodeUnsafe<T, TScopedName>,\n\t\t\tobject & InsertableObjectFromSchemaRecordUnsafe<T>,\n\t\t\tfalse,\n\t\t\tT,\n\t\t\tnever,\n\t\t\tTCustomMetadata\n\t\t> &\n\t\t\tObjectNodeSchema<\n\t\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\t\tRestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t\t\tfalse,\n\t\t\t\tTCustomMetadata\n\t\t\t>;\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optional}\n\t */\n\tpublic static override readonly optional = schemaStatics.optional;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.required}\n\t */\n\tpublic static override readonly required = schemaStatics.required;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optionalRecursive}\n\t */\n\tpublic static override readonly optionalRecursive = schemaStatics.optionalRecursive;\n\n\t/**\n\t * Like {@link SchemaFactory.identifier} but static and a factory function that can be provided {@link FieldProps}.\n\t */\n\tpublic static readonly identifier = schemaStatics.identifier;\n\n\t/**\n\t * Define a {@link TreeNodeSchema} for a {@link TreeMapNode}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear as values in the map.\n\t * @param options - Additional options for the schema.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedMap extends factory.map(\"name\", factory.number, {\n\t * \tmetadata: { description: \"A map of numbers\" }\n\t * }) {}\n\t * ```\n\t */\n\tpublic mapAlpha<\n\t\tName extends TName,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\toptions?: NodeSchemaOptions<TCustomMetadata>,\n\t): MapNodeCustomizableSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> {\n\t\treturn mapSchema(this.scoped2(name), allowedTypes, true, true, options?.metadata);\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaFactory.objectRecursive}\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic override mapRecursive<\n\t\tName extends TName,\n\t\tconst T extends ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(name: Name, allowedTypes: T, options?: NodeSchemaOptions<TCustomMetadata>) {\n\t\treturn this.mapAlpha(\n\t\t\tname,\n\t\t\tallowedTypes as T & ImplicitAllowedTypes,\n\t\t\toptions,\n\t\t) as unknown as MapNodeCustomizableSchemaUnsafe<\n\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\tT,\n\t\t\tTCustomMetadata\n\t\t>;\n\t}\n\n\t/**\n\t * Define (and add to this library) a {@link TreeNodeSchemaClass} for a {@link (TreeArrayNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear in the array.\n\t * @param options - Additional options for the schema.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedArray extends factory.arrayAlpha(\"name\", factory.number) {}\n\t * ```\n\t */\n\tpublic arrayAlpha<\n\t\tconst Name extends TName,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\toptions?: NodeSchemaOptions<TCustomMetadata>,\n\t): ArrayNodeCustomizableSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> {\n\t\treturn arraySchema(this.scoped2(name), allowedTypes, true, true, options?.metadata);\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaFactory.objectRecursive}\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic override arrayRecursive<\n\t\tconst Name extends TName,\n\t\tconst T extends ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(name: Name, allowedTypes: T, options?: NodeSchemaOptions<TCustomMetadata>) {\n\t\treturn this.arrayAlpha(\n\t\t\tname,\n\t\t\tallowedTypes as T & ImplicitAllowedTypes,\n\t\t\toptions,\n\t\t) as unknown as ArrayNodeCustomizableSchemaUnsafe<\n\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\tT,\n\t\t\tTCustomMetadata\n\t\t>;\n\t}\n\n\t/**\n\t * Create a {@link SchemaFactory} with a {@link SchemaFactory.scope|scope} which is a combination of this factory's scope and the provided name.\n\t * @remarks\n\t * The main use-case for this is when creating a collection of related schema (for example using a function that creates multiple schema).\n\t * Creating such related schema using a sub-scope helps ensure they won't collide with other schema in the parent scope.\n\t */\n\tpublic scopedFactory<const T extends TName, TNameInner extends number | string = string>(\n\t\tname: T,\n\t): SchemaFactoryAlpha<ScopedSchemaName<TScope, T>, TNameInner> {\n\t\treturn new SchemaFactoryAlpha(this.scoped2(name));\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"schemaFactoryAlpha.js","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaFactoryAlpha.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH,yDAK4B;AAM5B,oDAAgD;AAShD,8CAA0C;AAC1C,kDAA8C;AAM9C;;;;;;;;GAQG;AACH,MAAa,kBAGX,SAAQ,gCAA4B;IAC7B,OAAO,CAA8B,IAAU;QACtD,OAAO,CACN,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,EAAE,CAC5B,CAAC;IACrC,CAAC;IAED;;;;;;OAMG;IACa,MAAM,CAKrB,IAAU,EACV,MAAS,EACT,OAAqD;QAcrD,OAAO,IAAA,4BAAY,EAClB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAClB,MAAM,EACN,IAAI,EACJ,OAAO,EAAE,0BAA0B;YAClC,oDAAiC,CAAC,0BAA0B,EAC7D,OAAO,EAAE,QAAQ,CACjB,CAAC;IACH,CAAC;IAED;;OAEG;IACa,eAAe,CAK9B,IAAU,EACV,CAAI,EACJ,OAAqD;QAwBrD,OAAO,IAAI,CAAC,MAAM,CACjB,IAAI,EACJ,CAAqD,EACrD,OAAO,CAgBN,CAAC;IACJ,CAAC;IA2BD;;;;;;;;;;;;;OAaG;IACI,QAAQ,CAKd,IAAU,EACV,YAAe,EACf,OAA4C;QAE5C,OAAO,IAAA,sBAAS,EAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IACnF,CAAC;IAED;;OAEG;IACH,4EAA4E;IAC5D,YAAY,CAI1B,IAAU,EAAE,YAAe,EAAE,OAA4C;QAC1E,OAAO,IAAI,CAAC,QAAQ,CACnB,IAAI,EACJ,YAAwC,EACxC,OAAO,CAKP,CAAC;IACH,CAAC;IAED;;;;;;;;;;;OAWG;IACI,UAAU,CAKhB,IAAU,EACV,YAAe,EACf,OAA4C;QAE5C,OAAO,IAAA,0BAAW,EAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IACrF,CAAC;IAED;;OAEG;IACH,4EAA4E;IAC5D,cAAc,CAI5B,IAAU,EAAE,YAAe,EAAE,OAA4C;QAC1E,OAAO,IAAI,CAAC,UAAU,CACrB,IAAI,EACJ,YAAwC,EACxC,OAAO,CAKP,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACI,aAAa,CACnB,IAAO;QAEP,OAAO,IAAI,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IACnD,CAAC;;AArOF,gDAsOC;AA9HA;;GAEG;AAC6B,yBAAM,GAAG,gCAAa,CAAC,MAAM,CAAC;AAE9D;;GAEG;AAC6B,2BAAQ,GAAG,gCAAa,CAAC,QAAQ,CAAC;AAElE;;GAEG;AAC6B,2BAAQ,GAAG,gCAAa,CAAC,QAAQ,CAAC;AAElE;;GAEG;AAC6B,oCAAiB,GAAG,gCAAa,CAAC,iBAAiB,CAAC;AAEpF;;GAEG;AACoB,6BAAU,GAAG,gCAAa,CAAC,UAAU,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tScopedSchemaName,\n\tTreeObjectNodeUnsafe,\n\tInsertableObjectFromSchemaRecordUnsafe,\n} from \"../../internalTypes.js\";\nimport {\n\tdefaultSchemaFactoryObjectOptions,\n\tSchemaFactory,\n\tschemaStatics,\n\ttype SchemaFactoryObjectOptions,\n} from \"./schemaFactory.js\";\nimport type {\n\tImplicitAllowedTypes,\n\tImplicitFieldSchema,\n\tNodeSchemaOptions,\n} from \"../schemaTypes.js\";\nimport { objectSchema } from \"../objectNode.js\";\nimport type { RestrictiveStringRecord } from \"../../util/index.js\";\nimport type { NodeKind, TreeNodeSchemaClass } from \"../core/index.js\";\nimport type {\n\tImplicitAllowedTypesUnsafe,\n\tImplicitFieldSchemaUnsafe,\n\tArrayNodeCustomizableSchemaUnsafe,\n\tMapNodeCustomizableSchemaUnsafe,\n} from \"./typesUnsafe.js\";\nimport { mapSchema } from \"../mapNode.js\";\nimport { arraySchema } from \"../arrayNode.js\";\nimport type { ObjectNodeSchema } from \"../objectNodeTypes.js\";\nimport type { SimpleObjectNodeSchema } from \"../simpleSchema.js\";\nimport type { ArrayNodeCustomizableSchema } from \"../arrayNodeTypes.js\";\nimport type { MapNodeCustomizableSchema } from \"../mapNodeTypes.js\";\n\n/**\n * {@link SchemaFactory} with additional alpha APIs.\n *\n * @alpha\n * @privateRemarks\n *\n * Some private methods on `SchemaFactory` are intentionally duplicated here to avoid increasing their exposure to `protected`.\n * If we were to do so, they would be exposed on the public API surface of `SchemaFactory`.\n */\nexport class SchemaFactoryAlpha<\n\tout TScope extends string | undefined = string | undefined,\n\tTName extends number | string = string,\n> extends SchemaFactory<TScope, TName> {\n\tprivate scoped2<Name extends TName | string>(name: Name): ScopedSchemaName<TScope, Name> {\n\t\treturn (\n\t\t\tthis.scope === undefined ? `${name}` : `${this.scope}.${name}`\n\t\t) as ScopedSchemaName<TScope, Name>;\n\t}\n\n\t/**\n\t * Define a {@link TreeNodeSchemaClass} for a {@link TreeObjectNode}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.\n\t * @param options - Additional options for the schema.\n\t */\n\tpublic override object<\n\t\tconst Name extends TName,\n\t\tconst T extends RestrictiveStringRecord<ImplicitFieldSchema>,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tfields: T,\n\t\toptions?: SchemaFactoryObjectOptions<TCustomMetadata>,\n\t): ObjectNodeSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> & {\n\t\t/**\n\t\t * Typing checking workaround: not for for actual use.\n\t\t * @remarks\n\t\t * This API collides with {@link TreeNodeSchemaCore.createFromInsertable} to disable a type checking optimization which produces different and undesired results.\n\t\t * See {@link https://github.com/microsoft/TypeScript/issues/59049#issuecomment-2773459693} for more details.\n\t\t * @privateRemarks\n\t\t * The specific issue here is non-empty POJO mode object schema not being assignable to `ObjectNodeSchema`,\n\t\t * See the above link and the tests in objectNode.spec.ts which reference it.\n\t\t * @system\n\t\t */\n\t\treadonly createFromInsertable: unknown;\n\t} {\n\t\treturn objectSchema(\n\t\t\tthis.scoped2(name),\n\t\t\tfields,\n\t\t\ttrue,\n\t\t\toptions?.allowUnknownOptionalFields ??\n\t\t\t\tdefaultSchemaFactoryObjectOptions.allowUnknownOptionalFields,\n\t\t\toptions?.metadata,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritdoc SchemaFactory.objectRecursive}\n\t */\n\tpublic override objectRecursive<\n\t\tconst Name extends TName,\n\t\tconst T extends RestrictiveStringRecord<ImplicitFieldSchemaUnsafe>,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tt: T,\n\t\toptions?: SchemaFactoryObjectOptions<TCustomMetadata>,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Object,\n\t\tTreeObjectNodeUnsafe<T, ScopedSchemaName<TScope, Name>>,\n\t\tobject & InsertableObjectFromSchemaRecordUnsafe<T>,\n\t\tfalse,\n\t\tT,\n\t\tnever,\n\t\tTCustomMetadata\n\t> &\n\t\tSimpleObjectNodeSchema<TCustomMetadata> &\n\t\t// We can't just use non generic `ObjectNodeSchema` here since \"Base constructors must all have the same return type\".\n\t\t// We also can't just use generic `ObjectNodeSchema` here and not `TreeNodeSchemaClass` since that doesn't work with unsafe recursive types.\n\t\t// ObjectNodeSchema<\n\t\t// \tScopedSchemaName<TScope, Name>,\n\t\t// \t// T & RestrictiveStringRecord<ImplicitFieldSchema> would be nice to use here, but it breaks the recursive type self references.\n\t\t// \tRestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t// \tfalse,\n\t\t// \tTCustomMetadata\n\t\t// >\n\t\tPick<ObjectNodeSchema, \"fields\"> {\n\t\t// TODO: syntax highting is vs code is broken here. Don't trust it. Use the compiler instead.\n\t\ttype TScopedName = ScopedSchemaName<TScope, Name>;\n\t\treturn this.object(\n\t\t\tname,\n\t\t\tt as T & RestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t\toptions,\n\t\t) as unknown as TreeNodeSchemaClass<\n\t\t\tTScopedName,\n\t\t\tNodeKind.Object,\n\t\t\tTreeObjectNodeUnsafe<T, TScopedName>,\n\t\t\tobject & InsertableObjectFromSchemaRecordUnsafe<T>,\n\t\t\tfalse,\n\t\t\tT,\n\t\t\tnever,\n\t\t\tTCustomMetadata\n\t\t> &\n\t\t\tObjectNodeSchema<\n\t\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\t\tRestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t\t\tfalse,\n\t\t\t\tTCustomMetadata\n\t\t\t>;\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optional}\n\t */\n\tpublic static override readonly leaves = schemaStatics.leaves;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optional}\n\t */\n\tpublic static override readonly optional = schemaStatics.optional;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.required}\n\t */\n\tpublic static override readonly required = schemaStatics.required;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optionalRecursive}\n\t */\n\tpublic static override readonly optionalRecursive = schemaStatics.optionalRecursive;\n\n\t/**\n\t * Like {@link SchemaFactory.identifier} but static and a factory function that can be provided {@link FieldProps}.\n\t */\n\tpublic static readonly identifier = schemaStatics.identifier;\n\n\t/**\n\t * Define a {@link TreeNodeSchema} for a {@link TreeMapNode}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear as values in the map.\n\t * @param options - Additional options for the schema.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedMap extends factory.map(\"name\", factory.number, {\n\t * \tmetadata: { description: \"A map of numbers\" }\n\t * }) {}\n\t * ```\n\t */\n\tpublic mapAlpha<\n\t\tName extends TName,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\toptions?: NodeSchemaOptions<TCustomMetadata>,\n\t): MapNodeCustomizableSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> {\n\t\treturn mapSchema(this.scoped2(name), allowedTypes, true, true, options?.metadata);\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaFactory.objectRecursive}\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic override mapRecursive<\n\t\tName extends TName,\n\t\tconst T extends ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(name: Name, allowedTypes: T, options?: NodeSchemaOptions<TCustomMetadata>) {\n\t\treturn this.mapAlpha(\n\t\t\tname,\n\t\t\tallowedTypes as T & ImplicitAllowedTypes,\n\t\t\toptions,\n\t\t) as unknown as MapNodeCustomizableSchemaUnsafe<\n\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\tT,\n\t\t\tTCustomMetadata\n\t\t>;\n\t}\n\n\t/**\n\t * Define (and add to this library) a {@link TreeNodeSchemaClass} for a {@link (TreeArrayNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear in the array.\n\t * @param options - Additional options for the schema.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedArray extends factory.arrayAlpha(\"name\", factory.number) {}\n\t * ```\n\t */\n\tpublic arrayAlpha<\n\t\tconst Name extends TName,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\toptions?: NodeSchemaOptions<TCustomMetadata>,\n\t): ArrayNodeCustomizableSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> {\n\t\treturn arraySchema(this.scoped2(name), allowedTypes, true, true, options?.metadata);\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaFactory.objectRecursive}\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic override arrayRecursive<\n\t\tconst Name extends TName,\n\t\tconst T extends ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(name: Name, allowedTypes: T, options?: NodeSchemaOptions<TCustomMetadata>) {\n\t\treturn this.arrayAlpha(\n\t\t\tname,\n\t\t\tallowedTypes as T & ImplicitAllowedTypes,\n\t\t\toptions,\n\t\t) as unknown as ArrayNodeCustomizableSchemaUnsafe<\n\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\tT,\n\t\t\tTCustomMetadata\n\t\t>;\n\t}\n\n\t/**\n\t * Create a {@link SchemaFactory} with a {@link SchemaFactory.scope|scope} which is a combination of this factory's scope and the provided name.\n\t * @remarks\n\t * The main use-case for this is when creating a collection of related schema (for example using a function that creates multiple schema).\n\t * Creating such related schema using a sub-scope helps ensure they won't collide with other schema in the parent scope.\n\t */\n\tpublic scopedFactory<const T extends TName, TNameInner extends number | string = string>(\n\t\tname: T,\n\t): SchemaFactoryAlpha<ScopedSchemaName<TScope, T>, TNameInner> {\n\t\treturn new SchemaFactoryAlpha(this.scoped2(name));\n\t}\n}\n"]}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { type FieldSchemaAlpha } from "../schemaTypes.js";
|
|
6
5
|
import type { SimpleTreeSchema } from "../simpleSchema.js";
|
|
6
|
+
import type { TreeSchema } from "./tree.js";
|
|
7
7
|
/**
|
|
8
8
|
* Create {@link FieldSchema} from a SimpleTreeSchema.
|
|
9
9
|
* @remarks
|
|
@@ -13,7 +13,10 @@ import type { SimpleTreeSchema } from "../simpleSchema.js";
|
|
|
13
13
|
* will produce a poor TypeScript typing experience which is subject to change.
|
|
14
14
|
*
|
|
15
15
|
* Editing through a view produced using this schema can easily violate invariants other users of the document might expect and must be done with great care.
|
|
16
|
+
*
|
|
17
|
+
* This API bakes in some arbitrary policy choices for how to handle data that is not included in the SimpleTreeSchema API, for example the value of `allowUnknownOptionalFields`.
|
|
18
|
+
* If any particular choice is required for such cases, this API should not be used.
|
|
16
19
|
* @alpha
|
|
17
20
|
*/
|
|
18
|
-
export declare function generateSchemaFromSimpleSchema(simple: SimpleTreeSchema):
|
|
21
|
+
export declare function generateSchemaFromSimpleSchema(simple: SimpleTreeSchema): TreeSchema;
|
|
19
22
|
//# sourceMappingURL=schemaFromSimple.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemaFromSimple.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaFromSimple.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"schemaFromSimple.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaFromSimple.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAWH,OAAO,KAAK,EAGX,gBAAgB,EAChB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAI5C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,gBAAgB,GAAG,UAAU,CAmBnF"}
|
|
@@ -8,7 +8,6 @@ exports.generateSchemaFromSimpleSchema = void 0;
|
|
|
8
8
|
const internal_1 = require("@fluidframework/core-utils/internal");
|
|
9
9
|
const index_js_1 = require("../core/index.js");
|
|
10
10
|
const schemaTypes_js_1 = require("../schemaTypes.js");
|
|
11
|
-
const schemaFactory_js_1 = require("./schemaFactory.js");
|
|
12
11
|
const schemaFactoryAlpha_js_1 = require("./schemaFactoryAlpha.js");
|
|
13
12
|
const factory = new schemaFactoryAlpha_js_1.SchemaFactoryAlpha(undefined);
|
|
14
13
|
/**
|
|
@@ -20,6 +19,9 @@ const factory = new schemaFactoryAlpha_js_1.SchemaFactoryAlpha(undefined);
|
|
|
20
19
|
* will produce a poor TypeScript typing experience which is subject to change.
|
|
21
20
|
*
|
|
22
21
|
* Editing through a view produced using this schema can easily violate invariants other users of the document might expect and must be done with great care.
|
|
22
|
+
*
|
|
23
|
+
* This API bakes in some arbitrary policy choices for how to handle data that is not included in the SimpleTreeSchema API, for example the value of `allowUnknownOptionalFields`.
|
|
24
|
+
* If any particular choice is required for such cases, this API should not be used.
|
|
23
25
|
* @alpha
|
|
24
26
|
*/
|
|
25
27
|
function generateSchemaFromSimpleSchema(simple) {
|
|
@@ -28,19 +30,31 @@ function generateSchemaFromSimpleSchema(simple) {
|
|
|
28
30
|
// This relies on the caching in evaluateLazySchema so that it only runs once.
|
|
29
31
|
() => generateNode(id, schema, context),
|
|
30
32
|
]));
|
|
31
|
-
|
|
33
|
+
const root = generateFieldSchema(simple.root, context, undefined);
|
|
34
|
+
const definitions = new Map();
|
|
35
|
+
for (const [id, lazy] of context) {
|
|
36
|
+
definitions.set(id, lazy());
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
root,
|
|
40
|
+
definitions,
|
|
41
|
+
};
|
|
32
42
|
}
|
|
33
43
|
exports.generateSchemaFromSimpleSchema = generateSchemaFromSimpleSchema;
|
|
34
|
-
function generateFieldSchema(simple, context) {
|
|
44
|
+
function generateFieldSchema(simple, context, storedKey) {
|
|
35
45
|
const allowed = generateAllowedTypes(simple.allowedTypesIdentifiers, context);
|
|
46
|
+
const props = {
|
|
47
|
+
metadata: simple.metadata,
|
|
48
|
+
key: storedKey,
|
|
49
|
+
};
|
|
36
50
|
// Using createFieldSchema could work, but would require setting up the default providers.
|
|
37
51
|
switch (simple.kind) {
|
|
38
52
|
case schemaTypes_js_1.FieldKind.Identifier:
|
|
39
|
-
return schemaFactoryAlpha_js_1.SchemaFactoryAlpha.identifier(
|
|
53
|
+
return schemaFactoryAlpha_js_1.SchemaFactoryAlpha.identifier(props);
|
|
40
54
|
case schemaTypes_js_1.FieldKind.Optional:
|
|
41
|
-
return schemaFactoryAlpha_js_1.SchemaFactoryAlpha.optional(allowed,
|
|
55
|
+
return schemaFactoryAlpha_js_1.SchemaFactoryAlpha.optional(allowed, props);
|
|
42
56
|
case schemaTypes_js_1.FieldKind.Required:
|
|
43
|
-
return schemaFactoryAlpha_js_1.SchemaFactoryAlpha.required(allowed,
|
|
57
|
+
return schemaFactoryAlpha_js_1.SchemaFactoryAlpha.required(allowed, props);
|
|
44
58
|
default:
|
|
45
59
|
return (0, internal_1.unreachableCase)(simple.kind);
|
|
46
60
|
}
|
|
@@ -53,8 +67,10 @@ function generateNode(id, schema, context) {
|
|
|
53
67
|
case index_js_1.NodeKind.Object: {
|
|
54
68
|
const fields = {};
|
|
55
69
|
for (const [key, field] of schema.fields) {
|
|
56
|
-
fields[key] = generateFieldSchema(field, context);
|
|
70
|
+
fields[key] = generateFieldSchema(field, context, field.storedKey);
|
|
57
71
|
}
|
|
72
|
+
// Here allowUnknownOptionalFields is implicitly defaulting. This is a subjective policy choice:
|
|
73
|
+
// users of this code are expected to handle what ever choice this code makes for cases like this.
|
|
58
74
|
return factory.object(id, fields, { metadata: schema.metadata });
|
|
59
75
|
}
|
|
60
76
|
case index_js_1.NodeKind.Array:
|
|
@@ -62,7 +78,7 @@ function generateNode(id, schema, context) {
|
|
|
62
78
|
case index_js_1.NodeKind.Map:
|
|
63
79
|
return factory.mapAlpha(id, generateAllowedTypes(schema.allowedTypesIdentifiers, context), { metadata: schema.metadata });
|
|
64
80
|
case index_js_1.NodeKind.Leaf:
|
|
65
|
-
return (
|
|
81
|
+
return (schemaFactoryAlpha_js_1.SchemaFactoryAlpha.leaves.find((leaf) => leaf.identifier === id) ??
|
|
66
82
|
(0, internal_1.fail)(0xb5b /* Missing schema */));
|
|
67
83
|
default:
|
|
68
84
|
return (0, internal_1.unreachableCase)(schema);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemaFromSimple.js","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaFromSimple.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA4E;AAC5E,+CAAiE;AACjE,
|
|
1
|
+
{"version":3,"file":"schemaFromSimple.js","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaFromSimple.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA4E;AAC5E,+CAAiE;AACjE,sDAM2B;AAM3B,mEAA6D;AAG7D,MAAM,OAAO,GAAG,IAAI,0CAAkB,CAAC,SAAS,CAAC,CAAC;AAElD;;;;;;;;;;;;;GAaG;AACH,SAAgB,8BAA8B,CAAC,MAAwB;IACtE,MAAM,OAAO,GAAY,IAAI,GAAG,CAC/B,CAAC,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,GAAG,CAC1B,CAAC,CAAC,EAAE,EAAE,MAAM,CAAC,EAAqD,EAAE,CAAC;QACpE,EAAE;QACF,8EAA8E;QAC9E,GAAG,EAAE,CAAC,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC;KACvC,CACD,CACD,CAAC;IACF,MAAM,IAAI,GAAG,mBAAmB,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;IAClE,MAAM,WAAW,GAAG,IAAI,GAAG,EAA6C,CAAC;IACzE,KAAK,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,OAAO,EAAE,CAAC;QAClC,WAAW,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7B,CAAC;IACD,OAAO;QACN,IAAI;QACJ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,EAAE,CAAC;gBAC1C,MAAM,CAAC,GAAG,CAAC,GAAG,mBAAmB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;YACpE,CAAC;YACD,gGAAgG;YAChG,kGAAkG;YAClG,OAAO,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;QAClE,CAAC;QACD,KAAK,mBAAQ,CAAC,KAAK;YAClB,OAAO,OAAO,CAAC,UAAU,CACxB,EAAE,EACF,oBAAoB,CAAC,MAAM,CAAC,uBAAuB,EAAE,OAAO,CAAC,EAC7D,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,CAC7B,CAAC;QACH,KAAK,mBAAQ,CAAC,GAAG;YAChB,OAAO,OAAO,CAAC,QAAQ,CACtB,EAAE,EACF,oBAAoB,CAAC,MAAM,CAAC,uBAAuB,EAAE,OAAO,CAAC,EAC7D,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,CAC7B,CAAC;QACH,KAAK,mBAAQ,CAAC,IAAI;YACjB,OAAO,CACN,0CAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,KAAK,EAAE,CAAC;gBAChE,IAAA,eAAI,EAAC,KAAK,CAAC,oBAAoB,CAAC,CAChC,CAAC;QACH;YACC,OAAO,IAAA,0BAAe,EAAC,MAAM,CAAC,CAAC;IACjC,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { unreachableCase, fail } from \"@fluidframework/core-utils/internal\";\nimport { NodeKind, type TreeNodeSchema } from \"../core/index.js\";\nimport {\n\ttype FieldSchema,\n\ttype AllowedTypes,\n\ttype FieldSchemaAlpha,\n\tFieldKind,\n\ttype FieldProps,\n} from \"../schemaTypes.js\";\nimport type {\n\tSimpleFieldSchema,\n\tSimpleNodeSchema,\n\tSimpleTreeSchema,\n} from \"../simpleSchema.js\";\nimport { SchemaFactoryAlpha } from \"./schemaFactoryAlpha.js\";\nimport type { TreeSchema } from \"./tree.js\";\n\nconst factory = new SchemaFactoryAlpha(undefined);\n\n/**\n * Create {@link FieldSchema} from a SimpleTreeSchema.\n * @remarks\n * Only use this API if hand written schema (produced using {@link SchemaFactory} cannot be provided.\n *\n * Using generated schema with schema aware APIs (designed to work with strongly typed schema) like {@link TreeViewConfiguration}\n * will produce a poor TypeScript typing experience which is subject to change.\n *\n * Editing through a view produced using this schema can easily violate invariants other users of the document might expect and must be done with great care.\n *\n * This API bakes in some arbitrary policy choices for how to handle data that is not included in the SimpleTreeSchema API, for example the value of `allowUnknownOptionalFields`.\n * If any particular choice is required for such cases, this API should not be used.\n * @alpha\n */\nexport function generateSchemaFromSimpleSchema(simple: SimpleTreeSchema): TreeSchema {\n\tconst context: Context = new Map(\n\t\t[...simple.definitions].map(\n\t\t\t([id, schema]): [string, () => TreeNodeSchema & SimpleNodeSchema] => [\n\t\t\t\tid,\n\t\t\t\t// This relies on the caching in evaluateLazySchema so that it only runs once.\n\t\t\t\t() => generateNode(id, schema, context),\n\t\t\t],\n\t\t),\n\t);\n\tconst root = generateFieldSchema(simple.root, context, undefined);\n\tconst definitions = new Map<string, TreeNodeSchema & SimpleNodeSchema>();\n\tfor (const [id, lazy] of context) {\n\t\tdefinitions.set(id, lazy());\n\t}\n\treturn {\n\t\troot,\n\t\tdefinitions,\n\t};\n}\n\ntype Context = ReadonlyMap<string, () => TreeNodeSchema & SimpleNodeSchema>;\n\nfunction generateFieldSchema(\n\tsimple: SimpleFieldSchema,\n\tcontext: Context,\n\tstoredKey: string | undefined,\n): FieldSchemaAlpha {\n\tconst allowed = generateAllowedTypes(simple.allowedTypesIdentifiers, context);\n\tconst props: Omit<FieldProps, \"defaultProvider\"> = {\n\t\tmetadata: simple.metadata,\n\t\tkey: storedKey,\n\t};\n\n\t// Using createFieldSchema could work, but would require setting up the default providers.\n\tswitch (simple.kind) {\n\t\tcase FieldKind.Identifier:\n\t\t\treturn SchemaFactoryAlpha.identifier(props);\n\t\tcase FieldKind.Optional:\n\t\t\treturn SchemaFactoryAlpha.optional(allowed, props);\n\t\tcase FieldKind.Required:\n\t\t\treturn SchemaFactoryAlpha.required(allowed, props);\n\t\tdefault:\n\t\t\treturn unreachableCase(simple.kind);\n\t}\n}\n\nfunction generateAllowedTypes(allowed: ReadonlySet<string>, context: Context): AllowedTypes {\n\treturn [...allowed].map((id) => context.get(id) ?? fail(0xb5a /* Missing schema */));\n}\n\nfunction generateNode(\n\tid: string,\n\tschema: SimpleNodeSchema,\n\tcontext: Context,\n): TreeNodeSchema & SimpleNodeSchema {\n\tswitch (schema.kind) {\n\t\tcase NodeKind.Object: {\n\t\t\tconst fields: Record<string, FieldSchema> = {};\n\t\t\tfor (const [key, field] of schema.fields) {\n\t\t\t\tfields[key] = generateFieldSchema(field, context, field.storedKey);\n\t\t\t}\n\t\t\t// Here allowUnknownOptionalFields is implicitly defaulting. This is a subjective policy choice:\n\t\t\t// users of this code are expected to handle what ever choice this code makes for cases like this.\n\t\t\treturn factory.object(id, fields, { metadata: schema.metadata });\n\t\t}\n\t\tcase NodeKind.Array:\n\t\t\treturn factory.arrayAlpha(\n\t\t\t\tid,\n\t\t\t\tgenerateAllowedTypes(schema.allowedTypesIdentifiers, context),\n\t\t\t\t{ metadata: schema.metadata },\n\t\t\t);\n\t\tcase NodeKind.Map:\n\t\t\treturn factory.mapAlpha(\n\t\t\t\tid,\n\t\t\t\tgenerateAllowedTypes(schema.allowedTypesIdentifiers, context),\n\t\t\t\t{ metadata: schema.metadata },\n\t\t\t);\n\t\tcase NodeKind.Leaf:\n\t\t\treturn (\n\t\t\t\tSchemaFactoryAlpha.leaves.find((leaf) => leaf.identifier === id) ??\n\t\t\t\tfail(0xb5b /* Missing schema */)\n\t\t\t);\n\t\tdefault:\n\t\t\treturn unreachableCase(schema);\n\t}\n}\n"]}
|
|
@@ -3,11 +3,19 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import type { JsonObjectNodeSchema, JsonTreeSchema } from "./jsonSchema.js";
|
|
6
|
-
import type {
|
|
6
|
+
import type { TreeSchema } from "./tree.js";
|
|
7
|
+
import type { TreeSchemaEncodingOptions } from "./getJsonSchema.js";
|
|
8
|
+
import { ObjectNodeSchema } from "../objectNodeTypes.js";
|
|
7
9
|
/**
|
|
8
10
|
* Generates a JSON Schema representation from a simple tree schema.
|
|
11
|
+
* @remarks
|
|
12
|
+
* This expects the data to be in the {@link ConciseTree} format.
|
|
13
|
+
*
|
|
14
|
+
* This cannot handle the case where the root is undefined since undefined is not a concept in JSON.
|
|
15
|
+
* This also cannot handle {@link SchemaStatics.handle} since they also are not supported in JSON.
|
|
16
|
+
*
|
|
9
17
|
* @internal
|
|
10
18
|
*/
|
|
11
|
-
export declare function toJsonSchema(schema:
|
|
12
|
-
export declare function convertObjectNodeSchema(schema:
|
|
19
|
+
export declare function toJsonSchema(schema: TreeSchema, options: Required<TreeSchemaEncodingOptions>): JsonTreeSchema;
|
|
20
|
+
export declare function convertObjectNodeSchema(schema: ObjectNodeSchema, options: Required<TreeSchemaEncodingOptions>): JsonObjectNodeSchema;
|
|
13
21
|
//# sourceMappingURL=simpleSchemaToJsonSchema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simpleSchemaToJsonSchema.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/simpleSchemaToJsonSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EAQX,oBAAoB,EACpB,cAAc,EAEd,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"simpleSchemaToJsonSchema.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/simpleSchemaToJsonSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EAQX,oBAAoB,EACpB,cAAc,EAEd,MAAM,iBAAiB,CAAC;AAQzB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAKzD;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAC3B,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,QAAQ,CAAC,yBAAyB,CAAC,GAC1C,cAAc,CAoBhB;AAkFD,wBAAgB,uBAAuB,CACtC,MAAM,EAAE,gBAAgB,EACxB,OAAO,EAAE,QAAQ,CAAC,yBAAyB,CAAC,GAC1C,oBAAoB,CAwCtB"}
|
|
@@ -11,16 +11,29 @@ const index_js_1 = require("../../core/index.js");
|
|
|
11
11
|
const index_js_2 = require("../../util/index.js");
|
|
12
12
|
const schemaTypes_js_1 = require("../schemaTypes.js");
|
|
13
13
|
const index_js_3 = require("../core/index.js");
|
|
14
|
+
const objectNodeTypes_js_1 = require("../objectNodeTypes.js");
|
|
15
|
+
const arrayNodeTypes_js_1 = require("../arrayNodeTypes.js");
|
|
16
|
+
const mapNodeTypes_js_1 = require("../mapNodeTypes.js");
|
|
17
|
+
const leafNodeSchema_js_1 = require("../leafNodeSchema.js");
|
|
14
18
|
/**
|
|
15
19
|
* Generates a JSON Schema representation from a simple tree schema.
|
|
20
|
+
* @remarks
|
|
21
|
+
* This expects the data to be in the {@link ConciseTree} format.
|
|
22
|
+
*
|
|
23
|
+
* This cannot handle the case where the root is undefined since undefined is not a concept in JSON.
|
|
24
|
+
* This also cannot handle {@link SchemaStatics.handle} since they also are not supported in JSON.
|
|
25
|
+
*
|
|
16
26
|
* @internal
|
|
17
27
|
*/
|
|
18
|
-
function toJsonSchema(schema) {
|
|
19
|
-
const definitions = convertDefinitions(schema.definitions);
|
|
28
|
+
function toJsonSchema(schema, options) {
|
|
29
|
+
const definitions = convertDefinitions(schema.definitions, options);
|
|
20
30
|
const allowedTypes = [];
|
|
21
|
-
for (const allowedType of schema.allowedTypesIdentifiers) {
|
|
31
|
+
for (const allowedType of schema.root.allowedTypesIdentifiers) {
|
|
22
32
|
allowedTypes.push(createSchemaRef(allowedType));
|
|
23
33
|
}
|
|
34
|
+
// TODO: deduplicate field handling logic from convertObjectNodeSchema: at least include metadata's description.
|
|
35
|
+
// TODO: maybe account for consider schema.kind, or just take in ImplicitAllowedTypes
|
|
36
|
+
// TODO: handle case where allowedTypes is empty.
|
|
24
37
|
return (0, index_js_2.hasSingle)(allowedTypes)
|
|
25
38
|
? {
|
|
26
39
|
...allowedTypes[0],
|
|
@@ -32,37 +45,32 @@ function toJsonSchema(schema) {
|
|
|
32
45
|
};
|
|
33
46
|
}
|
|
34
47
|
exports.toJsonSchema = toJsonSchema;
|
|
35
|
-
function convertDefinitions(definitions) {
|
|
48
|
+
function convertDefinitions(definitions, options) {
|
|
36
49
|
const result = {};
|
|
37
50
|
for (const [key, value] of definitions) {
|
|
38
|
-
result[key] = convertNodeSchema(value);
|
|
51
|
+
result[key] = convertNodeSchema(value, options);
|
|
39
52
|
}
|
|
40
53
|
return result;
|
|
41
54
|
}
|
|
42
|
-
/**
|
|
43
|
-
* Private symbol under which the results of {@link convertNodeSchema} are cached on an input {@link SimpleNodeSchema}.
|
|
44
|
-
*/
|
|
45
|
-
const nodeJsonSchemaCache = new WeakMap();
|
|
46
55
|
/**
|
|
47
56
|
* Converts an input {@link SimpleNodeSchema} to a {@link JsonNodeSchema}.
|
|
48
57
|
*
|
|
49
58
|
* @remarks Caches the result on the input schema for future calls.
|
|
50
59
|
*/
|
|
51
|
-
function convertNodeSchema(schema) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
});
|
|
60
|
+
function convertNodeSchema(schema, options) {
|
|
61
|
+
if (schema instanceof arrayNodeTypes_js_1.ArrayNodeSchema) {
|
|
62
|
+
return convertArrayNodeSchema(schema);
|
|
63
|
+
}
|
|
64
|
+
else if (schema instanceof mapNodeTypes_js_1.MapNodeSchema) {
|
|
65
|
+
return convertMapNodeSchema(schema);
|
|
66
|
+
}
|
|
67
|
+
else if (schema instanceof objectNodeTypes_js_1.ObjectNodeSchema) {
|
|
68
|
+
return convertObjectNodeSchema(schema, options);
|
|
69
|
+
}
|
|
70
|
+
else if (schema instanceof leafNodeSchema_js_1.LeafNodeSchema) {
|
|
71
|
+
return convertLeafNodeSchema(schema);
|
|
72
|
+
}
|
|
73
|
+
throw new TypeError(`Unknown node schema kind: ${schema.kind}`);
|
|
66
74
|
}
|
|
67
75
|
function convertArrayNodeSchema(schema) {
|
|
68
76
|
const allowedTypes = [];
|
|
@@ -105,10 +113,11 @@ function convertLeafNodeSchema(schema) {
|
|
|
105
113
|
_treeNodeSchemaKind: index_js_3.NodeKind.Leaf,
|
|
106
114
|
};
|
|
107
115
|
}
|
|
108
|
-
function convertObjectNodeSchema(schema) {
|
|
116
|
+
function convertObjectNodeSchema(schema, options) {
|
|
109
117
|
const properties = {};
|
|
110
118
|
const required = [];
|
|
111
|
-
for (const [
|
|
119
|
+
for (const [propertyKey, fieldSchema] of schema.fields) {
|
|
120
|
+
const key = options.useStoredKeys ? fieldSchema.storedKey : propertyKey;
|
|
112
121
|
const allowedTypes = [];
|
|
113
122
|
for (const allowedType of fieldSchema.allowedTypesIdentifiers) {
|
|
114
123
|
allowedTypes.push(createSchemaRef(allowedType));
|
|
@@ -120,8 +129,11 @@ function convertObjectNodeSchema(schema) {
|
|
|
120
129
|
};
|
|
121
130
|
(0, index_js_2.copyProperty)(fieldSchema.metadata, "description", output);
|
|
122
131
|
properties[key] = output;
|
|
123
|
-
if (fieldSchema.kind
|
|
124
|
-
|
|
132
|
+
if (fieldSchema.kind !== schemaTypes_js_1.FieldKind.Optional) {
|
|
133
|
+
if (options.requireFieldsWithDefaults ||
|
|
134
|
+
fieldSchema.props?.defaultProvider === undefined) {
|
|
135
|
+
required.push(key);
|
|
136
|
+
}
|
|
125
137
|
}
|
|
126
138
|
}
|
|
127
139
|
const transformedNode = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simpleSchemaToJsonSchema.js","sourceRoot":"","sources":["../../../src/simple-tree/api/simpleSchemaToJsonSchema.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAsE;AACtE,uEAAsE;AACtE,kDAAkD;AAClD,kDAAyF;AAazF,sDAA8C;AAS9C,+CAA4C;AAE5C;;;GAGG;AACH,SAAgB,YAAY,CAAC,MAAwB;IACpD,MAAM,WAAW,GAAG,kBAAkB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAE3D,MAAM,YAAY,GAAoB,EAAE,CAAC;IACzC,KAAK,MAAM,WAAW,IAAI,MAAM,CAAC,uBAAuB,EAAE,CAAC;QAC1D,YAAY,CAAC,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC;IACjD,CAAC;IAED,OAAO,IAAA,oBAAS,EAAC,YAAY,CAAC;QAC7B,CAAC,CAAC;YACA,GAAG,YAAY,CAAC,CAAC,CAAC;YAClB,KAAK,EAAE,WAAW;SAClB;QACF,CAAC,CAAC;YACA,KAAK,EAAE,WAAW;YAClB,KAAK,EAAE,YAAY;SACnB,CAAC;AACL,CAAC;AAjBD,oCAiBC;AAED,SAAS,kBAAkB,CAC1B,WAAkD;IAElD,MAAM,MAAM,GAAmC,EAAE,CAAC;IAClD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,WAAW,EAAE,CAAC;QACxC,MAAM,CAAC,GAAG,CAAC,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC;AAED;;GAEG;AACH,MAAM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AC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,QAAgB;IACtC,OAAO,WAAW,QAAQ,EAAE,CAAC;AAC9B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { ValueSchema } from \"../../core/index.js\";\nimport { copyProperty, getOrCreate, hasSingle, type Mutable } from \"../../util/index.js\";\nimport type {\n\tJsonArrayNodeSchema,\n\tJsonFieldSchema,\n\tJsonSchemaRef,\n\tJsonRefPath,\n\tJsonLeafNodeSchema,\n\tJsonMapNodeSchema,\n\tJsonNodeSchema,\n\tJsonObjectNodeSchema,\n\tJsonTreeSchema,\n\tJsonLeafSchemaType,\n} from \"./jsonSchema.js\";\nimport { FieldKind } from \"../schemaTypes.js\";\nimport type {\n\tSimpleArrayNodeSchema,\n\tSimpleLeafNodeSchema,\n\tSimpleMapNodeSchema,\n\tSimpleNodeSchema,\n\tSimpleObjectNodeSchema,\n\tSimpleTreeSchema,\n} from \"../simpleSchema.js\";\nimport { NodeKind } from \"../core/index.js\";\n\n/**\n * Generates a JSON Schema representation from a simple tree schema.\n * @internal\n */\nexport function toJsonSchema(schema: SimpleTreeSchema): JsonTreeSchema {\n\tconst definitions = convertDefinitions(schema.definitions);\n\n\tconst allowedTypes: JsonSchemaRef[] = [];\n\tfor (const allowedType of schema.allowedTypesIdentifiers) {\n\t\tallowedTypes.push(createSchemaRef(allowedType));\n\t}\n\n\treturn hasSingle(allowedTypes)\n\t\t? {\n\t\t\t\t...allowedTypes[0],\n\t\t\t\t$defs: definitions,\n\t\t\t}\n\t\t: {\n\t\t\t\t$defs: definitions,\n\t\t\t\tanyOf: allowedTypes,\n\t\t\t};\n}\n\nfunction convertDefinitions(\n\tdefinitions: ReadonlyMap<string, SimpleNodeSchema>,\n): Record<string, JsonNodeSchema> {\n\tconst result: Record<string, JsonNodeSchema> = {};\n\tfor (const [key, value] of definitions) {\n\t\tresult[key] = convertNodeSchema(value);\n\t}\n\treturn result;\n}\n\n/**\n * Private symbol under which the results of {@link convertNodeSchema} are cached on an input {@link SimpleNodeSchema}.\n */\nconst nodeJsonSchemaCache = new WeakMap<SimpleNodeSchema, JsonNodeSchema>();\n\n/**\n * Converts an input {@link SimpleNodeSchema} to a {@link JsonNodeSchema}.\n *\n * @remarks Caches the result on the input schema for future calls.\n */\nfunction convertNodeSchema(schema: SimpleNodeSchema): JsonNodeSchema {\n\treturn getOrCreate(nodeJsonSchemaCache, schema, () => {\n\t\tswitch (schema.kind) {\n\t\t\tcase NodeKind.Array:\n\t\t\t\treturn convertArrayNodeSchema(schema);\n\t\t\tcase NodeKind.Leaf:\n\t\t\t\treturn convertLeafNodeSchema(schema);\n\t\t\tcase NodeKind.Map:\n\t\t\t\treturn convertMapNodeSchema(schema);\n\t\t\tcase NodeKind.Object:\n\t\t\t\treturn convertObjectNodeSchema(schema);\n\t\t\tdefault:\n\t\t\t\tthrow new TypeError(`Unknown node schema kind: ${(schema as SimpleNodeSchema).kind}`);\n\t\t}\n\t});\n}\n\nfunction convertArrayNodeSchema(schema: SimpleArrayNodeSchema): JsonArrayNodeSchema {\n\tconst allowedTypes: JsonSchemaRef[] = [];\n\tschema.allowedTypesIdentifiers.forEach((type) => {\n\t\tallowedTypes.push(createSchemaRef(type));\n\t});\n\n\tconst items: JsonFieldSchema = hasSingle(allowedTypes)\n\t\t? allowedTypes[0]\n\t\t: { anyOf: allowedTypes };\n\n\tconst output: Mutable<JsonArrayNodeSchema> = {\n\t\ttype: \"array\",\n\t\t_treeNodeSchemaKind: NodeKind.Array,\n\t\titems,\n\t};\n\n\tcopyProperty(schema.metadata, \"description\", output);\n\n\treturn output;\n}\n\nfunction convertLeafNodeSchema(schema: SimpleLeafNodeSchema): JsonLeafNodeSchema {\n\tlet type: JsonLeafSchemaType;\n\tswitch (schema.leafKind) {\n\t\tcase ValueSchema.String:\n\t\t\ttype = \"string\";\n\t\t\tbreak;\n\t\tcase ValueSchema.Number:\n\t\t\ttype = \"number\";\n\t\t\tbreak;\n\t\tcase ValueSchema.Boolean:\n\t\t\ttype = \"boolean\";\n\t\t\tbreak;\n\t\tcase ValueSchema.Null:\n\t\t\ttype = \"null\";\n\t\t\tbreak;\n\t\tcase ValueSchema.FluidHandle:\n\t\t\tthrow new UsageError(\"Fluid handles are not supported via JSON Schema.\");\n\t\tdefault:\n\t\t\tunreachableCase(schema.leafKind);\n\t}\n\n\treturn {\n\t\ttype,\n\t\t_treeNodeSchemaKind: NodeKind.Leaf,\n\t};\n}\n\nexport function convertObjectNodeSchema(schema: SimpleObjectNodeSchema): JsonObjectNodeSchema {\n\tconst properties: Record<string, JsonFieldSchema> = {};\n\tconst required: string[] = [];\n\tfor (const [key, fieldSchema] of schema.fields) {\n\t\tconst allowedTypes: JsonSchemaRef[] = [];\n\t\tfor (const allowedType of fieldSchema.allowedTypesIdentifiers) {\n\t\t\tallowedTypes.push(createSchemaRef(allowedType));\n\t\t}\n\n\t\tconst output: Mutable<JsonFieldSchema> = hasSingle(allowedTypes)\n\t\t\t? allowedTypes[0]\n\t\t\t: {\n\t\t\t\t\tanyOf: allowedTypes,\n\t\t\t\t};\n\n\t\tcopyProperty(fieldSchema.metadata, \"description\", output);\n\t\tproperties[key] = output;\n\n\t\tif (fieldSchema.kind === FieldKind.Required) {\n\t\t\trequired.push(key);\n\t\t}\n\t}\n\n\tconst transformedNode: Mutable<JsonObjectNodeSchema> = {\n\t\ttype: \"object\",\n\t\t_treeNodeSchemaKind: NodeKind.Object,\n\t\tproperties,\n\t\trequired,\n\t\tadditionalProperties: false,\n\t};\n\n\tcopyProperty(schema.metadata, \"description\", transformedNode);\n\n\treturn transformedNode;\n}\n\nfunction convertMapNodeSchema(schema: SimpleMapNodeSchema): JsonMapNodeSchema {\n\tconst allowedTypes: JsonSchemaRef[] = [];\n\tschema.allowedTypesIdentifiers.forEach((type) => {\n\t\tallowedTypes.push(createSchemaRef(type));\n\t});\n\n\tconst output: Mutable<JsonMapNodeSchema> = {\n\t\ttype: \"object\",\n\t\t_treeNodeSchemaKind: NodeKind.Map,\n\t\tpatternProperties: {\n\t\t\t\"^.*$\": hasSingle(allowedTypes)\n\t\t\t\t? allowedTypes[0]\n\t\t\t\t: {\n\t\t\t\t\t\tanyOf: allowedTypes,\n\t\t\t\t\t},\n\t\t},\n\t};\n\n\tcopyProperty(schema.metadata, \"description\", output);\n\n\treturn output;\n}\n\nfunction createSchemaRef(schemaId: string): JsonSchemaRef {\n\treturn {\n\t\t\"$ref\": createRefPath(schemaId),\n\t};\n}\n\nfunction createRefPath(schemaId: string): JsonRefPath {\n\treturn `#/$defs/${schemaId}`;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"simpleSchemaToJsonSchema.js","sourceRoot":"","sources":["../../../src/simple-tree/api/simpleSchemaToJsonSchema.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAsE;AACtE,uEAAsE;AACtE,kDAAkD;AAClD,kDAA4E;AAa5E,sDAA8C;AAM9C,+CAAiE;AAGjE,8DAAyD;AACzD,4DAAuD;AACvD,wDAAmD;AACnD,4DAAsD;AAEtD;;;;;;;;;GASG;AACH,SAAgB,YAAY,CAC3B,MAAkB,EAClB,OAA4C;IAE5C,MAAM,WAAW,GAAG,kBAAkB,CAAC,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAEpE,MAAM,YAAY,GAAoB,EAAE,CAAC;IACzC,KAAK,MAAM,WAAW,IAAI,MAAM,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAC/D,YAAY,CAAC,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC;IACjD,CAAC;IAED,gHAAgH;IAChH,qFAAqF;IACrF,iDAAiD;IACjD,OAAO,IAAA,oBAAS,EAAC,YAAY,CAAC;QAC7B,CAAC,CAAC;YACA,GAAG,YAAY,CAAC,CAAC,CAAC;YAClB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C,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;IAEH,MAAM,MAAM,GAA+B;QAC1C,IAAI,EAAE,QAAQ;QACd,mBAAmB,EAAE,mBAAQ,CAAC,GAAG;QACjC,iBAAiB,EAAE;YAClB,MAAM,EAAE,IAAA,oBAAS,EAAC,YAAY,CAAC;gBAC9B,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC;gBACjB,CAAC,CAAC;oBACA,KAAK,EAAE,YAAY;iBACnB;SACH;KACD,CAAC;IAEF,IAAA,uBAAY,EAAC,MAAM,CAAC,QAAQ,EAAE,aAAa,EAAE,MAAM,CAAC,CAAC;IAErD,OAAO,MAAM,CAAC;AACf,CAAC;AAED,SAAS,eAAe,CAAC,QAAgB;IACxC,OAAO;QACN,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC;KAC/B,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,QAAgB;IACtC,OAAO,WAAW,QAAQ,EAAE,CAAC;AAC9B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { ValueSchema } from \"../../core/index.js\";\nimport { copyProperty, hasSingle, type Mutable } from \"../../util/index.js\";\nimport type {\n\tJsonArrayNodeSchema,\n\tJsonFieldSchema,\n\tJsonSchemaRef,\n\tJsonRefPath,\n\tJsonLeafNodeSchema,\n\tJsonMapNodeSchema,\n\tJsonNodeSchema,\n\tJsonObjectNodeSchema,\n\tJsonTreeSchema,\n\tJsonLeafSchemaType,\n} from \"./jsonSchema.js\";\nimport { FieldKind } from \"../schemaTypes.js\";\nimport type {\n\tSimpleArrayNodeSchema,\n\tSimpleLeafNodeSchema,\n\tSimpleMapNodeSchema,\n} from \"../simpleSchema.js\";\nimport { NodeKind, type TreeNodeSchema } from \"../core/index.js\";\nimport type { TreeSchema } from \"./tree.js\";\nimport type { TreeSchemaEncodingOptions } from \"./getJsonSchema.js\";\nimport { ObjectNodeSchema } from \"../objectNodeTypes.js\";\nimport { ArrayNodeSchema } from \"../arrayNodeTypes.js\";\nimport { MapNodeSchema } from \"../mapNodeTypes.js\";\nimport { LeafNodeSchema } from \"../leafNodeSchema.js\";\n\n/**\n * Generates a JSON Schema representation from a simple tree schema.\n * @remarks\n * This expects the data to be in the {@link ConciseTree} format.\n *\n * This cannot handle the case where the root is undefined since undefined is not a concept in JSON.\n * This also cannot handle {@link SchemaStatics.handle} since they also are not supported in JSON.\n *\n * @internal\n */\nexport function toJsonSchema(\n\tschema: TreeSchema,\n\toptions: Required<TreeSchemaEncodingOptions>,\n): JsonTreeSchema {\n\tconst definitions = convertDefinitions(schema.definitions, options);\n\n\tconst allowedTypes: JsonSchemaRef[] = [];\n\tfor (const allowedType of schema.root.allowedTypesIdentifiers) {\n\t\tallowedTypes.push(createSchemaRef(allowedType));\n\t}\n\n\t// TODO: deduplicate field handling logic from convertObjectNodeSchema: at least include metadata's description.\n\t// TODO: maybe account for consider schema.kind, or just take in ImplicitAllowedTypes\n\t// TODO: handle case where allowedTypes is empty.\n\treturn hasSingle(allowedTypes)\n\t\t? {\n\t\t\t\t...allowedTypes[0],\n\t\t\t\t$defs: definitions,\n\t\t\t}\n\t\t: {\n\t\t\t\t$defs: definitions,\n\t\t\t\tanyOf: allowedTypes,\n\t\t\t};\n}\n\nfunction convertDefinitions(\n\tdefinitions: ReadonlyMap<string, TreeNodeSchema>,\n\toptions: Required<TreeSchemaEncodingOptions>,\n): Record<string, JsonNodeSchema> {\n\tconst result: Record<string, JsonNodeSchema> = {};\n\tfor (const [key, value] of definitions) {\n\t\tresult[key] = convertNodeSchema(value, options);\n\t}\n\treturn result;\n}\n\n/**\n * Converts an input {@link SimpleNodeSchema} to a {@link JsonNodeSchema}.\n *\n * @remarks Caches the result on the input schema for future calls.\n */\nfunction convertNodeSchema(\n\tschema: TreeNodeSchema,\n\toptions: Required<TreeSchemaEncodingOptions>,\n): JsonNodeSchema {\n\tif (schema instanceof ArrayNodeSchema) {\n\t\treturn convertArrayNodeSchema(schema);\n\t} else if (schema instanceof MapNodeSchema) {\n\t\treturn convertMapNodeSchema(schema);\n\t} else if (schema instanceof ObjectNodeSchema) {\n\t\treturn convertObjectNodeSchema(schema, options);\n\t} else if (schema instanceof LeafNodeSchema) {\n\t\treturn convertLeafNodeSchema(schema);\n\t}\n\tthrow new TypeError(`Unknown node schema kind: ${schema.kind}`);\n}\n\nfunction convertArrayNodeSchema(schema: SimpleArrayNodeSchema): JsonArrayNodeSchema {\n\tconst allowedTypes: JsonSchemaRef[] = [];\n\tschema.allowedTypesIdentifiers.forEach((type) => {\n\t\tallowedTypes.push(createSchemaRef(type));\n\t});\n\n\tconst items: JsonFieldSchema = hasSingle(allowedTypes)\n\t\t? allowedTypes[0]\n\t\t: { anyOf: allowedTypes };\n\n\tconst output: Mutable<JsonArrayNodeSchema> = {\n\t\ttype: \"array\",\n\t\t_treeNodeSchemaKind: NodeKind.Array,\n\t\titems,\n\t};\n\n\tcopyProperty(schema.metadata, \"description\", output);\n\n\treturn output;\n}\n\nfunction convertLeafNodeSchema(schema: SimpleLeafNodeSchema): JsonLeafNodeSchema {\n\tlet type: JsonLeafSchemaType;\n\tswitch (schema.leafKind) {\n\t\tcase ValueSchema.String:\n\t\t\ttype = \"string\";\n\t\t\tbreak;\n\t\tcase ValueSchema.Number:\n\t\t\ttype = \"number\";\n\t\t\tbreak;\n\t\tcase ValueSchema.Boolean:\n\t\t\ttype = \"boolean\";\n\t\t\tbreak;\n\t\tcase ValueSchema.Null:\n\t\t\ttype = \"null\";\n\t\t\tbreak;\n\t\tcase ValueSchema.FluidHandle:\n\t\t\tthrow new UsageError(\"Fluid handles are not supported via JSON Schema.\");\n\t\tdefault:\n\t\t\tunreachableCase(schema.leafKind);\n\t}\n\n\treturn {\n\t\ttype,\n\t\t_treeNodeSchemaKind: NodeKind.Leaf,\n\t};\n}\n\nexport function convertObjectNodeSchema(\n\tschema: ObjectNodeSchema,\n\toptions: Required<TreeSchemaEncodingOptions>,\n): JsonObjectNodeSchema {\n\tconst properties: Record<string, JsonFieldSchema> = {};\n\tconst required: string[] = [];\n\tfor (const [propertyKey, fieldSchema] of schema.fields) {\n\t\tconst key = options.useStoredKeys ? fieldSchema.storedKey : propertyKey;\n\t\tconst allowedTypes: JsonSchemaRef[] = [];\n\t\tfor (const allowedType of fieldSchema.allowedTypesIdentifiers) {\n\t\t\tallowedTypes.push(createSchemaRef(allowedType));\n\t\t}\n\n\t\tconst output: Mutable<JsonFieldSchema> = hasSingle(allowedTypes)\n\t\t\t? allowedTypes[0]\n\t\t\t: {\n\t\t\t\t\tanyOf: allowedTypes,\n\t\t\t\t};\n\n\t\tcopyProperty(fieldSchema.metadata, \"description\", output);\n\t\tproperties[key] = output;\n\n\t\tif (fieldSchema.kind !== FieldKind.Optional) {\n\t\t\tif (\n\t\t\t\toptions.requireFieldsWithDefaults ||\n\t\t\t\tfieldSchema.props?.defaultProvider === undefined\n\t\t\t) {\n\t\t\t\trequired.push(key);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst transformedNode: Mutable<JsonObjectNodeSchema> = {\n\t\ttype: \"object\",\n\t\t_treeNodeSchemaKind: NodeKind.Object,\n\t\tproperties,\n\t\trequired,\n\t\tadditionalProperties: false,\n\t};\n\n\tcopyProperty(schema.metadata, \"description\", transformedNode);\n\n\treturn transformedNode;\n}\n\nfunction convertMapNodeSchema(schema: SimpleMapNodeSchema): JsonMapNodeSchema {\n\tconst allowedTypes: JsonSchemaRef[] = [];\n\tschema.allowedTypesIdentifiers.forEach((type) => {\n\t\tallowedTypes.push(createSchemaRef(type));\n\t});\n\n\tconst output: Mutable<JsonMapNodeSchema> = {\n\t\ttype: \"object\",\n\t\t_treeNodeSchemaKind: NodeKind.Map,\n\t\tpatternProperties: {\n\t\t\t\"^.*$\": hasSingle(allowedTypes)\n\t\t\t\t? allowedTypes[0]\n\t\t\t\t: {\n\t\t\t\t\t\tanyOf: allowedTypes,\n\t\t\t\t\t},\n\t\t},\n\t};\n\n\tcopyProperty(schema.metadata, \"description\", output);\n\n\treturn output;\n}\n\nfunction createSchemaRef(schemaId: string): JsonSchemaRef {\n\treturn {\n\t\t\"$ref\": createRefPath(schemaId),\n\t};\n}\n\nfunction createRefPath(schemaId: string): JsonRefPath {\n\treturn `#/$defs/${schemaId}`;\n}\n"]}
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { IFluidLoadable, IDisposable, Listenable } from "@fluidframework/core-interfaces";
|
|
6
6
|
import type { CommitMetadata, RevertibleAlphaFactory, RevertibleFactory } from "../../core/index.js";
|
|
7
|
-
import { type ImplicitFieldSchema, type InsertableField, type InsertableTreeFieldFromImplicitField, type ReadableField, type ReadSchema, type TreeFieldFromImplicitField, type UnsafeUnknownSchema } from "../schemaTypes.js";
|
|
7
|
+
import { type FieldSchemaAlpha, type ImplicitFieldSchema, type InsertableField, type InsertableTreeFieldFromImplicitField, type ReadableField, type ReadSchema, type TreeFieldFromImplicitField, type UnsafeUnknownSchema } from "../schemaTypes.js";
|
|
8
8
|
import { type TreeNodeSchema } from "../core/index.js";
|
|
9
9
|
import type { MakeNominal } from "../../util/index.js";
|
|
10
10
|
import type { VerboseTree } from "./verboseTree.js";
|
|
11
|
-
import type { SimpleTreeSchema } from "../simpleSchema.js";
|
|
11
|
+
import type { SimpleNodeSchema, SimpleTreeSchema } from "../simpleSchema.js";
|
|
12
12
|
import type { RunTransactionParams, TransactionCallbackStatus, TransactionResult, TransactionResultExt, VoidTransactionCallbackStatus } from "./transactionTypes.js";
|
|
13
13
|
/**
|
|
14
14
|
* A tree from which a {@link TreeView} can be created.
|
|
@@ -67,9 +67,7 @@ export interface ITree extends ViewableTree, IFluidLoadable {
|
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
69
69
|
* {@link ITree} extended with some alpha APIs.
|
|
70
|
-
* @
|
|
71
|
-
* TODO: Promote this to alpha.
|
|
72
|
-
* @internal
|
|
70
|
+
* @sealed @alpha
|
|
73
71
|
*/
|
|
74
72
|
export interface ITreeAlpha extends ITree {
|
|
75
73
|
/**
|
|
@@ -220,6 +218,35 @@ export declare class TreeViewConfiguration<const TSchema extends ImplicitFieldSc
|
|
|
220
218
|
*/
|
|
221
219
|
constructor(props: ITreeViewConfiguration<TSchema>);
|
|
222
220
|
}
|
|
221
|
+
/**
|
|
222
|
+
* {@link TreeViewConfiguration} extended with some alpha APIs.
|
|
223
|
+
* @sealed @alpha
|
|
224
|
+
*/
|
|
225
|
+
export declare class TreeViewConfigurationAlpha<const TSchema extends ImplicitFieldSchema = ImplicitFieldSchema> extends TreeViewConfiguration<TSchema> implements TreeSchema {
|
|
226
|
+
/**
|
|
227
|
+
* {@inheritDoc TreeSchema.root}
|
|
228
|
+
*/
|
|
229
|
+
readonly root: FieldSchemaAlpha;
|
|
230
|
+
/**
|
|
231
|
+
* {@inheritDoc TreeSchema.definitions}
|
|
232
|
+
*/
|
|
233
|
+
readonly definitions: ReadonlyMap<string, SimpleNodeSchema & TreeNodeSchema>;
|
|
234
|
+
constructor(props: ITreeViewConfiguration<TSchema>);
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* {@link TreeViewConfigurationAlpha}
|
|
238
|
+
* @sealed @alpha
|
|
239
|
+
*/
|
|
240
|
+
export interface TreeSchema extends SimpleTreeSchema {
|
|
241
|
+
/**
|
|
242
|
+
* {@inheritDoc SimpleTreeSchema.root}
|
|
243
|
+
*/
|
|
244
|
+
readonly root: FieldSchemaAlpha;
|
|
245
|
+
/**
|
|
246
|
+
* {@inheritDoc SimpleTreeSchema.definitions}
|
|
247
|
+
*/
|
|
248
|
+
readonly definitions: ReadonlyMap<string, SimpleNodeSchema & TreeNodeSchema>;
|
|
249
|
+
}
|
|
223
250
|
/**
|
|
224
251
|
* Detect cases documented in {@link ITreeConfigurationOptions.preventAmbiguity}.
|
|
225
252
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/tree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAG/F,OAAO,KAAK,EACX,cAAc,EACd,sBAAsB,EACtB,iBAAiB,EACjB,MAAM,qBAAqB,CAAC;AAQ7B,OAAO,EACN,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,oCAAoC,EACzC,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,0BAA0B,EAC/B,KAAK,mBAAmB,
|
|
1
|
+
{"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/tree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAG/F,OAAO,KAAK,EACX,cAAc,EACd,sBAAsB,EACtB,iBAAiB,EACjB,MAAM,qBAAqB,CAAC;AAQ7B,OAAO,EACN,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,oCAAoC,EACzC,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,0BAA0B,EAC/B,KAAK,mBAAmB,EAIxB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAKjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,KAAK,EACX,oBAAoB,EACpB,yBAAyB,EACzB,iBAAiB,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AAI,CAAC;IAEpB;;;;;;;OAOG;IACH,aAAa,IAAI,IAAI,CAAC;IAEtB;;;;;;;;;;;;OAYG;IACH,aAAa,CAAC,IAAI,EAAE,cAAc,EAAE,aAAa,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAC;CAC7E;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,SAAS,mBAAmB,EAClE,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,GACrB,aAAa,CAAC,OAAO,CAAC,CAExB"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.asTreeViewAlpha = exports.checkUnion = exports.TreeViewConfiguration = void 0;
|
|
7
|
+
exports.asTreeViewAlpha = exports.checkUnion = exports.TreeViewConfigurationAlpha = exports.TreeViewConfiguration = void 0;
|
|
8
8
|
const internal_1 = require("@fluidframework/core-utils/internal");
|
|
9
9
|
const internal_2 = require("@fluidframework/telemetry-utils/internal");
|
|
10
10
|
const schemaTypes_js_1 = require("../schemaTypes.js");
|
|
@@ -64,6 +64,22 @@ class TreeViewConfiguration {
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
exports.TreeViewConfiguration = TreeViewConfiguration;
|
|
67
|
+
/**
|
|
68
|
+
* {@link TreeViewConfiguration} extended with some alpha APIs.
|
|
69
|
+
* @sealed @alpha
|
|
70
|
+
*/
|
|
71
|
+
class TreeViewConfigurationAlpha extends TreeViewConfiguration {
|
|
72
|
+
constructor(props) {
|
|
73
|
+
super(props);
|
|
74
|
+
this.root = (0, schemaTypes_js_1.normalizeFieldSchema)(props.schema);
|
|
75
|
+
const definitions = new Map();
|
|
76
|
+
(0, walkFieldSchema_js_1.walkFieldSchema)(props.schema, {
|
|
77
|
+
node: (schema) => definitions.set(schema.identifier, schema),
|
|
78
|
+
});
|
|
79
|
+
this.definitions = definitions;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.TreeViewConfigurationAlpha = TreeViewConfigurationAlpha;
|
|
67
83
|
/**
|
|
68
84
|
* Pretty print a set of types for use in error messages.
|
|
69
85
|
*/
|