@wenlarge/communication 1.1.2 → 1.1.4
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/dist/config/executor-core-config.d.ts +1 -0
- package/dist/config/executor-core-config.js +4 -0
- package/dist/generated/auth.d.ts +21 -0
- package/dist/generated/auth.js +10 -2
- package/dist/generated/executor-core.d.ts +25 -0
- package/dist/generated/executor-core.js +30 -0
- package/dist/generated/google/protobuf/empty.js +1 -1
- package/dist/generated/google/protobuf/struct.d.ts +82 -0
- package/dist/generated/google/protobuf/struct.js +117 -0
- package/dist/generated/project.js +1 -1
- package/dist/generated/workflow.d.ts +93 -20
- package/dist/generated/workflow.js +16 -2
- package/dist/grpc-client/grpc-client.module.d.ts +1 -0
- package/dist/grpc-client/grpc-client.module.js +18 -0
- package/dist/helpers/structToJson.d.ts +1 -0
- package/dist/helpers/structToJson.js +23 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +8 -1
- package/dist/kafka/kafka-topics.d.ts +5 -3
- package/dist/kafka/kafka-topics.js +5 -4
- package/package.json +1 -1
- package/proto/auth.proto +23 -0
- package/proto/executor-core.proto +19 -0
- package/proto/workflow.proto +84 -23
- package/src/generated/auth.ts +42 -2
- package/src/generated/executor-core.ts +57 -0
- package/src/generated/google/protobuf/empty.ts +1 -1
- package/src/generated/google/protobuf/struct.ts +179 -0
- package/src/generated/project.ts +1 -1
- package/src/generated/workflow.ts +119 -22
- package/dist/config/workflow-node-config.d.ts +0 -1
- package/dist/config/workflow-node-config.js +0 -6
package/dist/index.js
CHANGED
|
@@ -36,7 +36,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
36
36
|
};
|
|
37
37
|
})();
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.Metadata = exports.Project = exports.Workflow = exports.Auth = void 0;
|
|
39
|
+
exports.ListValue = exports.Value = exports.Struct = exports.ExecutorCore = exports.Metadata = exports.Project = exports.Workflow = exports.Auth = void 0;
|
|
40
40
|
__exportStar(require("./helpers/helper"), exports);
|
|
41
41
|
exports.Auth = __importStar(require("./generated/auth"));
|
|
42
42
|
__exportStar(require("./config/auth-config"), exports);
|
|
@@ -45,5 +45,12 @@ __exportStar(require("./config/workflow-config"), exports);
|
|
|
45
45
|
exports.Project = __importStar(require("./generated/project"));
|
|
46
46
|
__exportStar(require("./config/project-config"), exports);
|
|
47
47
|
__exportStar(require("./grpc-client"), exports);
|
|
48
|
+
__exportStar(require("./config/executor-core-config"), exports);
|
|
48
49
|
var grpc_js_1 = require("@grpc/grpc-js");
|
|
49
50
|
Object.defineProperty(exports, "Metadata", { enumerable: true, get: function () { return grpc_js_1.Metadata; } });
|
|
51
|
+
exports.ExecutorCore = __importStar(require("./generated/executor-core"));
|
|
52
|
+
__exportStar(require("./kafka/kafka-topics"), exports);
|
|
53
|
+
var struct_1 = require("./generated/google/protobuf/struct");
|
|
54
|
+
Object.defineProperty(exports, "Struct", { enumerable: true, get: function () { return struct_1.Struct; } });
|
|
55
|
+
Object.defineProperty(exports, "Value", { enumerable: true, get: function () { return struct_1.Value; } });
|
|
56
|
+
Object.defineProperty(exports, "ListValue", { enumerable: true, get: function () { return struct_1.ListValue; } });
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
export declare
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export declare const KafkaTopics: {
|
|
2
|
+
readonly EXECUTION_COMPLETED: "execution.completed";
|
|
3
|
+
readonly EXECUTION_FAILED: "execution.failed";
|
|
4
|
+
readonly EXECUTION_WAITING: "execution.waiting";
|
|
5
|
+
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.KafkaTopics = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
exports.KafkaTopics = {
|
|
5
|
+
EXECUTION_COMPLETED: "execution.completed",
|
|
6
|
+
EXECUTION_FAILED: "execution.failed",
|
|
7
|
+
EXECUTION_WAITING: "execution.waiting",
|
|
8
|
+
};
|
package/package.json
CHANGED
package/proto/auth.proto
CHANGED
|
@@ -10,6 +10,8 @@ service AuthService {
|
|
|
10
10
|
rpc GetMe (GetMeRequest) returns (GetMeResponse);
|
|
11
11
|
rpc InviteToCompany (InviteToCompanyRequest) returns (InviteToCompanyResponse);
|
|
12
12
|
rpc UpdateInviteStatus (UpdateInviteStatusRequest) returns (UpdateInviteStatusResponse);
|
|
13
|
+
rpc GetCompanyUsers (GetCompanyUsersRequest) returns (GetCompanyUsersResponse);
|
|
14
|
+
rpc RemoveUserFromCompany (RemoveUserFromCompanyRequest) returns (google.protobuf.Empty);
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
message LoginRequest {
|
|
@@ -72,4 +74,25 @@ message GetMeResponse {
|
|
|
72
74
|
string createdAt = 4;
|
|
73
75
|
string updatedAt = 5;
|
|
74
76
|
repeated CompanyUser companyUsersOnUser = 6;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
message GetCompanyUsersRequest {
|
|
80
|
+
string companyId = 1;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
message CompanyUserDetail {
|
|
84
|
+
string userId = 1;
|
|
85
|
+
string userName = 2;
|
|
86
|
+
string userEmail = 3;
|
|
87
|
+
string joinedAt = 4;
|
|
88
|
+
bool isOwner = 5;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
message GetCompanyUsersResponse {
|
|
92
|
+
repeated CompanyUserDetail users = 1;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
message RemoveUserFromCompanyRequest {
|
|
96
|
+
string companyId = 1;
|
|
97
|
+
string userId = 2;
|
|
75
98
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package executor_core;
|
|
4
|
+
import "google/protobuf/struct.proto";
|
|
5
|
+
|
|
6
|
+
message ExecuteNodeRequest {
|
|
7
|
+
string nodeTypeId = 1;
|
|
8
|
+
string nodeId = 2;
|
|
9
|
+
google.protobuf.Struct config = 3;
|
|
10
|
+
google.protobuf.Struct inputSchema = 4;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
message ExecuteNodeResponse {
|
|
14
|
+
string lastResult = 1;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
service CoreExecutionService {
|
|
18
|
+
rpc ExecuteNode (ExecuteNodeRequest) returns (ExecuteNodeResponse);
|
|
19
|
+
}
|
package/proto/workflow.proto
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
syntax = "proto3";
|
|
2
2
|
|
|
3
3
|
import "google/protobuf/empty.proto";
|
|
4
|
+
import "google/protobuf/struct.proto";
|
|
4
5
|
|
|
5
6
|
package workflow;
|
|
6
7
|
|
|
@@ -9,12 +10,17 @@ service WorkflowService {
|
|
|
9
10
|
rpc FindMany (FindManyWorkflowRequest) returns (FindManyWorkflowResponse);
|
|
10
11
|
rpc Delete (DeleteWorkflowRequest) returns (google.protobuf.Empty);
|
|
11
12
|
rpc Update (UpdateWorkflowRequest) returns (WorkflowResponse);
|
|
12
|
-
rpc TriggerWorkflow (
|
|
13
|
+
rpc TriggerWorkflow (TriggerWorkflowRequest) returns (TriggerWorkflowResponse);
|
|
14
|
+
rpc TriggerNode (TriggerNodeRequest) returns (TriggerNodeResponse);
|
|
13
15
|
rpc CreateWorkflowNode (CreateWorkflowNodeRequest) returns (WorkflowNodeResponse);
|
|
14
16
|
rpc FindManyWorkflowNode (FindManyWorkflowNodeRequest) returns (FindManyWorkflowNodeResponse);
|
|
15
17
|
rpc FindFirstWorkflowNode (FindFirstWorkflowNodeRequest) returns (FindFirstWorkflowNodeResponse);
|
|
16
18
|
rpc UpdateWorkflowNode (UpdateWorkflowNodeRequest) returns (WorkflowNodeResponse);
|
|
17
19
|
rpc DeleteWorkflowNode (DeleteWorkflowNodeRequest) returns (google.protobuf.Empty);
|
|
20
|
+
rpc SaveWorkflowBatch (SaveWorkflowBatchRequest) returns (google.protobuf.Empty);
|
|
21
|
+
rpc FindWorkflowNodeTypes (google.protobuf.Empty) returns (FindManyWorkflowNodeTypeResponse);
|
|
22
|
+
rpc FindConnections (FindConnectionsRequest) returns (FindConnectionsResponse);
|
|
23
|
+
rpc UpdateWorkflowStatus (UpdateWorkflowStatusRequest) returns (google.protobuf.Empty);
|
|
18
24
|
}
|
|
19
25
|
|
|
20
26
|
message CreateWorkflowRequest {
|
|
@@ -51,37 +57,43 @@ message FindManyWorkflowResponse{
|
|
|
51
57
|
int32 total = 2;
|
|
52
58
|
}
|
|
53
59
|
|
|
54
|
-
message
|
|
60
|
+
message TriggerWorkflowRequest{
|
|
61
|
+
string workflowId = 1;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
message TriggerWorkflowResponse{
|
|
65
|
+
bool ok = 1;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
message TriggerNodeRequest{
|
|
55
69
|
string nodeId = 1;
|
|
56
70
|
}
|
|
57
71
|
|
|
58
|
-
message
|
|
72
|
+
message TriggerNodeResponse{
|
|
59
73
|
bool ok = 1;
|
|
60
74
|
}
|
|
61
75
|
|
|
62
|
-
// NODE SERVICE COMPS
|
|
63
76
|
message CreateWorkflowNodeRequest{
|
|
64
77
|
string workflowId = 1;
|
|
65
78
|
string name = 2;
|
|
66
|
-
|
|
67
|
-
int32
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
string
|
|
72
|
-
repeated string nextNodeIds = 9;
|
|
79
|
+
int32 positionX = 3;
|
|
80
|
+
int32 positionY = 4;
|
|
81
|
+
google.protobuf.Struct inputSchema = 5;
|
|
82
|
+
google.protobuf.Struct outputSchema = 6;
|
|
83
|
+
google.protobuf.Struct config = 7;
|
|
84
|
+
string nodeTypeId = 8;
|
|
73
85
|
}
|
|
74
86
|
|
|
75
87
|
message UpdateWorkflowNodeRequest{
|
|
76
88
|
string id = 1;
|
|
77
89
|
string name = 2;
|
|
78
|
-
string
|
|
90
|
+
string nodeTypeId = 3;
|
|
79
91
|
int32 positionX = 4;
|
|
80
92
|
int32 positionY=5;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
string
|
|
93
|
+
google.protobuf.Struct inputSchema = 6;
|
|
94
|
+
google.protobuf.Struct outputSchema = 7;
|
|
95
|
+
google.protobuf.Struct config = 8;
|
|
96
|
+
string workflowId = 9;
|
|
85
97
|
}
|
|
86
98
|
|
|
87
99
|
message DeleteWorkflowNodeRequest{
|
|
@@ -109,13 +121,62 @@ message FindFirstWorkflowNodeResponse{
|
|
|
109
121
|
message WorkflowNodeResponse{
|
|
110
122
|
string id = 1;
|
|
111
123
|
string name = 2;
|
|
112
|
-
string
|
|
124
|
+
string nodeTypeId = 3;
|
|
113
125
|
int32 positionX = 4;
|
|
114
126
|
int32 positionY = 5;
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
string
|
|
120
|
-
string
|
|
127
|
+
google.protobuf.Struct inputSchema = 6;
|
|
128
|
+
google.protobuf.Struct outputSchema = 7;
|
|
129
|
+
google.protobuf.Struct config = 8;
|
|
130
|
+
string createdAt = 9;
|
|
131
|
+
string updatedAt = 10;
|
|
132
|
+
string workflowId = 11;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
message WorkflowNodeConnection {
|
|
136
|
+
string id = 1;
|
|
137
|
+
string workflowId = 2;
|
|
138
|
+
string fromNodeId = 3;
|
|
139
|
+
string toNodeId = 4;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
message SaveWorkflowBatchRequest {
|
|
143
|
+
string workflowId = 1;
|
|
144
|
+
repeated UpdateWorkflowNodeRequest nodes = 2;
|
|
145
|
+
repeated UpdateBatchConnection connections = 3;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
message UpdateBatchConnection {
|
|
149
|
+
string fromNodeId = 1;
|
|
150
|
+
string toNodeId = 2;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
message WorkflowNodeTypeResponse {
|
|
154
|
+
string id = 1;
|
|
155
|
+
string label = 2;
|
|
156
|
+
string description = 3;
|
|
157
|
+
string service = 4;
|
|
158
|
+
string icon = 5;
|
|
159
|
+
string form = 6;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
message FindManyWorkflowNodeTypeResponse {
|
|
163
|
+
repeated WorkflowNodeTypeResponse data = 1;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
message FindConnectionsRequest {
|
|
167
|
+
string workflowId = 1;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
message FindConnectionsResponse {
|
|
171
|
+
repeated WorkflowNodeConnection data = 1;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
enum WorkflowStatus {
|
|
175
|
+
DRAFT = 0;
|
|
176
|
+
PUBLISHED = 1;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
message UpdateWorkflowStatusRequest {
|
|
180
|
+
string workflowId = 1;
|
|
181
|
+
WorkflowStatus status = 2;
|
|
121
182
|
}
|
package/src/generated/auth.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
2
2
|
// versions:
|
|
3
3
|
// protoc-gen-ts_proto v1.181.2
|
|
4
|
-
// protoc
|
|
4
|
+
// protoc v5.29.6
|
|
5
5
|
// source: auth.proto
|
|
6
6
|
|
|
7
7
|
/* eslint-disable */
|
|
@@ -74,6 +74,27 @@ export interface GetMeResponse {
|
|
|
74
74
|
companyUsersOnUser: CompanyUser[];
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
export interface GetCompanyUsersRequest {
|
|
78
|
+
companyId: string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface CompanyUserDetail {
|
|
82
|
+
userId: string;
|
|
83
|
+
userName: string;
|
|
84
|
+
userEmail: string;
|
|
85
|
+
joinedAt: string;
|
|
86
|
+
isOwner: boolean;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface GetCompanyUsersResponse {
|
|
90
|
+
users: CompanyUserDetail[];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface RemoveUserFromCompanyRequest {
|
|
94
|
+
companyId: string;
|
|
95
|
+
userId: string;
|
|
96
|
+
}
|
|
97
|
+
|
|
77
98
|
export const AUTH_PACKAGE_NAME = "auth";
|
|
78
99
|
|
|
79
100
|
export interface AuthServiceClient {
|
|
@@ -86,6 +107,10 @@ export interface AuthServiceClient {
|
|
|
86
107
|
inviteToCompany(request: InviteToCompanyRequest, metadata?: Metadata): Observable<InviteToCompanyResponse>;
|
|
87
108
|
|
|
88
109
|
updateInviteStatus(request: UpdateInviteStatusRequest, metadata?: Metadata): Observable<UpdateInviteStatusResponse>;
|
|
110
|
+
|
|
111
|
+
getCompanyUsers(request: GetCompanyUsersRequest, metadata?: Metadata): Observable<GetCompanyUsersResponse>;
|
|
112
|
+
|
|
113
|
+
removeUserFromCompany(request: RemoveUserFromCompanyRequest, metadata?: Metadata): Observable<Empty>;
|
|
89
114
|
}
|
|
90
115
|
|
|
91
116
|
export interface AuthServiceController {
|
|
@@ -104,11 +129,26 @@ export interface AuthServiceController {
|
|
|
104
129
|
request: UpdateInviteStatusRequest,
|
|
105
130
|
metadata?: Metadata,
|
|
106
131
|
): Promise<UpdateInviteStatusResponse> | Observable<UpdateInviteStatusResponse> | UpdateInviteStatusResponse;
|
|
132
|
+
|
|
133
|
+
getCompanyUsers(
|
|
134
|
+
request: GetCompanyUsersRequest,
|
|
135
|
+
metadata?: Metadata,
|
|
136
|
+
): Promise<GetCompanyUsersResponse> | Observable<GetCompanyUsersResponse> | GetCompanyUsersResponse;
|
|
137
|
+
|
|
138
|
+
removeUserFromCompany(request: RemoveUserFromCompanyRequest, metadata?: Metadata): void;
|
|
107
139
|
}
|
|
108
140
|
|
|
109
141
|
export function AuthServiceControllerMethods() {
|
|
110
142
|
return function (constructor: Function) {
|
|
111
|
-
const grpcMethods: string[] = [
|
|
143
|
+
const grpcMethods: string[] = [
|
|
144
|
+
"login",
|
|
145
|
+
"register",
|
|
146
|
+
"getMe",
|
|
147
|
+
"inviteToCompany",
|
|
148
|
+
"updateInviteStatus",
|
|
149
|
+
"getCompanyUsers",
|
|
150
|
+
"removeUserFromCompany",
|
|
151
|
+
];
|
|
112
152
|
for (const method of grpcMethods) {
|
|
113
153
|
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
114
154
|
GrpcMethod("AuthService", method)(constructor.prototype[method], method, descriptor);
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
2
|
+
// versions:
|
|
3
|
+
// protoc-gen-ts_proto v1.181.2
|
|
4
|
+
// protoc v5.29.6
|
|
5
|
+
// source: executor-core.proto
|
|
6
|
+
|
|
7
|
+
/* eslint-disable */
|
|
8
|
+
import { Metadata } from "@grpc/grpc-js";
|
|
9
|
+
import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
|
|
10
|
+
import { wrappers } from "protobufjs";
|
|
11
|
+
import { Observable } from "rxjs";
|
|
12
|
+
import { Struct } from "./google/protobuf/struct";
|
|
13
|
+
|
|
14
|
+
export const protobufPackage = "executor_core";
|
|
15
|
+
|
|
16
|
+
export interface ExecuteNodeRequest {
|
|
17
|
+
nodeTypeId: string;
|
|
18
|
+
nodeId: string;
|
|
19
|
+
config?: { [key: string]: any } | undefined;
|
|
20
|
+
inputSchema?: { [key: string]: any } | undefined;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface ExecuteNodeResponse {
|
|
24
|
+
lastResult: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const EXECUTOR_CORE_PACKAGE_NAME = "executor_core";
|
|
28
|
+
|
|
29
|
+
wrappers[".google.protobuf.Struct"] = { fromObject: Struct.wrap, toObject: Struct.unwrap } as any;
|
|
30
|
+
|
|
31
|
+
export interface CoreExecutionServiceClient {
|
|
32
|
+
executeNode(request: ExecuteNodeRequest, metadata?: Metadata): Observable<ExecuteNodeResponse>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface CoreExecutionServiceController {
|
|
36
|
+
executeNode(
|
|
37
|
+
request: ExecuteNodeRequest,
|
|
38
|
+
metadata?: Metadata,
|
|
39
|
+
): Promise<ExecuteNodeResponse> | Observable<ExecuteNodeResponse> | ExecuteNodeResponse;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function CoreExecutionServiceControllerMethods() {
|
|
43
|
+
return function (constructor: Function) {
|
|
44
|
+
const grpcMethods: string[] = ["executeNode"];
|
|
45
|
+
for (const method of grpcMethods) {
|
|
46
|
+
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
47
|
+
GrpcMethod("CoreExecutionService", method)(constructor.prototype[method], method, descriptor);
|
|
48
|
+
}
|
|
49
|
+
const grpcStreamMethods: string[] = [];
|
|
50
|
+
for (const method of grpcStreamMethods) {
|
|
51
|
+
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
52
|
+
GrpcStreamMethod("CoreExecutionService", method)(constructor.prototype[method], method, descriptor);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export const CORE_EXECUTION_SERVICE_NAME = "CoreExecutionService";
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
2
|
+
// versions:
|
|
3
|
+
// protoc-gen-ts_proto v1.181.2
|
|
4
|
+
// protoc v5.29.6
|
|
5
|
+
// source: google/protobuf/struct.proto
|
|
6
|
+
|
|
7
|
+
/* eslint-disable */
|
|
8
|
+
import { wrappers } from "protobufjs";
|
|
9
|
+
|
|
10
|
+
export const protobufPackage = "google.protobuf";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* `NullValue` is a singleton enumeration to represent the null value for the
|
|
14
|
+
* `Value` type union.
|
|
15
|
+
*
|
|
16
|
+
* The JSON representation for `NullValue` is JSON `null`.
|
|
17
|
+
*/
|
|
18
|
+
export enum NullValue {
|
|
19
|
+
/** NULL_VALUE - Null value. */
|
|
20
|
+
NULL_VALUE = "NULL_VALUE",
|
|
21
|
+
UNRECOGNIZED = "UNRECOGNIZED",
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* `Struct` represents a structured data value, consisting of fields
|
|
26
|
+
* which map to dynamically typed values. In some languages, `Struct`
|
|
27
|
+
* might be supported by a native representation. For example, in
|
|
28
|
+
* scripting languages like JS a struct is represented as an
|
|
29
|
+
* object. The details of that representation are described together
|
|
30
|
+
* with the proto support for the language.
|
|
31
|
+
*
|
|
32
|
+
* The JSON representation for `Struct` is JSON object.
|
|
33
|
+
*/
|
|
34
|
+
export interface Struct {
|
|
35
|
+
/** Unordered map of dynamically typed values. */
|
|
36
|
+
fields: { [key: string]: any | undefined };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface Struct_FieldsEntry {
|
|
40
|
+
key: string;
|
|
41
|
+
value?: any | undefined;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* `Value` represents a dynamically typed value which can be either
|
|
46
|
+
* null, a number, a string, a boolean, a recursive struct value, or a
|
|
47
|
+
* list of values. A producer of value is expected to set one of these
|
|
48
|
+
* variants. Absence of any variant indicates an error.
|
|
49
|
+
*
|
|
50
|
+
* The JSON representation for `Value` is JSON value.
|
|
51
|
+
*/
|
|
52
|
+
export interface Value {
|
|
53
|
+
/** Represents a null value. */
|
|
54
|
+
nullValue?:
|
|
55
|
+
| NullValue
|
|
56
|
+
| undefined;
|
|
57
|
+
/** Represents a double value. */
|
|
58
|
+
numberValue?:
|
|
59
|
+
| number
|
|
60
|
+
| undefined;
|
|
61
|
+
/** Represents a string value. */
|
|
62
|
+
stringValue?:
|
|
63
|
+
| string
|
|
64
|
+
| undefined;
|
|
65
|
+
/** Represents a boolean value. */
|
|
66
|
+
boolValue?:
|
|
67
|
+
| boolean
|
|
68
|
+
| undefined;
|
|
69
|
+
/** Represents a structured value. */
|
|
70
|
+
structValue?:
|
|
71
|
+
| { [key: string]: any }
|
|
72
|
+
| undefined;
|
|
73
|
+
/** Represents a repeated `Value`. */
|
|
74
|
+
listValue?: Array<any> | undefined;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* `ListValue` is a wrapper around a repeated field of values.
|
|
79
|
+
*
|
|
80
|
+
* The JSON representation for `ListValue` is JSON array.
|
|
81
|
+
*/
|
|
82
|
+
export interface ListValue {
|
|
83
|
+
/** Repeated field of dynamically typed values. */
|
|
84
|
+
values: any[];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export const GOOGLE_PROTOBUF_PACKAGE_NAME = "google.protobuf";
|
|
88
|
+
|
|
89
|
+
function createBaseStruct(): Struct {
|
|
90
|
+
return { fields: {} };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export const Struct = {
|
|
94
|
+
wrap(object: { [key: string]: any } | undefined): Struct {
|
|
95
|
+
const struct = createBaseStruct();
|
|
96
|
+
|
|
97
|
+
if (object !== undefined) {
|
|
98
|
+
for (const key of Object.keys(object)) {
|
|
99
|
+
struct.fields[key] = Value.wrap(object[key]);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return struct;
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
unwrap(message: Struct): { [key: string]: any } {
|
|
106
|
+
const object: { [key: string]: any } = {};
|
|
107
|
+
if (message.fields) {
|
|
108
|
+
for (const key of Object.keys(message.fields)) {
|
|
109
|
+
object[key] = Value.unwrap(message.fields[key]);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return object;
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
function createBaseValue(): Value {
|
|
117
|
+
return {};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export const Value = {
|
|
121
|
+
wrap(value: any): Value {
|
|
122
|
+
const result = {} as any;
|
|
123
|
+
if (value === null) {
|
|
124
|
+
result.nullValue = NullValue.NULL_VALUE;
|
|
125
|
+
} else if (typeof value === "boolean") {
|
|
126
|
+
result.boolValue = value;
|
|
127
|
+
} else if (typeof value === "number") {
|
|
128
|
+
result.numberValue = value;
|
|
129
|
+
} else if (typeof value === "string") {
|
|
130
|
+
result.stringValue = value;
|
|
131
|
+
} else if (globalThis.Array.isArray(value)) {
|
|
132
|
+
result.listValue = ListValue.wrap(value);
|
|
133
|
+
} else if (typeof value === "object") {
|
|
134
|
+
result.structValue = Struct.wrap(value);
|
|
135
|
+
} else if (typeof value !== "undefined") {
|
|
136
|
+
throw new globalThis.Error("Unsupported any value type: " + typeof value);
|
|
137
|
+
}
|
|
138
|
+
return result;
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
unwrap(message: any): string | number | boolean | Object | null | Array<any> | undefined {
|
|
142
|
+
if (message?.hasOwnProperty("stringValue") && message.stringValue !== undefined) {
|
|
143
|
+
return message.stringValue;
|
|
144
|
+
} else if (message?.hasOwnProperty("numberValue") && message?.numberValue !== undefined) {
|
|
145
|
+
return message.numberValue;
|
|
146
|
+
} else if (message?.hasOwnProperty("boolValue") && message?.boolValue !== undefined) {
|
|
147
|
+
return message.boolValue;
|
|
148
|
+
} else if (message?.hasOwnProperty("structValue") && message?.structValue !== undefined) {
|
|
149
|
+
return Struct.unwrap(message.structValue as any);
|
|
150
|
+
} else if (message?.hasOwnProperty("listValue") && message?.listValue !== undefined) {
|
|
151
|
+
return ListValue.unwrap(message.listValue);
|
|
152
|
+
} else if (message?.hasOwnProperty("nullValue") && message?.nullValue !== undefined) {
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
return undefined;
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
function createBaseListValue(): ListValue {
|
|
160
|
+
return { values: [] };
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export const ListValue = {
|
|
164
|
+
wrap(array: Array<any> | undefined): ListValue {
|
|
165
|
+
const result = createBaseListValue();
|
|
166
|
+
result.values = (array ?? []).map(Value.wrap);
|
|
167
|
+
return result;
|
|
168
|
+
},
|
|
169
|
+
|
|
170
|
+
unwrap(message: ListValue): Array<any> {
|
|
171
|
+
if (message?.hasOwnProperty("values") && globalThis.Array.isArray(message.values)) {
|
|
172
|
+
return message.values.map(Value.unwrap);
|
|
173
|
+
} else {
|
|
174
|
+
return message as any;
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
wrappers[".google.protobuf.Struct"] = { fromObject: Struct.wrap, toObject: Struct.unwrap } as any;
|