@newhomestar/sdk 0.4.7 → 0.4.8

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
@@ -13,6 +13,32 @@ export interface ActionDef<I extends ZodTypeAny, O extends ZodTypeAny> {
13
13
  };
14
14
  method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
15
15
  path?: string;
16
+ capabilities?: Array<{
17
+ type: 'webhook';
18
+ eventTypes: string[];
19
+ source: string;
20
+ endpoint?: string;
21
+ headers?: Record<string, string>;
22
+ authentication?: {
23
+ type: 'bearer' | 'basic' | 'api_key' | 'signature';
24
+ config?: Record<string, any>;
25
+ };
26
+ } | {
27
+ type: 'scheduled';
28
+ cron: string;
29
+ timezone?: string;
30
+ description?: string;
31
+ } | {
32
+ type: 'queue';
33
+ topics: string[];
34
+ queueName?: string;
35
+ consumerGroup?: string;
36
+ } | {
37
+ type: 'stream';
38
+ streamName: string;
39
+ eventTypes?: string[];
40
+ consumerGroup?: string;
41
+ }>;
16
42
  }
17
43
  export interface ActionCtx {
18
44
  jobId: string;
@@ -30,6 +56,32 @@ export declare function action<I extends ZodTypeAny, O extends ZodTypeAny>(cfg:
30
56
  };
31
57
  method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
32
58
  path?: string;
59
+ capabilities?: Array<{
60
+ type: 'webhook';
61
+ eventTypes: string[];
62
+ source: string;
63
+ endpoint?: string;
64
+ headers?: Record<string, string>;
65
+ authentication?: {
66
+ type: 'bearer' | 'basic' | 'api_key' | 'signature';
67
+ config?: Record<string, any>;
68
+ };
69
+ } | {
70
+ type: 'scheduled';
71
+ cron: string;
72
+ timezone?: string;
73
+ description?: string;
74
+ } | {
75
+ type: 'queue';
76
+ topics: string[];
77
+ queueName?: string;
78
+ consumerGroup?: string;
79
+ } | {
80
+ type: 'stream';
81
+ streamName: string;
82
+ eventTypes?: string[];
83
+ consumerGroup?: string;
84
+ }>;
33
85
  handler: (input: z.infer<I>, ctx: ActionCtx) => Promise<z.infer<O>>;
34
86
  }): ActionDef<I, O>;
35
87
  import type { NovaSpec } from './parseSpec.js';
