@sdflc/backend-helpers 1.0.131 → 1.0.132

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.
@@ -85,7 +85,15 @@ declare class BaseRestApiCrudController extends BaseController {
85
85
  *
86
86
  * Base implementation treats every query string key that is NOT a known
87
87
  * pagination key (pagination, sortBy) as a filter field. Override to
88
- * apply custom parsing (e.g. typed booleans, array values, renamed fields).
88
+ * apply custom parsing (e.g. array values, renamed fields).
89
+ *
90
+ * Coercions applied at the transport boundary so gateways receive the
91
+ * same types whether called from GraphQL or REST:
92
+ * 'true' → true
93
+ * 'false' → false
94
+ * 'null' → omitted (key excluded from filter entirely)
95
+ * 'undefined' → omitted (key excluded from filter entirely)
96
+ * anything else → left as string
89
97
  */
90
98
  protected buildFilter(req: any): Record<string, any>;
91
99
  /**
@@ -120,12 +120,35 @@ class BaseRestApiCrudController extends BaseController_1.BaseController {
120
120
  *
121
121
  * Base implementation treats every query string key that is NOT a known
122
122
  * pagination key (pagination, sortBy) as a filter field. Override to
123
- * apply custom parsing (e.g. typed booleans, array values, renamed fields).
123
+ * apply custom parsing (e.g. array values, renamed fields).
124
+ *
125
+ * Coercions applied at the transport boundary so gateways receive the
126
+ * same types whether called from GraphQL or REST:
127
+ * 'true' → true
128
+ * 'false' → false
129
+ * 'null' → omitted (key excluded from filter entirely)
130
+ * 'undefined' → omitted (key excluded from filter entirely)
131
+ * anything else → left as string
124
132
  */
125
133
  buildFilter(req) {
126
134
  const filter = {};
127
135
  for (const [key, value] of Object.entries(req.query ?? {})) {
128
- if (!PAGINATION_KEYS.has(key)) {
136
+ if (PAGINATION_KEYS.has(key)) {
137
+ continue;
138
+ }
139
+ if (value === 'null' || value === 'undefined') {
140
+ // Omit entirely — these express "no value" and should not constrain
141
+ // the query. Passing the string 'null' to a gateway that checks
142
+ // value == null would silently fail to filter.
143
+ continue;
144
+ }
145
+ if (value === 'true') {
146
+ filter[key] = true;
147
+ }
148
+ else if (value === 'false') {
149
+ filter[key] = false;
150
+ }
151
+ else {
129
152
  filter[key] = value;
130
153
  }
131
154
  }
@@ -85,7 +85,15 @@ declare class BaseRestApiCrudController extends BaseController {
85
85
  *
86
86
  * Base implementation treats every query string key that is NOT a known
87
87
  * pagination key (pagination, sortBy) as a filter field. Override to
88
- * apply custom parsing (e.g. typed booleans, array values, renamed fields).
88
+ * apply custom parsing (e.g. array values, renamed fields).
89
+ *
90
+ * Coercions applied at the transport boundary so gateways receive the
91
+ * same types whether called from GraphQL or REST:
92
+ * 'true' → true
93
+ * 'false' → false
94
+ * 'null' → omitted (key excluded from filter entirely)
95
+ * 'undefined' → omitted (key excluded from filter entirely)
96
+ * anything else → left as string
89
97
  */
90
98
  protected buildFilter(req: any): Record<string, any>;
91
99
  /**
@@ -117,12 +117,35 @@ class BaseRestApiCrudController extends BaseController {
117
117
  *
118
118
  * Base implementation treats every query string key that is NOT a known
119
119
  * pagination key (pagination, sortBy) as a filter field. Override to
120
- * apply custom parsing (e.g. typed booleans, array values, renamed fields).
120
+ * apply custom parsing (e.g. array values, renamed fields).
121
+ *
122
+ * Coercions applied at the transport boundary so gateways receive the
123
+ * same types whether called from GraphQL or REST:
124
+ * 'true' → true
125
+ * 'false' → false
126
+ * 'null' → omitted (key excluded from filter entirely)
127
+ * 'undefined' → omitted (key excluded from filter entirely)
128
+ * anything else → left as string
121
129
  */
122
130
  buildFilter(req) {
123
131
  const filter = {};
124
132
  for (const [key, value] of Object.entries(req.query ?? {})) {
125
- if (!PAGINATION_KEYS.has(key)) {
133
+ if (PAGINATION_KEYS.has(key)) {
134
+ continue;
135
+ }
136
+ if (value === 'null' || value === 'undefined') {
137
+ // Omit entirely — these express "no value" and should not constrain
138
+ // the query. Passing the string 'null' to a gateway that checks
139
+ // value == null would silently fail to filter.
140
+ continue;
141
+ }
142
+ if (value === 'true') {
143
+ filter[key] = true;
144
+ }
145
+ else if (value === 'false') {
146
+ filter[key] = false;
147
+ }
148
+ else {
126
149
  filter[key] = value;
127
150
  }
128
151
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdflc/backend-helpers",
3
- "version": "1.0.131",
3
+ "version": "1.0.132",
4
4
  "description": "Set of helper functions and classes to simplify building backend apps within @sdflc ecosystem",
5
5
  "type": "commonjs",
6
6
  "exports": {