@dalmore/api-contracts 1.0.1 → 1.0.3
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 +12 -7
- package/clients/index.mjs +10970 -0
- package/compliance/index.mjs +20016 -0
- package/compliance-apikey/index.mjs +9795 -0
- package/helpers/index.mjs +146 -0
- package/index.mjs +28607 -0
- package/investors/index.mjs +12844 -0
- package/issuers/index.mjs +16168 -0
- package/package.json +42 -31
- package/secondaries/index.mjs +10282 -0
- package/src/common/helpers/index.ts +205 -0
- package/{common → src/common}/types/batch-jobs.types.ts +0 -1
- package/{common → src/common}/types/common.types.ts +1 -1
- package/src/common/types/contract-helpers.ts +205 -0
- package/{common → src/common}/types/page.types.ts +1 -1
- package/{common → src/common}/types/queue.types.ts +0 -1
- package/{common → src/common}/types/trade.types.ts +4 -2
- package/{common → src/common}/types/zip.type.ts +1 -1
- package/types/index.mjs +10320 -0
- package/common/helpers/index.ts +0 -88
- package/common/types/contract-helpers.ts +0 -88
- package/common/types/reminder-config.types.ts +0 -40
- /package/{common → src/common}/types/account-contact.types.ts +0 -0
- /package/{common → src/common}/types/account-detail.types.ts +0 -0
- /package/{common → src/common}/types/account-integration.types.ts +0 -0
- /package/{common → src/common}/types/account-manager.types.ts +0 -0
- /package/{common → src/common}/types/account.types.ts +0 -0
- /package/{common → src/common}/types/activity.types.ts +0 -0
- /package/{common → src/common}/types/address.types.ts +0 -0
- /package/{common → src/common}/types/aic.types.ts +0 -0
- /package/{common → src/common}/types/aml.types.ts +0 -0
- /package/{common → src/common}/types/api-key-logs.types.ts +0 -0
- /package/{common → src/common}/types/api-keys.types.ts +0 -0
- /package/{common → src/common}/types/asset.types.ts +0 -0
- /package/{common → src/common}/types/auth.types.ts +0 -0
- /package/{common → src/common}/types/bonus-tier.types.ts +0 -0
- /package/{common → src/common}/types/cart.types.ts +0 -0
- /package/{common → src/common}/types/checklist-items.types.ts +0 -0
- /package/{common → src/common}/types/checklist.types.ts +0 -0
- /package/{common → src/common}/types/comply-advantage-api.types.ts +0 -0
- /package/{common → src/common}/types/comply-advantage.types.ts +0 -0
- /package/{common → src/common}/types/contact-us.types.ts +0 -0
- /package/{common → src/common}/types/countries.types.ts +0 -0
- /package/{common → src/common}/types/covered-person.types.ts +0 -0
- /package/{common → src/common}/types/dashboard.types.ts +0 -0
- /package/{common → src/common}/types/data-record.types.ts +0 -0
- /package/{common → src/common}/types/data-room.types.ts +0 -0
- /package/{common → src/common}/types/default-theme-config.types.ts +0 -0
- /package/{common → src/common}/types/disbursement-adjustment.types.ts +0 -0
- /package/{common → src/common}/types/disbursement-approval-user.types.ts +0 -0
- /package/{common → src/common}/types/disbursement-review.types.ts +0 -0
- /package/{common → src/common}/types/disbursement-transaction.types.ts +0 -0
- /package/{common → src/common}/types/disbursements.types.ts +0 -0
- /package/{common → src/common}/types/domain-filter.types.ts +0 -0
- /package/{common → src/common}/types/email-theme.types.ts +0 -0
- /package/{common → src/common}/types/entity.types.ts +0 -0
- /package/{common → src/common}/types/error-responses.types.ts +0 -0
- /package/{common → src/common}/types/escrow-account.types.ts +0 -0
- /package/{common → src/common}/types/exchange-api-key.types.ts +0 -0
- /package/{common → src/common}/types/exchange-import.types.ts +0 -0
- /package/{common → src/common}/types/exchange-provider.types.ts +0 -0
- /package/{common → src/common}/types/file.types.ts +0 -0
- /package/{common → src/common}/types/health.types.ts +0 -0
- /package/{common → src/common}/types/index.ts +0 -0
- /package/{common → src/common}/types/individuals.types.ts +0 -0
- /package/{common → src/common}/types/investor-account.types.ts +0 -0
- /package/{common → src/common}/types/investorAccountIdSchema.type.ts +0 -0
- /package/{common → src/common}/types/investors-offering.types.ts +0 -0
- /package/{common → src/common}/types/invite.types.ts +0 -0
- /package/{common → src/common}/types/issuer-bank-account.types.ts +0 -0
- /package/{common → src/common}/types/issuer-offering.types.ts +0 -0
- /package/{common → src/common}/types/issuer-payment-method.types.ts +0 -0
- /package/{common → src/common}/types/issuer.types.ts +0 -0
- /package/{common → src/common}/types/job-item.types.ts +0 -0
- /package/{common → src/common}/types/jobs.types.ts +0 -0
- /package/{common → src/common}/types/kyb.types.ts +0 -0
- /package/{common → src/common}/types/kyc.types.ts +0 -0
- /package/{common → src/common}/types/legal-entity.types.ts +0 -0
- /package/{common → src/common}/types/login-history.types.ts +0 -0
- /package/{common → src/common}/types/mail-template.types.ts +0 -0
- /package/{common → src/common}/types/north-cap-integration.types.ts +0 -0
- /package/{common → src/common}/types/note.types.ts +0 -0
- /package/{common → src/common}/types/notification.types.ts +0 -0
- /package/{common → src/common}/types/notion-api.types.ts +0 -0
- /package/{common → src/common}/types/notion-database.types.ts +0 -0
- /package/{common → src/common}/types/notion-page.types.ts +0 -0
- /package/{common → src/common}/types/offering-reports.types.ts +0 -0
- /package/{common → src/common}/types/offering-submission.types.ts +0 -0
- /package/{common → src/common}/types/offering.types.ts +0 -0
- /package/{common → src/common}/types/page-revision.types.ts +0 -0
- /package/{common → src/common}/types/password.type.ts +0 -0
- /package/{common → src/common}/types/payment-methods.types.ts +0 -0
- /package/{common → src/common}/types/phone.type.ts +0 -0
- /package/{common → src/common}/types/portfolio.types.ts +0 -0
- /package/{common → src/common}/types/privacy-policy-and-tos.types.ts +0 -0
- /package/{common → src/common}/types/registered-reps.types.ts +0 -0
- /package/{common → src/common}/types/rejection-reasons.types.ts +0 -0
- /package/{common → src/common}/types/review.types.ts +0 -0
- /package/{common → src/common}/types/role.types.ts +0 -0
- /package/{common → src/common}/types/secondary-customer.types.ts +0 -0
- /package/{common → src/common}/types/secondary-issuer.types.ts +0 -0
- /package/{common → src/common}/types/secondary-order.types.ts +0 -0
- /package/{common → src/common}/types/secondary-security.types.ts +0 -0
- /package/{common → src/common}/types/secondary-trade.entity.ts +0 -0
- /package/{common → src/common}/types/secondary-trade.types.ts +0 -0
- /package/{common → src/common}/types/secure-request.types.ts +0 -0
- /package/{common → src/common}/types/signer.types.ts +0 -0
- /package/{common → src/common}/types/site-link.types.ts +0 -0
- /package/{common → src/common}/types/site-settings.types.ts +0 -0
- /package/{common → src/common}/types/site.types.ts +0 -0
- /package/{common → src/common}/types/sms.types.ts +0 -0
- /package/{common → src/common}/types/state-machine.types.ts +0 -0
- /package/{common → src/common}/types/states.types.ts +0 -0
- /package/{common → src/common}/types/subdoc-preview.types.ts +0 -0
- /package/{common → src/common}/types/task.types.ts +0 -0
- /package/{common → src/common}/types/trade-adjustment.type.ts +0 -0
- /package/{common → src/common}/types/trade-line-item.type.ts +0 -0
- /package/{common → src/common}/types/transaction.types.ts +0 -0
- /package/{common → src/common}/types/trusted-contact.types.ts +0 -0
- /package/{common → src/common}/types/typography.types.ts +0 -0
- /package/{common → src/common}/types/user-manual.types.ts +0 -0
- /package/{common → src/common}/types/user-setting.types.ts +0 -0
- /package/{common → src/common}/types/user.types.ts +0 -0
- /package/{common → src/common}/types/webhook.types.ts +0 -0
- /package/{contracts → src/contracts}/clients/accounts/index.ts +0 -0
- /package/{contracts → src/contracts}/clients/aic/index.ts +0 -0
- /package/{contracts → src/contracts}/clients/api-key-logs/index.ts +0 -0
- /package/{contracts → src/contracts}/clients/api-keys/index.ts +0 -0
- /package/{contracts → src/contracts}/clients/assets/index.ts +0 -0
- /package/{contracts → src/contracts}/clients/auth/index.ts +0 -0
- /package/{contracts → src/contracts}/clients/files/index.ts +0 -0
- /package/{contracts → src/contracts}/clients/files-public/index.ts +0 -0
- /package/{contracts → src/contracts}/clients/index.ts +0 -0
- /package/{contracts → src/contracts}/clients/individuals/index.ts +0 -0
- /package/{contracts → src/contracts}/clients/investor-accounts/index.ts +0 -0
- /package/{contracts → src/contracts}/clients/issuers/index.ts +0 -0
- /package/{contracts → src/contracts}/clients/legal-entities/index.ts +0 -0
- /package/{contracts → src/contracts}/clients/offerings/index.ts +0 -0
- /package/{contracts → src/contracts}/clients/secure-requests/index.ts +0 -0
- /package/{contracts → src/contracts}/clients/sites/index.ts +0 -0
- /package/{contracts → src/contracts}/clients/trades/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/account-contacts/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/account-managers/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/accounts/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/activities/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/aic/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/api-keys/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/assets/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/auth/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/batch-jobs/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/bonus-tiers/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/checklist/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/checklist-items/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/covered-persons/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/dashboard/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/data-records/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/data-rooms/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/default-theme-configs/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/disbursement/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/disbursement-approval-users/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/disbursement-transactions/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/domain-filters/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/email-themes/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/escrow-accounts/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/exchange-api-keys/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/exchange-imports/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/files/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/files-public/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/health/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/individuals/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/investor-accounts/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/invites/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/issuer-bank-accounts/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/issuer-payment-methods/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/issuers/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/job-items/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/jobs/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/kyb/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/kyc/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/legal-entities/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/login-histories/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/notes/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/notion-databases/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/notion-pages/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/offering-reports/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/offerings/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/pages/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/payment-methods/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/rejection-reasons/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/review/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/roles/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/secondary-customers/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/secondary-orders/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/secondary-trades/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/secure-requests/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/signer/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/site-links/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/site-settings/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/sites/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/state-machine/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/tasks/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/third-parties/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/trade-line-items/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/trades/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/transactions/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/user-manuals/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/user-settings/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/users/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance/webhooks/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance-apikey/accounts/index.ts +0 -0
- /package/{contracts → src/contracts}/compliance-apikey/index.ts +0 -0
- /package/{contracts → src/contracts}/index.ts +0 -0
- /package/{contracts → src/contracts}/investors/account-contacts/index.ts +0 -0
- /package/{contracts → src/contracts}/investors/aic/index.ts +0 -0
- /package/{contracts → src/contracts}/investors/assets/index.ts +0 -0
- /package/{contracts → src/contracts}/investors/auth/index.ts +0 -0
- /package/{contracts → src/contracts}/investors/bonus-tiers/index.ts +0 -0
- /package/{contracts → src/contracts}/investors/cart/index.ts +0 -0
- /package/{contracts → src/contracts}/investors/contact-us/index.ts +0 -0
- /package/{contracts → src/contracts}/investors/data-records/index.ts +0 -0
- /package/{contracts → src/contracts}/investors/data-rooms/index.ts +0 -0
- /package/{contracts → src/contracts}/investors/files/index.ts +0 -0
- /package/{contracts → src/contracts}/investors/files-public/index.ts +0 -0
- /package/{contracts → src/contracts}/investors/index.ts +0 -0
- /package/{contracts → src/contracts}/investors/individuals/index.ts +0 -0
- /package/{contracts → src/contracts}/investors/investor-accounts/index.ts +0 -0
- /package/{contracts → src/contracts}/investors/issuer-payment-methods/index.ts +0 -0
- /package/{contracts → src/contracts}/investors/issuers/index.ts +0 -0
- /package/{contracts → src/contracts}/investors/legal-entities/index.ts +0 -0
- /package/{contracts → src/contracts}/investors/notes/index.ts +0 -0
- /package/{contracts → src/contracts}/investors/offerings/index.ts +0 -0
- /package/{contracts → src/contracts}/investors/pages/index.ts +0 -0
- /package/{contracts → src/contracts}/investors/payment-methods/index.ts +0 -0
- /package/{contracts → src/contracts}/investors/portfolios/index.ts +0 -0
- /package/{contracts → src/contracts}/investors/sites/index.ts +0 -0
- /package/{contracts → src/contracts}/investors/tasks/index.ts +0 -0
- /package/{contracts → src/contracts}/investors/trade-line-items/index.ts +0 -0
- /package/{contracts → src/contracts}/investors/trades/index.ts +0 -0
- /package/{contracts → src/contracts}/investors/transactions/index.ts +0 -0
- /package/{contracts → src/contracts}/investors/trusted-contacts/index.ts +0 -0
- /package/{contracts → src/contracts}/investors/user-manuals/index.ts +0 -0
- /package/{contracts → src/contracts}/investors/user-settings/index.ts +0 -0
- /package/{contracts → src/contracts}/investors/users/index.ts +0 -0
- /package/{contracts → src/contracts}/investors/webhooks/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/account-contacts/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/account-integrations/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/accounts/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/activities/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/aic/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/api-key-logs/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/api-keys/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/assets/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/auth/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/bonus-tiers/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/contact-us/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/covered-persons/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/dashboard/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/data-records/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/data-rooms/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/disbursement-approval-users/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/disbursement-transactions/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/disbursements/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/email-themes/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/escrow-accounts/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/exchange-api-keys/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/files/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/files-public/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/health/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/investor-accounts/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/invites/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/issuer/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/issuer-bank-accounts/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/issuer-payment-methods/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/kyc/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/login-histories/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/notes/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/offerings/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/pages/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/payment-methods/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/portfolios/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/rejection-reasons/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/review/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/secondary-customers/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/secondary-orders/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/secondary-trades/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/secure-requests/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/site-links/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/site-settings/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/sites/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/tasks/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/trades/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/transactions/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/user-manuals/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/user-settings/index.ts +0 -0
- /package/{contracts → src/contracts}/issuers/users/index.ts +0 -0
- /package/{contracts → src/contracts}/secondaries/accounts/index.ts +0 -0
- /package/{contracts → src/contracts}/secondaries/index.ts +0 -0
- /package/{contracts → src/contracts}/secondaries/secondary-customers/index.ts +0 -0
- /package/{contracts → src/contracts}/secondaries/secondary-issuers/index.ts +0 -0
- /package/{contracts → src/contracts}/secondaries/secondary-orders/index.ts +0 -0
- /package/{contracts → src/contracts}/secondaries/secondary-securities/index.ts +0 -0
- /package/{contracts → src/contracts}/secondaries/secondary-trades/index.ts +0 -0
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contract helpers - minimal subset for API contracts package
|
|
3
|
+
* This file is copied directly to @dalmore/api-contracts
|
|
4
|
+
*/
|
|
5
|
+
import { HttpStatus } from '@nestjs/common';
|
|
6
|
+
import parsePhoneNumberFromString, {
|
|
7
|
+
CountryCode,
|
|
8
|
+
PhoneNumber,
|
|
9
|
+
} from 'libphonenumber-js';
|
|
10
|
+
import { err, ok, Result } from 'neverthrow';
|
|
11
|
+
import { ErrorResult } from '../types/common.types';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Validates a US zip code format (12345 or 12345-6789)
|
|
15
|
+
*/
|
|
16
|
+
export const validateUSZipCode = (zipCode: string): boolean => {
|
|
17
|
+
const regex = /^[0-9]{5}(?:-[0-9]{4})?$/;
|
|
18
|
+
return regex.test(zipCode);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Validates a Canadian postal code format (A1A 1A1)
|
|
23
|
+
*/
|
|
24
|
+
export const validateCanadaZipCode = (zipCode: string): boolean => {
|
|
25
|
+
const regex = /^[A-Za-z]\d[A-Za-z] \d[A-Za-z]\d$/;
|
|
26
|
+
return regex.test(zipCode);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Normalizes a short date string (M/D/YY or M/D/YYYY) to MM/DD/YYYY format
|
|
31
|
+
*/
|
|
32
|
+
export function normalizeShortDate(input: string): string {
|
|
33
|
+
const [month, day, year] = input.split('/');
|
|
34
|
+
|
|
35
|
+
if (!month || !day || !year) {
|
|
36
|
+
throw new Error('Invalid date format');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const paddedMonth = month.padStart(2, '0');
|
|
40
|
+
const paddedDay = day.padStart(2, '0');
|
|
41
|
+
const fullYear = year.length === 2 ? `20${year}` : year;
|
|
42
|
+
|
|
43
|
+
return `${paddedMonth}/${paddedDay}/${fullYear}`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Converts a string into a URL-safe slug
|
|
48
|
+
*/
|
|
49
|
+
export function slugify(input: string, exclude: boolean = false): string {
|
|
50
|
+
if (exclude) {
|
|
51
|
+
const excludeWords = ['llc', 'inc', 'corp', 'co'];
|
|
52
|
+
const negativeWordsList = [
|
|
53
|
+
'www',
|
|
54
|
+
'api',
|
|
55
|
+
'admin',
|
|
56
|
+
'dashboard',
|
|
57
|
+
'auth',
|
|
58
|
+
'cdn',
|
|
59
|
+
'static',
|
|
60
|
+
'blog',
|
|
61
|
+
'support',
|
|
62
|
+
'status',
|
|
63
|
+
'mail',
|
|
64
|
+
'smtp',
|
|
65
|
+
'ftp',
|
|
66
|
+
'ssh',
|
|
67
|
+
'login',
|
|
68
|
+
'register',
|
|
69
|
+
'signup',
|
|
70
|
+
'account',
|
|
71
|
+
'accounts',
|
|
72
|
+
'user',
|
|
73
|
+
'users',
|
|
74
|
+
'profile',
|
|
75
|
+
'settings',
|
|
76
|
+
'help',
|
|
77
|
+
'docs',
|
|
78
|
+
'documentation',
|
|
79
|
+
'developer',
|
|
80
|
+
'developers',
|
|
81
|
+
'app',
|
|
82
|
+
'apps',
|
|
83
|
+
'test',
|
|
84
|
+
'demo',
|
|
85
|
+
'staging',
|
|
86
|
+
'dev',
|
|
87
|
+
'prod',
|
|
88
|
+
'production',
|
|
89
|
+
'beta',
|
|
90
|
+
'alpha',
|
|
91
|
+
'portal',
|
|
92
|
+
'portals',
|
|
93
|
+
'client',
|
|
94
|
+
'clients',
|
|
95
|
+
'investor',
|
|
96
|
+
'investors',
|
|
97
|
+
'issuer',
|
|
98
|
+
'issuers',
|
|
99
|
+
'compliance',
|
|
100
|
+
'offering',
|
|
101
|
+
'offerings',
|
|
102
|
+
'trade',
|
|
103
|
+
'trades',
|
|
104
|
+
];
|
|
105
|
+
|
|
106
|
+
let slug = input
|
|
107
|
+
.toLowerCase()
|
|
108
|
+
.replace(/[^\w\s-]/g, '')
|
|
109
|
+
.replace(/[\s_-]+/g, '-')
|
|
110
|
+
.replace(/^-+|-+$/g, '');
|
|
111
|
+
|
|
112
|
+
excludeWords.forEach((word) => {
|
|
113
|
+
slug = slug.replace(new RegExp(`-${word}$`, 'i'), '');
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
if (negativeWordsList.includes(slug)) {
|
|
117
|
+
return 'new-account';
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return slug;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return input
|
|
124
|
+
.toLowerCase()
|
|
125
|
+
.replace(/[^\w\s-]/g, '')
|
|
126
|
+
.replace(/[\s_-]+/g, '-')
|
|
127
|
+
.replace(/^-+|-+$/g, '');
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
type CurlOptions = {
|
|
131
|
+
query?: Record<string, string>;
|
|
132
|
+
headers?: Record<string, string>;
|
|
133
|
+
body?: Record<string, unknown>;
|
|
134
|
+
formData?: Record<string, string>;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
export const authHeader: CurlOptions['headers'] = {
|
|
138
|
+
Authorization: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9',
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
const generateCurlExample = (
|
|
142
|
+
method: string,
|
|
143
|
+
path: string,
|
|
144
|
+
options: CurlOptions,
|
|
145
|
+
) => {
|
|
146
|
+
const baseUrl = 'https://dalmore-client-portal-api-prod.onrender.com/api/v1';
|
|
147
|
+
let curl = `curl -X ${method.toUpperCase()} '${baseUrl}${path}`;
|
|
148
|
+
if (options.query) {
|
|
149
|
+
const queryString = new URLSearchParams(options.query).toString();
|
|
150
|
+
curl += `?${queryString}`;
|
|
151
|
+
}
|
|
152
|
+
curl += "'";
|
|
153
|
+
if (options.headers) {
|
|
154
|
+
Object.entries(options.headers).forEach(([key, value]) => {
|
|
155
|
+
curl += ` \\\n --header '${key}: ${value}'`;
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
if (options.body) {
|
|
159
|
+
curl += ` \\\n --header 'Content-Type: application/json'`;
|
|
160
|
+
curl += ` \\\n --data '${JSON.stringify(options.body)}'`;
|
|
161
|
+
}
|
|
162
|
+
if (options.formData) {
|
|
163
|
+
Object.entries(options.formData).forEach(([key, value]) => {
|
|
164
|
+
curl += ` \\\n --form '${key}=${value}'`;
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
return curl;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
export const generateApiDescription = (
|
|
171
|
+
summary: string,
|
|
172
|
+
method: string,
|
|
173
|
+
path: string,
|
|
174
|
+
options: CurlOptions,
|
|
175
|
+
) => {
|
|
176
|
+
const curlExample = generateCurlExample(method, path, options);
|
|
177
|
+
return `${summary}
|
|
178
|
+
|
|
179
|
+
### Example curl request
|
|
180
|
+
|
|
181
|
+
\`\`\`bash
|
|
182
|
+
${curlExample}
|
|
183
|
+
\`\`\``;
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Normalizes a phone number to E.164 format
|
|
188
|
+
*/
|
|
189
|
+
export function normalizePhoneNumber(
|
|
190
|
+
phoneNumber: string,
|
|
191
|
+
countryCode: CountryCode,
|
|
192
|
+
): Result<PhoneNumber, ErrorResult> {
|
|
193
|
+
const parsedPhoneNumber = parsePhoneNumberFromString(
|
|
194
|
+
phoneNumber,
|
|
195
|
+
countryCode,
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
if (!parsedPhoneNumber || !parsedPhoneNumber.isValid()) {
|
|
199
|
+
return err({
|
|
200
|
+
status: HttpStatus.BAD_REQUEST,
|
|
201
|
+
message: 'Invalid phone number. Only numbers',
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
return ok(parsedPhoneNumber);
|
|
205
|
+
}
|
|
@@ -5,7 +5,6 @@ import { dateSchema, IPaginationMeta, UserRole } from './common.types';
|
|
|
5
5
|
import { userIdSchema } from './user.types';
|
|
6
6
|
import { accountIdSchema } from './account.types';
|
|
7
7
|
import { IBaseEntity } from './entity.types';
|
|
8
|
-
import { JobsOptions } from 'bullmq';
|
|
9
8
|
|
|
10
9
|
extendZodWithOpenApi(z);
|
|
11
10
|
|
|
@@ -4,7 +4,7 @@ import { z } from 'zod';
|
|
|
4
4
|
import { TypeID } from 'typeid-js';
|
|
5
5
|
import { ErrorHttpStatusCode } from '@ts-rest/core';
|
|
6
6
|
import { TwoFactorMethod } from './sms.types';
|
|
7
|
-
import { normalizeShortDate } from '
|
|
7
|
+
import { normalizeShortDate } from './contract-helpers';
|
|
8
8
|
import { HttpStatus } from '@nestjs/common';
|
|
9
9
|
|
|
10
10
|
extendZodWithOpenApi(z);
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contract helpers - minimal subset for API contracts package
|
|
3
|
+
* This file is copied directly to @dalmore/api-contracts
|
|
4
|
+
*/
|
|
5
|
+
import { HttpStatus } from '@nestjs/common';
|
|
6
|
+
import parsePhoneNumberFromString, {
|
|
7
|
+
CountryCode,
|
|
8
|
+
PhoneNumber,
|
|
9
|
+
} from 'libphonenumber-js';
|
|
10
|
+
import { err, ok, Result } from 'neverthrow';
|
|
11
|
+
import { ErrorResult } from './common.types';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Validates a US zip code format (12345 or 12345-6789)
|
|
15
|
+
*/
|
|
16
|
+
export const validateUSZipCode = (zipCode: string): boolean => {
|
|
17
|
+
const regex = /^[0-9]{5}(?:-[0-9]{4})?$/;
|
|
18
|
+
return regex.test(zipCode);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Validates a Canadian postal code format (A1A 1A1)
|
|
23
|
+
*/
|
|
24
|
+
export const validateCanadaZipCode = (zipCode: string): boolean => {
|
|
25
|
+
const regex = /^[A-Za-z]\d[A-Za-z] \d[A-Za-z]\d$/;
|
|
26
|
+
return regex.test(zipCode);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Normalizes a short date string (M/D/YY or M/D/YYYY) to MM/DD/YYYY format
|
|
31
|
+
*/
|
|
32
|
+
export function normalizeShortDate(input: string): string {
|
|
33
|
+
const [month, day, year] = input.split('/');
|
|
34
|
+
|
|
35
|
+
if (!month || !day || !year) {
|
|
36
|
+
throw new Error('Invalid date format');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const paddedMonth = month.padStart(2, '0');
|
|
40
|
+
const paddedDay = day.padStart(2, '0');
|
|
41
|
+
const fullYear = year.length === 2 ? `20${year}` : year;
|
|
42
|
+
|
|
43
|
+
return `${paddedMonth}/${paddedDay}/${fullYear}`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Converts a string into a URL-safe slug
|
|
48
|
+
*/
|
|
49
|
+
export function slugify(input: string, exclude: boolean = false): string {
|
|
50
|
+
if (exclude) {
|
|
51
|
+
const excludeWords = ['llc', 'inc', 'corp', 'co'];
|
|
52
|
+
const negativeWordsList = [
|
|
53
|
+
'www',
|
|
54
|
+
'api',
|
|
55
|
+
'admin',
|
|
56
|
+
'dashboard',
|
|
57
|
+
'auth',
|
|
58
|
+
'cdn',
|
|
59
|
+
'static',
|
|
60
|
+
'blog',
|
|
61
|
+
'support',
|
|
62
|
+
'status',
|
|
63
|
+
'mail',
|
|
64
|
+
'smtp',
|
|
65
|
+
'ftp',
|
|
66
|
+
'ssh',
|
|
67
|
+
'login',
|
|
68
|
+
'register',
|
|
69
|
+
'signup',
|
|
70
|
+
'account',
|
|
71
|
+
'accounts',
|
|
72
|
+
'user',
|
|
73
|
+
'users',
|
|
74
|
+
'profile',
|
|
75
|
+
'settings',
|
|
76
|
+
'help',
|
|
77
|
+
'docs',
|
|
78
|
+
'documentation',
|
|
79
|
+
'developer',
|
|
80
|
+
'developers',
|
|
81
|
+
'app',
|
|
82
|
+
'apps',
|
|
83
|
+
'test',
|
|
84
|
+
'demo',
|
|
85
|
+
'staging',
|
|
86
|
+
'dev',
|
|
87
|
+
'prod',
|
|
88
|
+
'production',
|
|
89
|
+
'beta',
|
|
90
|
+
'alpha',
|
|
91
|
+
'portal',
|
|
92
|
+
'portals',
|
|
93
|
+
'client',
|
|
94
|
+
'clients',
|
|
95
|
+
'investor',
|
|
96
|
+
'investors',
|
|
97
|
+
'issuer',
|
|
98
|
+
'issuers',
|
|
99
|
+
'compliance',
|
|
100
|
+
'offering',
|
|
101
|
+
'offerings',
|
|
102
|
+
'trade',
|
|
103
|
+
'trades',
|
|
104
|
+
];
|
|
105
|
+
|
|
106
|
+
let slug = input
|
|
107
|
+
.toLowerCase()
|
|
108
|
+
.replace(/[^\w\s-]/g, '')
|
|
109
|
+
.replace(/[\s_-]+/g, '-')
|
|
110
|
+
.replace(/^-+|-+$/g, '');
|
|
111
|
+
|
|
112
|
+
excludeWords.forEach((word) => {
|
|
113
|
+
slug = slug.replace(new RegExp(`-${word}$`, 'i'), '');
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
if (negativeWordsList.includes(slug)) {
|
|
117
|
+
return 'new-account';
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return slug;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return input
|
|
124
|
+
.toLowerCase()
|
|
125
|
+
.replace(/[^\w\s-]/g, '')
|
|
126
|
+
.replace(/[\s_-]+/g, '-')
|
|
127
|
+
.replace(/^-+|-+$/g, '');
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
type CurlOptions = {
|
|
131
|
+
query?: Record<string, string>;
|
|
132
|
+
headers?: Record<string, string>;
|
|
133
|
+
body?: Record<string, unknown>;
|
|
134
|
+
formData?: Record<string, string>;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
export const authHeader: CurlOptions['headers'] = {
|
|
138
|
+
Authorization: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9',
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
const generateCurlExample = (
|
|
142
|
+
method: string,
|
|
143
|
+
path: string,
|
|
144
|
+
options: CurlOptions,
|
|
145
|
+
) => {
|
|
146
|
+
const baseUrl = 'https://dalmore-client-portal-api-prod.onrender.com/api/v1';
|
|
147
|
+
let curl = `curl -X ${method.toUpperCase()} '${baseUrl}${path}`;
|
|
148
|
+
if (options.query) {
|
|
149
|
+
const queryString = new URLSearchParams(options.query).toString();
|
|
150
|
+
curl += `?${queryString}`;
|
|
151
|
+
}
|
|
152
|
+
curl += "'";
|
|
153
|
+
if (options.headers) {
|
|
154
|
+
Object.entries(options.headers).forEach(([key, value]) => {
|
|
155
|
+
curl += ` \\\n --header '${key}: ${value}'`;
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
if (options.body) {
|
|
159
|
+
curl += ` \\\n --header 'Content-Type: application/json'`;
|
|
160
|
+
curl += ` \\\n --data '${JSON.stringify(options.body)}'`;
|
|
161
|
+
}
|
|
162
|
+
if (options.formData) {
|
|
163
|
+
Object.entries(options.formData).forEach(([key, value]) => {
|
|
164
|
+
curl += ` \\\n --form '${key}=${value}'`;
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
return curl;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
export const generateApiDescription = (
|
|
171
|
+
summary: string,
|
|
172
|
+
method: string,
|
|
173
|
+
path: string,
|
|
174
|
+
options: CurlOptions,
|
|
175
|
+
) => {
|
|
176
|
+
const curlExample = generateCurlExample(method, path, options);
|
|
177
|
+
return `${summary}
|
|
178
|
+
|
|
179
|
+
### Example curl request
|
|
180
|
+
|
|
181
|
+
\`\`\`bash
|
|
182
|
+
${curlExample}
|
|
183
|
+
\`\`\``;
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Normalizes a phone number to E.164 format
|
|
188
|
+
*/
|
|
189
|
+
export function normalizePhoneNumber(
|
|
190
|
+
phoneNumber: string,
|
|
191
|
+
countryCode: CountryCode,
|
|
192
|
+
): Result<PhoneNumber, ErrorResult> {
|
|
193
|
+
const parsedPhoneNumber = parsePhoneNumberFromString(
|
|
194
|
+
phoneNumber,
|
|
195
|
+
countryCode,
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
if (!parsedPhoneNumber || !parsedPhoneNumber.isValid()) {
|
|
199
|
+
return err({
|
|
200
|
+
status: HttpStatus.BAD_REQUEST,
|
|
201
|
+
message: 'Invalid phone number. Only numbers',
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
return ok(parsedPhoneNumber);
|
|
205
|
+
}
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
UrlSchema,
|
|
15
15
|
} from './common.types';
|
|
16
16
|
import { accountIdSchema } from './account.types';
|
|
17
|
-
import { slugify } from '
|
|
17
|
+
import { slugify } from './contract-helpers';
|
|
18
18
|
import { fileIdSchema } from './file.types';
|
|
19
19
|
|
|
20
20
|
extendZodWithOpenApi(z);
|
|
@@ -53,8 +53,10 @@ import {
|
|
|
53
53
|
SecondaryTrade,
|
|
54
54
|
SecondaryTradeFiltersZod,
|
|
55
55
|
} from './secondary-trade.types';
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
|
|
57
|
+
// Stub types for backend entities (not included in contracts package)
|
|
58
|
+
type InvestorAccount = Record<string, unknown>;
|
|
59
|
+
type Trade = Record<string, unknown>;
|
|
58
60
|
|
|
59
61
|
extendZodWithOpenApi(z);
|
|
60
62
|
export const CheckResultsSchema = z.object({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { validateCanadaZipCode, validateUSZipCode } from '
|
|
2
|
+
import { validateCanadaZipCode, validateUSZipCode } from './contract-helpers';
|
|
3
3
|
import { CountryCode, CountryEnumSchema } from './countries.types';
|
|
4
4
|
|
|
5
5
|
export function refineAddressZip(
|