hanzio 1.2.0 → 2.1.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.
Files changed (155) hide show
  1. package/README.md +786 -239
  2. package/dist/api-wrapper/builders.d.ts +4 -3
  3. package/dist/api-wrapper/create-client.d.ts +1 -1
  4. package/dist/api-wrapper/describe.d.ts +16 -0
  5. package/dist/api-wrapper/endpoint.d.ts +18 -0
  6. package/dist/api-wrapper/errors.d.ts +39 -2
  7. package/dist/api-wrapper/index.d.ts +5 -0
  8. package/dist/api-wrapper/otel.d.ts +44 -0
  9. package/dist/api-wrapper/paginate.d.ts +12 -0
  10. package/dist/api-wrapper/redaction.d.ts +2 -0
  11. package/dist/api-wrapper/shared.d.ts +16 -2
  12. package/dist/api-wrapper/testing.d.ts +23 -0
  13. package/dist/api-wrapper/transport.d.ts +4 -5
  14. package/dist/api-wrapper/types.d.ts +103 -18
  15. package/dist/array/index.d.ts +50 -4
  16. package/dist/cache/createCache.d.ts +31 -0
  17. package/dist/cache/index.d.ts +19 -2
  18. package/dist/color/contrast.d.ts +40 -0
  19. package/dist/color/index.d.ts +2 -0
  20. package/dist/{math → color}/metricsSeriesColors.d.ts +14 -7
  21. package/dist/cool-console-log/index.d.ts +34 -5
  22. package/dist/crypto/encoding.d.ts +18 -0
  23. package/dist/crypto/hash.d.ts +33 -0
  24. package/dist/crypto/index.d.ts +4 -0
  25. package/dist/crypto/sealer.d.ts +25 -0
  26. package/dist/crypto/webhook.d.ts +20 -0
  27. package/dist/date/index.d.ts +46 -2
  28. package/dist/emitter/index.d.ts +21 -0
  29. package/dist/error/index.d.ts +12 -0
  30. package/dist/format/index.d.ts +102 -0
  31. package/dist/function/index.d.ts +60 -0
  32. package/dist/guard/index.d.ts +20 -0
  33. package/dist/i18n/index.d.ts +37 -0
  34. package/dist/index-0zvtcbzy.js +224 -0
  35. package/dist/index-8r2vdzjg.js +87 -0
  36. package/dist/index-hy7kbb99.js +157 -0
  37. package/dist/index-hyt6c56h.js +290 -0
  38. package/dist/{src/secrets/infisical.js → index-j1ybktbr.js} +500 -538
  39. package/dist/index-k9yx6bne.js +89 -0
  40. package/dist/index-kj1phgrx.js +169 -0
  41. package/dist/index-ktynw3vs.js +37 -0
  42. package/dist/index-mnkcfyx8.js +78 -0
  43. package/dist/{p-queue/index.js → index-pwt0dz63.js} +7 -11
  44. package/dist/index-rp5pqghz.js +157 -0
  45. package/dist/index-w882zry3.js +29 -0
  46. package/dist/index.d.ts +7 -7
  47. package/dist/jwt/index.d.ts +50 -2
  48. package/dist/math/index.d.ts +2 -2
  49. package/dist/math/linearRegressionTrend.d.ts +14 -1
  50. package/dist/math/scale.d.ts +8 -0
  51. package/dist/object/index.d.ts +19 -0
  52. package/dist/p-queue/index.d.ts +1 -1
  53. package/dist/promise/index.d.ts +97 -2
  54. package/dist/secrets/core.d.ts +7 -0
  55. package/dist/secrets/index.d.ts +3 -1
  56. package/dist/secrets/public-config.d.ts +7 -0
  57. package/dist/secrets/vite.d.ts +1 -0
  58. package/dist/secrets/worker.d.ts +1 -0
  59. package/dist/sitemap/index.d.ts +48 -6
  60. package/dist/src/api-wrapper/index.js +60 -1130
  61. package/dist/src/api-wrapper/testing.js +20 -0
  62. package/dist/{cool-console-log → src/cool-console-log}/index.js +80 -33
  63. package/dist/src/crypto/index.js +195 -0
  64. package/dist/src/format/index.js +211 -0
  65. package/dist/src/i18n/index.js +36 -0
  66. package/dist/src/index.js +739 -3145
  67. package/dist/src/jwt/index.js +138 -92
  68. package/dist/src/p-queue/index.js +9 -437
  69. package/dist/src/secrets/index.js +50 -1428
  70. package/dist/src/secrets/vite.js +10 -39
  71. package/dist/src/secrets/worker.js +14 -273
  72. package/dist/src/sitemap/index.js +183 -511
  73. package/dist/src/storage/index.js +119 -0
  74. package/dist/src/zod/index.js +340 -167
  75. package/dist/state/index.d.ts +21 -0
  76. package/dist/storage/index.d.ts +58 -0
  77. package/dist/string/index.d.ts +75 -2
  78. package/dist/typedswitch/index.d.ts +31 -24
  79. package/dist/types/index.d.ts +11 -0
  80. package/dist/url/index.d.ts +50 -1
  81. package/dist/zod/index.d.ts +32 -3
  82. package/dist/zod/introspect.d.ts +19 -0
  83. package/dist/zod/jsonToZodSchemaMapper.d.ts +3 -1
  84. package/dist/zod/zodMinMaxFilter.d.ts +22 -3
  85. package/dist/zod/zodToTypeString.d.ts +8 -3
  86. package/package.json +78 -7
  87. package/src/api-wrapper/actions-impl.ts +11 -72
  88. package/src/api-wrapper/builders.ts +32 -25
  89. package/src/api-wrapper/create-client.ts +171 -41
  90. package/src/api-wrapper/describe.ts +157 -0
  91. package/src/api-wrapper/endpoint.ts +26 -0
  92. package/src/api-wrapper/error-reporting.ts +7 -1
  93. package/src/api-wrapper/errors.ts +107 -2
  94. package/src/api-wrapper/headers.ts +11 -6
  95. package/src/api-wrapper/index.ts +5 -0
  96. package/src/api-wrapper/otel.ts +139 -0
  97. package/src/api-wrapper/paginate.ts +28 -0
  98. package/src/api-wrapper/redaction.ts +42 -0
  99. package/src/api-wrapper/shared.ts +21 -2
  100. package/src/api-wrapper/testing.ts +48 -0
  101. package/src/api-wrapper/transport.ts +41 -43
  102. package/src/api-wrapper/types.ts +185 -18
  103. package/src/array/index.ts +195 -42
  104. package/src/cache/createCache.ts +157 -0
  105. package/src/cache/index.ts +132 -147
  106. package/src/color/contrast.ts +163 -0
  107. package/src/color/index.ts +22 -0
  108. package/src/{math → color}/metricsSeriesColors.ts +47 -49
  109. package/src/cool-console-log/index.ts +128 -41
  110. package/src/crypto/encoding.ts +83 -0
  111. package/src/crypto/hash.ts +170 -0
  112. package/src/crypto/index.ts +26 -0
  113. package/src/crypto/sealer.ts +168 -0
  114. package/src/crypto/webhook.ts +86 -0
  115. package/src/date/index.ts +109 -34
  116. package/src/emitter/index.ts +82 -0
  117. package/src/error/index.ts +63 -0
  118. package/src/format/index.ts +389 -0
  119. package/src/function/index.ts +201 -0
  120. package/src/guard/index.ts +80 -0
  121. package/src/i18n/index.ts +125 -0
  122. package/src/index.ts +11 -7
  123. package/src/jwt/index.ts +199 -125
  124. package/src/math/index.ts +5 -10
  125. package/src/math/linearRegressionTrend.ts +33 -8
  126. package/src/math/scale.ts +17 -0
  127. package/src/object/index.ts +99 -0
  128. package/src/p-queue/index.ts +2 -0
  129. package/src/promise/index.ts +304 -9
  130. package/src/secrets/core.ts +72 -16
  131. package/src/secrets/index.ts +16 -4
  132. package/src/secrets/public-config.ts +47 -0
  133. package/src/secrets/vite.ts +2 -0
  134. package/src/secrets/worker.ts +2 -0
  135. package/src/sitemap/index.ts +293 -130
  136. package/src/state/index.ts +133 -81
  137. package/src/storage/index.ts +187 -0
  138. package/src/string/index.ts +261 -23
  139. package/src/typedswitch/index.ts +58 -38
  140. package/src/types/index.ts +14 -0
  141. package/src/url/index.ts +146 -1
  142. package/src/zod/index.ts +105 -9
  143. package/src/zod/introspect.ts +103 -0
  144. package/src/zod/jsonToZodSchemaMapper.ts +44 -21
  145. package/src/zod/zodMinMaxFilter.ts +37 -13
  146. package/src/zod/zodToTypeString.ts +184 -181
  147. package/dist/api-wrapper/index.js +0 -250
  148. package/dist/gzip/index.d.ts +0 -2
  149. package/dist/gzip/index.js +0 -16
  150. package/dist/index.js +0 -1823
  151. package/dist/jwt/index.js +0 -19
  152. package/dist/sitemap/index.js +0 -552
  153. package/dist/src/gzip/index.js +0 -16
  154. package/dist/src/secrets/loaders.js +0 -1529
  155. package/dist/zod/index.js +0 -210
