@ingenyus/swarm-wasp 0.1.0 → 0.2.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/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.js +391 -0
- package/dist/common/plugin.js +41 -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 +1429 -0
- package/dist/generators/action/index.js +1429 -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 +119 -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 +1108 -0
- package/dist/generators/api/index.js +1108 -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 +121 -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 +1032 -0
- package/dist/generators/api-namespace/index.js +1032 -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 +93 -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 +935 -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 +1334 -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 +1335 -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 +710 -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 +600 -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 +600 -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 +1554 -0
- package/dist/generators/crud/index.js +1554 -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 +137 -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 +769 -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 +769 -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 +90 -0
- package/dist/generators/index.d.ts +1 -1
- package/dist/generators/index.d.ts.map +1 -1
- package/dist/generators/index.js +2215 -0
- package/dist/generators/job/index.js +1103 -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 +1103 -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 +156 -0
- package/dist/generators/query/index.js +1429 -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 +1429 -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 +119 -0
- package/dist/generators/route/index.js +1042 -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 +1042 -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 +94 -0
- package/dist/index.d.ts +2 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1730 -1839
- 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/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,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
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// src/wasp-config/stubs/index.ts
|
|
2
|
+
var App = class {
|
|
3
|
+
name;
|
|
4
|
+
config;
|
|
5
|
+
constructor(name, config) {
|
|
6
|
+
this.name = name;
|
|
7
|
+
this.config = config;
|
|
8
|
+
}
|
|
9
|
+
auth(_authConfig) {
|
|
10
|
+
return this;
|
|
11
|
+
}
|
|
12
|
+
client(_clientConfig) {
|
|
13
|
+
return this;
|
|
14
|
+
}
|
|
15
|
+
db(_dbConfig) {
|
|
16
|
+
return this;
|
|
17
|
+
}
|
|
18
|
+
emailSender(_emailSenderConfig) {
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
21
|
+
job(_name, _jobConfig) {
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
query(_name, _queryConfig) {
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
route(_name, _routeConfig) {
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
api(_name, _apiConfig) {
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
apiNamespace(_name, _apiNamespaceConfig) {
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
crud(_name, _crudConfig) {
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
action(_name, _actionConfig) {
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
page(_componentName, options) {
|
|
43
|
+
return { authRequired: options.authRequired, component: options.component };
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
export {
|
|
47
|
+
App
|
|
48
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ingenyus/swarm-wasp",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"description": "Wasp-specific plugins for Swarm - Feature generators, commands, MCP tools, and enhanced Wasp configuration for Wasp development",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -41,10 +41,9 @@
|
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@mrleebo/prisma-ast": "^0.13.0",
|
|
44
|
-
"@vitest/coverage-v8": "^3.2.3",
|
|
45
44
|
"eta": "^4.0.1",
|
|
46
45
|
"zod": "^4.1.11",
|
|
47
|
-
"@ingenyus/swarm": "0.
|
|
46
|
+
"@ingenyus/swarm": "0.2.0"
|
|
48
47
|
},
|
|
49
48
|
"peerDependencies": {
|
|
50
49
|
"wasp-config": "*"
|
|
@@ -56,7 +55,9 @@
|
|
|
56
55
|
},
|
|
57
56
|
"devDependencies": {
|
|
58
57
|
"@types/node": "^24.3.0",
|
|
58
|
+
"@vitest/coverage-v8": "^3.2.3",
|
|
59
59
|
"glob": "^11.0.3",
|
|
60
|
+
"rimraf": "^6.0.1",
|
|
60
61
|
"tsup": "^8.5.0",
|
|
61
62
|
"typescript": "^5.9.2",
|
|
62
63
|
"vitest": "^3.1.4",
|
|
@@ -65,18 +66,8 @@
|
|
|
65
66
|
"publishConfig": {
|
|
66
67
|
"access": "public"
|
|
67
68
|
},
|
|
68
|
-
"swarm": {
|
|
69
|
-
"plugins": {
|
|
70
|
-
"wasp": {
|
|
71
|
-
"entry": "./dist/index.js",
|
|
72
|
-
"name": "wasp",
|
|
73
|
-
"description": "Wasp Plugin for Swarm",
|
|
74
|
-
"version": "0.1.0"
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
69
|
"scripts": {
|
|
79
|
-
"build": "
|
|
70
|
+
"build": "rimraf dist && tsup && tsc --project tsconfig.dts.json && pnpm copy-templates && pnpm pack",
|
|
80
71
|
"build:watch": "tsc --watch",
|
|
81
72
|
"copy-templates": "for dir in src/generators/*/templates; do if [ -d \"$dir\" ]; then generator=$(basename $(dirname $dir)); mkdir -p dist/generators/$generator/templates; cp -r $dir/* dist/generators/$generator/templates/; fi; done",
|
|
82
73
|
"test": "vitest run",
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { ActionOperation, CrudOperation, HttpMethod, QueryOperation } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Common flags used across different generators
|
|
4
|
-
* @interface CommonGeneratorFlags
|
|
5
|
-
*/
|
|
6
|
-
interface CommonGeneratorFlags {
|
|
7
|
-
/** Feature path/name */
|
|
8
|
-
feature: string;
|
|
9
|
-
/** Resource name (API, Job, Route, etc.) */
|
|
10
|
-
name: string;
|
|
11
|
-
/** Data type/model name */
|
|
12
|
-
dataType: string;
|
|
13
|
-
/** Operation type (for queries/actions) */
|
|
14
|
-
operation: ActionOperation | QueryOperation;
|
|
15
|
-
/** HTTP method (for APIs) */
|
|
16
|
-
method: HttpMethod;
|
|
17
|
-
/** Route/API path */
|
|
18
|
-
path: string;
|
|
19
|
-
/** Route path (alias for path) */
|
|
20
|
-
route: string;
|
|
21
|
-
/** Entities to include */
|
|
22
|
-
entities?: string | string[];
|
|
23
|
-
/** Force overwrite existing files */
|
|
24
|
-
force?: boolean;
|
|
25
|
-
/** Require authentication */
|
|
26
|
-
auth?: boolean;
|
|
27
|
-
/** Cron schedule (for jobs) */
|
|
28
|
-
cron?: string;
|
|
29
|
-
/** Schedule arguments (for jobs) */
|
|
30
|
-
args?: string;
|
|
31
|
-
/** Public operations (for CRUD) */
|
|
32
|
-
public?: CrudOperation[];
|
|
33
|
-
/** Override operations (for CRUD) */
|
|
34
|
-
override?: CrudOperation[];
|
|
35
|
-
/** Exclude operations (for CRUD) */
|
|
36
|
-
exclude?: CrudOperation[];
|
|
37
|
-
/** Enable custom middleware for API definitions */
|
|
38
|
-
customMiddleware?: boolean;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Operation-specific flags
|
|
42
|
-
*/
|
|
43
|
-
export type OperationFlags = Pick<CommonGeneratorFlags, 'feature' | 'entities' | 'force' | 'auth' | 'operation' | 'dataType'>;
|
|
44
|
-
/**
|
|
45
|
-
* Action-specific flags
|
|
46
|
-
*/
|
|
47
|
-
export type ActionFlags = Pick<CommonGeneratorFlags, 'feature' | 'entities' | 'force' | 'auth' | 'dataType' | 'name'> & {
|
|
48
|
-
operation: ActionOperation;
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* Query-specific flags
|
|
52
|
-
*/
|
|
53
|
-
export type QueryFlags = Pick<CommonGeneratorFlags, 'feature' | 'entities' | 'force' | 'auth' | 'dataType' | 'name'> & {
|
|
54
|
-
operation: QueryOperation;
|
|
55
|
-
};
|
|
56
|
-
/**
|
|
57
|
-
* API-specific flags
|
|
58
|
-
*/
|
|
59
|
-
export type ApiFlags = Pick<CommonGeneratorFlags, 'feature' | 'name' | 'method' | 'route' | 'force' | 'entities' | 'auth' | 'customMiddleware'>;
|
|
60
|
-
/**
|
|
61
|
-
* Job-specific flags
|
|
62
|
-
*/
|
|
63
|
-
export type JobFlags = Pick<CommonGeneratorFlags, 'feature' | 'name' | 'entities' | 'cron' | 'args' | 'force'>;
|
|
64
|
-
/**
|
|
65
|
-
* Route-specific flags
|
|
66
|
-
*/
|
|
67
|
-
export type RouteFlags = Pick<CommonGeneratorFlags, 'feature' | 'name' | 'force' | 'auth' | 'path'>;
|
|
68
|
-
/**
|
|
69
|
-
* CRUD-specific flags
|
|
70
|
-
*/
|
|
71
|
-
export type CrudFlags = Pick<CommonGeneratorFlags, 'feature' | 'public' | 'override' | 'exclude' | 'force' | 'dataType' | 'auth'>;
|
|
72
|
-
/**
|
|
73
|
-
* ApiNamespace-specific flags
|
|
74
|
-
*/
|
|
75
|
-
export type ApiNamespaceFlags = Pick<CommonGeneratorFlags, 'feature' | 'name' | 'path' | 'force'>;
|
|
76
|
-
/**
|
|
77
|
-
* Represents a configuration entry for an operation.
|
|
78
|
-
*/
|
|
79
|
-
export interface OperationConfigEntry {
|
|
80
|
-
operationName: string;
|
|
81
|
-
entities: string[];
|
|
82
|
-
authRequired: boolean;
|
|
83
|
-
}
|
|
84
|
-
export {};
|
|
85
|
-
//# sourceMappingURL=args.types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"args.types.d.ts","sourceRoot":"","sources":["../../src/generators/args.types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,aAAa,EACb,UAAU,EACV,cAAc,EACf,MAAM,UAAU,CAAC;AAElB;;;GAGG;AACH,UAAU,oBAAoB;IAC5B,wBAAwB;IACxB,OAA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U,GAAG,OAAO,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,CAChE,GAAG;IACF,SAAS,EAAE,cAAc,CAAC;CAC3B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,IAAI,CACzB,oBAAoB,EAClB,SAAS,GACT,MAAM,GACN,QAAQ,GACR,OAAO,GACP,OAAO,GACP,UAAU,GACV,MAAM,GACN,kBAAkB,CACrB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,IAAI,CACzB,oBAAoB,EACpB,SAAS,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAC5D,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,IAAI,CAC3B,oBAAoB,EACpB,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAC/C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,IAAI,CAC1B,oBAAoB,EACpB,SAAS,GAAG,QAAQ,GAAG,UAAU,GAAG,SAAS,GAAG,OAAO,GAAG,UAAU,GAAG,MAAM,CAC9E,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAClC,oBAAoB,EACpB,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CACtC,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;CACvB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"entity-generator.base.d.ts","sourceRoot":"","sources":["../../../src/generators/base/entity-generator.base.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAEV,MAAM,EAEN,cAAc,EAIf,MAAM,iBAAiB,CAAC;AAQzB,OAAO,EAAE,UAAU,EAAE,YAAY,EAAoB,MAAM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ClB,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,OAAO,GACb,IAAI;IAmBP;;;;;;OAMG;IACH,SAAS,CAAC,mBAAmB,CAC3B,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,GACX;QAAE,eAAe,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAE;IAavD;;OAEG;IACH,SAAS,CAAC,qBAAqB,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;;;;IAYjE;;OAEG;cACa,sBAAsB,CACpC,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,IAAI,CAAC;CAcjB"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { ExtendedSchema, FileSystem, Logger } from '@ingenyus/swarm';
|
|
2
|
-
import { WaspGeneratorBase } from '../base/wasp-generator.base';
|
|
3
|
-
import { SchemaArgs } from './schema';
|
|
4
|
-
export declare class FeatureDirectoryGenerator extends WaspGeneratorBase<SchemaArgs> {
|
|
5
|
-
logger: Logger;
|
|
6
|
-
fileSystem: FileSystem;
|
|
7
|
-
name: string;
|
|
8
|
-
description: string;
|
|
9
|
-
schema: ExtendedSchema;
|
|
10
|
-
constructor(logger?: Logger, fileSystem?: FileSystem);
|
|
11
|
-
protected getDefaultTemplatePath(templateName: string): string;
|
|
12
|
-
/**
|
|
13
|
-
* Generate feature directory structure (main entry point)
|
|
14
|
-
* @param featurePath - The path to the feature
|
|
15
|
-
*/
|
|
16
|
-
generate(flags: SchemaArgs): Promise<void>;
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=feature-directory-generator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"feature-directory-generator.d.ts","sourceRoot":"","sources":["../../../src/generators/feature-directory/feature-directory-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,UAAU,EAEV,MAAM,EAGP,MAAM,iBAAiB,CAAC;AAOzB,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAU,UAAU,EAAE,MAAM,UAAU,CAAC;AAE9C,qBAAa,yBAA0B,SAAQ,iBAAiB,CAAC,UAAU,CAAC;IAMjE,MAAM,EAAE,MAAM;IACd,UAAU,EAAE,UAAU;IAN/B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,cAAc,CAAC;gBAGd,MAAM,GAAE,MAA4B,EACpC,UAAU,GAAE,UAA2B;IAQhD,SAAS,CAAC,sBAAsB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM;IAQ9D;;;OAGG;IACG,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;CA0BjD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/generators/feature-directory/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/generators/feature-directory/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,MAAM;;;;iBAEjB,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,MAAM,CAAC,CAAC"}
|
package/dist/plugin.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { SwarmPluginInterface } from '@ingenyus/swarm';
|
|
2
|
-
export declare function createWaspPlugin(): SwarmPluginInterface;
|
|
3
|
-
declare function getWaspPlugin(): SwarmPluginInterface;
|
|
4
|
-
export declare const wasp: typeof getWaspPlugin;
|
|
5
|
-
export {};
|
|
6
|
-
//# sourceMappingURL=plugin.d.ts.map
|
package/dist/plugin.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAcvD,wBAAgB,gBAAgB,IAAI,oBAAoB,CAiBvD;AAKD,iBAAS,aAAa,IAAI,oBAAoB,CAM7C;AAGD,eAAO,MAAM,IAAI,sBAAgB,CAAC"}
|
|
File without changes
|