@gibwork/sdk 0.0.1

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.
@@ -0,0 +1,356 @@
1
+ import { PublicKey, VersionedTransaction } from '@solana/web3.js';
2
+
3
+ interface WalletSigner {
4
+ publicKey: PublicKey;
5
+ signMessage(message: Uint8Array): Promise<Uint8Array>;
6
+ signTransaction(transaction: VersionedTransaction): Promise<VersionedTransaction>;
7
+ }
8
+
9
+ declare class GibworkError extends Error {
10
+ readonly name: string;
11
+ }
12
+ declare class GibworkConfigurationError extends GibworkError {
13
+ readonly name: string;
14
+ }
15
+ declare class GibworkApiError extends GibworkError {
16
+ readonly status: number;
17
+ readonly body: unknown;
18
+ readonly method: string;
19
+ readonly path: string;
20
+ readonly requestId?: string | undefined;
21
+ readonly name: string;
22
+ constructor(status: number, body: unknown, method: string, path: string, requestId?: string | undefined);
23
+ }
24
+ declare class GibworkNetworkError extends GibworkError {
25
+ readonly method: string;
26
+ readonly path: string;
27
+ readonly name: string;
28
+ constructor(message: string, method: string, path: string, options?: ErrorOptions);
29
+ }
30
+ declare class GibworkTimeoutError extends GibworkNetworkError {
31
+ readonly timeoutMs: number;
32
+ readonly name: string;
33
+ constructor(method: string, path: string, timeoutMs: number, options?: ErrorOptions);
34
+ }
35
+ declare class GibworkRequestAbortedError extends GibworkNetworkError {
36
+ readonly name: string;
37
+ constructor(method: string, path: string, options?: ErrorOptions);
38
+ }
39
+ type SubmitOperation = 'create-task' | 'refund-task' | 'approve-submission';
40
+ interface AmbiguousSubmitContext {
41
+ operation: SubmitOperation;
42
+ taskId?: string;
43
+ submissionId?: string;
44
+ intentId: string;
45
+ }
46
+ declare class GibworkAmbiguousSubmitError extends GibworkNetworkError {
47
+ readonly context: AmbiguousSubmitContext;
48
+ readonly name: string;
49
+ constructor(method: string, path: string, context: AmbiguousSubmitContext, options?: ErrorOptions);
50
+ }
51
+
52
+ interface RequestOptions {
53
+ signal?: AbortSignal;
54
+ }
55
+ interface PaginationQuery {
56
+ page?: number;
57
+ limit?: number;
58
+ pageAll?: boolean;
59
+ }
60
+ type SubmissionStatus = 'pending' | 'approved' | 'rejected';
61
+ interface SubmissionPaginationQuery extends PaginationQuery {
62
+ status?: SubmissionStatus;
63
+ }
64
+ interface Paginated<T> {
65
+ results: T[];
66
+ page: number;
67
+ limit: number;
68
+ total: number;
69
+ lastPage: number;
70
+ }
71
+ interface CreateTaskInput {
72
+ title: string;
73
+ content: string;
74
+ tags: string[];
75
+ primarySkillSlug?: string;
76
+ payment: {
77
+ mintAddress: string;
78
+ amount: string;
79
+ };
80
+ minSubmissionAmount: string;
81
+ refundFeeOverride?: number | null;
82
+ deadline?: string | null;
83
+ allowOnlyVerifiedSubmissions?: boolean;
84
+ allowOnlyDiscordGuildSubmissions?: boolean;
85
+ requiredDiscordGuildId?: string | null;
86
+ requiredDiscordGuildName?: string | null;
87
+ discordGuildInvitationUrl?: string | null;
88
+ requiredDiscordRoleIds?: string[];
89
+ }
90
+ interface ApproveSubmissionInput {
91
+ amount: string;
92
+ rating?: number;
93
+ }
94
+ interface TokenQuote {
95
+ mintAddress: string;
96
+ symbol: string;
97
+ decimals: number;
98
+ }
99
+ interface FeeQuote {
100
+ percent: number;
101
+ amount: string;
102
+ }
103
+ interface PaymentQuote {
104
+ token: TokenQuote;
105
+ fundingAmount: string;
106
+ platformFee: FeeQuote;
107
+ totalDebit: string;
108
+ }
109
+ interface RefundQuote {
110
+ token: TokenQuote;
111
+ grossRefundAmount: string;
112
+ platformFee: FeeQuote;
113
+ netRefundAmount: string;
114
+ }
115
+ interface ApprovalQuote {
116
+ token: TokenQuote;
117
+ grossApprovalAmount: string;
118
+ platformFee: FeeQuote;
119
+ referralFee: string;
120
+ netPayoutAmount: string;
121
+ closeTask: boolean;
122
+ }
123
+ interface PreparedTaskIntent {
124
+ intentId: string;
125
+ taskId: string;
126
+ serializedTransaction: string;
127
+ lastValidBlockHeight: number;
128
+ paymentQuote: PaymentQuote;
129
+ }
130
+ interface PreparedRefundIntent {
131
+ intentId: string;
132
+ taskId: string;
133
+ serializedTransaction: string;
134
+ lastValidBlockHeight: number;
135
+ refundQuote: RefundQuote;
136
+ }
137
+ interface PreparedApprovalIntent {
138
+ intentId: string;
139
+ taskId: string;
140
+ taskSubmissionId: string;
141
+ serializedTransaction: string;
142
+ lastValidBlockHeight: number;
143
+ approvalQuote: ApprovalQuote;
144
+ }
145
+ interface TaskSubmitResult {
146
+ taskId: string;
147
+ txHash?: string;
148
+ status: 'confirmed' | 'processing' | 'failed';
149
+ }
150
+ interface RefundSubmitResult {
151
+ taskId: string;
152
+ txHash: string;
153
+ }
154
+ interface ApprovalSubmitResult extends RefundSubmitResult {
155
+ taskSubmissionId: string;
156
+ }
157
+ interface CreateTaskResult extends TaskSubmitResult {
158
+ intentId: string;
159
+ lastValidBlockHeight: number;
160
+ paymentQuote: PaymentQuote;
161
+ }
162
+ interface RefundTaskResult extends RefundSubmitResult {
163
+ intentId: string;
164
+ lastValidBlockHeight: number;
165
+ refundQuote: RefundQuote;
166
+ }
167
+ interface ApproveSubmissionResult extends ApprovalSubmitResult {
168
+ intentId: string;
169
+ lastValidBlockHeight: number;
170
+ approvalQuote: ApprovalQuote;
171
+ }
172
+ interface RejectSubmissionResult {
173
+ message: 'Submission rejected';
174
+ submission: {
175
+ id: string;
176
+ taskId: string;
177
+ status: 'REJECTED';
178
+ rejectReason?: string | null;
179
+ reviewedAt: string;
180
+ };
181
+ }
182
+ interface WalletTaskAsset {
183
+ decimals: number;
184
+ imageUrl: string | null;
185
+ symbol: string | null;
186
+ amount: number;
187
+ rewarded: number;
188
+ price: string;
189
+ mintAddress: string | null;
190
+ }
191
+ interface WalletTaskSummary {
192
+ id: string;
193
+ createdAt: string;
194
+ type: 'tasks';
195
+ status: 'refunded' | 'complete' | 'creating' | 'in progress';
196
+ approvedSubmissions: number;
197
+ totalSubmissions: number;
198
+ title: string;
199
+ isOpen: boolean;
200
+ asset: WalletTaskAsset;
201
+ rewardedAmount: number;
202
+ rewardedPrice: string;
203
+ }
204
+ interface Membership {
205
+ tier: string;
206
+ entitlementLevel: number;
207
+ isPro: boolean;
208
+ }
209
+ interface UserSummary {
210
+ id: string;
211
+ externalId: string;
212
+ username: string;
213
+ firstName?: string;
214
+ lastName?: string;
215
+ profilePicture: string;
216
+ isPremium: boolean;
217
+ membership: Membership;
218
+ approvedTaskSubmissions: number;
219
+ rejectedTaskSubmissions: number;
220
+ rating: number;
221
+ }
222
+ interface MediaItem {
223
+ id: string;
224
+ provider: string;
225
+ providerFileId?: string;
226
+ type: string;
227
+ mimeType: string;
228
+ url: string;
229
+ thumbnailUrl?: string;
230
+ sizeBytes?: number | null;
231
+ order: number;
232
+ status: string;
233
+ metadata?: Record<string, unknown>;
234
+ createdAt: string;
235
+ }
236
+ interface SubmissionComment {
237
+ id: string;
238
+ taskSubmissionId: string;
239
+ content: string;
240
+ createdBy?: string;
241
+ createdAt: string;
242
+ user: UserSummary;
243
+ media: MediaItem[];
244
+ }
245
+ interface SubmissionAsset extends Record<string, unknown> {
246
+ id?: string;
247
+ mintAddress?: string;
248
+ symbol?: string;
249
+ imageUrl?: string;
250
+ amount?: number;
251
+ price?: number;
252
+ decimals?: number;
253
+ }
254
+ type TaskSubmissionStatus = 'OPEN' | 'REJECTED' | 'CLAIMING' | 'WAITING_CLAIM' | 'CLOSED' | 'CLAIMED' | 'PROCESSING';
255
+ interface TaskSubmission extends Record<string, unknown> {
256
+ id: string;
257
+ taskId: string;
258
+ content: string;
259
+ status: TaskSubmissionStatus;
260
+ assetId: string | null;
261
+ transactionId: string | null;
262
+ rejectReason: string | null;
263
+ blinks: boolean;
264
+ isHidden: boolean;
265
+ referralId: string | null;
266
+ createdBy: string;
267
+ createdAt: string;
268
+ rating: number | null;
269
+ user: UserSummary;
270
+ comments: SubmissionComment[];
271
+ media: MediaItem[];
272
+ asset: SubmissionAsset | null;
273
+ }
274
+ interface GibworkApiErrorBody {
275
+ statusCode?: number;
276
+ message?: string | string[];
277
+ error?: string;
278
+ [key: string]: unknown;
279
+ }
280
+
281
+ type FetchImplementation = typeof fetch;
282
+ interface HttpTransportOptions {
283
+ baseUrl: string;
284
+ fetch?: FetchImplementation;
285
+ timeoutMs?: number;
286
+ }
287
+ interface HttpRequest {
288
+ method: 'GET' | 'POST';
289
+ path: string;
290
+ headers?: Record<string, string>;
291
+ body?: unknown;
292
+ options?: RequestOptions;
293
+ ambiguousSubmit?: AmbiguousSubmitContext;
294
+ }
295
+ declare class HttpTransport {
296
+ private readonly baseUrl;
297
+ private readonly fetchImplementation;
298
+ private readonly timeoutMs;
299
+ constructor(options: HttpTransportOptions);
300
+ request<T>(request: HttpRequest): Promise<T>;
301
+ }
302
+
303
+ declare class SubmissionCommentsResource {
304
+ private readonly transport;
305
+ private readonly signer;
306
+ constructor(transport: HttpTransport, signer: WalletSigner);
307
+ list(taskId: string, submissionId: string, options?: RequestOptions): Promise<SubmissionComment[]>;
308
+ create(taskId: string, submissionId: string, content: string, options?: RequestOptions): Promise<SubmissionComment>;
309
+ }
310
+
311
+ declare class SubmissionsResource {
312
+ private readonly transport;
313
+ private readonly signer;
314
+ readonly comments: SubmissionCommentsResource;
315
+ constructor(transport: HttpTransport, signer: WalletSigner);
316
+ list(taskId: string, query?: SubmissionPaginationQuery, options?: RequestOptions): Promise<Paginated<TaskSubmission>>;
317
+ approve(taskId: string, submissionId: string, input: ApproveSubmissionInput, options?: RequestOptions): Promise<ApproveSubmissionResult>;
318
+ reject(taskId: string, submissionId: string, reason?: string | null, options?: RequestOptions): Promise<RejectSubmissionResult>;
319
+ prepareApproval(taskId: string, submissionId: string, input: ApproveSubmissionInput, options?: RequestOptions): Promise<PreparedApprovalIntent>;
320
+ submitApproval(taskId: string, submissionId: string, intentId: string, signedTransaction: string, options?: RequestOptions): Promise<ApprovalSubmitResult>;
321
+ private get walletAddress();
322
+ }
323
+
324
+ declare class TasksResource {
325
+ private readonly transport;
326
+ private readonly signer;
327
+ constructor(transport: HttpTransport, signer: WalletSigner);
328
+ create(input: CreateTaskInput, options?: RequestOptions): Promise<CreateTaskResult>;
329
+ list(query?: PaginationQuery, options?: RequestOptions): Promise<Paginated<WalletTaskSummary>>;
330
+ refund(taskId: string, options?: RequestOptions): Promise<RefundTaskResult>;
331
+ prepareCreate(input: CreateTaskInput, options?: RequestOptions): Promise<PreparedTaskIntent>;
332
+ submitCreate(intentId: string, signedTransaction: string, options?: RequestOptions): Promise<TaskSubmitResult>;
333
+ prepareRefund(taskId: string, options?: RequestOptions): Promise<PreparedRefundIntent>;
334
+ submitRefund(taskId: string, intentId: string, signedTransaction: string, options?: RequestOptions): Promise<RefundSubmitResult>;
335
+ private get walletAddress();
336
+ private auth;
337
+ }
338
+
339
+ interface GibworkClientOptions {
340
+ baseUrl?: string;
341
+ signer: WalletSigner;
342
+ fetch?: FetchImplementation;
343
+ timeoutMs?: number;
344
+ }
345
+ declare class GibworkClient {
346
+ readonly tasks: TasksResource;
347
+ readonly submissions: SubmissionsResource;
348
+ constructor(options: GibworkClientOptions);
349
+ }
350
+
351
+ /** The API origin embedded when this package was built. */
352
+ declare const DEFAULT_GIBWORK_API_URL: string;
353
+
354
+ declare function signPreparedTransaction(serializedTransaction: string, signer: WalletSigner): Promise<string>;
355
+
356
+ export { type AmbiguousSubmitContext, type ApprovalQuote, type ApprovalSubmitResult, type ApproveSubmissionInput, type ApproveSubmissionResult, type CreateTaskInput, type CreateTaskResult, DEFAULT_GIBWORK_API_URL, type FeeQuote, type FetchImplementation, GibworkAmbiguousSubmitError, GibworkApiError, type GibworkApiErrorBody, GibworkClient, type GibworkClientOptions, GibworkConfigurationError, GibworkError, GibworkNetworkError, GibworkRequestAbortedError, GibworkTimeoutError, type MediaItem, type Membership, type Paginated, type PaginationQuery, type PaymentQuote, type PreparedApprovalIntent, type PreparedRefundIntent, type PreparedTaskIntent, type RefundQuote, type RefundSubmitResult, type RefundTaskResult, type RejectSubmissionResult, type RequestOptions, type SubmissionAsset, type SubmissionComment, type SubmissionPaginationQuery, type SubmissionStatus, type SubmitOperation, type TaskSubmission, type TaskSubmissionStatus, type TaskSubmitResult, type TokenQuote, type UserSummary, type WalletSigner, type WalletTaskAsset, type WalletTaskSummary, signPreparedTransaction };
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { DEFAULT_GIBWORK_API_URL, GibworkAmbiguousSubmitError, GibworkApiError, GibworkClient, GibworkConfigurationError, GibworkError, GibworkNetworkError, GibworkRequestAbortedError, GibworkTimeoutError, signPreparedTransaction } from './chunk-24XHBDMZ.js';
2
+ //# sourceMappingURL=index.js.map
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}