UNPKG

@cognigy/rest-api-client

Version:

Cognigy REST-Client

49 lines 2.02 kB
import { __awaiter } from "tslib"; /* Custom modules */ import { createNodeDescriptor } from "../../../createNodeDescriptor"; import { nodeColor } from "../utils/design"; /** * Node name: 'teamsPermissions' * * Purpose: * divide the flow into granted and not granted requests */ export const microsoftTokenStatusNode = createNodeDescriptor({ type: "microsoftTokenStatus", defaultLabel: "Token Status", summary: "UI__NODE_EDITOR__MICROSOFT__TOKEN_STATUS__SUMMARY", appearance: { showIcon: true, color: nodeColor, }, fields: [], sections: [], tags: ["microsoft"], dependencies: { children: ["microsoftTokenGranted", "microsoftTokenNotGranted"] }, function: ({ cognigy, childConfigs }) => __awaiter(void 0, void 0, void 0, function* () { const { api, input } = cognigy; const tokenGrantedChild = childConfigs === null || childConfigs === void 0 ? void 0 : childConfigs.find((child) => child.type === "microsoftTokenGranted"); const tokenNotGrantedChild = childConfigs === null || childConfigs === void 0 ? void 0 : childConfigs.find((child) => child.type === "microsoftTokenNotGranted"); /** Permissions not requested */ if (!input.data.microsoftSsoPermissionRequest) { api.setNextNode(tokenNotGrantedChild.id); /** Permissions granted and token valid */ } else if (input.data.microsoftSsoPermissionRequest === "completed" && input.data.microsoftSsoToken !== null) { api.setNextNode(tokenGrantedChild.id); /** Token expired or Logged out */ } else if (input.data.microsoftSsoPermissionRequest === "completed" && input.data.microsoftSsoToken === null) { api.setNextNode(tokenNotGrantedChild.id); /** Permissions not yet accepted or declined */ } else { api.setNextNode(tokenNotGrantedChild.id); } }), }); //# sourceMappingURL=index.js.map