@newhomestar/sdk 0.4.3 → 0.4.4

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.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { z, type ZodTypeAny } from "zod";
2
+ import type { IncomingMessage, ServerResponse } from "node:http";
2
3
  export interface ActionDef<I extends ZodTypeAny, O extends ZodTypeAny> {
3
4
  name: string;
4
5
  input: I;
@@ -54,10 +55,9 @@ export interface ORPCServerOptions {
54
55
  plugins?: any[];
55
56
  }
56
57
  /**
57
- * Run an oRPC server with OpenAPI support - the modern Nova server!
58
- * Note: Simplified version for ESM compatibility
58
+ * Run an official oRPC server - fully compliant with oRPC standards!
59
59
  */
60
- export declare function runORPCServer<T extends WorkerDef>(def: T, options?: ORPCServerOptions): void;
60
+ export declare function runORPCServer<T extends WorkerDef>(def: T, options?: ORPCServerOptions): import("http").Server<typeof IncomingMessage, typeof ServerResponse>;
61
61
  export declare function runWorker(def: WorkerDef): Promise<void>;
62
62
  export declare function generateOpenAPISpec<T extends WorkerDef>(def: T): Promise<{
63
63
  openapi: string;
package/dist/index.js CHANGED
@@ -13,6 +13,8 @@ import { OpenFgaClient } from "@openfga/sdk";
13
13
  import { createServer } from "node:http";
14
14
  // Full oRPC imports now working with ESM
15
15
  import { os } from "@orpc/server";
16
+ import { RPCHandler } from "@orpc/server/node";
17
+ import { CORSPlugin } from "@orpc/server/plugins";
16
18
  import { OpenAPIHandler } from "@orpc/openapi/fetch";
17
19
  if (!process.env.RUNTIME_SUPABASE_URL) {
18
20
  // local dev – read .env.local
@@ -82,15 +84,36 @@ export function createORPCRouter(def) {
82
84
  return procedures;
83
85
  }
84
86
  /**
85
- * Run an oRPC server with OpenAPI support - the modern Nova server!
86
- * Note: Simplified version for ESM compatibility
87
+ * Run an official oRPC server - fully compliant with oRPC standards!
87
88
  */
88
89
  export function runORPCServer(def, options = {}) {
89
90
  const router = createORPCRouter(def);
90
- // For now, use the enhanced HTTP server as fallback until oRPC integration is fully complete
91
- console.log(`[nova] Starting oRPC-enhanced server "${def.name}"`);
92
- console.log(`[nova] Note: Full oRPC integration available, using enhanced HTTP server for compatibility`);
93
- return runHttpServer(def, { port: options.port });
91
+ console.log(`[nova] Starting official oRPC server "${def.name}"`);
92
+ // Use official oRPC serving pattern
93
+ const handler = new RPCHandler(router, {
94
+ plugins: [new CORSPlugin(), ...(options.plugins || [])]
95
+ });
96
+ const server = createServer(async (req, res) => {
97
+ const result = await handler.handle(req, res, {
98
+ context: {
99
+ headers: req.headers,
100
+ jobId: `orpc-${Date.now()}`,
101
+ // Add any other Nova-specific context
102
+ }
103
+ });
104
+ if (!result.matched) {
105
+ res.statusCode = 404;
106
+ res.end('No procedure matched');
107
+ }
108
+ });
109
+ const port = options.port ?? (process.env.PORT ? parseInt(process.env.PORT) : 8000);
110
+ server.listen(port, () => {
111
+ console.log(`[nova] Official oRPC server listening on http://localhost:${port}`);
112
+ console.log(`[nova] Available procedures: ${Object.keys(def.actions).join(', ')}`);
113
+ console.log(`[nova] 🔥 RPC protocol: ACTIVE (not HTTP fallback)`);
114
+ console.log(`[nova] 🌐 CORS: Enabled via CORSPlugin`);
115
+ });
116
+ return server;
94
117
  }
95
118
  /*──────────────── Runtime harness (Supabase RPC) - UNCHANGED ───────────────*/
96
119
  const RUNTIME_SUPABASE_URL = process.env.RUNTIME_SUPABASE_URL;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newhomestar/sdk",
3
- "version": "0.4.3",
3
+ "version": "0.4.4",
4
4
  "description": "Type-safe SDK for building Nova pipelines (workers & functions)",
5
5
  "homepage": "https://github.com/newhomestar/nova-node-sdk#readme",
6
6
  "bugs": {