@@ -1,3 +1,51 @@
1
+ import type { Result } from '../promise';
1
2
  export type JWTPayload = Record<string, unknown>;
2
- export declare function jwtSign<Payload extends JWTPayload>(payload: Payload, secret: string): Promise<string>;
3
- export declare function jwtVerify<Payload extends JWTPayload>(token: string, secret: string): Promise<Payload | null>;
3
+ export type JwtAlgorithm = 'HS256' | 'HS384' | 'HS512';
4
+ export type JwtHeader = {
5
+ alg: string;
6
+ typ?: string;
7
+ } & Record<string, unknown>;
8
+ export type JwtSignOptions = {
9
+ /** Seconds from now until `exp`. */
10
+ expiresIn?: number;
11
+ /** Seconds from now until `nbf`. */
12
+ notBefore?: number;
13
+ issuer?: string;
14
+ audience?: string | string[];
15
+ /** Default: `'HS256'` */
16
+ algorithm?: JwtAlgorithm;
17
+ };
18
+ export type JwtVerifyOptions = {
19
+ /** Clock skew tolerance for `exp`/`nbf`, in seconds. Default: 0 */
20
+ leewaySec?: number;
21
+ /** Required `iss` value. */
22
+ issuer?: string;
23
+ /** Required `aud` value (matches a string `aud` or an entry of an array `aud`). */
24
+ audience?: string;
25
+ /** Accepted header `alg` values. Default: all of HS256/HS384/HS512. */
26
+ algorithms?: JwtAlgorithm[];
27
+ };
28
+ export type JwtVerifyErrorCode = 'malformed' | 'unsupported_alg' | 'invalid_signature' | 'expired' | 'not_yet_valid' | 'invalid_issuer' | 'invalid_audience';
29
+ export declare class JwtVerifyError extends Error {
30
+ readonly code: JwtVerifyErrorCode;
31
+ constructor(code: JwtVerifyErrorCode);
32
+ }
33
+ /**
34
+ * Signs `payload` as a compact JWS. `iat` is always set to now.
35
+ * Claims derived from `options` (`exp`, `nbf`, `iss`, `aud`) override the same
36
+ * claims in `payload`; payload claims are kept when the option is not given.
37
+ */
38
+ export declare function jwtSign<Payload extends JWTPayload>(payload: Payload, secret: string, options?: JwtSignOptions): Promise<string>;
39
+ /** Verifies a token. Returns `null` for any failure; use `jwtVerifyResult` for the reason. */
40
+ export declare function jwtVerify<Payload extends JWTPayload>(token: string, secret: string, options?: JwtVerifyOptions): Promise<Payload | null>;
41
+ /**
42
+ * Verifies signature, `exp`/`nbf` and optional `iss`/`aud`.
43
+ * Token problems are returned as a failed `Result`; configuration problems
44
+ * (no Web Crypto, empty secret) throw.
45
+ */
46
+ export declare function jwtVerifyResult<Payload extends JWTPayload>(token: string, secret: string, options?: JwtVerifyOptions): Promise<Result<Payload, JwtVerifyError>>;
47
+ /** Decodes header and payload WITHOUT verifying the signature. Never trust the result for auth. */
48
+ export declare function jwtDecode<Payload extends JWTPayload = JWTPayload>(token: string): {
49
+ header: JwtHeader;
50
+ payload: Payload;
51
+ } | null;
@@ -1,2 +1,2 @@
1
- export { linearRegressionTrend } from './linearRegressionTrend';
2
- export { createResolveColorsByKeys, getHeatmapCellStyle, hashStringToColorIndex, METRICS_SERIES_PALETTE_SIZE, type ResolveColorsByKeysResult, resolveSeriesColorMap, seriesColorKey, withAlpha } from './metricsSeriesColors';
1
+ export { type LinearRegression, linearRegression, linearRegressionTrend } from './linearRegressionTrend';
2
+ export { clamp, lerp, normalize } from './scale';
@@ -1,5 +1,18 @@
1
+ export type LinearRegression = {
2
+ slope: number;
3
+ intercept: number;
4
+ /** Coefficient of determination (0..1). 1 when all values are equal (exact fit). */
5
+ r2: number;
6
+ /** Fitted y for each index. */
7
+ fitted: number[];
8
+ };
1
9
  /**
2
10
  * Least-squares linear regression for y at x = 0, 1, …, n − 1.
3
- * Returns fitted y for each index, or [] if n < 2 or any input is non-finite.
11
+ * Returns `null` if n < 2 or any input is non-finite.
12
+ */
13
+ export declare function linearRegression(values: number[]): LinearRegression | null;
14
+ /**
15
+ * Fitted y for each index of `values` (see `linearRegression`), or [] if n < 2
16
+ * or any input is non-finite.
4
17
  */
