@wenlarge/ostrol-communication 0.5.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.
Files changed (53) hide show
  1. package/dist/config/astro-engine-config.d.ts +1 -0
  2. package/dist/config/astro-engine-config.js +4 -0
  3. package/dist/config/astrology-config.d.ts +1 -0
  4. package/dist/config/astrology-config.js +4 -0
  5. package/dist/config/auth-config.d.ts +1 -0
  6. package/dist/config/auth-config.js +4 -0
  7. package/dist/config/billing-config.d.ts +1 -0
  8. package/dist/config/billing-config.js +4 -0
  9. package/dist/generated/astro_engine.d.ts +93 -0
  10. package/dist/generated/astro_engine.js +30 -0
  11. package/dist/generated/astrology.d.ts +92 -0
  12. package/dist/generated/astrology.js +50 -0
  13. package/dist/generated/auth.d.ts +131 -0
  14. package/dist/generated/auth.js +53 -0
  15. package/dist/generated/billing.d.ts +62 -0
  16. package/dist/generated/billing.js +41 -0
  17. package/dist/generated/common.d.ts +17 -0
  18. package/dist/generated/common.js +18 -0
  19. package/dist/generated/google/protobuf/empty.d.ts +13 -0
  20. package/dist/generated/google/protobuf/empty.js +11 -0
  21. package/dist/generated/google/protobuf/struct.d.ts +82 -0
  22. package/dist/generated/google/protobuf/struct.js +117 -0
  23. package/dist/grpc-client/grpc-client.module.d.ts +10 -0
  24. package/dist/grpc-client/grpc-client.module.js +68 -0
  25. package/dist/grpc-client/index.d.ts +1 -0
  26. package/dist/grpc-client/index.js +17 -0
  27. package/dist/helpers/helper.d.ts +12 -0
  28. package/dist/helpers/helper.js +31 -0
  29. package/dist/helpers/struct-to-json.d.ts +3 -0
  30. package/dist/helpers/struct-to-json.js +46 -0
  31. package/dist/index.d.ts +18 -0
  32. package/dist/index.js +69 -0
  33. package/dist/kafka/commit-kafka-offset.d.ts +16 -0
  34. package/dist/kafka/commit-kafka-offset.js +14 -0
  35. package/dist/kafka/kafka-topics.d.ts +13 -0
  36. package/dist/kafka/kafka-topics.js +19 -0
  37. package/dist/kafka/payloads.d.ts +67 -0
  38. package/dist/kafka/payloads.js +3 -0
  39. package/dist/pagination/cursor.d.ts +17 -0
  40. package/dist/pagination/cursor.js +42 -0
  41. package/package.json +49 -0
  42. package/proto/astro_engine.proto +60 -0
  43. package/proto/astrology.proto +78 -0
  44. package/proto/auth.proto +123 -0
  45. package/proto/billing.proto +56 -0
  46. package/proto/common.proto +17 -0
  47. package/src/generated/astro_engine.ts +144 -0
  48. package/src/generated/astrology.ts +135 -0
  49. package/src/generated/auth.ts +215 -0
  50. package/src/generated/billing.ts +117 -0
  51. package/src/generated/common.ts +28 -0
  52. package/src/generated/google/protobuf/empty.ts +23 -0
  53. package/src/generated/google/protobuf/struct.ts +179 -0
