drimion 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/index.js CHANGED
@@ -219,7 +219,7 @@ function resolvePackageManager() {
219
219
  if (true) {
220
220
  return {
221
221
  __PKG_NAME__: "drimion",
222
- __PKG_VERSION__: "0.1.0",
222
+ __PKG_VERSION__: "0.1.2",
223
223
  __PKG_REPOSITORY__: "git+https://github.com/bramadl/drimion.git"
224
224
  };
225
225
  }
@@ -571,7 +571,7 @@ var { __PKG_VERSION__: __PKG_VERSION__3 } = resolvePackageManager();
571
571
  var Copier = class {
572
572
  static async copyKernel(targetPath) {
573
573
  const __dirname = path4.dirname(fileURLToPath2(import.meta.url));
574
- const source = path4.resolve(__dirname, "..", "..", "kernel");
574
+ const source = path4.resolve(__dirname, "..", "kernel");
575
575
  const sourceExists = await fs3.pathExists(source);
576
576
  if (!sourceExists) {
577
577
  throw new Error(
@@ -8,7 +8,15 @@ import { DomainError } from "../helpers";
8
8
  * @throws {DomainError} If the event name does not contain a colon separator.
9
9
  */
10
10
  export const ValidateEventName = (eventName: string): void => {
11
- if (!eventName.includes(":")) {
11
+ if (typeof eventName !== "string") {
12
+ throw new DomainError(`Invalid event name. Expected a string.`, {
13
+ context: "DomainEvent",
14
+ });
15
+ }
16
+
17
+ const parts = eventName.split(":");
18
+
19
+ if (parts.length !== 2 || parts[0]?.length === 0 || parts[1]?.length === 0) {
12
20
  throw new DomainError(
13
21
  `Invalid event name "${eventName}". ` +
14
22
  'Event names must follow the pattern "context:EventName" ' +
@@ -16,4 +24,14 @@ export const ValidateEventName = (eventName: string): void => {
16
24
  { context: "DomainEvent" },
17
25
  );
18
26
  }
27
+
28
+ const validPattern = /^[a-z][a-z0-9-]*:[a-z][a-z0-9-]*$/;
29
+ if (!validPattern.test(eventName)) {
30
+ throw new DomainError(
31
+ `Invalid event name "${eventName}". ` +
32
+ "Context and event name must only contain lowercase letters, numbers, and hyphens " +
33
+ '(e.g., "order:placed", "user:email-changed").',
34
+ { context: "DomainEvent" },
35
+ );
36
+ }
19
37
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drimion",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Headless DDD primitives CLI for TypeScript — own your domain",
5
5
  "keywords": [
6
6
  "ddd",