@fluidframework/core-interfaces 0.40.0 → 0.42.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/.eslintrc.js +1 -1
  2. package/api-report/core-interfaces.api.md +47 -20
  3. package/dist/fluidLoadable.d.ts +15 -0
  4. package/dist/fluidLoadable.d.ts.map +1 -1
  5. package/dist/fluidLoadable.js +3 -0
  6. package/dist/fluidLoadable.js.map +1 -1
  7. package/dist/fluidObject.d.ts +36 -5
  8. package/dist/fluidObject.d.ts.map +1 -1
  9. package/dist/fluidObject.js +0 -1
  10. package/dist/fluidObject.js.map +1 -1
  11. package/dist/fluidPackage.d.ts +25 -0
  12. package/dist/fluidPackage.d.ts.map +1 -1
  13. package/dist/fluidPackage.js +10 -0
  14. package/dist/fluidPackage.js.map +1 -1
  15. package/dist/handles.d.ts +2 -1
  16. package/dist/handles.d.ts.map +1 -1
  17. package/dist/handles.js.map +1 -1
  18. package/dist/index.d.ts +1 -0
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +1 -0
  21. package/dist/index.js.map +1 -1
  22. package/dist/provider.d.ts +64 -0
  23. package/dist/provider.d.ts.map +1 -0
  24. package/dist/provider.js +7 -0
  25. package/dist/provider.js.map +1 -0
  26. package/dist/serializer.d.ts +10 -0
  27. package/dist/serializer.d.ts.map +1 -1
  28. package/dist/serializer.js +3 -0
  29. package/dist/serializer.js.map +1 -1
  30. package/lib/fluidLoadable.d.ts +15 -0
  31. package/lib/fluidLoadable.d.ts.map +1 -1
  32. package/lib/fluidLoadable.js +3 -0
  33. package/lib/fluidLoadable.js.map +1 -1
  34. package/lib/fluidObject.d.ts +36 -5
  35. package/lib/fluidObject.d.ts.map +1 -1
  36. package/lib/fluidObject.js +0 -1
  37. package/lib/fluidObject.js.map +1 -1
  38. package/lib/fluidPackage.d.ts +25 -0
  39. package/lib/fluidPackage.d.ts.map +1 -1
  40. package/lib/fluidPackage.js +10 -0
  41. package/lib/fluidPackage.js.map +1 -1
  42. package/lib/handles.d.ts +2 -1
  43. package/lib/handles.d.ts.map +1 -1
  44. package/lib/handles.js.map +1 -1
  45. package/lib/index.d.ts +1 -0
  46. package/lib/index.d.ts.map +1 -1
  47. package/lib/index.js +1 -0
  48. package/lib/index.js.map +1 -1
  49. package/lib/provider.d.ts +64 -0
  50. package/lib/provider.d.ts.map +1 -0
  51. package/lib/provider.js +6 -0
  52. package/lib/provider.js.map +1 -0
  53. package/lib/serializer.d.ts +10 -0
  54. package/lib/serializer.d.ts.map +1 -1
  55. package/lib/serializer.js +3 -0
  56. package/lib/serializer.js.map +1 -1
  57. package/lib/test/types/fluidObjectTypes.d.ts +2 -0
  58. package/lib/test/types/fluidObjectTypes.d.ts.map +1 -0
  59. package/lib/test/types/fluidObjectTypes.js +80 -0
  60. package/lib/test/types/fluidObjectTypes.js.map +1 -0
  61. package/lib/test/types/validate0.40.0.d.ts +2 -0
  62. package/lib/test/types/validate0.40.0.d.ts.map +1 -0
  63. package/lib/test/types/validate0.40.0.js +72 -0
  64. package/lib/test/types/validate0.40.0.js.map +1 -0
  65. package/lib/test/types/validate0.41.0.d.ts +2 -0
  66. package/lib/test/types/validate0.41.0.d.ts.map +1 -0
  67. package/lib/test/types/validate0.41.0.js +78 -0
  68. package/lib/test/types/validate0.41.0.js.map +1 -0
  69. package/package.json +19 -17
  70. package/src/fluidLoadable.ts +15 -0
  71. package/src/fluidObject.ts +39 -17
  72. package/src/fluidPackage.ts +25 -0
  73. package/src/handles.ts +3 -2
  74. package/src/index.ts +1 -0
  75. package/src/provider.ts +70 -0
  76. package/src/serializer.ts +10 -0
  77. package/tsconfig.json +3 -2
@@ -4,6 +4,8 @@
4
4
  */
5
5
 
6
6
  /**
7
+ * @deprecated in favor of {@link @fluidframework/container-definitions/fluidPackage.ts#IFluidPackageEnvironment}
8
+ * to have code loading modules in same package.
7
9
  * Specifies an environment on Fluid property of a IFluidPackage
8
10
  */
