@ingenyus/swarm-wasp 0.1.0 → 0.2.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 +229 -21
- package/dist/.tsbuildinfo +1 -1
- package/dist/common/filesystem.d.ts +0 -14
- package/dist/common/filesystem.d.ts.map +1 -1
- package/dist/common/filesystem.js +123 -0
- package/dist/common/index.d.ts +0 -1
- package/dist/common/index.d.ts.map +1 -1
- package/dist/common/index.js +366 -0
- package/dist/common/prisma.js +140 -0
- package/dist/common/schemas.d.ts +8 -42
- package/dist/common/schemas.d.ts.map +1 -1
- package/dist/common/schemas.js +54 -0
- package/dist/common/templates.js +52 -0
- package/dist/generators/action/action-generator.d.ts +16 -29
- package/dist/generators/action/action-generator.d.ts.map +1 -1
- package/dist/generators/action/action-generator.js +1425 -0
- package/dist/generators/action/index.js +1425 -0
- package/dist/generators/action/schema.d.ts +11 -23
- package/dist/generators/action/schema.d.ts.map +1 -1
- package/dist/generators/action/schema.js +115 -0
- package/dist/generators/api/api-generator.d.ts +19 -26
- package/dist/generators/api/api-generator.d.ts.map +1 -1
- package/dist/generators/api/api-generator.js +1104 -0
- package/dist/generators/api/index.js +1104 -0
- package/dist/generators/api/schema.d.ts +13 -21
- package/dist/generators/api/schema.d.ts.map +1 -1
- package/dist/generators/api/schema.js +117 -0
- package/dist/generators/api-namespace/api-namespace-generator.d.ts +10 -17
- package/dist/generators/api-namespace/api-namespace-generator.d.ts.map +1 -1
- package/dist/generators/api-namespace/api-namespace-generator.js +1028 -0
- package/dist/generators/api-namespace/index.js +1028 -0
- package/dist/generators/api-namespace/schema.d.ts +4 -12
- package/dist/generators/api-namespace/schema.d.ts.map +1 -1
- package/dist/generators/api-namespace/schema.js +89 -0
- package/dist/generators/base/{entity-generator.base.d.ts → component-generator.base.d.ts} +9 -9
- package/dist/generators/base/component-generator.base.d.ts.map +1 -0
- package/dist/generators/base/component-generator.base.js +931 -0
- package/dist/generators/base/index.d.ts +1 -1
- package/dist/generators/base/index.d.ts.map +1 -1
- package/dist/generators/base/index.js +1330 -0
- package/dist/generators/base/operation-generator.base.d.ts +12 -3
- package/dist/generators/base/operation-generator.base.d.ts.map +1 -1
- package/dist/generators/base/operation-generator.base.js +1331 -0
- package/dist/generators/base/wasp-generator.base.d.ts +2 -1
- package/dist/generators/base/wasp-generator.base.d.ts.map +1 -1
- package/dist/generators/base/wasp-generator.base.js +706 -0
- package/dist/generators/config/config-generator.d.ts +7 -4
- package/dist/generators/config/config-generator.d.ts.map +1 -1
- package/dist/generators/config/config-generator.js +0 -0
- package/dist/generators/config/index.js +596 -0
- package/dist/generators/config/wasp-config-generator.d.ts +1 -1
- package/dist/generators/config/wasp-config-generator.d.ts.map +1 -1
- package/dist/generators/config/wasp-config-generator.js +596 -0
- package/dist/generators/crud/crud-generator.d.ts +34 -22
- package/dist/generators/crud/crud-generator.d.ts.map +1 -1
- package/dist/generators/crud/crud-generator.js +1550 -0
- package/dist/generators/crud/index.js +1550 -0
- package/dist/generators/crud/schema.d.ts +25 -18
- package/dist/generators/crud/schema.d.ts.map +1 -1
- package/dist/generators/crud/schema.js +133 -0
- package/dist/generators/feature/feature-generator.d.ts +20 -0
- package/dist/generators/feature/feature-generator.d.ts.map +1 -0
- package/dist/generators/feature/feature-generator.js +765 -0
- package/dist/generators/feature/index.d.ts +2 -0
- package/dist/generators/feature/index.d.ts.map +1 -0
- package/dist/generators/feature/index.js +765 -0
- package/dist/generators/feature/schema.d.ts +5 -0
- package/dist/generators/feature/schema.d.ts.map +1 -0
- package/dist/generators/feature/schema.js +86 -0
- package/dist/generators/index.d.ts +1 -1
- package/dist/generators/index.d.ts.map +1 -1
- package/dist/generators/index.js +2211 -0
- package/dist/generators/job/index.js +1099 -0
- package/dist/generators/job/job-generator.d.ts +12 -23
- package/dist/generators/job/job-generator.d.ts.map +1 -1
- package/dist/generators/job/job-generator.js +1099 -0
- package/dist/generators/job/schema.d.ts +6 -18
- package/dist/generators/job/schema.d.ts.map +1 -1
- package/dist/generators/job/schema.js +152 -0
- package/dist/generators/query/index.js +1425 -0
- package/dist/generators/query/query-generator.d.ts +16 -29
- package/dist/generators/query/query-generator.d.ts.map +1 -1
- package/dist/generators/query/query-generator.js +1425 -0
- package/dist/generators/query/schema.d.ts +11 -23
- package/dist/generators/query/schema.d.ts.map +1 -1
- package/dist/generators/query/schema.js +115 -0
- package/dist/generators/route/index.js +1038 -0
- package/dist/generators/route/route-generator.d.ts +11 -20
- package/dist/generators/route/route-generator.d.ts.map +1 -1
- package/dist/generators/route/route-generator.js +1038 -0
- package/dist/generators/route/schema.d.ts +5 -15
- package/dist/generators/route/schema.d.ts.map +1 -1
- package/dist/generators/route/schema.js +90 -0
- package/dist/index.d.ts +2 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1980 -2115
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/wasp.d.ts +3 -0
- package/dist/plugins/wasp.d.ts.map +1 -0
- package/dist/types/constants.d.ts +4 -22
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/constants.js +8 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +8 -2
- package/dist/wasp-config/app.d.ts +2 -1
- package/dist/wasp-config/app.d.ts.map +1 -1
- package/dist/wasp-config/app.js +357 -0
- package/dist/wasp-config/index.js +357 -0
- package/dist/wasp-config/stubs/index.js +48 -0
- package/package.json +5 -14
- package/dist/common/plugin.d.ts +0 -2
- package/dist/common/plugin.d.ts.map +0 -1
- package/dist/generators/args.types.d.ts +0 -85
- package/dist/generators/args.types.d.ts.map +0 -1
- package/dist/generators/base/entity-generator.base.d.ts.map +0 -1
- package/dist/generators/feature-directory/feature-directory-generator.d.ts +0 -18
- package/dist/generators/feature-directory/feature-directory-generator.d.ts.map +0 -1
- package/dist/generators/feature-directory/index.d.ts +0 -2
- package/dist/generators/feature-directory/index.d.ts.map +0 -1
- package/dist/generators/feature-directory/schema.d.ts +0 -8
- package/dist/generators/feature-directory/schema.d.ts.map +0 -1
- package/dist/plugin.d.ts +0 -6
- package/dist/plugin.d.ts.map +0 -1
- /package/dist/generators/{feature-directory → feature}/templates/feature.wasp.eta +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wasp.d.ts","sourceRoot":"","sources":["../../src/plugins/wasp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAa9C,eAAO,MAAM,IAAI,EAAE,WAYlB,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ApiFlags, ApiNamespaceFlags, CrudFlags, JobFlags, OperationFlags, RouteFlags } from '../generators/args.types.js';
|
|
2
1
|
export declare const PLUGIN_NAME: "wasp";
|
|
3
2
|
/**
|
|
4
3
|
* List of valid operation types.
|
|
@@ -9,13 +8,13 @@ export declare const OPERATION_TYPES: readonly ["query", "action"];
|
|
|
9
8
|
*/
|
|
10
9
|
export type OperationType = (typeof OPERATION_TYPES)[number];
|
|
11
10
|
/**
|
|
12
|
-
* List of valid HTTP methods.
|
|
11
|
+
* List of valid API HTTP methods.
|
|
13
12
|
*/
|
|
14
|
-
export declare const
|
|
13
|
+
export declare const API_HTTP_METHODS: readonly ["ALL", "GET", "POST", "PUT", "DELETE"];
|
|
15
14
|
/**
|
|
16
|
-
* Type for valid HTTP method values.
|
|
15
|
+
* Type for valid API HTTP method values.
|
|
17
16
|
*/
|
|
18
|
-
export type
|
|
17
|
+
export type ApiHttpMethod = (typeof API_HTTP_METHODS)[number];
|
|
19
18
|
/**
|
|
20
19
|
* Map of valid operations.
|
|
21
20
|
*/
|
|
@@ -82,21 +81,4 @@ export declare const CONFIG_TYPES: {
|
|
|
82
81
|
* Type for valid config type values.
|
|
83
82
|
*/
|
|
84
83
|
export type ConfigType = (typeof CONFIG_TYPES)[keyof typeof CONFIG_TYPES];
|
|
85
|
-
/**
|
|
86
|
-
* Maps config types to their corresponding flags types
|
|
87
|
-
*/
|
|
88
|
-
interface ConfigToFlagsMap {
|
|
89
|
-
API: ApiFlags;
|
|
90
|
-
JOB: JobFlags;
|
|
91
|
-
ROUTE: RouteFlags;
|
|
92
|
-
QUERY: OperationFlags;
|
|
93
|
-
ACTION: OperationFlags;
|
|
94
|
-
CRUD: CrudFlags;
|
|
95
|
-
API_NAMESPACE: ApiNamespaceFlags;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Type helper to get flags type from config type
|
|
99
|
-
*/
|
|
100
|
-
export type GetFlagsType<T extends ConfigType> = T extends keyof ConfigToFlagsMap ? ConfigToFlagsMap[T] : never;
|
|
101
|
-
export {};
|
|
102
84
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/types/constants.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/types/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,EAAG,MAAe,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,eAAe,8BAA+B,CAAC;AAE5D;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7D;;GAEG;AACH,eAAO,MAAM,gBAAgB,kDAMnB,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;;;CAOb,CAAC;AAEX,eAAO,MAAM,eAAe;;;;;;CAMlB,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,aAAa,GACvB,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,OAAO,eAAe,CAAC,CAAC;AAEzD;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;CAIpB,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,eAAe,GACzB,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,OAAO,iBAAiB,CAAC,CAAC;AAE7D;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;CAInB,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,cAAc,GACxB,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,OAAO,gBAAgB,CAAC,CAAC;AAE3D;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAanD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY;;;;;;;;CAQf,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC"}
|
package/dist/types/constants.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
// src/types/constants.ts
|
|
2
2
|
var PLUGIN_NAME = "wasp";
|
|
3
3
|
var OPERATION_TYPES = ["query", "action"];
|
|
4
|
-
var
|
|
4
|
+
var API_HTTP_METHODS = [
|
|
5
|
+
"ALL",
|
|
6
|
+
"GET",
|
|
7
|
+
"POST",
|
|
8
|
+
"PUT",
|
|
9
|
+
"DELETE"
|
|
10
|
+
];
|
|
5
11
|
var OPERATIONS = {
|
|
6
12
|
CREATE: "create",
|
|
7
13
|
UPDATE: "update",
|
|
@@ -52,9 +58,9 @@ var CONFIG_TYPES = {
|
|
|
52
58
|
};
|
|
53
59
|
export {
|
|
54
60
|
ACTION_OPERATIONS,
|
|
61
|
+
API_HTTP_METHODS,
|
|
55
62
|
CONFIG_TYPES,
|
|
56
63
|
CRUD_OPERATIONS,
|
|
57
|
-
HTTP_METHODS,
|
|
58
64
|
OPERATIONS,
|
|
59
65
|
OPERATION_TYPES,
|
|
60
66
|
PLUGIN_NAME,
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { ACTION_OPERATIONS, CONFIG_TYPES, CRUD_OPERATIONS,
|
|
2
|
-
export type { ActionOperation, ConfigType, CrudOperation,
|
|
1
|
+
export { ACTION_OPERATIONS, API_HTTP_METHODS, CONFIG_TYPES, CRUD_OPERATIONS, OPERATION_TYPES, OPERATIONS, PLUGIN_NAME, QUERY_OPERATIONS, TYPE_DIRECTORIES, } from './constants';
|
|
2
|
+
export type { ActionOperation, ApiHttpMethod, ConfigType, CrudOperation, OperationType, QueryOperation, } from './constants';
|
|
3
3
|
export type { EntityMetadata } from './prisma.types';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,eAAe,EACf,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,eAAe,EACf,aAAa,EACb,UAAU,EACV,aAAa,EACb,aAAa,EACb,cAAc,GACf,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/types/index.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
// src/types/constants.ts
|
|
2
2
|
var PLUGIN_NAME = "wasp";
|
|
3
3
|
var OPERATION_TYPES = ["query", "action"];
|
|
4
|
-
var
|
|
4
|
+
var API_HTTP_METHODS = [
|
|
5
|
+
"ALL",
|
|
6
|
+
"GET",
|
|
7
|
+
"POST",
|
|
8
|
+
"PUT",
|
|
9
|
+
"DELETE"
|
|
10
|
+
];
|
|
5
11
|
var OPERATIONS = {
|
|
6
12
|
CREATE: "create",
|
|
7
13
|
UPDATE: "update",
|
|
@@ -52,9 +58,9 @@ var CONFIG_TYPES = {
|
|
|
52
58
|
};
|
|
53
59
|
export {
|
|
54
60
|
ACTION_OPERATIONS,
|
|
61
|
+
API_HTTP_METHODS,
|
|
55
62
|
CONFIG_TYPES,
|
|
56
63
|
CRUD_OPERATIONS,
|
|
57
|
-
HTTP_METHODS,
|
|
58
64
|
OPERATIONS,
|
|
59
65
|
OPERATION_TYPES,
|
|
60
66
|
PLUGIN_NAME,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { ActionConfig, ApiConfig, ApiNamespaceConfig, AppConfig, AuthConfig, ClientConfig, CrudConfig, DbConfig, EmailSenderConfig, JobConfig, QueryConfig, RouteConfig, App as WaspApp } from 'wasp-config';
|
|
2
|
+
import { ApiHttpMethod } from '../types';
|
|
2
3
|
interface RouteOptions {
|
|
3
4
|
path: string;
|
|
4
5
|
auth?: boolean;
|
|
5
6
|
}
|
|
6
7
|
interface ApiOptions {
|
|
7
|
-
method:
|
|
8
|
+
method: ApiHttpMethod;
|
|
8
9
|
route: string;
|
|
9
10
|
customMiddleware?: boolean;
|
|
10
11
|
entities?: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/wasp-config/app.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,YAAY,EACZ,SAAS,EACT,kBAAkB,EAClB,SAAS,EACT,UAAU,EACV,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,iBAAiB,EACjB,SAAS,EACT,WAAW,EACX,WAAW,EACX,GAAG,IAAI,OAAO,EACf,MAAM,aAAa,CAAC;
|
|
1
|
+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AU,GAAG,IAAI;IA+B3E;;;;;OAKG;IACI,OAAO,CACZ,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,WAAW,GACnB,IAAI;IA8CP;;;;;OAKG;IACI,SAAS,CACd,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,gBAAgB,GACxB,IAAI;IAmBP;;;;;OAKG;IACI,QAAQ,CACb,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,gBAAgB,GACxB,IAAI;IAmBP;;;;;OAKG;IACI,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAG,IAAI;IA4B3E;;;;;OAKG;IACI,eAAe,CACpB,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,mBAAmB,GAC3B,IAAI;IAmBP;;;;;;;OAOG;IACH,OAAO,CAAC,oBAAoB;IAW5B;;;;OAIG;IACH,OAAO,CAAC,SAAS;IAgBjB;;OAEG;IACG,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAoDxC;;;;;;OAMG;IACH,OAAO,CAAC,kBAAkB;CAe3B"}
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
// src/wasp-config/app.ts
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import {
|
|
5
|
+
App as WaspApp
|
|
6
|
+
} from "wasp-config";
|
|
7
|
+
var App = class _App extends WaspApp {
|
|
8
|
+
constructor(name, config) {
|
|
9
|
+
super(name, config);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Static factory method that creates and initializes Swarm with configuration
|
|
13
|
+
* dynamically loaded from feature directories
|
|
14
|
+
*
|
|
15
|
+
* @param name The name of the application
|
|
16
|
+
* @param config The base configuration for the application
|
|
17
|
+
* @returns An initialized Swarm instance
|
|
18
|
+
*/
|
|
19
|
+
static async create(name, config) {
|
|
20
|
+
const app = new _App(name, config);
|
|
21
|
+
await app.configureFeatures();
|
|
22
|
+
return app;
|
|
23
|
+
}
|
|
24
|
+
// Chainable configuration methods
|
|
25
|
+
auth(authConfig) {
|
|
26
|
+
super.auth(authConfig);
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
client(clientConfig) {
|
|
30
|
+
super.client(clientConfig);
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
db(dbConfig) {
|
|
34
|
+
super.db(dbConfig);
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
emailSender(emailSenderConfig) {
|
|
38
|
+
super.emailSender(emailSenderConfig);
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
41
|
+
job(name, jobConfig) {
|
|
42
|
+
super.job(name, jobConfig);
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
query(name, queryConfig) {
|
|
46
|
+
super.query(name, queryConfig);
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
route(name, routeConfig) {
|
|
50
|
+
super.route(name, routeConfig);
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
api(name, apiConfig) {
|
|
54
|
+
super.api(name, apiConfig);
|
|
55
|
+
return this;
|
|
56
|
+
}
|
|
57
|
+
apiNamespace(name, apiNamespaceConfig) {
|
|
58
|
+
super.apiNamespace(name, apiNamespaceConfig);
|
|
59
|
+
return this;
|
|
60
|
+
}
|
|
61
|
+
crud(name, crudConfig) {
|
|
62
|
+
super.crud(name, crudConfig);
|
|
63
|
+
return this;
|
|
64
|
+
}
|
|
65
|
+
action(name, actionConfig) {
|
|
66
|
+
super.action(name, actionConfig);
|
|
67
|
+
return this;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Helper method to add routes with simplified parameters
|
|
71
|
+
* @param featureName The name of the feature
|
|
72
|
+
* @param name Route name, e.g. "DashboardRoute"
|
|
73
|
+
* @param options Route configuration options
|
|
74
|
+
*/
|
|
75
|
+
addRoute(featureName, name, options) {
|
|
76
|
+
const componentName = name.charAt(0).toUpperCase() + name.slice(1);
|
|
77
|
+
const importPath = this.getFeatureImportPath(
|
|
78
|
+
featureName,
|
|
79
|
+
"client",
|
|
80
|
+
"pages",
|
|
81
|
+
componentName
|
|
82
|
+
);
|
|
83
|
+
const routeConfig = {
|
|
84
|
+
path: options.path,
|
|
85
|
+
to: this.page(componentName, {
|
|
86
|
+
authRequired: options.auth || false,
|
|
87
|
+
component: {
|
|
88
|
+
import: componentName,
|
|
89
|
+
from: `@src/${importPath}`
|
|
90
|
+
}
|
|
91
|
+
})
|
|
92
|
+
};
|
|
93
|
+
super.route(name, routeConfig);
|
|
94
|
+
return this;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Helper method to add API endpoints with simplified parameters
|
|
98
|
+
* @param featureName The name of the feature
|
|
99
|
+
* @param name API endpoint name, e.g. "getTasksApi"
|
|
100
|
+
* @param options API configuration options
|
|
101
|
+
*/
|
|
102
|
+
addApi(featureName, name, options) {
|
|
103
|
+
const importPath = this.getFeatureImportPath(
|
|
104
|
+
featureName,
|
|
105
|
+
"server",
|
|
106
|
+
"apis",
|
|
107
|
+
name
|
|
108
|
+
);
|
|
109
|
+
const middlewareImportPath = this.getFeatureImportPath(
|
|
110
|
+
featureName,
|
|
111
|
+
"server",
|
|
112
|
+
"middleware",
|
|
113
|
+
name
|
|
114
|
+
);
|
|
115
|
+
super.api(name, {
|
|
116
|
+
fn: {
|
|
117
|
+
import: name,
|
|
118
|
+
from: `@src/${importPath}`
|
|
119
|
+
},
|
|
120
|
+
...options.customMiddleware && {
|
|
121
|
+
import: name,
|
|
122
|
+
from: `@src/${middlewareImportPath}`
|
|
123
|
+
},
|
|
124
|
+
entities: options.entities,
|
|
125
|
+
httpRoute: { method: options.method, route: options.route },
|
|
126
|
+
auth: options.auth || false
|
|
127
|
+
});
|
|
128
|
+
return this;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Helper method to add CRUD operations with simplified parameters
|
|
132
|
+
* @param featureName The name of the feature
|
|
133
|
+
* @param name The CRUD name
|
|
134
|
+
* @param options CRUD configuration options
|
|
135
|
+
*/
|
|
136
|
+
addCrud(featureName, name, options) {
|
|
137
|
+
const processOperationOptions = (operationName, operationOptions) => {
|
|
138
|
+
if (!operationOptions) return void 0;
|
|
139
|
+
const processedOptions = { ...operationOptions };
|
|
140
|
+
if (operationOptions.override) {
|
|
141
|
+
const operationDataType = operationName === "getAll" ? this.getPlural(options.entity) : options.entity;
|
|
142
|
+
const operationComponent = `${operationName}${operationDataType}`;
|
|
143
|
+
const importPath = this.getFeatureImportPath(
|
|
144
|
+
featureName,
|
|
145
|
+
"server",
|
|
146
|
+
"cruds",
|
|
147
|
+
name.charAt(0).toLowerCase() + name.slice(1)
|
|
148
|
+
);
|
|
149
|
+
processedOptions.overrideFn = {
|
|
150
|
+
import: operationComponent,
|
|
151
|
+
from: `@src/${importPath}`
|
|
152
|
+
};
|
|
153
|
+
delete processedOptions.override;
|
|
154
|
+
}
|
|
155
|
+
return processedOptions;
|
|
156
|
+
};
|
|
157
|
+
super.crud(this.getPlural(options.entity), {
|
|
158
|
+
entity: options.entity,
|
|
159
|
+
operations: {
|
|
160
|
+
getAll: processOperationOptions("getAll", options.getAll),
|
|
161
|
+
get: processOperationOptions("get", options.get),
|
|
162
|
+
create: processOperationOptions("create", options.create),
|
|
163
|
+
update: processOperationOptions("update", options.update),
|
|
164
|
+
delete: processOperationOptions("delete", options.delete)
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
return this;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Helper method to add actions with simplified parameters
|
|
171
|
+
* @param featureName The name of the feature
|
|
172
|
+
* @param name The action name
|
|
173
|
+
* @param options Action configuration options
|
|
174
|
+
*/
|
|
175
|
+
addAction(featureName, name, options) {
|
|
176
|
+
const importPath = this.getFeatureImportPath(
|
|
177
|
+
featureName,
|
|
178
|
+
"server",
|
|
179
|
+
"actions",
|
|
180
|
+
name
|
|
181
|
+
);
|
|
182
|
+
const config = this.getOperationConfig(
|
|
183
|
+
name,
|
|
184
|
+
importPath,
|
|
185
|
+
options.entities,
|
|
186
|
+
options.auth
|
|
187
|
+
);
|
|
188
|
+
super.action(name, config);
|
|
189
|
+
return this;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Helper method to add queries with simplified parameters
|
|
193
|
+
* @param featureName The name of the feature
|
|
194
|
+
* @param name The query name
|
|
195
|
+
* @param options Query configuration options
|
|
196
|
+
*/
|
|
197
|
+
addQuery(featureName, name, options) {
|
|
198
|
+
const importPath = this.getFeatureImportPath(
|
|
199
|
+
featureName,
|
|
200
|
+
"server",
|
|
201
|
+
"queries",
|
|
202
|
+
name
|
|
203
|
+
);
|
|
204
|
+
const config = this.getOperationConfig(
|
|
205
|
+
name,
|
|
206
|
+
importPath,
|
|
207
|
+
options.entities,
|
|
208
|
+
options.auth
|
|
209
|
+
);
|
|
210
|
+
super.query(name, config);
|
|
211
|
+
return this;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Helper method to add background jobs with simplified parameters
|
|
215
|
+
* @param featureName The name of the feature
|
|
216
|
+
* @param name Job name
|
|
217
|
+
* @param options Job configuration options
|
|
218
|
+
*/
|
|
219
|
+
addJob(featureName, name, options) {
|
|
220
|
+
const importPath = this.getFeatureImportPath(
|
|
221
|
+
featureName,
|
|
222
|
+
"server",
|
|
223
|
+
"jobs",
|
|
224
|
+
name
|
|
225
|
+
);
|
|
226
|
+
super.job(name, {
|
|
227
|
+
executor: "PgBoss",
|
|
228
|
+
perform: {
|
|
229
|
+
fn: {
|
|
230
|
+
import: name,
|
|
231
|
+
from: `@src/${importPath}`
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
entities: options.entities,
|
|
235
|
+
...options.cron && {
|
|
236
|
+
schedule: {
|
|
237
|
+
cron: options.cron,
|
|
238
|
+
args: options.args || {}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
return this;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Helper method to add API namespaces with simplified parameters
|
|
246
|
+
* @param featureName The name of the feature
|
|
247
|
+
* @param name Namespace name
|
|
248
|
+
* @param options API namespace configuration options
|
|
249
|
+
*/
|
|
250
|
+
addApiNamespace(featureName, name, options) {
|
|
251
|
+
const importPath = this.getFeatureImportPath(
|
|
252
|
+
featureName,
|
|
253
|
+
"server",
|
|
254
|
+
"middleware",
|
|
255
|
+
name
|
|
256
|
+
);
|
|
257
|
+
super.apiNamespace(name, {
|
|
258
|
+
path: options.path,
|
|
259
|
+
middlewareConfigFn: {
|
|
260
|
+
import: name,
|
|
261
|
+
from: `@src/${importPath}`
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
return this;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Calculates the import path for a feature component
|
|
268
|
+
* @param featureName The name of the feature
|
|
269
|
+
* @param type The type of component (client, server, etc.)
|
|
270
|
+
* @param subPath The sub-path within the feature directory
|
|
271
|
+
* @param fileName The name of the file (optional, defaults to featureName)
|
|
272
|
+
* @returns The calculated import path
|
|
273
|
+
*/
|
|
274
|
+
getFeatureImportPath(featureName, type, subPath, fileName) {
|
|
275
|
+
const file = fileName || featureName;
|
|
276
|
+
return `features/${featureName}/${type}/${subPath}/${file}`;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Converts a singular word to its plural form
|
|
280
|
+
* @param word The singular word to pluralize
|
|
281
|
+
* @returns The plural form of the word
|
|
282
|
+
*/
|
|
283
|
+
getPlural(word) {
|
|
284
|
+
if (word.endsWith("y")) {
|
|
285
|
+
return word.slice(0, -1) + "ies";
|
|
286
|
+
} else if (word.endsWith("s") || word.endsWith("sh") || word.endsWith("ch") || word.endsWith("x") || word.endsWith("z")) {
|
|
287
|
+
return word + "es";
|
|
288
|
+
} else {
|
|
289
|
+
return word + "s";
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Configures all feature modules by scanning the features directory
|
|
294
|
+
*/
|
|
295
|
+
async configureFeatures() {
|
|
296
|
+
const featuresDir = path.join(process.cwd(), "src", "features");
|
|
297
|
+
if (!fs.existsSync(featuresDir)) {
|
|
298
|
+
console.warn(
|
|
299
|
+
"Features directory not found, skipping feature configuration"
|
|
300
|
+
);
|
|
301
|
+
return this;
|
|
302
|
+
}
|
|
303
|
+
const getAllFeatureFiles = (dir) => {
|
|
304
|
+
let results = [];
|
|
305
|
+
const list = fs.readdirSync(dir, { withFileTypes: true });
|
|
306
|
+
for (const entry of list) {
|
|
307
|
+
const fullPath = path.join(dir, entry.name);
|
|
308
|
+
if (entry.isDirectory()) {
|
|
309
|
+
results = results.concat(getAllFeatureFiles(fullPath));
|
|
310
|
+
} else if (entry.isFile() && entry.name.endsWith(".wasp.ts")) {
|
|
311
|
+
results.push(path.relative(featuresDir, fullPath));
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
return results;
|
|
315
|
+
};
|
|
316
|
+
const featureFiles = getAllFeatureFiles(featuresDir);
|
|
317
|
+
for (const file of featureFiles) {
|
|
318
|
+
try {
|
|
319
|
+
const featureName = path.dirname(file);
|
|
320
|
+
const modulePath = path.join(
|
|
321
|
+
process.cwd(),
|
|
322
|
+
".wasp",
|
|
323
|
+
"src",
|
|
324
|
+
"features",
|
|
325
|
+
file.replace(".ts", ".js")
|
|
326
|
+
);
|
|
327
|
+
const module = await import(modulePath);
|
|
328
|
+
if (module.default) {
|
|
329
|
+
module.default(this, featureName);
|
|
330
|
+
}
|
|
331
|
+
} catch (error) {
|
|
332
|
+
console.error(`Failed to load feature module ${file}:`, error);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
return this;
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Helper method to get the configuration for an action or query
|
|
339
|
+
* @param name The operation name
|
|
340
|
+
* @param importPath Import path (excluding `@src/` prefix), e.g. "features/dashboard/server/queries/getTasks"
|
|
341
|
+
* @param entities Comma-separated list of entities (optional, defaults to datatype)
|
|
342
|
+
* @param auth Require authentication (optional)
|
|
343
|
+
*/
|
|
344
|
+
getOperationConfig(name, importPath, entities, auth) {
|
|
345
|
+
return {
|
|
346
|
+
fn: {
|
|
347
|
+
import: name,
|
|
348
|
+
from: `@src/${importPath}`
|
|
349
|
+
},
|
|
350
|
+
entities,
|
|
351
|
+
auth: auth || false
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
export {
|
|
356
|
+
App
|
|
357
|
+
};
|