@mappa-ai/mappa-node 1.2.3 → 2.0.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.
@@ -0,0 +1,621 @@
1
+ //#region src/types.d.ts
2
+ type JsonValue = string | number | boolean | null | {
3
+ [k: string]: JsonValue;
4
+ } | JsonValue[];
5
+ type ReportTemplateId = "sales_playbook" | "general_report" | "hiring_report" | "profile_alignment";
6
+ type ReportOutputType = "markdown" | "json" | "pdf" | "url";
7
+ type ReportOutput = {
8
+ template: ReportTemplateId;
9
+ templateParams?: Record<string, unknown>;
10
+ };
11
+ type TargetSelector = {
12
+ strategy: "dominant";
13
+ onMiss?: "fallback_dominant" | "error";
14
+ } | {
15
+ strategy: "timerange";
16
+ onMiss?: "fallback_dominant" | "error";
17
+ timeRange?: {
18
+ startSeconds?: number;
19
+ endSeconds?: number;
20
+ };
21
+ } | {
22
+ strategy: "entity_id";
23
+ onMiss?: "fallback_dominant" | "error";
24
+ entityId: string;
25
+ } | {
26
+ strategy: "magic_hint";
27
+ onMiss?: "fallback_dominant" | "error";
28
+ hint: string;
29
+ };
30
+ type WebhookConfig = {
31
+ url: string;
32
+ headers?: Record<string, string>;
33
+ };
34
+ type ReportCreateJobRequest = {
35
+ media: {
36
+ mediaId: string;
37
+ };
38
+ output: ReportOutput;
39
+ target: TargetSelector;
40
+ label?: string;
41
+ entityLabel?: string;
42
+ webhook?: WebhookConfig;
43
+ idempotencyKey?: string;
44
+ requestId?: string;
45
+ signal?: AbortSignal;
46
+ };
47
+ type JobStage = "uploaded" | "queued" | "transcoding" | "extracting" | "scoring" | "rendering" | "finalizing";
48
+ type JobStatus = "queued" | "running" | "succeeded" | "failed" | "canceled";
49
+ type Usage = {
50
+ creditsUsed: number;
51
+ creditsDiscounted?: number;
52
+ creditsNetUsed: number;
53
+ durationMs?: number;
54
+ modelVersion?: string;
55
+ };
56
+ type JobCreditReservation = {
57
+ reservedCredits: number | null;
58
+ reservationStatus: "active" | "released" | "applied" | null;
59
+ };
60
+ type Job = {
61
+ id: string;
62
+ type: "report.generate";
63
+ status: JobStatus;
64
+ stage?: JobStage;
65
+ progress?: number;
66
+ createdAt: string;
67
+ updatedAt: string;
68
+ reportId?: string;
69
+ usage?: Usage;
70
+ credits?: JobCreditReservation;
71
+ releasedCredits?: number | null;
72
+ error?: {
73
+ code: string;
74
+ message: string;
75
+ details?: unknown;
76
+ retryable?: boolean;
77
+ };
78
+ requestId?: string;
79
+ };
80
+ type JobEvent = {
81
+ type: "status";
82
+ job: Job;
83
+ } | {
84
+ type: "stage";
85
+ stage: JobStage;
86
+ progress?: number;
87
+ job: Job;
88
+ } | {
89
+ type: "terminal";
90
+ job: Job;
91
+ };
92
+ type WaitOptions = {
93
+ timeoutMs?: number;
94
+ onEvent?: (event: JobEvent) => void;
95
+ signal?: AbortSignal;
96
+ };
97
+ type Report = {
98
+ id: string;
99
+ createdAt: string;
100
+ jobId?: string;
101
+ label?: string;
102
+ summary?: string;
103
+ media: {
104
+ url?: string;
105
+ mediaId?: string;
106
+ };
107
+ output: {
108
+ template: ReportTemplateId;
109
+ };
110
+ entity?: {
111
+ id: string;
112
+ label: string | null;
113
+ };
114
+ markdown?: string | null;
115
+ sections?: Array<{
116
+ section_title: string;
117
+ section_content: unknown;
118
+ }> | null;
119
+ metrics?: Record<string, unknown> | null;
120
+ raw?: unknown;
121
+ pdfUrl?: string;
122
+ reportUrl?: string;
123
+ };
124
+ type ReportForOutputType = Report;
125
+ type ReportRunHandle = {
126
+ jobId: string;
127
+ stream(opts?: {
128
+ signal?: AbortSignal;
129
+ onEvent?: (e: JobEvent) => void;
130
+ }): AsyncIterable<JobEvent>;
131
+ wait(opts?: WaitOptions): Promise<ReportForOutputType>;
132
+ cancel(): Promise<Job>;
133
+ job(): Promise<Job>;
134
+ report(): Promise<ReportForOutputType | null>;
135
+ };
136
+ type MatchingAnalysisOutputType = "markdown" | "json" | "pdf" | "url";
137
+ type MatchingAnalysisOutput = {
138
+ template: "matching_analysis";
139
+ templateParams?: Record<string, unknown>;
140
+ };
141
+ type MatchingAnalysisEntitySource = {
142
+ type: "entity_id";
143
+ entityId: string;
144
+ } | {
145
+ type: "media_target";
146
+ mediaId: string;
147
+ target: TargetSelector;
148
+ };
149
+ type MatchingAnalysisCreateJobRequest = {
150
+ entityA: MatchingAnalysisEntitySource;
151
+ entityB: MatchingAnalysisEntitySource;
152
+ context: string;
153
+ output: MatchingAnalysisOutput;
154
+ label?: string;
155
+ entityALabel?: string;
156
+ entityBLabel?: string;
157
+ webhook?: WebhookConfig;
158
+ idempotencyKey?: string;
159
+ requestId?: string;
160
+ signal?: AbortSignal;
161
+ };
162
+ type MatchingAnalysisResponse = {
163
+ id: string;
164
+ createdAt: string;
165
+ jobId?: string;
166
+ label?: string;
167
+ context: string;
168
+ output: {
169
+ template: "matching_analysis";
170
+ };
171
+ entityA?: {
172
+ id: string;
173
+ label: string | null;
174
+ };
175
+ entityB?: {
176
+ id: string;
177
+ label: string | null;
178
+ };
179
+ markdown?: string | null;
180
+ sections?: Array<{
181
+ section_title: string;
182
+ section_content: unknown;
183
+ }> | null;
184
+ metrics?: Record<string, unknown> | null;
185
+ raw?: unknown;
186
+ pdfUrl?: string;
187
+ reportUrl?: string;
188
+ };
189
+ type MatchingAnalysisForOutputType = MatchingAnalysisResponse;
190
+ type MatchingAnalysisRunHandle = {
191
+ jobId: string;
192
+ stream(opts?: {
193
+ signal?: AbortSignal;
194
+ onEvent?: (e: JobEvent) => void;
195
+ }): AsyncIterable<JobEvent>;
196
+ wait(opts?: WaitOptions): Promise<MatchingAnalysisForOutputType>;
197
+ cancel(): Promise<Job>;
198
+ job(): Promise<Job>;
199
+ analysis(): Promise<MatchingAnalysisForOutputType | null>;
200
+ };
201
+ type MatchingAnalysisJobReceipt = {
202
+ jobId: string;
203
+ status: "queued" | "running";
204
+ stage?: string;
205
+ estimatedWaitSec?: number;
206
+ requestId?: string;
207
+ handle?: MatchingAnalysisRunHandle;
208
+ };
209
+ type ReportJobReceipt = {
210
+ jobId: string;
211
+ status: "queued" | "running";
212
+ stage?: string;
213
+ estimatedWaitSec?: number;
214
+ requestId?: string;
215
+ handle?: ReportRunHandle;
216
+ };
217
+ type FeedbackCreateRequest = {
218
+ reportId?: string;
219
+ jobId?: string;
220
+ matchingAnalysisId?: string;
221
+ rating: "thumbs_up" | "thumbs_down";
222
+ comment?: string;
223
+ corrections?: Array<{
224
+ path: string;
225
+ expected?: unknown;
226
+ observed?: unknown;
227
+ }>;
228
+ idempotencyKey?: string;
229
+ requestId?: string;
230
+ signal?: AbortSignal;
231
+ };
232
+ type FeedbackReceipt = {
233
+ id: string;
234
+ createdAt: string;
235
+ target: {
236
+ reportId?: string;
237
+ jobId?: string;
238
+ matchingAnalysisId?: string;
239
+ };
240
+ rating: "thumbs_up" | "thumbs_down";
241
+ comment?: string;
242
+ credits: {
243
+ eligible: boolean;
244
+ reason?: string;
245
+ discountApplied: number;
246
+ netUsed: number;
247
+ };
248
+ };
249
+ type MediaObject = {
250
+ mediaId: string;
251
+ createdAt: string;
252
+ contentType: string;
253
+ label?: string | null;
254
+ sizeBytes?: number | null;
255
+ durationSeconds?: number | null;
256
+ };
257
+ type MediaRetention = {
258
+ expiresAt: string | null;
259
+ daysRemaining: number | null;
260
+ locked: boolean;
261
+ };
262
+ type MediaFile = {
263
+ mediaId: string;
264
+ createdAt: string;
265
+ contentType: string;
266
+ label?: string | null;
267
+ sizeBytes?: number | null;
268
+ durationSeconds?: number | null;
269
+ processingStatus: "PENDING" | "PROCESSING" | "COMPLETED" | "FAILED";
270
+ lastUsedAt: string | null;
271
+ retention: MediaRetention;
272
+ };
273
+ type FileDeleteReceipt = {
274
+ mediaId: string;
275
+ deleted: true;
276
+ };
277
+ type RetentionLockResult = {
278
+ mediaId: string;
279
+ retentionLock: boolean;
280
+ message: string;
281
+ };
282
+ type ListFilesResponse = {
283
+ files: MediaFile[];
284
+ nextCursor: string | null;
285
+ hasMore: boolean;
286
+ };
287
+ type Entity = {
288
+ id: string;
289
+ label: string | null;
290
+ createdAt: string;
291
+ mediaCount: number;
292
+ lastSeenAt: string | null;
293
+ };
294
+ type ListEntitiesResponse = {
295
+ entities: Entity[];
296
+ cursor: string | null;
297
+ hasMore: boolean;
298
+ };
299
+ declare function hasEntity(report: Report): report is Report & {
300
+ entity: {
301
+ id: string;
302
+ label: string | null;
303
+ };
304
+ };
305
+ //#endregion
306
+ //#region src/resources/transport.d.ts
307
+ type SSEStreamOptions = {
308
+ signal?: AbortSignal;
309
+ lastEventId?: string;
310
+ };
311
+ type SSEEvent<T = unknown> = {
312
+ id?: string;
313
+ event: string;
314
+ data: T;
315
+ };
316
+ type Telemetry = {
317
+ onRequest?: (ctx: {
318
+ method: string;
319
+ url: string;
320
+ requestId?: string;
321
+ }) => void;
322
+ onResponse?: (ctx: {
323
+ status: number;
324
+ url: string;
325
+ requestId?: string;
326
+ durationMs: number;
327
+ }) => void;
328
+ onError?: (ctx: {
329
+ url: string;
330
+ requestId?: string;
331
+ error: unknown;
332
+ context?: Record<string, unknown>;
333
+ }) => void;
334
+ };
335
+ type TransportOptions = {
336
+ apiKey: string;
337
+ baseUrl: string;
338
+ timeoutMs: number;
339
+ maxRetries: number;
340
+ defaultHeaders?: Record<string, string>;
341
+ fetch?: typeof fetch;
342
+ telemetry?: Telemetry;
343
+ userAgent?: string;
344
+ };
345
+ type RequestOptions = {
346
+ method: "GET" | "POST" | "DELETE" | "PUT" | "PATCH";
347
+ path: string;
348
+ query?: Record<string, string | number | boolean | undefined>;
349
+ headers?: Record<string, string | undefined>;
350
+ body?: unknown;
351
+ idempotencyKey?: string;
352
+ requestId?: string;
353
+ signal?: AbortSignal;
354
+ retryable?: boolean;
355
+ };
356
+ type TransportResponse<T> = {
357
+ data: T;
358
+ status: number;
359
+ requestId?: string;
360
+ headers: Headers;
361
+ };
362
+ declare class Transport {
363
+ private readonly opts;
364
+ private readonly fetchImpl;
365
+ constructor(opts: TransportOptions);
366
+ streamSSE<T>(path: string, opts?: SSEStreamOptions): AsyncGenerator<SSEEvent<T>>;
367
+ private parseSSEStream;
368
+ private parseSSEEvent;
369
+ request<T>(req: RequestOptions): Promise<TransportResponse<T>>;
370
+ }
371
+ //#endregion
372
+ //#region src/resources/entities.d.ts
373
+ type ListEntitiesOptions = {
374
+ limit?: number;
375
+ cursor?: string;
376
+ requestId?: string;
377
+ signal?: AbortSignal;
378
+ };
379
+ declare class EntitiesResource {
380
+ private readonly transport;
381
+ constructor(transport: Transport);
382
+ get(entityId: string, opts?: {
383
+ requestId?: string;
384
+ signal?: AbortSignal;
385
+ }): Promise<Entity>;
386
+ list(opts?: ListEntitiesOptions): Promise<ListEntitiesResponse>;
387
+ listAll(opts?: Omit<ListEntitiesOptions, "cursor">): AsyncIterable<Entity>;
388
+ update(entityId: string, body: {
389
+ label?: string | null;
390
+ }, opts?: {
391
+ requestId?: string;
392
+ signal?: AbortSignal;
393
+ }): Promise<Entity>;
394
+ }
395
+ //#endregion
396
+ //#region src/resources/feedback.d.ts
397
+ declare class FeedbackResource {
398
+ private readonly transport;
399
+ constructor(transport: Transport);
400
+ create(req: FeedbackCreateRequest): Promise<FeedbackReceipt>;
401
+ }
402
+ //#endregion
403
+ //#region src/resources/files.d.ts
404
+ type UploadRequest = {
405
+ file: Blob | ArrayBuffer | Uint8Array | ReadableStream<Uint8Array>;
406
+ label?: string;
407
+ idempotencyKey?: string;
408
+ requestId?: string;
409
+ signal?: AbortSignal;
410
+ };
411
+ type ListFilesOptions = {
412
+ limit?: number;
413
+ cursor?: string;
414
+ includeDeleted?: boolean;
415
+ requestId?: string;
416
+ signal?: AbortSignal;
417
+ };
418
+ declare class FilesResource {
419
+ private readonly transport;
420
+ constructor(transport: Transport);
421
+ upload(req: UploadRequest): Promise<MediaObject>;
422
+ get(mediaId: string, opts?: {
423
+ requestId?: string;
424
+ signal?: AbortSignal;
425
+ }): Promise<MediaFile>;
426
+ list(opts?: ListFilesOptions): Promise<ListFilesResponse>;
427
+ listAll(opts?: Omit<ListFilesOptions, "cursor">): AsyncIterable<MediaFile>;
428
+ setRetentionLock(mediaId: string, locked: boolean, opts?: {
429
+ requestId?: string;
430
+ signal?: AbortSignal;
431
+ }): Promise<RetentionLockResult>;
432
+ delete(mediaId: string, opts?: {
433
+ idempotencyKey?: string;
434
+ requestId?: string;
435
+ signal?: AbortSignal;
436
+ }): Promise<FileDeleteReceipt>;
437
+ }
438
+ //#endregion
439
+ //#region src/resources/health.d.ts
440
+ declare class HealthResource {
441
+ private readonly transport;
442
+ constructor(transport: Transport);
443
+ ping(): Promise<{
444
+ ok: true;
445
+ time: string;
446
+ }>;
447
+ }
448
+ //#endregion
449
+ //#region src/resources/jobs.d.ts
450
+ declare class JobsResource {
451
+ private readonly transport;
452
+ constructor(transport: Transport);
453
+ get(jobId: string, opts?: {
454
+ requestId?: string;
455
+ signal?: AbortSignal;
456
+ }): Promise<Job>;
457
+ cancel(jobId: string, opts?: {
458
+ idempotencyKey?: string;
459
+ requestId?: string;
460
+ signal?: AbortSignal;
461
+ }): Promise<Job>;
462
+ wait(jobId: string, opts?: WaitOptions): Promise<Job>;
463
+ stream(jobId: string, opts?: {
464
+ signal?: AbortSignal;
465
+ onEvent?: (e: JobEvent) => void;
466
+ }): AsyncIterable<JobEvent>;
467
+ private mapSSEToJobEvent;
468
+ private backoff;
469
+ }
470
+ //#endregion
471
+ //#region src/resources/matching-analysis.d.ts
472
+ declare class MatchingAnalysisResource {
473
+ private readonly transport;
474
+ private readonly jobs;
475
+ constructor(transport: Transport, jobs: JobsResource);
476
+ createJob(req: MatchingAnalysisCreateJobRequest): Promise<MatchingAnalysisJobReceipt>;
477
+ get(matchingAnalysisId: string, opts?: {
478
+ requestId?: string;
479
+ signal?: AbortSignal;
480
+ }): Promise<MatchingAnalysisResponse>;
481
+ getByJob(jobId: string, opts?: {
482
+ requestId?: string;
483
+ signal?: AbortSignal;
484
+ }): Promise<MatchingAnalysisResponse | null>;
485
+ generate(req: MatchingAnalysisCreateJobRequest, opts?: {
486
+ wait?: WaitOptions;
487
+ }): Promise<MatchingAnalysisForOutputType>;
488
+ makeHandle(jobId: string): MatchingAnalysisRunHandle;
489
+ private normalizeBody;
490
+ private normalizeEntitySource;
491
+ private normalizeTarget;
492
+ }
493
+ //#endregion
494
+ //#region src/resources/reports.d.ts
495
+ type ReportCreateJobFromFileRequest = Omit<ReportCreateJobRequest, "media" | "idempotencyKey" | "requestId"> & Omit<UploadRequest, "label"> & {
496
+ label?: string;
497
+ idempotencyKey?: string;
498
+ requestId?: string;
499
+ };
500
+ type ReportCreateJobFromUrlRequest = Omit<ReportCreateJobRequest, "media" | "idempotencyKey" | "requestId"> & {
501
+ url: string;
502
+ label?: string;
503
+ idempotencyKey?: string;
504
+ requestId?: string;
505
+ signal?: AbortSignal;
506
+ };
507
+ declare class ReportsResource {
508
+ private readonly transport;
509
+ private readonly jobs;
510
+ private readonly files;
511
+ private readonly fetchImpl;
512
+ constructor(transport: Transport, jobs: JobsResource, files: {
513
+ upload: (req: UploadRequest) => Promise<{
514
+ mediaId: string;
515
+ }>;
516
+ }, fetchImpl: typeof fetch);
517
+ createJob(req: ReportCreateJobRequest): Promise<ReportJobReceipt>;
518
+ createJobFromFile(req: ReportCreateJobFromFileRequest): Promise<ReportJobReceipt>;
519
+ createJobFromUrl(req: ReportCreateJobFromUrlRequest): Promise<ReportJobReceipt>;
520
+ get(reportId: string, opts?: {
521
+ requestId?: string;
522
+ signal?: AbortSignal;
523
+ }): Promise<Report>;
524
+ getByJob(jobId: string, opts?: {
525
+ requestId?: string;
526
+ signal?: AbortSignal;
527
+ }): Promise<Report | null>;
528
+ generate(req: ReportCreateJobRequest, opts?: {
529
+ wait?: WaitOptions;
530
+ }): Promise<ReportForOutputType>;
531
+ generateFromFile(req: ReportCreateJobFromFileRequest, opts?: {
532
+ wait?: WaitOptions;
533
+ }): Promise<ReportForOutputType>;
534
+ generateFromUrl(req: ReportCreateJobFromUrlRequest, opts?: {
535
+ wait?: WaitOptions;
536
+ }): Promise<ReportForOutputType>;
537
+ makeHandle(jobId: string): ReportRunHandle;
538
+ private defaultIdempotencyKey;
539
+ private normalizeJobRequest;
540
+ }
541
+ //#endregion
542
+ //#region src/resources/webhooks.d.ts
543
+ type WebhookEventType = "report.completed" | "report.failed";
544
+ interface WebhookEvent<T = unknown> {
545
+ type: string;
546
+ timestamp: string;
547
+ data: T;
548
+ }
549
+ interface ReportCompletedData {
550
+ jobId: string;
551
+ reportId: string;
552
+ status: "succeeded";
553
+ }
554
+ interface ReportFailedData {
555
+ jobId: string;
556
+ status: "failed";
557
+ error: {
558
+ code: string;
559
+ message: string;
560
+ };
561
+ }
562
+ type ReportCompletedEvent = WebhookEvent<ReportCompletedData> & {
563
+ type: "report.completed";
564
+ };
565
+ type ReportFailedEvent = WebhookEvent<ReportFailedData> & {
566
+ type: "report.failed";
567
+ };
568
+ declare class WebhooksResource {
569
+ verifySignature(params: {
570
+ payload: string;
571
+ headers: Record<string, string | string[] | undefined>;
572
+ secret: string;
573
+ toleranceSec?: number;
574
+ }): Promise<{
575
+ ok: true;
576
+ }>;
577
+ parseEvent<T = unknown>(payload: string): WebhookEvent<T>;
578
+ parseEvent(payload: string): ReportCompletedEvent | ReportFailedEvent | WebhookEvent<unknown>;
579
+ }
580
+ //#endregion
581
+ //#region src/Mappa.d.ts
582
+ type MappaClientOptions = {
583
+ /** API key used for Mappa authenticated requests. */apiKey: string; /** Base API URL. Defaults to https://api.mappa.ai. */
584
+ baseUrl?: string; /** Per-request timeout in milliseconds. Defaults to 30000. */
585
+ timeoutMs?: number; /** Number of retry attempts for retryable requests. Defaults to 2. */
586
+ maxRetries?: number; /** Headers included on every request. */
587
+ defaultHeaders?: Record<string, string>; /** Custom fetch implementation. */
588
+ fetch?: typeof fetch; /** User-Agent header value sent on requests. */
589
+ userAgent?: string; /** Request/response/error instrumentation hooks. */
590
+ telemetry?: Telemetry;
591
+ /**
592
+ * Allow use from browser-like runtimes.
593
+ *
594
+ * This is unsafe for secret API keys and should only be used when
595
+ * credentials are intentionally exposed.
596
+ */
597
+ dangerouslyAllowBrowser?: boolean;
598
+ };
599
+ /**
600
+ * Mappa API client for server and worker runtimes.
601
+ */
602
+ declare class Mappa {
603
+ readonly files: FilesResource;
604
+ readonly jobs: JobsResource;
605
+ readonly reports: ReportsResource;
606
+ readonly matchingAnalysis: MatchingAnalysisResource;
607
+ readonly feedback: FeedbackResource;
608
+ readonly entities: EntitiesResource;
609
+ readonly webhooks: WebhooksResource;
610
+ readonly health: HealthResource;
611
+ private readonly transport;
612
+ private readonly opts;
613
+ /** Create a new client instance. */
614
+ constructor(options: MappaClientOptions);
615
+ /** Clone the client with option overrides. */
616
+ withOptions(overrides: Partial<MappaClientOptions>): Mappa;
617
+ close(): void;
618
+ }
619
+ //#endregion
620
+ export { MediaRetention as A, TargetSelector as B, MatchingAnalysisJobReceipt as C, MatchingAnalysisRunHandle as D, MatchingAnalysisResponse as E, ReportOutput as F, WaitOptions as H, ReportOutputType as I, ReportRunHandle as L, ReportCreateJobRequest as M, ReportForOutputType as N, MediaFile as O, ReportJobReceipt as P, ReportTemplateId as R, MatchingAnalysisForOutputType as S, MatchingAnalysisOutputType as T, WebhookConfig as U, Usage as V, hasEntity as W, JsonValue as _, ReportFailedEvent as a, MatchingAnalysisCreateJobRequest as b, Entity as c, FileDeleteReceipt as d, Job as f, JobStatus as g, JobStage as h, ReportFailedData as i, Report as j, MediaObject as k, FeedbackCreateRequest as l, JobEvent as m, ReportCompletedData as n, WebhookEvent as o, JobCreditReservation as p, ReportCompletedEvent as r, WebhookEventType as s, Mappa as t, FeedbackReceipt as u, ListEntitiesResponse as v, MatchingAnalysisOutput as w, MatchingAnalysisEntitySource as x, ListFilesResponse as y, RetentionLockResult as z };
621
+ //# sourceMappingURL=Mappa-BTrlzSaB.d.cts.map