@tdacorp/hyle-sdk 0.5.0 → 0.9.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.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as Resolved, M as MountsResult } from './types-CwBCPh6K.cjs';
2
- export { A as Alternate, a as ArticleContent, B as Breadcrumb, C as CacheInfo, F as Fallback, L as ListItem, b as Mount, c as Mounts, N as NavItem, d as ResolvedArticle, e as ResolvedDisabled, f as ResolvedList, g as ResolvedNotFound, h as ResolvedRedirect, T as TocEntry } from './types-CwBCPh6K.cjs';
1
+ import { R as Resolved, M as MountsResult } from './types-CHxH5E0S.cjs';
2
+ export { A as Alternate, a as ArticleContent, B as Breadcrumb, C as CacheInfo, F as Fallback, L as ListItem, b as Mount, c as Mounts, N as NavItem, d as NavNode, e as NavTree, f as ResolvedArticle, g as ResolvedDisabled, h as ResolvedList, i as ResolvedNotFound, j as ResolvedRedirect, T as TocEntry } from './types-CHxH5E0S.cjs';
3
3
  export { R as RevalidationCallbackOptions, a as RevalidationCallbackRoute, b as RevalidationPayload, c as createRevalidationCallbackRoute } from './revalidation-callback-D7Ms_Puz.cjs';
4
4
 
5
5
  /** `next` is a Next.js fetch extension with no lib.dom type; typed structurally so this module needs no Next import. */
