@90soft/parse-server-kit 1.0.0 → 2.0.1
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 +424 -0
- 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 +41 -0
- package/dist/middleware/middleware.d.ts.map +1 -0
- package/dist/middleware/middleware.js +154 -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,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,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AC,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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AC;IAClD,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,uBAAuB,CAAC,IAAS;QACtC,IAAI,IAAI,KAAK,MAAM;YAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;QAC/C,IAAI,IAAI,KAAK,MAAM;YAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;QAC/C,IAAI,IAAI,KAAK,OAAO;YAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QACjD,IAAI,IAAI,KAAK,KAAK;YAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,CAAC;QACxE,IAAI,IAAI,KAAK,MAAM;YAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;QAC/C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IAC5B,CAAC;;AAhHH,0CAiHC;AAhHgB,sBAAM,GAAoC,IAAI,GAAG,EAAE,CAAC;AACpD,yBAAS,GAAuC,IAAI,GAAG,EAAE,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export interface SwaggerConfig {
|
|
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"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateSwaggerSpec = generateSwaggerSpec;
|
|
4
|
+
exports.getSwaggerJson = getSwaggerJson;
|
|
5
|
+
const swaggerRegistry_1 = require("./swaggerRegistry");
|
|
6
|
+
/**
|
|
7
|
+
* Generate OpenAPI 3.0 specification from registered metadata
|
|
8
|
+
*/
|
|
9
|
+
function generateSwaggerSpec(config) {
|
|
10
|
+
const models = swaggerRegistry_1.SwaggerRegistry.getModels();
|
|
11
|
+
const functions = swaggerRegistry_1.SwaggerRegistry.getFunctions();
|
|
12
|
+
// Build schemas from models
|
|
13
|
+
const schemas = {};
|
|
14
|
+
for (const model of models) {
|
|
15
|
+
schemas[model.className] = {
|
|
16
|
+
type: 'object',
|
|
17
|
+
description: model.description,
|
|
18
|
+
properties: model.properties,
|
|
19
|
+
required: model.required.length > 0 ? model.required : undefined,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
// Add common schemas
|
|
23
|
+
schemas['ParseError'] = {
|
|
24
|
+
type: 'object',
|
|
25
|
+
properties: {
|
|
26
|
+
code: { type: 'number', description: 'Error code' },
|
|
27
|
+
error: { type: 'string', description: 'Error message' },
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
schemas['CloudFunctionRequest'] = {
|
|
31
|
+
type: 'object',
|
|
32
|
+
properties: {
|
|
33
|
+
_ApplicationId: { type: 'string', description: 'Application ID' },
|
|
34
|
+
_SessionToken: {
|
|
35
|
+
type: 'string',
|
|
36
|
+
description: 'Session token for authentication',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
// Build paths from functions
|
|
41
|
+
const paths = {};
|
|
42
|
+
const tagSet = new Set();
|
|
43
|
+
for (const func of functions) {
|
|
44
|
+
const path = `/functions/${func.name}`;
|
|
45
|
+
const method = func.method.toLowerCase();
|
|
46
|
+
// Collect tags
|
|
47
|
+
if (func.tags) {
|
|
48
|
+
func.tags.forEach(tag => tagSet.add(tag));
|
|
49
|
+
}
|
|
50
|
+
// Build request body schema
|
|
51
|
+
let requestBody = undefined;
|
|
52
|
+
if (func.requestBody &&
|
|
53
|
+
Object.keys(func.requestBody.properties).length > 0) {
|
|
54
|
+
requestBody = {
|
|
55
|
+
required: true,
|
|
56
|
+
content: {
|
|
57
|
+
'application/json': {
|
|
58
|
+
schema: {
|
|
59
|
+
type: 'object',
|
|
60
|
+
properties: func.requestBody.properties,
|
|
61
|
+
required: Object.entries(func.requestBody.properties)
|
|
62
|
+
.filter(([_, v]) => v.required)
|
|
63
|
+
.map(([k]) => k),
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
// Build responses
|
|
70
|
+
const responses = {};
|
|
71
|
+
if (func.responses) {
|
|
72
|
+
for (const [code, response] of Object.entries(func.responses)) {
|
|
73
|
+
responses[code] = {
|
|
74
|
+
description: response.description,
|
|
75
|
+
content: response.schema
|
|
76
|
+
? {
|
|
77
|
+
'application/json': {
|
|
78
|
+
schema: response.schema,
|
|
79
|
+
},
|
|
80
|
+
}
|
|
81
|
+
: {
|
|
82
|
+
'application/json': {
|
|
83
|
+
schema: {
|
|
84
|
+
type: 'object',
|
|
85
|
+
properties: {
|
|
86
|
+
result: { type: 'object', description: 'Function result' },
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// Build security requirements (applicationId and restApiKey are always required)
|
|
95
|
+
const security = func.requiresAuth
|
|
96
|
+
? [
|
|
97
|
+
{ applicationId: [], restApiKey: [], sessionToken: [] },
|
|
98
|
+
{ applicationId: [], restApiKey: [], masterKey: [] },
|
|
99
|
+
]
|
|
100
|
+
: [{ applicationId: [], restApiKey: [] }];
|
|
101
|
+
paths[path] = {
|
|
102
|
+
...paths[path],
|
|
103
|
+
[method]: {
|
|
104
|
+
tags: func.tags || ['Default'],
|
|
105
|
+
summary: func.summary,
|
|
106
|
+
description: func.description,
|
|
107
|
+
operationId: func.name,
|
|
108
|
+
security,
|
|
109
|
+
requestBody,
|
|
110
|
+
responses,
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
// Build tags array
|
|
115
|
+
const tags = Array.from(tagSet).map(tag => ({
|
|
116
|
+
name: tag,
|
|
117
|
+
description: `${tag} related operations`,
|
|
118
|
+
}));
|
|
119
|
+
// Build final spec
|
|
120
|
+
const spec = {
|
|
121
|
+
openapi: '3.0.3',
|
|
122
|
+
info: {
|
|
123
|
+
title: config.title,
|
|
124
|
+
version: config.version,
|
|
125
|
+
description: config.description || 'Auto-generated API documentation',
|
|
126
|
+
},
|
|
127
|
+
servers: [
|
|
128
|
+
{
|
|
129
|
+
url: config.basePath || process.env.mountPath || '/parse',
|
|
130
|
+
description: 'Parse Server API',
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
tags,
|
|
134
|
+
paths,
|
|
135
|
+
components: {
|
|
136
|
+
schemas,
|
|
137
|
+
securitySchemes: {
|
|
138
|
+
applicationId: {
|
|
139
|
+
type: 'apiKey',
|
|
140
|
+
in: 'header',
|
|
141
|
+
name: 'X-Parse-Application-Id',
|
|
142
|
+
description: 'Parse Application ID',
|
|
143
|
+
},
|
|
144
|
+
sessionToken: {
|
|
145
|
+
type: 'apiKey',
|
|
146
|
+
in: 'header',
|
|
147
|
+
name: 'X-Parse-Session-Token',
|
|
148
|
+
description: 'User session token for authentication',
|
|
149
|
+
},
|
|
150
|
+
masterKey: {
|
|
151
|
+
type: 'apiKey',
|
|
152
|
+
in: 'header',
|
|
153
|
+
name: 'X-Parse-Master-Key',
|
|
154
|
+
description: 'Master key for admin operations',
|
|
155
|
+
},
|
|
156
|
+
restApiKey: {
|
|
157
|
+
type: 'apiKey',
|
|
158
|
+
in: 'header',
|
|
159
|
+
name: 'X-Parse-REST-API-Key',
|
|
160
|
+
description: 'REST API key for client requests',
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
security: [{ applicationId: [] }, { restApiKey: [] }],
|
|
165
|
+
};
|
|
166
|
+
return spec;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Get the Swagger specification as JSON
|
|
170
|
+
*/
|
|
171
|
+
function getSwaggerJson(config) {
|
|
172
|
+
return JSON.stringify(generateSwaggerSpec(config), null, 2);
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=swaggerSpec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swaggerSpec.js","sourceRoot":"","sources":["../../src/swagger/swaggerSpec.ts"],"names":[],"mappings":";;AAeA,kDA6KC;AAKD,wCAEC;AAnMD,uDAAkD;AAYlD;;GAEG;AACH,SAAgB,mBAAmB,CAAC,MAAqB;IACvD,MAAM,MAAM,GAAG,iCAAe,CAAC,SAAS,EAAE,CAAC;IAC3C,MAAM,SAAS,GAAG,iCAAe,CAAC,YAAY,EAAE,CAAC;IAEjD,4BAA4B;IAC5B,MAAM,OAAO,GAAwB,EAAE,CAAC;IACxC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG;YACzB,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAA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AAE,EAAE,QAAQ;oBACZ,IAAI,EAAE,wBAAwB;oBAC9B,WAAW,EAAE,sBAAsB;iBACpC;gBACD,YAAY,EAAE;oBACZ,IAAI,EAAE,QAAQ;oBACd,EAAE,EAAE,QAAQ;oBACZ,IAAI,EAAE,uBAAuB;oBAC7B,WAAW,EAAE,uCAAuC;iBACrD;gBACD,SAAS,EAAE;oBACT,IAAI,EAAE,QAAQ;oBACd,EAAE,EAAE,QAAQ;oBACZ,IAAI,EAAE,oBAAoB;oBAC1B,WAAW,EAAE,iCAAiC;iBAC/C;gBACD,UAAU,EAAE;oBACV,IAAI,EAAE,QAAQ;oBACd,EAAE,EAAE,QAAQ;oBACZ,IAAI,EAAE,sBAAsB;oBAC5B,WAAW,EAAE,kCAAkC;iBAChD;aACF;SACF;QACD,QAAQ,EAAE,CAAC,EAAC,aAAa,EAAE,EAAE,EAAC,EAAE,EAAC,UAAU,EAAE,EAAE,EAAC,CAAC;KAClD,CAAC;IAEF,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;GAEG;AACH,SAAgB,cAAc,CAAC,MAAqB;IAClD,OAAO,IAAI,CAAC,SAAS,CAAC,mBAAmB,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
type RoleRule = {
|
|
2
|
+
role: string;
|
|
3
|
+
read?: boolean;
|
|
4
|
+
write?: boolean;
|
|
5
|
+
};
|
|
6
|
+
type OwnerRule = {
|
|
7
|
+
user?: string | any;
|
|
8
|
+
read?: boolean;
|
|
9
|
+
write?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare function implementACL(params: {
|
|
12
|
+
publicRead?: boolean;
|
|
13
|
+
publicWrite?: boolean;
|
|
14
|
+
roleRules?: RoleRule[] | undefined;
|
|
15
|
+
excludedRoles?: string[];
|
|
16
|
+
owner?: OwnerRule[];
|
|
17
|
+
}, existingACL?: Parse.ACL): Parse.ACL;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=ACL.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ACL.d.ts","sourceRoot":"","sources":["../../src/utils/ACL.ts"],"names":[],"mappings":"AAAA,KAAK,QAAQ,GAAG;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAC,CAAC;AAChE,KAAK,SAAS,GAAG;IAAC,IAAI,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAC,CAAC;AAExE,wBAAgB,YAAY,CAC1B,MAAM,EAAE;IACN,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,QAAQ,EAAE,GAAG,SAAS,CAAC;IACnC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,KAAK,CAAC,EAAE,SAAS,EAAE,CAAC;CACrB,EACD,WAAW,CAAC,EAAE,KAAK,CAAC,GAAG,GACtB,KAAK,CAAC,GAAG,CAgCX"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.implementACL = implementACL;
|
|
4
|
+
function implementACL(params, existingACL) {
|
|
5
|
+
const { publicRead = false, publicWrite = false, roleRules, excludedRoles = [], owner = [], } = params;
|
|
6
|
+
const acl = existingACL ?? new Parse.ACL();
|
|
7
|
+
acl.setPublicReadAccess(!!publicRead);
|
|
8
|
+
acl.setPublicWriteAccess(!!publicWrite);
|
|
9
|
+
for (const { role, read = false, write = false } of roleRules ?? []) {
|
|
10
|
+
if (excludedRoles.includes(role))
|
|
11
|
+
continue;
|
|
12
|
+
if (read)
|
|
13
|
+
acl.setRoleReadAccess(role, true);
|
|
14
|
+
else
|
|
15
|
+
acl.setRoleReadAccess(role, false);
|
|
16
|
+
if (write)
|
|
17
|
+
acl.setRoleWriteAccess(role, true);
|
|
18
|
+
else
|
|
19
|
+
acl.setRoleWriteAccess(role, false);
|
|
20
|
+
}
|
|
21
|
+
for (const { user, read = false, write = false } of owner) {
|
|
22
|
+
if (user !== undefined) {
|
|
23
|
+
if (read)
|
|
24
|
+
acl.setReadAccess(user, true);
|
|
25
|
+
else
|
|
26
|
+
acl.setReadAccess(user, false);
|
|
27
|
+
if (write)
|
|
28
|
+
acl.setWriteAccess(user, true);
|
|
29
|
+
else
|
|
30
|
+
acl.setWriteAccess(user, false);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return acl;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=ACL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ACL.js","sourceRoot":"","sources":["../../src/utils/ACL.ts"],"names":[],"mappings":";;AAGA,oCAyCC;AAzCD,SAAgB,YAAY,CAC1B,MAMC,EACD,WAAuB;IAEvB,MAAM,EACJ,UAAU,GAAG,KAAK,EAClB,WAAW,GAAG,KAAK,EACnB,SAAS,EACT,aAAa,GAAG,EAAE,EAClB,KAAK,GAAG,EAAE,GACX,GAAG,MAAM,CAAC;IAEX,MAAM,GAAG,GAAG,WAAW,IAAI,IAAI,KAAK,CAAC,GAAG,EAAE,CAAC;IAE3C,GAAG,CAAC,mBAAmB,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;IACtC,GAAG,CAAC,oBAAoB,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;IAExC,KAAK,MAAM,EAAC,IAAI,EAAE,IAAI,GAAG,KAAK,EAAE,KAAK,GAAG,KAAK,EAAC,IAAI,SAAS,IAAI,EAAE,EAAE,CAAC;QAClE,IAAI,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC;YAAE,SAAS;QAC3C,IAAI,IAAI;YAAE,GAAG,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;;YACvC,GAAG,CAAC,iBAAiB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACxC,IAAI,KAAK;YAAE,GAAG,CAAC,kBAAkB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;;YACzC,GAAG,CAAC,kBAAkB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK,MAAM,EAAC,IAAI,EAAE,IAAI,GAAG,KAAK,EAAE,KAAK,GAAG,KAAK,EAAC,IAAI,KAAK,EAAE,CAAC;QACxD,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,IAAI,IAAI;gBAAE,GAAG,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;;gBACnC,GAAG,CAAC,aAAa,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YACpC,IAAI,KAAK;gBAAE,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;;gBACrC,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User Roles — override these in your project by re-exporting with your own values.
|
|
3
|
+
* These are the defaults for the template.
|
|
4
|
+
*/
|
|
5
|
+
export declare enum UserRoles {
|
|
6
|
+
ADMIN = "SuperAdmin",
|
|
7
|
+
EMPLOYEE = "Employee"
|
|
8
|
+
}
|
|
9
|
+
export type RoleString = `role:${UserRoles}`;
|
|
10
|
+
export declare function roleKey(role: UserRoles): RoleString;
|
|
11
|
+
/** Maximum limit for unbounded Parse queries */
|
|
12
|
+
export declare const MAX_QUERY_LIMIT = 10000;
|
|
13
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,oBAAY,SAAS;IACnB,KAAK,eAAe;IACpB,QAAQ,aAAa;CACtB;AAED,MAAM,MAAM,UAAU,GAAG,QAAQ,SAAS,EAAE,CAAC;AAE7C,wBAAgB,OAAO,CAAC,IAAI,EAAE,SAAS,GAAG,UAAU,CAEnD;AAED,gDAAgD;AAChD,eAAO,MAAM,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MAX_QUERY_LIMIT = exports.UserRoles = void 0;
|
|
4
|
+
exports.roleKey = roleKey;
|
|
5
|
+
/**
|
|
6
|
+
* User Roles — override these in your project by re-exporting with your own values.
|
|
7
|
+
* These are the defaults for the template.
|
|
8
|
+
*/
|
|
9
|
+
var UserRoles;
|
|
10
|
+
(function (UserRoles) {
|
|
11
|
+
UserRoles["ADMIN"] = "SuperAdmin";
|
|
12
|
+
UserRoles["EMPLOYEE"] = "Employee";
|
|
13
|
+
})(UserRoles || (exports.UserRoles = UserRoles = {}));
|
|
14
|
+
function roleKey(role) {
|
|
15
|
+
return `role:${role}`;
|
|
16
|
+
}
|
|
17
|
+
/** Maximum limit for unbounded Parse queries */
|
|
18
|
+
exports.MAX_QUERY_LIMIT = 10000;
|
|
19
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":";;;AAWA,0BAEC;AAbD;;;GAGG;AACH,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,iCAAoB,CAAA;IACpB,kCAAqB,CAAA;AACvB,CAAC,EAHW,SAAS,yBAAT,SAAS,QAGpB;AAID,SAAgB,OAAO,CAAC,IAAe;IACrC,OAAO,QAAQ,IAAI,EAAE,CAAC;AACxB,CAAC;AAED,gDAAgD;AACnC,QAAA,eAAe,GAAG,KAAK,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamicImport.d.ts","sourceRoot":"","sources":["../../src/utils/dynamicImport.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,WAAW,GAAI,eAAe,MAAM,SAWhD,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.importFiles = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const isDirectory = (path) => (0, fs_1.statSync)(path).isDirectory();
|
|
7
|
+
const importFiles = (directoryPath) => {
|
|
8
|
+
const files = (0, fs_1.readdirSync)(directoryPath);
|
|
9
|
+
files.forEach(file => {
|
|
10
|
+
const filePath = (0, path_1.join)(directoryPath, file);
|
|
11
|
+
if (isDirectory(filePath)) {
|
|
12
|
+
(0, exports.importFiles)(filePath);
|
|
13
|
+
}
|
|
14
|
+
else if ((0, path_1.extname)(filePath) === '.js') {
|
|
15
|
+
console.log(filePath);
|
|
16
|
+
require(filePath);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
exports.importFiles = importFiles;
|
|
21
|
+
//# sourceMappingURL=dynamicImport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamicImport.js","sourceRoot":"","sources":["../../src/utils/dynamicImport.ts"],"names":[],"mappings":";;;AAAA,2BAAyC;AACzC,+BAAmC;AAEnC,MAAM,WAAW,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAA,aAAQ,EAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;AAE5D,MAAM,WAAW,GAAG,CAAC,aAAqB,EAAE,EAAE;IACnD,MAAM,KAAK,GAAG,IAAA,gBAAW,EAAC,aAAa,CAAC,CAAC;IACzC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACnB,MAAM,QAAQ,GAAG,IAAA,WAAI,EAAC,aAAa,EAAE,IAAI,CAAC,CAAC;QAC3C,IAAI,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC1B,IAAA,mBAAW,EAAC,QAAQ,CAAC,CAAC;QACxB,CAAC;aAAM,IAAI,IAAA,cAAO,EAAC,QAAQ,CAAC,KAAK,KAAK,EAAE,CAAC;YACvC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACtB,OAAO,CAAC,QAAQ,CAAC,CAAC;QACpB,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAXW,QAAA,WAAW,eAWtB"}
|