macrocosmos 1.2.2 → 1.2.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.
@@ -1,99 +1,76 @@
1
- export interface IGetUsageRequest {
2
- productType?: string;
1
+ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
2
+ import { type CallOptions, ChannelCredentials, Client, type ClientOptions, type ClientUnaryCall, type handleUnaryCall, Metadata, type ServiceError, type UntypedServiceImplementation } from "@grpc/grpc-js";
3
+ export declare const protobufPackage = "billing.v1";
4
+ /** GetUsageRequest is the request message for getting the usage of the user's credits */
5
+ export interface GetUsageRequest {
6
+ /** product_type: the type of the product (i.e. "gravity") */
7
+ productType?: string | undefined;
3
8
  }
4
- export interface IBillingRate {
5
- rateType?: string;
6
- unitSize?: number;
7
- unitType?: string;
8
- pricePerUnit?: number;
9
- currency?: string;
9
+ /** ProductPlan is details of the subscription plan for a product */
10
+ export interface BillingRate {
11
+ /** product_type: the type of the product (i.e. "gravity") */
12
+ rateType: string;
13
+ /** unit_size: the size of the unit of the subscription (e.g. 1000, 10000, 100000) */
14
+ unitSize: number;
15
+ /** unit_type: the type of the unit of the subscription (i.e. "rows") */
16
+ unitType: string;
17
+ /** price_per_unit: the price per unit of the subscription */
18
+ pricePerUnit: number;
19
+ /** currency: the currency of the subscription */
20
+ currency: string;
10
21
  }
11
- export interface IGetUsageResponse {
12
- availableCredits?: number;
13
- usedCredits?: number;
14
- remainingCredits?: number;
15
- billingRates?: IBillingRate[];
22
+ /** GetUsageResponse is the response message for getting the usage of the user's credits */
23
+ export interface GetUsageResponse {
24
+ /** available_credits: the number of credits available to the user */
25
+ availableCredits: number;
26
+ /** used_credits: the number of credits used by the user */
27
+ usedCredits: number;
28
+ /** remaining_credits: the number of credits remaining to the user */
29
+ remainingCredits: number;
30
+ /** subscription: the subscription that the user has */
31
+ billingRates: BillingRate[];
16
32
  }
17
- export interface IBillingServiceClient {
18
- GetUsage(request: IGetUsageRequest): Promise<IGetUsageResponse>;
19
- GetUsage(request: IGetUsageRequest, callback: (error: Error | null, response: IGetUsageResponse) => void): void;
20
- }
21
- export declare const billing: {
22
- options: {
23
- syntax: string;
24
- };
25
- nested: {
26
- billing: {
27
- nested: {
28
- v1: {
29
- options: {
30
- go_package: string;
31
- };
32
- nested: {
33
- BillingService: {
34
- methods: {
35
- GetUsage: {
36
- requestType: string;
37
- responseType: string;
38
- };
39
- };
40
- };
41
- GetUsageRequest: {
42
- fields: {
43
- productType: {
44
- type: string;
45
- id: number;
46
- };
47
- };
48
- };
49
- BillingRate: {
50
- fields: {
51
- rateType: {
52
- type: string;
53
- id: number;
54
- };
55
- unitSize: {
56
- type: string;
57
- id: number;
58
- };
59
- unitType: {
60
- type: string;
61
- id: number;
62
- };
63
- pricePerUnit: {
64
- type: string;
65
- id: number;
66
- };
67
- currency: {
68
- type: string;
69
- id: number;
70
- };
71
- };
72
- };
73
- GetUsageResponse: {
74
- fields: {
75
- availableCredits: {
76
- type: string;
77
- id: number;
78
- };
79
- usedCredits: {
80
- type: string;
81
- id: number;
82
- };
83
- remainingCredits: {
84
- type: string;
85
- id: number;
86
- };
87
- billingRates: {
88
- rule: string;
89
- type: string;
90
- id: number;
91
- };
92
- };
93
- };
94
- };
95
- };
96
- };
97
- };
33
+ export declare const GetUsageRequest: MessageFns<GetUsageRequest>;
34
+ export declare const BillingRate: MessageFns<BillingRate>;
35
+ export declare const GetUsageResponse: MessageFns<GetUsageResponse>;
36
+ export type BillingServiceService = typeof BillingServiceService;
37
+ export declare const BillingServiceService: {
38
+ /** Get the usage of the user's credits */
39
+ readonly getUsage: {
40
+ readonly path: "/billing.v1.BillingService/GetUsage";
41
+ readonly requestStream: false;
42
+ readonly responseStream: false;
43
+ readonly requestSerialize: (value: GetUsageRequest) => Buffer<ArrayBuffer>;
44
+ readonly requestDeserialize: (value: Buffer) => GetUsageRequest;
45
+ readonly responseSerialize: (value: GetUsageResponse) => Buffer<ArrayBuffer>;
46
+ readonly responseDeserialize: (value: Buffer) => GetUsageResponse;
98
47
  };
99
48
  };
49
+ export interface BillingServiceServer extends UntypedServiceImplementation {
50
+ /** Get the usage of the user's credits */
51
+ getUsage: handleUnaryCall<GetUsageRequest, GetUsageResponse>;
52
+ }
53
+ export interface BillingServiceClient extends Client {
54
+ /** Get the usage of the user's credits */
55
+ getUsage(request: GetUsageRequest, callback: (error: ServiceError | null, response: GetUsageResponse) => void): ClientUnaryCall;
56
+ getUsage(request: GetUsageRequest, metadata: Metadata, callback: (error: ServiceError | null, response: GetUsageResponse) => void): ClientUnaryCall;
57
+ getUsage(request: GetUsageRequest, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: GetUsageResponse) => void): ClientUnaryCall;
58
+ }
59
+ export declare const BillingServiceClient: {
60
+ new (address: string, credentials: ChannelCredentials, options?: Partial<ClientOptions>): BillingServiceClient;
61
+ service: typeof BillingServiceService;
62
+ serviceName: string;
63
+ };
64
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
65
+ export type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
66
+ [K in keyof T]?: DeepPartial<T[K]>;
67
+ } : Partial<T>;
68
+ export interface MessageFns<T> {
69
+ encode(message: T, writer?: BinaryWriter): BinaryWriter;
70
+ decode(input: BinaryReader | Uint8Array, length?: number): T;
71
+ fromJSON(object: any): T;
72
+ toJSON(message: T): unknown;
73
+ create(base?: DeepPartial<T>): T;
74
+ fromPartial(object: DeepPartial<T>): T;
75
+ }
76
+ export {};
@@ -1,84 +1,332 @@
1
1
  "use strict";
2
- // Generated from billing/v1/billing.proto
2
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
3
+ // versions:
4
+ // protoc-gen-ts_proto v2.7.0
5
+ // protoc v3.20.3
6
+ // source: billing/v1/billing.proto
3
7
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.billing = void 0;
5
- // Original protobuf JSON schema
6
- exports.billing = {
7
- options: {
8
- syntax: "proto3",
9
- },
10
- nested: {
11
- billing: {
12
- nested: {
13
- v1: {
14
- options: {
15
- go_package: "macrocosm-os/rift/constellation_api/gen/billing/v1",
16
- },
17
- nested: {
18
- BillingService: {
19
- methods: {
20
- GetUsage: {
21
- requestType: "GetUsageRequest",
22
- responseType: "GetUsageResponse",
23
- },
24
- },
25
- },
26
- GetUsageRequest: {
27
- fields: {
28
- productType: {
29
- type: "string",
30
- id: 1,
31
- },
32
- },
33
- },
34
- BillingRate: {
35
- fields: {
36
- rateType: {
37
- type: "string",
38
- id: 1,
39
- },
40
- unitSize: {
41
- type: "int64",
42
- id: 2,
43
- },
44
- unitType: {
45
- type: "string",
46
- id: 3,
47
- },
48
- pricePerUnit: {
49
- type: "float",
50
- id: 4,
51
- },
52
- currency: {
53
- type: "string",
54
- id: 5,
55
- },
56
- },
57
- },
58
- GetUsageResponse: {
59
- fields: {
60
- availableCredits: {
61
- type: "float",
62
- id: 1,
63
- },
64
- usedCredits: {
65
- type: "float",
66
- id: 2,
67
- },
68
- remainingCredits: {
69
- type: "float",
70
- id: 3,
71
- },
72
- billingRates: {
73
- rule: "repeated",
74
- type: "BillingRate",
75
- id: 4,
76
- },
77
- },
78
- },
79
- },
80
- },
81
- },
82
- },
8
+ exports.BillingServiceClient = exports.BillingServiceService = exports.GetUsageResponse = exports.BillingRate = exports.GetUsageRequest = exports.protobufPackage = void 0;
9
+ /* eslint-disable */
10
+ const wire_1 = require("@bufbuild/protobuf/wire");
11
+ const grpc_js_1 = require("@grpc/grpc-js");
12
+ exports.protobufPackage = "billing.v1";
13
+ function createBaseGetUsageRequest() {
14
+ return { productType: undefined };
15
+ }
16
+ exports.GetUsageRequest = {
17
+ encode(message, writer = new wire_1.BinaryWriter()) {
18
+ if (message.productType !== undefined) {
19
+ writer.uint32(10).string(message.productType);
20
+ }
21
+ return writer;
22
+ },
23
+ decode(input, length) {
24
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
25
+ let end = length === undefined ? reader.len : reader.pos + length;
26
+ const message = createBaseGetUsageRequest();
27
+ while (reader.pos < end) {
28
+ const tag = reader.uint32();
29
+ switch (tag >>> 3) {
30
+ case 1: {
31
+ if (tag !== 10) {
32
+ break;
33
+ }
34
+ message.productType = reader.string();
35
+ continue;
36
+ }
37
+ }
38
+ if ((tag & 7) === 4 || tag === 0) {
39
+ break;
40
+ }
41
+ reader.skip(tag & 7);
42
+ }
43
+ return message;
44
+ },
45
+ fromJSON(object) {
46
+ return {
47
+ productType: isSet(object.productType)
48
+ ? globalThis.String(object.productType)
49
+ : undefined,
50
+ };
51
+ },
52
+ toJSON(message) {
53
+ const obj = {};
54
+ if (message.productType !== undefined) {
55
+ obj.productType = message.productType;
56
+ }
57
+ return obj;
58
+ },
59
+ create(base) {
60
+ return exports.GetUsageRequest.fromPartial(base ?? {});
61
+ },
62
+ fromPartial(object) {
63
+ const message = createBaseGetUsageRequest();
64
+ message.productType = object.productType ?? undefined;
65
+ return message;
66
+ },
67
+ };
68
+ function createBaseBillingRate() {
69
+ return {
70
+ rateType: "",
71
+ unitSize: 0,
72
+ unitType: "",
73
+ pricePerUnit: 0,
74
+ currency: "",
75
+ };
76
+ }
77
+ exports.BillingRate = {
78
+ encode(message, writer = new wire_1.BinaryWriter()) {
79
+ if (message.rateType !== "") {
80
+ writer.uint32(10).string(message.rateType);
81
+ }
82
+ if (message.unitSize !== 0) {
83
+ writer.uint32(16).int64(message.unitSize);
84
+ }
85
+ if (message.unitType !== "") {
86
+ writer.uint32(26).string(message.unitType);
87
+ }
88
+ if (message.pricePerUnit !== 0) {
89
+ writer.uint32(37).float(message.pricePerUnit);
90
+ }
91
+ if (message.currency !== "") {
92
+ writer.uint32(42).string(message.currency);
93
+ }
94
+ return writer;
95
+ },
96
+ decode(input, length) {
97
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
98
+ let end = length === undefined ? reader.len : reader.pos + length;
99
+ const message = createBaseBillingRate();
100
+ while (reader.pos < end) {
101
+ const tag = reader.uint32();
102
+ switch (tag >>> 3) {
103
+ case 1: {
104
+ if (tag !== 10) {
105
+ break;
106
+ }
107
+ message.rateType = reader.string();
108
+ continue;
109
+ }
110
+ case 2: {
111
+ if (tag !== 16) {
112
+ break;
113
+ }
114
+ message.unitSize = longToNumber(reader.int64());
115
+ continue;
116
+ }
117
+ case 3: {
118
+ if (tag !== 26) {
119
+ break;
120
+ }
121
+ message.unitType = reader.string();
122
+ continue;
123
+ }
124
+ case 4: {
125
+ if (tag !== 37) {
126
+ break;
127
+ }
128
+ message.pricePerUnit = reader.float();
129
+ continue;
130
+ }
131
+ case 5: {
132
+ if (tag !== 42) {
133
+ break;
134
+ }
135
+ message.currency = reader.string();
136
+ continue;
137
+ }
138
+ }
139
+ if ((tag & 7) === 4 || tag === 0) {
140
+ break;
141
+ }
142
+ reader.skip(tag & 7);
143
+ }
144
+ return message;
145
+ },
146
+ fromJSON(object) {
147
+ return {
148
+ rateType: isSet(object.rateType)
149
+ ? globalThis.String(object.rateType)
150
+ : "",
151
+ unitSize: isSet(object.unitSize) ? globalThis.Number(object.unitSize) : 0,
152
+ unitType: isSet(object.unitType)
153
+ ? globalThis.String(object.unitType)
154
+ : "",
155
+ pricePerUnit: isSet(object.pricePerUnit)
156
+ ? globalThis.Number(object.pricePerUnit)
157
+ : 0,
158
+ currency: isSet(object.currency)
159
+ ? globalThis.String(object.currency)
160
+ : "",
161
+ };
162
+ },
163
+ toJSON(message) {
164
+ const obj = {};
165
+ if (message.rateType !== "") {
166
+ obj.rateType = message.rateType;
167
+ }
168
+ if (message.unitSize !== 0) {
169
+ obj.unitSize = Math.round(message.unitSize);
170
+ }
171
+ if (message.unitType !== "") {
172
+ obj.unitType = message.unitType;
173
+ }
174
+ if (message.pricePerUnit !== 0) {
175
+ obj.pricePerUnit = message.pricePerUnit;
176
+ }
177
+ if (message.currency !== "") {
178
+ obj.currency = message.currency;
179
+ }
180
+ return obj;
181
+ },
182
+ create(base) {
183
+ return exports.BillingRate.fromPartial(base ?? {});
184
+ },
185
+ fromPartial(object) {
186
+ const message = createBaseBillingRate();
187
+ message.rateType = object.rateType ?? "";
188
+ message.unitSize = object.unitSize ?? 0;
189
+ message.unitType = object.unitType ?? "";
190
+ message.pricePerUnit = object.pricePerUnit ?? 0;
191
+ message.currency = object.currency ?? "";
192
+ return message;
193
+ },
194
+ };
195
+ function createBaseGetUsageResponse() {
196
+ return {
197
+ availableCredits: 0,
198
+ usedCredits: 0,
199
+ remainingCredits: 0,
200
+ billingRates: [],
201
+ };
202
+ }
203
+ exports.GetUsageResponse = {
204
+ encode(message, writer = new wire_1.BinaryWriter()) {
205
+ if (message.availableCredits !== 0) {
206
+ writer.uint32(13).float(message.availableCredits);
207
+ }
208
+ if (message.usedCredits !== 0) {
209
+ writer.uint32(21).float(message.usedCredits);
210
+ }
211
+ if (message.remainingCredits !== 0) {
212
+ writer.uint32(29).float(message.remainingCredits);
213
+ }
214
+ for (const v of message.billingRates) {
215
+ exports.BillingRate.encode(v, writer.uint32(34).fork()).join();
216
+ }
217
+ return writer;
218
+ },
219
+ decode(input, length) {
220
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
221
+ let end = length === undefined ? reader.len : reader.pos + length;
222
+ const message = createBaseGetUsageResponse();
223
+ while (reader.pos < end) {
224
+ const tag = reader.uint32();
225
+ switch (tag >>> 3) {
226
+ case 1: {
227
+ if (tag !== 13) {
228
+ break;
229
+ }
230
+ message.availableCredits = reader.float();
231
+ continue;
232
+ }
233
+ case 2: {
234
+ if (tag !== 21) {
235
+ break;
236
+ }
237
+ message.usedCredits = reader.float();
238
+ continue;
239
+ }
240
+ case 3: {
241
+ if (tag !== 29) {
242
+ break;
243
+ }
244
+ message.remainingCredits = reader.float();
245
+ continue;
246
+ }
247
+ case 4: {
248
+ if (tag !== 34) {
249
+ break;
250
+ }
251
+ message.billingRates.push(exports.BillingRate.decode(reader, reader.uint32()));
252
+ continue;
253
+ }
254
+ }
255
+ if ((tag & 7) === 4 || tag === 0) {
256
+ break;
257
+ }
258
+ reader.skip(tag & 7);
259
+ }
260
+ return message;
261
+ },
262
+ fromJSON(object) {
263
+ return {
264
+ availableCredits: isSet(object.availableCredits)
265
+ ? globalThis.Number(object.availableCredits)
266
+ : 0,
267
+ usedCredits: isSet(object.usedCredits)
268
+ ? globalThis.Number(object.usedCredits)
269
+ : 0,
270
+ remainingCredits: isSet(object.remainingCredits)
271
+ ? globalThis.Number(object.remainingCredits)
272
+ : 0,
273
+ billingRates: globalThis.Array.isArray(object?.billingRates)
274
+ ? object.billingRates.map((e) => exports.BillingRate.fromJSON(e))
275
+ : [],
276
+ };
277
+ },
278
+ toJSON(message) {
279
+ const obj = {};
280
+ if (message.availableCredits !== 0) {
281
+ obj.availableCredits = message.availableCredits;
282
+ }
283
+ if (message.usedCredits !== 0) {
284
+ obj.usedCredits = message.usedCredits;
285
+ }
286
+ if (message.remainingCredits !== 0) {
287
+ obj.remainingCredits = message.remainingCredits;
288
+ }
289
+ if (message.billingRates?.length) {
290
+ obj.billingRates = message.billingRates.map(e => exports.BillingRate.toJSON(e));
291
+ }
292
+ return obj;
293
+ },
294
+ create(base) {
295
+ return exports.GetUsageResponse.fromPartial(base ?? {});
296
+ },
297
+ fromPartial(object) {
298
+ const message = createBaseGetUsageResponse();
299
+ message.availableCredits = object.availableCredits ?? 0;
300
+ message.usedCredits = object.usedCredits ?? 0;
301
+ message.remainingCredits = object.remainingCredits ?? 0;
302
+ message.billingRates =
303
+ object.billingRates?.map(e => exports.BillingRate.fromPartial(e)) || [];
304
+ return message;
305
+ },
306
+ };
307
+ exports.BillingServiceService = {
308
+ /** Get the usage of the user's credits */
309
+ getUsage: {
310
+ path: "/billing.v1.BillingService/GetUsage",
311
+ requestStream: false,
312
+ responseStream: false,
313
+ requestSerialize: (value) => Buffer.from(exports.GetUsageRequest.encode(value).finish()),
314
+ requestDeserialize: (value) => exports.GetUsageRequest.decode(value),
315
+ responseSerialize: (value) => Buffer.from(exports.GetUsageResponse.encode(value).finish()),
316
+ responseDeserialize: (value) => exports.GetUsageResponse.decode(value),
83
317
  },
84
318
  };
319
+ exports.BillingServiceClient = (0, grpc_js_1.makeGenericClientConstructor)(exports.BillingServiceService, "billing.v1.BillingService");
320
+ function longToNumber(int64) {
321
+ const num = globalThis.Number(int64.toString());
322
+ if (num > globalThis.Number.MAX_SAFE_INTEGER) {
323
+ throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
324
+ }
325
+ if (num < globalThis.Number.MIN_SAFE_INTEGER) {
326
+ throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");
327
+ }
328
+ return num;
329
+ }
330
+ function isSet(value) {
331
+ return value !== null && value !== undefined;
332
+ }