@ai-grator/api 0.3.79 → 0.3.80
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/admin/endpoints/admin.ts +3 -0
- package/admin/endpoints/commands/create-admin-vendor-deposit.command.ts +37 -0
- package/admin/endpoints/commands/index.ts +1 -0
- package/admin/endpoints/queries/get-admin-vendor-deposits.query.ts +34 -0
- package/admin/endpoints/queries/get-admin-vendor-spend.query.ts +42 -0
- package/admin/endpoints/queries/index.ts +2 -0
- package/admin/enums/ai-vendor.enum.ts +7 -0
- package/admin/enums/index.ts +4 -0
- package/admin/enums/vendor-spend-limits.ts +2 -0
- package/admin/enums/vendor-spend-unit.enum.ts +14 -0
- package/admin/enums/vendor-usage-source.enum.ts +4 -0
- package/admin/models/admin-vendor-deposit-response.schema.ts +15 -0
- package/admin/models/admin-vendor-spend-response.schema.ts +49 -0
- package/admin/models/index.ts +2 -0
- package/build/admin/endpoints/admin.d.ts +3 -0
- package/build/admin/endpoints/admin.d.ts.map +1 -1
- package/build/admin/endpoints/admin.js +3 -0
- package/build/admin/endpoints/commands/create-admin-vendor-deposit.command.d.ts +49 -0
- package/build/admin/endpoints/commands/create-admin-vendor-deposit.command.d.ts.map +1 -0
- package/build/admin/endpoints/commands/create-admin-vendor-deposit.command.js +34 -0
- package/build/admin/endpoints/commands/index.d.ts +1 -0
- package/build/admin/endpoints/commands/index.d.ts.map +1 -1
- package/build/admin/endpoints/commands/index.js +1 -0
- package/build/admin/endpoints/queries/get-admin-vendor-deposits.query.d.ts +57 -0
- package/build/admin/endpoints/queries/get-admin-vendor-deposits.query.d.ts.map +1 -0
- package/build/admin/endpoints/queries/get-admin-vendor-deposits.query.js +31 -0
- package/build/admin/endpoints/queries/get-admin-vendor-spend.query.d.ts +110 -0
- package/build/admin/endpoints/queries/get-admin-vendor-spend.query.d.ts.map +1 -0
- package/build/admin/endpoints/queries/get-admin-vendor-spend.query.js +38 -0
- package/build/admin/endpoints/queries/index.d.ts +2 -0
- package/build/admin/endpoints/queries/index.d.ts.map +1 -1
- package/build/admin/endpoints/queries/index.js +2 -0
- package/build/admin/enums/ai-vendor.enum.d.ts +8 -0
- package/build/admin/enums/ai-vendor.enum.d.ts.map +1 -0
- package/build/admin/enums/ai-vendor.enum.js +11 -0
- package/build/admin/enums/index.d.ts +4 -0
- package/build/admin/enums/index.d.ts.map +1 -1
- package/build/admin/enums/index.js +4 -0
- package/build/admin/enums/vendor-spend-limits.d.ts +3 -0
- package/build/admin/enums/vendor-spend-limits.d.ts.map +1 -0
- package/build/admin/enums/vendor-spend-limits.js +5 -0
- package/build/admin/enums/vendor-spend-unit.enum.d.ts +7 -0
- package/build/admin/enums/vendor-spend-unit.enum.d.ts.map +1 -0
- package/build/admin/enums/vendor-spend-unit.enum.js +16 -0
- package/build/admin/enums/vendor-usage-source.enum.d.ts +5 -0
- package/build/admin/enums/vendor-usage-source.enum.d.ts.map +1 -0
- package/build/admin/enums/vendor-usage-source.enum.js +8 -0
- package/build/admin/models/admin-vendor-deposit-response.schema.d.ts +14 -0
- package/build/admin/models/admin-vendor-deposit-response.schema.d.ts.map +1 -0
- package/build/admin/models/admin-vendor-deposit-response.schema.js +15 -0
- package/build/admin/models/admin-vendor-spend-response.schema.d.ts +122 -0
- package/build/admin/models/admin-vendor-spend-response.schema.d.ts.map +1 -0
- package/build/admin/models/admin-vendor-spend-response.schema.js +41 -0
- package/build/admin/models/index.d.ts +2 -0
- package/build/admin/models/index.d.ts.map +1 -1
- package/build/admin/models/index.js +2 -0
- package/build/errors/errors.d.ts +10 -0
- package/build/errors/errors.d.ts.map +1 -1
- package/build/errors/errors.js +10 -0
- package/build/tsconfig.tsbuildinfo +1 -1
- package/errors/errors.ts +10 -0
- package/package.json +1 -1
package/admin/endpoints/admin.ts
CHANGED
|
@@ -25,6 +25,9 @@ export const ADMIN_ROUTES = {
|
|
|
25
25
|
|
|
26
26
|
// PROVIDERS
|
|
27
27
|
KIE_BALANCE: 'providers/kie/balance',
|
|
28
|
+
GET_VENDOR_SPEND: 'providers/spend',
|
|
29
|
+
GET_VENDOR_DEPOSITS: 'providers/spend/deposits',
|
|
30
|
+
CREATE_VENDOR_DEPOSIT: 'providers/spend/deposits',
|
|
28
31
|
|
|
29
32
|
// USERS
|
|
30
33
|
GET_USERS: 'users',
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { defineContract, HTTP_METHODS, HttpErrorResponseSchema } from '../../../_common';
|
|
3
|
+
import { AI_VENDOR, VENDOR_DEPOSIT_MAX_AMOUNT } from '../../enums';
|
|
4
|
+
import { AdminVendorDepositResponseSchema } from '../../models';
|
|
5
|
+
import { ADMIN_ROUTES } from '../admin';
|
|
6
|
+
|
|
7
|
+
export const CreateAdminVendorDepositCommandBody = z.object({
|
|
8
|
+
vendor: z.enum(AI_VENDOR),
|
|
9
|
+
amount: z.number().positive().max(VENDOR_DEPOSIT_MAX_AMOUNT),
|
|
10
|
+
paidAt: z.iso
|
|
11
|
+
.datetime({ offset: true })
|
|
12
|
+
.transform((paidAt) => new Date(paidAt))
|
|
13
|
+
.refine((paidAt) => paidAt.getTime() <= Date.now(), {
|
|
14
|
+
message: '`paidAt` must not be in the future',
|
|
15
|
+
}),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export const CreateAdminVendorDepositCommandResponse = AdminVendorDepositResponseSchema;
|
|
19
|
+
|
|
20
|
+
export const CreateAdminVendorDepositCommand = defineContract({
|
|
21
|
+
method: HTTP_METHODS.POST,
|
|
22
|
+
path: ADMIN_ROUTES.CREATE_VENDOR_DEPOSIT,
|
|
23
|
+
summary: 'Register AI vendor deposit (amount in vendor unit: credits for KIE, USD for others)',
|
|
24
|
+
request: {
|
|
25
|
+
body: CreateAdminVendorDepositCommandBody,
|
|
26
|
+
},
|
|
27
|
+
responses: {
|
|
28
|
+
201: CreateAdminVendorDepositCommandResponse,
|
|
29
|
+
400: HttpErrorResponseSchema,
|
|
30
|
+
401: HttpErrorResponseSchema,
|
|
31
|
+
403: HttpErrorResponseSchema,
|
|
32
|
+
500: HttpErrorResponseSchema,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export type CreateAdminVendorDepositCommandBodyType = z.infer<typeof CreateAdminVendorDepositCommandBody>;
|
|
37
|
+
export type CreateAdminVendorDepositCommandResponseType = z.infer<typeof CreateAdminVendorDepositCommandResponse>;
|
|
@@ -35,3 +35,4 @@ export * from './reorder-admin-presets.command';
|
|
|
35
35
|
export * from './update-admin-preset-category.command';
|
|
36
36
|
export * from './update-admin-preset-status.command';
|
|
37
37
|
export * from './update-admin-preset.command';
|
|
38
|
+
export * from './create-admin-vendor-deposit.command';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { defineContract, defineCursorPaginationQuery, HTTP_METHODS, HttpErrorResponseSchema } from '../../../_common';
|
|
3
|
+
import { AI_VENDOR } from '../../enums';
|
|
4
|
+
import { AdminVendorDepositResponseSchema } from '../../models';
|
|
5
|
+
import { ADMIN_ROUTES } from '../admin';
|
|
6
|
+
|
|
7
|
+
export const GetAdminVendorDepositsQueryQuery = defineCursorPaginationQuery(z.uuid()).extend({
|
|
8
|
+
vendor: z.enum(AI_VENDOR).optional(),
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export const GetAdminVendorDepositsQueryResponse = z.object({
|
|
12
|
+
deposits: z.array(AdminVendorDepositResponseSchema),
|
|
13
|
+
nextCursor: z.uuid().nullable(),
|
|
14
|
+
hasMore: z.boolean(),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export const GetAdminVendorDepositsQuery = defineContract({
|
|
18
|
+
method: HTTP_METHODS.GET,
|
|
19
|
+
path: ADMIN_ROUTES.GET_VENDOR_DEPOSITS,
|
|
20
|
+
summary: 'Get AI vendor deposits',
|
|
21
|
+
request: {
|
|
22
|
+
query: GetAdminVendorDepositsQueryQuery,
|
|
23
|
+
},
|
|
24
|
+
responses: {
|
|
25
|
+
200: GetAdminVendorDepositsQueryResponse,
|
|
26
|
+
400: HttpErrorResponseSchema,
|
|
27
|
+
401: HttpErrorResponseSchema,
|
|
28
|
+
403: HttpErrorResponseSchema,
|
|
29
|
+
500: HttpErrorResponseSchema,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export type GetAdminVendorDepositsQueryQueryType = z.infer<typeof GetAdminVendorDepositsQueryQuery>;
|
|
34
|
+
export type GetAdminVendorDepositsQueryResponseType = z.infer<typeof GetAdminVendorDepositsQueryResponse>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { defineContract, HTTP_METHODS, HttpErrorResponseSchema } from '../../../_common';
|
|
3
|
+
import { VENDOR_SPEND_MAX_PERIOD_DAYS } from '../../enums';
|
|
4
|
+
import { AdminVendorSpendResponseSchema } from '../../models';
|
|
5
|
+
import { ADMIN_ROUTES } from '../admin';
|
|
6
|
+
|
|
7
|
+
const MS_PER_DAY = 24 * 60 * 60 * 1000;
|
|
8
|
+
|
|
9
|
+
export const GetAdminVendorSpendQueryQuery = z
|
|
10
|
+
.object({
|
|
11
|
+
from: z.coerce.date(),
|
|
12
|
+
to: z.coerce.date(),
|
|
13
|
+
})
|
|
14
|
+
.refine(({ from, to }) => from < to, {
|
|
15
|
+
message: '`from` must be earlier than `to`',
|
|
16
|
+
path: ['to'],
|
|
17
|
+
})
|
|
18
|
+
.refine(({ from, to }) => to.getTime() - from.getTime() <= VENDOR_SPEND_MAX_PERIOD_DAYS * MS_PER_DAY, {
|
|
19
|
+
message: `Period must not exceed ${VENDOR_SPEND_MAX_PERIOD_DAYS} days`,
|
|
20
|
+
path: ['to'],
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export const GetAdminVendorSpendQueryResponse = AdminVendorSpendResponseSchema;
|
|
24
|
+
|
|
25
|
+
export const GetAdminVendorSpendQuery = defineContract({
|
|
26
|
+
method: HTTP_METHODS.GET,
|
|
27
|
+
path: ADMIN_ROUTES.GET_VENDOR_SPEND,
|
|
28
|
+
summary: 'Get AI vendor spend by model for a period (hour granularity)',
|
|
29
|
+
request: {
|
|
30
|
+
query: GetAdminVendorSpendQueryQuery,
|
|
31
|
+
},
|
|
32
|
+
responses: {
|
|
33
|
+
200: GetAdminVendorSpendQueryResponse,
|
|
34
|
+
400: HttpErrorResponseSchema,
|
|
35
|
+
401: HttpErrorResponseSchema,
|
|
36
|
+
403: HttpErrorResponseSchema,
|
|
37
|
+
500: HttpErrorResponseSchema,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export type GetAdminVendorSpendQueryQueryType = z.infer<typeof GetAdminVendorSpendQueryQuery>;
|
|
42
|
+
export type GetAdminVendorSpendQueryResponseType = z.infer<typeof GetAdminVendorSpendQueryResponse>;
|
|
@@ -30,3 +30,5 @@ export * from './get-admin-antifraud-checks.query';
|
|
|
30
30
|
export * from './get-admin-preset-categories.query';
|
|
31
31
|
export * from './get-admin-preset.query';
|
|
32
32
|
export * from './get-admin-presets.query';
|
|
33
|
+
export * from './get-admin-vendor-spend.query';
|
|
34
|
+
export * from './get-admin-vendor-deposits.query';
|
package/admin/enums/index.ts
CHANGED
|
@@ -12,3 +12,7 @@ export * from './admin-bulk-ban-result.enum';
|
|
|
12
12
|
export * from './admin-bulk-ban-skip-reason.enum';
|
|
13
13
|
export * from './admin-blacklist-entry-type.enum';
|
|
14
14
|
export * from './admin-antifraud-check-reason.enum';
|
|
15
|
+
export * from './ai-vendor.enum';
|
|
16
|
+
export * from './vendor-spend-unit.enum';
|
|
17
|
+
export * from './vendor-usage-source.enum';
|
|
18
|
+
export * from './vendor-spend-limits';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AI_VENDOR } from './ai-vendor.enum';
|
|
2
|
+
|
|
3
|
+
export enum VENDOR_SPEND_UNIT {
|
|
4
|
+
CREDITS = 'credits',
|
|
5
|
+
USD = 'usd',
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const VENDOR_SPEND_UNIT_BY_VENDOR: Record<AI_VENDOR, VENDOR_SPEND_UNIT> = {
|
|
9
|
+
[AI_VENDOR.KIE]: VENDOR_SPEND_UNIT.CREDITS,
|
|
10
|
+
[AI_VENDOR.ANTHROPIC]: VENDOR_SPEND_UNIT.USD,
|
|
11
|
+
[AI_VENDOR.OPENAI]: VENDOR_SPEND_UNIT.USD,
|
|
12
|
+
[AI_VENDOR.GOOGLE]: VENDOR_SPEND_UNIT.USD,
|
|
13
|
+
[AI_VENDOR.DEEPSEEK]: VENDOR_SPEND_UNIT.USD,
|
|
14
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { AI_VENDOR, VENDOR_SPEND_UNIT } from '../enums';
|
|
3
|
+
|
|
4
|
+
export const AdminVendorDepositResponseSchema = z.object({
|
|
5
|
+
uuid: z.uuid(),
|
|
6
|
+
vendor: z.enum(AI_VENDOR),
|
|
7
|
+
unit: z.enum(VENDOR_SPEND_UNIT),
|
|
8
|
+
amount: z.number().positive(),
|
|
9
|
+
paidAt: z.iso.datetime(),
|
|
10
|
+
alertSentAt: z.iso.datetime().nullable(),
|
|
11
|
+
createdById: z.uuid(),
|
|
12
|
+
createdAt: z.iso.datetime(),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export type AdminVendorDepositResponseSchemaType = z.infer<typeof AdminVendorDepositResponseSchema>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { AI_VENDOR, VENDOR_SPEND_UNIT, VENDOR_USAGE_SOURCE } from '../enums';
|
|
3
|
+
|
|
4
|
+
export const AdminVendorUsageMetricsSchema = z.object({
|
|
5
|
+
requestsCount: z.number().int().nonnegative(),
|
|
6
|
+
inputTokens: z.number().int().nonnegative().nullable(),
|
|
7
|
+
inputImageTokens: z.number().int().nonnegative().nullable(),
|
|
8
|
+
outputTokens: z.number().int().nonnegative().nullable(),
|
|
9
|
+
cacheReadTokens: z.number().int().nonnegative().nullable(),
|
|
10
|
+
cacheWriteTokens: z.number().int().nonnegative().nullable(),
|
|
11
|
+
reasoningTokens: z.number().int().nonnegative().nullable(),
|
|
12
|
+
kieCredits: z.number().nonnegative().nullable(),
|
|
13
|
+
cost: z.number().nonnegative().nullable(),
|
|
14
|
+
unpricedRequestsCount: z.number().int().nonnegative(),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export const AdminVendorModelSpendSchema = AdminVendorUsageMetricsSchema.extend({
|
|
18
|
+
model: z.string(),
|
|
19
|
+
source: z.enum(VENDOR_USAGE_SOURCE),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export const AdminVendorLastDepositSchema = z.object({
|
|
23
|
+
uuid: z.uuid(),
|
|
24
|
+
amount: z.number().positive(),
|
|
25
|
+
paidAt: z.iso.datetime(),
|
|
26
|
+
spentSince: z.number().nonnegative().describe('Spend since the payment moment, up to the time of the request'),
|
|
27
|
+
remaining: z.number(),
|
|
28
|
+
spentPercent: z.number().nonnegative(),
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export const AdminVendorSpendSchema = z.object({
|
|
32
|
+
vendor: z.enum(AI_VENDOR),
|
|
33
|
+
unit: z.enum(VENDOR_SPEND_UNIT),
|
|
34
|
+
totals: AdminVendorUsageMetricsSchema,
|
|
35
|
+
models: z.array(AdminVendorModelSpendSchema),
|
|
36
|
+
lastDeposit: AdminVendorLastDepositSchema.nullable(),
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export const AdminVendorSpendResponseSchema = z.object({
|
|
40
|
+
from: z.iso.datetime(),
|
|
41
|
+
to: z.iso.datetime(),
|
|
42
|
+
vendors: z.array(AdminVendorSpendSchema),
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export type AdminVendorUsageMetricsSchemaType = z.infer<typeof AdminVendorUsageMetricsSchema>;
|
|
46
|
+
export type AdminVendorModelSpendSchemaType = z.infer<typeof AdminVendorModelSpendSchema>;
|
|
47
|
+
export type AdminVendorLastDepositSchemaType = z.infer<typeof AdminVendorLastDepositSchema>;
|
|
48
|
+
export type AdminVendorSpendSchemaType = z.infer<typeof AdminVendorSpendSchema>;
|
|
49
|
+
export type AdminVendorSpendResponseSchemaType = z.infer<typeof AdminVendorSpendResponseSchema>;
|
package/admin/models/index.ts
CHANGED
|
@@ -23,3 +23,5 @@ export * from './admin-blacklist-entry-response.schema';
|
|
|
23
23
|
export * from './admin-antifraud-check-response.schema';
|
|
24
24
|
export * from './admin-preset-category-response.schema';
|
|
25
25
|
export * from './admin-preset-response.schema';
|
|
26
|
+
export * from './admin-vendor-spend-response.schema';
|
|
27
|
+
export * from './admin-vendor-deposit-response.schema';
|
|
@@ -16,6 +16,9 @@ export declare const ADMIN_ROUTES: {
|
|
|
16
16
|
readonly DASHBOARD: "dashboard";
|
|
17
17
|
readonly EXPORT_DASHBOARD: "dashboard/export";
|
|
18
18
|
readonly KIE_BALANCE: "providers/kie/balance";
|
|
19
|
+
readonly GET_VENDOR_SPEND: "providers/spend";
|
|
20
|
+
readonly GET_VENDOR_DEPOSITS: "providers/spend/deposits";
|
|
21
|
+
readonly CREATE_VENDOR_DEPOSIT: "providers/spend/deposits";
|
|
19
22
|
readonly GET_USERS: "users";
|
|
20
23
|
readonly EXPORT_USERS: "users/export";
|
|
21
24
|
readonly GET_USER: (userId: string) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../../../admin/endpoints/admin.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,EAAG,OAAgB,CAAC;AAEjD,eAAO,MAAM,YAAY;;sCAGI,MAAM;gDACI,MAAM;iDACL,MAAM;sDACD,MAAM;yDACH,MAAM;kDACb,MAAM;+DACO,MAAM;wDACb,MAAM,aAAa,MAAM;uDAE1B,MAAM;yDACJ,MAAM
|
|
1
|
+
{"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../../../admin/endpoints/admin.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,EAAG,OAAgB,CAAC;AAEjD,eAAO,MAAM,YAAY;;sCAGI,MAAM;gDACI,MAAM;iDACL,MAAM;sDACD,MAAM;yDACH,MAAM;kDACb,MAAM;+DACO,MAAM;wDACb,MAAM,aAAa,MAAM;uDAE1B,MAAM;yDACJ,MAAM;;;;;;;;;;;gCAmB/B,MAAM;6CACO,MAAM;gCACnB,MAAM;;kCAEJ,MAAM;;;;+CAQO,MAAM;;kDAIH,MAAM;;iDAIP,MAAM;0CACb,MAAM;8CACF,MAAM;;;gCAKpB,MAAM;mCACH,MAAM;mCACN,MAAM;0CACC,MAAM;;;6CAKH,MAAM;6CACN,MAAM;;;;;kCAOjB,MAAM;qCACH,MAAM;qCACN,MAAM;4CACC,MAAM;;;iDAKD,MAAM;iDACN,MAAM;;;;oCAMnB,MAAM;uCACH,MAAM;uCACN,MAAM;8CACC,MAAM;;;;kDAMF,MAAM;kDACN,MAAM;;;CAKrC,CAAC"}
|
|
@@ -23,6 +23,9 @@ exports.ADMIN_ROUTES = {
|
|
|
23
23
|
EXPORT_DASHBOARD: 'dashboard/export',
|
|
24
24
|
// PROVIDERS
|
|
25
25
|
KIE_BALANCE: 'providers/kie/balance',
|
|
26
|
+
GET_VENDOR_SPEND: 'providers/spend',
|
|
27
|
+
GET_VENDOR_DEPOSITS: 'providers/spend/deposits',
|
|
28
|
+
CREATE_VENDOR_DEPOSIT: 'providers/spend/deposits',
|
|
26
29
|
// USERS
|
|
27
30
|
GET_USERS: 'users',
|
|
28
31
|
EXPORT_USERS: 'users/export',
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { HTTP_METHODS } from '../../../_common';
|
|
3
|
+
import { AI_VENDOR } from '../../enums';
|
|
4
|
+
export declare const CreateAdminVendorDepositCommandBody: z.ZodObject<{
|
|
5
|
+
vendor: z.ZodEnum<typeof AI_VENDOR>;
|
|
6
|
+
amount: z.ZodNumber;
|
|
7
|
+
paidAt: z.ZodPipe<z.ZodISODateTime, z.ZodTransform<Date, string>>;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
export declare const CreateAdminVendorDepositCommandResponse: z.ZodObject<{
|
|
10
|
+
uuid: z.ZodUUID;
|
|
11
|
+
vendor: z.ZodEnum<typeof AI_VENDOR>;
|
|
12
|
+
unit: z.ZodEnum<typeof import("../../enums").VENDOR_SPEND_UNIT>;
|
|
13
|
+
amount: z.ZodNumber;
|
|
14
|
+
paidAt: z.ZodISODateTime;
|
|
15
|
+
alertSentAt: z.ZodNullable<z.ZodISODateTime>;
|
|
16
|
+
createdById: z.ZodUUID;
|
|
17
|
+
createdAt: z.ZodISODateTime;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
export declare const CreateAdminVendorDepositCommand: {
|
|
20
|
+
method: HTTP_METHODS.POST;
|
|
21
|
+
path: "providers/spend/deposits";
|
|
22
|
+
summary: string;
|
|
23
|
+
request: {
|
|
24
|
+
body: z.ZodObject<{
|
|
25
|
+
vendor: z.ZodEnum<typeof AI_VENDOR>;
|
|
26
|
+
amount: z.ZodNumber;
|
|
27
|
+
paidAt: z.ZodPipe<z.ZodISODateTime, z.ZodTransform<Date, string>>;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
};
|
|
30
|
+
responses: {
|
|
31
|
+
201: z.ZodObject<{
|
|
32
|
+
uuid: z.ZodUUID;
|
|
33
|
+
vendor: z.ZodEnum<typeof AI_VENDOR>;
|
|
34
|
+
unit: z.ZodEnum<typeof import("../../enums").VENDOR_SPEND_UNIT>;
|
|
35
|
+
amount: z.ZodNumber;
|
|
36
|
+
paidAt: z.ZodISODateTime;
|
|
37
|
+
alertSentAt: z.ZodNullable<z.ZodISODateTime>;
|
|
38
|
+
createdById: z.ZodUUID;
|
|
39
|
+
createdAt: z.ZodISODateTime;
|
|
40
|
+
}, z.core.$strip>;
|
|
41
|
+
400: z.ZodType<import("../../../_common").HttpErrorResponse, unknown, z.core.$ZodTypeInternals<import("../../../_common").HttpErrorResponse, unknown>>;
|
|
42
|
+
401: z.ZodType<import("../../../_common").HttpErrorResponse, unknown, z.core.$ZodTypeInternals<import("../../../_common").HttpErrorResponse, unknown>>;
|
|
43
|
+
403: z.ZodType<import("../../../_common").HttpErrorResponse, unknown, z.core.$ZodTypeInternals<import("../../../_common").HttpErrorResponse, unknown>>;
|
|
44
|
+
500: z.ZodType<import("../../../_common").HttpErrorResponse, unknown, z.core.$ZodTypeInternals<import("../../../_common").HttpErrorResponse, unknown>>;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
export type CreateAdminVendorDepositCommandBodyType = z.infer<typeof CreateAdminVendorDepositCommandBody>;
|
|
48
|
+
export type CreateAdminVendorDepositCommandResponseType = z.infer<typeof CreateAdminVendorDepositCommandResponse>;
|
|
49
|
+
//# sourceMappingURL=create-admin-vendor-deposit.command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-admin-vendor-deposit.command.d.ts","sourceRoot":"","sources":["../../../../admin/endpoints/commands/create-admin-vendor-deposit.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAkB,YAAY,EAA2B,MAAM,kBAAkB,CAAC;AACzF,OAAO,EAAE,SAAS,EAA6B,MAAM,aAAa,CAAC;AAInE,eAAO,MAAM,mCAAmC;;;;iBAS9C,CAAC;AAEH,eAAO,MAAM,uCAAuC;;;;;;;;;iBAAmC,CAAC;AAExF,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;CAc1C,CAAC;AAEH,MAAM,MAAM,uCAAuC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mCAAmC,CAAC,CAAC;AAC1G,MAAM,MAAM,2CAA2C,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uCAAuC,CAAC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CreateAdminVendorDepositCommand = exports.CreateAdminVendorDepositCommandResponse = exports.CreateAdminVendorDepositCommandBody = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const _common_1 = require("../../../_common");
|
|
6
|
+
const enums_1 = require("../../enums");
|
|
7
|
+
const models_1 = require("../../models");
|
|
8
|
+
const admin_1 = require("../admin");
|
|
9
|
+
exports.CreateAdminVendorDepositCommandBody = zod_1.z.object({
|
|
10
|
+
vendor: zod_1.z.enum(enums_1.AI_VENDOR),
|
|
11
|
+
amount: zod_1.z.number().positive().max(enums_1.VENDOR_DEPOSIT_MAX_AMOUNT),
|
|
12
|
+
paidAt: zod_1.z.iso
|
|
13
|
+
.datetime({ offset: true })
|
|
14
|
+
.transform((paidAt) => new Date(paidAt))
|
|
15
|
+
.refine((paidAt) => paidAt.getTime() <= Date.now(), {
|
|
16
|
+
message: '`paidAt` must not be in the future',
|
|
17
|
+
}),
|
|
18
|
+
});
|
|
19
|
+
exports.CreateAdminVendorDepositCommandResponse = models_1.AdminVendorDepositResponseSchema;
|
|
20
|
+
exports.CreateAdminVendorDepositCommand = (0, _common_1.defineContract)({
|
|
21
|
+
method: _common_1.HTTP_METHODS.POST,
|
|
22
|
+
path: admin_1.ADMIN_ROUTES.CREATE_VENDOR_DEPOSIT,
|
|
23
|
+
summary: 'Register AI vendor deposit (amount in vendor unit: credits for KIE, USD for others)',
|
|
24
|
+
request: {
|
|
25
|
+
body: exports.CreateAdminVendorDepositCommandBody,
|
|
26
|
+
},
|
|
27
|
+
responses: {
|
|
28
|
+
201: exports.CreateAdminVendorDepositCommandResponse,
|
|
29
|
+
400: _common_1.HttpErrorResponseSchema,
|
|
30
|
+
401: _common_1.HttpErrorResponseSchema,
|
|
31
|
+
403: _common_1.HttpErrorResponseSchema,
|
|
32
|
+
500: _common_1.HttpErrorResponseSchema,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
@@ -35,4 +35,5 @@ export * from './reorder-admin-presets.command';
|
|
|
35
35
|
export * from './update-admin-preset-category.command';
|
|
36
36
|
export * from './update-admin-preset-status.command';
|
|
37
37
|
export * from './update-admin-preset.command';
|
|
38
|
+
export * from './create-admin-vendor-deposit.command';
|
|
38
39
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../admin/endpoints/commands/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,gDAAgD,CAAC;AAC/D,cAAc,gDAAgD,CAAC;AAC/D,cAAc,wCAAwC,CAAC;AACvD,cAAc,oCAAoC,CAAC;AACnD,cAAc,wCAAwC,CAAC;AACvD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oCAAoC,CAAC;AACnD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qCAAqC,CAAC;AACpD,cAAc,qCAAqC,CAAC;AACpD,cAAc,qCAAqC,CAAC;AACpD,cAAc,qCAAqC,CAAC;AACpD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qCAAqC,CAAC;AACpD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6CAA6C,CAAC;AAC5D,cAAc,uCAAuC,CAAC;AACtD,cAAc,uCAAuC,CAAC;AACtD,cAAc,uCAAuC,CAAC;AACtD,cAAc,wCAAwC,CAAC;AACvD,cAAc,wCAAwC,CAAC;AACvD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,wCAAwC,CAAC;AACvD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wCAAwC,CAAC;AACvD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,2CAA2C,CAAC;AAC1D,cAAc,iCAAiC,CAAC;AAChD,cAAc,wCAAwC,CAAC;AACvD,cAAc,sCAAsC,CAAC;AACrD,cAAc,+BAA+B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../admin/endpoints/commands/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,gDAAgD,CAAC;AAC/D,cAAc,gDAAgD,CAAC;AAC/D,cAAc,wCAAwC,CAAC;AACvD,cAAc,oCAAoC,CAAC;AACnD,cAAc,wCAAwC,CAAC;AACvD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oCAAoC,CAAC;AACnD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qCAAqC,CAAC;AACpD,cAAc,qCAAqC,CAAC;AACpD,cAAc,qCAAqC,CAAC;AACpD,cAAc,qCAAqC,CAAC;AACpD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qCAAqC,CAAC;AACpD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6CAA6C,CAAC;AAC5D,cAAc,uCAAuC,CAAC;AACtD,cAAc,uCAAuC,CAAC;AACtD,cAAc,uCAAuC,CAAC;AACtD,cAAc,wCAAwC,CAAC;AACvD,cAAc,wCAAwC,CAAC;AACvD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,wCAAwC,CAAC;AACvD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wCAAwC,CAAC;AACvD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,2CAA2C,CAAC;AAC1D,cAAc,iCAAiC,CAAC;AAChD,cAAc,wCAAwC,CAAC;AACvD,cAAc,sCAAsC,CAAC;AACrD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uCAAuC,CAAC"}
|
|
@@ -51,3 +51,4 @@ __exportStar(require("./reorder-admin-presets.command"), exports);
|
|
|
51
51
|
__exportStar(require("./update-admin-preset-category.command"), exports);
|
|
52
52
|
__exportStar(require("./update-admin-preset-status.command"), exports);
|
|
53
53
|
__exportStar(require("./update-admin-preset.command"), exports);
|
|
54
|
+
__exportStar(require("./create-admin-vendor-deposit.command"), exports);
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { HTTP_METHODS } from '../../../_common';
|
|
3
|
+
import { AI_VENDOR } from '../../enums';
|
|
4
|
+
export declare const GetAdminVendorDepositsQueryQuery: z.ZodObject<{
|
|
5
|
+
cursor: z.ZodOptional<z.ZodUUID>;
|
|
6
|
+
limit: z.ZodOptional<z.ZodDefault<z.ZodCoercedNumber<unknown>>>;
|
|
7
|
+
vendor: z.ZodOptional<z.ZodEnum<typeof AI_VENDOR>>;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
export declare const GetAdminVendorDepositsQueryResponse: z.ZodObject<{
|
|
10
|
+
deposits: z.ZodArray<z.ZodObject<{
|
|
11
|
+
uuid: z.ZodUUID;
|
|
12
|
+
vendor: z.ZodEnum<typeof AI_VENDOR>;
|
|
13
|
+
unit: z.ZodEnum<typeof import("../../enums").VENDOR_SPEND_UNIT>;
|
|
14
|
+
amount: z.ZodNumber;
|
|
15
|
+
paidAt: z.ZodISODateTime;
|
|
16
|
+
alertSentAt: z.ZodNullable<z.ZodISODateTime>;
|
|
17
|
+
createdById: z.ZodUUID;
|
|
18
|
+
createdAt: z.ZodISODateTime;
|
|
19
|
+
}, z.core.$strip>>;
|
|
20
|
+
nextCursor: z.ZodNullable<z.ZodUUID>;
|
|
21
|
+
hasMore: z.ZodBoolean;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
export declare const GetAdminVendorDepositsQuery: {
|
|
24
|
+
method: HTTP_METHODS.GET;
|
|
25
|
+
path: "providers/spend/deposits";
|
|
26
|
+
summary: string;
|
|
27
|
+
request: {
|
|
28
|
+
query: z.ZodObject<{
|
|
29
|
+
cursor: z.ZodOptional<z.ZodUUID>;
|
|
30
|
+
limit: z.ZodOptional<z.ZodDefault<z.ZodCoercedNumber<unknown>>>;
|
|
31
|
+
vendor: z.ZodOptional<z.ZodEnum<typeof AI_VENDOR>>;
|
|
32
|
+
}, z.core.$strip>;
|
|
33
|
+
};
|
|
34
|
+
responses: {
|
|
35
|
+
200: z.ZodObject<{
|
|
36
|
+
deposits: z.ZodArray<z.ZodObject<{
|
|
37
|
+
uuid: z.ZodUUID;
|
|
38
|
+
vendor: z.ZodEnum<typeof AI_VENDOR>;
|
|
39
|
+
unit: z.ZodEnum<typeof import("../../enums").VENDOR_SPEND_UNIT>;
|
|
40
|
+
amount: z.ZodNumber;
|
|
41
|
+
paidAt: z.ZodISODateTime;
|
|
42
|
+
alertSentAt: z.ZodNullable<z.ZodISODateTime>;
|
|
43
|
+
createdById: z.ZodUUID;
|
|
44
|
+
createdAt: z.ZodISODateTime;
|
|
45
|
+
}, z.core.$strip>>;
|
|
46
|
+
nextCursor: z.ZodNullable<z.ZodUUID>;
|
|
47
|
+
hasMore: z.ZodBoolean;
|
|
48
|
+
}, z.core.$strip>;
|
|
49
|
+
400: z.ZodType<import("../../../_common").HttpErrorResponse, unknown, z.core.$ZodTypeInternals<import("../../../_common").HttpErrorResponse, unknown>>;
|
|
50
|
+
401: z.ZodType<import("../../../_common").HttpErrorResponse, unknown, z.core.$ZodTypeInternals<import("../../../_common").HttpErrorResponse, unknown>>;
|
|
51
|
+
403: z.ZodType<import("../../../_common").HttpErrorResponse, unknown, z.core.$ZodTypeInternals<import("../../../_common").HttpErrorResponse, unknown>>;
|
|
52
|
+
500: z.ZodType<import("../../../_common").HttpErrorResponse, unknown, z.core.$ZodTypeInternals<import("../../../_common").HttpErrorResponse, unknown>>;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
export type GetAdminVendorDepositsQueryQueryType = z.infer<typeof GetAdminVendorDepositsQueryQuery>;
|
|
56
|
+
export type GetAdminVendorDepositsQueryResponseType = z.infer<typeof GetAdminVendorDepositsQueryResponse>;
|
|
57
|
+
//# sourceMappingURL=get-admin-vendor-deposits.query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-admin-vendor-deposits.query.d.ts","sourceRoot":"","sources":["../../../../admin/endpoints/queries/get-admin-vendor-deposits.query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAA+C,YAAY,EAA2B,MAAM,kBAAkB,CAAC;AACtH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAIxC,eAAO,MAAM,gCAAgC;;;;iBAE3C,CAAC;AAEH,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;iBAI9C,CAAC;AAEH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CActC,CAAC;AAEH,MAAM,MAAM,oCAAoC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAC;AACpG,MAAM,MAAM,uCAAuC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mCAAmC,CAAC,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetAdminVendorDepositsQuery = exports.GetAdminVendorDepositsQueryResponse = exports.GetAdminVendorDepositsQueryQuery = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const _common_1 = require("../../../_common");
|
|
6
|
+
const enums_1 = require("../../enums");
|
|
7
|
+
const models_1 = require("../../models");
|
|
8
|
+
const admin_1 = require("../admin");
|
|
9
|
+
exports.GetAdminVendorDepositsQueryQuery = (0, _common_1.defineCursorPaginationQuery)(zod_1.z.uuid()).extend({
|
|
10
|
+
vendor: zod_1.z.enum(enums_1.AI_VENDOR).optional(),
|
|
11
|
+
});
|
|
12
|
+
exports.GetAdminVendorDepositsQueryResponse = zod_1.z.object({
|
|
13
|
+
deposits: zod_1.z.array(models_1.AdminVendorDepositResponseSchema),
|
|
14
|
+
nextCursor: zod_1.z.uuid().nullable(),
|
|
15
|
+
hasMore: zod_1.z.boolean(),
|
|
16
|
+
});
|
|
17
|
+
exports.GetAdminVendorDepositsQuery = (0, _common_1.defineContract)({
|
|
18
|
+
method: _common_1.HTTP_METHODS.GET,
|
|
19
|
+
path: admin_1.ADMIN_ROUTES.GET_VENDOR_DEPOSITS,
|
|
20
|
+
summary: 'Get AI vendor deposits',
|
|
21
|
+
request: {
|
|
22
|
+
query: exports.GetAdminVendorDepositsQueryQuery,
|
|
23
|
+
},
|
|
24
|
+
responses: {
|
|
25
|
+
200: exports.GetAdminVendorDepositsQueryResponse,
|
|
26
|
+
400: _common_1.HttpErrorResponseSchema,
|
|
27
|
+
401: _common_1.HttpErrorResponseSchema,
|
|
28
|
+
403: _common_1.HttpErrorResponseSchema,
|
|
29
|
+
500: _common_1.HttpErrorResponseSchema,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { HTTP_METHODS } from '../../../_common';
|
|
3
|
+
export declare const GetAdminVendorSpendQueryQuery: z.ZodObject<{
|
|
4
|
+
from: z.ZodCoercedDate<unknown>;
|
|
5
|
+
to: z.ZodCoercedDate<unknown>;
|
|
6
|
+
}, z.core.$strip>;
|
|
7
|
+
export declare const GetAdminVendorSpendQueryResponse: z.ZodObject<{
|
|
8
|
+
from: z.ZodISODateTime;
|
|
9
|
+
to: z.ZodISODateTime;
|
|
10
|
+
vendors: z.ZodArray<z.ZodObject<{
|
|
11
|
+
vendor: z.ZodEnum<typeof import("../../enums").AI_VENDOR>;
|
|
12
|
+
unit: z.ZodEnum<typeof import("../../enums").VENDOR_SPEND_UNIT>;
|
|
13
|
+
totals: z.ZodObject<{
|
|
14
|
+
requestsCount: z.ZodNumber;
|
|
15
|
+
inputTokens: z.ZodNullable<z.ZodNumber>;
|
|
16
|
+
inputImageTokens: z.ZodNullable<z.ZodNumber>;
|
|
17
|
+
outputTokens: z.ZodNullable<z.ZodNumber>;
|
|
18
|
+
cacheReadTokens: z.ZodNullable<z.ZodNumber>;
|
|
19
|
+
cacheWriteTokens: z.ZodNullable<z.ZodNumber>;
|
|
20
|
+
reasoningTokens: z.ZodNullable<z.ZodNumber>;
|
|
21
|
+
kieCredits: z.ZodNullable<z.ZodNumber>;
|
|
22
|
+
cost: z.ZodNullable<z.ZodNumber>;
|
|
23
|
+
unpricedRequestsCount: z.ZodNumber;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
models: z.ZodArray<z.ZodObject<{
|
|
26
|
+
requestsCount: z.ZodNumber;
|
|
27
|
+
inputTokens: z.ZodNullable<z.ZodNumber>;
|
|
28
|
+
inputImageTokens: z.ZodNullable<z.ZodNumber>;
|
|
29
|
+
outputTokens: z.ZodNullable<z.ZodNumber>;
|
|
30
|
+
cacheReadTokens: z.ZodNullable<z.ZodNumber>;
|
|
31
|
+
cacheWriteTokens: z.ZodNullable<z.ZodNumber>;
|
|
32
|
+
reasoningTokens: z.ZodNullable<z.ZodNumber>;
|
|
33
|
+
kieCredits: z.ZodNullable<z.ZodNumber>;
|
|
34
|
+
cost: z.ZodNullable<z.ZodNumber>;
|
|
35
|
+
unpricedRequestsCount: z.ZodNumber;
|
|
36
|
+
model: z.ZodString;
|
|
37
|
+
source: z.ZodEnum<typeof import("../../enums").VENDOR_USAGE_SOURCE>;
|
|
38
|
+
}, z.core.$strip>>;
|
|
39
|
+
lastDeposit: z.ZodNullable<z.ZodObject<{
|
|
40
|
+
uuid: z.ZodUUID;
|
|
41
|
+
amount: z.ZodNumber;
|
|
42
|
+
paidAt: z.ZodISODateTime;
|
|
43
|
+
spentSince: z.ZodNumber;
|
|
44
|
+
remaining: z.ZodNumber;
|
|
45
|
+
spentPercent: z.ZodNumber;
|
|
46
|
+
}, z.core.$strip>>;
|
|
47
|
+
}, z.core.$strip>>;
|
|
48
|
+
}, z.core.$strip>;
|
|
49
|
+
export declare const GetAdminVendorSpendQuery: {
|
|
50
|
+
method: HTTP_METHODS.GET;
|
|
51
|
+
path: "providers/spend";
|
|
52
|
+
summary: string;
|
|
53
|
+
request: {
|
|
54
|
+
query: z.ZodObject<{
|
|
55
|
+
from: z.ZodCoercedDate<unknown>;
|
|
56
|
+
to: z.ZodCoercedDate<unknown>;
|
|
57
|
+
}, z.core.$strip>;
|
|
58
|
+
};
|
|
59
|
+
responses: {
|
|
60
|
+
200: z.ZodObject<{
|
|
61
|
+
from: z.ZodISODateTime;
|
|
62
|
+
to: z.ZodISODateTime;
|
|
63
|
+
vendors: z.ZodArray<z.ZodObject<{
|
|
64
|
+
vendor: z.ZodEnum<typeof import("../../enums").AI_VENDOR>;
|
|
65
|
+
unit: z.ZodEnum<typeof import("../../enums").VENDOR_SPEND_UNIT>;
|
|
66
|
+
totals: z.ZodObject<{
|
|
67
|
+
requestsCount: z.ZodNumber;
|
|
68
|
+
inputTokens: z.ZodNullable<z.ZodNumber>;
|
|
69
|
+
inputImageTokens: z.ZodNullable<z.ZodNumber>;
|
|
70
|
+
outputTokens: z.ZodNullable<z.ZodNumber>;
|
|
71
|
+
cacheReadTokens: z.ZodNullable<z.ZodNumber>;
|
|
72
|
+
cacheWriteTokens: z.ZodNullable<z.ZodNumber>;
|
|
73
|
+
reasoningTokens: z.ZodNullable<z.ZodNumber>;
|
|
74
|
+
kieCredits: z.ZodNullable<z.ZodNumber>;
|
|
75
|
+
cost: z.ZodNullable<z.ZodNumber>;
|
|
76
|
+
unpricedRequestsCount: z.ZodNumber;
|
|
77
|
+
}, z.core.$strip>;
|
|
78
|
+
models: z.ZodArray<z.ZodObject<{
|
|
79
|
+
requestsCount: z.ZodNumber;
|
|
80
|
+
inputTokens: z.ZodNullable<z.ZodNumber>;
|
|
81
|
+
inputImageTokens: z.ZodNullable<z.ZodNumber>;
|
|
82
|
+
outputTokens: z.ZodNullable<z.ZodNumber>;
|
|
83
|
+
cacheReadTokens: z.ZodNullable<z.ZodNumber>;
|
|
84
|
+
cacheWriteTokens: z.ZodNullable<z.ZodNumber>;
|
|
85
|
+
reasoningTokens: z.ZodNullable<z.ZodNumber>;
|
|
86
|
+
kieCredits: z.ZodNullable<z.ZodNumber>;
|
|
87
|
+
cost: z.ZodNullable<z.ZodNumber>;
|
|
88
|
+
unpricedRequestsCount: z.ZodNumber;
|
|
89
|
+
model: z.ZodString;
|
|
90
|
+
source: z.ZodEnum<typeof import("../../enums").VENDOR_USAGE_SOURCE>;
|
|
91
|
+
}, z.core.$strip>>;
|
|
92
|
+
lastDeposit: z.ZodNullable<z.ZodObject<{
|
|
93
|
+
uuid: z.ZodUUID;
|
|
94
|
+
amount: z.ZodNumber;
|
|
95
|
+
paidAt: z.ZodISODateTime;
|
|
96
|
+
spentSince: z.ZodNumber;
|
|
97
|
+
remaining: z.ZodNumber;
|
|
98
|
+
spentPercent: z.ZodNumber;
|
|
99
|
+
}, z.core.$strip>>;
|
|
100
|
+
}, z.core.$strip>>;
|
|
101
|
+
}, z.core.$strip>;
|
|
102
|
+
400: z.ZodType<import("../../../_common").HttpErrorResponse, unknown, z.core.$ZodTypeInternals<import("../../../_common").HttpErrorResponse, unknown>>;
|
|
103
|
+
401: z.ZodType<import("../../../_common").HttpErrorResponse, unknown, z.core.$ZodTypeInternals<import("../../../_common").HttpErrorResponse, unknown>>;
|
|
104
|
+
403: z.ZodType<import("../../../_common").HttpErrorResponse, unknown, z.core.$ZodTypeInternals<import("../../../_common").HttpErrorResponse, unknown>>;
|
|
105
|
+
500: z.ZodType<import("../../../_common").HttpErrorResponse, unknown, z.core.$ZodTypeInternals<import("../../../_common").HttpErrorResponse, unknown>>;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
export type GetAdminVendorSpendQueryQueryType = z.infer<typeof GetAdminVendorSpendQueryQuery>;
|
|
109
|
+
export type GetAdminVendorSpendQueryResponseType = z.infer<typeof GetAdminVendorSpendQueryResponse>;
|
|
110
|
+
//# sourceMappingURL=get-admin-vendor-spend.query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-admin-vendor-spend.query.d.ts","sourceRoot":"","sources":["../../../../admin/endpoints/queries/get-admin-vendor-spend.query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAkB,YAAY,EAA2B,MAAM,kBAAkB,CAAC;AAOzF,eAAO,MAAM,6BAA6B;;;iBAYpC,CAAC;AAEP,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAiC,CAAC;AAE/E,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAcnC,CAAC;AAEH,MAAM,MAAM,iCAAiC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC;AAC9F,MAAM,MAAM,oCAAoC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetAdminVendorSpendQuery = exports.GetAdminVendorSpendQueryResponse = exports.GetAdminVendorSpendQueryQuery = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const _common_1 = require("../../../_common");
|
|
6
|
+
const enums_1 = require("../../enums");
|
|
7
|
+
const models_1 = require("../../models");
|
|
8
|
+
const admin_1 = require("../admin");
|
|
9
|
+
const MS_PER_DAY = 24 * 60 * 60 * 1000;
|
|
10
|
+
exports.GetAdminVendorSpendQueryQuery = zod_1.z
|
|
11
|
+
.object({
|
|
12
|
+
from: zod_1.z.coerce.date(),
|
|
13
|
+
to: zod_1.z.coerce.date(),
|
|
14
|
+
})
|
|
15
|
+
.refine(({ from, to }) => from < to, {
|
|
16
|
+
message: '`from` must be earlier than `to`',
|
|
17
|
+
path: ['to'],
|
|
18
|
+
})
|
|
19
|
+
.refine(({ from, to }) => to.getTime() - from.getTime() <= enums_1.VENDOR_SPEND_MAX_PERIOD_DAYS * MS_PER_DAY, {
|
|
20
|
+
message: `Period must not exceed ${enums_1.VENDOR_SPEND_MAX_PERIOD_DAYS} days`,
|
|
21
|
+
path: ['to'],
|
|
22
|
+
});
|
|
23
|
+
exports.GetAdminVendorSpendQueryResponse = models_1.AdminVendorSpendResponseSchema;
|
|
24
|
+
exports.GetAdminVendorSpendQuery = (0, _common_1.defineContract)({
|
|
25
|
+
method: _common_1.HTTP_METHODS.GET,
|
|
26
|
+
path: admin_1.ADMIN_ROUTES.GET_VENDOR_SPEND,
|
|
27
|
+
summary: 'Get AI vendor spend by model for a period (hour granularity)',
|
|
28
|
+
request: {
|
|
29
|
+
query: exports.GetAdminVendorSpendQueryQuery,
|
|
30
|
+
},
|
|
31
|
+
responses: {
|
|
32
|
+
200: exports.GetAdminVendorSpendQueryResponse,
|
|
33
|
+
400: _common_1.HttpErrorResponseSchema,
|
|
34
|
+
401: _common_1.HttpErrorResponseSchema,
|
|
35
|
+
403: _common_1.HttpErrorResponseSchema,
|
|
36
|
+
500: _common_1.HttpErrorResponseSchema,
|
|
37
|
+
},
|
|
38
|
+
});
|