@alpic-ai/api 0.0.0-dev.fa5b169 → 0.0.0-dev.fb2f877

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.mjs ADDED
@@ -0,0 +1,370 @@
1
+ import { oc } from "@orpc/contract";
2
+ import { z } from "zod";
3
+
4
+ //#region src/schemas.ts
5
+ const RESERVED_KEYS = [
6
+ "_HANDLER",
7
+ "_X_AMZN_TRACE_ID",
8
+ "AWS_DEFAULT_REGION",
9
+ "AWS_REGION",
10
+ "AWS_EXECUTION_ENV",
11
+ "AWS_LAMBDA_FUNCTION_NAME",
12
+ "AWS_LAMBDA_FUNCTION_MEMORY_SIZE",
13
+ "AWS_LAMBDA_FUNCTION_VERSION",
14
+ "AWS_LAMBDA_INITIALIZATION_TYPE",
15
+ "AWS_LAMBDA_LOG_GROUP_NAME",
16
+ "AWS_ACCESS_KEY",
17
+ "AWS_LAMBDA_RUNTIME_API",
18
+ "LAMBDA_TASK_ROOT",
19
+ "LAMBDA_RUNTIME_DIR",
20
+ "START_COMMAND",
21
+ "ENVIRONMENT_ID",
22
+ "PROJECT_BUILD_IMAGES_REPOSITORY_URI",
23
+ "ENVIRONMENT_LAMBDA_FUNCTION_ARN",
24
+ "SOURCE_REPOSITORY",
25
+ "SOURCE_BRANCH",
26
+ "SOURCE_REPOSITORY_CREDENTIALS",
27
+ "RUNTIME",
28
+ "ROOT_DIRECTORY",
29
+ "BUILD_ARG_INSTALL_COMMAND",
30
+ "BUILD_ARG_BUILD_COMMAND",
31
+ "BUILD_ARG_BUILD_OUTPUT_DIR",
32
+ "BUILD_ARG_START_COMMAND",
33
+ "ALPIC_HOST"
34
+ ];
35
+ const environmentVariableSchema = z.object({
36
+ 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"),
37
+ value: z.string().min(1, "Value is required"),
38
+ isSecret: z.boolean().default(false)
39
+ });
40
+ const environmentVariablesSchema = z.array(environmentVariableSchema);
41
+ const buildSettingsSchema = z.object({
42
+ installCommand: z.string().optional(),
43
+ buildCommand: z.string().optional(),
44
+ buildOutputDir: z.string().optional(),
45
+ startCommand: z.string().optional()
46
+ });
47
+ const runtimeSchema = z.enum([
48
+ "python3.13",
49
+ "python3.14",
50
+ "node22",
51
+ "node24"
52
+ ]);
53
+ const transportSchema = z.enum([
54
+ "stdio",
55
+ "sse",
56
+ "streamablehttp"
57
+ ]);
58
+
59
+ //#endregion
60
+ //#region src/api.contract.ts
61
+ const deploymentStatusSchema = z.enum([
62
+ "ongoing",
63
+ "deployed",
64
+ "failed",
65
+ "canceled"
66
+ ]);
67
+ const latestDeploymentSchema = z.object({
68
+ id: z.string(),
69
+ status: deploymentStatusSchema,
70
+ sourceCommitId: z.string().nullable(),
71
+ sourceCommitMessage: z.string().nullable(),
72
+ completedAt: z.coerce.date().nullable()
73
+ });
74
+ const deploymentSchema = z.object({
75
+ id: z.string(),
76
+ status: deploymentStatusSchema,
77
+ sourceRef: z.string().nullable(),
78
+ sourceCommitId: z.string().nullable(),
79
+ sourceCommitMessage: z.string().nullable(),
80
+ authorUsername: z.string().nullable(),
81
+ authorAvatarUrl: z.string().nullable(),
82
+ startedAt: z.coerce.date().nullable(),
83
+ completedAt: z.coerce.date().nullable()
84
+ });
85
+ const createEnvironmentContractV1 = oc.route({
86
+ path: "/v1/environments",
87
+ method: "POST",
88
+ summary: "Create an environment",
89
+ description: "Create an environment for a project",
90
+ tags: ["environments"],
91
+ successDescription: "The environment has been created successfully"
92
+ }).errors({
93
+ NOT_FOUND: {},
94
+ BAD_REQUEST: {}
95
+ }).input(z.object({
96
+ projectId: z.string().describe("The ID of the project to create the environment for"),
97
+ name: z.string().min(1).describe("The name of the environment"),
98
+ sourceBranch: z.string().min(1).describe("The branch used to build the environment"),
99
+ environmentVariables: environmentVariablesSchema.default([])
100
+ })).output(z.object({
101
+ id: z.string(),
102
+ name: z.string(),
103
+ sourceBranch: z.string().nullable().describe("The branch used to build the environment"),
104
+ urls: z.array(z.string().url()).describe("The URLs of the MCP server"),
105
+ createdAt: z.coerce.date(),
106
+ projectId: z.string().describe("The ID of the project the environment belongs to")
107
+ }));
108
+ const getEnvironmentContractV1 = oc.route({
109
+ path: "/v1/environments/{environmentId}",
110
+ method: "GET",
111
+ summary: "Get an environment",
112
+ description: "Get an environment by ID",
113
+ tags: ["environments"],
114
+ successDescription: "The environment details"
115
+ }).errors({ NOT_FOUND: {} }).input(z.object({ environmentId: z.string().describe("The ID of the environment") })).output(z.object({
116
+ id: z.string(),
117
+ name: z.string(),
118
+ sourceBranch: z.string().nullable(),
119
+ mcpServerUrl: z.string(),
120
+ domains: z.array(z.url()),
121
+ createdAt: z.coerce.date(),
122
+ projectId: z.string()
123
+ }));
124
+ const productionEnvironmentSchema = z.object({
125
+ id: z.string(),
126
+ name: z.string(),
127
+ mcpServerUrl: z.string(),
128
+ latestDeployment: latestDeploymentSchema.nullable()
129
+ });
130
+ const environmentSchema = z.object({
131
+ id: z.string(),
132
+ name: z.string(),
133
+ sourceBranch: z.string().nullable(),
134
+ mcpServerUrl: z.string(),
135
+ createdAt: z.coerce.date(),
136
+ projectId: z.string(),
137
+ latestDeployment: latestDeploymentSchema.nullable()
138
+ });
139
+ const projectOutputSchema = z.object({
140
+ id: z.string(),
141
+ name: z.string(),
142
+ teamId: z.string(),
143
+ sourceRepository: z.string().nullable(),
144
+ runtime: runtimeSchema,
145
+ transport: transportSchema.nullable(),
146
+ rootDirectory: z.string().nullable(),
147
+ buildCommand: z.string().nullable(),
148
+ buildOutputDir: z.string().nullable(),
149
+ installCommand: z.string().nullable(),
150
+ startCommand: z.string().nullable(),
151
+ createdAt: z.coerce.date(),
152
+ productionEnvironment: productionEnvironmentSchema.nullable(),
153
+ environments: z.array(environmentSchema)
154
+ });
155
+ const getProjectContractV1 = oc.route({
156
+ path: "/v1/projects/{projectId}",
157
+ method: "GET",
158
+ summary: "Get a project",
159
+ description: "Get a project by ID",
160
+ tags: ["projects"],
161
+ successDescription: "The project details"
162
+ }).errors({ NOT_FOUND: {} }).input(z.object({ projectId: z.string().describe("The ID of the project") })).output(projectOutputSchema);
163
+ const listProjectsContractV1 = oc.route({
164
+ path: "/v1/projects",
165
+ method: "GET",
166
+ summary: "List projects",
167
+ description: "List all projects for a team",
168
+ tags: ["projects"],
169
+ successDescription: "The list of projects"
170
+ }).output(z.array(projectOutputSchema));
171
+ const createProjectContractV1 = oc.route({
172
+ path: "/v1/projects",
173
+ method: "POST",
174
+ summary: "Create a project",
175
+ description: "Create a project for a team",
176
+ tags: ["projects"],
177
+ successDescription: "The project has been created successfully"
178
+ }).errors({
179
+ NOT_FOUND: {},
180
+ BAD_REQUEST: {}
181
+ }).input(z.object({
182
+ teamId: z.string().optional(),
183
+ name: z.string().min(1).max(100),
184
+ sourceRepository: z.string().optional(),
185
+ branchName: z.string().min(1).optional(),
186
+ runtime: runtimeSchema,
187
+ transport: transportSchema.optional(),
188
+ rootDirectory: z.string().optional(),
189
+ settings: buildSettingsSchema.default({}),
190
+ environmentVariables: environmentVariablesSchema.default([])
191
+ })).output(z.object({
192
+ id: z.string(),
193
+ name: z.string(),
194
+ teamId: z.string(),
195
+ environments: z.array(z.object({
196
+ id: z.string(),
197
+ name: z.string()
198
+ })),
199
+ productionEnvironment: z.object({
200
+ id: z.string(),
201
+ name: z.string()
202
+ }).nullable(),
203
+ sourceRepository: z.string().nullable(),
204
+ runtime: runtimeSchema,
205
+ transport: transportSchema.nullable(),
206
+ rootDirectory: z.string().nullable(),
207
+ buildCommand: z.string().nullable(),
208
+ buildOutputDir: z.string().nullable(),
209
+ installCommand: z.string().nullable(),
210
+ startCommand: z.string().nullable(),
211
+ createdAt: z.coerce.date()
212
+ }));
213
+ const deleteProjectContractV1 = oc.route({
214
+ path: "/v1/projects/:projectId",
215
+ method: "DELETE",
216
+ summary: "Delete a project",
217
+ description: "Delete a project and all its environments",
218
+ tags: ["projects"],
219
+ successDescription: "The project has been deleted successfully"
220
+ }).errors({ NOT_FOUND: {} }).input(z.object({ projectId: z.string().describe("The ID of the project") })).output(z.object({ success: z.literal(true) }));
221
+ const updateProjectContractV1 = oc.route({
222
+ path: "/v1/projects/{projectId}",
223
+ method: "PATCH",
224
+ summary: "Update a project",
225
+ description: "Update project settings",
226
+ tags: ["projects"],
227
+ successDescription: "The project has been updated successfully"
228
+ }).errors({
229
+ NOT_FOUND: {},
230
+ BAD_REQUEST: {}
231
+ }).input(z.object({
232
+ projectId: z.string().describe("The ID of the project"),
233
+ sourceRepository: z.string().nullable().optional().describe("The source repository to connect to the project")
234
+ })).output(projectOutputSchema);
235
+ const deployEnvironmentContractV1 = oc.route({
236
+ path: "/v1/environments/{environmentId}/deploy",
237
+ method: "POST",
238
+ summary: "Deploy an environment",
239
+ description: "Deploy an environment",
240
+ tags: ["environments"],
241
+ successDescription: "The environment has been deployed successfully"
242
+ }).errors({
243
+ NOT_FOUND: {},
244
+ BAD_REQUEST: {}
245
+ }).input(z.object({
246
+ environmentId: z.string().describe("The ID of the environment to deploy"),
247
+ token: z.string().describe("The token to identify the source archive").optional()
248
+ })).output(deploymentSchema);
249
+ const uploadDeploymentArtifactContractV1 = oc.route({
250
+ path: "/v1/deployments/upload",
251
+ method: "POST",
252
+ summary: "Upload deployment artifacts",
253
+ description: "Return a presigned S3 URL to upload a deployment artifact",
254
+ tags: ["deployments"],
255
+ successDescription: "The presigned upload URL has been generated successfully"
256
+ }).input(z.object({ teamId: z.string().optional() }).optional()).output(z.object({
257
+ uploadUrl: z.string().url().describe("Presigned S3 URL to upload the source archive with HTTP PUT"),
258
+ token: z.string().describe("Token to identify the source archive"),
259
+ expiresAt: z.coerce.date().describe("Expiration date of the presigned URL")
260
+ }));
261
+ const listProjectDeploymentsContractV1 = oc.route({
262
+ path: "/v1/projects/{projectId}/deployments",
263
+ method: "GET",
264
+ summary: "List project deployments",
265
+ description: "List all deployments for a project",
266
+ tags: ["deployments"],
267
+ successDescription: "The list of deployments"
268
+ }).errors({ NOT_FOUND: {} }).input(z.object({ projectId: z.string().describe("The ID of the project") })).output(z.array(deploymentSchema.extend({
269
+ isCurrent: z.boolean(),
270
+ environmentId: z.string()
271
+ })));
272
+ const getDeploymentContractV1 = oc.route({
273
+ path: "/v1/deployments/{deploymentId}",
274
+ method: "GET",
275
+ summary: "Get a deployment",
276
+ description: "Get a deployment by ID",
277
+ tags: ["deployments"],
278
+ successDescription: "The deployment details"
279
+ }).errors({ NOT_FOUND: {} }).input(z.object({ deploymentId: z.string().describe("The ID of the deployment") })).output(deploymentSchema);
280
+ const getDeploymentLogsContractV1 = oc.route({
281
+ path: "/v1/deployments/{deploymentId}/logs",
282
+ method: "GET",
283
+ summary: "Get deployment logs",
284
+ description: "Get the logs for a deployment",
285
+ tags: ["deployments"],
286
+ successDescription: "The deployment logs"
287
+ }).errors({ NOT_FOUND: {} }).input(z.object({ deploymentId: z.string().describe("The ID of the deployment") })).output(z.object({
288
+ logs: z.array(z.object({
289
+ timestamp: z.coerce.date().optional(),
290
+ content: z.string().optional()
291
+ })),
292
+ hasMoreLogs: z.boolean()
293
+ }));
294
+ const analyticsDataPointSchema = z.object({
295
+ timestamp: z.number(),
296
+ categories: z.record(z.string(), z.unknown())
297
+ });
298
+ const analyticsTimeSeriesSchema = z.object({
299
+ sessions_count: z.array(analyticsDataPointSchema),
300
+ requests_count: z.array(analyticsDataPointSchema),
301
+ requests_latency_mean: z.array(analyticsDataPointSchema),
302
+ tool_errors: z.array(analyticsDataPointSchema),
303
+ mcp_errors: z.array(analyticsDataPointSchema),
304
+ output_token_mean: z.array(analyticsDataPointSchema),
305
+ task_count: z.array(analyticsDataPointSchema)
306
+ });
307
+ const getProjectAnalyticsContractV1 = oc.route({
308
+ path: "/v1/analytics/{projectId}",
309
+ method: "GET",
310
+ summary: "Get project analytics",
311
+ description: "Get analytics data for a project over a time range",
312
+ tags: ["analytics"],
313
+ successDescription: "The project analytics data"
314
+ }).errors({
315
+ NOT_FOUND: {},
316
+ BAD_REQUEST: {}
317
+ }).input(z.object({
318
+ projectId: z.string().describe("The ID of the project"),
319
+ startTimestamp: z.coerce.number().describe("Start timestamp in milliseconds"),
320
+ endTimestamp: z.coerce.number().describe("End timestamp in milliseconds"),
321
+ timeZone: z.string().describe("IANA timezone (e.g. Europe/Paris)")
322
+ }).refine(({ startTimestamp, endTimestamp }) => endTimestamp - startTimestamp > 0, { message: "End date must be after start date" }).refine(({ startTimestamp, endTimestamp }) => endTimestamp - startTimestamp <= 744 * 60 * 60 * 1e3, { message: "Date range must be less than 1 month" }).refine(({ timeZone }) => Intl.supportedValuesOf("timeZone").includes(timeZone), { message: "Time zone must be a valid IANA timezone" })).output(z.object({
323
+ metadata: z.object({
324
+ startTimestamp: z.number(),
325
+ endTimestamp: z.number(),
326
+ timeZone: z.string(),
327
+ startDate: z.coerce.date(),
328
+ interval: z.string()
329
+ }),
330
+ timeSeries: analyticsTimeSeriesSchema
331
+ }));
332
+ const listTeamsContractV1 = oc.route({
333
+ path: "/v1/teams",
334
+ method: "GET",
335
+ summary: "List teams",
336
+ description: "List all teams for the authenticated user",
337
+ tags: ["teams"],
338
+ successDescription: "The list of teams"
339
+ }).output(z.array(z.object({
340
+ id: z.string(),
341
+ name: z.string(),
342
+ createdAt: z.coerce.date(),
343
+ hasStripeAccount: z.boolean(),
344
+ hasActiveSubscription: z.boolean()
345
+ })));
346
+ const contract = {
347
+ teams: { list: { v1: listTeamsContractV1 } },
348
+ analytics: { get: { v1: getProjectAnalyticsContractV1 } },
349
+ deployments: {
350
+ list: { v1: listProjectDeploymentsContractV1 },
351
+ get: { v1: getDeploymentContractV1 },
352
+ uploadArtifact: { v1: uploadDeploymentArtifactContractV1 },
353
+ getLogs: { v1: getDeploymentLogsContractV1 }
354
+ },
355
+ environments: {
356
+ create: { v1: createEnvironmentContractV1 },
357
+ get: { v1: getEnvironmentContractV1 },
358
+ deploy: { v1: deployEnvironmentContractV1 }
359
+ },
360
+ projects: {
361
+ update: { v1: updateProjectContractV1 },
362
+ get: { v1: getProjectContractV1 },
363
+ list: { v1: listProjectsContractV1 },
364
+ create: { v1: createProjectContractV1 },
365
+ delete: { v1: deleteProjectContractV1 }
366
+ }
367
+ };
368
+
369
+ //#endregion
370
+ export { buildSettingsSchema, contract, createEnvironmentContractV1, environmentVariableSchema, environmentVariablesSchema, runtimeSchema, transportSchema };
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@alpic-ai/api",
3
- "version": "0.0.0-dev.fa5b169",
3
+ "version": "0.0.0-dev.fb2f877",
4
4
  "description": "Contract for the Alpic API",