@@ -28,6 +28,8 @@ interface ResolveOptions {
28
28
  readonly path: string;
29
29
  readonly locale?: string;
30
30
  readonly format?: "hast" | "html";
31
+ /** "tree" adds the whole section's navigation (`article.nav`); the docs layout asks for it. An older hyle ignores it. */
32
+ readonly nav?: "tree";
31
33
  readonly cursor?: string;
32
34
  readonly limit?: number;
33
35
  /** Extra fetch options (for example Next's `next: { tags, revalidate }`). Method, body and the auth header cannot be overridden. */
@@ -37,9 +39,20 @@ interface MountsOptions {
37
39
  /** Extra fetch options (for example Next's `next: { tags, revalidate }`). Method, body and the auth header cannot be overridden. */
38
40
  readonly init?: HyleRequestInit;
39
41
  }
42
+ interface AssetOptions {
43
+ /** Only these request headers are sent upstream: a browser's own cache validators and byte range. Everything else is dropped. */
44
+ readonly headers?: {
45
+ readonly range?: string | null;
46
+ readonly "if-range"?: string | null;
47
+ readonly "if-none-match"?: string | null;
48
+ };
49
+ /** Abort after this many milliseconds, body included. Default: the client's `timeoutMs`. */
50
+ readonly timeoutMs?: number;
51
+ }
40
52
  declare function createHyleClient(options: HyleClientOptions): {
41
53
  resolve: (opts: ResolveOptions) => Promise<Resolved>;
42
54
  mounts: (opts?: MountsOptions) => Promise<MountsResult>;
55
+ asset: (file: string, opts?: AssetOptions) => Promise<Response>;
43
56
  };
44
57
  type HyleClient = ReturnType<typeof createHyleClient>;
45
58
 
@@ -51,6 +64,41 @@ declare class Cp1ClientError extends Error {
51
64
  constructor(code: string, message: string, status: number, requestId: string, details?: Record<string, unknown>);
52
65
  }
53
66
 
67
+ interface HostSyncInput {
68
+ /** hyle's origin. */
69
+ readonly baseUrl: string;
70
+ /** A CONTROL credential (hyle_tc_...) holding hyle.workspace.manage on the workspace. Never a target (read) token. */
71
+ readonly token: string;
72
+ /** The workspace to write, from `client.mounts()`; the credential must be granted on it. */
73
+ readonly workspaceId: string;
74
+ /** The host's complete list of reserved paths (a replace). */
75
+ readonly paths: readonly string[];
76
+ readonly host: string;
77
+ readonly buildId: string;
78
+ readonly fetch?: typeof fetch;
79
+ readonly timeoutMs?: number;
80
+ readonly allowInsecureHttp?: boolean;
81
+ }
82
+ interface HostSyncResult {
83
+ /** What hyle stored: sorted, de-duplicated. */
84
+ readonly paths: readonly string[];
85
+ /** False when hyle already held exactly this list. */
86
+ readonly changed: boolean;
87
+ readonly syncedAt: string;
88
+ /** Published hyle URLs the list now covers. hyle unpublishes nothing; the host decides what to do. */
89
+ readonly conflicts: {
90
+ readonly total: number;
91
+ readonly offenders: readonly string[];
92
+ };
93
+ }
94
+ /**
95
+ * Reports the host's reserved paths to hyle (ADR 0016): `PUT /cp1/control/workspace/host-reserved-paths`. Idempotent (resending the
96
+ * same list changes nothing), so a retry or a repeated deploy is safe; the random Idempotency-Key only satisfies the control
97
+ * surface's mutation rule. Throws `TypeError` before any request for a wrong token kind or an insecure URL, and `Cp1ClientError`
98
+ * for anything hyle answers or the network does.
99
+ */
100
+ declare function syncHostReserved(input: HostSyncInput): Promise<HostSyncResult>;
101
+
54
102
  /**
55
103
  * docs/cp1-spec.md section 5.2: `Hyle-Signature: t=<unix seconds>,v1=<hex>,v1=<hex>`.
56
104
  * Multiple v1= values support dual-secret rotation with no receiver-side
@@ -207,17 +255,23 @@ interface RouteCheckReport {
207
255
  readonly ok: boolean;
208
256
  }
209
257
  declare function checkRoutes(input: RouteCheckInput): RouteCheckReport;
258
+ /** Paths the SDK's own components serve inside a host app, always reserved on top of the host's routes: the asset route (ADR 0015). */
259
+ declare const SDK_OWN_RESERVED: readonly string[];
210
260
  /**
211
- * The host's static routes in hyle's Reserved paths format: exact paths, and "/x/*" for a segment with two or more routes under it
212
- * (route groups such as "/api/*"). A segment is NOT collapsed when a non-root mount prefix lies on it, so "/learn/about" stays exact
213
- * while a mount serves "/learn/notes". Without `mounts` (hyle unreachable) nothing is collapsed. The leading locale segment is dropped
214
- * because hyle's paths carry no host locale prefix.
261
+ * The host's routes in hyle's Reserved paths format. Static routes are exact paths, and "/x/*" for a segment with two or more
262
+ * routes under it (route groups such as "/api/*"). A dynamic route ("/shop/[id]", "/docs/[...slug]") becomes the wildcard on its
263
+ * static prefix ("/shop/*", "/docs/*"); one with no static prefix, and hyle's own catch-all (`hyleParam`, default "hyle"), are
264
+ * skipped. A segment is NOT collapsed, and a wildcard is not made, when a non-root mount prefix lies on it, so "/learn/about" stays
265
+ * exact while a mount serves "/learn/notes". Without `mounts` (hyle unreachable) nothing is collapsed. The leading locale segment
266
+ * is dropped because hyle's paths carry no host locale prefix. Per-build hashed metadata routes are omitted, an entry another
267
+ * wildcard already covers is dropped, and the result is sorted.
215
268
  */
216
269
  declare function reservedFor(hostRoutes: readonly string[], options?: {
217
270
  readonly locale?: LocaleOptions;
218
271
  readonly mounts?: readonly string[];
272
+ readonly hyleParam?: string;
219
273
  }): string[];
220
274
  /** The human report. */
221
275
  declare function formatReport(report: RouteCheckReport): string;
222
276
 
223
- export { CACHE_TAG_PATTERN, Cp1ClientError, DeliveryDedupe, type DynamicOverlap, type HyleClient, type HyleClientOptions, type HyleRequestInit, type ListPublicationPathsOptions, type LocaleOptions, type LocalePrefix, type MountsOptions, MountsResult, type NextManifests, type ParsedSignatureHeader, type PublicationPath, type PublicationPaths, type ResolveOptions, Resolved, type RouteCheckInput, type RouteCheckReport, type VerifySignatureParams, checkRoutes, createHyleClient, formatReport, hostRoutesFromManifests, isValidCacheTag, listPublicationPaths, normalizeRoute, parseSignatureHeader, reservedFor, routeMatches, verifyHyleSignature };
277
+ export { type AssetOptions, CACHE_TAG_PATTERN, Cp1ClientError, DeliveryDedupe, type DynamicOverlap, type HostSyncInput, type HostSyncResult, type HyleClient, type HyleClientOptions, type HyleRequestInit, type ListPublicationPathsOptions, type LocaleOptions, type LocalePrefix, type MountsOptions, MountsResult, type NextManifests, type ParsedSignatureHeader, type PublicationPath, type PublicationPaths, type ResolveOptions, Resolved, type RouteCheckInput, type RouteCheckReport, SDK_OWN_RESERVED, type VerifySignatureParams, checkRoutes, createHyleClient, formatReport, hostRoutesFromManifests, isValidCacheTag, listPublicationPaths, normalizeRoute, parseSignatureHeader, reservedFor, routeMatches, syncHostReserved, verifyHyleSignature };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as Resolved, M as MountsResult } from './types-CwBCPh6K.js';
2
- export { A as Alternate, a as ArticleContent, B as Breadcrumb, C as CacheInfo, F as Fallback, L as ListItem, b as Mount, c as Mounts, N as NavItem, d as ResolvedArticle, e as ResolvedDisabled, f as ResolvedList, g as ResolvedNotFound, h as ResolvedRedirect, T as TocEntry } from './types-CwBCPh6K.js';
1
+ import { R as Resolved, M as MountsResult } from './types-CHxH5E0S.js';
2
+ export { A as Alternate, a as ArticleContent, B as Breadcrumb, C as CacheInfo, F as Fallback, L as ListItem, b as Mount, c as Mounts, N as NavItem, d as NavNode, e as NavTree, f as ResolvedArticle, g as ResolvedDisabled, h as ResolvedList, i as ResolvedNotFound, j as ResolvedRedirect, T as TocEntry } from './types-CHxH5E0S.js';
3
3
  export { R as RevalidationCallbackOptions, a as RevalidationCallbackRoute, b as RevalidationPayload, c as createRevalidationCallbackRoute } from './revalidation-callback-D7Ms_Puz.js';