5
18
  export declare function linearRegressionTrend(values: number[]): number[];
@@ -0,0 +1,8 @@
1
+ export declare function clamp(value: number, min: number, max: number): number;
2
+ /** Linear interpolation: `t = 0` → `start`, `t = 1` → `end`. */
3
+ export declare function lerp(start: number, end: number, t: number): number;
4
+ /**
5
+ * Position of `value` within `[min, max]` as 0..1 (clamped). Returns 0 when
6
+ * the range is empty.
7
+ */
8
+ export declare function normalize(value: number, min: number, max: number): number;
@@ -0,0 +1,19 @@
1
+ /** `Object.keys` typed as the object's string keys. */
2
+ export declare function typedKeys<T extends object>(object: T): (keyof T & string)[];
3
+ /** `Object.entries` typed as `[key, value]` pairs per key. */
4
+ export declare function typedEntries<T extends object>(object: T): {
5
+ [K in keyof T & string]: [K, T[K]];
6
+ }[keyof T & string][];
7
+ /** `Object.fromEntries` typed as `Record<K, V>`. */
8
+ export declare function typedFromEntries<const K extends PropertyKey, V>(entries: Iterable<readonly [K, V]>): Record<K, V>;
9
+ /** Builds a record with one entry per key. */
10
+ export declare function recordFromKeys<const K extends PropertyKey, V>(keys: readonly K[], fn: (key: K) => V): Record<K, V>;
11
+ export declare function mapValues<T extends object, R>(object: T, fn: (value: T[keyof T & string], key: keyof T & string) => R): Record<keyof T & string, R>;
12
+ export declare function pick<T extends object, const K extends keyof T>(object: T, keys: readonly K[]): Pick<T, K>;
13
+ export declare function omit<T extends object, const K extends keyof T>(object: T, keys: readonly K[]): Omit<T, K>;
14
+ type Path = string | readonly (string | number)[];
15
+ /** Reads a nested value by dot path (`a.b.0.c`) or segment array; undefined when missing. */
16
+ export declare function getAtPath(object: unknown, path: Path): unknown;
17
+ /** Writes a nested value in place, creating arrays for numeric segments and objects otherwise. */
18
+ export declare function setAtPath(object: object, path: Path, value: unknown): void;
19
+ export {};
@@ -92,4 +92,4 @@ export default class PQueue<QueueType extends Queue<RunFunction, EnqueueOptionsT
92
92
  onError(): Promise<never>;
