@classytic/arc 1.0.5 → 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 +930 -0
- package/dist/BaseController-nNRS3vpA.d.ts +233 -0
- package/dist/adapters/index.d.ts +2 -2
- package/dist/{arcCorePlugin-Cqi7j5-_.d.ts → arcCorePlugin-CAjBQtZB.d.ts} +1 -1
- package/dist/auth/index.d.ts +1 -1
- package/dist/cli/commands/init.js +21 -6
- package/dist/cli/index.js +21 -6
- package/dist/core/index.d.ts +220 -0
- package/dist/core/index.js +2764 -0
- package/dist/{createApp-9q_I1la4.d.ts → createApp-CjN9zZSL.d.ts} +1 -1
- package/dist/factory/index.d.ts +4 -4
- package/dist/hooks/index.d.ts +1 -1
- package/dist/{index-WBEvhmWM.d.ts → index-D5QTob1X.d.ts} +1 -1
- package/dist/index.d.ts +7 -236
- package/dist/index.js +5 -2
- 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 +1 -1
- 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/types/index.d.ts +1 -1
- package/dist/{types-EBZBXrg-.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 +1 -1
package/dist/factory/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export { A as ArcFactory, c as createApp } from '../createApp-
|
|
2
|
-
import { C as CreateAppOptions } from '../types-
|
|
3
|
-
export { M as MultipartOptions, R as RawBodyOptions, U as UnderPressureOptions } from '../types-
|
|
1
|
+
export { A as ArcFactory, c as createApp } from '../createApp-CjN9zZSL.js';
|
|
2
|
+
import { C as CreateAppOptions } from '../types-zpN48n6B.js';
|
|
3
|
+
export { M as MultipartOptions, R as RawBodyOptions, U as UnderPressureOptions } from '../types-zpN48n6B.js';
|
|
4
4
|
import 'fastify';
|
|
5
5
|
import '@fastify/cors';
|
|
6
6
|
import '@fastify/helmet';
|
|
7
7
|
import '@fastify/rate-limit';
|
|
8
|
-
import '../index-
|
|
8
|
+
import '../index-D5QTob1X.js';
|
|
9
9
|
import 'mongoose';
|
|
10
10
|
import '../types-B99TBmFV.js';
|
|
11
11
|
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { ac as HookContext, ad as HookHandler, aH as HookOperation, aG as HookPhase, aI as HookRegistration, H as HookSystem, aJ as HookSystemOptions, aB as afterCreate, aF as afterDelete, aD as afterUpdate, aA as beforeCreate, aE as beforeDelete, aC as beforeUpdate, az as createHookSystem, ab as hookSystem } from '../index-
|
|
1
|
+
export { ac as HookContext, ad as HookHandler, aH as HookOperation, aG as HookPhase, aI as HookRegistration, H as HookSystem, aJ as HookSystemOptions, aB as afterCreate, aF as afterDelete, aD as afterUpdate, aA as beforeCreate, aE as beforeDelete, aC as beforeUpdate, az as createHookSystem, ab as hookSystem } from '../index-D5QTob1X.js';
|
|
2
2
|
import 'mongoose';
|
|
3
3
|
import 'fastify';
|
|
4
4
|
import '../types-B99TBmFV.js';
|
|
@@ -1319,4 +1319,4 @@ interface ValidationResult {
|
|
|
1319
1319
|
}
|
|
1320
1320
|
type AdapterFactory<TDoc> = (config: unknown) => DataAdapter<TDoc>;
|
|
1321
1321
|
|
|
1322
|
-
export { type InferDocType as $, type
|
|
1322
|
+
export { type InferDocType as $, type AnyRecord as A, type CrudController as B, type ControllerQueryOptions as C, type DataAdapter as D, type FieldRule as E, type FieldMetadata as F, type CrudSchemas as G, HookSystem as H, type IController as I, type JWTPayload as J, type AdditionalRoute as K, type PresetFunction as L, type MiddlewareConfig as M, type EventDefinition as N, type OwnershipCheck as O, type PaginatedResult as P, type QueryParserInterface as Q, type RouteSchemaOptions as R, type ServiceContext as S, type ResourceMetadata as T, type UserOrganization as U, type ValidationResult as V, type RegistryEntry as W, type RegistryStats as X, type IntrospectionData as Y, type OrgScopeOptions as Z, type CrudRouterOptions as _, type IRequestContext as a, type InferResourceDoc as a0, type TypedResourceConfig as a1, type TypedController as a2, type TypedRepository as a3, type ConfigError as a4, type ValidationResult$1 as a5, type ValidateOptions as a6, type HealthCheck as a7, type HealthOptions as a8, type GracefulShutdownOptions as a9, beforeCreate as aA, afterCreate as aB, beforeUpdate as aC, afterUpdate as aD, beforeDelete as aE, afterDelete as aF, type HookPhase as aG, type HookOperation as aH, type HookRegistration as aI, type HookSystemOptions as aJ, type RequestIdOptions as aa, hookSystem as ab, type HookContext as ac, type HookHandler as ad, type ParsedQuery as ae, type OpenApiSchemas as af, type AdapterFactory as ag, type ObjectId as ah, type UserLike as ai, getUserId as aj, type ArcDecorator as ak, type EventsDecorator as al, type ResourcePermissions as am, type ResourceHooks as an, type MiddlewareHandler as ao, type JwtContext as ap, type AuthenticatorContext as aq, type Authenticator as ar, type TokenPair as as, type PresetHook as at, type BaseControllerOptions as au, type PaginationParams as av, type InferDoc as aw, type ControllerHandler as ax, type FastifyHandler as ay, createHookSystem as az, type RequestContext as b, type IControllerResponse as c, type RequestWithExtras as d, type CrudRouteKey as e, type PresetResult as f, type AuthHelpers as g, type AuthPluginOptions as h, type IntrospectionPluginOptions as i, ResourceRegistry as j, type RegisterOptions as k, type ResourceConfig as l, type SchemaMetadata as m, type RelationMetadata as n, type RepositoryLike as o, defineResource as p, ResourceDefinition as q, resourceRegistry as r, type ApiResponse as s, type ControllerLike as t, type FastifyRequestExtras as u, type FastifyWithAuth as v, type FastifyWithDecorators as w, type QueryOptions as x, type CrudRepository as y, type RouteHandler as z };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,249 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { V as AdapterValidationResult, K as AdditionalRoute, s as ApiResponse,
|
|
1
|
+
import { l as ResourceConfig } from './index-D5QTob1X.js';
|
|
2
|
+
export { V as AdapterValidationResult, K as AdditionalRoute, A as AnyRecord, s as ApiResponse, h as AuthPluginOptions, a4 as ConfigError, t as ControllerLike, B as CrudController, y as CrudRepository, e as CrudRouteKey, _ as CrudRouterOptions, G as CrudSchemas, D as DataAdapter, N as EventDefinition, u as FastifyRequestExtras, v as FastifyWithAuth, w as FastifyWithDecorators, F as FieldMetadata, E as FieldRule, a9 as GracefulShutdownOptions, a7 as HealthCheck, a8 as HealthOptions, ac as HookContext, ad as HookHandler, H as HookSystem, I as IController, c as IControllerResponse, a as IRequestContext, $ as InferDocType, a0 as InferResourceDoc, Y as IntrospectionData, i as IntrospectionPluginOptions, J as JWTPayload, M as MiddlewareConfig, Z as OrgScopeOptions, O as OwnershipCheck, P as PaginatedResult, L as PresetFunction, f as PresetResult, x as QueryOptions, W as RegistryEntry, X as RegistryStats, n as RelationMetadata, o as RepositoryLike, b as RequestContext, aa as RequestIdOptions, d as RequestWithExtras, q as ResourceDefinition, T as ResourceMetadata, z as RouteHandler, R as RouteSchemaOptions, m as SchemaMetadata, S as ServiceContext, a2 as TypedController, a3 as TypedRepository, a1 as TypedResourceConfig, U as UserOrganization, a6 as ValidateOptions, a5 as ValidationResult, p as defineResource, ab as hookSystem, r as resourceRegistry } from './index-D5QTob1X.js';
|
|
3
3
|
export { MongooseAdapter, MongooseAdapterOptions, PrismaAdapter, PrismaAdapterOptions, createMongooseAdapter, createPrismaAdapter } from './adapters/index.js';
|
|
4
|
+
export { B as BaseController, a as BaseControllerOptions } from './BaseController-nNRS3vpA.js';
|
|
4
5
|
export { RouteHandlerMethod } from 'fastify';
|
|
5
6
|
export { P as PermissionCheck, a as PermissionContext, b as PermissionResult, U as UserBase } from './types-B99TBmFV.js';
|
|
6
7
|
export { A as ArcError, F as ForbiddenError, N as NotFoundError, U as UnauthorizedError, V as ValidationError } from './errors-8WIxGS_6.js';
|
|
7
|
-
export { e as gracefulShutdownPlugin, a as healthPlugin, _ as requestIdPlugin } from './arcCorePlugin-
|
|
8
|
+
export { e as gracefulShutdownPlugin, a as healthPlugin, _ as requestIdPlugin } from './arcCorePlugin-CAjBQtZB.js';
|
|
8
9
|
export { DomainEvent, EventHandler, eventPlugin } from './events/index.js';
|
|
9
10
|
export { allOf, allowPublic, anyOf, denyAll, requireAuth, requireOwnership, requireRoles, when } from './permissions/index.js';
|
|
10
|
-
export { A as ArcFactory, c as createApp } from './createApp-
|
|
11
|
-
export { C as CreateAppOptions } from './types-
|
|
11
|
+
export { A as ArcFactory, c as createApp } from './createApp-CjN9zZSL.js';
|
|
12
|
+
export { C as CreateAppOptions } from './types-zpN48n6B.js';
|
|
12
13
|
import 'mongoose';
|
|
13
14
|
import '@fastify/cors';
|
|
14
15
|
import '@fastify/helmet';
|
|
15
16
|
import '@fastify/rate-limit';
|
|
16
17
|
|
|
17
|
-
/**
|
|
18
|
-
* Base Controller - Framework-Agnostic CRUD Operations
|
|
19
|
-
*
|
|
20
|
-
* Implements IController interface for framework portability.
|
|
21
|
-
* Works with Fastify, Express, Next.js, or any framework via adapter pattern.
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* import { BaseController } from '@classytic/arc';
|
|
25
|
-
*
|
|
26
|
-
* // Use Arc's default query parser (works out of the box)
|
|
27
|
-
* class ProductController extends BaseController {
|
|
28
|
-
* constructor(repository: CrudRepository) {
|
|
29
|
-
* super(repository);
|
|
30
|
-
* }
|
|
31
|
-
* }
|
|
32
|
-
*
|
|
33
|
-
* // Or use MongoKit's parser for advanced MongoDB features ($lookup, aggregations)
|
|
34
|
-
* import { QueryParser } from '@classytic/mongokit';
|
|
35
|
-
* defineResource({
|
|
36
|
-
* name: 'product',
|
|
37
|
-
* queryParser: new QueryParser(),
|
|
38
|
-
* // ...
|
|
39
|
-
* });
|
|
40
|
-
*
|
|
41
|
-
* // Or use a custom parser for SQL databases
|
|
42
|
-
* defineResource({
|
|
43
|
-
* name: 'user',
|
|
44
|
-
* queryParser: new PgQueryParser(),
|
|
45
|
-
* // ...
|
|
46
|
-
* });
|
|
47
|
-
*/
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Flexible repository interface that accepts any repository shape
|
|
51
|
-
* Core CRUD methods use flexible signatures to work with any implementation
|
|
52
|
-
* Custom methods can be added via the index signature
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* // MongoKit repository with custom methods
|
|
56
|
-
* interface MyRepository extends FlexibleRepository {
|
|
57
|
-
* findByEmail(email: string): Promise<User>;
|
|
58
|
-
* customMethod(): Promise<void>;
|
|
59
|
-
* }
|
|
60
|
-
*/
|
|
61
|
-
interface FlexibleRepository {
|
|
62
|
-
getAll(...args: any[]): Promise<any>;
|
|
63
|
-
getById(...args: any[]): Promise<any>;
|
|
64
|
-
create(...args: any[]): Promise<any>;
|
|
65
|
-
update(...args: any[]): Promise<any>;
|
|
66
|
-
delete(...args: any[]): Promise<any>;
|
|
67
|
-
[key: string]: any;
|
|
68
|
-
}
|
|
69
|
-
interface BaseControllerOptions {
|
|
70
|
-
/** Schema options for field sanitization */
|
|
71
|
-
schemaOptions?: RouteSchemaOptions;
|
|
72
|
-
/**
|
|
73
|
-
* Query parser instance
|
|
74
|
-
* Default: Arc built-in query parser (adapter-agnostic).
|
|
75
|
-
* You can swap in MongoKit QueryParser, pgkit parser, etc.
|
|
76
|
-
*/
|
|
77
|
-
queryParser?: QueryParserInterface;
|
|
78
|
-
/** Maximum limit for pagination (default: 100) */
|
|
79
|
-
maxLimit?: number;
|
|
80
|
-
/** Default limit for pagination (default: 20) */
|
|
81
|
-
defaultLimit?: number;
|
|
82
|
-
/** Default sort field (default: '-createdAt') */
|
|
83
|
-
defaultSort?: string;
|
|
84
|
-
/** Resource name for hook execution (e.g., 'product' → 'product.created') */
|
|
85
|
-
resourceName?: string;
|
|
86
|
-
/** Disable automatic event emission (default: false) */
|
|
87
|
-
disableEvents?: boolean;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Framework-agnostic base controller implementing MongoKit's IController
|
|
91
|
-
*
|
|
92
|
-
* @template TDoc - The document type
|
|
93
|
-
* @template TRepository - The repository type (defaults to CrudRepository<TDoc>, preserves custom methods when specified)
|
|
94
|
-
*
|
|
95
|
-
* Use with Fastify adapter for Fastify integration (see createFastifyAdapter in createCrudRouter)
|
|
96
|
-
*
|
|
97
|
-
* @example
|
|
98
|
-
* // Without custom repository type (backward compatible)
|
|
99
|
-
* class SimpleController extends BaseController<Product> {
|
|
100
|
-
* constructor(repository: CrudRepository<Product>) {
|
|
101
|
-
* super(repository);
|
|
102
|
-
* }
|
|
103
|
-
* }
|
|
104
|
-
*
|
|
105
|
-
* @example
|
|
106
|
-
* // With custom repository type (type-safe access to custom methods)
|
|
107
|
-
* class ProductController extends BaseController<Product, ProductRepository> {
|
|
108
|
-
* constructor(repository: ProductRepository) {
|
|
109
|
-
* super(repository);
|
|
110
|
-
* }
|
|
111
|
-
*
|
|
112
|
-
* async customMethod(context: IRequestContext) {
|
|
113
|
-
* // TypeScript knows about ProductRepository's custom methods
|
|
114
|
-
* return await this.repository.findByCategory(...);
|
|
115
|
-
* }
|
|
116
|
-
* }
|
|
117
|
-
*/
|
|
118
|
-
declare class BaseController<TDoc = AnyRecord, TRepository extends FlexibleRepository = FlexibleRepository> implements IController<TDoc> {
|
|
119
|
-
protected repository: TRepository;
|
|
120
|
-
protected schemaOptions: RouteSchemaOptions;
|
|
121
|
-
protected queryParser: QueryParserInterface;
|
|
122
|
-
protected maxLimit: number;
|
|
123
|
-
protected defaultLimit: number;
|
|
124
|
-
protected defaultSort: string;
|
|
125
|
-
protected resourceName?: string;
|
|
126
|
-
protected disableEvents: boolean;
|
|
127
|
-
/** Preset field names for dynamic param reading */
|
|
128
|
-
protected _presetFields: {
|
|
129
|
-
slugField?: string;
|
|
130
|
-
parentField?: string;
|
|
131
|
-
};
|
|
132
|
-
constructor(repository: TRepository, options?: BaseControllerOptions);
|
|
133
|
-
/**
|
|
134
|
-
* Inject resource options from defineResource
|
|
135
|
-
*/
|
|
136
|
-
_setResourceOptions(options: {
|
|
137
|
-
schemaOptions?: RouteSchemaOptions;
|
|
138
|
-
presetFields?: {
|
|
139
|
-
slugField?: string;
|
|
140
|
-
parentField?: string;
|
|
141
|
-
};
|
|
142
|
-
resourceName?: string;
|
|
143
|
-
queryParser?: QueryParserInterface;
|
|
144
|
-
}): void;
|
|
145
|
-
/**
|
|
146
|
-
* Build service context from IRequestContext
|
|
147
|
-
*/
|
|
148
|
-
protected _buildContext(req: IRequestContext): ServiceContext;
|
|
149
|
-
/**
|
|
150
|
-
* Parse query into QueryOptions using queryParser
|
|
151
|
-
*/
|
|
152
|
-
protected _parseQueryOptions(req: IRequestContext): ControllerQueryOptions;
|
|
153
|
-
/**
|
|
154
|
-
* Apply org and policy filters
|
|
155
|
-
*/
|
|
156
|
-
protected _applyFilters(options: ControllerQueryOptions, req: IRequestContext): ControllerQueryOptions;
|
|
157
|
-
/**
|
|
158
|
-
* Build filter for single-item operations (get/update/delete)
|
|
159
|
-
* Combines ID filter with policy/org filters for proper security enforcement
|
|
160
|
-
*/
|
|
161
|
-
protected _buildIdFilter(id: string, req: IRequestContext): AnyRecord;
|
|
162
|
-
/**
|
|
163
|
-
* Check if a value matches a MongoDB query operator
|
|
164
|
-
*/
|
|
165
|
-
protected _matchesOperator(itemValue: unknown, operator: string, filterValue: unknown): boolean;
|
|
166
|
-
/**
|
|
167
|
-
* Forbidden paths that could lead to prototype pollution
|
|
168
|
-
*/
|
|
169
|
-
private static readonly FORBIDDEN_PATHS;
|
|
170
|
-
/**
|
|
171
|
-
* Get nested value from object using dot notation (e.g., "owner.id")
|
|
172
|
-
* Security: Validates path against forbidden patterns to prevent prototype pollution
|
|
173
|
-
*/
|
|
174
|
-
protected _getNestedValue(obj: AnyRecord, path: string): unknown;
|
|
175
|
-
/**
|
|
176
|
-
* Check if item matches a single filter condition
|
|
177
|
-
* Supports nested paths (e.g., "owner.id", "metadata.status")
|
|
178
|
-
*/
|
|
179
|
-
protected _matchesFilter(item: AnyRecord, key: string, filterValue: unknown): boolean;
|
|
180
|
-
/**
|
|
181
|
-
* Check if item matches policy filters (for get/update/delete operations)
|
|
182
|
-
* Validates that fetched item satisfies all policy constraints
|
|
183
|
-
* Supports MongoDB query operators: $eq, $ne, $gt, $gte, $lt, $lte, $in, $nin, $exists, $regex, $and, $or
|
|
184
|
-
*/
|
|
185
|
-
protected _checkPolicyFilters(item: AnyRecord, req: IRequestContext): boolean;
|
|
186
|
-
/** Parse lean option (default: true for performance) */
|
|
187
|
-
protected _parseLean(leanValue: unknown): boolean;
|
|
188
|
-
/** Get blocked fields from schema options */
|
|
189
|
-
protected _getBlockedFields(schemaOptions: RouteSchemaOptions): string[];
|
|
190
|
-
/**
|
|
191
|
-
* Convert parsed select object to string format
|
|
192
|
-
* Converts { name: 1, email: 1, password: 0 } → 'name email -password'
|
|
193
|
-
*/
|
|
194
|
-
protected _selectToString(select: string | string[] | Record<string, 0 | 1> | undefined): string | undefined;
|
|
195
|
-
/** Sanitize select fields */
|
|
196
|
-
protected _sanitizeSelect(select: string | undefined, schemaOptions: RouteSchemaOptions): string | undefined;
|
|
197
|
-
/** Sanitize populate fields */
|
|
198
|
-
protected _sanitizePopulate(populate: unknown, schemaOptions: RouteSchemaOptions): string[] | undefined;
|
|
199
|
-
/** Check org scope for a document */
|
|
200
|
-
protected _checkOrgScope(item: AnyRecord | null, arcContext: RequestContext | undefined): boolean;
|
|
201
|
-
/** Check ownership for update/delete (ownedByUser preset) */
|
|
202
|
-
protected _checkOwnership(item: AnyRecord | null, req: IRequestContext): boolean;
|
|
203
|
-
/**
|
|
204
|
-
* Get hook system from context (instance-scoped) or fall back to global singleton
|
|
205
|
-
* This allows proper isolation when running multiple app instances (e.g., in tests)
|
|
206
|
-
*/
|
|
207
|
-
protected _getHooks(req: IRequestContext): HookSystem;
|
|
208
|
-
/**
|
|
209
|
-
* List resources with filtering, pagination, sorting
|
|
210
|
-
* Implements IController.list()
|
|
211
|
-
*/
|
|
212
|
-
list(req: IRequestContext): Promise<IControllerResponse<PaginatedResult<TDoc>>>;
|
|
213
|
-
/**
|
|
214
|
-
* Get single resource by ID
|
|
215
|
-
* Implements IController.get()
|
|
216
|
-
*/
|
|
217
|
-
get(req: IRequestContext): Promise<IControllerResponse<TDoc>>;
|
|
218
|
-
/**
|
|
219
|
-
* Create new resource
|
|
220
|
-
* Implements IController.create()
|
|
221
|
-
*/
|
|
222
|
-
create(req: IRequestContext): Promise<IControllerResponse<TDoc>>;
|
|
223
|
-
/**
|
|
224
|
-
* Update existing resource
|
|
225
|
-
* Implements IController.update()
|
|
226
|
-
*/
|
|
227
|
-
update(req: IRequestContext): Promise<IControllerResponse<TDoc>>;
|
|
228
|
-
/**
|
|
229
|
-
* Delete resource
|
|
230
|
-
* Implements IController.delete()
|
|
231
|
-
*/
|
|
232
|
-
delete(req: IRequestContext): Promise<IControllerResponse<{
|
|
233
|
-
message: string;
|
|
234
|
-
}>>;
|
|
235
|
-
/** Get resource by slug (slugLookup preset) */
|
|
236
|
-
getBySlug(req: IRequestContext): Promise<IControllerResponse<TDoc>>;
|
|
237
|
-
/** Get soft-deleted resources (softDelete preset) */
|
|
238
|
-
getDeleted(req: IRequestContext): Promise<IControllerResponse<PaginatedResult<TDoc>>>;
|
|
239
|
-
/** Restore soft-deleted resource (softDelete preset) */
|
|
240
|
-
restore(req: IRequestContext): Promise<IControllerResponse<TDoc>>;
|
|
241
|
-
/** Get hierarchical tree (tree preset) */
|
|
242
|
-
getTree(req: IRequestContext): Promise<IControllerResponse<TDoc[]>>;
|
|
243
|
-
/** Get children of parent (tree preset) */
|
|
244
|
-
getChildren(req: IRequestContext): Promise<IControllerResponse<TDoc[]>>;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
18
|
/**
|
|
248
19
|
* Resource Configuration Validator
|
|
249
20
|
*
|
|
@@ -361,4 +132,4 @@ declare function assertValidConfig(config: ResourceConfig, options?: ValidateOpt
|
|
|
361
132
|
|
|
362
133
|
declare const version = "1.0.0";
|
|
363
134
|
|
|
364
|
-
export {
|
|
135
|
+
export { ResourceConfig, assertValidConfig, formatValidationErrors, validateResourceConfig, version };
|
package/dist/index.js
CHANGED
|
@@ -3306,15 +3306,16 @@ function allowPublic() {
|
|
|
3306
3306
|
return check;
|
|
3307
3307
|
}
|
|
3308
3308
|
function requireAuth() {
|
|
3309
|
-
|
|
3309
|
+
const check = (ctx) => {
|
|
3310
3310
|
if (!ctx.user) {
|
|
3311
3311
|
return { granted: false, reason: "Authentication required" };
|
|
3312
3312
|
}
|
|
3313
3313
|
return true;
|
|
3314
3314
|
};
|
|
3315
|
+
return check;
|
|
3315
3316
|
}
|
|
3316
3317
|
function requireRoles(roles, options) {
|
|
3317
|
-
|
|
3318
|
+
const check = (ctx) => {
|
|
3318
3319
|
if (!ctx.user) {
|
|
3319
3320
|
return { granted: false, reason: "Authentication required" };
|
|
3320
3321
|
}
|
|
@@ -3330,6 +3331,8 @@ function requireRoles(roles, options) {
|
|
|
3330
3331
|
reason: `Required roles: ${roles.join(", ")}`
|
|
3331
3332
|
};
|
|
3332
3333
|
};
|
|
3334
|
+
check._roles = roles;
|
|
3335
|
+
return check;
|
|
3333
3336
|
}
|
|
3334
3337
|
function requireOwnership(ownerField = "userId", options) {
|
|
3335
3338
|
return (ctx) => {
|
package/dist/org/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RouteHandlerMethod, FastifyPluginAsync } from 'fastify';
|
|
2
|
-
import {
|
|
2
|
+
import { b as RequestContext, Z as OrgScopeOptions, z as RouteHandler } from '../index-D5QTob1X.js';
|
|
3
3
|
import { U as UserBase } from '../types-B99TBmFV.js';
|
|
4
4
|
import 'mongoose';
|
|
5
5
|
|
|
@@ -5,15 +5,16 @@ function allowPublic() {
|
|
|
5
5
|
return check;
|
|
6
6
|
}
|
|
7
7
|
function requireAuth() {
|
|
8
|
-
|
|
8
|
+
const check = (ctx) => {
|
|
9
9
|
if (!ctx.user) {
|
|
10
10
|
return { granted: false, reason: "Authentication required" };
|
|
11
11
|
}
|
|
12
12
|
return true;
|
|
13
13
|
};
|
|
14
|
+
return check;
|
|
14
15
|
}
|
|
15
16
|
function requireRoles(roles, options) {
|
|
16
|
-
|
|
17
|
+
const check = (ctx) => {
|
|
17
18
|
if (!ctx.user) {
|
|
18
19
|
return { granted: false, reason: "Authentication required" };
|
|
19
20
|
}
|
|
@@ -29,6 +30,8 @@ function requireRoles(roles, options) {
|
|
|
29
30
|
reason: `Required roles: ${roles.join(", ")}`
|
|
30
31
|
};
|
|
31
32
|
};
|
|
33
|
+
check._roles = roles;
|
|
34
|
+
return check;
|
|
32
35
|
}
|
|
33
36
|
function requireOwnership(ownerField = "userId", options) {
|
|
34
37
|
return (ctx) => {
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { k as ArcCore, A as ArcCorePluginOptions, G as GracefulShutdownOptions, b as HealthCheck, H as HealthOptions, R as RequestIdOptions, T as TracingOptions, f as arcCorePlugin, j as arcCorePluginFn, d as createSpan, e as gracefulShutdownPlugin, g as gracefulShutdownPluginFn, a as healthPlugin, h as healthPluginFn, i as isTracingAvailable, _ as requestIdPlugin, r as requestIdPluginFn, t as traced, c as tracingPlugin } from '../arcCorePlugin-
|
|
1
|
+
export { k as ArcCore, A as ArcCorePluginOptions, G as GracefulShutdownOptions, b as HealthCheck, H as HealthOptions, R as RequestIdOptions, T as TracingOptions, f as arcCorePlugin, j as arcCorePluginFn, d as createSpan, e as gracefulShutdownPlugin, g as gracefulShutdownPluginFn, a as healthPlugin, h as healthPluginFn, i as isTracingAvailable, _ as requestIdPlugin, r as requestIdPluginFn, t as traced, c as tracingPlugin } from '../arcCorePlugin-CAjBQtZB.js';
|
|
2
2
|
import { FastifyInstance, FastifyRequest } from 'fastify';
|
|
3
|
-
import '../index-
|
|
3
|
+
import '../index-D5QTob1X.js';
|
|
4
4
|
import 'mongoose';
|
|
5
5
|
import '../types-B99TBmFV.js';
|
|
6
6
|
|
package/dist/presets/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MultiTenantOptions } from './multiTenant.js';
|
|
2
2
|
export { default as multiTenantPreset } from './multiTenant.js';
|
|
3
|
-
import {
|
|
3
|
+
import { f as PresetResult, a as IRequestContext, c as IControllerResponse, P as PaginatedResult, A as AnyRecord, l as ResourceConfig } from '../index-D5QTob1X.js';
|
|
4
4
|
import 'mongoose';
|
|
5
5
|
import 'fastify';
|
|
6
6
|
import '../types-B99TBmFV.js';
|
package/dist/presets/index.js
CHANGED
|
@@ -5,7 +5,7 @@ function allowPublic() {
|
|
|
5
5
|
return check;
|
|
6
6
|
}
|
|
7
7
|
function requireRoles(roles, options) {
|
|
8
|
-
|
|
8
|
+
const check = (ctx) => {
|
|
9
9
|
if (!ctx.user) {
|
|
10
10
|
return { granted: false, reason: "Authentication required" };
|
|
11
11
|
}
|
|
@@ -18,6 +18,8 @@ function requireRoles(roles, options) {
|
|
|
18
18
|
reason: `Required roles: ${roles.join(", ")}`
|
|
19
19
|
};
|
|
20
20
|
};
|
|
21
|
+
check._roles = roles;
|
|
22
|
+
return check;
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
// src/presets/softDelete.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { d as RequestWithExtras, e as CrudRouteKey, f as PresetResult } from '../index-D5QTob1X.js';
|
|
2
2
|
import 'mongoose';
|
|
3
3
|
import 'fastify';
|
|
4
4
|
import '../types-B99TBmFV.js';
|
package/dist/registry/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { i as IntrospectionPluginOptions } from '../index-D5QTob1X.js';
|
|
2
|
+
export { k as RegisterOptions, j as ResourceRegistry, r as resourceRegistry } from '../index-D5QTob1X.js';
|
|
3
3
|
import { FastifyPluginAsync } from 'fastify';
|
|
4
4
|
import 'mongoose';
|
|
5
5
|
import '../types-B99TBmFV.js';
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { q as ResourceDefinition,
|
|
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/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 };
|