4
4
 
5
5
  /** `next` is a Next.js fetch extension with no lib.dom type; typed structurally so this module needs no Next import. */
@@ -28,6 +28,8 @@ interface ResolveOptions {
28
28
  readonly path: string;
29
29
  readonly locale?: string;
30
30
  readonly format?: "hast" | "html";
31
+ /** "tree" adds the whole section's navigation (`article.nav`); the docs layout asks for it. An older hyle ignores it. */
32
+ readonly nav?: "tree";
31
33
  readonly cursor?: string;
32
34
  readonly limit?: number;
33
35
  /** Extra fetch options (for example Next's `next: { tags, revalidate }`). Method, body and the auth header cannot be overridden. */
@@ -37,9 +39,20 @@ interface MountsOptions {
37
39
  /** Extra fetch options (for example Next's `next: { tags, revalidate }`). Method, body and the auth header cannot be overridden. */
38
40
  readonly init?: HyleRequestInit;
39
41
  }
42
+ interface AssetOptions {
43
+ /** Only these request headers are sent upstream: a browser's own cache validators and byte range. Everything else is dropped. */
44
+ readonly headers?: {
45
+ readonly range?: string | null;
46
+ readonly "if-range"?: string | null;
47
+ readonly "if-none-match"?: string | null;
48
+ };
49
+ /** Abort after this many milliseconds, body included. Default: the client's `timeoutMs`. */
50
+ readonly timeoutMs?: number;
51
+ }
40
52
  declare function createHyleClient(options: HyleClientOptions): {
41
53
  resolve: (opts: ResolveOptions) => Promise<Resolved>;
42
54
  mounts: (opts?: MountsOptions) => Promise<MountsResult>;
55
+ asset: (file: string, opts?: AssetOptions) => Promise<Response>;
43
56
  };
44
57
  type HyleClient = ReturnType<typeof createHyleClient>;
45
58
 
@@ -51,6 +64,41 @@ declare class Cp1ClientError extends Error {
51
64
  constructor(code: string, message: string, status: number, requestId: string, details?: Record<string, unknown>);
52
65
  }
53
66
 
67
+ interface HostSyncInput {
68
+ /** hyle's origin. */
69
+ readonly baseUrl: string;
70
+ /** A CONTROL credential (hyle_tc_...) holding hyle.workspace.manage on the workspace. Never a target (read) token. */
71
+ readonly token: string;
72
+ /** The workspace to write, from `client.mounts()`; the credential must be granted on it. */
73
+ readonly workspaceId: string;
74
+ /** The host's complete list of reserved paths (a replace). */
75
+ readonly paths: readonly string[];
76
+ readonly host: string;
77
+ readonly buildId: string;
78
+ readonly fetch?: typeof fetch;
79
+ readonly timeoutMs?: number;
80
+ readonly allowInsecureHttp?: boolean;
81
+ }
82
+ interface HostSyncResult {
83
+ /** What hyle stored: sorted, de-duplicated. */
84
+ readonly paths: readonly string[];
85
+ /** False when hyle already held exactly this list. */
86
+ readonly changed: boolean;
87
+ readonly syncedAt: string;
88
+ /** Published hyle URLs the list now covers. hyle unpublishes nothing; the host decides what to do. */
89
+ readonly conflicts: {
90
+ readonly total: number;
91
+ readonly offenders: readonly string[];
92
+ };
93
+ }
94
+ /**
95
+ * Reports the host's reserved paths to hyle (ADR 0016): `PUT /cp1/control/workspace/host-reserved-paths`. Idempotent (resending the
96
+ * same list changes nothing), so a retry or a repeated deploy is safe; the random Idempotency-Key only satisfies the control
97
+ * surface's mutation rule. Throws `TypeError` before any request for a wrong token kind or an insecure URL, and `Cp1ClientError`
98
+ * for anything hyle answers or the network does.
99
+ */
100
+ declare function syncHostReserved(input: HostSyncInput): Promise<HostSyncResult>;
101
+
54
102
  /**
55
103
  * docs/cp1-spec.md section 5.2: `Hyle-Signature: t=<unix seconds>,v1=<hex>,v1=<hex>`.
56
104
  * Multiple v1= values support dual-secret rotation with no receiver-side
@@ -207,17 +255,23 @@ interface RouteCheckReport {
207
255
  readonly ok: boolean;
208
256
  }
209
257
  declare function checkRoutes(input: RouteCheckInput): RouteCheckReport;
258
+ /** Paths the SDK's own components serve inside a host app, always reserved on top of the host's routes: the asset route (ADR 0015). */
259
+ declare const SDK_OWN_RESERVED: readonly string[];
210
260
  /**
211
- * The host's static routes in hyle's Reserved paths format: exact paths, and "/x/*" for a segment with two or more routes under it
212
- * (route groups such as "/api/*"). A segment is NOT collapsed when a non-root mount prefix lies on it, so "/learn/about" stays exact
213
- * while a mount serves "/learn/notes". Without `mounts` (hyle unreachable) nothing is collapsed. The leading locale segment is dropped
214
- * because hyle's paths carry no host locale prefix.
261
+ * The host's routes in hyle's Reserved paths format. Static routes are exact paths, and "/x/*" for a segment with two or more
262
+ * routes under it (route groups such as "/api/*"). A dynamic route ("/shop/[id]", "/docs/[...slug]") becomes the wildcard on its
263
+ * static prefix ("/shop/*", "/docs/*"); one with no static prefix, and hyle's own catch-all (`hyleParam`, default "hyle"), are
264
+ * skipped. A segment is NOT collapsed, and a wildcard is not made, when a non-root mount prefix lies on it, so "/learn/about" stays
265
+ * exact while a mount serves "/learn/notes". Without `mounts` (hyle unreachable) nothing is collapsed. The leading locale segment
266
+ * is dropped because hyle's paths carry no host locale prefix. Per-build hashed metadata routes are omitted, an entry another
267
+ * wildcard already covers is dropped, and the result is sorted.
215
268
  */
216
269
  declare function reservedFor(hostRoutes: readonly string[], options?: {
217
270
  readonly locale?: LocaleOptions;
218
271
  readonly mounts?: readonly string[];
272
+ readonly hyleParam?: string;
219
273
  }): string[];
220
274
  /** The human report. */
221
275
  declare function formatReport(report: RouteCheckReport): string;
222
276
 
223
- export { CACHE_TAG_PATTERN, Cp1ClientError, DeliveryDedupe, type DynamicOverlap, type HyleClient, type HyleClientOptions, type HyleRequestInit, type ListPublicationPathsOptions, type LocaleOptions, type LocalePrefix, type MountsOptions, MountsResult, type NextManifests, type ParsedSignatureHeader, type PublicationPath, type PublicationPaths, type ResolveOptions, Resolved, type RouteCheckInput, type RouteCheckReport, type VerifySignatureParams, checkRoutes, createHyleClient, formatReport, hostRoutesFromManifests, isValidCacheTag, listPublicationPaths, normalizeRoute, parseSignatureHeader, reservedFor, routeMatches, verifyHyleSignature };
277
+ export { type AssetOptions, CACHE_TAG_PATTERN, Cp1ClientError, DeliveryDedupe, type DynamicOverlap, type HostSyncInput, type HostSyncResult, type HyleClient, type HyleClientOptions, type HyleRequestInit, type ListPublicationPathsOptions, type LocaleOptions, type LocalePrefix, type MountsOptions, MountsResult, type NextManifests, type ParsedSignatureHeader, type PublicationPath, type PublicationPaths, type ResolveOptions, Resolved, type RouteCheckInput, type RouteCheckReport, SDK_OWN_RESERVED, type VerifySignatureParams, checkRoutes, createHyleClient, formatReport, hostRoutesFromManifests, isValidCacheTag, listPublicationPaths, normalizeRoute, parseSignatureHeader, reservedFor, routeMatches, syncHostReserved, verifyHyleSignature };
package/dist/index.js CHANGED
@@ -2,6 +2,7 @@ import {
2
2
  CACHE_TAG_PATTERN,
3
3
  Cp1ClientError,
4
4
  DeliveryDedupe,
5
+ SDK_OWN_RESERVED,
5
6
  checkRoutes,
6
7
  createHyleClient,
7
8
  createRevalidationCallbackRoute,
@@ -13,12 +14,15 @@ import {
13
14
  parseSignatureHeader,
14
15
  reservedFor,
15
16
  routeMatches,
17
+ syncHostReserved,
16
18
  verifyHyleSignature
17
- } from "./chunk-4OB77ZOD.js";
19
+ } from "./chunk-54JF4E53.js";
20
+ import "./chunk-67IOIAVW.js";
18
21
  export {
19
22
  CACHE_TAG_PATTERN,
20
23
  Cp1ClientError,
21
24
  DeliveryDedupe,
25
+ SDK_OWN_RESERVED,
22
26
  checkRoutes,
23
27
  createHyleClient,
24
28
  createRevalidationCallbackRoute,
@@ -30,5 +34,6 @@ export {
30
34
  parseSignatureHeader,
31
35
  reservedFor,
32
36
  routeMatches,
37
+ syncHostReserved,
33
38
  verifyHyleSignature
34
39
  };