-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathregistry-config.zod.ts
More file actions
179 lines (156 loc) · 4.5 KB
/
registry-config.zod.ts
File metadata and controls
179 lines (156 loc) · 4.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
import { z } from 'zod';
/**
* # Registry Configuration Protocol
*
* Defines the configuration for the ObjectStack Registry Service.
* Includes federation, synchronization, and storage settings.
*/
/**
* Registry Sync Policy
* Defines how registries synchronize with upstreams
*/
export const RegistrySyncPolicySchema = z.enum([
'manual', // Manual synchronization only
'auto', // Automatic synchronization
'proxy', // Proxy requests to upstream without caching
]).describe('Registry synchronization strategy');
/**
* Registry Upstream Configuration
* Configuration for upstream registry connection
*/
export const RegistryUpstreamSchema = z.object({
/**
* Upstream registry URL
*/
url: z.string().url()
.describe('Upstream registry endpoint'),
/**
* Synchronization policy
*/
syncPolicy: RegistrySyncPolicySchema.default('auto'),
/**
* Sync interval in seconds (for auto sync)
*/
syncInterval: z.number().int().min(60).optional()
.describe('Auto-sync interval in seconds'),
/**
* Authentication credentials
*/
auth: z.object({
type: z.enum(['none', 'basic', 'bearer', 'api-key', 'oauth2']).default('none'),
username: z.string().optional(),
password: z.string().optional(),
token: z.string().optional(),
apiKey: z.string().optional(),
}).optional(),
/**
* TLS/SSL configuration
*/
tls: z.object({
enabled: z.boolean().default(true),
verifyCertificate: z.boolean().default(true),
certificate: z.string().optional(),
privateKey: z.string().optional(),
}).optional(),
/**
* Timeout settings
*/
timeout: z.number().int().min(1000).default(30000)
.describe('Request timeout in milliseconds'),
/**
* Retry configuration
*/
retry: z.object({
maxAttempts: z.number().int().min(0).default(3),
backoff: z.enum(['fixed', 'linear', 'exponential']).default('exponential'),
}).optional(),
});
/**
* Registry Configuration
* Complete registry configuration supporting federation
*/
export const RegistryConfigSchema = z.object({
/**
* Registry type
*/
type: z.enum([
'public', // Public marketplace (e.g., plugins.objectstack.com)
'private', // Private enterprise registry
'hybrid', // Hybrid with upstream federation
]).describe('Registry deployment type'),
/**
* Upstream registries (for hybrid/private registries)
*/
upstream: z.array(RegistryUpstreamSchema).optional()
.describe('Upstream registries to sync from or proxy to'),
/**
* Scopes managed by this registry
*/
scope: z.array(z.string()).optional()
.describe('npm-style scopes managed by this registry (e.g., @my-corp, @enterprise)'),
/**
* Default scope for new plugins
*/
defaultScope: z.string().optional()
.describe('Default scope prefix for new plugins'),
/**
* Registry storage configuration
*/
storage: z.object({
/**
* Storage backend type
*/
backend: z.enum(['local', 's3', 'gcs', 'azure-blob', 'oss']).default('local'),
/**
* Storage path or bucket name
*/
path: z.string().optional(),
/**
* Credentials
*/
credentials: z.record(z.string(), z.unknown()).optional(),
}).optional(),
/**
* Registry visibility
*/
visibility: z.enum(['public', 'private', 'internal']).default('private')
.describe('Who can access this registry'),
/**
* Access control
*/
accessControl: z.object({
/**
* Require authentication for read
*/
requireAuthForRead: z.boolean().default(false),
/**
* Require authentication for write
*/
requireAuthForWrite: z.boolean().default(true),
/**
* Allowed users/teams
*/
allowedPrincipals: z.array(z.string()).optional(),
}).optional(),
/**
* Caching configuration
*/
cache: z.object({
enabled: z.boolean().default(true),
ttl: z.number().int().min(0).default(3600)
.describe('Cache TTL in seconds'),
maxSize: z.number().int().optional()
.describe('Maximum cache size in bytes'),
}).optional(),
/**
* Mirroring configuration (for high availability)
*/
mirrors: z.array(z.object({
url: z.string().url(),
priority: z.number().int().min(1).default(1),
})).optional()
.describe('Mirror registries for redundancy'),
});
export type RegistrySyncPolicy = z.infer<typeof RegistrySyncPolicySchema>;
export type RegistryUpstream = z.infer<typeof RegistryUpstreamSchema>;
export type RegistryConfig = z.infer<typeof RegistryConfigSchema>;