@fluidframework/odsp-client 2.41.0-338186 → 2.41.0
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/CHANGELOG.md +4 -0
- package/dist/odspClient.d.ts +0 -1
- package/dist/odspClient.d.ts.map +1 -1
- package/dist/odspClient.js +13 -23
- package/dist/odspClient.js.map +1 -1
- package/lib/odspClient.d.ts +0 -1
- package/lib/odspClient.d.ts.map +1 -1
- package/lib/odspClient.js +3 -16
- package/lib/odspClient.js.map +1 -1
- package/package.json +15 -15
- package/src/odspClient.ts +2 -21
package/CHANGELOG.md
CHANGED
package/dist/odspClient.d.ts
CHANGED
package/dist/odspClient.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspClient.d.ts","sourceRoot":"","sources":["../src/odspClient.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"odspClient.d.ts","sourceRoot":"","sources":["../src/odspClient.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAmBH,OAAO,KAAK,EAEX,eAAe,EACf,eAAe,EACf,MAAM,8BAA8B,CAAC;AAkBtC,OAAO,KAAK,EACX,eAAe,EAGf,qBAAqB,EACrB,MAAM,iBAAiB,CAAC;AA2CzB;;;;GAIG;AACH,qBAAa,UAAU;IACtB,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAA0B;IACjE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAwB;IACpD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAkC;IACjE,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAuB;IACxD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAmC;gBAEvC,UAAU,EAAE,eAAe;IAYjC,eAAe,CAAC,CAAC,SAAS,eAAe,EACrD,eAAe,EAAE,CAAC,GAChB,OAAO,CAAC;QACV,SAAS,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;QAC9B,QAAQ,EAAE,qBAAqB,CAAC;KAChC,CAAC;IAkBW,YAAY,CAAC,CAAC,SAAS,eAAe,EAClD,EAAE,EAAE,MAAM,EACV,eAAe,EAAE,CAAC,GAChB,OAAO,CAAC;QACV,SAAS,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;QAC9B,QAAQ,EAAE,qBAAqB,CAAC;KAChC,CAAC;IAiBF,OAAO,CAAC,cAAc;YAiCR,oBAAoB;YAuCpB,oBAAoB;CAQlC"}
|
package/dist/odspClient.js
CHANGED
|
@@ -7,10 +7,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
exports.OdspClient = void 0;
|
|
8
8
|
const container_definitions_1 = require("@fluidframework/container-definitions");
|
|
9
9
|
const internal_1 = require("@fluidframework/container-loader/internal");
|
|
10
|
-
const internal_2 = require("@fluidframework/
|
|
11
|
-
const internal_3 = require("@fluidframework/
|
|
12
|
-
const internal_4 = require("@fluidframework/
|
|
13
|
-
const internal_5 = require("@fluidframework/telemetry-utils/internal");
|
|
10
|
+
const internal_2 = require("@fluidframework/fluid-static/internal");
|
|
11
|
+
const internal_3 = require("@fluidframework/odsp-driver/internal");
|
|
12
|
+
const internal_4 = require("@fluidframework/telemetry-utils/internal");
|
|
14
13
|
const uuid_1 = require("uuid");
|
|
15
14
|
const odspAudience_js_1 = require("./odspAudience.js");
|
|
16
15
|
async function getStorageToken(options, tokenProvider) {
|
|
@@ -34,7 +33,7 @@ const odspClientFeatureGates = {
|
|
|
34
33
|
* @returns A new config provider with the appropriate defaults applied underneath the given provider
|
|
35
34
|
*/
|
|
36
35
|
function wrapConfigProvider(baseConfigProvider) {
|
|
37
|
-
return (0,
|
|
36
|
+
return (0, internal_4.wrapConfigProviderWithDefaults)(baseConfigProvider, odspClientFeatureGates);
|
|
38
37
|
}
|
|
39
38
|
/**
|
|
40
39
|
* OdspClient provides the ability to have a Fluid object backed by the ODSP service within the context of Microsoft 365 (M365) tenants.
|
|
@@ -45,8 +44,8 @@ class OdspClient {
|
|
|
45
44
|
constructor(properties) {
|
|
46
45
|
this.connectionConfig = properties.connection;
|
|
47
46
|
this.logger = properties.logger;
|
|
48
|
-
this.documentServiceFactory = new
|
|
49
|
-
this.urlResolver = new
|
|
47
|
+
this.documentServiceFactory = new internal_3.OdspDocumentServiceFactory(async (options) => getStorageToken(options, this.connectionConfig.tokenProvider), async (options) => getWebsocketToken(options, this.connectionConfig.tokenProvider));
|
|
48
|
+
this.urlResolver = new internal_3.OdspDriverUrlResolver();
|
|
50
49
|
this.configProvider = wrapConfigProvider(properties.configProvider);
|
|
51
50
|
}
|
|
52
51
|
async createContainer(containerSchema) {
|
|
@@ -64,22 +63,21 @@ class OdspClient {
|
|
|
64
63
|
}
|
|
65
64
|
async getContainer(id, containerSchema) {
|
|
66
65
|
const loaderProps = this.getLoaderProps(containerSchema);
|
|
67
|
-
const url = (0,
|
|
66
|
+
const url = (0, internal_3.createOdspUrl)({
|
|
68
67
|
siteUrl: this.connectionConfig.siteUrl,
|
|
69
68
|
driveId: this.connectionConfig.driveId,
|
|
70
69
|
itemId: id,
|
|
71
70
|
dataStorePath: "",
|
|
72
71
|
});
|
|
73
72
|
const container = await (0, internal_1.loadExistingContainer)({ ...loaderProps, request: { url } });
|
|
74
|
-
const fluidContainer = (0,
|
|
73
|
+
const fluidContainer = await (0, internal_2.createFluidContainer)({
|
|
75
74
|
container,
|
|
76
|
-
rootDataObject: await this.getContainerEntryPoint(container),
|
|
77
75
|
});
|
|
78
76
|
const services = await this.getContainerServices(container);
|
|
79
77
|
return { container: fluidContainer, services };
|
|
80
78
|
}
|
|
81
79
|
getLoaderProps(schema) {
|
|
82
|
-
const runtimeFactory = (0,
|
|
80
|
+
const runtimeFactory = (0, internal_2.createDOProviderContainerRuntimeFactory)({
|
|
83
81
|
schema,
|
|
84
82
|
compatibilityMode: "2",
|
|
85
83
|
});
|
|
@@ -109,20 +107,17 @@ class OdspClient {
|
|
|
109
107
|
};
|
|
110
108
|
}
|
|
111
109
|
async createFluidContainer(container, connection) {
|
|
112
|
-
const rootDataObject = await this.getContainerEntryPoint(container);
|
|
113
110
|
/**
|
|
114
111
|
* See {@link FluidContainer.attach}
|
|
115
112
|
*/
|
|
116
113
|
const attach = async (odspProps) => {
|
|
117
|
-
|
|
118
|
-
// eslint-disable-next-line import/no-deprecated
|
|
119
|
-
const createNewRequest = (0, internal_4.createOdspCreateContainerRequest)(connection.siteUrl, connection.driveId, odspProps?.filePath ?? "", odspProps?.fileName ?? (0, uuid_1.v4)());
|
|
114
|
+
const createNewRequest = (0, internal_3.createOdspCreateContainerRequest)(connection.siteUrl, connection.driveId, odspProps?.filePath ?? "", odspProps?.fileName ?? (0, uuid_1.v4)());
|
|
120
115
|
if (container.attachState !== container_definitions_1.AttachState.Detached) {
|
|
121
116
|
throw new Error("Cannot attach container. Container is not in detached state");
|
|
122
117
|
}
|
|
123
118
|
await container.attach(createNewRequest);
|
|
124
119
|
const resolvedUrl = container.resolvedUrl;
|
|
125
|
-
if (resolvedUrl === undefined || !(0,
|
|
120
|
+
if (resolvedUrl === undefined || !(0, internal_3.isOdspResolvedUrl)(resolvedUrl)) {
|
|
126
121
|
throw new Error("Resolved Url not available on attached container");
|
|
127
122
|
}
|
|
128
123
|
/**
|
|
@@ -132,23 +127,18 @@ class OdspClient {
|
|
|
132
127
|
*/
|
|
133
128
|
return resolvedUrl.itemId;
|
|
134
129
|
};
|
|
135
|
-
const fluidContainer = (0,
|
|
130
|
+
const fluidContainer = await (0, internal_2.createFluidContainer)({ container });
|
|
136
131
|
fluidContainer.attach = attach;
|
|
137
132
|
return fluidContainer;
|
|
138
133
|
}
|
|
139
134
|
async getContainerServices(container) {
|
|
140
135
|
return {
|
|
141
|
-
audience: (0,
|
|
136
|
+
audience: (0, internal_2.createServiceAudience)({
|
|
142
137
|
container,
|
|
143
138
|
createServiceMember: odspAudience_js_1.createOdspAudienceMember,
|
|
144
139
|
}),
|
|
145
140
|
};
|
|
146
141
|
}
|
|
147
|
-
async getContainerEntryPoint(container) {
|
|
148
|
-
const rootDataObject = await container.getEntryPoint();
|
|
149
|
-
(0, internal_2.assert)(rootDataObject.IRootDataObject !== undefined, 0x878 /* entryPoint must be of type IRootDataObject */);
|
|
150
|
-
return rootDataObject.IRootDataObject;
|
|
151
|
-
}
|
|
152
142
|
}
|
|
153
143
|
exports.OdspClient = OdspClient;
|
|
154
144
|
//# sourceMappingURL=odspClient.js.map
|
package/dist/odspClient.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspClient.js","sourceRoot":"","sources":["../src/odspClient.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,iFAAoE;AAKpE,wEAImD;AAOnD,kEAA6D;AAS7D,oEAI+C;AAC/C,mEAQ8C;AAE9C,uEAA0F;AAC1F,+BAAkC;AASlC,uDAA6D;AAG7D,KAAK,UAAU,eAAe,CAC7B,OAAsC,EACtC,aAAiC;IAEjC,MAAM,aAAa,GAAkB,MAAM,aAAa,CAAC,iBAAiB,CACzE,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,OAAO,CACf,CAAC;IACF,OAAO,aAAa,CAAC;AACtB,CAAC;AAED,KAAK,UAAU,iBAAiB,CAC/B,OAAsC,EACtC,aAAiC;IAEjC,MAAM,aAAa,GAAkB,MAAM,aAAa,CAAC,mBAAmB,CAC3E,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,OAAO,CACf,CAAC;IACF,OAAO,aAAa,CAAC;AACtB,CAAC;AAED;;;GAGG;AACH,MAAM,sBAAsB,GAAG;AAC9B,WAAW;CACX,CAAC;AAEF;;;;GAIG;AACH,SAAS,kBAAkB,CAAC,kBAAwC;IACnE,OAAO,IAAA,yCAA8B,EAAC,kBAAkB,EAAE,sBAAsB,CAAC,CAAC;AACnF,CAAC;AAED;;;;GAIG;AACH,MAAa,UAAU;IAOtB,YAAmB,UAA2B;QAC7C,IAAI,CAAC,gBAAgB,GAAG,UAAU,CAAC,UAAU,CAAC;QAC9C,IAAI,CAAC,M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,mBAAmB,EAAE,0CAAwB;aAC7C,CAAC;SACF,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,sBAAsB,CAAC,SAAqB;QACzD,MAAM,cAAc,GAAiC,MAAM,SAAS,CAAC,aAAa,EAAE,CAAC;QACrF,IAAA,iBAAM,EACL,cAAc,CAAC,eAAe,KAAK,SAAS,EAC5C,KAAK,CAAC,gDAAgD,CACtD,CAAC;QACF,OAAO,cAAc,CAAC,eAAe,CAAC;IACvC,CAAC;CACD;AA/JD,gCA+JC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport type {\n\tIContainer,\n\tIFluidModuleWithDetails,\n} from \"@fluidframework/container-definitions/internal\";\nimport {\n\tcreateDetachedContainer,\n\tloadExistingContainer,\n\ttype ILoaderProps,\n} from \"@fluidframework/container-loader/internal\";\nimport type {\n\tFluidObject,\n\tIConfigProviderBase,\n\tIRequest,\n\tITelemetryBaseLogger,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IClient } from \"@fluidframework/driver-definitions\";\nimport type { IDocumentServiceFactory } from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tContainerAttachProps,\n\tContainerSchema,\n\tIFluidContainer,\n} from \"@fluidframework/fluid-static\";\nimport type { IRootDataObject } from \"@fluidframework/fluid-static/internal\";\nimport {\n\tcreateDOProviderContainerRuntimeFactory,\n\tcreateFluidContainer,\n\tcreateServiceAudience,\n} from \"@fluidframework/fluid-static/internal\";\nimport {\n\tOdspDocumentServiceFactory,\n\tOdspDriverUrlResolver,\n\t// The comment will be removed up when the deprecated code is removed in AB#31049\n\t// eslint-disable-next-line import/no-deprecated\n\tcreateOdspCreateContainerRequest,\n\tcreateOdspUrl,\n\tisOdspResolvedUrl,\n} from \"@fluidframework/odsp-driver/internal\";\nimport type { OdspResourceTokenFetchOptions } from \"@fluidframework/odsp-driver-definitions/internal\";\nimport { wrapConfigProviderWithDefaults } from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport type { TokenResponse } from \"./interfaces.js\";\nimport type {\n\tOdspClientProps,\n\tOdspConnectionConfig,\n\tOdspContainerAttachProps,\n\tOdspContainerServices,\n} from \"./interfaces.js\";\nimport { createOdspAudienceMember } from \"./odspAudience.js\";\nimport type { IOdspTokenProvider } from \"./token.js\";\n\nasync function getStorageToken(\n\toptions: OdspResourceTokenFetchOptions,\n\ttokenProvider: IOdspTokenProvider,\n): Promise<TokenResponse> {\n\tconst tokenResponse: TokenResponse = await tokenProvider.fetchStorageToken(\n\t\toptions.siteUrl,\n\t\toptions.refresh,\n\t);\n\treturn tokenResponse;\n}\n\nasync function getWebsocketToken(\n\toptions: OdspResourceTokenFetchOptions,\n\ttokenProvider: IOdspTokenProvider,\n): Promise<TokenResponse> {\n\tconst tokenResponse: TokenResponse = await tokenProvider.fetchWebsocketToken(\n\t\toptions.siteUrl,\n\t\toptions.refresh,\n\t);\n\treturn tokenResponse;\n}\n\n/**\n * Default feature gates.\n * These values will only be used if the feature gate is not already set by the supplied config provider.\n */\nconst odspClientFeatureGates = {\n\t// None yet\n};\n\n/**\n * Wrap the config provider to fall back on the appropriate defaults for ODSP Client.\n * @param baseConfigProvider - The base config provider to wrap\n * @returns A new config provider with the appropriate defaults applied underneath the given provider\n */\nfunction wrapConfigProvider(baseConfigProvider?: IConfigProviderBase): IConfigProviderBase {\n\treturn wrapConfigProviderWithDefaults(baseConfigProvider, odspClientFeatureGates);\n}\n\n/**\n * OdspClient provides the ability to have a Fluid object backed by the ODSP service within the context of Microsoft 365 (M365) tenants.\n * @sealed\n * @beta\n */\nexport class OdspClient {\n\tprivate readonly documentServiceFactory: IDocumentServiceFactory;\n\tprivate readonly urlResolver: OdspDriverUrlResolver;\n\tprivate readonly configProvider: IConfigProviderBase | undefined;\n\tprivate readonly connectionConfig: OdspConnectionConfig;\n\tprivate readonly logger: ITelemetryBaseLogger | undefined;\n\n\tpublic constructor(properties: OdspClientProps) {\n\t\tthis.connectionConfig = properties.connection;\n\t\tthis.logger = properties.logger;\n\t\tthis.documentServiceFactory = new OdspDocumentServiceFactory(\n\t\t\tasync (options) => getStorageToken(options, this.connectionConfig.tokenProvider),\n\t\t\tasync (options) => getWebsocketToken(options, this.connectionConfig.tokenProvider),\n\t\t);\n\n\t\tthis.urlResolver = new OdspDriverUrlResolver();\n\t\tthis.configProvider = wrapConfigProvider(properties.configProvider);\n\t}\n\n\tpublic async createContainer<T extends ContainerSchema>(\n\t\tcontainerSchema: T,\n\t): Promise<{\n\t\tcontainer: IFluidContainer<T>;\n\t\tservices: OdspContainerServices;\n\t}> {\n\t\tconst loaderProps = this.getLoaderProps(containerSchema);\n\n\t\tconst container = await createDetachedContainer({\n\t\t\t...loaderProps,\n\t\t\tcodeDetails: {\n\t\t\t\tpackage: \"no-dynamic-package\",\n\t\t\t\tconfig: {},\n\t\t\t},\n\t\t});\n\n\t\tconst fluidContainer = await this.createFluidContainer(container, this.connectionConfig);\n\n\t\tconst services = await this.getContainerServices(container);\n\n\t\treturn { container: fluidContainer as IFluidContainer<T>, services };\n\t}\n\n\tpublic async getContainer<T extends ContainerSchema>(\n\t\tid: string,\n\t\tcontainerSchema: T,\n\t): Promise<{\n\t\tcontainer: IFluidContainer<T>;\n\t\tservices: OdspContainerServices;\n\t}> {\n\t\tconst loaderProps = this.getLoaderProps(containerSchema);\n\t\tconst url = createOdspUrl({\n\t\t\tsiteUrl: this.connectionConfig.siteUrl,\n\t\t\tdriveId: this.connectionConfig.driveId,\n\t\t\titemId: id,\n\t\t\tdataStorePath: \"\",\n\t\t});\n\t\tconst container = await loadExistingContainer({ ...loaderProps, request: { url } });\n\n\t\tconst fluidContainer = createFluidContainer({\n\t\t\tcontainer,\n\t\t\trootDataObject: await this.getContainerEntryPoint(container),\n\t\t});\n\t\tconst services = await this.getContainerServices(container);\n\t\treturn { container: fluidContainer as IFluidContainer<T>, services };\n\t}\n\n\tprivate getLoaderProps(schema: ContainerSchema): ILoaderProps {\n\t\tconst runtimeFactory = createDOProviderContainerRuntimeFactory({\n\t\t\tschema,\n\t\t\tcompatibilityMode: \"2\",\n\t\t});\n\t\tconst load = async (): Promise<IFluidModuleWithDetails> => {\n\t\t\treturn {\n\t\t\t\tmodule: { fluidExport: runtimeFactory },\n\t\t\t\tdetails: { package: \"no-dynamic-package\", config: {} },\n\t\t\t};\n\t\t};\n\n\t\tconst codeLoader = { load };\n\t\tconst client: IClient = {\n\t\t\tdetails: {\n\t\t\t\tcapabilities: { interactive: true },\n\t\t\t},\n\t\t\tpermission: [],\n\t\t\tscopes: [],\n\t\t\tuser: { id: \"\" },\n\t\t\tmode: \"write\",\n\t\t};\n\n\t\treturn {\n\t\t\turlResolver: this.urlResolver,\n\t\t\tdocumentServiceFactory: this.documentServiceFactory,\n\t\t\tcodeLoader,\n\t\t\tlogger: this.logger,\n\t\t\toptions: { client },\n\t\t\tconfigProvider: this.configProvider,\n\t\t};\n\t}\n\n\tprivate async createFluidContainer(\n\t\tcontainer: IContainer,\n\t\tconnection: OdspConnectionConfig,\n\t): Promise<IFluidContainer> {\n\t\tconst rootDataObject = await this.getContainerEntryPoint(container);\n\n\t\t/**\n\t\t * See {@link FluidContainer.attach}\n\t\t */\n\t\tconst attach = async (\n\t\t\todspProps?: ContainerAttachProps<OdspContainerAttachProps>,\n\t\t): Promise<string> => {\n\t\t\t// The comment will be removed up when the deprecated code is removed in AB#31049\n\t\t\t// eslint-disable-next-line import/no-deprecated\n\t\t\tconst createNewRequest: IRequest = createOdspCreateContainerRequest(\n\t\t\t\tconnection.siteUrl,\n\t\t\t\tconnection.driveId,\n\t\t\t\todspProps?.filePath ?? \"\",\n\t\t\t\todspProps?.fileName ?? uuid(),\n\t\t\t);\n\t\t\tif (container.attachState !== AttachState.Detached) {\n\t\t\t\tthrow new Error(\"Cannot attach container. Container is not in detached state\");\n\t\t\t}\n\t\t\tawait container.attach(createNewRequest);\n\n\t\t\tconst resolvedUrl = container.resolvedUrl;\n\n\t\t\tif (resolvedUrl === undefined || !isOdspResolvedUrl(resolvedUrl)) {\n\t\t\t\tthrow new Error(\"Resolved Url not available on attached container\");\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * A unique identifier for the file within the provided SharePoint Embedded container ID. When you attach a container,\n\t\t\t * a new `itemId` is created in the user's drive, which developers can use for various operations\n\t\t\t * like updating, renaming, moving the Fluid file, changing permissions, and more. `itemId` is used to load the container.\n\t\t\t */\n\t\t\treturn resolvedUrl.itemId;\n\t\t};\n\t\tconst fluidContainer = createFluidContainer({ container, rootDataObject });\n\t\tfluidContainer.attach = attach;\n\t\treturn fluidContainer;\n\t}\n\n\tprivate async getContainerServices(container: IContainer): Promise<OdspContainerServices> {\n\t\treturn {\n\t\t\taudience: createServiceAudience({\n\t\t\t\tcontainer,\n\t\t\t\tcreateServiceMember: createOdspAudienceMember,\n\t\t\t}),\n\t\t};\n\t}\n\n\tprivate async getContainerEntryPoint(container: IContainer): Promise<IRootDataObject> {\n\t\tconst rootDataObject: FluidObject<IRootDataObject> = await container.getEntryPoint();\n\t\tassert(\n\t\t\trootDataObject.IRootDataObject !== undefined,\n\t\t\t0x878 /* entryPoint must be of type IRootDataObject */,\n\t\t);\n\t\treturn rootDataObject.IRootDataObject;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"odspClient.js","sourceRoot":"","sources":["../src/odspClient.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,iFAAoE;AAKpE,wEAImD;AAanD,oEAI+C;AAC/C,mEAM8C;AAE9C,uEAA0F;AAC1F,+BAAkC;AASlC,uDAA6D;AAG7D,KAAK,UAAU,eAAe,CAC7B,OAAsC,EACtC,aAAiC;IAEjC,MAAM,aAAa,GAAkB,MAAM,aAAa,CAAC,iBAAiB,CACzE,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,OAAO,CACf,CAAC;IACF,OAAO,aAAa,CAAC;AACtB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AC,CAAC;YACrE,CAAC;YAED;;;;eAIG;YACH,OAAO,WAAW,CAAC,MAAM,CAAC;QAC3B,CAAC,CAAC;QACF,MAAM,cAAc,GAAG,MAAM,IAAA,+BAAoB,EAAC,EAAE,SAAS,EAAE,CAAC,CAAC;QACjE,cAAc,CAAC,MAAM,GAAG,MAAM,CAAC;QAC/B,OAAO,cAAc,CAAC;IACvB,CAAC;IAEO,KAAK,CAAC,oBAAoB,CAAC,SAAqB;QACvD,OAAO;YACN,QAAQ,EAAE,IAAA,gCAAqB,EAAC;gBAC/B,SAAS;gBACT,mBAAmB,EAAE,0CAAwB;aAC7C,CAAC;SACF,CAAC;IACH,CAAC;CACD;AAjJD,gCAiJC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport type {\n\tIContainer,\n\tIFluidModuleWithDetails,\n} from \"@fluidframework/container-definitions/internal\";\nimport {\n\tcreateDetachedContainer,\n\tloadExistingContainer,\n\ttype ILoaderProps,\n} from \"@fluidframework/container-loader/internal\";\nimport type {\n\tIConfigProviderBase,\n\tIRequest,\n\tITelemetryBaseLogger,\n} from \"@fluidframework/core-interfaces\";\nimport type { IClient } from \"@fluidframework/driver-definitions\";\nimport type { IDocumentServiceFactory } from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tContainerAttachProps,\n\tContainerSchema,\n\tIFluidContainer,\n} from \"@fluidframework/fluid-static\";\nimport {\n\tcreateDOProviderContainerRuntimeFactory,\n\tcreateFluidContainer,\n\tcreateServiceAudience,\n} from \"@fluidframework/fluid-static/internal\";\nimport {\n\tOdspDocumentServiceFactory,\n\tOdspDriverUrlResolver,\n\tcreateOdspCreateContainerRequest,\n\tcreateOdspUrl,\n\tisOdspResolvedUrl,\n} from \"@fluidframework/odsp-driver/internal\";\nimport type { OdspResourceTokenFetchOptions } from \"@fluidframework/odsp-driver-definitions/internal\";\nimport { wrapConfigProviderWithDefaults } from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport type { TokenResponse } from \"./interfaces.js\";\nimport type {\n\tOdspClientProps,\n\tOdspConnectionConfig,\n\tOdspContainerAttachProps,\n\tOdspContainerServices,\n} from \"./interfaces.js\";\nimport { createOdspAudienceMember } from \"./odspAudience.js\";\nimport type { IOdspTokenProvider } from \"./token.js\";\n\nasync function getStorageToken(\n\toptions: OdspResourceTokenFetchOptions,\n\ttokenProvider: IOdspTokenProvider,\n): Promise<TokenResponse> {\n\tconst tokenResponse: TokenResponse = await tokenProvider.fetchStorageToken(\n\t\toptions.siteUrl,\n\t\toptions.refresh,\n\t);\n\treturn tokenResponse;\n}\n\nasync function getWebsocketToken(\n\toptions: OdspResourceTokenFetchOptions,\n\ttokenProvider: IOdspTokenProvider,\n): Promise<TokenResponse> {\n\tconst tokenResponse: TokenResponse = await tokenProvider.fetchWebsocketToken(\n\t\toptions.siteUrl,\n\t\toptions.refresh,\n\t);\n\treturn tokenResponse;\n}\n\n/**\n * Default feature gates.\n * These values will only be used if the feature gate is not already set by the supplied config provider.\n */\nconst odspClientFeatureGates = {\n\t// None yet\n};\n\n/**\n * Wrap the config provider to fall back on the appropriate defaults for ODSP Client.\n * @param baseConfigProvider - The base config provider to wrap\n * @returns A new config provider with the appropriate defaults applied underneath the given provider\n */\nfunction wrapConfigProvider(baseConfigProvider?: IConfigProviderBase): IConfigProviderBase {\n\treturn wrapConfigProviderWithDefaults(baseConfigProvider, odspClientFeatureGates);\n}\n\n/**\n * OdspClient provides the ability to have a Fluid object backed by the ODSP service within the context of Microsoft 365 (M365) tenants.\n * @sealed\n * @beta\n */\nexport class OdspClient {\n\tprivate readonly documentServiceFactory: IDocumentServiceFactory;\n\tprivate readonly urlResolver: OdspDriverUrlResolver;\n\tprivate readonly configProvider: IConfigProviderBase | undefined;\n\tprivate readonly connectionConfig: OdspConnectionConfig;\n\tprivate readonly logger: ITelemetryBaseLogger | undefined;\n\n\tpublic constructor(properties: OdspClientProps) {\n\t\tthis.connectionConfig = properties.connection;\n\t\tthis.logger = properties.logger;\n\t\tthis.documentServiceFactory = new OdspDocumentServiceFactory(\n\t\t\tasync (options) => getStorageToken(options, this.connectionConfig.tokenProvider),\n\t\t\tasync (options) => getWebsocketToken(options, this.connectionConfig.tokenProvider),\n\t\t);\n\n\t\tthis.urlResolver = new OdspDriverUrlResolver();\n\t\tthis.configProvider = wrapConfigProvider(properties.configProvider);\n\t}\n\n\tpublic async createContainer<T extends ContainerSchema>(\n\t\tcontainerSchema: T,\n\t): Promise<{\n\t\tcontainer: IFluidContainer<T>;\n\t\tservices: OdspContainerServices;\n\t}> {\n\t\tconst loaderProps = this.getLoaderProps(containerSchema);\n\n\t\tconst container = await createDetachedContainer({\n\t\t\t...loaderProps,\n\t\t\tcodeDetails: {\n\t\t\t\tpackage: \"no-dynamic-package\",\n\t\t\t\tconfig: {},\n\t\t\t},\n\t\t});\n\n\t\tconst fluidContainer = await this.createFluidContainer(container, this.connectionConfig);\n\n\t\tconst services = await this.getContainerServices(container);\n\n\t\treturn { container: fluidContainer as IFluidContainer<T>, services };\n\t}\n\n\tpublic async getContainer<T extends ContainerSchema>(\n\t\tid: string,\n\t\tcontainerSchema: T,\n\t): Promise<{\n\t\tcontainer: IFluidContainer<T>;\n\t\tservices: OdspContainerServices;\n\t}> {\n\t\tconst loaderProps = this.getLoaderProps(containerSchema);\n\t\tconst url = createOdspUrl({\n\t\t\tsiteUrl: this.connectionConfig.siteUrl,\n\t\t\tdriveId: this.connectionConfig.driveId,\n\t\t\titemId: id,\n\t\t\tdataStorePath: \"\",\n\t\t});\n\t\tconst container = await loadExistingContainer({ ...loaderProps, request: { url } });\n\n\t\tconst fluidContainer = await createFluidContainer({\n\t\t\tcontainer,\n\t\t});\n\t\tconst services = await this.getContainerServices(container);\n\t\treturn { container: fluidContainer as IFluidContainer<T>, services };\n\t}\n\n\tprivate getLoaderProps(schema: ContainerSchema): ILoaderProps {\n\t\tconst runtimeFactory = createDOProviderContainerRuntimeFactory({\n\t\t\tschema,\n\t\t\tcompatibilityMode: \"2\",\n\t\t});\n\t\tconst load = async (): Promise<IFluidModuleWithDetails> => {\n\t\t\treturn {\n\t\t\t\tmodule: { fluidExport: runtimeFactory },\n\t\t\t\tdetails: { package: \"no-dynamic-package\", config: {} },\n\t\t\t};\n\t\t};\n\n\t\tconst codeLoader = { load };\n\t\tconst client: IClient = {\n\t\t\tdetails: {\n\t\t\t\tcapabilities: { interactive: true },\n\t\t\t},\n\t\t\tpermission: [],\n\t\t\tscopes: [],\n\t\t\tuser: { id: \"\" },\n\t\t\tmode: \"write\",\n\t\t};\n\n\t\treturn {\n\t\t\turlResolver: this.urlResolver,\n\t\t\tdocumentServiceFactory: this.documentServiceFactory,\n\t\t\tcodeLoader,\n\t\t\tlogger: this.logger,\n\t\t\toptions: { client },\n\t\t\tconfigProvider: this.configProvider,\n\t\t};\n\t}\n\n\tprivate async createFluidContainer(\n\t\tcontainer: IContainer,\n\t\tconnection: OdspConnectionConfig,\n\t): Promise<IFluidContainer> {\n\t\t/**\n\t\t * See {@link FluidContainer.attach}\n\t\t */\n\t\tconst attach = async (\n\t\t\todspProps?: ContainerAttachProps<OdspContainerAttachProps>,\n\t\t): Promise<string> => {\n\t\t\tconst createNewRequest: IRequest = createOdspCreateContainerRequest(\n\t\t\t\tconnection.siteUrl,\n\t\t\t\tconnection.driveId,\n\t\t\t\todspProps?.filePath ?? \"\",\n\t\t\t\todspProps?.fileName ?? uuid(),\n\t\t\t);\n\t\t\tif (container.attachState !== AttachState.Detached) {\n\t\t\t\tthrow new Error(\"Cannot attach container. Container is not in detached state\");\n\t\t\t}\n\t\t\tawait container.attach(createNewRequest);\n\n\t\t\tconst resolvedUrl = container.resolvedUrl;\n\n\t\t\tif (resolvedUrl === undefined || !isOdspResolvedUrl(resolvedUrl)) {\n\t\t\t\tthrow new Error(\"Resolved Url not available on attached container\");\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * A unique identifier for the file within the provided SharePoint Embedded container ID. When you attach a container,\n\t\t\t * a new `itemId` is created in the user's drive, which developers can use for various operations\n\t\t\t * like updating, renaming, moving the Fluid file, changing permissions, and more. `itemId` is used to load the container.\n\t\t\t */\n\t\t\treturn resolvedUrl.itemId;\n\t\t};\n\t\tconst fluidContainer = await createFluidContainer({ container });\n\t\tfluidContainer.attach = attach;\n\t\treturn fluidContainer;\n\t}\n\n\tprivate async getContainerServices(container: IContainer): Promise<OdspContainerServices> {\n\t\treturn {\n\t\t\taudience: createServiceAudience({\n\t\t\t\tcontainer,\n\t\t\t\tcreateServiceMember: createOdspAudienceMember,\n\t\t\t}),\n\t\t};\n\t}\n}\n"]}
|
package/lib/odspClient.d.ts
CHANGED
package/lib/odspClient.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspClient.d.ts","sourceRoot":"","sources":["../src/odspClient.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"odspClient.d.ts","sourceRoot":"","sources":["../src/odspClient.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAmBH,OAAO,KAAK,EAEX,eAAe,EACf,eAAe,EACf,MAAM,8BAA8B,CAAC;AAkBtC,OAAO,KAAK,EACX,eAAe,EAGf,qBAAqB,EACrB,MAAM,iBAAiB,CAAC;AA2CzB;;;;GAIG;AACH,qBAAa,UAAU;IACtB,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAA0B;IACjE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAwB;IACpD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAkC;IACjE,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAuB;IACxD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAmC;gBAEvC,UAAU,EAAE,eAAe;IAYjC,eAAe,CAAC,CAAC,SAAS,eAAe,EACrD,eAAe,EAAE,CAAC,GAChB,OAAO,CAAC;QACV,SAAS,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;QAC9B,QAAQ,EAAE,qBAAqB,CAAC;KAChC,CAAC;IAkBW,YAAY,CAAC,CAAC,SAAS,eAAe,EAClD,EAAE,EAAE,MAAM,EACV,eAAe,EAAE,CAAC,GAChB,OAAO,CAAC;QACV,SAAS,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;QAC9B,QAAQ,EAAE,qBAAqB,CAAC;KAChC,CAAC;IAiBF,OAAO,CAAC,cAAc;YAiCR,oBAAoB;YAuCpB,oBAAoB;CAQlC"}
|
package/lib/odspClient.js
CHANGED
|
@@ -4,12 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { AttachState } from "@fluidframework/container-definitions";
|
|
6
6
|
import { createDetachedContainer, loadExistingContainer, } from "@fluidframework/container-loader/internal";
|
|
7
|
-
import { assert } from "@fluidframework/core-utils/internal";
|
|
8
7
|
import { createDOProviderContainerRuntimeFactory, createFluidContainer, createServiceAudience, } from "@fluidframework/fluid-static/internal";
|
|
9
|
-
import { OdspDocumentServiceFactory, OdspDriverUrlResolver,
|
|
10
|
-
// The comment will be removed up when the deprecated code is removed in AB#31049
|
|
11
|
-
// eslint-disable-next-line import/no-deprecated
|
|
12
|
-
createOdspCreateContainerRequest, createOdspUrl, isOdspResolvedUrl, } from "@fluidframework/odsp-driver/internal";
|
|
8
|
+
import { OdspDocumentServiceFactory, OdspDriverUrlResolver, createOdspCreateContainerRequest, createOdspUrl, isOdspResolvedUrl, } from "@fluidframework/odsp-driver/internal";
|
|
13
9
|
import { wrapConfigProviderWithDefaults } from "@fluidframework/telemetry-utils/internal";
|
|
14
10
|
import { v4 as uuid } from "uuid";
|
|
15
11
|
import { createOdspAudienceMember } from "./odspAudience.js";
|
|
@@ -71,9 +67,8 @@ export class OdspClient {
|
|
|
71
67
|
dataStorePath: "",
|
|
72
68
|
});
|
|
73
69
|
const container = await loadExistingContainer({ ...loaderProps, request: { url } });
|
|
74
|
-
const fluidContainer = createFluidContainer({
|
|
70
|
+
const fluidContainer = await createFluidContainer({
|
|
75
71
|
container,
|
|
76
|
-
rootDataObject: await this.getContainerEntryPoint(container),
|
|
77
72
|
});
|
|
78
73
|
const services = await this.getContainerServices(container);
|
|
79
74
|
return { container: fluidContainer, services };
|
|
@@ -109,13 +104,10 @@ export class OdspClient {
|
|
|
109
104
|
};
|
|
110
105
|
}
|
|
111
106
|
async createFluidContainer(container, connection) {
|
|
112
|
-
const rootDataObject = await this.getContainerEntryPoint(container);
|
|
113
107
|
/**
|
|
114
108
|
* See {@link FluidContainer.attach}
|
|
115
109
|
*/
|
|
116
110
|
const attach = async (odspProps) => {
|
|
117
|
-
// The comment will be removed up when the deprecated code is removed in AB#31049
|
|
118
|
-
// eslint-disable-next-line import/no-deprecated
|
|
119
111
|
const createNewRequest = createOdspCreateContainerRequest(connection.siteUrl, connection.driveId, odspProps?.filePath ?? "", odspProps?.fileName ?? uuid());
|
|
120
112
|
if (container.attachState !== AttachState.Detached) {
|
|
121
113
|
throw new Error("Cannot attach container. Container is not in detached state");
|
|
@@ -132,7 +124,7 @@ export class OdspClient {
|
|
|
132
124
|
*/
|
|
133
125
|
return resolvedUrl.itemId;
|
|
134
126
|
};
|
|
135
|
-
const fluidContainer = createFluidContainer({ container
|
|
127
|
+
const fluidContainer = await createFluidContainer({ container });
|
|
136
128
|
fluidContainer.attach = attach;
|
|
137
129
|
return fluidContainer;
|
|
138
130
|
}
|
|
@@ -144,10 +136,5 @@ export class OdspClient {
|
|
|
144
136
|
}),
|
|
145
137
|
};
|
|
146
138
|
}
|
|
147
|
-
async getContainerEntryPoint(container) {
|
|
148
|
-
const rootDataObject = await container.getEntryPoint();
|
|
149
|
-
assert(rootDataObject.IRootDataObject !== undefined, 0x878 /* entryPoint must be of type IRootDataObject */);
|
|
150
|
-
return rootDataObject.IRootDataObject;
|
|
151
|
-
}
|
|
152
139
|
}
|
|
153
140
|
//# sourceMappingURL=odspClient.js.map
|
package/lib/odspClient.js.map
CHANGED
|
@@ -1 +1 @@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CAAC,SAAqB;QACvD,OAAO;YACN,QAAQ,EAAE,qBAAqB,CAAC;gBAC/B,SAAS;gBACT,mBAAmB,EAAE,wBAAwB;aAC7C,CAAC;SACF,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,sBAAsB,CAAC,SAAqB;QACzD,MAAM,cAAc,GAAiC,MAAM,SAAS,CAAC,aAAa,EAAE,CAAC;QACrF,MAAM,CACL,cAAc,CAAC,eAAe,KAAK,SAAS,EAC5C,KAAK,CAAC,gDAAgD,CACtD,CAAC;QACF,OAAO,cAAc,CAAC,eAAe,CAAC;IACvC,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport type {\n\tIContainer,\n\tIFluidModuleWithDetails,\n} from \"@fluidframework/container-definitions/internal\";\nimport {\n\tcreateDetachedContainer,\n\tloadExistingContainer,\n\ttype ILoaderProps,\n} from \"@fluidframework/container-loader/internal\";\nimport type {\n\tFluidObject,\n\tIConfigProviderBase,\n\tIRequest,\n\tITelemetryBaseLogger,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IClient } from \"@fluidframework/driver-definitions\";\nimport type { IDocumentServiceFactory } from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tContainerAttachProps,\n\tContainerSchema,\n\tIFluidContainer,\n} from \"@fluidframework/fluid-static\";\nimport type { IRootDataObject } from \"@fluidframework/fluid-static/internal\";\nimport {\n\tcreateDOProviderContainerRuntimeFactory,\n\tcreateFluidContainer,\n\tcreateServiceAudience,\n} from \"@fluidframework/fluid-static/internal\";\nimport {\n\tOdspDocumentServiceFactory,\n\tOdspDriverUrlResolver,\n\t// The comment will be removed up when the deprecated code is removed in AB#31049\n\t// eslint-disable-next-line import/no-deprecated\n\tcreateOdspCreateContainerRequest,\n\tcreateOdspUrl,\n\tisOdspResolvedUrl,\n} from \"@fluidframework/odsp-driver/internal\";\nimport type { OdspResourceTokenFetchOptions } from \"@fluidframework/odsp-driver-definitions/internal\";\nimport { wrapConfigProviderWithDefaults } from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport type { TokenResponse } from \"./interfaces.js\";\nimport type {\n\tOdspClientProps,\n\tOdspConnectionConfig,\n\tOdspContainerAttachProps,\n\tOdspContainerServices,\n} from \"./interfaces.js\";\nimport { createOdspAudienceMember } from \"./odspAudience.js\";\nimport type { IOdspTokenProvider } from \"./token.js\";\n\nasync function getStorageToken(\n\toptions: OdspResourceTokenFetchOptions,\n\ttokenProvider: IOdspTokenProvider,\n): Promise<TokenResponse> {\n\tconst tokenResponse: TokenResponse = await tokenProvider.fetchStorageToken(\n\t\toptions.siteUrl,\n\t\toptions.refresh,\n\t);\n\treturn tokenResponse;\n}\n\nasync function getWebsocketToken(\n\toptions: OdspResourceTokenFetchOptions,\n\ttokenProvider: IOdspTokenProvider,\n): Promise<TokenResponse> {\n\tconst tokenResponse: TokenResponse = await tokenProvider.fetchWebsocketToken(\n\t\toptions.siteUrl,\n\t\toptions.refresh,\n\t);\n\treturn tokenResponse;\n}\n\n/**\n * Default feature gates.\n * These values will only be used if the feature gate is not already set by the supplied config provider.\n */\nconst odspClientFeatureGates = {\n\t// None yet\n};\n\n/**\n * Wrap the config provider to fall back on the appropriate defaults for ODSP Client.\n * @param baseConfigProvider - The base config provider to wrap\n * @returns A new config provider with the appropriate defaults applied underneath the given provider\n */\nfunction wrapConfigProvider(baseConfigProvider?: IConfigProviderBase): IConfigProviderBase {\n\treturn wrapConfigProviderWithDefaults(baseConfigProvider, odspClientFeatureGates);\n}\n\n/**\n * OdspClient provides the ability to have a Fluid object backed by the ODSP service within the context of Microsoft 365 (M365) tenants.\n * @sealed\n * @beta\n */\nexport class OdspClient {\n\tprivate readonly documentServiceFactory: IDocumentServiceFactory;\n\tprivate readonly urlResolver: OdspDriverUrlResolver;\n\tprivate readonly configProvider: IConfigProviderBase | undefined;\n\tprivate readonly connectionConfig: OdspConnectionConfig;\n\tprivate readonly logger: ITelemetryBaseLogger | undefined;\n\n\tpublic constructor(properties: OdspClientProps) {\n\t\tthis.connectionConfig = properties.connection;\n\t\tthis.logger = properties.logger;\n\t\tthis.documentServiceFactory = new OdspDocumentServiceFactory(\n\t\t\tasync (options) => getStorageToken(options, this.connectionConfig.tokenProvider),\n\t\t\tasync (options) => getWebsocketToken(options, this.connectionConfig.tokenProvider),\n\t\t);\n\n\t\tthis.urlResolver = new OdspDriverUrlResolver();\n\t\tthis.configProvider = wrapConfigProvider(properties.configProvider);\n\t}\n\n\tpublic async createContainer<T extends ContainerSchema>(\n\t\tcontainerSchema: T,\n\t): Promise<{\n\t\tcontainer: IFluidContainer<T>;\n\t\tservices: OdspContainerServices;\n\t}> {\n\t\tconst loaderProps = this.getLoaderProps(containerSchema);\n\n\t\tconst container = await createDetachedContainer({\n\t\t\t...loaderProps,\n\t\t\tcodeDetails: {\n\t\t\t\tpackage: \"no-dynamic-package\",\n\t\t\t\tconfig: {},\n\t\t\t},\n\t\t});\n\n\t\tconst fluidContainer = await this.createFluidContainer(container, this.connectionConfig);\n\n\t\tconst services = await this.getContainerServices(container);\n\n\t\treturn { container: fluidContainer as IFluidContainer<T>, services };\n\t}\n\n\tpublic async getContainer<T extends ContainerSchema>(\n\t\tid: string,\n\t\tcontainerSchema: T,\n\t): Promise<{\n\t\tcontainer: IFluidContainer<T>;\n\t\tservices: OdspContainerServices;\n\t}> {\n\t\tconst loaderProps = this.getLoaderProps(containerSchema);\n\t\tconst url = createOdspUrl({\n\t\t\tsiteUrl: this.connectionConfig.siteUrl,\n\t\t\tdriveId: this.connectionConfig.driveId,\n\t\t\titemId: id,\n\t\t\tdataStorePath: \"\",\n\t\t});\n\t\tconst container = await loadExistingContainer({ ...loaderProps, request: { url } });\n\n\t\tconst fluidContainer = createFluidContainer({\n\t\t\tcontainer,\n\t\t\trootDataObject: await this.getContainerEntryPoint(container),\n\t\t});\n\t\tconst services = await this.getContainerServices(container);\n\t\treturn { container: fluidContainer as IFluidContainer<T>, services };\n\t}\n\n\tprivate getLoaderProps(schema: ContainerSchema): ILoaderProps {\n\t\tconst runtimeFactory = createDOProviderContainerRuntimeFactory({\n\t\t\tschema,\n\t\t\tcompatibilityMode: \"2\",\n\t\t});\n\t\tconst load = async (): Promise<IFluidModuleWithDetails> => {\n\t\t\treturn {\n\t\t\t\tmodule: { fluidExport: runtimeFactory },\n\t\t\t\tdetails: { package: \"no-dynamic-package\", config: {} },\n\t\t\t};\n\t\t};\n\n\t\tconst codeLoader = { load };\n\t\tconst client: IClient = {\n\t\t\tdetails: {\n\t\t\t\tcapabilities: { interactive: true },\n\t\t\t},\n\t\t\tpermission: [],\n\t\t\tscopes: [],\n\t\t\tuser: { id: \"\" },\n\t\t\tmode: \"write\",\n\t\t};\n\n\t\treturn {\n\t\t\turlResolver: this.urlResolver,\n\t\t\tdocumentServiceFactory: this.documentServiceFactory,\n\t\t\tcodeLoader,\n\t\t\tlogger: this.logger,\n\t\t\toptions: { client },\n\t\t\tconfigProvider: this.configProvider,\n\t\t};\n\t}\n\n\tprivate async createFluidContainer(\n\t\tcontainer: IContainer,\n\t\tconnection: OdspConnectionConfig,\n\t): Promise<IFluidContainer> {\n\t\tconst rootDataObject = await this.getContainerEntryPoint(container);\n\n\t\t/**\n\t\t * See {@link FluidContainer.attach}\n\t\t */\n\t\tconst attach = async (\n\t\t\todspProps?: ContainerAttachProps<OdspContainerAttachProps>,\n\t\t): Promise<string> => {\n\t\t\t// The comment will be removed up when the deprecated code is removed in AB#31049\n\t\t\t// eslint-disable-next-line import/no-deprecated\n\t\t\tconst createNewRequest: IRequest = createOdspCreateContainerRequest(\n\t\t\t\tconnection.siteUrl,\n\t\t\t\tconnection.driveId,\n\t\t\t\todspProps?.filePath ?? \"\",\n\t\t\t\todspProps?.fileName ?? uuid(),\n\t\t\t);\n\t\t\tif (container.attachState !== AttachState.Detached) {\n\t\t\t\tthrow new Error(\"Cannot attach container. Container is not in detached state\");\n\t\t\t}\n\t\t\tawait container.attach(createNewRequest);\n\n\t\t\tconst resolvedUrl = container.resolvedUrl;\n\n\t\t\tif (resolvedUrl === undefined || !isOdspResolvedUrl(resolvedUrl)) {\n\t\t\t\tthrow new Error(\"Resolved Url not available on attached container\");\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * A unique identifier for the file within the provided SharePoint Embedded container ID. When you attach a container,\n\t\t\t * a new `itemId` is created in the user's drive, which developers can use for various operations\n\t\t\t * like updating, renaming, moving the Fluid file, changing permissions, and more. `itemId` is used to load the container.\n\t\t\t */\n\t\t\treturn resolvedUrl.itemId;\n\t\t};\n\t\tconst fluidContainer = createFluidContainer({ container, rootDataObject });\n\t\tfluidContainer.attach = attach;\n\t\treturn fluidContainer;\n\t}\n\n\tprivate async getContainerServices(container: IContainer): Promise<OdspContainerServices> {\n\t\treturn {\n\t\t\taudience: createServiceAudience({\n\t\t\t\tcontainer,\n\t\t\t\tcreateServiceMember: createOdspAudienceMember,\n\t\t\t}),\n\t\t};\n\t}\n\n\tprivate async getContainerEntryPoint(container: IContainer): Promise<IRootDataObject> {\n\t\tconst rootDataObject: FluidObject<IRootDataObject> = await container.getEntryPoint();\n\t\tassert(\n\t\t\trootDataObject.IRootDataObject !== undefined,\n\t\t\t0x878 /* entryPoint must be of type IRootDataObject */,\n\t\t);\n\t\treturn rootDataObject.IRootDataObject;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"odspClient.js","sourceRoot":"","sources":["../src/odspClient.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAKpE,OAAO,EACN,uBAAuB,EACvB,qBAAqB,GAErB,MAAM,2CAA2C,CAAC;AAanD,OAAO,EACN,uCAAuC,EACvC,oBAAoB,EACpB,qBAAqB,GACrB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACN,0BAA0B,EAC1B,qBAAqB,EACr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CAC7B,CAAC;YACF,IAAI,SAAS,CAAC,WAAW,KAAK,WAAW,CAAC,QAAQ,EAAE,CAAC;gBACpD,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;YAChF,CAAC;YACD,MAAM,SAAS,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;YAEzC,MAAM,WAAW,GAAG,SAAS,CAAC,WAAW,CAAC;YAE1C,IAAI,WAAW,KAAK,SAAS,IAAI,CAAC,iBAAiB,CAAC,WAAW,CAAC,EAAE,CAAC;gBAClE,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;YACrE,CAAC;YAED;;;;eAIG;YACH,OAAO,WAAW,CAAC,MAAM,CAAC;QAC3B,CAAC,CAAC;QACF,MAAM,cAAc,GAAG,MAAM,oBAAoB,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;QACjE,cAAc,CAAC,MAAM,GAAG,MAAM,CAAC;QAC/B,OAAO,cAAc,CAAC;IACvB,CAAC;IAEO,KAAK,CAAC,oBAAoB,CAAC,SAAqB;QACvD,OAAO;YACN,QAAQ,EAAE,qBAAqB,CAAC;gBAC/B,SAAS;gBACT,mBAAmB,EAAE,wBAAwB;aAC7C,CAAC;SACF,CAAC;IACH,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport type {\n\tIContainer,\n\tIFluidModuleWithDetails,\n} from \"@fluidframework/container-definitions/internal\";\nimport {\n\tcreateDetachedContainer,\n\tloadExistingContainer,\n\ttype ILoaderProps,\n} from \"@fluidframework/container-loader/internal\";\nimport type {\n\tIConfigProviderBase,\n\tIRequest,\n\tITelemetryBaseLogger,\n} from \"@fluidframework/core-interfaces\";\nimport type { IClient } from \"@fluidframework/driver-definitions\";\nimport type { IDocumentServiceFactory } from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tContainerAttachProps,\n\tContainerSchema,\n\tIFluidContainer,\n} from \"@fluidframework/fluid-static\";\nimport {\n\tcreateDOProviderContainerRuntimeFactory,\n\tcreateFluidContainer,\n\tcreateServiceAudience,\n} from \"@fluidframework/fluid-static/internal\";\nimport {\n\tOdspDocumentServiceFactory,\n\tOdspDriverUrlResolver,\n\tcreateOdspCreateContainerRequest,\n\tcreateOdspUrl,\n\tisOdspResolvedUrl,\n} from \"@fluidframework/odsp-driver/internal\";\nimport type { OdspResourceTokenFetchOptions } from \"@fluidframework/odsp-driver-definitions/internal\";\nimport { wrapConfigProviderWithDefaults } from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport type { TokenResponse } from \"./interfaces.js\";\nimport type {\n\tOdspClientProps,\n\tOdspConnectionConfig,\n\tOdspContainerAttachProps,\n\tOdspContainerServices,\n} from \"./interfaces.js\";\nimport { createOdspAudienceMember } from \"./odspAudience.js\";\nimport type { IOdspTokenProvider } from \"./token.js\";\n\nasync function getStorageToken(\n\toptions: OdspResourceTokenFetchOptions,\n\ttokenProvider: IOdspTokenProvider,\n): Promise<TokenResponse> {\n\tconst tokenResponse: TokenResponse = await tokenProvider.fetchStorageToken(\n\t\toptions.siteUrl,\n\t\toptions.refresh,\n\t);\n\treturn tokenResponse;\n}\n\nasync function getWebsocketToken(\n\toptions: OdspResourceTokenFetchOptions,\n\ttokenProvider: IOdspTokenProvider,\n): Promise<TokenResponse> {\n\tconst tokenResponse: TokenResponse = await tokenProvider.fetchWebsocketToken(\n\t\toptions.siteUrl,\n\t\toptions.refresh,\n\t);\n\treturn tokenResponse;\n}\n\n/**\n * Default feature gates.\n * These values will only be used if the feature gate is not already set by the supplied config provider.\n */\nconst odspClientFeatureGates = {\n\t// None yet\n};\n\n/**\n * Wrap the config provider to fall back on the appropriate defaults for ODSP Client.\n * @param baseConfigProvider - The base config provider to wrap\n * @returns A new config provider with the appropriate defaults applied underneath the given provider\n */\nfunction wrapConfigProvider(baseConfigProvider?: IConfigProviderBase): IConfigProviderBase {\n\treturn wrapConfigProviderWithDefaults(baseConfigProvider, odspClientFeatureGates);\n}\n\n/**\n * OdspClient provides the ability to have a Fluid object backed by the ODSP service within the context of Microsoft 365 (M365) tenants.\n * @sealed\n * @beta\n */\nexport class OdspClient {\n\tprivate readonly documentServiceFactory: IDocumentServiceFactory;\n\tprivate readonly urlResolver: OdspDriverUrlResolver;\n\tprivate readonly configProvider: IConfigProviderBase | undefined;\n\tprivate readonly connectionConfig: OdspConnectionConfig;\n\tprivate readonly logger: ITelemetryBaseLogger | undefined;\n\n\tpublic constructor(properties: OdspClientProps) {\n\t\tthis.connectionConfig = properties.connection;\n\t\tthis.logger = properties.logger;\n\t\tthis.documentServiceFactory = new OdspDocumentServiceFactory(\n\t\t\tasync (options) => getStorageToken(options, this.connectionConfig.tokenProvider),\n\t\t\tasync (options) => getWebsocketToken(options, this.connectionConfig.tokenProvider),\n\t\t);\n\n\t\tthis.urlResolver = new OdspDriverUrlResolver();\n\t\tthis.configProvider = wrapConfigProvider(properties.configProvider);\n\t}\n\n\tpublic async createContainer<T extends ContainerSchema>(\n\t\tcontainerSchema: T,\n\t): Promise<{\n\t\tcontainer: IFluidContainer<T>;\n\t\tservices: OdspContainerServices;\n\t}> {\n\t\tconst loaderProps = this.getLoaderProps(containerSchema);\n\n\t\tconst container = await createDetachedContainer({\n\t\t\t...loaderProps,\n\t\t\tcodeDetails: {\n\t\t\t\tpackage: \"no-dynamic-package\",\n\t\t\t\tconfig: {},\n\t\t\t},\n\t\t});\n\n\t\tconst fluidContainer = await this.createFluidContainer(container, this.connectionConfig);\n\n\t\tconst services = await this.getContainerServices(container);\n\n\t\treturn { container: fluidContainer as IFluidContainer<T>, services };\n\t}\n\n\tpublic async getContainer<T extends ContainerSchema>(\n\t\tid: string,\n\t\tcontainerSchema: T,\n\t): Promise<{\n\t\tcontainer: IFluidContainer<T>;\n\t\tservices: OdspContainerServices;\n\t}> {\n\t\tconst loaderProps = this.getLoaderProps(containerSchema);\n\t\tconst url = createOdspUrl({\n\t\t\tsiteUrl: this.connectionConfig.siteUrl,\n\t\t\tdriveId: this.connectionConfig.driveId,\n\t\t\titemId: id,\n\t\t\tdataStorePath: \"\",\n\t\t});\n\t\tconst container = await loadExistingContainer({ ...loaderProps, request: { url } });\n\n\t\tconst fluidContainer = await createFluidContainer({\n\t\t\tcontainer,\n\t\t});\n\t\tconst services = await this.getContainerServices(container);\n\t\treturn { container: fluidContainer as IFluidContainer<T>, services };\n\t}\n\n\tprivate getLoaderProps(schema: ContainerSchema): ILoaderProps {\n\t\tconst runtimeFactory = createDOProviderContainerRuntimeFactory({\n\t\t\tschema,\n\t\t\tcompatibilityMode: \"2\",\n\t\t});\n\t\tconst load = async (): Promise<IFluidModuleWithDetails> => {\n\t\t\treturn {\n\t\t\t\tmodule: { fluidExport: runtimeFactory },\n\t\t\t\tdetails: { package: \"no-dynamic-package\", config: {} },\n\t\t\t};\n\t\t};\n\n\t\tconst codeLoader = { load };\n\t\tconst client: IClient = {\n\t\t\tdetails: {\n\t\t\t\tcapabilities: { interactive: true },\n\t\t\t},\n\t\t\tpermission: [],\n\t\t\tscopes: [],\n\t\t\tuser: { id: \"\" },\n\t\t\tmode: \"write\",\n\t\t};\n\n\t\treturn {\n\t\t\turlResolver: this.urlResolver,\n\t\t\tdocumentServiceFactory: this.documentServiceFactory,\n\t\t\tcodeLoader,\n\t\t\tlogger: this.logger,\n\t\t\toptions: { client },\n\t\t\tconfigProvider: this.configProvider,\n\t\t};\n\t}\n\n\tprivate async createFluidContainer(\n\t\tcontainer: IContainer,\n\t\tconnection: OdspConnectionConfig,\n\t): Promise<IFluidContainer> {\n\t\t/**\n\t\t * See {@link FluidContainer.attach}\n\t\t */\n\t\tconst attach = async (\n\t\t\todspProps?: ContainerAttachProps<OdspContainerAttachProps>,\n\t\t): Promise<string> => {\n\t\t\tconst createNewRequest: IRequest = createOdspCreateContainerRequest(\n\t\t\t\tconnection.siteUrl,\n\t\t\t\tconnection.driveId,\n\t\t\t\todspProps?.filePath ?? \"\",\n\t\t\t\todspProps?.fileName ?? uuid(),\n\t\t\t);\n\t\t\tif (container.attachState !== AttachState.Detached) {\n\t\t\t\tthrow new Error(\"Cannot attach container. Container is not in detached state\");\n\t\t\t}\n\t\t\tawait container.attach(createNewRequest);\n\n\t\t\tconst resolvedUrl = container.resolvedUrl;\n\n\t\t\tif (resolvedUrl === undefined || !isOdspResolvedUrl(resolvedUrl)) {\n\t\t\t\tthrow new Error(\"Resolved Url not available on attached container\");\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * A unique identifier for the file within the provided SharePoint Embedded container ID. When you attach a container,\n\t\t\t * a new `itemId` is created in the user's drive, which developers can use for various operations\n\t\t\t * like updating, renaming, moving the Fluid file, changing permissions, and more. `itemId` is used to load the container.\n\t\t\t */\n\t\t\treturn resolvedUrl.itemId;\n\t\t};\n\t\tconst fluidContainer = await createFluidContainer({ container });\n\t\tfluidContainer.attach = attach;\n\t\treturn fluidContainer;\n\t}\n\n\tprivate async getContainerServices(container: IContainer): Promise<OdspContainerServices> {\n\t\treturn {\n\t\t\taudience: createServiceAudience({\n\t\t\t\tcontainer,\n\t\t\t\tcreateServiceMember: createOdspAudienceMember,\n\t\t\t}),\n\t\t};\n\t}\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/odsp-client",
|
|
3
|
-
"version": "2.41.0
|
|
3
|
+
"version": "2.41.0",
|
|
4
4
|
"description": "A tool to enable creation and loading of Fluid containers using the ODSP service",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -69,28 +69,28 @@
|
|
|
69
69
|
"temp-directory": "nyc/.nyc_output"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@fluidframework/container-definitions": "2.41.0
|
|
73
|
-
"@fluidframework/container-loader": "2.41.0
|
|
74
|
-
"@fluidframework/core-interfaces": "2.41.0
|
|
75
|
-
"@fluidframework/core-utils": "2.41.0
|
|
76
|
-
"@fluidframework/driver-definitions": "2.41.0
|
|
77
|
-
"@fluidframework/fluid-static": "2.41.0
|
|
78
|
-
"@fluidframework/map": "2.41.0
|
|
79
|
-
"@fluidframework/odsp-doclib-utils": "2.41.0
|
|
80
|
-
"@fluidframework/odsp-driver": "2.41.0
|
|
81
|
-
"@fluidframework/odsp-driver-definitions": "2.41.0
|
|
82
|
-
"@fluidframework/telemetry-utils": "2.41.0
|
|
72
|
+
"@fluidframework/container-definitions": "~2.41.0",
|
|
73
|
+
"@fluidframework/container-loader": "~2.41.0",
|
|
74
|
+
"@fluidframework/core-interfaces": "~2.41.0",
|
|
75
|
+
"@fluidframework/core-utils": "~2.41.0",
|
|
76
|
+
"@fluidframework/driver-definitions": "~2.41.0",
|
|
77
|
+
"@fluidframework/fluid-static": "~2.41.0",
|
|
78
|
+
"@fluidframework/map": "~2.41.0",
|
|
79
|
+
"@fluidframework/odsp-doclib-utils": "~2.41.0",
|
|
80
|
+
"@fluidframework/odsp-driver": "~2.41.0",
|
|
81
|
+
"@fluidframework/odsp-driver-definitions": "~2.41.0",
|
|
82
|
+
"@fluidframework/telemetry-utils": "~2.41.0",
|
|
83
83
|
"uuid": "^9.0.0"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
86
|
"@arethetypeswrong/cli": "^0.17.1",
|
|
87
87
|
"@biomejs/biome": "~1.9.3",
|
|
88
|
-
"@fluid-internal/mocha-test-setup": "2.41.0
|
|
88
|
+
"@fluid-internal/mocha-test-setup": "~2.41.0",
|
|
89
89
|
"@fluid-tools/build-cli": "^0.55.0",
|
|
90
90
|
"@fluidframework/build-common": "^2.0.3",
|
|
91
91
|
"@fluidframework/build-tools": "^0.55.0",
|
|
92
|
-
"@fluidframework/eslint-config-fluid": "^5.7.
|
|
93
|
-
"@fluidframework/test-utils": "2.41.0
|
|
92
|
+
"@fluidframework/eslint-config-fluid": "^5.7.4",
|
|
93
|
+
"@fluidframework/test-utils": "~2.41.0",
|
|
94
94
|
"@microsoft/api-extractor": "7.52.8",
|
|
95
95
|
"@types/mocha": "^10.0.10",
|
|
96
96
|
"@types/node": "^18.19.0",
|
package/src/odspClient.ts
CHANGED
|
@@ -14,12 +14,10 @@ import {
|
|
|
14
14
|
type ILoaderProps,
|
|
15
15
|
} from "@fluidframework/container-loader/internal";
|
|
16
16
|
import type {
|
|
17
|
-
FluidObject,
|
|
18
17
|
IConfigProviderBase,
|
|
19
18
|
IRequest,
|
|
20
19
|
ITelemetryBaseLogger,
|
|
21
20
|
} from "@fluidframework/core-interfaces";
|
|
22
|
-
import { assert } from "@fluidframework/core-utils/internal";
|
|
23
21
|
import type { IClient } from "@fluidframework/driver-definitions";
|
|
24
22
|
import type { IDocumentServiceFactory } from "@fluidframework/driver-definitions/internal";
|
|
25
23
|
import type {
|
|
@@ -27,7 +25,6 @@ import type {
|
|
|
27
25
|
ContainerSchema,
|
|
28
26
|
IFluidContainer,
|
|
29
27
|
} from "@fluidframework/fluid-static";
|
|
30
|
-
import type { IRootDataObject } from "@fluidframework/fluid-static/internal";
|
|
31
28
|
import {
|
|
32
29
|
createDOProviderContainerRuntimeFactory,
|
|
33
30
|
createFluidContainer,
|
|
@@ -36,8 +33,6 @@ import {
|
|
|
36
33
|
import {
|
|
37
34
|
OdspDocumentServiceFactory,
|
|
38
35
|
OdspDriverUrlResolver,
|
|
39
|
-
// The comment will be removed up when the deprecated code is removed in AB#31049
|
|
40
|
-
// eslint-disable-next-line import/no-deprecated
|
|
41
36
|
createOdspCreateContainerRequest,
|
|
42
37
|
createOdspUrl,
|
|
43
38
|
isOdspResolvedUrl,
|
|
@@ -158,9 +153,8 @@ export class OdspClient {
|
|
|
158
153
|
});
|
|
159
154
|
const container = await loadExistingContainer({ ...loaderProps, request: { url } });
|
|
160
155
|
|
|
161
|
-
const fluidContainer = createFluidContainer({
|
|
156
|
+
const fluidContainer = await createFluidContainer({
|
|
162
157
|
container,
|
|
163
|
-
rootDataObject: await this.getContainerEntryPoint(container),
|
|
164
158
|
});
|
|
165
159
|
const services = await this.getContainerServices(container);
|
|
166
160
|
return { container: fluidContainer as IFluidContainer<T>, services };
|
|
@@ -203,16 +197,12 @@ export class OdspClient {
|
|
|
203
197
|
container: IContainer,
|
|
204
198
|
connection: OdspConnectionConfig,
|
|
205
199
|
): Promise<IFluidContainer> {
|
|
206
|
-
const rootDataObject = await this.getContainerEntryPoint(container);
|
|
207
|
-
|
|
208
200
|
/**
|
|
209
201
|
* See {@link FluidContainer.attach}
|
|
210
202
|
*/
|
|
211
203
|
const attach = async (
|
|
212
204
|
odspProps?: ContainerAttachProps<OdspContainerAttachProps>,
|
|
213
205
|
): Promise<string> => {
|
|
214
|
-
// The comment will be removed up when the deprecated code is removed in AB#31049
|
|
215
|
-
// eslint-disable-next-line import/no-deprecated
|
|
216
206
|
const createNewRequest: IRequest = createOdspCreateContainerRequest(
|
|
217
207
|
connection.siteUrl,
|
|
218
208
|
connection.driveId,
|
|
@@ -237,7 +227,7 @@ export class OdspClient {
|
|
|
237
227
|
*/
|
|
238
228
|
return resolvedUrl.itemId;
|
|
239
229
|
};
|
|
240
|
-
const fluidContainer = createFluidContainer({ container
|
|
230
|
+
const fluidContainer = await createFluidContainer({ container });
|
|
241
231
|
fluidContainer.attach = attach;
|
|
242
232
|
return fluidContainer;
|
|
243
233
|
}
|
|
@@ -250,13 +240,4 @@ export class OdspClient {
|
|
|
250
240
|
}),
|
|
251
241
|
};
|
|
252
242
|
}
|
|
253
|
-
|
|
254
|
-
private async getContainerEntryPoint(container: IContainer): Promise<IRootDataObject> {
|
|
255
|
-
const rootDataObject: FluidObject<IRootDataObject> = await container.getEntryPoint();
|
|
256
|
-
assert(
|
|
257
|
-
rootDataObject.IRootDataObject !== undefined,
|
|
258
|
-
0x878 /* entryPoint must be of type IRootDataObject */,
|
|
259
|
-
);
|
|
260
|
-
return rootDataObject.IRootDataObject;
|
|
261
|
-
}
|
|
262
243
|
}
|