@seed-hypermedia/client 0.0.13 → 0.0.15

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.
@@ -941,6 +941,34 @@ var HMListCommentVersionsRequestSchema = z.object({
941
941
  input: HMListCommentVersionsInputSchema,
942
942
  output: HMListCommentVersionsOutputSchema
943
943
  });
944
+ var HMDomainInfoSchema = z.object({
945
+ domain: z.string(),
946
+ lastCheck: z.date().nullable(),
947
+ status: z.string(),
948
+ lastSuccess: z.date().nullable(),
949
+ registeredAccountUid: z.string().nullable(),
950
+ peerId: z.string().nullable(),
951
+ lastError: z.string().nullable()
952
+ });
953
+ var HMGetDomainInputSchema = z.object({
954
+ domain: z.string(),
955
+ /** If true, forces a fresh HTTP check instead of returning cached data. */
956
+ forceCheck: z.boolean().optional()
957
+ });
958
+ var HMGetDomainRequestSchema = z.object({
959
+ key: z.literal("GetDomain"),
960
+ input: HMGetDomainInputSchema,
961
+ output: HMDomainInfoSchema
962
+ });
963
+ var HMListDomainsInputSchema = z.object({});
964
+ var HMListDomainsOutputSchema = z.object({
965
+ domains: z.array(HMDomainInfoSchema)
966
+ });
967
+ var HMListDomainsRequestSchema = z.object({
968
+ key: z.literal("ListDomains"),
969
+ input: HMListDomainsInputSchema,
970
+ output: HMListDomainsOutputSchema
971
+ });
944
972
  var HMGetRequestSchema = z.discriminatedUnion("key", [
945
973
  HMResourceRequestSchema,
946
974
  HMResourceMetadataRequestSchema,
@@ -962,7 +990,9 @@ var HMGetRequestSchema = z.discriminatedUnion("key", [
962
990
  HMListChangesRequestSchema,
963
991
  HMListCapabilitiesRequestSchema,
964
992
  HMInteractionSummaryRequestSchema,
965
- HMListCommentVersionsRequestSchema
993
+ HMListCommentVersionsRequestSchema,
994
+ HMGetDomainRequestSchema,
995
+ HMListDomainsRequestSchema
966
996
  ]);
967
997
  var HMActionSchema = z.discriminatedUnion("key", [
968
998
  HMPublishBlobsRequestSchema,
@@ -990,6 +1020,8 @@ var HMRequestSchema = z.discriminatedUnion("key", [
990
1020
  HMListCapabilitiesRequestSchema,
991
1021
  HMInteractionSummaryRequestSchema,
992
1022
  HMListCommentVersionsRequestSchema,
1023
+ HMGetDomainRequestSchema,
1024
+ HMListDomainsRequestSchema,
993
1025
  HMPublishBlobsRequestSchema,
994
1026
  HMPrepareDocumentChangeRequestSchema
995
1027
  ]);
@@ -1148,87 +1180,6 @@ function isSurrogate(s, i) {
1148
1180
  const code = s.charCodeAt(i);
1149
1181
  return 55296 <= code && code <= 56319;
1150
1182
  }
1151
- async function resolveHypermediaUrl(url) {
1152
- let latest = false;
1153
- let blockRef = null;
1154
- let blockRange = null;
1155
- let panel = null;
1156
- try {
1157
- const parsedUrl = new URL(url);
1158
- const hasVersion = parsedUrl.searchParams.has("v");
1159
- const hasLatest = parsedUrl.searchParams.has("l");
1160
- panel = parsedUrl.searchParams.get("panel");
1161
- if (parsedUrl.hash) {
1162
- const fragment = parseFragment(parsedUrl.hash.slice(1));
1163
- if (fragment) {
1164
- blockRef = fragment.blockId;
1165
- if ("start" in fragment && fragment.start !== void 0) {
1166
- blockRange = { start: fragment.start, end: fragment.end };
1167
- } else if ("expanded" in fragment && fragment.expanded) {
1168
- blockRange = { expanded: fragment.expanded };
1169
- }
1170
- }
1171
- }
1172
- latest = blockRef ? false : hasLatest || !hasVersion;
1173
- } catch {
1174
- }
1175
- const response = await fetch(url, {
1176
- method: "OPTIONS"
1177
- });
1178
- if (response.status === 200) {
1179
- const rawId = response.headers.get("x-hypermedia-id");
1180
- const id = rawId ? decodeURIComponent(rawId) : null;
1181
- const version = response.headers.get("x-hypermedia-version");
1182
- const encodedTitle = response.headers.get("x-hypermedia-title");
1183
- const title = encodedTitle ? decodeURIComponent(encodedTitle) : null;
1184
- const rawTarget = response.headers.get("x-hypermedia-target");
1185
- const target = rawTarget ? unpackHmId(decodeURIComponent(rawTarget)) : null;
1186
- const rawAuthors = response.headers.get("x-hypermedia-authors");
1187
- const authors = rawAuthors ? decodeURIComponent(rawAuthors).split(",").map((author) => unpackHmId(author)) : null;
1188
- const type = response.headers.get("x-hypermedia-type");
1189
- if (id) {
1190
- const hmId = unpackHmId(id);
1191
- const resolvedVersion = version ?? (hmId == null ? void 0 : hmId.version) ?? null;
1192
- let siteHostname = null;
1193
- try {
1194
- const inputUrl = new URL(url);
1195
- if (!inputUrl.pathname.startsWith("/hm/")) {
1196
- siteHostname = inputUrl.origin;
1197
- }
1198
- } catch {
1199
- }
1200
- return {
1201
- id,
1202
- hmId: hmId ? {
1203
- ...hmId,
1204
- version: resolvedVersion,
1205
- latest,
1206
- blockRef,
1207
- blockRange,
1208
- hostname: siteHostname || hmId.hostname
1209
- } : null,
1210
- version,
1211
- title,
1212
- target,
1213
- authors,
1214
- type,
1215
- panel
1216
- };
1217
- }
1218
- return null;
1219
- }
1220
- return null;
1221
- }
1222
- async function resolveId(input) {
1223
- const parsed = unpackHmId(input);
1224
- if (parsed) return parsed;
1225
- if (input.startsWith("http://") || input.startsWith("https://")) {
1226
- const resolved = await resolveHypermediaUrl(input);
1227
- if (resolved == null ? void 0 : resolved.hmId) return resolved.hmId;
1228
- throw new Error(`URL does not appear to be a Seed Hypermedia resource: ${input}`);
1229
- }
1230
- throw new Error(`Invalid Hypermedia ID: ${input}`);
1231
- }
1232
1183
 
1233
1184
  export {
1234
1185
  BlockRangeSchema,
@@ -1376,6 +1327,12 @@ export {
1376
1327
  HMListCommentVersionsInputSchema,
1377
1328
  HMListCommentVersionsOutputSchema,
1378
1329
  HMListCommentVersionsRequestSchema,
1330
+ HMDomainInfoSchema,
1331
+ HMGetDomainInputSchema,
1332
+ HMGetDomainRequestSchema,
1333
+ HMListDomainsInputSchema,
1334
+ HMListDomainsOutputSchema,
1335
+ HMListDomainsRequestSchema,
1379
1336
  HMGetRequestSchema,
1380
1337
  HMActionSchema,
1381
1338
  HMRequestSchema,
@@ -1390,7 +1347,5 @@ export {
1390
1347
  parseFragment,
1391
1348
  unpackHmId,
1392
1349
  codePointLength,
1393
- isSurrogate,
1394
- resolveHypermediaUrl,
1395
- resolveId
1350
+ isSurrogate
1396
1351
  };
@@ -0,0 +1,38 @@
1
+ import { type UnpackedHypermediaId } from './hm-types';
2
+ /**
3
+ * A domain resolver function that maps a hostname to an account UID
4
+ * using the daemon's domain store. Returns the UID if cached, or null.
5
+ */
6
+ export type DomainResolverFn = (hostname: string) => Promise<string | null>;
7
+ /**
8
+ * Callback fired when a background domain check detects that a domain
9
+ * now points to a different account UID than what was cached.
10
+ */
11
+ export type DomainIdChangedCallback = (domain: string, oldUid: string, newUid: string) => void;
12
+ export type ResolveOptions = {
13
+ domainResolver?: DomainResolverFn;
14
+ };
15
+ /**
16
+ * Resolve a web URL to its Hypermedia metadata.
17
+ *
18
+ * If opts.domainResolver is provided, it is tried first for fast cached
19
+ * resolution (works offline). Falls back to an OPTIONS request if the
20
+ * domain resolver returns null or is not provided.
21
+ */
22
+ export type ResolvedUrl = {
23
+ id: string;
24
+ hmId: UnpackedHypermediaId;
25
+ version: string | null;
26
+ title: string | null;
27
+ target: UnpackedHypermediaId | null;
28
+ authors: UnpackedHypermediaId[] | null;
29
+ type: string | null;
30
+ panel: string | null;
31
+ };
32
+ export declare function resolveHypermediaUrl(url: string, opts?: ResolveOptions): Promise<ResolvedUrl | null>;
33
+ /**
34
+ * Resolve a string that may be an hm:// ID, a gateway URL, or a site web URL
35
+ * into an UnpackedHypermediaId. Tries synchronous parsing first, then falls
36
+ * back to an OPTIONS request for web URLs.
37
+ */
38
+ export declare function resolveId(input: string, opts?: ResolveOptions): Promise<UnpackedHypermediaId>;
@@ -27283,6 +27283,244 @@ export declare const HMListCommentVersionsRequestSchema: z.ZodObject<{
27283
27283
  };
27284
27284
  }>;
27285
27285
  export type HMListCommentVersionsRequest = z.infer<typeof HMListCommentVersionsRequestSchema>;
27286
+ export declare const HMDomainInfoSchema: z.ZodObject<{
27287
+ domain: z.ZodString;
27288
+ lastCheck: z.ZodNullable<z.ZodDate>;
27289
+ status: z.ZodString;
27290
+ lastSuccess: z.ZodNullable<z.ZodDate>;
27291
+ registeredAccountUid: z.ZodNullable<z.ZodString>;
27292
+ peerId: z.ZodNullable<z.ZodString>;
27293
+ lastError: z.ZodNullable<z.ZodString>;
27294
+ }, "strip", z.ZodTypeAny, {
27295
+ status: string;
27296
+ peerId: string | null;
27297
+ registeredAccountUid: string | null;
27298
+ domain: string;
27299
+ lastCheck: Date | null;
27300
+ lastSuccess: Date | null;
27301
+ lastError: string | null;
27302
+ }, {
27303
+ status: string;
27304
+ peerId: string | null;
27305
+ registeredAccountUid: string | null;
27306
+ domain: string;
27307
+ lastCheck: Date | null;
27308
+ lastSuccess: Date | null;
27309
+ lastError: string | null;
27310
+ }>;
27311
+ export type HMDomainInfo = z.infer<typeof HMDomainInfoSchema>;
27312
+ export declare const HMGetDomainInputSchema: z.ZodObject<{
27313
+ domain: z.ZodString;
27314
+ /** If true, forces a fresh HTTP check instead of returning cached data. */
27315
+ forceCheck: z.ZodOptional<z.ZodBoolean>;
27316
+ }, "strip", z.ZodTypeAny, {
27317
+ domain: string;
27318
+ forceCheck?: boolean | undefined;
27319
+ }, {
27320
+ domain: string;
27321
+ forceCheck?: boolean | undefined;
27322
+ }>;
27323
+ export type HMGetDomainInput = z.infer<typeof HMGetDomainInputSchema>;
27324
+ export declare const HMGetDomainRequestSchema: z.ZodObject<{
27325
+ key: z.ZodLiteral<"GetDomain">;
27326
+ input: z.ZodObject<{
27327
+ domain: z.ZodString;
27328
+ /** If true, forces a fresh HTTP check instead of returning cached data. */
27329
+ forceCheck: z.ZodOptional<z.ZodBoolean>;
27330
+ }, "strip", z.ZodTypeAny, {
27331
+ domain: string;
27332
+ forceCheck?: boolean | undefined;
27333
+ }, {
27334
+ domain: string;
27335
+ forceCheck?: boolean | undefined;
27336
+ }>;
27337
+ output: z.ZodObject<{
27338
+ domain: z.ZodString;
27339
+ lastCheck: z.ZodNullable<z.ZodDate>;
27340
+ status: z.ZodString;
27341
+ lastSuccess: z.ZodNullable<z.ZodDate>;
27342
+ registeredAccountUid: z.ZodNullable<z.ZodString>;
27343
+ peerId: z.ZodNullable<z.ZodString>;
27344
+ lastError: z.ZodNullable<z.ZodString>;
27345
+ }, "strip", z.ZodTypeAny, {
27346
+ status: string;
27347
+ peerId: string | null;
27348
+ registeredAccountUid: string | null;
27349
+ domain: string;
27350
+ lastCheck: Date | null;
27351
+ lastSuccess: Date | null;
27352
+ lastError: string | null;
27353
+ }, {
27354
+ status: string;
27355
+ peerId: string | null;
27356
+ registeredAccountUid: string | null;
27357
+ domain: string;
27358
+ lastCheck: Date | null;
27359
+ lastSuccess: Date | null;
27360
+ lastError: string | null;
27361
+ }>;
27362
+ }, "strip", z.ZodTypeAny, {
27363
+ key: "GetDomain";
27364
+ input: {
27365
+ domain: string;
27366
+ forceCheck?: boolean | undefined;
27367
+ };
27368
+ output: {
27369
+ status: string;
27370
+ peerId: string | null;
27371
+ registeredAccountUid: string | null;
27372
+ domain: string;
27373
+ lastCheck: Date | null;
27374
+ lastSuccess: Date | null;
27375
+ lastError: string | null;
27376
+ };
27377
+ }, {
27378
+ key: "GetDomain";
27379
+ input: {
27380
+ domain: string;
27381
+ forceCheck?: boolean | undefined;
27382
+ };
27383
+ output: {
27384
+ status: string;
27385
+ peerId: string | null;
27386
+ registeredAccountUid: string | null;
27387
+ domain: string;
27388
+ lastCheck: Date | null;
27389
+ lastSuccess: Date | null;
27390
+ lastError: string | null;
27391
+ };
27392
+ }>;
27393
+ export type HMGetDomainRequest = z.infer<typeof HMGetDomainRequestSchema>;
27394
+ export declare const HMListDomainsInputSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
27395
+ export type HMListDomainsInput = z.infer<typeof HMListDomainsInputSchema>;
27396
+ export declare const HMListDomainsOutputSchema: z.ZodObject<{
27397
+ domains: z.ZodArray<z.ZodObject<{
27398
+ domain: z.ZodString;
27399
+ lastCheck: z.ZodNullable<z.ZodDate>;
27400
+ status: z.ZodString;
27401
+ lastSuccess: z.ZodNullable<z.ZodDate>;
27402
+ registeredAccountUid: z.ZodNullable<z.ZodString>;
27403
+ peerId: z.ZodNullable<z.ZodString>;
27404
+ lastError: z.ZodNullable<z.ZodString>;
27405
+ }, "strip", z.ZodTypeAny, {
27406
+ status: string;
27407
+ peerId: string | null;
27408
+ registeredAccountUid: string | null;
27409
+ domain: string;
27410
+ lastCheck: Date | null;
27411
+ lastSuccess: Date | null;
27412
+ lastError: string | null;
27413
+ }, {
27414
+ status: string;
27415
+ peerId: string | null;
27416
+ registeredAccountUid: string | null;
27417
+ domain: string;
27418
+ lastCheck: Date | null;
27419
+ lastSuccess: Date | null;
27420
+ lastError: string | null;
27421
+ }>, "many">;
27422
+ }, "strip", z.ZodTypeAny, {
27423
+ domains: {
27424
+ status: string;
27425
+ peerId: string | null;
27426
+ registeredAccountUid: string | null;
27427
+ domain: string;
27428
+ lastCheck: Date | null;
27429
+ lastSuccess: Date | null;
27430
+ lastError: string | null;
27431
+ }[];
27432
+ }, {
27433
+ domains: {
27434
+ status: string;
27435
+ peerId: string | null;
27436
+ registeredAccountUid: string | null;
27437
+ domain: string;
27438
+ lastCheck: Date | null;
27439
+ lastSuccess: Date | null;
27440
+ lastError: string | null;
27441
+ }[];
27442
+ }>;
27443
+ export type HMListDomainsOutput = z.infer<typeof HMListDomainsOutputSchema>;
27444
+ export declare const HMListDomainsRequestSchema: z.ZodObject<{
27445
+ key: z.ZodLiteral<"ListDomains">;
27446
+ input: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
27447
+ output: z.ZodObject<{
27448
+ domains: z.ZodArray<z.ZodObject<{
27449
+ domain: z.ZodString;
27450
+ lastCheck: z.ZodNullable<z.ZodDate>;
27451
+ status: z.ZodString;
27452
+ lastSuccess: z.ZodNullable<z.ZodDate>;
27453
+ registeredAccountUid: z.ZodNullable<z.ZodString>;
27454
+ peerId: z.ZodNullable<z.ZodString>;
27455
+ lastError: z.ZodNullable<z.ZodString>;
27456
+ }, "strip", z.ZodTypeAny, {
27457
+ status: string;
27458
+ peerId: string | null;
27459
+ registeredAccountUid: string | null;
27460
+ domain: string;
27461
+ lastCheck: Date | null;
27462
+ lastSuccess: Date | null;
27463
+ lastError: string | null;
27464
+ }, {
27465
+ status: string;
27466
+ peerId: string | null;
27467
+ registeredAccountUid: string | null;
27468
+ domain: string;
27469
+ lastCheck: Date | null;
27470
+ lastSuccess: Date | null;
27471
+ lastError: string | null;
27472
+ }>, "many">;
27473
+ }, "strip", z.ZodTypeAny, {
27474
+ domains: {
27475
+ status: string;
27476
+ peerId: string | null;
27477
+ registeredAccountUid: string | null;
27478
+ domain: string;
27479
+ lastCheck: Date | null;
27480
+ lastSuccess: Date | null;
27481
+ lastError: string | null;
27482
+ }[];
27483
+ }, {
27484
+ domains: {
27485
+ status: string;
27486
+ peerId: string | null;
27487
+ registeredAccountUid: string | null;
27488
+ domain: string;
27489
+ lastCheck: Date | null;
27490
+ lastSuccess: Date | null;
27491
+ lastError: string | null;
27492
+ }[];
27493
+ }>;
27494
+ }, "strip", z.ZodTypeAny, {
27495
+ key: "ListDomains";
27496
+ input: {};
27497
+ output: {
27498
+ domains: {
27499
+ status: string;
27500
+ peerId: string | null;
27501
+ registeredAccountUid: string | null;
27502
+ domain: string;
27503
+ lastCheck: Date | null;
27504
+ lastSuccess: Date | null;
27505
+ lastError: string | null;
27506
+ }[];
27507
+ };
27508
+ }, {
27509
+ key: "ListDomains";
27510
+ input: {};
27511
+ output: {
27512
+ domains: {
27513
+ status: string;
27514
+ peerId: string | null;
27515
+ registeredAccountUid: string | null;
27516
+ domain: string;
27517
+ lastCheck: Date | null;
27518
+ lastSuccess: Date | null;
27519
+ lastError: string | null;
27520
+ }[];
27521
+ };
27522
+ }>;
27523
+ export type HMListDomainsRequest = z.infer<typeof HMListDomainsRequestSchema>;
27286
27524
  export declare const HMGetRequestSchema: z.ZodDiscriminatedUnion<"key", [z.ZodObject<{
27287
27525
  key: z.ZodLiteral<"Resource">;
27288
27526
  input: z.ZodObject<{
@@ -36373,6 +36611,152 @@ export declare const HMGetRequestSchema: z.ZodDiscriminatedUnion<"key", [z.ZodOb
36373
36611
  capability?: string | undefined;
36374
36612
  }[];
36375
36613
  };
36614
+ }>, z.ZodObject<{
36615
+ key: z.ZodLiteral<"GetDomain">;
36616
+ input: z.ZodObject<{
36617
+ domain: z.ZodString;
36618
+ /** If true, forces a fresh HTTP check instead of returning cached data. */
36619
+ forceCheck: z.ZodOptional<z.ZodBoolean>;
36620
+ }, "strip", z.ZodTypeAny, {
36621
+ domain: string;
36622
+ forceCheck?: boolean | undefined;
36623
+ }, {
36624
+ domain: string;
36625
+ forceCheck?: boolean | undefined;
36626
+ }>;
36627
+ output: z.ZodObject<{
36628
+ domain: z.ZodString;
36629
+ lastCheck: z.ZodNullable<z.ZodDate>;
36630
+ status: z.ZodString;
36631
+ lastSuccess: z.ZodNullable<z.ZodDate>;
36632
+ registeredAccountUid: z.ZodNullable<z.ZodString>;
36633
+ peerId: z.ZodNullable<z.ZodString>;
36634
+ lastError: z.ZodNullable<z.ZodString>;
36635
+ }, "strip", z.ZodTypeAny, {
36636
+ status: string;
36637
+ peerId: string | null;
36638
+ registeredAccountUid: string | null;
36639
+ domain: string;
36640
+ lastCheck: Date | null;
36641
+ lastSuccess: Date | null;
36642
+ lastError: string | null;
36643
+ }, {
36644
+ status: string;
36645
+ peerId: string | null;
36646
+ registeredAccountUid: string | null;
36647
+ domain: string;
36648
+ lastCheck: Date | null;
36649
+ lastSuccess: Date | null;
36650
+ lastError: string | null;
36651
+ }>;
36652
+ }, "strip", z.ZodTypeAny, {
36653
+ key: "GetDomain";
36654
+ input: {
36655
+ domain: string;
36656
+ forceCheck?: boolean | undefined;
36657
+ };
36658
+ output: {
36659
+ status: string;
36660
+ peerId: string | null;
36661
+ registeredAccountUid: string | null;
36662
+ domain: string;
36663
+ lastCheck: Date | null;
36664
+ lastSuccess: Date | null;
36665
+ lastError: string | null;
36666
+ };
36667
+ }, {
36668
+ key: "GetDomain";
36669
+ input: {
36670
+ domain: string;
36671
+ forceCheck?: boolean | undefined;
36672
+ };
36673
+ output: {
36674
+ status: string;
36675
+ peerId: string | null;
36676
+ registeredAccountUid: string | null;
36677
+ domain: string;
36678
+ lastCheck: Date | null;
36679
+ lastSuccess: Date | null;
36680
+ lastError: string | null;
36681
+ };
36682
+ }>, z.ZodObject<{
36683
+ key: z.ZodLiteral<"ListDomains">;
36684
+ input: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
36685
+ output: z.ZodObject<{
36686
+ domains: z.ZodArray<z.ZodObject<{
36687
+ domain: z.ZodString;
36688
+ lastCheck: z.ZodNullable<z.ZodDate>;
36689
+ status: z.ZodString;
36690
+ lastSuccess: z.ZodNullable<z.ZodDate>;
36691
+ registeredAccountUid: z.ZodNullable<z.ZodString>;
36692
+ peerId: z.ZodNullable<z.ZodString>;
36693
+ lastError: z.ZodNullable<z.ZodString>;
36694
+ }, "strip", z.ZodTypeAny, {
36695
+ status: string;
36696
+ peerId: string | null;
36697
+ registeredAccountUid: string | null;
36698
+ domain: string;
36699
+ lastCheck: Date | null;
36700
+ lastSuccess: Date | null;
36701
+ lastError: string | null;
36702
+ }, {
36703
+ status: string;
36704
+ peerId: string | null;
36705
+ registeredAccountUid: string | null;
36706
+ domain: string;
36707
+ lastCheck: Date | null;
36708
+ lastSuccess: Date | null;
36709
+ lastError: string | null;
36710
+ }>, "many">;
36711
+ }, "strip", z.ZodTypeAny, {
36712
+ domains: {
36713
+ status: string;
36714
+ peerId: string | null;
36715
+ registeredAccountUid: string | null;
36716
+ domain: string;
36717
+ lastCheck: Date | null;
36718
+ lastSuccess: Date | null;
36719
+ lastError: string | null;
36720
+ }[];
36721
+ }, {
36722
+ domains: {
36723
+ status: string;
36724
+ peerId: string | null;
36725
+ registeredAccountUid: string | null;
36726
+ domain: string;
36727
+ lastCheck: Date | null;
36728
+ lastSuccess: Date | null;
36729
+ lastError: string | null;
36730
+ }[];
36731
+ }>;
36732
+ }, "strip", z.ZodTypeAny, {
36733
+ key: "ListDomains";
36734
+ input: {};
36735
+ output: {
36736
+ domains: {
36737
+ status: string;
36738
+ peerId: string | null;
36739
+ registeredAccountUid: string | null;
36740
+ domain: string;
36741
+ lastCheck: Date | null;
36742
+ lastSuccess: Date | null;
36743
+ lastError: string | null;
36744
+ }[];
36745
+ };
36746
+ }, {
36747
+ key: "ListDomains";
36748
+ input: {};
36749
+ output: {
36750
+ domains: {
36751
+ status: string;
36752
+ peerId: string | null;
36753
+ registeredAccountUid: string | null;
36754
+ domain: string;
36755
+ lastCheck: Date | null;
36756
+ lastSuccess: Date | null;
36757
+ lastError: string | null;
36758
+ }[];
36759
+ };
36376
36760
  }>]>;
36377
36761
  export type HMGetRequest = z.infer<typeof HMGetRequestSchema>;
36378
36762
  export declare const HMActionSchema: z.ZodDiscriminatedUnion<"key", [z.ZodObject<{
@@ -46235,6 +46619,152 @@ export declare const HMRequestSchema: z.ZodDiscriminatedUnion<"key", [z.ZodObjec
46235
46619
  capability?: string | undefined;
46236
46620
  }[];
46237
46621
  };
46622
+ }>, z.ZodObject<{
46623
+ key: z.ZodLiteral<"GetDomain">;
46624
+ input: z.ZodObject<{
46625
+ domain: z.ZodString;
46626
+ /** If true, forces a fresh HTTP check instead of returning cached data. */
46627
+ forceCheck: z.ZodOptional<z.ZodBoolean>;
46628
+ }, "strip", z.ZodTypeAny, {
46629
+ domain: string;
46630
+ forceCheck?: boolean | undefined;
46631
+ }, {
46632
+ domain: string;
46633
+ forceCheck?: boolean | undefined;
46634
+ }>;
46635
+ output: z.ZodObject<{
46636
+ domain: z.ZodString;
46637
+ lastCheck: z.ZodNullable<z.ZodDate>;
46638
+ status: z.ZodString;
46639
+ lastSuccess: z.ZodNullable<z.ZodDate>;
46640
+ registeredAccountUid: z.ZodNullable<z.ZodString>;
46641
+ peerId: z.ZodNullable<z.ZodString>;
46642
+ lastError: z.ZodNullable<z.ZodString>;
46643
+ }, "strip", z.ZodTypeAny, {
46644
+ status: string;
46645
+ peerId: string | null;
46646
+ registeredAccountUid: string | null;
46647
+ domain: string;
46648
+ lastCheck: Date | null;
46649
+ lastSuccess: Date | null;
46650
+ lastError: string | null;
46651
+ }, {
46652
+ status: string;
46653
+ peerId: string | null;
46654
+ registeredAccountUid: string | null;
46655
+ domain: string;
46656
+ lastCheck: Date | null;
46657
+ lastSuccess: Date | null;
46658
+ lastError: string | null;
46659
+ }>;
46660
+ }, "strip", z.ZodTypeAny, {
46661
+ key: "GetDomain";
46662
+ input: {
46663
+ domain: string;
46664
+ forceCheck?: boolean | undefined;
46665
+ };
46666
+ output: {
46667
+ status: string;
46668
+ peerId: string | null;
46669
+ registeredAccountUid: string | null;
46670
+ domain: string;
46671
+ lastCheck: Date | null;
46672
+ lastSuccess: Date | null;
46673
+ lastError: string | null;
46674
+ };
46675
+ }, {
46676
+ key: "GetDomain";
46677
+ input: {
46678
+ domain: string;
46679
+ forceCheck?: boolean | undefined;
46680
+ };
46681
+ output: {
46682
+ status: string;
46683
+ peerId: string | null;
46684
+ registeredAccountUid: string | null;
46685
+ domain: string;
46686
+ lastCheck: Date | null;
46687
+ lastSuccess: Date | null;
46688
+ lastError: string | null;
46689
+ };
46690
+ }>, z.ZodObject<{
46691
+ key: z.ZodLiteral<"ListDomains">;
46692
+ input: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
46693
+ output: z.ZodObject<{
46694
+ domains: z.ZodArray<z.ZodObject<{
46695
+ domain: z.ZodString;
46696
+ lastCheck: z.ZodNullable<z.ZodDate>;
46697
+ status: z.ZodString;
46698
+ lastSuccess: z.ZodNullable<z.ZodDate>;
46699
+ registeredAccountUid: z.ZodNullable<z.ZodString>;
46700
+ peerId: z.ZodNullable<z.ZodString>;
46701
+ lastError: z.ZodNullable<z.ZodString>;
46702
+ }, "strip", z.ZodTypeAny, {
46703
+ status: string;
46704
+ peerId: string | null;
46705
+ registeredAccountUid: string | null;
46706
+ domain: string;
46707
+ lastCheck: Date | null;
46708
+ lastSuccess: Date | null;
46709
+ lastError: string | null;
46710
+ }, {
46711
+ status: string;
46712
+ peerId: string | null;
46713
+ registeredAccountUid: string | null;
46714
+ domain: string;
46715
+ lastCheck: Date | null;
46716
+ lastSuccess: Date | null;
46717
+ lastError: string | null;
46718
+ }>, "many">;
46719
+ }, "strip", z.ZodTypeAny, {
46720
+ domains: {
46721
+ status: string;
46722
+ peerId: string | null;
46723
+ registeredAccountUid: string | null;
46724
+ domain: string;
46725
+ lastCheck: Date | null;
46726
+ lastSuccess: Date | null;
46727
+ lastError: string | null;
46728
+ }[];
46729
+ }, {
46730
+ domains: {
46731
+ status: string;
46732
+ peerId: string | null;
46733
+ registeredAccountUid: string | null;
46734
+ domain: string;
46735
+ lastCheck: Date | null;
46736
+ lastSuccess: Date | null;
46737
+ lastError: string | null;
46738
+ }[];
46739
+ }>;
46740
+ }, "strip", z.ZodTypeAny, {
46741
+ key: "ListDomains";
46742
+ input: {};
46743
+ output: {
46744
+ domains: {
46745
+ status: string;
46746
+ peerId: string | null;
46747
+ registeredAccountUid: string | null;
46748
+ domain: string;
46749
+ lastCheck: Date | null;
46750
+ lastSuccess: Date | null;
46751
+ lastError: string | null;
46752
+ }[];
46753
+ };
46754
+ }, {
46755
+ key: "ListDomains";
46756
+ input: {};
46757
+ output: {
46758
+ domains: {
46759
+ status: string;
46760
+ peerId: string | null;
46761
+ registeredAccountUid: string | null;
46762
+ domain: string;
46763
+ lastCheck: Date | null;
46764
+ lastSuccess: Date | null;
46765
+ lastError: string | null;
46766
+ }[];
46767
+ };
46238
46768
  }>, z.ZodObject<{
46239
46769
  key: z.ZodLiteral<"PublishBlobs">;
46240
46770
  input: z.ZodObject<{
@@ -47033,70 +47563,4 @@ export declare function unpackHmId(hypermediaId?: string): UnpackedHypermediaId
47033
47563
  export declare function codePointLength(entry: string): number;
47034
47564
  /** Check if a UTF-16 code unit at index i is the start of a surrogate pair. */
47035
47565
  export declare function isSurrogate(s: string, i: number): boolean;
47036
- /** Resolve a web URL to its Hypermedia metadata via an OPTIONS request. */
47037
- export declare function resolveHypermediaUrl(url: string): Promise<{
47038
- id: string;
47039
- hmId: {
47040
- version: string | null;
47041
- latest: boolean;
47042
- blockRef: string | null;
47043
- blockRange: {
47044
- start: number;
47045
- end: number;
47046
- } | {
47047
- expanded: boolean;
47048
- } | null;
47049
- hostname: string | null;
47050
- path: string[] | null;
47051
- id: string;
47052
- uid: string;
47053
- scheme: string | null;
47054
- targetDocUid?: string | null | undefined;
47055
- targetDocPath?: string[] | null | undefined;
47056
- } | null;
47057
- version: string | null;
47058
- title: string | null;
47059
- target: {
47060
- path: string[] | null;
47061
- version: string | null;
47062
- id: string;
47063
- uid: string;
47064
- blockRef: string | null;
47065
- blockRange: {
47066
- start?: number | undefined;
47067
- end?: number | undefined;
47068
- expanded?: boolean | undefined;
47069
- } | null;
47070
- hostname: string | null;
47071
- scheme: string | null;
47072
- latest?: boolean | null | undefined;
47073
- targetDocUid?: string | null | undefined;
47074
- targetDocPath?: string[] | null | undefined;
47075
- } | null;
47076
- authors: ({
47077
- path: string[] | null;
47078
- version: string | null;
47079
- id: string;
47080
- uid: string;
47081
- blockRef: string | null;
47082
- blockRange: {
47083
- start?: number | undefined;
47084
- end?: number | undefined;
47085
- expanded?: boolean | undefined;
47086
- } | null;
47087
- hostname: string | null;
47088
- scheme: string | null;
47089
- latest?: boolean | null | undefined;
47090
- targetDocUid?: string | null | undefined;
47091
- targetDocPath?: string[] | null | undefined;
47092
- } | null)[] | null;
47093
- type: string | null;
47094
- panel: string | null;
47095
- } | null>;
47096
- /**
47097
- * Resolve a string that may be an hm:// ID, a gateway URL, or a site web URL
47098
- * into an UnpackedHypermediaId. Tries synchronous parsing first, then falls
47099
- * back to an OPTIONS request for web URLs.
47100
- */
47101
- export declare function resolveId(input: string): Promise<UnpackedHypermediaId>;
47102
47566
  export {};
package/dist/hm-types.mjs CHANGED
@@ -47,6 +47,7 @@ import {
47
47
  HMDocumentInfoSchema,
48
48
  HMDocumentMetadataSchema,
49
49
  HMDocumentSchema,
50
+ HMDomainInfoSchema,
50
51
  HMDraftContentSchema,
51
52
  HMDraftMetaSchema,
52
53
  HMEmbedViewSchema,
@@ -57,6 +58,8 @@ import {
57
58
  HMGetCIDRequestSchema,
58
59
  HMGetCommentReplyCountInputSchema,
59
60
  HMGetCommentReplyCountRequestSchema,
61
+ HMGetDomainInputSchema,
62
+ HMGetDomainRequestSchema,
60
63
  HMGetRequestSchema,
61
64
  HMHostConfigSchema,
62
65
  HMInteractionSummaryInputSchema,
@@ -88,6 +91,9 @@ import {
88
91
  HMListDiscussionsInputSchema,
89
92
  HMListDiscussionsOutputSchema,
90
93
  HMListDiscussionsRequestSchema,
94
+ HMListDomainsInputSchema,
95
+ HMListDomainsOutputSchema,
96
+ HMListDomainsRequestSchema,
91
97
  HMListEventsInputSchema,
92
98
  HMListEventsOutputSchema,
93
99
  HMListEventsRequestSchema,
@@ -154,14 +160,12 @@ import {
154
160
  packHmId,
155
161
  parseCustomURL,
156
162
  parseFragment,
157
- resolveHypermediaUrl,
158
- resolveId,
159
163
  serializeBlockRange,
160
164
  siteDiscoverRequestSchema,
161
165
  toNumber,
162
166
  unpackHmId,
163
167
  unpackedHmIdSchema
164
- } from "./chunk-LCXR7GLM.mjs";
168
+ } from "./chunk-B6GAAJII.mjs";
165
169
  export {
166
170
  BlockRangeSchema,
167
171
  BoldAnnotationSchema,
@@ -211,6 +215,7 @@ export {
211
215
  HMDocumentInfoSchema,
212
216
  HMDocumentMetadataSchema,
213
217
  HMDocumentSchema,
218
+ HMDomainInfoSchema,
214
219
  HMDraftContentSchema,
215
220
  HMDraftMetaSchema,
216
221
  HMEmbedViewSchema,
@@ -221,6 +226,8 @@ export {
221
226
  HMGetCIDRequestSchema,
222
227
  HMGetCommentReplyCountInputSchema,
223
228
  HMGetCommentReplyCountRequestSchema,
229
+ HMGetDomainInputSchema,
230
+ HMGetDomainRequestSchema,
224
231
  HMGetRequestSchema,
225
232
  HMHostConfigSchema,
226
233
  HMInteractionSummaryInputSchema,
@@ -252,6 +259,9 @@ export {
252
259
  HMListDiscussionsInputSchema,
253
260
  HMListDiscussionsOutputSchema,
254
261
  HMListDiscussionsRequestSchema,
262
+ HMListDomainsInputSchema,
263
+ HMListDomainsOutputSchema,
264
+ HMListDomainsRequestSchema,
255
265
  HMListEventsInputSchema,
256
266
  HMListEventsOutputSchema,
257
267
  HMListEventsRequestSchema,
@@ -318,8 +328,6 @@ export {
318
328
  packHmId,
319
329
  parseCustomURL,
320
330
  parseFragment,
321
- resolveHypermediaUrl,
322
- resolveId,
323
331
  serializeBlockRange,
324
332
  siteDiscoverRequestSchema,
325
333
  toNumber,
package/dist/index.d.ts CHANGED
@@ -20,8 +20,10 @@ export type { GrobidOptions } from './grobid';
20
20
  export { embeddedPdfToBlocks } from './pdf-to-blocks-embedded';
21
21
  export type { EmbeddedPdfResult } from './pdf-to-blocks-embedded';
22
22
  export { trimTrailingEmptyBlocks } from './comment';
23
- export { codePointLength, entityQueryPathToHmIdPath, getHMQueryString, hmIdPathToEntityQueryPath, HYPERMEDIA_SCHEME, isSurrogate, packBaseId, packHmId, parseCustomURL, parseFragment, resolveHypermediaUrl, resolveId, serializeBlockRange, unpackHmId, } from './hm-types';
23
+ export { codePointLength, entityQueryPathToHmIdPath, getHMQueryString, hmIdPathToEntityQueryPath, HYPERMEDIA_SCHEME, isSurrogate, packBaseId, packHmId, parseCustomURL, parseFragment, serializeBlockRange, unpackHmId, } from './hm-types';
24
24
  export type { HMRequest, HMSigner, UnpackedHypermediaId } from './hm-types';
25
+ export { resolveHypermediaUrl, resolveId } from './hm-resolver';
26
+ export type { DomainResolverFn, DomainIdChangedCallback, ResolveOptions, ResolvedUrl } from './hm-resolver';
25
27
  export { fileToIpfsBlobs, filesToIpfsBlobs, resolveFileLinksInBlocks, hasFileLinks } from './file-to-ipfs';
26
28
  export type { CollectedBlob } from './file-to-ipfs';
27
29
  export { parseMarkdown, flattenToOperations, parseInlineFormatting, parseFrontmatter, markdownBlockNodesToHMBlockNodes, } from './markdown-to-blocks';
package/dist/index.mjs CHANGED
@@ -13,12 +13,10 @@ import {
13
13
  packHmId,
14
14
  parseCustomURL,
15
15
  parseFragment,
16
- resolveHypermediaUrl,
17
- resolveId,
18
16
  serializeBlockRange,
19
17
  toNumber,
20
18
  unpackHmId
21
- } from "./chunk-LCXR7GLM.mjs";
19
+ } from "./chunk-B6GAAJII.mjs";
22
20
 
23
21
  // src/capability.ts
24
22
  import { encode as cborEncode2 } from "@ipld/dag-cbor";
@@ -2006,6 +2004,128 @@ async function useEmbeddedExtraction(pdfData) {
2006
2004
  };
2007
2005
  }
2008
2006
 
2007
+ // src/hm-resolver.ts
2008
+ async function resolveHypermediaUrl(url, opts) {
2009
+ let latest = false;
2010
+ let blockRef = null;
2011
+ let blockRange = null;
2012
+ let panel = null;
2013
+ let parsedHostname = null;
2014
+ try {
2015
+ const parsedUrl = new URL(url);
2016
+ parsedHostname = parsedUrl.hostname;
2017
+ const hasVersion = parsedUrl.searchParams.has("v");
2018
+ const hasLatest = parsedUrl.searchParams.has("l");
2019
+ panel = parsedUrl.searchParams.get("panel");
2020
+ if (parsedUrl.hash) {
2021
+ const fragment = parseFragment(parsedUrl.hash.slice(1));
2022
+ if (fragment) {
2023
+ blockRef = fragment.blockId;
2024
+ if ("start" in fragment && fragment.start !== void 0) {
2025
+ blockRange = { start: fragment.start, end: fragment.end };
2026
+ } else if ("expanded" in fragment && fragment.expanded) {
2027
+ blockRange = { expanded: fragment.expanded };
2028
+ }
2029
+ }
2030
+ }
2031
+ latest = blockRef ? false : hasLatest || !hasVersion;
2032
+ } catch {
2033
+ }
2034
+ if ((opts == null ? void 0 : opts.domainResolver) && parsedHostname) {
2035
+ try {
2036
+ const parsedUrl = new URL(url);
2037
+ const uid = await opts.domainResolver(parsedHostname);
2038
+ if (uid) {
2039
+ const pathSegments = parsedUrl.pathname.split("/").filter(Boolean);
2040
+ const path = pathSegments.length > 0 ? pathSegments : null;
2041
+ const version = parsedUrl.searchParams.get("v") || null;
2042
+ const pathStr = path ? "/" + path.join("/") : "";
2043
+ const siteHostname = parsedUrl.origin;
2044
+ return {
2045
+ id: `hm://${uid}${pathStr}`,
2046
+ hmId: {
2047
+ id: `hm://${uid}${pathStr}`,
2048
+ uid,
2049
+ path,
2050
+ version,
2051
+ blockRef,
2052
+ blockRange,
2053
+ hostname: siteHostname,
2054
+ scheme: "hm",
2055
+ latest
2056
+ },
2057
+ version,
2058
+ title: null,
2059
+ target: null,
2060
+ authors: null,
2061
+ type: null,
2062
+ panel
2063
+ };
2064
+ }
2065
+ } catch {
2066
+ }
2067
+ }
2068
+ const response = await fetch(url, {
2069
+ method: "OPTIONS"
2070
+ });
2071
+ if (response.status === 200) {
2072
+ const rawId = response.headers.get("x-hypermedia-id");
2073
+ const id = rawId ? decodeURIComponent(rawId) : null;
2074
+ const version = response.headers.get("x-hypermedia-version");
2075
+ const encodedTitle = response.headers.get("x-hypermedia-title");
2076
+ const title = encodedTitle ? decodeURIComponent(encodedTitle) : null;
2077
+ const rawTarget = response.headers.get("x-hypermedia-target");
2078
+ const target = rawTarget ? unpackHmId(decodeURIComponent(rawTarget)) : null;
2079
+ const rawAuthors = response.headers.get("x-hypermedia-authors");
2080
+ const authors = rawAuthors ? decodeURIComponent(rawAuthors).split(",").map((author) => unpackHmId(author)).filter((author) => author !== null) : null;
2081
+ const type = response.headers.get("x-hypermedia-type");
2082
+ if (id) {
2083
+ const hmId = unpackHmId(id);
2084
+ const resolvedVersion = version ?? (hmId == null ? void 0 : hmId.version) ?? null;
2085
+ let siteHostname = null;
2086
+ try {
2087
+ const inputUrl = new URL(url);
2088
+ if (!inputUrl.pathname.startsWith("/hm/")) {
2089
+ siteHostname = inputUrl.origin;
2090
+ }
2091
+ } catch {
2092
+ }
2093
+ if (!hmId) {
2094
+ return null;
2095
+ }
2096
+ return {
2097
+ id,
2098
+ hmId: {
2099
+ ...hmId,
2100
+ version: resolvedVersion,
2101
+ latest,
2102
+ blockRef,
2103
+ blockRange,
2104
+ hostname: siteHostname || hmId.hostname
2105
+ },
2106
+ version,
2107
+ title,
2108
+ target,
2109
+ authors,
2110
+ type,
2111
+ panel
2112
+ };
2113
+ }
2114
+ return null;
2115
+ }
2116
+ return null;
2117
+ }
2118
+ async function resolveId(input, opts) {
2119
+ const parsed = unpackHmId(input);
2120
+ if (parsed) return parsed;
2121
+ if (input.startsWith("http://") || input.startsWith("https://")) {
2122
+ const resolved = await resolveHypermediaUrl(input, opts);
2123
+ if (resolved == null ? void 0 : resolved.hmId) return resolved.hmId;
2124
+ throw new Error(`URL does not appear to be a Seed Hypermedia resource: ${input}`);
2125
+ }
2126
+ throw new Error(`Invalid Hypermedia ID: ${input}`);
2127
+ }
2128
+
2009
2129
  // src/file-to-ipfs.ts
2010
2130
  import { MemoryBlockstore } from "blockstore-core/memory";
2011
2131
  import { importer as unixFSImporter } from "ipfs-unixfs-importer";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seed-hypermedia/client",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/seed-hypermedia/seed",
package/src/index.ts CHANGED
@@ -46,13 +46,14 @@ export {
46
46
  packHmId,
47
47
  parseCustomURL,
48
48
  parseFragment,
49
- resolveHypermediaUrl,
50
- resolveId,
51
49
  serializeBlockRange,
52
50
  unpackHmId,
53
51
  } from './hm-types'
54
52
  export type {HMRequest, HMSigner, UnpackedHypermediaId} from './hm-types'
55
53
 
54
+ export {resolveHypermediaUrl, resolveId} from './hm-resolver'
55
+ export type {DomainResolverFn, DomainIdChangedCallback, ResolveOptions, ResolvedUrl} from './hm-resolver'
56
+
56
57
  export {fileToIpfsBlobs, filesToIpfsBlobs, resolveFileLinksInBlocks, hasFileLinks} from './file-to-ipfs'
57
58
  export type {CollectedBlob} from './file-to-ipfs'
58
59