@fluid-tools/fetch-tool 2.0.0-rc.3.0.3 → 2.0.0-rc.4.0.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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # @fluid-tools/fetch-tool
2
2
 
3
+ ## 2.0.0-rc.4.0.0
4
+
5
+ Dependency updates only.
6
+
3
7
  ## 2.0.0-rc.3.0.0
4
8
 
5
9
  ### Major Changes
@@ -9,13 +9,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.getSingleSharePointFile = exports.getSharepointFiles = exports.resolveWrapper = void 0;
11
11
  const child_process_1 = __importDefault(require("child_process"));
12
- const driver_definitions_1 = require("@fluidframework/driver-definitions");
13
- const internal_1 = require("@fluidframework/odsp-doclib-utils/internal");
14
- const internal_2 = require("@fluidframework/tool-utils/internal");
12
+ const internal_1 = require("@fluidframework/driver-definitions/internal");
13
+ const internal_2 = require("@fluidframework/odsp-doclib-utils/internal");
14
+ const internal_3 = require("@fluidframework/tool-utils/internal");
15
15
  const fluidFetchArgs_js_1 = require("./fluidFetchArgs.js");
16
16
  async function resolveWrapper(callback, server, clientConfig, forceTokenReauth = false, forToken = false) {
17
17
  try {
18
- const odspTokenManager = new internal_2.OdspTokenManager(internal_2.odspTokensCache);
18
+ const odspTokenManager = new internal_3.OdspTokenManager(internal_3.odspTokensCache);
19
19
  const tokenConfig = {
20
20
  type: "browserLogin",
21
21
  navigator: fluidFetchWebNavigator,
@@ -23,7 +23,7 @@ async function resolveWrapper(callback, server, clientConfig, forceTokenReauth =
23
23
  const tokens = await odspTokenManager.getOdspTokens(server, clientConfig, tokenConfig, undefined /* forceRefresh */, forceTokenReauth || (0, fluidFetchArgs_js_1.getForceTokenReauth)());
24
24
  const result = await callback({
25
25
  accessToken: tokens.accessToken,
26
- refreshTokenFn: (0, internal_1.getOdspRefreshTokenFn)(server, clientConfig, tokens),
26
+ refreshTokenFn: (0, internal_2.getOdspRefreshTokenFn)(server, clientConfig, tokens),
27
27
  });
28
28
  // If this is used for getting a token, then refresh the cache with new token.
29
29
  if (forToken) {
@@ -37,7 +37,7 @@ async function resolveWrapper(callback, server, clientConfig, forceTokenReauth =
37
37
  return result;
38
38
  }
39
39
  catch (e) {
40
- if (e.errorType === driver_definitions_1.DriverErrorTypes.authorizationError && !forceTokenReauth) {
40
+ if (e.errorType === internal_1.DriverErrorTypes.authorizationError && !forceTokenReauth) {
41
41
  // Re-auth
42
42
  return resolveWrapper(callback, server, clientConfig, true, forToken);
43
43
  }
@@ -48,15 +48,15 @@ exports.resolveWrapper = resolveWrapper;
48
48
  async function resolveDriveItemByServerRelativePath(server, serverRelativePath, clientConfig) {
49
49
  return resolveWrapper(
50
50
  // eslint-disable-next-line @typescript-eslint/promise-function-async
51
- (authRequestInfo) => (0, internal_1.getDriveItemByServerRelativePath)(server, serverRelativePath, authRequestInfo, false), server, clientConfig);
51
+ (authRequestInfo) => (0, internal_2.getDriveItemByServerRelativePath)(server, serverRelativePath, authRequestInfo, false), server, clientConfig);
52
52
  }
53
53
  async function resolveChildrenByDriveItem(server, folderDriveItem, clientConfig) {
54
54
  return resolveWrapper(
55
55
  // eslint-disable-next-line @typescript-eslint/promise-function-async
56
- (authRequestInfo) => (0, internal_1.getChildrenByDriveItem)(folderDriveItem, server, authRequestInfo), server, clientConfig);
56
+ (authRequestInfo) => (0, internal_2.getChildrenByDriveItem)(folderDriveItem, server, authRequestInfo), server, clientConfig);
57
57
  }
58
58
  async function getSharepointFiles(server, serverRelativePath, recurse) {
59
- const clientConfig = (0, internal_2.getMicrosoftConfiguration)();
59
+ const clientConfig = (0, internal_3.getMicrosoftConfiguration)();
60
60
  const fileInfo = await resolveDriveItemByServerRelativePath(server, serverRelativePath, clientConfig);
61
61
  console.log(fileInfo);
62
62
  const pendingFolder = [];
@@ -91,10 +91,10 @@ async function getSharepointFiles(server, serverRelativePath, recurse) {
91
91
  }
92
92
  exports.getSharepointFiles = getSharepointFiles;
93
93
  async function getSingleSharePointFile(server, drive, item) {
94
- const clientConfig = (0, internal_2.getMicrosoftConfiguration)();
94
+ const clientConfig = (0, internal_3.getMicrosoftConfiguration)();
95
95
  return resolveWrapper(
96
96
  // eslint-disable-next-line @typescript-eslint/promise-function-async
97
- (authRequestInfo) => (0, internal_1.getDriveItemFromDriveAndItem)(server, drive, item, authRequestInfo), server, clientConfig);
97
+ (authRequestInfo) => (0, internal_2.getDriveItemFromDriveAndItem)(server, drive, item, authRequestInfo), server, clientConfig);
98
98
  }
99
99
  exports.getSingleSharePointFile = getSingleSharePointFile;
100
100
  const fluidFetchWebNavigator = (url) => {
@@ -1 +1 @@
1
- {"version":3,"file":"fluidFetchSharePoint.js","sourceRoot":"","sources":["../src/fluidFetchSharePoint.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,kEAA0C;AAE1C,2EAAsE;AACtE,yEAQoD;AACpD,kEAM6C;AAE7C,2DAA0D;AAEnD,KAAK,UAAU,cAAc,CACnC,QAA+D,EAC/D,MAAc,EACd,YAA2B,EAC3B,gBAAgB,GAAG,KAAK,EACxB,QAAQ,GAAG,KAAK;IAEhB,IAAI;QACH,MAAM,gBAAgB,GAAG,IAAI,2BAAgB,CAAC,0BAAe,CAAC,CAAC;QAC/D,MAAM,WAAW,GAAoB;YACpC,IAAI,EAAE,cAAc;YACpB,SAAS,EAAE,sBAAsB;SACjC,CAAC;QACF,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,aAAa,CAClD,MAAM,EACN,YAAY,EACZ,WAAW,EACX,SAAS,CAAC,kBAAkB,EAC5B,gBAAgB,IAAI,IAAA,uCAAmB,GAAE,CACzC,CAAC;QAEF,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC;YAC7B,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,cAAc,EAAE,IAAA,gCAAqB,EAAC,MAAM,EAAE,YAAY,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D,OAAO,cAAc;IACpB,qEAAqE;IACrE,CAAC,eAAe,EAAE,EAAE,CAAC,IAAA,uCAA4B,EAAC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,eAAe,CAAC,EACvF,MAAM,EACN,YAAY,CACZ,CAAC;AACH,CAAC;AATD,0DASC;AAED,MAAM,sBAAsB,GAAG,CAAC,GAAW,EAAE,EAAE;IAC9C,IAAI,OAAO,GAAG,+CAA+C,CAAC;IAC9D,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE;QACjC,uBAAa,CAAC,IAAI,CAAC,2BAA2B,GAAG,GAAG,CAAC,CAAC;QACtD,OAAO;YACN,kGAAkG,CAAC;KACpG;IACD,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,OAAO,GAAG,EAAE,CAAC,CAAC;AACrC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport child_process from \"child_process\";\n\nimport { DriverErrorTypes } from \"@fluidframework/driver-definitions\";\nimport {\n\tIClientConfig,\n\tIOdspAuthRequestInfo,\n\tIOdspDriveItem,\n\tgetChildrenByDriveItem,\n\tgetDriveItemByServerRelativePath,\n\tgetDriveItemFromDriveAndItem,\n\tgetOdspRefreshTokenFn,\n} from \"@fluidframework/odsp-doclib-utils/internal\";\nimport {\n\tIOdspTokenManagerCacheKey,\n\tOdspTokenConfig,\n\tOdspTokenManager,\n\tgetMicrosoftConfiguration,\n\todspTokensCache,\n} from \"@fluidframework/tool-utils/internal\";\n\nimport { getForceTokenReauth } from \"./fluidFetchArgs.js\";\n\nexport async function resolveWrapper<T>(\n\tcallback: (authRequestInfo: IOdspAuthRequestInfo) => Promise<T>,\n\tserver: string,\n\tclientConfig: IClientConfig,\n\tforceTokenReauth = false,\n\tforToken = false,\n): Promise<T> {\n\ttry {\n\t\tconst odspTokenManager = new OdspTokenManager(odspTokensCache);\n\t\tconst tokenConfig: OdspTokenConfig = {\n\t\t\ttype: \"browserLogin\",\n\t\t\tnavigator: fluidFetchWebNavigator,\n\t\t};\n\t\tconst tokens = await odspTokenManager.getOdspTokens(\n\t\t\tserver,\n\t\t\tclientConfig,\n\t\t\ttokenConfig,\n\t\t\tundefined /* forceRefresh */,\n\t\t\tforceTokenReauth || getForceTokenReauth(),\n\t\t);\n\n\t\tconst result = await callback({\n\t\t\taccessToken: tokens.accessToken,\n\t\t\trefreshTokenFn: getOdspRefreshTokenFn(server, clientConfig, tokens),\n\t\t});\n\t\t// If this is used for getting a token, then refresh the cache with new token.\n\t\tif (forToken) {\n\t\t\tconst key: IOdspTokenManagerCacheKey = { isPush: false, userOrServer: server };\n\t\t\tawait odspTokenManager.updateTokensCache(key, {\n\t\t\t\taccessToken: result as any as string,\n\t\t\t\trefreshToken: tokens.refreshToken,\n\t\t\t});\n\t\t\treturn result;\n\t\t}\n\t\treturn result;\n\t} catch (e: any) {\n\t\tif (e.errorType === DriverErrorTypes.authorizationError && !forceTokenReauth) {\n\t\t\t// Re-auth\n\t\t\treturn resolveWrapper<T>(callback, server, clientConfig, true, forToken);\n\t\t}\n\t\tthrow e;\n\t}\n}\n\nasync function resolveDriveItemByServerRelativePath(\n\tserver: string,\n\tserverRelativePath: string,\n\tclientConfig: IClientConfig,\n) {\n\treturn resolveWrapper<IOdspDriveItem>(\n\t\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\t\t(authRequestInfo) =>\n\t\t\tgetDriveItemByServerRelativePath(server, serverRelativePath, authRequestInfo, false),\n\t\tserver,\n\t\tclientConfig,\n\t);\n}\n\nasync function resolveChildrenByDriveItem(\n\tserver: string,\n\tfolderDriveItem: IOdspDriveItem,\n\tclientConfig: IClientConfig,\n) {\n\treturn resolveWrapper<IOdspDriveItem[]>(\n\t\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\t\t(authRequestInfo) => getChildrenByDriveItem(folderDriveItem, server, authRequestInfo),\n\t\tserver,\n\t\tclientConfig,\n\t);\n}\n\nexport async function getSharepointFiles(\n\tserver: string,\n\tserverRelativePath: string,\n\trecurse: boolean,\n) {\n\tconst clientConfig = getMicrosoftConfiguration();\n\n\tconst fileInfo = await resolveDriveItemByServerRelativePath(\n\t\tserver,\n\t\tserverRelativePath,\n\t\tclientConfig,\n\t);\n\tconsole.log(fileInfo);\n\tconst pendingFolder: { path: string; folder: IOdspDriveItem }[] = [];\n\tconst files: IOdspDriveItem[] = [];\n\tif (fileInfo.isFolder) {\n\t\tpendingFolder.push({ path: serverRelativePath, folder: fileInfo });\n\t} else {\n\t\tfiles.push(fileInfo);\n\t}\n\n\t// eslint-disable-next-line no-constant-condition\n\twhile (true) {\n\t\tconst folderInfo = pendingFolder.shift();\n\t\tif (!folderInfo) {\n\t\t\tbreak;\n\t\t}\n\t\tconst { path, folder } = folderInfo;\n\t\tconst children = await resolveChildrenByDriveItem(server, folder, clientConfig);\n\t\tfor (const child of children) {\n\t\t\tconst childPath = `${path}/${child.name}`;\n\t\t\tif (child.isFolder) {\n\t\t\t\tif (recurse) {\n\t\t\t\t\tpendingFolder.push({ path: childPath, folder: child });\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfiles.push(child);\n\t\t\t}\n\t\t}\n\t}\n\treturn files;\n}\n\nexport async function getSingleSharePointFile(server: string, drive: string, item: string) {\n\tconst clientConfig = getMicrosoftConfiguration();\n\n\treturn resolveWrapper<IOdspDriveItem>(\n\t\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\t\t(authRequestInfo) => getDriveItemFromDriveAndItem(server, drive, item, authRequestInfo),\n\t\tserver,\n\t\tclientConfig,\n\t);\n}\n\nconst fluidFetchWebNavigator = (url: string) => {\n\tlet message = \"Please open browser and navigate to this URL:\";\n\tif (process.platform === \"win32\") {\n\t\tchild_process.exec(`start \"fluid-fetch\" /B \"${url}\"`);\n\t\tmessage =\n\t\t\t\"Opening browser to get authorization code. If that doesn't open, please go to this URL manually\";\n\t}\n\tconsole.log(`${message}\\n ${url}`);\n};\n"]}
1
+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O,OAAO,GAAG,EAAE,CAAC,CAAC;AACrC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport child_process from \"child_process\";\n\nimport { DriverErrorTypes } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tIClientConfig,\n\tIOdspAuthRequestInfo,\n\tIOdspDriveItem,\n\tgetChildrenByDriveItem,\n\tgetDriveItemByServerRelativePath,\n\tgetDriveItemFromDriveAndItem,\n\tgetOdspRefreshTokenFn,\n} from \"@fluidframework/odsp-doclib-utils/internal\";\nimport {\n\tIOdspTokenManagerCacheKey,\n\tOdspTokenConfig,\n\tOdspTokenManager,\n\tgetMicrosoftConfiguration,\n\todspTokensCache,\n} from \"@fluidframework/tool-utils/internal\";\n\nimport { getForceTokenReauth } from \"./fluidFetchArgs.js\";\n\nexport async function resolveWrapper<T>(\n\tcallback: (authRequestInfo: IOdspAuthRequestInfo) => Promise<T>,\n\tserver: string,\n\tclientConfig: IClientConfig,\n\tforceTokenReauth = false,\n\tforToken = false,\n): Promise<T> {\n\ttry {\n\t\tconst odspTokenManager = new OdspTokenManager(odspTokensCache);\n\t\tconst tokenConfig: OdspTokenConfig = {\n\t\t\ttype: \"browserLogin\",\n\t\t\tnavigator: fluidFetchWebNavigator,\n\t\t};\n\t\tconst tokens = await odspTokenManager.getOdspTokens(\n\t\t\tserver,\n\t\t\tclientConfig,\n\t\t\ttokenConfig,\n\t\t\tundefined /* forceRefresh */,\n\t\t\tforceTokenReauth || getForceTokenReauth(),\n\t\t);\n\n\t\tconst result = await callback({\n\t\t\taccessToken: tokens.accessToken,\n\t\t\trefreshTokenFn: getOdspRefreshTokenFn(server, clientConfig, tokens),\n\t\t});\n\t\t// If this is used for getting a token, then refresh the cache with new token.\n\t\tif (forToken) {\n\t\t\tconst key: IOdspTokenManagerCacheKey = { isPush: false, userOrServer: server };\n\t\t\tawait odspTokenManager.updateTokensCache(key, {\n\t\t\t\taccessToken: result as any as string,\n\t\t\t\trefreshToken: tokens.refreshToken,\n\t\t\t});\n\t\t\treturn result;\n\t\t}\n\t\treturn result;\n\t} catch (e: any) {\n\t\tif (e.errorType === DriverErrorTypes.authorizationError && !forceTokenReauth) {\n\t\t\t// Re-auth\n\t\t\treturn resolveWrapper<T>(callback, server, clientConfig, true, forToken);\n\t\t}\n\t\tthrow e;\n\t}\n}\n\nasync function resolveDriveItemByServerRelativePath(\n\tserver: string,\n\tserverRelativePath: string,\n\tclientConfig: IClientConfig,\n) {\n\treturn resolveWrapper<IOdspDriveItem>(\n\t\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\t\t(authRequestInfo) =>\n\t\t\tgetDriveItemByServerRelativePath(server, serverRelativePath, authRequestInfo, false),\n\t\tserver,\n\t\tclientConfig,\n\t);\n}\n\nasync function resolveChildrenByDriveItem(\n\tserver: string,\n\tfolderDriveItem: IOdspDriveItem,\n\tclientConfig: IClientConfig,\n) {\n\treturn resolveWrapper<IOdspDriveItem[]>(\n\t\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\t\t(authRequestInfo) => getChildrenByDriveItem(folderDriveItem, server, authRequestInfo),\n\t\tserver,\n\t\tclientConfig,\n\t);\n}\n\nexport async function getSharepointFiles(\n\tserver: string,\n\tserverRelativePath: string,\n\trecurse: boolean,\n) {\n\tconst clientConfig = getMicrosoftConfiguration();\n\n\tconst fileInfo = await resolveDriveItemByServerRelativePath(\n\t\tserver,\n\t\tserverRelativePath,\n\t\tclientConfig,\n\t);\n\tconsole.log(fileInfo);\n\tconst pendingFolder: { path: string; folder: IOdspDriveItem }[] = [];\n\tconst files: IOdspDriveItem[] = [];\n\tif (fileInfo.isFolder) {\n\t\tpendingFolder.push({ path: serverRelativePath, folder: fileInfo });\n\t} else {\n\t\tfiles.push(fileInfo);\n\t}\n\n\t// eslint-disable-next-line no-constant-condition\n\twhile (true) {\n\t\tconst folderInfo = pendingFolder.shift();\n\t\tif (!folderInfo) {\n\t\t\tbreak;\n\t\t}\n\t\tconst { path, folder } = folderInfo;\n\t\tconst children = await resolveChildrenByDriveItem(server, folder, clientConfig);\n\t\tfor (const child of children) {\n\t\t\tconst childPath = `${path}/${child.name}`;\n\t\t\tif (child.isFolder) {\n\t\t\t\tif (recurse) {\n\t\t\t\t\tpendingFolder.push({ path: childPath, folder: child });\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfiles.push(child);\n\t\t\t}\n\t\t}\n\t}\n\treturn files;\n}\n\nexport async function getSingleSharePointFile(server: string, drive: string, item: string) {\n\tconst clientConfig = getMicrosoftConfiguration();\n\n\treturn resolveWrapper<IOdspDriveItem>(\n\t\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\t\t(authRequestInfo) => getDriveItemFromDriveAndItem(server, drive, item, authRequestInfo),\n\t\tserver,\n\t\tclientConfig,\n\t);\n}\n\nconst fluidFetchWebNavigator = (url: string) => {\n\tlet message = \"Please open browser and navigate to this URL:\";\n\tif (process.platform === \"win32\") {\n\t\tchild_process.exec(`start \"fluid-fetch\" /B \"${url}\"`);\n\t\tmessage =\n\t\t\t\"Opening browser to get authorization code. If that doesn't open, please go to this URL manually\";\n\t}\n\tconsole.log(`${message}\\n ${url}`);\n};\n"]}
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import child_process from "child_process";
6
- import { DriverErrorTypes } from "@fluidframework/driver-definitions";
6
+ import { DriverErrorTypes } from "@fluidframework/driver-definitions/internal";
7
7
  import { getChildrenByDriveItem, getDriveItemByServerRelativePath, getDriveItemFromDriveAndItem, getOdspRefreshTokenFn, } from "@fluidframework/odsp-doclib-utils/internal";
8
8
  import { OdspTokenManager, getMicrosoftConfiguration, odspTokensCache, } from "@fluidframework/tool-utils/internal";
9
9
  import { getForceTokenReauth } from "./fluidFetchArgs.js";
@@ -1 +1 @@
1
- {"version":3,"file":"fluidFetchSharePoint.js","sourceRoot":"","sources":["../src/fluidFetchSharePoint.ts"],"names":[],"mappings":"AAAA;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AAG,GAAG,CAAC,CAAC;QACtD,OAAO;YACN,kGAAkG,CAAC;KACpG;IACD,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,OAAO,GAAG,EAAE,CAAC,CAAC;AACrC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport child_process from \"child_process\";\n\nimport { DriverErrorTypes } from \"@fluidframework/driver-definitions\";\nimport {\n\tIClientConfig,\n\tIOdspAuthRequestInfo,\n\tIOdspDriveItem,\n\tgetChildrenByDriveItem,\n\tgetDriveItemByServerRelativePath,\n\tgetDriveItemFromDriveAndItem,\n\tgetOdspRefreshTokenFn,\n} from \"@fluidframework/odsp-doclib-utils/internal\";\nimport {\n\tIOdspTokenManagerCacheKey,\n\tOdspTokenConfig,\n\tOdspTokenManager,\n\tgetMicrosoftConfiguration,\n\todspTokensCache,\n} from \"@fluidframework/tool-utils/internal\";\n\nimport { getForceTokenReauth } from \"./fluidFetchArgs.js\";\n\nexport async function resolveWrapper<T>(\n\tcallback: (authRequestInfo: IOdspAuthRequestInfo) => Promise<T>,\n\tserver: string,\n\tclientConfig: IClientConfig,\n\tforceTokenReauth = false,\n\tforToken = false,\n): Promise<T> {\n\ttry {\n\t\tconst odspTokenManager = new OdspTokenManager(odspTokensCache);\n\t\tconst tokenConfig: OdspTokenConfig = {\n\t\t\ttype: \"browserLogin\",\n\t\t\tnavigator: fluidFetchWebNavigator,\n\t\t};\n\t\tconst tokens = await odspTokenManager.getOdspTokens(\n\t\t\tserver,\n\t\t\tclientConfig,\n\t\t\ttokenConfig,\n\t\t\tundefined /* forceRefresh */,\n\t\t\tforceTokenReauth || getForceTokenReauth(),\n\t\t);\n\n\t\tconst result = await callback({\n\t\t\taccessToken: tokens.accessToken,\n\t\t\trefreshTokenFn: getOdspRefreshTokenFn(server, clientConfig, tokens),\n\t\t});\n\t\t// If this is used for getting a token, then refresh the cache with new token.\n\t\tif (forToken) {\n\t\t\tconst key: IOdspTokenManagerCacheKey = { isPush: false, userOrServer: server };\n\t\t\tawait odspTokenManager.updateTokensCache(key, {\n\t\t\t\taccessToken: result as any as string,\n\t\t\t\trefreshToken: tokens.refreshToken,\n\t\t\t});\n\t\t\treturn result;\n\t\t}\n\t\treturn result;\n\t} catch (e: any) {\n\t\tif (e.errorType === DriverErrorTypes.authorizationError && !forceTokenReauth) {\n\t\t\t// Re-auth\n\t\t\treturn resolveWrapper<T>(callback, server, clientConfig, true, forToken);\n\t\t}\n\t\tthrow e;\n\t}\n}\n\nasync function resolveDriveItemByServerRelativePath(\n\tserver: string,\n\tserverRelativePath: string,\n\tclientConfig: IClientConfig,\n) {\n\treturn resolveWrapper<IOdspDriveItem>(\n\t\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\t\t(authRequestInfo) =>\n\t\t\tgetDriveItemByServerRelativePath(server, serverRelativePath, authRequestInfo, false),\n\t\tserver,\n\t\tclientConfig,\n\t);\n}\n\nasync function resolveChildrenByDriveItem(\n\tserver: string,\n\tfolderDriveItem: IOdspDriveItem,\n\tclientConfig: IClientConfig,\n) {\n\treturn resolveWrapper<IOdspDriveItem[]>(\n\t\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\t\t(authRequestInfo) => getChildrenByDriveItem(folderDriveItem, server, authRequestInfo),\n\t\tserver,\n\t\tclientConfig,\n\t);\n}\n\nexport async function getSharepointFiles(\n\tserver: string,\n\tserverRelativePath: string,\n\trecurse: boolean,\n) {\n\tconst clientConfig = getMicrosoftConfiguration();\n\n\tconst fileInfo = await resolveDriveItemByServerRelativePath(\n\t\tserver,\n\t\tserverRelativePath,\n\t\tclientConfig,\n\t);\n\tconsole.log(fileInfo);\n\tconst pendingFolder: { path: string; folder: IOdspDriveItem }[] = [];\n\tconst files: IOdspDriveItem[] = [];\n\tif (fileInfo.isFolder) {\n\t\tpendingFolder.push({ path: serverRelativePath, folder: fileInfo });\n\t} else {\n\t\tfiles.push(fileInfo);\n\t}\n\n\t// eslint-disable-next-line no-constant-condition\n\twhile (true) {\n\t\tconst folderInfo = pendingFolder.shift();\n\t\tif (!folderInfo) {\n\t\t\tbreak;\n\t\t}\n\t\tconst { path, folder } = folderInfo;\n\t\tconst children = await resolveChildrenByDriveItem(server, folder, clientConfig);\n\t\tfor (const child of children) {\n\t\t\tconst childPath = `${path}/${child.name}`;\n\t\t\tif (child.isFolder) {\n\t\t\t\tif (recurse) {\n\t\t\t\t\tpendingFolder.push({ path: childPath, folder: child });\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfiles.push(child);\n\t\t\t}\n\t\t}\n\t}\n\treturn files;\n}\n\nexport async function getSingleSharePointFile(server: string, drive: string, item: string) {\n\tconst clientConfig = getMicrosoftConfiguration();\n\n\treturn resolveWrapper<IOdspDriveItem>(\n\t\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\t\t(authRequestInfo) => getDriveItemFromDriveAndItem(server, drive, item, authRequestInfo),\n\t\tserver,\n\t\tclientConfig,\n\t);\n}\n\nconst fluidFetchWebNavigator = (url: string) => {\n\tlet message = \"Please open browser and navigate to this URL:\";\n\tif (process.platform === \"win32\") {\n\t\tchild_process.exec(`start \"fluid-fetch\" /B \"${url}\"`);\n\t\tmessage =\n\t\t\t\"Opening browser to get authorization code. If that doesn't open, please go to this URL manually\";\n\t}\n\tconsole.log(`${message}\\n ${url}`);\n};\n"]}
1
+ {"version":3,"file":"fluidFetchSharePoint.js","sourceRoot":"","sources":["../src/fluidFetchSharePoint.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,aAAa,MAAM,eAAe,CAAC;AAE1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAC/E,OAAO,EAIN,sBAAsB,EACtB,gCAAgC,EAChC,4BAA4B,EAC5B,qBAAqB,GACrB,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAGN,gBAAgB,EAChB,yBAAyB,EACzB,eAAe,GACf,MAAM,qCAAqC,CAAC;AAE7C,O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AM,QAAQ,GAAG,MAAM,0BAA0B,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;QAChF,KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE;YAC7B,MAAM,SAAS,GAAG,GAAG,IAAI,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;YAC1C,IAAI,KAAK,CAAC,QAAQ,EAAE;gBACnB,IAAI,OAAO,EAAE;oBACZ,aAAa,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;iBACvD;aACD;iBAAM;gBACN,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aAClB;SACD;KACD;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,MAAc,EAAE,KAAa,EAAE,IAAY;IACxF,MAAM,YAAY,GAAG,yBAAyB,EAAE,CAAC;IAEjD,OAAO,cAAc;IACpB,qEAAqE;IACrE,CAAC,eAAe,EAAE,EAAE,CAAC,4BAA4B,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,eAAe,CAAC,EACvF,MAAM,EACN,YAAY,CACZ,CAAC;AACH,CAAC;AAED,MAAM,sBAAsB,GAAG,CAAC,GAAW,EAAE,EAAE;IAC9C,IAAI,OAAO,GAAG,+CAA+C,CAAC;IAC9D,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE;QACjC,aAAa,CAAC,IAAI,CAAC,2BAA2B,GAAG,GAAG,CAAC,CAAC;QACtD,OAAO;YACN,kGAAkG,CAAC;KACpG;IACD,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,OAAO,GAAG,EAAE,CAAC,CAAC;AACrC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport child_process from \"child_process\";\n\nimport { DriverErrorTypes } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tIClientConfig,\n\tIOdspAuthRequestInfo,\n\tIOdspDriveItem,\n\tgetChildrenByDriveItem,\n\tgetDriveItemByServerRelativePath,\n\tgetDriveItemFromDriveAndItem,\n\tgetOdspRefreshTokenFn,\n} from \"@fluidframework/odsp-doclib-utils/internal\";\nimport {\n\tIOdspTokenManagerCacheKey,\n\tOdspTokenConfig,\n\tOdspTokenManager,\n\tgetMicrosoftConfiguration,\n\todspTokensCache,\n} from \"@fluidframework/tool-utils/internal\";\n\nimport { getForceTokenReauth } from \"./fluidFetchArgs.js\";\n\nexport async function resolveWrapper<T>(\n\tcallback: (authRequestInfo: IOdspAuthRequestInfo) => Promise<T>,\n\tserver: string,\n\tclientConfig: IClientConfig,\n\tforceTokenReauth = false,\n\tforToken = false,\n): Promise<T> {\n\ttry {\n\t\tconst odspTokenManager = new OdspTokenManager(odspTokensCache);\n\t\tconst tokenConfig: OdspTokenConfig = {\n\t\t\ttype: \"browserLogin\",\n\t\t\tnavigator: fluidFetchWebNavigator,\n\t\t};\n\t\tconst tokens = await odspTokenManager.getOdspTokens(\n\t\t\tserver,\n\t\t\tclientConfig,\n\t\t\ttokenConfig,\n\t\t\tundefined /* forceRefresh */,\n\t\t\tforceTokenReauth || getForceTokenReauth(),\n\t\t);\n\n\t\tconst result = await callback({\n\t\t\taccessToken: tokens.accessToken,\n\t\t\trefreshTokenFn: getOdspRefreshTokenFn(server, clientConfig, tokens),\n\t\t});\n\t\t// If this is used for getting a token, then refresh the cache with new token.\n\t\tif (forToken) {\n\t\t\tconst key: IOdspTokenManagerCacheKey = { isPush: false, userOrServer: server };\n\t\t\tawait odspTokenManager.updateTokensCache(key, {\n\t\t\t\taccessToken: result as any as string,\n\t\t\t\trefreshToken: tokens.refreshToken,\n\t\t\t});\n\t\t\treturn result;\n\t\t}\n\t\treturn result;\n\t} catch (e: any) {\n\t\tif (e.errorType === DriverErrorTypes.authorizationError && !forceTokenReauth) {\n\t\t\t// Re-auth\n\t\t\treturn resolveWrapper<T>(callback, server, clientConfig, true, forToken);\n\t\t}\n\t\tthrow e;\n\t}\n}\n\nasync function resolveDriveItemByServerRelativePath(\n\tserver: string,\n\tserverRelativePath: string,\n\tclientConfig: IClientConfig,\n) {\n\treturn resolveWrapper<IOdspDriveItem>(\n\t\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\t\t(authRequestInfo) =>\n\t\t\tgetDriveItemByServerRelativePath(server, serverRelativePath, authRequestInfo, false),\n\t\tserver,\n\t\tclientConfig,\n\t);\n}\n\nasync function resolveChildrenByDriveItem(\n\tserver: string,\n\tfolderDriveItem: IOdspDriveItem,\n\tclientConfig: IClientConfig,\n) {\n\treturn resolveWrapper<IOdspDriveItem[]>(\n\t\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\t\t(authRequestInfo) => getChildrenByDriveItem(folderDriveItem, server, authRequestInfo),\n\t\tserver,\n\t\tclientConfig,\n\t);\n}\n\nexport async function getSharepointFiles(\n\tserver: string,\n\tserverRelativePath: string,\n\trecurse: boolean,\n) {\n\tconst clientConfig = getMicrosoftConfiguration();\n\n\tconst fileInfo = await resolveDriveItemByServerRelativePath(\n\t\tserver,\n\t\tserverRelativePath,\n\t\tclientConfig,\n\t);\n\tconsole.log(fileInfo);\n\tconst pendingFolder: { path: string; folder: IOdspDriveItem }[] = [];\n\tconst files: IOdspDriveItem[] = [];\n\tif (fileInfo.isFolder) {\n\t\tpendingFolder.push({ path: serverRelativePath, folder: fileInfo });\n\t} else {\n\t\tfiles.push(fileInfo);\n\t}\n\n\t// eslint-disable-next-line no-constant-condition\n\twhile (true) {\n\t\tconst folderInfo = pendingFolder.shift();\n\t\tif (!folderInfo) {\n\t\t\tbreak;\n\t\t}\n\t\tconst { path, folder } = folderInfo;\n\t\tconst children = await resolveChildrenByDriveItem(server, folder, clientConfig);\n\t\tfor (const child of children) {\n\t\t\tconst childPath = `${path}/${child.name}`;\n\t\t\tif (child.isFolder) {\n\t\t\t\tif (recurse) {\n\t\t\t\t\tpendingFolder.push({ path: childPath, folder: child });\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfiles.push(child);\n\t\t\t}\n\t\t}\n\t}\n\treturn files;\n}\n\nexport async function getSingleSharePointFile(server: string, drive: string, item: string) {\n\tconst clientConfig = getMicrosoftConfiguration();\n\n\treturn resolveWrapper<IOdspDriveItem>(\n\t\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\t\t(authRequestInfo) => getDriveItemFromDriveAndItem(server, drive, item, authRequestInfo),\n\t\tserver,\n\t\tclientConfig,\n\t);\n}\n\nconst fluidFetchWebNavigator = (url: string) => {\n\tlet message = \"Please open browser and navigate to this URL:\";\n\tif (process.platform === \"win32\") {\n\t\tchild_process.exec(`start \"fluid-fetch\" /B \"${url}\"`);\n\t\tmessage =\n\t\t\t\"Opening browser to get authorization code. If that doesn't open, please go to this URL manually\";\n\t}\n\tconsole.log(`${message}\\n ${url}`);\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-tools/fetch-tool",
3
- "version": "2.0.0-rc.3.0.3",
3
+ "version": "2.0.0-rc.4.0.1",
4
4
  "description": "Console tool to fetch Fluid data from relay service",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -15,28 +15,28 @@
15
15
  "fluid-fetch": "bin/fluid-fetch"
16
16
  },
17
17
  "dependencies": {
18
- "@fluid-internal/client-utils": ">=2.0.0-rc.3.0.3 <2.0.0-rc.3.1.0",
19
- "@fluidframework/container-runtime": ">=2.0.0-rc.3.0.3 <2.0.0-rc.3.1.0",
20
- "@fluidframework/core-interfaces": ">=2.0.0-rc.3.0.3 <2.0.0-rc.3.1.0",
21
- "@fluidframework/core-utils": ">=2.0.0-rc.3.0.3 <2.0.0-rc.3.1.0",
22
- "@fluidframework/datastore": ">=2.0.0-rc.3.0.3 <2.0.0-rc.3.1.0",
23
- "@fluidframework/driver-definitions": ">=2.0.0-rc.3.0.3 <2.0.0-rc.3.1.0",
24
- "@fluidframework/odsp-doclib-utils": ">=2.0.0-rc.3.0.3 <2.0.0-rc.3.1.0",
25
- "@fluidframework/odsp-driver": ">=2.0.0-rc.3.0.3 <2.0.0-rc.3.1.0",
26
- "@fluidframework/odsp-driver-definitions": ">=2.0.0-rc.3.0.3 <2.0.0-rc.3.1.0",
27
- "@fluidframework/odsp-urlresolver": ">=2.0.0-rc.3.0.3 <2.0.0-rc.3.1.0",
18
+ "@fluid-internal/client-utils": ">=2.0.0-rc.4.0.1 <2.0.0-rc.4.1.0",
19
+ "@fluidframework/container-runtime": ">=2.0.0-rc.4.0.1 <2.0.0-rc.4.1.0",
20
+ "@fluidframework/core-interfaces": ">=2.0.0-rc.4.0.1 <2.0.0-rc.4.1.0",
21
+ "@fluidframework/core-utils": ">=2.0.0-rc.4.0.1 <2.0.0-rc.4.1.0",
22
+ "@fluidframework/datastore": ">=2.0.0-rc.4.0.1 <2.0.0-rc.4.1.0",
23
+ "@fluidframework/driver-definitions": ">=2.0.0-rc.4.0.1 <2.0.0-rc.4.1.0",
24
+ "@fluidframework/odsp-doclib-utils": ">=2.0.0-rc.4.0.1 <2.0.0-rc.4.1.0",
25
+ "@fluidframework/odsp-driver": ">=2.0.0-rc.4.0.1 <2.0.0-rc.4.1.0",
26
+ "@fluidframework/odsp-driver-definitions": ">=2.0.0-rc.4.0.1 <2.0.0-rc.4.1.0",
27
+ "@fluidframework/odsp-urlresolver": ">=2.0.0-rc.4.0.1 <2.0.0-rc.4.1.0",
28
28
  "@fluidframework/protocol-definitions": "^3.2.0",
29
- "@fluidframework/routerlicious-driver": ">=2.0.0-rc.3.0.3 <2.0.0-rc.3.1.0",
30
- "@fluidframework/routerlicious-urlresolver": ">=2.0.0-rc.3.0.3 <2.0.0-rc.3.1.0",
31
- "@fluidframework/runtime-definitions": ">=2.0.0-rc.3.0.3 <2.0.0-rc.3.1.0",
32
- "@fluidframework/tool-utils": ">=2.0.0-rc.3.0.3 <2.0.0-rc.3.1.0"
29
+ "@fluidframework/routerlicious-driver": ">=2.0.0-rc.4.0.1 <2.0.0-rc.4.1.0",
30
+ "@fluidframework/routerlicious-urlresolver": ">=2.0.0-rc.4.0.1 <2.0.0-rc.4.1.0",
31
+ "@fluidframework/runtime-definitions": ">=2.0.0-rc.4.0.1 <2.0.0-rc.4.1.0",
32
+ "@fluidframework/tool-utils": ">=2.0.0-rc.4.0.1 <2.0.0-rc.4.1.0"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@biomejs/biome": "^1.6.2",
36
- "@fluid-tools/build-cli": "^0.37.0",
37
- "@fluid-tools/fetch-tool-previous": "npm:@fluid-tools/fetch-tool@2.0.0-internal.8.0.0",
36
+ "@fluid-tools/build-cli": "^0.38.0",
37
+ "@fluid-tools/fetch-tool-previous": "npm:@fluid-tools/fetch-tool@2.0.0-rc.3.0.0",
38
38
  "@fluidframework/build-common": "^2.0.3",
39
- "@fluidframework/build-tools": "^0.37.0",
39
+ "@fluidframework/build-tools": "^0.38.0",
40
40
  "@fluidframework/eslint-config-fluid": "^5.1.0",
41
41
  "@types/node": "^18.19.0",
42
42
  "copyfiles": "^2.4.1",
@@ -5,7 +5,7 @@
5
5
 
6
6
  import child_process from "child_process";
7
7
 
8
- import { DriverErrorTypes } from "@fluidframework/driver-definitions";
8
+ import { DriverErrorTypes } from "@fluidframework/driver-definitions/internal";
9
9
  import {
10
10
  IClientConfig,
11
11
  IOdspAuthRequestInfo,