@classytic/arc 1.0.5 → 1.1.0

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.
@@ -1,5 +1,5 @@
1
1
  export { A as ArcError, C as ConflictError, E as ErrorDetails, F as ForbiddenError, N as NotFoundError, a as OrgAccessDeniedError, O as OrgRequiredError, R as RateLimitError, S as ServiceUnavailableError, U as UnauthorizedError, V as ValidationError, c as createError, i as isArcError } from '../errors-8WIxGS_6.js';
2
- import { d as AnyRecord, Q as QueryParserInterface, ae as ParsedQuery } from '../index-WBEvhmWM.js';
2
+ import { A as AnyRecord, Q as QueryParserInterface, ae as ParsedQuery } from '../index-B4t03KQ0.js';
3
3
  import 'mongoose';
4
4
  import 'fastify';
5
5
  import '../types-B99TBmFV.js';
@@ -29,7 +29,10 @@ declare const successResponseSchema: JsonSchema;
29
29
  */
30
30
  declare const errorResponseSchema: JsonSchema;
31
31
  /**
32
- * Pagination schema
32
+ * Pagination schema - matches MongoKit/Arc runtime format
33
+ *
34
+ * Runtime format (flat fields):
35
+ * { page, limit, total, pages, hasNext, hasPrev }
33
36
  */
34
37
  declare const paginationSchema: JsonSchema;
35
38
  /**
@@ -37,21 +40,42 @@ declare const paginationSchema: JsonSchema;
37
40
  */
38
41
  declare function wrapResponse(dataSchema: JsonSchema): JsonSchema;
39
42
  /**
40
- * Create a list response schema with pagination
43
+ * Create a list response schema with pagination - matches MongoKit/Arc runtime format
44
+ *
45
+ * Runtime format:
46
+ * { success, docs: [...], page, limit, total, pages, hasNext, hasPrev }
47
+ *
48
+ * Note: Uses 'docs' array (not 'data') with flat pagination fields
41
49
  */
42
50
  declare function listResponse(itemSchema: JsonSchema): JsonSchema;
51
+ /**
52
+ * Alias for listResponse - matches local responseSchemas.js naming
53
+ */
54
+ declare const paginateWrapper: typeof listResponse;
43
55
  /**
44
56
  * Create a single item response schema
57
+ *
58
+ * Runtime format: { success, data: {...} }
45
59
  */
46
60
  declare function itemResponse(itemSchema: JsonSchema): JsonSchema;
61
+ /**
62
+ * Alias for itemResponse - matches local responseSchemas.js naming
63
+ */
64
+ declare const itemWrapper: typeof itemResponse;
47
65
  /**
48
66
  * Create a create/update response schema
49
67
  */
50
68
  declare function mutationResponse(itemSchema: JsonSchema): JsonSchema;
51
69
  /**
52
70
  * Create a delete response schema
71
+ *
72
+ * Runtime format: { success, message }
53
73
  */
54
74
  declare function deleteResponse(): JsonSchema;
