@dalmore/api-contracts 0.0.0-dev.eb820f7 → 0.0.0-dev.fc1b175
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/common/types/cart.types.ts +4 -1
- package/common/types/transaction.types.ts +12 -1
- package/common/types/user.types.ts +1 -1
- package/contracts/clients/cart/index.ts +21 -1
- package/contracts/clients/index.ts +2 -0
- package/contracts/clients/transactions/index.ts +37 -0
- package/package.json +1 -1
|
@@ -3,6 +3,7 @@ import { extendZodWithOpenApi } from '@anatine/zod-openapi';
|
|
|
3
3
|
import { TradeStatus } from './common.types';
|
|
4
4
|
import { investorAccountIdSchema } from './investor-account.types';
|
|
5
5
|
import { paymentMethodIdSchema } from './payment-methods.types';
|
|
6
|
+
import { userIdSchema } from './user.types';
|
|
6
7
|
|
|
7
8
|
extendZodWithOpenApi(z);
|
|
8
9
|
|
|
@@ -10,7 +11,9 @@ export const PlaceTradeResponse = z.object({
|
|
|
10
11
|
tradeStatus: z.nativeEnum(TradeStatus).optional(),
|
|
11
12
|
});
|
|
12
13
|
export const PlaceTradeBody = z.object({});
|
|
13
|
-
|
|
14
|
+
export const ClientPlacetradeBody = z.object({
|
|
15
|
+
userId: userIdSchema,
|
|
16
|
+
});
|
|
14
17
|
export const PatchCartBody = z.object({
|
|
15
18
|
investorAccountId: investorAccountIdSchema.optional(),
|
|
16
19
|
paymentMethodId: paymentMethodIdSchema.optional(),
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { extendZodWithOpenApi } from '@anatine/zod-openapi';
|
|
1
3
|
import { TypeID } from 'typeid-js';
|
|
2
4
|
import {
|
|
3
5
|
dateSchema,
|
|
4
6
|
InvestorAccountType,
|
|
5
7
|
numberPrecisionSchema,
|
|
6
8
|
} from './common.types';
|
|
7
|
-
import { z } from 'zod';
|
|
8
9
|
import { IBaseEntity } from './entity.types';
|
|
9
10
|
import { accountIdSchema } from './account.types';
|
|
10
11
|
import {
|
|
@@ -18,7 +19,9 @@ import {
|
|
|
18
19
|
investorAccountIdSchema,
|
|
19
20
|
} from './investor-account.types';
|
|
20
21
|
import { TransactionStatus, TransactionType } from './common.types';
|
|
22
|
+
import { userIdSchema } from './user.types';
|
|
21
23
|
export { TransactionStatus, TransactionType };
|
|
24
|
+
extendZodWithOpenApi(z);
|
|
22
25
|
|
|
23
26
|
export enum RefundPaymentMethod {
|
|
24
27
|
CHECK = 'CHECK',
|
|
@@ -115,6 +118,14 @@ export type InvestorPostTransactionZod = z.infer<
|
|
|
115
118
|
typeof InvestorPostTransactionZod
|
|
116
119
|
>;
|
|
117
120
|
|
|
121
|
+
export const ClientPostTransactionZod = InvestorPostTransactionZod.extend({
|
|
122
|
+
userId: z
|
|
123
|
+
.lazy(() => userIdSchema)
|
|
124
|
+
.openapi({ example: 'user_01j5y5ghx5fg68d663j1fvy2x7' }),
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
export type ClientPostTransactionZod = z.infer<typeof ClientPostTransactionZod>;
|
|
128
|
+
|
|
118
129
|
export const refundTransactionIdSchema = z.string().refine(
|
|
119
130
|
(value) => {
|
|
120
131
|
try {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { extendZodWithOpenApi } from '@anatine/zod-openapi';
|
|
2
3
|
import {
|
|
3
4
|
AccountStatus,
|
|
4
5
|
AccountWithoutUsersZod,
|
|
@@ -12,7 +13,6 @@ import {
|
|
|
12
13
|
UserType,
|
|
13
14
|
} from './common.types';
|
|
14
15
|
import { dateOrString, IBaseEntity } from './entity.types';
|
|
15
|
-
import { extendZodWithOpenApi } from '@anatine/zod-openapi';
|
|
16
16
|
import { PhoneZodSchema } from './phone.type';
|
|
17
17
|
import { IInvestorAccount } from './investor-account.types';
|
|
18
18
|
import { TradeZod } from './trade.types';
|
|
@@ -10,7 +10,11 @@ import {
|
|
|
10
10
|
userIdSchema,
|
|
11
11
|
tradeIdSchema,
|
|
12
12
|
} from '../../../common/types';
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
PatchCartBody,
|
|
15
|
+
ClientPlacetradeBody,
|
|
16
|
+
PlaceTradeResponse,
|
|
17
|
+
} from '../../../common/types/cart.types';
|
|
14
18
|
|
|
15
19
|
const c = initContract();
|
|
16
20
|
|
|
@@ -34,6 +38,22 @@ export const cartContract = c.router(
|
|
|
34
38
|
500: InternalError,
|
|
35
39
|
},
|
|
36
40
|
},
|
|
41
|
+
postCheckout: {
|
|
42
|
+
summary: 'Place a trade (checkout button)',
|
|
43
|
+
method: 'POST',
|
|
44
|
+
path: '/checkout',
|
|
45
|
+
metadata: {
|
|
46
|
+
auth: true,
|
|
47
|
+
},
|
|
48
|
+
body: ClientPlacetradeBody,
|
|
49
|
+
responses: {
|
|
50
|
+
200: PlaceTradeResponse,
|
|
51
|
+
400: BadRequestError,
|
|
52
|
+
401: UnauthorizedError,
|
|
53
|
+
403: ForbiddenError,
|
|
54
|
+
500: InternalError,
|
|
55
|
+
},
|
|
56
|
+
},
|
|
37
57
|
patchCart: {
|
|
38
58
|
summary: 'Patch a cart',
|
|
39
59
|
method: 'PATCH',
|
|
@@ -19,6 +19,7 @@ import { sitesContract } from './sites';
|
|
|
19
19
|
import { paymentMethodsContract } from './payment-methods';
|
|
20
20
|
import { issuerPaymentMethodsContract } from './issuer-payment-methods';
|
|
21
21
|
import { tradeLineItemsContract } from './trade-line-items';
|
|
22
|
+
import { clientsTransactionsContract } from './transactions';
|
|
22
23
|
|
|
23
24
|
const c = initContract();
|
|
24
25
|
|
|
@@ -45,6 +46,7 @@ export const clientsContract = c.router(
|
|
|
45
46
|
sites: sitesContract,
|
|
46
47
|
tradeLineItems: tradeLineItemsContract,
|
|
47
48
|
trades: tradesContract,
|
|
49
|
+
transactions: clientsTransactionsContract,
|
|
48
50
|
},
|
|
49
51
|
{
|
|
50
52
|
pathPrefix: '/clients/api/v1/',
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { initContract } from '@ts-rest/core';
|
|
2
|
+
import {
|
|
3
|
+
BadRequestError,
|
|
4
|
+
InternalError,
|
|
5
|
+
NotFoundError,
|
|
6
|
+
UnauthorizedError,
|
|
7
|
+
} from '../../../common/types';
|
|
8
|
+
import {
|
|
9
|
+
ClientPostTransactionZod,
|
|
10
|
+
TransactionZod,
|
|
11
|
+
} from '../../../common/types/transaction.types';
|
|
12
|
+
|
|
13
|
+
const c = initContract();
|
|
14
|
+
|
|
15
|
+
export const clientsTransactionsContract = c.router(
|
|
16
|
+
{
|
|
17
|
+
postTransaction: {
|
|
18
|
+
summary: 'Create a transaction',
|
|
19
|
+
method: 'POST',
|
|
20
|
+
path: '',
|
|
21
|
+
metadata: {
|
|
22
|
+
auth: true,
|
|
23
|
+
},
|
|
24
|
+
body: ClientPostTransactionZod,
|
|
25
|
+
responses: {
|
|
26
|
+
201: TransactionZod,
|
|
27
|
+
400: BadRequestError,
|
|
28
|
+
401: UnauthorizedError,
|
|
29
|
+
404: NotFoundError,
|
|
30
|
+
500: InternalError,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
pathPrefix: 'transactions',
|
|
36
|
+
},
|
|
37
|
+
);
|
package/package.json
CHANGED