93
93
  onSizeLessThan(limit: number): Promise<void>;
94
94
  }
95
- export {};
95
+ export { PQueue };
@@ -4,18 +4,113 @@ export type BackgroundPromiseOptions = {
4
4
  scheduler?: (callback: () => void) => void;
5
5
  };
6
6
  export type Success<T> = {
7
+ ok: true;
7
8
  data: T;
8
9
  error: null;
9
10
  };
10
11
  export type Failure<E> = {
12
+ ok: false;
11
13
  data: null;
12
14
  error: E;
13
15
  };
14
16
  export type Result<T, E = Error> = Success<T> | Failure<E>;
17
+ export declare function ok<T>(data: T): Success<T>;
18
+ export declare function err<E>(error: E): Failure<E>;
15
19
  export declare function isSuccess<T, E>(result: Result<T, E>): result is Success<T>;
16
20
  export declare function isFailure<T, E>(result: Result<T, E>): result is Failure<E>;
17
21
  export declare function unwrapResult<T, E>(result: Result<T, E>): T;
18
22
  export declare function backgroundPromise<T>(promiseFactory: () => Promise<T>, options?: BackgroundPromiseOptions): void;
19
23
  export declare function backgroundPromiseSync<T>(promiseFactory: () => Promise<T>, options?: BackgroundPromiseOptions): void;
