@fluidframework/tree 2.70.0-360374 → 2.70.0-361092
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/.eslintrc.cjs +1 -0
- package/api-report/tree.alpha.api.md +31 -27
- package/api-report/tree.beta.api.md +36 -1
- package/api-report/tree.legacy.beta.api.md +36 -1
- package/dist/alpha.d.ts +4 -4
- package/dist/beta.d.ts +4 -0
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +2 -2
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +9 -10
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +5 -4
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +0 -1
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +3 -14
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.js +2 -2
- package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +9 -7
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js +34 -11
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
- package/dist/legacy.d.ts +4 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/serializableDomainSchema.d.ts +12 -10
- package/dist/serializableDomainSchema.d.ts.map +1 -1
- package/dist/serializableDomainSchema.js +7 -7
- package/dist/serializableDomainSchema.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +1 -1
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +2 -2
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js +17 -13
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.js +8 -8
- package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryBeta.d.ts +2 -1
- package/dist/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryBeta.js +8 -7
- package/dist/simple-tree/api/schemaFactoryBeta.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +1 -1
- package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
- package/dist/simple-tree/core/allowedTypes.d.ts +6 -2
- package/dist/simple-tree/core/allowedTypes.d.ts.map +1 -1
- package/dist/simple-tree/core/allowedTypes.js +2 -2
- package/dist/simple-tree/core/allowedTypes.js.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.d.ts +3 -4
- package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.js +3 -2
- package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNode.d.ts +4 -3
- package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNode.js +3 -2
- package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.d.ts +4 -3
- package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.js +5 -5
- package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNode.d.ts +3 -10
- package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNode.js +3 -2
- package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNodeTypes.d.ts +2 -2
- package/dist/simple-tree/node-kinds/record/recordNodeTypes.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNodeTypes.js.map +1 -1
- package/dist/tableSchema.d.ts +37 -24
- package/dist/tableSchema.d.ts.map +1 -1
- package/dist/tableSchema.js +81 -54
- package/dist/tableSchema.js.map +1 -1
- package/dist/treeFactory.d.ts.map +1 -1
- package/dist/treeFactory.js +1 -1
- package/dist/treeFactory.js.map +1 -1
- package/dist/util/breakable.js +3 -3
- package/dist/util/breakable.js.map +1 -1
- package/dist/util/index.d.ts +1 -1
- package/dist/util/index.d.ts.map +1 -1
- package/dist/util/index.js +2 -2
- package/dist/util/index.js.map +1 -1
- package/dist/util/utils.d.ts +18 -6
- package/dist/util/utils.d.ts.map +1 -1
- package/dist/util/utils.js +23 -16
- package/dist/util/utils.js.map +1 -1
- package/lib/alpha.d.ts +4 -4
- package/lib/beta.d.ts +4 -0
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +2 -2
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +9 -10
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +5 -4
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +0 -1
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +2 -12
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.js +2 -2
- package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +9 -7
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js +34 -11
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
- package/lib/legacy.d.ts +4 -0
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/serializableDomainSchema.d.ts +12 -10
- package/lib/serializableDomainSchema.d.ts.map +1 -1
- package/lib/serializableDomainSchema.js +8 -8
- package/lib/serializableDomainSchema.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +1 -1
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +2 -2
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js +18 -14
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.js +8 -8
- package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryBeta.d.ts +2 -1
- package/lib/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryBeta.js +8 -7
- package/lib/simple-tree/api/schemaFactoryBeta.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +1 -1
- package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
- package/lib/simple-tree/core/allowedTypes.d.ts +6 -2
- package/lib/simple-tree/core/allowedTypes.d.ts.map +1 -1
- package/lib/simple-tree/core/allowedTypes.js +2 -2
- package/lib/simple-tree/core/allowedTypes.js.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.d.ts +3 -4
- package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.js +3 -2
- package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNode.d.ts +4 -3
- package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNode.js +3 -2
- package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.d.ts +4 -3
- package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.js +5 -5
- package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNode.d.ts +3 -10
- package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNode.js +3 -2
- package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNodeTypes.d.ts +2 -2
- package/lib/simple-tree/node-kinds/record/recordNodeTypes.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNodeTypes.js.map +1 -1
- package/lib/tableSchema.d.ts +37 -24
- package/lib/tableSchema.d.ts.map +1 -1
- package/lib/tableSchema.js +81 -54
- package/lib/tableSchema.js.map +1 -1
- package/lib/treeFactory.d.ts.map +1 -1
- package/lib/treeFactory.js +1 -1
- package/lib/treeFactory.js.map +1 -1
- package/lib/util/breakable.js +3 -3
- package/lib/util/breakable.js.map +1 -1
- package/lib/util/index.d.ts +1 -1
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +1 -1
- package/lib/util/index.js.map +1 -1
- package/lib/util/utils.d.ts +18 -6
- package/lib/util/utils.d.ts.map +1 -1
- package/lib/util/utils.js +21 -14
- package/lib/util/utils.js.map +1 -1
- package/package.json +24 -24
- package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +16 -14
- package/src/feature-libraries/chunked-forest/codec/codecs.ts +8 -4
- package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +2 -13
- package/src/feature-libraries/forest-summary/forestSummarizer.ts +2 -0
- package/src/feature-libraries/forest-summary/incrementalSummaryBuilder.ts +65 -13
- package/src/packageVersion.ts +1 -1
- package/src/serializableDomainSchema.ts +11 -11
- package/src/shared-tree/sharedTree.ts +2 -0
- package/src/simple-tree/api/schemaFactory.ts +38 -22
- package/src/simple-tree/api/schemaFactoryAlpha.ts +8 -17
- package/src/simple-tree/api/schemaFactoryBeta.ts +17 -23
- package/src/simple-tree/api/schemaFactoryRecursive.ts +1 -1
- package/src/simple-tree/core/allowedTypes.ts +5 -17
- package/src/simple-tree/node-kinds/array/arrayNode.ts +5 -4
- package/src/simple-tree/node-kinds/map/mapNode.ts +5 -3
- package/src/simple-tree/node-kinds/object/objectNode.ts +9 -8
- package/src/simple-tree/node-kinds/record/recordNode.ts +6 -18
- package/src/simple-tree/node-kinds/record/recordNodeTypes.ts +2 -2
- package/src/tableSchema.ts +143 -81
- package/src/treeFactory.ts +1 -0
- package/src/util/breakable.ts +4 -4
- package/src/util/index.ts +1 -1
- package/src/util/utils.ts +33 -17
|
@@ -65,6 +65,7 @@ import type {
|
|
|
65
65
|
} from "./mapNodeTypes.js";
|
|
66
66
|
import { recordLikeDataToFlexContent } from "../common.js";
|
|
67
67
|
import { MapNodeStoredSchema } from "../../../core/index.js";
|
|
68
|
+
import type { NodeSchemaOptionsAlpha } from "../../api/index.js";
|
|
68
69
|
|
|
69
70
|
/**
|
|
70
71
|
* A map of string keys to tree objects.
|
|
@@ -268,8 +269,7 @@ export function mapSchema<
|
|
|
268
269
|
info: T,
|
|
269
270
|
implicitlyConstructable: ImplicitlyConstructable,
|
|
270
271
|
useMapPrototype: boolean,
|
|
271
|
-
|
|
272
|
-
persistedMetadata?: JsonCompatibleReadOnlyObject | undefined,
|
|
272
|
+
nodeOptions: NodeSchemaOptionsAlpha<TCustomMetadata> = {},
|
|
273
273
|
) {
|
|
274
274
|
const normalizedTypes = normalizeAllowedTypes(info);
|
|
275
275
|
const lazyAllowedTypesIdentifiers = new Lazy(
|
|
@@ -277,6 +277,7 @@ export function mapSchema<
|
|
|
277
277
|
);
|
|
278
278
|
|
|
279
279
|
let privateData: TreeNodeSchemaPrivateData | undefined;
|
|
280
|
+
const persistedMetadata = nodeOptions.persistedMetadata;
|
|
280
281
|
|
|
281
282
|
class Schema extends CustomMapNodeBase<T> implements TreeMapNode<T> {
|
|
282
283
|
public static override prepareInstance<T2>(
|
|
@@ -319,7 +320,8 @@ export function mapSchema<
|
|
|
319
320
|
public static get childTypes(): ReadonlySet<TreeNodeSchema> {
|
|
320
321
|
return normalizedTypes.evaluateSet();
|
|
321
322
|
}
|
|
322
|
-
public static readonly metadata: NodeSchemaMetadata<TCustomMetadata> =
|
|
323
|
+
public static readonly metadata: NodeSchemaMetadata<TCustomMetadata> =
|
|
324
|
+
nodeOptions.metadata ?? {};
|
|
323
325
|
public static readonly persistedMetadata: JsonCompatibleReadOnlyObject | undefined =
|
|
324
326
|
persistedMetadata;
|
|
325
327
|
|
|
@@ -87,6 +87,7 @@ import {
|
|
|
87
87
|
type InsertableContent,
|
|
88
88
|
} from "../../unhydratedFlexTreeFromInsertable.js";
|
|
89
89
|
import { convertField, convertFieldKind } from "../../toStoredSchema.js";
|
|
90
|
+
import type { ObjectSchemaOptionsAlpha } from "../../api/index.js";
|
|
90
91
|
|
|
91
92
|
/**
|
|
92
93
|
* Generates the properties for an ObjectNode from its field schema object.
|
|
@@ -98,7 +99,7 @@ import { convertField, convertFieldKind } from "../../toStoredSchema.js";
|
|
|
98
99
|
*/
|
|
99
100
|
export type ObjectFromSchemaRecord<T extends RestrictiveStringRecord<ImplicitFieldSchema>> =
|
|
100
101
|
RestrictiveStringRecord<ImplicitFieldSchema> extends T
|
|
101
|
-
? // eslint-disable-next-line @typescript-eslint/ban-types
|
|
102
|
+
? // eslint-disable-next-line @typescript-eslint/no-empty-object-type, @typescript-eslint/ban-types
|
|
102
103
|
{}
|
|
103
104
|
: {
|
|
104
105
|
-readonly [Property in keyof T]: Property extends string
|
|
@@ -415,9 +416,7 @@ export function objectSchema<
|
|
|
415
416
|
identifier: TName,
|
|
416
417
|
info: T,
|
|
417
418
|
implicitlyConstructable: ImplicitlyConstructable,
|
|
418
|
-
|
|
419
|
-
metadata?: NodeSchemaMetadata<TCustomMetadata>,
|
|
420
|
-
persistedMetadata?: JsonCompatibleReadOnlyObject | undefined,
|
|
419
|
+
nodeOptions: ObjectSchemaOptionsAlpha<TCustomMetadata>,
|
|
421
420
|
): ObjectNodeSchema<TName, T, ImplicitlyConstructable, TCustomMetadata> &
|
|
422
421
|
ObjectNodeSchemaInternalData &
|
|
423
422
|
TreeNodeSchemaCorePrivate {
|
|
@@ -471,7 +470,8 @@ export function objectSchema<
|
|
|
471
470
|
]),
|
|
472
471
|
);
|
|
473
472
|
public static readonly identifierFieldKeys: readonly FieldKey[] = identifierFieldKeys;
|
|
474
|
-
public static readonly allowUnknownOptionalFields: boolean =
|
|
473
|
+
public static readonly allowUnknownOptionalFields: boolean =
|
|
474
|
+
nodeOptions.allowUnknownOptionalFields ?? false;
|
|
475
475
|
|
|
476
476
|
public static override prepareInstance<T2>(
|
|
477
477
|
this: typeof TreeNodeValid<T2>,
|
|
@@ -561,9 +561,10 @@ export function objectSchema<
|
|
|
561
561
|
public static get childTypes(): ReadonlySet<TreeNodeSchema> {
|
|
562
562
|
return lazyChildTypes.value;
|
|
563
563
|
}
|
|
564
|
-
public static readonly metadata: NodeSchemaMetadata<TCustomMetadata> =
|
|
564
|
+
public static readonly metadata: NodeSchemaMetadata<TCustomMetadata> =
|
|
565
|
+
nodeOptions.metadata ?? {};
|
|
565
566
|
public static readonly persistedMetadata: JsonCompatibleReadOnlyObject | undefined =
|
|
566
|
-
persistedMetadata;
|
|
567
|
+
nodeOptions.persistedMetadata;
|
|
567
568
|
|
|
568
569
|
// eslint-disable-next-line import/no-deprecated
|
|
569
570
|
public get [typeNameSymbol](): TName {
|
|
@@ -592,7 +593,7 @@ export function objectSchema<
|
|
|
592
593
|
convertField(fieldSchema.schema, storedOptions),
|
|
593
594
|
);
|
|
594
595
|
}
|
|
595
|
-
return new ObjectNodeStoredSchema(fields, persistedMetadata);
|
|
596
|
+
return new ObjectNodeStoredSchema(fields, nodeOptions.persistedMetadata);
|
|
596
597
|
},
|
|
597
598
|
));
|
|
598
599
|
}
|
|
@@ -57,6 +57,7 @@ import {
|
|
|
57
57
|
import { prepareForInsertion } from "../../prepareForInsertion.js";
|
|
58
58
|
import { recordLikeDataToFlexContent } from "../common.js";
|
|
59
59
|
import { MapNodeStoredSchema } from "../../../core/index.js";
|
|
60
|
+
import type { NodeSchemaOptionsAlpha } from "../../api/index.js";
|
|
60
61
|
|
|
61
62
|
/**
|
|
62
63
|
* Create a proxy which implements the {@link TreeRecordNode} API.
|
|
@@ -227,15 +228,7 @@ export interface RecordSchemaOptions<
|
|
|
227
228
|
|
|
228
229
|
readonly implicitlyConstructable: TImplicitlyConstructable;
|
|
229
230
|
|
|
230
|
-
|
|
231
|
-
* Optional ephemeral metadata for the object node schema.
|
|
232
|
-
*/
|
|
233
|
-
readonly metadata?: NodeSchemaMetadata<TCustomMetadata>;
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* Optional persisted metadata for the object node schema.
|
|
237
|
-
*/
|
|
238
|
-
readonly persistedMetadata?: JsonCompatibleReadOnlyObject | undefined;
|
|
231
|
+
readonly nodeOptions?: NodeSchemaOptionsAlpha<TCustomMetadata>;
|
|
239
232
|
}
|
|
240
233
|
|
|
241
234
|
/**
|
|
@@ -258,14 +251,8 @@ export function recordSchema<
|
|
|
258
251
|
TCustomMetadata
|
|
259
252
|
>,
|
|
260
253
|
) {
|
|
261
|
-
const {
|
|
262
|
-
|
|
263
|
-
info,
|
|
264
|
-
customizable,
|
|
265
|
-
implicitlyConstructable,
|
|
266
|
-
metadata,
|
|
267
|
-
persistedMetadata,
|
|
268
|
-
} = options;
|
|
254
|
+
const { identifier, info, customizable, implicitlyConstructable, nodeOptions } = options;
|
|
255
|
+
const persistedMetadata = nodeOptions?.persistedMetadata;
|
|
269
256
|
|
|
270
257
|
const normalizedTypes = normalizeAllowedTypes(info);
|
|
271
258
|
const lazyAllowedTypesIdentifiers = new Lazy(
|
|
@@ -369,7 +356,8 @@ export function recordSchema<
|
|
|
369
356
|
public static get childTypes(): ReadonlySet<TreeNodeSchema> {
|
|
370
357
|
return normalizedTypes.evaluateSet();
|
|
371
358
|
}
|
|
372
|
-
public static readonly metadata: NodeSchemaMetadata<TCustomMetadata> =
|
|
359
|
+
public static readonly metadata: NodeSchemaMetadata<TCustomMetadata> =
|
|
360
|
+
nodeOptions?.metadata ?? {};
|
|
373
361
|
public static readonly persistedMetadata: JsonCompatibleReadOnlyObject | undefined =
|
|
374
362
|
persistedMetadata;
|
|
375
363
|
|
|
@@ -64,7 +64,7 @@ export interface RecordNodeCustomizableSchema<
|
|
|
64
64
|
/* TInsertable */ RecordNodeInsertableData<T>,
|
|
65
65
|
/* ImplicitlyConstructable */ ImplicitlyConstructable,
|
|
66
66
|
/* Info */ T,
|
|
67
|
-
/* TConstructorExtra */
|
|
67
|
+
/* TConstructorExtra */ undefined,
|
|
68
68
|
/* TCustomMetadata */ TCustomMetadata
|
|
69
69
|
>,
|
|
70
70
|
SimpleRecordNodeSchema<TCustomMetadata> {}
|
|
@@ -85,7 +85,7 @@ export interface RecordNodePojoEmulationSchema<
|
|
|
85
85
|
/* TInsertable */ RecordNodeInsertableData<T>,
|
|
86
86
|
/* ImplicitlyConstructable */ ImplicitlyConstructable,
|
|
87
87
|
/* Info */ T,
|
|
88
|
-
/* TConstructorExtra */
|
|
88
|
+
/* TConstructorExtra */ undefined,
|
|
89
89
|
/* TCustomMetadata */ TCustomMetadata
|
|
90
90
|
>,
|
|
91
91
|
SimpleRecordNodeSchema<TCustomMetadata> {}
|
package/src/tableSchema.ts
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
type InsertableObjectFromSchemaRecord,
|
|
14
14
|
type InsertableTreeNodeFromImplicitAllowedTypes,
|
|
15
15
|
type NodeKind,
|
|
16
|
-
type
|
|
16
|
+
type SchemaFactoryBeta,
|
|
17
17
|
type ScopedSchemaName,
|
|
18
18
|
TreeArrayNode,
|
|
19
19
|
type TreeNode,
|
|
@@ -119,7 +119,7 @@ export namespace System_TableSchema {
|
|
|
119
119
|
* @privateRemarks This interface primarily exists to provide a single home for property documentation.
|
|
120
120
|
* @system @alpha
|
|
121
121
|
*/
|
|
122
|
-
export interface OptionsWithSchemaFactory<TSchemaFactory extends
|
|
122
|
+
export interface OptionsWithSchemaFactory<TSchemaFactory extends SchemaFactoryBeta> {
|
|
123
123
|
/**
|
|
124
124
|
* Schema factory with which the Column schema will be associated.
|
|
125
125
|
* @remarks Can be used to associate the resulting schema with an existing {@link SchemaFactory.scope|scope}.
|
|
@@ -148,7 +148,7 @@ export namespace System_TableSchema {
|
|
|
148
148
|
* @system @alpha
|
|
149
149
|
*/
|
|
150
150
|
export type CreateColumnOptionsBase<
|
|
151
|
-
TSchemaFactory extends
|
|
151
|
+
TSchemaFactory extends SchemaFactoryBeta = SchemaFactoryBeta,
|
|
152
152
|
TCell extends ImplicitAllowedTypes = ImplicitAllowedTypes,
|
|
153
153
|
> = OptionsWithSchemaFactory<TSchemaFactory> & OptionsWithCellSchema<TCell>;
|
|
154
154
|
|
|
@@ -162,11 +162,11 @@ export namespace System_TableSchema {
|
|
|
162
162
|
const TCellSchema extends ImplicitAllowedTypes,
|
|
163
163
|
const TPropsSchema extends ImplicitFieldSchema,
|
|
164
164
|
>(
|
|
165
|
-
inputSchemaFactory:
|
|
165
|
+
inputSchemaFactory: SchemaFactoryBeta<TInputScope>,
|
|
166
166
|
cellSchema: TCellSchema,
|
|
167
167
|
propsSchema: TPropsSchema,
|
|
168
168
|
) {
|
|
169
|
-
const schemaFactory = inputSchemaFactory.
|
|
169
|
+
const schemaFactory = inputSchemaFactory.scopedFactory(tableSchemaFactorySubScope);
|
|
170
170
|
type Scope = ScopedSchemaName<TInputScope, typeof tableSchemaFactorySubScope>;
|
|
171
171
|
|
|
172
172
|
type CellValueType = TreeNodeFromImplicitAllowedTypes<TCellSchema>;
|
|
@@ -320,7 +320,7 @@ export namespace System_TableSchema {
|
|
|
320
320
|
* @system @alpha
|
|
321
321
|
*/
|
|
322
322
|
export type CreateRowOptionsBase<
|
|
323
|
-
TSchemaFactory extends
|
|
323
|
+
TSchemaFactory extends SchemaFactoryBeta = SchemaFactoryBeta,
|
|
324
324
|
TCell extends ImplicitAllowedTypes = ImplicitAllowedTypes,
|
|
325
325
|
> = OptionsWithSchemaFactory<TSchemaFactory> & OptionsWithCellSchema<TCell>;
|
|
326
326
|
|
|
@@ -334,11 +334,11 @@ export namespace System_TableSchema {
|
|
|
334
334
|
const TCellSchema extends ImplicitAllowedTypes,
|
|
335
335
|
const TPropsSchema extends ImplicitFieldSchema,
|
|
336
336
|
>(
|
|
337
|
-
inputSchemaFactory:
|
|
337
|
+
inputSchemaFactory: SchemaFactoryBeta<TInputScope>,
|
|
338
338
|
cellSchema: TCellSchema,
|
|
339
339
|
propsSchema: TPropsSchema,
|
|
340
340
|
) {
|
|
341
|
-
const schemaFactory = inputSchemaFactory.
|
|
341
|
+
const schemaFactory = inputSchemaFactory.scopedFactory(tableSchemaFactorySubScope);
|
|
342
342
|
type Scope = ScopedSchemaName<TInputScope, typeof tableSchemaFactorySubScope>;
|
|
343
343
|
|
|
344
344
|
type CellValueType = TreeNodeFromImplicitAllowedTypes<TCellSchema>;
|
|
@@ -538,7 +538,7 @@ export namespace System_TableSchema {
|
|
|
538
538
|
* @system @alpha
|
|
539
539
|
*/
|
|
540
540
|
export type TableFactoryOptionsBase<
|
|
541
|
-
TSchemaFactory extends
|
|
541
|
+
TSchemaFactory extends SchemaFactoryBeta = SchemaFactoryBeta,
|
|
542
542
|
TCell extends ImplicitAllowedTypes = ImplicitAllowedTypes,
|
|
543
543
|
> = OptionsWithSchemaFactory<TSchemaFactory> & OptionsWithCellSchema<TCell>;
|
|
544
544
|
|
|
@@ -553,12 +553,12 @@ export namespace System_TableSchema {
|
|
|
553
553
|
const TColumnSchema extends ColumnSchemaBase<TInputScope, TCellSchema>,
|
|
554
554
|
const TRowSchema extends RowSchemaBase<TInputScope, TCellSchema>,
|
|
555
555
|
>(
|
|
556
|
-
inputSchemaFactory:
|
|
556
|
+
inputSchemaFactory: SchemaFactoryBeta<TInputScope>,
|
|
557
557
|
_cellSchema: TCellSchema,
|
|
558
558
|
columnSchema: TColumnSchema,
|
|
559
559
|
rowSchema: TRowSchema,
|
|
560
560
|
) {
|
|
561
|
-
const schemaFactory = inputSchemaFactory.
|
|
561
|
+
const schemaFactory = inputSchemaFactory.scopedFactory(tableSchemaFactorySubScope);
|
|
562
562
|
type Scope = ScopedSchemaName<TInputScope, typeof tableSchemaFactorySubScope>;
|
|
563
563
|
|
|
564
564
|
type CellValueType = TreeNodeFromImplicitAllowedTypes<TCellSchema>;
|
|
@@ -579,7 +579,7 @@ export namespace System_TableSchema {
|
|
|
579
579
|
* The Table schema
|
|
580
580
|
*/
|
|
581
581
|
class Table
|
|
582
|
-
extends schemaFactory.
|
|
582
|
+
extends schemaFactory.object("Table", tableFields, {
|
|
583
583
|
// Will make it easier to evolve this schema in the future.
|
|
584
584
|
allowUnknownOptionalFields: true,
|
|
585
585
|
})
|
|
@@ -591,32 +591,24 @@ export namespace System_TableSchema {
|
|
|
591
591
|
return new this({ columns: [], rows: [] }) as InstanceType<TThis>;
|
|
592
592
|
}
|
|
593
593
|
|
|
594
|
-
public getColumn(
|
|
595
|
-
|
|
596
|
-
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
597
|
-
return this.columns.find((column) => (column as ColumnValueType).id === id) as
|
|
598
|
-
| ColumnValueType
|
|
599
|
-
| undefined;
|
|
594
|
+
public getColumn(indexOrId: number | string): ColumnValueType | undefined {
|
|
595
|
+
return this._tryGetColumn(indexOrId);
|
|
600
596
|
}
|
|
601
597
|
|
|
602
|
-
public getRow(
|
|
603
|
-
|
|
604
|
-
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
605
|
-
return this.rows.find((_row) => (_row as RowValueType).id === id) as
|
|
606
|
-
| RowValueType
|
|
607
|
-
| undefined;
|
|
598
|
+
public getRow(indexOrId: number | string): RowValueType | undefined {
|
|
599
|
+
return this._tryGetRow(indexOrId);
|
|
608
600
|
}
|
|
609
601
|
|
|
610
602
|
public getCell(
|
|
611
603
|
key: TableSchema.CellKey<TColumnSchema, TRowSchema>,
|
|
612
604
|
): CellValueType | undefined {
|
|
613
|
-
const { column:
|
|
614
|
-
const row = this._tryGetRow(
|
|
605
|
+
const { column: columnOrIdOrIndex, row: rowOrIdOrIndex } = key;
|
|
606
|
+
const row = this._tryGetRow(rowOrIdOrIndex);
|
|
615
607
|
if (row === undefined) {
|
|
616
608
|
return undefined;
|
|
617
609
|
}
|
|
618
610
|
|
|
619
|
-
const column = this._tryGetColumn(
|
|
611
|
+
const column = this._tryGetColumn(columnOrIdOrIndex);
|
|
620
612
|
if (column === undefined) {
|
|
621
613
|
return undefined;
|
|
622
614
|
}
|
|
@@ -816,7 +808,8 @@ export namespace System_TableSchema {
|
|
|
816
808
|
// So if we throw an error here for any row, no rows will be removed.
|
|
817
809
|
for (const rowToRemove of rowsToRemove) {
|
|
818
810
|
// We have already validated that all of the rows exist above, so this is safe.
|
|
819
|
-
this.rows.
|
|
811
|
+
const index = this.rows.indexOf(rowToRemove);
|
|
812
|
+
this.rows.removeAt(index);
|
|
820
813
|
}
|
|
821
814
|
});
|
|
822
815
|
return rowsToRemove;
|
|
@@ -825,9 +818,9 @@ export namespace System_TableSchema {
|
|
|
825
818
|
public removeCell(
|
|
826
819
|
key: TableSchema.CellKey<TColumnSchema, TRowSchema>,
|
|
827
820
|
): CellValueType | undefined {
|
|
828
|
-
const { column:
|
|
829
|
-
const row = this._getRow(
|
|
830
|
-
const column = this._getColumn(
|
|
821
|
+
const { column: columnOrIdOrIndex, row: rowOrIdOrIndex } = key;
|
|
822
|
+
const row = this._getRow(rowOrIdOrIndex);
|
|
823
|
+
const column = this._getColumn(columnOrIdOrIndex);
|
|
831
824
|
|
|
832
825
|
const cell: CellValueType | undefined = row.getCell(column.id);
|
|
833
826
|
if (cell === undefined) {
|
|
@@ -906,10 +899,32 @@ export namespace System_TableSchema {
|
|
|
906
899
|
* @remarks Searches for a match based strictly on the ID and returns that result.
|
|
907
900
|
*/
|
|
908
901
|
private _tryGetColumn(
|
|
909
|
-
|
|
902
|
+
columnOrIdOrIndex: ColumnValueType | string | number,
|
|
910
903
|
): ColumnValueType | undefined {
|
|
911
|
-
|
|
912
|
-
|
|
904
|
+
if (typeof columnOrIdOrIndex === "number") {
|
|
905
|
+
if (columnOrIdOrIndex < 0 || columnOrIdOrIndex >= this.columns.length) {
|
|
906
|
+
return undefined;
|
|
907
|
+
}
|
|
908
|
+
// TypeScript is unable to narrow the types correctly here, hence the cast.
|
|
909
|
+
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
910
|
+
return this.columns[columnOrIdOrIndex] as ColumnValueType;
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
if (typeof columnOrIdOrIndex === "string") {
|
|
914
|
+
const columnId = columnOrIdOrIndex;
|
|
915
|
+
// TypeScript is unable to narrow the types correctly here, hence the casts.
|
|
916
|
+
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
917
|
+
return this.columns.find((col) => (col as ColumnValueType).id === columnId) as
|
|
918
|
+
| ColumnValueType
|
|
919
|
+
| undefined;
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
// If the user provided a node, ensure it actually exists in this table.
|
|
923
|
+
if (!this.columns.includes(columnOrIdOrIndex)) {
|
|
924
|
+
return undefined;
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
return columnOrIdOrIndex;
|
|
913
928
|
}
|
|
914
929
|
|
|
915
930
|
/**
|
|
@@ -917,23 +932,16 @@ export namespace System_TableSchema {
|
|
|
917
932
|
* @throws Throws a `UsageError` if there is no match.
|
|
918
933
|
* @remarks Searches for a match based strictly on the ID and returns that result.
|
|
919
934
|
*/
|
|
920
|
-
private _getColumn(
|
|
921
|
-
|
|
935
|
+
private _getColumn(
|
|
936
|
+
columnOrIdOrIndex: ColumnValueType | string | number,
|
|
937
|
+
): ColumnValueType {
|
|
938
|
+
const column = this._tryGetColumn(columnOrIdOrIndex);
|
|
922
939
|
if (column === undefined) {
|
|
923
|
-
|
|
940
|
+
Table._throwMissingColumnError(columnOrIdOrIndex);
|
|
924
941
|
}
|
|
925
942
|
return column;
|
|
926
943
|
}
|
|
927
944
|
|
|
928
|
-
/**
|
|
929
|
-
* Resolves a Column node or ID to its ID.
|
|
930
|
-
* If an ID is provided, it is returned as-is.
|
|
931
|
-
* If a node is provided, its ID is returned.
|
|
932
|
-
*/
|
|
933
|
-
private _getColumnId(columnOrId: string | ColumnValueType): string {
|
|
934
|
-
return typeof columnOrId === "string" ? columnOrId : columnOrId.id;
|
|
935
|
-
}
|
|
936
|
-
|
|
937
945
|
/**
|
|
938
946
|
* Checks if a Column with the specified ID exists in the table.
|
|
939
947
|
*/
|
|
@@ -942,10 +950,24 @@ export namespace System_TableSchema {
|
|
|
942
950
|
}
|
|
943
951
|
|
|
944
952
|
/**
|
|
945
|
-
* Throw a `UsageError` for a missing Column by its ID.
|
|
953
|
+
* Throw a `UsageError` for a missing Column by its ID or index.
|
|
946
954
|
*/
|
|
947
|
-
private _throwMissingColumnError(
|
|
948
|
-
|
|
955
|
+
private static _throwMissingColumnError(
|
|
956
|
+
columnOrIdOrIndex: ColumnValueType | string | number,
|
|
957
|
+
): never {
|
|
958
|
+
if (typeof columnOrIdOrIndex === "number") {
|
|
959
|
+
throw new UsageError(`No column exists at index ${columnOrIdOrIndex}.`);
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
if (typeof columnOrIdOrIndex === "string") {
|
|
963
|
+
throw new UsageError(
|
|
964
|
+
`No column with ID "${columnOrIdOrIndex}" exists in the table.`,
|
|
965
|
+
);
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
throw new UsageError(
|
|
969
|
+
`The specified column node with ID "${columnOrIdOrIndex.id}" does not exist in the table.`,
|
|
970
|
+
);
|
|
949
971
|
}
|
|
950
972
|
|
|
951
973
|
/**
|
|
@@ -953,38 +975,65 @@ export namespace System_TableSchema {
|
|
|
953
975
|
* Returns `undefined` if there is no match.
|
|
954
976
|
* @remarks Searches for a match based strictly on the ID and returns that result.
|
|
955
977
|
*/
|
|
956
|
-
private _tryGetRow(
|
|
957
|
-
|
|
958
|
-
|
|
978
|
+
private _tryGetRow(
|
|
979
|
+
rowOrIdOrIndex: RowValueType | string | number,
|
|
980
|
+
): RowValueType | undefined {
|
|
981
|
+
if (typeof rowOrIdOrIndex === "number") {
|
|
982
|
+
if (rowOrIdOrIndex < 0 || rowOrIdOrIndex >= this.rows.length) {
|
|
983
|
+
return undefined;
|
|
984
|
+
}
|
|
985
|
+
// TypeScript is unable to narrow the types correctly here, hence the cast.
|
|
986
|
+
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
987
|
+
return this.rows[rowOrIdOrIndex] as RowValueType;
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
if (typeof rowOrIdOrIndex === "string") {
|
|
991
|
+
const rowId = rowOrIdOrIndex;
|
|
992
|
+
// TypeScript is unable to narrow the types correctly here, hence the casts.
|
|
993
|
+
// See: https://github.com/microsoft/TypeScript/issues/52144
|
|
994
|
+
return this.rows.find((row) => (row as RowValueType).id === rowId) as
|
|
995
|
+
| RowValueType
|
|
996
|
+
| undefined;
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
// If the user provided a node, ensure it actually exists in this table.
|
|
1000
|
+
if (!this.rows.includes(rowOrIdOrIndex)) {
|
|
1001
|
+
return undefined;
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
return rowOrIdOrIndex;
|
|
959
1005
|
}
|
|
960
1006
|
|
|
961
1007
|
/**
|
|
962
|
-
* Attempts to resolve the provided Row node or
|
|
1008
|
+
* Attempts to resolve the provided Row node, ID, or index to a Row node in the table.
|
|
963
1009
|
* @throws Throws a `UsageError` if there is no match.
|
|
964
1010
|
* @remarks Searches for a match based strictly on the ID and returns that result.
|
|
965
1011
|
*/
|
|
966
|
-
private _getRow(
|
|
967
|
-
const row = this._tryGetRow(
|
|
1012
|
+
private _getRow(rowOrIdOrIndex: RowValueType | string | number): RowValueType {
|
|
1013
|
+
const row = this._tryGetRow(rowOrIdOrIndex);
|
|
968
1014
|
if (row === undefined) {
|
|
969
|
-
|
|
1015
|
+
Table._throwMissingRowError(rowOrIdOrIndex);
|
|
970
1016
|
}
|
|
971
1017
|
return row;
|
|
972
1018
|
}
|
|
973
1019
|
|
|
974
1020
|
/**
|
|
975
|
-
*
|
|
976
|
-
* If an ID is provided, it is returned as-is.
|
|
977
|
-
* If a node is provided, its ID is returned.
|
|
1021
|
+
* Throw a `UsageError` for a missing Row by its ID or index.
|
|
978
1022
|
*/
|
|
979
|
-
private
|
|
980
|
-
|
|
981
|
-
|
|
1023
|
+
private static _throwMissingRowError(
|
|
1024
|
+
rowOrIdOrIndex: RowValueType | string | number,
|
|
1025
|
+
): never {
|
|
1026
|
+
if (typeof rowOrIdOrIndex === "number") {
|
|
1027
|
+
throw new UsageError(`No row exists at index ${rowOrIdOrIndex}.`);
|
|
1028
|
+
}
|
|
982
1029
|
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
throw new UsageError(
|
|
1030
|
+
if (typeof rowOrIdOrIndex === "string") {
|
|
1031
|
+
throw new UsageError(`No row with ID "${rowOrIdOrIndex}" exists in the table.`);
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
throw new UsageError(
|
|
1035
|
+
`The specified row node with ID "${rowOrIdOrIndex.id}" does not exist in the table.`,
|
|
1036
|
+
);
|
|
988
1037
|
}
|
|
989
1038
|
|
|
990
1039
|
private static _removeRange<TNodeSchema extends ImplicitAllowedTypes>(
|
|
@@ -1225,7 +1274,7 @@ export namespace TableSchema {
|
|
|
1225
1274
|
|
|
1226
1275
|
/**
|
|
1227
1276
|
* Gets all of the populated cells in the column, keyed by their associated row IDs.
|
|
1228
|
-
* @throws Throws an error if the
|
|
1277
|
+
* @throws Throws an error if the column is not in a table.
|
|
1229
1278
|
*/
|
|
1230
1279
|
getCells(): readonly {
|
|
1231
1280
|
rowId: string;
|
|
@@ -1243,7 +1292,7 @@ export namespace TableSchema {
|
|
|
1243
1292
|
const TScope extends string | undefined,
|
|
1244
1293
|
const TCell extends ImplicitAllowedTypes,
|
|
1245
1294
|
>(
|
|
1246
|
-
params: System_TableSchema.CreateColumnOptionsBase<
|
|
1295
|
+
params: System_TableSchema.CreateColumnOptionsBase<SchemaFactoryBeta<TScope>, TCell>,
|
|
1247
1296
|
): System_TableSchema.ColumnSchemaBase<TScope, TCell, System_TableSchema.DefaultPropsType>;
|
|
1248
1297
|
/**
|
|
1249
1298
|
* Factory for creating new table column schema.
|
|
@@ -1257,7 +1306,7 @@ export namespace TableSchema {
|
|
|
1257
1306
|
const TCell extends ImplicitAllowedTypes,
|
|
1258
1307
|
const TProps extends ImplicitFieldSchema,
|
|
1259
1308
|
>(
|
|
1260
|
-
params: System_TableSchema.CreateColumnOptionsBase<
|
|
1309
|
+
params: System_TableSchema.CreateColumnOptionsBase<SchemaFactoryBeta<TScope>, TCell> & {
|
|
1261
1310
|
/**
|
|
1262
1311
|
* Optional column properties.
|
|
1263
1312
|
*/
|
|
@@ -1366,7 +1415,7 @@ export namespace TableSchema {
|
|
|
1366
1415
|
const TScope extends string | undefined,
|
|
1367
1416
|
const TCell extends ImplicitAllowedTypes,
|
|
1368
1417
|
>(
|
|
1369
|
-
params: System_TableSchema.CreateRowOptionsBase<
|
|
1418
|
+
params: System_TableSchema.CreateRowOptionsBase<SchemaFactoryBeta<TScope>, TCell>,
|
|
1370
1419
|
): System_TableSchema.RowSchemaBase<TScope, TCell, System_TableSchema.DefaultPropsType>;
|
|
1371
1420
|
/**
|
|
1372
1421
|
* Factory for creating new table row schema.
|
|
@@ -1380,7 +1429,7 @@ export namespace TableSchema {
|
|
|
1380
1429
|
const TCell extends ImplicitAllowedTypes,
|
|
1381
1430
|
const TProps extends ImplicitFieldSchema,
|
|
1382
1431
|
>(
|
|
1383
|
-
params: System_TableSchema.CreateRowOptionsBase<
|
|
1432
|
+
params: System_TableSchema.CreateRowOptionsBase<SchemaFactoryBeta<TScope>, TCell> & {
|
|
1384
1433
|
/**
|
|
1385
1434
|
* Optional row properties.
|
|
1386
1435
|
*/
|
|
@@ -1413,14 +1462,14 @@ export namespace TableSchema {
|
|
|
1413
1462
|
TRow extends ImplicitAllowedTypes,
|
|
1414
1463
|
> {
|
|
1415
1464
|
/**
|
|
1416
|
-
* {@link TableSchema.Column}
|
|
1465
|
+
* {@link TableSchema.Column}, {@link TableSchema.Column.id}, or column index at which the cell is located.
|
|
1417
1466
|
*/
|
|
1418
|
-
readonly column: string | TreeNodeFromImplicitAllowedTypes<TColumn>;
|
|
1467
|
+
readonly column: string | number | TreeNodeFromImplicitAllowedTypes<TColumn>;
|
|
1419
1468
|
|
|
1420
1469
|
/**
|
|
1421
|
-
* {@link TableSchema.Row}
|
|
1470
|
+
* {@link TableSchema.Row}, {@link TableSchema.Row.id}, or row index at which the cell is located.
|
|
1422
1471
|
*/
|
|
1423
|
-
readonly row: string | TreeNodeFromImplicitAllowedTypes<TRow>;
|
|
1472
|
+
readonly row: string | number | TreeNodeFromImplicitAllowedTypes<TRow>;
|
|
1424
1473
|
}
|
|
1425
1474
|
|
|
1426
1475
|
/**
|
|
@@ -1503,17 +1552,30 @@ export namespace TableSchema {
|
|
|
1503
1552
|
|
|
1504
1553
|
/**
|
|
1505
1554
|
* Gets a table column by its {@link TableSchema.Column.id}.
|
|
1555
|
+
* @returns The column, if it exists. Otherwise, `undefined`.
|
|
1506
1556
|
*/
|
|
1507
1557
|
getColumn(id: string): TreeNodeFromImplicitAllowedTypes<TColumn> | undefined;
|
|
1558
|
+
/**
|
|
1559
|
+
* Gets a table column by its index in the table.
|
|
1560
|
+
* @returns The column, if it exists. Otherwise, `undefined`.
|
|
1561
|
+
*/
|
|
1562
|
+
getColumn(index: number): TreeNodeFromImplicitAllowedTypes<TColumn> | undefined;
|
|
1508
1563
|
|
|
1509
1564
|
/**
|
|
1510
1565
|
* Gets a table row by its {@link TableSchema.Row.id}.
|
|
1566
|
+
* @returns The row, if it exists. Otherwise, `undefined`.
|
|
1511
1567
|
*/
|
|
1512
1568
|
getRow(id: string): TreeNodeFromImplicitAllowedTypes<TRow> | undefined;
|
|
1569
|
+
/**
|
|
1570
|
+
* Gets a table row by its index in the table.
|
|
1571
|
+
* @returns The row, if it exists. Otherwise, `undefined`.
|
|
1572
|
+
*/
|
|
1573
|
+
getRow(index: number): TreeNodeFromImplicitAllowedTypes<TRow> | undefined;
|
|
1513
1574
|
|
|
1514
1575
|
/**
|
|
1515
|
-
* Gets a cell in the table by column and row
|
|
1576
|
+
* Gets a cell in the table by corresponding column and row.
|
|
1516
1577
|
* @param key - A key that uniquely distinguishes a cell in the table, represented as a combination of the column ID and row ID.
|
|
1578
|
+
* @returns The cell, if it exists. Otherwise, `undefined`.
|
|
1517
1579
|
*/
|
|
1518
1580
|
getCell(key: CellKey<TColumn, TRow>): TreeNodeFromImplicitAllowedTypes<TCell> | undefined;
|
|
1519
1581
|
|
|
@@ -1644,7 +1706,7 @@ export namespace TableSchema {
|
|
|
1644
1706
|
const TScope extends string | undefined,
|
|
1645
1707
|
const TCell extends ImplicitAllowedTypes,
|
|
1646
1708
|
>(
|
|
1647
|
-
params: System_TableSchema.TableFactoryOptionsBase<
|
|
1709
|
+
params: System_TableSchema.TableFactoryOptionsBase<SchemaFactoryBeta<TScope>, TCell>,
|
|
1648
1710
|
): System_TableSchema.TableSchemaBase<
|
|
1649
1711
|
TScope,
|
|
1650
1712
|
TCell,
|
|
@@ -1663,7 +1725,7 @@ export namespace TableSchema {
|
|
|
1663
1725
|
const TCell extends ImplicitAllowedTypes,
|
|
1664
1726
|
const TColumn extends System_TableSchema.ColumnSchemaBase<TScope, TCell>,
|
|
1665
1727
|
>(
|
|
1666
|
-
params: System_TableSchema.TableFactoryOptionsBase<
|
|
1728
|
+
params: System_TableSchema.TableFactoryOptionsBase<SchemaFactoryBeta<TScope>, TCell> & {
|
|
1667
1729
|
readonly column: TColumn;
|
|
1668
1730
|
},
|
|
1669
1731
|
): System_TableSchema.TableSchemaBase<
|
|
@@ -1684,7 +1746,7 @@ export namespace TableSchema {
|
|
|
1684
1746
|
const TCell extends ImplicitAllowedTypes,
|
|
1685
1747
|
const TRow extends System_TableSchema.RowSchemaBase<TScope, TCell>,
|
|
1686
1748
|
>(
|
|
1687
|
-
params: System_TableSchema.TableFactoryOptionsBase<
|
|
1749
|
+
params: System_TableSchema.TableFactoryOptionsBase<SchemaFactoryBeta<TScope>, TCell> & {
|
|
1688
1750
|
readonly row: TRow;
|
|
1689
1751
|
},
|
|
1690
1752
|
): System_TableSchema.TableSchemaBase<
|
|
@@ -1707,7 +1769,7 @@ export namespace TableSchema {
|
|
|
1707
1769
|
const TColumn extends System_TableSchema.ColumnSchemaBase<TScope, TCell>,
|
|
1708
1770
|
const TRow extends System_TableSchema.RowSchemaBase<TScope, TCell>,
|
|
1709
1771
|
>(
|
|
1710
|
-
params: System_TableSchema.TableFactoryOptionsBase<
|
|
1772
|
+
params: System_TableSchema.TableFactoryOptionsBase<SchemaFactoryBeta<TScope>, TCell> & {
|
|
1711
1773
|
readonly column: TColumn;
|
|
1712
1774
|
readonly row: TRow;
|
|
1713
1775
|
},
|
package/src/treeFactory.ts
CHANGED
package/src/util/breakable.ts
CHANGED
|
@@ -171,10 +171,10 @@ export function throwIfBroken<
|
|
|
171
171
|
return replacementMethod as Target;
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
174
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type, @typescript-eslint/ban-types
|
|
175
175
|
type PossiblyNamedFunction = Function & { displayName?: undefined | string };
|
|
176
176
|
|
|
177
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
177
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type, @typescript-eslint/ban-types
|
|
178
178
|
function nameFunctionFrom(toName: Function, nameFrom: Function): void {
|
|
179
179
|
(toName as PossiblyNamedFunction).displayName =
|
|
180
180
|
(nameFrom as PossiblyNamedFunction).displayName ?? nameFrom.name;
|
|
@@ -183,13 +183,13 @@ function nameFunctionFrom(toName: Function, nameFrom: Function): void {
|
|
|
183
183
|
const isBreakerSymbol: unique symbol = Symbol("isBreaker");
|
|
184
184
|
|
|
185
185
|
// Accepting any function like value is desired and safe here as this does not call the provided function.
|
|
186
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
186
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type, @typescript-eslint/ban-types
|
|
187
187
|
function markBreaker(f: Function): void {
|
|
188
188
|
(f as unknown as Record<typeof isBreakerSymbol, true>)[isBreakerSymbol] = true;
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
// Accepting any function like value is desired and safe here as this does not call the provided function.
|
|
192
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
192
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type, @typescript-eslint/ban-types
|
|
193
193
|
function isBreaker(f: Function): boolean {
|
|
194
194
|
return isBreakerSymbol in (f as unknown as Record<typeof isBreakerSymbol, true>);
|
|
195
195
|
}
|