@fluidframework/azure-client 2.0.0-dev-rc.3.0.0.254674 → 2.0.0-dev-rc.4.0.0.261659

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 (43) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +3 -3
  3. package/api-report/azure-client.api.md +5 -6
  4. package/beta.d.ts +11 -0
  5. package/dist/AzureAudience.js +5 -6
  6. package/dist/AzureAudience.js.map +1 -1
  7. package/dist/AzureClient.d.ts +9 -11
  8. package/dist/AzureClient.d.ts.map +1 -1
  9. package/dist/AzureClient.js +36 -43
  10. package/dist/AzureClient.js.map +1 -1
  11. package/dist/AzureFunctionTokenProvider.d.ts +1 -1
  12. package/dist/AzureFunctionTokenProvider.d.ts.map +1 -1
  13. package/dist/AzureFunctionTokenProvider.js +2 -2
  14. package/dist/AzureFunctionTokenProvider.js.map +1 -1
  15. package/dist/beta.d.ts +2 -1
  16. package/dist/interfaces.d.ts +1 -1
  17. package/dist/interfaces.d.ts.map +1 -1
  18. package/dist/interfaces.js.map +1 -1
  19. package/dist/{alpha.d.ts → legacy.d.ts} +3 -2
  20. package/dist/public.d.ts +2 -1
  21. package/internal.d.ts +11 -0
  22. package/legacy.d.ts +11 -0
  23. package/lib/AzureAudience.js +5 -6
  24. package/lib/AzureAudience.js.map +1 -1
  25. package/lib/AzureClient.d.ts +9 -11
  26. package/lib/AzureClient.d.ts.map +1 -1
  27. package/lib/AzureClient.js +22 -29
  28. package/lib/AzureClient.js.map +1 -1
  29. package/lib/AzureFunctionTokenProvider.d.ts +1 -1
  30. package/lib/AzureFunctionTokenProvider.d.ts.map +1 -1
  31. package/lib/AzureFunctionTokenProvider.js +2 -2
  32. package/lib/AzureFunctionTokenProvider.js.map +1 -1
  33. package/lib/beta.d.ts +2 -1
  34. package/lib/interfaces.d.ts +1 -1
  35. package/lib/interfaces.d.ts.map +1 -1
  36. package/lib/interfaces.js.map +1 -1
  37. package/lib/{alpha.d.ts → legacy.d.ts} +3 -2
  38. package/lib/public.d.ts +2 -1
  39. package/package.json +40 -31
  40. package/src/AzureAudience.ts +5 -6
  41. package/src/AzureClient.ts +23 -39
  42. package/src/AzureFunctionTokenProvider.ts +3 -3
  43. package/src/interfaces.ts +1 -1
@@ -18,8 +18,8 @@ export function createAzureAudienceMember(audienceMember: IClient): AzureMember
18
18
  assertIsAzureUser(user);
19
19
 
20
20
  return {
21
- userId: user.id,
22
- userName: user.name,
21
+ id: user.id,
22
+ name: user.name,
23
23
  connections: [],
24
24
  additionalDetails: user.additionalDetails,
25
25
  };
@@ -34,8 +34,7 @@ function assertIsAzureUser(user: IUser): asserts user is AzureUser<unknown> {
34
34
  if (maybeAzureUser.id === undefined) {
35
35
  throw new TypeError(`${baseMessage} Missing required "id" property.`);
36
36
  }
37
- // AB#7448 to reenable this check. Disabling to mitigate a bug that the name may be missing.
38
- // if (maybeAzureUser.name === undefined) {
39
- // throw new TypeError(`${baseMessage} Missing required "name" property.`);
40
- // }
37
+ if (maybeAzureUser.name === undefined) {
38
+ throw new TypeError(`${baseMessage} Missing required "name" property.`);
39
+ }
41
40
  }
@@ -7,8 +7,9 @@ import { AttachState } from "@fluidframework/container-definitions";
7
7
  import {
8
8
  type IContainer,
9
9
  type IFluidModuleWithDetails,
10
+ LoaderHeader,
10
11
  } from "@fluidframework/container-definitions/internal";
11
- import { Loader } from "@fluidframework/container-loader/internal";
12
+ import { Loader, loadContainerPaused } from "@fluidframework/container-loader/internal";
12
13
  import { type FluidObject, type IConfigProviderBase } from "@fluidframework/core-interfaces";
13
14
  import { assert } from "@fluidframework/core-utils/internal";
