@gibwork/sdk 0.0.5 → 0.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.
- package/CHANGELOG.md +7 -0
- package/README.md +85 -1
- package/dist/{chunk-BNAVP5XZ.js → chunk-HJ5D5SOE.js} +329 -37
- package/dist/chunk-HJ5D5SOE.js.map +1 -0
- package/dist/index.cjs +329 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +159 -3
- package/dist/index.d.ts +159 -3
- package/dist/index.js +1 -1
- package/dist/node.cjs +329 -34
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.cts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/node.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-BNAVP5XZ.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -18,8 +18,9 @@ declare class GibworkApiError extends GibworkError {
|
|
|
18
18
|
readonly method: string;
|
|
19
19
|
readonly path: string;
|
|
20
20
|
readonly requestId?: string | undefined;
|
|
21
|
+
readonly retryAfter?: string | undefined;
|
|
21
22
|
readonly name: string;
|
|
22
|
-
constructor(status: number, body: unknown, method: string, path: string, requestId?: string | undefined);
|
|
23
|
+
constructor(status: number, body: unknown, method: string, path: string, requestId?: string | undefined, retryAfter?: string | undefined);
|
|
23
24
|
}
|
|
24
25
|
declare class GibworkNetworkError extends GibworkError {
|
|
25
26
|
readonly method: string;
|
|
@@ -36,18 +37,46 @@ declare class GibworkRequestAbortedError extends GibworkNetworkError {
|
|
|
36
37
|
readonly name: string;
|
|
37
38
|
constructor(method: string, path: string, options?: ErrorOptions);
|
|
38
39
|
}
|
|
39
|
-
type SubmitOperation = 'create-task' | 'refund-task' | 'approve-submission';
|
|
40
|
+
type SubmitOperation = 'create-task' | 'refund-task' | 'approve-submission' | 'create-submission';
|
|
40
41
|
interface AmbiguousSubmitContext {
|
|
41
42
|
operation: SubmitOperation;
|
|
42
43
|
taskId?: string;
|
|
43
44
|
submissionId?: string;
|
|
44
45
|
intentId: string;
|
|
46
|
+
paymentAttemptId?: string;
|
|
47
|
+
idempotencyKey?: string;
|
|
48
|
+
walletAddress?: string;
|
|
49
|
+
environment?: 'stage' | 'prod';
|
|
50
|
+
apiUrl?: string;
|
|
45
51
|
}
|
|
46
52
|
declare class GibworkAmbiguousSubmitError extends GibworkNetworkError {
|
|
47
53
|
readonly context: AmbiguousSubmitContext;
|
|
48
54
|
readonly name: string;
|
|
49
55
|
constructor(method: string, path: string, context: AmbiguousSubmitContext, options?: ErrorOptions);
|
|
50
56
|
}
|
|
57
|
+
declare class GibworkValidationError extends GibworkError {
|
|
58
|
+
readonly name: string;
|
|
59
|
+
}
|
|
60
|
+
declare class GibworkProtocolError extends GibworkError {
|
|
61
|
+
readonly name: string;
|
|
62
|
+
}
|
|
63
|
+
interface SubmissionRecoveryContext {
|
|
64
|
+
taskId: string;
|
|
65
|
+
idempotencyKey: string;
|
|
66
|
+
walletAddress: string;
|
|
67
|
+
environment: 'stage' | 'prod';
|
|
68
|
+
apiUrl: string;
|
|
69
|
+
phase: 'prepare' | 'sign' | 'submit';
|
|
70
|
+
intentId?: string;
|
|
71
|
+
paymentAttemptId?: string;
|
|
72
|
+
submissionId?: string;
|
|
73
|
+
}
|
|
74
|
+
/** Retains identifiers when creation stops, including before any payment is sent. */
|
|
75
|
+
declare class GibworkSubmissionOperationError extends GibworkError {
|
|
76
|
+
readonly context: SubmissionRecoveryContext;
|
|
77
|
+
readonly name: string;
|
|
78
|
+
constructor(context: SubmissionRecoveryContext, options?: ErrorOptions);
|
|
79
|
+
}
|
|
51
80
|
|
|
52
81
|
interface RequestOptions {
|
|
53
82
|
signal?: AbortSignal;
|
|
@@ -239,6 +268,13 @@ interface UserSummary {
|
|
|
239
268
|
rejectedTaskSubmissions: number;
|
|
240
269
|
rating: number;
|
|
241
270
|
}
|
|
271
|
+
interface PublicProfileReference {
|
|
272
|
+
id: string;
|
|
273
|
+
routeKey: string;
|
|
274
|
+
}
|
|
275
|
+
type WalletSubmissionUser = Omit<UserSummary, 'externalId' | 'membership'> & {
|
|
276
|
+
publicProfile: PublicProfileReference | null;
|
|
277
|
+
};
|
|
242
278
|
interface MediaItem {
|
|
243
279
|
id: string;
|
|
244
280
|
provider: string;
|
|
@@ -262,6 +298,14 @@ interface SubmissionComment {
|
|
|
262
298
|
user: UserSummary;
|
|
263
299
|
media: MediaItem[];
|
|
264
300
|
}
|
|
301
|
+
interface WalletSubmissionComment {
|
|
302
|
+
id: string;
|
|
303
|
+
taskSubmissionId: string;
|
|
304
|
+
content: string;
|
|
305
|
+
createdAt: string;
|
|
306
|
+
user: WalletSubmissionUser;
|
|
307
|
+
media: MediaItem[];
|
|
308
|
+
}
|
|
265
309
|
interface SubmissionAsset extends Record<string, unknown> {
|
|
266
310
|
id?: string;
|
|
267
311
|
mintAddress?: string;
|
|
@@ -272,6 +316,19 @@ interface SubmissionAsset extends Record<string, unknown> {
|
|
|
272
316
|
decimals?: number;
|
|
273
317
|
}
|
|
274
318
|
type TaskSubmissionStatus = 'OPEN' | 'REJECTED' | 'CLAIMING' | 'WAITING_CLAIM' | 'CLOSED' | 'CLAIMED' | 'PROCESSING';
|
|
319
|
+
interface WalletTaskSubmissionDetails {
|
|
320
|
+
id: string;
|
|
321
|
+
taskId: string;
|
|
322
|
+
content: string;
|
|
323
|
+
status: TaskSubmissionStatus;
|
|
324
|
+
createdAt: string;
|
|
325
|
+
rejectReason?: string | null;
|
|
326
|
+
rating: number | null;
|
|
327
|
+
user: WalletSubmissionUser;
|
|
328
|
+
comments: WalletSubmissionComment[];
|
|
329
|
+
media: MediaItem[];
|
|
330
|
+
asset?: SubmissionAsset | null;
|
|
331
|
+
}
|
|
275
332
|
interface TaskSubmission extends Record<string, unknown> {
|
|
276
333
|
id: string;
|
|
277
334
|
taskId: string;
|
|
@@ -297,6 +354,88 @@ interface GibworkApiErrorBody {
|
|
|
297
354
|
error?: string;
|
|
298
355
|
[key: string]: unknown;
|
|
299
356
|
}
|
|
357
|
+
interface AvailableTasksQuery {
|
|
358
|
+
page?: number;
|
|
359
|
+
limit?: number;
|
|
360
|
+
}
|
|
361
|
+
interface AvailableTask {
|
|
362
|
+
id: string;
|
|
363
|
+
slug: string;
|
|
364
|
+
title: string;
|
|
365
|
+
content: string;
|
|
366
|
+
requirements: string | null;
|
|
367
|
+
tags: string[];
|
|
368
|
+
primarySkillId: string | null;
|
|
369
|
+
createdAt: string;
|
|
370
|
+
deadline: string | null;
|
|
371
|
+
status: 'CREATED';
|
|
372
|
+
isOpen: boolean;
|
|
373
|
+
asset: AvailableTaskAsset | null;
|
|
374
|
+
minSubmissionAmount: string | null;
|
|
375
|
+
totalSubmissions: number;
|
|
376
|
+
maxSubmissions: number | null;
|
|
377
|
+
standardSubmissionSlotsRemaining: number | null;
|
|
378
|
+
requiresPremium: boolean;
|
|
379
|
+
participationRequirements: AvailableTaskParticipationRequirements;
|
|
380
|
+
}
|
|
381
|
+
type AvailableTaskPage = Paginated<AvailableTask>;
|
|
382
|
+
interface CreateSubmissionInput {
|
|
383
|
+
content: string;
|
|
384
|
+
referral?: string | null;
|
|
385
|
+
mediaIds?: string[] | null;
|
|
386
|
+
/** Reuse for retries of this exact task and submission payload. */
|
|
387
|
+
idempotencyKey: string;
|
|
388
|
+
}
|
|
389
|
+
interface SubmitSubmissionInput {
|
|
390
|
+
paymentAttemptId: string;
|
|
391
|
+
signedTransaction: string;
|
|
392
|
+
}
|
|
393
|
+
type TaskSubmissionIntentStatus = 'pending' | 'submitted' | 'fulfilled' | 'failed' | 'expired' | 'requires_review';
|
|
394
|
+
interface TaskSubmissionIntent {
|
|
395
|
+
intentId: string;
|
|
396
|
+
taskId: string;
|
|
397
|
+
/** Allocated in advance; exists as a submission only when fulfilled. */
|
|
398
|
+
taskSubmissionId: string;
|
|
399
|
+
paymentAttemptId: string;
|
|
400
|
+
status: TaskSubmissionIntentStatus;
|
|
401
|
+
txHash: string | null;
|
|
402
|
+
expiresAt: string;
|
|
403
|
+
lastValidBlockHeight: number;
|
|
404
|
+
fee: TaskSubmissionFee;
|
|
405
|
+
reviewReason?: string;
|
|
406
|
+
/** Only returned by prepare for a pending intent, including pending retries. */
|
|
407
|
+
serializedTransaction?: string;
|
|
408
|
+
}
|
|
409
|
+
interface TaskSubmissionFee {
|
|
410
|
+
amount: string;
|
|
411
|
+
amountBaseUnits: string;
|
|
412
|
+
totalDebit: string;
|
|
413
|
+
symbol: 'USDC';
|
|
414
|
+
mintAddress: string;
|
|
415
|
+
decimals: number;
|
|
416
|
+
destinationAddress: string;
|
|
417
|
+
}
|
|
418
|
+
interface AvailableTaskAsset {
|
|
419
|
+
mintAddress: string;
|
|
420
|
+
symbol: string;
|
|
421
|
+
imageUrl: string;
|
|
422
|
+
decimals: number;
|
|
423
|
+
/** Original reward pool in base units, not the remaining balance. */
|
|
424
|
+
amount: string;
|
|
425
|
+
}
|
|
426
|
+
interface AvailableTaskParticipationRequirements {
|
|
427
|
+
allowOnlyVerifiedSubmissions: boolean;
|
|
428
|
+
allowOnlyVerifiedTwitterAccountSubmissions: boolean;
|
|
429
|
+
minTwitterFollowers: number;
|
|
430
|
+
minTweetLikes: number;
|
|
431
|
+
minTweetViews: number;
|
|
432
|
+
isTwitterTask: boolean;
|
|
433
|
+
allowOnlyDiscordGuildSubmissions: boolean;
|
|
434
|
+
requiredDiscordGuildId: string | null;
|
|
435
|
+
requiredDiscordGuildName: string | null;
|
|
436
|
+
discordGuildInvitationUrl: string | null;
|
|
437
|
+
requiredDiscordRoleIds: string[];
|
|
438
|
+
}
|
|
300
439
|
|
|
301
440
|
type FetchImplementation = typeof fetch;
|
|
302
441
|
interface HttpTransportOptions {
|
|
@@ -312,6 +451,7 @@ interface HttpRequest {
|
|
|
312
451
|
body?: unknown;
|
|
313
452
|
options?: RequestOptions;
|
|
314
453
|
ambiguousSubmit?: AmbiguousSubmitContext;
|
|
454
|
+
validateResponse?: (body: unknown) => void;
|
|
315
455
|
}
|
|
316
456
|
declare class HttpTransport {
|
|
317
457
|
private readonly baseUrl;
|
|
@@ -319,6 +459,11 @@ declare class HttpTransport {
|
|
|
319
459
|
private readonly production;
|
|
320
460
|
private readonly timeoutMs;
|
|
321
461
|
constructor(options: HttpTransportOptions);
|
|
462
|
+
/** Recovery location without URL credentials. Retains reverse-proxy path prefixes. */
|
|
463
|
+
get recoveryLocation(): {
|
|
464
|
+
apiUrl: string;
|
|
465
|
+
environment: 'stage' | 'prod';
|
|
466
|
+
};
|
|
322
467
|
request<T>(request: HttpRequest): Promise<T>;
|
|
323
468
|
}
|
|
324
469
|
|
|
@@ -335,7 +480,16 @@ declare class SubmissionsResource {
|
|
|
335
480
|
private readonly signer;
|
|
336
481
|
readonly comments: SubmissionCommentsResource;
|
|
337
482
|
constructor(transport: HttpTransport, signer: WalletSigner);
|
|
483
|
+
/** Creates work through a participation fee; only fulfilled confirms creation. */
|
|
484
|
+
create(taskId: string, input: CreateSubmissionInput, options?: RequestOptions): Promise<TaskSubmissionIntent>;
|
|
485
|
+
/** Reuse the exact input and idempotency key after an interrupted prepare. */
|
|
486
|
+
prepareCreate(taskId: string, input: CreateSubmissionInput, options?: RequestOptions): Promise<TaskSubmissionIntent>;
|
|
487
|
+
/** Never automatically retries. Recover an uncertain payment with getIntent. */
|
|
488
|
+
submitCreate(taskId: string, intentId: string, input: SubmitSubmissionInput, options?: RequestOptions): Promise<TaskSubmissionIntent>;
|
|
489
|
+
/** Reads/reconciles creation using the original wallet; does not report review/payout. */
|
|
490
|
+
getIntent(taskId: string, intentId: string, options?: RequestOptions): Promise<TaskSubmissionIntent>;
|
|
338
491
|
list(taskId: string, query?: SubmissionPaginationQuery, options?: RequestOptions): Promise<Paginated<TaskSubmission>>;
|
|
492
|
+
get(taskId: string, submissionId: string, options?: RequestOptions): Promise<WalletTaskSubmissionDetails>;
|
|
339
493
|
approve(taskId: string, submissionId: string, input: ApproveSubmissionInput, options?: RequestOptions): Promise<ApproveSubmissionResult>;
|
|
340
494
|
reject(taskId: string, submissionId: string, reason?: string | null, options?: RequestOptions): Promise<RejectSubmissionResult>;
|
|
341
495
|
prepareApproval(taskId: string, submissionId: string, input: ApproveSubmissionInput, options?: RequestOptions): Promise<PreparedApprovalIntent>;
|
|
@@ -349,6 +503,8 @@ declare class TasksResource {
|
|
|
349
503
|
constructor(transport: HttpTransport, signer: WalletSigner);
|
|
350
504
|
create(input: CreateTaskInput, options?: RequestOptions): Promise<CreateTaskResult>;
|
|
351
505
|
list(query?: PaginationQuery, options?: RequestOptions): Promise<Paginated<WalletTaskSummary>>;
|
|
506
|
+
/** Discover tasks across creators. Eligibility is checked when preparing work. */
|
|
507
|
+
listAvailable(query?: AvailableTasksQuery, options?: RequestOptions): Promise<AvailableTaskPage>;
|
|
352
508
|
update(taskId: string, input: UpdateTaskInput, options?: RequestOptions): Promise<UpdatedTask>;
|
|
353
509
|
refund(taskId: string, options?: RequestOptions): Promise<RefundTaskResult>;
|
|
354
510
|
prepareCreate(input: CreateTaskInput, options?: RequestOptions): Promise<PreparedTaskIntent>;
|
|
@@ -378,4 +534,4 @@ declare const DEFAULT_GIBWORK_API_URL: string;
|
|
|
378
534
|
|
|
379
535
|
declare function signPreparedTransaction(serializedTransaction: string, signer: WalletSigner): Promise<string>;
|
|
380
536
|
|
|
381
|
-
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 UpdateTaskInput, type UpdatedTask, type UserSummary, type WalletSigner, type WalletTaskAsset, type WalletTaskSummary, signPreparedTransaction };
|
|
537
|
+
export { type AmbiguousSubmitContext, type ApprovalQuote, type ApprovalSubmitResult, type ApproveSubmissionInput, type ApproveSubmissionResult, type AvailableTask, type AvailableTaskAsset, type AvailableTaskPage, type AvailableTaskParticipationRequirements, type AvailableTasksQuery, type CreateSubmissionInput, type CreateTaskInput, type CreateTaskResult, DEFAULT_GIBWORK_API_URL, type FeeQuote, type FetchImplementation, GibworkAmbiguousSubmitError, GibworkApiError, type GibworkApiErrorBody, GibworkClient, type GibworkClientOptions, GibworkConfigurationError, GibworkError, GibworkNetworkError, GibworkProtocolError, GibworkRequestAbortedError, GibworkSubmissionOperationError, GibworkTimeoutError, GibworkValidationError, type MediaItem, type Membership, type Paginated, type PaginationQuery, type PaymentQuote, type PreparedApprovalIntent, type PreparedRefundIntent, type PreparedTaskIntent, type PublicProfileReference, type RefundQuote, type RefundSubmitResult, type RefundTaskResult, type RejectSubmissionResult, type RequestOptions, type SubmissionAsset, type SubmissionComment, type SubmissionPaginationQuery, type SubmissionRecoveryContext, type SubmissionStatus, type SubmitOperation, type SubmitSubmissionInput, type TaskSubmission, type TaskSubmissionFee, type TaskSubmissionIntent, type TaskSubmissionIntentStatus, type TaskSubmissionStatus, type TaskSubmitResult, type TokenQuote, type UpdateTaskInput, type UpdatedTask, type UserSummary, type WalletSigner, type WalletSubmissionComment, type WalletSubmissionUser, type WalletTaskAsset, type WalletTaskSubmissionDetails, type WalletTaskSummary, signPreparedTransaction };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { DEFAULT_GIBWORK_API_URL, GibworkAmbiguousSubmitError, GibworkApiError, GibworkClient, GibworkConfigurationError, GibworkError, GibworkNetworkError, GibworkRequestAbortedError, GibworkTimeoutError, signPreparedTransaction } from './chunk-
|
|
1
|
+
export { DEFAULT_GIBWORK_API_URL, GibworkAmbiguousSubmitError, GibworkApiError, GibworkClient, GibworkConfigurationError, GibworkError, GibworkNetworkError, GibworkProtocolError, GibworkRequestAbortedError, GibworkSubmissionOperationError, GibworkTimeoutError, GibworkValidationError, signPreparedTransaction } from './chunk-HJ5D5SOE.js';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
3
3
|
//# sourceMappingURL=index.js.map
|