@teambit/cloud 0.0.390 → 0.0.391
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/cloud.ui.runtime.tsx +127 -0
- package/cloud.ui.styles.scss +0 -0
- package/dist/cloud.aspect.d.ts +1 -0
- package/dist/cloud.aspect.js +2 -1
- package/dist/cloud.aspect.js.map +1 -1
- package/dist/cloud.graphql.d.ts +3 -0
- package/dist/cloud.graphql.js +83 -0
- package/dist/cloud.graphql.js.map +1 -0
- package/dist/cloud.main.runtime.d.ts +82 -4
- package/dist/cloud.main.runtime.js +449 -9
- package/dist/cloud.main.runtime.js.map +1 -1
- package/dist/cloud.ui.runtime.d.ts +28 -0
- package/dist/cloud.ui.runtime.js +167 -0
- package/dist/cloud.ui.runtime.js.map +1 -0
- package/dist/cloud.ui.styles.scss +0 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js.map +1 -1
- package/dist/login.cmd.d.ts +33 -0
- package/dist/login.cmd.js +69 -0
- package/dist/login.cmd.js.map +1 -0
- package/dist/logout.cmd.d.ts +17 -0
- package/dist/logout.cmd.js +42 -0
- package/dist/logout.cmd.js.map +1 -0
- package/dist/whoami.cmd.d.ts +17 -0
- package/dist/whoami.cmd.js +46 -0
- package/dist/whoami.cmd.js.map +1 -0
- package/package.json +27 -3
- /package/dist/{preview-1703733956734.js → preview-1704079387779.js} +0 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { UIRuntime } from '@teambit/ui';
|
|
3
|
+
import { flatten } from 'lodash';
|
|
4
|
+
import { SubMenu } from '@teambit/design.controls.menu';
|
|
5
|
+
import { Slot } from '@teambit/harmony';
|
|
6
|
+
import { UserBar, UserBarItem, UserBarItemSlot, UserBarSection, UserBarSectionSlot } from '@teambit/cloud.ui.user-bar';
|
|
7
|
+
import WorkspaceAspect, { WorkspaceUI } from '@teambit/workspace';
|
|
8
|
+
import { CloudAspect } from './cloud.aspect';
|
|
9
|
+
|
|
10
|
+
export class CloudUI {
|
|
11
|
+
constructor(private userBarSectionSlot: UserBarSectionSlot, private userBarItemSlot: UserBarItemSlot) {}
|
|
12
|
+
/**
|
|
13
|
+
* register a new user bar item.
|
|
14
|
+
*/
|
|
15
|
+
registerUserBarItem(userBarItem: UserBarItem[]) {
|
|
16
|
+
this.userBarItemSlot.register(userBarItem);
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* register a new user bar section
|
|
22
|
+
*/
|
|
23
|
+
registerUserBarSection(sections: UserBarSection[]) {
|
|
24
|
+
this.userBarSectionSlot.register(sections);
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* list user bar items.
|
|
30
|
+
*/
|
|
31
|
+
listUserBarItems() {
|
|
32
|
+
return flatten(this.userBarItemSlot.values());
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* list all user bar sections.
|
|
37
|
+
*/
|
|
38
|
+
listUserBarSections() {
|
|
39
|
+
return flatten(this.userBarSectionSlot.values());
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
static runtime = UIRuntime;
|
|
43
|
+
|
|
44
|
+
static dependencies = [WorkspaceAspect];
|
|
45
|
+
|
|
46
|
+
static slots = [Slot.withType<UserBarItem[]>(), Slot.withType<UserBarSection[]>()];
|
|
47
|
+
|
|
48
|
+
static async provider(
|
|
49
|
+
[workspace]: [WorkspaceUI],
|
|
50
|
+
_,
|
|
51
|
+
[userBarItemSlot, userBarSectionSlot]: [UserBarItemSlot, UserBarSectionSlot]
|
|
52
|
+
) {
|
|
53
|
+
const cloudUI = new CloudUI(userBarSectionSlot, userBarItemSlot);
|
|
54
|
+
|
|
55
|
+
cloudUI.registerUserBarSection([
|
|
56
|
+
{
|
|
57
|
+
displayName: 'Scopes & Components',
|
|
58
|
+
categoryName: 'ScopesAndComponents',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
displayName: 'Docs, Support & Feedback',
|
|
62
|
+
categoryName: 'DocsSupportAndFeedback',
|
|
63
|
+
},
|
|
64
|
+
]);
|
|
65
|
+
cloudUI.registerUserBarItem([
|
|
66
|
+
{
|
|
67
|
+
icon: 'settings',
|
|
68
|
+
label: 'Settings',
|
|
69
|
+
href: 'https://bit.cloud/settings',
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
category: 'ScopesAndComponents',
|
|
73
|
+
icon: 'components',
|
|
74
|
+
label: 'Your components',
|
|
75
|
+
href: 'https://bit.cloud/components',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
category: 'ScopesAndComponents',
|
|
79
|
+
icon: 'collection',
|
|
80
|
+
label: 'Your scopes',
|
|
81
|
+
href: 'https://bit.cloud/scopes',
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
category: 'DocsSupportAndFeedback',
|
|
85
|
+
icon: 'book-glossary',
|
|
86
|
+
label: 'Bit Docs',
|
|
87
|
+
href: 'https://bit.dev/docs',
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
category: 'DocsSupportAndFeedback',
|
|
91
|
+
component: function Support() {
|
|
92
|
+
return (
|
|
93
|
+
<SubMenu
|
|
94
|
+
item={{
|
|
95
|
+
label: 'Support',
|
|
96
|
+
icon: 'users',
|
|
97
|
+
children: [
|
|
98
|
+
{
|
|
99
|
+
label: 'Bit Community on bit.cloud',
|
|
100
|
+
link: 'https://bit.cloud/bitdev',
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
label: 'Ticket Support',
|
|
104
|
+
link: 'https://support.bit.cloud',
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
label: 'Bit Community Slack',
|
|
108
|
+
link: 'https://join.slack.com/t/bit-dev-community/shared_invite/zt-29pmawrp1-ehfEzYbQyuAC3CNA_jYPvA',
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
}}
|
|
112
|
+
/>
|
|
113
|
+
);
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
]);
|
|
117
|
+
const userBarItems = cloudUI.listUserBarItems();
|
|
118
|
+
const userBarSections = cloudUI.listUserBarSections();
|
|
119
|
+
const CloudUserBar = () => <UserBar sections={userBarSections} items={userBarItems} />;
|
|
120
|
+
workspace.registerMenuWidget([CloudUserBar]);
|
|
121
|
+
return cloudUI;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export default CloudUI;
|
|
126
|
+
|
|
127
|
+
CloudAspect.addRuntime(CloudUI);
|
|
File without changes
|
package/dist/cloud.aspect.d.ts
CHANGED
package/dist/cloud.aspect.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.CloudAspect = void 0;
|
|
6
|
+
exports.default = exports.CloudAspect = void 0;
|
|
7
7
|
function _harmony() {
|
|
8
8
|
const data = require("@teambit/harmony");
|
|
9
9
|
_harmony = function () {
|
|
@@ -14,5 +14,6 @@ function _harmony() {
|
|
|
14
14
|
const CloudAspect = exports.CloudAspect = _harmony().Aspect.create({
|
|
15
15
|
id: 'teambit.cloud/cloud'
|
|
16
16
|
});
|
|
17
|
+
var _default = exports.default = CloudAspect;
|
|
17
18
|
|
|
18
19
|
//# sourceMappingURL=cloud.aspect.js.map
|
package/dist/cloud.aspect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_harmony","data","require","CloudAspect","exports","Aspect","create","id"],"sources":["cloud.aspect.ts"],"sourcesContent":["import { Aspect } from '@teambit/harmony';\n\nexport const CloudAspect = Aspect.create({\n id: 'teambit.cloud/cloud',\n});\n"],"mappings":";;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEO,MAAME,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAGE,iBAAM,CAACC,MAAM,CAAC;EACvCC,EAAE,EAAE;AACN,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"names":["_harmony","data","require","CloudAspect","exports","Aspect","create","id","_default","default"],"sources":["cloud.aspect.ts"],"sourcesContent":["import { Aspect } from '@teambit/harmony';\n\nexport const CloudAspect = Aspect.create({\n id: 'teambit.cloud/cloud',\n});\n\nexport default CloudAspect;\n"],"mappings":";;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEO,MAAME,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAGE,iBAAM,CAACC,MAAM,CAAC;EACvCC,EAAE,EAAE;AACN,CAAC,CAAC;AAAC,IAAAC,QAAA,GAAAJ,OAAA,CAAAK,OAAA,GAEYN,WAAW"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.cloudSchema = cloudSchema;
|
|
7
|
+
function _graphqlTag() {
|
|
8
|
+
const data = _interopRequireDefault(require("graphql-tag"));
|
|
9
|
+
_graphqlTag = function () {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
16
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
17
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
18
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
19
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
20
|
+
function cloudSchema(cloud) {
|
|
21
|
+
return {
|
|
22
|
+
typeDefs: (0, _graphqlTag().default)`
|
|
23
|
+
type CloudScope {
|
|
24
|
+
id: String!
|
|
25
|
+
icon: String
|
|
26
|
+
backgroundIconColor: String
|
|
27
|
+
stripColor: String
|
|
28
|
+
displayName: String
|
|
29
|
+
}
|
|
30
|
+
type CloudUser {
|
|
31
|
+
displayName: String
|
|
32
|
+
username: String
|
|
33
|
+
profileImage: String
|
|
34
|
+
}
|
|
35
|
+
type Query {
|
|
36
|
+
getCurrentUser: CloudUser
|
|
37
|
+
loginUrl(redirectUrl: String!): String!
|
|
38
|
+
getCloudScopes(ids: [String!]): [CloudScope!]
|
|
39
|
+
isLoggedIn: Boolean
|
|
40
|
+
}
|
|
41
|
+
type Mutation {
|
|
42
|
+
logout: Boolean
|
|
43
|
+
}
|
|
44
|
+
`,
|
|
45
|
+
resolvers: {
|
|
46
|
+
CloudScope: {
|
|
47
|
+
id: scope => {
|
|
48
|
+
return scope?.id.toString();
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
Query: {
|
|
52
|
+
isLoggedIn: () => {
|
|
53
|
+
return cloud.isLoggedIn();
|
|
54
|
+
},
|
|
55
|
+
loginUrl: (_, {
|
|
56
|
+
redirectUrl
|
|
57
|
+
}) => {
|
|
58
|
+
return cloud.getLoginUrl({
|
|
59
|
+
redirectUrl
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
getCurrentUser: async () => {
|
|
63
|
+
const user = await cloud.getCurrentUser();
|
|
64
|
+
return _objectSpread({}, user);
|
|
65
|
+
},
|
|
66
|
+
getCloudScopes: async (_, {
|
|
67
|
+
ids
|
|
68
|
+
}) => {
|
|
69
|
+
const scopes = await cloud.getCloudScopes(ids);
|
|
70
|
+
return scopes;
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
Mutation: {
|
|
74
|
+
logout: async () => {
|
|
75
|
+
cloud.logout();
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
//# sourceMappingURL=cloud.graphql.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_graphqlTag","data","_interopRequireDefault","require","obj","__esModule","default","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","key","value","_toPropertyKey","configurable","writable","i","_toPrimitive","String","Symbol","toPrimitive","call","TypeError","Number","cloudSchema","cloud","typeDefs","gql","resolvers","CloudScope","id","scope","toString","Query","isLoggedIn","loginUrl","_","redirectUrl","getLoginUrl","getCurrentUser","user","getCloudScopes","ids","scopes","Mutation","logout"],"sources":["cloud.graphql.ts"],"sourcesContent":["import gql from 'graphql-tag';\nimport { Schema } from '@teambit/graphql';\nimport { ScopeDescriptor } from '@teambit/scopes.scope-descriptor';\nimport { CloudMain } from './cloud.main.runtime';\n\nexport function cloudSchema(cloud: CloudMain): Schema {\n return {\n typeDefs: gql`\n type CloudScope {\n id: String!\n icon: String\n backgroundIconColor: String\n stripColor: String\n displayName: String\n }\n type CloudUser {\n displayName: String\n username: String\n profileImage: String\n }\n type Query {\n getCurrentUser: CloudUser\n loginUrl(redirectUrl: String!): String!\n getCloudScopes(ids: [String!]): [CloudScope!]\n isLoggedIn: Boolean\n }\n type Mutation {\n logout: Boolean\n }\n `,\n resolvers: {\n CloudScope: {\n id: (scope?: ScopeDescriptor) => {\n return scope?.id.toString();\n },\n },\n Query: {\n isLoggedIn: () => {\n return cloud.isLoggedIn();\n },\n loginUrl: (_, { redirectUrl }: { redirectUrl?: string }) => {\n return cloud.getLoginUrl({ redirectUrl });\n },\n getCurrentUser: async () => {\n const user = await cloud.getCurrentUser();\n return {\n ...user,\n };\n },\n getCloudScopes: async (_, { ids }) => {\n const scopes = await cloud.getCloudScopes(ids);\n return scopes;\n },\n },\n Mutation: {\n logout: async () => {\n cloud.logout();\n return true;\n },\n },\n },\n };\n}\n"],"mappings":";;;;;;AAAA,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,WAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA8B,SAAAC,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,GAAAC,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAN,CAAA,WAAAE,MAAA,CAAAK,wBAAA,CAAAR,CAAA,EAAAC,CAAA,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,CAAC,CAAC;UACd,OAAO,IAAI;QACb;MACF;IACF;EACF,CAAC;AACH"}
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { SlotRegistry } from '@teambit/harmony';
|
|
3
|
+
import { CLIMain } from '@teambit/cli';
|
|
4
|
+
import * as http from 'http';
|
|
5
|
+
import { Express } from 'express';
|
|
6
|
+
import { CloudUser } from '@teambit/cloud.models.cloud-user';
|
|
7
|
+
import { ScopeDescriptor } from '@teambit/scopes.scope-descriptor';
|
|
8
|
+
import { Logger, LoggerMain } from '@teambit/logger';
|
|
9
|
+
import { ScopeMain } from '@teambit/scope';
|
|
10
|
+
import { GraphqlMain } from '@teambit/graphql';
|
|
11
|
+
import { Workspace } from '@teambit/workspace';
|
|
12
|
+
import { ExpressMain } from '@teambit/express';
|
|
13
|
+
import { GlobalConfigMain } from '@teambit/global-config';
|
|
14
|
+
import { UiMain } from '@teambit/ui';
|
|
1
15
|
export interface CloudWorkspaceConfig {
|
|
2
16
|
cloudDomain: string;
|
|
3
17
|
cloudHubDomain: string;
|
|
@@ -8,10 +22,40 @@ export interface CloudWorkspaceConfig {
|
|
|
8
22
|
registryUrl: string;
|
|
9
23
|
cloudExporterUrl: string;
|
|
10
24
|
cloudHubName: string;
|
|
25
|
+
loginPort?: number;
|
|
11
26
|
}
|
|
27
|
+
type CloudAuthListener = {
|
|
28
|
+
port: number;
|
|
29
|
+
server?: http.Server;
|
|
30
|
+
username?: string | null;
|
|
31
|
+
clientId?: string;
|
|
32
|
+
expressApp?: Express | null;
|
|
33
|
+
};
|
|
34
|
+
export type OnSuccessLogin = ({ username, token }: {
|
|
35
|
+
username?: string;
|
|
36
|
+
token?: string;
|
|
37
|
+
}) => void;
|
|
38
|
+
export type OnSuccessLoginSlot = SlotRegistry<OnSuccessLogin>;
|
|
12
39
|
export declare class CloudMain {
|
|
13
40
|
private config;
|
|
14
|
-
|
|
41
|
+
logger: Logger;
|
|
42
|
+
express: ExpressMain;
|
|
43
|
+
workspace: Workspace;
|
|
44
|
+
scope: ScopeMain;
|
|
45
|
+
globalConfig: GlobalConfigMain;
|
|
46
|
+
onSuccessLoginSlot: OnSuccessLoginSlot;
|
|
47
|
+
static ERROR_RESPONSE: number;
|
|
48
|
+
static DEFAULT_PORT: number;
|
|
49
|
+
static REDIRECT: number;
|
|
50
|
+
static GRAPHQL_ENDPOINT: string;
|
|
51
|
+
private authListenerByPort;
|
|
52
|
+
private REDIRECT_URL?;
|
|
53
|
+
constructor(config: CloudWorkspaceConfig, logger: Logger, express: ExpressMain, workspace: Workspace, scope: ScopeMain, globalConfig: GlobalConfigMain, onSuccessLoginSlot: OnSuccessLoginSlot);
|
|
54
|
+
setupAuthListener({ port: portFromParams, clientId, }?: {
|
|
55
|
+
port?: number;
|
|
56
|
+
clientId?: string;
|
|
57
|
+
}): Promise<CloudAuthListener | null>;
|
|
58
|
+
registerOnSuccessLogin(onSuccessLoginFn: OnSuccessLogin): this;
|
|
15
59
|
getCloudDomain(): string;
|
|
16
60
|
getCloudHubDomain(): string;
|
|
17
61
|
getCloudApi(): string;
|
|
@@ -21,9 +65,43 @@ export declare class CloudMain {
|
|
|
21
65
|
getRegistryUrl(): string;
|
|
22
66
|
getCloudExporterUrl(): string;
|
|
23
67
|
getHubName(): string;
|
|
24
|
-
|
|
25
|
-
|
|
68
|
+
getLoginPort(): number;
|
|
69
|
+
isLoggedIn(): boolean;
|
|
70
|
+
getAuthToken(): string;
|
|
71
|
+
getAuthHeader(): {
|
|
72
|
+
Authorization: string;
|
|
73
|
+
};
|
|
74
|
+
getCurrentUser(): Promise<CloudUser | null>;
|
|
75
|
+
getUsername(): string | undefined;
|
|
76
|
+
getLoginUrl({ redirectUrl, machineName, cloudDomain, port: portFromParams, }?: {
|
|
77
|
+
redirectUrl?: string;
|
|
78
|
+
machineName?: string;
|
|
79
|
+
cloudDomain?: string;
|
|
80
|
+
port?: string;
|
|
81
|
+
}): Promise<string | null>;
|
|
82
|
+
logout(): void;
|
|
83
|
+
whoami(): Promise<string | undefined>;
|
|
84
|
+
login(port?: string, suppressBrowserLaunch?: boolean, machineName?: string, cloudDomain?: string, redirectUrl?: string): Promise<{
|
|
85
|
+
isAlreadyLoggedIn?: boolean;
|
|
86
|
+
username?: string;
|
|
87
|
+
token?: string;
|
|
88
|
+
} | null>;
|
|
89
|
+
static GET_SCOPES: string;
|
|
90
|
+
getCloudScopes(scopes: string[]): Promise<ScopeDescriptor[]>;
|
|
91
|
+
fetchFromSymphonyViaGQL<T>(query: string, variables?: Record<string, any>): Promise<T | null>;
|
|
92
|
+
static slots: ((registerFn: () => string) => SlotRegistry<OnSuccessLogin>)[];
|
|
93
|
+
static dependencies: import("@teambit/harmony").Aspect[];
|
|
26
94
|
static runtime: import("@teambit/harmony").RuntimeDefinition;
|
|
27
95
|
static defaultConfig: CloudWorkspaceConfig;
|
|
28
|
-
static provider(
|
|
96
|
+
static provider([loggerMain, graphql, express, workspace, scope, globalConfig, cli, ui]: [
|
|
97
|
+
LoggerMain,
|
|
98
|
+
GraphqlMain,
|
|
99
|
+
ExpressMain,
|
|
100
|
+
Workspace,
|
|
101
|
+
ScopeMain,
|
|
102
|
+
GlobalConfigMain,
|
|
103
|
+
CLIMain,
|
|
104
|
+
UiMain
|
|
105
|
+
], config: CloudWorkspaceConfig, [onSuccessLoginSlot]: [OnSuccessLoginSlot]): Promise<CloudMain>;
|
|
29
106
|
}
|
|
107
|
+
export {};
|