@workglow/storage 0.0.96 → 0.0.98

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.
Files changed (35) hide show
  1. package/dist/browser.js +396 -33
  2. package/dist/browser.js.map +11 -10
  3. package/dist/bun.js +470 -53
  4. package/dist/bun.js.map +15 -14
  5. package/dist/common.d.ts +1 -0
  6. package/dist/common.d.ts.map +1 -1
  7. package/dist/node.js +470 -53
  8. package/dist/node.js.map +15 -14
  9. package/dist/queue/PostgresQueueStorage.d.ts +1 -1
  10. package/dist/queue/PostgresQueueStorage.d.ts.map +1 -1
  11. package/dist/queue-limiter/PostgresRateLimiterStorage.d.ts +1 -1
  12. package/dist/queue-limiter/PostgresRateLimiterStorage.d.ts.map +1 -1
  13. package/dist/tabular/BaseTabularStorage.d.ts +21 -0
  14. package/dist/tabular/BaseTabularStorage.d.ts.map +1 -1
  15. package/dist/tabular/CachedTabularStorage.d.ts +7 -0
  16. package/dist/tabular/CachedTabularStorage.d.ts.map +1 -1
  17. package/dist/tabular/FsFolderTabularStorage.d.ts +7 -0
  18. package/dist/tabular/FsFolderTabularStorage.d.ts.map +1 -1
  19. package/dist/tabular/HuggingFaceTabularStorage.d.ts +119 -0
  20. package/dist/tabular/HuggingFaceTabularStorage.d.ts.map +1 -0
  21. package/dist/tabular/ITabularStorage.d.ts +19 -3
  22. package/dist/tabular/ITabularStorage.d.ts.map +1 -1
  23. package/dist/tabular/InMemoryTabularStorage.d.ts +7 -0
  24. package/dist/tabular/InMemoryTabularStorage.d.ts.map +1 -1
  25. package/dist/tabular/IndexedDbTabularStorage.d.ts +7 -0
  26. package/dist/tabular/IndexedDbTabularStorage.d.ts.map +1 -1
  27. package/dist/tabular/PostgresTabularStorage.d.ts +7 -0
  28. package/dist/tabular/PostgresTabularStorage.d.ts.map +1 -1
  29. package/dist/tabular/SharedInMemoryTabularStorage.d.ts +7 -0
  30. package/dist/tabular/SharedInMemoryTabularStorage.d.ts.map +1 -1
  31. package/dist/tabular/SqliteTabularStorage.d.ts +7 -0
  32. package/dist/tabular/SqliteTabularStorage.d.ts.map +1 -1
  33. package/dist/tabular/SupabaseTabularStorage.d.ts +7 -0
  34. package/dist/tabular/SupabaseTabularStorage.d.ts.map +1 -1
  35. package/package.json +13 -13
