@fluidframework/odsp-client 2.0.0-dev-rc.5.0.0.270401

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/.eslintrc.cjs +23 -0
  2. package/.mocharc.cjs +12 -0
  3. package/CHANGELOG.md +81 -0
  4. package/LICENSE +21 -0
  5. package/README.md +109 -0
  6. package/api-extractor-lint.json +4 -0
  7. package/api-extractor.json +4 -0
  8. package/api-report/odsp-client.alpha.api.md +68 -0
  9. package/api-report/odsp-client.beta.api.md +68 -0
  10. package/api-report/odsp-client.public.api.md +17 -0
  11. package/beta.d.ts +11 -0
  12. package/dist/beta.d.ts +21 -0
  13. package/dist/index.d.ts +18 -0
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.js +10 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/interfaces.d.ts +102 -0
  18. package/dist/interfaces.d.ts.map +1 -0
  19. package/dist/interfaces.js +7 -0
  20. package/dist/interfaces.js.map +1 -0
  21. package/dist/odspAudience.d.ts +8 -0
  22. package/dist/odspAudience.d.ts.map +1 -0
  23. package/dist/odspAudience.js +20 -0
  24. package/dist/odspAudience.js.map +1 -0
  25. package/dist/odspClient.d.ts +31 -0
  26. package/dist/odspClient.d.ts.map +1 -0
  27. package/dist/odspClient.js +165 -0
  28. package/dist/odspClient.js.map +1 -0
  29. package/dist/package.json +3 -0
  30. package/dist/token.d.ts +35 -0
  31. package/dist/token.d.ts.map +1 -0
  32. package/dist/token.js +7 -0
  33. package/dist/token.js.map +1 -0
  34. package/internal.d.ts +11 -0
  35. package/lib/beta.d.ts +21 -0
  36. package/lib/index.d.ts +18 -0
  37. package/lib/index.d.ts.map +1 -0
  38. package/lib/index.js +6 -0
  39. package/lib/index.js.map +1 -0
  40. package/lib/interfaces.d.ts +102 -0
  41. package/lib/interfaces.d.ts.map +1 -0
  42. package/lib/interfaces.js +6 -0
  43. package/lib/interfaces.js.map +1 -0
  44. package/lib/odspAudience.d.ts +8 -0
  45. package/lib/odspAudience.d.ts.map +1 -0
  46. package/lib/odspAudience.js +16 -0
  47. package/lib/odspAudience.js.map +1 -0
  48. package/lib/odspClient.d.ts +31 -0
  49. package/lib/odspClient.d.ts.map +1 -0
  50. package/lib/odspClient.js +161 -0
  51. package/lib/odspClient.js.map +1 -0
  52. package/lib/token.d.ts +35 -0
  53. package/lib/token.d.ts.map +1 -0
  54. package/lib/token.js +6 -0
  55. package/lib/token.js.map +1 -0
  56. package/lib/tsdoc-metadata.json +11 -0
  57. package/package.json +138 -0
  58. package/prettier.config.cjs +8 -0
  59. package/src/index.ts +25 -0
  60. package/src/interfaces.ts +114 -0
  61. package/src/odspAudience.ts +44 -0
  62. package/src/odspClient.ts +265 -0
  63. package/src/token.ts +37 -0
  64. package/tsconfig.cjs.json +7 -0
  65. package/tsconfig.json +11 -0
