1- import { ZodError , type ZodSchema , z } from "zod" ;
1+ import { ZodError , type ZodSchema } from "zod" ;
2+
3+ // Import and re-export all schemas
4+ export * from "./schemas/access-token" ;
5+ export * from "./schemas/application" ;
6+ export * from "./schemas/base-platform" ;
7+ export * from "./schemas/blockchain-network" ;
8+ export * from "./schemas/blockchain-node" ;
9+ export * from "./schemas/custom-deployment" ;
10+ export * from "./schemas/ethereum" ;
11+ export * from "./schemas/insights" ;
12+ export * from "./schemas/integration-tool" ;
13+ export * from "./schemas/middleware" ;
14+ export * from "./schemas/private-key" ;
15+ export * from "./schemas/search-key" ;
16+ export * from "./schemas/service-type" ;
17+ export * from "./schemas/settlemint-client-env" ;
18+ export * from "./schemas/storage" ;
19+ export * from "./schemas/unique-name" ;
20+ export * from "./schemas/url" ;
21+ export * from "./schemas/workspace" ;
22+ export * from "./schemas/ws-appl-platform" ;
223
3- /**
4- * Validates the given value against the provided Zod schema.
5- * @param schema The Zod schema to validate against.
6- * @param value The value to validate.
7- * @returns The validated and parsed data if successful.
8- * @throws {Error } If validation fails, with a formatted error message.
9- */
1024export function validate < T extends ZodSchema > ( schema : T , value : unknown ) : T [ "_output" ] {
1125 try {
1226 return schema . parse ( value ) ;
@@ -18,208 +32,3 @@ export function validate<T extends ZodSchema>(schema: T, value: unknown): T["_ou
1832 throw error ; // Re-throw if it's not a ZodError
1933 }
2034}
21-
22- export const AccessTokenSchema = z . string ( ) . regex ( / ^ b t p _ p a t _ .* | b t p _ a a t _ .* $ / ) ;
23-
24- export const UniqueNameSchema = z . string ( ) . regex ( / ^ [ a - z - ] + - [ a - z 0 - 9 ] { 5 } $ / ) ;
25- export type UniqueName = z . infer < typeof UniqueNameSchema > ;
26-
27- export const SearchKeySchema = z . string ( ) . regex ( / ^ [ a - z 0 - 9 ] { 5 } $ / ) ;
28-
29- export const UrlSchema = z . string ( ) . url ( ) ;
30-
31- export const ServiceTypeSchema = z . enum ( [
32- "workspace" ,
33- "application" ,
34- "blockchain-network" ,
35- "blockchain-node" ,
36- "smart-contract-set" ,
37- "middleware" ,
38- "integration-tool" ,
39- "storage" ,
40- "private-key" ,
41- "insights" ,
42- "custom-deployment" ,
43- ] ) ;
44- export type ServiceType = z . infer < typeof ServiceTypeSchema > ;
45-
46- export const EthereumAddressSchema = z . string ( ) . regex ( / ^ 0 x [ a - f A - F 0 - 9 ] { 40 } $ / ) ;
47-
48- export const EthereumPublicKeySchema = z . string ( ) . regex ( / ^ 0 x [ a - f A - F 0 - 9 ] { 64 } $ / ) ;
49-
50- export const SettleMintClientEnvSchema = z . object ( {
51- SETTLEMINT_ACCESS_TOKEN : AccessTokenSchema ,
52- SETTLEMINT_INSTANCE : UrlSchema ,
53- SETTLEMINT_DEFAULT_BLOCKCHAIN_NETWORK : UniqueNameSchema . optional ( ) ,
54- SETTLEMINT_DEFAULT_BLOCKCHAIN_NODE : UniqueNameSchema . optional ( ) ,
55- SETTLEMINT_DEFAULT_STORAGE : UniqueNameSchema . optional ( ) ,
56- SETTLEMINT_DEFAULT_PRIVATE_KEY : UniqueNameSchema . optional ( ) ,
57- SETTLEMINT_DEFAULT_INTEGRATION_TOOL : UniqueNameSchema . optional ( ) ,
58- SETTLEMINT_DEFAULT_MIDDLEWARE : UniqueNameSchema . optional ( ) ,
59- SETTLEMINT_DEFAULT_CUSTOM_DEPLOYMENT : UniqueNameSchema . optional ( ) ,
60- SETTLEMINT_DEFAULT_INSIGHTS : UniqueNameSchema . optional ( ) ,
61- SETTLEMINT_DEFAULT_WORKSPACE : UniqueNameSchema . optional ( ) ,
62- SETTLEMINT_DEFAULT_APPLICATION : UniqueNameSchema . optional ( ) ,
63- } ) ;
64-
65- const BasePlatformReturnValueSchema = z . object ( {
66- uniqueName : UniqueNameSchema ,
67- displayName : z . string ( ) ,
68- } ) ;
69-
70- export const WorkspaceReturnValueSchema = BasePlatformReturnValueSchema . extend ( { } ) ;
71- export type WorkspaceReturnValue = z . infer < typeof WorkspaceReturnValueSchema > ;
72-
73- export const ApplicationReturnValueSchema = BasePlatformReturnValueSchema . extend ( {
74- workspace : UniqueNameSchema ,
75- } ) ;
76- export type ApplicationReturnValue = z . infer < typeof ApplicationReturnValueSchema > ;
77-
78- const WsApplPlatformReturnValueSchema = BasePlatformReturnValueSchema . extend ( {
79- workspace : UniqueNameSchema ,
80- application : UniqueNameSchema ,
81- } ) ;
82-
83- export const BlockchainNetworkReturnValueSchema = WsApplPlatformReturnValueSchema . extend ( {
84- serviceSubType : z . string ( ) ,
85- chainId : z . string ( ) ,
86- } ) ;
87- export type BlockchainNetworkReturnValue = z . infer < typeof BlockchainNetworkReturnValueSchema > ;
88-
89- export const BlockchainNodeReturnValueSchema = WsApplPlatformReturnValueSchema . extend ( {
90- serviceSubType : z . string ( ) ,
91- network : UniqueNameSchema ,
92- endpoints : z . object ( {
93- base : UrlSchema ,
94- jsonRpc : UrlSchema ,
95- jsonWs : UrlSchema ,
96- graphQl : UrlSchema ,
97- } ) ,
98- } ) ;
99- export type BlockchainNodeReturnValue = z . infer < typeof BlockchainNodeReturnValueSchema > ;
100-
101- const BaseMiddlewareSchema = WsApplPlatformReturnValueSchema . extend ( {
102- serviceSubType : z . string ( ) ,
103- endpoints : z . object ( {
104- base : UrlSchema ,
105- } ) ,
106- } ) ;
107-
108- const PortalMiddlewareSchema = BaseMiddlewareSchema . extend ( {
109- serviceSubType : z . literal ( "SMART_CONTRACT_PORTAL" ) ,
110- endpoints : z . object ( {
111- base : UrlSchema ,
112- jsonRpc : UrlSchema ,
113- jsonWs : UrlSchema ,
114- graphQl : UrlSchema ,
115- } ) ,
116- } ) ;
117-
118- const TheGraphMiddlewareSchema = BaseMiddlewareSchema . extend ( {
119- serviceSubType : z . literal ( "HA_GRAPH" ) ,
120- endpoints : z . object ( {
121- base : UrlSchema ,
122- subgraph : UrlSchema ,
123- defaultSubgraph : UrlSchema ,
124- } ) ,
125- } ) ;
126-
127- export const MiddlewareReturnValueSchema = z . union ( [
128- PortalMiddlewareSchema ,
129- TheGraphMiddlewareSchema ,
130- BaseMiddlewareSchema ,
131- ] ) ;
132-
133- export type MiddlewareReturnValue = z . infer < typeof MiddlewareReturnValueSchema > ;
134-
135- const BaseIntegrationToolSchema = WsApplPlatformReturnValueSchema . extend ( {
136- serviceSubType : z . string ( ) ,
137- endpoints : z . object ( {
138- base : UrlSchema ,
139- } ) ,
140- } ) ;
141-
142- const HasuraIntegrationToolSchema = BaseIntegrationToolSchema . extend ( {
143- serviceSubType : z . literal ( "HASURA" ) ,
144- endpoints : z . object ( {
145- base : UrlSchema ,
146- graphQl : UrlSchema ,
147- } ) ,
148- secrets : z . object ( {
149- adminSecret : z . string ( ) ,
150- } ) ,
151- } ) ;
152-
153- export const IntegrationToolReturnValueSchema = z . union ( [ HasuraIntegrationToolSchema , BaseIntegrationToolSchema ] ) ;
154- export type IntegrationToolReturnValue = z . infer < typeof IntegrationToolReturnValueSchema > ;
155-
156- const BaseStorageSchema = WsApplPlatformReturnValueSchema . extend ( {
157- serviceSubType : z . string ( ) ,
158- endpoints : z . object ( {
159- base : UrlSchema ,
160- } ) ,
161- } ) ;
162-
163- const IpfsStorageSchema = BaseStorageSchema . extend ( {
164- serviceSubType : z . literal ( "IPFS" ) ,
165- endpoints : z . object ( {
166- base : UrlSchema ,
167- api : UrlSchema ,
168- gateway : UrlSchema ,
169- clusterApi : UrlSchema ,
170- pinning : UrlSchema ,
171- } ) ,
172- secrets : z . object ( {
173- password : z . string ( ) ,
174- } ) ,
175- } ) ;
176-
177- const MinioStorageSchema = BaseStorageSchema . extend ( {
178- serviceSubType : z . literal ( "MINIO" ) ,
179- endpoints : z . object ( {
180- base : UrlSchema ,
181- s3Api : UrlSchema ,
182- } ) ,
183- secrets : z . object ( {
184- accessKey : z . string ( ) ,
185- secretKey : z . string ( ) ,
186- } ) ,
187- } ) ;
188-
189- export const StorageReturnValueSchema = z . union ( [ IpfsStorageSchema , MinioStorageSchema , BaseStorageSchema ] ) ;
190- export type StorageReturnValue = z . infer < typeof StorageReturnValueSchema > ;
191-
192- const BasePrivateKeySchema = WsApplPlatformReturnValueSchema . extend ( {
193- serviceSubType : z . string ( ) ,
194- } ) ;
195-
196- const HdPrivateKeySchema = BasePrivateKeySchema . extend ( {
197- serviceSubType : z . literal ( "HD_ECDSA_P256" ) ,
198- } ) ;
199-
200- const EcdsaPrivateKeySchema = BasePrivateKeySchema . extend ( {
201- serviceSubType : z . literal ( "MINIO" ) ,
202- address : EthereumAddressSchema ,
203- publicKey : EthereumPublicKeySchema ,
204- } ) ;
205-
206- export const PrivateKeyReturnValueSchema = z . union ( [ HdPrivateKeySchema , EcdsaPrivateKeySchema , BasePrivateKeySchema ] ) ;
207- export type PrivateKeyReturnValue = z . infer < typeof PrivateKeyReturnValueSchema > ;
208-
209- export const InsightsReturnValueSchema = WsApplPlatformReturnValueSchema . extend ( {
210- serviceSubType : z . string ( ) ,
211- protocol : z . string ( ) ,
212- endpoints : z . object ( {
213- base : UrlSchema ,
214- } ) ,
215- } ) ;
216- export type InsightsReturnValue = z . infer < typeof InsightsReturnValueSchema > ;
217-
218- export const CustomDeploymentReturnValueSchema = WsApplPlatformReturnValueSchema . extend ( {
219- serviceSubType : z . string ( ) ,
220- protocol : z . string ( ) ,
221- endpoints : z . object ( {
222- base : UrlSchema ,
223- } ) ,
224- } ) ;
225- export type CustomDeploymentReturnValue = z . infer < typeof CustomDeploymentReturnValueSchema > ;
0 commit comments