@getstrata/core 0.5.7 → 0.5.8

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.
@@ -1555,24 +1555,24 @@ class Model {
1555
1555
  throw new Error(`${this.constructor.name}.primaryKey() is not implemented.`);
1556
1556
  }
1557
1557
  static primaryKeyField() {
1558
- return resolveModelRepository(Model).getTable().primaryKey;
1558
+ return resolveModelRepository(this).getTable().primaryKey;
1559
1559
  }
1560
1560
  static hydrateAttributes(attributes) {
1561
- const casts = modelStatics(Model).$casts ?? {};
1561
+ const casts = modelStatics(this).$casts ?? {};
1562
1562
  return applyCasts(attributes, casts, "hydrate");
1563
1563
  }
1564
1564
  static dehydrateAttributes(attributes) {
1565
- const casts = modelStatics(Model).$casts ?? {};
1565
+ const casts = modelStatics(this).$casts ?? {};
1566
1566
  return applyCasts(attributes, casts, "dehydrate");
1567
1567
  }
1568
1568
  static fromRecord(record, repository, exists = true) {
1569
- const statics = modelStatics(Model);
1569
+ const statics = modelStatics(this);
1570
1570
  const hydrated = statics.hydrateAttributes(record);
1571
1571
  return new statics(hydrated, repository, exists);
1572
1572
  }
1573
1573
  static boot() {}
