@dalmore/api-contracts 0.0.0-dev.d30d175 → 0.0.0-dev.ff07a57

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.
@@ -17,7 +17,7 @@ import { KybZod } from './kyb.types';
17
17
  import { IIndividualZod, individualIdSchema } from './individuals.types';
18
18
  import { LegalEntityZod } from './legal-entity.types';
19
19
  import { IInvestorAccount } from './investor-account.types';
20
- import { TradeZod } from './trade.types';
20
+ import { tradeIdSchema, TradeZod } from './trade.types';
21
21
 
22
22
  extendZodWithOpenApi(z);
23
23
 
@@ -168,13 +168,13 @@ export type PostFileQueryParams = z.infer<typeof PostFileQueryParams>;
168
168
 
169
169
  /**
170
170
  * CLIENT portal specific schema for file uploads
171
- * Only allows INDIVIDUALS as target for file uploads
171
+ * Only allows INDIVIDUALS and TRADES as target for file uploads
172
172
  */
173
173
  export const ClientPostFileQueryParams = z.object({
174
174
  name: z.string().min(1).max(100).openapi({ example: 'file_name' }),
175
175
  category: z.string().max(50).openapi({ example: 'application' }),
176
176
  label: FileLabelsEnum.openapi({ example: FileLabels.OTHER }),
177
- targetId: individualIdSchema.openapi({
177
+ targetId: z.union([individualIdSchema, tradeIdSchema]).openapi({
178
178
  example: 'individual_01kcrsny60fb9rjc8bbqc3b80c',
179
179
  }),
180
180
  metadata: metadataSchema.nullable().optional(),
@@ -42,6 +42,7 @@ export * from './domain-filter.types';
42
42
  export * from './aic.types';
43
43
  export * from './default-theme-config.types';
44
44
  export * from './offering-reports.types';
45
+ export * from './payment-methods.types';
45
46
 
46
47
  export enum Versions {
47
48
  V1 = 'v1',
@@ -13,12 +13,7 @@ import {
13
13
  } from './common.types';
14
14
  import { IBaseEntity } from './entity.types';
15
15
  import { IIssuer, issuerIdSchema } from './issuer.types';
16
- import {
17
- IAsset,
18
- postAssetRefinement,
19
- AssetTemplateType,
20
- assetIdSchema,
21
- } from './asset.types';
16
+ import { IAsset, postAssetRefinement, AssetTemplateType } from './asset.types';
22
17
  import { fileIdSchema, FileZod } from './file.types';
23
18
  import { accountIdSchema } from './account.types';
24
19
 
@@ -258,7 +253,6 @@ export const PatchIssuerOffering = z.object({
258
253
  managedBy: z.nativeEnum(ManagedByType).optional(),
259
254
  showTotalRaised: z.boolean().optional(),
260
255
  issuerId: issuerIdSchema.optional(),
261
- assetId: assetIdSchema,
262
256
  assetName: z.string().min(2).max(50).optional().openapi({ example: 'Z' }),
263
257
  assetType: z
264
258
  .nativeEnum(AssetType)
@@ -222,10 +222,51 @@ export type IPaginatedIssuerPaymentMethod = z.infer<
222
222
  typeof IPaginatedIssuerPaymentMethod
223
223
  >;
224
224
 
225
+ const issuerPaymentMethodsInclude = z.enum(['issuer', 'integration']);
226
+
227
+ /**
228
+ * @description Query parameters for including related entities
229
+ * @example in contract use as -> query: PaginationOptionsZod.merge(GetIssuerPaymentMethodZod).merge(IssuerPaymentMethodsIncludeQuery)
230
+ */
231
+ export const IssuerPaymentMethodsIncludeQuery = z.object({
232
+ include: z
233
+ .string()
234
+ .optional()
235
+ .transform((str) => (str ? str.split(',') : []))
236
+ .refine(
237
+ (includes) =>
238
+ includes.every((include) =>
239
+ issuerPaymentMethodsInclude.options.includes(include as any),
240
+ ),
241
+ {
242
+ message: `Invalid include option provided. Valid options are: ${issuerPaymentMethodsInclude.options.join(',')}`,
243
+ },
244
+ )
245
+ .openapi({
246
+ example: `${issuerPaymentMethodsInclude.options.join(',')}`,
247
+ }),
248
+ });
249
+ export type IssuerPaymentMethodsIncludeQuery = z.infer<
250
+ typeof IssuerPaymentMethodsIncludeQuery
251
+ >;
252
+
225
253
  export const GetIssuerPaymentMethodZod = z.object({
226
254
  issuerId: issuerIdSchema.openapi({
227
255
  example: 'issuer_01jdq2crwke8xskjd840cj79pw',
228
256
  }),
257
+ enabled: z
258
+ .string()
259
+ .optional()
260
+ .refine((v) => !v || v === 'true' || v === 'false', {
261
+ message: 'enabled must be a boolean string',
262
+ })
263
+ .transform((v) => {
264
+ if (!v) return undefined;
265
+ return v === 'true';
266
+ })
267
+ .openapi({
268
+ example: 'true',
269
+ }),
229
270
  });
230
271
  export type GetIssuerPaymentMethodZod = z.infer<
231
272
  typeof GetIssuerPaymentMethodZod
@@ -26,11 +26,7 @@ import {
26
26
  InvestorsOfferingsIncludeQuery,
27
27
  } from './investors-offering.types';
28
28
  import { OfferingStatus } from './issuer-offering.types';
29
- import {
30
- assetIdSchema,
31
- postAssetRefinement,
32
- AssetTemplateType,
33
- } from './asset.types';
29
+ import { postAssetRefinement, AssetTemplateType } from './asset.types';
34
30
 
35
31
  export enum OfferingFeeType {
36
32
  FIXED = 'FIXED',
@@ -184,7 +180,6 @@ export const PatchOfferingBase = z.object({
184
180
  });
185
181
  export const PatchOffering = PatchOfferingBase.merge(
186
182
  z.object({
187
- assetId: assetIdSchema,
188
183
  assetName: z
189
184
  .string()
190
185
  .min(2)
@@ -0,0 +1,60 @@
1
+ import { initContract } from '@ts-rest/core';
2
+ import { z } from 'zod';
3
+ import {
4
+ UnauthorizedError,
5
+ ForbiddenError,
6
+ NotFoundError,
7
+ BadRequestError,
8
+ InternalError,
9
+ TradeZod,
10
+ userIdSchema,
11
+ tradeIdSchema,
12
+ } from '../../../common/types';
13
+ import { PatchCartBody } from '../../../common/types/cart.types';
14
+
15
+ const c = initContract();
16
+
17
+ export const cartContract = c.router(
18
+ {
19
+ getTradeCart: {
20
+ summary: 'Get carts (Trade.status = CART)',
21
+ method: 'GET',
22
+ path: '',
23
+ metadata: {
24
+ auth: true,
25
+ },
26
+ query: z.object({
27
+ userId: userIdSchema,
28
+ }),
29
+ responses: {
30
+ 200: TradeZod,
31
+ 401: UnauthorizedError,
32
+ 403: ForbiddenError,
33
+ 404: NotFoundError,
34
+ 500: InternalError,
35
+ },
36
+ },
37
+ patchCart: {
38
+ summary: 'Patch a cart',
39
+ method: 'PATCH',
40
+ path: '/:id',
41
+ metadata: {
42
+ auth: true,
43
+ },
44
+ pathParams: z.object({
45
+ id: tradeIdSchema,
46
+ }),
47
+ body: PatchCartBody,
48
+ responses: {
49
+ 200: TradeZod,
50
+ 400: BadRequestError,
51
+ 401: UnauthorizedError,
52
+ 403: ForbiddenError,
53
+ 500: InternalError,
54
+ },
55
+ },
56
+ },
57
+ {
58
+ pathPrefix: 'carts',
59
+ },
60
+ );
@@ -3,6 +3,7 @@ import { accountsContract } from './accounts';
3
3
  import { apiKeysContract } from './api-keys';
4
4
  import { clientApiKeyLogsContract } from './api-key-logs';
5
5
  import { assetsContract } from './assets';
6
+ import { cartContract } from './cart';
6
7
  import { filesContract } from './files';
7
8
  import { individualsContract } from './individuals';
8
9
  import { investorAccountsContract } from './investor-accounts';
@@ -15,6 +16,9 @@ import { secureRequestContract } from './secure-requests';
15
16
  import { aicContract } from './aic';
16
17
  import { authContract } from './auth';
17
18
  import { sitesContract } from './sites';
19
+ import { paymentMethodsContract } from './payment-methods';
20
+ import { issuerPaymentMethodsContract } from './issuer-payment-methods';
21
+ import { tradeLineItemsContract } from './trade-line-items';
18
22
 
19
23
  const c = initContract();
20
24
 
@@ -27,15 +31,19 @@ export const clientsContract = c.router(
27
31
  apiKeys: apiKeysContract,
28
32
  apiKeyLogs: clientApiKeyLogsContract,
29
33
  assets: assetsContract,
34
+ cart: cartContract,
30
35
  files: filesContract,
31
36
  filesPublic: filesPublicContract,
32
37
  individuals: individualsContract,
33
38
  investorAccounts: investorAccountsContract,
39
+ issuerPaymentMethods: issuerPaymentMethodsContract,
34
40
  issuers: issuersContract,
35
41
  legalEntities: legalEntityContract,
36
42
  offerings: offeringsContract,
43
+ paymentMethods: paymentMethodsContract,
37
44
  secureRequests: secureRequestContract,
38
45
  sites: sitesContract,
46
+ tradeLineItems: tradeLineItemsContract,
39
47
  trades: tradesContract,
40
48
  },
41
49
  {
@@ -0,0 +1,39 @@
1
+ import { initContract } from '@ts-rest/core';
2
+ import {
3
+ ForbiddenError,
4
+ InternalError,
5
+ NotFoundError,
6
+ UnauthorizedError,
7
+ GetIssuerPaymentMethodZod,
8
+ IPaginatedIssuerPaymentMethod,
9
+ IssuerPaymentMethodsIncludeQuery,
10
+ PaginationOptionsZod,
11
+ } from '../../../common/types';
12
+
13
+ const c = initContract();
14
+
15
+ export const issuerPaymentMethodsContract = c.router(
16
+ {
17
+ getIssuerPaymentMethods: {
18
+ summary: 'Get issuer payment methods',
19
+ method: 'GET',
20
+ path: '',
21
+ metadata: {
22
+ auth: true,
23
+ },
24
+ query: PaginationOptionsZod.merge(GetIssuerPaymentMethodZod).merge(
25
+ IssuerPaymentMethodsIncludeQuery,
26
+ ),
27
+ responses: {
28
+ 200: IPaginatedIssuerPaymentMethod,
29
+ 401: UnauthorizedError,
30
+ 403: ForbiddenError,
31
+ 404: NotFoundError,
32
+ 500: InternalError,
33
+ },
34
+ },
35
+ },
36
+ {
37
+ pathPrefix: 'issuer-payment-methods',
38
+ },
39
+ );
@@ -0,0 +1,85 @@
1
+ import { initContract } from '@ts-rest/core';
2
+ import { z } from 'zod';
3
+ import {
4
+ UnauthorizedError,
5
+ ForbiddenError,
6
+ NotFoundError,
7
+ userIdSchema,
8
+ BadRequestError,
9
+ InternalError,
10
+ } from '../../../common/types';
11
+ import {
12
+ PaymentMethodResponseArray,
13
+ PaymentMethodResponse,
14
+ PostPaymentMethod,
15
+ PostSetupIntentBody,
16
+ SetupIntentResponse,
17
+ } from '../../../common/types/payment-methods.types';
18
+
19
+ const c = initContract();
20
+
21
+ export const paymentMethodsContract = c.router(
22
+ {
23
+ getPaymentMethods: {
24
+ summary: 'Get payment methods for a user',
25
+ method: 'GET',
26
+ path: '',
27
+ metadata: {
28
+ auth: true,
29
+ },
30
+ query: z.object({
31
+ userId: userIdSchema,
32
+ }),
33
+ responses: {
34
+ 200: PaymentMethodResponseArray,
35
+ 401: UnauthorizedError,
36
+ 403: ForbiddenError,
37
+ 404: NotFoundError,
38
+ 500: InternalError,
39
+ },
40
+ },
41
+ createPaymentMethod: {
42
+ summary: 'Create payment method for a user',
43
+ method: 'POST',
44
+ path: '',
45
+ metadata: {
46
+ auth: true,
47
+ },
48
+ query: z.object({
49
+ userId: userIdSchema,
50
+ }),
51
+ body: PostPaymentMethod,
52
+ responses: {
53
+ 201: PaymentMethodResponse,
54
+ 400: BadRequestError,
55
+ 401: UnauthorizedError,
56
+ 403: ForbiddenError,
57
+ 404: NotFoundError,
58
+ 500: InternalError,
59
+ },
60
+ },
61
+ createSetupIntent: {
62
+ summary: 'Create payment method setup intent for a user',
63
+ method: 'POST',
64
+ path: '/intent',
65
+ metadata: {
66
+ auth: true,
67
+ },
68
+ query: z.object({
69
+ userId: userIdSchema,
70
+ }),
71
+ body: PostSetupIntentBody,
72
+ responses: {
73
+ 201: SetupIntentResponse,
74
+ 400: BadRequestError,
75
+ 401: UnauthorizedError,
76
+ 403: ForbiddenError,
77
+ 404: NotFoundError,
78
+ 500: InternalError,
79
+ },
80
+ },
81
+ },
82
+ {
83
+ pathPrefix: 'payment-methods',
84
+ },
85
+ );
@@ -0,0 +1,66 @@
1
+ import { initContract } from '@ts-rest/core';
2
+ import { z } from 'zod';
3
+ import {
4
+ BadRequestError,
5
+ ForbiddenError,
6
+ InternalError,
7
+ NotFoundError,
8
+ UnauthorizedError,
9
+ userIdSchema,
10
+ } from '../../../common/types';
11
+ import {
12
+ PostTradeLineItem,
13
+ TradeLineItemParams,
14
+ TradeLineItemQuery,
15
+ TradeLineItemResponse,
16
+ TradeLineItemUpdate,
17
+ } from '../../../common/types/trade-line-item.type';
18
+
19
+ const c = initContract();
20
+
21
+ export const tradeLineItemsContract = c.router(
22
+ {
23
+ postTradeLineItem: {
24
+ summary: 'Create Trade Line Item',
25
+ method: 'POST',
26
+ path: '/',
27
+ metadata: {
28
+ auth: true,
29
+ },
30
+ body: PostTradeLineItem,
31
+ query: TradeLineItemQuery.merge(
32
+ z.object({
33
+ userId: userIdSchema,
34
+ }),
35
+ ),
36
+ responses: {
37
+ 201: TradeLineItemResponse,
38
+ 401: UnauthorizedError,
39
+ 403: ForbiddenError,
40
+ 400: BadRequestError,
41
+ 500: InternalError,
42
+ },
43
+ },
44
+ updateTradeLineItem: {
45
+ summary: 'Update Trade Line Item - Can delete if you pass quantity = 0',
46
+ method: 'PATCH',
47
+ path: '/:id',
48
+ metadata: {
49
+ auth: true,
50
+ },
51
+ pathParams: TradeLineItemParams,
52
+ body: TradeLineItemUpdate,
53
+ responses: {
54
+ 200: TradeLineItemResponse,
55
+ 401: UnauthorizedError,
56
+ 403: ForbiddenError,
57
+ 404: NotFoundError,
58
+ 500: InternalError,
59
+ 400: BadRequestError,
60
+ },
61
+ },
62
+ },
63
+ {
64
+ pathPrefix: 'trade-line-items',
65
+ },
66
+ );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalmore/api-contracts",
3
- "version": "0.0.0-dev.d30d175",
3
+ "version": "0.0.0-dev.ff07a57",
4
4
  "description": "Type-safe API contracts for Dalmore Client Portal",
5
5
  "main": "./contracts/index.ts",
6
6
  "types": "./contracts/index.ts",