arkormx 0.2.0 → 0.2.2

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/cli.mjs CHANGED
@@ -103,7 +103,7 @@ var TableBuilder = class {
103
103
  *
104
104
  * @param name The name of the integer column.
105
105
  * @param options Additional options for the integer column.
106
- * @returns
106
+ * @returns The current TableBuilder instance for chaining.
107
107
  */
108
108
  integer(name, options = {}) {
109
109
  return this.column(name, "integer", options);
@@ -113,7 +113,7 @@ var TableBuilder = class {
113
113
  *
114
114
  * @param name The name of the big integer column.
115
115
  * @param options Additional options for the big integer column.
116
- * @returns
116
+ * @returns The current TableBuilder instance for chaining.
117
117
  */
118
118
  bigInteger(name, options = {}) {
119
119
  return this.column(name, "bigInteger", options);
@@ -123,17 +123,29 @@ var TableBuilder = class {
123
123
  *
124
124
  * @param name The name of the float column.
125
125
  * @param options Additional options for the float column.
126
- * @returns
126
+ * @returns The current TableBuilder instance for chaining.
127
127
  */
128
128
  float(name, options = {}) {
129
129
  return this.column(name, "float", options);
130
130
  }
131
131
  /**
132
+ * Marks a column as unique in the table.
133
+ *
134
+ * @param name Optional explicit column name.
135
+ * When omitted, applies to the latest defined column.
136
+ * @returns The current TableBuilder instance for chaining.
137
+ */
138
+ unique(name) {
139
+ const column = this.resolveColumn(name);
140
+ column.unique = true;
141
+ return this;
142
+ }
143
+ /**
132
144
  * Defines a boolean column in the table.
133
145
  *
134
146
  * @param name The name of the boolean column.
135
147
  * @param options Additional options for the boolean column.
136
- * @returns
148
+ * @returns The current TableBuilder instance for chaining.
137
149
  */
138
150
  boolean(name, options = {}) {
139
151
  return this.column(name, "boolean", options);
package/dist/index.cjs CHANGED
@@ -194,7 +194,7 @@ var TableBuilder = class {
194
194
  *
195
195
  * @param name The name of the integer column.
196
196
  * @param options Additional options for the integer column.
197
- * @returns
197
+ * @returns The current TableBuilder instance for chaining.
198
198
  */
199
199
  integer(name, options = {}) {
200
200
  return this.column(name, "integer", options);
@@ -204,7 +204,7 @@ var TableBuilder = class {
204
204
  *
205
205
  * @param name The name of the big integer column.
206
206
  * @param options Additional options for the big integer column.
207
- * @returns
207
+ * @returns The current TableBuilder instance for chaining.
208
208
  */
209
209
  bigInteger(name, options = {}) {
210
210
  return this.column(name, "bigInteger", options);
@@ -214,17 +214,29 @@ var TableBuilder = class {
214
214
  *
215
215
  * @param name The name of the float column.
216
216
  * @param options Additional options for the float column.
217
- * @returns
217
+ * @returns The current TableBuilder instance for chaining.
218
218
  */
219
219
  float(name, options = {}) {
220
220
  return this.column(name, "float", options);
221
221
  }
222
222
  /**
223
+ * Marks a column as unique in the table.
224
+ *
225
+ * @param name Optional explicit column name.
226
+ * When omitted, applies to the latest defined column.
227
+ * @returns The current TableBuilder instance for chaining.
228
+ */
229
+ unique(name) {
230
+ const column = this.resolveColumn(name);
231
+ column.unique = true;
232
+ return this;
233
+ }
234
+ /**
223
235
  * Defines a boolean column in the table.
224
236
  *
225
237
  * @param name The name of the boolean column.
226
238
  * @param options Additional options for the boolean column.
227
- * @returns
239
+ * @returns The current TableBuilder instance for chaining.
228
240
  */
229
241
  boolean(name, options = {}) {
230
242
  return this.column(name, "boolean", options);
@@ -2203,9 +2215,14 @@ const defineFactory = (model, definition) => {
2203
2215
  * @since 0.1.0
2204
2216
  */
2205
2217
  var ModelNotFoundException = class extends ArkormException {
2206
- constructor(message = "No query results for the given model.") {
2218
+ modelName;
2219
+ constructor(modelName, message = "No query results for the given model.") {
2207
2220
  super(message);
2208
2221
  this.name = "ModelNotFoundException";
2222
+ this.modelName = modelName;
2223
+ }
2224
+ getModelName() {
2225
+ return this.modelName;
2209
2226
  }
2210
2227
  };
2211
2228
 
@@ -3605,7 +3622,7 @@ var QueryBuilder = class QueryBuilder {
3605
3622
  */
3606
3623
  async firstOrFail() {
3607
3624
  const model = await this.first();
3608
- if (!model) throw new ModelNotFoundException("Record not found.");
3625
+ if (!model) throw new ModelNotFoundException(this.model.name, "Record not found.");
3609
3626
  return model;
3610
3627
  }
3611
3628
  async find(value, key = "id") {
@@ -3638,7 +3655,7 @@ var QueryBuilder = class QueryBuilder {
3638
3655
  */
3639
3656
  async valueOrFail(column) {
3640
3657
  const result = await this.value(column);
3641
- if (result == null) throw new ModelNotFoundException("Record not found.");
3658
+ if (result == null) throw new ModelNotFoundException(this.model.name, "Record not found.");
3642
3659
  return result;
3643
3660
  }
3644
3661
  /**
package/dist/index.d.cts CHANGED
@@ -2351,7 +2351,7 @@ declare class TableBuilder {
2351
2351
  *
2352
2352
  * @param name The name of the integer column.
2353
2353
  * @param options Additional options for the integer column.
2354
- * @returns
2354
+ * @returns The current TableBuilder instance for chaining.
2355
2355
  */
2356
2356
  integer(name: string, options?: Partial<SchemaColumn>): this;
2357
2357
  /**
@@ -2359,7 +2359,7 @@ declare class TableBuilder {
2359
2359
  *
2360
2360
  * @param name The name of the big integer column.
2361
2361
  * @param options Additional options for the big integer column.
2362
- * @returns
2362
+ * @returns The current TableBuilder instance for chaining.
2363
2363
  */
2364
2364
  bigInteger(name: string, options?: Partial<SchemaColumn>): this;
2365
2365
  /**
@@ -2367,15 +2367,23 @@ declare class TableBuilder {
2367
2367
  *
2368
2368
  * @param name The name of the float column.
2369
2369
  * @param options Additional options for the float column.
2370
- * @returns
2370
+ * @returns The current TableBuilder instance for chaining.
2371
2371
  */
2372
2372
  float(name: string, options?: Partial<SchemaColumn>): this;
2373
+ /**
2374
+ * Marks a column as unique in the table.
2375
+ *
2376
+ * @param name Optional explicit column name.
2377
+ * When omitted, applies to the latest defined column.
2378
+ * @returns The current TableBuilder instance for chaining.
2379
+ */
2380
+ unique(name?: string): this;
2373
2381
  /**
2374
2382
  * Defines a boolean column in the table.
2375
2383
  *
2376
2384
  * @param name The name of the boolean column.
2377
2385
  * @param options Additional options for the boolean column.
2378
- * @returns
2386
+ * @returns The current TableBuilder instance for chaining.
2379
2387
  */
2380
2388
  boolean(name: string, options?: Partial<SchemaColumn>): this;
2381
2389
  /**
@@ -2630,7 +2638,9 @@ declare class ArkormException extends Error {
2630
2638
  * @since 0.1.0
2631
2639
  */
2632
2640
  declare class ModelNotFoundException extends ArkormException {
2633
- constructor(message?: string);
2641
+ private modelName;
2642
+ constructor(modelName: string, message?: string);
2643
+ getModelName(): string;
2634
2644
  }
2635
2645
  //#endregion
2636
2646
  //#region src/helpers/migrations.d.ts
package/dist/index.d.mts CHANGED
@@ -2351,7 +2351,7 @@ declare class TableBuilder {
2351
2351
  *
2352
2352
  * @param name The name of the integer column.
2353
2353
  * @param options Additional options for the integer column.
2354
- * @returns
2354
+ * @returns The current TableBuilder instance for chaining.
2355
2355
  */
2356
2356
  integer(name: string, options?: Partial<SchemaColumn>): this;
2357
2357
  /**
@@ -2359,7 +2359,7 @@ declare class TableBuilder {
2359
2359
  *
2360
2360
  * @param name The name of the big integer column.
2361
2361
  * @param options Additional options for the big integer column.
2362
- * @returns
2362
+ * @returns The current TableBuilder instance for chaining.
2363
2363
  */
2364
2364
  bigInteger(name: string, options?: Partial<SchemaColumn>): this;
2365
2365
  /**
@@ -2367,15 +2367,23 @@ declare class TableBuilder {
2367
2367
  *
2368
2368
  * @param name The name of the float column.
2369
2369
  * @param options Additional options for the float column.
2370
- * @returns
2370
+ * @returns The current TableBuilder instance for chaining.
2371
2371
  */
2372
2372
  float(name: string, options?: Partial<SchemaColumn>): this;
2373
+ /**
2374
+ * Marks a column as unique in the table.
2375
+ *
2376
+ * @param name Optional explicit column name.
2377
+ * When omitted, applies to the latest defined column.
2378
+ * @returns The current TableBuilder instance for chaining.
2379
+ */
2380
+ unique(name?: string): this;
2373
2381
  /**
2374
2382
  * Defines a boolean column in the table.
2375
2383
  *
2376
2384
  * @param name The name of the boolean column.
2377
2385
  * @param options Additional options for the boolean column.
2378
- * @returns
2386
+ * @returns The current TableBuilder instance for chaining.
2379
2387
  */
2380
2388
  boolean(name: string, options?: Partial<SchemaColumn>): this;
2381
2389
  /**
@@ -2630,7 +2638,9 @@ declare class ArkormException extends Error {
2630
2638
  * @since 0.1.0
2631
2639
  */
2632
2640
  declare class ModelNotFoundException extends ArkormException {
2633
- constructor(message?: string);
2641
+ private modelName;
2642
+ constructor(modelName: string, message?: string);
2643
+ getModelName(): string;
2634
2644
  }
2635
2645
  //#endregion
2636
2646
  //#region src/helpers/migrations.d.ts
package/dist/index.mjs CHANGED
@@ -165,7 +165,7 @@ var TableBuilder = class {
165
165
  *
166
166
  * @param name The name of the integer column.
167
167
  * @param options Additional options for the integer column.
168
- * @returns
168
+ * @returns The current TableBuilder instance for chaining.
169
169
  */
170
170
  integer(name, options = {}) {
171
171
  return this.column(name, "integer", options);
@@ -175,7 +175,7 @@ var TableBuilder = class {
175
175
  *
176
176
  * @param name The name of the big integer column.
177
177
  * @param options Additional options for the big integer column.
178
- * @returns
178
+ * @returns The current TableBuilder instance for chaining.
179
179
  */
180
180
  bigInteger(name, options = {}) {
181
181
  return this.column(name, "bigInteger", options);
@@ -185,17 +185,29 @@ var TableBuilder = class {
185
185
  *
186
186
  * @param name The name of the float column.
187
187
  * @param options Additional options for the float column.
188
- * @returns
188
+ * @returns The current TableBuilder instance for chaining.
189
189
  */
190
190
  float(name, options = {}) {
191
191
  return this.column(name, "float", options);
192
192
  }
193
193
  /**
194
+ * Marks a column as unique in the table.
195
+ *
196
+ * @param name Optional explicit column name.
197
+ * When omitted, applies to the latest defined column.
198
+ * @returns The current TableBuilder instance for chaining.
199
+ */
200
+ unique(name) {
201
+ const column = this.resolveColumn(name);
202
+ column.unique = true;
203
+ return this;
204
+ }
205
+ /**
194
206
  * Defines a boolean column in the table.
195
207
  *
196
208
  * @param name The name of the boolean column.
197
209
  * @param options Additional options for the boolean column.
198
- * @returns
210
+ * @returns The current TableBuilder instance for chaining.
199
211
  */
200
212
  boolean(name, options = {}) {
201
213
  return this.column(name, "boolean", options);
@@ -2174,9 +2186,14 @@ const defineFactory = (model, definition) => {
2174
2186
  * @since 0.1.0
2175
2187
  */
2176
2188
  var ModelNotFoundException = class extends ArkormException {
2177
- constructor(message = "No query results for the given model.") {
2189
+ modelName;
2190
+ constructor(modelName, message = "No query results for the given model.") {
2178
2191
  super(message);
2179
2192
  this.name = "ModelNotFoundException";
2193
+ this.modelName = modelName;
2194
+ }
2195
+ getModelName() {
2196
+ return this.modelName;
2180
2197
  }
2181
2198
  };
2182
2199
 
@@ -3576,7 +3593,7 @@ var QueryBuilder = class QueryBuilder {
3576
3593
  */
3577
3594
  async firstOrFail() {
3578
3595
  const model = await this.first();
3579
- if (!model) throw new ModelNotFoundException("Record not found.");
3596
+ if (!model) throw new ModelNotFoundException(this.model.name, "Record not found.");
3580
3597
  return model;
3581
3598
  }
3582
3599
  async find(value, key = "id") {
@@ -3609,7 +3626,7 @@ var QueryBuilder = class QueryBuilder {
3609
3626
  */
3610
3627
  async valueOrFail(column) {
3611
3628
  const result = await this.value(column);
3612
- if (result == null) throw new ModelNotFoundException("Record not found.");
3629
+ if (result == null) throw new ModelNotFoundException(this.model.name, "Record not found.");
3613
3630
  return result;
3614
3631
  }
3615
3632
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arkormx",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Modern TypeScript-first ORM for Node.js.",
5
5
  "keywords": [
6
6
  "orm",