@positronic/spec 0.0.2

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/src/index.ts ADDED
@@ -0,0 +1,136 @@
1
+ /**
2
+ * @positronic/spec
3
+ *
4
+ * This package contains:
5
+ * - Interface specifications for Positronic implementations
6
+ * - Conformance test suites
7
+ * - Shared types and contracts
8
+ *
9
+ * Currently includes the PositronicDevServer interface.
10
+ * Future additions will include REST API specifications and tests.
11
+ */
12
+
13
+ /**
14
+ * Handle for managing a running development server
15
+ *
16
+ * This interface provides lifecycle management for a server instance,
17
+ * abstracting away the underlying implementation details (process, worker, etc.)
18
+ */
19
+ export interface ServerHandle {
20
+ /**
21
+ * Register a callback to be called when the server closes
22
+ * @param callback Function called with exit code when server terminates
23
+ */
24
+ onClose(callback: (code?: number | null) => void): void;
25
+
26
+ /**
27
+ * Register a callback to be called when the server encounters an error
28
+ * @param callback Function called with error details
29
+ */
30
+ onError(callback: (error: Error) => void): void;
31
+
32
+ /**
33
+ * Stop the server
34
+ * @param signal Optional signal to send (e.g., 'SIGTERM', 'SIGKILL')
35
+ * @returns true if the kill signal was sent successfully
36
+ */
37
+ kill(signal?: string): boolean;
38
+
39
+ /**
40
+ * Whether the server has been killed
41
+ */
42
+ readonly killed: boolean;
43
+
44
+ /**
45
+ * Wait until the server is ready to accept requests
46
+ * @param maxWaitMs Maximum time to wait in milliseconds
47
+ * @returns true if server is ready, false if timeout reached
48
+ */
49
+ waitUntilReady(maxWaitMs?: number): Promise<boolean>;
50
+ }
51
+
52
+ /**
53
+ * Development server interface for Positronic backends
54
+ *
55
+ * This interface is used by the Positronic CLI to manage local development servers.
56
+ */
57
+ export interface PositronicDevServer {
58
+ /**
59
+ * The root path of the Positronic project
60
+ */
61
+ readonly projectRootDir: string;
62
+
63
+ /**
64
+ * Setup the development environment (e.g., create .positronic directory)
65
+ * This is called once when setting up a project or when --force is used
66
+ * @param force Force regeneration even if environment exists
67
+ */
68
+ setup(force?: boolean): Promise<void>;
69
+
70
+ /**
71
+ * Start the development server
72
+ * @param port Optional port number
73
+ * @returns A handle for managing the running server
74
+ */
75
+ start(port?: number): Promise<ServerHandle>;
76
+
77
+ /**
78
+ * Optional: Watch for brain file changes and handle them
79
+ * This is called by the CLI when brain files (*.ts in brains/) change
80
+ * @param filePath The path to the brain file that changed
81
+ * @param event The type of change that occurred
82
+ */
83
+ watch?(filePath: string, event: 'add' | 'change' | 'unlink'): Promise<void>;
84
+
85
+ /**
86
+ * Optional: Deploy to the backend's hosting service
87
+ * @param config Deployment configuration
88
+ */
89
+ deploy(config?: any): Promise<void>;
90
+
91
+ /**
92
+ * Register a callback for log messages
93
+ * @param callback Function called with log messages
94
+ */
95
+ onLog(callback: (message: string) => void): void;
96
+
97
+ /**
98
+ * Register a callback for error messages
99
+ * @param callback Function called with error messages
100
+ */
101
+ onError(callback: (message: string) => void): void;
102
+
103
+ /**
104
+ * Register a callback for warning messages
105
+ * @param callback Function called with warning messages
106
+ */
107
+ onWarning(callback: (message: string) => void): void;
108
+
109
+ /**
110
+ * List all secrets for the current environment
111
+ * @returns Array of secret names with optional metadata
112
+ */
113
+ listSecrets?(): Promise<Array<{ name: string; createdAt?: Date; updatedAt?: Date }>>;
114
+
115
+ /**
116
+ * Set or update a secret
117
+ * @param name Secret name (must be valid environment variable name)
118
+ * @param value Secret value
119
+ */
120
+ setSecret?(name: string, value: string): Promise<void>;
121
+
122
+ /**
123
+ * Delete a secret
124
+ * @param name Secret name
125
+ * @returns true if deleted, false if not found
126
+ */
127
+ deleteSecret?(name: string): Promise<boolean>;
128
+
129
+ /**
130
+ * Bulk upload secrets from a .env file to the backend.
131
+ * @param filePath Path to the .env file
132
+ */
133
+ bulkSecrets(filePath: string): Promise<void>;
134
+ }
135
+
136
+ export { testStatus, resources, brains, schedules, secrets } from './api.js';
package/tsconfig.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "rootDir": "./src",
5
+ "outDir": "./dist",
6
+ "declaration": true,
7
+ "declarationMap": true
8
+ },
9
+ "include": ["src/**/*"],
10
+ "exclude": ["node_modules", "dist", "src/**/*.test.ts"]
11
+ }