@@ -77,16 +129,33 @@ export declare function runHttpServer<T extends WorkerDef>(def: T, opts?: {
77
129
  export type { ZodTypeAny as SchemaAny, ZodTypeAny };
78
130
  export { parseNovaSpec } from "./parseSpec.js";
79
131
  export type { NovaSpec } from "./parseSpec.js";
80
- import { parseNovaSpec as parseNovaSpecFunction } from "./parseSpec.js";
81
- declare const _default: {
82
- defineWorker: typeof defineWorker;
83
- action: typeof action;
84
- enqueue: typeof enqueue;
85
- runHttpServer: typeof runHttpServer;
86
- runORPCServer: typeof runORPCServer;
87
- runWorker: typeof runWorker;
88
- generateOpenAPISpec: typeof generateOpenAPISpec;
89
- createORPCRouter: typeof createORPCRouter;
90
- parseNovaSpec: typeof parseNovaSpecFunction;
132
+ export type WebhookCapability = {
133
+ type: 'webhook';
134
+ eventTypes: string[];
135
+ source: string;
136
+ endpoint?: string;
137
+ headers?: Record<string, string>;
138
+ authentication?: {
139
+ type: 'bearer' | 'basic' | 'api_key' | 'signature';
140
+ config?: Record<string, any>;
141
+ };
142
+ };
143
+ export type ScheduledCapability = {
144
+ type: 'scheduled';
145
+ cron: string;
146
+ timezone?: string;
147
+ description?: string;
148
+ };
149
+ export type QueueCapability = {
150
+ type: 'queue';
151
+ topics: string[];
152
+ queueName?: string;
153
+ consumerGroup?: string;
154
+ };
155
+ export type StreamCapability = {
156
+ type: 'stream';
157
+ streamName: string;
158
+ eventTypes?: string[];
159
+ consumerGroup?: string;
91
160
  };
92
- export default _default;
161
+ export type Capability = WebhookCapability | ScheduledCapability | QueueCapability | StreamCapability;
package/dist/index.js CHANGED
@@ -1,3 +1,12 @@
1
+ // nova-sdk-esm – Modern ESM Nova SDK with full oRPC integration (v0.4.2)
2
+ // =====================================================
3
+ // 1. Public API – action(), defineWorker(), enqueue() - SAME AS BEFORE
4
+ // 2. Enhanced HTTP server with REST endpoints and custom routing
5
+ // 3. Full oRPC integration with OpenAPI spec generation
6
+ // 4. Runtime harness for *worker* pipelines using Supabase RPC
7
+ // 5. Modern ESM architecture for future compatibility
8
+ // -----------------------------------------------------------
9
+ import { z } from "zod";
1
10
  import dotenv from "dotenv";
2
11
  import { createClient } from "@supabase/supabase-js";
3
12
  import { OpenFgaClient } from "@openfga/sdk";
@@ -6,6 +15,7 @@ import { createServer } from "node:http";
6
15
  import { os } from "@orpc/server";
7
16
  import { RPCHandler } from "@orpc/server/node";
8
17
  import { CORSPlugin } from "@orpc/server/plugins";
18
+ import { OpenAPIHandler } from "@orpc/openapi/fetch";
9
19
  if (!process.env.RUNTIME_SUPABASE_URL) {
10
20
  // local dev – read .env.local
11
21
  dotenv.config({ path: ".env.local", override: true });
@@ -294,16 +304,3 @@ export function runHttpServer(def, opts = {}) {
294
304
  }
295
305
  // YAML spec parsing utility
296
306
  export { parseNovaSpec } from "./parseSpec.js";
297
- // Default export for compatibility
298
- import { parseNovaSpec as parseNovaSpecFunction } from "./parseSpec.js";
299
- export default {
300
- defineWorker,
301
- action,
302
- enqueue,
303
- runHttpServer,
304
- runORPCServer,
305
- runWorker,
306
- generateOpenAPISpec,
307
- createORPCRouter,
308
- parseNovaSpec: parseNovaSpecFunction
309
- };
@@ -43,7 +43,69 @@ export declare const NovaSpecSchema: z.ZodObject<{
43
43
  resourceType: z.ZodString;
44
44
  relation: z.ZodString;
45
45
  }, z.core.$strip>>;
46
+ capabilities: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
47
+ type: z.ZodLiteral<"webhook">;
48
+ eventTypes: z.ZodArray<z.ZodString>;
49
+ source: z.ZodString;
50
+ endpoint: z.ZodOptional<z.ZodString>;
51
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
52
+ authentication: z.ZodOptional<z.ZodObject<{
53
+ type: z.ZodEnum<{
54
+ bearer: "bearer";
55
+ basic: "basic";
56
+ api_key: "api_key";
57
+ signature: "signature";
58
+ }>;
59
+ config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
60
+ }, z.core.$strip>>;
61
+ }, z.core.$strip>, z.ZodObject<{
62
+ type: z.ZodLiteral<"scheduled">;
63
+ cron: z.ZodString;
64
+ timezone: z.ZodOptional<z.ZodString>;
65
+ description: z.ZodOptional<z.ZodString>;
66
+ }, z.core.$strip>, z.ZodObject<{
67
+ type: z.ZodLiteral<"queue">;
68
+ topics: z.ZodArray<z.ZodString>;
69
+ queueName: z.ZodOptional<z.ZodString>;
70
+ consumerGroup: z.ZodOptional<z.ZodString>;
71
+ }, z.core.$strip>, z.ZodObject<{
72
+ type: z.ZodLiteral<"stream">;
73
+ streamName: z.ZodString;
74
+ eventTypes: z.ZodOptional<z.ZodArray<z.ZodString>>;
75
+ consumerGroup: z.ZodOptional<z.ZodString>;
76
+ }, z.core.$strip>]>>>;
46
77
  }, z.core.$strip>>;
78
+ capabilities: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
79
+ type: z.ZodLiteral<"webhook">;
80
+ eventTypes: z.ZodArray<z.ZodString>;
81
+ source: z.ZodString;
82
+ endpoint: z.ZodOptional<z.ZodString>;
83
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
84
+ authentication: z.ZodOptional<z.ZodObject<{
85
+ type: z.ZodEnum<{
86
+ bearer: "bearer";
87
+ basic: "basic";
88
+ api_key: "api_key";
89
+ signature: "signature";
90
+ }>;
91
+ config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
92
+ }, z.core.$strip>>;
93
+ }, z.core.$strip>, z.ZodObject<{
94
+ type: z.ZodLiteral<"scheduled">;
95
+ cron: z.ZodString;
96
+ timezone: z.ZodOptional<z.ZodString>;
97
+ description: z.ZodOptional<z.ZodString>;
98
+ }, z.core.$strip>, z.ZodObject<{
99
+ type: z.ZodLiteral<"queue">;
100
+ topics: z.ZodArray<z.ZodString>;
101
+ queueName: z.ZodOptional<z.ZodString>;
102
+ consumerGroup: z.ZodOptional<z.ZodString>;
103
+ }, z.core.$strip>, z.ZodObject<{
104
+ type: z.ZodLiteral<"stream">;
105
+ streamName: z.ZodString;
106
+ eventTypes: z.ZodOptional<z.ZodArray<z.ZodString>>;
107
+ consumerGroup: z.ZodOptional<z.ZodString>;
108
+ }, z.core.$strip>]>>>;
47
109
  }, z.core.$strip>;
