@aikirun/client 0.16.0 → 0.18.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/README.md CHANGED
@@ -14,6 +14,7 @@ npm install @aikirun/client
14
14
  import { client } from "@aikirun/client";
15
15
  import { orderWorkflowV1 } from "./workflows.ts";
16
16
 
17
+ // Set AIKI_API_KEY env variable or pass apiKey option
17
18
  const aikiClient = client({
18
19
  url: "http://localhost:9850",
19
20
  redis: { host: "localhost", port: 6379 },
package/dist/index.d.ts CHANGED
@@ -10,6 +10,7 @@ export { AdaptivePollingSubscriberStrategy, ApiClient, Client, ClientParams, Log
10
10
  * @template AppContext - Type of application context passed to workflows (default: null)
11
11
  * @param params - Client configuration parameters
12
12
  * @param params.url - HTTP URL of the Aiki server (e.g., "http://localhost:9850")
13
+ * @param params.apiKey - API key for authentication. Falls back to AIKI_API_KEY env variable if not provided.
13
14
  * @param params.redis - Redis connection configuration
14
15
  * @param params.redis.host - Redis server hostname
15
16
  * @param params.redis.port - Redis server port
@@ -22,6 +23,7 @@ export { AdaptivePollingSubscriberStrategy, ApiClient, Client, ClientParams, Log
22
23
  * ```typescript
23
24
  * const aikiClient = client({
24
25
  * url: "http://localhost:9850",
26
+ * apiKey: "yourApiKey", // or omit to use AIKI_API_KEY env variable
25
27
  * redis: { host: "localhost", port: 6379 },
26
28
  * createContext: (run) => ({
27
29
  * traceId: generateTraceId(),
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  // client.ts
2
+ import process from "process";
2
3
  import { INTERNAL as INTERNAL2 } from "@aikirun/types/symbols";
3
4
  import { createORPCClient } from "@orpc/client";
4
5
  import { RPCLink } from "@orpc/client/fetch";
@@ -84,15 +85,15 @@ var ConsoleLogger = class _ConsoleLogger {
84
85
 
85
86
  // ../../lib/address/index.ts
86
87
  function getWorkflowStreamName(name, versionId, shard) {
87
- return shard ? `workflow/${name}/${versionId}/${shard}` : `workflow/${name}/${versionId}`;
88
+ return shard ? `workflow:${name}:${versionId}:${shard}` : `workflow:${name}:${versionId}`;
88
89
  }
89
90
  function getWorkerConsumerGroupName(workflowName, workflowVersionId, shard) {
90
- return shard ? `worker/${workflowName}/${workflowVersionId}/${shard}` : `worker/${workflowName}/${workflowVersionId}`;
91
+ return shard ? `worker:${workflowName}:${workflowVersionId}:${shard}` : `worker:${workflowName}:${workflowVersionId}`;
91
92
  }
92
93
 
93
94
  // ../../lib/array/utils.ts
94
95
  function isNonEmptyArray(value) {
95
- return value.length > 0;
96
+ return value !== void 0 && value.length > 0;
96
97
  }
97
98
  function shuffleArray(array) {
98
99
  const shuffledArray = Array.from(array);
@@ -558,7 +559,16 @@ var ClientImpl = class {
558
559
  constructor(params) {
559
560
  this.params = params;
560
561
  this.logger = params.logger ?? new ConsoleLogger();
561
- const rpcLink = new RPCLink({ url: `${params.url}` });
562
+ const apiKey = params.apiKey ?? process.env.AIKI_API_KEY;
563
+ if (!apiKey) {
564
+ throw new Error(`API key is required. Provide it via 'apiKey' param or AIKI_API_KEY env variable`);
565
+ }
566
+ const rpcLink = new RPCLink({
567
+ url: `${params.url}/api`,
568
+ headers: () => ({
569
+ Authorization: `Bearer ${apiKey}`
570
+ })
571
+ });
562
572
  this.api = createORPCClient(rpcLink);
563
573
  this.logger.info("Aiki client initialized", {
564
574
  "aiki.url": params.url
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aikirun/client",
3
- "version": "0.16.0",
3
+ "version": "0.18.0",
4
4
  "description": "Client SDK for Aiki - connect to the server, start workflows, and manage execution",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -18,7 +18,7 @@
18
18
  "build": "tsup"
19
19
  },
20
20
  "dependencies": {
21
- "@aikirun/types": "0.16.0",
21
+ "@aikirun/types": "0.18.0",
22
22
  "@orpc/client": "^1.9.3",
23
23
  "ioredis": "^5.4.1",
24
24
  "arktype": "^2.1.29"