@classytic/arc 1.0.0 → 1.0.8
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/README.md +65 -35
- package/bin/arc.js +118 -103
- package/dist/BaseController-nNRS3vpA.d.ts +233 -0
- package/dist/adapters/index.d.ts +2 -2
- package/dist/{arcCorePlugin-DTPWXcZN.d.ts → arcCorePlugin-CAjBQtZB.d.ts} +1 -1
- package/dist/auth/index.d.ts +1 -1
- package/dist/cli/commands/generate.d.ts +16 -0
- package/dist/cli/commands/generate.js +334 -0
- package/dist/cli/commands/init.d.ts +24 -0
- package/dist/cli/commands/init.js +2425 -0
- package/dist/cli/index.d.ts +4 -43
- package/dist/cli/index.js +3160 -411
- package/dist/core/index.d.ts +220 -0
- package/dist/core/index.js +2764 -0
- package/dist/{createApp-pzUAkzbz.d.ts → createApp-CjN9zZSL.d.ts} +1 -1
- package/dist/docs/index.js +19 -11
- package/dist/factory/index.d.ts +4 -4
- package/dist/factory/index.js +6 -23
- package/dist/hooks/index.d.ts +1 -1
- package/dist/{index-DkAW8BXh.d.ts → index-D5QTob1X.d.ts} +32 -12
- package/dist/index.d.ts +7 -203
- package/dist/index.js +108 -113
- package/dist/org/index.d.ts +1 -1
- package/dist/permissions/index.js +5 -2
- package/dist/plugins/index.d.ts +2 -2
- package/dist/presets/index.d.ts +6 -6
- package/dist/presets/index.js +3 -1
- package/dist/presets/multiTenant.d.ts +1 -1
- package/dist/registry/index.d.ts +2 -2
- package/dist/testing/index.d.ts +2 -2
- package/dist/testing/index.js +6 -23
- package/dist/types/index.d.ts +1 -1
- package/dist/{types-0IPhH_NR.d.ts → types-zpN48n6B.d.ts} +1 -1
- package/dist/utils/index.d.ts +28 -4
- package/dist/utils/index.js +17 -8
- package/package.json +8 -14
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { q as ResourceDefinition, A as AnyRecord, y as CrudRepository } from '../index-D5QTob1X.js';
|
|
2
2
|
import Fastify, { FastifyInstance } from 'fastify';
|
|
3
|
-
import { C as CreateAppOptions } from '../types-
|
|
3
|
+
import { C as CreateAppOptions } from '../types-zpN48n6B.js';
|
|
4
4
|
import { Mock } from 'vitest';
|
|
5
5
|
import { Connection } from 'mongoose';
|
|
6
6
|
import '../types-B99TBmFV.js';
|
package/dist/testing/index.js
CHANGED
|
@@ -46935,9 +46935,7 @@ async function loadPlugin(name, logger) {
|
|
|
46935
46935
|
const err = error2;
|
|
46936
46936
|
const isModuleNotFound = err.message.includes("Cannot find module") || err.message.includes("Cannot find package") || err.message.includes("MODULE_NOT_FOUND") || err.message.includes("Could not resolve");
|
|
46937
46937
|
if (isModuleNotFound && OPTIONAL_PLUGINS.has(name)) {
|
|
46938
|
-
logger?.warn(
|
|
46939
|
-
`ℹ️ Optional plugin '${name}' skipped (${packageName} not installed)`
|
|
46940
|
-
);
|
|
46938
|
+
logger?.warn(`ℹ️ Optional plugin '${name}' skipped (${packageName} not installed)`);
|
|
46941
46939
|
return null;
|
|
46942
46940
|
}
|
|
46943
46941
|
if (isModuleNotFound) {
|
|
@@ -46976,10 +46974,7 @@ async function createApp(options2) {
|
|
|
46976
46974
|
});
|
|
46977
46975
|
if (config.helmet !== false) {
|
|
46978
46976
|
const helmet = await loadPlugin("helmet");
|
|
46979
|
-
await fastify.register(
|
|
46980
|
-
helmet,
|
|
46981
|
-
config.helmet ?? {}
|
|
46982
|
-
);
|
|
46977
|
+
await fastify.register(helmet, config.helmet ?? {});
|
|
46983
46978
|
fastify.log.info("✅ Helmet (security headers) enabled");
|
|
46984
46979
|
} else {
|
|
46985
46980
|
fastify.log.warn("⚠️ Helmet disabled - security headers not applied");
|
|
@@ -46999,20 +46994,14 @@ async function createApp(options2) {
|
|
|
46999
46994
|
}
|
|
47000
46995
|
if (config.rateLimit !== false) {
|
|
47001
46996
|
const rateLimit = await loadPlugin("rateLimit");
|
|
47002
|
-
await fastify.register(
|
|
47003
|
-
rateLimit,
|
|
47004
|
-
config.rateLimit ?? { max: 100, timeWindow: "1 minute" }
|
|
47005
|
-
);
|
|
46997
|
+
await fastify.register(rateLimit, config.rateLimit ?? { max: 100, timeWindow: "1 minute" });
|
|
47006
46998
|
fastify.log.info("✅ Rate limiting enabled");
|
|
47007
46999
|
} else {
|
|
47008
47000
|
fastify.log.warn("⚠️ Rate limiting disabled");
|
|
47009
47001
|
}
|
|
47010
47002
|
if (config.underPressure !== false) {
|
|
47011
47003
|
const underPressure = await loadPlugin("underPressure");
|
|
47012
|
-
await fastify.register(
|
|
47013
|
-
underPressure,
|
|
47014
|
-
config.underPressure ?? { exposeStatusRoute: true }
|
|
47015
|
-
);
|
|
47004
|
+
await fastify.register(underPressure, config.underPressure ?? { exposeStatusRoute: true });
|
|
47016
47005
|
fastify.log.info("✅ Health monitoring (under-pressure) enabled");
|
|
47017
47006
|
} else {
|
|
47018
47007
|
fastify.log.info("ℹ️ Health monitoring disabled");
|
|
@@ -47032,10 +47021,7 @@ async function createApp(options2) {
|
|
|
47032
47021
|
files: 10
|
|
47033
47022
|
}
|
|
47034
47023
|
};
|
|
47035
|
-
await fastify.register(multipart, {
|
|
47036
|
-
...multipartDefaults,
|
|
47037
|
-
...config.multipart
|
|
47038
|
-
});
|
|
47024
|
+
await fastify.register(multipart, { ...multipartDefaults, ...config.multipart });
|
|
47039
47025
|
fastify.log.info("✅ Multipart (file uploads) enabled");
|
|
47040
47026
|
}
|
|
47041
47027
|
}
|
|
@@ -47048,10 +47034,7 @@ async function createApp(options2) {
|
|
|
47048
47034
|
encoding: "utf8",
|
|
47049
47035
|
runFirst: true
|
|
47050
47036
|
};
|
|
47051
|
-
await fastify.register(rawBody, {
|
|
47052
|
-
...rawBodyDefaults,
|
|
47053
|
-
...config.rawBody
|
|
47054
|
-
});
|
|
47037
|
+
await fastify.register(rawBody, { ...rawBodyDefaults, ...config.rawBody });
|
|
47055
47038
|
fastify.log.info("✅ Raw body parsing enabled");
|
|
47056
47039
|
}
|
|
47057
47040
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { K as AdditionalRoute,
|
|
1
|
+
export { K as AdditionalRoute, A as AnyRecord, s as ApiResponse, ak as ArcDecorator, g as AuthHelpers, h as AuthPluginOptions, ar as Authenticator, aq as AuthenticatorContext, au as BaseControllerOptions, a4 as ConfigError, ax as ControllerHandler, t as ControllerLike, C as ControllerQueryOptions, B as CrudController, y as CrudRepository, e as CrudRouteKey, _ as CrudRouterOptions, G as CrudSchemas, N as EventDefinition, al as EventsDecorator, ay as FastifyHandler, u as FastifyRequestExtras, v as FastifyWithAuth, w as FastifyWithDecorators, E as FieldRule, a9 as GracefulShutdownOptions, a7 as HealthCheck, a8 as HealthOptions, I as IController, c as IControllerResponse, a as IRequestContext, aw as InferDoc, $ as InferDocType, a0 as InferResourceDoc, Y as IntrospectionData, i as IntrospectionPluginOptions, J as JWTPayload, ap as JwtContext, M as MiddlewareConfig, ao as MiddlewareHandler, ah as ObjectId, af as OpenApiSchemas, Z as OrgScopeOptions, O as OwnershipCheck, P as PaginatedResult, av as PaginationParams, ae as ParsedQuery, L as PresetFunction, at as PresetHook, f as PresetResult, x as QueryOptions, Q as QueryParserInterface, W as RegistryEntry, X as RegistryStats, b as RequestContext, aa as RequestIdOptions, d as RequestWithExtras, l as ResourceConfig, an as ResourceHooks, T as ResourceMetadata, am as ResourcePermissions, z as RouteHandler, R as RouteSchemaOptions, S as ServiceContext, as as TokenPair, a2 as TypedController, a3 as TypedRepository, a1 as TypedResourceConfig, ai as UserLike, U as UserOrganization, a6 as ValidateOptions, a5 as ValidationResult, aj as getUserId } from '../index-D5QTob1X.js';
|
|
2
2
|
export { RouteHandlerMethod } from 'fastify';
|
|
3
3
|
export { Document, Model } from 'mongoose';
|
|
4
4
|
export { P as PermissionCheck, a as PermissionContext, b as PermissionResult, U as UserBase } from '../types-B99TBmFV.js';
|
|
@@ -2,7 +2,7 @@ import { FastifyServerOptions } from 'fastify';
|
|
|
2
2
|
import { FastifyCorsOptions } from '@fastify/cors';
|
|
3
3
|
import { FastifyHelmetOptions } from '@fastify/helmet';
|
|
4
4
|
import { RateLimitOptions } from '@fastify/rate-limit';
|
|
5
|
-
import {
|
|
5
|
+
import { h as AuthPluginOptions } from './index-D5QTob1X.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Types for createApp factory
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -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 {
|
|
2
|
+
import { A as AnyRecord, Q as QueryParserInterface, ae as ParsedQuery } from '../index-D5QTob1X.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 };
|
package/dist/utils/index.js
CHANGED
|
@@ -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
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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", "
|
|
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
|
-
|
|
204
|
+
docs: {
|
|
205
205
|
type: "array",
|
|
206
206
|
items: itemSchema
|
|
207
207
|
},
|
|
208
|
-
pagination
|
|
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", "
|
|
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",
|
|
@@ -902,4 +911,4 @@ function createQueryParser(options) {
|
|
|
902
911
|
return new ArcQueryParser(options);
|
|
903
912
|
}
|
|
904
913
|
|
|
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 };
|
|
914
|
+
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.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "Resource-oriented backend framework for Fastify + MongoDB",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -120,15 +120,15 @@
|
|
|
120
120
|
},
|
|
121
121
|
"peerDependencies": {
|
|
122
122
|
"@classytic/mongokit": "^3.0.0",
|
|
123
|
+
"fastify": "^5.0.0",
|
|
124
|
+
"mongoose": "^8.0.0 || ^9.0.0",
|
|
123
125
|
"@fastify/cors": "^11.0.0",
|
|
124
126
|
"@fastify/helmet": "^13.0.0",
|
|
125
|
-
"@fastify/multipart": "^9.0.0",
|
|
126
127
|
"@fastify/rate-limit": "^10.0.0",
|
|
127
128
|
"@fastify/sensible": "^6.0.0",
|
|
128
129
|
"@fastify/under-pressure": "^9.0.0",
|
|
129
|
-
"fastify": "^
|
|
130
|
+
"@fastify/multipart": "^9.0.0",
|
|
130
131
|
"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": {
|
|
@@ -189,18 +189,12 @@
|
|
|
189
189
|
},
|
|
190
190
|
"devDependencies": {
|
|
191
191
|
"@classytic/mongokit": "^3.1.0",
|
|
192
|
-
"@fastify/cors": "^11.2.0",
|
|
193
|
-
"@fastify/helmet": "^13.0.2",
|
|
194
192
|
"@fastify/jwt": "^9.0.0",
|
|
195
|
-
"@fastify/multipart": "^9.
|
|
196
|
-
"@
|
|
197
|
-
"@fastify/sensible": "^6.0.4",
|
|
198
|
-
"@fastify/under-pressure": "^9.0.3",
|
|
199
|
-
"@types/jsonwebtoken": "^9.0.10",
|
|
193
|
+
"@fastify/multipart": "^9.0.0",
|
|
194
|
+
"@types/jsonwebtoken": "^9.0.0",
|
|
200
195
|
"@types/node": "^22.10.0",
|
|
201
|
-
"fastify": "^5.7.1",
|
|
202
196
|
"fastify-raw-body": "^5.0.0",
|
|
203
|
-
"jsonwebtoken": "^9.0.
|
|
197
|
+
"jsonwebtoken": "^9.0.0",
|
|
204
198
|
"mongodb-memory-server": "^11.0.1",
|
|
205
199
|
"tsup": "^8.3.5",
|
|
206
200
|
"typescript": "^5.7.2",
|
|
@@ -224,4 +218,4 @@
|
|
|
224
218
|
"type": "git",
|
|
225
219
|
"url": "https://github.com/classytic/arc.git"
|
|
226
220
|
}
|
|
227
|
-
}
|
|
221
|
+
}
|