-
Notifications
You must be signed in to change notification settings - Fork 168
Expand file tree
/
Copy pathbindings.d.ts
More file actions
253 lines (211 loc) · 5.05 KB
/
bindings.d.ts
File metadata and controls
253 lines (211 loc) · 5.05 KB
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
export {}
import Toucan from 'toucan-js'
import { Service } from 'ucan-storage/service'
import { Mode } from './middleware/maintenance.js'
import { UserOutput, UserOutputKey } from './utils/db-client-types.js'
import { DBClient } from './utils/db-client.js'
import { Logging } from './utils/logs.js'
export type RuntimeEnvironmentName = 'test' | 'dev' | 'staging' | 'production'
export interface ServiceConfiguration {
/** Is this a debug build? */
DEBUG: boolean
/** Target runtime environment */
ENV: RuntimeEnvironmentName
/** Semantic version for current build */
VERSION: string
/** Git branch name of current build */
BRANCH: string
/** Git commit hash of current build */
COMMITHASH: string
/** Current maintenance mode */
MAINTENANCE_MODE: Mode
/** Salt for API key generation */
SALT: string
/** API key for special metaplex upload account */
METAPLEX_AUTH_TOKEN: string
/** UCAN private signing key */
PRIVATE_KEY: string
/** API url for active IPFS cluster endpoint */
CLUSTER_API_URL: string
/** Auth token for IPFS culster */
CLUSTER_BASIC_AUTH_TOKEN: string
/** Postgrest endpoint URL */
DATABASE_URL: string
/** Postgrest auth token */
DATABASE_TOKEN: string
/** S3 endpoint URL */
S3_ENDPOINT: string
/** S3 region */
S3_REGION: string
/** S3 access key id */
S3_ACCESS_KEY_ID: string
/** S3 secret key */
S3_SECRET_ACCESS_KEY: string
/** S3 bucket name */
S3_BUCKET_NAME: string
/** Magic link secret key */
MAGIC_SECRET_KEY: string
/** Logtail auth token */
LOGTAIL_TOKEN: string
/** Sentry DSN */
SENTRY_DSN: string
/** Mailchimp api key */
MAILCHIMP_API_KEY: string
/** PSA quota with number of in flight requests possible */
PSA_QUOTA: number
}
export interface Ucan {
token: string
root: any
cap: any
}
export interface Auth {
user: UserOutput
key?: UserOutputKey
db: DBClient
ucan?: Ucan
type: 'ucan' | 'key' | 'session'
}
export interface AuthOptions {
checkUcan?: boolean
checkHasAccountRestriction?: boolean
checkHasDeleteRestriction?: boolean
checkHasPsaAccess?: boolean
checkHasPsaQuota?: boolean
}
export interface RouteContext {
params: Record<string, string>
db: DBClient
log: Logging
backup?: BackupClient
ucanService: Service
auth?: Auth
}
export type Handler = (
event: FetchEvent,
ctx: RouteContext
) => Promise<Response> | Response
export interface Pin {
/**
* Content Identifier for the NFT data.
*/
cid: string
name?: string
meta?: Record<string, string>
status: PinStatus
created: string
size?: number
}
export type PinStatus = 'queued' | 'pinning' | 'pinned' | 'failed'
export type NFT = {
/**
* Content Identifier for the NFT data.
*/
cid: string
/**
* Type of the data: "directory" or Blob.type.
*/
type: string
/**
* Files in the directory (only if this NFT is a directory).
*/
files: Array<{ name?: string; type?: string } | undefined>
/**
* Pinata pin name and meta.
*/
pin?: { name?: string; meta?: Record<string, string> }
/**
* Name of the JWT token used to create this NFT.
*/
name?: string
/**
* Optional name of the file(s) uploaded as NFT.
*/
scope: string
/**
* Date this NFT was created in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: YYYY-MM-DDTHH:MM:SSZ.
*/
created: string
}
export type NFTResponse = NFT & {
size: number
pin: Pin
deals: Deal[]
}
export type CheckNFTResponse = {
cid: string
pin: Pin
deals: Deal[]
}
export type DealStatus = 'queued' | 'active' | 'published' | 'terminated'
export interface Deal {
status: DealStatus
lastChanged?: Date
chainDealID?: number
datamodelSelector: string
statusText?: string
dealActivation?: Date
dealExpiration?: Date
miner?: string
pieceCid: CIDString
batchRootCid: CIDString
}
export interface User {
sub: string
nickname: string
name: string
email: string
picture: string
issuer: string
publicAddress: string
tokens: Record<string, string>
/**
* This will actually be json object
*/
github?: string
}
export type UserSafe = Omit<User, 'tokens' | 'github'>
/**
* Pins add endpoint body interface
*/
export interface PinsAddInput {
cid: string
name: string
origins: string[]
meta: Record<string, string>
}
/**
* Pins endpoints response
*/
export interface PinsResponse {
requestid: string
status: PinStatus
created: string
pin: {
cid: string
meta: Record<string, string>
name?: string
origins: string[]
}
delegates: string[]
}
/**
* The known structural completeness of a given DAG. "Unknown" structure means
* it could be a partial or it could be a complete DAG i.e. we haven't walked
* the graph to verify if we have all the blocks or not.
*/
export type DagStructure = 'Unknown' | 'Partial' | 'Complete'
/**
* A client to a service that backups up a CAR file.
*/
export interface BackupClient {
/**
* Uploads the CAR file to the service and returns the URL.
*/
backupCar(
userId: number,
rootCid: CID,
car: Blob,
structure?: DagStructure
): Promise<URL>
}