@alpic-ai/api 0.0.0-staging.29dafd1 → 0.0.0-staging.2aa4565
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/dist/index.d.mts +88 -0
- package/dist/index.mjs +109 -2
- package/package.json +5 -2
package/dist/index.d.mts
CHANGED
|
@@ -226,6 +226,94 @@ declare const contract: {
|
|
|
226
226
|
BAD_REQUEST: {};
|
|
227
227
|
}>, Record<never, never>>;
|
|
228
228
|
};
|
|
229
|
+
getLogs: {
|
|
230
|
+
v1: _orpc_contract0.ContractProcedureBuilderWithInputOutput<z.ZodObject<{
|
|
231
|
+
environmentId: z.ZodString;
|
|
232
|
+
since: z.ZodOptional<z.ZodString>;
|
|
233
|
+
until: z.ZodOptional<z.ZodString>;
|
|
234
|
+
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
235
|
+
level: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
236
|
+
INFO: "INFO";
|
|
237
|
+
ERROR: "ERROR";
|
|
238
|
+
WARNING: "WARNING";
|
|
239
|
+
DEBUG: "DEBUG";
|
|
240
|
+
}>>>;
|
|
241
|
+
search: z.ZodOptional<z.ZodString>;
|
|
242
|
+
nextToken: z.ZodOptional<z.ZodString>;
|
|
243
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
244
|
+
logs: z.ZodArray<z.ZodObject<{
|
|
245
|
+
timestamp: z.ZodCoercedDate<unknown>;
|
|
246
|
+
type: z.ZodEnum<{
|
|
247
|
+
INFO: "INFO";
|
|
248
|
+
ERROR: "ERROR";
|
|
249
|
+
WARNING: "WARNING";
|
|
250
|
+
DEBUG: "DEBUG";
|
|
251
|
+
START: "START";
|
|
252
|
+
END: "END";
|
|
253
|
+
}>;
|
|
254
|
+
requestId: z.ZodString;
|
|
255
|
+
content: z.ZodOptional<z.ZodString>;
|
|
256
|
+
method: z.ZodOptional<z.ZodString>;
|
|
257
|
+
durationInMs: z.ZodOptional<z.ZodNumber>;
|
|
258
|
+
}, z.core.$strip>>;
|
|
259
|
+
nextToken: z.ZodNullable<z.ZodString>;
|
|
260
|
+
}, z.core.$strip>, _orpc_contract0.MergedErrorMap<Record<never, never>, {
|
|
261
|
+
NOT_FOUND: {};
|
|
262
|
+
BAD_REQUEST: {};
|
|
263
|
+
}>, Record<never, never>>;
|
|
264
|
+
};
|
|
265
|
+
};
|
|
266
|
+
environmentVariables: {
|
|
267
|
+
list: {
|
|
268
|
+
v1: _orpc_contract0.ContractProcedureBuilderWithInputOutput<z.ZodObject<{
|
|
269
|
+
environmentId: z.ZodString;
|
|
270
|
+
}, z.core.$strip>, z.ZodArray<z.ZodObject<{
|
|
271
|
+
id: z.ZodString;
|
|
272
|
+
key: z.ZodString;
|
|
273
|
+
value: z.ZodString;
|
|
274
|
+
isSecret: z.ZodBoolean;
|
|
275
|
+
createdAt: z.ZodCoercedDate<unknown>;
|
|
276
|
+
}, z.core.$strip>>, _orpc_contract0.MergedErrorMap<Record<never, never>, {
|
|
277
|
+
NOT_FOUND: {};
|
|
278
|
+
}>, Record<never, never>>;
|
|
279
|
+
};
|
|
280
|
+
create: {
|
|
281
|
+
v1: _orpc_contract0.ContractProcedureBuilderWithInputOutput<z.ZodObject<{
|
|
282
|
+
environmentId: z.ZodString;
|
|
283
|
+
environmentVariables: z.ZodArray<z.ZodObject<{
|
|
284
|
+
key: z.ZodString;
|
|
285
|
+
value: z.ZodString;
|
|
286
|
+
isSecret: z.ZodDefault<z.ZodBoolean>;
|
|
287
|
+
}, z.core.$strip>>;
|
|
288
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
289
|
+
success: z.ZodLiteral<true>;
|
|
290
|
+
}, z.core.$strip>, _orpc_contract0.MergedErrorMap<Record<never, never>, {
|
|
291
|
+
NOT_FOUND: {};
|
|
292
|
+
BAD_REQUEST: {};
|
|
293
|
+
}>, Record<never, never>>;
|
|
294
|
+
};
|
|
295
|
+
update: {
|
|
296
|
+
v1: _orpc_contract0.ContractProcedureBuilderWithInputOutput<z.ZodObject<{
|
|
297
|
+
environmentVariableId: z.ZodString;
|
|
298
|
+
key: z.ZodString;
|
|
299
|
+
value: z.ZodOptional<z.ZodString>;
|
|
300
|
+
isSecret: z.ZodDefault<z.ZodBoolean>;
|
|
301
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
302
|
+
success: z.ZodLiteral<true>;
|
|
303
|
+
}, z.core.$strip>, _orpc_contract0.MergedErrorMap<Record<never, never>, {
|
|
304
|
+
NOT_FOUND: {};
|
|
305
|
+
BAD_REQUEST: {};
|
|
306
|
+
}>, Record<never, never>>;
|
|
307
|
+
};
|
|
308
|
+
delete: {
|
|
309
|
+
v1: _orpc_contract0.ContractProcedureBuilderWithInputOutput<z.ZodObject<{
|
|
310
|
+
environmentVariableId: z.ZodString;
|
|
311
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
312
|
+
success: z.ZodLiteral<true>;
|
|
313
|
+
}, z.core.$strip>, _orpc_contract0.MergedErrorMap<Record<never, never>, {
|
|
314
|
+
NOT_FOUND: {};
|
|
315
|
+
}>, Record<never, never>>;
|
|
316
|
+
};
|
|
229
317
|
};
|
|
230
318
|
projects: {
|
|
231
319
|
update: {
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { oc } from "@orpc/contract";
|
|
2
|
+
import ms from "ms";
|
|
2
3
|
import { z } from "zod";
|
|
3
4
|
//#region src/schemas.ts
|
|
4
5
|
const RESERVED_KEYS = [
|
|
@@ -33,7 +34,8 @@ const RESERVED_KEYS = [
|
|
|
33
34
|
"BUILD_ARG_BUILD_COMMAND",
|
|
34
35
|
"BUILD_ARG_BUILD_OUTPUT_DIR",
|
|
35
36
|
"BUILD_ARG_START_COMMAND",
|
|
36
|
-
"ALPIC_HOST"
|
|
37
|
+
"ALPIC_HOST",
|
|
38
|
+
"ALPIC_CUSTOM_DOMAINS"
|
|
37
39
|
];
|
|
38
40
|
const environmentVariableSchema = z.object({
|
|
39
41
|
key: z.string().min(2, "Key must be at least 2 characters").regex(/^[a-zA-Z]([a-zA-Z0-9_])+$/, "Key must start with a letter and contain only letters, numbers, and underscores").refine((key) => !RESERVED_KEYS.includes(key), "This key is reserved and cannot be used as an environment variable key"),
|
|
@@ -85,6 +87,10 @@ const deploymentSchema = z.object({
|
|
|
85
87
|
completedAt: z.coerce.date().nullable()
|
|
86
88
|
});
|
|
87
89
|
const deploymentWithPageUrlSchema = deploymentSchema.extend({ deploymentPageUrl: z.url().nullable() });
|
|
90
|
+
const isValidLogTimeInput = (value) => {
|
|
91
|
+
if (ms(value) !== void 0) return true;
|
|
92
|
+
return !Number.isNaN(new Date(value).getTime());
|
|
93
|
+
};
|
|
88
94
|
const createEnvironmentContractV1 = oc.route({
|
|
89
95
|
path: "/v1/environments",
|
|
90
96
|
method: "POST",
|
|
@@ -223,6 +229,59 @@ const createProjectContractV1 = oc.route({
|
|
|
223
229
|
startCommand: z.string().nullable(),
|
|
224
230
|
createdAt: z.coerce.date()
|
|
225
231
|
}));
|
|
232
|
+
const environmentVariableOutputSchema = z.object({
|
|
233
|
+
id: z.string(),
|
|
234
|
+
key: z.string(),
|
|
235
|
+
value: z.string(),
|
|
236
|
+
isSecret: z.boolean(),
|
|
237
|
+
createdAt: z.coerce.date()
|
|
238
|
+
});
|
|
239
|
+
const listEnvironmentVariablesContractV1 = oc.route({
|
|
240
|
+
path: "/v1/environments/{environmentId}/environment-variables",
|
|
241
|
+
method: "GET",
|
|
242
|
+
summary: "List environment variables",
|
|
243
|
+
description: "List all environment variables for an environment",
|
|
244
|
+
tags: ["environments"],
|
|
245
|
+
successDescription: "The list of environment variables"
|
|
246
|
+
}).errors({ NOT_FOUND: {} }).input(z.object({ environmentId: z.string().describe("The ID of the environment") })).output(z.array(environmentVariableOutputSchema));
|
|
247
|
+
const createEnvironmentVariablesContractV1 = oc.route({
|
|
248
|
+
path: "/v1/environments/{environmentId}/environment-variables",
|
|
249
|
+
method: "POST",
|
|
250
|
+
summary: "Add environment variables",
|
|
251
|
+
description: "Add one or more environment variables to an environment",
|
|
252
|
+
tags: ["environments"],
|
|
253
|
+
successDescription: "The environment variables have been added successfully"
|
|
254
|
+
}).errors({
|
|
255
|
+
NOT_FOUND: {},
|
|
256
|
+
BAD_REQUEST: {}
|
|
257
|
+
}).input(z.object({
|
|
258
|
+
environmentId: z.string().describe("The ID of the environment"),
|
|
259
|
+
environmentVariables: environmentVariablesSchema
|
|
260
|
+
})).output(z.object({ success: z.literal(true) }));
|
|
261
|
+
const updateEnvironmentVariableContractV1 = oc.route({
|
|
262
|
+
path: "/v1/environment-variables/{environmentVariableId}",
|
|
263
|
+
method: "PATCH",
|
|
264
|
+
summary: "Update an environment variable",
|
|
265
|
+
description: "Update an environment variable by ID",
|
|
266
|
+
tags: ["environments"],
|
|
267
|
+
successDescription: "The environment variable has been updated successfully"
|
|
268
|
+
}).errors({
|
|
269
|
+
NOT_FOUND: {},
|
|
270
|
+
BAD_REQUEST: {}
|
|
271
|
+
}).input(z.object({
|
|
272
|
+
environmentVariableId: z.string().describe("The ID of the environment variable"),
|
|
273
|
+
key: environmentVariableSchema.shape.key,
|
|
274
|
+
value: environmentVariableSchema.shape.value.optional(),
|
|
275
|
+
isSecret: environmentVariableSchema.shape.isSecret
|
|
276
|
+
})).output(z.object({ success: z.literal(true) }));
|
|
277
|
+
const deleteEnvironmentVariableContractV1 = oc.route({
|
|
278
|
+
path: "/v1/environment-variables/{environmentVariableId}",
|
|
279
|
+
method: "DELETE",
|
|
280
|
+
summary: "Delete an environment variable",
|
|
281
|
+
description: "Delete an environment variable by ID",
|
|
282
|
+
tags: ["environments"],
|
|
283
|
+
successDescription: "The environment variable has been deleted successfully"
|
|
284
|
+
}).errors({ NOT_FOUND: {} }).input(z.object({ environmentVariableId: z.string().describe("The ID of the environment variable") })).output(z.object({ success: z.literal(true) }));
|
|
226
285
|
const deleteProjectContractV1 = oc.route({
|
|
227
286
|
path: "/v1/projects/:projectId",
|
|
228
287
|
method: "DELETE",
|
|
@@ -291,6 +350,47 @@ const getDeploymentContractV1 = oc.route({
|
|
|
291
350
|
tags: ["deployments"],
|
|
292
351
|
successDescription: "The deployment details"
|
|
293
352
|
}).errors({ NOT_FOUND: {} }).input(z.object({ deploymentId: z.string().describe("The ID of the deployment") })).output(deploymentWithPageUrlSchema);
|
|
353
|
+
const getLogsContractV1 = oc.route({
|
|
354
|
+
path: "/v1/environments/{environmentId}/logs",
|
|
355
|
+
method: "GET",
|
|
356
|
+
summary: "Get logs",
|
|
357
|
+
description: "Get logs for an environment",
|
|
358
|
+
tags: ["environments"],
|
|
359
|
+
successDescription: "The logs"
|
|
360
|
+
}).errors({
|
|
361
|
+
NOT_FOUND: {},
|
|
362
|
+
BAD_REQUEST: {}
|
|
363
|
+
}).input(z.object({
|
|
364
|
+
environmentId: z.string().describe("The ID of the environment"),
|
|
365
|
+
since: z.string().refine(isValidLogTimeInput, { message: "Invalid time. Use relative (1h, 30m, 2d) or ISO 8601 format." }).optional().describe("Start time — ISO 8601 (2024-01-01T00:00:00Z) or relative (1h, 30m, 2d)"),
|
|
366
|
+
until: z.string().refine(isValidLogTimeInput, { message: "Invalid time. Use relative (1h, 30m, 2d) or ISO 8601 format." }).optional().describe("End time — ISO 8601 or relative"),
|
|
367
|
+
limit: z.coerce.number().int().min(1).max(1e3).default(1e3).describe("Maximum number of log entries to return."),
|
|
368
|
+
level: z.array(z.enum([
|
|
369
|
+
"INFO",
|
|
370
|
+
"ERROR",
|
|
371
|
+
"WARNING",
|
|
372
|
+
"DEBUG"
|
|
373
|
+
])).optional().describe("Filter by log level"),
|
|
374
|
+
search: z.string().optional().describe("Filter pattern to search for in log content"),
|
|
375
|
+
nextToken: z.string().optional().describe("Pagination token from a previous response")
|
|
376
|
+
})).output(z.object({
|
|
377
|
+
logs: z.array(z.object({
|
|
378
|
+
timestamp: z.coerce.date(),
|
|
379
|
+
type: z.enum([
|
|
380
|
+
"START",
|
|
381
|
+
"END",
|
|
382
|
+
"INFO",
|
|
383
|
+
"ERROR",
|
|
384
|
+
"WARNING",
|
|
385
|
+
"DEBUG"
|
|
386
|
+
]),
|
|
387
|
+
requestId: z.string(),
|
|
388
|
+
content: z.string().optional(),
|
|
389
|
+
method: z.string().optional(),
|
|
390
|
+
durationInMs: z.number().optional()
|
|
391
|
+
})),
|
|
392
|
+
nextToken: z.string().nullable()
|
|
393
|
+
}));
|
|
294
394
|
const getDeploymentLogsContractV1 = oc.route({
|
|
295
395
|
path: "/v1/deployments/{deploymentId}/logs",
|
|
296
396
|
method: "GET",
|
|
@@ -380,7 +480,14 @@ const contract = {
|
|
|
380
480
|
environments: {
|
|
381
481
|
create: { v1: createEnvironmentContractV1 },
|
|
382
482
|
get: { v1: getEnvironmentContractV1 },
|
|
383
|
-
deploy: { v1: deployEnvironmentContractV1 }
|
|
483
|
+
deploy: { v1: deployEnvironmentContractV1 },
|
|
484
|
+
getLogs: { v1: getLogsContractV1 }
|
|
485
|
+
},
|
|
486
|
+
environmentVariables: {
|
|
487
|
+
list: { v1: listEnvironmentVariablesContractV1 },
|
|
488
|
+
create: { v1: createEnvironmentVariablesContractV1 },
|
|
489
|
+
update: { v1: updateEnvironmentVariableContractV1 },
|
|
490
|
+
delete: { v1: deleteEnvironmentVariableContractV1 }
|
|
384
491
|
},
|
|
385
492
|
projects: {
|
|
386
493
|
update: { v1: updateProjectContractV1 },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alpic-ai/api",
|
|
3
|
-
"version": "0.0.0-staging.
|
|
3
|
+
"version": "0.0.0-staging.2aa4565",
|
|
4
4
|
"description": "Contract for the Alpic API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.mjs",
|
|
@@ -18,10 +18,12 @@
|
|
|
18
18
|
"license": "ISC",
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@orpc/contract": "^1.13.6",
|
|
21
|
+
"ms": "^2.1.3",
|
|
21
22
|
"zod": "^4.3.6"
|
|
22
23
|
},
|
|
23
24
|
"devDependencies": {
|
|
24
25
|
"@total-typescript/tsconfig": "^1.0.4",
|
|
26
|
+
"@types/ms": "^2.1.0",
|
|
25
27
|
"shx": "^0.4.0",
|
|
26
28
|
"tsdown": "^0.21.1",
|
|
27
29
|
"typescript": "^5.9.3",
|
|
@@ -33,6 +35,7 @@
|
|
|
33
35
|
"test": "pnpm run test:unit && pnpm run test:type && pnpm run test:format",
|
|
34
36
|
"test:unit": "vitest run",
|
|
35
37
|
"test:format": "prettier --check .",
|
|
36
|
-
"test:type": "tsc --noEmit"
|
|
38
|
+
"test:type": "tsc --noEmit",
|
|
39
|
+
"publish:npm": "pnpm publish --tag \"${NPM_TAG}\" --access public --no-git-checks"
|
|
37
40
|
}
|
|
38
41
|
}
|