@fluidframework/core-interfaces 2.70.0-361248 → 2.70.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/CHANGELOG.md +4 -0
- package/api-report/core-interfaces.legacy.beta.api.md +6 -0
- package/dist/erasedType.d.ts +2 -2
- package/dist/erasedType.js +2 -2
- package/dist/erasedType.js.map +1 -1
- package/dist/error.d.ts +50 -0
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +6 -1
- package/dist/error.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/legacy.d.ts +4 -0
- package/lib/erasedType.d.ts +2 -2
- package/lib/erasedType.js +2 -2
- package/lib/erasedType.js.map +1 -1
- package/lib/error.d.ts +50 -0
- package/lib/error.d.ts.map +1 -1
- package/lib/error.js +5 -0
- package/lib/error.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/legacy.d.ts +4 -0
- package/package.json +1 -1
- package/src/erasedType.ts +2 -2
- package/src/error.ts +55 -0
- package/src/index.ts +8 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,12 @@
|
|
|
7
7
|
// @public
|
|
8
8
|
export type ConfigTypes = string | number | boolean | number[] | string[] | boolean[] | undefined;
|
|
9
9
|
|
|
10
|
+
// @beta @sealed @system
|
|
11
|
+
export abstract class ErasedBaseType<out Name = unknown> {
|
|
12
|
+
protected constructor();
|
|
13
|
+
protected abstract brand(dummy: never): Name;
|
|
14
|
+
}
|
|
15
|
+
|
|
10
16
|
// @public @sealed
|
|
11
17
|
export abstract class ErasedType<out Name = unknown> {
|
|
12
18
|
static [Symbol.hasInstance](value: never): value is never;
|
package/dist/erasedType.d.ts
CHANGED
|
@@ -88,10 +88,10 @@ export declare abstract class ErasedType<out Name = unknown> {
|
|
|
88
88
|
*
|
|
89
89
|
* This class should only be a `type` package export, preventing users from extending it directly.
|
|
90
90
|
*
|
|
91
|
-
* Since {@link ErasedTypeImplementation} is exported as `@internal`, this restricts implementations of the sealed interfaces to users of `@internal` APIs, which should be anything
|
|
91
|
+
* Since {@link ErasedTypeImplementation} is exported as `@internal`, this restricts implementations of the sealed interfaces to users of `@internal` APIs, which should be anything within this release group.
|
|
92
92
|
* Any finer grained restrictions can be done as documentation, but not type enforced.
|
|
93
93
|
* @sealed
|
|
94
|
-
* @
|
|
94
|
+
* @beta
|
|
95
95
|
* @system
|
|
96
96
|
*/
|
|
97
97
|
export declare abstract class ErasedBaseType<out Name = unknown> {
|
package/dist/erasedType.js
CHANGED
|
@@ -86,10 +86,10 @@ exports.ErasedType = ErasedType;
|
|
|
86
86
|
*
|
|
87
87
|
* This class should only be a `type` package export, preventing users from extending it directly.
|
|
88
88
|
*
|
|
89
|
-
* Since {@link ErasedTypeImplementation} is exported as `@internal`, this restricts implementations of the sealed interfaces to users of `@internal` APIs, which should be anything
|
|
89
|
+
* Since {@link ErasedTypeImplementation} is exported as `@internal`, this restricts implementations of the sealed interfaces to users of `@internal` APIs, which should be anything within this release group.
|
|
90
90
|
* Any finer grained restrictions can be done as documentation, but not type enforced.
|
|
91
91
|
* @sealed
|
|
92
|
-
* @
|
|
92
|
+
* @beta
|
|
93
93
|
* @system
|
|
94
94
|
*/
|
|
95
95
|
class ErasedBaseType {
|
package/dist/erasedType.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"erasedType.js","sourceRoot":"","sources":["../src/erasedType.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,MAAsB,UAAU;IAU/B;;OAEG;IACH,gBAAuB,CAAC;IAExB;;;;OAIG;IACI,MAAM,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,KAAY;QAC9C,MAAM,IAAI,KAAK,CACd,yGAAyG,CACzG,CAAC;IACH,CAAC;CACD;AAzBD,gCAyBC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAsB,cAAc;IAUnC;;;;;;OAMG;IACH,gBAAyB,CAAC;CAC1B;AAlBD,wCAkBC;AAED;;;;;;;;;GASG;AACH,MAAsB,wBAEpB,SAAQ,cAA4E;IAKrF;QACC,KAAK,EAAE,CAAC;IACT,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAEjC,KAAc;QAEd,OAAO,CACN,OAAO,KAAK,KAAK,QAAQ;YACzB,KAAK,KAAK,IAAI;YACd,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAC1D,CAAC;IACH,CAAC;IAED;;;;;;;;;OASG;IACI,MAAM,CAAC,MAAM,CAEnB,KAAkD;QAElD,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,KAAe,CAAC,EAAE,CAAC;YAC/E,MAAM,IAAI,SAAS,CAAC,iCAAiC,CAAC,CAAC;QACxD,CAAC;IACF,CAAC;IAED;;;;OAIG;IACI,MAAM;QACZ,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AApDD,4DAoDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Erased type which can be used to expose a opaque/erased version of a type without referencing the actual type.\n * @remarks\n * This similar to the {@link https://en.wikipedia.org/wiki/Type_erasure | type erasure} pattern,\n * but for erasing types at the package boundary.\n *\n * This can be used to implement the TypeScript typing for the {@link https://en.wikipedia.org/wiki/Handle_(computing) | handle} pattern,\n * allowing code outside of a package to have a reference/handle to something in the package in a type safe way without the package having to publicly export the types of the object.\n * This should not be confused with the more specific IFluidHandle which is also named after this design pattern.\n *\n * Recommended usage is to use `interface` instead of `type` so tooling (such as tsc and refactoring tools)\n * uses the type name instead of expanding it.\n *\n * @example\n * ```typescript\n * // public sealed type\n * export interface ErasedMyType extends ErasedType<\"myPackage.MyType\"> {}\n * // internal type\n * export interface MyType {\n * \texample: number;\n * }\n * // Usage\n * function extract(input: ErasedMyType): MyType {\n * \treturn input as unknown as MyType;\n * }\n * function erase(input: MyType): ErasedMyType {\n * \treturn input as unknown as ErasedMyType;\n * }\n * ```\n *\n * Do not use this class with `instanceof`: this will always be false at runtime,\n * but the compiler may think it's true in some cases.\n * @privateRemarks\n * For this pattern to work well it needs to be difficult for a user of the erased type to\n * implicitly use something other than a instance received from the package as an instance of the erased type in type safe code.\n *\n * This means that this type must not be able to be implicitly converted to from any strong type (not `any` or `never`),\n * and no amount of auto complete or auto-implement refactoring will produce something that can be used as an erased type.\n * This is accomplished by:\n *\n * 1. requiring that values of this type be an instance of this class.\n * Typescript does not enforce this requirement for class: only for classes with protected or private members, so such member is included.\n *\n * 2. making this class impossible to get an instance of.\n * This is done by having a private constructor.\n *\n * 3. ensuring different erased types also using this library can not be implicitly converted between each-other.\n * This is done by using the \"Name\" type parameter.\n * Note that just having the type parameter is not enough since the presence of type parameters has no impact on implicit conversion in TypeScript:\n * only the usages of the type parameter matter.\n *\n * @sealed\n * @public\n */\nexport abstract class ErasedType<out Name = unknown> {\n\t/**\n\t * Compile time only marker to make type checking more strict.\n\t * This method will not exist at runtime and accessing it is invalid.\n\t * @privateRemarks\n\t * `Name` is used as the return type of a method rather than a a simple readonly member as this allows types with two brands to be intersected without getting `never`.\n\t * The method takes in never to help emphasize that its not callable.\n\t */\n\tprotected abstract brand(dummy: never): Name;\n\n\t/**\n\t * This class should never exist at runtime, so make it un-constructable.\n\t */\n\tprivate constructor() {}\n\n\t/**\n\t * Since this class is a compile time only type brand, `instanceof` will never work with it.\n\t * This `Symbol.hasInstance` implementation ensures that `instanceof` will error if used,\n\t * and in TypeScript 5.3 and newer will produce a compile time error if used.\n\t */\n\tpublic static [Symbol.hasInstance](value: never): value is never {\n\t\tthrow new Error(\n\t\t\t\"ErasedType is a compile time type brand not a real class that can be used with `instanceof` at runtime.\",\n\t\t);\n\t}\n}\n\n/**\n * Used to mark a `@sealed` interface in a strongly typed way to prevent external implementations.\n * @remarks\n * This is an alternative to {@link ErasedType} which is more ergonomic to implement in the case where the implementation can extend `ErasedTypeImplementation`.\n *\n * Users of interfaces extending this should never refer to anything about this class:\n * migrating the type branding to another mechanism, like {@link ErasedType} should be considered a non-breaking change.\n * @privateRemarks\n * Implement interfaces which extend this by sub-classing {@link ErasedTypeImplementation}.\n *\n * This class should only be a `type` package export, preventing users from extending it directly.\n *\n * Since {@link ErasedTypeImplementation} is exported as `@internal`, this restricts implementations of the sealed interfaces to users of `@internal` APIs, which should be anything withing this release group.\n * Any finer grained restrictions can be done as documentation, but not type enforced.\n * @sealed\n * @alpha\n * @system\n */\nexport abstract class ErasedBaseType<out Name = unknown> {\n\t/**\n\t * Compile time only marker to make type checking more strict.\n\t * This method will not exist at runtime and accessing it is invalid.\n\t * @privateRemarks\n\t * `Name` is used as the return type of a method rather than a a simple readonly member as this allows types with two brands to be intersected without getting `never`.\n\t * The method takes in never to help emphasize that its not callable.\n\t */\n\tprotected abstract brand(dummy: never): Name;\n\n\t/**\n\t * This class should never exist at runtime, so make it un-constructable.\n\t * @privateRemarks\n\t * From an API perspective, private would be preferred here.\n\t * However protected is almost as good since this class is not package exported,\n\t * and it allows ErasedTypeImplementation to extend this class.\n\t */\n\tprotected constructor() {}\n}\n\n/**\n * An implementation of an {@link ErasedBaseType}.\n * For a given erased type interface, there should be exactly one implementation of it, and it must be defined by the same code which defined the interface.\n *\n * @typeParam TInterface - The erased type interface this class implements.\n * @remarks\n * {@link ErasedBaseType} is package exported only as a type, not a value, so the only way to subclass it is via this class.\n * This limitation help enforce the pattern that there is only one implementation of a given erased type interface.\n * @internal\n */\nexport abstract class ErasedTypeImplementation<\n\tTInterface extends ErasedBaseType,\n> extends ErasedBaseType<TInterface extends ErasedBaseType<infer Name> ? Name : never> {\n\tprotected readonly brand!: (\n\t\tdummy: never,\n\t) => TInterface extends ErasedBaseType<infer Name> ? Name : never;\n\n\tprotected constructor() {\n\t\tsuper();\n\t}\n\n\t/**\n\t * {@link https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates|Type predicate} for narrowing the internal implementation type via `instanceof`.\n\t */\n\tpublic static [Symbol.hasInstance]<TThis extends { prototype: object }>(\n\t\tthis: TThis,\n\t\tvalue: unknown,\n\t): value is InstanceTypeRelaxed<TThis> {\n\t\treturn (\n\t\t\ttypeof value === \"object\" &&\n\t\t\tvalue !== null &&\n\t\t\tObject.prototype.isPrototypeOf.call(this.prototype, value)\n\t\t);\n\t}\n\n\t/**\n\t * {@link https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#assertion-functions|Type assertion} which narrows from ErasedBaseType to the internal implementation type.\n\t * @remarks\n\t * This does a checked conversion, throwing a `TypeError` if invalid.\n\t *\n\t * It would be safer if this narrowed from `TInterface`, but that is not possible since type parameters can not be accessed in static methods.\n\t * Replacing `ErasedTypeImplementation` with a generic function which returns a non-generic class could be used to work around this limitation if desired.\n\t *\n\t * Derived classes can provide their own customized narrowing function with a more specific types if desired.\n\t */\n\tpublic static narrow<TThis extends { prototype: object }>(\n\t\tthis: TThis,\n\t\tvalue: ErasedBaseType | InstanceTypeRelaxed<TThis>,\n\t): asserts value is InstanceTypeRelaxed<TThis> {\n\t\tif (!ErasedTypeImplementation[Symbol.hasInstance].call(this, value as object)) {\n\t\t\tthrow new TypeError(\"Invalid ErasedBaseType instance\");\n\t\t}\n\t}\n\n\t/**\n\t * Upcasts the instance to the erased interface type.\n\t * @remarks\n\t * This is mainly useful when inferring the interface type is required.\n\t */\n\tpublic upCast<TThis extends TInterface>(this: TThis): TInterface {\n\t\treturn this;\n\t}\n}\n\n/**\n * The same as the built-in InstanceType, but works on classes with private constructors.\n * @privateRemarks\n * This is based on the trick in {@link https://stackoverflow.com/a/74657881}.\n * @internal\n */\nexport type InstanceTypeRelaxed<TClass> = InstanceType<(new () => never) & TClass>;\n"]}
|
|
1
|
+
{"version":3,"file":"erasedType.js","sourceRoot":"","sources":["../src/erasedType.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,MAAsB,UAAU;IAU/B;;OAEG;IACH,gBAAuB,CAAC;IAExB;;;;OAIG;IACI,MAAM,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,KAAY;QAC9C,MAAM,IAAI,KAAK,CACd,yGAAyG,CACzG,CAAC;IACH,CAAC;CACD;AAzBD,gCAyBC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAsB,cAAc;IAUnC;;;;;;OAMG;IACH,gBAAyB,CAAC;CAC1B;AAlBD,wCAkBC;AAED;;;;;;;;;GASG;AACH,MAAsB,wBAEpB,SAAQ,cAA4E;IAKrF;QACC,KAAK,EAAE,CAAC;IACT,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAEjC,KAAc;QAEd,OAAO,CACN,OAAO,KAAK,KAAK,QAAQ;YACzB,KAAK,KAAK,IAAI;YACd,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAC1D,CAAC;IACH,CAAC;IAED;;;;;;;;;OASG;IACI,MAAM,CAAC,MAAM,CAEnB,KAAkD;QAElD,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,KAAe,CAAC,EAAE,CAAC;YAC/E,MAAM,IAAI,SAAS,CAAC,iCAAiC,CAAC,CAAC;QACxD,CAAC;IACF,CAAC;IAED;;;;OAIG;IACI,MAAM;QACZ,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AApDD,4DAoDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Erased type which can be used to expose a opaque/erased version of a type without referencing the actual type.\n * @remarks\n * This similar to the {@link https://en.wikipedia.org/wiki/Type_erasure | type erasure} pattern,\n * but for erasing types at the package boundary.\n *\n * This can be used to implement the TypeScript typing for the {@link https://en.wikipedia.org/wiki/Handle_(computing) | handle} pattern,\n * allowing code outside of a package to have a reference/handle to something in the package in a type safe way without the package having to publicly export the types of the object.\n * This should not be confused with the more specific IFluidHandle which is also named after this design pattern.\n *\n * Recommended usage is to use `interface` instead of `type` so tooling (such as tsc and refactoring tools)\n * uses the type name instead of expanding it.\n *\n * @example\n * ```typescript\n * // public sealed type\n * export interface ErasedMyType extends ErasedType<\"myPackage.MyType\"> {}\n * // internal type\n * export interface MyType {\n * \texample: number;\n * }\n * // Usage\n * function extract(input: ErasedMyType): MyType {\n * \treturn input as unknown as MyType;\n * }\n * function erase(input: MyType): ErasedMyType {\n * \treturn input as unknown as ErasedMyType;\n * }\n * ```\n *\n * Do not use this class with `instanceof`: this will always be false at runtime,\n * but the compiler may think it's true in some cases.\n * @privateRemarks\n * For this pattern to work well it needs to be difficult for a user of the erased type to\n * implicitly use something other than a instance received from the package as an instance of the erased type in type safe code.\n *\n * This means that this type must not be able to be implicitly converted to from any strong type (not `any` or `never`),\n * and no amount of auto complete or auto-implement refactoring will produce something that can be used as an erased type.\n * This is accomplished by:\n *\n * 1. requiring that values of this type be an instance of this class.\n * Typescript does not enforce this requirement for class: only for classes with protected or private members, so such member is included.\n *\n * 2. making this class impossible to get an instance of.\n * This is done by having a private constructor.\n *\n * 3. ensuring different erased types also using this library can not be implicitly converted between each-other.\n * This is done by using the \"Name\" type parameter.\n * Note that just having the type parameter is not enough since the presence of type parameters has no impact on implicit conversion in TypeScript:\n * only the usages of the type parameter matter.\n *\n * @sealed\n * @public\n */\nexport abstract class ErasedType<out Name = unknown> {\n\t/**\n\t * Compile time only marker to make type checking more strict.\n\t * This method will not exist at runtime and accessing it is invalid.\n\t * @privateRemarks\n\t * `Name` is used as the return type of a method rather than a a simple readonly member as this allows types with two brands to be intersected without getting `never`.\n\t * The method takes in never to help emphasize that its not callable.\n\t */\n\tprotected abstract brand(dummy: never): Name;\n\n\t/**\n\t * This class should never exist at runtime, so make it un-constructable.\n\t */\n\tprivate constructor() {}\n\n\t/**\n\t * Since this class is a compile time only type brand, `instanceof` will never work with it.\n\t * This `Symbol.hasInstance` implementation ensures that `instanceof` will error if used,\n\t * and in TypeScript 5.3 and newer will produce a compile time error if used.\n\t */\n\tpublic static [Symbol.hasInstance](value: never): value is never {\n\t\tthrow new Error(\n\t\t\t\"ErasedType is a compile time type brand not a real class that can be used with `instanceof` at runtime.\",\n\t\t);\n\t}\n}\n\n/**\n * Used to mark a `@sealed` interface in a strongly typed way to prevent external implementations.\n * @remarks\n * This is an alternative to {@link ErasedType} which is more ergonomic to implement in the case where the implementation can extend `ErasedTypeImplementation`.\n *\n * Users of interfaces extending this should never refer to anything about this class:\n * migrating the type branding to another mechanism, like {@link ErasedType} should be considered a non-breaking change.\n * @privateRemarks\n * Implement interfaces which extend this by sub-classing {@link ErasedTypeImplementation}.\n *\n * This class should only be a `type` package export, preventing users from extending it directly.\n *\n * Since {@link ErasedTypeImplementation} is exported as `@internal`, this restricts implementations of the sealed interfaces to users of `@internal` APIs, which should be anything within this release group.\n * Any finer grained restrictions can be done as documentation, but not type enforced.\n * @sealed\n * @beta\n * @system\n */\nexport abstract class ErasedBaseType<out Name = unknown> {\n\t/**\n\t * Compile time only marker to make type checking more strict.\n\t * This method will not exist at runtime and accessing it is invalid.\n\t * @privateRemarks\n\t * `Name` is used as the return type of a method rather than a a simple readonly member as this allows types with two brands to be intersected without getting `never`.\n\t * The method takes in never to help emphasize that its not callable.\n\t */\n\tprotected abstract brand(dummy: never): Name;\n\n\t/**\n\t * This class should never exist at runtime, so make it un-constructable.\n\t * @privateRemarks\n\t * From an API perspective, private would be preferred here.\n\t * However protected is almost as good since this class is not package exported,\n\t * and it allows ErasedTypeImplementation to extend this class.\n\t */\n\tprotected constructor() {}\n}\n\n/**\n * An implementation of an {@link ErasedBaseType}.\n * For a given erased type interface, there should be exactly one implementation of it, and it must be defined by the same code which defined the interface.\n *\n * @typeParam TInterface - The erased type interface this class implements.\n * @remarks\n * {@link ErasedBaseType} is package exported only as a type, not a value, so the only way to subclass it is via this class.\n * This limitation help enforce the pattern that there is only one implementation of a given erased type interface.\n * @internal\n */\nexport abstract class ErasedTypeImplementation<\n\tTInterface extends ErasedBaseType,\n> extends ErasedBaseType<TInterface extends ErasedBaseType<infer Name> ? Name : never> {\n\tprotected readonly brand!: (\n\t\tdummy: never,\n\t) => TInterface extends ErasedBaseType<infer Name> ? Name : never;\n\n\tprotected constructor() {\n\t\tsuper();\n\t}\n\n\t/**\n\t * {@link https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates|Type predicate} for narrowing the internal implementation type via `instanceof`.\n\t */\n\tpublic static [Symbol.hasInstance]<TThis extends { prototype: object }>(\n\t\tthis: TThis,\n\t\tvalue: unknown,\n\t): value is InstanceTypeRelaxed<TThis> {\n\t\treturn (\n\t\t\ttypeof value === \"object\" &&\n\t\t\tvalue !== null &&\n\t\t\tObject.prototype.isPrototypeOf.call(this.prototype, value)\n\t\t);\n\t}\n\n\t/**\n\t * {@link https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#assertion-functions|Type assertion} which narrows from ErasedBaseType to the internal implementation type.\n\t * @remarks\n\t * This does a checked conversion, throwing a `TypeError` if invalid.\n\t *\n\t * It would be safer if this narrowed from `TInterface`, but that is not possible since type parameters can not be accessed in static methods.\n\t * Replacing `ErasedTypeImplementation` with a generic function which returns a non-generic class could be used to work around this limitation if desired.\n\t *\n\t * Derived classes can provide their own customized narrowing function with a more specific types if desired.\n\t */\n\tpublic static narrow<TThis extends { prototype: object }>(\n\t\tthis: TThis,\n\t\tvalue: ErasedBaseType | InstanceTypeRelaxed<TThis>,\n\t): asserts value is InstanceTypeRelaxed<TThis> {\n\t\tif (!ErasedTypeImplementation[Symbol.hasInstance].call(this, value as object)) {\n\t\t\tthrow new TypeError(\"Invalid ErasedBaseType instance\");\n\t\t}\n\t}\n\n\t/**\n\t * Upcasts the instance to the erased interface type.\n\t * @remarks\n\t * This is mainly useful when inferring the interface type is required.\n\t */\n\tpublic upCast<TThis extends TInterface>(this: TThis): TInterface {\n\t\treturn this;\n\t}\n}\n\n/**\n * The same as the built-in InstanceType, but works on classes with private constructors.\n * @privateRemarks\n * This is based on the trick in {@link https://stackoverflow.com/a/74657881}.\n * @internal\n */\nexport type InstanceTypeRelaxed<TClass> = InstanceType<(new () => never) & TClass>;\n"]}
|
package/dist/error.d.ts
CHANGED
|
@@ -110,4 +110,54 @@ export interface IThrottlingWarning extends IErrorBase {
|
|
|
110
110
|
readonly errorType: typeof FluidErrorTypes.throttlingError;
|
|
111
111
|
readonly retryAfterSeconds: number;
|
|
112
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* Symbol used to identify an error of type {@link ILayerIncompatibilityError}.
|
|
115
|
+
* @legacy @alpha
|
|
116
|
+
*/
|
|
117
|
+
export declare const layerIncompatibilityErrorSymbol: unique symbol;
|
|
118
|
+
/**
|
|
119
|
+
* Usage error indicating that two Fluid layers are incompatible. For instance, if the Loader layer is
|
|
120
|
+
* not compatible with the Runtime layer, the container will be disposed with this error.
|
|
121
|
+
* @legacy @alpha
|
|
122
|
+
*/
|
|
123
|
+
export interface ILayerIncompatibilityError extends IErrorBase {
|
|
124
|
+
/**
|
|
125
|
+
* {@inheritDoc IErrorBase.errorType}
|
|
126
|
+
*/
|
|
127
|
+
readonly errorType: typeof FluidErrorTypes.usageError;
|
|
128
|
+
/**
|
|
129
|
+
* Symbol used to identify this error as a layer incompatibility error.
|
|
130
|
+
*/
|
|
131
|
+
readonly [layerIncompatibilityErrorSymbol]: true;
|
|
132
|
+
/**
|
|
133
|
+
* The layer that is reporting the incompatibility.
|
|
134
|
+
*/
|
|
135
|
+
readonly layer: string;
|
|
136
|
+
/**
|
|
137
|
+
* The layer that is incompatible with the reporting layer.
|
|
138
|
+
*/
|
|
139
|
+
readonly incompatibleLayer: string;
|
|
140
|
+
/**
|
|
141
|
+
* The package version of the reporting layer.
|
|
142
|
+
*/
|
|
143
|
+
readonly layerVersion: string;
|
|
144
|
+
/**
|
|
145
|
+
* The package version of the incompatible layer.
|
|
146
|
+
*/
|
|
147
|
+
readonly incompatibleLayerVersion: string;
|
|
148
|
+
/**
|
|
149
|
+
* The number of months of compatibility requirements between the two layers as per the layer compatibility policy.
|
|
150
|
+
*/
|
|
151
|
+
readonly compatibilityRequirementsInMonths: number;
|
|
152
|
+
/**
|
|
153
|
+
* The minimum actual difference in months between the release of the two layers.
|
|
154
|
+
* Note that for layers with package versions older than 2.63.0, the actual difference may be higher than this value
|
|
155
|
+
* because the difference reported is capped as per 2.63.0 where the compatibility enforcement was introduced.
|
|
156
|
+
*/
|
|
157
|
+
readonly actualDifferenceInMonths: number;
|
|
158
|
+
/**
|
|
159
|
+
* Additional details about the incompatibility to be used for debugging purposes.
|
|
160
|
+
*/
|
|
161
|
+
readonly details: string;
|
|
162
|
+
}
|
|
113
163
|
//# sourceMappingURL=error.d.ts.map
|
package/dist/error.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAE5D;;;GAGG;AACH,eAAO,MAAM,eAAe;IAC3B;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;CAEM,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,OAAO,eAAe,CAAC,CAAC;AAErF;;;;;;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;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B;;OAEG;IACH,QAAQ,CAAC,wBAAwB,EAAE,MAAM,CAAC;IAC1C;;OAEG;IACH,QAAQ,CAAC,iCAAiC,EAAE,MAAM,CAAC;IACnD;;;;OAIG;IACH,QAAQ,CAAC,wBAAwB,EAAE,MAAM,CAAC;IAC1C;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CACzB"}
|
package/dist/error.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.FluidErrorTypes = void 0;
|
|
7
|
+
exports.layerIncompatibilityErrorSymbol = exports.FluidErrorTypes = void 0;
|
|
8
8
|
/**
|
|
9
9
|
* Error types the Fluid Framework may report.
|
|
10
10
|
* @legacy @beta
|
|
@@ -31,4 +31,9 @@ exports.FluidErrorTypes = {
|
|
|
31
31
|
*/
|
|
32
32
|
usageError: "usageError",
|
|
33
33
|
};
|
|
34
|
+
/**
|
|
35
|
+
* Symbol used to identify an error of type {@link ILayerIncompatibilityError}.
|
|
36
|
+
* @legacy @alpha
|
|
37
|
+
*/
|
|
38
|
+
exports.layerIncompatibilityErrorSymbol = Symbol("LayerIncompatibilityError");
|
|
34
39
|
//# sourceMappingURL=error.js.map
|
package/dist/error.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH;;;GAGG;AACU,QAAA,eAAe,GAAG;IAC9B;;OAEG;IACH,YAAY,EAAE,cAAc;IAE5B;;OAEG;IACH,eAAe,EAAE,iBAAiB;IAElC;;OAEG;IACH,mBAAmB,EAAE,qBAAqB;IAE1C;;OAEG;IACH,mBAAmB,EAAE,qBAAqB;IAE1C;;OAEG;IACH,UAAU,EAAE,YAAY;CACf,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryBaseProperties } from \"./logger.js\";\n\n/**\n * Error types the Fluid Framework may report.\n * @legacy @beta\n */\nexport const FluidErrorTypes = {\n\t/**\n\t * Some error, most likely an exception caught by runtime and propagated to container as critical error\n\t */\n\tgenericError: \"genericError\",\n\n\t/**\n\t * Throttling error from server. Server is busy and is asking not to reconnect for some time\n\t */\n\tthrottlingError: \"throttlingError\",\n\n\t/**\n\t * Data loss error detected by Container / DeltaManager. Likely points to storage issue.\n\t */\n\tdataCorruptionError: \"dataCorruptionError\",\n\n\t/**\n\t * Error encountered when processing an operation. May correlate with data corruption.\n\t */\n\tdataProcessingError: \"dataProcessingError\",\n\n\t/**\n\t * Error indicating an API is being used improperly resulting in an invalid operation.\n\t */\n\tusageError: \"usageError\",\n} as const;\n\n/**\n * @legacy @beta\n */\nexport type FluidErrorTypes = (typeof FluidErrorTypes)[keyof typeof FluidErrorTypes];\n\n/**\n * Base interface for all errors and warnings emitted the container.\n *\n * @remarks\n *\n * We are in the process of unifying error types across layers of the Framework. For now we have only migrated\n * those from container-definitions. Once fully migrated, this will be a base interface for all errors and\n * warnings emitted by the Fluid Framework. Currently only the container layer is using IErrorBase.\n * Runtime and others will follow soon.\n * @public\n */\nexport interface IErrorBase extends Partial<Error> {\n\t/**\n\t * A type tag differentiating kinds of errors emitted by the container.\n\t *\n\t * @see See {@link FluidErrorTypes#genericError} for some common examples.\n\t * - container\n\t * - runtime\n\t * - drivers\n\t */\n\treadonly errorType: string;\n\n\t/**\n\t * See {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error | Error.message}\n\t *\n\t * @remarks\n\t *\n\t * Privacy Note - This is a freeform string that we may not control in all cases (e.g. a dependency throws an error)\n\t * If there are known cases where this contains privacy-sensitive data it will be tagged and included in the result\n\t * of getTelemetryProperties. When logging, consider fetching it that way rather than straight from this field.\n\t */\n\treadonly message: string;\n\n\t/**\n\t * See {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/name | Error.name}\n\t */\n\treadonly name?: string;\n\n\t/**\n\t * See {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stack | Error.stack}\n\t */\n\treadonly stack?: string;\n\n\t/**\n\t * Returns all properties of this error object that are fit for logging.\n\t * Some may be tagged to indicate they contain some kind of sensitive data.\n\t */\n\tgetTelemetryProperties?(): ITelemetryBaseProperties;\n}\n\n/**\n * Generic wrapper for an unrecognized/uncategorized error object\n * @internal\n */\nexport interface IGenericError extends IErrorBase {\n\t/**\n\t * {@inheritDoc IErrorBase.errorType}\n\t */\n\treadonly errorType: typeof FluidErrorTypes.genericError;\n\n\t// TODO: Use `unknown` instead (API-Breaking)\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\terror?: any;\n}\n\n/**\n * Error indicating an API is being used improperly resulting in an invalid operation.\n * @internal\n */\nexport interface IUsageError extends IErrorBase {\n\t/**\n\t * {@inheritDoc IErrorBase.errorType}\n\t */\n\treadonly errorType: typeof FluidErrorTypes.usageError;\n}\n\n/**\n * Warning emitted when requests to storage are being throttled\n * @legacy @beta\n */\nexport interface IThrottlingWarning extends IErrorBase {\n\t/**\n\t * {@inheritDoc IErrorBase.errorType}\n\t */\n\treadonly errorType: typeof FluidErrorTypes.throttlingError;\n\treadonly retryAfterSeconds: number;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH;;;GAGG;AACU,QAAA,eAAe,GAAG;IAC9B;;OAEG;IACH,YAAY,EAAE,cAAc;IAE5B;;OAEG;IACH,eAAe,EAAE,iBAAiB;IAElC;;OAEG;IACH,mBAAmB,EAAE,qBAAqB;IAE1C;;OAEG;IACH,mBAAmB,EAAE,qBAAqB;IAE1C;;OAEG;IACH,UAAU,EAAE,YAAY;CACf,CAAC;AA+FX;;;GAGG;AACU,QAAA,+BAA+B,GAAkB,MAAM,CACnE,2BAA2B,CAC3B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryBaseProperties } from \"./logger.js\";\n\n/**\n * Error types the Fluid Framework may report.\n * @legacy @beta\n */\nexport const FluidErrorTypes = {\n\t/**\n\t * Some error, most likely an exception caught by runtime and propagated to container as critical error\n\t */\n\tgenericError: \"genericError\",\n\n\t/**\n\t * Throttling error from server. Server is busy and is asking not to reconnect for some time\n\t */\n\tthrottlingError: \"throttlingError\",\n\n\t/**\n\t * Data loss error detected by Container / DeltaManager. Likely points to storage issue.\n\t */\n\tdataCorruptionError: \"dataCorruptionError\",\n\n\t/**\n\t * Error encountered when processing an operation. May correlate with data corruption.\n\t */\n\tdataProcessingError: \"dataProcessingError\",\n\n\t/**\n\t * Error indicating an API is being used improperly resulting in an invalid operation.\n\t */\n\tusageError: \"usageError\",\n} as const;\n\n/**\n * @legacy @beta\n */\nexport type FluidErrorTypes = (typeof FluidErrorTypes)[keyof typeof FluidErrorTypes];\n\n/**\n * Base interface for all errors and warnings emitted the container.\n *\n * @remarks\n *\n * We are in the process of unifying error types across layers of the Framework. For now we have only migrated\n * those from container-definitions. Once fully migrated, this will be a base interface for all errors and\n * warnings emitted by the Fluid Framework. Currently only the container layer is using IErrorBase.\n * Runtime and others will follow soon.\n * @public\n */\nexport interface IErrorBase extends Partial<Error> {\n\t/**\n\t * A type tag differentiating kinds of errors emitted by the container.\n\t *\n\t * @see See {@link FluidErrorTypes#genericError} for some common examples.\n\t * - container\n\t * - runtime\n\t * - drivers\n\t */\n\treadonly errorType: string;\n\n\t/**\n\t * See {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error | Error.message}\n\t *\n\t * @remarks\n\t *\n\t * Privacy Note - This is a freeform string that we may not control in all cases (e.g. a dependency throws an error)\n\t * If there are known cases where this contains privacy-sensitive data it will be tagged and included in the result\n\t * of getTelemetryProperties. When logging, consider fetching it that way rather than straight from this field.\n\t */\n\treadonly message: string;\n\n\t/**\n\t * See {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/name | Error.name}\n\t */\n\treadonly name?: string;\n\n\t/**\n\t * See {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stack | Error.stack}\n\t */\n\treadonly stack?: string;\n\n\t/**\n\t * Returns all properties of this error object that are fit for logging.\n\t * Some may be tagged to indicate they contain some kind of sensitive data.\n\t */\n\tgetTelemetryProperties?(): ITelemetryBaseProperties;\n}\n\n/**\n * Generic wrapper for an unrecognized/uncategorized error object\n * @internal\n */\nexport interface IGenericError extends IErrorBase {\n\t/**\n\t * {@inheritDoc IErrorBase.errorType}\n\t */\n\treadonly errorType: typeof FluidErrorTypes.genericError;\n\n\t// TODO: Use `unknown` instead (API-Breaking)\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\terror?: any;\n}\n\n/**\n * Error indicating an API is being used improperly resulting in an invalid operation.\n * @internal\n */\nexport interface IUsageError extends IErrorBase {\n\t/**\n\t * {@inheritDoc IErrorBase.errorType}\n\t */\n\treadonly errorType: typeof FluidErrorTypes.usageError;\n}\n\n/**\n * Warning emitted when requests to storage are being throttled\n * @legacy @beta\n */\nexport interface IThrottlingWarning extends IErrorBase {\n\t/**\n\t * {@inheritDoc IErrorBase.errorType}\n\t */\n\treadonly errorType: typeof FluidErrorTypes.throttlingError;\n\treadonly retryAfterSeconds: number;\n}\n\n/**\n * Symbol used to identify an error of type {@link ILayerIncompatibilityError}.\n * @legacy @alpha\n */\nexport const layerIncompatibilityErrorSymbol: unique symbol = Symbol(\n\t\"LayerIncompatibilityError\",\n);\n\n/**\n * Usage error indicating that two Fluid layers are incompatible. For instance, if the Loader layer is\n * not compatible with the Runtime layer, the container will be disposed with this error.\n * @legacy @alpha\n */\nexport interface ILayerIncompatibilityError extends IErrorBase {\n\t/**\n\t * {@inheritDoc IErrorBase.errorType}\n\t */\n\treadonly errorType: typeof FluidErrorTypes.usageError;\n\n\t/**\n\t * Symbol used to identify this error as a layer incompatibility error.\n\t */\n\treadonly [layerIncompatibilityErrorSymbol]: true;\n\t/**\n\t * The layer that is reporting the incompatibility.\n\t */\n\treadonly layer: string;\n\t/**\n\t * The layer that is incompatible with the reporting layer.\n\t */\n\treadonly incompatibleLayer: string;\n\t/**\n\t * The package version of the reporting layer.\n\t */\n\treadonly layerVersion: string;\n\t/**\n\t * The package version of the incompatible layer.\n\t */\n\treadonly incompatibleLayerVersion: string;\n\t/**\n\t * The number of months of compatibility requirements between the two layers as per the layer compatibility policy.\n\t */\n\treadonly compatibilityRequirementsInMonths: number;\n\t/**\n\t * The minimum actual difference in months between the release of the two layers.\n\t * Note that for layers with package versions older than 2.63.0, the actual difference may be higher than this value\n\t * because the difference reported is capped as per 2.63.0 where the compatibility enforcement was introduced.\n\t */\n\treadonly actualDifferenceInMonths: number;\n\t/**\n\t * Additional details about the incompatibility to be used for debugging purposes.\n\t */\n\treadonly details: string;\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export type { BrandedType } from "./brandedType.js";
|
|
6
6
|
export type { IDisposable } from "./disposable.js";
|
|
7
|
-
export type { IErrorBase, IGenericError, IUsageError, IThrottlingWarning } from "./error.js";
|
|
7
|
+
export type { IErrorBase, IGenericError, IUsageError, IThrottlingWarning, ILayerIncompatibilityError, } from "./error.js";
|
|
8
|
+
export { layerIncompatibilityErrorSymbol } from "./error.js";
|
|
8
9
|
export { FluidErrorTypes } from "./error.js";
|
|
9
10
|
export type { ExtendEventProvider, IErrorEvent, IEvent, IEventProvider, IEventThisPlaceHolder, IEventTransformer, ReplaceIEventThisPlaceHolder, TransformedEvent, } from "./events.js";
|
|
10
11
|
export type { IProvideFluidLoadable, IProvideFluidRunnable } from "./fluidLoadable.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,YAAY,EACX,UAAU,EACV,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,0BAA0B,GAC1B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,+BAA+B,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,YAAY,EACX,mBAAmB,EACnB,WAAW,EACX,MAAM,EACN,cAAc,EACd,qBAAqB,EACrB,iBAAiB,EACjB,4BAA4B,EAC5B,gBAAgB,GAChB,MAAM,aAAa,CAAC;AAErB,YAAY,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AACvF,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAKpE,YAAY,EAAE,QAAQ,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE5E,YAAY,EACX,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,kCAAkC,EAClC,0BAA0B,EAC1B,iBAAiB,EACjB,uBAAuB,EACvB,mBAAmB,EACnB,0BAA0B,EAC1B,YAAY,GACZ,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEpF,YAAY,EACX,aAAa,EACb,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,EACxB,MAAM,EACN,8BAA8B,GAC9B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,YAAY,EAAE,uBAAuB,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC3F,YAAY,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACpE,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACnE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACvF,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAE3D,YAAY,EACX,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,SAAS,EACT,UAAU,EACV,SAAS,EACT,mBAAmB,EACnB,GAAG,GACH,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.ErasedTypeImplementation = exports.LogLevel = exports.fluidHandleSymbol = exports.IFluidHandle = exports.IFluidHandleContext = exports.IFluidRunnable = exports.IFluidLoadable = exports.FluidErrorTypes = void 0;
|
|
7
|
+
exports.ErasedTypeImplementation = exports.LogLevel = exports.fluidHandleSymbol = exports.IFluidHandle = exports.IFluidHandleContext = exports.IFluidRunnable = exports.IFluidLoadable = exports.FluidErrorTypes = exports.layerIncompatibilityErrorSymbol = void 0;
|
|
8
8
|
var error_js_1 = require("./error.js");
|
|
9
|
-
Object.defineProperty(exports, "
|
|
9
|
+
Object.defineProperty(exports, "layerIncompatibilityErrorSymbol", { enumerable: true, get: function () { return error_js_1.layerIncompatibilityErrorSymbol; } });
|
|
10
|
+
var error_js_2 = require("./error.js");
|
|
11
|
+
Object.defineProperty(exports, "FluidErrorTypes", { enumerable: true, get: function () { return error_js_2.FluidErrorTypes; } });
|
|
10
12
|
var fluidLoadable_js_1 = require("./fluidLoadable.js");
|
|
11
13
|
Object.defineProperty(exports, "IFluidLoadable", { enumerable: true, get: function () { return fluidLoadable_js_1.IFluidLoadable; } });
|
|
12
14
|
Object.defineProperty(exports, "IFluidRunnable", { enumerable: true, get: function () { return fluidLoadable_js_1.IFluidRunnable; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAaH,uCAA6D;AAApD,2HAAA,+BAA+B,OAAA;AACxC,uCAA6C;AAApC,2GAAA,eAAe,OAAA;AAcxB,uDAAoE;AAA3D,kHAAA,cAAc,OAAA;AAAE,kHAAA,cAAc,OAAA;AAmBvC,2CAAoF;AAA3E,iHAAA,mBAAmB,OAAA;AAAE,0GAAA,YAAY,OAAA;AAAE,+GAAA,iBAAiB,OAAA;AAU7D,yCAAuC;AAA9B,qGAAA,QAAQ,OAAA;AAKjB,iDAA2D;AAAlD,yHAAA,wBAAwB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport type { BrandedType } from \"./brandedType.js\";\n\nexport type { IDisposable } from \"./disposable.js\";\n\nexport type {\n\tIErrorBase,\n\tIGenericError,\n\tIUsageError,\n\tIThrottlingWarning,\n\tILayerIncompatibilityError,\n} from \"./error.js\";\nexport { layerIncompatibilityErrorSymbol } from \"./error.js\";\nexport { FluidErrorTypes } from \"./error.js\";\n\nexport type {\n\tExtendEventProvider,\n\tIErrorEvent,\n\tIEvent,\n\tIEventProvider,\n\tIEventThisPlaceHolder,\n\tIEventTransformer,\n\tReplaceIEventThisPlaceHolder,\n\tTransformedEvent,\n} from \"./events.js\";\n\nexport type { IProvideFluidLoadable, IProvideFluidRunnable } from \"./fluidLoadable.js\";\nexport { IFluidLoadable, IFluidRunnable } from \"./fluidLoadable.js\";\n\n// TypeScript forgets the index signature when customers augment IRequestHeader if we export *.\n// So we export the explicit members as a workaround:\n// https://github.com/microsoft/TypeScript/issues/18877#issuecomment-476921038\nexport type { IRequest, IRequestHeader, IResponse } from \"./fluidRouter.js\";\n\nexport type {\n\tIFluidHandleErased,\n\tIFluidHandleEvents,\n\tIFluidHandleInternal,\n\tIFluidHandleInternalPayloadPending,\n\tIFluidHandlePayloadPending,\n\tILocalFluidHandle,\n\tILocalFluidHandleEvents,\n\tIProvideFluidHandle,\n\tIProvideFluidHandleContext,\n\tPayloadState,\n} from \"./handles.js\";\nexport { IFluidHandleContext, IFluidHandle, fluidHandleSymbol } from \"./handles.js\";\n\nexport type {\n\tILoggingError,\n\tITelemetryBaseEvent,\n\tITelemetryBaseLogger,\n\tITelemetryBaseProperties,\n\tTagged,\n\tTelemetryBaseEventPropertyType,\n} from \"./logger.js\";\nexport { LogLevel } from \"./logger.js\";\nexport type { FluidObjectProviderKeys, FluidObject, FluidObjectKeys } from \"./provider.js\";\nexport type { ConfigTypes, IConfigProviderBase } from \"./config.js\";\nexport type { ISignalEnvelope, TypedMessage } from \"./messages.js\";\nexport type { ErasedType, ErasedBaseType, InstanceTypeRelaxed } from \"./erasedType.js\";\nexport { ErasedTypeImplementation } from \"./erasedType.js\";\n\nexport type {\n\tHasListeners,\n\tIEmitter,\n\tIsListener,\n\tListeners,\n\tListenable,\n\tMapGetSet,\n\tNoListenersCallback,\n\tOff,\n} from \"./events/index.js\";\n"]}
|
package/dist/legacy.d.ts
CHANGED
package/lib/erasedType.d.ts
CHANGED
|
@@ -88,10 +88,10 @@ export declare abstract class ErasedType<out Name = unknown> {
|
|
|
88
88
|
*
|
|
89
89
|
* This class should only be a `type` package export, preventing users from extending it directly.
|
|
90
90
|
*
|
|
91
|
-
* Since {@link ErasedTypeImplementation} is exported as `@internal`, this restricts implementations of the sealed interfaces to users of `@internal` APIs, which should be anything
|
|
91
|
+
* Since {@link ErasedTypeImplementation} is exported as `@internal`, this restricts implementations of the sealed interfaces to users of `@internal` APIs, which should be anything within this release group.
|
|
92
92
|
* Any finer grained restrictions can be done as documentation, but not type enforced.
|
|
93
93
|
* @sealed
|
|
94
|
-
* @
|
|
94
|
+
* @beta
|
|
95
95
|
* @system
|
|
96
96
|
*/
|
|
97
97
|
export declare abstract class ErasedBaseType<out Name = unknown> {
|
package/lib/erasedType.js
CHANGED
|
@@ -82,10 +82,10 @@ export class ErasedType {
|
|
|
82
82
|
*
|
|
83
83
|
* This class should only be a `type` package export, preventing users from extending it directly.
|
|
84
84
|
*
|
|
85
|
-
* Since {@link ErasedTypeImplementation} is exported as `@internal`, this restricts implementations of the sealed interfaces to users of `@internal` APIs, which should be anything
|
|
85
|
+
* Since {@link ErasedTypeImplementation} is exported as `@internal`, this restricts implementations of the sealed interfaces to users of `@internal` APIs, which should be anything within this release group.
|
|
86
86
|
* Any finer grained restrictions can be done as documentation, but not type enforced.
|
|
87
87
|
* @sealed
|
|
88
|
-
* @
|
|
88
|
+
* @beta
|
|
89
89
|
* @system
|
|
90
90
|
*/
|
|
91
91
|
export class ErasedBaseType {
|
package/lib/erasedType.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"erasedType.js","sourceRoot":"","sources":["../src/erasedType.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,MAAM,OAAgB,UAAU;IAU/B;;OAEG;IACH,gBAAuB,CAAC;IAExB;;;;OAIG;IACI,MAAM,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,KAAY;QAC9C,MAAM,IAAI,KAAK,CACd,yGAAyG,CACzG,CAAC;IACH,CAAC;CACD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAgB,cAAc;IAUnC;;;;;;OAMG;IACH,gBAAyB,CAAC;CAC1B;AAED;;;;;;;;;GASG;AACH,MAAM,OAAgB,wBAEpB,SAAQ,cAA4E;IAKrF;QACC,KAAK,EAAE,CAAC;IACT,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAEjC,KAAc;QAEd,OAAO,CACN,OAAO,KAAK,KAAK,QAAQ;YACzB,KAAK,KAAK,IAAI;YACd,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAC1D,CAAC;IACH,CAAC;IAED;;;;;;;;;OASG;IACI,MAAM,CAAC,MAAM,CAEnB,KAAkD;QAElD,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,KAAe,CAAC,EAAE,CAAC;YAC/E,MAAM,IAAI,SAAS,CAAC,iCAAiC,CAAC,CAAC;QACxD,CAAC;IACF,CAAC;IAED;;;;OAIG;IACI,MAAM;QACZ,OAAO,IAAI,CAAC;IACb,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Erased type which can be used to expose a opaque/erased version of a type without referencing the actual type.\n * @remarks\n * This similar to the {@link https://en.wikipedia.org/wiki/Type_erasure | type erasure} pattern,\n * but for erasing types at the package boundary.\n *\n * This can be used to implement the TypeScript typing for the {@link https://en.wikipedia.org/wiki/Handle_(computing) | handle} pattern,\n * allowing code outside of a package to have a reference/handle to something in the package in a type safe way without the package having to publicly export the types of the object.\n * This should not be confused with the more specific IFluidHandle which is also named after this design pattern.\n *\n * Recommended usage is to use `interface` instead of `type` so tooling (such as tsc and refactoring tools)\n * uses the type name instead of expanding it.\n *\n * @example\n * ```typescript\n * // public sealed type\n * export interface ErasedMyType extends ErasedType<\"myPackage.MyType\"> {}\n * // internal type\n * export interface MyType {\n * \texample: number;\n * }\n * // Usage\n * function extract(input: ErasedMyType): MyType {\n * \treturn input as unknown as MyType;\n * }\n * function erase(input: MyType): ErasedMyType {\n * \treturn input as unknown as ErasedMyType;\n * }\n * ```\n *\n * Do not use this class with `instanceof`: this will always be false at runtime,\n * but the compiler may think it's true in some cases.\n * @privateRemarks\n * For this pattern to work well it needs to be difficult for a user of the erased type to\n * implicitly use something other than a instance received from the package as an instance of the erased type in type safe code.\n *\n * This means that this type must not be able to be implicitly converted to from any strong type (not `any` or `never`),\n * and no amount of auto complete or auto-implement refactoring will produce something that can be used as an erased type.\n * This is accomplished by:\n *\n * 1. requiring that values of this type be an instance of this class.\n * Typescript does not enforce this requirement for class: only for classes with protected or private members, so such member is included.\n *\n * 2. making this class impossible to get an instance of.\n * This is done by having a private constructor.\n *\n * 3. ensuring different erased types also using this library can not be implicitly converted between each-other.\n * This is done by using the \"Name\" type parameter.\n * Note that just having the type parameter is not enough since the presence of type parameters has no impact on implicit conversion in TypeScript:\n * only the usages of the type parameter matter.\n *\n * @sealed\n * @public\n */\nexport abstract class ErasedType<out Name = unknown> {\n\t/**\n\t * Compile time only marker to make type checking more strict.\n\t * This method will not exist at runtime and accessing it is invalid.\n\t * @privateRemarks\n\t * `Name` is used as the return type of a method rather than a a simple readonly member as this allows types with two brands to be intersected without getting `never`.\n\t * The method takes in never to help emphasize that its not callable.\n\t */\n\tprotected abstract brand(dummy: never): Name;\n\n\t/**\n\t * This class should never exist at runtime, so make it un-constructable.\n\t */\n\tprivate constructor() {}\n\n\t/**\n\t * Since this class is a compile time only type brand, `instanceof` will never work with it.\n\t * This `Symbol.hasInstance` implementation ensures that `instanceof` will error if used,\n\t * and in TypeScript 5.3 and newer will produce a compile time error if used.\n\t */\n\tpublic static [Symbol.hasInstance](value: never): value is never {\n\t\tthrow new Error(\n\t\t\t\"ErasedType is a compile time type brand not a real class that can be used with `instanceof` at runtime.\",\n\t\t);\n\t}\n}\n\n/**\n * Used to mark a `@sealed` interface in a strongly typed way to prevent external implementations.\n * @remarks\n * This is an alternative to {@link ErasedType} which is more ergonomic to implement in the case where the implementation can extend `ErasedTypeImplementation`.\n *\n * Users of interfaces extending this should never refer to anything about this class:\n * migrating the type branding to another mechanism, like {@link ErasedType} should be considered a non-breaking change.\n * @privateRemarks\n * Implement interfaces which extend this by sub-classing {@link ErasedTypeImplementation}.\n *\n * This class should only be a `type` package export, preventing users from extending it directly.\n *\n * Since {@link ErasedTypeImplementation} is exported as `@internal`, this restricts implementations of the sealed interfaces to users of `@internal` APIs, which should be anything withing this release group.\n * Any finer grained restrictions can be done as documentation, but not type enforced.\n * @sealed\n * @alpha\n * @system\n */\nexport abstract class ErasedBaseType<out Name = unknown> {\n\t/**\n\t * Compile time only marker to make type checking more strict.\n\t * This method will not exist at runtime and accessing it is invalid.\n\t * @privateRemarks\n\t * `Name` is used as the return type of a method rather than a a simple readonly member as this allows types with two brands to be intersected without getting `never`.\n\t * The method takes in never to help emphasize that its not callable.\n\t */\n\tprotected abstract brand(dummy: never): Name;\n\n\t/**\n\t * This class should never exist at runtime, so make it un-constructable.\n\t * @privateRemarks\n\t * From an API perspective, private would be preferred here.\n\t * However protected is almost as good since this class is not package exported,\n\t * and it allows ErasedTypeImplementation to extend this class.\n\t */\n\tprotected constructor() {}\n}\n\n/**\n * An implementation of an {@link ErasedBaseType}.\n * For a given erased type interface, there should be exactly one implementation of it, and it must be defined by the same code which defined the interface.\n *\n * @typeParam TInterface - The erased type interface this class implements.\n * @remarks\n * {@link ErasedBaseType} is package exported only as a type, not a value, so the only way to subclass it is via this class.\n * This limitation help enforce the pattern that there is only one implementation of a given erased type interface.\n * @internal\n */\nexport abstract class ErasedTypeImplementation<\n\tTInterface extends ErasedBaseType,\n> extends ErasedBaseType<TInterface extends ErasedBaseType<infer Name> ? Name : never> {\n\tprotected readonly brand!: (\n\t\tdummy: never,\n\t) => TInterface extends ErasedBaseType<infer Name> ? Name : never;\n\n\tprotected constructor() {\n\t\tsuper();\n\t}\n\n\t/**\n\t * {@link https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates|Type predicate} for narrowing the internal implementation type via `instanceof`.\n\t */\n\tpublic static [Symbol.hasInstance]<TThis extends { prototype: object }>(\n\t\tthis: TThis,\n\t\tvalue: unknown,\n\t): value is InstanceTypeRelaxed<TThis> {\n\t\treturn (\n\t\t\ttypeof value === \"object\" &&\n\t\t\tvalue !== null &&\n\t\t\tObject.prototype.isPrototypeOf.call(this.prototype, value)\n\t\t);\n\t}\n\n\t/**\n\t * {@link https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#assertion-functions|Type assertion} which narrows from ErasedBaseType to the internal implementation type.\n\t * @remarks\n\t * This does a checked conversion, throwing a `TypeError` if invalid.\n\t *\n\t * It would be safer if this narrowed from `TInterface`, but that is not possible since type parameters can not be accessed in static methods.\n\t * Replacing `ErasedTypeImplementation` with a generic function which returns a non-generic class could be used to work around this limitation if desired.\n\t *\n\t * Derived classes can provide their own customized narrowing function with a more specific types if desired.\n\t */\n\tpublic static narrow<TThis extends { prototype: object }>(\n\t\tthis: TThis,\n\t\tvalue: ErasedBaseType | InstanceTypeRelaxed<TThis>,\n\t): asserts value is InstanceTypeRelaxed<TThis> {\n\t\tif (!ErasedTypeImplementation[Symbol.hasInstance].call(this, value as object)) {\n\t\t\tthrow new TypeError(\"Invalid ErasedBaseType instance\");\n\t\t}\n\t}\n\n\t/**\n\t * Upcasts the instance to the erased interface type.\n\t * @remarks\n\t * This is mainly useful when inferring the interface type is required.\n\t */\n\tpublic upCast<TThis extends TInterface>(this: TThis): TInterface {\n\t\treturn this;\n\t}\n}\n\n/**\n * The same as the built-in InstanceType, but works on classes with private constructors.\n * @privateRemarks\n * This is based on the trick in {@link https://stackoverflow.com/a/74657881}.\n * @internal\n */\nexport type InstanceTypeRelaxed<TClass> = InstanceType<(new () => never) & TClass>;\n"]}
|
|
1
|
+
{"version":3,"file":"erasedType.js","sourceRoot":"","sources":["../src/erasedType.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,MAAM,OAAgB,UAAU;IAU/B;;OAEG;IACH,gBAAuB,CAAC;IAExB;;;;OAIG;IACI,MAAM,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,KAAY;QAC9C,MAAM,IAAI,KAAK,CACd,yGAAyG,CACzG,CAAC;IACH,CAAC;CACD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAgB,cAAc;IAUnC;;;;;;OAMG;IACH,gBAAyB,CAAC;CAC1B;AAED;;;;;;;;;GASG;AACH,MAAM,OAAgB,wBAEpB,SAAQ,cAA4E;IAKrF;QACC,KAAK,EAAE,CAAC;IACT,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAEjC,KAAc;QAEd,OAAO,CACN,OAAO,KAAK,KAAK,QAAQ;YACzB,KAAK,KAAK,IAAI;YACd,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAC1D,CAAC;IACH,CAAC;IAED;;;;;;;;;OASG;IACI,MAAM,CAAC,MAAM,CAEnB,KAAkD;QAElD,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,KAAe,CAAC,EAAE,CAAC;YAC/E,MAAM,IAAI,SAAS,CAAC,iCAAiC,CAAC,CAAC;QACxD,CAAC;IACF,CAAC;IAED;;;;OAIG;IACI,MAAM;QACZ,OAAO,IAAI,CAAC;IACb,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Erased type which can be used to expose a opaque/erased version of a type without referencing the actual type.\n * @remarks\n * This similar to the {@link https://en.wikipedia.org/wiki/Type_erasure | type erasure} pattern,\n * but for erasing types at the package boundary.\n *\n * This can be used to implement the TypeScript typing for the {@link https://en.wikipedia.org/wiki/Handle_(computing) | handle} pattern,\n * allowing code outside of a package to have a reference/handle to something in the package in a type safe way without the package having to publicly export the types of the object.\n * This should not be confused with the more specific IFluidHandle which is also named after this design pattern.\n *\n * Recommended usage is to use `interface` instead of `type` so tooling (such as tsc and refactoring tools)\n * uses the type name instead of expanding it.\n *\n * @example\n * ```typescript\n * // public sealed type\n * export interface ErasedMyType extends ErasedType<\"myPackage.MyType\"> {}\n * // internal type\n * export interface MyType {\n * \texample: number;\n * }\n * // Usage\n * function extract(input: ErasedMyType): MyType {\n * \treturn input as unknown as MyType;\n * }\n * function erase(input: MyType): ErasedMyType {\n * \treturn input as unknown as ErasedMyType;\n * }\n * ```\n *\n * Do not use this class with `instanceof`: this will always be false at runtime,\n * but the compiler may think it's true in some cases.\n * @privateRemarks\n * For this pattern to work well it needs to be difficult for a user of the erased type to\n * implicitly use something other than a instance received from the package as an instance of the erased type in type safe code.\n *\n * This means that this type must not be able to be implicitly converted to from any strong type (not `any` or `never`),\n * and no amount of auto complete or auto-implement refactoring will produce something that can be used as an erased type.\n * This is accomplished by:\n *\n * 1. requiring that values of this type be an instance of this class.\n * Typescript does not enforce this requirement for class: only for classes with protected or private members, so such member is included.\n *\n * 2. making this class impossible to get an instance of.\n * This is done by having a private constructor.\n *\n * 3. ensuring different erased types also using this library can not be implicitly converted between each-other.\n * This is done by using the \"Name\" type parameter.\n * Note that just having the type parameter is not enough since the presence of type parameters has no impact on implicit conversion in TypeScript:\n * only the usages of the type parameter matter.\n *\n * @sealed\n * @public\n */\nexport abstract class ErasedType<out Name = unknown> {\n\t/**\n\t * Compile time only marker to make type checking more strict.\n\t * This method will not exist at runtime and accessing it is invalid.\n\t * @privateRemarks\n\t * `Name` is used as the return type of a method rather than a a simple readonly member as this allows types with two brands to be intersected without getting `never`.\n\t * The method takes in never to help emphasize that its not callable.\n\t */\n\tprotected abstract brand(dummy: never): Name;\n\n\t/**\n\t * This class should never exist at runtime, so make it un-constructable.\n\t */\n\tprivate constructor() {}\n\n\t/**\n\t * Since this class is a compile time only type brand, `instanceof` will never work with it.\n\t * This `Symbol.hasInstance` implementation ensures that `instanceof` will error if used,\n\t * and in TypeScript 5.3 and newer will produce a compile time error if used.\n\t */\n\tpublic static [Symbol.hasInstance](value: never): value is never {\n\t\tthrow new Error(\n\t\t\t\"ErasedType is a compile time type brand not a real class that can be used with `instanceof` at runtime.\",\n\t\t);\n\t}\n}\n\n/**\n * Used to mark a `@sealed` interface in a strongly typed way to prevent external implementations.\n * @remarks\n * This is an alternative to {@link ErasedType} which is more ergonomic to implement in the case where the implementation can extend `ErasedTypeImplementation`.\n *\n * Users of interfaces extending this should never refer to anything about this class:\n * migrating the type branding to another mechanism, like {@link ErasedType} should be considered a non-breaking change.\n * @privateRemarks\n * Implement interfaces which extend this by sub-classing {@link ErasedTypeImplementation}.\n *\n * This class should only be a `type` package export, preventing users from extending it directly.\n *\n * Since {@link ErasedTypeImplementation} is exported as `@internal`, this restricts implementations of the sealed interfaces to users of `@internal` APIs, which should be anything within this release group.\n * Any finer grained restrictions can be done as documentation, but not type enforced.\n * @sealed\n * @beta\n * @system\n */\nexport abstract class ErasedBaseType<out Name = unknown> {\n\t/**\n\t * Compile time only marker to make type checking more strict.\n\t * This method will not exist at runtime and accessing it is invalid.\n\t * @privateRemarks\n\t * `Name` is used as the return type of a method rather than a a simple readonly member as this allows types with two brands to be intersected without getting `never`.\n\t * The method takes in never to help emphasize that its not callable.\n\t */\n\tprotected abstract brand(dummy: never): Name;\n\n\t/**\n\t * This class should never exist at runtime, so make it un-constructable.\n\t * @privateRemarks\n\t * From an API perspective, private would be preferred here.\n\t * However protected is almost as good since this class is not package exported,\n\t * and it allows ErasedTypeImplementation to extend this class.\n\t */\n\tprotected constructor() {}\n}\n\n/**\n * An implementation of an {@link ErasedBaseType}.\n * For a given erased type interface, there should be exactly one implementation of it, and it must be defined by the same code which defined the interface.\n *\n * @typeParam TInterface - The erased type interface this class implements.\n * @remarks\n * {@link ErasedBaseType} is package exported only as a type, not a value, so the only way to subclass it is via this class.\n * This limitation help enforce the pattern that there is only one implementation of a given erased type interface.\n * @internal\n */\nexport abstract class ErasedTypeImplementation<\n\tTInterface extends ErasedBaseType,\n> extends ErasedBaseType<TInterface extends ErasedBaseType<infer Name> ? Name : never> {\n\tprotected readonly brand!: (\n\t\tdummy: never,\n\t) => TInterface extends ErasedBaseType<infer Name> ? Name : never;\n\n\tprotected constructor() {\n\t\tsuper();\n\t}\n\n\t/**\n\t * {@link https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates|Type predicate} for narrowing the internal implementation type via `instanceof`.\n\t */\n\tpublic static [Symbol.hasInstance]<TThis extends { prototype: object }>(\n\t\tthis: TThis,\n\t\tvalue: unknown,\n\t): value is InstanceTypeRelaxed<TThis> {\n\t\treturn (\n\t\t\ttypeof value === \"object\" &&\n\t\t\tvalue !== null &&\n\t\t\tObject.prototype.isPrototypeOf.call(this.prototype, value)\n\t\t);\n\t}\n\n\t/**\n\t * {@link https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#assertion-functions|Type assertion} which narrows from ErasedBaseType to the internal implementation type.\n\t * @remarks\n\t * This does a checked conversion, throwing a `TypeError` if invalid.\n\t *\n\t * It would be safer if this narrowed from `TInterface`, but that is not possible since type parameters can not be accessed in static methods.\n\t * Replacing `ErasedTypeImplementation` with a generic function which returns a non-generic class could be used to work around this limitation if desired.\n\t *\n\t * Derived classes can provide their own customized narrowing function with a more specific types if desired.\n\t */\n\tpublic static narrow<TThis extends { prototype: object }>(\n\t\tthis: TThis,\n\t\tvalue: ErasedBaseType | InstanceTypeRelaxed<TThis>,\n\t): asserts value is InstanceTypeRelaxed<TThis> {\n\t\tif (!ErasedTypeImplementation[Symbol.hasInstance].call(this, value as object)) {\n\t\t\tthrow new TypeError(\"Invalid ErasedBaseType instance\");\n\t\t}\n\t}\n\n\t/**\n\t * Upcasts the instance to the erased interface type.\n\t * @remarks\n\t * This is mainly useful when inferring the interface type is required.\n\t */\n\tpublic upCast<TThis extends TInterface>(this: TThis): TInterface {\n\t\treturn this;\n\t}\n}\n\n/**\n * The same as the built-in InstanceType, but works on classes with private constructors.\n * @privateRemarks\n * This is based on the trick in {@link https://stackoverflow.com/a/74657881}.\n * @internal\n */\nexport type InstanceTypeRelaxed<TClass> = InstanceType<(new () => never) & TClass>;\n"]}
|
package/lib/error.d.ts
CHANGED
|
@@ -110,4 +110,54 @@ export interface IThrottlingWarning extends IErrorBase {
|
|
|
110
110
|
readonly errorType: typeof FluidErrorTypes.throttlingError;
|
|
111
111
|
readonly retryAfterSeconds: number;
|
|
112
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* Symbol used to identify an error of type {@link ILayerIncompatibilityError}.
|
|
115
|
+
* @legacy @alpha
|
|
116
|
+
*/
|
|
117
|
+
export declare const layerIncompatibilityErrorSymbol: unique symbol;
|
|
118
|
+
/**
|
|
119
|
+
* Usage error indicating that two Fluid layers are incompatible. For instance, if the Loader layer is
|
|
120
|
+
* not compatible with the Runtime layer, the container will be disposed with this error.
|
|
121
|
+
* @legacy @alpha
|
|
122
|
+
*/
|
|
123
|
+
export interface ILayerIncompatibilityError extends IErrorBase {
|
|
124
|
+
/**
|
|
125
|
+
* {@inheritDoc IErrorBase.errorType}
|
|
126
|
+
*/
|
|
127
|
+
readonly errorType: typeof FluidErrorTypes.usageError;
|
|
128
|
+
/**
|
|
129
|
+
* Symbol used to identify this error as a layer incompatibility error.
|
|
130
|
+
*/
|
|
131
|
+
readonly [layerIncompatibilityErrorSymbol]: true;
|
|
132
|
+
/**
|
|
133
|
+
* The layer that is reporting the incompatibility.
|
|
134
|
+
*/
|
|
135
|
+
readonly layer: string;
|
|
136
|
+
/**
|
|
137
|
+
* The layer that is incompatible with the reporting layer.
|
|
138
|
+
*/
|
|
139
|
+
readonly incompatibleLayer: string;
|
|
140
|
+
/**
|
|
141
|
+
* The package version of the reporting layer.
|
|
142
|
+
*/
|
|
143
|
+
readonly layerVersion: string;
|
|
144
|
+
/**
|
|
145
|
+
* The package version of the incompatible layer.
|
|
146
|
+
*/
|
|
147
|
+
readonly incompatibleLayerVersion: string;
|
|
148
|
+
/**
|
|
149
|
+
* The number of months of compatibility requirements between the two layers as per the layer compatibility policy.
|
|
150
|
+
*/
|
|
151
|
+
readonly compatibilityRequirementsInMonths: number;
|
|
152
|
+
/**
|
|
153
|
+
* The minimum actual difference in months between the release of the two layers.
|
|
154
|
+
* Note that for layers with package versions older than 2.63.0, the actual difference may be higher than this value
|
|
155
|
+
* because the difference reported is capped as per 2.63.0 where the compatibility enforcement was introduced.
|
|
156
|
+
*/
|
|
157
|
+
readonly actualDifferenceInMonths: number;
|
|
158
|
+
/**
|
|
159
|
+
* Additional details about the incompatibility to be used for debugging purposes.
|
|
160
|
+
*/
|
|
161
|
+
readonly details: string;
|
|
162
|
+
}
|
|
113
163
|
//# sourceMappingURL=error.d.ts.map
|
package/lib/error.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAE5D;;;GAGG;AACH,eAAO,MAAM,eAAe;IAC3B;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;CAEM,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,OAAO,eAAe,CAAC,CAAC;AAErF;;;;;;;;;;GAUG;AACH,MAAM,WAAW,UAAW,SAAQ,OAAO,CAAC,KAAK,CAAC;IACjD;;;;;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,CAAC,wBAAwB,EAAE,MAAM,CAAC;IAC1C;;OAEG;IACH,QAAQ,CAAC,iCAAiC,EAAE,MAAM,CAAC;IACnD;;;;OAIG;IACH,QAAQ,CAAC,wBAAwB,EAAE,MAAM,CAAC;IAC1C;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CACzB"}
|
package/lib/error.js
CHANGED
|
@@ -28,4 +28,9 @@ export const FluidErrorTypes = {
|
|
|
28
28
|
*/
|
|
29
29
|
usageError: "usageError",
|
|
30
30
|
};
|
|
31
|
+
/**
|
|
32
|
+
* Symbol used to identify an error of type {@link ILayerIncompatibilityError}.
|
|
33
|
+
* @legacy @alpha
|
|
34
|
+
*/
|
|
35
|
+
export const layerIncompatibilityErrorSymbol = Symbol("LayerIncompatibilityError");
|
|
31
36
|
//# sourceMappingURL=error.js.map
|
package/lib/error.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC9B;;OAEG;IACH,YAAY,EAAE,cAAc;IAE5B;;OAEG;IACH,eAAe,EAAE,iBAAiB;IAElC;;OAEG;IACH,mBAAmB,EAAE,qBAAqB;IAE1C;;OAEG;IACH,mBAAmB,EAAE,qBAAqB;IAE1C;;OAEG;IACH,UAAU,EAAE,YAAY;CACf,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryBaseProperties } from \"./logger.js\";\n\n/**\n * Error types the Fluid Framework may report.\n * @legacy @beta\n */\nexport const FluidErrorTypes = {\n\t/**\n\t * Some error, most likely an exception caught by runtime and propagated to container as critical error\n\t */\n\tgenericError: \"genericError\",\n\n\t/**\n\t * Throttling error from server. Server is busy and is asking not to reconnect for some time\n\t */\n\tthrottlingError: \"throttlingError\",\n\n\t/**\n\t * Data loss error detected by Container / DeltaManager. Likely points to storage issue.\n\t */\n\tdataCorruptionError: \"dataCorruptionError\",\n\n\t/**\n\t * Error encountered when processing an operation. May correlate with data corruption.\n\t */\n\tdataProcessingError: \"dataProcessingError\",\n\n\t/**\n\t * Error indicating an API is being used improperly resulting in an invalid operation.\n\t */\n\tusageError: \"usageError\",\n} as const;\n\n/**\n * @legacy @beta\n */\nexport type FluidErrorTypes = (typeof FluidErrorTypes)[keyof typeof FluidErrorTypes];\n\n/**\n * Base interface for all errors and warnings emitted the container.\n *\n * @remarks\n *\n * We are in the process of unifying error types across layers of the Framework. For now we have only migrated\n * those from container-definitions. Once fully migrated, this will be a base interface for all errors and\n * warnings emitted by the Fluid Framework. Currently only the container layer is using IErrorBase.\n * Runtime and others will follow soon.\n * @public\n */\nexport interface IErrorBase extends Partial<Error> {\n\t/**\n\t * A type tag differentiating kinds of errors emitted by the container.\n\t *\n\t * @see See {@link FluidErrorTypes#genericError} for some common examples.\n\t * - container\n\t * - runtime\n\t * - drivers\n\t */\n\treadonly errorType: string;\n\n\t/**\n\t * See {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error | Error.message}\n\t *\n\t * @remarks\n\t *\n\t * Privacy Note - This is a freeform string that we may not control in all cases (e.g. a dependency throws an error)\n\t * If there are known cases where this contains privacy-sensitive data it will be tagged and included in the result\n\t * of getTelemetryProperties. When logging, consider fetching it that way rather than straight from this field.\n\t */\n\treadonly message: string;\n\n\t/**\n\t * See {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/name | Error.name}\n\t */\n\treadonly name?: string;\n\n\t/**\n\t * See {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stack | Error.stack}\n\t */\n\treadonly stack?: string;\n\n\t/**\n\t * Returns all properties of this error object that are fit for logging.\n\t * Some may be tagged to indicate they contain some kind of sensitive data.\n\t */\n\tgetTelemetryProperties?(): ITelemetryBaseProperties;\n}\n\n/**\n * Generic wrapper for an unrecognized/uncategorized error object\n * @internal\n */\nexport interface IGenericError extends IErrorBase {\n\t/**\n\t * {@inheritDoc IErrorBase.errorType}\n\t */\n\treadonly errorType: typeof FluidErrorTypes.genericError;\n\n\t// TODO: Use `unknown` instead (API-Breaking)\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\terror?: any;\n}\n\n/**\n * Error indicating an API is being used improperly resulting in an invalid operation.\n * @internal\n */\nexport interface IUsageError extends IErrorBase {\n\t/**\n\t * {@inheritDoc IErrorBase.errorType}\n\t */\n\treadonly errorType: typeof FluidErrorTypes.usageError;\n}\n\n/**\n * Warning emitted when requests to storage are being throttled\n * @legacy @beta\n */\nexport interface IThrottlingWarning extends IErrorBase {\n\t/**\n\t * {@inheritDoc IErrorBase.errorType}\n\t */\n\treadonly errorType: typeof FluidErrorTypes.throttlingError;\n\treadonly retryAfterSeconds: number;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC9B;;OAEG;IACH,YAAY,EAAE,cAAc;IAE5B;;OAEG;IACH,eAAe,EAAE,iBAAiB;IAElC;;OAEG;IACH,mBAAmB,EAAE,qBAAqB;IAE1C;;OAEG;IACH,mBAAmB,EAAE,qBAAqB;IAE1C;;OAEG;IACH,UAAU,EAAE,YAAY;CACf,CAAC;AA+FX;;;GAGG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAkB,MAAM,CACnE,2BAA2B,CAC3B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryBaseProperties } from \"./logger.js\";\n\n/**\n * Error types the Fluid Framework may report.\n * @legacy @beta\n */\nexport const FluidErrorTypes = {\n\t/**\n\t * Some error, most likely an exception caught by runtime and propagated to container as critical error\n\t */\n\tgenericError: \"genericError\",\n\n\t/**\n\t * Throttling error from server. Server is busy and is asking not to reconnect for some time\n\t */\n\tthrottlingError: \"throttlingError\",\n\n\t/**\n\t * Data loss error detected by Container / DeltaManager. Likely points to storage issue.\n\t */\n\tdataCorruptionError: \"dataCorruptionError\",\n\n\t/**\n\t * Error encountered when processing an operation. May correlate with data corruption.\n\t */\n\tdataProcessingError: \"dataProcessingError\",\n\n\t/**\n\t * Error indicating an API is being used improperly resulting in an invalid operation.\n\t */\n\tusageError: \"usageError\",\n} as const;\n\n/**\n * @legacy @beta\n */\nexport type FluidErrorTypes = (typeof FluidErrorTypes)[keyof typeof FluidErrorTypes];\n\n/**\n * Base interface for all errors and warnings emitted the container.\n *\n * @remarks\n *\n * We are in the process of unifying error types across layers of the Framework. For now we have only migrated\n * those from container-definitions. Once fully migrated, this will be a base interface for all errors and\n * warnings emitted by the Fluid Framework. Currently only the container layer is using IErrorBase.\n * Runtime and others will follow soon.\n * @public\n */\nexport interface IErrorBase extends Partial<Error> {\n\t/**\n\t * A type tag differentiating kinds of errors emitted by the container.\n\t *\n\t * @see See {@link FluidErrorTypes#genericError} for some common examples.\n\t * - container\n\t * - runtime\n\t * - drivers\n\t */\n\treadonly errorType: string;\n\n\t/**\n\t * See {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error | Error.message}\n\t *\n\t * @remarks\n\t *\n\t * Privacy Note - This is a freeform string that we may not control in all cases (e.g. a dependency throws an error)\n\t * If there are known cases where this contains privacy-sensitive data it will be tagged and included in the result\n\t * of getTelemetryProperties. When logging, consider fetching it that way rather than straight from this field.\n\t */\n\treadonly message: string;\n\n\t/**\n\t * See {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/name | Error.name}\n\t */\n\treadonly name?: string;\n\n\t/**\n\t * See {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stack | Error.stack}\n\t */\n\treadonly stack?: string;\n\n\t/**\n\t * Returns all properties of this error object that are fit for logging.\n\t * Some may be tagged to indicate they contain some kind of sensitive data.\n\t */\n\tgetTelemetryProperties?(): ITelemetryBaseProperties;\n}\n\n/**\n * Generic wrapper for an unrecognized/uncategorized error object\n * @internal\n */\nexport interface IGenericError extends IErrorBase {\n\t/**\n\t * {@inheritDoc IErrorBase.errorType}\n\t */\n\treadonly errorType: typeof FluidErrorTypes.genericError;\n\n\t// TODO: Use `unknown` instead (API-Breaking)\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\terror?: any;\n}\n\n/**\n * Error indicating an API is being used improperly resulting in an invalid operation.\n * @internal\n */\nexport interface IUsageError extends IErrorBase {\n\t/**\n\t * {@inheritDoc IErrorBase.errorType}\n\t */\n\treadonly errorType: typeof FluidErrorTypes.usageError;\n}\n\n/**\n * Warning emitted when requests to storage are being throttled\n * @legacy @beta\n */\nexport interface IThrottlingWarning extends IErrorBase {\n\t/**\n\t * {@inheritDoc IErrorBase.errorType}\n\t */\n\treadonly errorType: typeof FluidErrorTypes.throttlingError;\n\treadonly retryAfterSeconds: number;\n}\n\n/**\n * Symbol used to identify an error of type {@link ILayerIncompatibilityError}.\n * @legacy @alpha\n */\nexport const layerIncompatibilityErrorSymbol: unique symbol = Symbol(\n\t\"LayerIncompatibilityError\",\n);\n\n/**\n * Usage error indicating that two Fluid layers are incompatible. For instance, if the Loader layer is\n * not compatible with the Runtime layer, the container will be disposed with this error.\n * @legacy @alpha\n */\nexport interface ILayerIncompatibilityError extends IErrorBase {\n\t/**\n\t * {@inheritDoc IErrorBase.errorType}\n\t */\n\treadonly errorType: typeof FluidErrorTypes.usageError;\n\n\t/**\n\t * Symbol used to identify this error as a layer incompatibility error.\n\t */\n\treadonly [layerIncompatibilityErrorSymbol]: true;\n\t/**\n\t * The layer that is reporting the incompatibility.\n\t */\n\treadonly layer: string;\n\t/**\n\t * The layer that is incompatible with the reporting layer.\n\t */\n\treadonly incompatibleLayer: string;\n\t/**\n\t * The package version of the reporting layer.\n\t */\n\treadonly layerVersion: string;\n\t/**\n\t * The package version of the incompatible layer.\n\t */\n\treadonly incompatibleLayerVersion: string;\n\t/**\n\t * The number of months of compatibility requirements between the two layers as per the layer compatibility policy.\n\t */\n\treadonly compatibilityRequirementsInMonths: number;\n\t/**\n\t * The minimum actual difference in months between the release of the two layers.\n\t * Note that for layers with package versions older than 2.63.0, the actual difference may be higher than this value\n\t * because the difference reported is capped as per 2.63.0 where the compatibility enforcement was introduced.\n\t */\n\treadonly actualDifferenceInMonths: number;\n\t/**\n\t * Additional details about the incompatibility to be used for debugging purposes.\n\t */\n\treadonly details: string;\n}\n"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export type { BrandedType } from "./brandedType.js";
|
|
6
6
|
export type { IDisposable } from "./disposable.js";
|
|
7
|
-
export type { IErrorBase, IGenericError, IUsageError, IThrottlingWarning } from "./error.js";
|
|
7
|
+
export type { IErrorBase, IGenericError, IUsageError, IThrottlingWarning, ILayerIncompatibilityError, } from "./error.js";
|
|
8
|
+
export { layerIncompatibilityErrorSymbol } from "./error.js";
|
|
8
9
|
export { FluidErrorTypes } from "./error.js";
|
|
9
10
|
export type { ExtendEventProvider, IErrorEvent, IEvent, IEventProvider, IEventThisPlaceHolder, IEventTransformer, ReplaceIEventThisPlaceHolder, TransformedEvent, } from "./events.js";
|
|
10
11
|
export type { IProvideFluidLoadable, IProvideFluidRunnable } from "./fluidLoadable.js";
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/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M,aAAa,CAAC;AACpE,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACnE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACvF,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAE3D,YAAY,EACX,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,SAAS,EACT,UAAU,EACV,SAAS,EACT,mBAAmB,EACnB,GAAG,GACH,MAAM,mBAAmB,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
+
export { layerIncompatibilityErrorSymbol } from "./error.js";
|
|
5
6
|
export { FluidErrorTypes } from "./error.js";
|
|
6
7
|
export { IFluidLoadable, IFluidRunnable } from "./fluidLoadable.js";
|
|
7
8
|
export { IFluidHandleContext, IFluidHandle, fluidHandleSymbol } from "./handles.js";
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAaH,OAAO,EAAE,+BAA+B,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAc7C,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAmBpE,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAUpF,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAKvC,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport type { BrandedType } from \"./brandedType.js\";\n\nexport type { IDisposable } from \"./disposable.js\";\n\nexport type {\n\tIErrorBase,\n\tIGenericError,\n\tIUsageError,\n\tIThrottlingWarning,\n\tILayerIncompatibilityError,\n} from \"./error.js\";\nexport { layerIncompatibilityErrorSymbol } from \"./error.js\";\nexport { FluidErrorTypes } from \"./error.js\";\n\nexport type {\n\tExtendEventProvider,\n\tIErrorEvent,\n\tIEvent,\n\tIEventProvider,\n\tIEventThisPlaceHolder,\n\tIEventTransformer,\n\tReplaceIEventThisPlaceHolder,\n\tTransformedEvent,\n} from \"./events.js\";\n\nexport type { IProvideFluidLoadable, IProvideFluidRunnable } from \"./fluidLoadable.js\";\nexport { IFluidLoadable, IFluidRunnable } from \"./fluidLoadable.js\";\n\n// TypeScript forgets the index signature when customers augment IRequestHeader if we export *.\n// So we export the explicit members as a workaround:\n// https://github.com/microsoft/TypeScript/issues/18877#issuecomment-476921038\nexport type { IRequest, IRequestHeader, IResponse } from \"./fluidRouter.js\";\n\nexport type {\n\tIFluidHandleErased,\n\tIFluidHandleEvents,\n\tIFluidHandleInternal,\n\tIFluidHandleInternalPayloadPending,\n\tIFluidHandlePayloadPending,\n\tILocalFluidHandle,\n\tILocalFluidHandleEvents,\n\tIProvideFluidHandle,\n\tIProvideFluidHandleContext,\n\tPayloadState,\n} from \"./handles.js\";\nexport { IFluidHandleContext, IFluidHandle, fluidHandleSymbol } from \"./handles.js\";\n\nexport type {\n\tILoggingError,\n\tITelemetryBaseEvent,\n\tITelemetryBaseLogger,\n\tITelemetryBaseProperties,\n\tTagged,\n\tTelemetryBaseEventPropertyType,\n} from \"./logger.js\";\nexport { LogLevel } from \"./logger.js\";\nexport type { FluidObjectProviderKeys, FluidObject, FluidObjectKeys } from \"./provider.js\";\nexport type { ConfigTypes, IConfigProviderBase } from \"./config.js\";\nexport type { ISignalEnvelope, TypedMessage } from \"./messages.js\";\nexport type { ErasedType, ErasedBaseType, InstanceTypeRelaxed } from \"./erasedType.js\";\nexport { ErasedTypeImplementation } from \"./erasedType.js\";\n\nexport type {\n\tHasListeners,\n\tIEmitter,\n\tIsListener,\n\tListeners,\n\tListenable,\n\tMapGetSet,\n\tNoListenersCallback,\n\tOff,\n} from \"./events/index.js\";\n"]}
|
package/lib/legacy.d.ts
CHANGED
package/package.json
CHANGED
package/src/erasedType.ts
CHANGED
|
@@ -96,10 +96,10 @@ export abstract class ErasedType<out Name = unknown> {
|
|
|
96
96
|
*
|
|
97
97
|
* This class should only be a `type` package export, preventing users from extending it directly.
|
|
98
98
|
*
|
|
99
|
-
* Since {@link ErasedTypeImplementation} is exported as `@internal`, this restricts implementations of the sealed interfaces to users of `@internal` APIs, which should be anything
|
|
99
|
+
* Since {@link ErasedTypeImplementation} is exported as `@internal`, this restricts implementations of the sealed interfaces to users of `@internal` APIs, which should be anything within this release group.
|
|
100
100
|
* Any finer grained restrictions can be done as documentation, but not type enforced.
|
|
101
101
|
* @sealed
|
|
102
|
-
* @
|
|
102
|
+
* @beta
|
|
103
103
|
* @system
|
|
104
104
|
*/
|
|
105
105
|
export abstract class ErasedBaseType<out Name = unknown> {
|
package/src/error.ts
CHANGED
|
@@ -128,3 +128,58 @@ export interface IThrottlingWarning extends IErrorBase {
|
|
|
128
128
|
readonly errorType: typeof FluidErrorTypes.throttlingError;
|
|
129
129
|
readonly retryAfterSeconds: number;
|
|
130
130
|
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Symbol used to identify an error of type {@link ILayerIncompatibilityError}.
|
|
134
|
+
* @legacy @alpha
|
|
135
|
+
*/
|
|
136
|
+
export const layerIncompatibilityErrorSymbol: unique symbol = Symbol(
|
|
137
|
+
"LayerIncompatibilityError",
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Usage error indicating that two Fluid layers are incompatible. For instance, if the Loader layer is
|
|
142
|
+
* not compatible with the Runtime layer, the container will be disposed with this error.
|
|
143
|
+
* @legacy @alpha
|
|
144
|
+
*/
|
|
145
|
+
export interface ILayerIncompatibilityError extends IErrorBase {
|
|
146
|
+
/**
|
|
147
|
+
* {@inheritDoc IErrorBase.errorType}
|
|
148
|
+
*/
|
|
149
|
+
readonly errorType: typeof FluidErrorTypes.usageError;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Symbol used to identify this error as a layer incompatibility error.
|
|
153
|
+
*/
|
|
154
|
+
readonly [layerIncompatibilityErrorSymbol]: true;
|
|
155
|
+
/**
|
|
156
|
+
* The layer that is reporting the incompatibility.
|
|
157
|
+
*/
|
|
158
|
+
readonly layer: string;
|
|
159
|
+
/**
|
|
160
|
+
* The layer that is incompatible with the reporting layer.
|
|
161
|
+
*/
|
|
162
|
+
readonly incompatibleLayer: string;
|
|
163
|
+
/**
|
|
164
|
+
* The package version of the reporting layer.
|
|
165
|
+
*/
|
|
166
|
+
readonly layerVersion: string;
|
|
167
|
+
/**
|
|
168
|
+
* The package version of the incompatible layer.
|
|
169
|
+
*/
|
|
170
|
+
readonly incompatibleLayerVersion: string;
|
|
171
|
+
/**
|
|
172
|
+
* The number of months of compatibility requirements between the two layers as per the layer compatibility policy.
|
|
173
|
+
*/
|
|
174
|
+
readonly compatibilityRequirementsInMonths: number;
|
|
175
|
+
/**
|
|
176
|
+
* The minimum actual difference in months between the release of the two layers.
|
|
177
|
+
* Note that for layers with package versions older than 2.63.0, the actual difference may be higher than this value
|
|
178
|
+
* because the difference reported is capped as per 2.63.0 where the compatibility enforcement was introduced.
|
|
179
|
+
*/
|
|
180
|
+
readonly actualDifferenceInMonths: number;
|
|
181
|
+
/**
|
|
182
|
+
* Additional details about the incompatibility to be used for debugging purposes.
|
|
183
|
+
*/
|
|
184
|
+
readonly details: string;
|
|
185
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -7,7 +7,14 @@ export type { BrandedType } from "./brandedType.js";
|
|
|
7
7
|
|
|
8
8
|
export type { IDisposable } from "./disposable.js";
|
|
9
9
|
|
|
10
|
-
export type {
|
|
10
|
+
export type {
|
|
11
|
+
IErrorBase,
|
|
12
|
+
IGenericError,
|
|
13
|
+
IUsageError,
|
|
14
|
+
IThrottlingWarning,
|
|
15
|
+
ILayerIncompatibilityError,
|
|
16
|
+
} from "./error.js";
|
|
17
|
+
export { layerIncompatibilityErrorSymbol } from "./error.js";
|
|
11
18
|
export { FluidErrorTypes } from "./error.js";
|
|
12
19
|
|
|
13
20
|
export type {
|