@computesdk/railway 1.0.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 computesdk
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # @computesdk/railway
2
+
3
+ Railway provider for ComputeSDK that enables creating and managing containerized sandboxes on Railway's infrastructure.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @computesdk/railway
9
+ ```
10
+
11
+ ## Configuration
12
+
13
+ The Railway provider requires the following environment variables:
14
+
15
+ ```bash
16
+ RAILWAY_API_KEY=your_railway_api_key
17
+ RAILWAY_PROJECT_ID=your_railway_project_id
18
+ RAILWAY_ENVIRONMENT_ID=your_railway_environment_id
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ ```typescript
24
+ import { railway } from '@computesdk/railway';
25
+
26
+ const provider = railway({
27
+ apiKey: 'your_api_key',
28
+ projectId: 'your_project_id',
29
+ environmentId: 'your_environment_id'
30
+ });
31
+
32
+ // Create a sandbox
33
+ const sandbox = await provider.sandbox.create({ runtime: 'node' });
34
+ console.log(`Created sandbox: ${sandbox.sandboxId}`);
35
+
36
+ // Destroy the sandbox
37
+ await provider.sandbox.destroy(sandbox.sandboxId);
38
+ ```
39
+
40
+ ## Currently Implemented
41
+
42
+ ### Sandbox Operations
43
+ - **create()** - Creates a new Railway service with Docker container deployment
44
+ - **destroy()** - Deletes a Railway service
45
+
46
+ ### Supported Runtimes
47
+ - **node** - Uses `node:alpine` Docker image
48
+ - **python** - Uses `python:alpine` Docker image (default)
49
+
50
+ ### Configuration Options
51
+ - **apiKey** - Railway API authentication token
52
+ - **projectId** - Railway project identifier
53
+ - **environmentId** - Railway environment identifier
54
+
55
+ ## Notes
56
+
57
+ - Services are automatically deployed upon creation
58
+ - Service names are generated with timestamp: `sandbox-{timestamp}`
59
+ - All operations use Railway's GraphQL API
60
+ - Environment variables take precedence over config options
@@ -0,0 +1,33 @@
1
+ import * as computesdk from 'computesdk';
2
+
3
+ /**
4
+ * Railway Provider - Factory-based Implementation
5
+ */
6
+ /**
7
+ * Railway sandbox interface
8
+ */
9
+ interface RailwaySandbox {
10
+ serviceId: string;
11
+ projectId: string;
12
+ environmentId: string;
13
+ }
14
+ interface RailwayConfig {
15
+ /** Railway API key - if not provided, will fallback to RAILWAY_API_KEY environment variable */
16
+ apiKey?: string;
17
+ /** Railway Project ID */
18
+ projectId?: string;
19
+ /** Railway Environment ID - if not provided, will fallback to RAILWAY_ENVIRONMENT_ID environment variable */
20
+ environmentId?: string;
21
+ }
22
+ declare const getAndValidateCredentials: (config: RailwayConfig) => {
23
+ apiKey: string;
24
+ projectId: string;
25
+ environmentId: string;
26
+ };
27
+ declare const fetchRailway: (apiKey: string, mutation: any) => Promise<any>;
28
+ /**
29
+ * Create a Railway provider instance using the factory pattern
30
+ */
31
+ declare const railway: (config: RailwayConfig) => computesdk.Provider<RailwaySandbox, any, any>;
32
+
33
+ export { type RailwayConfig, fetchRailway, getAndValidateCredentials, railway };
@@ -0,0 +1,33 @@
1
+ import * as computesdk from 'computesdk';
2
+
3
+ /**
4
+ * Railway Provider - Factory-based Implementation
5
+ */
6
+ /**
7
+ * Railway sandbox interface
8
+ */
9
+ interface RailwaySandbox {
10
+ serviceId: string;
11
+ projectId: string;
12
+ environmentId: string;
13
+ }
14
+ interface RailwayConfig {
15
+ /** Railway API key - if not provided, will fallback to RAILWAY_API_KEY environment variable */
16
+ apiKey?: string;
17
+ /** Railway Project ID */
18
+ projectId?: string;
19
+ /** Railway Environment ID - if not provided, will fallback to RAILWAY_ENVIRONMENT_ID environment variable */
20
+ environmentId?: string;
21
+ }
22
+ declare const getAndValidateCredentials: (config: RailwayConfig) => {
23
+ apiKey: string;
24
+ projectId: string;
25
+ environmentId: string;
26
+ };
27
+ declare const fetchRailway: (apiKey: string, mutation: any) => Promise<any>;
28
+ /**
29
+ * Create a Railway provider instance using the factory pattern
30
+ */
31
+ declare const railway: (config: RailwayConfig) => computesdk.Provider<RailwaySandbox, any, any>;
32
+
33
+ export { type RailwayConfig, fetchRailway, getAndValidateCredentials, railway };
package/dist/index.js ADDED
@@ -0,0 +1,221 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ fetchRailway: () => fetchRailway,
24
+ getAndValidateCredentials: () => getAndValidateCredentials,
25
+ railway: () => railway
26
+ });
27
+ module.exports = __toCommonJS(index_exports);
28
+ var import_computesdk = require("computesdk");
29
+ var getAndValidateCredentials = (config) => {
30
+ const apiKey = config.apiKey || typeof process !== "undefined" && process.env?.RAILWAY_API_KEY || "";
31
+ const projectId = config.projectId || typeof process !== "undefined" && process.env?.RAILWAY_PROJECT_ID || "";
32
+ const environmentId = config.environmentId || typeof process !== "undefined" && process.env?.RAILWAY_ENVIRONMENT_ID || "";
33
+ if (!apiKey) {
34
+ throw new Error(
35
+ "Missing Railway API key. Provide apiKey in config or set RAILWAY_API_KEY environment variable."
36
+ );
37
+ }
38
+ if (!projectId) {
39
+ throw new Error(
40
+ "Missing Railway Project ID. Provide projectId in config or set RAILWAY_PROJECT_ID environment variable."
41
+ );
42
+ }
43
+ if (!environmentId) {
44
+ throw new Error(
45
+ "Missing Railway Environment ID. Provide environmentId in config or set RAILWAY_ENVIRONMENT_ID environment variable."
46
+ );
47
+ }
48
+ return { apiKey, projectId, environmentId };
49
+ };
50
+ var GRAPHQL_QUERIES = {
51
+ CREATE_SERVICE: `mutation ServiceCreate($input: ServiceCreateInput!) { serviceCreate(input: $input) { id name } }`,
52
+ GET_SERVICE: `query Service($serviceId: String!) { service(id: $serviceId) { id name createdAt } }`,
53
+ LIST_SERVICES: `query Project($projectId: String!) { project(id: $projectId) { services { edges { node { id name createdAt updatedAt } } } } }`,
54
+ DELETE_SERVICE: `mutation ServiceDelete($id: String!) { serviceDelete(id: $id) }`
55
+ };
56
+ var handleGraphQLErrors = (data) => {
57
+ if (data.errors) {
58
+ throw new Error(`Railway GraphQL error: ${data.errors.map((e) => e.message).join(", ")}`);
59
+ }
60
+ };
61
+ var fetchRailway = async (apiKey, mutation) => {
62
+ const response = await fetch("https://backboard.railway.com/graphql/v2", {
63
+ method: "POST",
64
+ headers: {
65
+ "Content-Type": "application/json",
66
+ "Authorization": `Bearer ${apiKey}`
67
+ },
68
+ body: JSON.stringify(mutation)
69
+ });
70
+ if (!response.ok) {
71
+ throw new Error(`Railway API error: ${response.status} ${response.statusText}`);
72
+ }
73
+ const data = await response.json();
74
+ handleGraphQLErrors(data);
75
+ return data.data;
76
+ };
77
+ var railway = (0, import_computesdk.createProvider)({
78
+ name: "railway",
79
+ methods: {
80
+ sandbox: {
81
+ // Collection operations (compute.sandbox.*)
82
+ create: async (config, options) => {
83
+ const { apiKey, projectId, environmentId } = getAndValidateCredentials(config);
84
+ try {
85
+ const mutation = {
86
+ query: GRAPHQL_QUERIES.CREATE_SERVICE,
87
+ variables: {
88
+ input: {
89
+ projectId,
90
+ environmentId,
91
+ source: {
92
+ image: options?.runtime === "node" ? "node:alpine" : "python:alpine"
93
+ }
94
+ }
95
+ }
96
+ };
97
+ const responseData = await fetchRailway(apiKey, mutation);
98
+ const service = responseData?.serviceCreate;
99
+ if (!service) {
100
+ throw new Error("No service returned from Railway API - responseData.serviceCreate is undefined");
101
+ }
102
+ if (!service.id) {
103
+ throw new Error(`Service ID is undefined. Full service object: ${JSON.stringify(service, null, 2)}`);
104
+ }
105
+ const railwaySandbox = {
106
+ serviceId: service.id,
107
+ projectId,
108
+ environmentId
109
+ };
110
+ return {
111
+ sandbox: railwaySandbox,
112
+ sandboxId: service.id
113
+ };
114
+ } catch (error) {
115
+ throw new Error(
116
+ `Failed to create Railway sandbox: ${error instanceof Error ? error.message : String(error)}`
117
+ );
118
+ }
119
+ },
120
+ getById: async (config, sandboxId) => {
121
+ const { apiKey, projectId, environmentId } = getAndValidateCredentials(config);
122
+ try {
123
+ const mutation = {
124
+ query: GRAPHQL_QUERIES.GET_SERVICE,
125
+ variables: {
126
+ serviceId: sandboxId
127
+ }
128
+ };
129
+ const responseData = await fetchRailway(apiKey, mutation);
130
+ if (responseData === null) {
131
+ return null;
132
+ }
133
+ const service = responseData?.service;
134
+ if (!service) {
135
+ throw new Error("Service data is missing from Railway response");
136
+ }
137
+ const railwaySandbox = {
138
+ serviceId: service.id,
139
+ projectId,
140
+ environmentId
141
+ };
142
+ return {
143
+ sandbox: railwaySandbox,
144
+ sandboxId: service.id
145
+ };
146
+ } catch (error) {
147
+ throw new Error(
148
+ `Failed to get Railway sandbox: ${error instanceof Error ? error.message : String(error)}`
149
+ );
150
+ }
151
+ },
152
+ list: async (config) => {
153
+ const { apiKey, projectId, environmentId } = getAndValidateCredentials(config);
154
+ try {
155
+ const mutation = {
156
+ query: GRAPHQL_QUERIES.LIST_SERVICES,
157
+ variables: {
158
+ projectId
159
+ }
160
+ };
161
+ const responseData = await fetchRailway(apiKey, mutation);
162
+ const services = responseData?.project?.services?.edges || [];
163
+ const sandboxes = services.map((edge) => {
164
+ const service = edge.node;
165
+ const railwaySandbox = {
166
+ serviceId: service.id,
167
+ projectId,
168
+ environmentId
169
+ };
170
+ return {
171
+ sandbox: railwaySandbox,
172
+ sandboxId: service.id
173
+ };
174
+ });
175
+ return sandboxes;
176
+ } catch (error) {
177
+ throw new Error(
178
+ `Failed to list Railway sandboxes: ${error instanceof Error ? error.message : String(error)}`
179
+ );
180
+ }
181
+ },
182
+ destroy: async (config, sandboxId) => {
183
+ const { apiKey } = getAndValidateCredentials(config);
184
+ try {
185
+ const mutation = {
186
+ query: GRAPHQL_QUERIES.DELETE_SERVICE,
187
+ variables: {
188
+ id: sandboxId
189
+ }
190
+ };
191
+ const data = await fetchRailway(apiKey, mutation);
192
+ if (data.errors) {
193
+ console.warn(`Railway delete warning: ${data.errors.map((e) => e.message).join(", ")}`);
194
+ }
195
+ } catch (error) {
196
+ console.warn(`Railway destroy warning: ${error instanceof Error ? error.message : String(error)}`);
197
+ }
198
+ },
199
+ // Instance operations (minimal stubs - not implemented yet)
200
+ runCode: async (_sandbox, _code, _runtime) => {
201
+ throw new Error("Railway runCode method not implemented yet");
202
+ },
203
+ runCommand: async (_sandbox, _command, _args, _options) => {
204
+ throw new Error("Railway runCommand method not implemented yet");
205
+ },
206
+ getInfo: async (_sandbox) => {
207
+ throw new Error("Railway getInfo method not implemented yet");
208
+ },
209
+ getUrl: async (_sandbox, _options) => {
210
+ throw new Error("Railway getUrl method not implemented yet");
211
+ }
212
+ }
213
+ }
214
+ });
215
+ // Annotate the CommonJS export names for ESM import in node:
216
+ 0 && (module.exports = {
217
+ fetchRailway,
218
+ getAndValidateCredentials,
219
+ railway
220
+ });
221
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Railway Provider - Factory-based Implementation\n */\n\nimport { createProvider, createBackgroundCommand } from 'computesdk';\nimport type { Runtime, ExecutionResult, SandboxInfo, CreateSandboxOptions, FileEntry, RunCommandOptions } from 'computesdk';\n\n/**\n * Railway sandbox interface\n */\ninterface RailwaySandbox {\n serviceId: string;\n projectId: string;\n environmentId: string;\n}\n\nexport interface RailwayConfig {\n /** Railway API key - if not provided, will fallback to RAILWAY_API_KEY environment variable */\n apiKey?: string;\n /** Railway Project ID */\n projectId?: string;\n /** Railway Environment ID - if not provided, will fallback to RAILWAY_ENVIRONMENT_ID environment variable */\n environmentId?: string;\n}\n\nexport const getAndValidateCredentials = (config: RailwayConfig) => {\n const apiKey = config.apiKey || (typeof process !== 'undefined' && process.env?.RAILWAY_API_KEY) || '';\n const projectId = config.projectId || (typeof process !== 'undefined' && process.env?.RAILWAY_PROJECT_ID) || '';\n const environmentId = config.environmentId || (typeof process !== 'undefined' && process.env?.RAILWAY_ENVIRONMENT_ID) || '';\n\n if (!apiKey) {\n throw new Error(\n 'Missing Railway API key. Provide apiKey in config or set RAILWAY_API_KEY environment variable.'\n );\n }\n\n if (!projectId) {\n throw new Error(\n 'Missing Railway Project ID. Provide projectId in config or set RAILWAY_PROJECT_ID environment variable.'\n );\n }\n\n if (!environmentId) {\n throw new Error(\n 'Missing Railway Environment ID. Provide environmentId in config or set RAILWAY_ENVIRONMENT_ID environment variable.'\n );\n }\n\n return { apiKey, projectId, environmentId };\n};\n\nconst GRAPHQL_QUERIES = {\n CREATE_SERVICE: `mutation ServiceCreate($input: ServiceCreateInput!) { serviceCreate(input: $input) { id name } }`,\n GET_SERVICE: `query Service($serviceId: String!) { service(id: $serviceId) { id name createdAt } }`,\n LIST_SERVICES: `query Project($projectId: String!) { project(id: $projectId) { services { edges { node { id name createdAt updatedAt } } } } }`,\n DELETE_SERVICE: `mutation ServiceDelete($id: String!) { serviceDelete(id: $id) }`\n};\n\nconst handleGraphQLErrors = (data: any) => {\n if (data.errors) {\n throw new Error(`Railway GraphQL error: ${data.errors.map((e: any) => e.message).join(', ')}`);\n }\n};\n\n\nexport const fetchRailway = async (\n apiKey: string, \n mutation: any,\n) => {\n \n const response = await fetch('https://backboard.railway.com/graphql/v2', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${apiKey}`\n },\n body: JSON.stringify(mutation)\n });\n\n if (!response.ok) {\n throw new Error(`Railway API error: ${response.status} ${response.statusText}`);\n }\n\n const data = await response.json();\n\n // Standard error handling for all operations\n handleGraphQLErrors(data);\n\n return data.data;\n};\n\n\n\n/**\n * Create a Railway provider instance using the factory pattern\n */\nexport const railway = createProvider<RailwaySandbox, RailwayConfig>({\n name: 'railway',\n methods: {\n sandbox: {\n // Collection operations (compute.sandbox.*)\n create: async (config: RailwayConfig, options?: CreateSandboxOptions) => {\n const { apiKey, projectId, environmentId } = getAndValidateCredentials(config);\n\n try {\n const mutation = {\n query: GRAPHQL_QUERIES.CREATE_SERVICE,\n variables: {\n input: {\n projectId,\n environmentId,\n source: {\n image: options?.runtime === 'node' ? 'node:alpine' : 'python:alpine'\n }\n }\n }\n };\n\n const responseData = await fetchRailway(apiKey, mutation);\n \n // Extract service from the expected serviceCreate response\n const service = responseData?.serviceCreate;\n \n if (!service) {\n throw new Error('No service returned from Railway API - responseData.serviceCreate is undefined');\n }\n \n if (!service.id) {\n throw new Error(`Service ID is undefined. Full service object: ${JSON.stringify(service, null, 2)}`);\n }\n\n const railwaySandbox: RailwaySandbox = {\n serviceId: service.id,\n projectId,\n environmentId,\n };\n\n return {\n sandbox: railwaySandbox,\n sandboxId: service.id\n };\n } catch (error) {\n throw new Error(\n `Failed to create Railway sandbox: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n getById: async (config: RailwayConfig, sandboxId: string) => {\n const { apiKey, projectId, environmentId } = getAndValidateCredentials(config);\n\n try {\n const mutation = {\n query: GRAPHQL_QUERIES.GET_SERVICE,\n variables: {\n serviceId: sandboxId\n }\n };\n\n const responseData = await fetchRailway(apiKey, mutation);\n \n // If service doesn't exist, fetchRailway returns null when useGetByIdErrorHandling=true\n if (responseData === null) {\n return null;\n }\n \n const service = responseData?.service;\n \n // Service should be defined if we get here (non-existent services return null above)\n if (!service) {\n throw new Error('Service data is missing from Railway response');\n }\n const railwaySandbox: RailwaySandbox = {\n serviceId: service.id,\n projectId,\n environmentId,\n };\n\n return {\n sandbox: railwaySandbox,\n sandboxId: service.id\n };\n } catch (error) {\n throw new Error(\n `Failed to get Railway sandbox: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n \n list: async (config: RailwayConfig) => {\n const { apiKey, projectId, environmentId } = getAndValidateCredentials(config);\n\n try {\n const mutation = {\n query: GRAPHQL_QUERIES.LIST_SERVICES,\n variables: {\n projectId\n }\n };\n\n const responseData = await fetchRailway(apiKey, mutation);\n \n // Extract services from the project.services.edges structure\n const services = responseData?.project?.services?.edges || [];\n \n // Transform each service into the expected format\n const sandboxes = services.map((edge: any) => {\n const service = edge.node;\n const railwaySandbox: RailwaySandbox = {\n serviceId: service.id,\n projectId,\n environmentId,\n };\n\n return {\n sandbox: railwaySandbox,\n sandboxId: service.id\n };\n });\n\n return sandboxes;\n } catch (error) {\n throw new Error(\n `Failed to list Railway sandboxes: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n destroy: async (config: RailwayConfig, sandboxId: string) => {\n const { apiKey } = getAndValidateCredentials(config);\n\n try {\n const mutation = {\n query: GRAPHQL_QUERIES.DELETE_SERVICE,\n variables: {\n id: sandboxId\n }\n };\n\n const data = await fetchRailway(apiKey, mutation);\n \n if (data.errors) {\n // Log errors but don't throw for destroy operations\n console.warn(`Railway delete warning: ${data.errors.map((e: any) => e.message).join(', ')}`);\n }\n } catch (error) {\n // For destroy operations, we typically don't throw if the service is already gone\n console.warn(`Railway destroy warning: ${error instanceof Error ? error.message : String(error)}`);\n }\n },\n\n // Instance operations (minimal stubs - not implemented yet)\n runCode: async (_sandbox: RailwaySandbox, _code: string, _runtime?: Runtime) => {\n throw new Error('Railway runCode method not implemented yet');\n },\n\n runCommand: async (_sandbox: RailwaySandbox, _command: string, _args?: string[], _options?: RunCommandOptions) => {\n throw new Error('Railway runCommand method not implemented yet');\n },\n\n getInfo: async (_sandbox: RailwaySandbox) => {\n throw new Error('Railway getInfo method not implemented yet');\n },\n\n getUrl: async (_sandbox: RailwaySandbox, _options: { port: number; protocol?: string }) => {\n throw new Error('Railway getUrl method not implemented yet');\n },\n\n },\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,wBAAwD;AAqBjD,IAAM,4BAA4B,CAAC,WAA0B;AAClE,QAAM,SAAS,OAAO,UAAW,OAAO,YAAY,eAAe,QAAQ,KAAK,mBAAoB;AACpG,QAAM,YAAY,OAAO,aAAc,OAAO,YAAY,eAAe,QAAQ,KAAK,sBAAuB;AAC7G,QAAM,gBAAgB,OAAO,iBAAkB,OAAO,YAAY,eAAe,QAAQ,KAAK,0BAA2B;AAEzH,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,MAAI,CAAC,WAAW;AACd,UAAM,IAAI;AAAA,MACR;A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S,OAAO,UAA0B,OAAe,aAAuB;AAC9E,cAAM,IAAI,MAAM,4CAA4C;AAAA,MAC9D;AAAA,MAEA,YAAY,OAAO,UAA0B,UAAkB,OAAkB,aAAiC;AAChH,cAAM,IAAI,MAAM,+CAA+C;AAAA,MACjE;AAAA,MAEA,SAAS,OAAO,aAA6B;AAC3C,cAAM,IAAI,MAAM,4CAA4C;AAAA,MAC9D;AAAA,MAEA,QAAQ,OAAO,UAA0B,aAAkD;AACzF,cAAM,IAAI,MAAM,2CAA2C;AAAA,MAC7D;AAAA,IAEF;AAAA,EACF;AACF,CAAC;","names":[]}
package/dist/index.mjs ADDED
@@ -0,0 +1,194 @@
1
+ // src/index.ts
2
+ import { createProvider } from "computesdk";
3
+ var getAndValidateCredentials = (config) => {
4
+ const apiKey = config.apiKey || typeof process !== "undefined" && process.env?.RAILWAY_API_KEY || "";
5
+ const projectId = config.projectId || typeof process !== "undefined" && process.env?.RAILWAY_PROJECT_ID || "";
6
+ const environmentId = config.environmentId || typeof process !== "undefined" && process.env?.RAILWAY_ENVIRONMENT_ID || "";
7
+ if (!apiKey) {
8
+ throw new Error(
9
+ "Missing Railway API key. Provide apiKey in config or set RAILWAY_API_KEY environment variable."
10
+ );
11
+ }
12
+ if (!projectId) {
13
+ throw new Error(
14
+ "Missing Railway Project ID. Provide projectId in config or set RAILWAY_PROJECT_ID environment variable."
15
+ );
16
+ }
17
+ if (!environmentId) {
18
+ throw new Error(
19
+ "Missing Railway Environment ID. Provide environmentId in config or set RAILWAY_ENVIRONMENT_ID environment variable."
20
+ );
21
+ }
22
+ return { apiKey, projectId, environmentId };
23
+ };
24
+ var GRAPHQL_QUERIES = {
25
+ CREATE_SERVICE: `mutation ServiceCreate($input: ServiceCreateInput!) { serviceCreate(input: $input) { id name } }`,
26
+ GET_SERVICE: `query Service($serviceId: String!) { service(id: $serviceId) { id name createdAt } }`,
27
+ LIST_SERVICES: `query Project($projectId: String!) { project(id: $projectId) { services { edges { node { id name createdAt updatedAt } } } } }`,
28
+ DELETE_SERVICE: `mutation ServiceDelete($id: String!) { serviceDelete(id: $id) }`
29
+ };
30
+ var handleGraphQLErrors = (data) => {
31
+ if (data.errors) {
32
+ throw new Error(`Railway GraphQL error: ${data.errors.map((e) => e.message).join(", ")}`);
33
+ }
34
+ };
35
+ var fetchRailway = async (apiKey, mutation) => {
36
+ const response = await fetch("https://backboard.railway.com/graphql/v2", {
37
+ method: "POST",
38
+ headers: {
39
+ "Content-Type": "application/json",
40
+ "Authorization": `Bearer ${apiKey}`
41
+ },
42
+ body: JSON.stringify(mutation)
43
+ });
44
+ if (!response.ok) {
45
+ throw new Error(`Railway API error: ${response.status} ${response.statusText}`);
46
+ }
47
+ const data = await response.json();
48
+ handleGraphQLErrors(data);
49
+ return data.data;
50
+ };
51
+ var railway = createProvider({
52
+ name: "railway",
53
+ methods: {
54
+ sandbox: {
55
+ // Collection operations (compute.sandbox.*)
56
+ create: async (config, options) => {
57
+ const { apiKey, projectId, environmentId } = getAndValidateCredentials(config);
58
+ try {
59
+ const mutation = {
60
+ query: GRAPHQL_QUERIES.CREATE_SERVICE,
61
+ variables: {
62
+ input: {
63
+ projectId,
64
+ environmentId,
65
+ source: {
66
+ image: options?.runtime === "node" ? "node:alpine" : "python:alpine"
67
+ }
68
+ }
69
+ }
70
+ };
71
+ const responseData = await fetchRailway(apiKey, mutation);
72
+ const service = responseData?.serviceCreate;
73
+ if (!service) {
74
+ throw new Error("No service returned from Railway API - responseData.serviceCreate is undefined");
75
+ }
76
+ if (!service.id) {
77
+ throw new Error(`Service ID is undefined. Full service object: ${JSON.stringify(service, null, 2)}`);
78
+ }
79
+ const railwaySandbox = {
80
+ serviceId: service.id,
81
+ projectId,
82
+ environmentId
83
+ };
84
+ return {
85
+ sandbox: railwaySandbox,
86
+ sandboxId: service.id
87
+ };
88
+ } catch (error) {
89
+ throw new Error(
90
+ `Failed to create Railway sandbox: ${error instanceof Error ? error.message : String(error)}`
91
+ );
92
+ }
93
+ },
94
+ getById: async (config, sandboxId) => {
95
+ const { apiKey, projectId, environmentId } = getAndValidateCredentials(config);
96
+ try {
97
+ const mutation = {
98
+ query: GRAPHQL_QUERIES.GET_SERVICE,
99
+ variables: {
100
+ serviceId: sandboxId
101
+ }
102
+ };
103
+ const responseData = await fetchRailway(apiKey, mutation);
104
+ if (responseData === null) {
105
+ return null;
106
+ }
107
+ const service = responseData?.service;
108
+ if (!service) {
109
+ throw new Error("Service data is missing from Railway response");
110
+ }
111
+ const railwaySandbox = {
112
+ serviceId: service.id,
113
+ projectId,
114
+ environmentId
115
+ };
116
+ return {
117
+ sandbox: railwaySandbox,
118
+ sandboxId: service.id
119
+ };
120
+ } catch (error) {
121
+ throw new Error(
122
+ `Failed to get Railway sandbox: ${error instanceof Error ? error.message : String(error)}`
123
+ );
124
+ }
125
+ },
126
+ list: async (config) => {
127
+ const { apiKey, projectId, environmentId } = getAndValidateCredentials(config);
128
+ try {
129
+ const mutation = {
130
+ query: GRAPHQL_QUERIES.LIST_SERVICES,
131
+ variables: {
132
+ projectId
133
+ }
134
+ };
135
+ const responseData = await fetchRailway(apiKey, mutation);
136
+ const services = responseData?.project?.services?.edges || [];
137
+ const sandboxes = services.map((edge) => {
138
+ const service = edge.node;
139
+ const railwaySandbox = {
140
+ serviceId: service.id,
141
+ projectId,
142
+ environmentId
143
+ };
144
+ return {
145
+ sandbox: railwaySandbox,
146
+ sandboxId: service.id
147
+ };
148
+ });
149
+ return sandboxes;
150
+ } catch (error) {
151
+ throw new Error(
152
+ `Failed to list Railway sandboxes: ${error instanceof Error ? error.message : String(error)}`
153
+ );
154
+ }
155
+ },
156
+ destroy: async (config, sandboxId) => {
157
+ const { apiKey } = getAndValidateCredentials(config);
158
+ try {
159
+ const mutation = {
160
+ query: GRAPHQL_QUERIES.DELETE_SERVICE,
161
+ variables: {
162
+ id: sandboxId
163
+ }
164
+ };
165
+ const data = await fetchRailway(apiKey, mutation);
166
+ if (data.errors) {
167
+ console.warn(`Railway delete warning: ${data.errors.map((e) => e.message).join(", ")}`);
168
+ }
169
+ } catch (error) {
170
+ console.warn(`Railway destroy warning: ${error instanceof Error ? error.message : String(error)}`);
171
+ }
172
+ },
173
+ // Instance operations (minimal stubs - not implemented yet)
174
+ runCode: async (_sandbox, _code, _runtime) => {
175
+ throw new Error("Railway runCode method not implemented yet");
176
+ },
177
+ runCommand: async (_sandbox, _command, _args, _options) => {
178
+ throw new Error("Railway runCommand method not implemented yet");
179
+ },
180
+ getInfo: async (_sandbox) => {
181
+ throw new Error("Railway getInfo method not implemented yet");
182
+ },
183
+ getUrl: async (_sandbox, _options) => {
184
+ throw new Error("Railway getUrl method not implemented yet");
185
+ }
186
+ }
187
+ }
188
+ });
189
+ export {
190
+ fetchRailway,
191
+ getAndValidateCredentials,
192
+ railway
193
+ };
194
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Railway Provider - Factory-based Implementation\n */\n\nimport { createProvider, createBackgroundCommand } from 'computesdk';\nimport type { Runtime, ExecutionResult, SandboxInfo, CreateSandboxOptions, FileEntry, RunCommandOptions } from 'computesdk';\n\n/**\n * Railway sandbox interface\n */\ninterface RailwaySandbox {\n serviceId: string;\n projectId: string;\n environmentId: string;\n}\n\nexport interface RailwayConfig {\n /** Railway API key - if not provided, will fallback to RAILWAY_API_KEY environment variable */\n apiKey?: string;\n /** Railway Project ID */\n projectId?: string;\n /** Railway Environment ID - if not provided, will fallback to RAILWAY_ENVIRONMENT_ID environment variable */\n environmentId?: string;\n}\n\nexport const getAndValidateCredentials = (config: RailwayConfig) => {\n const apiKey = config.apiKey || (typeof process !== 'undefined' && process.env?.RAILWAY_API_KEY) || '';\n const projectId = config.projectId || (typeof process !== 'undefined' && process.env?.RAILWAY_PROJECT_ID) || '';\n const environmentId = config.environmentId || (typeof process !== 'undefined' && process.env?.RAILWAY_ENVIRONMENT_ID) || '';\n\n if (!apiKey) {\n throw new Error(\n 'Missing Railway API key. Provide apiKey in config or set RAILWAY_API_KEY environment variable.'\n );\n }\n\n if (!projectId) {\n throw new Error(\n 'Missing Railway Project ID. Provide projectId in config or set RAILWAY_PROJECT_ID environment variable.'\n );\n }\n\n if (!environmentId) {\n throw new Error(\n 'Missing Railway Environment ID. Provide environmentId in config or set RAILWAY_ENVIRONMENT_ID environment variable.'\n );\n }\n\n return { apiKey, projectId, environmentId };\n};\n\nconst GRAPHQL_QUERIES = {\n CREATE_SERVICE: `mutation ServiceCreate($input: ServiceCreateInput!) { serviceCreate(input: $input) { id name } }`,\n GET_SERVICE: `query Service($serviceId: String!) { service(id: $serviceId) { id name createdAt } }`,\n LIST_SERVICES: `query Project($projectId: String!) { project(id: $projectId) { services { edges { node { id name createdAt updatedAt } } } } }`,\n DELETE_SERVICE: `mutation ServiceDelete($id: String!) { serviceDelete(id: $id) }`\n};\n\nconst handleGraphQLErrors = (data: any) => {\n if (data.errors) {\n throw new Error(`Railway GraphQL error: ${data.errors.map((e: any) => e.message).join(', ')}`);\n }\n};\n\n\nexport const fetchRailway = async (\n apiKey: string, \n mutation: any,\n) => {\n \n const response = await fetch('https://backboard.railway.com/graphql/v2', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${apiKey}`\n },\n body: JSON.stringify(mutation)\n });\n\n if (!response.ok) {\n throw new Error(`Railway API error: ${response.status} ${response.statusText}`);\n }\n\n const data = await response.json();\n\n // Standard error handling for all operations\n handleGraphQLErrors(data);\n\n return data.data;\n};\n\n\n\n/**\n * Create a Railway provider instance using the factory pattern\n */\nexport const railway = createProvider<RailwaySandbox, RailwayConfig>({\n name: 'railway',\n methods: {\n sandbox: {\n // Collection operations (compute.sandbox.*)\n create: async (config: RailwayConfig, options?: CreateSandboxOptions) => {\n const { apiKey, projectId, environmentId } = getAndValidateCredentials(config);\n\n try {\n const mutation = {\n query: GRAPHQL_QUERIES.CREATE_SERVICE,\n variables: {\n input: {\n projectId,\n environmentId,\n source: {\n image: options?.runtime === 'node' ? 'node:alpine' : 'python:alpine'\n }\n }\n }\n };\n\n const responseData = await fetchRailway(apiKey, mutation);\n \n // Extract service from the expected serviceCreate response\n const service = responseData?.serviceCreate;\n \n if (!service) {\n throw new Error('No service returned from Railway API - responseData.serviceCreate is undefined');\n }\n \n if (!service.id) {\n throw new Error(`Service ID is undefined. Full service object: ${JSON.stringify(service, null, 2)}`);\n }\n\n const railwaySandbox: RailwaySandbox = {\n serviceId: service.id,\n projectId,\n environmentId,\n };\n\n return {\n sandbox: railwaySandbox,\n sandboxId: service.id\n };\n } catch (error) {\n throw new Error(\n `Failed to create Railway sandbox: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n getById: async (config: RailwayConfig, sandboxId: string) => {\n const { apiKey, projectId, environmentId } = getAndValidateCredentials(config);\n\n try {\n const mutation = {\n query: GRAPHQL_QUERIES.GET_SERVICE,\n variables: {\n serviceId: sandboxId\n }\n };\n\n const responseData = await fetchRailway(apiKey, mutation);\n \n // If service doesn't exist, fetchRailway returns null when useGetByIdErrorHandling=true\n if (responseData === null) {\n return null;\n }\n \n const service = responseData?.service;\n \n // Service should be defined if we get here (non-existent services return null above)\n if (!service) {\n throw new Error('Service data is missing from Railway response');\n }\n const railwaySandbox: RailwaySandbox = {\n serviceId: service.id,\n projectId,\n environmentId,\n };\n\n return {\n sandbox: railwaySandbox,\n sandboxId: service.id\n };\n } catch (error) {\n throw new Error(\n `Failed to get Railway sandbox: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n \n list: async (config: RailwayConfig) => {\n const { apiKey, projectId, environmentId } = getAndValidateCredentials(config);\n\n try {\n const mutation = {\n query: GRAPHQL_QUERIES.LIST_SERVICES,\n variables: {\n projectId\n }\n };\n\n const responseData = await fetchRailway(apiKey, mutation);\n \n // Extract services from the project.services.edges structure\n const services = responseData?.project?.services?.edges || [];\n \n // Transform each service into the expected format\n const sandboxes = services.map((edge: any) => {\n const service = edge.node;\n const railwaySandbox: RailwaySandbox = {\n serviceId: service.id,\n projectId,\n environmentId,\n };\n\n return {\n sandbox: railwaySandbox,\n sandboxId: service.id\n };\n });\n\n return sandboxes;\n } catch (error) {\n throw new Error(\n `Failed to list Railway sandboxes: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n destroy: async (config: RailwayConfig, sandboxId: string) => {\n const { apiKey } = getAndValidateCredentials(config);\n\n try {\n const mutation = {\n query: GRAPHQL_QUERIES.DELETE_SERVICE,\n variables: {\n id: sandboxId\n }\n };\n\n const data = await fetchRailway(apiKey, mutation);\n \n if (data.errors) {\n // Log errors but don't throw for destroy operations\n console.warn(`Railway delete warning: ${data.errors.map((e: any) => e.message).join(', ')}`);\n }\n } catch (error) {\n // For destroy operations, we typically don't throw if the service is already gone\n console.warn(`Railway destroy warning: ${error instanceof Error ? error.message : String(error)}`);\n }\n },\n\n // Instance operations (minimal stubs - not implemented yet)\n runCode: async (_sandbox: RailwaySandbox, _code: string, _runtime?: Runtime) => {\n throw new Error('Railway runCode method not implemented yet');\n },\n\n runCommand: async (_sandbox: RailwaySandbox, _command: string, _args?: string[], _options?: RunCommandOptions) => {\n throw new Error('Railway runCommand method not implemented yet');\n },\n\n getInfo: async (_sandbox: RailwaySandbox) => {\n throw new Error('Railway getInfo method not implemented yet');\n },\n\n getUrl: async (_sandbox: RailwaySandbox, _options: { port: number; protocol?: string }) => {\n throw new Error('Railway getUrl method not implemented yet');\n },\n\n },\n },\n});\n"],"mappings":";AAIA,SAAS,sBAA+C;AAqBjD,IAAM,4BAA4B,CAAC,WAA0B;AAClE,QAAM,SAAS,OAAO,UAAW,OAAO,YAAY,eAAe,QAAQ,KAAK,mBAAoB;AACpG,QAAM,YAAY,OAAO,aAAc,OAAO,YAAY,eAAe,QAAQ,KAAK,sBAAuB;AAC7G,QAAM,gBAAgB,OAAO,iBAAkB,OAAO,YAAY,eAAe,QAAQ,KAAK,0BAA2B;AAEzH,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI;AAAA,MACR;AAAA,IAC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O,KAAK,CAAC,EAAE;AAAA,QACnG;AAAA,MACF;AAAA;AAAA,MAGA,SAAS,OAAO,UAA0B,OAAe,aAAuB;AAC9E,cAAM,IAAI,MAAM,4CAA4C;AAAA,MAC9D;AAAA,MAEA,YAAY,OAAO,UAA0B,UAAkB,OAAkB,aAAiC;AAChH,cAAM,IAAI,MAAM,+CAA+C;AAAA,MACjE;AAAA,MAEA,SAAS,OAAO,aAA6B;AAC3C,cAAM,IAAI,MAAM,4CAA4C;AAAA,MAC9D;AAAA,MAEA,QAAQ,OAAO,UAA0B,aAAkD;AACzF,cAAM,IAAI,MAAM,2CAA2C;AAAA,MAC7D;AAAA,IAEF;AAAA,EACF;AACF,CAAC;","names":[]}
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@computesdk/railway",
3
+ "version": "1.0.0",
4
+ "description": "Railway provider for ComputeSDK",
5
+ "author": "ComputeSDK Team",
6
+ "license": "MIT",
7
+ "main": "./dist/index.js",
8
+ "module": "./dist/index.mjs",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.mjs",
14
+ "require": "./dist/index.js"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "dependencies": {
21
+ "computesdk": "1.8.6"
22
+ },
23
+ "keywords": [
24
+ "railway",
25
+ "sandbox",
26
+ "code-execution",
27
+ "cloud",
28
+ "compute",
29
+ "containers"
30
+ ],
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "https://github.com/computesdk/computesdk.git",
34
+ "directory": "packages/railway"
35
+ },
36
+ "homepage": "https://github.com/computesdk/computesdk/tree/main/packages/railway",
37
+ "bugs": {
38
+ "url": "https://github.com/computesdk/computesdk/issues"
39
+ },
40
+ "devDependencies": {
41
+ "@types/node": "^20.0.0",
42
+ "@vitest/coverage-v8": "^1.0.0",
43
+ "eslint": "^8.37.0",
44
+ "rimraf": "^5.0.0",
45
+ "tsup": "^8.0.0",
46
+ "typescript": "^5.0.0",
47
+ "vitest": "^1.0.0",
48
+ "@computesdk/test-utils": "1.4.1"
49
+ },
50
+ "scripts": {
51
+ "build": "tsup",
52
+ "clean": "rimraf dist",
53
+ "dev": "tsup --watch",
54
+ "test": "vitest run",
55
+ "test:watch": "vitest watch",
56
+ "test:coverage": "vitest run --coverage",
57
+ "typecheck": "tsc --noEmit",
58
+ "lint": "eslint"
59
+ }
60
+ }