@microsoft/teamsfx-react 1.0.4-rc.0 → 2.0.0-beta.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 +4 -0
- package/LICENSE +21 -21
- package/NOTICE.txt +14833 -0
- package/build/index.d.ts +3 -3
- package/build/index.js +11 -11
- package/build/useData.d.ts +33 -33
- package/build/useData.js +45 -45
- package/build/useGraph.d.ts +18 -18
- package/build/useGraph.js +57 -57
- package/build/useTeamsFx.d.ts +41 -41
- package/build/useTeamsFx.js +30 -30
- package/package.json +10 -11
package/build/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { useData } from "./useData";
|
|
2
|
-
export { useTeamsFx, TeamsFxContext } from "./useTeamsFx";
|
|
3
|
-
export { useGraph } from "./useGraph";
|
|
1
|
+
export { useData } from "./useData";
|
|
2
|
+
export { useTeamsFx, TeamsFxContext } from "./useTeamsFx";
|
|
3
|
+
export { useGraph } from "./useGraph";
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright (c) Microsoft Corporation.
|
|
3
|
-
// Licensed under the MIT license.
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.useGraph = exports.useTeamsFx = exports.useData = void 0;
|
|
6
|
-
var useData_1 = require("./useData");
|
|
7
|
-
Object.defineProperty(exports, "useData", { enumerable: true, get: function () { return useData_1.useData; } });
|
|
8
|
-
var useTeamsFx_1 = require("./useTeamsFx");
|
|
9
|
-
Object.defineProperty(exports, "useTeamsFx", { enumerable: true, get: function () { return useTeamsFx_1.useTeamsFx; } });
|
|
10
|
-
var useGraph_1 = require("./useGraph");
|
|
11
|
-
Object.defineProperty(exports, "useGraph", { enumerable: true, get: function () { return useGraph_1.useGraph; } });
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT license.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.useGraph = exports.useTeamsFx = exports.useData = void 0;
|
|
6
|
+
var useData_1 = require("./useData");
|
|
7
|
+
Object.defineProperty(exports, "useData", { enumerable: true, get: function () { return useData_1.useData; } });
|
|
8
|
+
var useTeamsFx_1 = require("./useTeamsFx");
|
|
9
|
+
Object.defineProperty(exports, "useTeamsFx", { enumerable: true, get: function () { return useTeamsFx_1.useTeamsFx; } });
|
|
10
|
+
var useGraph_1 = require("./useGraph");
|
|
11
|
+
Object.defineProperty(exports, "useGraph", { enumerable: true, get: function () { return useGraph_1.useGraph; } });
|
package/build/useData.d.ts
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
declare type State<T> = {
|
|
2
|
-
/**
|
|
3
|
-
* User data.
|
|
4
|
-
*/
|
|
5
|
-
data?: T;
|
|
6
|
-
/**
|
|
7
|
-
* Status of data loading.
|
|
8
|
-
*/
|
|
9
|
-
loading: boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Error information.
|
|
12
|
-
*/
|
|
13
|
-
error?: unknown;
|
|
14
|
-
};
|
|
15
|
-
export declare type Data<T> = State<T> & {
|
|
16
|
-
/**
|
|
17
|
-
* reload function.
|
|
18
|
-
*/
|
|
19
|
-
reload: () => void;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Helper function to fetch data with status and error.
|
|
23
|
-
*
|
|
24
|
-
* @param fetchDataAsync - async function of how to fetch data
|
|
25
|
-
* @param options - if autoLoad is true, reload data immediately
|
|
26
|
-
* @returns data, loading status, error and reload function
|
|
27
|
-
*
|
|
28
|
-
* @beta
|
|
29
|
-
*/
|
|
30
|
-
export declare function useData<T>(fetchDataAsync: () => Promise<T>, options?: {
|
|
31
|
-
autoLoad: boolean;
|
|
32
|
-
}): Data<T>;
|
|
33
|
-
export {};
|
|
1
|
+
declare type State<T> = {
|
|
2
|
+
/**
|
|
3
|
+
* User data.
|
|
4
|
+
*/
|
|
5
|
+
data?: T;
|
|
6
|
+
/**
|
|
7
|
+
* Status of data loading.
|
|
8
|
+
*/
|
|
9
|
+
loading: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Error information.
|
|
12
|
+
*/
|
|
13
|
+
error?: unknown;
|
|
14
|
+
};
|
|
15
|
+
export declare type Data<T> = State<T> & {
|
|
16
|
+
/**
|
|
17
|
+
* reload function.
|
|
18
|
+
*/
|
|
19
|
+
reload: () => void;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Helper function to fetch data with status and error.
|
|
23
|
+
*
|
|
24
|
+
* @param fetchDataAsync - async function of how to fetch data
|
|
25
|
+
* @param options - if autoLoad is true, reload data immediately
|
|
26
|
+
* @returns data, loading status, error and reload function
|
|
27
|
+
*
|
|
28
|
+
* @beta
|
|
29
|
+
*/
|
|
30
|
+
export declare function useData<T>(fetchDataAsync: () => Promise<T>, options?: {
|
|
31
|
+
autoLoad: boolean;
|
|
32
|
+
}): Data<T>;
|
|
33
|
+
export {};
|
|
34
34
|
//# sourceMappingURL=useData.d.ts.map
|
package/build/useData.js
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright (c) Microsoft Corporation.
|
|
3
|
-
// Licensed under the MIT license.
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.useData = void 0;
|
|
6
|
-
const react_1 = require("react");
|
|
7
|
-
const createReducer = () => (state, action) => {
|
|
8
|
-
switch (action.type) {
|
|
9
|
-
case "loading":
|
|
10
|
-
return { data: state.data, loading: true };
|
|
11
|
-
case "result":
|
|
12
|
-
return { data: action.result, loading: false };
|
|
13
|
-
case "error":
|
|
14
|
-
return { loading: false, error: action.error };
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Helper function to fetch data with status and error.
|
|
19
|
-
*
|
|
20
|
-
* @param fetchDataAsync - async function of how to fetch data
|
|
21
|
-
* @param options - if autoLoad is true, reload data immediately
|
|
22
|
-
* @returns data, loading status, error and reload function
|
|
23
|
-
*
|
|
24
|
-
* @beta
|
|
25
|
-
*/
|
|
26
|
-
function useData(fetchDataAsync, options) {
|
|
27
|
-
var _a;
|
|
28
|
-
const auto = (_a = options === null || options === void 0 ? void 0 : options.autoLoad) !== null && _a !== void 0 ? _a : true;
|
|
29
|
-
const [{ data, loading, error }, dispatch] = (0, react_1.useReducer)(createReducer(), {
|
|
30
|
-
loading: auto,
|
|
31
|
-
});
|
|
32
|
-
function reload() {
|
|
33
|
-
if (!loading)
|
|
34
|
-
dispatch({ type: "loading" });
|
|
35
|
-
fetchDataAsync()
|
|
36
|
-
.then((data) => dispatch({ type: "result", result: data }))
|
|
37
|
-
.catch((error) => dispatch({ type: "error", error }));
|
|
38
|
-
}
|
|
39
|
-
(0, react_1.useEffect)(() => {
|
|
40
|
-
if (auto)
|
|
41
|
-
reload();
|
|
42
|
-
}, []);
|
|
43
|
-
return { data, loading, error, reload };
|
|
44
|
-
}
|
|
45
|
-
exports.useData = useData;
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT license.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.useData = void 0;
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const createReducer = () => (state, action) => {
|
|
8
|
+
switch (action.type) {
|
|
9
|
+
case "loading":
|
|
10
|
+
return { data: state.data, loading: true };
|
|
11
|
+
case "result":
|
|
12
|
+
return { data: action.result, loading: false };
|
|
13
|
+
case "error":
|
|
14
|
+
return { loading: false, error: action.error };
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Helper function to fetch data with status and error.
|
|
19
|
+
*
|
|
20
|
+
* @param fetchDataAsync - async function of how to fetch data
|
|
21
|
+
* @param options - if autoLoad is true, reload data immediately
|
|
22
|
+
* @returns data, loading status, error and reload function
|
|
23
|
+
*
|
|
24
|
+
* @beta
|
|
25
|
+
*/
|
|
26
|
+
function useData(fetchDataAsync, options) {
|
|
27
|
+
var _a;
|
|
28
|
+
const auto = (_a = options === null || options === void 0 ? void 0 : options.autoLoad) !== null && _a !== void 0 ? _a : true;
|
|
29
|
+
const [{ data, loading, error }, dispatch] = (0, react_1.useReducer)(createReducer(), {
|
|
30
|
+
loading: auto,
|
|
31
|
+
});
|
|
32
|
+
function reload() {
|
|
33
|
+
if (!loading)
|
|
34
|
+
dispatch({ type: "loading" });
|
|
35
|
+
fetchDataAsync()
|
|
36
|
+
.then((data) => dispatch({ type: "result", result: data }))
|
|
37
|
+
.catch((error) => dispatch({ type: "error", error }));
|
|
38
|
+
}
|
|
39
|
+
(0, react_1.useEffect)(() => {
|
|
40
|
+
if (auto)
|
|
41
|
+
reload();
|
|
42
|
+
}, []);
|
|
43
|
+
return { data, loading, error, reload };
|
|
44
|
+
}
|
|
45
|
+
exports.useData = useData;
|
package/build/useGraph.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { Data } from "./useData";
|
|
2
|
-
import { TeamsFx } from "@microsoft/teamsfx";
|
|
3
|
-
import { Client } from "@microsoft/microsoft-graph-client";
|
|
4
|
-
declare type GraphOption = {
|
|
5
|
-
scope?: string[];
|
|
6
|
-
teamsfx?: TeamsFx;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Helper function to call Microsoft Graph API with authentication.
|
|
10
|
-
*
|
|
11
|
-
* @param fetchGraphDataAsync - async function of how to call Graph API and fetch data.
|
|
12
|
-
* @param options - teamsfx instance and OAuth resource scope.
|
|
13
|
-
* @returns data, loading status, error and reload function
|
|
14
|
-
*
|
|
15
|
-
* @beta
|
|
16
|
-
*/
|
|
17
|
-
export declare function useGraph<T>(fetchGraphDataAsync: (graph: Client, teamsfx: TeamsFx, scope: string[]) => Promise<T>, options?: GraphOption): Data<T>;
|
|
18
|
-
export {};
|
|
1
|
+
import { Data } from "./useData";
|
|
2
|
+
import { TeamsFx } from "@microsoft/teamsfx";
|
|
3
|
+
import { Client } from "@microsoft/microsoft-graph-client";
|
|
4
|
+
declare type GraphOption = {
|
|
5
|
+
scope?: string[];
|
|
6
|
+
teamsfx?: TeamsFx;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Helper function to call Microsoft Graph API with authentication.
|
|
10
|
+
*
|
|
11
|
+
* @param fetchGraphDataAsync - async function of how to call Graph API and fetch data.
|
|
12
|
+
* @param options - teamsfx instance and OAuth resource scope.
|
|
13
|
+
* @returns data, loading status, error and reload function
|
|
14
|
+
*
|
|
15
|
+
* @beta
|
|
16
|
+
*/
|
|
17
|
+
export declare function useGraph<T>(fetchGraphDataAsync: (graph: Client, teamsfx: TeamsFx, scope: string[]) => Promise<T>, options?: GraphOption): Data<T>;
|
|
18
|
+
export {};
|
|
19
19
|
//# sourceMappingURL=useGraph.d.ts.map
|
package/build/useGraph.js
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright (c) Microsoft Corporation.
|
|
3
|
-
// Licensed under the MIT license.
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.useGraph = void 0;
|
|
6
|
-
const useData_1 = require("./useData");
|
|
7
|
-
const teamsfx_1 = require("@microsoft/teamsfx");
|
|
8
|
-
const microsoft_graph_client_1 = require("@microsoft/microsoft-graph-client");
|
|
9
|
-
const react_1 = require("react");
|
|
10
|
-
/**
|
|
11
|
-
* Helper function to call Microsoft Graph API with authentication.
|
|
12
|
-
*
|
|
13
|
-
* @param fetchGraphDataAsync - async function of how to call Graph API and fetch data.
|
|
14
|
-
* @param options - teamsfx instance and OAuth resource scope.
|
|
15
|
-
* @returns data, loading status, error and reload function
|
|
16
|
-
*
|
|
17
|
-
* @beta
|
|
18
|
-
*/
|
|
19
|
-
function useGraph(fetchGraphDataAsync, options) {
|
|
20
|
-
const { scope, teamsfx } = Object.assign({ scope: ["User.Read"], teamsfx: new teamsfx_1.TeamsFx() }, options);
|
|
21
|
-
const [needConsent, setNeedConsent] = (0, react_1.useState)(false);
|
|
22
|
-
const { data, error, loading, reload } = (0, useData_1.useData)(async () => {
|
|
23
|
-
var _a, _b;
|
|
24
|
-
if (needConsent) {
|
|
25
|
-
try {
|
|
26
|
-
await teamsfx.login(scope);
|
|
27
|
-
// Important: tokens are stored in sessionStorage, read more here: https://aka.ms/teamsfx-session-storage-notice
|
|
28
|
-
}
|
|
29
|
-
catch (err) {
|
|
30
|
-
if (err instanceof teamsfx_1.ErrorWithCode && ((_a = err.message) === null || _a === void 0 ? void 0 : _a.includes("CancelledByUser"))) {
|
|
31
|
-
const helpLink = "https://aka.ms/teamsfx-auth-code-flow";
|
|
32
|
-
err.message +=
|
|
33
|
-
'\nIf you see "AADSTS50011: The reply URL specified in the request does not match the reply URLs configured for the application" ' +
|
|
34
|
-
"in the popup window, you may be using unmatched version for TeamsFx SDK (version >= 0.5.0) and Teams Toolkit (version < 3.3.0) or " +
|
|
35
|
-
`cli (version < 0.11.0). Please refer to the help link for how to fix the issue: ${helpLink}`;
|
|
36
|
-
}
|
|
37
|
-
throw err;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
try {
|
|
41
|
-
const graph = (0, teamsfx_1.createMicrosoftGraphClient)(teamsfx, scope);
|
|
42
|
-
const graphData = await fetchGraphDataAsync(graph, teamsfx, scope);
|
|
43
|
-
return graphData;
|
|
44
|
-
}
|
|
45
|
-
catch (err) {
|
|
46
|
-
if (err instanceof microsoft_graph_client_1.GraphError && ((_b = err.code) === null || _b === void 0 ? void 0 : _b.includes("UiRequiredError"))) {
|
|
47
|
-
// Silently fail for user didn't consent error
|
|
48
|
-
setNeedConsent(true);
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
throw err;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
return { data, error, loading, reload };
|
|
56
|
-
}
|
|
57
|
-
exports.useGraph = useGraph;
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT license.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.useGraph = void 0;
|
|
6
|
+
const useData_1 = require("./useData");
|
|
7
|
+
const teamsfx_1 = require("@microsoft/teamsfx");
|
|
8
|
+
const microsoft_graph_client_1 = require("@microsoft/microsoft-graph-client");
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
/**
|
|
11
|
+
* Helper function to call Microsoft Graph API with authentication.
|
|
12
|
+
*
|
|
13
|
+
* @param fetchGraphDataAsync - async function of how to call Graph API and fetch data.
|
|
14
|
+
* @param options - teamsfx instance and OAuth resource scope.
|
|
15
|
+
* @returns data, loading status, error and reload function
|
|
16
|
+
*
|
|
17
|
+
* @beta
|
|
18
|
+
*/
|
|
19
|
+
function useGraph(fetchGraphDataAsync, options) {
|
|
20
|
+
const { scope, teamsfx } = Object.assign({ scope: ["User.Read"], teamsfx: new teamsfx_1.TeamsFx() }, options);
|
|
21
|
+
const [needConsent, setNeedConsent] = (0, react_1.useState)(false);
|
|
22
|
+
const { data, error, loading, reload } = (0, useData_1.useData)(async () => {
|
|
23
|
+
var _a, _b;
|
|
24
|
+
if (needConsent) {
|
|
25
|
+
try {
|
|
26
|
+
await teamsfx.login(scope);
|
|
27
|
+
// Important: tokens are stored in sessionStorage, read more here: https://aka.ms/teamsfx-session-storage-notice
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
if (err instanceof teamsfx_1.ErrorWithCode && ((_a = err.message) === null || _a === void 0 ? void 0 : _a.includes("CancelledByUser"))) {
|
|
31
|
+
const helpLink = "https://aka.ms/teamsfx-auth-code-flow";
|
|
32
|
+
err.message +=
|
|
33
|
+
'\nIf you see "AADSTS50011: The reply URL specified in the request does not match the reply URLs configured for the application" ' +
|
|
34
|
+
"in the popup window, you may be using unmatched version for TeamsFx SDK (version >= 0.5.0) and Teams Toolkit (version < 3.3.0) or " +
|
|
35
|
+
`cli (version < 0.11.0). Please refer to the help link for how to fix the issue: ${helpLink}`;
|
|
36
|
+
}
|
|
37
|
+
throw err;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
const graph = (0, teamsfx_1.createMicrosoftGraphClient)(teamsfx, scope);
|
|
42
|
+
const graphData = await fetchGraphDataAsync(graph, teamsfx, scope);
|
|
43
|
+
return graphData;
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
if (err instanceof microsoft_graph_client_1.GraphError && ((_b = err.code) === null || _b === void 0 ? void 0 : _b.includes("UiRequiredError"))) {
|
|
47
|
+
// Silently fail for user didn't consent error
|
|
48
|
+
setNeedConsent(true);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
throw err;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return { data, error, loading, reload };
|
|
56
|
+
}
|
|
57
|
+
exports.useGraph = useGraph;
|
package/build/useTeamsFx.d.ts
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import { TeamsFx } from "@microsoft/teamsfx";
|
|
2
|
-
import { ThemePrepared } from "@fluentui/react-northstar";
|
|
3
|
-
export declare type TeamsFxContext = {
|
|
4
|
-
/**
|
|
5
|
-
* Instance of TeamsFx.
|
|
6
|
-
*/
|
|
7
|
-
teamsfx?: TeamsFx;
|
|
8
|
-
/**
|
|
9
|
-
* Status of data loading.
|
|
10
|
-
*/
|
|
11
|
-
loading: boolean;
|
|
12
|
-
/**
|
|
13
|
-
* Error information.
|
|
14
|
-
*/
|
|
15
|
-
error: unknown;
|
|
16
|
-
/**
|
|
17
|
-
* Indicates that current environment is in Teams
|
|
18
|
-
*/
|
|
19
|
-
inTeams?: boolean;
|
|
20
|
-
/**
|
|
21
|
-
* Teams theme.
|
|
22
|
-
*/
|
|
23
|
-
theme: ThemePrepared;
|
|
24
|
-
/**
|
|
25
|
-
* Teams theme string.
|
|
26
|
-
*/
|
|
27
|
-
themeString: string;
|
|
28
|
-
/**
|
|
29
|
-
* Teams context object.
|
|
30
|
-
*/
|
|
31
|
-
context?: any;
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* Initialize TeamsFx SDK with customized configuration.
|
|
35
|
-
*
|
|
36
|
-
* @param teamsfxConfig - custom configuration to override default ones.
|
|
37
|
-
* @returns TeamsFxContext object
|
|
38
|
-
*
|
|
39
|
-
* @beta
|
|
40
|
-
*/
|
|
41
|
-
export declare function useTeamsFx(teamsfxConfig?: Record<string, string>): TeamsFxContext;
|
|
1
|
+
import { TeamsFx } from "@microsoft/teamsfx";
|
|
2
|
+
import { ThemePrepared } from "@fluentui/react-northstar";
|
|
3
|
+
export declare type TeamsFxContext = {
|
|
4
|
+
/**
|
|
5
|
+
* Instance of TeamsFx.
|
|
6
|
+
*/
|
|
7
|
+
teamsfx?: TeamsFx;
|
|
8
|
+
/**
|
|
9
|
+
* Status of data loading.
|
|
10
|
+
*/
|
|
11
|
+
loading: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Error information.
|
|
14
|
+
*/
|
|
15
|
+
error: unknown;
|
|
16
|
+
/**
|
|
17
|
+
* Indicates that current environment is in Teams
|
|
18
|
+
*/
|
|
19
|
+
inTeams?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Teams theme.
|
|
22
|
+
*/
|
|
23
|
+
theme: ThemePrepared;
|
|
24
|
+
/**
|
|
25
|
+
* Teams theme string.
|
|
26
|
+
*/
|
|
27
|
+
themeString: string;
|
|
28
|
+
/**
|
|
29
|
+
* Teams context object.
|
|
30
|
+
*/
|
|
31
|
+
context?: any;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Initialize TeamsFx SDK with customized configuration.
|
|
35
|
+
*
|
|
36
|
+
* @param teamsfxConfig - custom configuration to override default ones.
|
|
37
|
+
* @returns TeamsFxContext object
|
|
38
|
+
*
|
|
39
|
+
* @beta
|
|
40
|
+
*/
|
|
41
|
+
export declare function useTeamsFx(teamsfxConfig?: Record<string, string>): TeamsFxContext;
|
|
42
42
|
//# sourceMappingURL=useTeamsFx.d.ts.map
|
package/build/useTeamsFx.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright (c) Microsoft Corporation.
|
|
3
|
-
// Licensed under the MIT license.
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.useTeamsFx = void 0;
|
|
6
|
-
const teamsfx_1 = require("@microsoft/teamsfx");
|
|
7
|
-
const msteams_react_base_component_1 = require("msteams-react-base-component");
|
|
8
|
-
const useData_1 = require("./useData");
|
|
9
|
-
/**
|
|
10
|
-
* Initialize TeamsFx SDK with customized configuration.
|
|
11
|
-
*
|
|
12
|
-
* @param teamsfxConfig - custom configuration to override default ones.
|
|
13
|
-
* @returns TeamsFxContext object
|
|
14
|
-
*
|
|
15
|
-
* @beta
|
|
16
|
-
*/
|
|
17
|
-
function useTeamsFx(teamsfxConfig) {
|
|
18
|
-
const [result] = (0, msteams_react_base_component_1.useTeams)({});
|
|
19
|
-
const { data, error, loading } = (0, useData_1.useData)(async () => {
|
|
20
|
-
if (process.env.NODE_ENV === "development") {
|
|
21
|
-
(0, teamsfx_1.setLogLevel)(teamsfx_1.LogLevel.Verbose);
|
|
22
|
-
(0, teamsfx_1.setLogFunction)((level, message) => {
|
|
23
|
-
console.log(message);
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
return new teamsfx_1.TeamsFx(teamsfx_1.IdentityType.User, teamsfxConfig);
|
|
27
|
-
});
|
|
28
|
-
return Object.assign({ teamsfx: data, error, loading }, result);
|
|
29
|
-
}
|
|
30
|
-
exports.useTeamsFx = useTeamsFx;
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT license.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.useTeamsFx = void 0;
|
|
6
|
+
const teamsfx_1 = require("@microsoft/teamsfx");
|
|
7
|
+
const msteams_react_base_component_1 = require("msteams-react-base-component");
|
|
8
|
+
const useData_1 = require("./useData");
|
|
9
|
+
/**
|
|
10
|
+
* Initialize TeamsFx SDK with customized configuration.
|
|
11
|
+
*
|
|
12
|
+
* @param teamsfxConfig - custom configuration to override default ones.
|
|
13
|
+
* @returns TeamsFxContext object
|
|
14
|
+
*
|
|
15
|
+
* @beta
|
|
16
|
+
*/
|
|
17
|
+
function useTeamsFx(teamsfxConfig) {
|
|
18
|
+
const [result] = (0, msteams_react_base_component_1.useTeams)({});
|
|
19
|
+
const { data, error, loading } = (0, useData_1.useData)(async () => {
|
|
20
|
+
if (process.env.NODE_ENV === "development") {
|
|
21
|
+
(0, teamsfx_1.setLogLevel)(teamsfx_1.LogLevel.Verbose);
|
|
22
|
+
(0, teamsfx_1.setLogFunction)((level, message) => {
|
|
23
|
+
console.log(message);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return new teamsfx_1.TeamsFx(teamsfx_1.IdentityType.User, teamsfxConfig);
|
|
27
|
+
});
|
|
28
|
+
return Object.assign({ teamsfx: data, error, loading }, result);
|
|
29
|
+
}
|
|
30
|
+
exports.useTeamsFx = useTeamsFx;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/teamsfx-react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-beta.1",
|
|
4
4
|
"description": "React helper functions for Microsoft TeamsFx",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -19,18 +19,18 @@
|
|
|
19
19
|
"lint:staged": "lint-staged",
|
|
20
20
|
"lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
21
21
|
"test": "npm run test:unit",
|
|
22
|
-
"test:unit": "nyc mocha --no-timeouts --require init.js --require ts-node/register test/**/*.test.ts
|
|
22
|
+
"test:unit": "nyc mocha --no-timeouts --require init.js --require ts-node/register test/**/*.test.ts",
|
|
23
23
|
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
|
|
24
24
|
"format-check": "prettier --list-different \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
|
|
25
25
|
"check-sensitive": "npx eslint --plugin 'no-secrets' --cache --ignore-pattern 'package.json' --ignore-pattern 'package-lock.json'",
|
|
26
26
|
"precommit": "npm run check-sensitive && lint-staged"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@fluentui/react-northstar": "^0.
|
|
29
|
+
"@fluentui/react-northstar": "^0.62.0",
|
|
30
30
|
"@istanbuljs/nyc-config-typescript": "^1.0.2",
|
|
31
31
|
"@microsoft/microsoft-graph-client": "^3.0.1",
|
|
32
|
-
"@microsoft/teams-js": "^
|
|
33
|
-
"@microsoft/teamsfx": "
|
|
32
|
+
"@microsoft/teams-js": "^2.2.0",
|
|
33
|
+
"@microsoft/teamsfx": "2.0.0-beta.0",
|
|
34
34
|
"@testing-library/react-hooks": "^7.0.2",
|
|
35
35
|
"@types/chai": "^4.3.0",
|
|
36
36
|
"@types/mocha": "^9.1.0",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"isomorphic-fetch": "^3.0.0",
|
|
48
48
|
"lint-staged": "^12.3.4",
|
|
49
49
|
"mocha": "^9.2.1",
|
|
50
|
-
"msteams-react-base-component": "^
|
|
50
|
+
"msteams-react-base-component": "^4.0.1",
|
|
51
51
|
"nyc": "^15.1.0",
|
|
52
52
|
"prettier": "^2.5.1",
|
|
53
53
|
"react": "^16.9.0",
|
|
@@ -57,10 +57,10 @@
|
|
|
57
57
|
"sinon": "^13.0.1"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"@fluentui/react-northstar": "^0.
|
|
60
|
+
"@fluentui/react-northstar": "^0.62.0",
|
|
61
61
|
"@microsoft/microsoft-graph-client": "^3.0.1",
|
|
62
|
-
"@microsoft/teamsfx": "
|
|
63
|
-
"msteams-react-base-component": "
|
|
62
|
+
"@microsoft/teamsfx": "2.0.0-beta.0",
|
|
63
|
+
"msteams-react-base-component": "4.0.1",
|
|
64
64
|
"react": "^16.8.6"
|
|
65
65
|
},
|
|
66
66
|
"publishConfig": {
|
|
@@ -70,6 +70,5 @@
|
|
|
70
70
|
"*.{js,jsx,css,ts,tsx}": [
|
|
71
71
|
"npx eslint --cache --fix --quiet"
|
|
72
72
|
]
|
|
73
|
-
}
|
|
74
|
-
"gitHead": "9c0b3bc030a4cbc070b45d4dae186c097bb9b98e"
|
|
73
|
+
}
|
|
75
74
|
}
|