20
- export declare function promiseTimeout(ms: number): Promise<void>;
21
- export declare function tryCatch<T, E = Error>(promise: Promise<T>): Promise<Result<T, E>>;
24
+ /** Resolves after `ms`; rejects with `signal.reason` if the signal aborts first. */
25
+ export declare function promiseTimeout(ms: number, options?: {
26
+ signal?: AbortSignal;
27
+ }): Promise<void>;
28
+ /**
29
+ * Accepts a promise or a function; sync throws inside the function are
30
+ * captured too.
31
+ */
32
+ export declare function tryCatch<T, E = Error>(input: Promise<T> | (() => T | Promise<T>)): Promise<Result<T, E>>;
33
+ export declare class PromiseTimeoutError extends Error {
34
+ readonly timeoutMs: number;
35
+ constructor(timeoutMs: number, message?: string);
36
+ }
37
+ /**
38
+ * Rejects with `PromiseTimeoutError` after `ms`, or with `signal.reason` when
39
+ * the signal aborts. Pass a function to receive a signal that aborts on
40
+ * timeout, so the underlying work can stop too.
41
+ */
42
+ export declare function withTimeout<T>(input: Promise<T> | ((signal: AbortSignal) => Promise<T>), ms: number, options?: {
43
+ signal?: AbortSignal;
44
+ message?: string;
45
+ }): Promise<T>;
46
+ export type BackoffOptions = {
47
+ /** Delay for the first retry (default 300ms). */
48
+ baseMs?: number;
49
+ /** Upper bound for any delay (default 30s). */
50
+ maxMs?: number;
51
+ /**
52
+ * `true`/`'full'`: random delay in [0, computed] (default).
53
+ * `'partial'`: computed plus 0–`jitterRatio` extra (may exceed `maxMs`).
54
+ */
55
+ jitter?: boolean | 'full' | 'partial';
56
+ /** Max extra fraction for `'partial'` jitter (default 0.25). */
57
+ jitterRatio?: number;
58
+ /** Source of randomness in [0, 1) (default `Math.random`). */
59
+ random?: () => number;
60
+ };
61
+ /** Exponential backoff delay for a 1-based retry attempt. */
62
+ export declare function exponentialBackoff(attempt: number, options?: BackoffOptions): number;
63
+ export type RetryOptions = {
64
+ /** Retries after the first attempt (default 3). */
65
+ retries?: number;
66
+ /** Delay before retry `attempt` (1-based). Default: `exponentialBackoff`. */
67
+ delayMs?: number | ((attempt: number, error: unknown) => number);
68
+ /** Return false to stop retrying and rethrow (default: always retry). */
69
+ shouldRetry?: (error: unknown, attempt: number) => boolean;
70
+ onRetry?: (error: unknown, attempt: number, delayMs: number) => void;
71
+ signal?: AbortSignal;
72
+ };
73
+ export declare function retry<T>(fn: (context: {
74
+ attempt: number;
75
+ signal?: AbortSignal;
76
+ }) => Promise<T> | T, options?: RetryOptions): Promise<T>;
77
+ /** Maps with bounded concurrency; results keep input order. */
78
+ export declare function pMap<T, R>(items: Iterable<T>, fn: (item: T, index: number) => Promise<R> | R, options?: {
79
+ concurrency?: number;
80
+ signal?: AbortSignal;
81
+ }): Promise<R[]>;
82
+ /** Starts a clock; call the returned function to read elapsed ms. */
83
+ export declare function startTimer(): () => number;
84
+ /** Runs `fn` and reports how long it took (throws pass through). */
85
+ export declare function timed<T>(fn: () => Promise<T> | T): Promise<{
86
+ result: T;
87
+ durationMs: number;
88
+ }>;
89
+ /**
90
+ * Aborts when any input aborts, with that signal's `reason`. Undefined inputs
91
+ * are skipped; no inputs gives a signal that never aborts.
92
+ */
93
+ export declare function anySignal(...signals: (AbortSignal | undefined)[]): AbortSignal;
94
+ /** Aborts with a `TimeoutError` after `ms`, or earlier if `signal` aborts. */
95
+ export declare function timeoutSignal(ms: number, signal?: AbortSignal): AbortSignal;
96
+ /**
97
+ * Settles like `promise`, but rejects with `signal.reason` as soon as the
98
+ * signal aborts. The underlying work is not cancelled.
99
+ */
100
+ export declare function raceAbort<T>(promise: Promise<T>, signal: AbortSignal | undefined): Promise<T>;
101
+ export type LatestGuard = {
102
+ /** Starts a new generation; earlier tokens become stale. */
103
+ next(): number;
104
+ isCurrent(token: number): boolean;
105
+ /** Marks every outstanding token stale. */
106
+ invalidate(): void;
107
+ /** Runs `fn` under a new token; stale results and errors become `{ stale: true }`. */
108
+ run<T>(fn: () => Promise<T> | T): Promise<{
109
+ stale: true;
110
+ } | {
111
+ stale: false;
112
+ value: T;
113
+ }>;
114
+ };
115
+ /** Ignores results of async work superseded by a newer call. */
116
+ export declare function createLatestGuard(): LatestGuard;
@@ -44,4 +44,11 @@ export type SecretSet<K extends string, Parsed = Record<K, string>> = {
44
44
  sources: () => Record<K, string>;
45
45
  reload: (options?: SecretRequestOptions) => Promise<SecretSet<K, Parsed>>;
46
46
  };