package/dist/bun.js CHANGED
@@ -124,6 +124,42 @@ class BaseTabularStorage {
124
124
  waitOn(name) {
125
125
  return this.events.waitOn(name);
126
126
  }
127
+ async* records(pageSize = 100) {
128
+ if (pageSize <= 0) {
129
+ throw new RangeError(`pageSize must be greater than 0, got ${pageSize}`);
130
+ }
131
+ let offset = 0;
132
+ while (true) {
133
+ const page = await this.getBulk(offset, pageSize);
134
+ if (!page || page.length === 0) {
135
+ break;
136
+ }
137
+ for (const entity of page) {
138
+ yield entity;
139
+ }
140
+ if (page.length < pageSize) {
141
+ break;
142
+ }
143
+ offset += pageSize;
144
+ }
145
+ }
146
+ async* pages(pageSize = 100) {
147
+ if (pageSize <= 0) {
148
+ throw new RangeError(`pageSize must be greater than 0, got ${pageSize}`);
149
+ }
150
+ let offset = 0;
151
+ while (true) {
152
+ const page = await this.getBulk(offset, pageSize);
153
+ if (!page || page.length === 0) {
154
+ break;
155
+ }
156
+ yield page;
157
+ if (page.length < pageSize) {
158
+ break;
159
+ }
160
+ offset += pageSize;
161
+ }
162
+ }
127
163
  subscribeToChanges(_callback, _options) {
128
164
  throw new Error(`subscribeToChanges is not implemented for ${this.constructor.name}. ` + `All concrete repository implementations should override this method.`);
129
165
  }
@@ -347,6 +383,22 @@ class InMemoryTabularStorage extends BaseTabularStorage {
347
383
  async size() {
348
384
  return this.values.size;
349
385
  }
386
+ async getBulk(offset, limit) {
387
+ const all = Array.from(this.values.values());
388
+ all.sort((a, b) => {
389
+ for (const key of this.primaryKeyNames) {
390
+ const aVal = a[key];
391
+ const bVal = b[key];
392
+ if (aVal < bVal)
393
+ return -1;
394
+ if (aVal > bVal)
395
+ return 1;
396
+ }
397
+ return 0;
398
+ });
399
+ const page = all.slice(offset, offset + limit);
400
+ return page.length > 0 ? page : undefined;
401
+ }
350
402
  async deleteSearch(criteria) {
351
403
  const criteriaKeys = Object.keys(criteria);
352
404
  if (criteriaKeys.length === 0) {
@@ -532,6 +584,10 @@ class CachedTabularStorage extends BaseTabularStorage {
532
584
  await this.initializeCache();
533
585
  return await this.durable.size();
534
586
  }
587
+ async getBulk(offset, limit) {
588
+ await this.initializeCache();
589
+ return await this.durable.getBulk(offset, limit);
590
+ }
535
591
  async deleteSearch(criteria) {
536
592
  await this.initializeCache();
537
593
  await this.durable.deleteSearch(criteria);
@@ -565,13 +621,262 @@ class CachedTabularStorage extends BaseTabularStorage {
565
621
  this.cache.destroy();
566
622
  }
567
623
  }
624
+ // src/tabular/HuggingFaceTabularStorage.ts
625
+ import {
626
+ createServiceToken as createServiceToken4
627
+ } from "@workglow/util";
628
+ var HF_TABULAR_REPOSITORY = createServiceToken4("storage.tabularRepository.huggingface");
629
+
630
+ class HuggingFaceTabularStorage extends BaseTabularStorage {
631
+ dataset;
632
+ config;
633
+ split;
634
+ token;
635
+ baseUrl;
636
+ constructor(dataset, config, split, schema, primaryKeyNames, options) {
637
+ super(schema, primaryKeyNames, options?.indexes ?? [], "never");
638
+ this.dataset = dataset;
639
+ this.config = config;
640
+ this.split = split;
641
+ this.token = options?.token;
642
+ this.baseUrl = options?.baseUrl ?? "https://datasets-server.huggingface.co";
643
+ }
644
+ static async fromDataset(dataset, config, split, options) {
645
+ const baseUrl = options?.baseUrl ?? "https://datasets-server.huggingface.co";
646
+ const token = options?.token;
647
+ const url = new URL(`${baseUrl}/first-rows`);
648
+ url.searchParams.set("dataset", dataset);
649
+ url.searchParams.set("config", config);
650
+ url.searchParams.set("split", split);
651
+ const headers = {};
652
+ if (token) {
653
+ headers["Authorization"] = `Bearer ${token}`;
654
+ }
655
+ const response = await fetch(url.toString(), { headers });
656
+ if (!response.ok) {
657
+ throw new Error(`Failed to fetch dataset features: ${response.status} ${response.statusText}`);
658
+ }
659
+ const data = await response.json();
660
+ const properties = {};
661
+ const required = [];
662
+ properties["row_idx"] = { type: "integer", "x-auto-generated": true };
663
+ required.push("row_idx");
664
+ for (const feature of data.features) {
665
+ const jsonSchema = hfFeatureToJsonSchema(feature.type);
666
+ properties[feature.name] = jsonSchema;
667
+ required.push(feature.name);
668
+ }
669
+ const schema = {
670
+ type: "object",
671
+ properties,
672
+ required,
673
+ additionalProperties: false
674
+ };
675
+ return new HuggingFaceTabularStorage(dataset, config, split, schema, ["row_idx"], options);
676
+ }
677
+ async setupDatabase() {
678
+ const data = await this.fetchApi("/first-rows", {});
679
+ const schemaColumns = Object.keys(this.schema.properties);
680
+ const hfColumns = data.features.map((f) => f.name);
681
+ const hasRowIdx = schemaColumns.includes("row_idx");
682
+ if (!hasRowIdx) {
683
+ for (const column of schemaColumns) {
684
+ if (!hfColumns.includes(column) && !this.primaryKeyNames.includes(column)) {
685
+ throw new Error(`Schema column "${column}" not found in HuggingFace dataset features`);
686
+ }
687
+ }
688
+ }
689
+ }
690
+ async get(key) {
691
+ const keyObj = this.separateKeyValueFromCombined({ ...key }).key;
692
+ const whereConditions = [];
693
+ for (const [k, v] of Object.entries(keyObj)) {
694
+ if (typeof v === "string") {
695
+ const escaped = v.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
696
+ whereConditions.push(`${k}='${escaped}'`);
697
+ } else {
698
+ whereConditions.push(`${k}=${v}`);
699
+ }
700
+ }
701
+ const where = whereConditions.join(" AND ");
702
+ const data = await this.fetchApi("/filter", { where, limit: "1" });
703
+ if (data.rows.length > 0) {
704
+ const entity = this.rowToEntity(data.rows[0]);
705
+ this.events.emit("get", key, entity);
706
+ return entity;
707
+ }
708
+ this.events.emit("get", key, undefined);
709
+ return;
710
+ }
711
+ async getAll() {
712
+ const allEntities = [];
713
+ let offset = 0;
714
+ const pageSize = 100;
715
+ while (true) {
716
+ const page = await this.getBulk(offset, pageSize);
717
+ if (!page || page.length === 0) {
718
+ break;
719
+ }
720
+ allEntities.push(...page);
721
+ offset += page.length;
722
+ if (page.length < pageSize) {
723
+ break;
724
+ }
725
+ }
726
+ return allEntities.length > 0 ? allEntities : undefined;
727
+ }
728
+ async getBulk(offset, limit) {
729
+ const data = await this.fetchApi("/rows", {
730
+ offset: offset.toString(),
731
+ length: Math.min(limit, 100).toString()
732
+ });
733
+ if (data.rows.length === 0) {
734
+ return;
735
+ }
736
+ const entities = [];
737
+ for (const row of data.rows) {
738
+ entities.push(this.rowToEntity(row));
739
+ }
740
+ return entities;
741
+ }
742
+ async search(key) {
743
+ const searchKeys = Object.keys(key);
744
+ if (searchKeys.length === 0) {
745
+ return;
746
+ }
747
+ const bestIndex = this.findBestMatchingIndex(searchKeys);
748
+ if (!bestIndex) {
749
+ throw new Error(`No suitable index found for the search criteria, searching for ['${searchKeys.join("', '")}'] with pk ['${this.primaryKeyNames.join("', '")}'] and indexes ['${this.indexes.map((idx) => idx.join(",")).join("', '")}'`);
750
+ }
751
+ const whereConditions = [];
752
+ for (const [k, v] of Object.entries(key)) {
753
+ if (v !== undefined && v !== null) {
754
+ if (typeof v === "string") {
755
+ const escaped = v.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
756
+ whereConditions.push(`${k}='${escaped}'`);
757
+ } else {
758
+ whereConditions.push(`${k}=${v}`);
759
+ }
760
+ }
761
+ }
762
+ if (whereConditions.length === 0) {
763
+ throw new Error("Search criteria must include at least one non-null and non-undefined value to build a valid WHERE clause.");
764
+ }
765
+ const where = whereConditions.join(" AND ");
766
+ const allEntities = [];
767
+ let offset = 0;
768
+ const limit = 100;
769
+ while (true) {
770
+ const data = await this.fetchApi("/filter", {
771
+ where,
772
+ offset: offset.toString(),
773
+ limit: limit.toString()
774
+ });
775
+ for (const row of data.rows) {
776
+ allEntities.push(this.rowToEntity(row));
777
+ }
778
+ offset += data.rows.length;
779
+ if (offset >= data.num_rows_total || data.rows.length < limit) {
780
+ break;
781
+ }
782
+ }
783
+ if (allEntities.length > 0) {
784
+ this.events.emit("search", key, allEntities);
785
+ return allEntities;
786
+ } else {
787
+ this.events.emit("search", key, undefined);
788
+ return;
789
+ }
790
+ }
791
+ async size() {
792
+ const data = await this.fetchApi("/size", {});
793
+ return data.size.num_rows;
794
+ }
795
+ async put(_value) {
796
+ throw new Error("HuggingFaceTabularStorage is readonly");
797
+ }
798
+ async putBulk(_values) {
799
+ throw new Error("HuggingFaceTabularStorage is readonly");
800
+ }
801
+ async delete(_value) {
802
+ throw new Error("HuggingFaceTabularStorage is readonly");
803
+ }
804
+ async deleteAll() {
805
+ throw new Error("HuggingFaceTabularStorage is readonly");
806
+ }
807
+ async deleteSearch(_criteria) {
808
+ throw new Error("HuggingFaceTabularStorage is readonly");
809
+ }
810
+ subscribeToChanges(_callback, _options) {
811
+ throw new Error("HuggingFaceTabularStorage does not support subscriptions");
812
+ }
813
+ destroy() {}
814
+ async fetchApi(endpoint, params) {
815
+ const url = new URL(`${this.baseUrl}${endpoint}`);
816
+ url.searchParams.set("dataset", this.dataset);
817
+ url.searchParams.set("config", this.config);
818
+ url.searchParams.set("split", this.split);
819
+ for (const [key, value] of Object.entries(params)) {
820
+ if (value !== undefined) {
821
+ url.searchParams.set(key, value);
822
+ }
823
+ }
824
+ const headers = {};
825
+ if (this.token) {
826
+ headers["Authorization"] = `Bearer ${this.token}`;
827
+ }
828
+ const response = await fetch(url.toString(), { headers });
829
+ if (!response.ok) {
830
+ throw new Error(`HuggingFace API error: ${response.status} ${response.statusText}`);
831
+ }
832
+ return await response.json();
833
+ }
834
+ rowToEntity(row) {
835
+ return { row_idx: row.row_idx, ...row.row };
836
+ }
837
+ }
838
+ function hfFeatureToJsonSchema(feature) {
839
+ if (feature._type === "Value") {
840
+ switch (feature.dtype) {
841
+ case "string":
842
+ return { type: "string" };
843
+ case "int64":
844
+ case "int32":
845
+ case "int16":
846
+ case "int8":
847
+ case "uint64":
848
+ case "uint32":
849
+ case "uint16":
850
+ case "uint8":
851
+ return { type: "integer" };
852
+ case "float64":
853
+ case "float32":
854
+ case "float16":
855
+ return { type: "number" };
856
+ case "bool":
857
+ return { type: "boolean" };
858
+ default:
859
+ return {};
860
+ }
861
+ }
862
+ if (feature._type === "ClassLabel") {
863
+ return { type: "integer" };
864
+ }
865
+ if (feature._type === "Sequence") {
866
+ return {
867
+ type: "array",
868
+ items: hfFeatureToJsonSchema(feature.feature)
869
+ };
870
+ }
871
+ return {};
872
+ }
568
873
  // src/tabular/TabularStorageRegistry.ts
569
874
  import {
570
- createServiceToken as createServiceToken4,
875
+ createServiceToken as createServiceToken5,
571
876
  globalServiceRegistry,
572
877
  registerInputResolver
573
878
  } from "@workglow/util";
574
- var TABULAR_REPOSITORIES = createServiceToken4("storage.tabular.repositories");
879
+ var TABULAR_REPOSITORIES = createServiceToken5("storage.tabular.repositories");
575
880
  if (!globalServiceRegistry.has(TABULAR_REPOSITORIES)) {
576
881
  globalServiceRegistry.register(TABULAR_REPOSITORIES, () => new Map, true);
577
882
  }
@@ -605,11 +910,11 @@ var DefaultKeyValueSchema = {
605
910
  };
606
911
  var DefaultKeyValueKey = ["key"];
607
912
  // src/kv/InMemoryKvStorage.ts
608
- import { createServiceToken as createServiceToken6 } from "@workglow/util";
913
+ import { createServiceToken as createServiceToken7 } from "@workglow/util";
609
914
 
610
915
  // src/kv/KvStorage.ts
611
- import { createServiceToken as createServiceToken5, EventEmitter as EventEmitter2, makeFingerprint as makeFingerprint3 } from "@workglow/util";
612
- var KV_REPOSITORY = createServiceToken5("storage.kvRepository");
916
+ import { createServiceToken as createServiceToken6, EventEmitter as EventEmitter2, makeFingerprint as makeFingerprint3 } from "@workglow/util";
917
+ var KV_REPOSITORY = createServiceToken6("storage.kvRepository");
613
918
 
614
919
  class KvStorage {
615
920
  keySchema;
@@ -716,7 +1021,7 @@ class KvViaTabularStorage extends KvStorage {
716
1021
  }
717
1022
 
718
1023
  // src/kv/InMemoryKvStorage.ts
719
- var MEMORY_KV_REPOSITORY = createServiceToken6("storage.kvRepository.inMemory");
1024
+ var MEMORY_KV_REPOSITORY = createServiceToken7("storage.kvRepository.inMemory");
720
1025
 
721
1026
  class InMemoryKvStorage extends KvViaTabularStorage {
722
1027
  tabularRepository;
@@ -726,11 +1031,11 @@ class InMemoryKvStorage extends KvViaTabularStorage {
726
1031
  }
727
1032
  }
728
1033
  // src/queue/InMemoryQueueStorage.ts
729
- import { createServiceToken as createServiceToken8, EventEmitter as EventEmitter3, makeFingerprint as makeFingerprint4, sleep, uuid4 as uuid42 } from "@workglow/util";
1034
+ import { createServiceToken as createServiceToken9, EventEmitter as EventEmitter3, makeFingerprint as makeFingerprint4, sleep, uuid4 as uuid42 } from "@workglow/util";
730
1035
 
731
1036
  // src/queue/IQueueStorage.ts
732
- import { createServiceToken as createServiceToken7 } from "@workglow/util";
733
- var QUEUE_STORAGE = createServiceToken7("jobqueue.storage");
1037
+ import { createServiceToken as createServiceToken8 } from "@workglow/util";
1038
+ var QUEUE_STORAGE = createServiceToken8("jobqueue.storage");
734
1039
  var JobStatus = {
735
1040
  PENDING: "PENDING",
736
1041
  PROCESSING: "PROCESSING",
@@ -741,7 +1046,7 @@ var JobStatus = {
741
1046
  };
742
1047
 
743
1048
  // src/queue/InMemoryQueueStorage.ts
744
- var IN_MEMORY_QUEUE_STORAGE = createServiceToken8("jobqueue.storage.inMemory");
1049
+ var IN_MEMORY_QUEUE_STORAGE = createServiceToken9("jobqueue.storage.inMemory");
745
1050
 
746
1051
  class InMemoryQueueStorage {
747
1052
  queueName;
@@ -918,8 +1223,8 @@ class InMemoryQueueStorage {
918
1223
  }
919
1224
  }
920
1225
  // src/queue-limiter/InMemoryRateLimiterStorage.ts
921
- import { createServiceToken as createServiceToken9, sleep as sleep2 } from "@workglow/util";
922
- var IN_MEMORY_RATE_LIMITER_STORAGE = createServiceToken9("ratelimiter.storage.inMemory");
1226
+ import { createServiceToken as createServiceToken10, sleep as sleep2 } from "@workglow/util";
1227
+ var IN_MEMORY_RATE_LIMITER_STORAGE = createServiceToken10("ratelimiter.storage.inMemory");
923
1228
 
924
1229
  class InMemoryRateLimiterStorage {
925
1230
  prefixValues;
@@ -977,8 +1282,8 @@ class InMemoryRateLimiterStorage {
977
1282
  }
978
1283
  }
979
1284
  // src/queue-limiter/IRateLimiterStorage.ts
980
- import { createServiceToken as createServiceToken10 } from "@workglow/util";
981
- var RATE_LIMITER_STORAGE = createServiceToken10("ratelimiter.storage");
1285
+ import { createServiceToken as createServiceToken11 } from "@workglow/util";
1286
+ var RATE_LIMITER_STORAGE = createServiceToken11("ratelimiter.storage");
982
1287
  // src/util/HybridSubscriptionManager.ts
983
1288
  class HybridSubscriptionManager {
984
1289
  subscribers = new Set;
@@ -1372,14 +1677,14 @@ class InMemoryVectorStorage extends InMemoryTabularStorage {
1372
1677
  }
1373
1678
  // src/tabular/FsFolderTabularStorage.ts
1374
1679
  import {
1375
- createServiceToken as createServiceToken11,
1680
+ createServiceToken as createServiceToken12,
1376
1681
  makeFingerprint as makeFingerprint5,
1377
1682
  sleep as sleep3,
1378
1683
  uuid4 as uuid43
1379
1684
  } from "@workglow/util";
1380
1685
  import { mkdir, readdir, readFile, rm, writeFile } from "fs/promises";
1381
1686
  import path from "path";
1382
- var FS_FOLDER_TABULAR_REPOSITORY = createServiceToken11("storage.tabularRepository.fsFolder");
1687
+ var FS_FOLDER_TABULAR_REPOSITORY = createServiceToken12("storage.tabularRepository.fsFolder");
1383
1688
 
1384
1689
  class FsFolderTabularStorage extends BaseTabularStorage {
1385
1690
  folderPath;
@@ -1504,6 +1809,32 @@ class FsFolderTabularStorage extends BaseTabularStorage {
1504
1809
  const jsonFiles = files.filter((file) => file.endsWith(".json"));
1505
1810
  return jsonFiles.length;
1506
1811
  }
1812
+ async getBulk(offset, limit) {
1813
+ await this.setupDirectory();
1814
+ const files = await readdir(this.folderPath);
1815
+ const jsonFiles = files.filter((file) => file.endsWith(".json"));
1816
+ if (jsonFiles.length === 0) {
1817
+ return;
1818
+ }
1819
+ const allEntities = await Promise.all(jsonFiles.map(async (file) => {
1820
+ const filePath = path.join(this.folderPath, file);
1821
+ const content = await readFile(filePath, "utf8");
1822
+ return JSON.parse(content);
1823
+ }));
1824
+ allEntities.sort((a, b) => {
1825
+ for (const key of this.primaryKeyNames) {
1826
+ const aVal = a[key];
1827
+ const bVal = b[key];
1828
+ if (aVal < bVal)
1829
+ return -1;
1830
+ if (aVal > bVal)
1831
+ return 1;
1832
+ }
1833
+ return 0;
1834
+ });
1835
+ const page = allEntities.slice(offset, offset + limit);
1836
+ return page.length > 0 ? page : undefined;
1837
+ }
1507
1838
  async search(key) {
1508
1839
  throw new Error("Search not supported for FsFolderTabularStorage");
1509
1840
  }
@@ -1550,7 +1881,7 @@ class FsFolderTabularStorage extends BaseTabularStorage {
1550
1881
  }
1551
1882
  // src/tabular/PostgresTabularStorage.ts
1552
1883
  import {
1553
- createServiceToken as createServiceToken12
1884
+ createServiceToken as createServiceToken13
1554
1885
  } from "@workglow/util";
1555
1886
 
1556
1887
  // src/tabular/BaseSqlTabularStorage.ts
@@ -1737,7 +2068,7 @@ class BaseSqlTabularStorage extends BaseTabularStorage {
1737
2068
  }
1738
2069
 
1739
2070
  // src/tabular/PostgresTabularStorage.ts
1740
- var POSTGRES_TABULAR_REPOSITORY = createServiceToken12("storage.tabularRepository.postgres");
2071
+ var POSTGRES_TABULAR_REPOSITORY = createServiceToken13("storage.tabularRepository.postgres");
1741
2072
 
1742
2073
  class PostgresTabularStorage extends BaseSqlTabularStorage {
1743
2074
  db;
@@ -2164,6 +2495,20 @@ class PostgresTabularStorage extends BaseSqlTabularStorage {
2164
2495
  const result = await db.query(`SELECT COUNT(*) FROM "${this.table}"`);
2165
2496
  return parseInt(result.rows[0].count, 10);
2166
2497
  }
2498
+ async getBulk(offset, limit) {
2499
+ const db = this.db;
2500
+ const orderByClause = this.primaryKeyColumns().map((col) => `"${String(col)}"`).join(", ");
2501
+ const result = await db.query(`SELECT * FROM "${this.table}" ORDER BY ${orderByClause} LIMIT $1 OFFSET $2`, [limit, offset]);
2502
+ if (!result.rows || result.rows.length === 0) {
2503
+ return;
2504
+ }
2505
+ for (const row of result.rows) {
2506
+ for (const key in this.schema.properties) {
2507
+ row[key] = this.sqlToJsValue(key, row[key]);
2508
+ }
2509
+ }
2510
+ return result.rows;
2511
+ }
2167
2512
  buildDeleteSearchWhere(criteria) {
2168
2513
  const conditions = [];
2169
2514
  const params = [];
@@ -2210,10 +2555,10 @@ class PostgresTabularStorage extends BaseSqlTabularStorage {
2210
2555
  // src/tabular/SqliteTabularStorage.ts
2211
2556
  import { Sqlite } from "@workglow/sqlite";
2212
2557
  import {
2213
- createServiceToken as createServiceToken13,
2558
+ createServiceToken as createServiceToken14,
2214
2559
  uuid4 as uuid44
2215
2560
  } from "@workglow/util";
2216
- var SQLITE_TABULAR_REPOSITORY = createServiceToken13("storage.tabularRepository.sqlite");
2561
+ var SQLITE_TABULAR_REPOSITORY = createServiceToken14("storage.tabularRepository.sqlite");
2217
2562
  var Database = Sqlite.Database;
2218
2563
 
2219
2564
  class SqliteTabularStorage extends BaseSqlTabularStorage {
@@ -2596,6 +2941,23 @@ class SqliteTabularStorage extends BaseSqlTabularStorage {
2596
2941
  `);
2597
2942
  return stmt.get()?.count || 0;
2598
2943
  }
2944
+ async getBulk(offset, limit) {
2945
+ const db = this.db;
2946
+ const orderByClause = this.primaryKeyColumns().map((col) => `\`${String(col)}\``).join(", ");
2947
+ const stmt = db.prepare(`
2948
+ SELECT * FROM \`${this.table}\` ORDER BY ${orderByClause} LIMIT ? OFFSET ?
2949
+ `);
2950
+ const rows = stmt.all(limit, offset);
2951
+ if (!rows || rows.length === 0) {
2952
+ return;
2953
+ }
2954
+ for (const row of rows) {
2955
+ for (const k in this.schema.properties) {
2956
+ row[k] = this.sqlToJsValue(k, row[k]);
2957
+ }
2958
+ }
2959
+ return rows;
2960
+ }
2599
2961
  buildDeleteSearchWhere(criteria) {
2600
2962
  const conditions = [];
2601
2963
  const params = [];
@@ -2640,9 +3002,9 @@ class SqliteTabularStorage extends BaseSqlTabularStorage {
2640
3002
  }
2641
3003
  // src/tabular/SupabaseTabularStorage.ts
2642
3004
  import {
2643
- createServiceToken as createServiceToken14
3005
+ createServiceToken as createServiceToken15
2644
3006
  } from "@workglow/util";
2645
- var SUPABASE_TABULAR_REPOSITORY = createServiceToken14("storage.tabularRepository.supabase");
3007
+ var SUPABASE_TABULAR_REPOSITORY = createServiceToken15("storage.tabularRepository.supabase");
2646
3008
 
2647
3009
  class SupabaseTabularStorage extends BaseSqlTabularStorage {
2648
3010
  client;
@@ -2983,6 +3345,24 @@ class SupabaseTabularStorage extends BaseSqlTabularStorage {
2983
3345
  throw error;
2984
3346
  return count ?? 0;
2985
3347
  }
3348
+ async getBulk(offset, limit) {
3349
+ let query = this.client.from(this.table).select("*");
3350
+ for (const pkName of this.primaryKeyNames) {
3351
+ query = query.order(String(pkName));
3352
+ }
3353
+ const { data, error } = await query.range(offset, offset + limit - 1);
3354
+ if (error)
3355
+ throw error;
3356
+ if (!data || data.length === 0) {
3357
+ return;
3358
+ }
3359
+ for (const row of data) {
3360
+ for (const key in this.schema.properties) {
3361
+ row[key] = this.sqlToJsValue(key, row[key]);
3362
+ }
3363
+ }
3364
+ return data;
3365
+ }
2986
3366
  async deleteSearch(criteria) {
2987
3367
  const criteriaKeys = Object.keys(criteria);
2988
3368
  if (criteriaKeys.length === 0) {
@@ -3061,8 +3441,8 @@ class SupabaseTabularStorage extends BaseSqlTabularStorage {
3061
3441
  }
3062
3442
  }
3063
3443
  // src/kv/FsFolderJsonKvStorage.ts
3064
- import { createServiceToken as createServiceToken15 } from "@workglow/util";
3065
- var FS_FOLDER_JSON_KV_REPOSITORY = createServiceToken15("storage.kvRepository.fsFolderJson");
3444
+ import { createServiceToken as createServiceToken16 } from "@workglow/util";
3445
+ var FS_FOLDER_JSON_KV_REPOSITORY = createServiceToken16("storage.kvRepository.fsFolderJson");
3066
3446
 
3067
3447
  class FsFolderJsonKvStorage extends KvViaTabularStorage {
3068
3448
  folderPath;
@@ -3074,10 +3454,10 @@ class FsFolderJsonKvStorage extends KvViaTabularStorage {
3074
3454
  }
3075
3455
  }
3076
3456
  // src/kv/FsFolderKvStorage.ts
3077
- import { createServiceToken as createServiceToken16 } from "@workglow/util";
3457
+ import { createServiceToken as createServiceToken17 } from "@workglow/util";
3078
3458
  import { mkdir as mkdir2, readFile as readFile2, rm as rm2, unlink, writeFile as writeFile2 } from "fs/promises";
3079
3459
  import path2 from "path";
3080
- var FS_FOLDER_KV_REPOSITORY = createServiceToken16("storage.kvRepository.fsFolder");
3460
+ var FS_FOLDER_KV_REPOSITORY = createServiceToken17("storage.kvRepository.fsFolder");
3081
3461
 
3082
3462
  class FsFolderKvStorage extends KvStorage {
3083
3463
  folderPath;
@@ -3154,8 +3534,8 @@ class FsFolderKvStorage extends KvStorage {
3154
3534
  }
3155
3535
  }
3156
3536
  // src/kv/PostgresKvStorage.ts
3157
- import { createServiceToken as createServiceToken17 } from "@workglow/util";
3158
- var POSTGRES_KV_REPOSITORY = createServiceToken17("storage.kvRepository.postgres");
3537
+ import { createServiceToken as createServiceToken18 } from "@workglow/util";
3538
+ var POSTGRES_KV_REPOSITORY = createServiceToken18("storage.kvRepository.postgres");
3159
3539
 
3160
3540
  class PostgresKvStorage extends KvViaTabularStorage {
3161
3541
  db;
@@ -3169,8 +3549,8 @@ class PostgresKvStorage extends KvViaTabularStorage {
3169
3549
  }
3170
3550
  }
3171
3551
  // src/kv/SqliteKvStorage.ts
3172
- import { createServiceToken as createServiceToken18 } from "@workglow/util";
3173
- var SQLITE_KV_REPOSITORY = createServiceToken18("storage.kvRepository.sqlite");
3552
+ import { createServiceToken as createServiceToken19 } from "@workglow/util";
3553
+ var SQLITE_KV_REPOSITORY = createServiceToken19("storage.kvRepository.sqlite");
3174
3554
 
3175
3555
  class SqliteKvStorage extends KvViaTabularStorage {
3176
3556
  db;
@@ -3184,8 +3564,8 @@ class SqliteKvStorage extends KvViaTabularStorage {
3184
3564
  }
3185
3565
  }
3186
3566
  // src/kv/SupabaseKvStorage.ts
3187
- import { createServiceToken as createServiceToken19 } from "@workglow/util";
3188
- var SUPABASE_KV_REPOSITORY = createServiceToken19("storage.kvRepository.supabase");
3567
+ import { createServiceToken as createServiceToken20 } from "@workglow/util";
3568
+ var SUPABASE_KV_REPOSITORY = createServiceToken20("storage.kvRepository.supabase");
3189
3569
 
3190
3570
  class SupabaseKvStorage extends KvViaTabularStorage {
3191
3571
  client;
@@ -3199,8 +3579,8 @@ class SupabaseKvStorage extends KvViaTabularStorage {
3199
3579
  }
3200
3580
  }
3201
3581
  // src/queue/PostgresQueueStorage.ts
3202
- import { createServiceToken as createServiceToken20, makeFingerprint as makeFingerprint6, uuid4 as uuid45 } from "@workglow/util";
3203
- var POSTGRES_QUEUE_STORAGE = createServiceToken20("jobqueue.storage.postgres");
3582
+ import { createServiceToken as createServiceToken21, makeFingerprint as makeFingerprint6, uuid4 as uuid45 } from "@workglow/util";
3583
+ var POSTGRES_QUEUE_STORAGE = createServiceToken21("jobqueue.storage.postgres");
3204
3584
 
3205
3585
  class PostgresQueueStorage {
3206
3586
  db;
@@ -3529,8 +3909,8 @@ class PostgresQueueStorage {
3529
3909
  }
3530
3910
  }
3531
3911
  // src/queue/SqliteQueueStorage.ts
3532
- import { createServiceToken as createServiceToken21, makeFingerprint as makeFingerprint7, sleep as sleep4, uuid4 as uuid46 } from "@workglow/util";
3533
- var SQLITE_QUEUE_STORAGE = createServiceToken21("jobqueue.storage.sqlite");
3912
+ import { createServiceToken as createServiceToken22, makeFingerprint as makeFingerprint7, sleep as sleep4, uuid4 as uuid46 } from "@workglow/util";
3913
+ var SQLITE_QUEUE_STORAGE = createServiceToken22("jobqueue.storage.sqlite");
3534
3914
 
3535
3915
  class SqliteQueueStorage {
3536
3916
  db;
@@ -3865,8 +4245,8 @@ class SqliteQueueStorage {
3865
4245
  }
3866
4246
  }
3867
4247
  // src/queue/SupabaseQueueStorage.ts
3868
- import { createServiceToken as createServiceToken22, makeFingerprint as makeFingerprint8, uuid4 as uuid47 } from "@workglow/util";
3869
- var SUPABASE_QUEUE_STORAGE = createServiceToken22("jobqueue.storage.supabase");
4248
+ import { createServiceToken as createServiceToken23, makeFingerprint as makeFingerprint8, uuid4 as uuid47 } from "@workglow/util";
4249
+ var SUPABASE_QUEUE_STORAGE = createServiceToken23("jobqueue.storage.supabase");
3870
4250
 
3871
4251
  class SupabaseQueueStorage {
3872
4252
  client;
@@ -4365,8 +4745,8 @@ class SupabaseQueueStorage {
4365
4745
  }
4366
4746
  }
4367
4747
  // src/queue-limiter/PostgresRateLimiterStorage.ts
4368
- import { createServiceToken as createServiceToken23 } from "@workglow/util";
4369
- var POSTGRES_RATE_LIMITER_STORAGE = createServiceToken23("ratelimiter.storage.postgres");
4748
+ import { createServiceToken as createServiceToken24 } from "@workglow/util";
4749
+ var POSTGRES_RATE_LIMITER_STORAGE = createServiceToken24("ratelimiter.storage.postgres");
4370
4750
 
4371
4751
  class PostgresRateLimiterStorage {
4372
4752
  db;
@@ -4503,8 +4883,8 @@ class PostgresRateLimiterStorage {
4503
4883
  }
4504
4884
  }
4505
4885
  // src/queue-limiter/SqliteRateLimiterStorage.ts
4506
- import { createServiceToken as createServiceToken24, sleep as sleep5, toSQLiteTimestamp } from "@workglow/util";
4507
- var SQLITE_RATE_LIMITER_STORAGE = createServiceToken24("ratelimiter.storage.sqlite");
4886
+ import { createServiceToken as createServiceToken25, sleep as sleep5, toSQLiteTimestamp } from "@workglow/util";
4887
+ var SQLITE_RATE_LIMITER_STORAGE = createServiceToken25("ratelimiter.storage.sqlite");
4508
4888
 
4509
4889
  class SqliteRateLimiterStorage {
4510
4890
  db;
@@ -4642,8 +5022,8 @@ class SqliteRateLimiterStorage {
4642
5022
  }
4643
5023
  }
4644
5024
  // src/queue-limiter/SupabaseRateLimiterStorage.ts
4645
- import { createServiceToken as createServiceToken25 } from "@workglow/util";
4646
- var SUPABASE_RATE_LIMITER_STORAGE = createServiceToken25("ratelimiter.storage.supabase");
5025
+ import { createServiceToken as createServiceToken26 } from "@workglow/util";
5026
+ var SUPABASE_RATE_LIMITER_STORAGE = createServiceToken26("ratelimiter.storage.supabase");
4647
5027
 
4648
5028
  class SupabaseRateLimiterStorage {
4649
5029
  client;
@@ -5092,11 +5472,11 @@ class SqliteVectorStorage extends SqliteTabularStorage {
5092
5472
  }
5093
5473
  }
5094
5474
  // src/kv/IndexedDbKvStorage.ts
5095
- import { createServiceToken as createServiceToken27 } from "@workglow/util";
5475
+ import { createServiceToken as createServiceToken28 } from "@workglow/util";
5096
5476
 
5097
5477
  // src/tabular/IndexedDbTabularStorage.ts
5098
5478
  import {
5099
- createServiceToken as createServiceToken26,
5479
+ createServiceToken as createServiceToken27,
5100
5480
  makeFingerprint as makeFingerprint9,
5101
5481
  uuid4 as uuid48
5102
5482
  } from "@workglow/util";
@@ -5439,7 +5819,7 @@ async function dropIndexedDbTable(tableName) {
5439
5819
  }
5440
5820
 
5441
5821
  // src/tabular/IndexedDbTabularStorage.ts
5442
- var IDB_TABULAR_REPOSITORY = createServiceToken26("storage.tabularRepository.indexedDb");
5822
+ var IDB_TABULAR_REPOSITORY = createServiceToken27("storage.tabularRepository.indexedDb");
5443
5823
 
5444
5824
  class IndexedDbTabularStorage extends BaseTabularStorage {
5445
5825
  table;
@@ -5730,6 +6110,41 @@ class IndexedDbTabularStorage extends BaseTabularStorage {
5730
6110
  request.onsuccess = () => resolve(request.result);
5731
6111
  });
5732
6112
  }
6113
+ async getBulk(offset, limit) {
6114
+ if (offset < 0) {
6115
+ throw new RangeError(`offset must be non-negative, got ${offset}`);
6116
+ }
6117
+ if (limit <= 0) {
6118
+ return;
6119
+ }
6120
+ const db = await this.getDb();
6121
+ return new Promise((resolve, reject) => {
6122
+ const transaction = db.transaction(this.table, "readonly");
6123
+ const store = transaction.objectStore(this.table);
6124
+ const request = store.openCursor();
6125
+ const entities = [];
6126
+ let skipped = false;
6127
+ request.onerror = () => reject(request.error);
6128
+ request.onsuccess = () => {
6129
+ const cursor = request.result;
6130
+ if (cursor) {
6131
+ if (!skipped && offset > 0) {
6132
+ skipped = true;
6133
+ cursor.advance(offset);
6134
+ return;
6135
+ }
6136
+ entities.push(cursor.value);
6137
+ if (entities.length === limit) {
6138
+ resolve(entities);
6139
+ return;
6140
+ }
6141
+ cursor.continue();
6142
+ } else {
6143
+ resolve(entities.length > 0 ? entities : undefined);
6144
+ }
6145
+ };
6146
+ });
6147
+ }
5733
6148
  matchesCriteria(record, criteria) {
5734
6149
  for (const column of Object.keys(criteria)) {
5735
6150
  const criterion = criteria[column];
@@ -5855,7 +6270,7 @@ class IndexedDbTabularStorage extends BaseTabularStorage {
5855
6270
  }
5856
6271
 
5857
6272
  // src/kv/IndexedDbKvStorage.ts
5858
- var IDB_KV_REPOSITORY = createServiceToken27("storage.kvRepository.indexedDb");
6273
+ var IDB_KV_REPOSITORY = createServiceToken28("storage.kvRepository.indexedDb");
5859
6274
 
5860
6275
  class IndexedDbKvStorage extends KvViaTabularStorage {
5861
6276
  dbName;
@@ -5867,8 +6282,8 @@ class IndexedDbKvStorage extends KvViaTabularStorage {
5867
6282
  }
5868
6283
  }
5869
6284
  // src/queue-limiter/IndexedDbRateLimiterStorage.ts
5870
- import { createServiceToken as createServiceToken28 } from "@workglow/util";
5871
- var INDEXED_DB_RATE_LIMITER_STORAGE = createServiceToken28("ratelimiter.storage.indexedDb");
6285
+ import { createServiceToken as createServiceToken29 } from "@workglow/util";
6286
+ var INDEXED_DB_RATE_LIMITER_STORAGE = createServiceToken29("ratelimiter.storage.indexedDb");
5872
6287
 
5873
6288
  class IndexedDbRateLimiterStorage {
5874
6289
  executionDb;
@@ -6088,8 +6503,8 @@ class IndexedDbRateLimiterStorage {
6088
6503
  }
6089
6504
  }
6090
6505
  // src/queue/IndexedDbQueueStorage.ts
6091
- import { createServiceToken as createServiceToken29, makeFingerprint as makeFingerprint10, uuid4 as uuid49 } from "@workglow/util";
6092
- var INDEXED_DB_QUEUE_STORAGE = createServiceToken29("jobqueue.storage.indexedDb");
6506
+ import { createServiceToken as createServiceToken30, makeFingerprint as makeFingerprint10, uuid4 as uuid49 } from "@workglow/util";
6507
+ var INDEXED_DB_QUEUE_STORAGE = createServiceToken30("jobqueue.storage.indexedDb");
6093
6508
 
6094
6509
  class IndexedDbQueueStorage {
6095
6510
  queueName;
@@ -6718,6 +7133,8 @@ export {
6718
7133
  IDB_TABULAR_REPOSITORY,
6719
7134
  IDB_KV_REPOSITORY,
6720
7135
  HybridSubscriptionManager,
7136
+ HuggingFaceTabularStorage,
7137
+ HF_TABULAR_REPOSITORY,
6721
7138
  FsFolderTabularStorage,
6722
7139
  FsFolderKvStorage,
6723
7140
  FsFolderJsonKvStorage,
@@ -6731,4 +7148,4 @@ export {
6731
7148
  BaseTabularStorage
6732
7149
  };
6733
7150
 
6734
- //# debugId=2AFEB5A537CE948064756E2164756E21
7151
+ //# debugId=3F19856BE0970CD364756E2164756E21