@getstrata/core 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,10 +28,10 @@ declare class Model<TEntity extends object, PrimaryKey extends keyof TEntity & s
28
28
  get id(): TEntity[PrimaryKey];
29
29
  toObject(): TEntity;
30
30
  protected primaryKey(): PrimaryKey;
31
- protected static primaryKeyField(this: typeof Model): string;
32
- protected static hydrateAttributes<TEntity extends object>(this: typeof Model, attributes: TEntity): TEntity;
33
- protected static dehydrateAttributes(this: typeof Model, attributes: LoadedAttributes): LoadedAttributes;
34
- protected static fromRecord<TEntity extends object, PrimaryKey extends keyof TEntity & string>(this: typeof Model, record: TEntity, repository: BaseRepository<TEntity, PrimaryKey>, exists?: boolean): Model<TEntity, PrimaryKey>;
31
+ protected static primaryKeyField(this: object): string;
32
+ protected static hydrateAttributes<TEntity extends object>(this: object, attributes: TEntity): TEntity;
33
+ protected static dehydrateAttributes(this: object, attributes: LoadedAttributes): LoadedAttributes;
34
+ protected static fromRecord<TEntity extends object, PrimaryKey extends keyof TEntity & string>(this: object, record: TEntity, repository: BaseRepository<TEntity, PrimaryKey>, exists?: boolean): Model<TEntity, PrimaryKey>;
35
35
  static boot(): void;
36
36
  static addGlobalScope<TEntity extends object, PrimaryKey extends keyof TEntity & string>(this: object, _name: string, scope: GlobalScopeFn<TEntity, PrimaryKey>): void;
37
37
  static repository<TEntity extends object, PrimaryKey extends keyof TEntity & string>(this: object): BaseRepository<TEntity, PrimaryKey>;
@@ -1560,16 +1560,17 @@ class Model {
1560
1560
  return resolveModelRepository(Model).getTable().primaryKey;
1561
1561
  }
1562
1562
  static hydrateAttributes(attributes) {
1563
- const casts = Model.$casts ?? {};
1563
+ const casts = modelStatics(Model).$casts ?? {};
1564
1564
  return applyCasts(attributes, casts, "hydrate");
1565
1565
  }
1566
1566
  static dehydrateAttributes(attributes) {
1567
- const casts = Model.$casts ?? {};
1567
+ const casts = modelStatics(Model).$casts ?? {};
1568
1568
  return applyCasts(attributes, casts, "dehydrate");
1569
1569
  }
1570
1570
  static fromRecord(record, repository, exists = true) {
1571
- const hydrated = Model.hydrateAttributes(record);
1572
- return new Model(hydrated, repository, exists);
1571
+ const statics = modelStatics(Model);
1572
+ const hydrated = statics.hydrateAttributes(record);
1573
+ return new statics(hydrated, repository, exists);
1573
1574
  }
1574
1575
  static boot() {}