47
+ /** A declaration that must be loaded explicitly before its values can be read. */
48
+ export type LazySecretSet<K extends string, Parsed = Record<K, string>> = SecretSet<K, Parsed> & {
49
+ /** Initialize once. Concurrent calls share a load; use reload to refresh. */
50
+ load: (options?: SecretRequestOptions) => Promise<LazySecretSet<K, Parsed>>;
51
+ };
52
+ export declare function createSecretSet<const Keys extends readonly string[], Parsed = Record<Keys[number], string>>(keys: Keys, options: CustomLoaderDefineSecretSetOptions<Keys[number], Parsed>, environmentVariables?: EnvironmentVariables): LazySecretSet<Keys[number], Parsed>;
53
+ /** Compatibility API: declares and loads a complete snapshot before returning. */
47
54
  export declare function defineSecretSet<const Keys extends readonly string[], Parsed = Record<Keys[number], string>>(keys: Keys, options: CustomLoaderDefineSecretSetOptions<Keys[number], Parsed>, environmentVariables?: EnvironmentVariables): Promise<SecretSet<Keys[number], Parsed>>;
@@ -1,4 +1,4 @@
1
- import { type CommonSecretSetOptions, type CustomLoaderDefineSecretSetOptions, type SecretSet } from './core';
1
+ import { type LazySecretSet, type CommonSecretSetOptions, type CustomLoaderDefineSecretSetOptions, type SecretSet } from './core';
2
2
  import { type SecretEnvironment } from './environment';
