@soapjs/cli 1.0.0 → 1.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 +3 -0
- package/build/cli.js +2 -3
- package/build/commands/add/add.command.js +1 -2
- package/build/commands/add/command-plan.js +7 -8
- package/build/commands/add/entity-plan.js +1 -2
- package/build/commands/add/event-plan.js +1 -2
- package/build/commands/add/query-plan.js +6 -7
- package/build/commands/add/repository-plan.js +5 -6
- package/build/commands/add/resource-plan.js +16 -17
- package/build/commands/add/route-plan.js +7 -7
- package/build/commands/add/socket-plan.js +1 -2
- package/build/commands/add/use-case-plan.js +2 -3
- package/build/commands/check/check.command.js +1 -2
- package/build/commands/create/create.command.js +2 -3
- package/build/commands/create/project-plan.js +256 -216
- package/build/commands/doctor/doctor.command.js +1 -2
- package/build/commands/generate/bruno-analysis.js +4 -5
- package/build/commands/generate/bruno-plan.js +1 -2
- package/build/commands/generate/generate.command.js +1 -2
- package/build/commands/info/info.command.js +1 -2
- package/build/commands/remove/remove.command.js +1 -2
- package/build/commands/shared/common-options.js +3 -4
- package/build/commands/update/update.command.js +1 -2
- package/build/config/auth-policy.js +3 -4
- package/build/config/find-soap-root.js +1 -2
- package/build/config/load-soap-config.js +1 -2
- package/build/config/schemas/types.d.ts +1 -1
- package/build/config/schemas/validation.js +5 -6
- package/build/config/write-soap-config.js +1 -2
- package/build/core/command-context.js +2 -3
- package/build/core/errors.js +2 -2
- package/build/core/output.js +1 -2
- package/build/core/result.js +2 -3
- package/build/dependencies/dependency-resolver.js +5 -8
- package/build/dependencies/package-manager.js +3 -4
- package/build/io/conflict-policy.js +3 -4
- package/build/io/file-writer.js +1 -2
- package/build/io/format-file.js +1 -2
- package/build/presets/create-presets.js +3 -3
- package/build/prompts/add-resource.prompt.js +1 -2
- package/build/prompts/add-route.prompt.js +1 -2
- package/build/prompts/create-project.prompt.js +3 -2
- package/build/prompts/generate-bruno.prompt.js +1 -2
- package/build/prompts/inquirer-prompt-adapter.js +14 -5
- package/build/registry/registry.service.js +5 -6
- package/build/summary/create-summary.js +1 -2
- package/build/templates/naming.js +2 -3
- package/build/templates/template-engine.js +1 -2
- package/build/templates/template-resolver.js +2 -3
- package/build/terminal/terminal-capabilities.js +2 -3
- package/docs/cli/create.md +4 -1
- package/docs/guides/auth.md +9 -1
- package/docs/guides/index.md +1 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -101,6 +101,7 @@ Common options:
|
|
|
101
101
|
- `--db mongo|postgres|mysql|sqlite|redis|none`
|
|
102
102
|
- `--auth jwt|api-key|local|none`
|
|
103
103
|
- `--messaging in-memory|kafka|none`
|
|
104
|
+
- `--telemetry logs|otel-noop|metrics|memory|none`
|
|
104
105
|
- `--docs openapi|none`
|
|
105
106
|
- `--contracts zod|none`
|
|
106
107
|
- `--api-client bruno|none`
|
|
@@ -111,6 +112,8 @@ Common options:
|
|
|
111
112
|
- `--git-init` to initialize a local git repository without committing or pushing
|
|
112
113
|
- `--force` and `--write-new` for generated file conflicts
|
|
113
114
|
|
|
115
|
+
Generated projects use `@soapjs/soap-auth` 1.x with `SoapAuth.create(...)` and the `@soapjs/soap-express/auth` router/middleware helpers. Security defaults are generated through soap-express security config, including disabled `x-powered-by`, trust proxy, helmet, cors, and auth route throttling when auth is enabled.
|
|
116
|
+
|
|
114
117
|
## `soap add resource`
|
|
115
118
|
|
|
116
119
|
Add a resource to an existing SoapJS project:
|
package/build/cli.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.buildProgram = buildProgram;
|
|
4
|
+
exports.runCli = runCli;
|
|
4
5
|
const commander_1 = require("commander");
|
|
5
6
|
const command_context_1 = require("./core/command-context");
|
|
6
7
|
const errors_1 = require("./core/errors");
|
|
@@ -35,7 +36,6 @@ function buildProgram() {
|
|
|
35
36
|
});
|
|
36
37
|
return program;
|
|
37
38
|
}
|
|
38
|
-
exports.buildProgram = buildProgram;
|
|
39
39
|
async function runCli(argv) {
|
|
40
40
|
const program = buildProgram();
|
|
41
41
|
try {
|
|
@@ -47,4 +47,3 @@ async function runCli(argv) {
|
|
|
47
47
|
process.exitCode = 1;
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
exports.runCli = runCli;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.registerAddCommand =
|
|
3
|
+
exports.registerAddCommand = registerAddCommand;
|
|
4
4
|
const command_context_1 = require("../../core/command-context");
|
|
5
5
|
const errors_1 = require("../../core/errors");
|
|
6
6
|
const load_soap_config_1 = require("../../config/load-soap-config");
|
|
@@ -482,7 +482,6 @@ function registerAddCommand(program) {
|
|
|
482
482
|
context.output.success(`Added socket ${(0, naming_1.createNameVariants)(name).kebabName}`);
|
|
483
483
|
});
|
|
484
484
|
}
|
|
485
|
-
exports.registerAddCommand = registerAddCommand;
|
|
486
485
|
function firstOrNone(values) {
|
|
487
486
|
return values[0] ?? "none";
|
|
488
487
|
}
|
|
@@ -3,7 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.createCommandFiles = createCommandFiles;
|
|
7
|
+
exports.createCommandIndexFile = createCommandIndexFile;
|
|
8
|
+
exports.createCqrsConfigFile = createCqrsConfigFile;
|
|
9
|
+
exports.commandNameFromPath = commandNameFromPath;
|
|
10
|
+
exports.commandFeatureFromPath = commandFeatureFromPath;
|
|
7
11
|
const path_1 = __importDefault(require("path"));
|
|
8
12
|
const naming_1 = require("../../templates/naming");
|
|
9
13
|
function createCommandFiles(plan) {
|
|
@@ -31,7 +35,6 @@ function createCommandFiles(plan) {
|
|
|
31
35
|
},
|
|
32
36
|
];
|
|
33
37
|
}
|
|
34
|
-
exports.createCommandFiles = createCommandFiles;
|
|
35
38
|
function createCommandIndexFile(feature, featuresRoot, commandNames) {
|
|
36
39
|
const featureNames = (0, naming_1.createNameVariants)(feature);
|
|
37
40
|
const uniqueCommandNames = Array.from(new Set(commandNames)).sort();
|
|
@@ -52,7 +55,6 @@ function createCommandIndexFile(feature, featuresRoot, commandNames) {
|
|
|
52
55
|
`,
|
|
53
56
|
};
|
|
54
57
|
}
|
|
55
|
-
exports.createCommandIndexFile = createCommandIndexFile;
|
|
56
58
|
function createCqrsConfigFile(featuresRoot, importsByKind) {
|
|
57
59
|
const normalized = Array.isArray(importsByKind)
|
|
58
60
|
? { commands: importsByKind, queries: [] }
|
|
@@ -77,18 +79,15 @@ export {};
|
|
|
77
79
|
`,
|
|
78
80
|
};
|
|
79
81
|
}
|
|
80
|
-
exports.createCqrsConfigFile = createCqrsConfigFile;
|
|
81
82
|
function commandNameFromPath(filePath) {
|
|
82
83
|
const match = filePath.match(/\/application\/commands\/([^/]+)\.command\.ts$/);
|
|
83
84
|
return match?.[1];
|
|
84
85
|
}
|
|
85
|
-
exports.commandNameFromPath = commandNameFromPath;
|
|
86
86
|
function commandFeatureFromPath(filePath, featuresRoot) {
|
|
87
87
|
const escapedRoot = featuresRoot.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
88
88
|
const match = filePath.match(new RegExp(`^${escapedRoot}/([^/]+)/application/commands/index\\.ts$`));
|
|
89
89
|
return match?.[1];
|
|
90
90
|
}
|
|
91
|
-
exports.commandFeatureFromPath = commandFeatureFromPath;
|
|
92
91
|
function createCommandTs(className) {
|
|
93
92
|
return `import { BaseCommand } from '@soapjs/soap/cqrs';
|
|
94
93
|
|
|
@@ -112,7 +111,7 @@ export class ${className}Command extends BaseCommand<${className}Result> {
|
|
|
112
111
|
`;
|
|
113
112
|
}
|
|
114
113
|
function createCommandHandlerTs(className, kebabName) {
|
|
115
|
-
return `import { Result } from '@soapjs/soap';
|
|
114
|
+
return `import { Result } from '@soapjs/soap/common';
|
|
116
115
|
import { CommandHandler as SoapCommandHandler } from '@soapjs/soap/cqrs';
|
|
117
116
|
import { CommandHandler } from '@soapjs/soap-express/cqrs';
|
|
118
117
|
import { ${className}Command, ${className}Result } from './${kebabName}.command';
|
|
@@ -142,7 +141,7 @@ export class ${className}Handler implements SoapCommandHandler<${className}Comma
|
|
|
142
141
|
function createCommandHandlerSpecTs(className, kebabName) {
|
|
143
142
|
return `import assert from 'node:assert/strict';
|
|
144
143
|
import test from 'node:test';
|
|
145
|
-
import { Result } from '@soapjs/soap';
|
|
144
|
+
import { Result } from '@soapjs/soap/common';
|
|
146
145
|
import { InMemoryCommandBus } from '@soapjs/soap/cqrs';
|
|
147
146
|
import { ${className}Command, ${className}Result } from './${kebabName}.command';
|
|
148
147
|
import { ${className}Handler, ${className}Repository } from './${kebabName}.handler';
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createEntityFiles =
|
|
6
|
+
exports.createEntityFiles = createEntityFiles;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const naming_1 = require("../../templates/naming");
|
|
9
9
|
function createEntityFiles(plan) {
|
|
@@ -25,7 +25,6 @@ function createEntityFiles(plan) {
|
|
|
25
25
|
},
|
|
26
26
|
];
|
|
27
27
|
}
|
|
28
|
-
exports.createEntityFiles = createEntityFiles;
|
|
29
28
|
function createEntityTs(className) {
|
|
30
29
|
return `import { randomUUID } from 'crypto';
|
|
31
30
|
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createEventFiles =
|
|
6
|
+
exports.createEventFiles = createEventFiles;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const naming_1 = require("../../templates/naming");
|
|
9
9
|
function createEventFiles(plan) {
|
|
@@ -28,7 +28,6 @@ function createEventFiles(plan) {
|
|
|
28
28
|
}
|
|
29
29
|
return files;
|
|
30
30
|
}
|
|
31
|
-
exports.createEventFiles = createEventFiles;
|
|
32
31
|
function createEventTs(className, eventName) {
|
|
33
32
|
return `import { BaseDomainEvent } from '../../../../common/events/domain-event';
|
|
34
33
|
|
|
@@ -3,7 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.createQueryFiles = createQueryFiles;
|
|
7
|
+
exports.createQueryIndexFile = createQueryIndexFile;
|
|
8
|
+
exports.queryNameFromPath = queryNameFromPath;
|
|
9
|
+
exports.queryFeatureFromPath = queryFeatureFromPath;
|
|
7
10
|
const path_1 = __importDefault(require("path"));
|
|
8
11
|
const naming_1 = require("../../templates/naming");
|
|
9
12
|
function createQueryFiles(plan) {
|
|
@@ -31,7 +34,6 @@ function createQueryFiles(plan) {
|
|
|
31
34
|
},
|
|
32
35
|
];
|
|
33
36
|
}
|
|
34
|
-
exports.createQueryFiles = createQueryFiles;
|
|
35
37
|
function createQueryIndexFile(feature, featuresRoot, queryNames) {
|
|
36
38
|
const featureNames = (0, naming_1.createNameVariants)(feature);
|
|
37
39
|
const uniqueQueryNames = Array.from(new Set(queryNames)).sort();
|
|
@@ -52,18 +54,15 @@ function createQueryIndexFile(feature, featuresRoot, queryNames) {
|
|
|
52
54
|
`,
|
|
53
55
|
};
|
|
54
56
|
}
|
|
55
|
-
exports.createQueryIndexFile = createQueryIndexFile;
|
|
56
57
|
function queryNameFromPath(filePath) {
|
|
57
58
|
const match = filePath.match(/\/application\/queries\/([^/]+)\.query\.ts$/);
|
|
58
59
|
return match?.[1];
|
|
59
60
|
}
|
|
60
|
-
exports.queryNameFromPath = queryNameFromPath;
|
|
61
61
|
function queryFeatureFromPath(filePath, featuresRoot) {
|
|
62
62
|
const escapedRoot = featuresRoot.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
63
63
|
const match = filePath.match(new RegExp(`^${escapedRoot}/([^/]+)/application/queries/index\\.ts$`));
|
|
64
64
|
return match?.[1];
|
|
65
65
|
}
|
|
66
|
-
exports.queryFeatureFromPath = queryFeatureFromPath;
|
|
67
66
|
function createQueryTs(className) {
|
|
68
67
|
return `import { BaseQuery } from '@soapjs/soap/cqrs';
|
|
69
68
|
|
|
@@ -87,7 +86,7 @@ export class ${className}Query extends BaseQuery<${className}Result> {
|
|
|
87
86
|
`;
|
|
88
87
|
}
|
|
89
88
|
function createQueryHandlerTs(className, kebabName) {
|
|
90
|
-
return `import { Result } from '@soapjs/soap';
|
|
89
|
+
return `import { Result } from '@soapjs/soap/common';
|
|
91
90
|
import { QueryHandler as SoapQueryHandler } from '@soapjs/soap/cqrs';
|
|
92
91
|
import { QueryHandler } from '@soapjs/soap-express/cqrs';
|
|
93
92
|
import { ${className}Query, ${className}Result } from './${kebabName}.query';
|
|
@@ -117,7 +116,7 @@ export class ${className}Handler implements SoapQueryHandler<${className}Query,
|
|
|
117
116
|
function createQueryHandlerSpecTs(className, kebabName) {
|
|
118
117
|
return `import assert from 'node:assert/strict';
|
|
119
118
|
import test from 'node:test';
|
|
120
|
-
import { Result } from '@soapjs/soap';
|
|
119
|
+
import { Result } from '@soapjs/soap/common';
|
|
121
120
|
import { InMemoryQueryBus } from '@soapjs/soap/cqrs';
|
|
122
121
|
import { ${className}Query, ${className}Result } from './${kebabName}.query';
|
|
123
122
|
import { ${className}Handler, ${className}Repository } from './${kebabName}.handler';
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createRepositoryFiles =
|
|
6
|
+
exports.createRepositoryFiles = createRepositoryFiles;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const naming_1 = require("../../templates/naming");
|
|
9
9
|
function createRepositoryFiles(plan) {
|
|
@@ -63,9 +63,8 @@ function createRepositoryFiles(plan) {
|
|
|
63
63
|
},
|
|
64
64
|
];
|
|
65
65
|
}
|
|
66
|
-
exports.createRepositoryFiles = createRepositoryFiles;
|
|
67
66
|
function createRepositoryPortTs(className) {
|
|
68
|
-
return `import { ReadWriteRepository } from '@soapjs/soap';
|
|
67
|
+
return `import { ReadWriteRepository } from '@soapjs/soap/data';
|
|
69
68
|
|
|
70
69
|
export interface ${className}Record {
|
|
71
70
|
id: string;
|
|
@@ -102,7 +101,7 @@ function createMapperTs(names, db) {
|
|
|
102
101
|
const persistenceImport = db === "mongo"
|
|
103
102
|
? `import { ${names.pascalName}Model } from './${names.kebabName}.model';`
|
|
104
103
|
: `import { ${names.pascalName}Row } from './${names.kebabName}.row';`;
|
|
105
|
-
return `import { Mapper } from '@soapjs/soap';
|
|
104
|
+
return `import { Mapper } from '@soapjs/soap/data';
|
|
106
105
|
import { ${names.pascalName}Record } from '../application/ports/${names.kebabName}-repository.port';
|
|
107
106
|
${persistenceImport}
|
|
108
107
|
|
|
@@ -132,7 +131,7 @@ import {
|
|
|
132
131
|
DatabaseSessionRegistry,
|
|
133
132
|
ReadWriteRepository,
|
|
134
133
|
TransactionScope,
|
|
135
|
-
} from '@soapjs/soap';
|
|
134
|
+
} from '@soapjs/soap/data';
|
|
136
135
|
import { MongoSource } from '@soapjs/soap-node-mongo';
|
|
137
136
|
import { ${names.pascalName}Record } from '../application/ports/${names.kebabName}-repository.port';
|
|
138
137
|
import { ${names.camelName}Mapper } from './${names.kebabName}.mapper';
|
|
@@ -205,7 +204,7 @@ import {
|
|
|
205
204
|
DatabaseSessionRegistry,
|
|
206
205
|
ReadWriteRepository,
|
|
207
206
|
TransactionScope,
|
|
208
|
-
} from '@soapjs/soap';
|
|
207
|
+
} from '@soapjs/soap/data';
|
|
209
208
|
import { SqlDataSource } from '@soapjs/soap-node-sql';
|
|
210
209
|
import { ${names.pascalName}Record } from '../application/ports/${names.kebabName}-repository.port';
|
|
211
210
|
import { ${names.camelName}Mapper } from './${names.kebabName}.mapper';
|
|
@@ -3,7 +3,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.createResourceEntry = createResourceEntry;
|
|
7
|
+
exports.createResourceAddPlanningSummary = createResourceAddPlanningSummary;
|
|
8
|
+
exports.formatResourceAddPlanningSummary = formatResourceAddPlanningSummary;
|
|
9
|
+
exports.createResourceFiles = createResourceFiles;
|
|
10
|
+
exports.createResourcesFile = createResourcesFile;
|
|
11
|
+
exports.createFeaturesIndexFile = createFeaturesIndexFile;
|
|
12
|
+
exports.createControllersFile = createControllersFile;
|
|
13
|
+
exports.parseCrudRouteMatrix = parseCrudRouteMatrix;
|
|
14
|
+
exports.parseResourceFieldDefinitions = parseResourceFieldDefinitions;
|
|
15
|
+
exports.createAuthDecorator = createAuthDecorator;
|
|
16
|
+
exports.createRouteApiDocOptions = createRouteApiDocOptions;
|
|
7
17
|
const path_1 = __importDefault(require("path"));
|
|
8
18
|
const errors_1 = require("../../core/errors");
|
|
9
19
|
const auth_policy_1 = require("../../config/auth-policy");
|
|
@@ -23,7 +33,6 @@ function createResourceEntry(plan) {
|
|
|
23
33
|
generatedAt: new Date().toISOString(),
|
|
24
34
|
};
|
|
25
35
|
}
|
|
26
|
-
exports.createResourceEntry = createResourceEntry;
|
|
27
36
|
function createResourceAddPlanningSummary(plan) {
|
|
28
37
|
const names = (0, naming_1.createNameVariants)(plan.name);
|
|
29
38
|
const itemName = singularizeResourceName(names.kebabName);
|
|
@@ -65,7 +74,6 @@ function createResourceAddPlanningSummary(plan) {
|
|
|
65
74
|
steps,
|
|
66
75
|
};
|
|
67
76
|
}
|
|
68
|
-
exports.createResourceAddPlanningSummary = createResourceAddPlanningSummary;
|
|
69
77
|
function formatResourceAddPlanningSummary(summary) {
|
|
70
78
|
const lines = [
|
|
71
79
|
`Resource plan: ${summary.resource} (${summary.architecture})`,
|
|
@@ -73,7 +81,6 @@ function formatResourceAddPlanningSummary(summary) {
|
|
|
73
81
|
];
|
|
74
82
|
return lines.join("\n");
|
|
75
83
|
}
|
|
76
|
-
exports.formatResourceAddPlanningSummary = formatResourceAddPlanningSummary;
|
|
77
84
|
function singularizeResourceName(name) {
|
|
78
85
|
if (name.endsWith("ies")) {
|
|
79
86
|
return `${name.slice(0, -3)}y`;
|
|
@@ -162,7 +169,6 @@ function createResourceFiles(plan) {
|
|
|
162
169
|
];
|
|
163
170
|
return files;
|
|
164
171
|
}
|
|
165
|
-
exports.createResourceFiles = createResourceFiles;
|
|
166
172
|
function createCqrsCrudResourceFiles(plan) {
|
|
167
173
|
const featureNames = (0, naming_1.createNameVariants)(plan.name);
|
|
168
174
|
const itemNames = (0, naming_1.createNameVariants)(singularizeResourceName(featureNames.kebabName));
|
|
@@ -461,7 +467,7 @@ export class ${action.classBase}Query extends BaseQuery<${action.classBase}Resul
|
|
|
461
467
|
}
|
|
462
468
|
function createCqrsCrudCommandHandlerTs(action, itemNames) {
|
|
463
469
|
const repositoryCall = createCqrsCrudCommandRepositoryCall(action, itemNames);
|
|
464
|
-
return `import { Result } from '@soapjs/soap';
|
|
470
|
+
return `import { Result } from '@soapjs/soap/common';
|
|
465
471
|
import { CommandHandler as SoapCommandHandler } from '@soapjs/soap/cqrs';
|
|
466
472
|
import { CommandHandler } from '@soapjs/soap-express/cqrs';
|
|
467
473
|
import { ${itemNames.pascalName}Repository } from '../ports/${itemNames.kebabName}-repository.port';
|
|
@@ -484,7 +490,7 @@ ${repositoryCall}
|
|
|
484
490
|
}
|
|
485
491
|
function createCqrsCrudQueryHandlerTs(action, itemNames) {
|
|
486
492
|
const repositoryCall = createCqrsCrudQueryRepositoryCall(action);
|
|
487
|
-
return `import { Result } from '@soapjs/soap';
|
|
493
|
+
return `import { Result } from '@soapjs/soap/common';
|
|
488
494
|
import { QueryHandler as SoapQueryHandler } from '@soapjs/soap/cqrs';
|
|
489
495
|
import { QueryHandler } from '@soapjs/soap-express/cqrs';
|
|
490
496
|
import { ${itemNames.pascalName}Repository } from '../ports/${itemNames.kebabName}-repository.port';
|
|
@@ -535,7 +541,7 @@ function createCqrsCrudQueryRepositoryCall(action) {
|
|
|
535
541
|
function createCqrsCrudCommandSpecTs(action) {
|
|
536
542
|
return `import assert from 'node:assert/strict';
|
|
537
543
|
import test from 'node:test';
|
|
538
|
-
import { Result } from '@soapjs/soap';
|
|
544
|
+
import { Result } from '@soapjs/soap/common';
|
|
539
545
|
import { InMemoryCommandBus } from '@soapjs/soap/cqrs';
|
|
540
546
|
import { ${action.classBase}Command, ${action.classBase}Result } from './${action.name}.command';
|
|
541
547
|
import { ${action.classBase}Handler } from './${action.name}.handler';
|
|
@@ -553,7 +559,7 @@ test('${action.classBase}Command can be dispatched through a CQRS command bus',
|
|
|
553
559
|
function createCqrsCrudQuerySpecTs(action) {
|
|
554
560
|
return `import assert from 'node:assert/strict';
|
|
555
561
|
import test from 'node:test';
|
|
556
|
-
import { Result } from '@soapjs/soap';
|
|
562
|
+
import { Result } from '@soapjs/soap/common';
|
|
557
563
|
import { InMemoryQueryBus } from '@soapjs/soap/cqrs';
|
|
558
564
|
import { ${action.classBase}Query, ${action.classBase}Result } from './${action.name}.query';
|
|
559
565
|
import { ${action.classBase}Handler } from './${action.name}.handler';
|
|
@@ -657,7 +663,6 @@ function createResourcesFile(resources, featuresRoot) {
|
|
|
657
663
|
content: (0, project_plan_1.createResourcesTs)(registrations),
|
|
658
664
|
};
|
|
659
665
|
}
|
|
660
|
-
exports.createResourcesFile = createResourcesFile;
|
|
661
666
|
function createFeaturesIndexFile(resources, authCapabilities = []) {
|
|
662
667
|
const exports = [];
|
|
663
668
|
if (authCapabilities.includes("jwt") || authCapabilities.includes("local") || authCapabilities.includes("api-key")) {
|
|
@@ -673,7 +678,6 @@ function createFeaturesIndexFile(resources, authCapabilities = []) {
|
|
|
673
678
|
content: exports.length > 0 ? `${exports.join("\n")}\n` : "export {};\n",
|
|
674
679
|
};
|
|
675
680
|
}
|
|
676
|
-
exports.createFeaturesIndexFile = createFeaturesIndexFile;
|
|
677
681
|
function createControllersFile(resources, featuresRoot, authCapabilities = [], routeControllerIndexes = [], mainControllerResources = resources.map((resource) => resource.name)) {
|
|
678
682
|
const controllers = [];
|
|
679
683
|
const routeControllerIndexSet = new Set(routeControllerIndexes);
|
|
@@ -709,7 +713,6 @@ function createControllersFile(resources, featuresRoot, authCapabilities = [], r
|
|
|
709
713
|
content: (0, project_plan_1.createControllersTs)(controllers),
|
|
710
714
|
};
|
|
711
715
|
}
|
|
712
|
-
exports.createControllersFile = createControllersFile;
|
|
713
716
|
function createRegularCrudActions(itemNames, collectionNames, matrix = {}) {
|
|
714
717
|
return [
|
|
715
718
|
{
|
|
@@ -803,7 +806,6 @@ function parseCrudRouteMatrix(values) {
|
|
|
803
806
|
}
|
|
804
807
|
return matrix;
|
|
805
808
|
}
|
|
806
|
-
exports.parseCrudRouteMatrix = parseCrudRouteMatrix;
|
|
807
809
|
function isCrudOperation(value) {
|
|
808
810
|
return value === "list" || value === "get" || value === "create" || value === "update" || value === "delete";
|
|
809
811
|
}
|
|
@@ -1142,7 +1144,7 @@ function createRegularCrudUseCaseTs(action, itemNames) {
|
|
|
1142
1144
|
`;
|
|
1143
1145
|
const executeInput = action.kind === "list" ? "" : `input: ${inputInterface}`;
|
|
1144
1146
|
const repositoryCall = createRegularCrudRepositoryCall(action.kind, itemNames);
|
|
1145
|
-
return `import { Injectable, Result, UseCase } from '@soapjs/soap';
|
|
1147
|
+
return `import { Injectable, Result, UseCase } from '@soapjs/soap/common';
|
|
1146
1148
|
import { ${itemNames.pascalName}Props } from '../../domain/${itemNames.kebabName}.entity';
|
|
1147
1149
|
import { ${itemNames.pascalName}Repository } from '../ports/${itemNames.kebabName}-repository.port';
|
|
1148
1150
|
|
|
@@ -1470,7 +1472,6 @@ ${props}
|
|
|
1470
1472
|
function parseResourceFieldDefinitions(values) {
|
|
1471
1473
|
return normalizeResourceFields((values ?? []).map(parseResourceFieldDefinition));
|
|
1472
1474
|
}
|
|
1473
|
-
exports.parseResourceFieldDefinitions = parseResourceFieldDefinitions;
|
|
1474
1475
|
function parseResourceFieldDefinition(value) {
|
|
1475
1476
|
const [name, type, requiredToken] = value.split(":");
|
|
1476
1477
|
if (!name || !/^[A-Za-z][A-Za-z0-9_]*$/.test(name)) {
|
|
@@ -2003,7 +2004,6 @@ function createAuthDecorator(auth, zone, policy) {
|
|
|
2003
2004
|
const policyArgument = (0, auth_policy_1.createAuthPolicyArgument)(policy);
|
|
2004
2005
|
return policyArgument ? `@Auth('${strategy}', ${policyArgument})` : `@Auth('${strategy}')`;
|
|
2005
2006
|
}
|
|
2006
|
-
exports.createAuthDecorator = createAuthDecorator;
|
|
2007
2007
|
function createRouteApiDocOptions(input) {
|
|
2008
2008
|
const security = input.auth === "none"
|
|
2009
2009
|
? ""
|
|
@@ -2018,7 +2018,6 @@ function createRouteApiDocOptions(input) {
|
|
|
2018
2018
|
},
|
|
2019
2019
|
}`;
|
|
2020
2020
|
}
|
|
2021
|
-
exports.createRouteApiDocOptions = createRouteApiDocOptions;
|
|
2022
2021
|
function createFeatureIndexTs(name) {
|
|
2023
2022
|
const names = (0, naming_1.createNameVariants)(name);
|
|
2024
2023
|
return `export * from './api/${names.kebabName}.controller';
|
|
@@ -3,7 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.routeMethods = void 0;
|
|
7
|
+
exports.createRouteEntry = createRouteEntry;
|
|
8
|
+
exports.createRouteControllerFile = createRouteControllerFile;
|
|
9
|
+
exports.createRouteControllersIndexFile = createRouteControllersIndexFile;
|
|
10
|
+
exports.createRouteContractFile = createRouteContractFile;
|
|
11
|
+
exports.routeControllerNameFromPath = routeControllerNameFromPath;
|
|
12
|
+
exports.routeControllerIndexResourceFromPath = routeControllerIndexResourceFromPath;
|
|
7
13
|
const path_1 = __importDefault(require("path"));
|
|
8
14
|
const errors_1 = require("../../core/errors");
|
|
9
15
|
const naming_1 = require("../../templates/naming");
|
|
@@ -33,7 +39,6 @@ function createRouteEntry(plan) {
|
|
|
33
39
|
generatedAt: new Date().toISOString(),
|
|
34
40
|
};
|
|
35
41
|
}
|
|
36
|
-
exports.createRouteEntry = createRouteEntry;
|
|
37
42
|
function createRouteControllerFile(plan) {
|
|
38
43
|
const resourceNames = (0, naming_1.createNameVariants)(plan.resource.name);
|
|
39
44
|
const routeNames = (0, naming_1.createNameVariants)(plan.name);
|
|
@@ -45,7 +50,6 @@ function createRouteControllerFile(plan) {
|
|
|
45
50
|
content: createRouteControllerTs(plan),
|
|
46
51
|
};
|
|
47
52
|
}
|
|
48
|
-
exports.createRouteControllerFile = createRouteControllerFile;
|
|
49
53
|
function createRouteControllersIndexFile(resource, featuresRoot, routeNames) {
|
|
50
54
|
const resourceNames = (0, naming_1.createNameVariants)(resource.name);
|
|
51
55
|
const uniqueRouteNames = Array.from(new Set(routeNames)).sort();
|
|
@@ -70,7 +74,6 @@ ${controllers}
|
|
|
70
74
|
`,
|
|
71
75
|
};
|
|
72
76
|
}
|
|
73
|
-
exports.createRouteControllersIndexFile = createRouteControllersIndexFile;
|
|
74
77
|
function createRouteContractFile(plan) {
|
|
75
78
|
const resourceNames = (0, naming_1.createNameVariants)(plan.resource.name);
|
|
76
79
|
const routeNames = (0, naming_1.createNameVariants)(plan.name);
|
|
@@ -82,7 +85,6 @@ function createRouteContractFile(plan) {
|
|
|
82
85
|
content: createRouteContractTs(routeNames.pascalName, routeNames.camelName, plan.method, plan.contracts),
|
|
83
86
|
};
|
|
84
87
|
}
|
|
85
|
-
exports.createRouteContractFile = createRouteContractFile;
|
|
86
88
|
function routeControllerNameFromPath(filePath) {
|
|
87
89
|
const match = filePath.match(/\/api\/([^/]+)\.controller\.ts$/);
|
|
88
90
|
const name = match?.[1];
|
|
@@ -91,13 +93,11 @@ function routeControllerNameFromPath(filePath) {
|
|
|
91
93
|
}
|
|
92
94
|
return name;
|
|
93
95
|
}
|
|
94
|
-
exports.routeControllerNameFromPath = routeControllerNameFromPath;
|
|
95
96
|
function routeControllerIndexResourceFromPath(filePath, featuresRoot) {
|
|
96
97
|
const escapedRoot = featuresRoot.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
97
98
|
const match = filePath.match(new RegExp(`^${escapedRoot}/([^/]+)/api/\\1\\.controllers\\.ts$`));
|
|
98
99
|
return match?.[1];
|
|
99
100
|
}
|
|
100
|
-
exports.routeControllerIndexResourceFromPath = routeControllerIndexResourceFromPath;
|
|
101
101
|
function createRouteControllerTs(plan) {
|
|
102
102
|
const resourceNames = (0, naming_1.createNameVariants)(plan.resource.name);
|
|
103
103
|
const routeNames = (0, naming_1.createNameVariants)(plan.name);
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createSocketFiles =
|
|
6
|
+
exports.createSocketFiles = createSocketFiles;
|
|
7
7
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const errors_1 = require("../../core/errors");
|
|
@@ -27,7 +27,6 @@ async function createSocketFiles(root, plan) {
|
|
|
27
27
|
}),
|
|
28
28
|
];
|
|
29
29
|
}
|
|
30
|
-
exports.createSocketFiles = createSocketFiles;
|
|
31
30
|
function createSocketTs(className, exportName, eventName, auth) {
|
|
32
31
|
const authComment = auth === "none" ? "" : "\n // TODO: validate socket auth before handling this message.\n";
|
|
33
32
|
return `import { SocketMessage, SocketServer } from '@soapjs/soap-node-socket';
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createUseCaseFiles =
|
|
6
|
+
exports.createUseCaseFiles = createUseCaseFiles;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const naming_1 = require("../../templates/naming");
|
|
9
9
|
function createUseCaseFiles(plan) {
|
|
@@ -25,9 +25,8 @@ function createUseCaseFiles(plan) {
|
|
|
25
25
|
},
|
|
26
26
|
];
|
|
27
27
|
}
|
|
28
|
-
exports.createUseCaseFiles = createUseCaseFiles;
|
|
29
28
|
function createUseCaseTs(className, constantName) {
|
|
30
|
-
return `import { Inject, Injectable, Result, UseCase } from '@soapjs/soap';
|
|
29
|
+
return `import { Inject, Injectable, Result, UseCase } from '@soapjs/soap/common';
|
|
31
30
|
|
|
32
31
|
export interface ${className}Input {
|
|
33
32
|
[key: string]: unknown;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.registerCheckCommand =
|
|
6
|
+
exports.registerCheckCommand = registerCheckCommand;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const load_soap_config_1 = require("../../config/load-soap-config");
|
|
@@ -30,7 +30,6 @@ function registerCheckCommand(program) {
|
|
|
30
30
|
context.output.success(`Route registry is valid (${config.registry.routes.length} routes).`);
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
|
-
exports.registerCheckCommand = registerCheckCommand;
|
|
34
33
|
function checkRoutes(config) {
|
|
35
34
|
const errors = [];
|
|
36
35
|
const routeKeys = new Map();
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.registerCreateCommand =
|
|
6
|
+
exports.registerCreateCommand = registerCreateCommand;
|
|
7
7
|
const child_process_1 = require("child_process");
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
@@ -29,7 +29,7 @@ function registerCreateCommand(program) {
|
|
|
29
29
|
.option("--db <database>", "database capability: mongo, postgres, mysql, sqlite, redis, none", collect, [])
|
|
30
30
|
.option("--auth <auth>", "auth capability: jwt, api-key, local, none", collect, [])
|
|
31
31
|
.option("--messaging <messaging>", "messaging capability: in-memory, kafka, none", collect, [])
|
|
32
|
-
.option("--telemetry <telemetry>", "telemetry capability: logs, otel-noop, none", collect, [])
|
|
32
|
+
.option("--telemetry <telemetry>", "telemetry capability: logs, otel-noop, metrics, memory, none", collect, [])
|
|
33
33
|
.option("--docs <docs>", "docs capability: openapi, none", collect, [])
|
|
34
34
|
.option("--contracts <contracts>", "contract capability: zod, none", collect, [])
|
|
35
35
|
.option("--api-client <client>", "api client capability: bruno, none", collect, [])
|
|
@@ -148,7 +148,6 @@ function registerCreateCommand(program) {
|
|
|
148
148
|
context.output.success(`Created SoapJS project at ${path_1.default.relative(context.cwd, root) || root}`);
|
|
149
149
|
});
|
|
150
150
|
}
|
|
151
|
-
exports.registerCreateCommand = registerCreateCommand;
|
|
152
151
|
function createProvidedCreateOptions(command) {
|
|
153
152
|
return {
|
|
154
153
|
framework: isCliOption(command, "framework"),
|