effect-inngest 0.3.0-beta.0 → 0.3.0-beta.1

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
@@ -459,7 +459,7 @@ const ProcessOrder = InngestFunction.make("process-order", {
459
459
  debounce: { period: Duration.seconds(5) },
460
460
  idempotency: "event.data.orderId",
461
461
  timeouts: { finish: Duration.hours(1) },
462
- cancelOn: [{ event: "order/cancelled", if: "event.data.orderId == async.data.orderId" }],
462
+ cancelOn: [{ event: OrderCancelled, if: "event.data.orderId == async.data.orderId" }],
463
463
  priority: { run: "event.data.isPremium ? 100 : 0" },
464
464
  });
465
465
  ```
package/dist/Client.d.ts CHANGED
@@ -7,7 +7,7 @@ import * as _$effect_Cause0 from "effect/Cause";
7
7
 
8
8
  //#region src/Client.d.ts
9
9
  declare namespace Client_d_exports {
10
- export { CheckpointApiError, CheckpointRetrySchedule, CheckpointingOption, ClientConfig, EventPayload, InngestClient, InngestConfig, layer, layerConfig, layerFromEnv };
10
+ export { CheckpointApiError, CheckpointRetrySchedule, CheckpointingOption, ClientConfig, ClientMode, EventPayload, InngestClient, InngestClientService, InngestConfig, SendEventError, SendEventResponse, TypeId, layer, layerConfig, layerFromEnv };
11
11
  }
12
12
  /**
13
13
  * @since 0.1.0
@@ -212,4 +212,4 @@ declare const layerConfig: (config: Config.Wrap<ClientConfig>) => Layer.Layer<In
212
212
  */
213
213
  declare const layerFromEnv: Layer.Layer<InngestClient | InngestConfig, Config.ConfigError, HttpClient.HttpClient>;
214
214
  //#endregion
215
- export { CheckpointApiError, CheckpointRetrySchedule, type CheckpointingOption, ClientConfig, Client_d_exports, EventPayload, InngestClient, InngestConfig, layer, layerConfig, layerFromEnv };
215
+ export { CheckpointApiError, CheckpointRetrySchedule, type CheckpointingOption, ClientConfig, ClientMode, Client_d_exports, EventPayload, InngestClient, InngestClientService, InngestConfig, SendEventError, SendEventResponse, TypeId, layer, layerConfig, layerFromEnv };
package/dist/Client.js CHANGED
@@ -16,6 +16,8 @@ var Client_exports = /* @__PURE__ */ __exportAll({
16
16
  EventPayload: () => EventPayload,
17
17
  InngestClient: () => InngestClient,
18
18
  InngestConfig: () => InngestConfig,
19
+ SendEventError: () => SendEventError,
20
+ TypeId: () => TypeId,
19
21
  layer: () => layer,
20
22
  layerConfig: () => layerConfig,
21
23
  layerFromEnv: () => layerFromEnv
@@ -203,4 +205,4 @@ const layerFromEnv = layerConfig(Config.all({
203
205
  signingKeyFallback: Config.string("INNGEST_SIGNING_KEY_FALLBACK").pipe(Config.option, Config.map(Option.getOrUndefined))
204
206
  }));
205
207
  //#endregion
206
- export { CheckpointApiError, CheckpointRetrySchedule, Client_exports, EventPayload, InngestClient, InngestConfig, layer, layerConfig, layerFromEnv };
208
+ export { CheckpointApiError, CheckpointRetrySchedule, Client_exports, EventPayload, InngestClient, InngestConfig, SendEventError, TypeId, layer, layerConfig, layerFromEnv };
package/dist/Event.d.ts CHANGED
@@ -3,7 +3,7 @@ import { MakeOptions } from "effect/Schema";
3
3
 
4
4
  //#region src/Event.d.ts
5
5
  declare namespace Event_d_exports {
6
- export { EventData, EventDefinition, EventEnvelope, EventType, isEventSchema, make };
6
+ export { EventData, EventDefinition, EventEnvelope, EventOptions, EventType, TypeId, isEventSchema, make };
7
7
  }
8
8
  declare const TypeId: unique symbol;
9
9
  interface EventOptions extends MakeOptions {
@@ -40,4 +40,4 @@ declare function make<const Name extends string>(name: Name): EventDefinition<Na
40
40
  declare function make<const Name extends string, const DataSchema extends Schema.Top>(name: Name, schema: DataSchema): EventDefinition<Name, DataSchema>;
41
41
  declare const isEventSchema: (value: unknown) => value is EventDefinition;
42
42
  //#endregion
43
- export { EventDefinition, EventType, Event_d_exports };
43
+ export { EventData, EventDefinition, EventEnvelope, EventOptions, EventType, Event_d_exports, TypeId, isEventSchema, make };
package/dist/Event.js CHANGED
@@ -10,6 +10,7 @@ import { Predicate, Schema } from "effect";
10
10
  * @since 0.1.0
11
11
  */
12
12
  var Event_exports = /* @__PURE__ */ __exportAll({
13
+ TypeId: () => TypeId,
13
14
  isEventSchema: () => isEventSchema,
14
15
  make: () => make
15
16
  });
@@ -43,4 +44,4 @@ function make(name, schema = Schema.Struct({})) {
43
44
  }
44
45
  const isEventSchema = (value) => Schema.isSchema(value) && Predicate.hasProperty(value, TypeId);
45
46
  //#endregion
46
- export { Event_exports, make };
47
+ export { Event_exports, TypeId, isEventSchema, make };
@@ -5,7 +5,7 @@ import { Pipeable } from "effect/Pipeable";
5
5
 
6
6
  //#region src/Function.d.ts
7
7
  declare namespace Function_d_exports {
8
- export { CheckpointingOption, CronTrigger, EventTrigger, FunctionOptions, InngestFunction, Trigger, TriggerInput, TypeId, make };
8
+ export { BatchEventsOption, CancellationOption, CheckpointingOption, ConcurrencyOption, CronTrigger, DebounceOption, EventSchema, EventTrigger, FunctionOptions, FunctionRegistration, InngestFunction, PriorityOption, RateLimitOption, RegistrationConfig, Retries, SingletonOption, ThrottleOption, TimeoutsOption, Trigger, TriggerInput, TypeId, make };
9
9
  }
10
10
  /**
11
11
  * @since 0.1.0
@@ -196,7 +196,7 @@ interface CancellationOption {
196
196
  /**
197
197
  * The name of the event that should cancel the function run.
198
198
  */
199
- readonly event: string;
199
+ readonly event: EventSchema;
200
200
  /**
201
201
  * The expression that must evaluate to true in order to cancel the function run. There
202
202
  * are two variables available in this expression:
@@ -442,4 +442,4 @@ declare function make<const Tag extends string, T extends TriggerInput, S extend
442
442
  readonly success: S;
443
443
  } & O): InngestFunction<Tag, NormalizeTriggers<T>, S, O>;
444
444
  //#endregion
445
- export { type CheckpointingOption, CronTrigger, EventTrigger, FunctionOptions, Function_d_exports, InngestFunction, Trigger, TriggerInput, TypeId, make };
445
+ export { BatchEventsOption, CancellationOption, type CheckpointingOption, ConcurrencyOption, CronTrigger, DebounceOption, EventSchema, EventTrigger, FunctionOptions, FunctionRegistration, Function_d_exports, InngestFunction, PriorityOption, RateLimitOption, RegistrationConfig, Retries, SingletonOption, ThrottleOption, TimeoutsOption, Trigger, TriggerInput, TypeId, make };
package/dist/Function.js CHANGED
@@ -32,7 +32,7 @@ const Proto = {
32
32
  else triggers.push({ cron: t.cron });
33
33
  const opts = this.options;
34
34
  const cancel = opts.cancelOn?.map((c) => ({
35
- event: c.event,
35
+ event: c.event.identifier,
36
36
  if: c.if,
37
37
  timeout: c.timeout ? encodeDuration(c.timeout) : void 0
38
38
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "effect-inngest",
3
- "version": "0.3.0-beta.0",
3
+ "version": "0.3.0-beta.1",
4
4
  "description": "Native Effect client library for Inngest - build durable, type-safe workflows",
5
5
  "keywords": [
6
6
  "background-jobs",
@@ -42,6 +42,10 @@
42
42
  "types": "./dist/Client.d.ts",
43
43
  "import": "./src/Client.ts"
44
44
  },
45
+ "./Event": {
46
+ "types": "./dist/Event.d.ts",
47
+ "import": "./src/Event.ts"
48
+ },
45
49
  "./Events": {
46
50
  "types": "./dist/Events.d.ts",
47
51
  "import": "./src/Events.ts"
@@ -71,6 +75,10 @@
71
75
  "types": "./dist/Client.d.ts",
72
76
  "import": "./dist/Client.js"
73
77
  },
78
+ "./Event": {
79
+ "types": "./dist/Event.d.ts",
80
+ "import": "./dist/Event.js"
81
+ },
74
82
  "./Events": {
75
83
  "types": "./dist/Events.d.ts",
76
84
  "import": "./dist/Events.js"
package/src/Client.ts CHANGED
@@ -17,21 +17,21 @@ export { CheckpointApiError } from "./internal/checkpoint.js";
17
17
  * @category type ids
18
18
  * @internal
19
19
  */
20
- const TypeId: unique symbol = Symbol.for("effect-inngest/Client");
20
+ export const TypeId: unique symbol = Symbol.for("effect-inngest/Client");
21
21
 
22
22
  /**
23
23
  * @since 0.1.0
24
24
  * @category type ids
25
25
  * @internal
26
26
  */
27
- type TypeId = typeof TypeId;
27
+ export type TypeId = typeof TypeId;
28
28
 
29
29
  const DEFAULT_EVENT_BASE_URL = "https://inn.gs/";
30
30
  const DEFAULT_API_BASE_URL = "https://api.inngest.com/";
31
31
  const DEFAULT_DEV_SERVER_URL = "http://localhost:8288/";
32
32
  const SDK_VERSION = "2.0.0";
33
33
 
34
- type ClientMode = "dev" | "cloud";
34
+ export type ClientMode = "dev" | "cloud";
35
35
 
36
36
  export interface ClientConfig {
37
37
  /**
@@ -147,15 +147,15 @@ const SendEventResponse = Schema.Struct({
147
147
  status: Schema.optional(Schema.Number),
148
148
  });
149
149
 
150
- type EventPayload = typeof EventPayload.Type;
151
- type SendEventResponse = typeof SendEventResponse.Type;
150
+ export type EventPayload = typeof EventPayload.Type;
151
+ export type SendEventResponse = typeof SendEventResponse.Type;
152
152
 
153
- class SendEventError extends Schema.TaggedErrorClass<SendEventError>()("SendEventError", {
153
+ export class SendEventError extends Schema.TaggedErrorClass<SendEventError>()("SendEventError", {
154
154
  message: Schema.String,
155
155
  events: Schema.Array(Schema.String),
156
156
  }) {}
157
157
 
158
- interface InngestClientService {
158
+ export interface InngestClientService {
159
159
  readonly [TypeId]: TypeId;
160
160
  readonly config: ClientConfig;
161
161
  readonly mode: ClientMode;
package/src/Event.ts CHANGED
@@ -9,9 +9,9 @@
9
9
  import { Predicate, Schema } from "effect";
10
10
  import type { MakeOptions } from "effect/Schema";
11
11
 
12
- const TypeId: unique symbol = Symbol.for("effect-inngest/Event");
12
+ export const TypeId: unique symbol = Symbol.for("effect-inngest/Event");
13
13
 
14
- interface EventOptions extends MakeOptions {
14
+ export interface EventOptions extends MakeOptions {
15
15
  readonly id?: string;
16
16
  readonly ts?: number;
17
17
  readonly v?: string;
package/src/Function.ts CHANGED
@@ -22,7 +22,7 @@ export const TypeId: unique symbol = Symbol.for("effect-inngest/Function");
22
22
  */
23
23
  export type TypeId = typeof TypeId;
24
24
 
25
- type EventSchema = InngestEvent.EventDefinition;
25
+ export type EventSchema = InngestEvent.EventDefinition;
26
26
 
27
27
  /**
28
28
  * An event-based trigger configuration.
@@ -59,7 +59,7 @@ export type Trigger<E extends EventSchema = EventSchema> = EventTrigger<E> | Cro
59
59
  */
60
60
  export type TriggerInput<E extends EventSchema = EventSchema> = Trigger<E> | ReadonlyArray<Trigger<E>>;
61
61
 
62
- interface ConcurrencyOption {
62
+ export interface ConcurrencyOption {
63
63
  /**
64
64
  * The concurrency limit for this option, adding a limit on how many concurrent
65
65
  * steps can execute at once.
@@ -90,7 +90,7 @@ interface ConcurrencyOption {
90
90
  readonly scope?: "fn" | "env" | "account";
91
91
  }
92
92
 
93
- interface RateLimitOption {
93
+ export interface RateLimitOption {
94
94
  /**
95
95
  * An optional key to use for rate limiting, similar to idempotency.
96
96
  */
@@ -107,7 +107,7 @@ interface RateLimitOption {
107
107
  readonly period: Duration.Input;
108
108
  }
109
109
 
110
- interface ThrottleOption {
110
+ export interface ThrottleOption {
111
111
  /**
112
112
  * An optional expression which returns a throttling key for controlling throttling.
113
113
  * Every unique key is its own throttle limit. Event data may be used within this
@@ -135,7 +135,7 @@ interface ThrottleOption {
135
135
  readonly burst?: number;
136
136
  }
137
137
 
138
- interface DebounceOption {
138
+ export interface DebounceOption {
139
139
  /**
140
140
  * An optional key to use for debouncing.
141
141
  */
@@ -154,7 +154,7 @@ interface DebounceOption {
154
154
  readonly timeout?: Duration.Input;
155
155
  }
156
156
 
157
- interface BatchEventsOption {
157
+ export interface BatchEventsOption {
158
158
  /**
159
159
  * The maximum number of events to be consumed in one batch.
160
160
  */
@@ -178,7 +178,7 @@ interface BatchEventsOption {
178
178
  readonly if?: string;
179
179
  }
180
180
 
181
- interface PriorityOption {
181
+ export interface PriorityOption {
182
182
  /**
183
183
  * An expression to use to determine the priority of a function run. The
184
184
  * expression can return a number between `-600` and `600`, where `600`
@@ -189,7 +189,7 @@ interface PriorityOption {
189
189
  readonly run?: string;
190
190
  }
191
191
 
192
- interface TimeoutsOption {
192
+ export interface TimeoutsOption {
193
193
  /**
194
194
  * Start represents the timeout for starting a function. If the time
195
195
  * between scheduling and starting a function exceeds this value, the
@@ -208,7 +208,7 @@ interface TimeoutsOption {
208
208
  readonly finish?: Duration.Input;
209
209
  }
210
210
 
211
- interface SingletonOption {
211
+ export interface SingletonOption {
212
212
  /**
213
213
  * An optional key expression used to scope singleton execution.
214
214
  * Each unique key has its own singleton lock. Event data can be referenced,
@@ -224,11 +224,11 @@ interface SingletonOption {
224
224
  readonly mode: "skip" | "cancel";
225
225
  }
226
226
 
227
- interface CancellationOption {
227
+ export interface CancellationOption {
228
228
  /**
229
229
  * The name of the event that should cancel the function run.
230
230
  */
231
- readonly event: string;
231
+ readonly event: EventSchema;
232
232
 
233
233
  /**
234
234
  * The expression that must evaluate to true in order to cancel the function run. There
@@ -246,7 +246,7 @@ interface CancellationOption {
246
246
  readonly timeout?: Duration.Input;
247
247
  }
248
248
 
249
- type Retries = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20;
249
+ export type Retries = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20;
250
250
 
251
251
  /**
252
252
  * @since 0.1.0
@@ -343,12 +343,12 @@ export interface FunctionOptions {
343
343
  readonly checkpointing?: CheckpointingOption;
344
344
  }
345
345
 
346
- interface RegistrationConfig {
346
+ export interface RegistrationConfig {
347
347
  readonly appId: string;
348
348
  readonly url: string;
349
349
  }
350
350
 
351
- interface FunctionRegistration {
351
+ export interface FunctionRegistration {
352
352
  readonly id: string;
353
353
  readonly name: string;
354
354
  readonly triggers: ReadonlyArray<{
@@ -481,7 +481,7 @@ const Proto = {
481
481
 
482
482
  const opts = this.options;
483
483
  const cancel = opts.cancelOn?.map((c) => ({
484
- event: c.event,
484
+ event: c.event.identifier,
485
485
  if: c.if,
486
486
  timeout: c.timeout ? encodeDuration(c.timeout) : undefined,
487
487
  }));