3
3
  import { type InfisicalAuthMode } from './infisical';
4
4
  import { type InfisicalProjectOptions } from './infisical-config';
@@ -15,4 +15,6 @@ export type InfisicalDefineSecretSetOptions<K extends string = string, Parsed =
15
15
  };
16
16
  export type DefineSecretSetOptions<K extends string, Parsed = Record<K, string>> = InfisicalDefineSecretSetOptions<K, Parsed> | CustomLoaderDefineSecretSetOptions<K, Parsed>;
17
17
  export declare function getSecretEnvironment(): SecretEnvironment;
18
+ export declare function createSecretSet<const Keys extends readonly string[], Parsed = Record<Keys[number], string>>(keys: Keys, options: DefineSecretSetOptions<Keys[number], Parsed>): LazySecretSet<Keys[number], Parsed>;
19
+ /** Compatibility API: load immediately and fail before application startup. */
18
20
  export declare function defineSecretSet<const Keys extends readonly string[], Parsed = Record<Keys[number], string>>(keys: Keys, options: DefineSecretSetOptions<Keys[number], Parsed>): Promise<SecretSet<Keys[number], Parsed>>;
@@ -0,0 +1,7 @@
1
+ import type { SecretSet } from './core';
2
+ /**
3
+ * Read only explicitly listed public values. No process globals, secret loader,
4
+ * environment writes, or async initialization; safe in frontend tooling.
5
+ * Validate application-specific formats with your schema after secrets().
6
+ */
7
+ export declare function readPublicConfig<const Keys extends readonly string[]>(keys: Keys, values: Readonly<Record<string, string | undefined>>): Pick<SecretSet<Keys[number]>, 'secret' | 'secrets'>;
@@ -11,3 +11,4 @@ export type ViteSecretSetOptions<K extends string> = {
11
11
  };
12
12
  export declare function getViteDefine<K extends string>(secretSet: Pick<SecretSet<K, unknown>, 'secrets'>, options?: ViteSecretSetOptions<K>): Record<string, string>;
13
13
  export declare function viteSecretSetPlugin<K extends string>(secretSet: Pick<SecretSet<K, unknown>, 'secrets'>, options?: ViteSecretSetOptions<K>): ViteSecretSetPlugin;
