@aikirun/client 0.16.0 → 0.17.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/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,10 +85,10 @@ 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
@@ -551,6 +552,7 @@ function resolveSubscriberStrategy(client2, strategy, workflows, workerShards) {
551
552
  }
552
553
 
553
554
  // client.ts
555
+ var AIKI_API_KEY_ENV_NAME = "AIKI_API_KEY";
554
556
  function client(params) {
555
557
  return new ClientImpl(params);
556
558
  }
@@ -558,7 +560,16 @@ var ClientImpl = class {
558
560
  constructor(params) {
559
561
  this.params = params;
560
562
  this.logger = params.logger ?? new ConsoleLogger();
561
- const rpcLink = new RPCLink({ url: `${params.url}` });
563
+ const apiKey = params.apiKey ?? process.env[AIKI_API_KEY_ENV_NAME];
564
+ if (!apiKey) {
565
+ throw new Error(`API key is required. Provide it via 'apiKey' param or ${AIKI_API_KEY_ENV_NAME} env variable`);
566
+ }
567
+ const rpcLink = new RPCLink({
568
+ url: `${params.url}/api`,
569
+ headers: () => ({
570
+ Authorization: `Bearer ${apiKey}`
571
+ })
572
+ });
562
573
  this.api = createORPCClient(rpcLink);
563
574
  this.logger.info("Aiki client initialized", {
564
575
  "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.17.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.17.0",
22
22
  "@orpc/client": "^1.9.3",
23
23
  "ioredis": "^5.4.1",
24
24
  "arktype": "^2.1.29"