krawlet-js 1.3.5 → 2.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/dist/index.cjs CHANGED
@@ -30,7 +30,8 @@ __export(index_exports, {
30
30
  PlayersResource: () => PlayersResource,
31
31
  ReportsResource: () => ReportsResource,
32
32
  ShopsResource: () => ShopsResource,
33
- StorageResource: () => StorageResource
33
+ StorageResource: () => StorageResource,
34
+ TransfersResource: () => TransfersResource
34
35
  });
35
36
  module.exports = __toCommonJS(index_exports);
36
37
 
@@ -425,7 +426,7 @@ var StorageResource = class {
425
426
  }
426
427
  /**
427
428
  * Store ender storage data (requires authentication)
428
- * @param data - Any JSON object to store
429
+ * @param data - Ender storage payload to store
429
430
  * @param token - Ender Storage API token
430
431
  * @returns Success message and timestamp
431
432
  * @throws KrawletError with BAD_REQUEST if data is invalid
@@ -464,11 +465,14 @@ var ReportsResource = class {
464
465
  * @returns Validation failure records
465
466
  */
466
467
  async getValidationFailures(options) {
467
- const response = await this.client.request("/v1/reports/validation-failures", {
468
- params: {
469
- limit: options?.limit || 50
468
+ const response = await this.client.request(
469
+ "/v1/reports/validation-failures",
470
+ {
471
+ params: {
472
+ limit: options?.limit || 50
473
+ }
470
474
  }
471
- });
475
+ );
472
476
  return response.data;
473
477
  }
474
478
  /**
@@ -478,11 +482,14 @@ var ReportsResource = class {
478
482
  * @returns Successful post records
479
483
  */
480
484
  async getSuccessfulPosts(options) {
481
- const response = await this.client.request("/v1/reports/successful-posts", {
482
- params: {
483
- limit: options?.limit || 50
485
+ const response = await this.client.request(
486
+ "/v1/reports/successful-posts",
487
+ {
488
+ params: {
489
+ limit: options?.limit || 50
490
+ }
484
491
  }
485
- });
492
+ );
486
493
  return response.data;
487
494
  }
488
495
  /**
@@ -493,12 +500,18 @@ var ReportsResource = class {
493
500
  * @returns Shop change event records
494
501
  */
495
502
  async getShopChanges(options) {
496
- const response = await this.client.request("/v1/reports/shop-changes", {
497
- params: {
498
- limit: options?.limit || 50,
499
- shopId: options?.shopId
503
+ const response = await this.client.request(
504
+ "/v1/reports/shop-changes",
505
+ {
506
+ params: {
507
+ limit: options?.limit || 50,
508
+ shopId: options?.shopId,
509
+ since: options?.since,
510
+ until: options?.until,
511
+ source: options?.source
512
+ }
500
513
  }
501
- });
514
+ );
502
515
  return response.data;
503
516
  }
504
517
  /**
@@ -509,12 +522,19 @@ var ReportsResource = class {
509
522
  * @returns Item change event records
510
523
  */
511
524
  async getItemChanges(options) {
512
- const response = await this.client.request("/v1/reports/item-changes", {
513
- params: {
514
- limit: options?.limit || 50,
515
- shopId: options?.shopId
525
+ const response = await this.client.request(
526
+ "/v1/reports/item-changes",
527
+ {
528
+ params: {
529
+ limit: options?.limit || 50,
530
+ shopId: options?.shopId,
531
+ changeType: options?.changeType,
532
+ since: options?.since,
533
+ until: options?.until,
534
+ source: options?.source
535
+ }
516
536
  }
517
- });
537
+ );
518
538
  return response.data;
519
539
  }
520
540
  /**
@@ -523,15 +543,18 @@ var ReportsResource = class {
523
543
  * @returns Response containing count (number of logs in this response), total (total logs matching query), and logs (array of ShopChangeLog)
524
544
  */
525
545
  async getShopChangeLogs(options) {
526
- const response = await this.client.request("/v1/reports/shop-change-logs", {
527
- params: {
528
- limit: options?.limit,
529
- offset: options?.offset,
530
- shopId: options?.shopId,
531
- since: options?.since,
532
- until: options?.until
546
+ const response = await this.client.request(
547
+ "/v1/reports/shop-change-logs",
548
+ {
549
+ params: {
550
+ limit: options?.limit,
551
+ offset: options?.offset,
552
+ shopId: options?.shopId,
553
+ since: options?.since,
554
+ until: options?.until
555
+ }
533
556
  }
534
- });
557
+ );
535
558
  return response.data;
536
559
  }
537
560
  /**
@@ -540,15 +563,18 @@ var ReportsResource = class {
540
563
  * @returns Response containing count (number of logs in this response), total (total logs matching query), and logs (array of ItemChangeLog)
541
564
  */
542
565
  async getItemChangeLogs(options) {
543
- const response = await this.client.request("/v1/reports/item-change-logs", {
544
- params: {
545
- limit: options?.limit,
546
- offset: options?.offset,
547
- shopId: options?.shopId,
548
- since: options?.since,
549
- until: options?.until
566
+ const response = await this.client.request(
567
+ "/v1/reports/item-change-logs",
568
+ {
569
+ params: {
570
+ limit: options?.limit,
571
+ offset: options?.offset,
572
+ shopId: options?.shopId,
573
+ since: options?.since,
574
+ until: options?.until
575
+ }
550
576
  }
551
- });
577
+ );
552
578
  return response.data;
553
579
  }
554
580
  /**
@@ -557,15 +583,18 @@ var ReportsResource = class {
557
583
  * @returns Response containing count (number of logs in this response), total (total logs matching query), and logs (array of PriceChangeLog)
558
584
  */
559
585
  async getPriceChangeLogs(options) {
560
- const response = await this.client.request("/v1/reports/price-change-logs", {
561
- params: {
562
- limit: options?.limit,
563
- offset: options?.offset,
564
- shopId: options?.shopId,
565
- since: options?.since,
566
- until: options?.until
586
+ const response = await this.client.request(
587
+ "/v1/reports/price-change-logs",
588
+ {
589
+ params: {
590
+ limit: options?.limit,
591
+ offset: options?.offset,
592
+ shopId: options?.shopId,
593
+ since: options?.since,
594
+ until: options?.until
595
+ }
567
596
  }
568
- });
597
+ );
569
598
  return response.data;
570
599
  }
571
600
  /**
@@ -721,6 +750,84 @@ var ApiKeyResource = class {
721
750
  }
722
751
  };
723
752
 
753
+ // src/resources/transfers.ts
754
+ var TransfersResource = class {
755
+ constructor(client) {
756
+ this.client = client;
757
+ }
758
+ /**
759
+ * List all transfers where the authenticated player is sender or recipient
760
+ * @returns Array of transfer records
761
+ */
762
+ async getAll() {
763
+ const response = await this.client.request("/v1/transfers");
764
+ return response.data;
765
+ }
766
+ /**
767
+ * Queue a new transfer request
768
+ * @param data - Transfer request payload
769
+ * @returns Transfer record
770
+ */
771
+ async create(data) {
772
+ const response = await this.client.request("/v1/transfers", {
773
+ method: "POST",
774
+ body: data
775
+ });
776
+ return response.data;
777
+ }
778
+ /**
779
+ * Retrieve transfer details by ID
780
+ * @param transferId - Transfer UUID
781
+ * @returns Transfer record
782
+ */
783
+ async get(transferId) {
784
+ const response = await this.client.request(`/v1/transfers/${transferId}`);
785
+ return response.data;
786
+ }
787
+ /**
788
+ * Cancel a pending or in-progress transfer
789
+ * @param transferId - Transfer UUID
790
+ * @returns Updated transfer record
791
+ */
792
+ async cancel(transferId) {
793
+ const response = await this.client.request(`/v1/transfers/${transferId}/cancel`, {
794
+ method: "POST"
795
+ });
796
+ return response.data;
797
+ }
798
+ /**
799
+ * Get current ender storage contents for the authenticated player
800
+ * @returns Contents snapshot
801
+ */
802
+ async getContents() {
803
+ const response = await this.client.request("/v1/transfers/contents");
804
+ return response.data;
805
+ }
806
+ /**
807
+ * List active transfer targets available to the authenticated user
808
+ * @returns Array of transfer targets
809
+ */
810
+ async getTargets() {
811
+ const response = await this.client.request("/v1/transfers/targets");
812
+ return response.data;
813
+ }
814
+ /**
815
+ * Request transfer from public/service storage into the authenticated player's storage
816
+ * @param data - Public storage transfer payload
817
+ * @returns Transfer and resolved source entity information
818
+ */
819
+ async requestPublicStorage(data) {
820
+ const response = await this.client.request(
821
+ "/v1/requests/public-storage",
822
+ {
823
+ method: "POST",
824
+ body: data
825
+ }
826
+ );
827
+ return response.data;
828
+ }
829
+ };
830
+
724
831
  // src/client.ts
725
832
  var KrawletClient = class {
726
833
  /**
@@ -746,6 +853,7 @@ var KrawletClient = class {
746
853
  this.storage = new StorageResource(this.httpClient);
747
854
  this.reports = new ReportsResource(this.httpClient);
748
855
  this.apiKey = new ApiKeyResource(this.httpClient);
856
+ this.transfers = new TransfersResource(this.httpClient);
749
857
  }
750
858
  /**
751
859
  * Get the last known rate limit information
@@ -785,5 +893,6 @@ var ErrorCode = /* @__PURE__ */ ((ErrorCode2) => {
785
893
  PlayersResource,
786
894
  ReportsResource,
787
895
  ShopsResource,
788
- StorageResource
896
+ StorageResource,
897
+ TransfersResource
789
898
  });
package/dist/index.d.cts CHANGED
@@ -113,6 +113,66 @@ interface PriceChangeLog {
113
113
  createdAt: string;
114
114
  updatedAt: string;
115
115
  }
116
+ interface ShopChangeField {
117
+ field: string;
118
+ previousValue: unknown;
119
+ newValue: unknown;
120
+ }
121
+ interface ReporterStats {
122
+ validationFailures: number;
123
+ successfulPosts: number;
124
+ shopChanges: number;
125
+ itemChanges: number;
126
+ oldestRecord: string | null;
127
+ newestRecord: string | null;
128
+ persistent: {
129
+ shopChanges: number;
130
+ itemChanges: number;
131
+ priceChanges: number;
132
+ total: number;
133
+ };
134
+ }
135
+ interface ValidationFailureRecord {
136
+ id: string;
137
+ timestamp: string;
138
+ rawData: unknown;
139
+ errors: string[];
140
+ shopName?: string;
141
+ computerId?: number;
142
+ }
143
+ interface SuccessfulPostRecord {
144
+ id: string;
145
+ timestamp: string;
146
+ shopId: string;
147
+ shopName: string;
148
+ rawData: ShopSyncData;
149
+ itemCount: number;
150
+ }
151
+ interface ShopChangeRecord {
152
+ id: string;
153
+ timestamp: string;
154
+ shopId: string;
155
+ shopName: string;
156
+ changes: ShopChangeField[];
157
+ isNewShop: boolean;
158
+ }
159
+ interface ItemSummary {
160
+ name: string;
161
+ displayName: string;
162
+ hash: string;
163
+ }
164
+ interface ItemUpdateSummary extends ItemSummary {
165
+ changes: ShopChangeField[];
166
+ }
167
+ interface ItemChangeRecord {
168
+ id: string;
169
+ timestamp: string;
170
+ shopId: string;
171
+ shopName: string;
172
+ added: ItemSummary[];
173
+ removed: ItemSummary[];
174
+ updated: ItemUpdateSummary[];
175
+ }
116
176
  interface ShopSyncData {
117
177
  sourceType?: ShopSourceType;
118
178
  info: {
@@ -290,34 +350,123 @@ interface DetailedHealthResponse {
290
350
  };
291
351
  services: HealthServicesDetailed;
292
352
  }
353
+ type EnderStorageColor = {
354
+ name: string;
355
+ color: number;
356
+ };
357
+ type EnderStorageItem = {
358
+ name: string;
359
+ displayName: string;
360
+ rawName: string;
361
+ maxCount: number;
362
+ count: number;
363
+ mapColor?: number;
364
+ mapColour?: number;
365
+ itemGroups: Record<string, unknown>;
366
+ tags: Record<string, unknown>;
367
+ [key: string]: unknown;
368
+ };
369
+ type EnderStorageChest = {
370
+ colors: EnderStorageColor[];
371
+ contents: Record<string, EnderStorageItem>;
372
+ name?: string;
373
+ description?: string;
374
+ displayName?: string;
375
+ [key: string]: unknown;
376
+ };
377
+ type EnderStorageCollection = {
378
+ data: EnderStorageChest[];
379
+ retrievedAt: string;
380
+ };
381
+ type EnderStorageMeta = {
382
+ timestamp: string;
383
+ elapsed: number;
384
+ version: string;
385
+ requestId: string;
386
+ [key: string]: unknown;
387
+ };
388
+ type EnderStorageApiPayload = {
389
+ success: boolean;
390
+ data: EnderStorageCollection;
391
+ meta?: EnderStorageMeta;
392
+ [key: string]: unknown;
393
+ };
394
+ type EnderStoragePayload = EnderStorageApiPayload | EnderStorageChest[];
293
395
  interface StorageData {
294
- data: unknown;
396
+ data: EnderStorageChest[];
295
397
  retrievedAt: string;
296
398
  }
297
- interface ReportRecords {
399
+ interface StorageSlotItem {
400
+ name: string;
298
401
  count: number;
299
- records: unknown[];
402
+ nbt?: string | null;
300
403
  }
301
- interface ChangeLogResult {
302
- count: number;
303
- total: number;
304
- logs: unknown[];
404
+ interface StorageSlotContents {
405
+ items: StorageSlotItem[];
305
406
  }
306
- interface ShopChangeLogResponse {
307
- count: number;
308
- total: number;
309
- logs: ShopChangeLog[];
407
+ interface TransferTargetLink {
408
+ type: string;
409
+ value: string;
310
410
  }
311
- interface ItemChangeLogResponse {
411
+ interface TransferTarget {
412
+ id: string;
413
+ name: string;
414
+ type: string;
415
+ links: TransferTargetLink[];
416
+ }
417
+ type TransferStatus = 'pending' | 'in_progress' | 'completed' | 'failed' | 'cancelled';
418
+ interface Transfer {
419
+ id: string;
420
+ status: TransferStatus;
421
+ error: string | null;
422
+ workerId?: number | null;
423
+ fromUUID: string;
424
+ fromUsername: string;
425
+ toUUID: string;
426
+ toUsername: string;
427
+ itemName: string | null;
428
+ itemNbt: string | null;
429
+ quantity: number | null;
430
+ quantityTransferred: number;
431
+ timestamp: string;
432
+ }
433
+ interface TransferCreateRequest {
434
+ to: string;
435
+ itemName?: string;
436
+ itemNbt?: string;
437
+ quantity?: number;
438
+ timeout?: number;
439
+ }
440
+ interface PublicStorageSourceEntity {
441
+ id: string;
442
+ name: string;
443
+ type: string;
444
+ alias?: string;
445
+ }
446
+ interface PublicStorageTransferRequest {
447
+ itemName: string;
448
+ itemNbt?: string;
449
+ quantity: number;
450
+ timeout?: number;
451
+ source?: string;
452
+ colors?: [number, number, number];
453
+ }
454
+ interface PublicStorageTransferResponse {
455
+ transfer: Transfer;
456
+ sourceEntity: PublicStorageSourceEntity;
457
+ }
458
+ interface ReportRecords<TRecord = unknown> {
312
459
  count: number;
313
- total: number;
314
- logs: ItemChangeLog[];
460
+ records: TRecord[];
315
461
  }
316
- interface PriceChangeLogResponse {
462
+ interface ChangeLogResult<TLog = unknown> {
317
463
  count: number;
318
464
  total: number;
319
- logs: PriceChangeLog[];
465
+ logs: TLog[];
320
466
  }
467
+ type ShopChangeLogResponse = ChangeLogResult<ShopChangeLog>;
468
+ type ItemChangeLogResponse = ChangeLogResult<ItemChangeLog>;
469
+ type PriceChangeLogResponse = ChangeLogResult<PriceChangeLog>;
321
470
  interface ChangeLogOptions {
322
471
  limit?: number;
323
472
  offset?: number;
@@ -325,6 +474,29 @@ interface ChangeLogOptions {
325
474
  since?: string;
326
475
  until?: string;
327
476
  }
477
+ interface BaseQueryParams {
478
+ limit?: number;
479
+ offset?: number;
480
+ }
481
+ interface ShopChangesParams extends BaseQueryParams {
482
+ shopId?: string;
483
+ since?: string;
484
+ until?: string;
485
+ source?: 'memory' | 'persistent' | 'both';
486
+ }
487
+ interface ItemChangesParams extends BaseQueryParams {
488
+ shopId?: string;
489
+ changeType?: 'added' | 'removed';
490
+ since?: string;
491
+ until?: string;
492
+ source?: 'memory' | 'persistent' | 'both';
493
+ }
494
+ interface PriceChangesParams extends BaseQueryParams {
495
+ shopId?: string;
496
+ itemHash?: string;
497
+ since?: string;
498
+ until?: string;
499
+ }
328
500
 
329
501
  interface HttpClientConfig {
330
502
  baseUrl: string;
@@ -405,7 +577,7 @@ declare class StorageResource {
405
577
  private client;
406
578
  constructor(client: HttpClient);
407
579
  get(): Promise<StorageData>;
408
- set(data: unknown, token: string): Promise<{
580
+ set(data: EnderStoragePayload, token: string): Promise<{
409
581
  message: string;
410
582
  timestamp: string;
411
583
  }>;
@@ -414,21 +586,15 @@ declare class StorageResource {
414
586
  declare class ReportsResource {
415
587
  private client;
416
588
  constructor(client: HttpClient);
417
- getStats(): Promise<unknown>;
589
+ getStats(): Promise<ReporterStats>;
418
590
  getValidationFailures(options?: {
419
591
  limit?: number;
420
- }): Promise<ReportRecords>;
592
+ }): Promise<ReportRecords<ValidationFailureRecord>>;
421
593
  getSuccessfulPosts(options?: {
422
594
  limit?: number;
423
- }): Promise<ReportRecords>;
424
- getShopChanges(options?: {
425
- limit?: number;
426
- shopId?: string;
427
- }): Promise<ReportRecords>;
428
- getItemChanges(options?: {
429
- limit?: number;
430
- shopId?: string;
431
- }): Promise<ReportRecords>;
595
+ }): Promise<ReportRecords<SuccessfulPostRecord>>;
596
+ getShopChanges(options?: ShopChangesParams): Promise<ReportRecords<ShopChangeRecord>>;
597
+ getItemChanges(options?: ItemChangesParams): Promise<ReportRecords<ItemChangeRecord>>;
432
598
  getShopChangeLogs(options?: ChangeLogOptions): Promise<ShopChangeLogResponse>;
433
599
  getItemChangeLogs(options?: ChangeLogOptions): Promise<ItemChangeLogResponse>;
434
600
  getPriceChangeLogs(options?: ChangeLogOptions): Promise<PriceChangeLogResponse>;
@@ -451,6 +617,18 @@ declare class ApiKeyResource {
451
617
  redeemQuickCode(code: string): Promise<QuickCodeRedeemResponse>;
452
618
  }
453
619
 
620
+ declare class TransfersResource {
621
+ private client;
622
+ constructor(client: HttpClient);
623
+ getAll(): Promise<Transfer[]>;
624
+ create(data: TransferCreateRequest): Promise<Transfer>;
625
+ get(transferId: string): Promise<Transfer>;
626
+ cancel(transferId: string): Promise<Transfer>;
627
+ getContents(): Promise<StorageSlotContents>;
628
+ getTargets(): Promise<TransferTarget[]>;
629
+ requestPublicStorage(data: PublicStorageTransferRequest): Promise<PublicStorageTransferResponse>;
630
+ }
631
+
454
632
  interface KrawletClientConfig {
455
633
  baseUrl?: string;
456
634
  apiKey?: string;
@@ -470,6 +648,7 @@ declare class KrawletClient {
470
648
  readonly storage: StorageResource;
471
649
  readonly reports: ReportsResource;
472
650
  readonly apiKey: ApiKeyResource;
651
+ readonly transfers: TransfersResource;
473
652
  constructor(config?: KrawletClientConfig);
474
653
  getRateLimit(): RateLimit | undefined;
475
654
  }
@@ -486,4 +665,4 @@ declare class KrawletError extends Error {
486
665
  isRateLimitError(): boolean;
487
666
  }
488
667
 
489
- export { AddressesResource, type ApiKeyInfo, ApiKeyResource, type ApiKeyTier, type ApiKeyUsage, type ApiResponse, type ApiResponseMeta, type ChangeLogOptions, type ChangeLogResult, type ChatboxServiceInfo, type DetailedHealthResponse, type DiscordServiceInfo, ErrorCode, type ErrorResponse, type HealthChecks, HealthResource, type HealthResponse, type HealthServices, type HealthServicesDetailed, type Item, type ItemChangeLog, type ItemChangeLogResponse, type ItemChangeType, ItemsResource, type KnownAddress, type KnownAddressType, KrawletClient, type KrawletClientConfig, KrawletError, type KromerServiceInfo, type Player, type PlayerNotifications, PlayersResource, type Price, type PriceChangeLog, type PriceChangeLogResponse, type QuickCodeGenerateResponse, type QuickCodeRedeemResponse, type RateLimit, type ReportRecords, ReportsResource, type RequestLog, type RequestLogsResponse, type ServiceInfo, type ServiceName, type ServiceStatus, type Shop, type ShopChangeLog, type ShopChangeLogResponse, type ShopSourceType, type ShopSyncData, ShopsResource, type StorageData, StorageResource };
668
+ export { AddressesResource, type ApiKeyInfo, ApiKeyResource, type ApiKeyTier, type ApiKeyUsage, type ApiResponse, type ApiResponseMeta, type BaseQueryParams, type ChangeLogOptions, type ChangeLogResult, type ChatboxServiceInfo, type DetailedHealthResponse, type DiscordServiceInfo, type EnderStorageApiPayload, type EnderStorageChest, type EnderStorageCollection, type EnderStorageColor, type EnderStorageItem, type EnderStorageMeta, type EnderStoragePayload, ErrorCode, type ErrorResponse, type HealthChecks, HealthResource, type HealthResponse, type HealthServices, type HealthServicesDetailed, type Item, type ItemChangeLog, type ItemChangeLogResponse, type ItemChangeRecord, type ItemChangeType, type ItemChangesParams, type ItemSummary, type ItemUpdateSummary, ItemsResource, type KnownAddress, type KnownAddressType, KrawletClient, type KrawletClientConfig, KrawletError, type KromerServiceInfo, type Player, type PlayerNotifications, PlayersResource, type Price, type PriceChangeLog, type PriceChangeLogResponse, type PriceChangesParams, type PublicStorageSourceEntity, type PublicStorageTransferRequest, type PublicStorageTransferResponse, type QuickCodeGenerateResponse, type QuickCodeRedeemResponse, type RateLimit, type ReportRecords, type ReporterStats, ReportsResource, type RequestLog, type RequestLogsResponse, type ServiceInfo, type ServiceName, type ServiceStatus, type Shop, type ShopChangeField, type ShopChangeLog, type ShopChangeLogResponse, type ShopChangeRecord, type ShopChangesParams, type ShopSourceType, type ShopSyncData, ShopsResource, type StorageData, StorageResource, type StorageSlotContents, type StorageSlotItem, type SuccessfulPostRecord, type Transfer, type TransferCreateRequest, type TransferStatus, type TransferTarget, type TransferTargetLink, TransfersResource, type ValidationFailureRecord };
package/dist/index.d.ts CHANGED
@@ -113,6 +113,66 @@ interface PriceChangeLog {
113
113
  createdAt: string;
114
114
  updatedAt: string;
115
115
  }
116
+ interface ShopChangeField {
117
+ field: string;
118
+ previousValue: unknown;
119
+ newValue: unknown;
120
+ }
121
+ interface ReporterStats {
122
+ validationFailures: number;
123
+ successfulPosts: number;
124
+ shopChanges: number;
125
+ itemChanges: number;
126
+ oldestRecord: string | null;
127
+ newestRecord: string | null;
128
+ persistent: {
129
+ shopChanges: number;
130
+ itemChanges: number;
131
+ priceChanges: number;
132
+ total: number;
133
+ };
134
+ }
135
+ interface ValidationFailureRecord {
136
+ id: string;
137
+ timestamp: string;
138
+ rawData: unknown;
139
+ errors: string[];
140
+ shopName?: string;
141
+ computerId?: number;
142
+ }
143
+ interface SuccessfulPostRecord {
144
+ id: string;
145
+ timestamp: string;
146
+ shopId: string;
147
+ shopName: string;
148
+ rawData: ShopSyncData;
149
+ itemCount: number;
150
+ }
151
+ interface ShopChangeRecord {
152
+ id: string;
153
+ timestamp: string;
154
+ shopId: string;
155
+ shopName: string;
156
+ changes: ShopChangeField[];
157
+ isNewShop: boolean;
158
+ }
159
+ interface ItemSummary {
160
+ name: string;
161
+ displayName: string;
162
+ hash: string;
163
+ }
164
+ interface ItemUpdateSummary extends ItemSummary {
165
+ changes: ShopChangeField[];
166
+ }
167
+ interface ItemChangeRecord {
168
+ id: string;
169
+ timestamp: string;
170
+ shopId: string;
171
+ shopName: string;
172
+ added: ItemSummary[];
173
+ removed: ItemSummary[];
174
+ updated: ItemUpdateSummary[];
175
+ }
116
176
  interface ShopSyncData {
117
177
  sourceType?: ShopSourceType;
118
178
  info: {
@@ -290,34 +350,123 @@ interface DetailedHealthResponse {
290
350
  };
291
351
  services: HealthServicesDetailed;
292
352
  }
353
+ type EnderStorageColor = {
354
+ name: string;
355
+ color: number;
356
+ };
357
+ type EnderStorageItem = {
358
+ name: string;
359
+ displayName: string;
360
+ rawName: string;
361
+ maxCount: number;
362
+ count: number;
363
+ mapColor?: number;
364
+ mapColour?: number;
365
+ itemGroups: Record<string, unknown>;
366
+ tags: Record<string, unknown>;
367
+ [key: string]: unknown;
368
+ };
369
+ type EnderStorageChest = {
370
+ colors: EnderStorageColor[];
371
+ contents: Record<string, EnderStorageItem>;
372
+ name?: string;
373
+ description?: string;
374
+ displayName?: string;
375
+ [key: string]: unknown;
376
+ };
377
+ type EnderStorageCollection = {
378
+ data: EnderStorageChest[];
379
+ retrievedAt: string;
380
+ };
381
+ type EnderStorageMeta = {
382
+ timestamp: string;
383
+ elapsed: number;
384
+ version: string;
385
+ requestId: string;
386
+ [key: string]: unknown;
387
+ };
388
+ type EnderStorageApiPayload = {
389
+ success: boolean;
390
+ data: EnderStorageCollection;
391
+ meta?: EnderStorageMeta;
392
+ [key: string]: unknown;
393
+ };
394
+ type EnderStoragePayload = EnderStorageApiPayload | EnderStorageChest[];
293
395
  interface StorageData {
294
- data: unknown;
396
+ data: EnderStorageChest[];
295
397
  retrievedAt: string;
296
398
  }
297
- interface ReportRecords {
399
+ interface StorageSlotItem {
400
+ name: string;
298
401
  count: number;
299
- records: unknown[];
402
+ nbt?: string | null;
300
403
  }
301
- interface ChangeLogResult {
302
- count: number;
303
- total: number;
304
- logs: unknown[];
404
+ interface StorageSlotContents {
405
+ items: StorageSlotItem[];
305
406
  }
306
- interface ShopChangeLogResponse {
307
- count: number;
308
- total: number;
309
- logs: ShopChangeLog[];
407
+ interface TransferTargetLink {
408
+ type: string;
409
+ value: string;
310
410
  }
311
- interface ItemChangeLogResponse {
411
+ interface TransferTarget {
412
+ id: string;
413
+ name: string;
414
+ type: string;
415
+ links: TransferTargetLink[];
416
+ }
417
+ type TransferStatus = 'pending' | 'in_progress' | 'completed' | 'failed' | 'cancelled';
418
+ interface Transfer {
419
+ id: string;
420
+ status: TransferStatus;
421
+ error: string | null;
422
+ workerId?: number | null;
423
+ fromUUID: string;
424
+ fromUsername: string;
425
+ toUUID: string;
426
+ toUsername: string;
427
+ itemName: string | null;
428
+ itemNbt: string | null;
429
+ quantity: number | null;
430
+ quantityTransferred: number;
431
+ timestamp: string;
432
+ }
433
+ interface TransferCreateRequest {
434
+ to: string;
435
+ itemName?: string;
436
+ itemNbt?: string;
437
+ quantity?: number;
438
+ timeout?: number;
439
+ }
440
+ interface PublicStorageSourceEntity {
441
+ id: string;
442
+ name: string;
443
+ type: string;
444
+ alias?: string;
445
+ }
446
+ interface PublicStorageTransferRequest {
447
+ itemName: string;
448
+ itemNbt?: string;
449
+ quantity: number;
450
+ timeout?: number;
451
+ source?: string;
452
+ colors?: [number, number, number];
453
+ }
454
+ interface PublicStorageTransferResponse {
455
+ transfer: Transfer;
456
+ sourceEntity: PublicStorageSourceEntity;
457
+ }
458
+ interface ReportRecords<TRecord = unknown> {
312
459
  count: number;
313
- total: number;
314
- logs: ItemChangeLog[];
460
+ records: TRecord[];
315
461
  }
316
- interface PriceChangeLogResponse {
462
+ interface ChangeLogResult<TLog = unknown> {
317
463
  count: number;
318
464
  total: number;
319
- logs: PriceChangeLog[];
465
+ logs: TLog[];
320
466
  }
467
+ type ShopChangeLogResponse = ChangeLogResult<ShopChangeLog>;
468
+ type ItemChangeLogResponse = ChangeLogResult<ItemChangeLog>;
469
+ type PriceChangeLogResponse = ChangeLogResult<PriceChangeLog>;
321
470
  interface ChangeLogOptions {
322
471
  limit?: number;
323
472
  offset?: number;
@@ -325,6 +474,29 @@ interface ChangeLogOptions {
325
474
  since?: string;
326
475
  until?: string;
327
476
  }
477
+ interface BaseQueryParams {
478
+ limit?: number;
479
+ offset?: number;
480
+ }
481
+ interface ShopChangesParams extends BaseQueryParams {
482
+ shopId?: string;
483
+ since?: string;
484
+ until?: string;
485
+ source?: 'memory' | 'persistent' | 'both';
486
+ }
487
+ interface ItemChangesParams extends BaseQueryParams {
488
+ shopId?: string;
489
+ changeType?: 'added' | 'removed';
490
+ since?: string;
491
+ until?: string;
492
+ source?: 'memory' | 'persistent' | 'both';
493
+ }
494
+ interface PriceChangesParams extends BaseQueryParams {
495
+ shopId?: string;
496
+ itemHash?: string;
497
+ since?: string;
498
+ until?: string;
499
+ }
328
500
 
329
501
  interface HttpClientConfig {
330
502
  baseUrl: string;
@@ -405,7 +577,7 @@ declare class StorageResource {
405
577
  private client;
406
578
  constructor(client: HttpClient);
407
579
  get(): Promise<StorageData>;
408
- set(data: unknown, token: string): Promise<{
580
+ set(data: EnderStoragePayload, token: string): Promise<{
409
581
  message: string;
410
582
  timestamp: string;
411
583
  }>;
@@ -414,21 +586,15 @@ declare class StorageResource {
414
586
  declare class ReportsResource {
415
587
  private client;
416
588
  constructor(client: HttpClient);
417
- getStats(): Promise<unknown>;
589
+ getStats(): Promise<ReporterStats>;
418
590
  getValidationFailures(options?: {
419
591
  limit?: number;
420
- }): Promise<ReportRecords>;
592
+ }): Promise<ReportRecords<ValidationFailureRecord>>;
421
593
  getSuccessfulPosts(options?: {
422
594
  limit?: number;
423
- }): Promise<ReportRecords>;
424
- getShopChanges(options?: {
425
- limit?: number;
426
- shopId?: string;
427
- }): Promise<ReportRecords>;
428
- getItemChanges(options?: {
429
- limit?: number;
430
- shopId?: string;
431
- }): Promise<ReportRecords>;
595
+ }): Promise<ReportRecords<SuccessfulPostRecord>>;
596
+ getShopChanges(options?: ShopChangesParams): Promise<ReportRecords<ShopChangeRecord>>;
597
+ getItemChanges(options?: ItemChangesParams): Promise<ReportRecords<ItemChangeRecord>>;
432
598
  getShopChangeLogs(options?: ChangeLogOptions): Promise<ShopChangeLogResponse>;
433
599
  getItemChangeLogs(options?: ChangeLogOptions): Promise<ItemChangeLogResponse>;
434
600
  getPriceChangeLogs(options?: ChangeLogOptions): Promise<PriceChangeLogResponse>;
@@ -451,6 +617,18 @@ declare class ApiKeyResource {
451
617
  redeemQuickCode(code: string): Promise<QuickCodeRedeemResponse>;
452
618
  }
453
619
 
620
+ declare class TransfersResource {
621
+ private client;
622
+ constructor(client: HttpClient);
623
+ getAll(): Promise<Transfer[]>;
624
+ create(data: TransferCreateRequest): Promise<Transfer>;
625
+ get(transferId: string): Promise<Transfer>;
626
+ cancel(transferId: string): Promise<Transfer>;
627
+ getContents(): Promise<StorageSlotContents>;
628
+ getTargets(): Promise<TransferTarget[]>;
629
+ requestPublicStorage(data: PublicStorageTransferRequest): Promise<PublicStorageTransferResponse>;
630
+ }
631
+
454
632
  interface KrawletClientConfig {
455
633
  baseUrl?: string;
456
634
  apiKey?: string;
@@ -470,6 +648,7 @@ declare class KrawletClient {
470
648
  readonly storage: StorageResource;
471
649
  readonly reports: ReportsResource;
472
650
  readonly apiKey: ApiKeyResource;
651
+ readonly transfers: TransfersResource;
473
652
  constructor(config?: KrawletClientConfig);
474
653
  getRateLimit(): RateLimit | undefined;
475
654
  }
@@ -486,4 +665,4 @@ declare class KrawletError extends Error {
486
665
  isRateLimitError(): boolean;
487
666
  }
488
667
 
489
- export { AddressesResource, type ApiKeyInfo, ApiKeyResource, type ApiKeyTier, type ApiKeyUsage, type ApiResponse, type ApiResponseMeta, type ChangeLogOptions, type ChangeLogResult, type ChatboxServiceInfo, type DetailedHealthResponse, type DiscordServiceInfo, ErrorCode, type ErrorResponse, type HealthChecks, HealthResource, type HealthResponse, type HealthServices, type HealthServicesDetailed, type Item, type ItemChangeLog, type ItemChangeLogResponse, type ItemChangeType, ItemsResource, type KnownAddress, type KnownAddressType, KrawletClient, type KrawletClientConfig, KrawletError, type KromerServiceInfo, type Player, type PlayerNotifications, PlayersResource, type Price, type PriceChangeLog, type PriceChangeLogResponse, type QuickCodeGenerateResponse, type QuickCodeRedeemResponse, type RateLimit, type ReportRecords, ReportsResource, type RequestLog, type RequestLogsResponse, type ServiceInfo, type ServiceName, type ServiceStatus, type Shop, type ShopChangeLog, type ShopChangeLogResponse, type ShopSourceType, type ShopSyncData, ShopsResource, type StorageData, StorageResource };
668
+ export { AddressesResource, type ApiKeyInfo, ApiKeyResource, type ApiKeyTier, type ApiKeyUsage, type ApiResponse, type ApiResponseMeta, type BaseQueryParams, type ChangeLogOptions, type ChangeLogResult, type ChatboxServiceInfo, type DetailedHealthResponse, type DiscordServiceInfo, type EnderStorageApiPayload, type EnderStorageChest, type EnderStorageCollection, type EnderStorageColor, type EnderStorageItem, type EnderStorageMeta, type EnderStoragePayload, ErrorCode, type ErrorResponse, type HealthChecks, HealthResource, type HealthResponse, type HealthServices, type HealthServicesDetailed, type Item, type ItemChangeLog, type ItemChangeLogResponse, type ItemChangeRecord, type ItemChangeType, type ItemChangesParams, type ItemSummary, type ItemUpdateSummary, ItemsResource, type KnownAddress, type KnownAddressType, KrawletClient, type KrawletClientConfig, KrawletError, type KromerServiceInfo, type Player, type PlayerNotifications, PlayersResource, type Price, type PriceChangeLog, type PriceChangeLogResponse, type PriceChangesParams, type PublicStorageSourceEntity, type PublicStorageTransferRequest, type PublicStorageTransferResponse, type QuickCodeGenerateResponse, type QuickCodeRedeemResponse, type RateLimit, type ReportRecords, type ReporterStats, ReportsResource, type RequestLog, type RequestLogsResponse, type ServiceInfo, type ServiceName, type ServiceStatus, type Shop, type ShopChangeField, type ShopChangeLog, type ShopChangeLogResponse, type ShopChangeRecord, type ShopChangesParams, type ShopSourceType, type ShopSyncData, ShopsResource, type StorageData, StorageResource, type StorageSlotContents, type StorageSlotItem, type SuccessfulPostRecord, type Transfer, type TransferCreateRequest, type TransferStatus, type TransferTarget, type TransferTargetLink, TransfersResource, type ValidationFailureRecord };
package/dist/index.js CHANGED
@@ -389,7 +389,7 @@ var StorageResource = class {
389
389
  }
390
390
  /**
391
391
  * Store ender storage data (requires authentication)
392
- * @param data - Any JSON object to store
392
+ * @param data - Ender storage payload to store
393
393
  * @param token - Ender Storage API token
394
394
  * @returns Success message and timestamp
395
395
  * @throws KrawletError with BAD_REQUEST if data is invalid
@@ -428,11 +428,14 @@ var ReportsResource = class {
428
428
  * @returns Validation failure records
429
429
  */
430
430
  async getValidationFailures(options) {
431
- const response = await this.client.request("/v1/reports/validation-failures", {
432
- params: {
433
- limit: options?.limit || 50
431
+ const response = await this.client.request(
432
+ "/v1/reports/validation-failures",
433
+ {
434
+ params: {
435
+ limit: options?.limit || 50
436
+ }
434
437
  }
435
- });
438
+ );
436
439
  return response.data;
437
440
  }
438
441
  /**
@@ -442,11 +445,14 @@ var ReportsResource = class {
442
445
  * @returns Successful post records
443
446
  */
444
447
  async getSuccessfulPosts(options) {
445
- const response = await this.client.request("/v1/reports/successful-posts", {
446
- params: {
447
- limit: options?.limit || 50
448
+ const response = await this.client.request(
449
+ "/v1/reports/successful-posts",
450
+ {
451
+ params: {
452
+ limit: options?.limit || 50
453
+ }
448
454
  }
449
- });
455
+ );
450
456
  return response.data;
451
457
  }
452
458
  /**
@@ -457,12 +463,18 @@ var ReportsResource = class {
457
463
  * @returns Shop change event records
458
464
  */
459
465
  async getShopChanges(options) {
460
- const response = await this.client.request("/v1/reports/shop-changes", {
461
- params: {
462
- limit: options?.limit || 50,
463
- shopId: options?.shopId
466
+ const response = await this.client.request(
467
+ "/v1/reports/shop-changes",
468
+ {
469
+ params: {
470
+ limit: options?.limit || 50,
471
+ shopId: options?.shopId,
472
+ since: options?.since,
473
+ until: options?.until,
474
+ source: options?.source
475
+ }
464
476
  }
465
- });
477
+ );
466
478
  return response.data;
467
479
  }
468
480
  /**
@@ -473,12 +485,19 @@ var ReportsResource = class {
473
485
  * @returns Item change event records
474
486
  */
475
487
  async getItemChanges(options) {
476
- const response = await this.client.request("/v1/reports/item-changes", {
477
- params: {
478
- limit: options?.limit || 50,
479
- shopId: options?.shopId
488
+ const response = await this.client.request(
489
+ "/v1/reports/item-changes",
490
+ {
491
+ params: {
492
+ limit: options?.limit || 50,
493
+ shopId: options?.shopId,
494
+ changeType: options?.changeType,
495
+ since: options?.since,
496
+ until: options?.until,
497
+ source: options?.source
498
+ }
480
499
  }
481
- });
500
+ );
482
501
  return response.data;
483
502
  }
484
503
  /**
@@ -487,15 +506,18 @@ var ReportsResource = class {
487
506
  * @returns Response containing count (number of logs in this response), total (total logs matching query), and logs (array of ShopChangeLog)
488
507
  */
489
508
  async getShopChangeLogs(options) {
490
- const response = await this.client.request("/v1/reports/shop-change-logs", {
491
- params: {
492
- limit: options?.limit,
493
- offset: options?.offset,
494
- shopId: options?.shopId,
495
- since: options?.since,
496
- until: options?.until
509
+ const response = await this.client.request(
510
+ "/v1/reports/shop-change-logs",
511
+ {
512
+ params: {
513
+ limit: options?.limit,
514
+ offset: options?.offset,
515
+ shopId: options?.shopId,
516
+ since: options?.since,
517
+ until: options?.until
518
+ }
497
519
  }
498
- });
520
+ );
499
521
  return response.data;
500
522
  }
501
523
  /**
@@ -504,15 +526,18 @@ var ReportsResource = class {
504
526
  * @returns Response containing count (number of logs in this response), total (total logs matching query), and logs (array of ItemChangeLog)
505
527
  */
506
528
  async getItemChangeLogs(options) {
507
- const response = await this.client.request("/v1/reports/item-change-logs", {
508
- params: {
509
- limit: options?.limit,
510
- offset: options?.offset,
511
- shopId: options?.shopId,
512
- since: options?.since,
513
- until: options?.until
529
+ const response = await this.client.request(
530
+ "/v1/reports/item-change-logs",
531
+ {
532
+ params: {
533
+ limit: options?.limit,
534
+ offset: options?.offset,
535
+ shopId: options?.shopId,
536
+ since: options?.since,
537
+ until: options?.until
538
+ }
514
539
  }
515
- });
540
+ );
516
541
  return response.data;
517
542
  }
518
543
  /**
@@ -521,15 +546,18 @@ var ReportsResource = class {
521
546
  * @returns Response containing count (number of logs in this response), total (total logs matching query), and logs (array of PriceChangeLog)
522
547
  */
523
548
  async getPriceChangeLogs(options) {
524
- const response = await this.client.request("/v1/reports/price-change-logs", {
525
- params: {
526
- limit: options?.limit,
527
- offset: options?.offset,
528
- shopId: options?.shopId,
529
- since: options?.since,
530
- until: options?.until
549
+ const response = await this.client.request(
550
+ "/v1/reports/price-change-logs",
551
+ {
552
+ params: {
553
+ limit: options?.limit,
554
+ offset: options?.offset,
555
+ shopId: options?.shopId,
556
+ since: options?.since,
557
+ until: options?.until
558
+ }
531
559
  }
532
- });
560
+ );
533
561
  return response.data;
534
562
  }
535
563
  /**
@@ -685,6 +713,84 @@ var ApiKeyResource = class {
685
713
  }
686
714
  };
687
715
 
716
+ // src/resources/transfers.ts
717
+ var TransfersResource = class {
718
+ constructor(client) {
719
+ this.client = client;
720
+ }
721
+ /**
722
+ * List all transfers where the authenticated player is sender or recipient
723
+ * @returns Array of transfer records
724
+ */
725
+ async getAll() {
726
+ const response = await this.client.request("/v1/transfers");
727
+ return response.data;
728
+ }
729
+ /**
730
+ * Queue a new transfer request
731
+ * @param data - Transfer request payload
732
+ * @returns Transfer record
733
+ */
734
+ async create(data) {
735
+ const response = await this.client.request("/v1/transfers", {
736
+ method: "POST",
737
+ body: data
738
+ });
739
+ return response.data;
740
+ }
741
+ /**
742
+ * Retrieve transfer details by ID
743
+ * @param transferId - Transfer UUID
744
+ * @returns Transfer record
745
+ */
746
+ async get(transferId) {
747
+ const response = await this.client.request(`/v1/transfers/${transferId}`);
748
+ return response.data;
749
+ }
750
+ /**
751
+ * Cancel a pending or in-progress transfer
752
+ * @param transferId - Transfer UUID
753
+ * @returns Updated transfer record
754
+ */
755
+ async cancel(transferId) {
756
+ const response = await this.client.request(`/v1/transfers/${transferId}/cancel`, {
757
+ method: "POST"
758
+ });
759
+ return response.data;
760
+ }
761
+ /**
762
+ * Get current ender storage contents for the authenticated player
763
+ * @returns Contents snapshot
764
+ */
765
+ async getContents() {
766
+ const response = await this.client.request("/v1/transfers/contents");
767
+ return response.data;
768
+ }
769
+ /**
770
+ * List active transfer targets available to the authenticated user
771
+ * @returns Array of transfer targets
772
+ */
773
+ async getTargets() {
774
+ const response = await this.client.request("/v1/transfers/targets");
775
+ return response.data;
776
+ }
777
+ /**
778
+ * Request transfer from public/service storage into the authenticated player's storage
779
+ * @param data - Public storage transfer payload
780
+ * @returns Transfer and resolved source entity information
781
+ */
782
+ async requestPublicStorage(data) {
783
+ const response = await this.client.request(
784
+ "/v1/requests/public-storage",
785
+ {
786
+ method: "POST",
787
+ body: data
788
+ }
789
+ );
790
+ return response.data;
791
+ }
792
+ };
793
+
688
794
  // src/client.ts
689
795
  var KrawletClient = class {
690
796
  /**
@@ -710,6 +816,7 @@ var KrawletClient = class {
710
816
  this.storage = new StorageResource(this.httpClient);
711
817
  this.reports = new ReportsResource(this.httpClient);
712
818
  this.apiKey = new ApiKeyResource(this.httpClient);
819
+ this.transfers = new TransfersResource(this.httpClient);
713
820
  }
714
821
  /**
715
822
  * Get the last known rate limit information
@@ -748,5 +855,6 @@ export {
748
855
  PlayersResource,
749
856
  ReportsResource,
750
857
  ShopsResource,
751
- StorageResource
858
+ StorageResource,
859
+ TransfersResource
752
860
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "krawlet-js",
3
- "version": "1.3.5",
3
+ "version": "2.1.0",
4
4
  "description": "TypeScript/JavaScript client library for the Krawlet Minecraft economy tracking API",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -31,14 +31,15 @@
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/node": "^22.10.5",
34
- "@typescript-eslint/eslint-plugin": "^8.20.0",
35
- "@typescript-eslint/parser": "^8.20.0",
36
- "@vitest/coverage-v8": "^2.1.8",
37
- "eslint": "^9.18.0",
34
+ "@typescript-eslint/eslint-plugin": "^8.58.1",
35
+ "@typescript-eslint/parser": "^8.58.1",
36
+ "@vitest/coverage-v8": "^4.1.4",
37
+ "eslint": "^9.39.4",
38
38
  "prettier": "^3.4.2",
39
- "tsup": "^8.3.5",
39
+ "tsup": "^8.5.1",
40
40
  "typescript": "^5.7.2",
41
- "vitest": "^2.1.8"
41
+ "vite": "^8.0.8",
42
+ "vitest": "^4.1.4"
42
43
  },
43
44
  "scripts": {
44
45
  "build": "tsup src/index.ts --format cjs,esm --dts --clean",