9
11
  export interface IFluidPackageEnvironment {
@@ -30,6 +32,8 @@ export interface IFluidPackageEnvironment {
30
32
  }
31
33
 
32
34
  /**
35
+ * @deprecated in favor of {@link @fluidframework/container-definitions/fluidPackage.ts#IFluidPackage}
36
+ * to have code loading modules in same package.
33
37
  * Fluid-specific properties expected on a package to be loaded by the code loader.
34
38
  * While compatible with the npm package format it is not necessary that that package is an
35
39
  * npm package:
@@ -59,6 +63,8 @@ export interface IFluidPackage {
59
63
  }
60
64
 
61
65
  /**
66
+ * @deprecated in favor of {@link @fluidframework/container-definitions/fluidPackage.ts#isFluidPackage}
67
+ * to have code loading modules in same package.
62
68
  * Check if the package.json defines a Fluid package
63
69
  * @param pkg - the package json data to check if it is a Fluid package.
64
70
  */
@@ -68,6 +74,8 @@ export const isFluidPackage = (pkg: any): pkg is Readonly<IFluidPackage> =>
68
74
  && typeof pkg?.fluid === "object";
69
75
 
70
76
  /**
77
+ * @deprecated in favor of {@link @fluidframework/container-definitions/fluidPackage.ts#IFluidCodeDetailsConfig}
78
+ * to have code loading modules in same package.
71
79
  * Package manager configuration. Provides a key value mapping of config values
72
80
  */
73
81
  export interface IFluidCodeDetailsConfig {
@@ -75,6 +83,8 @@ export interface IFluidCodeDetailsConfig {
75
83
  }
76
84
 
77
85
  /**
86
+ * @deprecated in favor of {@link @fluidframework/container-definitions/fluidPackage.ts#IFluidCodeDetails}
87
+ * to have code loading modules in same package.
78
88
  * Data structure used to describe the code to load on the Fluid document
79
89
  */
80
90
  export interface IFluidCodeDetails {
@@ -90,6 +100,10 @@ export interface IFluidCodeDetails {
90
100
  readonly config?: IFluidCodeDetailsConfig;
91
101
  }
92
102
 
103
+ /**
104
+ * @deprecated in favor of {@link @fluidframework/container-definitions/fluidPackage.ts#isFluidCodeDetails}
105
+ * to have code loading modules in same package
106
+ */
93
107
  export const isFluidCodeDetails = (details: unknown): details is Readonly<IFluidCodeDetails> =>{
94
108
  const maybeCodeDetails = details as Partial<IFluidCodeDetails> | undefined;
95
109
  return typeof maybeCodeDetails === "object"
@@ -97,13 +111,24 @@ export const isFluidCodeDetails = (details: unknown): details is Readonly<IFluid
97
111
  && (maybeCodeDetails?.config === undefined || typeof maybeCodeDetails?.config === "object");
98
112
  };
99
113
 
114
+ /**
115
+ * @deprecated in favor of {@link @fluidframework/container-definitions/fluidPackage.ts#IFluidCodeDetailsComparer}
116
+ * to have code loading modules in same package.
117
+ */
100
118
  export const IFluidCodeDetailsComparer: keyof IProvideFluidCodeDetailsComparer = "IFluidCodeDetailsComparer";
101
119
 
120
+ /**
121
+ * @deprecated in favor of
122
+ * {@link @fluidframework/container-definitions/fluidPackage.ts#IProvideFluidCodeDetailsComparer}
123
+ * to have code loading modules in same package.
124
+ */
102
125
  export interface IProvideFluidCodeDetailsComparer {
103
126
  readonly IFluidCodeDetailsComparer: IFluidCodeDetailsComparer ;
104
127
  }
105
128
 
106
129
  /**
130
+ * @deprecated in favor of {@link @fluidframework/container-definitions/fluidPackage.ts#IFluidCodeDetailsComparer}
131
+ * to have code loading modules in same package.
107
132
  * Provides capability to compare Fluid code details.
108
133
  */
109
134
  export interface IFluidCodeDetailsComparer extends IProvideFluidCodeDetailsComparer {
package/src/handles.ts CHANGED
@@ -6,6 +6,7 @@
6
6
  import { IRequest, IResponse } from "./fluidRouter";
7
7
  import { IFluidObject } from "./fluidObject";
8
8
  import { IFluidLoadable } from "./fluidLoadable";
9
+ import { FluidObject } from "./provider";
9
10
 
10
11
  export const IFluidHandleContext: keyof IProvideFluidHandleContext = "IFluidHandleContext";
11
12
 
@@ -51,8 +52,8 @@ export interface IProvideFluidHandle {
51
52
  * Handle to a shared FluidObject
52
53
  */
53
54
  export interface IFluidHandle<
54
- // REVIEW: Constrain `T` to `IFluidObject & IFluidLoadable`?
55
- T = IFluidObject & IFluidLoadable
55
+ // REVIEW: Constrain `T` to something? How do we support dds and datastores safely?
56
+ T = IFluidObject & FluidObject & IFluidLoadable
56
57
  > extends IProvideFluidHandle {
57
58
 
58
59
  /**
package/src/index.ts CHANGED
@@ -21,3 +21,4 @@ export {
21
21
  export * from "./handles";
22
22
  export * from "./serializer";
23
23
  export * from "./fluidPackage";
24
+ export * from "./provider";
@@ -0,0 +1,70 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ /**
7
+ * @internal
8
+ * This utility type is meant for internal use by @see FluidObject
9
+ * Produces a valid FluidObject key given a type and a property.
10
+ * A valid FluidObject key is a property that exists on the incoming type
11
+ * as well as on the type of the property itself. For example, IProvideFoo.IFoo.IFoo
12
+ * This aligns with the FluidObject pattern expected to be used with all FluidObjects.
13
+ * For example:
14
+ * ```
15
+ * interface IProvideFoo{
16
+ * IFoo: IFoo
17
+ * }
18
+ * interface IFoo extends IProvideFoo{
19
+ * foobar();
20
+ * }
21
+ * ```
22
+ * This pattern enables discovery, and delegation in a standard way which is central
23
+ * to FluidObject pattern
24
+ */
25
+ export type FluidObjectProviderKeys<T, TProp extends keyof T = keyof T> =
26
+ string extends TProp ? never : number extends TProp? never : // exclude indexers [key:string |number]: any
27
+ TProp extends keyof Exclude<T[TProp], undefined> // TProp is a property of T, and T[TProp]
28
+ ? TProp
29
+ :never;
30
+
31
+ /**
32
+ * This utility type take interface(s) that follow the FluidObject pattern, and produces
33
+ * a new type that can be used for inspection and discovery of those interfaces.
34
+ *
35
+ * It is meant to be used with types that are known to implement the FluidObject pattern.
36
+ * A common way to specify a type implements the FluidObject pattern is to expose it as a
37
+ * FluidObject without a generic argument.
38
+ *
39
+ * For example, if we have an interface like below
40
+ * ```
41
+ * interface IProvideFoo{
42
+ * IFoo: IFoo
43
+ * }
44
+ * interface IFoo extends IProvideFoo{
45
+ * foobar();
46
+ * }
47
+ * ```
48
+ *
49
+ * and a function that returns a FluidObject. You would do the following
50
+ *
51
+ * `const maybeFoo: FluidObject<IFoo> = getFluidObject()`;
52
+ *
53
+ * Either IFoo or IProvideFoo are valid generic arguments. In both case
54
+ * maybeFoo will be of type `{IFoo?: IFoo}`. If IFoo is not undefined,
55
+ * then the FluidObject provides IFoo, and it can be used.
56
+ *
57
+ * You can inspect multiple types via a intersection. For example:
58
+ * `FluidObject<IFoo & IBar>`
59
+ *
60
+ */
61
+ export type FluidObject<T = unknown> = Partial<Pick<T, FluidObjectProviderKeys<T>>>;
62
+
63
+ /**
64
+ * This utility type creates a type that is the union of all keys on the generic type
65
+ * which implement the FluidObject pattern. @see FluidObject
66
+ *
67
+ * For example `FluidObjectKeys<IFoo & IBar>` would result in `"IFoo" | "IBar"`
68
+ *
69
+ */
70
+ export type FluidObjectKeys<T> = keyof FluidObject<T>;
package/src/serializer.ts CHANGED
@@ -6,6 +6,7 @@ import { IFluidHandle } from "./handles";
6
6
 
7
7
  /**
8
8
  * JSON serialized form of an IFluidHandle
9
+ * @deprecated - Moved to fluidframework/shared-object-base package
9
10
  */
10
11
  export interface ISerializedHandle {
11
12
  // Marker to indicate to JSON.parse that the object is a Fluid handle
@@ -15,12 +16,21 @@ export interface ISerializedHandle {
15
16
  url: string;
16
17
  }
17
18
 
19
+ /**
20
+ * @deprecated - Moved to fluidframework/shared-object-base package
21
+ */
18
22
  export const IFluidSerializer: keyof IProvideFluidSerializer = "IFluidSerializer";
19
23
 
24
+ /**
25
+ * @deprecated - Moved to fluidframework/shared-object-base package
26
+ */
20
27
  export interface IProvideFluidSerializer {
21
28
  readonly IFluidSerializer: IFluidSerializer;
22
29
  }
23
30
 
31
+ /**
32
+ * @deprecated - Moved to fluidframework/shared-object-base package
33
+ */
24
34
  export interface IFluidSerializer extends IProvideFluidSerializer {
25
35
  /**
26
36
  * Given a mostly-plain object that may have handle objects embedded within, will return a fully-plain object
package/tsconfig.json CHANGED
@@ -2,7 +2,8 @@
2
2
  "extends": "@fluidframework/build-common/ts-common-config.json",
3
3
  "exclude": [
4
4
  "dist",
5
- "node_modules"
5
+ "node_modules",
6
+ "test-d"
6
7
  ],
7
8
  "compilerOptions": {
8
9
  "rootDir": "./src",
@@ -11,4 +12,4 @@
11
12
  "include": [
12
13
  "src/**/*"
13
14
  ]
14
- }
15
+ }