@purpleschool/gptbot 0.13.8 → 0.13.9
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/api/controllers/http/b2b.ts +3 -2
- package/api/routes.ts +4 -2
- package/build/api/controllers/http/b2b.js +3 -2
- package/build/api/routes.js +3 -2
- package/build/commands/b2b/create-api-key.command.js +46 -0
- package/build/commands/b2b/get-api-key.command.js +2 -3
- package/build/commands/b2b/index.js +2 -0
- package/build/commands/b2b/update-api-key.command.js +19 -0
- package/build/constants/api-key/enums/api-key-expiration-option.enum.js +11 -0
- package/build/constants/api-key/enums/api-key-status.enum.js +10 -0
- package/build/constants/api-key/enums/index.js +18 -0
- package/build/constants/api-key/index.js +17 -0
- package/build/constants/index.js +1 -0
- package/build/models/api-key.schema.js +9 -2
- package/commands/b2b/create-api-key.command.ts +47 -0
- package/commands/b2b/get-api-key.command.ts +2 -3
- package/commands/b2b/index.ts +2 -0
- package/commands/b2b/update-api-key.command.ts +22 -0
- package/constants/api-key/enums/api-key-expiration-option.enum.ts +7 -0
- package/constants/api-key/enums/api-key-status.enum.ts +6 -0
- package/constants/api-key/enums/index.ts +2 -0
- package/constants/api-key/index.ts +1 -0
- package/constants/index.ts +1 -0
- package/models/api-key.schema.ts +11 -2
- package/package.json +1 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export const B2B_CONTROLLER = 'private/b2b' as const;
|
|
2
2
|
|
|
3
3
|
export const B2B_ROUTES = {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
GET_API_TOKENS: 'tokens',
|
|
5
|
+
UPDATE_API_TOKEN: (uuid: string) => `tokens/${uuid}`,
|
|
6
|
+
CREATE_API_TOKEN: 'create/token',
|
|
6
7
|
SEND_TEXT_REQUEST: 'completions',
|
|
7
8
|
SEND_IMAGE_REQUEST: 'image/generation',
|
|
8
9
|
GET_B2B_IMAGE_JOB: (uuid: string) => `image/generation/jobs/${uuid}`,
|
package/api/routes.ts
CHANGED
|
@@ -1246,8 +1246,10 @@ export const REST_API = {
|
|
|
1246
1246
|
CALLBACK: `${ROOT}/${CONTROLLERS.CLOUD_PAYMENTS_CONTROLLER}/${CONTROLLERS.CLOUD_PAYMENTS_ROUTES.CALLBACK}`,
|
|
1247
1247
|
},
|
|
1248
1248
|
B2B: {
|
|
1249
|
-
|
|
1250
|
-
|
|
1249
|
+
CREATE_API_TOKEN: `${ROOT}/${CONTROLLERS.B2B_CONTROLLER}/${CONTROLLERS.B2B_ROUTES.CREATE_API_TOKEN}`,
|
|
1250
|
+
GET_API_TOKENS: `${ROOT}/${CONTROLLERS.B2B_CONTROLLER}/${CONTROLLERS.B2B_ROUTES.GET_API_TOKENS}`,
|
|
1251
|
+
UPDATE_API_TOKEN: (uuid: string) =>
|
|
1252
|
+
`${ROOT}/${CONTROLLERS.B2B_CONTROLLER}/${CONTROLLERS.B2B_ROUTES.UPDATE_API_TOKEN(uuid)}`,
|
|
1251
1253
|
SEND_TEXT_REQUEST: `${ROOT}/${CONTROLLERS.B2B_CONTROLLER}/${CONTROLLERS.B2B_ROUTES.SEND_TEXT_REQUEST}`,
|
|
1252
1254
|
SEND_IMAGE_REQUEST: `${ROOT}/${CONTROLLERS.B2B_CONTROLLER}/${CONTROLLERS.B2B_ROUTES.SEND_IMAGE_REQUEST}`,
|
|
1253
1255
|
GET_B2B_IMAGE_JOB: (uuid: string) =>
|
|
@@ -3,8 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.B2B_ROUTES = exports.B2B_CONTROLLER = void 0;
|
|
4
4
|
exports.B2B_CONTROLLER = 'private/b2b';
|
|
5
5
|
exports.B2B_ROUTES = {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
GET_API_TOKENS: 'tokens',
|
|
7
|
+
UPDATE_API_TOKEN: (uuid) => `tokens/${uuid}`,
|
|
8
|
+
CREATE_API_TOKEN: 'create/token',
|
|
8
9
|
SEND_TEXT_REQUEST: 'completions',
|
|
9
10
|
SEND_IMAGE_REQUEST: 'image/generation',
|
|
10
11
|
GET_B2B_IMAGE_JOB: (uuid) => `image/generation/jobs/${uuid}`,
|
package/build/api/routes.js
CHANGED
|
@@ -919,8 +919,9 @@ exports.REST_API = {
|
|
|
919
919
|
CALLBACK: `${exports.ROOT}/${CONTROLLERS.CLOUD_PAYMENTS_CONTROLLER}/${CONTROLLERS.CLOUD_PAYMENTS_ROUTES.CALLBACK}`,
|
|
920
920
|
},
|
|
921
921
|
B2B: {
|
|
922
|
-
|
|
923
|
-
|
|
922
|
+
CREATE_API_TOKEN: `${exports.ROOT}/${CONTROLLERS.B2B_CONTROLLER}/${CONTROLLERS.B2B_ROUTES.CREATE_API_TOKEN}`,
|
|
923
|
+
GET_API_TOKENS: `${exports.ROOT}/${CONTROLLERS.B2B_CONTROLLER}/${CONTROLLERS.B2B_ROUTES.GET_API_TOKENS}`,
|
|
924
|
+
UPDATE_API_TOKEN: (uuid) => `${exports.ROOT}/${CONTROLLERS.B2B_CONTROLLER}/${CONTROLLERS.B2B_ROUTES.UPDATE_API_TOKEN(uuid)}`,
|
|
924
925
|
SEND_TEXT_REQUEST: `${exports.ROOT}/${CONTROLLERS.B2B_CONTROLLER}/${CONTROLLERS.B2B_ROUTES.SEND_TEXT_REQUEST}`,
|
|
925
926
|
SEND_IMAGE_REQUEST: `${exports.ROOT}/${CONTROLLERS.B2B_CONTROLLER}/${CONTROLLERS.B2B_ROUTES.SEND_IMAGE_REQUEST}`,
|
|
926
927
|
GET_B2B_IMAGE_JOB: (uuid) => `${exports.ROOT}/${CONTROLLERS.B2B_CONTROLLER}/${CONTROLLERS.B2B_ROUTES.GET_B2B_IMAGE_JOB(uuid)}`,
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CreateApiKeyCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const api_key_expiration_option_enum_1 = require("../../constants/api-key/enums/api-key-expiration-option.enum");
|
|
6
|
+
var CreateApiKeyCommand;
|
|
7
|
+
(function (CreateApiKeyCommand) {
|
|
8
|
+
const resolveExpiresAt = (expiresAt) => {
|
|
9
|
+
if (expiresAt === undefined)
|
|
10
|
+
return undefined;
|
|
11
|
+
if (expiresAt === null || expiresAt === api_key_expiration_option_enum_1.API_KEY_EXPIRATION_OPTION.NONE)
|
|
12
|
+
return null;
|
|
13
|
+
if (expiresAt instanceof Date)
|
|
14
|
+
return expiresAt;
|
|
15
|
+
const date = new Date();
|
|
16
|
+
switch (expiresAt) {
|
|
17
|
+
case api_key_expiration_option_enum_1.API_KEY_EXPIRATION_OPTION.SEVEN_DAYS:
|
|
18
|
+
date.setDate(date.getDate() + 7);
|
|
19
|
+
return date;
|
|
20
|
+
case api_key_expiration_option_enum_1.API_KEY_EXPIRATION_OPTION.THIRTY_DAYS:
|
|
21
|
+
date.setDate(date.getDate() + 30);
|
|
22
|
+
return date;
|
|
23
|
+
case api_key_expiration_option_enum_1.API_KEY_EXPIRATION_OPTION.NINETY_DAYS:
|
|
24
|
+
date.setDate(date.getDate() + 90);
|
|
25
|
+
return date;
|
|
26
|
+
case api_key_expiration_option_enum_1.API_KEY_EXPIRATION_OPTION.ONE_YEAR:
|
|
27
|
+
date.setFullYear(date.getFullYear() + 1);
|
|
28
|
+
return date;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
CreateApiKeyCommand.RequestBodySchema = zod_1.z.object({
|
|
32
|
+
title: zod_1.z.string().min(1).max(64),
|
|
33
|
+
limit: zod_1.z.number().int().nonnegative().nullable().optional(),
|
|
34
|
+
expiresAt: zod_1.z
|
|
35
|
+
.union([zod_1.z.coerce.date(), zod_1.z.nativeEnum(api_key_expiration_option_enum_1.API_KEY_EXPIRATION_OPTION)])
|
|
36
|
+
.nullable()
|
|
37
|
+
.optional()
|
|
38
|
+
.transform(resolveExpiresAt),
|
|
39
|
+
});
|
|
40
|
+
CreateApiKeyCommand.ResponseSchema = zod_1.z.object({
|
|
41
|
+
data: zod_1.z.object({
|
|
42
|
+
uuid: zod_1.z.string().uuid(),
|
|
43
|
+
rawKey: zod_1.z.string(),
|
|
44
|
+
}),
|
|
45
|
+
});
|
|
46
|
+
})(CreateApiKeyCommand || (exports.CreateApiKeyCommand = CreateApiKeyCommand = {}));
|
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GetApiKeyCommand = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
+
const api_key_schema_1 = require("../../models/api-key.schema");
|
|
5
6
|
var GetApiKeyCommand;
|
|
6
7
|
(function (GetApiKeyCommand) {
|
|
7
8
|
GetApiKeyCommand.ResponseSchema = zod_1.z.object({
|
|
8
|
-
data: zod_1.z.
|
|
9
|
-
apiKey: zod_1.z.string(),
|
|
10
|
-
}),
|
|
9
|
+
data: zod_1.z.array(api_key_schema_1.ApiKeySchema),
|
|
11
10
|
});
|
|
12
11
|
})(GetApiKeyCommand || (exports.GetApiKeyCommand = GetApiKeyCommand = {}));
|
|
@@ -14,7 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./create-api-key.command"), exports);
|
|
17
18
|
__exportStar(require("./get-api-key.command"), exports);
|
|
19
|
+
__exportStar(require("./update-api-key.command"), exports);
|
|
18
20
|
__exportStar(require("./refresh-api-key.command"), exports);
|
|
19
21
|
__exportStar(require("./send-text-request.command"), exports);
|
|
20
22
|
__exportStar(require("./send-image-request.command"), exports);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UpdateApiKeyCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const api_key_schema_1 = require("../../models/api-key.schema");
|
|
6
|
+
var UpdateApiKeyCommand;
|
|
7
|
+
(function (UpdateApiKeyCommand) {
|
|
8
|
+
UpdateApiKeyCommand.RequestParamsSchema = zod_1.z.object({
|
|
9
|
+
uuid: zod_1.z.string().uuid(),
|
|
10
|
+
});
|
|
11
|
+
UpdateApiKeyCommand.RequestBodySchema = zod_1.z.object({
|
|
12
|
+
title: zod_1.z.string().min(1).optional(),
|
|
13
|
+
limit: zod_1.z.number().int().nonnegative().nullable().optional(),
|
|
14
|
+
expiresAt: zod_1.z.coerce.date().nullable().optional(),
|
|
15
|
+
});
|
|
16
|
+
UpdateApiKeyCommand.ResponseSchema = zod_1.z.object({
|
|
17
|
+
data: api_key_schema_1.ApiKeySchema,
|
|
18
|
+
});
|
|
19
|
+
})(UpdateApiKeyCommand || (exports.UpdateApiKeyCommand = UpdateApiKeyCommand = {}));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.API_KEY_EXPIRATION_OPTION = void 0;
|
|
4
|
+
var API_KEY_EXPIRATION_OPTION;
|
|
5
|
+
(function (API_KEY_EXPIRATION_OPTION) {
|
|
6
|
+
API_KEY_EXPIRATION_OPTION["NONE"] = "none";
|
|
7
|
+
API_KEY_EXPIRATION_OPTION["SEVEN_DAYS"] = "7_days";
|
|
8
|
+
API_KEY_EXPIRATION_OPTION["THIRTY_DAYS"] = "30_days";
|
|
9
|
+
API_KEY_EXPIRATION_OPTION["NINETY_DAYS"] = "90_days";
|
|
10
|
+
API_KEY_EXPIRATION_OPTION["ONE_YEAR"] = "1_year";
|
|
11
|
+
})(API_KEY_EXPIRATION_OPTION || (exports.API_KEY_EXPIRATION_OPTION = API_KEY_EXPIRATION_OPTION = {}));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.API_KEY_STATUS = void 0;
|
|
4
|
+
var API_KEY_STATUS;
|
|
5
|
+
(function (API_KEY_STATUS) {
|
|
6
|
+
API_KEY_STATUS["ACTIVE"] = "active";
|
|
7
|
+
API_KEY_STATUS["INACTIVE"] = "inactive";
|
|
8
|
+
API_KEY_STATUS["EXPIRED"] = "expired";
|
|
9
|
+
API_KEY_STATUS["LIMITED"] = "limited";
|
|
10
|
+
})(API_KEY_STATUS || (exports.API_KEY_STATUS = API_KEY_STATUS = {}));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./api-key-expiration-option.enum"), exports);
|
|
18
|
+
__exportStar(require("./api-key-status.enum"), exports);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./enums"), exports);
|
package/build/constants/index.js
CHANGED
|
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./ai-model"), exports);
|
|
18
|
+
__exportStar(require("./api-key"), exports);
|
|
18
19
|
__exportStar(require("./agents"), exports);
|
|
19
20
|
__exportStar(require("./blog"), exports);
|
|
20
21
|
__exportStar(require("./billing"), exports);
|
|
@@ -5,11 +5,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.ApiKeySchema = void 0;
|
|
7
7
|
const zod_1 = __importDefault(require("zod"));
|
|
8
|
+
const api_key_status_enum_1 = require("../constants/api-key/enums/api-key-status.enum");
|
|
8
9
|
exports.ApiKeySchema = zod_1.default.object({
|
|
9
10
|
uuid: zod_1.default.string().uuid(),
|
|
11
|
+
title: zod_1.default.string(),
|
|
12
|
+
publicId: zod_1.default.string(),
|
|
10
13
|
userId: zod_1.default.string().uuid(),
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
status: zod_1.default.nativeEnum(api_key_status_enum_1.API_KEY_STATUS),
|
|
15
|
+
limit: zod_1.default.number().nullable(),
|
|
16
|
+
spent: zod_1.default.number(),
|
|
17
|
+
maskedKey: zod_1.default.string(),
|
|
13
18
|
createdAt: zod_1.default.date(),
|
|
14
19
|
updatedAt: zod_1.default.date(),
|
|
20
|
+
expiresAt: zod_1.default.date().nullable(),
|
|
21
|
+
lastUsedAt: zod_1.default.date().nullable(),
|
|
15
22
|
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { API_KEY_EXPIRATION_OPTION } from '../../constants/api-key/enums/api-key-expiration-option.enum';
|
|
3
|
+
|
|
4
|
+
export namespace CreateApiKeyCommand {
|
|
5
|
+
const resolveExpiresAt = (expiresAt?: Date | API_KEY_EXPIRATION_OPTION | null): Date | null | undefined => {
|
|
6
|
+
if (expiresAt === undefined) return undefined;
|
|
7
|
+
if (expiresAt === null || expiresAt === API_KEY_EXPIRATION_OPTION.NONE) return null;
|
|
8
|
+
if (expiresAt instanceof Date) return expiresAt;
|
|
9
|
+
|
|
10
|
+
const date = new Date();
|
|
11
|
+
|
|
12
|
+
switch (expiresAt) {
|
|
13
|
+
case API_KEY_EXPIRATION_OPTION.SEVEN_DAYS:
|
|
14
|
+
date.setDate(date.getDate() + 7);
|
|
15
|
+
return date;
|
|
16
|
+
case API_KEY_EXPIRATION_OPTION.THIRTY_DAYS:
|
|
17
|
+
date.setDate(date.getDate() + 30);
|
|
18
|
+
return date;
|
|
19
|
+
case API_KEY_EXPIRATION_OPTION.NINETY_DAYS:
|
|
20
|
+
date.setDate(date.getDate() + 90);
|
|
21
|
+
return date;
|
|
22
|
+
case API_KEY_EXPIRATION_OPTION.ONE_YEAR:
|
|
23
|
+
date.setFullYear(date.getFullYear() + 1);
|
|
24
|
+
return date;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const RequestBodySchema = z.object({
|
|
29
|
+
title: z.string().min(1).max(64),
|
|
30
|
+
limit: z.number().int().nonnegative().nullable().optional(),
|
|
31
|
+
expiresAt: z
|
|
32
|
+
.union([z.coerce.date(), z.nativeEnum(API_KEY_EXPIRATION_OPTION)])
|
|
33
|
+
.nullable()
|
|
34
|
+
.optional()
|
|
35
|
+
.transform(resolveExpiresAt),
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export const ResponseSchema = z.object({
|
|
39
|
+
data: z.object({
|
|
40
|
+
uuid: z.string().uuid(),
|
|
41
|
+
rawKey: z.string(),
|
|
42
|
+
}),
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export type RequestBody = z.infer<typeof RequestBodySchema>;
|
|
46
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
47
|
+
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { ApiKeySchema } from '../../models/api-key.schema';
|
|
2
3
|
|
|
3
4
|
export namespace GetApiKeyCommand {
|
|
4
5
|
export const ResponseSchema = z.object({
|
|
5
|
-
data: z.
|
|
6
|
-
apiKey: z.string(),
|
|
7
|
-
}),
|
|
6
|
+
data: z.array(ApiKeySchema),
|
|
8
7
|
});
|
|
9
8
|
|
|
10
9
|
export type Response = z.infer<typeof ResponseSchema>;
|
package/commands/b2b/index.ts
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ApiKeySchema } from '../../models/api-key.schema';
|
|
3
|
+
|
|
4
|
+
export namespace UpdateApiKeyCommand {
|
|
5
|
+
export const RequestParamsSchema = z.object({
|
|
6
|
+
uuid: z.string().uuid(),
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export const RequestBodySchema = z.object({
|
|
10
|
+
title: z.string().min(1).optional(),
|
|
11
|
+
limit: z.number().int().nonnegative().nullable().optional(),
|
|
12
|
+
expiresAt: z.coerce.date().nullable().optional(),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export const ResponseSchema = z.object({
|
|
16
|
+
data: ApiKeySchema,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export type RequestParams = z.infer<typeof RequestParamsSchema>;
|
|
20
|
+
export type RequestBody = z.infer<typeof RequestBodySchema>;
|
|
21
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './enums';
|
package/constants/index.ts
CHANGED
package/models/api-key.schema.ts
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
|
+
import { API_KEY_STATUS } from '../constants/api-key/enums/api-key-status.enum';
|
|
2
3
|
|
|
3
4
|
export const ApiKeySchema = z.object({
|
|
4
5
|
uuid: z.string().uuid(),
|
|
6
|
+
title: z.string(),
|
|
7
|
+
publicId: z.string(),
|
|
5
8
|
userId: z.string().uuid(),
|
|
6
|
-
|
|
7
|
-
|
|
9
|
+
status: z.nativeEnum(API_KEY_STATUS),
|
|
10
|
+
limit: z.number().nullable(),
|
|
11
|
+
spent: z.number(),
|
|
12
|
+
maskedKey: z.string(),
|
|
8
13
|
createdAt: z.date(),
|
|
9
14
|
updatedAt: z.date(),
|
|
15
|
+
expiresAt: z.date().nullable(),
|
|
16
|
+
lastUsedAt: z.date().nullable(),
|
|
10
17
|
});
|
|
18
|
+
|
|
19
|
+
export type ApiKey = z.infer<typeof ApiKeySchema>;
|