bun-query-builder 0.1.16 → 0.1.17

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/bin/cli.js CHANGED
@@ -18905,21 +18905,6 @@ class ModelInstance {
18905
18905
  }
18906
18906
  return out;
18907
18907
  }
18908
- toArray() {
18909
- const out = { ...this._attributes };
18910
- for (const [name, rel] of Object.entries(this._relations)) {
18911
- if (rel == null) {
18912
- out[name] = null;
18913
- } else if (Array.isArray(rel)) {
18914
- out[name] = rel.map((r2) => r2 && typeof r2.toArray === "function" ? r2.toArray() : r2);
18915
- } else if (typeof rel.toArray === "function") {
18916
- out[name] = rel.toArray();
18917
- } else {
18918
- out[name] = rel;
18919
- }
18920
- }
18921
- return out;
18922
- }
18923
18908
  getRelation(name) {
18924
18909
  return this._relations[name];
18925
18910
  }
@@ -24007,7 +23992,7 @@ var prefix = getPrefix();
24007
23992
  var color18 = __toESM(require_picocolors(), 1);
24008
23993
  var import_picocolors19 = __toESM(require_picocolors(), 1);
24009
23994
  // package.json
24010
- var version2 = "0.1.16";
23995
+ var version2 = "0.1.17";
24011
23996
 
24012
23997
  // bin/cli.ts
24013
23998
  init_actions();
package/dist/browser.d.ts CHANGED
@@ -62,11 +62,11 @@ export declare const browserAuth: {
62
62
  /**
63
63
  * Login and store token
64
64
  */
65
- async login: (credentials: { email: string, password: string }) => Promise<;
65
+ async login: (credentials: BrowserAuthCredentials) => Promise<BrowserAuthResult>;
66
66
  /**
67
67
  * Register a new user
68
68
  */
69
- async register: (data: { name: string, email: string, password: string }) => Promise<;
69
+ async register: (data: BrowserAuthRegistrationData) => Promise<BrowserAuthResult>;
70
70
  /**
71
71
  * Logout and clear token
72
72
  */
@@ -159,6 +159,17 @@ declare interface QueryState {
159
159
  selectColumns: string[]
160
160
  withRelations: string[]
161
161
  }
162
+ export declare interface BrowserAuthCredentials {
163
+ email: string
164
+ password: string
165
+ }
166
+ export declare interface BrowserAuthRegistrationData extends BrowserAuthCredentials {
167
+ name: string
168
+ }
169
+ export declare interface BrowserAuthResult {
170
+ user: Record<string, unknown>
171
+ token: string
172
+ }
162
173
  // Primitive type mappings
163
174
  declare type PrimitiveTypeMap = {
164
175
  string: string
@@ -247,7 +258,7 @@ declare type BrowserRelationNames<TDef> = | BrowserBelongsToNames<TDef>
247
258
  | BrowserHasOneThroughNames<TDef>
248
259
  | BrowserHasManyThroughNames<TDef>;
249
260
  // Types for query building
250
- export type WhereOperator = '=' | '!=' | '<' | '>' | '<=' | '>=' | 'like' | 'in' | 'not in' | 'is' | 'is not';
261
+ export type WhereOperator = '=' | '!=' | '<' | '>' | '<=' | '>=' | 'like' | 'not like' | 'in' | 'not in' | 'is' | 'is not';
251
262
  /**
252
263
  * Custom error class for browser query errors
253
264
  */
@@ -17,11 +17,11 @@ export declare function createRepository<T extends Record<string, any>>(manager:
17
17
  * oneToMany: (parentEntity: string,
18
18
  * childEntity: string,
19
19
  * parentIdField?: string,
20
- * childIdField?: string,) => { parent: SingleTableEntity, child: SingleTableEntity },
20
+ * childIdField?: string,) => OneToManyPattern,
21
21
  * manyToMany: (entityName: string,
22
22
  * relationName: string,
23
23
  * idField?: string,
24
- * relatedIdField?: string,) => { entity: SingleTableEntity, relation: SingleTableEntity },
24
+ * relatedIdField?: string,) => ManyToManyPattern,
25
25
  * hierarchical: (entityName: string, rootIdField?: string, pathField?: string) => SingleTableEntity
26
26
  * }
