@fluidframework/azure-client 1.1.0-74609 → 1.1.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.
Files changed (74) hide show
  1. package/.eslintrc.js +5 -7
  2. package/CHANGELOG.md +1 -2
  3. package/README.md +12 -10
  4. package/api-extractor.json +1 -1
  5. package/dist/AzureAudience.d.ts +7 -5
  6. package/dist/AzureAudience.d.ts.map +1 -1
  7. package/dist/AzureAudience.js +13 -4
  8. package/dist/AzureAudience.js.map +1 -1
  9. package/dist/AzureClient.d.ts.map +1 -1
  10. package/dist/AzureClient.js +25 -17
  11. package/dist/AzureClient.js.map +1 -1
  12. package/dist/AzureFunctionTokenProvider.d.ts +0 -4
  13. package/dist/AzureFunctionTokenProvider.d.ts.map +1 -1
  14. package/dist/AzureFunctionTokenProvider.js +4 -4
  15. package/dist/AzureFunctionTokenProvider.js.map +1 -1
  16. package/dist/AzureUrlResolver.d.ts +7 -0
  17. package/dist/AzureUrlResolver.d.ts.map +1 -1
  18. package/dist/AzureUrlResolver.js +11 -13
  19. package/dist/AzureUrlResolver.js.map +1 -1
  20. package/dist/index.d.ts +5 -5
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +7 -15
  23. package/dist/index.js.map +1 -1
  24. package/dist/interfaces.d.ts +34 -4
  25. package/dist/interfaces.d.ts.map +1 -1
  26. package/dist/interfaces.js +0 -4
  27. package/dist/interfaces.js.map +1 -1
  28. package/dist/packageVersion.d.ts +1 -1
  29. package/dist/packageVersion.d.ts.map +1 -1
  30. package/dist/packageVersion.js +1 -1
  31. package/dist/packageVersion.js.map +1 -1
  32. package/dist/utils.d.ts +1 -1
  33. package/dist/utils.d.ts.map +1 -1
  34. package/dist/utils.js.map +1 -1
  35. package/lib/AzureAudience.d.ts +7 -5
  36. package/lib/AzureAudience.d.ts.map +1 -1
  37. package/lib/AzureAudience.js +11 -2
  38. package/lib/AzureAudience.js.map +1 -1
  39. package/lib/AzureClient.d.ts.map +1 -1
  40. package/lib/AzureClient.js +27 -19
  41. package/lib/AzureClient.js.map +1 -1
  42. package/lib/AzureFunctionTokenProvider.d.ts +0 -4
  43. package/lib/AzureFunctionTokenProvider.d.ts.map +1 -1
  44. package/lib/AzureFunctionTokenProvider.js.map +1 -1
  45. package/lib/AzureUrlResolver.d.ts +7 -0
  46. package/lib/AzureUrlResolver.d.ts.map +1 -1
  47. package/lib/AzureUrlResolver.js +11 -13
  48. package/lib/AzureUrlResolver.js.map +1 -1
  49. package/lib/index.d.ts +5 -5
  50. package/lib/index.d.ts.map +1 -1
  51. package/lib/index.js +3 -4
  52. package/lib/index.js.map +1 -1
  53. package/lib/interfaces.d.ts +34 -4
  54. package/lib/interfaces.d.ts.map +1 -1
  55. package/lib/interfaces.js +0 -4
  56. package/lib/interfaces.js.map +1 -1
  57. package/lib/packageVersion.d.ts +1 -1
  58. package/lib/packageVersion.d.ts.map +1 -1
  59. package/lib/packageVersion.js +1 -1
  60. package/lib/packageVersion.js.map +1 -1
  61. package/lib/utils.d.ts +1 -1
  62. package/lib/utils.d.ts.map +1 -1
  63. package/lib/utils.js.map +1 -1
  64. package/package.json +40 -29
  65. package/src/AzureAudience.ts +23 -13
  66. package/src/AzureClient.ts +46 -72
  67. package/src/AzureFunctionTokenProvider.ts +4 -3
  68. package/src/AzureUrlResolver.ts +15 -24
  69. package/src/index.ts +19 -5
  70. package/src/interfaces.ts +42 -12
  71. package/src/packageVersion.ts +1 -1
  72. package/src/utils.ts +9 -3
  73. package/tsconfig.esnext.json +5 -5
  74. package/tsconfig.json +9 -15
