@fluidframework/odsp-client 2.0.2 → 2.1.0-276326
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.cjs +1 -13
- package/api-report/odsp-client.alpha.api.md +0 -7
- package/api-report/odsp-client.beta.api.md +0 -7
- package/api-report/odsp-client.public.api.md +0 -7
- package/dist/interfaces.d.ts +3 -3
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/interfaces.js.map +1 -1
- package/dist/odspAudience.d.ts +5 -0
- package/dist/odspAudience.d.ts.map +1 -1
- package/dist/odspAudience.js +5 -0
- package/dist/odspAudience.js.map +1 -1
- package/dist/odspClient.d.ts +2 -2
- package/dist/odspClient.d.ts.map +1 -1
- package/dist/odspClient.js +1 -14
- package/dist/odspClient.js.map +1 -1
- package/lib/interfaces.d.ts +3 -3
- package/lib/interfaces.d.ts.map +1 -1
- package/lib/interfaces.js.map +1 -1
- package/lib/odspAudience.d.ts +5 -0
- package/lib/odspAudience.d.ts.map +1 -1
- package/lib/odspAudience.js +5 -0
- package/lib/odspAudience.js.map +1 -1
- package/lib/odspClient.d.ts +2 -2
- package/lib/odspClient.d.ts.map +1 -1
- package/lib/odspClient.js +1 -14
- package/lib/odspClient.js.map +1 -1
- package/package.json +16 -16
- package/src/interfaces.ts +6 -3
- package/src/odspAudience.ts +5 -0
- package/src/odspClient.ts +8 -22
package/.eslintrc.cjs
CHANGED
|
@@ -4,20 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
module.exports = {
|
|
7
|
-
extends: [require.resolve("@fluidframework/eslint-config-fluid"), "prettier"],
|
|
7
|
+
extends: [require.resolve("@fluidframework/eslint-config-fluid/strict"), "prettier"],
|
|
8
8
|
parserOptions: {
|
|
9
9
|
project: ["./tsconfig.json", "./src/test/tsconfig.json"],
|
|
10
10
|
},
|
|
11
|
-
rules: {
|
|
12
|
-
"@typescript-eslint/strict-boolean-expressions": "off",
|
|
13
|
-
},
|
|
14
|
-
overrides: [
|
|
15
|
-
{
|
|
16
|
-
files: ["src/test/**"],
|
|
17
|
-
rules: {
|
|
18
|
-
// It's fine for tests to use Node.js modules
|
|
19
|
-
"import/no-nodejs-modules": "off",
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
],
|
|
23
11
|
};
|
|
@@ -4,13 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
```ts
|
|
6
6
|
|
|
7
|
-
import { ContainerSchema } from '@fluidframework/fluid-static';
|
|
8
|
-
import { IConfigProviderBase } from '@fluidframework/core-interfaces';
|
|
9
|
-
import { IFluidContainer } from '@fluidframework/fluid-static';
|
|
10
|
-
import type { IMember } from '@fluidframework/fluid-static';
|
|
11
|
-
import type { IServiceAudience } from '@fluidframework/fluid-static';
|
|
12
|
-
import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
|
|
13
|
-
|
|
14
7
|
// @beta
|
|
15
8
|
export type IOdspAudience = IServiceAudience<OdspMember>;
|
|
16
9
|
|
|
@@ -4,13 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
```ts
|
|
6
6
|
|
|
7
|
-
import { ContainerSchema } from '@fluidframework/fluid-static';
|
|
8
|
-
import { IConfigProviderBase } from '@fluidframework/core-interfaces';
|
|
9
|
-
import { IFluidContainer } from '@fluidframework/fluid-static';
|
|
10
|
-
import type { IMember } from '@fluidframework/fluid-static';
|
|
11
|
-
import type { IServiceAudience } from '@fluidframework/fluid-static';
|
|
12
|
-
import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
|
|
13
|
-
|
|
14
7
|
// @beta
|
|
15
8
|
export type IOdspAudience = IServiceAudience<OdspMember>;
|
|
16
9
|
|
|
@@ -4,11 +4,4 @@
|
|
|
4
4
|
|
|
5
5
|
```ts
|
|
6
6
|
|
|
7
|
-
import { ContainerSchema } from '@fluidframework/fluid-static';
|
|
8
|
-
import { IConfigProviderBase } from '@fluidframework/core-interfaces';
|
|
9
|
-
import { IFluidContainer } from '@fluidframework/fluid-static';
|
|
10
|
-
import type { IMember } from '@fluidframework/fluid-static';
|
|
11
|
-
import type { IServiceAudience } from '@fluidframework/fluid-static';
|
|
12
|
-
import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
|
|
13
|
-
|
|
14
7
|
```
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
6
|
-
import { IConfigProviderBase } from "@fluidframework/core-interfaces";
|
|
5
|
+
import type { IConfigProviderBase, ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
|
|
7
6
|
import type { IMember, IServiceAudience } from "@fluidframework/fluid-static";
|
|
8
|
-
import { IOdspTokenProvider } from "./token.js";
|
|
7
|
+
import type { IOdspTokenProvider } from "./token.js";
|
|
9
8
|
/**
|
|
10
9
|
* Defines the necessary properties that will be applied to all containers
|
|
11
10
|
* created by an OdspClient instance. This includes callbacks for the authentication tokens
|
|
@@ -48,6 +47,7 @@ export interface OdspClientProps {
|
|
|
48
47
|
readonly configProvider?: IConfigProviderBase;
|
|
49
48
|
}
|
|
50
49
|
/**
|
|
50
|
+
* @legacy
|
|
51
51
|
* @alpha
|
|
52
52
|
*/
|
|
53
53
|
export interface OdspContainerAttachProps {
|
package/dist/interfaces.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,mBAAmB,EACnB,oBAAoB,EACpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAA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
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tIConfigProviderBase,\n\tITelemetryBaseLogger,\n} from \"@fluidframework/core-interfaces\";\nimport type { IMember, IServiceAudience } from \"@fluidframework/fluid-static\";\n\nimport type { IOdspTokenProvider } from \"./token.js\";\n\n/**\n * Defines the necessary properties that will be applied to all containers\n * created by an OdspClient instance. This includes callbacks for the authentication tokens\n * required for ODSP.\n * @beta\n */\nexport interface OdspConnectionConfig {\n\t/**\n\t * Instance that provides AAD endpoint tokens for Push and SharePoint\n\t */\n\ttokenProvider: IOdspTokenProvider;\n\n\t/**\n\t * Site url representing ODSP resource location. It points to the specific SharePoint site where you can store and access the containers you create.\n\t */\n\tsiteUrl: string;\n\n\t/**\n\t * SharePoint Embedded Container Id of the tenant where Fluid containers are created\n\t */\n\tdriveId: string;\n\n\t/**\n\t * Specifies the file path where Fluid files are created. If passed an empty string, the Fluid files will be created at the root level.\n\t */\n\tfilePath: string;\n}\n/**\n * @beta\n */\nexport interface OdspClientProps {\n\t/**\n\t * Configuration for establishing a connection with the ODSP Fluid Service (Push).\n\t */\n\treadonly connection: OdspConnectionConfig;\n\n\t/**\n\t * Optional. A logger instance to receive diagnostic messages.\n\t */\n\treadonly logger?: ITelemetryBaseLogger;\n\n\t/**\n\t * Base interface for providing configurations to control experimental features. If unsure, leave this undefined.\n\t */\n\treadonly configProvider?: IConfigProviderBase;\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport interface OdspContainerAttachProps {\n\t/**\n\t * The file path where Fluid containers are created. If undefined, the file is created at the root.\n\t */\n\tfilePath: string | undefined;\n\n\t/**\n\t * The file name of the Fluid file. If undefined, the file is named with a GUID.\n\t */\n\tfileName: string | undefined;\n}\n\n/**\n * OdspContainerServices is returned by the OdspClient alongside a FluidContainer. It holds the\n * functionality specifically tied to the ODSP service, and how the data stored in the\n * FluidContainer is persisted in the backend and consumed by users. Any functionality regarding\n * how the data is handled within the FluidContainer itself, i.e. which data objects or DDSes to\n * use, will not be included here but rather on the FluidContainer class itself.\n * @beta\n */\nexport interface OdspContainerServices {\n\t/**\n\t * Provides an object that facilitates obtaining information about users present in the Fluid session, as well as listeners for roster changes triggered by users joining or leaving the session.\n\t */\n\taudience: IOdspAudience;\n}\n\n/**\n * Since ODSP provides user names and email for all of its members, we extend the\n * {@link @fluidframework/fluid-static#IMember} interface to include this service-specific value.\n * It will be returned for all audience members connected.\n * @beta\n */\nexport interface OdspMember extends IMember {\n\t/**\n\t * The object ID (oid) for the user, unique among each individual user connecting to the session.\n\t */\n\tid: string;\n\t/**\n\t * The user's name\n\t */\n\tname: string;\n\t/**\n\t * The user's email\n\t */\n\temail: string;\n}\n\n/**\n * Audience object for ODSP containers\n * @beta\n */\nexport type IOdspAudience = IServiceAudience<OdspMember>;\n\n/**\n * Represents token response\n * @beta\n */\nexport interface TokenResponse {\n\t/**\n\t * Token value\n\t */\n\ttoken: string;\n\n\t/**\n\t * Whether or not the token was obtained from local cache.\n\t * @remarks `undefined` indicates that it could not be determined whether or not the token was obtained this way.\n\t */\n\tfromCache?: boolean;\n}\n"]}
|
package/dist/odspAudience.d.ts
CHANGED
|
@@ -4,5 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { type IClient } from "@fluidframework/driver-definitions";
|
|
6
6
|
import { type OdspMember } from "./interfaces.js";
|
|
7
|
+
/**
|
|
8
|
+
* Creates an audience member from an IClient instance.
|
|
9
|
+
*
|
|
10
|
+
* @param audienceMember - the client instance/
|
|
11
|
+
*/
|
|
7
12
|
export declare function createOdspAudienceMember(audienceMember: IClient): OdspMember;
|
|
8
13
|
//# sourceMappingURL=odspAudience.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspAudience.d.ts","sourceRoot":"","sources":["../src/odspAudience.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAElE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAsBlD,wBAAgB,wBAAwB,CAAC,cAAc,EAAE,OAAO,GAAG,UAAU,CAa5E"}
|
|
1
|
+
{"version":3,"file":"odspAudience.d.ts","sourceRoot":"","sources":["../src/odspAudience.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAElE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAsBlD;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,cAAc,EAAE,OAAO,GAAG,UAAU,CAa5E"}
|
package/dist/odspAudience.js
CHANGED
|
@@ -6,6 +6,11 @@
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.createOdspAudienceMember = void 0;
|
|
8
8
|
const internal_1 = require("@fluidframework/core-utils/internal");
|
|
9
|
+
/**
|
|
10
|
+
* Creates an audience member from an IClient instance.
|
|
11
|
+
*
|
|
12
|
+
* @param audienceMember - the client instance/
|
|
13
|
+
*/
|
|
9
14
|
function createOdspAudienceMember(audienceMember) {
|
|
10
15
|
const user = audienceMember.user;
|
|
11
16
|
(0, internal_1.assert)(user.name !== undefined || user.email !== undefined || user.oid !== undefined, 0x836 /* Provided user was not an "OdspUser". */);
|
package/dist/odspAudience.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspAudience.js","sourceRoot":"","sources":["../src/odspAudience.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAyB7D,SAAgB,wBAAwB,CAAC,cAAuB;IAC/D,MAAM,IAAI,GAAG,cAAc,CAAC,IAA2B,CAAC;IACxD,IAAA,iBAAM,EACL,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,IAAI,IAAI,CAAC,GAAG,KAAK,SAAS,EAC7E,KAAK,CAAC,0CAA0C,CAChD,CAAC;IAEF,OAAO;QACN,EAAE,EAAE,IAAI,CAAC,GAAG;QACZ,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,WAAW,EAAE,EAAE;KACf,CAAC;AACH,CAAC;AAbD,4DAaC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { type IClient } from \"@fluidframework/driver-definitions\";\n\nimport { type OdspMember } from \"./interfaces.js\";\n\n/**\n * Since ODSP provides user names, email and oids for all of its members, we extend the\n * {@link @fluidframework/fluid-static#IMember} interface to include this service-specific value.\n * @internal\n */\ninterface OdspUser {\n\t/**\n\t * The user's email address\n\t */\n\temail: string;\n\t/**\n\t * The user's name\n\t */\n\tname: string;\n\t/**\n\t * The object ID (oid). It is a unique identifier assigned to each user, group, or other entity within AAD or another Microsoft 365 service. It is a GUID that uniquely identifies the object. When making Microsoft Graph API calls, you might need to reference or manipulate objects within the directory, and the `oid` is used to identify these objects.\n\t */\n\toid: string;\n}\n\nexport function createOdspAudienceMember(audienceMember: IClient): OdspMember {\n\tconst user = audienceMember.user as unknown as OdspUser;\n\tassert(\n\t\tuser.name !== undefined || user.email !== undefined || user.oid !== undefined,\n\t\t0x836 /* Provided user was not an \"OdspUser\". */,\n\t);\n\n\treturn {\n\t\tid: user.oid,\n\t\tname: user.name,\n\t\temail: user.email,\n\t\tconnections: [],\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"odspAudience.js","sourceRoot":"","sources":["../src/odspAudience.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAyB7D;;;;GAIG;AACH,SAAgB,wBAAwB,CAAC,cAAuB;IAC/D,MAAM,IAAI,GAAG,cAAc,CAAC,IAA2B,CAAC;IACxD,IAAA,iBAAM,EACL,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,IAAI,IAAI,CAAC,GAAG,KAAK,SAAS,EAC7E,KAAK,CAAC,0CAA0C,CAChD,CAAC;IAEF,OAAO;QACN,EAAE,EAAE,IAAI,CAAC,GAAG;QACZ,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,WAAW,EAAE,EAAE;KACf,CAAC;AACH,CAAC;AAbD,4DAaC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { type IClient } from \"@fluidframework/driver-definitions\";\n\nimport { type OdspMember } from \"./interfaces.js\";\n\n/**\n * Since ODSP provides user names, email and oids for all of its members, we extend the\n * {@link @fluidframework/fluid-static#IMember} interface to include this service-specific value.\n * @internal\n */\ninterface OdspUser {\n\t/**\n\t * The user's email address\n\t */\n\temail: string;\n\t/**\n\t * The user's name\n\t */\n\tname: string;\n\t/**\n\t * The object ID (oid). It is a unique identifier assigned to each user, group, or other entity within AAD or another Microsoft 365 service. It is a GUID that uniquely identifies the object. When making Microsoft Graph API calls, you might need to reference or manipulate objects within the directory, and the `oid` is used to identify these objects.\n\t */\n\toid: string;\n}\n\n/**\n * Creates an audience member from an IClient instance.\n *\n * @param audienceMember - the client instance/\n */\nexport function createOdspAudienceMember(audienceMember: IClient): OdspMember {\n\tconst user = audienceMember.user as unknown as OdspUser;\n\tassert(\n\t\tuser.name !== undefined || user.email !== undefined || user.oid !== undefined,\n\t\t0x836 /* Provided user was not an \"OdspUser\". */,\n\t);\n\n\treturn {\n\t\tid: user.oid,\n\t\tname: user.name,\n\t\temail: user.email,\n\t\tconnections: [],\n\t};\n}\n"]}
|
package/dist/odspClient.d.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
6
|
-
import { OdspClientProps, OdspContainerServices } from "./interfaces.js";
|
|
5
|
+
import type { ContainerSchema, IFluidContainer } from "@fluidframework/fluid-static";
|
|
6
|
+
import type { OdspClientProps, OdspContainerServices } from "./interfaces.js";
|
|
7
7
|
/**
|
|
8
8
|
* OdspClient provides the ability to have a Fluid object backed by the ODSP service within the context of Microsoft 365 (M365) tenants.
|
|
9
9
|
* @sealed
|
package/dist/odspClient.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspClient.d.ts","sourceRoot":"","sources":["../src/odspClient.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAgBH,OAAO,
|
|
1
|
+
{"version":3,"file":"odspClient.d.ts","sourceRoot":"","sources":["../src/odspClient.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAgBH,OAAO,KAAK,EAEX,eAAe,EACf,eAAe,EACf,MAAM,8BAA8B,CAAC;AAmBtC,OAAO,KAAK,EACX,eAAe,EAGf,qBAAqB,EACrB,MAAM,iBAAiB,CAAC;AA2CzB;;;;GAIG;AACH,qBAAa,UAAU;IAKH,OAAO,CAAC,QAAQ,CAAC,UAAU;IAJ9C,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAA0B;IACjE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAwB;IACpD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAkC;gBAE7B,UAAU,EAAE,eAAe;IAUlD,eAAe,CAAC,CAAC,SAAS,eAAe,EACrD,eAAe,EAAE,CAAC,GAChB,OAAO,CAAC;QACV,SAAS,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;QAC9B,QAAQ,EAAE,qBAAqB,CAAC;KAChC,CAAC;IAkBW,YAAY,CAAC,CAAC,SAAS,eAAe,EAClD,EAAE,EAAE,MAAM,EACV,eAAe,EAAE,CAAC,GAChB,OAAO,CAAC;QACV,SAAS,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;QAC9B,QAAQ,EAAE,qBAAqB,CAAC;KAChC,CAAC;IAkBF,OAAO,CAAC,YAAY;YAiCN,oBAAoB;YAyCpB,oBAAoB;YASpB,sBAAsB;CAQpC"}
|
package/dist/odspClient.js
CHANGED
|
@@ -28,26 +28,13 @@ async function getWebsocketToken(options, tokenProvider) {
|
|
|
28
28
|
const odspClientFeatureGates = {
|
|
29
29
|
// None yet
|
|
30
30
|
};
|
|
31
|
-
/**
|
|
32
|
-
* Feature gates required to support runtime compatibility when V1 and V2 clients are collaborating
|
|
33
|
-
*/
|
|
34
|
-
const odspClientV1CompatFeatureGates = {
|
|
35
|
-
// Disable Garbage Collection
|
|
36
|
-
"Fluid.GarbageCollection.RunSweep": false, // To prevent the GC op
|
|
37
|
-
"Fluid.GarbageCollection.DisableAutoRecovery": true, // To prevent the GC op
|
|
38
|
-
"Fluid.GarbageCollection.ThrowOnTombstoneLoadOverride": false, // For a consistent story of "GC is disabled"
|
|
39
|
-
};
|
|
40
31
|
/**
|
|
41
32
|
* Wrap the config provider to fall back on the appropriate defaults for ODSP Client.
|
|
42
33
|
* @param baseConfigProvider - The base config provider to wrap
|
|
43
34
|
* @returns A new config provider with the appropriate defaults applied underneath the given provider
|
|
44
35
|
*/
|
|
45
36
|
function wrapConfigProvider(baseConfigProvider) {
|
|
46
|
-
|
|
47
|
-
...odspClientFeatureGates,
|
|
48
|
-
...odspClientV1CompatFeatureGates,
|
|
49
|
-
};
|
|
50
|
-
return (0, internal_5.wrapConfigProviderWithDefaults)(baseConfigProvider, defaults);
|
|
37
|
+
return (0, internal_5.wrapConfigProviderWithDefaults)(baseConfigProvider, odspClientFeatureGates);
|
|
51
38
|
}
|
|
52
39
|
/**
|
|
53
40
|
* OdspClient provides the ability to have a Fluid object backed by the ODSP service within the context of Microsoft 365 (M365) tenants.
|
package/dist/odspClient.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspClient.js","sourceRoot":"","sources":["../src/odspClient.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,iFAAoE;AAKpE,wEAAmE;AAMnE,kEAA6D;AAQ7D,oEAK+C;AAC/C,mEAM8C;AAE9C,uEAA0F;AAC1F,+BAAkC;AASlC,uDAA6D;AAG7D,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;;GAEG;AACH,MAAM,8BAA8B,GAAG;IACtC,6BAA6B;IAC7B,kCAAkC,EAAE,KAAK,EAAE,uBAAuB;IAClE,6CAA6C,EAAE,IAAI,EAAE,uBAAuB;IAC5E,sDAAsD,EAAE,KAAK,EAAE,6CAA6C;CAC5G,CAAC;AAEF;;;;GAIG;AACH,SAAS,kBAAkB,CAAC,kBAAwC;IACnE,MAAM,QAAQ,GAAG;QAChB,GAAG,sBAAsB;QACzB,GAAG,8BAA8B;KACjC,CAAC;IACF,OAAO,IAAA,yCAA8B,EAAC,kBAAkB,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qB;QACvD,OAAO;YACN,QAAQ,EAAE,IAAA,gCAAqB,EAAC;gBAC/B,SAAS;gBACT,mBAAmB,EAAE,0CAAwB;aAC7C,CAAC;SACF,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,sBAAsB,CAAC,SAAqB;QACzD,MAAM,cAAc,GAAiC,MAAM,SAAS,CAAC,aAAa,EAAE,CAAC;QACrF,IAAA,iBAAM,EACL,cAAc,CAAC,eAAe,KAAK,SAAS,EAC5C,KAAK,CAAC,gDAAgD,CACtD,CAAC;QACF,OAAO,cAAc,CAAC,eAAe,CAAC;IACvC,CAAC;CACD;AAzJD,gCAyJC","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 {\n\tIContainer,\n\tIFluidModuleWithDetails,\n} from \"@fluidframework/container-definitions/internal\";\nimport { Loader } from \"@fluidframework/container-loader/internal\";\nimport {\n\ttype FluidObject,\n\ttype IConfigProviderBase,\n\ttype IRequest,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { IClient } from \"@fluidframework/driver-definitions\";\nimport { IDocumentServiceFactory } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tContainerAttachProps,\n\ttype ContainerSchema,\n\tIFluidContainer,\n} from \"@fluidframework/fluid-static\";\nimport {\n\tIRootDataObject,\n\tcreateDOProviderContainerRuntimeFactory,\n\tcreateFluidContainer,\n\tcreateServiceAudience,\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 { TokenResponse } from \"./interfaces.js\";\nimport {\n\tOdspClientProps,\n\tOdspConnectionConfig,\n\tOdspContainerAttachProps,\n\tOdspContainerServices,\n} from \"./interfaces.js\";\nimport { createOdspAudienceMember } from \"./odspAudience.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 * Feature gates required to support runtime compatibility when V1 and V2 clients are collaborating\n */\nconst odspClientV1CompatFeatureGates = {\n\t// Disable Garbage Collection\n\t\"Fluid.GarbageCollection.RunSweep\": false, // To prevent the GC op\n\t\"Fluid.GarbageCollection.DisableAutoRecovery\": true, // To prevent the GC op\n\t\"Fluid.GarbageCollection.ThrowOnTombstoneLoadOverride\": false, // For a consistent story of \"GC is disabled\"\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\tconst defaults = {\n\t\t...odspClientFeatureGates,\n\t\t...odspClientV1CompatFeatureGates,\n\t};\n\treturn wrapConfigProviderWithDefaults(baseConfigProvider, defaults);\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\n\tpublic constructor(private readonly properties: OdspClientProps) {\n\t\tthis.documentServiceFactory = new OdspDocumentServiceFactory(\n\t\t\tasync (options) => getStorageToken(options, this.properties.connection.tokenProvider),\n\t\t\tasync (options) => getWebsocketToken(options, this.properties.connection.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: IFluidContainer<T>;\n\t\tservices: OdspContainerServices;\n\t}> {\n\t\tconst loader = this.createLoader(containerSchema);\n\n\t\tconst container = await loader.createDetachedContainer({\n\t\t\tpackage: \"no-dynamic-package\",\n\t\t\tconfig: {},\n\t\t});\n\n\t\tconst fluidContainer = await this.createFluidContainer(\n\t\t\tcontainer,\n\t\t\tthis.properties.connection,\n\t\t);\n\n\t\tconst services = await this.getContainerServices(container);\n\n\t\treturn { container: fluidContainer as IFluidContainer<T>, 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: IFluidContainer<T>;\n\t\tservices: OdspContainerServices;\n\t}> {\n\t\tconst loader = this.createLoader(containerSchema);\n\t\tconst url = createOdspUrl({\n\t\t\tsiteUrl: this.properties.connection.siteUrl,\n\t\t\tdriveId: this.properties.connection.driveId,\n\t\t\titemId: id,\n\t\t\tdataStorePath: \"\",\n\t\t});\n\t\tconst container = await loader.resolve({ url });\n\n\t\tconst fluidContainer = createFluidContainer({\n\t\t\tcontainer,\n\t\t\trootDataObject: await this.getContainerEntryPoint(container),\n\t\t});\n\t\tconst services = await this.getContainerServices(container);\n\t\treturn { container: fluidContainer as IFluidContainer<T>, services };\n\t}\n\n\tprivate createLoader(schema: ContainerSchema): Loader {\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 new Loader({\n\t\t\turlResolver: this.urlResolver,\n\t\t\tdocumentServiceFactory: this.documentServiceFactory,\n\t\t\tcodeLoader,\n\t\t\tlogger: this.properties.logger,\n\t\t\toptions: { client },\n\t\t\tconfigProvider: this.configProvider,\n\t\t});\n\t}\n\n\tprivate async createFluidContainer(\n\t\tcontainer: IContainer,\n\t\tconnection: OdspConnectionConfig,\n\t): Promise<IFluidContainer> {\n\t\tconst rootDataObject = await this.getContainerEntryPoint(container);\n\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 = createFluidContainer({ container, rootDataObject });\n\t\tfluidContainer.attach = attach;\n\t\treturn fluidContainer;\n\t}\n\n\tprivate async getContainerServices(container: IContainer): Promise<OdspContainerServices> {\n\t\treturn {\n\t\t\taudience: createServiceAudience({\n\t\t\t\tcontainer,\n\t\t\t\tcreateServiceMember: createOdspAudienceMember,\n\t\t\t}),\n\t\t};\n\t}\n\n\tprivate async getContainerEntryPoint(container: IContainer): Promise<IRootDataObject> {\n\t\tconst rootDataObject: FluidObject<IRootDataObject> = await container.getEntryPoint();\n\t\tassert(\n\t\t\trootDataObject.IRootDataObject !== undefined,\n\t\t\t0x878 /* entryPoint must be of type IRootDataObject */,\n\t\t);\n\t\treturn rootDataObject.IRootDataObject;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"odspClient.js","sourceRoot":"","sources":["../src/odspClient.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,iFAAoE;AAKpE,wEAAmE;AAMnE,kEAA6D;AAS7D,oEAI+C;AAC/C,mEAM8C;AAE9C,uEAA0F;AAC1F,+BAAkC;AASlC,uDAA6D;AAG7D,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,OA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C,IAAA,4BAAiB,EAAC,WAAW,CAAC,EAAE,CAAC;gBAClE,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;YACrE,CAAC;YAED;;;;eAIG;YACH,OAAO,WAAW,CAAC,MAAM,CAAC;QAC3B,CAAC,CAAC;QACF,MAAM,cAAc,GAAG,IAAA,+BAAoB,EAAC,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC,CAAC;QAC3E,cAAc,CAAC,MAAM,GAAG,MAAM,CAAC;QAC/B,OAAO,cAAc,CAAC;IACvB,CAAC;IAEO,KAAK,CAAC,oBAAoB,CAAC,SAAqB;QACvD,OAAO;YACN,QAAQ,EAAE,IAAA,gCAAqB,EAAC;gBAC/B,SAAS;gBACT,mBAAmB,EAAE,0CAAwB;aAC7C,CAAC;SACF,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,sBAAsB,CAAC,SAAqB;QACzD,MAAM,cAAc,GAAiC,MAAM,SAAS,CAAC,aAAa,EAAE,CAAC;QACrF,IAAA,iBAAM,EACL,cAAc,CAAC,eAAe,KAAK,SAAS,EAC5C,KAAK,CAAC,gDAAgD,CACtD,CAAC;QACF,OAAO,cAAc,CAAC,eAAe,CAAC;IACvC,CAAC;CACD;AAzJD,gCAyJC","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 { Loader } from \"@fluidframework/container-loader/internal\";\nimport {\n\ttype FluidObject,\n\ttype IConfigProviderBase,\n\ttype IRequest,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IClient } from \"@fluidframework/driver-definitions\";\nimport type { IDocumentServiceFactory } from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tContainerAttachProps,\n\tContainerSchema,\n\tIFluidContainer,\n} from \"@fluidframework/fluid-static\";\nimport type { IRootDataObject } from \"@fluidframework/fluid-static/internal\";\nimport {\n\tcreateDOProviderContainerRuntimeFactory,\n\tcreateFluidContainer,\n\tcreateServiceAudience,\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 { TokenResponse } from \"./interfaces.js\";\nimport type {\n\tOdspClientProps,\n\tOdspConnectionConfig,\n\tOdspContainerAttachProps,\n\tOdspContainerServices,\n} from \"./interfaces.js\";\nimport { createOdspAudienceMember } from \"./odspAudience.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\n\tpublic constructor(private readonly properties: OdspClientProps) {\n\t\tthis.documentServiceFactory = new OdspDocumentServiceFactory(\n\t\t\tasync (options) => getStorageToken(options, this.properties.connection.tokenProvider),\n\t\t\tasync (options) => getWebsocketToken(options, this.properties.connection.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: IFluidContainer<T>;\n\t\tservices: OdspContainerServices;\n\t}> {\n\t\tconst loader = this.createLoader(containerSchema);\n\n\t\tconst container = await loader.createDetachedContainer({\n\t\t\tpackage: \"no-dynamic-package\",\n\t\t\tconfig: {},\n\t\t});\n\n\t\tconst fluidContainer = await this.createFluidContainer(\n\t\t\tcontainer,\n\t\t\tthis.properties.connection,\n\t\t);\n\n\t\tconst services = await this.getContainerServices(container);\n\n\t\treturn { container: fluidContainer as IFluidContainer<T>, 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: IFluidContainer<T>;\n\t\tservices: OdspContainerServices;\n\t}> {\n\t\tconst loader = this.createLoader(containerSchema);\n\t\tconst url = createOdspUrl({\n\t\t\tsiteUrl: this.properties.connection.siteUrl,\n\t\t\tdriveId: this.properties.connection.driveId,\n\t\t\titemId: id,\n\t\t\tdataStorePath: \"\",\n\t\t});\n\t\tconst container = await loader.resolve({ url });\n\n\t\tconst fluidContainer = createFluidContainer({\n\t\t\tcontainer,\n\t\t\trootDataObject: await this.getContainerEntryPoint(container),\n\t\t});\n\t\tconst services = await this.getContainerServices(container);\n\t\treturn { container: fluidContainer as IFluidContainer<T>, services };\n\t}\n\n\tprivate createLoader(schema: ContainerSchema): Loader {\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 new Loader({\n\t\t\turlResolver: this.urlResolver,\n\t\t\tdocumentServiceFactory: this.documentServiceFactory,\n\t\t\tcodeLoader,\n\t\t\tlogger: this.properties.logger,\n\t\t\toptions: { client },\n\t\t\tconfigProvider: this.configProvider,\n\t\t});\n\t}\n\n\tprivate async createFluidContainer(\n\t\tcontainer: IContainer,\n\t\tconnection: OdspConnectionConfig,\n\t): Promise<IFluidContainer> {\n\t\tconst rootDataObject = await this.getContainerEntryPoint(container);\n\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 = createFluidContainer({ container, rootDataObject });\n\t\tfluidContainer.attach = attach;\n\t\treturn fluidContainer;\n\t}\n\n\tprivate async getContainerServices(container: IContainer): Promise<OdspContainerServices> {\n\t\treturn {\n\t\t\taudience: createServiceAudience({\n\t\t\t\tcontainer,\n\t\t\t\tcreateServiceMember: createOdspAudienceMember,\n\t\t\t}),\n\t\t};\n\t}\n\n\tprivate async getContainerEntryPoint(container: IContainer): Promise<IRootDataObject> {\n\t\tconst rootDataObject: FluidObject<IRootDataObject> = await container.getEntryPoint();\n\t\tassert(\n\t\t\trootDataObject.IRootDataObject !== undefined,\n\t\t\t0x878 /* entryPoint must be of type IRootDataObject */,\n\t\t);\n\t\treturn rootDataObject.IRootDataObject;\n\t}\n}\n"]}
|
package/lib/interfaces.d.ts
CHANGED
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
6
|
-
import { IConfigProviderBase } from "@fluidframework/core-interfaces";
|
|
5
|
+
import type { IConfigProviderBase, ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
|
|
7
6
|
import type { IMember, IServiceAudience } from "@fluidframework/fluid-static";
|
|
8
|
-
import { IOdspTokenProvider } from "./token.js";
|
|
7
|
+
import type { IOdspTokenProvider } from "./token.js";
|
|
9
8
|
/**
|
|
10
9
|
* Defines the necessary properties that will be applied to all containers
|
|
11
10
|
* created by an OdspClient instance. This includes callbacks for the authentication tokens
|
|
@@ -48,6 +47,7 @@ export interface OdspClientProps {
|
|
|
48
47
|
readonly configProvider?: IConfigProviderBase;
|
|
49
48
|
}
|
|
50
49
|
/**
|
|
50
|
+
* @legacy
|
|
51
51
|
* @alpha
|
|
52
52
|
*/
|
|
53
53
|
export interface OdspContainerAttachProps {
|
package/lib/interfaces.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,mBAAmB,EACnB,oBAAoB,EACpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAE9E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACpC;;OAEG;IACH,aAAa,EAAE,kBAAkB,CAAC;IAElC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;CACjB;AACD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,oBAAoB,CAAC;IAE1C;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAEvC;;OAEG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,mBAAmB,CAAC;CAC9C;AAED;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACxC;;OAEG;IACH,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAE7B;;OAEG;IACH,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,qBAAqB;IACrC;;OAEG;IACH,QAAQ,EAAE,aAAa,CAAC;CACxB;AAED;;;;;GAKG;AACH,MAAM,WAAW,UAAW,SAAQ,OAAO;IAC1C;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;AAEzD;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC7B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACpB"}
|
package/lib/interfaces.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tIConfigProviderBase,\n\tITelemetryBaseLogger,\n} from \"@fluidframework/core-interfaces\";\nimport type { IMember, IServiceAudience } from \"@fluidframework/fluid-static\";\n\nimport type { IOdspTokenProvider } from \"./token.js\";\n\n/**\n * Defines the necessary properties that will be applied to all containers\n * created by an OdspClient instance. This includes callbacks for the authentication tokens\n * required for ODSP.\n * @beta\n */\nexport interface OdspConnectionConfig {\n\t/**\n\t * Instance that provides AAD endpoint tokens for Push and SharePoint\n\t */\n\ttokenProvider: IOdspTokenProvider;\n\n\t/**\n\t * Site url representing ODSP resource location. It points to the specific SharePoint site where you can store and access the containers you create.\n\t */\n\tsiteUrl: string;\n\n\t/**\n\t * SharePoint Embedded Container Id of the tenant where Fluid containers are created\n\t */\n\tdriveId: string;\n\n\t/**\n\t * Specifies the file path where Fluid files are created. If passed an empty string, the Fluid files will be created at the root level.\n\t */\n\tfilePath: string;\n}\n/**\n * @beta\n */\nexport interface OdspClientProps {\n\t/**\n\t * Configuration for establishing a connection with the ODSP Fluid Service (Push).\n\t */\n\treadonly connection: OdspConnectionConfig;\n\n\t/**\n\t * Optional. A logger instance to receive diagnostic messages.\n\t */\n\treadonly logger?: ITelemetryBaseLogger;\n\n\t/**\n\t * Base interface for providing configurations to control experimental features. If unsure, leave this undefined.\n\t */\n\treadonly configProvider?: IConfigProviderBase;\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport interface OdspContainerAttachProps {\n\t/**\n\t * The file path where Fluid containers are created. If undefined, the file is created at the root.\n\t */\n\tfilePath: string | undefined;\n\n\t/**\n\t * The file name of the Fluid file. If undefined, the file is named with a GUID.\n\t */\n\tfileName: string | undefined;\n}\n\n/**\n * OdspContainerServices is returned by the OdspClient alongside a FluidContainer. It holds the\n * functionality specifically tied to the ODSP service, and how the data stored in the\n * FluidContainer is persisted in the backend and consumed by users. Any functionality regarding\n * how the data is handled within the FluidContainer itself, i.e. which data objects or DDSes to\n * use, will not be included here but rather on the FluidContainer class itself.\n * @beta\n */\nexport interface OdspContainerServices {\n\t/**\n\t * Provides an object that facilitates obtaining information about users present in the Fluid session, as well as listeners for roster changes triggered by users joining or leaving the session.\n\t */\n\taudience: IOdspAudience;\n}\n\n/**\n * Since ODSP provides user names and email for all of its members, we extend the\n * {@link @fluidframework/fluid-static#IMember} interface to include this service-specific value.\n * It will be returned for all audience members connected.\n * @beta\n */\nexport interface OdspMember extends IMember {\n\t/**\n\t * The object ID (oid) for the user, unique among each individual user connecting to the session.\n\t */\n\tid: string;\n\t/**\n\t * The user's name\n\t */\n\tname: string;\n\t/**\n\t * The user's email\n\t */\n\temail: string;\n}\n\n/**\n * Audience object for ODSP containers\n * @beta\n */\nexport type IOdspAudience = IServiceAudience<OdspMember>;\n\n/**\n * Represents token response\n * @beta\n */\nexport interface TokenResponse {\n\t/**\n\t * Token value\n\t */\n\ttoken: string;\n\n\t/**\n\t * Whether or not the token was obtained from local cache.\n\t * @remarks `undefined` indicates that it could not be determined whether or not the token was obtained this way.\n\t */\n\tfromCache?: boolean;\n}\n"]}
|
package/lib/odspAudience.d.ts
CHANGED
|
@@ -4,5 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { type IClient } from "@fluidframework/driver-definitions";
|
|
6
6
|
import { type OdspMember } from "./interfaces.js";
|
|
7
|
+
/**
|
|
8
|
+
* Creates an audience member from an IClient instance.
|
|
9
|
+
*
|
|
10
|
+
* @param audienceMember - the client instance/
|
|
11
|
+
*/
|
|
7
12
|
export declare function createOdspAudienceMember(audienceMember: IClient): OdspMember;
|
|
8
13
|
//# sourceMappingURL=odspAudience.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspAudience.d.ts","sourceRoot":"","sources":["../src/odspAudience.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAElE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAsBlD,wBAAgB,wBAAwB,CAAC,cAAc,EAAE,OAAO,GAAG,UAAU,CAa5E"}
|
|
1
|
+
{"version":3,"file":"odspAudience.d.ts","sourceRoot":"","sources":["../src/odspAudience.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAElE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAsBlD;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,cAAc,EAAE,OAAO,GAAG,UAAU,CAa5E"}
|
package/lib/odspAudience.js
CHANGED
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
6
|
+
/**
|
|
7
|
+
* Creates an audience member from an IClient instance.
|
|
8
|
+
*
|
|
9
|
+
* @param audienceMember - the client instance/
|
|
10
|
+
*/
|
|
6
11
|
export function createOdspAudienceMember(audienceMember) {
|
|
7
12
|
const user = audienceMember.user;
|
|
8
13
|
assert(user.name !== undefined || user.email !== undefined || user.oid !== undefined, 0x836 /* Provided user was not an "OdspUser". */);
|
package/lib/odspAudience.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspAudience.js","sourceRoot":"","sources":["../src/odspAudience.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAyB7D,MAAM,UAAU,wBAAwB,CAAC,cAAuB;IAC/D,MAAM,IAAI,GAAG,cAAc,CAAC,IAA2B,CAAC;IACxD,MAAM,CACL,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,IAAI,IAAI,CAAC,GAAG,KAAK,SAAS,EAC7E,KAAK,CAAC,0CAA0C,CAChD,CAAC;IAEF,OAAO;QACN,EAAE,EAAE,IAAI,CAAC,GAAG;QACZ,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,WAAW,EAAE,EAAE;KACf,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { type IClient } from \"@fluidframework/driver-definitions\";\n\nimport { type OdspMember } from \"./interfaces.js\";\n\n/**\n * Since ODSP provides user names, email and oids for all of its members, we extend the\n * {@link @fluidframework/fluid-static#IMember} interface to include this service-specific value.\n * @internal\n */\ninterface OdspUser {\n\t/**\n\t * The user's email address\n\t */\n\temail: string;\n\t/**\n\t * The user's name\n\t */\n\tname: string;\n\t/**\n\t * The object ID (oid). It is a unique identifier assigned to each user, group, or other entity within AAD or another Microsoft 365 service. It is a GUID that uniquely identifies the object. When making Microsoft Graph API calls, you might need to reference or manipulate objects within the directory, and the `oid` is used to identify these objects.\n\t */\n\toid: string;\n}\n\nexport function createOdspAudienceMember(audienceMember: IClient): OdspMember {\n\tconst user = audienceMember.user as unknown as OdspUser;\n\tassert(\n\t\tuser.name !== undefined || user.email !== undefined || user.oid !== undefined,\n\t\t0x836 /* Provided user was not an \"OdspUser\". */,\n\t);\n\n\treturn {\n\t\tid: user.oid,\n\t\tname: user.name,\n\t\temail: user.email,\n\t\tconnections: [],\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"odspAudience.js","sourceRoot":"","sources":["../src/odspAudience.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAyB7D;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CAAC,cAAuB;IAC/D,MAAM,IAAI,GAAG,cAAc,CAAC,IAA2B,CAAC;IACxD,MAAM,CACL,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,IAAI,IAAI,CAAC,GAAG,KAAK,SAAS,EAC7E,KAAK,CAAC,0CAA0C,CAChD,CAAC;IAEF,OAAO;QACN,EAAE,EAAE,IAAI,CAAC,GAAG;QACZ,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,WAAW,EAAE,EAAE;KACf,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { type IClient } from \"@fluidframework/driver-definitions\";\n\nimport { type OdspMember } from \"./interfaces.js\";\n\n/**\n * Since ODSP provides user names, email and oids for all of its members, we extend the\n * {@link @fluidframework/fluid-static#IMember} interface to include this service-specific value.\n * @internal\n */\ninterface OdspUser {\n\t/**\n\t * The user's email address\n\t */\n\temail: string;\n\t/**\n\t * The user's name\n\t */\n\tname: string;\n\t/**\n\t * The object ID (oid). It is a unique identifier assigned to each user, group, or other entity within AAD or another Microsoft 365 service. It is a GUID that uniquely identifies the object. When making Microsoft Graph API calls, you might need to reference or manipulate objects within the directory, and the `oid` is used to identify these objects.\n\t */\n\toid: string;\n}\n\n/**\n * Creates an audience member from an IClient instance.\n *\n * @param audienceMember - the client instance/\n */\nexport function createOdspAudienceMember(audienceMember: IClient): OdspMember {\n\tconst user = audienceMember.user as unknown as OdspUser;\n\tassert(\n\t\tuser.name !== undefined || user.email !== undefined || user.oid !== undefined,\n\t\t0x836 /* Provided user was not an \"OdspUser\". */,\n\t);\n\n\treturn {\n\t\tid: user.oid,\n\t\tname: user.name,\n\t\temail: user.email,\n\t\tconnections: [],\n\t};\n}\n"]}
|
package/lib/odspClient.d.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
6
|
-
import { OdspClientProps, OdspContainerServices } from "./interfaces.js";
|
|
5
|
+
import type { ContainerSchema, IFluidContainer } from "@fluidframework/fluid-static";
|
|
6
|
+
import type { OdspClientProps, OdspContainerServices } from "./interfaces.js";
|
|
7
7
|
/**
|
|
8
8
|
* OdspClient provides the ability to have a Fluid object backed by the ODSP service within the context of Microsoft 365 (M365) tenants.
|
|
9
9
|
* @sealed
|
package/lib/odspClient.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspClient.d.ts","sourceRoot":"","sources":["../src/odspClient.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAgBH,OAAO,
|
|
1
|
+
{"version":3,"file":"odspClient.d.ts","sourceRoot":"","sources":["../src/odspClient.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAgBH,OAAO,KAAK,EAEX,eAAe,EACf,eAAe,EACf,MAAM,8BAA8B,CAAC;AAmBtC,OAAO,KAAK,EACX,eAAe,EAGf,qBAAqB,EACrB,MAAM,iBAAiB,CAAC;AA2CzB;;;;GAIG;AACH,qBAAa,UAAU;IAKH,OAAO,CAAC,QAAQ,CAAC,UAAU;IAJ9C,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAA0B;IACjE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAwB;IACpD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAkC;gBAE7B,UAAU,EAAE,eAAe;IAUlD,eAAe,CAAC,CAAC,SAAS,eAAe,EACrD,eAAe,EAAE,CAAC,GAChB,OAAO,CAAC;QACV,SAAS,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;QAC9B,QAAQ,EAAE,qBAAqB,CAAC;KAChC,CAAC;IAkBW,YAAY,CAAC,CAAC,SAAS,eAAe,EAClD,EAAE,EAAE,MAAM,EACV,eAAe,EAAE,CAAC,GAChB,OAAO,CAAC;QACV,SAAS,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;QAC9B,QAAQ,EAAE,qBAAqB,CAAC;KAChC,CAAC;IAkBF,OAAO,CAAC,YAAY;YAiCN,oBAAoB;YAyCpB,oBAAoB;YASpB,sBAAsB;CAQpC"}
|
package/lib/odspClient.js
CHANGED
|
@@ -25,26 +25,13 @@ async function getWebsocketToken(options, tokenProvider) {
|
|
|
25
25
|
const odspClientFeatureGates = {
|
|
26
26
|
// None yet
|
|
27
27
|
};
|
|
28
|
-
/**
|
|
29
|
-
* Feature gates required to support runtime compatibility when V1 and V2 clients are collaborating
|
|
30
|
-
*/
|
|
31
|
-
const odspClientV1CompatFeatureGates = {
|
|
32
|
-
// Disable Garbage Collection
|
|
33
|
-
"Fluid.GarbageCollection.RunSweep": false, // To prevent the GC op
|
|
34
|
-
"Fluid.GarbageCollection.DisableAutoRecovery": true, // To prevent the GC op
|
|
35
|
-
"Fluid.GarbageCollection.ThrowOnTombstoneLoadOverride": false, // For a consistent story of "GC is disabled"
|
|
36
|
-
};
|
|
37
28
|
/**
|
|
38
29
|
* Wrap the config provider to fall back on the appropriate defaults for ODSP Client.
|
|
39
30
|
* @param baseConfigProvider - The base config provider to wrap
|
|
40
31
|
* @returns A new config provider with the appropriate defaults applied underneath the given provider
|
|
41
32
|
*/
|
|
42
33
|
function wrapConfigProvider(baseConfigProvider) {
|
|
43
|
-
|
|
44
|
-
...odspClientFeatureGates,
|
|
45
|
-
...odspClientV1CompatFeatureGates,
|
|
46
|
-
};
|
|
47
|
-
return wrapConfigProviderWithDefaults(baseConfigProvider, defaults);
|
|
34
|
+
return wrapConfigProviderWithDefaults(baseConfigProvider, odspClientFeatureGates);
|
|
48
35
|
}
|
|
49
36
|
/**
|
|
50
37
|
* OdspClient provides the ability to have a Fluid object backed by the ODSP service within the context of Microsoft 365 (M365) tenants.
|
package/lib/odspClient.js.map
CHANGED
|
@@ -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,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAMnE,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAQ7D,OAAO,EAEN,uCAAuC,EACvC,oBAAoB,EACpB,qBAAqB,GACrB,M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qB;QACzD,MAAM,cAAc,GAAiC,MAAM,SAAS,CAAC,aAAa,EAAE,CAAC;QACrF,MAAM,CACL,cAAc,CAAC,eAAe,KAAK,SAAS,EAC5C,KAAK,CAAC,gDAAgD,CACtD,CAAC;QACF,OAAO,cAAc,CAAC,eAAe,CAAC;IACvC,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 {\n\tIContainer,\n\tIFluidModuleWithDetails,\n} from \"@fluidframework/container-definitions/internal\";\nimport { Loader } from \"@fluidframework/container-loader/internal\";\nimport {\n\ttype FluidObject,\n\ttype IConfigProviderBase,\n\ttype IRequest,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { IClient } from \"@fluidframework/driver-definitions\";\nimport { IDocumentServiceFactory } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tContainerAttachProps,\n\ttype ContainerSchema,\n\tIFluidContainer,\n} from \"@fluidframework/fluid-static\";\nimport {\n\tIRootDataObject,\n\tcreateDOProviderContainerRuntimeFactory,\n\tcreateFluidContainer,\n\tcreateServiceAudience,\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 { TokenResponse } from \"./interfaces.js\";\nimport {\n\tOdspClientProps,\n\tOdspConnectionConfig,\n\tOdspContainerAttachProps,\n\tOdspContainerServices,\n} from \"./interfaces.js\";\nimport { createOdspAudienceMember } from \"./odspAudience.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 * Feature gates required to support runtime compatibility when V1 and V2 clients are collaborating\n */\nconst odspClientV1CompatFeatureGates = {\n\t// Disable Garbage Collection\n\t\"Fluid.GarbageCollection.RunSweep\": false, // To prevent the GC op\n\t\"Fluid.GarbageCollection.DisableAutoRecovery\": true, // To prevent the GC op\n\t\"Fluid.GarbageCollection.ThrowOnTombstoneLoadOverride\": false, // For a consistent story of \"GC is disabled\"\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\tconst defaults = {\n\t\t...odspClientFeatureGates,\n\t\t...odspClientV1CompatFeatureGates,\n\t};\n\treturn wrapConfigProviderWithDefaults(baseConfigProvider, defaults);\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\n\tpublic constructor(private readonly properties: OdspClientProps) {\n\t\tthis.documentServiceFactory = new OdspDocumentServiceFactory(\n\t\t\tasync (options) => getStorageToken(options, this.properties.connection.tokenProvider),\n\t\t\tasync (options) => getWebsocketToken(options, this.properties.connection.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: IFluidContainer<T>;\n\t\tservices: OdspContainerServices;\n\t}> {\n\t\tconst loader = this.createLoader(containerSchema);\n\n\t\tconst container = await loader.createDetachedContainer({\n\t\t\tpackage: \"no-dynamic-package\",\n\t\t\tconfig: {},\n\t\t});\n\n\t\tconst fluidContainer = await this.createFluidContainer(\n\t\t\tcontainer,\n\t\t\tthis.properties.connection,\n\t\t);\n\n\t\tconst services = await this.getContainerServices(container);\n\n\t\treturn { container: fluidContainer as IFluidContainer<T>, 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: IFluidContainer<T>;\n\t\tservices: OdspContainerServices;\n\t}> {\n\t\tconst loader = this.createLoader(containerSchema);\n\t\tconst url = createOdspUrl({\n\t\t\tsiteUrl: this.properties.connection.siteUrl,\n\t\t\tdriveId: this.properties.connection.driveId,\n\t\t\titemId: id,\n\t\t\tdataStorePath: \"\",\n\t\t});\n\t\tconst container = await loader.resolve({ url });\n\n\t\tconst fluidContainer = createFluidContainer({\n\t\t\tcontainer,\n\t\t\trootDataObject: await this.getContainerEntryPoint(container),\n\t\t});\n\t\tconst services = await this.getContainerServices(container);\n\t\treturn { container: fluidContainer as IFluidContainer<T>, services };\n\t}\n\n\tprivate createLoader(schema: ContainerSchema): Loader {\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 new Loader({\n\t\t\turlResolver: this.urlResolver,\n\t\t\tdocumentServiceFactory: this.documentServiceFactory,\n\t\t\tcodeLoader,\n\t\t\tlogger: this.properties.logger,\n\t\t\toptions: { client },\n\t\t\tconfigProvider: this.configProvider,\n\t\t});\n\t}\n\n\tprivate async createFluidContainer(\n\t\tcontainer: IContainer,\n\t\tconnection: OdspConnectionConfig,\n\t): Promise<IFluidContainer> {\n\t\tconst rootDataObject = await this.getContainerEntryPoint(container);\n\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 = createFluidContainer({ container, rootDataObject });\n\t\tfluidContainer.attach = attach;\n\t\treturn fluidContainer;\n\t}\n\n\tprivate async getContainerServices(container: IContainer): Promise<OdspContainerServices> {\n\t\treturn {\n\t\t\taudience: createServiceAudience({\n\t\t\t\tcontainer,\n\t\t\t\tcreateServiceMember: createOdspAudienceMember,\n\t\t\t}),\n\t\t};\n\t}\n\n\tprivate async getContainerEntryPoint(container: IContainer): Promise<IRootDataObject> {\n\t\tconst rootDataObject: FluidObject<IRootDataObject> = await container.getEntryPoint();\n\t\tassert(\n\t\t\trootDataObject.IRootDataObject !== undefined,\n\t\t\t0x878 /* entryPoint must be of type IRootDataObject */,\n\t\t);\n\t\treturn rootDataObject.IRootDataObject;\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,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAMnE,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAS7D,OAAO,EACN,uCAAuC,EACvC,oBAAoB,EACpB,qBAAqB,GACrB,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;AASlC,OAAO,EAAE,wBAAwB,E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AAC;YAChF,CAAC;YACD,MAAM,SAAS,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;YAEzC,MAAM,WAAW,GAAG,SAAS,CAAC,WAAW,CAAC;YAE1C,IAAI,WAAW,KAAK,SAAS,IAAI,CAAC,iBAAiB,CAAC,WAAW,CAAC,EAAE,CAAC;gBAClE,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;YACrE,CAAC;YAED;;;;eAIG;YACH,OAAO,WAAW,CAAC,MAAM,CAAC;QAC3B,CAAC,CAAC;QACF,MAAM,cAAc,GAAG,oBAAoB,CAAC,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC,CAAC;QAC3E,cAAc,CAAC,MAAM,GAAG,MAAM,CAAC;QAC/B,OAAO,cAAc,CAAC;IACvB,CAAC;IAEO,KAAK,CAAC,oBAAoB,CAAC,SAAqB;QACvD,OAAO;YACN,QAAQ,EAAE,qBAAqB,CAAC;gBAC/B,SAAS;gBACT,mBAAmB,EAAE,wBAAwB;aAC7C,CAAC;SACF,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,sBAAsB,CAAC,SAAqB;QACzD,MAAM,cAAc,GAAiC,MAAM,SAAS,CAAC,aAAa,EAAE,CAAC;QACrF,MAAM,CACL,cAAc,CAAC,eAAe,KAAK,SAAS,EAC5C,KAAK,CAAC,gDAAgD,CACtD,CAAC;QACF,OAAO,cAAc,CAAC,eAAe,CAAC;IACvC,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 { Loader } from \"@fluidframework/container-loader/internal\";\nimport {\n\ttype FluidObject,\n\ttype IConfigProviderBase,\n\ttype IRequest,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IClient } from \"@fluidframework/driver-definitions\";\nimport type { IDocumentServiceFactory } from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tContainerAttachProps,\n\tContainerSchema,\n\tIFluidContainer,\n} from \"@fluidframework/fluid-static\";\nimport type { IRootDataObject } from \"@fluidframework/fluid-static/internal\";\nimport {\n\tcreateDOProviderContainerRuntimeFactory,\n\tcreateFluidContainer,\n\tcreateServiceAudience,\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 { TokenResponse } from \"./interfaces.js\";\nimport type {\n\tOdspClientProps,\n\tOdspConnectionConfig,\n\tOdspContainerAttachProps,\n\tOdspContainerServices,\n} from \"./interfaces.js\";\nimport { createOdspAudienceMember } from \"./odspAudience.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\n\tpublic constructor(private readonly properties: OdspClientProps) {\n\t\tthis.documentServiceFactory = new OdspDocumentServiceFactory(\n\t\t\tasync (options) => getStorageToken(options, this.properties.connection.tokenProvider),\n\t\t\tasync (options) => getWebsocketToken(options, this.properties.connection.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: IFluidContainer<T>;\n\t\tservices: OdspContainerServices;\n\t}> {\n\t\tconst loader = this.createLoader(containerSchema);\n\n\t\tconst container = await loader.createDetachedContainer({\n\t\t\tpackage: \"no-dynamic-package\",\n\t\t\tconfig: {},\n\t\t});\n\n\t\tconst fluidContainer = await this.createFluidContainer(\n\t\t\tcontainer,\n\t\t\tthis.properties.connection,\n\t\t);\n\n\t\tconst services = await this.getContainerServices(container);\n\n\t\treturn { container: fluidContainer as IFluidContainer<T>, 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: IFluidContainer<T>;\n\t\tservices: OdspContainerServices;\n\t}> {\n\t\tconst loader = this.createLoader(containerSchema);\n\t\tconst url = createOdspUrl({\n\t\t\tsiteUrl: this.properties.connection.siteUrl,\n\t\t\tdriveId: this.properties.connection.driveId,\n\t\t\titemId: id,\n\t\t\tdataStorePath: \"\",\n\t\t});\n\t\tconst container = await loader.resolve({ url });\n\n\t\tconst fluidContainer = createFluidContainer({\n\t\t\tcontainer,\n\t\t\trootDataObject: await this.getContainerEntryPoint(container),\n\t\t});\n\t\tconst services = await this.getContainerServices(container);\n\t\treturn { container: fluidContainer as IFluidContainer<T>, services };\n\t}\n\n\tprivate createLoader(schema: ContainerSchema): Loader {\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 new Loader({\n\t\t\turlResolver: this.urlResolver,\n\t\t\tdocumentServiceFactory: this.documentServiceFactory,\n\t\t\tcodeLoader,\n\t\t\tlogger: this.properties.logger,\n\t\t\toptions: { client },\n\t\t\tconfigProvider: this.configProvider,\n\t\t});\n\t}\n\n\tprivate async createFluidContainer(\n\t\tcontainer: IContainer,\n\t\tconnection: OdspConnectionConfig,\n\t): Promise<IFluidContainer> {\n\t\tconst rootDataObject = await this.getContainerEntryPoint(container);\n\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 = createFluidContainer({ container, rootDataObject });\n\t\tfluidContainer.attach = attach;\n\t\treturn fluidContainer;\n\t}\n\n\tprivate async getContainerServices(container: IContainer): Promise<OdspContainerServices> {\n\t\treturn {\n\t\t\taudience: createServiceAudience({\n\t\t\t\tcontainer,\n\t\t\t\tcreateServiceMember: createOdspAudienceMember,\n\t\t\t}),\n\t\t};\n\t}\n\n\tprivate async getContainerEntryPoint(container: IContainer): Promise<IRootDataObject> {\n\t\tconst rootDataObject: FluidObject<IRootDataObject> = await container.getEntryPoint();\n\t\tassert(\n\t\t\trootDataObject.IRootDataObject !== undefined,\n\t\t\t0x878 /* entryPoint must be of type IRootDataObject */,\n\t\t);\n\t\treturn rootDataObject.IRootDataObject;\n\t}\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/odsp-client",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0-276326",
|
|
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": {
|
|
@@ -67,28 +67,28 @@
|
|
|
67
67
|
"temp-directory": "nyc/.nyc_output"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@fluidframework/container-definitions": "
|
|
71
|
-
"@fluidframework/container-loader": "
|
|
72
|
-
"@fluidframework/core-interfaces": "
|
|
73
|
-
"@fluidframework/core-utils": "
|
|
74
|
-
"@fluidframework/driver-definitions": "
|
|
75
|
-
"@fluidframework/fluid-static": "
|
|
76
|
-
"@fluidframework/map": "
|
|
77
|
-
"@fluidframework/odsp-doclib-utils": "
|
|
78
|
-
"@fluidframework/odsp-driver": "
|
|
79
|
-
"@fluidframework/odsp-driver-definitions": "
|
|
80
|
-
"@fluidframework/telemetry-utils": "
|
|
70
|
+
"@fluidframework/container-definitions": "2.1.0-276326",
|
|
71
|
+
"@fluidframework/container-loader": "2.1.0-276326",
|
|
72
|
+
"@fluidframework/core-interfaces": "2.1.0-276326",
|
|
73
|
+
"@fluidframework/core-utils": "2.1.0-276326",
|
|
74
|
+
"@fluidframework/driver-definitions": "2.1.0-276326",
|
|
75
|
+
"@fluidframework/fluid-static": "2.1.0-276326",
|
|
76
|
+
"@fluidframework/map": "2.1.0-276326",
|
|
77
|
+
"@fluidframework/odsp-doclib-utils": "2.1.0-276326",
|
|
78
|
+
"@fluidframework/odsp-driver": "2.1.0-276326",
|
|
79
|
+
"@fluidframework/odsp-driver-definitions": "2.1.0-276326",
|
|
80
|
+
"@fluidframework/telemetry-utils": "2.1.0-276326",
|
|
81
81
|
"uuid": "^9.0.0"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
84
|
"@arethetypeswrong/cli": "^0.15.2",
|
|
85
85
|
"@biomejs/biome": "^1.7.3",
|
|
86
|
-
"@fluid-internal/mocha-test-setup": "
|
|
86
|
+
"@fluid-internal/mocha-test-setup": "2.1.0-276326",
|
|
87
87
|
"@fluid-tools/build-cli": "^0.39.0",
|
|
88
88
|
"@fluidframework/build-common": "^2.0.3",
|
|
89
89
|
"@fluidframework/build-tools": "^0.39.0",
|
|
90
90
|
"@fluidframework/eslint-config-fluid": "^5.3.0",
|
|
91
|
-
"@fluidframework/test-utils": "
|
|
91
|
+
"@fluidframework/test-utils": "2.1.0-276326",
|
|
92
92
|
"@microsoft/api-extractor": "^7.45.1",
|
|
93
93
|
"@types/mocha": "^9.1.1",
|
|
94
94
|
"@types/node": "^18.19.0",
|
|
@@ -109,8 +109,8 @@
|
|
|
109
109
|
},
|
|
110
110
|
"scripts": {
|
|
111
111
|
"api": "fluid-build . --task api",
|
|
112
|
-
"api-extractor:commonjs": "flub generate entrypoints --
|
|
113
|
-
"api-extractor:esnext": "flub generate entrypoints --
|
|
112
|
+
"api-extractor:commonjs": "flub generate entrypoints --outDir ./dist",
|
|
113
|
+
"api-extractor:esnext": "flub generate entrypoints --outDir ./lib --node10TypeCompat",
|
|
114
114
|
"build": "fluid-build . --task build",
|
|
115
115
|
"build:commonjs": "fluid-build . --task commonjs",
|
|
116
116
|
"build:compile": "fluid-build . --task compile",
|
package/src/interfaces.ts
CHANGED
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import
|
|
7
|
-
|
|
6
|
+
import type {
|
|
7
|
+
IConfigProviderBase,
|
|
8
|
+
ITelemetryBaseLogger,
|
|
9
|
+
} from "@fluidframework/core-interfaces";
|
|
8
10
|
import type { IMember, IServiceAudience } from "@fluidframework/fluid-static";
|
|
9
11
|
|
|
10
|
-
import { IOdspTokenProvider } from "./token.js";
|
|
12
|
+
import type { IOdspTokenProvider } from "./token.js";
|
|
11
13
|
|
|
12
14
|
/**
|
|
13
15
|
* Defines the necessary properties that will be applied to all containers
|
|
@@ -57,6 +59,7 @@ export interface OdspClientProps {
|
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
/**
|
|
62
|
+
* @legacy
|
|
60
63
|
* @alpha
|
|
61
64
|
*/
|
|
62
65
|
export interface OdspContainerAttachProps {
|
package/src/odspAudience.ts
CHANGED
|
@@ -28,6 +28,11 @@ interface OdspUser {
|
|
|
28
28
|
oid: string;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Creates an audience member from an IClient instance.
|
|
33
|
+
*
|
|
34
|
+
* @param audienceMember - the client instance/
|
|
35
|
+
*/
|
|
31
36
|
export function createOdspAudienceMember(audienceMember: IClient): OdspMember {
|
|
32
37
|
const user = audienceMember.user as unknown as OdspUser;
|
|
33
38
|
assert(
|
package/src/odspClient.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { AttachState } from "@fluidframework/container-definitions";
|
|
7
|
-
import {
|
|
7
|
+
import type {
|
|
8
8
|
IContainer,
|
|
9
9
|
IFluidModuleWithDetails,
|
|
10
10
|
} from "@fluidframework/container-definitions/internal";
|
|
@@ -15,15 +15,15 @@ import {
|
|
|
15
15
|
type IRequest,
|
|
16
16
|
} from "@fluidframework/core-interfaces";
|
|
17
17
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
18
|
-
import { IClient } from "@fluidframework/driver-definitions";
|
|
19
|
-
import { IDocumentServiceFactory } from "@fluidframework/driver-definitions/internal";
|
|
20
|
-
import {
|
|
18
|
+
import type { IClient } from "@fluidframework/driver-definitions";
|
|
19
|
+
import type { IDocumentServiceFactory } from "@fluidframework/driver-definitions/internal";
|
|
20
|
+
import type {
|
|
21
21
|
ContainerAttachProps,
|
|
22
|
-
|
|
22
|
+
ContainerSchema,
|
|
23
23
|
IFluidContainer,
|
|
24
24
|
} from "@fluidframework/fluid-static";
|
|
25
|
+
import type { IRootDataObject } from "@fluidframework/fluid-static/internal";
|
|
25
26
|
import {
|
|
26
|
-
IRootDataObject,
|
|
27
27
|
createDOProviderContainerRuntimeFactory,
|
|
28
28
|
createFluidContainer,
|
|
29
29
|
createServiceAudience,
|
|
@@ -40,7 +40,7 @@ import { wrapConfigProviderWithDefaults } from "@fluidframework/telemetry-utils/
|
|
|
40
40
|
import { v4 as uuid } from "uuid";
|
|
41
41
|
|
|
42
42
|
import type { TokenResponse } from "./interfaces.js";
|
|
43
|
-
import {
|
|
43
|
+
import type {
|
|
44
44
|
OdspClientProps,
|
|
45
45
|
OdspConnectionConfig,
|
|
46
46
|
OdspContainerAttachProps,
|
|
@@ -79,27 +79,13 @@ const odspClientFeatureGates = {
|
|
|
79
79
|
// None yet
|
|
80
80
|
};
|
|
81
81
|
|
|
82
|
-
/**
|
|
83
|
-
* Feature gates required to support runtime compatibility when V1 and V2 clients are collaborating
|
|
84
|
-
*/
|
|
85
|
-
const odspClientV1CompatFeatureGates = {
|
|
86
|
-
// Disable Garbage Collection
|
|
87
|
-
"Fluid.GarbageCollection.RunSweep": false, // To prevent the GC op
|
|
88
|
-
"Fluid.GarbageCollection.DisableAutoRecovery": true, // To prevent the GC op
|
|
89
|
-
"Fluid.GarbageCollection.ThrowOnTombstoneLoadOverride": false, // For a consistent story of "GC is disabled"
|
|
90
|
-
};
|
|
91
|
-
|
|
92
82
|
/**
|
|
93
83
|
* Wrap the config provider to fall back on the appropriate defaults for ODSP Client.
|
|
94
84
|
* @param baseConfigProvider - The base config provider to wrap
|
|
95
85
|
* @returns A new config provider with the appropriate defaults applied underneath the given provider
|
|
96
86
|
*/
|
|
97
87
|
function wrapConfigProvider(baseConfigProvider?: IConfigProviderBase): IConfigProviderBase {
|
|
98
|
-
|
|
99
|
-
...odspClientFeatureGates,
|
|
100
|
-
...odspClientV1CompatFeatureGates,
|
|
101
|
-
};
|
|
102
|
-
return wrapConfigProviderWithDefaults(baseConfigProvider, defaults);
|
|
88
|
+
return wrapConfigProviderWithDefaults(baseConfigProvider, odspClientFeatureGates);
|
|
103
89
|
}
|
|
104
90
|
|
|
105
91
|
/**
|