27
27
  * ```
@@ -38,20 +38,14 @@ export declare const SingleTablePatterns: {
38
38
  * Parent: PK=PARENT#<parentId>, SK=METADATA
39
39
  * Child: PK=PARENT#<parentId>, SK=CHILD#<childId>
40
40
  */
41
- oneToMany: (parentEntity: string,
42
- childEntity: string,
43
- parentIdField?: string,
44
- childIdField?: string,) => ;
41
+ oneToMany: (parentEntity: string, childEntity: string, parentIdField?: string, childIdField?: string,) => OneToManyPattern;
45
42
  /**
46
43
  * Many-to-many relationship pattern using adjacency list
47
44
  * Entity: PK=ENTITY#<entityId>, SK=METADATA
48
45
  * Relationship: PK=ENTITY#<entityId>, SK=RELATED#<relatedId>
49
46
  * Inverse: PK=ENTITY#<relatedId>, SK=RELATED#<entityId> (via GSI)
50
47
  */
51
- manyToMany: (entityName: string,
52
- relationName: string,
53
- idField?: string,
54
- relatedIdField?: string,) => ;
48
+ manyToMany: (entityName: string, relationName: string, idField?: string, relatedIdField?: string,) => ManyToManyPattern;
55
49
  /**
56
50
  * Hierarchical data pattern (e.g., org chart, file system)
57
51
  * PK: ROOT#<rootId>
@@ -92,6 +86,14 @@ export declare interface SingleTableConfig {
92
86
  }[]
93
87
  entities: SingleTableEntity[]
94
88
  }
89
+ export declare interface OneToManyPattern {
90
+ parent: SingleTableEntity
91
+ child: SingleTableEntity
92
+ }
93
+ export declare interface ManyToManyPattern {
94
+ entity: SingleTableEntity
95
+ relation: SingleTableEntity
96
+ }
95
97
  /**
96
98
  * Single Table Design Manager
97
99
  *
package/dist/orm.d.ts CHANGED
@@ -208,7 +208,7 @@ export type InferRelationNames<TDef> = | InferBelongsToNames<TDef>
208
208
  | InferBelongsToManyNames<TDef>
209
209
  | InferHasOneThroughNames<TDef>
210
210
  | InferHasManyThroughNames<TDef>;
211
- declare type WhereOperator = '=' | '!=' | '<' | '>' | '<=' | '>=' | 'like' | 'in' | 'not in';
211
+ declare type WhereOperator = '=' | '!=' | '<' | '>' | '<=' | '>=' | 'like' | 'not like' | 'in' | 'not in';
212
212
  /**
213
213
  * Model instance - represents a single database record
214
214
  */
@@ -220,7 +220,6 @@ declare class ModelInstance<TDef extends ModelDefinition, TSelected extends Colu
220
220
  set<K extends ColumnName<TDef>>(key: K, value: K extends keyof ModelAttributes<TDef> ? ModelAttributes<TDef>[K] : unknown): void;
221
221
  only<K extends TSelected>(keys: ReadonlyArray<K>): Partial<ModelAttributes<TDef>>;
222
222
  except<K extends TSelected>(keys: ReadonlyArray<K>): Partial<ModelAttributes<TDef>>;
223
- toArray(): Record<string, unknown>;
224
223
  getRelation(name: string): ModelInstance<any, any>[] | ModelInstance<any, any> | null | undefined;
225
224
  setRelation(name: string, data: ModelInstance<any, any>[] | ModelInstance<any, any> | null): void;
226
225
  getLoadedRelations(): Record<string, ModelInstance<any, any>[] | ModelInstance<any, any> | null>;
package/dist/src/index.js CHANGED
@@ -18893,21 +18893,6 @@ class ModelInstance {
18893
18893
  }
18894
18894
  return out;
18895
18895
  }
18896
- toArray() {
18897
- const out = { ...this._attributes };
18898
- for (const [name, rel] of Object.entries(this._relations)) {
18899
- if (rel == null) {
18900
- out[name] = null;
18901
- } else if (Array.isArray(rel)) {
18902
- out[name] = rel.map((r2) => r2 && typeof r2.toArray === "function" ? r2.toArray() : r2);
18903
- } else if (typeof rel.toArray === "function") {
18904
- out[name] = rel.toArray();
18905
- } else {
18906
- out[name] = rel;
18907
- }
18908
- }
18909
- return out;
18910
- }
18911
18896
  getRelation(name) {
18912
18897
  return this._relations[name];
18913
18898
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bun-query-builder",
3
3
  "type": "module",
4
- "version": "0.1.16",
4
+ "version": "0.1.17",
5
5
  "description": "A simple yet performant query builder for TypeScript. Built with Bun.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",