5
5
  "type": "module",
6
- "main": "./dist/index.js",
7
- "types": "./dist/index.d.ts",
6
+ "main": "./dist/index.mjs",
7
+ "types": "./dist/index.d.mts",
8
8
  "exports": {
9
9
  ".": {
10
- "types": "./dist/index.d.ts",
11
- "default": "./dist/index.js"
10
+ "types": "./dist/index.d.mts",
11
+ "default": "./dist/index.mjs"
12
12
  }
13
13
  },
14
14
  "files": [
@@ -17,20 +17,19 @@
17
17
  "author": "Alpic",
18
18
  "license": "ISC",
19
19
  "dependencies": {
20
- "@orpc/contract": "^1.13.4",
21
- "zod": "^4.3.6",
22
- "@alpic-ai/shared": "0.0.0"
20
+ "@orpc/contract": "^1.13.5",
21
+ "zod": "^4.3.6"
23
22
  },
24
23
  "devDependencies": {
25
24
  "@total-typescript/tsconfig": "^1.0.4",
26
25
  "biome": "^0.3.3",
27
26
  "shx": "^0.4.0",
28
- "tsup": "^8.5.0",
27
+ "tsdown": "^0.20.3",
29
28
  "typescript": "^5.9.3",
30
29
  "vitest": "^4.0.18"
31
30
  },
32
31
  "scripts": {
33
- "build": "shx rm -rf dist && tsup",
32
+ "build": "shx rm -rf dist && tsdown",
34
33
  "format": "biome check --write --error-on-warnings",
35
34
  "test": "pnpm run test:unit && pnpm run test:type && pnpm run test:format",
36
35
  "test:unit": "vitest run",