kannon.js 0.1.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.
- package/lib/kannon.d.ts +13 -0
- package/lib/kannon.js +89 -0
- package/lib/proto/google/protobuf/timestamp.d.ts +132 -0
- package/lib/proto/google/protobuf/timestamp.js +86 -0
- package/lib/proto/kannon/mailer/apiv1/mailerapiv1.d.ts +197 -0
- package/lib/proto/kannon/mailer/apiv1/mailerapiv1.js +290 -0
- package/lib/proto/kannon/mailer/types/email.d.ts +42 -0
- package/lib/proto/kannon/mailer/types/email.js +137 -0
- package/lib/proto/kannon/mailer/types/send.d.ts +72 -0
- package/lib/proto/kannon/mailer/types/send.js +190 -0
- package/lib/utils/grpc-promisify.d.ts +18 -0
- package/lib/utils/grpc-promisify.js +31 -0
- package/package.json +36 -0
package/lib/kannon.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as proto from './proto/kannon/mailer/apiv1/mailerapiv1';
|
|
2
|
+
import { Recipient } from './proto/kannon/mailer/types/send';
|
|
3
|
+
export declare class KannonCli {
|
|
4
|
+
private readonly senderEmail;
|
|
5
|
+
private readonly senderAlias;
|
|
6
|
+
private readonly token;
|
|
7
|
+
private readonly client;
|
|
8
|
+
constructor(host: string, skipTLS: boolean, senderEmail: string, senderAlias: string, token: string);
|
|
9
|
+
sendMail(recipients: Recipient[], subject: string, html: string, scheduledTime?: Date): Promise<proto.SendRes>;
|
|
10
|
+
sendMailTemplate(recipients: Recipient[], subject: string, templateId: string, scheduledTime?: Date): Promise<proto.SendRes>;
|
|
11
|
+
private meta;
|
|
12
|
+
private sender;
|
|
13
|
+
}
|
package/lib/kannon.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import * as proto from './proto/kannon/mailer/apiv1/mailerapiv1';
|
|
38
|
+
import * as grpc from '@grpc/grpc-js';
|
|
39
|
+
import { promisifyAll } from './utils/grpc-promisify';
|
|
40
|
+
var KannonCli = /** @class */ (function () {
|
|
41
|
+
function KannonCli(host, skipTLS, senderEmail, senderAlias, token) {
|
|
42
|
+
this.senderEmail = senderEmail;
|
|
43
|
+
this.senderAlias = senderAlias;
|
|
44
|
+
this.token = token;
|
|
45
|
+
var credentials = skipTLS ? grpc.credentials.createInsecure() : grpc.credentials.createSsl();
|
|
46
|
+
this.client = promisifyAll(new proto.MailerClient(host, credentials));
|
|
47
|
+
}
|
|
48
|
+
KannonCli.prototype.sendMail = function (recipients, subject, html, scheduledTime) {
|
|
49
|
+
if (scheduledTime === void 0) { scheduledTime = new Date(); }
|
|
50
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
51
|
+
return __generator(this, function (_a) {
|
|
52
|
+
return [2 /*return*/, this.client.sendHtml({
|
|
53
|
+
html: html,
|
|
54
|
+
sender: this.sender(),
|
|
55
|
+
subject: subject,
|
|
56
|
+
scheduledTime: scheduledTime,
|
|
57
|
+
recipients: recipients,
|
|
58
|
+
}, this.meta())];
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
KannonCli.prototype.sendMailTemplate = function (recipients, subject, templateId, scheduledTime) {
|
|
63
|
+
if (scheduledTime === void 0) { scheduledTime = new Date(); }
|
|
64
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
65
|
+
return __generator(this, function (_a) {
|
|
66
|
+
return [2 /*return*/, this.client.sendTemplate({
|
|
67
|
+
templateId: templateId,
|
|
68
|
+
sender: this.sender(),
|
|
69
|
+
subject: subject,
|
|
70
|
+
scheduledTime: scheduledTime,
|
|
71
|
+
recipients: recipients,
|
|
72
|
+
}, this.meta())];
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
KannonCli.prototype.meta = function () {
|
|
77
|
+
var meta = new grpc.Metadata();
|
|
78
|
+
meta.add('authorization', 'Basic ' + this.token);
|
|
79
|
+
return meta;
|
|
80
|
+
};
|
|
81
|
+
KannonCli.prototype.sender = function () {
|
|
82
|
+
return {
|
|
83
|
+
alias: this.senderAlias,
|
|
84
|
+
email: this.senderEmail,
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
return KannonCli;
|
|
88
|
+
}());
|
|
89
|
+
export { KannonCli };
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import _m0 from 'protobufjs/minimal';
|
|
2
|
+
export declare const protobufPackage = "google.protobuf";
|
|
3
|
+
/**
|
|
4
|
+
* A Timestamp represents a point in time independent of any time zone or local
|
|
5
|
+
* calendar, encoded as a count of seconds and fractions of seconds at
|
|
6
|
+
* nanosecond resolution. The count is relative to an epoch at UTC midnight on
|
|
7
|
+
* January 1, 1970, in the proleptic Gregorian calendar which extends the
|
|
8
|
+
* Gregorian calendar backwards to year one.
|
|
9
|
+
*
|
|
10
|
+
* All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
|
|
11
|
+
* second table is needed for interpretation, using a [24-hour linear
|
|
12
|
+
* smear](https://developers.google.com/time/smear).
|
|
13
|
+
*
|
|
14
|
+
* The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
|
|
15
|
+
* restricting to that range, we ensure that we can convert to and from [RFC
|
|
16
|
+
* 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
|
|
17
|
+
*
|
|
18
|
+
* # Examples
|
|
19
|
+
*
|
|
20
|
+
* Example 1: Compute Timestamp from POSIX `time()`.
|
|
21
|
+
*
|
|
22
|
+
* Timestamp timestamp;
|
|
23
|
+
* timestamp.set_seconds(time(NULL));
|
|
24
|
+
* timestamp.set_nanos(0);
|
|
25
|
+
*
|
|
26
|
+
* Example 2: Compute Timestamp from POSIX `gettimeofday()`.
|
|
27
|
+
*
|
|
28
|
+
* struct timeval tv;
|
|
29
|
+
* gettimeofday(&tv, NULL);
|
|
30
|
+
*
|
|
31
|
+
* Timestamp timestamp;
|
|
32
|
+
* timestamp.set_seconds(tv.tv_sec);
|
|
33
|
+
* timestamp.set_nanos(tv.tv_usec * 1000);
|
|
34
|
+
*
|
|
35
|
+
* Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
|
|
36
|
+
*
|
|
37
|
+
* FILETIME ft;
|
|
38
|
+
* GetSystemTimeAsFileTime(&ft);
|
|
39
|
+
* UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
|
|
40
|
+
*
|
|
41
|
+
* // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
|
|
42
|
+
* // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
|
|
43
|
+
* Timestamp timestamp;
|
|
44
|
+
* timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
|
|
45
|
+
* timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
|
|
46
|
+
*
|
|
47
|
+
* Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
|
|
48
|
+
*
|
|
49
|
+
* long millis = System.currentTimeMillis();
|
|
50
|
+
*
|
|
51
|
+
* Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
|
|
52
|
+
* .setNanos((int) ((millis % 1000) * 1000000)).build();
|
|
53
|
+
*
|
|
54
|
+
* Example 5: Compute Timestamp from Java `Instant.now()`.
|
|
55
|
+
*
|
|
56
|
+
* Instant now = Instant.now();
|
|
57
|
+
*
|
|
58
|
+
* Timestamp timestamp =
|
|
59
|
+
* Timestamp.newBuilder().setSeconds(now.getEpochSecond())
|
|
60
|
+
* .setNanos(now.getNano()).build();
|
|
61
|
+
*
|
|
62
|
+
* Example 6: Compute Timestamp from current time in Python.
|
|
63
|
+
*
|
|
64
|
+
* timestamp = Timestamp()
|
|
65
|
+
* timestamp.GetCurrentTime()
|
|
66
|
+
*
|
|
67
|
+
* # JSON Mapping
|
|
68
|
+
*
|
|
69
|
+
* In JSON format, the Timestamp type is encoded as a string in the
|
|
70
|
+
* [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
|
|
71
|
+
* format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
|
|
72
|
+
* where {year} is always expressed using four digits while {month}, {day},
|
|
73
|
+
* {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
|
|
74
|
+
* seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
|
|
75
|
+
* are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
|
|
76
|
+
* is required. A proto3 JSON serializer should always use UTC (as indicated by
|
|
77
|
+
* "Z") when printing the Timestamp type and a proto3 JSON parser should be
|
|
78
|
+
* able to accept both UTC and other timezones (as indicated by an offset).
|
|
79
|
+
*
|
|
80
|
+
* For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
|
|
81
|
+
* 01:30 UTC on January 15, 2017.
|
|
82
|
+
*
|
|
83
|
+
* In JavaScript, one can convert a Date object to this format using the
|
|
84
|
+
* standard
|
|
85
|
+
* [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
|
|
86
|
+
* method. In Python, a standard `datetime.datetime` object can be converted
|
|
87
|
+
* to this format using
|
|
88
|
+
* [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
|
|
89
|
+
* the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
|
|
90
|
+
* the Joda Time's [`ISODateTimeFormat.dateTime()`](
|
|
91
|
+
* http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D
|
|
92
|
+
* ) to obtain a formatter capable of generating timestamps in this format.
|
|
93
|
+
*/
|
|
94
|
+
export interface Timestamp {
|
|
95
|
+
/**
|
|
96
|
+
* Represents seconds of UTC time since Unix epoch
|
|
97
|
+
* 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
|
|
98
|
+
* 9999-12-31T23:59:59Z inclusive.
|
|
99
|
+
*/
|
|
100
|
+
seconds: number;
|
|
101
|
+
/**
|
|
102
|
+
* Non-negative fractions of a second at nanosecond resolution. Negative
|
|
103
|
+
* second values with fractions must still have non-negative nanos values
|
|
104
|
+
* that count forward in time. Must be from 0 to 999,999,999
|
|
105
|
+
* inclusive.
|
|
106
|
+
*/
|
|
107
|
+
nanos: number;
|
|
108
|
+
}
|
|
109
|
+
export declare const Timestamp: {
|
|
110
|
+
encode(message: Timestamp, writer?: _m0.Writer): _m0.Writer;
|
|
111
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): Timestamp;
|
|
112
|
+
fromJSON(object: any): Timestamp;
|
|
113
|
+
toJSON(message: Timestamp): unknown;
|
|
114
|
+
fromPartial<I extends {
|
|
115
|
+
seconds?: number | undefined;
|
|
116
|
+
nanos?: number | undefined;
|
|
117
|
+
} & {
|
|
118
|
+
seconds?: number | undefined;
|
|
119
|
+
nanos?: number | undefined;
|
|
120
|
+
} & { [K in Exclude<keyof I, keyof Timestamp>]: never; }>(object: I): Timestamp;
|
|
121
|
+
};
|
|
122
|
+
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
123
|
+
export type DeepPartial<T> = T extends Builtin ? T : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
|
|
124
|
+
[K in keyof T]?: DeepPartial<T[K]>;
|
|
125
|
+
} : Partial<T>;
|
|
126
|
+
type KeysOfUnion<T> = T extends T ? keyof T : never;
|
|
127
|
+
export type Exact<P, I extends P> = P extends Builtin ? P : P & {
|
|
128
|
+
[K in keyof P]: Exact<P[K], I[K]>;
|
|
129
|
+
} & {
|
|
130
|
+
[K in Exclude<keyof I, KeysOfUnion<P>>]: never;
|
|
131
|
+
};
|
|
132
|
+
export {};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import Long from 'long';
|
|
3
|
+
import _m0 from 'protobufjs/minimal';
|
|
4
|
+
export var protobufPackage = 'google.protobuf';
|
|
5
|
+
function createBaseTimestamp() {
|
|
6
|
+
return { seconds: 0, nanos: 0 };
|
|
7
|
+
}
|
|
8
|
+
export var Timestamp = {
|
|
9
|
+
encode: function (message, writer) {
|
|
10
|
+
if (writer === void 0) { writer = _m0.Writer.create(); }
|
|
11
|
+
if (message.seconds !== 0) {
|
|
12
|
+
writer.uint32(8).int64(message.seconds);
|
|
13
|
+
}
|
|
14
|
+
if (message.nanos !== 0) {
|
|
15
|
+
writer.uint32(16).int32(message.nanos);
|
|
16
|
+
}
|
|
17
|
+
return writer;
|
|
18
|
+
},
|
|
19
|
+
decode: function (input, length) {
|
|
20
|
+
var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
|
21
|
+
var end = length === undefined ? reader.len : reader.pos + length;
|
|
22
|
+
var message = createBaseTimestamp();
|
|
23
|
+
while (reader.pos < end) {
|
|
24
|
+
var tag = reader.uint32();
|
|
25
|
+
switch (tag >>> 3) {
|
|
26
|
+
case 1:
|
|
27
|
+
message.seconds = longToNumber(reader.int64());
|
|
28
|
+
break;
|
|
29
|
+
case 2:
|
|
30
|
+
message.nanos = reader.int32();
|
|
31
|
+
break;
|
|
32
|
+
default:
|
|
33
|
+
reader.skipType(tag & 7);
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return message;
|
|
38
|
+
},
|
|
39
|
+
fromJSON: function (object) {
|
|
40
|
+
return {
|
|
41
|
+
seconds: isSet(object.seconds) ? Number(object.seconds) : 0,
|
|
42
|
+
nanos: isSet(object.nanos) ? Number(object.nanos) : 0,
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
toJSON: function (message) {
|
|
46
|
+
var obj = {};
|
|
47
|
+
message.seconds !== undefined && (obj.seconds = Math.round(message.seconds));
|
|
48
|
+
message.nanos !== undefined && (obj.nanos = Math.round(message.nanos));
|
|
49
|
+
return obj;
|
|
50
|
+
},
|
|
51
|
+
fromPartial: function (object) {
|
|
52
|
+
var _a, _b;
|
|
53
|
+
var message = createBaseTimestamp();
|
|
54
|
+
message.seconds = (_a = object.seconds) !== null && _a !== void 0 ? _a : 0;
|
|
55
|
+
message.nanos = (_b = object.nanos) !== null && _b !== void 0 ? _b : 0;
|
|
56
|
+
return message;
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
var tsProtoGlobalThis = (function () {
|
|
60
|
+
if (typeof globalThis !== 'undefined') {
|
|
61
|
+
return globalThis;
|
|
62
|
+
}
|
|
63
|
+
if (typeof self !== 'undefined') {
|
|
64
|
+
return self;
|
|
65
|
+
}
|
|
66
|
+
if (typeof window !== 'undefined') {
|
|
67
|
+
return window;
|
|
68
|
+
}
|
|
69
|
+
if (typeof global !== 'undefined') {
|
|
70
|
+
return global;
|
|
71
|
+
}
|
|
72
|
+
throw 'Unable to locate global object';
|
|
73
|
+
})();
|
|
74
|
+
function longToNumber(long) {
|
|
75
|
+
if (long.gt(Number.MAX_SAFE_INTEGER)) {
|
|
76
|
+
throw new tsProtoGlobalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER');
|
|
77
|
+
}
|
|
78
|
+
return long.toNumber();
|
|
79
|
+
}
|
|
80
|
+
if (_m0.util.Long !== Long) {
|
|
81
|
+
_m0.util.Long = Long;
|
|
82
|
+
_m0.configure();
|
|
83
|
+
}
|
|
84
|
+
function isSet(value) {
|
|
85
|
+
return value !== null && value !== undefined;
|
|
86
|
+
}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { CallOptions, ChannelCredentials, Client, ClientOptions, ClientUnaryCall, handleUnaryCall, Metadata, ServiceError, UntypedServiceImplementation } from '@grpc/grpc-js';
|
|
3
|
+
import _m0 from 'protobufjs/minimal';
|
|
4
|
+
import { Recipient, Sender } from '../types/send';
|
|
5
|
+
export declare const protobufPackage = "pkg.kannon.mailer.apiv1";
|
|
6
|
+
export interface SendHTMLReq {
|
|
7
|
+
sender: Sender | undefined;
|
|
8
|
+
subject: string;
|
|
9
|
+
html: string;
|
|
10
|
+
scheduledTime?: Date | undefined;
|
|
11
|
+
recipients: Recipient[];
|
|
12
|
+
}
|
|
13
|
+
export interface SendTemplateReq {
|
|
14
|
+
sender: Sender | undefined;
|
|
15
|
+
subject: string;
|
|
16
|
+
templateId: string;
|
|
17
|
+
scheduledTime?: Date | undefined;
|
|
18
|
+
recipients: Recipient[];
|
|
19
|
+
}
|
|
20
|
+
export interface SendRes {
|
|
21
|
+
messageId: string;
|
|
22
|
+
templateId: string;
|
|
23
|
+
scheduledTime: Date | undefined;
|
|
24
|
+
}
|
|
25
|
+
export declare const SendHTMLReq: {
|
|
26
|
+
encode(message: SendHTMLReq, writer?: _m0.Writer): _m0.Writer;
|
|
27
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): SendHTMLReq;
|
|
28
|
+
fromJSON(object: any): SendHTMLReq;
|
|
29
|
+
toJSON(message: SendHTMLReq): unknown;
|
|
30
|
+
fromPartial<I extends {
|
|
31
|
+
sender?: {
|
|
32
|
+
email?: string | undefined;
|
|
33
|
+
alias?: string | undefined;
|
|
34
|
+
} | undefined;
|
|
35
|
+
subject?: string | undefined;
|
|
36
|
+
html?: string | undefined;
|
|
37
|
+
scheduledTime?: Date | undefined;
|
|
38
|
+
recipients?: {
|
|
39
|
+
email?: string | undefined;
|
|
40
|
+
fields?: {
|
|
41
|
+
[x: string]: string | undefined;
|
|
42
|
+
} | undefined;
|
|
43
|
+
}[] | undefined;
|
|
44
|
+
} & {
|
|
45
|
+
sender?: ({
|
|
46
|
+
email?: string | undefined;
|
|
47
|
+
alias?: string | undefined;
|
|
48
|
+
} & {
|
|
49
|
+
email?: string | undefined;
|
|
50
|
+
alias?: string | undefined;
|
|
51
|
+
} & { [K in Exclude<keyof I["sender"], keyof Sender>]: never; }) | undefined;
|
|
52
|
+
subject?: string | undefined;
|
|
53
|
+
html?: string | undefined;
|
|
54
|
+
scheduledTime?: Date | undefined;
|
|
55
|
+
recipients?: ({
|
|
56
|
+
email?: string | undefined;
|
|
57
|
+
fields?: {
|
|
58
|
+
[x: string]: string | undefined;
|
|
59
|
+
} | undefined;
|
|
60
|
+
}[] & ({
|
|
61
|
+
email?: string | undefined;
|
|
62
|
+
fields?: {
|
|
63
|
+
[x: string]: string | undefined;
|
|
64
|
+
} | undefined;
|
|
65
|
+
} & {
|
|
66
|
+
email?: string | undefined;
|
|
67
|
+
fields?: ({
|
|
68
|
+
[x: string]: string | undefined;
|
|
69
|
+
} & {
|
|
70
|
+
[x: string]: string | undefined;
|
|
71
|
+
} & { [K_1 in Exclude<keyof I["recipients"][number]["fields"], string | number>]: never; }) | undefined;
|
|
72
|
+
} & { [K_2 in Exclude<keyof I["recipients"][number], keyof Recipient>]: never; })[] & { [K_3 in Exclude<keyof I["recipients"], keyof {
|
|
73
|
+
email?: string | undefined;
|
|
74
|
+
fields?: {
|
|
75
|
+
[x: string]: string | undefined;
|
|
76
|
+
} | undefined;
|
|
77
|
+
}[]>]: never; }) | undefined;
|
|
78
|
+
} & { [K_4 in Exclude<keyof I, keyof SendHTMLReq>]: never; }>(object: I): SendHTMLReq;
|
|
79
|
+
};
|
|
80
|
+
export declare const SendTemplateReq: {
|
|
81
|
+
encode(message: SendTemplateReq, writer?: _m0.Writer): _m0.Writer;
|
|
82
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): SendTemplateReq;
|
|
83
|
+
fromJSON(object: any): SendTemplateReq;
|
|
84
|
+
toJSON(message: SendTemplateReq): unknown;
|
|
85
|
+
fromPartial<I extends {
|
|
86
|
+
sender?: {
|
|
87
|
+
email?: string | undefined;
|
|
88
|
+
alias?: string | undefined;
|
|
89
|
+
} | undefined;
|
|
90
|
+
subject?: string | undefined;
|
|
91
|
+
templateId?: string | undefined;
|
|
92
|
+
scheduledTime?: Date | undefined;
|
|
93
|
+
recipients?: {
|
|
94
|
+
email?: string | undefined;
|
|
95
|
+
fields?: {
|
|
96
|
+
[x: string]: string | undefined;
|
|
97
|
+
} | undefined;
|
|
98
|
+
}[] | undefined;
|
|
99
|
+
} & {
|
|
100
|
+
sender?: ({
|
|
101
|
+
email?: string | undefined;
|
|
102
|
+
alias?: string | undefined;
|
|
103
|
+
} & {
|
|
104
|
+
email?: string | undefined;
|
|
105
|
+
alias?: string | undefined;
|
|
106
|
+
} & { [K in Exclude<keyof I["sender"], keyof Sender>]: never; }) | undefined;
|
|
107
|
+
subject?: string | undefined;
|
|
108
|
+
templateId?: string | undefined;
|
|
109
|
+
scheduledTime?: Date | undefined;
|
|
110
|
+
recipients?: ({
|
|
111
|
+
email?: string | undefined;
|
|
112
|
+
fields?: {
|
|
113
|
+
[x: string]: string | undefined;
|
|
114
|
+
} | undefined;
|
|
115
|
+
}[] & ({
|
|
116
|
+
email?: string | undefined;
|
|
117
|
+
fields?: {
|
|
118
|
+
[x: string]: string | undefined;
|
|
119
|
+
} | undefined;
|
|
120
|
+
} & {
|
|
121
|
+
email?: string | undefined;
|
|
122
|
+
fields?: ({
|
|
123
|
+
[x: string]: string | undefined;
|
|
124
|
+
} & {
|
|
125
|
+
[x: string]: string | undefined;
|
|
126
|
+
} & { [K_1 in Exclude<keyof I["recipients"][number]["fields"], string | number>]: never; }) | undefined;
|
|
127
|
+
} & { [K_2 in Exclude<keyof I["recipients"][number], keyof Recipient>]: never; })[] & { [K_3 in Exclude<keyof I["recipients"], keyof {
|
|
128
|
+
email?: string | undefined;
|
|
129
|
+
fields?: {
|
|
130
|
+
[x: string]: string | undefined;
|
|
131
|
+
} | undefined;
|
|
132
|
+
}[]>]: never; }) | undefined;
|
|
133
|
+
} & { [K_4 in Exclude<keyof I, keyof SendTemplateReq>]: never; }>(object: I): SendTemplateReq;
|
|
134
|
+
};
|
|
135
|
+
export declare const SendRes: {
|
|
136
|
+
encode(message: SendRes, writer?: _m0.Writer): _m0.Writer;
|
|
137
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): SendRes;
|
|
138
|
+
fromJSON(object: any): SendRes;
|
|
139
|
+
toJSON(message: SendRes): unknown;
|
|
140
|
+
fromPartial<I extends {
|
|
141
|
+
messageId?: string | undefined;
|
|
142
|
+
templateId?: string | undefined;
|
|
143
|
+
scheduledTime?: Date | undefined;
|
|
144
|
+
} & {
|
|
145
|
+
messageId?: string | undefined;
|
|
146
|
+
templateId?: string | undefined;
|
|
147
|
+
scheduledTime?: Date | undefined;
|
|
148
|
+
} & { [K in Exclude<keyof I, keyof SendRes>]: never; }>(object: I): SendRes;
|
|
149
|
+
};
|
|
150
|
+
export type MailerService = typeof MailerService;
|
|
151
|
+
export declare const MailerService: {
|
|
152
|
+
readonly sendHtml: {
|
|
153
|
+
readonly path: "/pkg.kannon.mailer.apiv1.Mailer/SendHTML";
|
|
154
|
+
readonly requestStream: false;
|
|
155
|
+
readonly responseStream: false;
|
|
156
|
+
readonly requestSerialize: (value: SendHTMLReq) => Buffer;
|
|
157
|
+
readonly requestDeserialize: (value: Buffer) => SendHTMLReq;
|
|
158
|
+
readonly responseSerialize: (value: SendRes) => Buffer;
|
|
159
|
+
readonly responseDeserialize: (value: Buffer) => SendRes;
|
|
160
|
+
};
|
|
161
|
+
readonly sendTemplate: {
|
|
162
|
+
readonly path: "/pkg.kannon.mailer.apiv1.Mailer/SendTemplate";
|
|
163
|
+
readonly requestStream: false;
|
|
164
|
+
readonly responseStream: false;
|
|
165
|
+
readonly requestSerialize: (value: SendTemplateReq) => Buffer;
|
|
166
|
+
readonly requestDeserialize: (value: Buffer) => SendTemplateReq;
|
|
167
|
+
readonly responseSerialize: (value: SendRes) => Buffer;
|
|
168
|
+
readonly responseDeserialize: (value: Buffer) => SendRes;
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
export interface MailerServer extends UntypedServiceImplementation {
|
|
172
|
+
sendHtml: handleUnaryCall<SendHTMLReq, SendRes>;
|
|
173
|
+
sendTemplate: handleUnaryCall<SendTemplateReq, SendRes>;
|
|
174
|
+
}
|
|
175
|
+
export interface MailerClient extends Client {
|
|
176
|
+
sendHtml(request: SendHTMLReq, callback: (error: ServiceError | null, response: SendRes) => void): ClientUnaryCall;
|
|
177
|
+
sendHtml(request: SendHTMLReq, metadata: Metadata, callback: (error: ServiceError | null, response: SendRes) => void): ClientUnaryCall;
|
|
178
|
+
sendHtml(request: SendHTMLReq, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: SendRes) => void): ClientUnaryCall;
|
|
179
|
+
sendTemplate(request: SendTemplateReq, callback: (error: ServiceError | null, response: SendRes) => void): ClientUnaryCall;
|
|
180
|
+
sendTemplate(request: SendTemplateReq, metadata: Metadata, callback: (error: ServiceError | null, response: SendRes) => void): ClientUnaryCall;
|
|
181
|
+
sendTemplate(request: SendTemplateReq, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: SendRes) => void): ClientUnaryCall;
|
|
182
|
+
}
|
|
183
|
+
export declare const MailerClient: {
|
|
184
|
+
new (address: string, credentials: ChannelCredentials, options?: Partial<ClientOptions>): MailerClient;
|
|
185
|
+
service: typeof MailerService;
|
|
186
|
+
};
|
|
187
|
+
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
188
|
+
export type DeepPartial<T> = T extends Builtin ? T : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
|
|
189
|
+
[K in keyof T]?: DeepPartial<T[K]>;
|
|
190
|
+
} : Partial<T>;
|
|
191
|
+
type KeysOfUnion<T> = T extends T ? keyof T : never;
|
|
192
|
+
export type Exact<P, I extends P> = P extends Builtin ? P : P & {
|
|
193
|
+
[K in keyof P]: Exact<P[K], I[K]>;
|
|
194
|
+
} & {
|
|
195
|
+
[K in Exclude<keyof I, KeysOfUnion<P>>]: never;
|
|
196
|
+
};
|
|
197
|
+
export {};
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import { makeGenericClientConstructor, } from '@grpc/grpc-js';
|
|
3
|
+
import _m0 from 'protobufjs/minimal';
|
|
4
|
+
import { Timestamp } from '../../../google/protobuf/timestamp';
|
|
5
|
+
import { Recipient, Sender } from '../types/send';
|
|
6
|
+
export var protobufPackage = 'pkg.kannon.mailer.apiv1';
|
|
7
|
+
function createBaseSendHTMLReq() {
|
|
8
|
+
return { sender: undefined, subject: '', html: '', scheduledTime: undefined, recipients: [] };
|
|
9
|
+
}
|
|
10
|
+
export var SendHTMLReq = {
|
|
11
|
+
encode: function (message, writer) {
|
|
12
|
+
if (writer === void 0) { writer = _m0.Writer.create(); }
|
|
13
|
+
if (message.sender !== undefined) {
|
|
14
|
+
Sender.encode(message.sender, writer.uint32(10).fork()).ldelim();
|
|
15
|
+
}
|
|
16
|
+
if (message.subject !== '') {
|
|
17
|
+
writer.uint32(26).string(message.subject);
|
|
18
|
+
}
|
|
19
|
+
if (message.html !== '') {
|
|
20
|
+
writer.uint32(34).string(message.html);
|
|
21
|
+
}
|
|
22
|
+
if (message.scheduledTime !== undefined) {
|
|
23
|
+
Timestamp.encode(toTimestamp(message.scheduledTime), writer.uint32(42).fork()).ldelim();
|
|
24
|
+
}
|
|
25
|
+
for (var _i = 0, _a = message.recipients; _i < _a.length; _i++) {
|
|
26
|
+
var v = _a[_i];
|
|
27
|
+
Recipient.encode(v, writer.uint32(50).fork()).ldelim();
|
|
28
|
+
}
|
|
29
|
+
return writer;
|
|
30
|
+
},
|
|
31
|
+
decode: function (input, length) {
|
|
32
|
+
var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
|
33
|
+
var end = length === undefined ? reader.len : reader.pos + length;
|
|
34
|
+
var message = createBaseSendHTMLReq();
|
|
35
|
+
while (reader.pos < end) {
|
|
36
|
+
var tag = reader.uint32();
|
|
37
|
+
switch (tag >>> 3) {
|
|
38
|
+
case 1:
|
|
39
|
+
message.sender = Sender.decode(reader, reader.uint32());
|
|
40
|
+
break;
|
|
41
|
+
case 3:
|
|
42
|
+
message.subject = reader.string();
|
|
43
|
+
break;
|
|
44
|
+
case 4:
|
|
45
|
+
message.html = reader.string();
|
|
46
|
+
break;
|
|
47
|
+
case 5:
|
|
48
|
+
message.scheduledTime = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
|
|
49
|
+
break;
|
|
50
|
+
case 6:
|
|
51
|
+
message.recipients.push(Recipient.decode(reader, reader.uint32()));
|
|
52
|
+
break;
|
|
53
|
+
default:
|
|
54
|
+
reader.skipType(tag & 7);
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return message;
|
|
59
|
+
},
|
|
60
|
+
fromJSON: function (object) {
|
|
61
|
+
return {
|
|
62
|
+
sender: isSet(object.sender) ? Sender.fromJSON(object.sender) : undefined,
|
|
63
|
+
subject: isSet(object.subject) ? String(object.subject) : '',
|
|
64
|
+
html: isSet(object.html) ? String(object.html) : '',
|
|
65
|
+
scheduledTime: isSet(object.scheduledTime) ? fromJsonTimestamp(object.scheduledTime) : undefined,
|
|
66
|
+
recipients: Array.isArray(object === null || object === void 0 ? void 0 : object.recipients) ? object.recipients.map(function (e) { return Recipient.fromJSON(e); }) : [],
|
|
67
|
+
};
|
|
68
|
+
},
|
|
69
|
+
toJSON: function (message) {
|
|
70
|
+
var obj = {};
|
|
71
|
+
message.sender !== undefined && (obj.sender = message.sender ? Sender.toJSON(message.sender) : undefined);
|
|
72
|
+
message.subject !== undefined && (obj.subject = message.subject);
|
|
73
|
+
message.html !== undefined && (obj.html = message.html);
|
|
74
|
+
message.scheduledTime !== undefined && (obj.scheduledTime = message.scheduledTime.toISOString());
|
|
75
|
+
if (message.recipients) {
|
|
76
|
+
obj.recipients = message.recipients.map(function (e) { return (e ? Recipient.toJSON(e) : undefined); });
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
obj.recipients = [];
|
|
80
|
+
}
|
|
81
|
+
return obj;
|
|
82
|
+
},
|
|
83
|
+
fromPartial: function (object) {
|
|
84
|
+
var _a, _b, _c, _d;
|
|
85
|
+
var message = createBaseSendHTMLReq();
|
|
86
|
+
message.sender =
|
|
87
|
+
object.sender !== undefined && object.sender !== null ? Sender.fromPartial(object.sender) : undefined;
|
|
88
|
+
message.subject = (_a = object.subject) !== null && _a !== void 0 ? _a : '';
|
|
89
|
+
message.html = (_b = object.html) !== null && _b !== void 0 ? _b : '';
|
|
90
|
+
message.scheduledTime = (_c = object.scheduledTime) !== null && _c !== void 0 ? _c : undefined;
|
|
91
|
+
message.recipients = ((_d = object.recipients) === null || _d === void 0 ? void 0 : _d.map(function (e) { return Recipient.fromPartial(e); })) || [];
|
|
92
|
+
return message;
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
function createBaseSendTemplateReq() {
|
|
96
|
+
return { sender: undefined, subject: '', templateId: '', scheduledTime: undefined, recipients: [] };
|
|
97
|
+
}
|
|
98
|
+
export var SendTemplateReq = {
|
|
99
|
+
encode: function (message, writer) {
|
|
100
|
+
if (writer === void 0) { writer = _m0.Writer.create(); }
|
|
101
|
+
if (message.sender !== undefined) {
|
|
102
|
+
Sender.encode(message.sender, writer.uint32(10).fork()).ldelim();
|
|
103
|
+
}
|
|
104
|
+
if (message.subject !== '') {
|
|
105
|
+
writer.uint32(26).string(message.subject);
|
|
106
|
+
}
|
|
107
|
+
if (message.templateId !== '') {
|
|
108
|
+
writer.uint32(34).string(message.templateId);
|
|
109
|
+
}
|
|
110
|
+
if (message.scheduledTime !== undefined) {
|
|
111
|
+
Timestamp.encode(toTimestamp(message.scheduledTime), writer.uint32(42).fork()).ldelim();
|
|
112
|
+
}
|
|
113
|
+
for (var _i = 0, _a = message.recipients; _i < _a.length; _i++) {
|
|
114
|
+
var v = _a[_i];
|
|
115
|
+
Recipient.encode(v, writer.uint32(50).fork()).ldelim();
|
|
116
|
+
}
|
|
117
|
+
return writer;
|
|
118
|
+
},
|
|
119
|
+
decode: function (input, length) {
|
|
120
|
+
var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
|
121
|
+
var end = length === undefined ? reader.len : reader.pos + length;
|
|
122
|
+
var message = createBaseSendTemplateReq();
|
|
123
|
+
while (reader.pos < end) {
|
|
124
|
+
var tag = reader.uint32();
|
|
125
|
+
switch (tag >>> 3) {
|
|
126
|
+
case 1:
|
|
127
|
+
message.sender = Sender.decode(reader, reader.uint32());
|
|
128
|
+
break;
|
|
129
|
+
case 3:
|
|
130
|
+
message.subject = reader.string();
|
|
131
|
+
break;
|
|
132
|
+
case 4:
|
|
133
|
+
message.templateId = reader.string();
|
|
134
|
+
break;
|
|
135
|
+
case 5:
|
|
136
|
+
message.scheduledTime = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
|
|
137
|
+
break;
|
|
138
|
+
case 6:
|
|
139
|
+
message.recipients.push(Recipient.decode(reader, reader.uint32()));
|
|
140
|
+
break;
|
|
141
|
+
default:
|
|
142
|
+
reader.skipType(tag & 7);
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return message;
|
|
147
|
+
},
|
|
148
|
+
fromJSON: function (object) {
|
|
149
|
+
return {
|
|
150
|
+
sender: isSet(object.sender) ? Sender.fromJSON(object.sender) : undefined,
|
|
151
|
+
subject: isSet(object.subject) ? String(object.subject) : '',
|
|
152
|
+
templateId: isSet(object.templateId) ? String(object.templateId) : '',
|
|
153
|
+
scheduledTime: isSet(object.scheduledTime) ? fromJsonTimestamp(object.scheduledTime) : undefined,
|
|
154
|
+
recipients: Array.isArray(object === null || object === void 0 ? void 0 : object.recipients) ? object.recipients.map(function (e) { return Recipient.fromJSON(e); }) : [],
|
|
155
|
+
};
|
|
156
|
+
},
|
|
157
|
+
toJSON: function (message) {
|
|
158
|
+
var obj = {};
|
|
159
|
+
message.sender !== undefined && (obj.sender = message.sender ? Sender.toJSON(message.sender) : undefined);
|
|
160
|
+
message.subject !== undefined && (obj.subject = message.subject);
|
|
161
|
+
message.templateId !== undefined && (obj.templateId = message.templateId);
|
|
162
|
+
message.scheduledTime !== undefined && (obj.scheduledTime = message.scheduledTime.toISOString());
|
|
163
|
+
if (message.recipients) {
|
|
164
|
+
obj.recipients = message.recipients.map(function (e) { return (e ? Recipient.toJSON(e) : undefined); });
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
obj.recipients = [];
|
|
168
|
+
}
|
|
169
|
+
return obj;
|
|
170
|
+
},
|
|
171
|
+
fromPartial: function (object) {
|
|
172
|
+
var _a, _b, _c, _d;
|
|
173
|
+
var message = createBaseSendTemplateReq();
|
|
174
|
+
message.sender =
|
|
175
|
+
object.sender !== undefined && object.sender !== null ? Sender.fromPartial(object.sender) : undefined;
|
|
176
|
+
message.subject = (_a = object.subject) !== null && _a !== void 0 ? _a : '';
|
|
177
|
+
message.templateId = (_b = object.templateId) !== null && _b !== void 0 ? _b : '';
|
|
178
|
+
message.scheduledTime = (_c = object.scheduledTime) !== null && _c !== void 0 ? _c : undefined;
|
|
179
|
+
message.recipients = ((_d = object.recipients) === null || _d === void 0 ? void 0 : _d.map(function (e) { return Recipient.fromPartial(e); })) || [];
|
|
180
|
+
return message;
|
|
181
|
+
},
|
|
182
|
+
};
|
|
183
|
+
function createBaseSendRes() {
|
|
184
|
+
return { messageId: '', templateId: '', scheduledTime: undefined };
|
|
185
|
+
}
|
|
186
|
+
export var SendRes = {
|
|
187
|
+
encode: function (message, writer) {
|
|
188
|
+
if (writer === void 0) { writer = _m0.Writer.create(); }
|
|
189
|
+
if (message.messageId !== '') {
|
|
190
|
+
writer.uint32(10).string(message.messageId);
|
|
191
|
+
}
|
|
192
|
+
if (message.templateId !== '') {
|
|
193
|
+
writer.uint32(18).string(message.templateId);
|
|
194
|
+
}
|
|
195
|
+
if (message.scheduledTime !== undefined) {
|
|
196
|
+
Timestamp.encode(toTimestamp(message.scheduledTime), writer.uint32(26).fork()).ldelim();
|
|
197
|
+
}
|
|
198
|
+
return writer;
|
|
199
|
+
},
|
|
200
|
+
decode: function (input, length) {
|
|
201
|
+
var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
|
202
|
+
var end = length === undefined ? reader.len : reader.pos + length;
|
|
203
|
+
var message = createBaseSendRes();
|
|
204
|
+
while (reader.pos < end) {
|
|
205
|
+
var tag = reader.uint32();
|
|
206
|
+
switch (tag >>> 3) {
|
|
207
|
+
case 1:
|
|
208
|
+
message.messageId = reader.string();
|
|
209
|
+
break;
|
|
210
|
+
case 2:
|
|
211
|
+
message.templateId = reader.string();
|
|
212
|
+
break;
|
|
213
|
+
case 3:
|
|
214
|
+
message.scheduledTime = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
|
|
215
|
+
break;
|
|
216
|
+
default:
|
|
217
|
+
reader.skipType(tag & 7);
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return message;
|
|
222
|
+
},
|
|
223
|
+
fromJSON: function (object) {
|
|
224
|
+
return {
|
|
225
|
+
messageId: isSet(object.messageId) ? String(object.messageId) : '',
|
|
226
|
+
templateId: isSet(object.templateId) ? String(object.templateId) : '',
|
|
227
|
+
scheduledTime: isSet(object.scheduledTime) ? fromJsonTimestamp(object.scheduledTime) : undefined,
|
|
228
|
+
};
|
|
229
|
+
},
|
|
230
|
+
toJSON: function (message) {
|
|
231
|
+
var obj = {};
|
|
232
|
+
message.messageId !== undefined && (obj.messageId = message.messageId);
|
|
233
|
+
message.templateId !== undefined && (obj.templateId = message.templateId);
|
|
234
|
+
message.scheduledTime !== undefined && (obj.scheduledTime = message.scheduledTime.toISOString());
|
|
235
|
+
return obj;
|
|
236
|
+
},
|
|
237
|
+
fromPartial: function (object) {
|
|
238
|
+
var _a, _b, _c;
|
|
239
|
+
var message = createBaseSendRes();
|
|
240
|
+
message.messageId = (_a = object.messageId) !== null && _a !== void 0 ? _a : '';
|
|
241
|
+
message.templateId = (_b = object.templateId) !== null && _b !== void 0 ? _b : '';
|
|
242
|
+
message.scheduledTime = (_c = object.scheduledTime) !== null && _c !== void 0 ? _c : undefined;
|
|
243
|
+
return message;
|
|
244
|
+
},
|
|
245
|
+
};
|
|
246
|
+
export var MailerService = {
|
|
247
|
+
sendHtml: {
|
|
248
|
+
path: '/pkg.kannon.mailer.apiv1.Mailer/SendHTML',
|
|
249
|
+
requestStream: false,
|
|
250
|
+
responseStream: false,
|
|
251
|
+
requestSerialize: function (value) { return Buffer.from(SendHTMLReq.encode(value).finish()); },
|
|
252
|
+
requestDeserialize: function (value) { return SendHTMLReq.decode(value); },
|
|
253
|
+
responseSerialize: function (value) { return Buffer.from(SendRes.encode(value).finish()); },
|
|
254
|
+
responseDeserialize: function (value) { return SendRes.decode(value); },
|
|
255
|
+
},
|
|
256
|
+
sendTemplate: {
|
|
257
|
+
path: '/pkg.kannon.mailer.apiv1.Mailer/SendTemplate',
|
|
258
|
+
requestStream: false,
|
|
259
|
+
responseStream: false,
|
|
260
|
+
requestSerialize: function (value) { return Buffer.from(SendTemplateReq.encode(value).finish()); },
|
|
261
|
+
requestDeserialize: function (value) { return SendTemplateReq.decode(value); },
|
|
262
|
+
responseSerialize: function (value) { return Buffer.from(SendRes.encode(value).finish()); },
|
|
263
|
+
responseDeserialize: function (value) { return SendRes.decode(value); },
|
|
264
|
+
},
|
|
265
|
+
};
|
|
266
|
+
export var MailerClient = makeGenericClientConstructor(MailerService, 'pkg.kannon.mailer.apiv1.Mailer');
|
|
267
|
+
function toTimestamp(date) {
|
|
268
|
+
var seconds = date.getTime() / 1000;
|
|
269
|
+
var nanos = (date.getTime() % 1000) * 1000000;
|
|
270
|
+
return { seconds: seconds, nanos: nanos };
|
|
271
|
+
}
|
|
272
|
+
function fromTimestamp(t) {
|
|
273
|
+
var millis = t.seconds * 1000;
|
|
274
|
+
millis += t.nanos / 1000000;
|
|
275
|
+
return new Date(millis);
|
|
276
|
+
}
|
|
277
|
+
function fromJsonTimestamp(o) {
|
|
278
|
+
if (o instanceof Date) {
|
|
279
|
+
return o;
|
|
280
|
+
}
|
|
281
|
+
else if (typeof o === 'string') {
|
|
282
|
+
return new Date(o);
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
return fromTimestamp(Timestamp.fromJSON(o));
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
function isSet(value) {
|
|
289
|
+
return value !== null && value !== undefined;
|
|
290
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import _m0 from 'protobufjs/minimal';
|
|
2
|
+
export declare const protobufPackage = "pkg.kannon.mailer.types";
|
|
3
|
+
export interface EmailToSend {
|
|
4
|
+
emailId: string;
|
|
5
|
+
from: string;
|
|
6
|
+
to: string;
|
|
7
|
+
returnPath: string;
|
|
8
|
+
body: Uint8Array;
|
|
9
|
+
shouldRetry: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const EmailToSend: {
|
|
12
|
+
encode(message: EmailToSend, writer?: _m0.Writer): _m0.Writer;
|
|
13
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): EmailToSend;
|
|
14
|
+
fromJSON(object: any): EmailToSend;
|
|
15
|
+
toJSON(message: EmailToSend): unknown;
|
|
16
|
+
fromPartial<I extends {
|
|
17
|
+
emailId?: string | undefined;
|
|
18
|
+
from?: string | undefined;
|
|
19
|
+
to?: string | undefined;
|
|
20
|
+
returnPath?: string | undefined;
|
|
21
|
+
body?: Uint8Array | undefined;
|
|
22
|
+
shouldRetry?: boolean | undefined;
|
|
23
|
+
} & {
|
|
24
|
+
emailId?: string | undefined;
|
|
25
|
+
from?: string | undefined;
|
|
26
|
+
to?: string | undefined;
|
|
27
|
+
returnPath?: string | undefined;
|
|
28
|
+
body?: Uint8Array | undefined;
|
|
29
|
+
shouldRetry?: boolean | undefined;
|
|
30
|
+
} & { [K in Exclude<keyof I, keyof EmailToSend>]: never; }>(object: I): EmailToSend;
|
|
31
|
+
};
|
|
32
|
+
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
33
|
+
export type DeepPartial<T> = T extends Builtin ? T : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
|
|
34
|
+
[K in keyof T]?: DeepPartial<T[K]>;
|
|
35
|
+
} : Partial<T>;
|
|
36
|
+
type KeysOfUnion<T> = T extends T ? keyof T : never;
|
|
37
|
+
export type Exact<P, I extends P> = P extends Builtin ? P : P & {
|
|
38
|
+
[K in keyof P]: Exact<P[K], I[K]>;
|
|
39
|
+
} & {
|
|
40
|
+
[K in Exclude<keyof I, KeysOfUnion<P>>]: never;
|
|
41
|
+
};
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import _m0 from 'protobufjs/minimal';
|
|
3
|
+
export var protobufPackage = 'pkg.kannon.mailer.types';
|
|
4
|
+
function createBaseEmailToSend() {
|
|
5
|
+
return { emailId: '', from: '', to: '', returnPath: '', body: new Uint8Array(), shouldRetry: false };
|
|
6
|
+
}
|
|
7
|
+
export var EmailToSend = {
|
|
8
|
+
encode: function (message, writer) {
|
|
9
|
+
if (writer === void 0) { writer = _m0.Writer.create(); }
|
|
10
|
+
if (message.emailId !== '') {
|
|
11
|
+
writer.uint32(10).string(message.emailId);
|
|
12
|
+
}
|
|
13
|
+
if (message.from !== '') {
|
|
14
|
+
writer.uint32(18).string(message.from);
|
|
15
|
+
}
|
|
16
|
+
if (message.to !== '') {
|
|
17
|
+
writer.uint32(26).string(message.to);
|
|
18
|
+
}
|
|
19
|
+
if (message.returnPath !== '') {
|
|
20
|
+
writer.uint32(34).string(message.returnPath);
|
|
21
|
+
}
|
|
22
|
+
if (message.body.length !== 0) {
|
|
23
|
+
writer.uint32(42).bytes(message.body);
|
|
24
|
+
}
|
|
25
|
+
if (message.shouldRetry === true) {
|
|
26
|
+
writer.uint32(48).bool(message.shouldRetry);
|
|
27
|
+
}
|
|
28
|
+
return writer;
|
|
29
|
+
},
|
|
30
|
+
decode: function (input, length) {
|
|
31
|
+
var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
|
32
|
+
var end = length === undefined ? reader.len : reader.pos + length;
|
|
33
|
+
var message = createBaseEmailToSend();
|
|
34
|
+
while (reader.pos < end) {
|
|
35
|
+
var tag = reader.uint32();
|
|
36
|
+
switch (tag >>> 3) {
|
|
37
|
+
case 1:
|
|
38
|
+
message.emailId = reader.string();
|
|
39
|
+
break;
|
|
40
|
+
case 2:
|
|
41
|
+
message.from = reader.string();
|
|
42
|
+
break;
|
|
43
|
+
case 3:
|
|
44
|
+
message.to = reader.string();
|
|
45
|
+
break;
|
|
46
|
+
case 4:
|
|
47
|
+
message.returnPath = reader.string();
|
|
48
|
+
break;
|
|
49
|
+
case 5:
|
|
50
|
+
message.body = reader.bytes();
|
|
51
|
+
break;
|
|
52
|
+
case 6:
|
|
53
|
+
message.shouldRetry = reader.bool();
|
|
54
|
+
break;
|
|
55
|
+
default:
|
|
56
|
+
reader.skipType(tag & 7);
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return message;
|
|
61
|
+
},
|
|
62
|
+
fromJSON: function (object) {
|
|
63
|
+
return {
|
|
64
|
+
emailId: isSet(object.emailId) ? String(object.emailId) : '',
|
|
65
|
+
from: isSet(object.from) ? String(object.from) : '',
|
|
66
|
+
to: isSet(object.to) ? String(object.to) : '',
|
|
67
|
+
returnPath: isSet(object.returnPath) ? String(object.returnPath) : '',
|
|
68
|
+
body: isSet(object.body) ? bytesFromBase64(object.body) : new Uint8Array(),
|
|
69
|
+
shouldRetry: isSet(object.shouldRetry) ? Boolean(object.shouldRetry) : false,
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
toJSON: function (message) {
|
|
73
|
+
var obj = {};
|
|
74
|
+
message.emailId !== undefined && (obj.emailId = message.emailId);
|
|
75
|
+
message.from !== undefined && (obj.from = message.from);
|
|
76
|
+
message.to !== undefined && (obj.to = message.to);
|
|
77
|
+
message.returnPath !== undefined && (obj.returnPath = message.returnPath);
|
|
78
|
+
message.body !== undefined &&
|
|
79
|
+
(obj.body = base64FromBytes(message.body !== undefined ? message.body : new Uint8Array()));
|
|
80
|
+
message.shouldRetry !== undefined && (obj.shouldRetry = message.shouldRetry);
|
|
81
|
+
return obj;
|
|
82
|
+
},
|
|
83
|
+
fromPartial: function (object) {
|
|
84
|
+
var _a, _b, _c, _d, _e, _f;
|
|
85
|
+
var message = createBaseEmailToSend();
|
|
86
|
+
message.emailId = (_a = object.emailId) !== null && _a !== void 0 ? _a : '';
|
|
87
|
+
message.from = (_b = object.from) !== null && _b !== void 0 ? _b : '';
|
|
88
|
+
message.to = (_c = object.to) !== null && _c !== void 0 ? _c : '';
|
|
89
|
+
message.returnPath = (_d = object.returnPath) !== null && _d !== void 0 ? _d : '';
|
|
90
|
+
message.body = (_e = object.body) !== null && _e !== void 0 ? _e : new Uint8Array();
|
|
91
|
+
message.shouldRetry = (_f = object.shouldRetry) !== null && _f !== void 0 ? _f : false;
|
|
92
|
+
return message;
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
var tsProtoGlobalThis = (function () {
|
|
96
|
+
if (typeof globalThis !== 'undefined') {
|
|
97
|
+
return globalThis;
|
|
98
|
+
}
|
|
99
|
+
if (typeof self !== 'undefined') {
|
|
100
|
+
return self;
|
|
101
|
+
}
|
|
102
|
+
if (typeof window !== 'undefined') {
|
|
103
|
+
return window;
|
|
104
|
+
}
|
|
105
|
+
if (typeof global !== 'undefined') {
|
|
106
|
+
return global;
|
|
107
|
+
}
|
|
108
|
+
throw 'Unable to locate global object';
|
|
109
|
+
})();
|
|
110
|
+
function bytesFromBase64(b64) {
|
|
111
|
+
if (tsProtoGlobalThis.Buffer) {
|
|
112
|
+
return Uint8Array.from(tsProtoGlobalThis.Buffer.from(b64, 'base64'));
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
var bin = tsProtoGlobalThis.atob(b64);
|
|
116
|
+
var arr = new Uint8Array(bin.length);
|
|
117
|
+
for (var i = 0; i < bin.length; ++i) {
|
|
118
|
+
arr[i] = bin.charCodeAt(i);
|
|
119
|
+
}
|
|
120
|
+
return arr;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function base64FromBytes(arr) {
|
|
124
|
+
if (tsProtoGlobalThis.Buffer) {
|
|
125
|
+
return tsProtoGlobalThis.Buffer.from(arr).toString('base64');
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
var bin_1 = [];
|
|
129
|
+
arr.forEach(function (byte) {
|
|
130
|
+
bin_1.push(String.fromCharCode(byte));
|
|
131
|
+
});
|
|
132
|
+
return tsProtoGlobalThis.btoa(bin_1.join(''));
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
function isSet(value) {
|
|
136
|
+
return value !== null && value !== undefined;
|
|
137
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import _m0 from 'protobufjs/minimal';
|
|
2
|
+
export declare const protobufPackage = "pkg.kannon.mailer.types";
|
|
3
|
+
export interface Sender {
|
|
4
|
+
email: string;
|
|
5
|
+
alias: string;
|
|
6
|
+
}
|
|
7
|
+
export interface Recipient {
|
|
8
|
+
email: string;
|
|
9
|
+
fields: {
|
|
10
|
+
[key: string]: string;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export interface Recipient_FieldsEntry {
|
|
14
|
+
key: string;
|
|
15
|
+
value: string;
|
|
16
|
+
}
|
|
17
|
+
export declare const Sender: {
|
|
18
|
+
encode(message: Sender, writer?: _m0.Writer): _m0.Writer;
|
|
19
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): Sender;
|
|
20
|
+
fromJSON(object: any): Sender;
|
|
21
|
+
toJSON(message: Sender): unknown;
|
|
22
|
+
fromPartial<I extends {
|
|
23
|
+
email?: string | undefined;
|
|
24
|
+
alias?: string | undefined;
|
|
25
|
+
} & {
|
|
26
|
+
email?: string | undefined;
|
|
27
|
+
alias?: string | undefined;
|
|
28
|
+
} & { [K in Exclude<keyof I, keyof Sender>]: never; }>(object: I): Sender;
|
|
29
|
+
};
|
|
30
|
+
export declare const Recipient: {
|
|
31
|
+
encode(message: Recipient, writer?: _m0.Writer): _m0.Writer;
|
|
32
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): Recipient;
|
|
33
|
+
fromJSON(object: any): Recipient;
|
|
34
|
+
toJSON(message: Recipient): unknown;
|
|
35
|
+
fromPartial<I extends {
|
|
36
|
+
email?: string | undefined;
|
|
37
|
+
fields?: {
|
|
38
|
+
[x: string]: string | undefined;
|
|
39
|
+
} | undefined;
|
|
40
|
+
} & {
|
|
41
|
+
email?: string | undefined;
|
|
42
|
+
fields?: ({
|
|
43
|
+
[x: string]: string | undefined;
|
|
44
|
+
} & {
|
|
45
|
+
[x: string]: string | undefined;
|
|
46
|
+
} & { [K in Exclude<keyof I["fields"], string | number>]: never; }) | undefined;
|
|
47
|
+
} & { [K_1 in Exclude<keyof I, keyof Recipient>]: never; }>(object: I): Recipient;
|
|
48
|
+
};
|
|
49
|
+
export declare const Recipient_FieldsEntry: {
|
|
50
|
+
encode(message: Recipient_FieldsEntry, writer?: _m0.Writer): _m0.Writer;
|
|
51
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): Recipient_FieldsEntry;
|
|
52
|
+
fromJSON(object: any): Recipient_FieldsEntry;
|
|
53
|
+
toJSON(message: Recipient_FieldsEntry): unknown;
|
|
54
|
+
fromPartial<I extends {
|
|
55
|
+
key?: string | undefined;
|
|
56
|
+
value?: string | undefined;
|
|
57
|
+
} & {
|
|
58
|
+
key?: string | undefined;
|
|
59
|
+
value?: string | undefined;
|
|
60
|
+
} & { [K in Exclude<keyof I, keyof Recipient_FieldsEntry>]: never; }>(object: I): Recipient_FieldsEntry;
|
|
61
|
+
};
|
|
62
|
+
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
63
|
+
export type DeepPartial<T> = T extends Builtin ? T : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
|
|
64
|
+
[K in keyof T]?: DeepPartial<T[K]>;
|
|
65
|
+
} : Partial<T>;
|
|
66
|
+
type KeysOfUnion<T> = T extends T ? keyof T : never;
|
|
67
|
+
export type Exact<P, I extends P> = P extends Builtin ? P : P & {
|
|
68
|
+
[K in keyof P]: Exact<P[K], I[K]>;
|
|
69
|
+
} & {
|
|
70
|
+
[K in Exclude<keyof I, KeysOfUnion<P>>]: never;
|
|
71
|
+
};
|
|
72
|
+
export {};
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import _m0 from 'protobufjs/minimal';
|
|
3
|
+
export var protobufPackage = 'pkg.kannon.mailer.types';
|
|
4
|
+
function createBaseSender() {
|
|
5
|
+
return { email: '', alias: '' };
|
|
6
|
+
}
|
|
7
|
+
export var Sender = {
|
|
8
|
+
encode: function (message, writer) {
|
|
9
|
+
if (writer === void 0) { writer = _m0.Writer.create(); }
|
|
10
|
+
if (message.email !== '') {
|
|
11
|
+
writer.uint32(10).string(message.email);
|
|
12
|
+
}
|
|
13
|
+
if (message.alias !== '') {
|
|
14
|
+
writer.uint32(18).string(message.alias);
|
|
15
|
+
}
|
|
16
|
+
return writer;
|
|
17
|
+
},
|
|
18
|
+
decode: function (input, length) {
|
|
19
|
+
var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
|
20
|
+
var end = length === undefined ? reader.len : reader.pos + length;
|
|
21
|
+
var message = createBaseSender();
|
|
22
|
+
while (reader.pos < end) {
|
|
23
|
+
var tag = reader.uint32();
|
|
24
|
+
switch (tag >>> 3) {
|
|
25
|
+
case 1:
|
|
26
|
+
message.email = reader.string();
|
|
27
|
+
break;
|
|
28
|
+
case 2:
|
|
29
|
+
message.alias = reader.string();
|
|
30
|
+
break;
|
|
31
|
+
default:
|
|
32
|
+
reader.skipType(tag & 7);
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return message;
|
|
37
|
+
},
|
|
38
|
+
fromJSON: function (object) {
|
|
39
|
+
return {
|
|
40
|
+
email: isSet(object.email) ? String(object.email) : '',
|
|
41
|
+
alias: isSet(object.alias) ? String(object.alias) : '',
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
toJSON: function (message) {
|
|
45
|
+
var obj = {};
|
|
46
|
+
message.email !== undefined && (obj.email = message.email);
|
|
47
|
+
message.alias !== undefined && (obj.alias = message.alias);
|
|
48
|
+
return obj;
|
|
49
|
+
},
|
|
50
|
+
fromPartial: function (object) {
|
|
51
|
+
var _a, _b;
|
|
52
|
+
var message = createBaseSender();
|
|
53
|
+
message.email = (_a = object.email) !== null && _a !== void 0 ? _a : '';
|
|
54
|
+
message.alias = (_b = object.alias) !== null && _b !== void 0 ? _b : '';
|
|
55
|
+
return message;
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
function createBaseRecipient() {
|
|
59
|
+
return { email: '', fields: {} };
|
|
60
|
+
}
|
|
61
|
+
export var Recipient = {
|
|
62
|
+
encode: function (message, writer) {
|
|
63
|
+
if (writer === void 0) { writer = _m0.Writer.create(); }
|
|
64
|
+
if (message.email !== '') {
|
|
65
|
+
writer.uint32(10).string(message.email);
|
|
66
|
+
}
|
|
67
|
+
Object.entries(message.fields).forEach(function (_a) {
|
|
68
|
+
var key = _a[0], value = _a[1];
|
|
69
|
+
Recipient_FieldsEntry.encode({ key: key, value: value }, writer.uint32(18).fork()).ldelim();
|
|
70
|
+
});
|
|
71
|
+
return writer;
|
|
72
|
+
},
|
|
73
|
+
decode: function (input, length) {
|
|
74
|
+
var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
|
75
|
+
var end = length === undefined ? reader.len : reader.pos + length;
|
|
76
|
+
var message = createBaseRecipient();
|
|
77
|
+
while (reader.pos < end) {
|
|
78
|
+
var tag = reader.uint32();
|
|
79
|
+
switch (tag >>> 3) {
|
|
80
|
+
case 1:
|
|
81
|
+
message.email = reader.string();
|
|
82
|
+
break;
|
|
83
|
+
case 2:
|
|
84
|
+
var entry2 = Recipient_FieldsEntry.decode(reader, reader.uint32());
|
|
85
|
+
if (entry2.value !== undefined) {
|
|
86
|
+
message.fields[entry2.key] = entry2.value;
|
|
87
|
+
}
|
|
88
|
+
break;
|
|
89
|
+
default:
|
|
90
|
+
reader.skipType(tag & 7);
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return message;
|
|
95
|
+
},
|
|
96
|
+
fromJSON: function (object) {
|
|
97
|
+
return {
|
|
98
|
+
email: isSet(object.email) ? String(object.email) : '',
|
|
99
|
+
fields: isObject(object.fields)
|
|
100
|
+
? Object.entries(object.fields).reduce(function (acc, _a) {
|
|
101
|
+
var key = _a[0], value = _a[1];
|
|
102
|
+
acc[key] = String(value);
|
|
103
|
+
return acc;
|
|
104
|
+
}, {})
|
|
105
|
+
: {},
|
|
106
|
+
};
|
|
107
|
+
},
|
|
108
|
+
toJSON: function (message) {
|
|
109
|
+
var obj = {};
|
|
110
|
+
message.email !== undefined && (obj.email = message.email);
|
|
111
|
+
obj.fields = {};
|
|
112
|
+
if (message.fields) {
|
|
113
|
+
Object.entries(message.fields).forEach(function (_a) {
|
|
114
|
+
var k = _a[0], v = _a[1];
|
|
115
|
+
obj.fields[k] = v;
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
return obj;
|
|
119
|
+
},
|
|
120
|
+
fromPartial: function (object) {
|
|
121
|
+
var _a, _b;
|
|
122
|
+
var message = createBaseRecipient();
|
|
123
|
+
message.email = (_a = object.email) !== null && _a !== void 0 ? _a : '';
|
|
124
|
+
message.fields = Object.entries((_b = object.fields) !== null && _b !== void 0 ? _b : {}).reduce(function (acc, _a) {
|
|
125
|
+
var key = _a[0], value = _a[1];
|
|
126
|
+
if (value !== undefined) {
|
|
127
|
+
acc[key] = String(value);
|
|
128
|
+
}
|
|
129
|
+
return acc;
|
|
130
|
+
}, {});
|
|
131
|
+
return message;
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
function createBaseRecipient_FieldsEntry() {
|
|
135
|
+
return { key: '', value: '' };
|
|
136
|
+
}
|
|
137
|
+
export var Recipient_FieldsEntry = {
|
|
138
|
+
encode: function (message, writer) {
|
|
139
|
+
if (writer === void 0) { writer = _m0.Writer.create(); }
|
|
140
|
+
if (message.key !== '') {
|
|
141
|
+
writer.uint32(10).string(message.key);
|
|
142
|
+
}
|
|
143
|
+
if (message.value !== '') {
|
|
144
|
+
writer.uint32(18).string(message.value);
|
|
145
|
+
}
|
|
146
|
+
return writer;
|
|
147
|
+
},
|
|
148
|
+
decode: function (input, length) {
|
|
149
|
+
var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
|
150
|
+
var end = length === undefined ? reader.len : reader.pos + length;
|
|
151
|
+
var message = createBaseRecipient_FieldsEntry();
|
|
152
|
+
while (reader.pos < end) {
|
|
153
|
+
var tag = reader.uint32();
|
|
154
|
+
switch (tag >>> 3) {
|
|
155
|
+
case 1:
|
|
156
|
+
message.key = reader.string();
|
|
157
|
+
break;
|
|
158
|
+
case 2:
|
|
159
|
+
message.value = reader.string();
|
|
160
|
+
break;
|
|
161
|
+
default:
|
|
162
|
+
reader.skipType(tag & 7);
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return message;
|
|
167
|
+
},
|
|
168
|
+
fromJSON: function (object) {
|
|
169
|
+
return { key: isSet(object.key) ? String(object.key) : '', value: isSet(object.value) ? String(object.value) : '' };
|
|
170
|
+
},
|
|
171
|
+
toJSON: function (message) {
|
|
172
|
+
var obj = {};
|
|
173
|
+
message.key !== undefined && (obj.key = message.key);
|
|
174
|
+
message.value !== undefined && (obj.value = message.value);
|
|
175
|
+
return obj;
|
|
176
|
+
},
|
|
177
|
+
fromPartial: function (object) {
|
|
178
|
+
var _a, _b;
|
|
179
|
+
var message = createBaseRecipient_FieldsEntry();
|
|
180
|
+
message.key = (_a = object.key) !== null && _a !== void 0 ? _a : '';
|
|
181
|
+
message.value = (_b = object.value) !== null && _b !== void 0 ? _b : '';
|
|
182
|
+
return message;
|
|
183
|
+
},
|
|
184
|
+
};
|
|
185
|
+
function isObject(value) {
|
|
186
|
+
return typeof value === 'object' && value !== null;
|
|
187
|
+
}
|
|
188
|
+
function isSet(value) {
|
|
189
|
+
return value !== null && value !== undefined;
|
|
190
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as grpc from '@grpc/grpc-js';
|
|
2
|
+
type CbFun<Req, Res> = (req: Req, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: any, response: Res) => void) => void;
|
|
3
|
+
type AsyncFun<Req, Res> = (req: Req, metadata?: grpc.Metadata, options?: Partial<grpc.CallOptions>) => Promise<Res>;
|
|
4
|
+
type promisify<CB> = CB extends CbFun<infer Req, infer Res> ? AsyncFun<Req, Res> : never;
|
|
5
|
+
export type promisifyAll<Cli extends grpc.Client> = {
|
|
6
|
+
[k in keyof Cli]: promisify<Cli[k]>;
|
|
7
|
+
};
|
|
8
|
+
declare function promisify<Req, Res>(cb: CbFun<Req, Res>): promisify<CbFun<Req, Res>>;
|
|
9
|
+
export declare function promisifyAll<TClient extends grpc.Client>(client: TClient): promisifyAll<TClient>;
|
|
10
|
+
export declare function CreateClientContructor<TClient extends grpc.Client>(Cli: ITCli<TClient>): (conf: GrpcClientConfig) => promisifyAll<TClient>;
|
|
11
|
+
interface ITCli<TClient extends grpc.Client> {
|
|
12
|
+
new (address: string, credentials: grpc.ChannelCredentials, options?: Partial<grpc.ChannelOptions>): TClient;
|
|
13
|
+
}
|
|
14
|
+
export interface GrpcClientConfig {
|
|
15
|
+
host: string;
|
|
16
|
+
skipTLS: boolean;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as grpc from '@grpc/grpc-js';
|
|
2
|
+
function promisify(cb) {
|
|
3
|
+
return function (req, metadata, options) {
|
|
4
|
+
if (metadata === void 0) { metadata = new grpc.Metadata(); }
|
|
5
|
+
if (options === void 0) { options = {}; }
|
|
6
|
+
return new Promise(function (resolve, reject) {
|
|
7
|
+
cb(req, metadata, options, function (err, res) {
|
|
8
|
+
if (!!err) {
|
|
9
|
+
return reject(err);
|
|
10
|
+
}
|
|
11
|
+
return resolve(res);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export function promisifyAll(client) {
|
|
17
|
+
var methods = Object.getPrototypeOf(client);
|
|
18
|
+
var res = {};
|
|
19
|
+
for (var _i = 0, _a = Object.entries(methods); _i < _a.length; _i++) {
|
|
20
|
+
var _b = _a[_i], name_1 = _b[0], method = _b[1];
|
|
21
|
+
res[name_1] = promisify(method.bind(client));
|
|
22
|
+
}
|
|
23
|
+
return res;
|
|
24
|
+
}
|
|
25
|
+
export function CreateClientContructor(Cli) {
|
|
26
|
+
return function (conf) {
|
|
27
|
+
var credentials = conf.skipTLS ? grpc.credentials.createInsecure() : grpc.credentials.createSsl();
|
|
28
|
+
var cli = new Cli(conf.host, credentials);
|
|
29
|
+
return promisifyAll(cli);
|
|
30
|
+
};
|
|
31
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "kannon.js",
|
|
3
|
+
"repository": {
|
|
4
|
+
"type": "git",
|
|
5
|
+
"url": "https://github.com/kannon-email/kannon.js"
|
|
6
|
+
},
|
|
7
|
+
"version": "0.1.0",
|
|
8
|
+
"description": "Kannon node client libreary",
|
|
9
|
+
"main": "lib/kannon.js",
|
|
10
|
+
"types": "lib/kannon.d.ts",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
|
|
14
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
15
|
+
"prepare": "npm run build"
|
|
16
|
+
},
|
|
17
|
+
"author": "ludusrusso",
|
|
18
|
+
"license": "ISC",
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"prettier": "^2.8.1",
|
|
21
|
+
"ts-proto": "^1.137.0",
|
|
22
|
+
"tslint": "^6.1.3",
|
|
23
|
+
"tslint-config-prettier": "^1.18.0"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@grpc/grpc-js": "^1.8.1"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"email",
|
|
30
|
+
"node",
|
|
31
|
+
"grpc"
|
|
32
|
+
],
|
|
33
|
+
"files": [
|
|
34
|
+
"lib/**/*"
|
|
35
|
+
]
|
|
36
|
+
}
|