bigal 13.0.6 → 13.0.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.
package/dist/index.mjs CHANGED
@@ -86,6 +86,7 @@ class ColumnCollectionMetadata extends ColumnBaseMetadata {
86
86
  _throughFn;
87
87
  /**
88
88
  * Type of the items in the collection
89
+ * @returns Name of collection
89
90
  */
90
91
  get collection() {
91
92
  if (this._collectionString) {
@@ -103,6 +104,7 @@ class ColumnCollectionMetadata extends ColumnBaseMetadata {
103
104
  via;
104
105
  /**
105
106
  * Name of the junction table for multi-multi associations
107
+ * @returns Name of junction table
106
108
  */
107
109
  get through() {
108
110
  if (this._throughString) {
@@ -112,7 +114,7 @@ class ColumnCollectionMetadata extends ColumnBaseMetadata {
112
114
  this._throughString = this._throughFn();
113
115
  return this._throughString;
114
116
  }
115
- return undefined;
117
+ return void 0;
116
118
  }
117
119
  constructor({
118
120
  target,
@@ -161,6 +163,7 @@ class ColumnModelMetadata extends ColumnBaseMetadata {
161
163
  _modelFn;
162
164
  /**
163
165
  * Name of the model represented by this column id
166
+ * @returns Name of model
164
167
  */
165
168
  get model() {
166
169
  if (this._modelString) {
@@ -1325,6 +1328,7 @@ class ReadonlyRepository {
1325
1328
  * @param {string[]} [args.select] - Array of model property names to return from the query.
1326
1329
  * @param {object} [args.where] - Object representing the where query
1327
1330
  * @param {string|object} [args.sort] - Property name(s) to sort by
1331
+ * @returns Database record or null
1328
1332
  */
1329
1333
  findOne(args = {}) {
1330
1334
  const { stack } = new Error(`${this.model.name}.findOne()`);
@@ -1350,7 +1354,7 @@ class ReadonlyRepository {
1350
1354
  poolOverride = value;
1351
1355
  break;
1352
1356
  default:
1353
- select = undefined;
1357
+ select = void 0;
1354
1358
  where = args;
1355
1359
  sort = null;
1356
1360
  isWhereCriteria = true;
@@ -1368,6 +1372,7 @@ class ReadonlyRepository {
1368
1372
  /**
1369
1373
  * Filters the query
1370
1374
  * @param {object} value - Object representing the where query
1375
+ * @returns Query instance
1371
1376
  */
1372
1377
  where(value) {
1373
1378
  where = value;
@@ -1382,6 +1387,7 @@ class ReadonlyRepository {
1382
1387
  * @param {string|object} [options.sort] - Property name(s) to sort by
1383
1388
  * @param {string|number} [options.skip] - Number of records to skip
1384
1389
  * @param {string|number} [options.limit] - Number of results to return
1390
+ * @returns Query instance
1385
1391
  */
1386
1392
  populate(propertyName, options) {
1387
1393
  if (select && !select.has(propertyName)) {
@@ -1405,6 +1411,7 @@ class ReadonlyRepository {
1405
1411
  /**
1406
1412
  * Sorts the query
1407
1413
  * @param {string|object} [value]
1414
+ * @returns Query instance
1408
1415
  */
1409
1416
  sort(value) {
1410
1417
  if (value) {
@@ -1472,6 +1479,7 @@ ${stack ?? ""}`;
1472
1479
  * @param {string|object} [args.sort] - Property name(s) to sort by
1473
1480
  * @param {string|number} [args.skip] - Number of records to skip
1474
1481
  * @param {string|number} [args.limit] - Number of results to return
1482
+ * @returns Database records
1475
1483
  */
1476
1484
  find(args = {}) {
1477
1485
  const { stack } = new Error(`${this.model.name}.find()`);
@@ -1505,7 +1513,7 @@ ${stack ?? ""}`;
1505
1513
  poolOverride = value;
1506
1514
  break;
1507
1515
  default:
1508
- select = undefined;
1516
+ select = void 0;
1509
1517
  where = args;
1510
1518
  sort = null;
1511
1519
  skip = null;
@@ -1524,6 +1532,7 @@ ${stack ?? ""}`;
1524
1532
  /**
1525
1533
  * Filters the query
1526
1534
  * @param {object} value - Object representing the where query
1535
+ * @returns Query instance
1527
1536
  */
1528
1537
  where(value) {
1529
1538
  where = value;
@@ -1538,6 +1547,7 @@ ${stack ?? ""}`;
1538
1547
  * @param {string|object} [options.sort] - Property name(s) to sort by
1539
1548
  * @param {string|number} [options.skip] - Number of records to skip
1540
1549
  * @param {string|number} [options.limit] - Number of results to return
1550
+ * @returns Query instance
1541
1551
  */
1542
1552
  populate(propertyName, options) {
1543
1553
  if (select && !select.has(propertyName)) {
@@ -1561,6 +1571,7 @@ ${stack ?? ""}`;
1561
1571
  /**
1562
1572
  * Sorts the query
1563
1573
  * @param {string|string[]|object} [value]
1574
+ * @returns Query instance
1564
1575
  */
1565
1576
  sort(value) {
1566
1577
  if (value) {
@@ -1571,6 +1582,7 @@ ${stack ?? ""}`;
1571
1582
  /**
1572
1583
  * Limits results returned by the query
1573
1584
  * @param {number} value
1585
+ * @returns Query instance
1574
1586
  */
1575
1587
  limit(value) {
1576
1588
  limit = value;
@@ -1579,6 +1591,7 @@ ${stack ?? ""}`;
1579
1591
  /**
1580
1592
  * Skips records returned by the query
1581
1593
  * @param {number} value
1594
+ * @returns Query instance
1582
1595
  */
1583
1596
  skip(value) {
1584
1597
  skip = value;
@@ -1590,8 +1603,9 @@ ${stack ?? ""}`;
1590
1603
  },
1591
1604
  /**
1592
1605
  * Pages records returned by the query
1593
- * @param {number} [page=1] - Page to return - Starts at 1
1594
- * @param {number} [limit=10] - Number of records to return
1606
+ * @param {number} [page] - Page to return - Starts at 1
1607
+ * @param {number} [limit] - Number of records to return
1608
+ * @returns Query instance
1595
1609
  */
1596
1610
  paginate({ page = 1, limit: paginateLimit = 10 }) {
1597
1611
  const safePage = Math.max(page, 1);
@@ -1665,6 +1679,7 @@ ${stack ?? ""}`;
1665
1679
  /**
1666
1680
  * Filters the query
1667
1681
  * @param {object} value - Object representing the where query
1682
+ * @returns Count result
1668
1683
  */
1669
1684
  where(value) {
1670
1685
  where = value;
@@ -1962,7 +1977,7 @@ class Repository extends ReadonlyRepository {
1962
1977
  * Creates an object using the specified values
1963
1978
  * @param {object|object[]} values - Values to insert as a new object. If an array is specified, multiple rows will be inserted
1964
1979
  * @param {object} [options]
1965
- * @param {boolean} [options.returnRecords=true] - Determines if inserted records should be returned
1980
+ * @param {boolean} [options.returnRecords] - Determines if inserted records should be returned
1966
1981
  * @param {string[]} [options.returnSelect] - Array of model property names to return from the query.
1967
1982
  * @param {object} [options.onConflict] - Options to handle conflicts due to a unique constraint or exclusion constraint error during insert
1968
1983
  * @returns {object|object[]|void} Return value from the db
@@ -2009,14 +2024,14 @@ class Repository extends ReadonlyRepository {
2009
2024
  }
2010
2025
  throw new Error("Unknown error getting created rows back from the database");
2011
2026
  }
2012
- return undefined;
2027
+ return void 0;
2013
2028
  }
2014
2029
  /**
2015
2030
  * Updates object(s) matching the where query, with the specified values
2016
2031
  * @param {object} where - Object representing the where query
2017
2032
  * @param {object} values - Values to update
2018
2033
  * @param {object} [options]
2019
- * @param {boolean} [options.returnRecords=true] - Determines if inserted records should be returned
2034
+ * @param {boolean} [options.returnRecords] - Determines if inserted records should be returned
2020
2035
  * @param {string[]} [options.returnSelect] - Array of model property names to return from the query.
2021
2036
  * @returns {object[]|void} Return values from the db or `true` if returnRecords=false
2022
2037
  */
@@ -2051,13 +2066,13 @@ class Repository extends ReadonlyRepository {
2051
2066
  if (returnRecords) {
2052
2067
  return this._buildInstances(results.rows);
2053
2068
  }
2054
- return undefined;
2069
+ return void 0;
2055
2070
  }
2056
2071
  /**
2057
2072
  * Destroys object(s) matching the where query
2058
2073
  * @param {object} where - Object representing the where query
2059
2074
  * @param {object} [options]
2060
- * @param {boolean} [options.returnRecords=false] - Determines if inserted records should be returned
2075
+ * @param {boolean} [options.returnRecords] - Determines if inserted records should be returned
2061
2076
  * @param {string[]} [options.returnSelect] - Array of model property names to return from the query.
2062
2077
  * @returns {object[]|void} `void` or records affected if returnRecords=true
2063
2078
  */
@@ -2073,6 +2088,7 @@ class Repository extends ReadonlyRepository {
2073
2088
  /**
2074
2089
  * Filters the query
2075
2090
  * @param {object} value - Object representing the where query
2091
+ * @returns Query instance
2076
2092
  */
2077
2093
  where(value) {
2078
2094
  where = value;
@@ -2113,21 +2129,15 @@ ${stack}`;
2113
2129
 
2114
2130
  function column(dbColumnNameOrOptions, options) {
2115
2131
  return function columnDecorator(object, propertyName) {
2116
- if (!dbColumnNameOrOptions) {
2117
- dbColumnNameOrOptions = _.snakeCase(propertyName);
2118
- }
2132
+ dbColumnNameOrOptions ??= _.snakeCase(propertyName);
2119
2133
  let dbColumnName;
2120
2134
  if (typeof dbColumnNameOrOptions === "string") {
2121
2135
  dbColumnName = dbColumnNameOrOptions;
2122
2136
  } else {
2123
2137
  options = dbColumnNameOrOptions;
2124
2138
  }
2125
- if (!options) {
2126
- options = {};
2127
- }
2128
- if (!dbColumnName) {
2129
- dbColumnName = options.name ?? _.snakeCase(propertyName);
2130
- }
2139
+ options ??= {};
2140
+ dbColumnName ??= options.name ?? _.snakeCase(propertyName);
2131
2141
  const metadataStorage = getMetadataStorage();
2132
2142
  const columnCollectionOptions = options;
2133
2143
  if (columnCollectionOptions.collection || columnCollectionOptions.via) {
@@ -2186,12 +2196,8 @@ function createDateColumn(dbColumnNameOrOptions, options) {
2186
2196
  options = dbColumnNameOrOptions;
2187
2197
  }
2188
2198
  if (dbColumnNameOrOptions) {
2189
- if (!options) {
2190
- options = {};
2191
- }
2192
- if (!dbColumnName) {
2193
- dbColumnName = options.name ?? _.snakeCase(propertyName);
2194
- }
2199
+ options ??= {};
2200
+ dbColumnName ??= options.name ?? _.snakeCase(propertyName);
2195
2201
  metadataStorage.columns.push(
2196
2202
  new ColumnTypeMetadata({
2197
2203
  target: object.constructor.name,
@@ -2208,7 +2214,7 @@ function createDateColumn(dbColumnNameOrOptions, options) {
2208
2214
  name: dbColumnName ?? _.snakeCase(propertyName),
2209
2215
  propertyName,
2210
2216
  createDate: true,
2211
- required: options ? options.required : undefined,
2217
+ required: options ? options.required : void 0,
2212
2218
  type: options ? options.type : "datetime"
2213
2219
  });
2214
2220
  }
@@ -2224,12 +2230,8 @@ function primaryColumn(dbColumnNameOrOptions, options) {
2224
2230
  options = dbColumnNameOrOptions;
2225
2231
  }
2226
2232
  if (dbColumnNameOrOptions) {
2227
- if (!options) {
2228
- options = {};
2229
- }
2230
- if (!dbColumnName) {
2231
- dbColumnName = options.name ?? _.snakeCase(propertyName);
2232
- }
2233
+ options ??= {};
2234
+ dbColumnName ??= options.name ?? _.snakeCase(propertyName);
2233
2235
  const { type } = options;
2234
2236
  const { model } = options;
2235
2237
  const metadataStorage = getMetadataStorage();
@@ -2263,9 +2265,9 @@ function primaryColumn(dbColumnNameOrOptions, options) {
2263
2265
  name: dbColumnName ?? _.snakeCase(propertyName),
2264
2266
  propertyName,
2265
2267
  primary: true,
2266
- required: options ? options.required : undefined,
2267
- type: options ? options.type : undefined,
2268
- model: options ? options.model : undefined
2268
+ required: options ? options.required : void 0,
2269
+ type: options ? options.type : void 0,
2270
+ model: options ? options.model : void 0
2269
2271
  });
2270
2272
  }
2271
2273
  };
@@ -2280,12 +2282,8 @@ function table(dbNameOrTableOptions, options) {
2280
2282
  } else {
2281
2283
  options = dbNameOrTableOptions;
2282
2284
  }
2283
- if (!options) {
2284
- options = {};
2285
- }
2286
- if (!options.name) {
2287
- options.name = dbTableName ?? _.snakeCase(className);
2288
- }
2285
+ options ??= {};
2286
+ options.name ??= dbTableName ?? _.snakeCase(className);
2289
2287
  const metadataStorage = getMetadataStorage();
2290
2288
  const modelMetadata = new ModelMetadata({
2291
2289
  name: className,
@@ -2307,12 +2305,8 @@ function updateDateColumn(dbColumnNameOrOptions, options) {
2307
2305
  options = dbColumnNameOrOptions;
2308
2306
  }
2309
2307
  if (dbColumnNameOrOptions) {
2310
- if (!options) {
2311
- options = {};
2312
- }
2313
- if (!dbColumnName) {
2314
- dbColumnName = options.name ?? _.snakeCase(propertyName);
2315
- }
2308
+ options ??= {};
2309
+ dbColumnName ??= options.name ?? _.snakeCase(propertyName);
2316
2310
  const metadataStorage = getMetadataStorage();
2317
2311
  metadataStorage.columns.push(
2318
2312
  new ColumnTypeMetadata({
@@ -2331,7 +2325,7 @@ function updateDateColumn(dbColumnNameOrOptions, options) {
2331
2325
  name: dbColumnName ?? _.snakeCase(propertyName),
2332
2326
  propertyName,
2333
2327
  updateDate: true,
2334
- required: options ? options.required : undefined,
2328
+ required: options ? options.required : void 0,
2335
2329
  type: options ? options.type : "datetime"
2336
2330
  });
2337
2331
  }
@@ -2347,12 +2341,8 @@ function versionColumn(dbColumnNameOrOptions, options) {
2347
2341
  options = dbColumnNameOrOptions;
2348
2342
  }
2349
2343
  if (dbColumnNameOrOptions) {
2350
- if (!options) {
2351
- options = {};
2352
- }
2353
- if (!dbColumnName) {
2354
- dbColumnName = options.name ?? _.snakeCase(propertyName);
2355
- }
2344
+ options ??= {};
2345
+ dbColumnName ??= options.name ?? _.snakeCase(propertyName);
2356
2346
  const metadataStorage = getMetadataStorage();
2357
2347
  metadataStorage.columns.push(
2358
2348
  new ColumnTypeMetadata({
@@ -2371,8 +2361,8 @@ function versionColumn(dbColumnNameOrOptions, options) {
2371
2361
  name: dbColumnName ?? _.snakeCase(propertyName),
2372
2362
  propertyName,
2373
2363
  version: true,
2374
- required: options ? options.required : undefined,
2375
- type: options ? options.type : undefined
2364
+ required: options ? options.required : void 0,
2365
+ type: options ? options.type : void 0
2376
2366
  });
2377
2367
  }
2378
2368
  };
@@ -2451,6 +2441,7 @@ function initialize({ models, pool, readonlyPool = pool, connections = {}, expos
2451
2441
  throw new Error(`Unable to find @table() on ${model.name}`);
2452
2442
  }
2453
2443
  modelMetadataByModelName[model.name] = new ModelMetadata({
2444
+ // eslint-disable-next-line @typescript-eslint/no-misused-spread
2454
2445
  ...modelMetadata,
2455
2446
  name: model.name,
2456
2447
  type: model
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bigal",
3
- "version": "13.0.6",
3
+ "version": "13.0.8",
4
4
  "description": "A fast and lightweight orm for postgres and node.js, written in typescript.",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -33,32 +33,39 @@
33
33
  "node": ">=18"
34
34
  },
35
35
  "dependencies": {
36
- "@types/pg": "^8.11.10",
37
- "lodash": "^4.17.21",
38
- "pg": "^8.13.1",
39
- "postgres-pool": "^9.0.6"
36
+ "@types/pg": "8.11.11",
37
+ "lodash": "4.17.21",
38
+ "pg": "8.14.1",
39
+ "postgres-pool": "10.1.0"
40
40
  },
41
41
  "devDependencies": {
42
- "@faker-js/faker": "^9.3.0",
43
- "@types/chai": "^5.0.1",
44
- "@types/lodash": "^4.17.14",
42
+ "@faker-js/faker": "9.6.0",
43
+ "@semantic-release/changelog": "6.0.3",
44
+ "@semantic-release/commit-analyzer": "13.0.1",
45
+ "@semantic-release/git": "10.0.1",
46
+ "@semantic-release/github": "11.0.1",
47
+ "@semantic-release/npm": "12.0.1",
48
+ "@semantic-release/release-notes-generator": "14.0.3",
49
+ "@types/chai": "5.2.1",
50
+ "@types/lodash": "4.17.16",
45
51
  "@types/mocha": "10.0.10",
46
- "@types/node": ">=22",
47
- "chai": "^5.1.2",
48
- "eslint": "^9.17.0",
49
- "eslint-config-decent": "^2.3.1",
50
- "husky": "^9.1.7",
51
- "lint-staged": "^15.3.0",
52
- "markdownlint-cli": "^0.43.0",
53
- "mocha": "^11.0.1",
54
- "npm-run-all": "^4.1.5",
55
- "pinst": "^3.0.0",
56
- "prettier": "^3.4.2",
57
- "strict-event-emitter-types": "^2.0.0",
58
- "ts-mockito": "^2.6.1",
59
- "ts-node": "^10.9.2",
60
- "typescript": "^5.7.2",
61
- "unbuild": "^3.2.0"
52
+ "@types/node": "22.14.0",
53
+ "chai": "5.2.0",
54
+ "eslint": "9.24.0",
55
+ "eslint-config-decent": "2.6.4",
56
+ "husky": "9.1.7",
57
+ "lint-staged": "15.5.0",
58
+ "markdownlint-cli": "0.44.0",
59
+ "mocha": "11.1.0",
60
+ "npm-run-all2": "7.0.2",
61
+ "pinst": "3.0.0",
62
+ "prettier": "3.5.3",
63
+ "semantic-release": "24.2.3",
64
+ "strict-event-emitter-types": "2.0.0",
65
+ "ts-mockito": "2.6.1",
66
+ "ts-node": "10.9.2",
67
+ "typescript": "5.8.3",
68
+ "unbuild": "3.5.0"
62
69
  },
63
70
  "scripts": {
64
71
  "build": "unbuild",
@@ -78,17 +85,11 @@
78
85
  "prettier --write --cache",
79
86
  "markdownlint --config=.github/linters/.markdown-lint.yml --fix"
80
87
  ],
81
- "*.js": [
88
+ "*.{js,cjs,mjs,ts}": [
82
89
  "eslint --fix"
83
90
  ],
84
- "*.cjs": [
85
- "eslint --fix"
86
- ],
87
- "*.mjs": [
88
- "eslint --fix"
89
- ],
90
- "*.ts": [
91
- "eslint --fix"
91
+ "*.{json5,yml}": [
92
+ "prettier --write"
92
93
  ]
93
94
  },
94
95
  "repository": {
@@ -0,0 +1,43 @@
1
+ export default {
2
+ branches: ['main', 'beta'],
3
+ plugins: [
4
+ [
5
+ '@semantic-release/commit-analyzer',
6
+ {
7
+ preset: 'angular',
8
+ releaseRules: [
9
+ { type: 'docs', release: 'patch' },
10
+ { type: 'feat', release: 'minor' },
11
+ { type: 'fix', release: 'patch' },
12
+ { type: 'test', release: 'patch' },
13
+ { type: 'chore', release: 'patch' },
14
+ ],
15
+ parserOpts: {
16
+ headerPattern: /^(\w*): (.*)$/,
17
+ headerCorrespondence: ['type', 'subject'],
18
+ },
19
+ },
20
+ ],
21
+ '@semantic-release/release-notes-generator',
22
+ [
23
+ '@semantic-release/changelog',
24
+ {
25
+ changelogFile: 'CHANGELOG.md',
26
+ },
27
+ ],
28
+ '@semantic-release/npm',
29
+ [
30
+ '@semantic-release/github',
31
+ {
32
+ assets: [],
33
+ },
34
+ ],
35
+ [
36
+ '@semantic-release/git',
37
+ {
38
+ assets: ['CHANGELOG.md', 'package.json', 'package-lock.json'],
39
+ message: `chore: release \${nextRelease.version} [skip ci]\n\n\${nextRelease.notes}`,
40
+ },
41
+ ],
42
+ ],
43
+ };