14
15
  import {
@@ -23,7 +24,7 @@ import {
23
24
  createFluidContainer,
24
25
  createServiceAudience,
25
26
  } from "@fluidframework/fluid-static/internal";
26
- import { type IClient, SummaryType } from "@fluidframework/protocol-definitions";
27
+ import { type IClient } from "@fluidframework/protocol-definitions";
27
28
  import { RouterliciousDocumentServiceFactory } from "@fluidframework/routerlicious-driver/internal";
28
29
  import { wrapConfigProviderWithDefaults } from "@fluidframework/telemetry-utils/internal";
29
30
 
@@ -145,19 +146,16 @@ export class AzureClient {
145
146
  }
146
147
 
147
148
  /**
148
- * Creates new detached container out of specific version of another container.
149
+ * Accesses the existing container given its unique ID in the Azure Fluid Relay.
149
150
  * @typeparam TContainerSchema - Used to infer the the type of 'initialObjects' in the returned container.
150
151
  * (normally not explicitly specified.)
151
- * @param id - Unique ID of the source container in Azure Fluid Relay.
152
+ * @param id - Unique ID of the container in Azure Fluid Relay.
152
153
  * @param containerSchema - Container schema used to access data objects in the container.
153
- * @param version - Unique version of the source container in Azure Fluid Relay.
154
- * It defaults to latest version if parameter not provided.
155
- * @returns New detached container instance along with associated services.
154
+ * @returns Existing container instance along with associated services.
156
155
  */
157
- public async copyContainer<TContainerSchema extends ContainerSchema>(
156
+ public async getContainer<TContainerSchema extends ContainerSchema>(
158
157
  id: string,
159
158
  containerSchema: TContainerSchema,
160
- version?: AzureContainerVersion,
161
159
  ): Promise<{
162
160
  container: IFluidContainer<TContainerSchema>;
163
161
  services: AzureContainerServices;
@@ -170,47 +168,31 @@ export class AzureClient {
170
168
  encodeURIComponent(getTenantId(this.properties.connection)),
171
169
  );
172
170
  url.searchParams.append("containerId", encodeURIComponent(id));
173
- const sourceContainer = await loader.resolve({ url: url.href });
174
-
175
- if (sourceContainer.resolvedUrl === undefined) {
176
- throw new Error("Source container cannot resolve URL.");
177
- }
178
-
179
- const documentService = await this.documentServiceFactory.createDocumentService(
180
- sourceContainer.resolvedUrl,
181
- );
182
- const storage = await documentService.connectToStorage();
183
- const handle = {
184
- type: SummaryType.Handle,
185
- handleType: SummaryType.Tree,
186
- handle: version?.id ?? "latest",
187
- };
188
- const tree = await storage.downloadSummary(handle);
189
-
190
- const container = await loader.rehydrateDetachedContainerFromSnapshot(JSON.stringify(tree));
191
-
192
- const fluidContainer = await this.createFluidContainer<TContainerSchema>(
171
+ const container = await loader.resolve({ url: url.href });
172
+ const rootDataObject = await this.getContainerEntryPoint(container);
173
+ const fluidContainer = createFluidContainer<TContainerSchema>({
193
174
  container,
194
- this.properties.connection,
195
- );
175
+ rootDataObject,
176
+ });
196
177
  const services = this.getContainerServices(container);
197
178
  return { container: fluidContainer, services };
198
179
  }
199
180
 
200
181
  /**
201
- * Accesses the existing container given its unique ID in the Azure Fluid Relay.
182
+ * Load a specific version of a container for viewing only.
202
183
  * @typeparam TContainerSchema - Used to infer the the type of 'initialObjects' in the returned container.
203
184
  * (normally not explicitly specified.)
204
- * @param id - Unique ID of the container in Azure Fluid Relay.
185
+ * @param id - Unique ID of the source container in Azure Fluid Relay.
205
186
  * @param containerSchema - Container schema used to access data objects in the container.
206
- * @returns Existing container instance along with associated services.
187
+ * @param version - Unique version of the source container in Azure Fluid Relay.
188
+ * @returns Loaded container instance at the specified version.
207
189
  */
208
- public async getContainer<TContainerSchema extends ContainerSchema>(
190
+ public async viewContainerVersion<TContainerSchema extends ContainerSchema>(
209
191
  id: string,
210
192
  containerSchema: TContainerSchema,
193
+ version: AzureContainerVersion,
211
194
  ): Promise<{
212
195
  container: IFluidContainer<TContainerSchema>;
213
- services: AzureContainerServices;
214
196
  }> {
215
197
  const loader = this.createLoader(containerSchema);
216
198
  const url = new URL(this.properties.connection.endpoint);
@@ -220,14 +202,16 @@ export class AzureClient {
220
202
  encodeURIComponent(getTenantId(this.properties.connection)),
221
203
  );
222
204
  url.searchParams.append("containerId", encodeURIComponent(id));
223
- const container = await loader.resolve({ url: url.href });
205
+ const container = await loadContainerPaused(loader, {
206
+ url: url.href,
207
+ headers: { [LoaderHeader.version]: version.id },
208
+ });
224
209
  const rootDataObject = await this.getContainerEntryPoint(container);
225
210
  const fluidContainer = createFluidContainer<TContainerSchema>({
226
211
  container,
227
212
  rootDataObject,
228
213
  });
229
- const services = this.getContainerServices(container);
230
- return { container: fluidContainer, services };
214
+ return { container: fluidContainer };
231
215
  }
232
216
 
233
217
  /**
@@ -25,7 +25,7 @@ export class AzureFunctionTokenProvider implements ITokenProvider {
25
25
  */
26
26
  public constructor(
27
27
  private readonly azFunctionUrl: string,
28
- private readonly user?: Pick<AzureMember, "userId" | "userName" | "additionalDetails">,
28
+ private readonly user?: Pick<AzureMember, "id" | "name" | "additionalDetails">,
29
29
  ) {}
30
30
 
31
31
  public async fetchOrdererToken(tenantId: string, documentId?: string): Promise<ITokenResponse> {
@@ -45,8 +45,8 @@ export class AzureFunctionTokenProvider implements ITokenProvider {
45
45
  params: {
46
46
  tenantId,
47
47
  documentId,
48
- userId: this.user?.userId,
49
- userName: this.user?.userName,
48
+ id: this.user?.id,
49
+ name: this.user?.name,
50
50
  additionalDetails: this.user?.additionalDetails as unknown,
51
51
  },
52
52
  });
package/src/interfaces.ts CHANGED
@@ -176,7 +176,7 @@ export interface AzureMember<T = any> extends IMember {
176
176
  /**
177
177
  * {@inheritDoc AzureUser.name}
178
178
  */
179
- userName: string;
179
+ name: string;
180
180
 
181
181
  /**
182
182
  * {@inheritDoc AzureUser.additionalDetails}