75
+ /**
76
+ * Alias for deleteResponse - matches local responseSchemas.js naming
77
+ */
78
+ declare const messageWrapper: typeof deleteResponse;
55
79
  declare const responses: {
56
80
  200: (schema: JsonSchema) => {
57
81
  description: string;
@@ -652,4 +676,4 @@ declare class ArcQueryParser implements QueryParserInterface {
652
676
  */
653
677
  declare function createQueryParser(options?: ArcQueryParserOptions): ArcQueryParser;
654
678
 
655
- export { ArcQueryParser, type ArcQueryParserOptions, CircuitBreaker, CircuitBreakerError, type CircuitBreakerOptions, CircuitBreakerRegistry, type CircuitBreakerStats, CircuitState, type JsonSchema, type StateMachine, type TransitionConfig, circuitBreakerRegistry, createCircuitBreaker, createQueryParser, createStateMachine, deleteResponse, errorResponseSchema, getListQueryParams, itemResponse, listResponse, mutationResponse, paginationSchema, queryParams, responses, successResponseSchema, wrapResponse };
679
+ export { ArcQueryParser, type ArcQueryParserOptions, CircuitBreaker, CircuitBreakerError, type CircuitBreakerOptions, CircuitBreakerRegistry, type CircuitBreakerStats, CircuitState, type JsonSchema, type StateMachine, type TransitionConfig, circuitBreakerRegistry, createCircuitBreaker, createQueryParser, createStateMachine, deleteResponse, errorResponseSchema, getListQueryParams, itemResponse, itemWrapper, listResponse, messageWrapper, mutationResponse, paginateWrapper, paginationSchema, queryParams, responses, successResponseSchema, wrapResponse };
@@ -180,11 +180,11 @@ var paginationSchema = {
180
180
  page: { type: "integer", example: 1 },
181
181
  limit: { type: "integer", example: 20 },
182
182
  total: { type: "integer", example: 100 },
183
- totalPages: { type: "integer", example: 5 },
184
- hasNextPage: { type: "boolean", example: true },
185
- hasPrevPage: { type: "boolean", example: false }
183
+ pages: { type: "integer", example: 5 },
184
+ hasNext: { type: "boolean", example: true },
185
+ hasPrev: { type: "boolean", example: false }
186
186
  },
187
- required: ["page", "limit", "total", "totalPages", "hasNextPage", "hasPrevPage"]
187
+ required: ["page", "limit", "total", "pages", "hasNext", "hasPrev"]
188
188
  };
189
189
  function wrapResponse(dataSchema) {
190
190
  return {
@@ -201,18 +201,26 @@ function listResponse(itemSchema) {
201
201
  type: "object",
202
202
  properties: {
203
203
  success: { type: "boolean", example: true },
204
- data: {
204
+ docs: {
205
205
  type: "array",
206
206
  items: itemSchema
207
207
  },
208
- pagination: paginationSchema
208
+ // Flat pagination fields (not nested)
209
+ page: { type: "integer", example: 1 },
210
+ limit: { type: "integer", example: 20 },
211
+ total: { type: "integer", example: 100 },
212
+ pages: { type: "integer", example: 5 },
213
+ hasNext: { type: "boolean", example: false },
214
+ hasPrev: { type: "boolean", example: false }
209
215
  },
210
- required: ["success", "data"]
216
+ required: ["success", "docs"]
211
217
  };
212
218
  }
219
+ var paginateWrapper = listResponse;
213
220
  function itemResponse(itemSchema) {
214
221
  return wrapResponse(itemSchema);
215
222
  }
223
+ var itemWrapper = itemResponse;
216
224
  function mutationResponse(itemSchema) {
217
225
  return {
218
226
  type: "object",
@@ -234,6 +242,7 @@ function deleteResponse() {
234
242
  required: ["success"]
235
243
  };
236
244
  }
245
+ var messageWrapper = deleteResponse;
237
246
  var responses = {
238
247
  200: (schema) => ({
239
248
  description: "Successful response",
@@ -842,6 +851,23 @@ var ArcQueryParser = class {
842
851
  for (const [key, value] of Object.entries(query)) {
843
852
  if (reservedKeys.has(key)) continue;
844
853
  if (value === void 0 || value === null) continue;
854
+ if (!/^[a-zA-Z_][a-zA-Z0-9_.]*$/.test(key)) continue;
855
+ if (typeof value === "object" && value !== null && !Array.isArray(value)) {
856
+ const operatorObj = value;
857
+ const operatorKeys = Object.keys(operatorObj);
858
+ const allOperators = operatorKeys.every((op) => this.operators[op]);
859
+ if (allOperators && operatorKeys.length > 0) {
860
+ const mongoFilters = {};
861
+ for (const [op, opValue] of Object.entries(operatorObj)) {
862
+ const mongoOp = this.operators[op];
863
+ if (mongoOp) {
864
+ mongoFilters[mongoOp] = this.parseFilterValue(opValue, op);
865
+ }
866
+ }
867
+ filters[key] = mongoFilters;
868
+ continue;
869
+ }
870
+ }
845
871
  const match = key.match(/^([a-zA-Z_][a-zA-Z0-9_.]*)(?:\[([a-z]+)\])?$/);
846
872
  if (!match) continue;
847
873
  const [, fieldName, operator] = match;
@@ -902,4 +928,4 @@ function createQueryParser(options) {
902
928
  return new ArcQueryParser(options);
903
929
  }
904
930
 
905
- export { ArcError, ArcQueryParser, CircuitBreaker, CircuitBreakerError, CircuitBreakerRegistry, CircuitState, ConflictError, ForbiddenError, NotFoundError, OrgAccessDeniedError, OrgRequiredError, RateLimitError, ServiceUnavailableError, UnauthorizedError, ValidationError, circuitBreakerRegistry, createCircuitBreaker, createError, createQueryParser, createStateMachine, deleteResponse, errorResponseSchema, getListQueryParams, isArcError, itemResponse, listResponse, mutationResponse, paginationSchema, queryParams, responses, successResponseSchema, wrapResponse };
931
+ export { ArcError, ArcQueryParser, CircuitBreaker, CircuitBreakerError, CircuitBreakerRegistry, CircuitState, ConflictError, ForbiddenError, NotFoundError, OrgAccessDeniedError, OrgRequiredError, RateLimitError, ServiceUnavailableError, UnauthorizedError, ValidationError, circuitBreakerRegistry, createCircuitBreaker, createError, createQueryParser, createStateMachine, deleteResponse, errorResponseSchema, getListQueryParams, isArcError, itemResponse, itemWrapper, listResponse, messageWrapper, mutationResponse, paginateWrapper, paginationSchema, queryParams, responses, successResponseSchema, wrapResponse };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@classytic/arc",
3
- "version": "1.0.5",
3
+ "version": "1.1.0",
4
4
  "description": "Resource-oriented backend framework for Fastify + MongoDB",
5
5
  "type": "module",
6
6
  "exports": {
@@ -119,16 +119,16 @@
119
119
  "node": ">=20"
120
120
  },
121
121
  "peerDependencies": {
122
- "@classytic/mongokit": "^3.0.0",
123
- "fastify": "^5.0.0",
124
- "mongoose": "^8.0.0 || ^9.0.0",
122
+ "@classytic/mongokit": "^3.1.6",
125
123
  "@fastify/cors": "^11.0.0",
126
124
  "@fastify/helmet": "^13.0.0",
125
+ "@fastify/multipart": "^9.0.0",
127
126
  "@fastify/rate-limit": "^10.0.0",
128
127
  "@fastify/sensible": "^6.0.0",
129
128
  "@fastify/under-pressure": "^9.0.0",
130
- "@fastify/multipart": "^9.0.0",
129
+ "fastify": "^5.0.0",
131
130
  "fastify-raw-body": "^5.0.0",
131
+ "mongoose": "^8.0.0 || ^9.0.0",
132
132
  "pino-pretty": "^13.0.0"
133
133
  },
134
134
  "peerDependenciesMeta": {
@@ -185,14 +185,16 @@
185
185
  }
186
186
  },
187
187
  "dependencies": {
188
- "fastify-plugin": "^5.0.1"
188
+ "fastify-plugin": "^5.0.1",
189
+ "qs": "^6.14.1"
189
190
  },
190
191
  "devDependencies": {
191
- "@classytic/mongokit": "^3.1.0",
192
+ "@classytic/mongokit": "^3.1.6",
192
193
  "@fastify/jwt": "^9.0.0",
193
194
  "@fastify/multipart": "^9.0.0",
194
195
  "@types/jsonwebtoken": "^9.0.0",
195
196
  "@types/node": "^22.10.0",
197
+ "@types/qs": "^6.14.0",
196
198
  "fastify-raw-body": "^5.0.0",
197
199
  "jsonwebtoken": "^9.0.0",
198
200
  "mongodb-memory-server": "^11.0.1",
@@ -218,4 +220,4 @@
218
220
  "type": "git",
219
221
  "url": "https://github.com/classytic/arc.git"
220
222
  }
221
- }
223
+ }