@fluidframework/tree 2.60.0 → 2.61.0-355516
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/.mocharc.cjs +2 -3
- package/api-report/tree.alpha.api.md +11 -28
- package/api-report/tree.beta.api.md +6 -23
- package/api-report/tree.legacy.beta.api.md +71 -22
- package/api-report/tree.legacy.public.api.md +5 -22
- package/api-report/tree.public.api.md +5 -22
- package/dist/alpha.d.ts +10 -5
- package/dist/beta.d.ts +8 -4
- package/dist/core/tree/anchorSet.d.ts +3 -3
- package/dist/core/tree/anchorSet.d.ts.map +1 -1
- package/dist/core/tree/anchorSet.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/legacy.d.ts +22 -4
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/public.d.ts +6 -3
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +1 -0
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +1 -1
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts +11 -83
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js +26 -82
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +5 -3
- package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
- package/dist/simple-tree/core/index.d.ts +1 -1
- package/dist/simple-tree/core/index.d.ts.map +1 -1
- package/dist/simple-tree/core/index.js +2 -1
- package/dist/simple-tree/core/index.js.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.d.ts +12 -1
- package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.js +188 -43
- package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts +4 -3
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.js +22 -6
- package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/dist/simple-tree/index.d.ts +2 -2
- 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/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.js +13 -6
- package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/dist/tableSchema.d.ts.map +1 -1
- package/dist/tableSchema.js +15 -10
- package/dist/tableSchema.js.map +1 -1
- package/dist/util/breakable.d.ts.map +1 -1
- package/dist/util/breakable.js +7 -1
- package/dist/util/breakable.js.map +1 -1
- package/lib/alpha.d.ts +10 -5
- package/lib/beta.d.ts +8 -4
- package/lib/core/tree/anchorSet.d.ts +3 -3
- package/lib/core/tree/anchorSet.d.ts.map +1 -1
- package/lib/core/tree/anchorSet.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/legacy.d.ts +22 -4
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/public.d.ts +6 -3
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +1 -0
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +1 -1
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts +11 -83
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js +25 -81
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +5 -3
- package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
- package/lib/simple-tree/core/index.d.ts +1 -1
- package/lib/simple-tree/core/index.d.ts.map +1 -1
- package/lib/simple-tree/core/index.js +1 -1
- package/lib/simple-tree/core/index.js.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.d.ts +12 -1
- package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.js +187 -43
- package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts +4 -3
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.js +22 -6
- package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/lib/simple-tree/index.d.ts +2 -2
- 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/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.js +14 -7
- package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/lib/tableSchema.d.ts.map +1 -1
- package/lib/tableSchema.js +16 -11
- package/lib/tableSchema.js.map +1 -1
- package/lib/tsdoc-metadata.json +1 -1
- package/lib/util/breakable.d.ts.map +1 -1
- package/lib/util/breakable.js +7 -1
- package/lib/util/breakable.js.map +1 -1
- package/package.json +27 -27
- package/src/core/tree/anchorSet.ts +2 -2
- package/src/index.ts +1 -0
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/treeCheckout.ts +1 -0
- package/src/simple-tree/api/index.ts +1 -0
- package/src/simple-tree/api/schemaFactory.ts +31 -103
- package/src/simple-tree/api/schemaFactoryRecursive.ts +41 -40
- package/src/simple-tree/core/index.ts +1 -0
- package/src/simple-tree/core/treeNodeKernel.ts +242 -44
- package/src/simple-tree/core/unhydratedFlexTree.ts +26 -3
- package/src/simple-tree/index.ts +2 -0
- package/src/simple-tree/node-kinds/array/arrayNode.ts +19 -11
- package/src/tableSchema.ts +15 -9
- package/src/util/breakable.ts +9 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/tree",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.61.0-355516",
|
|
4
4
|
"description": "Distributed tree",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -101,17 +101,17 @@
|
|
|
101
101
|
"temp-directory": "nyc/.nyc_output"
|
|
102
102
|
},
|
|
103
103
|
"dependencies": {
|
|
104
|
-
"@fluid-internal/client-utils": "
|
|
105
|
-
"@fluidframework/container-runtime": "
|
|
106
|
-
"@fluidframework/core-interfaces": "
|
|
107
|
-
"@fluidframework/core-utils": "
|
|
108
|
-
"@fluidframework/datastore-definitions": "
|
|
109
|
-
"@fluidframework/driver-definitions": "
|
|
110
|
-
"@fluidframework/id-compressor": "
|
|
111
|
-
"@fluidframework/runtime-definitions": "
|
|
112
|
-
"@fluidframework/runtime-utils": "
|
|
113
|
-
"@fluidframework/shared-object-base": "
|
|
114
|
-
"@fluidframework/telemetry-utils": "
|
|
104
|
+
"@fluid-internal/client-utils": "2.61.0-355516",
|
|
105
|
+
"@fluidframework/container-runtime": "2.61.0-355516",
|
|
106
|
+
"@fluidframework/core-interfaces": "2.61.0-355516",
|
|
107
|
+
"@fluidframework/core-utils": "2.61.0-355516",
|
|
108
|
+
"@fluidframework/datastore-definitions": "2.61.0-355516",
|
|
109
|
+
"@fluidframework/driver-definitions": "2.61.0-355516",
|
|
110
|
+
"@fluidframework/id-compressor": "2.61.0-355516",
|
|
111
|
+
"@fluidframework/runtime-definitions": "2.61.0-355516",
|
|
112
|
+
"@fluidframework/runtime-utils": "2.61.0-355516",
|
|
113
|
+
"@fluidframework/shared-object-base": "2.61.0-355516",
|
|
114
|
+
"@fluidframework/telemetry-utils": "2.61.0-355516",
|
|
115
115
|
"@sinclair/typebox": "^0.34.13",
|
|
116
116
|
"@tylerbu/sorted-btree-es6": "^1.8.0",
|
|
117
117
|
"@types/ungap__structured-clone": "^1.2.0",
|
|
@@ -121,28 +121,28 @@
|
|
|
121
121
|
"devDependencies": {
|
|
122
122
|
"@arethetypeswrong/cli": "^0.17.1",
|
|
123
123
|
"@biomejs/biome": "~1.9.3",
|
|
124
|
-
"@fluid-internal/mocha-test-setup": "
|
|
125
|
-
"@fluid-private/stochastic-test-utils": "
|
|
126
|
-
"@fluid-private/test-dds-utils": "
|
|
127
|
-
"@fluid-private/test-drivers": "
|
|
124
|
+
"@fluid-internal/mocha-test-setup": "2.61.0-355516",
|
|
125
|
+
"@fluid-private/stochastic-test-utils": "2.61.0-355516",
|
|
126
|
+
"@fluid-private/test-dds-utils": "2.61.0-355516",
|
|
127
|
+
"@fluid-private/test-drivers": "2.61.0-355516",
|
|
128
128
|
"@fluid-tools/benchmark": "^0.51.0",
|
|
129
|
-
"@fluid-tools/build-cli": "^0.
|
|
129
|
+
"@fluid-tools/build-cli": "^0.58.1",
|
|
130
130
|
"@fluidframework/build-common": "^2.0.3",
|
|
131
|
-
"@fluidframework/build-tools": "^0.
|
|
132
|
-
"@fluidframework/container-definitions": "
|
|
133
|
-
"@fluidframework/container-loader": "
|
|
131
|
+
"@fluidframework/build-tools": "^0.58.1",
|
|
132
|
+
"@fluidframework/container-definitions": "2.61.0-355516",
|
|
133
|
+
"@fluidframework/container-loader": "2.61.0-355516",
|
|
134
134
|
"@fluidframework/eslint-config-fluid": "^6.0.0",
|
|
135
|
-
"@fluidframework/test-runtime-utils": "
|
|
136
|
-
"@fluidframework/test-utils": "
|
|
137
|
-
"@fluidframework/tree-previous": "npm:@fluidframework/tree@2.
|
|
138
|
-
"@microsoft/api-extractor": "7.52.
|
|
135
|
+
"@fluidframework/test-runtime-utils": "2.61.0-355516",
|
|
136
|
+
"@fluidframework/test-utils": "2.61.0-355516",
|
|
137
|
+
"@fluidframework/tree-previous": "npm:@fluidframework/tree@2.60.0",
|
|
138
|
+
"@microsoft/api-extractor": "7.52.11",
|
|
139
139
|
"@types/diff": "^3.5.1",
|
|
140
140
|
"@types/easy-table": "^0.0.32",
|
|
141
141
|
"@types/mocha": "^10.0.10",
|
|
142
142
|
"@types/node": "^18.19.0",
|
|
143
143
|
"ajv": "^8.12.0",
|
|
144
144
|
"ajv-formats": "^3.0.1",
|
|
145
|
-
"c8": "^
|
|
145
|
+
"c8": "^10.1.3",
|
|
146
146
|
"concurrently": "^8.2.1",
|
|
147
147
|
"copyfiles": "^2.4.1",
|
|
148
148
|
"cross-env": "^7.0.3",
|
|
@@ -177,8 +177,8 @@
|
|
|
177
177
|
},
|
|
178
178
|
"scripts": {
|
|
179
179
|
"api": "fluid-build . --task api",
|
|
180
|
-
"api-extractor:commonjs": "flub generate entrypoints --outDir ./dist",
|
|
181
|
-
"api-extractor:esnext": "flub generate entrypoints --outDir ./lib --node10TypeCompat",
|
|
180
|
+
"api-extractor:commonjs": "flub generate entrypoints --outFileLegacyBeta legacy --outDir ./dist",
|
|
181
|
+
"api-extractor:esnext": "flub generate entrypoints --outFileLegacyBeta legacy --outDir ./lib --node10TypeCompat",
|
|
182
182
|
"bench": "mocha --timeout 999999 --perfMode --parentProcess --fgrep @Benchmark --fgrep @ExecutionTime --reporter @fluid-tools/benchmark/dist/MochaReporter.js",
|
|
183
183
|
"bench:profile": "mocha --v8-prof --v8-logfile=profile.log --v8-no-logfile-per-isolate --timeout 999999 --perfMode --fgrep @Benchmark --fgrep @ExecutionTime --reporter @fluid-tools/benchmark/dist/MochaReporter.js && node --prof-process profile.log > profile.txt && rimraf profile.log && echo See results in profile.txt",
|
|
184
184
|
"build": "fluid-build . --task build",
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
7
7
|
|
|
8
8
|
import { createEmitter } from "@fluid-internal/client-utils";
|
|
9
|
-
import type { Listenable } from "@fluidframework/core-interfaces/internal";
|
|
9
|
+
import type { HasListeners, Listenable } from "@fluidframework/core-interfaces/internal";
|
|
10
10
|
import { assert, fail } from "@fluidframework/core-utils/internal";
|
|
11
11
|
|
|
12
12
|
import {
|
|
@@ -210,7 +210,7 @@ export interface AnchorNode extends INormalizedUpPath<AnchorNode> {
|
|
|
210
210
|
/**
|
|
211
211
|
* Events for this anchor node.
|
|
212
212
|
*/
|
|
213
|
-
readonly events: Listenable<AnchorEvents>;
|
|
213
|
+
readonly events: Listenable<AnchorEvents> & HasListeners<AnchorEvents>;
|
|
214
214
|
|
|
215
215
|
/**
|
|
216
216
|
* Allows access to data stored on the Anchor in "slots".
|
package/src/index.ts
CHANGED
package/src/packageVersion.ts
CHANGED
|
@@ -883,6 +883,7 @@ export class TreeCheckout implements ITreeCheckoutFork {
|
|
|
883
883
|
}
|
|
884
884
|
|
|
885
885
|
private revertRevertible(revision: RevisionTag, kind: CommitKind): RevertMetrics {
|
|
886
|
+
this.editLock.checkUnlocked("Reverting a commit");
|
|
886
887
|
if (this.transaction.isInProgress()) {
|
|
887
888
|
throw new UsageError("Undo is not yet supported during transactions.");
|
|
888
889
|
}
|
|
@@ -31,6 +31,7 @@ export {
|
|
|
31
31
|
type SchemaFactoryObjectOptions,
|
|
32
32
|
type NodeSchemaOptions,
|
|
33
33
|
type NodeSchemaOptionsAlpha,
|
|
34
|
+
type SchemaFactory_base,
|
|
34
35
|
} from "./schemaFactory.js";
|
|
35
36
|
export { SchemaFactoryBeta } from "./schemaFactoryBeta.js";
|
|
36
37
|
export { SchemaFactoryAlpha, type SchemaStaticsAlpha } from "./schemaFactoryAlpha.js";
|
|
@@ -174,6 +174,33 @@ export type ScopedSchemaName<
|
|
|
174
174
|
|
|
175
175
|
const schemaStaticsPublic: SchemaStatics = schemaStatics;
|
|
176
176
|
|
|
177
|
+
/**
|
|
178
|
+
* Create a class with `Statics` as both static properties and member properties.
|
|
179
|
+
* @privateRemarks
|
|
180
|
+
* An attempt was made to let this take in a base class so it could be used again on SchemaFactoryAlpha.
|
|
181
|
+
* This was unsuccessful, mostly due to issues with trying to manipulate constructor types.
|
|
182
|
+
*/
|
|
183
|
+
function classWithStatics<Statics extends object>(
|
|
184
|
+
statics: Statics,
|
|
185
|
+
): Statics & (new () => Statics) {
|
|
186
|
+
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
|
|
187
|
+
class WithStatics {}
|
|
188
|
+
|
|
189
|
+
Object.assign(WithStatics.prototype, statics);
|
|
190
|
+
Object.assign(WithStatics, statics);
|
|
191
|
+
return WithStatics as Statics & (new () => Statics);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Base class for SchemaFactory, exposes {@link SchemaStatics} as both static properties and member properties.
|
|
196
|
+
* @remarks
|
|
197
|
+
* Do not use this directly, use {@link SchemaFactory} instead.
|
|
198
|
+
* @privateRemarks
|
|
199
|
+
* Exported only as a workaround for {@link https://github.com/microsoft/TypeScript/issues/59550} and {@link https://github.com/microsoft/rushstack/issues/4429}.
|
|
200
|
+
* @system @public
|
|
201
|
+
*/
|
|
202
|
+
export const SchemaFactory_base = classWithStatics(schemaStaticsPublic);
|
|
203
|
+
|
|
177
204
|
// TODO:
|
|
178
205
|
// SchemaFactory.array references should link to the correct overloads, however the syntax for this does not seems to work currently for methods unless the they are not qualified with the class.
|
|
179
206
|
// API-Extractor requires such links to be qualified with the class, so it can't work.
|
|
@@ -289,8 +316,7 @@ const schemaStaticsPublic: SchemaStatics = schemaStatics;
|
|
|
289
316
|
export class SchemaFactory<
|
|
290
317
|
out TScope extends string | undefined = string | undefined,
|
|
291
318
|
TName extends number | string = string,
|
|
292
|
-
>
|
|
293
|
-
{
|
|
319
|
+
> extends SchemaFactory_base {
|
|
294
320
|
/**
|
|
295
321
|
* TODO:
|
|
296
322
|
* If users of this generate the same name because two different schema with the same identifier were used,
|
|
@@ -339,67 +365,9 @@ export class SchemaFactory<
|
|
|
339
365
|
* ```
|
|
340
366
|
*/
|
|
341
367
|
public readonly scope: TScope,
|
|
342
|
-
) {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
* {@inheritDoc SchemaStatics.string}
|
|
346
|
-
*/
|
|
347
|
-
public readonly string = schemaStaticsPublic.string;
|
|
348
|
-
|
|
349
|
-
/**
|
|
350
|
-
* {@inheritDoc SchemaStatics.number}
|
|
351
|
-
*/
|
|
352
|
-
public readonly number = schemaStaticsPublic.number;
|
|
353
|
-
|
|
354
|
-
/**
|
|
355
|
-
* {@inheritDoc SchemaStatics.boolean}
|
|
356
|
-
*/
|
|
357
|
-
public readonly boolean = schemaStaticsPublic.boolean;
|
|
358
|
-
|
|
359
|
-
/**
|
|
360
|
-
* {@inheritDoc SchemaStatics.null}
|
|
361
|
-
*/
|
|
362
|
-
public readonly null = schemaStaticsPublic.null;
|
|
363
|
-
|
|
364
|
-
/**
|
|
365
|
-
* {@inheritDoc SchemaStatics.handle}
|
|
366
|
-
*/
|
|
367
|
-
public readonly handle = schemaStaticsPublic.handle;
|
|
368
|
-
|
|
369
|
-
/**
|
|
370
|
-
* {@inheritDoc SchemaStatics.leaves}
|
|
371
|
-
*/
|
|
372
|
-
public readonly leaves = schemaStaticsPublic.leaves;
|
|
373
|
-
|
|
374
|
-
/**
|
|
375
|
-
* {@inheritDoc SchemaStatics.string}
|
|
376
|
-
*/
|
|
377
|
-
public static readonly string = schemaStaticsPublic.string;
|
|
378
|
-
|
|
379
|
-
/**
|
|
380
|
-
* {@inheritDoc SchemaStatics.number}
|
|
381
|
-
*/
|
|
382
|
-
public static readonly number = schemaStaticsPublic.number;
|
|
383
|
-
|
|
384
|
-
/**
|
|
385
|
-
* {@inheritDoc SchemaStatics.boolean}
|
|
386
|
-
*/
|
|
387
|
-
public static readonly boolean = schemaStaticsPublic.boolean;
|
|
388
|
-
|
|
389
|
-
/**
|
|
390
|
-
* {@inheritDoc SchemaStatics.null}
|
|
391
|
-
*/
|
|
392
|
-
public static readonly null = schemaStaticsPublic.null;
|
|
393
|
-
|
|
394
|
-
/**
|
|
395
|
-
* {@inheritDoc SchemaStatics.handle}
|
|
396
|
-
*/
|
|
397
|
-
public static readonly handle = schemaStaticsPublic.handle;
|
|
398
|
-
|
|
399
|
-
/**
|
|
400
|
-
* {@inheritDoc SchemaStatics.leaves}
|
|
401
|
-
*/
|
|
402
|
-
public static readonly leaves = schemaStaticsPublic.leaves;
|
|
368
|
+
) {
|
|
369
|
+
super();
|
|
370
|
+
}
|
|
403
371
|
|
|
404
372
|
/**
|
|
405
373
|
* Define a {@link TreeNodeSchemaClass} for a {@link TreeObjectNode}.
|
|
@@ -807,46 +775,6 @@ export class SchemaFactory<
|
|
|
807
775
|
>;
|
|
808
776
|
}
|
|
809
777
|
|
|
810
|
-
/**
|
|
811
|
-
* {@inheritDoc SchemaStatics.optional}
|
|
812
|
-
*/
|
|
813
|
-
public readonly optional = schemaStaticsPublic.optional;
|
|
814
|
-
|
|
815
|
-
/**
|
|
816
|
-
* {@inheritDoc SchemaStatics.required}
|
|
817
|
-
*/
|
|
818
|
-
public readonly required = schemaStaticsPublic.required;
|
|
819
|
-
|
|
820
|
-
/**
|
|
821
|
-
* {@inheritDoc SchemaStatics.optionalRecursive}
|
|
822
|
-
*/
|
|
823
|
-
public readonly optionalRecursive = schemaStaticsPublic.optionalRecursive;
|
|
824
|
-
|
|
825
|
-
/**
|
|
826
|
-
* {@inheritDoc SchemaStatics.requiredRecursive}
|
|
827
|
-
*/
|
|
828
|
-
public readonly requiredRecursive = schemaStaticsPublic.requiredRecursive;
|
|
829
|
-
|
|
830
|
-
/**
|
|
831
|
-
* {@inheritDoc SchemaStatics.optional}
|
|
832
|
-
*/
|
|
833
|
-
public static readonly optional = schemaStaticsPublic.optional;
|
|
834
|
-
|
|
835
|
-
/**
|
|
836
|
-
* {@inheritDoc SchemaStatics.required}
|
|
837
|
-
*/
|
|
838
|
-
public static readonly required = schemaStaticsPublic.required;
|
|
839
|
-
|
|
840
|
-
/**
|
|
841
|
-
* {@inheritDoc SchemaStatics.optionalRecursive}
|
|
842
|
-
*/
|
|
843
|
-
public static readonly optionalRecursive = schemaStaticsPublic.optionalRecursive;
|
|
844
|
-
|
|
845
|
-
/**
|
|
846
|
-
* {@inheritDoc SchemaStatics.requiredRecursive}
|
|
847
|
-
*/
|
|
848
|
-
public static readonly requiredRecursive = schemaStaticsPublic.requiredRecursive;
|
|
849
|
-
|
|
850
778
|
/**
|
|
851
779
|
* A special readonly field which holds an identifier string for an object node.
|
|
852
780
|
* @remarks
|
|
@@ -11,6 +11,7 @@ import type {
|
|
|
11
11
|
TreeNode,
|
|
12
12
|
ImplicitAllowedTypes,
|
|
13
13
|
InsertableTreeNodeFromImplicitAllowedTypes,
|
|
14
|
+
TreeNodeSchemaClass,
|
|
14
15
|
} from "../core/index.js";
|
|
15
16
|
import type { InsertableObjectFromSchemaRecord } from "../node-kinds/index.js";
|
|
16
17
|
import type { ImplicitFieldSchema } from "../fieldSchema.js";
|
|
@@ -136,50 +137,50 @@ import type { ImplicitFieldSchema } from "../fieldSchema.js";
|
|
|
136
137
|
* TODO: this currently does not reject `any`, but ideally should.
|
|
137
138
|
* @public
|
|
138
139
|
*/
|
|
139
|
-
export type ValidateRecursiveSchema<
|
|
140
|
-
// Recursive types should always be using TreeNodeSchemaClass (not TreeNodeSchemaNonClass) as thats part of the requirements for the type to work across compilation boundaries correctly.
|
|
141
|
-
T extends ValidateRecursiveSchemaTemplate<T>,
|
|
142
|
-
> = true;
|
|
140
|
+
export type ValidateRecursiveSchema<T extends ValidateRecursiveSchemaTemplate<T>> = true;
|
|
143
141
|
|
|
144
142
|
/**
|
|
145
143
|
* Validation logic used by {@link ValidateRecursiveSchema}.
|
|
144
|
+
* @privateRemarks
|
|
145
|
+
* Recursive types should always be using TreeNodeSchemaClass (not TreeNodeSchemaNonClass) as that's part of the requirements for the type to work across compilation boundaries correctly.
|
|
146
146
|
* @system @public
|
|
147
147
|
*/
|
|
148
|
-
export type ValidateRecursiveSchemaTemplate<T extends
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
148
|
+
export type ValidateRecursiveSchemaTemplate<T extends TreeNodeSchemaClass> =
|
|
149
|
+
TreeNodeSchemaClass<
|
|
150
|
+
// Name: This validator places no restrictions on the name other than that it's a string (as required by TreeNodeSchemaClass).
|
|
151
|
+
string,
|
|
152
|
+
// NodeKind: These are the NodeKinds which currently can be used recursively.
|
|
153
|
+
NodeKind.Array | NodeKind.Map | NodeKind.Object | NodeKind.Record,
|
|
154
|
+
// TNode: The produced node API. This is pretty minimal validation: more could be added if similar to how TInsertable works below if needed.
|
|
155
|
+
TreeNode & WithType<T["identifier"], T["kind"]>,
|
|
156
|
+
// TInsertable: What can be passed to the constructor. This should be enough to catch most issues with incorrect schema.
|
|
157
|
+
// These match whats defined in the recursive methods on `SchemaFactory` except they do not use `Unenforced`.
|
|
158
|
+
{
|
|
159
|
+
[NodeKind.Object]: T["info"] extends RestrictiveStringRecord<ImplicitFieldSchema>
|
|
160
|
+
? InsertableObjectFromSchemaRecord<T["info"]>
|
|
161
|
+
: unknown;
|
|
162
|
+
[NodeKind.Array]: T["info"] extends ImplicitAllowedTypes
|
|
163
|
+
? Iterable<InsertableTreeNodeFromImplicitAllowedTypes<T["info"]>>
|
|
164
|
+
: unknown;
|
|
165
|
+
[NodeKind.Map]: T["info"] extends ImplicitAllowedTypes
|
|
166
|
+
? Iterable<[string, InsertableTreeNodeFromImplicitAllowedTypes<T["info"]>]>
|
|
167
|
+
: unknown;
|
|
168
|
+
[NodeKind.Record]: {
|
|
169
|
+
readonly [P in string]: InsertableTreeNodeFromImplicitAllowedTypes<T>;
|
|
170
|
+
};
|
|
171
|
+
[NodeKind.Leaf]: unknown;
|
|
172
|
+
}[T["kind"]],
|
|
173
|
+
// ImplicitlyConstructable: recursive types are currently not implicitly constructable.
|
|
174
|
+
false,
|
|
175
|
+
// Info: What's passed to the method to create the schema. Constraining these here should be about as effective as if the actual constraints existed on the actual method itself.
|
|
176
|
+
{
|
|
177
|
+
[NodeKind.Object]: RestrictiveStringRecord<ImplicitFieldSchema>;
|
|
178
|
+
[NodeKind.Array]: ImplicitAllowedTypes;
|
|
179
|
+
[NodeKind.Map]: ImplicitAllowedTypes;
|
|
180
|
+
[NodeKind.Record]: ImplicitAllowedTypes;
|
|
181
|
+
[NodeKind.Leaf]: unknown;
|
|
182
|
+
}[T["kind"]]
|
|
183
|
+
>;
|
|
183
184
|
|
|
184
185
|
/**
|
|
185
186
|
* Workaround for "Type instantiation is excessively deep and possibly infinite.ts" errors.
|
|
@@ -236,7 +237,7 @@ export type ValidateRecursiveSchemaTemplate<T extends TreeNodeSchema> = TreeNode
|
|
|
236
237
|
* This uses ValidateRecursiveSchemaTemplate since it was found to evaluate enough of the type to work.
|
|
237
238
|
* @internal
|
|
238
239
|
*/
|
|
239
|
-
export type FixRecursiveRecursionLimit<T extends
|
|
240
|
+
export type FixRecursiveRecursionLimit<T extends TreeNodeSchemaClass> =
|
|
240
241
|
T extends ValidateRecursiveSchemaTemplate<T> ? undefined : undefined;
|
|
241
242
|
|
|
242
243
|
/**
|