@thisisagile/easy 15.15.3 → 15.15.5

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.
@@ -1,4 +1,4 @@
1
- import { Enum, List, Text } from '../types';
1
+ import { Enum, IdName, List, Text } from '../types';
2
2
  import { Scope } from './Scope';
3
3
  import { App } from './App';
4
4
  export declare class UseCase extends Enum {
@@ -6,5 +6,6 @@ export declare class UseCase extends Enum {
6
6
  readonly scopes: List<Scope>;
7
7
  constructor(app: App, name: string, id?: Text, scopes?: List<Scope>);
8
8
  with(...s: Scope[]): this;
9
+ for(item: string | IdName): UseCase;
9
10
  static byScopes<U extends UseCase>(...s: Scope[]): List<U>;
10
11
  }
@@ -29,17 +29,17 @@ class UseCase extends import_types.Enum {
29
29
  this.scopes = scopes;
30
30
  }
31
31
  with(...s) {
32
- this.scopes.add(...s);
32
+ this.scopes.add(...(0, import_types.toList)(s).flatMap((s2) => s2.expand()).distinct());
33
33
  return this;
34
34
  }
35
+ for(item) {
36
+ return new UseCase(this.app, `${this.name} ${(0, import_types.isString)(item) ? item : item?.name}`, (0, import_types.kebab)(`${this.id} ${(0, import_types.isString)(item) ? item : item.id}`)).with(
37
+ ...this.scopes.map((s) => s?.for(item))
38
+ );
39
+ }
35
40
  static byScopes(...s) {
36
41
  return this.filter((u) => u.scopes.some((us) => (0, import_types.isIn)(us, s)));
37
42
  }
38
- // static readonly Main = new UseCase(App.Main, 'Main');
39
- // static readonly Login = new UseCase(App.Main, 'Login').with(Scope.Basic, Scope.Auth);
40
- // static readonly Logout = new UseCase(App.Main, 'Logout').with(Scope.Basic, Scope.Auth);
41
- // static readonly ForgotPassword = new UseCase(App.Main, 'Forgot password').with(Scope.Basic, Scope.Auth);
42
- // static readonly ChangePassword = new UseCase(App.Main, 'Change password').with(Scope.Basic, Scope.Auth);
43
43
  }
44
44
  // Annotate the CommonJS export names for ESM import in node:
