@parsrun/service 0.1.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 +375 -0
- package/dist/client.d.ts +55 -0
- package/dist/client.js +1474 -0
- package/dist/client.js.map +1 -0
- package/dist/define.d.ts +82 -0
- package/dist/define.js +120 -0
- package/dist/define.js.map +1 -0
- package/dist/events/index.d.ts +285 -0
- package/dist/events/index.js +853 -0
- package/dist/events/index.js.map +1 -0
- package/dist/handler-CmiDUWZv.d.ts +204 -0
- package/dist/index-CVOAoJjZ.d.ts +268 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.js +3589 -0
- package/dist/index.js.map +1 -0
- package/dist/resilience/index.d.ts +197 -0
- package/dist/resilience/index.js +387 -0
- package/dist/resilience/index.js.map +1 -0
- package/dist/rpc/index.d.ts +5 -0
- package/dist/rpc/index.js +1175 -0
- package/dist/rpc/index.js.map +1 -0
- package/dist/serialization/index.d.ts +37 -0
- package/dist/serialization/index.js +320 -0
- package/dist/serialization/index.js.map +1 -0
- package/dist/server-DFE8n2Sx.d.ts +106 -0
- package/dist/tracing/index.d.ts +406 -0
- package/dist/tracing/index.js +820 -0
- package/dist/tracing/index.js.map +1 -0
- package/dist/transports/cloudflare/index.d.ts +237 -0
- package/dist/transports/cloudflare/index.js +746 -0
- package/dist/transports/cloudflare/index.js.map +1 -0
- package/dist/types-n4LLSPQU.d.ts +473 -0
- package/package.json +91 -0
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @parsrun/service - Core Types
|
|
3
|
+
* Type definitions for the unified service layer
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Query method definition
|
|
7
|
+
* Synchronous request-response pattern
|
|
8
|
+
*/
|
|
9
|
+
interface QueryDefinition<TInput = unknown, TOutput = unknown> {
|
|
10
|
+
/** Input schema/type */
|
|
11
|
+
input?: TInput;
|
|
12
|
+
/** Output schema/type */
|
|
13
|
+
output?: TOutput;
|
|
14
|
+
/** Version when this query was added */
|
|
15
|
+
since?: string;
|
|
16
|
+
/** Version when deprecated */
|
|
17
|
+
deprecated?: string;
|
|
18
|
+
/** Replacement method name */
|
|
19
|
+
replacement?: string;
|
|
20
|
+
/** Description for documentation */
|
|
21
|
+
description?: string;
|
|
22
|
+
/** Timeout override in ms */
|
|
23
|
+
timeout?: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Mutation method definition
|
|
27
|
+
* Synchronous request-response pattern that modifies state
|
|
28
|
+
*/
|
|
29
|
+
interface MutationDefinition<TInput = unknown, TOutput = unknown> {
|
|
30
|
+
/** Input schema/type */
|
|
31
|
+
input?: TInput;
|
|
32
|
+
/** Output schema/type */
|
|
33
|
+
output?: TOutput;
|
|
34
|
+
/** Version when this mutation was added */
|
|
35
|
+
since?: string;
|
|
36
|
+
/** Version when deprecated */
|
|
37
|
+
deprecated?: string;
|
|
38
|
+
/** Replacement method name */
|
|
39
|
+
replacement?: string;
|
|
40
|
+
/** Description for documentation */
|
|
41
|
+
description?: string;
|
|
42
|
+
/** Timeout override in ms */
|
|
43
|
+
timeout?: number;
|
|
44
|
+
/** Whether this mutation is idempotent */
|
|
45
|
+
idempotent?: boolean;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Event definition
|
|
49
|
+
*/
|
|
50
|
+
interface EventDefinition<TData = unknown> {
|
|
51
|
+
/** Event data schema/type */
|
|
52
|
+
data?: TData;
|
|
53
|
+
/** Delivery guarantee */
|
|
54
|
+
delivery?: "at-most-once" | "at-least-once";
|
|
55
|
+
/** Version when this event was added */
|
|
56
|
+
since?: string;
|
|
57
|
+
/** Description for documentation */
|
|
58
|
+
description?: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Event handler definition
|
|
62
|
+
*/
|
|
63
|
+
interface EventHandlerDefinition {
|
|
64
|
+
/** Event type to handle */
|
|
65
|
+
event: string;
|
|
66
|
+
/** Handler options */
|
|
67
|
+
options?: EventHandlerOptions;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Event handler options
|
|
71
|
+
*/
|
|
72
|
+
interface EventHandlerOptions {
|
|
73
|
+
/** Number of retry attempts */
|
|
74
|
+
retries?: number;
|
|
75
|
+
/** Backoff strategy */
|
|
76
|
+
backoff?: "linear" | "exponential";
|
|
77
|
+
/** Maximum delay between retries in ms */
|
|
78
|
+
maxDelay?: number;
|
|
79
|
+
/** Dead letter queue name */
|
|
80
|
+
deadLetter?: string;
|
|
81
|
+
/** Action when retries exhausted */
|
|
82
|
+
onExhausted?: "alert" | "log" | "discard";
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Complete service definition
|
|
86
|
+
*/
|
|
87
|
+
interface ServiceDefinition<TQueries extends Record<string, QueryDefinition> = Record<string, QueryDefinition>, TMutations extends Record<string, MutationDefinition> = Record<string, MutationDefinition>, TEmits extends Record<string, EventDefinition> = Record<string, EventDefinition>, THandles extends string[] = string[]> {
|
|
88
|
+
/** Unique service name */
|
|
89
|
+
name: string;
|
|
90
|
+
/** Service version (semver) */
|
|
91
|
+
version: string;
|
|
92
|
+
/** Service description */
|
|
93
|
+
description?: string;
|
|
94
|
+
/** Query methods (read-only, sync) */
|
|
95
|
+
queries?: TQueries;
|
|
96
|
+
/** Mutation methods (write, sync) */
|
|
97
|
+
mutations?: TMutations;
|
|
98
|
+
/** Events this service emits */
|
|
99
|
+
events?: {
|
|
100
|
+
emits?: TEmits;
|
|
101
|
+
handles?: THandles;
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* RPC request envelope
|
|
106
|
+
*/
|
|
107
|
+
interface RpcRequest<T = unknown> {
|
|
108
|
+
/** Request ID for correlation */
|
|
109
|
+
id: string;
|
|
110
|
+
/** Service name */
|
|
111
|
+
service: string;
|
|
112
|
+
/** Method name */
|
|
113
|
+
method: string;
|
|
114
|
+
/** Method type */
|
|
115
|
+
type: "query" | "mutation";
|
|
116
|
+
/** Client version requirement */
|
|
117
|
+
version?: string;
|
|
118
|
+
/** Request payload */
|
|
119
|
+
input: T;
|
|
120
|
+
/** Trace context */
|
|
121
|
+
traceContext?: TraceContext;
|
|
122
|
+
/** Request metadata */
|
|
123
|
+
metadata?: RpcMetadata;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* RPC response envelope
|
|
127
|
+
*/
|
|
128
|
+
interface RpcResponse<T = unknown> {
|
|
129
|
+
/** Correlation ID */
|
|
130
|
+
id: string;
|
|
131
|
+
/** Whether request succeeded */
|
|
132
|
+
success: boolean;
|
|
133
|
+
/** Service version that handled the request */
|
|
134
|
+
version: string;
|
|
135
|
+
/** Response payload (if success) */
|
|
136
|
+
output?: T;
|
|
137
|
+
/** Error details (if failure) */
|
|
138
|
+
error?: RpcErrorData;
|
|
139
|
+
/** Trace context */
|
|
140
|
+
traceContext?: TraceContext;
|
|
141
|
+
/** Response metadata */
|
|
142
|
+
metadata?: RpcMetadata;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* RPC error data structure (in RPC response)
|
|
146
|
+
*/
|
|
147
|
+
interface RpcErrorData {
|
|
148
|
+
/** Error code */
|
|
149
|
+
code: string;
|
|
150
|
+
/** Human-readable message */
|
|
151
|
+
message: string;
|
|
152
|
+
/** Additional details */
|
|
153
|
+
details?: Record<string, unknown>;
|
|
154
|
+
/** Whether client should retry */
|
|
155
|
+
retryable?: boolean;
|
|
156
|
+
/** Suggested retry delay in ms */
|
|
157
|
+
retryAfter?: number;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* RPC metadata
|
|
161
|
+
*/
|
|
162
|
+
interface RpcMetadata {
|
|
163
|
+
/** Tenant ID */
|
|
164
|
+
tenantId?: string;
|
|
165
|
+
/** User ID */
|
|
166
|
+
userId?: string;
|
|
167
|
+
/** Request ID */
|
|
168
|
+
requestId?: string;
|
|
169
|
+
/** Custom metadata */
|
|
170
|
+
[key: string]: unknown;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* CloudEvents-compatible event structure
|
|
174
|
+
*/
|
|
175
|
+
interface ParsEvent<T = unknown> {
|
|
176
|
+
/** CloudEvents spec version */
|
|
177
|
+
specversion: "1.0";
|
|
178
|
+
/** Event type (e.g., "subscription.created") */
|
|
179
|
+
type: string;
|
|
180
|
+
/** Event source (service name/path) */
|
|
181
|
+
source: string;
|
|
182
|
+
/** Unique event ID */
|
|
183
|
+
id: string;
|
|
184
|
+
/** Event timestamp (ISO 8601) */
|
|
185
|
+
time: string;
|
|
186
|
+
/** Content type */
|
|
187
|
+
datacontenttype?: string;
|
|
188
|
+
/** Subject (optional context) */
|
|
189
|
+
subject?: string;
|
|
190
|
+
/** Tenant ID */
|
|
191
|
+
parstenantid?: string;
|
|
192
|
+
/** Request ID for correlation */
|
|
193
|
+
parsrequestid?: string;
|
|
194
|
+
/** Trace context (W3C format) */
|
|
195
|
+
parstracecontext?: string;
|
|
196
|
+
/** Delivery guarantee */
|
|
197
|
+
parsdelivery?: "at-most-once" | "at-least-once";
|
|
198
|
+
/** Event payload */
|
|
199
|
+
data: T;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Compact internal event format (for service bindings)
|
|
203
|
+
*/
|
|
204
|
+
interface CompactEvent<T = unknown> {
|
|
205
|
+
/** Event type */
|
|
206
|
+
e: string;
|
|
207
|
+
/** Source service */
|
|
208
|
+
s: string;
|
|
209
|
+
/** Event ID */
|
|
210
|
+
i: string;
|
|
211
|
+
/** Timestamp (unix ms) */
|
|
212
|
+
t: number;
|
|
213
|
+
/** Trace context */
|
|
214
|
+
ctx?: string;
|
|
215
|
+
/** Tenant ID */
|
|
216
|
+
tid?: string;
|
|
217
|
+
/** Data */
|
|
218
|
+
d: T;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Event handler function type
|
|
222
|
+
*/
|
|
223
|
+
type EventHandler<T = unknown> = (event: ParsEvent<T>, context: EventHandlerContext) => Promise<void>;
|
|
224
|
+
/**
|
|
225
|
+
* Event handler context
|
|
226
|
+
*/
|
|
227
|
+
interface EventHandlerContext {
|
|
228
|
+
/** Logger instance */
|
|
229
|
+
logger: EventLogger;
|
|
230
|
+
/** Current attempt number (1-based) */
|
|
231
|
+
attempt: number;
|
|
232
|
+
/** Maximum attempts */
|
|
233
|
+
maxAttempts: number;
|
|
234
|
+
/** Whether this is a retry */
|
|
235
|
+
isRetry: boolean;
|
|
236
|
+
/** Trace context */
|
|
237
|
+
traceContext?: TraceContext;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Minimal logger interface for event handlers
|
|
241
|
+
*/
|
|
242
|
+
interface EventLogger {
|
|
243
|
+
debug(message: string, context?: Record<string, unknown>): void;
|
|
244
|
+
info(message: string, context?: Record<string, unknown>): void;
|
|
245
|
+
warn(message: string, context?: Record<string, unknown>): void;
|
|
246
|
+
error(message: string, error?: Error, context?: Record<string, unknown>): void;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* W3C Trace Context
|
|
250
|
+
*/
|
|
251
|
+
interface TraceContext {
|
|
252
|
+
/** Trace ID (32 hex chars) */
|
|
253
|
+
traceId: string;
|
|
254
|
+
/** Span ID (16 hex chars) */
|
|
255
|
+
spanId: string;
|
|
256
|
+
/** Trace flags */
|
|
257
|
+
traceFlags: number;
|
|
258
|
+
/** Trace state (vendor-specific) */
|
|
259
|
+
traceState?: string;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Span for tracing
|
|
263
|
+
*/
|
|
264
|
+
interface Span {
|
|
265
|
+
/** Span name */
|
|
266
|
+
name: string;
|
|
267
|
+
/** Span kind */
|
|
268
|
+
kind: SpanKind;
|
|
269
|
+
/** Trace context */
|
|
270
|
+
traceContext: TraceContext;
|
|
271
|
+
/** Parent span ID */
|
|
272
|
+
parentSpanId?: string;
|
|
273
|
+
/** Start time (unix ms) */
|
|
274
|
+
startTime: number;
|
|
275
|
+
/** End time (unix ms) */
|
|
276
|
+
endTime?: number;
|
|
277
|
+
/** Span status */
|
|
278
|
+
status: SpanStatus;
|
|
279
|
+
/** Span attributes */
|
|
280
|
+
attributes: Record<string, SpanAttributeValue>;
|
|
281
|
+
/** Span events */
|
|
282
|
+
events: SpanEvent[];
|
|
283
|
+
}
|
|
284
|
+
type SpanKind = "internal" | "server" | "client" | "producer" | "consumer";
|
|
285
|
+
type SpanStatus = "unset" | "ok" | "error";
|
|
286
|
+
type SpanAttributeValue = string | number | boolean | string[] | number[] | boolean[];
|
|
287
|
+
interface SpanEvent {
|
|
288
|
+
name: string;
|
|
289
|
+
time: number;
|
|
290
|
+
attributes?: Record<string, SpanAttributeValue>;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* RPC transport interface
|
|
294
|
+
*/
|
|
295
|
+
interface RpcTransport {
|
|
296
|
+
/** Transport name */
|
|
297
|
+
readonly name: string;
|
|
298
|
+
/** Send RPC request and get response */
|
|
299
|
+
call<TInput, TOutput>(request: RpcRequest<TInput>): Promise<RpcResponse<TOutput>>;
|
|
300
|
+
/** Close transport connection */
|
|
301
|
+
close?(): Promise<void>;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Event transport interface
|
|
305
|
+
*/
|
|
306
|
+
interface EventTransport {
|
|
307
|
+
/** Transport name */
|
|
308
|
+
readonly name: string;
|
|
309
|
+
/** Emit an event */
|
|
310
|
+
emit<T>(event: ParsEvent<T>): Promise<void>;
|
|
311
|
+
/** Subscribe to events */
|
|
312
|
+
subscribe(eventType: string, handler: EventHandler, options?: EventHandlerOptions): Unsubscribe;
|
|
313
|
+
/** Close transport connection */
|
|
314
|
+
close?(): Promise<void>;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Unsubscribe function
|
|
318
|
+
*/
|
|
319
|
+
type Unsubscribe = () => void;
|
|
320
|
+
/**
|
|
321
|
+
* Service configuration
|
|
322
|
+
*/
|
|
323
|
+
interface ServiceConfig {
|
|
324
|
+
/** Event format options */
|
|
325
|
+
events?: EventFormatConfig;
|
|
326
|
+
/** Serialization options */
|
|
327
|
+
serialization?: SerializationConfig;
|
|
328
|
+
/** Tracing options */
|
|
329
|
+
tracing?: TracingConfig;
|
|
330
|
+
/** Versioning options */
|
|
331
|
+
versioning?: VersioningConfig;
|
|
332
|
+
/** Resilience options */
|
|
333
|
+
resilience?: ResilienceConfig;
|
|
334
|
+
/** Dead letter queue options */
|
|
335
|
+
deadLetter?: DeadLetterConfig;
|
|
336
|
+
}
|
|
337
|
+
interface EventFormatConfig {
|
|
338
|
+
/** Use CloudEvents format (default: true) */
|
|
339
|
+
format?: "cloudevents" | "compact";
|
|
340
|
+
/** Use compact format for internal communication */
|
|
341
|
+
internalCompact?: boolean;
|
|
342
|
+
}
|
|
343
|
+
interface SerializationConfig {
|
|
344
|
+
/** Serialization format */
|
|
345
|
+
format?: "json" | "msgpack";
|
|
346
|
+
}
|
|
347
|
+
interface TracingConfig {
|
|
348
|
+
/** Enable tracing */
|
|
349
|
+
enabled?: boolean;
|
|
350
|
+
/** Sampling strategy */
|
|
351
|
+
sampler?: "always" | "never" | {
|
|
352
|
+
ratio: number;
|
|
353
|
+
};
|
|
354
|
+
/** Exporter type */
|
|
355
|
+
exporter?: "otlp" | "console" | "none";
|
|
356
|
+
/** OTLP endpoint */
|
|
357
|
+
endpoint?: string;
|
|
358
|
+
/** Service name for traces */
|
|
359
|
+
serviceName?: string;
|
|
360
|
+
}
|
|
361
|
+
interface VersioningConfig {
|
|
362
|
+
/** Versioning strategy */
|
|
363
|
+
strategy?: "header" | "url" | "none";
|
|
364
|
+
/** Default version to use */
|
|
365
|
+
defaultVersion?: string;
|
|
366
|
+
}
|
|
367
|
+
interface ResilienceConfig {
|
|
368
|
+
/** Circuit breaker config */
|
|
369
|
+
circuitBreaker?: CircuitBreakerConfig;
|
|
370
|
+
/** Bulkhead config */
|
|
371
|
+
bulkhead?: BulkheadConfig;
|
|
372
|
+
/** Default timeout in ms */
|
|
373
|
+
timeout?: number;
|
|
374
|
+
/** Retry config */
|
|
375
|
+
retry?: RetryConfig;
|
|
376
|
+
}
|
|
377
|
+
interface CircuitBreakerConfig {
|
|
378
|
+
/** Enable circuit breaker */
|
|
379
|
+
enabled?: boolean;
|
|
380
|
+
/** Number of failures before opening circuit */
|
|
381
|
+
failureThreshold?: number;
|
|
382
|
+
/** Time to wait before half-open state (ms) */
|
|
383
|
+
resetTimeout?: number;
|
|
384
|
+
/** Number of successes in half-open to close circuit */
|
|
385
|
+
successThreshold?: number;
|
|
386
|
+
}
|
|
387
|
+
interface BulkheadConfig {
|
|
388
|
+
/** Maximum concurrent requests */
|
|
389
|
+
maxConcurrent?: number;
|
|
390
|
+
/** Maximum queue size */
|
|
391
|
+
maxQueue?: number;
|
|
392
|
+
}
|
|
393
|
+
interface RetryConfig {
|
|
394
|
+
/** Number of retry attempts */
|
|
395
|
+
attempts?: number;
|
|
396
|
+
/** Backoff strategy */
|
|
397
|
+
backoff?: "linear" | "exponential";
|
|
398
|
+
/** Initial delay in ms */
|
|
399
|
+
initialDelay?: number;
|
|
400
|
+
/** Maximum delay in ms */
|
|
401
|
+
maxDelay?: number;
|
|
402
|
+
}
|
|
403
|
+
interface DeadLetterConfig {
|
|
404
|
+
/** Enable DLQ */
|
|
405
|
+
enabled?: boolean;
|
|
406
|
+
/** Retention period */
|
|
407
|
+
retention?: string;
|
|
408
|
+
/** Action on DLQ write */
|
|
409
|
+
onFail?: "alert" | "log" | "none";
|
|
410
|
+
/** Alert threshold (number of messages) */
|
|
411
|
+
alertThreshold?: number;
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Service client options
|
|
415
|
+
*/
|
|
416
|
+
interface ServiceClientOptions {
|
|
417
|
+
/** Transport mode */
|
|
418
|
+
mode?: "embedded" | "binding" | "http";
|
|
419
|
+
/** HTTP base URL (for http mode) */
|
|
420
|
+
baseUrl?: string;
|
|
421
|
+
/** Cloudflare service binding (for binding mode) */
|
|
422
|
+
binding?: Fetcher;
|
|
423
|
+
/** Embedded service instance (for embedded mode) */
|
|
424
|
+
instance?: ServiceInstance;
|
|
425
|
+
/** Service configuration */
|
|
426
|
+
config?: ServiceConfig;
|
|
427
|
+
/** Custom RPC transport */
|
|
428
|
+
rpcTransport?: RpcTransport;
|
|
429
|
+
/** Custom event transport */
|
|
430
|
+
eventTransport?: EventTransport;
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Cloudflare Fetcher interface (service binding)
|
|
434
|
+
*/
|
|
435
|
+
interface Fetcher {
|
|
436
|
+
fetch(input: string | Request | URL, init?: RequestInit): Promise<Response>;
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Service instance (for embedded mode)
|
|
440
|
+
*/
|
|
441
|
+
interface ServiceInstance {
|
|
442
|
+
/** Handle RPC request */
|
|
443
|
+
handleRpc<TInput, TOutput>(request: RpcRequest<TInput>): Promise<RpcResponse<TOutput>>;
|
|
444
|
+
/** Handle event */
|
|
445
|
+
handleEvent<T>(event: ParsEvent<T>): Promise<void>;
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Service client interface
|
|
449
|
+
*/
|
|
450
|
+
interface ServiceClient<TDef extends ServiceDefinition = ServiceDefinition> {
|
|
451
|
+
/** Service name */
|
|
452
|
+
readonly name: string;
|
|
453
|
+
/** Execute a query */
|
|
454
|
+
query<K extends keyof TDef["queries"]>(method: K, input: QueryInput<TDef["queries"], K>): Promise<QueryOutput<TDef["queries"], K>>;
|
|
455
|
+
/** Execute a mutation */
|
|
456
|
+
mutate<K extends keyof TDef["mutations"]>(method: K, input: MutationInput<TDef["mutations"], K>): Promise<MutationOutput<TDef["mutations"], K>>;
|
|
457
|
+
/** Emit an event */
|
|
458
|
+
emit<K extends keyof NonNullable<TDef["events"]>["emits"]>(eventType: K, data: EventData<NonNullable<TDef["events"]>["emits"], K>): Promise<void>;
|
|
459
|
+
/** Subscribe to events */
|
|
460
|
+
on<T = unknown>(eventType: string, handler: EventHandler<T>, options?: EventHandlerOptions): Unsubscribe;
|
|
461
|
+
}
|
|
462
|
+
/** Extract input type from queries record */
|
|
463
|
+
type QueryInput<TQueries extends Record<string, QueryDefinition> | undefined, K extends keyof NonNullable<TQueries>> = NonNullable<TQueries>[K] extends QueryDefinition<infer TInput, unknown> ? TInput : never;
|
|
464
|
+
/** Extract output type from queries record */
|
|
465
|
+
type QueryOutput<TQueries extends Record<string, QueryDefinition> | undefined, K extends keyof NonNullable<TQueries>> = NonNullable<TQueries>[K] extends QueryDefinition<unknown, infer TOutput> ? TOutput : never;
|
|
466
|
+
/** Extract input type from mutations record */
|
|
467
|
+
type MutationInput<TMutations extends Record<string, MutationDefinition> | undefined, K extends keyof NonNullable<TMutations>> = NonNullable<TMutations>[K] extends MutationDefinition<infer TInput, unknown> ? TInput : never;
|
|
468
|
+
/** Extract output type from mutations record */
|
|
469
|
+
type MutationOutput<TMutations extends Record<string, MutationDefinition> | undefined, K extends keyof NonNullable<TMutations>> = NonNullable<TMutations>[K] extends MutationDefinition<unknown, infer TOutput> ? TOutput : never;
|
|
470
|
+
/** Extract data type from events record */
|
|
471
|
+
type EventData<TEvents extends Record<string, EventDefinition> | undefined, K extends keyof NonNullable<TEvents>> = NonNullable<TEvents>[K] extends EventDefinition<infer TData> ? TData : never;
|
|
472
|
+
|
|
473
|
+
export type { QueryOutput as A, BulkheadConfig as B, CompactEvent as C, DeadLetterConfig as D, EventFormatConfig as E, Fetcher as F, MutationInput as G, MutationOutput as H, EventData as I, MutationDefinition as M, ParsEvent as P, QueryDefinition as Q, ResilienceConfig as R, ServiceConfig as S, TracingConfig as T, Unsubscribe as U, VersioningConfig as V, SerializationConfig as a, ServiceDefinition as b, EventDefinition as c, EventHandlerDefinition as d, EventHandlerOptions as e, RpcRequest as f, RpcResponse as g, RpcErrorData as h, RpcMetadata as i, EventHandler as j, EventHandlerContext as k, EventLogger as l, TraceContext as m, Span as n, SpanKind as o, SpanStatus as p, SpanAttributeValue as q, SpanEvent as r, RpcTransport as s, EventTransport as t, CircuitBreakerConfig as u, RetryConfig as v, ServiceClientOptions as w, ServiceClient as x, ServiceInstance as y, QueryInput as z };
|
package/package.json
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@parsrun/service",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Unified service layer for extracted microservices - RPC + Events",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"pars",
|
|
7
|
+
"service",
|
|
8
|
+
"microservices",
|
|
9
|
+
"rpc",
|
|
10
|
+
"events",
|
|
11
|
+
"edge",
|
|
12
|
+
"cloudflare"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://pars.run",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/parsrun/pars",
|
|
18
|
+
"directory": "packages/service"
|
|
19
|
+
},
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"type": "module",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"import": "./dist/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./define": {
|
|
28
|
+
"types": "./dist/define.d.ts",
|
|
29
|
+
"import": "./dist/define.js"
|
|
30
|
+
},
|
|
31
|
+
"./client": {
|
|
32
|
+
"types": "./dist/client.d.ts",
|
|
33
|
+
"import": "./dist/client.js"
|
|
34
|
+
},
|
|
35
|
+
"./rpc": {
|
|
36
|
+
"types": "./dist/rpc/index.d.ts",
|
|
37
|
+
"import": "./dist/rpc/index.js"
|
|
38
|
+
},
|
|
39
|
+
"./events": {
|
|
40
|
+
"types": "./dist/events/index.d.ts",
|
|
41
|
+
"import": "./dist/events/index.js"
|
|
42
|
+
},
|
|
43
|
+
"./resilience": {
|
|
44
|
+
"types": "./dist/resilience/index.d.ts",
|
|
45
|
+
"import": "./dist/resilience/index.js"
|
|
46
|
+
},
|
|
47
|
+
"./tracing": {
|
|
48
|
+
"types": "./dist/tracing/index.d.ts",
|
|
49
|
+
"import": "./dist/tracing/index.js"
|
|
50
|
+
},
|
|
51
|
+
"./serialization": {
|
|
52
|
+
"types": "./dist/serialization/index.d.ts",
|
|
53
|
+
"import": "./dist/serialization/index.js"
|
|
54
|
+
},
|
|
55
|
+
"./transports/cloudflare": {
|
|
56
|
+
"types": "./dist/transports/cloudflare/index.d.ts",
|
|
57
|
+
"import": "./dist/transports/cloudflare/index.js"
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"main": "./dist/index.js",
|
|
61
|
+
"types": "./dist/index.d.ts",
|
|
62
|
+
"files": [
|
|
63
|
+
"dist"
|
|
64
|
+
],
|
|
65
|
+
"scripts": {
|
|
66
|
+
"build": "tsup",
|
|
67
|
+
"dev": "tsup --watch",
|
|
68
|
+
"test": "vitest run",
|
|
69
|
+
"test:watch": "vitest",
|
|
70
|
+
"typecheck": "tsc --noEmit",
|
|
71
|
+
"clean": "rm -rf dist node_modules"
|
|
72
|
+
},
|
|
73
|
+
"dependencies": {
|
|
74
|
+
"@parsrun/core": "workspace:*",
|
|
75
|
+
"@parsrun/types": "workspace:*"
|
|
76
|
+
},
|
|
77
|
+
"devDependencies": {
|
|
78
|
+
"tsup": "^8.3.5",
|
|
79
|
+
"typescript": "^5.7.2",
|
|
80
|
+
"vitest": "^2.1.8",
|
|
81
|
+
"arktype": "^2.0.0"
|
|
82
|
+
},
|
|
83
|
+
"peerDependencies": {
|
|
84
|
+
"arktype": ">=2.0.0"
|
|
85
|
+
},
|
|
86
|
+
"peerDependenciesMeta": {
|
|
87
|
+
"arktype": {
|
|
88
|
+
"optional": true
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|