14
+ export { readPublicConfig } from './public-config';
@@ -1,3 +1,4 @@
1
1
  export * from './core';
2
2
  export { cloudflareWorkerEnvLoader } from './worker-loader';
3
3
  export type { SecretRequestOptions } from './deadline';
4
+ export { readPublicConfig } from './public-config';
@@ -1,14 +1,56 @@
1
- interface SitemapOptions {
2
- filterIndexes?: string;
1
+ /** Substring, RegExp, or predicate. */
2
+ export type SitemapUrlFilter = string | RegExp | ((url: string) => boolean);
3
+ export interface SitemapOptions {
4
+ /** Only follow nested sitemaps (from a `<sitemapindex>`) that match. */
5
+ filterIndexes?: SitemapUrlFilter;
6
+ /** Only keep page URLs (from a `<urlset>`) that match. */
7
+ filterUrls?: SitemapUrlFilter;
3
8
  concurrency?: number;
4
9
  maxDepth?: number;
10
+ /** Stop once this many URLs have been collected. */
11
+ maxUrls?: number;
12
+ /** Per-request timeout in ms. */
5
13
  timeout?: number;
14
+ userAgent?: string;
15
+ fetch?: typeof fetch;
16
+ /** Called for failed robots.txt/sitemap requests. Defaults to `console.warn`. */
17
+ onError?: (url: string, error: unknown) => void;
18
+ /** Drop page URLs that robots.txt disallows for `userAgent`. Defaults to `false`. */
19
+ respectRobots?: boolean;
6
20
  }
21
+ /** The robots.txt rules that apply to one user agent. */
22
+ export interface RobotsRules {
23
+ allow: string[];
24
+ disallow: string[];
25
+ /** Every `Sitemap:` line, whatever group it is in. */
26
+ sitemaps: string[];
27
+ crawlDelaySec?: number;
28
+ }
29
+ export interface SitemapEntry {
30
+ loc: string;
31
+ lastmod?: string;
32
+ }
33
+ /**
34
+ * Parses robots.txt for one user agent (RFC 9309): the groups naming its
35
+ * product token (case-insensitive, versions ignored), else the `*` groups.
36
+ * Several matching groups are merged. Empty `Allow`/`Disallow` values are dropped.
37
+ */
38
+ export declare function parseRobotsTxt(body: string, userAgent?: string): RobotsRules;
39
+ /**
40
+ * Whether `url` (absolute, or a path) may be crawled under `rules` (RFC 9309):
41
+ * the longest matching pattern wins and `Allow` wins a tie. Patterns support
42
+ * `*` and a trailing `$`, and match the path plus query string.
43
+ */
44
+ export declare function isAllowedByRobots(rules: Pick<RobotsRules, 'allow' | 'disallow'>, url: string): boolean;
45
+ /**
46
+ * Gets all entries (`loc` + optional `lastmod`) from a domain by discovering and crawling its sitemaps
47
+ * @param domain - The root domain (e.g., 'example.com' or 'https://example.com')
48
+ * @throws When no sitemap can be discovered
49
+ */
50
+ export declare const getDomainSitemapEntries: (domain: string, options?: SitemapOptions) => Promise<SitemapEntry[]>;
7
51
  /**
8
52
  * Gets all URLs from a domain by discovering and crawling its sitemaps
9
- * @param domain - The root domain (e.g., 'https://example.com')
10
- * @param options - Configuration options for the crawler
11
- * @returns Promise<string[]> - Array of unique URLs found in the sitemap
53
+ * @param domain - The root domain (e.g., 'example.com' or 'https://example.com')
54
+ * @returns Array of unique URLs found in the sitemap
12
55
  */
13
56
  export declare const getDomainSitemap: (domain: string, options?: SitemapOptions) => Promise<string[]>;
14
- export {};