@vectorx/cloud-toolkit 0.5.1 → 1.0.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.
@@ -1,3 +1,5 @@
1
+ import type { CloudEnvironment, CloudEnvironmentCreateRequest, CloudEnvironmentUpdateRequest } from "../env.kit";
2
+ import type { FunDeployOptions, FunDeployResult, FunDevOptions, FunDevRuntime } from "../fun.kit";
1
3
  import type { CheckStatusRequest, CheckStatusResponse } from "../services/auth-service";
2
4
  import type { BuildPreCheckResponse, IBuildPreCheckParams, IDeployParams } from "../services/upload-service";
3
5
  export interface IAuthService {
@@ -11,9 +13,43 @@ export interface IUploadService {
11
13
  buildPreCheck(params: IBuildPreCheckParams): Promise<BuildPreCheckResponse>;
12
14
  deploy(params: IDeployParams): Promise<any>;
13
15
  }
16
+ export interface ICloudEnvService {
17
+ getCloudEnvironments(cloudEnvId?: string): Promise<CloudEnvironment[]>;
18
+ getCloudEnvironment(cloudEnvId: string): Promise<CloudEnvironment | null>;
19
+ createCloudEnvironment(payload: CloudEnvironmentCreateRequest): Promise<CloudEnvironment>;
20
+ updateCloudEnvironment(payload: CloudEnvironmentUpdateRequest): Promise<CloudEnvironment>;
21
+ }
22
+ export interface IFunService {
23
+ startFunDev(options?: FunDevOptions): Promise<FunDevRuntime>;
24
+ deploy(options: FunDeployOptions): Promise<FunDeployResult>;
25
+ getPublishHistory(options: {
26
+ envId: string;
27
+ pageNo?: number;
28
+ pageSize?: number;
29
+ }): Promise<{
30
+ pkgList: Array<{
31
+ cloud_env_id: string;
32
+ desc: string;
33
+ resource_id: string;
34
+ committer_id: string;
35
+ committer_name: string;
36
+ committer_time: number;
37
+ }>;
38
+ total: number;
39
+ }>;
40
+ }
41
+ export interface CloudEnvInfo {
42
+ cloud_env_name: string;
43
+ status: number;
44
+ cloud_env_id: string;
45
+ description?: string;
46
+ create_time?: string;
47
+ update_time?: string;
48
+ }
14
49
  export interface LoginInfo {
15
50
  secret_id: string;
16
51
  cli_token: string;
17
52
  create_at: number;
18
53
  expire_in_sec: number;
54
+ cloudEnvInfo?: CloudEnvInfo | null;
19
55
  }
@@ -0,0 +1,43 @@
1
+ export interface CloudEnvironment {
2
+ cloud_env_name: string;
3
+ status: number;
4
+ cloud_env_id: string;
5
+ description?: string;
6
+ creator_id?: string;
7
+ create_time?: string;
8
+ update_time?: string;
9
+ env_variables?: unknown;
10
+ }
11
+ export interface CloudEnvironmentListData {
12
+ envs: CloudEnvironment[];
13
+ }
14
+ export interface CloudEnvironmentListResponse {
15
+ code: number;
16
+ msg: string;
17
+ success: boolean;
18
+ data: CloudEnvironmentListData;
19
+ }
20
+ export interface CloudEnvironmentCreateRequest {
21
+ cloud_env_name: string;
22
+ description?: string;
23
+ }
24
+ export interface CloudEnvironmentCreateResponse {
25
+ code: number;
26
+ msg: string;
27
+ success: boolean;
28
+ data: CloudEnvironment;
29
+ }
30
+ export interface CloudEnvironmentUpdateRequest {
31
+ cloud_env_id: string;
32
+ env_variables: string;
33
+ }
34
+ export interface CloudEnvironmentUpdateResponse {
35
+ code: number;
36
+ msg: string;
37
+ success: boolean;
38
+ data: CloudEnvironment;
39
+ }
40
+ export declare function getCloudEnvironments(cloudEnvId?: string): Promise<CloudEnvironment[]>;
41
+ export declare function getCloudEnvironment(cloudEnvId: string): Promise<CloudEnvironment | null>;
42
+ export declare function createCloudEnvironment(payload: CloudEnvironmentCreateRequest): Promise<CloudEnvironment>;
43
+ export declare function updateCloudEnvironment(payload: CloudEnvironmentUpdateRequest): Promise<CloudEnvironment>;
@@ -0,0 +1,63 @@
1
+ export interface FunDevOptions {
2
+ workDir?: string;
3
+ uiPort?: number;
4
+ apiPort?: number;
5
+ watch?: boolean;
6
+ open?: boolean;
7
+ quiet?: boolean;
8
+ envId?: string;
9
+ mode?: "agent" | "fun";
10
+ deps?: {
11
+ startFunctionDebugger?: (opts: any) => Promise<{
12
+ uiUrl: string;
13
+ apiUrl: string;
14
+ wsUrl: string;
15
+ close: () => Promise<void>;
16
+ }>;
17
+ };
18
+ }
19
+ export interface FunDevRuntime {
20
+ workDir: string;
21
+ uiUrl: string;
22
+ apiUrl: string;
23
+ wsUrl: string;
24
+ ffUrl: string;
25
+ close: () => Promise<void>;
26
+ }
27
+ export type LogType = "info" | "success" | "error" | "warn";
28
+ export interface LogCollector {
29
+ addLog(log: string, type?: LogType, loading?: boolean): void;
30
+ }
31
+ export interface FunDeployOptions {
32
+ envId: string;
33
+ workDir?: string;
34
+ includeNodeModules?: boolean;
35
+ desc?: string;
36
+ logCollector?: LogCollector;
37
+ }
38
+ export interface FunDeployResult {
39
+ success: boolean;
40
+ code: number;
41
+ msg?: string;
42
+ publisher?: string;
43
+ }
44
+ export interface PublishHistoryItem {
45
+ cloud_env_id: string;
46
+ desc: string;
47
+ resource_id: string;
48
+ committer_id: string;
49
+ committer_name: string;
50
+ committer_time: number;
51
+ }
52
+ export interface FunPublishHistoryOptions {
53
+ envId: string;
54
+ pageNo?: number;
55
+ pageSize?: number;
56
+ }
57
+ export interface FunPublishHistoryResult {
58
+ pkgList: PublishHistoryItem[];
59
+ total: number;
60
+ }
61
+ export declare function startFunDev(options?: FunDevOptions): Promise<FunDevRuntime>;
62
+ export declare function deployFun(options: FunDeployOptions): Promise<FunDeployResult>;
63
+ export declare function getPublishHistory(options: FunPublishHistoryOptions): Promise<FunPublishHistoryResult>;
package/types/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  export * from "./agent.kit";
2
+ export * from "./fun.kit";
3
+ export * from "./env.kit";
2
4
  export { Uploader } from "./utils/cos-uploader";
3
5
  export * from "./container";
4
6
  export * from "./services";
@@ -10,4 +12,6 @@ export * from "./utils/tracker";
10
12
  export * from "./utils/port-finder";
11
13
  export * from "./utils/open-browser";
12
14
  export * from "./utils/output";
15
+ export * from "./utils/table";
16
+ export * from "./utils/fun-project-validator";
13
17
  export { TokenRequest, TokenResponse, UploadTempPermit, InternalTokenRequest, } from "./services/upload-service";
@@ -0,0 +1,10 @@
1
+ import type { ICloudEnvService } from "../container";
2
+ import type { CloudEnvironment, CloudEnvironmentCreateRequest, CloudEnvironmentUpdateRequest } from "../env.kit";
3
+ export declare class CloudEnvService implements ICloudEnvService {
4
+ private readonly authService;
5
+ constructor();
6
+ getCloudEnvironments(cloudEnvId?: string): Promise<CloudEnvironment[]>;
7
+ getCloudEnvironment(cloudEnvId: string): Promise<CloudEnvironment | null>;
8
+ createCloudEnvironment(payload: CloudEnvironmentCreateRequest): Promise<CloudEnvironment>;
9
+ updateCloudEnvironment(payload: CloudEnvironmentUpdateRequest): Promise<CloudEnvironment>;
10
+ }
@@ -0,0 +1,23 @@
1
+ import type { IFunService } from "../container";
2
+ import type { FunDeployOptions, FunDeployResult, FunDevOptions, FunDevRuntime } from "../fun.kit";
3
+ export declare class FunService implements IFunService {
4
+ private readonly authService;
5
+ constructor();
6
+ startFunDev(options?: FunDevOptions): Promise<FunDevRuntime>;
7
+ deploy(options: FunDeployOptions): Promise<FunDeployResult>;
8
+ getPublishHistory(options: {
9
+ envId: string;
10
+ pageNo?: number;
11
+ pageSize?: number;
12
+ }): Promise<{
13
+ pkgList: Array<{
14
+ cloud_env_id: string;
15
+ desc: string;
16
+ resource_id: string;
17
+ committer_id: string;
18
+ committer_name: string;
19
+ committer_time: number;
20
+ }>;
21
+ total: number;
22
+ }>;
23
+ }
@@ -1,2 +1,4 @@
1
1
  export * from "./auth-service";
2
2
  export * from "./upload-service";
3
+ export * from "./cloud-env-service";
4
+ export * from "./fun-service";
@@ -0,0 +1,22 @@
1
+ export interface FunValidationResult {
2
+ valid: boolean;
3
+ errors: string[];
4
+ warnings?: string[];
5
+ }
6
+ export interface FunctionConfig {
7
+ name: string;
8
+ directory: string;
9
+ source: string;
10
+ triggerPath: string;
11
+ }
12
+ export interface CloudFunctionConfig {
13
+ functionsRoot: string;
14
+ functions?: FunctionConfig[];
15
+ }
16
+ export declare class FunProjectValidator {
17
+ private workDir;
18
+ constructor(workDir: string);
19
+ validate(): Promise<FunValidationResult>;
20
+ private validateFunctionsConfig;
21
+ private validateDependencies;
22
+ }
@@ -0,0 +1,2 @@
1
+ import { type TableOptions } from "cli-table3";
2
+ export declare function printHorizontalTable(head: string[], data?: (string | number)[][], options?: TableOptions): void;
@@ -0,0 +1,28 @@
1
+ import type { IBase } from "./tracker";
2
+ interface ISequence {
3
+ context_sdkSeqId: number;
4
+ context_sdkSessionId: string;
5
+ context_pageSessionId: string;
6
+ clientTime: number;
7
+ }
8
+ interface IReqItem {
9
+ sequence: ISequence;
10
+ measurement_name: string;
11
+ measurement_data: Record<string, any>;
12
+ }
13
+ export declare class APM {
14
+ private reportQueue;
15
+ private allowReport;
16
+ private eventSeq;
17
+ private context;
18
+ private baseData;
19
+ setContext(userId: string, base?: IBase): void;
20
+ setAppVersion(appVersion: string): void;
21
+ private startReport;
22
+ private getSequence;
23
+ private _request;
24
+ private batchReport;
25
+ private timer;
26
+ report(measurement_name: string, measurement_data?: IReqItem["measurement_data"]): void;
27
+ }
28
+ export {};
@@ -0,0 +1,27 @@
1
+ export declare const CLI_MEASUREMENT_NAME = "vectorx_cloud_cli_usage";
2
+ export type CliApmCommandStatus = 0 | 1;
3
+ export type CliApmExceptionSource = "uncaughtException" | "unhandledRejection";
4
+ export type CliApmErrorType = "auth" | "http" | "validation" | "biz" | "unknown";
5
+ export interface InitCliApmOptions {
6
+ cliVersion?: string;
7
+ userId?: string;
8
+ }
9
+ export interface CliCommandMeta {
10
+ cmd_path: string;
11
+ cmd_root?: string;
12
+ params_count?: number;
13
+ options_keys?: string[];
14
+ }
15
+ export declare function initCliApm(options?: InitCliApmOptions): void;
16
+ export declare function setCliApmCurrentCommand(cmdPath?: string): void;
17
+ export declare function createCliCommandTracker(meta: CliCommandMeta): {
18
+ reportSuccess(durationMs: number): void;
19
+ reportFail(durationMs: number, err: any): void;
20
+ };
21
+ export declare function reportCliException(source: CliApmExceptionSource, err: any): void;
22
+ export interface CliHttpErrorMeta {
23
+ method?: string;
24
+ url?: string;
25
+ status_code?: number;
26
+ }
27
+ export declare function reportCliHttpError(meta: CliHttpErrorMeta, err?: any): void;
@@ -1,27 +1,4 @@
1
- import type { IBase } from "./tracker";
2
- interface ISequence {
3
- context_sdkSeqId: number;
4
- context_sdkSessionId: string;
5
- context_pageSessionId: string;
6
- clientTime: number;
7
- }
8
- interface IReqItem {
9
- suquence: ISequence;
10
- measurement_name: string;
11
- measurement_data: Record<string, any>;
12
- }
13
- export declare class APM {
14
- private reportQueue;
15
- private allowReport;
16
- private eventSeq;
17
- private context;
18
- private baseData;
19
- setContext(userId: string, base?: IBase): void;
20
- private startReport;
21
- private getSequence;
22
- private _request;
23
- private bactchReport;
24
- private timer;
25
- report(measurement_name: string, measurement_data?: IReqItem["measurement_data"]): void;
26
- }
27
- export {};
1
+ export * from "./tracker";
2
+ export * from "./device";
3
+ export * from "./apm";
4
+ export * from "./cli-apm";