@@ -2,7 +2,6 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
-
6
5
  import { IRequest } from "@fluidframework/core-interfaces";
7
6
  import {
8
7
  DriverHeader,
@@ -11,23 +10,21 @@ import {
11
10
  IUrlResolver,
12
11
  } from "@fluidframework/driver-definitions";
13
12
 
14
- // Implementation of a URL resolver to resolve documents stored using the Azure Fluid Relay
15
- // based off of the orderer and storage URLs provide. The token provider here can be a
16
- // InsecureTokenProvider for basic scenarios or more robust, secure providers that fulfill the
17
- // ITokenProvider interface
13
+ /**
14
+ * Implementation of {@link @fluidframework/driver-definitions#IUrlResolver} to resolve documents stored using the
15
+ * Azure Fluid Relay based off of the orderer and storage URLs provide.
16
+ *
17
+ * @remarks The token provider here can be an `InsecureTokenProvider` for basic scenarios or more robust, secure
18
+ * providers that fulfill the {@link @fluidframework/routerlicious-driver#ITokenProvider} interface.
19
+ */
18
20
  export class AzureUrlResolver implements IUrlResolver {
19
- constructor() { }
21
+ constructor() {}
20
22
 
21
23
  public async resolve(request: IRequest): Promise<IFluidResolvedUrl> {
22
- const { ordererUrl, storageUrl, tenantId, containerId } = decodeAzureUrl(
23
- request.url,
24
- );
24
+ const { ordererUrl, storageUrl, tenantId, containerId } = decodeAzureUrl(request.url);
25
25
  // determine whether the request is for creating of a new container.
26
26
  // such request has the `createNew` header set to true and doesn't have a container ID.
27
- if (
28
- request.headers &&
29
- request.headers[DriverHeader.createNew] === true
30
- ) {
27
+ if (request.headers && request.headers[DriverHeader.createNew] === true) {
31
28
  return {
32
29
  endpoints: {
33
30
  deltaStorageUrl: `${ordererUrl}/deltas/${tenantId}/new`,
@@ -46,7 +43,7 @@ export class AzureUrlResolver implements IUrlResolver {
46
43
  throw new Error("Azure URL did not contain containerId");
47
44
  }
48
45
  const documentUrl = `${ordererUrl}/${tenantId}/${containerId}`;
49
- return Promise.resolve({
46
+ return {
50
47
  endpoints: {
51
48
  deltaStorageUrl: `${ordererUrl}/deltas/${tenantId}/${containerId}`,
52
49
  ordererUrl,
@@ -56,15 +53,12 @@ export class AzureUrlResolver implements IUrlResolver {
56
53
  tokens: {},
57
54
  type: "fluid",
58
55
  url: documentUrl,
59
- });
56
+ };
60
57
  }
61
58
 
62
- public async getAbsoluteUrl(
63
- resolvedUrl: IResolvedUrl,
64
- relativeUrl: string,
65
- ): Promise<string> {
59
+ public async getAbsoluteUrl(resolvedUrl: IResolvedUrl, relativeUrl: string): Promise<string> {
66
60
  if (resolvedUrl.type !== "fluid") {
67
- throw Error("Invalid Resolved Url");
61
+ throw new Error("Invalid Resolved Url");
68
62
  }
69
63
  return `${resolvedUrl.url}/${relativeUrl}`;
70
64
  }
@@ -99,10 +93,7 @@ function decodeAzureUrl(urlString: string): {
99
93
  };
100
94
  }
101
95
 
102
- export const createAzureCreateNewRequest = (
103
- endpointUrl: string,
104
- tenantId: string,
105
- ): IRequest => {
96
+ export const createAzureCreateNewRequest = (endpointUrl: string, tenantId: string): IRequest => {
106
97
  const url = new URL(endpointUrl);
107
98
  url.searchParams.append("storage", encodeURIComponent(endpointUrl));
108
99
  url.searchParams.append("tenantId", encodeURIComponent(tenantId));
package/src/index.ts CHANGED
@@ -9,10 +9,24 @@
9
9
  * @packageDocumentation
10
10
  */
11
11
 
12
- export * from "./AzureAudience";
13
- export * from "./AzureClient";
14
- export * from "./AzureFunctionTokenProvider";
15
- export * from "./interfaces";
12
+ export { AzureAudience } from "./AzureAudience";
13
+ export { AzureClient } from "./AzureClient";
14
+ export { AzureFunctionTokenProvider } from "./AzureFunctionTokenProvider";
15
+ export {
16
+ AzureClientProps,
17
+ AzureConnectionConfig,
18
+ AzureConnectionConfigType,
19
+ AzureContainerServices,
20
+ AzureContainerVersion,
21
+ AzureGetVersionsOptions,
22
+ AzureLocalConnectionConfig,
23
+ AzureMember,
24
+ AzureRemoteConnectionConfig,
25
+ AzureUser,
26
+ IAzureAudience,
27
+ ITelemetryBaseEvent,
28
+ ITelemetryBaseLogger,
29
+ } from "./interfaces";
16
30
 
17
31
  export { ITokenProvider, ITokenResponse } from "@fluidframework/routerlicious-driver";
18
- export { ScopeType, ITokenClaims, IUser } from "@fluidframework/protocol-definitions";
32
+ export { ITokenClaims, IUser, ScopeType } from "@fluidframework/protocol-definitions";
package/src/interfaces.ts CHANGED
@@ -2,19 +2,13 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
-
6
5
  import { ITelemetryBaseLogger } from "@fluidframework/common-definitions";
7
- import {
8
- IMember,
9
- IServiceAudience,
10
- } from "@fluidframework/fluid-static";
6
+ import { IMember, IServiceAudience } from "@fluidframework/fluid-static";
7
+ import { IUser } from "@fluidframework/protocol-definitions";
11
8
  import { ITokenProvider } from "@fluidframework/routerlicious-driver";
12
9
 
13
10
  // Re-export so developers can build loggers without pulling in common-definitions
14
- export {
15
- ITelemetryBaseEvent,
16
- ITelemetryBaseLogger,
17
- } from "@fluidframework/common-definitions";
11
+ export { ITelemetryBaseEvent, ITelemetryBaseLogger } from "@fluidframework/common-definitions";
18
12
 
19
13
  /**
20
14
  * Props for initializing a new AzureClient instance
@@ -23,7 +17,7 @@ export interface AzureClientProps {
23
17
  /**
24
18
  * Configuration for establishing a connection with the Azure Fluid Relay.
25
19
  */
26
- readonly connection: AzureConnectionConfig;
20
+ readonly connection: AzureRemoteConnectionConfig | AzureLocalConnectionConfig;
27
21
  /**
28
22
  * Optional. A logger instance to receive diagnostic messages.
29
23
  */
@@ -121,11 +115,47 @@ export interface AzureContainerServices {
121
115
  }
122
116
 
123
117
  /**
124
- * Since Azure provides user names for all of its members, we extend the IMember interface to include
125
- * this service-specific value. It will be returned for all audience members connected to Azure.
118
+ * Since Azure provides user names for all of its members, we extend the
119
+ * {@link @fluidframework/protocol-definitions#IUser} interface to include this service-specific value. *
120
+ *
121
+ * @typeParam T - See {@link AzureUser.additionalDetails}.
122
+ * Note: must be JSON-serializable.
123
+ * Passing a non-serializable object (e.g. a `class`) will result in undefined behavior.
124
+ */
125
+ // TODO: this should be updated to use something other than `any` (unknown)
126
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
127
+ export interface AzureUser<T = any> extends IUser {
128
+ /**
129
+ * The user's name
130
+ */
131
+ name: string;
132
+
133
+ /**
134
+ * Custom, app-specific user information
135
+ */
136
+ additionalDetails?: T;
137
+ }
138
+
139
+ /**
140
+ * Since Azure provides user names for all of its members, we extend the
141
+ * {@link @fluidframework/protocol-definitions#IMember} interface to include this service-specific value.
142
+ * It will be returned for all audience members connected to Azure.
143
+ *
144
+ * @typeParam T - See {@link AzureMember.additionalDetails}.
145
+ * Note: must be JSON-serializable.
146
+ * Passing a non-serializable object (e.g. a `class`) will result in undefined behavior.
126
147
  */
148
+ // TODO: this should be updated to use something other than `any` (unknown)
149
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
127
150
  export interface AzureMember<T = any> extends IMember {
151
+ /**
152
+ * {@inheritDoc AzureUser.name}
153
+ */
128
154
  userName: string;
155
+
156
+ /**
157
+ * {@inheritDoc AzureUser.additionalDetails}
158
+ */
129
159
  additionalDetails?: T;
130
160
  }
131
161
 
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/azure-client";
9
- export const pkgVersion = "1.1.0-74609";
9
+ export const pkgVersion = "1.1.1";
package/src/utils.ts CHANGED
@@ -2,13 +2,18 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { AzureRemoteConnectionConfig, AzureLocalConnectionConfig, AzureConnectionConfig } from "./interfaces";
5
+ import {
6
+ AzureConnectionConfig,
7
+ AzureLocalConnectionConfig,
8
+ AzureRemoteConnectionConfig,
9
+ } from "./interfaces";
6
10
 
7
11
  /**
8
12
  * Type guard for validating a given AzureConnectionConfig is a remote connection type (AzureRemoteConnectionConfig)
9
13
  */
10
14
  export function isAzureRemoteConnectionConfig(
11
- connectionConfig: AzureConnectionConfig): connectionConfig is AzureRemoteConnectionConfig {
15
+ connectionConfig: AzureConnectionConfig,
16
+ ): connectionConfig is AzureRemoteConnectionConfig {
12
17
  return connectionConfig.type === "remote";
13
18
  }
14
19
 
@@ -16,6 +21,7 @@ export function isAzureRemoteConnectionConfig(
16
21
  * Type guard for validating a given AzureConnectionConfig is a local connection type (AzureLocalConnectionConfig)
17
22
  */
18
23
  export function isAzureLocalConnectionConfig(
19
- connectionConfig: AzureConnectionConfig): connectionConfig is AzureLocalConnectionConfig {
24
+ connectionConfig: AzureConnectionConfig,
25
+ ): connectionConfig is AzureLocalConnectionConfig {
20
26
  return connectionConfig.type === "local";
21
27
  }
@@ -1,7 +1,7 @@
1
1
  {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "./lib",
5
- "module": "esnext"
6
- },
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "./lib",
5
+ "module": "esnext",
6
+ },
7
7
  }
package/tsconfig.json CHANGED
@@ -1,17 +1,11 @@
1
1
  {
2
- "extends": "@fluidframework/build-common/ts-common-config.json",
3
- "compilerOptions": {
4
- "rootDir": "./src",
5
- "outDir": "./dist",
6
- "composite": true,
7
- "types": [
8
- "node"
9
- ]
10
- },
11
- "include": [
12
- "src/**/*"
13
- ],
14
- "exclude": [
15
- "src/test/**/*"
16
- ]
2
+ "extends": "@fluidframework/build-common/ts-common-config.json",
3
+ "compilerOptions": {
4
+ "rootDir": "./src",
5
+ "outDir": "./dist",
6
+ "composite": true,
7
+ "types": ["node"],
8
+ },
9
+ "include": ["src/**/*"],
10
+ "exclude": ["src/test/**/*"],
17
11
  }