@loomcore/api 0.0.55 → 0.0.58

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.
@@ -20,13 +20,18 @@ export class MultiTenantApiService extends GenericApiService {
20
20
  return this.tenantDecorator.applyTenantToQuery(userContext, query, this.pluralResourceName);
21
21
  }
22
22
  prepareQueryOptions(userContext, queryOptions) {
23
+ console.log('--- MultiTenantApiService.prepareQueryOptions ---');
24
+ console.log('Initial queryOptions.filters:', JSON.stringify(queryOptions.filters, null, 2));
23
25
  if (!config?.app?.isMultiTenant) {
24
26
  return super.prepareQueryOptions(userContext, queryOptions);
25
27
  }
26
28
  if (!userContext || !userContext._orgId) {
27
29
  throw new BadRequestError('A valid userContext was not provided to MultiTenantApiService.prepareQueryOptions');
28
30
  }
29
- return this.tenantDecorator.applyTenantToQueryOptions(userContext, queryOptions, this.pluralResourceName);
31
+ const newQueryOptions = this.tenantDecorator.applyTenantToQueryOptions(userContext, queryOptions, this.pluralResourceName);
32
+ console.log('Final queryOptions.filters:', JSON.stringify(newQueryOptions.filters, null, 2));
33
+ console.log('-------------------------------------------------');
34
+ return newQueryOptions;
30
35
  }
31
36
  async prepareEntity(userContext, entity, isCreate, allowId = false) {
32
37
  if (!config?.app?.isMultiTenant) {
@@ -168,6 +168,9 @@ function buildMongoMatchFromQueryOptions(queryOptions, modelSpec) {
168
168
  const filters = queryOptions.filters || {};
169
169
  const schema = modelSpec?.fullSchema;
170
170
  let match = {};
171
+ console.log('--- Building Mongo Match ---');
172
+ console.log('Received queryOptions.filters:', JSON.stringify(filters, null, 2));
173
+ console.log('Received modelSpec:', !!modelSpec);
171
174
  for (const [key, value] of Object.entries(filters)) {
172
175
  if (value) {
173
176
  const propSchema = schema ? getPropertySchema(key, schema) : undefined;
@@ -217,6 +220,8 @@ function buildMongoMatchFromQueryOptions(queryOptions, modelSpec) {
217
220
  }
218
221
  }
219
222
  }
223
+ console.log('Constructed $match object:', JSON.stringify(match, null, 2));
224
+ console.log('--------------------------');
220
225
  return { $match: match };
221
226
  }
222
227
  function buildSQLWhereClauseFromQueryOptions(queryOptions, columnAliasMap) {
@@ -2,11 +2,15 @@ import express from 'express';
2
2
  import cookieParser from "cookie-parser";
3
3
  import bodyParser from "body-parser";
4
4
  import cors from "cors";
5
+ import qs from 'qs';
5
6
  import { NotFoundError } from "../errors/not-found.error.js";
6
7
  import { errorHandler } from "../middleware/error-handler.js";
7
8
  import { ensureUserContext } from '../middleware/ensure-user-context.js';
8
9
  function setupExpressApp(db, config, setupRoutes) {
9
10
  const app = express();
11
+ app.set('query parser', (str) => {
12
+ return qs.parse(str, {});
13
+ });
10
14
  app.use((req, res, next) => {
11
15
  if (req.path !== '/api/health' && process.env.NODE_ENV !== 'test') {
12
16
  console.log(`[${new Date().toLocaleString('en-US', { timeZone: 'America/Chicago' })}] INCOMING REQUEST: ${req.method} ${req.path}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loomcore/api",
3
- "version": "0.0.55",
3
+ "version": "0.0.58",
4
4
  "private": false,
5
5
  "description": "Loom Core Api - An opinionated Node.js api using Typescript, Express, and MongoDb",
6
6
  "scripts": {
@@ -41,7 +41,8 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "jsonwebtoken": "^9.0.2",
44
- "node-mailjet": "^6.0.8"
44
+ "node-mailjet": "^6.0.8",
45
+ "qs": "^6.14.0"
45
46
  },
46
47
  "peerDependencies": {
47
48
  "@loomcore/common": "^0.0.14",
@@ -60,6 +61,7 @@
60
61
  "@types/express": "^5.0.1",
61
62
  "@types/jsonwebtoken": "^9.0.9",
62
63
  "@types/lodash": "^4.17.13",
64
+ "@types/qs": "^6.14.0",
63
65
  "@types/supertest": "^6.0.3",
64
66
  "@vitest/coverage-v8": "^3.0.9",
65
67
  "cross-env": "^7.0.3",