@mymehq/sdk 3.8.0 → 4.0.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 +49 -16
- package/dist/index.js +10 -4
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MergeStrategy, ConflictSnapshot, MergePolicy, ItemState, Item, CreateItemInput, PaginatedResult, ItemWithMetadata, Version, Edge, Metadata, SearchResult, CreateEdgeInput, EdgeTypeSchema, TypeSchema, CreateKeyInput, ApiKey, UpdateKeyInput, CreateWebhookInput, Webhook, UpdateWebhookInput, WebhookDelivery, TenantConfig } from '@mymehq/shared';
|
|
1
|
+
import { MergeStrategy, ConflictSnapshot, MergePolicy, ItemState, Tier, Item, CreateItemInput, PaginatedResult, ItemWithMetadata, Version, Edge, Metadata, SearchResult, CreateEdgeInput, EdgeTypeSchema, TypeSchema, CreateKeyInput, ApiKey, UpdateKeyInput, CreateWebhookInput, Webhook, UpdateWebhookInput, WebhookDelivery, TenantConfig } from '@mymehq/shared';
|
|
2
2
|
export { ApiKey, ConflictSnapshot, CreateItemInput, CreateKeyInput, Item, ItemState, MergePolicy, MergeStrategy, Metadata, PaginatedResult, SearchResult, TypeSchema, UpdateKeyInput, Version } from '@mymehq/shared';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -94,9 +94,9 @@ interface UpdateOptions {
|
|
|
94
94
|
conflict?: ConflictStrategy;
|
|
95
95
|
/** Custom conflict resolver (required when `conflict` is `"callback"`). */
|
|
96
96
|
resolve?: ConflictResolver;
|
|
97
|
-
/** Toggle library
|
|
98
|
-
* for `properties`; a
|
|
99
|
-
|
|
97
|
+
/** Toggle the tier (`library` ↔ `feed`). Independent of the version-merge
|
|
98
|
+
* path for `properties`; a tier-only update never conflicts. */
|
|
99
|
+
tier?: Tier;
|
|
100
100
|
/**
|
|
101
101
|
* Item type. Required by the `auto` strategy when a `keep_both_copies`
|
|
102
102
|
* conflict spawns a sibling item. Omit to let the SDK pre-fetch it —
|
|
@@ -115,10 +115,9 @@ interface ListFilters {
|
|
|
115
115
|
type?: string;
|
|
116
116
|
state?: ItemState;
|
|
117
117
|
source?: string;
|
|
118
|
-
/**
|
|
119
|
-
*
|
|
120
|
-
|
|
121
|
-
library?: boolean;
|
|
118
|
+
/** Tier filter. `"library"` restricts to library items; `"feed"` restricts
|
|
119
|
+
* to feed items; `"all"` (or omitting the field) returns both. */
|
|
120
|
+
tier?: Tier | "all";
|
|
122
121
|
tags?: string[];
|
|
123
122
|
/** Filter-language expression, e.g. `edge[parent-of] eq "<id>"` or
|
|
124
123
|
* `edge[parent-of] not_exists`. The filter language replaces the
|
|
@@ -152,8 +151,8 @@ type ItemWithExtensions = Item & {
|
|
|
152
151
|
interface SearchFilters {
|
|
153
152
|
type?: string;
|
|
154
153
|
state?: ItemState;
|
|
155
|
-
/**
|
|
156
|
-
|
|
154
|
+
/** Tier filter, matching `ListFilters.tier`. */
|
|
155
|
+
tier?: Tier | "all";
|
|
157
156
|
/** Items must have ALL specified tags (AND semantics). Matches
|
|
158
157
|
* `ListFilters.tags` and `/items?tags=`. */
|
|
159
158
|
tags?: string[];
|
|
@@ -170,7 +169,7 @@ interface BulkItemInput {
|
|
|
170
169
|
type: string;
|
|
171
170
|
properties?: Record<string, unknown>;
|
|
172
171
|
state?: ItemState;
|
|
173
|
-
|
|
172
|
+
tier?: Tier;
|
|
174
173
|
timestamp?: string;
|
|
175
174
|
/** Ignored on the wire — server stamps `source` from the credential.
|
|
176
175
|
* Kept on the input shape for round-trip parity with /export output. */
|
|
@@ -265,7 +264,7 @@ interface BulkActionFilter {
|
|
|
265
264
|
type?: string;
|
|
266
265
|
state?: ItemState;
|
|
267
266
|
source?: string;
|
|
268
|
-
|
|
267
|
+
tier?: Tier | "all";
|
|
269
268
|
tags?: string[];
|
|
270
269
|
since?: string;
|
|
271
270
|
until?: string;
|
|
@@ -295,8 +294,8 @@ type BulkActionInput = (BulkActionBase & {
|
|
|
295
294
|
add?: string[];
|
|
296
295
|
remove?: string[];
|
|
297
296
|
}) | (BulkActionBase & {
|
|
298
|
-
action: "
|
|
299
|
-
|
|
297
|
+
action: "update_tier";
|
|
298
|
+
tier: Tier;
|
|
300
299
|
}) | (BulkActionBase & {
|
|
301
300
|
action: "update_properties";
|
|
302
301
|
patch: Record<string, unknown>;
|
|
@@ -486,7 +485,7 @@ declare class MymeClient {
|
|
|
486
485
|
readonly keys: {
|
|
487
486
|
/** Creates an API key. The raw key value is returned exactly once on
|
|
488
487
|
* creation; the rest of the shape mirrors the persisted ApiKey record
|
|
489
|
-
* (source, default_origin,
|
|
488
|
+
* (source, default_origin, default_tier, type_permissions, and
|
|
490
489
|
* extension_permissions are all stamped at create time and visible
|
|
491
490
|
* here so the caller doesn't need a follow-up GET /keys to inspect
|
|
492
491
|
* them). */
|
|
@@ -574,6 +573,40 @@ declare class ConflictError extends MymeError {
|
|
|
574
573
|
constructor(current: ConflictSnapshot, ancestor: ConflictSnapshot, conflictingFields: string[], clientPatch: Record<string, unknown>);
|
|
575
574
|
}
|
|
576
575
|
|
|
576
|
+
/**
|
|
577
|
+
* Authoring helper for declaring custom Myme types in TypeScript (TSC42 §7).
|
|
578
|
+
*
|
|
579
|
+
* The function is a no-op at runtime — it returns its input unchanged. Its
|
|
580
|
+
* value is at the type level: `defineType` constrains the argument to a
|
|
581
|
+
* structurally-valid `TypeSchema`, surfacing field-shape mistakes at compile
|
|
582
|
+
* time rather than at `POST /types` rejection time. Pair with the SDK's
|
|
583
|
+
* `client.types.register(schema)` call to register the type with the server.
|
|
584
|
+
*
|
|
585
|
+
* Example:
|
|
586
|
+
*
|
|
587
|
+
* ```ts
|
|
588
|
+
* import { defineType } from "@mymehq/sdk";
|
|
589
|
+
*
|
|
590
|
+
* export const acmeDeal = defineType({
|
|
591
|
+
* id: "acme.deal",
|
|
592
|
+
* label: "Deal",
|
|
593
|
+
* description: "A sales pipeline opportunity",
|
|
594
|
+
* version: 1,
|
|
595
|
+
* fields: {
|
|
596
|
+
* name: { type: "string", description: "Deal name", required: true },
|
|
597
|
+
* amount: { type: "number", description: "Deal value (USD)" },
|
|
598
|
+
* },
|
|
599
|
+
* });
|
|
600
|
+
*
|
|
601
|
+
* await client.types.register(acmeDeal);
|
|
602
|
+
* ```
|
|
603
|
+
*
|
|
604
|
+
* The helper preserves the literal types of the schema (via the generic
|
|
605
|
+
* parameter), so downstream code that reads `acmeDeal.fields.name.type` sees
|
|
606
|
+
* the narrowed literal `"string"` rather than the wide `FieldType` union.
|
|
607
|
+
*/
|
|
608
|
+
declare function defineType<T extends TypeSchema>(schema: T): T;
|
|
609
|
+
|
|
577
610
|
/**
|
|
578
611
|
* Reason a webhook signature did not validate. Receivers should treat
|
|
579
612
|
* any non-`valid` result as "do not trust this delivery".
|
|
@@ -626,4 +659,4 @@ interface VerifyWebhookSignatureInput {
|
|
|
626
659
|
*/
|
|
627
660
|
declare function verifyWebhookSignature(input: VerifyWebhookSignatureInput): WebhookVerifyResult;
|
|
628
661
|
|
|
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 };
|
|
662
|
+
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, defineType, verifyWebhookSignature };
|
package/dist/index.js
CHANGED
|
@@ -239,7 +239,7 @@ function toConflictError(response, clientPatch) {
|
|
|
239
239
|
clientPatch
|
|
240
240
|
);
|
|
241
241
|
}
|
|
242
|
-
async function handleConflictUpdate(transport, itemId, itemType, clientPatch, version, strategy, resolver,
|
|
242
|
+
async function handleConflictUpdate(transport, itemId, itemType, clientPatch, version, strategy, resolver, tier, onAutoMerge) {
|
|
243
243
|
let properties = clientPatch;
|
|
244
244
|
let currentVersion = version;
|
|
245
245
|
let pendingAutoMergeEvent;
|
|
@@ -248,7 +248,7 @@ async function handleConflictUpdate(transport, itemId, itemType, clientPatch, ve
|
|
|
248
248
|
body: {
|
|
249
249
|
properties,
|
|
250
250
|
version: currentVersion,
|
|
251
|
-
...
|
|
251
|
+
...tier !== void 0 && { tier }
|
|
252
252
|
}
|
|
253
253
|
});
|
|
254
254
|
if (!isConflictResponse(result)) {
|
|
@@ -401,7 +401,7 @@ var MymeClient = class {
|
|
|
401
401
|
version,
|
|
402
402
|
strategy,
|
|
403
403
|
options?.resolve,
|
|
404
|
-
options?.
|
|
404
|
+
options?.tier,
|
|
405
405
|
onAutoMerge
|
|
406
406
|
);
|
|
407
407
|
},
|
|
@@ -750,7 +750,7 @@ var MymeClient = class {
|
|
|
750
750
|
keys = {
|
|
751
751
|
/** Creates an API key. The raw key value is returned exactly once on
|
|
752
752
|
* creation; the rest of the shape mirrors the persisted ApiKey record
|
|
753
|
-
* (source, default_origin,
|
|
753
|
+
* (source, default_origin, default_tier, type_permissions, and
|
|
754
754
|
* extension_permissions are all stamped at create time and visible
|
|
755
755
|
* here so the caller doesn't need a follow-up GET /keys to inspect
|
|
756
756
|
* them). */
|
|
@@ -862,6 +862,11 @@ var MymeClient = class {
|
|
|
862
862
|
}
|
|
863
863
|
};
|
|
864
864
|
|
|
865
|
+
// src/define-type.ts
|
|
866
|
+
function defineType(schema) {
|
|
867
|
+
return schema;
|
|
868
|
+
}
|
|
869
|
+
|
|
865
870
|
// src/webhooks.ts
|
|
866
871
|
import { createHmac, timingSafeEqual } from "crypto";
|
|
867
872
|
var STRIPE_HEADER_RE = /^t=(\d+),v1=([0-9a-f]+)$/;
|
|
@@ -900,5 +905,6 @@ export {
|
|
|
900
905
|
NotFoundError,
|
|
901
906
|
UnauthorizedError,
|
|
902
907
|
ValidationError,
|
|
908
|
+
defineType,
|
|
903
909
|
verifyWebhookSignature
|
|
904
910
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mymehq/sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org",
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
"dist"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@mymehq/shared": "
|
|
19
|
+
"@mymehq/shared": "4.0.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@types/node": "^22.0.0",
|
|
23
23
|
"tsup": "^8.5.1",
|
|
24
24
|
"typescript": "^6.0.2",
|
|
25
|
-
"@mymehq/server": "0.0
|
|
25
|
+
"@mymehq/server": "1.0.0"
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
28
|
"build": "tsup",
|