1575
1576
  static addGlobalScope(_name, scope) {
@@ -1358,16 +1358,17 @@ class Model {
1358
1358
  return resolveModelRepository(Model).getTable().primaryKey;
1359
1359
  }
1360
1360
  static hydrateAttributes(attributes) {
1361
- const casts = Model.$casts ?? {};
1361
+ const casts = modelStatics(Model).$casts ?? {};
1362
1362
  return applyCasts(attributes, casts, "hydrate");
1363
1363
  }
1364
1364
  static dehydrateAttributes(attributes) {
1365
- const casts = Model.$casts ?? {};
1365
+ const casts = modelStatics(Model).$casts ?? {};
1366
1366
  return applyCasts(attributes, casts, "dehydrate");
1367
1367
  }
1368
1368
  static fromRecord(record, repository, exists = true) {
1369
- const hydrated = Model.hydrateAttributes(record);
1370
- return new Model(hydrated, repository, exists);
1369
+ const statics = modelStatics(Model);
1370
+ const hydrated = statics.hydrateAttributes(record);
1371
+ return new statics(hydrated, repository, exists);
1371
1372
  }
1372
1373
  static boot() {}
1373
1374
  static addGlobalScope(_name, scope) {
@@ -1582,16 +1582,17 @@ class Model {
1582
1582
  return resolveModelRepository(Model).getTable().primaryKey;
1583
1583
  }
1584
1584
  static hydrateAttributes(attributes) {
1585
- const casts = Model.$casts ?? {};
1585
+ const casts = modelStatics(Model).$casts ?? {};
1586
1586
  return applyCasts(attributes, casts, "hydrate");
1587
1587
  }
1588
1588
  static dehydrateAttributes(attributes) {
1589
- const casts = Model.$casts ?? {};
1589
+ const casts = modelStatics(Model).$casts ?? {};
1590
1590
  return applyCasts(attributes, casts, "dehydrate");
1591
1591
  }
1592
1592
  static fromRecord(record, repository, exists = true) {
1593
- const hydrated = Model.hydrateAttributes(record);
1594
- return new Model(hydrated, repository, exists);
1593
+ const statics = modelStatics(Model);
1594
+ const hydrated = statics.hydrateAttributes(record);
1595
+ return new statics(hydrated, repository, exists);
1595
1596
  }
1596
1597
  static boot() {}
1597
1598
  static addGlobalScope(_name, scope) {
@@ -1582,16 +1582,17 @@ class Model {
1582
1582
  return resolveModelRepository(Model).getTable().primaryKey;
1583
1583
  }
1584
1584
  static hydrateAttributes(attributes) {
1585
- const casts = Model.$casts ?? {};
1585
+ const casts = modelStatics(Model).$casts ?? {};
1586
1586
  return applyCasts(attributes, casts, "hydrate");
1587
1587
  }
1588
1588
  static dehydrateAttributes(attributes) {
1589
- const casts = Model.$casts ?? {};
1589
+ const casts = modelStatics(Model).$casts ?? {};
1590
1590
  return applyCasts(attributes, casts, "dehydrate");
1591
1591
  }
1592
1592
  static fromRecord(record, repository, exists = true) {
1593
- const hydrated = Model.hydrateAttributes(record);
1594
- return new Model(hydrated, repository, exists);
1593
+ const statics = modelStatics(Model);
1594
+ const hydrated = statics.hydrateAttributes(record);
1595
+ return new statics(hydrated, repository, exists);
1595
1596
  }
1596
1597
  static boot() {}
1597
1598
  static addGlobalScope(_name, scope) {
@@ -1753,16 +1753,17 @@ class Model {
1753
1753
  return resolveModelRepository(Model).getTable().primaryKey;
1754
1754
  }
1755
1755
  static hydrateAttributes(attributes) {
1756
- const casts = Model.$casts ?? {};
1756
+ const casts = modelStatics(Model).$casts ?? {};
1757
1757
  return applyCasts(attributes, casts, "hydrate");
1758
1758
  }
1759
1759
  static dehydrateAttributes(attributes) {
1760
- const casts = Model.$casts ?? {};
1760
+ const casts = modelStatics(Model).$casts ?? {};
1761
1761
  return applyCasts(attributes, casts, "dehydrate");
1762
1762
  }
1763
1763
  static fromRecord(record, repository, exists = true) {
1764
- const hydrated = Model.hydrateAttributes(record);
1765
- return new Model(hydrated, repository, exists);
1764
+ const statics = modelStatics(Model);
1765
+ const hydrated = statics.hydrateAttributes(record);
1766
+ return new statics(hydrated, repository, exists);
1766
1767
  }
1767
1768
  static boot() {}
1768
1769
  static addGlobalScope(_name, scope) {
@@ -1358,16 +1358,17 @@ class Model {
1358
1358
  return resolveModelRepository(Model).getTable().primaryKey;
1359
1359
  }
1360
1360
  static hydrateAttributes(attributes) {
1361
- const casts = Model.$casts ?? {};
1361
+ const casts = modelStatics(Model).$casts ?? {};
1362
1362
  return applyCasts(attributes, casts, "hydrate");
1363
1363
  }
1364
1364
  static dehydrateAttributes(attributes) {
1365
- const casts = Model.$casts ?? {};
1365
+ const casts = modelStatics(Model).$casts ?? {};
1366
1366
  return applyCasts(attributes, casts, "dehydrate");
1367
1367
  }
1368
1368
  static fromRecord(record, repository, exists = true) {
1369
- const hydrated = Model.hydrateAttributes(record);
1370
- return new Model(hydrated, repository, exists);
1369
+ const statics = modelStatics(Model);
1370
+ const hydrated = statics.hydrateAttributes(record);
1371
+ return new statics(hydrated, repository, exists);
1371
1372
  }
1372
1373
  static boot() {}
1373
1374
  static addGlobalScope(_name, scope) {
@@ -1763,16 +1763,17 @@ class Model {
1763
1763
  return resolveModelRepository(Model).getTable().primaryKey;
1764
1764
  }
1765
1765
  static hydrateAttributes(attributes) {
1766
- const casts = Model.$casts ?? {};
1766
+ const casts = modelStatics(Model).$casts ?? {};
1767
1767
  return applyCasts(attributes, casts, "hydrate");
1768
1768
  }
1769
1769
  static dehydrateAttributes(attributes) {
1770
- const casts = Model.$casts ?? {};
1770
+ const casts = modelStatics(Model).$casts ?? {};
1771
1771
  return applyCasts(attributes, casts, "dehydrate");
1772
1772
  }
1773
1773
  static fromRecord(record, repository, exists = true) {
1774
- const hydrated = Model.hydrateAttributes(record);
1775
- return new Model(hydrated, repository, exists);
1774
+ const statics = modelStatics(Model);
1775
+ const hydrated = statics.hydrateAttributes(record);
1776
+ return new statics(hydrated, repository, exists);
1776
1777
  }
1777
1778
  static boot() {}
1778
1779
  static addGlobalScope(_name, scope) {
@@ -1,8 +1,8 @@
1
1
  // @bun
2
2
  // ../../src/core/storage/storage.ts
3
- var {S3Client } = globalThis.Bun;
4
3
  import { mkdir, readFile, unlink, writeFile } from "fs/promises";
5
4
  import { dirname, join } from "path";
5
+ var {S3Client } = globalThis.Bun;
6
6
 
7
7
  class LocalStorageDriver {
8
8
  rootDirectory;
@@ -1567,16 +1567,17 @@ class Model {
1567
1567
  return resolveModelRepository(Model).getTable().primaryKey;
1568
1568
  }
1569
1569
  static hydrateAttributes(attributes) {
1570
- const casts = Model.$casts ?? {};
1570
+ const casts = modelStatics(Model).$casts ?? {};
1571
1571
  return applyCasts(attributes, casts, "hydrate");
1572
1572
  }
1573
1573
  static dehydrateAttributes(attributes) {
1574
- const casts = Model.$casts ?? {};
1574
+ const casts = modelStatics(Model).$casts ?? {};
1575
1575
  return applyCasts(attributes, casts, "dehydrate");
1576
1576
  }
1577
1577
  static fromRecord(record, repository, exists = true) {
1578
- const hydrated = Model.hydrateAttributes(record);
1579
- return new Model(hydrated, repository, exists);
1578
+ const statics = modelStatics(Model);
1579
+ const hydrated = statics.hydrateAttributes(record);
1580
+ return new statics(hydrated, repository, exists);
1580
1581
  }
1581
1582
  static boot() {}
1582
1583
  static addGlobalScope(_name, scope) {
package/dist/index.js CHANGED
@@ -1668,16 +1668,17 @@ class Model {
1668
1668
  return resolveModelRepository(Model).getTable().primaryKey;
1669
1669
  }
1670
1670
  static hydrateAttributes(attributes) {
1671
- const casts = Model.$casts ?? {};
1671
+ const casts = modelStatics(Model).$casts ?? {};
1672
1672
  return applyCasts(attributes, casts, "hydrate");
1673
1673
  }
1674
1674
  static dehydrateAttributes(attributes) {
1675
- const casts = Model.$casts ?? {};
1675
+ const casts = modelStatics(Model).$casts ?? {};
1676
1676
  return applyCasts(attributes, casts, "dehydrate");
1677
1677
  }
1678
1678
  static fromRecord(record, repository, exists = true) {
1679
- const hydrated = Model.hydrateAttributes(record);
1680
- return new Model(hydrated, repository, exists);
1679
+ const statics = modelStatics(Model);
1680
+ const hydrated = statics.hydrateAttributes(record);
1681
+ return new statics(hydrated, repository, exists);
1681
1682
  }
1682
1683
  static boot() {}
1683
1684
  static addGlobalScope(_name, scope) {
@@ -2758,9 +2759,9 @@ function mailer() {
2758
2759
  }
2759
2760
 
2760
2761
  // ../../src/core/storage/storage.ts
2761
- var {S3Client } = globalThis.Bun;
2762
2762
  import { mkdir, readFile, unlink, writeFile } from "fs/promises";
2763
2763
  import { dirname, join as join3 } from "path";
2764
+ var {S3Client } = globalThis.Bun;
2764
2765
 
2765
2766
  class LocalStorageDriver {
2766
2767
  rootDirectory;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getstrata/core",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Strata — Laravel-inspired Bun framework public API",
5
5
  "type": "module",
6
6
  "license": "MIT",