48
110
  build: z.ZodOptional<z.ZodObject<{
49
111
  dockerfile: z.ZodString;
package/dist/parseSpec.js CHANGED
@@ -1,5 +1,41 @@
1
1
  import { parse as parseYAML } from "yaml";
2
2
  import { z } from "zod";
3
+ // Capability schemas
4
+ const WebhookCapabilitySchema = z.object({
5
+ type: z.literal('webhook'),
6
+ eventTypes: z.array(z.string()),
7
+ source: z.string(),
8
+ endpoint: z.string().optional(),
9
+ headers: z.record(z.string(), z.string()).optional(),
10
+ authentication: z.object({
11
+ type: z.enum(['bearer', 'basic', 'api_key', 'signature']),
12
+ config: z.record(z.string(), z.unknown()).optional(),
13
+ }).optional(),
14
+ });
15
+ const ScheduledCapabilitySchema = z.object({
16
+ type: z.literal('scheduled'),
17
+ cron: z.string(),
18
+ timezone: z.string().optional(),
19
+ description: z.string().optional(),
20
+ });
21
+ const QueueCapabilitySchema = z.object({
22
+ type: z.literal('queue'),
23
+ topics: z.array(z.string()),
24
+ queueName: z.string().optional(),
25
+ consumerGroup: z.string().optional(),
26
+ });
27
+ const StreamCapabilitySchema = z.object({
28
+ type: z.literal('stream'),
29
+ streamName: z.string(),
30
+ eventTypes: z.array(z.string()).optional(),
31
+ consumerGroup: z.string().optional(),
32
+ });
33
+ const CapabilitySchema = z.discriminatedUnion('type', [
34
+ WebhookCapabilitySchema,
35
+ ScheduledCapabilitySchema,
36
+ QueueCapabilitySchema,
37
+ StreamCapabilitySchema,
38
+ ]);
3
39
  // Zod schema for nova.yaml
4
40
  export const NovaSpecSchema = z.object({
5
41
  apiVersion: z.string(),
@@ -45,7 +81,9 @@ export const NovaSpecSchema = z.object({
45
81
  resourceType: z.string(),
46
82
  relation: z.string(),
47
83
  }).optional(),
84
+ capabilities: z.array(CapabilitySchema).optional(),
48
85
  })),
86
+ capabilities: z.array(CapabilitySchema).optional(), // Worker-level capabilities
49
87
  }),
50
88
  build: z.object({
51
89
  dockerfile: z.string(),
@@ -40,6 +40,37 @@ export declare const WorkerDefSchema: z.ZodObject<{
40
40
  resourceIdKey: z.ZodOptional<z.ZodString>;
41
41
  policy: z.ZodOptional<z.ZodString>;
42
42
  }, z.core.$strip>>;
43
+ capabilities: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
44
+ type: z.ZodLiteral<"webhook">;
45
+ eventTypes: z.ZodArray<z.ZodString>;
46
+ source: z.ZodString;
47
+ endpoint: z.ZodOptional<z.ZodString>;
48
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
49
+ authentication: z.ZodOptional<z.ZodObject<{
50
+ type: z.ZodEnum<{
51
+ bearer: "bearer";
52
+ basic: "basic";
53
+ api_key: "api_key";
54
+ signature: "signature";
55
+ }>;
56
+ config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
57
+ }, z.core.$strip>>;
58
+ }, z.core.$strip>, z.ZodObject<{
59
+ type: z.ZodLiteral<"scheduled">;
60
+ cron: z.ZodString;
61
+ timezone: z.ZodDefault<z.ZodString>;
62
+ description: z.ZodOptional<z.ZodString>;
63
+ }, z.core.$strip>, z.ZodObject<{
64
+ type: z.ZodLiteral<"queue">;
65
+ topics: z.ZodArray<z.ZodString>;
66
+ queueName: z.ZodOptional<z.ZodString>;
67
+ consumerGroup: z.ZodOptional<z.ZodString>;
68
+ }, z.core.$strip>, z.ZodObject<{
69
+ type: z.ZodLiteral<"stream">;
70
+ streamName: z.ZodString;
71
+ eventTypes: z.ZodOptional<z.ZodArray<z.ZodString>>;
72
+ consumerGroup: z.ZodOptional<z.ZodString>;
73
+ }, z.core.$strip>]>>>;
43
74
  handler: z.ZodAny;
44
75
  }, z.core.$strip>>;
45
76
  }, z.core.$strip>;
