@mymehq/sdk 3.6.0 → 3.8.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 +70 -5
- package/dist/index.js +33 -14
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -217,6 +217,47 @@ interface BulkResult {
|
|
|
217
217
|
/** Present only on archive-restore paths. */
|
|
218
218
|
blobs_imported?: number;
|
|
219
219
|
}
|
|
220
|
+
/** One edge to create or upsert in a `POST /edges/bulk` call. */
|
|
221
|
+
interface BulkEdgeInputItem {
|
|
222
|
+
/** Optional server-id override. Server-generated UUIDv7 otherwise. */
|
|
223
|
+
id?: string;
|
|
224
|
+
source_id: string;
|
|
225
|
+
target_id: string;
|
|
226
|
+
edge_type: string;
|
|
227
|
+
properties?: Record<string, unknown>;
|
|
228
|
+
}
|
|
229
|
+
interface BulkEdgeInput {
|
|
230
|
+
edges: BulkEdgeInputItem[];
|
|
231
|
+
/** Default: `"upsert"`. On duplicate `(source_id, target_id, edge_type)`:
|
|
232
|
+
* `"upsert"` replaces properties in place; `"create_only"` skips with
|
|
233
|
+
* reason `"duplicate_edge"`. */
|
|
234
|
+
mode?: BulkMode;
|
|
235
|
+
/** Default: `true`. When false, errors are collected per edge and the
|
|
236
|
+
* batch continues past failures. */
|
|
237
|
+
atomic?: boolean;
|
|
238
|
+
/** Default: `false`. Per-edge `edge.created` / `edge.deleted` webhook
|
|
239
|
+
* events are suppressed on bulk writes unless the caller opts in. */
|
|
240
|
+
emit_events?: boolean;
|
|
241
|
+
}
|
|
242
|
+
interface BulkEdgeResultEntry {
|
|
243
|
+
index: number;
|
|
244
|
+
outcome: BulkOutcome;
|
|
245
|
+
id?: string;
|
|
246
|
+
reason?: string;
|
|
247
|
+
error?: {
|
|
248
|
+
code: string;
|
|
249
|
+
message: string;
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
interface BulkEdgeResult {
|
|
253
|
+
counts: {
|
|
254
|
+
created: number;
|
|
255
|
+
updated: number;
|
|
256
|
+
skipped: number;
|
|
257
|
+
errored: number;
|
|
258
|
+
};
|
|
259
|
+
results: BulkEdgeResultEntry[];
|
|
260
|
+
}
|
|
220
261
|
/** Filter shape for `POST /items/bulk_action`. Mirrors the `GET /items`
|
|
221
262
|
* query grammar — every field is AND-composed, `filter` accepts the
|
|
222
263
|
* full filter-SQL DSL. */
|
|
@@ -388,6 +429,21 @@ declare class MymeClient {
|
|
|
388
429
|
* are immutable; server rejects with 400. */
|
|
389
430
|
update: (id: string, properties: Record<string, unknown>) => Promise<Edge>;
|
|
390
431
|
delete: (id: string) => Promise<void>;
|
|
432
|
+
/**
|
|
433
|
+
* Create or upsert many edges in one call (admin-only). Up to 5000
|
|
434
|
+
* edges per call.
|
|
435
|
+
*
|
|
436
|
+
* Modes: `"upsert"` (default) replaces properties on existing
|
|
437
|
+
* `(source_id, target_id, edge_type)` triples; `"create_only"` surfaces
|
|
438
|
+
* duplicates as `skipped` with reason `"duplicate_edge"`. `atomic: true`
|
|
439
|
+
* (default) rolls back the whole batch on any failure — per-edge errors
|
|
440
|
+
* for non-atomic mode land in each result entry.
|
|
441
|
+
*
|
|
442
|
+
* Sibling to `items.bulk` for the edges half of mode-transition
|
|
443
|
+
* migrations (where cross-item edges can't reliably ride along as
|
|
444
|
+
* inline-edge payloads on the item writes).
|
|
445
|
+
*/
|
|
446
|
+
bulk: (input: BulkEdgeInput) => Promise<BulkEdgeResult>;
|
|
391
447
|
/** Outbound edges — items where this id is source. Filter by edge type
|
|
392
448
|
* (comma-separated string or array of type ids). */
|
|
393
449
|
listFromSource: (sourceId: string, filters?: {
|
|
@@ -489,17 +545,26 @@ declare class MymeError extends Error {
|
|
|
489
545
|
readonly details?: Record<string, unknown>;
|
|
490
546
|
constructor(code: string, message: string, status: number, details?: Record<string, unknown>, cause?: unknown);
|
|
491
547
|
}
|
|
548
|
+
/**
|
|
549
|
+
* Status-coded subclasses preserve the server-supplied `code` so callers
|
|
550
|
+
* can branch on specific codes (`bulk_cap_exceeded`, `edge_not_found`,
|
|
551
|
+
* `reset_disabled`, …) while still matching `instanceof NotFoundError`
|
|
552
|
+
* etc. for generic handling. The status family (4xx bucket) is
|
|
553
|
+
* communicated by the class; the specific code is communicated by the
|
|
554
|
+
* `code` field. When the server omits a code, the canonical value for
|
|
555
|
+
* the status family is used as a fallback.
|
|
556
|
+
*/
|
|
492
557
|
declare class NotFoundError extends MymeError {
|
|
493
|
-
constructor(message: string, details?: Record<string, unknown
|
|
558
|
+
constructor(message: string, details?: Record<string, unknown>, code?: string);
|
|
494
559
|
}
|
|
495
560
|
declare class ValidationError extends MymeError {
|
|
496
|
-
constructor(message: string, details?: Record<string, unknown
|
|
561
|
+
constructor(message: string, details?: Record<string, unknown>, code?: string);
|
|
497
562
|
}
|
|
498
563
|
declare class UnauthorizedError extends MymeError {
|
|
499
|
-
constructor(message: string, details?: Record<string, unknown
|
|
564
|
+
constructor(message: string, details?: Record<string, unknown>, code?: string);
|
|
500
565
|
}
|
|
501
566
|
declare class ForbiddenError extends MymeError {
|
|
502
|
-
constructor(message: string, details?: Record<string, unknown
|
|
567
|
+
constructor(message: string, details?: Record<string, unknown>, code?: string);
|
|
503
568
|
}
|
|
504
569
|
declare class ConflictError extends MymeError {
|
|
505
570
|
readonly current: ConflictSnapshot;
|
|
@@ -561,4 +626,4 @@ interface VerifyWebhookSignatureInput {
|
|
|
561
626
|
*/
|
|
562
627
|
declare function verifyWebhookSignature(input: VerifyWebhookSignatureInput): WebhookVerifyResult;
|
|
563
628
|
|
|
564
|
-
export { type BulkActionErrorEntry, type BulkActionFilter, type BulkActionInput, type BulkActionResult, type BulkInput, type BulkItemInput, type BulkMode, type BulkOutcome, type BulkResult, type BulkResultEntry, type ClientConfig, type ConflictAutoMergeListener, type ConflictAutoMergedEvent, type ConflictData, ConflictError, type ConflictResolver, type ConflictStrategy, ForbiddenError, type ItemWithExtensions, type ListFilters, type MetadataInput, MymeClient, MymeError, NotFoundError, type SearchFilters, UnauthorizedError, type UpdateOptions, ValidationError, type VerifyWebhookSignatureInput, type WebhookVerifyReason, type WebhookVerifyResult, verifyWebhookSignature };
|
|
629
|
+
export { type BulkActionErrorEntry, type BulkActionFilter, type BulkActionInput, type BulkActionResult, type BulkEdgeInput, type BulkEdgeInputItem, type BulkEdgeResult, type BulkEdgeResultEntry, type BulkInput, type BulkItemInput, type BulkMode, type BulkOutcome, type BulkResult, type BulkResultEntry, type ClientConfig, type ConflictAutoMergeListener, type ConflictAutoMergedEvent, type ConflictData, ConflictError, type ConflictResolver, type ConflictStrategy, ForbiddenError, type ItemWithExtensions, type ListFilters, type MetadataInput, MymeClient, MymeError, NotFoundError, type SearchFilters, UnauthorizedError, type UpdateOptions, ValidationError, type VerifyWebhookSignatureInput, type WebhookVerifyReason, type WebhookVerifyResult, verifyWebhookSignature };
|
package/dist/index.js
CHANGED
|
@@ -12,26 +12,26 @@ var MymeError = class extends Error {
|
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
14
|
var NotFoundError = class extends MymeError {
|
|
15
|
-
constructor(message, details) {
|
|
16
|
-
super("not_found", message, 404, details);
|
|
15
|
+
constructor(message, details, code) {
|
|
16
|
+
super(code ?? "not_found", message, 404, details);
|
|
17
17
|
this.name = "NotFoundError";
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
20
|
var ValidationError = class extends MymeError {
|
|
21
|
-
constructor(message, details) {
|
|
22
|
-
super("validation_error", message, 400, details);
|
|
21
|
+
constructor(message, details, code) {
|
|
22
|
+
super(code ?? "validation_error", message, 400, details);
|
|
23
23
|
this.name = "ValidationError";
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
var UnauthorizedError = class extends MymeError {
|
|
27
|
-
constructor(message, details) {
|
|
28
|
-
super("unauthorized", message, 401, details);
|
|
27
|
+
constructor(message, details, code) {
|
|
28
|
+
super(code ?? "unauthorized", message, 401, details);
|
|
29
29
|
this.name = "UnauthorizedError";
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
32
|
var ForbiddenError = class extends MymeError {
|
|
33
|
-
constructor(message, details) {
|
|
34
|
-
super("forbidden", message, 403, details);
|
|
33
|
+
constructor(message, details, code) {
|
|
34
|
+
super(code ?? "forbidden", message, 403, details);
|
|
35
35
|
this.name = "ForbiddenError";
|
|
36
36
|
}
|
|
37
37
|
};
|
|
@@ -167,18 +167,18 @@ var HttpTransport = class {
|
|
|
167
167
|
const errObj = parsed?.error;
|
|
168
168
|
const message = errObj?.message ?? `HTTP ${String(status)}`;
|
|
169
169
|
const details = errObj?.details;
|
|
170
|
-
const
|
|
170
|
+
const serverCode = errObj?.code;
|
|
171
171
|
switch (status) {
|
|
172
172
|
case 400:
|
|
173
|
-
throw new ValidationError(message, details);
|
|
173
|
+
throw new ValidationError(message, details, serverCode);
|
|
174
174
|
case 401:
|
|
175
|
-
throw new UnauthorizedError(message, details);
|
|
175
|
+
throw new UnauthorizedError(message, details, serverCode);
|
|
176
176
|
case 403:
|
|
177
|
-
throw new ForbiddenError(message, details);
|
|
177
|
+
throw new ForbiddenError(message, details, serverCode);
|
|
178
178
|
case 404:
|
|
179
|
-
throw new NotFoundError(message, details);
|
|
179
|
+
throw new NotFoundError(message, details, serverCode);
|
|
180
180
|
default:
|
|
181
|
-
throw new MymeError(
|
|
181
|
+
throw new MymeError(serverCode ?? "unknown", message, status, details);
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
};
|
|
@@ -613,6 +613,25 @@ var MymeClient = class {
|
|
|
613
613
|
delete: async (id) => {
|
|
614
614
|
await this.transport.request("DELETE", `/edges/${id}`);
|
|
615
615
|
},
|
|
616
|
+
/**
|
|
617
|
+
* Create or upsert many edges in one call (admin-only). Up to 5000
|
|
618
|
+
* edges per call.
|
|
619
|
+
*
|
|
620
|
+
* Modes: `"upsert"` (default) replaces properties on existing
|
|
621
|
+
* `(source_id, target_id, edge_type)` triples; `"create_only"` surfaces
|
|
622
|
+
* duplicates as `skipped` with reason `"duplicate_edge"`. `atomic: true`
|
|
623
|
+
* (default) rolls back the whole batch on any failure — per-edge errors
|
|
624
|
+
* for non-atomic mode land in each result entry.
|
|
625
|
+
*
|
|
626
|
+
* Sibling to `items.bulk` for the edges half of mode-transition
|
|
627
|
+
* migrations (where cross-item edges can't reliably ride along as
|
|
628
|
+
* inline-edge payloads on the item writes).
|
|
629
|
+
*/
|
|
630
|
+
bulk: async (input) => {
|
|
631
|
+
return this.transport.request("POST", "/edges/bulk", {
|
|
632
|
+
body: input
|
|
633
|
+
});
|
|
634
|
+
},
|
|
616
635
|
/** Outbound edges — items where this id is source. Filter by edge type
|
|
617
636
|
* (comma-separated string or array of type ids). */
|
|
618
637
|
listFromSource: async (sourceId, filters) => {
|