45
45
  0 && (module.exports = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/process/UseCase.ts"],"sourcesContent":["import { Enum, isIn, List, Text, text, toList } from '../types';\nimport { Scope } from './Scope';\nimport { App } from './App';\n\nexport class UseCase extends Enum {\n constructor(readonly app: App, name: string, id: Text = text(name).kebab, readonly scopes: List<Scope> = toList<Scope>()) {\n super(name, id.toString());\n }\n\n with(...s: Scope[]): this {\n this.scopes.add(...s);\n return this;\n }\n\n static byScopes<U extends UseCase>(...s: Scope[]): List<U> {\n return this.filter(u => u.scopes.some(us => isIn(us, s)));\n }\n\n // static readonly Main = new UseCase(App.Main, 'Main');\n // static readonly Login = new UseCase(App.Main, 'Login').with(Scope.Basic, Scope.Auth);\n // static readonly Logout = new UseCase(App.Main, 'Logout').with(Scope.Basic, Scope.Auth);\n // static readonly ForgotPassword = new UseCase(App.Main, 'Forgot password').with(Scope.Basic, Scope.Auth);\n // static readonly ChangePassword = new UseCase(App.Main, 'Change password').with(Scope.Basic, Scope.Auth);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAqD;AAI9C,MAAM,gBAAgB,kBAAK;AAAA,EAChC,YAAqB,KAAU,MAAc,SAAW,mBAAK,IAAI,EAAE,OAAgB,aAAsB,qBAAc,GAAG;AACxH,UAAM,MAAM,GAAG,SAAS,CAAC;AADN;AAA8D;AAAA,EAEnF;AAAA,EAEA,QAAQ,GAAkB;AACxB,SAAK,OAAO,IAAI,GAAG,CAAC;AACpB,WAAO;AAAA,EACT;AAAA,EAEA,OAAO,YAA+B,GAAqB;AACzD,WAAO,KAAK,OAAO,OAAK,EAAE,OAAO,KAAK,YAAM,mBAAK,IAAI,CAAC,CAAC,CAAC;AAAA,EAC1D;AAAA;AAAA;AAAA;AAAA;AAAA;AAOF;","names":[]}
1
+ {"version":3,"sources":["../../src/process/UseCase.ts"],"sourcesContent":["import { Enum, IdName, isIn, isString, kebab, List, Text, text, toList } from '../types';\nimport { Scope } from './Scope';\nimport { App } from './App';\n\nexport class UseCase extends Enum {\n constructor(readonly app: App, name: string, id: Text = text(name).kebab, readonly scopes: List<Scope> = toList<Scope>()) {\n super(name, id.toString());\n }\n\n with(...s: Scope[]): this {\n this.scopes.add(...toList(s).flatMap(s => s.expand()).distinct());\n return this;\n }\n\n for(item: string | IdName): UseCase {\n return new UseCase(this.app, `${this.name} ${isString(item) ? item : item?.name}`, kebab(`${this.id} ${isString(item) ? item : item.id}`)).with(\n ...this.scopes.map(s => s?.for(item))\n );\n }\n\n static byScopes<U extends UseCase>(...s: Scope[]): List<U> {\n return this.filter(u => u.scopes.some(us => isIn(us, s)));\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA8E;AAIvE,MAAM,gBAAgB,kBAAK;AAAA,EAChC,YAAqB,KAAU,MAAc,SAAW,mBAAK,IAAI,EAAE,OAAgB,aAAsB,qBAAc,GAAG;AACxH,UAAM,MAAM,GAAG,SAAS,CAAC;AADN;AAA8D;AAAA,EAEnF;AAAA,EAEA,QAAQ,GAAkB;AACxB,SAAK,OAAO,IAAI,OAAG,qBAAO,CAAC,EAAE,QAAQ,CAAAA,OAAKA,GAAE,OAAO,CAAC,EAAE,SAAS,CAAC;AAChE,WAAO;AAAA,EACT;AAAA,EAEA,IAAI,MAAgC;AAClC,WAAO,IAAI,QAAQ,KAAK,KAAK,GAAG,KAAK,IAAI,QAAI,uBAAS,IAAI,IAAI,OAAO,MAAM,IAAI,QAAI,oBAAM,GAAG,KAAK,EAAE,QAAI,uBAAS,IAAI,IAAI,OAAO,KAAK,EAAE,EAAE,CAAC,EAAE;AAAA,MACzI,GAAG,KAAK,OAAO,IAAI,OAAK,GAAG,IAAI,IAAI,CAAC;AAAA,IACtC;AAAA,EACF;AAAA,EAEA,OAAO,YAA+B,GAAqB;AACzD,WAAO,KAAK,OAAO,OAAK,EAAE,OAAO,KAAK,YAAM,mBAAK,IAAI,CAAC,CAAC,CAAC;AAAA,EAC1D;AACF;","names":["s"]}
@@ -1,5 +1,5 @@
1
1
  import "../chunk-4N72FQFX.mjs";
2
- import { Enum, isIn, text, toList } from "../types";
2
+ import { Enum, isIn, isString, kebab, text, toList } from "../types";
3
3
  class UseCase extends Enum {
4
4
  constructor(app, name, id = text(name).kebab, scopes = toList()) {
5
5
  super(name, id.toString());
@@ -7,17 +7,17 @@ class UseCase extends Enum {
7
7
  this.scopes = scopes;
8
8
  }
9
9
  with(...s) {
10
- this.scopes.add(...s);
10
+ this.scopes.add(...toList(s).flatMap((s2) => s2.expand()).distinct());
11
11
  return this;
12
12
  }
13
+ for(item) {
14
+ return new UseCase(this.app, `${this.name} ${isString(item) ? item : item?.name}`, kebab(`${this.id} ${isString(item) ? item : item.id}`)).with(
15
+ ...this.scopes.map((s) => s?.for(item))
16
+ );
17
+ }
13
18
  static byScopes(...s) {
14
19
  return this.filter((u) => u.scopes.some((us) => isIn(us, s)));
15
20
  }
16
- // static readonly Main = new UseCase(App.Main, 'Main');
17
- // static readonly Login = new UseCase(App.Main, 'Login').with(Scope.Basic, Scope.Auth);
18
- // static readonly Logout = new UseCase(App.Main, 'Logout').with(Scope.Basic, Scope.Auth);
19
- // static readonly ForgotPassword = new UseCase(App.Main, 'Forgot password').with(Scope.Basic, Scope.Auth);
20
- // static readonly ChangePassword = new UseCase(App.Main, 'Change password').with(Scope.Basic, Scope.Auth);
21
21
  }
22
22
  export {
23
23
  UseCase
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/process/UseCase.ts"],"sourcesContent":["import { Enum, isIn, List, Text, text, toList } from '../types';\nimport { Scope } from './Scope';\nimport { App } from './App';\n\nexport class UseCase extends Enum {\n constructor(readonly app: App, name: string, id: Text = text(name).kebab, readonly scopes: List<Scope> = toList<Scope>()) {\n super(name, id.toString());\n }\n\n with(...s: Scope[]): this {\n this.scopes.add(...s);\n return this;\n }\n\n static byScopes<U extends UseCase>(...s: Scope[]): List<U> {\n return this.filter(u => u.scopes.some(us => isIn(us, s)));\n }\n\n // static readonly Main = new UseCase(App.Main, 'Main');\n // static readonly Login = new UseCase(App.Main, 'Login').with(Scope.Basic, Scope.Auth);\n // static readonly Logout = new UseCase(App.Main, 'Logout').with(Scope.Basic, Scope.Auth);\n // static readonly ForgotPassword = new UseCase(App.Main, 'Forgot password').with(Scope.Basic, Scope.Auth);\n // static readonly ChangePassword = new UseCase(App.Main, 'Change password').with(Scope.Basic, Scope.Auth);\n}\n"],"mappings":";AAAA,SAAS,MAAM,MAAkB,MAAM,cAAc;AAI9C,MAAM,gBAAgB,KAAK;AAAA,EAChC,YAAqB,KAAU,MAAc,KAAW,KAAK,IAAI,EAAE,OAAgB,SAAsB,OAAc,GAAG;AACxH,UAAM,MAAM,GAAG,SAAS,CAAC;AADN;AAA8D;AAAA,EAEnF;AAAA,EAEA,QAAQ,GAAkB;AACxB,SAAK,OAAO,IAAI,GAAG,CAAC;AACpB,WAAO;AAAA,EACT;AAAA,EAEA,OAAO,YAA+B,GAAqB;AACzD,WAAO,KAAK,OAAO,OAAK,EAAE,OAAO,KAAK,QAAM,KAAK,IAAI,CAAC,CAAC,CAAC;AAAA,EAC1D;AAAA;AAAA;AAAA;AAAA;AAAA;AAOF;","names":[]}
1
+ {"version":3,"sources":["../../src/process/UseCase.ts"],"sourcesContent":["import { Enum, IdName, isIn, isString, kebab, List, Text, text, toList } from '../types';\nimport { Scope } from './Scope';\nimport { App } from './App';\n\nexport class UseCase extends Enum {\n constructor(readonly app: App, name: string, id: Text = text(name).kebab, readonly scopes: List<Scope> = toList<Scope>()) {\n super(name, id.toString());\n }\n\n with(...s: Scope[]): this {\n this.scopes.add(...toList(s).flatMap(s => s.expand()).distinct());\n return this;\n }\n\n for(item: string | IdName): UseCase {\n return new UseCase(this.app, `${this.name} ${isString(item) ? item : item?.name}`, kebab(`${this.id} ${isString(item) ? item : item.id}`)).with(\n ...this.scopes.map(s => s?.for(item))\n );\n }\n\n static byScopes<U extends UseCase>(...s: Scope[]): List<U> {\n return this.filter(u => u.scopes.some(us => isIn(us, s)));\n }\n}\n"],"mappings":";AAAA,SAAS,MAAc,MAAM,UAAU,OAAmB,MAAM,cAAc;AAIvE,MAAM,gBAAgB,KAAK;AAAA,EAChC,YAAqB,KAAU,MAAc,KAAW,KAAK,IAAI,EAAE,OAAgB,SAAsB,OAAc,GAAG;AACxH,UAAM,MAAM,GAAG,SAAS,CAAC;AADN;AAA8D;AAAA,EAEnF;AAAA,EAEA,QAAQ,GAAkB;AACxB,SAAK,OAAO,IAAI,GAAG,OAAO,CAAC,EAAE,QAAQ,CAAAA,OAAKA,GAAE,OAAO,CAAC,EAAE,SAAS,CAAC;AAChE,WAAO;AAAA,EACT;AAAA,EAEA,IAAI,MAAgC;AAClC,WAAO,IAAI,QAAQ,KAAK,KAAK,GAAG,KAAK,IAAI,IAAI,SAAS,IAAI,IAAI,OAAO,MAAM,IAAI,IAAI,MAAM,GAAG,KAAK,EAAE,IAAI,SAAS,IAAI,IAAI,OAAO,KAAK,EAAE,EAAE,CAAC,EAAE;AAAA,MACzI,GAAG,KAAK,OAAO,IAAI,OAAK,GAAG,IAAI,IAAI,CAAC;AAAA,IACtC;AAAA,EACF;AAAA,EAEA,OAAO,YAA+B,GAAqB;AACzD,WAAO,KAAK,OAAO,OAAK,EAAE,OAAO,KAAK,QAAM,KAAK,IAAI,CAAC,CAAC,CAAC;AAAA,EAC1D;AACF;","names":["s"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thisisagile/easy",
3
- "version": "15.15.3",
3
+ "version": "15.15.5",
4
4
  "description": "Straightforward library for building domain-driven microservice architectures",
5
5
  "author": "Sander Hoogendoorn",
6
6
  "license": "MIT",
@@ -33,7 +33,7 @@
33
33
  "access": "public"
34
34
  },
35
35
  "devDependencies": {
36
- "@thisisagile/easy-test": "15.15.3",
36
+ "@thisisagile/easy-test": "15.15.5",
37
37
  "@types/form-urlencoded": "^4.4.0",
38
38
  "@types/jsonwebtoken": "^9.0.2",
39
39
  "@types/luxon": "3.2.0",
@@ -1,4 +1,4 @@
1
- import { Enum, isIn, List, Text, text, toList } from '../types';
1
+ import { Enum, IdName, isIn, isString, kebab, List, Text, text, toList } from '../types';
2
2
  import { Scope } from './Scope';
3
3
  import { App } from './App';
4
4
 
@@ -8,17 +8,17 @@ export class UseCase extends Enum {
8
8
  }
9
9
 
10
10
  with(...s: Scope[]): this {
11
- this.scopes.add(...s);
11
+ this.scopes.add(...toList(s).flatMap(s => s.expand()).distinct());
12
12
  return this;
13
13
  }
14
14
 
15
+ for(item: string | IdName): UseCase {
16
+ return new UseCase(this.app, `${this.name} ${isString(item) ? item : item?.name}`, kebab(`${this.id} ${isString(item) ? item : item.id}`)).with(
17
+ ...this.scopes.map(s => s?.for(item))
18
+ );
19
+ }
20
+
15
21
  static byScopes<U extends UseCase>(...s: Scope[]): List<U> {
16
22
  return this.filter(u => u.scopes.some(us => isIn(us, s)));
17
23
  }
18
-
19
- // static readonly Main = new UseCase(App.Main, 'Main');
20
- // static readonly Login = new UseCase(App.Main, 'Login').with(Scope.Basic, Scope.Auth);
21
- // static readonly Logout = new UseCase(App.Main, 'Logout').with(Scope.Basic, Scope.Auth);
22
- // static readonly ForgotPassword = new UseCase(App.Main, 'Forgot password').with(Scope.Basic, Scope.Auth);
23
- // static readonly ChangePassword = new UseCase(App.Main, 'Change password').with(Scope.Basic, Scope.Auth);
24
24
  }