@secretenvs/contracts 0.0.0-stage → 1.1.0

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.
@@ -0,0 +1,405 @@
1
+ import { z } from 'zod';
2
+
3
+ declare const VARIABLE_KEY_REGEX: RegExp;
4
+ declare const SLUG_REGEX: RegExp;
5
+ declare const MAX_KEY_LENGTH = 128;
6
+ declare const MAX_VALUE_BYTES: number;
7
+ declare const MAX_NAME_LENGTH = 64;
8
+ declare const MAX_BULK_VARIABLES = 500;
9
+ declare const MIN_PASSWORD_LENGTH = 12;
10
+ declare const MAX_PASSWORD_LENGTH = 256;
11
+ declare const DEFAULT_VERSIONS_LIMIT = 20;
12
+ declare const MAX_VERSIONS_LIMIT = 100;
13
+ declare const CSRF_HEADER_NAME = "x-requested-with";
14
+ declare const CSRF_HEADER_VALUE = "secretenvs-web";
15
+ declare const TOKEN_PREFIX = "svt_";
16
+
17
+ declare const ProjectRole: z.ZodEnum<{
18
+ OWNER: "OWNER";
19
+ ADMIN: "ADMIN";
20
+ EDITOR: "EDITOR";
21
+ VIEWER: "VIEWER";
22
+ }>;
23
+ type ProjectRole = z.infer<typeof ProjectRole>;
24
+ declare const TokenAccess: z.ZodEnum<{
25
+ READ: "READ";
26
+ READ_WRITE: "READ_WRITE";
27
+ }>;
28
+ type TokenAccess = z.infer<typeof TokenAccess>;
29
+ declare const VersionChangeType: z.ZodEnum<{
30
+ CREATED: "CREATED";
31
+ UPDATED: "UPDATED";
32
+ ROLLBACK: "ROLLBACK";
33
+ }>;
34
+ type VersionChangeType = z.infer<typeof VersionChangeType>;
35
+ declare const ErrorCode: z.ZodEnum<{
36
+ VALIDATION_ERROR: "VALIDATION_ERROR";
37
+ BAD_REQUEST: "BAD_REQUEST";
38
+ UNAUTHENTICATED: "UNAUTHENTICATED";
39
+ FORBIDDEN: "FORBIDDEN";
40
+ NOT_FOUND: "NOT_FOUND";
41
+ CONFLICT: "CONFLICT";
42
+ RATE_LIMITED: "RATE_LIMITED";
43
+ INTERNAL: "INTERNAL";
44
+ }>;
45
+ type ErrorCode = z.infer<typeof ErrorCode>;
46
+
47
+ declare const RegisterInput: z.ZodObject<{
48
+ email: z.ZodPipe<z.ZodString, z.ZodEmail>;
49
+ name: z.ZodString;
50
+ password: z.ZodString;
51
+ }, z.core.$strict>;
52
+ type RegisterInput = z.infer<typeof RegisterInput>;
53
+ declare const LoginInput: z.ZodObject<{
54
+ email: z.ZodPipe<z.ZodString, z.ZodEmail>;
55
+ password: z.ZodString;
56
+ }, z.core.$strict>;
57
+ type LoginInput = z.infer<typeof LoginInput>;
58
+ declare const UserDto: z.ZodObject<{
59
+ id: z.ZodUUID;
60
+ email: z.ZodPipe<z.ZodString, z.ZodEmail>;
61
+ name: z.ZodString;
62
+ createdAt: z.ZodISODateTime;
63
+ }, z.core.$strict>;
64
+ type UserDto = z.infer<typeof UserDto>;
65
+ declare const CreateProjectInput: z.ZodObject<{
66
+ name: z.ZodString;
67
+ slug: z.ZodString;
68
+ description: z.ZodOptional<z.ZodString>;
69
+ }, z.core.$strict>;
70
+ type CreateProjectInput = z.infer<typeof CreateProjectInput>;
71
+ declare const UpdateProjectInput: z.ZodObject<{
72
+ name: z.ZodOptional<z.ZodString>;
73
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
74
+ }, z.core.$strict>;
75
+ type UpdateProjectInput = z.infer<typeof UpdateProjectInput>;
76
+ declare const ProjectDto: z.ZodObject<{
77
+ id: z.ZodUUID;
78
+ name: z.ZodString;
79
+ slug: z.ZodString;
80
+ description: z.ZodNullable<z.ZodString>;
81
+ createdAt: z.ZodISODateTime;
82
+ updatedAt: z.ZodISODateTime;
83
+ }, z.core.$strict>;
84
+ type ProjectDto = z.infer<typeof ProjectDto>;
85
+ declare const ProjectSummaryDto: z.ZodObject<{
86
+ id: z.ZodUUID;
87
+ name: z.ZodString;
88
+ slug: z.ZodString;
89
+ description: z.ZodNullable<z.ZodString>;
90
+ createdAt: z.ZodISODateTime;
91
+ updatedAt: z.ZodISODateTime;
92
+ role: z.ZodEnum<{
93
+ OWNER: "OWNER";
94
+ ADMIN: "ADMIN";
95
+ EDITOR: "EDITOR";
96
+ VIEWER: "VIEWER";
97
+ }>;
98
+ }, z.core.$strict>;
99
+ type ProjectSummaryDto = z.infer<typeof ProjectSummaryDto>;
100
+ declare const AddMemberInput: z.ZodObject<{
101
+ email: z.ZodPipe<z.ZodString, z.ZodEmail>;
102
+ role: z.ZodEnum<{
103
+ OWNER: "OWNER";
104
+ ADMIN: "ADMIN";
105
+ EDITOR: "EDITOR";
106
+ VIEWER: "VIEWER";
107
+ }>;
108
+ }, z.core.$strict>;
109
+ type AddMemberInput = z.infer<typeof AddMemberInput>;
110
+ declare const UpdateMemberInput: z.ZodObject<{
111
+ role: z.ZodEnum<{
112
+ OWNER: "OWNER";
113
+ ADMIN: "ADMIN";
114
+ EDITOR: "EDITOR";
115
+ VIEWER: "VIEWER";
116
+ }>;
117
+ }, z.core.$strict>;
118
+ type UpdateMemberInput = z.infer<typeof UpdateMemberInput>;
119
+ declare const MemberDto: z.ZodObject<{
120
+ userId: z.ZodUUID;
121
+ email: z.ZodPipe<z.ZodString, z.ZodEmail>;
122
+ name: z.ZodString;
123
+ role: z.ZodEnum<{
124
+ OWNER: "OWNER";
125
+ ADMIN: "ADMIN";
126
+ EDITOR: "EDITOR";
127
+ VIEWER: "VIEWER";
128
+ }>;
129
+ createdAt: z.ZodISODateTime;
130
+ }, z.core.$strict>;
131
+ type MemberDto = z.infer<typeof MemberDto>;
132
+ declare const CreateEnvironmentInput: z.ZodObject<{
133
+ name: z.ZodString;
134
+ slug: z.ZodString;
135
+ }, z.core.$strict>;
136
+ type CreateEnvironmentInput = z.infer<typeof CreateEnvironmentInput>;
137
+ declare const UpdateEnvironmentInput: z.ZodObject<{
138
+ name: z.ZodOptional<z.ZodString>;
139
+ slug: z.ZodOptional<z.ZodString>;
140
+ }, z.core.$strict>;
141
+ type UpdateEnvironmentInput = z.infer<typeof UpdateEnvironmentInput>;
142
+ declare const EnvironmentDto: z.ZodObject<{
143
+ id: z.ZodUUID;
144
+ projectId: z.ZodUUID;
145
+ name: z.ZodString;
146
+ slug: z.ZodString;
147
+ createdAt: z.ZodISODateTime;
148
+ updatedAt: z.ZodISODateTime;
149
+ }, z.core.$strict>;
150
+ type EnvironmentDto = z.infer<typeof EnvironmentDto>;
151
+ declare const CreateVariableInput: z.ZodObject<{
152
+ key: z.ZodString;
153
+ value: z.ZodString;
154
+ }, z.core.$strict>;
155
+ type CreateVariableInput = z.infer<typeof CreateVariableInput>;
156
+ declare const UpdateVariableInput: z.ZodObject<{
157
+ value: z.ZodString;
158
+ }, z.core.$strict>;
159
+ type UpdateVariableInput = z.infer<typeof UpdateVariableInput>;
160
+ declare const VariableMetaDto: z.ZodObject<{
161
+ id: z.ZodUUID;
162
+ key: z.ZodString;
163
+ currentVersion: z.ZodNumber;
164
+ updatedAt: z.ZodISODateTime;
165
+ }, z.core.$strict>;
166
+ type VariableMetaDto = z.infer<typeof VariableMetaDto>;
167
+ declare const VariableWithValueDto: z.ZodObject<{
168
+ id: z.ZodUUID;
169
+ key: z.ZodString;
170
+ currentVersion: z.ZodNumber;
171
+ updatedAt: z.ZodISODateTime;
172
+ value: z.ZodString;
173
+ }, z.core.$strict>;
174
+ type VariableWithValueDto = z.infer<typeof VariableWithValueDto>;
175
+ declare const BulkUpsertVariablesInput: z.ZodObject<{
176
+ variables: z.ZodArray<z.ZodObject<{
177
+ key: z.ZodString;
178
+ value: z.ZodString;
179
+ }, z.core.$strict>>;
180
+ }, z.core.$strict>;
181
+ type BulkUpsertVariablesInput = z.infer<typeof BulkUpsertVariablesInput>;
182
+ declare const BulkUpsertVariablesResponse: z.ZodObject<{
183
+ created: z.ZodNumber;
184
+ updated: z.ZodNumber;
185
+ unchanged: z.ZodNumber;
186
+ }, z.core.$strict>;
187
+ type BulkUpsertVariablesResponse = z.infer<typeof BulkUpsertVariablesResponse>;
188
+ declare const CreateSharedVariableInput: z.ZodObject<{
189
+ key: z.ZodString;
190
+ value: z.ZodString;
191
+ environmentIds: z.ZodArray<z.ZodUUID>;
192
+ }, z.core.$strict>;
193
+ type CreateSharedVariableInput = z.infer<typeof CreateSharedVariableInput>;
194
+ declare const UpdateSharedVariableInput: z.ZodObject<{
195
+ value: z.ZodOptional<z.ZodString>;
196
+ environmentIds: z.ZodOptional<z.ZodArray<z.ZodUUID>>;
197
+ }, z.core.$strict>;
198
+ type UpdateSharedVariableInput = z.infer<typeof UpdateSharedVariableInput>;
199
+ declare const SharedVariableMetaDto: z.ZodObject<{
200
+ id: z.ZodUUID;
201
+ key: z.ZodString;
202
+ currentVersion: z.ZodNumber;
203
+ updatedAt: z.ZodISODateTime;
204
+ environmentIds: z.ZodArray<z.ZodUUID>;
205
+ }, z.core.$strict>;
206
+ type SharedVariableMetaDto = z.infer<typeof SharedVariableMetaDto>;
207
+ declare const ListVersionsQuery: z.ZodObject<{
208
+ cursor: z.ZodOptional<z.ZodString>;
209
+ limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
210
+ }, z.core.$strict>;
211
+ type ListVersionsQuery = z.infer<typeof ListVersionsQuery>;
212
+ declare const VariableVersionMetaDto: z.ZodObject<{
213
+ version: z.ZodNumber;
214
+ changeType: z.ZodEnum<{
215
+ CREATED: "CREATED";
216
+ UPDATED: "UPDATED";
217
+ ROLLBACK: "ROLLBACK";
218
+ }>;
219
+ restoredFromVersion: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
220
+ changedBy: z.ZodNullable<z.ZodObject<{
221
+ id: z.ZodUUID;
222
+ name: z.ZodString;
223
+ }, z.core.$strict>>;
224
+ createdAt: z.ZodISODateTime;
225
+ isCurrent: z.ZodBoolean;
226
+ }, z.core.$strict>;
227
+ type VariableVersionMetaDto = z.infer<typeof VariableVersionMetaDto>;
228
+ declare const PaginatedVersionsResponse: z.ZodObject<{
229
+ items: z.ZodArray<z.ZodObject<{
230
+ version: z.ZodNumber;
231
+ changeType: z.ZodEnum<{
232
+ CREATED: "CREATED";
233
+ UPDATED: "UPDATED";
234
+ ROLLBACK: "ROLLBACK";
235
+ }>;
236
+ restoredFromVersion: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
237
+ changedBy: z.ZodNullable<z.ZodObject<{
238
+ id: z.ZodUUID;
239
+ name: z.ZodString;
240
+ }, z.core.$strict>>;
241
+ createdAt: z.ZodISODateTime;
242
+ isCurrent: z.ZodBoolean;
243
+ }, z.core.$strict>>;
244
+ nextCursor: z.ZodOptional<z.ZodString>;
245
+ }, z.core.$strict>;
246
+ type PaginatedVersionsResponse = z.infer<typeof PaginatedVersionsResponse>;
247
+ declare const VariableVersionValueDto: z.ZodObject<{
248
+ version: z.ZodNumber;
249
+ value: z.ZodString;
250
+ }, z.core.$strict>;
251
+ type VariableVersionValueDto = z.infer<typeof VariableVersionValueDto>;
252
+ declare const ResolvedVariableDto: z.ZodObject<{
253
+ key: z.ZodString;
254
+ value: z.ZodString;
255
+ source: z.ZodEnum<{
256
+ environment: "environment";
257
+ shared: "shared";
258
+ }>;
259
+ }, z.core.$strict>;
260
+ type ResolvedVariableDto = z.infer<typeof ResolvedVariableDto>;
261
+ declare const ResolvedVariablesResponse: z.ZodObject<{
262
+ project: z.ZodObject<{
263
+ id: z.ZodUUID;
264
+ slug: z.ZodString;
265
+ }, z.core.$strict>;
266
+ environment: z.ZodObject<{
267
+ id: z.ZodUUID;
268
+ slug: z.ZodString;
269
+ }, z.core.$strict>;
270
+ variables: z.ZodArray<z.ZodObject<{
271
+ key: z.ZodString;
272
+ value: z.ZodString;
273
+ source: z.ZodEnum<{
274
+ environment: "environment";
275
+ shared: "shared";
276
+ }>;
277
+ }, z.core.$strict>>;
278
+ }, z.core.$strict>;
279
+ type ResolvedVariablesResponse = z.infer<typeof ResolvedVariablesResponse>;
280
+ declare const SdkEnvironmentDto: z.ZodObject<{
281
+ id: z.ZodUUID;
282
+ slug: z.ZodString;
283
+ name: z.ZodString;
284
+ }, z.core.$strict>;
285
+ type SdkEnvironmentDto = z.infer<typeof SdkEnvironmentDto>;
286
+ declare const SdkProjectDto: z.ZodObject<{
287
+ id: z.ZodUUID;
288
+ slug: z.ZodString;
289
+ name: z.ZodString;
290
+ role: z.ZodEnum<{
291
+ OWNER: "OWNER";
292
+ ADMIN: "ADMIN";
293
+ EDITOR: "EDITOR";
294
+ VIEWER: "VIEWER";
295
+ }>;
296
+ environments: z.ZodArray<z.ZodObject<{
297
+ id: z.ZodUUID;
298
+ slug: z.ZodString;
299
+ name: z.ZodString;
300
+ }, z.core.$strict>>;
301
+ }, z.core.$strict>;
302
+ type SdkProjectDto = z.infer<typeof SdkProjectDto>;
303
+ declare const CreateTokenInput: z.ZodObject<{
304
+ name: z.ZodString;
305
+ access: z.ZodEnum<{
306
+ READ: "READ";
307
+ READ_WRITE: "READ_WRITE";
308
+ }>;
309
+ projectId: z.ZodOptional<z.ZodUUID>;
310
+ environmentId: z.ZodOptional<z.ZodUUID>;
311
+ expiresInDays: z.ZodOptional<z.ZodNumber>;
312
+ }, z.core.$strict>;
313
+ type CreateTokenInput = z.infer<typeof CreateTokenInput>;
314
+ declare const TokenDto: z.ZodObject<{
315
+ id: z.ZodUUID;
316
+ name: z.ZodString;
317
+ prefix: z.ZodString;
318
+ access: z.ZodEnum<{
319
+ READ: "READ";
320
+ READ_WRITE: "READ_WRITE";
321
+ }>;
322
+ projectId: z.ZodNullable<z.ZodUUID>;
323
+ environmentId: z.ZodNullable<z.ZodUUID>;
324
+ expiresAt: z.ZodNullable<z.ZodISODateTime>;
325
+ revokedAt: z.ZodNullable<z.ZodISODateTime>;
326
+ lastUsedAt: z.ZodNullable<z.ZodISODateTime>;
327
+ createdAt: z.ZodISODateTime;
328
+ }, z.core.$strict>;
329
+ type TokenDto = z.infer<typeof TokenDto>;
330
+ declare const CreatedTokenDto: z.ZodObject<{
331
+ id: z.ZodUUID;
332
+ name: z.ZodString;
333
+ prefix: z.ZodString;
334
+ access: z.ZodEnum<{
335
+ READ: "READ";
336
+ READ_WRITE: "READ_WRITE";
337
+ }>;
338
+ projectId: z.ZodNullable<z.ZodUUID>;
339
+ environmentId: z.ZodNullable<z.ZodUUID>;
340
+ expiresAt: z.ZodNullable<z.ZodISODateTime>;
341
+ revokedAt: z.ZodNullable<z.ZodISODateTime>;
342
+ lastUsedAt: z.ZodNullable<z.ZodISODateTime>;
343
+ createdAt: z.ZodISODateTime;
344
+ token: z.ZodString;
345
+ }, z.core.$strict>;
346
+ type CreatedTokenDto = z.infer<typeof CreatedTokenDto>;
347
+ declare const ApiErrorBody: z.ZodObject<{
348
+ error: z.ZodObject<{
349
+ code: z.ZodEnum<{
350
+ VALIDATION_ERROR: "VALIDATION_ERROR";
351
+ BAD_REQUEST: "BAD_REQUEST";
352
+ UNAUTHENTICATED: "UNAUTHENTICATED";
353
+ FORBIDDEN: "FORBIDDEN";
354
+ NOT_FOUND: "NOT_FOUND";
355
+ CONFLICT: "CONFLICT";
356
+ RATE_LIMITED: "RATE_LIMITED";
357
+ INTERNAL: "INTERNAL";
358
+ }>;
359
+ message: z.ZodString;
360
+ details: z.ZodOptional<z.ZodUnknown>;
361
+ }, z.core.$strict>;
362
+ }, z.core.$strict>;
363
+ type ApiErrorBody = z.infer<typeof ApiErrorBody>;
364
+
365
+ declare const apiEnvironmentSchema: z.ZodPipe<z.ZodObject<{
366
+ NODE_ENV: z.ZodEnum<{
367
+ development: "development";
368
+ test: "test";
369
+ production: "production";
370
+ }>;
371
+ HOST: z.ZodDefault<z.ZodString>;
372
+ PORT: z.ZodCoercedNumber<unknown>;
373
+ WEB_ORIGIN: z.ZodURL;
374
+ DATABASE_URL: z.ZodURL;
375
+ MASTER_KEY: z.ZodString;
376
+ COOKIE_SECURE: z.ZodOptional<z.ZodEnum<{
377
+ true: "true";
378
+ false: "false";
379
+ }>>;
380
+ VARIABLE_HISTORY_LIMIT: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
381
+ TRUST_PROXY: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
382
+ }, z.core.$strict>, z.ZodTransform<{
383
+ COOKIE_SECURE: boolean;
384
+ NODE_ENV: "development" | "test" | "production";
385
+ HOST: string;
386
+ PORT: number;
387
+ WEB_ORIGIN: string;
388
+ DATABASE_URL: string;
389
+ MASTER_KEY: string;
390
+ VARIABLE_HISTORY_LIMIT: number;
391
+ TRUST_PROXY: number;
392
+ }, {
393
+ NODE_ENV: "development" | "test" | "production";
394
+ HOST: string;
395
+ PORT: number;
396
+ WEB_ORIGIN: string;
397
+ DATABASE_URL: string;
398
+ MASTER_KEY: string;
399
+ VARIABLE_HISTORY_LIMIT: number;
400
+ TRUST_PROXY: number;
401
+ COOKIE_SECURE?: "true" | "false" | undefined;
402
+ }>>;
403
+ type ApiEnvironment = z.infer<typeof apiEnvironmentSchema>;
404
+
405
+ export { AddMemberInput, type ApiEnvironment, ApiErrorBody, BulkUpsertVariablesInput, BulkUpsertVariablesResponse, CSRF_HEADER_NAME, CSRF_HEADER_VALUE, CreateEnvironmentInput, CreateProjectInput, CreateSharedVariableInput, CreateTokenInput, CreateVariableInput, CreatedTokenDto, DEFAULT_VERSIONS_LIMIT, EnvironmentDto, ErrorCode, ListVersionsQuery, LoginInput, MAX_BULK_VARIABLES, MAX_KEY_LENGTH, MAX_NAME_LENGTH, MAX_PASSWORD_LENGTH, MAX_VALUE_BYTES, MAX_VERSIONS_LIMIT, MIN_PASSWORD_LENGTH, MemberDto, PaginatedVersionsResponse, ProjectDto, ProjectRole, ProjectSummaryDto, RegisterInput, ResolvedVariableDto, ResolvedVariablesResponse, SLUG_REGEX, SdkEnvironmentDto, SdkProjectDto, SharedVariableMetaDto, TOKEN_PREFIX, TokenAccess, TokenDto, UpdateEnvironmentInput, UpdateMemberInput, UpdateProjectInput, UpdateSharedVariableInput, UpdateVariableInput, UserDto, VARIABLE_KEY_REGEX, VariableMetaDto, VariableVersionMetaDto, VariableVersionValueDto, VariableWithValueDto, VersionChangeType, apiEnvironmentSchema };
package/dist/index.js ADDED
@@ -0,0 +1,258 @@
1
+ // src/index.ts
2
+ import { z as z3 } from "zod";
3
+
4
+ // src/constants.ts
5
+ var VARIABLE_KEY_REGEX = /^[A-Z_][A-Z0-9_]*$/;
6
+ var SLUG_REGEX = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
7
+ var MAX_KEY_LENGTH = 128;
8
+ var MAX_VALUE_BYTES = 64 * 1024;
9
+ var MAX_NAME_LENGTH = 64;
10
+ var MAX_BULK_VARIABLES = 500;
11
+ var MIN_PASSWORD_LENGTH = 12;
12
+ var MAX_PASSWORD_LENGTH = 256;
13
+ var DEFAULT_VERSIONS_LIMIT = 20;
14
+ var MAX_VERSIONS_LIMIT = 100;
15
+ var CSRF_HEADER_NAME = "x-requested-with";
16
+ var CSRF_HEADER_VALUE = "secretenvs-web";
17
+ var TOKEN_PREFIX = "svt_";
18
+
19
+ // src/enums.ts
20
+ import { z } from "zod";
21
+ var ProjectRole = z.enum(["OWNER", "ADMIN", "EDITOR", "VIEWER"]);
22
+ var TokenAccess = z.enum(["READ", "READ_WRITE"]);
23
+ var VersionChangeType = z.enum(["CREATED", "UPDATED", "ROLLBACK"]);
24
+ var ErrorCode = z.enum([
25
+ "VALIDATION_ERROR",
26
+ "BAD_REQUEST",
27
+ "UNAUTHENTICATED",
28
+ "FORBIDDEN",
29
+ "NOT_FOUND",
30
+ "CONFLICT",
31
+ "RATE_LIMITED",
32
+ "INTERNAL"
33
+ ]);
34
+
35
+ // src/schemas.ts
36
+ import { z as z2 } from "zod";
37
+ var id = z2.uuid();
38
+ var isoDate = z2.iso.datetime();
39
+ var email = z2.string().trim().toLowerCase().pipe(z2.email().max(254));
40
+ var name = z2.string().trim().min(1).max(MAX_NAME_LENGTH);
41
+ var slug = z2.string().min(1).max(MAX_NAME_LENGTH).regex(SLUG_REGEX);
42
+ var variableKey = z2.string().min(1).max(MAX_KEY_LENGTH).regex(VARIABLE_KEY_REGEX);
43
+ var variableValue = z2.string().refine(
44
+ (value) => new TextEncoder().encode(value).length <= MAX_VALUE_BYTES,
45
+ {
46
+ message: `Value must be at most ${MAX_VALUE_BYTES} bytes`
47
+ }
48
+ );
49
+ var password = z2.string().min(MIN_PASSWORD_LENGTH).max(MAX_PASSWORD_LENGTH);
50
+ var RegisterInput = z2.object({ email, name, password }).strict();
51
+ var LoginInput = z2.object({ email, password: z2.string().min(1).max(MAX_PASSWORD_LENGTH) }).strict();
52
+ var UserDto = z2.object({ id, email, name, createdAt: isoDate }).strict();
53
+ var CreateProjectInput = z2.object({ name, slug, description: z2.string().max(500).optional() }).strict();
54
+ var UpdateProjectInput = z2.object({
55
+ name: name.optional(),
56
+ description: z2.string().max(500).nullable().optional()
57
+ }).strict();
58
+ var ProjectDto = z2.object({
59
+ id,
60
+ name,
61
+ slug,
62
+ description: z2.string().nullable(),
63
+ createdAt: isoDate,
64
+ updatedAt: isoDate
65
+ }).strict();
66
+ var ProjectSummaryDto = ProjectDto.extend({ role: ProjectRole });
67
+ var AddMemberInput = z2.object({ email, role: ProjectRole }).strict();
68
+ var UpdateMemberInput = z2.object({ role: ProjectRole }).strict();
69
+ var MemberDto = z2.object({ userId: id, email, name, role: ProjectRole, createdAt: isoDate }).strict();
70
+ var CreateEnvironmentInput = z2.object({ name, slug }).strict();
71
+ var UpdateEnvironmentInput = z2.object({ name: name.optional(), slug: slug.optional() }).strict();
72
+ var EnvironmentDto = z2.object({
73
+ id,
74
+ projectId: id,
75
+ name,
76
+ slug,
77
+ createdAt: isoDate,
78
+ updatedAt: isoDate
79
+ }).strict();
80
+ var CreateVariableInput = z2.object({ key: variableKey, value: variableValue }).strict();
81
+ var UpdateVariableInput = z2.object({ value: variableValue }).strict();
82
+ var VariableMetaDto = z2.object({
83
+ id,
84
+ key: variableKey,
85
+ currentVersion: z2.number().int().min(1),
86
+ updatedAt: isoDate
87
+ }).strict();
88
+ var VariableWithValueDto = VariableMetaDto.extend({
89
+ value: z2.string()
90
+ });
91
+ var BulkUpsertVariablesInput = z2.object({
92
+ variables: z2.array(CreateVariableInput).min(1).max(MAX_BULK_VARIABLES).refine(
93
+ (items) => new Set(items.map((item) => item.key)).size === items.length,
94
+ { message: "Duplicate keys are not allowed" }
95
+ )
96
+ }).strict();
97
+ var BulkUpsertVariablesResponse = z2.object({
98
+ created: z2.number().int().min(0),
99
+ updated: z2.number().int().min(0),
100
+ unchanged: z2.number().int().min(0)
101
+ }).strict();
102
+ var environmentIds = z2.array(id).max(100);
103
+ var CreateSharedVariableInput = z2.object({ key: variableKey, value: variableValue, environmentIds }).strict();
104
+ var UpdateSharedVariableInput = z2.object({
105
+ value: variableValue.optional(),
106
+ environmentIds: environmentIds.optional()
107
+ }).strict().refine(
108
+ (input) => input.value !== void 0 || input.environmentIds !== void 0,
109
+ {
110
+ message: "Provide value and/or environmentIds"
111
+ }
112
+ );
113
+ var SharedVariableMetaDto = VariableMetaDto.extend({ environmentIds });
114
+ var ListVersionsQuery = z2.object({
115
+ cursor: z2.string().min(1).max(256).optional(),
116
+ limit: z2.coerce.number().int().min(1).max(MAX_VERSIONS_LIMIT).default(20)
117
+ }).strict();
118
+ var VariableVersionMetaDto = z2.object({
119
+ version: z2.number().int().min(1),
120
+ changeType: VersionChangeType,
121
+ restoredFromVersion: z2.number().int().min(1).nullable().optional(),
122
+ changedBy: z2.object({ id, name: z2.string() }).strict().nullable(),
123
+ createdAt: isoDate,
124
+ isCurrent: z2.boolean()
125
+ }).strict();
126
+ var PaginatedVersionsResponse = z2.object({
127
+ items: z2.array(VariableVersionMetaDto),
128
+ nextCursor: z2.string().optional()
129
+ }).strict();
130
+ var VariableVersionValueDto = z2.object({ version: z2.number().int().min(1), value: z2.string() }).strict();
131
+ var ResolvedVariableDto = z2.object({
132
+ key: variableKey,
133
+ value: z2.string(),
134
+ source: z2.enum(["environment", "shared"])
135
+ }).strict();
136
+ var ResolvedVariablesResponse = z2.object({
137
+ project: z2.object({ id, slug }).strict(),
138
+ environment: z2.object({ id, slug }).strict(),
139
+ variables: z2.array(ResolvedVariableDto)
140
+ }).strict();
141
+ var SdkEnvironmentDto = z2.object({ id, slug, name }).strict();
142
+ var SdkProjectDto = z2.object({
143
+ id,
144
+ slug,
145
+ name,
146
+ role: ProjectRole,
147
+ environments: z2.array(SdkEnvironmentDto)
148
+ }).strict();
149
+ var CreateTokenInput = z2.object({
150
+ name,
151
+ access: TokenAccess,
152
+ projectId: id.optional(),
153
+ environmentId: id.optional(),
154
+ expiresInDays: z2.number().int().min(1).max(365).optional()
155
+ }).strict().refine((input) => !input.environmentId || !!input.projectId, {
156
+ message: "environmentId requires projectId",
157
+ path: ["environmentId"]
158
+ });
159
+ var TokenDto = z2.object({
160
+ id,
161
+ name,
162
+ prefix: z2.string().length(8),
163
+ access: TokenAccess,
164
+ projectId: id.nullable(),
165
+ environmentId: id.nullable(),
166
+ expiresAt: isoDate.nullable(),
167
+ revokedAt: isoDate.nullable(),
168
+ lastUsedAt: isoDate.nullable(),
169
+ createdAt: isoDate
170
+ }).strict();
171
+ var CreatedTokenDto = TokenDto.extend({ token: z2.string().min(1) });
172
+ var ApiErrorBody = z2.object({
173
+ error: z2.object({
174
+ code: ErrorCode,
175
+ message: z2.string(),
176
+ details: z2.unknown().optional()
177
+ }).strict()
178
+ }).strict();
179
+
180
+ // src/index.ts
181
+ var apiEnvironmentSchema = z3.object({
182
+ NODE_ENV: z3.enum(["development", "test", "production"]),
183
+ HOST: z3.string().min(1).default("0.0.0.0"),
184
+ PORT: z3.coerce.number().int().min(1).max(65535),
185
+ WEB_ORIGIN: z3.url().refine((value) => {
186
+ const url = new URL(value);
187
+ return ["http:", "https:"].includes(url.protocol) && url.origin === value;
188
+ }, "Expected an exact HTTP(S) origin"),
189
+ DATABASE_URL: z3.url().refine((value) => {
190
+ const url = new URL(value);
191
+ return ["postgres:", "postgresql:"].includes(url.protocol) && !!url.hostname;
192
+ }, "Expected a PostgreSQL connection URL"),
193
+ MASTER_KEY: z3.string().regex(
194
+ /^[A-Za-z0-9+/]{42}[AEIMQUYcgkosw048]=$/,
195
+ "Expected exactly 32 bytes encoded as canonical base64"
196
+ ),
197
+ COOKIE_SECURE: z3.enum(["true", "false"]).optional(),
198
+ VARIABLE_HISTORY_LIMIT: z3.coerce.number().int().min(1).max(500).default(50),
199
+ // Reverse-proxy hops in front of the API (Express `trust proxy`); 0 trusts none.
200
+ TRUST_PROXY: z3.coerce.number().int().min(0).max(10).default(0)
201
+ }).strict().transform((environment) => ({
202
+ ...environment,
203
+ COOKIE_SECURE: environment.COOKIE_SECURE === void 0 ? environment.NODE_ENV === "production" : environment.COOKIE_SECURE === "true"
204
+ }));
205
+ export {
206
+ AddMemberInput,
207
+ ApiErrorBody,
208
+ BulkUpsertVariablesInput,
209
+ BulkUpsertVariablesResponse,
210
+ CSRF_HEADER_NAME,
211
+ CSRF_HEADER_VALUE,
212
+ CreateEnvironmentInput,
213
+ CreateProjectInput,
214
+ CreateSharedVariableInput,
215
+ CreateTokenInput,
216
+ CreateVariableInput,
217
+ CreatedTokenDto,
218
+ DEFAULT_VERSIONS_LIMIT,
219
+ EnvironmentDto,
220
+ ErrorCode,
221
+ ListVersionsQuery,
222
+ LoginInput,
223
+ MAX_BULK_VARIABLES,
224
+ MAX_KEY_LENGTH,
225
+ MAX_NAME_LENGTH,
226
+ MAX_PASSWORD_LENGTH,
227
+ MAX_VALUE_BYTES,
228
+ MAX_VERSIONS_LIMIT,
229
+ MIN_PASSWORD_LENGTH,
230
+ MemberDto,
231
+ PaginatedVersionsResponse,
232
+ ProjectDto,
233
+ ProjectRole,
234
+ ProjectSummaryDto,
235
+ RegisterInput,
236
+ ResolvedVariableDto,
237
+ ResolvedVariablesResponse,
238
+ SLUG_REGEX,
239
+ SdkEnvironmentDto,
240
+ SdkProjectDto,
241
+ SharedVariableMetaDto,
242
+ TOKEN_PREFIX,
243
+ TokenAccess,
244
+ TokenDto,
245
+ UpdateEnvironmentInput,
246
+ UpdateMemberInput,
247
+ UpdateProjectInput,
248
+ UpdateSharedVariableInput,
249
+ UpdateVariableInput,
250
+ UserDto,
251
+ VARIABLE_KEY_REGEX,
252
+ VariableMetaDto,
253
+ VariableVersionMetaDto,
254
+ VariableVersionValueDto,
255
+ VariableWithValueDto,
256
+ VersionChangeType,
257
+ apiEnvironmentSchema
258
+ };