@scolladon/tsgit 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/LICENSE +21 -0
- package/README.md +169 -0
- package/dist/cjs/adapters/browser/index.cjs +2 -0
- package/dist/cjs/adapters/browser/index.cjs.map +1 -0
- package/dist/cjs/adapters/memory/index.cjs +2 -0
- package/dist/cjs/adapters/memory/index.cjs.map +1 -0
- package/dist/cjs/adapters/node/index.cjs +2 -0
- package/dist/cjs/adapters/node/index.cjs.map +1 -0
- package/dist/cjs/chunks/browser-http-transport-BBF8uw-f.cjs +2 -0
- package/dist/cjs/chunks/browser-http-transport-BBF8uw-f.cjs.map +1 -0
- package/dist/cjs/chunks/context-BcoAzPuU.cjs +2 -0
- package/dist/cjs/chunks/context-BcoAzPuU.cjs.map +1 -0
- package/dist/cjs/chunks/error-DL4SHCBJ.cjs +2 -0
- package/dist/cjs/chunks/error-DL4SHCBJ.cjs.map +1 -0
- package/dist/cjs/chunks/error-DN8Vnwr4.cjs +2 -0
- package/dist/cjs/chunks/error-DN8Vnwr4.cjs.map +1 -0
- package/dist/cjs/chunks/index-iUd-bwwm.cjs +2 -0
- package/dist/cjs/chunks/index-iUd-bwwm.cjs.map +1 -0
- package/dist/cjs/chunks/logger-Cz9r6yt5.cjs +2 -0
- package/dist/cjs/chunks/logger-Cz9r6yt5.cjs.map +1 -0
- package/dist/cjs/chunks/lru-cache-1OU7JhD8.cjs +2 -0
- package/dist/cjs/chunks/lru-cache-1OU7JhD8.cjs.map +1 -0
- package/dist/cjs/chunks/memory-http-transport-DGll7Af4.cjs +2 -0
- package/dist/cjs/chunks/memory-http-transport-DGll7Af4.cjs.map +1 -0
- package/dist/cjs/chunks/merge-base-DlGWnkxP.cjs +2 -0
- package/dist/cjs/chunks/merge-base-DlGWnkxP.cjs.map +1 -0
- package/dist/cjs/chunks/node-http-transport-CuOgJlws.cjs +2 -0
- package/dist/cjs/chunks/node-http-transport-CuOgJlws.cjs.map +1 -0
- package/dist/cjs/chunks/progress-CK7CT9vU.cjs +2 -0
- package/dist/cjs/chunks/progress-CK7CT9vU.cjs.map +1 -0
- package/dist/cjs/chunks/repository-Cbzk-Qwz.cjs +2 -0
- package/dist/cjs/chunks/repository-Cbzk-Qwz.cjs.map +1 -0
- package/dist/cjs/commands/index.cjs +2 -0
- package/dist/cjs/commands/index.cjs.map +1 -0
- package/dist/cjs/index.browser.cjs +2 -0
- package/dist/cjs/index.browser.cjs.map +1 -0
- package/dist/cjs/index.cjs +2 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.default.cjs +2 -0
- package/dist/cjs/index.default.cjs.map +1 -0
- package/dist/cjs/index.node.cjs +2 -0
- package/dist/cjs/index.node.cjs.map +1 -0
- package/dist/cjs/operators/index.cjs +2 -0
- package/dist/cjs/operators/index.cjs.map +1 -0
- package/dist/cjs/primitives/index.cjs +2 -0
- package/dist/cjs/primitives/index.cjs.map +1 -0
- package/dist/cjs/transport/index.cjs +2 -0
- package/dist/cjs/transport/index.cjs.map +1 -0
- package/dist/esm/adapters/browser/index.js +2 -0
- package/dist/esm/adapters/browser/index.js.map +1 -0
- package/dist/esm/adapters/memory/index.js +2 -0
- package/dist/esm/adapters/memory/index.js.map +1 -0
- package/dist/esm/adapters/node/index.js +2 -0
- package/dist/esm/adapters/node/index.js.map +1 -0
- package/dist/esm/chunks/browser-http-transport-CRPPmib5.js +2 -0
- package/dist/esm/chunks/browser-http-transport-CRPPmib5.js.map +1 -0
- package/dist/esm/chunks/context-CumKOV7K.js +2 -0
- package/dist/esm/chunks/context-CumKOV7K.js.map +1 -0
- package/dist/esm/chunks/error-CAlAXhN3.js +2 -0
- package/dist/esm/chunks/error-CAlAXhN3.js.map +1 -0
- package/dist/esm/chunks/error-DVZkS_ub.js +2 -0
- package/dist/esm/chunks/error-DVZkS_ub.js.map +1 -0
- package/dist/esm/chunks/index-gUdap5AF.js +2 -0
- package/dist/esm/chunks/index-gUdap5AF.js.map +1 -0
- package/dist/esm/chunks/logger-Cg7fUh8D.js +2 -0
- package/dist/esm/chunks/logger-Cg7fUh8D.js.map +1 -0
- package/dist/esm/chunks/lru-cache-Cy7C7Lx2.js +2 -0
- package/dist/esm/chunks/lru-cache-Cy7C7Lx2.js.map +1 -0
- package/dist/esm/chunks/memory-http-transport-Cv1sbkCX.js +2 -0
- package/dist/esm/chunks/memory-http-transport-Cv1sbkCX.js.map +1 -0
- package/dist/esm/chunks/merge-base-opORz-S1.js +2 -0
- package/dist/esm/chunks/merge-base-opORz-S1.js.map +1 -0
- package/dist/esm/chunks/node-http-transport-CuXVJf0s.js +2 -0
- package/dist/esm/chunks/node-http-transport-CuXVJf0s.js.map +1 -0
- package/dist/esm/chunks/progress-OxUHmDV4.js +2 -0
- package/dist/esm/chunks/progress-OxUHmDV4.js.map +1 -0
- package/dist/esm/chunks/repository-BaEhU6zt.js +2 -0
- package/dist/esm/chunks/repository-BaEhU6zt.js.map +1 -0
- package/dist/esm/commands/index.js +2 -0
- package/dist/esm/commands/index.js.map +1 -0
- package/dist/esm/index.browser.js +2 -0
- package/dist/esm/index.browser.js.map +1 -0
- package/dist/esm/index.default.js +2 -0
- package/dist/esm/index.default.js.map +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/index.node.js +2 -0
- package/dist/esm/index.node.js.map +1 -0
- package/dist/esm/operators/index.js +2 -0
- package/dist/esm/operators/index.js.map +1 -0
- package/dist/esm/primitives/index.js +2 -0
- package/dist/esm/primitives/index.js.map +1 -0
- package/dist/esm/transport/index.js +2 -0
- package/dist/esm/transport/index.js.map +1 -0
- package/dist/types/adapters/browser/index.d.cts +67 -0
- package/dist/types/adapters/browser/index.d.ts +67 -0
- package/dist/types/adapters/memory/index.d.cts +95 -0
- package/dist/types/adapters/memory/index.d.ts +95 -0
- package/dist/types/adapters/node/index.d.cts +75 -0
- package/dist/types/adapters/node/index.d.ts +75 -0
- package/dist/types/chunks/context-C6df52Qs.d.ts +354 -0
- package/dist/types/chunks/context-Ku1aP8Ie.d.cts +354 -0
- package/dist/types/chunks/diff-change-BwO75AgS.d.cts +59 -0
- package/dist/types/chunks/diff-change-CUWN3OSK.d.ts +59 -0
- package/dist/types/chunks/http-transport--_NdQOiw.d.cts +20 -0
- package/dist/types/chunks/http-transport--_NdQOiw.d.ts +20 -0
- package/dist/types/chunks/repository-BBKJnr8a.d.ts +89 -0
- package/dist/types/chunks/repository-Cv4Y0T9t.d.cts +89 -0
- package/dist/types/commands/index.d.cts +336 -0
- package/dist/types/commands/index.d.ts +336 -0
- package/dist/types/index.browser.d.cts +26 -0
- package/dist/types/index.browser.d.ts +26 -0
- package/dist/types/index.d.cts +68 -0
- package/dist/types/index.d.ts +68 -0
- package/dist/types/index.default.d.cts +35 -0
- package/dist/types/index.default.d.ts +35 -0
- package/dist/types/index.node.d.cts +23 -0
- package/dist/types/index.node.d.ts +23 -0
- package/dist/types/operators/index.d.cts +36 -0
- package/dist/types/operators/index.d.ts +36 -0
- package/dist/types/primitives/index.d.cts +217 -0
- package/dist/types/primitives/index.d.ts +217 -0
- package/dist/types/transport/index.d.cts +62 -0
- package/dist/types/transport/index.d.ts +62 -0
- package/package.json +524 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Callback return that may be resolved synchronously or via any thenable.
|
|
3
|
+
* Uses `PromiseLike<T>` — the exact shape `await` accepts under ES2022 —
|
|
4
|
+
* so custom thenables and test doubles compose cleanly.
|
|
5
|
+
*/
|
|
6
|
+
type Awaitable<T> = T | PromiseLike<T>;
|
|
7
|
+
|
|
8
|
+
declare function filter<T>(predicate: (value: T) => Awaitable<boolean>): (source: AsyncIterable<T>) => AsyncIterable<T>;
|
|
9
|
+
|
|
10
|
+
declare function find<T>(predicate: (value: T) => Awaitable<boolean>): (source: AsyncIterable<T>) => Promise<T | undefined>;
|
|
11
|
+
|
|
12
|
+
type FlatMapReturn<U> = Iterable<U> | AsyncIterable<U> | Promise<Iterable<U> | AsyncIterable<U>>;
|
|
13
|
+
declare function flatMap<T, U>(mapper: (value: T) => FlatMapReturn<U>): (source: AsyncIterable<T>) => AsyncIterable<U>;
|
|
14
|
+
|
|
15
|
+
declare function groupBy<T, K>(keyFn: (value: T) => Awaitable<K>, limit?: number): (source: AsyncIterable<T>) => Promise<ReadonlyMap<K, ReadonlyArray<T>>>;
|
|
16
|
+
|
|
17
|
+
declare function map<T, U>(mapper: (value: T) => Awaitable<U>): (source: AsyncIterable<T>) => AsyncIterable<U>;
|
|
18
|
+
|
|
19
|
+
type UnaryFn<A, B> = (value: A) => B;
|
|
20
|
+
declare function pipe<A>(a: A): A;
|
|
21
|
+
declare function pipe<A, B>(a: A, ab: UnaryFn<A, B>): B;
|
|
22
|
+
declare function pipe<A, B, C>(a: A, ab: UnaryFn<A, B>, bc: UnaryFn<B, C>): C;
|
|
23
|
+
declare function pipe<A, B, C, D>(a: A, ab: UnaryFn<A, B>, bc: UnaryFn<B, C>, cd: UnaryFn<C, D>): D;
|
|
24
|
+
declare function pipe<A, B, C, D, E>(a: A, ab: UnaryFn<A, B>, bc: UnaryFn<B, C>, cd: UnaryFn<C, D>, de: UnaryFn<D, E>): E;
|
|
25
|
+
declare function pipe<A, B, C, D, E, F>(a: A, ab: UnaryFn<A, B>, bc: UnaryFn<B, C>, cd: UnaryFn<C, D>, de: UnaryFn<D, E>, ef: UnaryFn<E, F>): F;
|
|
26
|
+
declare function pipe<A, B, C, D, E, F, G>(a: A, ab: UnaryFn<A, B>, bc: UnaryFn<B, C>, cd: UnaryFn<C, D>, de: UnaryFn<D, E>, ef: UnaryFn<E, F>, fg: UnaryFn<F, G>): G;
|
|
27
|
+
declare function pipe<A, B, C, D, E, F, G, H>(a: A, ab: UnaryFn<A, B>, bc: UnaryFn<B, C>, cd: UnaryFn<C, D>, de: UnaryFn<D, E>, ef: UnaryFn<E, F>, fg: UnaryFn<F, G>, gh: UnaryFn<G, H>): H;
|
|
28
|
+
declare function pipe<A, B, C, D, E, F, G, H, I>(a: A, ab: UnaryFn<A, B>, bc: UnaryFn<B, C>, cd: UnaryFn<C, D>, de: UnaryFn<D, E>, ef: UnaryFn<E, F>, fg: UnaryFn<F, G>, gh: UnaryFn<G, H>, hi: UnaryFn<H, I>): I;
|
|
29
|
+
declare function pipe<A, B, C, D, E, F, G, H, I, J>(a: A, ab: UnaryFn<A, B>, bc: UnaryFn<B, C>, cd: UnaryFn<C, D>, de: UnaryFn<D, E>, ef: UnaryFn<E, F>, fg: UnaryFn<F, G>, gh: UnaryFn<G, H>, hi: UnaryFn<H, I>, ij: UnaryFn<I, J>): J;
|
|
30
|
+
|
|
31
|
+
declare function take<T>(count: number): (source: AsyncIterable<T>) => AsyncIterable<T>;
|
|
32
|
+
|
|
33
|
+
declare function toArray<T>(source: AsyncIterable<T>, limit?: number): Promise<T[]>;
|
|
34
|
+
|
|
35
|
+
export { filter, find, flatMap, groupBy, map, pipe, take, toArray };
|
|
36
|
+
export type { Awaitable };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Callback return that may be resolved synchronously or via any thenable.
|
|
3
|
+
* Uses `PromiseLike<T>` — the exact shape `await` accepts under ES2022 —
|
|
4
|
+
* so custom thenables and test doubles compose cleanly.
|
|
5
|
+
*/
|
|
6
|
+
type Awaitable<T> = T | PromiseLike<T>;
|
|
7
|
+
|
|
8
|
+
declare function filter<T>(predicate: (value: T) => Awaitable<boolean>): (source: AsyncIterable<T>) => AsyncIterable<T>;
|
|
9
|
+
|
|
10
|
+
declare function find<T>(predicate: (value: T) => Awaitable<boolean>): (source: AsyncIterable<T>) => Promise<T | undefined>;
|
|
11
|
+
|
|
12
|
+
type FlatMapReturn<U> = Iterable<U> | AsyncIterable<U> | Promise<Iterable<U> | AsyncIterable<U>>;
|
|
13
|
+
declare function flatMap<T, U>(mapper: (value: T) => FlatMapReturn<U>): (source: AsyncIterable<T>) => AsyncIterable<U>;
|
|
14
|
+
|
|
15
|
+
declare function groupBy<T, K>(keyFn: (value: T) => Awaitable<K>, limit?: number): (source: AsyncIterable<T>) => Promise<ReadonlyMap<K, ReadonlyArray<T>>>;
|
|
16
|
+
|
|
17
|
+
declare function map<T, U>(mapper: (value: T) => Awaitable<U>): (source: AsyncIterable<T>) => AsyncIterable<U>;
|
|
18
|
+
|
|
19
|
+
type UnaryFn<A, B> = (value: A) => B;
|
|
20
|
+
declare function pipe<A>(a: A): A;
|
|
21
|
+
declare function pipe<A, B>(a: A, ab: UnaryFn<A, B>): B;
|
|
22
|
+
declare function pipe<A, B, C>(a: A, ab: UnaryFn<A, B>, bc: UnaryFn<B, C>): C;
|
|
23
|
+
declare function pipe<A, B, C, D>(a: A, ab: UnaryFn<A, B>, bc: UnaryFn<B, C>, cd: UnaryFn<C, D>): D;
|
|
24
|
+
declare function pipe<A, B, C, D, E>(a: A, ab: UnaryFn<A, B>, bc: UnaryFn<B, C>, cd: UnaryFn<C, D>, de: UnaryFn<D, E>): E;
|
|
25
|
+
declare function pipe<A, B, C, D, E, F>(a: A, ab: UnaryFn<A, B>, bc: UnaryFn<B, C>, cd: UnaryFn<C, D>, de: UnaryFn<D, E>, ef: UnaryFn<E, F>): F;
|
|
26
|
+
declare function pipe<A, B, C, D, E, F, G>(a: A, ab: UnaryFn<A, B>, bc: UnaryFn<B, C>, cd: UnaryFn<C, D>, de: UnaryFn<D, E>, ef: UnaryFn<E, F>, fg: UnaryFn<F, G>): G;
|
|
27
|
+
declare function pipe<A, B, C, D, E, F, G, H>(a: A, ab: UnaryFn<A, B>, bc: UnaryFn<B, C>, cd: UnaryFn<C, D>, de: UnaryFn<D, E>, ef: UnaryFn<E, F>, fg: UnaryFn<F, G>, gh: UnaryFn<G, H>): H;
|
|
28
|
+
declare function pipe<A, B, C, D, E, F, G, H, I>(a: A, ab: UnaryFn<A, B>, bc: UnaryFn<B, C>, cd: UnaryFn<C, D>, de: UnaryFn<D, E>, ef: UnaryFn<E, F>, fg: UnaryFn<F, G>, gh: UnaryFn<G, H>, hi: UnaryFn<H, I>): I;
|
|
29
|
+
declare function pipe<A, B, C, D, E, F, G, H, I, J>(a: A, ab: UnaryFn<A, B>, bc: UnaryFn<B, C>, cd: UnaryFn<C, D>, de: UnaryFn<D, E>, ef: UnaryFn<E, F>, fg: UnaryFn<F, G>, gh: UnaryFn<G, H>, hi: UnaryFn<H, I>, ij: UnaryFn<I, J>): J;
|
|
30
|
+
|
|
31
|
+
declare function take<T>(count: number): (source: AsyncIterable<T>) => AsyncIterable<T>;
|
|
32
|
+
|
|
33
|
+
declare function toArray<T>(source: AsyncIterable<T>, limit?: number): Promise<T[]>;
|
|
34
|
+
|
|
35
|
+
export { filter, find, flatMap, groupBy, map, pipe, take, toArray };
|
|
36
|
+
export type { Awaitable };
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { O as ObjectId, b as FilePath, a as Context, j as RefName } from '../chunks/context-Ku1aP8Ie.cjs';
|
|
2
|
+
import { A as AuthorIdentity, F as FileMode, T as TreeDiff } from '../chunks/diff-change-BwO75AgS.cjs';
|
|
3
|
+
import '../chunks/http-transport--_NdQOiw.cjs';
|
|
4
|
+
|
|
5
|
+
interface Blob {
|
|
6
|
+
readonly type: 'blob';
|
|
7
|
+
readonly id: ObjectId;
|
|
8
|
+
readonly content: Uint8Array;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface ExtraHeader {
|
|
12
|
+
readonly key: string;
|
|
13
|
+
readonly value: string;
|
|
14
|
+
}
|
|
15
|
+
interface CommitData {
|
|
16
|
+
readonly tree: ObjectId;
|
|
17
|
+
readonly parents: ReadonlyArray<ObjectId>;
|
|
18
|
+
readonly author: AuthorIdentity;
|
|
19
|
+
readonly committer: AuthorIdentity;
|
|
20
|
+
readonly message: string;
|
|
21
|
+
readonly gpgSignature?: string;
|
|
22
|
+
readonly extraHeaders: ReadonlyArray<ExtraHeader>;
|
|
23
|
+
}
|
|
24
|
+
interface Commit {
|
|
25
|
+
readonly type: 'commit';
|
|
26
|
+
readonly id: ObjectId;
|
|
27
|
+
readonly data: CommitData;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
type ObjectType = 'blob' | 'tree' | 'commit' | 'tag';
|
|
31
|
+
|
|
32
|
+
interface TagData {
|
|
33
|
+
readonly object: ObjectId;
|
|
34
|
+
readonly objectType: ObjectType;
|
|
35
|
+
readonly tagName: string;
|
|
36
|
+
readonly tagger?: AuthorIdentity;
|
|
37
|
+
readonly message: string;
|
|
38
|
+
readonly gpgSignature?: string;
|
|
39
|
+
readonly extraHeaders: ReadonlyArray<ExtraHeader>;
|
|
40
|
+
}
|
|
41
|
+
interface Tag {
|
|
42
|
+
readonly type: 'tag';
|
|
43
|
+
readonly id: ObjectId;
|
|
44
|
+
readonly data: TagData;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface TreeEntry {
|
|
48
|
+
readonly mode: FileMode;
|
|
49
|
+
readonly name: string;
|
|
50
|
+
readonly id: ObjectId;
|
|
51
|
+
}
|
|
52
|
+
interface Tree {
|
|
53
|
+
readonly type: 'tree';
|
|
54
|
+
readonly id: ObjectId;
|
|
55
|
+
readonly entries: ReadonlyArray<TreeEntry>;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
type GitObject = Blob | Tree | Commit | Tag;
|
|
59
|
+
|
|
60
|
+
interface IndexEntryFlags {
|
|
61
|
+
readonly assumeValid: boolean;
|
|
62
|
+
readonly extended: boolean;
|
|
63
|
+
readonly stage: 0 | 1 | 2 | 3;
|
|
64
|
+
}
|
|
65
|
+
interface IndexEntry {
|
|
66
|
+
readonly ctimeSeconds: number;
|
|
67
|
+
readonly ctimeNanoseconds: number;
|
|
68
|
+
readonly mtimeSeconds: number;
|
|
69
|
+
readonly mtimeNanoseconds: number;
|
|
70
|
+
readonly dev: number;
|
|
71
|
+
readonly ino: number;
|
|
72
|
+
readonly mode: FileMode;
|
|
73
|
+
readonly uid: number;
|
|
74
|
+
readonly gid: number;
|
|
75
|
+
readonly fileSize: number;
|
|
76
|
+
readonly id: ObjectId;
|
|
77
|
+
readonly flags: IndexEntryFlags;
|
|
78
|
+
readonly path: FilePath;
|
|
79
|
+
}
|
|
80
|
+
interface IndexExtension {
|
|
81
|
+
readonly signature: string;
|
|
82
|
+
readonly data: Uint8Array;
|
|
83
|
+
}
|
|
84
|
+
interface GitIndex {
|
|
85
|
+
readonly version: 2;
|
|
86
|
+
readonly entries: ReadonlyArray<IndexEntry>;
|
|
87
|
+
readonly extensions: ReadonlyArray<IndexExtension>;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
interface RenameDetectOptions {
|
|
91
|
+
readonly limit?: number;
|
|
92
|
+
readonly maxSameIdDeletes?: number;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Phase 7 primitive option shapes, walker value types, and shared constants.
|
|
97
|
+
* Defined in one location to avoid circular imports between primitive modules.
|
|
98
|
+
*/
|
|
99
|
+
|
|
100
|
+
/** Max symbolic-ref dereferences resolveRef will follow. */
|
|
101
|
+
declare const MAX_SYMBOLIC_REF_DEPTH = 5;
|
|
102
|
+
/** Max tag-peel hops resolveRef / readTree will follow when peeling. */
|
|
103
|
+
declare const MAX_PEEL_DEPTH = 5;
|
|
104
|
+
/** Max seeds walkCommits.from can contain. */
|
|
105
|
+
declare const MAX_WALK_SEEDS = 1024;
|
|
106
|
+
/** Hard cap on walkCommits' pending queue size to prevent unbounded heap growth. */
|
|
107
|
+
declare const MAX_WALK_QUEUE_SIZE: number;
|
|
108
|
+
/** Max .git/index file size readIndex will accept. */
|
|
109
|
+
declare const MAX_INDEX_BYTES: number;
|
|
110
|
+
/** Max commit message byte length createCommit will accept. */
|
|
111
|
+
declare const MAX_COMMIT_MESSAGE_BYTES: number;
|
|
112
|
+
interface ReadObjectOptions {
|
|
113
|
+
readonly verifyHash?: boolean;
|
|
114
|
+
}
|
|
115
|
+
interface ResolveRefOptions {
|
|
116
|
+
readonly peel?: boolean;
|
|
117
|
+
readonly maxSymbolicDepth?: number;
|
|
118
|
+
readonly maxPeelDepth?: number;
|
|
119
|
+
}
|
|
120
|
+
interface UpdateRefOptions {
|
|
121
|
+
readonly expected?: ObjectId | 'absent';
|
|
122
|
+
readonly delete?: boolean;
|
|
123
|
+
}
|
|
124
|
+
interface WalkCommitsOptions {
|
|
125
|
+
readonly from: ReadonlyArray<ObjectId>;
|
|
126
|
+
readonly until?: ReadonlyArray<ObjectId>;
|
|
127
|
+
readonly order?: 'topo' | 'first-parent';
|
|
128
|
+
readonly ignoreMissing?: boolean;
|
|
129
|
+
readonly verifyHash?: boolean;
|
|
130
|
+
}
|
|
131
|
+
interface WalkTreeEntry {
|
|
132
|
+
readonly path: FilePath;
|
|
133
|
+
readonly id: ObjectId;
|
|
134
|
+
readonly mode: FileMode;
|
|
135
|
+
}
|
|
136
|
+
interface WalkTreeOptions {
|
|
137
|
+
readonly recursive?: boolean;
|
|
138
|
+
readonly maxDepth?: number;
|
|
139
|
+
readonly maxEntries?: number;
|
|
140
|
+
}
|
|
141
|
+
interface CreateCommitInput {
|
|
142
|
+
readonly tree: ObjectId;
|
|
143
|
+
readonly parents: ReadonlyArray<ObjectId>;
|
|
144
|
+
readonly author: AuthorIdentity;
|
|
145
|
+
readonly committer: AuthorIdentity;
|
|
146
|
+
readonly message: string;
|
|
147
|
+
readonly gpgSignature?: string;
|
|
148
|
+
readonly extraHeaders?: ReadonlyArray<ExtraHeader>;
|
|
149
|
+
}
|
|
150
|
+
type DiffTreesInput = Tree | ObjectId | undefined;
|
|
151
|
+
interface DiffTreesOptions {
|
|
152
|
+
readonly detectRenames?: boolean;
|
|
153
|
+
readonly renameOptions?: RenameDetectOptions;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
declare function createCommit(ctx: Context, input: CreateCommitInput): Promise<ObjectId>;
|
|
157
|
+
|
|
158
|
+
declare function diffTrees(ctx: Context, a: DiffTreesInput, b: DiffTreesInput, options?: DiffTreesOptions): Promise<TreeDiff>;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Compute a merge base — the first commit reachable from BOTH `a` and `b`.
|
|
162
|
+
*
|
|
163
|
+
* Algorithm: bidirectional BFS with two visited sets. After each layer
|
|
164
|
+
* advance, check the intersection. When non-empty, return the
|
|
165
|
+
* lexicographically smallest oid (deterministic tie-breaker).
|
|
166
|
+
*
|
|
167
|
+
* Returns `undefined` for unrelated histories. Documented limitation: cherry-picks
|
|
168
|
+
* and criss-cross merges may yield non-optimal bases — `recursive`-strategy
|
|
169
|
+
* multi-base resolution is v2.
|
|
170
|
+
*/
|
|
171
|
+
declare const mergeBase: (ctx: Context, a: ObjectId, b: ObjectId) => Promise<ObjectId | undefined>;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Pure path helpers composing `ctx.layout.gitDir` with known sub-paths.
|
|
175
|
+
* No I/O. No port access. Primitive step 3.
|
|
176
|
+
*/
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Repository working-tree root. Returns the workDir from the current context;
|
|
180
|
+
* facade-tier code (Phase 10) is responsible for discovery / realpath pinning
|
|
181
|
+
* at construction time. Primitives consume the already-resolved path.
|
|
182
|
+
*/
|
|
183
|
+
declare const getRepoRoot: (ctx: Context) => FilePath;
|
|
184
|
+
|
|
185
|
+
declare function readBlob(ctx: Context, id: ObjectId, options?: ReadObjectOptions): Promise<Blob>;
|
|
186
|
+
|
|
187
|
+
declare function readIndex(ctx: Context): Promise<GitIndex>;
|
|
188
|
+
|
|
189
|
+
declare function readObject(ctx: Context, id: ObjectId, options?: ReadObjectOptions): Promise<GitObject>;
|
|
190
|
+
|
|
191
|
+
declare function readTree(ctx: Context, ref: RefName | ObjectId): Promise<Tree>;
|
|
192
|
+
|
|
193
|
+
declare function resolveRef(ctx: Context, name: RefName | 'HEAD', options?: ResolveRefOptions): Promise<ObjectId>;
|
|
194
|
+
|
|
195
|
+
declare function updateRef(ctx: Context, name: RefName, newId: ObjectId, options?: UpdateRefOptions): Promise<void>;
|
|
196
|
+
|
|
197
|
+
declare function walkCommits(ctx: Context, options: WalkCommitsOptions): AsyncIterable<Commit>;
|
|
198
|
+
|
|
199
|
+
declare function walkTree(ctx: Context, treeIdOrObject: ObjectId | Tree, options?: WalkTreeOptions): AsyncIterable<WalkTreeEntry>;
|
|
200
|
+
|
|
201
|
+
declare function writeObject(ctx: Context, object: GitObject): Promise<ObjectId>;
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Write a symbolic ref atomically. Used for HEAD updates that point at a
|
|
205
|
+
* branch, branch renames affecting the current HEAD, and `clone`/`init`
|
|
206
|
+
* to set the initial HEAD.
|
|
207
|
+
*
|
|
208
|
+
* Single-level only in v1: target MUST be a direct ref name (no chained
|
|
209
|
+
* symrefs). Validation runs through `validateRefName` for both `name` and
|
|
210
|
+
* `target` — invalid inputs throw INVALID_REF before any I/O.
|
|
211
|
+
*/
|
|
212
|
+
declare const writeSymbolicRef: (ctx: Context, name: RefName, target: RefName) => Promise<void>;
|
|
213
|
+
|
|
214
|
+
declare function writeTree(ctx: Context, entries: ReadonlyArray<TreeEntry>): Promise<ObjectId>;
|
|
215
|
+
|
|
216
|
+
export { MAX_COMMIT_MESSAGE_BYTES, MAX_INDEX_BYTES, MAX_PEEL_DEPTH, MAX_SYMBOLIC_REF_DEPTH, MAX_WALK_QUEUE_SIZE, MAX_WALK_SEEDS, TreeDiff, createCommit, diffTrees, getRepoRoot, mergeBase, readBlob, readIndex, readObject, readTree, resolveRef, updateRef, walkCommits, walkTree, writeObject, writeSymbolicRef, writeTree };
|
|
217
|
+
export type { CreateCommitInput, DiffTreesInput, DiffTreesOptions, ReadObjectOptions, ResolveRefOptions, UpdateRefOptions, WalkCommitsOptions, WalkTreeEntry, WalkTreeOptions };
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { O as ObjectId, b as FilePath, a as Context, j as RefName } from '../chunks/context-C6df52Qs.js';
|
|
2
|
+
import { A as AuthorIdentity, F as FileMode, T as TreeDiff } from '../chunks/diff-change-CUWN3OSK.js';
|
|
3
|
+
import '../chunks/http-transport--_NdQOiw.js';
|
|
4
|
+
|
|
5
|
+
interface Blob {
|
|
6
|
+
readonly type: 'blob';
|
|
7
|
+
readonly id: ObjectId;
|
|
8
|
+
readonly content: Uint8Array;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface ExtraHeader {
|
|
12
|
+
readonly key: string;
|
|
13
|
+
readonly value: string;
|
|
14
|
+
}
|
|
15
|
+
interface CommitData {
|
|
16
|
+
readonly tree: ObjectId;
|
|
17
|
+
readonly parents: ReadonlyArray<ObjectId>;
|
|
18
|
+
readonly author: AuthorIdentity;
|
|
19
|
+
readonly committer: AuthorIdentity;
|
|
20
|
+
readonly message: string;
|
|
21
|
+
readonly gpgSignature?: string;
|
|
22
|
+
readonly extraHeaders: ReadonlyArray<ExtraHeader>;
|
|
23
|
+
}
|
|
24
|
+
interface Commit {
|
|
25
|
+
readonly type: 'commit';
|
|
26
|
+
readonly id: ObjectId;
|
|
27
|
+
readonly data: CommitData;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
type ObjectType = 'blob' | 'tree' | 'commit' | 'tag';
|
|
31
|
+
|
|
32
|
+
interface TagData {
|
|
33
|
+
readonly object: ObjectId;
|
|
34
|
+
readonly objectType: ObjectType;
|
|
35
|
+
readonly tagName: string;
|
|
36
|
+
readonly tagger?: AuthorIdentity;
|
|
37
|
+
readonly message: string;
|
|
38
|
+
readonly gpgSignature?: string;
|
|
39
|
+
readonly extraHeaders: ReadonlyArray<ExtraHeader>;
|
|
40
|
+
}
|
|
41
|
+
interface Tag {
|
|
42
|
+
readonly type: 'tag';
|
|
43
|
+
readonly id: ObjectId;
|
|
44
|
+
readonly data: TagData;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface TreeEntry {
|
|
48
|
+
readonly mode: FileMode;
|
|
49
|
+
readonly name: string;
|
|
50
|
+
readonly id: ObjectId;
|
|
51
|
+
}
|
|
52
|
+
interface Tree {
|
|
53
|
+
readonly type: 'tree';
|
|
54
|
+
readonly id: ObjectId;
|
|
55
|
+
readonly entries: ReadonlyArray<TreeEntry>;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
type GitObject = Blob | Tree | Commit | Tag;
|
|
59
|
+
|
|
60
|
+
interface IndexEntryFlags {
|
|
61
|
+
readonly assumeValid: boolean;
|
|
62
|
+
readonly extended: boolean;
|
|
63
|
+
readonly stage: 0 | 1 | 2 | 3;
|
|
64
|
+
}
|
|
65
|
+
interface IndexEntry {
|
|
66
|
+
readonly ctimeSeconds: number;
|
|
67
|
+
readonly ctimeNanoseconds: number;
|
|
68
|
+
readonly mtimeSeconds: number;
|
|
69
|
+
readonly mtimeNanoseconds: number;
|
|
70
|
+
readonly dev: number;
|
|
71
|
+
readonly ino: number;
|
|
72
|
+
readonly mode: FileMode;
|
|
73
|
+
readonly uid: number;
|
|
74
|
+
readonly gid: number;
|
|
75
|
+
readonly fileSize: number;
|
|
76
|
+
readonly id: ObjectId;
|
|
77
|
+
readonly flags: IndexEntryFlags;
|
|
78
|
+
readonly path: FilePath;
|
|
79
|
+
}
|
|
80
|
+
interface IndexExtension {
|
|
81
|
+
readonly signature: string;
|
|
82
|
+
readonly data: Uint8Array;
|
|
83
|
+
}
|
|
84
|
+
interface GitIndex {
|
|
85
|
+
readonly version: 2;
|
|
86
|
+
readonly entries: ReadonlyArray<IndexEntry>;
|
|
87
|
+
readonly extensions: ReadonlyArray<IndexExtension>;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
interface RenameDetectOptions {
|
|
91
|
+
readonly limit?: number;
|
|
92
|
+
readonly maxSameIdDeletes?: number;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Phase 7 primitive option shapes, walker value types, and shared constants.
|
|
97
|
+
* Defined in one location to avoid circular imports between primitive modules.
|
|
98
|
+
*/
|
|
99
|
+
|
|
100
|
+
/** Max symbolic-ref dereferences resolveRef will follow. */
|
|
101
|
+
declare const MAX_SYMBOLIC_REF_DEPTH = 5;
|
|
102
|
+
/** Max tag-peel hops resolveRef / readTree will follow when peeling. */
|
|
103
|
+
declare const MAX_PEEL_DEPTH = 5;
|
|
104
|
+
/** Max seeds walkCommits.from can contain. */
|
|
105
|
+
declare const MAX_WALK_SEEDS = 1024;
|
|
106
|
+
/** Hard cap on walkCommits' pending queue size to prevent unbounded heap growth. */
|
|
107
|
+
declare const MAX_WALK_QUEUE_SIZE: number;
|
|
108
|
+
/** Max .git/index file size readIndex will accept. */
|
|
109
|
+
declare const MAX_INDEX_BYTES: number;
|
|
110
|
+
/** Max commit message byte length createCommit will accept. */
|
|
111
|
+
declare const MAX_COMMIT_MESSAGE_BYTES: number;
|
|
112
|
+
interface ReadObjectOptions {
|
|
113
|
+
readonly verifyHash?: boolean;
|
|
114
|
+
}
|
|
115
|
+
interface ResolveRefOptions {
|
|
116
|
+
readonly peel?: boolean;
|
|
117
|
+
readonly maxSymbolicDepth?: number;
|
|
118
|
+
readonly maxPeelDepth?: number;
|
|
119
|
+
}
|
|
120
|
+
interface UpdateRefOptions {
|
|
121
|
+
readonly expected?: ObjectId | 'absent';
|
|
122
|
+
readonly delete?: boolean;
|
|
123
|
+
}
|
|
124
|
+
interface WalkCommitsOptions {
|
|
125
|
+
readonly from: ReadonlyArray<ObjectId>;
|
|
126
|
+
readonly until?: ReadonlyArray<ObjectId>;
|
|
127
|
+
readonly order?: 'topo' | 'first-parent';
|
|
128
|
+
readonly ignoreMissing?: boolean;
|
|
129
|
+
readonly verifyHash?: boolean;
|
|
130
|
+
}
|
|
131
|
+
interface WalkTreeEntry {
|
|
132
|
+
readonly path: FilePath;
|
|
133
|
+
readonly id: ObjectId;
|
|
134
|
+
readonly mode: FileMode;
|
|
135
|
+
}
|
|
136
|
+
interface WalkTreeOptions {
|
|
137
|
+
readonly recursive?: boolean;
|
|
138
|
+
readonly maxDepth?: number;
|
|
139
|
+
readonly maxEntries?: number;
|
|
140
|
+
}
|
|
141
|
+
interface CreateCommitInput {
|
|
142
|
+
readonly tree: ObjectId;
|
|
143
|
+
readonly parents: ReadonlyArray<ObjectId>;
|
|
144
|
+
readonly author: AuthorIdentity;
|
|
145
|
+
readonly committer: AuthorIdentity;
|
|
146
|
+
readonly message: string;
|
|
147
|
+
readonly gpgSignature?: string;
|
|
148
|
+
readonly extraHeaders?: ReadonlyArray<ExtraHeader>;
|
|
149
|
+
}
|
|
150
|
+
type DiffTreesInput = Tree | ObjectId | undefined;
|
|
151
|
+
interface DiffTreesOptions {
|
|
152
|
+
readonly detectRenames?: boolean;
|
|
153
|
+
readonly renameOptions?: RenameDetectOptions;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
declare function createCommit(ctx: Context, input: CreateCommitInput): Promise<ObjectId>;
|
|
157
|
+
|
|
158
|
+
declare function diffTrees(ctx: Context, a: DiffTreesInput, b: DiffTreesInput, options?: DiffTreesOptions): Promise<TreeDiff>;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Compute a merge base — the first commit reachable from BOTH `a` and `b`.
|
|
162
|
+
*
|
|
163
|
+
* Algorithm: bidirectional BFS with two visited sets. After each layer
|
|
164
|
+
* advance, check the intersection. When non-empty, return the
|
|
165
|
+
* lexicographically smallest oid (deterministic tie-breaker).
|
|
166
|
+
*
|
|
167
|
+
* Returns `undefined` for unrelated histories. Documented limitation: cherry-picks
|
|
168
|
+
* and criss-cross merges may yield non-optimal bases — `recursive`-strategy
|
|
169
|
+
* multi-base resolution is v2.
|
|
170
|
+
*/
|
|
171
|
+
declare const mergeBase: (ctx: Context, a: ObjectId, b: ObjectId) => Promise<ObjectId | undefined>;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Pure path helpers composing `ctx.layout.gitDir` with known sub-paths.
|
|
175
|
+
* No I/O. No port access. Primitive step 3.
|
|
176
|
+
*/
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Repository working-tree root. Returns the workDir from the current context;
|
|
180
|
+
* facade-tier code (Phase 10) is responsible for discovery / realpath pinning
|
|
181
|
+
* at construction time. Primitives consume the already-resolved path.
|
|
182
|
+
*/
|
|
183
|
+
declare const getRepoRoot: (ctx: Context) => FilePath;
|
|
184
|
+
|
|
185
|
+
declare function readBlob(ctx: Context, id: ObjectId, options?: ReadObjectOptions): Promise<Blob>;
|
|
186
|
+
|
|
187
|
+
declare function readIndex(ctx: Context): Promise<GitIndex>;
|
|
188
|
+
|
|
189
|
+
declare function readObject(ctx: Context, id: ObjectId, options?: ReadObjectOptions): Promise<GitObject>;
|
|
190
|
+
|
|
191
|
+
declare function readTree(ctx: Context, ref: RefName | ObjectId): Promise<Tree>;
|
|
192
|
+
|
|
193
|
+
declare function resolveRef(ctx: Context, name: RefName | 'HEAD', options?: ResolveRefOptions): Promise<ObjectId>;
|
|
194
|
+
|
|
195
|
+
declare function updateRef(ctx: Context, name: RefName, newId: ObjectId, options?: UpdateRefOptions): Promise<void>;
|
|
196
|
+
|
|
197
|
+
declare function walkCommits(ctx: Context, options: WalkCommitsOptions): AsyncIterable<Commit>;
|
|
198
|
+
|
|
199
|
+
declare function walkTree(ctx: Context, treeIdOrObject: ObjectId | Tree, options?: WalkTreeOptions): AsyncIterable<WalkTreeEntry>;
|
|
200
|
+
|
|
201
|
+
declare function writeObject(ctx: Context, object: GitObject): Promise<ObjectId>;
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Write a symbolic ref atomically. Used for HEAD updates that point at a
|
|
205
|
+
* branch, branch renames affecting the current HEAD, and `clone`/`init`
|
|
206
|
+
* to set the initial HEAD.
|
|
207
|
+
*
|
|
208
|
+
* Single-level only in v1: target MUST be a direct ref name (no chained
|
|
209
|
+
* symrefs). Validation runs through `validateRefName` for both `name` and
|
|
210
|
+
* `target` — invalid inputs throw INVALID_REF before any I/O.
|
|
211
|
+
*/
|
|
212
|
+
declare const writeSymbolicRef: (ctx: Context, name: RefName, target: RefName) => Promise<void>;
|
|
213
|
+
|
|
214
|
+
declare function writeTree(ctx: Context, entries: ReadonlyArray<TreeEntry>): Promise<ObjectId>;
|
|
215
|
+
|
|
216
|
+
export { MAX_COMMIT_MESSAGE_BYTES, MAX_INDEX_BYTES, MAX_PEEL_DEPTH, MAX_SYMBOLIC_REF_DEPTH, MAX_WALK_QUEUE_SIZE, MAX_WALK_SEEDS, TreeDiff, createCommit, diffTrees, getRepoRoot, mergeBase, readBlob, readIndex, readObject, readTree, resolveRef, updateRef, walkCommits, walkTree, writeObject, writeSymbolicRef, writeTree };
|
|
217
|
+
export type { CreateCommitInput, DiffTreesInput, DiffTreesOptions, ReadObjectOptions, ResolveRefOptions, UpdateRefOptions, WalkCommitsOptions, WalkTreeEntry, WalkTreeOptions };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { a as HttpRequest, b as HttpResponse, H as HttpTransport } from '../chunks/http-transport--_NdQOiw.cjs';
|
|
2
|
+
|
|
3
|
+
type RetryPredicate = (info: {
|
|
4
|
+
readonly error?: unknown;
|
|
5
|
+
readonly response?: HttpResponse;
|
|
6
|
+
readonly attempt: number;
|
|
7
|
+
}) => boolean;
|
|
8
|
+
interface RetryConfig {
|
|
9
|
+
readonly attempts: number;
|
|
10
|
+
readonly backoff?: 'fixed' | 'exponential';
|
|
11
|
+
readonly baseMs?: number;
|
|
12
|
+
readonly maxDelayMs?: number;
|
|
13
|
+
readonly jitter?: number;
|
|
14
|
+
readonly isRetryable?: RetryPredicate;
|
|
15
|
+
readonly delay?: (ms: number, signal?: AbortSignal) => Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
type AuthConfig = {
|
|
18
|
+
readonly type: 'bearer';
|
|
19
|
+
readonly token: string;
|
|
20
|
+
} | {
|
|
21
|
+
readonly type: 'basic';
|
|
22
|
+
readonly username: string;
|
|
23
|
+
readonly password: string;
|
|
24
|
+
} | {
|
|
25
|
+
readonly type: 'custom';
|
|
26
|
+
readonly header: (req: HttpRequest) => string | Promise<string>;
|
|
27
|
+
};
|
|
28
|
+
type LogEvent = {
|
|
29
|
+
readonly kind: 'request';
|
|
30
|
+
readonly method: 'GET' | 'POST';
|
|
31
|
+
readonly url: string;
|
|
32
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
33
|
+
readonly bodyBytes: number;
|
|
34
|
+
} | {
|
|
35
|
+
readonly kind: 'response';
|
|
36
|
+
readonly statusCode: number;
|
|
37
|
+
readonly url: string;
|
|
38
|
+
readonly elapsedMs: number;
|
|
39
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
40
|
+
} | {
|
|
41
|
+
readonly kind: 'error';
|
|
42
|
+
readonly url: string;
|
|
43
|
+
readonly elapsedMs: number;
|
|
44
|
+
readonly errorMessage: string;
|
|
45
|
+
};
|
|
46
|
+
interface Logger {
|
|
47
|
+
readonly log: (event: LogEvent) => void;
|
|
48
|
+
}
|
|
49
|
+
interface LoggingConfig {
|
|
50
|
+
readonly logger: Logger;
|
|
51
|
+
readonly now?: () => number;
|
|
52
|
+
readonly redactHeaders?: ReadonlyArray<string>;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
declare const withAuth: (config: AuthConfig) => (inner: HttpTransport) => HttpTransport;
|
|
56
|
+
|
|
57
|
+
declare const withLogging: (config: LoggingConfig) => (inner: HttpTransport) => HttpTransport;
|
|
58
|
+
|
|
59
|
+
declare const withRetry: (config: RetryConfig) => (inner: HttpTransport) => HttpTransport;
|
|
60
|
+
|
|
61
|
+
export { withAuth, withLogging, withRetry };
|
|
62
|
+
export type { AuthConfig, LogEvent, Logger, LoggingConfig, RetryConfig, RetryPredicate };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { a as HttpRequest, b as HttpResponse, H as HttpTransport } from '../chunks/http-transport--_NdQOiw.js';
|
|
2
|
+
|
|
3
|
+
type RetryPredicate = (info: {
|
|
4
|
+
readonly error?: unknown;
|
|
5
|
+
readonly response?: HttpResponse;
|
|
6
|
+
readonly attempt: number;
|
|
7
|
+
}) => boolean;
|
|
8
|
+
interface RetryConfig {
|
|
9
|
+
readonly attempts: number;
|
|
10
|
+
readonly backoff?: 'fixed' | 'exponential';
|
|
11
|
+
readonly baseMs?: number;
|
|
12
|
+
readonly maxDelayMs?: number;
|
|
13
|
+
readonly jitter?: number;
|
|
14
|
+
readonly isRetryable?: RetryPredicate;
|
|
15
|
+
readonly delay?: (ms: number, signal?: AbortSignal) => Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
type AuthConfig = {
|
|
18
|
+
readonly type: 'bearer';
|
|
19
|
+
readonly token: string;
|
|
20
|
+
} | {
|
|
21
|
+
readonly type: 'basic';
|
|
22
|
+
readonly username: string;
|
|
23
|
+
readonly password: string;
|
|
24
|
+
} | {
|
|
25
|
+
readonly type: 'custom';
|
|
26
|
+
readonly header: (req: HttpRequest) => string | Promise<string>;
|
|
27
|
+
};
|
|
28
|
+
type LogEvent = {
|
|
29
|
+
readonly kind: 'request';
|
|
30
|
+
readonly method: 'GET' | 'POST';
|
|
31
|
+
readonly url: string;
|
|
32
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
33
|
+
readonly bodyBytes: number;
|
|
34
|
+
} | {
|
|
35
|
+
readonly kind: 'response';
|
|
36
|
+
readonly statusCode: number;
|
|
37
|
+
readonly url: string;
|
|
38
|
+
readonly elapsedMs: number;
|
|
39
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
40
|
+
} | {
|
|
41
|
+
readonly kind: 'error';
|
|
42
|
+
readonly url: string;
|
|
43
|
+
readonly elapsedMs: number;
|
|
44
|
+
readonly errorMessage: string;
|
|
45
|
+
};
|
|
46
|
+
interface Logger {
|
|
47
|
+
readonly log: (event: LogEvent) => void;
|
|
48
|
+
}
|
|
49
|
+
interface LoggingConfig {
|
|
50
|
+
readonly logger: Logger;
|
|
51
|
+
readonly now?: () => number;
|
|
52
|
+
readonly redactHeaders?: ReadonlyArray<string>;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
declare const withAuth: (config: AuthConfig) => (inner: HttpTransport) => HttpTransport;
|
|
56
|
+
|
|
57
|
+
declare const withLogging: (config: LoggingConfig) => (inner: HttpTransport) => HttpTransport;
|
|
58
|
+
|
|
59
|
+
declare const withRetry: (config: RetryConfig) => (inner: HttpTransport) => HttpTransport;
|
|
60
|
+
|
|
61
|
+
export { withAuth, withLogging, withRetry };
|
|
62
|
+
export type { AuthConfig, LogEvent, Logger, LoggingConfig, RetryConfig, RetryPredicate };
|