@skyiro/sky-client 0.1.0 → 0.1.2
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/README.md +1 -1
- package/dist/enums.d.ts +33 -0
- package/dist/enums.js +1 -0
- package/dist/enums.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/dist/notifier-client.d.ts +11 -0
- package/dist/notifier-client.js +40 -44
- package/dist/notifier-client.js.map +1 -0
- package/dist/shortener-client.d.ts +8 -0
- package/dist/shortener-client.js +30 -28
- package/dist/shortener-client.js.map +1 -0
- package/dist/types.d.ts +59 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -0
- package/package.json +1 -1
- package/proto/shortener.proto +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Single dependency for Skyiro **internal gRPC** clients:
|
|
4
4
|
|
|
5
5
|
- **Notifier** — `NotifierClient` (`notifier.v1.NotifierService`)
|
|
6
|
-
- **Short** — `ShortenerClient` (`shortener.
|
|
6
|
+
- **Short** — `ShortenerClient` (`shortener.v1.ShortenerService`)
|
|
7
7
|
|
|
8
8
|
Typed **`ProductKey`**, **`EventKey`**, and **`NotificationChannel`** mirror notifier Prisma enums and seeded events so callers cannot accidentally pass unknown keys (until you extend the enums when the server adds events).
|
|
9
9
|
|
package/dist/enums.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mirrors Prisma `ProductKey` on the notifier service.
|
|
3
|
+
* Use these values when publishing events so callers stay aligned with server configuration.
|
|
4
|
+
*/
|
|
5
|
+
export declare const ProductKey: {
|
|
6
|
+
readonly SkyPeople: "SkyPeople";
|
|
7
|
+
readonly SkyOnelogin: "SkyOnelogin";
|
|
8
|
+
readonly SkyPaper: "SkyPaper";
|
|
9
|
+
readonly SkyBill: "SkyBill";
|
|
10
|
+
};
|
|
11
|
+
export type ProductKey = (typeof ProductKey)[keyof typeof ProductKey];
|
|
12
|
+
/**
|
|
13
|
+
* Known notifier `Event.key` values from seed data (`prisma/data/events.yml`).
|
|
14
|
+
* Add entries here when new events are introduced on the server.
|
|
15
|
+
*/
|
|
16
|
+
export declare const EventKey: {
|
|
17
|
+
readonly LOGIN: "LOGIN";
|
|
18
|
+
readonly PASSWORD_RESET: "PASSWORD_RESET";
|
|
19
|
+
readonly DOC_SIGN_REQUEST: "DOC_SIGN_REQUEST";
|
|
20
|
+
readonly DOC_SIGN_OTP: "DOC_SIGN_OTP";
|
|
21
|
+
readonly DOC_SIGN_COMPLETED: "DOC_SIGN_COMPLETED";
|
|
22
|
+
readonly DOC_SIGN_REJECTED: "DOC_SIGN_REJECTED";
|
|
23
|
+
readonly DOC_OVERDUE_NOTIFICATION: "DOC_OVERDUE_NOTIFICATION";
|
|
24
|
+
};
|
|
25
|
+
export type EventKey = (typeof EventKey)[keyof typeof EventKey];
|
|
26
|
+
/** Channels accepted by notifier `PublishEvent` (matches Prisma `NotificationChannel`). */
|
|
27
|
+
export declare const NotificationChannel: {
|
|
28
|
+
readonly SMS: "SMS";
|
|
29
|
+
readonly EMAIL: "EMAIL";
|
|
30
|
+
readonly PUSH: "PUSH";
|
|
31
|
+
readonly WHATSAPP: "WHATSAPP";
|
|
32
|
+
};
|
|
33
|
+
export type NotificationChannel = (typeof NotificationChannel)[keyof typeof NotificationChannel];
|
package/dist/enums.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enums.js","sourceRoot":"","sources":["../src/enums.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACU,QAAA,UAAU,GAAG;IACxB,SAAS,EAAE,WAAW;IACtB,WAAW,EAAE,aAAa;IAC1B,QAAQ,EAAE,UAAU;IACpB,OAAO,EAAE,SAAS;CACV,CAAC;AAIX;;;GAGG;AACU,QAAA,QAAQ,GAAG;IACtB,KAAK,EAAE,OAAO;IACd,cAAc,EAAE,gBAAgB;IAChC,gBAAgB,EAAE,kBAAkB;IACpC,YAAY,EAAE,cAAc;IAC5B,kBAAkB,EAAE,oBAAoB;IACxC,iBAAiB,EAAE,mBAAmB;IACtC,wBAAwB,EAAE,0BAA0B;CAC5C,CAAC;AAIX,2FAA2F;AAC9E,QAAA,mBAAmB,GAAG;IACjC,GAAG,EAAE,KAAK;IACV,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE,UAAU;CACZ,CAAC"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
CHANGED
|
@@ -21,3 +21,4 @@ var notifier_client_1 = require("./notifier-client");
|
|
|
21
21
|
Object.defineProperty(exports, "NotifierClient", { enumerable: true, get: function () { return notifier_client_1.NotifierClient; } });
|
|
22
22
|
var shortener_client_1 = require("./shortener-client");
|
|
23
23
|
Object.defineProperty(exports, "ShortenerClient", { enumerable: true, get: function () { return shortener_client_1.ShortenerClient; } });
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,0CAAwB;AACxB,qDAAmD;AAA1C,iHAAA,cAAc,OAAA;AACvB,uDAAqD;AAA5C,mHAAA,eAAe,OAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ProductKey } from "./enums";
|
|
2
|
+
import type { PublishEmailEventRequest, PublishEventRequest, PublishEventResponse, PublishNotificationEventRequest } from "./types";
|
|
3
|
+
export declare class NotifierClient {
|
|
4
|
+
private readonly client;
|
|
5
|
+
private readonly defaultProductKey;
|
|
6
|
+
constructor(address: string, defaultProductKey: ProductKey);
|
|
7
|
+
publishEvent(data: PublishEventRequest): Promise<PublishEventResponse>;
|
|
8
|
+
publishEmailEvent(data: PublishEmailEventRequest): Promise<PublishEventResponse>;
|
|
9
|
+
publishNotificationEvent(data: PublishNotificationEventRequest): Promise<PublishEventResponse>;
|
|
10
|
+
close(): void;
|
|
11
|
+
}
|
package/dist/notifier-client.js
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NotifierClient = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const grpc_js_1 = require("@grpc/grpc-js");
|
|
5
|
+
const proto_loader_1 = require("@grpc/proto-loader");
|
|
6
|
+
const node_path_1 = require("node:path");
|
|
7
7
|
function loadNotifierGrpc(address) {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const protoPath = (0, node_path_1.resolve)(__dirname, "../proto/notifier.proto");
|
|
9
|
+
const packageDefinition = (0, proto_loader_1.loadSync)(protoPath, {
|
|
10
10
|
keepCase: false,
|
|
11
11
|
longs: String,
|
|
12
12
|
enums: String,
|
|
13
13
|
defaults: true,
|
|
14
14
|
oneofs: true,
|
|
15
15
|
});
|
|
16
|
-
|
|
16
|
+
const loaded = (0, grpc_js_1.loadPackageDefinition)(packageDefinition);
|
|
17
17
|
return new loaded.notifier.v1.NotifierService(address, grpc_js_1.ChannelCredentials.createInsecure());
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
class NotifierClient {
|
|
20
|
+
client;
|
|
21
|
+
defaultProductKey;
|
|
22
|
+
constructor(address, defaultProductKey) {
|
|
21
23
|
this.client = loadNotifierGrpc(address);
|
|
22
24
|
this.defaultProductKey = defaultProductKey;
|
|
23
25
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var productKey = (_a = data.productKey) !== null && _a !== void 0 ? _a : this.defaultProductKey;
|
|
28
|
-
var grpcReq = {
|
|
26
|
+
publishEvent(data) {
|
|
27
|
+
const productKey = data.productKey ?? this.defaultProductKey;
|
|
28
|
+
const grpcReq = {
|
|
29
29
|
tenantId: data.tenantId,
|
|
30
|
-
productKey
|
|
30
|
+
productKey,
|
|
31
31
|
eventKey: data.eventKey,
|
|
32
32
|
destinationAddress: data.destinationAddress,
|
|
33
|
-
channel:
|
|
34
|
-
payload:
|
|
35
|
-
idempotencyKey:
|
|
33
|
+
channel: data.channel ?? "",
|
|
34
|
+
payload: data.payload ?? {},
|
|
35
|
+
idempotencyKey: data.idempotencyKey ?? "",
|
|
36
36
|
};
|
|
37
|
-
return new Promise(
|
|
38
|
-
|
|
37
|
+
return new Promise((resolvePromise, rejectPromise) => {
|
|
38
|
+
this.client.PublishEvent(grpcReq, (error, response) => {
|
|
39
39
|
if (error) {
|
|
40
40
|
rejectPromise(error);
|
|
41
41
|
return;
|
|
@@ -43,21 +43,19 @@ var NotifierClient = /** @class */ (function () {
|
|
|
43
43
|
resolvePromise(response);
|
|
44
44
|
});
|
|
45
45
|
});
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
var productKey = (_a = data.productKey) !== null && _a !== void 0 ? _a : this.defaultProductKey;
|
|
51
|
-
var grpcReq = {
|
|
46
|
+
}
|
|
47
|
+
publishEmailEvent(data) {
|
|
48
|
+
const productKey = data.productKey ?? this.defaultProductKey;
|
|
49
|
+
const grpcReq = {
|
|
52
50
|
tenantId: data.tenantId,
|
|
53
51
|
recipient: data.recipient,
|
|
54
52
|
templateKey: data.templateKey,
|
|
55
|
-
payload:
|
|
56
|
-
idempotencyKey:
|
|
57
|
-
productKey
|
|
53
|
+
payload: data.payload ?? {},
|
|
54
|
+
idempotencyKey: data.idempotencyKey ?? "",
|
|
55
|
+
productKey,
|
|
58
56
|
};
|
|
59
|
-
return new Promise(
|
|
60
|
-
|
|
57
|
+
return new Promise((resolvePromise, rejectPromise) => {
|
|
58
|
+
this.client.PublishEmailEvent(grpcReq, (error, response) => {
|
|
61
59
|
if (error) {
|
|
62
60
|
rejectPromise(error);
|
|
63
61
|
return;
|
|
@@ -65,21 +63,19 @@ var NotifierClient = /** @class */ (function () {
|
|
|
65
63
|
resolvePromise(response);
|
|
66
64
|
});
|
|
67
65
|
});
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
var _a, _b;
|
|
72
|
-
var grpcReq = {
|
|
66
|
+
}
|
|
67
|
+
publishNotificationEvent(data) {
|
|
68
|
+
const grpcReq = {
|
|
73
69
|
tenantId: data.tenantId,
|
|
74
70
|
userId: data.userId,
|
|
75
71
|
channel: data.channel,
|
|
76
72
|
title: data.title,
|
|
77
73
|
body: data.body,
|
|
78
|
-
payload:
|
|
79
|
-
idempotencyKey:
|
|
74
|
+
payload: data.payload ?? {},
|
|
75
|
+
idempotencyKey: data.idempotencyKey ?? "",
|
|
80
76
|
};
|
|
81
|
-
return new Promise(
|
|
82
|
-
|
|
77
|
+
return new Promise((resolvePromise, rejectPromise) => {
|
|
78
|
+
this.client.PublishNotificationEvent(grpcReq, (error, response) => {
|
|
83
79
|
if (error) {
|
|
84
80
|
rejectPromise(error);
|
|
85
81
|
return;
|
|
@@ -87,10 +83,10 @@ var NotifierClient = /** @class */ (function () {
|
|
|
87
83
|
resolvePromise(response);
|
|
88
84
|
});
|
|
89
85
|
});
|
|
90
|
-
}
|
|
91
|
-
|
|
86
|
+
}
|
|
87
|
+
close() {
|
|
92
88
|
this.client.close();
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
}());
|
|
89
|
+
}
|
|
90
|
+
}
|
|
96
91
|
exports.NotifierClient = NotifierClient;
|
|
92
|
+
//# sourceMappingURL=notifier-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifier-client.js","sourceRoot":"","sources":["../src/notifier-client.ts"],"names":[],"mappings":";;;AAAA,2CAMuB;AACvB,qDAA8C;AAC9C,yCAAoC;AAqEpC,SAAS,gBAAgB,CAAC,OAAe;IACvC,MAAM,SAAS,GAAG,IAAA,mBAAO,EAAC,SAAS,EAAE,yBAAyB,CAAC,CAAC;IAChE,MAAM,iBAAiB,GAAG,IAAA,uBAAQ,EAAC,S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C,wBAAwB,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;gBAChE,IAAI,KAAK,EAAE,CAAC;oBACV,aAAa,CAAC,KAAK,CAAC,CAAC;oBACrB,OAAO;gBACT,CAAC;gBACD,cAAc,CAAC,QAAQ,CAAC,CAAC;YAC3B,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK;QACF,IAAI,CAAC,MAAiB,CAAC,KAAK,EAAE,CAAC;IAClC,CAAC;CACF;AAnFD,wCAmFC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CreateShortUrlRequest, CreateShortUrlResponse, RetrieveShortUrlRequest, RetrieveShortUrlResponse } from "./types";
|
|
2
|
+
export declare class ShortenerClient {
|
|
3
|
+
private readonly client;
|
|
4
|
+
constructor(address: string);
|
|
5
|
+
createShortUrl(data: CreateShortUrlRequest): Promise<CreateShortUrlResponse>;
|
|
6
|
+
retrieveShortUrl(data: RetrieveShortUrlRequest): Promise<RetrieveShortUrlResponse>;
|
|
7
|
+
close(): void;
|
|
8
|
+
}
|
package/dist/shortener-client.js
CHANGED
|
@@ -1,36 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ShortenerClient = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const grpc_js_1 = require("@grpc/grpc-js");
|
|
5
|
+
const proto_loader_1 = require("@grpc/proto-loader");
|
|
6
|
+
const node_path_1 = require("node:path");
|
|
7
7
|
function loadShortenerGrpc(address) {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const protoPath = (0, node_path_1.resolve)(__dirname, "../proto/shortener.proto");
|
|
9
|
+
const packageDefinition = (0, proto_loader_1.loadSync)(protoPath, {
|
|
10
10
|
keepCase: false,
|
|
11
11
|
longs: String,
|
|
12
12
|
enums: String,
|
|
13
13
|
defaults: true,
|
|
14
14
|
oneofs: true,
|
|
15
15
|
});
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
const loaded = (0, grpc_js_1.loadPackageDefinition)(packageDefinition);
|
|
17
|
+
const ShortenerCtor = loaded.shortener?.v1?.ShortenerService;
|
|
18
|
+
if (!ShortenerCtor) {
|
|
19
|
+
throw new Error("Failed to load shortener gRPC constructor from proto");
|
|
20
|
+
}
|
|
21
|
+
return new ShortenerCtor(address, grpc_js_1.ChannelCredentials.createInsecure());
|
|
18
22
|
}
|
|
19
|
-
|
|
20
|
-
|
|
23
|
+
class ShortenerClient {
|
|
24
|
+
client;
|
|
25
|
+
constructor(address) {
|
|
21
26
|
this.client = loadShortenerGrpc(address);
|
|
22
27
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
var _a, _b, _c;
|
|
27
|
-
_this.client.CreateShortUrl({
|
|
28
|
+
createShortUrl(data) {
|
|
29
|
+
return new Promise((resolvePromise, rejectPromise) => {
|
|
30
|
+
this.client.CreateShortUrl({
|
|
28
31
|
url: data.url,
|
|
29
|
-
customCode:
|
|
32
|
+
customCode: data.customCode ?? "",
|
|
30
33
|
ttlSeconds: data.ttlSeconds,
|
|
31
|
-
expiresIn:
|
|
32
|
-
expiresAt:
|
|
33
|
-
},
|
|
34
|
+
expiresIn: data.expiresIn ?? "",
|
|
35
|
+
expiresAt: data.expiresAt ?? "",
|
|
36
|
+
}, (error, response) => {
|
|
34
37
|
if (error) {
|
|
35
38
|
rejectPromise(error);
|
|
36
39
|
return;
|
|
@@ -38,11 +41,10 @@ var ShortenerClient = /** @class */ (function () {
|
|
|
38
41
|
resolvePromise(response);
|
|
39
42
|
});
|
|
40
43
|
});
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
_this.client.RetrieveShortUrl(data, function (error, response) {
|
|
44
|
+
}
|
|
45
|
+
retrieveShortUrl(data) {
|
|
46
|
+
return new Promise((resolvePromise, rejectPromise) => {
|
|
47
|
+
this.client.RetrieveShortUrl(data, (error, response) => {
|
|
46
48
|
if (error) {
|
|
47
49
|
rejectPromise(error);
|
|
48
50
|
return;
|
|
@@ -50,10 +52,10 @@ var ShortenerClient = /** @class */ (function () {
|
|
|
50
52
|
resolvePromise(response);
|
|
51
53
|
});
|
|
52
54
|
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
+
}
|
|
56
|
+
close() {
|
|
55
57
|
this.client.close();
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
}());
|
|
58
|
+
}
|
|
59
|
+
}
|
|
59
60
|
exports.ShortenerClient = ShortenerClient;
|
|
61
|
+
//# sourceMappingURL=shortener-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shortener-client.js","sourceRoot":"","sources":["../src/shortener-client.ts"],"names":[],"mappings":";;;AAAA,2CAMuB;AACvB,qDAA8C;AAC9C,yCAAoC;AAkCpC,SAAS,iBAAiB,CAAC,OAAe;IACxC,MAAM,SAAS,GAAG,IAAA,mBAAO,EAAC,SAAS,EAAE,0BAA0B,CAAC,CAAC;IACjE,MAAM,iBAAiB,GAAG,IAAA,uBAAQ,EAAC,SAAS,EAAE;QAC5C,QAAQ,EAAE,KAAK;QACf,KAAK,EAAE,MAAM;QACb,KAAK,EAAE,MAAM;QACb,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,IAAI;KACb,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,IAAA,+BAAqB,EAClC,iBAAiB,CACiB,CAAC;IAErC,MAAM,aAAa,GAAG,MAAM,CAAC,SAAS,EAAE,EAAE,EAAE,gBAAgB,CAAC;IAC7D,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;IAC1E,CAAC;IAED,OAAO,IAAI,aAAa,CACtB,OAAO,EACP,4BAAkB,CAAC,cAAc,EAAE,CACpC,CAAC;AACJ,CAAC;AAED,MAAa,eAAe;IACT,MAAM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, NotificationChannel, ProductKey } from "./enums";
|
|
2
|
+
export type PayloadMap = Record<string, string>;
|
|
3
|
+
export interface PublishEventRequest {
|
|
4
|
+
tenantId: string;
|
|
5
|
+
/** Defaults to the client’s constructor `defaultProductKey` when omitted. */
|
|
6
|
+
productKey?: ProductKey;
|
|
7
|
+
eventKey: EventKey;
|
|
8
|
+
destinationAddress: string[];
|
|
9
|
+
channel?: NotificationChannel;
|
|
10
|
+
payload?: PayloadMap;
|
|
11
|
+
idempotencyKey?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface PublishEmailEventRequest {
|
|
14
|
+
tenantId: string;
|
|
15
|
+
recipient: string;
|
|
16
|
+
templateKey: string;
|
|
17
|
+
payload?: PayloadMap;
|
|
18
|
+
idempotencyKey?: string;
|
|
19
|
+
productKey?: ProductKey;
|
|
20
|
+
}
|
|
21
|
+
export interface PublishNotificationEventRequest {
|
|
22
|
+
tenantId: string;
|
|
23
|
+
userId: string;
|
|
24
|
+
channel: NotificationChannel;
|
|
25
|
+
title: string;
|
|
26
|
+
body: string;
|
|
27
|
+
payload?: PayloadMap;
|
|
28
|
+
idempotencyKey?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface PublishEventResponse {
|
|
31
|
+
eventId: string;
|
|
32
|
+
queueJobId: string;
|
|
33
|
+
status: string;
|
|
34
|
+
}
|
|
35
|
+
export type CreateShortUrlRequest = {
|
|
36
|
+
url: string;
|
|
37
|
+
customCode?: string;
|
|
38
|
+
ttlSeconds?: number;
|
|
39
|
+
expiresIn?: string;
|
|
40
|
+
expiresAt?: string;
|
|
41
|
+
};
|
|
42
|
+
export type CreateShortUrlResponse = {
|
|
43
|
+
code: string;
|
|
44
|
+
shortUrl: string;
|
|
45
|
+
targetUrl: string;
|
|
46
|
+
expiresAt: string;
|
|
47
|
+
};
|
|
48
|
+
export type RetrieveShortUrlRequest = {
|
|
49
|
+
code: string;
|
|
50
|
+
};
|
|
51
|
+
export type RetrieveShortUrlResponse = {
|
|
52
|
+
found: boolean;
|
|
53
|
+
code: string;
|
|
54
|
+
targetUrl: string;
|
|
55
|
+
shortUrl: string;
|
|
56
|
+
createdAt: string;
|
|
57
|
+
expiresAt: string;
|
|
58
|
+
ttlSeconds: number;
|
|
59
|
+
};
|
package/dist/types.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
package/proto/shortener.proto
CHANGED