@fluidframework/azure-client 2.0.0-internal.7.3.0 → 2.0.0-internal.7.4.1
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/.attw.json +3 -0
- package/CHANGELOG.md +16 -0
- package/api-extractor-lint.json +13 -0
- package/api-extractor.json +8 -3
- package/api-report/azure-client.api.md +15 -16
- package/azure-client.test-files.tar +0 -0
- package/dist/AzureAudience.cjs +18 -13
- package/dist/AzureAudience.cjs.map +1 -1
- package/dist/AzureAudience.d.ts +6 -4
- package/dist/AzureAudience.d.ts.map +1 -1
- package/dist/AzureClient.cjs +27 -9
- package/dist/AzureClient.cjs.map +1 -1
- package/dist/AzureClient.d.ts +2 -2
- package/dist/AzureClient.d.ts.map +1 -1
- package/dist/AzureFunctionTokenProvider.cjs +1 -2
- package/dist/AzureFunctionTokenProvider.cjs.map +1 -1
- package/dist/AzureFunctionTokenProvider.d.ts +1 -2
- package/dist/AzureFunctionTokenProvider.d.ts.map +1 -1
- package/dist/azure-client-alpha.d.ts +18 -76
- package/dist/azure-client-beta.d.ts +32 -273
- package/dist/azure-client-public.d.ts +32 -273
- package/dist/azure-client-untrimmed.d.ts +17 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/interfaces.cjs.map +1 -1
- package/dist/interfaces.d.ts +12 -25
- package/dist/interfaces.d.ts.map +1 -1
- package/lib/AzureAudience.d.ts +7 -5
- package/lib/AzureAudience.d.ts.map +1 -1
- package/lib/AzureAudience.mjs +16 -12
- package/lib/AzureAudience.mjs.map +1 -1
- package/lib/AzureClient.d.ts +3 -3
- package/lib/AzureClient.d.ts.map +1 -1
- package/lib/AzureClient.mjs +29 -11
- package/lib/AzureClient.mjs.map +1 -1
- package/lib/AzureFunctionTokenProvider.d.ts +2 -3
- package/lib/AzureFunctionTokenProvider.d.ts.map +1 -1
- package/lib/AzureFunctionTokenProvider.mjs +1 -2
- package/lib/AzureFunctionTokenProvider.mjs.map +1 -1
- package/lib/AzureUrlResolver.d.ts +0 -4
- package/lib/AzureUrlResolver.d.ts.map +1 -1
- package/lib/azure-client-alpha.d.ts +18 -76
- package/lib/azure-client-beta.d.ts +32 -273
- package/lib/azure-client-public.d.ts +32 -273
- package/lib/azure-client-untrimmed.d.ts +17 -31
- package/lib/index.d.ts +5 -9
- package/lib/index.d.ts.map +1 -1
- package/lib/index.mjs.map +1 -1
- package/lib/interfaces.d.ts +12 -29
- package/lib/interfaces.d.ts.map +1 -1
- package/lib/interfaces.mjs.map +1 -1
- package/lib/utils.d.ts +1 -5
- package/lib/utils.d.ts.map +1 -1
- package/package.json +25 -21
- package/src/AzureAudience.ts +18 -13
- package/src/AzureClient.ts +35 -14
- package/src/AzureFunctionTokenProvider.ts +1 -2
- package/src/index.ts +3 -2
- package/src/interfaces.ts +15 -27
package/.attw.json
ADDED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @fluidframework/azure-client
|
|
2
2
|
|
|
3
|
+
## 2.0.0-internal.7.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- azure-client: Deprecated FluidStatic Classes ([#18402](https://github.com/microsoft/FluidFramework/issues/18402)) [589ec39de5](https://github.com/microsoft/FluidFramework/commits/589ec39de52116c7f782319e6f6aa61bc5aa9964)
|
|
8
|
+
|
|
9
|
+
Several FluidStatic classes were unnecessarily exposed. They have been replaced with creation functions. This helps us
|
|
10
|
+
keep implementations decoupled from usage which is easier to maintain and extend. It has very minimal impact on the
|
|
11
|
+
public surface area of downstream packages. The deprecated classes are as follows:
|
|
12
|
+
|
|
13
|
+
- `AzureAudience` (use `IAzureAudience` instead)
|
|
14
|
+
- `TinyliciousAudience` (use `ITinyliciousAudience` instead)
|
|
15
|
+
- `DOProviderContainerRuntimeFactory`
|
|
16
|
+
- `FluidContainer`
|
|
17
|
+
- `ServiceAudience`
|
|
18
|
+
|
|
3
19
|
## 2.0.0-internal.7.3.0
|
|
4
20
|
|
|
5
21
|
Dependency updates only.
|
|
@@ -0,0 +1,13 @@
|
|
|
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.json",
|
|
4
|
+
"messages": {
|
|
5
|
+
"extractorMessageReporting": {
|
|
6
|
+
// TODO: remove once base config has this enabled as an error
|
|
7
|
+
"ae-incompatible-release-tags": {
|
|
8
|
+
"logLevel": "error",
|
|
9
|
+
"addToApiReportFile": false
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
package/api-extractor.json
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
|
3
|
-
"extends": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"extends": "../../../common/build/build-common/api-extractor-base.json",
|
|
4
|
+
"messages": {
|
|
5
|
+
"extractorMessageReporting": {
|
|
6
|
+
// TODO: Add missing documentation and remove this rule override
|
|
7
|
+
"ae-undocumented": {
|
|
8
|
+
"logLevel": "none"
|
|
9
|
+
}
|
|
10
|
+
}
|
|
6
11
|
}
|
|
7
12
|
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { ContainerSchema } from '@fluidframework/fluid-static';
|
|
8
8
|
import { IClient } from '@fluidframework/protocol-definitions';
|
|
9
9
|
import { ICompressionStorageConfig } from '@fluidframework/driver-utils';
|
|
10
|
-
import { IConfigProviderBase } from '@fluidframework/
|
|
10
|
+
import { IConfigProviderBase } from '@fluidframework/core-interfaces';
|
|
11
11
|
import { IFluidContainer } from '@fluidframework/fluid-static';
|
|
12
12
|
import { IMember } from '@fluidframework/fluid-static';
|
|
13
13
|
import { IServiceAudience } from '@fluidframework/fluid-static';
|
|
@@ -20,13 +20,12 @@ import { IUser } from '@fluidframework/protocol-definitions';
|
|
|
20
20
|
import { ScopeType } from '@fluidframework/protocol-definitions';
|
|
21
21
|
import { ServiceAudience } from '@fluidframework/fluid-static';
|
|
22
22
|
|
|
23
|
-
// @
|
|
23
|
+
// @internal @deprecated
|
|
24
24
|
export class AzureAudience extends ServiceAudience<AzureMember> implements IAzureAudience {
|
|
25
|
-
// @internal
|
|
26
25
|
protected createServiceMember(audienceMember: IClient): AzureMember;
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
// @
|
|
28
|
+
// @alpha
|
|
30
29
|
export class AzureClient {
|
|
31
30
|
constructor(properties: AzureClientProps);
|
|
32
31
|
copyContainer<TContainerSchema extends ContainerSchema>(id: string, containerSchema: TContainerSchema, version?: AzureContainerVersion): Promise<{
|
|
@@ -44,7 +43,7 @@ export class AzureClient {
|
|
|
44
43
|
getContainerVersions(id: string, options?: AzureGetVersionsOptions): Promise<AzureContainerVersion[]>;
|
|
45
44
|
}
|
|
46
45
|
|
|
47
|
-
// @
|
|
46
|
+
// @alpha
|
|
48
47
|
export interface AzureClientProps {
|
|
49
48
|
readonly configProvider?: IConfigProviderBase;
|
|
50
49
|
readonly connection: AzureRemoteConnectionConfig | AzureLocalConnectionConfig;
|
|
@@ -53,28 +52,28 @@ export interface AzureClientProps {
|
|
|
53
52
|
readonly summaryCompression?: boolean | ICompressionStorageConfig;
|
|
54
53
|
}
|
|
55
54
|
|
|
56
|
-
// @
|
|
55
|
+
// @alpha
|
|
57
56
|
export interface AzureConnectionConfig {
|
|
58
57
|
endpoint: string;
|
|
59
58
|
tokenProvider: ITokenProvider;
|
|
60
59
|
type: AzureConnectionConfigType;
|
|
61
60
|
}
|
|
62
61
|
|
|
63
|
-
// @
|
|
62
|
+
// @alpha
|
|
64
63
|
export type AzureConnectionConfigType = "local" | "remote";
|
|
65
64
|
|
|
66
|
-
// @
|
|
65
|
+
// @alpha
|
|
67
66
|
export interface AzureContainerServices {
|
|
68
67
|
audience: IAzureAudience;
|
|
69
68
|
}
|
|
70
69
|
|
|
71
|
-
// @
|
|
70
|
+
// @alpha
|
|
72
71
|
export interface AzureContainerVersion {
|
|
73
72
|
date?: string;
|
|
74
73
|
id: string;
|
|
75
74
|
}
|
|
76
75
|
|
|
77
|
-
// @
|
|
76
|
+
// @internal @deprecated
|
|
78
77
|
export class AzureFunctionTokenProvider implements ITokenProvider {
|
|
79
78
|
constructor(azFunctionUrl: string, user?: Pick<AzureMember<any>, "userId" | "userName" | "additionalDetails"> | undefined);
|
|
80
79
|
// (undocumented)
|
|
@@ -83,35 +82,35 @@ export class AzureFunctionTokenProvider implements ITokenProvider {
|
|
|
83
82
|
fetchStorageToken(tenantId: string, documentId: string): Promise<ITokenResponse>;
|
|
84
83
|
}
|
|
85
84
|
|
|
86
|
-
// @
|
|
85
|
+
// @alpha
|
|
87
86
|
export interface AzureGetVersionsOptions {
|
|
88
87
|
maxCount: number;
|
|
89
88
|
}
|
|
90
89
|
|
|
91
|
-
// @
|
|
90
|
+
// @alpha
|
|
92
91
|
export interface AzureLocalConnectionConfig extends AzureConnectionConfig {
|
|
93
92
|
type: "local";
|
|
94
93
|
}
|
|
95
94
|
|
|
96
|
-
// @
|
|
95
|
+
// @alpha
|
|
97
96
|
export interface AzureMember<T = any> extends IMember {
|
|
98
97
|
additionalDetails?: T;
|
|
99
98
|
userName: string;
|
|
100
99
|
}
|
|
101
100
|
|
|
102
|
-
// @
|
|
101
|
+
// @alpha
|
|
103
102
|
export interface AzureRemoteConnectionConfig extends AzureConnectionConfig {
|
|
104
103
|
tenantId: string;
|
|
105
104
|
type: "remote";
|
|
106
105
|
}
|
|
107
106
|
|
|
108
|
-
// @
|
|
107
|
+
// @internal
|
|
109
108
|
export interface AzureUser<T = any> extends IUser {
|
|
110
109
|
additionalDetails?: T;
|
|
111
110
|
name: string;
|
|
112
111
|
}
|
|
113
112
|
|
|
114
|
-
// @
|
|
113
|
+
// @alpha
|
|
115
114
|
export type IAzureAudience = IServiceAudience<AzureMember>;
|
|
116
115
|
|
|
117
116
|
export { ITelemetryBaseEvent }
|
|
Binary file
|
package/dist/AzureAudience.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AzureAudience = void 0;
|
|
3
|
+
exports.createAzureAudienceMember = exports.AzureAudience = void 0;
|
|
4
4
|
/*!
|
|
5
5
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
6
6
|
* Licensed under the MIT License.
|
|
@@ -11,8 +11,8 @@ const fluid_static_1 = require("@fluidframework/fluid-static");
|
|
|
11
11
|
* Azure-specific {@link @fluidframework/fluid-static#ServiceAudience} implementation.
|
|
12
12
|
*
|
|
13
13
|
* @remarks Operates in terms of {@link AzureMember}s.
|
|
14
|
-
*
|
|
15
|
-
* @
|
|
14
|
+
* @deprecated This class will be removed. use {@link IAzureAudience} instead
|
|
15
|
+
* @internal
|
|
16
16
|
*/
|
|
17
17
|
class AzureAudience extends fluid_static_1.ServiceAudience {
|
|
18
18
|
/**
|
|
@@ -21,19 +21,24 @@ class AzureAudience extends fluid_static_1.ServiceAudience {
|
|
|
21
21
|
*
|
|
22
22
|
* @param audienceMember - Audience member for which the `ServiceAudience` will be generated.
|
|
23
23
|
* Note: its {@link @fluidframework/protocol-definitions#IClient.user} is required to be an {@link AzureUser}.
|
|
24
|
-
*
|
|
25
|
-
* @internal
|
|
26
24
|
*/
|
|
27
25
|
createServiceMember(audienceMember) {
|
|
28
|
-
|
|
29
|
-
(0, core_utils_1.assert)(azureUser?.name !== undefined, 'Provided user was not an "AzureUser".');
|
|
30
|
-
return {
|
|
31
|
-
userId: audienceMember.user.id,
|
|
32
|
-
userName: azureUser.name,
|
|
33
|
-
connections: [],
|
|
34
|
-
additionalDetails: azureUser.additionalDetails,
|
|
35
|
-
};
|
|
26
|
+
return createAzureAudienceMember(audienceMember);
|
|
36
27
|
}
|
|
37
28
|
}
|
|
38
29
|
exports.AzureAudience = AzureAudience;
|
|
30
|
+
/**
|
|
31
|
+
* Creates Azure-specific audience member
|
|
32
|
+
*/
|
|
33
|
+
function createAzureAudienceMember(audienceMember) {
|
|
34
|
+
const azureUser = audienceMember.user;
|
|
35
|
+
(0, core_utils_1.assert)(azureUser?.name !== undefined, 'Provided user was not an "AzureUser".');
|
|
36
|
+
return {
|
|
37
|
+
userId: audienceMember.user.id,
|
|
38
|
+
userName: azureUser.name,
|
|
39
|
+
connections: [],
|
|
40
|
+
additionalDetails: azureUser.additionalDetails,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
exports.createAzureAudienceMember = createAzureAudienceMember;
|
|
39
44
|
//# sourceMappingURL=AzureAudience.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AzureAudience.cjs","sourceRoot":"","sources":["../src/AzureAudience.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,2DAAoD;AACpD,+DAA+D;AAK/D;;;;;;GAMG;AACH,MAAa,aAAc,SAAQ,8BAA4B;IAC9D
|
|
1
|
+
{"version":3,"file":"AzureAudience.cjs","sourceRoot":"","sources":["../src/AzureAudience.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,2DAAoD;AACpD,+DAA+D;AAK/D;;;;;;GAMG;AACH,MAAa,aAAc,SAAQ,8BAA4B;IAC9D;;;;;;OAMG;IACO,mBAAmB,CAAC,cAAuB;QACpD,OAAO,yBAAyB,CAAC,cAAc,CAAC,CAAC;IAClD,CAAC;CACD;AAXD,sCAWC;AAED;;GAEG;AACH,SAAgB,yBAAyB,CAAC,cAAuB;IAChE,MAAM,SAAS,GAAG,cAAc,CAAC,IAAiB,CAAC;IACnD,IAAA,mBAAM,EAAC,SAAS,EAAE,IAAI,KAAK,SAAS,EAAE,uCAAuC,CAAC,CAAC;IAE/E,OAAO;QACN,MAAM,EAAE,cAAc,CAAC,IAAI,CAAC,EAAE;QAC9B,QAAQ,EAAE,SAAS,CAAC,IAAI;QACxB,WAAW,EAAE,EAAE;QACf,iBAAiB,EAAE,SAAS,CAAC,iBAA4B;KACzD,CAAC;AACH,CAAC;AAVD,8DAUC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { assert } from \"@fluidframework/core-utils\";\nimport { ServiceAudience } from \"@fluidframework/fluid-static\";\nimport { type IClient } from \"@fluidframework/protocol-definitions\";\n\nimport { type AzureMember, type AzureUser, type IAzureAudience } from \"./interfaces\";\n\n/**\n * Azure-specific {@link @fluidframework/fluid-static#ServiceAudience} implementation.\n *\n * @remarks Operates in terms of {@link AzureMember}s.\n * @deprecated This class will be removed. use {@link IAzureAudience} instead\n * @internal\n */\nexport class AzureAudience extends ServiceAudience<AzureMember> implements IAzureAudience {\n\t/**\n\t * Creates a {@link @fluidframework/fluid-static#ServiceAudience} from the provided\n\t * {@link @fluidframework/protocol-definitions#IClient | audience member}.\n\t *\n\t * @param audienceMember - Audience member for which the `ServiceAudience` will be generated.\n\t * Note: its {@link @fluidframework/protocol-definitions#IClient.user} is required to be an {@link AzureUser}.\n\t */\n\tprotected createServiceMember(audienceMember: IClient): AzureMember {\n\t\treturn createAzureAudienceMember(audienceMember);\n\t}\n}\n\n/**\n * Creates Azure-specific audience member\n */\nexport function createAzureAudienceMember(audienceMember: IClient): AzureMember {\n\tconst azureUser = audienceMember.user as AzureUser;\n\tassert(azureUser?.name !== undefined, 'Provided user was not an \"AzureUser\".');\n\n\treturn {\n\t\tuserId: audienceMember.user.id,\n\t\tuserName: azureUser.name,\n\t\tconnections: [],\n\t\tadditionalDetails: azureUser.additionalDetails as unknown,\n\t};\n}\n"]}
|
package/dist/AzureAudience.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ import { type AzureMember, type IAzureAudience } from "./interfaces";
|
|
|
5
5
|
* Azure-specific {@link @fluidframework/fluid-static#ServiceAudience} implementation.
|
|
6
6
|
*
|
|
7
7
|
* @remarks Operates in terms of {@link AzureMember}s.
|
|
8
|
-
*
|
|
9
|
-
* @
|
|
8
|
+
* @deprecated This class will be removed. use {@link IAzureAudience} instead
|
|
9
|
+
* @internal
|
|
10
10
|
*/
|
|
11
11
|
export declare class AzureAudience extends ServiceAudience<AzureMember> implements IAzureAudience {
|
|
12
12
|
/**
|
|
@@ -15,9 +15,11 @@ export declare class AzureAudience extends ServiceAudience<AzureMember> implemen
|
|
|
15
15
|
*
|
|
16
16
|
* @param audienceMember - Audience member for which the `ServiceAudience` will be generated.
|
|
17
17
|
* Note: its {@link @fluidframework/protocol-definitions#IClient.user} is required to be an {@link AzureUser}.
|
|
18
|
-
*
|
|
19
|
-
* @internal
|
|
20
18
|
*/
|
|
21
19
|
protected createServiceMember(audienceMember: IClient): AzureMember;
|
|
22
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Creates Azure-specific audience member
|
|
23
|
+
*/
|
|
24
|
+
export declare function createAzureAudienceMember(audienceMember: IClient): AzureMember;
|
|
23
25
|
//# sourceMappingURL=AzureAudience.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AzureAudience.d.ts","sourceRoot":"","sources":["../src/AzureAudience.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,sCAAsC,CAAC;AAEpE,OAAO,EAAE,KAAK,WAAW,EAAkB,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAErF;;;;;;GAMG;AACH,qBAAa,aAAc,SAAQ,eAAe,CAAC,WAAW,CAAE,YAAW,cAAc;IACxF
|
|
1
|
+
{"version":3,"file":"AzureAudience.d.ts","sourceRoot":"","sources":["../src/AzureAudience.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,sCAAsC,CAAC;AAEpE,OAAO,EAAE,KAAK,WAAW,EAAkB,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAErF;;;;;;GAMG;AACH,qBAAa,aAAc,SAAQ,eAAe,CAAC,WAAW,CAAE,YAAW,cAAc;IACxF;;;;;;OAMG;IACH,SAAS,CAAC,mBAAmB,CAAC,cAAc,EAAE,OAAO,GAAG,WAAW;CAGnE;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,cAAc,EAAE,OAAO,GAAG,WAAW,CAU9E"}
|
package/dist/AzureClient.cjs
CHANGED
|
@@ -11,6 +11,7 @@ const driver_utils_1 = require("@fluidframework/driver-utils");
|
|
|
11
11
|
const fluid_static_1 = require("@fluidframework/fluid-static");
|
|
12
12
|
const protocol_definitions_1 = require("@fluidframework/protocol-definitions");
|
|
13
13
|
const routerlicious_driver_1 = require("@fluidframework/routerlicious-driver");
|
|
14
|
+
const core_utils_1 = require("@fluidframework/core-utils");
|
|
14
15
|
const AzureAudience_1 = require("./AzureAudience.cjs");
|
|
15
16
|
const AzureUrlResolver_1 = require("./AzureUrlResolver.cjs");
|
|
16
17
|
const utils_1 = require("./utils.cjs");
|
|
@@ -27,8 +28,7 @@ const MAX_VERSION_COUNT = 5;
|
|
|
27
28
|
/**
|
|
28
29
|
* AzureClient provides the ability to have a Fluid object backed by the Azure Fluid Relay or,
|
|
29
30
|
* when running with local tenantId, have it be backed by a local Azure Fluid Relay instance.
|
|
30
|
-
*
|
|
31
|
-
* @public
|
|
31
|
+
* @alpha
|
|
32
32
|
*/
|
|
33
33
|
class AzureClient {
|
|
34
34
|
/**
|
|
@@ -115,8 +115,11 @@ class AzureClient {
|
|
|
115
115
|
url.searchParams.append("tenantId", encodeURIComponent(getTenantId(this.properties.connection)));
|
|
116
116
|
url.searchParams.append("containerId", encodeURIComponent(id));
|
|
117
117
|
const container = await loader.resolve({ url: url.href });
|
|
118
|
-
const rootDataObject =
|
|
119
|
-
const fluidContainer =
|
|
118
|
+
const rootDataObject = await this.getContainerEntryPoint(container);
|
|
119
|
+
const fluidContainer = (0, fluid_static_1.createFluidContainer)({
|
|
120
|
+
container,
|
|
121
|
+
rootDataObject,
|
|
122
|
+
});
|
|
120
123
|
const services = this.getContainerServices(container);
|
|
121
124
|
return { container: fluidContainer, services };
|
|
122
125
|
}
|
|
@@ -147,11 +150,14 @@ class AzureClient {
|
|
|
147
150
|
}
|
|
148
151
|
getContainerServices(container) {
|
|
149
152
|
return {
|
|
150
|
-
audience:
|
|
153
|
+
audience: (0, fluid_static_1.createServiceAudience)({
|
|
154
|
+
container,
|
|
155
|
+
createServiceMember: AzureAudience_1.createAzureAudienceMember,
|
|
156
|
+
}),
|
|
151
157
|
};
|
|
152
158
|
}
|
|
153
|
-
createLoader(
|
|
154
|
-
const runtimeFactory =
|
|
159
|
+
createLoader(schema) {
|
|
160
|
+
const runtimeFactory = (0, fluid_static_1.createDOProviderContainerRuntimeFactory)({ schema });
|
|
155
161
|
const load = async () => {
|
|
156
162
|
return {
|
|
157
163
|
module: { fluidExport: runtimeFactory },
|
|
@@ -179,7 +185,7 @@ class AzureClient {
|
|
|
179
185
|
}
|
|
180
186
|
async createFluidContainer(container, connection) {
|
|
181
187
|
const createNewRequest = (0, AzureUrlResolver_1.createAzureCreateNewRequest)(connection.endpoint, getTenantId(connection));
|
|
182
|
-
const rootDataObject =
|
|
188
|
+
const rootDataObject = await this.getContainerEntryPoint(container);
|
|
183
189
|
/**
|
|
184
190
|
* See {@link FluidContainer.attach}
|
|
185
191
|
*/
|
|
@@ -193,10 +199,22 @@ class AzureClient {
|
|
|
193
199
|
}
|
|
194
200
|
return container.resolvedUrl.id;
|
|
195
201
|
};
|
|
196
|
-
const fluidContainer =
|
|
202
|
+
const fluidContainer = (0, fluid_static_1.createFluidContainer)({
|
|
203
|
+
container,
|
|
204
|
+
rootDataObject,
|
|
205
|
+
});
|
|
197
206
|
fluidContainer.attach = attach;
|
|
198
207
|
return fluidContainer;
|
|
199
208
|
}
|
|
209
|
+
async getContainerEntryPoint(container) {
|
|
210
|
+
const rootDataObject = await container.getEntryPoint();
|
|
211
|
+
(0, core_utils_1.assert)(rootDataObject !== undefined, "entryPoint must exist");
|
|
212
|
+
// ! This "if" is needed for back-compat (older instances of IRootDataObject may not have the IRootDataObject property)
|
|
213
|
+
if (rootDataObject.IRootDataObject === undefined) {
|
|
214
|
+
return rootDataObject;
|
|
215
|
+
}
|
|
216
|
+
return rootDataObject.IRootDataObject;
|
|
217
|
+
}
|
|
200
218
|
}
|
|
201
219
|
exports.AzureClient = AzureClient;
|
|
202
220
|
//# sourceMappingURL=AzureClient.cjs.map
|
package/dist/AzureClient.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AzureClient.cjs","sourceRoot":"","sources":["../src/AzureClient.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,iFAI+C;AAC/C,uEAA0D;AAK1D,+DAAuE;AACvE,+DAMsC;AACtC,+EAAiF;AACjF,+EAA2F;AAG3F,uDAAgD;AAChD,6DAAmF;AAQnF,uCAAwD;AAExD;;GAEG;AACH,MAAM,oBAAoB,GAAG,OAAO,CAAC;AACrC,MAAM,WAAW,GAAG,CAAC,oBAA2C,EAAU,EAAE;IAC3E,OAAO,IAAA,qCAA6B,EAAC,oBAAoB,CAAC;QACzD,CAAC,CAAC,oBAAoB,CAAC,QAAQ;QAC/B,CAAC,CAAC,oBAAoB,CAAC;AACzB,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAE5B;;;;;GAKG;AACH,MAAa,WAAW;IAKvB;;;OAGG;IACH,YAAoC,UAA4B;QAA5B,eAAU,GAAV,UAAU,CAAkB;QAC/D,wCAAwC;QACxC,UAAU,CAAC,UAAU,CAAC,QAAQ,GAAG,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACnF,IAAI,CAAC,WAAW,GAAG,IAAI,mCAAgB,EAAE,CAAC;QA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C,CAAC;YACzC,IAAI,SAAS,CAAC,WAAW,KAAK,SAAS,EAAE;gBACxC,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;aACpE;YACD,OAAO,SAAS,CAAC,WAAW,CAAC,EAAE,CAAC;QACjC,CAAC,CAAC;QACF,MAAM,cAAc,GAAG,IAAI,6BAAc,CAAmB,SAAS,EAAE,cAAc,CAAC,CAAC;QACvF,cAAc,CAAC,MAAM,GAAG,MAAM,CAAC;QAC/B,OAAO,cAAc,CAAC;IACvB,CAAC;CAED;AAjPD,kCAiPC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport {\n\tAttachState,\n\ttype IContainer,\n\ttype IFluidModuleWithDetails,\n} from \"@fluidframework/container-definitions\";\nimport { Loader } from \"@fluidframework/container-loader\";\nimport {\n\ttype IDocumentServiceFactory,\n\ttype IUrlResolver,\n} from \"@fluidframework/driver-definitions\";\nimport { applyStorageCompression } from \"@fluidframework/driver-utils\";\nimport {\n\ttype ContainerSchema,\n\tDOProviderContainerRuntimeFactory,\n\tFluidContainer,\n\ttype IFluidContainer,\n\ttype IRootDataObject,\n} from \"@fluidframework/fluid-static\";\nimport { type IClient, SummaryType } from \"@fluidframework/protocol-definitions\";\nimport { RouterliciousDocumentServiceFactory } from \"@fluidframework/routerlicious-driver\";\n\nimport { type IConfigProviderBase } from \"@fluidframework/telemetry-utils\";\nimport { AzureAudience } from \"./AzureAudience\";\nimport { AzureUrlResolver, createAzureCreateNewRequest } from \"./AzureUrlResolver\";\nimport {\n\ttype AzureClientProps,\n\ttype AzureConnectionConfig,\n\ttype AzureContainerServices,\n\ttype AzureContainerVersion,\n\ttype AzureGetVersionsOptions,\n} from \"./interfaces\";\nimport { isAzureRemoteConnectionConfig } from \"./utils\";\n\n/**\n * Strongly typed id for connecting to a local Azure Fluid Relay.\n */\nconst LOCAL_MODE_TENANT_ID = \"local\";\nconst getTenantId = (connectionProperties: AzureConnectionConfig): string => {\n\treturn isAzureRemoteConnectionConfig(connectionProperties)\n\t\t? connectionProperties.tenantId\n\t\t: LOCAL_MODE_TENANT_ID;\n};\n\nconst MAX_VERSION_COUNT = 5;\n\n/**\n * AzureClient provides the ability to have a Fluid object backed by the Azure Fluid Relay or,\n * when running with local tenantId, have it be backed by a local Azure Fluid Relay instance.\n *\n * @public\n */\nexport class AzureClient {\n\tprivate readonly documentServiceFactory: IDocumentServiceFactory;\n\tprivate readonly urlResolver: IUrlResolver;\n\tprivate readonly configProvider: IConfigProviderBase | undefined;\n\n\t/**\n\t * Creates a new client instance using configuration parameters.\n\t * @param properties - Properties for initializing a new AzureClient instance\n\t */\n\tpublic constructor(private readonly properties: AzureClientProps) {\n\t\t// remove trailing slash from URL if any\n\t\tproperties.connection.endpoint = properties.connection.endpoint.replace(/\\/$/, \"\");\n\t\tthis.urlResolver = new AzureUrlResolver();\n\t\t// The local service implementation differs from the Azure Fluid Relay in blob\n\t\t// storage format. Azure Fluid Relay supports whole summary upload. Local currently does not.\n\t\tconst isRemoteConnection = isAzureRemoteConnectionConfig(this.properties.connection);\n\t\tconst origDocumentServiceFactory: IDocumentServiceFactory =\n\t\t\tnew RouterliciousDocumentServiceFactory(this.properties.connection.tokenProvider, {\n\t\t\t\tenableWholeSummaryUpload: isRemoteConnection,\n\t\t\t\tenableDiscovery: isRemoteConnection,\n\t\t\t});\n\n\t\tthis.documentServiceFactory = applyStorageCompression(\n\t\t\torigDocumentServiceFactory,\n\t\t\tproperties.summaryCompression,\n\t\t);\n\t\tthis.configProvider = properties.configProvider;\n\t}\n\n\t/**\n\t * Creates a new detached container instance in the Azure Fluid Relay.\n\t * @typeparam TContainerSchema - Used to infer the the type of 'initialObjects' in the returned container.\n\t * (normally not explicitly specified.)\n\t * @param containerSchema - Container schema for the new container.\n\t * @returns New detached container instance along with associated services.\n\t */\n\tpublic async createContainer<TContainerSchema extends ContainerSchema>(\n\t\tcontainerSchema: TContainerSchema,\n\t): Promise<{\n\t\tcontainer: IFluidContainer<TContainerSchema>;\n\t\tservices: AzureContainerServices;\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<TContainerSchema>(\n\t\t\tcontainer,\n\t\t\tthis.properties.connection,\n\t\t);\n\t\tconst services = this.getContainerServices(container);\n\t\treturn { container: fluidContainer, services };\n\t}\n\n\t/**\n\t * Creates new detached container out of specific version of another container.\n\t * @typeparam TContainerSchema - Used to infer the the type of 'initialObjects' in the returned container.\n\t * (normally not explicitly specified.)\n\t * @param id - Unique ID of the source container in Azure Fluid Relay.\n\t * @param containerSchema - Container schema used to access data objects in the container.\n\t * @param version - Unique version of the source container in Azure Fluid Relay.\n\t * It defaults to latest version if parameter not provided.\n\t * @returns New detached container instance along with associated services.\n\t */\n\tpublic async copyContainer<TContainerSchema extends ContainerSchema>(\n\t\tid: string,\n\t\tcontainerSchema: TContainerSchema,\n\t\tversion?: AzureContainerVersion,\n\t): Promise<{\n\t\tcontainer: IFluidContainer<TContainerSchema>;\n\t\tservices: AzureContainerServices;\n\t}> {\n\t\tconst loader = this.createLoader(containerSchema);\n\t\tconst url = new URL(this.properties.connection.endpoint);\n\t\turl.searchParams.append(\"storage\", encodeURIComponent(this.properties.connection.endpoint));\n\t\turl.searchParams.append(\n\t\t\t\"tenantId\",\n\t\t\tencodeURIComponent(getTenantId(this.properties.connection)),\n\t\t);\n\t\turl.searchParams.append(\"containerId\", encodeURIComponent(id));\n\t\tconst sourceContainer = await loader.resolve({ url: url.href });\n\n\t\tif (sourceContainer.resolvedUrl === undefined) {\n\t\t\tthrow new Error(\"Source container cannot resolve URL.\");\n\t\t}\n\n\t\tconst documentService = await this.documentServiceFactory.createDocumentService(\n\t\t\tsourceContainer.resolvedUrl,\n\t\t);\n\t\tconst storage = await documentService.connectToStorage();\n\t\tconst handle = {\n\t\t\ttype: SummaryType.Handle,\n\t\t\thandleType: SummaryType.Tree,\n\t\t\thandle: version?.id ?? \"latest\",\n\t\t};\n\t\tconst tree = await storage.downloadSummary(handle);\n\n\t\tconst container = await loader.rehydrateDetachedContainerFromSnapshot(JSON.stringify(tree));\n\n\t\tconst fluidContainer = await this.createFluidContainer<TContainerSchema>(\n\t\t\tcontainer,\n\t\t\tthis.properties.connection,\n\t\t);\n\t\tconst services = this.getContainerServices(container);\n\t\treturn { container: fluidContainer, services };\n\t}\n\n\t/**\n\t * Accesses the existing container given its unique ID in the Azure Fluid Relay.\n\t * @typeparam TContainerSchema - Used to infer the the type of 'initialObjects' in the returned container.\n\t * (normally not explicitly specified.)\n\t * @param id - Unique ID of the container in Azure Fluid Relay.\n\t * @param containerSchema - Container schema used to access data objects in the container.\n\t * @returns Existing container instance along with associated services.\n\t */\n\tpublic async getContainer<TContainerSchema extends ContainerSchema>(\n\t\tid: string,\n\t\tcontainerSchema: TContainerSchema,\n\t): Promise<{\n\t\tcontainer: IFluidContainer<TContainerSchema>;\n\t\tservices: AzureContainerServices;\n\t}> {\n\t\tconst loader = this.createLoader(containerSchema);\n\t\tconst url = new URL(this.properties.connection.endpoint);\n\t\turl.searchParams.append(\"storage\", encodeURIComponent(this.properties.connection.endpoint));\n\t\turl.searchParams.append(\n\t\t\t\"tenantId\",\n\t\t\tencodeURIComponent(getTenantId(this.properties.connection)),\n\t\t);\n\t\turl.searchParams.append(\"containerId\", encodeURIComponent(id));\n\t\tconst container = await loader.resolve({ url: url.href });\n\t\tconst rootDataObject = (await container.getEntryPoint()) as IRootDataObject;\n\t\tconst fluidContainer = new FluidContainer<TContainerSchema>(container, rootDataObject);\n\t\tconst services = this.getContainerServices(container);\n\t\treturn { container: fluidContainer, services };\n\t}\n\n\t/**\n\t * Get the list of versions for specific container.\n\t * @param id - Unique ID of the source container in Azure Fluid Relay.\n\t * @param options - \"Get\" options. If options are not provided, API\n\t * will assume maxCount of versions to retreive to be 5.\n\t * @returns Array of available container versions.\n\t */\n\tpublic async getContainerVersions(\n\t\tid: string,\n\t\toptions?: AzureGetVersionsOptions,\n\t): Promise<AzureContainerVersion[]> {\n\t\tconst url = new URL(this.properties.connection.endpoint);\n\t\turl.searchParams.append(\"storage\", encodeURIComponent(this.properties.connection.endpoint));\n\t\turl.searchParams.append(\n\t\t\t\"tenantId\",\n\t\t\tencodeURIComponent(getTenantId(this.properties.connection)),\n\t\t);\n\t\turl.searchParams.append(\"containerId\", encodeURIComponent(id));\n\n\t\tconst resolvedUrl = await this.urlResolver.resolve({ url: url.href });\n\t\tif (!resolvedUrl) {\n\t\t\tthrow new Error(\"Unable to resolved URL\");\n\t\t}\n\t\tconst documentService =\n\t\t\tawait this.documentServiceFactory.createDocumentService(resolvedUrl);\n\t\tconst storage = await documentService.connectToStorage();\n\n\t\t// External API uses null\n\t\t// eslint-disable-next-line unicorn/no-null\n\t\tconst versions = await storage.getVersions(null, options?.maxCount ?? MAX_VERSION_COUNT);\n\n\t\treturn versions.map((item) => {\n\t\t\treturn { id: item.id, date: item.date };\n\t\t});\n\t}\n\n\tprivate getContainerServices(container: IContainer): AzureContainerServices {\n\t\treturn {\n\t\t\taudience: new AzureAudience(container),\n\t\t};\n\t}\n\n\tprivate createLoader(containerSchema: ContainerSchema): Loader {\n\t\tconst runtimeFactory = new DOProviderContainerRuntimeFactory(containerSchema);\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<TContainerSchema extends ContainerSchema>(\n\t\tcontainer: IContainer,\n\t\tconnection: AzureConnectionConfig,\n\t): Promise<FluidContainer<TContainerSchema>> {\n\t\tconst createNewRequest = createAzureCreateNewRequest(\n\t\t\tconnection.endpoint,\n\t\t\tgetTenantId(connection),\n\t\t);\n\n\t\tconst rootDataObject = (await container.getEntryPoint()) as IRootDataObject;\n\n\t\t/**\n\t\t * See {@link FluidContainer.attach}\n\t\t */\n\t\tconst attach = async (): Promise<string> => {\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\t\t\tif (container.resolvedUrl === undefined) {\n\t\t\t\tthrow new Error(\"Resolved Url not available on attached container\");\n\t\t\t}\n\t\t\treturn container.resolvedUrl.id;\n\t\t};\n\t\tconst fluidContainer = new FluidContainer<TContainerSchema>(container, rootDataObject);\n\t\tfluidContainer.attach = attach;\n\t\treturn fluidContainer;\n\t}\n\t// #endregion\n}\n"]}
|
|
1
|
+
{"version":3,"file":"AzureClient.cjs","sourceRoot":"","sources":["../src/AzureClient.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,iFAI+C;AAC/C,uEAA0D;AAK1D,+DAAuE;AACvE,+DAOsC;AACtC,+EAAiF;AACjF,+EAA2F;AAG3F,2DAAoD;AACpD,uDAA4D;AAC5D,6DAAmF;AAQnF,uCAAwD;AAExD;;GAEG;AACH,MAAM,oBAAoB,GAAG,OAAO,CAAC;AACrC,MAAM,WAAW,GAAG,CAAC,oBAA2C,EAAU,EAAE;IAC3E,OAAO,IAAA,qCAA6B,EAAC,oBAAoB,CAAC;QACzD,CAAC,CAAC,oBAAoB,CAAC,QAAQ;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,KAAK,CAAC,oBAAoB,CACjC,SAAqB,EACrB,UAAiC;QAEjC,MAAM,gBAAgB,GAAG,IAAA,8CAA2B,EACnD,UAAU,CAAC,QAAQ,EACnB,WAAW,CAAC,UAAU,CAAC,CACvB,CAAC;QAEF,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,sBAAsB,CAAC,SAAS,CAAC,CAAC;QAEpE;;WAEG;QACH,MAAM,MAAM,GAAG,KAAK,IAAqB,EAAE;YAC1C,IAAI,SAAS,CAAC,WAAW,KAAK,mCAAW,CAAC,QAAQ,EAAE;gBACnD,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;aAC/E;YACD,MAAM,SAAS,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;YACzC,IAAI,SAAS,CAAC,WAAW,KAAK,SAAS,EAAE;gBACxC,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;aACpE;YACD,OAAO,SAAS,CAAC,WAAW,CAAC,EAAE,CAAC;QACjC,CAAC,CAAC;QACF,MAAM,cAAc,GAAG,IAAA,mCAAoB,EAAmB;YAC7D,SAAS;YACT,cAAc;SACd,CAAC,CAAC;QACH,cAAc,CAAC,MAAM,GAAG,MAAM,CAAC;QAC/B,OAAO,cAAc,CAAC;IACvB,CAAC;IAEO,KAAK,CAAC,sBAAsB,CAAC,SAAqB;QACzD,MAAM,cAAc,GACnB,MAAM,SAAS,CAAC,aAAa,EAAE,CAAC;QACjC,IAAA,mBAAM,EAAC,cAAc,KAAK,SAAS,EAAE,uBAAuB,CAAC,CAAC;QAC9D,uHAAuH;QACvH,IAAI,cAAc,CAAC,eAAe,KAAK,SAAS,EAAE;YACjD,OAAO,cAAiC,CAAC;SACzC;QACD,OAAO,cAAc,CAAC,eAAe,CAAC;IACvC,CAAC;CAED;AArQD,kCAqQC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport {\n\tAttachState,\n\ttype IContainer,\n\ttype IFluidModuleWithDetails,\n} from \"@fluidframework/container-definitions\";\nimport { Loader } from \"@fluidframework/container-loader\";\nimport {\n\ttype IDocumentServiceFactory,\n\ttype IUrlResolver,\n} from \"@fluidframework/driver-definitions\";\nimport { applyStorageCompression } from \"@fluidframework/driver-utils\";\nimport {\n\ttype ContainerSchema,\n\tcreateDOProviderContainerRuntimeFactory,\n\tcreateFluidContainer,\n\ttype IFluidContainer,\n\ttype IRootDataObject,\n\tcreateServiceAudience,\n} from \"@fluidframework/fluid-static\";\nimport { type IClient, SummaryType } from \"@fluidframework/protocol-definitions\";\nimport { RouterliciousDocumentServiceFactory } from \"@fluidframework/routerlicious-driver\";\n\nimport { type IConfigProviderBase, type FluidObject } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { createAzureAudienceMember } from \"./AzureAudience\";\nimport { AzureUrlResolver, createAzureCreateNewRequest } from \"./AzureUrlResolver\";\nimport {\n\ttype AzureClientProps,\n\ttype AzureConnectionConfig,\n\ttype AzureContainerServices,\n\ttype AzureContainerVersion,\n\ttype AzureGetVersionsOptions,\n} from \"./interfaces\";\nimport { isAzureRemoteConnectionConfig } from \"./utils\";\n\n/**\n * Strongly typed id for connecting to a local Azure Fluid Relay.\n */\nconst LOCAL_MODE_TENANT_ID = \"local\";\nconst getTenantId = (connectionProperties: AzureConnectionConfig): string => {\n\treturn isAzureRemoteConnectionConfig(connectionProperties)\n\t\t? connectionProperties.tenantId\n\t\t: LOCAL_MODE_TENANT_ID;\n};\n\nconst MAX_VERSION_COUNT = 5;\n\n/**\n * AzureClient provides the ability to have a Fluid object backed by the Azure Fluid Relay or,\n * when running with local tenantId, have it be backed by a local Azure Fluid Relay instance.\n * @alpha\n */\nexport class AzureClient {\n\tprivate readonly documentServiceFactory: IDocumentServiceFactory;\n\tprivate readonly urlResolver: IUrlResolver;\n\tprivate readonly configProvider: IConfigProviderBase | undefined;\n\n\t/**\n\t * Creates a new client instance using configuration parameters.\n\t * @param properties - Properties for initializing a new AzureClient instance\n\t */\n\tpublic constructor(private readonly properties: AzureClientProps) {\n\t\t// remove trailing slash from URL if any\n\t\tproperties.connection.endpoint = properties.connection.endpoint.replace(/\\/$/, \"\");\n\t\tthis.urlResolver = new AzureUrlResolver();\n\t\t// The local service implementation differs from the Azure Fluid Relay in blob\n\t\t// storage format. Azure Fluid Relay supports whole summary upload. Local currently does not.\n\t\tconst isRemoteConnection = isAzureRemoteConnectionConfig(this.properties.connection);\n\t\tconst origDocumentServiceFactory: IDocumentServiceFactory =\n\t\t\tnew RouterliciousDocumentServiceFactory(this.properties.connection.tokenProvider, {\n\t\t\t\tenableWholeSummaryUpload: isRemoteConnection,\n\t\t\t\tenableDiscovery: isRemoteConnection,\n\t\t\t});\n\n\t\tthis.documentServiceFactory = applyStorageCompression(\n\t\t\torigDocumentServiceFactory,\n\t\t\tproperties.summaryCompression,\n\t\t);\n\t\tthis.configProvider = properties.configProvider;\n\t}\n\n\t/**\n\t * Creates a new detached container instance in the Azure Fluid Relay.\n\t * @typeparam TContainerSchema - Used to infer the the type of 'initialObjects' in the returned container.\n\t * (normally not explicitly specified.)\n\t * @param containerSchema - Container schema for the new container.\n\t * @returns New detached container instance along with associated services.\n\t */\n\tpublic async createContainer<TContainerSchema extends ContainerSchema>(\n\t\tcontainerSchema: TContainerSchema,\n\t): Promise<{\n\t\tcontainer: IFluidContainer<TContainerSchema>;\n\t\tservices: AzureContainerServices;\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<TContainerSchema>(\n\t\t\tcontainer,\n\t\t\tthis.properties.connection,\n\t\t);\n\t\tconst services = this.getContainerServices(container);\n\t\treturn { container: fluidContainer, services };\n\t}\n\n\t/**\n\t * Creates new detached container out of specific version of another container.\n\t * @typeparam TContainerSchema - Used to infer the the type of 'initialObjects' in the returned container.\n\t * (normally not explicitly specified.)\n\t * @param id - Unique ID of the source container in Azure Fluid Relay.\n\t * @param containerSchema - Container schema used to access data objects in the container.\n\t * @param version - Unique version of the source container in Azure Fluid Relay.\n\t * It defaults to latest version if parameter not provided.\n\t * @returns New detached container instance along with associated services.\n\t */\n\tpublic async copyContainer<TContainerSchema extends ContainerSchema>(\n\t\tid: string,\n\t\tcontainerSchema: TContainerSchema,\n\t\tversion?: AzureContainerVersion,\n\t): Promise<{\n\t\tcontainer: IFluidContainer<TContainerSchema>;\n\t\tservices: AzureContainerServices;\n\t}> {\n\t\tconst loader = this.createLoader(containerSchema);\n\t\tconst url = new URL(this.properties.connection.endpoint);\n\t\turl.searchParams.append(\"storage\", encodeURIComponent(this.properties.connection.endpoint));\n\t\turl.searchParams.append(\n\t\t\t\"tenantId\",\n\t\t\tencodeURIComponent(getTenantId(this.properties.connection)),\n\t\t);\n\t\turl.searchParams.append(\"containerId\", encodeURIComponent(id));\n\t\tconst sourceContainer = await loader.resolve({ url: url.href });\n\n\t\tif (sourceContainer.resolvedUrl === undefined) {\n\t\t\tthrow new Error(\"Source container cannot resolve URL.\");\n\t\t}\n\n\t\tconst documentService = await this.documentServiceFactory.createDocumentService(\n\t\t\tsourceContainer.resolvedUrl,\n\t\t);\n\t\tconst storage = await documentService.connectToStorage();\n\t\tconst handle = {\n\t\t\ttype: SummaryType.Handle,\n\t\t\thandleType: SummaryType.Tree,\n\t\t\thandle: version?.id ?? \"latest\",\n\t\t};\n\t\tconst tree = await storage.downloadSummary(handle);\n\n\t\tconst container = await loader.rehydrateDetachedContainerFromSnapshot(JSON.stringify(tree));\n\n\t\tconst fluidContainer = await this.createFluidContainer<TContainerSchema>(\n\t\t\tcontainer,\n\t\t\tthis.properties.connection,\n\t\t);\n\t\tconst services = this.getContainerServices(container);\n\t\treturn { container: fluidContainer, services };\n\t}\n\n\t/**\n\t * Accesses the existing container given its unique ID in the Azure Fluid Relay.\n\t * @typeparam TContainerSchema - Used to infer the the type of 'initialObjects' in the returned container.\n\t * (normally not explicitly specified.)\n\t * @param id - Unique ID of the container in Azure Fluid Relay.\n\t * @param containerSchema - Container schema used to access data objects in the container.\n\t * @returns Existing container instance along with associated services.\n\t */\n\tpublic async getContainer<TContainerSchema extends ContainerSchema>(\n\t\tid: string,\n\t\tcontainerSchema: TContainerSchema,\n\t): Promise<{\n\t\tcontainer: IFluidContainer<TContainerSchema>;\n\t\tservices: AzureContainerServices;\n\t}> {\n\t\tconst loader = this.createLoader(containerSchema);\n\t\tconst url = new URL(this.properties.connection.endpoint);\n\t\turl.searchParams.append(\"storage\", encodeURIComponent(this.properties.connection.endpoint));\n\t\turl.searchParams.append(\n\t\t\t\"tenantId\",\n\t\t\tencodeURIComponent(getTenantId(this.properties.connection)),\n\t\t);\n\t\turl.searchParams.append(\"containerId\", encodeURIComponent(id));\n\t\tconst container = await loader.resolve({ url: url.href });\n\t\tconst rootDataObject = await this.getContainerEntryPoint(container);\n\t\tconst fluidContainer = createFluidContainer<TContainerSchema>({\n\t\t\tcontainer,\n\t\t\trootDataObject,\n\t\t});\n\t\tconst services = this.getContainerServices(container);\n\t\treturn { container: fluidContainer, services };\n\t}\n\n\t/**\n\t * Get the list of versions for specific container.\n\t * @param id - Unique ID of the source container in Azure Fluid Relay.\n\t * @param options - \"Get\" options. If options are not provided, API\n\t * will assume maxCount of versions to retreive to be 5.\n\t * @returns Array of available container versions.\n\t */\n\tpublic async getContainerVersions(\n\t\tid: string,\n\t\toptions?: AzureGetVersionsOptions,\n\t): Promise<AzureContainerVersion[]> {\n\t\tconst url = new URL(this.properties.connection.endpoint);\n\t\turl.searchParams.append(\"storage\", encodeURIComponent(this.properties.connection.endpoint));\n\t\turl.searchParams.append(\n\t\t\t\"tenantId\",\n\t\t\tencodeURIComponent(getTenantId(this.properties.connection)),\n\t\t);\n\t\turl.searchParams.append(\"containerId\", encodeURIComponent(id));\n\n\t\tconst resolvedUrl = await this.urlResolver.resolve({ url: url.href });\n\t\tif (!resolvedUrl) {\n\t\t\tthrow new Error(\"Unable to resolved URL\");\n\t\t}\n\t\tconst documentService =\n\t\t\tawait this.documentServiceFactory.createDocumentService(resolvedUrl);\n\t\tconst storage = await documentService.connectToStorage();\n\n\t\t// External API uses null\n\t\t// eslint-disable-next-line unicorn/no-null\n\t\tconst versions = await storage.getVersions(null, options?.maxCount ?? MAX_VERSION_COUNT);\n\n\t\treturn versions.map((item) => {\n\t\t\treturn { id: item.id, date: item.date };\n\t\t});\n\t}\n\n\tprivate getContainerServices(container: IContainer): AzureContainerServices {\n\t\treturn {\n\t\t\taudience: createServiceAudience({\n\t\t\t\tcontainer,\n\t\t\t\tcreateServiceMember: createAzureAudienceMember,\n\t\t\t}),\n\t\t};\n\t}\n\n\tprivate createLoader(schema: ContainerSchema): Loader {\n\t\tconst runtimeFactory = createDOProviderContainerRuntimeFactory({ schema });\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<TContainerSchema extends ContainerSchema>(\n\t\tcontainer: IContainer,\n\t\tconnection: AzureConnectionConfig,\n\t): Promise<IFluidContainer<TContainerSchema>> {\n\t\tconst createNewRequest = createAzureCreateNewRequest(\n\t\t\tconnection.endpoint,\n\t\t\tgetTenantId(connection),\n\t\t);\n\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 (): Promise<string> => {\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\t\t\tif (container.resolvedUrl === undefined) {\n\t\t\t\tthrow new Error(\"Resolved Url not available on attached container\");\n\t\t\t}\n\t\t\treturn container.resolvedUrl.id;\n\t\t};\n\t\tconst fluidContainer = createFluidContainer<TContainerSchema>({\n\t\t\tcontainer,\n\t\t\trootDataObject,\n\t\t});\n\t\tfluidContainer.attach = attach;\n\t\treturn fluidContainer;\n\t}\n\n\tprivate async getContainerEntryPoint(container: IContainer): Promise<IRootDataObject> {\n\t\tconst rootDataObject: FluidObject<IRootDataObject> | undefined =\n\t\t\tawait container.getEntryPoint();\n\t\tassert(rootDataObject !== undefined, \"entryPoint must exist\");\n\t\t// ! This \"if\" is needed for back-compat (older instances of IRootDataObject may not have the IRootDataObject property)\n\t\tif (rootDataObject.IRootDataObject === undefined) {\n\t\t\treturn rootDataObject as IRootDataObject;\n\t\t}\n\t\treturn rootDataObject.IRootDataObject;\n\t}\n\t// #endregion\n}\n"]}
|
package/dist/AzureClient.d.ts
CHANGED
|
@@ -3,8 +3,7 @@ import { type AzureClientProps, type AzureContainerServices, type AzureContainer
|
|
|
3
3
|
/**
|
|
4
4
|
* AzureClient provides the ability to have a Fluid object backed by the Azure Fluid Relay or,
|
|
5
5
|
* when running with local tenantId, have it be backed by a local Azure Fluid Relay instance.
|
|
6
|
-
*
|
|
7
|
-
* @public
|
|
6
|
+
* @alpha
|
|
8
7
|
*/
|
|
9
8
|
export declare class AzureClient {
|
|
10
9
|
private readonly properties;
|
|
@@ -64,5 +63,6 @@ export declare class AzureClient {
|
|
|
64
63
|
private getContainerServices;
|
|
65
64
|
private createLoader;
|
|
66
65
|
private createFluidContainer;
|
|
66
|
+
private getContainerEntryPoint;
|
|
67
67
|
}
|
|
68
68
|
//# sourceMappingURL=AzureClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AzureClient.d.ts","sourceRoot":"","sources":["../src/AzureClient.ts"],"names":[],"mappings":"AAeA,OAAO,EACN,KAAK,eAAe,EAGpB,KAAK,eAAe,
|
|
1
|
+
{"version":3,"file":"AzureClient.d.ts","sourceRoot":"","sources":["../src/AzureClient.ts"],"names":[],"mappings":"AAeA,OAAO,EACN,KAAK,eAAe,EAGpB,KAAK,eAAe,EAGpB,MAAM,8BAA8B,CAAC;AAQtC,OAAO,EACN,KAAK,gBAAgB,EAErB,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,MAAM,cAAc,CAAC;AAetB;;;;GAIG;AACH,qBAAa,WAAW;IASJ,OAAO,CAAC,QAAQ,CAAC,UAAU;IAR9C,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAA0B;IACjE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAe;IAC3C,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAkC;IAEjE;;;OAGG;gBACiC,UAAU,EAAE,gBAAgB;IAoBhE;;;;;;OAMG;IACU,eAAe,CAAC,gBAAgB,SAAS,eAAe,EACpE,eAAe,EAAE,gBAAgB,GAC/B,OAAO,CAAC;QACV,SAAS,EAAE,eAAe,CAAC,gBAAgB,CAAC,CAAC;QAC7C,QAAQ,EAAE,sBAAsB,CAAC;KACjC,CAAC;IAgBF;;;;;;;;;OASG;IACU,aAAa,CAAC,gBAAgB,SAAS,eAAe,EAClE,EAAE,EAAE,MAAM,EACV,eAAe,EAAE,gBAAgB,EACjC,OAAO,CAAC,EAAE,qBAAqB,GAC7B,OAAO,CAAC;QACV,SAAS,EAAE,eAAe,CAAC,gBAAgB,CAAC,CAAC;QAC7C,QAAQ,EAAE,sBAAsB,CAAC;KACjC,CAAC;IAoCF;;;;;;;OAOG;IACU,YAAY,CAAC,gBAAgB,SAAS,eAAe,EACjE,EAAE,EAAE,MAAM,EACV,eAAe,EAAE,gBAAgB,GAC/B,OAAO,CAAC;QACV,SAAS,EAAE,eAAe,CAAC,gBAAgB,CAAC,CAAC;QAC7C,QAAQ,EAAE,sBAAsB,CAAC;KACjC,CAAC;IAmBF;;;;;;OAMG;IACU,oBAAoB,CAChC,EAAE,EAAE,MAAM,EACV,OAAO,CAAC,EAAE,uBAAuB,GAC/B,OAAO,CAAC,qBAAqB,EAAE,CAAC;IA0BnC,OAAO,CAAC,oBAAoB;IAS5B,OAAO,CAAC,YAAY;YA8BN,oBAAoB;YAgCpB,sBAAsB;CAWpC"}
|
|
@@ -16,8 +16,7 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
16
16
|
* @deprecated 1.2.0, This API will be removed in 2.0.0
|
|
17
17
|
* No replacement since it is not expected anyone will use this token provider as is
|
|
18
18
|
* See https://github.com/microsoft/FluidFramework/issues/13693 for context
|
|
19
|
-
*
|
|
20
|
-
* @public
|
|
19
|
+
* @internal
|
|
21
20
|
*/
|
|
22
21
|
class AzureFunctionTokenProvider {
|
|
23
22
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AzureFunctionTokenProvider.cjs","sourceRoot":"","sources":["../src/AzureFunctionTokenProvider.ts"],"names":[],"mappings":";;;;;;AAAA;;;GAGG;AACH,kDAA0B;AAM1B
|
|
1
|
+
{"version":3,"file":"AzureFunctionTokenProvider.cjs","sourceRoot":"","sources":["../src/AzureFunctionTokenProvider.ts"],"names":[],"mappings":";;;;;;AAAA;;;GAGG;AACH,kDAA0B;AAM1B;;;;;;;;GAQG;AACH,MAAa,0BAA0B;IACtC;;;;OAIG;IACH,YACkB,aAAqB,EACrB,IAAqE;QADrE,kBAAa,GAAb,aAAa,CAAQ;QACrB,SAAI,GAAJ,IAAI,CAAiE;IACpF,CAAC;IAEG,KAAK,CAAC,iBAAiB,CAAC,QAAgB,EAAE,UAAmB;QACnE,OAAO;YACN,GAAG,EAAE,MAAM,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;SAC9C,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,iBAAiB,CAAC,QAAgB,EAAE,UAAkB;QAClE,OAAO;YACN,GAAG,EAAE,MAAM,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;SAC9C,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,QAAQ,CAAC,QAAgB,EAAE,UAAmB;QAC3D,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,EAAE;YACpD,MAAM,EAAE;gBACP,QAAQ;gBACR,UAAU;gBACV,MAAM,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM;gBACzB,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ;gBAC7B,iBAAiB,EAAE,IAAI,CAAC,IAAI,EAAE,iBAA4B;aAC1D;SACD,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC,IAAc,CAAC;IAChC,CAAC;CACD;AAnCD,gEAmCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport axios from \"axios\";\n\nimport { type ITokenProvider, type ITokenResponse } from \"@fluidframework/routerlicious-driver\";\n\nimport { type AzureMember } from \"./interfaces\";\n\n/**\n * Token Provider implementation for connecting to an Azure Function endpoint for\n * Azure Fluid Relay token resolution.\n *\n * @deprecated 1.2.0, This API will be removed in 2.0.0\n * No replacement since it is not expected anyone will use this token provider as is\n * See https://github.com/microsoft/FluidFramework/issues/13693 for context\n * @internal\n */\nexport class AzureFunctionTokenProvider implements ITokenProvider {\n\t/**\n\t * Creates a new instance using configuration parameters.\n\t * @param azFunctionUrl - URL to Azure Function endpoint\n\t * @param user - User object\n\t */\n\tpublic constructor(\n\t\tprivate readonly azFunctionUrl: string,\n\t\tprivate readonly user?: Pick<AzureMember, \"userId\" | \"userName\" | \"additionalDetails\">,\n\t) {}\n\n\tpublic async fetchOrdererToken(tenantId: string, documentId?: string): Promise<ITokenResponse> {\n\t\treturn {\n\t\t\tjwt: await this.getToken(tenantId, documentId),\n\t\t};\n\t}\n\n\tpublic async fetchStorageToken(tenantId: string, documentId: string): Promise<ITokenResponse> {\n\t\treturn {\n\t\t\tjwt: await this.getToken(tenantId, documentId),\n\t\t};\n\t}\n\n\tprivate async getToken(tenantId: string, documentId?: string): Promise<string> {\n\t\tconst response = await axios.get(this.azFunctionUrl, {\n\t\t\tparams: {\n\t\t\t\ttenantId,\n\t\t\t\tdocumentId,\n\t\t\t\tuserId: this.user?.userId,\n\t\t\t\tuserName: this.user?.userName,\n\t\t\t\tadditionalDetails: this.user?.additionalDetails as unknown,\n\t\t\t},\n\t\t});\n\t\treturn response.data as string;\n\t}\n}\n"]}
|
|
@@ -7,8 +7,7 @@ import { type AzureMember } from "./interfaces";
|
|
|
7
7
|
* @deprecated 1.2.0, This API will be removed in 2.0.0
|
|
8
8
|
* No replacement since it is not expected anyone will use this token provider as is
|
|
9
9
|
* See https://github.com/microsoft/FluidFramework/issues/13693 for context
|
|
10
|
-
*
|
|
11
|
-
* @public
|
|
10
|
+
* @internal
|
|
12
11
|
*/
|
|
13
12
|
export declare class AzureFunctionTokenProvider implements ITokenProvider {
|
|
14
13
|
private readonly azFunctionUrl;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AzureFunctionTokenProvider.d.ts","sourceRoot":"","sources":["../src/AzureFunctionTokenProvider.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAEhG,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD
|
|
1
|
+
{"version":3,"file":"AzureFunctionTokenProvider.d.ts","sourceRoot":"","sources":["../src/AzureFunctionTokenProvider.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAEhG,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD;;;;;;;;GAQG;AACH,qBAAa,0BAA2B,YAAW,cAAc;IAO/D,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;IAPvB;;;;OAIG;gBAEe,aAAa,EAAE,MAAM,EACrB,IAAI,CAAC,iFAAgE;IAG1E,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAMjF,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;YAM/E,QAAQ;CAYtB"}
|