package/.eslintrc.cjs ADDED
@@ -0,0 +1,23 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ module.exports = {
7
+ extends: [require.resolve("@fluidframework/eslint-config-fluid"), "prettier"],
8
+ parserOptions: {
9
+ project: ["./tsconfig.json", "./src/test/tsconfig.json"],
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
+ };
package/.mocharc.cjs ADDED
@@ -0,0 +1,12 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ "use strict";
7
+
8
+ const getFluidTestMochaConfig = require("@fluid-internal/mocha-test-setup/mocharc-common");
9
+
10
+ const packageDir = __dirname;
11
+ const config = getFluidTestMochaConfig(packageDir);
12
+ module.exports = config;
package/CHANGELOG.md ADDED
@@ -0,0 +1,81 @@
1
+ # @fluid-experimental/odsp-client
2
+
3
+ ## 2.0.0-rc.4.0.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Rename `AzureMember.userName` to `AzureMember.name` and `IMember.userId` to `IMember.id` [96872186d0](https://github.com/microsoft/FluidFramework/commit/96872186d0d0f245c1fece7d19b3743e501679b6)
8
+
9
+ 1. Renamed `AzureMember.userName` to `AzureMember.name` to establish uniform naming across odsp-client and azure-client.
10
+ 2. Renamed `IMember.userId` to `IMember.id` to align with the properties received from AFR.
11
+
12
+ ## 2.0.0-rc.3.0.0
13
+
14
+ ### Major Changes
15
+
16
+ - Packages now use package.json "exports" and require modern module resolution [97d68aa06b](https://github.com/microsoft/FluidFramework/commit/97d68aa06bd5c022ecb026655814aea222a062ae)
17
+
18
+ Fluid Framework packages have been updated to use the [package.json "exports"
19
+ field](https://nodejs.org/docs/latest-v18.x/api/packages.html#exports) to define explicit entry points for both
20
+ TypeScript types and implementation code.
21
+
22
+ This means that using Fluid Framework packages require the following TypeScript settings in tsconfig.json:
23
+
24
+ - `"moduleResolution": "Node16"` with `"module": "Node16"`
25
+ - `"moduleResolution": "Bundler"` with `"module": "ESNext"`
26
+
27
+ We recommend using Node16/Node16 unless absolutely necessary. That will produce transpiled JavaScript that is suitable
28
+ for use with modern versions of Node.js _and_ Bundlers.
29
+ [See the TypeScript documentation](https://www.typescriptlang.org/tsconfig#moduleResolution) for more information
30
+ regarding the module and moduleResolution options.
31
+
32
+ **Node10 moduleResolution is not supported; it does not support Fluid Framework's API structuring pattern that is used
33
+ to distinguish stable APIs from those that are in development.**
34
+
35
+ ## 2.0.0-rc.2.0.0
36
+
37
+ Dependency updates only.
38
+
39
+ ## 2.0.0-rc.1.0.0
40
+
41
+ ### Minor Changes
42
+
43
+ - Updated server dependencies ([#19122](https://github.com/microsoft/FluidFramework/issues/19122)) [25366b4229](https://github.com/microsoft/FluidFramework/commits/25366b422918cb43685c5f328b50450749592902)
44
+
45
+ The following Fluid server dependencies have been updated to the latest version, 3.0.0. [See the full changelog.](https://github.com/microsoft/FluidFramework/releases/tag/server_v3.0.0)
46
+
47
+ - @fluidframework/gitresources
48
+ - @fluidframework/server-kafka-orderer
49
+ - @fluidframework/server-lambdas
50
+ - @fluidframework/server-lambdas-driver
51
+ - @fluidframework/server-local-server
52
+ - @fluidframework/server-memory-orderer
53
+ - @fluidframework/protocol-base
54
+ - @fluidframework/server-routerlicious
55
+ - @fluidframework/server-routerlicious-base
56
+ - @fluidframework/server-services
57
+ - @fluidframework/server-services-client
58
+ - @fluidframework/server-services-core
59
+ - @fluidframework/server-services-ordering-kafkanode
60
+ - @fluidframework/server-services-ordering-rdkafka
61
+ - @fluidframework/server-services-ordering-zookeeper
62
+ - @fluidframework/server-services-shared
63
+ - @fluidframework/server-services-telemetry
64
+ - @fluidframework/server-services-utils
65
+ - @fluidframework/server-test-utils
66
+ - tinylicious
67
+
68
+ - Updated @fluidframework/protocol-definitions ([#19122](https://github.com/microsoft/FluidFramework/issues/19122)) [25366b4229](https://github.com/microsoft/FluidFramework/commits/25366b422918cb43685c5f328b50450749592902)
69
+
70
+ The @fluidframework/protocol-definitions dependency has been upgraded to v3.1.0. [See the full
71
+ changelog.](https://github.com/microsoft/FluidFramework/blob/main/common/lib/protocol-definitions/CHANGELOG.md#310)
72
+
73
+ ## 2.0.0-internal.8.0.0
74
+
75
+ Dependency updates only.
76
+
77
+ ## 2.0.0-internal.7.4.0
78
+
79
+ Dependency updates only.
80
+
81
+ ## 2.0.0-internal.7.3.0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Copyright (c) Microsoft Corporation and contributors. All rights reserved.
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,109 @@
1
+ # @fluidframework/odsp-client
2
+
3
+ The odsp-client package provides a simple and powerful way to consume collaborative Fluid data with OneDrive/SharePoint (ODSP) storage. Please note that odsp-client is currently an experimental package. We'd love for you to try it out and provide feedback but it is not yet recommended or supported for production scenarios.
4
+
5
+ ## Using odsp-client
6
+
7
+ The odsp-client package has an `OdspClient` class that allows you to interact with Fluid.
8
+
9
+ ```typescript
10
+ import { OdspClient } from "@fluidframework/odsp-client";
11
+ ```
12
+
13
+ ### Example usage
14
+
15
+ ```typescript
16
+ import { OdspClient, OdspConnectionConfig, OdspClientProps } from "@fluidframework/odsp-client";
17
+
18
+ const connectionConfig: OdspConnectionConfig = {
19
+ tokenProvider: "<YOUR_TOKEN_PROVIDER>",
20
+ siteUrl: "<SITE_URL>",
21
+ driveId: "<SHAREPOINT_EMBEDDED_CONTAINER_ID>",
22
+ filePath: "<FLUID_FILE_PATH>",
23
+ };
24
+
25
+ export const clientProps: OdspClientProps = {
26
+ connection: connectionConfig,
27
+ };
28
+
29
+ const client = new OdspClient(clientProps);
30
+ ```
31
+
32
+ ### Experimental Features
33
+
34
+ `OdspClient` provides access to experimental features, as demonstrated below. These features are experimental in nature and should **NOT** be used in production applications. To learn more, see [Experimental Features](https://fluidframework.com/docs/build/experimental-features/).
35
+
36
+ ```typescript
37
+ const configProvider = (settings: Record<string, ConfigTypes>): IConfigProviderBase => ({
38
+ getRawConfig: (name: string): ConfigTypes => settings[name],
39
+ });
40
+
41
+ export const clientProps: OdspClientProps = {
42
+ connection: connectionConfig,
43
+ configProvider: configProvider({
44
+ "Fluid.Container.ForceWriteConnection": true,
45
+ }),
46
+ };
47
+ ```
48
+
49
+ ## Fluid Containers
50
+
51
+ A Container instance is a organizational unit within Fluid. Each Container instance has a connection to the defined Fluid Service and contains a collection of collaborative objects.
52
+
53
+ Containers are created and identified by unique itemIds. Management and storage of these itemIds are the responsibility of the developer.
54
+
55
+ ## Defining Fluid Containers
56
+
57
+ Fluid Containers are defined by a schema. The schema includes initial properties of the Container as well as what collaborative objects can be dynamically created.
58
+
59
+ ```typescript
60
+ const containerSchema = {
61
+ initialObjects: {
62
+ /* ... */
63
+ },
64
+ dynamicObjectTypes: [
65
+ /*...*/
66
+ ],
67
+ };
68
+ const odspClient = new OdspClient(clientProps);
69
+ const { container, services } = await odspClient.createContainer(containerSchema);
70
+
71
+ const itemId = await container.attach();
72
+ ```
73
+
74
+ ## Using Fluid Containers
75
+
76
+ Using the `OdspClient` class the developer can create and get Fluid containers. Because Fluid needs to be connected to a server, containers need to be created and retrieved asynchronously.
77
+
78
+ ```typescript
79
+ import { OdspClient } from "@fluidframework/odsp-client";
80
+
81
+ const odspClient = new OdspClient(props);
82
+ const { container, services } = await odspClient.getContainer("_unique-itemId_", schema);
83
+ ```
84
+
85
+ ## Using initial objects
86
+
87
+ The most common way to use Fluid is through initial collaborative objects that are created when the Container is created. Distributed data structures and DataObjects are both supported types of collaborative objects.
88
+
89
+ `initialObjects` are loaded into memory when the Container is loaded and the developer can access them via the Container's `initialObjects` property. The `initialObjects` property has the same signature as the Container schema.
90
+
91
+ ```typescript
92
+ // Define the keys and types of the initial list of collaborative objects.
93
+ // Here, we are using a SharedMap DDS on key "map1" and a SharedString on key "text1".
94
+ const schema = {
95
+ initialObjects: {
96
+ map1: SharedMap,
97
+ text1: SharedString,
98
+ },
99
+ };
100
+
101
+ // Fetch back the container that had been created earlier with the same itemId and schema
102
+ const { container, services } = await OdspClient.getContainer("_unique-itemId_", schema);
103
+
104
+ // Get our list of initial objects that we had defined in the schema. initialObjects here will have the same signature
105
+ const initialObjects = container.initialObjects;
106
+ // Use the keys that we had set in the schema to load the individual objects
107
+ const map1 = initialObjects.map1;
108
+ const text1 = initialObjects.text1;
109
+ ```
@@ -0,0 +1,4 @@
1
+ {
2
+ "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
+ "extends": "../../../common/build/build-common/api-extractor-lint.esm.primary.json"
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
+ "extends": "../../../common/build/build-common/api-extractor-base.esm.primary.json"
4
+ }
@@ -0,0 +1,68 @@
1
+ ## Alpha API Report File for "@fluidframework/odsp-client"
2
+
3
+ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ ```ts
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
+ import { TokenResponse } from '@fluidframework/odsp-driver-definitions/internal';
14
+
15
+ // @beta
16
+ export type IOdspAudience = IServiceAudience<OdspMember>;
17
+
18
+ // @beta
19
+ export interface IOdspTokenProvider {
20
+ fetchStorageToken(siteUrl: string, refresh: boolean): Promise<TokenResponse>;
21
+ fetchWebsocketToken(siteUrl: string, refresh: boolean): Promise<TokenResponse>;
22
+ }
23
+
24
+ // @beta @sealed
25
+ export class OdspClient {
26
+ constructor(properties: OdspClientProps);
27
+ // (undocumented)
28
+ createContainer<T extends ContainerSchema>(containerSchema: T): Promise<{
29
+ container: IFluidContainer<T>;
30
+ services: OdspContainerServices;
31
+ }>;
32
+ // (undocumented)
33
+ getContainer<T extends ContainerSchema>(id: string, containerSchema: T): Promise<{
34
+ container: IFluidContainer<T>;
35
+ services: OdspContainerServices;
36
+ }>;
37
+ }
38
+
39
+ // @beta (undocumented)
40
+ export interface OdspClientProps {
41
+ readonly configProvider?: IConfigProviderBase;
42
+ readonly connection: OdspConnectionConfig;
43
+ readonly logger?: ITelemetryBaseLogger;
44
+ }
45
+
46
+ // @beta
47
+ export interface OdspConnectionConfig {
48
+ driveId: string;
49
+ filePath: string;
50
+ siteUrl: string;
51
+ tokenProvider: IOdspTokenProvider;
52
+ }
53
+
54
+ // @beta
55
+ export interface OdspContainerServices {
56
+ audience: IOdspAudience;
57
+ }
58
+
59
+ // @beta
60
+ export interface OdspMember extends IMember {
61
+ email: string;
62
+ id: string;
63
+ name: string;
64
+ }
65
+
66
+ export { TokenResponse }
67
+
68
+ ```
@@ -0,0 +1,68 @@
1
+ ## Beta API Report File for "@fluidframework/odsp-client"
2
+
3
+ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ ```ts
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
+ import { TokenResponse } from '@fluidframework/odsp-driver-definitions/internal';
14
+
15
+ // @beta
16
+ export type IOdspAudience = IServiceAudience<OdspMember>;
17
+
18
+ // @beta
19
+ export interface IOdspTokenProvider {
20
+ fetchStorageToken(siteUrl: string, refresh: boolean): Promise<TokenResponse>;
21
+ fetchWebsocketToken(siteUrl: string, refresh: boolean): Promise<TokenResponse>;
22
+ }
23
+
24
+ // @beta @sealed
25
+ export class OdspClient {
26
+ constructor(properties: OdspClientProps);
27
+ // (undocumented)
28
+ createContainer<T extends ContainerSchema>(containerSchema: T): Promise<{
29
+ container: IFluidContainer<T>;
30
+ services: OdspContainerServices;
31
+ }>;
32
+ // (undocumented)
33
+ getContainer<T extends ContainerSchema>(id: string, containerSchema: T): Promise<{
34
+ container: IFluidContainer<T>;
35
+ services: OdspContainerServices;
36
+ }>;
37
+ }
38
+
39
+ // @beta (undocumented)
40
+ export interface OdspClientProps {
41
+ readonly configProvider?: IConfigProviderBase;
42
+ readonly connection: OdspConnectionConfig;
43
+ readonly logger?: ITelemetryBaseLogger;
44
+ }
45
+
46
+ // @beta
47
+ export interface OdspConnectionConfig {
48
+ driveId: string;
49
+ filePath: string;
50
+ siteUrl: string;
51
+ tokenProvider: IOdspTokenProvider;
52
+ }
53
+
54
+ // @beta
55
+ export interface OdspContainerServices {
56
+ audience: IOdspAudience;
57
+ }
58
+
59
+ // @beta
60
+ export interface OdspMember extends IMember {
61
+ email: string;
62
+ id: string;
63
+ name: string;
64
+ }
65
+
66
+ export { TokenResponse }
67
+
68
+ ```
@@ -0,0 +1,17 @@
1
+ ## Public API Report File for "@fluidframework/odsp-client"
2
+
3
+ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ ```ts
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
+ import { TokenResponse } from '@fluidframework/odsp-driver-definitions/internal';
14
+
15
+ export { TokenResponse }
16
+
17
+ ```
package/beta.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ /*
7
+ * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
8
+ * Generated by "flub generate entrypoints" in @fluidframework/build-tools.
9
+ */
10
+
11
+ export * from "./lib/beta.js";
package/dist/beta.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ /*
7
+ * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
8
+ * Generated by "flub generate entrypoints" in @fluidframework/build-tools.
9
+ */
10
+
11
+ export {
12
+ // @beta APIs
13
+ IOdspAudience,
14
+ IOdspTokenProvider,
15
+ OdspClient,
16
+ OdspClientProps,
17
+ OdspConnectionConfig,
18
+ OdspContainerServices,
19
+ OdspMember,
20
+ TokenResponse
21
+ } from "./index.js";
@@ -0,0 +1,18 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ /**
6
+ * The odsp-client package provides a simple and powerful way to consume collaborative Fluid data with OneDrive/SharePoint (ODSP) storage.
7
+ *
8
+ * @remarks
9
+ * Please note that odsp-client is currently an experimental package.
10
+ * We'd love for you to try it out and provide feedback but it is not yet recommended or supported for production scenarios.
11
+ *
12
+ * @packageDocumentation
13
+ */
14
+ export { type TokenResponse } from "@fluidframework/odsp-driver-definitions/internal";
15
+ export type { OdspConnectionConfig, OdspClientProps, OdspContainerServices, IOdspAudience, OdspMember, } from "./interfaces.js";
16
+ export { OdspClient } from "./odspClient.js";
17
+ export { type IOdspTokenProvider } from "./token.js";
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;GAQG;AAEH,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,kDAAkD,CAAC;AACtF,YAAY,EACX,oBAAoB,EACpB,eAAe,EACf,qBAAqB,EACrB,aAAa,EACb,UAAU,GACV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.OdspClient = void 0;
8
+ var odspClient_js_1 = require("./odspClient.js");
9
+ Object.defineProperty(exports, "OdspClient", { enumerable: true, get: function () { return odspClient_js_1.OdspClient; } });
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAoBH,iDAA6C;AAApC,2GAAA,UAAU,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * The odsp-client package provides a simple and powerful way to consume collaborative Fluid data with OneDrive/SharePoint (ODSP) storage.\n *\n * @remarks\n * Please note that odsp-client is currently an experimental package.\n * We'd love for you to try it out and provide feedback but it is not yet recommended or supported for production scenarios.\n *\n * @packageDocumentation\n */\n\nexport { type TokenResponse } from \"@fluidframework/odsp-driver-definitions/internal\";\nexport type {\n\tOdspConnectionConfig,\n\tOdspClientProps,\n\tOdspContainerServices,\n\tIOdspAudience,\n\tOdspMember,\n} from \"./interfaces.js\";\nexport { OdspClient } from \"./odspClient.js\";\nexport { type IOdspTokenProvider } from \"./token.js\";\n"]}
@@ -0,0 +1,102 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { type ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
6
+ import { IConfigProviderBase } from "@fluidframework/core-interfaces";
7
+ import type { IMember, IServiceAudience } from "@fluidframework/fluid-static";
8
+ import { IOdspTokenProvider } from "./token.js";
9
+ /**
10
+ * Defines the necessary properties that will be applied to all containers
11
+ * created by an OdspClient instance. This includes callbacks for the authentication tokens
12
+ * required for ODSP.
13
+ * @beta
14
+ */
15
+ export interface OdspConnectionConfig {
16
+ /**
17
+ * Instance that provides AAD endpoint tokens for Push and SharePoint
18
+ */
19
+ tokenProvider: IOdspTokenProvider;
20
+ /**
21
+ * Site url representing ODSP resource location. It points to the specific SharePoint site where you can store and access the containers you create.
22
+ */
23
+ siteUrl: string;
24
+ /**
25
+ * SharePoint Embedded Container Id of the tenant where Fluid containers are created
26
+ */
27
+ driveId: string;
28
+ /**
29
+ * Specifies the file path where Fluid files are created. If passed an empty string, the Fluid files will be created at the root level.
30
+ */
31
+ filePath: string;
32
+ }
33
+ /**
34
+ * @beta
35
+ */
36
+ export interface OdspClientProps {
37
+ /**
38
+ * Configuration for establishing a connection with the ODSP Fluid Service (Push).
39
+ */
40
+ readonly connection: OdspConnectionConfig;
41
+ /**
42
+ * Optional. A logger instance to receive diagnostic messages.
43
+ */
44
+ readonly logger?: ITelemetryBaseLogger;
45
+ /**
46
+ * Base interface for providing configurations to control experimental features. If unsure, leave this undefined.
47
+ */
48
+ readonly configProvider?: IConfigProviderBase;
49
+ }
50
+ /**
51
+ * @alpha
52
+ */
53
+ export interface OdspContainerAttachProps {
54
+ /**
55
+ * The file path where Fluid containers are created. If undefined, the file is created at the root.
56
+ */
57
+ filePath: string | undefined;
58
+ /**
59
+ * The file name of the Fluid file. If undefined, the file is named with a GUID.
60
+ */
61
+ fileName: string | undefined;
62
+ }
63
+ /**
64
+ * OdspContainerServices is returned by the OdspClient alongside a FluidContainer. It holds the
65
+ * functionality specifically tied to the ODSP service, and how the data stored in the
66
+ * FluidContainer is persisted in the backend and consumed by users. Any functionality regarding
67
+ * how the data is handled within the FluidContainer itself, i.e. which data objects or DDSes to
68
+ * use, will not be included here but rather on the FluidContainer class itself.
69
+ * @beta
70
+ */
71
+ export interface OdspContainerServices {
72
+ /**
73
+ * 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.
74
+ */
75
+ audience: IOdspAudience;
76
+ }
77
+ /**
78
+ * Since ODSP provides user names and email for all of its members, we extend the
79
+ * {@link @fluidframework/fluid-static#IMember} interface to include this service-specific value.
80
+ * It will be returned for all audience members connected.
81
+ * @beta
82
+ */
83
+ export interface OdspMember extends IMember {
84
+ /**
85
+ * The object ID (oid) for the user, unique among each individual user connecting to the session.
86
+ */
87
+ id: string;
88
+ /**
89
+ * The user's name
90
+ */
91
+ name: string;
92
+ /**
93
+ * The user's email
94
+ */
95
+ email: string;
96
+ }
97
+ /**
98
+ * Audience object for ODSP containers
99
+ * @beta
100
+ */
101
+ export type IOdspAudience = IServiceAudience<OdspMember>;
102
+ //# sourceMappingURL=interfaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAE9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD;;;;;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;;GAEG;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"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ //# sourceMappingURL=interfaces.js.map
@@ -0,0 +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 { type ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { IConfigProviderBase } from \"@fluidframework/core-interfaces\";\nimport type { IMember, IServiceAudience } from \"@fluidframework/fluid-static\";\n\nimport { 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 * @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"]}
@@ -0,0 +1,8 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { type IClient } from "@fluidframework/driver-definitions";
6
+ import { type OdspMember } from "./interfaces.js";
7
+ export declare function createOdspAudienceMember(audienceMember: IClient): OdspMember;
8
+ //# sourceMappingURL=odspAudience.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.createOdspAudienceMember = void 0;
8
+ const internal_1 = require("@fluidframework/core-utils/internal");
9
+ function createOdspAudienceMember(audienceMember) {
10
+ const user = audienceMember.user;
11
+ (0, internal_1.assert)(user.name !== undefined || user.email !== undefined || user.oid !== undefined, 0x836 /* Provided user was not an "OdspUser". */);
12
+ return {
13
+ id: user.oid,
14
+ name: user.name,
15
+ email: user.email,
16
+ connections: [],
17
+ };
18
+ }
19
+ exports.createOdspAudienceMember = createOdspAudienceMember;
20
+ //# sourceMappingURL=odspAudience.js.map
@@ -0,0 +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"]}