@@ -33,6 +33,38 @@ export const WorkerDefSchema = z.object({
33
33
  resourceIdKey: z.string().optional(),
34
34
  policy: z.string().optional(),
35
35
  }).optional(),
36
+ // NEW: Capabilities array for event subscriptions and external triggers
37
+ capabilities: z.array(z.union([
38
+ z.object({
39
+ type: z.literal('webhook'),
40
+ eventTypes: z.array(z.string()),
41
+ source: z.string(),
42
+ endpoint: z.string().optional(),
43
+ headers: z.record(z.string(), z.string()).optional(),
44
+ authentication: z.object({
45
+ type: z.enum(['bearer', 'basic', 'api_key', 'signature']),
46
+ config: z.record(z.string(), z.any()).optional()
47
+ }).optional()
48
+ }),
49
+ z.object({
50
+ type: z.literal('scheduled'),
51
+ cron: z.string(),
52
+ timezone: z.string().default('UTC'),
53
+ description: z.string().optional()
54
+ }),
55
+ z.object({
56
+ type: z.literal('queue'),
57
+ topics: z.array(z.string()),
58
+ queueName: z.string().optional(),
59
+ consumerGroup: z.string().optional()
60
+ }),
61
+ z.object({
62
+ type: z.literal('stream'),
63
+ streamName: z.string(),
64
+ eventTypes: z.array(z.string()).optional(),
65
+ consumerGroup: z.string().optional()
66
+ })
67
+ ])).optional(),
36
68
  handler: z.any(), // function with signature (input, ctx) => Promise<…>
37
69
  })),
38
70
  });
package/package.json CHANGED
@@ -1,45 +1,45 @@
1
- {
2
- "name": "@newhomestar/sdk",
3
- "version": "0.4.7",
4
- "description": "Type-safe SDK for building Nova pipelines (workers & functions)",
5
- "homepage": "https://github.com/newhomestar/nova-node-sdk#readme",
6
- "bugs": {
7
- "url": "https://github.com/newhomestar/nova-node-sdk/issues"
8
- },
9
- "repository": {
10
- "type": "git",
11
- "url": "git+https://github.com/newhomestar/nova-node-sdk.git"
12
- },
13
- "license": "ISC",
14
- "author": "Christian Gomez",
15
- "type": "module",
16
- "main": "dist/index.js",
17
- "types": "dist/index.d.ts",
18
- "exports": {
19
- ".": {
20
- "import": "./dist/index.js",
21
- "types": "./dist/index.d.ts"
22
- }
23
- },
24
- "files": [
25
- "dist"
26
- ],
27
- "scripts": {
28
- "build": "tsc"
29
- },
30
- "dependencies": {
31
- "@openfga/sdk": "^0.9.0",
32
- "@orpc/openapi": "1.7.4",
33
- "@orpc/server": "1.7.4",
34
- "@supabase/supabase-js": "^2.39.0",
35
- "body-parser": "^1.20.2",
36
- "dotenv": "^16.4.3",
37
- "express": "^4.18.2",
38
- "yaml": "^2.7.1",
39
- "zod": "^4.0.5"
40
- },
41
- "devDependencies": {
42
- "@types/node": "^20.11.17",
43
- "typescript": "^5.4.4"
44
- }
45
- }
1
+ {
2
+ "name": "@newhomestar/sdk",
3
+ "version": "0.4.8",
4
+ "description": "Type-safe SDK for building Nova pipelines (workers & functions)",
5
+ "homepage": "https://github.com/newhomestar/nova-node-sdk#readme",
6
+ "bugs": {
7
+ "url": "https://github.com/newhomestar/nova-node-sdk/issues"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/newhomestar/nova-node-sdk.git"
12
+ },
13
+ "license": "ISC",
14
+ "author": "Christian Gomez",
15
+ "type": "module",
16
+ "main": "dist/index.js",
17
+ "types": "dist/index.d.ts",
18
+ "exports": {
19
+ ".": {
20
+ "import": "./dist/index.js",
21
+ "types": "./dist/index.d.ts"
22
+ }
23
+ },
24
+ "files": [
25
+ "dist"
26
+ ],
27
+ "scripts": {
28
+ "build": "tsc"
29
+ },
30
+ "dependencies": {
31
+ "@openfga/sdk": "^0.9.0",
32
+ "@orpc/openapi": "1.7.4",
33
+ "@orpc/server": "1.7.4",
34
+ "@supabase/supabase-js": "^2.39.0",
35
+ "body-parser": "^1.20.2",
36
+ "dotenv": "^16.4.3",
37
+ "express": "^4.18.2",
38
+ "yaml": "^2.7.1",
39
+ "zod": "^4.0.5"
40
+ },
41
+ "devDependencies": {
42
+ "@types/node": "^20.11.17",
43
+ "typescript": "^5.4.4"
44
+ }
45
+ }