@fluidframework/odsp-client 2.101.1 → 2.102.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 CHANGED
@@ -1,5 +1,16 @@
1
1
  # @fluid-experimental/odsp-client
2
2
 
3
+ ## 2.102.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Service client createContainer/getContainer overloads taking CompatibilityMode are deprecated ([#27212](https://github.com/microsoft/FluidFramework/pull/27212)) [3e951b4abf](https://github.com/microsoft/FluidFramework/commit/3e951b4abfc61ea78a3e3e4a891e34e374c76efb)
8
+
9
+ The `createContainer` and `getContainer` overloads on `AzureClient`, `OdspClient`, and `TinyliciousClient` (plus `AzureClient.viewContainerVersion`) that accept a [`CompatibilityMode`](https://fluidframework.com/docs/api/fluid-static/compatibilitymode-typealias) (`"1"` / `"2"`) argument are now deprecated.
10
+ Pass a [`MinimumVersionForCollab`](https://fluidframework.com/docs/api/runtime-definitions/minimumversionforcollab-typealias) SemVer string instead — it specifies the minimum collaborating client version directly.
11
+
12
+ See [issue #23289](https://github.com/microsoft/FluidFramework/issues/23289) for migration details and removal tracking.
13
+
3
14
  ## 2.101.0
4
15
 
5
16
  Dependency updates only.
package/README.md CHANGED
@@ -104,7 +104,7 @@ const containerSchema = {
104
104
  ],
105
105
  };
106
106
  const odspClient = new OdspClient(clientProps);
107
- const { container, services } = await odspClient.createContainer(containerSchema);
107
+ const { container, services } = await odspClient.createContainer(containerSchema, "2.100.0");
108
108
 
109
109
  const itemId = await container.attach();
110
110
  ```
@@ -117,7 +117,7 @@ Using the `OdspClient` class the developer can create and get Fluid containers.
117
117
  import { OdspClient } from "@fluidframework/odsp-client";
118
118
 
119
119
  const odspClient = new OdspClient(props);
120
- const { container, services } = await odspClient.getContainer("_unique-itemId_", schema);
120
+ const { container, services } = await odspClient.getContainer("_unique-itemId_", schema, "2.100.0");
121
121
  ```
122
122
 
123
123
  ## Using initial objects
@@ -137,7 +137,7 @@ const schema = {
137
137
  };
138
138
 
139
139
  // Fetch back the container that had been created earlier with the same itemId and schema
140
- const { container, services } = await OdspClient.getContainer("_unique-itemId_", schema);
140
+ const { container, services } = await OdspClient.getContainer("_unique-itemId_", schema, "2.100.0");
141
141
 
142
142
  // Get our list of initial objects that we had defined in the schema. initialObjects here will have the same signature
143
143
  const initialObjects = container.initialObjects;
@@ -28,12 +28,20 @@ export interface IOdspTokenProvider {
28
28
  // @beta @sealed
29
29
  export class OdspClient {
30
30
  constructor(properties: OdspClientProps);
31
- // (undocumented)
31
+ createContainer<T extends ContainerSchema>(containerSchema: T, minVersionForCollab: Exclude<MinimumVersionForCollab, `1.${string}`>): Promise<{
32
+ container: IOdspFluidContainer<T>;
33
+ services: OdspContainerServices;
34
+ }>;
35
+ // @deprecated
32
36
  createContainer<T extends ContainerSchema>(containerSchema: T): Promise<{
33
37
  container: IOdspFluidContainer<T>;
34
38
  services: OdspContainerServices;
35
39
  }>;
36
- // (undocumented)
40
+ getContainer<T extends ContainerSchema>(id: string, containerSchema: T, minVersionForCollab: Exclude<MinimumVersionForCollab, `1.${string}`>): Promise<{
41
+ container: IOdspFluidContainer<T>;
42
+ services: OdspContainerServices;
43
+ }>;
44
+ // @deprecated
37
45
  getContainer<T extends ContainerSchema>(id: string, containerSchema: T): Promise<{
38
46
  container: IOdspFluidContainer<T>;
39
47
  services: OdspContainerServices;
@@ -28,12 +28,20 @@ export interface IOdspTokenProvider {
28
28
  // @beta @sealed
29
29
  export class OdspClient {
30
30
  constructor(properties: OdspClientProps);
31
- // (undocumented)
31
+ createContainer<T extends ContainerSchema>(containerSchema: T, minVersionForCollab: Exclude<MinimumVersionForCollab, `1.${string}`>): Promise<{
32
+ container: IOdspFluidContainer<T>;
33
+ services: OdspContainerServices;
34
+ }>;
35
+ // @deprecated
32
36
  createContainer<T extends ContainerSchema>(containerSchema: T): Promise<{
33
37
  container: IOdspFluidContainer<T>;
34
38
  services: OdspContainerServices;
35
39
  }>;
36
- // (undocumented)
40
+ getContainer<T extends ContainerSchema>(id: string, containerSchema: T, minVersionForCollab: Exclude<MinimumVersionForCollab, `1.${string}`>): Promise<{
41
+ container: IOdspFluidContainer<T>;
42
+ services: OdspContainerServices;
43
+ }>;
44
+ // @deprecated
37
45
  getContainer<T extends ContainerSchema>(id: string, containerSchema: T): Promise<{
38
46
  container: IOdspFluidContainer<T>;
39
47
  services: OdspContainerServices;
@@ -3,6 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import type { ContainerSchema } from "@fluidframework/fluid-static";
6
+ import type { MinimumVersionForCollab } from "@fluidframework/runtime-definitions";
6
7
  import type { OdspClientProps, OdspContainerServices as IOdspContainerServices, IOdspFluidContainer } from "./interfaces.js";
7
8
  /**
8
9
  * OdspClient provides the ability to have a Fluid object backed by the ODSP service within the context of Microsoft 365 (M365) tenants.
@@ -16,10 +17,50 @@ export declare class OdspClient {
16
17
  private readonly connectionConfig;
17
18
  private readonly logger;
18
19
  constructor(properties: OdspClientProps);
20
+ /**
21
+ * Creates a new detached container instance backed by ODSP.
22
+ * @param containerSchema - Container schema for the new container.
23
+ * @param minVersionForCollab - Minimum Fluid Framework version required for collaboration, as a
24
+ * `MinimumVersionForCollab` SemVer string (e.g. `"2.100.0"`). Prefer the current Fluid Framework
25
+ * version so the container opts into the latest defaults.
26
+ * @returns New detached container instance along with associated services.
27
+ */
28
+ createContainer<T extends ContainerSchema>(containerSchema: T, minVersionForCollab: Exclude<MinimumVersionForCollab, `1.${string}`>): Promise<{
29
+ container: IOdspFluidContainer<T>;
30
+ services: IOdspContainerServices;
31
+ }>;
32
+ /**
33
+ * Creates a new detached container instance backed by ODSP.
34
+ * @param containerSchema - Container schema for the new container.
35
+ * @returns New detached container instance along with associated services.
36
+ * @deprecated Pass a `MinimumVersionForCollab` SemVer string (e.g. `"2.0.0"`) as a second argument.
37
+ * The previous behavior was equivalent to passing `"2.0.0"`.
38
+ */
19
39
  createContainer<T extends ContainerSchema>(containerSchema: T): Promise<{
20
40
  container: IOdspFluidContainer<T>;
21
41
  services: IOdspContainerServices;
22
42
  }>;
43
+ /**
44
+ * Accesses an existing container by its unique ID in ODSP.
45
+ * @param id - Unique ID of the container in ODSP.
46
+ * @param containerSchema - Container schema used to access data objects in the container.
47
+ * @param minVersionForCollab - Minimum Fluid Framework version required for collaboration, as a
48
+ * `MinimumVersionForCollab` SemVer string (e.g. `"2.100.0"`). Prefer the current Fluid Framework
49
+ * version so the container opts into the latest defaults.
50
+ * @returns Existing container instance along with associated services.
51
+ */
52
+ getContainer<T extends ContainerSchema>(id: string, containerSchema: T, minVersionForCollab: Exclude<MinimumVersionForCollab, `1.${string}`>): Promise<{
53
+ container: IOdspFluidContainer<T>;
54
+ services: IOdspContainerServices;
55
+ }>;
56
+ /**
57
+ * Accesses an existing container by its unique ID in ODSP.
58
+ * @param id - Unique ID of the container in ODSP.
59
+ * @param containerSchema - Container schema used to access data objects in the container.
60
+ * @returns Existing container instance along with associated services.
61
+ * @deprecated Pass a `MinimumVersionForCollab` SemVer string (e.g. `"2.0.0"`) as a third argument.
62
+ * The previous behavior was equivalent to passing `"2.0.0"`.
63
+ */
23
64
  getContainer<T extends ContainerSchema>(id: string, containerSchema: T): Promise<{
24
65
  container: IOdspFluidContainer<T>;
25
66
  services: IOdspContainerServices;
@@ -1 +1 @@
1
- {"version":3,"file":"odspClient.d.ts","sourceRoot":"","sources":["../src/odspClient.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAmBH,OAAO,KAAK,EAAwB,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAiB1F,OAAO,KAAK,EAEX,eAAe,EAGf,qBAAqB,IAAI,sBAAsB,EAC/C,mBAAmB,EACnB,MAAM,iBAAiB,CAAC;AA2CzB;;;;GAIG;AACH,qBAAa,UAAU;IACtB,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAA0B;IACjE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAwB;IACpD,OAAO,CAAC,QAAQ,CAAC,cAAc,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E,CAAC,EAElB,mBAAmB,EAAE,OAAO,CAAC,uBAAuB,EAAE,KAAK,MAAM,EAAE,CAAC,GAClE,OAAO,CAAC;QACV,SAAS,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC;QAClC,QAAQ,EAAE,sBAAsB,CAAC;KACjC,CAAC;IACF;;;;;;OAMG;IACU,eAAe,CAAC,CAAC,SAAS,eAAe,EACrD,eAAe,EAAE,CAAC,GAChB,OAAO,CAAC;QACV,SAAS,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC;QAClC,QAAQ,EAAE,sBAAsB,CAAC;KACjC,CAAC;IA4BF;;;;;;;;OAQG;IACU,YAAY,CAAC,CAAC,SAAS,eAAe,EAClD,EAAE,EAAE,MAAM,EACV,eAAe,EAAE,CAAC,EAClB,mBAAmB,EAAE,OAAO,CAAC,uBAAuB,EAAE,KAAK,MAAM,EAAE,CAAC,GAClE,OAAO,CAAC;QACV,SAAS,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC;QAClC,QAAQ,EAAE,sBAAsB,CAAC;KACjC,CAAC;IACF;;;;;;;OAOG;IACU,YAAY,CAAC,CAAC,SAAS,eAAe,EAClD,EAAE,EAAE,MAAM,EACV,eAAe,EAAE,CAAC,GAChB,OAAO,CAAC;QACV,SAAS,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC;QAClC,QAAQ,EAAE,sBAAsB,CAAC;KACjC,CAAC;IA4BF,OAAO,CAAC,cAAc;YAoCR,oBAAoB;YA0CpB,oBAAoB;CAGlC"}
@@ -48,8 +48,8 @@ class OdspClient {
48
48
  this.urlResolver = new internal_3.OdspDriverUrlResolver();
49
49
  this.configProvider = wrapConfigProvider(properties.configProvider);
50
50
  }
51
- async createContainer(containerSchema) {
52
- const loaderProps = this.getLoaderProps(containerSchema);
51
+ async createContainer(containerSchema, minVersionForCollab = "2.0.0") {
52
+ const loaderProps = this.getLoaderProps(containerSchema, minVersionForCollab);
53
53
  const container = await (0, internal_1.createDetachedContainer)({
54
54
  ...loaderProps,
55
55
  codeDetails: {
@@ -61,8 +61,8 @@ class OdspClient {
61
61
  const services = await this.getContainerServices(container);
62
62
  return { container: fluidContainer, services };
63
63
  }
64
- async getContainer(id, containerSchema) {
65
- const loaderProps = this.getLoaderProps(containerSchema);
64
+ async getContainer(id, containerSchema, minVersionForCollab = "2.0.0") {
65
+ const loaderProps = this.getLoaderProps(containerSchema, minVersionForCollab);
66
66
  const url = (0, internal_3.createOdspUrl)({
67
67
  siteUrl: this.connectionConfig.siteUrl,
68
68
  driveId: this.connectionConfig.driveId,
@@ -79,10 +79,10 @@ class OdspClient {
79
79
  const services = await this.getContainerServices(container);
80
80
  return { container: fluidContainer, services };
81
81
  }
82
- getLoaderProps(schema) {
82
+ getLoaderProps(schema, minVersionForCollaboration) {
83
83
  const runtimeFactory = (0, internal_2.createDOProviderContainerRuntimeFactory)({
84
84
  schema,
85
- compatibilityMode: "2",
85
+ minVersionForCollaboration,
86
86
  });
87
87
  const load = async () => {
88
88
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"odspClient.js","sourceRoot":"","sources":["../src/odspClient.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,iFAAoE;AAKpE,wEAImD;AASnD,oEAI+C;AAC/C,mEAM8C;AAE9C,uEAA0F;AAC1F,+BAAkC;AAUlC,yEAAmE;AAGnE,KAAK,UAAU,eAAe,CAC7B,OAAsC,EACtC,aAAiC;IAEjC,MAAM,aAAa,GAAkB,MAAM,aAAa,CAAC,iBAAiB,CACzE,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,OAAO,CACf,CAAC;IACF,OAAO,aAAa,CAAC;AACtB,CAAC;AAED,KAAK,UAAU,iBAAiB,CAC/B,OAAsC,EACtC,aAAiC;IAEjC,MAAM,aAAa,GAAkB,MAAM,aAAa,CAAC,mBAAmB,CAC3E,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,OAAO,CACf,CAAC;IACF,OAAO,aAAa,CAAC;AACtB,CAAC;AA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;QACF,MAAM,cAAc,GAAG,MAAM,IAAA,+BAAoB,EAAI,EAAE,SAAS,EAAE,CAAC,CAAC;QACpE,IAAI,CAAC,IAAA,mCAAwB,EAAC,cAAc,CAAC,EAAE,CAAC;YAC/C,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACpD,CAAC;QACD,cAAc,CAAC,MAAM,GAAG,MAAM,CAAC;QAC/B,OAAO,cAAc,CAAC;IACvB,CAAC;IAEO,KAAK,CAAC,oBAAoB,CAAC,SAAqB;QACvD,OAAO,IAAI,gDAAqB,CAAC,SAAS,CAAC,CAAC;IAC7C,CAAC;CACD;AArJD,gCAqJC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport type {\n\tIContainer,\n\tIFluidModuleWithDetails,\n} from \"@fluidframework/container-definitions/internal\";\nimport {\n\tcreateDetachedContainer,\n\tloadExistingContainer,\n\ttype ILoaderProps,\n} from \"@fluidframework/container-loader/internal\";\nimport type {\n\tIConfigProviderBase,\n\tIRequest,\n\tITelemetryBaseLogger,\n} from \"@fluidframework/core-interfaces\";\nimport type { IClient } from \"@fluidframework/driver-definitions\";\nimport type { IDocumentServiceFactory } from \"@fluidframework/driver-definitions/internal\";\nimport type { ContainerAttachProps, ContainerSchema } from \"@fluidframework/fluid-static\";\nimport {\n\tcreateDOProviderContainerRuntimeFactory,\n\tcreateFluidContainer,\n\tisInternalFluidContainer,\n} from \"@fluidframework/fluid-static/internal\";\nimport {\n\tOdspDocumentServiceFactory,\n\tOdspDriverUrlResolver,\n\tcreateOdspCreateContainerRequest,\n\tcreateOdspUrl,\n\tisOdspResolvedUrl,\n} from \"@fluidframework/odsp-driver/internal\";\nimport type { OdspResourceTokenFetchOptions } from \"@fluidframework/odsp-driver-definitions/internal\";\nimport { wrapConfigProviderWithDefaults } from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport type {\n\tTokenResponse,\n\tOdspClientProps,\n\tOdspConnectionConfig,\n\tOdspContainerAttachProps,\n\tOdspContainerServices as IOdspContainerServices,\n\tIOdspFluidContainer,\n} from \"./interfaces.js\";\nimport { OdspContainerServices } from \"./odspContainerServices.js\";\nimport type { IOdspTokenProvider } from \"./token.js\";\n\nasync function getStorageToken(\n\toptions: OdspResourceTokenFetchOptions,\n\ttokenProvider: IOdspTokenProvider,\n): Promise<TokenResponse> {\n\tconst tokenResponse: TokenResponse = await tokenProvider.fetchStorageToken(\n\t\toptions.siteUrl,\n\t\toptions.refresh,\n\t);\n\treturn tokenResponse;\n}\n\nasync function getWebsocketToken(\n\toptions: OdspResourceTokenFetchOptions,\n\ttokenProvider: IOdspTokenProvider,\n): Promise<TokenResponse> {\n\tconst tokenResponse: TokenResponse = await tokenProvider.fetchWebsocketToken(\n\t\toptions.siteUrl,\n\t\toptions.refresh,\n\t);\n\treturn tokenResponse;\n}\n\n/**\n * Default feature gates.\n * These values will only be used if the feature gate is not already set by the supplied config provider.\n */\nconst odspClientFeatureGates = {\n\t// None yet\n};\n\n/**\n * Wrap the config provider to fall back on the appropriate defaults for ODSP Client.\n * @param baseConfigProvider - The base config provider to wrap\n * @returns A new config provider with the appropriate defaults applied underneath the given provider\n */\nfunction wrapConfigProvider(baseConfigProvider?: IConfigProviderBase): IConfigProviderBase {\n\treturn wrapConfigProviderWithDefaults(baseConfigProvider, odspClientFeatureGates);\n}\n\n/**\n * OdspClient provides the ability to have a Fluid object backed by the ODSP service within the context of Microsoft 365 (M365) tenants.\n * @sealed\n * @beta\n */\nexport class OdspClient {\n\tprivate readonly documentServiceFactory: IDocumentServiceFactory;\n\tprivate readonly urlResolver: OdspDriverUrlResolver;\n\tprivate readonly configProvider: IConfigProviderBase | undefined;\n\tprivate readonly connectionConfig: OdspConnectionConfig;\n\tprivate readonly logger: ITelemetryBaseLogger | undefined;\n\n\tpublic constructor(properties: OdspClientProps) {\n\t\tthis.connectionConfig = properties.connection;\n\t\tthis.logger = properties.logger;\n\t\tthis.documentServiceFactory = new OdspDocumentServiceFactory(\n\t\t\tasync (options) => getStorageToken(options, this.connectionConfig.tokenProvider),\n\t\t\tasync (options) => getWebsocketToken(options, this.connectionConfig.tokenProvider),\n\t\t);\n\n\t\tthis.urlResolver = new OdspDriverUrlResolver();\n\t\tthis.configProvider = wrapConfigProvider(properties.configProvider);\n\t}\n\n\tpublic async createContainer<T extends ContainerSchema>(\n\t\tcontainerSchema: T,\n\t): Promise<{\n\t\tcontainer: IOdspFluidContainer<T>;\n\t\tservices: IOdspContainerServices;\n\t}> {\n\t\tconst loaderProps = this.getLoaderProps(containerSchema);\n\n\t\tconst container = await createDetachedContainer({\n\t\t\t...loaderProps,\n\t\t\tcodeDetails: {\n\t\t\t\tpackage: \"no-dynamic-package\",\n\t\t\t\tconfig: {},\n\t\t\t},\n\t\t});\n\n\t\tconst fluidContainer = await this.createFluidContainer<T>(\n\t\t\tcontainer,\n\t\t\tthis.connectionConfig,\n\t\t);\n\n\t\tconst services = await this.getContainerServices(container);\n\n\t\treturn { container: fluidContainer, services };\n\t}\n\n\tpublic async getContainer<T extends ContainerSchema>(\n\t\tid: string,\n\t\tcontainerSchema: T,\n\t): Promise<{\n\t\tcontainer: IOdspFluidContainer<T>;\n\t\tservices: IOdspContainerServices;\n\t}> {\n\t\tconst loaderProps = this.getLoaderProps(containerSchema);\n\t\tconst url = createOdspUrl({\n\t\t\tsiteUrl: this.connectionConfig.siteUrl,\n\t\t\tdriveId: this.connectionConfig.driveId,\n\t\t\titemId: id,\n\t\t\tdataStorePath: \"\",\n\t\t});\n\t\tconst container = await loadExistingContainer({ ...loaderProps, request: { url } });\n\n\t\tconst fluidContainer = await createFluidContainer<T>({\n\t\t\tcontainer,\n\t\t});\n\t\tif (!isInternalFluidContainer(fluidContainer)) {\n\t\t\tthrow new Error(\"Fluid container is not internal\");\n\t\t}\n\t\tconst services = await this.getContainerServices(container);\n\t\treturn { container: fluidContainer, services };\n\t}\n\n\tprivate getLoaderProps(schema: ContainerSchema): ILoaderProps {\n\t\tconst runtimeFactory = createDOProviderContainerRuntimeFactory({\n\t\t\tschema,\n\t\t\tcompatibilityMode: \"2\",\n\t\t});\n\t\tconst load = async (): Promise<IFluidModuleWithDetails> => {\n\t\t\treturn {\n\t\t\t\tmodule: { fluidExport: runtimeFactory },\n\t\t\t\tdetails: { package: \"no-dynamic-package\", config: {} },\n\t\t\t};\n\t\t};\n\n\t\tconst codeLoader = { load };\n\t\tconst client: IClient = {\n\t\t\tdetails: {\n\t\t\t\tcapabilities: { interactive: true },\n\t\t\t},\n\t\t\tpermission: [],\n\t\t\tscopes: [],\n\t\t\tuser: { id: \"\" },\n\t\t\tmode: \"write\",\n\t\t};\n\n\t\treturn {\n\t\t\turlResolver: this.urlResolver,\n\t\t\tdocumentServiceFactory: this.documentServiceFactory,\n\t\t\tcodeLoader,\n\t\t\tlogger: this.logger,\n\t\t\toptions: { client },\n\t\t\tconfigProvider: this.configProvider,\n\t\t};\n\t}\n\n\tprivate async createFluidContainer<T extends ContainerSchema>(\n\t\tcontainer: IContainer,\n\t\tconnection: OdspConnectionConfig,\n\t): Promise<IOdspFluidContainer<T>> {\n\t\t/**\n\t\t * See {@link FluidContainer.attach}\n\t\t */\n\t\tconst attach = async (\n\t\t\todspProps?: ContainerAttachProps<OdspContainerAttachProps>,\n\t\t): Promise<string> => {\n\t\t\tconst createNewRequest: IRequest = createOdspCreateContainerRequest(\n\t\t\t\tconnection.siteUrl,\n\t\t\t\tconnection.driveId,\n\t\t\t\todspProps?.filePath ?? \"\",\n\t\t\t\todspProps?.fileName ?? uuid(),\n\t\t\t);\n\t\t\tif (container.attachState !== AttachState.Detached) {\n\t\t\t\tthrow new Error(\"Cannot attach container. Container is not in detached state\");\n\t\t\t}\n\t\t\tawait container.attach(createNewRequest);\n\n\t\t\tconst resolvedUrl = container.resolvedUrl;\n\n\t\t\tif (resolvedUrl === undefined || !isOdspResolvedUrl(resolvedUrl)) {\n\t\t\t\tthrow new Error(\"Resolved Url not available on attached container\");\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * A unique identifier for the file within the provided SharePoint Embedded container ID. When you attach a container,\n\t\t\t * a new `itemId` is created in the user's drive, which developers can use for various operations\n\t\t\t * like updating, renaming, moving the Fluid file, changing permissions, and more. `itemId` is used to load the container.\n\t\t\t */\n\t\t\treturn resolvedUrl.itemId;\n\t\t};\n\t\tconst fluidContainer = await createFluidContainer<T>({ container });\n\t\tif (!isInternalFluidContainer(fluidContainer)) {\n\t\t\tthrow new Error(\"Fluid container is not internal\");\n\t\t}\n\t\tfluidContainer.attach = attach;\n\t\treturn fluidContainer;\n\t}\n\n\tprivate async getContainerServices(container: IContainer): Promise<IOdspContainerServices> {\n\t\treturn new OdspContainerServices(container);\n\t}\n}\n"]}
1
+ {"version":3,"file":"odspClient.js","sourceRoot":"","sources":["../src/odspClient.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,iFAAoE;AAKpE,wEAImD;AASnD,oEAI+C;AAC/C,mEAM8C;AAG9C,uEAA0F;AAC1F,+BAAkC;AAUlC,yEAAmE;AAGnE,KAAK,UAAU,eAAe,CAC7B,OAAsC,EACtC,aAAiC;IAEjC,MAAM,aAAa,GAAkB,MAAM,aAAa,CAAC,iBAAiB,CACzE,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,OAAO,CACf,CAAC;IACF,OAAO,aAAa,CAAC;AACtB,CAAC;AAED,KAAK,UAAU,iBAAiB,CAC/B,OAAsC,EACtC,aAAiC;IAEjC,MAAM,aAAa,GAAkB,MAAM,aAAa,CAAC,mBAAmB,CAC3E,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,OAAO,CACf,CAAC;IACF,OAAO,aAAa,CAAC;AACtB,CAAC;AAED;;;GAGG;AACH,MAAM,sBAAsB,GAAG;AAC9B,WAAW;CACX,CAAC;AAEF;;;;GAIG;AACH,SAAS,kBAAkB,CAAC,kBAAwC;IACnE,OAAO,IAAA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,EAAE,SAAS,EAAE,CAAC,CAAC;QACpE,IAAI,CAAC,IAAA,mCAAwB,EAAC,cAAc,CAAC,EAAE,CAAC;YAC/C,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACpD,CAAC;QACD,cAAc,CAAC,MAAM,GAAG,MAAM,CAAC;QAC/B,OAAO,cAAc,CAAC;IACvB,CAAC;IAEO,KAAK,CAAC,oBAAoB,CAAC,SAAqB;QACvD,OAAO,IAAI,gDAAqB,CAAC,SAAS,CAAC,CAAC;IAC7C,CAAC;CACD;AAvND,gCAuNC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport type {\n\tIContainer,\n\tIFluidModuleWithDetails,\n} from \"@fluidframework/container-definitions/internal\";\nimport {\n\tcreateDetachedContainer,\n\tloadExistingContainer,\n\ttype ILoaderProps,\n} from \"@fluidframework/container-loader/internal\";\nimport type {\n\tIConfigProviderBase,\n\tIRequest,\n\tITelemetryBaseLogger,\n} from \"@fluidframework/core-interfaces\";\nimport type { IClient } from \"@fluidframework/driver-definitions\";\nimport type { IDocumentServiceFactory } from \"@fluidframework/driver-definitions/internal\";\nimport type { ContainerAttachProps, ContainerSchema } from \"@fluidframework/fluid-static\";\nimport {\n\tcreateDOProviderContainerRuntimeFactory,\n\tcreateFluidContainer,\n\tisInternalFluidContainer,\n} from \"@fluidframework/fluid-static/internal\";\nimport {\n\tOdspDocumentServiceFactory,\n\tOdspDriverUrlResolver,\n\tcreateOdspCreateContainerRequest,\n\tcreateOdspUrl,\n\tisOdspResolvedUrl,\n} from \"@fluidframework/odsp-driver/internal\";\nimport type { OdspResourceTokenFetchOptions } from \"@fluidframework/odsp-driver-definitions/internal\";\nimport type { MinimumVersionForCollab } from \"@fluidframework/runtime-definitions\";\nimport { wrapConfigProviderWithDefaults } from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport type {\n\tTokenResponse,\n\tOdspClientProps,\n\tOdspConnectionConfig,\n\tOdspContainerAttachProps,\n\tOdspContainerServices as IOdspContainerServices,\n\tIOdspFluidContainer,\n} from \"./interfaces.js\";\nimport { OdspContainerServices } from \"./odspContainerServices.js\";\nimport type { IOdspTokenProvider } from \"./token.js\";\n\nasync function getStorageToken(\n\toptions: OdspResourceTokenFetchOptions,\n\ttokenProvider: IOdspTokenProvider,\n): Promise<TokenResponse> {\n\tconst tokenResponse: TokenResponse = await tokenProvider.fetchStorageToken(\n\t\toptions.siteUrl,\n\t\toptions.refresh,\n\t);\n\treturn tokenResponse;\n}\n\nasync function getWebsocketToken(\n\toptions: OdspResourceTokenFetchOptions,\n\ttokenProvider: IOdspTokenProvider,\n): Promise<TokenResponse> {\n\tconst tokenResponse: TokenResponse = await tokenProvider.fetchWebsocketToken(\n\t\toptions.siteUrl,\n\t\toptions.refresh,\n\t);\n\treturn tokenResponse;\n}\n\n/**\n * Default feature gates.\n * These values will only be used if the feature gate is not already set by the supplied config provider.\n */\nconst odspClientFeatureGates = {\n\t// None yet\n};\n\n/**\n * Wrap the config provider to fall back on the appropriate defaults for ODSP Client.\n * @param baseConfigProvider - The base config provider to wrap\n * @returns A new config provider with the appropriate defaults applied underneath the given provider\n */\nfunction wrapConfigProvider(baseConfigProvider?: IConfigProviderBase): IConfigProviderBase {\n\treturn wrapConfigProviderWithDefaults(baseConfigProvider, odspClientFeatureGates);\n}\n\n/**\n * OdspClient provides the ability to have a Fluid object backed by the ODSP service within the context of Microsoft 365 (M365) tenants.\n * @sealed\n * @beta\n */\nexport class OdspClient {\n\tprivate readonly documentServiceFactory: IDocumentServiceFactory;\n\tprivate readonly urlResolver: OdspDriverUrlResolver;\n\tprivate readonly configProvider: IConfigProviderBase | undefined;\n\tprivate readonly connectionConfig: OdspConnectionConfig;\n\tprivate readonly logger: ITelemetryBaseLogger | undefined;\n\n\tpublic constructor(properties: OdspClientProps) {\n\t\tthis.connectionConfig = properties.connection;\n\t\tthis.logger = properties.logger;\n\t\tthis.documentServiceFactory = new OdspDocumentServiceFactory(\n\t\t\tasync (options) => getStorageToken(options, this.connectionConfig.tokenProvider),\n\t\t\tasync (options) => getWebsocketToken(options, this.connectionConfig.tokenProvider),\n\t\t);\n\n\t\tthis.urlResolver = new OdspDriverUrlResolver();\n\t\tthis.configProvider = wrapConfigProvider(properties.configProvider);\n\t}\n\n\t/**\n\t * Creates a new detached container instance backed by ODSP.\n\t * @param containerSchema - Container schema for the new container.\n\t * @param minVersionForCollab - Minimum Fluid Framework version required for collaboration, as a\n\t * `MinimumVersionForCollab` SemVer string (e.g. `\"2.100.0\"`). Prefer the current Fluid Framework\n\t * version so the container opts into the latest defaults.\n\t * @returns New detached container instance along with associated services.\n\t */\n\tpublic async createContainer<T extends ContainerSchema>(\n\t\tcontainerSchema: T,\n\t\t// OdspClient does not support 1.x clients, so we exclude it from the accepted `minVersionForCollab` values.\n\t\tminVersionForCollab: Exclude<MinimumVersionForCollab, `1.${string}`>,\n\t): Promise<{\n\t\tcontainer: IOdspFluidContainer<T>;\n\t\tservices: IOdspContainerServices;\n\t}>;\n\t/**\n\t * Creates a new detached container instance backed by ODSP.\n\t * @param containerSchema - Container schema for the new container.\n\t * @returns New detached container instance along with associated services.\n\t * @deprecated Pass a `MinimumVersionForCollab` SemVer string (e.g. `\"2.0.0\"`) as a second argument.\n\t * The previous behavior was equivalent to passing `\"2.0.0\"`.\n\t */\n\tpublic async createContainer<T extends ContainerSchema>(\n\t\tcontainerSchema: T,\n\t): Promise<{\n\t\tcontainer: IOdspFluidContainer<T>;\n\t\tservices: IOdspContainerServices;\n\t}>;\n\tpublic async createContainer<T extends ContainerSchema>(\n\t\tcontainerSchema: T,\n\t\tminVersionForCollab: Exclude<MinimumVersionForCollab, `1.${string}`> = \"2.0.0\",\n\t): Promise<{\n\t\tcontainer: IOdspFluidContainer<T>;\n\t\tservices: IOdspContainerServices;\n\t}> {\n\t\tconst loaderProps = this.getLoaderProps(containerSchema, minVersionForCollab);\n\n\t\tconst container = await createDetachedContainer({\n\t\t\t...loaderProps,\n\t\t\tcodeDetails: {\n\t\t\t\tpackage: \"no-dynamic-package\",\n\t\t\t\tconfig: {},\n\t\t\t},\n\t\t});\n\n\t\tconst fluidContainer = await this.createFluidContainer<T>(\n\t\t\tcontainer,\n\t\t\tthis.connectionConfig,\n\t\t);\n\n\t\tconst services = await this.getContainerServices(container);\n\n\t\treturn { container: fluidContainer, services };\n\t}\n\n\t/**\n\t * Accesses an existing container by its unique ID in ODSP.\n\t * @param id - Unique ID of the container in ODSP.\n\t * @param containerSchema - Container schema used to access data objects in the container.\n\t * @param minVersionForCollab - Minimum Fluid Framework version required for collaboration, as a\n\t * `MinimumVersionForCollab` SemVer string (e.g. `\"2.100.0\"`). Prefer the current Fluid Framework\n\t * version so the container opts into the latest defaults.\n\t * @returns Existing container instance along with associated services.\n\t */\n\tpublic async getContainer<T extends ContainerSchema>(\n\t\tid: string,\n\t\tcontainerSchema: T,\n\t\tminVersionForCollab: Exclude<MinimumVersionForCollab, `1.${string}`>,\n\t): Promise<{\n\t\tcontainer: IOdspFluidContainer<T>;\n\t\tservices: IOdspContainerServices;\n\t}>;\n\t/**\n\t * Accesses an existing container by its unique ID in ODSP.\n\t * @param id - Unique ID of the container in ODSP.\n\t * @param containerSchema - Container schema used to access data objects in the container.\n\t * @returns Existing container instance along with associated services.\n\t * @deprecated Pass a `MinimumVersionForCollab` SemVer string (e.g. `\"2.0.0\"`) as a third argument.\n\t * The previous behavior was equivalent to passing `\"2.0.0\"`.\n\t */\n\tpublic async getContainer<T extends ContainerSchema>(\n\t\tid: string,\n\t\tcontainerSchema: T,\n\t): Promise<{\n\t\tcontainer: IOdspFluidContainer<T>;\n\t\tservices: IOdspContainerServices;\n\t}>;\n\tpublic async getContainer<T extends ContainerSchema>(\n\t\tid: string,\n\t\tcontainerSchema: T,\n\t\tminVersionForCollab: Exclude<MinimumVersionForCollab, `1.${string}`> = \"2.0.0\",\n\t): Promise<{\n\t\tcontainer: IOdspFluidContainer<T>;\n\t\tservices: IOdspContainerServices;\n\t}> {\n\t\tconst loaderProps = this.getLoaderProps(containerSchema, minVersionForCollab);\n\t\tconst url = createOdspUrl({\n\t\t\tsiteUrl: this.connectionConfig.siteUrl,\n\t\t\tdriveId: this.connectionConfig.driveId,\n\t\t\titemId: id,\n\t\t\tdataStorePath: \"\",\n\t\t});\n\t\tconst container = await loadExistingContainer({ ...loaderProps, request: { url } });\n\n\t\tconst fluidContainer = await createFluidContainer<T>({\n\t\t\tcontainer,\n\t\t});\n\t\tif (!isInternalFluidContainer(fluidContainer)) {\n\t\t\tthrow new Error(\"Fluid container is not internal\");\n\t\t}\n\t\tconst services = await this.getContainerServices(container);\n\t\treturn { container: fluidContainer, services };\n\t}\n\n\tprivate getLoaderProps(\n\t\tschema: ContainerSchema,\n\t\tminVersionForCollaboration: Exclude<MinimumVersionForCollab, `1.${string}`>,\n\t): ILoaderProps {\n\t\tconst runtimeFactory = createDOProviderContainerRuntimeFactory({\n\t\t\tschema,\n\t\t\tminVersionForCollaboration,\n\t\t});\n\t\tconst load = async (): Promise<IFluidModuleWithDetails> => {\n\t\t\treturn {\n\t\t\t\tmodule: { fluidExport: runtimeFactory },\n\t\t\t\tdetails: { package: \"no-dynamic-package\", config: {} },\n\t\t\t};\n\t\t};\n\n\t\tconst codeLoader = { load };\n\t\tconst client: IClient = {\n\t\t\tdetails: {\n\t\t\t\tcapabilities: { interactive: true },\n\t\t\t},\n\t\t\tpermission: [],\n\t\t\tscopes: [],\n\t\t\tuser: { id: \"\" },\n\t\t\tmode: \"write\",\n\t\t};\n\n\t\treturn {\n\t\t\turlResolver: this.urlResolver,\n\t\t\tdocumentServiceFactory: this.documentServiceFactory,\n\t\t\tcodeLoader,\n\t\t\tlogger: this.logger,\n\t\t\toptions: { client },\n\t\t\tconfigProvider: this.configProvider,\n\t\t};\n\t}\n\n\tprivate async createFluidContainer<T extends ContainerSchema>(\n\t\tcontainer: IContainer,\n\t\tconnection: OdspConnectionConfig,\n\t): Promise<IOdspFluidContainer<T>> {\n\t\t/**\n\t\t * See {@link FluidContainer.attach}\n\t\t */\n\t\tconst attach = async (\n\t\t\todspProps?: ContainerAttachProps<OdspContainerAttachProps>,\n\t\t): Promise<string> => {\n\t\t\tconst createNewRequest: IRequest = createOdspCreateContainerRequest(\n\t\t\t\tconnection.siteUrl,\n\t\t\t\tconnection.driveId,\n\t\t\t\todspProps?.filePath ?? \"\",\n\t\t\t\todspProps?.fileName ?? uuid(),\n\t\t\t);\n\t\t\tif (container.attachState !== AttachState.Detached) {\n\t\t\t\tthrow new Error(\"Cannot attach container. Container is not in detached state\");\n\t\t\t}\n\t\t\tawait container.attach(createNewRequest);\n\n\t\t\tconst resolvedUrl = container.resolvedUrl;\n\n\t\t\tif (resolvedUrl === undefined || !isOdspResolvedUrl(resolvedUrl)) {\n\t\t\t\tthrow new Error(\"Resolved Url not available on attached container\");\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * A unique identifier for the file within the provided SharePoint Embedded container ID. When you attach a container,\n\t\t\t * a new `itemId` is created in the user's drive, which developers can use for various operations\n\t\t\t * like updating, renaming, moving the Fluid file, changing permissions, and more. `itemId` is used to load the container.\n\t\t\t */\n\t\t\treturn resolvedUrl.itemId;\n\t\t};\n\t\tconst fluidContainer = await createFluidContainer<T>({ container });\n\t\tif (!isInternalFluidContainer(fluidContainer)) {\n\t\t\tthrow new Error(\"Fluid container is not internal\");\n\t\t}\n\t\tfluidContainer.attach = attach;\n\t\treturn fluidContainer;\n\t}\n\n\tprivate async getContainerServices(container: IContainer): Promise<IOdspContainerServices> {\n\t\treturn new OdspContainerServices(container);\n\t}\n}\n"]}
@@ -3,6 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import type { ContainerSchema } from "@fluidframework/fluid-static";
6
+ import type { MinimumVersionForCollab } from "@fluidframework/runtime-definitions";
6
7
  import type { OdspClientProps, OdspContainerServices as IOdspContainerServices, IOdspFluidContainer } from "./interfaces.js";
7
8
  /**
8
9
  * OdspClient provides the ability to have a Fluid object backed by the ODSP service within the context of Microsoft 365 (M365) tenants.
@@ -16,10 +17,50 @@ export declare class OdspClient {
16
17
  private readonly connectionConfig;
17
18
  private readonly logger;
18
19
  constructor(properties: OdspClientProps);
20
+ /**
21
+ * Creates a new detached container instance backed by ODSP.
22
+ * @param containerSchema - Container schema for the new container.
23
+ * @param minVersionForCollab - Minimum Fluid Framework version required for collaboration, as a
24
+ * `MinimumVersionForCollab` SemVer string (e.g. `"2.100.0"`). Prefer the current Fluid Framework
25
+ * version so the container opts into the latest defaults.
26
+ * @returns New detached container instance along with associated services.
27
+ */
28
+ createContainer<T extends ContainerSchema>(containerSchema: T, minVersionForCollab: Exclude<MinimumVersionForCollab, `1.${string}`>): Promise<{
29
+ container: IOdspFluidContainer<T>;
30
+ services: IOdspContainerServices;
31
+ }>;
32
+ /**
33
+ * Creates a new detached container instance backed by ODSP.
34
+ * @param containerSchema - Container schema for the new container.
35
+ * @returns New detached container instance along with associated services.
36
+ * @deprecated Pass a `MinimumVersionForCollab` SemVer string (e.g. `"2.0.0"`) as a second argument.
37
+ * The previous behavior was equivalent to passing `"2.0.0"`.
38
+ */
19
39
  createContainer<T extends ContainerSchema>(containerSchema: T): Promise<{
20
40
  container: IOdspFluidContainer<T>;
21
41
  services: IOdspContainerServices;
22
42
  }>;
43
+ /**
44
+ * Accesses an existing container by its unique ID in ODSP.
45
+ * @param id - Unique ID of the container in ODSP.
46
+ * @param containerSchema - Container schema used to access data objects in the container.
47
+ * @param minVersionForCollab - Minimum Fluid Framework version required for collaboration, as a
48
+ * `MinimumVersionForCollab` SemVer string (e.g. `"2.100.0"`). Prefer the current Fluid Framework
49
+ * version so the container opts into the latest defaults.
50
+ * @returns Existing container instance along with associated services.
51
+ */
52
+ getContainer<T extends ContainerSchema>(id: string, containerSchema: T, minVersionForCollab: Exclude<MinimumVersionForCollab, `1.${string}`>): Promise<{
53
+ container: IOdspFluidContainer<T>;
54
+ services: IOdspContainerServices;
55
+ }>;
56
+ /**
57
+ * Accesses an existing container by its unique ID in ODSP.
58
+ * @param id - Unique ID of the container in ODSP.
59
+ * @param containerSchema - Container schema used to access data objects in the container.
60
+ * @returns Existing container instance along with associated services.
61
+ * @deprecated Pass a `MinimumVersionForCollab` SemVer string (e.g. `"2.0.0"`) as a third argument.
62
+ * The previous behavior was equivalent to passing `"2.0.0"`.
63
+ */
23
64
  getContainer<T extends ContainerSchema>(id: string, containerSchema: T): Promise<{
24
65
  container: IOdspFluidContainer<T>;
25
66
  services: IOdspContainerServices;
@@ -1 +1 @@
1
- {"version":3,"file":"odspClient.d.ts","sourceRoot":"","sources":["../src/odspClient.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAmBH,OAAO,KAAK,EAAwB,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAiB1F,OAAO,KAAK,EAEX,eAAe,EAGf,qBAAqB,IAAI,sBAAsB,EAC/C,mBAAmB,EACnB,MAAM,iBAAiB,CAAC;AA2CzB;;;;GAIG;AACH,qBAAa,UAAU;IACtB,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAA0B;IACjE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAwB;IACpD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAkC;IACjE,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAuB;IACxD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAmC;gBAEvC,UAAU,EAAE,eAAe;IAYjC,eAAe,CAAC,CAAC,SAAS,eAAe,EACrD,eAAe,EAAE,CAAC,GAChB,OAAO,CAAC;QACV,SAAS,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC;QAClC,QAAQ,EAAE,sBAAsB,CAAC;KACjC,CAAC;IAqBW,YAAY,CAAC,CAAC,SAAS,eAAe,EAClD,EAAE,EAAE,MAAM,EACV,eAAe,EAAE,CAAC,GAChB,OAAO,CAAC;QACV,SAAS,EAAE,mBAAmB,CAA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,eAAe,EAClD,EAAE,EAAE,MAAM,EACV,eAAe,EAAE,CAAC,EAClB,mBAAmB,EAAE,OAAO,CAAC,uBAAuB,EAAE,KAAK,MAAM,EAAE,CAAC,GAClE,OAAO,CAAC;QACV,SAAS,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC;QAClC,QAAQ,EAAE,sBAAsB,CAAC;KACjC,CAAC;IACF;;;;;;;OAOG;IACU,YAAY,CAAC,CAAC,SAAS,eAAe,EAClD,EAAE,EAAE,MAAM,EACV,eAAe,EAAE,CAAC,GAChB,OAAO,CAAC;QACV,SAAS,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC;QAClC,QAAQ,EAAE,sBAAsB,CAAC;KACjC,CAAC;IA4BF,OAAO,CAAC,cAAc;YAoCR,oBAAoB;YA0CpB,oBAAoB;CAGlC"}
package/lib/odspClient.js CHANGED
@@ -45,8 +45,8 @@ export class OdspClient {
45
45
  this.urlResolver = new OdspDriverUrlResolver();
46
46
  this.configProvider = wrapConfigProvider(properties.configProvider);
47
47
  }
48
- async createContainer(containerSchema) {
49
- const loaderProps = this.getLoaderProps(containerSchema);
48
+ async createContainer(containerSchema, minVersionForCollab = "2.0.0") {
49
+ const loaderProps = this.getLoaderProps(containerSchema, minVersionForCollab);
50
50
  const container = await createDetachedContainer({
51
51
  ...loaderProps,
52
52
  codeDetails: {
@@ -58,8 +58,8 @@ export class OdspClient {
58
58
  const services = await this.getContainerServices(container);
59
59
  return { container: fluidContainer, services };
60
60
  }
61
- async getContainer(id, containerSchema) {
62
- const loaderProps = this.getLoaderProps(containerSchema);
61
+ async getContainer(id, containerSchema, minVersionForCollab = "2.0.0") {
62
+ const loaderProps = this.getLoaderProps(containerSchema, minVersionForCollab);
63
63
  const url = createOdspUrl({
64
64
  siteUrl: this.connectionConfig.siteUrl,
65
65
  driveId: this.connectionConfig.driveId,
@@ -76,10 +76,10 @@ export class OdspClient {
76
76
  const services = await this.getContainerServices(container);
77
77
  return { container: fluidContainer, services };
78
78
  }
79
- getLoaderProps(schema) {
79
+ getLoaderProps(schema, minVersionForCollaboration) {
80
80
  const runtimeFactory = createDOProviderContainerRuntimeFactory({
81
81
  schema,
82
- compatibilityMode: "2",
82
+ minVersionForCollaboration,
83
83
  });
84
84
  const load = async () => {
85
85
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"odspClient.js","sourceRoot":"","sources":["../src/odspClient.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAKpE,OAAO,EACN,uBAAuB,EACvB,qBAAqB,GAErB,MAAM,2CAA2C,CAAC;AASnD,OAAO,EACN,uCAAuC,EACvC,oBAAoB,EACpB,wBAAwB,GACxB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACN,0BAA0B,EAC1B,qBAAqB,EACrB,gCAAgC,EAChC,aAAa,EACb,iBAAiB,GACjB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,8BAA8B,EAAE,MAAM,0CAA0C,CAAC;AAC1F,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAUlC,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAGnE,KAAK,UAAU,eAAe,CAC7B,OAAsC,EACtC,aAAiC;IAEjC,MAAM,aAAa,GAAkB,MAAM,aAAa,CAAC,iBAAiB,CACzE,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,OAAO,CACf,CAAC;IACF,OAAO,aAAa,CAAC;AACtB,CAAC;AAED,KAAK,UAAU,iBAAiB,CAC/B,OAAsC,EACtC,aAAiC;IAEjC,MAAM,aAAa,GAAkB,MAAM,aAAa,CAAC,mBAAmB,CAC3E,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,OAAO,CACf,CAAC;IACF,OAAO,aAAa,CAAC;AACtB,CAAC;AAED;;;GAGG;AACH,MAAM,sBAAsB,GAAG;AAC9B,WAAW;CACX,CAAC;AAEF;;;;GAIG;A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C/C,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACpD,CAAC;QACD,cAAc,CAAC,MAAM,GAAG,MAAM,CAAC;QAC/B,OAAO,cAAc,CAAC;IACvB,CAAC;IAEO,KAAK,CAAC,oBAAoB,CAAC,SAAqB;QACvD,OAAO,IAAI,qBAAqB,CAAC,SAAS,CAAC,CAAC;IAC7C,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport type {\n\tIContainer,\n\tIFluidModuleWithDetails,\n} from \"@fluidframework/container-definitions/internal\";\nimport {\n\tcreateDetachedContainer,\n\tloadExistingContainer,\n\ttype ILoaderProps,\n} from \"@fluidframework/container-loader/internal\";\nimport type {\n\tIConfigProviderBase,\n\tIRequest,\n\tITelemetryBaseLogger,\n} from \"@fluidframework/core-interfaces\";\nimport type { IClient } from \"@fluidframework/driver-definitions\";\nimport type { IDocumentServiceFactory } from \"@fluidframework/driver-definitions/internal\";\nimport type { ContainerAttachProps, ContainerSchema } from \"@fluidframework/fluid-static\";\nimport {\n\tcreateDOProviderContainerRuntimeFactory,\n\tcreateFluidContainer,\n\tisInternalFluidContainer,\n} from \"@fluidframework/fluid-static/internal\";\nimport {\n\tOdspDocumentServiceFactory,\n\tOdspDriverUrlResolver,\n\tcreateOdspCreateContainerRequest,\n\tcreateOdspUrl,\n\tisOdspResolvedUrl,\n} from \"@fluidframework/odsp-driver/internal\";\nimport type { OdspResourceTokenFetchOptions } from \"@fluidframework/odsp-driver-definitions/internal\";\nimport { wrapConfigProviderWithDefaults } from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport type {\n\tTokenResponse,\n\tOdspClientProps,\n\tOdspConnectionConfig,\n\tOdspContainerAttachProps,\n\tOdspContainerServices as IOdspContainerServices,\n\tIOdspFluidContainer,\n} from \"./interfaces.js\";\nimport { OdspContainerServices } from \"./odspContainerServices.js\";\nimport type { IOdspTokenProvider } from \"./token.js\";\n\nasync function getStorageToken(\n\toptions: OdspResourceTokenFetchOptions,\n\ttokenProvider: IOdspTokenProvider,\n): Promise<TokenResponse> {\n\tconst tokenResponse: TokenResponse = await tokenProvider.fetchStorageToken(\n\t\toptions.siteUrl,\n\t\toptions.refresh,\n\t);\n\treturn tokenResponse;\n}\n\nasync function getWebsocketToken(\n\toptions: OdspResourceTokenFetchOptions,\n\ttokenProvider: IOdspTokenProvider,\n): Promise<TokenResponse> {\n\tconst tokenResponse: TokenResponse = await tokenProvider.fetchWebsocketToken(\n\t\toptions.siteUrl,\n\t\toptions.refresh,\n\t);\n\treturn tokenResponse;\n}\n\n/**\n * Default feature gates.\n * These values will only be used if the feature gate is not already set by the supplied config provider.\n */\nconst odspClientFeatureGates = {\n\t// None yet\n};\n\n/**\n * Wrap the config provider to fall back on the appropriate defaults for ODSP Client.\n * @param baseConfigProvider - The base config provider to wrap\n * @returns A new config provider with the appropriate defaults applied underneath the given provider\n */\nfunction wrapConfigProvider(baseConfigProvider?: IConfigProviderBase): IConfigProviderBase {\n\treturn wrapConfigProviderWithDefaults(baseConfigProvider, odspClientFeatureGates);\n}\n\n/**\n * OdspClient provides the ability to have a Fluid object backed by the ODSP service within the context of Microsoft 365 (M365) tenants.\n * @sealed\n * @beta\n */\nexport class OdspClient {\n\tprivate readonly documentServiceFactory: IDocumentServiceFactory;\n\tprivate readonly urlResolver: OdspDriverUrlResolver;\n\tprivate readonly configProvider: IConfigProviderBase | undefined;\n\tprivate readonly connectionConfig: OdspConnectionConfig;\n\tprivate readonly logger: ITelemetryBaseLogger | undefined;\n\n\tpublic constructor(properties: OdspClientProps) {\n\t\tthis.connectionConfig = properties.connection;\n\t\tthis.logger = properties.logger;\n\t\tthis.documentServiceFactory = new OdspDocumentServiceFactory(\n\t\t\tasync (options) => getStorageToken(options, this.connectionConfig.tokenProvider),\n\t\t\tasync (options) => getWebsocketToken(options, this.connectionConfig.tokenProvider),\n\t\t);\n\n\t\tthis.urlResolver = new OdspDriverUrlResolver();\n\t\tthis.configProvider = wrapConfigProvider(properties.configProvider);\n\t}\n\n\tpublic async createContainer<T extends ContainerSchema>(\n\t\tcontainerSchema: T,\n\t): Promise<{\n\t\tcontainer: IOdspFluidContainer<T>;\n\t\tservices: IOdspContainerServices;\n\t}> {\n\t\tconst loaderProps = this.getLoaderProps(containerSchema);\n\n\t\tconst container = await createDetachedContainer({\n\t\t\t...loaderProps,\n\t\t\tcodeDetails: {\n\t\t\t\tpackage: \"no-dynamic-package\",\n\t\t\t\tconfig: {},\n\t\t\t},\n\t\t});\n\n\t\tconst fluidContainer = await this.createFluidContainer<T>(\n\t\t\tcontainer,\n\t\t\tthis.connectionConfig,\n\t\t);\n\n\t\tconst services = await this.getContainerServices(container);\n\n\t\treturn { container: fluidContainer, services };\n\t}\n\n\tpublic async getContainer<T extends ContainerSchema>(\n\t\tid: string,\n\t\tcontainerSchema: T,\n\t): Promise<{\n\t\tcontainer: IOdspFluidContainer<T>;\n\t\tservices: IOdspContainerServices;\n\t}> {\n\t\tconst loaderProps = this.getLoaderProps(containerSchema);\n\t\tconst url = createOdspUrl({\n\t\t\tsiteUrl: this.connectionConfig.siteUrl,\n\t\t\tdriveId: this.connectionConfig.driveId,\n\t\t\titemId: id,\n\t\t\tdataStorePath: \"\",\n\t\t});\n\t\tconst container = await loadExistingContainer({ ...loaderProps, request: { url } });\n\n\t\tconst fluidContainer = await createFluidContainer<T>({\n\t\t\tcontainer,\n\t\t});\n\t\tif (!isInternalFluidContainer(fluidContainer)) {\n\t\t\tthrow new Error(\"Fluid container is not internal\");\n\t\t}\n\t\tconst services = await this.getContainerServices(container);\n\t\treturn { container: fluidContainer, services };\n\t}\n\n\tprivate getLoaderProps(schema: ContainerSchema): ILoaderProps {\n\t\tconst runtimeFactory = createDOProviderContainerRuntimeFactory({\n\t\t\tschema,\n\t\t\tcompatibilityMode: \"2\",\n\t\t});\n\t\tconst load = async (): Promise<IFluidModuleWithDetails> => {\n\t\t\treturn {\n\t\t\t\tmodule: { fluidExport: runtimeFactory },\n\t\t\t\tdetails: { package: \"no-dynamic-package\", config: {} },\n\t\t\t};\n\t\t};\n\n\t\tconst codeLoader = { load };\n\t\tconst client: IClient = {\n\t\t\tdetails: {\n\t\t\t\tcapabilities: { interactive: true },\n\t\t\t},\n\t\t\tpermission: [],\n\t\t\tscopes: [],\n\t\t\tuser: { id: \"\" },\n\t\t\tmode: \"write\",\n\t\t};\n\n\t\treturn {\n\t\t\turlResolver: this.urlResolver,\n\t\t\tdocumentServiceFactory: this.documentServiceFactory,\n\t\t\tcodeLoader,\n\t\t\tlogger: this.logger,\n\t\t\toptions: { client },\n\t\t\tconfigProvider: this.configProvider,\n\t\t};\n\t}\n\n\tprivate async createFluidContainer<T extends ContainerSchema>(\n\t\tcontainer: IContainer,\n\t\tconnection: OdspConnectionConfig,\n\t): Promise<IOdspFluidContainer<T>> {\n\t\t/**\n\t\t * See {@link FluidContainer.attach}\n\t\t */\n\t\tconst attach = async (\n\t\t\todspProps?: ContainerAttachProps<OdspContainerAttachProps>,\n\t\t): Promise<string> => {\n\t\t\tconst createNewRequest: IRequest = createOdspCreateContainerRequest(\n\t\t\t\tconnection.siteUrl,\n\t\t\t\tconnection.driveId,\n\t\t\t\todspProps?.filePath ?? \"\",\n\t\t\t\todspProps?.fileName ?? uuid(),\n\t\t\t);\n\t\t\tif (container.attachState !== AttachState.Detached) {\n\t\t\t\tthrow new Error(\"Cannot attach container. Container is not in detached state\");\n\t\t\t}\n\t\t\tawait container.attach(createNewRequest);\n\n\t\t\tconst resolvedUrl = container.resolvedUrl;\n\n\t\t\tif (resolvedUrl === undefined || !isOdspResolvedUrl(resolvedUrl)) {\n\t\t\t\tthrow new Error(\"Resolved Url not available on attached container\");\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * A unique identifier for the file within the provided SharePoint Embedded container ID. When you attach a container,\n\t\t\t * a new `itemId` is created in the user's drive, which developers can use for various operations\n\t\t\t * like updating, renaming, moving the Fluid file, changing permissions, and more. `itemId` is used to load the container.\n\t\t\t */\n\t\t\treturn resolvedUrl.itemId;\n\t\t};\n\t\tconst fluidContainer = await createFluidContainer<T>({ container });\n\t\tif (!isInternalFluidContainer(fluidContainer)) {\n\t\t\tthrow new Error(\"Fluid container is not internal\");\n\t\t}\n\t\tfluidContainer.attach = attach;\n\t\treturn fluidContainer;\n\t}\n\n\tprivate async getContainerServices(container: IContainer): Promise<IOdspContainerServices> {\n\t\treturn new OdspContainerServices(container);\n\t}\n}\n"]}
1
+ {"version":3,"file":"odspClient.js","sourceRoot":"","sources":["../src/odspClient.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAKpE,OAAO,EACN,uBAAuB,EACvB,qBAAqB,GAErB,MAAM,2CAA2C,CAAC;AASnD,OAAO,EACN,uCAAuC,EACvC,oBAAoB,EACpB,wBAAwB,GACxB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACN,0BAA0B,EAC1B,qBAAqB,EACrB,gCAAgC,EAChC,aAAa,EACb,iBAAiB,GACjB,MAAM,sCAAsC,CAAC;AAG9C,OAAO,EAAE,8BAA8B,EAAE,MAAM,0CAA0C,CAAC;AAC1F,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAUlC,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAGnE,KAAK,UAAU,eAAe,CAC7B,OAAsC,EACtC,aAAiC;IAEjC,MAAM,aAAa,GAAkB,MAAM,aAAa,CAAC,iBAAiB,CACzE,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,OAAO,CACf,CAAC;IACF,OAAO,aAAa,CAAC;AACtB,CAAC;AAED,KAAK,UAAU,iBAAiB,CAC/B,OAAsC,EACtC,aAAiC;IAEjC,MAAM,aAAa,GAAkB,MAAM,aAAa,CAAC,mBAAmB,CAC3E,OAAO,C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C,kDAAkD,CAAC,CAAC;YACrE,CAAC;YAED;;;;eAIG;YACH,OAAO,WAAW,CAAC,MAAM,CAAC;QAC3B,CAAC,CAAC;QACF,MAAM,cAAc,GAAG,MAAM,oBAAoB,CAAI,EAAE,SAAS,EAAE,CAAC,CAAC;QACpE,IAAI,CAAC,wBAAwB,CAAC,cAAc,CAAC,EAAE,CAAC;YAC/C,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACpD,CAAC;QACD,cAAc,CAAC,MAAM,GAAG,MAAM,CAAC;QAC/B,OAAO,cAAc,CAAC;IACvB,CAAC;IAEO,KAAK,CAAC,oBAAoB,CAAC,SAAqB;QACvD,OAAO,IAAI,qBAAqB,CAAC,SAAS,CAAC,CAAC;IAC7C,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport type {\n\tIContainer,\n\tIFluidModuleWithDetails,\n} from \"@fluidframework/container-definitions/internal\";\nimport {\n\tcreateDetachedContainer,\n\tloadExistingContainer,\n\ttype ILoaderProps,\n} from \"@fluidframework/container-loader/internal\";\nimport type {\n\tIConfigProviderBase,\n\tIRequest,\n\tITelemetryBaseLogger,\n} from \"@fluidframework/core-interfaces\";\nimport type { IClient } from \"@fluidframework/driver-definitions\";\nimport type { IDocumentServiceFactory } from \"@fluidframework/driver-definitions/internal\";\nimport type { ContainerAttachProps, ContainerSchema } from \"@fluidframework/fluid-static\";\nimport {\n\tcreateDOProviderContainerRuntimeFactory,\n\tcreateFluidContainer,\n\tisInternalFluidContainer,\n} from \"@fluidframework/fluid-static/internal\";\nimport {\n\tOdspDocumentServiceFactory,\n\tOdspDriverUrlResolver,\n\tcreateOdspCreateContainerRequest,\n\tcreateOdspUrl,\n\tisOdspResolvedUrl,\n} from \"@fluidframework/odsp-driver/internal\";\nimport type { OdspResourceTokenFetchOptions } from \"@fluidframework/odsp-driver-definitions/internal\";\nimport type { MinimumVersionForCollab } from \"@fluidframework/runtime-definitions\";\nimport { wrapConfigProviderWithDefaults } from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport type {\n\tTokenResponse,\n\tOdspClientProps,\n\tOdspConnectionConfig,\n\tOdspContainerAttachProps,\n\tOdspContainerServices as IOdspContainerServices,\n\tIOdspFluidContainer,\n} from \"./interfaces.js\";\nimport { OdspContainerServices } from \"./odspContainerServices.js\";\nimport type { IOdspTokenProvider } from \"./token.js\";\n\nasync function getStorageToken(\n\toptions: OdspResourceTokenFetchOptions,\n\ttokenProvider: IOdspTokenProvider,\n): Promise<TokenResponse> {\n\tconst tokenResponse: TokenResponse = await tokenProvider.fetchStorageToken(\n\t\toptions.siteUrl,\n\t\toptions.refresh,\n\t);\n\treturn tokenResponse;\n}\n\nasync function getWebsocketToken(\n\toptions: OdspResourceTokenFetchOptions,\n\ttokenProvider: IOdspTokenProvider,\n): Promise<TokenResponse> {\n\tconst tokenResponse: TokenResponse = await tokenProvider.fetchWebsocketToken(\n\t\toptions.siteUrl,\n\t\toptions.refresh,\n\t);\n\treturn tokenResponse;\n}\n\n/**\n * Default feature gates.\n * These values will only be used if the feature gate is not already set by the supplied config provider.\n */\nconst odspClientFeatureGates = {\n\t// None yet\n};\n\n/**\n * Wrap the config provider to fall back on the appropriate defaults for ODSP Client.\n * @param baseConfigProvider - The base config provider to wrap\n * @returns A new config provider with the appropriate defaults applied underneath the given provider\n */\nfunction wrapConfigProvider(baseConfigProvider?: IConfigProviderBase): IConfigProviderBase {\n\treturn wrapConfigProviderWithDefaults(baseConfigProvider, odspClientFeatureGates);\n}\n\n/**\n * OdspClient provides the ability to have a Fluid object backed by the ODSP service within the context of Microsoft 365 (M365) tenants.\n * @sealed\n * @beta\n */\nexport class OdspClient {\n\tprivate readonly documentServiceFactory: IDocumentServiceFactory;\n\tprivate readonly urlResolver: OdspDriverUrlResolver;\n\tprivate readonly configProvider: IConfigProviderBase | undefined;\n\tprivate readonly connectionConfig: OdspConnectionConfig;\n\tprivate readonly logger: ITelemetryBaseLogger | undefined;\n\n\tpublic constructor(properties: OdspClientProps) {\n\t\tthis.connectionConfig = properties.connection;\n\t\tthis.logger = properties.logger;\n\t\tthis.documentServiceFactory = new OdspDocumentServiceFactory(\n\t\t\tasync (options) => getStorageToken(options, this.connectionConfig.tokenProvider),\n\t\t\tasync (options) => getWebsocketToken(options, this.connectionConfig.tokenProvider),\n\t\t);\n\n\t\tthis.urlResolver = new OdspDriverUrlResolver();\n\t\tthis.configProvider = wrapConfigProvider(properties.configProvider);\n\t}\n\n\t/**\n\t * Creates a new detached container instance backed by ODSP.\n\t * @param containerSchema - Container schema for the new container.\n\t * @param minVersionForCollab - Minimum Fluid Framework version required for collaboration, as a\n\t * `MinimumVersionForCollab` SemVer string (e.g. `\"2.100.0\"`). Prefer the current Fluid Framework\n\t * version so the container opts into the latest defaults.\n\t * @returns New detached container instance along with associated services.\n\t */\n\tpublic async createContainer<T extends ContainerSchema>(\n\t\tcontainerSchema: T,\n\t\t// OdspClient does not support 1.x clients, so we exclude it from the accepted `minVersionForCollab` values.\n\t\tminVersionForCollab: Exclude<MinimumVersionForCollab, `1.${string}`>,\n\t): Promise<{\n\t\tcontainer: IOdspFluidContainer<T>;\n\t\tservices: IOdspContainerServices;\n\t}>;\n\t/**\n\t * Creates a new detached container instance backed by ODSP.\n\t * @param containerSchema - Container schema for the new container.\n\t * @returns New detached container instance along with associated services.\n\t * @deprecated Pass a `MinimumVersionForCollab` SemVer string (e.g. `\"2.0.0\"`) as a second argument.\n\t * The previous behavior was equivalent to passing `\"2.0.0\"`.\n\t */\n\tpublic async createContainer<T extends ContainerSchema>(\n\t\tcontainerSchema: T,\n\t): Promise<{\n\t\tcontainer: IOdspFluidContainer<T>;\n\t\tservices: IOdspContainerServices;\n\t}>;\n\tpublic async createContainer<T extends ContainerSchema>(\n\t\tcontainerSchema: T,\n\t\tminVersionForCollab: Exclude<MinimumVersionForCollab, `1.${string}`> = \"2.0.0\",\n\t): Promise<{\n\t\tcontainer: IOdspFluidContainer<T>;\n\t\tservices: IOdspContainerServices;\n\t}> {\n\t\tconst loaderProps = this.getLoaderProps(containerSchema, minVersionForCollab);\n\n\t\tconst container = await createDetachedContainer({\n\t\t\t...loaderProps,\n\t\t\tcodeDetails: {\n\t\t\t\tpackage: \"no-dynamic-package\",\n\t\t\t\tconfig: {},\n\t\t\t},\n\t\t});\n\n\t\tconst fluidContainer = await this.createFluidContainer<T>(\n\t\t\tcontainer,\n\t\t\tthis.connectionConfig,\n\t\t);\n\n\t\tconst services = await this.getContainerServices(container);\n\n\t\treturn { container: fluidContainer, services };\n\t}\n\n\t/**\n\t * Accesses an existing container by its unique ID in ODSP.\n\t * @param id - Unique ID of the container in ODSP.\n\t * @param containerSchema - Container schema used to access data objects in the container.\n\t * @param minVersionForCollab - Minimum Fluid Framework version required for collaboration, as a\n\t * `MinimumVersionForCollab` SemVer string (e.g. `\"2.100.0\"`). Prefer the current Fluid Framework\n\t * version so the container opts into the latest defaults.\n\t * @returns Existing container instance along with associated services.\n\t */\n\tpublic async getContainer<T extends ContainerSchema>(\n\t\tid: string,\n\t\tcontainerSchema: T,\n\t\tminVersionForCollab: Exclude<MinimumVersionForCollab, `1.${string}`>,\n\t): Promise<{\n\t\tcontainer: IOdspFluidContainer<T>;\n\t\tservices: IOdspContainerServices;\n\t}>;\n\t/**\n\t * Accesses an existing container by its unique ID in ODSP.\n\t * @param id - Unique ID of the container in ODSP.\n\t * @param containerSchema - Container schema used to access data objects in the container.\n\t * @returns Existing container instance along with associated services.\n\t * @deprecated Pass a `MinimumVersionForCollab` SemVer string (e.g. `\"2.0.0\"`) as a third argument.\n\t * The previous behavior was equivalent to passing `\"2.0.0\"`.\n\t */\n\tpublic async getContainer<T extends ContainerSchema>(\n\t\tid: string,\n\t\tcontainerSchema: T,\n\t): Promise<{\n\t\tcontainer: IOdspFluidContainer<T>;\n\t\tservices: IOdspContainerServices;\n\t}>;\n\tpublic async getContainer<T extends ContainerSchema>(\n\t\tid: string,\n\t\tcontainerSchema: T,\n\t\tminVersionForCollab: Exclude<MinimumVersionForCollab, `1.${string}`> = \"2.0.0\",\n\t): Promise<{\n\t\tcontainer: IOdspFluidContainer<T>;\n\t\tservices: IOdspContainerServices;\n\t}> {\n\t\tconst loaderProps = this.getLoaderProps(containerSchema, minVersionForCollab);\n\t\tconst url = createOdspUrl({\n\t\t\tsiteUrl: this.connectionConfig.siteUrl,\n\t\t\tdriveId: this.connectionConfig.driveId,\n\t\t\titemId: id,\n\t\t\tdataStorePath: \"\",\n\t\t});\n\t\tconst container = await loadExistingContainer({ ...loaderProps, request: { url } });\n\n\t\tconst fluidContainer = await createFluidContainer<T>({\n\t\t\tcontainer,\n\t\t});\n\t\tif (!isInternalFluidContainer(fluidContainer)) {\n\t\t\tthrow new Error(\"Fluid container is not internal\");\n\t\t}\n\t\tconst services = await this.getContainerServices(container);\n\t\treturn { container: fluidContainer, services };\n\t}\n\n\tprivate getLoaderProps(\n\t\tschema: ContainerSchema,\n\t\tminVersionForCollaboration: Exclude<MinimumVersionForCollab, `1.${string}`>,\n\t): ILoaderProps {\n\t\tconst runtimeFactory = createDOProviderContainerRuntimeFactory({\n\t\t\tschema,\n\t\t\tminVersionForCollaboration,\n\t\t});\n\t\tconst load = async (): Promise<IFluidModuleWithDetails> => {\n\t\t\treturn {\n\t\t\t\tmodule: { fluidExport: runtimeFactory },\n\t\t\t\tdetails: { package: \"no-dynamic-package\", config: {} },\n\t\t\t};\n\t\t};\n\n\t\tconst codeLoader = { load };\n\t\tconst client: IClient = {\n\t\t\tdetails: {\n\t\t\t\tcapabilities: { interactive: true },\n\t\t\t},\n\t\t\tpermission: [],\n\t\t\tscopes: [],\n\t\t\tuser: { id: \"\" },\n\t\t\tmode: \"write\",\n\t\t};\n\n\t\treturn {\n\t\t\turlResolver: this.urlResolver,\n\t\t\tdocumentServiceFactory: this.documentServiceFactory,\n\t\t\tcodeLoader,\n\t\t\tlogger: this.logger,\n\t\t\toptions: { client },\n\t\t\tconfigProvider: this.configProvider,\n\t\t};\n\t}\n\n\tprivate async createFluidContainer<T extends ContainerSchema>(\n\t\tcontainer: IContainer,\n\t\tconnection: OdspConnectionConfig,\n\t): Promise<IOdspFluidContainer<T>> {\n\t\t/**\n\t\t * See {@link FluidContainer.attach}\n\t\t */\n\t\tconst attach = async (\n\t\t\todspProps?: ContainerAttachProps<OdspContainerAttachProps>,\n\t\t): Promise<string> => {\n\t\t\tconst createNewRequest: IRequest = createOdspCreateContainerRequest(\n\t\t\t\tconnection.siteUrl,\n\t\t\t\tconnection.driveId,\n\t\t\t\todspProps?.filePath ?? \"\",\n\t\t\t\todspProps?.fileName ?? uuid(),\n\t\t\t);\n\t\t\tif (container.attachState !== AttachState.Detached) {\n\t\t\t\tthrow new Error(\"Cannot attach container. Container is not in detached state\");\n\t\t\t}\n\t\t\tawait container.attach(createNewRequest);\n\n\t\t\tconst resolvedUrl = container.resolvedUrl;\n\n\t\t\tif (resolvedUrl === undefined || !isOdspResolvedUrl(resolvedUrl)) {\n\t\t\t\tthrow new Error(\"Resolved Url not available on attached container\");\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * A unique identifier for the file within the provided SharePoint Embedded container ID. When you attach a container,\n\t\t\t * a new `itemId` is created in the user's drive, which developers can use for various operations\n\t\t\t * like updating, renaming, moving the Fluid file, changing permissions, and more. `itemId` is used to load the container.\n\t\t\t */\n\t\t\treturn resolvedUrl.itemId;\n\t\t};\n\t\tconst fluidContainer = await createFluidContainer<T>({ container });\n\t\tif (!isInternalFluidContainer(fluidContainer)) {\n\t\t\tthrow new Error(\"Fluid container is not internal\");\n\t\t}\n\t\tfluidContainer.attach = attach;\n\t\treturn fluidContainer;\n\t}\n\n\tprivate async getContainerServices(container: IContainer): Promise<IOdspContainerServices> {\n\t\treturn new OdspContainerServices(container);\n\t}\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/odsp-client",
3
- "version": "2.101.1",
3
+ "version": "2.102.0",
4
4
  "description": "A tool to enable creation and loading of Fluid containers using the ODSP service",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -69,29 +69,30 @@
69
69
  "temp-directory": "nyc/.nyc_output"
70
70
  },
71
71
  "dependencies": {
72
- "@fluid-internal/client-utils": "~2.101.1",
73
- "@fluidframework/container-definitions": "~2.101.1",
74
- "@fluidframework/container-loader": "~2.101.1",
75
- "@fluidframework/core-interfaces": "~2.101.1",
76
- "@fluidframework/core-utils": "~2.101.1",
77
- "@fluidframework/driver-definitions": "~2.101.1",
78
- "@fluidframework/fluid-static": "~2.101.1",
79
- "@fluidframework/map": "~2.101.1",
80
- "@fluidframework/odsp-doclib-utils": "~2.101.1",
81
- "@fluidframework/odsp-driver": "~2.101.1",
82
- "@fluidframework/odsp-driver-definitions": "~2.101.1",
83
- "@fluidframework/telemetry-utils": "~2.101.1",
72
+ "@fluid-internal/client-utils": "~2.102.0",
73
+ "@fluidframework/container-definitions": "~2.102.0",
74
+ "@fluidframework/container-loader": "~2.102.0",
75
+ "@fluidframework/core-interfaces": "~2.102.0",
76
+ "@fluidframework/core-utils": "~2.102.0",
77
+ "@fluidframework/driver-definitions": "~2.102.0",
78
+ "@fluidframework/fluid-static": "~2.102.0",
79
+ "@fluidframework/map": "~2.102.0",
80
+ "@fluidframework/odsp-doclib-utils": "~2.102.0",
81
+ "@fluidframework/odsp-driver": "~2.102.0",
82
+ "@fluidframework/odsp-driver-definitions": "~2.102.0",
83
+ "@fluidframework/runtime-definitions": "~2.102.0",
84
+ "@fluidframework/telemetry-utils": "~2.102.0",
84
85
  "uuid": "^11.1.0"
85
86
  },
86
87
  "devDependencies": {
87
88
  "@arethetypeswrong/cli": "^0.18.2",
88
89
  "@biomejs/biome": "~2.4.5",
89
- "@fluid-internal/mocha-test-setup": "~2.101.1",
90
+ "@fluid-internal/mocha-test-setup": "~2.102.0",
90
91
  "@fluid-tools/build-cli": "^0.65.0",
91
92
  "@fluidframework/build-common": "^2.0.3",
92
93
  "@fluidframework/build-tools": "^0.65.0",
93
94
  "@fluidframework/eslint-config-fluid": "^9.0.0",
94
- "@fluidframework/test-utils": "~2.101.1",
95
+ "@fluidframework/test-utils": "~2.102.0",
95
96
  "@microsoft/api-extractor": "7.58.1",
96
97
  "@types/mocha": "^10.0.10",
97
98
  "@types/node": "~22.19.17",
package/src/odspClient.ts CHANGED
@@ -34,6 +34,7 @@ import {
34
34
  isOdspResolvedUrl,
35
35
  } from "@fluidframework/odsp-driver/internal";
36
36
  import type { OdspResourceTokenFetchOptions } from "@fluidframework/odsp-driver-definitions/internal";
37
+ import type { MinimumVersionForCollab } from "@fluidframework/runtime-definitions";
37
38
  import { wrapConfigProviderWithDefaults } from "@fluidframework/telemetry-utils/internal";
38
39
  import { v4 as uuid } from "uuid";
39
40
 
@@ -111,13 +112,43 @@ export class OdspClient {
111
112
  this.configProvider = wrapConfigProvider(properties.configProvider);
112
113
  }
113
114
 
115
+ /**
116
+ * Creates a new detached container instance backed by ODSP.
117
+ * @param containerSchema - Container schema for the new container.
118
+ * @param minVersionForCollab - Minimum Fluid Framework version required for collaboration, as a
119
+ * `MinimumVersionForCollab` SemVer string (e.g. `"2.100.0"`). Prefer the current Fluid Framework
120
+ * version so the container opts into the latest defaults.
121
+ * @returns New detached container instance along with associated services.
122
+ */
114
123
  public async createContainer<T extends ContainerSchema>(
115
124
  containerSchema: T,
125
+ // OdspClient does not support 1.x clients, so we exclude it from the accepted `minVersionForCollab` values.
126
+ minVersionForCollab: Exclude<MinimumVersionForCollab, `1.${string}`>,
127
+ ): Promise<{
128
+ container: IOdspFluidContainer<T>;
129
+ services: IOdspContainerServices;
130
+ }>;
131
+ /**
132
+ * Creates a new detached container instance backed by ODSP.
133
+ * @param containerSchema - Container schema for the new container.
134
+ * @returns New detached container instance along with associated services.
135
+ * @deprecated Pass a `MinimumVersionForCollab` SemVer string (e.g. `"2.0.0"`) as a second argument.
136
+ * The previous behavior was equivalent to passing `"2.0.0"`.
137
+ */
138
+ public async createContainer<T extends ContainerSchema>(
139
+ containerSchema: T,
140
+ ): Promise<{
141
+ container: IOdspFluidContainer<T>;
142
+ services: IOdspContainerServices;
143
+ }>;
144
+ public async createContainer<T extends ContainerSchema>(
145
+ containerSchema: T,
146
+ minVersionForCollab: Exclude<MinimumVersionForCollab, `1.${string}`> = "2.0.0",
116
147
  ): Promise<{
117
148
  container: IOdspFluidContainer<T>;
118
149
  services: IOdspContainerServices;
119
150
  }> {
120
- const loaderProps = this.getLoaderProps(containerSchema);
151
+ const loaderProps = this.getLoaderProps(containerSchema, minVersionForCollab);
121
152
 
122
153
  const container = await createDetachedContainer({
123
154
  ...loaderProps,
@@ -137,14 +168,47 @@ export class OdspClient {
137
168
  return { container: fluidContainer, services };
138
169
  }
139
170
 
171
+ /**
172
+ * Accesses an existing container by its unique ID in ODSP.
173
+ * @param id - Unique ID of the container in ODSP.
174
+ * @param containerSchema - Container schema used to access data objects in the container.
175
+ * @param minVersionForCollab - Minimum Fluid Framework version required for collaboration, as a
176
+ * `MinimumVersionForCollab` SemVer string (e.g. `"2.100.0"`). Prefer the current Fluid Framework
177
+ * version so the container opts into the latest defaults.
178
+ * @returns Existing container instance along with associated services.
179
+ */
180
+ public async getContainer<T extends ContainerSchema>(
181
+ id: string,
182
+ containerSchema: T,
183
+ minVersionForCollab: Exclude<MinimumVersionForCollab, `1.${string}`>,
184
+ ): Promise<{
185
+ container: IOdspFluidContainer<T>;
186
+ services: IOdspContainerServices;
187
+ }>;
188
+ /**
189
+ * Accesses an existing container by its unique ID in ODSP.
190
+ * @param id - Unique ID of the container in ODSP.
191
+ * @param containerSchema - Container schema used to access data objects in the container.
192
+ * @returns Existing container instance along with associated services.
193
+ * @deprecated Pass a `MinimumVersionForCollab` SemVer string (e.g. `"2.0.0"`) as a third argument.
194
+ * The previous behavior was equivalent to passing `"2.0.0"`.
195
+ */
196
+ public async getContainer<T extends ContainerSchema>(
197
+ id: string,
198
+ containerSchema: T,
199
+ ): Promise<{
200
+ container: IOdspFluidContainer<T>;
201
+ services: IOdspContainerServices;
202
+ }>;
140
203
  public async getContainer<T extends ContainerSchema>(
141
204
  id: string,
142
205
  containerSchema: T,
206
+ minVersionForCollab: Exclude<MinimumVersionForCollab, `1.${string}`> = "2.0.0",
143
207
  ): Promise<{
144
208
  container: IOdspFluidContainer<T>;
145
209
  services: IOdspContainerServices;
146
210
  }> {
147
- const loaderProps = this.getLoaderProps(containerSchema);
211
+ const loaderProps = this.getLoaderProps(containerSchema, minVersionForCollab);
148
212
  const url = createOdspUrl({
149
213
  siteUrl: this.connectionConfig.siteUrl,
150
214
  driveId: this.connectionConfig.driveId,
@@ -163,10 +227,13 @@ export class OdspClient {
163
227
  return { container: fluidContainer, services };
164
228
  }
165
229
 
166
- private getLoaderProps(schema: ContainerSchema): ILoaderProps {
230
+ private getLoaderProps(
231
+ schema: ContainerSchema,
232
+ minVersionForCollaboration: Exclude<MinimumVersionForCollab, `1.${string}`>,
233
+ ): ILoaderProps {
167
234
  const runtimeFactory = createDOProviderContainerRuntimeFactory({
168
235
  schema,
169
- compatibilityMode: "2",
236
+ minVersionForCollaboration,
170
237
  });
171
238
  const load = async (): Promise<IFluidModuleWithDetails> => {
172
239
  return {