@90soft/parse-server-kit 1.0.0 → 2.0.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.
- package/dist/decorators/cloudDecorator.d.ts +7 -0
- package/dist/decorators/cloudDecorator.d.ts.map +1 -0
- package/dist/decorators/cloudDecorator.js +77 -0
- package/dist/decorators/cloudDecorator.js.map +1 -0
- package/dist/decorators/cloudRegistry.d.ts +9 -0
- package/dist/decorators/cloudRegistry.d.ts.map +1 -0
- package/dist/decorators/cloudRegistry.js +26 -0
- package/dist/decorators/cloudRegistry.js.map +1 -0
- package/dist/decorators/cronDecorator.d.ts +6 -0
- package/dist/decorators/cronDecorator.d.ts.map +1 -0
- package/dist/decorators/cronDecorator.js +28 -0
- package/dist/decorators/cronDecorator.js.map +1 -0
- package/dist/decorators/cronRegistry.d.ts +13 -0
- package/dist/decorators/cronRegistry.d.ts.map +1 -0
- package/dist/decorators/cronRegistry.js +96 -0
- package/dist/decorators/cronRegistry.js.map +1 -0
- package/dist/decorators/routeDecorator.d.ts +35 -0
- package/dist/decorators/routeDecorator.d.ts.map +1 -0
- package/dist/decorators/routeDecorator.js +160 -0
- package/dist/decorators/routeDecorator.js.map +1 -0
- package/dist/decorators/triggerDecorator.d.ts +19 -0
- package/dist/decorators/triggerDecorator.d.ts.map +1 -0
- package/dist/decorators/triggerDecorator.js +45 -0
- package/dist/decorators/triggerDecorator.js.map +1 -0
- package/dist/decorators/triggerRegistry.d.ts +10 -0
- package/dist/decorators/triggerRegistry.d.ts.map +1 -0
- package/dist/decorators/triggerRegistry.js +87 -0
- package/dist/decorators/triggerRegistry.js.map +1 -0
- package/dist/decorators/types/cloudTypes.d.ts +32 -0
- package/dist/decorators/types/cloudTypes.d.ts.map +1 -0
- package/dist/decorators/types/cloudTypes.js +3 -0
- package/dist/decorators/types/cloudTypes.js.map +1 -0
- package/dist/decorators/types/common.d.ts +14 -0
- package/dist/decorators/types/common.d.ts.map +1 -0
- package/dist/decorators/types/common.js +3 -0
- package/dist/decorators/types/common.js.map +1 -0
- package/dist/decorators/types/cronTypes.d.ts +32 -0
- package/dist/decorators/types/cronTypes.d.ts.map +1 -0
- package/dist/decorators/types/cronTypes.js +21 -0
- package/dist/decorators/types/cronTypes.js.map +1 -0
- package/dist/decorators/types/fieldValidation.d.ts +36 -0
- package/dist/decorators/types/fieldValidation.d.ts.map +1 -0
- package/dist/decorators/types/fieldValidation.js +135 -0
- package/dist/decorators/types/fieldValidation.js.map +1 -0
- package/dist/decorators/types/triggerTypes.d.ts +14 -0
- package/dist/decorators/types/triggerTypes.d.ts.map +1 -0
- package/dist/decorators/types/triggerTypes.js +3 -0
- package/dist/decorators/types/triggerTypes.js.map +1 -0
- package/dist/index.d.ts +25 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +78 -6
- package/dist/index.js.map +1 -1
- package/dist/middleware/middleware.d.ts +36 -0
- package/dist/middleware/middleware.d.ts.map +1 -0
- package/dist/middleware/middleware.js +133 -0
- package/dist/middleware/middleware.js.map +1 -0
- package/dist/swagger/index.d.ts +9 -0
- package/dist/swagger/index.d.ts.map +1 -0
- package/dist/swagger/index.js +37 -0
- package/dist/swagger/index.js.map +1 -0
- package/dist/swagger/swaggerRegistry.d.ts +79 -0
- package/dist/swagger/swaggerRegistry.d.ts.map +1 -0
- package/dist/swagger/swaggerRegistry.js +115 -0
- package/dist/swagger/swaggerRegistry.js.map +1 -0
- package/dist/swagger/swaggerSpec.d.ts +69 -0
- package/dist/swagger/swaggerSpec.d.ts.map +1 -0
- package/dist/swagger/swaggerSpec.js +174 -0
- package/dist/swagger/swaggerSpec.js.map +1 -0
- package/dist/utils/ACL.d.ts +19 -0
- package/dist/utils/ACL.d.ts.map +1 -0
- package/dist/utils/ACL.js +35 -0
- package/dist/utils/ACL.js.map +1 -0
- package/dist/utils/constants.d.ts +13 -0
- package/dist/utils/constants.d.ts.map +1 -0
- package/dist/utils/constants.js +19 -0
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/dynamicImport.d.ts +2 -0
- package/dist/utils/dynamicImport.d.ts.map +1 -0
- package/dist/utils/dynamicImport.js +21 -0
- package/dist/utils/dynamicImport.js.map +1 -0
- package/dist/utils/helper.d.ts +15 -0
- package/dist/utils/helper.d.ts.map +1 -0
- package/dist/utils/helper.js +93 -0
- package/dist/utils/helper.js.map +1 -0
- package/package.json +21 -5
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import express, { NextFunction, Request, Response } from 'express';
|
|
2
|
+
/**
|
|
3
|
+
* Validates cloud function routes — supports both entity routes and legacy /functions routes.
|
|
4
|
+
*
|
|
5
|
+
* Entity routes: /api/students/create → resolves to 'createStudent'
|
|
6
|
+
* Legacy routes: /api/functions/createStudent → resolves directly
|
|
7
|
+
*
|
|
8
|
+
* Converts all requests to POST for Parse Server internal handling.
|
|
9
|
+
*/
|
|
10
|
+
export declare function validateFunctionRoutes(req: Request, res: Response, next: NextFunction): void | express.Response<any, Record<string, any>>;
|
|
11
|
+
/**
|
|
12
|
+
* Validates entity-based routes: /api/{entity}/{action}
|
|
13
|
+
* Resolves the route to a cloud function name and rewrites the URL
|
|
14
|
+
* to /functions/{functionName} so Parse Server can handle it.
|
|
15
|
+
*/
|
|
16
|
+
export declare function validateEntityRoutes(req: Request, res: Response, next: NextFunction): void | express.Response<any, Record<string, any>>;
|
|
17
|
+
/**
|
|
18
|
+
* Extracts master key from the request body during JSON parsing
|
|
19
|
+
*/
|
|
20
|
+
export declare function extractMasterKey(req: any, res: Response, buf: Buffer, encoding: BufferEncoding): void;
|
|
21
|
+
/**
|
|
22
|
+
* Restricts access to specific routes unless master key is provided.
|
|
23
|
+
* Only registered entity routes and system routes are allowed.
|
|
24
|
+
* /functions is NO LONGER allowed — use entity routes instead.
|
|
25
|
+
*/
|
|
26
|
+
export declare function restrictRoutes(req: any, res: Response, next: NextFunction): void;
|
|
27
|
+
/**
|
|
28
|
+
* Conditionally applies JSON parsing middleware, skipping file routes
|
|
29
|
+
*/
|
|
30
|
+
export declare function conditionalJsonMiddleware(req: Request, res: Response, next: NextFunction): void;
|
|
31
|
+
/**
|
|
32
|
+
* Removes the 'result' wrapper from Parse Server responses.
|
|
33
|
+
* Applies to all registered entity routes (no longer just /functions).
|
|
34
|
+
*/
|
|
35
|
+
export declare function removeResultMiddleware(req: any, res: any, next: any): any;
|
|
36
|
+
//# sourceMappingURL=middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/middleware/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAC,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAC,MAAM,SAAS,CAAC;AAKjE;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,YAAY,qDAenB;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,YAAY,qDAuBnB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,QAAQ,EACb,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,cAAc,QAUzB;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,QAwBzE;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,YAAY,QAYnB;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,OAoBnE"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.validateFunctionRoutes = validateFunctionRoutes;
|
|
7
|
+
exports.validateEntityRoutes = validateEntityRoutes;
|
|
8
|
+
exports.extractMasterKey = extractMasterKey;
|
|
9
|
+
exports.restrictRoutes = restrictRoutes;
|
|
10
|
+
exports.conditionalJsonMiddleware = conditionalJsonMiddleware;
|
|
11
|
+
exports.removeResultMiddleware = removeResultMiddleware;
|
|
12
|
+
const express_1 = __importDefault(require("express"));
|
|
13
|
+
const cloudRegistry_1 = require("../decorators/cloudRegistry");
|
|
14
|
+
const routeDecorator_1 = require("../decorators/routeDecorator");
|
|
15
|
+
/**
|
|
16
|
+
* Validates cloud function routes — supports both entity routes and legacy /functions routes.
|
|
17
|
+
*
|
|
18
|
+
* Entity routes: /api/students/create → resolves to 'createStudent'
|
|
19
|
+
* Legacy routes: /api/functions/createStudent → resolves directly
|
|
20
|
+
*
|
|
21
|
+
* Converts all requests to POST for Parse Server internal handling.
|
|
22
|
+
*/
|
|
23
|
+
function validateFunctionRoutes(req, res, next) {
|
|
24
|
+
const functionName = req.path.split('/')[1];
|
|
25
|
+
const metadata = cloudRegistry_1.CloudFunctionRegistry.getFunction(functionName);
|
|
26
|
+
if (!metadata) {
|
|
27
|
+
return res.status(404).json({ message: 'Function not found' });
|
|
28
|
+
}
|
|
29
|
+
if (!metadata.config.methods.includes(req.method)) {
|
|
30
|
+
return res.status(405).json({ message: 'Method not allowed' });
|
|
31
|
+
}
|
|
32
|
+
req.method = 'POST'; // Convert method to POST for Parse Server
|
|
33
|
+
return next();
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Validates entity-based routes: /api/{entity}/{action}
|
|
37
|
+
* Resolves the route to a cloud function name and rewrites the URL
|
|
38
|
+
* to /functions/{functionName} so Parse Server can handle it.
|
|
39
|
+
*/
|
|
40
|
+
function validateEntityRoutes(req, res, next) {
|
|
41
|
+
// Build route path from URL: /students/create
|
|
42
|
+
const routePath = req.path;
|
|
43
|
+
const functionName = routeDecorator_1.RouteRegistry.resolve(routePath);
|
|
44
|
+
if (!functionName) {
|
|
45
|
+
return res.status(404).json({ message: 'Route not found' });
|
|
46
|
+
}
|
|
47
|
+
const metadata = cloudRegistry_1.CloudFunctionRegistry.getFunction(functionName);
|
|
48
|
+
if (!metadata) {
|
|
49
|
+
return res.status(404).json({ message: 'Function not found' });
|
|
50
|
+
}
|
|
51
|
+
if (!metadata.config.methods.includes(req.method)) {
|
|
52
|
+
return res.status(405).json({ message: 'Method not allowed' });
|
|
53
|
+
}
|
|
54
|
+
// Rewrite URL to /functions/{functionName} so Parse Server handles it
|
|
55
|
+
req.url = `/functions/${functionName}`;
|
|
56
|
+
req.method = 'POST'; // Convert method to POST for Parse Server
|
|
57
|
+
return next();
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Extracts master key from the request body during JSON parsing
|
|
61
|
+
*/
|
|
62
|
+
function extractMasterKey(req, res, buf, encoding) {
|
|
63
|
+
try {
|
|
64
|
+
const body = JSON.parse(buf.toString(encoding));
|
|
65
|
+
if (body && (body.masterKey || body._MasterKey)) {
|
|
66
|
+
req['x-master-key'] = body.masterKey || body._MasterKey;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
throw res.status(400).json({ message: 'Error parsing JSON body' });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Restricts access to specific routes unless master key is provided.
|
|
75
|
+
* Only registered entity routes and system routes are allowed.
|
|
76
|
+
* /functions is NO LONGER allowed — use entity routes instead.
|
|
77
|
+
*/
|
|
78
|
+
function restrictRoutes(req, res, next) {
|
|
79
|
+
const systemRoutes = ['/health', '/serverInfo', '/files'];
|
|
80
|
+
// Master key bypasses all restrictions
|
|
81
|
+
if (req['x-master-key'] === process.env.masterKey) {
|
|
82
|
+
return next();
|
|
83
|
+
}
|
|
84
|
+
// Allow system routes
|
|
85
|
+
if (systemRoutes.some(route => req.path.startsWith(route))) {
|
|
86
|
+
return next();
|
|
87
|
+
}
|
|
88
|
+
// Allow registered entity route prefixes
|
|
89
|
+
if (routeDecorator_1.RouteRegistry.isRegisteredPrefix(req.path)) {
|
|
90
|
+
return next();
|
|
91
|
+
}
|
|
92
|
+
// Allow /functions for internal Parse Server use (rewritten by validateEntityRoutes)
|
|
93
|
+
if (req.path.startsWith('/functions')) {
|
|
94
|
+
return next();
|
|
95
|
+
}
|
|
96
|
+
throw res.status(403).json({ message: 'Route not allowed' });
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Conditionally applies JSON parsing middleware, skipping file routes
|
|
100
|
+
*/
|
|
101
|
+
function conditionalJsonMiddleware(req, res, next) {
|
|
102
|
+
if (req.path.startsWith(`${process.env.mountPath}/files`)) {
|
|
103
|
+
console.log('Skipping JSON middleware for /files route');
|
|
104
|
+
return next();
|
|
105
|
+
}
|
|
106
|
+
express_1.default.json({
|
|
107
|
+
limit: '10mb',
|
|
108
|
+
type: ['text/plain'],
|
|
109
|
+
verify: extractMasterKey,
|
|
110
|
+
})(req, res, next);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Removes the 'result' wrapper from Parse Server responses.
|
|
114
|
+
* Applies to all registered entity routes (no longer just /functions).
|
|
115
|
+
*/
|
|
116
|
+
function removeResultMiddleware(req, res, next) {
|
|
117
|
+
const mountPath = process.env.mountPath || '/api';
|
|
118
|
+
// Check if this is a registered entity route or a rewritten /functions route
|
|
119
|
+
const pathAfterMount = req.path.replace(mountPath, '');
|
|
120
|
+
const isEntityRoute = routeDecorator_1.RouteRegistry.isRegisteredPrefix(pathAfterMount);
|
|
121
|
+
const isFunctionRoute = req.path.includes('/functions');
|
|
122
|
+
if (!isEntityRoute && !isFunctionRoute)
|
|
123
|
+
return next();
|
|
124
|
+
const originalJson = res.json.bind(res);
|
|
125
|
+
res.json = (body) => {
|
|
126
|
+
if (body && typeof body === 'object' && 'result' in body) {
|
|
127
|
+
return originalJson(body.result);
|
|
128
|
+
}
|
|
129
|
+
return originalJson(body);
|
|
130
|
+
};
|
|
131
|
+
next();
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=middleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../src/middleware/middleware.ts"],"names":[],"mappings":";;;;;AAaA,wDAkBC;AAOD,oDA0BC;AAKD,4CAcC;AAOD,wCAwBC;AAKD,8DAeC;AAMD,wDAoBC;AAhKD,sDAAiE;AACjE,+DAAkE;AAClE,iEAA2D;AAG3D;;;;;;;GAOG;AACH,SAAgB,sBAAsB,CACpC,GAAY,EACZ,GAAa,EACb,IAAkB;IAElB,MAAM,YAAY,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5C,MAAM,QAAQ,GAAG,qCAAqB,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;IAEjE,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAC,OAAO,EAAE,oBAAoB,EAAC,CAAC,CAAC;IAC/D,CAAC;IAED,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAoB,CAAC,EAAE,CAAC;QAChE,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAC,OAAO,EAAE,oBAAoB,EAAC,CAAC,CAAC;IAC/D,CAAC;IAED,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,0CAA0C;IAC/D,OAAO,IAAI,EAAE,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,SAAgB,oBAAoB,CAClC,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
|
|
1
|
+
import { Express } from 'express';
|
|
2
|
+
import { SwaggerConfig } from './swaggerSpec';
|
|
3
|
+
export { SwaggerRegistry } from './swaggerRegistry';
|
|
4
|
+
export { generateSwaggerSpec, getSwaggerJson } from './swaggerSpec';
|
|
5
|
+
/**
|
|
6
|
+
* Setup Swagger UI for the Express app
|
|
7
|
+
*/
|
|
8
|
+
export declare function setupSwagger(app: Express, config: SwaggerConfig, path?: string): void;
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/swagger/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAsB,aAAa,EAAC,MAAM,eAAe,CAAC;AAEjE,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAC,mBAAmB,EAAE,cAAc,EAAC,MAAM,eAAe,CAAC;AAElE;;GAEG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,aAAa,EACrB,IAAI,GAAE,MAAoB,QA0B3B"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getSwaggerJson = exports.generateSwaggerSpec = exports.SwaggerRegistry = void 0;
|
|
7
|
+
exports.setupSwagger = setupSwagger;
|
|
8
|
+
const swagger_ui_express_1 = __importDefault(require("swagger-ui-express"));
|
|
9
|
+
const swaggerSpec_1 = require("./swaggerSpec");
|
|
10
|
+
var swaggerRegistry_1 = require("./swaggerRegistry");
|
|
11
|
+
Object.defineProperty(exports, "SwaggerRegistry", { enumerable: true, get: function () { return swaggerRegistry_1.SwaggerRegistry; } });
|
|
12
|
+
var swaggerSpec_2 = require("./swaggerSpec");
|
|
13
|
+
Object.defineProperty(exports, "generateSwaggerSpec", { enumerable: true, get: function () { return swaggerSpec_2.generateSwaggerSpec; } });
|
|
14
|
+
Object.defineProperty(exports, "getSwaggerJson", { enumerable: true, get: function () { return swaggerSpec_2.getSwaggerJson; } });
|
|
15
|
+
/**
|
|
16
|
+
* Setup Swagger UI for the Express app
|
|
17
|
+
*/
|
|
18
|
+
function setupSwagger(app, config, path = '/api-docs') {
|
|
19
|
+
console.log(path);
|
|
20
|
+
// Generate spec dynamically (after all models and functions are loaded)
|
|
21
|
+
const getSpec = () => (0, swaggerSpec_1.generateSwaggerSpec)(config);
|
|
22
|
+
// Serve Swagger JSON BEFORE the UI middleware (so it doesn't get caught)
|
|
23
|
+
app.get(`${path}/json`, (req, res) => {
|
|
24
|
+
res.json(getSpec());
|
|
25
|
+
});
|
|
26
|
+
// Serve Swagger UI
|
|
27
|
+
app.use(path, swagger_ui_express_1.default.serve, swagger_ui_express_1.default.setup(null, {
|
|
28
|
+
swaggerOptions: {
|
|
29
|
+
url: `${path}/json`,
|
|
30
|
+
persistAuthorization: true,
|
|
31
|
+
},
|
|
32
|
+
customSiteTitle: config.title || 'API Documentation',
|
|
33
|
+
}));
|
|
34
|
+
console.log(`[Swagger] API documentation available at ${path}`);
|
|
35
|
+
console.log(`[Swagger] API spec available at ${path}/json`);
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/swagger/index.ts"],"names":[],"mappings":";;;;;;AAUA,oCA6BC;AAtCD,4EAA2C;AAC3C,+CAAiE;AAEjE,qDAAkD;AAA1C,kHAAA,eAAe,OAAA;AACvB,6CAAkE;AAA1D,kHAAA,mBAAmB,OAAA;AAAE,6GAAA,cAAc,OAAA;AAE3C;;GAEG;AACH,SAAgB,YAAY,CAC1B,GAAY,EACZ,MAAqB,EACrB,OAAe,WAAW;IAE1B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAClB,wEAAwE;IACxE,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,IAAA,iCAAmB,EAAC,MAAM,CAAC,CAAC;IAElD,yEAAyE;IACzE,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACnC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;IACtB,CAAC,CAAC,CAAC;IAEH,mBAAmB;IACnB,GAAG,CAAC,GAAG,CACL,IAAI,EACJ,4BAAS,CAAC,KAAK,EACf,4BAAS,CAAC,KAAK,CAAC,IAAI,EAAE;QACpB,cAAc,EAAE;YACd,GAAG,EAAE,GAAG,IAAI,OAAO;YACnB,oBAAoB,EAAE,IAAI;SAC3B;QACD,eAAe,EAAE,MAAM,CAAC,KAAK,IAAI,mBAAmB;KACrD,CAAC,CACH,CAAC;IAEF,OAAO,CAAC,GAAG,CAAC,4CAA4C,IAAI,EAAE,CAAC,CAAC;IAChE,OAAO,CAAC,GAAG,CAAC,mCAAmC,IAAI,OAAO,CAAC,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
export interface SwaggerModelSchema {
|
|
3
|
+
className: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
properties: Record<string, SwaggerPropertySchema>;
|
|
6
|
+
required: string[];
|
|
7
|
+
}
|
|
8
|
+
export interface SwaggerPropertySchema {
|
|
9
|
+
type: string;
|
|
10
|
+
format?: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
$ref?: string;
|
|
13
|
+
items?: {
|
|
14
|
+
type?: string;
|
|
15
|
+
$ref?: string;
|
|
16
|
+
};
|
|
17
|
+
nullable?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface SwaggerFunctionSchema {
|
|
20
|
+
name: string;
|
|
21
|
+
method: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
summary?: string;
|
|
24
|
+
tags?: string[];
|
|
25
|
+
requiresAuth: boolean;
|
|
26
|
+
requestBody?: {
|
|
27
|
+
required: boolean;
|
|
28
|
+
properties: Record<string, SwaggerPropertySchema>;
|
|
29
|
+
};
|
|
30
|
+
responses?: Record<string, {
|
|
31
|
+
description: string;
|
|
32
|
+
schema?: any;
|
|
33
|
+
}>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Registry for collecting Swagger/OpenAPI documentation metadata
|
|
37
|
+
*/
|
|
38
|
+
export declare class SwaggerRegistry {
|
|
39
|
+
private static models;
|
|
40
|
+
private static functions;
|
|
41
|
+
/**
|
|
42
|
+
* Register a model for Swagger documentation
|
|
43
|
+
*/
|
|
44
|
+
static registerModel(schema: SwaggerModelSchema): void;
|
|
45
|
+
/**
|
|
46
|
+
* Register a cloud function for Swagger documentation
|
|
47
|
+
*/
|
|
48
|
+
static registerFunction(schema: SwaggerFunctionSchema): void;
|
|
49
|
+
/**
|
|
50
|
+
* Get all registered models
|
|
51
|
+
*/
|
|
52
|
+
static getModels(): SwaggerModelSchema[];
|
|
53
|
+
/**
|
|
54
|
+
* Get all registered functions
|
|
55
|
+
*/
|
|
56
|
+
static getFunctions(): SwaggerFunctionSchema[];
|
|
57
|
+
/**
|
|
58
|
+
* Get a specific model by name
|
|
59
|
+
*/
|
|
60
|
+
static getModel(name: string): SwaggerModelSchema | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Get a specific function by name
|
|
63
|
+
*/
|
|
64
|
+
static getFunction(name: string): SwaggerFunctionSchema | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Normalize class name to match Parse Server conventions
|
|
67
|
+
* (e.g., 'User' -> '_User', 'Role' -> '_Role')
|
|
68
|
+
*/
|
|
69
|
+
static normalizeClassName(className?: string): string | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Convert Parse field type to Swagger/OpenAPI type
|
|
72
|
+
*/
|
|
73
|
+
static parseTypeToSwagger(fieldType: string, targetClass?: string): SwaggerPropertySchema;
|
|
74
|
+
/**
|
|
75
|
+
* Convert validation field type to Swagger type
|
|
76
|
+
*/
|
|
77
|
+
static validationTypeToSwagger(type: any): SwaggerPropertySchema;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=swaggerRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swaggerRegistry.d.ts","sourceRoot":"","sources":["../../src/swagger/swaggerRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;IAClD,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACzC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,YAAY,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE;QACZ,QAAQ,EAAE,OAAO,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;KACnD,CAAC;IACF,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,GAAG,CAAA;KAAE,CAAC,CAAC;CACnE;AAED;;GAEG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAC,MAAM,CAA8C;IACnE,OAAO,CAAC,MAAM,CAAC,SAAS,CAAiD;IAEzE;;OAEG;IACH,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,kBAAkB;IAK/C;;OAEG;IACH,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,qBAAqB;IAKrD;;OAEG;IACH,MAAM,CAAC,SAAS;IAIhB;;OAEG;IACH,MAAM,CAAC,YAAY;IAInB;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM;IAI5B;;OAEG;IACH,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM;IAI/B;;;OAGG;IACH,MAAM,CAAC,kBAAkB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAWjE;;OAEG;IACH,MAAM,CAAC,kBAAkB,CACvB,SAAS,EAAE,MAAM,EACjB,WAAW,CAAC,EAAE,MAAM,GACnB,qBAAqB;IAiCxB;;OAEG;IACH,MAAM,CAAC,uBAAuB,CAAC,IAAI,EAAE,GAAG,GAAG,qBAAqB;CAQjE"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SwaggerRegistry = void 0;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
/**
|
|
6
|
+
* Registry for collecting Swagger/OpenAPI documentation metadata
|
|
7
|
+
*/
|
|
8
|
+
class SwaggerRegistry {
|
|
9
|
+
/**
|
|
10
|
+
* Register a model for Swagger documentation
|
|
11
|
+
*/
|
|
12
|
+
static registerModel(schema) {
|
|
13
|
+
this.models.set(schema.className, schema);
|
|
14
|
+
console.log(`[Swagger] Registered model: ${schema.className}`);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Register a cloud function for Swagger documentation
|
|
18
|
+
*/
|
|
19
|
+
static registerFunction(schema) {
|
|
20
|
+
this.functions.set(schema.name, schema);
|
|
21
|
+
console.log(`[Swagger] Registered function: ${schema.name}`);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Get all registered models
|
|
25
|
+
*/
|
|
26
|
+
static getModels() {
|
|
27
|
+
return Array.from(this.models.values());
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Get all registered functions
|
|
31
|
+
*/
|
|
32
|
+
static getFunctions() {
|
|
33
|
+
return Array.from(this.functions.values());
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Get a specific model by name
|
|
37
|
+
*/
|
|
38
|
+
static getModel(name) {
|
|
39
|
+
return this.models.get(name);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Get a specific function by name
|
|
43
|
+
*/
|
|
44
|
+
static getFunction(name) {
|
|
45
|
+
return this.functions.get(name);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Normalize class name to match Parse Server conventions
|
|
49
|
+
* (e.g., 'User' -> '_User', 'Role' -> '_Role')
|
|
50
|
+
*/
|
|
51
|
+
static normalizeClassName(className) {
|
|
52
|
+
if (!className)
|
|
53
|
+
return undefined;
|
|
54
|
+
// Parse built-in classes use underscore prefix
|
|
55
|
+
const builtInClasses = ['User', 'Role', 'Session', 'Installation'];
|
|
56
|
+
if (builtInClasses.includes(className)) {
|
|
57
|
+
return `_${className}`;
|
|
58
|
+
}
|
|
59
|
+
return className;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Convert Parse field type to Swagger/OpenAPI type
|
|
63
|
+
*/
|
|
64
|
+
static parseTypeToSwagger(fieldType, targetClass) {
|
|
65
|
+
const normalizedClass = this.normalizeClassName(targetClass);
|
|
66
|
+
const typeMap = {
|
|
67
|
+
String: { type: 'string' },
|
|
68
|
+
Number: { type: 'number' },
|
|
69
|
+
Boolean: { type: 'boolean' },
|
|
70
|
+
Date: { type: 'string', format: 'date-time' },
|
|
71
|
+
Object: { type: 'object' },
|
|
72
|
+
Array: { type: 'array', items: { type: 'string' } },
|
|
73
|
+
GeoPoint: {
|
|
74
|
+
type: 'object',
|
|
75
|
+
description: 'GeoPoint with latitude and longitude',
|
|
76
|
+
},
|
|
77
|
+
File: { type: 'object', description: 'Parse File object' },
|
|
78
|
+
Bytes: { type: 'string', format: 'byte' },
|
|
79
|
+
Polygon: { type: 'object', description: 'Polygon coordinates' },
|
|
80
|
+
Pointer: {
|
|
81
|
+
type: 'object',
|
|
82
|
+
description: `Pointer to ${targetClass || 'unknown'}`,
|
|
83
|
+
$ref: normalizedClass ? `#/components/schemas/${normalizedClass}` : undefined,
|
|
84
|
+
},
|
|
85
|
+
Relation: {
|
|
86
|
+
type: 'array',
|
|
87
|
+
description: `Relation to ${targetClass || 'unknown'}`,
|
|
88
|
+
items: {
|
|
89
|
+
$ref: normalizedClass ? `#/components/schemas/${normalizedClass}` : undefined,
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
return typeMap[fieldType] || { type: 'string' };
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Convert validation field type to Swagger type
|
|
97
|
+
*/
|
|
98
|
+
static validationTypeToSwagger(type) {
|
|
99
|
+
if (type === String)
|
|
100
|
+
return { type: 'string' };
|
|
101
|
+
if (type === Number)
|
|
102
|
+
return { type: 'number' };
|
|
103
|
+
if (type === Boolean)
|
|
104
|
+
return { type: 'boolean' };
|
|
105
|
+
if (type === Array)
|
|
106
|
+
return { type: 'array', items: { type: 'string' } };
|
|
107
|
+
if (type === Object)
|
|
108
|
+
return { type: 'object' };
|
|
109
|
+
return { type: 'string' };
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exports.SwaggerRegistry = SwaggerRegistry;
|
|
113
|
+
SwaggerRegistry.models = new Map();
|
|
114
|
+
SwaggerRegistry.functions = new Map();
|
|
115
|
+
//# sourceMappingURL=swaggerRegistry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swaggerRegistry.js","sourceRoot":"","sources":["../../src/swagger/swaggerRegistry.ts"],"names":[],"mappings":";;;AAAA,4BAA0B;AAgC1B;;GAEG;AACH,MAAa,eAAe;IAI1B;;OAEG;IACH,MAAM,CAAC,aAAa,CAAC,MAA0B;QAC7C,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QAC1C,OAAO,CAAC,GAAG,CAAC,+BAA+B,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC;IACjE,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,gBAAgB,CAAC,MAA6B;QACnD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACxC,OAAO,CAAC,GAAG,CAAC,kCAAkC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IAC/D,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,SAAS;QACd,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IAC1C,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,YAAY;QACjB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;IAC7C,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAY;QAC1B,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,WAAW,CAAC,IAAY;QAC7B,OAAO,IAAI,CAAC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
2
|
+
title: string;
|
|
3
|
+
version: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
basePath?: string;
|
|
6
|
+
host?: string;
|
|
7
|
+
schemes?: string[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Generate OpenAPI 3.0 specification from registered metadata
|
|
11
|
+
*/
|
|
12
|
+
export declare function generateSwaggerSpec(config: SwaggerConfig): {
|
|
13
|
+
openapi: string;
|
|
14
|
+
info: {
|
|
15
|
+
title: string;
|
|
16
|
+
version: string;
|
|
17
|
+
description: string;
|
|
18
|
+
};
|
|
19
|
+
servers: {
|
|
20
|
+
url: string;
|
|
21
|
+
description: string;
|
|
22
|
+
}[];
|
|
23
|
+
tags: {
|
|
24
|
+
name: string;
|
|
25
|
+
description: string;
|
|
26
|
+
}[];
|
|
27
|
+
paths: Record<string, any>;
|
|
28
|
+
components: {
|
|
29
|
+
schemas: Record<string, any>;
|
|
30
|
+
securitySchemes: {
|
|
31
|
+
applicationId: {
|
|
32
|
+
type: string;
|
|
33
|
+
in: string;
|
|
34
|
+
name: string;
|
|
35
|
+
description: string;
|
|
36
|
+
};
|
|
37
|
+
sessionToken: {
|
|
38
|
+
type: string;
|
|
39
|
+
in: string;
|
|
40
|
+
name: string;
|
|
41
|
+
description: string;
|
|
42
|
+
};
|
|
43
|
+
masterKey: {
|
|
44
|
+
type: string;
|
|
45
|
+
in: string;
|
|
46
|
+
name: string;
|
|
47
|
+
description: string;
|
|
48
|
+
};
|
|
49
|
+
restApiKey: {
|
|
50
|
+
type: string;
|
|
51
|
+
in: string;
|
|
52
|
+
name: string;
|
|
53
|
+
description: string;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
security: ({
|
|
58
|
+
applicationId: never[];
|
|
59
|
+
restApiKey?: undefined;
|
|
60
|
+
} | {
|
|
61
|
+
restApiKey: never[];
|
|
62
|
+
applicationId?: undefined;
|
|
63
|
+
})[];
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Get the Swagger specification as JSON
|
|
67
|
+
*/
|
|
68
|
+
export declare function getSwaggerJson(config: SwaggerConfig): string;
|
|
69
|
+
//# sourceMappingURL=swaggerSpec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swaggerSpec.d.ts","sourceRoot":"","sources":["../../src/swagger/swaggerSpec.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CAEpB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6KxD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAE5D"}
|