@@ -0,0 +1,135 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v1.181.2
4
+ // protoc v3.21.5
5
+ // source: astrology.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 { CursorRequest, Plan } from "./common";
13
+ import { Struct } from "./google/protobuf/struct";
14
+
15
+ export const protobufPackage = "astrology";
16
+
17
+ export enum PostType {
18
+ POST_TYPE_UNSPECIFIED = "POST_TYPE_UNSPECIFIED",
19
+ /** GENERAL - userId empty; canonical English post + per-language translation rows */
20
+ GENERAL = "GENERAL",
21
+ DAILY = "DAILY",
22
+ WEEKLY = "WEEKLY",
23
+ MONTHLY = "MONTHLY",
24
+ TRANSIT_ALERT = "TRANSIT_ALERT",
25
+ UNRECOGNIZED = "UNRECOGNIZED",
26
+ }
27
+
28
+ export enum CalculationStatus {
29
+ CALCULATION_STATUS_UNSPECIFIED = "CALCULATION_STATUS_UNSPECIFIED",
30
+ PENDING = "PENDING",
31
+ IN_PROGRESS = "IN_PROGRESS",
32
+ DONE = "DONE",
33
+ FAILED = "FAILED",
34
+ UNRECOGNIZED = "UNRECOGNIZED",
35
+ }
36
+
37
+ export interface Post {
38
+ id: string;
39
+ /** empty => general */
40
+ userId: string;
41
+ type: PostType;
42
+ title: string;
43
+ content: string;
44
+ /** general posts: "en"; personal posts: user's language at generation time */
45
+ language: string;
46
+ plan: Plan;
47
+ shouldNotify: boolean;
48
+ /** ISO 8601 */
49
+ publishedAt: string;
50
+ /** ISO 8601 */
51
+ createdAt: string;
52
+ /** translations: id of the canonical (English) post; empty on canonical/personal posts */
53
+ sourcePostId: string;
54
+ }
55
+
56
+ export interface NatalChart {
57
+ id: string;
58
+ userId: string;
59
+ rawData?: { [key: string]: any } | undefined;
60
+ natalPoints?: { [key: string]: any } | undefined;
61
+ status: CalculationStatus;
62
+ summary: string;
63
+ deepSummary: string;
64
+ personalityScores?: { [key: string]: any } | undefined;
65
+ personalitySummary: string;
66
+ }
67
+
68
+ /** GENERAL feed: userId left empty. Personal types: userId set (caller). */
69
+ export interface FindManyPostRequest {
70
+ page?: CursorRequest | undefined;
71
+ type: PostType;
72
+ userId: string;
73
+ /** GENERAL only: language variant to return; empty => "en" */
74
+ language: string;
75
+ }
76
+
77
+ export interface FindManyPostResponse {
78
+ data: Post[];
79
+ nextCursor: string;
80
+ hasMore: boolean;
81
+ }
82
+
83
+ export interface FindFirstPostRequest {
84
+ /** canonical post id (GENERAL translations are addressed via their canonical id) */
85
+ id: string;
86
+ /** GENERAL only: preferred translation; falls back to the canonical post when absent */
87
+ language: string;
88
+ }
89
+
90
+ export interface GetNatalChartRequest {
91
+ userId: string;
92
+ }
93
+
94
+ export const ASTROLOGY_PACKAGE_NAME = "astrology";
95
+
96
+ wrappers[".google.protobuf.Struct"] = { fromObject: Struct.wrap, toObject: Struct.unwrap } as any;
97
+
98
+ export interface AstrologyServiceClient {
99
+ findManyPost(request: FindManyPostRequest, metadata?: Metadata): Observable<FindManyPostResponse>;
100
+
101
+ findFirstPost(request: FindFirstPostRequest, metadata?: Metadata): Observable<Post>;
102
+
103
+ getNatalChart(request: GetNatalChartRequest, metadata?: Metadata): Observable<NatalChart>;
104
+ }
105
+
106
+ export interface AstrologyServiceController {
107
+ findManyPost(
108
+ request: FindManyPostRequest,
109
+ metadata?: Metadata,
110
+ ): Promise<FindManyPostResponse> | Observable<FindManyPostResponse> | FindManyPostResponse;
111
+
112
+ findFirstPost(request: FindFirstPostRequest, metadata?: Metadata): Promise<Post> | Observable<Post> | Post;
113
+
114
+ getNatalChart(
115
+ request: GetNatalChartRequest,
116
+ metadata?: Metadata,
117
+ ): Promise<NatalChart> | Observable<NatalChart> | NatalChart;
118
+ }
119
+
120
+ export function AstrologyServiceControllerMethods() {
121
+ return function (constructor: Function) {
122
+ const grpcMethods: string[] = ["findManyPost", "findFirstPost", "getNatalChart"];
123
+ for (const method of grpcMethods) {
124
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
125
+ GrpcMethod("AstrologyService", method)(constructor.prototype[method], method, descriptor);
126
+ }
127
+ const grpcStreamMethods: string[] = [];
128
+ for (const method of grpcStreamMethods) {
129
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
130
+ GrpcStreamMethod("AstrologyService", method)(constructor.prototype[method], method, descriptor);
131
+ }
132
+ };
133
+ }
134
+
135
+ export const ASTROLOGY_SERVICE_NAME = "AstrologyService";
@@ -0,0 +1,215 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v1.181.2
4
+ // protoc v3.21.5
5
+ // source: auth.proto
6
+
7
+ /* eslint-disable */
8
+ import { Metadata } from "@grpc/grpc-js";
9
+ import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
10
+ import { Observable } from "rxjs";
11
+ import { Plan } from "./common";
12
+ import { Empty } from "./google/protobuf/empty";
13
+
14
+ export const protobufPackage = "auth";
15
+
16
+ export enum OAuthProvider {
17
+ OAUTH_PROVIDER_UNSPECIFIED = "OAUTH_PROVIDER_UNSPECIFIED",
18
+ GOOGLE = "GOOGLE",
19
+ MICROSOFT = "MICROSOFT",
20
+ UNRECOGNIZED = "UNRECOGNIZED",
21
+ }
22
+
23
+ export enum UserStatus {
24
+ USER_STATUS_UNSPECIFIED = "USER_STATUS_UNSPECIFIED",
25
+ ACTIVE = "ACTIVE",
26
+ SUSPENDED = "SUSPENDED",
27
+ DELETED = "DELETED",
28
+ UNRECOGNIZED = "UNRECOGNIZED",
29
+ }
30
+
31
+ export interface User {
32
+ id: string;
33
+ email: string;
34
+ emailVerified: boolean;
35
+ name: string;
36
+ /** ISO 8601, empty if unset */
37
+ birthAt: string;
38
+ /** BCP-47 */
39
+ language: string;
40
+ birthLat: number;
41
+ birthLng: number;
42
+ birthLocationName: string;
43
+ plan: Plan;
44
+ status: UserStatus;
45
+ linkedProviders: OAuthProvider[];
46
+ /**
47
+ * Current IANA timezone (device-reported, e.g. "Europe/Istanbul"), empty if
48
+ * unset. NOT the birth timezone — that stays server-derived from lat/lng.
49
+ */
50
+ timezone: string;
51
+ }
52
+
53
+ export interface AuthResponse {
54
+ /** RS256 JWT, short TTL */
55
+ accessToken: string;
56
+ /** revocable, Redis-backed */
57
+ refreshToken: string;
58
+ user?: User | undefined;
59
+ }
60
+
61
+ export interface RegisterRequest {
62
+ name: string;
63
+ email: string;
64
+ password: string;
65
+ language: string;
66
+ /** current IANA timezone (device-reported), optional */
67
+ timezone: string;
68
+ }
69
+
70
+ export interface LoginRequest {
71
+ email: string;
72
+ password: string;
73
+ }
74
+
75
+ export interface OAuthLoginRequest {
76
+ provider: OAuthProvider;
77
+ providerToken: string;
78
+ language: string;
79
+ /** current IANA timezone (device-reported), optional */
80
+ timezone: string;
81
+ }
82
+
83
+ export interface RefreshTokenRequest {
84
+ refreshToken: string;
85
+ }
86
+
87
+ export interface UpdateProfileRequest {
88
+ /**
89
+ * Partial update: every field except userId is `optional` so absence is
90
+ * distinguishable from proto3 defaults ("" / 0). Without presence tracking a
91
+ * language-only PATCH used to arrive with birthLat=0/birthLng=0 and silently
92
+ * overwrite the stored birth coordinates.
93
+ */
94
+ userId: string;
95
+ name?: string | undefined;
96
+ birthAt?: string | undefined;
97
+ birthLat?: number | undefined;
98
+ birthLng?: number | undefined;
99
+ birthLocationName?: string | undefined;
100
+ language?:
101
+ | string
102
+ | undefined;
103
+ /** current IANA timezone; never triggers a natal recalc */
104
+ timezone?: string | undefined;
105
+ }
106
+
107
+ export interface OAuthLinkRequest {
108
+ userId: string;
109
+ provider: OAuthProvider;
110
+ providerToken: string;
111
+ }
112
+
113
+ export interface OAuthUnlinkRequest {
114
+ userId: string;
115
+ provider: OAuthProvider;
116
+ }
117
+
118
+ export interface GetUserRequest {
119
+ userId: string;
120
+ }
121
+
122
+ export interface UpdateUserPlanRequest {
123
+ userId: string;
124
+ plan: Plan;
125
+ }
126
+
127
+ export interface DeleteAccountRequest {
128
+ userId: string;
129
+ }
130
+
131
+ export const AUTH_PACKAGE_NAME = "auth";
132
+
133
+ export interface AuthServiceClient {
134
+ register(request: RegisterRequest, metadata?: Metadata): Observable<AuthResponse>;
135
+
136
+ login(request: LoginRequest, metadata?: Metadata): Observable<AuthResponse>;
137
+
138
+ oAuthLogin(request: OAuthLoginRequest, metadata?: Metadata): Observable<AuthResponse>;
139
+
140
+ refreshToken(request: RefreshTokenRequest, metadata?: Metadata): Observable<AuthResponse>;
141
+
142
+ updateProfile(request: UpdateProfileRequest, metadata?: Metadata): Observable<AuthResponse>;
143
+
144
+ oAuthLink(request: OAuthLinkRequest, metadata?: Metadata): Observable<Empty>;
145
+
146
+ oAuthUnlink(request: OAuthUnlinkRequest, metadata?: Metadata): Observable<Empty>;
147
+
148
+ getUser(request: GetUserRequest, metadata?: Metadata): Observable<User>;
149
+
150
+ updateUserPlan(request: UpdateUserPlanRequest, metadata?: Metadata): Observable<Empty>;
151
+
152
+ deleteAccount(request: DeleteAccountRequest, metadata?: Metadata): Observable<Empty>;
153
+ }
154
+
155
+ export interface AuthServiceController {
156
+ register(
157
+ request: RegisterRequest,
158
+ metadata?: Metadata,
159
+ ): Promise<AuthResponse> | Observable<AuthResponse> | AuthResponse;
160
+
161
+ login(request: LoginRequest, metadata?: Metadata): Promise<AuthResponse> | Observable<AuthResponse> | AuthResponse;
162
+
163
+ oAuthLogin(
164
+ request: OAuthLoginRequest,
165
+ metadata?: Metadata,
166
+ ): Promise<AuthResponse> | Observable<AuthResponse> | AuthResponse;
167
+
168
+ refreshToken(
169
+ request: RefreshTokenRequest,
170
+ metadata?: Metadata,
171
+ ): Promise<AuthResponse> | Observable<AuthResponse> | AuthResponse;
172
+
173
+ updateProfile(
174
+ request: UpdateProfileRequest,
175
+ metadata?: Metadata,
176
+ ): Promise<AuthResponse> | Observable<AuthResponse> | AuthResponse;
177
+
178
+ oAuthLink(request: OAuthLinkRequest, metadata?: Metadata): void;
179
+
180
+ oAuthUnlink(request: OAuthUnlinkRequest, metadata?: Metadata): void;
181
+
182
+ getUser(request: GetUserRequest, metadata?: Metadata): Promise<User> | Observable<User> | User;
183
+
184
+ updateUserPlan(request: UpdateUserPlanRequest, metadata?: Metadata): void;
185
+
186
+ deleteAccount(request: DeleteAccountRequest, metadata?: Metadata): void;
187
+ }
188
+
189
+ export function AuthServiceControllerMethods() {
190
+ return function (constructor: Function) {
191
+ const grpcMethods: string[] = [
192
+ "register",
193
+ "login",
194
+ "oAuthLogin",
195
+ "refreshToken",
196
+ "updateProfile",
197
+ "oAuthLink",
198
+ "oAuthUnlink",
199
+ "getUser",
200
+ "updateUserPlan",
201
+ "deleteAccount",
202
+ ];
203
+ for (const method of grpcMethods) {
204
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
205
+ GrpcMethod("AuthService", method)(constructor.prototype[method], method, descriptor);
206
+ }
207
+ const grpcStreamMethods: string[] = [];
208
+ for (const method of grpcStreamMethods) {
209
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
210
+ GrpcStreamMethod("AuthService", method)(constructor.prototype[method], method, descriptor);
211
+ }
212
+ };
213
+ }
214
+
215
+ export const AUTH_SERVICE_NAME = "AuthService";
@@ -0,0 +1,117 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v1.181.2
4
+ // protoc v3.21.5
5
+ // source: billing.proto
6
+
7
+ /* eslint-disable */
8
+ import { Metadata } from "@grpc/grpc-js";
9
+ import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
10
+ import { Observable } from "rxjs";
11
+ import { Plan } from "./common";
12
+ import { Empty } from "./google/protobuf/empty";
13
+
14
+ export const protobufPackage = "billing";
15
+
16
+ export enum SubscriptionStatus {
17
+ SUBSCRIPTION_STATUS_UNSPECIFIED = "SUBSCRIPTION_STATUS_UNSPECIFIED",
18
+ ACTIVE = "ACTIVE",
19
+ PAST_DUE = "PAST_DUE",
20
+ CANCELLED = "CANCELLED",
21
+ EXPIRED = "EXPIRED",
22
+ UNRECOGNIZED = "UNRECOGNIZED",
23
+ }
24
+
25
+ export interface Subscription {
26
+ id: string;
27
+ userId: string;
28
+ plan: Plan;
29
+ status: SubscriptionStatus;
30
+ cancelAtPeriodEnd: boolean;
31
+ /** ISO 8601 */
32
+ currentPeriodStart: string;
33
+ /** ISO 8601 */
34
+ currentPeriodEnd: string;
35
+ }
36
+
37
+ export interface GetSubscriptionRequest {
38
+ userId: string;
39
+ }
40
+
41
+ export interface CreateCheckoutSessionRequest {
42
+ userId: string;
43
+ }
44
+
45
+ export interface CreatePortalSessionRequest {
46
+ userId: string;
47
+ }
48
+
49
+ export interface CheckoutSession {
50
+ /** Stripe checkout page */
51
+ checkoutUrl: string;
52
+ }
53
+
54
+ export interface PortalSession {
55
+ /** Stripe customer portal */
56
+ portalUrl: string;
57
+ }
58
+
59
+ export interface WebhookEventRequest {
60
+ /** raw Stripe webhook body */
61
+ payload: Uint8Array;
62
+ /** Stripe-Signature header */
63
+ signature: string;
64
+ }
65
+
66
+ export const BILLING_PACKAGE_NAME = "billing";
67
+
68
+ export interface BillingServiceClient {
69
+ getSubscription(request: GetSubscriptionRequest, metadata?: Metadata): Observable<Subscription>;
70
+
71
+ createCheckoutSession(request: CreateCheckoutSessionRequest, metadata?: Metadata): Observable<CheckoutSession>;
72
+
73
+ createPortalSession(request: CreatePortalSessionRequest, metadata?: Metadata): Observable<PortalSession>;
74
+
75
+ handleWebhookEvent(request: WebhookEventRequest, metadata?: Metadata): Observable<Empty>;
76
+ }
77
+
78
+ export interface BillingServiceController {
79
+ getSubscription(
80
+ request: GetSubscriptionRequest,
81
+ metadata?: Metadata,
82
+ ): Promise<Subscription> | Observable<Subscription> | Subscription;
83
+
84
+ createCheckoutSession(
85
+ request: CreateCheckoutSessionRequest,
86
+ metadata?: Metadata,
87
+ ): Promise<CheckoutSession> | Observable<CheckoutSession> | CheckoutSession;
88
+
89
+ createPortalSession(
90
+ request: CreatePortalSessionRequest,
91
+ metadata?: Metadata,
92
+ ): Promise<PortalSession> | Observable<PortalSession> | PortalSession;
93
+
94
+ handleWebhookEvent(request: WebhookEventRequest, metadata?: Metadata): void;
95
+ }
96
+
97
+ export function BillingServiceControllerMethods() {
98
+ return function (constructor: Function) {
99
+ const grpcMethods: string[] = [
100
+ "getSubscription",
101
+ "createCheckoutSession",
102
+ "createPortalSession",
103
+ "handleWebhookEvent",
104
+ ];
105
+ for (const method of grpcMethods) {
106
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
107
+ GrpcMethod("BillingService", method)(constructor.prototype[method], method, descriptor);
108
+ }
109
+ const grpcStreamMethods: string[] = [];
110
+ for (const method of grpcStreamMethods) {
111
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
112
+ GrpcStreamMethod("BillingService", method)(constructor.prototype[method], method, descriptor);
113
+ }
114
+ };
115
+ }
116
+
117
+ export const BILLING_SERVICE_NAME = "BillingService";
@@ -0,0 +1,28 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v1.181.2
4
+ // protoc v3.21.5
5
+ // source: common.proto
6
+
7
+ /* eslint-disable */
8
+
9
+ export const protobufPackage = "common";
10
+
11
+ export enum Plan {
12
+ PLAN_UNSPECIFIED = "PLAN_UNSPECIFIED",
13
+ FREE = "FREE",
14
+ PREMIUM = "PREMIUM",
15
+ UNRECOGNIZED = "UNRECOGNIZED",
16
+ }
17
+
18
+ /**
19
+ * Keyset (seek) cursor pagination request. `cursor` is an opaque base64 of the
20
+ * last row's sort key ({ v, id }); empty on the first page. `limit` is capped
21
+ * server-side (e.g. <= 50). See cursor.ts encode/decode helpers.
22
+ */
23
+ export interface CursorRequest {
24
+ cursor: string;
25
+ limit: number;
26
+ }
27
+
28
+ export const COMMON_PACKAGE_NAME = "common";
@@ -0,0 +1,23 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v1.181.2
4
+ // protoc v3.21.5
5
+ // source: google/protobuf/empty.proto
6
+
7
+ /* eslint-disable */
8
+
9
+ export const protobufPackage = "google.protobuf";
10
+
11
+ /**
12
+ * A generic empty message that you can re-use to avoid defining duplicated
13
+ * empty messages in your APIs. A typical example is to use it as the request
14
+ * or the response type of an API method. For instance:
15
+ *
16
+ * service Foo {
17
+ * rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
18
+ * }
19
+ */
20
+ export interface Empty {
21
+ }
22
+
23
+ export const GOOGLE_PROTOBUF_PACKAGE_NAME = "google.protobuf";
@@ -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 v3.21.5
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;