-
Notifications
You must be signed in to change notification settings - Fork 10
/
types.d.ts
126 lines (109 loc) · 3.5 KB
/
types.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import type { Response } from 'node-fetch'
import type fetch from 'node-fetch'
import type {
NodeFetch,
ConfigurationParameters as ConfigurationParameters_og,
Configuration as Configuration_og
} from '@ipfs-shipyard/pinning-service-client'
/**
* This should move to the pinning-service-client package.
*/
declare module '@ipfs-shipyard/pinning-service-client' {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace NodeFetch {
interface RequestContext {
fetch: typeof fetch
url: string
init: RequestInit
}
interface ResponseContext {
fetch: typeof fetch
url: string
init: RequestInit
response: Response | any
}
interface FetchParams {
url: string
init: RequestInit
}
interface Middleware {
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
pre?: (context: NodeFetch.RequestContext) => Promise<NodeFetch.FetchParams | void>
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
post?: (context: NodeFetch.ResponseContext) => Promise<Response | void>
}
interface ConfigurationParameters extends ConfigurationParameters_og {
middleware: NodeFetch.Middleware[]
}
class Configuration extends Configuration_og {
constructor (options: NodeFetch.ConfigurationParameters): Configuration
}
}
}
interface ComplianceCheckDetailsCallbackArg extends NodeFetch.ResponseContext {
response: Response
errors: Error[]
url: string
}
interface ProcessedResponse extends Response {
text: string | null
json: Record<string, any>
}
interface ComplianceCheckDetailsCallback {
(details: ComplianceCheckDetailsCallbackArg): Promise<void>
}
interface ExpectationResult {
error?: Error
success: boolean
title: string
}
type ServiceAndTokenPair = [endpointUrl: string, authToken: string | undefined]
type PinsApiType = import('@ipfs-shipyard/pinning-service-client').PinsApi
type ImplementableMethods = keyof Omit<PinsApiType, 'withMiddleware' | 'withPreMiddleware' | 'withPostMiddleware'>
type PinsApiMethod<T extends ImplementableMethods = ImplementableMethods> = PinsApiType[T] extends never ? never : T
type SchemaNames = 'Delegates' | 'Failure' | 'Origins' | 'Pin' | 'PinMeta' | 'PinResults' | 'PinStatus' | 'StatusInfo' | 'Status' | 'TextMatchingStrategy'
type PinningSpecJoiSchema = Record<SchemaNames, import('@hapi/joi').Schema>
interface CheckResult {
success: boolean
}
interface ComplianceCheckRequest {
headers: Headers | string[][] | Record<string, string>
body: string
}
interface ComplianceCheckResponse {
headers: Headers | string[][] | Record<string, string>
status: number
statusText: string
json: Record<string, any> | null
body: string
}
interface ComplianceCheckDetails<T> {
pair: ServiceAndTokenPair
errors: Error[]
url: string
method: string
title: string
successful: boolean
validationResult: import('@hapi/joi').ValidationResult | null
request: ComplianceCheckRequest
response: ComplianceCheckResponse
result: T | null
expectationResults: ExpectationResult[]
}
// eslint-disable-next-line @typescript-eslint/dot-notation
interface ProcessedResponse extends Response {
text: string | null
json: Record<string, any>
}
interface ComplianceCheckDetailsCallback {
(details: ComplianceCheckDetailsCallbackArg): void
}
export type {
ComplianceCheckDetails,
ExpectationResult,
ProcessedResponse,
ComplianceCheckDetailsCallback,
ComplianceCheckDetailsCallbackArg,
PinningSpecJoiSchema,
ServiceAndTokenPair
}