1574
1574
  static addGlobalScope(_name, scope) {
1575
- ensureBooted(Model);
1575
+ ensureBooted(this);
1576
1576
  const existing = modelGlobalScopes.get(Model) ?? [];
1577
1577
  modelGlobalScopes.set(Model, [
1578
1578
  ...existing,
@@ -1604,7 +1604,7 @@ class Model {
1604
1604
  return statics.fromRecord(record, repository, true);
1605
1605
  }
1606
1606
  static async find(id) {
1607
- const statics = modelStatics(Model);
1607
+ const statics = modelStatics(this);
1608
1608
  const repository = resolveModelRepository(Model);
1609
1609
  const primaryKey = repository.getTable().primaryKey;
1610
1610
  const record = await Model.query.call(Model).where({ [primaryKey]: id }).first();
@@ -1353,24 +1353,24 @@ class Model {
1353
1353
  throw new Error(`${this.constructor.name}.primaryKey() is not implemented.`);
1354
1354
  }
1355
1355
  static primaryKeyField() {
1356
- return resolveModelRepository(Model).getTable().primaryKey;
1356
+ return resolveModelRepository(this).getTable().primaryKey;
1357
1357
  }
1358
1358
  static hydrateAttributes(attributes) {
1359
- const casts = modelStatics(Model).$casts ?? {};
1359
+ const casts = modelStatics(this).$casts ?? {};
1360
1360
  return applyCasts(attributes, casts, "hydrate");
1361
1361
  }
1362
1362
  static dehydrateAttributes(attributes) {
1363
- const casts = modelStatics(Model).$casts ?? {};
1363
+ const casts = modelStatics(this).$casts ?? {};
1364
1364
  return applyCasts(attributes, casts, "dehydrate");
1365
1365
  }
1366
1366
  static fromRecord(record, repository, exists = true) {
1367
- const statics = modelStatics(Model);
1367
+ const statics = modelStatics(this);
1368
1368
  const hydrated = statics.hydrateAttributes(record);
1369
1369
  return new statics(hydrated, repository, exists);
1370
1370
  }
1371
1371
  static boot() {}
1372
1372
  static addGlobalScope(_name, scope) {
1373
- ensureBooted(Model);
1373
+ ensureBooted(this);
1374
1374
  const existing = modelGlobalScopes.get(Model) ?? [];
1375
1375
  modelGlobalScopes.set(Model, [
1376
1376
  ...existing,
@@ -1402,7 +1402,7 @@ class Model {
1402
1402
  return statics.fromRecord(record, repository, true);
1403
1403
  }
1404
1404
  static async find(id) {
1405
- const statics = modelStatics(Model);
1405
+ const statics = modelStatics(this);
1406
1406
  const repository = resolveModelRepository(Model);
1407
1407
  const primaryKey = repository.getTable().primaryKey;
1408
1408
  const record = await Model.query.call(Model).where({ [primaryKey]: id }).first();
@@ -1577,24 +1577,24 @@ class Model {
1577
1577
  throw new Error(`${this.constructor.name}.primaryKey() is not implemented.`);
1578
1578
  }
1579
1579
  static primaryKeyField() {
1580
- return resolveModelRepository(Model).getTable().primaryKey;
1580
+ return resolveModelRepository(this).getTable().primaryKey;
1581
1581
  }
1582
1582
  static hydrateAttributes(attributes) {
1583
- const casts = modelStatics(Model).$casts ?? {};
1583
+ const casts = modelStatics(this).$casts ?? {};
1584
1584
  return applyCasts(attributes, casts, "hydrate");
1585
1585
  }
1586
1586
  static dehydrateAttributes(attributes) {
1587
- const casts = modelStatics(Model).$casts ?? {};
1587
+ const casts = modelStatics(this).$casts ?? {};
1588
1588
  return applyCasts(attributes, casts, "dehydrate");
1589
1589
  }
1590
1590
  static fromRecord(record, repository, exists = true) {
1591
- const statics = modelStatics(Model);
1591
+ const statics = modelStatics(this);
1592
1592
  const hydrated = statics.hydrateAttributes(record);
1593
1593
  return new statics(hydrated, repository, exists);
1594
1594
  }
1595
1595
  static boot() {}
1596
1596
  static addGlobalScope(_name, scope) {
1597
- ensureBooted(Model);
1597
+ ensureBooted(this);
1598
1598
  const existing = modelGlobalScopes.get(Model) ?? [];
1599
1599
  modelGlobalScopes.set(Model, [
1600
1600
  ...existing,
@@ -1626,7 +1626,7 @@ class Model {
1626
1626
  return statics.fromRecord(record, repository, true);
1627
1627
  }
1628
1628
  static async find(id) {
1629
- const statics = modelStatics(Model);
1629
+ const statics = modelStatics(this);
1630
1630
  const repository = resolveModelRepository(Model);
1631
1631
  const primaryKey = repository.getTable().primaryKey;
1632
1632
  const record = await Model.query.call(Model).where({ [primaryKey]: id }).first();
@@ -1577,24 +1577,24 @@ class Model {
1577
1577
  throw new Error(`${this.constructor.name}.primaryKey() is not implemented.`);
1578
1578
  }
1579
1579
  static primaryKeyField() {
1580
- return resolveModelRepository(Model).getTable().primaryKey;
1580
+ return resolveModelRepository(this).getTable().primaryKey;
1581
1581
  }
1582
1582
  static hydrateAttributes(attributes) {
1583
- const casts = modelStatics(Model).$casts ?? {};
1583
+ const casts = modelStatics(this).$casts ?? {};
1584
1584
  return applyCasts(attributes, casts, "hydrate");
1585
1585
  }
1586
1586
  static dehydrateAttributes(attributes) {
1587
- const casts = modelStatics(Model).$casts ?? {};
1587
+ const casts = modelStatics(this).$casts ?? {};
1588
1588
  return applyCasts(attributes, casts, "dehydrate");
1589
1589
  }
1590
1590
  static fromRecord(record, repository, exists = true) {
1591
- const statics = modelStatics(Model);
1591
+ const statics = modelStatics(this);
1592
1592
  const hydrated = statics.hydrateAttributes(record);
1593
1593
  return new statics(hydrated, repository, exists);
1594
1594
  }
1595
1595
  static boot() {}
1596
1596
  static addGlobalScope(_name, scope) {
1597
- ensureBooted(Model);
1597
+ ensureBooted(this);
1598
1598
  const existing = modelGlobalScopes.get(Model) ?? [];
1599
1599
  modelGlobalScopes.set(Model, [
1600
1600
  ...existing,
@@ -1626,7 +1626,7 @@ class Model {
1626
1626
  return statics.fromRecord(record, repository, true);
1627
1627
  }
1628
1628
  static async find(id) {
1629
- const statics = modelStatics(Model);
1629
+ const statics = modelStatics(this);
1630
1630
  const repository = resolveModelRepository(Model);
1631
1631
  const primaryKey = repository.getTable().primaryKey;
1632
1632
  const record = await Model.query.call(Model).where({ [primaryKey]: id }).first();
@@ -1751,24 +1751,24 @@ class Model {
1751
1751
  throw new Error(`${this.constructor.name}.primaryKey() is not implemented.`);
1752
1752
  }
1753
1753
  static primaryKeyField() {
1754
- return resolveModelRepository(Model).getTable().primaryKey;
1754
+ return resolveModelRepository(this).getTable().primaryKey;
1755
1755
  }
1756
1756
  static hydrateAttributes(attributes) {
1757
- const casts = modelStatics(Model).$casts ?? {};
1757
+ const casts = modelStatics(this).$casts ?? {};
1758
1758
  return applyCasts(attributes, casts, "hydrate");
1759
1759
  }
1760
1760
  static dehydrateAttributes(attributes) {
1761
- const casts = modelStatics(Model).$casts ?? {};
1761
+ const casts = modelStatics(this).$casts ?? {};
1762
1762
  return applyCasts(attributes, casts, "dehydrate");
1763
1763
  }
1764
1764
  static fromRecord(record, repository, exists = true) {
1765
- const statics = modelStatics(Model);
1765
+ const statics = modelStatics(this);
1766
1766
  const hydrated = statics.hydrateAttributes(record);
1767
1767
  return new statics(hydrated, repository, exists);
1768
1768
  }
1769
1769
  static boot() {}
1770
1770
  static addGlobalScope(_name, scope) {
1771
- ensureBooted(Model);
1771
+ ensureBooted(this);
1772
1772
  const existing = modelGlobalScopes.get(Model) ?? [];
1773
1773
  modelGlobalScopes.set(Model, [
1774
1774
  ...existing,
@@ -1800,7 +1800,7 @@ class Model {
1800
1800
  return statics.fromRecord(record, repository, true);
1801
1801
  }
1802
1802
  static async find(id) {
1803
- const statics = modelStatics(Model);
1803
+ const statics = modelStatics(this);
1804
1804
  const repository = resolveModelRepository(Model);
1805
1805
  const primaryKey = repository.getTable().primaryKey;
1806
1806
  const record = await Model.query.call(Model).where({ [primaryKey]: id }).first();
@@ -1353,24 +1353,24 @@ class Model {
1353
1353
  throw new Error(`${this.constructor.name}.primaryKey() is not implemented.`);
1354
1354
  }
1355
1355
  static primaryKeyField() {
1356
- return resolveModelRepository(Model).getTable().primaryKey;
1356
+ return resolveModelRepository(this).getTable().primaryKey;
1357
1357
  }
1358
1358
  static hydrateAttributes(attributes) {
1359
- const casts = modelStatics(Model).$casts ?? {};
1359
+ const casts = modelStatics(this).$casts ?? {};
1360
1360
  return applyCasts(attributes, casts, "hydrate");
1361
1361
  }
1362
1362
  static dehydrateAttributes(attributes) {
1363
- const casts = modelStatics(Model).$casts ?? {};
1363
+ const casts = modelStatics(this).$casts ?? {};
1364
1364
  return applyCasts(attributes, casts, "dehydrate");
1365
1365
  }
1366
1366
  static fromRecord(record, repository, exists = true) {
1367
- const statics = modelStatics(Model);
1367
+ const statics = modelStatics(this);
1368
1368
  const hydrated = statics.hydrateAttributes(record);
1369
1369
  return new statics(hydrated, repository, exists);
1370
1370
  }
1371
1371
  static boot() {}
1372
1372
  static addGlobalScope(_name, scope) {
1373
- ensureBooted(Model);
1373
+ ensureBooted(this);
1374
1374
  const existing = modelGlobalScopes.get(Model) ?? [];
1375
1375
  modelGlobalScopes.set(Model, [
1376
1376
  ...existing,
@@ -1402,7 +1402,7 @@ class Model {
1402
1402
  return statics.fromRecord(record, repository, true);
1403
1403
  }
1404
1404
  static async find(id) {
1405
- const statics = modelStatics(Model);
1405
+ const statics = modelStatics(this);
1406
1406
  const repository = resolveModelRepository(Model);
1407
1407
  const primaryKey = repository.getTable().primaryKey;
1408
1408
  const record = await Model.query.call(Model).where({ [primaryKey]: id }).first();
@@ -1761,24 +1761,24 @@ class Model {
1761
1761
  throw new Error(`${this.constructor.name}.primaryKey() is not implemented.`);
1762
1762
  }
1763
1763
  static primaryKeyField() {
1764
- return resolveModelRepository(Model).getTable().primaryKey;
1764
+ return resolveModelRepository(this).getTable().primaryKey;
1765
1765
  }
1766
1766
  static hydrateAttributes(attributes) {
1767
- const casts = modelStatics(Model).$casts ?? {};
1767
+ const casts = modelStatics(this).$casts ?? {};
1768
1768
  return applyCasts(attributes, casts, "hydrate");
1769
1769
  }
1770
1770
  static dehydrateAttributes(attributes) {
1771
- const casts = modelStatics(Model).$casts ?? {};
1771
+ const casts = modelStatics(this).$casts ?? {};
1772
1772
  return applyCasts(attributes, casts, "dehydrate");
1773
1773
  }
1774
1774
  static fromRecord(record, repository, exists = true) {
1775
- const statics = modelStatics(Model);
1775
+ const statics = modelStatics(this);
1776
1776
  const hydrated = statics.hydrateAttributes(record);
1777
1777
  return new statics(hydrated, repository, exists);
1778
1778
  }
1779
1779
  static boot() {}
1780
1780
  static addGlobalScope(_name, scope) {
1781
- ensureBooted(Model);
1781
+ ensureBooted(this);
1782
1782
  const existing = modelGlobalScopes.get(Model) ?? [];
1783
1783
  modelGlobalScopes.set(Model, [
1784
1784
  ...existing,
@@ -1810,7 +1810,7 @@ class Model {
1810
1810
  return statics.fromRecord(record, repository, true);
1811
1811
  }
1812
1812
  static async find(id) {
1813
- const statics = modelStatics(Model);
1813
+ const statics = modelStatics(this);
1814
1814
  const repository = resolveModelRepository(Model);
1815
1815
  const primaryKey = repository.getTable().primaryKey;
1816
1816
  const record = await Model.query.call(Model).where({ [primaryKey]: id }).first();
@@ -1562,24 +1562,24 @@ class Model {
1562
1562
  throw new Error(`${this.constructor.name}.primaryKey() is not implemented.`);
1563
1563
  }
1564
1564
  static primaryKeyField() {
1565
- return resolveModelRepository(Model).getTable().primaryKey;
1565
+ return resolveModelRepository(this).getTable().primaryKey;
1566
1566
  }
1567
1567
  static hydrateAttributes(attributes) {
1568
- const casts = modelStatics(Model).$casts ?? {};
1568
+ const casts = modelStatics(this).$casts ?? {};
1569
1569
  return applyCasts(attributes, casts, "hydrate");
1570
1570
  }
1571
1571
  static dehydrateAttributes(attributes) {
1572
- const casts = modelStatics(Model).$casts ?? {};
1572
+ const casts = modelStatics(this).$casts ?? {};
1573
1573
  return applyCasts(attributes, casts, "dehydrate");
1574
1574
  }
1575
1575
  static fromRecord(record, repository, exists = true) {
1576
- const statics = modelStatics(Model);
1576
+ const statics = modelStatics(this);
1577
1577
  const hydrated = statics.hydrateAttributes(record);
1578
1578
  return new statics(hydrated, repository, exists);
1579
1579
  }
1580
1580
  static boot() {}
1581
1581
  static addGlobalScope(_name, scope) {
1582
- ensureBooted(Model);
1582
+ ensureBooted(this);
1583
1583
  const existing = modelGlobalScopes.get(Model) ?? [];
1584
1584
  modelGlobalScopes.set(Model, [
1585
1585
  ...existing,
@@ -1611,7 +1611,7 @@ class Model {
1611
1611
  return statics.fromRecord(record, repository, true);
1612
1612
  }
1613
1613
  static async find(id) {
1614
- const statics = modelStatics(Model);
1614
+ const statics = modelStatics(this);
1615
1615
  const repository = resolveModelRepository(Model);
1616
1616
  const primaryKey = repository.getTable().primaryKey;
1617
1617
  const record = await Model.query.call(Model).where({ [primaryKey]: id }).first();
package/dist/index.js CHANGED
@@ -1747,24 +1747,24 @@ class Model {
1747
1747
  throw new Error(`${this.constructor.name}.primaryKey() is not implemented.`);
1748
1748
  }
1749
1749
  static primaryKeyField() {
1750
- return resolveModelRepository(Model).getTable().primaryKey;
1750
+ return resolveModelRepository(this).getTable().primaryKey;
1751
1751
  }
1752
1752
  static hydrateAttributes(attributes) {
1753
- const casts = modelStatics(Model).$casts ?? {};
1753
+ const casts = modelStatics(this).$casts ?? {};
1754
1754
  return applyCasts(attributes, casts, "hydrate");
1755
1755
  }
1756
1756
  static dehydrateAttributes(attributes) {
1757
- const casts = modelStatics(Model).$casts ?? {};
1757
+ const casts = modelStatics(this).$casts ?? {};
1758
1758
  return applyCasts(attributes, casts, "dehydrate");
1759
1759
  }
1760
1760
  static fromRecord(record, repository, exists = true) {
1761
- const statics = modelStatics(Model);
1761
+ const statics = modelStatics(this);
1762
1762
  const hydrated = statics.hydrateAttributes(record);
1763
1763
  return new statics(hydrated, repository, exists);
1764
1764
  }
1765
1765
  static boot() {}
1766
1766
  static addGlobalScope(_name, scope) {
1767
- ensureBooted(Model);
1767
+ ensureBooted(this);
1768
1768
  const existing = modelGlobalScopes.get(Model) ?? [];
1769
1769
  modelGlobalScopes.set(Model, [
1770
1770
  ...existing,
@@ -1796,7 +1796,7 @@ class Model {
1796
1796
  return statics.fromRecord(record, repository, true);
1797
1797
  }
1798
1798
  static async find(id) {
1799
- const statics = modelStatics(Model);
1799
+ const statics = modelStatics(this);
1800
1800
  const repository = resolveModelRepository(Model);
1801
1801
  const primaryKey = repository.getTable().primaryKey;
1802
1802
  const record = await Model.query.call(Model).where({ [primaryKey]: id }).first();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getstrata/core",
3
- "version": "0.5.7",
3
+ "version": "0.5.8",
4
4
  "description": "Strata — Laravel-inspired Bun framework public API",
5
5
  "type": "module",
6
6
  "license": "MIT",