@getstrata/bootstrap 0.2.0 → 0.2.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>;
@@ -12,12 +12,12 @@ declare function buildWhereClause<TEntity extends object>(tableName: string, whe
12
12
  clause: string;
13
13
  params: unknown[];
14
14
  };
15
- declare function buildAdvancedWhereClause<TEntity extends object>(tableName: string, where?: QueryWhere<TEntity>, whereNodes?: readonly WhereNode<TEntity>[]): {
15
+ declare function buildAdvancedWhereClause<TEntity extends object>(tableName: string, where?: QueryWhere<TEntity>, whereNodes?: readonly WhereNode<TEntity>[], params?: unknown[]): {
16
16
  clause: string;
17
17
  params: unknown[];
18
18
  };
19
19
  declare function resolveSoftDeleteColumn<TEntity>(table: TableDefinition<TEntity>): string | null;
20
- declare function buildQueryWhereClause<TEntity extends object>(table: TableDefinition<TEntity>, options?: Pick<QueryOptions<TEntity>, "where" | "withTrashed" | "onlyTrashed">, whereNodes?: readonly WhereNode<TEntity>[]): {
20
+ declare function buildQueryWhereClause<TEntity extends object>(table: TableDefinition<TEntity>, options?: Pick<QueryOptions<TEntity>, "where" | "withTrashed" | "onlyTrashed">, whereNodes?: readonly WhereNode<TEntity>[], params?: unknown[]): {
21
21
  clause: string;
22
22
  params: unknown[];
23
23
  };
package/dist/index.js CHANGED
@@ -595,7 +595,15 @@ import { join } from "path";
595
595
  import { pathToFileURL } from "url";
596
596
  async function loadDiscoveredModules() {
597
597
  const modulesDirectory = join(import.meta.dir, "../modules");
598
- const moduleNames = readdirSync(modulesDirectory, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
598
+ let moduleNames;
599
+ try {
600
+ moduleNames = readdirSync(modulesDirectory, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
601
+ } catch (error) {
602
+ if (error.code === "ENOENT") {
603
+ return [];
604
+ }
605
+ throw error;
606
+ }
599
607
  const modules = await Promise.all(moduleNames.map(async (moduleName) => {
600
608
  const moduleUrl = pathToFileURL(join(modulesDirectory, moduleName, "index.ts")).href;
601
609
  const loaded = await import(moduleUrl);
@@ -2032,8 +2040,7 @@ function buildWhereGroupClause(tableName, nodes, params) {
2032
2040
  }
2033
2041
  return result;
2034
2042
  }
2035
- function buildAdvancedWhereClause(tableName, where = {}, whereNodes = []) {
2036
- const params = [];
2043
+ function buildAdvancedWhereClause(tableName, where = {}, whereNodes = [], params = []) {
2037
2044
  const nodes = [];
2038
2045
  if (Object.keys(where).length > 0) {
2039
2046
  nodes.push({ kind: "and", where });
@@ -2068,18 +2075,18 @@ function appendSoftDeleteScope(table, options, clauses) {
2068
2075
  clauses.push(`${qualifiedColumn} IS NULL`);
2069
2076
  }
2070
2077
  }
2071
- function buildQueryWhereClause(table, options = {}, whereNodes = []) {
2072
- const { clause, params } = buildAdvancedWhereClause(table.name, options.where ?? {}, whereNodes);
2078
+ function buildQueryWhereClause(table, options = {}, whereNodes = [], params = []) {
2079
+ const { clause, params: whereParams } = buildAdvancedWhereClause(table.name, options.where ?? {}, whereNodes, params);
2073
2080
  const softDeleteClauses = [];
2074
2081
  appendSoftDeleteScope(table, options, softDeleteClauses);
2075
2082
  if (softDeleteClauses.length === 0) {
2076
- return { clause, params };
2083
+ return { clause, params: whereParams };
2077
2084
  }
2078
2085
  const base = clause.replace(/^ WHERE /, "");
2079
2086
  const scope = softDeleteClauses.join(" AND ");
2080
2087
  return {
2081
2088
  clause: base ? ` WHERE (${base}) AND ${scope}` : ` WHERE ${scope}`,
2082
- params
2089
+ params: whereParams
2083
2090
  };
2084
2091
  }
2085
2092
  function isQueryOrder(value) {
@@ -2183,8 +2190,7 @@ function getDefinedColumnEntries(table, values, options = {}) {
2183
2190
  function buildSelectQuery(table, options = {}, whereNodes = []) {
2184
2191
  const params = [];
2185
2192
  const columns = buildSelectList(table, options.select, params);
2186
- const { clause, params: whereParams } = buildQueryWhereClause(table, options, whereNodes);
2187
- params.push(...whereParams);
2193
+ const { clause } = buildQueryWhereClause(table, options, whereNodes, params);
2188
2194
  const joins = buildJoinClause(options.joins);
2189
2195
  const groupBy = buildGroupByClause(table.name, options.groupBy);
2190
2196
  const havingClause = buildHavingClause(table.name, options.having, params);
@@ -4102,7 +4108,6 @@ function createAppContext() {
4102
4108
  setActiveApplicationContext(appContext);
4103
4109
  return appContext;
4104
4110
  }
4105
- var appContext = createAppContext();
4106
4111
  // ../../src/bootstrap/createWebRoutes.ts
4107
4112
  import { join as join4 } from "path";
4108
4113
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getstrata/bootstrap",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Strata application bootstrap — HttpKernel, DI, web session helpers",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -73,7 +73,7 @@
73
73
  "access": "public"
74
74
  },
75
75
  "peerDependencies": {
76
- "@getstrata/core": "^0.5.0",
76
+ "@getstrata/core": "^0.5.4",
77
77
  "typescript": "^5.9.0"
78
78
  }
79
79
  }